1import{ag as e,p as t,M as r,O as o,b8 as i,m as n}from"./2c1ab0fe.GMbxnz74.js";import{kT as a,ed as s,hF as c,gP as u,S as l}from"./4c290a1e.C6TDJ9Fn.js";import{S as d}from"./app.CepNJbvh.js";function f(e){return`${p(e)}:::${e.message}`}function h(e){return p(e)}function p(e){return e.cause&&"object"==typeof e.cause&&"code"in e.cause?`${e.name}::${e.cause.code}`:e.cause&&"object"==typeof e.cause&&"name"in e.cause?`${e.name}::${e.cause.name}`:e.name}class g extends d{constructor(){super(...arguments),this.name="CheckoutProfileChangeError"}}class _ extends d{constructor(){super(...arguments),this.name="CheckoutProfileQueryMissingData"}}class I extends d{constructor(){super(...arguments),this.name="CheckoutProfileQueryFetchError",this.unactionable=!0}}async function k(r,o){const{trigger:i,profileRequest:n,graphql:c,extensibility:u,configuration:l,observability:d,userEvents:p,telemetryContext:I,isActive:E}=o,T=E??(()=>!0),S=performance.now(),v=Date.now(),P={hasFinalized:!1},N=()=>{P.hasFinalized||(P.hasFinalized=!0,r())},D=l.profileId.value,O=n?.id,b=(e,t)=>{N(),D&&O&&O!==D?M({status:"superseded",activeCheckoutProfileId:l.profileId.value,stage:e,error:t}):d.debug("checkout_profile_change","[CheckoutProfileChange]: Checkout profile change not applied due to isActive returning false",{configurationRecordId:O,stage:e})};if("simulated"===I?.source?.type)return void N();if(!T())return b("before_fetch");if(!n?.id)return void N();const w=n,{requireBusinessCriticalOnly:y}=w,U=l.profileKey.peek();if(U&&e(a,U)===e(a,w))return void N();const A=O!==D,L=A?void 0:l.getProfile(w);try{let e,r;if(L)e=L;else{const o=await t(async()=>{const{data:e,error:t}=await c.staticQuery(a,{variables:w,cache:!0});if(t)throw t;if(!e)throw new _("Checkout profile query returned no data");if(!e.checkoutProfile)throw new _("Checkout profile query returned no checkout profile data");if(A&&!e.shop)throw new _("Checkout profile query returned no shop data");return e},{maxAttempts:3,shouldRetry:()=>!y&&T()});e=o.checkoutProfile,r=o.shop}if(!T())return b("after_fetch");const n=()=>{try{if(!T())return void b("before_apply");const t=e.activatedExtensions,{removed:n,kept:a}=function(e,t){const r=e.ui.search().peek().filter(e=>"persisted"===e.type),o=new Set(t.flatMap(e=>e.targets.map(e=>e.publicIdentifier))),i=r.filter(e=>!o.has(e.targetPublicIdentifier));i.length>0&&e.ui.remove(i.map(e=>e.targetPublicIdentifier),{keepAlive:!1,reason:"checkout_profile_change"});return{removed:i,kept:e.ui.search().peek().filter(e=>"persisted"===e.type)}}(u,t);N();const s=e=>e.capabilities.blockProgress&&e.behaviors.value.blockProgress,c=a.filter(s),f=n.filter(s);u.ui.replace({activatedExtensions:t},{keepAlive:!1,reason:"checkout_profile_change"}),"negotiation"===i&&(c.length>0||f.length>0)&&(d.leaveErrorBreadcrumb("[CheckoutProfileChange] Running negotiation interceptors",{identifier:"checkout_profile_configuration_change",reason:"Blocking UI extension removed/updated. Validation errors will be updated, but interceptor behavior (block/allow) will be ignored.",removedBlockingExtensions:m(f),updatedBlockingExtensions:m(c)}),o.runInterceptors({negotiationStage:"negotiation",skipEffects:!1}).then(e=>{T()&&o.setValidationErrors(e.errors)}).catch(e=>{d.error(new g("Error occurred while running interceptors after checkout profile change",{cause:e}))})),l.update({profile:e,requireBusinessCriticalOnly:y,...A&&r?{themeData:r,addressSettings:{shopConfig:r}}:{}}),M({status:"success"})}catch(t){R(t)}};return n}catch(q){if(!T())return b("fetch_failed",C(q));if(y){"initialization"!==i&&d.counter({name:"checkout_profile_unrestricted_fallback",value:1,attributes:{trigger:i,reason:"query_failure"}});const e=C(q);return d.error(e),d.leaveErrorBreadcrumb("[CheckoutProfileChange] Loading unrestricted profile after restricted query failure",{checkoutProfileId:O}),k(N,{...o,profileRequest:{...n,requireBusinessCriticalOnly:!1}})}R(q)}function R(e){const t=C(e);N(),d.error(t),M({status:"error",error:t})}function M({status:e,error:t,activeCheckoutProfileId:r,stage:o}){"initialization"!==i&&(function(e,t){const{startTime:r,startTimestamp:o,previousCheckoutProfileId:i,checkoutProfileId:n,activeCheckoutProfileId:a,trigger:c,status:u,stage:l,error:d}=t,p=Math.round(performance.now()-r),{observability:g,userEvents:_,source:I,shop:k,sessionToken:C,current:m}=e,E=I.checkoutSessionIdentifier??"",T=k.id,S=m.fields.buyerIdentity.peek()?.customerProfile?.id,v=s(n),P=s(i),N=d?f(d):void 0,D=d?h(d):void 0,O=Intl.DateTimeFormat().resolvedOptions().timeZone;"superseded"!==u&&_.monorailEvent({schemaId:"checkout_c1_profile_configuration_change_events/1.0",payload:{eventName:"checkout_profile_configuration_change",eventType:n===i?"business_critical_filter":"checkout_profile_markets_interaction",frontendEventTimestampEpochMs:o,frontendEventTimeZone:O,checkoutToken:E,shopId:T,customerId:S,sessionToken:C,checkoutProfileId:v,previousCheckoutProfileId:P,frontendEventsTimeDifferenceMs:p,errors:N?[N]:void 0}}),g.histogram({name:"checkout_profile_configuration_change",value:p,attributes:{trigger:c,status:u,error:D}});const b={previousCheckoutProfileId:i,checkoutProfileId:n,...a?{activeCheckoutProfileId:a}:{},trigger:c,duration:p,status:u,...l?{stage:l}:{},error:D},w="superseded"===u?`Checkout profile change to ${n} superseded; active profile is ${a??"none"}`:`Checkout profile changed from ${i} to ${n}`;g.log("checkout_profile_configuration_change",w,b),g.leaveErrorBreadcrumb("[CheckoutProfileChange] Checkout profile change event recorded",{identifier:"checkout_profile_configuration_change",...b})}({observability:d,userEvents:p,...I},{startTime:S,startTimestamp:v,previousCheckoutProfileId:D,checkoutProfileId:O,activeCheckoutProfileId:r,trigger:i,status:e,stage:o,error:t}),"superseded"!==e&&d.debug("checkout_profile_change",`[CheckoutProfileChange] ${t?"Failed to update":"Updated"} checkout profile`,{trigger:i,previousCheckoutProfileId:D,checkoutProfileId:O,error:t?h(t):void 0}))}}function C(e){return e instanceof r||e instanceof o?new I("Could not complete checkout profile change, could not query checkout profile",{cause:e}):new g("Could not complete checkout profile change",{cause:e})}function m(e){return e.map(({id:e,name:t,appName:r,extensionPoint:{target:o}})=>({id:e,name:t,appName:r,target:o}))}function E({checkout:e,shop:t,profileId:r=e.configuration.profileId.peek()}
1){if(!r)return;const o=e.latestReceipt.peek(),i=e.wallets.escalatedWallet.peek();return{id:r,requireBusinessCriticalOnly:"three-page"===e.configuration.layout.baseName&&(!o||"failed"===o.status||"abandoned"===o.status)&&("APPLE_PAY"===i&&t.hasFlagEnabled(c)||"GOOGLE_PAY"===i&&t.hasFlagEnabled(u))}}const T="DISCOUNTS_DISCOUNT_CODE_NOT_HONOURED",S=new Set(["DISCOUNTS_ALLOCATIONS_MISMATCH","DISCOUNTS_ADDITIONAL_REQUESTED_DISCOUNT_CODE_DISCARDED"]),v=new Set(["DISCOUNTS_NO_ENTITLED_LINE_ITEMS","DISCOUNTS_UNSUPPORTED_EXPECTATION","DISCOUNTS_CUSTOMER_USAGE_LIMIT_REACHED","DISCOUNTS_INCOMPATIBLE_PURCHASE_TYPE","DISCOUNTS_USAGE_LIMIT_REACHED","DISCOUNTS_QUANTITY_NOT_IN_RANGE","DISCOUNTS_PURCHASE_NOT_IN_RANGE","DISCOUNTS_NO_ENTITLED_SHIPPING_LINES","DISCOUNTS_CUSTOMER_NOT_ELIGIBLE","DISCOUNTS_DISCOUNT_ALREADY_APPLIED","DISCOUNTS_HIGHER_VALUE_DISCOUNT_APPLIED","DISCOUNTS_MAXIMUM_DISCOUNT_CODE_LIMIT_REACHED","DISCOUNTS_DISCOUNT_CODE_APPLICATION_FAILED","DISCOUNTS_CURRENTLY_INACTIVE",T,...S]),P='GraphQL execution failed with errors: [ "Internal error. Looks like something went wrong on our end.',N=["Content-Length header of network response exceeds response Body.","Failed to fetch","The operation was aborted.","The network connection was lost.","GraphQL fetch failed with status:",P,i],D=["A server with the specified hostname could not be found.","An SSL error has occurred and a secure connection to the server cannot be made.","cannot parse response","Failed to fetch","Load failed","cancelled","NetworkError when attempting to fetch resource.","The network connection was lost","The operation couldn't be completed. Protocol error","The request timed out."];function O(e){return e.replace(/\s+/g," ")}const b=e=>{if(""===e)return!0;const t=O(e);return N.some(e=>t.startsWith(e))},w=e=>{if(""===e)return"unknown";const t=O(e);return t.startsWith(i)?D.some(e=>t.endsWith(e))?e:"unknown":t.startsWith(P)?"Internal server error":e};function y({isShippingRequired:e,isPickupSelected:t,shippingCountryCode:r,billingCountryCode:o}){return!e||t?o||r:r||o}function U(e,t){const r=t?e.countrySpecific[t]?.phoneMarketingDisclosure:void 0;return void 0===r?e.phoneMarketingDisclosure:r}function A(e,{pageWasPainted:t=!0}={}){const{observability:r}=l();n(()=>{t&&r.log("page_rendered",`"${e}" page was rendered.`)},[r,e,t])}export{_ as C,v as D,U as a,h as b,f as c,T as d,S as e,w as f,y as p,E as r,b as s,A as u,k as w};
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.