1import{u as h,d as p}from"./CtnidYUC.js";const y=(e,r)=>` 2 cursor, 3 node { 4 id, 5 availableForSale, 6 title, 7 productType, 8 handle, 9 tags, 10 compareAtPriceRange { 11 maxVariantPrice { 12 amount 13 } 14 }, 15 options { 16 name, 17 values 18 }, 19 images(first: ${e}) { 20 edges { 21 node { 22 altText, 23 id, 24 src, 25 width, 26 height 27 } 28 } 29 }, 30 variants(first: ${r}) { 31 edges { 32 node { 33 id, 34 availableForSale, 35 price { 36 amount, 37 currencyCode 38 }, 39 title 40 } 41 } 42 }, 43 vendor 44 } 45`,f=(e,r)=>` 46 id, 47 availableForSale, 48 title, 49 productType, 50 handle, 51 tags, 52 compareAtPriceRange { 53 maxVariantPrice { 54 amount 55 } 56 }, 57 options { 58 name, 59 values 60 }, 61 images(first: ${e}) { 62 edges { 63 node { 64 altText, 65 id, 66 src, 67 width, 68 height 69 } 70 } 71 }, 72 variants(first: ${r}) { 73 edges { 74 node { 75 id, 76 availableForSale, 77 price { 78 amount, 79 currencyCode 80 }, 81 title 82 } 83 } 84 }, 85 vendor 86`,v=(e,r,d,n,c)=>`query @inContext(country: ${c}) { 87 products(first: ${e}, query: "(title:${n}*) OR (tag:${n}*)") { 88 edges { 89 ${y(r,d)} 90 } 91 } 92} 93`,P=(e,r)=>`query @inContext(country: ${r}) { 94 productByHandle(handle: "${e}") { 95 availableForSale, 96 description, 97 descriptionHtml, 98 handle, 99 id, 100 tags, 101 compareAtPriceRange { 102 maxVariantPrice { 103 amount 104 } 105 }, 106 onlineStoreUrl, 107 productType, 108 title, 109 vendor, 110 totalInventory, 111 options(first: 10) { 112 id, 113 name, 114 values 115 }, 116 media(first: 10) { 117 edges { 118 node { 119 alt, 120 mediaContentType, 121 ... on Video { 122 alt, 123 id, 124 sources { 125 format, 126 height, 127 mimeType, 128 url, 129 width 130 } 131 }, 132 ... on MediaImage { 133 alt, 134 id, 135 image { 136 altText, 137 height, 138 id, 139 width, 140 src 141 } 142 } 143 } 144 } 145 }, 146 images(first: 10) { 147 edges { 148 node { 149 altText, 150 id, 151 src, 152 width, 153 height 154 } 155 } 156 }, 157 variants(first: 10) { 158 edges { 159 node { 160 availableForSale, 161 selectedOptions { 162 name, 163 value 164 }, 165 id, 166 sku, 167 quantityAvailable, 168 title, 169 price { 170 amount, 171 currencyCode 172 }, 173 compareAtPriceV2 { 174 amount 175 }, 176 selectedOptions { 177 name, 178 value 179 }, 180 image { 181 url, 182 src, 183 id, 184 altText 185 } 186 } 187 } 188 }, 189 collections(first: 1) { 190 edges { 191 node { 192 id, 193 handle 194 } 195 } 196 } 197 } 198}`,$=(e,r,d,n)=>`query @inContext(country: ${n}) { 199 productRecommendations(productId: "${e}") { 200 id, 201 availableForSale, 202 title, 203 productType, 204 handle, 205 tags, 206 compareAtPriceRange { 207 maxVariantPrice { 208 amount 209 } 210 }, 211 options { 212 name, 213 values 214 }, 215 images(first: ${r}) { 216 edges { 217 node { 218 altText, 219 id, 220 src, 221 width, 222 height 223 } 224 } 225 }, 226 variants(first: ${d}) { 227 edges { 228 node { 229 id, 230 availableForSale, 231 price { 232 amount, 233 currencyCode 234 }, 235 title, 236 } 237 } 238 }, 239 vendor 240 } 241} 242`,x=(e,r,d,n,c)=>` query @inContext(country: ${c}) { 243 products (first: ${r}, query: "${e}") { 244 edges { 245 ${y(d,n)} 246 } 247 } 248} 249`,A=()=>{const{url:e,headers:r,getOptions:d,formatProduct:n,currencyPreferences:c}=h();return{getProductsBySearchTerm:async(s,t=null)=>{const{productsToLoad:a,images:u,variants:i}=d(t);try{const l=(await p.post(e,v(a,u,i,s,c.value.country),r)).data;let o=[],m;return o=l.data.products.edges,o.length&&(m=o[o.length-1].cursor),o=o.map(g=>n(g)),{products:o,cursor:m}}catch(l){return console.log(l),{products:[]}}},getProductByHandle:async s=>{try{const t=(await p.post(e,P(s,c.value.country),r)).data;if(t.data.productByHandle)return n(t.data.productByHandle)}catch(t){return console.log(t),null}},initialVariant:(s,t=!1)=>
249{if(t){for(let a of s)if(a.availableForSale)return a}return s[0]},getRecommendedProducts:async(s,t=null)=>{try{const{images:a,variants:u}=d(t),i=(await p.post(e,$(s,a,u,c.value.country),r)).data;return i?.data?.productRecommendations?.length?{products:i.data.productRecommendations.map(o=>n(o))}:{products:[]}}catch(a){return console.log(a),{products:[]}}},getProductsByQueryArgument:async(s,t=null)=>{try{const{productsToLoad:a,images:u,variants:i}=d(t);return(await p.post(e,x(s,a,u,i,c.value.country),r)).data.data.products.edges.length>1?{products:filteredProducts.map(g=>n(g))}:{products:[]}}catch(a){return console.log(a),{error:a,products:[]}}},getProductsByIds:async s=>{try{let t="[";for(let o of s)t+=`"${o}",`;t+="]";let a=`query { 250 nodes(ids: ${t}) { 251 ... on Product { 252 ${f(2,1)} 253 } 254 } 255 }`;return((await p.post(e,a,r)).data?.data?.nodes.filter(o=>o!==null)).map(o=>o&&n(o))}catch(t){return console.log(t),[]}}}};export{A 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.