PageSourceSearch

https://shop.plantura.garden/cdn/shopifycloud/checkout-web/assets/c1/ExtensionsInner.BRI8nSzT.js

js plantura.garden collected 2026-10-01 12:09:19 UTC 44,850 bytes, 1 lines download raw bytes

1import{f as fe,ac as K,A as M,h as k,n as Be,V as $e,j as je,R as Fe,a4 as oe,y as V,E as qe,e as me,q as Z,o as Ge,G as Ve,u as B,T as xe,k as He,_ as ze}from"./esnext-vendor.BDPAaZdq.js";import{f1 as We,gd as Ke,bY as ee,e as j,d$ as Ee,ge as Qe,gf as Je,h as Xe,bf as Ye,bi as Ze,gg as et,gh as tt,gi as nt,gj as st,gk as it,d_ as ye,f4 as ot,cy as rt,av as at,gl as ct,gm as dt,bh as ut,gn as lt,go as ht}from"./hydrate.B0xlt2dG.js";import{i as pt,A as gt,D as ft}from"./shared-permissions.BaDWlj5_.js";import{O as P,P as mt,aS as be,bh as re,gd as xt,ge as te,b1 as H,A as ve,gf as Et,gg as yt,gh as bt,ap as vt,aL as wt,a6 as we}from"./hooks-useReplaceShopPayInHistory.C8UL-mAH.js";import{i as Tt,s as At}from"./ImpressionEventCapture.iMEQlBKs.js";import{e as L,c as St,b as It,d as Ct,f as kt,g as Rt,h as Nt,j as Lt,s as _t,k as Mt,l as Pt,m as Dt,n as Ot,o as Ut,p as Te,R as Bt,q as $t,r as jt,t as Ft,u as qt,v as Gt,w as Vt,x as Ht,y as zt}from"./extension-targets-rendering-extension-targets.tmKtkZ2m.js";import{a as Wt}from"./hooks-useForceShopPayUrl.F3deeEs7.js";import{e as N}from"./performance-index.mu6MOGR9.js";import{v as Kt}from"./dist-v4.EwEgHOG0.js";import{i as Qt,e as Jt}from"./app.D1P6yWfp.js";import{T as X,a as Xt,b as ae,c as G,d as Q,e as Yt,A as Y,f as ce,H as Zt,M as en,i as tn,g as J,E as Ae,h as nn,L as sn,j as on,k as rn,l as an,m as cn,n as dn}from"./utilities-extension-execution-errors.DALAv5qR.js";import{a as un,i as ln,c as hn}from"./AnnouncementRuntimeExtensions.BmwVyQEZ.js";import{a as pn}from"./adapter-host.D9Q-kuZb.js";import{L as de}from"./extensions-remote-dom.CBgtF6hU.js";import{c as gn}from"./amazon-pay-useAmazonPayPaymentLine.BXwZMsYY.js";import"./helpers-getNormalizedPaymentMethodName.B-mE5wnL.js";import"./hooks-useShopPayExternalAppContext.DyGXtar4.js";import"./checkout-updaters-helpers.BAeH3ddd.js";import"./cross-border-hooks.DVubeg9N.js";import"./AddressPresenter.B0qw2vWQ.js";import"./QRCode.DqS7YeCa.js";import"./Pressable.MgKWvfeE.js";import"./Checkbox.CiixBh9Z.js";import"./Choice.BIzIW4rp.js";import"./utilities-dates.ChO2GdxN.js";
1import"./Popover.BUTwaoOa.js";import"./PaymentIcon.CQXs-ePm.js";import"./NumberField.BZROjWxa.js";import"./Switch.BG-32C8R.js";import"./EmailField.BtJiNLVF.js";import"./TextArea.C0R8_jwI.js";import"./Sheet.B-DMh7lO.js";import"./styles-floating-layer.module.BOdGEzlq.js";import"./PhoneField.ykPh8SPx.js";import"./FormLayout.CMVyKzjL.js";import"./hooks-useSuppressShopPayModalOnLoad.brztd70E.js";function fn(){const i=We(),{i18n:e}=P();return fe(()=>i.value?{id:"cart",label:e.translate("general.cart"),route:"",features:[]}:void 0)}function mn(i,e){const t=K(i?.translations[i.defaultLocale]??{}),n=Se(e),s=K(i?.translations[n]??{}),o=K(i?.translations[e]??{});return En(new Map([...t,...s,...o]))}function xn(i,e){if(!i)return e;const t=new Set(Object.keys(i.translations));if(t.size===0||t.has(e))return e;const n=Se(e);return t.has(n)?n:i.defaultLocale}function En(i){const e={};for(const[t,n]of i)e[t]=n;return e}function Se(i){return i.split("-")[0]}function yn(i,e){let t=!0;const n=new WebSocket(i),s=({data:o})=>{try{const{type:r}=JSON.parse(o);if(r==="ok"||r==="warnings"){if(t){t=!1;return}e()}}catch(r){console.log(`error parsing update message from ${i} : ${r}`)}};return n.addEventListener("message",s),()=>{n.removeEventListener("message",s),n.close()}}function Ie(i){let e,t;return i.type!=="local"&&(e="targetPublicIdentifier"in i?i.targetPublicIdentifier:void 0,t=i.publicIdentifier),{extensionId:Ke(i),extensionPoint:{target:i.extensionPoint.target,metafields:i.extensionPoint.metafields},placementReference:i.placementReference,type:i.type,appId:i.appId,appApiKey:i.appApiKey??null,apiVersion:i.apiVersion,version:i.version,registrationId:i&&"registrationId"in i?i.registrationId:"",targetPublicIdentifier:e,publicIdentifier:t}}function bn(i){const e=ee(),{currentPage:t,currentDetour:n}=j().value,s=M(t),o=M(n);k(()=>{s.current=t},[t]),k(()=>{o.current=n},[n]),k(()=>{if(i)return i.on("apiRead",r=>{const a=o.current?.type??s.current?.id??"";for(const c of r.apiPropertyNames)e("extensionLifecycle",{apiPropertyName:c,extension:Ie(r.extension),initialPageLoad:r.initialLoad,page:a,phase:"apiRead",section:"extension",timestamp:r.timestamp})})},[e,i])}function vn(){const{shop:i}=P(),e=mt().buyerIdentity;return fe(()=>({isoCode:e.value?.presentmentCurrency??i.currencyCode}))}function wn({renderManager:i}){const{client:e}=P(),t=ee(),{currentPage:n,currentDetour:s}=j().value,o=e.unstable_legacyNavigationPerformance,r=M(n),a=M(s),c=M(i);k(()=>{r.current=n},[n]),k(()=>{a.current=s},[s]),k(()=>{c.current=i},[i]),k(()=>{if(!o)return;const l=o.on("navigation",()=>{N.setEndOfInitialLoad()});return()=>{l()}},[o]),k(()=>N.subscribe(u=>{u.forEach(d=>{const g=a.current?.type??r.current?.id??"";switch(d.type){case"iframe-loader-metric":case"sandbox-fetch-metric":{const{mark:f,duration:x,timestamp:b,initialLoad:T}=d;t("extensionLifecycle",{duration:x,extension:null,phase:f,section:"extension",page:g,timestamp:b,initialPageLoad:!!T,transferredBundleSize:d.type==="sandbox-fetch-metric"?d.transferredBundleSize:void 0,bundleSize:d.type==="sandbox-fetch-metric"?d.bundleSize:void 0});break}case"extension-fetch-call-metric":{const{duration:f,timestamp:x,httpStatus:b,httpMethod:T,errorType:E,destination:y,extension:m,origin:w,requestUrl:S}=d;t("extensionFetchCall",{duration:f,destination:y,httpStatus:b,httpMethod:T,errorType:E,timestamp:x,extension:{extensionId:m.extensionId,extensionPoint:{target:m.extensionPoint.target,metafields:m.extensionPoint.metafields},placementReference:m.placementReference,type:m.type,appId:m.appId,appApiKey:m.appApiKey??null,apiVersion:m.apiVersion,version:m.version,registrationId:"registrationId"in m?m.registrationId:void 0,publicIdentifier:"publicIdentifier"in m?m.publicIdentifier:void 0,targetPublicIdentifier:"targetPublicIdentifier"in m?m.targetPublicIdentifier:void 0},section:"extension",origin:w,requestUrl:S});break}case"extension-metric":{const{mark:f,extension:x,duration:b,timestamp:T,instanceId:E,transferredBundleSize:y,bundleSize:m,initialLoad:w,ttsCompletionReason:S,ttsRenderObserved:p,ttsRequestCount:I}=d;t("extensionLifecycle",{duration:b,instanceId:E,extension:Ie(x),phase:f,section:"extension",page:g,timestamp:T,initialPageLoad:!!w,transferredBundleSize:y,bundleSize:m,ttsCompletionReason:S,ttsRenderObserved:p,ttsRequestCount:I});break}}})}),[t])}const Tn=250;function An(){const{extensionSkeletonBatchStateSignal:i,extensionSkeletonBatchReleaseIdSignal:e,extensionSkeletonPendingCountSignal:t}=be(),n=i.value,s=t.value,o=M(null);return k(()=>
1{if(n!=="collecting"){o.current=null;return}const r=o.current??Date.now();o.current=r;const a=()=>{Be(()=>{e.value+=1,i.value="idle"})};if(s===0){a();return}const c=setTimeout(a,Math.max(0,Tn-(Date.now()-r)));return()=>clearTimeout(c)},[n,s,i,e]),null}class Sn{#e;constructor(e){this.domain=e.domain,this.action=e.action,this.#e=[e.domain,e.action,Kt()].join(":"),Object.freeze(this)}get eventId(){return this.#e}}const In=3,Cn=200,kn=100,ue=100;function Rn(i){return new Nn(i)}class Nn{constructor({proposal:e,observability:t,negotiationRateLimiter:n}){this.queue=[],this.isProcessingQueue=!1,this.debounceTimer=null,this.debouncedNegotiations=[],this.negotiate=async({options:s,extension:o,validateCanNegotiate:r})=>(this.throwIfThrottled(o),s.customizeNegotiation?this.enqueue({options:s,extension:o,validateCanNegotiate:r}):this.debounceNegotiation({options:s,extension:o,validateCanNegotiate:r})),this.throwIfThrottled=s=>{if(this.negotiationRateLimiter.isThrottled(s.id))throw new X(this.negotiationRateLimiter.reason)},this.recordAndCheckThrottle=(s,o)=>{const{isThrottled:r,isFirstThrottled:a}=this.negotiationRateLimiter.record(s.id,o);if(a){if(s.type!=="local"){const l=L(s),u=!0;this.observability.log("extension_sliding_window_throttle_exceeded","[Extensions::Negotiator] Extension exceeded the sliding window throttle (enforced=true)",{reason:this.negotiationRateLimiter.reason,requestCount:this.negotiationRateLimiter.maxRequests,windowMs:this.negotiationRateLimiter.windowMs,enforced:!0,isHighValueExtension:l.isHighValueExtension,extension:l,eventIds:this.negotiationRateLimiter.eventIds(s.id)},{exportImmediately:u}),this.observability.counter({name:"extension_sliding_window_throttle_exceeded",value:1,attributes:{enforced:!0,isHighValueExtension:l.isHighValueExtension},exportImmediately:u})}const c=s.appName?`${s.appName} (${s.name})`:s.name;console.warn(`Checkout UI extension ${c} has exceeded the maximum number of allowed API requests and has been blocked for this session.`)}return r?new X(this.negotiationRateLimiter.reason):null},this.enqueue=async({options:s,extension:o,validateCanNegotiate:r})=>{if(this.queue.length>=kn)throw new Xt("There are too many negotiations waiting to be processed. Please wait and try again.");return new Promise((a,c)=>{this.queue.push({options:s,extension:o,resolve:a,reject:c,retryCount:0,validateCanNegotiate:r}),this.processQueue()})},this.processQueue=async()=>{if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.queue.length>0;){const s=this.queue.shift();try{this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Performing queued negotiation",{...L(s.extension),queueLength:this.queue.length});const o=await this.executeSingleNegotiation({options:s.options,extension:s.extension,validateCanNegotiate:s.validateCanNegotiate});s.resolve(o)}catch(o){if(o instanceof ae&&s.retryCount<In){const r=Cn*2**s.retryCount;this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Retrying stale negotiation",{...L(s.extension),retryCount:s.retryCount,delayMs:r}),await $e(r),s.retryCount++,this.queue.unshift(s)}else s.reject(o)}}this.isProcessingQueue=!1}},this.debounceNegotiation=({options:s,extension:o,validateCanNegotiate:r})=>{if(this.debounceTimer!==null){const a=this.debouncedNegotiations.length+1;return this.observability.debug("extension_negotiation_debounced",`[Extensions::Negotiator] Debounce: collapsing call ${a} into open window`,{callNumber:a,newOptions:s}),this.observability.log("extension_negotiation_debounced","[Extensions::Negotiator] Extension negotiation debounced — collapsing into pending window",{callNumber:a}),new Promise((c,l)=>{this.debouncedNegotiations.push({resolve:c,reject:l,extension:o,options:s,validateCanNegotiate:r})})}return this.observability.debug("extension_negotiation_debounced","[Extensions::Negotiator] Debounce: opening window",{options:s,delayMs:ue}),new Promise((a,c)=>{this.debouncedNegotiations.push({resolve:a,reject:c,extension:o,options:s,validateCanNegotiate:r}),this.debounceTimer=setTimeout(async()=>{const l=[...this.debouncedNegotiations];this.debouncedNegotiations=[],this.debounceTimer=null,await this.executeDebouncedNegotiations(l)},ue)})},this.executeDebouncedNegotiations=async s=>{this.observability.debug("extension_negotiation_debounced",`[Extensions::Negotiator] Debounce: firing for ${s.length} collapsed call(s)`),this.observability.histogram({name:"extension_negotiation_debounce_window_size",value:s.length});const o=this.rejectInvalidNegotiations(s),r=this.rejectThrottledExtensions(o);await Promise.all(r.map(async a=>{try{const c=await this.executeNegotiation({options:a.options});a.resolve(c)}catch(c){a.reject(c)}}))},this.rejectInvalidNegotiations=s=>{const o=[];for(const r of s)try{r.validateCanNegotiate(),o.push(r)}catch(a){r.reject(a)}return o},this.rejectThrottledExtensions=s=>{const o=new Map,r=[];for(const a of s){o.has(a.extension.id)||o.set(a.extension.id,this.recordAndCheckThrottle(a.extension,a.options.reason?.eventId));const c=o.get(a.extension.id);c?a.reject(c):r.push(a)}return r},this.executeSingleNegotiation=({options:s,extension:o,validateCanNegotiate:r})=>{r();const a=this.recordAndCheckThrottle(o,s.reason?.eventId);if(a!==null)throw a;return this.executeNegotiation({options:s})},this.executeNegotiation=async({options:s})=>{const{runListenersOnError:o=!0}=s,r=await this.proposal.negotiate({...s,negotiationStage:"negotiation"});switch(r.status){case"success":{const a={type:r.status,errors:r.errors,violations:r.violations,negotiationStage:"negotiation"};return this.proposal.lastJourneyProgression.value=a,await this.proposal.runListeners(a),r}case"error":{const a={type:r.status,errors:r.errors,violations:r.violations,negotiationStage:"negotiation"};return o&&(this.proposal.lastJourneyProgression.value=a,await this.proposal.runListeners(a)),r}
1case"invalid":throw r.reasons.includes(re.SubmittedForCompletion)?new G("The buyer has already submitted the checkout.",{cause:{code:re.SubmittedForCompletion}}):new Q(`Negotiation was invalid. Reasons: ${r.reasons.join(", ")}`,{cause:{code:"INVALID_NEGOTIATION"}});case"stale":throw new ae("Negotiation was stale.",{cause:{code:"STALE_NEGOTIATION"}});case"denied":throw new Q("A checkpoint was denied during negotiation.",{cause:{code:"DENIED_NEGOTIATION"}});case"throttled":throw new Q("The negotiation was throttled.",{cause:{code:"THROTTLED_NEGOTIATION"}});case"tooManyRequests":throw new G("The negotiation was halted due to too many requests.",{cause:{code:"TOO_MANY_REQUESTS_IN_NEGOTIATION"}});case"alreadyCompleted":throw new G("Negotiation was already completed.",{cause:{code:"ALREADY_COMPLETED_NEGOTIATION"}});case"fetch_failed":throw new G("The negotiation fetch failed.",{cause:{code:"NEGOTIATION_FETCH_FAILED"}});default:return(c=>{throw new Yt("Unknown negotiation result.",{cause:{code:"UNKNOWN_NEGOTIATION_RESULT"}})})()}},this.proposal=e,this.observability=t,this.negotiationRateLimiter=n}}const Ln="unknownChange";function _n({captureEvent:i,journeyCompletedSignal:e,wallets:t,proposal:n,observability:s,extensionPerformance:o,negotiationRateLimiter:r}){const{negotiate:a}=Rn({proposal:n,observability:s,negotiationRateLimiter:r});function c(d,{error:g,changeTypeName:h,startTimestamp:f,extension:x,extensionInstanceId:b,initialLoad:T,eventId:E}){i("extensionInteraction",{interaction:`${h}${d}`,error:g,duration:d==="Start"||f===void 0?void 0:performance.now()-f,extension:x,section:"extension",extensionInstanceId:b??"",timestamp:new Date,initialLoad:T,eventId:E,throttleCounter:r.count(x.id)})}function l({changeTypeName:d,message:g,extension:h,eventId:f,changeIsNoOp:x}){s.leaveErrorBreadcrumb(`Extensions::API::${d}`,{message:g,eventId:f,throttleCounter:r.count(h.id),extension:{appId:h.appId,id:h.id,registrationId:h.type==="local"?void 0:h.registrationId},...x!==void 0&&{changeIsNoOp:x}})}function u({changeTypeName:d,change:g,result:h,error:f,extension:x,extensionInstanceId:b,initialLoad:T,changeIsNoOp:E}){const y=f?"failed":"successful",m={...L(x),change:g,result:h,...f&&{error:f},...E!==void 0&&{changeIsNoOp:E},extensionInstanceId:b,initialLoad:T};s.debug("extenstions_change_applied",`[Extensions::ApplyChange::${d}] ${y}`,m)}return async function({unknownChange:g,extension:h,allowChangeAfterJourneyCompletion:f=!1,allowChangeDuringAcceleratedWallet:x=!1,handlers:b,errorResult:T,extensionInstanceId:E}){const y=Ce(g)?g.type:Ln,m=Ee(h),w=o.initialLoad,S=new Sn({domain:"extensibility",action:y}),p=S.eventId;c("Start",{changeTypeName:y,extension:h,extensionInstanceId:E,initialLoad:w,eventId:p});const I=performance.now();try{Dn(g,b);const C=g;le({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:f,allowChangeDuringAcceleratedWallet:x}),On({negotiationRateLimiter:r,extension:h});const A=b[C.type];let v=!1;const D=await A({change:C,negotiate(R){return a({options:{...R,reason:S},extension:h,validateCanNegotiate:()=>le({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:f,allowChangeDuringAcceleratedWallet:x})})},markChangeAsNoOp(){v=!0}});return c("Success",{changeTypeName:y,extension:h,extensionInstanceId:E,startTimestamp:I,initialLoad:w,eventId:p}),l({changeTypeName:y,message:`Applied change ${y} successfully`,extension:h,eventId:p,changeIsNoOp:v}),u({changeTypeName:y,change:C,result:D,extension:h,extensionInstanceId:E,initialLoad:w,changeIsNoOp:v}),D}catch(C){const A=Un(C);Bn(A)?c("Success",{error:A,changeTypeName:y,extension:h,startTimestamp:I,extensionInstanceId:E,initialLoad:w,eventId:p}):c("Error",{error:A,changeTypeName:y,extension:h,startTimestamp:I,extensionInstanceId:E,initialLoad:w,eventId:p}),s.error(A,{metadata:{extension:m,change:{type:y}}}),l({changeTypeName:y,message:`Could not apply change ${y}. Error: ${A.message}`,extension:h,eventId:p});const v=T(A);return u({changeTypeName:y,change:g,result:v,error:{name:A.name,message:A.message,cause:A.cause},extension:h,extensionInstanceId:E,initialLoad:w}),v}}}function Ce(i){return Mn(i)?!!Pn(i.type):!1}function Mn(i){return typeof i=="object"&&i!==null&&"type"in i&&typeof i.type=="string"}function Pn(i){return Qe.includes(i)}function Dn(i,e){if(!Ce(i)||!Object.keys(e).includes(i.type))throw new Y(`Unknown change type "${i?.type}". Valid change types include: ${Object.keys(e).map(t=>`"${t}"`).join(", ")}.`)}function le({journeyCompletedSignal:i,wallets:e,allowChangeAfterJourneyCompletion:t,allowChangeDuringAcceleratedWallet:n}){if(!t&&i.peek())throw new Y("The buyer journey is completed");if(!n&&e.activeSession.value)throw new Y("The buyer is using an accelerated wallet")}function On({negotiationRateLimiter:i,extension:e}){if(i.isThrottled(e.id))throw new X(i.reason)}function Un(i){return i instanceof Error?i:typeof i=="string"?new ce(i):new ce("unknown")}function Bn(i){return xt(i.name)||Qt(i)||Jt(i)}function ke(i){const{shop:e,extension:t}=i,{attributes:n}=St(i),{billingAddress:s,shippingAddress:o}=It(i),{metafields:r}=Ct(i),{appMetafields:a}=kt(i);return{...Ut(i),...Ot(i),...Dt(i),...Pt(i),...un(i),appMetafields:a,attributes:n,billingAddress:s,extension:Mt(i),..._t(t.apiVersion)?{metafields:r}:{},settings:Lt(i),shippingAddress:o,shop:Nt(e),storage:Rt(i),version:t.apiVersion}}const he=Te({name:"purchase.address-autocomplete.suggest",api(i){return{signal:void 0,target:{},...ke(i)}}}),pe=Te({name:"purchase.address-autocomplete.format-suggestion",api(i){return{target:{},...ke(i)}}}),ne={[he.name]:he,[pe.name]:pe},$n={...Bt,...ne};function Re(i,e,t){const n=r(),s=te(n.extensionInstance.target);return a(n);function o(c){return s in ne?c.value:$t({get current(){return c.value},subscribe:l=>{const u=je(()=>{l(c.value)}),d=i.on("restart",()=>{h()}),g=i.on("destroy",()=>{h()}),h=()=>{u(),d(),g()};return h}})}function r(){return{extensionInstance:i,createSubscribableFromSignal:o,...e}}function a(c){return $n[s].api(c,t)}}class se{static#e=3e4;#t;#n;#r;#s=null;#o;#a=()=>{};#c=()=>{};#d=[];#u=!1;#i=new Set;constructor(e){this.#n=new MessageChannel,this.#r=this.#n.port2,this.#o=new Promise((t,n)=>{this.#a=t,this.#c=n}),this.#t=gn({id:e.id,url:e.sandboxUrl,privileges:["allow-scripts","allow-same-origin"],name:e.name}),this.#p(e.sandboxUrl)}get rpcPort(){return this.#r}get portReady(){return this.#o}register(e){this.#i.has(e)||Fe(e),this.#i.add(e)}unregister(e){this.#i.has(e)&&(oe(e),this.#i.delete(e))}
1emit(e){this.#i.forEach(t=>{try{t(e)}catch(n){throw new H(`HostedIframe relay listener threw: ${n}`)}})}onMessage(e){let t=!1;return this.#s?this.#s.addEventListener("message",e):this.#o.then(n=>{t||n.addEventListener("message",e)}).catch(()=>{}),()=>{t=!0,this.#s?.removeEventListener("message",e)}}postMessage(e){this.#s?.postMessage(e)}destroy(){this.#u||(this.#u=!0,this.#d.forEach(e=>e()),this.#s?.close(),this.#i.forEach(e=>{oe(e)}),this.#i.clear(),this.#t.remove())}get relayApi(){return{register:e=>this.register(e),unregister:e=>this.unregister(e),emit:e=>this.emit(e),postMessage:e=>this.postMessage(e),destroy:()=>this.destroy()}}#l(e){return e.source===this.#t.contentWindow}#h(e,t){return typeof e.data=="object"&&e.data!==null&&e.data.eventName===t}#p(e){const t=this.#g(e);if(!t)return;const n=this.#n.port1;let s=!1;const o=c=>{if(!(!this.#h(c,"app-bridge-checkout::handshake")||c.origin!==t||!this.#l(c))){try{c.source?.postMessage({eventName:"checkout-web::rpc-host-port"},{targetOrigin:t,transfer:[n]}),s=!0}catch(l){if(l instanceof Error&&l.message.includes("already neutered"))return;throw l}window.removeEventListener("message",o),s&&window.addEventListener("message",r)}},r=c=>{!this.#h(c,"app-bridge-checkout::port-transfer")||c.origin!==t||!this.#l(c)||!c.ports||c.ports.length!==1||(c.source?.postMessage({eventName:"checkout-web::port-received"},{targetOrigin:t}),this.#s=c.ports[0],this.#s.start(),this.#a(this.#s),clearTimeout(a),window.removeEventListener("message",r))},a=setTimeout(()=>{window.removeEventListener("message",o),window.removeEventListener("message",r),this.#c(new Zt("HostedIframe handshake timed out"))},se.#e);window.addEventListener("message",o),this.#d.push(()=>{clearTimeout(a),window.removeEventListener("message",o),window.removeEventListener("message",r)})}#g(e){try{return new URL(e).origin}catch{return null}}}const ge=100;class Ne{constructor({context:e,extension:t,id:n,extensionInstanceCache:s,options:o}){this.#e=V(new Set),this.teardowns=[],this.sandboxListenerCleanups=[],this.id=n,this.target=t.extensionPoint.target,this.extension=t,this.options=o,this.extensionInstanceCache=s;const r={...e},{addDeactivatedExtension:a,defaultCacheDuration:c,sandboxCache:l,...u}=r;this.sandboxCache=l,this.createApiContext=u,this.eventMap=new Map,this.blocking=qe(()=>this.#e.value.size>0)}#e;markBlocking(e){if(this.isDestroyed)return;const t=this.#e.value;if(!t.has(e)){const n=new Set(t);n.add(e),this.#e.value=n}this.emit("block")}markNotBlocking(e){if(this.isDestroyed)return;const t=this.#e.value;if(!t.has(e))return;const n=new Set(t);n.delete(e),this.#e.value=n,n.size===0&&this.emit("unblock")}on(e,t){let n=this.eventMap.get(e);return n==null&&(n=new Set,this.eventMap.set(e,n)),n.add(t),()=>{n.delete(t)}}emit(e){const t=this.eventMap.get(e);if(t!=null)for(const n of t)n()}initializeSandbox(){if(!this.sandboxCache)throw new en("Attempted to create a sandbox in an environment that does not support them");this.sandbox=this.sandboxCache.getOrCreate({extension:this.extension,storefrontUrl:this.createApiContext.shop.storefrontUrl,myshopifyDomain:this.createApiContext.shop.myshopifyDomain}),this.sandboxListenerCleanups=this.installSandboxListeners(this.sandbox)}notifyError({error:e,isDeactivated:t=!1}){this.createApiContext.observability.error(e,{severity:"error",metadata:{...t?{deactivatedExtension:{id:this.extension.id}}:{},extension:{...Ee(this.extension),extensionInstanceId:this.id},source:{type:this.createApiContext.sourceType}}})}performCleanup(e){this.createApiContext.observability.leaveErrorBreadcrumb("ExtensionInstance: Destroy set to true",{isDestroyed:this.isDestroyed,rendered:this.rendered,extensionId:this.id,reason:e.reason}),this.#e.value.size>0&&(this.#e.value=new Set,this.emit("unblock"));for(const n of this.sandboxListenerCleanups)n();this.sandboxListenerCleanups=[];const t=this.teardowns;this.teardowns=[],this.extensionInstanceCache.delete(this.id),this.executeTeardowns(t),this.sandboxCache?.release(this.sandbox),this.emit("destroy"),this.eventMap.clear(),this.createApiContext.observability.leaveErrorBreadcrumb("ExtensionInstance: Destroy event emitted",{isDestroyed:this.isDestroyed,rendered:this.rendered,extensionId:this.id,reason:e.reason})}addTeardown(e){this.isDestroyed?this.executeTeardowns([e]):(this.teardowns.length>=ge&&(this.teardowns.shift(),this.createApiContext.observability.log("extension_teardown_queue_overflow",`[Extensions::Teardown] Teardown queue exceeded ${ge}, dropping oldest`,{appId:this.extension.appId,extensionId:this.extension.extensionId,registrationId:"registrationId"in this.extension?this.extension.registrationId:void 0})),this.teardowns.push(e))}executeTeardowns(e){Promise.allSettled(e.map(t=>{try{return t()}catch(n){return Promise.reject(n)}})).then(t=>{for(const n of t){if(n.status!=="rejected")continue;const s=n.reason;ln(s)||tn(s)||this.createApiContext.observability.log("extension_teardown_error","[Extensions::Teardown] Teardown failed",{errorClass:s instanceof Error?s.constructor.name:typeof s,errorMessage:String(s),errorStack:s instanceof Error?s.stack??"":""})}})}}function Le({createApiContext:i,extension:e,phase:t,instanceId:n,mountId:s,mountStartTime:o,page:r="",error:a}){const{captureEvent:c,observability:l}=i,u=t==="mountStart"||o==null?void 0:Date.now()-o,d=a instanceof Error?a:void 0;if(c("extensionLifecycle",{duration:u,extension:e,phase:t,section:"extension",page:r,timestamp:new Date,instanceId:n,...s&&{mountId:s},...d&&{error:d},initialPageLoad:N.initialLoad}),t==="mountSuccess"||t==="mountError"){const g={...L(e),duration:u,...s&&{mountId:s},...d&&{error:{...d,message:d?.message??String(d)}}};(e.type==="persisted"||e.type==="global")&&l.log("extensions_lifecycle_event_phase_captured",`[Extensions::Lifecycle] ${t}`,g),l.debug("extensions_lifecycle_event_phase_captured",`[Extensions::Lifecycle] ${t}`,g)}}const jn=Object.keys(hn({notifyError(){}}));function Fn(i){return new qn(i)}class qn extends Ne{constructor({context:e,extension:t,id:n,options:s,extensionInstanceCache:o}){super({context:e,extension:t,id:n,options:s,extensionInstanceCache:o});const{addDeactivatedExtension:r,defaultCacheDuration:a,sandboxCache:c,mountRateLimiter:l,announcementEmitter:u}=e;this.receiver=new de(t),this.addDeactivatedExtension=d=>{this.deactivated=!0,r(d)},this.deactivated=!1,this.defaultCacheDuration=a,this.mountRateLimiter=l,this.sandboxCache=c,this.announcementEmitter=u,this.isMounted=!1,this.destroyed=!1,this.renderCount=0,Gn(t.extensionPoint.target)&&typeof document<"u"&&(this.hostedIframe=ne
1w se({sandboxUrl:e.sandboxAppBridgeUrl,id:`checkout.shopify.com-${this.id}`,name:"checkout.shopify.com/app-bridge-checkout"}))}get mounted(){return this.isMounted}get rendered(){return this.renderCount>0}get isDestroyed(){return this.destroyed}async initialize(e){try{await this.mount(e)}catch(t){this.notifyError({error:t,isDeactivated:this.deactivated})}this.leaveBreadcrumbForMountedExtension()}render(){if(this.destroyed)throw new J(`Can't render extension ${this.extension.id} because it has already been destroyed`);if(this.destroyTimeout&&clearTimeout(this.destroyTimeout),this.renderCount+=1,this.extension.type!=="local"){const e=this.mountRateLimiter.checkRate(this.id);if(!e.allowed){const t=this.extension.registrationId!=null&&Je.has(this.extension.registrationId);this.createApiContext.observability.counter({name:"extension_mount_rate_exceeded",value:1,attributes:{reason:"rapid_mounting_detected",isHighValueExtension:t}}),this.createApiContext.observability.leaveErrorBreadcrumb("RenderExtensionInstance: Mount rate limit exceeded - possible infinite reload loop",{reason:e.reason,extensionId:this.extension.id,extensionType:this.extension.type,extensionPoint:this.extension.extensionPoint.target,appId:this.extension.appId,renderCount:this.renderCount}),this.createApiContext.observability.log("extension_mount_rate_exceeded","Extension mount rate limit exceeded - possible infinite reload loop",{...L(this.extension),renderCount:this.renderCount,retryAfterSeconds:e.retryAfterSeconds,reason:e.reason})}}return this.mount().catch(e=>{this.notifyError({error:e,isDeactivated:this.deactivated})}),this.emit("render"),({cache:e=this.defaultCacheDuration}={})=>{this.destroyWithCache({cache:e,reason:"render_timeout"})}}destroy(e){this.destroyed||(this.destroyTimeout&&(clearTimeout(this.destroyTimeout),this.destroyTimeout=void 0),this.hostedIframe?.destroy(),this.destroyed=!0,this.performCleanup(e),e.reason==="checkout_profile_change"&&this.captureExtensionLifecycleEvent("checkoutProfileChangeDestroy"))}installSandboxListeners(e){const t=e.on("error",s=>{if(this.destroyed)return;const o=s.name==="ExtensionSandboxError"?new Ae(String(s)):new H(String(s));this.notifyError({error:o})}),n=e.on("restart",()=>{this.isMounted=!1,this.receiver=new de(this.extension),this.mountPromise=this.renderAndMountExtension(this.api),this.emit("restart")});return[t,n]}destroyWithCache(e){this.renderCount>0&&(this.renderCount-=1);const t=e.cache??this.defaultCacheDuration,n=Date.now(),s=Math.max(this.cacheUntil??n,n+t);if(this.cacheUntil=s,this.emit("remove"),this.createApiContext.observability.debug("extensions_lifecycle_event_phase_captured","[Extensions::Lifecycle] Remove event emitted",{...L(this.extension),isDestroyed:this.destroyed,rendered:this.rendered,extensionInstanceId:this.id,extensionDestroyedReason:e.reason}),this.destroyTimeout||this.destroyed||this.renderCount>0)return;const o=Math.max(0,this.cacheUntil-n);o<=0?this.destroy(e):this.destroyTimeout=setTimeout(()=>{this.destroy(e)},o)}async mount(e){return this.destroyed?Promise.reject(new J(`Can't mount extension ${this.extension.id} because it has already been destroyed`)):this.mountPromise!=null?this.mountPromise:(this.initializeSandbox(),N.markStarted("api-object",{extension:this.extension,instanceId:this.id,type:"extension"}),this.api=Re(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options),N.markFinished("api-object",{extension:this.extension,instanceId:this.id,type:"extension"}),this.stepOnMount=e?.currentStep,this.mountPromise=this.renderAndMountExtension(this.api),this.mountPromise)}async renderAndMountExtension(e){const t=ve();this.deactivated=!1;const n=this.receiver,s=()=>this.receiver===n;let o=!1,r;const a=(async()=>{try{const u=this.extension.extensionPoint.target,d=Et(u),g=u===d?u:[u,d];if(this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart",void 0,t),!this.destroyed){let h;if(pt(this.extension.apiVersion))h=n.connection;else{const x=pn(n.connection);h=(...b)=>{o||this.destroyed||!s()||x(...b)}}const f=await this.sandbox?.render(g,h,jn,e,this.createApiContext.storefrontTokens,this.id,this.extension.id,this.announcementEmitter,{acceptSmsMarketing:this.createApiContext.proposal.parts.acceptSmsMarketing.peek(),smsMarketingPhone:this.createApiContext.proposal.parts.smsMarketingPhone.peek()},this.hostedIframe?.relayApi);f?.teardown&&this.addTeardown(f.teardown)}}catch(u){if(this.destroyed&&u?.message?.includes("terminated web worker"))r=u;else{this.addDeactivatedExtension(this.extension.id);let d;switch(u?.name){case"ExtensionUsageError":case"ExtensionAssetFetchError":case"ExtensionSandboxAssetFetchError":d=u;break;case"DataCloneError":d=new H("DataCloneError occurred: failed to render extension",{cause:u});break;default:d=new nn(String(u),{cause:u,groupingHash:`ExtensionRenderError::${u.name??"Unknown"}`})}throw d.name==="ExtensionUsageError"&&(this.extension.type==="persisted"||this.extension.type==="global")&&this.createApiContext.observability.log("render_extension_
1instance_usage_error_occurred","Extension usage error occurred: failed to render extension",{...L(this.extension),errorMessage:u.message}),d}}if(this.destroyed){const u=`${this.extension.extensionPoint.target}:${this.extension.placementReference}`,d=r?{cause:r}:void 0;throw this.extension.type==="local"?new sn(`Local extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d):this.sandbox?.isWorkerAvailable()?new on(`Extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d):new J(`Extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d)}if(!s())throw this.extension.type==="local"?new rn(`Local extension ${this.extension.id} was restarted before it finished mounting`):new an(`Extension ${this.extension.id} was restarted before it finished mounting`);o||(this.isMounted=!0),N.markFinished("execution",{instanceId:this.id,extension:this.extension,type:"extension"}),N.markStarted("wait-time-after-execution",{instanceId:this.id,extension:this.extension,type:"extension"})})(),c=this.getExtensionMountTimeout(this.extension),l=new Promise((u,d)=>setTimeout(()=>{if(c===0)return;if(this.destroyed||this.isMounted||!s()){u();return}o=!0,this.addDeactivatedExtension(this.extension.id);const g=new cn(`Extension ${this.extension.id} timed out while mounting`);d(g)},c));try{await Promise.race([a,l]),!this.destroyed&&s()&&this.captureExtensionLifecycleEvent("mountSuccess",void 0,t),this.emit("mount")}catch(u){throw this.captureExtensionLifecycleEvent("mountError",u,t),u}}captureExtensionLifecycleEvent(e,t,n){Le({createApiContext:this.createApiContext,extension:this.extension,phase:e,instanceId:this.id,mountId:n,mountStartTime:this.mountStartTime,page:this.stepOnMount||"",error:t})}leaveBreadcrumbForMountedExtension(){const{id:e,extensionId:t,extensionPoint:{target:n},placementReference:s,appId:o,apiVersion:r}=this.extension;this.createApiContext.observability.leaveErrorBreadcrumb("Extensions:mountExtension",{id:e,extensionId:t,extensionPoint:n,placementReference:s,appId:o,apiVersion:r,currentStep:this.stepOnMount??""})}getExtensionMountTimeout(e){return this.createApiContext.shop.extendedExtensionTimeout?0:e.capabilities?.blockProgress?3e4:0}}function Gn(i){return i==="purchase.checkout.chat.render"||i==="purchase.thank-you.chat.render"}function Vn(i){return new Hn(i)}class Hn extends Ne{constructor({context:e,extension:t,extensionInstanceCache:n,id:s,options:o}){super({context:e,id:s,extension:t,extensionInstanceCache:n,options:o}),this.rendered=!1,this.destroyed=!1,this.initialized=!1,this.hasAttemptedMount=!1,this.hasMounted=!1}get isDestroyed(){return this.destroyed}async initialize(){this.initialized||(this.initializeSandbox(),this.createStaticApi(),this.initialized=!0)}async run(e){const{target:t}=this.extension.extensionPoint;if(this.initialize(),this.destroyed)return;const n=!this.hasAttemptedMount;n&&(this.hasAttemptedMount=!0,this.mountId=ve(),this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart"));try{const{output:s,teardown:o}=await this.sandbox.run(t,{...this.createStaticApi(),...e},this.id,this.extension.id,void 0);return this.addTeardown(o),!this.hasMounted&&!this.destroyed&&(this.hasMounted=!0,this.captureExtensionLifecycleEvent("mountSuccess")),s}catch(s){if(this.destroyed&&s?.message?.includes("terminated web worker"))return;const o=s?.name==="ExtensionUsageError"||s?.name==="ExtensionAssetFetchError"?s:new dn(String(s));n&&!this.hasMounted&&!this.destroyed&&this.captureExtensionLifecycleEvent("mountError",o),this.notifyError({error:o})}}destroy(e){this.destroyed=!0,this.performCleanup(e)}installSandboxListeners(e){return[e.on("error",n=>{if(this.destroyed)return;const s=n.name==="ExtensionSandboxError"?new Ae(String(n),{cause:n}):new H(String(n),{cause:n});this.notifyError({error:s})})]}captureExtensionLifecycleEvent(e,t){try{Le({createApiContext:this.createApiContext,extension:this.extension,phase:e,instanceId:this.id,mountId:e==="mountStart"||e==="mountSuccess"||e==="mountError"?this.mountId:void 0,mountStartTime:this.mountStartTime,error:t})}catch(n){this.createApiContext.observability.leaveErrorBreadcrumb("RunnableExtensionInstance: failed to capture lifecycle event",{phase:e,extensionId:this.id,error:n instanceof Error?n.message:String(n)})}}createStaticApi(){return Re(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options)}}function zn(i){return new Wn(i)}
1class Wn{constructor(e){this.context=e,this.cache=new Map,this.#e=new Map,this.#t=V([]),this.context.checkout.extensibility.ui.unstable_registerExtensionsManager(this),this.blockingExtensions=this.#t}#e;#t;get(e,t){const n=this.createFullIdentifier({id:e.id,target:e.extensionPoint.target,options:t}),s=this.cache.get(n);if(s)return s;const o=this.context.interceptorRegistrationResolversSignal.peek(),r=jt(o,e.id),a=this.createExtensionInstance({context:this.context,extension:e,id:n,options:t,extensionInstanceCache:this.cache});return a.on("block",()=>{this.#e.set(a.id,e),this.#n()}),a.on("unblock",()=>{this.#e.delete(a.id),this.#n()}),a.on("destroy",()=>{this.#e.delete(a.id),this.#n();for(const c of this.cache.values())if(c.extension.id===e.id)return;Ft(o,e.id,r)}),this.cache.set(n,a),a}findAll(e){const t=this.createFullIdentifier(e),n=this.cache.get(t);return n?[n]:Array.from(this.cache.values()).filter(s=>s.id.startsWith(t))}#n(){const e=new Map;for(const t of this.#e.values())e.has(t.id)||e.set(t.id,t);this.#t.value=[...e.values()]}createExtensionInstance(e){const{extension:t}=e;return te(t.extensionPoint.target)in ne?Vn(e):Fn(e)}createFullIdentifier({id:e,target:t,options:n}){const s=`${e}:${t}`;if(n==null)return s;const o=Object.keys(n);if(o.length===0)return s;let r="";for(const a of o.sort((c,l)=>c.localeCompare(l)))r.length>0&&(r+="&"),r+=`${a}=${JSON.stringify(n[a])}`;return`${s}?${r}`}}function Kn(i,e){const t=[];for(const n of i)switch(te(n.extensionPoint.target)){case"Checkout::ThankYou::CartLineDetails::RenderAfter":case"Checkout::CartLineDetails::RenderLineComponents":case"Checkout::CartLineDetails::RenderAfter":{const s=e.merchandiseLines?.lines?.filter(o=>o.variantId)?.flatMap(o=>o.lineAllocations)?.reduce((o,r)=>r.stableId?[...o,{extension:n,options:{stableId:r.stableId}}]:o,[])??[];t.push(...s);break}case"Checkout::GiftCard::Render":case"Checkout::PickupPoints::RenderBefore":case"Checkout::PickupPoints::RenderAfter":case"Checkout::PickupLocations::RenderBefore":case"Checkout::PickupLocations::RenderAfter":case"Checkout::PaymentMethod::Render":case"Checkout::PaymentMethod::HostedFields::RenderAfter":case"Checkout::ShippingMethodDetails::RenderAfter":case"Checkout::ShippingMethodDetails::RenderExpanded":break;case"Checkout::ShippingMethods::RenderBefore":case"Checkout::ShippingMethods::RenderAfter":{["2023-04","2023-07","2023-10"].includes(n.apiVersion)&&t.push({extension:n});break}default:t.push({extension:n})}return t}const Qn=20,Jn=6e4,Xn="Too many checkout changes. See https://shopify.dev/docs/api/checkout-ui-extensions/latest#apply-changes-update-the-cart-and-checkout for details";function Yn(){return new Zn({maxRequests:Qn,windowMs:Jn,reason:Xn})}class Zn{#e=new Map;#t=new Set;constructor(e){this.maxRequests=e.maxRequests,this.windowMs=e.windowMs,this.reason=e.reason}isThrottled(e){return this.#t.has(e)}record(e,t){if(this.#t.has(e))return{isThrottled:!0,isFirstThrottled:!1};const n=Date.now();let s=this.#e.get(e);s||(s=[],this.#e.set(e,s));const o=n-this.windowMs,r=s.filter(a=>a.timestamp>o);return this.#e.set(e,r),r.length>=this.maxRequests?(this.#t.add(e),{isThrottled:!0,isFirstThrottled:!0}):(r.push({timestamp:n,eventId:t}),{isThrottled:!1,isFirstThrottled:!1})}eventIds(e){return this.#n(e).map(t=>t.eventId).filter(t=>t!=null)}count(e){return this.#n(e).length}#n(e){const t=this.#e.get(e)??[];if(this.#t.has(e))return t;const n=Date.now()-this.windowMs;return t.filter(s=>s.timestamp>n)}}class es{#e=new Map;#t;constructor(e){this.#t=e}checkRate(e){const t=Date.now();let n=this.#e.get(e);n||(n={tokens:this.#t.maxTokens,lastCheck:t},this.#e.set(e,n));const r=(t-n.lastCheck)/1e3*this.#t.refillRate;if(n.tokens=Math.min(this.#t.maxTokens,n.tokens+r),n.lastCheck=t,n.tokens<1){const c=(1-n.tokens)/this.#t.refillRate;return{allowed:!1,reason:this.#t.reason,retryAfterSeconds:Math.ceil(c)}}return n.tokens-=1,{allowed:!0,tokensRemaining:Math.floor(n.tokens)}}}function ts(){const i=Xe(),e=me(void 0),t=Z(n=>{if(n){const[s,o]=n;i.detour(s,o)}},[i]);return Ge(()=>{const n=e.value;return Ve(()=>t(n))}),e}const ns=60*1e3,ss=10*1e3;function Hs(i){return B(cs,{children:B(is,{...i})})}function is({children:i,renderManager:e}){const{checkout:{extensibility:t},i18n:n,observability:s,shop:o}=P(),r=Wt(),a=j();function c(w,S){const p=xn(S,w),I=mn(S,w);return[p,I]}const l=t.ui.sandboxCache,d=Ye().workspace,g=xe(()=>{const w=d?.extensions??[],S=Ze(a.value);return w.flatMap((p,I)=>{const C="development"in p?p.development.hidden:!1;return(p.extensionPoints.length?p.extensionPoints.map(v=>typeof v=="string"?{target:v,metafields:[]}:{...v,metafields:v.metafields??[]}):[{target:"Checkout::Dynamic::Render",metafields:p.metafields??[]}]).map((v,D)=>{let R,F=n.locale,q={},O={apiAccess:!1,networkAccess:!1,blockProgress:!1,collectBuyerConsent:{smsMarketing:!1,customerPrivacy:!1}},_=new Set,U="local";Tt(p)?(_=new Set(p.approvalScopes),p.capabilities.networkAccess&&_.add(gt.NetworkAccessScope),R=p.assets.main.url,[F,q]=c(n.locale,p.localization),O={...O,...p.capabilities,collectBuyerConsent:{...O.collectBuyerConsent,...p.capabilities.collectBuyerConsent}},U=p.name):R=p.scriptUrl;const $=`${I}${D}`,_e=p.uuid??`gid://shopify/LocalExtension/${$}`,Me=`gid://shopify/LocalActivatedExtension/${$}`,Pe=d&&"app"in d?d.app?.title:"local",De=d.app?.apiKey??d?.apiKey,Oe=yt(v.target);if("preloads"in v&&typeof v.preloads=="object")try{const z=new URL(R).origin;
1Object.entries(v.preloads).forEach(([W,Ue])=>{const ie=bt(W,Ue,z);ie?v.preloads[W]=ie:delete v.preloads?.[W]})}catch(z){s.error(z)}return{type:"local",id:Me,extensionId:_e,appId:d?.appId??"",appName:Pe,appApiKey:De??"",handle:p.handle,apiVersion:p.apiVersion??ft,extensionPoint:v,scriptUrl:R,extensionLocale:F,metafields:p.metafields,translations:q,placementReference:Oe?r??S:void 0,approvalScopes:_,name:U,capabilities:O,behaviors:V({showInExpressCheckout:!0,alwaysReveal:!0,blockProgress:!0}),extensionSkeletons:null,configuration:V({}),hidden:C,version:p.version??"",metafieldRequests:[]}})}).filter(p=>!p.hidden)},[d,r,n,a.value,s]),h=t.ui.search().value,f=qt([...h,...g]),x=t.ui.storefrontTokens,b=as(l,x,f),T=e??b,E=o?.storefrontUrl??"",y=o?.myshopifyDomain??"",m=Z((w,S)=>{const p=g.filter(I=>I.extensionId===w);if(p.length!==0){if(S!==void 0){const[I,C]=c(n.locale,S);p.forEach(A=>{A.extensionLocale=I,A.translations=C})}p.forEach(I=>{l?.getOrCreate({extension:I,storefrontUrl:E,myshopifyDomain:y}).restart()})}},[g,l,n,E,y]);return k(()=>{if(!(!d||!d.extensions.length))return et(d)?At(d,m):yn(d.extensions[0].socketUrl,()=>m(g[0].extensionId))},[g,d,m]),os(T,g,f),bn(l),wn({renderManager:T}),B(nt.Provider,{value:T,children:B(tt.Provider,{value:g,children:[B(An,{}),i]})})}function os(i,e,t){const{currentPage:n}=j().value,s=we(),o=ye(),r=ut(),{observability:a,source:c,checkout:{extensibility:l}}=P();lt(async()=>{const d=l.ui.search().peek(),g=s.current.peek(),h=t.peek(),f=ht(n,g,o.deactivatedExtensionIds,r,c.type),x=[...d,...e].filter(f);Ht(h,x);const b=await rs(x,g,i,n?.id??"");a.leaveErrorBreadcrumb("[Extensions] Finished blocking extensions check",{awaitableCount:b.length});const T=b.map(E=>h.get(E.id)?.promise||Promise.resolve());await Promise.race([new Promise((E,y)=>setTimeout(E,1e3)),Promise.all(T)])})}function rs(i,e,t,n){const s=Kn(i,e);return Promise.all(s.map(async({extension:o,options:r})=>(await t.get(o,r).initialize({currentStep:n}),o)))}function as(i,e,t){const n=vt(),{checkout:s,consentManager:o,i18n:r,shop:a,source:c,observability:l,url:u,graphql:{coreGraphql:d}}=P(),g=j().value,{completed:h,journeyState:f}=g,{pageBeforeDetour:x}=wt(it),b=fn(),T=vn(),E=we(),{addDeactivatedExtension:y}=ye(),m=ot(),w=ee(),S=rt(),{closeOverlay:p}=at(),I=s.configuration.layout.isOnePage.value,C=ts(),A=me(zt),v=Gt(),D=ct(),{appMetafieldsSignal:R,currentDiscountCodeAttemptSignal:F,bankIdNumberSignal:q,cartLineChangeLoadingSignal:O}=be(),_=M();if(ze(()=>{try{A.value=Vt(o)}catch(U){l.error(U)}},[l,A,o]),!_.current){const U=new es({maxTokens:10,refillRate:1,reason:"Rate limit exceeded. Extension is mounting/unmounting too rapidly."}),$=Yn();_.current=zn({addDeactivatedExtension:y,captureEvent:w,defaultCacheDuration:S?ss:ns,coreGraphql:d,currencySignal:T,locale:r.locale,negotiated:E.current,deliveryMethodsAddressErrors:E.context.deliveryMethodsAddressErrors,proposal:n,proposed:n.parts,sandboxCache:i,mountRateLimiter:U,negotiationRateLimiter:$,shop:a,timezone:r.timeZone,webPixels:m,sourceId:c.sourceId,sourceType:c.type,isCheckoutEditor:S,journeyCompletedSignal:h,checkout:s,journeyStateSignal:f,pageBeforeDetourSignal:x,storefrontTokens:e,ui:{overlay:{close:p}},publicCheckoutSessionId:dt(c),isOnePageCheckout:I,stableDetourSignal:C,customerPrivacySignal:A,bankIdNumberSignal:q,cartPageSignal:b,cartInstructionsSignal:v,interceptorRegistrationResolversSignal:t,observability:l,consentManager:o,currentDiscountCodeAttemptSignal:F,cartLineChangeLoadingSignal:O,applyChange:_n({captureEvent:w,journeyCompletedSignal:h,wallets:s.wallets,proposal:n,observability:l,extensionPerformance:N,negotiationRateLimiter:$}),announcementEmitter:D,appMetafieldsSignal:R,sandboxAppBridgeUrl:u.sandboxAppBridge()})}return _.current}function cs({children:i}){const[e,t]=He(new Set),{observability:n,checkout:{extensibility:s}}=P(),o=s.ui.search().value;k(()=>{n.addErrorMetadata("extensions",{active:o.map(({id:c})=>c)})},[n,o]);const r=Z(c=>{t(l=>{const u=new Set([...l,c]);return n.addErrorMetadata("extensions",{deactivated:Array.from(u)}),u})},[n]),a=xe(()=>({deactivatedExtensionIds:e,addDeactivatedExtension:r}),[e,r]);return B(st.Provider,{value:a,children:i})}export{Hs 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.