1import{p as e,dH as t,dI as o,dJ as r,dK as i,dL as a,dM as n,dN as s,a as c,bj as u,j as d,dO as l,aI as m,dP as h,bV as p,dQ as f,dR as y,dS as v}from"./f67abd2c.DYpmk7mw.js";import{g as k,T as b,q as C}from"./2c1ab0fe.XVnTovwp.js";import{eH as g,v as S,j as A,eI as I,eJ as E,eK as D,eL as T}from"./164ad2e3.hrg71Gqs.js";import{u as P}from"./fe885b80.DpX5ei01.js";import"./app.Bke-0Cv3.js";import"./d0bb51ec.Bel_y502.js";import"./60a453ce.Al5ISuVm.js";import"./e12db40c.D-IRYT_x.js";import"./9dba8418.C8BcPjk_.js";var R=(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))(R||{});const M="checkout",_=[t,o,r,i,a,n,s];class w extends Error{constructor(){super(...arguments),this.name="TrekkieError"}}class N{constructor({shop:t,checkoutToken:o="",locale:r,analyticsConfig:i,sourceUrl:n,themeId:s,themeCityHash:c,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(e(t.id),10),f=_.filter(e=>t.hasFlagEnabled(e)),y=f.includes(a);this.tricorder.ready(()=>{this.libraryLoaded||(this.libraryLoaded=!0,this.shopifyAnalytics={...this.shopifyAnalytics,lib:this.tricorder},this.trekkieLoadedCallback(this.tricorder?.trekkie))}),this.tricorder.load=e=>{if(this.tricorder.config=e,!y){const{assetPath:e,sriHash:o}=t.trekkieLoadConfiguration,r=e&&o,i=document.getElementsByTagName("script")[0],a=document.createElement("script");a.type="text/javascript",a.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:s,contextUrl:window.location.href,sourceUrl:n}};u.monorailEvent(e)},e.async=!0,e.src=n,r&&(e.setAttribute("integrity",o),e.setAttribute("crossorigin","anonymous")),i?.parentNode?.insertBefore(e,i)},a.async=!0,a.src=n,r&&(a.setAttribute("integrity",o),a.setAttribute("crossorigin","anonymous")),i?.parentNode?.insertBefore(a,i)}};const v={appName:M,development:!1,defaultAttributes:{shopId:p,isMerchantRequest:!!m("_ab")||null,themeId:s,themeCityHash:c,contentLanguage:r,currency:t.currencyCode,checkoutToken:o},isServerSideCookieWritingEnabled:!0,enabledBetaFlags:f};l&&(v.monorailRegion=l),this.tricorder.load({Trekkie:v,...i,"Session Attribution":{},S2S:d})}get tricorder(){return this.analyticsWindow?.trekkie}set tricorder(e){if(!this.analyticsWindow)throw new w("AnalyticsWindow is not set.");this.analyticsWindow.trekkie=e}get shopifyAnalytics(){return this.analyticsWindow.ShopifyAnalytics}set shopifyAnalytics(e){if(!this.analyticsWindow)throw new w("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 O({remoteTotalDetails:e,remoteMerchandiseLinesByShopId:t,emitRemoteEventForShop:o}){if(e)for(const[r,i]of e.perShopRemoteTotals.entries())o(t?{remoteTotals:i,remoteMerchandiseLines:t?.get(r)??[]}:{remoteTotals:i})}function L(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 j(e){const t=e?.map(e=>{const t=e.lineAllocations.reduce((e,t)=>
1(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:p(e.variantId),productId:p(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 W(){const{client:e,observability:t,userEvents:o,environment:r,i18n:{locale:i},shop:a,source:n,checkout:{identity:s,negotiator:M}}=c(),_="shopPay"===s.current.value?"trekkie-checkout-one-shop-app":"trekkie-checkout-one",{data:w}=g(),W=w?.session?.activeCheckoutRolloutTreatments?.flatMap(({rolloutId:e,treatmentId:t})=>{const o=u(e),r=u(t);return void 0!==o&&void 0!==r?[{rolloutId:Number(o),treatmentId:Number(r)}]:[]}),F=d(W),x=n.checkoutSessionIdentifier||n.sourceId;let B=void 0===a.theme?.id||null===a.theme?.id?void 0:parseInt(a.theme.id,10);B&&B>Number.MAX_SAFE_INTEGER&&(B=void 0);const H=a.theme?.cityhash,{email:z,phone:V,shippingAddress:U}=M.parts,q=S(),{value:G}=M.current.fields.deliveryNext,J=e.unstable_getSerialization("apiClientId"),K=e.unstable_getSerialization("apiClientId"),{currentPage:$}=A().value,Q=$&&["onePage"].includes($.id),X=I(),Y=E(),Z=k(new WeakSet).current,{value:ee}=l(),te=ee,oe=P(),re=b(()=>({}),[]),ie=m(),ae=C(e=>{e?ie.value?.defaultAttributes!==e?.defaultAttributes&&ie.setValue({defaultAttributes:e?.defaultAttributes}):t.error(new h("Trekkie is not available"))},[t,ie]),ne=b(()=>{const t=null===H?void 0:H,n=M.current.fields.buyerIdentity.peek(),s={facebookCapiEnabled:a.facebookCapiEnabled,source:_,customerId:p(n?.customerProfile?.id),cartApiClientId:J,apiClientId:K},c=`${r.services.trekkie.url}/${a.trekkieLoadConfiguration?.assetPath||"s/trekkie.storefront.min.js"}`;return X?null:new N({shop:a,checkoutToken:x,locale:i,analyticsConfig:re,sourceUrl:c,themeId:B,themeCityHash:t,userEvents:o,monorailRegion:"shop_domain",s2s:s,getCookie:t=>e.cookies.get(t)??null},ae)},[a,x,i,re,B,H,o,e.cookies,ae,M,J,K,_,X,r.services.trekkie.url]),se=C(e=>{const{title:t,page:o}=L(e);t&&o&&oe.value&&ne?.page(t,{path:o})},[ne,oe]),ce=C(e=>{const{title:t,page:o}=L(e);if(!t||!o||!oe.value)return;const r={name:t,path:o};ne?.track(R.CheckoutOnePageView,r,void 0,void 0,{shopifyEmitted:!0})},[ne,oe]),ue=b(()=>{let e={amount:void 0,currencyCode:void 0};return q&&"filled"===G?.status&&G.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},[G,q]),de=C(()=>{const e=M.current.fields.merchandiseLines.value,t=M.current.fields.remoteMerchandiseDetails.value;if(oe.value){const o=M.current.fields.subtotal.value,r=M.current.fields.subtotalAfterMerchandiseDiscounts.value,i={step:1,products:j(f(e?.lines??[],t)),currency:o?.currencyCode,revenue:o?.amount,subtotalAfterMerchandiseDiscounts:r?.amount,...F.current?.length?{rolloutIds:F.current.map(e=>Number(e.rolloutId)),rolloutTreatmentIds:F.current.map(e=>Number(e.treatmentId))}:{}};ne?.track(R.StartedOrder,i,void 0,void 0,{shopifyEmitted:!0})}te&&O({remoteTotalDetails:M.current.fields.remoteTotalDetails.value,remoteMerchandiseLinesByShopId:y(e?.lines??[],t),emitRemoteEventForShop:({remoteTotals:e,remoteMerchandiseLines:t})=>{const o={step:1,products:t?j(t):[],currency:e?.subtotal?.currencyCode,revenue:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(R.StartedOrderRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ne,M,te,oe,F]),le=C(()=>{const e=M.current.fields.subtotal.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.current.fields.remoteTotalDetails.value,r=M.current.fields.merchandiseLines.value,i=M.current.fields.remoteMerchandiseDetails.value,a=f(r?.lines??[],i),n=y(r?.lines??[],i);if(oe.value){const o={step:1,products:j(a),currency:e?.currencyCode,revenue:e?.amount,subtotalAfterMerchandiseDiscounts:t?.amount,...F.current?.length?{rolloutIds:F.current.map(e=>Number(e.rolloutId)),rolloutTreatmentIds:F.current.map(e=>Number(e.treatmentId))}:{}};ne?.track(R.StartedOrderOncePerCheckout,o,void 0,void 0,{shopifyEmitted:!0})}te&&O({remoteTotalDetails:o,remoteMerchandiseLinesByShopId:n,emitRemoteEventForShop:({remoteTotals:e,remoteMerchandiseLines:t})=>{const o={step:1,products:t?j(t):[],currency:e?.subtotal?.currencyCode,revenue:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(R.StartedOrderOncePerCheckoutRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ne,M,te,oe,F]),me=C(()=>
1{if(!q)return;if(Y.shouldPrevent())return;if(!oe.value)return;const e=M.current.fields.merchandiseLines.value,t=e?.lines&&j(e?.lines),o=q.purchaseOrder,r=p(q.orderIdentity.id),i=r?.toString(),a=o.billingAddress,n=M.current.fields.buyerIdentity.value,s=n?.customerProfile;let c=s?.firstName,u=s?.lastName;u||(c=a?.firstName,u=a?.lastName);const d=M.current.fields.total.value,l=M.current.fields.subtotal.value,m=M.current.fields.subtotalAfterMerchandiseDiscounts.value,h=D(M),f=M.current.fields.contactInfo.value,y=M.current.fields.discountLines.value,v=y?.lines.filter(e=>"code"===e.discount.type).map(e=>e.discount.title)||[],k=q.analytics?.checkoutCompletedEventId||void 0,b=q.analytics?.emitConversionEvent||!1;ne?.track(R.CompletedOrder,{customerEventData:{customer:{firstName:c,lastName:u,emailAddress:s?.email??f?.email,phoneNumber:s?.phone??f?.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:v[0],tax:h?.amount??0,shipping:ue.amount??0},k,b,{shopifyEmitted:!0}),Y.markAsEmitted()},[q,M,ne,ue.amount,Y,oe]),he=C(()=>{const e=M.current.fields.runningTotal.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.current.fields.remoteTotalDetails.value;if(oe.value){const o={currency:e?.currencyCode,total:e?.amount,subtotalAfterMerchandiseDiscounts:t?.amount};ne?.track(R.AddedPayment,o,void 0,void 0,{shopifyEmitted:!0})}te&&O({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:e})=>{const t={currency:e?.runningTotal?.currencyCode,total:e?.runningTotal?.amount,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(R.AddedPaymentRemote,t,void 0,void 0,{shopifyEmitted:!0})}})},[ne,M,te,oe]),pe=C(()=>{if(oe.value){const{title:e,page:t}=L("/information"),o={name:e,path:t};ne?.track(R.CheckoutContactPageStarted,o,void 0,void 0,{shopifyEmitted:!0})}},[ne,oe]),fe=C(()=>{const e=z.value,t=V.value,o=M.current.fields.subtotalAfterMerchandiseDiscounts.value,r=M.current.fields.remoteTotalDetails.value;if(oe.value){const r={email:e,phone:t,subtotalAfterMerchandiseDiscounts:o?.amount};ne?.track(R.CheckoutContactInfoSubmitted,r,void 0,void 0,{shopifyEmitted:!0})}te&&O({remoteTotalDetails:r,emitRemoteEventForShop:({remoteTotals:o})=>{const r={email:e,phone:t,subtotalAfterMerchandiseDiscounts:o?.subtotal?.amount};ne?.track(R.CheckoutContactInfoSubmittedRemote,r,void 0,void 0,{shopifyEmitted:!0})}})},[ne,z,V,M,te,oe]),ye=C(()=>{const e=U.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.current.fields.remoteTotalDetails.value;if(oe.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};ne?.track(R.CheckoutAddressInfoSubmitted,o,void 0,void 0,{shopifyEmitted:!0})}te&&O({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};ne?.track(R.CheckoutAddressInfoSubmittedRemote,o,void 0,void 0,{shopifyEmitted:!0})}})},[ne,U,M,te,oe]),ve=C(()=>{if(!oe.value)return;const{title:e,page:t}=L("/shipping"),o={name:e,path:t};ne?.track(R.CheckoutShippingPageStarted,o,void 0,void 0,{shopifyEmitted:!0})},[ne,oe]),ke=C(()=>{const e=M.current.fields.runningTotal.value,t=M.current.fields.subtotalAfterMerchandiseDiscounts.value,o=M.current.fields.remoteTotalDetails.value;if(oe.value){const o={total:e?.amount,currency:e?.currencyCode,subtotalAfterMerchandiseDiscounts:t?.amount};ne?.track(R.CheckoutShippingInfoSubmitted,o,void 0,void 0,{shopifyEmitted:!0})}te&&O({remoteTotalDetails:o,emitRemoteEventForShop:({remoteTotals:e})=>{const t={total:e?.runningTotal?.amount,currency:e?.runningTotal?.currencyCode,subtotalAfterMerchandiseDiscounts:e?.subtotal?.amount};ne?.track(R.CheckoutShippingInfoSubmittedRemote,t,void 0,void 0,{shopifyEmitted:!0})}})},[ne,M,te,oe]),be=C(()=>
1{if(!oe.value)return;const{title:e,page:t}=L("/payment"),o={name:e,path:t};ne?.track(R.CheckoutPaymentPageStarted,o,void 0,void 0,{shopifyEmitted:!0})},[ne,oe]);T(C(e=>{ie.value.defaultAttributes&&"page_view"===e.type&&se(e.url)},[ie,se])),T(C(e=>{ie.value.defaultAttributes&&"initiate_checkout"===e.type&&de()},[ie,de])),T(C(e=>{ie.value.defaultAttributes&&"initiate_checkout_once_per_checkout"===e.type&&le()},[ie,le])),T(C(e=>{ie.value.defaultAttributes&&"complete_checkout"===e.type&&me()},[ie,me])),T(C(e=>{ie.value.defaultAttributes&&"add_payment_info"===e.type&&he()},[ie,he]));const Ce=k(!1),ge=k(void 0),Se=v(fe,500),Ae=v(ye,500);return T(C(e=>{ie.value.defaultAttributes&&!Z.has(e)&&(Z.add(e),"one_page_checkout_page_view"===e.type&&(ce(e.url),"/"===e.url&&void 0===ge.current&&(pe(),Ce.current=!0)),"section_interaction"===e.type&&Q&&("contact"===e.section?(Ce.current&&void 0===ge.current||pe(),Ce.current=!1):"payment"===e.section&&(ke(),be()),ge.current=e.section),"section_complete"===e.type&&("contact"===e.section?Se():"deliveryAddress"===e.section&&Ae()),"shipping_methods_filled"===e.type&&Q&&ve(),"page_submit"!==e.type||"shipping"!==e.page||Q||ke())},[ie.value.defaultAttributes,Q,pe,Z,ce,ke,be,Se,Ae,ve])),null}export{W 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.