{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/ipwnVsdWgrjFNA05lcj7/gL57TLydDFQI0DmyxkHm/CartTrigger.js"],
  "sourcesContent": ["/**\n * CartTrigger Component\n *\n * This component serves as a trigger for the shopping cart functionality in the Umbrel Home product.\n * It works in conjunction with the Cart component (defined in Cart.tsx) to manage the cart state\n * across different components and browser instances.\n *\n * Key features:\n * - Displays a button that can trigger the opening of the cart\n * - Optionally shows the current quantity of items in the cart\n * - Can add an item to the cart if it's empty\n * - Persists cart state across page reloads and browser tabs using localStorage\n *\n * Relationship with Cart.tsx:\n * Since Framer components can't directly share state, this component uses localStorage and custom events\n * to synchronize the cart state with the Cart component. This approach allows for consistent cart\n * behavior across different parts of the application without direct state sharing.\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect,useCallback}from\"react\";export default function CartTrigger({children,showQuantity=false,addToCart=false}){// Initialize quantity state from localStorage\n// This ensures the quantity persists across page reloads\nconst[quantity,setQuantity]=useState(()=>{if(typeof window===\"undefined\")return 0;return parseInt(window.localStorage.getItem(\"cartQuantity\")||\"0\",10);});// Create a memoized callback to handle cart updates\n// This function will be called whenever the cart is updated in any component\nconst handleCartUpdate=useCallback(()=>{if(typeof window===\"undefined\")return;const newQuantity=parseInt(window.localStorage.getItem(\"cartQuantity\")||\"0\",10);setQuantity(newQuantity);},[]);// Set up an event listener for cart updates\n// This allows the CartTrigger to react to changes made in the Cart component\nuseEffect(()=>{if(typeof window===\"undefined\")return;window.addEventListener(\"cartUpdate\",handleCartUpdate);// Clean up the event listener when the component unmounts\nreturn()=>{window.removeEventListener(\"cartUpdate\",handleCartUpdate);};},[handleCartUpdate]);// Handle click events on the cart trigger\nconst handleClick=()=>{console.log(\"clicked...\");if(typeof window===\"undefined\"){console.log(\"window is undefined\");return;}// If addToCart is true and the cart is empty, add one item\nif(addToCart&&quantity===0){console.log(\"adding to cart\");window.localStorage.setItem(\"cartQuantity\",\"1\");}console.log(\"setting isCartOpen to true\");// Open the cart\nwindow.localStorage.setItem(\"isCartOpen\",\"true\");console.log(\"dispatching cartUpdate event\");// Notify other components (especially Cart.tsx) about the update\nwindow.dispatchEvent(new Event(\"cartUpdate\"));};// Render the cart trigger button\nreturn /*#__PURE__*/_jsxs(\"button\",{onClick:handleClick,style:{cursor:\"pointer\",position:\"relative\",background:\"none\",border:\"none\",padding:0},children:[children,showQuantity&&quantity>0&&/*#__PURE__*/_jsx(\"span\",{style:quantityBadgeStyle,children:quantity})]});}// Add property controls for Framer\n// This allows users to customize the component's behavior in the Framer interface\naddPropertyControls(CartTrigger,{children:{type:ControlType.ComponentInstance},showQuantity:{type:ControlType.Boolean,title:\"Show Quantity\",defaultValue:false},addToCart:{type:ControlType.Boolean,title:\"Add to Cart\",defaultValue:true}});// Style for the quantity badge\n// This creates a small circular badge to display the cart quantity\nconst quantityBadgeStyle={position:\"absolute\",top:\"-0.35rem\",right:\"-0.35rem\",background:\"radial-gradient(circle, #5351F3, #312EE9)\",color:\"white\",fontSize:\"0.5rem\",fontWeight:\"bold\",borderRadius:\"50%\",width:\"0.8rem\",height:\"0.8rem\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",fontFamily:\"var(--framer-font-family, Inter, Inter Placeholder, sans-serif)\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CartTrigger\",\"slots\":[\"children\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CartTrigger.map"],
  "mappings": "8HAiBiL,SAARA,EAA6B,CAAC,SAAAC,EAAS,aAAAC,EAAa,GAAM,UAAAC,EAAU,EAAK,EAAE,CAEpP,GAAK,CAACC,EAASC,CAAW,EAAEC,EAAS,IAAQ,OAAOC,EAAS,IAAmB,EAAS,SAASA,EAAO,aAAa,QAAQ,cAAc,GAAG,IAAI,EAAE,CAAG,EAElJC,E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,aAAa,MAAM,MAAM,SAAS,OAAO,SAAS,QAAQ,OAAO,eAAe,SAAS,WAAW,SAAS,WAAW,iEAAiE",
  "names": ["CartTrigger", "children", "showQuantity", "addToCart", "quantity", "setQuantity", "ye", "window", "handleCartUpdate", "te", "newQuantity", "ue", "u", "p", "quantityBadgeStyle", "addPropertyControls", "ControlType"]
}
