{"version":3,"file":"Shopify_client.CoO2FWMX.mjs","names":[],"sources":["https:/framerusercontent.com/modules/TgekT24FCXsp3m1M9KnX/UiecgZDEjubVKN4lur2X/Get_shopify_config.js","https:/framerusercontent.com/modules/c5gtsBimYk7u4sSXwOlt/CM2cTm98pCUipAHQyaQn/Shopify_client.js"],"sourcesContent":["import{isBrowserFn}from\"https://framerusercontent.com/modules/0cFx6PDS8kp3yxNfnoIw/3wFcPS10LYSFljb1q710/Framer_utils.js\";let _cfg=null;export function getShopifyConfig(){const isBrowser=isBrowserFn();if(!isBrowser)return null;if(_cfg)return _cfg;// 1) JSON script\nconst el=document.getElementById(\"frameship-shopify-config\");if(el?.textContent){try{_cfg=JSON.parse(el.textContent);if(_cfg?.shop&&_cfg?.storefrontToken)return _cfg;}catch(error){console.error(\"Error parsing Shopify config:\",error);return null;}}// throw new Error(\"Frameship Shopify config not found on page.\");\nreturn null;}export function getLicenseId(){const config=getShopifyConfig();return config?.licenseId||null;}\nexport const __FramerMetadata__ = {\"exports\":{\"getLicenseId\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getShopifyConfig\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Get_shopify_config.map","import{getShopifyConfig}from\"https://framerusercontent.com/modules/TgekT24FCXsp3m1M9KnX/UiecgZDEjubVKN4lur2X/Get_shopify_config.js\";export async function shopifyClient({query,variables}){try{const config=getShopifyConfig();// Early return if config is null or missing required fields\nif(!config||!config.shop||!config.storefrontToken){return{data:null,errors:[{message:\"Shopify configuration is not available. Make sure the frameship-shopify-config script is present on the page.\"}]};}// Construct the Shopify GraphQL endpoint URL\nconst endpoint=`https://${config.shop}/api/${config.apiVersion}/graphql.json`;// Prepare the request body\nconst requestBody={query,...variables&&{variables}};// Make the fetch request\nconst response=await fetch(endpoint,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",\"X-Shopify-Storefront-Access-Token\":config.storefrontToken},body:JSON.stringify(requestBody)});// Check if the response is ok\nif(!response.ok){return{data:null,errors:[{message:`Shopify API request failed: ${response.status} ${response.statusText}`}]};}// Parse the JSON response\nconst result=await response.json();// Check for GraphQL errors\nif(result.errors&&result.errors.length>0){const errorMessages=result.errors.map(error=>error.message).join(\", \");// throw new Error(`GraphQL errors: ${errorMessages}`);\nreturn{data:null,errors:[{message:`GraphQL errors: ${errorMessages}`}]};}// Return the data if everything is successful\nreturn{data:result.data,errors:[]};}catch(error){return{data:null,errors:[{message:`Unexpected error occurred: ${String(error)}`}]};}}\nexport const __FramerMetadata__ = {\"exports\":{\"shopifyClient\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"2GAAuI,SAAgB,GAAkB,CAA+B,GAAG,CAAjB,GAAa,CAAe,OAAO,KAAK,GAAG,EAAK,OAAO,EACjP,IAAM,EAAG,SAAS,eAAe,2BAA2B,CAAC,GAAG,GAAI,YAAa,GAAG,CAAiC,GAAhC,EAAK,KAAK,MAAM,EAAG,YAAY,CAAI,GAAM,MAAM,GAAM,gBAAgB,OAAO,QAAY,EAAM,CAAsD,OAArD,QAAQ,MAAM,gCAAgC,EAAM,CAAQ,KAChP,OAAO,wBAFkH,CAAI,EAAK,QCAE,eAAsB,EAAc,CAAC,QAAM,aAAW,CAAC,GAAG,CAAC,IAAM,EAAO,GAAkB,CAC9N,GAAG,CAAC,GAAQ,CAAC,EAAO,MAAM,CAAC,EAAO,gBAAiB,MAAM,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,QAAQ,gHAAgH,CAAC,CAAC,CACvM,IAAM,EAAS,WAAW,EAAO,KAAK,OAAO,EAAO,WAAW,eACzD,EAAY,CAAC,QAAM,GAAG,GAAW,CAAC,YAAU,CAAC,CAC7C,EAAS,MAAM,MAAM,EAAS,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,oCAAo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