1import{l as e,T as t,s as o}from"./2c1ab0fe.GMbxnz74.js";import{J as r,e4 as i,e5 as a,e6 as n,e7 as s,e8 as c,e9 as u,ea as d,S as l,g as m,aa as h,W as p,T as f,eb as y,c2 as k,ec as v,ed as b,ee as C,ef as g,eg as S}from"./4c290a1e.C6TDJ9Fn.js";import{eH as A,u as I,e as E,eI as T,eJ as D,eK as P,eL as R}from"./164ad2e3.BbIvMjRY.js";import{u as _}from"./91319467.CaV5Q69j.js";import"./app.CepNJbvh.js";import"./9f047e05.CCJUgz_L.js";import"./0a7dffce.DfUtZWCu.js";import"./5fda1420.KYpufQ--.js";import"./60a453ce.CkhHeRBc.js";import"./21cc90a2.DAzJmttM.js";import"./bb728e1c.iawBHR84.js";var w=(e=>(e.StartedOrder="Started Order",e.StartedOrderRemote="Started Order Remote",e.StartedOrderOncePerCheckout="Started Order Once Per Checkout",e.StartedOrderOncePerCheckoutRemote="Started Order Once Per Checkout Remote",e.CompletedOrder="Completed Order",e.AddedPayment="Added Payment",e.AddedPaymentRemote="Added Payment Remote",e.CheckoutContactPageStarted="Checkout Contact Step Started",e.CheckoutContactInfoSubmitted="Checkout Contact Info Submitted",e.CheckoutContactInfoSubmittedRemote="Checkout Contact Info Submitted Remote",e.CheckoutAddressInfoSubmitted="Checkout Address Info Submitted",e.CheckoutAddressInfoSubmittedRemote="Checkout Address Info Submitted Remote",e.CheckoutShippingPageStarted="Checkout Shipping Step Started",e.CheckoutShippingInfoSubmitted="Checkout Shipping Info Submitted",e.CheckoutShippingInfoSubmittedRemote="Checkout Shipping Info Submitted Remote",e.CheckoutPaymentPageStarted="Checkout Payment Step Started",e.CheckoutOnePageView="Checkout One Page View",e))(w||{});const M="checkout",N=[i,a,n,s,c,u,d];class O extends Error{constructor(){super(...arguments),this.name="TrekkieError"}}class L{constructor({shop:e,checkoutToken:t="",locale:o,analyticsConfig:i,sourceUrl:a,themeId:n,themeCityHash:s,userEvents:u,s2s:d,monorailRegion:l,getCookie:m},h){if(this.libraryLoaded=!1,this.trekkieLoadedCallback=h,this.analyticsWindow=window,this.tricorder=this.analyticsWindow.ShopifyAnalytics?.lib||this.analyticsWindow.trekkie||[],this.tricorder?.integrations)return this.libraryLoaded=!0,void this.trekkieLoadedCallback(this.analyticsWindow?.ShopifyAnalytics?.lib?.trekkie);const p=parseInt(r(e.id),10),f=N.filter(t=>e.hasFlagEnabled(t)),y=f.includes(c);this.tricorder.ready(()=>{this.libraryLoaded||(this.libraryLoaded=!0,this.shopifyAnalytics={...this.shopifyAnalytics,lib:this.tricorder},this.trekkieLoadedCallback(this.tricorder?.trekkie))}),this.tricorder.load=t=>{if(this.tricorder.config=t,!y){const{assetPath:t,sriHash:o}=e.trekkieLoadConfiguration,r=t&&o,i=document.getElementsByTagName("script")[0],s=document.createElement("script");s.type="text/javascript",s.onerror=function(){const e=document.createElement("script");e.type="text/javascript",e.onerror=function(){const e={schemaId:"trekkie_checkout_load_errors/1.1",payload:{appName:M,shopId:p,themeId:n,contextUrl:window.location.href,sourceUrl:a}};u.monorailEvent(e)},e.async=!0,e.src=a,r&&(e.setAttribute("integrity",o),e.setAttribute("crossorigin","anonymous")),i?.parentNode?.insertBefore(e,i)},s.async=!0,s.src=a,r&&(s.setAttribute("integrity",o),s.setAttribute("crossorigin","anonymous")),i?.parentNode?.insertBefore(s,i)}};const k={appName:M,development:!1,defaultAttributes:{shopId:p,isMerchantRequest:!!m("_ab")||null,themeId:n,themeCityHash:s,contentLanguage:o,currency:e.currencyCode,checkoutToken:t},isServerSideCookieWritingEnabled:!0,enabledBetaFlags:f};l&&(k.monorailRegion=l),this.tricorder.load({Trekkie:k,...i,"Session Attribution":{},S2S:d})}get tricorder(){return this.analyticsWindow?.trekkie}set tricorder(e){if(!this.analyticsWindow)throw new O("AnalyticsWindow is not set.");this.analyticsWindow.trekkie=e}get shopifyAnalytics(){return this.analyticsWindow.ShopifyAnalytics}set shopifyAnalytics(e){if(!this.analyticsWindow)throw new O("AnalyticsWindow is not set.");this.analyticsWindow.ShopifyAnalytics=e}page(e="",t={},o){this.tricorder?.page(e,t,o)}track(e,t,o,r,i){this.tricorder?.track(e,t,o,r,i)}}function W({remoteTotalDetails:e,remoteMerchandiseLinesByShopId:t,emitRemoteEventForShop:o}
1){if(e)for(const[r,i]of e.perShopRemoteTotals.entries())o(t?{remoteTotals:i,remoteMerchandiseLines:t?.get(r)??[]}:{remoteTotals:i})}function j(e){switch(e){case"/":case"/information":return{title:"Checkout - Contact Information",page:"/checkout/contact_information"};case"/shipping":return{title:"Checkout - Shipping",page:"/checkout/shipping"};case"/payment":return{title:"Checkout - Payment",page:"/checkout/payment"};case"/review":return{title:"Checkout - Review",page:"/checkout/review"};case"/processing":return{title:"Checkout - Processing",page:"/checkout/processing"};case"/thank-you":return{title:"Checkout - Receipt",page:"/checkout/thank_you"};case"/stock-problems":return{title:"Checkout - Stock problems",page:"/checkout/stock_problems"};case"/error":return{title:"Checkout - Error",page:"/checkout/error"};case"/no-address-location":return{title:"Checkout - No Address Location",page:"/checkout/no_address_location"};case"/shoppay_login":return{title:"ShopPay - Login",page:"/shop.app/pay/login"};case"/shoppay":return{title:"ShopPay - Payment",page:"/shop.app/pay/payment"};default:return{title:null,page:null}}}function F(e){const t=e?.map(e=>{const t=e.lineAllocations.reduce((e,t)=>(t.allocations.filter(e=>"code"===e.discountDetails.discount.type).forEach(t=>{t.amount.amount>e.amount&&(e.amount=t.amount.amount,e.code=t.discountDetails.title)}),e),{code:void 0,amount:0});return{variantId:b(e.variantId),productId:b(e.productId),productGid:e.productId,category:e.productType,coupon:t.code,currency:e.itemPrice?.currencyCode,name:e.title,price:e.itemPrice?.amount,quantity:e.quantity,brand:e.vendor,variant:e.subtitle,sku:e.sku}});return t}function x(){const{client:r,observability:i,userEvents:a,environment:n,i18n:{locale:s},shop:c,source:u,checkout:{identity:d}}=l(),M="shopPay"===d.current.value?"trekkie-checkout-one-shop-app":"trekkie-checkout-one",{data:N}=A(),O=N?.session?.activeCheckoutRolloutTreatments?.flatMap(({rolloutId:e,treatmentId:t})=>{const o=m(e),r=m(t);return void 0!==o&&void 0!==r?[{rolloutId:Number(o),treatmentId:Number(r)}]:[]}),x=e(O);x.current=O;const B=u.checkoutSessionIdentifier||u.sourceId;let z=void 0===c.theme?.id||null===c.theme?.id?void 0:parseInt(c.theme.id,10);z&&z>Number.MAX_SAFE_INTEGER&&(z=void 0);const H=c.theme?.cityhash,U=h(),{email:V,phone:q,shippingAddress:G}=p(),J=I(),{value:$}=f().deliveryNext,K=r.unstable_getSerialization("apiClientId"),X=r.unstable_getSerialization("apiClientId"),{currentPage:Q}=E().value,Y=Q&&["onePage"].includes(Q.id),Z=T(),ee=D(),te=e(new WeakSet).current,{value:oe}=y(),re=oe,ie=_(),ae=t(()=>({}
1),[]),ne=k(),se=o(e=>{e?ne.value?.defaultAttributes!==e?.defaultAttributes&&ne.setValue({defaultAttributes:e?.defaultAttributes}):i.error(new v("Trekkie is not available"))},[i,ne]),ce=t(()=>{const e=null===H?void 0:H,t=U.current.fields.buyerIdentity.peek(),o={facebookCapiEnabled:c.facebookCapiEnabled,source:M,customerId:b(t?.customerProfile?.id),cartApiClientId:K,apiClientId:X},i=`${n.services.trekkie.url}/${c.trekkieLoadConfiguration?.assetPath||"s/trekkie.storefront.min.js"}`;return Z?null:new L({shop:c,checkoutToken:B,locale:s,analyticsConfig:ae,sourceUrl:i,themeId:z,themeCityHash:e,userEvents:a,monorailRegion:"shop_domain",s2s:o,getCookie:e=>r.cookies.get(e)??null},se)},[c,B,s,ae,z,H,a,r.cookies,se,U,K,X,M,Z,n.services.trekkie.url]),ue=o(e=>{const{title:t,page:o}=j(e);t&&o&&ie.value&&ce?.page(t,{path:o})},[ce,ie]),de=o(e=>{const{title:t,page:o}=j(e);if(!t||!o||!ie.value)return;const r={name:t,path:o};ce?.track(w.CheckoutOnePageView,r,void 0,void 0,{shopifyEmitted:!0})},[ce,ie]),le=t(()=>{let e={amount:void 0,currencyCode:void 0};return J&&"filled"===$?.status&&$.lines.forEach(t=>{if("available"===t.status){const o=t.selectedDeliveryMethodHandle;if(o){const r=t.methods.filter(e=>e.handle===o&&void 0!==e.costAfterDiscounts);e=r.reduce((e,t)=>{const o=void 0===e.amount?0:e.amount;return e.amount=o+t.costAfterDiscounts.amount,e.currencyCode=t.costAfterDiscounts.currencyCode,e},e)}}}),e},[$,J]),me=o(()=>{const e=U.current.fields.merchandiseLines.value,t=U.current.fields.remoteMerchandiseDetails.value;if(ie.value){const o=U.current.fields.subtotal.value,r=U.current.fields.subtotalAfterMerchandiseDiscounts.value,i={step:1,products:F(C(e?.lines??[],t)),currency:o?.currencyCode,revenue:o?.amount,subtotalAfterMerchandiseDiscounts:r?.amount,...x.current?.length?{rolloutIds:x.current.map(e=>Number(e.rolloutId)),rolloutTreatmentIds:x.current.map(e=>Number(e.treatmentId))}:{}};ce?.track(w.StartedOrder,i,void 0,void 0,{shopifyEmitted:!0})}re&&W({remoteTotalDetails:U.current.fields.remoteTotalDetails.value,remoteMerchandiseLinesByShopId:g(e?.lines??[],t),emitRemoteEventForShop:({remoteTotals:e,remoteMerchandiseLines:t})=>{const o={step:1,products:t?F(t):[],currency:e?.subtotal?.currencyCode,revenue:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ce?.track(w.StartedOrderRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ce,U,re,ie]),he=o(()=>{const e=U.current.fields.subtotal.value,t=U.current.fields.subtotalAfterMerchandiseDiscounts.value,o=U.current.fields.remoteTotalDetails.value,r=U.current.fields.merchandiseLines.value,i=U.current.fields.remoteMerchandiseDetails.value,a=C(r?.lines??[],i),n=g(r?.lines??[],i);if(ie.value){const o={step:1,products:F(a),currency:e?.currencyCode,revenue:e?.amount,subtotalAfterMerchandiseDiscounts:t?.amount,...x.current?.length?{rolloutIds:x.current.map(e=>Number(e.rolloutId)),rolloutTreatmentIds:x.current.map(e=>Number(e.treatmentId))}:{}};ce?.track(w.StartedOrderOncePerCheckout,o,void 0,void 0,{shopifyEmitted:!0})}re&&W({remoteTotalDetails:o,remoteMerchandiseLinesByShopId:n,emitRemoteEventForShop:({remoteTotals:e,remoteMerchandiseLines:t})=>{const o={step:1,products:t?F(t):[],currency:e?.subtotal?.currencyCode,revenue:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ce?.track(w.StartedOrderOncePerCheckoutRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ce,U,re,ie]),pe=o(()=>{if(!J)return;if(ee.shouldPrevent())return;if(!ie.value)return;const e=U.current.fields.merchandiseLines.value,t=e?.lines&&F(e?.lines),o=J.purchaseOrder,r=b(J.orderIdentity.id),i=r?.toString(),a=o.billingAddress,n=U.current.fields.buyerIdentity.value,s=n?.customerProfile;let c=s?.firstName,u=s?.lastName;u||(c=a?.firstName,u=a?.lastName);const d=U.current.fields.total.value,l=U.current.fields.subtotal.value,m=U.current.fields.subtotalAfterMerchandiseDiscounts.value,h=P(U),p=U.current.fields.contactInfo.value,f=U.current.fields.discountLines.value,y=f?.lines.filter(e=>"code"===e.discount.type).map(e=>e.discount.title)||[],k=J.analytics?.checkoutCompletedEventId||void 0,v=J.analytics?.emitConversionEvent||!1;ce?.track(w.CompletedOrder,{customerEventData:{customer:{firstName:c,lastName:u,emailAddress:s?.email??p?.email,phoneNumber:s?.phone??p?.phone},address:{city:a?.city,province:a?.zoneCode,country:a?.countryCode,zip:a?.postalCode}},orderId:r,orderName:i,products:t,total:d?.amount??0,currency:d?.currencyCode,revenue:l?.amount??0,subtotalAfterMerchandiseDiscounts:m?.amount??0,coupon:y[0],tax:h?.amount??0,shipping:le.amount??0},k,v,{shopifyEmitted:!0}),ee.markAsEmitted()},[J,U,ce,le.amount,ee,ie]),fe=o(()=>{const e=U.current.fields.runningTotal.value,t=U.current.fields.subtotalAfterMerchandiseDiscounts.value,o=U.current.fields.remoteTotalDetails.value;if(ie.value){const o={currency:e?.currencyCode,total:e?.amount,subtotalAfterMerchandiseDiscounts:t?.amount};ce?.track(w.AddedPayment,o,void 0,void 0,{shopifyEmitted:!0})}re&&W({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:e})=>{const t={currency:e?.runningTotal?.currencyCode,total:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ce?.track(w.AddedPaymentRemote,t,void 0,void 0,{shopifyEmitted:!0})}})},[ce,U,re,ie]),ye=o(()=>
1{if(ie.value){const{title:e,page:t}=j("/information"),o={name:e,path:t};ce?.track(w.CheckoutContactPageStarted,o,void 0,void 0,{shopifyEmitted:!0})}},[ce,ie]),ke=o(()=>{const e=V.value,t=q.value,o=U.current.fields.subtotalAfterMerchandiseDiscounts.value,r=U.current.fields.remoteTotalDetails.value;if(ie.value){const r={email:e,phone:t,subtotalAfterMerchandiseDiscounts:o?.amount};ce?.track(w.CheckoutContactInfoSubmitted,r,void 0,void 0,{shopifyEmitted:!0})}re&&W({remoteTotalDetails:r,emitRemoteEventForShop:({remoteTotals:o})=>{const r={email:e,phone:t,subtotalAfterMerchandiseDiscounts:o?.subtotal?.amount};ce?.track(w.CheckoutContactInfoSubmittedRemote,r,void 0,void 0,{shopifyEmitted:!0})}})},[ce,V,q,U,re,ie]),ve=o(()=>{const e=G.value,t=U.current.fields.subtotalAfterMerchandiseDiscounts.value,o=U.current.fields.remoteTotalDetails.value;if(ie.value){const o={city:e?.city,country:e?.countryCode,phone:e?.phone,province:e?.zoneCode,postalCode:e?.postalCode,firstName:e?.firstName,lastName:e?.lastName,address1:e?.address1,address2:e?.address2,subtotalAfterMerchandiseDiscounts:t?.amount};ce?.track(w.CheckoutAddressInfoSubmitted,o,void 0,void 0,{shopifyEmitted:!0})}re&&W({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:t})=>{const o={city:e?.city,country:e?.countryCode,phone:e?.phone,province:e?.zoneCode,postalCode:e?.postalCode,firstName:e?.firstName,lastName:e?.lastName,address1:e?.address1,address2:e?.address2,subtotalAfterMerchandiseDiscounts:t?.subtotal?.amount};ce?.track(w.CheckoutAddressInfoSubmittedRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ce,G,U,re,ie]),be=o(()=>{if(!ie.value)return;const{title:e,page:t}=j("/shipping"),o={name:e,path:t};ce?.track(w.CheckoutShippingPageStarted,o,void 0,void 0,{shopifyEmitted:!0})},[ce,ie]),Ce=o(()=>{const e=U.current.fields.runningTotal.value,t=U.current.fields.subtotalAfterMerchandiseDiscounts.value,o=U.current.fields.remoteTotalDetails.value;if(ie.value){const o={total:e?.amount,currency:e?.currencyCode,subtotalAfterMerchandiseDiscounts:t?.amount};ce?.track(w.CheckoutShippingInfoSubmitted,o,void 0,void 0,{shopifyEmitted:!0})}re&&W({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:e})=>{const t={total:e?.runningTotal?.amount,currency:e?.runningTotal?.currencyCode,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ce?.track(w.CheckoutShippingInfoSubmittedRemote,t,void 0,void 0,{shopifyEmitted:!0})}})},[ce,U,re,ie]),ge=o(()=>{if(!ie.value)return;const{title:e,page:t}=j("/payment"),o={name:e,path:t};ce?.track(w.CheckoutPaymentPageStarted,o,void 0,void 0,{shopifyEmitted:!0})},[ce,ie]);R(o(e=>{ne.value.defaultAttributes&&"page_view"===e.type&&ue(e.url)},[ne,ue])),R(o(e=>{ne.value.defaultAttributes&&"initiate_checkout"===e.type&&me()},[ne,me])),R(o(e=>{ne.value.defaultAttributes&&"initiate_checkout_once_per_checkout"===e.type&&he()},[ne,he])),R(o(e=>{ne.value.defaultAttributes&&"complete_checkout"===e.type&&pe()},[ne,pe])),R(o(e=>{ne.value.defaultAttributes&&"add_payment_info"===e.type&&fe()},[ne,fe]));const Se=e(!1),Ae=e(void 0),Ie=S(ke,500),Ee=S(ve,500);return R(o(e=>{ne.value.defaultAttributes&&!te.has(e)&&(te.add(e),"one_page_checkout_page_view"===e.type&&(de(e.url),"/"===e.url&&void 0===Ae.current&&(ye(),Se.current=!0)),"section_interaction"===e.type&&Y&&("contact"===e.section?(Se.current&&void 0===Ae.current||ye(),Se.current=!1):"payment"===e.section&&(Ce(),ge()),Ae.current=e.section),"section_complete"===e.type&&("contact"===e.section?Ie():"deliveryAddress"===e.section&&Ee()),"shipping_methods_filled"===e.type&&Y&&be(),"page_submit"!==e.type||"shipping"!==e.page||Y||Ce())},[ne.value.defaultAttributes,Y,ye,te,de,Ce,ge,Ie,Ee,be])),null}export{x as default};
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.