PageSourceSearch

https://peacelovehormones.com/assets/useShopifyProducts-CJvwiYNR.js

js peacelovehormones.com collected 2026-10-04 03:53:05 UTC 2,321 bytes, 1 lines download raw bytes

1import{r as f,Z as y,$ as F,a9 as P}from"./index-DL151FI2.js";let l=null,d=null,h=null;const S=new Set;function g(r,o,u){S.has(r)||(S.add(r),console.warn(`[useShopifyProducts] ${o}`))}async function w(){return l||d||(d=(async()=>{try{const o=(await y(F,{first:50,query:null}))?.data?.products?.edges??[];return o.length||console.warn("[useShopifyProducts] Storefront API returned 0 products. Check that products exist and that the storefront token has read_products scope."),l=o,h=null,o}catch(r){const o=r instanceof Error?r:new Error(String(r));return h=o,console.error("[useShopifyProducts] Failed to load products from Shopify Storefront API. Falling back to bundled assets. Original error:",o),d=null,[]}})(),d)}function O(){const[r,o]=f.useState(l??[]),[u,i]=f.useState(!l),[a,c]=f.useState(h);f.useEffect(()=>{if(l){i(!1);return}let t=!0;return w().then(e=>{t&&(o(e),c(h))}).finally(()=>t&&i(!1)),()=>{t=!1}},[]);const p=t=>{const e=t.toLowerCase();return r.find(n=>n.node.title.toLowerCase().startsWith(e))},m=t=>{const e=(P[t]??t).toLowerCase();return r.find(n=>n.node.handle.toLowerCase()===e)};return{products:r,loading:u,error:a,findByTitle:p,findByHandle:m,imageFor:(t,e=0)=>{if(u||a||r.length===0)return null;const n=p(t);if(!n)return g(`missing-product:${t}`,`No Shopify product matches title "${t}". Falling back to bundled asset.`),null;const s=n.node.images.edges[e];return s?.node?.url?s.node.url:(g(`missing-image:${t}:${e}`,`Product "${n.node.title}" (handle: ${n.node.handle}) has no image at index ${e}. Add one in Shopify admin.`),null)},imageForHandle:(t,e=0)=>{if(!t||u||a||r.length===0)return null;const n=m(t);if(!n)return g(`missing-handle:${t}`,`No Shopify product matches handle "${t}". Falling back to bundled asset.`),null;const s=n.node.images.edges[e];return s?.node?.url?s.node.url:(g(`missing-image-handle:${t}:${e}`,`Product handle "${t}" has no image at index ${e}. Add one in Shopify admin.`),null)},altFor:(t,e,n=0)=>{const s=p(t);return s?$(s,e,n):e},altForHandle:(t,e,n=0)=>{if(!t)return e;const s=m(t);return s?$(s,e,n):e}}}function $(r,o,u){const i=r.node,a=i.images.edges[u]?.node?.altText?.trim();if(a)return a;const c=(i.description??"").replace(/\s+/g," ").trim().split(new RegExp("(?<=[.!?])\\s"))[0];return c&&c.length>0?`${i.title} — ${c}`:i.title||o}export{O as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.