{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/xpqbkEp3IFoaBlvr8BRa/LAxytVtozzpoY8z47RPy/_queries.js", "ssg:https://framerusercontent.com/modules/yZBbIevRfN36MGDPpltx/QsMt3lifGFhrUUWGTJnm/_atoms.js", "ssg:https://framerusercontent.com/modules/tdCHCV0pSkxlDaX5GkOX/T2HZ5a4bzltl1yZXtjGv/_useShopify.js"],
  "sourcesContent": ["const cartReturnData=`\nid\ncreatedAt\nupdatedAt\ncheckoutUrl\nlines(first: 250) {\n  edges {\n    node {\n      id\n      quantity\n      sellingPlanAllocation {\n          checkoutChargeAmount {\n            amount\n            currencyCode\n          }\n          sellingPlan {\n            name\n          }\n      }\n      merchandise {\n        ... on ProductVariant {\n          id\n          title\n          compareAtPriceV2 {\n            amount\n            currencyCode\n          }\n          priceV2 {\n            amount\n            currencyCode\n          }\n          product {\n            id\n            title\n          }\n          image {\n            url\n            width\n            height\n            altText\n          }\n          selectedOptions {\n            value\n            name\n          }\n        }\n      }\n      attributes {\n        key\n        value\n      }\n    }\n  }\n}\ncost {\n  totalAmount {\n    amount\n    currencyCode\n  }\n  subtotalAmount {\n    amount\n    currencyCode\n  }\n  totalTaxAmount {\n    amount\n    currencyCode\n  }\n  totalDutyAmount {\n    amount\n    currencyCode\n  }\n}`;export const productsQuery=({sellingPlan,pageInfo})=>`{\n  products(first: 250${pageInfo?`, after: \"${pageInfo}\"`:\"\"}) {\n    nodes {\n      compareAtPriceRange {\n        minVariantPrice {\n          amount\n          currencyCode\n        }\n      }\n      totalInventory\n      availableForSale\n      isGiftCard\n      collections(first: 250) {\n        nodes {\n          title\n          handle\n        }\n      }\n      handle\n      id\n      media(first: 15) {\n        nodes {\n            mediaContentType\n            alt\n            ...mediaFieldsByType\n        }\n      }\n      images(first: 15) {\n        nodes {\n          altText\n          height\n          url\n          width\n        }\n      }\n      options {\n        id\n        name\n        values\n      }\n      priceRange {\n        minVariantPrice {\n          amount\n          currencyCode\n        }\n        maxVariantPrice {\n          amount\n          currencyCode\n        }\n      }\n      productType\n      tags\n      title\n      description\n      descriptionHtml\n      vendor\n      updatedAt\n      createdAt\n      featuredImage {\n        url\n      }\n      ${sellingPlan?`\n      requiresSellingPlan\n      sellingPlanGroups(first: 250) {\n        nodes {\n          name\n          sellingPlans(first: 250) {\n            nodes {\n              id\n              name\n            }\n          }\n        }\n      }`:\"\"}\n      variants(first: 250) {\n        nodes {\n          title\n          availableForSale\n          sku\n          barcode\n          compareAtPriceV2 {\n            amount\n            currencyCode\n          }\n          priceV2 {\n            amount\n            currencyCode\n          }\n          id\n          image {\n            url\n            width\n            height\n            altText\n          }\n          currentlyNotInStock\n          requiresShipping\n          quantityAvailable\n          taxable\n          selectedOptions {\n            value\n            name\n          }\n          ${sellingPlan?`\n          sellingPlanAllocations(first: 250) {\n            nodes {\n              checkoutChargeAmount {\n                amount\n                currencyCode\n              }\n              sellingPlan {\n                name\n                id\n              }\n            }\n          }`:\"\"}\n        }\n      }\n    }\n    pageInfo {\n        hasNextPage\n        endCursor\n      }\n    }\n}\n\nfragment mediaFieldsByType on Media {\n  ...on MediaImage {\n    image {\n      height\n      width\n      url\n      altText\n    }\n  }\n  ...on Video {\n    previewImage {\n      height\n      width\n      url\n      altText\n    }\n    sources {\n      url\n      mimeType\n      format\n      height\n      width\n    }\n  }\n}\n`;export const createCart=`\n  mutation createCart($cartInput: CartInput) {\n    cartCreate(input: $cartInput) {\n      cart {\n        ${cartReturnData}\n      }\n    }\n  }\n`;export const readCart=`\n  query cartQuery($cartId: ID!) {\n    cart(id: $cartId) {\n      ${cartReturnData}\n    }\n  }\n`;export const addItemsToCart=`\n  mutation addCartLines($cartId: ID!, $lines: [CartLineInput!]!) {\n    cartLinesAdd(cartId: $cartId, lines: $lines) {\n      cart {\n         ${cartReturnData}\n      }\n      userErrors {\n        field\n        message\n      }\n    }\n  }\n`;export const updateCartItems=`\n  mutation addCartLines($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n    cartLinesUpdate(cartId: $cartId, lines: $lines) {\n      cart {\n         ${cartReturnData}\n      }\n      userErrors {\n        field\n        message\n      }\n    }\n  }\n`;export const removeCartItems=`\n  mutation removeCartLines($cartId: ID!, $lineIds: [ID!]!) {\n    cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n      cart {\n         ${cartReturnData}\n      }\n      userErrors {\n        field\n        message\n      }\n    }\n  }\n`;\nexport const __FramerMetadata__ = {\"exports\":{\"createCart\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"readCart\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"addItemsToCart\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"removeCartItems\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateCartItems\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"productsQuery\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./_queries.map", "import{atom}from\"jotai\";import{productsQuery,createCart,readCart}from\"https://framerusercontent.com/modules/xpqbkEp3IFoaBlvr8BRa/LAxytVtozzpoY8z47RPy/_queries.js\";export async function fetchAllProducts(client,sellingPlan){const products=[];let pageInfo=null;try{do{const query=productsQuery({pageInfo,sellingPlan});const response=await client.request(query);products.push(...response.data?.products.nodes);// Update pageInfo for next iteration\nconst responsePageInfo=response.data?.products.pageInfo;pageInfo=responsePageInfo.hasNextPage?responsePageInfo.endCursor:null;console.log(`Fetched ${products.length} products so far...`);}while(pageInfo)return products;}catch(error){console.error(\"Error fetching products:\",error.message);return[];}}export const settingsAtom=atom({enableSellingPlan:false});export const configAtom=atom(null);export const clientAtom=atom(null);export const selectedProductsAtom=atom({});export const productsAtom=atom(async get=>{const sellingPlan=get(settingsAtom).enableSellingPlan;if(!get(clientAtom))return[];const products=await fetchAllProducts(get(clientAtom),sellingPlan);return products;});export const localCartAtom=atom(null);export const createCartAtom=atom(async get=>{const attributes=[];const currentUrl=new URL(window.location.href);// Add all search parameters from the current URL to attributes\ncurrentUrl.searchParams?.forEach((value,key)=>{if(key!==\"key\"){attributes.push({key,value});}});console.log(\"Create Cart\",attributes);return get(clientAtom)?.request(createCart,{variables:{cartInput:{attributes}}}).then(res=>res.data?.cartCreate?.cart);});export const cartAtom=atom(async get=>{const cartId=localStorage.getItem(\"shopifyCartID\");const localCart=get(localCartAtom);if(localCart)return localCart;const client=get(clientAtom);if(!client)return null;if(!cartId)return get(createCartAtom);return client.request(readCart,{variables:{cartId}}).then(res=>{if(res.data?.cart)return res.data.cart;return get(createCartAtom);}).catch(()=>get(createCartAtom));});\nexport const __FramerMetadata__ = {\"exports\":{\"SelectedProduct\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"selectedProductsAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createCartAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"localCartAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"fetchAllProducts\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clientAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"settingsAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"configAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"productsAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"cartAtom\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}", "import{useEffect,useCallback}from\"react\";import{createStorefrontApiClient}from\"@shopify/storefront-api-client\";import{useAtomValue,useSetAtom}from\"jotai\";import{productsAtom,clientAtom,configAtom,cartAtom}from\"https://framerusercontent.com/modules/yZBbIevRfN36MGDPpltx/QsMt3lifGFhrUUWGTJnm/_atoms.js\";import{checkConfigAreSame,debounce}from\"https://framerusercontent.com/modules/7dEgbg7qo3lsQk361YtS/NrF60tPHZRRgADqpoRFr/_utils.js\";export const useShopify=config=>{const debouncedCheck=useCallback(debounce(()=>{checkConfigAreSame();},100),[]);const products=useAtomValue(productsAtom);const cart=useAtomValue(cartAtom);const client=useAtomValue(clientAtom);const setClient=useSetAtom(clientAtom);const setConfig=useSetAtom(configAtom);useEffect(()=>{debouncedCheck();//set config if exist\nif(config&&Object.keys(config).length!==0)setConfig(config);// create the client and store it\nif(!client&&config?.storeDomain&&config?.storefrontToken){setClient(createStorefrontApiClient({storeDomain:config.storeDomain,apiVersion:\"2024-07\",publicAccessToken:config.storefrontToken,customFetchApi:fetch}));}return()=>{debouncedCheck();};},[config]);useEffect(()=>{if(cart){localStorage.setItem(\"shopifyCartID\",cart.id);}},[cart]);return{products,cart};};\nexport const __FramerMetadata__ = {\"exports\":{\"useShopify\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],
  "mappings": "qKAAA,IAAMA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAuELC,EAAc,CAAC,CAAC,YAAAC,EAAY,SAAAC,CAAQ,IAAI;AAAA,uBACj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GAAM,aAAa,QAAQ,gBAAgBA,EAAK,EAAE,CAAG,EAAE,CAACA,CAAI,CAAC,EAAQ,CAAC,SAAAH,EAAS,KAAAG,CAAI,CAAE",
  "names": ["cartReturnData", "productsQuery", "sellingPlan", "pageInfo", "createCart", "readCart", "addItemsToCart", "updateCartItems", "removeCartItems", "fetchAllProducts", "client", "sellingPlan", "products", "pageInfo", "query", "productsQuery", "response", "responsePageInfo", "error", "settingsAtom", "atom", "configAtom", "clientAtom", "selectedProductsAtom", "productsAtom", "get", "localCartAtom", "createCartAtom", "attributes", "window", "value", "key", "createCart", "res", "cartAtom", "cartId", "localCart", "readCart", "useShopify", "config", "debouncedCheck", "te", "debounce", "checkConfigAreSame", "products", "useAtomValue", "productsAtom", "cart", "cartAtom", "client", "clientAtom", "setClient", "useSetAtom", "setConfig", "configAtom", "ue", "createStorefrontApiClient"]
}
