@tinkerlandai/longplay-sdk 0.10.25 → 0.10.26

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 (96) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/THIRD_PARTY_NOTICES.md +26 -0
  3. package/dist/{ai-usage-B6RepnmH.d.ts → ai-usage-E4c9NSJK.d.ts} +1 -1
  4. package/dist/{api-C9P338XT.d.ts → api-BpeJkr6U.d.ts} +390 -390
  5. package/dist/chunk-2KOQBV3Y.js +1 -0
  6. package/dist/chunk-2MTTK3BT.js +1 -0
  7. package/dist/chunk-3FPYCF7Z.js +1 -0
  8. package/dist/chunk-3VUPVXAV.js +1 -0
  9. package/dist/chunk-5RXU57I5.js +1 -0
  10. package/dist/chunk-6VY4PZZ6.js +1 -0
  11. package/dist/chunk-7CFF6SWH.js +1 -0
  12. package/dist/chunk-B5JHPPR4.js +10 -0
  13. package/dist/chunk-BZSKOOMM.js +1 -0
  14. package/dist/chunk-C6JRUYKW.js +1 -0
  15. package/dist/chunk-CILM5XMH.js +1 -0
  16. package/dist/chunk-CNIBGSVO.js +1 -0
  17. package/dist/chunk-CZ3H2X7D.js +1 -0
  18. package/dist/chunk-DCCM7FYR.js +1 -0
  19. package/dist/chunk-DCIGO3NJ.js +1 -0
  20. package/dist/chunk-DOJE7VUR.js +1 -0
  21. package/dist/{chunk-34I23EKZ.js → chunk-ECMWY3G2.js} +1 -1
  22. package/dist/chunk-G7NSECIG.js +1 -0
  23. package/dist/chunk-GIV4FOOW.js +1 -0
  24. package/dist/chunk-HMRIMJ5W.js +1 -0
  25. package/dist/chunk-JAKOBECD.js +1 -0
  26. package/dist/{chunk-O3LZPMS4.js → chunk-KRTX4QEH.js} +1 -1
  27. package/dist/chunk-LPDUK7HT.js +1 -0
  28. package/dist/chunk-MRFBMFNK.js +1 -0
  29. package/dist/chunk-MWDR5FEU.js +1 -0
  30. package/dist/chunk-MYUYN7ZG.js +1 -0
  31. package/dist/chunk-NMKZ724L.js +1 -0
  32. package/dist/chunk-O4KXODTJ.js +17 -0
  33. package/dist/chunk-ORPOCB2J.js +1 -0
  34. package/dist/chunk-PMCGTXGH.js +1 -0
  35. package/dist/{chunk-RKREEPCT.js → chunk-PWQ5BHBJ.js} +1 -1
  36. package/dist/chunk-SMIO7OG5.js +1 -0
  37. package/dist/chunk-T4GTAH43.js +1 -0
  38. package/dist/chunk-UBKD6VMS.js +1 -0
  39. package/dist/chunk-UHI7SPHK.js +1 -0
  40. package/dist/chunk-WM27UTWT.js +62 -0
  41. package/dist/chunk-WOT6VMZA.js +1 -0
  42. package/dist/{chunk-SJNF6JDJ.js → chunk-X7G7JMZ3.js} +1 -1
  43. package/dist/chunk-YSNMXK4R.js +1 -0
  44. package/dist/{configuration-sync-eEFj_oKG.d.ts → configuration-sync-DdTRUv7A.d.ts} +17 -17
  45. package/dist/content-UDP5VQS4.js +1 -0
  46. package/dist/funnel-host-purchase-5NLPYJRK.js +1 -0
  47. package/dist/{funnel-local-client-CSA9XoC4.d.ts → funnel-local-client-DoYVcZ1z.d.ts} +1696 -1696
  48. package/dist/funnel-node-evaluation-COxXtZEQ.d.ts +1003 -0
  49. package/dist/{funnel-process-client-RXgS2i-R.d.ts → funnel-process-client-DtXNiFQ-.d.ts} +1736 -1736
  50. package/dist/funnel-runtime-host-ZWUAGDBU.js +1 -0
  51. package/dist/index.d.ts +70 -69
  52. package/dist/index.js +1 -1
  53. package/dist/merchant-bridge-contracts-N3Q4W6ZU.js +1 -0
  54. package/dist/native-shell.js +1 -1
  55. package/dist/openrouter.d.ts +3 -3
  56. package/dist/openrouter.js +1 -1
  57. package/dist/operation-contracts-VURXKAFX.js +1 -0
  58. package/dist/page.d.ts +12 -12
  59. package/dist/page.js +1 -1
  60. package/dist/paywall-QQ2MC4KO.js +1 -0
  61. package/dist/paywall-session-WC2WFWBQ.js +1 -0
  62. package/dist/popup.d.ts +4 -4
  63. package/dist/popup.js +1 -1
  64. package/dist/react-native.d.ts +8 -8
  65. package/dist/react-native.js +1 -1
  66. package/dist/screen-renderer-G2EWN3WB.js +1 -0
  67. package/dist/server.d.ts +1752 -23
  68. package/dist/server.js +6 -1
  69. package/dist/visual-dom-5LUN4AHO.js +1 -0
  70. package/dist/visual.js +1 -1
  71. package/package.json +1 -1
  72. package/dist/chunk-2KI63SPJ.js +0 -10
  73. package/dist/chunk-2ZJ5CS5Q.js +0 -1
  74. package/dist/chunk-5HJMAZ7A.js +0 -1
  75. package/dist/chunk-7AXCG6NU.js +0 -1
  76. package/dist/chunk-BB5P5HPS.js +0 -1
  77. package/dist/chunk-C2BODHNY.js +0 -1
  78. package/dist/chunk-EIYWDWXP.js +0 -1
  79. package/dist/chunk-LFFBNGXP.js +0 -1
  80. package/dist/chunk-MHEYMXGZ.js +0 -17
  81. package/dist/chunk-ML3BIPM6.js +0 -1
  82. package/dist/chunk-O4535GJR.js +0 -6
  83. package/dist/chunk-OEH47Y2L.js +0 -1
  84. package/dist/chunk-THGLNE4K.js +0 -1
  85. package/dist/chunk-TUYBXAAK.js +0 -1
  86. package/dist/chunk-ZX2RWS3T.js +0 -1
  87. package/dist/content-FD2Q6XD6.js +0 -1
  88. package/dist/funnel-host-purchase-XW7IF52Y.js +0 -1
  89. package/dist/funnel-node-evaluation-Cg-4tcAs.d.ts +0 -2731
  90. package/dist/funnel-runtime-host-I6PJXVRC.js +0 -1
  91. package/dist/paywall-CGBFHFRU.js +0 -1
  92. package/dist/screen-renderer-WOMWOEYL.js +0 -1
  93. package/dist/visual-dom-7IF7ITAK.js +0 -1
  94. package/dist/{coupon-DyKA-BRG.d.ts → coupon-kfkIVf9n.d.ts} +4 -4
  95. package/dist/{presentation-loading-D0A9G_kT.d.ts → presentation-loading-iSaRiDP2.d.ts} +3 -3
  96. package/dist/{screen-DRP7nsrQ.d.ts → screen-CGCJ46b1.d.ts} +3 -3
@@ -1,8 +1,8 @@
1
1
  import { OpenRouter } from '@openrouter/sdk';
2
2
  import { ChatUsage } from '@openrouter/sdk/models';
3
- import { F as FoundationApi } from './api-C9P338XT.js';
4
- import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-B6RepnmH.js';
5
- import './screen-DRP7nsrQ.js';
3
+ import { F as FoundationApi } from './api-BpeJkr6U.js';
4
+ import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-E4c9NSJK.js';
5
+ import './screen-CGCJ46b1.js';
6
6
  import 'zod';
7
7
  import 'zod/v4';
8
8
  import '@ai-sdk/provider';
@@ -1 +1 @@
1
- import"./chunk-ML3BIPM6.js";import"./chunk-5HJMAZ7A.js";import{a as i}from"./chunk-SJNF6JDJ.js";import"./chunk-O4535GJR.js";import"./chunk-MHEYMXGZ.js";import{z as k}from"zod";var c=k.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:A}=await w.read();if(A){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-T4GTAH43.js";import"./chunk-NMKZ724L.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import{a as i}from"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-SMIO7OG5.js";import{b as A}from"./chunk-WM27UTWT.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-6VY4PZZ6.js";import"./chunk-2KOQBV3Y.js";import"./chunk-LPDUK7HT.js";import"./chunk-GIV4FOOW.js";import"./chunk-MYUYN7ZG.js";import"./chunk-C6JRUYKW.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-HMRIMJ5W.js";import"./chunk-NMKZ724L.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-JAKOBECD.js";import"./chunk-WM27UTWT.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
package/dist/page.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { a as ConfigurationSync } from './configuration-sync-eEFj_oKG.js';
1
+ import { a as ConfigurationSync } from './configuration-sync-DdTRUv7A.js';
2
2
  import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
3
3
  import { z } from 'zod';
4
- import './screen-DRP7nsrQ.js';
4
+ import './screen-CGCJ46b1.js';
5
5
 
6
6
  /** GET /api/v1/page-experiments/{environmentId}: page experiments and the saved groups they reference only. */
7
7
  declare const pageExperimentPayloadSchema: z.ZodObject<{
@@ -10,20 +10,13 @@ declare const pageExperimentPayloadSchema: z.ZodObject<{
10
10
  generation: z.ZodString;
11
11
  experiments: z.ZodArray<z.ZodObject<{
12
12
  name: z.ZodOptional<z.ZodString>;
13
- phase: z.ZodOptional<z.ZodString>;
13
+ coverage: z.ZodOptional<z.ZodNumber>;
14
14
  key: z.ZodString;
15
- filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
16
- attribute: z.ZodOptional<z.ZodString>;
17
- seed: z.ZodString;
18
- hashVersion: z.ZodLiteral<2>;
19
- ranges: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
20
- }, z.core.$strict>>>;
21
15
  condition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
22
- force: z.ZodOptional<z.ZodNumber>;
23
- hashAttribute: z.ZodOptional<z.ZodString>;
24
16
  seed: z.ZodOptional<z.ZodString>;
25
17
  hashVersion: z.ZodOptional<z.ZodLiteral<2>>;
26
18
  ranges: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
19
+ force: z.ZodOptional<z.ZodNumber>;
27
20
  urlPatterns: z.ZodOptional<z.ZodArray<z.ZodObject<{
28
21
  include: z.ZodBoolean;
29
22
  type: z.ZodEnum<{
@@ -33,13 +26,20 @@ declare const pageExperimentPayloadSchema: z.ZodObject<{
33
26
  pattern: z.ZodString;
34
27
  }, z.core.$strict>>>;
35
28
  persistQueryString: z.ZodOptional<z.ZodBoolean>;
29
+ hashAttribute: z.ZodOptional<z.ZodString>;
30
+ phase: z.ZodOptional<z.ZodString>;
31
+ filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
32
+ attribute: z.ZodOptional<z.ZodString>;
33
+ seed: z.ZodString;
34
+ hashVersion: z.ZodLiteral<2>;
35
+ ranges: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
36
+ }, z.core.$strict>>>;
36
37
  parentConditions: z.ZodOptional<z.ZodArray<z.ZodObject<{
37
38
  id: z.ZodString;
38
39
  condition: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
39
40
  gate: z.ZodOptional<z.ZodBoolean>;
40
41
  }, z.core.$strict>>>;
41
42
  weights: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
42
- coverage: z.ZodOptional<z.ZodNumber>;
43
43
  fallbackAttribute: z.ZodOptional<z.ZodString>;
44
44
  disableStickyBucketing: z.ZodOptional<z.ZodBoolean>;
45
45
  bucketVersion: z.ZodOptional<z.ZodNumber>;
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{d as o,e as r,f as e,g as f}from"./chunk-O3LZPMS4.js";import"./chunk-OEH47Y2L.js";import"./chunk-2ZJ5CS5Q.js";import"./chunk-O4535GJR.js";import"./chunk-DSPLGTQI.js";import"./chunk-MHEYMXGZ.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-KRTX4QEH.js";import"./chunk-DCIGO3NJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{b as Ye,c as Je}from"./chunk-JGG4R75K.js";import{c as ze,d as He,e as Be,f as de,g as Qe,h as Ge,i as je,k as We}from"./chunk-CNIBGSVO.js";import{a as qe,c as Ae,d as Ve,g as Fe}from"./chunk-PWQ5BHBJ.js";import{b as ee}from"./chunk-HMRIMJ5W.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import{c as Y,o as Z,oa as te,qa as Me}from"./chunk-5RXU57I5.js";import{c as Ie}from"./chunk-DOJE7VUR.js";import{a as A}from"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import{a as z}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function Ke(s,n,v){if(n.status!=="complete")throw new A("INVALID_RESPONSE","A verified completed purchase is required");let g=s?Z.parse(s):null;if(await v.onComplete?.(n),!g||!v.check)return;let y=Z.parse(await v.check());if(y.internal_feature_id!==g.internal_feature_id||y.quantity!==g.quantity||g.observation!==void 0&&(y.observation===void 0||y.observation.requirementDigest!==g.observation.requirementDigest||y.observation.authority!==g.observation.authority||Ie(y.observation.subject)!==Ie(g.observation.subject)))throw new A("INVALID_RESPONSE","The access requirement changed");y.allowed&&await v.onAccessGranted?.(y)}var st={none:0,sm:4,md:8,lg:14,full:9999},ct={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"};function lt(s){let[n,v,g]=[1,3,5].map(y=>{let x=Number.parseInt(s.slice(y,y+2),16)/255;return x<=.03928?x/12.92:((x+.055)/1.055)**2.4});return .2126*n+.7152*v+.0722*g}function Xe(s){let n=lt(s.primary),v=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",g=`color-mix(in srgb, ${s.text} 22%, ${s.background})`,y=`${st[s.radius]}px`,x=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${y};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;background:${s.background};color:${s.text};font:14px/1.5 ${ct[s.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${g};border-radius:${y}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${x};background:${s.primary};color:${v}`,secondary:`${x};background:transparent;color:${s.text};box-shadow:inset 0 0 0 1px ${g}`,link:`${x};background:transparent;color:${s.text};opacity:.72;font-weight:500`}}function Re(s){s.style.opacity=s.disabled?".55":"",s.style.cursor=s.disabled?"not-allowed":"pointer"}function Se(s){return Object.entries(s.document.buttons).filter(([,n])=>n.type==="checkout"&&n.product.type==="fixed"&&!ee(n.product,{},s.capabilities)).map(([n])=>n)}async function Nt(s,n,v){let g=We(s.ownerDocument),y=()=>{C.finish("dismissed"),g()},x=()=>y(),C=Qe(s,n,"paywall",()=>{y(),z(n.onDismiss)});n.signal?.throwIfAborted(),n.signal?.addEventListener("abort",x,{once:!0});let H=null,N,b,Te;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(H=n.check?Z.parse(await C.wait(n.check(),de)):null,H?.allowed)return C.finish("skipped"),n.signal?.removeEventListener("abort",x),g(),await n.onAccessGranted?.(H),{check:H,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-G2EWN3WB.js")),C.wait(n.start().then(d=>(C.cancelled&&d.destroy(),d)),de)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Te=e.value,N=t.value,n.signal?.throwIfAborted(),N.signal?.throwIfAborted(),N.signal?.addEventListener("abort",x,{once:!0});let a=N.view??await C.wait(N.refresh(),de);if(!a)throw new A("INVALID_RESPONSE","Paywall presentation is missing");N.signal?.throwIfAborted(),b=a}catch(e){throw C.finish("error",e),n.signal?.removeEventListener("abort",x),N?.signal?.removeEventListener("abort",x),N?.destroy(),g(),e}let r=N,{mountScreenPreview:Ze}=Te,u=s.ownerDocument,pe=new AbortController,L=u.createElement("section"),fe=u.createElement("div"),M=u.createElement("div"),m=u.createElement("p"),f=u.createElement("button"),P=u.createElement("button"),w=u.createElement("dialog"),i=b.document.screen.strings.defaultLocale.startsWith("zh"),et=i?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",tt=i?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",O=Xe(b.document.screen.theme);L.dataset.indianaPaywall="",L.setAttribute("aria-label",b.document.name),L.style.cssText=O.root,M.style.cssText=O.controls,m.style.cssText=O.message,m.setAttribute("role","status"),P.style.cssText=O.link,P.textContent=i?"\u5173\u95ED":"Close",f.style.cssText=O.secondary,f.textContent=i?"\u91CD\u8BD5":"Retry",f.hidden=!0,M.append(m,f,P),L.append(fe,M);let B=b.document.presentation,Q,Oe,me=!1,De=JSON.stringify(b.capabilities);function he(e){if(p)return;b=e;let t=JSON.stringify(e.capabilities);t!==De&&(Q?.updateCapabilities(e.capabilities,Se(e)),De=t),rt(e)}let R;function Ne(){let e=u.defaultView;R?.responsive&&e&&Q?.resizeViewport?.(e.innerHeight,e.innerWidth)}let p=!1,J=!1,E=null,ne=!1,Le=!1,q=!1,ye,we=!1,$,G;function nt(){return J||p||$||we?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Ae(r)}let S=()=>!p&&!ne&&!$&&n.canInteract?.()!==!1,ge=!1,c=null,U=null;function rt(e){J||E||r.quote||r.operation||(m.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":i?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let be=new Map,re=e=>qe({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:r.canReselect});async function ve(e){let t=e.merchantExecution;if(!(!S()||!e.checkoutUrl||n.checkoutNavigation==="after_confirmation"&&re(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||be.get(e.operationId)===e.checkoutUrl)){be.set(e.operationId,e.checkoutUrl);try{n.onCheckoutUrl?await n.onCheckoutUrl(e.checkoutUrl):u.defaultView?.location.assign(e.checkoutUrl)}catch(a){throw be.delete(e.operationId),a}}}let j=(e,t=!1)=>{if(t){let a=e instanceof A?e.code:void 0;a==="CAPABILITY_UNAVAILABLE"||a==="NOT_CONFIGURED"?(c=null,m.textContent=i?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):a==="COMMAND_PENDING"?m.textContent=i?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":m.textContent=i?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else m.textContent=e instanceof Error?e.message:i?"\u8BF7\u6C42\u5931\u8D25":"Request failed";f.hidden=c===null,t&&m.scrollIntoView?.({block:"nearest"}),z(t&&v?.quoteError?v.quoteError:n.onError,e)},ie=new WeakMap;function oe(e){J=e;for(let t of U?.querySelectorAll("button")??[])e?(ie.set(t,t.disabled),t.disabled=!0):ie.has(t)&&(t.disabled=ie.get(t),ie.delete(t)),Re(t)}function xe(){m.textContent=i?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function it(e){if(n.beforeAction)try{await n.beforeAction()}catch(t){throw c=e,t}}async function _(e){if(J||p)return;if(!S()){xe();return}let t=e===se,a=t?tt:et;oe(!0),f.hidden=!0,m.textContent=a,t&&m.scrollIntoView?.({block:"nearest"});try{if(await it(e),p)return;if(!S()){c=e,f.hidden=!1,xe();return}await e()}catch(d){p||j(d,t)}finally{oe(!1),m.textContent===a&&(m.textContent="")}}async function ot(e){await Ke(H,e,n)}function Ue(e){return Ae(r).type==="recording"||re(e).type==="recording"}async function k(e,t=n.checkoutNavigation!=="after_confirmation"){if(p)return;if(!S()){c=async()=>k(await r.read()),f.hidden=!1;return}if(m.textContent=Je(e.status,i),Ue(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";m.textContent=o?i?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":i?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",f.textContent=i?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",c=async()=>k(await r.read()),f.hidden=!1;return}if(e.problem){let o=e.problem;c=ae,f.textContent=i?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",j(new A(o.code,o.reason==="RESULT_UNKNOWN"?i?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":o.phase==="fulfillment"?i?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":o.code==="CAPABILITY_UNAVAILABLE"?i?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":o.code==="NOT_CONFIGURED"?i?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":i?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,o));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(m.textContent=i?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){c=null,await ot(e);return}if(e.status!=="pending"){if(r.canReselect===!1){m.textContent=i?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",f.textContent=i?"\u67E5\u8BE2\u7ED3\u679C":"Check result",c=async()=>k(await r.read()),f.hidden=!1;return}f.textContent=i?"\u91CD\u8BD5":"Retry",c=null,E=null;return}if(!t&&re(e).type==="checkout"){m.textContent=i?"\u539F\u4ED8\u6B3E\u5C1A\u672A\u5B8C\u6210\uFF0C\u53EF\u7EE7\u7EED\u539F\u6536\u94F6\u53F0\u3002":"Payment is unfinished. Continue the original checkout.",f.textContent=i?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",c=async()=>k(await r.read(),!0),f.hidden=!1;return}await ve(e);let a=Date.now()+6e5,d=2e3;me=!0,z(n.onObservationChange,!0);try{for(;!p&&Date.now()<a;){if(await Ye(d,u,pe.signal),p)return;if(!S()){c=async()=>k(await r.read()),f.hidden=!1;return}let o=await r.read();if(!t&&re(o).type==="checkout"){await k(o,!1);return}if(!o.problem&&o.status==="pending"&&await ve(o),o.status!=="pending"||o.problem||Ue(o)){await k(o);return}d=Math.min(d*1.5,3e4)}}finally{me=!1,z(n.onObservationChange,!1)}c=async()=>k(await r.read()),f.hidden=!1}async function Ce(){let e=await r.read();if(p)return;if(!S()){c=Ce,f.hidden=!1;return}let t=r.quote;if(t&&Fe(e,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&e.status==="pending"&&e.quoteFinalized===!1&&!e.confirmedAt&&!e.checkoutUrl&&!e.nativePurchase&&!e.merchantExecution&&!e.problem&&!r.pendingCancellation){_e(t);return}await k(e)}async function ae(){U?.remove(),U=null,c=ae;let e=await r.confirm();if(!S()){c=ae,f.hidden=!1;return}if(e.problem){await k(e);return}if(e.status==="pending"){if(e.checkoutUrl)await ve(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!n.onPurchase)throw new A("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await n.onPurchase({operation:e,signal:pe.signal})}}c=async()=>k(await r.read()),await k(e,!0)}function _e(e){U?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());m.textContent=t?i?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let a=u.createElement("div"),d=u.createElement("button"),o=u.createElement("button"),V=u.createElement("div"),K=u.createElement("p"),T=e.merchantTerms,ce=T?T.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),le=i?"zh-CN":"en",ue=T?.subscriptionTerms?.items??[],X=T?ue.length===1&&ue[0]?.amountMinor===ce&&ue[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===ce&&e.lines[0];K.textContent=e.lines.map(l=>l.productName).join(", ")+" \xB7 "+(ce===null?i?`${Y(T.subtotalMinor-T.discountMinor,e.currency)} + \u5F85\u786E\u8BA4\u7A0E\u8D39`:`${Y(T.subtotalMinor-T.discountMinor,e.currency)} + tax confirmed at checkout`:Y(ce,e.currency)+(X?te(X.interval,le,X.intervalCount??1):"")),d.textContent=i?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",d.disabled=t,o.textContent=i?"\u53D6\u6D88":"Cancel",a.style.cssText=O.panel,K.style.cssText=O.summary,V.style.cssText=O.actions,d.style.cssText=O.primary,o.style.cssText=O.secondary,Re(d),d.onclick=()=>{_(ae)};let $e=async()=>{let l=await r.cancel();p||(a.remove(),U=null,await k(l))};o.onclick=()=>{c=$e,_($e)};let D=u.createElement("div");if(D.style.cssText=O.terms,T){for(let h of ue){if(h===X)continue;let I=u.createElement("p");I.textContent=Y(h.amountMinor,e.currency)+te(h.interval,le,h.intervalCount),D.append(I)}let l=T.subscriptionTerms?.trial;if(l){let h=u.createElement("p");h.textContent=i?`\u8BD5\u7528 ${l.days} \u5929\uFF1B${l.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${l.days}; ${l.cardRequired?"a payment method is required":"no payment method is required"}`,D.append(h)}for(let h of[...T.expectedEffects.map(I=>I.description),...T.requiredConsents.map(I=>I.summary)]){let I=u.createElement("p");I.textContent=h,D.append(I)}}else{for(let l of e.lines){if(l!==X){let h=u.createElement("p");h.textContent=`${l.productName} \xB7 ${Y(l.catalogAmountMinor,e.currency)}${te(l.interval,le,l.intervalCount??1)}`,D.append(h)}for(let h of l.prepaid??[]){let I=u.createElement("p"),F=r.view?.capabilities.plans[l.productVersionId]?.prepaid?.find(at=>at.internalFeatureId===h.internal_feature_id);I.textContent=`${F?.name??h.internal_feature_id} \xB7 ${h.quantity} ${i?"\u4EFD":"packs"} \xD7 ${h.terms.units}`,F&&(I.textContent+=te(F.reset==="week"||F.reset==="month"||F.reset==="year"?F.reset:"one_time",le,F.resetCount)),D.append(I)}if(l.trial){let h=u.createElement("p");h.textContent=i?`\u8BD5\u7528 ${l.trial.days} \u5929\uFF1B${l.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${l.trial.days}; ${l.trial.cardRequired?"a payment method is required":"no payment method is required"}`,D.append(h)}}if(!e.charge){let l=u.createElement("p");l.textContent=i?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",D.append(l)}}for(let l of D.children)l.style.margin="0";V.append(d,o),a.append(K,...D.childElementCount?[D]:[],V),M.prepend(a),a.scrollIntoView?.({block:"nearest"}),d.focus({preventScroll:!0}),U=a,c=null}async function se(){if(!E)return;if(c=se,!ge){let t=r.view,a=t?.document.buttons[E.actionId],d=t&&a?.type==="checkout"?ee(a.product,E.selection,t.capabilities):null;if(!d)throw new A("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let o=await n.resolveOfferId?.({actionId:E.actionId,productVersionId:d});if(p)return;o!==void 0&&(E.offerId=o),ge=!0}if(!S()){f.hidden=!1;return}let e=await r.preview(E);p||_e(e)}function W(e="destroy"){p||(p=!0,n.signal?.removeEventListener("abort",x),r.signal?.removeEventListener("abort",x),C.finish("dismissed"),Oe?.(),pe.abort(),R?.destroy(),Q?.destroy(),r.destroy(),w.open&&w.close(),w.remove(),L.remove(),g(),e==="dismiss"&&z(n.onDismiss))}y=W;async function Pe(){if(!q||p||ne||$==="closing"||!$&&!S())return;if(!v){W("dismiss");return}let e=u.createElement("p");e.setAttribute("role","status"),e.textContent=i?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",G||(G=u.createElement("div"),G.style.cssText=M.style.cssText,M.replaceWith(G),fe.inert=!0),G.replaceChildren(e,P),$="closing",P.setAttribute("aria-disabled","true"),P.focus({preventScroll:!0});try{await v.dismiss()}catch(t){p||z(n.onError,t)}p||($="retry",e.textContent=i?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",P.textContent=i?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",P.removeAttribute("aria-label"),P.removeAttribute("aria-disabled"))}P.onclick=()=>{Pe()},w.addEventListener("cancel",e=>{e.preventDefault(),Pe()}),f.onclick=()=>{c&&_(c)};function Ee(e){C.finish("error",e),W()}function ke(){if(!(!Le||q||p||ne||R&&!S()))try{let e=t=>{ye?.(),R&&(w.showModal(),R.responsive&&w.focus({preventScroll:!0}),!t&&n.loading!=="host"&&He(w,R.type,R.responsive)),q=!0};v?v.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ee(e),j(e)}}try{if(B.type==="inline")ye=je(L,s),s.append(L);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in B?t[B.size]+"px":"100vw"}`,w.setAttribute("aria-label",b.document.name),P.textContent="\xD7",P.setAttribute("aria-label",i?"\u5173\u95ED":"Close"),Be(P,b.document.screen.theme),w.append(P,L),s.append(w),R=ze(w,{...b.document.screen,presentation:B},Ne),R.latch(),ye=Ge(w)}Q=Ze(fe,{mode:"live",rendererUrl:r.webViewUrl,title:b.document.name,hostPresentation:()=>R?.type??B.type,onResize:t=>{R?.responsive&&R.setContentHeight(t+(G??M).getBoundingClientRect().height)},onAction(t,a={}){if(!q||p||$)return;if(!S()){xe();return}let d=r.view,o=d?.document.buttons[t];if(!o)return;if(o.type==="close"){_(async()=>{await n.onAction?.(t),W(n.onAction?"action":"dismiss")});return}if(o.type==="action"){c=async()=>{if(o.action.type==="event"){if(!n.onEvent)throw new A("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(o.action.event)}else n.onOpenUrl?await n.onOpenUrl(o.action.url):u.defaultView?.location.assign(o.action.url);await n.onAction?.(t),c=null},_(c);return}if(U&&r.canReselect===!1){m.textContent=i?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",U.scrollIntoView?.({block:"nearest"}),U.querySelector("button")?.focus({preventScroll:!0});return}if((r.quote||E)&&r.canReselect===!1){c=r.quote?Ce:se,_(c);return}let V=d&&ee(o.product,a,d.capabilities);if(!d||!V){j(new A("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(n.onPurchaseIntent){c=null,_(async()=>{let K={actionId:t,productVersionId:V,selection:structuredClone(a),featureQuantities:Me(d.document.screen,V,a,d.capabilities)};we=!0,await n.onPurchaseIntent(K)});return}if(E&&E.actionId!==t){j(new A("COMMAND_PENDING","Finish the current purchase"));return}E||(E={requestId:crypto.randomUUID(),actionId:t,selection:a},ge=!1),_(se)},onEscape:()=>{Pe()},onError:t=>{let a=new Error(t);!q&&!p&&Ee(a),j(a)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Le=!0,ke()}}),Ne(),Q.update(b.document.screen,b.document.screen.strings.defaultLocale,{capabilities:b.capabilities,unavailableActions:Se(b),serverInput:{bindings:[],answers:{}}}),Oe=r.subscribe?.(he),he(r.view??b),await C.wait(Q.ready);let e=r.operation;(r.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(c=Ce,_(c))}catch(e){throw Ee(e),e}return{check:H,host:{get observing(){return me},get recovery(){return nt()},async prepareFallback(){if(J||p||$||we)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};oe(!0);try{let e=await Ve(r);return e.type==="native"&&W(),e}finally{oe(!1)}},setSuspended(e){ne=e,L.hidden=e,e&&w.open?w.close():!e&&!q?ke():!e&&!p&&q&&B.type!=="inline"&&!w.open&&w.showModal()},destroy:W,refresh:async()=>{if(!S()){if(r.view)return r.view;throw new A("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return he(e),ke(),e}}}}export{Nt as showPaywall};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-CZ3H2X7D.js";import"./chunk-6VY4PZZ6.js";import"./chunk-2KOQBV3Y.js";import"./chunk-BZSKOOMM.js";import"./chunk-LPDUK7HT.js";import"./chunk-G7NSECIG.js";import"./chunk-GIV4FOOW.js";import"./chunk-MYUYN7ZG.js";import"./chunk-C6JRUYKW.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-PWQ5BHBJ.js";import"./chunk-HMRIMJ5W.js";import"./chunk-NMKZ724L.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
package/dist/popup.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { b as ScreenAction, c as ScreenNode, d as ScreenInteractivity, e as ScreenDocument } from './screen-DRP7nsrQ.js';
2
- import { O as Offer, a as OfferUnavailableReason } from './coupon-DyKA-BRG.js';
3
- import { d as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, e as ScreenParameters, f as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-D0A9G_kT.js';
4
- export { b as PresentationState } from './presentation-loading-D0A9G_kT.js';
1
+ import { b as ScreenAction, c as ScreenNode, d as ScreenInteractivity, e as ScreenDocument } from './screen-CGCJ46b1.js';
2
+ import { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
3
+ import { d as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, e as ScreenParameters, f as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-iSaRiDP2.js';
4
+ export { b as PresentationState } from './presentation-loading-iSaRiDP2.js';
5
5
  import { WindowLike } from 'dompurify';
6
6
  import 'zod';
7
7
 
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-2KI63SPJ.js";import"./chunk-ZX2RWS3T.js";import"./chunk-SJNF6JDJ.js";import"./chunk-DSPLGTQI.js";import"./chunk-MHEYMXGZ.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-B5JHPPR4.js";import"./chunk-CNIBGSVO.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
@@ -1,14 +1,14 @@
1
- import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-RXgS2i-R.js';
2
- export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-RXgS2i-R.js';
3
- import { I as IndianaOptions, d as SessionCredentials, E as Scope, y as createFunnelRunController, u as PaywallStartInput, A as createPaywallSession } from './funnel-local-client-CSA9XoC4.js';
4
- export { c as FunnelCommandStorage, F as FunnelRunController, q as LocalFunnelClientOptions, r as LongplayError, t as PaywallPurchaseInput, P as PaywallSession, v as PushHost, w as PushJournal, x as createFeatureClient, z as createLocalFunnelClient } from './funnel-local-client-CSA9XoC4.js';
1
+ import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-DtXNiFQ-.js';
2
+ export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-DtXNiFQ-.js';
3
+ import { I as IndianaOptions, d as SessionCredentials, E as Scope, z as createFunnelRunController, v as PaywallStartInput, j as createPaywallSession } from './funnel-local-client-DoYVcZ1z.js';
4
+ export { c as FunnelCommandStorage, F as FunnelRunController, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, P as PaywallSession, w as PushHost, x as PushJournal, y as createFeatureClient, A as createLocalFunnelClient } from './funnel-local-client-DoYVcZ1z.js';
5
5
  import { z } from 'zod';
6
6
  import { J as JsonValue } from './growth-rules-B4YYy64R.js';
7
- export { C as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-eEFj_oKG.js';
8
- import './api-C9P338XT.js';
9
- import './screen-DRP7nsrQ.js';
7
+ export { C as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-DdTRUv7A.js';
8
+ import './api-BpeJkr6U.js';
9
+ import './screen-CGCJ46b1.js';
10
10
  import 'zod/v4';
11
- import './coupon-DyKA-BRG.js';
11
+ import './coupon-kfkIVf9n.js';
12
12
 
13
13
  /** The autolinked IndianaBridge module. It accepts Customer credentials only. */
14
14
  interface IndianaReactNativeModule {
@@ -1 +1 @@
1
- import{b as S,c as A,d as T}from"./chunk-BB5P5HPS.js";import"./chunk-THGLNE4K.js";import{c as b,d as E,e as x,g as L}from"./chunk-TUYBXAAK.js";import{q as C}from"./chunk-LFFBNGXP.js";import"./chunk-RKREEPCT.js";import"./chunk-5HJMAZ7A.js";import{a as r}from"./chunk-SJNF6JDJ.js";import"./chunk-2ZJ5CS5Q.js";import{Da as P}from"./chunk-O4535GJR.js";import"./chunk-DSPLGTQI.js";import{a as R}from"./chunk-MHEYMXGZ.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 A({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return E(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-MRFBMFNK.js";import"./chunk-3FPYCF7Z.js";import{a as A}from"./chunk-CZ3H2X7D.js";import{e as P}from"./chunk-6VY4PZZ6.js";import"./chunk-2KOQBV3Y.js";import{h as b,i as x,k as L}from"./chunk-2MTTK3BT.js";import"./chunk-BZSKOOMM.js";import"./chunk-LPDUK7HT.js";import{F as C}from"./chunk-UHI7SPHK.js";import"./chunk-G7NSECIG.js";import"./chunk-GIV4FOOW.js";import"./chunk-MYUYN7ZG.js";import"./chunk-C6JRUYKW.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-PWQ5BHBJ.js";import"./chunk-HMRIMJ5W.js";import"./chunk-NMKZ724L.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import{a as r}from"./chunk-X7G7JMZ3.js";import{h as R}from"./chunk-JAKOBECD.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-B5JHPPR4.js";import"./chunk-CNIBGSVO.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};