@tinkerlandai/longplay-sdk 0.10.37 → 0.10.39

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 (75) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/check-response-MNFEOKKE.js +1 -0
  3. package/dist/{chunk-T2KWLYCW.js → chunk-2Y5SGDC6.js} +1 -1
  4. package/dist/{chunk-LOLMUXHW.js → chunk-3JD3U45R.js} +1 -1
  5. package/dist/{chunk-VLSP3LRH.js → chunk-3S25TLC3.js} +1 -1
  6. package/dist/{chunk-XGNXZWZL.js → chunk-525K7BPJ.js} +1 -1
  7. package/dist/chunk-73ISTR7P.js +1 -0
  8. package/dist/{chunk-WZMZMJCK.js → chunk-BIT6YWM7.js} +1 -1
  9. package/dist/{chunk-6F4JS3RK.js → chunk-CBZ5GW4J.js} +1 -1
  10. package/dist/{chunk-AB7GEGZ2.js → chunk-CE5MAAIR.js} +1 -1
  11. package/dist/{chunk-ECKVJGXQ.js → chunk-CEMHQQAJ.js} +1 -1
  12. package/dist/chunk-CKVAV2W5.js +1 -0
  13. package/dist/{chunk-E7CCHUSO.js → chunk-DPIQ3SV7.js} +1 -1
  14. package/dist/{chunk-ZZIBLQCJ.js → chunk-GDD26ZDV.js} +1 -1
  15. package/dist/{chunk-PW5PIBSO.js → chunk-GGYBZWWY.js} +1 -1
  16. package/dist/{chunk-DDLSQSWO.js → chunk-GNAMACMK.js} +1 -1
  17. package/dist/{chunk-7XDQKZYA.js → chunk-HFD4CLCJ.js} +1 -1
  18. package/dist/{chunk-4KLXQKNO.js → chunk-HX36OZPQ.js} +1 -1
  19. package/dist/{chunk-XJRDO3NI.js → chunk-IGANLTKS.js} +1 -1
  20. package/dist/{chunk-YV6UFESO.js → chunk-IYHXEKAD.js} +1 -1
  21. package/dist/{chunk-UV4H6VCS.js → chunk-JAZHNQKO.js} +1 -1
  22. package/dist/{chunk-AHUYZ6IW.js → chunk-JBVZ6A6V.js} +1 -1
  23. package/dist/{chunk-AOGDCT4T.js → chunk-KIPUBMU3.js} +1 -1
  24. package/dist/{chunk-RE4OLOOT.js → chunk-LJBTEB2Q.js} +1 -1
  25. package/dist/{chunk-ZYOZSUZS.js → chunk-LZBJHWVH.js} +1 -1
  26. package/dist/{chunk-S43TYW3V.js → chunk-MTIOLSVM.js} +1 -1
  27. package/dist/{chunk-KFIL73QY.js → chunk-N774V4SQ.js} +1 -1
  28. package/dist/chunk-NSAEHRIT.js +1 -0
  29. package/dist/{chunk-LC6UCDWE.js → chunk-O2D3A4CS.js} +1 -1
  30. package/dist/{chunk-W74JLL2O.js → chunk-ONMIBSOC.js} +1 -1
  31. package/dist/{chunk-VIBJNB5B.js → chunk-PFPMK4IO.js} +1 -1
  32. package/dist/{chunk-OX2A3UD2.js → chunk-QCMFCK7Z.js} +1 -1
  33. package/dist/{chunk-OQRMAU2B.js → chunk-QXOUDODX.js} +1 -1
  34. package/dist/{chunk-TASEZY5T.js → chunk-TA4W6SXG.js} +1 -1
  35. package/dist/{chunk-2VMEDQHT.js → chunk-TLRRBUGP.js} +1 -1
  36. package/dist/{chunk-U7NX5ET2.js → chunk-TPXRO63H.js} +1 -1
  37. package/dist/{chunk-D3OYXTMC.js → chunk-U7XD4ZR5.js} +1 -1
  38. package/dist/{chunk-2KJLN65C.js → chunk-UKVWANDE.js} +1 -1
  39. package/dist/{chunk-Q676H74B.js → chunk-VYI6QRJW.js} +1 -1
  40. package/dist/{chunk-GH6FM44P.js → chunk-W3G4YIM5.js} +1 -1
  41. package/dist/{chunk-OCWSWXCW.js → chunk-YJS6NNIO.js} +1 -1
  42. package/dist/{chunk-HEHLFHW7.js → chunk-YURGISSB.js} +1 -1
  43. package/dist/{chunk-CY7OKV7E.js → chunk-ZORZA4WG.js} +1 -1
  44. package/dist/{content-QNBATPA2.js → content-HSMBQFM3.js} +1 -1
  45. package/dist/{funnel-host-purchase-FVYPBPET.js → funnel-host-purchase-4KOOLMXV.js} +1 -1
  46. package/dist/funnel-paywall-prerender-NX6ZQ7EU.js +1 -0
  47. package/dist/funnel-runtime-host-6XYYLVCI.js +1 -0
  48. package/dist/index.js +1 -1
  49. package/dist/merchant-bridge-contracts-ACGAMHU6.js +1 -0
  50. package/dist/native-shell.js +1 -1
  51. package/dist/openrouter.js +1 -1
  52. package/dist/operation-contracts-H27WHXQC.js +1 -0
  53. package/dist/page.js +1 -1
  54. package/dist/paywall-ZGG6DXO3.js +1 -0
  55. package/dist/paywall-content-ZQBE2EZP.js +1 -0
  56. package/dist/paywall-session-DBTBLLWI.js +1 -0
  57. package/dist/popup.js +1 -1
  58. package/dist/react-native.js +1 -1
  59. package/dist/screen-renderer-5SJCTMJH.js +1 -0
  60. package/dist/server.js +1 -1
  61. package/dist/visual.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/check-response-N22NNTIT.js +0 -1
  64. package/dist/chunk-2HBIBIOF.js +0 -1
  65. package/dist/chunk-HKXFCRVT.js +0 -1
  66. package/dist/chunk-WQ3O5RXN.js +0 -1
  67. package/dist/funnel-paywall-prerender-Z7RA4YDY.js +0 -1
  68. package/dist/funnel-runtime-host-TJPF3FJS.js +0 -1
  69. package/dist/merchant-bridge-contracts-67AYXZFI.js +0 -1
  70. package/dist/operation-contracts-EK4RCUWJ.js +0 -1
  71. package/dist/paywall-OAVC654P.js +0 -1
  72. package/dist/paywall-content-75XEM7K3.js +0 -1
  73. package/dist/paywall-session-U6SPRJRS.js +0 -1
  74. package/dist/screen-renderer-YIIT742O.js +0 -1
  75. /package/dist/{chunk-CR2XJ2CX.js → chunk-NOOIJXRN.js} +0 -0
@@ -1 +1 @@
1
- import"./chunk-OX2A3UD2.js";import"./chunk-E7CCHUSO.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-HEHLFHW7.js";import{a as i}from"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-AHUYZ6IW.js";import{b as A}from"./chunk-CR2XJ2CX.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-QCMFCK7Z.js";import"./chunk-DPIQ3SV7.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-YURGISSB.js";import{a as i}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-JBVZ6A6V.js";import{b as A}from"./chunk-NOOIJXRN.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-O2D3A4CS.js";import"./chunk-JAZHNQKO.js";import"./chunk-U7XD4ZR5.js";import"./chunk-HX36OZPQ.js";import"./chunk-MTIOLSVM.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-CE5MAAIR.js";import"./chunk-DPIQ3SV7.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{d as o,e as r,f as e,g as f}from"./chunk-6F4JS3RK.js";import"./chunk-OCWSWXCW.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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-CBZ5GW4J.js";import"./chunk-YJS6NNIO.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{a as Tt,c as Ot,d as et,f as tt,g as Dt,k as Lt}from"./chunk-525K7BPJ.js";import{b as Xe}from"./chunk-W32FI2A2.js";import{d as Et,e as xt,f as It,h as Ze,i as De,j as At,k as Rt,l as St}from"./chunk-KIPUBMU3.js";import{a as bt,c as Je,d as Ct,e as vt}from"./chunk-3NCMYTNG.js";import{b as ce}from"./chunk-CE5MAAIR.js";import{a as pe,c as Ke,e as Pt,h as kt}from"./chunk-VYI6QRJW.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import{ca as Ce,ea as ve,i as gt}from"./chunk-BIT6YWM7.js";import{c as fe,j as be}from"./chunk-2Y5SGDC6.js";import{c as Ye}from"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import{a as v}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as q}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function Nt(O,i,R){if(i.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let P=O?be.parse(O):null;if(await R.onComplete?.(i),!P||!R.check)return;let N=be.parse(await R.check());if(N.internal_feature_id!==P.internal_feature_id||N.quantity!==P.quantity||P.observation!==void 0&&(N.observation===void 0||N.observation.requirementDigest!==P.observation.requirementDigest||N.observation.authority!==P.observation.authority||Ye(N.observation.subject)!==Ye(P.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");N.allowed&&await R.onAccessGranted?.(N)}function nt(O){return Object.entries(O.document.buttons).filter(([,i])=>i.type==="checkout"&&i.product.type==="fixed"&&!ce(i.product,{},O.capabilities)).map(([i])=>i)}function _t(O,i){let R=i.lines[0];if(i.lines.length!==1||!R)return;let P=R.productVersionId,{screen:N,buttons:J}=O.document,x=new Map((R.prepaid??[]).map(m=>[m.internal_feature_id,m.quantity]));function K(m,h){if(m.hidden)return!1;if(m.type==="plan_picker"&&O.capabilities.pickers[m.id]?.options.includes(P))return h[m.id]=P,!0;if(m.type==="quantity_picker"){let Q=x.get(m.internalFeatureId);return Q!==void 0&&(!m.bind?.plan||m.bind.plan===P)&&(h[m.id]=Q),!1}if(m.type==="button"&&m.action){let Q=J[m.action];return Q?.type==="checkout"&&Q.product.type==="fixed"&&Q.product.productVersionId===P}if(m.type!=="stack")return!1;let j=m.interaction,r=m.bind?.plan===P;for(let[Q,p]of m.children.entries()){let te={},S=K(p,te);if(j?.type==="toggle"||j?.type==="tabs"){if(!S)continue;return h[m.id]=j.type==="toggle"?Q===0:p.id,Object.assign(h,te),!0}Object.assign(h,te),S&&(r=!0,j?.type==="select"&&j.purpose==="product"&&j.pickerId&&p.type==="stack"&&p.bind?.plan===P&&(h[m.id]=p.id,h[j.pickerId]=P))}return r}for(let m of N.pages){let h={__page:m.id};if(K(m.root,h))return h}}async function Pn(O,i,R){let P=i.focusAtReveal?()=>{}:Ze(O.ownerDocument),N=()=>{x.finish("dismissed"),P()},J=()=>N(),x=At(O,i,"paywall",()=>{N(),q(i.onDismiss)},Tt);i.signal?.throwIfAborted(),i.signal?.addEventListener("abort",J,{once:!0});let K=null,m,h,j;try{if(x.start(!0,i.loadingDocument?.screen.strings.defaultLocale,i.loadingDocument??null),x.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(K=i.check?be.parse(await x.wait(i.check(),De)):null,K?.allowed)return x.finish("skipped"),i.signal?.removeEventListener("abort",J),P(),await i.onAccessGranted?.(K),{check:K,host:null};let[e,t]=await Promise.allSettled([x.wait(import("./screen-renderer-5SJCTMJH.js")),x.wait(i.start().then(o=>(x.cancelled&&o.destroy(),o)),De)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;j=e.value,m=t.value,i.signal?.throwIfAborted(),m.signal?.throwIfAborted(),m.signal?.addEventListener("abort",J,{once:!0});let n=m.view??await x.wait(m.refresh(),De);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");m.signal?.throwIfAborted(),h=n}catch(e){throw x.finish("error",e),i.signal?.removeEventListener("abort",J),m?.signal?.removeEventListener("abort",J),m?.destroy(),P(),e}let r=m,{mountScreenPreview:Q}=j,p=O.ownerDocument,te=new AbortController,S=p.createElement("section"),le=p.createElement("div"),G=p.createElement("div"),Le=i.mountControls,V=Le?p.createElement("div"):void 0,u=p.createElement("p"),g=p.createElement("button"),k=p.createElement("button"),I=p.createElement("dialog"),rt=r.locale||h.document.screen.strings.defaultLocale,a=rt.toLowerCase().startsWith("zh"),Ut=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",Mt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",D=Ot(h.document.screen.theme);S.dataset.indianaPaywall="",S.setAttribute("aria-label",h.document.name),S.style.cssText=D.root,G.style.cssText=D.controls,u.style.cssText=D.message,u.setAttribute("role","status"),k.style.cssText=D.link,k.textContent=a?"\u5173\u95ED":"Close",g.style.cssText=D.secondary,g.textContent=a?"\u91CD\u8BD5":"Retry",g.hidden=!0,G.append(u,g,k),V&&(V.style.cssText="flex:1 0 100%;min-width:0",V.hidden=!0,G.prepend(V)),S.append(le,G);let Ne=()=>{if(V){let o=!V.childElementCount&&!V.textContent?.trim();V.hidden!==o&&(V.hidden=o)}let e=ne??G,t=[...e.children].every(o=>o===u?!u.textContent:o.hidden),n=[...e.children].some(o=>o===k?!1:o===u?!!u.textContent:!o.hidden);e.style.cssText=t?D.controls.replace(/padding:[^;]+/,"padding:0"):n?`${D.controls};${D.pinned}`:D.controls,Me()},it=typeof MutationObserver>"u"?void 0:new MutationObserver(Ne);it?.observe(S,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Pe=h.document.presentation,qt=Object.entries(h.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),$,ot,_e=!1,at=JSON.stringify(h.capabilities),st=e=>oe&&!he?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):nt(e);function ke(e){if(y)return;h=e;let t=JSON.stringify(e.capabilities);t!==at&&($?.updateCapabilities(pe(e),st(e)),at=t),Ht(e),ye()}let E,Ue=0;function Me(){let e=p.defaultView;if(!E?.responsive||!e)return;let t=ne??G,n=e.innerHeight-(E.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ue=Math.max(1,n-t.getBoundingClientRect().height),$?.resizeViewport?.(Ue,e.innerWidth)}let y=!1,oe=!1,C=null,qe,Ee=!1,ct=!1,ae=!1,Ve,$e=!1,X,ne;function Vt(){return oe||y||X||$e?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Je(r)}let A=()=>!y&&!Ee&&!X&&i.canInteract?.()!==!1,H,ue=!1,d=null,Z=null,He="",se=()=>i.checkoutNavigation==="after_confirmation"&&!!(i.terminateCheckout||i.resumeCheckout),me={},he,W=null;function ye(){if(!se()||!$?.updateCheckoutControls)return;let e=r.quote,t=!W&&!!e&&!!r.operation&&B(r.operation).type==="checkout",n=Object.entries(h.document.buttons).flatMap(([o,c])=>c.type==="checkout"?[{actionId:o,policy:c}]:[]);$.updateCheckoutControls({actions:n.map(({actionId:o})=>o),resume:t?n.filter(({actionId:o,policy:c})=>Ae(e,h,o,c.product,me)).map(({actionId:o})=>o):[],resumeLabel:a?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:he})}function lt(){Z?.remove(),Z=null}async function Be(){if(W)return;if(i.resumeCheckout&&r.operation){await i.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(B(e).type!=="checkout")return _(e,!1);A()&&(xe.delete(e.operationId),await Re(e))}function ut(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",g.hidden=!0}async function dt(e=!1){let t=W;if(!t)return;g.hidden=!0;let n=Date.now()+2e4;for(;A();){let o=await r.read();if(o.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let c=B(o);if(c.type==="native"){W=null,lt(),C=t.selection,H=t.coupon,ue=!1,await ge();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){W=null,await _(o,!1);return}if(e&&c.type==="checkout"){e=!1;try{await i.terminateCheckout(t.operationId)}catch(w){q(i.onError,w)}}if(Date.now()>=n)break;await Xe(1e3,p,te.signal)}y||ut()}async function $t(e,t,n){W={operationId:e,selection:t,coupon:n};let o=!1;try{await i.terminateCheckout(e)}catch(c){if(c instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){W=null,u.textContent=a?"\u8BF7\u7EE7\u7EED\u539F\u8BA2\u5355\uFF0C\u6216\u7B49\u5F85\u5B83\u8FC7\u671F\u540E\u518D\u66F4\u6362\u65B9\u6848\u3002":"Continue your original checkout, or wait for it to expire before changing plans.",q(i.onError,c);return}o=c instanceof v&&(c.status??0)>=500,q(i.onError,c)}A()&&await dt(o)}function Fe(e,t,n,o,c){let w=pe(e).checkoutCoupons?.[t],l=w?w.products[n]:i.claimCoupon&&c?gt(e.capabilities,c,o):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Ht(e){oe||C||r.quote||r.operation||He&&u.textContent===He||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let xe=new Map,Ie=!1;function Ae(e,t,n,o,c,w){let l=e.lines.length===1?e.lines[0]:void 0,s=ce(o,c,t.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let L=Fe(t,n,s,c,w);if((L||pe(t).checkoutCoupons?.[n])&&(L?.id??null)!==(e.discount?.couponId??null))return!1;let U;try{U=ve(t.document.screen,s,c,t.capabilities)}catch{return!1}let ie=Object.fromEntries((l.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(U),...Object.keys(ie)])].every(z=>(U[z]??0)===(ie[z]??0))}let B=e=>bt({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:y,canReselect:r.canReselect});async function Re(e){let t=e.merchantExecution;if(!(!A()||!e.checkoutUrl||i.checkoutNavigation==="after_confirmation"&&B(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||xe.get(e.operationId)===e.checkoutUrl)){xe.set(e.operationId,e.checkoutUrl);try{i.onCheckoutUrl?await i.onCheckoutUrl(e.checkoutUrl):p.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw xe.delete(e.operationId),n}}}let re=(e,t=!1)=>{if(e instanceof Ke)d=null,u.textContent=e.customerMessage(a);else if(Dt(e))d=null,u.textContent=t?a?"\u5F53\u524D\u65E0\u6CD5\u5728\u6B64\u8D2D\u4E70\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u3002":"Purchases aren\u2019t available here right now. Payment hasn\u2019t started. Contact the merchant for help.":tt(e,a);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(d=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):r.canReselect===!0&&!C?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?tt(e,a):e instanceof v?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";g.hidden=d===null,He=u.textContent,t&&!E?.responsive&&u.scrollIntoView?.({block:"nearest"}),q(t&&R?.quoteError?R.quoteError:i.onError,e)},Se=new WeakMap;function Te(e){oe=e,g.disabled=e,$?.updateCapabilities?.(pe(h),st(h));for(let t of Z?.querySelectorAll("button")??[])e?(Se.set(t,t.disabled),t.disabled=!0):Se.has(t)&&(t.disabled=Se.get(t),Se.delete(t)),et(t)}function je(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function Bt(e){if(i.beforeAction)try{await i.beforeAction()}catch(t){throw t instanceof Ke?(C=null,ue=!1,d=null):d=e,t}}async function M(e,t){if(oe||y)return;if(!A()){je();return}let n=e===ge,o=n?Mt:Ut,c=se()&&t!==void 0;he=c?t:void 0,Te(!0),ye(),g.hidden=!0,u.textContent=c?"":o;try{if((e!==Be||!i.resumeCheckout)&&await Bt(e),y)return;if(!A()){d=e,g.hidden=!1,je();return}await e()}catch(w){y||re(w,n&&!c)}finally{he=void 0,Te(!1),ye(),u.textContent===o&&(u.textContent="")}}async function Ft(e){await Nt(K,e,i)}function ft(e){return Je(r).type==="recording"||B(e).type==="recording"}function pt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],o=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=t?n.length===1&&n[0]?.amountMinor===o&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===o&&e.lines[0],w=o===null?fe(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):fe(o,e.currency)+(c?Ce(c.interval,a?"zh-CN":"en",c.intervalCount??1):""),l=e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} \xB7 ${w}`:w,recurring:c}}async function _(e,t=i.checkoutNavigation!=="after_confirmation"){if(y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}if(u.textContent=Lt(e.status,a),ft(e)){let s=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=s?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",g.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",d=async()=>_(await r.read()),g.hidden=!1;return}if(e.problem){let s=e.problem;d=we,g.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",re(new v(s.code,s.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){d=null,await Ft(e);return}if(e.status!=="pending"){if(r.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",g.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",d=async()=>_(await r.read()),g.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),g.textContent=a?"\u91CD\u8BD5":"Retry",d=null,C=null;return}if(!t&&B(e).type==="checkout"){if(W){ut();return}if(se()){u.textContent="",Ie=!1,d=null,ye();return}let s=r.quote,L=s?.operationId===e.operationId?pt(s).label:"";u.textContent=Ie?L?a?`${L} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${L} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ie=!1,d=null;return}await Re(e);let n=Date.now(),o=n+6e5,c=2e3,w=!e.checkoutUrl,l=()=>w&&Date.now()-n<15e3;_e=!0,q(i.onObservationChange,!0);try{for(;!y&&Date.now()<o;){if(await Xe(l()?700:c,p,te.signal),y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}let s=await r.read();if(s.checkoutUrl&&(w=!1),!t&&B(s).type==="checkout"){await _(s,!1);return}if(!s.problem&&s.status==="pending"&&await Re(s),s.status!=="pending"||s.problem||ft(s)){await _(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{_e=!1,q(i.onObservationChange,!1)}d=async()=>_(await r.read()),g.hidden=!1}async function Qe(e=!1){let t=await r.read();if(y)return;if(!A()){d=()=>Qe(e),g.hidden=!1;return}let n=r.quote;if(n&&Pt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!r.pendingCancellation){mt(n);return}await _(t,e||void 0)}async function we(){lt(),d=we;let e=await r.confirm();if(!A()){d=we,g.hidden=!1;return}if(e.problem){await _(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Re(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!i.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await i.onPurchase({operation:e,signal:te.signal})}}d=async()=>_(await r.read()),await _(e,!0)}function mt(e){Z?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),o=p.createElement("button"),c=p.createElement("button"),w=p.createElement("div"),l=p.createElement("p"),s=e.merchantTerms,L=a?"zh-CN":"en",U=s?.subscriptionTerms?.items??[],ie=s?s.subscriptionTerms?.trial?.days:e.lines.find(f=>f.trial)?.trial?.days,ee=ie===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(f=>f.trial)?0:null,z=(f,b)=>a?`${b} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${f}`:`Then ${f} after the ${b}-day trial`,{label:ze,recurring:ht}=pt(e),jt=e.lines.map(f=>f.productName).join(", "),yt=ee===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${fe(ee,e.currency)}`;l.textContent=yt?[jt,yt].filter(Boolean).join(" \xB7 "):ze,o.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",o.disabled=t,c.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,w.style.cssText=D.actions,o.style.cssText=D.primary,c.style.cssText=D.secondary,et(o),o.onclick=()=>{M(we)};let wt=async()=>{let f=await r.cancel();y||(n.remove(),Z=null,await _(f))};c.onclick=()=>{d=wt,M(wt)};let F=p.createElement("div");if(F.style.cssText=D.terms,s){for(let b of U){if(ee===null&&b===ht)continue;let T=p.createElement("p"),Y=fe(b.amountMinor,e.currency)+Ce(b.interval,L,b.intervalCount);T.textContent=ee!==null&&ie!==void 0?z(Y,ie):Y,F.append(T)}let f=s.subscriptionTerms?.trial;if(f){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.days} \u5929\uFF1B${f.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.days}; ${f.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}for(let b of[...s.expectedEffects.map(T=>T.description),...s.requiredConsents.map(T=>T.summary)]){let T=p.createElement("p");T.textContent=b,F.append(T)}}else{for(let f of e.lines){if(ee!==null||f!==ht){let b=p.createElement("p"),T=`${fe(f.catalogAmountMinor,e.currency)}${Ce(f.interval,L,f.intervalCount??1)}`;b.textContent=ee!==null&&f.trial?(e.lines.length>1?`${f.productName} \xB7 `:"")+z(T,f.trial.days):`${f.productName} \xB7 ${T}`,F.append(b)}for(let b of f.prepaid??[]){let T=p.createElement("p"),Y=r.view?.capabilities.plans[f.productVersionId]?.prepaid?.find(Qt=>Qt.internalFeatureId===b.internal_feature_id);T.textContent=`${Y?.name??b.internal_feature_id} \xB7 ${b.quantity} ${a?"\u4EFD":"packs"} \xD7 ${b.terms.units}`,Y&&(T.textContent+=Ce(Y.reset==="week"||Y.reset==="month"||Y.reset==="year"?Y.reset:"one_time",L,Y.resetCount)),F.append(T)}if(f.trial){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.trial.days} \u5929\uFF1B${f.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.trial.days}; ${f.trial.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}}if(!e.charge){let f=p.createElement("p");f.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",F.append(f)}}for(let f of F.children)f.style.margin="0";w.append(o,c),n.append(l,...F.childElementCount?[F]:[],w),G.prepend(n),E?.responsive||n.scrollIntoView?.({block:"nearest"}),o.focus({preventScroll:!0}),Z=n,d=null}async function ge(){if(!C)return;if(d=ge,!ue){let n=r.view,o=n?.document.buttons[C.actionId],c=n&&o?.type==="checkout"?ce(o.product,C.selection,n.capabilities):null;if(!n||!c)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let w=H?.offerId;if(H&&!w){if(!i.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await i.claimCoupon(H.id,C.requestId);if(y)return;if(!l||l.couponId!==H.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw C=null,H=void 0,d=async()=>{ke(await r.refresh()),d=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");w=l.id}if(!H&&!n.document.screen.actions.some(l=>l.id===C?.actionId&&typeof l.properties.couponBinding=="string")&&(w=await i.resolveOfferId?.({actionId:C.actionId,productVersionId:c,featureQuantities:ve(n.document.screen,c,C.selection,n.capabilities)})),y)return;w!==void 0&&(C.offerId=w),ue=!0}if(!A()){g.hidden=!1;return}let e;try{e=await r.preview(C)}catch(n){throw r.canReselect===!0&&(C=null,ue=!1,H=void 0,d=null),n}if(H&&(e.discount?.couponId!==H.id||e.discount.offerId!==C.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(y)return;let t=e.merchantTerms;if(i.confirmOnHostedCheckout&&A()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=he?"":a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await we()}catch(o){y||re(o)}finally{u.textContent===n&&(u.textContent="")}return}mt(e)}function de(e="destroy"){if(y)return;y=!0;let t=qe;qe=void 0,q(t),i.signal?.removeEventListener("abort",J),r.signal?.removeEventListener("abort",J),x.finish("dismissed"),ot?.(),te.abort(),it?.disconnect(),E?.destroy(),$?.destroy(),r.destroy(),I.open&&I.close(),I.remove(),S.remove(),P(),e==="dismiss"&&q(i.onDismiss)}N=de;async function Oe(){if(!ae||y||Ee||X==="closing"||!X&&!A())return;if(!R){de("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",ne||(ne=p.createElement("div"),ne.style.cssText=G.style.cssText,G.replaceWith(ne),le.inert=!0),k.hidden=!1,ne.replaceChildren(e,k),X="closing",k.setAttribute("aria-disabled","true"),k.focus({preventScroll:!0});try{await R.dismiss()}catch(t){y||q(i.onError,t)}y||(X="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",k.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",k.removeAttribute("aria-label"),k.removeAttribute("aria-disabled"))}k.onclick=()=>{Oe()},I.addEventListener("cancel",e=>{e.preventDefault(),Oe()}),g.onclick=()=>{d&&M(d)};function Ge(e){x.finish("error",e),de()}function We(){if(!(!ct||ae||y||Ee||E&&!A()))try{let e=t=>{i.focusAtReveal&&(P=Ze(p)),$?.setHidden?.(!1),Ve?.(),E&&(I.showModal(),E.responsive&&I.focus({preventScroll:!0}),!t&&i.loading!=="host"&&xt(I,E.type,E.responsive)),ae=!0};R?R.present(()=>x.present(()=>e(!0))):x.present(e)}catch(e){Ge(e),re(e)}}try{if(Pe.type==="inline"?(Ne(),Ve=St(S,O),O.append(S)):(I.setAttribute("aria-label",h.document.name),k.textContent="\xD7",k.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),It(k,h.document.screen.theme),k.hidden=kt(h.document),I.append(k,S),O.append(I),E=Et(I,{...h.document.screen,presentation:Pe},Me),E.latch(),E.responsive&&(S.style.display="flex",S.style.flexDirection="column",S.style.maxHeight="100%",le.style.overflow="clip",le.style.minHeight="0"),Ve=Rt(I)),Le&&V){let n=Le(V);if(typeof n=="function"&&(y?q(n):qe=n),y)throw new DOMException("Presentation cancelled","AbortError");Ne()}$=Q(le,{mode:"live",rendererUrl:r.webViewUrl,title:h.document.name,closeActions:qt,onAuthoredClose(n){X||y||(k.hidden=n)},hostPresentation:()=>E?.type??Pe.type,reportContentHeight:E?.responsive,onResize:n=>{if(!E?.responsive)return;let o=Math.min(n,Ue);le.style.height=`${o}px`,E.setContentHeight(o+(ne??G).getBoundingClientRect().height)},onSelection(n){me=n,ye()},onAction(n,o={},c,w){if(!ae||y||X)return;let l=r.view,s=l?.document.buttons[n];if(!s)return;if(s.type==="close"&&R&&i.resumeCheckout&&r.operation&&Ct(B(r.operation))){Oe();return}if(oe)return;if(!A()){je();return}if(s.type==="close"){M(async()=>{await i.onAction?.(n),de(i.onAction?"action":"dismiss")});return}if(s.type==="action"){d=async()=>{if(s.action.type==="event"){if(!i.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await i.onEvent(s.action.event)}else i.onOpenUrl?await i.onOpenUrl(s.action.url):p.defaultView?.location.assign(s.action.url);await i.onAction?.(n),d=null},M(d);return}if(i.allowNewPurchase===!1){se()&&l&&r.quote&&r.operation&&B(r.operation).type==="checkout"&&Ae(r.quote,l,n,s.product,o,w)?M(Be,n):u.textContent=a?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(Z&&r.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",E?.responsive||Z.scrollIntoView?.({block:"nearest"}),Z.querySelector("button")?.focus({preventScroll:!0});return}if(se()&&W){W.selection.actionId===n&&M(()=>dt(!0),n);return}if(se()&&i.terminateCheckout&&l&&r.quote&&r.operation&&r.canReselect===!1&&B(r.operation).type==="checkout"){if(Ae(r.quote,l,n,s.product,o,w)){M(Be,n);return}let U=ce(s.product,o,l.capabilities);try{if(!U)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ve(l.document.screen,U,o,l.capabilities)}catch(ze){re(ze);return}let ie=r.operation.operationId,ee={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(o)},z=Fe(l,n,U,o,w);M(()=>$t(ie,ee,z),n);return}if((r.quote||C)&&r.canReselect===!1){let U=!!l&&!!r.quote&&Ae(r.quote,l,n,s.product,o,w);Ie=!!r.quote&&!U,d=r.quote?()=>Qe(U):ge,M(d);return}let L=l&&ce(s.product,o,l.capabilities);if(!l||!L){re(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(i.onPurchaseIntent){d=null,M(async()=>{let U={actionId:n,productVersionId:L,selection:structuredClone(o),featureQuantities:ve(l.document.screen,L,o,l.capabilities)};$e=!0,await i.onPurchaseIntent(U)});return}if(C&&C.actionId!==n){re(new v("COMMAND_PENDING","Finish the current purchase"));return}C||(H=Fe(l,n,L,o,w),C={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(o)},ue=!1),M(ge,n)},onEscape:()=>{Oe()},onError:n=>{let o=new Error(n);!ae&&!y&&Ge(o),re(o)},onRendered:n=>{n&&I.setAttribute("aria-label",n),ct=!0,We()}}),$.setHidden?.(!0),Me();let e=se()&&!!r.quote&&!!r.operation&&B(r.operation).type==="checkout";me=e?_t(h,r.quote)??{}:{},$.update(h.document.screen,rt,{capabilities:pe(h),unavailableActions:nt(h),serverInput:{bindings:[],answers:{}},...Object.keys(me).length?{selection:me}:{}}),ot=r.subscribe?.(ke),ke(r.view??h),await x.wait($.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(d=()=>Qe(),M(d))}catch(e){throw Ge(e),e}return{check:K,host:{get observing(){return _e},get recovery(){return Vt()},async prepareFallback(){if(oe||y||X||$e)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};Te(!0);try{let e=await vt(r);return e.type==="native"&&de(),e}finally{Te(!1)}},setSuspended(e){Ee=e,S.hidden=e,e&&I.open?I.close():!e&&!ae?We():!e&&!y&&ae&&Pe.type!=="inline"&&!I.open&&I.showModal()},destroy:de,refresh:async()=>{if(!A()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return ke(e),We(),e}}}}export{Pn as showPaywall};
@@ -0,0 +1 @@
1
+ import{b as a}from"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-CE5MAAIR.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-LJBTEB2Q.js";import"./chunk-O2D3A4CS.js";import"./chunk-JAZHNQKO.js";import"./chunk-ZORZA4WG.js";import"./chunk-U7XD4ZR5.js";import"./chunk-HX36OZPQ.js";import"./chunk-GGYBZWWY.js";import"./chunk-MTIOLSVM.js";import"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-3NCMYTNG.js";import"./chunk-CE5MAAIR.js";import"./chunk-VYI6QRJW.js";import"./chunk-DPIQ3SV7.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
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-DDLSQSWO.js";import"./chunk-AOGDCT4T.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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-GNAMACMK.js";import"./chunk-KIPUBMU3.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{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-2VMEDQHT.js";import"./chunk-ZYOZSUZS.js";import{a as A}from"./chunk-RE4OLOOT.js";import{e as P}from"./chunk-LC6UCDWE.js";import"./chunk-UV4H6VCS.js";import{h as b,i as x,k as L}from"./chunk-ZZIBLQCJ.js";import{F as C}from"./chunk-KFIL73QY.js";import"./chunk-CY7OKV7E.js";import"./chunk-D3OYXTMC.js";import"./chunk-4KLXQKNO.js";import"./chunk-PW5PIBSO.js";import"./chunk-S43TYW3V.js";import"./chunk-W74JLL2O.js";import"./chunk-ECKVJGXQ.js";import"./chunk-GH6FM44P.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-3NCMYTNG.js";import"./chunk-AB7GEGZ2.js";import"./chunk-Q676H74B.js";import"./chunk-E7CCHUSO.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import{b as R}from"./chunk-HEHLFHW7.js";import{a as r}from"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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-TLRRBUGP.js";import"./chunk-LZBJHWVH.js";import{a as A}from"./chunk-LJBTEB2Q.js";import{e as P}from"./chunk-O2D3A4CS.js";import"./chunk-JAZHNQKO.js";import{h as b,i as x,k as L}from"./chunk-GDD26ZDV.js";import{F as C}from"./chunk-N774V4SQ.js";import"./chunk-ZORZA4WG.js";import"./chunk-U7XD4ZR5.js";import"./chunk-HX36OZPQ.js";import"./chunk-GGYBZWWY.js";import"./chunk-MTIOLSVM.js";import"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import"./chunk-W3G4YIM5.js";import"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-3NCMYTNG.js";import"./chunk-CE5MAAIR.js";import"./chunk-VYI6QRJW.js";import"./chunk-DPIQ3SV7.js";import"./chunk-HFD4CLCJ.js";import"./chunk-IGANLTKS.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import{b as R}from"./chunk-YURGISSB.js";import{a as r}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";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};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-GNAMACMK.js";import"./chunk-KIPUBMU3.js";import"./chunk-BIT6YWM7.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as pn}from"./chunk-2HBIBIOF.js";import{a as I}from"./chunk-VIBJNB5B.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-OX2A3UD2.js";import{a as xt}from"./chunk-RE4OLOOT.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-LC6UCDWE.js";import"./chunk-UV4H6VCS.js";import{a as Te,b as ae,c as yt,d as It,e as wt,f as xe,g as vt,h as Me,i as dn,j as ln,k as mn}from"./chunk-ZZIBLQCJ.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 z,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-KFIL73QY.js";import{c as h}from"./chunk-CY7OKV7E.js";import"./chunk-D3OYXTMC.js";import"./chunk-4KLXQKNO.js";import{a as Et,b as _e}from"./chunk-PW5PIBSO.js";import{A as tt,B as Se,C as ie,E as se,F as Ce,K as j,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 X,y as W,z as oe}from"./chunk-S43TYW3V.js";import"./chunk-W74JLL2O.js";import"./chunk-ECKVJGXQ.js";import{e as at}from"./chunk-GH6FM44P.js";import{$ as mt,A as it,B as Re,C as st,D as ct,I as ut,J as dt,K as be,L as Ae,T as pt,U as de,V as Z,W as lt,d as ve,f as Ze,g as et,u as q}from"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-3NCMYTNG.js";import"./chunk-AB7GEGZ2.js";import"./chunk-Q676H74B.js";import"./chunk-E7CCHUSO.js";import"./chunk-7XDQKZYA.js";import{a as Ne,b as Le}from"./chunk-XJRDO3NI.js";import{$ as ue,J as Xe,M as We}from"./chunk-WZMZMJCK.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-T2KWLYCW.js";import{c as Ie}from"./chunk-LOLMUXHW.js";import{b as Y}from"./chunk-HEHLFHW7.js";import{a as c}from"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import{b as u}from"./chunk-CR2XJ2CX.js";import{a as Ye}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var _t=4,Mt=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results","checkout_termination"],In=u.enum(Mt),ee=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...se.shape,bridgeVersion:u.literal(_t),capabilities:ee(In,Mt.length),checkKinds:ee(u.enum(["access","metered","credit"]),3),preparationActions:ee(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:ee(u.enum(["auto_topup"]),1),nextActionTypes:ee(u.enum(["redirect","authenticate"]),2),resultEvents:ee(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("checkout_termination")&&(!t("operation_status")||!t("billing_records")||!e.billingEvents.includes("purchase.closed"))&&o("capabilities","Checkout termination requires original lookup and purchase.closed"),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`)}),K={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe,"purchase.terminate":j},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He,"purchase.terminate":j.extend({outcome:u.enum(["requested","already_paid"])})},Gn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read","purchase.terminate"]);function $(e,n){return u.strictObject({bridgeVersion:u.literal(_t),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[$("bridge.ping",K["bridge.ping"]),$("bridge.describe",K["bridge.describe"]),$("requirement.check",K["requirement.check"]),$("operation.prepare",K["operation.prepare"]),$("benefit.claim",K["benefit.claim"]),$("operation.read",K["operation.read"]),$("purchase.terminate",K["purchase.terminate"])]),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",Q="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-NSAEHRIT.js";import{a as I}from"./chunk-PFPMK4IO.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-QCMFCK7Z.js";import{a as xt}from"./chunk-LJBTEB2Q.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-O2D3A4CS.js";import"./chunk-JAZHNQKO.js";import{a as Te,b as ae,c as yt,d as It,e as wt,f as xe,g as vt,h as Me,i as dn,j as ln,k as mn}from"./chunk-GDD26ZDV.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 z,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-N774V4SQ.js";import{c as h}from"./chunk-ZORZA4WG.js";import"./chunk-U7XD4ZR5.js";import"./chunk-HX36OZPQ.js";import{a as Et,b as _e}from"./chunk-GGYBZWWY.js";import{A as tt,B as Se,C as ie,E as se,F as Ce,K as j,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 X,y as W,z as oe}from"./chunk-MTIOLSVM.js";import"./chunk-ONMIBSOC.js";import"./chunk-CEMHQQAJ.js";import{e as at}from"./chunk-W3G4YIM5.js";import{$ as mt,A as it,B as Re,C as st,D as ct,I as ut,J as dt,K as be,L as Ae,T as pt,U as de,V as Z,W as lt,d as ve,f as Ze,g as et,u as q}from"./chunk-IYHXEKAD.js";import"./chunk-73ISTR7P.js";import"./chunk-3NCMYTNG.js";import"./chunk-CE5MAAIR.js";import"./chunk-VYI6QRJW.js";import"./chunk-DPIQ3SV7.js";import"./chunk-HFD4CLCJ.js";import{a as Ne,b as Le}from"./chunk-IGANLTKS.js";import{$ as ue,J as Xe,M as We}from"./chunk-BIT6YWM7.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-2Y5SGDC6.js";import{c as Ie}from"./chunk-3JD3U45R.js";import{b as Y}from"./chunk-YURGISSB.js";import{a as c}from"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import{b as u}from"./chunk-NOOIJXRN.js";import{a as Ye}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var _t=4,Mt=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results","checkout_termination"],In=u.enum(Mt),ee=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...se.shape,bridgeVersion:u.literal(_t),capabilities:ee(In,Mt.length),checkKinds:ee(u.enum(["access","metered","credit"]),3),preparationActions:ee(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:ee(u.enum(["auto_topup"]),1),nextActionTypes:ee(u.enum(["redirect","authenticate"]),2),resultEvents:ee(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("checkout_termination")&&(!t("operation_status")||!t("billing_records")||!e.billingEvents.includes("purchase.closed"))&&o("capabilities","Checkout termination requires original lookup and purchase.closed"),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`)}),K={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe,"purchase.terminate":j},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He,"purchase.terminate":j.extend({outcome:u.enum(["requested","already_paid"])})},Gn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read","purchase.terminate"]);function $(e,n){return u.strictObject({bridgeVersion:u.literal(_t),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[$("bridge.ping",K["bridge.ping"]),$("bridge.describe",K["bridge.describe"]),$("requirement.check",K["requirement.check"]),$("operation.prepare",K["operation.prepare"]),$("benefit.claim",K["benefit.claim"]),$("operation.read",K["operation.read"]),$("purchase.terminate",K["purchase.terminate"])]),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",Q="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
  ${W}
package/dist/visual.js CHANGED
@@ -1 +1 @@
1
- import{a as pe,c as fe}from"./chunk-OJM6ORHE.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as J,b as F,c as ge,e as me}from"./chunk-6F4JS3RK.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-OCWSWXCW.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import{b as o}from"./chunk-CR2XJ2CX.js";import{c as te,e as ie,g as M}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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:le(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=se(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=re(e.deviceIdCookie??"indiana_did"),T=ae(),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(de(`${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=oe(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=ue(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=ce(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{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as J,b as F,c as ge,e as me}from"./chunk-CBZ5GW4J.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-YJS6NNIO.js";import"./chunk-3VUPVXAV.js";import"./chunk-JBVZ6A6V.js";import{b as o}from"./chunk-NOOIJXRN.js";import{c as te,e as ie,g as M}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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:le(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=se(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=re(e.deviceIdCookie??"indiana_did"),T=ae(),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(de(`${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=oe(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=ue(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=ce(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.37",
3
+ "version": "0.10.39",
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{a,b}from"./chunk-PW5PIBSO.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
@@ -1 +0,0 @@
1
- import{p as n,s as t}from"./chunk-KFIL73QY.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +0,0 @@
1
- import{a as Mn,b as Un,c as un,d as dn,e as Me,f as $n,h as xn,i as Gn,j as Qn,k as Jn}from"./chunk-XGNXZWZL.js";import{b as zn}from"./chunk-TASEZY5T.js";import{b as qn,c as Bn}from"./chunk-2KJLN65C.js";import{a as On}from"./chunk-W32FI2A2.js";import{c as Sn,e as _n,f as Ln,h as Hn,i as Se,j as Ze,k as Vn,l as Ke}from"./chunk-AOGDCT4T.js";import{aa as Xe}from"./chunk-YV6UFESO.js";import{a as Ve,d as Dn}from"./chunk-3NCMYTNG.js";import{b as Rn}from"./chunk-AB7GEGZ2.js";import{b as kn,d as Tn,e as An,f as Nn,g as Fn}from"./chunk-Q676H74B.js";import{F as Pn,ea as En}from"./chunk-WZMZMJCK.js";import{a as y}from"./chunk-U7NX5ET2.js";import{a as Ce}from"./chunk-DSPLGTQI.js";async function cn(t){let{session:v,load:C}=it(t);try{return await C(),v}catch(e){throw v.destroy(),e}}function it(t){let v=t.view;if(!v?.paywall)throw new y("INVALID_REQUEST","The current node is not a Paywall");let C=v.paywall.receiptId,e=v.nodeId,w=v.visit,A=v.paywall.resolution,s=v.paywall,S="document"in A?{document:A.document,offering:A.offering,capabilities:A.capabilities}:null;function d(){let i=s.resolution;return"document"in i?i:S&&{...i,document:S.document,offering:S.offering,capabilities:kn(i.capabilities,S.capabilities)}}function I(i){if(!Tn(i,A))throw new y("INVALID_RESPONSE","The pinned Paywall binding changed")}let P=!1,$=new Set,ne=null;function m(){let i=d();if(i&&!P)for(let l of $)Ce(l,structuredClone(i))}async function V(){N();let i=d();if(i)return structuredClone(i);if(!ne){let l=(async()=>{if("document"in s.resolution||!t.resolvePaywall)throw new y("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await qn(t,s.resolution);return N(),I(b),S={document:b.document,offering:b.offering,capabilities:b.capabilities},m(),d()})();ne=l;let a=()=>{ne===l&&(ne=null)};l.then(a,a)}return ne.then(l=>structuredClone(l))}let o=new AbortController,_=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,Y=0,J=null,Q=new Set,E=null,z=new Map;function k(i){if(i.purchase&&i.purchase.receiptId!==C)throw new y("INVALID_RESPONSE","Purchase receipt changed");let l=i.run.paywall;return i.purchase??(l?.receiptId===C?l:null)}function N(){if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed")}function F(i,l,a){if(N(),l!==Y||a!==void 0&&s.quote?.operationId!==a)return!1;let b=s.selectionGeneration??0,c=i.run.paywall;if(c?.receiptId===C){if((c.selectionGeneration??0)<(s.selectionGeneration??0))return!1;I(c.resolution)}let u=k(i),q=c?.receiptId===C&&(c.selectionGeneration??0)>b,L=q?u?.quote??null:u?.quote??s.quote,B=u?.operation??(L?.operationId===s.quote?.operationId?s.operation:null);return L&&B&&An(B,{operationId:L.operationId},"Purchase operation changed"),(q||L?.operationId!==s.quote?.operationId)&&(Y++,c?.receiptId===C&&(_=c.purchaseRequestId)),c?.canReselect===!0&&c.purchaseRequestId===E&&!(t.pendingCommands??[t.pendingCommand]).some(M=>M?.requestId===E)&&(E=null),s={...s,...c?.receiptId===C?c:{},...a!==void 0&&!q&&u?.canReselect!==void 0?{canReselect:u.canReselect}:{},quote:L,operation:Fn(s.operation,B,!0)},m(),!0}function ce(i,l,a){return new Promise((b,c)=>{let u=!1,q=()=>{clearTimeout(Ee),o.signal.removeEventListener("abort",M)},L=Re=>{u||(u=!0,q(),b(Re))},B=Re=>{u||(u=!0,q(),c(Re))},M=()=>B(new y("IDENTITY_CHANGED","Paywall presentation has closed")),Ee=setTimeout(()=>B(new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,l-Date.now()));o.signal.addEventListener("abort",M,{once:!0}),o.signal.aborted&&M(),i.then(L,B)})}function Pe(i){return new Promise(l=>{let a=()=>{clearTimeout(b),o.signal.removeEventListener("abort",a),l()},b=setTimeout(a,i);o.signal.addEventListener("abort",a,{once:!0}),o.signal.aborted&&a()})}function se(i,l){N();let a=z.get(i)??t.pendingCommands?.find(u=>u.requestId===i)??t.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===w){l.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!l.predecessor&&(l={...l,predecessor:a.input.predecessor});let u=Xe.parse(a),q=Xe.parse({...a,input:l});if(u.operation!=="submit"||q.operation!=="submit"||JSON.stringify(u.input)!==JSON.stringify(q.input))throw new y("CONFLICT","A purchase request cannot change its input");return z.set(i,u),u}let b=t.view;if(!b||b.nodeId!==e||b.visit!==w||b.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","The Paywall visit has changed");let c=Xe.parse({operation:"submit",requestId:i,nodeId:e,visit:w,revision:b.revision,input:structuredClone(l)});if(c.operation!=="submit")throw new y("INVALID_REQUEST","A purchase submission is required");return z.set(i,c),c}async function te(i,l){N();let{requestId:a,input:b}=i,c=Date.now()+3e4;Q.add(a);try{let u=await ce(t.submit(i),c,a);for(;u.run.pendingRequest?.requestId===a&&Date.now()<c&&!P&&(await Pe(Math.min(1e3,c-Date.now())),!(P||Date.now()>=c));)u=await ce(t.resume(a),c,a);if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed");if(u.run.pendingRequest?.requestId===a)throw new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!F(u,l,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new y("PRECONDITION_FAILED","The purchase selection has changed");E===a&&(E=null)}catch(u){if(E=a,b.type==="paywall_quote"&&t.settle&&!P&&u instanceof y&&u.status!==void 0&&![401,425].includes(u.status)&&!u.retryable&&u.recovery!=="recover_operation")try{if((await ce(t.settle(a),c,a)).settlement?.state==="settled"){let L=await ce(t.get(),c,a);F(L,l)&&L.run.paywall?.purchaseRequestId===a&&s.canReselect===!0&&z.delete(a)}}catch{}throw u instanceof y&&u.code==="COMMAND_PENDING"&&u.status===void 0&&z.delete(a),u}finally{Q.delete(a)}}async function me(i){if(!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let l=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(c=>c.operation==="submit"&&c.input.type===l&&"operationId"in c.input&&c.input.operationId===s.quote.operationId),b=a?.operation==="submit"&&a.input.type===l&&"operationId"in a.input&&a.input.operationId===s.quote.operationId?a.requestId:crypto.randomUUID();if(await te(se(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:s.quote.operationId}),Y),!s.operation)throw new y("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(s.operation)}let G={get view(){return structuredClone(d())},get quote(){return s.quote?structuredClone(s.quote):null},get operation(){return s.operation?structuredClone(s.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??v.locale},get canReselect(){return s.canReselect===!0&&E===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),l=t.pendingPurchase;if(l&&(l.receiptId!==C||l.operationId!==s.quote?.operationId))return{type:"recover",operationId:l.operationId,requestId:i[0]?.requestId??null};let a=Ve({quote:s.quote,operation:s.operation,requestId:i[0]?.requestId??E??_,pending:Q.size>0||i.length>0||E!==null,destroyed:P,canReselect:s.canReselect});return a.type==="recover"&&a.requestId===null&&!P&&t.hasDurableJournal===!0&&!s.quote&&!s.operation&&(s.selectionGeneration??0)===0&&!l&&!i.length&&!Q.size&&!_?{type:"native",operationId:null}:a},get pendingCancellation(){return!P&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_cancel"&&i.input.operationId===s.quote?.operationId)},subscribe(i){return P?()=>{}:($.add(i),()=>$.delete(i))},async refresh(){N();let i=Y,l=await t.get();if(F(l,i),l.run.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","Paywall presentation has changed");return V()},preview(i){let l=d();if(!l)return Promise.reject(new y("PRECONDITION_FAILED","Load the Paywall presentation first"));if(_&&_!==i.requestId&&(J||s.canReselect!==!0))return Promise.reject(new y("COMMAND_PENDING","Retry the original purchase before starting another"));let a=l.document.buttons[i.actionId],b=a?.type==="checkout"?Rn(a.product,i.selection,l.capabilities):null;if(!b)return Promise.reject(new y("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let c=En(l.document.screen,b,i.selection,l.capabilities),u=_!==i.requestId&&(s.selectionGeneration??0)>0?{operationId:s.quote?.operationId??null,generation:s.selectionGeneration??0}:void 0;if(u&&s.canReselect!==!0)return Promise.reject(new y("COMMAND_PENDING","Original purchase requires authoritative termination"));let q;try{q=se(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(c).length?{featureQuantities:c}:{},...u?{predecessor:u}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(M){return Promise.reject(M)}if(_===i.requestId&&J)return J;_!==i.requestId&&Y++;let L=Y;_=i.requestId;let B=(async()=>{if(await te(q,L),!s.quote)throw new y("INVALID_RESPONSE","The accepted quote is missing");return Nn(s.quote,{productVersionId:b,featureQuantities:c},"The selected purchase changed"),structuredClone(s.quote)})();return J=B,B.then(()=>{J===B&&(J=null)},M=>{J===B&&(J=null),_===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&M instanceof y&&M.status!==void 0&&M.status<500&&![401,425].includes(M.status)&&(_=null)}),B},confirm:()=>me("confirm"),cancel:()=>me("cancel"),async read(){if(N(),!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let i=s.quote.operationId,l=Y,a=t.pendingCommands?.find(L=>L.operation==="submit"&&(L.input.type==="paywall_confirm"||L.input.type==="paywall_cancel")&&L.input.operationId===i)??t.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await t.settle?.(a.requestId);let b=await t.get(void 0,{receiptId:C,operationId:i});N();let c=k(b);if(c?.quote&&c.quote.operationId!==i||c?.operation&&c.operation.operationId!==i)throw new y("INVALID_RESPONSE","Purchase operation changed");let u=F(b,l,i),q=u?s.operation:c?.operation;if(!q)throw new y("INVALID_RESPONSE","The current purchase result is missing");return u&&Q.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(E=null),structuredClone(q)},destroy(){P=!0,T(),$.clear(),o.abort(),z.clear()}},T=t.subscribe(i=>{P||i.nodeId!==e||i.visit!==w||i.paywall?.receiptId!==C||(i.paywall.selectionGeneration??0)<(s.selectionGeneration??0)||(I(i.paywall.resolution),s={...s,resolution:i.paywall.resolution},m())});return{session:G,load:V}}function jn(t){let v=new Set,C=new Set,e=null;async function w(d,I){let P=!1;for(;!t.stopped&&t.key===d&&t.client.pendingCommand?.requestId===I;){if(!t.client.settle)throw new y("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(I),P=!0,t.client.pendingCommand?.requestId===I&&await new Promise($=>setTimeout($,1500))}t.stopped||t.key!==d||(P&&await t.client.get(),!(t.stopped||t.key!==d)&&v.add(d))}function A(d,I){e=I;let P=()=>{e===I&&(e=null),C.delete(d)};return I.then(P,$=>{P(),t.busy||t.fail($)}),I}function s(d){if(t.reviewing||v.has(d)||C.has(d)||t.stopped)return;C.add(d);let I=async()=>{if(t.reviewing||t.stopped||t.key!==d||v.has(d)){C.delete(d);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{I()},250);return}let P=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==d)return;if(t.client.pendingCommand){setTimeout(()=>{I()},250);return}}let $=t.client.view,ne=t.expected(),m=ne.requestId;try{await t.client.submit({operation:"shown",...ne})}catch(V){if(!(V instanceof y)||V.code!=="CONFLICT"||V.status!==409||t.client.pendingCommand)throw V;await t.client.get();let o=t.client.view;if(t.stopped||t.reviewing||t.key!==d||!o||!$||o.id!==$.id||o.source.versionId!==$.source.versionId||o.nodeId!==ne.nodeId||o.visit!==ne.visit||o.revision<=ne.revision||o.stopped||!o.screen&&(!o.paywall||o.paywall.receiptId!==$.paywall?.receiptId)||!["running","waiting"].includes(o.status)||t.client.pendingCommand)throw V;let R=t.expected();m=R.requestId,await t.client.submit({operation:"shown",...R})}await w(d,m)})();A(d,P)};I()}function S(){if(e)return e;let d=t.client.pendingCommand;if(d?.operation!=="shown")return null;let I=t.key;return C.add(I),A(I,(async()=>{await t.client.retry(),await w(I,d.requestId)})())}return{report:s,settled:S,get inFlight(){return e}}}function Wn(t){let v={},C=new Map;async function e(w){let A=t.client.view,s=A?.screen,S=s?.customerData.nodes[w.nodeId];if(t.stopped||t.busy||!A||!s||!S)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(w.action)){let V=t.document,o=V?Pn(V,w.nodeId):null,R=o?.type==="customer_data"?o.data.outputs?.[w.action]:void 0;R&&s.outputs.includes(R)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:R,answers:t.answers,selection:w.value?{[w.nodeId]:w.value}:{}}})):await t.onIntent?.(w,A);return}let I=w.action.startsWith("sources_")?S.resources.find(V=>V.key===w.value):null;if(w.action.startsWith("sources_")&&!I)throw new y("INVALID_REQUEST","Choose a current resource");let P=`${A.visit}:${w.nodeId}:${I?.key??""}`,$=C.get(P)??[null],m=v[w.nodeId]??{page:1,after:null,filter:"all",...I?{resourceKey:I.key}:{}};if(w.action==="filter"){let V=w.value;if(!V||!(S.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(V))throw new y("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:V},$.splice(0,$.length,null)}else if(w.action==="next"||w.action==="sources_next"){let V=I?.sources.at(-1),o=I?V?{kind:"ledger",cursor:{at:V.detail[0],id:V.id,type:"source"}}:null:s.dataCursors[w.nodeId];if(!o||!I&&!S.hasNext)return;$[m.page]=o,m={...m,page:m.page+1,after:o}}else if(w.action==="previous"||w.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:$[m.page-2]??null}}C.set(P,$),v={...v,[w.nodeId]:m},await t.perform(()=>t.client.get({nodeId:A.nodeId,visit:A.visit,revision:A.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},C.clear()}}}function Yn(t){let{doc:v,holder:C,reviewHolder:e,mountScreenPreview:w}=t,A=!1,s,S=0,d=null,I="",P,$=new Map,ne=o=>o?`${o.id}:${o.nodeId}:${o.visit}:${o.revision}:${o.paywall?.quote?.operationId??""}`:"";async function m(o){if(t.stopped||!t.client.review||A&&o===s&&P?.active)return;let R=!A||o!==s;A||(I=ne(t.client.view),$.set(I,structuredClone(t.answers))),A=!0,s=o,C.hidden=!0,t.suspend(!0),e.hidden=!1;let _=++S;R&&(P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),P=Ze(e,t.loadingOptions,"funnel",()=>{V()}));let Y=R?P:void 0;try{if(Y?.start(!1,t.client.view?.locale),_!==S||t.stopped)return;let J=t.client.review(o),Q=await(Y?.wait(J,Se)??J);if(t.stopped||_!==S||!A)return;if(!Q.review)throw new y("INVALID_RESPONSE","Historical projection is missing");d?.destroy(),d=null,Y||e.replaceChildren();let E=v.createElement("div"),z=Y?Ke(E,e):()=>{};e.append(E);let k=Q.run.locale.startsWith("zh"),N=t.chrome;E.style.cssText=N.history;let F=v.createElement("p");F.textContent=k?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",F.style.cssText=N.historyTitle,E.append(F);let ce=v.createElement("p");ce.style.cssText=N.historyNote,ce.textContent=Q.review.pages.length?k?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":k?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",E.append(ce);let Pe=Q.review.page?.receiptId,se=v.createElement("div");se.style.cssText=N.historyPages;for(let[G,T]of Q.review.pages.entries()){let i=v.createElement("button");i.type="button",i.textContent=k?`\u7B2C ${G+1} \u9875`:`Page ${G+1}`;let l=Pe!==void 0&&T.receiptId===Pe;i.style.cssText=l?N.primary:N.secondary,l&&i.setAttribute("aria-current","page"),Me(i,()=>t.chrome.focus),i.onclick=()=>{m(T.receiptId)},se.append(i)}if(se.childElementCount&&E.append(se),Q.review.page){let G=Q.review.page,T=v.createElement("div");T.inert=!0,T.style.cssText=N.historyPage,E.append(T),d=w(T,{mode:"live",rendererUrl:t.client.webViewUrl,title:G.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{_===S&&!t.stopped&&Y?.present(z)},onError:l=>{if(_!==S||t.stopped)return;let a=new Error(l);Y?.finish("error",a),d?.destroy(),d=null,E.remove(),t.fail(a)},onEscape:()=>{V()}});let i=d;if(i.update(G.document,Q.run.locale,{serverInput:{bindings:G.inputs,answers:G.answers,values:G.values}}),await i.ready,t.stopped||_!==S||!A)return}let te=k?{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"},me=v.createElement("div");me.style.cssText=N.historyRecords;for(let G of[...Q.review.coupons.map((T,i)=>`${k?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${te[T.status]}`),...Q.review.purchases.map((T,i)=>`${k?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Jn(T.status,k)}`)]){let T=v.createElement("p");T.textContent=G,T.style.margin="0",me.append(T)}me.childElementCount&&E.append(me),Q.review.page||Y?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(J){if(_!==S||t.stopped)return;Y?.finish("error",J),d?.destroy(),d=null,e.replaceChildren(),t.fail(J)}}async function V(){if(!A||t.stopped||!t.client.review)return;let o=++S;P?.finish("dismissed");try{if(await t.client.review(),t.stopped||o!==S)return;A=!1,S++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1;let R=t.client.view;ne(R)!==I?($.set(I,structuredClone(t.answers)),t.resetScreen()):($.delete(I),t.suspend(!1)),R&&await t.enqueue(R)}catch(R){if(o!==S||t.stopped)return;d?.destroy(),d=null,e.replaceChildren(),t.fail(R)}}return{get active(){return A},get receipt(){return s},open:m,exit:V,get drafts(){return new Map([...$].map(([o,R])=>[o,structuredClone(R)]))},stop(){A=!1,S++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1}}}var pn=5e3;async function rt(t,v,C){let e=v,w=e.prepared&&zn(e.prepared),A=()=>{};function s(){e.prepared&&e.prepared.state!=="adopted"&&w?.release()}let S=()=>e.prepared?.state==="shown"&&!!w?.modal,d=e.client.identitySignal,I;try{I=await Promise.all([import("./screen-renderer-YIIT742O.js"),import("./paywall-OAVC654P.js")]),e.signal?.throwIfAborted(),d?.throwIfAborted()}catch(n){throw s(),n}let[{mountScreenPreview:P},{showPaywall:$}]=I,ne=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&e.appManifestRelease?Bn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;ne?.start();let m=t.ownerDocument,V=Hn(m),o=m.createElement("section"),R=m.createElement("div"),_=m.createElement("div"),Y=m.createElement("div"),J=m.createElement("button");Y.hidden=!0,J.type="button";let Q=m.createElement("p"),E=m.createElement("p"),z=m.createElement("button"),k=m.createElement("button"),N=m.createElement("button"),F=m.createElement("dialog"),ce,Pe=!1;o.dataset.indianaFunnel="",o.dataset.longplayCloseOwner="sdk",o.setAttribute("aria-busy","false"),Q.setAttribute("role","status"),E.setAttribute("role","alert"),E.hidden=!0,z.type=k.type=N.type="button",_.append(z,J,Q,E,N,k),o.append(R,Y,_),t.append(o);let se=Un,te=un(se),me="",G=(m.documentElement.lang||"").startsWith("zh"),T,i="",l;for(let n of[z,J,N,k])Me(n,()=>te.focus);function a(){let n=G?"\u5173\u95ED":"Close";k.parentElement===F?(k.textContent="\xD7",k.setAttribute("aria-label",n),Ln(k,se)):(k.textContent=n,k.removeAttribute("aria-label"),k.style.cssText=te.link+";margin-inline-start:auto")}function b(n){let r=n?.screen?.content.document.theme??se,p=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,k.parentElement===F]);if(p===me)return;me=p,se=r;let H=k.parentElement===F;te=un(se,H),o.style.cssText=te.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),_.style.cssText=te.bar+(H?";margin-top:auto":""),z.style.cssText=J.style.cssText=te.secondary,N.style.cssText=te.primary,Q.style.cssText=te.status,E.style.cssText=te.alert,a(),dn(z)}function c(){_.hidden=z.hidden&&J.hidden&&N.hidden&&E.hidden&&!Q.textContent&&(k.hidden||k.parentElement!==_),T?.responsive&&l!==void 0&&T.setContentHeight(l+_.getBoundingClientRect().height)}b();let u=null,q=null,L=null,B="",M="",Ee=!1,Re="",en="",Ue="",h=!1,le=0,$e=!1,fn="",nn=null,tn=Promise.resolve(),mn=!e.client.view,j=C,Te,_e,xe="",Ge,ue=!1,qe=null,he=!1,Qe=()=>e.client.pendingCommand?.operation==="close",de=null,X=null,wn=On({document:m,run:async()=>{(!q?.observing||e.client.pendingCommand)&&await on()},delay:()=>{if(!(h||!L||!["running","waiting"].includes(L.status)&&!e.client.pendingCommand)&&!(q?.observing&&!e.client.pendingCommand))return L.pendingRequest||e.client.pendingCommand?1500:pn},hiddenDelay:()=>!h&&e.client.pendingCommand?15e3:void 0}),K=null;function rn(){return X&&e.client.hasDurableJournal===!0&&K?.acknowledged===!0&&K.operationId===X.operationId&&e.client.view?.id===K.runId&&e.client.view?.status==="closed"&&e.client.view.revision===K.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?X:null}function yn(n){let r=n.run.paywall;if(K&&n.settlement?.requestId===K.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===K.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===K.revision+1&&n.run.nodeId===K.nodeId&&n.run.visit===K.visit&&r?.receiptId===K.receiptId&&r.selectionGeneration===K.selectionGeneration&&(r.quote?.operationId??null)===K.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===K.operationId){let p=K.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(p||r.canReselect===!0&&H.type==="native")&&(K.acknowledged=!0)}}let De=null,Je=new Set,we={},Ae=!1,pe=(n,r=null)=>{h||(De=r,Ae=!1,E.textContent=$n(n,G),E.hidden=!1,N.hidden=e.client.pendingCommand===null,c(),Ce(e.onError,n))},gn=()=>{h||(De=null,E.textContent=Gn(G),E.hidden=!1,N.hidden=!0,c())};function ke(){let n=e.client.view;if(!n)throw new y("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let O=Yn({client:e.client,doc:m,holder:R,reviewHolder:Y,mountScreenPreview:P,loadingOptions:e,get chrome(){return te},get stopped(){return h},get answers(){return we},suspend(n){q?.setSuspended(n)},resetScreen(){B="",M="",Re=""},enqueue:ye,fail:pe}),Le=jn({client:e.client,expected:ke,fail:pe,get stopped(){return h},get reviewing(){return O.active},get key(){return B},get busy(){return le},get staleRead(){return nn}}),ze=Wn({client:e.client,expected:ke,perform:Fe,onIntent:e.onCustomerDataIntent,get stopped(){return h},get busy(){return le},get document(){return u?.document},get answers(){return we}}),Be=n=>`${n.id}:${n.nodeId}:${n.visit}`,Ne=n=>n&&(n.screen||n.paywall)?Be(n):"";function ve(){let n=e.client.view;z.disabled=!O.active&&(le>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!Ne(n)||M!==Ne(n)),z.hidden=!O.active&&!n?.canBack,dn(z);let r=!!q&&!O.active;k.hidden=r&&!j?.active||Pe&&!O.active,J.hidden=!e.client.review||r&&!n?.canBack,r&&(Q.textContent=""),c()}async function hn(n){if(!n)return;let r=e.client.view;await n;let p=e.client.view;if(!r||!p||p.id!==r.id||p.nodeId!==r.nodeId||p.visit!==r.visit||p.stopped||!["running","waiting"].includes(p.status))throw new y("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Fe(n,r=!1,p){if(!((le||he||de||X)&&!r||h||O.active&&!r)){le++,o.setAttribute("aria-busy","true"),E.hidden=!0,De=null,Ae=!1,ve();try{if(r||await hn(Le.inFlight),h)return;let H=await n();h||await ye(e.client.view??H.run)}catch(H){p?.(H)&&e.client.pendingCommand===null?gn():pe(H,e.client.pendingCommand?.requestId??null)}finally{le=Math.max(0,le-1),o.setAttribute("aria-busy",String(le>0)),h||(N.hidden=e.client.pendingCommand===null,ve())}}}function He(){wn.schedule()}async function on(){if(!(h||$e||le)){if(O.active){await O.open(O.receipt);return}$e=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,p=ze.queries,H=await e.client.get(r?.screen&&Object.keys(p).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:p}:void 0);Ae&&!h&&(Ae=!1,E.hidden=!0,c()),!h&&p===ze.queries&&await ye(e.client.view??H.run)}catch(n){pe(n),Ae=!h}finally{$e=!1}}}function je(n,r,p){if(j?.active){let ae=j;return ae.setDismissHandler(()=>vn(ae)),ae}let H=Ze(t,e,"funnel",()=>vn(H),Mn);return j=H,H.start(n,r,p),H}function vn(n){h||ue||(ue=!0,n.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):ie())}function sn(){clearTimeout(Ge?.timeout),Ge=void 0}function Ie(){Pe=!1,sn(),Te?.abort(),Te=void 0,u?.destroy(),u=null,q?.destroy(),q=null,_e?.(),_e=void 0,F.open&&F.close(),R.replaceChildren(),R.style.cssText="",l=void 0,B="",M="",Ee=!1,Re="",Ue=""}function In(){let n=m.defaultView;T?.responsive&&n&&u?.resizeViewport?.(n.innerHeight,n.innerWidth)}function an(){T?.destroy(),T=void 0,i=""}function We(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){F.open&&F.close(),an(),k.parentElement!==_&&_.append(k),o.parentElement!==t&&t.append(o);for(let ae of["flex","display","flex-direction","justify-content"])R.style.removeProperty(ae);b(n),c();return}o.parentElement!==F&&(F.append(k,o),t.append(F)),R.style.flex="1 0 auto",R.style.display="flex",R.style.flexDirection="column",R.style.justifyContent="center",b(n);let p=n.screen.content.document,H=JSON.stringify([r,me]);if(H!==i){an(),i=H;let ae={sm:420,md:640,lg:900},ge="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";F.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${se.background};color:${se.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ae[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${ge};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),T=Sn(F,{presentation:r,theme:p.theme,pages:p.pages},In),T.latch()}c(),F.setAttribute("aria-label",(ce?.screen===n.screen?.content.document.name?ce?.label:void 0)??u?.document?.name??n.screen?.content.document.name??"Funnel")}async function Xn(n){if(h||ue||he&&(Qe()||["running","waiting"].includes(n.status))||(L=n,De&&e.client.pendingCommand?.requestId!==De&&(E.hidden=!0,De=null),G=n.locale.startsWith("zh"),J.textContent=G?"\u56DE\u770B":"History",z.textContent=O.active?G?"\u8FD4\u56DE\u5F53\u524D":"Return to current":G?"\u8FD4\u56DE":"Back",a(),N.textContent=G?"\u91CD\u8BD5":"Retry",N.hidden=e.client.pendingCommand===null,Q.textContent=n.pendingRequest?G?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?G?"\u7B49\u5F85\u4E2D":"Waiting":"",ve(),fn!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(fn=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,Ce(e.onState,structuredClone(n))),h||ue))return;if((!n.pendingRequest||he&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){ie();return}if(n.stopped&&S()){ie();return}if(n.stopped||e.client.configurationReady===!1){O.stop(),s(),Ie(),j?.finish("skipped"),o.hidden=!0,He();return}if(o.hidden=!1,O.active){He();return}let r=Ne(n),p=e.client.view;if(p&&p.revision>n.revision&&Ne(p)!==r)return;let H=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==B&&(B&&j?.finish("dismissed"),Ie(),B=r,we={...n.answers},ze.reset());let ae=Be(n);if(xe===ae){o.hidden=!0;return}if(H&&!r){o.hidden=!0;let U=e.prepared?.state==="shown"?null:je(!0,n.locale);!h&&!ue&&Ge?.key!==ae&&(sn(),Ge={key:ae,timeout:setTimeout(()=>{let g=e.client.view;if(h||!U?.active&&e.prepared?.state!=="shown"||!g||Be(g)!==ae)return;xe=ae;let W=new Error("Funnel screen preparation timed out");U?.finish("error",W),s(),Ie(),pe(W)},Se)}),He();return}sn();let Z=U=>{let g=e.client.view;return!h&&!ue&&!qe&&!U.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Ne(g)===r},ge=(U,g)=>{Z(g)&&(xe=r,j?.finish("error",U),Ie(),o.hidden=!0,pe(U))};if(r||((n.instruction&&n.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(n.status))&&s(),We(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&j?.finish("skipped")),n.screen){s();let U=n.screen.content;if(!u){let x=n.screen.presentation.type!=="inline",re=je(x,n.locale);if(h||ue)return;let ee=(Te=new AbortController).signal;We(n),_e=x?Vn(F):Ke(o,t),u=P(R,{mode:"live",closeActions:Array.from(new Set([...e.closeActions??[],...U.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){Z(ee)&&(Pe=f,ve())},rendererUrl:e.client.webViewUrl,title:U.document.name,...x?{hostPresentation:()=>T?.type??n.screen.presentation.type}:{},onResize:f=>{l=f,T?.responsive&&T.setContentHeight(f+_.getBoundingClientRect().height)},onAction(f,fe={},tt={}){if(O.active||!Z(ee)||M!==r)return;we={...we,...tt};let ln=n.screen?.inputs??[],Cn=Object.fromEntries(ln.filter(({variable:Oe})=>Object.hasOwn(we,Oe)).map(({variable:Oe})=>[Oe,we[Oe]]));if(Qn(ln,Cn).length){gn();return}Fe(()=>e.client.submit({operation:"submit",...ke(),input:{type:"screen",output:f,answers:Cn,selection:fe}}),!1,Oe=>xn(Oe,ln))},onAnswers:f=>{O.active||!Z(ee)||M!==r||(we={...we,...f})},onCustomerDataIntent:f=>{O.active||!Z(ee)||M!==r||ze.intent(f).catch(pe)},onEscape:()=>{!Z(ee)||M!==r||O.active||de||X||be()},onError:f=>{let fe=new Error(f);M===r?pe(fe):ge(fe,ee)},onRendered:f=>{if(!(!Z(ee)||M===r))try{re.present(fe=>{_e?.(),_e=void 0,f&&(ce={screen:U.document.name,label:f},F.setAttribute("aria-label",f)),x&&(F.showModal(),T?.responsive&&F.focus({preventScroll:!0}),!fe&&e.loading!=="host"&&_n(F,T?.type??n.screen.presentation.type,T?.responsive)),M=r,Ee=x,ve()}),Z(ee)&&Le.report(r)}catch(fe){ge(fe,ee)}}}),In()}let g={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:we,values:n.screen.values}},W=JSON.stringify([U,n.locale,g.parameters,n.screen.inputs,n.screen.values]);if(W!==Re)u.update(U.document,n.locale,g),Re=W,en=JSON.stringify(g.capabilities),Ue=JSON.stringify(g.customerData);else{let x=JSON.stringify(g.capabilities);x!==en&&(u.updateCapabilities(g.capabilities),en=x),JSON.stringify(g.customerData)!==Ue&&(u.updateCustomerData(g.customerData),Ue=JSON.stringify(g.customerData))}let oe=u;if(oe)try{await(j?.wait(oe.ready)??oe.ready)}catch(x){Te&&ge(x,Te.signal)}}else if(n.paywall&&!q){let U=n.paywall.resolution,g="document"in U?U.document:null,W=w,oe=null,x=(Te=new AbortController).signal,re={loading:"host",signal:x,canInteract:()=>Z(x)&&!O.active&&!de&&!X,beforeAction:async()=>{le++;try{await hn(Le.settled()),E.hidden=!0,De=null,Ae=!1,c()}finally{le=Math.max(0,le-1)}},start:()=>cn(e.client),onObservationChange:He,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,resumeCheckout:e.resumeCheckout,allowNewPurchase:e.allowNewPurchase,checkoutNavigation:e.checkoutNavigation,terminateCheckout:e.terminateCheckout,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,claimCoupon:e.claimCoupon,onEvent:e.onEvent,onOpenUrl:f=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:f,openIn:"same_window"}):m.defaultView?.location.assign(f),onAction:async f=>{if(O.active)return;let fe=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:f,answers:{}}});await ye(e.client.view??fe.run)},onError:f=>{M===r?pe(f):ge(f,x)}},ee={quoteError:f=>Ce(e.onError,f),present(f){Z(x)&&(oe?.present(()=>{f(),M=r,Ee=!!R.querySelector("dialog[open]"),ve()}),Z(x)&&Le.report(r))},async dismiss(){if(!(h||x.aborted||O.active||de||X||!he&&!Z(x))){if(he=!0,(e.resumeCheckout||e.terminateCheckout)&&nt()){L=e.client.view,ie();return}await be()}}};if(W){let f=await W.adopt(n,{options:re,handoff:ee,start:()=>cn(e.client)});f&&Z(x)&&!h?(We(n),q=f,j?.active&&j.present(()=>{}),M=r,Ee=W.modal,ve(),Le.report(r),O.active&&q.setSuspended(!0)):(f?.destroy(),s())}if(h||ue)return;if(!q){if(oe=je(!0,n.locale,g),h||ue)return;We(n);let f=await $(R,re,ee).catch(fe=>(ge(fe,x),null));!Z(x)&&!(he&&!h&&!x.aborted)?f?.host?.destroy():f&&(q=f.host,q?.setSuspended(O.active))}}if(h||ue)return;ve();let D=n.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Je.has(D.receiptId)){let U=m.createElement("button");U.type="button",U.style.cssText=te.primary,Me(U,()=>te.focus),R.style.cssText=te.stage,U.textContent=D.type==="open_url"?`${G?"\u524D\u5F80":"Continue to"} ${new URL(D.url).host}`:G?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let g=ke(),W=D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="new_window"?Zn(D.url):null;Fe(async()=>{let oe="success";if(D.type==="open_url")if(e.onOpenUrl)try{oe=await e.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(re){Ce(e.onError,re),oe="failed"}else oe=D.openIn==="new_window"&&!W?"failed":"opened";if(D.type==="event"){if(!e.onEvent)throw new y("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(D.event)}if(h||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new y("PRECONDITION_FAILED","The client action visit changed");let x=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:D.receiptId,outcome:oe}});return Je.add(D.receiptId),D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="same_window"&&m.defaultView?.location.assign(D.url),x})},j?.active?j.present(()=>R.replaceChildren(U)):R.replaceChildren(U)}!n.pendingRequest&&n.status==="completed"&&!Je.has(`complete:${n.id}`)&&(Je.add(`complete:${n.id}`),Ce(e.onComplete,structuredClone(n))),He()}function Zn(n){let r=m.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function ye(n){return ve(),tn=tn.catch(()=>{}).then(async()=>{try{await Xn(n)}catch(r){throw j?.active&&(xe=Be(n),j.finish("error",r),Ie(),o.hidden=!0),r}}),tn}let Kn=e.client.subscribe(n=>{if(!mn){if(n.stopped&&(Ee||S())&&!he){L=n,ie();return}!he&&(n.stopped||e.client.configurationReady===!1||B&&M!==B&&(Ne(n)!==B||["closed","ineligible","failed"].includes(n.status)))&&(Ie(),j?.finish("dismissed"),o.hidden=!0),ye(n).catch(pe)}}),et=e.client.subscribeError?.(pe);function nt(){let n=e.client.view,r=n?.paywall;return!!r?.operation&&!!n&&["running","waiting"].includes(n.status)&&Dn(Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function be(n){if(qe)return qe;if(h||!n&&(de||X))return Promise.resolve();let r=!n&&Qe();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(L=e.client.view,ie(),Promise.resolve()):(qe=Fe(async()=>{let p=r?await e.client.retry():await e.client.submit({operation:"close",...n??ke()});return n&&yn(p),p},!0).then(()=>{let p=e.client.view;p?.status==="closed"&&!Qe()&&(L=p,ie())}).finally(()=>{qe=null}),qe)}function ie(){ne?.destroy(),!h&&(h=!0,A(),s(),e.signal?.removeEventListener("abort",ie),d?.removeEventListener("abort",ie),j?.finish("dismissed"),wn.destroy(),Kn(),et?.(),Ie(),an(),O.stop(),F.remove(),o.remove(),V(),Ce(e.onDismiss,L?structuredClone(L):null))}z.onclick=()=>{if(!z.disabled){if(O.active){O.exit();return}Fe(()=>e.client.submit({operation:"back",...ke()}))}},J.onclick=()=>{O.open()},k.onclick=()=>{j?.active?j.dismiss():de||be()},N.onclick=()=>{Qe()?be():Fe(()=>e.client.retry())},F.addEventListener("cancel",n=>{n.preventDefault(),j?.active?j.dismiss():de||be()}),e.signal?.addEventListener("abort",ie,{once:!0}),d?.addEventListener("abort",ie,{once:!0});let Ye=!1;w&&(A=w.onClose(()=>{h||ue||(ue=!0,j?.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):Ye=!0)}));let bn={destroy:ie,refresh:on,get recovery(){let n=rn();if(n)return n;if(!h&&!le&&!he&&!de&&q){let r=q.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(de)return de;let n=rn();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,p=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let D=q?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:p())}let H=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||X&&e.client.view?.status==="closed")||le||$e||qe||O.active||!q&&!X&&!H)return Promise.resolve(p());let ae=q,Z=(async()=>{try{if(!X&&H){let g=await e.client.retry();return await ye(e.client.view??g.run),p()}if(!X){let g=await ae.prepareFallback();if(g.type!=="native")return g;if(e.client.hasDurableJournal!==!0)return p();X=g}let D=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(D.length){let g=D.find(oe=>oe.operation==="close");if(!g||!K||g.requestId!==K.requestId)return p();let W=await e.client.retry();yn(W),await ye(e.client.view??W.run)}else{let g=e.client.view,W=g?.paywall;if(!g||!W||W.selectionGeneration===void 0||(W.quote?.operationId??null)!==X.operationId||X.operationId!==null&&W.canReselect!==!0)return p();let oe=W.selectionGeneration,x=await e.client.get();await ye(e.client.view??x.run);let re=e.client.view,ee=re?.paywall;if(!re||!ee||!["running","waiting"].includes(re.status)||re.stopped||re.id!==g.id||re.nodeId!==g.nodeId||re.visit!==g.visit||ee.receiptId!==W.receiptId||ee.selectionGeneration!==oe||(ee.quote?.operationId??null)!==X.operationId||X.operationId!==null&&ee.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return p();let f=ke();K={runId:re.id,operationId:X.operationId,revision:f.revision,requestId:f.requestId,nodeId:re.nodeId,visit:re.visit,receiptId:ee.receiptId,selectionGeneration:oe,acknowledged:!1},await be(f)}let U=rn();return U?(ie(),U):p()}catch(D){return pe(D),p()}})();de=Z;let ge=()=>{de===Z&&(de=null)};return Z.then(ge,ge),Z},review:O.open,exitReview:O.exit,get unappliedDrafts(){return O.drafts}};try{let n=e.client.view;if(n)((e.client.viewAgeMs??pn)>=pn||n.instruction?.type==="evaluate_segment")&&(nn=on().finally(()=>{nn=null})),await ye(n);else{if(o.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=Ye||e.prepared?.state==="shown"?null:je(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(h||ue&&!Ye)throw new DOMException("Presentation cancelled","AbortError");let p=e.client.get(),H=await(r?r.wait(p,Se):ot(p,Se));if(mn=!1,Ye)return h||await be().finally(ie),bn;await ye(e.client.view??H.run)}}catch(n){throw j?.finish("error",n),ie(),n}return bn}function ot(t,v){let C;return Promise.race([t,new Promise((e,w)=>{C=setTimeout(()=>w(new Error("Presentation data timed out")),v)})]).finally(()=>clearTimeout(C))}function Gt(t,v,C){return rt(t,v,C)}export{rt as a,Gt as b};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-CR2XJ2CX.js";var c=e.enum(["replace","stack_native"]);export{c as a};
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-TASEZY5T.js";import"./chunk-Q676H74B.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk-HKXFCRVT.js";import"./chunk-XGNXZWZL.js";import"./chunk-TASEZY5T.js";import"./chunk-2KJLN65C.js";import"./chunk-W32FI2A2.js";import"./chunk-AOGDCT4T.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-3NCMYTNG.js";import"./chunk-AB7GEGZ2.js";import"./chunk-Q676H74B.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-SLUA7ABW.js";import"./chunk-OCWSWXCW.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
@@ -1 +0,0 @@
1
- import{N as r,O as m,h as e}from"./chunk-S43TYW3V.js";import"./chunk-WQ3O5RXN.js";import"./chunk-XJRDO3NI.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.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-LC6UCDWE.js";import"./chunk-UV4H6VCS.js";import"./chunk-D3OYXTMC.js";import"./chunk-4KLXQKNO.js";import"./chunk-S43TYW3V.js";import"./chunk-ECKVJGXQ.js";import"./chunk-GH6FM44P.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-AB7GEGZ2.js";import"./chunk-E7CCHUSO.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{a as Tt,c as Ot,d as et,f as tt,g as Dt,k as Lt}from"./chunk-XGNXZWZL.js";import{b as Xe}from"./chunk-W32FI2A2.js";import{d as Et,e as xt,f as It,h as Ze,i as De,j as At,k as Rt,l as St}from"./chunk-AOGDCT4T.js";import{a as bt,c as Je,d as Ct,e as vt}from"./chunk-3NCMYTNG.js";import{b as ce}from"./chunk-AB7GEGZ2.js";import{a as pe,c as Ke,e as Pt,h as kt}from"./chunk-Q676H74B.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import{ca as Ce,ea as ve,i as gt}from"./chunk-WZMZMJCK.js";import{c as fe,j as be}from"./chunk-T2KWLYCW.js";import{c as Ye}from"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import{a as v}from"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as M}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function Nt(O,o,R){if(o.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let P=O?be.parse(O):null;if(await R.onComplete?.(o),!P||!R.check)return;let L=be.parse(await R.check());if(L.internal_feature_id!==P.internal_feature_id||L.quantity!==P.quantity||P.observation!==void 0&&(L.observation===void 0||L.observation.requirementDigest!==P.observation.requirementDigest||L.observation.authority!==P.observation.authority||Ye(L.observation.subject)!==Ye(P.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");L.allowed&&await R.onAccessGranted?.(L)}function nt(O){return Object.entries(O.document.buttons).filter(([,o])=>o.type==="checkout"&&o.product.type==="fixed"&&!ce(o.product,{},O.capabilities)).map(([o])=>o)}function _t(O,o){let R=o.lines[0];if(o.lines.length!==1||!R)return;let P=R.productVersionId,{screen:L,buttons:J}=O.document,x=new Map((R.prepaid??[]).map(p=>[p.internal_feature_id,p.quantity]));function K(p,m){if(p.hidden)return!1;if(p.type==="plan_picker"&&O.capabilities.pickers[p.id]?.options.includes(P))return m[p.id]=P,!0;if(p.type==="quantity_picker"){let Q=x.get(p.internalFeatureId);return Q!==void 0&&(!p.bind?.plan||p.bind.plan===P)&&(m[p.id]=Q),!1}if(p.type==="button"&&p.action){let Q=J[p.action];return Q?.type==="checkout"&&Q.product.type==="fixed"&&Q.product.productVersionId===P}if(p.type!=="stack")return!1;let j=p.interaction,r=p.bind?.plan===P;for(let[Q,f]of p.children.entries()){let te={},S=K(f,te);if(j?.type==="toggle"||j?.type==="tabs"){if(!S)continue;return m[p.id]=j.type==="toggle"?Q===0:f.id,Object.assign(m,te),!0}Object.assign(m,te),S&&(r=!0,j?.type==="select"&&j.purpose==="product"&&j.pickerId&&f.type==="stack"&&f.bind?.plan===P&&(m[p.id]=f.id,m[j.pickerId]=P))}return r}for(let p of L.pages){let m={__page:p.id};if(K(p.root,m))return m}}async function Pn(O,o,R){let P=o.focusAtReveal?()=>{}:Ze(O.ownerDocument),L=()=>{x.finish("dismissed"),P()},J=()=>L(),x=At(O,o,"paywall",()=>{L(),M(o.onDismiss)},Tt);o.signal?.throwIfAborted(),o.signal?.addEventListener("abort",J,{once:!0});let K=null,p,m,j;try{if(x.start(!0,o.loadingDocument?.screen.strings.defaultLocale,o.loadingDocument??null),x.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(K=o.check?be.parse(await x.wait(o.check(),De)):null,K?.allowed)return x.finish("skipped"),o.signal?.removeEventListener("abort",J),P(),await o.onAccessGranted?.(K),{check:K,host:null};let[e,t]=await Promise.allSettled([x.wait(import("./screen-renderer-YIIT742O.js")),x.wait(o.start().then(i=>(x.cancelled&&i.destroy(),i)),De)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;j=e.value,p=t.value,o.signal?.throwIfAborted(),p.signal?.throwIfAborted(),p.signal?.addEventListener("abort",J,{once:!0});let n=p.view??await x.wait(p.refresh(),De);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");p.signal?.throwIfAborted(),m=n}catch(e){throw x.finish("error",e),o.signal?.removeEventListener("abort",J),p?.signal?.removeEventListener("abort",J),p?.destroy(),P(),e}let r=p,{mountScreenPreview:Q}=j,f=O.ownerDocument,te=new AbortController,S=f.createElement("section"),le=f.createElement("div"),G=f.createElement("div"),Le=o.mountControls,q=Le?f.createElement("div"):void 0,l=f.createElement("p"),g=f.createElement("button"),k=f.createElement("button"),I=f.createElement("dialog"),rt=r.locale||m.document.screen.strings.defaultLocale,s=rt.toLowerCase().startsWith("zh"),Ut=s?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",Mt=s?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",D=Ot(m.document.screen.theme);S.dataset.indianaPaywall="",S.setAttribute("aria-label",m.document.name),S.style.cssText=D.root,G.style.cssText=D.controls,l.style.cssText=D.message,l.setAttribute("role","status"),k.style.cssText=D.link,k.textContent=s?"\u5173\u95ED":"Close",g.style.cssText=D.secondary,g.textContent=s?"\u91CD\u8BD5":"Retry",g.hidden=!0,G.append(l,g,k),q&&(q.style.cssText="flex:1 0 100%;min-width:0",q.hidden=!0,G.prepend(q)),S.append(le,G);let Ne=()=>{if(q){let i=!q.childElementCount&&!q.textContent?.trim();q.hidden!==i&&(q.hidden=i)}let e=ne??G,t=[...e.children].every(i=>i===l?!l.textContent:i.hidden),n=[...e.children].some(i=>i===k?!1:i===l?!!l.textContent:!i.hidden);e.style.cssText=t?D.controls.replace(/padding:[^;]+/,"padding:0"):n?`${D.controls};${D.pinned}`:D.controls,Me()},it=typeof MutationObserver>"u"?void 0:new MutationObserver(Ne);it?.observe(S,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Pe=m.document.presentation,qt=Object.entries(m.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),V,ot,_e=!1,at=JSON.stringify(m.capabilities),st=e=>oe&&!he?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):nt(e);function ke(e){if(y)return;m=e;let t=JSON.stringify(e.capabilities);t!==at&&(V?.updateCapabilities(pe(e),st(e)),at=t),Ht(e),ye()}let E,Ue=0;function Me(){let e=f.defaultView;if(!E?.responsive||!e)return;let t=ne??G,n=e.innerHeight-(E.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ue=Math.max(1,n-t.getBoundingClientRect().height),V?.resizeViewport?.(Ue,e.innerWidth)}let y=!1,oe=!1,C=null,qe,Ee=!1,ct=!1,ae=!1,Ve,$e=!1,X,ne;function Vt(){return oe||y||X||$e?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Je(r)}let A=()=>!y&&!Ee&&!X&&o.canInteract?.()!==!1,$,ue=!1,u=null,Z=null,He="",se=()=>o.checkoutNavigation==="after_confirmation"&&!!(o.terminateCheckout||o.resumeCheckout),me={},he,W=null;function ye(){if(!se()||!V?.updateCheckoutControls)return;let e=r.quote,t=!W&&!!e&&!!r.operation&&H(r.operation).type==="checkout",n=Object.entries(m.document.buttons).flatMap(([i,a])=>a.type==="checkout"?[{actionId:i,policy:a}]:[]);V.updateCheckoutControls({actions:n.map(({actionId:i})=>i),resume:t?n.filter(({actionId:i,policy:a})=>Ae(e,m,i,a.product,me)).map(({actionId:i})=>i):[],resumeLabel:s?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:he})}function lt(){Z?.remove(),Z=null}async function Be(){if(W)return;if(o.resumeCheckout&&r.operation){await o.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(H(e).type!=="checkout")return N(e,!1);A()&&(xe.delete(e.operationId),await Re(e))}function ut(){l.textContent=s?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",g.hidden=!0}async function dt(e=!1){let t=W;if(!t)return;g.hidden=!0;let n=Date.now()+2e4;for(;A();){let i=await r.read();if(i.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let a=H(i);if(a.type==="native"){W=null,lt(),C=t.selection,$=t.coupon,ue=!1,await ge();return}if(a.type==="complete"||a.type==="fulfillment"||a.type==="recording"){W=null,await N(i,!1);return}if(e&&a.type==="checkout"){e=!1;try{await o.terminateCheckout(t.operationId)}catch(h){M(o.onError,h)}}if(Date.now()>=n)break;await Xe(1e3,f,te.signal)}y||ut()}async function $t(e,t,n){W={operationId:e,selection:t,coupon:n};let i=!1;try{await o.terminateCheckout(e)}catch(a){if(a instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(a.code)){W=null,l.textContent=s?"\u8BF7\u7EE7\u7EED\u539F\u8BA2\u5355\uFF0C\u6216\u7B49\u5F85\u5B83\u8FC7\u671F\u540E\u518D\u66F4\u6362\u65B9\u6848\u3002":"Continue your original checkout, or wait for it to expire before changing plans.",M(o.onError,a);return}i=a instanceof v&&(a.status??0)>=500,M(o.onError,a)}A()&&await dt(i)}function Fe(e,t,n,i,a){let h=pe(e).checkoutCoupons?.[t],c=h?h.products[n]:o.claimCoupon&&a?gt(e.capabilities,a,i):void 0;return c?.couponId&&c.planVersionId===n?{id:c.couponId,offerId:c.offerId}:void 0}function Ht(e){oe||C||r.quote||r.operation||He&&l.textContent===He||(l.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":s?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let xe=new Map,Ie=!1;function Ae(e,t,n,i,a,h){let c=e.lines.length===1?e.lines[0]:void 0,w=ce(i,a,t.capabilities);if(!c||!w||c.productVersionId!==w)return!1;let B=Fe(t,n,w,a,h);if((B||pe(t).checkoutCoupons?.[n])&&(B?.id??null)!==(e.discount?.couponId??null))return!1;let _;try{_=ve(t.document.screen,w,a,t.capabilities)}catch{return!1}let ie=Object.fromEntries((c.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(_),...Object.keys(ie)])].every(z=>(_[z]??0)===(ie[z]??0))}let H=e=>bt({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:y,canReselect:r.canReselect});async function Re(e){let t=e.merchantExecution;if(!(!A()||!e.checkoutUrl||o.checkoutNavigation==="after_confirmation"&&H(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||xe.get(e.operationId)===e.checkoutUrl)){xe.set(e.operationId,e.checkoutUrl);try{o.onCheckoutUrl?await o.onCheckoutUrl(e.checkoutUrl):f.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw xe.delete(e.operationId),n}}}let re=(e,t=!1)=>{if(e instanceof Ke)u=null,l.textContent=e.customerMessage(s);else if(Dt(e))u=null,l.textContent=t?s?"\u5F53\u524D\u65E0\u6CD5\u5728\u6B64\u8D2D\u4E70\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u3002":"Purchases aren\u2019t available here right now. Payment hasn\u2019t started. Contact the merchant for help.":tt(e,s);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(u=null,l.textContent=s?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):r.canReselect===!0&&!C?l.textContent=s?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?l.textContent=s?"\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.":l.textContent=s?"\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 l.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?tt(e,s):e instanceof v?e.message:s?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";g.hidden=u===null,He=l.textContent,t&&!E?.responsive&&l.scrollIntoView?.({block:"nearest"}),M(t&&R?.quoteError?R.quoteError:o.onError,e)},Se=new WeakMap;function Te(e){oe=e,g.disabled=e,V?.updateCapabilities?.(pe(m),st(m));for(let t of Z?.querySelectorAll("button")??[])e?(Se.set(t,t.disabled),t.disabled=!0):Se.has(t)&&(t.disabled=Se.get(t),Se.delete(t)),et(t)}function je(){l.textContent=s?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function Bt(e){if(o.beforeAction)try{await o.beforeAction()}catch(t){throw t instanceof Ke?(C=null,ue=!1,u=null):u=e,t}}async function U(e,t){if(oe||y)return;if(!A()){je();return}let n=e===ge,i=n?Mt:Ut,a=se()&&t!==void 0;he=a?t:void 0,Te(!0),ye(),g.hidden=!0,l.textContent=a?"":i;try{if((e!==Be||!o.resumeCheckout)&&await Bt(e),y)return;if(!A()){u=e,g.hidden=!1,je();return}await e()}catch(h){y||re(h,n&&!a)}finally{he=void 0,Te(!1),ye(),l.textContent===i&&(l.textContent="")}}async function Ft(e){await Nt(K,e,o)}function ft(e){return Je(r).type==="recording"||H(e).type==="recording"}function pt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],i=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),a=t?n.length===1&&n[0]?.amountMinor===i&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===i&&e.lines[0],h=i===null?fe(t.subtotalMinor-t.discountMinor,e.currency)+(s?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):fe(i,e.currency)+(a?Ce(a.interval,s?"zh-CN":"en",a.intervalCount??1):""),c=e.lines.map(w=>w.productName).join(", ");return{label:c?`${c} \xB7 ${h}`:h,recurring:a}}async function N(e,t=o.checkoutNavigation!=="after_confirmation"){if(y)return;if(!A()){u=async()=>N(await r.read()),g.hidden=!1;return}if(l.textContent=Lt(e.status,s),ft(e)){let a=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";l.textContent=a?s?"\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.":s?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",g.textContent=s?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",u=async()=>N(await r.read()),g.hidden=!1;return}if(e.problem){let a=e.problem;u=we,g.textContent=s?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",re(new v(a.code,a.reason==="RESULT_UNKNOWN"?s?"\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"?s?"\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"?s?"\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"?s?"\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.":s?"\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)&&(l.textContent=s?"\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"){u=null,await Ft(e);return}if(e.status!=="pending"){if(r.canReselect===!1){l.textContent=s?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",g.textContent=s?"\u67E5\u8BE2\u7ED3\u679C":"Check result",u=async()=>N(await r.read()),g.hidden=!1;return}e.status==="cancelled"?l.textContent=s?"\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"&&(l.textContent=s?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),g.textContent=s?"\u91CD\u8BD5":"Retry",u=null,C=null;return}if(!t&&H(e).type==="checkout"){if(W){ut();return}if(se()){l.textContent="",Ie=!1,u=null,ye();return}let a=r.quote,h=a?.operationId===e.operationId?pt(a).label:"";l.textContent=Ie?h?s?`${h} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${h} is still unpaid. Choose it again to continue paying.`:s?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ie=!1,u=null;return}await Re(e);let n=Date.now()+6e5,i=2e3;_e=!0,M(o.onObservationChange,!0);try{for(;!y&&Date.now()<n;){if(await Xe(i,f,te.signal),y)return;if(!A()){u=async()=>N(await r.read()),g.hidden=!1;return}let a=await r.read();if(!t&&H(a).type==="checkout"){await N(a,!1);return}if(!a.problem&&a.status==="pending"&&await Re(a),a.status!=="pending"||a.problem||ft(a)){await N(a);return}i=Math.min(i*1.5,3e4)}}finally{_e=!1,M(o.onObservationChange,!1)}u=async()=>N(await r.read()),g.hidden=!1}async function Qe(e=!1){let t=await r.read();if(y)return;if(!A()){u=()=>Qe(e),g.hidden=!1;return}let n=r.quote;if(n&&Pt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!r.pendingCancellation){mt(n);return}await N(t,e||void 0)}async function we(){lt(),u=we;let e=await r.confirm();if(!A()){u=we,g.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Re(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!o.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await o.onPurchase({operation:e,signal:te.signal})}}u=async()=>N(await r.read()),await N(e,!0)}function mt(e){Z?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());l.textContent=t?s?"\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=f.createElement("div"),i=f.createElement("button"),a=f.createElement("button"),h=f.createElement("div"),c=f.createElement("p"),w=e.merchantTerms,B=s?"zh-CN":"en",_=w?.subscriptionTerms?.items??[],ie=w?w.subscriptionTerms?.trial?.days:e.lines.find(d=>d.trial)?.trial?.days,ee=ie===void 0?null:w?w.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(d=>d.trial)?0:null,z=(d,b)=>s?`${b} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${d}`:`Then ${d} after the ${b}-day trial`,{label:ze,recurring:ht}=pt(e),jt=e.lines.map(d=>d.productName).join(", "),yt=ee===null?"":`${s?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${fe(ee,e.currency)}`;c.textContent=yt?[jt,yt].filter(Boolean).join(" \xB7 "):ze,i.textContent=s?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",i.disabled=t,a.textContent=s?"\u53D6\u6D88":"Cancel",n.style.cssText=D.panel,c.style.cssText=D.summary,h.style.cssText=D.actions,i.style.cssText=D.primary,a.style.cssText=D.secondary,et(i),i.onclick=()=>{U(we)};let wt=async()=>{let d=await r.cancel();y||(n.remove(),Z=null,await N(d))};a.onclick=()=>{u=wt,U(wt)};let F=f.createElement("div");if(F.style.cssText=D.terms,w){for(let b of _){if(ee===null&&b===ht)continue;let T=f.createElement("p"),Y=fe(b.amountMinor,e.currency)+Ce(b.interval,B,b.intervalCount);T.textContent=ee!==null&&ie!==void 0?z(Y,ie):Y,F.append(T)}let d=w.subscriptionTerms?.trial;if(d){let b=f.createElement("p");b.textContent=s?`\u8BD5\u7528 ${d.days} \u5929\uFF1B${d.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${d.days}; ${d.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}for(let b of[...w.expectedEffects.map(T=>T.description),...w.requiredConsents.map(T=>T.summary)]){let T=f.createElement("p");T.textContent=b,F.append(T)}}else{for(let d of e.lines){if(ee!==null||d!==ht){let b=f.createElement("p"),T=`${fe(d.catalogAmountMinor,e.currency)}${Ce(d.interval,B,d.intervalCount??1)}`;b.textContent=ee!==null&&d.trial?(e.lines.length>1?`${d.productName} \xB7 `:"")+z(T,d.trial.days):`${d.productName} \xB7 ${T}`,F.append(b)}for(let b of d.prepaid??[]){let T=f.createElement("p"),Y=r.view?.capabilities.plans[d.productVersionId]?.prepaid?.find(Qt=>Qt.internalFeatureId===b.internal_feature_id);T.textContent=`${Y?.name??b.internal_feature_id} \xB7 ${b.quantity} ${s?"\u4EFD":"packs"} \xD7 ${b.terms.units}`,Y&&(T.textContent+=Ce(Y.reset==="week"||Y.reset==="month"||Y.reset==="year"?Y.reset:"one_time",B,Y.resetCount)),F.append(T)}if(d.trial){let b=f.createElement("p");b.textContent=s?`\u8BD5\u7528 ${d.trial.days} \u5929\uFF1B${d.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${d.trial.days}; ${d.trial.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}}if(!e.charge){let d=f.createElement("p");d.textContent=s?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",F.append(d)}}for(let d of F.children)d.style.margin="0";h.append(i,a),n.append(c,...F.childElementCount?[F]:[],h),G.prepend(n),E?.responsive||n.scrollIntoView?.({block:"nearest"}),i.focus({preventScroll:!0}),Z=n,u=null}async function ge(){if(!C)return;if(u=ge,!ue){let n=r.view,i=n?.document.buttons[C.actionId],a=n&&i?.type==="checkout"?ce(i.product,C.selection,n.capabilities):null;if(!n||!a)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let h=$?.offerId;if($&&!h){if(!o.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:c}=await o.claimCoupon($.id,C.requestId);if(y)return;if(!c||c.couponId!==$.id||c.status!=="issued"||!(Date.parse(c.expiresAt)>Date.now()))throw C=null,$=void 0,u=async()=>{ke(await r.refresh()),u=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");h=c.id}if(!$&&!n.document.screen.actions.some(c=>c.id===C?.actionId&&typeof c.properties.couponBinding=="string")&&(h=await o.resolveOfferId?.({actionId:C.actionId,productVersionId:a,featureQuantities:ve(n.document.screen,a,C.selection,n.capabilities)})),y)return;h!==void 0&&(C.offerId=h),ue=!0}if(!A()){g.hidden=!1;return}let e;try{e=await r.preview(C)}catch(n){throw r.canReselect===!0&&(C=null,ue=!1,$=void 0,u=null),n}if($&&(e.discount?.couponId!==$.id||e.discount.offerId!==C.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(y)return;let t=e.merchantTerms;if(o.confirmOnHostedCheckout&&A()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=he?"":s?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";l.textContent=n;try{await we()}catch(i){y||re(i)}finally{l.textContent===n&&(l.textContent="")}return}mt(e)}function de(e="destroy"){if(y)return;y=!0;let t=qe;qe=void 0,M(t),o.signal?.removeEventListener("abort",J),r.signal?.removeEventListener("abort",J),x.finish("dismissed"),ot?.(),te.abort(),it?.disconnect(),E?.destroy(),V?.destroy(),r.destroy(),I.open&&I.close(),I.remove(),S.remove(),P(),e==="dismiss"&&M(o.onDismiss)}L=de;async function Oe(){if(!ae||y||Ee||X==="closing"||!X&&!A())return;if(!R){de("dismiss");return}let e=f.createElement("p");e.setAttribute("role","status"),e.textContent=s?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",ne||(ne=f.createElement("div"),ne.style.cssText=G.style.cssText,G.replaceWith(ne),le.inert=!0),k.hidden=!1,ne.replaceChildren(e,k),X="closing",k.setAttribute("aria-disabled","true"),k.focus({preventScroll:!0});try{await R.dismiss()}catch(t){y||M(o.onError,t)}y||(X="retry",e.textContent=s?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",k.textContent=s?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",k.removeAttribute("aria-label"),k.removeAttribute("aria-disabled"))}k.onclick=()=>{Oe()},I.addEventListener("cancel",e=>{e.preventDefault(),Oe()}),g.onclick=()=>{u&&U(u)};function Ge(e){x.finish("error",e),de()}function We(){if(!(!ct||ae||y||Ee||E&&!A()))try{let e=t=>{o.focusAtReveal&&(P=Ze(f)),V?.setHidden?.(!1),Ve?.(),E&&(I.showModal(),E.responsive&&I.focus({preventScroll:!0}),!t&&o.loading!=="host"&&xt(I,E.type,E.responsive)),ae=!0};R?R.present(()=>x.present(()=>e(!0))):x.present(e)}catch(e){Ge(e),re(e)}}try{if(Pe.type==="inline"?(Ne(),Ve=St(S,O),O.append(S)):(I.setAttribute("aria-label",m.document.name),k.textContent="\xD7",k.setAttribute("aria-label",s?"\u5173\u95ED":"Close"),It(k,m.document.screen.theme),k.hidden=kt(m.document),I.append(k,S),O.append(I),E=Et(I,{...m.document.screen,presentation:Pe},Me),E.latch(),E.responsive&&(S.style.display="flex",S.style.flexDirection="column",S.style.maxHeight="100%",le.style.overflow="clip",le.style.minHeight="0"),Ve=Rt(I)),Le&&q){let n=Le(q);if(typeof n=="function"&&(y?M(n):qe=n),y)throw new DOMException("Presentation cancelled","AbortError");Ne()}V=Q(le,{mode:"live",rendererUrl:r.webViewUrl,title:m.document.name,closeActions:qt,onAuthoredClose(n){X||y||(k.hidden=n)},hostPresentation:()=>E?.type??Pe.type,reportContentHeight:E?.responsive,onResize:n=>{if(!E?.responsive)return;let i=Math.min(n,Ue);le.style.height=`${i}px`,E.setContentHeight(i+(ne??G).getBoundingClientRect().height)},onSelection(n){me=n,ye()},onAction(n,i={},a,h){if(!ae||y||X)return;let c=r.view,w=c?.document.buttons[n];if(!w)return;if(w.type==="close"&&R&&o.resumeCheckout&&r.operation&&Ct(H(r.operation))){Oe();return}if(oe)return;if(!A()){je();return}if(w.type==="close"){U(async()=>{await o.onAction?.(n),de(o.onAction?"action":"dismiss")});return}if(w.type==="action"){u=async()=>{if(w.action.type==="event"){if(!o.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await o.onEvent(w.action.event)}else o.onOpenUrl?await o.onOpenUrl(w.action.url):f.defaultView?.location.assign(w.action.url);await o.onAction?.(n),u=null},U(u);return}if(o.allowNewPurchase===!1){se()&&c&&r.quote&&r.operation&&H(r.operation).type==="checkout"&&Ae(r.quote,c,n,w.product,i,h)?U(Be,n):l.textContent=s?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(Z&&r.canReselect===!1){l.textContent=s?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",E?.responsive||Z.scrollIntoView?.({block:"nearest"}),Z.querySelector("button")?.focus({preventScroll:!0});return}if(se()&&W){W.selection.actionId===n&&U(()=>dt(!0),n);return}if(se()&&o.terminateCheckout&&c&&r.quote&&r.operation&&r.canReselect===!1&&H(r.operation).type==="checkout"){if(Ae(r.quote,c,n,w.product,i,h)){U(Be,n);return}let _=ce(w.product,i,c.capabilities);try{if(!_)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ve(c.document.screen,_,i,c.capabilities)}catch(ze){re(ze);return}let ie=r.operation.operationId,ee={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(i)},z=Fe(c,n,_,i,h);U(()=>$t(ie,ee,z),n);return}if((r.quote||C)&&r.canReselect===!1){let _=!!c&&!!r.quote&&Ae(r.quote,c,n,w.product,i,h);Ie=!!r.quote&&!_,u=r.quote?()=>Qe(_):ge,U(u);return}let B=c&&ce(w.product,i,c.capabilities);if(!c||!B){re(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(o.onPurchaseIntent){u=null,U(async()=>{let _={actionId:n,productVersionId:B,selection:structuredClone(i),featureQuantities:ve(c.document.screen,B,i,c.capabilities)};$e=!0,await o.onPurchaseIntent(_)});return}if(C&&C.actionId!==n){re(new v("COMMAND_PENDING","Finish the current purchase"));return}C||($=Fe(c,n,B,i,h),C={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(i)},ue=!1),U(ge,n)},onEscape:()=>{Oe()},onError:n=>{let i=new Error(n);!ae&&!y&&Ge(i),re(i)},onRendered:n=>{n&&I.setAttribute("aria-label",n),ct=!0,We()}}),V.setHidden?.(!0),Me();let e=se()&&!!r.quote&&!!r.operation&&H(r.operation).type==="checkout";me=e?_t(m,r.quote)??{}:{},V.update(m.document.screen,rt,{capabilities:pe(m),unavailableActions:nt(m),serverInput:{bindings:[],answers:{}},...Object.keys(me).length?{selection:me}:{}}),ot=r.subscribe?.(ke),ke(r.view??m),await x.wait(V.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(u=()=>Qe(),U(u))}catch(e){throw Ge(e),e}return{check:K,host:{get observing(){return _e},get recovery(){return Vt()},async prepareFallback(){if(oe||y||X||$e)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};Te(!0);try{let e=await vt(r);return e.type==="native"&&de(),e}finally{Te(!1)}},setSuspended(e){Ee=e,S.hidden=e,e&&I.open?I.close():!e&&!ae?We():!e&&!y&&ae&&Pe.type!=="inline"&&!I.open&&I.showModal()},destroy:de,refresh:async()=>{if(!A()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return ke(e),We(),e}}}}export{Pn as showPaywall};
@@ -1 +0,0 @@
1
- import{b as a}from"./chunk-W74JLL2O.js";import"./chunk-ECKVJGXQ.js";import"./chunk-GH6FM44P.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-AB7GEGZ2.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-RE4OLOOT.js";import"./chunk-LC6UCDWE.js";import"./chunk-UV4H6VCS.js";import"./chunk-CY7OKV7E.js";import"./chunk-D3OYXTMC.js";import"./chunk-4KLXQKNO.js";import"./chunk-PW5PIBSO.js";import"./chunk-S43TYW3V.js";import"./chunk-W74JLL2O.js";import"./chunk-ECKVJGXQ.js";import"./chunk-GH6FM44P.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-3NCMYTNG.js";import"./chunk-AB7GEGZ2.js";import"./chunk-Q676H74B.js";import"./chunk-E7CCHUSO.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-DDLSQSWO.js";import"./chunk-AOGDCT4T.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
File without changes