@tinkerlandai/longplay-sdk 0.10.39 → 0.10.41

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 (120) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +57 -2
  3. package/README.zh-CN.md +6 -2
  4. package/dist/{ai-usage-DXwAGTxT.d.ts → ai-usage-B-qsCn-k.d.ts} +1 -1
  5. package/dist/{api-r6FfVQpg.d.ts → api-DpRb_Pd3.d.ts} +52 -0
  6. package/dist/check-response-SR3PDVGE.js +1 -0
  7. package/dist/chunk-24Z3THUR.js +1 -0
  8. package/dist/{chunk-IGANLTKS.js → chunk-26UXCYBP.js} +1 -1
  9. package/dist/{chunk-GGYBZWWY.js → chunk-2LERKK7O.js} +1 -1
  10. package/dist/{chunk-JBVZ6A6V.js → chunk-2LUVO7GM.js} +1 -1
  11. package/dist/{chunk-YJS6NNIO.js → chunk-2P2YSNYU.js} +1 -1
  12. package/dist/{chunk-ONMIBSOC.js → chunk-2RUJXZCO.js} +1 -1
  13. package/dist/chunk-2XF34Q6D.js +1 -0
  14. package/dist/chunk-4B4RB36N.js +1 -0
  15. package/dist/chunk-5PNH2FPI.js +1 -0
  16. package/dist/{chunk-CEMHQQAJ.js → chunk-6EBS6MLW.js} +1 -1
  17. package/dist/chunk-6OVMC5BT.js +1 -0
  18. package/dist/{chunk-LZBJHWVH.js → chunk-6STWY5GX.js} +1 -1
  19. package/dist/chunk-756SIMZF.js +1 -0
  20. package/dist/chunk-7IVLNV5H.js +1 -0
  21. package/dist/chunk-ANXK3B5B.js +1 -0
  22. package/dist/{chunk-KIPUBMU3.js → chunk-AQQJPP3P.js} +1 -1
  23. package/dist/chunk-BWRRZ2NW.js +1 -0
  24. package/dist/{chunk-O4KXODTJ.js → chunk-CQRSMCCG.js} +1 -1
  25. package/dist/{chunk-JAZHNQKO.js → chunk-DPEMW2FO.js} +1 -1
  26. package/dist/chunk-EECTJHI6.js +1 -0
  27. package/dist/{chunk-525K7BPJ.js → chunk-EJSDOSP5.js} +1 -1
  28. package/dist/{chunk-ZORZA4WG.js → chunk-EON4IKWR.js} +1 -1
  29. package/dist/chunk-EOPKOAR5.js +1 -0
  30. package/dist/{chunk-TLRRBUGP.js → chunk-FTVNGN6Z.js} +1 -1
  31. package/dist/{chunk-TPXRO63H.js → chunk-G6CWZBT5.js} +1 -1
  32. package/dist/chunk-GXADA7OV.js +1 -0
  33. package/dist/{chunk-U7XD4ZR5.js → chunk-H26F3IOI.js} +1 -1
  34. package/dist/{chunk-GNAMACMK.js → chunk-H7AHDGVU.js} +2 -2
  35. package/dist/chunk-HGH2X6QM.js +1 -0
  36. package/dist/chunk-KINNES62.js +1 -0
  37. package/dist/{chunk-3JD3U45R.js → chunk-MYDMOAKX.js} +1 -1
  38. package/dist/chunk-NFY7DKVJ.js +1 -0
  39. package/dist/{chunk-QCMFCK7Z.js → chunk-O3HLNU6T.js} +1 -1
  40. package/dist/chunk-OAAS5LJY.js +1 -0
  41. package/dist/{chunk-CBZ5GW4J.js → chunk-OEONV3JY.js} +1 -1
  42. package/dist/chunk-P6XQC7GG.js +1 -0
  43. package/dist/chunk-PYLX3WF6.js +1 -0
  44. package/dist/{chunk-O2D3A4CS.js → chunk-QJMM37CB.js} +1 -1
  45. package/dist/{chunk-CE5MAAIR.js → chunk-RQTYIUWP.js} +1 -1
  46. package/dist/chunk-S4P4UUUF.js +1 -0
  47. package/dist/{chunk-DPIQ3SV7.js → chunk-SYHMHKFQ.js} +1 -1
  48. package/dist/{chunk-PFPMK4IO.js → chunk-TGPZJ5A7.js} +1 -1
  49. package/dist/chunk-VILB5M4X.js +1 -0
  50. package/dist/chunk-VJHURKRY.js +1 -0
  51. package/dist/{chunk-UKVWANDE.js → chunk-VWRQBQZD.js} +1 -1
  52. package/dist/chunk-W35FZWGG.js +1 -0
  53. package/dist/chunk-W3J2SIPY.js +1 -0
  54. package/dist/chunk-Y2HXKANG.js +1 -0
  55. package/dist/{configuration-sync-BHrAf-ql.d.ts → configuration-sync-7ruSsSrL.d.ts} +150 -1
  56. package/dist/content-XYUJFGY2.js +1 -0
  57. package/dist/funnel-host-purchase-BNS3242X.js +1 -0
  58. package/dist/{funnel-local-client-DR8OpKGU.d.ts → funnel-local-client-BMxDQWE6.d.ts} +51987 -22983
  59. package/dist/{funnel-node-evaluation-COxXtZEQ.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -0
  60. package/dist/funnel-paywall-prerender-DDQI3GAZ.js +1 -0
  61. package/dist/{funnel-process-client-C87U4r_G.d.ts → funnel-process-client-DNR9nHs8.d.ts} +7338 -3163
  62. package/dist/funnel-route-prediction-BT5ZWU54.js +1 -0
  63. package/dist/funnel-route-source-7ZJMZRID.js +1 -0
  64. package/dist/funnel-runtime-host-3SSDNG24.js +1 -0
  65. package/dist/index.d.ts +273 -22
  66. package/dist/index.js +1 -1
  67. package/dist/merchant-bridge-contracts-YU53UKUN.js +1 -0
  68. package/dist/native-shell.js +1 -1
  69. package/dist/openrouter.d.ts +2 -2
  70. package/dist/openrouter.js +1 -1
  71. package/dist/operation-contracts-GEIGP23I.js +1 -0
  72. package/dist/page.d.ts +1 -1
  73. package/dist/page.js +1 -1
  74. package/dist/paywall-YZAEI7TF.js +1 -0
  75. package/dist/paywall-content-QBSB5NA7.js +1 -0
  76. package/dist/paywall-session-MHBAZLS7.js +1 -0
  77. package/dist/popup.d.ts +2 -2
  78. package/dist/popup.js +1 -1
  79. package/dist/{presentation-loading-B_v5XZtM.d.ts → presentation-loading-B2OeFzRN.d.ts} +1 -0
  80. package/dist/react-native.d.ts +6 -6
  81. package/dist/react-native.js +1 -1
  82. package/dist/screen-renderer-SEJG7A2C.js +1 -0
  83. package/dist/server.d.ts +34204 -17797
  84. package/dist/server.js +1 -1
  85. package/dist/{visual-dom-5LUN4AHO.js → visual-dom-7YYJQ2ZI.js} +1 -1
  86. package/dist/visual.js +1 -1
  87. package/package.json +9 -10
  88. package/dist/check-response-MNFEOKKE.js +0 -1
  89. package/dist/chunk-2Y5SGDC6.js +0 -1
  90. package/dist/chunk-3NCMYTNG.js +0 -1
  91. package/dist/chunk-3S25TLC3.js +0 -1
  92. package/dist/chunk-73ISTR7P.js +0 -1
  93. package/dist/chunk-BIT6YWM7.js +0 -1
  94. package/dist/chunk-CKVAV2W5.js +0 -1
  95. package/dist/chunk-GDD26ZDV.js +0 -1
  96. package/dist/chunk-HFD4CLCJ.js +0 -1
  97. package/dist/chunk-HX36OZPQ.js +0 -1
  98. package/dist/chunk-IYHXEKAD.js +0 -1
  99. package/dist/chunk-LJBTEB2Q.js +0 -1
  100. package/dist/chunk-MTIOLSVM.js +0 -1
  101. package/dist/chunk-N774V4SQ.js +0 -1
  102. package/dist/chunk-NSAEHRIT.js +0 -1
  103. package/dist/chunk-QXOUDODX.js +0 -1
  104. package/dist/chunk-TA4W6SXG.js +0 -1
  105. package/dist/chunk-VYI6QRJW.js +0 -1
  106. package/dist/chunk-W3G4YIM5.js +0 -1
  107. package/dist/chunk-YURGISSB.js +0 -1
  108. package/dist/content-HSMBQFM3.js +0 -1
  109. package/dist/funnel-host-purchase-4KOOLMXV.js +0 -1
  110. package/dist/funnel-paywall-prerender-NX6ZQ7EU.js +0 -1
  111. package/dist/funnel-runtime-host-6XYYLVCI.js +0 -1
  112. package/dist/merchant-bridge-contracts-ACGAMHU6.js +0 -1
  113. package/dist/operation-contracts-H27WHXQC.js +0 -1
  114. package/dist/paywall-ZGG6DXO3.js +0 -1
  115. package/dist/paywall-content-ZQBE2EZP.js +0 -1
  116. package/dist/paywall-session-DBTBLLWI.js +0 -1
  117. package/dist/screen-renderer-5SJCTMJH.js +0 -1
  118. /package/dist/{chunk-NOOIJXRN.js → chunk-2ULWP26K.js} +0 -0
  119. /package/dist/{chunk-OJM6ORHE.js → chunk-4PGYQ2TI.js} +0 -0
  120. /package/dist/{chunk-CILM5XMH.js → chunk-PBBREFS5.js} +0 -0
@@ -1 +0,0 @@
1
- import{f as ue,g as se}from"./chunk-HX36OZPQ.js";import{b as on}from"./chunk-ONMIBSOC.js";import{d as tn,e as pe}from"./chunk-CEMHQQAJ.js";import{c as Be,d as Ke,e as J,l as nn}from"./chunk-W3G4YIM5.js";import{$ as de,A as $e,E as Ye,S as Ze,X as We,Y as Xe,Z as $,_ as en,a as j,aa as U,b as qe,c as Me,d as je,e as G,f as Ge,g as Ue,i as X,w as ee,x as ze,y as Je}from"./chunk-IYHXEKAD.js";import{b as an}from"./chunk-3NCMYTNG.js";import{b as ne}from"./chunk-HFD4CLCJ.js";import{a as W}from"./chunk-IGANLTKS.js";import{$ as Qe,I as L,J as De,K as Le,Z as He,_ as le,aa as ce,g as Oe,m as Ae,q as Te,z as ae}from"./chunk-BIT6YWM7.js";import{b as D}from"./chunk-YURGISSB.js";import{a as f}from"./chunk-TPXRO63H.js";import{b as rn}from"./chunk-JBVZ6A6V.js";import{b as n}from"./chunk-NOOIJXRN.js";import{c as _e,d as ke,e as Ve,f as z}from"./chunk-O4KXODTJ.js";import{a as Pe,b as Ne}from"./chunk-CILM5XMH.js";function un(e){return Cn({...e,namespace:"commands",identity:[e.runToken]})}function Cn(e){let t,u,r=()=>new f("COMMAND_STORAGE_INVALID","Durable command storage is unavailable"),i=Promise.resolve().then(async()=>{if(t=e.storage??globalThis.localStorage,u=e.locks??globalThis.navigator?.locks,!t||!u||!globalThis.crypto?.subtle)throw r();let d=new TextEncoder().encode(JSON.stringify([new URL(e.baseUrl??rn).href,...e.identity])),a=new Uint8Array(await crypto.subtle.digest("SHA-256",d));return`indiana.funnel.${e.namespace}.v1.`+Array.from(a,o=>o.toString(16).padStart(2,"0")).join("")});i.catch(()=>{});async function p(d){try{let a=await i;return await u.request(a,{mode:"exclusive"},()=>d(a))}catch(a){throw a instanceof f?a:r()}}function c(d){let a=t.getItem(d);if(a===null)return{revision:0,entry:null};if(a.length>1048576)throw r();let o=JSON.parse(a);if(!o||typeof o!="object"||!("revision"in o)||!("entry"in o)||!Number.isSafeInteger(o.revision)||Number(o.revision)<0)throw r();return{revision:Number(o.revision),entry:o.entry}}return{read:()=>p(c),write:(d,a)=>p(o=>{if(c(o).revision!==d)return null;if(!Number.isSafeInteger(d+1))throw r();let y=JSON.stringify({revision:d+1,entry:a});if(y.length>1048576)throw r();return t.setItem(o,y),d+1})}}var sn=n.strictObject({type:n.literal("funnel"),id:n.uuid(),versionId:n.uuid()});var q=n.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Pn=n.enum(["running","waiting","completed","closed","ineligible","failed"]),Nn=n.discriminatedUnion("type",[Ye,n.strictObject({type:n.literal("wait"),receiptId:n.uuid(),kind:n.enum(["timer","event","operation"]),deadline:n.iso.datetime({offset:!0}).nullable(),eventName:q.optional()}),n.strictObject({type:n.literal("open_url"),receiptId:n.uuid(),url:We,openIn:Xe}),n.strictObject({type:n.literal("event"),receiptId:n.uuid(),event:q})]),On={id:q,presentation:Te,outputs:n.array(q).max(250),inputs:ce,values:n.record(n.string(),L).optional(),offeringKey:j.optional(),capabilities:Oe,customerData:Ae,dataCursors:n.record(q,He.nullable())},An=n.strictObject({...On,content:n.strictObject({type:n.literal("document"),document:ae})}),me=n.strictObject({id:n.uuid(),source:sn,revision:n.number().int().nonnegative(),visit:n.number().int().nonnegative(),nodeId:q,nodeType:n.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),status:Pn,stopped:n.boolean(),canBack:n.boolean(),authenticated:n.boolean(),locale:n.string().min(1).max(35),answers:le,parameters:Qe,variables:n.record(n.string(),L),output:L.nullable(),screen:An.nullable(),paywall:n.strictObject({receiptId:n.uuid(),resolution:n.union([tn,pe]),quote:ue.nullable(),operation:se.nullable(),purchaseRequestId:n.uuid().nullable(),selectionGeneration:n.number().int().nonnegative().optional(),canReselect:n.boolean().optional()}).nullable(),instruction:Nn.nullable(),pendingRequest:n.strictObject({requestId:n.uuid(),authenticationRequired:n.boolean()}).nullable(),runExpiresAt:n.iso.datetime({offset:!0}),credentialExpiresAt:n.iso.datetime({offset:!0}).nullable()}),Tn=n.strictObject({scope:D,run:me,settlement:n.strictObject({requestId:n.uuid(),state:n.enum(["pending","unknown","settled"]),operationId:n.uuid().nullable(),receiptId:n.uuid().nullable().optional()}).optional(),purchase:n.strictObject({receiptId:n.uuid(),quote:ue.nullable(),operation:se.nullable(),canReselect:n.boolean().optional()}).optional(),review:n.strictObject({activeOperationId:n.uuid().nullable(),pages:n.array(n.strictObject({receiptId:n.uuid(),nodeId:q,visit:n.number().int().nonnegative()})).max(100),page:n.strictObject({receiptId:n.uuid(),nodeId:q,visit:n.number().int().nonnegative(),document:ae,answers:le,inputs:ce,values:n.record(n.string(),L).optional()}).nullable(),coupons:n.array(n.strictObject({grantId:n.uuid(),status:n.enum(["issued","reserved","redeemed","expired","revoked","unknown"]),expiresAt:n.string().nullable()})).max(100),purchases:n.array(n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),status:n.enum(["pending","complete","cancelled","failed","unknown"])})).max(100)}).optional(),runToken:n.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/).optional(),customerId:n.uuid().optional()}),ln=Tn.extend({run:me.extend({paywall:me.shape.paywall.unwrap().extend({resolution:pe}).nullable()})});var cn="X-Indiana-Server-Key";var H=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function fe(e,t,u){let r={},i,p,c,d="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let o=e.cases.findIndex(g=>ke(t.attributes??{},g.condition,t.savedGroups??{}));d=o<0?"default":`case:${o}`,a=o<0?e.default:e.cases[o].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new H("Required GB Feature is unavailable");i=z(e.featureKey,t),c=i.value,Object.assign(r,G(e,{value:c})),a=e.next;break;case"split":{let o=u[e.experimentId];if(!o)throw new H("Required GB Experiment is unavailable");if(p=Ve(o,t),c=p.value,d=p.inExperiment&&!p.passthrough&&typeof c=="string"?c:"notParticipating",a=d==="notParticipating"?e.notParticipating:e.routes[d],!a)throw new H("Experiment Variation has no published route");break}case"offering":{let o=e.configuration.source==="fixed"?e.configuration.versionId:z(e.configuration.featureKey,t).value;c={type:"offering_version",id:n.uuid().parse(o)},Object.assign(r,G(e,{value:c})),a=e.next;break}case"coupon":case"coupons":c=e.type==="coupons"?e.couponIds.map(o=>({type:"reward",id:o})):{type:"reward",id:e.couponId},Object.assign(r,G(e,{value:c})),a=e.next;break}return{port:d,target:a,projections:r,...c===void 0?{}:{value:c},...i?{feature:i}:{},...p?{experiment:p}:{}}}function dn(e,t,u){n.uuid().parse(e),n.number().int().nonnegative().parse(t);let r=Pe(Ne(new TextEncoder().encode(JSON.stringify([e,t,u])))).slice(0,32);return`${r.slice(0,8)}-${r.slice(8,12)}-5${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20)}`}var _n=n.strictObject({selector:n.string().min(1).max(2048),action:n.enum(["set","append","remove"]),attribute:n.string().min(1).max(128).refine(e=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e)),value:n.string().max(5e4).optional(),parentSelector:n.string().max(2048).optional(),insertBeforeSelector:n.string().max(2048).optional()}),kn=n.strictObject({variation:n.string().min(1).max(128),description:n.string().max(2e3).default(""),css:n.string().max(1e5).default(""),js:n.string().max(1e5).default(""),domMutations:n.array(_n).max(200).default([]),iam:ze.optional(),renderGuard:ee.optional()}),ge=kn.omit({variation:!0,description:!0,iam:!0}),Vn=Be.omit({variations:!0,active:!0}).extend({changeId:n.string().regex(/^[a-f0-9]{64}$/),variations:n.tuple([ge,ge]).rest(ge).refine(e=>e.length<=20)}),pn=n.strictObject({trackExposures:n.boolean(),environmentId:n.uuid(),generation:n.string().regex(/^[a-f0-9]{64}$/),experiments:n.array(Vn).max(100),savedGroups:Ke});var Q=n.string().regex(/^[a-f0-9]{64}$/),jt=n.strictObject({iam:Q,executionContracts:n.union([n.tuple([n.literal("funnel-run/1")]),n.tuple([n.literal("funnel-process/1")])]).default(["funnel-run/1"])}),Dn=n.strictObject({release:Q,render:ee,button:n.strictObject({selector:n.string().min(1).max(512),elementKey:n.string().min(1).max(256),tag:n.enum(["button","a","input"])}).nullable()}),Gt=n.strictObject({scope:D.extend({environmentId:n.uuid()}),release:Q,validatedAt:n.iso.datetime({offset:!0}),validUntil:n.iso.datetime({offset:!0}),entries:n.array(n.strictObject({id:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),event:n.enum(["screen_enter","button_click"]),delivery:Je.optional(),target:Dn})).max(4e3)}),Ut=n.strictObject({operation:n.literal("entry_start"),funnelId:n.uuid(),versionId:n.uuid(),entryId:n.uuid(),release:Q,requestId:n.uuid(),locale:n.string().min(1).max(35).default("en")}),Bt=n.strictObject({scope:D,suppressed:n.literal(!0),reason:n.enum(["frequency","in_progress"]),retryAt:n.iso.datetime({offset:!0}).nullable()}),Kt=n.strictObject({experimentId:n.uuid(),splitNodeId:n.string().min(1).max(128)}),Ln=n.strictObject({experimentId:n.uuid(),experimentKey:n.string().min(1).max(128),variationKey:n.string().min(1).max(128),inExperiment:n.boolean(),generation:n.string().min(1).max(256)}),ye=n.strictObject({operation:n.literal("page_experiments"),release:Q,usedReceiptIds:n.array(n.uuid()).max(20).default([]),customerToken:n.string().regex(W).optional()}),mn=n.strictObject({scope:D,runId:n.uuid(),assignments:n.array(Ln.extend({receiptId:n.uuid()})).max(100),payload:pn});var B=n.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),gn=n.strictObject({entry:B,nodes:n.array(n.strictObject({id:B,type:n.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),outputs:n.record(n.string(),B),writes:n.record(j,j),resources:n.strictObject({screenId:B.optional(),paywallVersionId:n.uuid().optional(),couponId:n.uuid().optional(),couponIds:n.array(n.uuid()).max(20).optional(),experimentId:n.uuid().optional(),featureKey:n.string().optional(),offeringVersionId:n.uuid().optional()})})).min(1).max(500)}),fn={scope:D,funnelId:n.uuid(),versionId:n.uuid(),evaluationRevision:n.number().int().nonnegative(),expiresAt:n.iso.datetime({offset:!0}).nullable(),topology:gn},te=n.discriminatedUnion("evaluationMode",[n.strictObject({...fn,evaluationMode:n.literal("local"),growth:J,conditions:n.record(B,n.array(n.strictObject({condition:Le,port:n.string()})))}),n.strictObject({...fn,evaluationMode:n.literal("remote")})]),qn=te.options[0].extend({evaluation:n.strictObject({maxTransitions:n.number().int().min(1).max(1e4),variables:n.record(j,Me),outputSchema:qe,terminals:n.record(B,n.strictObject({outcome:n.enum(["completed","closed","ineligible","failed"]),output:Ze.nullable()}))})});function Mn(e){return gn.parse({entry:e.graph.entry,nodes:e.graph.nodes.map(t=>{let u={},r={};switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":u.next=t.next;break;case"screen":Object.assign(u,t.outputs),r.screenId=t.screenId;{let p=e.screens.find(c=>c.id===t.screenId);p?.type==="paywall"&&(r.paywallVersionId=p.paywallVersionId)}break;case"condition":t.cases.forEach((p,c)=>{u[`case:${c}`]=p.target}),u.default=t.default;break;case"split":Object.assign(u,t.routes),u.notParticipating=t.notParticipating,r.experimentId=t.experimentId;break;case"action":for(let p of["success","cancel","unavailable","failure"])u[p]=t[p];t.action.type==="claim_offer"&&t.action.coupon.source==="literal"&&t.action.coupon.value&&typeof t.action.coupon.value=="object"&&!Array.isArray(t.action.coupon.value)&&(r.couponId=n.uuid().parse(t.action.coupon.value.id));break;case"external_page":u.opened=t.opened,u.failed=t.failed;break;case"wait":t.wait.type==="duration"?u.elapsed=t.wait.elapsed:(u.received=t.wait.received,u.timeout=t.wait.timeout);break;case"end":case"output":break}t.type==="feature"&&(r.featureKey=t.featureKey),t.type==="offering"&&t.configuration.source==="feature"&&(r.featureKey=t.configuration.featureKey);let i=t.type==="output"?t.value:t.type==="end"?t.output:void 0;return i?.type==="feature"&&(r.featureKey=i.featureKey),t.type==="coupon"&&(r.couponId=t.couponId),t.type==="coupons"&&(r.couponIds=t.couponIds),t.type==="offering"&&t.configuration.source==="fixed"&&(r.offeringVersionId=t.configuration.versionId),{id:t.id,type:t.type,outputs:u,resources:r,writes:"writes"in t?t.writes??{}:{}}})})}function ve(e){let t=de.parse(e.document),u=e.evaluationMode==="local"?J.parse(e.payload):null;if(u&&(u.scope.projectId!==e.scope.projectId||u.scope.environment!==e.scope.environment))throw new Error("GB payload belongs to another App or environment");let r={scope:e.scope,funnelId:e.funnelId,versionId:e.versionId,evaluationRevision:e.evaluationRevision,evaluationMode:e.evaluationMode,expiresAt:u?.expiresAt??null,topology:Mn(t)};return te.parse(e.evaluationMode==="remote"?r:{...r,growth:nn(t,u),conditions:Object.fromEntries(t.graph.nodes.filter(i=>i.type==="condition").map(i=>[i.id,i.cases.map((p,c)=>({condition:p.condition,port:`case:${c}`}))]))})}function er(e){let t=ve(e);if(t.evaluationMode!=="local")throw new Error("Remote Funnel cannot disclose local rules");let u=de.parse(e.document);return qn.parse({...t,evaluation:{maxTransitions:u.execution.maxTransitions,variables:u.variables,outputSchema:u.outputSchema,terminals:Object.fromEntries(u.graph.nodes.flatMap(r=>{let i=r.type==="end"?r.output:r.type==="output"?r.value:void 0;return r.type!=="end"&&r.type!=="output"?[]:i&&i.type!=="literal"&&i.type!=="feature"&&i.type!=="variable"?[]:[[r.id,{outcome:r.type==="end"?r.outcome:"completed",output:i??null}]]}))}})}var he=32,jn=522240;function we(e){if(["entry","condition","feature","split","offering","coupon","coupons"].includes(e.type))return!0;if(e.type!=="end"&&e.type!=="output")return!1;let t=e.type==="end"?e.output:e.value;return t?.type!=="bundle"&&t?.type!=="selection"}var Gn=n.strictObject({nodeId:n.string().min(1).max(64),visit:n.number().int().nonnegative(),revision:n.number().int().nonnegative()}),Ie=n.record(n.string(),L),Un=n.strictObject({id:n.uuid(),nodeId:n.string().min(1).max(64),visit:n.number().int().nonnegative(),input:n.strictObject({schemaVersion:$.shape.schemaVersion,kind:$.shape.kind,selector:$.shape.selector,contract:$.shape.contract}),context:Ie,removed:n.array(n.string()).max(100),attributes:Ie,removedAttributes:n.array(n.string()).max(100),result:en,offeringVersionId:n.uuid().nullable(),events:n.strictObject({entered:n.string().regex(/^[1-9][0-9]{0,18}$/),decision:n.string().regex(/^[1-9][0-9]{0,18}$/).nullable()})}),ar=n.strictObject({schemaVersion:n.literal(1),mode:n.enum(["local","remote"]),versionId:n.uuid(),generation:n.number().int().positive(),base:Gn,context:Ie,steps:n.array(Un).min(1).max(he)}).refine(e=>X(e)<=jn,"Segment exceeds its byte budget");var Bn=/^(parameters(?:\.|$)|answers(?:\.|$)|results(?:\.|$)|variables(?:\.|$)|funnelParticipantId$)/;function Y(e){return Array.isArray(e)?e.some(Y):!e||typeof e!="object"?!1:Object.entries(e).some(([t,u])=>t.startsWith("$")?["$and","$or","$nor","$not"].includes(t)&&Y(u):!Bn.test(t))}function yn(e,t,u,r){if(e.executionContract!=="funnel-process/1"||r)return null;if(["offering","coupon","coupons"].includes(t.type)||t.type==="action"&&t.action.type!=="event"||t.type==="screen"&&(t.offering||e.screens.some(d=>d.id===t.screenId&&d.type==="paywall")))return"customer_required";let i=t.type==="end"?t.output:t.type==="output"?t.value:void 0;if(i&&["bundle","selection","offering"].includes(i.type)||t.type==="condition"&&t.cases.some(d=>Y(d.condition)))return"customer_required";let p=JSON.stringify([t,t.type==="screen"?e.screens.find(d=>d.id===t.screenId):null]);for(let[d,a]of Object.entries(e.variables))if(a.source.type==="attribute"&&a.source.key!=="funnelParticipantId"&&(p.includes(`variables.${d}`)||p.includes(JSON.stringify(d))))return"customer_required";if(t.type==="split"){let d=u.experiments?.[t.experimentId];if((d?.hashAttribute??"id")!=="funnelParticipantId"||Y(d?.condition)||d?.parentConditions?.length)return"customer_experiment_required"}let c=t.type==="feature"?t.featureKey:i?.type==="feature"?i.featureKey:void 0;return c&&u.features?.[c]?.rules?.some(d=>(d.hashAttribute??"id")!=="funnelParticipantId"||Y(d.condition)||d.parentConditions?.length)?"customer_experiment_required":null}var be=class extends Error{constructor(u,r){super(r);this.code=u;this.name="FunnelLocalCalculationError"}code},re=(e,t)=>new be(e,t),Kn=e=>({experiments:e.experiments,features:e.features});function xe(e,t=re){let u=new Map(e.topology.nodes.map(c=>[c.id,c])),r=_e(e.growth.savedGroups),i=Kn(e.growth);function p(c,d){if(!Object.hasOwn(e.growth.features,c))throw t("INVALID_RESPONSE","Required GB Feature is unavailable");return z(c,d).value}return{nodes:u,savedGroups:r,features:i.features,feature:p,evaluate(c,d){let a=u.get(c);if(!a)throw t("NOT_FOUND","Funnel node is unavailable");let o,g;if(a.type==="condition"){let I=e.conditions[a.id];if(!I)throw t("INVALID_RESPONSE","Local condition rules are unavailable");o=fe({id:a.id,name:a.id,type:"condition",cases:I.map(h=>({condition:h.condition,target:a.outputs[h.port]})),default:a.outputs.default},d,i.experiments).port}else if(a.type==="feature"){if(!a.resources.featureKey)throw t("INVALID_RESPONSE","Feature reference is unavailable");g=p(a.resources.featureKey,d),o="next"}else if(a.type==="split"){if(!(a.resources.experimentId?e.growth.experiments[a.resources.experimentId]:void 0))throw t("INVALID_RESPONSE","Experiment reference is unavailable");let h=fe({id:a.id,name:a.id,type:"split",experimentId:a.resources.experimentId,routes:a.outputs,notParticipating:a.outputs.notParticipating},d,i.experiments);g=h.value,o=h.port}else if(["offering","end","output"].includes(a.type)&&a.resources.featureKey)g=p(a.resources.featureKey,d),o=a.type==="offering"?"next":"value";else throw t("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let y=a.outputs[o]??(o==="value"?a.id:void 0);if(!y)throw t("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:c,port:o,target:y,...g===void 0?{}:{value:g}}}}}function hr(e,t,u,r=re){return Re(e,r)(t,u)}function Re(e,t){let u=te.parse(e);if(u.evaluationMode!=="local")throw t("EVALUATION_MODE","Remote nodes are evaluated by Grow");let r=u.expiresAt?Date.parse(u.expiresAt):null,i=()=>{if(r!==null&&r<=Date.now())throw t("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition")};i();let p=xe(u,t);return(c,d)=>(i(),zn(p,c,d))}function zn(e,t,u){let r=De.parse(u.attributes??{}),{saveStickyBucketAssignmentDoc:i,onFeatureUsage:p,onExperimentViewed:c}=u,d={attributes:r,...i?{saveStickyBucketAssignmentDoc:a=>i(structuredClone(a))}:{},...p?{onFeatureUsage:(a,o)=>p(a,structuredClone(o))}:{},...c?{onExperimentViewed:(a,o)=>c(structuredClone(a),structuredClone(o))}:{},features:e.features,savedGroups:e.savedGroups,...u.stickyBucketAssignmentDocs?{stickyBucketAssignmentDocs:structuredClone(u.stickyBucketAssignmentDocs)}:{}};return e.evaluate(t,d)}function wr(e,t,u,r=re){return vn(Re(e,r),t,u)}function vn(e,t,u){let r=[],i=[],p=[],c=e(t,{...u.attributes?{attributes:u.attributes}:{},stickyBucketAssignmentDocs:u.sticky,saveStickyBucketAssignmentDoc(d){let a=r.findIndex(y=>y.next.attributeName===d.attributeName&&y.next.attributeValue===d.attributeValue),o=d.attributeName+"||"+d.attributeValue,g={expected:u.sticky[o]??null,next:d};a<0?r.push(g):r[a]=g},onExperimentViewed(d,a){a.inExperiment&&a.hashUsed&&!a.passthrough&&i.push(L.parse({key:d.key,variationId:a.variationId,keyUsed:a.key,hashAttribute:a.hashAttribute,hashValue:a.hashValue}))},onFeatureUsage(d,a){p.push(L.parse({feature:d,value:a.value,source:a.source,...a.ruleId?{ruleId:a.ruleId}:{}}))}});return{port:c.port,...c.value===void 0?{}:{value:c.value},sticky:r,exposures:i,features:p}}function In(e,t,u,r=re){let i=u,p=new Map(t.graph.nodes.map(O=>[O.id,O])),c=structuredClone(u.variables),d=structuredClone(i.sticky),a=[],o=u.nodeId,g=u.visit,y=!1,I,h=O=>yn(t,O,e.evaluationMode==="local"?e.growth:{features:{},experiments:{}},i.attributes.funnelCustomerBound===!0),b=O=>(I??=Re(e,r),vn(I,O,{attributes:$e({declarations:t.variables,attributes:i.attributes,parameters:u.parameters,answers:u.answers,results:c,savedGroups:{}}),sticky:d}));for(let O=0;O<he;O++){let s=p.get(o);if(!s||!we(s)||h(s))break;if(g>=t.execution.maxTransitions&&(g>t.execution.maxTransitions||s.type!=="end"&&s.type!=="output")){if(!a.length)throw r("TRANSITION_LIMIT","Local Funnel transition budget exceeded");break}let m,x;if(["condition","feature","split"].includes(s.type)||s.type==="offering"&&s.configuration.source==="feature")m=b(s.id),s.type==="offering"&&(m.value={type:"offering_version",id:String(m.value)}),s.type==="condition"?x=m.port==="default"?s.default:s.cases[Number(m.port.slice(5))]?.target:s.type==="split"?x=m.port==="notParticipating"?s.notParticipating:s.routes[m.port]:(s.type==="feature"||s.type==="offering")&&(x=s.next);else if(m={port:"next",sticky:[],exposures:[],features:[]},(s.type==="entry"||s.type==="coupon"||s.type==="coupons")&&(x=s.next),s.type==="offering"&&s.configuration.source==="fixed"&&(m.value={type:"offering_version",id:s.configuration.versionId},x=s.next),s.type==="end"||s.type==="output"){let R=s.type==="end"?s.output:s.value;if(m=R?.type==="feature"?b(s.id):{...m,port:"value",value:R?.type==="literal"?R.value:R?.type==="variable"?Ue({source:"variable",key:R.key,...R.path?{path:R.path}:{}},{declarations:t.variables,answers:u.answers,results:c,parameters:u.parameters,attributes:i.attributes,savedGroups:{}}):null},R&&(m.value===void 0||!je(t.outputSchema,m.value)))throw r("INVALID_RESPONSE","Local terminal violates its declared output")}let C=[...a,{nodeId:o,result:m}];if(X({steps:C})>6e4){if(!a.length)throw r("INVALID_REQUEST","Local step exceeds its command budget");break}if(a.push({nodeId:o,result:m}),s.type==="feature"||s.type==="offering"||s.type==="coupon"||s.type==="coupons"){let R=s.type==="coupons"?s.couponIds.map(V=>({type:"reward",id:V})):s.type==="coupon"?{type:"reward",id:s.couponId}:m.value;if(R===void 0)throw r("INVALID_RESPONSE","Node output is missing");let _=G(s,{value:R});Ge(t.variables,s,_),Object.assign(c,_)}for(let R of m.sticky)d[`${R.next.attributeName}||${R.next.attributeValue}`]=structuredClone(R.next);if(s.type==="end"||s.type==="output"){y=!0;break}if(!x)throw r("INVALID_RESPONSE","Local pure exit is unavailable");o=x,g++}let T=p.get(o);return{steps:a,...!y&&T&&(!we(T)||h(T))?{boundary:{nodeId:o,visit:g}}:{}}}function hn(e,t){let u=ln.safeParse(t);if(!u.success)throw new f("INVALID_RESPONSE","Funnel response contract changed");let r=u.data;if(e.scope&&(r.scope.projectId!==e.scope.projectId||r.scope.environment!==e.scope.environment))throw new f("SCOPE_MISMATCH","Funnel scope changed");return r}var Se=(e,t)=>new f(e,t);function Cr(e){return xe(e,Se)}var Jn=3,$n=2e3;function Hn(e){return e instanceof TypeError||e instanceof f&&/^(?:CONFIGURATION_UNAVAILABLE|CONFIGURATION_HTTP_(?:429|5\d\d)|TEMPORARY_UNAVAILABLE)$/i.test(e.code)}async function Qn(e){for(let t=1;;t++)try{return await e.refresh()}catch(u){if(t===Jn||!Hn(u))throw u;await new Promise(r=>setTimeout(r,t*$n))}}async function Fe(e,t,{predict:u=!0}={}){let r=t.instruction;if(r?.type!=="evaluate_segment")throw new Error("Local segment instruction required");if(!e)throw new f("CONFIGURATION_UNAVAILABLE","Local execution requires public configuration");if(e.scope.environmentId!==r.environmentId)throw new f("SCOPE_MISMATCH","Evaluation environment changed");let i=null,p;if(u)try{let c=await e.funnel(t.source.id,t.source.versionId);p=c.manifest.generation,i=Yn(e,t,c)}catch{i=null}return p??=e.snapshot?.generation??(await Qn(e)).generation,{advance:{policyRevision:r.policyRevision,generation:p},prediction:i}}function Yn(e,t,u){let r=t.instruction;if(r?.type!=="evaluate_segment"||!u.growth||u.control.evaluationMode!=="local"||u.control.evaluationRevision!==r.policyRevision)return null;let{analyticsConfig:i,remoteFeatures:p,...c}=u.growth,d=ve({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:t.source.id,versionId:t.source.versionId,evaluationMode:"local",evaluationRevision:r.policyRevision,document:u.document,payload:J.parse(c)}),a=Zn(d,u.document,{...t,...r}),o=a.steps.at(-1),g=a.boundary??(o?.result.port==="value"?{nodeId:o.nodeId,visit:t.visit+a.steps.length-1}:null);return g?{runId:t.id,from:{nodeId:t.nodeId,visit:t.visit,revision:t.revision},nodeId:g.nodeId,visit:g.visit,terminal:!a.boundary}:null}function Zn(e,t,u){return In(e,t,u,Se)}var wn=U.refine(e=>!["start","get","review"].includes(e.operation)&&!("customerToken"in e),"Persist only the original mutation, without credentials").transform(e=>{if(e.operation==="start"||e.operation==="get"||e.operation==="review")throw new f("COMMAND_STORAGE_INVALID","Stored mutation required");return e}),bn=n.strictObject({schemaVersion:n.literal(1),scope:D,runId:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),processBindingIds:n.record(n.uuid(),n.uuid().nullable()).optional(),command:wn.optional(),closeCommand:wn.refine(e=>e.operation==="close").optional(),purchase:n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),generation:n.number().int().nonnegative()}).optional(),closed:n.literal(!0).optional()}).refine(e=>!e.closeCommand||e.command&&e.command.operation!=="close"&&e.command.requestId!==e.closeCommand.requestId,"Close requires a separate request identity").refine(e=>e.command!==void 0||e.purchase!==void 0,"A recovery record requires an original obligation"),A=()=>new f("COMMAND_STORAGE_CONFLICT","Another host changed this Run's pending command"),oe=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Z(e,t){if(!e||!t)return e;if(e.processBindingIds&&Object.hasOwn(e.processBindingIds,t)){let u={...e.processBindingIds};delete u[t],e={...e,processBindingIds:u}}return e.command?.requestId===t?e.closeCommand?{...e,command:e.closeCommand,closeCommand:void 0}:e.purchase?{...e,command:void 0}:null:e.closeCommand?.requestId===t?{...e,closeCommand:void 0}:e}function xn(e){let t=0,u=null,r=a=>JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]),i=Promise.resolve();async function p(){let a=await e.read();if(!Number.isSafeInteger(a.revision)||a.revision<0)throw new f("COMMAND_STORAGE_INVALID","Invalid command storage revision");return{revision:a.revision,entry:a.entry===null?null:bn.parse(a.entry)}}function c(a){let o=i.then(a);return i=o.catch(()=>{}),o}async function d(a){for(let o=0;o<4;o++){let g=await p();if(g.entry&&u!==null&&r(g.entry)!==u)throw A();let y=a(g.entry,g.revision);if(oe(g.entry,y)){t=g.revision;return}let I=await e.write(g.revision,y);if(I!==null){if(!Number.isSafeInteger(I)||I<=g.revision)throw A();t=I;return}}throw A()}return{bind(a){let o=JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]);if(u!==null&&u!==o)throw A();u=o},async load(){let a=await p();return t=a.revision,u=a.entry?r(a.entry):null,a.entry},retain(a){let o=bn.parse(a),g=o.command;return!g||u!==null&&r(o)!==u?Promise.reject(A()):(u??=r(o),c(()=>d((y,I)=>{if(y&&!oe(r(y),r(o)))throw A();if(y&&o.processBindingIds){for(let[h,b]of Object.entries(o.processBindingIds))if(y.processBindingIds&&Object.hasOwn(y.processBindingIds,h)&&y.processBindingIds[h]!==b)throw A();y={...y,processBindingIds:{...y.processBindingIds,...o.processBindingIds}}}if(!y){if(I!==t&&g.operation!=="close")throw A();return o}if(!y.command)return{...y,command:g,...g.operation==="close"?{closed:!0}:{}};if(g.operation==="close"&&y.command.operation!=="close"){if(y.command.requestId===g.requestId||y.closeCommand&&!oe(y.closeCommand,g))throw A();return{...y,closeCommand:g,closed:!0}}if(!oe(y.command,g))throw A();return y})))},observePurchase(a,o,g,y){return c(()=>d((I,h)=>{if(!I&&h!==t||I&&r(I)!==r({...a,schemaVersion:1}))throw A();if(I?.purchase&&I.purchase.generation>o.generation)return Z(I,y);if(I?.purchase&&I.purchase.generation===o.generation&&I.purchase.operationId!==o.operationId)throw A();return g?!I?.purchase||I.purchase.operationId!==o.operationId?Z(I,y):Z(I.command?{...I,purchase:void 0}:null,y):Z({schemaVersion:1,...a,...I,purchase:o},y)}))},settle(a){return c(()=>d(o=>Z(o,a)))}}}function jr(e,t){return t.type==="id"?e.customerId===t.value:e.externalUserId===t.value}function ie(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,p)=>ie(i,t[p]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let u=Object.entries(e),r=Object.entries(t);return u.length===r.length&&u.every(([i,p])=>Object.hasOwn(t,i)&&ie(p,Reflect.get(t,i)))}function Rn(e,t){let u=t&&{...t},r=null,i=0,p=-1,c=0,d=new AbortController;function a(){c++,d.abort(new f("IDENTITY_CHANGED","Run identity changed")),d=new AbortController}let o=!1,g,y=0,I=new Set;return{get scope(){return u},bindScope(h){if(u&&(u.projectId!==h.projectId||u.environment!==h.environment))throw new f("SCOPE_MISMATCH","Run scope changed");u??={...h}},get view(){return r},get currentView(){return p===c?r:null},get viewAgeMs(){return r&&p===c?performance.now()-i:void 0},get generation(){return c},get signal(){return d.signal},get disposed(){return o},get customerToken(){return g},get readSequence(){return y},nextRead(){return++y},assertCurrent(h,b="Run identity changed during the request"){if(h!==c||o)throw new f("IDENTITY_CHANGED",b)},assertRun(h){if(r&&(h.id!==r.id||h.source.type!==r.source.type||h.source.id!==r.source.id||h.source.versionId!==r.source.versionId||h.locale!==r.locale||!ie(h.parameters,r.parameters)))throw new f("INVALID_RESPONSE","Run version changed");if(e&&h.source.id!==e)throw new f("INVALID_RESPONSE","Run belongs to another Funnel")},publish(h,b,T,O,s){if(!(h.operation==="review"&&r&&r!==T&&b.run.revision<=r.revision)&&!(r&&b.run.revision===r.revision&&O!==void 0&&O<y)&&(h.operation==="review"&&!b.run.stopped&&["running","waiting"].includes(b.run.status)&&r&&p===c&&b.run.nodeId===r.nodeId&&b.run.visit===r.visit&&b.run.revision===r.revision&&(b.run.screen=r.screen,(r.paywall?.quote?.operationId===b.review?.activeOperationId||!r.paywall?.quote&&b.review?.activeOperationId===null)&&(b.run.paywall=r.paywall)),!(r?.paywall&&b.run.paywall&&r.paywall.receiptId===b.run.paywall.receiptId&&(b.run.paywall.selectionGeneration??0)<(r.paywall.selectionGeneration??0)))){if(!r||b.run.revision>=r.revision)r=b.run,i=performance.now(),p=c;else if(!s)return;if(r&&p===c)for(let m of I)try{m(structuredClone(r))}catch{}}},identify(h){if(o)throw new f("IDENTITY_CHANGED","Controller was reset");if(!W.test(h))throw new f("INVALID_TOKEN","Customer credential required");a(),g=h},subscribe(h){return I.add(h),()=>I.delete(h)},reset(){o||(o=!0,a(),g=void 0,r=null,I.clear())}}}var Ee=/^gg_sk_[A-Za-z0-9_-]{32,128}$/;function $r(e,t,u="A server API key is required"){if(typeof window<"u")throw new f("SERVER_ONLY",t);if(!Ee.test(e))throw new f("INVALID_TOKEN",u)}function Hr(e){let t=ne(e);return t.identify(e.apiKey),t}function Sn(e,t){if(!e)return;let u=t?.execution,r=u?.provider==="merchant"?"merchant":u?.provider==="stripe"?u.executor==="merchant"?"record_only":"indiana":t&&["apple","google"].includes(t.provider)?"native":t?.provider==="stripe"?"indiana":void 0;if(!r||!e.allowed.includes(r))throw new f("EXECUTION_POLICY_REFUSED","The original quote does not permit the declared purchase execution")}function M(e){let{customerToken:t,...u}=e;return u}var Wn=e=>!(e instanceof f&&e.code==="EXECUTION_POLICY_REFUSED")&&(!(e instanceof f)||e.status===void 0||e.status>=500||[401,425].includes(e.status)||e.recovery==="recover_operation");function Fn({journal:e,state:t,call:u,processIdentity:r}){let i=null,p=null,c=!1,d={command:null,close:null},a=new Set,o,g=null,y=e?e.load().then(s=>{if(t.disposed)throw new f("IDENTITY_CHANGED","Controller was reset during command restoration");if(g=s,!s)return;if(r){if([s.command,s.closeCommand].some(x=>x&&!Object.hasOwn(s.processBindingIds??{},x.requestId)))throw new f("COMMAND_STORAGE_INVALID","The original process identity is missing");r.restore(s.processBindingIds??{})}if(t.scope&&(s.scope.projectId!==t.scope.projectId||s.scope.environment!==t.scope.environment))throw new f("SCOPE_MISMATCH","Pending command belongs to another scope");if(o=s.purchase,c=s.closed===!0,!s.command)return;let m=s.command;i=m.operation==="close"?null:m,p=m.operation==="close"?m:s.closeCommand?.operation==="close"?s.closeCommand:null,p&&(c=!0);for(let x of[i,p])x&&a.add(x.requestId)}):Promise.resolve();y.catch(()=>{});async function I(s){e&&await y;let m=t.generation;if(e){if(!t.view||!t.scope)throw new f("COMMAND_STORAGE_INVALID","Read the original scoped Run before persisting a mutation");await e.retain({schemaVersion:1,scope:t.scope,runId:t.view.id,funnelId:t.view.source.id,versionId:t.view.source.versionId,command:M(s),...r?{processBindingIds:{[s.requestId]:r.binding(s.requestId)}}:{}})}if(m!==t.generation||i!==s&&p!==s)throw new f("IDENTITY_CHANGED","Run changed before command dispatch");let x=a.has(s.requestId);a.add(s.requestId);try{return await u(s)}catch(C){let R=s.operation==="submit"&&s.input.type==="paywall_quote",_=!x&&!Wn(C),V=!1;if(R&&_&&m===t.generation&&i===s&&C instanceof f&&C.status!==void 0){let l=await T(s.requestId).catch(()=>{});V=l?.settlement?.state==="unknown"&&l.settlement.operationId===null}throw m===t.generation&&(i===s||p===s)&&_&&(!R||!(C instanceof f)||C.status===void 0||V)&&(e&&await e.settle(s.requestId),m===t.generation&&O(s)),C}}function h(s){let m=U.parse(s);if(m.operation==="start"||m.operation==="get"||m.operation==="review")throw new f("INVALID_REQUEST","Mutation required");if(c&&m.operation!=="close"){if(i?.requestId===m.requestId)return T(m.requestId);throw new f("COMMAND_PENDING","Close preserves the original recovery record; settle it by identity")}if(m.operation==="close"){if(i?.requestId===m.requestId)throw new f("INVALID_REQUEST","Close requires its own request identity");if(c=!0,p&&JSON.stringify(M(p))!==JSON.stringify(M(m)))throw new f("COMMAND_PENDING","Retry the original Close");return p??=m,d.close?d.close:b(p,"close")}if(i){if(JSON.stringify(M(i))!==JSON.stringify(M(m)))throw new f("COMMAND_PENDING","Retry the original command before sending another");if(d.command)return d.command}else i=m;return b(i,"command")}function b(s,m){let x=I(s);d[m]=x;let C=()=>{d[m]===x&&(d[m]=null)};return x.then(C,C),x}function T(s){return u({operation:"get",settlementRequestId:s})}function O(s){return!s||i!==s&&p!==s?!1:(i===s&&(i=null),p===s&&(p=null),a.delete(s.requestId),!i&&!p&&(g=null),!0)}return{ready:y,get pending(){return i},get closing(){return p},get closeRequested(){return c},get inFlight(){return d.command},get closeFlight(){return d.close},get purchase(){return o},assertBinding(s){if(g&&(s.run.id!==g.runId||s.run.source.id!==g.funnelId||s.run.source.versionId!==g.versionId))throw new f("SCOPE_MISMATCH","Stored command belongs to another Run or Version")},async observe(s,m,x,C){let R=s.operation==="get"?s.settlementRequestId:"requestId"in s&&s.operation!=="start"?s.requestId:void 0,_=R&&m.settlement?.state==="settled"&&m.run.pendingRequest?.requestId!==R&&(s.operation==="get"||!c||s.operation==="close"||!["running","waiting"].includes(m.run.status))?R:void 0,V=i?.requestId===_?i:p?.requestId===_?p:void 0;e?.bind({scope:m.scope,runId:m.run.id,funnelId:m.run.source.id,versionId:m.run.source.versionId});let l=m.run.paywall,v=l??m.purchase,P=v?.operation,E=m.settlement&&(!l||l.purchaseRequestId===m.settlement.requestId)&&(!o||o.operationId===m.settlement.operationId)?m.settlement:void 0,S=P?.operationId??v?.quote?.operationId??E?.operationId,F=v?.receiptId??E?.receiptId,w=l?.selectionGeneration??o?.generation??0;if(e&&S&&F&&s.operation!=="review"&&(!t.view||m.run.revision>=t.view.revision)&&(C===void 0||C>=t.readSequence)&&(!o||w>=o.generation)){let N={receiptId:F,operationId:S,generation:w},k=an(P,v?.canReselect===!0);await e.observePurchase({scope:m.scope,runId:m.run.id,funnelId:m.run.source.id,versionId:m.run.source.versionId},N,k,_),t.assertCurrent(x),(!o||N.generation>=o.generation)&&(C===void 0||C>=t.readSequence)&&(k?o?.operationId===N.operationId&&(o=void 0):o=N)}else e&&_&&await e.settle(_);return t.assertCurrent(x),_?O(V):!1},stop(){c=!0},submit:h,settle:T,reset(){c=!0,i=null,p=null,o=void 0,g=null,d.close=null,a.clear(),d.command=null}}}function Xn(e){e={...e};let t=e.initialResponse;delete e.initialResponse;let u=e.funnelExecutionPolicy&&structuredClone(e.funnelExecutionPolicy);if(!e.customerRun&&(typeof e.runToken!="string"||!/^gg_fr_[A-Za-z0-9_-]{43}$/.test(e.runToken)))throw new f("INVALID_TOKEN","Run credential required");if(e.customerRun&&(!e.session||!e.scope||!e.funnelId||!e.funnelCommandStorage||e.serverKey))throw new f("INVALID_REQUEST","Customer recovery requires its scoped session and durable journal");if(e.serverKey&&(typeof window<"u"||!Ee.test(e.serverKey)))throw new f("SERVER_ONLY","Run Server-Key proof belongs to the merchant backend");if(e.serverKey&&e.session)throw new f("INVALID_REQUEST","Choose Customer session or Server-Key proof for this Run");let r=ne({...e,session:void 0,timeoutMs:e.timeoutMs??35e3}),i=Rn(e.funnelId,e.scope??e.configuration?.scope),p=e.session?.subscribeIdentity(b),c=null,d=e.funnelCommandStorage??(!e.customerRun&&typeof window<"u"&&window.isSecureContext?un(e):void 0),a=d&&xn(d),o=Fn({journal:a,state:i,call:T,processIdentity:e.process}),g=0,y=new Map;function I(){g++,y.clear(),t=void 0}async function h(l){let v=l.operation==="resume"?o.pending?.operation==="resume"?null:o.pending:l;if(u&&l.operation==="resume"&&!v&&l.requestId!==e.customerRun?.startRequestId)throw new f("EXECUTION_POLICY_REFUSED","The original command is required to verify execution permission before resuming");if(v?.operation==="submit"&&v.input.type==="paywall_confirm"){let N=i.view?.paywall;Sn(u,N?.quote?.operationId===v.input.operationId?N.quote:void 0)}if(e.process)return e.process.request(l);let P=i.generation;i.assertCurrent(P);let E=performance.now()+(e.timeoutMs??35e3),S=i.customerToken??("customerToken"in l?l.customerToken:void 0);if(e.session){let N=i.signal,k,K=()=>{},En=new Promise((et,Ce)=>{K=()=>Ce(N.reason),N.addEventListener("abort",K,{once:!0}),k=setTimeout(()=>Ce(new f("TIMEOUT","The request timed out")),Math.max(1,E-performance.now()))});try{S=await Promise.race([Promise.resolve().then(()=>(i.assertCurrent(P),e.session.access())),En])}finally{clearTimeout(k),N.removeEventListener("abort",K)}}i.assertCurrent(P);let F={...l,...S?{customerToken:S}:{}},w=l.operation==="page_experiments"?ye.parse(F):U.parse(F);if(e.customerRun){if(e.session?.snapshot()?.customerId!==e.customerRun.customerId||!S)throw new f("IDENTITY_CHANGED","Original recovery Customer changed");let N={...w};return"customerToken"in N&&delete N.customerToken,r.requestWithCredential("funnels",{operation:"run_command",runId:e.customerRun.runId,funnelId:e.funnelId,command:N},S,{timeoutMs:Math.max(1,E-performance.now())})}return r.requestWithCredential("funnels",w,e.runToken,{headers:e.serverKey&&!S?{[cn]:e.serverKey}:void 0,timeoutMs:Math.max(1,E-performance.now())})}function b(){I(),p?.(),i.reset(),o.reset(),c=null,r.dispose()}async function T(l,v){let P=t;t=void 0;let E=i.generation,S=()=>i.assertCurrent(E);a&&await o.ready,S();let F=i.view,w=hn(e,P!==void 0&&l.operation==="get"&&!l.data&&!l.purchase&&!l.settlementRequestId?P:await h(l));if(l.operation==="review"&&!w.review)throw new f("INVALID_RESPONSE","Historical projection is missing");if(e.customerRun&&w.run.id!==e.customerRun.runId)throw new f("INVALID_RESPONSE","Original recovery Run changed");if(l.operation==="get"&&l.purchase&&w.purchase&&(w.purchase.receiptId!==l.purchase.receiptId||(w.purchase.operation?.operationId??w.purchase.quote?.operationId)!==l.purchase.operationId))throw new f("INVALID_RESPONSE","The requested original purchase changed");if(S(),w.runToken&&w.runToken!==e.runToken)throw new f("INVALID_RESPONSE","Run credential changed");let N=l.operation==="get"?l.settlementRequestId:"requestId"in l&&l.operation!=="start"?l.requestId:void 0;if(N&&w.settlement?.requestId!==N)throw new f("INVALID_RESPONSE","Exact command settlement is missing or belongs to another command");o.assertBinding(w),i.assertRun(w.run),i.bindScope(w.scope);let k=await o.observe(l,w,E,v);return(!i.view||w.run.revision>=i.view.revision)&&(v===void 0||v>=i.readSequence)&&(await e.onAcceptedResponse?.(w),S()),!w.run.stopped&&["running","waiting"].includes(w.run.status)&&l.operation==="get"&&l.settlementRequestId||(S(),["running","waiting"].includes(w.run.status)||o.stop(),i.publish(l,w,F,v,k)),w}function O(l){let v=i.generation;I();let P=l(),E=()=>{i.generation===v&&I()};return P.then(E,E),P}let s=l=>O(()=>o.submit(l)),m=null,x=new WeakMap;function C(l){let v=x.get(l);if(v)return v;let P=_(l);return x.set(l,P),P}let R=!1;async function _(l){let v=await l;if(v.run.instruction?.type!=="evaluate_segment")return v;if(m)return m;R=!0;let P=i.generation,E=(async()=>{for(let S=0;S<32&&v.run.instruction?.type==="evaluate_segment";S++){if(o.pending||o.closeRequested)return v;let F=v.run;if(v.run.instruction?.type==="evaluate_segment"){let{advance:N}=await Fe(e.configuration,F,{predict:!1});if(P!==i.generation)throw new f("IDENTITY_CHANGED","Run identity changed during segment calculation");if(o.pending||o.closeRequested)return v;if(i.view&&(i.view.revision!==F.revision||i.view.visit!==F.visit||i.view.nodeId!==F.nodeId))return T({operation:"get"});let k=!0;Fe(e.configuration,F).then(({prediction:K})=>{k&&P===i.generation&&!o.closeRequested&&i.view?.id===F.id&&!i.view.stopped&&i.view.nodeId===F.nodeId&&i.view.visit===F.visit&&i.view.revision===F.revision&&(c=K)}).catch(()=>{});try{v=await s({operation:"commit_segment",requestId:dn(F.id,F.visit,`segment:${F.revision}`),nodeId:F.nodeId,visit:F.visit,revision:F.revision,...N})}finally{k=!1,c=null}}}return v})();m=E;try{return await E}finally{m===E&&(m=null)}}let V={get configuration(){return R?e.configuration:void 0},get configurationReady(){return!0},get view(){let l=i.currentView;return l?structuredClone(l):null},get viewAgeMs(){return i.viewAgeMs},get pendingCommand(){let l=o.closing??o.pending;return l?structuredClone(M(l)):null},get pendingCommands(){return[o.pending,o.closing].filter(l=>l!==null).map(l=>structuredClone(M(l)))},get pendingPurchase(){return o.purchase?structuredClone(o.purchase):null},get hasDurableJournal(){return a!==void 0},get prediction(){let l=i.view;return c&&l&&!l.stopped&&["running","waiting"].includes(l.status)&&l.id===c.runId&&l.nodeId===c.from.nodeId&&l.visit===c.from.visit&&l.revision===c.from.revision&&!o.closeRequested?structuredClone(c):null},settle:(...l)=>O(()=>o.settle(...l)),get webViewUrl(){return"bundled"},resolvePaywall(l){return on(e,l)},async pageExperiments(l,v=[]){let P=i.generation;i.assertCurrent(P);let E=i.view?.id;if(!E)throw new f("INVALID_REQUEST","Read the Run before its page experiments");let S=mn.parse(await h(ye.parse({operation:"page_experiments",release:l,usedReceiptIds:v})));if(i.assertCurrent(P),S.runId!==E||S.scope.projectId!==i.scope?.projectId||S.scope.environment!==i.scope?.environment)throw new f("SCOPE_MISMATCH","Page experiment Run changed");return S},review(l){return T({operation:"review",...l?{receiptId:l}:{}},i.nextRead())},async get(l,v){let P=i.generation;l=l&&structuredClone(l),v=v&&{...v},a&&await o.ready,i.assertCurrent(P),v??=o.purchase&&{receiptId:o.purchase.receiptId,operationId:o.purchase.operationId};let E=JSON.stringify([i.generation,g,l??null,v??null]),S=y.get(E);if(S)return S.then(k=>structuredClone(k));let F=i.nextRead(),w=C(T({operation:"get",...l?{data:l}:{},...v?{purchase:v}:{}},F));y.set(E,w);let N=()=>{y.get(E)===w&&y.delete(E)};return w.then(N,N),w.then(k=>structuredClone(k))},resume(l=i.view?.pendingRequest?.requestId){return l?o.closeRequested?V.settle(l):o.pending?.requestId===l?C(s(o.pending)):C(s({operation:"resume",requestId:l})):Promise.reject(new f("INVALID_REQUEST","No interrupted command is available"))},submit(l){return C(s(l))},async retry(){if(o.closeFlight)return o.closeFlight;if(o.closing)return s(o.closing);if(o.closeRequested&&o.pending)return V.settle(o.pending.requestId);if(o.inFlight)return C(o.inFlight);if(!o.pending)throw new f("INVALID_REQUEST","No command is pending");let l=o.pending;if(l.operation==="submit"&&l.input.type==="paywall_quote"){let v=i.generation;if(await V.settle(l.requestId),i.assertCurrent(v),!o.pending)return V.get();if(o.pending!==l||o.closeRequested)throw new f("COMMAND_PENDING","The original quote is being recovered")}return C(s(l))},identify(l){let v=i.customerToken?void 0:t;I(),i.identify(l),t=v,c=null,r.reset()},get identitySignal(){return i.signal},subscribe:i.subscribe,reset:b};return V}function vo(e,t){return Xn({...e,runToken:"",initialResponse:t})}export{dn as a,sn as b,Nn as c,me as d,Tn as e,ln as f,Dn as g,Gt as h,Ut as i,Bt as j,ye as k,mn as l,te as m,qn as n,er as o,hr as p,wr as q,hn as r,Se as s,Cr as t,Zn as u,bn as v,Z as w,un as x,Cn as y,jr as z,ie as A,Ee as B,$r as C,Hr as D,Sn as E,Xn as F,vo as G};
@@ -1 +0,0 @@
1
- import{p as n,s as t}from"./chunk-N774V4SQ.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +0,0 @@
1
- import{b as Re}from"./chunk-LZBJHWVH.js";import{a as G}from"./chunk-PFPMK4IO.js";import{A as _e,E as W,G as ke,d as Pe,f as x,k as Se,v as Ee,w as be,y as Oe}from"./chunk-N774V4SQ.js";import{a as we,b as ge,c as ye}from"./chunk-ZORZA4WG.js";import{aa as U}from"./chunk-IYHXEKAD.js";import{a as X}from"./chunk-3NCMYTNG.js";import{g as Z}from"./chunk-VYI6QRJW.js";import{b as ve}from"./chunk-HFD4CLCJ.js";import{b as $}from"./chunk-YURGISSB.js";import{a as l}from"./chunk-TPXRO63H.js";import{b as Ce}from"./chunk-JBVZ6A6V.js";import{b as n}from"./chunk-NOOIJXRN.js";import{a as ue}from"./chunk-DSPLGTQI.js";var g=U.options,Ve=n.discriminatedUnion("operation",[g[1].omit({customerToken:!0}),g[2].omit({customerToken:!0}),g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0}),g[8].omit({customerToken:!0}),Se.omit({customerToken:!0})]),ce=n.strictObject({receiptId:n.uuid(),operationId:n.uuid()}),We=n.discriminatedUnion("operation",[n.strictObject({operation:n.literal("find_purchase")}),n.strictObject({operation:n.literal("recover_start"),intent:n.enum(["lookup","resume"]),start:n.strictObject({requestId:g[0].shape.requestId,funnelId:g[0].shape.funnelId,locale:g[0].shape.locale,parameters:g[0].shape.parameters})}),n.strictObject({operation:n.literal("recover_run"),runId:n.uuid(),funnelId:n.uuid()}),n.strictObject({operation:n.literal("recover_purchase"),runId:n.uuid(),funnelId:n.uuid(),purchase:ce}),n.strictObject({operation:n.literal("terminate_checkout"),runId:n.uuid(),funnelId:n.uuid(),purchase:ce}),n.strictObject({operation:n.literal("settle_command"),runId:n.uuid(),funnelId:n.uuid(),requestId:n.uuid(),command:n.discriminatedUnion("operation",[g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0})]).optional()}).refine(a=>!a.command||a.requestId===a.command.requestId),n.strictObject({operation:n.literal("run_command"),runId:n.uuid(),funnelId:n.uuid(),command:Ve})]),ee=n.strictObject({runId:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),startRequestId:n.uuid(),runExpiresAt:n.iso.datetime({offset:!0}),status:x.shape.run.shape.status}),N={scope:$,customerId:n.uuid()},Fe=n.discriminatedUnion("outcome",[n.strictObject({...N,outcome:n.literal("unknown"),target:n.null(),view:n.null(),access:n.null()}),n.strictObject({...N,outcome:n.literal("resolved"),target:ee,view:x.shape.run.nullable(),access:n.discriminatedUnion("type",[n.strictObject({type:n.literal("customer")}),n.strictObject({type:n.literal("operation_only"),cause:n.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((a,d)=>{a.outcome==="resolved"&&(a.access.type==="customer"!=(a.view!==null)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),qe=n.strictObject({...N,target:ee,view:x.shape.run.nullable(),settlement:n.strictObject({requestId:n.uuid(),state:n.enum(["pending","unknown","settled"]),acceptance:n.enum(["accepted","not_accepted","unknown"]),receiptPhase:n.enum(["accepted","processing","done"]).nullable(),basis:n.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:n.uuid().nullable(),operationId:n.uuid().nullable()}),purchase:x.shape.purchase.unwrap().nullable()}).superRefine((a,d)=>{let p=a.settlement;(p.acceptance==="accepted"!=(p.receiptPhase!==null)||p.acceptance==="accepted"&&p.basis!=="receipt"||p.acceptance==="unknown"&&(p.state!=="unknown"||p.basis!=="none")||p.acceptance!=="accepted"&&(p.operationId!==null||p.receiptId!==null)||p.acceptance==="not_accepted"&&(p.state!=="settled"||!["run_terminal","position_advanced"].includes(p.basis))||a.purchase&&(a.purchase.receiptId!==p.receiptId||a.purchase.operation&&a.purchase.operation.operationId!==p.operationId||a.purchase.quote&&a.purchase.quote.operationId!==p.operationId)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),Ae=n.strictObject({...N,target:ee,purchase:x.shape.purchase.unwrap()}).superRefine((a,d)=>{(!a.purchase.operation||typeof a.purchase.canReselect!="boolean"||a.purchase.quote&&a.purchase.quote.operationId!==a.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})}),Ne=n.discriminatedUnion("outcome",[n.strictObject({...N,outcome:n.literal("none")}),n.strictObject({...N,outcome:n.literal("blocked")}),n.strictObject({...N,outcome:n.literal("found"),target:ee,start:n.strictObject({locale:g[0].shape.locale,parameters:g[0].shape.parameters}),purchase:ce})]);var Ge=U.options[0].refine(a=>!a.customer&&!a.customerData),Me=n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),terminal:n.enum(["complete","native"]).nullable()}),je=n.strictObject({schemaVersion:n.literal(1),baseUrl:n.url(),scope:$,customerId:n.uuid(),sessionId:n.uuid(),start:Ge,allowed:n.array(n.enum(["merchant","record_only","indiana","native"])),run:n.strictObject({id:n.uuid(),versionId:n.uuid(),status:Pe.shape.status,revision:n.number().int().nonnegative(),runExpiresAt:n.iso.datetime({offset:!0}).optional()}).optional(),purchases:n.array(Me).max(100),operationCommand:n.strictObject({operationId:n.uuid(),intent:n.literal("confirm")}).optional(),journal:n.strictObject({revision:n.number().int().nonnegative(),entry:Ee.nullable()})});function Te(a){return Oe({...a,namespace:"purchases",identity:[a.scope.projectId,a.scope.environment,a.customerId]})}function Ue(a){let d=new URL(a.baseUrl??Ce).href,p=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function S(){a.assertCurrent();try{let C=await a.storage.read();if(a.assertCurrent(),!Number.isSafeInteger(C.revision)||C.revision<0)throw p();let u=C.entry===null?null:je.parse(C.entry);if(u&&(u.baseUrl!==d||u.customerId!==a.customerId||u.scope.projectId!==a.scope.projectId||u.scope.environment!==a.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(u?.journal.entry&&(u.journal.entry.scope.projectId!==u.scope.projectId||u.journal.entry.scope.environment!==u.scope.environment||u.journal.entry.funnelId!==u.start.funnelId||u.journal.entry.runId!==u.run?.id||u.journal.entry.versionId!==u.run?.versionId)||u?.operationCommand&&!u.purchases.some(E=>E.operationId===u.operationCommand?.operationId))throw p();return{revision:C.revision,entry:u}}catch(C){throw C instanceof l?C:p()}}async function M(C){for(let u=0;u<8;u++){let E=await S(),O=C(structuredClone(E.entry));if(JSON.stringify(O)===JSON.stringify(E.entry))return O;O&&je.parse(O),a.assertCurrent();let R;try{R=await a.storage.write(E.revision,O)}catch{throw p()}if(a.assertCurrent(),R!==null){if(!Number.isSafeInteger(R)||R<=E.revision)throw p();return O}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:S,update:M,baseUrl:d}}var ze=5*6e4;function Be(a,d){let p=a.purchases.find(S=>S.type==="checkout");if(!a.actions.includes("continue_checkout")||p?.type!=="checkout"||d!==void 0&&p.operationId!==d)throw new l("PURCHASE_PENDING","No single resumable Checkout is confirmed");return p.checkoutUrl}function Ct(a){let d={...a,scope:{...a.scope},executionPolicy:structuredClone(a.executionPolicy)},p=d.session.snapshot();if(!p)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:S,sessionId:M}=p,C=!1,u=null,E,O=null,R=!1,q,z,B,k={mode:"idle",status:"idle",actions:["start"],purchases:[]},y=new Map,j=new Map,le=new AbortController,Q=new Set,D=ve(d),de=Re(D.request);function H(e){return{code:e instanceof l?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof l&&e.status!==void 0?{status:e.status}:{}}}function w(){if(C||d.session.snapshot()?.customerId!==S)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let f=Ue({...d,customerId:S,assertCurrent:w,storage:d.storage??Te({baseUrl:d.baseUrl,scope:d.scope,customerId:S})}),xe=d.session.subscribeIdentity(pe);function pe(){C||(C=!0,clearTimeout(B),le.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),xe(),u?.reset(),u=null,O=null,D.dispose(),Q.clear(),y.clear(),j.clear())}function P(e){w();let t=JSON.stringify(e)!==JSON.stringify(k);k=e,clearTimeout(B),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(B=setTimeout(()=>{T().catch(()=>{})},5e3)),t&&ue(d.onRecovery,structuredClone(e));for(let r of t?Q:[]){if(C)break;ue(r,structuredClone(e))}return structuredClone(e)}function I(e){if(w(),!e||e.start.requestId!==E)throw new l("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function b(e){let t=[...e.purchases],r=e.journal.entry?.purchase;return r&&!t.some(o=>o.operationId===r.operationId)&&t.push({receiptId:r.receiptId,operationId:r.operationId,terminal:null}),t}function A(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&b(e).every(t=>t.terminal!==null)}function _(e,t){let r=e.journal.entry?.command??e.journal.entry?.closeCommand,o=b(e).map(v=>{let se=y.get(v.operationId);return v.terminal&&!se?{type:v.terminal,operationId:v.operationId}:X({quote:se?.quote??null,operation:se??null,requestId:r?.requestId??null,pending:!1,destroyed:!1,canReselect:j.get(v.operationId)===!0})}),c=o.filter(v=>!["complete","native"].includes(v.type)),i=c[0],s=c.length===1&&i?.operationId?y.get(i.operationId):void 0;if(s&&(i?.type==="checkout"||i?.type==="cancel"))try{W({allowed:e.allowed.filter(v=>d.executionPolicy.allowed.includes(v))},s.quote)}catch(v){return{mode:t,status:"blocked",actions:["refresh",...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:o,error:H(v)}}let m;if(t==="operation"&&!r&&i?.type==="cancel"&&s?.quote&&!s.problem&&!s.confirmedAt)try{W({allowed:e.allowed.filter(v=>d.executionPolicy.allowed.includes(v))},s.quote),Date.parse(s.quote.expiresAt)>Date.now()&&(m={operationId:s.operationId,quote:s.quote})}catch{}let h=o.length>0&&c.length===0,V=A(e)||t==="operation"&&h&&!r&&!e.operationCommand?"complete":i?.type==="checkout"?"checkout":i?.type==="fulfillment"?"fulfillment":i?.type==="recording"?"recording":r||e.operationCommand||i&&i.type!=="cancel"||t==="operation"&&!m?"waiting_result":"ready";return{mode:t,status:V,purchases:o,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...A(e)?["start"]:[],...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...c.length===1&&i?.type==="checkout"?["continue_checkout"]:[]]}}function te(e){let t=X({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&j.get(e.operationId)===!0});return t.type==="complete"||t.type==="native"?t.type:null}function ne(e){if(!e.operation)return;let t={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(t.merchantExecution&&t.merchantExecution.customerId!==S)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let r=Z(y.get(t.operationId)??null,t);y.set(t.operationId,r),r===t&&j.set(t.operationId,e.canReselect===!0)}async function De(e){w();for(let r of[e.purchase,e.run.paywall])r&&ne(r);let t=await f.update(r=>{if(I(r),r.run&&(r.run.id!==e.run.id||r.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let o=b(r);for(let c of[e.purchase,e.run.paywall]){let i=c?.operation?.operationId??c?.quote?.operationId;if(!c||!i)continue;let s=o.find(h=>h.operationId===i);if(s&&s.receiptId!==c.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=te(y.get(i));s?s.terminal??=m:o.push({receiptId:c.receiptId,operationId:i,terminal:m})}return{...r,purchases:o,run:r.run&&(r.run.revision>e.run.revision||!["running","waiting"].includes(r.run.status)&&["running","waiting"].includes(e.run.status))?r.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});I(t),t.run&&!["running","waiting"].includes(t.run.status)&&b(t).some(r=>!r.terminal)&&(t=await L(t,!t.journal.entry?.command&&!t.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(r=>!!r)))),I(t),P(_(t,"run"))}function He(){return{async read(){let{entry:e}=await f.read();return I(e),structuredClone(e.journal)},async write(e,t){let r=null;return await f.update(o=>{if(I(o),o.operationCommand&&t?.command&&t.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return r=null,o.journal.revision!==e?o:(r=e+1,{...o,journal:{revision:r,entry:t}})}),r}}}async function L(e,t=!1,r=new Set){I(e);let o=b(e);for(let i of o){if(i.terminal)continue;let s=r.has(i.operationId)?y.get(i.operationId):void 0;if(s??=await oe(e,i),w(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(s.merchantExecution&&s.merchantExecution.customerId!==S)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(t&&!e.operationCommand&&X({quote:s.quote??null,operation:s,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:s}=await de.attach({operationId:i.operationId,intent:"cancel"}),w(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");s=await oe(e,i)}y.set(i.operationId,Z(y.get(i.operationId)??null,s))}let c=await f.update(i=>{I(i);let s=i.operationCommand&&y.get(i.operationCommand.operationId);return{...i,...s&&(s.confirmedAt||s.merchantExecution||s.status!=="pending")?{operationCommand:void 0}:{},purchases:b(i).map(m=>({...m,terminal:m.terminal??te(y.get(m.operationId))}))}});return I(c),c}async function Y(e){w();let t=await D.request("funnels",e);return w(),t}async function Le(){let e=G(Ne,await Y({operation:"find_purchase"}));if(e.customerId!==S||e.scope.projectId!==d.scope.projectId||e.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(e.outcome!=="found")return e.outcome;let{target:t,purchase:r}=e;return await f.update(o=>o&&!A(o)?o:{schemaVersion:1,baseUrl:f.baseUrl,scope:d.scope,customerId:S,sessionId:M,start:{operation:"start",requestId:t.startRequestId,funnelId:t.funnelId,...e.start},allowed:[...d.executionPolicy.allowed],run:{id:t.runId,versionId:t.versionId,status:t.status,revision:0,runExpiresAt:t.runExpiresAt},purchases:[{...r,terminal:null}],journal:{revision:0,entry:null}}),"found"}let J;function re(e){let t=J;if(t&&(!t.outcome||e&&t.outcome==="none"&&Date.now()-t.at<ze))return t.job;let r={at:Date.now(),job:Le().then(o=>(r.outcome=o,r.at=Date.now(),o),o=>{throw J===r&&(J=void 0),o})};return J=r,r.job}async function oe(e,t,r="recover_purchase"){let o=G(Ae,await Y({operation:r,runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:t.receiptId,operationId:t.operationId}}));if(ae(e,o),o.purchase.receiptId!==t.receiptId||o.purchase.operation?.operationId!==t.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return ne(o.purchase),y.get(t.operationId)}async function me(e){for(let t of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!t)continue;let r=G(qe,await Y({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:t.requestId,...t.operation==="resume"?{}:{command:t}}));if(ae(e,r),r.settlement.requestId!==t.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");r.purchase&&ne(r.purchase);let o=await f.update(c=>{I(c);let i=b(c),{receiptId:s,operationId:m}=r.settlement;if(s&&m){let V=i.find(v=>v.operationId===m);if(V&&V.receiptId!==s)throw new l("INVALID_RESPONSE","Original Receipt changed");V||i.push({receiptId:s,operationId:m,terminal:te(y.get(m))})}let h=r.settlement.state==="settled"?be(c.journal.entry,t.requestId):c.journal.entry;return{...c,purchases:i,journal:h===c.journal.entry?c.journal:{revision:c.journal.revision+1,entry:h}}});I(o),e=o}return e}function ae(e,t){if(t.customerId!==S||t.scope.projectId!==d.scope.projectId||t.scope.environment!==d.scope.environment||t.target.funnelId!==e.start.funnelId||t.target.startRequestId!==e.start.requestId||e.run&&(t.target.runId!==e.run.id||t.target.versionId!==e.run.versionId))throw new l("SCOPE_MISMATCH","The original recovery binding changed")}async function ie(e,t){if(I(e),e.run&&(e=await me(e)),!b(e).length&&A(e))return P(_(e,"operation"));if(!b(e).length)return P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:H(t)});R=!0;let r=await L(e);return P(_(r,"operation"))}async function K(e,t=!1,r=!0){if(E=e.start.requestId,O=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!u){let o=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:t?"resume":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},c;try{c=await Y(o)}catch(h){if(!e.run&&h instanceof l&&(h.status===void 0||h.status>=500))return P({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:k.purchases,error:H(h)});throw h}let i=G(Fe,c);if(i.customerId!==S||i.scope.projectId!==d.scope.projectId||i.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(i.outcome==="unknown")return P({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:k.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});ae(e,i);let s=await f.update(h=>(I(h),{...h,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??h.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(I(s),e=s,i.access.type==="operation_only")return ie(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await me(e);let m=i.view;if(m.locale!==e.start.locale||!_e(m.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");u=ke({...d,customerRun:{runId:i.target.runId,customerId:S,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},funnelCommandStorage:He(),onAcceptedResponse:De},{scope:i.scope,run:m})}try{await u.get(),u.view?.pendingRequest?.requestId===e.start.requestId&&!u.pendingCommands?.length&&await u.resume(u.view.pendingRequest.requestId);for(let c of u.pendingCommands??[])c.operation!=="close"&&await u.settle?.(c.requestId);u.pendingCommands?.length&&await u.retry(),w();let o=(await f.read()).entry;return I(o),P(_(o,"run"))}catch(o){if(w(),r&&o instanceof l&&(o.status===401||o.status===409&&o.reason==="STATE_CHANGED")){u.reset(),u=null;let c=(await f.read()).entry;return I(c),K(c,!1,!1)}throw o}}function F(e,t="read",r){if(w(),q)return t==="read"||t===z?q:q.then(()=>F(e,t,r),()=>F(e,t,r));clearTimeout(B);let o=e().catch(c=>{throw!C&&!r?.(c)&&P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:k.purchases,error:H(c)}),c});return q=o,z=t,o.then(()=>{q===o&&(q=void 0,z=void 0)},()=>{q===o&&(q=void 0,z=void 0)}),o}function T(){return F(async()=>{let{entry:e}=await f.read();if(!e||A(e)){if(await re(!1)==="blocked")return fe();({entry:e}=await f.read())}return e?(E&&e.start.requestId!==E&&(u?.reset(),u=null,y.clear(),j.clear(),R=!1),R&&E===e.start.requestId?ie(e,k.error):K(e)):P({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}function fe(){return P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:H(new l("PURCHASE_PENDING","Check the outstanding purchases before starting another"))})}async function he(){let e=await T();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:F(async()=>{let t=(await f.read()).entry;if(I(t),!R){if(!u?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let s=u.view.paywall.operation;if(s?.confirmedAt||s?.merchantExecution||s&&s.status!=="pending")return P(_(t,"run"));if(u.pendingCommands?.length)await u.retry();else{let h=u.view;await u.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:h.nodeId,visit:h.visit,revision:h.revision,input:{type:"paywall_confirm",operationId:h.paywall.quote.operationId}})}let m=(await f.read()).entry;return I(m),P(_(m,"run"))}let r=t.operationCommand?.operationId??k.confirmation?.operationId,o=r&&y.get(r);if(!r||!o||t.journal.entry?.command||t.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");W({allowed:t.allowed.filter(s=>d.executionPolicy.allowed.includes(s))},o.quote),await f.update(s=>{if(I(s),s.journal.entry?.command||s.journal.entry?.closeCommand||s.operationCommand&&s.operationCommand.operationId!==r)throw new l("PURCHASE_PENDING","Another original command is pending");return{...s,operationCommand:{operationId:r,intent:"confirm"}}});let c=await de.attach({operationId:r,intent:"confirm"});if(w(),c.operation.operationId!==r)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");y.set(r,Z(o,c.operation));let i=(await f.read()).entry;return I(i),P(_(await L(i,!1,new Set([r])),"operation"))},"confirm")}async function Ie(){w();let{entry:e}=await f.read();return e?A(e)?"finished":"pending":"none"}return{get controller(){return u},get recovery(){return structuredClone(k)},get attempt(){return w(),structuredClone(O)},get identitySignal(){return le.signal},retained:Ie,async findPurchase(){let e=await Ie();if(e==="pending")return e;let t=await re(!0);return w(),t==="none"?e:t},async readPaywall(e){w();let t=we(e),[r,{readPaywallContent:o},{validateResourceCheck:c}]=await Promise.all([ge(D.request,"resolvePaywall"),import("./paywall-content-ZQBE2EZP.js"),import("./check-response-MNFEOKKE.js")]);w();let i=r.request.parse({selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale}),s=await ye(D.request,r,i);c(i,s.paywall.check,s.scope);let m=await o(d,s.paywall);if(w(),t.paywallVersionId?m.id!==t.paywallVersionId:m.paywallId!==t.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");return m},start(e){let t=U.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(t.operation!=="start"||t.customer||t.customerData)throw new l("INVALID_REQUEST","A Customer-owned Funnel start is required");return F(async()=>{let r=(await f.read()).entry;if((!r||A(r))&&await re(!0)==="blocked")return fe();let o=await f.update(c=>{if(c&&!A(c)){if(c.start.funnelId!==t.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return c}return{schemaVersion:1,baseUrl:f.baseUrl,scope:d.scope,customerId:S,sessionId:M,start:t,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!o)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return E!==o.start.requestId&&(u?.reset(),u=null,y.clear(),j.clear(),R=!1),R?ie(o,k.error):K(o,!0)},`start:${t.funnelId}`)},refresh:T,confirm:he,retry:()=>R?he():F(async()=>{let{entry:e}=await f.read();return e?K(e,!0):P({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return u?.view?F(async()=>{if(!u?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(u.pendingCommands?.find(r=>r.operation==="close"))await u.retry();else if(["running","waiting"].includes(u.view.status)){let r=u.view;await u.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:r.nodeId,visit:r.visit,revision:r.revision})}let t=(await f.read()).entry;return I(t),P(_(t,"run"))},"close"):T()},async continueCheckout(e,t){let r=t?await F(async()=>{let{entry:o}=await f.read();if(I(o),!o.run||!b(o).some(i=>i.operationId===t&&!i.terminal))throw new l("PURCHASE_PENDING","The original Checkout changed");let c=await L(o);return P(_(c,R?"operation":"run"))},`continue:${t}`,o=>o instanceof l&&o.code==="PURCHASE_PENDING"):await T();w(),await e(Be(r,t))},async terminateCheckout(e){let t=await T();if(!t.purchases.find(o=>o.type==="checkout"&&o.operationId===e)||!t.actions.includes("continue_checkout"))throw new l("PURCHASE_PENDING","The original Checkout has changed");return F(async()=>{let{entry:o}=await f.read();I(o);let c=b(o).find(s=>s.operationId===e&&!s.terminal);if(!c||!o.run)throw new l("PURCHASE_PENDING","The original Checkout has changed");await oe(o,c,"terminate_checkout");let i=await L(o,!1,new Set([e]));return P(_(i,R?"operation":"run"))},`terminate:${e}`,o=>o instanceof l&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(o.code))},subscribe(e){return Q.add(e),()=>{Q.delete(e)}},destroy:pe}}export{Te as a,Be as b,Ct as c};
@@ -1 +0,0 @@
1
- import{c as ee,d as ne}from"./chunk-VYI6QRJW.js";import{a as Z}from"./chunk-TPXRO63H.js";import{a as b}from"./chunk-DSPLGTQI.js";var ue=5*6e4,pe=15e3,re=new WeakMap;function me(t){return re.get(t)}var E=t=>Array.isArray(t)?t.map(E):t&&typeof t=="object"?Object.fromEntries(Object.keys(t).sort().map(n=>[n,E(t[n])])):t,ae=(t,n)=>JSON.stringify(E(t))===JSON.stringify(E(n)),te=t=>JSON.stringify(E([t.funnelId,t.locale??null,t.parameters??{}])),fe=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","confirmOnHostedCheckout","resolveOfferId","onOpenUrl","onEvent","onAction","onComplete","onError"];function he(t,n){let V=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),y,j="",T=n.start instanceof Promise?void 0:V(n.start),O=e=>e?.parameters?.commerce,_=n.maxAgeMs??ue,J=new AbortController,d=AbortSignal.any([J.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),F=()=>r("released","aborted"),a="preparing",U,k=0,g=null,p=null,f=null,u=null,l=null,A=new Set,v=new Map,N,G=new Promise(e=>N=e),D,oe=new Promise(e=>D=e);function I(e,o){a!==e&&(a=e,U=o,b(n.onState,e))}function le(){d.removeEventListener("abort",F),R(),p?.destroy(),p=null,g?.remove(),g=null,f=null}function r(e,o){["adopted","unavailable","released","closed"].includes(a)||(I(e,o),le(),N(!1),D(null))}let q=e=>`error:${e?.code??e?.name??"unknown"}`,M=t.ownerDocument.defaultView,C=!0,W=null,h=!1,se=e=>e.storageArea===M?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),K=e=>{se(e)&&H()},ie=n.client.subscribe(()=>H());function R(){C&&(C=!1,M?.removeEventListener("storage",K),ie())}let B=()=>C&&(a==="ready"||a==="preparing");function X(e){(a==="ready"||a==="preparing")&&r("unavailable",e)}function H(){if(a==="ready"&&Date.now()-k>=_)return R();h=!0,W??=(async()=>{for(;h&&y&&B();){h=!1;try{await n.client.retained()==="pending"&&X("purchase_pending")}catch(e){d.aborted?r("released","aborted"):X(q(e))}}})().finally(()=>{W=null,h&&y&&B()&&H()})}M?.addEventListener("storage",K),d.addEventListener("abort",F,{once:!0});let $=n.client.findPurchase();$.catch(()=>{});async function P(){let e=await oe;if(!e)throw new Z("PURCHASE_PENDING","The purchase did not start; open it again");return e}let ce={get view(){return l?l.view:u},get signal(){return l?.signal??n.client.identitySignal},get quote(){return l?.quote??null},get operation(){return l?.operation??null},webViewUrl:"bundled",get canReselect(){return l?.canReselect},get recovery(){return l?.recovery},get pendingCancellation(){return l?.pendingCancellation},subscribe(e){return v.set(e,l?.subscribe?.(e)??(()=>{})),()=>{v.get(e)?.(),v.delete(e)}},refresh:async()=>l?l.refresh():structuredClone(u),preview:async e=>(await P()).preview(e),confirm:async()=>(await P()).confirm(),cancel:async()=>(await P()).cancel(),read:async()=>(await P()).read(),destroy(){l?.destroy()}},s={options:{},handoff:{}},z={loading:"host",focusAtReveal:!0,signal:n.client.identitySignal,start:async()=>ce,canInteract:()=>s.options.canInteract?s.options.canInteract():!["unavailable","released","closed"].includes(a),async beforeAction(){let e=a!=="adopted",o=u?.capabilities,i=await P();if(e&&!ae(i.view?.capabilities,o))throw new ee;await s.options.beforeAction?.()}};for(let e of fe)Object.defineProperty(z,e,{enumerable:!0,get:()=>s.options[e]});function x(){a!=="preparing"||!f||!p||!y||(I("ready"),N(!0))}let de={present(e){if(s.handoff.present)return s.handoff.present(e);a==="preparing"&&(f=e,k=Date.now(),x())},async dismiss(){if(s.handoff.dismiss)return s.handoff.dismiss();r("closed");for(let e of[...A])b(e)},quoteError(e){s.handoff.quoteError?s.handoff.quoteError(e):b(s.options.onError,e)}};(async()=>{try{let{showPaywall:e}=await import("./paywall-ZGG6DXO3.js");if(d.throwIfAborted(),a!=="preparing")return;let o=n.commerce??O(T),i=n.locale??T?.locale;if(!o)return r("unavailable","commerce_missing");if(!i)return r("unavailable","locale_missing");if(u=await n.client.readPaywall({paywallVersionId:n.paywallVersionId,paywallId:n.paywallId,commerce:o,locale:i}),d.throwIfAborted(),a!=="preparing")return;let m=Object.values(u.capabilities.plans);if(Object.values(u.document.buttons).some(c=>c.type==="checkout")&&m.length===0||m.some(c=>!c.available))return r("unavailable","plan_unavailable");g=t.ownerDocument.createElement("div"),t.append(g);let L=setTimeout(()=>a==="preparing"&&r("unavailable","timeout"),pe);G.then(()=>clearTimeout(L));let S=await e(g,z,de);if(!S.host||d.aborted||a!=="preparing"){S.host?.destroy(),r(d.aborted?"released":"unavailable","error");return}p=S.host,x()}catch(e){r(d.aborted?"released":"unavailable",q(e))}})(),Promise.resolve(n.start).then(async e=>{if(!e)return r("unavailable","gated");let o=V(e);if(!ae(O(o),n.commerce??O(o))||n.locale!==void 0&&o.locale!==n.locale)return r("unavailable","start_mismatch");try{let i=await $,m=i==="pending"?"purchase_pending":i==="found"?"original_purchase":i==="blocked"?"purchase_blocked":void 0;if(m)return r("unavailable",m);if(a!=="preparing")return;if(C&&(h=!1,await n.client.retained()==="pending"))return r("unavailable","purchase_pending")}catch(i){return r(d.aborted?"released":"unavailable",q(i))}a==="preparing"&&(y=o,j=te(o),x(),h&&H())},()=>r("unavailable","gated"));let Q={get state(){return a},get reason(){return U},ready:G,get start(){return y},matches:e=>!!y&&te(e)===j,open(){if(a==="preparing")return"pending";if(a!=="ready"||!f)return!1;if(Date.now()-k>=_)return r("unavailable","expired"),!1;let e=f;return f=null,R(),I("shown"),e(),"shown"},destroy(){J.abort()}};return re.set(Q,{onClose(e){return a==="closed"?(b(e),()=>{}):(A.add(e),()=>{A.delete(e)})},claim(){R()},async adopt(e,o){let i=e.paywall?.resolution,m=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(a!=="shown"||!p||!u||!i||!m||e.source.id!==y?.funnelId||!["running","waiting"].includes(e.status)||!ne(i,u))return null;let w;try{w=await o.start()}catch{return null}if(a!=="shown"||!p)return w.destroy(),null;l=w,s.options=o.options,s.handoff=o.handoff;for(let[c]of v)v.set(c,w.subscribe?.(c)??(()=>{})),w.view&&b(c,structuredClone(w.view));d.removeEventListener("abort",F),I("adopted"),D(w),A.clear();let L=p,S=g;return p=null,g=null,f=null,new Proxy(L,{get(c,Y){return Y==="destroy"?()=>{c.destroy(),S?.remove()}:Reflect.get(c,Y,c)}})},get modal(){return u?.document.presentation.type!=="inline"},get revealable(){return a==="ready"&&!!f&&Date.now()-k<_},release(){r("released")}}),Q}export{ue as a,me as b,he as c};
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-TPXRO63H.js";function b(t){let n=Object.create(null);for(let e of t.document.screen.actions){let a=e.properties.couponBinding,i=t.document.buttons[e.id];if(typeof a!="string"||i?.type!=="checkout")continue;let r=Object.hasOwn(t.capabilities.nodes,a)?t.capabilities.nodes[a]:void 0,{product:s}=i,l=s.type==="fixed"?[s.productVersionId]:s.allowedProductVersionIds,p=r?[r.base,...Object.values(r.byPlan??{})]:[],d=Object.fromEntries(p.flatMap(o=>o.planVersionId&&o.couponId&&o.text&&l.includes(o.planVersionId)?[[o.planVersionId,o]]:[]));n[e.id]={products:d,...s.type==="picker"?{picker:s.pickerId}:{}}}return Object.keys(n).length?{...t.capabilities,checkoutCoupons:n}:t.capabilities}function y(t,n){let e=structuredClone(t);for(let[a,i]of Object.entries(e.plans)){let r=n.plans[a];!r||r.versionId!==i.versionId||(r.amountMinor!==void 0&&(i.amountMinor=r.amountMinor),r.interval!==void 0&&(i.interval=r.interval),r.intervalCount!==void 0&&(i.intervalCount=r.intervalCount),r.prepaid!==void 0&&(i.prepaid=structuredClone(r.prepaid)))}return e}var u=class extends c{constructor(e="Plans were updated. Choose again.",a="\u5957\u9910\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002"){super("CONFLICT",e);this.zhMessage=a}zhMessage;customerMessage(e){return e?this.zhMessage:this.message}};function h(t,n){let e=a=>"document"in a?a.offering.id:a.content.offeringVersionId;return t.id===n.id&&e(t)===e(n)&&t.content?.artifact.sha256===n.content?.artifact.sha256}function O(t,n,e){if(t.operationId!==n.operationId||n.currency!==void 0&&t.currency!==n.currency)throw new c("INVALID_RESPONSE",e)}function S(t,n,e){let a=Object.fromEntries((t.lines[0]?.prepaid??[]).map(i=>[i.internal_feature_id,i.quantity]));if(n.featureQuantities&&(Object.keys(a).length!==Object.keys(n.featureQuantities).length||Object.entries(n.featureQuantities).some(([i,r])=>a[i]!==r)))throw new c("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(t.lines.length!==1||t.lines[0].productVersionId!==n.productVersionId||n.currency!==void 0&&t.currency!==n.currency||n.provider!==void 0&&t.provider!==n.provider&&!(n.provider==="stripe"&&t.provider==="merchant"&&t.execution?.provider==="merchant"))throw new c("INVALID_RESPONSE",e)}function I(t,n,e=!1){if(!t||t.operationId!==n?.operationId)return n;let a=t.merchantExecution,i=n.merchantExecution;if(a&&(!i||Date.parse(i.updatedAt)<Date.parse(a.updatedAt))||t.status==="complete"&&n.status!=="complete")return t;let r=n.status===t.status&&a?.recordingStatus!=="accepted"&&i?.recordingStatus==="accepted";return t.status!=="pending"&&(n.status==="pending"||e&&n.status!=="complete"&&!r)?t:n}function P(t){return t.screen.actions.some(n=>n.properties.closeControl==="content"&&t.buttons[n.id]?.type==="close")}export{b as a,y as b,u as c,h as d,O as e,S as f,I as g,P as h};
@@ -1 +0,0 @@
1
- import{$ as se,d as ee,k as te,o as ne,p as re,q as oe,t as O,v as ie,z as ae}from"./chunk-IYHXEKAD.js";import{a as F}from"./chunk-CE5MAAIR.js";import{A as Q,C as k,F as Y,I as h,J as D,K as C,L as A,da as ce,e as J,j as Z,l as W,p as I,q as S,s as R,v as X,w as H,y as w,z as P}from"./chunk-BIT6YWM7.js";import{a as T,f as K}from"./chunk-2Y5SGDC6.js";import{b as j}from"./chunk-YURGISSB.js";import{b as e}from"./chunk-NOOIJXRN.js";import{a as L,b as U}from"./chunk-CILM5XMH.js";var V=e.strictObject({eventsEnabled:e.boolean(),experimentViewsEnabled:e.boolean(),featureUsageEnabled:e.boolean()}),Ze=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function We(t,r){return r==="experiment_exposure"?t.experimentViewsEnabled:r==="feature_usage"?t.featureUsageEnabled:t.eventsEnabled}var z=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,r])=>t<=r),Se=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),we=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Oe=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),ue={condition:C.optional(),parentConditions:e.array(we).max(100).optional(),weights:e.array(e.number().min(0).max(1)).max(20).optional(),coverage:e.number().min(0).max(1).optional(),hashAttribute:e.string().optional(),fallbackAttribute:e.string().optional(),hashVersion:e.literal(2).optional(),disableStickyBucketing:e.boolean().optional(),bucketVersion:e.number().int().nonnegative().optional(),minBucketVersion:e.number().int().nonnegative().optional(),filters:e.array(Se).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Oe).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},pe=e.strictObject({...ue,key:e.string().min(1).max(255),variations:e.tuple([h,h]).rest(h).refine(t=>t.length<=20),urlPatterns:e.array(e.strictObject({include:e.boolean(),type:e.enum(["regex","simple"]),pattern:e.string()})).max(100).optional(),force:e.number().int().nonnegative().optional(),active:e.boolean().optional(),persistQueryString:e.boolean().optional()}),G=e.strictObject({value:h,variationId:e.number().int(),key:e.string(),name:e.string().optional(),bucket:e.number().optional(),passthrough:e.boolean().optional(),inExperiment:e.boolean(),hashUsed:e.boolean().optional(),hashAttribute:e.string(),hashValue:e.string(),featureId:e.string().nullable(),stickyBucketUsed:e.boolean().optional()}),je=e.strictObject({...ue,id:e.string().max(255).optional(),force:h.optional(),variations:e.array(h).min(2).max(20).optional(),key:e.string().optional(),range:z.optional(),tracks:e.array(e.strictObject({experiment:pe,result:G})).max(100).optional()}),Ie=e.strictObject({defaultValue:h.optional(),rules:e.array(je).max(500).optional()}),Pe=e.record(e.string(),e.union([e.strictObject({type:e.literal("hashed"),attributeKey:e.string(),values:e.array(e.string().regex(/^[a-f0-9]{64}$/))}),e.strictObject({type:e.literal("list"),attributeKey:e.string(),values:e.array(e.union([e.string(),e.number()]))}),e.strictObject({type:e.literal("condition"),condition:C})])),v=e.strictObject({scope:j,generation:e.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}).nullable(),features:e.record(e.string(),Ie),savedGroups:Pe,experiments:e.record(e.uuid(),pe)});var ke=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),it=ke.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((t,r)=>{for(let a of t.remoteFeatures)Object.hasOwn(t.features,a)&&r.addIssue({code:"custom",path:["features",a],message:"Remote Feature definitions cannot be public"});for(let[a,o]of Object.entries(t.savedGroups))o.type==="list"&&r.addIssue({code:"custom",path:["savedGroups",a],message:"Raw Saved Group lists cannot be public"})}),at=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),me=e.strictObject({value:h,source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:e.boolean(),off:e.boolean(),ruleId:e.string(),experimentResult:G.optional()}),st=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),me),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),de={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:te.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},le={...de,generation:v.shape.generation},Ce=e.discriminatedUnion("kind",[e.strictObject({...de,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...le,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...le,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:me.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),ct=e.strictObject({customerId:e.uuid().optional(),events:e.array(Ce).min(1).max(100)}),Ae=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),ut=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejections:e.array(Ae).max(100),analyticsConfig:V});function fe(t,r){let a=new Set,o=new Set,c=new Set,p=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(c.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(c.add(s),d.set(s,n),p.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function u(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ae(s[n]))throw new Error(`Funnel GB ${n} uses a reserved flow namespace`);m(s.condition);for(let n of s.parentConditions??[])l(n.id),m(n.condition)}function l(s,n=!1){let b=Object.hasOwn(r.features,s)?r.features[s]:void 0;if(!b){if(n)throw new Error("Required GB Feature is unavailable");return}a.has(s)||(a.add(s),g.set(s,b),p.push(()=>{for(let x of b.rules??[]){u(x);for(let ve of x.tracks??[])u(ve.experiment)}}))}function y(s){let n=Object.hasOwn(r.experiments,s)?r.experiments[s]:void 0;if(!n)throw new Error("Required GB Experiment is unavailable");o.has(s)||(o.add(s),f.set(s,n),p.push(()=>u(n)))}for(let s of t.graph.nodes){s.type==="feature"&&l(s.featureKey,!0),s.type==="split"&&y(s.experimentId),s.type==="condition"&&s.cases.forEach(b=>m(b.condition)),s.type==="offering"&&s.configuration.source==="feature"&&l(s.configuration.featureKey,!0);let n=s.type==="output"?s.value:s.type==="end"?s.output:null;n?.type==="feature"&&l(n.featureKey,!0)}for(let s of p)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var ge=e.object({defaultLocale:R,locales:e.record(R,e.object({name:e.string().max(80),description:e.string().max(500)}).strict())}).strict().superRefine((t,r)=>{let a=Object.keys(t.locales);(!a.length||a.length>20||!t.locales[t.defaultLocale])&&r.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(t)).length>5e4&&r.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var M=e.discriminatedUnion("type",[e.strictObject({type:e.literal("event"),event:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),e.strictObject({type:e.literal("open_url"),url:e.url().refine(t=>new URL(t).protocol==="https:")})]),Fe=P,Ee=e.discriminatedUnion("type",[e.object({type:e.literal("checkout"),product:I}).strict(),e.object({type:e.literal("close")}).strict(),e.object({type:e.literal("action"),action:M}).strict()]),E=e.object({schemaVersion:e.literal(3),kind:e.literal("paywall"),name:e.string().trim().min(1).max(80),presentation:S,requirement:K.optional(),products:F,offeringVersionId:e.uuid().nullable(),offeringId:e.uuid(),screen:Fe,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ee)}).strict(),Pt=E.superRefine((t,r)=>{(t.screen.surface!=="paywall"||t.screen.actions.some(o=>!["event","navigate"].includes(o.type)||o.close))&&r.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let o of Re(t))r.addIssue({code:"custom",message:o});for(let o of _e(t))r.addIssue({code:"custom",message:o});for(let o of t.screen.actions){let c=o.properties.closeControl;c!==void 0&&(c!=="content"||t.buttons[o.id]?.type!=="close")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:'Only a close button can carry closeControl, and its value is "content"'})}for(let o of t.screen.actions){let c=o.properties.couponBinding;c!==void 0&&(typeof c!="string"||!X.safeParse(c).success||t.buttons[o.id]?.type!=="checkout"||Y(t.screen,c)?.type!=="text")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:"Choose a Coupon text binding for this checkout action"})}k(t.screen).some(o=>!o.complete)&&r.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(t.buttons).length!==t.screen.actions.filter(o=>o.type!=="navigate").length||t.screen.actions.some(o=>o.type!=="navigate"&&!Object.hasOwn(t.buttons,o.id)))&&r.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(t.buttons).some(o=>o.type==="checkout")||r.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _e(t){let r=t.products.items.map(p=>p.productVersionId),a=Z(t.screen),o=new Set,c=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&c.push("products"),t.offeringVersionId||c.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(p=>!t.products.grouping.assignments.some(g=>g.tierId===p.id)))&&c.push("grouping");for(let p of Object.values(t.buttons))if(p.type==="checkout"){let g=p.product;if(g.type==="fixed")o.add(g.productVersionId);else{g.allowedProductVersionIds.forEach(m=>o.add(m));let f=!1,d=a[g.pickerId];d&&(f=!0,(g.allowedProductVersionIds.some(m=>!d.ids.includes(m))||d.ids.some(m=>!g.allowedProductVersionIds.includes(m)))&&c.push("picker")),w(t.screen,m=>{if(m.id!==g.pickerId||m.type!=="plan_picker")return;f=!0,(JSON.stringify(m.planIds)!==JSON.stringify(r)||JSON.stringify(g.allowedProductVersionIds)!==JSON.stringify(r)||m.defaultPlan!==t.products.defaultProductVersionId)&&c.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&c.push("grouping")}),f||c.push("picker")}}return(!o.size||[...o].some(p=>!r.includes(p)))&&c.push("purchase"),w(t.screen,p=>{p.type==="stack"&&p.productSlot&&!p.bind?.plan&&c.push(`productBinding:${p.id}`),(p.type==="stack"||p.type==="button")&&p.bind?.plan&&!r.includes(p.bind.plan)&&c.push("binding"),p.type==="plan_picker"&&(!p.planIds?.length||p.planIds.some(g=>!r.includes(g)))&&c.push("binding")}),[...new Set(c)]}function Re(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),Q(f.root,d=>{let m=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(m){let i=t.screen.actions.find(l=>l.id===m);i?.type==="navigate"&&o.get(f.id).push(i.pageId);let u=t.buttons[m];f.id!==a.id&&u&&u.type!=="close"&&r.push(`purchaseScreen:${d.id}`)}f.id!==a.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&r.push(`packageScreen:${d.id}`)});let c=new Set;function p(f){if(!c.has(f)){c.add(f);for(let d of o.get(f)??[])p(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?p(g):r.push("initialPage");for(let f of t.screen.pages)c.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var ye=e.object({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),state:e.enum(["active","archived"]),publishedVersionId:e.uuid().nullable(),updatedAt:e.iso.datetime({offset:!0}),draft:E}).strict(),kt=e.object({rows:e.array(ye).max(200),nextCursor:e.uuid().nullable()}).strict(),Ct=ye.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),At=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),document:E}).strict(),e.object({action:e.enum(["publish","archive"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Ft=e.object({paywalls:e.array(e.object({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),name:e.string().min(1).max(80),presentation:S,buttons:E.shape.buttons}).strict()).max(500),limited:e.boolean()}).strict();var De=["customer_data","coupon_code"],be=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Ve=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,ze=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ge=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),Me=e.strictObject({stripe:e.strictObject({prices:e.array(ze).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(be).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:be,basePlanId:Ve.nullable()})).min(1).max(10)}).optional()}).superRefine((t,r)=>{(t.stripe&&!_(t.stripe.prices,a=>a.currency)||t.apple&&!_(t.apple.productIds,a=>a)||t.google&&!_(t.google.products,a=>`${a.productId}:${a.basePlanId}`))&&r.addIssue({code:"custom",message:"Duplicate channel entry"})}),qe=e.strictObject({name:e.string().trim().min(1).max(80),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(100),trial:e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}).nullable(),benefits:e.array(Ge).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:Me,prepaid:e.array(J).max(100).optional()}),Be=e.strictObject({digest:O,content:e.strictObject({discount:ne,duration:re,appliesTo:oe,displayCopy:ge.nullable(),firstPurchaseOnly:e.boolean(),qualificationRequired:e.boolean(),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),grantWindowHours:e.number().int().positive(),perCustomerLimit:e.number().int().positive()})}),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("checkout"),product:I}),e.strictObject({type:e.literal("close")}),e.strictObject({type:e.literal("action"),action:M})]),Lt=e.strictObject({kind:e.literal("paywall"),formatVersion:e.literal(1),name:e.string().trim().min(1).max(80),offeringVersionId:e.uuid(),presentation:S,screen:P,products:F,catalog:e.record(e.uuid(),qe),buttons:e.record(H,Ne),coupons:e.record(e.uuid(),Be)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ce(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),ie(o,De).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let c=new Set,p=new Set,g=new Set;w(o,n=>{let b="bind"in n?n.bind:void 0;b?.promotionCode&&a("Promotion codes must not be published"),b?.plan&&c.add(b.plan),b?.coupon&&p.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>c.add(x)),n.defaultPlan&&c.add(n.defaultPlan)),n.type==="text"&&n.feature&&g.add(n.feature.id)});let f=t.products.items.map(n=>n.productVersionId),d=Object.keys(t.catalog);(f.length!==d.length||f.some(n=>!Object.hasOwn(t.catalog,n)))&&a("Catalog must contain exactly the displayed Products");let m=new Set(f);t.products.defaultProductVersionId!==null&&!m.has(t.products.defaultProductVersionId)&&a("Default Product must be displayed");for(let n of c)m.has(n)||a("Screen references a Product that is not displayed");for(let n of Object.values(t.catalog))!n.channels.stripe&&!n.channels.apple&&!n.channels.google&&a("A displayed Product needs at least one sales channel");let i=new Set(Object.values(t.catalog).flatMap(n=>n.benefits.map(b=>b.featureId)));for(let n of g)i.has(n)||a("Feature text must read a displayed benefit");let u=o.actions.filter(n=>n.type!=="navigate");o.actions.some(n=>n.type!=="event"&&n.type!=="navigate")&&a("Paywall actions are events or navigation"),(Object.keys(t.buttons).length!==u.length||u.some(n=>!Object.hasOwn(t.buttons,n.id)))&&a("Buttons must match the screen's actions");let y=!1;for(let n of Object.values(t.buttons)){if(n.type!=="checkout")continue;y=!0,(n.product.type==="fixed"?[n.product.productVersionId]:n.product.allowedProductVersionIds).some(x=>!m.has(x))&&a("Checkout may only sell displayed Products")}y||a("A Paywall needs a checkout button");let s=Object.keys(t.coupons);(s.length!==p.size||s.some(n=>!p.has(n)))&&a("Coupons must be exactly the bound Coupons")}),he=e.strictObject({state:e.enum(["published","archived"]),controlRevision:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({version:e.number().int().positive(),artifact:e.string().min(1),sourceDigest:e.string().regex(/^[a-f0-9]{64}$/)}))}).refine(t=>Object.keys(t.versions).length>0,"Reviewed Paywall Versions are required");var $e={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},q=e.string().regex(/^[a-f0-9]{64}$/),B=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Le=j.extend({environmentId:e.uuid()}),xe=e.strictObject({features:e.array(e.string()).max(500),experiments:e.record(e.uuid(),e.array(e.string()).max(20)),savedGroups:e.array(e.string()).max(1e3)}),Ue=e.strictObject({kind:e.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:e.number().int().positive(),url:e.string().min(1).max(2048),sha256:q,byteLength:e.number().int().positive().max($e.maxArtifactBytes),generation:q.optional()}),Te=e.strictObject({state:e.enum(["active","paused","archived"]),controlRevision:B,evaluationMode:e.enum(["local","remote"]),evaluationRevision:B,currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({artifact:e.string(),dependencies:xe,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),en=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Le,revision:B,generation:q,policy:e.strictObject({refreshIntervalSeconds:e.number().positive().max(15),maxControlAgeSeconds:e.number().positive().max(60)}),gb:e.strictObject({features:e.string().nullable(),pageExperiments:e.string().nullable()}),artifacts:e.record(e.string(),Ue),funnels:e.record(e.uuid(),Te),paywalls:e.record(e.uuid(),he).optional()}).superRefine((t,r)=>{let a=(o,c)=>{o!==null&&t.artifacts[o]?.kind!==c&&r.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};a(t.gb.features,"gb_features"),a(t.gb.pageExperiments,"gb_page_experiments");for(let o of Object.values(t.paywalls??{}))for(let c of Object.values(o.versions))a(c.artifact,"paywall");for(let o of Object.values(t.funnels)){o.evaluationMode==="remote"&&Object.keys(o.versions).length&&r.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),o.evaluationMode==="local"&&!o.versions[o.currentVersionId]&&r.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let c of Object.values(o.versions))a(c.artifact,"funnel")}});function N(t){if(Array.isArray(t))return`[${t.map(N).join(",")}]`;if(t!==null&&typeof t=="object")return`{${Object.entries(t).sort(([a],[o])=>a<o?-1:a>o?1:0).map(([a,o])=>`${JSON.stringify(a)}:${N(o)}`).join(",")}}`;let r=JSON.stringify(t);if(r===void 0)throw new Error("Configuration must contain JSON values");return r}function Je(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function tn(t){return Je(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function nn(t,r){let a=i=>i.type==="feature"?i.featureKey:i.type==="end"&&i.output?.type==="feature"?i.output.featureKey:i.type==="output"&&i.value.type==="feature"?i.value.featureKey:void 0,o=(i,u)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===u:i==="feature"&&a(l)===u)?.name,c=(i,u,l=o(u.type,u.resource))=>new $(i,{...u,...l?{step:l}:{}});for(let i of Object.values(t.references)){let u=i.type==="flag"?!Object.hasOwn(r.features,i.key)||r.remoteFeatures.includes(i.key)?{type:"feature",resource:i.key}:null:i.type==="experiment"?Object.hasOwn(r.experiments,i.id)?null:{type:"experiment",resource:i.id}:i.type==="saved_group"&&!Object.hasOwn(r.savedGroups,i.id)?{type:"saved_group",resource:i.id}:null;if(u)throw c("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...u})}let p=fe(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let u=a(i);if(!u)continue;let l=p.features[u],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:u};if(!l||!y)throw c("Required public Feature declaration is unavailable",{reason:"unavailable",...s},i.name);if([l.defaultValue,...(l.rules??[]).flatMap(b=>[...Object.hasOwn(b,"force")?[b.force]:[],...b.variations??[],...(b.tracks??[]).flatMap(x=>x.experiment.variations)])].some(b=>b===void 0||!ee(y,b)))throw c("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,u)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw c("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},u);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,u)}},m=(i,u)=>{if(g.has(i)||!r.features[i])throw c("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},u)};for(let i of t.graph.nodes)if(i.type==="condition")for(let u of i.cases)d(u.condition,i.name);for(let[i,u]of Object.entries(p.features)){let l=o("feature",i);for(let y of u.rules??[]){d(y.condition,l);for(let s of[...y.parentConditions??[],...(y.tracks??[]).flatMap(n=>n.experiment.parentConditions??[])])m(s.id,l),d(s.condition,l);for(let s of y.tracks??[])d(s.experiment.condition,l)}}for(let[i,u]of Object.entries(p.experiments)){let l=o("experiment",i);d(u.condition,l);for(let y of u.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let u=p.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!u)throw c("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of u.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw c("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return xe.parse({features:Object.keys(p.features).sort(),experiments:Object.fromEntries(Object.entries(p.experiments).map(([i,u])=>[i,u.variations.map(String)])),savedGroups:[...f].sort()})}function rn(t){return se.parse(t)}export{E as a,We as b,pe as c,Pe as d,v as e,ke as f,it as g,at as h,st as i,ct as j,ut as k,fe as l,Lt as m,$e as n,Le as o,Ue as p,en as q,N as r,Je as s,tn as t,nn as u,rn as v};
@@ -1 +0,0 @@
1
- import{b as t}from"./chunk-NOOIJXRN.js";var $=t.enum(["sandbox","live"]),P=t.object({projectId:t.string().min(1),environment:$}).strict();var w=t.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),z=t.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let n=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return n==="-0"?"0":n}),y=u.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),I=t.string().min(1).max(64),T=t.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),j=t.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),M=t.record(I,t.union([t.string().max(120),t.number().finite(),t.boolean()])).refine(e=>Object.keys(e).length<=16,"\u6700\u591A 16 \u4E2A\u8BA1\u4EF7\u5C5E\u6027").transform(e=>Object.fromEntries(Object.entries(e).map(([n,i])=>[n,String(i)]))),B=t.record(I,t.union([t.string().max(120),t.number().finite(),t.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u6700\u591A 8 \u4E2A\u5C5E\u6027"),d=e=>{let n=e.startsWith("-");n&&(e=e.slice(1));let[i,s=""]=e.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");let p=BigInt(i)*BigInt("1000000")+BigInt(s.padEnd(6,"0"));return n?-p:p},k=t.array(t.object({upTo:y.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((n,i)=>{let s=e[i-1]?.upTo;return n.upTo!==null&&(i===0||s!=null&&d(n.upTo)>d(s))}),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),D=t.object({key:j,match:B,priority:t.number().int().default(0),cost:u.optional(),tiers:k.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),E=t.object({key:j,match:B,factor:y.optional(),add:z.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),A=t.object({units:y.default("1"),cost:u,tiers:k.optional(),dimensions:t.array(D).max(12).optional(),multipliers:t.array(E).max(4).optional()}).strict().superRefine((e,n)=>{let i=e.dimensions??[],s=e.multipliers??[];(new Set(i.map(o=>o.key)).size!==i.length||new Set(s.map(o=>o.key)).size!==s.length)&&n.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let[o,r]of i.entries())for(let c of i.slice(o+1))Object.keys(r.match).length===Object.keys(c.match).length&&r.priority===c.priority&&!Object.keys(r.match).some(a=>c.match[a]!==void 0&&c.match[a]!==r.match[a])&&n.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"});let p=[e.cost,...(e.tiers??[]).map(o=>o.cost),...i.flatMap(o=>[...o.cost===void 0?[]:[o.cost],...(o.tiers??[]).map(r=>r.cost)])],O=d(e.units);for(let o of p)for(let r=0;r<1<<s.length;r++){let c=s.filter((l,m)=>r&1<<m);if(c.some((l,m)=>c.slice(m+1).some(S=>Object.keys(l.match).some(h=>S.match[h]!==void 0&&S.match[h]!==l.match[h]))))continue;let a=d(o),f=BigInt("1"),x=BigInt("0");for(let[l,m]of s.entries())r&1<<l&&(a*=d(m.factor??"1"),f*=BigInt("1000000"),x+=d(m.add??"0"));let g=(a+x*f)*BigInt("1000000"),b=f*O;(g<BigInt("0")||g%b!==BigInt("0")||g/b>BigInt("999999999999999999"))&&n.addIssue({code:"custom",message:"\u6BCF\u4E2A\u4E1A\u52A1\u5355\u4F4D\u7684\u6700\u7EC8\u5355\u4EF7\u5FC5\u987B\u975E\u8D1F\u3001\u5728\u8303\u56F4\u5185\u4E14\u80FD\u7CBE\u786E\u8868\u793A\u4E3A\u6700\u591A 6 \u4F4D\u5C0F\u6570"})}}),_=A.safeExtend({featureKey:T});export{$ as a,P as b,w as c,u as d,z as e,T as f,M as g};
@@ -1 +0,0 @@
1
- import{i as ie}from"./chunk-GNAMACMK.js";import{a as Z,c as ee,e as te,f as ne,h as N,j as re,k as oe,l as se}from"./chunk-KIPUBMU3.js";import{b as X}from"./chunk-JAZHNQKO.js";import{r as V}from"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-CE5MAAIR.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import{$ as Y,D as G,I as R,aa as K,r as $}from"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import{a as p}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-JBVZ6A6V.js";import{b as u}from"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
@@ -1 +0,0 @@
1
- import{b as B}from"./chunk-CKVAV2W5.js";import{a as z}from"./chunk-525K7BPJ.js";import{b as S}from"./chunk-TA4W6SXG.js";import{b as V}from"./chunk-QXOUDODX.js";import"./chunk-UKVWANDE.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-KIPUBMU3.js";import"./chunk-LZBJHWVH.js";import"./chunk-PFPMK4IO.js";import"./chunk-N774V4SQ.js";import"./chunk-ZORZA4WG.js";import"./chunk-HX36OZPQ.js";import"./chunk-MTIOLSVM.js";import"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-3NCMYTNG.js";import"./chunk-CE5MAAIR.js";import"./chunk-VYI6QRJW.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import{a as v}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-SLUA7ABW.js";import"./chunk-YJS6NNIO.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-TA4W6SXG.js";import"./chunk-VYI6QRJW.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk-CKVAV2W5.js";import"./chunk-525K7BPJ.js";import"./chunk-TA4W6SXG.js";import"./chunk-UKVWANDE.js";import"./chunk-W32FI2A2.js";import"./chunk-KIPUBMU3.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-3NCMYTNG.js";import"./chunk-CE5MAAIR.js";import"./chunk-VYI6QRJW.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-SLUA7ABW.js";import"./chunk-YJS6NNIO.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
@@ -1 +0,0 @@
1
- import{N as r,O as m,h as e}from"./chunk-MTIOLSVM.js";import"./chunk-73ISTR7P.js";import"./chunk-IGANLTKS.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
@@ -1 +0,0 @@
1
- import{e as o}from"./chunk-O2D3A4CS.js";import"./chunk-JAZHNQKO.js";import"./chunk-U7XD4ZR5.js";import"./chunk-HX36OZPQ.js";import"./chunk-MTIOLSVM.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-CE5MAAIR.js";import"./chunk-DPIQ3SV7.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{a as Tt,c as Ot,d as et,f as tt,g as Dt,k as Lt}from"./chunk-525K7BPJ.js";import{b as Xe}from"./chunk-W32FI2A2.js";import{d as Et,e as xt,f as It,h as Ze,i as De,j as At,k as Rt,l as St}from"./chunk-KIPUBMU3.js";import{a as bt,c as Je,d as Ct,e as vt}from"./chunk-3NCMYTNG.js";import{b as ce}from"./chunk-CE5MAAIR.js";import{a as pe,c as Ke,e as Pt,h as kt}from"./chunk-VYI6QRJW.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import{ca as Ce,ea as ve,i as gt}from"./chunk-BIT6YWM7.js";import{c as fe,j as be}from"./chunk-2Y5SGDC6.js";import{c as Ye}from"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import{a as v}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as q}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function Nt(O,i,R){if(i.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let P=O?be.parse(O):null;if(await R.onComplete?.(i),!P||!R.check)return;let N=be.parse(await R.check());if(N.internal_feature_id!==P.internal_feature_id||N.quantity!==P.quantity||P.observation!==void 0&&(N.observation===void 0||N.observation.requirementDigest!==P.observation.requirementDigest||N.observation.authority!==P.observation.authority||Ye(N.observation.subject)!==Ye(P.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");N.allowed&&await R.onAccessGranted?.(N)}function nt(O){return Object.entries(O.document.buttons).filter(([,i])=>i.type==="checkout"&&i.product.type==="fixed"&&!ce(i.product,{},O.capabilities)).map(([i])=>i)}function _t(O,i){let R=i.lines[0];if(i.lines.length!==1||!R)return;let P=R.productVersionId,{screen:N,buttons:J}=O.document,x=new Map((R.prepaid??[]).map(m=>[m.internal_feature_id,m.quantity]));function K(m,h){if(m.hidden)return!1;if(m.type==="plan_picker"&&O.capabilities.pickers[m.id]?.options.includes(P))return h[m.id]=P,!0;if(m.type==="quantity_picker"){let Q=x.get(m.internalFeatureId);return Q!==void 0&&(!m.bind?.plan||m.bind.plan===P)&&(h[m.id]=Q),!1}if(m.type==="button"&&m.action){let Q=J[m.action];return Q?.type==="checkout"&&Q.product.type==="fixed"&&Q.product.productVersionId===P}if(m.type!=="stack")return!1;let j=m.interaction,r=m.bind?.plan===P;for(let[Q,p]of m.children.entries()){let te={},S=K(p,te);if(j?.type==="toggle"||j?.type==="tabs"){if(!S)continue;return h[m.id]=j.type==="toggle"?Q===0:p.id,Object.assign(h,te),!0}Object.assign(h,te),S&&(r=!0,j?.type==="select"&&j.purpose==="product"&&j.pickerId&&p.type==="stack"&&p.bind?.plan===P&&(h[m.id]=p.id,h[j.pickerId]=P))}return r}for(let m of N.pages){let h={__page:m.id};if(K(m.root,h))return h}}async function Pn(O,i,R){let P=i.focusAtReveal?()=>{}:Ze(O.ownerDocument),N=()=>{x.finish("dismissed"),P()},J=()=>N(),x=At(O,i,"paywall",()=>{N(),q(i.onDismiss)},Tt);i.signal?.throwIfAborted(),i.signal?.addEventListener("abort",J,{once:!0});let K=null,m,h,j;try{if(x.start(!0,i.loadingDocument?.screen.strings.defaultLocale,i.loadingDocument??null),x.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(K=i.check?be.parse(await x.wait(i.check(),De)):null,K?.allowed)return x.finish("skipped"),i.signal?.removeEventListener("abort",J),P(),await i.onAccessGranted?.(K),{check:K,host:null};let[e,t]=await Promise.allSettled([x.wait(import("./screen-renderer-5SJCTMJH.js")),x.wait(i.start().then(o=>(x.cancelled&&o.destroy(),o)),De)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;j=e.value,m=t.value,i.signal?.throwIfAborted(),m.signal?.throwIfAborted(),m.signal?.addEventListener("abort",J,{once:!0});let n=m.view??await x.wait(m.refresh(),De);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");m.signal?.throwIfAborted(),h=n}catch(e){throw x.finish("error",e),i.signal?.removeEventListener("abort",J),m?.signal?.removeEventListener("abort",J),m?.destroy(),P(),e}let r=m,{mountScreenPreview:Q}=j,p=O.ownerDocument,te=new AbortController,S=p.createElement("section"),le=p.createElement("div"),G=p.createElement("div"),Le=i.mountControls,V=Le?p.createElement("div"):void 0,u=p.createElement("p"),g=p.createElement("button"),k=p.createElement("button"),I=p.createElement("dialog"),rt=r.locale||h.document.screen.strings.defaultLocale,a=rt.toLowerCase().startsWith("zh"),Ut=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",Mt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",D=Ot(h.document.screen.theme);S.dataset.indianaPaywall="",S.setAttribute("aria-label",h.document.name),S.style.cssText=D.root,G.style.cssText=D.controls,u.style.cssText=D.message,u.setAttribute("role","status"),k.style.cssText=D.link,k.textContent=a?"\u5173\u95ED":"Close",g.style.cssText=D.secondary,g.textContent=a?"\u91CD\u8BD5":"Retry",g.hidden=!0,G.append(u,g,k),V&&(V.style.cssText="flex:1 0 100%;min-width:0",V.hidden=!0,G.prepend(V)),S.append(le,G);let Ne=()=>{if(V){let o=!V.childElementCount&&!V.textContent?.trim();V.hidden!==o&&(V.hidden=o)}let e=ne??G,t=[...e.children].every(o=>o===u?!u.textContent:o.hidden),n=[...e.children].some(o=>o===k?!1:o===u?!!u.textContent:!o.hidden);e.style.cssText=t?D.controls.replace(/padding:[^;]+/,"padding:0"):n?`${D.controls};${D.pinned}`:D.controls,Me()},it=typeof MutationObserver>"u"?void 0:new MutationObserver(Ne);it?.observe(S,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Pe=h.document.presentation,qt=Object.entries(h.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),$,ot,_e=!1,at=JSON.stringify(h.capabilities),st=e=>oe&&!he?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):nt(e);function ke(e){if(y)return;h=e;let t=JSON.stringify(e.capabilities);t!==at&&($?.updateCapabilities(pe(e),st(e)),at=t),Ht(e),ye()}let E,Ue=0;function Me(){let e=p.defaultView;if(!E?.responsive||!e)return;let t=ne??G,n=e.innerHeight-(E.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ue=Math.max(1,n-t.getBoundingClientRect().height),$?.resizeViewport?.(Ue,e.innerWidth)}let y=!1,oe=!1,C=null,qe,Ee=!1,ct=!1,ae=!1,Ve,$e=!1,X,ne;function Vt(){return oe||y||X||$e?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Je(r)}let A=()=>!y&&!Ee&&!X&&i.canInteract?.()!==!1,H,ue=!1,d=null,Z=null,He="",se=()=>i.checkoutNavigation==="after_confirmation"&&!!(i.terminateCheckout||i.resumeCheckout),me={},he,W=null;function ye(){if(!se()||!$?.updateCheckoutControls)return;let e=r.quote,t=!W&&!!e&&!!r.operation&&B(r.operation).type==="checkout",n=Object.entries(h.document.buttons).flatMap(([o,c])=>c.type==="checkout"?[{actionId:o,policy:c}]:[]);$.updateCheckoutControls({actions:n.map(({actionId:o})=>o),resume:t?n.filter(({actionId:o,policy:c})=>Ae(e,h,o,c.product,me)).map(({actionId:o})=>o):[],resumeLabel:a?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:he})}function lt(){Z?.remove(),Z=null}async function Be(){if(W)return;if(i.resumeCheckout&&r.operation){await i.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(B(e).type!=="checkout")return _(e,!1);A()&&(xe.delete(e.operationId),await Re(e))}function ut(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",g.hidden=!0}async function dt(e=!1){let t=W;if(!t)return;g.hidden=!0;let n=Date.now()+2e4;for(;A();){let o=await r.read();if(o.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let c=B(o);if(c.type==="native"){W=null,lt(),C=t.selection,H=t.coupon,ue=!1,await ge();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){W=null,await _(o,!1);return}if(e&&c.type==="checkout"){e=!1;try{await i.terminateCheckout(t.operationId)}catch(w){q(i.onError,w)}}if(Date.now()>=n)break;await Xe(1e3,p,te.signal)}y||ut()}async function $t(e,t,n){W={operationId:e,selection:t,coupon:n};let o=!1;try{await i.terminateCheckout(e)}catch(c){if(c instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){W=null,u.textContent=a?"\u8BF7\u7EE7\u7EED\u539F\u8BA2\u5355\uFF0C\u6216\u7B49\u5F85\u5B83\u8FC7\u671F\u540E\u518D\u66F4\u6362\u65B9\u6848\u3002":"Continue your original checkout, or wait for it to expire before changing plans.",q(i.onError,c);return}o=c instanceof v&&(c.status??0)>=500,q(i.onError,c)}A()&&await dt(o)}function Fe(e,t,n,o,c){let w=pe(e).checkoutCoupons?.[t],l=w?w.products[n]:i.claimCoupon&&c?gt(e.capabilities,c,o):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Ht(e){oe||C||r.quote||r.operation||He&&u.textContent===He||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let xe=new Map,Ie=!1;function Ae(e,t,n,o,c,w){let l=e.lines.length===1?e.lines[0]:void 0,s=ce(o,c,t.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let L=Fe(t,n,s,c,w);if((L||pe(t).checkoutCoupons?.[n])&&(L?.id??null)!==(e.discount?.couponId??null))return!1;let U;try{U=ve(t.document.screen,s,c,t.capabilities)}catch{return!1}let ie=Object.fromEntries((l.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(U),...Object.keys(ie)])].every(z=>(U[z]??0)===(ie[z]??0))}let B=e=>bt({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:y,canReselect:r.canReselect});async function Re(e){let t=e.merchantExecution;if(!(!A()||!e.checkoutUrl||i.checkoutNavigation==="after_confirmation"&&B(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||xe.get(e.operationId)===e.checkoutUrl)){xe.set(e.operationId,e.checkoutUrl);try{i.onCheckoutUrl?await i.onCheckoutUrl(e.checkoutUrl):p.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw xe.delete(e.operationId),n}}}let re=(e,t=!1)=>{if(e instanceof Ke)d=null,u.textContent=e.customerMessage(a);else if(Dt(e))d=null,u.textContent=t?a?"\u5F53\u524D\u65E0\u6CD5\u5728\u6B64\u8D2D\u4E70\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u3002":"Purchases aren\u2019t available here right now. Payment hasn\u2019t started. Contact the merchant for help.":tt(e,a);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(d=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):r.canReselect===!0&&!C?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?tt(e,a):e instanceof v?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";g.hidden=d===null,He=u.textContent,t&&!E?.responsive&&u.scrollIntoView?.({block:"nearest"}),q(t&&R?.quoteError?R.quoteError:i.onError,e)},Se=new WeakMap;function Te(e){oe=e,g.disabled=e,$?.updateCapabilities?.(pe(h),st(h));for(let t of Z?.querySelectorAll("button")??[])e?(Se.set(t,t.disabled),t.disabled=!0):Se.has(t)&&(t.disabled=Se.get(t),Se.delete(t)),et(t)}function je(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function Bt(e){if(i.beforeAction)try{await i.beforeAction()}catch(t){throw t instanceof Ke?(C=null,ue=!1,d=null):d=e,t}}async function M(e,t){if(oe||y)return;if(!A()){je();return}let n=e===ge,o=n?Mt:Ut,c=se()&&t!==void 0;he=c?t:void 0,Te(!0),ye(),g.hidden=!0,u.textContent=c?"":o;try{if((e!==Be||!i.resumeCheckout)&&await Bt(e),y)return;if(!A()){d=e,g.hidden=!1,je();return}await e()}catch(w){y||re(w,n&&!c)}finally{he=void 0,Te(!1),ye(),u.textContent===o&&(u.textContent="")}}async function Ft(e){await Nt(K,e,i)}function ft(e){return Je(r).type==="recording"||B(e).type==="recording"}function pt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],o=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=t?n.length===1&&n[0]?.amountMinor===o&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===o&&e.lines[0],w=o===null?fe(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):fe(o,e.currency)+(c?Ce(c.interval,a?"zh-CN":"en",c.intervalCount??1):""),l=e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} \xB7 ${w}`:w,recurring:c}}async function _(e,t=i.checkoutNavigation!=="after_confirmation"){if(y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}if(u.textContent=Lt(e.status,a),ft(e)){let s=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=s?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",g.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",d=async()=>_(await r.read()),g.hidden=!1;return}if(e.problem){let s=e.problem;d=we,g.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",re(new v(s.code,s.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){d=null,await Ft(e);return}if(e.status!=="pending"){if(r.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",g.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",d=async()=>_(await r.read()),g.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),g.textContent=a?"\u91CD\u8BD5":"Retry",d=null,C=null;return}if(!t&&B(e).type==="checkout"){if(W){ut();return}if(se()){u.textContent="",Ie=!1,d=null,ye();return}let s=r.quote,L=s?.operationId===e.operationId?pt(s).label:"";u.textContent=Ie?L?a?`${L} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${L} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ie=!1,d=null;return}await Re(e);let n=Date.now(),o=n+6e5,c=2e3,w=!e.checkoutUrl,l=()=>w&&Date.now()-n<15e3;_e=!0,q(i.onObservationChange,!0);try{for(;!y&&Date.now()<o;){if(await Xe(l()?700:c,p,te.signal),y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}let s=await r.read();if(s.checkoutUrl&&(w=!1),!t&&B(s).type==="checkout"){await _(s,!1);return}if(!s.problem&&s.status==="pending"&&await Re(s),s.status!=="pending"||s.problem||ft(s)){await _(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{_e=!1,q(i.onObservationChange,!1)}d=async()=>_(await r.read()),g.hidden=!1}async function Qe(e=!1){let t=await r.read();if(y)return;if(!A()){d=()=>Qe(e),g.hidden=!1;return}let n=r.quote;if(n&&Pt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!r.pendingCancellation){mt(n);return}await _(t,e||void 0)}async function we(){lt(),d=we;let e=await r.confirm();if(!A()){d=we,g.hidden=!1;return}if(e.problem){await _(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Re(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!i.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await i.onPurchase({operation:e,signal:te.signal})}}d=async()=>_(await r.read()),await _(e,!0)}function mt(e){Z?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),o=p.createElement("button"),c=p.createElement("button"),w=p.createElement("div"),l=p.createElement("p"),s=e.merchantTerms,L=a?"zh-CN":"en",U=s?.subscriptionTerms?.items??[],ie=s?s.subscriptionTerms?.trial?.days:e.lines.find(f=>f.trial)?.trial?.days,ee=ie===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(f=>f.trial)?0:null,z=(f,b)=>a?`${b} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${f}`:`Then ${f} after the ${b}-day trial`,{label:ze,recurring:ht}=pt(e),jt=e.lines.map(f=>f.productName).join(", "),yt=ee===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${fe(ee,e.currency)}`;l.textContent=yt?[jt,yt].filter(Boolean).join(" \xB7 "):ze,o.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",o.disabled=t,c.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,w.style.cssText=D.actions,o.style.cssText=D.primary,c.style.cssText=D.secondary,et(o),o.onclick=()=>{M(we)};let wt=async()=>{let f=await r.cancel();y||(n.remove(),Z=null,await _(f))};c.onclick=()=>{d=wt,M(wt)};let F=p.createElement("div");if(F.style.cssText=D.terms,s){for(let b of U){if(ee===null&&b===ht)continue;let T=p.createElement("p"),Y=fe(b.amountMinor,e.currency)+Ce(b.interval,L,b.intervalCount);T.textContent=ee!==null&&ie!==void 0?z(Y,ie):Y,F.append(T)}let f=s.subscriptionTerms?.trial;if(f){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.days} \u5929\uFF1B${f.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.days}; ${f.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}for(let b of[...s.expectedEffects.map(T=>T.description),...s.requiredConsents.map(T=>T.summary)]){let T=p.createElement("p");T.textContent=b,F.append(T)}}else{for(let f of e.lines){if(ee!==null||f!==ht){let b=p.createElement("p"),T=`${fe(f.catalogAmountMinor,e.currency)}${Ce(f.interval,L,f.intervalCount??1)}`;b.textContent=ee!==null&&f.trial?(e.lines.length>1?`${f.productName} \xB7 `:"")+z(T,f.trial.days):`${f.productName} \xB7 ${T}`,F.append(b)}for(let b of f.prepaid??[]){let T=p.createElement("p"),Y=r.view?.capabilities.plans[f.productVersionId]?.prepaid?.find(Qt=>Qt.internalFeatureId===b.internal_feature_id);T.textContent=`${Y?.name??b.internal_feature_id} \xB7 ${b.quantity} ${a?"\u4EFD":"packs"} \xD7 ${b.terms.units}`,Y&&(T.textContent+=Ce(Y.reset==="week"||Y.reset==="month"||Y.reset==="year"?Y.reset:"one_time",L,Y.resetCount)),F.append(T)}if(f.trial){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.trial.days} \u5929\uFF1B${f.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.trial.days}; ${f.trial.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}}if(!e.charge){let f=p.createElement("p");f.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",F.append(f)}}for(let f of F.children)f.style.margin="0";w.append(o,c),n.append(l,...F.childElementCount?[F]:[],w),G.prepend(n),E?.responsive||n.scrollIntoView?.({block:"nearest"}),o.focus({preventScroll:!0}),Z=n,d=null}async function ge(){if(!C)return;if(d=ge,!ue){let n=r.view,o=n?.document.buttons[C.actionId],c=n&&o?.type==="checkout"?ce(o.product,C.selection,n.capabilities):null;if(!n||!c)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let w=H?.offerId;if(H&&!w){if(!i.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await i.claimCoupon(H.id,C.requestId);if(y)return;if(!l||l.couponId!==H.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw C=null,H=void 0,d=async()=>{ke(await r.refresh()),d=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");w=l.id}if(!H&&!n.document.screen.actions.some(l=>l.id===C?.actionId&&typeof l.properties.couponBinding=="string")&&(w=await i.resolveOfferId?.({actionId:C.actionId,productVersionId:c,featureQuantities:ve(n.document.screen,c,C.selection,n.capabilities)})),y)return;w!==void 0&&(C.offerId=w),ue=!0}if(!A()){g.hidden=!1;return}let e;try{e=await r.preview(C)}catch(n){throw r.canReselect===!0&&(C=null,ue=!1,H=void 0,d=null),n}if(H&&(e.discount?.couponId!==H.id||e.discount.offerId!==C.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(y)return;let t=e.merchantTerms;if(i.confirmOnHostedCheckout&&A()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=he?"":a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await we()}catch(o){y||re(o)}finally{u.textContent===n&&(u.textContent="")}return}mt(e)}function de(e="destroy"){if(y)return;y=!0;let t=qe;qe=void 0,q(t),i.signal?.removeEventListener("abort",J),r.signal?.removeEventListener("abort",J),x.finish("dismissed"),ot?.(),te.abort(),it?.disconnect(),E?.destroy(),$?.destroy(),r.destroy(),I.open&&I.close(),I.remove(),S.remove(),P(),e==="dismiss"&&q(i.onDismiss)}N=de;async function Oe(){if(!ae||y||Ee||X==="closing"||!X&&!A())return;if(!R){de("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",ne||(ne=p.createElement("div"),ne.style.cssText=G.style.cssText,G.replaceWith(ne),le.inert=!0),k.hidden=!1,ne.replaceChildren(e,k),X="closing",k.setAttribute("aria-disabled","true"),k.focus({preventScroll:!0});try{await R.dismiss()}catch(t){y||q(i.onError,t)}y||(X="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",k.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",k.removeAttribute("aria-label"),k.removeAttribute("aria-disabled"))}k.onclick=()=>{Oe()},I.addEventListener("cancel",e=>{e.preventDefault(),Oe()}),g.onclick=()=>{d&&M(d)};function Ge(e){x.finish("error",e),de()}function We(){if(!(!ct||ae||y||Ee||E&&!A()))try{let e=t=>{i.focusAtReveal&&(P=Ze(p)),$?.setHidden?.(!1),Ve?.(),E&&(I.showModal(),E.responsive&&I.focus({preventScroll:!0}),!t&&i.loading!=="host"&&xt(I,E.type,E.responsive)),ae=!0};R?R.present(()=>x.present(()=>e(!0))):x.present(e)}catch(e){Ge(e),re(e)}}try{if(Pe.type==="inline"?(Ne(),Ve=St(S,O),O.append(S)):(I.setAttribute("aria-label",h.document.name),k.textContent="\xD7",k.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),It(k,h.document.screen.theme),k.hidden=kt(h.document),I.append(k,S),O.append(I),E=Et(I,{...h.document.screen,presentation:Pe},Me),E.latch(),E.responsive&&(S.style.display="flex",S.style.flexDirection="column",S.style.maxHeight="100%",le.style.overflow="clip",le.style.minHeight="0"),Ve=Rt(I)),Le&&V){let n=Le(V);if(typeof n=="function"&&(y?q(n):qe=n),y)throw new DOMException("Presentation cancelled","AbortError");Ne()}$=Q(le,{mode:"live",rendererUrl:r.webViewUrl,title:h.document.name,closeActions:qt,onAuthoredClose(n){X||y||(k.hidden=n)},hostPresentation:()=>E?.type??Pe.type,reportContentHeight:E?.responsive,onResize:n=>{if(!E?.responsive)return;let o=Math.min(n,Ue);le.style.height=`${o}px`,E.setContentHeight(o+(ne??G).getBoundingClientRect().height)},onSelection(n){me=n,ye()},onAction(n,o={},c,w){if(!ae||y||X)return;let l=r.view,s=l?.document.buttons[n];if(!s)return;if(s.type==="close"&&R&&i.resumeCheckout&&r.operation&&Ct(B(r.operation))){Oe();return}if(oe)return;if(!A()){je();return}if(s.type==="close"){M(async()=>{await i.onAction?.(n),de(i.onAction?"action":"dismiss")});return}if(s.type==="action"){d=async()=>{if(s.action.type==="event"){if(!i.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await i.onEvent(s.action.event)}else i.onOpenUrl?await i.onOpenUrl(s.action.url):p.defaultView?.location.assign(s.action.url);await i.onAction?.(n),d=null},M(d);return}if(i.allowNewPurchase===!1){se()&&l&&r.quote&&r.operation&&B(r.operation).type==="checkout"&&Ae(r.quote,l,n,s.product,o,w)?M(Be,n):u.textContent=a?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(Z&&r.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",E?.responsive||Z.scrollIntoView?.({block:"nearest"}),Z.querySelector("button")?.focus({preventScroll:!0});return}if(se()&&W){W.selection.actionId===n&&M(()=>dt(!0),n);return}if(se()&&i.terminateCheckout&&l&&r.quote&&r.operation&&r.canReselect===!1&&B(r.operation).type==="checkout"){if(Ae(r.quote,l,n,s.product,o,w)){M(Be,n);return}let U=ce(s.product,o,l.capabilities);try{if(!U)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ve(l.document.screen,U,o,l.capabilities)}catch(ze){re(ze);return}let ie=r.operation.operationId,ee={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(o)},z=Fe(l,n,U,o,w);M(()=>$t(ie,ee,z),n);return}if((r.quote||C)&&r.canReselect===!1){let U=!!l&&!!r.quote&&Ae(r.quote,l,n,s.product,o,w);Ie=!!r.quote&&!U,d=r.quote?()=>Qe(U):ge,M(d);return}let L=l&&ce(s.product,o,l.capabilities);if(!l||!L){re(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(i.onPurchaseIntent){d=null,M(async()=>{let U={actionId:n,productVersionId:L,selection:structuredClone(o),featureQuantities:ve(l.document.screen,L,o,l.capabilities)};$e=!0,await i.onPurchaseIntent(U)});return}if(C&&C.actionId!==n){re(new v("COMMAND_PENDING","Finish the current purchase"));return}C||(H=Fe(l,n,L,o,w),C={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(o)},ue=!1),M(ge,n)},onEscape:()=>{Oe()},onError:n=>{let o=new Error(n);!ae&&!y&&Ge(o),re(o)},onRendered:n=>{n&&I.setAttribute("aria-label",n),ct=!0,We()}}),$.setHidden?.(!0),Me();let e=se()&&!!r.quote&&!!r.operation&&B(r.operation).type==="checkout";me=e?_t(h,r.quote)??{}:{},$.update(h.document.screen,rt,{capabilities:pe(h),unavailableActions:nt(h),serverInput:{bindings:[],answers:{}},...Object.keys(me).length?{selection:me}:{}}),ot=r.subscribe?.(ke),ke(r.view??h),await x.wait($.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(d=()=>Qe(),M(d))}catch(e){throw Ge(e),e}return{check:K,host:{get observing(){return _e},get recovery(){return Vt()},async prepareFallback(){if(oe||y||X||$e)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};Te(!0);try{let e=await vt(r);return e.type==="native"&&de(),e}finally{Te(!1)}},setSuspended(e){Ee=e,S.hidden=e,e&&I.open?I.close():!e&&!ae?We():!e&&!y&&ae&&Pe.type!=="inline"&&!I.open&&I.showModal()},destroy:de,refresh:async()=>{if(!A()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return ke(e),We(),e}}}}export{Pn as showPaywall};
@@ -1 +0,0 @@
1
- import{b as a}from"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-CE5MAAIR.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-LJBTEB2Q.js";import"./chunk-O2D3A4CS.js";import"./chunk-JAZHNQKO.js";import"./chunk-ZORZA4WG.js";import"./chunk-U7XD4ZR5.js";import"./chunk-HX36OZPQ.js";import"./chunk-GGYBZWWY.js";import"./chunk-MTIOLSVM.js";import"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-3NCMYTNG.js";import"./chunk-CE5MAAIR.js";import"./chunk-VYI6QRJW.js";import"./chunk-DPIQ3SV7.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-GNAMACMK.js";import"./chunk-KIPUBMU3.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
File without changes
File without changes
File without changes