@tinkerlandai/indiana-sdk 0.8.1 → 0.8.3
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 +7 -0
- package/dist/{ai-usage-JoM7ZWk-.d.ts → ai-usage-BV-FlgWr.d.ts} +1 -1
- package/dist/{api-JVC7x2FV.d.ts → api-B3FIE41b.d.ts} +381 -7
- package/dist/chunk-2QPETWDX.js +1 -0
- package/dist/chunk-ANOOBDW5.js +350 -0
- package/dist/chunk-BNU6IG3F.js +1 -0
- package/dist/{chunk-YWFNWK7C.js → chunk-GRLMT5PR.js} +1 -1
- package/dist/chunk-LMR2TM3X.js +1 -0
- package/dist/chunk-OBYJWIRB.js +1 -0
- package/dist/{chunk-USLZX2ZA.js → chunk-SHSNIJJM.js} +1 -1
- package/dist/{chunk-6HG7U6AU.js → chunk-SOQO2RDZ.js} +1 -1
- package/dist/{chunk-KSNOXNTC.js → chunk-VVV3JNS3.js} +1 -1
- package/dist/{chunk-56AYS7RS.js → chunk-Y32NPIYY.js} +1 -1
- package/dist/chunk-ZT66RIFU.js +10 -0
- package/dist/{configuration-sync-BexM2qbg.d.ts → configuration-sync-DNvKXHk-.d.ts} +2 -2
- package/dist/{content-YNL2CRJZ.js → content-J3FKZTGT.js} +1 -1
- package/dist/{errors-DrdTlPwf.d.ts → errors-C8lRYZ0n.d.ts} +48 -1
- package/dist/{funnel-local-client-D1Fe7CZ6.d.ts → funnel-local-client-wbz-4gFx.d.ts} +28 -19
- package/dist/{funnel-runtime-host-CAMI6BJS.js → funnel-runtime-host-C5P5JTV3.js} +1 -1
- package/dist/index.d.ts +104 -14
- 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/{paywall-MXRMMF3R.js → paywall-3GIRKSHN.js} +1 -1
- package/dist/popup.d.ts +1 -1
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +97 -4
- package/dist/react-native.js +1 -1
- package/dist/{screen-renderer-P7MLBHY5.js → screen-renderer-5FPYVSPW.js} +1 -1
- package/dist/server.d.ts +11 -8
- package/dist/server.js +1 -1
- package/dist/src-BMJCIMIF.js +1 -0
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3BQFJANQ.js +0 -1
- package/dist/chunk-AE4CUTUE.js +0 -1
- package/dist/chunk-AEUFCOFG.js +0 -1
- package/dist/chunk-F767CM3T.js +0 -7
- package/dist/chunk-X7JJAEQQ.js +0 -350
- package/dist/src-G7UQB3QE.js +0 -1
- package/dist/{screen-i6eHL11m.d.ts → screen-BpAejkn0.d.ts} +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as StackNode } from './screen-
|
|
2
|
+
import { S as StackNode } from './screen-BpAejkn0.js';
|
|
3
3
|
|
|
4
4
|
declare const configurationScopeSchema: z.ZodObject<{
|
|
5
5
|
projectId: z.ZodString;
|
|
@@ -608,7 +608,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
608
608
|
event: string;
|
|
609
609
|
} | {
|
|
610
610
|
type: "api";
|
|
611
|
-
operation: "update" | "attach" | "refund" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
|
|
611
|
+
operation: "update" | "attach" | "refund" | "sendMessage" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
|
|
612
612
|
inputs: Record<string, {
|
|
613
613
|
source: "literal";
|
|
614
614
|
value: z.core.util.JSONType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as H}from"./chunk-
|
|
1
|
+
import{h as H}from"./chunk-ANOOBDW5.js";import{a as b}from"./chunk-DSPLGTQI.js";import"./chunk-2QPETWDX.js";import{Pc as D}from"./chunk-ZT66RIFU.js";import{a as f}from"./chunk-SOQO2RDZ.js";import{Eb as T,Mb as L,Ob as j,tb as k}from"./chunk-LMR2TM3X.js";import"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import{a as I}from"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";import{z as l}from"zod";var x=new WeakMap;function P(o){let t={string:l.string(),number:l.number().finite(),boolean:l.boolean(),strings:l.array(l.string()),json:I}[o.type];return o.nullable?t.nullable():t}async function J(o,t){let S=D.parse(t.content),r=S.document;if(x.has(o))throw new f("CONFLICT","Content is already mounted in this container");let u=l.record(l.string(),I).parse(t.inputs??{});if(Object.keys(u).length>40)throw new f("INVALID_REQUEST","Too many content inputs");for(let[e,i]of Object.entries(u))L.parse({[e]:i});if(Object.keys(u).some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new f("INVALID_REQUEST","Undeclared content input");for(let[e,i]of Object.entries(r.contract.inputs))if(Object.hasOwn(u,e))P(i).parse(u[e]);else if(i.required)throw new f("INVALID_REQUEST",`Missing content input ${e}`);for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new f("INVALID_REQUEST",`Missing host handler for ${e}`);let R=j.parse(t.bindings??[]),d=o.ownerDocument,v=d.activeElement,A=r.kind==="popup",n=A?d.createElement("dialog"):null,s=d.createElement("div");if(s.dataset.indianaContent=r.kind,s.setAttribute("aria-label",r.name),s.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${k[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",n.append(s),o.append(n)}else o.append(s);let m=!1,g=!1,a=null,w=structuredClone(r.screen);w.actions=w.actions.map(e=>e.type==="event"?{...e,close:!1}:e);let h;function E(){m||(m=!0,h?.destroy(),n?.close(),n?.remove(),s.remove(),x.delete(o),n&&v instanceof HTMLElement&&v.isConnected&&v.focus())}let C=()=>{E(),b(t.onDismiss)};if(n){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),e.style.cssText="position:absolute;right:8px;top:8px;width:30px;height:30px;z-index:1",e.addEventListener("click",C),n.prepend(e)}n?.addEventListener("cancel",e=>{e.preventDefault(),C()});async function V(){if(m||g||!a)return;let e=a;g=!0,s.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),a=null}catch(i){b(t.onError,i)}finally{g=!1,m||s.removeAttribute("aria-busy")}}try{n?.showModal(),h=H(s,{mode:"live",title:r.name,viewportHeight:r.kind==="page"?o.clientHeight||d.defaultView?.innerHeight||800:void 0,onError:c=>b(t.onError,new Error(c)),onEscape:A?C:void 0,onAction:(c,U,M)=>{if(m||g||a)return;let p=r.screen.actions.find(y=>y.id===c),O=r.contract.outputs[c];if(!(p?.type!=="event"||!O))try{let y=P(O).parse(Object.hasOwn(p.properties,"value")?p.properties.value:p.properties);a={requestId:crypto.randomUUID(),contentVersionId:S.id,actionId:c,event:p.event,value:y,selection:U??{},answers:M??{},requestedClose:p.close},V()}catch(y){b(t.onError,y)}}});let e={destroy:E,get pendingAction(){return a?structuredClone(a):null},retryAction:V,updateCapabilities:c=>h?.updateCapabilities(c)};x.set(o,e);let i=T(w,[t.locale,...d.defaultView?.navigator.languages??[]]);return h.update(w,i,{capabilities:t.capabilities,serverInput:{bindings:R,answers:{},values:u}}),await h.ready,e}catch(e){throw E(),e}}export{J as mountContent};
|
|
@@ -9,6 +9,33 @@ declare const scopeSchema: z.ZodObject<{
|
|
|
9
9
|
}, z.core.$strict>;
|
|
10
10
|
type Scope = z.infer<typeof scopeSchema>;
|
|
11
11
|
|
|
12
|
+
declare const pushPlatformSchema: z.ZodEnum<{
|
|
13
|
+
ios: "ios";
|
|
14
|
+
android: "android";
|
|
15
|
+
}>;
|
|
16
|
+
declare const pushAddressRequestSchema: z.ZodObject<{
|
|
17
|
+
installationId: z.ZodUUID;
|
|
18
|
+
publicKey: z.ZodString;
|
|
19
|
+
issuedAt: z.ZodISODateTime;
|
|
20
|
+
signature: z.ZodString;
|
|
21
|
+
sequence: z.ZodNumber;
|
|
22
|
+
credentialDigest: z.ZodString;
|
|
23
|
+
connectionId: z.ZodNullable<z.ZodUUID>;
|
|
24
|
+
kind: z.ZodNullable<z.ZodEnum<{
|
|
25
|
+
fcm_token: "fcm_token";
|
|
26
|
+
apns_token: "apns_token";
|
|
27
|
+
}>>;
|
|
28
|
+
token: z.ZodNullable<z.ZodString>;
|
|
29
|
+
permission: z.ZodEnum<{
|
|
30
|
+
unknown: "unknown";
|
|
31
|
+
denied: "denied";
|
|
32
|
+
provisional: "provisional";
|
|
33
|
+
granted: "granted";
|
|
34
|
+
}>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
type PushPlatform = z.infer<typeof pushPlatformSchema>;
|
|
37
|
+
type PushAddressObservation = Pick<z.infer<typeof pushAddressRequestSchema>, "connectionId" | "kind" | "token" | "permission">;
|
|
38
|
+
|
|
12
39
|
declare const errorRecoverySchema: z.ZodEnum<{
|
|
13
40
|
fix_request: "fix_request";
|
|
14
41
|
authenticate: "authenticate";
|
|
@@ -38,6 +65,26 @@ declare const errorReasonSchema: z.ZodEnum<{
|
|
|
38
65
|
}>;
|
|
39
66
|
type ErrorReason = z.infer<typeof errorReasonSchema>;
|
|
40
67
|
|
|
68
|
+
type PushJournal = {
|
|
69
|
+
identitySeq: number;
|
|
70
|
+
addressSeq: number;
|
|
71
|
+
detachSeq: number | null;
|
|
72
|
+
};
|
|
73
|
+
/** Scope-bound protected native storage. transaction commits atomically before
|
|
74
|
+
* returning; it never stores Customer credentials or provider tokens. */
|
|
75
|
+
interface PushHost {
|
|
76
|
+
readonly installationId: string;
|
|
77
|
+
readonly publicKey: string;
|
|
78
|
+
readonly platform: PushPlatform;
|
|
79
|
+
readonly scope: Scope;
|
|
80
|
+
transaction(update: (current: PushJournal) => PushJournal): PushJournal;
|
|
81
|
+
/** P-256 SHA-256, 64-byte IEEE-P1363 signature as unpadded base64url. */
|
|
82
|
+
sign(payload: Uint8Array): Promise<string>;
|
|
83
|
+
/** Native bridge fallback on runtimes without Web Crypto, including Hermes. */
|
|
84
|
+
sha256?(payload: Uint8Array): Promise<string>;
|
|
85
|
+
onError?(error: Error): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
41
88
|
declare class IndianaError extends Error {
|
|
42
89
|
readonly code: string;
|
|
43
90
|
readonly status?: number | undefined;
|
|
@@ -54,4 +101,4 @@ declare class IndianaError extends Error {
|
|
|
54
101
|
});
|
|
55
102
|
}
|
|
56
103
|
|
|
57
|
-
export { IndianaError as I, type Scope as S };
|
|
104
|
+
export { IndianaError as I, type PushAddressObservation as P, type Scope as S, type PushHost as a, type PushJournal as b };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { I as InvoiceModeParams,
|
|
2
|
-
import { S as StackNode, d as ScreenSelection } from './screen-
|
|
1
|
+
import { I as InvoiceModeParams, b as InvoiceModeParamsInput, A as ApiInput } from './api-B3FIE41b.js';
|
|
2
|
+
import { S as StackNode, d as ScreenSelection } from './screen-BpAejkn0.js';
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { E as EvaluationContext, J as JsonValue, F as FeatureResult } from './growth-rules-B4YYy64R.js';
|
|
6
|
-
import { S as Scope } from './errors-
|
|
7
|
-
import { C as ConfigurationSync } from './configuration-sync-
|
|
6
|
+
import { a as PushHost, S as Scope } from './errors-C8lRYZ0n.js';
|
|
7
|
+
import { C as ConfigurationSync } from './configuration-sync-DNvKXHk-.js';
|
|
8
8
|
|
|
9
9
|
declare const currencySchema: z.ZodEnum<{
|
|
10
10
|
USD: "USD";
|
|
@@ -99,6 +99,7 @@ declare const funnelCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
99
99
|
customerData: z.ZodOptional<z.ZodObject<{
|
|
100
100
|
name: z.ZodOptional<z.ZodString>;
|
|
101
101
|
email: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodLiteral<"">]>>;
|
|
102
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
102
103
|
attributes: z.ZodOptional<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodJSONSchema>, z.ZodObject<{
|
|
103
104
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
104
105
|
}, z.core.$loose>>>;
|
|
@@ -197,8 +198,8 @@ declare const funnelCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
197
198
|
success: "success";
|
|
198
199
|
failed: "failed";
|
|
199
200
|
cancel: "cancel";
|
|
200
|
-
failure: "failure";
|
|
201
201
|
opened: "opened";
|
|
202
|
+
failure: "failure";
|
|
202
203
|
}>;
|
|
203
204
|
}, z.core.$strict>], "type">;
|
|
204
205
|
requestId: z.ZodUUID;
|
|
@@ -7490,6 +7491,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7490
7491
|
customerData: z.ZodOptional<z.ZodObject<{
|
|
7491
7492
|
name: z.ZodOptional<z.ZodString>;
|
|
7492
7493
|
email: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodLiteral<"">]>>;
|
|
7494
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7493
7495
|
attributes: z.ZodOptional<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodJSONSchema>, z.ZodObject<{
|
|
7494
7496
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7495
7497
|
}, z.core.$loose>>>;
|
|
@@ -7588,8 +7590,8 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7588
7590
|
success: "success";
|
|
7589
7591
|
failed: "failed";
|
|
7590
7592
|
cancel: "cancel";
|
|
7591
|
-
failure: "failure";
|
|
7592
7593
|
opened: "opened";
|
|
7594
|
+
failure: "failure";
|
|
7593
7595
|
}>;
|
|
7594
7596
|
}, z.core.$strict>], "type">;
|
|
7595
7597
|
requestId: z.ZodUUID;
|
|
@@ -7666,7 +7668,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7666
7668
|
} | {
|
|
7667
7669
|
type: "client_action";
|
|
7668
7670
|
receiptId: string;
|
|
7669
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
7671
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
7670
7672
|
};
|
|
7671
7673
|
requestId: string;
|
|
7672
7674
|
nodeId: string;
|
|
@@ -7720,6 +7722,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7720
7722
|
customerData?: {
|
|
7721
7723
|
name?: string | undefined;
|
|
7722
7724
|
email?: string | undefined;
|
|
7725
|
+
phone?: string | null | undefined;
|
|
7723
7726
|
attributes?: (Record<string, z.core.util.JSONType> & {
|
|
7724
7727
|
[x: string]: unknown;
|
|
7725
7728
|
tags?: string[] | undefined;
|
|
@@ -7789,7 +7792,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7789
7792
|
} | {
|
|
7790
7793
|
type: "client_action";
|
|
7791
7794
|
receiptId: string;
|
|
7792
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
7795
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
7793
7796
|
};
|
|
7794
7797
|
requestId: string;
|
|
7795
7798
|
nodeId: string;
|
|
@@ -7846,6 +7849,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7846
7849
|
customerData: z.ZodOptional<z.ZodObject<{
|
|
7847
7850
|
name: z.ZodOptional<z.ZodString>;
|
|
7848
7851
|
email: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodLiteral<"">]>>;
|
|
7852
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7849
7853
|
attributes: z.ZodOptional<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodJSONSchema>, z.ZodObject<{
|
|
7850
7854
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7851
7855
|
}, z.core.$loose>>>;
|
|
@@ -7944,8 +7948,8 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
7944
7948
|
success: "success";
|
|
7945
7949
|
failed: "failed";
|
|
7946
7950
|
cancel: "cancel";
|
|
7947
|
-
failure: "failure";
|
|
7948
7951
|
opened: "opened";
|
|
7952
|
+
failure: "failure";
|
|
7949
7953
|
}>;
|
|
7950
7954
|
}, z.core.$strict>], "type">;
|
|
7951
7955
|
requestId: z.ZodUUID;
|
|
@@ -8022,7 +8026,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8022
8026
|
} | {
|
|
8023
8027
|
type: "client_action";
|
|
8024
8028
|
receiptId: string;
|
|
8025
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
8029
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
8026
8030
|
};
|
|
8027
8031
|
requestId: string;
|
|
8028
8032
|
nodeId: string;
|
|
@@ -8076,6 +8080,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8076
8080
|
customerData?: {
|
|
8077
8081
|
name?: string | undefined;
|
|
8078
8082
|
email?: string | undefined;
|
|
8083
|
+
phone?: string | null | undefined;
|
|
8079
8084
|
attributes?: (Record<string, z.core.util.JSONType> & {
|
|
8080
8085
|
[x: string]: unknown;
|
|
8081
8086
|
tags?: string[] | undefined;
|
|
@@ -8145,7 +8150,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8145
8150
|
} | {
|
|
8146
8151
|
type: "client_action";
|
|
8147
8152
|
receiptId: string;
|
|
8148
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
8153
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
8149
8154
|
};
|
|
8150
8155
|
requestId: string;
|
|
8151
8156
|
nodeId: string;
|
|
@@ -8210,6 +8215,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8210
8215
|
customerData?: {
|
|
8211
8216
|
name?: string | undefined;
|
|
8212
8217
|
email?: string | undefined;
|
|
8218
|
+
phone?: string | null | undefined;
|
|
8213
8219
|
attributes?: (Record<string, z.core.util.JSONType> & {
|
|
8214
8220
|
[x: string]: unknown;
|
|
8215
8221
|
tags?: string[] | undefined;
|
|
@@ -8279,7 +8285,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8279
8285
|
} | {
|
|
8280
8286
|
type: "client_action";
|
|
8281
8287
|
receiptId: string;
|
|
8282
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
8288
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
8283
8289
|
};
|
|
8284
8290
|
requestId: string;
|
|
8285
8291
|
nodeId: string;
|
|
@@ -8344,6 +8350,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8344
8350
|
customerData?: {
|
|
8345
8351
|
name?: string | undefined;
|
|
8346
8352
|
email?: string | undefined;
|
|
8353
|
+
phone?: string | null | undefined;
|
|
8347
8354
|
attributes?: (Record<string, z.core.util.JSONType> & {
|
|
8348
8355
|
[x: string]: unknown;
|
|
8349
8356
|
tags?: string[] | undefined;
|
|
@@ -8413,7 +8420,7 @@ declare const funnelPendingEntrySchema: z.ZodObject<{
|
|
|
8413
8420
|
} | {
|
|
8414
8421
|
type: "client_action";
|
|
8415
8422
|
receiptId: string;
|
|
8416
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
8423
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
8417
8424
|
};
|
|
8418
8425
|
requestId: string;
|
|
8419
8426
|
nodeId: string;
|
|
@@ -8475,6 +8482,8 @@ interface FunnelCommandStorage {
|
|
|
8475
8482
|
}
|
|
8476
8483
|
|
|
8477
8484
|
interface IndianaOptions {
|
|
8485
|
+
/** Optional native installation adapter; shares this client's identity and transport. */
|
|
8486
|
+
push?: PushHost;
|
|
8478
8487
|
/** Override the per-Run CAS adapter. Secure browser hosts use Web Locks/localStorage by default; non-browser hosts supply their own adapter. */
|
|
8479
8488
|
funnelCommandStorage?: FunnelCommandStorage;
|
|
8480
8489
|
/** One public GB/Funnel configuration manager shared by this App/environment's consumers. */
|
|
@@ -9493,7 +9502,7 @@ declare function createLocalFunnelClient(options: LocalFunnelClientOptions): Pro
|
|
|
9493
9502
|
event: string;
|
|
9494
9503
|
} | {
|
|
9495
9504
|
type: "api";
|
|
9496
|
-
operation: "update" | "attach" | "refund" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
|
|
9505
|
+
operation: "update" | "attach" | "refund" | "sendMessage" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
|
|
9497
9506
|
inputs: Record<string, {
|
|
9498
9507
|
source: "literal";
|
|
9499
9508
|
value: zod.JSONType;
|
|
@@ -11563,7 +11572,7 @@ declare function createLocalFunnelClient(options: LocalFunnelClientOptions): Pro
|
|
|
11563
11572
|
} | {
|
|
11564
11573
|
type: "client_action";
|
|
11565
11574
|
receiptId: string;
|
|
11566
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
11575
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
11567
11576
|
};
|
|
11568
11577
|
requestId: string;
|
|
11569
11578
|
nodeId: string;
|
|
@@ -11636,7 +11645,7 @@ declare function createLocalFunnelClient(options: LocalFunnelClientOptions): Pro
|
|
|
11636
11645
|
} | {
|
|
11637
11646
|
type: "client_action";
|
|
11638
11647
|
receiptId: string;
|
|
11639
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
11648
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
11640
11649
|
};
|
|
11641
11650
|
requestId: string;
|
|
11642
11651
|
nodeId: string;
|
|
@@ -19598,7 +19607,7 @@ declare function createLocalFunnelClient(options: LocalFunnelClientOptions): Pro
|
|
|
19598
19607
|
event: string;
|
|
19599
19608
|
} | {
|
|
19600
19609
|
type: "api";
|
|
19601
|
-
operation: "update" | "attach" | "refund" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
|
|
19610
|
+
operation: "update" | "attach" | "refund" | "sendMessage" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
|
|
19602
19611
|
inputs: Record<string, {
|
|
19603
19612
|
source: "literal";
|
|
19604
19613
|
value: zod.JSONType;
|
|
@@ -21668,7 +21677,7 @@ declare function createLocalFunnelClient(options: LocalFunnelClientOptions): Pro
|
|
|
21668
21677
|
} | {
|
|
21669
21678
|
type: "client_action";
|
|
21670
21679
|
receiptId: string;
|
|
21671
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
21680
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
21672
21681
|
};
|
|
21673
21682
|
requestId: string;
|
|
21674
21683
|
nodeId: string;
|
|
@@ -21741,7 +21750,7 @@ declare function createLocalFunnelClient(options: LocalFunnelClientOptions): Pro
|
|
|
21741
21750
|
} | {
|
|
21742
21751
|
type: "client_action";
|
|
21743
21752
|
receiptId: string;
|
|
21744
|
-
outcome: "success" | "failed" | "cancel" | "
|
|
21753
|
+
outcome: "success" | "failed" | "cancel" | "opened" | "failure";
|
|
21745
21754
|
};
|
|
21746
21755
|
requestId: string;
|
|
21747
21756
|
nodeId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as X}from"./chunk-DSPLGTQI.js";import{a as le,b as ue,d as de}from"./chunk-YWFNWK7C.js";import"./chunk-AEUFCOFG.js";import{Qd as ae,bg as re}from"./chunk-F767CM3T.js";import{a as u}from"./chunk-6HG7U6AU.js";import{Hb as se}from"./chunk-3BQFJANQ.js";import"./chunk-AE4CUTUE.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";function ce(e){let C=e.view;if(!C?.paywall)throw new u("INVALID_REQUEST","The current node is not a Paywall");let n=C.paywall.receiptId,P=C.nodeId,h=C.visit,o=C.paywall.resolution,k=o,s="document"in o?o:null;function v(i){if(!le(i,o))throw new u("INVALID_RESPONSE","The pinned Paywall binding changed")}let a=C.paywall.quote,R=C.paywall.operation,S=!1,T=new AbortController,l=C.paywall.purchaseRequestId,r=0,f=C.paywall.selectionGeneration??0,E=C.paywall.canReselect===!0,y=null,O=new Map,U=new Map;function G(i){if(i.purchase&&i.purchase.receiptId!==n)throw new u("INVALID_RESPONSE","Purchase receipt changed");let w=i.run.paywall;return i.purchase??(w?.receiptId===n?w:null)}function F(){if(S)throw new u("IDENTITY_CHANGED","Paywall presentation has closed")}function _(i,w,c){if(F(),w!==r||c!==void 0&&a?.operationId!==c)return!1;let I=f,d=i.run.paywall;if(d?.receiptId===n){if((d.selectionGeneration??0)<f)return!1;f=d.selectionGeneration??0,E=d.canReselect===!0,v(d.resolution)}let m=G(i),p=f>I,N=p?m?.quote??null:m?.quote??a,q=m?.operation??(N?.operationId===a?.operationId?R:null);return N&&q&&ue(q,{operationId:N.operationId},"Purchase operation changed"),d?.receiptId===n&&(k=d.resolution,s="document"in k?k:s?{...k,document:s.document,offering:s.offering}:null),(p||N?.operationId!==a?.operationId)&&(r++,d?.receiptId===n&&(l=d.purchaseRequestId)),a=N,R=de(R,q,!0),!0}function $(i,w,c){return new Promise((I,d)=>{let m=!1,p=()=>{clearTimeout(D),T.signal.removeEventListener("abort",J)},N=z=>{m||(m=!0,p(),I(z))},q=z=>{m||(m=!0,p(),d(z))},J=()=>q(new u("IDENTITY_CHANGED","Paywall presentation has closed")),D=setTimeout(()=>q(new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,c)),Math.max(0,w-Date.now()));T.signal.addEventListener("abort",J,{once:!0}),T.signal.aborted&&J(),i.then(N,q)})}function j(i){return new Promise(w=>{let c=()=>{clearTimeout(I),T.signal.removeEventListener("abort",c),w()},I=setTimeout(c,i);T.signal.addEventListener("abort",c,{once:!0}),T.signal.aborted&&c()})}async function A(i,w,c){F();let I=O.get(i);if(!I){let p=e.pendingCommands?.find(N=>N.requestId===i)??e.pendingCommand;if(p?.operation==="submit"&&p.requestId===i&&p.nodeId===P&&p.visit===h){w.type==="paywall_quote"&&p.input.type==="paywall_quote"&&p.input.predecessor&&!w.predecessor&&(w={...w,predecessor:p.input.predecessor});let N=re.parse(p),q=re.parse({...p,input:w});if(q.operation!=="submit"||N.operation!=="submit"||JSON.stringify(q.input)!==JSON.stringify(N.input))throw new u("CONFLICT","A restored purchase request cannot change its input");w=q.input,I=N,O.set(i,I)}}if(I){if(JSON.stringify(I.input)!==JSON.stringify(w))throw new u("CONFLICT","A purchase request cannot change its input")}else{let p=e.view;if(!p||p.nodeId!==P||p.visit!==h||p.paywall?.receiptId!==n)throw new u("PRECONDITION_FAILED","The Paywall visit has changed");I={operation:"submit",requestId:i,nodeId:P,visit:h,revision:p.revision,input:w},O.set(i,I)}let d=Date.now()+3e4,m=await $(e.submit(I),d,i);for(;m.run.pendingRequest?.requestId===i&&Date.now()<d&&!S&&(await j(Math.min(1e3,d-Date.now())),!(S||Date.now()>=d));)m=await $(e.resume(i),d,i);if(S)throw new u("IDENTITY_CHANGED","Paywall presentation has closed");if(m.run.pendingRequest?.requestId===i)throw new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,i);if(!_(m,c,w.type==="paywall_confirm"||w.type==="paywall_cancel"?w.operationId:void 0))throw new u("PRECONDITION_FAILED","The purchase selection has changed")}async function Q(i){if(!a)throw new u("INVALID_REQUEST","A quoted purchase is required");let w=`${i}:${a.operationId}`,c=U.get(w);if(!c){let I=i==="confirm"?"paywall_confirm":"paywall_cancel",d=e.pendingCommands?.find(m=>m.operation==="submit"&&m.input.type===I&&"operationId"in m.input&&m.input.operationId===a.operationId)??e.pendingCommand;c=d?.operation==="submit"&&d.input.type===I&&"operationId"in d.input&&d.input.operationId===a.operationId?d.requestId:crypto.randomUUID(),U.set(w,c)}if(await A(c,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:a.operationId},r),!R)throw new u("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(R)}return{get view(){return structuredClone(s)},get quote(){return a?structuredClone(a):null},get operation(){return R?structuredClone(R):null},get webViewUrl(){return e.webViewUrl},get canReselect(){return E},async refresh(){F();let i=r,w=await e.get();if(_(w,i),w.run.paywall?.receiptId!==n)throw new u("PRECONDITION_FAILED","Paywall presentation has changed");if(!s){if("document"in k||!e.resolvePaywall)throw new u("INVALID_RESPONSE","Public Paywall reader is unavailable");let c=await e.resolvePaywall(k);F(),v(c),s={...k,document:c.document,offering:c.offering}}return structuredClone(s)},preview(i){if(!s)return Promise.reject(new u("PRECONDITION_FAILED","Load the Paywall presentation first"));if(l&&l!==i.requestId&&(y||!E))return Promise.reject(new u("COMMAND_PENDING","Retry the original purchase before starting another"));if(l===i.requestId&&y)return y;let w=s.document.buttons[i.actionId],c=w?.type==="checkout"?ae(w.product,i.selection,s.capabilities):null;if(!c)return Promise.reject(new u("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let I=l!==i.requestId&&f>0?{operationId:a?.operationId??null,generation:f}:void 0;if(I&&(!E||f<=0))return Promise.reject(new u("COMMAND_PENDING","Original purchase requires authoritative termination"));l!==i.requestId&&r++;let d=r;l=i.requestId;let m=(async()=>{if(await A(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:c,...I?{predecessor:I}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}},d),!a)throw new u("INVALID_RESPONSE","The accepted quote is missing");return structuredClone(a)})();return y=m,m.then(()=>{y===m&&(y=null)},p=>{y===m&&(y=null),l===i.requestId&&e.pendingCommand?.requestId!==i.requestId&&p instanceof u&&p.status!==void 0&&p.status<500&&![401,425].includes(p.status)&&(l=null)}),m},confirm:()=>Q("confirm"),cancel:()=>Q("cancel"),async read(){if(F(),!a)throw new u("INVALID_REQUEST","A quoted purchase is required");let i=a.operationId,w=r,c=e.pendingCommands?.find(p=>p.operation==="submit"&&(p.input.type==="paywall_confirm"||p.input.type==="paywall_cancel")&&p.input.operationId===i)??e.pendingCommand;c?.operation==="submit"&&(c.input.type==="paywall_confirm"||c.input.type==="paywall_cancel")&&c.input.operationId===i&&await e.settle?.(c.requestId);let I=await e.get(void 0,{receiptId:n,operationId:i});F();let d=G(I);if(d?.quote&&d.quote.operationId!==i||d?.operation&&d.operation.operationId!==i)throw new u("INVALID_RESPONSE","Purchase operation changed");let m=_(I,w,i)?R:d?.operation;if(!m)throw new u("INVALID_RESPONSE","The current purchase result is missing");return structuredClone(m)},destroy(){S=!0,T.abort(),O.clear(),U.clear()}}}function pe(e){let C=new Set,n=new Set,P=null;function h(o){if(e.reviewing||C.has(o)||n.has(o)||e.stopped)return;n.add(o);let k=async()=>{if(e.reviewing||e.stopped||e.key!==o){n.delete(o);return}if(e.busy||e.client.pendingCommand){setTimeout(()=>{k()},250);return}let s=(async()=>{let a=e.client.view,R=e.expected(),S=R.requestId,T=!1;try{await e.client.submit({operation:"shown",...R})}catch(l){if(!(l instanceof u)||l.code!=="CONFLICT"||l.status!==409||e.client.pendingCommand)throw l;await e.client.get();let r=e.client.view;if(e.stopped||e.reviewing||e.key!==o||!r||!a||r.id!==a.id||r.source.versionId!==a.source.versionId||r.nodeId!==R.nodeId||r.visit!==R.visit||r.revision<=R.revision||r.stopped||!r.screen||!["running","waiting"].includes(r.status)||e.client.pendingCommand)throw l;let f=e.expected();S=f.requestId,await e.client.submit({operation:"shown",...f})}for(;!e.stopped&&e.key===o&&e.client.pendingCommand?.requestId===S;){if(!e.client.settle)throw new u("COMMAND_PENDING","The original display acknowledgement is still pending");await e.client.settle(S),T=!0,e.client.pendingCommand?.requestId===S&&await new Promise(l=>setTimeout(l,1500))}e.stopped||e.key!==o||(T&&await e.client.get(),!(e.stopped||e.key!==o)&&C.add(o))})();P=s;let v=()=>{P===s&&(P=null),n.delete(o)};s.then(v,a=>{v(),e.busy||e.fail(a)})};k()}return{report:h,get inFlight(){return P}}}function fe(e){let C={},n=new Map;async function P(h){let o=e.client.view,k=o?.screen,s=k?.customerData.nodes[h.nodeId];if(e.stopped||e.busy||!o||!k||!s)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(h.action)){let r=e.document,f=r?se(r,h.nodeId):null,E=f?.type==="customer_data"?f.data.outputs?.[h.action]:void 0;E&&k.outputs.includes(E)?await e.perform(()=>e.client.submit({operation:"submit",...e.expected(),input:{type:"screen",output:E,answers:e.answers,selection:h.value?{[h.nodeId]:h.value}:{}}})):await e.onIntent?.(h,o);return}let a=h.action.startsWith("sources_")?s.resources.find(r=>r.key===h.value):null;if(h.action.startsWith("sources_")&&!a)throw new u("INVALID_REQUEST","Choose a current resource");let R=`${o.visit}:${h.nodeId}:${a?.key??""}`,S=n.get(R)??[null],l=C[h.nodeId]??{page:1,after:null,filter:"all",...a?{resourceKey:a.key}:{}};if(h.action==="filter"){let r=h.value;if(!r||!(s.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(r))throw new u("INVALID_REQUEST","Unknown data filter");l={page:1,after:null,filter:r},S.splice(0,S.length,null)}else if(h.action==="next"||h.action==="sources_next"){let r=a?.sources.at(-1),f=a?r?{kind:"ledger",cursor:{at:r.detail[0],id:r.id,type:"source"}}:null:k.dataCursors[h.nodeId];if(!f||!a&&!s.hasNext)return;S[l.page]=f,l={...l,page:l.page+1,after:f}}else if(h.action==="previous"||h.action==="sources_previous"){if(l.page<=1)return;l={...l,page:l.page-1,after:S[l.page-2]??null}}n.set(R,S),C={...C,[h.nodeId]:l},await e.perform(()=>e.client.get({nodeId:o.nodeId,visit:o.visit,revision:o.revision,components:C}))}return{get queries(){return C},intent:P,reset(){C={},n.clear()}}}function we(e){let{doc:C,holder:n,reviewHolder:P,mountScreenPreview:h}=e,o=!1,k,s=0,v=null,a="",R=new Map,S=r=>r?`${r.id}:${r.nodeId}:${r.visit}:${r.revision}:${r.paywall?.quote?.operationId??""}`:"";async function T(r){if(e.stopped||!e.client.review)return;o||(a=S(e.client.view),R.set(a,structuredClone(e.answers))),o=!0,k=r,n.hidden=!0,e.suspend(!0),P.hidden=!1;let f=++s;try{let E=await e.client.review(r);if(e.stopped||f!==s||!o)return;if(!E.review)throw new u("INVALID_RESPONSE","Historical projection is missing");v?.destroy(),v=null,P.replaceChildren();let y=E.run.locale.startsWith("zh"),O=C.createElement("p");O.textContent=y?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",P.append(O);for(let[F,_]of E.review.pages.entries()){let $=C.createElement("button");$.type="button",$.textContent=y?`\u7B2C ${F+1} \u9875`:`Page ${F+1}`,$.onclick=()=>{T(_.receiptId)},P.append($)}if(E.review.page){let F=E.review.page,_=C.createElement("div");if(_.inert=!0,P.append(_),v=h(_,{mode:"live",rendererUrl:e.client.webViewUrl,title:F.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{},onEscape:()=>{l()}}),v.update(F.document,E.run.locale,{serverInput:{bindings:F.inputs,answers:F.answers,values:F.values}}),await v.ready,e.stopped||f!==s||!o)return}let U=y?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},G=y?{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"};for(let F of[...E.review.coupons.map((_,$)=>`${y?"\u4F18\u60E0\u5238":"Coupon"} ${$+1}: ${U[_.status]}`),...E.review.purchases.map((_,$)=>`${y?"\u8D2D\u4E70":"Purchase"} ${$+1}: ${G[_.status]}`)]){let _=C.createElement("p");_.textContent=F,P.append(_)}e.client.view&&await e.enqueue(e.client.view)}catch(E){if(f!==s||e.stopped)return;v?.destroy(),v=null,P.replaceChildren(),e.fail(E)}}async function l(){if(!o||e.stopped||!e.client.review)return;let r=++s;try{if(await e.client.review(),e.stopped||r!==s)return;o=!1,s++,v?.destroy(),v=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1;let f=e.client.view;S(f)!==a?(R.set(a,structuredClone(e.answers)),e.resetScreen()):(R.delete(a),e.suspend(!1)),f&&await e.enqueue(f)}catch(f){if(r!==s||e.stopped)return;v?.destroy(),v=null,P.replaceChildren(),e.fail(f)}}return{get active(){return o},get receipt(){return k},open:T,exit:l,get drafts(){return new Map([...R].map(([r,f])=>[r,structuredClone(f)]))},stop(){o=!1,s++,v?.destroy(),v=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1}}}async function Ue(e,C){let n=C,{mountScreenPreview:P}=await import("./screen-renderer-P7MLBHY5.js"),{showPaywall:h}=await import("./paywall-MXRMMF3R.js"),o=e.ownerDocument,k=o.activeElement,s=o.createElement("section"),v=o.createElement("div"),a=o.createElement("div"),R=o.createElement("div"),S=o.createElement("button");R.hidden=!0,S.type="button";let T=o.createElement("p"),l=o.createElement("p"),r=o.createElement("button"),f=o.createElement("button"),E=o.createElement("button"),y=o.createElement("dialog");s.dataset.indianaFunnel="",s.setAttribute("aria-busy","false"),s.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033;background:#fff",a.style.cssText="display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 20px",T.setAttribute("role","status"),l.setAttribute("role","alert"),l.hidden=!0,r.type=f.type=E.type="button",a.append(r,T,l,E,S,f),s.append(v,R,a),e.append(s);let O=null,U=null,G=null,F="",_="",$="",j="",A=!1,Q=0,i=!1,w="",c=null,I=Promise.resolve(),d=null,m=null,p=new Set,N={},q=(t,g=null)=>{A||(m=g,l.textContent=t instanceof Error?t.message:"Request failed",l.hidden=!1,E.hidden=n.client.pendingCommand===null,X(n.onError,t))};function J(){let t=n.client.view;if(!t)throw new u("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let D=we({client:n.client,doc:o,holder:v,reviewHolder:R,mountScreenPreview:P,get stopped(){return A},get answers(){return N},suspend(t){U?.setSuspended(t)},resetScreen(){F="",_=""},enqueue:W,fail:q}),z=pe({client:n.client,expected:J,fail:q,get stopped(){return A},get reviewing(){return D.active},get key(){return F},get busy(){return Q}}),Z=fe({client:n.client,expected:J,perform:B,onIntent:n.onCustomerDataIntent,get stopped(){return A},get busy(){return Q},get document(){return O?.document},get answers(){return N}});async function B(t,g=!1){if(!(Q&&!g||A||D.active&&!g)){Q++,s.setAttribute("aria-busy","true"),l.hidden=!0,m=null;try{if(!g&&z.inFlight){let b=n.client.view;await z.inFlight;let L=n.client.view;if(!b||!L||L.id!==b.id||L.nodeId!==b.nodeId||L.visit!==b.visit||L.stopped||!["running","waiting"].includes(L.status))throw new u("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}if(A)return;let M=await t();A||await W(n.client.view??M.run)}catch(M){q(M,n.client.pendingCommand?.requestId??null)}finally{Q=Math.max(0,Q-1),s.setAttribute("aria-busy",String(Q>0)),A||(E.hidden=n.client.pendingCommand===null,r.disabled=Q>0||!!n.client.pendingCommand||!n.client.view?.canBack)}}}function x(){c&&clearTimeout(c),!(A||!G||!["running","waiting"].includes(G.status)&&!n.client.pendingCommand)&&(c=setTimeout(()=>{c=null,oe().finally(x)},G.pendingRequest||n.client.pendingCommand?1500:5e3))}async function oe(){if(!(A||i||Q)){if(D.active){await D.open(D.receipt);return}i=!0;try{let t=n.client.pendingCommand;t&&n.client.settle&&await n.client.settle(t.requestId);let g=n.client.view,M=Z.queries,b=await n.client.get(g?.screen&&Object.keys(M).length?{nodeId:g.nodeId,visit:g.visit,revision:g.revision,components:M}:void 0);!A&&M===Z.queries&&await W(n.client.view??b.run)}catch(t){q(t)}finally{i=!1}}}function me(t){let g=t.screen?.presentation;if(!g||g.type==="inline"){y.open&&y.close(),s.parentElement!==e&&e.append(s);return}s.parentElement!==y&&(y.append(s),e.append(y));let M={sm:420,md:640,lg:900};y.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in g?M[g.size]+"px":"100vw"}`,y.setAttribute("aria-label",O?.document?.name??t.screen?.content.document.name??"Funnel"),y.open||y.showModal()}async function ye(t){if(A)return;G=t,m&&n.client.pendingCommand?.requestId!==m&&(l.hidden=!0,m=null);let g=t.locale.startsWith("zh");if(S.textContent=g?"\u56DE\u770B":"History",S.hidden=!n.client.review,r.textContent=D.active?g?"\u8FD4\u56DE\u5F53\u524D":"Return to current":g?"\u8FD4\u56DE":"Back",f.textContent=g?"\u5173\u95ED":"Close",E.textContent=g?"\u91CD\u8BD5":"Retry",r.disabled=!D.active&&(Q>0||!!n.client.pendingCommand||!t.canBack),E.hidden=n.client.pendingCommand===null,T.textContent=t.pendingRequest?g?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?g?"\u7B49\u5F85\u4E2D":"Waiting":"",w!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(w=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,X(n.onState,structuredClone(t))),t.stopped||n.client.configurationReady===!1){D.stop(),O?.destroy(),O=null,U?.destroy(),U=null,v.replaceChildren(),F="",_="",j="",y.open&&y.close(),s.hidden=!0,x();return}if(s.hidden=!1,D.active){x();return}let M=t.screen||t.paywall?`${t.id}:${t.nodeId}:${t.visit}`:"";if(M!==F&&(O?.destroy(),O=null,U?.destroy(),U=null,v.replaceChildren(),F=M,_="",j="",N={...t.answers},Z.reset()),me(t),t.screen){let L=t.screen.content;O||(O=P(v,{mode:"live",rendererUrl:n.client.webViewUrl,title:L.document.name,onAction(H,te={},ie={}){if(D.active)return;N={...N,...ie};let Ie=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:ne})=>Object.hasOwn(N,ne)).map(({variable:ne})=>[ne,N[ne]]));B(()=>n.client.submit({operation:"submit",...J(),input:{type:"screen",output:H,answers:Ie,selection:te}}))},onAnswers:H=>{D.active||(N={...N,...H})},onCustomerDataIntent:H=>{D.active||Z.intent(H).catch(q)},onEscape:()=>{D.active||K()},onError:H=>q(new Error(H)),onRendered:()=>z.report(M)}));let V={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:N,values:t.screen.values}},Y=JSON.stringify([L,t.locale,V.parameters,t.screen.inputs,t.screen.values]);if(Y!==_)O.update(L.document,t.locale,V),_=Y,$=JSON.stringify(V.capabilities),j=JSON.stringify(V.customerData);else{let H=JSON.stringify(V.capabilities);H!==$&&(O.updateCapabilities(V.capabilities),$=H),JSON.stringify(V.customerData)!==j&&(O.updateCustomerData(V.customerData),j=JSON.stringify(V.customerData))}await O.ready}else if(t.paywall&&!U){let L=await h(v,{canInteract:()=>!D.active&&!A,start:async()=>ce(n.client),onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resolveOfferId:n.resolveOfferId,onEvent:n.onEvent,onOpenUrl:V=>n.onOpenUrl?n.onOpenUrl({receiptId:t.paywall.receiptId,url:V,openIn:"same_window"}):o.defaultView?.location.assign(V),onAction:async V=>{if(D.active)return;let Y=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision,input:{type:"screen",output:V,answers:{}}});await W(n.client.view??Y.run)},onError:q,onDismiss:()=>{!D.active&&!A&&n.client.view?.visit===t.visit&&K()}});A?L.host?.destroy():(U=L.host,U?.setSuspended(D.active)),z.report(M)}let b=t.instruction;if(b&&(b.type==="open_url"||b.type==="event")&&!p.has(b.receiptId)){let L=o.createElement("button");L.type="button",L.textContent=b.type==="open_url"?`${g?"\u524D\u5F80":"Continue to"} ${new URL(b.url).host}`:g?"\u7EE7\u7EED":"Continue",L.onclick=()=>{let V=J(),Y=b.type==="open_url"&&!n.onOpenUrl&&b.openIn==="new_window"?he(b.url):null;B(async()=>{let H="success";if(b.type==="open_url")if(n.onOpenUrl)try{H=await n.onOpenUrl({receiptId:b.receiptId,url:b.url,openIn:b.openIn})===!1?"failed":"opened"}catch(ie){X(n.onError,ie),H="failed"}else H=b.openIn==="new_window"&&!Y?"failed":"opened";if(b.type==="event"){if(!n.onEvent)throw new u("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(b.event)}if(A||n.client.view?.nodeId!==V.nodeId||n.client.view.visit!==V.visit)throw new u("PRECONDITION_FAILED","The client action visit changed");let te=await n.client.submit({operation:"submit",...V,input:{type:"client_action",receiptId:b.receiptId,outcome:H}});return p.add(b.receiptId),b.type==="open_url"&&!n.onOpenUrl&&b.openIn==="same_window"&&o.defaultView?.location.assign(b.url),te})},v.replaceChildren(L)}!t.pendingRequest&&t.status==="completed"&&!p.has(`complete:${t.id}`)&&(p.add(`complete:${t.id}`),X(n.onComplete,structuredClone(t))),x()}function he(t){let g=o.defaultView?.open(t,"_blank")??null;return g&&(g.opener=null),g}function W(t){return I=I.catch(()=>{}).then(()=>ye(t)),I}let ve=n.client.subscribe(t=>{n.client.configurationReady===!1&&(s.hidden=!0,O?.destroy(),O=null,U?.destroy(),U=null,v.replaceChildren(),F="",_="",j="",y.open&&y.close()),W(t).catch(q)}),ge=n.client.subscribeError?.(q);function K(){return d||(A?Promise.resolve():n.client.view&&!["running","waiting"].includes(n.client.view.status)?(ee(),Promise.resolve()):(d=B(()=>n.client.submit({operation:"close",...J()}),!0).then(()=>{n.client.view?.status==="closed"&&ee()}).finally(()=>{d=null}),d))}function ee(){A||(A=!0,c&&clearTimeout(c),ve(),ge?.(),O?.destroy(),D.stop(),U?.destroy(),y.close(),y.remove(),s.remove(),k instanceof HTMLElement&&k.isConnected&&k.focus(),X(n.onDismiss,G?structuredClone(G):null))}r.onclick=()=>{if(D.active){D.exit();return}B(()=>n.client.submit({operation:"back",...J()}))},S.onclick=()=>{D.open()},f.onclick=()=>{K()},E.onclick=()=>{B(()=>n.client.retry())},y.addEventListener("cancel",t=>{t.preventDefault(),K()});try{let t=await n.client.get();await W(n.client.view??t.run)}catch(t){throw ee(),t}return{destroy:ee,refresh:oe,review:D.open,exitReview:D.exit,get unappliedDrafts(){return D.drafts}}}export{Ue as showFunnelRun};
|
|
1
|
+
import{a as X}from"./chunk-DSPLGTQI.js";import{a as le,b as ue,d as de}from"./chunk-GRLMT5PR.js";import"./chunk-2QPETWDX.js";import{Hg as re,ue as ae}from"./chunk-ZT66RIFU.js";import{a as u}from"./chunk-SOQO2RDZ.js";import{Hb as se}from"./chunk-LMR2TM3X.js";import"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";function ce(e){let C=e.view;if(!C?.paywall)throw new u("INVALID_REQUEST","The current node is not a Paywall");let n=C.paywall.receiptId,P=C.nodeId,h=C.visit,o=C.paywall.resolution,k=o,s="document"in o?o:null;function v(i){if(!le(i,o))throw new u("INVALID_RESPONSE","The pinned Paywall binding changed")}let a=C.paywall.quote,R=C.paywall.operation,S=!1,T=new AbortController,l=C.paywall.purchaseRequestId,r=0,f=C.paywall.selectionGeneration??0,E=C.paywall.canReselect===!0,y=null,O=new Map,U=new Map;function G(i){if(i.purchase&&i.purchase.receiptId!==n)throw new u("INVALID_RESPONSE","Purchase receipt changed");let w=i.run.paywall;return i.purchase??(w?.receiptId===n?w:null)}function F(){if(S)throw new u("IDENTITY_CHANGED","Paywall presentation has closed")}function _(i,w,c){if(F(),w!==r||c!==void 0&&a?.operationId!==c)return!1;let I=f,d=i.run.paywall;if(d?.receiptId===n){if((d.selectionGeneration??0)<f)return!1;f=d.selectionGeneration??0,E=d.canReselect===!0,v(d.resolution)}let m=G(i),p=f>I,N=p?m?.quote??null:m?.quote??a,q=m?.operation??(N?.operationId===a?.operationId?R:null);return N&&q&&ue(q,{operationId:N.operationId},"Purchase operation changed"),d?.receiptId===n&&(k=d.resolution,s="document"in k?k:s?{...k,document:s.document,offering:s.offering}:null),(p||N?.operationId!==a?.operationId)&&(r++,d?.receiptId===n&&(l=d.purchaseRequestId)),a=N,R=de(R,q,!0),!0}function $(i,w,c){return new Promise((I,d)=>{let m=!1,p=()=>{clearTimeout(D),T.signal.removeEventListener("abort",J)},N=z=>{m||(m=!0,p(),I(z))},q=z=>{m||(m=!0,p(),d(z))},J=()=>q(new u("IDENTITY_CHANGED","Paywall presentation has closed")),D=setTimeout(()=>q(new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,c)),Math.max(0,w-Date.now()));T.signal.addEventListener("abort",J,{once:!0}),T.signal.aborted&&J(),i.then(N,q)})}function j(i){return new Promise(w=>{let c=()=>{clearTimeout(I),T.signal.removeEventListener("abort",c),w()},I=setTimeout(c,i);T.signal.addEventListener("abort",c,{once:!0}),T.signal.aborted&&c()})}async function A(i,w,c){F();let I=O.get(i);if(!I){let p=e.pendingCommands?.find(N=>N.requestId===i)??e.pendingCommand;if(p?.operation==="submit"&&p.requestId===i&&p.nodeId===P&&p.visit===h){w.type==="paywall_quote"&&p.input.type==="paywall_quote"&&p.input.predecessor&&!w.predecessor&&(w={...w,predecessor:p.input.predecessor});let N=re.parse(p),q=re.parse({...p,input:w});if(q.operation!=="submit"||N.operation!=="submit"||JSON.stringify(q.input)!==JSON.stringify(N.input))throw new u("CONFLICT","A restored purchase request cannot change its input");w=q.input,I=N,O.set(i,I)}}if(I){if(JSON.stringify(I.input)!==JSON.stringify(w))throw new u("CONFLICT","A purchase request cannot change its input")}else{let p=e.view;if(!p||p.nodeId!==P||p.visit!==h||p.paywall?.receiptId!==n)throw new u("PRECONDITION_FAILED","The Paywall visit has changed");I={operation:"submit",requestId:i,nodeId:P,visit:h,revision:p.revision,input:w},O.set(i,I)}let d=Date.now()+3e4,m=await $(e.submit(I),d,i);for(;m.run.pendingRequest?.requestId===i&&Date.now()<d&&!S&&(await j(Math.min(1e3,d-Date.now())),!(S||Date.now()>=d));)m=await $(e.resume(i),d,i);if(S)throw new u("IDENTITY_CHANGED","Paywall presentation has closed");if(m.run.pendingRequest?.requestId===i)throw new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,i);if(!_(m,c,w.type==="paywall_confirm"||w.type==="paywall_cancel"?w.operationId:void 0))throw new u("PRECONDITION_FAILED","The purchase selection has changed")}async function Q(i){if(!a)throw new u("INVALID_REQUEST","A quoted purchase is required");let w=`${i}:${a.operationId}`,c=U.get(w);if(!c){let I=i==="confirm"?"paywall_confirm":"paywall_cancel",d=e.pendingCommands?.find(m=>m.operation==="submit"&&m.input.type===I&&"operationId"in m.input&&m.input.operationId===a.operationId)??e.pendingCommand;c=d?.operation==="submit"&&d.input.type===I&&"operationId"in d.input&&d.input.operationId===a.operationId?d.requestId:crypto.randomUUID(),U.set(w,c)}if(await A(c,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:a.operationId},r),!R)throw new u("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(R)}return{get view(){return structuredClone(s)},get quote(){return a?structuredClone(a):null},get operation(){return R?structuredClone(R):null},get webViewUrl(){return e.webViewUrl},get canReselect(){return E},async refresh(){F();let i=r,w=await e.get();if(_(w,i),w.run.paywall?.receiptId!==n)throw new u("PRECONDITION_FAILED","Paywall presentation has changed");if(!s){if("document"in k||!e.resolvePaywall)throw new u("INVALID_RESPONSE","Public Paywall reader is unavailable");let c=await e.resolvePaywall(k);F(),v(c),s={...k,document:c.document,offering:c.offering}}return structuredClone(s)},preview(i){if(!s)return Promise.reject(new u("PRECONDITION_FAILED","Load the Paywall presentation first"));if(l&&l!==i.requestId&&(y||!E))return Promise.reject(new u("COMMAND_PENDING","Retry the original purchase before starting another"));if(l===i.requestId&&y)return y;let w=s.document.buttons[i.actionId],c=w?.type==="checkout"?ae(w.product,i.selection,s.capabilities):null;if(!c)return Promise.reject(new u("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let I=l!==i.requestId&&f>0?{operationId:a?.operationId??null,generation:f}:void 0;if(I&&(!E||f<=0))return Promise.reject(new u("COMMAND_PENDING","Original purchase requires authoritative termination"));l!==i.requestId&&r++;let d=r;l=i.requestId;let m=(async()=>{if(await A(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:c,...I?{predecessor:I}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}},d),!a)throw new u("INVALID_RESPONSE","The accepted quote is missing");return structuredClone(a)})();return y=m,m.then(()=>{y===m&&(y=null)},p=>{y===m&&(y=null),l===i.requestId&&e.pendingCommand?.requestId!==i.requestId&&p instanceof u&&p.status!==void 0&&p.status<500&&![401,425].includes(p.status)&&(l=null)}),m},confirm:()=>Q("confirm"),cancel:()=>Q("cancel"),async read(){if(F(),!a)throw new u("INVALID_REQUEST","A quoted purchase is required");let i=a.operationId,w=r,c=e.pendingCommands?.find(p=>p.operation==="submit"&&(p.input.type==="paywall_confirm"||p.input.type==="paywall_cancel")&&p.input.operationId===i)??e.pendingCommand;c?.operation==="submit"&&(c.input.type==="paywall_confirm"||c.input.type==="paywall_cancel")&&c.input.operationId===i&&await e.settle?.(c.requestId);let I=await e.get(void 0,{receiptId:n,operationId:i});F();let d=G(I);if(d?.quote&&d.quote.operationId!==i||d?.operation&&d.operation.operationId!==i)throw new u("INVALID_RESPONSE","Purchase operation changed");let m=_(I,w,i)?R:d?.operation;if(!m)throw new u("INVALID_RESPONSE","The current purchase result is missing");return structuredClone(m)},destroy(){S=!0,T.abort(),O.clear(),U.clear()}}}function pe(e){let C=new Set,n=new Set,P=null;function h(o){if(e.reviewing||C.has(o)||n.has(o)||e.stopped)return;n.add(o);let k=async()=>{if(e.reviewing||e.stopped||e.key!==o){n.delete(o);return}if(e.busy||e.client.pendingCommand){setTimeout(()=>{k()},250);return}let s=(async()=>{let a=e.client.view,R=e.expected(),S=R.requestId,T=!1;try{await e.client.submit({operation:"shown",...R})}catch(l){if(!(l instanceof u)||l.code!=="CONFLICT"||l.status!==409||e.client.pendingCommand)throw l;await e.client.get();let r=e.client.view;if(e.stopped||e.reviewing||e.key!==o||!r||!a||r.id!==a.id||r.source.versionId!==a.source.versionId||r.nodeId!==R.nodeId||r.visit!==R.visit||r.revision<=R.revision||r.stopped||!r.screen||!["running","waiting"].includes(r.status)||e.client.pendingCommand)throw l;let f=e.expected();S=f.requestId,await e.client.submit({operation:"shown",...f})}for(;!e.stopped&&e.key===o&&e.client.pendingCommand?.requestId===S;){if(!e.client.settle)throw new u("COMMAND_PENDING","The original display acknowledgement is still pending");await e.client.settle(S),T=!0,e.client.pendingCommand?.requestId===S&&await new Promise(l=>setTimeout(l,1500))}e.stopped||e.key!==o||(T&&await e.client.get(),!(e.stopped||e.key!==o)&&C.add(o))})();P=s;let v=()=>{P===s&&(P=null),n.delete(o)};s.then(v,a=>{v(),e.busy||e.fail(a)})};k()}return{report:h,get inFlight(){return P}}}function fe(e){let C={},n=new Map;async function P(h){let o=e.client.view,k=o?.screen,s=k?.customerData.nodes[h.nodeId];if(e.stopped||e.busy||!o||!k||!s)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(h.action)){let r=e.document,f=r?se(r,h.nodeId):null,E=f?.type==="customer_data"?f.data.outputs?.[h.action]:void 0;E&&k.outputs.includes(E)?await e.perform(()=>e.client.submit({operation:"submit",...e.expected(),input:{type:"screen",output:E,answers:e.answers,selection:h.value?{[h.nodeId]:h.value}:{}}})):await e.onIntent?.(h,o);return}let a=h.action.startsWith("sources_")?s.resources.find(r=>r.key===h.value):null;if(h.action.startsWith("sources_")&&!a)throw new u("INVALID_REQUEST","Choose a current resource");let R=`${o.visit}:${h.nodeId}:${a?.key??""}`,S=n.get(R)??[null],l=C[h.nodeId]??{page:1,after:null,filter:"all",...a?{resourceKey:a.key}:{}};if(h.action==="filter"){let r=h.value;if(!r||!(s.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(r))throw new u("INVALID_REQUEST","Unknown data filter");l={page:1,after:null,filter:r},S.splice(0,S.length,null)}else if(h.action==="next"||h.action==="sources_next"){let r=a?.sources.at(-1),f=a?r?{kind:"ledger",cursor:{at:r.detail[0],id:r.id,type:"source"}}:null:k.dataCursors[h.nodeId];if(!f||!a&&!s.hasNext)return;S[l.page]=f,l={...l,page:l.page+1,after:f}}else if(h.action==="previous"||h.action==="sources_previous"){if(l.page<=1)return;l={...l,page:l.page-1,after:S[l.page-2]??null}}n.set(R,S),C={...C,[h.nodeId]:l},await e.perform(()=>e.client.get({nodeId:o.nodeId,visit:o.visit,revision:o.revision,components:C}))}return{get queries(){return C},intent:P,reset(){C={},n.clear()}}}function we(e){let{doc:C,holder:n,reviewHolder:P,mountScreenPreview:h}=e,o=!1,k,s=0,v=null,a="",R=new Map,S=r=>r?`${r.id}:${r.nodeId}:${r.visit}:${r.revision}:${r.paywall?.quote?.operationId??""}`:"";async function T(r){if(e.stopped||!e.client.review)return;o||(a=S(e.client.view),R.set(a,structuredClone(e.answers))),o=!0,k=r,n.hidden=!0,e.suspend(!0),P.hidden=!1;let f=++s;try{let E=await e.client.review(r);if(e.stopped||f!==s||!o)return;if(!E.review)throw new u("INVALID_RESPONSE","Historical projection is missing");v?.destroy(),v=null,P.replaceChildren();let y=E.run.locale.startsWith("zh"),O=C.createElement("p");O.textContent=y?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",P.append(O);for(let[F,_]of E.review.pages.entries()){let $=C.createElement("button");$.type="button",$.textContent=y?`\u7B2C ${F+1} \u9875`:`Page ${F+1}`,$.onclick=()=>{T(_.receiptId)},P.append($)}if(E.review.page){let F=E.review.page,_=C.createElement("div");if(_.inert=!0,P.append(_),v=h(_,{mode:"live",rendererUrl:e.client.webViewUrl,title:F.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{},onEscape:()=>{l()}}),v.update(F.document,E.run.locale,{serverInput:{bindings:F.inputs,answers:F.answers,values:F.values}}),await v.ready,e.stopped||f!==s||!o)return}let U=y?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},G=y?{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"};for(let F of[...E.review.coupons.map((_,$)=>`${y?"\u4F18\u60E0\u5238":"Coupon"} ${$+1}: ${U[_.status]}`),...E.review.purchases.map((_,$)=>`${y?"\u8D2D\u4E70":"Purchase"} ${$+1}: ${G[_.status]}`)]){let _=C.createElement("p");_.textContent=F,P.append(_)}e.client.view&&await e.enqueue(e.client.view)}catch(E){if(f!==s||e.stopped)return;v?.destroy(),v=null,P.replaceChildren(),e.fail(E)}}async function l(){if(!o||e.stopped||!e.client.review)return;let r=++s;try{if(await e.client.review(),e.stopped||r!==s)return;o=!1,s++,v?.destroy(),v=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1;let f=e.client.view;S(f)!==a?(R.set(a,structuredClone(e.answers)),e.resetScreen()):(R.delete(a),e.suspend(!1)),f&&await e.enqueue(f)}catch(f){if(r!==s||e.stopped)return;v?.destroy(),v=null,P.replaceChildren(),e.fail(f)}}return{get active(){return o},get receipt(){return k},open:T,exit:l,get drafts(){return new Map([...R].map(([r,f])=>[r,structuredClone(f)]))},stop(){o=!1,s++,v?.destroy(),v=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1}}}async function Ue(e,C){let n=C,{mountScreenPreview:P}=await import("./screen-renderer-5FPYVSPW.js"),{showPaywall:h}=await import("./paywall-3GIRKSHN.js"),o=e.ownerDocument,k=o.activeElement,s=o.createElement("section"),v=o.createElement("div"),a=o.createElement("div"),R=o.createElement("div"),S=o.createElement("button");R.hidden=!0,S.type="button";let T=o.createElement("p"),l=o.createElement("p"),r=o.createElement("button"),f=o.createElement("button"),E=o.createElement("button"),y=o.createElement("dialog");s.dataset.indianaFunnel="",s.setAttribute("aria-busy","false"),s.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033;background:#fff",a.style.cssText="display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 20px",T.setAttribute("role","status"),l.setAttribute("role","alert"),l.hidden=!0,r.type=f.type=E.type="button",a.append(r,T,l,E,S,f),s.append(v,R,a),e.append(s);let O=null,U=null,G=null,F="",_="",$="",j="",A=!1,Q=0,i=!1,w="",c=null,I=Promise.resolve(),d=null,m=null,p=new Set,N={},q=(t,g=null)=>{A||(m=g,l.textContent=t instanceof Error?t.message:"Request failed",l.hidden=!1,E.hidden=n.client.pendingCommand===null,X(n.onError,t))};function J(){let t=n.client.view;if(!t)throw new u("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let D=we({client:n.client,doc:o,holder:v,reviewHolder:R,mountScreenPreview:P,get stopped(){return A},get answers(){return N},suspend(t){U?.setSuspended(t)},resetScreen(){F="",_=""},enqueue:W,fail:q}),z=pe({client:n.client,expected:J,fail:q,get stopped(){return A},get reviewing(){return D.active},get key(){return F},get busy(){return Q}}),Z=fe({client:n.client,expected:J,perform:B,onIntent:n.onCustomerDataIntent,get stopped(){return A},get busy(){return Q},get document(){return O?.document},get answers(){return N}});async function B(t,g=!1){if(!(Q&&!g||A||D.active&&!g)){Q++,s.setAttribute("aria-busy","true"),l.hidden=!0,m=null;try{if(!g&&z.inFlight){let b=n.client.view;await z.inFlight;let L=n.client.view;if(!b||!L||L.id!==b.id||L.nodeId!==b.nodeId||L.visit!==b.visit||L.stopped||!["running","waiting"].includes(L.status))throw new u("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}if(A)return;let M=await t();A||await W(n.client.view??M.run)}catch(M){q(M,n.client.pendingCommand?.requestId??null)}finally{Q=Math.max(0,Q-1),s.setAttribute("aria-busy",String(Q>0)),A||(E.hidden=n.client.pendingCommand===null,r.disabled=Q>0||!!n.client.pendingCommand||!n.client.view?.canBack)}}}function x(){c&&clearTimeout(c),!(A||!G||!["running","waiting"].includes(G.status)&&!n.client.pendingCommand)&&(c=setTimeout(()=>{c=null,oe().finally(x)},G.pendingRequest||n.client.pendingCommand?1500:5e3))}async function oe(){if(!(A||i||Q)){if(D.active){await D.open(D.receipt);return}i=!0;try{let t=n.client.pendingCommand;t&&n.client.settle&&await n.client.settle(t.requestId);let g=n.client.view,M=Z.queries,b=await n.client.get(g?.screen&&Object.keys(M).length?{nodeId:g.nodeId,visit:g.visit,revision:g.revision,components:M}:void 0);!A&&M===Z.queries&&await W(n.client.view??b.run)}catch(t){q(t)}finally{i=!1}}}function me(t){let g=t.screen?.presentation;if(!g||g.type==="inline"){y.open&&y.close(),s.parentElement!==e&&e.append(s);return}s.parentElement!==y&&(y.append(s),e.append(y));let M={sm:420,md:640,lg:900};y.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in g?M[g.size]+"px":"100vw"}`,y.setAttribute("aria-label",O?.document?.name??t.screen?.content.document.name??"Funnel"),y.open||y.showModal()}async function ye(t){if(A)return;G=t,m&&n.client.pendingCommand?.requestId!==m&&(l.hidden=!0,m=null);let g=t.locale.startsWith("zh");if(S.textContent=g?"\u56DE\u770B":"History",S.hidden=!n.client.review,r.textContent=D.active?g?"\u8FD4\u56DE\u5F53\u524D":"Return to current":g?"\u8FD4\u56DE":"Back",f.textContent=g?"\u5173\u95ED":"Close",E.textContent=g?"\u91CD\u8BD5":"Retry",r.disabled=!D.active&&(Q>0||!!n.client.pendingCommand||!t.canBack),E.hidden=n.client.pendingCommand===null,T.textContent=t.pendingRequest?g?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?g?"\u7B49\u5F85\u4E2D":"Waiting":"",w!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(w=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,X(n.onState,structuredClone(t))),t.stopped||n.client.configurationReady===!1){D.stop(),O?.destroy(),O=null,U?.destroy(),U=null,v.replaceChildren(),F="",_="",j="",y.open&&y.close(),s.hidden=!0,x();return}if(s.hidden=!1,D.active){x();return}let M=t.screen||t.paywall?`${t.id}:${t.nodeId}:${t.visit}`:"";if(M!==F&&(O?.destroy(),O=null,U?.destroy(),U=null,v.replaceChildren(),F=M,_="",j="",N={...t.answers},Z.reset()),me(t),t.screen){let L=t.screen.content;O||(O=P(v,{mode:"live",rendererUrl:n.client.webViewUrl,title:L.document.name,onAction(H,te={},ie={}){if(D.active)return;N={...N,...ie};let Ie=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:ne})=>Object.hasOwn(N,ne)).map(({variable:ne})=>[ne,N[ne]]));B(()=>n.client.submit({operation:"submit",...J(),input:{type:"screen",output:H,answers:Ie,selection:te}}))},onAnswers:H=>{D.active||(N={...N,...H})},onCustomerDataIntent:H=>{D.active||Z.intent(H).catch(q)},onEscape:()=>{D.active||K()},onError:H=>q(new Error(H)),onRendered:()=>z.report(M)}));let V={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:N,values:t.screen.values}},Y=JSON.stringify([L,t.locale,V.parameters,t.screen.inputs,t.screen.values]);if(Y!==_)O.update(L.document,t.locale,V),_=Y,$=JSON.stringify(V.capabilities),j=JSON.stringify(V.customerData);else{let H=JSON.stringify(V.capabilities);H!==$&&(O.updateCapabilities(V.capabilities),$=H),JSON.stringify(V.customerData)!==j&&(O.updateCustomerData(V.customerData),j=JSON.stringify(V.customerData))}await O.ready}else if(t.paywall&&!U){let L=await h(v,{canInteract:()=>!D.active&&!A,start:async()=>ce(n.client),onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resolveOfferId:n.resolveOfferId,onEvent:n.onEvent,onOpenUrl:V=>n.onOpenUrl?n.onOpenUrl({receiptId:t.paywall.receiptId,url:V,openIn:"same_window"}):o.defaultView?.location.assign(V),onAction:async V=>{if(D.active)return;let Y=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision,input:{type:"screen",output:V,answers:{}}});await W(n.client.view??Y.run)},onError:q,onDismiss:()=>{!D.active&&!A&&n.client.view?.visit===t.visit&&K()}});A?L.host?.destroy():(U=L.host,U?.setSuspended(D.active)),z.report(M)}let b=t.instruction;if(b&&(b.type==="open_url"||b.type==="event")&&!p.has(b.receiptId)){let L=o.createElement("button");L.type="button",L.textContent=b.type==="open_url"?`${g?"\u524D\u5F80":"Continue to"} ${new URL(b.url).host}`:g?"\u7EE7\u7EED":"Continue",L.onclick=()=>{let V=J(),Y=b.type==="open_url"&&!n.onOpenUrl&&b.openIn==="new_window"?he(b.url):null;B(async()=>{let H="success";if(b.type==="open_url")if(n.onOpenUrl)try{H=await n.onOpenUrl({receiptId:b.receiptId,url:b.url,openIn:b.openIn})===!1?"failed":"opened"}catch(ie){X(n.onError,ie),H="failed"}else H=b.openIn==="new_window"&&!Y?"failed":"opened";if(b.type==="event"){if(!n.onEvent)throw new u("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(b.event)}if(A||n.client.view?.nodeId!==V.nodeId||n.client.view.visit!==V.visit)throw new u("PRECONDITION_FAILED","The client action visit changed");let te=await n.client.submit({operation:"submit",...V,input:{type:"client_action",receiptId:b.receiptId,outcome:H}});return p.add(b.receiptId),b.type==="open_url"&&!n.onOpenUrl&&b.openIn==="same_window"&&o.defaultView?.location.assign(b.url),te})},v.replaceChildren(L)}!t.pendingRequest&&t.status==="completed"&&!p.has(`complete:${t.id}`)&&(p.add(`complete:${t.id}`),X(n.onComplete,structuredClone(t))),x()}function he(t){let g=o.defaultView?.open(t,"_blank")??null;return g&&(g.opener=null),g}function W(t){return I=I.catch(()=>{}).then(()=>ye(t)),I}let ve=n.client.subscribe(t=>{n.client.configurationReady===!1&&(s.hidden=!0,O?.destroy(),O=null,U?.destroy(),U=null,v.replaceChildren(),F="",_="",j="",y.open&&y.close()),W(t).catch(q)}),ge=n.client.subscribeError?.(q);function K(){return d||(A?Promise.resolve():n.client.view&&!["running","waiting"].includes(n.client.view.status)?(ee(),Promise.resolve()):(d=B(()=>n.client.submit({operation:"close",...J()}),!0).then(()=>{n.client.view?.status==="closed"&&ee()}).finally(()=>{d=null}),d))}function ee(){A||(A=!0,c&&clearTimeout(c),ve(),ge?.(),O?.destroy(),D.stop(),U?.destroy(),y.close(),y.remove(),s.remove(),k instanceof HTMLElement&&k.isConnected&&k.focus(),X(n.onDismiss,G?structuredClone(G):null))}r.onclick=()=>{if(D.active){D.exit();return}B(()=>n.client.submit({operation:"back",...J()}))},S.onclick=()=>{D.open()},f.onclick=()=>{K()},E.onclick=()=>{B(()=>n.client.retry())},y.addEventListener("cancel",t=>{t.preventDefault(),K()});try{let t=await n.client.get();await W(n.client.view??t.run)}catch(t){throw ee(),t}return{destroy:ee,refresh:oe,review:D.open,exitReview:D.exit,get unappliedDrafts(){return D.drafts}}}export{Ue as showFunnelRun};
|