@tinkerlandai/longplay-sdk 0.10.59 → 0.10.61
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.
- package/CHANGELOG.md +9 -0
- package/README.md +3 -2
- package/README.zh-CN.md +3 -2
- package/dist/{ai-usage-DBcYB8ix.d.ts → ai-usage-DM3jAubK.d.ts} +1 -1
- package/dist/{api-1Tplv-7M.d.ts → api-KIp0I50M.d.ts} +21 -21
- package/dist/{chunk-LUDTXNMH.js → chunk-24EPEF3N.js} +1 -1
- package/dist/{chunk-FBNEQ2K5.js → chunk-2KM537QH.js} +1 -1
- package/dist/{chunk-U2NEVISJ.js → chunk-4VCPJSRS.js} +1 -1
- package/dist/{chunk-725CAWOK.js → chunk-DCZUPVAI.js} +1 -1
- package/dist/{chunk-J7VGTAJ7.js → chunk-FEBXEBDK.js} +1 -1
- package/dist/{chunk-J3RW4GMO.js → chunk-HNNJ2RVS.js} +1 -1
- package/dist/chunk-IHA7BSU3.js +1 -0
- package/dist/{chunk-J5K4PNII.js → chunk-IM5OXTEH.js} +1 -1
- package/dist/chunk-KCLHX3Y5.js +1 -0
- package/dist/{chunk-66W37FEV.js → chunk-LH67TSR2.js} +1 -1
- package/dist/chunk-QXDLOPZK.js +1 -0
- package/dist/{chunk-YB3PQ75M.js → chunk-SQRNYT2W.js} +2 -2
- package/dist/{chunk-WUPNZGE2.js → chunk-WBBP25Q2.js} +1 -1
- package/dist/{chunk-6426YKPK.js → chunk-X6VBLJHA.js} +1 -1
- package/dist/chunk-X7V7AAWG.js +1 -0
- package/dist/{chunk-MZ6NEOOQ.js → chunk-XZLGDFZ4.js} +1 -1
- package/dist/{configuration-sync-DeWWW5za.d.ts → configuration-sync-Dad8B5Pv.d.ts} +3 -3
- package/dist/{content-5OMLKBPP.js → content-CXXLVFDH.js} +1 -1
- package/dist/{funnel-host-purchase-53LYWG4V.js → funnel-host-purchase-RFDAZBS6.js} +1 -1
- package/dist/{funnel-host-recovery-paywall-FC3XQU2U.js → funnel-host-recovery-paywall-HQI6ZBRL.js} +1 -1
- package/dist/{funnel-local-client-Fxsyl7rh.d.ts → funnel-local-client-Cb9jJGpo.d.ts} +53 -53
- package/dist/{funnel-paywall-prerender-YCATKDAY.js → funnel-paywall-prerender-RMSOP32P.js} +1 -1
- package/dist/{funnel-process-client-D9saqPse.d.ts → funnel-process-client-DE650LzB.d.ts} +28 -28
- package/dist/{funnel-runtime-host-LQ6X5B6R.js → funnel-runtime-host-FI4TYAXG.js} +1 -1
- package/dist/index.d.ts +23 -15
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/{paywall-KQIBPACY.js → paywall-VMEEMKO4.js} +1 -1
- package/dist/{paywall-content-NQXU3O4D.js → paywall-content-JGK22QA7.js} +1 -1
- package/dist/{paywall-session-W42F6DIF.js → paywall-session-UTQVXDY4.js} +1 -1
- package/dist/popup.d.ts +23 -3
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-CjljfuJq.d.ts → presentation-loading-B8W6a9WB.d.ts} +10 -46
- package/dist/react-native.d.ts +7 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-renderer-2ZDV2WYD.js → screen-renderer-3YO6EUWD.js} +1 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-IMFPRZUY.js +0 -1
- package/dist/chunk-O2V4MTM6.js +0 -1
- package/dist/chunk-PTNMDAND.js +0 -1
- package/dist/chunk-XY2X6YJF.js +0 -1
- package/dist/{chunk-YB3PQ75M.js.LEGAL.txt → chunk-SQRNYT2W.js.LEGAL.txt} +0 -0
- package/dist/{funnel-node-evaluation-CRRTh1je.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -3
- package/dist/{screen-D2bUmJ4M.d.ts → screen-Pv_pViF6.d.ts} +21 -21
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { n as FeatureClientOptions, I as IndianaOptions, C as CustomerSession, R as RemoteFeatureResult, O as PushAddressObservation, d as FunnelStartInput, r as FunnelRuntimeResponse, o as FunnelControllerResponse, B as createFunnelRunController, Q as FunnelProcessOpenInput, T as FunnelProcessResponse, U as FunnelCommand, V as FunnelProcessMutation, W as FunnelPageExperimentsResponse, k as FunnelProcessRunView, h as FunnelRunController } from './funnel-local-client-
|
|
4
|
-
import { A as ApiInput, O as OfferingItem, I as InvoiceModeParams, a as ApiOutput } from './api-
|
|
3
|
+
import { n as FeatureClientOptions, I as IndianaOptions, C as CustomerSession, R as RemoteFeatureResult, O as PushAddressObservation, d as FunnelStartInput, r as FunnelRuntimeResponse, o as FunnelControllerResponse, B as createFunnelRunController, Q as FunnelProcessOpenInput, T as FunnelProcessResponse, U as FunnelCommand, V as FunnelProcessMutation, W as FunnelPageExperimentsResponse, k as FunnelProcessRunView, h as FunnelRunController } from './funnel-local-client-Cb9jJGpo.js';
|
|
4
|
+
import { A as ApiInput, O as OfferingItem, I as InvoiceModeParams, a as ApiOutput } from './api-KIp0I50M.js';
|
|
5
5
|
import { O as Offer } from './coupon-kfkIVf9n.js';
|
|
6
|
-
import { S as StackNode } from './screen-
|
|
6
|
+
import { S as StackNode } from './screen-Pv_pViF6.js';
|
|
7
7
|
import { J as JsonValue, F as FeatureResult } from './growth-rules-B4YYy64R.js';
|
|
8
8
|
|
|
9
9
|
/** The store supplies the intent hint. Only verified provider facts prove ownership. */
|
|
@@ -1714,7 +1714,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
1714
1714
|
type: "forever";
|
|
1715
1715
|
};
|
|
1716
1716
|
renewalAmountMinor: number;
|
|
1717
|
-
status: "
|
|
1717
|
+
status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
|
|
1718
1718
|
url: string | null;
|
|
1719
1719
|
} | {
|
|
1720
1720
|
type: "subscription";
|
|
@@ -2233,7 +2233,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
2233
2233
|
operationId: string;
|
|
2234
2234
|
membershipId: string;
|
|
2235
2235
|
productVersionId: string;
|
|
2236
|
-
status: "
|
|
2236
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
2237
2237
|
timing: "immediate" | "renewal";
|
|
2238
2238
|
effectiveAt: string;
|
|
2239
2239
|
checkoutUrl: string | null;
|
|
@@ -3223,7 +3223,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
3223
3223
|
operationId: string;
|
|
3224
3224
|
membershipId: string;
|
|
3225
3225
|
productVersionId: string;
|
|
3226
|
-
status: "
|
|
3226
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
|
|
3227
3227
|
timing: "store";
|
|
3228
3228
|
effectiveAt: string | null;
|
|
3229
3229
|
checkoutUrl: null;
|
|
@@ -3275,7 +3275,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
3275
3275
|
operationId: string;
|
|
3276
3276
|
membershipId: string;
|
|
3277
3277
|
productVersionId: string;
|
|
3278
|
-
status: "
|
|
3278
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
3279
3279
|
timing: "immediate" | "renewal";
|
|
3280
3280
|
effectiveAt: string;
|
|
3281
3281
|
checkoutUrl: string | null;
|
|
@@ -4265,7 +4265,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
4265
4265
|
operationId: string;
|
|
4266
4266
|
membershipId: string;
|
|
4267
4267
|
productVersionId: string;
|
|
4268
|
-
status: "
|
|
4268
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
|
|
4269
4269
|
timing: "store";
|
|
4270
4270
|
effectiveAt: string | null;
|
|
4271
4271
|
checkoutUrl: null;
|
|
@@ -4317,7 +4317,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
4317
4317
|
requestId: string;
|
|
4318
4318
|
orderId: string;
|
|
4319
4319
|
purchaseIntentId: string;
|
|
4320
|
-
status: "
|
|
4320
|
+
status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
|
|
4321
4321
|
currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
|
|
4322
4322
|
refunded: boolean;
|
|
4323
4323
|
completion: {
|
|
@@ -4752,7 +4752,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
4752
4752
|
operation: {
|
|
4753
4753
|
operationId: string;
|
|
4754
4754
|
orderId: string;
|
|
4755
|
-
status: "
|
|
4755
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
4756
4756
|
executor: "merchant" | "indiana";
|
|
4757
4757
|
checkoutUrl: string | null;
|
|
4758
4758
|
execution: {
|
|
@@ -5785,7 +5785,7 @@ declare function createIndiana(options: IndianaOptions): {
|
|
|
5785
5785
|
operation: {
|
|
5786
5786
|
operationId: string;
|
|
5787
5787
|
orderId: string;
|
|
5788
|
-
status: "
|
|
5788
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
5789
5789
|
executor: "merchant" | "indiana";
|
|
5790
5790
|
checkoutUrl: string | null;
|
|
5791
5791
|
execution: {
|
|
@@ -9638,7 +9638,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
9638
9638
|
type: "forever";
|
|
9639
9639
|
};
|
|
9640
9640
|
renewalAmountMinor: number;
|
|
9641
|
-
status: "
|
|
9641
|
+
status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
|
|
9642
9642
|
url: string | null;
|
|
9643
9643
|
} | {
|
|
9644
9644
|
type: "subscription";
|
|
@@ -10157,7 +10157,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
10157
10157
|
operationId: string;
|
|
10158
10158
|
membershipId: string;
|
|
10159
10159
|
productVersionId: string;
|
|
10160
|
-
status: "
|
|
10160
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
10161
10161
|
timing: "immediate" | "renewal";
|
|
10162
10162
|
effectiveAt: string;
|
|
10163
10163
|
checkoutUrl: string | null;
|
|
@@ -11147,7 +11147,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
11147
11147
|
operationId: string;
|
|
11148
11148
|
membershipId: string;
|
|
11149
11149
|
productVersionId: string;
|
|
11150
|
-
status: "
|
|
11150
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
|
|
11151
11151
|
timing: "store";
|
|
11152
11152
|
effectiveAt: string | null;
|
|
11153
11153
|
checkoutUrl: null;
|
|
@@ -11199,7 +11199,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
11199
11199
|
operationId: string;
|
|
11200
11200
|
membershipId: string;
|
|
11201
11201
|
productVersionId: string;
|
|
11202
|
-
status: "
|
|
11202
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
11203
11203
|
timing: "immediate" | "renewal";
|
|
11204
11204
|
effectiveAt: string;
|
|
11205
11205
|
checkoutUrl: string | null;
|
|
@@ -12189,7 +12189,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
12189
12189
|
operationId: string;
|
|
12190
12190
|
membershipId: string;
|
|
12191
12191
|
productVersionId: string;
|
|
12192
|
-
status: "
|
|
12192
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
|
|
12193
12193
|
timing: "store";
|
|
12194
12194
|
effectiveAt: string | null;
|
|
12195
12195
|
checkoutUrl: null;
|
|
@@ -12241,7 +12241,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
12241
12241
|
requestId: string;
|
|
12242
12242
|
orderId: string;
|
|
12243
12243
|
purchaseIntentId: string;
|
|
12244
|
-
status: "
|
|
12244
|
+
status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
|
|
12245
12245
|
currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
|
|
12246
12246
|
refunded: boolean;
|
|
12247
12247
|
completion: {
|
|
@@ -12676,7 +12676,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
12676
12676
|
operation: {
|
|
12677
12677
|
operationId: string;
|
|
12678
12678
|
orderId: string;
|
|
12679
|
-
status: "
|
|
12679
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
12680
12680
|
executor: "merchant" | "indiana";
|
|
12681
12681
|
checkoutUrl: string | null;
|
|
12682
12682
|
execution: {
|
|
@@ -13709,7 +13709,7 @@ declare function createCustomerClient(options: IndianaOptions): {
|
|
|
13709
13709
|
operation: {
|
|
13710
13710
|
operationId: string;
|
|
13711
13711
|
orderId: string;
|
|
13712
|
-
status: "
|
|
13712
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
13713
13713
|
executor: "merchant" | "indiana";
|
|
13714
13714
|
checkoutUrl: string | null;
|
|
13715
13715
|
execution: {
|
|
@@ -17655,7 +17655,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
17655
17655
|
operation: {
|
|
17656
17656
|
operationId: string;
|
|
17657
17657
|
orderId: string;
|
|
17658
|
-
status: "
|
|
17658
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
17659
17659
|
executor: "merchant" | "indiana";
|
|
17660
17660
|
checkoutUrl: string | null;
|
|
17661
17661
|
execution: {
|
|
@@ -18681,7 +18681,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
18681
18681
|
operationId: string;
|
|
18682
18682
|
membershipId: string;
|
|
18683
18683
|
productVersionId: string;
|
|
18684
|
-
status: "
|
|
18684
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
18685
18685
|
timing: "immediate" | "renewal";
|
|
18686
18686
|
effectiveAt: string;
|
|
18687
18687
|
checkoutUrl: string | null;
|
|
@@ -19687,7 +19687,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
19687
19687
|
visit: number;
|
|
19688
19688
|
stopped: boolean;
|
|
19689
19689
|
variables: Record<string, zod.JSONType>;
|
|
19690
|
-
nodeType: "output" | "action" | "
|
|
19690
|
+
nodeType: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
|
|
19691
19691
|
canBack: boolean;
|
|
19692
19692
|
pendingRequest: {
|
|
19693
19693
|
requestId: string;
|
|
@@ -21467,7 +21467,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
21467
21467
|
operation: {
|
|
21468
21468
|
operationId: string;
|
|
21469
21469
|
orderId: string;
|
|
21470
|
-
status: "
|
|
21470
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
21471
21471
|
executor: "merchant" | "indiana";
|
|
21472
21472
|
checkoutUrl: string | null;
|
|
21473
21473
|
execution: {
|
|
@@ -22493,7 +22493,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
22493
22493
|
operationId: string;
|
|
22494
22494
|
membershipId: string;
|
|
22495
22495
|
productVersionId: string;
|
|
22496
|
-
status: "
|
|
22496
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
22497
22497
|
timing: "immediate" | "renewal";
|
|
22498
22498
|
effectiveAt: string;
|
|
22499
22499
|
checkoutUrl: string | null;
|
|
@@ -23499,7 +23499,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
23499
23499
|
visit: number;
|
|
23500
23500
|
stopped: boolean;
|
|
23501
23501
|
variables: Record<string, zod.JSONType>;
|
|
23502
|
-
nodeType: "output" | "action" | "
|
|
23502
|
+
nodeType: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
|
|
23503
23503
|
canBack: boolean;
|
|
23504
23504
|
pendingRequest: {
|
|
23505
23505
|
requestId: string;
|
|
@@ -25279,7 +25279,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
25279
25279
|
operation: {
|
|
25280
25280
|
operationId: string;
|
|
25281
25281
|
orderId: string;
|
|
25282
|
-
status: "
|
|
25282
|
+
status: "failed" | "complete" | "pending" | "cancelled";
|
|
25283
25283
|
executor: "merchant" | "indiana";
|
|
25284
25284
|
checkoutUrl: string | null;
|
|
25285
25285
|
execution: {
|
|
@@ -26305,7 +26305,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
26305
26305
|
operationId: string;
|
|
26306
26306
|
membershipId: string;
|
|
26307
26307
|
productVersionId: string;
|
|
26308
|
-
status: "
|
|
26308
|
+
status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
|
|
26309
26309
|
timing: "immediate" | "renewal";
|
|
26310
26310
|
effectiveAt: string;
|
|
26311
26311
|
checkoutUrl: string | null;
|
|
@@ -27311,7 +27311,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
|
|
|
27311
27311
|
visit: number;
|
|
27312
27312
|
stopped: boolean;
|
|
27313
27313
|
variables: Record<string, zod.JSONType>;
|
|
27314
|
-
nodeType: "output" | "action" | "
|
|
27314
|
+
nodeType: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
|
|
27315
27315
|
canBack: boolean;
|
|
27316
27316
|
pendingRequest: {
|
|
27317
27317
|
requestId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-KCLHX3Y5.js";import"./chunk-X7V7AAWG.js";import"./chunk-R4CYPCBI.js";import"./chunk-QXDLOPZK.js";import"./chunk-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import"./chunk-IM5OXTEH.js";import"./chunk-ZCJEXNJD.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-FEBXEBDK.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-HNNJ2RVS.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as ScreenAnswers, P as PresentationLoadingOptions, s as screenInputBindingsSchema, a as SurfaceData, b as PaywallLoadingDocument, C as CustomerDataIntent, c as createPresentationLoading, R as RetainedPurchaseDialog } from './presentation-loading-
|
|
3
|
-
export { d as PresentationState } from './presentation-loading-
|
|
2
|
+
import { S as ScreenAnswers, P as PresentationLoadingOptions, s as screenInputBindingsSchema, a as SurfaceData, b as PaywallLoadingDocument, C as CustomerDataIntent, c as createPresentationLoading, R as RetainedPurchaseDialog } from './presentation-loading-B8W6a9WB.js';
|
|
3
|
+
export { d as PresentationState } from './presentation-loading-B8W6a9WB.js';
|
|
4
4
|
import { J as JsonValue } from './growth-rules-B4YYy64R.js';
|
|
5
|
-
import { S as StackNode, a as ScreenSelection } from './screen-
|
|
5
|
+
import { S as StackNode, a as ScreenSelection } from './screen-Pv_pViF6.js';
|
|
6
6
|
import { C as CouponInput, O as Offer } from './coupon-kfkIVf9n.js';
|
|
7
7
|
export { a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
|
|
8
|
-
import { P as PaywallSession, a as PaywallOperation, b as PaywallResolution, c as PaywallSubscriptionChange, F as FunnelCommandStorage, s as scopeSchema, d as FunnelStartInput, I as IndianaOptions, S as SessionCredentials, e as FunnelExecutionPolicy, f as PaywallRecovery, g as PaywallQuote, h as FunnelRunController, i as FunnelRunView, j as IamFunnelEntryDelivery, k as FunnelProcessRunView, l as createPaywallSession$1 } from './funnel-local-client-
|
|
9
|
-
export { C as CustomerSession, m as FeatureClient, n as FeatureClientOptions, o as FunnelControllerResponse, p as FunnelPendingEntry, q as FunnelPurchaseRecovery, r as FunnelRuntimeResponse, t as FunnelSegmentPrediction, L as LocalFunnelClient, u as LocalFunnelClientOptions, v as LongplayError, w as PaywallPurchaseInput, x as PaywallStartInput, y as PushHost, z as PushJournal, A as createFeatureClient, B as createFunnelRunController, D as createLocalFunnelClient, E as getPaywallRecovery, G as isPaywallOperationComplete, H as isPaywallOperationPending, J as isPaywallUpdateOperation, K as isPaywallUpdateQuote, M as preparePaywallFallback } from './funnel-local-client-
|
|
10
|
-
import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-
|
|
11
|
-
export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-
|
|
12
|
-
import { C as ConfigurationSync } from './configuration-sync-
|
|
13
|
-
export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-
|
|
14
|
-
import { c as createFunnelProcess } from './funnel-process-client-
|
|
15
|
-
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-
|
|
16
|
-
import './api-
|
|
8
|
+
import { P as PaywallSession, a as PaywallOperation, b as PaywallResolution, c as PaywallSubscriptionChange, F as FunnelCommandStorage, s as scopeSchema, d as FunnelStartInput, I as IndianaOptions, S as SessionCredentials, e as FunnelExecutionPolicy, f as PaywallRecovery, g as PaywallQuote, h as FunnelRunController, i as FunnelRunView, j as IamFunnelEntryDelivery, k as FunnelProcessRunView, l as createPaywallSession$1 } from './funnel-local-client-Cb9jJGpo.js';
|
|
9
|
+
export { C as CustomerSession, m as FeatureClient, n as FeatureClientOptions, o as FunnelControllerResponse, p as FunnelPendingEntry, q as FunnelPurchaseRecovery, r as FunnelRuntimeResponse, t as FunnelSegmentPrediction, L as LocalFunnelClient, u as LocalFunnelClientOptions, v as LongplayError, w as PaywallPurchaseInput, x as PaywallStartInput, y as PushHost, z as PushJournal, A as createFeatureClient, B as createFunnelRunController, D as createLocalFunnelClient, E as getPaywallRecovery, G as isPaywallOperationComplete, H as isPaywallOperationPending, J as isPaywallUpdateOperation, K as isPaywallUpdateQuote, M as preparePaywallFallback } from './funnel-local-client-Cb9jJGpo.js';
|
|
10
|
+
import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-COIh1hKs.js';
|
|
11
|
+
export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-COIh1hKs.js';
|
|
12
|
+
import { C as ConfigurationSync } from './configuration-sync-Dad8B5Pv.js';
|
|
13
|
+
export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-Dad8B5Pv.js';
|
|
14
|
+
import { c as createFunnelProcess } from './funnel-process-client-DE650LzB.js';
|
|
15
|
+
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-DE650LzB.js';
|
|
16
|
+
import './api-KIp0I50M.js';
|
|
17
17
|
import 'zod/v4';
|
|
18
18
|
|
|
19
19
|
/** Opt-in geometry; documents without responsive fields retain their host's legacy sizing. */
|
|
@@ -2797,6 +2797,12 @@ interface PreparedFunnelPurchase {
|
|
|
2797
2797
|
readonly reason?: string;
|
|
2798
2798
|
/** Resolves true once it can be revealed, false when it never will be. */
|
|
2799
2799
|
readonly ready: Promise<boolean>;
|
|
2800
|
+
/**
|
|
2801
|
+
* Resolves true when it renders from the Paywall this device kept, so it paints without a
|
|
2802
|
+
* request; false when it must wait for a read. Decide by it whether to show a loading state:
|
|
2803
|
+
* none while it is local, and one at once otherwise or when `ready` resolves false.
|
|
2804
|
+
*/
|
|
2805
|
+
readonly local: Promise<boolean>;
|
|
2800
2806
|
/** The Start it was rendered for, once known. */
|
|
2801
2807
|
readonly start?: Start;
|
|
2802
2808
|
/**
|
|
@@ -2844,8 +2850,10 @@ declare function prerenderFunnelPurchase$1(container: HTMLElement, input: {
|
|
|
2844
2850
|
paywallVersionId?: string;
|
|
2845
2851
|
paywallId?: string;
|
|
2846
2852
|
/**
|
|
2847
|
-
*
|
|
2848
|
-
*
|
|
2853
|
+
* The Funnel's published route, evaluated on the device with the final Start (its parameters
|
|
2854
|
+
* decide the route) and recording nothing. Without a Paywall it predicts the one to render.
|
|
2855
|
+
* With one, a Start the route sends elsewhere (another Paywall, a screen, an end) makes the
|
|
2856
|
+
* copy unavailable and forgets the kept copy, so that Customer is never shown it first.
|
|
2849
2857
|
*/
|
|
2850
2858
|
configuration?: ConfigurationSync;
|
|
2851
2859
|
/** Required while `start` is a promise: the Start's commerce and locale. */
|
|
@@ -3772,7 +3780,7 @@ declare function createMerchantBridge(options: MerchantBridgeOptions): {
|
|
|
3772
3780
|
merchantSubscriptionId: string;
|
|
3773
3781
|
merchantProductId: string;
|
|
3774
3782
|
productVersionId: string | null;
|
|
3775
|
-
status: "active" | "
|
|
3783
|
+
status: "active" | "trialing" | "cancelled" | "expired" | "past_due";
|
|
3776
3784
|
currentPeriodStartsAt: string | null;
|
|
3777
3785
|
currentPeriodEndsAt: string | null;
|
|
3778
3786
|
cancelAtPeriodEnd: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as En,c as bn}from"./chunk-U2NEVISJ.js";import{a as Rn}from"./chunk-45PGU2HW.js";import{a as We}from"./chunk-AEQUKR4O.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as pn,c as wn,d as Sn}from"./chunk-WUPNZGE2.js";import"./chunk-77O2O552.js";import{a as In}from"./chunk-XY2X6YJF.js";import"./chunk-PJHTN5NJ.js";import{h as mn,i as vn,k as Pn}from"./chunk-725CAWOK.js";import{E as Ae,d as Xe,f as Qe,g as ge,h as ve,i as Ye,w as yn}from"./chunk-6426YKPK.js";import"./chunk-ZCJEXNJD.js";import{a as ze}from"./chunk-VNYUL3PV.js";import{c as hn,e as gn}from"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-4SI4SQ3C.js";import"./chunk-C3HZCZVJ.js";import"./chunk-LUDTXNMH.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import{K as Ke}from"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import{B as dn,C as ln,D as un,E as fn,c as an,d as sn,e as cn}from"./chunk-EB7MIZ4T.js";import{A as Le,B as Be,D as He,F as qe,G as Ue,I as Ve,J as je,K as Ge,L as Je,M as Te,N as $e,z as _e}from"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import{b as Ce}from"./chunk-J7VGTAJ7.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as G}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as we,d as Ee}from"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-J3RW4GMO.js";import"./chunk-5MRSFLQA.js";import{b as U}from"./chunk-PZTWDJHN.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function _n(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Tn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function P(m,s,E,_,O){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let M=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:O??(E===void 0?{}:{operationId:E})})}),J=await _n(M,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!M.ok){let F=$e.safeParse(J);throw!F.success||F.data.scope.projectId!==n.scope.projectId||F.data.scope.environment!==n.scope.environment||F.data.scope.environmentId!==n.scope.environmentId||F.data.requestId!==g||F.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status):new I(F.data.error.code,M.status,F.data.error.retryable,F.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);return $.data}function R(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let O=R();if(_!==void 0&&Te.parse({operationId:_,customerId:O}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,M)=>{o=()=>M(l.reason),l.addEventListener("abort",o,{once:!0})});try{let M=E(async()=>{let c=await import("./merchant-bridge-contracts-IZ7ARRRO.js");if(l.throwIfAborted(),S!==h||w!==O)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([M,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let O=R(),S=Te.parse({operationId:E,customerId:O}),l=await P(m,s,S.operationId,_,S);if(l.customerId!==O||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await P("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await P("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=R(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return P("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=R(),E=await B("customer_commerce",m,async(_,O)=>{let[S,l]=await Promise.all([_(),P("customer_commerce",U.unknown(),void 0,O)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,O)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,O)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Qe,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Ze=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ze.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Ze.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Oe=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,P=!1){if(u!==void 0)try{let R=n.binding();if(!R)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...R,i,t]),requestId:y},z=b(B);if(Oe.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!P&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Oe.get(t.storage);u||Oe.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Pe(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Re=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Cn(n){let d=we(n.baseUrl),f=n.scope,b=Ce(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,P="",R=0,B=0,z=0,m=!1,s,E=!0,_,O,S,l,o,T=-1,g,M=e=>{g===e&&(F.release(e.deliveryTicket),g=void 0,x())},J=new Set,c=(e,a)=>Z(n.onStatus,e,a),$=Pe(),F=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Y=e=>te.forget(e.storageKey,e.command.requestId);function Q(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),x()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Q(o.recovery,a);let p=Re(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,x())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ce({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Y(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function C(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==R||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=R,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===R&&p===y&&document.visibilityState!=="hidden"&&C(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(A=>A.command.funnelId===e.funnelId&&(!A.expiresAt||Date.parse(A.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let A={...p,storageKey:a.key,epoch:R,visit:y};ee.add(A.command.requestId),g=A,await N(A);return}let v=crypto.randomUUID(),K=F.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),x();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:R,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await N(j)}async function N(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(A){if(e.epoch!==R)return;let D=A.view;if(!(e.storageKey&&D&&(Re(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await A.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Y(e)}catch(k){if(!(k instanceof G&&k.code==="FORBIDDEN"))throw k}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=F.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Q(e),c("starting",e.command.entryId);let A=await b.request("funnels",e.command),D=Ye.safeParse(A);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===R&&c(D.data.reason,e.command.entryId),Y(e),M(e);return}let k=Xe.parse(A);if(!k.runToken||k.scope.projectId!==f.projectId||k.scope.environment!==f.environment||k.run.source.type!=="funnel"||k.run.source.id!==e.command.funnelId||k.run.source.versionId!==e.command.versionId||e.runId!==void 0&&k.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(F.accept(e.deliveryTicket,k.run.id),e.epoch!==R){M(e),c("identity_changed",e.command.entryId);return}Q(e,k.run);let L=Ae({...n,runToken:k.runToken,funnelId:e.command.funnelId,initialResponse:a?A:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==k.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Y(e),M(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-LQ6X5B6R.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),M(e);return}let Ne=!1,xe=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),M(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Re(ne),n.container.append(ie);let ke=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Z(n.host?.onState,q)},onDismiss(q){Ne=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Y(e),o?.client===L&&(o=void 0,L.reset(),x(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Z(n.host?.onDismiss,q)},onComplete(q){xe=!0,Y(e),o?.client===L&&re(),Z(n.host?.onComplete,q)},onError(q){Z(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Y(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Ne||xe){ke.destroy(),ie.remove(),H(e)||await j(L),M(e);return}let he=Re(L.view??ne);ie.hidden=he,o={host:ke,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:k.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,M(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(A){A instanceof G&&(!p||K&&A.code==="FORBIDDEN")&&A.status!==void 0&&A.status>=400&&A.status<500&&!A.retryable&&(Y(e),M(e)),e.epoch===R&&!t&&(c("start_failed",e.command.entryId),Z(n.host?.onError,A))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:R,visit:y};return g=p,N(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!C(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let x=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===P?!1:(P=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&x()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!C(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Me(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((A,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let A=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([A(),v]),k=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||k>Date.now()+5e3||L-k>6e4||L<=k)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&x()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Me()}catch{t||c("configuration_unavailable")}x()}}let Fe=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,P=location.origin+location.pathname,O=Ee(oe),S=n.session.subscribeIdentity(()=>{R++,$.cancel(),F.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),x()}),l=new MutationObserver(x),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",x),addEventListener("pagehide",ae),await Fe.refresh())},refresh:Me,async retry(){g&&!t&&g.epoch===R&&await N(g)},destroy(){t=!0,u++,$.cancel(),F.release(g?.deliveryTicket),Fe.destroy(),_?.abort(),l?.disconnect(),O?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",x),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function An(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,P=0,R=-1,B=!1,z="",m,s,E,_,O=new Set,S,l,o,T=(r,C)=>Z(n.onStatus,r,C),g=Pe(),M=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(M()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=M();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function F(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let C=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-LQ6X5B6R.js");if(t||C!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),R=P;let N=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Z(n.host?.onDismiss,X)}});if(t||C!==y||l!==r){N.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:N,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||C!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Q()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Y(r){if(t||i||l||o||S||g.active||R===P||!F(r))return;let C=`${P}:${r.id}`;if(O.has(C))return;O.add(C);let H=P,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&P===H&&J()===V&&document.visibilityState!=="hidden"&&F(r)&&b?.entries.some(N=>N.id===r.id&&N.funnelId===r.funnelId&&N.versionId===r.versionId&&N.event===r.event&&JSON.stringify(N.target)===JSON.stringify(r.target)&&JSON.stringify(N.delivery)===JSON.stringify(r.delivery))===!0,()=>{let N=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(N===!1){T("frequency",r.id),Q();return}try{let X={entry:r,process:n.createProcess(r),visit:P,deliveryTicket:N};l=X,te(X)}catch(X){c.release(N),T("entry_unavailable",r.id),Z(n.host?.onError,X)}},()=>{O.delete(C)})}function Q(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||R===P)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!O.has(`${P}:${r.id}`)&&F(r)){Y(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||R===P)return;let C=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!F(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||C(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Y(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,P++,g.cancel(),O.clear(),Q())};async function me(){if(t)return;if(s)return s;let r=y,C=new AbortController;m=C;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));C.signal.addEventListener("abort",V,{once:!0});let N=setTimeout(()=>C.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:C.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},x=await Promise.race([ue(),W]),se=Date.parse(x.validatedAt),oe=Date.parse(x.validUntil);if(x.scope.projectId!==n.scope.projectId||x.scope.environment!==n.scope.environment||x.scope.environmentId!==n.environmentId||x.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=x,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Q())})();s=X;try{await X}finally{clearTimeout(N),C.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Q),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Q),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Q();return}try{let C=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:P},S=void 0,await te(l)),C}catch(C){throw r.process.view||(S={...r,visit:P},l=void 0,ee()),C}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:P}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Q);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function Dn(n,d){return(await import("./paywall-KQIBPACY.js")).showPaywall(n,d)}async function dt(){return await Promise.all([import("./paywall-KQIBPACY.js"),import("./screen-renderer-2ZDV2WYD.js")]),Dn}async function lt(...n){return n[1]=ze(n[1]),(await import("./paywall-session-W42F6DIF.js")).createPaywallSession(...n)}async function ut(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-2ZDV2WYD.js").catch(()=>{}),import("./paywall-KQIBPACY.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-LQ6X5B6R.js"),n[1].prepared)).showFunnelRun(...n)}finally{d?.()}}async function rn(n,d){try{return await n()}catch(f){throw d&&d.state!=="adopted"&&await import("./funnel-paywall-prerender-YCATKDAY.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ft(...n){return import("./screen-renderer-2ZDV2WYD.js").catch(()=>{}),import("./paywall-KQIBPACY.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-53LYWG4V.js"),n[1].prepared)).showFunnelPurchase(...n)}async function mt(...n){return import("./funnel-host-purchase-53LYWG4V.js").catch(()=>{}),import("./screen-renderer-2ZDV2WYD.js").catch(()=>{}),(await import("./funnel-paywall-prerender-YCATKDAY.js")).prerenderFunnelPurchase(...n)}async function pt(){await Promise.all([import("./funnel-paywall-prerender-YCATKDAY.js"),import("./funnel-host-purchase-53LYWG4V.js"),import("./paywall-KQIBPACY.js"),import("./screen-renderer-2ZDV2WYD.js"),import("./paywall-content-NQXU3O4D.js"),import("./check-response-K56UEZ6E.js"),import("./operation-contracts-6RQ33K66.js")])}async function yt(...n){return(await import("./funnel-route-prediction-XYWNKGQZ.js")).predictFunnelStart(...n)}async function ht(...n){return(await import("./funnel-route-prediction-XYWNKGQZ.js")).predictedPaywallLoadingDocument(...n)}async function gt(...n){return(await import("./funnel-host-recovery-paywall-FC3XQU2U.js")).mountFunnelRecoveryPaywall(...n)}async function vt(...n){return(await import("./content-5OMLKBPP.js")).mountContent(...n)}async function It(...n){return(await import("./content-5OMLKBPP.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,yn as createBrowserFunnelCommandStorage,En as createBrowserFunnelPurchaseStorage,vn as createConfigurationSync,mn as createFeatureClient,wn as createFunnelClient,Rn as createFunnelPageExperiments,Sn as createFunnelProcess,bn as createFunnelPurchaseClient,Ae as createFunnelRunController,Cn as createIamFunnelEntries,An as createIamFunnelProcessEntries,Pn as createLocalFunnelClient,pn as createLongplay,Tn as createMerchantBridge,lt as createPaywallSession,In as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,hn as getPaywallRecovery,un as isPaywallOperationComplete,fn as isPaywallOperationPending,ln as isPaywallUpdateOperation,dn as isPaywallUpdateQuote,vt as mountContent,gt as mountFunnelRecoveryPaywall,yt as predictFunnelStart,ht as predictedPaywallLoadingDocument,pt as preloadFunnelPurchase,dt as preloadPaywall,It as prepareContent,gn as preparePaywallFallback,mt as prerenderFunnelPurchase,ft as showFunnelPurchase,ut as showFunnelRun,Dn as showPaywall};
|
|
1
|
+
import{a as En,c as bn}from"./chunk-4VCPJSRS.js";import{a as Rn}from"./chunk-45PGU2HW.js";import{a as We}from"./chunk-AEQUKR4O.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as pn,c as wn,d as Sn}from"./chunk-WBBP25Q2.js";import"./chunk-77O2O552.js";import{a as In}from"./chunk-IHA7BSU3.js";import"./chunk-PJHTN5NJ.js";import{h as mn,i as vn,k as Pn}from"./chunk-DCZUPVAI.js";import{E as Ae,d as Xe,f as Qe,g as ge,h as ve,i as Ye,w as yn}from"./chunk-X6VBLJHA.js";import"./chunk-ZCJEXNJD.js";import{a as ze}from"./chunk-VNYUL3PV.js";import{c as hn,e as gn}from"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-4SI4SQ3C.js";import"./chunk-C3HZCZVJ.js";import"./chunk-24EPEF3N.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import{K as Ke}from"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import{B as dn,C as ln,D as un,E as fn,c as an,d as sn,e as cn}from"./chunk-EB7MIZ4T.js";import{A as Le,B as Be,D as He,F as qe,G as Ue,I as Ve,J as je,K as Ge,L as Je,M as Te,N as $e,z as _e}from"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import{b as Ce}from"./chunk-FEBXEBDK.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as G}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as we,d as Ee}from"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-HNNJ2RVS.js";import"./chunk-5MRSFLQA.js";import{b as U}from"./chunk-PZTWDJHN.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function _n(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Tn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function P(m,s,E,_,O){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let M=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:O??(E===void 0?{}:{operationId:E})})}),J=await _n(M,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!M.ok){let F=$e.safeParse(J);throw!F.success||F.data.scope.projectId!==n.scope.projectId||F.data.scope.environment!==n.scope.environment||F.data.scope.environmentId!==n.scope.environmentId||F.data.requestId!==g||F.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status):new I(F.data.error.code,M.status,F.data.error.retryable,F.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);return $.data}function R(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let O=R();if(_!==void 0&&Te.parse({operationId:_,customerId:O}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,M)=>{o=()=>M(l.reason),l.addEventListener("abort",o,{once:!0})});try{let M=E(async()=>{let c=await import("./merchant-bridge-contracts-IZ7ARRRO.js");if(l.throwIfAborted(),S!==h||w!==O)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([M,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let O=R(),S=Te.parse({operationId:E,customerId:O}),l=await P(m,s,S.operationId,_,S);if(l.customerId!==O||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await P("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await P("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=R(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return P("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=R(),E=await B("customer_commerce",m,async(_,O)=>{let[S,l]=await Promise.all([_(),P("customer_commerce",U.unknown(),void 0,O)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,O)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,O)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Qe,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Ze=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ze.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Ze.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Oe=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,P=!1){if(u!==void 0)try{let R=n.binding();if(!R)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...R,i,t]),requestId:y},z=b(B);if(Oe.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!P&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Oe.get(t.storage);u||Oe.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Pe(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Re=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Cn(n){let d=we(n.baseUrl),f=n.scope,b=Ce(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,P="",R=0,B=0,z=0,m=!1,s,E=!0,_,O,S,l,o,T=-1,g,M=e=>{g===e&&(F.release(e.deliveryTicket),g=void 0,x())},J=new Set,c=(e,a)=>Z(n.onStatus,e,a),$=Pe(),F=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Y=e=>te.forget(e.storageKey,e.command.requestId);function Q(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),x()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Q(o.recovery,a);let p=Re(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,x())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ce({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Y(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function C(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==R||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=R,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===R&&p===y&&document.visibilityState!=="hidden"&&C(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(A=>A.command.funnelId===e.funnelId&&(!A.expiresAt||Date.parse(A.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let A={...p,storageKey:a.key,epoch:R,visit:y};ee.add(A.command.requestId),g=A,await N(A);return}let v=crypto.randomUUID(),K=F.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),x();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:R,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await N(j)}async function N(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(A){if(e.epoch!==R)return;let D=A.view;if(!(e.storageKey&&D&&(Re(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await A.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Y(e)}catch(k){if(!(k instanceof G&&k.code==="FORBIDDEN"))throw k}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=F.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Q(e),c("starting",e.command.entryId);let A=await b.request("funnels",e.command),D=Ye.safeParse(A);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===R&&c(D.data.reason,e.command.entryId),Y(e),M(e);return}let k=Xe.parse(A);if(!k.runToken||k.scope.projectId!==f.projectId||k.scope.environment!==f.environment||k.run.source.type!=="funnel"||k.run.source.id!==e.command.funnelId||k.run.source.versionId!==e.command.versionId||e.runId!==void 0&&k.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(F.accept(e.deliveryTicket,k.run.id),e.epoch!==R){M(e),c("identity_changed",e.command.entryId);return}Q(e,k.run);let L=Ae({...n,runToken:k.runToken,funnelId:e.command.funnelId,initialResponse:a?A:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==k.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Y(e),M(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-FI4TYAXG.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),M(e);return}let Ne=!1,xe=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),M(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Re(ne),n.container.append(ie);let ke=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Z(n.host?.onState,q)},onDismiss(q){Ne=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Y(e),o?.client===L&&(o=void 0,L.reset(),x(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Z(n.host?.onDismiss,q)},onComplete(q){xe=!0,Y(e),o?.client===L&&re(),Z(n.host?.onComplete,q)},onError(q){Z(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Y(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Ne||xe){ke.destroy(),ie.remove(),H(e)||await j(L),M(e);return}let he=Re(L.view??ne);ie.hidden=he,o={host:ke,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:k.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,M(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(A){A instanceof G&&(!p||K&&A.code==="FORBIDDEN")&&A.status!==void 0&&A.status>=400&&A.status<500&&!A.retryable&&(Y(e),M(e)),e.epoch===R&&!t&&(c("start_failed",e.command.entryId),Z(n.host?.onError,A))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:R,visit:y};return g=p,N(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!C(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let x=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===P?!1:(P=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&x()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!C(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Me(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((A,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let A=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([A(),v]),k=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||k>Date.now()+5e3||L-k>6e4||L<=k)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&x()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Me()}catch{t||c("configuration_unavailable")}x()}}let Fe=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,P=location.origin+location.pathname,O=Ee(oe),S=n.session.subscribeIdentity(()=>{R++,$.cancel(),F.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),x()}),l=new MutationObserver(x),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",x),addEventListener("pagehide",ae),await Fe.refresh())},refresh:Me,async retry(){g&&!t&&g.epoch===R&&await N(g)},destroy(){t=!0,u++,$.cancel(),F.release(g?.deliveryTicket),Fe.destroy(),_?.abort(),l?.disconnect(),O?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",x),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function An(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,P=0,R=-1,B=!1,z="",m,s,E,_,O=new Set,S,l,o,T=(r,C)=>Z(n.onStatus,r,C),g=Pe(),M=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(M()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=M();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function F(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let C=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-FI4TYAXG.js");if(t||C!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),R=P;let N=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Z(n.host?.onDismiss,X)}});if(t||C!==y||l!==r){N.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:N,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||C!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Q()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Y(r){if(t||i||l||o||S||g.active||R===P||!F(r))return;let C=`${P}:${r.id}`;if(O.has(C))return;O.add(C);let H=P,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&P===H&&J()===V&&document.visibilityState!=="hidden"&&F(r)&&b?.entries.some(N=>N.id===r.id&&N.funnelId===r.funnelId&&N.versionId===r.versionId&&N.event===r.event&&JSON.stringify(N.target)===JSON.stringify(r.target)&&JSON.stringify(N.delivery)===JSON.stringify(r.delivery))===!0,()=>{let N=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(N===!1){T("frequency",r.id),Q();return}try{let X={entry:r,process:n.createProcess(r),visit:P,deliveryTicket:N};l=X,te(X)}catch(X){c.release(N),T("entry_unavailable",r.id),Z(n.host?.onError,X)}},()=>{O.delete(C)})}function Q(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||R===P)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!O.has(`${P}:${r.id}`)&&F(r)){Y(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||R===P)return;let C=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!F(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||C(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Y(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,P++,g.cancel(),O.clear(),Q())};async function me(){if(t)return;if(s)return s;let r=y,C=new AbortController;m=C;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));C.signal.addEventListener("abort",V,{once:!0});let N=setTimeout(()=>C.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:C.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},x=await Promise.race([ue(),W]),se=Date.parse(x.validatedAt),oe=Date.parse(x.validUntil);if(x.scope.projectId!==n.scope.projectId||x.scope.environment!==n.scope.environment||x.scope.environmentId!==n.environmentId||x.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=x,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Q())})();s=X;try{await X}finally{clearTimeout(N),C.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Q),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Q),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Q();return}try{let C=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:P},S=void 0,await te(l)),C}catch(C){throw r.process.view||(S={...r,visit:P},l=void 0,ee()),C}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:P}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Q);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function Dn(n,d){return(await import("./paywall-VMEEMKO4.js")).showPaywall(n,d)}async function dt(){return await Promise.all([import("./paywall-VMEEMKO4.js"),import("./screen-renderer-3YO6EUWD.js")]),Dn}async function lt(...n){return n[1]=ze(n[1]),(await import("./paywall-session-UTQVXDY4.js")).createPaywallSession(...n)}async function ut(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-3YO6EUWD.js").catch(()=>{}),import("./paywall-VMEEMKO4.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-FI4TYAXG.js"),n[1].prepared)).showFunnelRun(...n)}finally{d?.()}}async function rn(n,d){try{return await n()}catch(f){throw d&&d.state!=="adopted"&&await import("./funnel-paywall-prerender-RMSOP32P.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ft(...n){return import("./screen-renderer-3YO6EUWD.js").catch(()=>{}),import("./paywall-VMEEMKO4.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-RFDAZBS6.js"),n[1].prepared)).showFunnelPurchase(...n)}async function mt(...n){return import("./funnel-host-purchase-RFDAZBS6.js").catch(()=>{}),import("./screen-renderer-3YO6EUWD.js").catch(()=>{}),(await import("./funnel-paywall-prerender-RMSOP32P.js")).prerenderFunnelPurchase(...n)}async function pt(){await Promise.all([import("./funnel-paywall-prerender-RMSOP32P.js"),import("./funnel-host-purchase-RFDAZBS6.js"),import("./paywall-VMEEMKO4.js"),import("./screen-renderer-3YO6EUWD.js"),import("./paywall-content-JGK22QA7.js"),import("./check-response-K56UEZ6E.js"),import("./operation-contracts-6RQ33K66.js")])}async function yt(...n){return(await import("./funnel-route-prediction-XYWNKGQZ.js")).predictFunnelStart(...n)}async function ht(...n){return(await import("./funnel-route-prediction-XYWNKGQZ.js")).predictedPaywallLoadingDocument(...n)}async function gt(...n){return(await import("./funnel-host-recovery-paywall-HQI6ZBRL.js")).mountFunnelRecoveryPaywall(...n)}async function vt(...n){return(await import("./content-CXXLVFDH.js")).mountContent(...n)}async function It(...n){return(await import("./content-CXXLVFDH.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,yn as createBrowserFunnelCommandStorage,En as createBrowserFunnelPurchaseStorage,vn as createConfigurationSync,mn as createFeatureClient,wn as createFunnelClient,Rn as createFunnelPageExperiments,Sn as createFunnelProcess,bn as createFunnelPurchaseClient,Ae as createFunnelRunController,Cn as createIamFunnelEntries,An as createIamFunnelProcessEntries,Pn as createLocalFunnelClient,pn as createLongplay,Tn as createMerchantBridge,lt as createPaywallSession,In as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,hn as getPaywallRecovery,un as isPaywallOperationComplete,fn as isPaywallOperationPending,ln as isPaywallUpdateOperation,dn as isPaywallUpdateQuote,vt as mountContent,gt as mountFunnelRecoveryPaywall,yt as predictFunnelStart,ht as predictedPaywallLoadingDocument,pt as preloadFunnelPurchase,dt as preloadPaywall,It as prepareContent,gn as preparePaywallFallback,mt as prerenderFunnelPurchase,ft as showFunnelPurchase,ut as showFunnelRun,Dn as showPaywall};
|