@tinkerlandai/indiana-sdk 0.8.5 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +20 -41
  3. package/README.zh-CN.md +17 -17
  4. package/dist/{ai-usage-DUlre7JC.d.ts → ai-usage-DMNKvCiq.d.ts} +3 -3
  5. package/dist/{api-XDc4pRlN.d.ts → api--Zf0gxfj.d.ts} +128 -124
  6. package/dist/chunk-3PZ4Y6UD.js +17 -0
  7. package/dist/chunk-5O667MKA.js +1 -0
  8. package/dist/chunk-65TBYVCS.js +1 -0
  9. package/dist/chunk-67A7I6MB.js +1 -0
  10. package/dist/chunk-7DXL3LHT.js +1 -0
  11. package/dist/chunk-CCQHYQ4P.js +1 -0
  12. package/dist/chunk-CPLLMISZ.js +1 -0
  13. package/dist/chunk-G23YNWWI.js +1 -0
  14. package/dist/chunk-G56XGVMS.js +1 -0
  15. package/dist/chunk-L7LKE3MG.js +173 -0
  16. package/dist/chunk-NH2PTTNK.js +2 -0
  17. package/dist/chunk-PK5HYUHD.js +1 -0
  18. package/dist/chunk-SEW4YVR7.js +1 -0
  19. package/dist/chunk-UYSOTMY3.js +1 -0
  20. package/dist/{chunk-WWUUVURR.js → chunk-WSVH6IQA.js} +1 -1
  21. package/dist/chunk-YZSQDZXW.js +4 -0
  22. package/dist/{configuration-sync-Ce3dShy7.d.ts → configuration-sync-E98CqVwh.d.ts} +6 -5
  23. package/dist/content-3LOJVYQO.js +1 -0
  24. package/dist/{errors-C8lRYZ0n.d.ts → errors-0TSUIbUi.d.ts} +12 -1
  25. package/dist/{funnel-local-client-CUGavICI.d.ts → funnel-local-client-BjPwXlQb.d.ts} +550 -260
  26. package/dist/funnel-runtime-host-NYHKQT6T.js +1 -0
  27. package/dist/index.d.ts +689 -223
  28. package/dist/index.js +1 -1
  29. package/dist/native-shell.js +1 -1
  30. package/dist/openrouter.d.ts +3 -3
  31. package/dist/openrouter.js +1 -1
  32. package/dist/page.d.ts +6 -6
  33. package/dist/page.js +1 -1
  34. package/dist/paywall-ISCYOGPZ.js +1 -0
  35. package/dist/popup.d.ts +1 -1
  36. package/dist/popup.js +1 -1
  37. package/dist/react-native.d.ts +122 -99
  38. package/dist/react-native.js +1 -1
  39. package/dist/screen-renderer-A6VYE2QL.js +1 -0
  40. package/dist/server.d.ts +58 -58
  41. package/dist/server.js +1 -1
  42. package/dist/visual.d.ts +36 -1
  43. package/dist/visual.js +1 -2
  44. package/package.json +1 -1
  45. package/dist/chunk-3KQHKRZJ.js +0 -1
  46. package/dist/chunk-6A5WWFNS.js +0 -10
  47. package/dist/chunk-A3XRIG53.js +0 -1
  48. package/dist/chunk-BUDTHBFF.js +0 -173
  49. package/dist/chunk-FGIGKO7A.js +0 -1
  50. package/dist/chunk-GRLMT5PR.js +0 -1
  51. package/dist/chunk-HEBQUICQ.js +0 -4
  52. package/dist/chunk-KQCTDXVD.js +0 -17
  53. package/dist/chunk-LMR2TM3X.js +0 -1
  54. package/dist/chunk-OBYJWIRB.js +0 -1
  55. package/dist/chunk-RRII2DMC.js +0 -1
  56. package/dist/chunk-SOQO2RDZ.js +0 -1
  57. package/dist/chunk-SUXAWRR6.js +0 -1
  58. package/dist/chunk-VVV3JNS3.js +0 -1
  59. package/dist/content-DDMDNRCV.js +0 -1
  60. package/dist/funnel-runtime-host-QK6WDRPS.js +0 -1
  61. package/dist/paywall-4QT3JYD4.js +0 -1
  62. package/dist/screen-renderer-DLXDQQKK.js +0 -1
  63. package/dist/src-EG7RWDDY.js +0 -1
  64. package/dist/{screen-BpAejkn0.d.ts → screen-BITZ11jn.d.ts} +18 -18
package/dist/server.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { F as FoundationApi, I as InvoiceModeParams } from './api-XDc4pRlN.js';
2
- import { u as IndianaServerOptions, v as FunnelLocalConfiguration, p as PaywallStartInput, g as PaywallSession, h as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-CUGavICI.js';
3
- export { k as FeatureClient, l as FunnelNodeEvaluationContext, j as FunnelStartInput, L as LocalFunnelClient, n as LocalFunnelClientOptions, q as createFeatureClient, w as createFunnelStartClient, r as createLocalFunnelClient, t as evaluateFunnelNode } from './funnel-local-client-CUGavICI.js';
1
+ import { F as FoundationApi, I as InvoiceModeParams } from './api--Zf0gxfj.js';
2
+ import { v as IndianaServerOptions, w as FunnelLocalConfiguration, p as PaywallStartInput, g as PaywallSession, h as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-BjPwXlQb.js';
3
+ export { k as FeatureClient, l as FunnelNodeEvaluationContext, j as FunnelStartInput, L as LocalFunnelClient, n as LocalFunnelClientOptions, r as createFeatureClient, x as createFunnelStartClient, s as createLocalFunnelClient, u as evaluateFunnelNode } from './funnel-local-client-BjPwXlQb.js';
4
4
  import * as zod from 'zod';
5
5
  import { z } from 'zod';
6
- import { S as StackNode } from './screen-BpAejkn0.js';
7
- import { C as ConfigurationSync } from './configuration-sync-Ce3dShy7.js';
8
- export { c as createConfigurationSync } from './configuration-sync-Ce3dShy7.js';
6
+ import { S as StackNode } from './screen-BITZ11jn.js';
7
+ import { C as ConfigurationSync } from './configuration-sync-E98CqVwh.js';
8
+ export { c as createConfigurationSync } from './configuration-sync-E98CqVwh.js';
9
9
  import { J as JsonValue, E as EvaluationContext, s as stickyAssignmentDocumentSchema, F as FeatureResult } from './growth-rules-B4YYy64R.js';
10
- import { I as IndianaError } from './errors-C8lRYZ0n.js';
11
- export { d as AiPricingOptions, b as AiTokenQuote, a as AiTokenUsage, A as AiUsageContext, e as AiUsageMiddlewareOptions, f as AiUsageRecord, g as aiPriceSnapshotSchema, h as aiTokenQuoteSchema, c as createAiPricing, i as createAiUsageMiddleware, j as createConfiguredAiPricing } from './ai-usage-DUlre7JC.js';
10
+ import { I as IndianaError } from './errors-0TSUIbUi.js';
11
+ export { d as AiPricingOptions, b as AiTokenQuote, a as AiTokenUsage, A as AiUsageContext, e as AiUsageMiddlewareOptions, f as AiUsageRecord, g as aiPriceSnapshotSchema, h as aiTokenQuoteSchema, c as createAiPricing, i as createAiUsageMiddleware, j as createConfiguredAiPricing } from './ai-usage-DMNKvCiq.js';
12
12
  import 'zod/v4';
13
13
  import '@ai-sdk/provider';
14
14
 
@@ -238,8 +238,8 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
238
238
  revision: number;
239
239
  visit: number;
240
240
  nodeId: string;
241
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
242
- status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
241
+ nodeType: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
242
+ status: "running" | "failed" | "completed" | "closed" | "ineligible" | "waiting";
243
243
  stopped: boolean;
244
244
  canBack: boolean;
245
245
  authenticated: boolean;
@@ -425,7 +425,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
425
425
  productId: string;
426
426
  productVersionId: string;
427
427
  name: string;
428
- action: "addon" | "upgrade" | "purchase" | "topup";
428
+ action: "upgrade" | "purchase" | "addon" | "topup";
429
429
  membershipId: string | null;
430
430
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
431
431
  amountMinor: string;
@@ -521,7 +521,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
521
521
  cursor: {
522
522
  at: string;
523
523
  id: string;
524
- type: "source" | "usage" | "invoice" | "debt" | "transaction" | "settlement";
524
+ type: "usage" | "source" | "invoice" | "debt" | "transaction" | "settlement";
525
525
  };
526
526
  } | {
527
527
  kind: "billing";
@@ -751,7 +751,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
751
751
  productId: string;
752
752
  productVersionId: string;
753
753
  name: string;
754
- action: "addon" | "upgrade" | "purchase" | "topup";
754
+ action: "upgrade" | "purchase" | "addon" | "topup";
755
755
  membershipId: string | null;
756
756
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
757
757
  amountMinor: string;
@@ -774,7 +774,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
774
774
  productId: string;
775
775
  productVersionId: string;
776
776
  name: string;
777
- action: "addon" | "upgrade" | "purchase" | "topup";
777
+ action: "upgrade" | "purchase" | "addon" | "topup";
778
778
  membershipId: string | null;
779
779
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
780
780
  amountMinor: string;
@@ -809,7 +809,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
809
809
  productId: string;
810
810
  productVersionId: string;
811
811
  name: string;
812
- action: "addon" | "upgrade" | "purchase" | "topup";
812
+ action: "upgrade" | "purchase" | "addon" | "topup";
813
813
  membershipId: string | null;
814
814
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
815
815
  amountMinor: string;
@@ -897,7 +897,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
897
897
  productId: string;
898
898
  productVersionId: string;
899
899
  name: string;
900
- action: "addon" | "upgrade" | "purchase" | "topup";
900
+ action: "upgrade" | "purchase" | "addon" | "topup";
901
901
  membershipId: string | null;
902
902
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
903
903
  amountMinor: string;
@@ -959,7 +959,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
959
959
  totalMinor: number;
960
960
  } | null;
961
961
  expiresAt: string;
962
- provider: "apple" | "google" | "stripe";
962
+ provider: "stripe" | "apple" | "google";
963
963
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
964
964
  lines: {
965
965
  lineId: string;
@@ -1019,9 +1019,9 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1019
1019
  automaticTax: boolean;
1020
1020
  execution: {
1021
1021
  provider: "stripe";
1022
- executor: "merchant" | "indiana";
1022
+ executor: "indiana" | "merchant";
1023
1023
  accountId: string;
1024
- mode: "subscription" | "payment";
1024
+ mode: "payment" | "subscription";
1025
1025
  lineItems: {
1026
1026
  price: string | null;
1027
1027
  quantity: number;
@@ -1091,13 +1091,13 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1091
1091
  operationId: string;
1092
1092
  orderId: string;
1093
1093
  status: "pending" | "failed" | "complete" | "cancelled";
1094
- executor: "merchant" | "indiana";
1094
+ executor: "indiana" | "merchant";
1095
1095
  checkoutUrl: string | null;
1096
1096
  execution: {
1097
1097
  provider: "stripe";
1098
- executor: "merchant" | "indiana";
1098
+ executor: "indiana" | "merchant";
1099
1099
  accountId: string;
1100
- mode: "subscription" | "payment";
1100
+ mode: "payment" | "subscription";
1101
1101
  lineItems: {
1102
1102
  price: string | null;
1103
1103
  quantity: number;
@@ -1168,7 +1168,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1168
1168
  productVersionId: string;
1169
1169
  provider: "apple" | "google";
1170
1170
  productId: string;
1171
- productKind: "membership" | "lifetime" | "credit_pack";
1171
+ productKind: "lifetime" | "membership" | "credit_pack";
1172
1172
  replacement: {
1173
1173
  sourceOrderId: string;
1174
1174
  sourceProductId: string;
@@ -1284,7 +1284,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1284
1284
  totalMinor: number;
1285
1285
  } | null;
1286
1286
  expiresAt: string;
1287
- provider: "apple" | "google" | "stripe";
1287
+ provider: "stripe" | "apple" | "google";
1288
1288
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
1289
1289
  lines: {
1290
1290
  lineId: string;
@@ -1344,9 +1344,9 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1344
1344
  automaticTax: boolean;
1345
1345
  execution: {
1346
1346
  provider: "stripe";
1347
- executor: "merchant" | "indiana";
1347
+ executor: "indiana" | "merchant";
1348
1348
  accountId: string;
1349
- mode: "subscription" | "payment";
1349
+ mode: "payment" | "subscription";
1350
1350
  lineItems: {
1351
1351
  price: string | null;
1352
1352
  quantity: number;
@@ -1416,13 +1416,13 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1416
1416
  operationId: string;
1417
1417
  orderId: string;
1418
1418
  status: "pending" | "failed" | "complete" | "cancelled";
1419
- executor: "merchant" | "indiana";
1419
+ executor: "indiana" | "merchant";
1420
1420
  checkoutUrl: string | null;
1421
1421
  execution: {
1422
1422
  provider: "stripe";
1423
- executor: "merchant" | "indiana";
1423
+ executor: "indiana" | "merchant";
1424
1424
  accountId: string;
1425
- mode: "subscription" | "payment";
1425
+ mode: "payment" | "subscription";
1426
1426
  lineItems: {
1427
1427
  price: string | null;
1428
1428
  quantity: number;
@@ -1493,7 +1493,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
1493
1493
  productVersionId: string;
1494
1494
  provider: "apple" | "google";
1495
1495
  productId: string;
1496
- productKind: "membership" | "lifetime" | "credit_pack";
1496
+ productKind: "lifetime" | "membership" | "credit_pack";
1497
1497
  replacement: {
1498
1498
  sourceOrderId: string;
1499
1499
  sourceProductId: string;
@@ -1887,7 +1887,7 @@ declare function createFunnelLocalEvaluator(options: FunnelLocalEvaluatorOptions
1887
1887
  entry: string;
1888
1888
  nodes: {
1889
1889
  id: string;
1890
- type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
1890
+ type: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
1891
1891
  outputs: Record<string, string>;
1892
1892
  writes: Record<string, string>;
1893
1893
  resources: {
@@ -2139,7 +2139,7 @@ declare function createSynchronizedFunnelLocalEvaluator(configuration: Configura
2139
2139
  entry: string;
2140
2140
  nodes: {
2141
2141
  id: string;
2142
- type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2142
+ type: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2143
2143
  outputs: Record<string, string>;
2144
2144
  writes: Record<string, string>;
2145
2145
  resources: {
@@ -2429,7 +2429,7 @@ declare function createFunnelDecisionClient(options: IndianaServerOptions & {
2429
2429
  entry: string;
2430
2430
  nodes: {
2431
2431
  id: string;
2432
- type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2432
+ type: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2433
2433
  outputs: Record<string, string>;
2434
2434
  writes: Record<string, string>;
2435
2435
  resources: {
@@ -2667,7 +2667,7 @@ declare function createFunnelDecisionClient(options: IndianaServerOptions & {
2667
2667
  entry: string;
2668
2668
  nodes: {
2669
2669
  id: string;
2670
- type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2670
+ type: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2671
2671
  outputs: Record<string, string>;
2672
2672
  writes: Record<string, string>;
2673
2673
  resources: {
@@ -2695,7 +2695,7 @@ declare function createFunnelDecisionClient(options: IndianaServerOptions & {
2695
2695
  entry: string;
2696
2696
  nodes: {
2697
2697
  id: string;
2698
- type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2698
+ type: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2699
2699
  outputs: Record<string, string>;
2700
2700
  writes: Record<string, string>;
2701
2701
  resources: {
@@ -3167,7 +3167,7 @@ declare function createNativeReceiptClient(options: IndianaServerOptions): {
3167
3167
  requestId: string;
3168
3168
  orderId: string;
3169
3169
  receiptId: string;
3170
- orderStatus: "pending" | "failed" | "paid" | "trialing" | "created" | "cancelled";
3170
+ orderStatus: "pending" | "paid" | "failed" | "trialing" | "cancelled" | "created";
3171
3171
  refunded: boolean;
3172
3172
  nativeCompletion?: {
3173
3173
  orderId: string;
@@ -3235,8 +3235,8 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3235
3235
  revision: number;
3236
3236
  visit: number;
3237
3237
  nodeId: string;
3238
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
3239
- status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
3238
+ nodeType: "output" | "feature" | "split" | "action" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
3239
+ status: "running" | "failed" | "completed" | "closed" | "ineligible" | "waiting";
3240
3240
  stopped: boolean;
3241
3241
  canBack: boolean;
3242
3242
  authenticated: boolean;
@@ -3422,7 +3422,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3422
3422
  productId: string;
3423
3423
  productVersionId: string;
3424
3424
  name: string;
3425
- action: "addon" | "upgrade" | "purchase" | "topup";
3425
+ action: "upgrade" | "purchase" | "addon" | "topup";
3426
3426
  membershipId: string | null;
3427
3427
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
3428
3428
  amountMinor: string;
@@ -3518,7 +3518,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3518
3518
  cursor: {
3519
3519
  at: string;
3520
3520
  id: string;
3521
- type: "source" | "usage" | "invoice" | "debt" | "transaction" | "settlement";
3521
+ type: "usage" | "source" | "invoice" | "debt" | "transaction" | "settlement";
3522
3522
  };
3523
3523
  } | {
3524
3524
  kind: "billing";
@@ -3748,7 +3748,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3748
3748
  productId: string;
3749
3749
  productVersionId: string;
3750
3750
  name: string;
3751
- action: "addon" | "upgrade" | "purchase" | "topup";
3751
+ action: "upgrade" | "purchase" | "addon" | "topup";
3752
3752
  membershipId: string | null;
3753
3753
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
3754
3754
  amountMinor: string;
@@ -3771,7 +3771,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3771
3771
  productId: string;
3772
3772
  productVersionId: string;
3773
3773
  name: string;
3774
- action: "addon" | "upgrade" | "purchase" | "topup";
3774
+ action: "upgrade" | "purchase" | "addon" | "topup";
3775
3775
  membershipId: string | null;
3776
3776
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
3777
3777
  amountMinor: string;
@@ -3806,7 +3806,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3806
3806
  productId: string;
3807
3807
  productVersionId: string;
3808
3808
  name: string;
3809
- action: "addon" | "upgrade" | "purchase" | "topup";
3809
+ action: "upgrade" | "purchase" | "addon" | "topup";
3810
3810
  membershipId: string | null;
3811
3811
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
3812
3812
  amountMinor: string;
@@ -3894,7 +3894,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3894
3894
  productId: string;
3895
3895
  productVersionId: string;
3896
3896
  name: string;
3897
- action: "addon" | "upgrade" | "purchase" | "topup";
3897
+ action: "upgrade" | "purchase" | "addon" | "topup";
3898
3898
  membershipId: string | null;
3899
3899
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
3900
3900
  amountMinor: string;
@@ -3956,7 +3956,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3956
3956
  totalMinor: number;
3957
3957
  } | null;
3958
3958
  expiresAt: string;
3959
- provider: "apple" | "google" | "stripe";
3959
+ provider: "stripe" | "apple" | "google";
3960
3960
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
3961
3961
  lines: {
3962
3962
  lineId: string;
@@ -4016,9 +4016,9 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4016
4016
  automaticTax: boolean;
4017
4017
  execution: {
4018
4018
  provider: "stripe";
4019
- executor: "merchant" | "indiana";
4019
+ executor: "indiana" | "merchant";
4020
4020
  accountId: string;
4021
- mode: "subscription" | "payment";
4021
+ mode: "payment" | "subscription";
4022
4022
  lineItems: {
4023
4023
  price: string | null;
4024
4024
  quantity: number;
@@ -4088,13 +4088,13 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4088
4088
  operationId: string;
4089
4089
  orderId: string;
4090
4090
  status: "pending" | "failed" | "complete" | "cancelled";
4091
- executor: "merchant" | "indiana";
4091
+ executor: "indiana" | "merchant";
4092
4092
  checkoutUrl: string | null;
4093
4093
  execution: {
4094
4094
  provider: "stripe";
4095
- executor: "merchant" | "indiana";
4095
+ executor: "indiana" | "merchant";
4096
4096
  accountId: string;
4097
- mode: "subscription" | "payment";
4097
+ mode: "payment" | "subscription";
4098
4098
  lineItems: {
4099
4099
  price: string | null;
4100
4100
  quantity: number;
@@ -4165,7 +4165,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4165
4165
  productVersionId: string;
4166
4166
  provider: "apple" | "google";
4167
4167
  productId: string;
4168
- productKind: "membership" | "lifetime" | "credit_pack";
4168
+ productKind: "lifetime" | "membership" | "credit_pack";
4169
4169
  replacement: {
4170
4170
  sourceOrderId: string;
4171
4171
  sourceProductId: string;
@@ -4281,7 +4281,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4281
4281
  totalMinor: number;
4282
4282
  } | null;
4283
4283
  expiresAt: string;
4284
- provider: "apple" | "google" | "stripe";
4284
+ provider: "stripe" | "apple" | "google";
4285
4285
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
4286
4286
  lines: {
4287
4287
  lineId: string;
@@ -4341,9 +4341,9 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4341
4341
  automaticTax: boolean;
4342
4342
  execution: {
4343
4343
  provider: "stripe";
4344
- executor: "merchant" | "indiana";
4344
+ executor: "indiana" | "merchant";
4345
4345
  accountId: string;
4346
- mode: "subscription" | "payment";
4346
+ mode: "payment" | "subscription";
4347
4347
  lineItems: {
4348
4348
  price: string | null;
4349
4349
  quantity: number;
@@ -4413,13 +4413,13 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4413
4413
  operationId: string;
4414
4414
  orderId: string;
4415
4415
  status: "pending" | "failed" | "complete" | "cancelled";
4416
- executor: "merchant" | "indiana";
4416
+ executor: "indiana" | "merchant";
4417
4417
  checkoutUrl: string | null;
4418
4418
  execution: {
4419
4419
  provider: "stripe";
4420
- executor: "merchant" | "indiana";
4420
+ executor: "indiana" | "merchant";
4421
4421
  accountId: string;
4422
- mode: "subscription" | "payment";
4422
+ mode: "payment" | "subscription";
4423
4423
  lineItems: {
4424
4424
  price: string | null;
4425
4425
  quantity: number;
@@ -4490,7 +4490,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
4490
4490
  productVersionId: string;
4491
4491
  provider: "apple" | "google";
4492
4492
  productId: string;
4493
- productKind: "membership" | "lifetime" | "credit_pack";
4493
+ productKind: "lifetime" | "membership" | "credit_pack";
4494
4494
  replacement: {
4495
4495
  sourceOrderId: string;
4496
4496
  sourceProductId: string;
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- import{a as K,b as N,c as fe,d as ye,e as ve,g as T,h as Ie,j as ge,k as Pe,l as Ue,m as Me,n as Ve}from"./chunk-SUXAWRR6.js";import"./chunk-GRLMT5PR.js";import{a as Be,b as Ge,c as je,d as qe}from"./chunk-A3XRIG53.js";import{a}from"./chunk-VVV3JNS3.js";import{a as A}from"./chunk-3KQHKRZJ.js";import{$f as _,$j as le,Ak as de,Ck as me,Fc as B,Ic as X,Mc as ee,Yi as r,_j as pe,ag as O,bg as ie,ej as j,kf as te,sj as q,tj as se,uj as ce,vf as G,wf as oe,wj as D,xj as ue,yf as ae}from"./chunk-6A5WWFNS.js";import{a as o}from"./chunk-SOQO2RDZ.js";import{Mb as re}from"./chunk-LMR2TM3X.js";import{b as $,h as ne}from"./chunk-OBYJWIRB.js";import"./chunk-WWUUVURR.js";import{b as Z,q as W}from"./chunk-RRII2DMC.js";import{d as J}from"./chunk-KQCTDXVD.js";function we(e){return{async getCustomer(t){let n=r.getCustomer;return a(e,n,t,{request:"Invalid customer lookup",response:"Invalid customer response"})},async listCustomers(t={}){let n=r.listCustomers;return a(e,n,t,{request:"Invalid customer filters",response:"Invalid customer response"})},async updateCustomer(t){let n=r.updateCustomer;return a(e,n,t,{request:"Invalid customer patch",response:"Invalid customer response"})},async createGuestCustomer(t){let n=r.createGuestCustomer;return a(e,n,t)},async resumeGuestSession(t){let n=r.resumeGuestSession;return a(e,n,t)},async claimGuestCustomer(t){let n=r.claimGuestCustomer;return a(e,n,t)},async renewCustomerSession(t){let n=r.renewSession;return a(e,n,t)},async revokeCustomerSessions(t){let n=r.revokeSessions;return a(e,n,t)},async createCustomerSession(t){return a(e,r.createSession,{customerId:t},{request:"A customer ID is required",response:"Invalid customer session response"})},async getOrCreateCustomer(t){return a(e,r.createCustomer,t,{request:"Invalid customer input",response:"Invalid customer response"})}}}function u(e,t){try{return e.parse(t)}catch{throw new o("INVALID_RESPONSE","Invalid gateway response")}}function he(e){return{async checkEntitlement(t){let n=r.checkEntitlement;return a(e,n,t,u)},async readHoldings(t){let n=r.readHoldings;return a(e,n,t,u)},async readSeats(t){let n=r.readSeats;return a(e,n,t,u)},async manageSeat(t){let n=r.manageSeat;return a(e,n,t,u)}}}function Se(e){return{async readAiPricing(t){let n=r.readAiPricing;return a(e,n,t,u)},async readUsage(t){let n=r.readUsage;return a(e,n,t,u)},async setUsage(t){let n=r.setUsage;return a(e,n,t,u)},async manageBalanceGrant(t){let n=r.manageBalanceGrant;return a(e,n,t,u)},async readBalanceSource(t){let n=r.readBalanceSource;return a(e,n,t,u)},async adjustBalance(t){let n=r.adjustBalance;return a(e,n,t,u)},async listBalanceGrants(t){let n=r.listBalanceGrants;return a(e,n,t,u)},async manageBillingLimits(t){let n=r.manageBillingLimits;return a(e,n,t,u)},async manageUsageEntity(t){let n=r.manageUsageEntity;return a(e,n,t,u)},async readUsageAnalytics(t){let n=r.readUsageAnalytics;return a(e,n,t,u)},async readCreditAnalytics(t){let n=r.readCreditAnalytics;return a(e,n,t,u)},async submitUsageBatch(t){let n=r.submitUsageBatch;return a(e,n,t,u)},async readUsageBatch(t){let n=r.readUsageBatch;return a(e,n,t,u)},async readLedger(t){let n=r.readLedger;return a(e,n,t,u)},async readCreditStatement(t){let n=r.readCreditStatement;return a(e,n,t,u)},async quoteBalance(t){let n=r.quoteBalance;return a(e,n,t,u)},async trackUsage(t){let n=r.trackUsage;return a(e,n,t,u)},async mutateBalance(t){let n=r.mutateBalance;return a(e,n,t,u)}}}function Ee(e){return{async listInvoiceTemplates(t={}){let n=r.listInvoiceTemplates;return a(e,n,t,u)},async previewInvoice(t){let n=r.previewInvoice;return a(e,n,t,u)},async createInvoice(t){let n=r.createInvoice;return a(e,n,t,u)},async manageInvoice(t){let n=r.manageInvoice;return a(e,n,t,u)},async readInvoiceOperation(t){let n=r.readInvoiceOperation;return a(e,n,t,u)},async listInvoices(t){let n=r.listInvoices;return a(e,n,t,u)},async getInvoice(t){let n=r.getInvoice;return a(e,n,t,u)},async setupPayment(t){let n=r.setupPayment;return a(e,n,t,u)},async readPaymentSetup(t){let n=r.readPaymentSetup;return a(e,n,t,u)},async readBillingInvoice(t){let n=r.readBillingInvoice;return a(e,n,t,u)},async previewRefund(t){let n=r.previewRefund;return a(e,n,t,u)},async refund(t){let n=r.refund;return a(e,n,t,u)},async readRefund(t){let n=r.readRefund;return a(e,n,t,u)}}}function Ae(e){return{async previewSubscriptionBatch(t){let n=r.previewSubscriptionBatch;return a(e,n,t,u)},async confirmSubscriptionBatch(t){let n=r.confirmSubscriptionBatch;return a(e,n,t,u)},async readSubscriptionBatch(t){let n=r.readSubscriptionBatch;return a(e,n,t,u)},async abandonSubscriptionBatch(t){let n=r.abandonSubscriptionBatch;return a(e,n,t,u)},async manageSubscriptionTrial(t){let n=r.manageSubscriptionTrial;return a(e,n,t,u)},async readSubscriptionTrial(t){let n=r.readSubscriptionTrial;return a(e,n,t,u)},async listSubscriptions(t){let n=r.listSubscriptions;return a(e,n,t,u)},async listPurchases(t){let n=r.listPurchases;return a(e,n,t,u)},async listSubscriptionConflicts(t){let n=r.listSubscriptionConflicts;return a(e,n,t,u)},async retrySubscriptionConflict(t){let n=r.retrySubscriptionConflict;return a(e,n,t,u)},async previewUpdate(t){let n=r.previewUpdate;return a(e,n,t,u)},async update(t){let n=r.update;return a(e,n,t,u)},async readSubscriptionUpdate(t){let n=r.readSubscriptionUpdate;return a(e,n,t,u)},async restoreNativePurchase(t){let n=r.restoreNativePurchase;return a(e,n,t,u)},async verifySubscriptions(t){let n=r.verifySubscriptions;return a(e,n,t,u)},async previewAttach(t){let n=r.previewAttach;return a(e,n,t,u)},async attach(t){let n=r.attach;return a(e,n,t,u)},async readSubscriptionOperation(t){let n=r.readSubscriptionOperation;return a(e,n,t,u)}}}function Fe(e){return{async recordCouponRedemption(t){return a(e,r.recordCouponRedemption,t,{request:"Invalid Coupon redemption facts",parseResponse:u})},async grantOffer(t){let n=r.grantOffer;return a(e,{...n,request:n.request.refine(c=>!!c.customerId)},{...t,requestId:t.requestId??crypto.randomUUID()},{request:"Invalid offer grant",response:"Invalid offer response"})}}}function Ce(e){return{...he(e),...Se(e),...Ee(e),...Ae(e),...Fe(e)}}function Re(e){return{async getFeatures(t={}){let n=r.getFeatures;return a(e,n,t,u)},async evaluateFeatures(t){let n=r.evaluateFeatures;return a(e,n,t,u)}}}function Oe(e){return{async trackEvents(t){let n=r.trackEvents;return a(e,n,t,u)}}}function be(e){return{async resolveContent(t){let n=r.resolveContent;return a(e,n,t,u)},async resolvePaywall(t){let n=r.resolvePaywall;return a(e,n,t,u)},async resolveOffering(t){let n=r.resolveOffering;return a(e,n,t,u)}}}function Ke(e){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A(e);t.identify(e.apiKey);let n=t.request;return{async sendMessage(c){let i=r.sendMessage;return i.response.parse(await n(i.path,i.request.parse(c)))},async readMessage(c){let i=r.readMessage;return i.response.parse(await n(i.path,i.request.parse(c)))},...we(n),...Ce(n),...Re(n),...Oe(n),...be(n)}}function ze(){if(typeof window<"u")throw new o("SERVER_ONLY","Guest identity is issued by your backend");let e=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...e)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}async function Ye(e,t){if(typeof window<"u")throw new o("SERVER_ONLY","Renewal requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let{funnelCredentialCommandSchema:n,funnelCredentialResponseSchema:c}=await import("./src-EG7RWDDY.js"),i=A(e);i.identify(e.apiKey);let l=c.parse(await N(e,await i.request("funnels",n.parse({...t,operation:"renew_run"}))));if(l.run.id!==t.runId)throw new o("INVALID_RESPONSE","Run renewal identity changed");return l}function ke(e){let t=ye(e),n=s=>{throw new o("INVALID_RESPONSE",s)};t.nodes.size!==e.topology.nodes.length&&n("Duplicate local node identity"),t.nodes.get(e.topology.entry)?.type!=="entry"&&n("A local Funnel must start at Entry");let c=new Set(["entry","condition","feature","split","end","output"]);for(let s of t.nodes.values()){if(!c.has(s.type))throw new o("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(s.type==="entry"&&s.id!==e.topology.entry&&n("Unexpected Entry node"),["entry","feature"].includes(s.type)&&!s.outputs.next&&n("Local next exit is unavailable"),s.type==="feature"){let p=s.resources.featureKey;(!p||!Object.hasOwn(e.evaluation.variables,s.writes.value)||!Object.hasOwn(t.features,p))&&n("Local Feature definition or declaration is unavailable")}if(s.type==="condition"){let p=e.conditions[s.id];(!p||!s.outputs.default||p.some((f,y)=>f.port!==`case:${y}`||!s.outputs[f.port]))&&n("Local Condition exits are unavailable")}if(s.type==="split"&&(!s.resources.experimentId||!Object.hasOwn(e.growth.experiments,s.resources.experimentId)||!s.outputs.notParticipating)&&n("Local Experiment definition or exit is unavailable"),s.type==="end"||s.type==="output"){let p=e.evaluation.terminals[s.id];if(!p)throw new o("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(s.outputs).length&&n("A terminal cannot have outgoing edges"),p.output?.type==="feature"&&!Object.hasOwn(t.features,p.output.featureKey)&&n("Terminal Feature definition is unavailable")}for(let p of Object.values(s.outputs))t.nodes.has(p)||n("Local target is unavailable")}let i=new Set,l=new Set;function d(s){if(l.has(s)&&n("Local graph contains a cycle"),!i.has(s)){l.add(s);for(let p of Object.values(t.nodes.get(s).outputs))d(p);l.delete(s),i.add(s)}}return d(e.topology.entry),i.size!==t.nodes.size&&n("Local graph contains unreachable nodes"),{evaluate(s){let p={},f=s.context;f.features=t.features,f.savedGroups=t.savedGroups;let y=()=>{f.attributes=te({declarations:e.evaluation.variables,attributes:s.attributes,parameters:s.parameters,answers:{},results:p,savedGroups:t.savedGroups})};y();let g=e.topology.entry,m=0;for(;;){let v=t.nodes.get(g);if(v.type==="end"||v.type==="output"){let I=e.evaluation.terminals[g],w=I.output,S=w?.type==="feature"?t.feature(w.featureKey,f):w?.type==="variable"?ee({source:"variable",key:w.key,...w.path?{path:w.path}:{}},{declarations:e.evaluation.variables,answers:{},results:p,parameters:s.parameters,attributes:s.attributes,savedGroups:t.savedGroups}):w?.value??null;return B(e.evaluation.outputSchema,S)||n("Local output does not match its declaration"),{outcome:I.outcome,value:S}}if(m++>=e.evaluation.maxTransitions)throw new o("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(v.type==="entry")g=v.outputs.next;else{let I=t.evaluate(g,f);if(v.type==="feature"){let w=v.writes.value,S=I.value??null;B(e.evaluation.variables[w],S)||n("Local Feature value does not match its declaration"),X(e.evaluation.variables,{writes:v.writes},{[w]:S}),p[w]=S,y()}g=I.target}}}}}import{z as Le}from"zod";function xe(e,t,n){let c=Z.parse(e.attributes);if(["parameters","answers","results"].some(E=>Object.hasOwn(c,E)))throw new o("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let i=re.parse(e.parameters??{}),l=Le.record(Le.string(),W).parse(e.stickyBucketAssignmentDocs??{});for(let[E,h]of Object.entries(l))if(E!==`${h.attributeName}||${h.attributeValue}`||!Object.hasOwn(c,h.attributeName)||J(c[h.attributeName])!==h.attributeValue)throw new o("INVALID_REQUEST","Sticky document identity does not match this session");let d=e.saveStickyBucketAssignmentDoc,s=e.onFeatureUsage,p=e.onExperimentViewed,f=e.onError,y=new Map,g=new Set,m={},v=Promise.resolve();function I(E){let h=v.then(()=>(n(),E()));return v=h.catch(()=>{}),h}function w(E){try{f?.(E)}catch{}}function S(E){try{let h=E();h&&typeof h.catch=="function"&&h.catch(w)}catch(h){w(h)}}async function k(){for(let[E,h]of y){if(n(),d)try{await d(structuredClone(h))}catch{throw new o("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}n(),y.delete(E)}}return{evaluate(E={}){let h=E.track===!0;return I(async()=>{let L=await t();n(L);let Y=new Set(g),H={...m},Q=new Map,M=[],_e={stickyBucketAssignmentDocs:structuredClone(l),saveStickyBucketAssignmentDoc(F){Q.set(`${F.attributeName}||${F.attributeValue}`,structuredClone(F))},...h?{trackedExperiments:Y,trackedFeatureUsage:H,onExperimentViewed(F,R){let V=structuredClone(F),Te=structuredClone(R);p&&M.push(()=>p(structuredClone(V),structuredClone(Te)))},onFeatureUsage(F,R){let V=structuredClone(R);s&&M.push(()=>s(F,structuredClone(V)))}}:{}},Ne=L.program.evaluate({attributes:c,parameters:i,context:_e});n(L);for(let[F,R]of Q)l[F]=R,y.set(F,R);await k(),n(L),h&&(g=Y,m=H);for(let F of M)S(F);let x=L.configuration;return structuredClone({evaluationMode:"local",scope:x.scope,funnelId:x.funnelId,versionId:x.versionId,evaluationRevision:x.evaluationRevision,generation:x.growth.generation,...Ne})})},flush:()=>I(k),get stickyBucketAssignmentDocs(){return n(),structuredClone(l)}}}var He=6e4;function P(e){if(typeof window<"u")throw new o("SERVER_ONLY","Local Funnel sessions run on your backend");let t=$.parse(e.scope),n=e.funnelId,c=e.load,i,l,d,s=0,p=g=>Date.now()>=g.expiresAt;async function f(){if(l)return l;let g=s;i=void 0;let m=(async()=>{let v=await c();if(g!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(v&&typeof v=="object"&&"evaluationMode"in v&&v.evaluationMode==="remote")throw u(D,v),new o("EVALUATION_MODE","This Funnel requires remote decide");let I=u(ue,v);if(g!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(I.scope.projectId!==t.projectId||I.scope.environment!==t.environment||I.funnelId!==n)throw new o("SCOPE_MISMATCH","Local configuration scope changed");if(I.growth.scope.projectId!==t.projectId||I.growth.scope.environment!==t.environment||I.growth.expiresAt!==I.expiresAt)throw new o("INVALID_RESPONSE","GB configuration scope or expiry changed");let w=Math.min(Date.now()+He,I.expiresAt?Date.parse(I.expiresAt):1/0);if(Date.now()>=w)throw new o("CONFIGURATION_EXPIRED","Refresh expired local rules");let S=JSON.stringify([t.projectId,t.environment,n,I.versionId,I.evaluationRevision,I.growth.generation]),k=[I.topology,I.conditions,I.evaluation,I.growth.features,I.growth.experiments,I.growth.savedGroups];if(d?.key===S&&!Ie(d.body,k))throw new o("INVALID_RESPONSE","Immutable local configuration identity changed");return d?.key!==S&&(d={key:S,body:k,program:ke(I)}),i={key:S,configuration:I,expiresAt:w,program:d.program},i})();l=m;try{return await m}finally{l===m&&(l=void 0)}}function y(){return l??(i&&!p(i)?Promise.resolve(i):f())}return{session(g){let m=s;return xe(g,y,v=>{if(e.assertUsable?.(),m!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(v&&(p(v)||i?.key!==v.key))throw new o("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){s++,i=void 0,l=void 0,d=void 0}}}function Qe(e,t){let n=e.snapshot?.generation,c=P({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:t,load:()=>e.localFunnel(t),assertUsable:()=>e.assertFunnel(t)}),i=e.subscribe(()=>{let d=e.snapshot?.generation;e.fresh&&d!==n&&(n=d,c.refresh().catch(()=>{}))}),l=c.session;return Object.assign(c,{session(d){let s=l(d),p=s.evaluate;return Object.assign(s,{async evaluate(...f){return e.fresh||await e.refresh(),p(...f)}})},destroy(){i(),c.reset()}})}function $e(e){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on the backend");return{start:t=>ge(e,t)}}function De(e,t,n){return de(e,t,n,fe)}var b=class extends o{constructor(n,c){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,c);this.decisionId=n;this.decisionRequestId=c}decisionId;decisionRequestId};async function U(e,t,n,c){let{decisionId:i,requestId:l}=e,d=e,s=250,p=0;for(;;){if(d.decisionId!==i||d.requestId!==l||d.decision&&!T(d.decision,t))throw new o("INVALID_RESPONSE","Decision request or customer changed");if(d.decision)return d.decision;if(d.status==="failed")throw new o("DECISION_FAILED","Decision execution failed",503,l);if(Date.now()>=n)throw new b(i,l);if(await new Promise(f=>setTimeout(f,Math.min(Math.max(s,p-Date.now()),n-Date.now()))),Date.now()>=n)throw new b(i,l);s=Math.min(1e3,s*2);try{d=await c(i,n)}catch(f){if(f instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(f.code)){p=Date.now()+(f.retryAfterSeconds??0)*1e3;continue}throw f}}}function z(e){if("remoteEval"in e)throw new o("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new o("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t,n,c=new Map;async function i(p,f){let y=p;y.status!=="pending"&&c.delete(y.decisionId);for(let g=0;g<32&&y.evaluation;g++){let m=y.evaluation;if(m.runId!==y.decisionId)throw new o("INVALID_RESPONSE","Local evaluation Run changed");let v=c.get(y.decisionId);if(!v&&m.type==="evaluate_segment"){let w=me.parse(await l({operation:"segment_configuration",funnelId:e.funnelId,versionId:m.versionId},f));if(w.configuration.scope.projectId!==e.scope.projectId||w.configuration.scope.environment!==e.scope.environment||w.configuration.funnelId!==e.funnelId||w.configuration.versionId!==m.versionId||w.configuration.evaluationRevision!==m.policyRevision)throw new o("SCOPE_MISMATCH","Original decision segment configuration changed");if(c.size>=128)throw new o("COMMAND_PENDING","Reconcile outstanding decisions first");v={operation:"commit_decision_segment",decisionId:y.decisionId,requestId:j(y.decisionId,m.visit,`segment:${m.revision}`),nodeId:m.nodeId,visit:m.visit,revision:m.revision,policyRevision:m.policyRevision,generation:w.configuration.growth.generation,...ve(w.configuration,w.document,m)},c.set(y.decisionId,v)}if(!v){if(m.type!=="evaluate")throw new o("INVALID_RESPONSE","Unknown decision instruction");if((!n||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision||n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())&&(n=D.parse(await l({operation:"configuration",funnelId:e.funnelId,versionId:m.versionId},f))),n.scope.projectId!==e.scope.projectId||n.scope.environment!==e.scope.environment||n.funnelId!==e.funnelId)throw new o("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(n.evaluationMode!=="local"||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision)throw new o("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(c.size>=128)throw new o("COMMAND_PENDING","Reconcile outstanding Local decisions first");v={operation:"evaluate_decision",decisionId:y.decisionId,requestId:j(y.decisionId,m.visit,"evaluation"),nodeId:m.nodeId,visit:m.visit,revision:m.revision,receiptId:m.receiptId,policyRevision:m.policyRevision,generation:n.growth.generation,result:De(n,m.nodeId,m)},c.set(y.decisionId,v)}let I=O.parse(await l(v,f));if(I.decisionId!==p.decisionId||I.requestId!==p.requestId)throw new o("INVALID_RESPONSE","Decision identity changed during local evaluation");c.delete(y.decisionId),y=I}return y}async function l(p,f,y=!1){let g=A({...e,fetch:(m,v)=>{let I=new Headers(v?.headers);return I.set("Accept-Encoding","identity"),y&&I.set("Prefer","respond-async"),(e.fetch??globalThis.fetch)(m,{...v,headers:I})},timeoutMs:Math.min(e.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)});return g.identify(e.apiKey),g.request("funnels",p)}async function d(p,f){let y=O.parse(await l(_.parse({operation:"read_decision",decisionId:p}),f));if(y.decisionId!==p)throw new o("INVALID_RESPONSE","Decision identity changed");return i(y,f)}async function s(p,f,y=!1){let g=_.options[0].parse({...p,operation:"decide",funnelId:e.funnelId}),m;try{m=O.parse(await l(g,f,y))}catch(v){throw v instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(v.code)?new o("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",v.status,p.requestId):v}if(m.requestId!==p.requestId||m.decision&&!T(m.decision,g.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");return{response:await i(m,f),customer:g.customer}}return{local(){return t??=P({scope:e.scope,funnelId:e.funnelId,load:()=>l({operation:"local_configuration",funnelId:e.funnelId})})},async configuration(){let p=D.parse(await l({operation:"configuration",funnelId:e.funnelId}));if(p.scope.projectId!==e.scope.projectId||p.scope.environment!==e.scope.environment||p.funnelId!==e.funnelId)throw new o("SCOPE_MISMATCH","Configuration scope changed");return p},features(p={}){return K({...p,scope:e.scope,load:async()=>ne.parse(await l({operation:"feature_config",funnelId:e.funnelId}))})},read:p=>d(p),async submit(p){return(await s(p,void 0,!0)).response},async decide(p){let f=Date.now()+3e4,y=await s(p,f);return U(y.response,y.customer,f,d)},async reportUsed(p){let f=ie.parse(await l(_.parse({...p,operation:"report_used"})));if(f.decisionId!==p.decisionId||f.eventId!==p.eventId)throw new o("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Je(e){if(typeof window<"u")throw new o("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","Server API key required");let t=A({...e,timeoutMs:e.timeoutMs??35e3});return t.identify(e.apiKey),{async recover(n){let c=pe.parse(n);if(c.orderId!==c.receiptId)throw new o("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let i=c.nativeEvidence,l={requestId:c.requestId,customerToken:c.customerToken,purchaseIntentId:c.orderId,...i===null?{intent:"read"}:i.provider==="apple"?{provider:"apple",signedTransaction:i.signedTransaction}:{provider:"google",purchaseToken:i.purchaseToken}},d=r.restoreNativePurchase.response.parse(await t.request(r.restoreNativePurchase.path,l));if(d.operation.requestId!==c.requestId||d.operation.purchaseIntentId!==c.orderId)throw new o("INVALID_RESPONSE","Native receipt request identity changed");let s=le.parse({scope:d.scope,requestId:c.requestId,orderId:d.operation.orderId,receiptId:d.operation.orderId,orderStatus:d.operation.status,refunded:d.operation.refunded,...d.operation.completion===null?{}:{nativeCompletion:{orderId:d.operation.orderId,receiptId:d.operation.orderId,...d.operation.completion}}});if(s.requestId!==c.requestId||s.orderId!==c.orderId||s.receiptId!==c.receiptId||s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Current order receipt scope changed");return s}}}import{z as Ze}from"zod";var C=Ze.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function We(e,t){let n=C.parse(e.inputTokens.total),c=C.parse(e.outputTokens.total),i=C.parse(e.inputTokens.cacheRead??0),l=C.parse(e.inputTokens.cacheWrite??0),d=C.parse(e.outputTokens.reasoning??0);if(i+l>n||d>c||e.inputTokens.noCache!==void 0&&C.parse(e.inputTokens.noCache)!==n-i-l||e.outputTokens.text!==void 0&&C.parse(e.outputTokens.text)!==c-d)throw new o("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:n-i-l,cache_read:i,cache_write:l,output:t==="output"?c:c-d,reasoning:t==="separate"?d:0,input_audio:0,output_audio:0}}function Xe(e){if(typeof window<"u")throw new o("SERVER_ONLY","AI usage belongs on the trusted backend");if(!e.modelId||!["output","separate"].includes(e.reasoning))throw new o("INVALID_REQUEST","Model ID and reasoning pricing are required");async function t(c){await e.persist({context:c,modelId:e.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function n(c,i){let l={context:c,modelId:e.modelId,usage:i,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(l);let d=e.mapTokens?e.mapTokens(i):We(i,e.reasoning),s=await e.pricing.quoteTokens({modelId:e.modelId,tokens:d});await e.persist({...l,tokens:d,quote:s,phase:"quoted"});let p=await e.pricing.trackTokens(e.client,{...c,quote:s});if(!p.receipt.accepted)throw new o("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await e.persist({...l,tokens:d,quote:s,receipt:p,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:c}){let i=await e.context(),l;try{l=await c()}catch(d){throw await t(i),d}return await n(i,l.usage),l},async wrapStream({doStream:c}){let i=await e.context(),l;try{l=await c()}catch(y){throw await t(i),y}let d=!1,s=!1,p=l.stream.getReader();async function f(){d||s||(s=!0,await t(i))}return{...l,stream:new ReadableStream({async pull(y){try{let{value:g,done:m}=await p.read();if(m){if(!d)throw await f(),new o("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");y.close();return}if(g.type==="finish"){if(d)throw new o("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");d=!0,await n(i,g.usage)}y.enqueue(g)}catch(g){try{await f()}finally{y.error(g),await p.cancel(g)}}},async cancel(y){try{await f()}finally{await p.cancel(y)}}})}}}}function en(e){if(typeof window<"u")throw new o("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A(e);return t.identify(e.apiKey),{async signal(n){let c=G.parse({...n,operation:"signal"}),i=oe.parse(await t.request("funnels",c));if(i.runId!==n.runId||i.eventId!==n.eventId||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Receipt identity changed");return i},async readResults(n){let c=G.parse({operation:"read_results",runId:n}),i=ae.parse(await t.request("funnels",c));if(i.runId!==n||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Result identity changed");return i}}}function nn(e){if("remoteEval"in e)throw new o("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new o("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A({...e,timeoutMs:e.timeoutMs??35e3});return t.identify(e.apiKey),{async decide(n){let c=Date.now()+(e.timeoutMs??3e4),i=q.parse({...n,funnelId:e.funnelId,operation:"campaign_decide"}),l=A({...e,timeoutMs:Math.min(e.timeoutMs??35e3,Math.max(1,c-Date.now()))});l.identify(e.apiKey);let d=O.parse(await l.request("funnels",i));if(d.scope.projectId!==e.scope.projectId||d.scope.environment!==e.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");return U(d,i.customer,c,(s,p)=>z({...e,timeoutMs:Math.min(e.timeoutMs??1e4,Math.max(1,p-Date.now()))}).read(s))},async start(n){let c=q.parse({...n,funnelId:e.funnelId,operation:"campaign_start"}),i=ce.parse(await t.request("funnels",c)),l=se.parse("suppressed"in i?i:await N(e,i));if(l.scope.projectId!==e.scope.projectId||l.scope.environment!==e.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in l)&&(l.run.source.id!==e.funnelId||!l.customerId||c.customer.type==="id"&&l.customerId!==c.customer.value))throw new o("INVALID_RESPONSE","Campaign Funnel or Customer changed");return l}}}export{b as FunnelDecisionTimeoutError,o as IndianaError,Be as aiPriceSnapshotSchema,Ge as aiTokenQuoteSchema,je as createAiPricing,Xe as createAiUsageMiddleware,Pe as createConfigurationSync,qe as createConfiguredAiPricing,K as createFeatureClient,nn as createFunnelCampaignClient,z as createFunnelDecisionClient,P as createFunnelLocalEvaluator,en as createFunnelOrchestrationClient,Me as createFunnelStartClient,ze as createGuestToken,Ke as createIndianaServer,Ve as createLocalFunnelClient,Je as createNativeReceiptClient,$e as createPaywallStartClient,Qe as createSynchronizedFunnelLocalEvaluator,Ue as evaluateFunnelNode,Ye as renewFunnelRun};
1
+ import{a as z,b as T,c as Ie,d as ge,e as we,g as _,h as he,i as A,j as F,l as Se,m as Ve,n as Be,o as Ge,p as je}from"./chunk-UYSOTMY3.js";import"./chunk-CPLLMISZ.js";import{a as qe,b as Ke,c as ze,d as He}from"./chunk-67A7I6MB.js";import{a as o}from"./chunk-5O667MKA.js";import{$ as le,R as r,S as q,X as ce,Y as ue,Z as K,_ as pe,aa as N,ba as de,ea as me,fa as fe,k as G,ka as ye,l as ee,m as ne,ma as ve,t as re,u as j,v as ae,w as ie,x as P,y as b,z as se}from"./chunk-PK5HYUHD.js";import{ca as oe,fa as u}from"./chunk-G23YNWWI.js";import{a as $,e as te}from"./chunk-G56XGVMS.js";import"./chunk-WSVH6IQA.js";import{b as X,e as Z}from"./chunk-7DXL3LHT.js";import{a as W}from"./chunk-3PZ4Y6UD.js";function Ee(e){return{async getCustomer(t){let n=r.getCustomer;return o(e,n,t,{request:"Invalid customer lookup",response:"Invalid customer response"})},async listCustomers(t={}){let n=r.listCustomers;return o(e,n,t,{request:"Invalid customer filters",response:"Invalid customer response"})},async updateCustomer(t){let n=r.updateCustomer;return o(e,n,t,{request:"Invalid customer patch",response:"Invalid customer response"})},async createGuestCustomer(t){let n=r.createGuestCustomer;return o(e,n,t)},async resumeGuestSession(t){let n=r.resumeGuestSession;return o(e,n,t)},async claimGuestCustomer(t){let n=r.claimGuestCustomer;return o(e,n,t)},async revokeCustomerSessions(t){let n=r.revokeSessions;return o(e,n,t)},async createCustomerSession(t){return o(e,r.createSession,{customerId:t},{request:"A customer ID is required",response:"Invalid customer session response"})},async getOrCreateCustomer(t){return o(e,r.createCustomer,t,{request:"Invalid customer input",response:"Invalid customer response"})}}}function c(e,t){try{return e.parse(t)}catch{throw new u("INVALID_RESPONSE","Invalid gateway response")}}function Fe(e){return{async checkEntitlement(t){let n=r.checkEntitlement;return o(e,n,t,c)},async readHoldings(t){let n=r.readHoldings;return o(e,n,t,c)},async readSeats(t){let n=r.readSeats;return o(e,n,t,c)},async manageSeat(t){let n=r.manageSeat;return o(e,n,t,c)}}}function Ce(e){return{async readAiPricing(t){let n=r.readAiPricing;return o(e,n,t,c)},async readUsage(t){let n=r.readUsage;return o(e,n,t,c)},async setUsage(t){let n=r.setUsage;return o(e,n,t,c)},async manageBalanceGrant(t){let n=r.manageBalanceGrant;return o(e,n,t,c)},async readBalanceSource(t){let n=r.readBalanceSource;return o(e,n,t,c)},async adjustBalance(t){let n=r.adjustBalance;return o(e,n,t,c)},async listBalanceGrants(t){let n=r.listBalanceGrants;return o(e,n,t,c)},async manageBillingLimits(t){let n=r.manageBillingLimits;return o(e,n,t,c)},async manageUsageEntity(t){let n=r.manageUsageEntity;return o(e,n,t,c)},async readUsageAnalytics(t){let n=r.readUsageAnalytics;return o(e,n,t,c)},async readCreditAnalytics(t){let n=r.readCreditAnalytics;return o(e,n,t,c)},async submitUsageBatch(t){let n=r.submitUsageBatch;return o(e,n,t,c)},async readUsageBatch(t){let n=r.readUsageBatch;return o(e,n,t,c)},async readLedger(t){let n=r.readLedger;return o(e,n,t,c)},async readCreditStatement(t){let n=r.readCreditStatement;return o(e,n,t,c)},async quoteBalance(t){let n=r.quoteBalance;return o(e,n,t,c)},async trackUsage(t){let n=r.trackUsage;return o(e,n,t,c)},async mutateBalance(t){let n=r.mutateBalance;return o(e,n,t,c)}}}function Ae(e){return{async listInvoiceTemplates(t={}){let n=r.listInvoiceTemplates;return o(e,n,t,c)},async previewInvoice(t){let n=r.previewInvoice;return o(e,n,t,c)},async createInvoice(t){let n=r.createInvoice;return o(e,n,t,c)},async manageInvoice(t){let n=r.manageInvoice;return o(e,n,t,c)},async readInvoiceOperation(t){let n=r.readInvoiceOperation;return o(e,n,t,c)},async listInvoices(t){let n=r.listInvoices;return o(e,n,t,c)},async getInvoice(t){let n=r.getInvoice;return o(e,n,t,c)},async setupPayment(t){let n=r.setupPayment;return o(e,n,t,c)},async readPaymentSetup(t){let n=r.readPaymentSetup;return o(e,n,t,c)},async readBillingInvoice(t){let n=r.readBillingInvoice;return o(e,n,t,c)},async previewRefund(t){let n=r.previewRefund;return o(e,n,t,c)},async refund(t){let n=r.refund;return o(e,n,t,c)},async readRefund(t){let n=r.readRefund;return o(e,n,t,c)}}}function Re(e){return{async previewSubscriptionBatch(t){let n=r.previewSubscriptionBatch;return o(e,n,t,c)},async confirmSubscriptionBatch(t){let n=r.confirmSubscriptionBatch;return o(e,n,t,c)},async readSubscriptionBatch(t){let n=r.readSubscriptionBatch;return o(e,n,t,c)},async abandonSubscriptionBatch(t){let n=r.abandonSubscriptionBatch;return o(e,n,t,c)},async manageSubscriptionTrial(t){let n=r.manageSubscriptionTrial;return o(e,n,t,c)},async readSubscriptionTrial(t){let n=r.readSubscriptionTrial;return o(e,n,t,c)},async listSubscriptions(t){let n=r.listSubscriptions;return o(e,n,t,c)},async listPurchases(t){let n=r.listPurchases;return o(e,n,t,c)},async listSubscriptionConflicts(t){let n=r.listSubscriptionConflicts;return o(e,n,t,c)},async retrySubscriptionConflict(t){let n=r.retrySubscriptionConflict;return o(e,n,t,c)},async previewUpdate(t){let n=r.previewUpdate;return o(e,n,t,c)},async update(t){let n=r.update;return o(e,n,t,c)},async readSubscriptionUpdate(t){let n=r.readSubscriptionUpdate;return o(e,n,t,c)},async restoreNativePurchase(t){let n=r.restoreNativePurchase;return o(e,n,t,c)},async verifySubscriptions(t){let n=r.verifySubscriptions;return o(e,n,t,c)},async previewAttach(t){let n=r.previewAttach;return o(e,n,t,c)},async attach(t){let n=r.attach;return o(e,n,t,c)},async readSubscriptionOperation(t){let n=r.readSubscriptionOperation;return o(e,n,t,c)}}}function Oe(e){return{async recordCouponRedemption(t){return o(e,r.recordCouponRedemption,t,{request:"Invalid Coupon redemption facts",parseResponse:c})},async grantOffer(t){let n=r.grantOffer;return o(e,{...n,request:n.request.refine(a=>!!a.customerId)},{...t,requestId:t.requestId??crypto.randomUUID()},{request:"Invalid offer grant",response:"Invalid offer response"})}}}function be(e){return{...Fe(e),...Ce(e),...Ae(e),...Re(e),...Oe(e)}}function xe(e){return{async getFeatures(t={}){let n=r.getFeatures;return o(e,n,t,c)},async evaluateFeatures(t){let n=r.evaluateFeatures;return o(e,n,t,c)}}}function ke(e){return{async trackEvents(t){let n=r.trackEvents;return o(e,n,t,c)}}}function Le(e){return{async resolveContent(t){let n=r.resolveContent;return o(e,n,t,c)},async resolvePaywall(t){let n=r.resolvePaywall;return o(e,n,t,c)},async resolveOffering(t){let n=r.resolveOffering;return o(e,n,t,c)}}}function Qe(e){A(e.apiKey,"Secret API keys must stay on your backend");let n=F(e).request;return{async sendMessage(a){let s=r.sendMessage;return s.response.parse(await n(s.path,s.request.parse(a)))},async readMessage(a){let s=r.readMessage;return s.response.parse(await n(s.path,s.request.parse(a)))},...Ee(n),...be(n),...xe(n),...ke(n),...Le(n)}}function Je(){if(typeof window<"u")throw new u("SERVER_ONLY","Guest identity is issued by your backend");let e=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...e)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}async function Ye(e,t){A(e.apiKey,"Renewal requires your backend");let n=F(e),a=ue.parse(await T(e,await n.request("funnels",ce.parse({...t,operation:"renew_run"}))));if(a.run.id!==t.runId)throw new u("INVALID_RESPONSE","Run renewal identity changed");return a}function De(e){let t=ge(e),n=i=>{throw new u("INVALID_RESPONSE",i)};t.nodes.size!==e.topology.nodes.length&&n("Duplicate local node identity"),t.nodes.get(e.topology.entry)?.type!=="entry"&&n("A local Funnel must start at Entry");let a=new Set(["entry","condition","feature","split","end","output"]);for(let i of t.nodes.values()){if(!a.has(i.type))throw new u("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(i.type==="entry"&&i.id!==e.topology.entry&&n("Unexpected Entry node"),["entry","feature"].includes(i.type)&&!i.outputs.next&&n("Local next exit is unavailable"),i.type==="feature"){let p=i.resources.featureKey;(!p||!Object.hasOwn(e.evaluation.variables,i.writes.value)||!Object.hasOwn(t.features,p))&&n("Local Feature definition or declaration is unavailable")}if(i.type==="condition"){let p=e.conditions[i.id];(!p||!i.outputs.default||p.some((f,y)=>f.port!==`case:${y}`||!i.outputs[f.port]))&&n("Local Condition exits are unavailable")}if(i.type==="split"&&(!i.resources.experimentId||!Object.hasOwn(e.growth.experiments,i.resources.experimentId)||!i.outputs.notParticipating)&&n("Local Experiment definition or exit is unavailable"),i.type==="end"||i.type==="output"){let p=e.evaluation.terminals[i.id];if(!p)throw new u("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(i.outputs).length&&n("A terminal cannot have outgoing edges"),p.output?.type==="feature"&&!Object.hasOwn(t.features,p.output.featureKey)&&n("Terminal Feature definition is unavailable")}for(let p of Object.values(i.outputs))t.nodes.has(p)||n("Local target is unavailable")}let s=new Set,l=new Set;function d(i){if(l.has(i)&&n("Local graph contains a cycle"),!s.has(i)){l.add(i);for(let p of Object.values(t.nodes.get(i).outputs))d(p);l.delete(i),s.add(i)}}return d(e.topology.entry),s.size!==t.nodes.size&&n("Local graph contains unreachable nodes"),{evaluate(i){let p={},f=i.context;f.features=t.features,f.savedGroups=t.savedGroups;let y=()=>{f.attributes=re({declarations:e.evaluation.variables,attributes:i.attributes,parameters:i.parameters,answers:{},results:p,savedGroups:t.savedGroups})};y();let g=e.topology.entry,m=0;for(;;){let v=t.nodes.get(g);if(v.type==="end"||v.type==="output"){let I=e.evaluation.terminals[g],w=I.output,S=w?.type==="feature"?t.feature(w.featureKey,f):w?.type==="variable"?ne({source:"variable",key:w.key,...w.path?{path:w.path}:{}},{declarations:e.evaluation.variables,answers:{},results:p,parameters:i.parameters,attributes:i.attributes,savedGroups:t.savedGroups}):w?.value??null;return G(e.evaluation.outputSchema,S)||n("Local output does not match its declaration"),{outcome:I.outcome,value:S}}if(m++>=e.evaluation.maxTransitions)throw new u("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(v.type==="entry")g=v.outputs.next;else{let I=t.evaluate(g,f);if(v.type==="feature"){let w=v.writes.value,S=I.value??null;G(e.evaluation.variables[w],S)||n("Local Feature value does not match its declaration"),ee(e.evaluation.variables,{writes:v.writes},{[w]:S}),p[w]=S,y()}g=I.target}}}}}import{z as Ne}from"zod";function Pe(e,t,n){let a=X.parse(e.attributes);if(["parameters","answers","results"].some(E=>Object.hasOwn(a,E)))throw new u("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let s=oe.parse(e.parameters??{}),l=Ne.record(Ne.string(),Z).parse(e.stickyBucketAssignmentDocs??{});for(let[E,h]of Object.entries(l))if(E!==`${h.attributeName}||${h.attributeValue}`||!Object.hasOwn(a,h.attributeName)||W(a[h.attributeName])!==h.attributeValue)throw new u("INVALID_REQUEST","Sticky document identity does not match this session");let d=e.saveStickyBucketAssignmentDoc,i=e.onFeatureUsage,p=e.onExperimentViewed,f=e.onError,y=new Map,g=new Set,m={},v=Promise.resolve();function I(E){let h=v.then(()=>(n(),E()));return v=h.catch(()=>{}),h}function w(E){try{f?.(E)}catch{}}function S(E){try{let h=E();h&&typeof h.catch=="function"&&h.catch(w)}catch(h){w(h)}}async function k(){for(let[E,h]of y){if(n(),d)try{await d(structuredClone(h))}catch{throw new u("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}n(),y.delete(E)}}return{evaluate(E={}){let h=E.track===!0;return I(async()=>{let L=await t();n(L);let Q=new Set(g),J={...m},Y=new Map,V=[],_e={stickyBucketAssignmentDocs:structuredClone(l),saveStickyBucketAssignmentDoc(C){Y.set(`${C.attributeName}||${C.attributeValue}`,structuredClone(C))},...h?{trackedExperiments:Q,trackedFeatureUsage:J,onExperimentViewed(C,O){let B=structuredClone(C),Me=structuredClone(O);p&&V.push(()=>p(structuredClone(B),structuredClone(Me)))},onFeatureUsage(C,O){let B=structuredClone(O);i&&V.push(()=>i(C,structuredClone(B)))}}:{}},Ue=L.program.evaluate({attributes:a,parameters:s,context:_e});n(L);for(let[C,O]of Y)l[C]=O,y.set(C,O);await k(),n(L),h&&(g=Q,m=J);for(let C of V)S(C);let D=L.configuration;return structuredClone({evaluationMode:"local",scope:D.scope,funnelId:D.funnelId,versionId:D.versionId,evaluationRevision:D.evaluationRevision,generation:D.growth.generation,...Ue})})},flush:()=>I(k),get stickyBucketAssignmentDocs(){return n(),structuredClone(l)}}}var $e=6e4;function U(e){if(typeof window<"u")throw new u("SERVER_ONLY","Local Funnel sessions run on your backend");let t=$.parse(e.scope),n=e.funnelId,a=e.load,s,l,d,i=0,p=g=>Date.now()>=g.expiresAt;async function f(){if(l)return l;let g=i;s=void 0;let m=(async()=>{let v=await a();if(g!==i)throw new u("IDENTITY_CHANGED","Local evaluator was reset");if(v&&typeof v=="object"&&"evaluationMode"in v&&v.evaluationMode==="remote")throw c(N,v),new u("EVALUATION_MODE","This Funnel requires remote decide");let I=c(de,v);if(g!==i)throw new u("IDENTITY_CHANGED","Local evaluator was reset");if(I.scope.projectId!==t.projectId||I.scope.environment!==t.environment||I.funnelId!==n)throw new u("SCOPE_MISMATCH","Local configuration scope changed");if(I.growth.scope.projectId!==t.projectId||I.growth.scope.environment!==t.environment||I.growth.expiresAt!==I.expiresAt)throw new u("INVALID_RESPONSE","GB configuration scope or expiry changed");let w=Math.min(Date.now()+$e,I.expiresAt?Date.parse(I.expiresAt):1/0);if(Date.now()>=w)throw new u("CONFIGURATION_EXPIRED","Refresh expired local rules");let S=JSON.stringify([t.projectId,t.environment,n,I.versionId,I.evaluationRevision,I.growth.generation]),k=[I.topology,I.conditions,I.evaluation,I.growth.features,I.growth.experiments,I.growth.savedGroups];if(d?.key===S&&!he(d.body,k))throw new u("INVALID_RESPONSE","Immutable local configuration identity changed");return d?.key!==S&&(d={key:S,body:k,program:De(I)}),s={key:S,configuration:I,expiresAt:w,program:d.program},s})();l=m;try{return await m}finally{l===m&&(l=void 0)}}function y(){return l??(s&&!p(s)?Promise.resolve(s):f())}return{session(g){let m=i;return Pe(g,y,v=>{if(e.assertUsable?.(),m!==i)throw new u("IDENTITY_CHANGED","Local evaluator was reset");if(v&&(p(v)||s?.key!==v.key))throw new u("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){i++,s=void 0,l=void 0,d=void 0}}}function We(e,t){let n=e.snapshot?.generation,a=U({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:t,load:()=>e.localFunnel(t),assertUsable:()=>e.assertFunnel(t)}),s=e.subscribe(()=>{let d=e.snapshot?.generation;e.fresh&&d!==n&&(n=d,a.refresh().catch(()=>{}))}),l=a.session;return Object.assign(a,{session(d){let i=l(d),p=i.evaluate;return Object.assign(i,{async evaluate(...f){return e.fresh||await e.refresh(),p(...f)}})},destroy(){s(),a.reset()}})}function Xe(e){if(typeof window<"u")throw new u("SERVER_ONLY","Secret API keys must stay on the backend");return{start:t=>Se(e,t)}}function Te(e,t,n){return ye(e,t,n,Ie)}var x=class extends u{constructor(n,a){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,a);this.decisionId=n;this.decisionRequestId=a}decisionId;decisionRequestId};async function M(e,t,n,a){let{decisionId:s,requestId:l}=e,d=e,i=250,p=0;for(;;){if(d.decisionId!==s||d.requestId!==l||d.decision&&!_(d.decision,t))throw new u("INVALID_RESPONSE","Decision request or customer changed");if(d.decision)return d.decision;if(d.status==="failed")throw new u("DECISION_FAILED","Decision execution failed",503,l);if(Date.now()>=n)throw new x(s,l);if(await new Promise(f=>setTimeout(f,Math.min(Math.max(i,p-Date.now()),n-Date.now()))),Date.now()>=n)throw new x(s,l);i=Math.min(1e3,i*2);try{d=await a(s,n)}catch(f){if(f instanceof u&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(f.code)){p=Date.now()+(f.retryAfterSeconds??0)*1e3;continue}throw f}}}function H(e){if("remoteEval"in e)throw new u("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");A(e.apiKey,"Funnel decisions are requested by your backend");let t,n,a=new Map;async function s(p,f){let y=p;y.status!=="pending"&&a.delete(y.decisionId);for(let g=0;g<32&&y.evaluation;g++){let m=y.evaluation;if(m.runId!==y.decisionId)throw new u("INVALID_RESPONSE","Local evaluation Run changed");let v=a.get(y.decisionId);if(!v&&m.type==="evaluate_segment"){let w=ve.parse(await l({operation:"segment_configuration",funnelId:e.funnelId,versionId:m.versionId},f));if(w.configuration.scope.projectId!==e.scope.projectId||w.configuration.scope.environment!==e.scope.environment||w.configuration.funnelId!==e.funnelId||w.configuration.versionId!==m.versionId||w.configuration.evaluationRevision!==m.policyRevision)throw new u("SCOPE_MISMATCH","Original decision segment configuration changed");if(a.size>=128)throw new u("COMMAND_PENDING","Reconcile outstanding decisions first");v={operation:"commit_decision_segment",decisionId:y.decisionId,requestId:q(y.decisionId,m.visit,`segment:${m.revision}`),nodeId:m.nodeId,visit:m.visit,revision:m.revision,policyRevision:m.policyRevision,generation:w.configuration.growth.generation,...we(w.configuration,w.document,m)},a.set(y.decisionId,v)}if(!v){if(m.type!=="evaluate")throw new u("INVALID_RESPONSE","Unknown decision instruction");if((!n||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision||n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())&&(n=N.parse(await l({operation:"configuration",funnelId:e.funnelId,versionId:m.versionId},f))),n.scope.projectId!==e.scope.projectId||n.scope.environment!==e.scope.environment||n.funnelId!==e.funnelId)throw new u("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(n.evaluationMode!=="local"||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision)throw new u("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(a.size>=128)throw new u("COMMAND_PENDING","Reconcile outstanding Local decisions first");v={operation:"evaluate_decision",decisionId:y.decisionId,requestId:q(y.decisionId,m.visit,"evaluation"),nodeId:m.nodeId,visit:m.visit,revision:m.revision,receiptId:m.receiptId,policyRevision:m.policyRevision,generation:n.growth.generation,result:Te(n,m.nodeId,m)},a.set(y.decisionId,v)}let I=b.parse(await l(v,f));if(I.decisionId!==p.decisionId||I.requestId!==p.requestId)throw new u("INVALID_RESPONSE","Decision identity changed during local evaluation");a.delete(y.decisionId),y=I}return y}async function l(p,f,y=!1){return F({...e,fetch:(m,v)=>{let I=new Headers(v?.headers);return I.set("Accept-Encoding","identity"),y&&I.set("Prefer","respond-async"),(e.fetch??globalThis.fetch)(m,{...v,headers:I})},timeoutMs:Math.min(e.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)}).request("funnels",p)}async function d(p,f){let y=b.parse(await l(P.parse({operation:"read_decision",decisionId:p}),f));if(y.decisionId!==p)throw new u("INVALID_RESPONSE","Decision identity changed");return s(y,f)}async function i(p,f,y=!1){let g=P.options[0].parse({...p,operation:"decide",funnelId:e.funnelId}),m;try{m=b.parse(await l(g,f,y))}catch(v){throw v instanceof u&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(v.code)?new u("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",v.status,p.requestId):v}if(m.requestId!==p.requestId||m.decision&&!_(m.decision,g.customer))throw new u("INVALID_RESPONSE","Decision request or customer changed");return{response:await s(m,f),customer:g.customer}}return{local(){return t??=U({scope:e.scope,funnelId:e.funnelId,load:()=>l({operation:"local_configuration",funnelId:e.funnelId})})},async configuration(){let p=N.parse(await l({operation:"configuration",funnelId:e.funnelId}));if(p.scope.projectId!==e.scope.projectId||p.scope.environment!==e.scope.environment||p.funnelId!==e.funnelId)throw new u("SCOPE_MISMATCH","Configuration scope changed");return p},features(p={}){return z({...p,scope:e.scope,load:async()=>te.parse(await l({operation:"feature_config",funnelId:e.funnelId}))})},read:p=>d(p),async submit(p){return(await i(p,void 0,!0)).response},async decide(p){let f=Date.now()+3e4,y=await i(p,f);return M(y.response,y.customer,f,d)},async reportUsed(p){let f=se.parse(await l(P.parse({...p,operation:"report_used"})));if(f.decisionId!==p.decisionId||f.eventId!==p.eventId)throw new u("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Ze(e){A(e.apiKey,"Native receipts are verified by your backend","Server API key required");let t=F({...e,timeoutMs:e.timeoutMs??35e3});return{async recover(n){let a=me.parse(n);if(a.orderId!==a.receiptId)throw new u("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let s=a.nativeEvidence,l={requestId:a.requestId,customerToken:a.customerToken,purchaseIntentId:a.orderId,...s===null?{intent:"read"}:s.provider==="apple"?{provider:"apple",signedTransaction:s.signedTransaction}:{provider:"google",purchaseToken:s.purchaseToken}},d=r.restoreNativePurchase.response.parse(await t.request(r.restoreNativePurchase.path,l));if(d.operation.requestId!==a.requestId||d.operation.purchaseIntentId!==a.orderId)throw new u("INVALID_RESPONSE","Native receipt request identity changed");let i=fe.parse({scope:d.scope,requestId:a.requestId,orderId:d.operation.orderId,receiptId:d.operation.orderId,orderStatus:d.operation.status,refunded:d.operation.refunded,...d.operation.completion===null?{}:{nativeCompletion:{orderId:d.operation.orderId,receiptId:d.operation.orderId,...d.operation.completion}}});if(i.requestId!==a.requestId||i.orderId!==a.orderId||i.receiptId!==a.receiptId||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new u("INVALID_RESPONSE","Current order receipt scope changed");return i}}}import{z as en}from"zod";var R=en.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function nn(e,t){let n=R.parse(e.inputTokens.total),a=R.parse(e.outputTokens.total),s=R.parse(e.inputTokens.cacheRead??0),l=R.parse(e.inputTokens.cacheWrite??0),d=R.parse(e.outputTokens.reasoning??0);if(s+l>n||d>a||e.inputTokens.noCache!==void 0&&R.parse(e.inputTokens.noCache)!==n-s-l||e.outputTokens.text!==void 0&&R.parse(e.outputTokens.text)!==a-d)throw new u("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:n-s-l,cache_read:s,cache_write:l,output:t==="output"?a:a-d,reasoning:t==="separate"?d:0,input_audio:0,output_audio:0}}function tn(e){if(typeof window<"u")throw new u("SERVER_ONLY","AI usage belongs on the trusted backend");if(!e.modelId||!["output","separate"].includes(e.reasoning))throw new u("INVALID_REQUEST","Model ID and reasoning pricing are required");async function t(a){await e.persist({context:a,modelId:e.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function n(a,s){let l={context:a,modelId:e.modelId,usage:s,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(l);let d=e.mapTokens?e.mapTokens(s):nn(s,e.reasoning),i=await e.pricing.quoteTokens({modelId:e.modelId,tokens:d});await e.persist({...l,tokens:d,quote:i,phase:"quoted"});let p=await e.pricing.trackTokens(e.client,{...a,quote:i});if(!p.receipt.accepted)throw new u("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await e.persist({...l,tokens:d,quote:i,receipt:p,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:a}){let s=await e.context(),l;try{l=await a()}catch(d){throw await t(s),d}return await n(s,l.usage),l},async wrapStream({doStream:a}){let s=await e.context(),l;try{l=await a()}catch(y){throw await t(s),y}let d=!1,i=!1,p=l.stream.getReader();async function f(){d||i||(i=!0,await t(s))}return{...l,stream:new ReadableStream({async pull(y){try{let{value:g,done:m}=await p.read();if(m){if(!d)throw await f(),new u("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");y.close();return}if(g.type==="finish"){if(d)throw new u("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");d=!0,await n(s,g.usage)}y.enqueue(g)}catch(g){try{await f()}finally{y.error(g),await p.cancel(g)}}},async cancel(y){try{await f()}finally{await p.cancel(y)}}})}}}}function rn(e){A(e.apiKey,"Funnel receipts are sent by your backend");let t=F(e);return{async signal(n){let a=j.parse({...n,operation:"signal"}),s=ae.parse(await t.request("funnels",a));if(s.runId!==n.runId||s.eventId!==n.eventId||s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment)throw new u("INVALID_RESPONSE","Receipt identity changed");return s},async readResults(n){let a=j.parse({operation:"read_results",runId:n}),s=ie.parse(await t.request("funnels",a));if(s.runId!==n||s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment)throw new u("INVALID_RESPONSE","Result identity changed");return s}}}function on(e){if("remoteEval"in e)throw new u("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");A(e.apiKey,"Campaign entry requires your backend");let t=F({...e,timeoutMs:e.timeoutMs??35e3});return{async decide(n){let a=Date.now()+(e.timeoutMs??3e4),s=K.parse({...n,funnelId:e.funnelId,operation:"campaign_decide"}),l=F({...e,timeoutMs:Math.min(e.timeoutMs??35e3,Math.max(1,a-Date.now()))}),d=b.parse(await l.request("funnels",s));if(d.scope.projectId!==e.scope.projectId||d.scope.environment!==e.scope.environment)throw new u("SCOPE_MISMATCH","Campaign scope changed");return M(d,s.customer,a,(i,p)=>H({...e,timeoutMs:Math.min(e.timeoutMs??1e4,Math.max(1,p-Date.now()))}).read(i))},async start(n){let a=K.parse({...n,funnelId:e.funnelId,operation:"campaign_start"}),s=le.parse(await t.request("funnels",a)),l=pe.parse("suppressed"in s?s:await T(e,s));if(l.scope.projectId!==e.scope.projectId||l.scope.environment!==e.scope.environment)throw new u("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in l)&&(l.run.source.id!==e.funnelId||!l.customerId||a.customer.type==="id"&&l.customerId!==a.customer.value))throw new u("INVALID_RESPONSE","Campaign Funnel or Customer changed");return l}}}export{x as FunnelDecisionTimeoutError,u as IndianaError,qe as aiPriceSnapshotSchema,Ke as aiTokenQuoteSchema,ze as createAiPricing,tn as createAiUsageMiddleware,Ve as createConfigurationSync,He as createConfiguredAiPricing,z as createFeatureClient,on as createFunnelCampaignClient,H as createFunnelDecisionClient,U as createFunnelLocalEvaluator,rn as createFunnelOrchestrationClient,Ge as createFunnelStartClient,Je as createGuestToken,Qe as createIndianaServer,je as createLocalFunnelClient,Ze as createNativeReceiptClient,Xe as createPaywallStartClient,We as createSynchronizedFunnelLocalEvaluator,Be as evaluateFunnelNode,Ye as renewFunnelRun};
package/dist/visual.d.ts CHANGED
@@ -1,5 +1,37 @@
1
+ import { z } from 'zod';
1
2
  import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
2
- import 'zod';
3
+
4
+ declare const visualDiagnosticSchema: z.ZodObject<{
5
+ environmentId: z.ZodString;
6
+ release: z.ZodNullable<z.ZodString>;
7
+ generation: z.ZodNullable<z.ZodString>;
8
+ publishedGeneration: z.ZodNullable<z.ZodString>;
9
+ checkedAt: z.ZodString;
10
+ origin: z.ZodString;
11
+ pathname: z.ZodString;
12
+ urlMatches: z.ZodBoolean;
13
+ stopped: z.ZodBoolean;
14
+ rows: z.ZodArray<z.ZodObject<{
15
+ changeId: z.ZodString;
16
+ experimentKey: z.ZodString;
17
+ variationKey: z.ZodString;
18
+ inExperiment: z.ZodBoolean;
19
+ fingerprint: z.ZodString;
20
+ status: z.ZodEnum<{
21
+ error: "error";
22
+ inactive: "inactive";
23
+ unavailable: "unavailable";
24
+ partial: "partial";
25
+ applied: "applied";
26
+ waiting: "waiting";
27
+ mismatch: "mismatch";
28
+ no_changes: "no_changes";
29
+ }>;
30
+ total: z.ZodNumber;
31
+ applied: z.ZodNumber;
32
+ }, z.core.$strict>>;
33
+ }, z.core.$strict>;
34
+ type VisualDiagnostic = z.infer<typeof visualDiagnosticSchema>;
3
35
 
4
36
  /** Optional post-build release descriptor. Keeps bundler CSS output out of a digest/rebuild cycle. */
5
37
  declare function loadAppManifestRelease(path: string, document: Document, signal: AbortSignal): Promise<string>;
@@ -18,12 +50,15 @@ type VisualExperimentsOptions = {
18
50
  log?: (message: string, details: Record<string, unknown>) => void;
19
51
  /** Exact local IAM digest. Delivery safely rebinds compatible authored changes to this release. */
20
52
  appManifestRelease?: string;
53
+ /** Explicit additional Console origins for local/Preview diagnostics. No wildcards. */
54
+ diagnosticsOrigins?: readonly string[];
21
55
  };
22
56
  declare function createVisualExperiments(options: VisualExperimentsOptions): {
23
57
  start(): Promise<void>;
24
58
  refresh(): Promise<void>;
25
59
  setAttributes(attributes: Record<string, JsonValue>): void;
26
60
  flush: () => Promise<void>;
61
+ getDiagnostics: (changeId?: string, expectedUrl?: string) => Promise<VisualDiagnostic>;
27
62
  getResults(): Map<string, Result<{
28
63
  css: string;
29
64
  js: string;