@tinkerlandai/longplay-sdk 0.10.34 → 0.10.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +83 -5
  3. package/README.zh-CN.md +26 -3
  4. package/dist/{ai-usage-T62xehqa.d.ts → ai-usage-DXwAGTxT.d.ts} +1 -1
  5. package/dist/{api-Do-6AyWa.d.ts → api-r6FfVQpg.d.ts} +6 -1
  6. package/dist/check-response-DHY6T5Z2.js +1 -0
  7. package/dist/{chunk-7MNJH5GB.js → chunk-2HSD2SEU.js} +1 -1
  8. package/dist/chunk-2KKLY323.js +1 -0
  9. package/dist/{chunk-BXPXJARS.js → chunk-35VG2IYD.js} +1 -1
  10. package/dist/chunk-3NCMYTNG.js +1 -0
  11. package/dist/{chunk-HQITRRHF.js → chunk-5XIKN35D.js} +1 -1
  12. package/dist/chunk-5XKFUFXK.js +1 -0
  13. package/dist/chunk-7ZEXY4GC.js +1 -0
  14. package/dist/chunk-BL7E4RZ2.js +1 -0
  15. package/dist/{chunk-FYQXSGRT.js → chunk-BTPEXSNY.js} +1 -1
  16. package/dist/chunk-C4GBV32U.js +10 -0
  17. package/dist/chunk-CGXNU5BC.js +1 -0
  18. package/dist/chunk-DB4EO3JG.js +1 -0
  19. package/dist/chunk-DHT3AWJQ.js +1 -0
  20. package/dist/chunk-GLYFT5WW.js +1 -0
  21. package/dist/chunk-HS56A4IK.js +1 -0
  22. package/dist/chunk-HVVJGLYZ.js +1 -0
  23. package/dist/chunk-HYE2YQYM.js +1 -0
  24. package/dist/chunk-I6D25FWU.js +1 -0
  25. package/dist/{chunk-TYY3MUTF.js → chunk-IOBB6KFK.js} +1 -1
  26. package/dist/chunk-JOIPLLHK.js +1 -0
  27. package/dist/{chunk-MIBRUDIS.js → chunk-LAGGWYH3.js} +1 -1
  28. package/dist/{chunk-6T575JKD.js → chunk-LVG5ED52.js} +1 -1
  29. package/dist/{chunk-I6TSQQ5N.js → chunk-M3GGR53D.js} +1 -1
  30. package/dist/chunk-MHWPEMX7.js +1 -0
  31. package/dist/chunk-MYBUQFTC.js +1 -0
  32. package/dist/{chunk-7QL4GF4C.js → chunk-O4KXODTJ.js} +1 -1
  33. package/dist/chunk-OL2AI6DA.js +1 -0
  34. package/dist/chunk-QHJWVLJC.js +1 -0
  35. package/dist/chunk-R3YVDRTB.js +1 -0
  36. package/dist/chunk-RHF4NFCZ.js +1 -0
  37. package/dist/{chunk-5HJYR6Z4.js → chunk-RHWZRHK7.js} +1 -1
  38. package/dist/{chunk-X4W22IH6.js → chunk-TIQS5DUF.js} +1 -1
  39. package/dist/chunk-U4WUX3WB.js +1 -0
  40. package/dist/chunk-UHTTCVSL.js +1 -0
  41. package/dist/{chunk-UWLEGMWX.js → chunk-UVUFJO2V.js} +1 -1
  42. package/dist/{chunk-7NELM6EH.js → chunk-VKG6BB3Z.js} +1 -1
  43. package/dist/chunk-VWMFR22O.js +1 -0
  44. package/dist/chunk-W32FI2A2.js +1 -0
  45. package/dist/chunk-W3K5ARMY.js +1 -0
  46. package/dist/chunk-WRLVPHPE.js +1 -0
  47. package/dist/chunk-XE7GU6FZ.js +1 -0
  48. package/dist/{chunk-EQPEUPMG.js → chunk-XQTCEQXI.js} +1 -1
  49. package/dist/chunk-YQX27SBG.js +1 -0
  50. package/dist/{chunk-VYFSRHXM.js → chunk-ZYF6TRJ3.js} +1 -1
  51. package/dist/{configuration-sync-DdTRUv7A.d.ts → configuration-sync-BHrAf-ql.d.ts} +10 -1
  52. package/dist/content-RGKTEV23.js +1 -0
  53. package/dist/funnel-host-purchase-M7MM33EC.js +1 -0
  54. package/dist/{funnel-local-client-BeGBvi3z.d.ts → funnel-local-client-DR8OpKGU.d.ts} +167 -25
  55. package/dist/funnel-paywall-prerender-OSBI4VMY.js +1 -0
  56. package/dist/{funnel-process-client-C6QKDZun.d.ts → funnel-process-client-C87U4r_G.d.ts} +17 -3
  57. package/dist/funnel-runtime-host-AMJXEASH.js +1 -0
  58. package/dist/index.d.ts +214 -63
  59. package/dist/index.js +1 -1
  60. package/dist/merchant-bridge-contracts-GJQVKEAG.js +1 -0
  61. package/dist/native-shell.js +1 -1
  62. package/dist/openrouter.d.ts +3 -3
  63. package/dist/openrouter.js +1 -1
  64. package/dist/operation-contracts-MFK2KORK.js +1 -0
  65. package/dist/page.d.ts +2 -2
  66. package/dist/page.js +1 -1
  67. package/dist/paywall-ATZ2IZPS.js +1 -0
  68. package/dist/paywall-content-XERXGNND.js +1 -0
  69. package/dist/paywall-session-EMMF6IYS.js +1 -0
  70. package/dist/popup.d.ts +21 -3
  71. package/dist/popup.js +1 -1
  72. package/dist/{presentation-loading-CFSiS0VX.d.ts → presentation-loading-B_v5XZtM.d.ts} +11 -1
  73. package/dist/react-native.d.ts +7 -7
  74. package/dist/react-native.js +1 -1
  75. package/dist/{screen-CGCJ46b1.d.ts → screen-qUBRsUi9.d.ts} +26 -21
  76. package/dist/screen-renderer-B7LUTPTJ.js +1 -0
  77. package/dist/server.d.ts +37 -7
  78. package/dist/server.js +2 -2
  79. package/dist/{visual-dom-6DCUZGPB.js → visual-dom-5LUN4AHO.js} +1 -1
  80. package/dist/visual.js +1 -1
  81. package/package.json +1 -1
  82. package/dist/chunk-3JJYWRA3.js +0 -1
  83. package/dist/chunk-4WZVC4TM.js +0 -1
  84. package/dist/chunk-5JWMP4YD.js +0 -1
  85. package/dist/chunk-7VRZYSTR.js +0 -1
  86. package/dist/chunk-EHDHWYVJ.js +0 -1
  87. package/dist/chunk-ERJP2GBD.js +0 -1
  88. package/dist/chunk-ILEDKSRQ.js +0 -1
  89. package/dist/chunk-ITGERPCJ.js +0 -1
  90. package/dist/chunk-N7YXDSQL.js +0 -1
  91. package/dist/chunk-NAZU3EEJ.js +0 -1
  92. package/dist/chunk-QBA3B4YK.js +0 -1
  93. package/dist/chunk-R23IGK5U.js +0 -1
  94. package/dist/chunk-R4FDIYMN.js +0 -1
  95. package/dist/chunk-RKPAIF6U.js +0 -1
  96. package/dist/chunk-SCC3O2RD.js +0 -1
  97. package/dist/chunk-TDSATEGE.js +0 -10
  98. package/dist/chunk-THMGTRXP.js +0 -1
  99. package/dist/chunk-U6UHASIB.js +0 -1
  100. package/dist/chunk-WKIR2EQG.js +0 -1
  101. package/dist/chunk-WTVLNUMS.js +0 -1
  102. package/dist/chunk-ZGCKQWQ5.js +0 -1
  103. package/dist/content-ORU4ODJQ.js +0 -1
  104. package/dist/funnel-host-purchase-BEFE3N3E.js +0 -1
  105. package/dist/funnel-runtime-host-V6TYIDX3.js +0 -1
  106. package/dist/merchant-bridge-contracts-ZUQ6SGXZ.js +0 -1
  107. package/dist/operation-contracts-443N2P3A.js +0 -1
  108. package/dist/paywall-HO4PS472.js +0 -1
  109. package/dist/paywall-session-MZXFOPTR.js +0 -1
  110. package/dist/screen-renderer-W7ZGBFIR.js +0 -1
  111. /package/dist/{chunk-BID4UGWB.js → chunk-CILM5XMH.js} +0 -0
  112. /package/dist/{chunk-UKMEW5I7.js → chunk-OJM6ORHE.js} +0 -0
  113. /package/dist/{chunk-VF6QMMEA.js → chunk-ZYN4CRHS.js} +0 -0
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as cn,c as dn}from"./chunk-3JJYWRA3.js";import{a as Ue,b as fn,c as Ie}from"./chunk-RKPAIF6U.js";import{g as pe}from"./chunk-4WZVC4TM.js";import"./chunk-U6UHASIB.js";import{a as en,c as sn,d as un}from"./chunk-7NELM6EH.js";import"./chunk-I6TSQQ5N.js";import{a as an}from"./chunk-5JWMP4YD.js";import"./chunk-UWLEGMWX.js";import{h as Qe,i as on,k as ln}from"./chunk-7VRZYSTR.js";import"./chunk-FYQXSGRT.js";import"./chunk-7MNJH5GB.js";import{F as Re,e as Ve,g as je,h as fe,i as me,j as Ge,x as nn}from"./chunk-QBA3B4YK.js";import{a as qe}from"./chunk-ITGERPCJ.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import{B as Fe,D as Oe,E as xe,G as De,H as Te,I as ke,J as Be,K as Ee,L as He,x as ve,y as Me,z as Ne}from"./chunk-SCC3O2RD.js";import{$ as Le,l as Ye,m as Ze,n as We}from"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import{c as tn,d as rn}from"./chunk-EHDHWYVJ.js";import"./chunk-BXPXJARS.js";import{b as be}from"./chunk-WTVLNUMS.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import{a as H}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import{a as ge,c as ce}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as ye,d as he}from"./chunk-6T575JKD.js";import"./chunk-3VUPVXAV.js";import"./chunk-WKIR2EQG.js";import{b as K}from"./chunk-VF6QMMEA.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";var y=class extends Error{constructor(m,k=0,_=!1,E="fix_request"){super(m);this.code=m;this.status=k;this.retryable=_;this.recovery=E;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function mn(n,A){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let m=n.body?.getReader();if(!m)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let k=()=>{m.cancel().catch(()=>{})};A.addEventListener("abort",k,{once:!0});let _=0,E="",r=new TextDecoder("utf-8",{fatal:!0});try{for(A.throwIfAborted();;){let i=await m.read();if(A.throwIfAborted(),i.done)break;if(_+=i.value.byteLength,_>262144)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");E+=r.decode(i.value,{stream:!0})}return E+=r.decode(),JSON.parse(E)}catch(i){throw A.throwIfAborted(),i instanceof y?i:new y("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{A.removeEventListener("abort",k),await m.cancel().catch(()=>{}),m.releaseLock()}}function pn(n){let A=Oe.parse(n.origin),m=xe.parse(n.manifest),k={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let c of["projectId","environmentId","environment"])if(m[c]!==n.scope[c])throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");let _=n.customerId===void 0?null:K.uuid().parse(n.customerId),E=0,r=null,i=null,g=new AbortController,I=n.fetch??globalThis.fetch;async function U(c,s,p,w,h){if(!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=Fe[c];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(d.authority))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);let l=E,o=AbortSignal.any([g.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...w?[w]:[]]);o.throwIfAborted();let N=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==E)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(N.get("authorization")??"")||N.has("X-Indiana-Bridge-Signature")||N.has("X-Indiana-Bridge-Key-Id"))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);N.set(Ne,String(ve)),N.set("Accept","application/json");let P=crypto.randomUUID();N.set("X-Request-Id",P),N.set("Content-Type","application/json");let b=await I(A+Me,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:N,signal:o,body:JSON.stringify({bridgeVersion:ve,requestId:P,command:d.command,scope:k,data:h??(p===void 0?{}:{operationId:p})})}),V=await mn(b,o);if(o.throwIfAborted(),l!==E)throw new DOMException("Merchant identity changed","AbortError");if(!b.ok){let D=He.safeParse(V);throw!D.success||D.data.scope.projectId!==n.scope.projectId||D.data.scope.environment!==n.scope.environment||D.data.scope.environmentId!==n.scope.environmentId||D.data.requestId!==P||D.data.command!==d.command?new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status):new y(D.data.error.code,b.status,D.data.error.retryable,D.data.error.recovery)}let u=De(K.unknown()).safeParse(V);if(!u.success||u.data.scope.projectId!==n.scope.projectId||u.data.scope.environment!==n.scope.environment||u.data.scope.environmentId!==n.scope.environmentId||u.data.requestId!==P||u.data.command!==d.command)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status);let j=s.safeParse(u.data.data);if(!j.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status);return j.data}function M(){if(!_)throw new y("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return _}async function z(c,s,p,w){let h=M();if(w!==void 0&&Ee.parse({operationId:w,customerId:h}),!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=E,l=AbortSignal.any([g.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,N=new Promise((P,b)=>{o=()=>b(l.reason),l.addEventListener("abort",o,{once:!0})});try{let b=p(async()=>{let u=await import("./merchant-bridge-contracts-ZUQ6SGXZ.js");if(l.throwIfAborted(),d!==E||_!==h)throw new DOMException("Merchant identity changed","AbortError");return u},l),V=await Promise.race([b,N]);return l.throwIfAborted(),V}finally{l.removeEventListener("abort",o)}}async function J(c,s,p,w){let h=M(),d=Ee.parse({operationId:p,customerId:h}),l=await U(c,s,d.operationId,w,d);if(l.customerId!==h||l.operationId!==d.operationId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(c){let s=await U("presentation",ke,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&_!==null&&s.presentation.customerId!==_)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,r=s.presentation,s},async createSession(c){let s=await U("session",Te,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(_!==null&&_!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(r&&r.customerId!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return _=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(c,s){let p=M(),w=Be.parse(c);if(!r||r.customerId!==p||r.decisionId!==w.decisionId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return U("presentation_events",K.strictObject({queued:K.literal(!0)}),void 0,s,w)},async readCustomerCommerce(c){let s=M(),p=await z("customer_commerce",c,async(w,h)=>{let[d,l]=await Promise.all([w(),U("customer_commerce",K.unknown(),void 0,h)]),o=d.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(p.customerId!==s)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return p},async executePurchase(c,s){let p=await z("purchases",s,async(w,h)=>J("purchases",(await w()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="purchase")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},readOperation:(c,s)=>z("operation_status",s,async(p,w)=>J("operation_status",(await p()).merchantOperationLookupSchema,c,w),c),async executeSubscriptionChange(c,s){let p=await z("subscription_changes",s,async(w,h)=>J("subscription_changes",(await w()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="subscription_change")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},reset(){E++,g.abort(),g=new AbortController,_=null,r=null,i=null}}}var $e=K.strictObject({command:me,target:je,runId:K.uuid().optional(),expiresAt:K.iso.datetime({offset:!0}).optional()}).refine(n=>n.command.release===n.target.release),Ke=K.strictObject({schemaVersion:K.literal(1),entries:K.array($e).max(4e3)});function ze(n){let A=!1,m=()=>{A||n.unavailable(),A=!0};function k(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function _(r){let i=k()?.getItem(r);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ke.parse(JSON.parse(i)).entries}function E(r,i){let g=k();if(!g)return;if(!i.length)return g.removeItem(r);let I=JSON.stringify(Ke.parse({schemaVersion:1,entries:i}));if(I.length>1048576)throw Error("Entry recovery is too large");g.setItem(r,I)}return{load(){try{let r=n.binding();if(!r||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(r);return{key:i,entries:_(i)}}catch{m();return}},retain(r,i){if(r)try{let g=$e.parse(i);E(r,[..._(r).filter(I=>I.command.funnelId!==g.command.funnelId),g])}catch{m()}},forget(r,i){if(r)try{E(r,_(r).filter(g=>g.command.requestId!==i))}catch{m()}}}}var we=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function yn(n){let A=ye(n.baseUrl),m=n.scope,k=be(n),_=n.fetch??globalThis.fetch.bind(globalThis),E,r=!1,i=!1,g=0,I=0,U="",M=0,z=0,J=0,c=!1,s,p=!0,w,h,d,l,o,N=-1,P,b=e=>{P===e&&(P=void 0,q())},V=new Set,u=(e,a)=>Z(n.onStatus,e,a),j=new Set,D=ze({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[A,m.projectId,m.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>u("recovery_unavailable")}),X=e=>D.forget(e.storageKey,e.command.requestId);function re(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),D.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt}})}function ee(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),q()}let de=()=>P!==void 0||o!==void 0&&!o.background;function t(e,a){if(o?.client!==e)return;re(o.recovery,a);let f=we(a);o.slot.hidden=f,f!==o.background&&(o.background=f,f?u("run_background",o.entryId):N=I,q())}function R(e,a,f){let S=e.client.view;if(!a||e.background||!S?.screen||S.paywall||S.pendingRequest||S.stopped||S.status!=="waiting")return;let O=Le.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:S.nodeId,visit:S.visit,revision:S.revision,customerToken:a}),$=be({...n,session:void 0});$.requestWithCredential("funnels",O,e.runToken,{keepalive:f}).then(()=>X(e.recovery)).catch(()=>{}).finally(()=>$.dispose())}let F=()=>{o&&R(o,n.session.peek(),!0)},L=()=>Date.now()<z&&performance.now()<J;function G(e){if(e.target.release!==n.appManifestRelease||!L())return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return u("incompatible",e.id),!1}}function ne(e){if(r||e.epoch!==M||e.visit!==I||document.visibilityState==="hidden")return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return!1}}async function oe(e){if(de()){u("in_progress",e.id);return}if(!n.session.peek()){u("identity_required",e.id);return}let a=D.load(),f=a?.entries.find(O=>O.command.funnelId===e.funnelId&&(!O.expiresAt||Date.parse(O.expiresAt)>Date.now()));if(f){if(!ae(f)){u("recovery_pending",e.id);return}let O={...f,storageKey:a.key,epoch:M,visit:I};j.add(O.command.requestId),P=O,await te(O);return}let S={freshStart:!0,command:me.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:crypto.randomUUID(),locale:document.documentElement.lang||"en"}),epoch:M,visit:I,target:e.target,storageKey:a?.key};j.add(S.command.requestId),P=S,await te(S)}async function te(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let f,S=!1,O=!1;async function $(T){if(e.epoch!==M)return;let v=T.view;if(!(e.storageKey&&v&&(we(v)||v.paywall||v.pendingRequest))&&v&&["running","waiting"].includes(v.status))try{await T.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision}),X(e)}catch(x){if(!(x instanceof H&&x.code==="FORBIDDEN"))throw x}}try{re(e),u("starting",e.command.entryId);let T=await k.request("funnels",e.command),v=Ge.safeParse(T);if(v.success){if(v.data.scope.projectId!==m.projectId||v.data.scope.environment!==m.environment)throw new H("SCOPE_MISMATCH","Entry scope changed");e.epoch===M&&u(v.data.reason,e.command.entryId),X(e),b(e);return}let x=Ve.parse(T);if(!x.runToken||x.scope.projectId!==m.projectId||x.scope.environment!==m.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new H("INVALID_RESPONSE","Invalid entry Run");if(e.epoch!==M){b(e),u("identity_changed",e.command.entryId);return}re(e,x.run);let C=Re({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?T:void 0});f=C,O=!0,await C.get(),O=!1;let Y=C.view;if(!Y||Y.id!==x.run.id||Y.source.type!=="funnel"||Y.source.id!==e.command.funnelId||Y.source.versionId!==e.command.versionId)throw new H("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(Y.status)){X(e),b(e),u("run_ended",e.command.entryId);return}if(!ne(e)){await $(C),u("left_screen",e.command.entryId),b(e);return}let se=!1,Ae=!1;if(o&&!o.background){await $(C),u("in_progress",e.command.entryId),b(e);return}o&&ee();let Q=document.createElement("div");Q.hidden=we(Y),n.container.append(Q);let Ce=await Ie(Q,{...n.host,client:C,appManifestRelease:n.appManifestRelease,onState(B){t(C,B),Z(n.host?.onState,B)},onDismiss(B){se=!0,Q.remove(),B&&!["running","waiting"].includes(B.status)&&X(e),o?.client===C&&(o=void 0,C.reset(),q(),B&&B.status!=="completed"&&u("run_ended",e.command.entryId)),Z(n.host?.onDismiss,B)},onComplete(B){Ae=!0,X(e),o?.client===C&&ee(),Z(n.host?.onComplete,B)},onError(B){Z(n.host?.onError,B),o?.client===C&&B instanceof H&&B.code==="FORBIDDEN"&&(X(e),ee(),u("run_ended",e.command.entryId))}}).catch(B=>{throw Q.remove(),B});if(!ne(e)||se||Ae){Ce.destroy(),Q.remove(),ne(e)||await $(C),b(e);return}let le=we(C.view??Y);Q.hidden=le,o={host:Ce,client:C,slot:Q,entryId:e.command.entryId,background:le,runToken:x.runToken,owner:n.session.peek(),recovery:e},le||(N=e.visit),S=!0,b(e),u("started",e.command.entryId),le&&u("run_background",e.command.entryId)}catch(T){T instanceof H&&(!f||O&&T.code==="FORBIDDEN")&&T.status!==void 0&&T.status>=400&&T.status<500&&!T.retryable&&(X(e),b(e)),e.epoch===M&&!r&&(u("start_failed",e.command.entryId),Z(n.host?.onError,T))}finally{S||f?.reset(),e.dispatching=!1}}function ae(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(){if(de())return!1;let e=D.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){D.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||j.has(a.command.requestId)||!ae(a))continue;j.add(a.command.requestId);let f={...a,storageKey:e.key,epoch:M,visit:I};return P=f,te(f),!0}return!1}function ue(){if(c=!1,r||!i||document.visibilityState==="hidden")return;ie();let e=o!==void 0&&!o.background;if(e&&(N=I),!W()){if(!L()){p=!0;return}p=!1;for(let a of E?.entries??[]){let f=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||V.has(f)||!G(a))){if(!n.session.peek()){u("identity_required",a.id);continue}if(N===I){V.add(f),e&&u("in_progress",a.id);continue}if(P){u("in_progress",a.id);return}V.add(f),oe(a);break}}}}let q=()=>{!c&&!r&&(c=!0,queueMicrotask(ue))};function ie(){let e=location.origin+location.pathname;return e===U?!1:(U=e,I++,p=!0,V.clear(),j.clear(),!0)}function Je(){ie()&&q()}function Se(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let f=a.closest("button,a,input");if(!(!f||f.matches(":disabled,[aria-disabled='true']")||f.closest("[hidden],[inert],[aria-hidden='true']")))for(let S of E?.entries??[]){let O=S.target.button;if(!(S.event!=="button_click"||!O||!G(S))){try{let $=ge(document);if(!f.matches(O.selector)||$(O.selector,f)!==1)continue}catch{u("incompatible",S.id);continue}oe(S);break}}}async function _e(){if(r)return;if(s)return s;let e=++g,a=new AbortController;w=a;let f,S=new Promise((T,v)=>{f=()=>v(new H("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",f,{once:!0})}),O=setTimeout(()=>a.abort(),n.timeoutMs??5e3),$=(async()=>{let T=async()=>{let se=await _(`${A}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!se.ok)throw new H("SERVICE_UNAVAILABLE","Funnel entries unavailable",se.status);return fe.parse(await se.json())},v=await Promise.race([T(),S]),x=Date.parse(v.validatedAt),C=Date.parse(v.validUntil);if(v.scope.projectId!==m.projectId||v.scope.environment!==m.environment||v.scope.environmentId!==n.environmentId||v.release!==n.appManifestRelease||C<=Date.now()||x>Date.now()+5e3||C-x>6e4||C<=x)throw new H("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(r||e!==g)return;let Y=E===void 0;E=v,z=C,J=performance.now()+Math.min(C-Date.now(),6e4),(Y||p)&&q()})();s=$;try{await $}finally{clearTimeout(O),a.signal.removeEventListener("abort",f),s===$&&(s=void 0)}}async function Xe(){if(!(!i||r)){try{await _e()}catch{r||u("configuration_unavailable")}q()}}let Pe=pe({document,run:Xe,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,U=location.origin+location.pathname,h=he(Je),d=n.session.subscribeIdentity(()=>{M++,p=!0,P=void 0,V.clear(),N=-1,j.clear(),o&&R(o,o.owner,!1),ee(),q()}),l=new MutationObserver(q),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",Se,!0),addEventListener("pagehide",F),await Pe.refresh())},refresh:_e,async retry(){P&&!r&&P.epoch===M&&await te(P)},destroy(){r=!0,g++,Pe.destroy(),w?.abort(),l?.disconnect(),h?.(),d?.(),document.removeEventListener("click",Se,!0),removeEventListener("pagehide",F),F(),ee(),k.dispose(),E=void 0}}}function hn(n){let A=ye(n.baseUrl),m=n.fetch??globalThis.fetch.bind(globalThis),k,_=0,E=0,r=!1,i=!1,g=0,I=0,U=-1,M=!1,z="",J,c,s,p,w=new Set,h,d,l,o=(t,R)=>Z(n.onStatus,t,R),N=()=>Date.now()<_&&performance.now()<E;function P(t){try{return N()&&t.target.release===n.appManifestRelease&&ce(t.target.render,document,location.pathname,()=>{})}catch{return o("incompatible",t.id),!1}}function b(){let t=l;l=void 0,t?.host.destroy(),t?.slot.remove()}async function V(t){if(t.dispatching)return;t.dispatching=!0;let R=g;try{let F=await t.process.open({operation:"entry_start",funnelId:t.entry.funnelId,versionId:t.entry.versionId,entryId:t.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});if(r||R!==g||d!==t)return;let L=document.createElement("div");n.container.append(L),U=I;let G=await Ie(L,{...n.host,client:F.controller,appManifestRelease:n.appManifestRelease,onDismiss(ne){l?.process===t.process&&(l=void 0,L.remove()),Z(n.host?.onDismiss,ne)}});if(r||R!==g||d!==t){G.destroy(),L.remove();return}l={entry:t.entry,process:t.process,host:G,slot:L},d=void 0,o("run_presented",t.entry.id)}catch(F){if(r||R!==g||d!==t)return;F instanceof H&&"result"in F?(d=void 0,t.process.destroy(),o("suppressed",t.entry.id),j()):o("entry_unavailable",t.entry.id)}finally{t.dispatching=!1}}function u(t){if(r||d||l||h||U===I||!P(t))return;let R=`${I}:${t.id}`;if(w.has(R))return;w.add(R);let F={entry:t,process:n.createProcess(t),visit:I};d=F,V(F)}function j(){M||r||(M=!0,queueMicrotask(()=>{if(M=!1,!(r||document.visibilityState==="hidden"||!N()||d||l||h||U===I)){for(let t of k?.entries??[])if(t.event==="screen_enter"&&P(t)){u(t);break}}}))}function D(t){if(!t.isTrusted||t.defaultPrevented||!(t.target instanceof Element)||d||l||h||U===I)return;let R=ge(document,()=>{});for(let F of k?.entries??[]){let L=F.target.button;if(F.event!=="button_click"||!L||!P(F))continue;let G=t.target.closest(L.selector);if(!(!G||G.tagName.toLowerCase()!==L.tag||R(L.selector)!==1||G.matches(":disabled")||G.closest('[inert],[hidden],[aria-hidden="true"]'))){u(F);break}}}let X=()=>{let t=location.origin+location.pathname;t!==z&&(z=t,I++,w.clear(),j())};async function re(){if(r)return;if(c)return c;let t=g,R=new AbortController;J=R;let F,L=new Promise((te,ae)=>{F=ae}),G=()=>F(new H("TIMEOUT","Funnel entry read cancelled"));R.signal.addEventListener("abort",G,{once:!0});let ne=setTimeout(()=>R.abort(),n.timeoutMs??5e3),oe=(async()=>{let te=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ae=async()=>{let ie=await m(`${A}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${te}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:R.signal});if(!ie.ok)throw new H("SERVICE_UNAVAILABLE","Funnel entries unavailable",ie.status);return fe.parse(await ie.json())},W=await Promise.race([ae(),L]),ue=Date.parse(W.validatedAt),q=Date.parse(W.validUntil);if(W.scope.projectId!==n.scope.projectId||W.scope.environment!==n.scope.environment||W.scope.environmentId!==n.environmentId||W.release!==n.appManifestRelease||q<=Date.now()||ue>Date.now()+5e3||q<=ue||q-ue>6e4)throw new H("INVALID_RESPONSE","Entry scope or deadline changed");r||t!==g||(k=W,_=q,E=performance.now()+Math.min(q-Date.now(),6e4),j())})();c=oe;try{await oe}finally{clearTimeout(ne),R.signal.removeEventListener("abort",G),c===oe&&(c=void 0)}}async function ee(){if(!(!i||r))try{await re()}catch{r||o("configuration_unavailable")}}let de=pe({document,run:ee,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,z=location.origin+location.pathname,s=he(X),p=new MutationObserver(j),p.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",D,!0),await de.refresh())},refresh:re,async retry(){d&&!r&&await V(d)},async syncIdentity(){let t=l??d??h;if(t)try{let R=await t.process.syncIdentity();return h===t&&(d={entry:t.entry,process:t.process,visit:I},h=void 0,await V(d)),R}catch(R){throw t.process.view||(h={entry:t.entry,process:t.process,visit:I},d=void 0,b()),R}},async detach(){g++,J?.abort();let t=l??d??h;t&&(h={entry:t.entry,process:t.process,visit:I}),d=void 0,b(),t&&await t.process.detach()},destroy(){r=!0,g++,de.destroy(),J?.abort(),p?.disconnect(),s?.(),document.removeEventListener("click",D,!0);let t=l??d??h;d=void 0,h=void 0,b(),t?.process.destroy(),k=void 0}}}async function zn(n,A){return(await import("./paywall-HO4PS472.js")).showPaywall(n,A)}async function Jn(...n){return n[1]=qe(n[1]),(await import("./paywall-session-MZXFOPTR.js")).createPaywallSession(...n)}async function Xn(...n){let A=n[1].signal?.aborted?void 0:Ue(n[1].client);try{let[m]=await Promise.all([import("./funnel-runtime-host-V6TYIDX3.js"),import("./screen-renderer-W7ZGBFIR.js"),import("./paywall-HO4PS472.js")]);return await m.showFunnelRun(...n)}finally{A?.()}}async function Yn(...n){return(await import("./funnel-host-purchase-BEFE3N3E.js")).showFunnelPurchase(...n)}async function Zn(...n){return(await import("./content-ORU4ODJQ.js")).mountContent(...n)}async function Wn(...n){return(await import("./content-ORU4ODJQ.js")).prepareContent(...n)}export{H as LongplayError,y as MerchantBridgeError,nn as createBrowserFunnelCommandStorage,cn as createBrowserFunnelPurchaseStorage,on as createConfigurationSync,Qe as createFeatureClient,sn as createFunnelClient,fn as createFunnelPageExperiments,un as createFunnelProcess,dn as createFunnelPurchaseClient,Re as createFunnelRunController,yn as createIamFunnelEntries,hn as createIamFunnelProcessEntries,ln as createLocalFunnelClient,en as createLongplay,pn as createMerchantBridge,Jn as createPaywallSession,an as evaluateFunnelNode,Ze as formatCouponDiscount,Ye as formatCouponMoney,We as formatCouponTerms,tn as getPaywallRecovery,Zn as mountContent,Wn as prepareContent,rn as preparePaywallFallback,Yn as showFunnelPurchase,Xn as showFunnelRun,zn as showPaywall};
1
+ import{a as gn,c as vn}from"./chunk-BL7E4RZ2.js";import{a as We,c as En}from"./chunk-VWMFR22O.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as ln,c as hn,d as In}from"./chunk-VKG6BB3Z.js";import"./chunk-M3GGR53D.js";import{a as yn}from"./chunk-W3K5ARMY.js";import"./chunk-UVUFJO2V.js";import{h as dn,i as pn,k as wn}from"./chunk-HS56A4IK.js";import{F as Ce,e as Xe,g as Ye,h as ge,i as ve,j as Ze,x as un}from"./chunk-HYE2YQYM.js";import{a as ze}from"./chunk-MHWPEMX7.js";import"./chunk-2HSD2SEU.js";import"./chunk-5XKFUFXK.js";import"./chunk-BTPEXSNY.js";import{B as He,D as qe,E as Ue,G as Ve,H as je,I as Ge,J as Je,K as Te,L as $e,x as _e,y as Le,z as Be}from"./chunk-2KKLY323.js";import"./chunk-R3YVDRTB.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import{aa as Ke,l as an,m as sn,n as cn}from"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import{c as fn,e as mn}from"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import{b as Ae}from"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as G}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import{c as we,d as Ee}from"./chunk-LVG5ED52.js";import"./chunk-3VUPVXAV.js";import"./chunk-RHF4NFCZ.js";import{b as U}from"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as Q}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function bn(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Sn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function R(m,s,E,_,M){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let N=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:M??(E===void 0?{}:{operationId:E})})}),J=await bn(N,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!N.ok){let O=$e.safeParse(J);throw!O.success||O.data.scope.projectId!==n.scope.projectId||O.data.scope.environment!==n.scope.environment||O.data.scope.environmentId!==n.scope.environmentId||O.data.requestId!==g||O.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status):new I(O.data.error.code,N.status,O.data.error.retryable,O.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status);return $.data}function P(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let M=P();if(_!==void 0&&Te.parse({operationId:_,customerId:M}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,N)=>{o=()=>N(l.reason),l.addEventListener("abort",o,{once:!0})});try{let N=E(async()=>{let c=await import("./merchant-bridge-contracts-GJQVKEAG.js");if(l.throwIfAborted(),S!==h||w!==M)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([N,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let M=P(),S=Te.parse({operationId:E,customerId:M}),l=await R(m,s,S.operationId,_,S);if(l.customerId!==M||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await R("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await R("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=P(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return R("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=P(),E=await B("customer_commerce",m,async(_,M)=>{let[S,l]=await Promise.all([_(),R("customer_commerce",U.unknown(),void 0,M)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,M)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,M),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,M)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,M),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Ye,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Qe=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Qe.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Qe.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Me=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,R=!1){if(u!==void 0)try{let P=n.binding();if(!P)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...P,i,t]),requestId:y},z=b(B);if(Me.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!R&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Me.get(t.storage);u||Me.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Re(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Pe=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Rn(n){let d=we(n.baseUrl),f=n.scope,b=Ae(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,R="",P=0,B=0,z=0,m=!1,s,E=!0,_,M,S,l,o,T=-1,g,N=e=>{g===e&&(O.release(e.deliveryTicket),g=void 0,k())},J=new Set,c=(e,a)=>Q(n.onStatus,e,a),$=Re(),O=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Z=e=>te.forget(e.storageKey,e.command.requestId);function Y(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),k()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Y(o.recovery,a);let p=Pe(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,k())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ae({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Z(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function A(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==P||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=P,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===P&&p===y&&document.visibilityState!=="hidden"&&A(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(C=>C.command.funnelId===e.funnelId&&(!C.expiresAt||Date.parse(C.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let C={...p,storageKey:a.key,epoch:P,visit:y};ee.add(C.command.requestId),g=C,await F(C);return}let v=crypto.randomUUID(),K=O.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),k();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:P,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await F(j)}async function F(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(C){if(e.epoch!==P)return;let D=C.view;if(!(e.storageKey&&D&&(Pe(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await C.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Z(e)}catch(x){if(!(x instanceof G&&x.code==="FORBIDDEN"))throw x}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=O.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Y(e),c("starting",e.command.entryId);let C=await b.request("funnels",e.command),D=Ze.safeParse(C);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===P&&c(D.data.reason,e.command.entryId),Z(e),N(e);return}let x=Xe.parse(C);if(!x.runToken||x.scope.projectId!==f.projectId||x.scope.environment!==f.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(O.accept(e.deliveryTicket,x.run.id),e.epoch!==P){N(e),c("identity_changed",e.command.entryId);return}Y(e,x.run);let L=Ce({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?C:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==x.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Z(e),N(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-AMJXEASH.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),N(e);return}let Fe=!1,ke=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),N(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Pe(ne),n.container.append(ie);let xe=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Q(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Z(e),o?.client===L&&(o=void 0,L.reset(),k(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Q(n.host?.onDismiss,q)},onComplete(q){ke=!0,Z(e),o?.client===L&&re(),Q(n.host?.onComplete,q)},onError(q){Q(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Z(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||ke){xe.destroy(),ie.remove(),H(e)||await j(L),N(e);return}let he=Pe(L.view??ne);ie.hidden=he,o={host:xe,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:x.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,N(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(C){C instanceof G&&(!p||K&&C.code==="FORBIDDEN")&&C.status!==void 0&&C.status>=400&&C.status<500&&!C.retryable&&(Z(e),N(e)),e.epoch===P&&!t&&(c("start_failed",e.command.entryId),Q(n.host?.onError,C))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:P,visit:y};return g=p,F(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!A(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let k=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===R?!1:(R=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&k()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!A(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Ne(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((C,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let C=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([C(),v]),x=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||x>Date.now()+5e3||L-x>6e4||L<=x)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&k()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Ne()}catch{t||c("configuration_unavailable")}k()}}let Oe=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,R=location.origin+location.pathname,M=Ee(oe),S=n.session.subscribeIdentity(()=>{P++,$.cancel(),O.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),k()}),l=new MutationObserver(k),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",k),addEventListener("pagehide",ae),await Oe.refresh())},refresh:Ne,async retry(){g&&!t&&g.epoch===P&&await F(g)},destroy(){t=!0,u++,$.cancel(),O.release(g?.deliveryTicket),Oe.destroy(),_?.abort(),l?.disconnect(),M?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",k),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function Pn(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,R=0,P=-1,B=!1,z="",m,s,E,_,M=new Set,S,l,o,T=(r,A)=>Q(n.onStatus,r,A),g=Re(),N=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(N()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=N();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function O(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let A=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-AMJXEASH.js");if(t||A!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),P=R;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Q(n.host?.onDismiss,X)}});if(t||A!==y||l!==r){F.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:F,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||A!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Y()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Z(r){if(t||i||l||o||S||g.active||P===R||!O(r))return;let A=`${R}:${r.id}`;if(M.has(A))return;M.add(A);let H=R,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&R===H&&J()===V&&document.visibilityState!=="hidden"&&O(r)&&b?.entries.some(F=>F.id===r.id&&F.funnelId===r.funnelId&&F.versionId===r.versionId&&F.event===r.event&&JSON.stringify(F.target)===JSON.stringify(r.target)&&JSON.stringify(F.delivery)===JSON.stringify(r.delivery))===!0,()=>{let F=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(F===!1){T("frequency",r.id),Y();return}try{let X={entry:r,process:n.createProcess(r),visit:R,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Q(n.host?.onError,X)}},()=>{M.delete(A)})}function Y(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||P===R)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!M.has(`${R}:${r.id}`)&&O(r)){Z(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||P===R)return;let A=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!O(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||A(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Z(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,R++,g.cancel(),M.clear(),Y())};async function me(){if(t)return;if(s)return s;let r=y,A=new AbortController;m=A;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));A.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>A.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:A.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},k=await Promise.race([ue(),W]),se=Date.parse(k.validatedAt),oe=Date.parse(k.validUntil);if(k.scope.projectId!==n.scope.projectId||k.scope.environment!==n.scope.environment||k.scope.environmentId!==n.environmentId||k.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=k,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Y())})();s=X;try{await X}finally{clearTimeout(F),A.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Y),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Y),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Y();return}try{let A=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:R},S=void 0,await te(l)),A}catch(A){throw r.process.view||(S={...r,visit:R},l=void 0,ee()),A}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:R}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Y);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function it(n,d){return(await import("./paywall-ATZ2IZPS.js")).showPaywall(n,d)}async function ot(...n){return n[1]=ze(n[1]),(await import("./paywall-session-EMMF6IYS.js")).createPaywallSession(...n)}async function at(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),import("./paywall-ATZ2IZPS.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-AMJXEASH.js"),n[1].prepared)).showFunnelRun(...n)}finally{d?.()}}async function rn(n,d){try{return await n()}catch(f){throw d&&d.state!=="adopted"&&await import("./funnel-paywall-prerender-OSBI4VMY.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function st(...n){return import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),import("./paywall-ATZ2IZPS.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-M7MM33EC.js"),n[1].prepared)).showFunnelPurchase(...n)}async function ct(...n){return import("./funnel-host-purchase-M7MM33EC.js").catch(()=>{}),import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),(await import("./funnel-paywall-prerender-OSBI4VMY.js")).prerenderFunnelPurchase(...n)}async function dt(...n){return(await import("./content-RGKTEV23.js")).mountContent(...n)}async function lt(...n){return(await import("./content-RGKTEV23.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,un as createBrowserFunnelCommandStorage,gn as createBrowserFunnelPurchaseStorage,pn as createConfigurationSync,dn as createFeatureClient,hn as createFunnelClient,En as createFunnelPageExperiments,In as createFunnelProcess,vn as createFunnelPurchaseClient,Ce as createFunnelRunController,Rn as createIamFunnelEntries,Pn as createIamFunnelProcessEntries,wn as createLocalFunnelClient,ln as createLongplay,Sn as createMerchantBridge,ot as createPaywallSession,yn as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,fn as getPaywallRecovery,dt as mountContent,lt as prepareContent,mn as preparePaywallFallback,ct as prerenderFunnelPurchase,st as showFunnelPurchase,at as showFunnelRun,it as showPaywall};
@@ -0,0 +1 @@
1
+ import{N as r,O as m,h as e}from"./chunk-2KKLY323.js";import"./chunk-WRLVPHPE.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import"./chunk-7ZEXY4GC.js";import"./chunk-ZYN4CRHS.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};