{"version":3,"file":"ReviewCardPurchase.DN84XMsx.mjs","names":["React.useRef","React.useState","__esmMin","ce","window","init_ssg_sandbox_shims","c","init_jsx_runtime","init_npm_react_18_3_1","p","de","_e","addPropertyControls","RenderTarget","init_framer_DKgW_P28","ControlType","getShopUi","shopUi","initialize","shopify","reject","client","resolve","script","sdkUrl","error","applyCartColors","frames","apply","doc","sheet","styleFrame","event","scan","frame","observer","ReviewCardPurchase","ref","ready","setReady","failed","setFailed","canvas","stopStylingCart","node","disposed","product","ui","productId","style","previewPrice","init_ReviewCardPurchase"],"sources":["https:/framerusercontent.com/modules/NodL2ba4zorTWfVuldVE/oxKfQmCTQ5ZqTRKIZdCg/ReviewCardPurchase.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{RenderTarget,addPropertyControls,ControlType}from\"framer\";const sdkUrl=\"https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js\";let shopUi;function getShopUi(){if(!shopUi){shopUi=new Promise((resolve,reject)=>{const initialize=()=>{const shopify=window.ShopifyBuy;if(!shopify?.UI){reject(new Error(\"Shopify cart could not load\"));return;}const client=shopify.buildClient({domain:\"wx2gzw-26.myshopify.com\",storefrontAccessToken:\"9cbcee3080ec8af267e7fa8166ce16c8\"});shopify.UI.onReady(client).then(resolve,reject);};if(window.ShopifyBuy?.UI)initialize();else{const script=document.createElement(\"script\");script.src=sdkUrl;script.async=true;script.onload=initialize;script.onerror=()=>{script.remove();reject(new Error(\"Shopify cart could not load\"));};document.head.appendChild(script);}}).catch(error=>{shopUi=undefined;throw error;});}return shopUi;}function applyCartColors(){const css=`\n        .shopify-buy__cart .shopify-buy__btn,\n        .shopify-buy__cart-toggle {\n            background-color: #062F31 !important;\n            color: white !important;\n        }\n        .shopify-buy__cart .shopify-buy__btn:hover,\n        .shopify-buy__cart .shopify-buy__btn:focus,\n        .shopify-buy__cart-toggle:hover,\n        .shopify-buy__cart-toggle:focus {\n            background-color: #0A5053 !important;\n        }\n    `;const frames=new Set;const apply=doc=>{if(!doc?.head||doc.getElementById(\"ratelee-shopify-cart-colors\"))return;const sheet=doc.createElement(\"style\");sheet.id=\"ratelee-shopify-cart-colors\";sheet.textContent=css;doc.head.appendChild(sheet);};const styleFrame=event=>apply(event.currentTarget.contentDocument);const scan=()=>{document.querySelectorAll(\"iframe.shopify-buy-frame--cart, iframe.shopify-buy-frame--toggle, .shopify-buy-frame--cart iframe, .shopify-buy-frame--toggle iframe, iframe[name^='frame-cart'], iframe[name^='frame-toggle']\").forEach(frame=>{if(!frames.has(frame)){frames.add(frame);frame.addEventListener(\"load\",styleFrame);}apply(frame.contentDocument);});};apply(document);const observer=new MutationObserver(scan);observer.observe(document.body,{childList:true,subtree:true});scan();return()=>{observer.disconnect();frames.forEach(frame=>frame.removeEventListener(\"load\",styleFrame));};}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function ReviewCardPurchase({style,productId=\"15531633803377\",previewPrice=\"NZ$20.00\"}){const ref=React.useRef(null);const[ready,setReady]=React.useState(false);const[failed,setFailed]=React.useState(false);const canvas=RenderTarget.current()===RenderTarget.canvas;React.useEffect(()=>{if(canvas||!ref.current)return;const stopStylingCart=applyCartColors();const node=document.createElement(\"div\");ref.current.appendChild(node);let disposed=false;let product;getShopUi().then(async ui=>{if(disposed)return;product=await ui.createComponent(\"product\",{id:productId,node,moneyFormat:\"NZ%24%7B%7Bamount%7D%7D\",options:{product:{buttonDestination:\"cart\",contents:{img:false,imgWithCarousel:false,title:false,price:true,description:false,button:false,quantity:false,buttonWithQuantity:true},styles:{product:{\"text-align\":\"left\",\"@media (min-width: 601px)\":{\"max-width\":\"100%\",\"margin-left\":\"0\",\"margin-bottom\":\"0\"}},button:{\"font-family\":\"Inter, sans-serif\",\"background-color\":\"#062F31\",\"border-radius\":\"8px\",\":hover\":{\"background-color\":\"#124846\"},\":focus\":{\"background-color\":\"#124846\"}}},text:{button:\"Add to cart\"}},cart:{contents:{note:true},text:{total:\"Subtotal\",button:\"Checkout\",noteDescription:\"Paste your Google review link so we can set up your order before shipping.\"},styles:{button:{\"background-color\":\"#062F31\",\":hover\":{\"background-color\":\"#0a5053\"},\":focus\":{\"background-color\":\"#0a5053\"}}}},toggle:{styles:{toggle:{\"background-color\":\"#062F31\",\":hover\":{\"background-color\":\"#0a5053\"},\":focus\":{\"background-color\":\"#0a5053\"}}}}}});if(disposed)product?.destroy?.();else setReady(true);}).catch(()=>{if(!disposed)setFailed(true);});return()=>{disposed=true;stopStylingCart();product?.destroy?.();node.remove();};},[canvas,productId]);return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",minHeight:84,...style},children:[/*#__PURE__*/_jsx(\"div\",{ref:ref}),!ready&&!failed&&/*#__PURE__*/_jsxs(\"div\",{style:{font:\"15px Inter, sans-serif\",color:\"#062F31\"},children:[/*#__PURE__*/_jsx(\"div\",{children:previewPrice}),/*#__PURE__*/_jsx(\"button\",{disabled:true,\"aria-busy\":!canvas,style:{marginTop:8,padding:\"10px 16px\",border:0,borderRadius:8,background:\"#062F31\",color:\"white\"},children:\"Add to cart\"})]}),failed&&/*#__PURE__*/_jsx(\"a\",{href:\"/contact\",children:\"Ask about ordering\"})]});}addPropertyControls(ReviewCardPurchase,{productId:{type:ControlType.String,title:\"Product ID\",defaultValue:\"15531633803377\"},previewPrice:{type:ControlType.String,title:\"Preview Price\",defaultValue:\"NZ$20.00\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ReviewCardPurchase\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReviewCardPurchase.map"],"mappings":"A,qNAA2P,SAASgB,GAAW,CAAqqB,MAApqB,CAAYC,IAAO,IAAI,SAAS,EAAQ,IAAS,CAAC,IAAMC,M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