@tinkerlandai/longplay-sdk 0.10.28 → 0.10.29

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 (65) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{chunk-JOI5ZUBO.js → chunk-2JTMXZ5M.js} +1 -1
  3. package/dist/chunk-3GT4A3TA.js +1 -0
  4. package/dist/{chunk-IVDXTPNR.js → chunk-4OBCF5H3.js} +1 -1
  5. package/dist/{chunk-DVOYXRVB.js → chunk-4WBIACS2.js} +1 -1
  6. package/dist/{chunk-FVM4JJBA.js → chunk-5X6WAPH3.js} +1 -1
  7. package/dist/{chunk-FODM46LT.js → chunk-6QJRT23Q.js} +1 -1
  8. package/dist/{chunk-BSBHQVHH.js → chunk-77GCT2VP.js} +1 -1
  9. package/dist/{chunk-FCBTTR5W.js → chunk-7EPE2PUN.js} +1 -1
  10. package/dist/{chunk-WYMP6O5B.js → chunk-AZ53RDWO.js} +1 -1
  11. package/dist/{chunk-UIYOW47V.js → chunk-CGSZBPSX.js} +1 -1
  12. package/dist/{chunk-O7HHYO3I.js → chunk-EUVKRGMO.js} +1 -1
  13. package/dist/{chunk-QQ43HZVT.js → chunk-FDCINOOI.js} +1 -1
  14. package/dist/{chunk-CTSSHAV7.js → chunk-GOYKJHDV.js} +1 -1
  15. package/dist/{chunk-P3PXFIMG.js → chunk-HZYCK4XJ.js} +1 -1
  16. package/dist/chunk-IDMOAV63.js +1 -0
  17. package/dist/chunk-JAUJZWYJ.js +1 -0
  18. package/dist/{chunk-6YJ3CFPM.js → chunk-JPHYIUIR.js} +1 -1
  19. package/dist/chunk-K72QA2PO.js +1 -0
  20. package/dist/{chunk-FKDUXXGT.js → chunk-KAXKYBSI.js} +1 -1
  21. package/dist/{chunk-VGLBSYPV.js → chunk-MBKZYWPF.js} +1 -1
  22. package/dist/{chunk-5KB452HB.js → chunk-MMZR4I5X.js} +1 -1
  23. package/dist/{chunk-LS4XNIXR.js → chunk-PKY55SBA.js} +1 -1
  24. package/dist/{chunk-4GZKK2RE.js → chunk-PNHGULO2.js} +1 -1
  25. package/dist/{chunk-TEMI3X5X.js → chunk-PQJJ5BSY.js} +1 -1
  26. package/dist/{chunk-5SL2JQU3.js → chunk-Q2TQLDEH.js} +1 -1
  27. package/dist/{chunk-RCUBJJ7K.js → chunk-QZG2YXM4.js} +1 -1
  28. package/dist/{chunk-NROHBY3P.js → chunk-S4JIOALC.js} +1 -1
  29. package/dist/{chunk-CK4QMCWN.js → chunk-SBSLHDBE.js} +1 -1
  30. package/dist/{chunk-QE6T6NX6.js → chunk-TLGKBSXC.js} +1 -1
  31. package/dist/chunk-TNN4S6VO.js +1 -0
  32. package/dist/{chunk-ARIVUZUH.js → chunk-UWAZDSWO.js} +1 -1
  33. package/dist/{chunk-W5KG2IWX.js → chunk-VC2H3LFP.js} +1 -1
  34. package/dist/chunk-VKDBROTE.js +1 -0
  35. package/dist/{chunk-6O4IBSE3.js → chunk-VSWKFI3L.js} +1 -1
  36. package/dist/{chunk-GRNHBOSS.js → chunk-YBX2LLRG.js} +1 -1
  37. package/dist/{content-VNX6YOVO.js → content-S5MXIR7Y.js} +1 -1
  38. package/dist/{funnel-host-purchase-WRJIUARR.js → funnel-host-purchase-7BRXGIJX.js} +1 -1
  39. package/dist/funnel-runtime-host-ITKTYBDS.js +1 -0
  40. package/dist/index.js +1 -1
  41. package/dist/merchant-bridge-contracts-JCDMP54Z.js +1 -0
  42. package/dist/native-shell.js +1 -1
  43. package/dist/openrouter.js +1 -1
  44. package/dist/operation-contracts-B7I45NS3.js +1 -0
  45. package/dist/page.js +1 -1
  46. package/dist/paywall-BEFHTZW7.js +1 -0
  47. package/dist/paywall-session-YVGZPSFM.js +1 -0
  48. package/dist/popup.js +1 -1
  49. package/dist/react-native.js +1 -1
  50. package/dist/{screen-renderer-EHGDVWEV.js → screen-renderer-ITUUNF4E.js} +1 -1
  51. package/dist/server.js +1 -1
  52. package/dist/visual.js +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-2AKQWIK6.js +0 -1
  55. package/dist/chunk-3JQPCIKN.js +0 -1
  56. package/dist/chunk-6KAADDQL.js +0 -1
  57. package/dist/chunk-JGG4R75K.js +0 -1
  58. package/dist/chunk-JPBLMVZR.js +0 -1
  59. package/dist/chunk-QONPVFRV.js +0 -1
  60. package/dist/funnel-runtime-host-CHE2WGKE.js +0 -1
  61. package/dist/merchant-bridge-contracts-M3V6MBVB.js +0 -1
  62. package/dist/operation-contracts-ROG5DVKX.js +0 -1
  63. package/dist/paywall-OATK5XFF.js +0 -1
  64. package/dist/paywall-session-ABEEADOM.js +0 -1
  65. /package/dist/{chunk-Z43N7U4U.js → chunk-7GD2UTBU.js} +0 -0
@@ -1 +1 @@
1
- import"./chunk-QQ43HZVT.js";import"./chunk-O7HHYO3I.js";import"./chunk-GRNHBOSS.js";import"./chunk-QE6T6NX6.js";import{a as i}from"./chunk-FCBTTR5W.js";import"./chunk-W5KG2IWX.js";import"./chunk-FVM4JJBA.js";import{b as A}from"./chunk-Z43N7U4U.js";import"./chunk-WOT6VMZA.js";var c=A.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:k}=await w.read();if(k){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
1
+ import"./chunk-FDCINOOI.js";import"./chunk-EUVKRGMO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import{a as i}from"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-5X6WAPH3.js";import{b as A}from"./chunk-7GD2UTBU.js";import"./chunk-WOT6VMZA.js";var c=A.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:k}=await w.read();if(k){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
@@ -0,0 +1 @@
1
+ import{e as o}from"./chunk-Q2TQLDEH.js";import"./chunk-CGSZBPSX.js";import"./chunk-MBKZYWPF.js";import"./chunk-UWAZDSWO.js";import"./chunk-TNN4S6VO.js";import"./chunk-PNHGULO2.js";import"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-AZ53RDWO.js";import"./chunk-EUVKRGMO.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-VC2H3LFP.js";import"./chunk-7GD2UTBU.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{d as o,e as r,f as e,g as f}from"./chunk-CK4QMCWN.js";import"./chunk-RCUBJJ7K.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVM4JJBA.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
1
+ import{d as o,e as r,f as e,g as f}from"./chunk-SBSLHDBE.js";import"./chunk-QZG2YXM4.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{b as at,c as Ne,e as ot,g as st,h as ct}from"./chunk-K72QA2PO.js";import{c as Xe,d as Ze,e as et,f as de,g as tt,h as nt,i as rt,k as it}from"./chunk-GOYKJHDV.js";import{a as We,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-KAXKYBSI.js";import{b as te}from"./chunk-AZ53RDWO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import{c as ee,o as re,oa as ie,qa as Oe}from"./chunk-4WBIACS2.js";import{c as Te}from"./chunk-HZYCK4XJ.js";import{a as x}from"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-5X6WAPH3.js";import"./chunk-7GD2UTBU.js";import{a as G}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function lt(T,r,D){if(r.status!=="complete")throw new x("INVALID_RESPONSE","A verified completed purchase is required");let O=T?re.parse(T):null;if(await D.onComplete?.(r),!O||!D.check)return;let S=re.parse(await D.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Te(S.observation.subject)!==Te(O.observation.subject)))throw new x("INVALID_RESPONSE","The access requirement changed");S.allowed&&await D.onAccessGranted?.(S)}function De(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!te(r.product,{},T.capabilities)).map(([r])=>r)}async function zt(T,r,D){let O=it(T.ownerDocument),S=()=>{C.finish("dismissed"),O()},B=()=>S(),C=tt(T,r,"paywall",()=>{S(),G(r.onDismiss)});r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let W=null,_,h,Le;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(W=r.check?re.parse(await C.wait(r.check(),de)):null,W?.allowed)return C.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(W),{check:W,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-ITUUNF4E.js")),C.wait(r.start().then(s=>(C.cancelled&&s.destroy(),s)),de)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await C.wait(_.refresh(),de);if(!n)throw new x("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw C.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let o=_,{mountScreenPreview:ut}=Le,d=T.ownerDocument,pe=new AbortController,k=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),b=d.createElement("button"),w=d.createElement("dialog"),a=h.document.screen.strings.defaultLocale.startsWith("zh"),dt=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",pt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",P=at(h.document.screen.theme);k.dataset.indianaPaywall="",k.setAttribute("aria-label",h.document.name),k.style.cssText=P.root,U.style.cssText=P.controls,u.style.cssText=P.message,u.setAttribute("role","status"),b.style.cssText=P.link,b.textContent=a?"\u5173\u95ED":"Close",y.style.cssText=P.secondary,y.textContent=a?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,b),k.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===b?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?P.controls.replace(/padding:[^;]+/,"padding:0"):n?`${P.controls};${P.pinned}`:P.controls,ye()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(k,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let J=h.document.presentation,F,Ue,fe=!1,$e=JSON.stringify(h.capabilities),qe=e=>K?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):De(e);function me(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),mt(e)}let g,he=0;function ye(){let e=d.defaultView;if(!g?.responsive||!e)return;let t=H??U,n=e.innerHeight-(g.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",he=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(he,e.innerWidth)}let p=!1,K=!1,A=null,ae=!1,Ve=!1,j=!1,we,be=!1,V,H;function ft(){return K||p||V||be?{type:"recover",operationId:o.operation?.operationId??o.quote?.operationId??null,requestId:null}:Se(o)}let R=()=>!p&&!ae&&!V&&r.canInteract?.()!==!1,ge=!1,l=null,$=null;function mt(e){K||A||o.quote||o.operation||(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 ve=new Map,Ce=!1;function ht(e,t,n,s){let i=e.lines.length===1?e.lines[0]:void 0,m=te(n,s,t.capabilities);if(!i||!m||i.productVersionId!==m)return!1;let E;try{E=Oe(t.document.screen,m,s,t.capabilities)}catch{return!1}let I=Object.fromEntries((i.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(E),...Object.keys(I)])].every(z=>(E[z]??0)===(I[z]??0))}let oe=e=>We({quote:o.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:o.canReselect});async function Pe(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&oe(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||ve.get(e.operationId)===e.checkoutUrl)){ve.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let Q=(e,t=!1)=>{if(t){let n=e instanceof x?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=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."):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 x&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?ot(e,a):e instanceof x?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!g?.responsive&&u.scrollIntoView?.({block:"nearest"}),G(t&&D?.quoteError?D.quoteError:r.onError,e)},se=new WeakMap;function ce(e){K=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of $?.querySelectorAll("button")??[])e?(se.set(t,t.disabled),t.disabled=!0):se.has(t)&&(t.disabled=se.get(t),se.delete(t)),Ne(t)}function Ee(){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 yt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function q(e){if(K||p)return;if(!R()){Ee();return}let t=e===le,n=t?pt:dt;ce(!0),y.hidden=!0,u.textContent=n;try{if(await yt(e),p)return;if(!R()){l=e,y.hidden=!1,Ee();return}await e()}catch(s){p||Q(s,t)}finally{ce(!1),u.textContent===n&&(u.textContent="")}}async function wt(e){await lt(W,e,r)}function He(e){return Se(o).type==="recording"||oe(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),i=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?ee(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ee(s,e.currency)+(i?ie(i.interval,a?"zh-CN":"en",i.intervalCount??1):""),E=e.lines.map(I=>I.productName).join(", ");return{label:E?`${E} \xB7 ${m}`:m,recurring:i}}async function N(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>N(await o.read()),y.hidden=!1;return}if(u.textContent=ct(e.status,a),He(e)){let i=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=i?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.",y.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>N(await o.read()),y.hidden=!1;return}if(e.problem){let i=e.problem;l=ne,y.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",Q(new x(i.code,i.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.":i.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.":i.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.":i.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,i));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"){l=null,await wt(e);return}if(e.status!=="pending"){if(o.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>N(await o.read()),y.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."),y.textContent=a?"\u91CD\u8BD5":"Retry",l=null,A=null;return}if(!t&&oe(e).type==="checkout"){let i=o.quote,m=i?.operationId===e.operationId?Be(i).label:"";u.textContent=Ce?m?a?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} 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.":"",Ce=!1,l=null;return}await Pe(e);let n=Date.now()+6e5,s=2e3;fe=!0,G(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await st(s,d,pe.signal),p)return;if(!R()){l=async()=>N(await o.read()),y.hidden=!1;return}let i=await o.read();if(!t&&oe(i).type==="checkout"){await N(i,!1);return}if(!i.problem&&i.status==="pending"&&await Pe(i),i.status!=="pending"||i.problem||He(i)){await N(i);return}s=Math.min(s*1.5,3e4)}}finally{fe=!1,G(r.onObservationChange,!1)}l=async()=>N(await o.read()),y.hidden=!1}async function xe(e=!1){let t=await o.read();if(p)return;if(!R()){l=()=>xe(e),y.hidden=!1;return}let n=o.quote;if(n&&Je(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&&!o.pendingCancellation){Fe(n);return}await N(t,e||void 0)}async function ne(){$?.remove(),$=null,l=ne;let e=await o.confirm();if(!R()){l=ne,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Pe(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new x("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:pe.signal})}}l=async()=>N(await o.read()),await N(e,!0)}function Fe(e){$?.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=d.createElement("div"),s=d.createElement("button"),i=d.createElement("button"),m=d.createElement("div"),E=d.createElement("p"),I=e.merchantTerms,ue=a?"zh-CN":"en",z=I?.subscriptionTerms?.items??[],Re=I?I.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,Z=Re===void 0?null:I?I.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,je=(c,f)=>a?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:bt,recurring:Qe}=Be(e),gt=e.lines.map(c=>c.productName).join(", "),ze=Z===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ee(Z,e.currency)}`;E.textContent=ze?[gt,ze].filter(Boolean).join(" \xB7 "):bt,s.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,i.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=P.panel,E.style.cssText=P.summary,m.style.cssText=P.actions,s.style.cssText=P.primary,i.style.cssText=P.secondary,Ne(s),s.onclick=()=>{q(ne)};let Ge=async()=>{let c=await o.cancel();p||(n.remove(),$=null,await N(c))};i.onclick=()=>{l=Ge,q(Ge)};let L=d.createElement("div");if(L.style.cssText=P.terms,I){for(let f of z){if(Z===null&&f===Qe)continue;let v=d.createElement("p"),M=ee(f.amountMinor,e.currency)+ie(f.interval,ue,f.intervalCount);v.textContent=Z!==null&&Re!==void 0?je(M,Re):M,L.append(v)}let c=I.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...I.expectedEffects.map(v=>v.description),...I.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=f,L.append(v)}}else{for(let c of e.lines){if(Z!==null||c!==Qe){let f=d.createElement("p"),v=`${ee(c.catalogAmountMinor,e.currency)}${ie(c.interval,ue,c.intervalCount??1)}`;f.textContent=Z!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+je(v,c.trial.days):`${c.productName} \xB7 ${v}`,L.append(f)}for(let f of c.prepaid??[]){let v=d.createElement("p"),M=o.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(vt=>vt.internalFeatureId===f.internal_feature_id);v.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${a?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(v.textContent+=ie(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",ue,M.resetCount)),L.append(v)}if(c.trial){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.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.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,i),n.append(E,...L.childElementCount?[L]:[],m),U.prepend(n),g?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),$=n,l=null}async function le(){if(!A)return;if(l=le,!ge){let n=o.view,s=n?.document.buttons[A.actionId],i=n&&s?.type==="checkout"?te(s.product,A.selection,n.capabilities):null;if(!i)throw new x("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:A.actionId,productVersionId:i});if(p)return;m!==void 0&&(A.offerId=m),ge=!0}if(!R()){y.hidden=!1;return}let e=await o.preview(A);if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&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=a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await ne()}catch(s){p||Q(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function X(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),o.signal?.removeEventListener("abort",B),C.finish("dismissed"),Ue?.(),pe.abort(),_e?.disconnect(),g?.destroy(),F?.destroy(),o.destroy(),w.open&&w.close(),w.remove(),k.remove(),O(),e==="dismiss"&&G(r.onDismiss))}S=X;async function ke(){if(!j||p||ae||V==="closing"||!V&&!R())return;if(!D){X("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),b.hidden=!1,H.replaceChildren(e,b),V="closing",b.setAttribute("aria-disabled","true"),b.focus({preventScroll:!0});try{await D.dismiss()}catch(t){p||G(r.onError,t)}p||(V="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",b.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",b.removeAttribute("aria-label"),b.removeAttribute("aria-disabled"))}b.onclick=()=>{ke()},w.addEventListener("cancel",e=>{e.preventDefault(),ke()}),y.onclick=()=>{l&&q(l)};function Ie(e){C.finish("error",e),X()}function Ae(){if(!(!Ve||j||p||ae||g&&!R()))try{let e=t=>{we?.(),g&&(w.showModal(),g.responsive&&w.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(w,g.type,g.responsive)),j=!0};D?D.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ie(e),Q(e)}}try{if(J.type==="inline")b.hidden=Object.values(h.document.buttons).some(t=>t.type==="close"),Me(),we=rt(k,T),T.append(k);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in J?t[J.size]+"px":"100vw"}`,w.setAttribute("aria-label",h.document.name),b.textContent="\xD7",b.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),et(b,h.document.screen.theme),Ke(h.document)?(b.hidden=!0,w.append(k)):w.append(b,k),T.append(w),g=Xe(w,{...h.document.screen,presentation:J},ye),g.latch(),g.responsive&&(k.style.display="flex",k.style.flexDirection="column",k.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),we=nt(w)}F=ut(Y,{mode:"live",rendererUrl:o.webViewUrl,title:h.document.name,hostPresentation:()=>g?.type??J.type,reportContentHeight:g?.responsive,onResize:t=>{if(!g?.responsive)return;let n=Math.min(t,he);Y.style.height=`${n}px`,g.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!j||p||V)return;if(!R()){Ee();return}let s=o.view,i=s?.document.buttons[t];if(!i)return;if(i.type==="close"){q(async()=>{await r.onAction?.(t),X(r.onAction?"action":"dismiss")});return}if(i.type==="action"){l=async()=>{if(i.action.type==="event"){if(!r.onEvent)throw new x("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(i.action.event)}else r.onOpenUrl?await r.onOpenUrl(i.action.url):d.defaultView?.location.assign(i.action.url);await r.onAction?.(t),l=null},q(l);return}if($&&o.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",g?.responsive||$.scrollIntoView?.({block:"nearest"}),$.querySelector("button")?.focus({preventScroll:!0});return}if((o.quote||A)&&o.canReselect===!1){let E=!!s&&!!o.quote&&ht(o.quote,s,i.product,n);Ce=!!o.quote&&!E,l=o.quote?()=>xe(E):le,q(l);return}let m=s&&te(i.product,n,s.capabilities);if(!s||!m){Q(new x("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,q(async()=>{let E={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:Oe(s.document.screen,m,n,s.capabilities)};be=!0,await r.onPurchaseIntent(E)});return}if(A&&A.actionId!==t){Q(new x("COMMAND_PENDING","Finish the current purchase"));return}A||(A={requestId:crypto.randomUUID(),actionId:t,selection:n},ge=!1),q(le)},onEscape:()=>{ke()},onError:t=>{let n=new Error(t);!j&&!p&&Ie(n),Q(n)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Ve=!0,Ae()}}),ye(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:De(h),serverInput:{bindings:[],answers:{}}}),Ue=o.subscribe?.(me),me(o.view??h),await C.wait(F.ready);let e=o.operation;(o.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>xe(),q(l))}catch(e){throw Ie(e),e}return{check:W,host:{get observing(){return fe},get recovery(){return ft()},async prepareFallback(){if(K||p||V||be)return{type:"recover",operationId:o.operation?.operationId??o.quote?.operationId??null,requestId:null};ce(!0);try{let e=await Ye(o);return e.type==="native"&&X(),e}finally{ce(!1)}},setSuspended(e){ae=e,k.hidden=e,e&&w.open?w.close():!e&&!j?Ae():!e&&!p&&j&&J.type!=="inline"&&!w.open&&w.showModal()},destroy:X,refresh:async()=>{if(!R()){if(o.view)return o.view;throw new x("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await o.refresh();return me(e),Ae(),e}}}}export{zt as showPaywall};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-77GCT2VP.js";import"./chunk-Q2TQLDEH.js";import"./chunk-CGSZBPSX.js";import"./chunk-VSWKFI3L.js";import"./chunk-MBKZYWPF.js";import"./chunk-PKY55SBA.js";import"./chunk-UWAZDSWO.js";import"./chunk-TNN4S6VO.js";import"./chunk-PNHGULO2.js";import"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-KAXKYBSI.js";import"./chunk-AZ53RDWO.js";import"./chunk-EUVKRGMO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
package/dist/popup.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-IVDXTPNR.js";import"./chunk-CTSSHAV7.js";import"./chunk-DVOYXRVB.js";import"./chunk-P3PXFIMG.js";import"./chunk-FCBTTR5W.js";import"./chunk-W5KG2IWX.js";import"./chunk-Z43N7U4U.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-4OBCF5H3.js";import"./chunk-GOYKJHDV.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
@@ -1 +1 @@
1
- import{b as S,c as E,d as T}from"./chunk-JPBLMVZR.js";import"./chunk-TEMI3X5X.js";import{a as A}from"./chunk-BSBHQVHH.js";import{e as P}from"./chunk-5SL2JQU3.js";import"./chunk-UIYOW47V.js";import{h as b,i as x,k as L}from"./chunk-NROHBY3P.js";import"./chunk-6O4IBSE3.js";import"./chunk-VGLBSYPV.js";import{F as C}from"./chunk-6YJ3CFPM.js";import"./chunk-LS4XNIXR.js";import"./chunk-ARIVUZUH.js";import"./chunk-6KAADDQL.js";import"./chunk-4GZKK2RE.js";import"./chunk-JOI5ZUBO.js";import"./chunk-QONPVFRV.js";import"./chunk-FKDUXXGT.js";import"./chunk-WYMP6O5B.js";import"./chunk-O7HHYO3I.js";import"./chunk-GRNHBOSS.js";import"./chunk-QE6T6NX6.js";import"./chunk-DVOYXRVB.js";import"./chunk-P3PXFIMG.js";import{a as r}from"./chunk-FCBTTR5W.js";import{h as R}from"./chunk-W5KG2IWX.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVM4JJBA.js";import"./chunk-Z43N7U4U.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
1
+ import{b as S,c as E,d as T}from"./chunk-VKDBROTE.js";import"./chunk-PQJJ5BSY.js";import{a as A}from"./chunk-77GCT2VP.js";import{e as P}from"./chunk-Q2TQLDEH.js";import"./chunk-CGSZBPSX.js";import{h as b,i as x,k as L}from"./chunk-S4JIOALC.js";import"./chunk-VSWKFI3L.js";import"./chunk-MBKZYWPF.js";import{F as C}from"./chunk-JPHYIUIR.js";import"./chunk-PKY55SBA.js";import"./chunk-UWAZDSWO.js";import"./chunk-TNN4S6VO.js";import"./chunk-PNHGULO2.js";import"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-KAXKYBSI.js";import"./chunk-AZ53RDWO.js";import"./chunk-EUVKRGMO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import{a as r}from"./chunk-7EPE2PUN.js";import{h as R}from"./chunk-VC2H3LFP.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-IVDXTPNR.js";import"./chunk-CTSSHAV7.js";import"./chunk-DVOYXRVB.js";import"./chunk-P3PXFIMG.js";import"./chunk-FCBTTR5W.js";import"./chunk-W5KG2IWX.js";import"./chunk-Z43N7U4U.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.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};
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-4OBCF5H3.js";import"./chunk-GOYKJHDV.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.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};
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as pn}from"./chunk-2AKQWIK6.js";import{a as I}from"./chunk-FODM46LT.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-QQ43HZVT.js";import{a as xt}from"./chunk-BSBHQVHH.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-5SL2JQU3.js";import"./chunk-UIYOW47V.js";import{a as Te,b as oe,c as yt,d as It,e as wt,f as xe,g as vt,h as _e,i as dn,j as ln,k as mn}from"./chunk-NROHBY3P.js";import{a as Et,b as Me}from"./chunk-6O4IBSE3.js";import"./chunk-VGLBSYPV.js";import{A as Tt,C as V,D as N,a as Oe,e as ft,f as ht,l as gt,m as j,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-6YJ3CFPM.js";import{c as f}from"./chunk-LS4XNIXR.js";import"./chunk-ARIVUZUH.js";import{e as at}from"./chunk-6KAADDQL.js";import{A as tt,B as Se,C as ae,E as ie,F as Ce,K as se,M as ce,N as nt,P as Ee,Q as rt,R as ot,d as Ge,e as je,h as we,p as ze,q as Ke,s as an,t as sn,w as cn,x as Q,y as J,z as re}from"./chunk-4GZKK2RE.js";import{A as Re,B as st,C as ct,H as ut,I as dt,J as be,K as Ae,S as pt,T as de,U as Y,V as lt,_ as mt,d as ve,f as Ze,g as et,u as q,z as it}from"./chunk-JOI5ZUBO.js";import"./chunk-QONPVFRV.js";import"./chunk-FKDUXXGT.js";import"./chunk-WYMP6O5B.js";import"./chunk-O7HHYO3I.js";import"./chunk-GRNHBOSS.js";import{a as Ne,b as Le}from"./chunk-QE6T6NX6.js";import{V as Xe,Y as We,la as ue,n as un,p as $e,q as Qe,r as Je}from"./chunk-DVOYXRVB.js";import{c as Ie}from"./chunk-P3PXFIMG.js";import{a as c}from"./chunk-FCBTTR5W.js";import{h as $}from"./chunk-W5KG2IWX.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVM4JJBA.js";import{b as u}from"./chunk-Z43N7U4U.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var Mt=4,_t=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results"],In=u.enum(_t),X=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...ie.shape,bridgeVersion:u.literal(Mt),capabilities:X(In,_t.length),checkKinds:X(u.enum(["access","metered","credit"]),3),preparationActions:X(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:X(u.enum(["auto_topup"]),1),nextActionTypes:X(u.enum(["redirect","authenticate"]),2),resultEvents:X(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),W={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He},Hn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read"]);function Z(e,n){return u.strictObject({bridgeVersion:u.literal(Mt),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[Z("bridge.ping",W["bridge.ping"]),Z("bridge.describe",W["bridge.describe"]),Z("requirement.check",W["requirement.check"]),Z("operation.prepare",W["operation.prepare"]),Z("benefit.claim",W["benefit.claim"]),Z("operation.read",W["operation.read"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",z="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
1
+ import{a as pn}from"./chunk-JAUJZWYJ.js";import{a as I}from"./chunk-6QJRT23Q.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-FDCINOOI.js";import{a as xt}from"./chunk-77GCT2VP.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-Q2TQLDEH.js";import"./chunk-CGSZBPSX.js";import{a as Te,b as oe,c as yt,d as It,e as wt,f as xe,g as vt,h as _e,i as dn,j as ln,k as mn}from"./chunk-S4JIOALC.js";import{a as Et,b as Me}from"./chunk-VSWKFI3L.js";import"./chunk-MBKZYWPF.js";import{A as Tt,C as V,D as N,a as Oe,e as ft,f as ht,l as gt,m as j,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-JPHYIUIR.js";import{c as f}from"./chunk-PKY55SBA.js";import"./chunk-UWAZDSWO.js";import{e as at}from"./chunk-TNN4S6VO.js";import{A as tt,B as Se,C as ae,E as ie,F as Ce,K as se,M as ce,N as nt,P as Ee,Q as rt,R as ot,d as Ge,e as je,h as we,p as ze,q as Ke,s as an,t as sn,w as cn,x as Q,y as J,z as re}from"./chunk-PNHGULO2.js";import{A as Re,B as st,C as ct,H as ut,I as dt,J as be,K as Ae,S as pt,T as de,U as Y,V as lt,_ as mt,d as ve,f as Ze,g as et,u as q,z as it}from"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-KAXKYBSI.js";import"./chunk-AZ53RDWO.js";import"./chunk-EUVKRGMO.js";import"./chunk-YBX2LLRG.js";import{a as Ne,b as Le}from"./chunk-TLGKBSXC.js";import{V as Xe,Y as We,la as ue,n as un,p as $e,q as Qe,r as Je}from"./chunk-4WBIACS2.js";import{c as Ie}from"./chunk-HZYCK4XJ.js";import{a as c}from"./chunk-7EPE2PUN.js";import{h as $}from"./chunk-VC2H3LFP.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import{b as u}from"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var Mt=4,_t=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results"],In=u.enum(_t),X=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...ie.shape,bridgeVersion:u.literal(Mt),capabilities:X(In,_t.length),checkKinds:X(u.enum(["access","metered","credit"]),3),preparationActions:X(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:X(u.enum(["auto_topup"]),1),nextActionTypes:X(u.enum(["redirect","authenticate"]),2),resultEvents:X(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),W={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He},Hn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read"]);function Z(e,n){return u.strictObject({bridgeVersion:u.literal(Mt),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[Z("bridge.ping",W["bridge.ping"]),Z("bridge.describe",W["bridge.describe"]),Z("requirement.check",W["requirement.check"]),Z("operation.prepare",W["operation.prepare"]),Z("benefit.claim",W["benefit.claim"]),Z("operation.read",W["operation.read"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",z="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
2
2
  ${n}
3
3
  POST
4
4
  ${J}
package/dist/visual.js CHANGED
@@ -1 +1 @@
1
- import{a as pe,c as fe}from"./chunk-OJM6ORHE.js";import{b as ue}from"./chunk-J6KIN4RH.js";import{a as Ve,b as re,c as ce,d as de}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-CK4QMCWN.js";import{a as ae,b as se,c as oe,d as le}from"./chunk-RCUBJJ7K.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVM4JJBA.js";import{b as o}from"./chunk-Z43N7U4U.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:ue(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=oe(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=ae(e.deviceIdCookie??"indiana_did"),T=se(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(ce(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=le(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=de(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=re(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
1
+ import{a as pe,c as fe}from"./chunk-OJM6ORHE.js";import{b as ue}from"./chunk-J6KIN4RH.js";import{a as Ve,b as re,c as ce,d as de}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-SBSLHDBE.js";import{a as ae,b as se,c as oe,d as le}from"./chunk-QZG2YXM4.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import{b as o}from"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:ue(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=oe(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=ae(e.deviceIdCookie??"indiana_did"),T=se(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(ce(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=le(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=de(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=re(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkerlandai/longplay-sdk",
3
- "version": "0.10.28",
3
+ "version": "0.10.29",
4
4
  "description": "Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- import{p as n,s as t}from"./chunk-6YJ3CFPM.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +0,0 @@
1
- import{a as $e,c as cn}from"./chunk-JGG4R75K.js";import{d as ln,f as De,g as Me,h as un,i as Ue,k as dn}from"./chunk-CTSSHAV7.js";import{$ as Le}from"./chunk-JOI5ZUBO.js";import{a as Ve,e as tn,f as rn,g as on,h as sn,i as an}from"./chunk-FKDUXXGT.js";import{b as en}from"./chunk-WYMP6O5B.js";import{R as Xe,qa as nn}from"./chunk-DVOYXRVB.js";import{a as C}from"./chunk-FCBTTR5W.js";import{b as pn,e as mn}from"./chunk-SLUA7ABW.js";import{d as fn}from"./chunk-RCUBJJ7K.js";import{a as oe}from"./chunk-DSPLGTQI.js";import{b as Ze}from"./chunk-O4KXODTJ.js";var qe=new WeakMap;function Fn(n){let v=n.view,m=v?.paywall?.resolution;if(!v||!["running","waiting"].includes(v.status)||v.stopped||!m||"document"in m||!n.resolvePaywall||n.identitySignal?.aborted)return;let e=JSON.stringify(m);if(qe.get(n)?.key===e)return;let p=JSON.parse(e),P=n.identitySignal,r=Promise.resolve().then(async()=>{P?.throwIfAborted();let o=await n.resolvePaywall(p);return P?.throwIfAborted(),o}),R={key:e,content:r};return qe.set(n,R),r.catch(()=>{}),()=>{qe.get(n)===R&&qe.delete(n)}}function wn(n,v){let m=qe.get(n);return qe.delete(n),m?.key===JSON.stringify(v)?m.content:n.resolvePaywall(v)}async function yn(n){let{session:v,load:m}=kn(n);try{return await m(),v}catch(e){throw v.destroy(),e}}function kn(n){let v=n.view;if(!v?.paywall)throw new C("INVALID_REQUEST","The current node is not a Paywall");let m=v.paywall.receiptId,e=v.nodeId,p=v.visit,P=v.paywall.resolution,r=v.paywall,R="document"in P?{document:P.document,offering:P.offering,capabilities:P.capabilities}:null;function o(){let i=r.resolution;return"document"in i?i:R&&{...i,document:R.document,offering:R.offering,capabilities:tn(i.capabilities,R.capabilities)}}function y(i){if(!rn(i,P))throw new C("INVALID_RESPONSE","The pinned Paywall binding changed")}let u=!1,k=new Set,T=null;function _(){let i=o();if(i&&!u)for(let f of k)oe(f,structuredClone(i))}async function E(){O();let i=o();if(i)return structuredClone(i);if(!T){let f=(async()=>{if("document"in r.resolution||!n.resolvePaywall)throw new C("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await wn(n,r.resolution);return O(),y(b),R={document:b.document,offering:b.offering,capabilities:b.capabilities},_(),o()})();T=f;let l=()=>{T===f&&(T=null)};f.then(l,l)}return T.then(f=>structuredClone(f))}let c=new AbortController,F=(n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===p&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,U=0,$=null,D=new Set,j=null,I=new Map;function V(i){if(i.purchase&&i.purchase.receiptId!==m)throw new C("INVALID_RESPONSE","Purchase receipt changed");let f=i.run.paywall;return i.purchase??(f?.receiptId===m?f:null)}function O(){if(u)throw new C("IDENTITY_CHANGED","Paywall presentation has closed")}function X(i,f,l){if(O(),f!==U||l!==void 0&&r.quote?.operationId!==l)return!1;let b=r.selectionGeneration??0,h=i.run.paywall;if(h?.receiptId===m){if((h.selectionGeneration??0)<(r.selectionGeneration??0))return!1;y(h.resolution)}let d=V(i),G=h?.receiptId===m&&(h.selectionGeneration??0)>b,Q=G?d?.quote??null:d?.quote??r.quote,Y=d?.operation??(Q?.operationId===r.quote?.operationId?r.operation:null);return Q&&Y&&on(Y,{operationId:Q.operationId},"Purchase operation changed"),(G||Q?.operationId!==r.quote?.operationId)&&(U++,h?.receiptId===m&&(F=h.purchaseRequestId)),r={...r,...h?.receiptId===m?h:{},quote:Q,operation:an(r.operation,Y,!0)},_(),!0}function A(i,f,l){return new Promise((b,h)=>{let d=!1,G=()=>{clearTimeout(se),c.signal.removeEventListener("abort",ee)},Q=ce=>{d||(d=!0,G(),b(ce))},Y=ce=>{d||(d=!0,G(),h(ce))},ee=()=>Y(new C("IDENTITY_CHANGED","Paywall presentation has closed")),se=setTimeout(()=>Y(new C("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,l)),Math.max(0,f-Date.now()));c.signal.addEventListener("abort",ee,{once:!0}),c.signal.aborted&&ee(),i.then(Q,Y)})}function N(i){return new Promise(f=>{let l=()=>{clearTimeout(b),c.signal.removeEventListener("abort",l),f()},b=setTimeout(l,i);c.signal.addEventListener("abort",l,{once:!0}),c.signal.aborted&&l()})}function M(i,f){O();let l=I.get(i)??n.pendingCommands?.find(d=>d.requestId===i)??n.pendingCommand;if(l?.operation==="submit"&&l.requestId===i&&l.nodeId===e&&l.visit===p){f.type==="paywall_quote"&&l.input.type==="paywall_quote"&&l.input.predecessor&&!f.predecessor&&(f={...f,predecessor:l.input.predecessor});let d=Le.parse(l),G=Le.parse({...l,input:f});if(d.operation!=="submit"||G.operation!=="submit"||JSON.stringify(d.input)!==JSON.stringify(G.input))throw new C("CONFLICT","A purchase request cannot change its input");return I.set(i,d),d}let b=n.view;if(!b||b.nodeId!==e||b.visit!==p||b.paywall?.receiptId!==m)throw new C("PRECONDITION_FAILED","The Paywall visit has changed");let h=Le.parse({operation:"submit",requestId:i,nodeId:e,visit:p,revision:b.revision,input:structuredClone(f)});if(h.operation!=="submit")throw new C("INVALID_REQUEST","A purchase submission is required");return I.set(i,h),h}async function de(i,f){O();let{requestId:l,input:b}=i,h=Date.now()+3e4;D.add(l);try{let d=await A(n.submit(i),h,l);for(;d.run.pendingRequest?.requestId===l&&Date.now()<h&&!u&&(await N(Math.min(1e3,h-Date.now())),!(u||Date.now()>=h));)d=await A(n.resume(l),h,l);if(u)throw new C("IDENTITY_CHANGED","Paywall presentation has closed");if(d.run.pendingRequest?.requestId===l)throw new C("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,l);if(!X(d,f,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new C("PRECONDITION_FAILED","The purchase selection has changed");j===l&&(j=null)}catch(d){throw j=l,d instanceof C&&d.code==="COMMAND_PENDING"&&d.status===void 0&&I.delete(l),d}finally{D.delete(l)}}async function ie(i){if(!r.quote)throw new C("INVALID_REQUEST","A quoted purchase is required");let f=i==="confirm"?"paywall_confirm":"paywall_cancel",l=[...I.values(),...n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[])].find(h=>h.operation==="submit"&&h.input.type===f&&"operationId"in h.input&&h.input.operationId===r.quote.operationId),b=l?.operation==="submit"&&l.input.type===f&&"operationId"in l.input&&l.input.operationId===r.quote.operationId?l.requestId:crypto.randomUUID();if(await de(M(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:r.quote.operationId}),U),!r.operation)throw new C("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(r.operation)}let w={get view(){return structuredClone(o())},get quote(){return r.quote?structuredClone(r.quote):null},get operation(){return r.operation?structuredClone(r.operation):null},get webViewUrl(){return n.webViewUrl},get canReselect(){return r.canReselect===!0},get recovery(){let i=n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[]),f=n.pendingPurchase;if(f&&(f.receiptId!==m||f.operationId!==r.quote?.operationId))return{type:"recover",operationId:f.operationId,requestId:i[0]?.requestId??null};let l=Ve({quote:r.quote,operation:r.operation,requestId:i[0]?.requestId??j??F,pending:D.size>0||i.length>0||j!==null,destroyed:u,canReselect:r.canReselect});return l.type==="recover"&&l.requestId===null&&!u&&n.hasDurableJournal===!0&&!r.quote&&!r.operation&&(r.selectionGeneration??0)===0&&!f&&!i.length&&!D.size&&!F?{type:"native",operationId:null}:l},get pendingCancellation(){return!u&&(n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===p&&i.input.type==="paywall_cancel"&&i.input.operationId===r.quote?.operationId)},subscribe(i){return u?()=>{}:(k.add(i),()=>k.delete(i))},async refresh(){O();let i=U,f=await n.get();if(X(f,i),f.run.paywall?.receiptId!==m)throw new C("PRECONDITION_FAILED","Paywall presentation has changed");return E()},preview(i){let f=o();if(!f)return Promise.reject(new C("PRECONDITION_FAILED","Load the Paywall presentation first"));if(F&&F!==i.requestId&&($||r.canReselect!==!0))return Promise.reject(new C("COMMAND_PENDING","Retry the original purchase before starting another"));let l=f.document.buttons[i.actionId],b=l?.type==="checkout"?en(l.product,i.selection,f.capabilities):null;if(!b)return Promise.reject(new C("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let h=nn(f.document.screen,b,i.selection,f.capabilities),d=F!==i.requestId&&(r.selectionGeneration??0)>0?{operationId:r.quote?.operationId??null,generation:r.selectionGeneration??0}:void 0;if(d&&r.canReselect!==!0)return Promise.reject(new C("COMMAND_PENDING","Original purchase requires authoritative termination"));let G;try{G=M(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(h).length?{featureQuantities:h}:{},...d?{predecessor:d}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(ee){return Promise.reject(ee)}if(F===i.requestId&&$)return $;F!==i.requestId&&U++;let Q=U;F=i.requestId;let Y=(async()=>{if(await de(G,Q),!r.quote)throw new C("INVALID_RESPONSE","The accepted quote is missing");return sn(r.quote,{productVersionId:b,featureQuantities:h},"The selected purchase changed"),structuredClone(r.quote)})();return $=Y,Y.then(()=>{$===Y&&($=null)},ee=>{$===Y&&($=null),F===i.requestId&&n.pendingCommand?.requestId!==i.requestId&&ee instanceof C&&ee.status!==void 0&&ee.status<500&&![401,425].includes(ee.status)&&(F=null)}),Y},confirm:()=>ie("confirm"),cancel:()=>ie("cancel"),async read(){if(O(),!r.quote)throw new C("INVALID_REQUEST","A quoted purchase is required");let i=r.quote.operationId,f=U,l=n.pendingCommands?.find(Q=>Q.operation==="submit"&&(Q.input.type==="paywall_confirm"||Q.input.type==="paywall_cancel")&&Q.input.operationId===i)??n.pendingCommand;l?.operation==="submit"&&(l.input.type==="paywall_confirm"||l.input.type==="paywall_cancel")&&l.input.operationId===i&&await n.settle?.(l.requestId);let b=await n.get(void 0,{receiptId:m,operationId:i});O();let h=V(b);if(h?.quote&&h.quote.operationId!==i||h?.operation&&h.operation.operationId!==i)throw new C("INVALID_RESPONSE","Purchase operation changed");let d=X(b,f,i),G=d?r.operation:h?.operation;if(!G)throw new C("INVALID_RESPONSE","The current purchase result is missing");return d&&D.size===0&&!(n.pendingCommands?.length??(n.pendingCommand?1:0))&&(j=null),structuredClone(G)},destroy(){u=!0,H(),k.clear(),c.abort(),I.clear()}},H=n.subscribe(i=>{u||i.nodeId!==e||i.visit!==p||i.paywall?.receiptId!==m||(i.paywall.selectionGeneration??0)<(r.selectionGeneration??0)||(y(i.paywall.resolution),r={...r,resolution:i.paywall.resolution},_())});return{session:w,load:E}}function gn(n){let v=new Set,m=new Set,e=null;async function p(o,y){let u=!1;for(;!n.stopped&&n.key===o&&n.client.pendingCommand?.requestId===y;){if(!n.client.settle)throw new C("COMMAND_PENDING","The original display acknowledgement is still pending");await n.client.settle(y),u=!0,n.client.pendingCommand?.requestId===y&&await new Promise(k=>setTimeout(k,1500))}n.stopped||n.key!==o||(u&&await n.client.get(),!(n.stopped||n.key!==o)&&v.add(o))}function P(o,y){e=y;let u=()=>{e===y&&(e=null),m.delete(o)};return y.then(u,k=>{u(),n.busy||n.fail(k)}),y}function r(o){if(n.reviewing||v.has(o)||m.has(o)||n.stopped)return;m.add(o);let y=async()=>{if(n.reviewing||n.stopped||n.key!==o||v.has(o)){m.delete(o);return}if(n.busy||n.client.pendingCommand){setTimeout(()=>{y()},250);return}let u=(async()=>{if(n.staleRead){if(await n.staleRead,n.stopped||n.key!==o)return;if(n.client.pendingCommand){setTimeout(()=>{y()},250);return}}let k=n.client.view,T=n.expected(),_=T.requestId;try{await n.client.submit({operation:"shown",...T})}catch(E){if(!(E instanceof C)||E.code!=="CONFLICT"||E.status!==409||n.client.pendingCommand)throw E;await n.client.get();let c=n.client.view;if(n.stopped||n.reviewing||n.key!==o||!c||!k||c.id!==k.id||c.source.versionId!==k.source.versionId||c.nodeId!==T.nodeId||c.visit!==T.visit||c.revision<=T.revision||c.stopped||!c.screen&&(!c.paywall||c.paywall.receiptId!==k.paywall?.receiptId)||!["running","waiting"].includes(c.status)||n.client.pendingCommand)throw E;let S=n.expected();_=S.requestId,await n.client.submit({operation:"shown",...S})}await p(o,_)})();P(o,u)};y()}function R(){if(e)return e;let o=n.client.pendingCommand;if(o?.operation!=="shown")return null;let y=n.key;return m.add(y),P(y,(async()=>{await n.client.retry(),await p(y,o.requestId)})())}return{report:r,settled:R,get inFlight(){return e}}}function vn(n){let v={},m=new Map;async function e(p){let P=n.client.view,r=P?.screen,R=r?.customerData.nodes[p.nodeId];if(n.stopped||n.busy||!P||!r||!R)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(p.action)){let E=n.document,c=E?Xe(E,p.nodeId):null,S=c?.type==="customer_data"?c.data.outputs?.[p.action]:void 0;S&&r.outputs.includes(S)?await n.perform(()=>n.client.submit({operation:"submit",...n.expected(),input:{type:"screen",output:S,answers:n.answers,selection:p.value?{[p.nodeId]:p.value}:{}}})):await n.onIntent?.(p,P);return}let y=p.action.startsWith("sources_")?R.resources.find(E=>E.key===p.value):null;if(p.action.startsWith("sources_")&&!y)throw new C("INVALID_REQUEST","Choose a current resource");let u=`${P.visit}:${p.nodeId}:${y?.key??""}`,k=m.get(u)??[null],_=v[p.nodeId]??{page:1,after:null,filter:"all",...y?{resourceKey:y.key}:{}};if(p.action==="filter"){let E=p.value;if(!E||!(R.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(E))throw new C("INVALID_REQUEST","Unknown data filter");_={page:1,after:null,filter:E},k.splice(0,k.length,null)}else if(p.action==="next"||p.action==="sources_next"){let E=y?.sources.at(-1),c=y?E?{kind:"ledger",cursor:{at:E.detail[0],id:E.id,type:"source"}}:null:r.dataCursors[p.nodeId];if(!c||!y&&!R.hasNext)return;k[_.page]=c,_={..._,page:_.page+1,after:c}}else if(p.action==="previous"||p.action==="sources_previous"){if(_.page<=1)return;_={..._,page:_.page-1,after:k[_.page-2]??null}}m.set(u,k),v={...v,[p.nodeId]:_},await n.perform(()=>n.client.get({nodeId:P.nodeId,visit:P.visit,revision:P.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},m.clear()}}}function hn(n){let{doc:v,holder:m,reviewHolder:e,mountScreenPreview:p}=n,P=!1,r,R=0,o=null,y="",u,k=new Map,T=c=>c?`${c.id}:${c.nodeId}:${c.visit}:${c.revision}:${c.paywall?.quote?.operationId??""}`:"";async function _(c){if(n.stopped||!n.client.review||P&&c===r&&u?.active)return;let S=!P||c!==r;P||(y=T(n.client.view),k.set(y,structuredClone(n.answers))),P=!0,r=c,m.hidden=!0,n.suspend(!0),e.hidden=!1;let F=++R;S&&(u?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),u=Me(e,n.loadingOptions,"funnel",()=>{E()}));let U=S?u:void 0;try{if(U?.start(!1,n.client.view?.locale),F!==R||n.stopped)return;let $=n.client.review(c),D=await(U?.wait($,De)??$);if(n.stopped||F!==R||!P)return;if(!D.review)throw new C("INVALID_RESPONSE","Historical projection is missing");o?.destroy(),o=null,U||e.replaceChildren();let j=v.createElement("div"),I=U?Ue(j,e):()=>{};e.append(j);let V=D.run.locale.startsWith("zh"),O=v.createElement("p");O.textContent=V?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",j.append(O);for(let[A,N]of D.review.pages.entries()){let M=v.createElement("button");M.type="button",M.textContent=V?`\u7B2C ${A+1} \u9875`:`Page ${A+1}`,M.onclick=()=>{_(N.receiptId)},j.append(M)}if(D.review.page){let A=D.review.page,N=v.createElement("div");N.inert=!0,j.append(N),o=p(N,{mode:"live",rendererUrl:n.client.webViewUrl,title:A.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{F===R&&!n.stopped&&U?.present(I)},onError:de=>{if(F!==R||n.stopped)return;let ie=new Error(de);U?.finish("error",ie),o?.destroy(),o=null,j.remove(),n.fail(ie)},onEscape:()=>{E()}});let M=o;if(M.update(A.document,D.run.locale,{serverInput:{bindings:A.inputs,answers:A.answers,values:A.values}}),await M.ready,n.stopped||F!==R||!P)return}let X=V?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"};for(let A of[...D.review.coupons.map((N,M)=>`${V?"\u4F18\u60E0\u5238":"Coupon"} ${M+1}: ${X[N.status]}`),...D.review.purchases.map((N,M)=>`${V?"\u8D2D\u4E70":"Purchase"} ${M+1}: ${cn(N.status,V)}`)]){let N=v.createElement("p");N.textContent=A,j.append(N)}D.review.page||U?.present(I),n.client.view&&await n.enqueue(n.client.view)}catch($){if(F!==R||n.stopped)return;U?.finish("error",$),o?.destroy(),o=null,e.replaceChildren(),n.fail($)}}async function E(){if(!P||n.stopped||!n.client.review)return;let c=++R;u?.finish("dismissed");try{if(await n.client.review(),n.stopped||c!==R)return;P=!1,R++,u?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),e.hidden=!0,m.hidden=!1;let S=n.client.view;T(S)!==y?(k.set(y,structuredClone(n.answers)),n.resetScreen()):(k.delete(y),n.suspend(!1)),S&&await n.enqueue(S)}catch(S){if(c!==R||n.stopped)return;o?.destroy(),o=null,e.replaceChildren(),n.fail(S)}}return{get active(){return P},get receipt(){return r},open:_,exit:E,get drafts(){return new Map([...k].map(([c,S])=>[c,structuredClone(S)]))},stop(){P=!1,R++,u?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),e.hidden=!0,m.hidden=!1}}}function In(n){if(!n.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let v=n.client.pageExperiments.bind(n.client),m=!1,e=!1,p=0,P=!1,r=!1,R="",o=()=>{let I=n.client.view;return JSON.stringify([I?.id,I?.source.versionId,I?.visit,I?.revision,I?.status,I?.stopped])},y=new Map,u=new Set,k={},T=new Map,_=pn(n.appManifestRelease),E=()=>{for(let I of y.values())I.effect.revert();y.clear()},c=()=>{E();for(let I of T.values())I();T.clear()};function S(I){if(m||u.has(I))return;u.add(I);let V=p;v(n.appManifestRelease,[I]).catch(O=>{u.delete(I),!m&&V===p&&oe(n.onError,O)})}async function F(){if(m)return;R=o();let I=n.client.view;if(!I||I.stopped||!["running","waiting"].includes(I.status)){p++,c();return}if(document.visibilityState==="hidden")return;if(P){r=!0;return}P=!0;let V=++p,O=`${I.id}:${I.visit}:${I.revision}`,X=location.href;try{let[A,{applyVisualVariation:N}]=await Promise.all([v(n.appManifestRelease),import("./visual-dom-5LUN4AHO.js")]),M=n.client.view;if(m||V!==p||!M||M.stopped||!["running","waiting"].includes(M.status)||`${M.id}:${M.visit}:${M.revision}`!==O||location.href!==X)return;let de=new Set,ie=new Set;for(let w of A.assignments){let H=`${A.payload.environmentId}:${w.experimentKey}`;if(ie.add(H),T.has(H)||T.set(H,mn(H,k)),!!w.inExperiment)for(let i of A.payload.experiments){if(i.key!==w.experimentKey||!Ze(location.href,i.urlPatterns??[]))continue;let f=i.meta?.findIndex(Q=>Q.key===w.variationKey)??-1,l=i.variations[f];if(!l?.renderGuard)continue;let b=w.receiptId+":"+i.changeId,h=JSON.stringify([w.variationKey,l]);de.add(b);let d=y.get(b);if(d?.signature===h){d.effect.applied&&S(w.receiptId);continue}y.get(b)?.effect.revert(),y.delete(b);let G=N(l,{requireUniqueTargets:!0,boundVariations:i.variations,allowJs:!1,onApplied:()=>S(w.receiptId),onError:Q=>oe(n.onError,Q)});y.set(b,{signature:h,effect:G}),G.applied&&S(w.receiptId)}}for(let[w,H]of y)de.has(w)||(H.effect.revert(),y.delete(w));for(let[w,H]of T)ie.has(w)||(H(),T.delete(w))}catch(A){V===p&&c(),!m&&V===p&&oe(n.onError,A)}finally{P=!1,r&&!m&&(r=!1,F())}}let U=n.client.subscribe(()=>{if(o()===R)return;R=o(),p++;let I=n.client.view;(!I||I.stopped||!["running","waiting"].includes(I.status))&&c(),e&&F()}),$=fn(()=>{p++,c(),e&&F()}),D=()=>{p++,E()};document.addEventListener("visibilitychange",D);let j=$e({document,run:async()=>{e&&await F()},delay:()=>e&&!m?15e3:void 0});return{async start(){e||m||(e=!0,await j.refresh())},refresh:F,destroy(){m=!0,p++,j.destroy(),document.removeEventListener("visibilitychange",D),U(),$(),c(),_.destroy()}}}var ze=5e3;async function Dn(n,v,m){let e=v,[{mountScreenPreview:p},{showPaywall:P}]=await Promise.all([import("./screen-renderer-EHGDVWEV.js"),import("./paywall-OATK5XFF.js")]),r=e.client.identitySignal;e.signal?.throwIfAborted(),r?.throwIfAborted();let R=e.appManifestRelease?In({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;R?.start();let o=n.ownerDocument,y=dn(o),u=o.createElement("section"),k=o.createElement("div"),T=o.createElement("div"),_=o.createElement("div"),E=o.createElement("button");_.hidden=!0,E.type="button";let c=o.createElement("p"),S=o.createElement("p"),F=o.createElement("button"),U=o.createElement("button"),$=o.createElement("button"),D=o.createElement("dialog"),j;u.dataset.indianaFunnel="",u.setAttribute("aria-busy","false"),u.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033";let I="display:flex;gap:12px;align-items:center;flex-wrap:wrap";T.style.cssText=I,c.setAttribute("role","status"),S.setAttribute("role","alert"),S.hidden=!0,F.type=U.type=$.type="button",T.append(F,c,S,$,E,U),u.append(k,_,T),n.append(u);let V=null,O=null,X=null,A="",N="",M="",de="",ie="",w=!1,H=0,i=!1,f="",l=null,b=Promise.resolve(),h=!e.client.view,d=m,G,Q,Y="",ee,se=!1,ce=null,ge=!1,Fe=()=>e.client.pendingCommand?.operation==="close",re=null,B=null,je=$e({document:o,run:async()=>{(!O?.observing||e.client.pendingCommand)&&await Ge()},delay:()=>{if(!(w||!X||!["running","waiting"].includes(X.status)&&!e.client.pendingCommand)&&!(O?.observing&&!e.client.pendingCommand))return X.pendingRequest||e.client.pendingCommand?1500:ze},hiddenDelay:()=>!w&&e.client.pendingCommand?15e3:void 0}),W=null;function He(){return B&&e.client.hasDurableJournal===!0&&W?.acknowledged===!0&&W.operationId===B.operationId&&e.client.view?.id===W.runId&&e.client.view?.status==="closed"&&e.client.view.revision===W.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?B:null}function Be(t){let s=t.run.paywall;if(W&&t.settlement?.requestId===W.requestId&&t.settlement.state==="settled"&&t.settlement.operationId===null&&t.run.id===W.runId&&t.run.status==="closed"&&!t.run.pendingRequest&&t.run.revision===W.revision+1&&t.run.nodeId===W.nodeId&&t.run.visit===W.visit&&s?.receiptId===W.receiptId&&s.selectionGeneration===W.selectionGeneration&&(s.quote?.operationId??null)===W.operationId&&(s.operation?.operationId??s.quote?.operationId??null)===W.operationId){let a=W.operationId===null&&s.selectionGeneration===0&&!s.quote&&!s.operation&&!s.purchaseRequestId,ne=Ve({quote:s.quote,operation:s.operation,requestId:s.purchaseRequestId,pending:!1,destroyed:!1,canReselect:s.canReselect});(a||s.canReselect===!0&&ne.type==="native")&&(W.acknowledged=!0)}}let Pe=null,Se=new Set,fe={},ae=(t,s=null)=>{w||(Pe=s,S.textContent=t instanceof Error?t.message:"Request failed",S.hidden=!1,$.hidden=e.client.pendingCommand===null,oe(e.onError,t))};function Ie(){let t=e.client.view;if(!t)throw new C("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let L=hn({client:e.client,doc:o,holder:k,reviewHolder:_,mountScreenPreview:p,loadingOptions:e,get stopped(){return w},get answers(){return fe},suspend(t){O?.setSuspended(t)},resetScreen(){A="",N="",M=""},enqueue:me,fail:ae}),Oe=gn({client:e.client,expected:Ie,fail:ae,get stopped(){return w},get reviewing(){return L.active},get key(){return A},get busy(){return H},get staleRead(){return l}}),Ne=vn({client:e.client,expected:Ie,perform:Ee,onIntent:e.onCustomerDataIntent,get stopped(){return w},get busy(){return H},get document(){return V?.document},get answers(){return fe}}),Ae=t=>`${t.id}:${t.nodeId}:${t.visit}`,Re=t=>t&&(t.screen||t.paywall)?Ae(t):"";function be(){let t=e.client.view;F.disabled=!L.active&&(H>0||!!e.client.pendingCommand||!t?.canBack||t.stopped||!["running","waiting"].includes(t.status)||!Re(t)||N!==Re(t)),We()}function We(){let t=e.client.view;F.hidden=!L.active&&!t?.canBack;let s=!!O&&!L.active;U.hidden=s&&!d?.active,E.hidden=!e.client.review||s&&!t?.canBack,s&&(c.textContent="");let a=F.hidden&&U.hidden&&$.hidden&&E.hidden&&S.hidden&&!c.textContent;T.style.cssText=a?I:`${I};padding:12px 20px`}async function Ye(t){if(!t)return;let s=e.client.view;await t;let a=e.client.view;if(!s||!a||a.id!==s.id||a.nodeId!==s.nodeId||a.visit!==s.visit||a.stopped||!["running","waiting"].includes(a.status))throw new C("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Ee(t,s=!1){if(!((H||ge||re||B)&&!s||w||L.active&&!s)){H++,u.setAttribute("aria-busy","true"),be(),S.hidden=!0,Pe=null;try{if(s||await Ye(Oe.inFlight),w)return;let a=await t();w||await me(e.client.view??a.run)}catch(a){ae(a,e.client.pendingCommand?.requestId??null)}finally{H=Math.max(0,H-1),u.setAttribute("aria-busy",String(H>0)),w||($.hidden=e.client.pendingCommand===null,be())}}}function ke(){je.schedule()}async function Ge(){if(!(w||i||H)){if(L.active){await L.open(L.receipt);return}i=!0;try{let t=e.client.pendingCommand;t&&e.client.settle&&await e.client.settle(t.requestId);let s=e.client.view,a=Ne.queries,ne=await e.client.get(s?.screen&&Object.keys(a).length?{nodeId:s.nodeId,visit:s.visit,revision:s.revision,components:a}:void 0);!w&&a===Ne.queries&&await me(e.client.view??ne.run)}catch(t){ae(t)}finally{i=!1}}}function Te(t,s){if(d?.active){let ne=d;return ne.setDismissHandler(()=>Ke(ne)),ne}let a=Me(n,e,"funnel",()=>Ke(a));return d=a,a.start(t,s),a}function Ke(t){w||se||(se=!0,t.finish("dismissed"),ve(),u.hidden=!0,e.client.view?Ce().finally(le):le())}function Qe(){clearTimeout(ee?.timeout),ee=void 0}function ve(){Qe(),G?.abort(),G=void 0,V?.destroy(),V=null,O?.destroy(),O=null,Q?.(),Q=void 0,D.open&&D.close(),k.replaceChildren(),A="",N="",M="",ie=""}function Je(t){let s=t.screen?.presentation;if(!s||s.type==="inline"){D.open&&D.close(),u.parentElement!==n&&n.append(u);return}u.parentElement!==D&&(D.append(u),n.append(D));let a={sm:420,md:640,lg:900};D.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in s?a[s.size]+"px":"100vw"}`,D.setAttribute("aria-label",(j?.screen===t.screen?.content.document.name?j?.label:void 0)??V?.document?.name??t.screen?.content.document.name??"Funnel")}async function bn(t){if(w||se||ge&&(Fe()||["running","waiting"].includes(t.status)))return;X=t,Pe&&e.client.pendingCommand?.requestId!==Pe&&(S.hidden=!0,Pe=null);let s=t.locale.startsWith("zh");if(E.textContent=s?"\u56DE\u770B":"History",F.textContent=L.active?s?"\u8FD4\u56DE\u5F53\u524D":"Return to current":s?"\u8FD4\u56DE":"Back",U.textContent=s?"\u5173\u95ED":"Close",$.textContent=s?"\u91CD\u8BD5":"Retry",be(),$.hidden=e.client.pendingCommand===null,c.textContent=t.pendingRequest?s?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?s?"\u7B49\u5F85\u4E2D":"Waiting":"",We(),f!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(f=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,oe(e.onState,structuredClone(t))),w||se)return;if((!t.pendingRequest||ge&&t.status==="closed")&&["closed","ineligible","failed"].includes(t.status)){le();return}if(t.stopped||e.client.configurationReady===!1){L.stop(),ve(),d?.finish("skipped"),u.hidden=!0,ke();return}if(u.hidden=!1,L.active){ke();return}let a=Re(t),ne=e.client.view;if(ne&&ne.revision>t.revision&&Re(ne)!==a)return;let xe=!t.instruction&&!t.pendingRequest&&t.nodeType==="screen"&&["running","waiting"].includes(t.status);a!==A&&(A&&d?.finish("dismissed"),ve(),A=a,fe={...t.answers},Ne.reset());let we=Ae(t);if(Y===we){u.hidden=!0;return}if(xe&&!a){u.hidden=!0;let q=Te(!0,t.locale);!w&&!se&&ee?.key!==we&&(Qe(),ee={key:we,timeout:setTimeout(()=>{let g=e.client.view;if(!q.active||!g||Ae(g)!==we)return;Y=we;let Z=new Error("Funnel screen preparation timed out");q.finish("error",Z),ve(),ae(Z)},De)}),ke();return}Qe();let te=q=>{let g=e.client.view;return!w&&!se&&!ce&&!q.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Re(g)===a},K=(q,g)=>{te(g)&&(Y=a,d?.finish("error",q),ve(),u.hidden=!0,ae(q))};if(a||(Je(t),t.instruction?.type!=="event"&&t.instruction?.type!=="open_url"&&d?.finish("skipped")),t.screen){let q=t.screen.content;if(!V){let z=t.screen.presentation.type!=="inline",ye=Te(z,t.locale);if(w||se)return;let ue=(G=new AbortController).signal;Je(t),Q=z?un(D):Ue(u,n),V=p(k,{mode:"live",rendererUrl:e.client.webViewUrl,title:q.document.name,onAction(pe,he={},En={}){if(L.active||!te(ue)||N!==a)return;fe={...fe,...En};let qn=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:_e})=>Object.hasOwn(fe,_e)).map(({variable:_e})=>[_e,fe[_e]]));Ee(()=>e.client.submit({operation:"submit",...Ie(),input:{type:"screen",output:pe,answers:qn,selection:he}}))},onAnswers:pe=>{L.active||!te(ue)||N!==a||(fe={...fe,...pe})},onCustomerDataIntent:pe=>{L.active||!te(ue)||N!==a||Ne.intent(pe).catch(ae)},onEscape:()=>{!te(ue)||N!==a||L.active||re||B||Ce()},onError:pe=>{let he=new Error(pe);N===a?ae(he):K(he,ue)},onRendered:pe=>{if(!(!te(ue)||N===a))try{ye.present(he=>{Q?.(),Q=void 0,pe&&(j={screen:q.document.name,label:pe},D.setAttribute("aria-label",pe)),z&&(D.showModal(),!he&&e.loading!=="host"&&ln(D,t.screen.presentation.type)),N=a,be()}),te(ue)&&Oe.report(a)}catch(he){K(he,ue)}}})}let g={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:fe,values:t.screen.values}},Z=JSON.stringify([q,t.locale,g.parameters,t.screen.inputs,t.screen.values]);if(Z!==M)V.update(q.document,t.locale,g),M=Z,de=JSON.stringify(g.capabilities),ie=JSON.stringify(g.customerData);else{let z=JSON.stringify(g.capabilities);z!==de&&(V.updateCapabilities(g.capabilities),de=z),JSON.stringify(g.customerData)!==ie&&(V.updateCustomerData(g.customerData),ie=JSON.stringify(g.customerData))}let x=V;if(x)try{await(d?.wait(x.ready)??x.ready)}catch(z){G&&K(z,G.signal)}}else if(t.paywall&&!O){let q=Te(!0,t.locale);if(w||se)return;let g=(G=new AbortController).signal;Je(t);let Z=await P(k,{loading:"host",signal:g,canInteract:()=>te(g)&&!L.active&&!re&&!B,beforeAction:async()=>{H++;try{await Ye(Oe.settled()),S.hidden=!0,Pe=null}finally{H=Math.max(0,H-1)}},start:()=>yn(e.client),onObservationChange:ke,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,checkoutNavigation:e.checkoutNavigation,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,onEvent:e.onEvent,onOpenUrl:x=>e.onOpenUrl?e.onOpenUrl({receiptId:t.paywall.receiptId,url:x,openIn:"same_window"}):o.defaultView?.location.assign(x),onAction:async x=>{if(L.active)return;let z=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:e.client.view?.revision??t.revision,input:{type:"screen",output:x,answers:{}}});await me(e.client.view??z.run)},onError:x=>{N===a?ae(x):K(x,g)}},{quoteError:x=>oe(e.onError,x),present(x){te(g)&&(q.present(()=>{x(),N=a,be()}),te(g)&&Oe.report(a))},async dismiss(){w||g.aborted||L.active||re||B||!ge&&!te(g)||(ge=!0,await Ce())}}).catch(x=>(K(x,g),null));!te(g)&&!(ge&&!w&&!g.aborted)?Z?.host?.destroy():Z&&(O=Z.host,O?.setSuspended(L.active))}if(w||se)return;be();let J=t.instruction;if(J&&(J.type==="open_url"||J.type==="event")&&!Se.has(J.receiptId)){let q=o.createElement("button");q.type="button",q.textContent=J.type==="open_url"?`${s?"\u524D\u5F80":"Continue to"} ${new URL(J.url).host}`:s?"\u7EE7\u7EED":"Continue",q.onclick=()=>{let g=Ie(),Z=J.type==="open_url"&&!e.onOpenUrl&&J.openIn==="new_window"?Cn(J.url):null;Ee(async()=>{let x="success";if(J.type==="open_url")if(e.onOpenUrl)try{x=await e.onOpenUrl({receiptId:J.receiptId,url:J.url,openIn:J.openIn})===!1?"failed":"opened"}catch(ye){oe(e.onError,ye),x="failed"}else x=J.openIn==="new_window"&&!Z?"failed":"opened";if(J.type==="event"){if(!e.onEvent)throw new C("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(J.event)}if(w||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new C("PRECONDITION_FAILED","The client action visit changed");let z=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:J.receiptId,outcome:x}});return Se.add(J.receiptId),J.type==="open_url"&&!e.onOpenUrl&&J.openIn==="same_window"&&o.defaultView?.location.assign(J.url),z})},d?.active?d.present(()=>k.replaceChildren(q)):k.replaceChildren(q)}!t.pendingRequest&&t.status==="completed"&&!Se.has(`complete:${t.id}`)&&(Se.add(`complete:${t.id}`),oe(e.onComplete,structuredClone(t))),ke()}function Cn(t){let s=o.defaultView?.open(t,"_blank")??null;return s&&(s.opener=null),s}function me(t){return be(),b=b.catch(()=>{}).then(async()=>{try{await bn(t)}catch(s){throw d?.active&&(Y=Ae(t),d.finish("error",s),ve(),u.hidden=!0),s}}),b}let Pn=e.client.subscribe(t=>{h||(!ge&&(t.stopped||e.client.configurationReady===!1||A&&N!==A&&(Re(t)!==A||["closed","ineligible","failed"].includes(t.status)))&&(ve(),d?.finish("dismissed"),u.hidden=!0),me(t).catch(ae))}),Rn=e.client.subscribeError?.(ae);function Ce(t){if(ce)return ce;if(w||!t&&(re||B))return Promise.resolve();let s=!t&&Fe();return!s&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(X=e.client.view,le(),Promise.resolve()):(ce=Ee(async()=>{let a=s?await e.client.retry():await e.client.submit({operation:"close",...t??Ie()});return t&&Be(a),a},!0).then(()=>{let a=e.client.view;a?.status==="closed"&&!Fe()&&(X=a,le())}).finally(()=>{ce=null}),ce)}function le(){R?.destroy(),!w&&(w=!0,e.signal?.removeEventListener("abort",le),r?.removeEventListener("abort",le),d?.finish("dismissed"),je.destroy(),Pn(),Rn?.(),ve(),L.stop(),D.remove(),u.remove(),y(),oe(e.onDismiss,X?structuredClone(X):null))}F.onclick=()=>{if(!F.disabled){if(L.active){L.exit();return}Ee(()=>e.client.submit({operation:"back",...Ie()}))}},E.onclick=()=>{L.open()},U.onclick=()=>{d?.active?d.dismiss():re||Ce()},$.onclick=()=>{Fe()?Ce():Ee(()=>e.client.retry())},D.addEventListener("cancel",t=>{t.preventDefault(),d?.active?d.dismiss():re||Ce()}),e.signal?.addEventListener("abort",le,{once:!0}),r?.addEventListener("abort",le,{once:!0});try{let t=e.client.view;if(t)((e.client.viewAgeMs??ze)>=ze||t.instruction?.type==="evaluate_segment")&&(l=Ge().finally(()=>{l=null})),await me(t);else{u.hidden=!0;let s=Te(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(w||se)throw new DOMException("Presentation cancelled","AbortError");let a=await s.wait(e.client.get(),De);h=!1,await me(e.client.view??a.run)}}catch(t){throw d?.finish("error",t),le(),t}return{destroy:le,refresh:Ge,get recovery(){let t=He();if(t)return t;if(!w&&!H&&!ge&&!re&&O){let s=O.recovery;if(s.type!=="native")return s}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??B?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(re)return re;let t=He();if(t)return Promise.resolve(t);let s=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??B?.operationId??null,a=()=>({type:"recover",operationId:s,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let K=O?.recovery;return Promise.resolve(K&&K.type!=="native"&&K.type!=="cancel"?K:a())}let ne=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(K=>K.operation==="close");if(w&&!(ne||B&&e.client.view?.status==="closed")||H||i||ce||L.active||!O&&!B&&!ne)return Promise.resolve(a());let xe=O,we=(async()=>{try{if(!B&&ne){let q=await e.client.retry();return await me(e.client.view??q.run),a()}if(!B){let q=await xe.prepareFallback();if(q.type!=="native")return q;if(e.client.hasDurableJournal!==!0)return a();B=q}let K=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(K.length){let q=K.find(Z=>Z.operation==="close");if(!q||!W||q.requestId!==W.requestId)return a();let g=await e.client.retry();Be(g),await me(e.client.view??g.run)}else{let q=e.client.view,g=q?.paywall;if(!q||!g||g.selectionGeneration===void 0||(g.quote?.operationId??null)!==B.operationId||B.operationId!==null&&g.canReselect!==!0)return a();let Z=g.selectionGeneration,x=await e.client.get();await me(e.client.view??x.run);let z=e.client.view,ye=z?.paywall;if(!z||!ye||!["running","waiting"].includes(z.status)||z.stopped||z.id!==q.id||z.nodeId!==q.nodeId||z.visit!==q.visit||ye.receiptId!==g.receiptId||ye.selectionGeneration!==Z||(ye.quote?.operationId??null)!==B.operationId||B.operationId!==null&&ye.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return a();let ue=Ie();W={runId:z.id,operationId:B.operationId,revision:ue.revision,requestId:ue.requestId,nodeId:z.nodeId,visit:z.visit,receiptId:ye.receiptId,selectionGeneration:Z,acknowledged:!1},await Ce(ue)}let J=He();return J?(le(),J):a()}catch(K){return ae(K),a()}})();re=we;let te=()=>{re===we&&(re=null)};return we.then(te,te),we},review:L.open,exitReview:L.exit,get unappliedDrafts(){return L.drafts}}}function yt(n,v,m){return Dn(n,v,m)}export{Fn as a,In as b,Dn as c,yt as d};
@@ -1 +0,0 @@
1
- import{_ as oe,d as Q,k as Y,o as ee,p as te,q as ne,t as O,v as re,y as ie}from"./chunk-JOI5ZUBO.js";import{a as F}from"./chunk-WYMP6O5B.js";import{C as I,D as S,F as R,I as X,K as w,L as P,M as H,O as k,U as h,V as D,W as C,X as A,a as T,h as J,k as K,pa as ae,w as Z,y as W}from"./chunk-DVOYXRVB.js";import{h as j}from"./chunk-W5KG2IWX.js";import{b as e}from"./chunk-Z43N7U4U.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()}),Je=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function Ke(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),xe=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),ve=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Se=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),se={condition:C.optional(),parentConditions:e.array(ve).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(xe).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Se).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},ce=e.strictObject({...se,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()}),we=e.strictObject({...se,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:ce,result:G})).max(100).optional()}),Oe=e.strictObject({defaultValue:h.optional(),rules:e.array(we).max(500).optional()}),je=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(),Oe),savedGroups:je,experiments:e.record(e.uuid(),ce)});var Ie=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),rt=Ie.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"})}),it=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),pe=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()}),ot=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),pe),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),le={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:Y.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},ue={...le,generation:v.shape.generation},Pe=e.discriminatedUnion("kind",[e.strictObject({...le,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...ue,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...ue,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:pe.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),at=e.strictObject({customerId:e.uuid().optional(),events:e.array(Pe).min(1).max(100)}),ke=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),st=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(ke).max(100),analyticsConfig:V});function me(t,r){let a=new Set,o=new Set,p=new Set,u=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(p.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(p.add(s),d.set(s,n),u.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function c(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ie(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),u.push(()=>{for(let x of b.rules??[]){c(x);for(let he of x.tracks??[])c(he.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),u.push(()=>c(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 u)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var de=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:")})]),Ce=P,Ae=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:Ce,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ae)}).strict(),jt=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 Ee(t))r.addIssue({code:"custom",message:o});for(let o of Fe(t))r.addIssue({code:"custom",message:o});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 Fe(t){let r=t.products.items.map(u=>u.productVersionId),a=Z(t.screen),o=new Set,p=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&p.push("products"),t.offeringVersionId||p.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(u=>!t.products.grouping.assignments.some(g=>g.tierId===u.id)))&&p.push("grouping");for(let u of Object.values(t.buttons))if(u.type==="checkout"){let g=u.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)))&&p.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)&&p.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&p.push("grouping")}),f||p.push("picker")}}return(!o.size||[...o].some(u=>!r.includes(u)))&&p.push("purchase"),w(t.screen,u=>{u.type==="stack"&&u.productSlot&&!u.bind?.plan&&p.push(`productBinding:${u.id}`),(u.type==="stack"||u.type==="button")&&u.bind?.plan&&!r.includes(u.bind.plan)&&p.push("binding"),u.type==="plan_picker"&&(!u.planIds?.length||u.planIds.some(g=>!r.includes(g)))&&p.push("binding")}),[...new Set(p)]}function Ee(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),H(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 c=t.buttons[m];f.id!==a.id&&c&&c.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 p=new Set;function u(f){if(!p.has(f)){p.add(f);for(let d of o.get(f)??[])u(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?u(g):r.push("initialPage");for(let f of t.screen.pages)p.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var fe=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(),It=e.object({rows:e.array(fe).max(200),nextCursor:e.uuid().nullable()}).strict(),Pt=fe.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),kt=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()]),Ct=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 _e=["customer_data","coupon_code"],ge=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Re=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,De=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ve=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),ze=e.strictObject({stripe:e.strictObject({prices:e.array(De).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(ge).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:ge,basePlanId:Re.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"})}),Ge=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(Ve).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:ze,prepaid:e.array(J).max(100).optional()}),Me=e.strictObject({digest:O,content:e.strictObject({discount:ee,duration:te,appliesTo:ne,displayCopy:de.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()})}),qe=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})]),Nt=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(),Ge),buttons:e.record(X,qe),coupons:e.record(e.uuid(),Me)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ae(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),re(o,_e).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let p=new Set,u=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&&p.add(b.plan),b?.coupon&&u.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>p.add(x)),n.defaultPlan&&p.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 p)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 c=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!==c.length||c.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!==u.size||s.some(n=>!u.has(n)))&&a("Coupons must be exactly the bound Coupons")}),ye=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 Be={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),Ne=j.extend({environmentId:e.uuid()}),be=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)}),$e=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(Be.maxArtifactBytes),generation:q.optional()}),Le=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:be,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),Qt=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Ne,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(),$e),funnels:e.record(e.uuid(),Le),paywalls:e.record(e.uuid(),ye).optional()}).superRefine((t,r)=>{let a=(o,p)=>{o!==null&&t.artifacts[o]?.kind!==p&&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 p of Object.values(o.versions))a(p.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 p of Object.values(o.versions))a(p.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 Ue(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function Yt(t){return Ue(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function en(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,c)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===c:i==="feature"&&a(l)===c)?.name,p=(i,c,l=o(c.type,c.resource))=>new $(i,{...c,...l?{step:l}:{}});for(let i of Object.values(t.references)){let c=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(c)throw p("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...c})}let u=me(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let c=a(i);if(!c)continue;let l=u.features[c],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:c};if(!l||!y)throw p("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||!Q(y,b)))throw p("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,c)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw p("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},c);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,c)}},m=(i,c)=>{if(g.has(i)||!r.features[i])throw p("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},c)};for(let i of t.graph.nodes)if(i.type==="condition")for(let c of i.cases)d(c.condition,i.name);for(let[i,c]of Object.entries(u.features)){let l=o("feature",i);for(let y of c.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,c]of Object.entries(u.experiments)){let l=o("experiment",i);d(c.condition,l);for(let y of c.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let c=u.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!c)throw p("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of c.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw p("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return be.parse({features:Object.keys(u.features).sort(),experiments:Object.fromEntries(Object.entries(u.experiments).map(([i,c])=>[i,c.variations.map(String)])),savedGroups:[...f].sort()})}function tn(t){return oe.parse(t)}export{E as a,Ke as b,ce as c,je as d,v as e,Ie as f,rt as g,it as h,ot as i,at as j,st as k,me as l,Nt as m,Be as n,Ne as o,$e as p,Qt as q,N as r,Ue as s,Yt as t,en as u,tn as v};
@@ -1 +0,0 @@
1
- function l(e){let n=!1,t,r,o=()=>{clearTimeout(t),t=void 0};function i(){if(o(),n)return;let d=e.document.visibilityState==="hidden"?e.hiddenDelay?.():e.delay();d!==void 0&&(t=setTimeout(()=>{u().catch(()=>{})},d))}function u(){if(n)return Promise.resolve();if(r)return r;o();let d=Promise.resolve().then(()=>n?void 0:e.run());r=d;let a=()=>{r===d&&(r=void 0),i()};return d.then(a,a),d}let s=()=>{e.document.visibilityState==="hidden"?i():u().catch(()=>{})};return e.document.addEventListener("visibilitychange",s),{schedule:i,refresh:u,destroy(){n=!0,o(),e.document.removeEventListener("visibilitychange",s)}}}function m(e,n,t){return new Promise(r=>{let o,i=()=>{clearTimeout(o),n.removeEventListener("visibilitychange",s),t.removeEventListener("abort",i),r()},u=()=>{clearTimeout(o),o=setTimeout(i,n.visibilityState==="hidden"?Math.max(e,3e4):e)},s=()=>{n.visibilityState==="visible"?i():u()};n.addEventListener("visibilitychange",s),t.addEventListener("abort",i,{once:!0}),u(),t.aborted&&i()})}var c={zh:{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"}};function v(e,n){return c[n?"zh":"en"][e]}export{l as a,m as b,v as c};
@@ -1 +0,0 @@
1
- import{a as T,b as se}from"./chunk-TEMI3X5X.js";import{b as re,h as ae,j as ce}from"./chunk-NROHBY3P.js";import{a as oe,b as j}from"./chunk-6O4IBSE3.js";import{c as Z,e as ee,f as te,g as H,h as G,j as ne}from"./chunk-VGLBSYPV.js";import{F as M,b as J}from"./chunk-6YJ3CFPM.js";import{a as b,b as f,c as m}from"./chunk-LS4XNIXR.js";import{b as W,j as X}from"./chunk-6KAADDQL.js";import{E as $}from"./chunk-JOI5ZUBO.js";import{b as ie}from"./chunk-GRNHBOSS.js";import{a as U}from"./chunk-QE6T6NX6.js";import{a as s}from"./chunk-FCBTTR5W.js";import{h as Q}from"./chunk-W5KG2IWX.js";import{b as K}from"./chunk-Z43N7U4U.js";import{a as z}from"./chunk-DSPLGTQI.js";var B=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new s("INVALID_STATE","Installation sequence exhausted");return t+1},Se=async t=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(t,e=>e.charCodeAt(0))))].map(e=>e.toString(16).padStart(2,"0")).join("");function _(t,e){return t.transaction(n=>{if(!Number.isSafeInteger(n.identitySeq)||n.identitySeq<0||!Number.isSafeInteger(n.addressSeq)||n.addressSeq<0||n.detachSeq!==null&&(!Number.isSafeInteger(n.detachSeq)||n.detachSeq<1||n.detachSeq>n.identitySeq))throw new s("INVALID_STATE","Installation journal is invalid");return e({...n})})}function ue(t,e,n){let r=null,o=0,a=0,d=0,y=Promise.resolve(),g=!1;if(t&&(!n||Q.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new s("SCOPE_MISMATCH","Push installation belongs to another scope");let l=()=>{if(g)throw new s("CLOSED","SDK client was destroyed");if(!t)throw new s("NOT_CONFIGURED","Configure this client's native Push host first");return t},O=i=>{if(i!==o)throw new s("IDENTITY_CHANGED","Identity changed during Push operation")};async function F(i){let c=l();if(!c.sha256&&!globalThis.crypto?.subtle)throw new s("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,A=>A.charCodeAt(0))):await Se(i);if(!/^[a-f0-9]{64}$/.test(u))throw new s("INVALID_STATE","Push credential digest is invalid");return u}function p(i){let c=G.parse(i);if(c.installationId.toLowerCase()!==l().installationId.toLowerCase())throw new s("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=l(),A={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},w=await u.sign(ne(i,u.scope,A));return{...A,signature:w}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=l(),c=o,u=r?await(e.session?.access()??r):null,A=_(i,v=>v),w;if(A.detachSeq!==null){let v=A.detachSeq,V=Z.parse(await S("detach",{sequence:v,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...V},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new s("INVALID_RESPONSE","Push detach acknowledgement is invalid");let x=p(k.installation);if(x.bound||x.identitySeq!==v)throw new s("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof s&&k.status===404)w=k;else if(!(k instanceof s)||k.status!==412)throw k}w||_(i,k=>({...k,detachSeq:k.detachSeq===v?null:k.detachSeq}))}if(O(c),!u){if(w)throw w;return null}let C=(await import("./operation-contracts-ROG5DVKX.js")).apiOperations.bindPushInstallation,D=C.request.parse(await S("bind",{sequence:d,platform:i.platform,credentialDigest:await F(u)}));O(c);let R=C.response.parse(await I(C.path,D,u));O(c);let N=p(R.installation);if(!N.bound||N.identitySeq!==d)throw new s("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return w&&A.detachSeq!==null&&d>A.detachSeq&&_(i,v=>({...v,detachSeq:v.detachSeq===A.detachSeq?null:v.detachSeq})),N}async function h(){l();let i=o,c=r?await(e.session?.access()??r):null;if(!c)throw new s("NOT_IDENTIFIED","Identify before reading this installation");let u=(await import("./operation-contracts-ROG5DVKX.js")).apiOperations.readPushInstallation,A=u.request.parse(await S("read",{credentialDigest:await F(c)}));O(i);let w=u.response.parse(await I(u.path,A,c));return O(i),p(w.installation)}function P(i=q){let c=y.catch(()=>{}).then(i);return y=c,c.catch(u=>{try{t?.onError?.(u instanceof Error?u:new Error("Push synchronization failed"))}catch{}}),c}async function E(i,c,u){let A=l(),w=c.identity,C=c.observation,D=r?await(e.session?.access()??r):null;if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");if(!D)throw new s("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new s("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await P(async()=>{if(O(w),await q(),O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let R=_(A,x=>u?x:{...x,addressSeq:B(x.addressSeq)}),v=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:R.addressSeq,credentialDigest:await F(D),...u?{challenge:u}:{}}),V=u?te.parse(v):ee.parse(v);if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,V,D);if(O(w),C!==a||_(A,x=>x).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");if(u){let{apiOperations:x}=await import("./operation-contracts-ROG5DVKX.js");if(O(w),C!==a||_(A,Oe=>Oe).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");let Ae=x.updatePushAddress.response.parse(k),L=p(Ae.installation);if(!L.bound||L.identitySeq!==d||L.addressSeq!==R.addressSeq||L.connectionId!==i.connectionId||L.addressStatus!=="active")throw new s("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return L}if(!k||typeof k!="object"||!("recovery"in k))throw new s("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return H.parse(k.recovery)})}return{recoveryObserver(){l();let i={identity:o,observation:++a};return{async request(c){return H.parse(await E(c,i))},async confirm(c,u){return G.parse(await E(u,i,c))}}},identify(i){if(!t)return;d=_(t,u=>({...u,identitySeq:B(u.identitySeq)})).identitySeq,r=i,o++,a++},reset(){if(t)try{_(t,i=>{let c=B(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,o++,a++}},start(){t&&!g&&P()},destroy(){g=!0,r=null,o++,a++},async sync(){return await P()},read:h,async recover(){let i=l(),c=o,u=d;return a++,await P(async()=>{O(c);let A=await h();return O(c),d=_(i,C=>{if(C.identitySeq!==u)throw new s("IDENTITY_CHANGED","A newer installation intent exists");return{...C,identitySeq:B(Math.max(C.identitySeq,A.identitySeq)),addressSeq:Math.max(C.addressSeq,A.addressSeq)}}).identitySeq,await q()})},tokenObserver(){l();let i=++a,c=o;return async u=>{if(i!==a||c!==o)return null;let A=l(),w=r?await(e.session?.access()??r):null;if(!w)throw new s("NOT_IDENTIFIED","Identify before registering a Push token");if(await P(),O(c),i!==a)return null;let C=_(A,v=>({...v,addressSeq:B(v.addressSeq)})),D=(await import("./operation-contracts-ROG5DVKX.js")).apiOperations.updatePushAddress,R=D.request.parse(await S("address",{...u,sequence:C.addressSeq,credentialDigest:await F(w)}));if(O(c),i!==a)return null;let N=await I(D.path,R,w);return O(c),i!==a||_(A,v=>v).addressSeq!==C.addressSeq?null:p(D.response.parse(N).installation)}}}}function de(t,e){let n={async preference(r){let o=await f(t,"readMessagingPreference");return(await m(t,o,{channel:r})).preference},async setPreference(r){r=b(r);let o=await f(t,"setMessagingPreference");return(await m(t,o,r)).preference}};return{messaging:n,push:{sync:e.sync,read:e.read,recover:e.recover,tokenObserver:e.tokenObserver,recoveryObserver:e.recoveryObserver,async preference(){return n.preference("push")},async setPreference(r){return r=b(r),n.setPreference({...r,channel:"push"})}}}}function le(t,e,n={}){let r=!1;function o(){if(r)throw new s("CLOSED","SDK client was destroyed")}let a=new Set,d=g=>{for(let l of a)try{l(g)}catch{}},y=t.session.subscribeIdentity(()=>{d(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:o,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return o(),a.add(g),()=>{a.delete(g)}},identify(g){o();let l=typeof g=="string"?g:g.accessToken;if(!U.test(l))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(l),t.identify(g)},reset(){if(!r)try{n.beforeReset?.()}finally{t.reset()}},destroy(){if(!r){r=!0,y(),a.clear();try{n.beforeDestroy?.(),e()}finally{t.dispose()}}}}}}function pe(t){return{async checkEntitlement(e){e=b(e),T(e);let n=await f(t,"checkEntitlement"),r=n.request.parse(e),o=await m(t,n,r);return oe(r.requirement,o.check,void 0,o.scope),o},async readHoldings(e={}){e=b(e);let n=await f(t,"readHoldings"),r={...n,request:n.request.omit({customerId:!0})};return m(t,r,e)}}}function fe(t){return{async readLedger(e){e=b(e);let n=await f(t,"readLedger");return m(t,n,{query:e})},async readCreditStatement(e){e=b(e),T(e);let n=await f(t,"readCreditStatement");return m(t,n,e)},async quoteBalance(e){e=b(e),T(e);let n=await f(t,"quoteBalance");return m(t,n,{command:e})}}}function me(t){return{async setupPayment(e){e=b(e),T(e);let n=await f(t,"setupPayment");return m(t,n,e)},async readPaymentSetup(e){e=b(e),T(e);let n=await f(t,"readPaymentSetup");return m(t,n,e)},async readBillingInvoice(e){e=b(e),T(e);let n=await f(t,"readBillingInvoice");return m(t,n,e)},async readBillingControls(e={}){e=b(e),T(e);let n=await f(t,"readBillingControls");return m(t,n,e)},async prepareBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"prepareBillingAuthorization");return m(t,n,e)},async confirmBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"confirmBillingAuthorization");return m(t,n,e)},async setBillingCoupons(e){e=b(e),T(e);let n=await f(t,"setBillingCoupons");return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"revokeBillingAuthorization");return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){e=b(e),T(e);let n=await f(t,"listBillingInvoices");return m(t,n,e)},async confirmBillingAdjustment(e){e=b(e),T(e);let n=await f(t,"confirmBillingAdjustment");return m(t,n,e)}}}function ye(t){return{async redeemReward(e){return e=b(e),T(e),(await m(t,await f(t,"redeemReward"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return e=b(e),T(e),(await m(t,await f(t,"claimRewardProduct"),e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return e=b(e),T(e),(await m(t,await f(t,"createReferralCode"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){let r=await m(t,await f(t,"redeemCoupon"),{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async claimCoupon(e,n=crypto.randomUUID()){let r=await m(t,await f(t,"grantOffer"),{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async listOffers(){return(await m(t,await f(t,"listOffers"),{},{response:"Invalid offers response"})).offers}}}function Ie(t){return{...pe(t),...fe(t),...me(t),...se(t),...ye(t)}}function he(t){return{async resolveContent(e){e=b(e),T(e);let n=await f(t,"resolveContent");return m(t,n,e)},async resolvePaywall(e){e=b(e),T(e);let n=await f(t,"resolvePaywall"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.paywall.check,o.scope),o},async resolveOffering(e){e=b(e),T(e);let n=await f(t,"resolveOffering"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.check,o.scope),o}}}var Y=t=>new TextEncoder().encode(JSON.stringify(t)).length,we=16384,Pe=5e3,Ce=6e4,Re=5;function Te(t){return t instanceof s&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function ge(t,e){let n=0,r,o=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],d=null,y,g=0;function l(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function O(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(O)},Math.min(Pe*2**g,Ce)),typeof y=="object"&&"unref"in y&&y.unref())}function F(h){if(l(),r&&Date.now()<r.until&&!W(r.config,h.kind))return;q();let P=X.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(Y({events:[P]})>we)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(P)),O()}function p(h,P={},E={}){F({kind:"custom",name:h,properties:P,...E})}async function S(h=!1){if(l(),d)return d;let P=n,E=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&P===n;){let u=[],A=Y({events:[]});for(let C of a.slice(0,Math.min(c,100))){let D=Y(C)+(u.length?1:0);if(u.length&&A+D>we)break;u.push(C),A+=D}let w;try{let C=await f(t,"trackEvents");if(w=await m(t,C,{events:u},void 0,{keepalive:h}),P!==n)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==u.length||w.rejections.length!==w.rejected)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(C){throw P===n&&(g++,(Te(C)||g>=Re)&&(a.splice(0,u.length),g=0)),C}g=0,o(w.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=w.inserted,i.duplicates+=w.duplicates,i.rejected+=w.rejected,i.skipped+=w.skipped,i.rejections.push(...w.rejections)}return i})();d=E;try{return await E}finally{d===E&&(d=null)}}let I;function q(){if(I||typeof document>"u")return;let h=()=>{document.visibilityState==="hidden"&&e()&&a.length&&S(!0).catch(()=>{})};document.addEventListener("visibilitychange",h),I=()=>document.removeEventListener("visibilitychange",h)}return{rememberConfiguration:o,track:p,observe:F,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,d=null},detachVisibility(){I?.(),I=void 0}}}function ve(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}var qe=new Set([...$,"merchandiseId","merchandise"]);function ke(t){let e=ve(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!qe.has(r))),...e?{merchandise:e}:{}}}function Ee(t,e,n,r,o){if(o&&r&&(o.scope.projectId!==r.projectId||o.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,d=new Set;function y(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(l={}){o||y();let O=a,F=!1,p=async()=>{if(F||O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let R=o?{scope:{projectId:o.scope.projectId,environment:o.scope.environment},payload:await o.features()}:await m(t,await f(t,"getFeatures"),{});if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(R.scope.projectId!==r.projectId||R.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(R.payload.analyticsConfig),R},S=await p(),I=!0,q,h=R=>{try{l.onError?.(R)}catch{}},P=(R,N)=>{try{let v=ve(N);n.observe({...R,...v?{merchandise:v}:{}})}catch(v){h(v)}},E=ae({assertUsable:o?.assertFeatures,scope:S.scope,attributes:l.attributes,onError:l.onError,load:async()=>I?(I=!1,S.payload):(await p()).payload,evaluateRemote:async R=>{if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let N=await f(t,"evaluateFeatures"),v=await m(t,N,{...R,attributes:ke(R.attributes)});if(v.scope.projectId!==S.scope.projectId||v.scope.environment!==S.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:v.generation,evaluatedAt:v.evaluatedAt,expiresAt:v.expiresAt,features:v.features,...v.merchandiseContext?{merchandiseContext:v.merchandiseContext}:{}}},onExperimentViewed:(R,N,v,V)=>P({kind:"experiment_exposure",generation:V,experimentId:R.key,variationId:N.key},v),onFeatureUsage:(R,N,v,V)=>P({kind:"feature_usage",generation:V,feature:R,value:N.value??null,source:N.source,ruleId:N.ruleId,...N.experimentResult?{variationId:N.experimentResult.key}:{}},v)}),i=E.refresh;function c(){clearTimeout(q),!o&&(F||O!==a||!E.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(E.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let A=()=>{F||u().catch(h)},w=E.subscribe(c),C=o?.subscribe(()=>{!F&&o.fresh&&u().catch(h)});function D(){F||(F=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",A),w(),C?.(),E.reset(),d.delete(D))}d.add(D);try{await E.init(),(l.attributes?.merchandise||l.attributes?.merchandiseId)&&await E.refreshRemote()}catch(R){throw D(),R}return c(),!o&&typeof window<"u"&&window.addEventListener("focus",A),Object.assign(E,{refresh:u,destroy:D})}return{features:g,reset(l){a++,l();for(let O of d)O()}}}function be(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,r=K.object({funnelId:J.shape.id,funnelVersionId:J.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let o=Object.freeze(r.data);function a(d){if("customerId"in d)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in d&&d.funnelId!==void 0&&d.funnelId!==o.funnelId||"funnelVersionId"in d&&d.funnelVersionId!==void 0&&d.funnelVersionId!==o.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...d,...o}}return{async claimCoupon(d,y=crypto.randomUUID()){let g=await f(t,"grantOffer"),l=await m(t,g,a({couponId:d,requestId:y}));return{offer:l.offer,reason:l.reason}},async resolveOffering(d){d=b(d);let y=await f(t,"resolveOffering"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.check,l.scope),l},async resolvePaywall(d){d=b(d);let y=await f(t,"resolvePaywall"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.paywall.check,l.scope),l},async previewAttach(d){d=b(d);let y=await f(t,"previewAttach");return m(t,y,a(d))}}}function xt(t){return Ne(t)}function Ne(t){let e=ie(t),n=e.request,r;try{r=ue(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let o=le(e,()=>{d.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=ge(n,o.isIdentified),d=Ee(n,o.isIdentified,a,t.scope,t.configuration);return{session:e.session,...de(n,r),...Ie(n),...he(n),forFunnel(y){return o.assertActive(),be(n,y)},async features(y={}){return o.assertActive(),d.features(y)},track(y,g,l={}){return a.track(y,g,l)},flush(){return a.flush()},...o.methods}}function Mt(t){if(!U.test(t.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let e=ce({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),o=M({...t,runToken:r.runToken,initialResponse:r});o.identify(t.customerToken);let a=await o.get();return{...r,...a,controller:o}}}}function Kt(t){if(!t.scope)throw new s("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new s("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,o=new Set,a=new Map,d=new Map;async function y(p){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new s("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(p),I])}finally{clearTimeout(S)}}function g(p){throw p instanceof s&&(p.status===401||p.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear()),p}function l(p,S){if(S!==r)throw new s("IDENTITY_CHANGED","Process was detached during a request");let I=re.parse(p);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new s("SCOPE_MISMATCH","Process response belongs to another App/environment");if(e&&(e.run.id!==I.run.id||e.run.source.versionId!==I.run.source.versionId||e.run.source.id!==I.run.source.id||e.run.runExpiresAt!==I.run.runExpiresAt||e.run.identity.startedAs!==I.run.identity.startedAs||e.run.identity.participantId!==I.run.identity.participantId||e.run.identity.binding&&I.run.identity.binding&&e.run.identity.binding.id!==I.run.identity.binding.id))throw new s("INVALID_RESPONSE","The process changed its Run or Customer binding");if(!e||I.run.revision>=e.run.revision){if(e?.run.identity.binding&&!I.run.identity.binding)throw new s("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let A of o)z(A,I.run);I.run.instruction?.type==="authentication_required"&&z(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&d.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...P}=I.run,{contract:E,settlement:i,...c}=I,u=i&&(({accepted:A,...w})=>w)(i);return{...c,run:{...P,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let O=p=>(a.has(p)||a.set(p,e?.run.identity.binding?.id??null),a.get(p));async function F(p){let S=r,I=e?.run.identity.binding?.id??null,q=P=>{if(I!==(e?.run.identity.binding?.id??null))throw P;return g(P)};if(p.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new s("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(p.release,p.usedReceiptIds)).catch(q)}let h;if(p.operation==="get"){let{operation:P,customerToken:E,...i}=p;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:O(i.settlementRequestId)}:{}})).catch(q)}else if(p.operation==="review")h=await y(()=>t.adapter.review(p.receiptId)).catch(q);else{if(p.operation==="start")throw new s("INVALID_REQUEST","Use process.open for entry");{let{customerToken:P,...E}=p;h=await y(()=>t.adapter.command(E,O(E.requestId))).catch(q)}}return l(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(p){let S=r,I=await y(()=>t.adapter.open(p)).catch(g),q=l(I,S);if(!n){n=M({...t,runToken:I.runToken,initialResponse:q,process:{request:F,binding:O,restore(E){for(let[i,c]of Object.entries(E))a.set(i,c)}}});let h=n,P=h.submit;h.submit=async E=>{try{return await P(E)}catch(i){if(!(i instanceof s)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||E.operation!=="submit"||E.input.type!=="screen"||a.get(E.requestId)!==null)throw i;await h.settle?.(E.requestId),await h.get();let c=h.view;if(d.get(E.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==E.nodeId||c.visit!==E.visit||!e?.run.identity.binding)throw i;return P({...E,requestId:crypto.randomUUID(),revision:c.revision})}}}await n.get();for(let h of n.pendingCommands??[])a.has(h.requestId)&&a.get(h.requestId)!==(e?.run.identity.binding?.id??null)&&await n.settle?.(h.requestId);return{run:e.run,controller:n}},async syncIdentity(){let p=r;l(await y(()=>t.adapter.syncIdentity()).catch(g),p),await n?.get();for(let S of n?.pendingCommands??[])a.has(S.requestId)&&a.get(S.requestId)!==(e?.run.identity.binding?.id??null)&&await n?.settle?.(S.requestId);return e.run},async detach(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),await y(()=>t.adapter.detach())},forProcess(p){if(!e?.run.identity.binding)throw new s("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:p}},subscribe(p){return o.add(p),()=>{o.delete(p)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),o.clear()}}}export{xt as a,Ne as b,Mt as c,Kt as d};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-Z43N7U4U.js";var c=e.enum(["replace","stack_native"]);export{c as a};
@@ -1 +0,0 @@
1
- import{c as a,d as b}from"./chunk-3JQPCIKN.js";import"./chunk-JGG4R75K.js";import"./chunk-CTSSHAV7.js";import"./chunk-JOI5ZUBO.js";import"./chunk-QONPVFRV.js";import"./chunk-FKDUXXGT.js";import"./chunk-WYMP6O5B.js";import"./chunk-GRNHBOSS.js";import"./chunk-QE6T6NX6.js";import"./chunk-DVOYXRVB.js";import"./chunk-P3PXFIMG.js";import"./chunk-FCBTTR5W.js";import"./chunk-W5KG2IWX.js";import"./chunk-SLUA7ABW.js";import"./chunk-RCUBJJ7K.js";import"./chunk-FVM4JJBA.js";import"./chunk-Z43N7U4U.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.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-4GZKK2RE.js";import"./chunk-QONPVFRV.js";import"./chunk-QE6T6NX6.js";import"./chunk-P3PXFIMG.js";import"./chunk-W5KG2IWX.js";import"./chunk-Z43N7U4U.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-5SL2JQU3.js";import"./chunk-UIYOW47V.js";import"./chunk-VGLBSYPV.js";import"./chunk-ARIVUZUH.js";import"./chunk-6KAADDQL.js";import"./chunk-4GZKK2RE.js";import"./chunk-JOI5ZUBO.js";import"./chunk-QONPVFRV.js";import"./chunk-WYMP6O5B.js";import"./chunk-O7HHYO3I.js";import"./chunk-QE6T6NX6.js";import"./chunk-DVOYXRVB.js";import"./chunk-P3PXFIMG.js";import"./chunk-W5KG2IWX.js";import"./chunk-Z43N7U4U.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{b as Xe,c as Ze}from"./chunk-JGG4R75K.js";import{c as Qe,d as je,e as Ge,f as ce,g as We,h as Ye,i as Je,k as Ke}from"./chunk-CTSSHAV7.js";import{a as Fe,c as Ie,d as ze,g as Be}from"./chunk-FKDUXXGT.js";import{b as te}from"./chunk-WYMP6O5B.js";import"./chunk-GRNHBOSS.js";import"./chunk-QE6T6NX6.js";import{c as Z,o as ee,oa as ne,qa as Ve}from"./chunk-DVOYXRVB.js";import{c as Ee}from"./chunk-P3PXFIMG.js";import{a as A}from"./chunk-FCBTTR5W.js";import"./chunk-W5KG2IWX.js";import"./chunk-FVM4JJBA.js";import"./chunk-Z43N7U4U.js";import{a as j}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function et(c,n,P){if(n.status!=="complete")throw new A("INVALID_RESPONSE","A verified completed purchase is required");let w=c?ee.parse(c):null;if(await P.onComplete?.(n),!w||!P.check)return;let b=ee.parse(await P.check());if(b.internal_feature_id!==w.internal_feature_id||b.quantity!==w.quantity||w.observation!==void 0&&(b.observation===void 0||b.observation.requirementDigest!==w.observation.requirementDigest||b.observation.authority!==w.observation.authority||Ee(b.observation.subject)!==Ee(w.observation.subject)))throw new A("INVALID_RESPONSE","The access requirement changed");b.allowed&&await P.onAccessGranted?.(b)}var pt={none:0,sm:4,md:8,lg:14,full:9999},ft={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"};function mt(c){let[n,P,w]=[1,3,5].map(b=>{let k=Number.parseInt(c.slice(b,b+2),16)/255;return k<=.03928?k/12.92:((k+.055)/1.055)**2.4});return .2126*n+.7152*P+.0722*w}function tt(c){let n=mt(c.primary),P=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",w=`color-mix(in srgb, ${c.text} 22%, ${c.background})`,b=`${pt[c.radius]}px`,k=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${b};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;background:${c.background};color:${c.text};font:14px/1.5 ${ft[c.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",pinned:`position:sticky;bottom:0;z-index:1;box-sizing:border-box;padding-top:12px;background:${c.background};border-top:1px solid ${w}`,message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${w};border-radius:${b}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${k};background:${c.primary};color:${P}`,secondary:`${k};background:transparent;color:${c.text};box-shadow:inset 0 0 0 1px ${w}`,link:`${k};background:transparent;color:${c.text};opacity:.72;font-weight:500`}}function Ae(c){c.style.opacity=c.disabled?".55":"",c.style.cursor=c.disabled?"not-allowed":"pointer"}function Re(c){return Object.entries(c.document.buttons).filter(([,n])=>n.type==="checkout"&&n.product.type==="fixed"&&!te(n.product,{},c.capabilities)).map(([n])=>n)}async function Mt(c,n,P){let w=Ke(c.ownerDocument),b=()=>{E.finish("dismissed"),w()},k=()=>b(),E=We(c,n,"paywall",()=>{b(),j(n.onDismiss)});n.signal?.throwIfAborted(),n.signal?.addEventListener("abort",k,{once:!0});let G=null,$,y,Te;try{if(E.start(!0),E.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(G=n.check?ee.parse(await E.wait(n.check(),ce)):null,G?.allowed)return E.finish("skipped"),n.signal?.removeEventListener("abort",k),w(),await n.onAccessGranted?.(G),{check:G,host:null};let[e,t]=await Promise.allSettled([E.wait(import("./screen-renderer-EHGDVWEV.js")),E.wait(n.start().then(s=>(E.cancelled&&s.destroy(),s)),ce)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Te=e.value,$=t.value,n.signal?.throwIfAborted(),$.signal?.throwIfAborted(),$.signal?.addEventListener("abort",k,{once:!0});let r=$.view??await E.wait($.refresh(),ce);if(!r)throw new A("INVALID_RESPONSE","Paywall presentation is missing");$.signal?.throwIfAborted(),y=r}catch(e){throw E.finish("error",e),n.signal?.removeEventListener("abort",k),$?.signal?.removeEventListener("abort",k),$?.destroy(),w(),e}let i=$,{mountScreenPreview:nt}=Te,d=c.ownerDocument,le=new AbortController,R=d.createElement("section"),W=d.createElement("div"),L=d.createElement("div"),u=d.createElement("p"),m=d.createElement("button"),x=d.createElement("button"),g=d.createElement("dialog"),o=y.document.screen.strings.defaultLocale.startsWith("zh"),rt=o?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",it=o?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",I=tt(y.document.screen.theme);R.dataset.indianaPaywall="",R.setAttribute("aria-label",y.document.name),R.style.cssText=I.root,L.style.cssText=I.controls,u.style.cssText=I.message,u.setAttribute("role","status"),x.style.cssText=I.link,x.textContent=o?"\u5173\u95ED":"Close",m.style.cssText=I.secondary,m.textContent=o?"\u91CD\u8BD5":"Retry",m.hidden=!0,L.append(u,m,x),R.append(W,L);let Se=()=>{let e=q??L,t=[...e.children].every(r=>r===u?!u.textContent:r.hidden);e.style.cssText=t?I.controls.replace(/padding:[^;]+/,"padding:0"):`${I.controls};${I.pinned}`,fe()},Oe=typeof MutationObserver>"u"?void 0:new MutationObserver(Se);Oe?.observe(R,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Y=y.document.presentation,V,De,ue=!1,Ne=JSON.stringify(y.capabilities),$e=e=>J?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):Re(e);function de(e){if(p)return;y=e;let t=JSON.stringify(e.capabilities);t!==Ne&&(V?.updateCapabilities(e.capabilities,$e(e)),Ne=t),at(e)}let v,pe=0;function fe(){let e=d.defaultView;if(!v?.responsive||!e)return;let t=q??L,r=e.innerHeight-(v.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,r)}px`,t.style.overflowY="auto",t.style.flexShrink="0",pe=Math.max(1,r-t.getBoundingClientRect().height),V?.resizeViewport?.(pe,e.innerWidth)}let p=!1,J=!1,T=null,re=!1,Le=!1,F=!1,me,he=!1,M,q;function ot(){return J||p||M||he?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Ie(i)}let S=()=>!p&&!re&&!M&&n.canInteract?.()!==!1,ye=!1,l=null,U=null;function at(e){J||T||i.quote||i.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let we=new Map,ie=e=>Fe({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:i.canReselect});async function be(e){let t=e.merchantExecution;if(!(!S()||!e.checkoutUrl||n.checkoutNavigation==="after_confirmation"&&ie(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||we.get(e.operationId)===e.checkoutUrl)){we.set(e.operationId,e.checkoutUrl);try{n.onCheckoutUrl?await n.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(r){throw we.delete(e.operationId),r}}}let z=(e,t=!1)=>{if(t){let r=e instanceof A?e.code:void 0;r==="CAPABILITY_UNAVAILABLE"||r==="NOT_CONFIGURED"?(l=null,u.textContent=o?"\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==="COMMAND_PENDING"?u.textContent=o?"\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=o?"\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 A?e.message:o?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";m.hidden=l===null,t&&!v?.responsive&&u.scrollIntoView?.({block:"nearest"}),j(t&&P?.quoteError?P.quoteError:n.onError,e)},oe=new WeakMap;function ae(e){J=e,V?.updateCapabilities?.(y.capabilities,$e(y));for(let t of U?.querySelectorAll("button")??[])e?(oe.set(t,t.disabled),t.disabled=!0):oe.has(t)&&(t.disabled=oe.get(t),oe.delete(t)),Ae(t)}function ge(){u.textContent=o?"\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 st(e){if(n.beforeAction)try{await n.beforeAction()}catch(t){throw l=e,t}}async function _(e){if(J||p)return;if(!S()){ge();return}let t=e===se,r=t?it:rt;ae(!0),m.hidden=!0,u.textContent=r;try{if(await st(e),p)return;if(!S()){l=e,m.hidden=!1,ge();return}await e()}catch(s){p||z(s,t)}finally{ae(!1),u.textContent===r&&(u.textContent="")}}async function ct(e){await et(G,e,n)}function Ue(e){return Ie(i).type==="recording"||ie(e).type==="recording"}function _e(e){let t=e.merchantTerms,r=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),a=t?r.length===1&&r[0]?.amountMinor===s&&r[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],C=s===null?Z(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):Z(s,e.currency)+(a?ne(a.interval,o?"zh-CN":"en",a.intervalCount??1):""),H=e.lines.map(B=>B.productName).join(", ");return{label:H?`${H} \xB7 ${C}`:C,recurring:a}}async function O(e,t=n.checkoutNavigation!=="after_confirmation"){if(p)return;if(!S()){l=async()=>O(await i.read()),m.hidden=!1;return}if(u.textContent=Ze(e.status,o),Ue(e)){let a=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=a?o?"\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.":o?"\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.",m.textContent=o?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>O(await i.read()),m.hidden=!1;return}if(e.problem){let a=e.problem;l=X,m.textContent=o?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",z(new A(a.code,a.reason==="RESULT_UNKNOWN"?o?"\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.":a.phase==="fulfillment"?o?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":a.code==="CAPABILITY_UNAVAILABLE"?o?"\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.":a.code==="NOT_CONFIGURED"?o?"\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.":o?"\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,a));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=o?"\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"){l=null,await ct(e);return}if(e.status!=="pending"){if(i.canReselect===!1){u.textContent=o?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",m.textContent=o?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>O(await i.read()),m.hidden=!1;return}e.status==="cancelled"?u.textContent=o?"\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=o?"\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."),m.textContent=o?"\u91CD\u8BD5":"Retry",l=null,T=null;return}if(!t&&ie(e).type==="checkout"){let a=i.quote,C=a?.operationId===e.operationId?_e(a).label:"";u.textContent=(C?`${C} \u2014 `:"")+(o?"\u539F\u4ED8\u6B3E\u5C1A\u672A\u5B8C\u6210\uFF0C\u53EF\u7EE7\u7EED\u539F\u6536\u94F6\u53F0\u3002":"Payment is unfinished. Continue the original checkout."),m.textContent=o?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",l=async()=>O(await i.read(),!0),m.hidden=!1;return}await be(e);let r=Date.now()+6e5,s=2e3;ue=!0,j(n.onObservationChange,!0);try{for(;!p&&Date.now()<r;){if(await Xe(s,d,le.signal),p)return;if(!S()){l=async()=>O(await i.read()),m.hidden=!1;return}let a=await i.read();if(!t&&ie(a).type==="checkout"){await O(a,!1);return}if(!a.problem&&a.status==="pending"&&await be(a),a.status!=="pending"||a.problem||Ue(a)){await O(a);return}s=Math.min(s*1.5,3e4)}}finally{ue=!1,j(n.onObservationChange,!1)}l=async()=>O(await i.read()),m.hidden=!1}async function ve(){let e=await i.read();if(p)return;if(!S()){l=ve,m.hidden=!1;return}let t=i.quote;if(t&&Be(e,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&e.status==="pending"&&e.quoteFinalized===!1&&!e.confirmedAt&&!e.checkoutUrl&&!e.nativePurchase&&!e.merchantExecution&&!e.problem&&!i.pendingCancellation){Me(t);return}await O(e)}async function X(){U?.remove(),U=null,l=X;let e=await i.confirm();if(!S()){l=X,m.hidden=!1;return}if(e.problem){await O(e);return}if(e.status==="pending"){if(e.checkoutUrl)await be(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!n.onPurchase)throw new A("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await n.onPurchase({operation:e,signal:le.signal})}}l=async()=>O(await i.read()),await O(e,!0)}function Me(e){U?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?o?"\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 r=d.createElement("div"),s=d.createElement("button"),a=d.createElement("button"),C=d.createElement("div"),H=d.createElement("p"),B=e.merchantTerms,ke=o?"zh-CN":"en",lt=B?.subscriptionTerms?.items??[],{label:ut,recurring:qe}=_e(e);H.textContent=ut,s.textContent=o?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,a.textContent=o?"\u53D6\u6D88":"Cancel",r.style.cssText=I.panel,H.style.cssText=I.summary,C.style.cssText=I.actions,s.style.cssText=I.primary,a.style.cssText=I.secondary,Ae(s),s.onclick=()=>{_(X)};let He=async()=>{let f=await i.cancel();p||(r.remove(),U=null,await O(f))};a.onclick=()=>{l=He,_(He)};let N=d.createElement("div");if(N.style.cssText=I.terms,B){for(let h of lt){if(h===qe)continue;let D=d.createElement("p");D.textContent=Z(h.amountMinor,e.currency)+ne(h.interval,ke,h.intervalCount),N.append(D)}let f=B.subscriptionTerms?.trial;if(f){let h=d.createElement("p");h.textContent=o?`\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"}`,N.append(h)}for(let h of[...B.expectedEffects.map(D=>D.description),...B.requiredConsents.map(D=>D.summary)]){let D=d.createElement("p");D.textContent=h,N.append(D)}}else{for(let f of e.lines){if(f!==qe){let h=d.createElement("p");h.textContent=`${f.productName} \xB7 ${Z(f.catalogAmountMinor,e.currency)}${ne(f.interval,ke,f.intervalCount??1)}`,N.append(h)}for(let h of f.prepaid??[]){let D=d.createElement("p"),Q=i.view?.capabilities.plans[f.productVersionId]?.prepaid?.find(dt=>dt.internalFeatureId===h.internal_feature_id);D.textContent=`${Q?.name??h.internal_feature_id} \xB7 ${h.quantity} ${o?"\u4EFD":"packs"} \xD7 ${h.terms.units}`,Q&&(D.textContent+=ne(Q.reset==="week"||Q.reset==="month"||Q.reset==="year"?Q.reset:"one_time",ke,Q.resetCount)),N.append(D)}if(f.trial){let h=d.createElement("p");h.textContent=o?`\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"}`,N.append(h)}}if(!e.charge){let f=d.createElement("p");f.textContent=o?"\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.",N.append(f)}}for(let f of N.children)f.style.margin="0";C.append(s,a),r.append(H,...N.childElementCount?[N]:[],C),L.prepend(r),v?.responsive||r.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),U=r,l=null}async function se(){if(!T)return;if(l=se,!ye){let r=i.view,s=r?.document.buttons[T.actionId],a=r&&s?.type==="checkout"?te(s.product,T.selection,r.capabilities):null;if(!a)throw new A("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let C=await n.resolveOfferId?.({actionId:T.actionId,productVersionId:a});if(p)return;C!==void 0&&(T.offerId=C),ye=!0}if(!S()){m.hidden=!1;return}let e=await i.preview(T);if(p)return;let t=e.merchantTerms;if(n.confirmOnHostedCheckout&&S()&&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 r=o?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=r;try{await X()}catch(s){p||z(s)}finally{u.textContent===r&&(u.textContent="")}return}Me(e)}function K(e="destroy"){p||(p=!0,n.signal?.removeEventListener("abort",k),i.signal?.removeEventListener("abort",k),E.finish("dismissed"),De?.(),le.abort(),Oe?.disconnect(),v?.destroy(),V?.destroy(),i.destroy(),g.open&&g.close(),g.remove(),R.remove(),w(),e==="dismiss"&&j(n.onDismiss))}b=K;async function xe(){if(!F||p||re||M==="closing"||!M&&!S())return;if(!P){K("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=o?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",q||(q=d.createElement("div"),q.style.cssText=L.style.cssText,L.replaceWith(q),W.inert=!0),x.hidden=!1,q.replaceChildren(e,x),M="closing",x.setAttribute("aria-disabled","true"),x.focus({preventScroll:!0});try{await P.dismiss()}catch(t){p||j(n.onError,t)}p||(M="retry",e.textContent=o?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",x.textContent=o?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",x.removeAttribute("aria-label"),x.removeAttribute("aria-disabled"))}x.onclick=()=>{xe()},g.addEventListener("cancel",e=>{e.preventDefault(),xe()}),m.onclick=()=>{l&&_(l)};function Ce(e){E.finish("error",e),K()}function Pe(){if(!(!Le||F||p||re||v&&!S()))try{let e=t=>{me?.(),v&&(g.showModal(),v.responsive&&g.focus({preventScroll:!0}),!t&&n.loading!=="host"&&je(g,v.type,v.responsive)),F=!0};P?P.present(()=>E.present(()=>e(!0))):E.present(e)}catch(e){Ce(e),z(e)}}try{if(Y.type==="inline")x.hidden=Object.values(y.document.buttons).some(t=>t.type==="close"),Se(),me=Je(R,c),c.append(R);else{let t={sm:420,md:640,lg:900};g.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in Y?t[Y.size]+"px":"100vw"}`,g.setAttribute("aria-label",y.document.name),x.textContent="\xD7",x.setAttribute("aria-label",o?"\u5173\u95ED":"Close"),Ge(x,y.document.screen.theme),g.append(x,R),c.append(g),v=Qe(g,{...y.document.screen,presentation:Y},fe),v.latch(),v.responsive&&(R.style.display="flex",R.style.flexDirection="column",R.style.maxHeight="100%",W.style.overflow="clip",W.style.minHeight="0"),me=Ye(g)}V=nt(W,{mode:"live",rendererUrl:i.webViewUrl,title:y.document.name,hostPresentation:()=>v?.type??Y.type,reportContentHeight:v?.responsive,onResize:t=>{if(!v?.responsive)return;let r=Math.min(t,pe);W.style.height=`${r}px`,v.setContentHeight(r+(q??L).getBoundingClientRect().height)},onAction(t,r={}){if(!F||p||M)return;if(!S()){ge();return}let s=i.view,a=s?.document.buttons[t];if(!a)return;if(a.type==="close"){_(async()=>{await n.onAction?.(t),K(n.onAction?"action":"dismiss")});return}if(a.type==="action"){l=async()=>{if(a.action.type==="event"){if(!n.onEvent)throw new A("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(a.action.event)}else n.onOpenUrl?await n.onOpenUrl(a.action.url):d.defaultView?.location.assign(a.action.url);await n.onAction?.(t),l=null},_(l);return}if(U&&i.canReselect===!1){u.textContent=o?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",v?.responsive||U.scrollIntoView?.({block:"nearest"}),U.querySelector("button")?.focus({preventScroll:!0});return}if((i.quote||T)&&i.canReselect===!1){l=i.quote?ve:se,_(l);return}let C=s&&te(a.product,r,s.capabilities);if(!s||!C){z(new A("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(n.onPurchaseIntent){l=null,_(async()=>{let H={actionId:t,productVersionId:C,selection:structuredClone(r),featureQuantities:Ve(s.document.screen,C,r,s.capabilities)};he=!0,await n.onPurchaseIntent(H)});return}if(T&&T.actionId!==t){z(new A("COMMAND_PENDING","Finish the current purchase"));return}T||(T={requestId:crypto.randomUUID(),actionId:t,selection:r},ye=!1),_(se)},onEscape:()=>{xe()},onError:t=>{let r=new Error(t);!F&&!p&&Ce(r),z(r)},onRendered:t=>{t&&g.setAttribute("aria-label",t),Le=!0,Pe()}}),fe(),V.update(y.document.screen,y.document.screen.strings.defaultLocale,{capabilities:y.capabilities,unavailableActions:Re(y),serverInput:{bindings:[],answers:{}}}),De=i.subscribe?.(de),de(i.view??y),await E.wait(V.ready);let e=i.operation;(i.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=ve,_(l))}catch(e){throw Ce(e),e}return{check:G,host:{get observing(){return ue},get recovery(){return ot()},async prepareFallback(){if(J||p||M||he)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};ae(!0);try{let e=await ze(i);return e.type==="native"&&K(),e}finally{ae(!1)}},setSuspended(e){re=e,R.hidden=e,e&&g.open?g.close():!e&&!F?Pe():!e&&!p&&F&&Y.type!=="inline"&&!g.open&&g.showModal()},destroy:K,refresh:async()=>{if(!S()){if(i.view)return i.view;throw new A("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return de(e),Pe(),e}}}}export{Mt as showPaywall};