@tinkerlandai/longplay-sdk 0.10.45 → 0.10.46

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 (88) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/check-response-5ZLFYMPK.js +1 -0
  3. package/dist/{chunk-CWD36SJO.js → chunk-4LIM2ZQR.js} +1 -1
  4. package/dist/chunk-6RNLPMMJ.js +1 -0
  5. package/dist/{chunk-LZ3OJYBY.js → chunk-7MTQQIGR.js} +1 -1
  6. package/dist/{chunk-MPD3UIY4.js → chunk-A37ZU2AP.js} +1 -1
  7. package/dist/{chunk-CGAE5OZ3.js → chunk-AAILPAL5.js} +1 -1
  8. package/dist/{chunk-YPOE4KNG.js → chunk-AKBF7TGD.js} +1 -1
  9. package/dist/{chunk-K3RXO2S3.js → chunk-ANTKNFC6.js} +1 -1
  10. package/dist/{chunk-NZ2DB72P.js → chunk-ASCVMPXG.js} +1 -1
  11. package/dist/{chunk-AV2WZSII.js → chunk-CI7UPAWD.js} +1 -1
  12. package/dist/{chunk-B4AELNLE.js → chunk-CRCAYVV5.js} +1 -1
  13. package/dist/{chunk-OTNH77B2.js → chunk-D3WC3T4U.js} +1 -1
  14. package/dist/{chunk-5JRBCW6V.js → chunk-DTOYPMAW.js} +1 -1
  15. package/dist/{chunk-ZKGVOJCV.js → chunk-EIVFBGI5.js} +1 -1
  16. package/dist/{chunk-AQONMY2H.js → chunk-EQKTKITL.js} +1 -1
  17. package/dist/{chunk-7MYS52FL.js → chunk-GFSAWDV2.js} +1 -1
  18. package/dist/{chunk-MWICFZUF.js → chunk-GJLCTQJN.js} +1 -1
  19. package/dist/{chunk-7HU7JZVZ.js → chunk-HIUSHWDK.js} +1 -1
  20. package/dist/{chunk-CSLTAXC7.js → chunk-HMPIUYZ2.js} +1 -1
  21. package/dist/{chunk-5TJISOWN.js → chunk-JDUB4T4P.js} +1 -1
  22. package/dist/{chunk-ASL7TJFU.js → chunk-JZ73DRHT.js} +1 -1
  23. package/dist/{chunk-3SXPCVIP.js → chunk-KAMYLHAT.js} +1 -1
  24. package/dist/{chunk-MEDW4N3F.js → chunk-L42A5KVA.js} +1 -1
  25. package/dist/{chunk-DCZWNTG2.js → chunk-L7OMFH4O.js} +1 -1
  26. package/dist/{chunk-HLCDAU5A.js → chunk-MBWUIYCH.js} +1 -1
  27. package/dist/{chunk-TL67SYPH.js → chunk-MFAEHTOH.js} +1 -1
  28. package/dist/{chunk-CEYUJ3LO.js → chunk-MMJBC6PW.js} +1 -1
  29. package/dist/{chunk-LNEBSVA7.js → chunk-N3C57R2I.js} +1 -1
  30. package/dist/chunk-N3TAZ7HB.js +1 -0
  31. package/dist/{chunk-GWTNU665.js → chunk-PE5Y524X.js} +1 -1
  32. package/dist/{chunk-IT5DIE6G.js → chunk-POOXIM6Q.js} +1 -1
  33. package/dist/{chunk-NVF54BDR.js → chunk-PPOPJTHA.js} +1 -1
  34. package/dist/{chunk-RJY5CUTB.js → chunk-R2OJIXYE.js} +1 -1
  35. package/dist/{chunk-CPBHDAL4.js → chunk-SIJY35EE.js} +1 -1
  36. package/dist/{chunk-FTGRTYBL.js → chunk-SWULFBRF.js} +1 -1
  37. package/dist/{chunk-GGFCD3PT.js → chunk-TWQB35B7.js} +1 -1
  38. package/dist/{chunk-PBZSOTKZ.js → chunk-UBUFXGS7.js} +1 -1
  39. package/dist/{chunk-UJMP7AMY.js → chunk-UHT5DGAJ.js} +1 -1
  40. package/dist/{chunk-LSVTH3TS.js → chunk-UIKMEVXM.js} +1 -1
  41. package/dist/{chunk-DGZCD3AY.js → chunk-W55G3VGB.js} +1 -1
  42. package/dist/{chunk-KP4QI4RX.js → chunk-WQN2D5FZ.js} +1 -1
  43. package/dist/{chunk-CALDEF4M.js → chunk-X2ON6QRA.js} +1 -1
  44. package/dist/{chunk-6XRXHFM6.js → chunk-XB24ATBA.js} +1 -1
  45. package/dist/{chunk-V65FSNYO.js → chunk-XQN7MLP5.js} +1 -1
  46. package/dist/{chunk-C4NG6RVA.js → chunk-XWD4N2QI.js} +1 -1
  47. package/dist/{chunk-VBJTINET.js → chunk-YHC5WAVP.js} +1 -1
  48. package/dist/{chunk-5GFH7YB3.js → chunk-YPN2ZL2V.js} +1 -1
  49. package/dist/{chunk-TJMC7WPQ.js → chunk-ZNTV6TU7.js} +1 -1
  50. package/dist/{chunk-RDUKCMST.js → chunk-ZQAAZ7Q4.js} +1 -1
  51. package/dist/{content-CS452JHX.js → content-4Y57QHWP.js} +1 -1
  52. package/dist/funnel-host-purchase-UWTK3C7Q.js +1 -0
  53. package/dist/funnel-paywall-prerender-MQWJONN5.js +1 -0
  54. package/dist/funnel-route-prediction-O7XGFYHS.js +1 -0
  55. package/dist/funnel-route-source-MYKZJIXG.js +1 -0
  56. package/dist/funnel-runtime-host-66OPNY4C.js +1 -0
  57. package/dist/index.js +1 -1
  58. package/dist/merchant-bridge-contracts-Z5PJ2P6H.js +1 -0
  59. package/dist/native-shell.js +1 -1
  60. package/dist/openrouter.js +1 -1
  61. package/dist/operation-contracts-OSBKHIVO.js +1 -0
  62. package/dist/page.js +1 -1
  63. package/dist/{paywall-IAKGXJTB.js → paywall-QMYTDELU.js} +1 -1
  64. package/dist/paywall-content-LLRPWEZD.js +1 -0
  65. package/dist/paywall-session-P6NIFMKG.js +1 -0
  66. package/dist/popup.js +1 -1
  67. package/dist/react-native.js +1 -1
  68. package/dist/screen-renderer-AQXCFML3.js +1 -0
  69. package/dist/server.js +1 -1
  70. package/dist/{visual-dom-IN6DRNX3.js → visual-dom-KUABNJV6.js} +1 -1
  71. package/dist/visual.js +1 -1
  72. package/package.json +1 -1
  73. package/dist/check-response-OIBVUP72.js +0 -1
  74. package/dist/chunk-YBANRBZX.js +0 -1
  75. package/dist/chunk-YHZXVCE3.js +0 -1
  76. package/dist/funnel-host-purchase-3CX75LNN.js +0 -1
  77. package/dist/funnel-paywall-prerender-PZX3C5UF.js +0 -1
  78. package/dist/funnel-route-prediction-XGCMCIKA.js +0 -1
  79. package/dist/funnel-route-source-O76QSUYU.js +0 -1
  80. package/dist/funnel-runtime-host-CYPEWOWS.js +0 -1
  81. package/dist/merchant-bridge-contracts-FB63H7NE.js +0 -1
  82. package/dist/operation-contracts-YSFIINLK.js +0 -1
  83. package/dist/paywall-content-5UVXGL3Q.js +0 -1
  84. package/dist/paywall-session-NAEV7VRT.js +0 -1
  85. package/dist/screen-renderer-E4TZF74V.js +0 -1
  86. /package/dist/{chunk-GPJF3T43.js → chunk-6RGARS6I.js} +0 -0
  87. /package/dist/{chunk-WPFTSHP2.js → chunk-FRK6322O.js} +0 -0
  88. /package/dist/{chunk-RA7GZ67U.js → chunk-KV5MZ4NI.js} +0 -0
@@ -1 +1 @@
1
- import"./chunk-UJMP7AMY.js";import"./chunk-FTGRTYBL.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import{a as i}from"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-5GFH7YB3.js";import{b as A}from"./chunk-GPJF3T43.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-UHT5DGAJ.js";import"./chunk-SWULFBRF.js";import"./chunk-D3WC3T4U.js";import"./chunk-UIKMEVXM.js";import{a as i}from"./chunk-MFAEHTOH.js";import"./chunk-XB24ATBA.js";import"./chunk-YPN2ZL2V.js";import{b as A}from"./chunk-6RGARS6I.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-L42A5KVA.js";import"./chunk-7MTQQIGR.js";import"./chunk-CI7UPAWD.js";import"./chunk-UBUFXGS7.js";import"./chunk-MBWUIYCH.js";import"./chunk-L7OMFH4O.js";import"./chunk-JZ73DRHT.js";import"./chunk-ZQAAZ7Q4.js";import"./chunk-WQN2D5FZ.js";import"./chunk-JDUB4T4P.js";import"./chunk-VILB5M4X.js";import"./chunk-SWULFBRF.js";import"./chunk-UIKMEVXM.js";import"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import"./chunk-4LIM2ZQR.js";import"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import"./chunk-XB24ATBA.js";import"./chunk-6RGARS6I.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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-CPBHDAL4.js";import"./chunk-CGAE5OZ3.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.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-SIJY35EE.js";import"./chunk-AAILPAL5.js";import"./chunk-3VUPVXAV.js";import"./chunk-YPN2ZL2V.js";import"./chunk-DSPLGTQI.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -1 +1 @@
1
- import{a as Qt,c as jt,d as pt,f as mt,g as Bt,k as Ft}from"./chunk-LNEBSVA7.js";import{b as dt}from"./chunk-W32FI2A2.js";import{d as _t,e as Mt,f as Ut,h as ft,i as qe,j as $t,k as Vt,l as Ht}from"./chunk-7HU7JZVZ.js";import{a as Tt,c as lt,d as St,e as Dt}from"./chunk-B4AELNLE.js";import{a as Fe,b as he,d as ut,f as Nt,j as Lt}from"./chunk-AQONMY2H.js";import{b as de}from"./chunk-RDUKCMST.js";import{B as A,C as Be,D as Re,E as Oe,y as Ot}from"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import{r as be,t as me}from"./chunk-7MYS52FL.js";import{i as Rt}from"./chunk-MWICFZUF.js";import{c as ue,j as Ae}from"./chunk-CWD36SJO.js";import{c as ct}from"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import{a as P}from"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-5GFH7YB3.js";import"./chunk-GPJF3T43.js";import{a as G}from"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";async function qt(_,a,E){if(!Re(a))throw new P("INVALID_RESPONSE","A verified completed purchase is required");let k=_?Ae.parse(_):null;if(await E.onComplete?.(a),!k||!E.check)return;let U=Ae.parse(await E.check());if(U.internal_feature_id!==k.internal_feature_id||U.quantity!==k.quantity||k.observation!==void 0&&(U.observation===void 0||U.observation.requirementDigest!==k.observation.requirementDigest||U.observation.authority!==k.observation.authority||ct(U.observation.subject)!==ct(k.observation.subject)))throw new P("INVALID_RESPONSE","The access requirement changed");U.allowed&&await E.onAccessGranted?.(U)}function ht(_){return Object.entries(_.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!de(a.product,{},_.capabilities)).map(([a])=>a)}function Gt(_,a){let E=A(a)?void 0:a.lines[0];if(!A(a)&&(a.lines.length!==1||!E))return;let k=A(a)?a.productVersionId:E.productVersionId,{screen:U,buttons:X}=_.document,R=new Map(A(a)?Object.entries(a.featureQuantities??{}):(E?.prepaid??[]).map(h=>[h.internal_feature_id,h.quantity]));function Z(h,m){if(h.hidden)return!1;if(h.type==="plan_picker"&&_.capabilities.pickers[h.id]?.options.includes(k))return m[h.id]=k,!0;if(h.type==="quantity_picker"){let Y=R.get(h.internalFeatureId);return Y!==void 0&&(!h.bind?.plan||h.bind.plan===k)&&(m[h.id]=Y),!1}if(h.type==="button"&&h.action){let Y=X[h.action];return Y?.type==="checkout"&&Y.product.type==="fixed"&&Y.product.productVersionId===k}if(h.type!=="stack")return!1;let z=h.interaction,i=h.bind?.plan===k;for(let[Y,d]of h.children.entries()){let re={},N=Z(d,re);if(z?.type==="toggle"||z?.type==="tabs"){if(!N)continue;return m[h.id]=z.type==="toggle"?Y===0:d.id,Object.assign(m,re),!0}Object.assign(m,re),N&&(i=!0,z?.type==="select"&&z.purpose==="product"&&z.pickerId&&d.type==="stack"&&d.bind?.plan===k&&(m[h.id]=d.id,m[z.pickerId]=k))}return i}for(let h of U.pages){let m={__page:h.id};if(Z(h.root,m))return m}}async function _n(_,a,E){let k=a.focusAtReveal?()=>{}:ft(_.ownerDocument),U=()=>{R.finish("dismissed"),k()},X=()=>U(),R=$t(_,a,"paywall",()=>{U(),G(a.onDismiss)},Qt);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",X,{once:!0});let Z=null,h,m,z;try{if(R.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),R.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(Z=a.check?Ae.parse(await R.wait(a.check(),qe)):null,Z?.allowed)return R.finish("skipped"),a.signal?.removeEventListener("abort",X),k(),await a.onAccessGranted?.(Z),{check:Z,host:null};let[e,t]=await Promise.allSettled([R.wait(import("./screen-renderer-E4TZF74V.js")),R.wait(a.start().then(r=>(R.cancelled&&r.destroy(),r)),qe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;z=e.value,h=t.value,a.signal?.throwIfAborted(),h.signal?.throwIfAborted(),h.signal?.addEventListener("abort",X,{once:!0});let n=h.view??await R.wait(h.refresh(),qe);if(!n)throw new P("INVALID_RESPONSE","Paywall presentation is missing");h.signal?.throwIfAborted(),m=n}catch(e){throw R.finish("error",e),a.signal?.removeEventListener("abort",X),h?.signal?.removeEventListener("abort",X),h?.destroy(),k(),e}let i=h,{mountScreenPreview:Y}=z,d=_.ownerDocument,re=new AbortController,N=d.createElement("section"),ie=d.createElement("div"),J=d.createElement("div"),Ge=a.mountControls,W=Ge?d.createElement("div"):void 0,f=d.createElement("p"),C=d.createElement("button"),x=d.createElement("button"),O=d.createElement("dialog"),We=i.locale||m.document.screen.strings.defaultLocale,o=We.toLowerCase().startsWith("zh"),Wt=o?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",zt=o?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",M=jt(m.document.screen.theme);N.dataset.indianaPaywall="",N.setAttribute("aria-label",m.document.name),N.style.cssText=M.root,J.style.cssText=M.controls,f.style.cssText=M.message,f.setAttribute("role","status"),x.style.cssText=M.link,x.textContent=o?"\u5173\u95ED":"Close",C.style.cssText=M.secondary,C.textContent=o?"\u91CD\u8BD5":"Retry",C.hidden=!0,J.append(f,C,x),W&&(W.style.cssText="flex:1 0 100%;min-width:0",W.hidden=!0,J.prepend(W)),N.append(ie,J);let ze=()=>{if(W){let r=!W.childElementCount&&!W.textContent?.trim();W.hidden!==r&&(W.hidden=r)}let e=oe??J,t=[...e.children].every(r=>r===f?!f.textContent:r.hidden),n=[...e.children].some(r=>r===x?!1:r===f?!!f.textContent:!r.hidden);e.style.cssText=t?M.controls.replace(/padding:[^;]+/,"padding:0"):n?`${M.controls};${M.pinned}`:M.controls,Xe()},yt=typeof MutationObserver>"u"?void 0:new MutationObserver(ze);yt?.observe(N,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Te=m.document.presentation,Yt=Object.entries(m.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),B,wt,Ye=!1,gt=JSON.stringify(m.capabilities),Je=e=>ae&&!Ce?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):ht(e);function Se(e){if(w)return;m=e;let t=JSON.stringify(e.capabilities);if(t!==gt){let n=!b&&!i.quote&&!i.operation?Fe(e,q,Ct):q;JSON.stringify(n)!==JSON.stringify(q)?(q=n,B?.update(e.document.screen,We,{capabilities:he(e),unavailableActions:Je(e),serverInput:{bindings:[],answers:{}},selection:q})):B?.updateCapabilities(he(e),Je(e)),gt=t}Xt(e),ve()}let I,Ke=0;function Xe(){let e=d.defaultView;if(!I?.responsive||!e)return;let t=oe??J,n=e.innerHeight-(I.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ke=Math.max(1,n-t.getBoundingClientRect().height),B?.resizeViewport?.(Ke,e.innerWidth)}let w=!1,ae=!1,b=null,Ze,De=!1,bt=!1,fe=!1,et,tt=!1,ee,oe;function Jt(){return ae||w||ee||tt?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:lt(i)}let T=()=>!w&&!De&&!ee&&a.canInteract?.()!==!1,F,ye=!1,we=!1,p=null,te=null,nt="",pe=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),q={},Ct=new Set,Ce,K=null;function ve(){if(!pe()||!B?.updateCheckoutControls)return;let e=i.quote,t=!K&&!!e&&!!i.operation&&S(i.operation).type==="checkout",n=Object.entries(m.document.buttons).flatMap(([r,c])=>c.type==="checkout"?[{actionId:r,policy:c}]:[]);B.updateCheckoutControls({actions:n.map(({actionId:r})=>r),resume:t?n.filter(({actionId:r,policy:c})=>Me(e,m,r,c.product,q)).map(({actionId:r})=>r):[],resumeLabel:o?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:Ce})}function vt(){te?.remove(),te=null}async function rt(){if(K)return;if(a.resumeCheckout&&i.operation){await a.resumeCheckout(i.operation.operationId);return}let e=await i.read();if(S(e).type!=="checkout")return $(e,!1);T()&&(Le.delete(e.operationId),await Ue(e))}function Pt(){f.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",C.hidden=!0}async function kt(e=!1){let t=K;if(!t)return;C.hidden=!0;let n=Date.now()+2e4;for(;T();){let r=await i.read();if(r.operationId!==t.operationId)throw new P("PURCHASE_PENDING","The original Checkout changed");if(!T())break;let c=S(r);if(c.type==="native"){K=null,vt(),b=t.selection,F=t.coupon,ye=!1,we=!1,await xe();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){K=null,await $(r,!1);return}if(e&&c.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(g){G(a.onError,g)}}if(Date.now()>=n)break;await dt(1e3,d,re.signal)}w||Pt()}async function Kt(e,t,n){K={operationId:e,selection:t,coupon:n};let r=!1;try{await a.terminateCheckout(e)}catch(c){if(c instanceof P&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){K=null,f.textContent=o?"\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.",G(a.onError,c);return}r=c instanceof P&&(c.status??0)>=500,G(a.onError,c)}T()&&await kt(r)}function Ne(e,t,n,r,c){let g=he(e).checkoutCoupons?.[t],l=g?g.products[n]:a.claimCoupon&&c?Rt(e.capabilities,c,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Xt(e){ae||b||i.quote||i.operation||nt&&f.textContent===nt||(f.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let Le=new Map,_e=!1;function Me(e,t,n,r,c,g){if(A(e)){let H=de(r,c,t.capabilities),le=H&&Ne(t,n,H,c,g),Ie=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0),Ve=me(t.document.screen,e.productVersionId,c,t.capabilities);return H===e.productVersionId&&Object.keys(Ve).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(Ve).every(([He,Qe])=>e.featureQuantities?.[He]===Qe)&&(!le||Ie?.couponId===le.id&&(!le.offerId||Ie.grantId===le.offerId))}let l=e.lines.length===1?e.lines[0]:void 0,s=de(r,c,t.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let L=Ne(t,n,s,c,g);if((L||he(t).checkoutCoupons?.[n])&&(L?.id??null)!==(e.discount?.couponId??null))return!1;let V;try{V=me(t.document.screen,s,c,t.capabilities)}catch{return!1}let ce=Object.fromEntries((l.prepaid??[]).map(H=>[H.internal_feature_id,H.quantity]));return[...new Set([...Object.keys(V),...Object.keys(ce)])].every(H=>(V[H]??0)===(ce[H]??0))}let S=e=>Tt({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Ue(e){let t=e.merchantExecution,n=S(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!T()||!r||Be(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||Le.get(e.operationId)===r)){Le.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):d.defaultView?.location.assign(r)}catch(c){throw Le.delete(e.operationId),c}}}let se=(e,t=!1)=>{if(e instanceof ut)p=null,f.textContent=e.customerMessage(o);else if(Bt(e))p=null,f.textContent=t?o?"\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.":mt(e,o);else if(t){let n=e instanceof P?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(p=null,f.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):i.canReselect===!0&&!b?f.textContent=o?"\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"?f.textContent=o?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":f.textContent=o?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else f.textContent=e instanceof P&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?mt(e,o):e instanceof P?e.message:o?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";C.hidden=p===null,nt=f.textContent,t&&!I?.responsive&&f.scrollIntoView?.({block:"nearest"}),G(t&&E?.quoteError?E.quoteError:a.onError,e)},Pe=new WeakMap;function ke(e){ae=e,C.disabled=e,B?.updateCapabilities?.(he(m),Je(m));for(let t of te?.querySelectorAll("button")??[])e?(Pe.has(t)||Pe.set(t,t.disabled),t.disabled=!0):Pe.has(t)&&(t.disabled=Pe.get(t),Pe.delete(t)),pt(t)}function it(){f.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function Zt(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof ut?(b=null,ye=!1,we=!1,p=null):p=e,t}}async function j(e,t){if(ae||w)return;if(!T()){it();return}let n=e===xe,r=n?zt:Wt,c=pe()&&t!==void 0;Ce=c?t:void 0,ke(!0),ve(),C.hidden=!0,f.textContent=c?"":r;try{if(e!==It&&(e!==rt||!a.resumeCheckout)&&await Zt(e),w)return;if(!T()){p=e,C.hidden=!1,it();return}await e()}catch(g){w||se(g,n&&!c)}finally{Ce=void 0,ke(!1),ve(),f.textContent===r&&(f.textContent="")}}async function en(e){await qt(Z,e,a)}function Et(e){return lt(i).type==="recording"||S(e).type==="recording"}function xt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:A(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!A(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],g=r===null?ue(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ue(r,e.currency)+(c?be(c.interval,o?"zh-CN":"en",c.intervalCount??1):""),l=A(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} \xB7 ${g}`:g,recurring:c}}async function $(e,t=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!T()){p=async()=>$(await i.read()),C.hidden=!1;return}if(f.textContent=Ft(e.status,o),Et(e)){let s=e.merchantExecution?.recordingStatus==="failed";f.textContent=s?o?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",C.textContent=o?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",p=async()=>$(await i.read()),C.hidden=!1;return}if(e.problem&&S(e).type!=="native"){let s=e.problem;p=Ee,C.textContent=o?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",se(new P(s.code,s.reason==="RESULT_UNKNOWN"?o?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?o?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?o?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?o?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(f.textContent=o?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),Re(e)&&S(e).type==="complete"){p=null,await en(e);return}if(!Oe(e)&&S(e).type!=="fulfillment"){if(i.canReselect===!1){f.textContent=o?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",C.textContent=o?"\u67E5\u8BE2\u7ED3\u679C":"Check result",p=async()=>$(await i.read()),C.hidden=!1;return}e.status==="cancelled"?f.textContent=o?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(f.textContent=o?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),C.textContent=o?"\u91CD\u8BD5":"Retry",p=null,b=null;return}if(!t&&S(e).type==="checkout"){if(K){Pt();return}if(pe()){f.textContent="",_e=!1,p=null,ve();return}let s=i.quote,L=s?.operationId===e.operationId?xt(s).label:"";f.textContent=_e?L?o?`${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.`:o?"\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.":"",_e=!1,p=null;return}await Ue(e);let n=Date.now(),r=n+6e5,c=2e3,g=S(e).type!=="checkout",l=()=>g&&Date.now()-n<15e3;Ye=!0,G(a.onObservationChange,!0);try{for(;!w&&Date.now()<r;){if(await dt(l()?700:c,d,re.signal),w)return;if(!T()){p=async()=>$(await i.read()),C.hidden=!1;return}let s=await i.read();if(S(s).type==="checkout"&&(g=!1),!t&&S(s).type==="checkout"){await $(s,!1);return}if(!s.problem&&Oe(s)&&await Ue(s),!Oe(s)||s.problem||Et(s)){await $(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{Ye=!1,G(a.onObservationChange,!1)}p=async()=>$(await i.read()),C.hidden=!1}async function at(e=!1){let t=await i.read();if(w)return;if(!T()){p=()=>at(e),C.hidden=!1;return}let n=i.quote;if(n&&Nt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(Be(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(Be(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){At(n);return}await $(t,e||void 0)}async function It(){await at()}async function Ee(){vt(),p=Ee;let e=await i.confirm();if(!T()){p=Ee,C.hidden=!1;return}if(e.problem){await $(e);return}if(Oe(e)){if(S(e).type==="checkout")await Ue(e);else if(e.execution&&e.execution.provider!=="merchant"||"nativePurchase"in e&&e.nativePurchase){if(!a.onPurchase)throw new P("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:e,signal:re.signal})}}p=async()=>$(await i.read()),await $(e,!0)}function At(e){te?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());f.textContent=t?o?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),r=d.createElement("button"),c=d.createElement("button"),g=d.createElement("div"),l=d.createElement("p"),s=e.merchantTerms,L=o?"zh-CN":"en",V=s?.subscriptionTerms?.items??[],ce=s?s.subscriptionTerms?.trial?.days:A(e)?void 0:e.lines.find(u=>u.trial)?.trial?.days,ne=A(e)?s?s.totalMinor:e.totalMinor:ce===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(u=>u.trial)?0:null,H=(u,y)=>o?`${y} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${u}`:`Then ${u} after the ${y}-day trial`,{label:le,recurring:Ie}=xt(e),Ve=A(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(u=>u.productName).join(", "),He=ne===null?"":`${o?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ue(ne,e.currency)}`;l.textContent=He?[Ve,He].filter(Boolean).join(" \xB7 "):le,r.textContent=A(e)?o?"\u786E\u8BA4\u53D8\u66F4":"Confirm change":o?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",r.disabled=t,c.textContent=o?"\u53D6\u6D88":"Cancel",n.style.cssText=M.panel,l.style.cssText=M.summary,g.style.cssText=M.actions,r.style.cssText=M.primary,c.style.cssText=M.secondary,pt(r),r.onclick=()=>{j(Ee)};let Qe=async()=>{let u=await i.cancel();w||(n.remove(),te=null,await $(u))};c.onclick=()=>{p=Qe,j(Qe)};let Q=d.createElement("div");if(Q.style.cssText=M.terms,A(e)){for(let[y,v]of Object.entries(e.featureQuantities??{})){let D=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(tn=>tn.internalFeatureId===y),je=d.createElement("p");je.textContent=`${D?.name??y} \xB7 ${v} ${o?"\u4EFD":"packs"}${D?` \xD7 ${D.terms.units}`:""}`,Q.append(je)}for(let[y,v]of[[o?"\u539F\u8BA2\u9605\u62B5\u6263":"Unused subscription credit",e.creditMinor],[o?"\u65B0\u5957\u9910\u8D39\u7528":"New plan charge",e.debitMinor],[o?"\u4F18\u60E0\u51CF\u514D":"Offer savings",s?.discountMinor??e.discountMinor],[o?"\u7A0E\u8D39":"Tax",s?s.taxMinor:e.taxMinor]]){let D=d.createElement("p");D.textContent=`${y}: ${v===null?o?"\u7ED3\u8D26\u65F6\u786E\u8BA4":"Confirmed at checkout":ue(v,e.currency)}`,Q.append(D)}let u=d.createElement("p");u.textContent=`${o?"\u751F\u6548\u65F6\u95F4":"Effective"}: ${e.effectiveAt}`,Q.append(u)}if(s){for(let y of V){if(ne===null&&y===Ie)continue;let v=d.createElement("p"),D=ue(y.amountMinor,e.currency)+be(y.interval,L,y.intervalCount);v.textContent=ne!==null&&ce!==void 0?H(D,ce):D,y.amountAfterOfferMinor!==void 0&&(v.textContent+=` \xB7 ${o?"\u4F18\u60E0\u7ED3\u675F\u540E":"After the offer"} ${ue(y.amountAfterOfferMinor,e.currency)}${be(y.interval,L,y.intervalCount)}`),Q.append(v)}let u=s.subscriptionTerms?.trial;if(u){let y=d.createElement("p");y.textContent=o?`\u8BD5\u7528 ${u.days} \u5929\uFF1B${u.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${u.days}; ${u.cardRequired?"a payment method is required":"no payment method is required"}`,Q.append(y)}for(let y of[...s.expectedEffects.map(v=>v.description),...s.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=y,Q.append(v)}}else if(!A(e)){for(let u of e.lines){if(ne!==null||u!==Ie){let y=d.createElement("p"),v=`${ue(u.catalogAmountMinor,e.currency)}${be(u.interval,L,u.intervalCount??1)}`;y.textContent=ne!==null&&u.trial?(e.lines.length>1?`${u.productName} \xB7 `:"")+H(v,u.trial.days):`${u.productName} \xB7 ${v}`,Q.append(y)}for(let y of u.prepaid??[]){let v=d.createElement("p"),D=i.view?.capabilities.plans[u.productVersionId]?.prepaid?.find(je=>je.internalFeatureId===y.internal_feature_id);v.textContent=`${D?.name??y.internal_feature_id} \xB7 ${y.quantity} ${o?"\u4EFD":"packs"} \xD7 ${y.terms.units}`,D&&(v.textContent+=be(D.reset==="week"||D.reset==="month"||D.reset==="year"?D.reset:"one_time",L,D.resetCount)),Q.append(v)}if(u.trial){let y=d.createElement("p");y.textContent=o?`\u8BD5\u7528 ${u.trial.days} \u5929\uFF1B${u.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${u.trial.days}; ${u.trial.cardRequired?"a payment method is required":"no payment method is required"}`,Q.append(y)}}if(!e.charge){let u=d.createElement("p");u.textContent=o?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",Q.append(u)}}for(let u of Q.children)u.style.margin="0";g.append(r,c),n.append(l,...Q.childElementCount?[Q]:[],g),J.prepend(n),I?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),te=n,ae&&ke(!0),p=null}async function xe(){if(!b)return;if(p=xe,!ye){let n=i.view,r=n?.document.buttons[b.actionId],c=n&&r?.type==="checkout"?de(r.product,b.selection,n.capabilities):null;if(!n||!c)throw new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!we){let l=await a.resolveSubscriptionChange?.({actionId:b.actionId,productVersionId:c,featureQuantities:me(n.document.screen,c,b.selection,n.capabilities)});if(w)return;l!==void 0&&(b.subscriptionChange=Ot.parse(l)),we=!0}let g=F?.offerId;if(F&&!g){if(!a.claimCoupon)throw new P("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(F.id,b.requestId);if(w)return;if(!l||l.couponId!==F.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw b=null,F=void 0,p=async()=>{Se(await i.refresh()),p=null},new P("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");g=l.id}if(!F&&!n.document.screen.actions.some(l=>l.id===b?.actionId&&typeof l.properties.couponBinding=="string")&&(g=await a.resolveOfferId?.({actionId:b.actionId,productVersionId:c,featureQuantities:me(n.document.screen,c,b.selection,n.capabilities)})),w)return;g!==void 0&&(b.offerId=g),ye=!0}if(!T()){C.hidden=!1;return}let e;try{e=await i.preview(b)}catch(n){throw i.canReselect===!0&&(b=null,ye=!1,we=!1,F=void 0,p=null),n}if(F&&(A(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==F.id||n.grantId!==b.offerId})():e.discount?.couponId!==F.id||e.discount.offerId!==b.offerId))throw new P("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(a.confirmOnHostedCheckout&&T()&&!A(e)&&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=Ce?"":o?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";f.textContent=n;try{await Ee()}catch(r){w||se(r)}finally{f.textContent===n&&(f.textContent="")}return}At(e)}function ge(e="destroy"){if(w)return;w=!0;let t=Ze;Ze=void 0,G(t),a.signal?.removeEventListener("abort",X),i.signal?.removeEventListener("abort",X),R.finish("dismissed"),wt?.(),re.abort(),yt?.disconnect(),I?.destroy(),B?.destroy(),i.destroy(),O.open&&O.close(),O.remove(),N.remove(),k(),e==="dismiss"&&G(a.onDismiss)}U=ge;async function $e(){if(!fe||w||De||ee==="closing"||!ee&&!T())return;if(!E){ge("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=o?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",oe||(oe=d.createElement("div"),oe.style.cssText=J.style.cssText,J.replaceWith(oe),ie.inert=!0),x.hidden=!1,oe.replaceChildren(e,x),ee="closing",x.setAttribute("aria-disabled","true"),x.focus({preventScroll:!0});try{await E.dismiss()}catch(t){w||G(a.onError,t)}w||(ee="retry",e.textContent=o?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",x.textContent=o?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",x.removeAttribute("aria-label"),x.removeAttribute("aria-disabled"))}x.onclick=()=>{$e()},O.addEventListener("cancel",e=>{e.preventDefault(),$e()}),C.onclick=()=>{p&&j(p)};function ot(e){R.finish("error",e),ge()}function st(){if(!(!bt||fe||w||De||I&&!T()))try{let e=t=>{a.focusAtReveal&&(k=ft(d)),B?.setHidden?.(!1),et?.(),I&&(O.showModal(),I.responsive&&O.focus({preventScroll:!0}),!t&&a.loading!=="host"&&Mt(O,I.type,I.responsive)),t&&a.loading!=="host"&&typeof ie.animate=="function"&&!d.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&ie.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),fe=!0};E?E.present(()=>R.present(()=>e(!0))):R.present(e)}catch(e){ot(e),se(e)}}try{if(Te.type==="inline"?(ze(),et=Ht(N,_),_.append(N)):(O.setAttribute("aria-label",m.document.name),x.textContent="\xD7",x.setAttribute("aria-label",o?"\u5173\u95ED":"Close"),Ut(x,m.document.screen.theme),x.hidden=Lt(m.document),O.append(x,N),_.append(O),I=_t(O,{...m.document.screen,presentation:Te},Xe),I.latch(),I.responsive&&(N.style.display="flex",N.style.flexDirection="column",N.style.maxHeight="100%",ie.style.overflow="clip",ie.style.minHeight="0"),et=Vt(O)),Ge&&W){let n=Ge(W);if(typeof n=="function"&&(w?G(n):Ze=n),w)throw new DOMException("Presentation cancelled","AbortError");ze()}B=Y(ie,{mode:"live",rendererUrl:i.webViewUrl,title:m.document.name,closeActions:Yt,onAuthoredClose(n){ee||w||(x.hidden=n)},hostPresentation:()=>I?.type??Te.type,reportContentHeight:I?.responsive,onResize:n=>{if(!I?.responsive)return;let r=Math.min(n,Ke);ie.style.height=`${r}px`,I.setContentHeight(r+(oe??J).getBoundingClientRect().height)},onSelection(n){for(let[r,c]of Object.entries(n))typeof c=="number"&&typeof q[r]=="number"&&q[r]!==c&&Ct.add(r);q=n,ve()},onAction(n,r={},c,g){if(!fe||w||ee)return;let l=i.view,s=l?.document.buttons[n];if(!s)return;if(s.type==="close"&&E&&a.resumeCheckout&&i.operation&&St(S(i.operation))){$e();return}if(ae)return;if(!T()){it();return}if(s.type==="close"){j(async()=>{E?.closeAction?await E.closeAction(n):await a.onAction?.(n),ge(a.onAction?"action":"dismiss")});return}if(s.type==="action"){p=async()=>{if(s.action.type==="event"){if(!a.onEvent)throw new P("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(s.action.event)}else a.onOpenUrl?await a.onOpenUrl(s.action.url):d.defaultView?.location.assign(s.action.url);await a.onAction?.(n),p=null},j(p);return}if(a.allowNewPurchase===!1){pe()&&l&&i.quote&&i.operation&&S(i.operation).type==="checkout"&&Me(i.quote,l,n,s.product,r,g)?j(rt,n):f.textContent=o?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(te&&i.canReselect===!1){f.textContent=o?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",I?.responsive||te.scrollIntoView?.({block:"nearest"}),te.querySelector("button")?.focus({preventScroll:!0});return}if(pe()&&K){K.selection.actionId===n&&j(()=>kt(!0),n);return}if(pe()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&S(i.operation).type==="checkout"){if(Me(i.quote,l,n,s.product,r,g)){j(rt,n);return}let V=de(s.product,r,l.capabilities);try{if(!V)throw new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");me(l.document.screen,V,r,l.capabilities)}catch(le){se(le);return}let ce=i.operation.operationId,ne={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},H=Ne(l,n,V,r,g);j(()=>Kt(ce,ne,H),n);return}if((i.quote||b)&&i.canReselect===!1){let V=!!l&&!!i.quote&&Me(i.quote,l,n,s.product,r,g);_e=!!i.quote&&!V,p=i.quote?()=>at(V):xe,j(p);return}let L=l&&de(s.product,r,l.capabilities);if(!l||!L){se(new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){p=null,j(async()=>{let V={actionId:n,productVersionId:L,selection:structuredClone(r),featureQuantities:me(l.document.screen,L,r,l.capabilities)};tt=!0,await a.onPurchaseIntent(V)});return}if(b&&b.actionId!==n){se(new P("COMMAND_PENDING","Finish the current purchase"));return}b||(F=Ne(l,n,L,r,g),b={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},ye=!1,we=!1),j(xe,n)},onEscape:()=>{$e()},onError:n=>{let r=new Error(n);!fe&&!w&&ot(r),se(r)},onRendered:n=>{n&&O.setAttribute("aria-label",n),bt=!0,st()}}),B.setHidden?.(!0),Xe();let e=pe()&&!!i.quote&&!!i.operation&&S(i.operation).type==="checkout";q=i.quote?Gt(m,i.quote)??Fe(m,{}):Fe(m,{}),B.update(m.document.screen,We,{capabilities:he(m),unavailableActions:ht(m),serverInput:{bindings:[],answers:{}},...Object.keys(q).length?{selection:q}:{}}),wt=i.subscribe?.(Se),Se(i.view??m),await R.wait(B.ready);let t=i.operation;!e&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Re(t)))&&(p=It,j(p))}catch(e){throw ot(e),e}return{check:Z,host:{get observing(){return Ye},get recovery(){return Jt()},async prepareFallback(){if(ae||w||ee||tt)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};ke(!0);try{let e=await Dt(i);return e.type==="native"&&ge(),e}finally{ke(!1)}},setSuspended(e){De=e,N.hidden=e,e&&O.open?O.close():!e&&!fe?st():!e&&!w&&fe&&Te.type!=="inline"&&!O.open&&O.showModal()},destroy:ge,refresh:async()=>{if(!T()){if(i.view)return i.view;throw new P("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return Se(e),st(),e}}}}export{_n as showPaywall};
1
+ import{a as Qt,c as jt,d as pt,f as mt,g as Bt,k as Ft}from"./chunk-N3C57R2I.js";import{b as dt}from"./chunk-W32FI2A2.js";import{d as _t,e as Mt,f as Ut,h as ft,i as qe,j as $t,k as Vt,l as Ht}from"./chunk-HIUSHWDK.js";import{a as Tt,c as lt,d as St,e as Dt}from"./chunk-CRCAYVV5.js";import{a as Fe,b as he,d as ut,f as Nt,j as Lt}from"./chunk-EQKTKITL.js";import{b as de}from"./chunk-ZQAAZ7Q4.js";import{B as A,C as Be,D as Re,E as Oe,y as Ot}from"./chunk-WQN2D5FZ.js";import"./chunk-JDUB4T4P.js";import"./chunk-VILB5M4X.js";import"./chunk-D3WC3T4U.js";import"./chunk-UIKMEVXM.js";import{r as be,t as me}from"./chunk-GFSAWDV2.js";import{i as Rt}from"./chunk-GJLCTQJN.js";import{c as ue,j as Ae}from"./chunk-4LIM2ZQR.js";import{c as ct}from"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import{a as P}from"./chunk-MFAEHTOH.js";import"./chunk-XB24ATBA.js";import"./chunk-YPN2ZL2V.js";import"./chunk-6RGARS6I.js";import{a as G}from"./chunk-DSPLGTQI.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";async function qt(_,a,E){if(!Re(a))throw new P("INVALID_RESPONSE","A verified completed purchase is required");let k=_?Ae.parse(_):null;if(await E.onComplete?.(a),!k||!E.check)return;let U=Ae.parse(await E.check());if(U.internal_feature_id!==k.internal_feature_id||U.quantity!==k.quantity||k.observation!==void 0&&(U.observation===void 0||U.observation.requirementDigest!==k.observation.requirementDigest||U.observation.authority!==k.observation.authority||ct(U.observation.subject)!==ct(k.observation.subject)))throw new P("INVALID_RESPONSE","The access requirement changed");U.allowed&&await E.onAccessGranted?.(U)}function ht(_){return Object.entries(_.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!de(a.product,{},_.capabilities)).map(([a])=>a)}function Gt(_,a){let E=A(a)?void 0:a.lines[0];if(!A(a)&&(a.lines.length!==1||!E))return;let k=A(a)?a.productVersionId:E.productVersionId,{screen:U,buttons:X}=_.document,R=new Map(A(a)?Object.entries(a.featureQuantities??{}):(E?.prepaid??[]).map(h=>[h.internal_feature_id,h.quantity]));function Z(h,m){if(h.hidden)return!1;if(h.type==="plan_picker"&&_.capabilities.pickers[h.id]?.options.includes(k))return m[h.id]=k,!0;if(h.type==="quantity_picker"){let Y=R.get(h.internalFeatureId);return Y!==void 0&&(!h.bind?.plan||h.bind.plan===k)&&(m[h.id]=Y),!1}if(h.type==="button"&&h.action){let Y=X[h.action];return Y?.type==="checkout"&&Y.product.type==="fixed"&&Y.product.productVersionId===k}if(h.type!=="stack")return!1;let z=h.interaction,i=h.bind?.plan===k;for(let[Y,d]of h.children.entries()){let re={},N=Z(d,re);if(z?.type==="toggle"||z?.type==="tabs"){if(!N)continue;return m[h.id]=z.type==="toggle"?Y===0:d.id,Object.assign(m,re),!0}Object.assign(m,re),N&&(i=!0,z?.type==="select"&&z.purpose==="product"&&z.pickerId&&d.type==="stack"&&d.bind?.plan===k&&(m[h.id]=d.id,m[z.pickerId]=k))}return i}for(let h of U.pages){let m={__page:h.id};if(Z(h.root,m))return m}}async function _n(_,a,E){let k=a.focusAtReveal?()=>{}:ft(_.ownerDocument),U=()=>{R.finish("dismissed"),k()},X=()=>U(),R=$t(_,a,"paywall",()=>{U(),G(a.onDismiss)},Qt);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",X,{once:!0});let Z=null,h,m,z;try{if(R.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),R.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(Z=a.check?Ae.parse(await R.wait(a.check(),qe)):null,Z?.allowed)return R.finish("skipped"),a.signal?.removeEventListener("abort",X),k(),await a.onAccessGranted?.(Z),{check:Z,host:null};let[e,t]=await Promise.allSettled([R.wait(import("./screen-renderer-AQXCFML3.js")),R.wait(a.start().then(r=>(R.cancelled&&r.destroy(),r)),qe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;z=e.value,h=t.value,a.signal?.throwIfAborted(),h.signal?.throwIfAborted(),h.signal?.addEventListener("abort",X,{once:!0});let n=h.view??await R.wait(h.refresh(),qe);if(!n)throw new P("INVALID_RESPONSE","Paywall presentation is missing");h.signal?.throwIfAborted(),m=n}catch(e){throw R.finish("error",e),a.signal?.removeEventListener("abort",X),h?.signal?.removeEventListener("abort",X),h?.destroy(),k(),e}let i=h,{mountScreenPreview:Y}=z,d=_.ownerDocument,re=new AbortController,N=d.createElement("section"),ie=d.createElement("div"),J=d.createElement("div"),Ge=a.mountControls,W=Ge?d.createElement("div"):void 0,f=d.createElement("p"),C=d.createElement("button"),x=d.createElement("button"),O=d.createElement("dialog"),We=i.locale||m.document.screen.strings.defaultLocale,o=We.toLowerCase().startsWith("zh"),Wt=o?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",zt=o?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",M=jt(m.document.screen.theme);N.dataset.indianaPaywall="",N.setAttribute("aria-label",m.document.name),N.style.cssText=M.root,J.style.cssText=M.controls,f.style.cssText=M.message,f.setAttribute("role","status"),x.style.cssText=M.link,x.textContent=o?"\u5173\u95ED":"Close",C.style.cssText=M.secondary,C.textContent=o?"\u91CD\u8BD5":"Retry",C.hidden=!0,J.append(f,C,x),W&&(W.style.cssText="flex:1 0 100%;min-width:0",W.hidden=!0,J.prepend(W)),N.append(ie,J);let ze=()=>{if(W){let r=!W.childElementCount&&!W.textContent?.trim();W.hidden!==r&&(W.hidden=r)}let e=oe??J,t=[...e.children].every(r=>r===f?!f.textContent:r.hidden),n=[...e.children].some(r=>r===x?!1:r===f?!!f.textContent:!r.hidden);e.style.cssText=t?M.controls.replace(/padding:[^;]+/,"padding:0"):n?`${M.controls};${M.pinned}`:M.controls,Xe()},yt=typeof MutationObserver>"u"?void 0:new MutationObserver(ze);yt?.observe(N,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Te=m.document.presentation,Yt=Object.entries(m.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),B,wt,Ye=!1,gt=JSON.stringify(m.capabilities),Je=e=>ae&&!Ce?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):ht(e);function Se(e){if(w)return;m=e;let t=JSON.stringify(e.capabilities);if(t!==gt){let n=!b&&!i.quote&&!i.operation?Fe(e,q,Ct):q;JSON.stringify(n)!==JSON.stringify(q)?(q=n,B?.update(e.document.screen,We,{capabilities:he(e),unavailableActions:Je(e),serverInput:{bindings:[],answers:{}},selection:q})):B?.updateCapabilities(he(e),Je(e)),gt=t}Xt(e),ve()}let I,Ke=0;function Xe(){let e=d.defaultView;if(!I?.responsive||!e)return;let t=oe??J,n=e.innerHeight-(I.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ke=Math.max(1,n-t.getBoundingClientRect().height),B?.resizeViewport?.(Ke,e.innerWidth)}let w=!1,ae=!1,b=null,Ze,De=!1,bt=!1,fe=!1,et,tt=!1,ee,oe;function Jt(){return ae||w||ee||tt?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:lt(i)}let T=()=>!w&&!De&&!ee&&a.canInteract?.()!==!1,F,ye=!1,we=!1,p=null,te=null,nt="",pe=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),q={},Ct=new Set,Ce,K=null;function ve(){if(!pe()||!B?.updateCheckoutControls)return;let e=i.quote,t=!K&&!!e&&!!i.operation&&S(i.operation).type==="checkout",n=Object.entries(m.document.buttons).flatMap(([r,c])=>c.type==="checkout"?[{actionId:r,policy:c}]:[]);B.updateCheckoutControls({actions:n.map(({actionId:r})=>r),resume:t?n.filter(({actionId:r,policy:c})=>Me(e,m,r,c.product,q)).map(({actionId:r})=>r):[],resumeLabel:o?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:Ce})}function vt(){te?.remove(),te=null}async function rt(){if(K)return;if(a.resumeCheckout&&i.operation){await a.resumeCheckout(i.operation.operationId);return}let e=await i.read();if(S(e).type!=="checkout")return $(e,!1);T()&&(Le.delete(e.operationId),await Ue(e))}function Pt(){f.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",C.hidden=!0}async function kt(e=!1){let t=K;if(!t)return;C.hidden=!0;let n=Date.now()+2e4;for(;T();){let r=await i.read();if(r.operationId!==t.operationId)throw new P("PURCHASE_PENDING","The original Checkout changed");if(!T())break;let c=S(r);if(c.type==="native"){K=null,vt(),b=t.selection,F=t.coupon,ye=!1,we=!1,await xe();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){K=null,await $(r,!1);return}if(e&&c.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(g){G(a.onError,g)}}if(Date.now()>=n)break;await dt(1e3,d,re.signal)}w||Pt()}async function Kt(e,t,n){K={operationId:e,selection:t,coupon:n};let r=!1;try{await a.terminateCheckout(e)}catch(c){if(c instanceof P&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){K=null,f.textContent=o?"\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.",G(a.onError,c);return}r=c instanceof P&&(c.status??0)>=500,G(a.onError,c)}T()&&await kt(r)}function Ne(e,t,n,r,c){let g=he(e).checkoutCoupons?.[t],l=g?g.products[n]:a.claimCoupon&&c?Rt(e.capabilities,c,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Xt(e){ae||b||i.quote||i.operation||nt&&f.textContent===nt||(f.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let Le=new Map,_e=!1;function Me(e,t,n,r,c,g){if(A(e)){let H=de(r,c,t.capabilities),le=H&&Ne(t,n,H,c,g),Ie=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0),Ve=me(t.document.screen,e.productVersionId,c,t.capabilities);return H===e.productVersionId&&Object.keys(Ve).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(Ve).every(([He,Qe])=>e.featureQuantities?.[He]===Qe)&&(!le||Ie?.couponId===le.id&&(!le.offerId||Ie.grantId===le.offerId))}let l=e.lines.length===1?e.lines[0]:void 0,s=de(r,c,t.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let L=Ne(t,n,s,c,g);if((L||he(t).checkoutCoupons?.[n])&&(L?.id??null)!==(e.discount?.couponId??null))return!1;let V;try{V=me(t.document.screen,s,c,t.capabilities)}catch{return!1}let ce=Object.fromEntries((l.prepaid??[]).map(H=>[H.internal_feature_id,H.quantity]));return[...new Set([...Object.keys(V),...Object.keys(ce)])].every(H=>(V[H]??0)===(ce[H]??0))}let S=e=>Tt({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Ue(e){let t=e.merchantExecution,n=S(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!T()||!r||Be(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||Le.get(e.operationId)===r)){Le.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):d.defaultView?.location.assign(r)}catch(c){throw Le.delete(e.operationId),c}}}let se=(e,t=!1)=>{if(e instanceof ut)p=null,f.textContent=e.customerMessage(o);else if(Bt(e))p=null,f.textContent=t?o?"\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.":mt(e,o);else if(t){let n=e instanceof P?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(p=null,f.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):i.canReselect===!0&&!b?f.textContent=o?"\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"?f.textContent=o?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":f.textContent=o?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else f.textContent=e instanceof P&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?mt(e,o):e instanceof P?e.message:o?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";C.hidden=p===null,nt=f.textContent,t&&!I?.responsive&&f.scrollIntoView?.({block:"nearest"}),G(t&&E?.quoteError?E.quoteError:a.onError,e)},Pe=new WeakMap;function ke(e){ae=e,C.disabled=e,B?.updateCapabilities?.(he(m),Je(m));for(let t of te?.querySelectorAll("button")??[])e?(Pe.has(t)||Pe.set(t,t.disabled),t.disabled=!0):Pe.has(t)&&(t.disabled=Pe.get(t),Pe.delete(t)),pt(t)}function it(){f.textContent=o?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function Zt(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof ut?(b=null,ye=!1,we=!1,p=null):p=e,t}}async function j(e,t){if(ae||w)return;if(!T()){it();return}let n=e===xe,r=n?zt:Wt,c=pe()&&t!==void 0;Ce=c?t:void 0,ke(!0),ve(),C.hidden=!0,f.textContent=c?"":r;try{if(e!==It&&(e!==rt||!a.resumeCheckout)&&await Zt(e),w)return;if(!T()){p=e,C.hidden=!1,it();return}await e()}catch(g){w||se(g,n&&!c)}finally{Ce=void 0,ke(!1),ve(),f.textContent===r&&(f.textContent="")}}async function en(e){await qt(Z,e,a)}function Et(e){return lt(i).type==="recording"||S(e).type==="recording"}function xt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:A(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!A(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],g=r===null?ue(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ue(r,e.currency)+(c?be(c.interval,o?"zh-CN":"en",c.intervalCount??1):""),l=A(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} \xB7 ${g}`:g,recurring:c}}async function $(e,t=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!T()){p=async()=>$(await i.read()),C.hidden=!1;return}if(f.textContent=Ft(e.status,o),Et(e)){let s=e.merchantExecution?.recordingStatus==="failed";f.textContent=s?o?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",C.textContent=o?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",p=async()=>$(await i.read()),C.hidden=!1;return}if(e.problem&&S(e).type!=="native"){let s=e.problem;p=Ee,C.textContent=o?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",se(new P(s.code,s.reason==="RESULT_UNKNOWN"?o?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?o?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?o?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?o?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(f.textContent=o?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),Re(e)&&S(e).type==="complete"){p=null,await en(e);return}if(!Oe(e)&&S(e).type!=="fulfillment"){if(i.canReselect===!1){f.textContent=o?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",C.textContent=o?"\u67E5\u8BE2\u7ED3\u679C":"Check result",p=async()=>$(await i.read()),C.hidden=!1;return}e.status==="cancelled"?f.textContent=o?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(f.textContent=o?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),C.textContent=o?"\u91CD\u8BD5":"Retry",p=null,b=null;return}if(!t&&S(e).type==="checkout"){if(K){Pt();return}if(pe()){f.textContent="",_e=!1,p=null,ve();return}let s=i.quote,L=s?.operationId===e.operationId?xt(s).label:"";f.textContent=_e?L?o?`${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.`:o?"\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.":"",_e=!1,p=null;return}await Ue(e);let n=Date.now(),r=n+6e5,c=2e3,g=S(e).type!=="checkout",l=()=>g&&Date.now()-n<15e3;Ye=!0,G(a.onObservationChange,!0);try{for(;!w&&Date.now()<r;){if(await dt(l()?700:c,d,re.signal),w)return;if(!T()){p=async()=>$(await i.read()),C.hidden=!1;return}let s=await i.read();if(S(s).type==="checkout"&&(g=!1),!t&&S(s).type==="checkout"){await $(s,!1);return}if(!s.problem&&Oe(s)&&await Ue(s),!Oe(s)||s.problem||Et(s)){await $(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{Ye=!1,G(a.onObservationChange,!1)}p=async()=>$(await i.read()),C.hidden=!1}async function at(e=!1){let t=await i.read();if(w)return;if(!T()){p=()=>at(e),C.hidden=!1;return}let n=i.quote;if(n&&Nt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(Be(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(Be(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){At(n);return}await $(t,e||void 0)}async function It(){await at()}async function Ee(){vt(),p=Ee;let e=await i.confirm();if(!T()){p=Ee,C.hidden=!1;return}if(e.problem){await $(e);return}if(Oe(e)){if(S(e).type==="checkout")await Ue(e);else if(e.execution&&e.execution.provider!=="merchant"||"nativePurchase"in e&&e.nativePurchase){if(!a.onPurchase)throw new P("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:e,signal:re.signal})}}p=async()=>$(await i.read()),await $(e,!0)}function At(e){te?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());f.textContent=t?o?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),r=d.createElement("button"),c=d.createElement("button"),g=d.createElement("div"),l=d.createElement("p"),s=e.merchantTerms,L=o?"zh-CN":"en",V=s?.subscriptionTerms?.items??[],ce=s?s.subscriptionTerms?.trial?.days:A(e)?void 0:e.lines.find(u=>u.trial)?.trial?.days,ne=A(e)?s?s.totalMinor:e.totalMinor:ce===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(u=>u.trial)?0:null,H=(u,y)=>o?`${y} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${u}`:`Then ${u} after the ${y}-day trial`,{label:le,recurring:Ie}=xt(e),Ve=A(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(u=>u.productName).join(", "),He=ne===null?"":`${o?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ue(ne,e.currency)}`;l.textContent=He?[Ve,He].filter(Boolean).join(" \xB7 "):le,r.textContent=A(e)?o?"\u786E\u8BA4\u53D8\u66F4":"Confirm change":o?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",r.disabled=t,c.textContent=o?"\u53D6\u6D88":"Cancel",n.style.cssText=M.panel,l.style.cssText=M.summary,g.style.cssText=M.actions,r.style.cssText=M.primary,c.style.cssText=M.secondary,pt(r),r.onclick=()=>{j(Ee)};let Qe=async()=>{let u=await i.cancel();w||(n.remove(),te=null,await $(u))};c.onclick=()=>{p=Qe,j(Qe)};let Q=d.createElement("div");if(Q.style.cssText=M.terms,A(e)){for(let[y,v]of Object.entries(e.featureQuantities??{})){let D=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(tn=>tn.internalFeatureId===y),je=d.createElement("p");je.textContent=`${D?.name??y} \xB7 ${v} ${o?"\u4EFD":"packs"}${D?` \xD7 ${D.terms.units}`:""}`,Q.append(je)}for(let[y,v]of[[o?"\u539F\u8BA2\u9605\u62B5\u6263":"Unused subscription credit",e.creditMinor],[o?"\u65B0\u5957\u9910\u8D39\u7528":"New plan charge",e.debitMinor],[o?"\u4F18\u60E0\u51CF\u514D":"Offer savings",s?.discountMinor??e.discountMinor],[o?"\u7A0E\u8D39":"Tax",s?s.taxMinor:e.taxMinor]]){let D=d.createElement("p");D.textContent=`${y}: ${v===null?o?"\u7ED3\u8D26\u65F6\u786E\u8BA4":"Confirmed at checkout":ue(v,e.currency)}`,Q.append(D)}let u=d.createElement("p");u.textContent=`${o?"\u751F\u6548\u65F6\u95F4":"Effective"}: ${e.effectiveAt}`,Q.append(u)}if(s){for(let y of V){if(ne===null&&y===Ie)continue;let v=d.createElement("p"),D=ue(y.amountMinor,e.currency)+be(y.interval,L,y.intervalCount);v.textContent=ne!==null&&ce!==void 0?H(D,ce):D,y.amountAfterOfferMinor!==void 0&&(v.textContent+=` \xB7 ${o?"\u4F18\u60E0\u7ED3\u675F\u540E":"After the offer"} ${ue(y.amountAfterOfferMinor,e.currency)}${be(y.interval,L,y.intervalCount)}`),Q.append(v)}let u=s.subscriptionTerms?.trial;if(u){let y=d.createElement("p");y.textContent=o?`\u8BD5\u7528 ${u.days} \u5929\uFF1B${u.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${u.days}; ${u.cardRequired?"a payment method is required":"no payment method is required"}`,Q.append(y)}for(let y of[...s.expectedEffects.map(v=>v.description),...s.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=y,Q.append(v)}}else if(!A(e)){for(let u of e.lines){if(ne!==null||u!==Ie){let y=d.createElement("p"),v=`${ue(u.catalogAmountMinor,e.currency)}${be(u.interval,L,u.intervalCount??1)}`;y.textContent=ne!==null&&u.trial?(e.lines.length>1?`${u.productName} \xB7 `:"")+H(v,u.trial.days):`${u.productName} \xB7 ${v}`,Q.append(y)}for(let y of u.prepaid??[]){let v=d.createElement("p"),D=i.view?.capabilities.plans[u.productVersionId]?.prepaid?.find(je=>je.internalFeatureId===y.internal_feature_id);v.textContent=`${D?.name??y.internal_feature_id} \xB7 ${y.quantity} ${o?"\u4EFD":"packs"} \xD7 ${y.terms.units}`,D&&(v.textContent+=be(D.reset==="week"||D.reset==="month"||D.reset==="year"?D.reset:"one_time",L,D.resetCount)),Q.append(v)}if(u.trial){let y=d.createElement("p");y.textContent=o?`\u8BD5\u7528 ${u.trial.days} \u5929\uFF1B${u.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${u.trial.days}; ${u.trial.cardRequired?"a payment method is required":"no payment method is required"}`,Q.append(y)}}if(!e.charge){let u=d.createElement("p");u.textContent=o?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",Q.append(u)}}for(let u of Q.children)u.style.margin="0";g.append(r,c),n.append(l,...Q.childElementCount?[Q]:[],g),J.prepend(n),I?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),te=n,ae&&ke(!0),p=null}async function xe(){if(!b)return;if(p=xe,!ye){let n=i.view,r=n?.document.buttons[b.actionId],c=n&&r?.type==="checkout"?de(r.product,b.selection,n.capabilities):null;if(!n||!c)throw new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!we){let l=await a.resolveSubscriptionChange?.({actionId:b.actionId,productVersionId:c,featureQuantities:me(n.document.screen,c,b.selection,n.capabilities)});if(w)return;l!==void 0&&(b.subscriptionChange=Ot.parse(l)),we=!0}let g=F?.offerId;if(F&&!g){if(!a.claimCoupon)throw new P("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(F.id,b.requestId);if(w)return;if(!l||l.couponId!==F.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw b=null,F=void 0,p=async()=>{Se(await i.refresh()),p=null},new P("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");g=l.id}if(!F&&!n.document.screen.actions.some(l=>l.id===b?.actionId&&typeof l.properties.couponBinding=="string")&&(g=await a.resolveOfferId?.({actionId:b.actionId,productVersionId:c,featureQuantities:me(n.document.screen,c,b.selection,n.capabilities)})),w)return;g!==void 0&&(b.offerId=g),ye=!0}if(!T()){C.hidden=!1;return}let e;try{e=await i.preview(b)}catch(n){throw i.canReselect===!0&&(b=null,ye=!1,we=!1,F=void 0,p=null),n}if(F&&(A(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==F.id||n.grantId!==b.offerId})():e.discount?.couponId!==F.id||e.discount.offerId!==b.offerId))throw new P("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(a.confirmOnHostedCheckout&&T()&&!A(e)&&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=Ce?"":o?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";f.textContent=n;try{await Ee()}catch(r){w||se(r)}finally{f.textContent===n&&(f.textContent="")}return}At(e)}function ge(e="destroy"){if(w)return;w=!0;let t=Ze;Ze=void 0,G(t),a.signal?.removeEventListener("abort",X),i.signal?.removeEventListener("abort",X),R.finish("dismissed"),wt?.(),re.abort(),yt?.disconnect(),I?.destroy(),B?.destroy(),i.destroy(),O.open&&O.close(),O.remove(),N.remove(),k(),e==="dismiss"&&G(a.onDismiss)}U=ge;async function $e(){if(!fe||w||De||ee==="closing"||!ee&&!T())return;if(!E){ge("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=o?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",oe||(oe=d.createElement("div"),oe.style.cssText=J.style.cssText,J.replaceWith(oe),ie.inert=!0),x.hidden=!1,oe.replaceChildren(e,x),ee="closing",x.setAttribute("aria-disabled","true"),x.focus({preventScroll:!0});try{await E.dismiss()}catch(t){w||G(a.onError,t)}w||(ee="retry",e.textContent=o?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",x.textContent=o?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",x.removeAttribute("aria-label"),x.removeAttribute("aria-disabled"))}x.onclick=()=>{$e()},O.addEventListener("cancel",e=>{e.preventDefault(),$e()}),C.onclick=()=>{p&&j(p)};function ot(e){R.finish("error",e),ge()}function st(){if(!(!bt||fe||w||De||I&&!T()))try{let e=t=>{a.focusAtReveal&&(k=ft(d)),B?.setHidden?.(!1),et?.(),I&&(O.showModal(),I.responsive&&O.focus({preventScroll:!0}),!t&&a.loading!=="host"&&Mt(O,I.type,I.responsive)),t&&a.loading!=="host"&&typeof ie.animate=="function"&&!d.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&ie.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),fe=!0};E?E.present(()=>R.present(()=>e(!0))):R.present(e)}catch(e){ot(e),se(e)}}try{if(Te.type==="inline"?(ze(),et=Ht(N,_),_.append(N)):(O.setAttribute("aria-label",m.document.name),x.textContent="\xD7",x.setAttribute("aria-label",o?"\u5173\u95ED":"Close"),Ut(x,m.document.screen.theme),x.hidden=Lt(m.document),O.append(x,N),_.append(O),I=_t(O,{...m.document.screen,presentation:Te},Xe),I.latch(),I.responsive&&(N.style.display="flex",N.style.flexDirection="column",N.style.maxHeight="100%",ie.style.overflow="clip",ie.style.minHeight="0"),et=Vt(O)),Ge&&W){let n=Ge(W);if(typeof n=="function"&&(w?G(n):Ze=n),w)throw new DOMException("Presentation cancelled","AbortError");ze()}B=Y(ie,{mode:"live",rendererUrl:i.webViewUrl,title:m.document.name,closeActions:Yt,onAuthoredClose(n){ee||w||(x.hidden=n)},hostPresentation:()=>I?.type??Te.type,reportContentHeight:I?.responsive,onResize:n=>{if(!I?.responsive)return;let r=Math.min(n,Ke);ie.style.height=`${r}px`,I.setContentHeight(r+(oe??J).getBoundingClientRect().height)},onSelection(n){for(let[r,c]of Object.entries(n))typeof c=="number"&&typeof q[r]=="number"&&q[r]!==c&&Ct.add(r);q=n,ve()},onAction(n,r={},c,g){if(!fe||w||ee)return;let l=i.view,s=l?.document.buttons[n];if(!s)return;if(s.type==="close"&&E&&a.resumeCheckout&&i.operation&&St(S(i.operation))){$e();return}if(ae)return;if(!T()){it();return}if(s.type==="close"){j(async()=>{E?.closeAction?await E.closeAction(n):await a.onAction?.(n),ge(a.onAction?"action":"dismiss")});return}if(s.type==="action"){p=async()=>{if(s.action.type==="event"){if(!a.onEvent)throw new P("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(s.action.event)}else a.onOpenUrl?await a.onOpenUrl(s.action.url):d.defaultView?.location.assign(s.action.url);await a.onAction?.(n),p=null},j(p);return}if(a.allowNewPurchase===!1){pe()&&l&&i.quote&&i.operation&&S(i.operation).type==="checkout"&&Me(i.quote,l,n,s.product,r,g)?j(rt,n):f.textContent=o?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(te&&i.canReselect===!1){f.textContent=o?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",I?.responsive||te.scrollIntoView?.({block:"nearest"}),te.querySelector("button")?.focus({preventScroll:!0});return}if(pe()&&K){K.selection.actionId===n&&j(()=>kt(!0),n);return}if(pe()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&S(i.operation).type==="checkout"){if(Me(i.quote,l,n,s.product,r,g)){j(rt,n);return}let V=de(s.product,r,l.capabilities);try{if(!V)throw new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");me(l.document.screen,V,r,l.capabilities)}catch(le){se(le);return}let ce=i.operation.operationId,ne={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},H=Ne(l,n,V,r,g);j(()=>Kt(ce,ne,H),n);return}if((i.quote||b)&&i.canReselect===!1){let V=!!l&&!!i.quote&&Me(i.quote,l,n,s.product,r,g);_e=!!i.quote&&!V,p=i.quote?()=>at(V):xe,j(p);return}let L=l&&de(s.product,r,l.capabilities);if(!l||!L){se(new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){p=null,j(async()=>{let V={actionId:n,productVersionId:L,selection:structuredClone(r),featureQuantities:me(l.document.screen,L,r,l.capabilities)};tt=!0,await a.onPurchaseIntent(V)});return}if(b&&b.actionId!==n){se(new P("COMMAND_PENDING","Finish the current purchase"));return}b||(F=Ne(l,n,L,r,g),b={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},ye=!1,we=!1),j(xe,n)},onEscape:()=>{$e()},onError:n=>{let r=new Error(n);!fe&&!w&&ot(r),se(r)},onRendered:n=>{n&&O.setAttribute("aria-label",n),bt=!0,st()}}),B.setHidden?.(!0),Xe();let e=pe()&&!!i.quote&&!!i.operation&&S(i.operation).type==="checkout";q=i.quote?Gt(m,i.quote)??Fe(m,{}):Fe(m,{}),B.update(m.document.screen,We,{capabilities:he(m),unavailableActions:ht(m),serverInput:{bindings:[],answers:{}},...Object.keys(q).length?{selection:q}:{}}),wt=i.subscribe?.(Se),Se(i.view??m),await R.wait(B.ready);let t=i.operation;!e&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Re(t)))&&(p=It,j(p))}catch(e){throw ot(e),e}return{check:Z,host:{get observing(){return Ye},get recovery(){return Jt()},async prepareFallback(){if(ae||w||ee||tt)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};ke(!0);try{let e=await Dt(i);return e.type==="native"&&ge(),e}finally{ke(!1)}},setSuspended(e){De=e,N.hidden=e,e&&O.open?O.close():!e&&!fe?st():!e&&!w&&fe&&Te.type!=="inline"&&!O.open&&O.showModal()},destroy:ge,refresh:async()=>{if(!T()){if(i.view)return i.view;throw new P("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return Se(e),st(),e}}}}export{_n as showPaywall};
@@ -0,0 +1 @@
1
+ import{b as a}from"./chunk-EIVFBGI5.js";import"./chunk-UBUFXGS7.js";import"./chunk-MBWUIYCH.js";import"./chunk-L7OMFH4O.js";import"./chunk-JZ73DRHT.js";import"./chunk-ZQAAZ7Q4.js";import"./chunk-WQN2D5FZ.js";import"./chunk-JDUB4T4P.js";import"./chunk-VILB5M4X.js";import"./chunk-D3WC3T4U.js";import"./chunk-UIKMEVXM.js";import"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import"./chunk-4LIM2ZQR.js";import"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import"./chunk-MFAEHTOH.js";import"./chunk-XB24ATBA.js";import"./chunk-3VUPVXAV.js";import"./chunk-YPN2ZL2V.js";import"./chunk-6RGARS6I.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ASCVMPXG.js";import"./chunk-L42A5KVA.js";import"./chunk-7MTQQIGR.js";import"./chunk-PPOPJTHA.js";import"./chunk-CI7UPAWD.js";import"./chunk-A37ZU2AP.js";import"./chunk-EIVFBGI5.js";import"./chunk-UBUFXGS7.js";import"./chunk-MBWUIYCH.js";import"./chunk-L7OMFH4O.js";import"./chunk-JZ73DRHT.js";import"./chunk-CRCAYVV5.js";import"./chunk-EQKTKITL.js";import"./chunk-ZQAAZ7Q4.js";import"./chunk-WQN2D5FZ.js";import"./chunk-JDUB4T4P.js";import"./chunk-VILB5M4X.js";import"./chunk-SWULFBRF.js";import"./chunk-D3WC3T4U.js";import"./chunk-UIKMEVXM.js";import"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import"./chunk-4LIM2ZQR.js";import"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import"./chunk-MFAEHTOH.js";import"./chunk-XB24ATBA.js";import"./chunk-3VUPVXAV.js";import"./chunk-YPN2ZL2V.js";import"./chunk-6RGARS6I.js";import"./chunk-DSPLGTQI.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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-GGFCD3PT.js";import"./chunk-7HU7JZVZ.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.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-TWQB35B7.js";import"./chunk-HIUSHWDK.js";import"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import"./chunk-4LIM2ZQR.js";import"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import"./chunk-MFAEHTOH.js";import"./chunk-XB24ATBA.js";import"./chunk-6RGARS6I.js";import"./chunk-DSPLGTQI.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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-TJMC7WPQ.js";import"./chunk-RJY5CUTB.js";import{a as A}from"./chunk-NZ2DB72P.js";import{e as P}from"./chunk-MEDW4N3F.js";import"./chunk-LZ3OJYBY.js";import{h as b,i as x,k as L}from"./chunk-YPOE4KNG.js";import{E as C}from"./chunk-VBJTINET.js";import"./chunk-IT5DIE6G.js";import"./chunk-NVF54BDR.js";import"./chunk-AV2WZSII.js";import"./chunk-MPD3UIY4.js";import"./chunk-ZKGVOJCV.js";import"./chunk-PBZSOTKZ.js";import"./chunk-HLCDAU5A.js";import"./chunk-DCZWNTG2.js";import"./chunk-CALDEF4M.js";import"./chunk-ASL7TJFU.js";import"./chunk-B4AELNLE.js";import"./chunk-AQONMY2H.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-FTGRTYBL.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import{a as r}from"./chunk-TL67SYPH.js";import{h as R}from"./chunk-6XRXHFM6.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.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-ZNTV6TU7.js";import"./chunk-R2OJIXYE.js";import{a as A}from"./chunk-ASCVMPXG.js";import{e as P}from"./chunk-L42A5KVA.js";import"./chunk-7MTQQIGR.js";import{h as b,i as x,k as L}from"./chunk-AKBF7TGD.js";import{E as C}from"./chunk-YHC5WAVP.js";import"./chunk-POOXIM6Q.js";import"./chunk-PPOPJTHA.js";import"./chunk-CI7UPAWD.js";import"./chunk-A37ZU2AP.js";import"./chunk-EIVFBGI5.js";import"./chunk-UBUFXGS7.js";import"./chunk-MBWUIYCH.js";import"./chunk-L7OMFH4O.js";import"./chunk-X2ON6QRA.js";import"./chunk-JZ73DRHT.js";import"./chunk-CRCAYVV5.js";import"./chunk-EQKTKITL.js";import"./chunk-ZQAAZ7Q4.js";import"./chunk-WQN2D5FZ.js";import"./chunk-JDUB4T4P.js";import"./chunk-VILB5M4X.js";import"./chunk-SWULFBRF.js";import"./chunk-D3WC3T4U.js";import"./chunk-UIKMEVXM.js";import"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import"./chunk-4LIM2ZQR.js";import"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import{a as r}from"./chunk-MFAEHTOH.js";import{h as R}from"./chunk-XB24ATBA.js";import"./chunk-3VUPVXAV.js";import"./chunk-YPN2ZL2V.js";import"./chunk-6RGARS6I.js";import"./chunk-DSPLGTQI.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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-TWQB35B7.js";import"./chunk-HIUSHWDK.js";import"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import"./chunk-4LIM2ZQR.js";import"./chunk-DTOYPMAW.js";import"./chunk-KAMYLHAT.js";import"./chunk-MFAEHTOH.js";import"./chunk-XB24ATBA.js";import"./chunk-6RGARS6I.js";import"./chunk-DSPLGTQI.js";import"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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-YBANRBZX.js";import{a as I}from"./chunk-V65FSNYO.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-UJMP7AMY.js";import{a as xt}from"./chunk-NZ2DB72P.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-MEDW4N3F.js";import"./chunk-LZ3OJYBY.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-YPOE4KNG.js";import{B as V,C as N,d as ft,e as ht,k as gt,l as z,m as St,p as Ct,q as Rt,r as bt,s as At,t as Ot,y as pe,z as Tt}from"./chunk-VBJTINET.js";import"./chunk-IT5DIE6G.js";import{c as h}from"./chunk-NVF54BDR.js";import"./chunk-AV2WZSII.js";import{a as Et,b as _e}from"./chunk-MPD3UIY4.js";import"./chunk-ZKGVOJCV.js";import"./chunk-PBZSOTKZ.js";import{e as at}from"./chunk-HLCDAU5A.js";import{B as pt,C as de,D as Z,E as lt,J as mt,a as et,e as q,j as Re,k as st,l as ct,q as ut,r as dt,s as be,t as Ae}from"./chunk-DCZWNTG2.js";import{b as Oe}from"./chunk-CALDEF4M.js";import{e as ve,i as Ze,l as it}from"./chunk-ASL7TJFU.js";import"./chunk-B4AELNLE.js";import"./chunk-AQONMY2H.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import{A as oe,B as tt,C as Se,D as ie,F as se,G as Ce,L as j,N as ce,O as nt,Q as Ee,R as rt,S as ot,e as Ge,f as je,i as we,q as ze,r as Ke,t as an,u as sn,x as cn,y as X,z as W}from"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-FTGRTYBL.js";import"./chunk-OTNH77B2.js";import{a as Ne,b as Le}from"./chunk-LSVTH3TS.js";import{o as ue}from"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-CWD36SJO.js";import{c as Ie}from"./chunk-5JRBCW6V.js";import{e as Xe,h as We}from"./chunk-3SXPCVIP.js";import{a as c}from"./chunk-TL67SYPH.js";import{h as Y}from"./chunk-6XRXHFM6.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import{b as u}from"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.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-6RNLPMMJ.js";import{a as I}from"./chunk-XQN7MLP5.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-UHT5DGAJ.js";import{a as xt}from"./chunk-ASCVMPXG.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-L42A5KVA.js";import"./chunk-7MTQQIGR.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-AKBF7TGD.js";import{B as V,C as N,d as ft,e as ht,k as gt,l as z,m as St,p as Ct,q as Rt,r as bt,s as At,t as Ot,y as pe,z as Tt}from"./chunk-YHC5WAVP.js";import"./chunk-POOXIM6Q.js";import{c as h}from"./chunk-PPOPJTHA.js";import"./chunk-CI7UPAWD.js";import{a as Et,b as _e}from"./chunk-A37ZU2AP.js";import"./chunk-EIVFBGI5.js";import"./chunk-UBUFXGS7.js";import{e as at}from"./chunk-MBWUIYCH.js";import{B as pt,C as de,D as Z,E as lt,J as mt,a as et,e as q,j as Re,k as st,l as ct,q as ut,r as dt,s as be,t as Ae}from"./chunk-L7OMFH4O.js";import{b as Oe}from"./chunk-X2ON6QRA.js";import{e as ve,i as Ze,l as it}from"./chunk-JZ73DRHT.js";import"./chunk-CRCAYVV5.js";import"./chunk-EQKTKITL.js";import"./chunk-ZQAAZ7Q4.js";import"./chunk-WQN2D5FZ.js";import{A as oe,B as tt,C as Se,D as ie,F as se,G as Ce,L as j,N as ce,O as nt,Q as Ee,R as rt,S as ot,e as Ge,f as je,i as we,q as ze,r as Ke,t as an,u as sn,x as cn,y as X,z as W}from"./chunk-JDUB4T4P.js";import"./chunk-VILB5M4X.js";import"./chunk-SWULFBRF.js";import"./chunk-D3WC3T4U.js";import{a as Ne,b as Le}from"./chunk-UIKMEVXM.js";import{o as ue}from"./chunk-GFSAWDV2.js";import"./chunk-GJLCTQJN.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-4LIM2ZQR.js";import{c as Ie}from"./chunk-DTOYPMAW.js";import{e as Xe,h as We}from"./chunk-KAMYLHAT.js";import{a as c}from"./chunk-MFAEHTOH.js";import{h as Y}from"./chunk-XB24ATBA.js";import"./chunk-3VUPVXAV.js";import"./chunk-YPN2ZL2V.js";import{b as u}from"./chunk-6RGARS6I.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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}
@@ -1 +1 @@
1
- import{b as a,c as b}from"./chunk-RA7GZ67U.js";import"./chunk-J6KIN4RH.js";import"./chunk-WOT6VMZA.js";export{b as applyVisualVariation,a as safeVisualMutation};
1
+ import{b as a,c as b}from"./chunk-KV5MZ4NI.js";import"./chunk-J6KIN4RH.js";import"./chunk-WOT6VMZA.js";export{b as applyVisualVariation,a as safeVisualMutation};
package/dist/visual.js CHANGED
@@ -1 +1 @@
1
- import{a as pe,c as fe}from"./chunk-RA7GZ67U.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-CPBHDAL4.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-CGAE5OZ3.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import{b as o}from"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.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-KV5MZ4NI.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-SIJY35EE.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-AAILPAL5.js";import"./chunk-3VUPVXAV.js";import"./chunk-YPN2ZL2V.js";import{b as o}from"./chunk-6RGARS6I.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-XWD4N2QI.js";import"./chunk-FRK6322O.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.45",
3
+ "version": "0.10.46",
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-MPD3UIY4.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-GPJF3T43.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
@@ -1 +0,0 @@
1
- import{o as n,r as t}from"./chunk-VBJTINET.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +0,0 @@
1
- import{b as Kn}from"./chunk-GWTNU665.js";import{a as Jn,b as jn,c as fn,d as mn,e as $e,f as Bn,h as Wn,i as Yn,j as Xn,k as Zn}from"./chunk-LNEBSVA7.js";import{b as Sn,c as et}from"./chunk-CEYUJ3LO.js";import{a as Mn}from"./chunk-W32FI2A2.js";import{c as $n,e as xn,f as Gn,h as Qn,i as _e,j as tn,k as zn,l as rn}from"./chunk-7HU7JZVZ.js";import{b as Fn}from"./chunk-IT5DIE6G.js";import{K as nn}from"./chunk-DCZWNTG2.js";import{a as Me,d as Nn}from"./chunk-B4AELNLE.js";import{c as On,e as _n,f as Ln,g as Hn,h as Vn,i as Un}from"./chunk-AQONMY2H.js";import{b as Tn}from"./chunk-RDUKCMST.js";import{B as pn}from"./chunk-KP4QI4RX.js";import{w as Dn}from"./chunk-5TJISOWN.js";import{t as An}from"./chunk-7MYS52FL.js";import{C as kn}from"./chunk-MWICFZUF.js";import{a as w}from"./chunk-TL67SYPH.js";import{a as Ee}from"./chunk-DSPLGTQI.js";async function wn(t){let{session:b,load:P}=ut(t);try{return await P(),b}catch(n){throw b.destroy(),n}}function ut(t){let b=t.view;if(!b?.paywall)throw new w("INVALID_REQUEST","The current node is not a Paywall");let P=b.paywall.receiptId,n=b.nodeId,g=b.visit,A=b.paywall.resolution,o=b.paywall,O="document"in A?{document:A.document,offering:A.offering,capabilities:A.capabilities}:null;function u(){let i=o.resolution;return"document"in i?i:O&&{...i,document:O.document,offering:O.offering,capabilities:On(i.capabilities,O.capabilities)}}function C(i){if(!_n(i,A))throw new w("INVALID_RESPONSE","The pinned Paywall binding changed")}let R=!1,x=new Set,ie=null;function m(){let i=u();if(i&&!R)for(let a of x)Ee(a,structuredClone(i))}async function _(){I();let i=u();if(i)return structuredClone(i);if(!ie){let a=(async()=>{if("document"in o.resolution||!t.resolvePaywall)throw new w("INVALID_RESPONSE","Public Paywall reader is unavailable");let q=await Sn(t,o.resolution);return I(),C(q),O={document:q.document,offering:q.offering,capabilities:q.capabilities},m(),u()})();ie=a;let s=()=>{ie===a&&(ie=null)};a.then(s,s)}return ie.then(a=>structuredClone(a))}let l=new AbortController,E=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===n&&i.visit===g&&i.input.type==="paywall_quote")?.requestId??b.paywall.purchaseRequestId,S=0,re=null,U=new Set,M=null,z=new Map;function Q(i){if(i.purchase&&i.purchase.receiptId!==P)throw new w("INVALID_RESPONSE","Purchase receipt changed");let a=i.run.paywall;return i.purchase??(a?.receiptId===P?a:null)}function I(){if(R)throw new w("IDENTITY_CHANGED","Paywall presentation has closed")}function Z(i,a,s){if(I(),a!==S||s!==void 0&&o.quote?.operationId!==s)return!1;let q=o.selectionGeneration??0,f=i.run.paywall;if(f?.receiptId===P){if((f.selectionGeneration??0)<(o.selectionGeneration??0))return!1;C(f.resolution)}let p=Q(i),F=f?.receiptId===P&&(f.selectionGeneration??0)>q,y=F?p?.quote??null:p?.quote??o.quote,Y=p?.operation??(y?.operationId===o.quote?.operationId?o.operation:null);return o.quote&&y&&Vn(o.quote,y),y&&Y&&Ln(Y,{operationId:y.operationId,membershipId:pn(y)?y.membershipId:null,...pn(y)?{featureQuantities:y.featureQuantities??{}}:{}},"Purchase operation changed"),(F||y?.operationId!==o.quote?.operationId)&&(S++,f?.receiptId===P&&(E=f.purchaseRequestId)),f?.canReselect===!0&&f.purchaseRequestId===M&&!(t.pendingCommands??[t.pendingCommand]).some(X=>X?.requestId===M)&&(M=null),o={...o,...f?.receiptId===P?f:{},...s!==void 0&&!F&&p?.canReselect!==void 0?{canReselect:p.canReselect}:{},quote:y,operation:Un(o.operation,Y,!0)},m(),!0}function N(i,a,s){return new Promise((q,f)=>{let p=!1,F=()=>{clearTimeout(j),l.signal.removeEventListener("abort",X)},y=ge=>{p||(p=!0,F(),q(ge))},Y=ge=>{p||(p=!0,F(),f(ge))},X=()=>Y(new w("IDENTITY_CHANGED","Paywall presentation has closed")),j=setTimeout(()=>Y(new w("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,s)),Math.max(0,a-Date.now()));l.signal.addEventListener("abort",X,{once:!0}),l.signal.aborted&&X(),i.then(y,Y)})}function qe(i){return new Promise(a=>{let s=()=>{clearTimeout(q),l.signal.removeEventListener("abort",s),a()},q=setTimeout(s,i);l.signal.addEventListener("abort",s,{once:!0}),l.signal.aborted&&s()})}function he(i,a){I();let s=z.get(i)??t.pendingCommands?.find(p=>p.requestId===i)??t.pendingCommand;if(s?.operation==="submit"&&s.requestId===i&&s.nodeId===n&&s.visit===g){a.type==="paywall_quote"&&s.input.type==="paywall_quote"&&s.input.predecessor&&!a.predecessor&&(a={...a,predecessor:s.input.predecessor});let p=nn.parse(s),F=nn.parse({...s,input:a});if(p.operation!=="submit"||F.operation!=="submit"||JSON.stringify(p.input)!==JSON.stringify(F.input))throw new w("CONFLICT","A purchase request cannot change its input");return z.set(i,p),p}let q=t.view;if(!q||q.nodeId!==n||q.visit!==g||q.paywall?.receiptId!==P)throw new w("PRECONDITION_FAILED","The Paywall visit has changed");let f=nn.parse({operation:"submit",requestId:i,nodeId:n,visit:g,revision:q.revision,input:structuredClone(a)});if(f.operation!=="submit")throw new w("INVALID_REQUEST","A purchase submission is required");return z.set(i,f),f}async function we(i,a){I();let{requestId:s,input:q}=i,f=Date.now()+3e4;U.add(s);try{let p=await N(t.submit(i),f,s);for(;p.run.pendingRequest?.requestId===s&&Date.now()<f&&!R&&(await qe(Math.min(1e3,f-Date.now())),!(R||Date.now()>=f));)p=await N(t.resume(s),f,s);if(R)throw new w("IDENTITY_CHANGED","Paywall presentation has closed");if(p.run.pendingRequest?.requestId===s)throw new w("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,s);if(!Z(p,a,q.type==="paywall_confirm"||q.type==="paywall_cancel"?q.operationId:void 0))throw new w("PRECONDITION_FAILED","The purchase selection has changed");M===s&&(M=null)}catch(p){if(M=s,q.type==="paywall_quote"&&t.settle&&!R&&p instanceof w&&p.status!==void 0&&![401,425].includes(p.status)&&!p.retryable&&p.recovery!=="recover_operation")try{if((await N(t.settle(s),f,s)).settlement?.state==="settled"){let y=await N(t.get(),f,s);Z(y,a)&&y.run.paywall?.purchaseRequestId===s&&o.canReselect===!0&&z.delete(s)}}catch{}throw p instanceof w&&p.code==="COMMAND_PENDING"&&p.status===void 0&&z.delete(s),p}finally{U.delete(s)}}async function W(i){if(!o.quote)throw new w("INVALID_REQUEST","A quoted purchase is required");let a=i==="confirm"?"paywall_confirm":"paywall_cancel",s=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(f=>f.operation==="submit"&&f.input.type===a&&"operationId"in f.input&&f.input.operationId===o.quote.operationId),q=s?.operation==="submit"&&s.input.type===a&&"operationId"in s.input&&s.input.operationId===o.quote.operationId?s.requestId:crypto.randomUUID();if(await we(he(q,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:o.quote.operationId,...i==="confirm"&&o.quote.merchantTerms?{merchantConfirmation:Dn(o.quote.merchantTerms)}:{}}),S),!o.operation)throw new w("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(o.operation)}let le={get view(){return structuredClone(u())},get quote(){return o.quote?structuredClone(o.quote):null},get operation(){return o.operation?structuredClone(o.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??b.locale},get canReselect(){return o.canReselect===!0&&M===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),a=t.pendingPurchase;if(a&&(a.receiptId!==P||a.operationId!==o.quote?.operationId))return{type:"recover",operationId:a.operationId,requestId:i[0]?.requestId??null};let s=Me({quote:o.quote,operation:o.operation,requestId:i[0]?.requestId??M??E,pending:U.size>0||i.length>0||M!==null,destroyed:R,canReselect:o.canReselect});return s.type==="recover"&&s.requestId===null&&!R&&t.hasDurableJournal===!0&&!o.quote&&!o.operation&&(o.selectionGeneration??0)===0&&!a&&!i.length&&!U.size&&!E?{type:"native",operationId:null}:s},get pendingCancellation(){return!R&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===n&&i.visit===g&&i.input.type==="paywall_cancel"&&i.input.operationId===o.quote?.operationId)},subscribe(i){return R?()=>{}:(x.add(i),()=>x.delete(i))},async refresh(){I();let i=S,a=await t.get();if(Z(a,i),a.run.paywall?.receiptId!==P)throw new w("PRECONDITION_FAILED","Paywall presentation has changed");return _()},preview(i){let a=u();if(!a)return Promise.reject(new w("PRECONDITION_FAILED","Load the Paywall presentation first"));if(E&&E!==i.requestId&&(re||o.canReselect!==!0))return Promise.reject(new w("COMMAND_PENDING","Retry the original purchase before starting another"));let s=a.document.buttons[i.actionId],q=s?.type==="checkout"?Tn(s.product,i.selection,a.capabilities):null;if(!q)return Promise.reject(new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let f=An(a.document.screen,q,i.selection,a.capabilities),p=E!==i.requestId&&(o.selectionGeneration??0)>0?{operationId:o.quote?.operationId??null,generation:o.selectionGeneration??0}:void 0,F=t.view?.parameters.commerce;if(F&&typeof F=="object"&&!Array.isArray(F)&&F.intent==="subscription_change"&&!i.subscriptionChange)return Promise.reject(new w("INVALID_REQUEST","Choose the existing membership for this subscription change"));if(i.subscriptionChange&&i.nativeOffer)return Promise.reject(new w("INVALID_REQUEST","A web membership change cannot include a store offer"));if(p&&o.canReselect!==!0)return Promise.reject(new w("COMMAND_PENDING","Original purchase requires authoritative termination"));let y;try{y=he(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:q,...Object.keys(f).length?{featureQuantities:f}:{},...p?{predecessor:p}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{},...i.subscriptionChange?{subscriptionChange:i.subscriptionChange}:{}})}catch(j){return Promise.reject(j)}if(E===i.requestId&&re)return re;E!==i.requestId&&S++;let Y=S;E=i.requestId;let X=(async()=>{if(await we(y,Y),!o.quote)throw new w("INVALID_RESPONSE","The accepted quote is missing");return Hn(o.quote,{productVersionId:q,featureQuantities:f,subscriptionChange:i.subscriptionChange},"The selected purchase changed"),structuredClone(o.quote)})();return re=X,X.then(()=>{re===X&&(re=null)},j=>{re===X&&(re=null),E===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&j instanceof w&&j.status!==void 0&&j.status<500&&![401,425].includes(j.status)&&(E=null)}),X},confirm:()=>W("confirm"),cancel:()=>W("cancel"),async read(){if(I(),!o.quote)throw new w("INVALID_REQUEST","A quoted purchase is required");let i=o.quote.operationId,a=S,s=t.pendingCommands?.find(y=>y.operation==="submit"&&(y.input.type==="paywall_confirm"||y.input.type==="paywall_cancel")&&y.input.operationId===i)??t.pendingCommand;s?.operation==="submit"&&(s.input.type==="paywall_confirm"||s.input.type==="paywall_cancel")&&s.input.operationId===i&&await t.settle?.(s.requestId);let q=await t.get(void 0,{receiptId:P,operationId:i});I();let f=Q(q);if(f?.quote&&f.quote.operationId!==i||f?.operation&&f.operation.operationId!==i)throw new w("INVALID_RESPONSE","Purchase operation changed");let p=Z(q,a,i),F=p?o.operation:f?.operation;if(!F)throw new w("INVALID_RESPONSE","The current purchase result is missing");return p&&U.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(M=null),structuredClone(F)},destroy(){R=!0,L(),x.clear(),l.abort(),z.clear()}},L=t.subscribe(i=>{R||i.nodeId!==n||i.visit!==g||i.paywall?.receiptId!==P||(i.paywall.selectionGeneration??0)<(o.selectionGeneration??0)||(C(i.paywall.resolution),o={...o,resolution:i.paywall.resolution},m())});return{session:le,load:_}}function nt(t){let b=new Set,P=new Set,n=null;async function g(u,C){let R=!1;for(;!t.stopped&&t.key===u&&t.client.pendingCommand?.requestId===C;){if(!t.client.settle)throw new w("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(C),R=!0,t.client.pendingCommand?.requestId===C&&await new Promise(x=>setTimeout(x,1500))}t.stopped||t.key!==u||(R&&await t.client.get(),!(t.stopped||t.key!==u)&&b.add(u))}function A(u,C){n=C;let R=()=>{n===C&&(n=null),P.delete(u)};return C.then(R,x=>{R(),t.busy||t.fail(x)}),C}function o(u){if(t.reviewing||b.has(u)||P.has(u)||t.stopped)return;P.add(u);let C=async()=>{if(t.reviewing||t.stopped||t.key!==u||b.has(u)){P.delete(u);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{C()},250);return}let R=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==u)return;if(t.client.pendingCommand){setTimeout(()=>{C()},250);return}}let x=t.client.view,ie=t.expected(),m=ie.requestId;try{await t.client.submit({operation:"shown",...ie})}catch(_){if(!(_ instanceof w)||_.code!=="CONFLICT"||_.status!==409||t.client.pendingCommand)throw _;await t.client.get();let l=t.client.view;if(t.stopped||t.reviewing||t.key!==u||!l||!x||l.id!==x.id||l.source.versionId!==x.source.versionId||l.nodeId!==ie.nodeId||l.visit!==ie.visit||l.revision<=ie.revision||l.stopped||!l.screen&&(!l.paywall||l.paywall.receiptId!==x.paywall?.receiptId)||!["running","waiting"].includes(l.status)||t.client.pendingCommand)throw _;let c=t.expected();m=c.requestId,await t.client.submit({operation:"shown",...c})}await g(u,m)})();A(u,R)};C()}function O(){if(n)return n;let u=t.client.pendingCommand;if(u?.operation!=="shown")return null;let C=t.key;return P.add(C),A(C,(async()=>{await t.client.retry(),await g(C,u.requestId)})())}return{report:o,settled:O,get inFlight(){return n}}}function tt(t){let b={},P=new Map;async function n(g){let A=t.client.view,o=A?.screen,O=o?.customerData.nodes[g.nodeId];if(t.stopped||t.busy||!A||!o||!O)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(g.action)){let _=t.document,l=_?kn(_,g.nodeId):null,c=l?.type==="customer_data"?l.data.outputs?.[g.action]:void 0;c&&o.outputs.includes(c)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:c,answers:t.answers,selection:g.value?{[g.nodeId]:g.value}:{}}})):await t.onIntent?.(g,A);return}let C=g.action.startsWith("sources_")?O.resources.find(_=>_.key===g.value):null;if(g.action.startsWith("sources_")&&!C)throw new w("INVALID_REQUEST","Choose a current resource");let R=`${A.visit}:${g.nodeId}:${C?.key??""}`,x=P.get(R)??[null],m=b[g.nodeId]??{page:1,after:null,filter:"all",...C?{resourceKey:C.key}:{}};if(g.action==="filter"){let _=g.value;if(!_||!(O.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(_))throw new w("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:_},x.splice(0,x.length,null)}else if(g.action==="next"||g.action==="sources_next"){let _=C?.sources.at(-1),l=C?_?{kind:"ledger",cursor:{at:_.detail[0],id:_.id,type:"source"}}:null:o.dataCursors[g.nodeId];if(!l||!C&&!O.hasNext)return;x[m.page]=l,m={...m,page:m.page+1,after:l}}else if(g.action==="previous"||g.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:x[m.page-2]??null}}P.set(R,x),b={...b,[g.nodeId]:m},await t.perform(()=>t.client.get({nodeId:A.nodeId,visit:A.visit,revision:A.revision,components:b}))}return{get queries(){return b},intent:n,reset(){b={},P.clear()}}}function it(t){let{doc:b,holder:P,reviewHolder:n,mountScreenPreview:g}=t,A=!1,o,O=0,u=null,C="",R,x=new Map,ie=l=>l?`${l.id}:${l.nodeId}:${l.visit}:${l.revision}:${l.paywall?.quote?.operationId??""}`:"";async function m(l){if(t.stopped||!t.client.review||A&&l===o&&R?.active)return;let c=!A||l!==o;A||(C=ie(t.client.view),x.set(C,structuredClone(t.answers))),A=!0,o=l,P.hidden=!0,t.suspend(!0),n.hidden=!1;let E=++O;c&&(R?.finish("dismissed"),u?.destroy(),u=null,n.replaceChildren(),R=tn(n,t.loadingOptions,"funnel",()=>{_()}));let S=c?R:void 0;try{if(S?.start(!1,t.client.view?.locale),E!==O||t.stopped)return;let re=t.client.review(l),U=await(S?.wait(re,_e)??re);if(t.stopped||E!==O||!A)return;if(!U.review)throw new w("INVALID_RESPONSE","Historical projection is missing");u?.destroy(),u=null,S||n.replaceChildren();let M=b.createElement("div"),z=S?rn(M,n):()=>{};n.append(M);let Q=U.run.locale.startsWith("zh"),I=t.chrome;M.style.cssText=I.history;let Z=b.createElement("p");Z.textContent=Q?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",Z.style.cssText=I.historyTitle,M.append(Z);let N=b.createElement("p");N.style.cssText=I.historyNote,N.textContent=U.review.pages.length?Q?"\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.":Q?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",M.append(N);let qe=U.review.page?.receiptId,he=b.createElement("div");he.style.cssText=I.historyPages;for(let[le,L]of U.review.pages.entries()){let i=b.createElement("button");i.type="button",i.textContent=Q?`\u7B2C ${le+1} \u9875`:`Page ${le+1}`;let a=qe!==void 0&&L.receiptId===qe;i.style.cssText=a?I.primary:I.secondary,a&&i.setAttribute("aria-current","page"),$e(i,()=>t.chrome.focus),i.onclick=()=>{m(L.receiptId)},he.append(i)}if(he.childElementCount&&M.append(he),U.review.page){let le=U.review.page,L=b.createElement("div");L.inert=!0,L.style.cssText=I.historyPage,M.append(L),u=g(L,{mode:"live",rendererUrl:t.client.webViewUrl,title:le.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{E===O&&!t.stopped&&S?.present(z)},onError:a=>{if(E!==O||t.stopped)return;let s=new Error(a);S?.finish("error",s),u?.destroy(),u=null,M.remove(),t.fail(s)},onEscape:()=>{_()}});let i=u;if(i.update(le.document,U.run.locale,{serverInput:{bindings:le.inputs,answers:le.answers,values:le.values}}),await i.ready,t.stopped||E!==O||!A)return}let we=Q?{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"},W=b.createElement("div");W.style.cssText=I.historyRecords;for(let le of[...U.review.coupons.map((L,i)=>`${Q?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${we[L.status]}`),...U.review.purchases.map((L,i)=>`${Q?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Zn(L.status,Q)}`)]){let L=b.createElement("p");L.textContent=le,L.style.margin="0",W.append(L)}W.childElementCount&&M.append(W),U.review.page||S?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(re){if(E!==O||t.stopped)return;S?.finish("error",re),u?.destroy(),u=null,n.replaceChildren(),t.fail(re)}}async function _(){if(!A||t.stopped||!t.client.review)return;let l=++O;R?.finish("dismissed");try{if(await t.client.review(),t.stopped||l!==O)return;A=!1,O++,R?.finish("dismissed"),u?.destroy(),u=null,n.replaceChildren(),n.hidden=!0,P.hidden=!1;let c=t.client.view;ie(c)!==C?(x.set(C,structuredClone(t.answers)),t.resetScreen()):(x.delete(C),t.suspend(!1)),c&&await t.enqueue(c)}catch(c){if(l!==O||t.stopped)return;u?.destroy(),u=null,n.replaceChildren(),t.fail(c)}}return{get active(){return A},get receipt(){return o},open:m,exit:_,get drafts(){return new Map([...x].map(([l,c])=>[l,structuredClone(c)]))},stop(){A=!1,O++,R?.finish("dismissed"),u?.destroy(),u=null,n.replaceChildren(),n.hidden=!0,P.hidden=!1}}}var yn=5e3;async function dt(t,b,P){let n=b,g=n.prepared&&Kn(n.prepared),A=()=>{};function o(){n.prepared&&n.prepared.state!=="adopted"&&g?.release()}let O=()=>n.prepared?.state==="shown"&&!!g?.modal,u=n.client.identitySignal,C;try{C=await Promise.all([import("./screen-renderer-E4TZF74V.js"),import("./paywall-IAKGXJTB.js")]),n.signal?.throwIfAborted(),u?.throwIfAborted()}catch(e){throw o(),e}let[{mountScreenPreview:R},{showPaywall:x}]=C,ie=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.appManifestRelease?et({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;ie?.start();let m=t.ownerDocument,_=Qn(m),l=!1,c=m.createElement("section"),E=m.createElement("div"),S=m.createElement("div"),re=m.createElement("div"),U=m.createElement("button");re.hidden=!0,U.type="button";let M=m.createElement("p"),z=m.createElement("p"),Q=m.createElement("button"),I=m.createElement("button"),Z=m.createElement("button"),N=m.createElement("dialog"),qe,he=!1;c.dataset.indianaFunnel="",c.dataset.longplayCloseOwner="sdk",c.setAttribute("aria-busy","false"),M.setAttribute("role","status"),z.setAttribute("role","alert"),z.hidden=!0,Q.type=I.type=Z.type="button",S.append(Q,U,M,z,Z,I),c.append(E,re,S),t.append(c);let we=jn,W=fn(we),le="",L=(m.documentElement.lang||"").startsWith("zh"),i,a="",s;for(let e of[Q,U,Z,I])$e(e,()=>W.focus);function q(){let e=L?"\u5173\u95ED":"Close";I.parentElement===N?(I.textContent="\xD7",I.setAttribute("aria-label",e),Gn(I,we)):(I.textContent=e,I.removeAttribute("aria-label"),I.style.cssText=W.link+";margin-inline-start:auto")}function f(e){let r=e?.screen?.content.document.theme??we,d=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,I.parentElement===N]);if(d===le)return;le=d,we=r;let H=I.parentElement===N;W=fn(we,H),c.style.cssText=W.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),S.style.cssText=W.bar+(H?";margin-top:auto":""),S.hidden&&(S.style.display="none"),Q.style.cssText=U.style.cssText=W.secondary,Z.style.cssText=W.primary,M.style.cssText=W.status,z.style.cssText=W.alert,q(),mn(Q)}function p(){S.hidden=Q.hidden&&U.hidden&&Z.hidden&&z.hidden&&!M.textContent&&(I.hidden||I.parentElement!==S),S.style.display=S.hidden?"none":"flex",i?.responsive&&s!==void 0&&i.setContentHeight(s+S.getBoundingClientRect().height)}f();let F=null,y=null,Y=null,X="",j="",ge=!1,xe="",on="",Ge="",h=!1,ue=0,Qe=!1,hn="",sn=null,an=Promise.resolve(),gn=!n.client.view,J=P,Ae,Le,ze="",Je,pe=!1,De=null,ve=!1,je=()=>n.client.pendingCommand?.operation==="close",fe=null,K=null,vn=Mn({document:m,run:async()=>{(!y?.observing||n.client.pendingCommand)&&await un()},delay:()=>{if(!me.pending&&!(h||!Y||!["running","waiting"].includes(Y.status)&&!n.client.pendingCommand)&&!(y?.observing&&!n.client.pendingCommand))return Y.pendingRequest||n.client.pendingCommand?1500:yn},hiddenDelay:()=>!h&&!me.pending&&n.client.pendingCommand?15e3:void 0}),ne=null;function ln(){return K&&n.client.hasDurableJournal===!0&&ne?.acknowledged===!0&&ne.operationId===K.operationId&&n.client.view?.id===ne.runId&&n.client.view?.status==="closed"&&n.client.view.revision===ne.revision+1&&!(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0))&&!n.client.pendingPurchase?K:null}function In(e){let r=e.run.paywall;if(ne&&e.settlement?.requestId===ne.requestId&&e.settlement.state==="settled"&&e.settlement.operationId===null&&e.run.id===ne.runId&&e.run.status==="closed"&&!e.run.pendingRequest&&e.run.revision===ne.revision+1&&e.run.nodeId===ne.nodeId&&e.run.visit===ne.visit&&r?.receiptId===ne.receiptId&&r.selectionGeneration===ne.selectionGeneration&&(r.quote?.operationId??null)===ne.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===ne.operationId){let d=ne.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Me({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(d||r.canReselect===!0&&H.type==="native")&&(ne.acknowledged=!0)}}let ke=null,Be=new Set,Ie={},Se=!1,de=(e,r=null)=>{h||(ke=r,Se=!1,z.textContent=Bn(e,L),z.hidden=!1,Z.hidden=n.client.pendingCommand===null,p(),Ee(n.onError,e))},me=Fn({client:n.client,document:m,conceal(){h||(be(),J?.finish("dismissed"),c.hidden=!0,l||(l=!0,_()))},async receive(e){h||await ye(n.client.view??e.run)},failed(e){if(!h){if(!me.pending){ve=!1;let r=n.client.view;r&&ye(r).then(()=>de(e),de);return}Ze(),c.parentElement!==t&&t.append(c),c.hidden=!1,Q.hidden=U.hidden=I.hidden=!0,M.textContent="",f(),de(e,n.client.pendingCommand?.requestId??null)}}}),bn=()=>{h||(ke=null,z.textContent=Yn(L),z.hidden=!1,Z.hidden=!0,p())};function Te(){let e=n.client.view;if(!e)throw new w("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision}}let T=it({client:n.client,doc:m,holder:E,reviewHolder:re,mountScreenPreview:R,loadingOptions:n,get chrome(){return W},get stopped(){return h},get answers(){return Ie},suspend(e){y?.setSuspended(e)},resetScreen(){X="",j="",xe=""},enqueue:ye,fail:de}),He=nt({client:n.client,expected:Te,fail:de,get stopped(){return h},get reviewing(){return T.active},get key(){return X},get busy(){return ue},get staleRead(){return sn}}),We=tt({client:n.client,expected:Te,perform:Ne,onIntent:n.onCustomerDataIntent,get stopped(){return h},get busy(){return ue},get document(){return F?.document},get answers(){return Ie}}),Ye=e=>`${e.id}:${e.nodeId}:${e.visit}`,Fe=e=>e&&(e.screen||e.paywall)?Ye(e):"";function Pe(){let e=n.client.view;Q.disabled=!T.active&&(ue>0||!!n.client.pendingCommand||!e?.canBack||e.stopped||!["running","waiting"].includes(e.status)||!Fe(e)||j!==Fe(e)),Q.hidden=!T.active&&!e?.canBack,mn(Q);let r=!!y&&!T.active;I.hidden=r&&!J?.active||he&&!T.active,U.hidden=!n.client.review||!T.active&&!e?.canBack;let d=e?.locale.startsWith("zh");M.textContent=r?"":ue>0||e?.pendingRequest?d?"\u6B63\u5728\u5904\u7406":"Processing":e?.instruction?.type==="wait"?d?"\u7B49\u5F85\u4E2D":"Waiting":"",p()}async function Cn(e){if(!e)return;let r=n.client.view;await e;let d=n.client.view;if(!r||!d||d.id!==r.id||d.nodeId!==r.nodeId||d.visit!==r.visit||d.stopped||!["running","waiting"].includes(d.status))throw new w("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Ne(e,r=!1,d){if(!((ue||ve||fe||K)&&!r||h||T.active&&!r)){ue++,c.setAttribute("aria-busy","true"),z.hidden=!0,ke=null,Se=!1,Pe();try{if(r||await Cn(He.inFlight),h)return;let H=await e();h||await ye(n.client.view??H.run)}catch(H){d?.(H)&&n.client.pendingCommand===null?bn():me.pending||de(H,n.client.pendingCommand?.requestId??null)}finally{ue=Math.max(0,ue-1),c.setAttribute("aria-busy",String(ue>0)),h||(Z.hidden=n.client.pendingCommand===null,Pe())}}}function Ve(){vn.schedule()}async function un(){if(!(h||Qe||ue)&&!me.pending){if(T.active){await T.open(T.receipt);return}Qe=!0;try{let e=n.client.pendingCommand;e&&n.client.settle&&await n.client.settle(e.requestId);let r=n.client.view,d=We.queries,H=await n.client.get(r?.screen&&Object.keys(d).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:d}:void 0);Se&&!h&&(Se=!1,z.hidden=!0,p()),!h&&d===We.queries&&await ye(n.client.view??H.run)}catch(e){de(e),Se=!h}finally{Qe=!1}}}function Xe(e,r,d){if(J?.active){let ce=J;return ce.setDismissHandler(()=>Pn(ce)),ce}let H=tn(t,n,"funnel",()=>Pn(H),Jn);return J=H,H.start(e,r,d),H}function Pn(e){h||pe||(pe=!0,e.finish("dismissed"),be(),c.hidden=!0,n.client.view?Re().finally(oe):oe())}function dn(){clearTimeout(Je?.timeout),Je=void 0}function be(){he=!1,dn(),Ae?.abort(),Ae=void 0,F?.destroy(),F=null,y?.destroy(),y=null,Le?.(),Le=void 0,N.open&&N.close(),E.replaceChildren(),E.style.cssText="",s=void 0,X="",j="",ge=!1,xe="",Ge=""}function Rn(){let e=m.defaultView;i?.responsive&&e&&F?.resizeViewport?.(e.innerHeight,e.innerWidth)}function Ze(){i?.destroy(),i=void 0,a=""}function Ke(e){let r=e.screen?.presentation;if(!r||r.type==="inline"){N.open&&N.close(),Ze(),I.parentElement!==S&&S.append(I),c.parentElement!==t&&t.append(c);for(let ce of["flex","display","flex-direction","justify-content"])E.style.removeProperty(ce);f(e),p();return}c.parentElement!==N&&(N.append(I,c),t.append(N)),E.style.flex="1 0 auto",E.style.display="flex",E.style.flexDirection="column",E.style.justifyContent="center",f(e);let d=e.screen.content.document,H=JSON.stringify([r,le]);if(H!==a){Ze(),a=H;let ce={sm:420,md:640,lg:900},Ce="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";N.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${we.background};color:${we.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ce[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${Ce};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),i=$n(N,{presentation:r,theme:d.theme,pages:d.pages},Rn),i.latch()}p(),N.setAttribute("aria-label",(qe?.screen===e.screen?.content.document.name?qe?.label:void 0)??F?.document?.name??e.screen?.content.document.name??"Funnel")}async function rt(e){if(h||pe)return;if(me.observe(),me.pending){Y=e;return}if(ve&&(je()||["running","waiting"].includes(e.status))||(Y=e,ke&&n.client.pendingCommand?.requestId!==ke&&(z.hidden=!0,ke=null),L=e.locale.startsWith("zh"),U.textContent=L?"\u56DE\u770B":"History",Q.textContent=T.active?L?"\u8FD4\u56DE\u5F53\u524D":"Return to current":L?"\u8FD4\u56DE":"Back",q(),Z.textContent=L?"\u91CD\u8BD5":"Retry",Z.hidden=n.client.pendingCommand===null,Pe(),hn!==`${e.revision}:${e.visit}:${e.status}:${e.stopped}`&&(hn=`${e.revision}:${e.visit}:${e.status}:${e.stopped}`,Ee(n.onState,structuredClone(e))),h||pe))return;if((!e.pendingRequest||ve&&e.status==="closed")&&["closed","ineligible","failed"].includes(e.status)){oe();return}if(e.stopped&&O()){oe();return}if(e.stopped||n.client.configurationReady===!1){T.stop(),o(),be(),J?.finish("skipped"),c.hidden=!0,Ve();return}if(c.hidden=!1,T.active){Ve();return}let r=Fe(e),d=n.client.view;if(d&&d.revision>e.revision&&Fe(d)!==r)return;let H=!e.instruction&&!e.pendingRequest&&e.nodeType==="screen"&&["running","waiting"].includes(e.status);r!==X&&(X&&J?.finish("dismissed"),be(),X=r,Ie={...e.answers},We.reset());let ce=Ye(e);if(ze===ce){c.hidden=!0;return}if(H&&!r){c.hidden=!0;let $=n.prepared?.state==="shown"?null:Xe(!0,e.locale);!h&&!pe&&Je?.key!==ce&&(dn(),Je={key:ce,timeout:setTimeout(()=>{let v=n.client.view;if(h||!$?.active&&n.prepared?.state!=="shown"||!v||Ye(v)!==ce)return;ze=ce;let B=new Error("Funnel screen preparation timed out");$?.finish("error",B),o(),be(),de(B)},_e)}),Ve();return}dn();let ee=$=>{let v=n.client.view;return!h&&!pe&&!De&&!$.aborted&&n.client.configurationReady!==!1&&!!v&&!v.stopped&&!["closed","ineligible","failed"].includes(v.status)&&Fe(v)===r},Ce=($,v)=>{ee(v)&&(ze=r,J?.finish("error",$),be(),c.hidden=!0,de($))};if(r||((e.instruction&&e.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(e.status))&&o(),Ke(e),e.instruction?.type!=="event"&&e.instruction?.type!=="open_url"&&J?.finish("skipped")),e.screen){o();let $=e.screen.content;if(!F){let ae=e.screen.presentation.type!=="inline",G=Xe(ae,e.locale);if(h||pe)return;let te=(Ae=new AbortController).signal;Ke(e),Le=ae?zn(N):rn(c,t),F=R(E,{mode:"live",closeActions:Array.from(new Set([...n.closeActions??[],...$.document.actions.filter(V=>V.type==="event"&&V.close).map(V=>V.id)])),onAuthoredClose(V){ee(te)&&(he=V,Pe())},rendererUrl:n.client.webViewUrl,title:$.document.name,...ae?{hostPresentation:()=>i?.type??e.screen.presentation.type}:{},onResize:V=>{s=V,i?.responsive&&i.setContentHeight(V+S.getBoundingClientRect().height)},onAction(V,k={},Ue={}){if(T.active||!ee(te)||j!==r)return;Ie={...Ie,...Ue};let cn=e.screen?.inputs??[],qn=Object.fromEntries(cn.filter(({variable:Oe})=>Object.hasOwn(Ie,Oe)).map(({variable:Oe})=>[Oe,Ie[Oe]]));if(Xn(cn,qn).length){bn();return}Ne(()=>n.client.submit({operation:"submit",...Te(),input:{type:"screen",output:V,answers:qn,selection:k}}),!1,Oe=>Wn(Oe,cn))},onAnswers:V=>{T.active||!ee(te)||j!==r||(Ie={...Ie,...V})},onCustomerDataIntent:V=>{T.active||!ee(te)||j!==r||We.intent(V).catch(de)},onEscape:()=>{!ee(te)||j!==r||T.active||fe||K||Re()},onError:V=>{let k=new Error(V);j===r?de(k):Ce(k,te)},onRendered:V=>{if(!(!ee(te)||j===r))try{G.present(k=>{Le?.(),Le=void 0,V&&(qe={screen:$.document.name,label:V},N.setAttribute("aria-label",V)),ae&&(N.showModal(),l=!1,i?.responsive&&N.focus({preventScroll:!0}),!k&&n.loading!=="host"&&xn(N,i?.type??e.screen.presentation.type,i?.responsive)),j=r,ge=ae,Pe()}),ee(te)&&He.report(r)}catch(k){Ce(k,te)}}}),Rn()}let v={capabilities:e.screen.capabilities,customerData:e.screen.customerData,parameters:e.parameters,serverInput:{bindings:e.screen.inputs,answers:Ie,values:e.screen.values}},B=JSON.stringify([$,e.locale,v.parameters,e.screen.inputs,e.screen.values]);if(B!==xe)F.update($.document,e.locale,v),xe=B,on=JSON.stringify(v.capabilities),Ge=JSON.stringify(v.customerData);else{let ae=JSON.stringify(v.capabilities);ae!==on&&(F.updateCapabilities(v.capabilities),on=ae),JSON.stringify(v.customerData)!==Ge&&(F.updateCustomerData(v.customerData),Ge=JSON.stringify(v.customerData))}let se=F;if(se)try{await(J?.wait(se.ready)??se.ready)}catch(ae){Ae&&Ce(ae,Ae.signal)}}else if(e.paywall&&!y){let $=e.paywall.resolution,v="document"in $?$.document:null,B=g,se=n.mountPaywallControls,ae=null,G=(Ae=new AbortController).signal,te={loading:"host",signal:G,...se&&{mountControls:k=>se(k,e)},canInteract:()=>ee(G)&&!T.active&&!fe&&!K,beforeAction:async()=>{ue++;try{await Cn(He.settled()),z.hidden=!0,ke=null,Se=!1,p()}finally{ue=Math.max(0,ue-1)}},start:()=>wn(n.client),onObservationChange:Ve,onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resumeCheckout:n.resumeCheckout,allowNewPurchase:n.allowNewPurchase,checkoutNavigation:n.checkoutNavigation,terminateCheckout:n.terminateCheckout,confirmOnHostedCheckout:n.confirmOnHostedCheckout,resolveOfferId:n.resolveOfferId,resolveSubscriptionChange:n.resolveSubscriptionChange,claimCoupon:n.claimCoupon,onEvent:n.onEvent,onOpenUrl:k=>n.onOpenUrl?n.onOpenUrl({receiptId:e.paywall.receiptId,url:k,openIn:"same_window"}):m.defaultView?.location.assign(k),onAction:async k=>{if(T.active)return;let Ue=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:k,answers:{}}});await ye(n.client.view??Ue.run)},onError:k=>{j===r?de(k):Ce(k,G)}},V={quoteError:k=>Ee(n.onError,k),present(k){ee(G)&&(ae?.present(()=>{k(),j=r,ge=!!E.querySelector("dialog[open]"),ge&&(l=!1),Pe()}),ee(G)&&He.report(r))},async closeAction(k){h||T.active||await me.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:k,answers:{}}})},async dismiss(){if(!(h||G.aborted||T.active||fe||K||!ve&&!ee(G))){if(ve=!0,(n.resumeCheckout||n.terminateCheckout)&&lt()){Y=n.client.view,oe();return}await Re()}}};if(B&&se)o();else if(B){let k=await B.adopt(e,{options:te,handoff:V,start:()=>wn(n.client)});k&&ee(G)&&!h?(Ke(e),y=k,J?.active&&J.present(()=>{}),j=r,ge=B.modal,ge&&(l=!1),Pe(),He.report(r),T.active&&y.setSuspended(!0)):(k?.destroy(),o())}if(h||pe)return;if(!y){if(ae=Xe(!0,e.locale,v),h||pe)return;Ke(e);let k=await x(E,te,V).catch(Ue=>(Ce(Ue,G),null));!ee(G)&&!(ve&&!h&&!G.aborted)?k?.host?.destroy():k&&(y=k.host,y?.setSuspended(T.active))}}if(h||pe)return;Pe();let D=e.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Be.has(D.receiptId)){let $=m.createElement("button");$.type="button",$.style.cssText=W.primary,$e($,()=>W.focus),E.style.cssText=W.stage,$.textContent=D.type==="open_url"?`${L?"\u524D\u5F80":"Continue to"} ${new URL(D.url).host}`:L?"\u7EE7\u7EED":"Continue",$.onclick=()=>{let v=Te(),B=D.type==="open_url"&&!n.onOpenUrl&&D.openIn==="new_window"?ot(D.url):null;Ne(async()=>{let se="success";if(D.type==="open_url")if(n.onOpenUrl)try{se=await n.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(G){Ee(n.onError,G),se="failed"}else se=D.openIn==="new_window"&&!B?"failed":"opened";if(D.type==="event"){if(!n.onEvent)throw new w("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(D.event)}if(h||n.client.view?.nodeId!==v.nodeId||n.client.view.visit!==v.visit)throw new w("PRECONDITION_FAILED","The client action visit changed");let ae=await n.client.submit({operation:"submit",...v,input:{type:"client_action",receiptId:D.receiptId,outcome:se}});return Be.add(D.receiptId),D.type==="open_url"&&!n.onOpenUrl&&D.openIn==="same_window"&&m.defaultView?.location.assign(D.url),ae})},J?.active?J.present(()=>E.replaceChildren($)):E.replaceChildren($)}!e.pendingRequest&&e.status==="completed"&&!Be.has(`complete:${e.id}`)&&(Be.add(`complete:${e.id}`),Ee(n.onComplete,structuredClone(e))),Ve()}function ot(e){let r=m.defaultView?.open(e,"_blank")??null;return r&&(r.opener=null),r}function ye(e){return Pe(),an=an.catch(()=>{}).then(async()=>{try{await rt(e)}catch(r){throw J?.active&&(ze=Ye(e),J.finish("error",r),be(),c.hidden=!0),r}}),an}let st=n.client.subscribe(e=>{if(!gn){if(e.stopped&&(ge||O())&&!ve){Y=e,oe();return}!ve&&(e.stopped||n.client.configurationReady===!1||X&&j!==X&&(Fe(e)!==X||["closed","ineligible","failed"].includes(e.status)))&&(be(),J?.finish("dismissed"),c.hidden=!0),ye(e).catch(de)}}),at=n.client.subscribeError?.(e=>{me.pending||de(e)});function lt(){let e=n.client.view,r=e?.paywall;return!!r?.operation&&!!e&&["running","waiting"].includes(e.status)&&Nn(Me({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function Re(e){if(De)return De;if(h||!e&&(fe||K))return Promise.resolve();let r=!e&&je();return!r&&n.client.view&&!["running","waiting"].includes(n.client.view.status)?(Y=n.client.view,oe(),Promise.resolve()):(De=Ne(async()=>{let d=r?await n.client.retry():await(e?n.client.submit.bind(n.client):me.submit)({operation:"close",...e??Te()});return e&&In(d),d},!0).then(()=>{let d=n.client.view;d?.status==="closed"&&!je()&&(Y=d,oe())}).finally(()=>{De=null}),De)}function oe(){ie?.destroy(),!h&&(h=!0,me.destroy(),A(),o(),n.signal?.removeEventListener("abort",oe),u?.removeEventListener("abort",oe),J?.finish("dismissed"),vn.destroy(),st(),at?.(),be(),Ze(),T.stop(),N.remove(),c.remove(),l||_(),Ee(n.onDismiss,Y?structuredClone(Y):null))}Q.onclick=()=>{if(!Q.disabled){if(T.active){T.exit();return}Ne(()=>n.client.submit({operation:"back",...Te()}))}},U.onclick=()=>{T.open()},I.onclick=()=>{J?.active?J.dismiss():fe||Re()},Z.onclick=()=>{me.pending?me.retry().catch(()=>{}):je()?Re():Ne(()=>n.client.retry())},N.addEventListener("cancel",e=>{e.preventDefault(),J?.active?J.dismiss():fe||Re()}),n.signal?.addEventListener("abort",oe,{once:!0}),u?.addEventListener("abort",oe,{once:!0});let en=!1;g&&(A=g.onClose(()=>{h||pe||(pe=!0,J?.finish("dismissed"),be(),c.hidden=!0,n.client.view?Re().finally(oe):en=!0)}));let En={destroy:oe,refresh:un,get recovery(){let e=ln();if(e)return e;if(!h&&!ue&&!ve&&!fe&&y){let r=y.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??K?.operationId??null,requestId:n.client.pendingCommand?.requestId??null}},prepareFallback(){if(fe)return fe;let e=ln();if(e)return Promise.resolve(e);let r=n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??K?.operationId??null,d=()=>({type:"recover",operationId:r,requestId:n.client.pendingCommand?.requestId??null});if(n.client.hasDurableJournal!==!0){let D=y?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:d())}let H=(n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||K&&n.client.view?.status==="closed")||ue||Qe||De||T.active||!y&&!K&&!H)return Promise.resolve(d());let ce=y,ee=(async()=>{try{if(!K&&H){let v=await n.client.retry();return await ye(n.client.view??v.run),d()}if(!K){let v=await ce.prepareFallback();if(v.type!=="native")return v;if(n.client.hasDurableJournal!==!0)return d();K=v}let D=n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[]);if(D.length){let v=D.find(se=>se.operation==="close");if(!v||!ne||v.requestId!==ne.requestId)return d();let B=await n.client.retry();In(B),await ye(n.client.view??B.run)}else{let v=n.client.view,B=v?.paywall;if(!v||!B||B.selectionGeneration===void 0||(B.quote?.operationId??null)!==K.operationId||K.operationId!==null&&B.canReselect!==!0)return d();let se=B.selectionGeneration,ae=await n.client.get();await ye(n.client.view??ae.run);let G=n.client.view,te=G?.paywall;if(!G||!te||!["running","waiting"].includes(G.status)||G.stopped||G.id!==v.id||G.nodeId!==v.nodeId||G.visit!==v.visit||te.receiptId!==B.receiptId||te.selectionGeneration!==se||(te.quote?.operationId??null)!==K.operationId||K.operationId!==null&&te.canReselect!==!0||n.client.pendingPurchase||(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0)))return d();let V=Te();ne={runId:G.id,operationId:K.operationId,revision:V.revision,requestId:V.requestId,nodeId:G.nodeId,visit:G.visit,receiptId:te.receiptId,selectionGeneration:se,acknowledged:!1},await Re(V)}let $=ln();return $?(oe(),$):d()}catch(D){return de(D),d()}})();fe=ee;let Ce=()=>{fe===ee&&(fe=null)};return ee.then(Ce,Ce),ee},review:T.open,exitReview:T.exit,get unappliedDrafts(){return T.drafts}};try{let e=n.client.view;if(e)((n.client.viewAgeMs??yn)>=yn||e.instruction?.type==="evaluate_segment")&&(sn=un().finally(()=>{sn=null})),await ye(e);else{if(c.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=en||n.prepared?.state==="shown"?null:Xe(n.client.view?.screen?.presentation.type!=="inline",n.client.view?.locale);if(h||pe&&!en)throw new DOMException("Presentation cancelled","AbortError");let d=n.client.get(),H=await(r?r.wait(d,_e):ct(d,_e));if(gn=!1,en)return h||await Re().finally(oe),En;await ye(n.client.view??H.run)}}catch(e){throw J?.finish("error",e),oe(),e}return En}function ct(t,b){let P;return Promise.race([t,new Promise((n,g)=>{P=setTimeout(()=>g(new Error("Presentation data timed out")),b)})]).finally(()=>clearTimeout(P))}function Zt(t,b,P){return dt(t,b,P)}export{dt as a,Zt as b};
@@ -1 +0,0 @@
1
- import{b as Q}from"./chunk-YHZXVCE3.js";import{b as N}from"./chunk-GWTNU665.js";import"./chunk-CSLTAXC7.js";import"./chunk-DGZCD3AY.js";import{a as K}from"./chunk-LNEBSVA7.js";import{b as B}from"./chunk-K3RXO2S3.js";import"./chunk-CEYUJ3LO.js";import"./chunk-W32FI2A2.js";import{i as R,j as J}from"./chunk-7HU7JZVZ.js";import"./chunk-RJY5CUTB.js";import"./chunk-V65FSNYO.js";import"./chunk-VBJTINET.js";import"./chunk-IT5DIE6G.js";import"./chunk-NVF54BDR.js";import"./chunk-ZKGVOJCV.js";import"./chunk-PBZSOTKZ.js";import"./chunk-HLCDAU5A.js";import"./chunk-DCZWNTG2.js";import"./chunk-CALDEF4M.js";import"./chunk-ASL7TJFU.js";import"./chunk-B4AELNLE.js";import"./chunk-AQONMY2H.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import{a as f}from"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-SLUA7ABW.js";import"./chunk-CGAE5OZ3.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import"./chunk-GPJF3T43.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";var b=new WeakMap,C=new WeakMap,H=new WeakSet;function ie(E,e){let s=e.prepared,T=()=>{s&&!H.has(s)&&N(s)?.release()},U=b.get(e.client);if(U)return T(),U;let _=r=>({...r,requestId:r.requestId??crypto.randomUUID()}),p=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,c=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:_(e.start);c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=s&&(c&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))||p&&["preparing","ready"].includes(s.state))?s:void 0;i?H.add(i):T();let d=i&&N(i);d?.claim();let v=Promise.resolve().then(async()=>{let r=!1,y,A,L=!1,q=()=>{},M=()=>{},I,x=!1,O=!1,h,G=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,m=()=>{b.get(e.client)===v&&b.delete(e.client),n.removeEventListener("abort",F),q(),M(),i&&H.delete(i),d?.release()};function V(){if(h)return h;let a=new Promise(w=>h=w);return C.set(e.client,a),a.then(()=>{C.get(e.client)===a&&C.delete(e.client)}),b.get(e.client)===v&&b.delete(e.client),h}let o=J(E,e,"funnel",()=>S(),K);function F(){S()}function S(a=!1){if(!r){if(r=!0,o.finish("dismissed"),y){y.destroy();return}if(a&&I){let w=V();G=!0,I.then(async P=>{P.mode==="run"&&P.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{w(),u(e.onDismiss,null)}),m();return}m(),u(e.onDismiss,null)}}n.addEventListener("abort",F,{once:!0}),d&&(M=d.onClose(()=>{x?r||V():S(!0)}));try{let k=function(){!r&&!n.aborted&&!L&&A&&e.client.recovery.status==="complete"&&(L=!0,u(e.onComplete,structuredClone(A)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):E.ownerDocument.defaultView?.location.assign(t)};var X=k,Y=D;n.throwIfAborted();let a=e.client.controller?.view?.paywall?.resolution,w=a&&"document"in a?a.document:e.loadingDocument;o.start(!0,c?.locale??e.client.attempt?.locale??w?.screen.strings.defaultLocale,w??null);let P=p?o.wait(p.then(t=>t?_(t):null,()=>null),R):Promise.resolve(c??null);P.catch(()=>{}),i?.state==="shown"?(O=!0,o.present(()=>{})):i&&["preparing","ready"].includes(i.state)&&Promise.all([i.ready,P.catch(()=>null)]).then(([t,l])=>{if(t){if(r||!o.active||!l||!i.matches(l)||!d?.revealable)return d?.release();o.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let W=C.get(e.client);if(W&&await o.wait(W),r)return null;if(n.throwIfAborted(),p){let t=await P;if(r)return null;if(n.throwIfAborted(),!t)return o.finish("skipped"),m(),null;c=t}I=c?e.client.start(c):e.client.refresh();let j=await o.wait(I,R);if(r)return null;n.throwIfAborted();let z=e.client.controller;return j.mode!=="run"||j.status==="blocked"||!z?(o.finish("skipped"),m(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",F),x=!0,q=e.client.subscribe(k),y=await Q(E,{...e,prepared:i,client:z,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let l=e.client.recovery;if((!l.actions.includes("continue_checkout")||!l.purchases.some(g=>g.type==="checkout"&&g.checkoutUrl===t))&&(l=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(B(l)!==t)throw new f("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let l=e.client.attempt;if(!l)throw new f("PURCHASE_PENDING","Read the original Start before selecting an offer");let g=await e.resolveOfferId?.(t,l);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==l.requestId)throw new f("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return g},async resolveSubscriptionChange(t){n.throwIfAborted();let l=e.client.attempt;if(r||!l)throw new f("PURCHASE_PENDING","Read the original Start before selecting a membership");let g=await e.resolveSubscriptionChange?.(t);if(n.throwIfAborted(),r||e.client.attempt?.requestId!==l.requestId)throw new f("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return g},onComplete(t){A=t,k()},onError(t){u(e.onError,t),t instanceof f&&t.status===401&&!n.aborted&&e.client.refresh().catch(l=>u(e.onError,l))},onDismiss(t){r=!0,m(),h?.(),u(e.onDismiss,t)}},o),r||n.aborted?(y.destroy(),null):y)}catch(a){if(G||h?.(),r)return null;throw o.finish("error",a),m(),u(e.onError,a),a}});return b.set(e.client,v),v}export{ie as showFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-GWTNU665.js";import"./chunk-CSLTAXC7.js";import"./chunk-DGZCD3AY.js";import"./chunk-CALDEF4M.js";import"./chunk-ASL7TJFU.js";import"./chunk-AQONMY2H.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-LSVTH3TS.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.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,c}from"./chunk-CSLTAXC7.js";import"./chunk-DGZCD3AY.js";import"./chunk-CALDEF4M.js";import"./chunk-ASL7TJFU.js";import"./chunk-VILB5M4X.js";import"./chunk-3SXPCVIP.js";import"./chunk-GPJF3T43.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as predictFunnelStart,c as predictedPaywallLoadingDocument,b as predictionRefusal};
@@ -1 +0,0 @@
1
- import{a as e,b as o,c as n}from"./chunk-DGZCD3AY.js";import"./chunk-CALDEF4M.js";import"./chunk-ASL7TJFU.js";import"./chunk-VILB5M4X.js";import"./chunk-3SXPCVIP.js";import"./chunk-GPJF3T43.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{e as FUNNEL_ROUTE_LIMITS,o as funnelRouteSchema,n as projectFunnelRoute};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk-YHZXVCE3.js";import"./chunk-GWTNU665.js";import"./chunk-CSLTAXC7.js";import"./chunk-DGZCD3AY.js";import"./chunk-LNEBSVA7.js";import"./chunk-CEYUJ3LO.js";import"./chunk-W32FI2A2.js";import"./chunk-7HU7JZVZ.js";import"./chunk-IT5DIE6G.js";import"./chunk-DCZWNTG2.js";import"./chunk-CALDEF4M.js";import"./chunk-ASL7TJFU.js";import"./chunk-B4AELNLE.js";import"./chunk-AQONMY2H.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-SLUA7ABW.js";import"./chunk-CGAE5OZ3.js";import"./chunk-5GFH7YB3.js";import"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
@@ -1 +0,0 @@
1
- import{O as r,P as m,i as e}from"./chunk-5TJISOWN.js";import"./chunk-LSVTH3TS.js";import"./chunk-5JRBCW6V.js";import"./chunk-6XRXHFM6.js";import"./chunk-GPJF3T43.js";import"./chunk-WPFTSHP2.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-MEDW4N3F.js";import"./chunk-LZ3OJYBY.js";import"./chunk-AV2WZSII.js";import"./chunk-PBZSOTKZ.js";import"./chunk-HLCDAU5A.js";import"./chunk-DCZWNTG2.js";import"./chunk-ASL7TJFU.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-FTGRTYBL.js";import"./chunk-LSVTH3TS.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import"./chunk-6XRXHFM6.js";import"./chunk-GPJF3T43.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{b as a}from"./chunk-ZKGVOJCV.js";import"./chunk-PBZSOTKZ.js";import"./chunk-HLCDAU5A.js";import"./chunk-DCZWNTG2.js";import"./chunk-ASL7TJFU.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import"./chunk-GPJF3T43.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-NZ2DB72P.js";import"./chunk-MEDW4N3F.js";import"./chunk-LZ3OJYBY.js";import"./chunk-NVF54BDR.js";import"./chunk-AV2WZSII.js";import"./chunk-MPD3UIY4.js";import"./chunk-ZKGVOJCV.js";import"./chunk-PBZSOTKZ.js";import"./chunk-HLCDAU5A.js";import"./chunk-DCZWNTG2.js";import"./chunk-ASL7TJFU.js";import"./chunk-B4AELNLE.js";import"./chunk-AQONMY2H.js";import"./chunk-RDUKCMST.js";import"./chunk-KP4QI4RX.js";import"./chunk-5TJISOWN.js";import"./chunk-VILB5M4X.js";import"./chunk-FTGRTYBL.js";import"./chunk-OTNH77B2.js";import"./chunk-LSVTH3TS.js";import"./chunk-7MYS52FL.js";import"./chunk-MWICFZUF.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-3SXPCVIP.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-3VUPVXAV.js";import"./chunk-5GFH7YB3.js";import"./chunk-GPJF3T43.js";import"./chunk-DSPLGTQI.js";import"./chunk-C4NG6RVA.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};