@tinkerlandai/longplay-sdk 0.10.64 → 0.10.66

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 (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +14 -1
  3. package/README.zh-CN.md +1 -1
  4. package/dist/check-response-WOTPYNDN.js +1 -0
  5. package/dist/{chunk-EB7MIZ4T.js → chunk-3Q3DZEP3.js} +1 -1
  6. package/dist/{chunk-R4CYPCBI.js → chunk-45MWDZ42.js} +1 -1
  7. package/dist/{chunk-TK3WOD2O.js → chunk-46USIMCJ.js} +1 -1
  8. package/dist/{chunk-ZCJEXNJD.js → chunk-47FCHF3Y.js} +1 -1
  9. package/dist/{chunk-ZRGL2CAP.js → chunk-56YCOGQZ.js} +1 -1
  10. package/dist/{chunk-S5RM3VO6.js → chunk-5WFI36LF.js} +1 -1
  11. package/dist/{chunk-77O2O552.js → chunk-74T76RE4.js} +1 -1
  12. package/dist/{chunk-5ZD3BY5R.js → chunk-7D5462NE.js} +1 -1
  13. package/dist/{chunk-HUYKZH3H.js → chunk-7EENIOSJ.js} +1 -1
  14. package/dist/chunk-7NKBMAOB.js +1 -0
  15. package/dist/{chunk-FQMZY5VP.js → chunk-7OJIW75D.js} +1 -1
  16. package/dist/{chunk-QXDLOPZK.js → chunk-A22QPPNY.js} +1 -1
  17. package/dist/{chunk-EKUDMQXT.js → chunk-AD35L6BX.js} +1 -1
  18. package/dist/{chunk-KOJI7IH6.js → chunk-C5FSL4XH.js} +2 -2
  19. package/dist/{chunk-PGLBFTRK.js → chunk-DCMA7W7N.js} +1 -1
  20. package/dist/{chunk-C3HZCZVJ.js → chunk-E3FUZSTM.js} +1 -1
  21. package/dist/{chunk-FDWFBCXV.js → chunk-EYTP23EK.js} +1 -1
  22. package/dist/{chunk-32AEJKJW.js → chunk-FUP5JVDE.js} +1 -1
  23. package/dist/{chunk-EE6QNOCL.js → chunk-G2OLUFYT.js} +1 -1
  24. package/dist/{chunk-PJHTN5NJ.js → chunk-GE6RSO2C.js} +1 -1
  25. package/dist/{chunk-7N765ZES.js → chunk-HT5SLWWG.js} +1 -1
  26. package/dist/{chunk-7STWC4L4.js → chunk-IGE2UMXG.js} +1 -1
  27. package/dist/{chunk-5LNX7MHO.js → chunk-JBN6ADWQ.js} +1 -1
  28. package/dist/{chunk-IM5OXTEH.js → chunk-K675GO7R.js} +1 -1
  29. package/dist/{chunk-NDNHTG5B.js → chunk-KVLOMX2G.js} +1 -1
  30. package/dist/{chunk-LFEFSEK3.js → chunk-M6MXJHJ5.js} +1 -1
  31. package/dist/{chunk-DBYRJ4QV.js → chunk-MNICOIQ6.js} +1 -1
  32. package/dist/chunk-MUCDKWMP.js +1 -0
  33. package/dist/{chunk-R7CH2XLH.js → chunk-MUP7FNNY.js} +1 -1
  34. package/dist/{chunk-JBSJ3JU2.js → chunk-N5HX3K5J.js} +1 -1
  35. package/dist/{chunk-KTWKDR5L.js → chunk-O5YYORDW.js} +1 -1
  36. package/dist/{chunk-ZYSMQMC5.js → chunk-OFG3SGEX.js} +1 -1
  37. package/dist/{chunk-XCFAKO23.js → chunk-OKPWZZZW.js} +1 -1
  38. package/dist/{chunk-NA6IYWSB.js → chunk-OT55LG4U.js} +1 -1
  39. package/dist/{chunk-JEDRJAJ5.js → chunk-PNX7Y2K3.js} +1 -1
  40. package/dist/{chunk-2KM537QH.js → chunk-PQ4ISW55.js} +1 -1
  41. package/dist/{chunk-VXDVMAS6.js → chunk-Q523TPZM.js} +1 -1
  42. package/dist/{chunk-NAFHQVSX.js → chunk-QPVA644N.js} +1 -1
  43. package/dist/{chunk-YVTXJWTS.js → chunk-RHILCVPZ.js} +1 -1
  44. package/dist/{chunk-2RFI2DEV.js → chunk-RNCUAYLQ.js} +1 -1
  45. package/dist/{chunk-4SI4SQ3C.js → chunk-SAPICYY3.js} +1 -1
  46. package/dist/{chunk-BJW4AXFL.js → chunk-TXVLJFZG.js} +1 -1
  47. package/dist/{chunk-RIEWU4MN.js → chunk-XIBJF5E6.js} +1 -1
  48. package/dist/{chunk-7HJQJG6Z.js → chunk-YA5YKHDE.js} +1 -1
  49. package/dist/{chunk-VNYUL3PV.js → chunk-YUL23NAW.js} +1 -1
  50. package/dist/chunk-ZLSZBGJG.js +1 -0
  51. package/dist/{chunk-4OODZM64.js → chunk-ZWNWVMCH.js} +1 -1
  52. package/dist/{content-N4FPQMWG.js → content-WWME7E27.js} +1 -1
  53. package/dist/funnel-host-purchase-XIGJ7P7M.js +1 -0
  54. package/dist/{funnel-host-recovery-paywall-OJROCEFE.js → funnel-host-recovery-paywall-POMEY6I2.js} +1 -1
  55. package/dist/{funnel-paywall-copies-U3JIYQJ5.js → funnel-paywall-copies-DUZ3YX67.js} +1 -1
  56. package/dist/funnel-paywall-prerender-5NU457SR.js +1 -0
  57. package/dist/funnel-route-prediction-EW3HVH46.js +1 -0
  58. package/dist/funnel-route-source-YVFAFCVG.js +1 -0
  59. package/dist/funnel-runtime-host-J2HWW5IN.js +1 -0
  60. package/dist/index.d.ts +12 -6
  61. package/dist/index.js +1 -1
  62. package/dist/merchant-bridge-contracts-PNRVNTCN.js +1 -0
  63. package/dist/native-shell.js +1 -1
  64. package/dist/openrouter.js +1 -1
  65. package/dist/operation-contracts-6ORJSGYH.js +1 -0
  66. package/dist/page.js +1 -1
  67. package/dist/paywall-YRB7LQUS.js +1 -0
  68. package/dist/paywall-content-QLJIOFR3.js +1 -0
  69. package/dist/paywall-session-Q6ZYXUOU.js +1 -0
  70. package/dist/popup.js +1 -1
  71. package/dist/react-native.js +1 -1
  72. package/dist/screen-renderer-P6U5UBFX.js +1 -0
  73. package/dist/server.js +1 -1
  74. package/dist/visual.js +1 -1
  75. package/package.json +1 -1
  76. package/dist/check-response-K56UEZ6E.js +0 -1
  77. package/dist/chunk-6AHZAXQE.js +0 -1
  78. package/dist/chunk-D4CK3DCQ.js +0 -1
  79. package/dist/chunk-GKNN4T3B.js +0 -1
  80. package/dist/funnel-host-purchase-YWSXBNT6.js +0 -1
  81. package/dist/funnel-paywall-prerender-EMEIQRIH.js +0 -1
  82. package/dist/funnel-route-prediction-XYWNKGQZ.js +0 -1
  83. package/dist/funnel-route-source-4ZVBFNYV.js +0 -1
  84. package/dist/funnel-runtime-host-JUGVP64Q.js +0 -1
  85. package/dist/merchant-bridge-contracts-IZ7ARRRO.js +0 -1
  86. package/dist/operation-contracts-6RQ33K66.js +0 -1
  87. package/dist/paywall-KJ44JWLV.js +0 -1
  88. package/dist/paywall-content-Y5L3WMDS.js +0 -1
  89. package/dist/paywall-session-I6XT22TL.js +0 -1
  90. package/dist/screen-renderer-3YO6EUWD.js +0 -1
  91. /package/dist/{chunk-KOJI7IH6.js.LEGAL.txt → chunk-C5FSL4XH.js.LEGAL.txt} +0 -0
  92. /package/dist/{chunk-PZTWDJHN.js → chunk-YLH3AYCK.js} +0 -0
@@ -1 +1 @@
1
- import"./chunk-7STWC4L4.js";import"./chunk-2RFI2DEV.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import{a as i}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import{b as A}from"./chunk-PZTWDJHN.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-IGE2UMXG.js";import"./chunk-RNCUAYLQ.js";import"./chunk-7D5462NE.js";import"./chunk-7EENIOSJ.js";import{a as i}from"./chunk-46USIMCJ.js";import"./chunk-XIBJF5E6.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import{b as A}from"./chunk-YLH3AYCK.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-QPVA644N.js";import"./chunk-G2OLUFYT.js";import"./chunk-SAPICYY3.js";import"./chunk-TXVLJFZG.js";import"./chunk-FUP5JVDE.js";import"./chunk-AD35L6BX.js";import"./chunk-ZWNWVMCH.js";import"./chunk-3Q3DZEP3.js";import"./chunk-5WFI36LF.js";import"./chunk-MNICOIQ6.js";import"./chunk-VILB5M4X.js";import"./chunk-RNCUAYLQ.js";import"./chunk-7EENIOSJ.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import"./chunk-XIBJF5E6.js";import"./chunk-YLH3AYCK.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{d as o,e as r,f as e,g as f}from"./chunk-KOJI7IH6.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
1
+ import{d as o,e as r,f as e,g as f}from"./chunk-C5FSL4XH.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ZLSZBGJG.js";import"./chunk-A22QPPNY.js";import"./chunk-W32FI2A2.js";import"./chunk-K675GO7R.js";import"./chunk-KVLOMX2G.js";import"./chunk-JBN6ADWQ.js";import"./chunk-ZWNWVMCH.js";import"./chunk-3Q3DZEP3.js";import"./chunk-5WFI36LF.js";import"./chunk-VILB5M4X.js";import"./chunk-7D5462NE.js";import"./chunk-7EENIOSJ.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import"./chunk-46USIMCJ.js";import"./chunk-XIBJF5E6.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showPaywall};
@@ -0,0 +1 @@
1
+ import{b as a}from"./chunk-HT5SLWWG.js";import"./chunk-TXVLJFZG.js";import"./chunk-FUP5JVDE.js";import"./chunk-AD35L6BX.js";import"./chunk-ZWNWVMCH.js";import"./chunk-3Q3DZEP3.js";import"./chunk-5WFI36LF.js";import"./chunk-MNICOIQ6.js";import"./chunk-VILB5M4X.js";import"./chunk-7D5462NE.js";import"./chunk-7EENIOSJ.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import"./chunk-46USIMCJ.js";import"./chunk-XIBJF5E6.js";import"./chunk-3VUPVXAV.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import"./chunk-YLH3AYCK.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-YA5YKHDE.js";import"./chunk-QPVA644N.js";import"./chunk-G2OLUFYT.js";import"./chunk-YUL23NAW.js";import"./chunk-KVLOMX2G.js";import"./chunk-JBN6ADWQ.js";import"./chunk-SAPICYY3.js";import"./chunk-E3FUZSTM.js";import"./chunk-HT5SLWWG.js";import"./chunk-TXVLJFZG.js";import"./chunk-FUP5JVDE.js";import"./chunk-AD35L6BX.js";import"./chunk-ZWNWVMCH.js";import"./chunk-3Q3DZEP3.js";import"./chunk-5WFI36LF.js";import"./chunk-MNICOIQ6.js";import"./chunk-VILB5M4X.js";import"./chunk-RNCUAYLQ.js";import"./chunk-7D5462NE.js";import"./chunk-7EENIOSJ.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import"./chunk-46USIMCJ.js";import"./chunk-XIBJF5E6.js";import"./chunk-3VUPVXAV.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
package/dist/popup.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-2KM537QH.js";import"./chunk-IM5OXTEH.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-PQ4ISW55.js";import"./chunk-K675GO7R.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import"./chunk-46USIMCJ.js";import"./chunk-XIBJF5E6.js";import"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
@@ -1 +1 @@
1
- import{b as S,c as E,d as T}from"./chunk-ZYSMQMC5.js";import"./chunk-77O2O552.js";import{a as A}from"./chunk-7HJQJG6Z.js";import{e as P}from"./chunk-NAFHQVSX.js";import"./chunk-EE6QNOCL.js";import{h as b,i as x,k as L}from"./chunk-LFEFSEK3.js";import{E as C}from"./chunk-YVTXJWTS.js";import"./chunk-ZCJEXNJD.js";import"./chunk-VNYUL3PV.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-4SI4SQ3C.js";import"./chunk-C3HZCZVJ.js";import"./chunk-7N765ZES.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-2RFI2DEV.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as r}from"./chunk-TK3WOD2O.js";import{h as R}from"./chunk-RIEWU4MN.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
1
+ import{b as S,c as E,d as T}from"./chunk-OFG3SGEX.js";import"./chunk-74T76RE4.js";import{a as A}from"./chunk-YA5YKHDE.js";import{e as P}from"./chunk-QPVA644N.js";import"./chunk-G2OLUFYT.js";import{h as b,i as x,k as L}from"./chunk-M6MXJHJ5.js";import{E as C}from"./chunk-RHILCVPZ.js";import"./chunk-47FCHF3Y.js";import"./chunk-YUL23NAW.js";import"./chunk-KVLOMX2G.js";import"./chunk-JBN6ADWQ.js";import"./chunk-SAPICYY3.js";import"./chunk-E3FUZSTM.js";import"./chunk-HT5SLWWG.js";import"./chunk-TXVLJFZG.js";import"./chunk-FUP5JVDE.js";import"./chunk-AD35L6BX.js";import"./chunk-ZWNWVMCH.js";import"./chunk-3Q3DZEP3.js";import"./chunk-5WFI36LF.js";import"./chunk-PNX7Y2K3.js";import"./chunk-MNICOIQ6.js";import"./chunk-VILB5M4X.js";import"./chunk-RNCUAYLQ.js";import"./chunk-7D5462NE.js";import"./chunk-7EENIOSJ.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import{a as r}from"./chunk-46USIMCJ.js";import{h as R}from"./chunk-XIBJF5E6.js";import"./chunk-3VUPVXAV.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-PQ4ISW55.js";import"./chunk-K675GO7R.js";import"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import"./chunk-O5YYORDW.js";import"./chunk-OKPWZZZW.js";import"./chunk-7OJIW75D.js";import"./chunk-46USIMCJ.js";import"./chunk-XIBJF5E6.js";import"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as pn}from"./chunk-D4CK3DCQ.js";import{a as I}from"./chunk-PJHTN5NJ.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-7STWC4L4.js";import{a as xt}from"./chunk-7HJQJG6Z.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-NAFHQVSX.js";import"./chunk-EE6QNOCL.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-LFEFSEK3.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-YVTXJWTS.js";import"./chunk-ZCJEXNJD.js";import{c as h}from"./chunk-VNYUL3PV.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-4SI4SQ3C.js";import{a as Et,b as _e}from"./chunk-C3HZCZVJ.js";import"./chunk-7N765ZES.js";import"./chunk-BJW4AXFL.js";import{e as at}from"./chunk-32AEJKJW.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-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import{A as W,B as oe,C as tt,D as Se,E as ie,G as se,H as Ce,M as j,O as ce,P as nt,R as Ee,S as rt,T as ot,f as Ge,g as je,j as we,r as ze,s as Ke,u as an,v as sn,y as cn,z as X}from"./chunk-S5RM3VO6.js";import{b as Oe}from"./chunk-JEDRJAJ5.js";import{e as ve,i as Ze,l as it}from"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-2RFI2DEV.js";import"./chunk-5ZD3BY5R.js";import{a as Ne,b as Le}from"./chunk-HUYKZH3H.js";import{o as ue}from"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-KTWKDR5L.js";import{c as Ie}from"./chunk-XCFAKO23.js";import{e as Xe,h as We}from"./chunk-FQMZY5VP.js";import{a as c}from"./chunk-TK3WOD2O.js";import{h as Y}from"./chunk-RIEWU4MN.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.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-MUCDKWMP.js";import{a as I}from"./chunk-GE6RSO2C.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-IGE2UMXG.js";import{a as xt}from"./chunk-YA5YKHDE.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-QPVA644N.js";import"./chunk-G2OLUFYT.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-M6MXJHJ5.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-RHILCVPZ.js";import"./chunk-47FCHF3Y.js";import{c as h}from"./chunk-YUL23NAW.js";import"./chunk-KVLOMX2G.js";import"./chunk-JBN6ADWQ.js";import"./chunk-SAPICYY3.js";import{a as Et,b as _e}from"./chunk-E3FUZSTM.js";import"./chunk-HT5SLWWG.js";import"./chunk-TXVLJFZG.js";import{e as at}from"./chunk-FUP5JVDE.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-AD35L6BX.js";import"./chunk-ZWNWVMCH.js";import"./chunk-3Q3DZEP3.js";import{A as W,B as oe,C as tt,D as Se,E as ie,G as se,H as Ce,M as j,O as ce,P as nt,R as Ee,S as rt,T as ot,f as Ge,g as je,j as we,r as ze,s as Ke,u as an,v as sn,y as cn,z as X}from"./chunk-5WFI36LF.js";import{b as Oe}from"./chunk-PNX7Y2K3.js";import{e as ve,i as Ze,l as it}from"./chunk-MNICOIQ6.js";import"./chunk-VILB5M4X.js";import"./chunk-RNCUAYLQ.js";import"./chunk-7D5462NE.js";import{a as Ne,b as Le}from"./chunk-7EENIOSJ.js";import{o as ue}from"./chunk-Q523TPZM.js";import"./chunk-56YCOGQZ.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-O5YYORDW.js";import{c as Ie}from"./chunk-OKPWZZZW.js";import{e as Xe,h as We}from"./chunk-7OJIW75D.js";import{a as c}from"./chunk-46USIMCJ.js";import{h as Y}from"./chunk-XIBJF5E6.js";import"./chunk-3VUPVXAV.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var _t=4,Mt=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results","checkout_termination"],In=u.enum(Mt),ee=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...se.shape,bridgeVersion:u.literal(_t),capabilities:ee(In,Mt.length),checkKinds:ee(u.enum(["access","metered","credit"]),3),preparationActions:ee(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:ee(u.enum(["auto_topup"]),1),nextActionTypes:ee(u.enum(["redirect","authenticate"]),2),resultEvents:ee(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("checkout_termination")&&(!t("operation_status")||!t("billing_records")||!e.billingEvents.includes("purchase.closed"))&&o("capabilities","Checkout termination requires original lookup and purchase.closed"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),K={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe,"purchase.terminate":j},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He,"purchase.terminate":j.extend({outcome:u.enum(["requested","already_paid"])})},Gn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read","purchase.terminate"]);function $(e,n){return u.strictObject({bridgeVersion:u.literal(_t),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[$("bridge.ping",K["bridge.ping"]),$("bridge.describe",K["bridge.describe"]),$("requirement.check",K["requirement.check"]),$("operation.prepare",K["operation.prepare"]),$("benefit.claim",K["benefit.claim"]),$("operation.read",K["operation.read"]),$("purchase.terminate",K["purchase.terminate"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",Q="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
2
2
  ${n}
3
3
  POST
4
4
  ${W}
package/dist/visual.js CHANGED
@@ -1 +1 @@
1
- import{a as pe,c as fe}from"./chunk-OJM6ORHE.js";import{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-KOJI7IH6.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import{b as o}from"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:le(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=se(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=re(e.deviceIdCookie??"indiana_did"),T=ae(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(de(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=oe(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=ue(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=ce(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
1
+ import{a as pe,c as fe}from"./chunk-OJM6ORHE.js";import{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-C5FSL4XH.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-EYTP23EK.js";import"./chunk-5MRSFLQA.js";import{b as o}from"./chunk-YLH3AYCK.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard: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.64",
3
+ "version": "0.10.66",
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-C3HZCZVJ.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-PZTWDJHN.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
@@ -1 +0,0 @@
1
- import{a as mn,c as bn,d as Tt,f as Ot,g as Cn,k as vn}from"./chunk-QXDLOPZK.js";import{a as un,b as ze}from"./chunk-W32FI2A2.js";import{d as dn,e as fn,f as pn,g as hn,i as St,j as it,k as yn,l as wn,m as gn}from"./chunk-IM5OXTEH.js";import{a as on,c as xt,d as sn,e as ln}from"./chunk-NDNHTG5B.js";import{a as rt,b as ae,d as Rt,f as At,j as cn}from"./chunk-5LNX7MHO.js";import{b as Ie}from"./chunk-4OODZM64.js";import{B as N,C as nt,D as Ge,E as De,y as an}from"./chunk-EB7MIZ4T.js";import{r as _e,t as Ue}from"./chunk-VXDVMAS6.js";import{i as rn}from"./chunk-ZRGL2CAP.js";import{c as ge,j as We}from"./chunk-KTWKDR5L.js";import{c as Et}from"./chunk-XCFAKO23.js";import{a as k}from"./chunk-TK3WOD2O.js";import{a as G}from"./chunk-DSPLGTQI.js";async function Pn($,a,E){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=$?We.parse($):null;if(await E.onComplete?.(a),!T||!E.check)return;let j=We.parse(await E.check());if(j.internal_feature_id!==T.internal_feature_id||j.quantity!==T.quantity||T.observation!==void 0&&(j.observation===void 0||j.observation.requirementDigest!==T.observation.requirementDigest||j.observation.authority!==T.observation.authority||Et(j.observation.subject)!==Et(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");j.allowed&&await E.onAccessGranted?.(j)}function kn($){return Object.entries($.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ie(a.product,{},$.capabilities)).map(([a])=>a)}function In($,a){let E=N(a)?void 0:a.lines[0];if(!N(a)&&(a.lines.length!==1||!E))return;let T=N(a)?a.productVersionId:E.productVersionId,{screen:j,buttons:oe}=$.document,U=new Map(N(a)?Object.entries(a.featureQuantities??{}):(E?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function se(b,c){if(b.hidden)return!1;if(b.type==="plan_picker"&&$.capabilities.pickers[b.id]?.options.includes(T))return c[b.id]=T,!0;if(b.type==="quantity_picker"){let te=U.get(b.internalFeatureId);return te!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(c[b.id]=te),!1}if(b.type==="button"&&b.action){let te=oe[b.action];return te?.type==="checkout"&&te.product.type==="fixed"&&te.product.productVersionId===T}if(b.type!=="stack")return!1;let ee=b.interaction,i=b.bind?.plan===T;for(let[te,p]of b.children.entries()){let ne={},D=se(p,ne);if(ee?.type==="toggle"||ee?.type==="tabs"){if(!D)continue;return c[b.id]=ee.type==="toggle"?te===0:p.id,Object.assign(c,ne),!0}Object.assign(c,ne),D&&(i=!0,ee?.type==="select"&&ee.purpose==="product"&&ee.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(c[b.id]=p.id,c[ee.pickerId]=T))}return i}for(let b of j.pages){let c={__page:b.id};if(se(b.root,c))return c}}async function dr($,a,E){let T=a.focusAtReveal?()=>{}:St($.ownerDocument),j=()=>{U.finish("dismissed"),T()},oe=()=>j(),U=yn($,a,"paywall",()=>{j(),G(a.onDismiss)},mn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",oe,{once:!0});let se=null,b,c,ee;try{if(U.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),U.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(se=a.check?We.parse(await U.wait(a.check(),it)):null,se?.allowed)return U.finish("skipped"),a.signal?.removeEventListener("abort",oe),T(),await a.onAccessGranted?.(se),{check:se,host:null};let[e,t]=await Promise.allSettled([U.wait(import("./screen-renderer-3YO6EUWD.js")),U.wait(a.start().then(r=>(U.cancelled&&r.destroy(),r)),it)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;ee=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",oe,{once:!0});let n=b.view??await U.wait(b.refresh(),it);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),c=n}catch(e){throw U.finish("error",e),E?.retainedDialog?.release(),a.signal?.removeEventListener("abort",oe),b?.signal?.removeEventListener("abort",oe),b?.destroy(),T(),e}let i=b,{mountScreenPreview:te}=ee,p=$.ownerDocument,ne=new AbortController,D=p.createElement("section"),pe=p.createElement("div"),F=p.createElement("div"),at=a.mountControls,X=at?p.createElement("div"):void 0,d=p.createElement("p"),h=p.createElement("button"),le=p.createElement("button"),O=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&E?.hostPaywallTarget&&!E.retainedDialog&&c.document.presentation.type==="modal"&&(E.retainedDialog=hn(E.hostPaywallTarget));let ce=E?.retainedDialog,R=ce?.dialog??p.createElement("dialog"),Le=ce&&c.document.presentation.type==="inline"?{type:"modal",size:"md"}:c.document.presentation,re=Le.type==="inline"?F:p.createElement("div"),ot=i.locale||c.document.screen.strings.defaultLocale,o=ot.toLowerCase().startsWith("zh"),En=o?"正在处理…":"Processing…",xn=o?"正在准备报价…":"Preparing your price…",L=bn(c.document.screen.theme);D.dataset.indianaPaywall="",D.setAttribute("aria-label",c.document.name),D.style.cssText=L.root,F.style.cssText=L.controls,d.style.cssText=L.message,d.setAttribute("role","status"),O.style.cssText=L.link,O.textContent=o?"关闭":"Close",h.style.cssText=L.secondary,h.textContent=o?"重试":"Retry",h.hidden=!0,le.type="button",le.style.cssText=L.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(d,le,h),F.append(O),X&&(X.style.cssText="flex:1 0 100%;min-width:0",X.hidden=!0,F.prepend(X)),re!==F&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",D.append(re)),D.append(pe,F);let st=()=>{let e=s=>!s.hidden&&(s!==d||!!d.textContent);if(re!==F&&(re.style.cssText=!ie&&[...re.children].some(e)?`${L.controls};padding:12px 64px 12px 20px;flex-shrink:0`:"display:none;padding:0"),X){let s=!X.childElementCount&&!X.textContent?.trim();X.hidden!==s&&(X.hidden=s)}let t=me??F,n=![...t.children].some(e),r=[...t.children].some(s=>s!==O&&e(s));t.style.cssText=n?L.controls.replace(/padding:[^;]+/,"padding:0"):r?`${L.controls};${L.pinned}`:L.controls,ct()},Nt=typeof MutationObserver>"u"?void 0:new MutationObserver(st);Nt?.observe(D,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Rn=Object.entries(c.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),H,Dt,Me=!1,_t=JSON.stringify(c.capabilities),q;function be(e){let t=kn(e);if(q||he&&!fe||Q&&(C||!Re()||ye))return $e(e).map(({actionId:r})=>r);if(mt()||!C&&Re())return t;let n=C?Ht(e):Qt(e);return[...new Set([...t,...$e(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function Ve(e){if(g)return;let t=c.id!==e.id;c=e;let n=JSON.stringify(e.capabilities);if(t||n!==_t){let r=!P&&!i.quote&&!i.operation?rt(e,z,Mt):z;t||JSON.stringify(r)!==JSON.stringify(z)?(z=r,H?.update(e.document.screen,ot,{capabilities:ae(e),unavailableActions:be(e),serverInput:{bindings:[],answers:{}},selection:z})):H?.updateCapabilities(ae(e),be(e)),_t=n}Sn(e),ve()}let _,lt=0;function Ut(){return(me??F).getBoundingClientRect().height+(re===F?0:re.getBoundingClientRect().height)}function ct(){let e=p.defaultView;if(!_?.responsive||!e)return;let t=me??F,n=e.innerHeight-(_.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",lt=Math.max(1,n-Ut()),H?.resizeViewport?.(lt,e.innerWidth)}let g=!1,he=!1,P=null,ut,Ye=!1,Lt=!1,Ce=!1,dt,ft=!1,ie,me;function An(){return he||g||ie||ft?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:xt(i)}let I=()=>!g&&!Ye&&!ie&&a.canInteract?.()!==!1,Y,Ee=!1,xe=!1,u=null,ue=null,Ke="",de=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),z={},Mt=new Set,fe,C;function pt(e){return!!e&&N(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let ht=o?"正在确认付款…":"Confirming payment…",Q=null,ye,Je,Vt=!1,Re=()=>a.allowNewPurchase!==!1||Vt;function $e(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function $t(e){let t=C?.quote;return t?$e(e).filter(({actionId:n,policy:r})=>Ae(t,e,n,r.product,z)).map(({actionId:n})=>n):[]}function Ht(e){return C?.phase==="payment"?$t(e):[]}function mt(){return(C?C.phase==="payment":!Re())&&(Re()||!!a.prepareUpgradeReplacement)&&de()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&x(i.operation).type==="checkout"}function Qt(e){let t=i.quote;return!de()||Q||!t||!i.operation||x(i.operation).type!=="checkout"?[]:$e(e).filter(({actionId:n,policy:r})=>Ae(t,e,n,r.product,z)).map(({actionId:n})=>n)}function ve(){let e=q?[]:C?Ht(c):Qt(c),t=a.allowNewPurchase===!1&&!!i.operation&&x(i.operation).type==="checkout";if(le.hidden=!!q||(C?C.phase!=="payment":!t)||e.length>0,!de()&&!C||!H?.updateCheckoutControls)return;let n=!q&&C?.phase==="checking"?fe:void 0;H.updateCheckoutControls({actions:$e(c).map(({actionId:r})=>r),resume:n?[n]:e,resumeLabel:n?ht:o?"继续付款":C?"Continue payment":"Continue checkout",busy:fe})}function Bt(){ue?.remove(),ue=null}async function Xe(){if(Q)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||x(r).type==="checkout")throw n;await M(r,!1)}return}let e=await i.read();if(x(e).type!=="checkout")return M(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function yt(){ye?.destroy(),ye=void 0,Je=void 0}function jt(){let e=Q;if(!e||ye)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=un({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ye!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let f=x(s);f.type==="native"?(yt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",h.textContent=o?"继续更换套餐":"Continue changing plans",u=()=>Ze(),h.hidden=!1):(f.type==="complete"||f.type==="fulfillment"||f.type==="recording")&&(yt(),Q=null,h.hidden=!0,await M(s,!1))}});ye=r,Je=async()=>{try{await r.refresh()}finally{ye===r&&(d.textContent=t,h.hidden=!1)}},u=Je,h.textContent=o?"查询结果":"Check result",h.hidden=!1,d.textContent=t,r.schedule()}async function Ze(e=!1){let t=Q;if(!t)return;u=()=>Ze(),C&&(h.textContent=o?"查询状态":"Check status"),h.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=x(r);if(s.type==="native"){if(!Re()&&a.prepareUpgradeReplacement){let f=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;Vt=!0,Ve(f)}Q=null,C&&Se(C.quote),Bt(),P=t.selection,Y=t.coupon,Ee=!1,xe=!1,await Fe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){Q=null,C?await Pe(C.quote,r):await M(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(f){G(a.onError,f)}}if(Date.now()>=n){C&&s.type==="checkout"&&(Q=null,await Pe(C.quote,r));break}await ze(1e3,p,ne.signal)}!Q||g||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",h.hidden=!1):jt())}async function Ft(e,t,n,r){if(u=()=>Ft(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||x(s).type!=="checkout"){u=null,s&&await M(s,!1);return}Q={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",h.hidden=!0);let f=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){Q=null,C&&(u=bt,h.textContent=o?"查询状态":"Check status",h.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",G(a.onError,l);return}f=l instanceof k&&(l.status??0)>=500,G(a.onError,l)}I()&&await Ze(f)}function wt(e,t,n,r,s){let f=ae(e).checkoutCoupons?.[t],l=f?f.products[n]:a.claimCoupon&&s?rn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Sn(e){he||P||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,et=!1;function Ae(e,t,n,r,s,f){let l=N(e),y=!l&&e.lines.length===1?e.lines[0]:void 0,m=Ie(r,s,t.capabilities);if(!m||m!==(l?e.productVersionId:y?.productVersionId))return!1;let A=wt(t,n,m,s,f),K;try{K=Ue(t.document.screen,m,s,t.capabilities)}catch{return!1}if(l){let J=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(K).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(K).every(([Ne,It])=>e.featureQuantities?.[Ne]===It)&&(!A||J?.couponId===A.id&&(!A.offerId||J.grantId===A.offerId))}if((A||ae(t).checkoutCoupons?.[n])&&(A?.id??null)!==(e.discount?.couponId??null))return!1;let Z=Object.fromEntries((y?.prepaid??[]).map(J=>[J.internal_feature_id,J.quantity]));return[...new Set([...Object.keys(K),...Object.keys(Z)])].every(J=>(K[J]??0)===(Z[J]??0))}let x=e=>on({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:g,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=x(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||nt(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Rt)u=null,d.textContent=e.customerMessage(o);else if(Cn(e))u=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Ot(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(u=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!P?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Ot(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";h.hidden=u===null,Ke=d.textContent,t&&fe===void 0&&!_?.responsive&&d.scrollIntoView?.({block:"nearest"}),G(t&&E?.quoteError?E.quoteError:a.onError,e)},Be=new WeakMap;function je(e){he=e,h.disabled=e,le.disabled=e,H?.updateCapabilities?.(ae(c),be(c));for(let t of ue?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Tt(t)}function qt(){q&&(d.textContent=q.message,h.textContent=o?"重试":"Retry",h.disabled=!1,h.hidden=!q.retry,le.disabled=!0)}function gt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function Tn(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Rt?(P=null,Ee=!1,xe=!1,u=null):u=e,t}}async function B(e,t){if(he||g||q)return;if(!I()){gt();return}let n=e===Fe,r=n?xn:En,s=de()&&t!==void 0;fe=s?t:void 0,je(!0),ve(),h.hidden=!0,d.textContent=s?"":r;try{if(e!==Jt&&e!==bt&&e!==Ct&&e!==Je&&(e!==Xe||!a.resumeCheckout)&&await Tn(e),g||q)return;if(!I()){u=e,h.hidden=!1,gt();return}await e()}catch(f){g||we(f,n)}finally{fe=void 0,je(!1),ve(),q?qt():d.textContent===r&&(d.textContent="")}}async function Wt(e){await Pn(se,e,a)}function Se(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(fe??=P?.actionId??$t(c)[0],d.textContent=ht,u=bt,h.textContent=o?"查询状态":"Check status",h.hidden=!0):fe=void 0,H?.updateCapabilities(ae(c),be(c)),ve()}function Gt(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function zt(e,t){At(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function bt(){C&&await Pe(C.quote)}async function Pe(e,t){Se(e,"checking"),Ke="";let n=1e3;Me=!0,G(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!Gt(s))throw s}if(!I())return}if(r){zt(r,e);let s=x(r);if(s.type==="checkout"){Se(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",h.hidden=!1;return}if(s.type==="complete"){Se(e,"complete"),u=null;let f=c.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,y=l?.length===1?l[0].interval:void 0,m=y==="year"?o?"年付":"annual billing":y==="month"?o?"月付":"monthly billing":null;d.textContent=f?o?`已升级到 ${f}${m?" "+m:""}。`:`Upgraded to ${f}${m?" ("+m+")":""}.`:o?"已成功升级。":"Plan upgraded.",await Wt(r);return}if(s.type==="native"&&!De(r)){Se(e),P=null,u=null,d.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",h.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await ze(n,p,ne.signal),n=Math.min(n*1.5,15e3)}}finally{Me=!1,G(a.onObservationChange,!1)}}async function Ct(){let e=C?.quote;if(!e)return;let t=await i.read();if(zt(t,e),x(t).type!=="checkout")return Pe(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function Yt(e){return xt(i).type==="recording"||x(e).type==="recording"}function Kt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:N(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!N(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],f=r===null?ge(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ge(r,e.currency)+(s?_e(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=N(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(y=>y.productName).join(", ");return{label:l?`${l} · ${f}`:f,recurring:s}}async function M(e,t=a.checkoutNavigation!=="after_confirmation"){if(g)return;if(!I()){u=async()=>M(await i.read()),h.hidden=!1;return}let n=e.quote??i.quote;if(pt(n)&&(e.confirmedAt||e.merchantExecution))return Pe(n,e);if(d.textContent=vn(e.status,o),Yt(e)){let m=e.merchantExecution?.recordingStatus==="failed";d.textContent=m?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",h.textContent=o?"查询记录":"Check recording",u=async()=>M(await i.read()),h.hidden=!1;return}if(e.problem&&x(e).type!=="native"){let m=e.problem;u=Te,h.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(m.code,m.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":m.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":m.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":m.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,m));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)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&x(e).type==="complete"){u=null,await Wt(e);return}if(!De(e)&&x(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",h.textContent=o?"查询结果":"Check result",u=async()=>M(await i.read()),h.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),h.textContent=o?"重试":"Retry",u=null,P=null;return}if(!t&&x(e).type==="checkout"){if(Q){jt();return}if(de()){d.textContent="",et=!1,u=null,h.hidden=!0,H?.updateCapabilities?.(ae(c),be(c)),ve();return}let m=i.quote,A=m?.operationId===e.operationId?Kt(m).label:"";d.textContent=et?A?o?`${A} 尚未付款。再次选择该方案即可继续付款。`:`${A} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",et=!1,u=null;return}await Qe(e);let r=Date.now(),s=r+6e5,f=2e3,l=x(e).type!=="checkout",y=()=>l&&Date.now()-r<15e3;Me=!0,G(a.onObservationChange,!0);try{for(;!g&&Date.now()<s;){if(await ze(y()?700:f,p,ne.signal),g)return;if(!I()){u=async()=>M(await i.read()),h.hidden=!1;return}let m=await i.read();if(x(m).type==="checkout"&&(l=!1),!t&&x(m).type==="checkout"){await M(m,!1);return}if(!m.problem&&De(m)&&await Qe(m),!De(m)||m.problem||Yt(m)){await M(m);return}y()||(f=Math.min(f*1.5,3e4))}}finally{Me=!1,G(a.onObservationChange,!1)}u=async()=>M(await i.read()),h.hidden=!1}async function vt(e=!1){let t=await i.read();if(g)return;if(!I()){u=()=>vt(e),h.hidden=!1;return}let n=i.quote;if(n&&At(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(nt(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(nt(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Te():u=null;return}setTimeout(Xt,0,n);return}await M(t,e||void 0)}async function Jt(){await vt()}async function On(e){d.textContent=ht;let t=Date.now()+12e3;for(;!g&&Date.now()<t&&(await ze(1500,p,ne.signal),!(g||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Te(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Bt();let e=i.quote;if(pt(e)){Se(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!Gt(r))throw r;return Pe(e)}return Pe(e,n)}u=Te;let t=await i.confirm();if(!I()){u=Te,h.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await On(t)),t.problem){await M(t);return}if(De(t)){if(x(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:ne.signal})}}u=async()=>M(await i.read()),await M(t,!0)}function Xt(e){if(g)return;ue?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),f=p.createElement("div"),l=p.createElement("p"),y=e.merchantTerms,m=o?"zh-CN":"en",A=y?.subscriptionTerms?.items??[],K=y?y.subscriptionTerms?.trial?.days:N(e)?void 0:e.lines.find(w=>w.trial)?.trial?.days,Z=N(e)?y?y.totalMinor:e.totalMinor:K===void 0?null:y?y.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(w=>w.trial)?0:null,Oe=(w,v)=>o?`${v} 天试用结束后 ${w}`:`Then ${w} after the ${v}-day trial`,{label:J,recurring:Ne}=Kt(e),It=N(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(w=>w.productName).join(", "),tn=Z===null?"":`${o?"今天应付":"Due today"} ${ge(Z,e.currency)}`;l.textContent=tn?[It,tn].filter(Boolean).join(" · "):J,r.textContent=N(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=L.panel,l.style.cssText=L.summary,f.style.cssText=L.actions,r.style.cssText=L.primary,s.style.cssText=L.secondary,Tt(r),r.onclick=()=>{B(Te)};let nn=async()=>{let w=await i.cancel();g||(n.remove(),ue=null,await M(w))};s.onclick=()=>{u=nn,B(nn)};let W=p.createElement("div");if(W.style.cssText=L.terms,N(e)){for(let[v,S]of Object.entries(e.featureQuantities??{})){let V=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Nn=>Nn.internalFeatureId===v),tt=p.createElement("p");tt.textContent=`${V?.name??v} · ${S} ${o?"份":"packs"}${V?` × ${V.terms.units}`:""}`,W.append(tt)}for(let[v,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",y?.discountMinor??e.discountMinor],[o?"税费":"Tax",y?y.taxMinor:e.taxMinor]]){let V=p.createElement("p");V.textContent=`${v}: ${S===null?o?"结账时确认":"Confirmed at checkout":ge(S,e.currency)}`,W.append(V)}let w=p.createElement("p");w.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,W.append(w)}if(y){for(let v of A){if(Z===null&&v===Ne)continue;let S=p.createElement("p"),V=ge(v.amountMinor,e.currency)+_e(v.interval,m,v.intervalCount);S.textContent=Z!==null&&K!==void 0?Oe(V,K):V,v.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ge(v.amountAfterOfferMinor,e.currency)}${_e(v.interval,m,v.intervalCount)}`),W.append(S)}let w=y.subscriptionTerms?.trial;if(w){let v=p.createElement("p");v.textContent=o?`试用 ${w.days} 天;${w.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${w.days}; ${w.cardRequired?"a payment method is required":"no payment method is required"}`,W.append(v)}for(let v of[...y.expectedEffects.map(S=>S.description),...y.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=v,W.append(S)}}else if(!N(e)){for(let w of e.lines){if(Z!==null||w!==Ne){let v=p.createElement("p"),S=`${ge(w.catalogAmountMinor,e.currency)}${_e(w.interval,m,w.intervalCount??1)}`;v.textContent=Z!==null&&w.trial?(e.lines.length>1?`${w.productName} · `:"")+Oe(S,w.trial.days):`${w.productName} · ${S}`,W.append(v)}for(let v of w.prepaid??[]){let S=p.createElement("p"),V=i.view?.capabilities.plans[w.productVersionId]?.prepaid?.find(tt=>tt.internalFeatureId===v.internal_feature_id);S.textContent=`${V?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,V&&(S.textContent+=_e(V.reset==="week"||V.reset==="month"||V.reset==="year"?V.reset:"one_time",m,V.resetCount)),W.append(S)}if(w.trial){let v=p.createElement("p");v.textContent=o?`试用 ${w.trial.days} 天;${w.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${w.trial.days}; ${w.trial.cardRequired?"a payment method is required":"no payment method is required"}`,W.append(v)}}if(!e.charge){let w=p.createElement("p");w.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",W.append(w)}}for(let w of W.children)w.style.margin="0";f.append(r,s),n.append(l,...W.childElementCount?[W]:[],f),F.prepend(n),_?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),ue=n,he&&je(!0),u=null}async function Fe(){if(!P)return;if(u=Fe,!Ee){let n=i.view,r=n?.document.buttons[P.actionId],s=n&&r?.type==="checkout"?Ie(r.product,P.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!xe){let l=await a.resolveSubscriptionChange?.({actionId:P.actionId,productVersionId:s,featureQuantities:Ue(n.document.screen,s,P.selection,n.capabilities)});if(g)return;l!==void 0&&(P.subscriptionChange=an.parse(l)),xe=!0}let f=Y?.offerId;if(Y&&!f){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(Y.id,P.requestId);if(g)return;if(!l||l.couponId!==Y.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw P=null,Y=void 0,u=async()=>{Ve(await i.refresh()),u=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");f=l.id}if(!Y&&!n.document.screen.actions.some(l=>l.id===P?.actionId&&typeof l.properties.couponBinding=="string")&&(f=await a.resolveOfferId?.({actionId:P.actionId,productVersionId:s,featureQuantities:Ue(n.document.screen,s,P.selection,n.capabilities)})),g)return;f!==void 0&&(P.offerId=f),Ee=!0}if(!I()){h.hidden=!1;return}let e;try{e=await i.preview(P)}catch(n){throw i.canReselect===!0&&(P=null,Ee=!1,xe=!1,Y=void 0,u=null),n}if(Y&&(N(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==Y.id||n.grantId!==P.offerId})():e.discount?.couponId!==Y.id||e.discount.offerId!==P.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(g)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!N(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()){if(!I()){h.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let n=fe?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Te()}catch(r){g||we(r)}finally{d.textContent===n&&(d.textContent="")}return}Xt(e)}function ke(e="destroy",t=!1){if(g)return;g=!0;let n=ut;ut=void 0,G(n),a.signal?.removeEventListener("abort",oe),i.signal?.removeEventListener("abort",oe),U.finish("dismissed"),Dt?.(),yt(),ne.abort(),Nt?.disconnect(),H?.destroy(),i.destroy(),R.removeEventListener("cancel",en),O.remove(),D.remove(),t||Zt(),e==="dismiss"&&G(a.onDismiss)}function Zt(){if(_?.destroy(),ce){ce.release();return}R.open&&R.close(),R.remove(),T()}j=ke;async function qe(){if(!Ce||g||Ye||ie==="closing"||!ie&&!I())return;if(!E){ke("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=F.style.cssText,F.replaceWith(me),pe.inert=!0),O.hidden=!1,me.replaceChildren(e,O),ie="closing",O.setAttribute("aria-disabled","true"),O.focus({preventScroll:!0});try{await E.dismiss()}catch(t){g||G(a.onError,t)}g||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",O.textContent=o?"重试关闭":"Retry closing",O.removeAttribute("aria-label"),O.removeAttribute("aria-disabled"))}O.onclick=()=>{qe()};function en(e){e.preventDefault(),qe()}R.addEventListener("cancel",en),le.onclick=()=>{B(C?Ct:Xe)},h.onclick=()=>{if(q){q.retry?.();return}u&&B(u)};function Pt(e){U.finish("error",e),ke()}function kt(){if(!(!Lt||Ce||g||Ye||_&&!I()))try{let e=t=>{a.focusAtReveal&&(T=St(p)),H?.setHidden?.(!1),dt?.(),_&&(R.open||R.showModal(),_.responsive&&R.focus({preventScroll:!0}),!t&&a.loading!=="host"&&fn(R,_.type,_.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),Ce=!0};E?E.present(t=>U.present(n=>e(t??n))):U.present(e)}catch(e){Pt(e),we(e)}}try{if(Le.type==="inline"?(st(),dt=gn(D,$),$.append(D)):(R.setAttribute("aria-label",c.document.name),O.textContent="×",O.setAttribute("aria-label",o?"关闭":"Close"),pn(O,c.document.screen.theme),O.hidden=cn(c.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ce?.content?ce.content.append(O,D):R.replaceChildren(O,D),ce||$.append(R),_=dn(R,{...c.document.screen,presentation:Le},ct),_.latch(),_.responsive&&(D.style.display="flex",D.style.flexDirection="column",D.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ce||(dt=wn(R))),at&&X){let n=at(X);if(typeof n=="function"&&(g?G(n):ut=n),g)throw new DOMException("Presentation cancelled","AbortError");st()}H=te(pe,{mode:"live",rendererUrl:"bundled",title:c.document.name,closeActions:Rn,onAuthoredClose(n){ie||g||(O.hidden=n)},hostPresentation:()=>_?.type??Le.type,reportContentHeight:_?.responsive,onResize:n=>{if(!_?.responsive)return;let r=Math.min(n,lt);pe.style.height=`${r}px`,_.setContentHeight(r+Ut())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof z[r]=="number"&&z[r]!==s&&Mt.add(r);z=n,ve()},onAction(n,r={},s,f){if(!Ce||g||ie)return;let l=i.view,y=l?.document.buttons[n];if(!y)return;if(q){y.type==="close"&&qe();return}if(y.type==="close"&&E&&a.resumeCheckout&&i.operation&&sn(x(i.operation))){qe();return}if(he)return;if(!I()){gt();return}if(y.type==="close"){B(async()=>{E?.closeAction?await E.closeAction(n):await a.onAction?.(n),ke(a.onAction?"action":"dismiss")});return}if(y.type==="action"){u=async()=>{if(y.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(y.action.event)}else a.onOpenUrl?await a.onOpenUrl(y.action.url):p.defaultView?.location.assign(y.action.url);await a.onAction?.(n),u=null},B(u);return}if(de()&&Q){!ye&&Q.selection.actionId===n&&B(()=>Ze(!0),n);return}if(C){if(C.phase==="payment"&&l&&Ae(C.quote,l,n,y.product,r,f)){B(Ct,n);return}if(!mt())return}if(!Re()&&!mt()){de()&&l&&i.quote&&i.operation&&x(i.operation).type==="checkout"&&Ae(i.quote,l,n,y.product,r,f)?B(Xe,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(ue&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",_?.responsive||ue.scrollIntoView?.({block:"nearest"}),ue.querySelector("button")?.focus({preventScroll:!0});return}if(de()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&x(i.operation).type==="checkout"){if(Ae(i.quote,l,n,y.product,r,f)){B(Xe,n);return}let A=Ie(y.product,r,l.capabilities),K;try{if(!A)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");K=Ue(l.document.screen,A,r,l.capabilities)}catch(Ne){we(Ne);return}let Z=i.operation.operationId,Oe={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},J=wt(l,n,A,r,f);B(()=>Ft(Z,Oe,J,{actionId:n,productVersionId:A,selection:Oe.selection,featureQuantities:K}),n);return}if((i.quote||P)&&i.canReselect===!1){let A=!!l&&!!i.quote&&Ae(i.quote,l,n,y.product,r,f);et=!!i.quote&&!A,u=i.quote?()=>vt(A):Fe,B(u);return}let m=l&&Ie(y.product,r,l.capabilities);if(!l||!m){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){u=null,B(async()=>{let A={actionId:n,productVersionId:m,selection:structuredClone(r),featureQuantities:Ue(l.document.screen,m,r,l.capabilities)};ft=!0,await a.onPurchaseIntent(A)});return}if(P&&P.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}P||(Y=wt(l,n,m,r,f),P={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},Ee=!1,xe=!1),B(Fe,n)},onEscape:()=>{qe()},onError:n=>{let r=new Error(n);!Ce&&!g&&Pt(r),we(r)},onRendered:n=>{n&&R.setAttribute("aria-label",n),Lt=!0,kt()}}),H.setHidden?.(!0),ct();let e=de()&&!!i.quote&&!!i.operation&&x(i.operation).type==="checkout";z=i.quote?In(c,i.quote)??rt(c,{}):rt(c,{}),H.update(c.document.screen,ot,{capabilities:ae(c),unavailableActions:be(c),serverInput:{bindings:[],answers:{}},...Object.keys(z).length?{selection:z}:{}}),Dt=i.subscribe?.(Ve),Ve(i.view??c),await U.wait(H.ready);let t=i.operation;(!e||pt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(u=Jt,B(u))}catch(e){throw Pt(e),e}return{check:se,host:{get currentResolution(){return c},setPurchaseRecovery(e,t){q={message:e,retry:t},H?.updateCapabilities?.(ae(c),be(c)),ve(),qt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Me},get recovery(){return An()},async prepareFallback(){if(he||g||ie||ft)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await ln(i);return e.type==="native"&&ke(),e}finally{je(!1)}},setSuspended(e){Ye=e,D.hidden=e,e&&R.open?R.close():!e&&!Ce?kt():!e&&!g&&Ce&&Le.type!=="inline"&&!R.open&&R.showModal()},destroy:ke,retainPurchaseDialog(){if(!(g||!R.open||!R.isConnected))return ke("destroy",!0),{dialog:R,content:ce?.content,release:Zt}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return Ve(e),kt(),e}}}}export{dr as a};
@@ -1 +0,0 @@
1
- import{o as n,r as t}from"./chunk-YVTXJWTS.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +0,0 @@
1
- import{a as ue,b as fe}from"./chunk-JBSJ3JU2.js";import{d as Ee,e as U}from"./chunk-5LNX7MHO.js";import{a as ke}from"./chunk-TK3WOD2O.js";import{a as C}from"./chunk-DSPLGTQI.js";var qe=5*6e4,Le=15e3,_e=new WeakMap;function We(c){return _e.get(c)}var A=c=>Array.isArray(c)?c.map(A):c&&typeof c=="object"?Object.fromEntries(Object.keys(c).sort().map(n=>[n,A(c[n])])):c,O=(c,n)=>JSON.stringify(A(c))===JSON.stringify(A(n)),pe=c=>JSON.stringify(A([c.funnelId,c.locale??null,c.parameters??{}])),Te=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","beforeCheckoutReplacement","purchaseConfirmation","confirmOnHostedCheckout","resolveOfferId","resolveSubscriptionChange","onOpenUrl","onEvent","onAction","onComplete","onError"];function Ke(c,n){let we=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),g,G="",H=n.start instanceof Promise?void 0:we(n.start),W=e=>e?.parameters?.commerce,K=Promise.resolve(n.start).then(e=>e?we(e):void 0),B=n.maxAgeMs??qe,ye=new AbortController,p=AbortSignal.any([ye.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),X=()=>d("released","aborted"),r="preparing",me,F,$=()=>{},N=0,P=null,b=null,v=null,w=null,y,z,Q,ge=new Map,m=null,x=new Set,R=new Map,Y,he=new Promise(e=>Y=e),M,be=new Promise(e=>M=e),Z,Ve=new Promise(e=>Z=e);function q(e,a){r!==e&&(r=e,me=a,C(n.onState,e))}function De(){p.removeEventListener("abort",X),L(),b?.destroy(),b=null,P?.remove(),P=null,v=null}function d(e,a){["adopted","unavailable","released","closed"].includes(r)||(q(e,a),De(),Y(!1),M(!1),Z(null))}function _(e){r!=="shown"&&d("unavailable",e)}let f,ee=!1,ne=n.client.paywallCopies,ae,Oe=new Promise(e=>ae=e);function re(e){Oe.then(a=>{a&&ne&&ne.write(a,e).catch(()=>{})})}let te=e=>`error:${e?.code??e?.name??"unknown"}`,oe=c.ownerDocument.defaultView,V=!0,Pe=null,k=!1,He=e=>e.storageArea===oe?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),ve=e=>{He(e)&&T()},Fe=n.client.subscribe(()=>T());function L(){V&&(V=!1,oe?.removeEventListener("storage",ve),Fe(),$())}let le=()=>V&&(r==="ready"||r==="preparing");function ie(e){(r==="ready"||r==="preparing")&&d("unavailable",e)}function T(){if(r==="ready"&&Date.now()-N>=B)return L();k=!0,Pe??=(async()=>{for(;k&&g&&le();){k=!1;try{await n.client.retained()==="pending"&&ie("purchase_pending")}catch(e){p.aborted?d("released","aborted"):ie(te(e))}}})().finally(()=>{Pe=null,k&&g&&le()&&T()})}oe?.addEventListener("storage",ve),p.addEventListener("abort",X,{once:!0});let Ie=n.client.findPurchase();Ie.catch(()=>{});let j;function J(e){let a=j?.paywallVersionId??n.paywallVersionId??f?.resolution.id??w?.id,t=JSON.stringify(A([a??null,e])),l=ge.get(t);return l||(l=n.client.readPaywall({paywallVersionId:a,...a?{}:{paywallId:j?.paywallId??n.paywallId},...e}),ge.set(t,l)),l}function E(e,a){let t=Object.values(e.capabilities.plans),l=Object.values(e.document.buttons).some(i=>i.type==="checkout");return l&&t.length===0?!1:a.intent==="subscription_change"&&l?t.some(i=>i.available):t.every(i=>i.available)}function se(e,a){if(w&&!U(e,w))return d("unavailable","paywall_changed"),!1;w=e,Q=a;for(let t of R.keys())C(t,structuredClone(e));return!0}function Se(e,a){if(!(!w||!["preparing","ready","shown"].includes(r))){if(!U(e,w))return _("paywall_changed");if(!E(e,a.commerce))return _("plan_unavailable");se(e,a)}}async function D(){let e=await Ve;if(!e)throw new ke("PURCHASE_PENDING","The purchase did not start; open it again");return e}let Ne={get view(){return m?m.view:w},get signal(){return m?.signal??n.client.identitySignal},get quote(){return m?.quote??null},get operation(){return m?.operation??null},webViewUrl:"bundled",get canReselect(){return m?.canReselect},get recovery(){return m?.recovery},get pendingCancellation(){return m?.pendingCancellation},subscribe(e){return R.set(e,m?.subscribe?.(e)??(()=>{})),()=>{R.get(e)?.(),R.delete(e)}},refresh:async()=>m?m.refresh():structuredClone(w),preview:async e=>(await D()).preview(e),confirm:async()=>(await D()).confirm(),cancel:async()=>(await D()).cancel(),read:async()=>(await D()).read(),destroy(){m?.destroy()}},u={options:{},handoff:{}},Ce={loading:"host",focusAtReveal:!0,signal:n.client.identitySignal,start:async()=>Ne,canInteract:()=>u.options.canInteract?u.options.canInteract():!["unavailable","released","closed"].includes(r),async beforeAction(){let e=r!=="adopted",a=w?.capabilities,t=await D();if(e&&!O(t.view?.capabilities,a))throw new Ee;await u.options.beforeAction?.()}};for(let e of Te)Object.defineProperty(Ce,e,{enumerable:!0,get:()=>u.options[e]});function ce(){r!=="preparing"||!v||!b||!f&&(!g||!O(Q?.commerce,W(g))||Q?.locale!==g.locale)||(q("ready"),Y(!0))}let Ae={present(e){if(u.handoff.present)return u.handoff.present(e);r==="preparing"&&(v=e,N=Date.now(),ce())},async dismiss(){if(u.handoff.dismiss)return u.handoff.dismiss();d("closed");for(let e of[...x])C(e)},async closeAction(e){if(u.handoff.closeAction)return u.handoff.closeAction(e);u.options.onAction?await u.options.onAction(e):await Ae.dismiss()},quoteError(e){u.handoff.quoteError?u.handoff.quoteError(e):C(u.options.onError,e)}};async function xe(){if(n.paywallVersionId||n.paywallId)return{paywallVersionId:n.paywallVersionId,paywallId:n.paywallId};let e=n.configuration;if(!e)return d("unavailable","paywall_missing"),null;let a=await Promise.resolve(n.start).catch(()=>null);if(!a||r!=="preparing")return null;let t=()=>ue(e,{funnelId:a.funnelId,customerId:n.client.customerId,parameters:a.parameters??{}});if(F=await t(),r!=="preparing")return null;let l=F;if(l.type!=="paywall")return d("unavailable",fe(l)??"route"),null;let i=!1;return $=e.subscribe(()=>{i||!le()||(i=!0,t().then(s=>{!(s.type==="unavailable"&&!["funnel_stopped","route_unavailable"].includes(s.reason))&&(s.type!=="paywall"||s.paywallVersionId!==l.paywallVersionId)&&ie("route_changed")}).finally(()=>i=!1))}),V||$(),{paywallVersionId:l.paywallVersionId}}(async()=>{try{let[{showPaywall:e},a]=await Promise.all([import("./paywall-KJ44JWLV.js"),xe()]),t=n.commerce??W(H),l=n.locale??H?.locale,i=a&&t&&l?JSON.stringify(A([a.paywallVersionId??null,a.paywallId??null,{commerce:t,locale:l}])):null;if(ae(i),p.throwIfAborted(),r!=="preparing"||!a)return;if(!t)return d("unavailable","commerce_missing");if(!l)return d("unavailable","locale_missing");j=a;let s={commerce:t,locale:l},h=i?await ne?.read(i).catch(()=>null):null;if(p.throwIfAborted(),r!=="preparing")return;h&&(!H||h.funnelId===H.funnelId)&&E(h.resolution,h.context.commerce)&&(f=h),M(!!f);let o;if(f){let de=f.context;s=de,o=structuredClone(f.resolution),J(de).then(Me=>Se(Me,de),()=>{})}else o=await J(s);if(p.throwIfAborted(),r!=="preparing"||(!E(o,s.commerce)&&n.start instanceof Promise&&!y&&await K,!f&&y&&!O(s,y)&&(s=y,o=await J(s)),p.throwIfAborted(),r!=="preparing"))return;if(!E(o,s.commerce))return d("unavailable","plan_unavailable");if(!se(o,s))return;P=c.ownerDocument.createElement("div"),c.append(P);let S=setTimeout(()=>r==="preparing"&&d("unavailable","timeout"),Le);he.then(()=>clearTimeout(S));let I=await e(P,Ce,Ae);if(!I.host||p.aborted||r!=="preparing"){I.host?.destroy(),d(p.aborted?"released":"unavailable","error");return}b=I.host,ce()}catch(e){d(p.aborted?"released":"unavailable",te(e))}finally{ae(null),M(!1)}})(),K.then(async e=>{let a=s=>{ee||re(null),_(s)};if(!e)return a("gated");let t=e,l=W(t),i=n.commerce??l;if(!O(l&&{...l,intent:void 0},i&&{...i,intent:void 0})||n.locale!==void 0&&t.locale!==n.locale)return a("start_mismatch");if(!l)return a("commerce_missing");y={commerce:l,locale:t.locale},z=t,f&&["preparing","ready","shown"].includes(r)&&(g=t,G=pe(t));try{let s=await Ie,h=s==="pending"?"purchase_pending":s==="found"?"original_purchase":s==="blocked"?"purchase_blocked":void 0;if(h)return a(h);if(!["preparing","ready","shown"].includes(r))return;if(n.configuration&&(n.paywallId||n.paywallVersionId)){let o=await ue(n.configuration,{funnelId:t.funnelId,customerId:n.client.customerId,parameters:t.parameters??{}});p.throwIfAborted();let S=o.type==="unknown"||o.type==="unavailable"&&o.reason!=="funnel_stopped";if(o.type==="paywall"?f?o.paywallId!==f.resolution.paywallId:n.paywallVersionId?o.paywallVersionId!==n.paywallVersionId:o.paywallId!==n.paywallId:!S)return a(fe(o)??"route_changed")}if(V&&(k=!1,await n.client.retained()==="pending"))return a("purchase_pending");if(await be,j||n.paywallId||n.paywallVersionId||w){let o=await J(y);if(p.throwIfAborted(),ee||re(E(o,y.commerce)?{savedAt:Date.now(),funnelId:t.funnelId,context:y,resolution:o}:null),f)Se(o,y);else{if(r!=="preparing")return;if(w){if(!E(o,y.commerce))return d("unavailable","plan_unavailable");if(!se(o,y))return}}}}catch(s){return p.aborted?d("released","aborted"):_(te(s))}["preparing","ready","shown"].includes(r)&&(g=t,G=pe(t),ce(),k&&T())},()=>_("gated"));let Re={get state(){return r},get reason(){return me},ready:he,local:be,get start(){return g},get prediction(){return F?structuredClone(F):void 0},matches:e=>g?pe(e)===G:!!f&&e.funnelId===f.funnelId&&e.locale===f.context.locale,open(){if(r==="preparing")return"pending";if(r!=="ready"||!v)return!1;if(Date.now()-N>=B)return d("unavailable","expired"),!1;let e=v;return v=null,L(),q("shown"),e(),"shown"},destroy(){ye.abort()}};return _e.set(Re,{onClose(e){return r==="closed"?(C(e),()=>{}):(x.add(e),()=>{x.delete(e)})},claim(){L()},remember(e){ee=!0;let a=structuredClone(e);K.then(()=>{!z||!y||re({savedAt:Date.now(),funnelId:z.funnelId,context:y,resolution:a})},()=>{})},async adopt(e,a){let t=e.paywall?.resolution,l=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(r!=="shown"||!b||!w||!t||!l||e.source.id!==g?.funnelId||e.locale!==g?.locale||!O(e.parameters??{},g?.parameters??{})||!["running","waiting"].includes(e.status)||!U(t,w))return null;let i;try{i=await a.start()}catch{return null}if(r!=="shown"||!b)return i.destroy(),null;m=i,u.options=a.options,u.handoff=a.handoff;for(let[o]of R)R.set(o,i.subscribe?.(o)??(()=>{})),i.view&&C(o,structuredClone(i.view));p.removeEventListener("abort",X),q("adopted"),Z(i),x.clear();let s=b,h=P;return b=null,P=null,v=null,new Proxy(s,{get(o,S){return S==="destroy"?()=>{o.destroy(),h?.remove()}:S==="retainPurchaseDialog"?()=>{let I=o.retainPurchaseDialog();if(I)return{dialog:I.dialog,release(){I.release(),h?.remove()}}}:Reflect.get(o,S,o)}})},retainPurchaseDialog(){if(r!=="shown")return;let e=b?.retainPurchaseDialog();if(!e)return;let a=P;return b=null,P=null,d("released"),{dialog:e.dialog,release(){e.release(),a?.remove()}}},get modal(){return w?.document.presentation.type!=="inline"},get revealable(){return r==="ready"&&!!v&&Date.now()-N<B},release(){d("released")}}),Re}export{qe as a,We as b,Ke as c};
@@ -1 +0,0 @@
1
- import{b as ne}from"./chunk-R7CH2XLH.js";import{b as j}from"./chunk-GKNN4T3B.js";import{a as re}from"./chunk-6AHZAXQE.js";import"./chunk-R4CYPCBI.js";import{a as V}from"./chunk-QXDLOPZK.js";import"./chunk-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import{b as te}from"./chunk-NA6IYWSB.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{j as A,k as z}from"./chunk-IM5OXTEH.js";import"./chunk-77O2O552.js";import"./chunk-PJHTN5NJ.js";import"./chunk-YVTXJWTS.js";import"./chunk-ZCJEXNJD.js";import"./chunk-VNYUL3PV.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-7N765ZES.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as C}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var k=new WeakMap,_=new WeakMap,B=new WeakSet;function he(D,e){let P=e.hostPaywallTarget?void 0:e.prepared,J=()=>{e.prepared&&!B.has(e.prepared)&&j(e.prepared)?.release()},K=k.get(e.client);if(K)return J(),K;let Q=n=>({...n,requestId:n.requestId??crypto.randomUUID()}),O=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,m=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:Q(e.start);m&&P?.state==="ready"&&P.matches(m)&&P.open();let f=P&&(m&&(P.state==="preparing"||["shown","closed"].includes(P.state)&&P.matches(m))||O&&["preparing","ready"].includes(P.state))?P:void 0;f?B.add(f):J();let y=f&&j(f);y?.claim();let S=Promise.resolve().then(async()=>{let n=!1,c,p=!1,U,g=0,E,q,X=!1,F=()=>{},Y=()=>{},H,L=!1,M=!1,I,Z=!1,a=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,v=()=>{k.get(e.client)===S&&k.delete(e.client),a.removeEventListener("abort",R),F(),Y(),f&&B.delete(f),y?.release()};function $(){if(I)return I;let t=new Promise(o=>I=o);return _.set(e.client,t),t.then(()=>{_.get(e.client)===t&&_.delete(e.client)}),k.get(e.client)===S&&k.delete(e.client),I}let l=z(D,e,"funnel",()=>b(),V);function R(){b()}function b(t=!1){if(!n){if(n=!0,l.finish("dismissed"),c){c.destroy();return}if(t&&H){let o=$();Z=!0,H.then(async s=>{s.mode==="run"&&s.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===m?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{o(),h(e.onDismiss,null)}),v();return}v(),h(e.onDismiss,null)}}let N={destroy:()=>b(),refresh:()=>E??(p?G():c?.refresh())??Promise.resolve(),get recovery(){return c?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>c?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...t)=>c?.review(...t)??Promise.resolve(),exitReview:(...t)=>c?.exitReview(...t)??Promise.resolve(),get unappliedDrafts(){return c?.unappliedDrafts??new Map}};a.addEventListener("abort",R,{once:!0}),y&&(Y=y.onClose(()=>{L?n||$():b(!0)}));try{a.throwIfAborted();let t=e.client.controller?.view?.paywall?.resolution,o=t&&"document"in t?t.document:e.loadingDocument;l.start(!0,m?.locale??e.client.attempt?.locale??o?.screen.strings.defaultLocale,o??null);let s=O?l.wait(O.then(r=>r?Q(r):null,()=>null),A):Promise.resolve(m??null);s.catch(()=>{}),f?.state==="shown"?(M=!0,l.present(()=>{})):f&&["preparing","ready"].includes(f.state)&&Promise.all([f.ready,s.catch(()=>null)]).then(([r,i])=>{if(r){if(n||!l.active||!i||!f.matches(i)||!y?.revealable)return y?.release();l.present(()=>{f.open()==="shown"?M=!0:y.release()})}});let d=_.get(e.client);if(d&&await l.wait(d),n)return null;if(a.throwIfAborted(),O){let r=await s;if(n)return null;if(a.throwIfAborted(),!r)return l.finish("skipped"),v(),null;m=r}H=m?e.client.start(m):e.client.refresh({reuseRecentRead:!0});let u=await l.wait(H,A);return n?null:(a.throwIfAborted(),await ee(u,l))}catch(t){if(Z||I?.(),n)return null;throw l.finish("error",t),v(),h(e.onError,t),t}function x(t=!1){g++;let o=c;c=void 0,F(),F=()=>{};let s=t?o?.retainPurchaseDialog?.():void 0;return o?.destroy(),a.addEventListener("abort",R,{once:!0}),s}function T(t){p=!0;let o=e.client.attempt?.locale??m?.locale,s=o?.startsWith("zh"),d=t?s?"正在查询原订单…":"Checking your purchase…":s?"暂时无法确认原订单,请重试。":"Could not check your original purchase. Try again.",u=t?void 0:()=>{G()};c?.setPurchaseRecovery?.(d,u)||(c&&x(),l.active||(l=z(D,e,"funnel",()=>b(),V),l.start(!0,o,e.loadingDocument??null)),l.setPurchaseRecovery(d,u))}function G(){if(E)return E;if(n||a.aborted)return Promise.resolve();U??=c?.recoveryPaywall,a.addEventListener("abort",R,{once:!0}),T(!0);let t=Promise.resolve().then(async()=>{try{let s=await l.wait(e.client.refresh(),A);!n&&!a.aborted&&await ee(s,l)}catch(s){!n&&!a.aborted&&(h(e.onError,s),T(!1))}});E=t;let o=()=>{E===t&&(E=void 0)};return t.then(o,o),t}async function ee(t,o){let s=e.client.controller;if(t.mode==="run"&&t.status!=="blocked"&&s)return p&&c&&x(),p=!1,U=void 0,ae(s,o?.active?o:void 0);if(t.mode==="operation"&&t.purchases.length){T(!0);let d=await l.wait(e.client.recoverPurchasePaywall(U).then(u=>((n||a.aborted)&&u?.destroy(),u)),A).catch(u=>(!n&&!a.aborted&&h(e.onError,u),null));if(n||a.aborted)return null;if(d){if(n||a.aborted)return d.destroy(),null;let u=x(!0)??y?.retainPurchaseDialog?.()??l.retainPurchaseDialog();y?.release();let r=await re(D,{signal:a,loading:"host",start:async()=>d,checkoutNavigation:"after_confirmation",allowNewPurchase:!1,resumeCheckout:w=>e.client.continueCheckout(W,w),onError:e.onError,onDismiss:()=>{n||b()}},{retainedDialog:u,present(w){l.active?l.present(w):w(!!u)},async dismiss(){b()}});if(!r.host||n||a.aborted)return r.host?.destroy(),u?.release(),v(),null;let i=r.host;return p=!1,c={destroy(){i.destroy(),v(),h(e.onDismiss,null)},refresh:async()=>{await i.refresh()},get recovery(){return i.recovery},prepareFallback:()=>i.prepareFallback(),review:async()=>{},exitReview:async()=>{},unappliedDrafts:new Map},N}}return t.purchases.length||p?(T(!1),N):(l.finish("skipped"),v(),(M||L)&&(n=!0,h(e.onDismiss,null)),null)}function W(t){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):D.ownerDocument.defaultView?.location.assign(t)}async function ae(t,o){a.removeEventListener("abort",R),L=!0;function s(){!n&&!a.aborted&&!p&&!X&&q&&e.client.recovery.status==="complete"&&(X=!0,h(e.onComplete,structuredClone(q)))}F(),F=e.client.subscribe(s);let d=++g,u=await ne(D,{...e,prepared:f,client:t,signal:a,checkoutNavigation:"after_confirmation",resumeCheckout:r=>e.client.continueCheckout(W,r),terminateCheckout:e.allowNewPurchase===!1?void 0:r=>e.client.terminateCheckout(r),async onCheckoutUrl(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.recovery;if((!i.actions.includes("continue_checkout")||!i.purchases.some(w=>w.type==="checkout"&&w.checkoutUrl===r))&&(i=await e.client.refresh(),a.throwIfAborted(),n))throw new DOMException("Presentation dismissed","AbortError");if(te(i)!==r)throw new C("PURCHASE_PENDING","Checkout differs from the original recovery proof");return W(r)},async resolveOfferId(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.attempt;if(!i)throw new C("PURCHASE_PENDING","Read the original Start before selecting an offer");let w=await e.resolveOfferId?.(r,i);if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==i.requestId)throw new C("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return w},async resolveSubscriptionChange(r){a.throwIfAborted();let i=e.client.attempt;if(n||!i)throw new C("PURCHASE_PENDING","Read the original Start before selecting a membership");let w=await e.resolveSubscriptionChange?.(r);if(a.throwIfAborted(),n||e.client.attempt?.requestId!==i.requestId)throw new C("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return w},onPresentationState(r){d===g&&h(e.onPresentationState,r)},onComplete(r){d===g&&(q=r,s())},onError(r){d===g&&(h(e.onError,r),r instanceof C&&(r.status===401||r.status===409&&r.reason==="STATE_CHANGED"&&r.recovery==="recover_operation")&&!a.aborted&&G().catch(i=>h(e.onError,i)))},onDismiss(r){d===g&&(n=!0,v(),I?.(),h(e.onDismiss,r))}},o);return d!==g||n||a.aborted?(u.destroy(),n||a.aborted?null:N):(c=u,N)}});return k.set(e.client,S),S}export{he as showFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-GKNN4T3B.js";import"./chunk-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import"./chunk-5LNX7MHO.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-HUYKZH3H.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.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-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-FQMZY5VP.js";import"./chunk-PZTWDJHN.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.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-PGLBFTRK.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-FQMZY5VP.js";import"./chunk-PZTWDJHN.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.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-R7CH2XLH.js";import"./chunk-GKNN4T3B.js";import"./chunk-R4CYPCBI.js";import"./chunk-QXDLOPZK.js";import"./chunk-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import"./chunk-IM5OXTEH.js";import"./chunk-ZCJEXNJD.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
@@ -1 +0,0 @@
1
- import{P as r,Q as m,j as e}from"./chunk-S5RM3VO6.js";import"./chunk-HUYKZH3H.js";import"./chunk-XCFAKO23.js";import"./chunk-RIEWU4MN.js";import"./chunk-PZTWDJHN.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
@@ -1 +0,0 @@
1
- import{e as o}from"./chunk-NAFHQVSX.js";import"./chunk-EE6QNOCL.js";import"./chunk-4SI4SQ3C.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-2RFI2DEV.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-RIEWU4MN.js";import"./chunk-PZTWDJHN.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-6AHZAXQE.js";import"./chunk-QXDLOPZK.js";import"./chunk-W32FI2A2.js";import"./chunk-IM5OXTEH.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-VILB5M4X.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showPaywall};
@@ -1 +0,0 @@
1
- import{b as a}from"./chunk-7N765ZES.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-7HJQJG6Z.js";import"./chunk-NAFHQVSX.js";import"./chunk-EE6QNOCL.js";import"./chunk-VNYUL3PV.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-4SI4SQ3C.js";import"./chunk-C3HZCZVJ.js";import"./chunk-7N765ZES.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-2RFI2DEV.js";import"./chunk-5ZD3BY5R.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-3VUPVXAV.js";import"./chunk-FDWFBCXV.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-2KM537QH.js";import"./chunk-IM5OXTEH.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
File without changes