@tinkerlandai/longplay-sdk 0.10.35 → 0.10.36
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/README.md +34 -3
- package/README.zh-CN.md +6 -0
- package/dist/{ai-usage-T62xehqa.d.ts → ai-usage-DXwAGTxT.d.ts} +1 -1
- package/dist/{api-Do-6AyWa.d.ts → api-r6FfVQpg.d.ts} +6 -1
- package/dist/check-response-DHY6T5Z2.js +1 -0
- package/dist/{chunk-7MNJH5GB.js → chunk-2HSD2SEU.js} +1 -1
- package/dist/{chunk-CKKIB2HC.js → chunk-2KKLY323.js} +1 -1
- package/dist/{chunk-VEX2FOFZ.js → chunk-35VG2IYD.js} +1 -1
- package/dist/{chunk-SXBM3DWK.js → chunk-5XIKN35D.js} +1 -1
- package/dist/{chunk-CIP5SQ5Y.js → chunk-5XKFUFXK.js} +1 -1
- package/dist/{chunk-V7MMTILA.js → chunk-7ZEXY4GC.js} +1 -1
- package/dist/chunk-BL7E4RZ2.js +1 -0
- package/dist/{chunk-LF2UIJYD.js → chunk-BTPEXSNY.js} +1 -1
- package/dist/{chunk-TOTRALYQ.js → chunk-C4GBV32U.js} +1 -1
- package/dist/{chunk-V7PFLFHE.js → chunk-CGXNU5BC.js} +1 -1
- package/dist/{chunk-YVXLCQGM.js → chunk-DB4EO3JG.js} +1 -1
- package/dist/{chunk-TJGIT5CU.js → chunk-DHT3AWJQ.js} +1 -1
- package/dist/{chunk-TAFALMQN.js → chunk-GLYFT5WW.js} +1 -1
- package/dist/chunk-HS56A4IK.js +1 -0
- package/dist/{chunk-56BYGPQ6.js → chunk-HVVJGLYZ.js} +1 -1
- package/dist/chunk-HYE2YQYM.js +1 -0
- package/dist/chunk-I6D25FWU.js +1 -0
- package/dist/{chunk-FMDC6N4W.js → chunk-IOBB6KFK.js} +1 -1
- package/dist/{chunk-PUR5CYWX.js → chunk-JOIPLLHK.js} +1 -1
- package/dist/{chunk-KE26KWIU.js → chunk-LAGGWYH3.js} +1 -1
- package/dist/{chunk-TLZP7BW6.js → chunk-LVG5ED52.js} +1 -1
- package/dist/{chunk-KPDHY76A.js → chunk-M3GGR53D.js} +1 -1
- package/dist/{chunk-EUTWY7A2.js → chunk-MHWPEMX7.js} +1 -1
- package/dist/chunk-MYBUQFTC.js +1 -0
- package/dist/{chunk-7QL4GF4C.js → chunk-O4KXODTJ.js} +1 -1
- package/dist/chunk-OL2AI6DA.js +1 -0
- package/dist/chunk-QHJWVLJC.js +1 -0
- package/dist/{chunk-W6OQTXLL.js → chunk-R3YVDRTB.js} +1 -1
- package/dist/{chunk-EM3MGDPG.js → chunk-RHF4NFCZ.js} +1 -1
- package/dist/{chunk-5HJYR6Z4.js → chunk-RHWZRHK7.js} +1 -1
- package/dist/{chunk-OX7PA64E.js → chunk-TIQS5DUF.js} +1 -1
- package/dist/{chunk-BOVN2BE3.js → chunk-U4WUX3WB.js} +1 -1
- package/dist/{chunk-44U3FOBB.js → chunk-UHTTCVSL.js} +1 -1
- package/dist/{chunk-MSK3VZ3A.js → chunk-UVUFJO2V.js} +1 -1
- package/dist/{chunk-RML52BOR.js → chunk-VKG6BB3Z.js} +1 -1
- package/dist/{chunk-73NP72FV.js → chunk-VWMFR22O.js} +1 -1
- package/dist/chunk-W3K5ARMY.js +1 -0
- package/dist/chunk-WRLVPHPE.js +1 -0
- package/dist/{chunk-U4RSRFZY.js → chunk-XE7GU6FZ.js} +1 -1
- package/dist/{chunk-WZR2XCSJ.js → chunk-XQTCEQXI.js} +1 -1
- package/dist/chunk-YQX27SBG.js +1 -0
- package/dist/{chunk-VYFSRHXM.js → chunk-ZYF6TRJ3.js} +1 -1
- package/dist/{configuration-sync-DdTRUv7A.d.ts → configuration-sync-BHrAf-ql.d.ts} +10 -1
- package/dist/{content-AJDTSI7A.js → content-RGKTEV23.js} +1 -1
- package/dist/{funnel-host-purchase-Z7FCJ5CX.js → funnel-host-purchase-M7MM33EC.js} +1 -1
- package/dist/{funnel-local-client-Dz1dTgES.d.ts → funnel-local-client-DR8OpKGU.d.ts} +145 -3
- package/dist/funnel-paywall-prerender-OSBI4VMY.js +1 -0
- package/dist/{funnel-process-client-D6qjStm2.d.ts → funnel-process-client-C87U4r_G.d.ts} +17 -3
- package/dist/funnel-runtime-host-AMJXEASH.js +1 -0
- package/dist/index.d.ts +26 -9
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-GJQVKEAG.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-MFK2KORK.js +1 -0
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/paywall-ATZ2IZPS.js +1 -0
- package/dist/paywall-content-XERXGNND.js +1 -0
- package/dist/paywall-session-EMMF6IYS.js +1 -0
- package/dist/popup.d.ts +3 -3
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-CFSiS0VX.d.ts → presentation-loading-B_v5XZtM.d.ts} +11 -1
- package/dist/react-native.d.ts +7 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-CGCJ46b1.d.ts → screen-qUBRsUi9.d.ts} +26 -21
- package/dist/screen-renderer-B7LUTPTJ.js +1 -0
- package/dist/server.d.ts +37 -7
- package/dist/server.js +1 -1
- package/dist/{visual-dom-6DCUZGPB.js → visual-dom-5LUN4AHO.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-GZZRWBEA.js +0 -1
- package/dist/chunk-2FE4FTPH.js +0 -1
- package/dist/chunk-BLVBUN2R.js +0 -1
- package/dist/chunk-BQRS7Y4K.js +0 -1
- package/dist/chunk-ETK6GC5P.js +0 -1
- package/dist/chunk-GZRRVHYK.js +0 -1
- package/dist/chunk-RNEF4MZW.js +0 -1
- package/dist/chunk-SFHIFCXG.js +0 -1
- package/dist/chunk-UVRT4MY6.js +0 -1
- package/dist/chunk-XUGEOELU.js +0 -1
- package/dist/chunk-ZGCKQWQ5.js +0 -1
- package/dist/funnel-paywall-prerender-QHCUZZY3.js +0 -1
- package/dist/funnel-runtime-host-UKSOOA4H.js +0 -1
- package/dist/merchant-bridge-contracts-EAE4HQE4.js +0 -1
- package/dist/operation-contracts-HS4M2UXN.js +0 -1
- package/dist/paywall-VYUBYBUI.js +0 -1
- package/dist/paywall-content-YQAVSO2T.js +0 -1
- package/dist/paywall-session-E5V42XUT.js +0 -1
- package/dist/screen-renderer-R5GH7XLV.js +0 -1
- /package/dist/{chunk-BID4UGWB.js → chunk-CILM5XMH.js} +0 -0
- /package/dist/{chunk-UKMEW5I7.js → chunk-OJM6ORHE.js} +0 -0
- /package/dist/{chunk-VF6QMMEA.js → chunk-ZYN4CRHS.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 } 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 } from './presentation-loading-B_v5XZtM.js';
|
|
3
|
+
export { d as PresentationState } from './presentation-loading-B_v5XZtM.js';
|
|
4
4
|
import { J as JsonValue } from './growth-rules-B4YYy64R.js';
|
|
5
|
-
import { S as StackNode, a as ScreenSelection } from './screen-
|
|
6
|
-
import { P as PaywallSession, S as SubscriptionOperation, F as FunnelCommandStorage, s as scopeSchema, a as FunnelStartInput, I as IndianaOptions, b as SessionCredentials, c as FunnelExecutionPolicy, d as PaywallRecovery, e as SubscriptionAttachQuote, f as FunnelRunController, g as PaywallResolution, h as FunnelRunView, i as IamFunnelEntryDelivery, j as FunnelProcessRunView, k as createPaywallSession$1 } from './funnel-local-client-
|
|
7
|
-
export { C as CustomerSession, l as FeatureClient, m as FeatureClientOptions, n as FunnelControllerResponse, o as FunnelPendingEntry, p as FunnelPurchaseRecovery, q as FunnelRuntimeResponse, r as FunnelSegmentPrediction, L as LocalFunnelClient, t as LocalFunnelClientOptions, u as LongplayError, v as PaywallPurchaseInput, w as PaywallStartInput, x as PushHost, y as PushJournal, z as createFeatureClient, A as createFunnelRunController, B as createLocalFunnelClient, D as getPaywallRecovery, E as preparePaywallFallback } from './funnel-local-client-
|
|
5
|
+
import { S as StackNode, a as ScreenSelection } from './screen-qUBRsUi9.js';
|
|
6
|
+
import { P as PaywallSession, S as SubscriptionOperation, F as FunnelCommandStorage, s as scopeSchema, a as FunnelStartInput, I as IndianaOptions, b as SessionCredentials, c as FunnelExecutionPolicy, d as PaywallRecovery, e as SubscriptionAttachQuote, f as FunnelRunController, g as PaywallResolution, h as FunnelRunView, i as IamFunnelEntryDelivery, j as FunnelProcessRunView, k as createPaywallSession$1 } from './funnel-local-client-DR8OpKGU.js';
|
|
7
|
+
export { C as CustomerSession, l as FeatureClient, m as FeatureClientOptions, n as FunnelControllerResponse, o as FunnelPendingEntry, p as FunnelPurchaseRecovery, q as FunnelRuntimeResponse, r as FunnelSegmentPrediction, L as LocalFunnelClient, t as LocalFunnelClientOptions, u as LongplayError, v as PaywallPurchaseInput, w as PaywallStartInput, x as PushHost, y as PushJournal, z as createFeatureClient, A as createFunnelRunController, B as createLocalFunnelClient, D as getPaywallRecovery, E as preparePaywallFallback } from './funnel-local-client-DR8OpKGU.js';
|
|
8
8
|
import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-COxXtZEQ.js';
|
|
9
9
|
export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-COxXtZEQ.js';
|
|
10
10
|
import { C as CouponInput } from './coupon-kfkIVf9n.js';
|
|
11
11
|
export { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
|
|
12
|
-
import { c as createFunnelProcess } from './funnel-process-client-
|
|
13
|
-
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-
|
|
14
|
-
export { C as ConfigurationStorage, a as ConfigurationSync, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-
|
|
15
|
-
import './api-
|
|
12
|
+
import { c as createFunnelProcess } from './funnel-process-client-C87U4r_G.js';
|
|
13
|
+
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-C87U4r_G.js';
|
|
14
|
+
export { C as ConfigurationStorage, a as ConfigurationSync, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-BHrAf-ql.js';
|
|
15
|
+
import './api-r6FfVQpg.js';
|
|
16
16
|
import 'zod/v4';
|
|
17
17
|
|
|
18
18
|
/** Currency always comes from business data; locale only controls notation. No currency conversion. */
|
|
@@ -80,6 +80,11 @@ declare const contentVersionSchema: z.ZodObject<{
|
|
|
80
80
|
blur: "blur";
|
|
81
81
|
}>>;
|
|
82
82
|
type: z.ZodLiteral<"modal">;
|
|
83
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
84
|
+
center: "center";
|
|
85
|
+
top: "top";
|
|
86
|
+
bottom: "bottom";
|
|
87
|
+
}>>;
|
|
83
88
|
size: z.ZodEnum<{
|
|
84
89
|
sm: "sm";
|
|
85
90
|
md: "md";
|
|
@@ -1891,6 +1896,8 @@ type IamFunnelEntriesOptions = IndianaOptions & {
|
|
|
1891
1896
|
container: HTMLElement;
|
|
1892
1897
|
/** Credential-free original starts survive reloads in this tab. Requires a full Customer session. */
|
|
1893
1898
|
recoveryStorage?: Storage | false;
|
|
1899
|
+
/** Per-tab frequency state. A capped entry requires a full Customer session. */
|
|
1900
|
+
deliveryStorage?: Storage;
|
|
1894
1901
|
host?: Omit<FunnelHostOptions, "client">;
|
|
1895
1902
|
onStatus?: (status: string, entryId?: string) => void;
|
|
1896
1903
|
};
|
|
@@ -1913,6 +1920,11 @@ declare function createFunnelPageExperiments(options: {
|
|
|
1913
1920
|
destroy(): void;
|
|
1914
1921
|
};
|
|
1915
1922
|
|
|
1923
|
+
type EntryDeliveryIdentity = {
|
|
1924
|
+
type: "customer" | "guest";
|
|
1925
|
+
id: string;
|
|
1926
|
+
};
|
|
1927
|
+
|
|
1916
1928
|
type Entry = IamFunnelEntryDelivery["entries"][number];
|
|
1917
1929
|
type Process = ReturnType<typeof createFunnelProcess>;
|
|
1918
1930
|
type IamFunnelProcessEntriesOptions = Pick<IndianaOptions, "baseUrl" | "fetch" | "timeoutMs"> & {
|
|
@@ -1924,6 +1936,9 @@ type IamFunnelProcessEntriesOptions = Pick<IndianaOptions, "baseUrl" | "fetch" |
|
|
|
1924
1936
|
createProcess(entry: Entry): Process;
|
|
1925
1937
|
host?: Omit<FunnelHostOptions, "client">;
|
|
1926
1938
|
locale?: string;
|
|
1939
|
+
/** Required for session-capped entries. Return the current Customer ID or a per-tab guest ID, never a credential. Update it before syncIdentity(). */
|
|
1940
|
+
deliveryIdentity?: () => EntryDeliveryIdentity | undefined;
|
|
1941
|
+
deliveryStorage?: Storage;
|
|
1927
1942
|
onStatus?: (status: string, entryId?: string) => void;
|
|
1928
1943
|
};
|
|
1929
1944
|
/** Explicit process-capable IAM host. Merely fetching configuration creates no identity. */
|
|
@@ -2034,6 +2049,7 @@ declare function showPaywall(container: HTMLElement, options: PaywallHostOptions
|
|
|
2034
2049
|
} | undefined;
|
|
2035
2050
|
mobile?: "sheet" | "fullscreen" | undefined;
|
|
2036
2051
|
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
2052
|
+
position?: "center" | "top" | "bottom" | undefined;
|
|
2037
2053
|
} | {
|
|
2038
2054
|
type: "sheet";
|
|
2039
2055
|
size: "sm" | "md" | "lg";
|
|
@@ -2064,6 +2080,7 @@ declare function showPaywall(container: HTMLElement, options: PaywallHostOptions
|
|
|
2064
2080
|
} | undefined;
|
|
2065
2081
|
mobile?: "sheet" | "fullscreen" | undefined;
|
|
2066
2082
|
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
2083
|
+
position?: "center" | "top" | "bottom" | undefined;
|
|
2067
2084
|
} | {
|
|
2068
2085
|
type: "sheet";
|
|
2069
2086
|
size: "sm" | "md" | "lg";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as dn,c as un}from"./chunk-RNEF4MZW.js";import{a as Ue,c as mn}from"./chunk-73NP72FV.js";import{a as pe}from"./chunk-W32FI2A2.js";import{a as nn,c as cn,d as ln}from"./chunk-RML52BOR.js";import"./chunk-KPDHY76A.js";import{a as sn}from"./chunk-UVRT4MY6.js";import"./chunk-MSK3VZ3A.js";import{h as en,i as an,k as fn}from"./chunk-BLVBUN2R.js";import{F as be,e as Ve,g as je,h as fe,i as me,j as Ge,x as tn}from"./chunk-2FE4FTPH.js";import{a as qe}from"./chunk-EUTWY7A2.js";import"./chunk-7MNJH5GB.js";import"./chunk-CIP5SQ5Y.js";import"./chunk-LF2UIJYD.js";import{B as Ne,D as Oe,E as xe,G as De,H as Te,I as ke,J as Be,K as ve,L as He,x as we,y as Me,z as Fe}from"./chunk-CKKIB2HC.js";import"./chunk-W6OQTXLL.js";import"./chunk-BOVN2BE3.js";import"./chunk-PUR5CYWX.js";import{$ as Le,l as Ze,m as We,n as Qe}from"./chunk-TAFALMQN.js";import"./chunk-ZGCKQWQ5.js";import{c as rn,e as on}from"./chunk-3NCMYTNG.js";import"./chunk-VEX2FOFZ.js";import"./chunk-V7PFLFHE.js";import{b as Ee}from"./chunk-56BYGPQ6.js";import"./chunk-VYFSRHXM.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import{a as L}from"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-SLUA7ABW.js";import{a as Ie,c as se}from"./chunk-J6KIN4RH.js";import{c as ye,d as he}from"./chunk-TLZP7BW6.js";import"./chunk-3VUPVXAV.js";import"./chunk-EM3MGDPG.js";import{b as G}from"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var y=class extends Error{constructor(m,D=0,_=!1,b="fix_request"){super(m);this.code=m;this.status=D;this.retryable=_;this.recovery=b;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function pn(n,w){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let m=n.body?.getReader();if(!m)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let D=()=>{m.cancel().catch(()=>{})};w.addEventListener("abort",D,{once:!0});let _=0,b="",r=new TextDecoder("utf-8",{fatal:!0});try{for(w.throwIfAborted();;){let i=await m.read();if(w.throwIfAborted(),i.done)break;if(_+=i.value.byteLength,_>262144)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");b+=r.decode(i.value,{stream:!0})}return b+=r.decode(),JSON.parse(b)}catch(i){throw w.throwIfAborted(),i instanceof y?i:new y("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{w.removeEventListener("abort",D),await m.cancel().catch(()=>{}),m.releaseLock()}}function yn(n){let w=Oe.parse(n.origin),m=xe.parse(n.manifest),D={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let c of["projectId","environmentId","environment"])if(m[c]!==n.scope[c])throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");let _=n.customerId===void 0?null:G.uuid().parse(n.customerId),b=0,r=null,i=null,I=new AbortController,g=n.fetch??globalThis.fetch;async function U(c,s,p,v,h){if(!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=Ne[c];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(d.authority))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);let l=b,o=AbortSignal.any([I.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...v?[v]:[]]);o.throwIfAborted();let F=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==b)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(F.get("authorization")??"")||F.has("X-Indiana-Bridge-Signature")||F.has("X-Indiana-Bridge-Key-Id"))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);F.set(Fe,String(we)),F.set("Accept","application/json");let A=crypto.randomUUID();F.set("X-Request-Id",A),F.set("Content-Type","application/json");let R=await g(w+Me,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:F,signal:o,body:JSON.stringify({bridgeVersion:we,requestId:A,command:d.command,scope:D,data:h??(p===void 0?{}:{operationId:p})})}),V=await pn(R,o);if(o.throwIfAborted(),l!==b)throw new DOMException("Merchant identity changed","AbortError");if(!R.ok){let T=He.safeParse(V);throw!T.success||T.data.scope.projectId!==n.scope.projectId||T.data.scope.environment!==n.scope.environment||T.data.scope.environmentId!==n.scope.environmentId||T.data.requestId!==A||T.data.command!==d.command?new y("MERCHANT_BRIDGE_INVALID_RESPONSE",R.status):new y(T.data.error.code,R.status,T.data.error.retryable,T.data.error.recovery)}let u=De(G.unknown()).safeParse(V);if(!u.success||u.data.scope.projectId!==n.scope.projectId||u.data.scope.environment!==n.scope.environment||u.data.scope.environmentId!==n.scope.environmentId||u.data.requestId!==A||u.data.command!==d.command)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",R.status);let j=s.safeParse(u.data.data);if(!j.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",R.status);return j.data}function M(){if(!_)throw new y("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return _}async function $(c,s,p,v){let h=M();if(v!==void 0&&ve.parse({operationId:v,customerId:h}),!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=b,l=AbortSignal.any([I.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,F=new Promise((A,R)=>{o=()=>R(l.reason),l.addEventListener("abort",o,{once:!0})});try{let R=p(async()=>{let u=await import("./merchant-bridge-contracts-EAE4HQE4.js");if(l.throwIfAborted(),d!==b||_!==h)throw new DOMException("Merchant identity changed","AbortError");return u},l),V=await Promise.race([R,F]);return l.throwIfAborted(),V}finally{l.removeEventListener("abort",o)}}async function J(c,s,p,v){let h=M(),d=ve.parse({operationId:p,customerId:h}),l=await U(c,s,d.operationId,v,d);if(l.customerId!==h||l.operationId!==d.operationId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(c){let s=await U("presentation",ke,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&_!==null&&s.presentation.customerId!==_)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,r=s.presentation,s},async createSession(c){let s=await U("session",Te,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(_!==null&&_!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(r&&r.customerId!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return _=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(c,s){let p=M(),v=Be.parse(c);if(!r||r.customerId!==p||r.decisionId!==v.decisionId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return U("presentation_events",G.strictObject({queued:G.literal(!0)}),void 0,s,v)},async readCustomerCommerce(c){let s=M(),p=await $("customer_commerce",c,async(v,h)=>{let[d,l]=await Promise.all([v(),U("customer_commerce",G.unknown(),void 0,h)]),o=d.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(p.customerId!==s)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return p},async executePurchase(c,s){let p=await $("purchases",s,async(v,h)=>J("purchases",(await v()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="purchase")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},readOperation:(c,s)=>$("operation_status",s,async(p,v)=>J("operation_status",(await p()).merchantOperationLookupSchema,c,v),c),async executeSubscriptionChange(c,s){let p=await $("subscription_changes",s,async(v,h)=>J("subscription_changes",(await v()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="subscription_change")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},reset(){b++,I.abort(),I=new AbortController,_=null,r=null,i=null}}}var $e=G.strictObject({command:me,target:je,runId:G.uuid().optional(),expiresAt:G.iso.datetime({offset:!0}).optional()}).refine(n=>n.command.release===n.target.release),Ke=G.strictObject({schemaVersion:G.literal(1),entries:G.array($e).max(4e3)});function ze(n){let w=!1,m=()=>{w||n.unavailable(),w=!0};function D(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function _(r){let i=D()?.getItem(r);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ke.parse(JSON.parse(i)).entries}function b(r,i){let I=D();if(!I)return;if(!i.length)return I.removeItem(r);let g=JSON.stringify(Ke.parse({schemaVersion:1,entries:i}));if(g.length>1048576)throw Error("Entry recovery is too large");I.setItem(r,g)}return{load(){try{let r=n.binding();if(!r||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(r);return{key:i,entries:_(i)}}catch{m();return}},retain(r,i){if(r)try{let I=$e.parse(i);b(r,[..._(r).filter(g=>g.command.funnelId!==I.command.funnelId),I])}catch{m()}},forget(r,i){if(r)try{b(r,_(r).filter(I=>I.command.requestId!==i))}catch{m()}}}}var ge=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function hn(n){let w=ye(n.baseUrl),m=n.scope,D=Ee(n),_=n.fetch??globalThis.fetch.bind(globalThis),b,r=!1,i=!1,I=0,g=0,U="",M=0,$=0,J=0,c=!1,s,p=!0,v,h,d,l,o,F=-1,A,R=e=>{A===e&&(A=void 0,q())},V=new Set,u=(e,a)=>Z(n.onStatus,e,a),j=new Set,T=ze({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[w,m.projectId,m.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>u("recovery_unavailable")}),X=e=>T.forget(e.storageKey,e.command.requestId);function oe(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),T.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt}})}function te(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),q()}let ce=()=>A!==void 0||o!==void 0&&!o.background;function t(e,a){if(o?.client!==e)return;oe(o.recovery,a);let f=ge(a);o.slot.hidden=f,f!==o.background&&(o.background=f,f?u("run_background",o.entryId):F=g,q())}function S(e,a,f){let P=e.client.view;if(!a||e.background||!P?.screen||P.paywall||P.pendingRequest||P.stopped||P.status!=="waiting")return;let O=Le.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:P.nodeId,visit:P.visit,revision:P.revision,customerToken:a}),K=Ee({...n,session:void 0});K.requestWithCredential("funnels",O,e.runToken,{keepalive:f}).then(()=>X(e.recovery)).catch(()=>{}).finally(()=>K.dispose())}let N=()=>{o&&S(o,n.session.peek(),!0)},z=()=>Date.now()<$&&performance.now()<J;function B(e){if(e.target.release!==n.appManifestRelease||!z())return!1;try{return se(e.target.render,document,location.pathname,()=>{})}catch{return u("incompatible",e.id),!1}}function Q(e){if(r||e.epoch!==M||e.visit!==g||document.visibilityState==="hidden")return!1;try{return se(e.target.render,document,location.pathname,()=>{})}catch{return!1}}async function ee(e){if(ce()){u("in_progress",e.id);return}if(!n.session.peek()){u("identity_required",e.id);return}let a=T.load(),f=a?.entries.find(O=>O.command.funnelId===e.funnelId&&(!O.expiresAt||Date.parse(O.expiresAt)>Date.now()));if(f){if(!ae(f)){u("recovery_pending",e.id);return}let O={...f,storageKey:a.key,epoch:M,visit:g};j.add(O.command.requestId),A=O,await re(O);return}let P={freshStart:!0,command:me.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:crypto.randomUUID(),locale:document.documentElement.lang||"en"}),epoch:M,visit:g,target:e.target,storageKey:a?.key};j.add(P.command.requestId),A=P,await re(P)}async function re(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let f,P=!1,O=!1;async function K(k){if(e.epoch!==M)return;let E=k.view;if(!(e.storageKey&&E&&(ge(E)||E.paywall||E.pendingRequest))&&E&&["running","waiting"].includes(E.status))try{await k.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:E.nodeId,visit:E.visit,revision:E.revision}),X(e)}catch(x){if(!(x instanceof L&&x.code==="FORBIDDEN"))throw x}}try{oe(e),u("starting",e.command.entryId);let k=await D.request("funnels",e.command),E=Ge.safeParse(k);if(E.success){if(E.data.scope.projectId!==m.projectId||E.data.scope.environment!==m.environment)throw new L("SCOPE_MISMATCH","Entry scope changed");e.epoch===M&&u(E.data.reason,e.command.entryId),X(e),R(e);return}let x=Ve.parse(k);if(!x.runToken||x.scope.projectId!==m.projectId||x.scope.environment!==m.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new L("INVALID_RESPONSE","Invalid entry Run");if(e.epoch!==M){R(e),u("identity_changed",e.command.entryId);return}oe(e,x.run);let C=be({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?k:void 0});f=C,O=!0,await C.get(),O=!1;let Y=C.view;if(!Y||Y.id!==x.run.id||Y.source.type!=="funnel"||Y.source.id!==e.command.funnelId||Y.source.versionId!==e.command.versionId)throw new L("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(Y.status)){X(e),R(e),u("run_ended",e.command.entryId);return}let{showFunnelRun:ue}=await import("./funnel-runtime-host-UKSOOA4H.js");if(!Q(e)){await K(C),u("left_screen",e.command.entryId),R(e);return}let _e=!1,Ae=!1;if(o&&!o.background){await K(C),u("in_progress",e.command.entryId),R(e);return}o&&te();let ne=document.createElement("div");ne.hidden=ge(Y),n.container.append(ne);let Ce=await ue(ne,{...n.host,client:C,appManifestRelease:n.appManifestRelease,onState(H){t(C,H),Z(n.host?.onState,H)},onDismiss(H){_e=!0,ne.remove(),H&&!["running","waiting"].includes(H.status)&&X(e),o?.client===C&&(o=void 0,C.reset(),q(),H&&H.status!=="completed"&&u("run_ended",e.command.entryId)),Z(n.host?.onDismiss,H)},onComplete(H){Ae=!0,X(e),o?.client===C&&te(),Z(n.host?.onComplete,H)},onError(H){Z(n.host?.onError,H),o?.client===C&&H instanceof L&&H.code==="FORBIDDEN"&&(X(e),te(),u("run_ended",e.command.entryId))}}).catch(H=>{throw ne.remove(),H});if(!Q(e)||_e||Ae){Ce.destroy(),ne.remove(),Q(e)||await K(C),R(e);return}let le=ge(C.view??Y);ne.hidden=le,o={host:Ce,client:C,slot:ne,entryId:e.command.entryId,background:le,runToken:x.runToken,owner:n.session.peek(),recovery:e},le||(F=e.visit),P=!0,R(e),u("started",e.command.entryId),le&&u("run_background",e.command.entryId)}catch(k){k instanceof L&&(!f||O&&k.code==="FORBIDDEN")&&k.status!==void 0&&k.status>=400&&k.status<500&&!k.retryable&&(X(e),R(e)),e.epoch===M&&!r&&(u("start_failed",e.command.entryId),Z(n.host?.onError,k))}finally{P||f?.reset(),e.dispatching=!1}}function ae(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return se(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(){if(ce())return!1;let e=T.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){T.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||j.has(a.command.requestId)||!ae(a))continue;j.add(a.command.requestId);let f={...a,storageKey:e.key,epoch:M,visit:g};return A=f,re(f),!0}return!1}function de(){if(c=!1,r||!i||document.visibilityState==="hidden")return;ie();let e=o!==void 0&&!o.background;if(e&&(F=g),!W()){if(!z()){p=!0;return}p=!1;for(let a of b?.entries??[]){let f=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||V.has(f)||!B(a))){if(!n.session.peek()){u("identity_required",a.id);continue}if(F===g){V.add(f),e&&u("in_progress",a.id);continue}if(A){u("in_progress",a.id);return}V.add(f),ee(a);break}}}}let q=()=>{!c&&!r&&(c=!0,queueMicrotask(de))};function ie(){let e=location.origin+location.pathname;return e===U?!1:(U=e,g++,p=!0,V.clear(),j.clear(),!0)}function Xe(){ie()&&q()}function Re(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 f=a.closest("button,a,input");if(!(!f||f.matches(":disabled,[aria-disabled='true']")||f.closest("[hidden],[inert],[aria-hidden='true']")))for(let P of b?.entries??[]){let O=P.target.button;if(!(P.event!=="button_click"||!O||!B(P))){try{let K=Ie(document);if(!f.matches(O.selector)||K(O.selector,f)!==1)continue}catch{u("incompatible",P.id);continue}ee(P);break}}}async function Se(){if(r)return;if(s)return s;let e=++I,a=new AbortController;v=a;let f,P=new Promise((k,E)=>{f=()=>E(new L("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",f,{once:!0})}),O=setTimeout(()=>a.abort(),n.timeoutMs??5e3),K=(async()=>{let k=async()=>{let ue=await _(`${w}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!ue.ok)throw new L("SERVICE_UNAVAILABLE","Funnel entries unavailable",ue.status);return fe.parse(await ue.json())},E=await Promise.race([k(),P]),x=Date.parse(E.validatedAt),C=Date.parse(E.validUntil);if(E.scope.projectId!==m.projectId||E.scope.environment!==m.environment||E.scope.environmentId!==n.environmentId||E.release!==n.appManifestRelease||C<=Date.now()||x>Date.now()+5e3||C-x>6e4||C<=x)throw new L("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(r||e!==I)return;let Y=b===void 0;b=E,$=C,J=performance.now()+Math.min(C-Date.now(),6e4),(Y||p)&&q()})();s=K;try{await K}finally{clearTimeout(O),a.signal.removeEventListener("abort",f),s===K&&(s=void 0)}}async function Ye(){if(!(!i||r)){try{await Se()}catch{r||u("configuration_unavailable")}q()}}let Pe=pe({document,run:Ye,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,U=location.origin+location.pathname,h=he(Xe),d=n.session.subscribeIdentity(()=>{M++,p=!0,A=void 0,V.clear(),F=-1,j.clear(),o&&S(o,o.owner,!1),te(),q()}),l=new MutationObserver(q),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",Re,!0),addEventListener("pagehide",N),await Pe.refresh())},refresh:Se,async retry(){A&&!r&&A.epoch===M&&await re(A)},destroy(){r=!0,I++,Pe.destroy(),v?.abort(),l?.disconnect(),h?.(),d?.(),document.removeEventListener("click",Re,!0),removeEventListener("pagehide",N),N(),te(),D.dispose(),b=void 0}}}function In(n){let w=ye(n.baseUrl),m=n.fetch??globalThis.fetch.bind(globalThis),D,_=0,b=0,r=!1,i=!1,I=0,g=0,U=-1,M=!1,$="",J,c,s,p,v=new Set,h,d,l,o=(t,S)=>Z(n.onStatus,t,S),F=()=>Date.now()<_&&performance.now()<b;function A(t){try{return F()&&t.target.release===n.appManifestRelease&&se(t.target.render,document,location.pathname,()=>{})}catch{return o("incompatible",t.id),!1}}function R(){let t=l;l=void 0,t?.host.destroy(),t?.slot.remove()}async function V(t){if(t.dispatching)return;t.dispatching=!0;let S=I;try{let N=await t.process.open({operation:"entry_start",funnelId:t.entry.funnelId,versionId:t.entry.versionId,entryId:t.entry.id,release:n.appManifestRelease,locale:n.locale??"en"}),{showFunnelRun:z}=await import("./funnel-runtime-host-UKSOOA4H.js");if(r||S!==I||d!==t)return;let B=document.createElement("div");n.container.append(B),U=g;let Q=await z(B,{...n.host,client:N.controller,appManifestRelease:n.appManifestRelease,onDismiss(ee){l?.process===t.process&&(l=void 0,B.remove()),Z(n.host?.onDismiss,ee)}});if(r||S!==I||d!==t){Q.destroy(),B.remove();return}l={entry:t.entry,process:t.process,host:Q,slot:B},d=void 0,o("run_presented",t.entry.id)}catch(N){if(r||S!==I||d!==t)return;N instanceof L&&"result"in N?(d=void 0,t.process.destroy(),o("suppressed",t.entry.id),j()):o("entry_unavailable",t.entry.id)}finally{t.dispatching=!1}}function u(t){if(r||d||l||h||U===g||!A(t))return;let S=`${g}:${t.id}`;if(v.has(S))return;v.add(S);let N={entry:t,process:n.createProcess(t),visit:g};d=N,V(N)}function j(){M||r||(M=!0,queueMicrotask(()=>{if(M=!1,!(r||document.visibilityState==="hidden"||!F()||d||l||h||U===g)){for(let t of D?.entries??[])if(t.event==="screen_enter"&&A(t)){u(t);break}}}))}function T(t){if(!t.isTrusted||t.defaultPrevented||!(t.target instanceof Element)||d||l||h||U===g)return;let S=Ie(document,()=>{});for(let N of D?.entries??[]){let z=N.target.button;if(N.event!=="button_click"||!z||!A(N))continue;let B=t.target.closest(z.selector);if(!(!B||B.tagName.toLowerCase()!==z.tag||S(z.selector)!==1||B.matches(":disabled")||B.closest('[inert],[hidden],[aria-hidden="true"]'))){u(N);break}}}let X=()=>{let t=location.origin+location.pathname;t!==$&&($=t,g++,v.clear(),j())};async function oe(){if(r)return;if(c)return c;let t=I,S=new AbortController;J=S;let N,z=new Promise((re,ae)=>{N=ae}),B=()=>N(new L("TIMEOUT","Funnel entry read cancelled"));S.signal.addEventListener("abort",B,{once:!0});let Q=setTimeout(()=>S.abort(),n.timeoutMs??5e3),ee=(async()=>{let re=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ae=async()=>{let ie=await m(`${w}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${re}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:S.signal});if(!ie.ok)throw new L("SERVICE_UNAVAILABLE","Funnel entries unavailable",ie.status);return fe.parse(await ie.json())},W=await Promise.race([ae(),z]),de=Date.parse(W.validatedAt),q=Date.parse(W.validUntil);if(W.scope.projectId!==n.scope.projectId||W.scope.environment!==n.scope.environment||W.scope.environmentId!==n.environmentId||W.release!==n.appManifestRelease||q<=Date.now()||de>Date.now()+5e3||q<=de||q-de>6e4)throw new L("INVALID_RESPONSE","Entry scope or deadline changed");r||t!==I||(D=W,_=q,b=performance.now()+Math.min(q-Date.now(),6e4),j())})();c=ee;try{await ee}finally{clearTimeout(Q),S.signal.removeEventListener("abort",B),c===ee&&(c=void 0)}}async function te(){if(!(!i||r))try{await oe()}catch{r||o("configuration_unavailable")}}let ce=pe({document,run:te,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,$=location.origin+location.pathname,s=he(X),p=new MutationObserver(j),p.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",T,!0),await ce.refresh())},refresh:oe,async retry(){d&&!r&&await V(d)},async syncIdentity(){let t=l??d??h;if(t)try{let S=await t.process.syncIdentity();return h===t&&(d={entry:t.entry,process:t.process,visit:g},h=void 0,await V(d)),S}catch(S){throw t.process.view||(h={entry:t.entry,process:t.process,visit:g},d=void 0,R()),S}},async detach(){I++,J?.abort();let t=l??d??h;t&&(h={entry:t.entry,process:t.process,visit:g}),d=void 0,R(),t&&await t.process.detach()},destroy(){r=!0,I++,ce.destroy(),J?.abort(),p?.disconnect(),s?.(),document.removeEventListener("click",T,!0);let t=l??d??h;d=void 0,h=void 0,R(),t?.process.destroy(),D=void 0}}}async function $n(n,w){return(await import("./paywall-VYUBYBUI.js")).showPaywall(n,w)}async function zn(...n){return n[1]=qe(n[1]),(await import("./paywall-session-E5V42XUT.js")).createPaywallSession(...n)}async function Jn(...n){let w=n[1].signal?.aborted?void 0:Ue(n[1].client);try{return import("./screen-renderer-R5GH7XLV.js").catch(()=>{}),import("./paywall-VYUBYBUI.js").catch(()=>{}),await(await Je(()=>import("./funnel-runtime-host-UKSOOA4H.js"),n[1].prepared)).showFunnelRun(...n)}finally{w?.()}}async function Je(n,w){try{return await n()}catch(m){throw w&&w.state!=="adopted"&&await import("./funnel-paywall-prerender-QHCUZZY3.js").then(D=>D.preparedInternals(w)?.release(),()=>{}),m}}async function Xn(...n){return import("./screen-renderer-R5GH7XLV.js").catch(()=>{}),import("./paywall-VYUBYBUI.js").catch(()=>{}),(await Je(()=>import("./funnel-host-purchase-Z7FCJ5CX.js"),n[1].prepared)).showFunnelPurchase(...n)}async function Yn(...n){return import("./funnel-host-purchase-Z7FCJ5CX.js").catch(()=>{}),import("./screen-renderer-R5GH7XLV.js").catch(()=>{}),(await import("./funnel-paywall-prerender-QHCUZZY3.js")).prerenderFunnelPurchase(...n)}async function Zn(...n){return(await import("./content-AJDTSI7A.js")).mountContent(...n)}async function Wn(...n){return(await import("./content-AJDTSI7A.js")).prepareContent(...n)}export{L as LongplayError,y as MerchantBridgeError,tn as createBrowserFunnelCommandStorage,dn as createBrowserFunnelPurchaseStorage,an as createConfigurationSync,en as createFeatureClient,cn as createFunnelClient,mn as createFunnelPageExperiments,ln as createFunnelProcess,un as createFunnelPurchaseClient,be as createFunnelRunController,hn as createIamFunnelEntries,In as createIamFunnelProcessEntries,fn as createLocalFunnelClient,nn as createLongplay,yn as createMerchantBridge,zn as createPaywallSession,sn as evaluateFunnelNode,We as formatCouponDiscount,Ze as formatCouponMoney,Qe as formatCouponTerms,rn as getPaywallRecovery,Zn as mountContent,Wn as prepareContent,on as preparePaywallFallback,Yn as prerenderFunnelPurchase,Xn as showFunnelPurchase,Jn as showFunnelRun,$n as showPaywall};
|
|
1
|
+
import{a as gn,c as vn}from"./chunk-BL7E4RZ2.js";import{a as We,c as En}from"./chunk-VWMFR22O.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as ln,c as hn,d as In}from"./chunk-VKG6BB3Z.js";import"./chunk-M3GGR53D.js";import{a as yn}from"./chunk-W3K5ARMY.js";import"./chunk-UVUFJO2V.js";import{h as dn,i as pn,k as wn}from"./chunk-HS56A4IK.js";import{F as Ce,e as Xe,g as Ye,h as ge,i as ve,j as Ze,x as un}from"./chunk-HYE2YQYM.js";import{a as ze}from"./chunk-MHWPEMX7.js";import"./chunk-2HSD2SEU.js";import"./chunk-5XKFUFXK.js";import"./chunk-BTPEXSNY.js";import{B as He,D as qe,E as Ue,G as Ve,H as je,I as Ge,J as Je,K as Te,L as $e,x as _e,y as Le,z as Be}from"./chunk-2KKLY323.js";import"./chunk-R3YVDRTB.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import{aa as Ke,l as an,m as sn,n as cn}from"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import{c as fn,e as mn}from"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import{b as Ae}from"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as G}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import{c as we,d as Ee}from"./chunk-LVG5ED52.js";import"./chunk-3VUPVXAV.js";import"./chunk-RHF4NFCZ.js";import{b as U}from"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as Q}from"./chunk-DSPLGTQI.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 bn(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 Sn(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 R(m,s,E,_,M){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 N=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:M??(E===void 0?{}:{operationId:E})})}),J=await bn(N,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!N.ok){let O=$e.safeParse(J);throw!O.success||O.data.scope.projectId!==n.scope.projectId||O.data.scope.environment!==n.scope.environment||O.data.scope.environmentId!==n.scope.environmentId||O.data.requestId!==g||O.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status):new I(O.data.error.code,N.status,O.data.error.retryable,O.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",N.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status);return $.data}function P(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let M=P();if(_!==void 0&&Te.parse({operationId:_,customerId:M}),!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,N)=>{o=()=>N(l.reason),l.addEventListener("abort",o,{once:!0})});try{let N=E(async()=>{let c=await import("./merchant-bridge-contracts-GJQVKEAG.js");if(l.throwIfAborted(),S!==h||w!==M)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([N,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let M=P(),S=Te.parse({operationId:E,customerId:M}),l=await R(m,s,S.operationId,_,S);if(l.customerId!==M||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await R("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 R("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=P(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return R("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=P(),E=await B("customer_commerce",m,async(_,M)=>{let[S,l]=await Promise.all([_(),R("customer_commerce",U.unknown(),void 0,M)]),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(_,M)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,M),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(_,M)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,M),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:Ye,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),Qe=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 Qe.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(Qe.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,Me=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,R=!1){if(u!==void 0)try{let P=n.binding();if(!P)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...P,i,t]),requestId:y},z=b(B);if(Me.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!R&&!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=Me.get(t.storage);u||Me.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Re(){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 Pe=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Rn(n){let d=we(n.baseUrl),f=n.scope,b=Ae(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,R="",P=0,B=0,z=0,m=!1,s,E=!0,_,M,S,l,o,T=-1,g,N=e=>{g===e&&(O.release(e.deliveryTicket),g=void 0,k())},J=new Set,c=(e,a)=>Q(n.onStatus,e,a),$=Re(),O=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")}),Z=e=>te.forget(e.storageKey,e.command.requestId);function Y(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(),k()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Y(o.recovery,a);let p=Pe(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,k())}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=Ae({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Z(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function A(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!==P||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=P,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===P&&p===y&&document.visibilityState!=="hidden"&&A(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(C=>C.command.funnelId===e.funnelId&&(!C.expiresAt||Date.parse(C.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let C={...p,storageKey:a.key,epoch:P,visit:y};ee.add(C.command.requestId),g=C,await F(C);return}let v=crypto.randomUUID(),K=O.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),k();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:P,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await F(j)}async function F(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(C){if(e.epoch!==P)return;let D=C.view;if(!(e.storageKey&&D&&(Pe(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await C.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Z(e)}catch(x){if(!(x instanceof G&&x.code==="FORBIDDEN"))throw x}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=O.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Y(e),c("starting",e.command.entryId);let C=await b.request("funnels",e.command),D=Ze.safeParse(C);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===P&&c(D.data.reason,e.command.entryId),Z(e),N(e);return}let x=Xe.parse(C);if(!x.runToken||x.scope.projectId!==f.projectId||x.scope.environment!==f.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(O.accept(e.deliveryTicket,x.run.id),e.epoch!==P){N(e),c("identity_changed",e.command.entryId);return}Y(e,x.run);let L=Ce({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?C:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==x.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)){Z(e),N(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-AMJXEASH.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),N(e);return}let Fe=!1,ke=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),N(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Pe(ne),n.container.append(ie);let xe=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Q(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Z(e),o?.client===L&&(o=void 0,L.reset(),k(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Q(n.host?.onDismiss,q)},onComplete(q){ke=!0,Z(e),o?.client===L&&re(),Q(n.host?.onComplete,q)},onError(q){Q(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Z(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||ke){xe.destroy(),ie.remove(),H(e)||await j(L),N(e);return}let he=Pe(L.view??ne);ie.hidden=he,o={host:xe,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:x.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,N(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(C){C instanceof G&&(!p||K&&C.code==="FORBIDDEN")&&C.status!==void 0&&C.status>=400&&C.status<500&&!C.retryable&&(Z(e),N(e)),e.epoch===P&&!t&&(c("start_failed",e.command.entryId),Q(n.host?.onError,C))}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:P,visit:y};return g=p,F(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)||!A(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 k=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===R?!1:(R=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&k()}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||!A(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 Ne(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((C,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 C=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([C(),v]),x=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()||x>Date.now()+5e3||L-x>6e4||L<=x)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)&&k()})();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 Ne()}catch{t||c("configuration_unavailable")}k()}}let Oe=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,R=location.origin+location.pathname,M=Ee(oe),S=n.session.subscribeIdentity(()=>{P++,$.cancel(),O.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),k()}),l=new MutationObserver(k),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",k),addEventListener("pagehide",ae),await Oe.refresh())},refresh:Ne,async retry(){g&&!t&&g.epoch===P&&await F(g)},destroy(){t=!0,u++,$.cancel(),O.release(g?.deliveryTicket),Oe.destroy(),_?.abort(),l?.disconnect(),M?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",k),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function Pn(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,R=0,P=-1,B=!1,z="",m,s,E,_,M=new Set,S,l,o,T=(r,A)=>Q(n.onStatus,r,A),g=Re(),N=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(N()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=N();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 O(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 A=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-AMJXEASH.js");if(t||A!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),P=R;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Q(n.host?.onDismiss,X)}});if(t||A!==y||l!==r){F.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:F,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||A!==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),Y()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Z(r){if(t||i||l||o||S||g.active||P===R||!O(r))return;let A=`${R}:${r.id}`;if(M.has(A))return;M.add(A);let H=R,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&R===H&&J()===V&&document.visibilityState!=="hidden"&&O(r)&&b?.entries.some(F=>F.id===r.id&&F.funnelId===r.funnelId&&F.versionId===r.versionId&&F.event===r.event&&JSON.stringify(F.target)===JSON.stringify(r.target)&&JSON.stringify(F.delivery)===JSON.stringify(r.delivery))===!0,()=>{let F=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(F===!1){T("frequency",r.id),Y();return}try{let X={entry:r,process:n.createProcess(r),visit:R,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Q(n.host?.onError,X)}},()=>{M.delete(A)})}function Y(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||P===R)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!M.has(`${R}:${r.id}`)&&O(r)){Z(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||P===R)return;let A=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!O(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||A(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Z(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,R++,g.cancel(),M.clear(),Y())};async function me(){if(t)return;if(s)return s;let r=y,A=new AbortController;m=A;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));A.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>A.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:A.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},k=await Promise.race([ue(),W]),se=Date.parse(k.validatedAt),oe=Date.parse(k.validUntil);if(k.scope.projectId!==n.scope.projectId||k.scope.environment!==n.scope.environment||k.scope.environmentId!==n.environmentId||k.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=k,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Y())})();s=X;try{await X}finally{clearTimeout(F),A.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(Y),_.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",Y),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,Y();return}try{let A=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:R},S=void 0,await te(l)),A}catch(A){throw r.process.view||(S={...r,visit:R},l=void 0,ee()),A}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:R}),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",Y);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function it(n,d){return(await import("./paywall-ATZ2IZPS.js")).showPaywall(n,d)}async function ot(...n){return n[1]=ze(n[1]),(await import("./paywall-session-EMMF6IYS.js")).createPaywallSession(...n)}async function at(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),import("./paywall-ATZ2IZPS.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-AMJXEASH.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-OSBI4VMY.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function st(...n){return import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),import("./paywall-ATZ2IZPS.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-M7MM33EC.js"),n[1].prepared)).showFunnelPurchase(...n)}async function ct(...n){return import("./funnel-host-purchase-M7MM33EC.js").catch(()=>{}),import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),(await import("./funnel-paywall-prerender-OSBI4VMY.js")).prerenderFunnelPurchase(...n)}async function dt(...n){return(await import("./content-RGKTEV23.js")).mountContent(...n)}async function lt(...n){return(await import("./content-RGKTEV23.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,un as createBrowserFunnelCommandStorage,gn as createBrowserFunnelPurchaseStorage,pn as createConfigurationSync,dn as createFeatureClient,hn as createFunnelClient,En as createFunnelPageExperiments,In as createFunnelProcess,vn as createFunnelPurchaseClient,Ce as createFunnelRunController,Rn as createIamFunnelEntries,Pn as createIamFunnelProcessEntries,wn as createLocalFunnelClient,ln as createLongplay,Sn as createMerchantBridge,ot as createPaywallSession,yn as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,fn as getPaywallRecovery,dt as mountContent,lt as prepareContent,mn as preparePaywallFallback,ct as prerenderFunnelPurchase,st as showFunnelPurchase,at as showFunnelRun,it as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as r,O as m,h as e}from"./chunk-2KKLY323.js";import"./chunk-WRLVPHPE.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import"./chunk-7ZEXY4GC.js";import"./chunk-ZYN4CRHS.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
|