1import{u as I,a as d}from"./axios.93df6217.js";import{e as g}from"./entry.7d939621.js";const l=()=>` 2 id, 3 webUrl, 4 totalPrice { 5 amount, 6 currencyCode 7 }, 8 subtotalPrice { 9 amount, 10 currencyCode 11 }, 12 totalTax { 13 amount, 14 currencyCode 15 }, 16 currencyCode, 17 completedAt, 18 lineItems(first: 200) { 19 edges { 20 node { 21 id, 22 title, 23 quantity, 24 customAttributes { 25 key, 26 value 27 } 28 discountAllocations { 29 allocatedAmount { 30 amount, 31 currencyCode 32 } 33 }, 34 unitPrice { 35 amount, 36 currencyCode 37 }, 38 variant { 39 id, 40 sku, 41 title, 42 quantityAvailable, 43 priceV2 { 44 amount, 45 currencyCode 46 }, 47 compareAtPriceV2 { 48 amount, 49 currencyCode 50 }, 51 selectedOptions { 52 name, 53 value 54 }, 55 image { 56 altText, 57 originalSrc, 58 url, 59 src 60 }, 61 price { 62 amount, 63 currencyCode 64 }, 65 product { 66 tags, 67 handle, 68 id 69 } 70 } 71 } 72 } 73 } 74`,$=(e,o)=>`query @inContext(country: ${o}) { 75 node(id: "${e}") { 76 ... on Checkout { 77 ${l()} 78 } 79 } 80}`,f=e=>`mutation { 81 checkoutCreate(input: { 82 buyerIdentity: { countryCode: ${e} }, 83 lineItems: [] 84 }) { 85 checkout { 86 ${l()} 87 } 88 } 89}`,A=(e,o,i)=>`mutation @inContext(country: ${i}) { 90 checkoutLineItemsAdd(checkoutId: "${e}", lineItems: [${o}]) { 91 checkout { 92 ${l()} 93 } 94 } 95}`,w=(e,o)=>`mutation { 96 checkoutLineItemsAdd(checkoutId: "${e}", lineItemIds: ${o}) { 97 ${l()} 98 } 99}`,b=(e,o,i)=>`mutation { 100 checkoutLineItemsUpdate(checkoutId: "${e}", lineItems: [${o}]) { 101 checkout { 102 ${l()} 103 } 104 } 105}`,Q=()=>{const{url:e,headers:o,currencyPreferences:i}=I(),n=g("checkout",()=>null),m=c=>{var u;const{lineItems:t,...a}=c;let r;return(u=t==null?void 0:t.edges)!=null&&u.length&&(r=t.edges.map(s=>s.node)),{...a,lineItems:r}},h=async(c=null)=>{try{const t=(await d.post(e,f(i.value.country),o)).data;if(t.data.checkoutCreate.checkout)return t.data.checkoutCreate.checkout}catch(t){return console.log(t),null}},p=async c=>{try{const t=(await d.post(e,$(c,i.value.country),o)).data;if(t.data.node)return t.data.node}catch(t){return console.log(t),null}};return{retrieveCheckout:async c=>{let t;try{return c?(t=await p(c),t||(t=await h(null)),t.completedAt&&(t=await h())):t=await h(null),n.value=m(t),t.id}catch(a){return console.log(a),null}},addToCart:async c=>{var t,a;try{const{variantId:r,quantity:u,customAttributes:s}=c;let v=`{ variantId: "${r}", quantity: ${u} ${s?", customAttributes: "+s:""} }`;const C=n.value.id,y=(await d.post(e,A(C,v,i.value.country),o)).data,k=(a=(t=y==null?void 0:y.data)==null?void 0:t.checkoutLineItemsAdd)==null?void 0:a.checkout;return k&&(n.value=m(k)),{msg:"Added to cart"}}catch(r){console.log(r)}},removeFromCart:async c=>{try{const t=n.value.id,a=await d.post(e,w(t,c),o);console.log(a)}catch(t){console.log(t)}},updateCart:async c=>{var t,a;try{const r=n.value.id,u=(await d.post(e,b(r,c),o)).data,s=(a=(t=u==null?void 0:u.data)==null?void 0:t.checkoutLineItemsUpdate)==null?void 0:a.checkout;if(console.log("UPDATED CHECKOUT",s),s)return n.value=m(s),{msg:"Cart Updated",id:n.value.id}}catch(r){console.log(r)}},checkout:n}};export{Q 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.