@tinkerlandai/longplay-sdk 0.10.40 → 0.10.42

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 (121) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +57 -1
  3. package/README.zh-CN.md +5 -1
  4. package/dist/{ai-usage-DXwAGTxT.d.ts → ai-usage-B-qsCn-k.d.ts} +1 -1
  5. package/dist/{api-r6FfVQpg.d.ts → api-DpRb_Pd3.d.ts} +52 -0
  6. package/dist/check-response-OIBVUP72.js +1 -0
  7. package/dist/chunk-2EVGXJ4R.js +1 -0
  8. package/dist/chunk-3SXPCVIP.js +1 -0
  9. package/dist/chunk-3WTVQ6OV.js +1 -0
  10. package/dist/{chunk-LSPHUA7V.js → chunk-5JRBCW6V.js} +1 -1
  11. package/dist/chunk-5TJISOWN.js +1 -0
  12. package/dist/{chunk-X6ONZGRY.js → chunk-67SIVUOS.js} +1 -1
  13. package/dist/chunk-6XRXHFM6.js +1 -0
  14. package/dist/chunk-7MYS52FL.js +1 -0
  15. package/dist/chunk-ABXCDVC7.js +1 -0
  16. package/dist/{chunk-2DPNSTCN.js → chunk-AC53CUJE.js} +1 -1
  17. package/dist/chunk-ANXDWUPK.js +1 -0
  18. package/dist/chunk-AQONMY2H.js +1 -0
  19. package/dist/chunk-ASL7TJFU.js +1 -0
  20. package/dist/{chunk-ORMQJAQE.js → chunk-AV2WZSII.js} +1 -1
  21. package/dist/chunk-B4AELNLE.js +1 -0
  22. package/dist/{chunk-O4KXODTJ.js → chunk-C4NG6RVA.js} +1 -1
  23. package/dist/chunk-CALDEF4M.js +1 -0
  24. package/dist/chunk-CSLTAXC7.js +1 -0
  25. package/dist/chunk-CWD36SJO.js +1 -0
  26. package/dist/chunk-DCZWNTG2.js +1 -0
  27. package/dist/chunk-DGZCD3AY.js +1 -0
  28. package/dist/{chunk-57GPGWSK.js → chunk-FTGRTYBL.js} +1 -1
  29. package/dist/chunk-HLCDAU5A.js +1 -0
  30. package/dist/{chunk-CZ4TQCUV.js → chunk-HTXB2WVI.js} +1 -1
  31. package/dist/chunk-JWTA2OCB.js +1 -0
  32. package/dist/{chunk-VC2HPREX.js → chunk-KEF6HIFK.js} +1 -1
  33. package/dist/chunk-KP4QI4RX.js +1 -0
  34. package/dist/{chunk-FCDWCQYC.js → chunk-LSVTH3TS.js} +1 -1
  35. package/dist/chunk-LUGZNBIW.js +1 -0
  36. package/dist/{chunk-YLPQLD2A.js → chunk-LZ3OJYBY.js} +1 -1
  37. package/dist/{chunk-5DZJCFNQ.js → chunk-MEDW4N3F.js} +1 -1
  38. package/dist/{chunk-7QDT6DO7.js → chunk-MPD3UIY4.js} +1 -1
  39. package/dist/chunk-MWICFZUF.js +1 -0
  40. package/dist/{chunk-POCDWUD3.js → chunk-NVF54BDR.js} +1 -1
  41. package/dist/{chunk-C2KT5ZFU.js → chunk-O6CUNETH.js} +1 -1
  42. package/dist/chunk-OXXPMJRJ.js +1 -0
  43. package/dist/{chunk-P6C3PNMQ.js → chunk-P6TNBX2S.js} +1 -1
  44. package/dist/{chunk-EREQZWGI.js → chunk-PBZSOTKZ.js} +1 -1
  45. package/dist/chunk-QHWR5UHD.js +1 -0
  46. package/dist/{chunk-33ZVZOSC.js → chunk-RDUKCMST.js} +1 -1
  47. package/dist/{chunk-ASDJTOGM.js → chunk-RJY5CUTB.js} +1 -1
  48. package/dist/chunk-S7A3IBAF.js +10 -0
  49. package/dist/{chunk-QZTTKH2H.js → chunk-SVLEVNHP.js} +1 -1
  50. package/dist/{chunk-WLGLQJ6M.js → chunk-TL67SYPH.js} +1 -1
  51. package/dist/{chunk-YY445FBU.js → chunk-UJMP7AMY.js} +1 -1
  52. package/dist/{chunk-67AY54E2.js → chunk-V65FSNYO.js} +1 -1
  53. package/dist/chunk-VILB5M4X.js +1 -0
  54. package/dist/{chunk-RV6UAUK2.js → chunk-ZICZN6WO.js} +1 -1
  55. package/dist/{configuration-sync-BHrAf-ql.d.ts → configuration-sync-7ruSsSrL.d.ts} +150 -1
  56. package/dist/content-KSIF5AXD.js +1 -0
  57. package/dist/funnel-host-purchase-YNC4LQJS.js +1 -0
  58. package/dist/{funnel-local-client-DR8OpKGU.d.ts → funnel-local-client-BMxDQWE6.d.ts} +51987 -22983
  59. package/dist/{funnel-node-evaluation-COxXtZEQ.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -0
  60. package/dist/funnel-paywall-prerender-DAAQUEEZ.js +1 -0
  61. package/dist/{funnel-process-client-C87U4r_G.d.ts → funnel-process-client-DNR9nHs8.d.ts} +7338 -3163
  62. package/dist/funnel-route-prediction-XGCMCIKA.js +1 -0
  63. package/dist/funnel-route-source-O76QSUYU.js +1 -0
  64. package/dist/funnel-runtime-host-WPU42YVT.js +1 -0
  65. package/dist/index.d.ts +273 -22
  66. package/dist/index.js +1 -1
  67. package/dist/merchant-bridge-contracts-FB63H7NE.js +1 -0
  68. package/dist/native-shell.js +1 -1
  69. package/dist/openrouter.d.ts +2 -2
  70. package/dist/openrouter.js +1 -1
  71. package/dist/operation-contracts-YSFIINLK.js +1 -0
  72. package/dist/page.d.ts +1 -1
  73. package/dist/page.js +1 -1
  74. package/dist/paywall-PZ4BBEFG.js +1 -0
  75. package/dist/paywall-content-5IWLT7YD.js +1 -0
  76. package/dist/paywall-session-K7GPR3UF.js +1 -0
  77. package/dist/popup.d.ts +2 -2
  78. package/dist/popup.js +1 -1
  79. package/dist/{presentation-loading-B_v5XZtM.d.ts → presentation-loading-B2OeFzRN.d.ts} +1 -0
  80. package/dist/react-native.d.ts +6 -6
  81. package/dist/react-native.js +1 -1
  82. package/dist/screen-renderer-RDXKWHYE.js +1 -0
  83. package/dist/server.d.ts +34204 -17797
  84. package/dist/server.js +1 -1
  85. package/dist/{visual-dom-5LUN4AHO.js → visual-dom-IN6DRNX3.js} +1 -1
  86. package/dist/visual.js +1 -1
  87. package/package.json +1 -1
  88. package/dist/check-response-DRQCUWDW.js +0 -1
  89. package/dist/chunk-3NCMYTNG.js +0 -1
  90. package/dist/chunk-4TEZZZYK.js +0 -1
  91. package/dist/chunk-6PG3AS3G.js +0 -1
  92. package/dist/chunk-AZFWG352.js +0 -1
  93. package/dist/chunk-BYP4KVB3.js +0 -10
  94. package/dist/chunk-C3GYAKIU.js +0 -1
  95. package/dist/chunk-ESAHTG3Y.js +0 -1
  96. package/dist/chunk-GC6JBIRQ.js +0 -1
  97. package/dist/chunk-IJKAQNK6.js +0 -1
  98. package/dist/chunk-IOJVF52Q.js +0 -1
  99. package/dist/chunk-OOD2VDDP.js +0 -1
  100. package/dist/chunk-P23JOPR5.js +0 -1
  101. package/dist/chunk-PJS7M6X3.js +0 -1
  102. package/dist/chunk-PZOQV6MU.js +0 -1
  103. package/dist/chunk-RFNIGJOL.js +0 -1
  104. package/dist/chunk-RULQQ7WI.js +0 -1
  105. package/dist/chunk-U7GH4VME.js +0 -1
  106. package/dist/chunk-VOKEZHAH.js +0 -1
  107. package/dist/chunk-XDOKFAE6.js +0 -1
  108. package/dist/chunk-Y6HL2IY2.js +0 -1
  109. package/dist/content-QUEVNSXD.js +0 -1
  110. package/dist/funnel-host-purchase-LMVMJNUO.js +0 -1
  111. package/dist/funnel-paywall-prerender-LGUSHEP3.js +0 -1
  112. package/dist/funnel-runtime-host-H5FM67UC.js +0 -1
  113. package/dist/merchant-bridge-contracts-LZSQYE3O.js +0 -1
  114. package/dist/operation-contracts-O7TCDGV4.js +0 -1
  115. package/dist/paywall-UANWOKKC.js +0 -1
  116. package/dist/paywall-content-CHPX2P77.js +0 -1
  117. package/dist/paywall-session-3BNUC5ZE.js +0 -1
  118. package/dist/screen-renderer-FFVZ64MR.js +0 -1
  119. /package/dist/{chunk-RGEBK6UF.js → chunk-GPJF3T43.js} +0 -0
  120. /package/dist/{chunk-OJM6ORHE.js → chunk-RA7GZ67U.js} +0 -0
  121. /package/dist/{chunk-CILM5XMH.js → chunk-WPFTSHP2.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.42
4
+
5
+ - Keep native subscription upgrades and their original purchase operation through Funnel quotes, confirmation and recovery, including prepaid quantities. Show the merchant’s exact amount due today.
6
+ - A provisional first Paywall rereads availability when the merchant resolves a subscription-change intent. Preserve first-screen route prediction.
7
+ - Restore a pending merchant Checkout from its verified redirect, and permit reselection after a sealed failed change only when the server confirms closure.
8
+ - Keep the accessible Continue checkout label synchronized with the visible button.
9
+ - Synchronize authored slider labels and local price state when eligibility becomes available again. Keep restored confirmation controls disabled until the opening read releases them.
10
+ - Wire protocol remains `0.10`.
11
+
12
+ ## 0.10.41
13
+
14
+ - `predictFunnelStart(configuration, { funnelId, customerId, parameters })` says on the device, before the click, which first screen a Run of the Funnel would present for this Customer: a Paywall (with `paywallId`, `paywallVersionId` and `presentation`), a Funnel screen such as a popup, an external page, an end such as `ineligible`, `unknown` when a step needs the server, or `unavailable`. It records nothing: no Run, exposure, Sticky assignment or Coupon. Splits bucket by the session's Customer ID, as the server does.
15
+ - A Remote Funnel's route is read from `/api/v1/configuration/{environmentId}/funnels/{funnelId}/versions/{versionId}/route`, outside the manifest, and only while its author has turned on **Publish the first-screen route**; until the API serves it, the prediction is `unavailable` (`route_unavailable`). A Local Funnel's route is computed from its public graph.
16
+ - `prerenderFunnelPurchase` renders the predicted Paywall when the app passes `configuration` and names no Paywall, exposes it as `prepared.prediction`, and withdraws an unclaimed copy as `route_changed` when a refresh routes the Start elsewhere. `predictedPaywallLoadingDocument` returns that Paywall's published design for a loading state.
17
+ - `showFunnelPurchase({ start })` accepts a promise: the SDK shows its loading state at the click and starts the Run when the merchant's checks settle; `null`, `undefined` or a rejection ends without a Run (`skipped`).
18
+ - New local error code `ROUTE_UNAVAILABLE`. Existing calls behave as in 0.10.40. Wire protocol remains `0.10`.
19
+
3
20
  ## 0.10.40
4
21
 
5
22
  - A purchase Funnel opens its first screen in one request. The purchase client asks Longplay to accept the Start and drive it to its first position in the same `recover_start` request (`intent: "start"`), instead of a recovery followed by a separate resume. A Run that ends in its first segment is reported as complete from that reply.
package/README.md CHANGED
@@ -246,8 +246,56 @@ purchase.destroy();
246
246
  `featureQuantities`, keyed by prepaid Feature ID. The quantities come from the
247
247
  submitted Paywall selection. Products without prepaid Features send an empty object.
248
248
 
249
+ For an existing web subscription, supply `resolveSubscriptionChange` to `showPaywall`,
250
+ `showFunnelRun` or `showFunnelPurchase`. It receives the same action, Product Version and
251
+ `featureQuantities` and returns `{ membershipId, timing: "immediate" | "renewal" }`.
252
+ Resolve that membership from the authenticated Customer's current subscription. Return
253
+ `undefined` only when the intended action is a new subscription; reject an unavailable or
254
+ ambiguous membership instead of falling back to attachment. For example, after the merchant
255
+ has verified a single current membership:
256
+
257
+ ```ts
258
+ import type { PaywallHostOptions } from "@tinkerlandai/longplay-sdk";
259
+
260
+ const resolveSubscriptionChange: PaywallHostOptions["resolveSubscriptionChange"] =
261
+ () => {
262
+ if (!existingMembershipId) return undefined; // A verified new-subscription account.
263
+ return { membershipId: existingMembershipId, timing: "immediate" as const };
264
+ };
265
+ await showFunnelPurchase(container, {
266
+ client: purchase,
267
+ start: { funnelId, locale, parameters },
268
+ resolveSubscriptionChange,
269
+ });
270
+ ```
271
+
272
+ Set `parameters.commerce.intent: "subscription_change"` (or a standalone Paywall's
273
+ `commerce.intent`) to resolve Offering availability against the Customer's unique owned
274
+ membership. Without this optional intent, availability retains new-purchase semantics. An
275
+ explicit change intent without a selected membership is refused rather than attached.
276
+
277
+ The selected target remains pinned to the Paywall's allowed Products. Plan changes retain
278
+ prepaid `featureQuantities` in the command, quote, operation and recovery selection (at most
279
+ 100 Feature UUIDs, integer quantities from 0 to 10000). Unsupported provider/timing combinations
280
+ remain server refusals; native store offers cannot be mixed into a web change. For upgrade
281
+ availability, the server supplies verified owned quantities through the existing quantity
282
+ capabilities. Untouched controls start at those values rather than an authored zero; user
283
+ changes and original quoted selections survive refreshes. Missing native source quantities
284
+ remain unavailable instead of being inferred from the displayed price. They retain the selected Coupon and use
285
+ `previewUpdate`, `update` and `readSubscriptionUpdate`, not `previewAttach`. The Paywall
286
+ shows the merchant's frozen credit, charge, amount due, renewal terms and required consents
287
+ before explicit confirmation; `confirmOnHostedCheckout` does not skip this confirmation.
288
+ The accepted change stays in the same Funnel Run, receipt and operation through cancellation,
289
+ lost responses and reopening. Public `PaywallQuote` and `PaywallOperation` are attach/update
290
+ unions; use `isPaywallUpdateQuote` / `isPaywallUpdateOperation` to distinguish them.
291
+ Updates retain their real `effective` or `scheduled` status. Completion also waits for the
292
+ merchant's fulfillment and accepted recording; an unfinished update redirect resumes only
293
+ its original verified payment URL.
294
+
249
295
  A purchase button can be bound to the Coupon its Paywall displays. Pass `claimCoupon`, for example `longplay.forFunnel({ funnelId, versionId }).claimCoupon`, to use it: the SDK claims that Coupon at the click and quotes with its offer. Such a button does not call `resolveOfferId`, and a quote that did not apply the Coupon is refused.
250
296
 
297
+ `start` can also be a promise for the Start while the merchant's own checks run: call `showFunnelPurchase` in the click, and the SDK shows its loading state at once (sized from `loadingDocument`, such as `predictedPaywallLoadingDocument(configuration, prediction)` for the first Paywall `predictFunnelStart` predicts) and starts the Run when the promise settles. `null`, `undefined` or a rejection ends the presentation without a Run (`skipped`), so the merchant can take its own path; closing the loading state before then starts nothing. A pre-rendered copy waiting for the same checks is revealed once they settle on a matching Start, and released otherwise.
298
+
251
299
  `preloadFunnelPurchase()` downloads the code a Funnel purchase presents with. It needs no Customer, sends no request and changes no DOM; call it when the page can spare the download.
252
300
 
253
301
  `start()` persists the complete original request before dispatch. An unresolved attempt retains its request ID, locale, parameters and execution policy even if later calls supply different inputs; another Funnel is refused. `refresh()` allocates nothing. The Controller's existing command journal shares the purchase CAS row, so unknown confirmation/Close results retain their original identities. A new attempt is permitted only after the original Run is terminal, its commands are settled and all retained purchases have server-confirmed outcomes. An untouched quote can be cancelled through the existing Customer API after confirmed Run termination. Clearing browser storage cannot prove an unknown purchase absent and is not a fallback procedure.
@@ -299,7 +347,9 @@ button.onclick = () => {
299
347
  ```
300
348
 
301
349
  - `paywallVersionId` (one exact Version) or `paywallId` (its current published Version) names the Paywall the Funnel presents first. The copy is read with `purchase.readPaywall()` as a standalone Paywall would be, for the Start's `parameters.commerce` and `locale`.
302
- - `start` can be a promise while the merchant's own checks run: rendering starts at once and the copy becomes ready only with the Start. Pass `commerce` and `locale` then; a Start with other commerce or locale, `null` or a rejection leaves it `unavailable`.
350
+ - Or pass `configuration` (the page's `createConfigurationSync`) and name no Paywall: the SDK predicts this Customer's first screen from the Funnel's published route (see below) once the Start is final, and renders that Paywall. `prepared.prediction` holds the prediction. A first screen that is not a Paywall leaves the copy `unavailable` with reason `first_screen_popup`, `first_screen_page`, `first_screen_external_page`, `route_end_<outcome>` (for example `route_end_ineligible`) or `route_unknown_<reason>`; a route that is not published reads `route_unavailable`. Until a click takes it, a ready copy becomes `unavailable` (`route_changed`) when a configuration refresh routes the Start to another first screen.
351
+ - `start` can be a promise while the merchant's own checks run: rendering starts at once and the copy becomes ready only with the Start. Pass provisional `commerce` and `locale` then. If admission changes only `commerce.intent`, the SDK rereads the same Paywall's server availability for the final intent before revealing it; an unavailable provisional purchase screen cannot decide upgrade eligibility. A provider, currency or locale change, `null` or a rejection leaves it `unavailable`.
352
+
303
353
  - `state` is `preparing`, `ready`, `unavailable` (see `reason`), `shown`, `adopted`, `released` or `closed`; `ready` resolves `true` once it can be revealed and `false` when it never will be; `onState` reports each change.
304
354
  - Call `open()` synchronously from the opening click. It returns `"shown"` (revealed now), `"pending"` (still rendering: pass it anyway; it is revealed only if it is ready before the Run presents anything, so the click never waits for it) or `false` (show the purchase the normal way). Pass the same Start to `showFunnelPurchase`; `matches(start)` says whether a Start would present this copy (the request ID may differ).
305
355
  - Passing `prepared` to `showFunnelPurchase` (or `showFunnelRun`) hands it to the SDK. When the SDK cannot use it (a presentation for the client is already open, another or no Start, no Run, operation-only or blocked recovery, a failure, an instruction or another presentation first), it releases it, so a revealed copy is never left on screen. A revealed presentation that ends without a Run reports `onDismiss(null)`, or `onError` for a failure; a Funnel paused before the takeover dismisses a revealed dialog for good, as it does one the Run presented. Do not reuse a copy you passed; pre-render a new one.
@@ -307,6 +357,12 @@ button.onclick = () => {
307
357
  - A copy is revealed only within `maxAgeMs` (5 minutes by default) of its render. It is never prepared while `purchase.retained()` reports a pending purchase, and until a click takes it a ready copy becomes `unavailable` when this Customer's purchase is left pending, by the same purchase client or, through the default browser purchase store, by another tab; the Run's own recovery stays the final guard. A Customer change, `signal` or `destroy()` releases it; after the takeover the Run host owns it.
308
358
  - Keep `container` attached and in place: moving it restarts the Paywall's frame.
309
359
 
360
+ #### Predict the first screen
361
+
362
+ `predictFunnelStart(configuration, { funnelId, customerId, parameters })` says which first screen a Run of the Funnel would present for this Customer and these Start parameters: `paywall` (with `paywallId`, `paywallVersionId` and `presentation`), `screen` (a Funnel-owned `page`, `popup` or `onboarding`), `external_page`, `end` (with its `outcome`, such as `ineligible`), `unknown` (a step only the server can decide) or `unavailable` (no published route, a paused Funnel, unreadable configuration). It is computed on the device from the Funnel Version's routing program and records nothing: no Run, exposure, Sticky assignment or Coupon. `customerId` is the session's Customer ID, which Splits bucket by. The Run started at the click still decides; a Customer with an earlier Sticky assignment, or a Funnel or Experiment changed since the last configuration refresh, can be routed differently, and the pre-rendered copy is then released as before. `predictedPaywallLoadingDocument(configuration, prediction)` returns the predicted Paywall's published design for a loading state.
363
+
364
+ A Remote Funnel's routing program is delivered only while the Funnel's **Publish the first-screen route** setting is on (Console, Funnel Settings, Organization Owner or Admin); otherwise `predictFunnelStart` reports `unavailable` (`route_unavailable`). The program holds the conditions over start parameters, inputs and the Customer ID before the first screen, each Split's bucketing (seed, weights, coverage, ranges, filters, forced or passthrough Variations, targeting over declared values), and each path's first screen; never screen content, Coupons, Bundles, Feature rules, Experiment keys or names, targeting over Customer facts, or anything after the first presentation. A step that reads other values, an action, a Feature, a Wait or a Split that buckets by another attribute is marked as server-only and stops the prediction. A Local Funnel's route is computed from its public graph. Remote routes are read from `/api/v1/configuration/{environmentId}/funnels/{funnelId}/versions/{versionId}/route`, outside the manifest, so SDKs that predate it keep reading the manifest.
365
+
310
366
  `purchase.retained()` reads storage only and says whether a new Start would begin afresh (`"none"`, `"finished"`, `"replaceable"`) or recover a pending original purchase (`"pending"`). `purchase.readPaywall({ paywallVersionId | paywallId, commerce, locale })` reads one published Paywall with its content for the current Customer, starting nothing; it refuses another Version or Paywall than requested and a Customer change during the read.
311
367
 
312
368
  ### Guest entry and same-Run login
package/README.zh-CN.md CHANGED
@@ -212,6 +212,10 @@ SDK 在首次派发前保存原 Start 请求 ID 和完整输入;同一未决
212
212
 
213
213
  `resolveOfferId` 还会收到 `featureQuantities`,按预付 Feature ID 提供本次提交的数量。无预付 Feature 的商品会传入空对象。
214
214
 
215
+ 已订阅用户的 Web 套餐变更通过 `showPaywall`、`showFunnelRun` 或 `showFunnelPurchase` 的 `resolveSubscriptionChange` 选择原 membership。回调收到同样的 action、Product Version 和 `featureQuantities`,返回 `{ membershipId, timing: "immediate" | "renewal" }`。membership 必须来自当前已认证 Customer 的真实订阅;只有明确新订阅的场景才返回 `undefined`,订阅缺失或有歧义时应拒绝。完整示例见[英文说明](README.md#managed-funnel-purchase-recovery)。
216
+
217
+ 可在 parameters.commerce.intent(独立 Paywall 则为 commerce.intent)传入 subscription_change,使 Offering 按 Customer 唯一已持有 membership 判断升级可用性;省略时保留新购语义。显式变更意图缺少 membership 会被拒绝,不回退新购。该路径保留选中 Coupon,使用 `previewUpdate/update/readSubscriptionUpdate`,不创建新的 attachment;预付 featureQuantities 在命令、报价、operation 和恢复选项中保持不变(最多 100 个 Feature UUID,每项整数 0–10000);服务端仍拒绝不支持的执行方式/时机,Web 变更不能混用原生商店 offer。升级首屏数量使用服务端核实的原订阅档位初始化;之后保留用户调整和原报价,原订数量缺失则不可用,不根据显示价格猜测。确认页展示商户固定的抵扣、实付、续费和 consent,用户明确确认后才执行;`confirmOnHostedCheckout` 不跳过变更确认。取消、丢响应和重开保留同一 Run、receipt 和 operation。公开 `PaywallQuote/PaywallOperation` 为 attach/update 联合类型,可用 `isPaywallUpdateQuote/isPaywallUpdateOperation` 区分;update 保留真实 `effective/scheduled` 状态,并等待商户权益处理和交易记录确认。未完成的变更付款跳转只恢复原来经核对的 URL。
218
+
215
219
  购买按钮可以绑定 Paywall 上展示的 Coupon。传入 `claimCoupon` 后,SDK 在点击时为 Customer 领取该 Coupon,并用领到的 offer 报价。这类按钮不再调用 `resolveOfferId`;报价没有应用该 Coupon 时不会进入确认。
216
220
 
217
221
  `preloadFunnelPurchase()` 提前下载 Funnel 购买展示所需的代码。它不需要 Customer,不发请求,也不改动页面,可在页面空闲时调用。
@@ -231,7 +235,7 @@ SDK 在首次派发前保存原 Start 请求 ID 和完整输入;同一未决
231
235
  `prerenderFunnelPurchase(container, { client: purchase, start, paywallVersionId 或 paywallId })` 在点击之前隐藏渲染购买 Start 首先展示的 Paywall,点击时只需显示它。预渲染不启动任何东西:没有 Run、回执、曝光或报价。点击时启动的 Run 若首个 Paywall 是同一发布版本且未被操作过,就接管这份已显示的 Paywall。完整示例见[英文说明](README.md#pre-render-the-first-paywall)。
232
236
 
233
237
  - 公开入口的 `prerenderFunnelPurchase` 返回 Promise,需在点击前 await 得到 `PreparedFunnelPurchase`。`paywallVersionId` 指定一个确切版本,`paywallId` 指定其当前发布版本;内容通过 `purchase.readPaywall()` 按 Start 的 `parameters.commerce` 和 `locale` 读取。
234
- - 商户自己的校验尚未完成时,`start` 可以传 Promise:渲染立即开始,拿到 Start 后才变为 ready。此时必须同时传 `commerce` 和 `locale`;最终 Start 的 commerce 或 locale 不同、为 `null` 或被拒绝时,状态为 `unavailable`。
238
+ - 商户自己的校验尚未完成时,`start` 可以传 Promise:渲染立即开始,拿到 Start 后才变为 ready。此时传入初始 `commerce` 和 `locale`;若最终只改变 commerce.intent,SDK 会按最终意图正常重新读取同一 Paywall 可用性,读取完成前不展示,不能用新购灰态判定升级资格。provider、currency 或 locale 改变、Start 为 `null` 或被拒绝时,仍为 `unavailable`。
235
239
  - `state` 依次为 `preparing`、`ready`、`unavailable`(原因见 `reason`)、`shown`、`adopted`、`released`、`closed`;`ready` 在可显示时解析为 `true`,永远不能显示时为 `false`;`onState` 报告每次变化。
236
240
  - 必须在点击处理函数里同步调用 `open()`(任何 await 之前):`"shown"` 表示本帧已显示;`"pending"` 表示仍在渲染,照样传给 `showFunnelPurchase`,只有在 Run 展示任何内容之前准备好才会显示,点击不会等它;`false` 表示按普通方式打开。传给 `showFunnelPurchase` 的 Start 必须与预渲染时相同(请求 ID 可以不同),`matches(start)` 可用于判断。
237
241
  - 把 `prepared` 传给 `showFunnelPurchase`(或 `showFunnelRun`)即交给 SDK 管理。SDK 用不上时(该 client 已有展示、Start 不同或缺失、没有 Run、仅恢复 Operation 或受阻、失败、Run 先展示指令或其他内容)会释放它,已显示的副本不会留在屏幕上。已显示的展示在没有 Run 的情况下结束时,商户收到 `onDismiss(null)`,失败时收到 `onError`;接管前 Funnel 被暂停时,已显示的对话框与 Run 自己展示的一样被永久关闭。传出后不要再复用,需要时重新预渲染。
@@ -1,5 +1,5 @@
1
1
  import { LanguageModelV4Usage, LanguageModelV4Middleware } from '@ai-sdk/provider';
2
- import { F as FoundationApi, A as ApiInput } from './api-r6FfVQpg.js';
2
+ import { F as FoundationApi, A as ApiInput } from './api-DpRb_Pd3.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const tokenCounts: z.ZodObject<{
@@ -2566,6 +2566,7 @@ declare const apiOperations: {
2566
2566
  }, z$1.core.$strict>, z$1.ZodObject<{
2567
2567
  type: z$1.ZodLiteral<"plan">;
2568
2568
  productVersionId: z$1.ZodUUID;
2569
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
2569
2570
  }, z$1.core.$strict>, z$1.ZodObject<{
2570
2571
  type: z$1.ZodLiteral<"seats">;
2571
2572
  licenseKey: z$1.ZodString;
@@ -2759,6 +2760,7 @@ declare const apiOperations: {
2759
2760
  operationId: z$1.ZodUUID;
2760
2761
  membershipId: z$1.ZodUUID;
2761
2762
  productVersionId: z$1.ZodUUID;
2763
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
2762
2764
  timing: z$1.ZodEnum<{
2763
2765
  immediate: "immediate";
2764
2766
  renewal: "renewal";
@@ -2897,6 +2899,7 @@ declare const apiOperations: {
2897
2899
  }, z$1.core.$strict>, z$1.ZodObject<{
2898
2900
  type: z$1.ZodLiteral<"plan">;
2899
2901
  productVersionId: z$1.ZodUUID;
2902
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
2900
2903
  }, z$1.core.$strict>, z$1.ZodObject<{
2901
2904
  type: z$1.ZodLiteral<"seats">;
2902
2905
  licenseKey: z$1.ZodString;
@@ -3133,6 +3136,7 @@ declare const apiOperations: {
3133
3136
  }, z$1.core.$strict>, z$1.ZodObject<{
3134
3137
  type: z$1.ZodLiteral<"plan">;
3135
3138
  productVersionId: z$1.ZodUUID;
3139
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
3136
3140
  }, z$1.core.$strict>, z$1.ZodObject<{
3137
3141
  type: z$1.ZodLiteral<"seats">;
3138
3142
  licenseKey: z$1.ZodString;
@@ -3326,6 +3330,7 @@ declare const apiOperations: {
3326
3330
  operationId: z$1.ZodUUID;
3327
3331
  membershipId: z$1.ZodUUID;
3328
3332
  productVersionId: z$1.ZodUUID;
3333
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
3329
3334
  timing: z$1.ZodEnum<{
3330
3335
  immediate: "immediate";
3331
3336
  renewal: "renewal";
@@ -3464,6 +3469,7 @@ declare const apiOperations: {
3464
3469
  }, z$1.core.$strict>, z$1.ZodObject<{
3465
3470
  type: z$1.ZodLiteral<"plan">;
3466
3471
  productVersionId: z$1.ZodUUID;
3472
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
3467
3473
  }, z$1.core.$strict>, z$1.ZodObject<{
3468
3474
  type: z$1.ZodLiteral<"seats">;
3469
3475
  licenseKey: z$1.ZodString;
@@ -3700,6 +3706,7 @@ declare const apiOperations: {
3700
3706
  }, z$1.core.$strict>, z$1.ZodObject<{
3701
3707
  type: z$1.ZodLiteral<"plan">;
3702
3708
  productVersionId: z$1.ZodUUID;
3709
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
3703
3710
  }, z$1.core.$strict>, z$1.ZodObject<{
3704
3711
  type: z$1.ZodLiteral<"seats">;
3705
3712
  licenseKey: z$1.ZodString;
@@ -3893,6 +3900,7 @@ declare const apiOperations: {
3893
3900
  operationId: z$1.ZodUUID;
3894
3901
  membershipId: z$1.ZodUUID;
3895
3902
  productVersionId: z$1.ZodUUID;
3903
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
3896
3904
  timing: z$1.ZodEnum<{
3897
3905
  immediate: "immediate";
3898
3906
  renewal: "renewal";
@@ -4031,6 +4039,7 @@ declare const apiOperations: {
4031
4039
  }, z$1.core.$strict>, z$1.ZodObject<{
4032
4040
  type: z$1.ZodLiteral<"plan">;
4033
4041
  productVersionId: z$1.ZodUUID;
4042
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
4034
4043
  }, z$1.core.$strict>, z$1.ZodObject<{
4035
4044
  type: z$1.ZodLiteral<"seats">;
4036
4045
  licenseKey: z$1.ZodString;
@@ -4267,6 +4276,7 @@ declare const apiOperations: {
4267
4276
  }, z$1.core.$strict>, z$1.ZodObject<{
4268
4277
  type: z$1.ZodLiteral<"plan">;
4269
4278
  productVersionId: z$1.ZodUUID;
4279
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
4270
4280
  }, z$1.core.$strict>, z$1.ZodObject<{
4271
4281
  type: z$1.ZodLiteral<"seats">;
4272
4282
  licenseKey: z$1.ZodString;
@@ -4460,6 +4470,7 @@ declare const apiOperations: {
4460
4470
  operationId: z$1.ZodUUID;
4461
4471
  membershipId: z$1.ZodUUID;
4462
4472
  productVersionId: z$1.ZodUUID;
4473
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
4463
4474
  timing: z$1.ZodEnum<{
4464
4475
  immediate: "immediate";
4465
4476
  renewal: "renewal";
@@ -4598,6 +4609,7 @@ declare const apiOperations: {
4598
4609
  }, z$1.core.$strict>, z$1.ZodObject<{
4599
4610
  type: z$1.ZodLiteral<"plan">;
4600
4611
  productVersionId: z$1.ZodUUID;
4612
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
4601
4613
  }, z$1.core.$strict>, z$1.ZodObject<{
4602
4614
  type: z$1.ZodLiteral<"seats">;
4603
4615
  licenseKey: z$1.ZodString;
@@ -5296,6 +5308,7 @@ declare const apiOperations: {
5296
5308
  }, z$1.core.$strict>, z$1.ZodObject<{
5297
5309
  type: z$1.ZodLiteral<"plan">;
5298
5310
  productVersionId: z$1.ZodUUID;
5311
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
5299
5312
  }, z$1.core.$strict>, z$1.ZodObject<{
5300
5313
  type: z$1.ZodLiteral<"seats">;
5301
5314
  licenseKey: z$1.ZodString;
@@ -6738,6 +6751,7 @@ declare const apiOperations: {
6738
6751
  }, z$1.core.$strict>, z$1.ZodObject<{
6739
6752
  type: z$1.ZodLiteral<"plan">;
6740
6753
  productVersionId: z$1.ZodUUID;
6754
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
6741
6755
  }, z$1.core.$strict>, z$1.ZodObject<{
6742
6756
  type: z$1.ZodLiteral<"seats">;
6743
6757
  licenseKey: z$1.ZodString;
@@ -7726,6 +7740,7 @@ declare const apiOperations: {
7726
7740
  }, z$1.core.$strict>, z$1.ZodObject<{
7727
7741
  type: z$1.ZodLiteral<"plan">;
7728
7742
  productVersionId: z$1.ZodUUID;
7743
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
7729
7744
  }, z$1.core.$strict>, z$1.ZodObject<{
7730
7745
  type: z$1.ZodLiteral<"seats">;
7731
7746
  licenseKey: z$1.ZodString;
@@ -7914,6 +7929,7 @@ declare const apiOperations: {
7914
7929
  }, z$1.core.$strict>, z$1.ZodObject<{
7915
7930
  type: z$1.ZodLiteral<"plan">;
7916
7931
  productVersionId: z$1.ZodUUID;
7932
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
7917
7933
  }, z$1.core.$strict>, z$1.ZodObject<{
7918
7934
  type: z$1.ZodLiteral<"seats">;
7919
7935
  licenseKey: z$1.ZodString;
@@ -8461,6 +8477,7 @@ declare const apiOperations: {
8461
8477
  }, z$1.core.$strict>, z$1.ZodObject<{
8462
8478
  type: z$1.ZodLiteral<"plan">;
8463
8479
  productVersionId: z$1.ZodUUID;
8480
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
8464
8481
  }, z$1.core.$strict>, z$1.ZodObject<{
8465
8482
  type: z$1.ZodLiteral<"seats">;
8466
8483
  licenseKey: z$1.ZodString;
@@ -9449,6 +9466,7 @@ declare const apiOperations: {
9449
9466
  }, z$1.core.$strict>, z$1.ZodObject<{
9450
9467
  type: z$1.ZodLiteral<"plan">;
9451
9468
  productVersionId: z$1.ZodUUID;
9469
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
9452
9470
  }, z$1.core.$strict>, z$1.ZodObject<{
9453
9471
  type: z$1.ZodLiteral<"seats">;
9454
9472
  licenseKey: z$1.ZodString;
@@ -9637,6 +9655,7 @@ declare const apiOperations: {
9637
9655
  }, z$1.core.$strict>, z$1.ZodObject<{
9638
9656
  type: z$1.ZodLiteral<"plan">;
9639
9657
  productVersionId: z$1.ZodUUID;
9658
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
9640
9659
  }, z$1.core.$strict>, z$1.ZodObject<{
9641
9660
  type: z$1.ZodLiteral<"seats">;
9642
9661
  licenseKey: z$1.ZodString;
@@ -9855,6 +9874,7 @@ declare const apiOperations: {
9855
9874
  change: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
9856
9875
  type: z$1.ZodLiteral<"plan">;
9857
9876
  productVersionId: z$1.ZodUUID;
9877
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
9858
9878
  }, z$1.core.$strict>, z$1.ZodObject<{
9859
9879
  type: z$1.ZodLiteral<"seats">;
9860
9880
  licenseKey: z$1.ZodString;
@@ -9924,6 +9944,7 @@ declare const apiOperations: {
9924
9944
  }, z$1.core.$strict>, z$1.ZodObject<{
9925
9945
  type: z$1.ZodLiteral<"plan">;
9926
9946
  productVersionId: z$1.ZodUUID;
9947
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
9927
9948
  }, z$1.core.$strict>, z$1.ZodObject<{
9928
9949
  type: z$1.ZodLiteral<"seats">;
9929
9950
  licenseKey: z$1.ZodString;
@@ -10117,6 +10138,7 @@ declare const apiOperations: {
10117
10138
  operationId: z$1.ZodUUID;
10118
10139
  membershipId: z$1.ZodUUID;
10119
10140
  productVersionId: z$1.ZodUUID;
10141
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
10120
10142
  timing: z$1.ZodEnum<{
10121
10143
  immediate: "immediate";
10122
10144
  renewal: "renewal";
@@ -10255,6 +10277,7 @@ declare const apiOperations: {
10255
10277
  }, z$1.core.$strict>, z$1.ZodObject<{
10256
10278
  type: z$1.ZodLiteral<"plan">;
10257
10279
  productVersionId: z$1.ZodUUID;
10280
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
10258
10281
  }, z$1.core.$strict>, z$1.ZodObject<{
10259
10282
  type: z$1.ZodLiteral<"seats">;
10260
10283
  licenseKey: z$1.ZodString;
@@ -10477,6 +10500,7 @@ declare const apiOperations: {
10477
10500
  invoiceMode: z$1.ZodOptional<z$1.ZodBoolean>;
10478
10501
  membershipId: z$1.ZodUUID;
10479
10502
  productVersionId: z$1.ZodUUID;
10503
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
10480
10504
  status: z$1.ZodEnum<{
10481
10505
  failed: "failed";
10482
10506
  pending: "pending";
@@ -10588,6 +10612,7 @@ declare const apiOperations: {
10588
10612
  }, z$1.core.$strict>, z$1.ZodObject<{
10589
10613
  type: z$1.ZodLiteral<"plan">;
10590
10614
  productVersionId: z$1.ZodUUID;
10615
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
10591
10616
  }, z$1.core.$strict>, z$1.ZodObject<{
10592
10617
  type: z$1.ZodLiteral<"seats">;
10593
10618
  licenseKey: z$1.ZodString;
@@ -11070,6 +11095,7 @@ declare const apiOperations: {
11070
11095
  }, z$1.core.$strict>, z$1.ZodObject<{
11071
11096
  type: z$1.ZodLiteral<"plan">;
11072
11097
  productVersionId: z$1.ZodUUID;
11098
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
11073
11099
  }, z$1.core.$strict>, z$1.ZodObject<{
11074
11100
  type: z$1.ZodLiteral<"seats">;
11075
11101
  licenseKey: z$1.ZodString;
@@ -11263,6 +11289,7 @@ declare const apiOperations: {
11263
11289
  operationId: z$1.ZodUUID;
11264
11290
  membershipId: z$1.ZodUUID;
11265
11291
  productVersionId: z$1.ZodUUID;
11292
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
11266
11293
  timing: z$1.ZodEnum<{
11267
11294
  immediate: "immediate";
11268
11295
  renewal: "renewal";
@@ -11401,6 +11428,7 @@ declare const apiOperations: {
11401
11428
  }, z$1.core.$strict>, z$1.ZodObject<{
11402
11429
  type: z$1.ZodLiteral<"plan">;
11403
11430
  productVersionId: z$1.ZodUUID;
11431
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
11404
11432
  }, z$1.core.$strict>, z$1.ZodObject<{
11405
11433
  type: z$1.ZodLiteral<"seats">;
11406
11434
  licenseKey: z$1.ZodString;
@@ -11634,6 +11662,7 @@ declare const apiOperations: {
11634
11662
  }, z$1.core.$strict>, z$1.ZodObject<{
11635
11663
  type: z$1.ZodLiteral<"plan">;
11636
11664
  productVersionId: z$1.ZodUUID;
11665
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
11637
11666
  }, z$1.core.$strict>, z$1.ZodObject<{
11638
11667
  type: z$1.ZodLiteral<"seats">;
11639
11668
  licenseKey: z$1.ZodString;
@@ -11822,6 +11851,7 @@ declare const apiOperations: {
11822
11851
  }, z$1.core.$strict>, z$1.ZodObject<{
11823
11852
  type: z$1.ZodLiteral<"plan">;
11824
11853
  productVersionId: z$1.ZodUUID;
11854
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
11825
11855
  }, z$1.core.$strict>, z$1.ZodObject<{
11826
11856
  type: z$1.ZodLiteral<"seats">;
11827
11857
  licenseKey: z$1.ZodString;
@@ -12130,6 +12160,7 @@ declare const apiOperations: {
12130
12160
  invoiceMode: z$1.ZodOptional<z$1.ZodBoolean>;
12131
12161
  membershipId: z$1.ZodUUID;
12132
12162
  productVersionId: z$1.ZodUUID;
12163
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
12133
12164
  status: z$1.ZodEnum<{
12134
12165
  failed: "failed";
12135
12166
  pending: "pending";
@@ -12241,6 +12272,7 @@ declare const apiOperations: {
12241
12272
  }, z$1.core.$strict>, z$1.ZodObject<{
12242
12273
  type: z$1.ZodLiteral<"plan">;
12243
12274
  productVersionId: z$1.ZodUUID;
12275
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
12244
12276
  }, z$1.core.$strict>, z$1.ZodObject<{
12245
12277
  type: z$1.ZodLiteral<"seats">;
12246
12278
  licenseKey: z$1.ZodString;
@@ -12723,6 +12755,7 @@ declare const apiOperations: {
12723
12755
  }, z$1.core.$strict>, z$1.ZodObject<{
12724
12756
  type: z$1.ZodLiteral<"plan">;
12725
12757
  productVersionId: z$1.ZodUUID;
12758
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
12726
12759
  }, z$1.core.$strict>, z$1.ZodObject<{
12727
12760
  type: z$1.ZodLiteral<"seats">;
12728
12761
  licenseKey: z$1.ZodString;
@@ -12916,6 +12949,7 @@ declare const apiOperations: {
12916
12949
  operationId: z$1.ZodUUID;
12917
12950
  membershipId: z$1.ZodUUID;
12918
12951
  productVersionId: z$1.ZodUUID;
12952
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
12919
12953
  timing: z$1.ZodEnum<{
12920
12954
  immediate: "immediate";
12921
12955
  renewal: "renewal";
@@ -13054,6 +13088,7 @@ declare const apiOperations: {
13054
13088
  }, z$1.core.$strict>, z$1.ZodObject<{
13055
13089
  type: z$1.ZodLiteral<"plan">;
13056
13090
  productVersionId: z$1.ZodUUID;
13091
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
13057
13092
  }, z$1.core.$strict>, z$1.ZodObject<{
13058
13093
  type: z$1.ZodLiteral<"seats">;
13059
13094
  licenseKey: z$1.ZodString;
@@ -13287,6 +13322,7 @@ declare const apiOperations: {
13287
13322
  }, z$1.core.$strict>, z$1.ZodObject<{
13288
13323
  type: z$1.ZodLiteral<"plan">;
13289
13324
  productVersionId: z$1.ZodUUID;
13325
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
13290
13326
  }, z$1.core.$strict>, z$1.ZodObject<{
13291
13327
  type: z$1.ZodLiteral<"seats">;
13292
13328
  licenseKey: z$1.ZodString;
@@ -13475,6 +13511,7 @@ declare const apiOperations: {
13475
13511
  }, z$1.core.$strict>, z$1.ZodObject<{
13476
13512
  type: z$1.ZodLiteral<"plan">;
13477
13513
  productVersionId: z$1.ZodUUID;
13514
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
13478
13515
  }, z$1.core.$strict>, z$1.ZodObject<{
13479
13516
  type: z$1.ZodLiteral<"seats">;
13480
13517
  licenseKey: z$1.ZodString;
@@ -13830,6 +13867,7 @@ declare const apiOperations: {
13830
13867
  }, z$1.core.$strict>, z$1.ZodObject<{
13831
13868
  type: z$1.ZodLiteral<"plan">;
13832
13869
  productVersionId: z$1.ZodUUID;
13870
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
13833
13871
  }, z$1.core.$strict>, z$1.ZodObject<{
13834
13872
  type: z$1.ZodLiteral<"seats">;
13835
13873
  licenseKey: z$1.ZodString;
@@ -14235,6 +14273,7 @@ declare const apiOperations: {
14235
14273
  }, z$1.core.$strict>, z$1.ZodObject<{
14236
14274
  type: z$1.ZodLiteral<"plan">;
14237
14275
  productVersionId: z$1.ZodUUID;
14276
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
14238
14277
  }, z$1.core.$strict>, z$1.ZodObject<{
14239
14278
  type: z$1.ZodLiteral<"seats">;
14240
14279
  licenseKey: z$1.ZodString;
@@ -14970,6 +15009,7 @@ declare const apiOperations: {
14970
15009
  }, z$1.core.$strict>, z$1.ZodObject<{
14971
15010
  type: z$1.ZodLiteral<"plan">;
14972
15011
  productVersionId: z$1.ZodUUID;
15012
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
14973
15013
  }, z$1.core.$strict>, z$1.ZodObject<{
14974
15014
  type: z$1.ZodLiteral<"seats">;
14975
15015
  licenseKey: z$1.ZodString;
@@ -15158,6 +15198,7 @@ declare const apiOperations: {
15158
15198
  }, z$1.core.$strict>, z$1.ZodObject<{
15159
15199
  type: z$1.ZodLiteral<"plan">;
15160
15200
  productVersionId: z$1.ZodUUID;
15201
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
15161
15202
  }, z$1.core.$strict>, z$1.ZodObject<{
15162
15203
  type: z$1.ZodLiteral<"seats">;
15163
15204
  licenseKey: z$1.ZodString;
@@ -15469,6 +15510,7 @@ declare const apiOperations: {
15469
15510
  }, z$1.core.$strict>, z$1.ZodObject<{
15470
15511
  type: z$1.ZodLiteral<"plan">;
15471
15512
  productVersionId: z$1.ZodUUID;
15513
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
15472
15514
  }, z$1.core.$strict>, z$1.ZodObject<{
15473
15515
  type: z$1.ZodLiteral<"seats">;
15474
15516
  licenseKey: z$1.ZodString;
@@ -16204,6 +16246,7 @@ declare const apiOperations: {
16204
16246
  }, z$1.core.$strict>, z$1.ZodObject<{
16205
16247
  type: z$1.ZodLiteral<"plan">;
16206
16248
  productVersionId: z$1.ZodUUID;
16249
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
16207
16250
  }, z$1.core.$strict>, z$1.ZodObject<{
16208
16251
  type: z$1.ZodLiteral<"seats">;
16209
16252
  licenseKey: z$1.ZodString;
@@ -16392,6 +16435,7 @@ declare const apiOperations: {
16392
16435
  }, z$1.core.$strict>, z$1.ZodObject<{
16393
16436
  type: z$1.ZodLiteral<"plan">;
16394
16437
  productVersionId: z$1.ZodUUID;
16438
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
16395
16439
  }, z$1.core.$strict>, z$1.ZodObject<{
16396
16440
  type: z$1.ZodLiteral<"seats">;
16397
16441
  licenseKey: z$1.ZodString;
@@ -18807,6 +18851,7 @@ declare const apiOperations: {
18807
18851
  TRY: "TRY";
18808
18852
  RON: "RON";
18809
18853
  }>;
18854
+ intent: z$1.ZodOptional<z$1.ZodLiteral<"subscription_change">>;
18810
18855
  }, z$1.core.$strict>>;
18811
18856
  paywallId: z$1.ZodOptional<z$1.ZodUUID>;
18812
18857
  customerId: z$1.ZodOptional<z$1.ZodString>;
@@ -18878,6 +18923,7 @@ declare const apiOperations: {
18878
18923
  topup: "topup";
18879
18924
  }>;
18880
18925
  membershipId: z$1.ZodNullable<z$1.ZodString>;
18926
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
18881
18927
  currency: z$1.ZodEnum<{
18882
18928
  USD: "USD";
18883
18929
  EUR: "EUR";
@@ -19228,6 +19274,7 @@ declare const apiOperations: {
19228
19274
  TRY: "TRY";
19229
19275
  RON: "RON";
19230
19276
  }>;
19277
+ intent: z$1.ZodOptional<z$1.ZodLiteral<"subscription_change">>;
19231
19278
  }, z$1.core.$strict>;
19232
19279
  locale: z$1.ZodString;
19233
19280
  requirement: z$1.ZodOptional<z$1.ZodObject<{
@@ -19314,6 +19361,7 @@ declare const apiOperations: {
19314
19361
  topup: "topup";
19315
19362
  }>;
19316
19363
  membershipId: z$1.ZodNullable<z$1.ZodString>;
19364
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
19317
19365
  currency: z$1.ZodEnum<{
19318
19366
  USD: "USD";
19319
19367
  EUR: "EUR";
@@ -19423,6 +19471,7 @@ declare const apiOperations: {
19423
19471
  topup: "topup";
19424
19472
  }>;
19425
19473
  membershipId: z$1.ZodNullable<z$1.ZodString>;
19474
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
19426
19475
  currency: z$1.ZodEnum<{
19427
19476
  USD: "USD";
19428
19477
  EUR: "EUR";
@@ -19801,6 +19850,7 @@ declare const apiOperations: {
19801
19850
  TRY: "TRY";
19802
19851
  RON: "RON";
19803
19852
  }>;
19853
+ intent: z$1.ZodOptional<z$1.ZodLiteral<"subscription_change">>;
19804
19854
  }, z$1.core.$strict>;
19805
19855
  requirement: z$1.ZodOptional<z$1.ZodObject<{
19806
19856
  internal_feature_id: z$1.ZodUUID;
@@ -19849,6 +19899,7 @@ declare const apiOperations: {
19849
19899
  topup: "topup";
19850
19900
  }>;
19851
19901
  membershipId: z$1.ZodNullable<z$1.ZodString>;
19902
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
19852
19903
  currency: z$1.ZodEnum<{
19853
19904
  USD: "USD";
19854
19905
  EUR: "EUR";
@@ -19968,6 +20019,7 @@ declare const apiOperations: {
19968
20019
  topup: "topup";
19969
20020
  }>;
19970
20021
  membershipId: z$1.ZodNullable<z$1.ZodString>;
20022
+ featureQuantities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodUUID, z$1.ZodNumber>>;
19971
20023
  currency: z$1.ZodEnum<{
19972
20024
  USD: "USD";
19973
20025
  EUR: "EUR";
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-MPD3UIY4.js";import"./chunk-CWD36SJO.js";import"./chunk-5JRBCW6V.js";import"./chunk-TL67SYPH.js";import"./chunk-6XRXHFM6.js";import"./chunk-GPJF3T43.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
@@ -0,0 +1 @@
1
+ import{A as me,E as rt,b as qe,c as $e,d as Se,h as He,i as Ke,j as Ye,n as We,q as Xe,z as nt}from"./chunk-ANXDWUPK.js";import{a as tt}from"./chunk-67SIVUOS.js";import{c as Ne,d as Te,e as _e,f as Le,g as De,i as Ue,m as ke,n as M,o as Ge,q as be,r as _,s as je,t as ze,u as Be,v as Je}from"./chunk-HLCDAU5A.js";import{K as U,e as Ve,q as ve,r as Me}from"./chunk-DCZWNTG2.js";import{a as fe,b as Ze}from"./chunk-LUGZNBIW.js";import{a as le}from"./chunk-LSVTH3TS.js";import{e as de}from"./chunk-3SXPCVIP.js";import{a as D}from"./chunk-TL67SYPH.js";import{h as ie}from"./chunk-6XRXHFM6.js";import{b as et}from"./chunk-3VUPVXAV.js";import{b as Qe}from"./chunk-ZICZN6WO.js";import{b as e}from"./chunk-GPJF3T43.js";import{c as Fe,f as Pe}from"./chunk-C4NG6RVA.js";var j=e.literal(Ve),ht=e.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),xe=e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),ot=e.discriminatedUnion("type",[e.strictObject({type:e.literal("guest"),guestToken:xe}),e.strictObject({type:e.literal("customer"),customer:ve,customerData:Me.optional()})]),Ee=e.strictObject({id:e.uuid(),runId:e.uuid(),customerId:e.uuid(),requestId:e.uuid(),acceptedAt:e.iso.datetime({offset:!0})}),yt=e.strictObject({participantId:e.uuid(),startedAs:e.enum(["guest","identified"]),binding:Ee.omit({runId:!0,requestId:!0}).nullable()}),wt=e.union([qe,e.strictObject({type:e.literal("authentication_required"),reason:e.enum(["customer_required","customer_experiment_required"]),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()})]),It=$e.omit({authenticated:!0}).extend({identity:yt,instruction:wt.nullable()}),vt=e.discriminatedUnion("operation",[U.options[2].omit({customerToken:!0}),U.options[3].omit({customerToken:!0}),U.options[4].omit({customerToken:!0}),U.options[5].omit({customerToken:!0}),U.options[6].omit({customerToken:!0}),U.options[7].omit({customerToken:!0})]),pe={contract:j,customerToken:e.string().regex(le)},it={contract:j,requestId:e.uuid(),runToken:ht,externalUserId:ve.options[1].shape.value},at=e.discriminatedUnion("operation",[e.strictObject({contract:j,operation:e.literal("describe")}),e.strictObject({contract:j,operation:e.literal("start"),source:ot,funnelId:U.options[0].shape.funnelId,requestId:e.uuid(),locale:U.options[0].shape.locale,parameters:U.options[0].shape.parameters}),He.omit({operation:!0}).extend({contract:j,operation:e.literal("entry_start"),source:ot}),e.strictObject({...it,operation:e.literal("bind_customer"),guestToken:xe,claimRequestId:e.uuid(),expectedBindingId:e.null()}),e.strictObject({...it,operation:e.literal("binding_status"),guestToken:xe.optional()}),U.options[1].omit({operation:!0,customerToken:!0}).extend({...pe,operation:e.literal("get"),settlementBindingId:e.uuid().nullable().optional()}),U.options[8].omit({operation:!0,customerToken:!0}).extend({...pe,operation:e.literal("review")}),Ye.omit({customerToken:!0}).extend(pe),e.strictObject({...pe,operation:e.literal("command"),identity:e.strictObject({bindingId:e.uuid().nullable()}),command:vt})]),bt=Se.omit({run:!0}).extend({contract:j,run:It,settlement:Se.shape.settlement.unwrap().extend({accepted:e.boolean().nullable().optional()}).optional()}),Dt=Ke.extend({contract:j}),Ut=e.discriminatedUnion("operation",[at.options[1].omit({contract:!0,source:!0,requestId:!0}),at.options[2].omit({contract:!0,source:!0,requestId:!0})]),Vt=bt.extend({binding:Ee,outcome:e.enum(["bound","already_bound"]),replayed:e.boolean()}),Mt=e.discriminatedUnion("state",[e.strictObject({contract:j,scope:ie,state:e.literal("not_accepted")}),e.strictObject({contract:j,scope:ie,state:e.literal("conflict")}),e.strictObject({contract:j,scope:ie,state:e.literal("bound"),binding:Ee})]),kt=e.strictObject({contract:j,scope:ie,keyId:e.uuid(),operations:e.array(e.string()).max(20)});var st=e.string().regex(/^[a-f0-9]{64}$/),St=Ne.omit({variations:!0,active:!0}).extend({changeId:st,variations:e.array(e.strictObject({urlRedirect:e.string().max(2048)})).min(2).max(20)}),ut=e.strictObject({environmentId:e.uuid(),trackExposures:e.boolean(),generation:st,experiments:e.array(St).max(100),savedGroups:Te}),xt=e.strictObject({eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}).optional(),deviceId:e.string().min(1).max(128),sessionId:e.string().min(1).max(128).optional(),url:e.url().max(2048),pageTitle:e.string().max(512).optional(),experimentKey:e.string().min(1).max(255),variationKey:e.string().min(1).max(64)}),Bt=e.strictObject({events:e.array(xt).min(1).max(20)}),Jt=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejected:e.array(e.strictObject({index:e.number().int().nonnegative(),reason:e.string()}))});function Wt(r){let a=null,g=null,O=0,v=0,C=new Set,l=null,w=null,m=new Set,b=()=>{for(let s of m)try{s()}catch{}},d={attributes:de.parse(r.attributes??{}),onFeatureUsage:r.onFeatureUsage?(s,I)=>{!C.has(s)&&a&&(!("analyticsConfig"in a)||a.analyticsConfig.featureUsageEnabled)&&r.onFeatureUsage(s,structuredClone(I),structuredClone(d.attributes),a.generation)}:void 0,onExperimentViewed:r.onExperimentViewed?(s,I)=>a&&(!("analyticsConfig"in a)||a.analyticsConfig.experimentViewsEnabled)&&r.onExperimentViewed(structuredClone(s),structuredClone(I),structuredClone(d.attributes),a.generation):void 0,stickyBucketAssignmentDocs:structuredClone(r.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:r.saveStickyBucketAssignmentDoc?s=>r.saveStickyBucketAssignmentDoc(structuredClone(s)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},S=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function h(s,I=new Set){return C.has(s)?!l||!l.features[s]||["unknownFeature","cyclicPrerequisite"].includes(l.features[s].source):I.has(s)?!1:(I.add(s),(a?.features[s]?.rules??[]).some(F=>[...F.parentConditions??[],...(F.tracks??[]).flatMap(P=>P.experiment.parentConditions??[])].some(P=>h(P.id,I))))}let x=s=>{if(r.assertUsable?.(a?.generation),!a)throw new Error("Initialize the Feature client before evaluation");if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return l?.expiresAt&&Date.parse(l.expiresAt)<=Date.now()&&(l=null,d.features=a.features),C.has(s)?!l||l.expiresAt&&Date.parse(l.expiresAt)<=Date.now()?S():structuredClone(l.features[s]??S()):r.evaluateRemote&&(d.attributes?.merchandise||d.attributes?.merchandiseId)&&!l||h(s)?S():structuredClone(Pe(s,d))};async function V(){if(!a||!C.size&&!d.attributes?.merchandise&&!d.attributes?.merchandiseId)return;if(!r.evaluateRemote){if(C.size)throw new Error("Remote Feature evaluation requires a server loader");return}let s=v;if(w?.revision===s)return w.loading;let I=O,F=a,P=[...C],E=(async()=>{let y=Ue.parse(await r.evaluateRemote({attributes:structuredClone(d.attributes),features:P}));if(!(I!==O||s!==v||F!==a)){if(r.assertUsable?.(F.generation),y.generation!==F.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(P.some(T=>!Object.hasOwn(y.features,T))||Object.keys(y.features).some(T=>!C.has(T)))throw new Error("Invalid remote Feature results");if(d.attributes?.merchandise||d.attributes?.merchandiseId){if(!y.merchandiseContext)throw new Error("Server did not resolve merchandise context");d.attributes=de.parse({...d.attributes,...y.merchandiseContext})}l=structuredClone(y),d.features={...F.features,...Object.fromEntries(Object.entries(l.features).map(([T,J])=>[T,{defaultValue:J.value}]))},b()}})();w={revision:s,loading:E};try{await E}finally{w?.loading===E&&(w=null)}}function L(){V().catch(s=>{try{r.onError?.(s)}catch{}})}async function k(){if(g)return g;let s=O,I=(async()=>{let F=await r.load(),P="remoteFeatures"in F?Le.parse(F):null,E=P??_e.parse(F);if(E.scope.projectId!==r.scope.projectId||E.scope.environment!==r.scope.environment)throw new Error("Feature payload scope changed");if(s!==O)throw new Error("Feature client was reset");if(r.assertUsable&&a?.generation===E.generation){let{evaluatedAt:T,expiresAt:J,...ae}=a,{evaluatedAt:Z,expiresAt:ge,...z}=E;if(_(ae)!==_(z))throw new Error("Immutable Feature generation changed content");return a.evaluatedAt=E.evaluatedAt,a.expiresAt=E.expiresAt,b(),(!l||l.expiresAt&&Date.parse(l.expiresAt)<=Date.now())&&L(),structuredClone(a)}let y=new Set(P?.remoteFeatures??[]);if([...y].some(T=>Object.hasOwn(E.features,T)))throw new Error("Remote Feature definitions must not be delivered locally");return a&&"analyticsConfig"in a&&"analyticsConfig"in E&&!a.analyticsConfig.experimentViewsEnabled&&P?.analyticsConfig.experimentViewsEnabled&&d.trackedExperiments?.clear(),a=structuredClone(E),C=y,l=null,w=null,v++,d.features=a.features,d.savedGroups=Fe(a.savedGroups),d.trackedFeatureUsage={},b(),L(),structuredClone(a)})();g=I;try{return await I}finally{g===I&&(g=null)}}return{init:k,refresh:k,refreshRemote:V,get generation(){return a?.generation??null},get expiresAt(){return a?.expiresAt??null},subscribe(s){return m.add(s),()=>{m.delete(s)}},setAttributes(s){let I=de.parse(s);(d.attributes?.merchandise||d.attributes?.merchandiseId||s.merchandise||s.merchandiseId)&&d.trackedExperiments?.clear(),d.attributes=I,v++,l=null,w=null,d.features=a?.features??{},d.trackedFeatureUsage={},b(),L()},evalFeature:x,isOn(s){return x(s).on},isOff(s){return x(s).off},getFeatureValue(s,I){let F=x(s).value;return structuredClone(F===null?I:F)},reset(){O++,v++,g=null,w=null,a=null,l=null,C.clear(),d.features={},d.savedGroups={},d.stickyBucketAssignmentDocs={},d.attributes={},d.trackedFeatureUsage={},d.trackedExperiments?.clear(),b()}}}var Et=e.record(e.string().regex(/^[a-f0-9]{64}$/),e.strictObject({at:e.number(),text:e.string()})),Q=2*1048576,Ct=100;function Rt(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function ct(r,a){let g=a===void 0?Rt():a,O=new Map,v=0,C=!1,l=!1,w,m;async function b(S){if(!g)return null;let h;try{let x=await Promise.race([Promise.resolve().then(()=>g.getItem(S)),new Promise(V=>{h=setTimeout(()=>V(null),Ct)})]);return typeof x=="string"&&x.length<=Q&&new TextEncoder().encode(x).byteLength<=Q?x:null}catch{return null}finally{clearTimeout(h)}}function d(){if(m)return m;let S=(async()=>{try{let h=await b(`${r}:artifacts`);if(h)return Et.parse(JSON.parse(h))}catch{}return{}})();return m=S,S.finally(()=>{m===S&&(m=void 0)}),S}return{async readManifest(){return b(r)},writeManifest(S){!g||S.length>Q||new TextEncoder().encode(S).byteLength>Q||(w=S,!l&&(l=!0,Promise.resolve().then(async()=>{try{for(;w!==void 0;){let h=w;try{await g.setItem(r,h)}catch{}w===h&&(w=void 0)}}finally{l=!1}})))},async readArtifact(S){let h=(await d())[S],x=Date.now();return h&&x>=h.at&&x-h.at<=M.retentionMs?h.text:void 0},writeArtifact(S,h){if(!g||h.length>Q)return;let x=O.get(S);if(x?.text===h||!x&&O.size>=128)return;let V=new TextEncoder().encode(h).byteLength;v-(x?.byteLength??0)+V>Q||(O.set(S,{text:h,byteLength:V}),v+=V-(x?.byteLength??0),!C&&(C=!0,Promise.resolve().then(async()=>{try{for(;O.size;){let L=new Map(O);try{let k={...await d()},s=Date.now();for(let[E,y]of L)k[E]={at:s,text:y.text};let I={},F=2,P=0;for(let[E,y]of Object.entries(k).sort(([,T],[,J])=>J.at-T.at)){if(y.at>s||s-y.at>M.retentionMs)continue;let T=new TextEncoder().encode(JSON.stringify({[E]:y})).byteLength;F+T>Q||P>=128||(I[E]=y,F+=T,P++)}await g.setItem(`${r}:artifacts`,JSON.stringify(I))}catch{}finally{for(let[k,s]of L)O.get(k)===s&&(O.delete(k),v-=s.byteLength)}}}finally{C=!1}})))}}}var u=(r,a)=>new D(r,a),B=()=>performance.now(),lt=r=>{typeof r=="object"&&"unref"in r&&r.unref()};function pn(r){let a=Ge.parse(r.scope),g=new fe(r.origin??Qe);if(g.username||g.password||g.search||g.hash||g.pathname!=="/"||g.protocol!=="https:"&&!(g.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(g.hostname)))throw u("INVALID_URL","Configuration requires a trusted HTTPS origin");let O=new Set([g.origin,...(r.assetOrigins??[]).map(t=>{let n=new fe(t);if(n.protocol!=="https:"||n.username||n.password||n.search||n.hash||n.pathname!=="/")throw u("INVALID_URL","Invalid configuration asset origin");return n.origin})]),v=r.fetch??globalThis.fetch.bind(globalThis),C=`/api/v1/configuration/${a.environmentId}`,l=`indiana:configuration:1:${g.origin}:${_(a)}`,w=ct(l,r.storage),m,b=0,d=0,S=!1,h=!1,x=0,V=0,L,k,s,I,F=0,P=new Set,E=new Set,y=new Map,T=new Map,J=0,ae=!1;function Z(){for(let t of P)try{t()}catch{}}function ge(t){try{r.onError?.(t)}catch{}}let z=()=>!h&&!S&&!!m&&B()<b&&Date.now()<d;function re(){if(!z())throw u("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function Ce(t,n,i){if(!y.has(t)){for(;y.size&&(y.size>=128||J+i>M.maxCacheBytes);){let o=y.entries().next().value;J-=o[1].byteLength,y.delete(o[0])}y.set(t,{text:n,byteLength:i}),J+=i}}function he(t,n,i){return et(t,n,{signal:i,error:o=>u("INVALID_RESPONSE",o==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function ye(t){let n=new fe(t,g);if(!O.has(n.origin)||n.username||n.password||n.hash||n.search)throw u("INVALID_URL","Configuration artifact origin is not trusted");return n.href}async function we(t,n,i=!1){let o=await v(ye(t),{method:"GET",credentials:"omit",redirect:"error",cache:i?"default":"no-cache",signal:n,headers:{}});if(o.status===429){let f=o.headers.get("retry-after")??"";F=/^\d+$/.test(f)?Number(f)*1e3:Math.max(0,Date.parse(f)-Date.now())||15e3}if(!o.ok&&o.status!==304)throw u(`CONFIGURATION_HTTP_${o.status}`,"Configuration synchronization failed");return o}function ft(t,n,i){let o=Date.parse(t.headers.get("x-indiana-config-validated-at")??""),f=Date.parse(t.headers.get("x-indiana-config-valid-until")??""),p=Date.parse(t.headers.get("date")??""),c=t.headers.get("age"),R=c!==null&&/^\d+(\.\d+)?$/.test(c)?Number(c)*1e3:NaN;if(![o,f,p,R].every(Number.isFinite)||f<=o||f-o>M.maxControlAgeMs||o>p+1e3)throw u("INVALID_RESPONSE","Configuration freshness evidence is invalid");let A=Math.min(f-o,i.maxControlAgeSeconds*1e3,M.maxControlAgeMs)-Math.max(R,p-o,0)-(B()-n);if(A<=0)throw u("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return B()+A}function se(){if(clearTimeout(s),clearTimeout(I),h||!P.size||(z()&&(I=setTimeout(()=>{z()?se():Z()},Math.max(1,b-B())),lt(I)),typeof document<"u"&&document.visibilityState==="hidden"))return;let t=V?Math.min(15e3,1e3*2**Math.min(V-1,4)):Math.min(15e3,(m?.policy.refreshIntervalSeconds??15)*1e3);s=setTimeout(()=>{X().catch(ge)},Math.max(F,t*(.8+Math.random()*.2))),lt(s)}async function X(){if(h)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(L)return L;let t=x,n=new AbortController;k=n;let i=(async()=>{if(!ae){ae=!0;try{let ce=await w.readManifest();if(ce&&!m){let $=be.parse(JSON.parse(ce));_($.scope)===_(a)&&(m=$)}}catch{}}n.signal.throwIfAborted();let c=m,R=B(),N=await we(C,n.signal);N.status===304&&(!c||!N.headers.has("x-indiana-config-validated-at")||!N.headers.has("x-indiana-config-valid-until")||!N.headers.has("age"))&&(N=await we(C,n.signal));let A=N.status===304?c:be.parse(JSON.parse(await he(N,M.maxManifestBytes,n.signal))),{generation:G,...ne}=A,q=N.headers.get("etag");if(_(A.scope)!==_(a)||ze(ne)!==G||q!==`"${G}"`&&q!==`W/"${G}"`)throw u("INVALID_RESPONSE","Configuration scope or content identity changed");if(c&&(A.revision<c.revision||A.revision===c.revision&&A.generation!==c.generation))throw u("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[ce,$]of Object.entries(c?.funnels??{})){let W=A.funnels[ce];if(W&&(W.controlRevision<$.controlRevision||W.evaluationRevision<$.evaluationRevision||W.controlRevision===$.controlRevision&&W.state!==$.state||W.evaluationRevision===$.evaluationRevision&&W.evaluationMode!==$.evaluationMode))throw u("INVALID_RESPONSE","Funnel control revision changed identity")}let Y=ft(N,R,A.policy);if(n.signal.throwIfAborted(),t!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return m=A,b=Y,d=Date.now()+Math.max(0,Y-B()),S=!1,V=0,F=0,w.writeManifest(_(A)),Z(),structuredClone(A)})(),o=setTimeout(()=>n.abort(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),M.initializationMs),f=new Promise((c,R)=>n.signal.addEventListener("abort",()=>R(n.signal.reason),{once:!0})),p=Promise.race([i,f]).catch(c=>{throw V++,(c instanceof e.ZodError||c instanceof SyntaxError||c instanceof D&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(c.code))&&(b=0,S=!0,Z()),c}).finally(()=>{clearTimeout(o),L===p&&(L=void 0),se()});return L=p,p}async function ue(t){let n=t.sha256,i=ne=>tt(ne,t);ye(t.url);let o=y.get(n);if(o){if(o.byteLength!==t.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return y.delete(n),y.set(n,o),o.text}let f=T.get(n);if(f){if(f.byteLength!==t.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return f.promise}let p=new AbortController;E.add(p);let c=x,R=(async()=>{try{let Y=await w.readArtifact(n);if(Y&&i(Y)){if(p.signal.throwIfAborted(),h||c!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return Ce(n,Y,t.byteLength),Y}}catch{}p.signal.throwIfAborted();let ne=await we(t.url,p.signal,!0),q=await he(ne,t.byteLength,p.signal);if(!i(q))throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(h||c!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return Ce(n,q,t.byteLength),w.writeArtifact(n,q),q})(),N=setTimeout(()=>p.abort(u("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),M.initializationMs),A=new Promise((ne,q)=>p.signal.addEventListener("abort",()=>q(p.signal.reason),{once:!0})),G=Promise.race([R,A]).finally(()=>{clearTimeout(N),E.delete(p),T.delete(n)});return T.set(n,{promise:G,byteLength:t.byteLength}),G}async function ee(){return z()||await X(),re(),m}async function K(t){let n,i=new Promise((o,f)=>{n=setTimeout(()=>f(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),M.initializationMs)});try{return await Promise.race([t(),i])}finally{clearTimeout(n)}}function H(t,n){if(re(),m?.generation!==t.generation)throw u("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(n&&m.funnels[n]?.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function Re(t){let n=t.gb.features;if(!n)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let i=t.artifacts[n];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let o=De.parse(JSON.parse(await ue(i)));if(_(o.scope)!==_({projectId:a.projectId,environment:a.environment})||o.generation!==i.generation||o.remoteFeatures.some(f=>Object.hasOwn(o.features,f)))throw u("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return H(t),{...o,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,b-B())).toISOString()}}async function Oe(t,n){let i=await ee(),o=i.funnels[t];n&&(!o||o.evaluationMode==="local"&&!o.versions[n])&&(L&&await L,i=await X()),H(i,t);let f=i.funnels[t];if(f.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let p=n??f.currentVersionId,c=f.versions[p];if(!c)throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(i.artifacts[c.artifact].formatVersion!==3)throw u("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[R,N]=await Promise.all([ue(i.artifacts[c.artifact]).then(A=>Je(JSON.parse(A))),f.evaluationMode==="local"?Re(i):void 0]);if(N&&_(Be(R,N))!==_(c.dependencies))throw u("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return H(i,t),{document:R,growth:N,versionId:p,control:structuredClone(f),manifest:structuredClone(i)}}async function Ie(t,n){try{return await Oe(t,n)}catch(i){if(!(i instanceof D)||!(i.code==="CONFIGURATION_CHANGED"||i.code==="CONFIGURATION_HTTP_404"&&z()))throw i;let o=m?.generation;if(L&&await L,await X(),i.code!=="CONFIGURATION_CHANGED"&&m?.generation===o)throw i;return Oe(t,n)}}let oe=new Map;async function mt(t,n){let{FUNNEL_ROUTE_LIMITS:i,funnelRouteSchema:o}=await import("./funnel-route-source-O76QSUYU.js"),f=new AbortController;E.add(f);let p=setTimeout(()=>f.abort(u("CONFIGURATION_UNAVAILABLE","Funnel route read timed out")),M.initializationMs);try{let c=await v(ye(`${C}/funnels/${t}/versions/${n}/route`),{method:"GET",credentials:"omit",redirect:"error",cache:"no-cache",signal:f.signal,headers:{}});if(c.status===404)throw u("ROUTE_UNAVAILABLE","This Funnel Version publishes no route");if(!c.ok)throw u(`CONFIGURATION_HTTP_${c.status}`,"Funnel route read failed");let R=await he(c,i.maxBytes,f.signal),N=je(R),A=c.headers.get("etag");if(A!==`"${N}"`&&A!==`W/"${N}"`)throw u("INVALID_RESPONSE","Funnel route identity changed");let G=o.safeParse(JSON.parse(R));if(!G.success||G.data.funnelId!==t||G.data.versionId!==n)throw u("INVALID_RESPONSE","Funnel route does not describe this Version");return G.data}finally{clearTimeout(p),E.delete(f)}}async function pt(t){let n=await ee();H(n,t);let i=n.funnels[t],o=i.currentVersionId,f;if(i.evaluationMode==="local"){let{projectFunnelRoute:p}=await import("./funnel-route-source-O76QSUYU.js"),c=await Ie(t,o),R=Object.entries(c.manifest.paywalls??{});f=p({funnelId:t,versionId:o,document:c.document,experiments:c.growth?.experiments??{},paywallOf:N=>R.find(([,A])=>Object.hasOwn(A.versions,N))?.[0]})}else{let p=`${t}:${o}`,c=oe.get(p);if(!c||B()-c.readAt>=M.maxControlAgeMs){let R={promise:mt(t,o),readAt:B()};oe.set(p,R),R.promise.catch(()=>{oe.get(p)===R&&oe.delete(p)}),c=R}f=await c.promise}return H(n,t),{route:structuredClone(f),control:structuredClone(i),generation:n.generation}}function te(){if(z()||Z(),typeof document<"u"&&document.visibilityState==="hidden"){se();return}X().catch(ge)}function gt(t){if(h)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return P.add(t),P.size===1&&(typeof window<"u"&&(window.addEventListener("online",te),window.addEventListener("focus",te),document.addEventListener("visibilitychange",te)),se()),()=>{P.delete(t),P.size||(clearTimeout(s),clearTimeout(I),Ae())}}function Ae(){typeof window<"u"&&(window.removeEventListener("online",te),window.removeEventListener("focus",te),document.removeEventListener("visibilitychange",te))}return{scope:Object.freeze({...a}),refresh:X,subscribe:gt,assertFresh:re,assertFeatures(t){re();let n=m.gb.features;if(!n)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(t!==void 0&&m.artifacts[n].generation!==t)throw u("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return z()},get snapshot(){return m?structuredClone(m):null},get remainingMs(){return z()?Math.max(0,b-B()):0},async features(){return K(async()=>Re(await ee()))},pageExperiments:()=>K(async()=>{let t=await ee(),n=t.gb.pageExperiments;if(!n)throw u("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let i=t.artifacts[n];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let o=ut.parse(JSON.parse(await ue(i)));if(o.environmentId!==a.environmentId||o.generation!==i.generation)throw u("INVALID_RESPONSE","Page experiment scope or generation changed");return H(t),o}),funnel:(t,n)=>K(()=>Ie(t,n)),funnelControl:t=>K(async()=>{let n=await ee();return H(n,t),structuredClone(n.funnels[t])}),funnelRoute:t=>K(()=>pt(t)),paywall:(t,n)=>K(async()=>{let i=await ee(),o=i.paywalls?.[t];if(!o||!n&&o.state!=="published")throw u("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let f=n??o.currentVersionId,p=o.versions[f],c=p&&i.artifacts[p.artifact];if(!c||c.kind!=="paywall"||c.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let R=ke.parse(JSON.parse(await ue(c)));return H(i),{document:R,versionId:f,version:p.version,control:structuredClone(o),manifest:structuredClone(i)}}),async localFunnel(t,n){let i=await K(()=>Ie(t,n));if(!i.growth)throw u("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:o,remoteFeatures:f,...p}=i.growth;return We({scope:{projectId:a.projectId,environment:a.environment},funnelId:t,versionId:i.versionId,evaluationMode:"local",evaluationRevision:i.control.evaluationRevision,document:i.document,payload:p})},assertFunnel(t,n,i){re();let o=m.funnels[t];if(!o||o.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable");if(o.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel now executes at Longplay");if(n!==void 0&&o.controlRevision!==n)throw u("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(i!==void 0&&!o.versions[i])throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!h){h=!0,x++,b=0,k?.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(s),clearTimeout(I),Ae(),Z(),P.clear();for(let t of E)t.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));y.clear(),oe.clear(),J=0}}}}function dt(r){let a=le.test(r.apiKey);if(typeof window<"u"&&!a)throw new D("SERVER_ONLY","Funnel starts are issued by your backend");if(!a&&!me.test(r.apiKey))throw new D("INVALID_TOKEN","A customer credential or server API key is required");return{async start(g){let O=U.safeParse({...g,operation:"start"});if(!O.success||O.data.operation!=="start"||(a?O.data.customer!==void 0:O.data.customer===void 0))throw new D("INVALID_REQUEST","Invalid current Funnel start");let v=O.data,C=Ze({...r,timeoutMs:r.timeoutMs??35e3});try{r.session||C.identify(r.apiKey);let l=Xe(r,await C.request("funnels",v));if(!l.runToken)throw new D("INVALID_RESPONSE","Funnel start credentials are missing");if(l.run.source.id!==v.funnelId||l.run.locale!==(v.locale??"en")||!nt(l.run.parameters,v.parameters??{})||(v.customer?!l.customerId||v.customer.type==="id"&&l.customerId!==v.customer.value:l.customerId!==void 0))throw new D("INVALID_RESPONSE","Funnel start contract changed");return{...l,runToken:l.runToken}}finally{C.dispose()}}}}async function An(r){r={...r};let a=r.configuration;if(!a)throw new D("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let g={projectId:a.scope.projectId,environment:a.scope.environment};if(r.scope&&_(g)!==_(r.scope))throw new D("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await a.funnelControl(r.funnelId)).evaluationMode!=="local")throw new D("EVALUATION_MODE","This Funnel uses Remote evaluation");let v=me.test(r.credential);if(v?!r.customerId:r.customerId!==void 0)throw new D("INVALID_REQUEST","Only Server-Key starts name their Customer");let C=dt({...r,scope:g,apiKey:r.credential}),l=(w,m)=>{let b=rt({...r,scope:g,runToken:w,initialResponse:m,...v?{serverKey:r.credential}:{}});return v||b.identify(r.credential),b};return{async start(w){let m=await C.start({...w,funnelId:r.funnelId,...v?{customer:{type:"id",value:r.customerId}}:{}}),b=l(m.runToken,m),d=await b.get();return{...m,...d,controller:b}},async restore(w){let m=l(w),b=await m.get();if(b.run.source.id!==r.funnelId)throw m.reset(),new D("SCOPE_MISMATCH","Run belongs to another Funnel");return{...b,runToken:w,controller:m}}}}export{at as a,bt as b,Dt as c,Ut as d,Vt as e,Mt as f,kt as g,Wt as h,pn as i,dt as j,An as k};