@tinkerlandai/longplay-sdk 0.10.7 → 0.10.11

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 (62) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +40 -4
  3. package/README.zh-CN.md +4 -2
  4. package/dist/{ai-usage-Btwg1nD7.d.ts → ai-usage-C-OZBxgW.d.ts} +1 -1
  5. package/dist/{api-5gAz4-Sb.d.ts → api-Bf_aRlXs.d.ts} +82 -0
  6. package/dist/chunk-33FQUT3Z.js +179 -0
  7. package/dist/chunk-4B5G3ZVV.js +4 -0
  8. package/dist/chunk-4C5XH3T3.js +1 -0
  9. package/dist/chunk-7DUOIHRD.js +6 -0
  10. package/dist/chunk-7RDYCTR4.js +1 -0
  11. package/dist/chunk-CDG7GM4C.js +1 -0
  12. package/dist/chunk-GDFBOM3V.js +1 -0
  13. package/dist/chunk-JGFAFQKK.js +1 -0
  14. package/dist/chunk-OZZMZH7X.js +1 -0
  15. package/dist/chunk-PYIHBK7E.js +1 -0
  16. package/dist/chunk-QHJAF5T2.js +1 -0
  17. package/dist/chunk-VSJOHWDL.js +17 -0
  18. package/dist/chunk-VSMITXQD.js +1 -0
  19. package/dist/chunk-ZYQPKGJM.js +1 -0
  20. package/dist/{configuration-sync-CywDxRkX.d.ts → configuration-sync-D2n_gGj6.d.ts} +1 -0
  21. package/dist/content-YQ7IJ47M.js +1 -0
  22. package/dist/{funnel-local-client-B4Z3dvNf.d.ts → funnel-local-client-DJq2K7an.d.ts} +8869 -93
  23. package/dist/{funnel-node-evaluation-P5B4fPfJ.d.ts → funnel-node-evaluation-CJSkUkbv.d.ts} +36 -0
  24. package/dist/{funnel-resource-client-BhbXsB2q.d.ts → funnel-process-client-C_UhTH8g.d.ts} +5132 -41
  25. package/dist/funnel-runtime-host-K2SXD2R2.js +1 -0
  26. package/dist/index.d.ts +106 -77
  27. package/dist/index.js +1 -1
  28. package/dist/native-shell.js +1 -1
  29. package/dist/openrouter.d.ts +2 -2
  30. package/dist/openrouter.js +1 -1
  31. package/dist/page.d.ts +1 -1
  32. package/dist/page.js +1 -1
  33. package/dist/paywall-PJEMTVSZ.js +1 -0
  34. package/dist/popup.js +1 -1
  35. package/dist/react-native.d.ts +109 -106
  36. package/dist/react-native.js +1 -1
  37. package/dist/screen-renderer-NHJ6OQTF.js +1 -0
  38. package/dist/server.d.ts +10677 -25
  39. package/dist/server.js +1 -1
  40. package/dist/{visual-dom-OIXANRP3.js → visual-dom-7IF7ITAK.js} +1 -1
  41. package/dist/visual.js +1 -1
  42. package/package.json +10 -9
  43. package/dist/chunk-22Z7JR4B.js +0 -1
  44. package/dist/chunk-3OFRQUUI.js +0 -1
  45. package/dist/chunk-5JJZSH23.js +0 -179
  46. package/dist/chunk-6LILLFH3.js +0 -1
  47. package/dist/chunk-7DXL3LHT.js +0 -1
  48. package/dist/chunk-ACF2FBUB.js +0 -1
  49. package/dist/chunk-G56XGVMS.js +0 -1
  50. package/dist/chunk-I4BZSRT4.js +0 -1
  51. package/dist/chunk-IAOOTBJV.js +0 -6
  52. package/dist/chunk-O52OWKP7.js +0 -4
  53. package/dist/chunk-SBPTOOYB.js +0 -1
  54. package/dist/chunk-SV6W2E2A.js +0 -1
  55. package/dist/chunk-XSVQHPQT.js +0 -17
  56. package/dist/chunk-Y3AGPHWF.js +0 -1
  57. package/dist/chunk-ZKSKBL4N.js +0 -1
  58. package/dist/content-F7IVCK3I.js +0 -1
  59. package/dist/funnel-runtime-host-W25OXLGE.js +0 -1
  60. package/dist/paywall-XGDRMPLP.js +0 -1
  61. package/dist/screen-renderer-NLB3FAQJ.js +0 -1
  62. /package/dist/{chunk-AK3IJ6FZ.js → chunk-OJM6ORHE.js} +0 -0
@@ -0,0 +1,6 @@
1
+ import{$ as Xt,A as ee,B as Ke,Ba as Da,C as it,D as vt,E as cr,F as Jt,G as ha,H as _n,I as ba,J as ya,K as xa,L as Pn,M as Sa,N as va,O as di,P as Wt,Q as Ia,R as Oa,S as ja,T as Aa,U as wa,V as ur,W as Qt,X as _a,Y as Pa,Z as Cn,_ as Ca,a as ui,aa as ka,b as ca,c as ua,ca as Ra,da as Ea,ea as Ma,fa as Ta,g as ie,h as pi,i as pa,j as rt,ja as kn,k as be,l as li,la as gt,m as ft,ma as Le,n as la,na as Yt,o as or,oa as fi,p as ma,pa as It,q as da,sa as gi,t as ar,u as sr,v as fa,va as pr,w as mi,wa as Et,x as ga,xa as ut,y as wn,ya as hi}from"./chunk-VSJOHWDL.js";import{z as g}from"zod";import{z as m}from"zod";var qe=m.string().min(1).max(200),$e=m.iso.datetime({offset:!0}),je=m.number().int().nonnegative().max(1e8),lr=m.string().regex(/^[A-Z]{3}$/),rl=["purchase.subscription","purchase.one_time","purchase.prepaid","purchase.trial","purchase.seats","purchase.tiered","tax.automatic","discount.percent.once","discount.percent.repeating","discount.percent.forever","discount.amount.once","discount.amount.repeating","discount.amount.forever","subscription.cancel.immediate","subscription.cancel.renewal","subscription.resume","subscription.plan.immediate","subscription.plan.renewal","subscription.seats","subscription.quantity","subscription.billing_cycle","subscription.proration","refund.full","refund.partial","refund.revoke"],za=m.enum(rl),Ba=m.strictObject({priceId:m.uuid(),productVersionId:m.uuid(),productId:qe,quantity:m.number().int().min(1).max(1e6),unitAmountMinor:je,totalMinor:je,interval:m.enum(["week","month","year","one_off"]),intervalCount:m.number().int().min(1).max(52),kind:m.enum(["fixed","prepaid","seat"]),tiers:m.strictObject({mode:m.enum(["graduated","volume"]),tiers:m.array(m.strictObject({upTo:m.number().int().positive().nullable(),unitAmountMinor:je,flatAmountMinor:je.optional()})).min(2).max(12)}).nullable()}),il=m.strictObject({grantId:m.uuid(),couponId:m.uuid(),amountMinor:je,terms:m.discriminatedUnion("type",[m.strictObject({type:m.literal("percent"),percentOff:m.number().gt(0).max(100)}),m.strictObject({type:m.literal("amount"),amountOffMinor:je,currency:lr})]),duration:m.discriminatedUnion("type",[m.strictObject({type:m.literal("once")}),m.strictObject({type:m.literal("forever")}),m.strictObject({type:m.literal("repeating"),months:m.number().int().min(1).max(36)})])}),Si={provider:m.literal("merchant"),executor:m.literal("merchant"),operationId:m.uuid(),customerId:m.uuid(),configurationRevision:m.number().int().nonnegative(),connectionRevision:m.number().int().nonnegative(),currency:lr,expiresAt:$e},mr=m.strictObject({...Si,type:m.literal("purchase"),mode:m.enum(["payment","subscription"]),lineItems:m.array(Ba).min(1).max(100),catalogAmountMinor:je,discount:il.nullable(),trialPeriodDays:m.number().int().min(1).max(730).nullable(),automaticTax:m.boolean()}).refine(e=>e.lineItems.reduce((t,n)=>t+n.totalMinor,0)===e.catalogAmountMinor&&(!e.discount||e.discount.amountMinor<=e.catalogAmountMinor)&&new Set(e.lineItems.map(t=>t.priceId)).size===e.lineItems.length,"Purchase lines must retain the original total and unique Price identities"),dr=m.strictObject({...Si,type:m.literal("subscription_change"),subscriptionId:m.uuid(),merchantSubscriptionId:qe,membershipId:m.uuid(),subscriptionAction:m.enum(["update","cancel","schedule","release"]),supersedesOperationId:m.uuid().nullable(),change:m.discriminatedUnion("type",[m.strictObject({type:m.literal("cancel")}),m.strictObject({type:m.literal("uncancel")}),m.strictObject({type:m.literal("plan"),productVersionId:m.uuid()}),m.strictObject({type:m.literal("seats"),licenseKey:qe,quantity:m.number().int().nonnegative().max(1e6)}),m.strictObject({type:m.literal("quantity"),internal_feature_id:m.uuid(),quantity:m.number().int().nonnegative().max(1e6)}),m.strictObject({type:m.literal("billing_cycle"),billingCycleAnchor:m.union([m.literal("now"),m.number().int().positive()])})]),timing:m.enum(["immediate","renewal"]),effectiveAt:$e,creditMinor:je,debitMinor:je,totalMinor:je,discountMinor:je,taxMinor:je,proration:m.enum(["none","create_prorations","always_invoice"]),lineItems:m.array(Ba.extend({quantity:m.number().int().nonnegative().max(1e6)})).max(100),removePriceIds:m.array(m.uuid()).max(100)}),fr=m.strictObject({...Si,type:m.literal("refund"),invoiceId:m.uuid(),merchantInvoiceId:qe,amountMinor:je.refine(e=>e>0),mode:m.enum(["full","partial"]),entitlementAction:m.enum(["retain","revoke"]),cancelSubscriptions:m.array(qe).max(100)}),qa=m.discriminatedUnion("type",[mr,dr,fr]);function Cg(e){let t=new Set;if(e.type==="purchase")t.add(e.mode==="subscription"?"purchase.subscription":"purchase.one_time"),e.lineItems.some(n=>n.kind==="prepaid")&&t.add("purchase.prepaid"),e.lineItems.some(n=>n.kind==="seat")&&t.add("purchase.seats"),e.lineItems.some(n=>n.tiers!==null)&&t.add("purchase.tiered"),e.trialPeriodDays!==null&&t.add("purchase.trial"),e.automaticTax&&t.add("tax.automatic"),e.discount&&t.add(`discount.${e.discount.terms.type}.${e.discount.duration.type}`);else if(e.type==="refund")t.add(`refund.${e.mode}`),e.entitlementAction==="revoke"&&t.add("refund.revoke");else{let n=e.change.type;n==="cancel"?t.add(`subscription.cancel.${e.timing}`):n==="uncancel"?t.add("subscription.resume"):n==="plan"?t.add(`subscription.plan.${e.timing}`):t.add(`subscription.${n}`),e.proration!=="none"&&t.add("subscription.proration")}return[...t].sort()}function kg(e){return e.type==="purchase"?e.mode==="subscription"?["purchase.completed","purchase.closed","subscription.observed","invoice.paid"]:["purchase.completed","purchase.closed"]:e.type==="subscription_change"?["subscription.change.completed","subscription.observed",...e.change.type==="cancel"||e.change.type==="uncancel"?[]:["invoice.paid"]]:["refund.updated",...e.entitlementAction==="revoke"&&e.cancelSubscriptions.length?["subscription.observed"]:[]]}var Rn=m.strictObject({phase:m.enum(["execution","payment","fulfillment","recording"]),code:ui,reason:ua.optional(),recovery:ca,retryable:m.boolean()}).refine(e=>e.reason!=="RESULT_UNKNOWN"||!e.retryable&&e.recovery==="recover_operation","Unknown financial effects require recovery of the original operation"),bi={operationId:m.uuid(),customerId:m.uuid(),merchantExecutionId:qe,fulfillmentStatus:m.enum(["not_started","pending","applied","failed","not_applicable"]),recordingStatus:m.enum(["not_ready","pending","accepted","failed"]),updatedAt:$e,problem:Rn.nullable(),pollAfterMs:m.number().int().min(1e3).max(6e4).nullable()},Mt=m.discriminatedUnion("type",[m.strictObject({...bi,type:m.literal("purchase"),merchantOrderId:qe.nullable(),paymentStatus:m.enum(["not_started","pending","succeeded","not_required","failed","expired","unknown"]),checkoutUrl:m.url().refine(e=>new URL(e).protocol==="https:").nullable(),checkoutExpiresAt:$e.nullable()}).refine(e=>!e.checkoutUrl||["not_started","pending"].includes(e.paymentStatus)&&e.checkoutExpiresAt!==null,"Only an unfinished original purchase may expose its checkout"),m.strictObject({...bi,type:m.literal("subscription_change"),status:m.enum(["pending","scheduled","applied","failed","unknown"]),merchantSubscriptionId:qe,scheduledFor:$e.nullable()}).refine(e=>e.status==="scheduled"==(e.scheduledFor!==null),"A scheduled change retains its future effective time"),m.strictObject({...bi,type:m.literal("refund"),status:m.enum(["pending","succeeded","failed","unknown"]),merchantRefundId:qe.nullable()}).refine(e=>e.status!=="succeeded"||e.merchantRefundId!==null,"A successful refund retains its original merchant identity")]),Fa=m.discriminatedUnion("lookup",[m.strictObject({lookup:m.literal("found"),operationId:m.uuid(),customerId:m.uuid(),execution:Mt,readAt:$e}),m.strictObject({lookup:m.literal("not_received"),operationId:m.uuid(),customerId:m.uuid(),execution:m.null(),readAt:$e})]).refine(e=>!e.execution||e.execution.operationId===e.operationId&&e.execution.customerId===e.customerId,"Lookup must retain the original Customer and operation"),yi=m.strictObject({merchantSubscriptionId:qe,revision:m.number().int().positive(),status:m.enum(["incomplete","trialing","active","past_due","canceled","unpaid","paused","incomplete_expired"]),periodStartsAt:$e,periodEndsAt:$e,cancelAtPeriodEnd:m.boolean(),hasDiscounts:m.boolean(),items:m.array(m.strictObject({merchantItemId:qe,priceId:m.uuid(),quantity:m.number().int().positive().max(1e6)})).min(1).max(100)}).refine(e=>Date.parse(e.periodEndsAt)>Date.parse(e.periodStartsAt)&&new Set(e.items.map(t=>t.priceId)).size===e.items.length,"Subscription periods and Price identities must be unambiguous"),xi=m.strictObject({merchantInvoiceId:qe,currency:lr,subtotalMinor:je,discountMinor:je,taxMinor:je,totalMinor:je,paidMinor:je,periodStartsAt:$e.nullable(),periodEndsAt:$e.nullable(),lines:m.array(m.strictObject({merchantLineId:qe,priceId:m.uuid(),quantity:m.number().int().nonnegative().max(1e6),subtotalMinor:m.number().int().min(-1e8).max(1e8),discountMinor:je,taxMinor:je,totalMinor:m.number().int().min(-1e8).max(2e8),periodStartsAt:$e.nullable(),periodEndsAt:$e.nullable()}).refine(e=>e.subtotalMinor-e.discountMinor+e.taxMinor===e.totalMinor&&(e.subtotalMinor<0?e.discountMinor===0&&e.taxMinor===0:e.discountMinor<=e.subtotalMinor),"Invoice line amounts must retain the complete debit or credit")).min(1).max(100)}).refine(e=>e.subtotalMinor-e.discountMinor+e.taxMinor===e.totalMinor&&e.discountMinor<=e.subtotalMinor&&e.paidMinor===e.totalMinor&&new Set(e.lines.map(t=>t.merchantLineId)).size===e.lines.length&&e.lines.reduce((t,n)=>t+n.subtotalMinor,0)===e.subtotalMinor&&e.lines.reduce((t,n)=>t+n.discountMinor,0)===e.discountMinor&&e.lines.reduce((t,n)=>t+n.taxMinor,0)===e.taxMinor&&e.lines.reduce((t,n)=>t+n.totalMinor,0)===e.totalMinor,"A paid Invoice retains the complete financial amounts"),en={provider:m.literal("merchant"),eventId:m.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),customerId:m.uuid(),occurredAt:$e},Na=m.enum(["purchase.completed","purchase.closed","subscription.observed","subscription.change.completed","invoice.paid","refund.updated"]),Va=m.discriminatedUnion("type",[m.strictObject({...en,type:m.literal("purchase.completed"),operationId:m.uuid(),merchantOrderId:qe,paymentStatus:m.enum(["paid","trialing","no_payment_required"]),invoice:xi.nullable(),subscription:yi.nullable()}).refine(e=>e.paymentStatus!=="paid"||e.invoice!==null,"A paid purchase includes its Invoice"),m.strictObject({...en,type:m.literal("purchase.closed"),operationId:m.uuid(),status:m.enum(["failed","expired","canceled"])}),m.strictObject({...en,type:m.literal("subscription.observed"),operationId:m.uuid().nullable(),subscription:yi}),m.strictObject({...en,type:m.literal("subscription.change.completed"),operationId:m.uuid(),status:m.enum(["scheduled","applied"]),scheduledFor:$e.nullable(),subscription:yi,invoice:xi.nullable()}).refine(e=>e.status==="scheduled"==(e.scheduledFor!==null),"Scheduled and applied changes are distinct facts"),m.strictObject({...en,type:m.literal("invoice.paid"),merchantSubscriptionId:qe,invoice:xi}),m.strictObject({...en,type:m.literal("refund.updated"),operationId:m.uuid(),merchantRefundId:qe,status:m.enum(["pending","succeeded","failed"]),amountMinor:je.refine(e=>e>0),currency:lr})]);import{z as Tt}from"zod";var pt=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,tn=Tt.object({customerId:Tt.uuid(),sessionId:Tt.uuid(),accessToken:Tt.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:Tt.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:Tt.iso.datetime(),refreshExpiresAt:Tt.iso.datetime()});var nn=3,$a="/integrations/indiana",Bg="X-Indiana-Merchant-Bridge-Version",ol=["session","catalog","customer_commerce","presentation","presentation_events","purchases","operation_status","billing_records","subscription_changes","refunds"],al=g.enum(ol),qg={session:{command:"session.create",authority:"merchant_user"},catalog:{command:"catalog.read",authority:"merchant_catalog_reader"},customer_commerce:{command:"customer.commerce.read",authority:"merchant_user"},presentation:{command:"presentation.resolve",authority:"merchant_user"},presentation_events:{command:"presentation.report",authority:"merchant_user"},purchases:{command:"purchase.execute",authority:"merchant_user"},operation_status:{command:"operation.read",authority:"merchant_user"},billing_records:{command:null,authority:"indiana_server_key"},subscription_changes:{command:"subscription.change",authority:"merchant_user"},refunds:{command:"refund.execute",authority:"merchant_refund_authority"}},Ga=g.enum(["bridge.ping","bridge.describe","session.create","catalog.read","customer.commerce.read","presentation.resolve","presentation.report","purchase.execute","operation.read","subscription.change","refund.execute"]),Ka=g.string().regex(/^[A-Za-z0-9_-]{1,64}$/),sl=g.string().regex(/^[A-Za-z0-9_-]{43}$/).refine(e=>"AEIMQUYcgkosw048".includes(e.at(-1)),"Use canonical base64url for a 32-byte key"),Ii=g.strictObject({keyId:Ka,signingSecret:sl}),cl=g.string().max(300).superRefine((e,t)=>{try{let n=new URL(e);if(n.protocol!=="https:"||n.username||n.password||n.search||n.hash||n.pathname!=="/"||n.port&&n.port!=="443"||!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,63}$/.test(n.hostname)||/(?:^|\.)(?:localhost|local|internal)$/.test(n.hostname))throw new Error("invalid origin")}catch{t.addIssue({code:"custom",message:"Use an exact public HTTPS origin"})}}).transform(e=>new URL(e).origin),La=g.array(al).max(10).refine(e=>new Set(e).size===e.length,"Capabilities must be unique"),Za=g.strictObject({bridgeVersion:g.literal(nn),projectId:g.uuid(),environmentId:g.uuid(),environment:g.enum(["sandbox","live"]),capabilities:La,catalog:g.enum(["endpoint","static","none"]),billingEvents:g.array(Na).max(6),profiles:g.array(za).max(32).refine(e=>new Set(e).size===e.length,"Profiles must be unique")}).superRefine((e,t)=>{let n=r=>e.capabilities.includes(r);n("catalog")!==(e.catalog!=="none")&&t.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(n("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&t.addIssue({code:"custom",path:["billingEvents"],message:"Declare the unique supported billing events"})}),Ha=g.strictObject({origin:cl,requiredCapabilities:La}),ul=g.strictObject({revision:g.number().int().nonnegative(),checkedAt:g.iso.datetime(),outcome:g.enum(["valid","unreachable","invalid","scope_mismatch","authentication_failed","credentials_missing"]),diagnostics:g.strictObject({ping:g.enum(["passed","failed","not_checked"]),authentication:g.enum(["passed","failed","not_checked"]),catalog:g.enum(["passed","failed","not_checked","static","unsupported"])}),manifest:Za.nullable()}).superRefine((e,t)=>{e.outcome==="valid"!=(e.manifest!==null)&&t.addIssue({code:"custom",path:["manifest"],message:"Only a valid declaration carries a manifest"})}),Fg=g.strictObject({projectId:g.uuid(),environmentId:g.uuid(),environment:g.enum(["sandbox","live"]),execution:g.enum(["indiana","record_only"]),accountId:g.string().nullable(),revision:g.number().int().nonnegative(),authentication:g.strictObject({keyId:Ka}).nullable(),secretStoreConfigured:g.boolean().optional(),connection:Ha.nullable(),check:ul.nullable()});var Ua=g.strictObject({projectId:g.uuid(),environmentId:g.uuid()}),Ng=g.discriminatedUnion("action",[Ua.extend({action:g.literal("save"),revision:g.number().int().nonnegative(),connection:Ha,authentication:Ii.optional()}),Ua.extend({action:g.literal("check"),revision:g.number().int().nonnegative()})]),hr=g.strictObject({projectId:g.uuid(),environmentId:g.uuid(),environment:g.enum(["sandbox","live"])});function Vg(e){return g.strictObject({bridgeVersion:g.literal(nn),requestId:g.uuid(),command:Ga,scope:hr,data:e})}var pl=g.strictObject({nativeUserId:g.string().min(1).max(128),session:tn.strict()}),ll=g.strictObject({nativeUserId:g.string().min(1).max(128),presentation:g.strictObject({customerId:g.uuid(),decisionId:g.uuid(),offeringVersionId:g.uuid(),paywallVersionId:g.uuid(),variant:g.string().min(1).max(128)}).nullable()}),ml=g.strictObject({decisionId:g.uuid(),eventId:g.uuid()}),gr=g.strictObject({operationId:g.uuid(),customerId:g.uuid()}),br=g.strictObject({scope:hr,operationId:g.uuid(),customerId:g.uuid(),confirmedAt:g.iso.datetime({offset:!0}).nullable(),initialExecutionAllowed:g.boolean(),instruction:qa}).refine(e=>e.operationId===e.instruction.operationId&&e.customerId===e.instruction.customerId,"Authority must refer to the original Customer and operation"),vi=Mt,ht=g.string().min(1).max(120),dl=g.string().regex(/^-?[0-9]+(?:\.[0-9]{1,6})?$/),fl=g.strictObject({revision:ht,updatedAt:g.iso.datetime(),provider:g.literal("merchant"),items:g.array(g.strictObject({merchantProductId:ht,productVersionId:g.uuid(),name:g.string().min(1).max(255),kind:g.enum(["subscription","credit_pack"]),merchantPriceId:ht,currency:g.string().regex(/^[a-z]{3}$/),amountMinor:g.number().int().nonnegative().max(1e8),interval:g.enum(["one_time","month","year"]),intervalCount:g.literal(1),includedCredits:g.string().regex(/^[0-9]{1,18}(?:\.[0-9]{1,6})?$/),creditReset:g.enum(["none","month"]),creditPolicyId:ht,available:g.boolean()}).superRefine((e,t)=>{(e.kind==="credit_pack"&&(e.interval!=="one_time"||e.creditReset!=="none")||e.kind==="subscription"&&e.interval==="one_time"||e.available&&e.amountMinor===0)&&t.addIssue({code:"custom",message:"Unsupported version 1 catalog terms"})})).max(500)}),gl=g.strictObject({customerId:g.uuid(),revision:g.string().min(1).max(128),observedAt:g.iso.datetime(),subscriptions:g.array(g.strictObject({merchantSubscriptionId:ht,merchantProductId:ht,productVersionId:g.uuid().nullable(),status:g.enum(["active","trialing","past_due","cancelled","expired"]),currentPeriodStartsAt:g.iso.datetime().nullable(),currentPeriodEndsAt:g.iso.datetime().nullable(),cancelAtPeriodEnd:g.boolean(),scheduledChange:g.strictObject({effectiveAt:g.iso.datetime(),merchantProductId:ht}).nullable()})).max(100),purchaseHistory:g.strictObject({complete:g.boolean(),hasPaidPurchase:g.boolean(),lastPaidAt:g.iso.datetime().nullable()}),balances:g.array(g.strictObject({bucketId:ht,key:ht,available:dl,expiresAt:g.iso.datetime().nullable(),nextResetAt:g.iso.datetime().nullable()})).max(100)}),Ug=g.strictObject({bridgeVersion:g.literal(nn),requestId:g.uuid(),command:g.string().min(1).max(64),scope:hr,error:g.strictObject({code:g.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:g.string().min(1).max(500),retryable:g.boolean(),recovery:g.string().min(1).max(80)})}),En=g.strictObject({}),hl={"bridge.ping":g.strictObject({challenge:g.uuid()}),"bridge.describe":En,"session.create":En,"catalog.read":En,"customer.commerce.read":En,"presentation.resolve":En,"presentation.report":ml,"purchase.execute":gr,"operation.read":gr,"subscription.change":gr,"refund.execute":gr},$g={"bridge.ping":g.strictObject({challenge:g.uuid()}),"bridge.describe":Za,"session.create":pl,"catalog.read":fl,"customer.commerce.read":gl,"presentation.resolve":ll,"presentation.report":g.strictObject({queued:g.literal(!0)}),"purchase.execute":vi,"operation.read":Fa,"subscription.change":vi,"refund.execute":vi},Gg=g.strictObject({bridgeVersion:g.literal(nn),requestId:g.uuid(),scope:hr,command:Ga,data:g.unknown()}).superRefine((e,t)=>{hl[e.command].safeParse(e.data).success||t.addIssue({code:"custom",path:["data"],message:"Invalid command data"})});var Ja="X-Indiana-Bridge-Signature",Wa="X-Indiana-Bridge-Key-Id";function bl(e){return new TextEncoder().encode(e)}function Qa(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),t=>t.charCodeAt(0))}function Xa(e,t,n){return bl(`indiana-merchant-bridge:${nn}
2
+ ${t}
3
+ POST
4
+ ${$a}
5
+ ${n}
6
+ ${e}`)}async function Ya(e){let t=Ii.parse(e);return crypto.subtle.importKey("raw",Qa(t.signingSecret),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}async function Zg(e,t,n,r=Date.now()){let o=String(Math.floor(r/1e3)),a=new Uint8Array(await crypto.subtle.sign("HMAC",await Ya(t),Xa(e,n,o))),l=btoa(String.fromCharCode(...a)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"");return{[Wa]:t.keyId,[Ja]:`t=${o},v1=${l}`}}async function Hg(e,t,n,r,o=Date.now()){try{if(t.get(Wa)!==n.keyId)return!1;let a=/^t=([0-9]{1,12}),v1=([A-Za-z0-9_-]{43})$/.exec(t.get(Ja)??"");return!a||Math.abs(o/1e3-Number(a[1]))>300?!1:await crypto.subtle.verify("HMAC",await Ya(n),Qa(a[2]),Xa(e,r,a[1]))}catch{return!1}}var es={"zh-Hans":{merchandise:"\u51CF {discount}\uFF08\u5355\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u51CF {discount}",repeating:"\u524D {months} \u4E2A\u6708\u6BCF\u6708\u51CF {discount}",forever:"\u6BCF\u671F\u51CF {discount}"},"zh-Hant":{merchandise:"\u6E1B {discount}\uFF08\u55AE\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u6E1B {discount}",repeating:"\u524D {months} \u500B\u6708\u6BCF\u6708\u6E1B {discount}",forever:"\u6BCF\u671F\u6E1B {discount}"},en:{merchandise:"{discount} off \xB7 one use",once:"{discount} off your first payment",repeating:"{discount} off each month for the first {months} months",repeatingOne:"{discount} off the first month",forever:"{discount} off every payment"},ja:{merchandise:"{discount} \u5272\u5F15\uFF081\u56DE\u306E\u307F\uFF09",once:"\u521D\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15",repeating:"\u6700\u521D\u306E {months} \u304B\u6708\u9593\u3001\u6BCE\u6708 {discount} \u5272\u5F15",forever:"\u6BCE\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15"},ko:{merchandise:"{discount} \uD560\uC778 \xB7 1\uD68C \uC0AC\uC6A9",once:"\uCCAB \uACB0\uC81C {discount} \uD560\uC778",repeating:"\uCCAB {months}\uAC1C\uC6D4 \uB3D9\uC548 \uB9E4\uC6D4 {discount} \uD560\uC778",forever:"\uB9E4 \uACB0\uC81C {discount} \uD560\uC778"},es:{merchandise:"{discount} de descuento \xB7 un uso",once:"{discount} de descuento en el primer pago",repeating:"{discount} de descuento cada mes durante los primeros {months} meses",forever:"{discount} de descuento en cada pago",repeatingOne:"{discount} de descuento durante el primer mes"},fr:{merchandise:"{discount} de r\xE9duction \xB7 une utilisation",once:"{discount} de r\xE9duction sur le premier paiement",repeating:"{discount} de r\xE9duction par mois pendant les {months} premiers mois",forever:"{discount} de r\xE9duction sur chaque paiement",repeatingOne:"{discount} de r\xE9duction pendant le premier mois"},de:{merchandise:"{discount} Rabatt \xB7 einmalig",once:"{discount} Rabatt auf die erste Zahlung",repeating:"{discount} Rabatt pro Monat f\xFCr die ersten {months} Monate",forever:"{discount} Rabatt auf jede Zahlung",repeatingOne:"{discount} Rabatt im ersten Monat"},pt:{merchandise:"{discount} de desconto \xB7 um uso",once:"{discount} de desconto no primeiro pagamento",repeating:"{discount} de desconto por m\xEAs nos primeiros {months} meses",forever:"{discount} de desconto em cada pagamento",repeatingOne:"{discount} de desconto no primeiro m\xEAs"},it:{merchandise:"{discount} di sconto \xB7 un utilizzo",once:"{discount} di sconto sul primo pagamento",repeating:"{discount} di sconto al mese per i primi {months} mesi",forever:"{discount} di sconto su ogni pagamento",repeatingOne:"{discount} di sconto per il primo mese"},ru:{merchandise:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \xB7 \u043E\u0434\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435",once:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436",repeating:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",repeatingOne:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u0432 \u043F\u0435\u0440\u0432\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",forever:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043A\u0430\u0436\u0434\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436"},vi:{merchandise:"Gi\u1EA3m {discount} \xB7 d\xF9ng m\u1ED9t l\u1EA7n",once:"Gi\u1EA3m {discount} cho l\u1EA7n thanh to\xE1n \u0111\u1EA7u ti\xEAn",repeating:"Gi\u1EA3m {discount} m\u1ED7i th\xE1ng trong {months} th\xE1ng \u0111\u1EA7u",forever:"Gi\u1EA3m {discount} cho m\u1ED7i l\u1EA7n thanh to\xE1n"},th:{merchandise:"\u0E25\u0E14 {discount} \xB7 \u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E04\u0E23\u0E31\u0E49\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27",once:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01",repeating:"\u0E25\u0E14 {discount} \u0E15\u0E48\u0E2D\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",forever:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E17\u0E38\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07"},id:{merchandise:"Diskon {discount} \xB7 sekali pakai",once:"Diskon {discount} untuk pembayaran pertama",repeating:"Diskon {discount} setiap bulan selama {months} bulan pertama",forever:"Diskon {discount} untuk setiap pembayaran"},ar:{merchandise:"\u062E\u0635\u0645 {discount} \xB7 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0648\u0627\u062D\u062F",once:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u062F\u0641\u0639\u0629 \u0627\u0644\u0623\u0648\u0644\u0649",repeating:"\u062E\u0635\u0645 {discount} \u0634\u0647\u0631\u064A\u064B\u0627 \u0644\u0645\u062F\u0629 {period}",forever:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0643\u0644 \u062F\u0641\u0639\u0629"}};function Oi(e){let t=ha(e)??"en",n=t.split("-"),r=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(a=>["TW","HK","MO"].includes(a))?"zh-Hant":"zh-Hans":n[0]??"en",o=es[r];return o?{locale:t,copy:o}:{locale:"en",copy:es.en}}function yl(e,t,n="zh-CN"){let r=pi(t);return pa(e,t,Oi(n).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:e%10**r===0?0:r,maximumFractionDigits:r})}function xl(e,t="zh-CN"){let n=Oi(t).locale;return e.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:2}).format(e.percentOff/100):yl(e.amountOffCents,e.currency,n)}var ts={zh:"\u524D {months} \u4E2A\u6708\u5185\u5F00\u51FA\u7684\u8D26\u5355\u51CF {discount}","zh-Hant":"\u524D {months} \u500B\u6708\u5167\u958B\u51FA\u7684\u5E33\u55AE\u6E1B {discount}",en:"{discount} off invoices issued within the first {months} months",ja:"\u6700\u521D\u306E {months} \u304B\u6708\u4EE5\u5185\u306E\u8ACB\u6C42\u304C {discount} \u5272\u5F15",ko:"\uCCAB {months}\uAC1C\uC6D4 \uB0B4 \uCCAD\uAD6C\uC11C {discount} \uD560\uC778",es:"{discount} de descuento en facturas emitidas durante los primeros {months} meses",fr:"{discount} de r\xE9duction sur les factures \xE9mises pendant les {months} premiers mois",de:"{discount} Rabatt auf Rechnungen innerhalb der ersten {months} Monate",pt:"{discount} de desconto nas faturas emitidas nos primeiros {months} meses",it:"{discount} di sconto sulle fatture emesse nei primi {months} mesi",ru:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u0441\u0447\u0435\u0442\u0430 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",vi:"Gi\u1EA3m {discount} cho h\xF3a \u0111\u01A1n trong {months} th\xE1ng \u0111\u1EA7u",th:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E43\u0E1A\u0E41\u0E08\u0E49\u0E07\u0E2B\u0E19\u0E35\u0E49\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",id:"Diskon {discount} untuk tagihan dalam {months} bulan pertama",ar:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u0641\u0648\u0627\u062A\u064A\u0631 \u0627\u0644\u0635\u0627\u062F\u0631\u0629 \u062E\u0644\u0627\u0644 \u0623\u0648\u0644 {period}"};function Xg(e,t="zh-CN",n="month"){let r=Oi(t),o=xl(e.discount,r.locale);if(e.appliesTo?.type==="merchandise")return r.copy.merchandise.replace("{discount}",o);let a=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale).format(e.duration.months):"",l=r.locale.split("-")[0]??"en",p=l==="zh"&&/(?:Hant|TW|HK|MO)/.test(r.locale)?"zh-Hant":l,d=e.duration.type==="repeating"&&n!=="month"?ts[p]??ts.en:e.duration.type==="repeating"&&e.duration.months===1?r.copy.repeatingOne??r.copy.repeating:r.copy[e.duration.type],v=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(e.duration.months):"";return d.replace("{discount}",o).replace("{months}",a).replace("{period}",v)}import{z as W}from"zod";import{z as De}from"zod";var Ae=De.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_.:-]*$/).refine(e=>e.split(".").every(t=>t.length>0&&!["__proto__","constructor","prototype"].includes(t)),"Reserved or empty variable path"),ji=De.strictObject({type:De.enum(["string","number","boolean","strings","json","offering_version","reward","paywall_version"]),nullable:De.boolean(),enum:De.array(De.string().max(255)).min(1).max(100).optional()}),rn=ji.extend({type:De.enum([...ji.shape.type.options,"array"]),items:ji.optional()}).superRefine((e,t)=>{(e.type==="array"!=!!e.items||e.enum&&e.type!=="string"||e.items?.enum&&e.items.type!=="string")&&t.addIssue({code:"custom",message:"Array requires items; only strings support enum"})}),on=rn.safeExtend({source:De.discriminatedUnion("type",[De.strictObject({type:De.literal("input")}),De.strictObject({type:De.literal("node")}),De.strictObject({type:De.enum(["parameter","attribute"]),key:Ae})])}),Sl=De.record(Ae,on),yr=De.record(Ae,Ae).refine(e=>Object.keys(e).length<=20);function Xe(e,t){return e?t===null?e.nullable:e.enum&&(typeof t!="string"||!e.enum.includes(t))?!1:e.type==="array"?Array.isArray(t)&&t.length<=100&&!!e.items&&t.every(n=>Xe(e.items,n)):["offering_version","reward","paywall_version"].includes(e.type)?typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===2&&t.type===e.type&&De.uuid().safeParse(t.id).success:e.type==="json"||(e.type==="strings"?Array.isArray(t)&&t.every(n=>typeof n=="string"):typeof t===e.type):!1}function Ai(e,t){return e.nullable&&!t.nullable?!1:t.type==="json"?!0:e.type!==t.type||t.enum&&(!e.enum||e.enum.some(n=>!t.enum.includes(n)))?!1:e.type!=="array"||!!e.items&&!!t.items&&Ai(e.items,t.items)}function Mn(e,t){let n={};for(let[r,o]of Object.entries(e)){let a=o.source,l=a.type==="input"?t.answers:a.type==="node"?t.results??{}:a.type==="parameter"?t.parameters:t.attributes,p=a.type==="parameter"||a.type==="attribute"?a.key:r,d=Object.hasOwn(l,p),v=l[p];if(a.type==="attribute"&&p.includes(".")&&(!d||p.startsWith("merchandise."))){v=l,d=!0;for(let h of p.split(".")){if(!v||typeof v!="object"||!Object.hasOwn(v,h)||Array.isArray(v)&&(!/^(0|[1-9]\d*)$/.test(h)||Number(h)>=v.length)){d=!1;break}v=v[h]}}if(!(!d||v===void 0)){if(!Xe(o,v))throw new Error(`Invalid variable value: ${r}`);n[r]=v}}return n}function Dt(e,t){let n={};for(let[r,o]of Object.entries(e.writes??{})){if(!Object.hasOwn(t,r))throw new Error(`Node output is missing: ${r}`);if(Object.hasOwn(n,o))throw new Error("Node outputs cannot overwrite one another");n[o]=t[r]}return n}function wi(e,t,n){let r=new Set(Object.values(t.writes??{}));for(let[o,a]of Object.entries(n))if(!r.has(o)||e[o]?.source.type!=="node"||!Xe(e[o],a))throw new Error(`Invalid node variable write: ${o}`);if(r.size!==Object.keys(n).length)throw new Error("Node output is incomplete")}import{z as zt}from"zod";var ot=zt.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(e=>e.split(".").every(t=>!["__proto__","constructor","prototype"].includes(t)),"Reserved value path"),lt=zt.discriminatedUnion("source",[zt.strictObject({source:zt.literal("literal"),value:ee}),zt.strictObject({source:zt.literal("variable"),key:zt.string().min(1).max(255),path:ot.optional()})]);function ns(e,t){if(!t)return e;for(let n of ot.parse(t).split(".")){if(Array.isArray(e)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=e.length)return;e=e[Number(n)];continue}if(e===null||typeof e!="object"||!Object.hasOwn(e,n))return;e=Reflect.get(e,n)}return e}function _i(e,t){if(e.source==="literal")return structuredClone(e.value);let n=Mn(t.declarations,t);if(!Object.hasOwn(n,e.key))throw new Error("Capability input is missing");return structuredClone(ee.parse(ns(n[e.key],e.path)))}function Pi(e,t){let n=[...t].sort((o,a)=>a.length-o.length).find(o=>e===o||e.startsWith(o+"."));if(!n)return null;let r=e===n?void 0:e.slice(n.length+1);return r&&!ot.safeParse(r).success?null:{key:n,path:r}}function Ci(e){let t=Object.values(e.strings.locales).flatMap(n=>Object.values(n));return gt(e,n=>{n.type==="custom_html"&&t.push(...Object.values(n.html))}),[...new Set(t.flatMap(ka))]}function xr(e){return Ci(e).filter(t=>t.startsWith("variables.")).map(t=>t.slice(10))}function Ze(e){let t=JSON.stringify(e);if(t===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(t).length,r=!1;for(let o=0;o<t.length;o++){let a=t.charAt(o);if(r)a==="\\"?o++:a==='"'&&(r=!1);else if(a==='"')r=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let l=o;for(;o+1<t.length&&/[0-9.eE+-]/.test(t.charAt(o+1));)o++;let p=t.slice(l,o+1);if(!/[eE]/.test(p))continue;let[d="",v]=p.split(/[eE]/),h=d.replace(/^-/,""),T=h.replace(".","").length,$=(h.includes(".")?h.indexOf("."):T)+Number(v),C=$<=0?2-$+T:$>=T?$:T+1;n+=C+(d.startsWith("-")?1:0)-p.length}}return n}var Ot=W.enum(["page","popup","banner"]),vl=3e5,rs=W.strictObject({type:W.enum(["string","number","boolean","strings","json"]),nullable:W.boolean()}),Il=W.strictObject({inputs:W.record(kn,rs.extend({required:W.boolean()})).refine(e=>Object.keys(e).length<=40,"Too many content inputs"),outputs:W.record(kn,rs).refine(e=>Object.keys(e).length<=40,"Too many content outputs")}),Ol=W.strictObject({kind:Ot,schemaVersion:W.literal(1),name:W.string().trim().min(1).max(80),screen:Le,contract:Il}),Sr=Ol.superRefine((e,t)=>{let n=(o,a)=>t.addIssue({code:"custom",message:o,path:a});e.screen.surface!==e.kind&&n("Content surface must match its domain",["screen","surface"]),e.screen.name!==e.name&&n("Content has one editable name",["screen","name"]),e.kind==="banner"&&e.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),e.kind!=="banner"&&e.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),e.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let r=new Set(e.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(e.contract.outputs).some(o=>!r.has(o))||[...r].some(o=>!Object.hasOwn(e.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),Ze(e)>vl&&n("Content document exceeds its byte budget",[])});function jl(e,t){if(e===null)return t.nullable;switch(t.type){case"json":return!0;case"string":return typeof e=="string";case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"strings":return Array.isArray(e)&&e.every(n=>typeof n=="string")}}var Al=Sr.superRefine((e,t)=>{for(let n of xr(e.screen))Object.keys(e.contract.inputs).some(r=>n===r||n.startsWith(r+"."))||t.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of e.screen.actions){if(n.type!=="event")continue;let r=e.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;r&&!jl(o,r)&&t.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}It(e.screen).some(n=>!n.complete)&&t.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),is=W.strictObject({id:W.uuid(),kind:Ot,projectId:W.uuid(),environmentId:W.uuid(),name:W.string(),revision:W.number().int().nonnegative(),status:W.enum(["draft","published","archived"]),publishedVersionId:W.uuid().nullable(),createdAt:W.iso.datetime({offset:!0}),updatedAt:W.iso.datetime({offset:!0})}),hh=is.extend({draft:Sr}),bh=W.strictObject({rows:W.array(is).max(200),nextCursor:W.uuid().nullable()}),ki=W.strictObject({id:W.uuid(),kind:Ot,resourceId:W.uuid(),projectId:W.uuid(),environmentId:W.uuid(),version:W.number().int().positive(),sourceRevision:W.number().int().nonnegative(),document:Al,createdAt:W.iso.datetime({offset:!0})}),yh=ki.omit({document:!0}),xh=W.discriminatedUnion("action",[W.strictObject({action:W.literal("create"),kind:Ot,id:W.uuid(),document:Sr}),W.strictObject({action:W.literal("save"),kind:Ot,id:W.uuid(),revision:W.number().int().nonnegative(),document:Sr}),W.strictObject({action:W.enum(["publish","archive"]),kind:Ot,id:W.uuid(),revision:W.number().int().nonnegative()})]).superRefine((e,t)=>{"document"in e&&e.document.kind!==e.kind&&t.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});import{z as an}from"zod";var vr=an.strictObject({items:an.array(an.strictObject({productVersionId:an.string().min(1).max(200),label:an.string().trim().max(40)})).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Duplicate Paywall Product"),defaultProductVersionId:an.string().min(1).max(200).nullable(),grouping:Ea.optional()});function Oh(e,t,n){let r=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof r!="string"||!Object.values(n.plans).some(o=>o.versionId===r&&o.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(r)||!n.pickers[e.pickerId]?.options.includes(r))?null:r}import{z as Ri}from"zod";var wl=Ri.enum(["sandbox","live"]),le=Ri.object({projectId:Ri.string().min(1),environment:wl}).strict();import{z as ce}from"zod";var Tn=ce.number().int().min(1).max(Number.MAX_SAFE_INTEGER),os=ce.enum(["unknown","denied","provisional","granted"]),as=ce.enum(["ios","android"]),Ir=ce.strictObject({installationId:ce.uuid(),publicKey:ce.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:ce.iso.datetime({offset:!0}),signature:ce.string().regex(/^[A-Za-z0-9_-]{86}$/)}),Ei=ce.string().regex(/^[a-f0-9]{64}$/),ss=Ir.extend({sequence:Tn,platform:as,credentialDigest:Ei}),cs=Ir.extend({credentialDigest:Ei}),Ph=Ir.extend({sequence:Tn,platform:as}),Or=Ir.extend({sequence:Tn,credentialDigest:Ei,connectionId:ce.uuid().nullable(),kind:ce.enum(["fcm_token","apns_token"]).nullable(),token:ce.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:os}),Ch=Or,kh=Or.extend({challenge:ce.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),Rh=ce.strictObject({requested:ce.literal(!0),expiresAt:ce.iso.datetime({offset:!0})}),jr=ce.strictObject({installationId:ce.uuid(),bound:ce.boolean(),identitySeq:Tn,bindingGeneration:Tn,addressSeq:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:ce.uuid().nullable(),addressStatus:ce.enum(["active","invalid"]).nullable(),permission:os}),Mi=ce.strictObject({channel:ce.enum(["email","sms","voice","push"]),state:ce.enum(["unknown","allowed","denied"]),revision:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:ce.iso.datetime({offset:!0}).nullable()}),Eh=ce.strictObject({state:ce.enum(["allowed","denied"]),revision:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function Mh(e,t,n){let r=["indiana_push_v1",e,t.projectId,t.environment,n.installationId,n.publicKey,n.issuedAt];e==="bind"?r.push(n.sequence,n.platform,n.credentialDigest):e==="detach"?r.push(n.sequence,n.platform):e==="read"?r.push(n.credentialDigest):r.push(n.sequence,n.credentialDigest,n.connectionId,n.kind,n.token,n.permission),e==="recovery_confirm"&&r.push(n.challenge);let o=JSON.stringify(r);if([...o].some(a=>a.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(o,a=>a.charCodeAt(0))}var Dh="X-Indiana-Protocol",zh="X-Indiana-SDK-Version";var Bh={current:"0.10"};import{z as sn}from"zod";var Ar=sn.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,"ID \u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u5F00\u5934"),Vh=sn.object({amountCents:sn.number().int().min(0).max(1e8),currency:ie,interval:sn.enum(["free","month","year"]),currencyOptions:sn.partialRecord(ie,sn.number().int().min(1).max(1e8)).optional()}).refine(e=>e.interval==="free"?e.amountCents===0:e.amountCents>0,"\u514D\u8D39\u5957\u9910\u91D1\u989D\u5FC5\u987B\u4E3A 0\uFF0C\u4ED8\u8D39\u91D1\u989D\u5FC5\u987B\u5927\u4E8E 0").refine(e=>!e.currencyOptions||!Object.hasOwn(e.currencyOptions,e.currency)&&(e.interval!=="free"||Object.keys(e.currencyOptions).length===0),"\u9644\u52A0\u5E01\u79CD\u4E0D\u80FD\u91CD\u590D\u9ED8\u8BA4\u5E01\u79CD\uFF1B\u514D\u8D39\u5957\u9910\u4E0D\u8BBE\u7F6E\u9644\u52A0\u4EF7\u683C");import{z as y}from"zod";var _l=y.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),ls=y.enum(["single_use","continuous_use"]),Ti=y.record(y.string(),y.union([y.string(),y.number(),y.boolean()]).transform(String).pipe(y.string())),us=y.string().min(1).max(64).refine(e=>!e.includes("::")),ms={credit_amount:y.number(),tier_behavior:y.never().optional(),tiers:y.never().optional()},ds={credit_amount:y.never().optional(),tier_behavior:y.literal("graduated"),tiers:y.array(y.strictObject({to:y.union([y.number(),y.literal("inf")]),credit_amount:y.number()}))},Pl=y.union([y.strictObject({match:Ti,priority:y.number().int().optional(),...ms}),y.strictObject({match:Ti,priority:y.number().int().optional(),...ds})]),Cl=y.strictObject({match:Ti,factor:y.number().positive().optional(),add:y.number().optional()}).refine(e=>e.factor!==void 0||e.add!==void 0),ps={metered_feature_id:y.string(),feature_amount:y.number().optional(),dimensions:y.record(us,Pl).optional(),multipliers:y.record(us,Cl).optional()},Di=y.union([y.strictObject({...ps,...ms}),y.strictObject({...ps,...ds})]),_r=y.number().min(-100),fs=y.record(y.string(),y.strictObject({markup:_r})).nullish(),Pr=y.record(y.string().regex(/.+\/.+/),y.strictObject({markup:_r.optional(),input_cost:y.number().min(0).optional(),output_cost:y.number().min(0).optional()})).nullish(),kl=y.strictObject({default_markup:_r.optional(),provider_markups:fs,model_markups:Pr}),Gh=y.strictObject({schema:y.array(Di).optional(),markups:kl.optional()}),Rl=y.strictObject({filters:y.array(y.strictObject({property:y.string(),operator:y.string(),value:y.array(y.string())})),aggregate:y.strictObject({type:y.string(),property:y.string().nullable()}),usage_type:ls}),gs=y.strictObject({schema:y.array(Di).min(1).refine(e=>new Set(e.map(t=>t.metered_feature_id)).size===e.length,"Credit rates must name each metered feature once"),invoice_credit:y.boolean().optional(),usage_type:ls.default("single_use").overwrite(()=>"single_use"),default_markup:_r.optional(),provider_markups:fs}),zi=gs.safeExtend({schema:y.array(Di).length(0)}),wr={id:_l,name:y.string().min(1),display:y.strictObject({singular:y.string().optional(),plural:y.string().optional()}).nullish(),event_names:y.array(y.string()).default([]),model_markups:Pr,stripe_meter:y.strictObject({id:y.string(),event_name:y.string()}).nullish(),stripe_product_id:y.string().nullish()},Bi=e=>y.discriminatedUnion("type",[y.strictObject({...wr,...e,type:y.literal("boolean"),config:y.null()}),y.strictObject({...wr,...e,type:y.literal("metered"),config:Rl}),y.strictObject({...wr,...e,type:y.literal("credit_system"),config:gs}),y.strictObject({...wr,...e,type:y.literal("ai_credit_system"),config:zi})]),Kh=Bi({}),El=y.strictObject({id:y.boolean(),type:y.boolean(),usage_type:y.boolean()}),Ml={internal_id:y.uuid(),org_id:y.uuid(),created_at:y.number(),env:y.enum(["sandbox","live"]),archived:y.boolean(),project_id:y.uuid(),environment_id:y.uuid(),revision:y.number().int().nonnegative(),update_rules:El},hs=Bi(Ml),Lh=y.strictObject({rows:y.array(hs).max(200),nextCursor:y.uuid().nullable()}),Zh=y.strictObject({features:y.array(hs).max(500),limited:y.boolean()}),Hh=y.union([Bi({action:y.literal("save"),internal_id:y.uuid().nullable(),revision:y.number().int().nonnegative()}),y.strictObject({action:y.enum(["archive","restore","delete"]),internal_id:y.uuid(),revision:y.number().int().nonnegative()})]);import{z as s}from"zod";import{z as M}from"zod";import{z as Re}from"zod";function jt(e){let t=new Set,n=a=>a!==null&&typeof a=="object"&&!Array.isArray(a);function r(a,l){if(n(a))for(let[p,d]of Object.entries(a))p==="$elemMatch"?o(d,l):p==="$not"?r(d,l):p==="$all"&&Array.isArray(d)&&d.forEach(v=>r(v,l))}function o(a,l=""){if(n(a)){for(let[p,d]of Object.entries(a))if(["$and","$or","$nor"].includes(p)&&Array.isArray(d))d.forEach(v=>o(v,l));else if(p==="$not")o(d,l);else if(p==="$savedGroup"&&n(d))typeof d.attributeKey=="string"&&t.add(d.attributeKey);else if(!p.startsWith("$")){let v=l?`${l}.${p}`:p;t.add(v),r(d,v)}}}return o(e),[...t]}var Tl=Re.enum(["active","inactive"]),Dl=Re.preprocess((e,t)=>{let n=0;function r(o,a){if(!(++n>1e4||a>20)){if(Array.isArray(o))o.forEach(l=>r(l,a+1));else if(o&&typeof o=="object")for(let[l,p]of Object.entries(o))["__proto__","constructor","prototype"].includes(l)&&t.addIssue({code:"custom",message:"Reserved merchandise attribute"}),r(p,a+1)}}return r(e,0),e},Ke),zl=Re.strictObject({id:Re.string().trim().min(1).max(255),name:Re.string().trim().min(1).max(255),status:Tl,metadata:Dl}),eb=zl.extend({internal_id:Re.uuid(),project_id:Re.uuid(),environment_id:Re.uuid(),created_at:Re.iso.datetime({offset:!0}),updated_at:Re.iso.datetime({offset:!0})}),ys=Re.union([Re.strictObject({id:Re.string().trim().min(1).max(255)}),Re.strictObject({internalId:Re.uuid()})]),tb=Re.enum(["customer","merchandise","context"]),nb=Re.enum(["system","stored","request"]),rb=Re.enum(["customer","merchandise","mixed"]),bs=e=>e==="merchandiseId"||e==="merchandise"||e.startsWith("merchandise.");function qi(e,t={},n=new Set){if(jt(e).some(bs))return!0;for(let r of vt(e)){if(n.has(r))continue;n.add(r);let o=t[r];if(o?.type==="list"&&bs(o.attributeKey)||o?.type==="condition"&&qi(o.condition,t,n))return!0}return!1}var ub=M.enum(["draft","active","paused","archived"]),At=M.discriminatedUnion("type",[M.object({type:M.literal("percent"),percentOff:M.number().min(1).max(100).multipleOf(.01)}).strict(),M.object({type:M.literal("amount"),amountOffCents:M.number().int().min(1).max(1e8),currency:ie}).strict()]),He=M.discriminatedUnion("type",[M.object({type:M.literal("once")}).strict(),M.object({type:M.literal("repeating"),months:M.number().int().min(1).max(36)}).strict(),M.object({type:M.literal("forever")}).strict()]),xs=[M.object({type:M.literal("all")}).strict(),M.object({type:M.literal("plans"),planIds:M.array(M.uuid()).min(1).max(50).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()],Bl=M.discriminatedUnion("type",[...xs,M.strictObject({type:M.literal("merchandise"),scope:M.discriminatedUnion("type",[M.strictObject({type:M.literal("all")}),M.strictObject({type:M.literal("selected"),merchandiseIds:M.array(M.uuid()).min(1).max(1e3).refine(e=>new Set(e).size===e.length,"Duplicate merchandise")}),M.strictObject({type:M.literal("condition"),condition:it})])})]),Fi=M.discriminatedUnion("type",[...xs,M.strictObject({type:M.literal("merchandise"),scope:M.strictObject({type:M.enum(["all","selected","condition"])})})]),ql=M.strictObject({firstPurchaseOnly:M.boolean(),condition:it}),pb=M.object({name:M.string().trim().min(1).max(80),description:M.string().max(500),discount:At,duration:He,appliesTo:Bl,eligibility:ql,selfClaimEnabled:M.boolean().default(!1),startsAt:M.iso.datetime().nullable(),endsAt:M.iso.datetime().nullable(),totalLimit:M.number().int().min(1).max(1e6).nullable(),perCustomerLimit:M.number().int().min(1).max(10),grantWindowHours:M.number().int().min(1).max(2160)}).strict().refine(e=>!e.startsAt||!e.endsAt||Date.parse(e.endsAt)>Date.parse(e.startsAt),{message:"\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4",path:["endsAt"]}).refine(e=>!qi(e.eligibility.condition),{message:"Customer eligibility cannot read merchandise; use merchandise applicability",path:["eligibility","condition"]}).refine(e=>e.appliesTo.type!=="merchandise"||e.duration.type==="once",{message:"Merchandise Coupons apply to one purchase",path:["duration"]}).refine(e=>e.appliesTo.type!=="merchandise"||!e.eligibility.firstPurchaseOnly,{message:"Merchant purchase eligibility requires trusted targeting attributes",path:["eligibility","firstPurchaseOnly"]}),lb=M.object({code:M.string().trim().transform(e=>e.toUpperCase()).pipe(M.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/,"\u4F18\u60E0\u7801\u53EA\u80FD\u7528 3\u201332 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934")),maxRedemptions:M.number().int().min(1).max(1e6).nullable(),expiresAt:M.iso.datetime().nullable(),firstPurchaseOnly:M.boolean(),minimumAmountCents:M.number().int().min(1).max(1e8).nullable(),minimumAmountCurrency:ie.nullable()}).strict().refine(e=>e.minimumAmountCents===null==(e.minimumAmountCurrency===null),"Minimum amount requires its currency");var Dn=M.object({id:M.uuid(),couponId:M.uuid(),status:M.enum(["issued","reserved","redeemed","revoked","expired"]),issuedAt:M.iso.datetime(),expiresAt:M.iso.datetime(),coupon:M.object({name:M.string(),discount:At,duration:He,appliesTo:Fi}).strict()}).strict(),Ss=M.enum(["claim_disabled","unavailable","inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var As=s.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),Ni=s.string().regex(/^(0|[1-9]\d{0,14})$/),cn=s.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,30})?$/),Fl=s.string().regex(/^(?:[1-9]\d{0,7}|1\d{8}|200000000)$/),zn=Fl,bt=be.refine(e=>/[1-9]/.test(e)),Fe=s.iso.datetime({offset:!0}),Cr=e=>{let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");return BigInt(t)*1000000n+BigInt(n.padEnd(6,"0"))},Nl=s.array(s.object({upTo:bt.nullable(),unitAmountMinor:As,flatAmountMinor:s.number().int().min(0).max(1e8).optional()}).strict()).min(1).max(12).refine(e=>{try{return e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,n)=>{let r=e[n-1]?.upTo;return t.upTo!==null&&(n===0||r!=null&&Cr(t.upTo)>Cr(r))})}catch{return!1}},"Tier ceilings must increase and the final tier must be unbounded"),Vl=s.discriminatedUnion("kind",[s.object({kind:s.literal("flat"),units:bt,unitAmountMinor:As}).strict(),s.object({kind:s.enum(["graduated","volume"]),units:bt,tiers:Nl}).strict()]).refine(e=>e.kind==="flat"||!e.tiers.some(t=>(t.flatAmountMinor??0)>0)||e.kind==="volume"&&e.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers"),Ul=s.strictObject({interval:s.enum(["month","year"]),count:s.number().int().min(1).max(12),anchor:s.enum(["membership","calendar"])}),Bn=s.object({currency:ie,pricing:Vl,billingCycle:Ul.optional()}).strict().refine(e=>e.pricing.kind!=="volume"||e.pricing.tiers.length===1,"Multiple volume tiers require prepaid billing");var vs={requestId:s.uuid(),productVersionId:s.uuid(),internal_feature_id:s.uuid(),currency:ie},ws=s.strictObject({interval:s.enum(["hour","day","week","month"]),intervalCount:s.number().int().min(1).max(12),limit:s.number().int().min(1).max(1e6)}),_s=s.discriminatedUnion("kind",[s.object({...vs,kind:s.literal("auto_topup"),threshold:li,quantity:bt.refine(e=>Number(e)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:ws.optional()}).strict(),s.object({...vs,kind:s.literal("postpaid"),maxAmountMinorPerPeriod:zn,maxOutstandingMinor:zn}).strict()]),Is={productVersionId:s.uuid(),internal_feature_id:s.uuid(),currency:ie},Ps=s.discriminatedUnion("kind",[s.object({...Is,kind:s.literal("auto_topup"),threshold:li,quantity:bt.refine(e=>Number(e)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:ws.optional(),purchaseAmountMinor:zn,purchaseUnits:bt}).strict(),s.object({...Is,kind:s.literal("postpaid"),maxAmountMinorPerPeriod:zn,maxOutstandingMinor:zn,cashPrice:Bn}).strict().refine(e=>e.cashPrice.currency===e.currency,"Currency must match")]),kr=s.object({id:s.uuid(),terms:Ps,status:s.enum(["prepared","active","revoked","blocked"]),createdAt:Fe,acceptedAt:Fe.nullable(),effectiveAt:Fe.nullable(),revokedAt:Fe.nullable()}).strict().refine(e=>(e.status==="prepared"?e.acceptedAt===null:!0)&&(e.status==="active"?e.acceptedAt!==null&&e.effectiveAt!==null:!0)&&(e.status==="revoked"?e.revokedAt!==null:e.revokedAt===null),"Authorization consent and revocation must be explicit"),Cs=s.object({authorizationId:s.uuid(),terms:Ps,setupUrl:s.url().nullable()}).strict(),ks=s.object({authorizationId:s.uuid(),accepted:s.literal(!0)}).strict(),Rs=s.object({authorizationId:s.uuid(),requestId:s.uuid()}).strict(),Es=s.object({internal_feature_id:s.uuid(),entityId:s.uuid().nullable(),interval:s.enum(["day","week","month","year"]),anchor:s.enum(["billing_cycle","utc"]).optional(),basis:s.enum(["usage","credits"]),filter:ft.optional(),limit:be.nullable(),thresholds:s.array(s.number().positive().max(1)).max(8),includedThresholds:s.array(s.number().positive().max(1)).max(8).optional(),absoluteThresholds:s.array(bt).max(8).optional()}).strict().refine(e=>e.thresholds.every((t,n)=>{let r=e.thresholds[n-1];return n===0||r!==void 0&&t>r})&&(e.includedThresholds??[]).every((t,n,r)=>{let o=r[n-1];return n===0||o!==void 0&&t>o})&&(e.absoluteThresholds??[]).every((t,n,r)=>{let o=r[n-1];return n===0||o!==void 0&&Cr(t)>Cr(o)}),"Notification thresholds must increase"),$l=Es.safeExtend({requestId:s.uuid()}),Os={control:s.literal("overage"),requestId:s.uuid(),internal_feature_id:s.uuid(),entityId:s.uuid().nullable()},Gl=s.discriminatedUnion("action",[s.strictObject({...Os,action:s.literal("set"),allowed:s.boolean().nullable(),overageLimit:be.nullable(),skipOverageBilling:s.boolean()}),s.strictObject({...Os,action:s.literal("remove")})]),Ms=s.union([$l,Gl]),Kl=s.strictObject({internal_feature_id:s.uuid(),entityId:s.uuid().nullable(),allowed:s.boolean().nullable(),overageLimit:be.nullable(),skipOverageBilling:s.boolean(),interval:s.enum(["day","week","month","year"]),startsAt:Fe,endsAt:Fe,used:s.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),reserved:s.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),remaining:s.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,6})?$/).nullable()}),Ll=s.object({internal_feature_id:s.uuid(),entityId:s.uuid().nullable(),interval:s.enum(["day","week","month","year"]),anchor:s.enum(["billing_cycle","utc"]).optional(),basis:s.enum(["usage","credits"]),filter:ft.optional(),startsAt:Fe,endsAt:Fe,used:rt,reserved:rt,limit:be.nullable(),thresholds:s.array(s.number().positive().max(1)).max(8),notifiedThresholds:s.array(s.number().positive().max(1)).max(1024),includedThresholds:s.array(s.number().positive().max(1)).max(8).optional(),includedAllowance:s.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/).optional(),notifiedIncludedThresholds:s.array(s.number().positive().max(1)).max(1024).optional(),absoluteThresholds:s.array(bt).max(8).optional(),notifiedAbsoluteThresholds:s.array(bt).max(1024).optional()}).strict().refine(e=>e.basis!=="usage"||be.safeParse(e.used).success&&be.safeParse(e.reserved).success,"Usage counters retain six decimals; credit costs retain twelve"),Zl=s.object({authorizationId:s.uuid(),status:s.enum(["idle","pending","blocked"]),taskId:s.uuid().nullable(),invoiceId:s.uuid().nullable(),hostedInvoiceUrl:s.url().nullable(),purchaseCount:s.number().int().nonnegative(),purchaseWindowEndsAt:Fe.nullable(),attemptCount:s.number().int().nonnegative(),failedAttemptCount:s.number().int().nonnegative(),suspendedAt:Fe.nullable(),nextAttemptAt:Fe.nullable(),failureReason:s.string().min(1).max(240).nullable()}).strict(),Ts=s.object({internal_feature_id:s.uuid().optional(),entityId:s.uuid().optional()}).strict(),Vi=s.object({authorizations:s.array(kr).max(100),limits:s.array(Es).max(100),overages:s.array(Kl).max(100).optional(),windows:s.array(Ll).max(200),autoTopups:s.array(Zl).max(100),limited:s.boolean()}).strict(),Hl=s.object({id:s.uuid(),internal_feature_id:s.uuid(),productVersionId:s.uuid(),authorizationId:s.uuid(),entityId:s.uuid().nullable(),units:be,amountMinor:cn,cashPrice:Bn}).strict(),qn=s.object({id:s.uuid(),sourceKind:s.enum(["product","usage","manual"]),providerInvoiceId:s.string().min(1).max(240).nullable(),status:s.enum(["accruing","open","pending","paid","failed","void"]),currency:ie,startsAt:Fe.nullable(),endsAt:Fe.nullable(),amountMinor:s.string().regex(/^-?(0|[1-9]\d{0,14})$/),grossAmountMinor:s.string().regex(/^-?(0|[1-9]\d{0,14})$/),discountMinor:Ni,paidAmountMinor:Ni,refundedAmountMinor:Ni,createdAt:Fe,hostedInvoiceUrl:s.url().nullable(),adjustment:s.object({originalInvoiceId:s.uuid(),amountMinor:s.string().regex(/^-?(0|[1-9]\d{0,8})$/).refine(e=>e!=="-0"&&/^-?(0|[1-9]\d{0,8})$/.test(e)&&BigInt(e)>=-200000000n&&BigInt(e)<=200000000n,"Invoice adjustment exceeds the bounded minor amount"),acceptedAt:Fe.nullable(),reason:s.string().min(1).max(500).optional()}).strict().nullable(),lines:s.array(Hl).max(100),linesLimited:s.boolean()}).strict(),Ds=s.object({invoiceId:s.uuid(),accepted:s.literal(!0)}).strict(),zs=s.strictObject({requestId:s.uuid(),originalInvoiceId:s.uuid(),amountMinor:s.string().regex(/^[1-9]\d{0,8}$/).refine(e=>/^[1-9]\d{0,8}$/.test(e)&&BigInt(e)<=200000000n,"Supplemental amount exceeds the bounded minor amount"),reason:s.string().trim().min(1).max(500)}),Bs=s.object({after:s.uuid().nullable(),limit:s.number().int().min(1).max(100)}).strict(),qs=s.object({rows:s.array(qn).max(100),nextCursor:s.uuid().nullable()}).strict(),js=s.strictObject({id:s.string(),coupon:s.string(),start:s.number().nonnegative(),end:s.number().nullable()}),Jl=s.strictObject({subscriptionId:s.string(),customerId:s.string(),accountId:s.string(),sourceItems:s.array(s.strictObject({id:s.string(),price_id:s.string(),quantity:s.number().int(),discounts:s.array(js).optional()})).max(100),items:s.array(s.strictObject({id:s.string(),price:s.string(),quantity:s.number().int(),discounts:s.array(s.strictObject({coupon:s.string().optional(),terms:s.strictObject({id:s.string(),name:s.string().optional(),percent_off:s.number().optional(),amount_off:s.number().optional(),currency:s.string().optional(),duration:s.enum(["once","forever","repeating"]),duration_in_months:s.number().optional()}).optional(),discount:s.string().optional(),receipt:js.optional()})).max(20)})).max(100)}),Fs=s.strictObject({membershipId:s.uuid(),requestId:s.uuid(),grantIds:s.array(s.uuid()).max(20).refine(e=>new Set(e).size===e.length,"Duplicate Coupon grants")}),Ns=s.strictObject({membershipId:s.uuid(),operationId:s.uuid(),status:s.enum(["pending","effective"]),execution:Jl.nullable(),grants:s.array(s.strictObject({id:s.uuid(),couponId:s.uuid(),name:s.string(),discount:At,duration:He,startedAt:Fe.nullable()})).max(20)});import{z as Fn}from"zod";var Vs=Fn.enum(["minute","hour","day","week","month","quarter","semi_annual","year","lifetime"]),Us=Fn.number().int().min(1).max(1e3),Rr=Fn.object({cap:be.refine(e=>/[1-9]/.test(e)).nullable(),capPercentage:Fn.number().positive().max(1e4).nullable(),cycles:Fn.number().int().min(1).max(1200).nullable()}).strict().refine(e=>e.cap===null||e.capPercentage===null,"Choose a fixed or percentage cap");import{z as wt}from"zod";var $s=wt.strictObject({itemKey:wt.string().regex(/^paid:feature:[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/),internal_feature_id:wt.uuid(),includedAmount:wt.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),quantity:wt.number().int().min(0).max(1e4),terms:ma,pricing:la.optional(),unitAmountMinor:wt.number().int().min(0).max(1e8),productId:wt.string().min(1).max(255).nullable(),priceId:wt.string().min(1).max(255).nullable()}).superRefine((e,t)=>{(e.quantity<e.terms.minimumQuantity||e.quantity>e.terms.maximumQuantity||e.productId===null!=(e.priceId===null)||e.quantity>0&&(e.pricing||e.unitAmountMinor>0)&&e.priceId===null)&&t.addIssue({code:"custom",message:"Purchased quantities need their published bounds and immutable price binding"});try{da(e.includedAmount,e.terms.units,e.quantity),or({quantity:e.quantity,unitAmountMinor:e.unitAmountMinor,...e.pricing===void 0?{}:{pricing:e.pricing}})}catch{t.addIssue({code:"custom",message:"Purchased allowance exceeds the ledger quantity limit"})}});import{z as ne}from"zod";var Bt=ne.iso.datetime({offset:!0}),Gs=be.refine(e=>/[1-9]/.test(e)),Ks=ne.strictObject({interval:Vs.exclude(["lifetime"]),count:Us}),Wl=ne.strictObject({action:ne.literal("create"),requestId:ne.uuid(),internal_feature_id:ne.uuid(),entityId:ne.uuid().nullable(),amount:Gs.nullable(),expiresAt:Bt.nullable(),reset:Ks.nullable(),rollover:Rr.nullable(),nextResetAt:Bt.nullable()}).refine(e=>e.amount!==null||e.reset===null&&e.rollover===null,"Unlimited grants cannot reset or roll over").refine(e=>!e.rollover||e.reset!==null,"Rollover requires a recurring grant").refine(e=>e.nextResetAt===null||e.reset!==null&&(e.expiresAt===null||Date.parse(e.nextResetAt)<Date.parse(e.expiresAt)),"The first reset needs a reset interval and must precede expiry"),Ls=ne.discriminatedUnion("action",[Wl,ne.strictObject({action:ne.literal("update"),requestId:ne.uuid(),grantId:ne.uuid(),revision:ne.number().int().nonnegative(),amount:Gs.nullable(),expiresAt:Bt.nullable(),rollover:Rr.nullable(),nextResetAt:Bt.nullable()}),ne.strictObject({action:ne.enum(["add","subtract","set_remaining"]),requestId:ne.uuid(),grantId:ne.uuid(),revision:ne.number().int().nonnegative(),amount:be}),ne.strictObject({action:ne.literal("revoke"),requestId:ne.uuid(),grantId:ne.uuid(),revision:ne.number().int().nonnegative()})]),Ui=ne.strictObject({id:ne.uuid(),internal_feature_id:ne.uuid(),entityId:ne.uuid().nullable(),amount:be.nullable(),reset:Ks.nullable(),rollover:Rr.nullable(),nextResetAt:Bt.nullable(),startsAt:Bt,expiresAt:Bt.nullable(),revision:ne.number().int().nonnegative(),revoked:ne.boolean(),available:rt,held:rt,spent:rt}),Zs=ne.strictObject({customerId:ne.uuid(),after:ne.uuid().nullable(),limit:ne.number().int().min(1).max(100)}),Hs=ne.strictObject({rows:ne.array(Ui).max(100),nextCursor:ne.uuid().nullable()});import{z as D}from"zod";var mt=D.iso.datetime({offset:!0}),Js=D.strictObject({invoiceId:D.uuid(),after:D.string().min(1).max(180).nullable(),limit:D.number().int().min(1).max(100)}),Ql=D.strictObject({kind:D.literal("product"),key:D.string(),productVersionId:D.uuid(),productName:D.string(),itemKey:D.string(),entityId:D.uuid().nullable(),quantity:D.number().positive(),subtotalMinor:D.string().regex(/^-?\d+$/),discountMinor:D.string().regex(/^\d+$/),taxMinor:D.string().regex(/^-?\d+$/).nullable(),totalMinor:D.string().regex(/^-?\d+$/),startsAt:mt.nullable(),endsAt:mt.nullable(),providerLineId:D.string().nullable(),providerItemId:D.string()}),Ws=D.strictObject({invoice:qn,items:D.array(D.discriminatedUnion("kind",[Ql,D.strictObject({kind:D.literal("invoice_credit"),key:D.string(),internal_feature_id:D.uuid(),internal_credit_feature_id:D.uuid(),name:D.string(),units:be,reserved:be,amountMinor:cn,grossAmountMinor:cn,creditsAppliedMinor:cn,properties:ft,cashPrice:Bn,providerItemId:D.string().nullable(),creditProviderItemId:D.string().nullable()}),D.strictObject({kind:D.literal("usage"),key:D.string(),internal_feature_id:D.uuid(),name:D.string(),units:be,reserved:be,amountMinor:cn,cashPrice:Bn})])).max(100),nextCursor:D.string().min(1).max(180).nullable()}),Xl=D.string().regex(/^-?(0|[1-9]\d{0,17})(\.\d{1,12})?$/).refine(e=>!/^\-0(?:\.0+)?$/.test(e)),$i=D.strictObject({from:mt,to:mt,entityId:D.uuid().optional(),snapshotAt:mt.nullable(),after:D.strictObject({at:mt,id:D.uuid(),position:D.number().int().nonnegative()}).nullable(),limit:D.number().int().min(1).max(100)}).refine(e=>Date.parse(e.from)<Date.parse(e.to)&&Date.parse(e.to)-Date.parse(e.from)<=366*864e5,"Statement range must be positive and at most 366 days").refine(e=>e.after===null||e.snapshotAt!==null,"A cursor requires the original snapshot time"),Qs=D.strictObject({customerId:D.uuid(),entityId:D.uuid().nullable(),from:mt,to:mt,snapshotAt:mt,totals:D.array(D.strictObject({internal_credit_feature_id:D.uuid(),name:D.string(),consumed:rt,refunded:rt,net:Xl})).max(1e3),rows:D.array(D.strictObject({operationId:D.uuid(),position:D.number().int().nonnegative(),kind:D.enum(["consume","confirm","refund"]),originalId:D.uuid().nullable(),occurredAt:mt,internal_feature_id:D.uuid(),entitlementName:D.string(),sourceId:D.uuid(),internal_credit_feature_id:D.uuid(),creditName:D.string(),units:ya,amount:rt,pricing:D.array(ba).max(12),properties:ft})).max(100),nextCursor:$i.shape.after});import{z as V}from"zod";var Ys=V.object({customerId:V.uuid()}).strict(),ec=V.discriminatedUnion("action",[V.object({customerId:V.uuid(),requestId:V.uuid(),action:V.literal("assign"),poolId:V.uuid(),memberCustomerId:V.uuid()}).strict(),V.strictObject({customerId:V.uuid(),requestId:V.uuid(),action:V.literal("assign_entity"),poolId:V.uuid(),entityId:V.uuid()}),V.object({customerId:V.uuid(),requestId:V.uuid(),action:V.literal("release"),poolId:V.uuid(),slotId:V.uuid()}).strict()]),Nn=V.number().int().nonnegative(),Gi=V.iso.datetime({offset:!0}),Ki=V.strictObject({internalId:V.uuid(),id:V.string(),name:V.string().nullable(),version:V.number().int().positive()}),Xs=V.enum(["active","past_due"]),Li=V.strictObject({customerId:V.uuid(),licenses:V.array(V.strictObject({id:V.uuid(),linkId:V.uuid(),parent:V.strictObject({customerProductId:V.uuid(),status:Xs,product:Ki}),product:Ki,planLicense:V.strictObject({id:V.uuid(),prepaidOnly:V.boolean(),isCustom:V.boolean()}).nullable(),granted:Nn,included:Nn,paidQuantity:Nn,usage:Nn,remaining:Nn,createdAt:Gi}).refine(e=>e.granted===e.included+e.paidQuantity&&e.granted===e.usage+e.remaining,"Granted seats are included plus paid, and usage plus remaining")).max(2e3),assignments:V.array(V.strictObject({id:V.uuid(),linkId:V.uuid(),status:Xs,product:Ki,entity:V.strictObject({internalId:V.uuid(),id:V.string().nullable(),name:V.string().nullable()}).nullable(),beneficiary:V.strictObject({internalId:V.uuid(),id:V.string().nullable(),name:V.string().nullable()}).nullable(),startedAt:Gi.nullable(),endedAt:Gi.nullable()}).refine(e=>e.entity!==null||e.beneficiary!==null,"A seat assignment has a holder")).max(1e4),limited:V.boolean()});import{z as N}from"zod";var Vn=N.enum(["email","sms","voice","push"]),Bb=N.enum(["resend","twilio","fcm","apns"]);var qb=N.string().regex(/^\+[1-9]\d{1,14}$/),Yl=N.enum(["email_recipient","sms_segment","voice_second","push_device"]);var em=N.string().trim().min(1).max(200).refine(e=>!/[\r\n\0]/.test(e),"Invalid email header"),tm=N.strictObject({subject:em,html:N.string().min(1).max(131072).optional(),text:N.string().min(1).max(65536).optional()}).refine(e=>e.html!==void 0||e.text!==void 0,{message:"Email requires HTML or text content"}),nm=N.strictObject({body:N.string().min(1).max(1600).refine(e=>e.trim().length>0)}),rm=N.strictObject({text:N.string().trim().min(1).max(4e3),language:N.string().regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(35),maxDurationSeconds:N.number().int().min(1).max(900)}),im=N.record(N.string().min(1).max(64),N.string().max(256)).refine(e=>Object.keys(e).length<=20&&Object.keys(e).every(t=>!/^(?:indiana_|google\.|gcm\.)/i.test(t)&&t!=="aps"),"Push data contains reserved fields or too many entries"),om=N.strictObject({title:N.string().trim().min(1).max(200),body:N.string().trim().min(1).max(2e3),url:N.url().max(2048).refine(e=>!/^(?:javascript|data|file|vbscript):/i.test(e)).optional(),data:im.optional()}).refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=3072,"Push content exceeds the provider payload budget"),tc=N.discriminatedUnion("channel",[N.strictObject({channel:N.literal("email"),content:tm}),N.strictObject({channel:N.literal("sms"),content:nm}),N.strictObject({channel:N.literal("voice"),content:rm}),N.strictObject({channel:N.literal("push"),content:om})]),nc=N.strictObject({requestId:N.uuid(),customerId:N.uuid(),connectionId:N.uuid().optional(),message:tc,expiresAt:N.iso.datetime({offset:!0})}),am=N.array(N.uuid()).min(1).max(1e4).refine(e=>new Set(e).size===e.length,"Duplicate Customer"),sm=N.discriminatedUnion("kind",[N.strictObject({kind:N.literal("all")}),N.strictObject({kind:N.literal("customers"),customerIds:am})]),Fb=N.strictObject({name:N.string().trim().min(1).max(120),connectionId:N.uuid().optional(),message:tc,audience:sm,frequencyLimit:N.number().int().min(1).max(100)}),rc=N.strictObject({requestId:N.uuid(),channel:Vn,state:N.enum(["allowed","denied"]),expectedRevision:N.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)}),ic=N.enum(["queued","leased","dispatching","accepted","unknown","retry","skipped","failed","canceled"]),oc=N.enum(["accepted","sent","delivered","delayed","bounced","complained","unsubscribed","opened","clicked","ringing","answered","completed","busy","no_answer","failed","cost_finalized"]),Nb=N.strictObject({meter:Yl,estimatedUnits:N.string().regex(/^(0|[1-9]\d{0,11})$/),observedUnits:N.string().regex(/^(0|[1-9]\d{0,11})$/).nullable()});import{z as ac}from"zod";var un={funnelId:ac.uuid().optional(),funnelVersionId:ac.uuid().optional()};import{z as Er}from"zod";var Mr=Er.strictObject({runId:Er.uuid(),bindingId:Er.uuid(),receiptId:Er.uuid()});import{z as ye}from"zod";import{z as ae}from"zod";import{z as fe}from"zod";var Zb=fe.discriminatedUnion("action",[fe.strictObject({action:fe.literal("create"),couponId:fe.uuid(),productBindingId:fe.uuid(),storeOfferId:fe.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),storeOfferType:fe.enum(["introductory","promotional"])}),fe.strictObject({action:fe.literal("set_enabled"),id:fe.uuid(),revision:fe.number().int().nonnegative(),enabled:fe.boolean()})]),Hb=fe.array(fe.strictObject({id:fe.uuid(),couponId:fe.uuid(),productBindingId:fe.uuid(),storeOfferId:fe.string().min(1).max(255).nullable(),storeOfferType:fe.enum(["introductory","promotional"]),enabled:fe.boolean(),revision:fe.number().int().nonnegative()})).max(500),pn=fe.strictObject({offerKind:fe.enum(["none","introductory","promotional"]),offerId:fe.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),discountMinor:fe.number().int().min(0).max(1e8),trialDays:fe.number().int().min(1).max(730).nullable()}).superRefine((e,t)=>{(e.offerKind==="none"&&(e.offerId!==null||e.discountMinor!==0||e.trialDays!==null)||e.trialDays!==null&&e.discountMinor!==0)&&t.addIssue({code:"custom",message:"Select one store purchase option with its exact terms"})}),Jb=fe.record(fe.uuid(),pn).refine(e=>Object.keys(e).length<=20,"At most 20 native store selections");var Zi=ae.object({type:ae.literal("native_purchase"),receiptId:ae.uuid(),orderId:ae.uuid(),productVersionId:ae.uuid(),provider:ae.enum(["apple","google"]),productId:ae.string().min(1).max(255),productKind:wa,replacement:ae.strictObject({sourceOrderId:ae.uuid(),sourceProductId:ae.string().min(1).max(255),policy:ae.enum(["apple_store","google_full_price"]),sourceAccountTokens:ae.array(ae.uuid()).max(50)}).nullable(),appAccountToken:ae.uuid().optional(),obfuscatedAccountId:ae.string().min(1).max(64).optional(),obfuscatedProfileId:ae.uuid().optional(),basePlanId:ae.string().min(1).max(255).optional(),offerId:ae.string().min(1).max(255).optional(),offerKind:ae.enum(["none","introductory","promotional"]),currency:ie,catalogAmountMinor:ae.number().int().nonnegative().max(1e8),discountMinor:ae.number().int().nonnegative().max(1e8),trialDays:ae.number().int().min(1).max(730).nullable(),seatBundle:ae.array(ae.strictObject({key:ae.string().regex(/^[a-z][a-z0-9_]{0,63}$/),quantity:ae.number().int().min(1).max(1e4)})).max(20),applePromotionalOffer:ae.strictObject({offerId:ae.string().min(1).max(255),keyId:ae.string().min(1).max(255),nonce:ae.uuid(),signature:ae.string().min(1).max(1024),timestamp:ae.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}).nullable()}).strict().superRefine((e,t)=>{let n=e.provider==="apple";(e.replacement!==null&&(e.productKind!=="membership"||e.offerKind!=="none"||e.trialDays!==null||e.replacement.policy!==(n?"apple_store":"google_full_price"))||e.productKind!=="membership"&&(e.trialDays!==null||e.offerKind!=="none"||e.basePlanId!==void 0)||!n&&e.productKind==="membership"&&e.basePlanId===void 0||e.discountMinor>e.catalogAmountMinor||new Set(e.seatBundle.map(o=>o.key)).size!==e.seatBundle.length||e.trialDays!==null&&(e.discountMinor!==0||e.offerKind==="none")||e.offerKind==="none"&&e.discountMinor!==0||(n?!e.appAccountToken||e.obfuscatedAccountId!==void 0||e.obfuscatedProfileId!==void 0||e.basePlanId!==void 0||e.offerKind==="promotional"!=(e.applePromotionalOffer!==null)||e.offerKind==="promotional"!=(e.offerId!==void 0)||e.applePromotionalOffer!==null&&e.applePromotionalOffer.offerId!==e.offerId:e.appAccountToken!==void 0||!e.obfuscatedAccountId||!e.obfuscatedProfileId||e.applePromotionalOffer!==null||e.offerKind==="none"!=(e.offerId===void 0)))&&t.addIssue({code:"custom",message:"Native purchase terms must match the accepted store selection"})});import{z as i}from"zod";import{z as Q}from"zod/v4";import{z as cm}from"zod/v4";var um=cm.registry(),{BillingInterval:sc}=(()=>{var e;return(function(t){t.OneOff="one_off",t.Week="week",t.Month="month",t.Quarter="quarter",t.SemiAnnual="semi_annual",t.Year="year"})(e||(e={})),{BillingInterval:e}})(),{DisplaySchema:pm}=(e=>({DisplaySchema:e.object({primary_text:e.string().meta({description:"Main display text (e.g. '$10' or '100 messages')."}),secondary_text:e.string().optional().meta({description:"Secondary display text (e.g. 'per month' or 'then $0.5 per 100')."})})}))(Q),{withSpecDefault:lm}=(e=>({withSpecDefault:({schema:n,defaultValue:r,description:o})=>(e.add(n,{description:o,default:r}),n)}))(um),{COMMON:cc}={COMMON:["usd","eur","gbp","cad","aud","jpy","chf","cny","inr"]},{STRIPE_PRESENTMENT_CURRENCIES:mm}={STRIPE_PRESENTMENT_CURRENCIES:["usd","aed","afn","all","amd","ang","aoa","ars","aud","awg","azn","bam","bbd","bdt","bif","bmd","bnd","bob","brl","bsd","bwp","byn","bzd","cad","cdf","chf","clp","cny","cop","crc","cve","czk","djf","dkk","dop","dzd","egp","etb","eur","fjd","fkp","gbp","gel","gip","gmd","gnf","gtq","gyd","hkd","hnl","htg","huf","idr","ils","inr","isk","jmd","jpy","kes","kgs","khr","kmf","krw","kyd","kzt","lak","lbp","lkr","lrd","lsl","mad","mdl","mga","mkd","mmk","mnt","mop","mur","mvr","mwk","mxn","myr","mzn","nad","ngn","nio","nok","npr","nzd","pab","pen","pgk","php","pkr","pln","pyg","qar","ron","rsd","rub","rwf","sar","sbd","scr","sek","sgd","shp","sle","sos","srd","std","szl","thb","tjs","top","try","ttd","twd","tzs","uah","ugx","uyu","uzs","vnd","vuv","wst","xaf","xcd","xcg","xof","xpf","yer","zar","zmw"]},{COMMON_SET:dm}=(e=>({COMMON_SET:new Set(e)}))(cc),{hasNoDuplicateCurrencies:uc}={hasNoDuplicateCurrencies:t=>{let n=new Set;for(let{currency:r}of t){let o=r.toLowerCase();if(n.has(o))return!1;n.add(o)}return!0}},{DUPLICATE_CURRENCY_MESSAGE:pc}={DUPLICATE_CURRENCY_MESSAGE:"Each currency may appear at most once in additional_currencies."},{ApiStripePriceProcessorSchema:fm}=(e=>({ApiStripePriceProcessorSchema:e.object({price_id:e.string().meta({description:"Stripe price ID. For prepaid with included > 0 this is the V2 price."})})}))(Q),{Infinite:gm}={Infinite:"inf"},{TierBehavior:hm}=(()=>{var e;return(function(t){t.Graduated="graduated",t.VolumeBased="volume"})(e||(e={})),{TierBehavior:e}})(),{BillingMethod:lc}=(()=>{var e;return(function(t){t.Prepaid="prepaid",t.UsageBased="usage_based"})(e||(e={})),{BillingMethod:e}})(),{AllocatedBilling:bm}=(()=>{var e;return(function(t){t.Arrear="arrear",t.ProratedLegacy="prorated_legacy"})(e||(e={})),{AllocatedBilling:e}})(),{CREDIT_DIMENSION_NAME_MAX_LENGTH:ym}={CREDIT_DIMENSION_NAME_MAX_LENGTH:64},{USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:xm}={USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:"::"},{CreditMatchSchema:Sm}=(e=>({CreditMatchSchema:e.record(e.string(),e.union([e.string(),e.number(),e.boolean()]).transform(String).pipe(e.string()))}))(Q),{ApiCreditTierSchema:mc}=(e=>({ApiCreditTierSchema:e.object({to:e.union([e.number().positive(),e.enum(["inf"])]).meta({description:"Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'."}),credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group within this tier."})})}))(Q),{VIOLATION_MESSAGES:vm}={VIOLATION_MESSAGES:{non_final_infinity:"Only the final tier may use an 'inf' boundary.",not_increasing:"Tier boundaries must be strictly increasing.",final_not_infinity:"The final tier must use an 'inf' boundary."}},{MarkupEntrySchema:dc}=(e=>({MarkupEntrySchema:e.object({markup:e.number().min(-100)})}))(Q),{ModelMarkupsSchema:Im}=((e,t)=>({ModelMarkupsSchema:e.record(e.string().regex(/.+\/.+/,'Model keys are "<provider>/<model>", e.g. "openai/gpt-4o" or "custom/my-model".'),t.extend({markup:e.number().min(-100).optional(),input_cost:e.number().min(0).optional(),output_cost:e.number().min(0).optional()})).nullish()}))(Q,dc),{InvoiceUsageEntrySchema:Om}=(e=>({InvoiceUsageEntrySchema:e.object({feature_id:e.string().meta({description:"The metered feature whose units are being converted."}),quantity:e.number().nonnegative().meta({description:"Billable units of the metered feature. Converted to the credit-system feature through its rate card."}),properties:e.record(e.string(),e.unknown()).optional().meta({description:"Event properties used to pick the rate card dimension and multipliers."})}).strict()}))(Q),{AttachDiscountSchema:fc}=(e=>({AttachDiscountSchema:e.object({reward_id:e.string().optional().meta({description:"The ID of the reward to apply as a discount."}),promotion_code:e.string().optional().meta({description:"The promotion code to apply as a discount."})}).refine(n=>n.reward_id||n.promotion_code,{message:"Either reward_id or promotion_code must be provided."}).meta({title:"AttachDiscount",description:"A discount to apply. Can be either a reward ID or a promotion code."})}))(Q),{CustomLineItemSchema:jm}=(e=>({CustomLineItemSchema:e.object({amount:e.number().meta({description:"Amount in dollars for this line item (e.g. 10.50). Can be negative for credits."}),description:e.string().meta({description:"Description for the line item."})})}))(Q),{UnixMsTimestampSchema:Am}=(e=>({UnixMsTimestampSchema:e.number().int().safe().nonnegative()}))(Q),{CreateInvoicePreviewLineSchema:wm}=(e=>({CreateInvoicePreviewLineSchema:e.object({plan_id:e.string().nullable(),feature_id:e.string().nullable(),description:e.string(),amount:e.number(),amount_after_discounts:e.number(),quantity:e.number().nullable(),prorated:e.boolean(),period_start:e.number().nullable(),period_end:e.number().nullable()})}))(Q),{ReissueInvoiceParamsSchema:gc}=(e=>({ReissueInvoiceParamsSchema:e.object({invoice_id:e.string().meta({description:"The Autumn invoice ID to void and replace.",example:"inv_2b3c4d5e6f7g8h"}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer and memo are applied to the replacement invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the replacement invoice. Defaults to the original invoice's due date; required when that date has already passed."}),update_customer_email:e.email().optional().meta({description:"Updates the customer's billing email before the replacement is issued, so Stripe sends the new invoice to this address."})})}))(Q),{InvoiceModeParamsSchema:qt}=(e=>({InvoiceModeParamsSchema:e.object({enabled:e.boolean().meta({description:"When true, creates an invoice and sends it to the customer instead of charging their card immediately. Uses Stripe's send_invoice collection method."}),enable_plan_immediately:e.boolean().default(!1).meta({description:"If true, enables the plan immediately even though the invoice is not paid yet."}),finalize:e.boolean().default(!0).meta({description:"If true, finalizes the invoice so it can be sent to the customer. If false, keeps it as a draft for manual review."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer (e.g. bank details) is applied to the invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the invoice before it is due (Stripe days_until_due)."})}).meta({title:"InvoiceMode",description:"Invoice mode configuration. Creates an invoice instead of charging the card immediately."})}))(Q),{InvoiceTemplateSchema:_m}=(e=>({InvoiceTemplateSchema:e.object({id:e.string().meta({description:"Unique identifier for the invoice template."}),name:e.string().meta({description:"User-defined name to distinguish this template when sending an invoice."}),footer:e.string().optional().meta({description:"Footer text rendered on the invoice, typically bank details so customers can pay directly."}),memo:e.string().optional().meta({description:"Memo shown near the top of the invoice (Stripe invoice description), e.g. a contact line for payment questions."}),net_terms_days:e.number().int().positive().optional().meta({description:"Default number of days the customer has to pay before the invoice is due. Overridable when sending."}),created_at:e.number().optional().meta({description:"Timestamp (ms) when the template was created."})})}))(Q),{BasePriceSchema:Pm}=((e,t,n)=>({BasePriceSchema:e.object({amount:e.number().meta({description:"Base price amount for the plan, in major currency units (e.g. dollars)."}),interval:e.enum(t).meta({description:"Billing interval (e.g. 'month', 'year')."}),interval_count:e.number().optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),display:n.optional().meta({description:"Display text for showing this price in pricing pages."})})}))(Q,sc,pm),{CURRENCY_CODES:Cm}=((e,t,n)=>({CURRENCY_CODES:[...e,...t.filter(o=>!n.has(o)).sort()]}))(cc,mm,dm),{ApiPriceProcessorsSchema:hc}=((e,t)=>({ApiPriceProcessorsSchema:e.object({stripe:t.nullish()}).meta({"x-atmn-mapping":!0})}))(Q,fm),{AllocatedBillingFieldSchema:km}=((e,t)=>({AllocatedBillingFieldSchema:e.enum(t).optional().meta({internal:!0,description:"How an allocated usage_based price bills mid-cycle quantity changes. 'arrear' (default) bills at period end. 'prorated_legacy' is only returned for prices still on the legacy immediate-proration behavior; omit it to migrate the price to 'arrear'."})}))(Q,bm),{CreditDimensionNameSchema:Rm}=((e,t,n)=>({CreditDimensionNameSchema:e.string().min(1).max(t).refine(o=>!o.includes(n),{message:`Dimension names cannot contain "${n}"`})}))(Q,ym,xm),{ApiCreditMatchSchema:bc}=(e=>({ApiCreditMatchSchema:e.meta({description:"Event properties this entry applies to. Every key must equal the tracked property, compared as strings."})}))(Sm),{findCreditTierViolations:Em}=(e=>({findCreditTierViolations:n=>{let r=[],o=(l,p)=>r.push({index:l,reason:p,message:e[p]}),a=0;for(let[l,p]of n.entries()){let d=l===n.length-1;if(p==="inf"){d||o(l,"non_final_infinity");continue}(!Number.isFinite(p)||p<=a)&&o(l,"not_increasing"),a=p,d&&o(l,"final_not_infinity")}return r}}))(vm),{ApiCreditMultiplierSchema:Mm}=((e,t)=>({ApiCreditMultiplierSchema:e.object({match:t,factor:e.number().positive().optional().meta({description:"Multiplies the matched rate. All matching multipliers stack."}),add:e.number().optional().meta({description:"Added to the rate after every factor is applied, in credits per billing-unit group."})}).strict().refine(r=>r.factor!==void 0||r.add!==void 0,{message:"A multiplier needs a factor or an add."})}))(Q,bc),{ProviderMarkupsSchema:Tm}=((e,t)=>({ProviderMarkupsSchema:e.record(e.string(),t).nullish()}))(Q,dc),{InvoiceFeatureQuantitySchema:yc}=((e,t,n)=>({InvoiceFeatureQuantitySchema:e.object({feature_id:e.string().meta({description:"The feature to bill."}),billing_behavior:e.enum(t).meta({description:"Which of the feature's prices to use: 'prepaid' or 'usage_based'."}),quantity:e.number().nonnegative().optional().meta({description:"Billable feature units in total, exclusive of any included usage. Not per seat or per entity. For a credit-system feature this is the number of credits."}),usage:e.array(n).optional().meta({description:"For credit-system features: billable units of the source features, converted through the credit rate card. Mutually exclusive with quantity."}),prorate:e.boolean().optional().meta({description:"Whether to prorate this line against period_start / period_end. Defaults to true for prepaid and false for usage-based."})}).strict().refine(o=>o.quantity!==void 0!=(o.usage!==void 0),{message:"Provide exactly one of quantity or usage."})}))(Q,lc,Om),{CreateInvoicePreviewSchema:Hi}=((e,t)=>({CreateInvoicePreviewSchema:e.object({currency:e.string(),lines:e.array(t),subtotal:e.number(),discount_total:e.number(),tax:e.object({total:e.number(),amount_inclusive:e.number(),amount_exclusive:e.number(),status:e.enum(["complete","incomplete"])}).nullable(),total:e.number(),due_date:e.number().nullable()})}))(Q,wm),{SUPPORTED_SET:Dm}=(e=>({SUPPORTED_SET:new Set(e)}))(Cm),{ApiCreditDimensionBaseSchema:zm}=((e,t)=>({ApiCreditDimensionBaseSchema:e.object({match:t,priority:e.number().int().optional().meta({description:"Breaks ties between dimensions that match the same number of keys. Higher wins."})})}))(Q,bc),{refineGraduatedTiers:xc}=(e=>({refineGraduatedTiers:(n,r)=>{let o=e(n.tiers.map(a=>a.to));for(let{index:a,message:l}of o)r.addIssue({code:"custom",message:l,path:["tiers",a,"to"]})}}))(Em),{ApiFeatureMarkupsOverrideSchema:Bm}=((e,t,n)=>({ApiFeatureMarkupsOverrideSchema:e.strictObject({default_markup:e.number().min(-100).optional().meta({description:"Default percentage markup for customers on this plan. Use -100 to make usage free."}),provider_markups:t.meta({description:"Per-provider markup percentages for customers on this plan."}),model_markups:n.meta({description:"Per-model markup overrides for customers on this plan."})})}))(Q,Tm,Im),{isValidCurrencyCode:qm}=(e=>({isValidCurrencyCode:n=>!!n&&e.has(n.toLowerCase())}))(Dm),{ApiCreditDimensionSchema:Fm}=((e,t,n,r)=>({ApiCreditDimensionSchema:e.union([t.extend({tier_behavior:e.literal("graduated"),tiers:e.array(n).min(1)}).strict().superRefine(r),t.extend({credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group when this dimension matches."})}).strict()])}))(Q,zm,mc,xc),{CurrencyCodeSchema:Sc}=((e,t)=>({CurrencyCodeSchema:e.string().refine(t,"must be a Stripe-supported currency code").meta({description:"Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp')."})}))(Q,qm),{AdditionalCurrencyTierSchema:Nm}=((e,t)=>({AdditionalCurrencyTierSchema:e.object({currency:t,amount:e.number().optional().meta({description:"Per-unit amount for this tier in this currency."}),flat_amount:e.number().optional().meta({description:"Flat amount for this tier in this currency, if the tier uses one."})}).refine(r=>r.amount!==void 0||r.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]})}))(Q,Sc),{ApiCreditSchemaItemBaseSchema:vc}=((e,t,n,r)=>({ApiCreditSchemaItemBaseSchema:e.object({metered_feature_id:e.string().nonempty().meta({description:"ID of the metered feature that draws from this credit system."}),billing_units:e.number().positive().optional().meta({description:"Number of metered-feature units priced together. Defaults to one when omitted."}),dimensions:e.record(t,n).optional().meta({description:"Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies."}),multipliers:e.record(t,r).optional().meta({description:"Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed."})})}))(Q,Rm,Fm,Mm),{ApiFlatCreditSchemaItemSchema:Vm}=((e,t)=>({ApiFlatCreditSchemaItemSchema:e.extend({credit_cost:t.number().min(0).meta({description:"Credits consumed per billing-unit group."})}).strict()}))(vc,Q),{AdditionalCurrencyPriceSchema:Um}=((e,t)=>({AdditionalCurrencyPriceSchema:e.object({currency:t,amount:e.number().meta({description:"Price amount in this currency. Set explicitly per currency, not converted from the base amount."})})}))(Q,Sc),{AdditionalCurrencyTierArraySchema:$m}=((e,t,n,r)=>({AdditionalCurrencyTierArraySchema:e.array(t).refine(n,{message:r})}))(Q,Nm,uc,pc),{ApiGraduatedCreditSchemaItemSchema:Gm}=((e,t,n,r)=>({ApiGraduatedCreditSchemaItemSchema:e.extend({tier_behavior:t.literal("graduated"),tiers:t.array(n).min(1)}).strict().superRefine(r)}))(vc,Q,mc,xc),{AdditionalCurrencyPriceArraySchema:Ic}=((e,t,n,r)=>({AdditionalCurrencyPriceArraySchema:e.array(t).refine(n,{message:r})}))(Q,Um,uc,pc),{ApiUsageTierWithCurrenciesSchema:Km}=((e,t,n)=>({ApiUsageTierWithCurrenciesSchema:e.object({to:e.number().or(e.literal(t)),amount:e.number().optional(),flat_amount:e.number().optional(),additional_currencies:n.optional().meta({description:"Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies."})}).refine(o=>o.amount!==void 0||o.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]}).transform(o=>({...o,amount:o.amount??0})).pipe(e.object({to:e.number().or(e.literal(t)),amount:e.number(),flat_amount:e.number().optional(),additional_currencies:n.optional()}))}))(Q,gm,$m),{ApiCreditSchemaItemSchema:Lm}=((e,t,n)=>({ApiCreditSchemaItemSchema:e.union([t,n])}))(Q,Gm,Vm),{BasePriceParamsSchema:Zm}=((e,t,n,r)=>({BasePriceParamsSchema:e.omit({display:!0}).extend({interval_count:t({schema:n.number().optional(),defaultValue:1,description:"Number of intervals per billing cycle. Defaults to 1."}),additional_currencies:r.optional().meta({description:"Base price amounts in additional currencies. The base 'amount' is in the org's default currency."}),base_currency:n.string().optional().meta({internal:!0}),entitlement_id:n.string().optional().meta({internal:!0}),price_id:n.string().optional().meta({internal:!0}),stripe_price_id:n.string().optional().meta({description:"Stripe price id this base price is billed under. Set by sync flows to capture the actual Stripe price when it differs from the catalog default.",internal:!0})}).meta({title:"BasePrice",description:"Base price configuration for a plan."})}))(Pm,lm,Q,Ic),{PlanItemPriceParamsSchema:Hm}=((e,t,n,r,o,a,l)=>({PlanItemPriceParamsSchema:e.object({stripe_price_id:e.string().nullish().transform(d=>d??void 0).meta({description:"Stripe price id this feature price is billed under. Set by sync flows to preserve an existing Stripe price.",internal:!0}).optional(),amount:e.number().optional().meta({description:"Price per billing_units after included usage. Either 'amount' or 'tiers' is required."}),additional_currencies:t.optional().meta({description:"Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'."}),tiers:e.array(n).optional().meta({description:"Tiered pricing. Either 'amount' or 'tiers' is required."}),tier_behavior:e.enum(r).optional(),interval:e.enum(o).meta({description:"Billing interval. For consumable features, should match reset.interval."}),interval_count:e.number().default(1).optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),billing_units:e.number().default(1).optional().meta({description:"Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200)."}),billing_method:e.enum(a).meta({description:"'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go."}),allocated_billing:l,max_purchase:e.number().nullish().meta({description:"Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit."})})}))(Q,Ic,Km,hm,sc,lc,km),{ApiFeatureOverrideSchema:Jm}=((e,t,n)=>({ApiFeatureOverrideSchema:e.strictObject({credit_schema:e.array(t).optional().meta({description:"For credit system features: replaces the feature's credit_schema entirely for customers on this plan."}),markups:n.optional().meta({description:"For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's."})})}))(Q,Lm,Bm),{InvoiceBasePriceParamsSchema:Oc}=((e,t)=>({InvoiceBasePriceParamsSchema:e.pick({amount:!0,interval:!0,interval_count:!0}).extend({processors:t.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(Zm,hc),{InvoiceItemPriceParamsSchema:Wm}=((e,t)=>({InvoiceItemPriceParamsSchema:e.pick({amount:!0,tiers:!0,tier_behavior:!0,interval:!0,interval_count:!0,billing_units:!0,billing_method:!0}).extend({processors:t.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(Hm,hc),{InvoiceLicenseQuantitySchema:Qm}=((e,t,n)=>({InvoiceLicenseQuantitySchema:e.object({license_plan_id:e.string().meta({description:"The license plan linked to the parent plan."}),quantity:e.number().int().nonnegative().meta({description:"Billable seats, exclusive of any included seats."}),customize:e.object({price:t.nullable().optional()}).strict().optional().meta({description:"Override the license's per-seat price on this invoice."}),feature_quantities:e.array(n).optional().meta({description:"Feature charges priced through the license plan."}),prorate:e.boolean().optional().meta({description:"Whether to prorate seat charges against period_start / period_end. Defaults to true."})}).strict()}))(Q,Oc,yc),{InvoiceCustomizeItemSchema:Xm}=((e,t,n)=>({InvoiceCustomizeItemSchema:e.object({feature_id:e.string().meta({description:"The feature whose pricing is overridden on this invoice."}),price:t.optional().meta({description:"Pricing to use for this feature on this invoice."}),feature_override:n.pick({credit_schema:!0}).strict().optional().meta({description:"For credit-system features: a credit rate card to use when converting `usage` on this invoice."})}).strict()}))(Q,Wm,Jm),{InvoiceCustomizeSchema:Ym}=((e,t,n)=>({InvoiceCustomizeSchema:e.object({price:t.nullable().optional().meta({description:"Override the plan's base price for this invoice. Pass null or an amount of 0 to omit the base price line."}),items:e.array(n).optional().meta({description:"Override feature pricing for this invoice. Only pricing fields are accepted; grants, resets and rollovers are not part of an invoice."})}).strict().meta({title:"InvoiceCustomize",description:"Pricing overrides applied to this invoice only. The catalog and the customer's plan are not changed."})}))(Q,Oc,Xm),{InvoicePlanParamsSchema:ed}=((e,t,n,r,o)=>({InvoicePlanParamsSchema:e.object({plan_id:e.string().meta({description:"The catalog plan (or variant) whose pricing to use."}),version:e.number().optional().meta({description:"Plan version. Defaults to the active version."}),customize:t.optional(),feature_quantities:e.array(n).optional(),license_quantities:e.array(r).optional(),discounts:e.array(o).optional().meta({description:"Discounts applied only to this plan's lines."}),prorate:e.boolean().optional().meta({description:"Whether to prorate the base price against period_start / period_end. Defaults to true."})}).strict()}))(Q,Ym,yc,Qm,fc),{CreateInvoiceParamsSchema:ln}=((e,t,n,r,o)=>({CreateInvoiceParamsSchema:e.object({customer_id:e.string().meta({description:"The customer to invoice."}),plans:e.array(t).optional(),custom_line_items:e.array(n).optional().meta({description:"Charges that are not tied to any plan or feature."}),discounts:e.array(r).optional().meta({description:"Discounts applied to the whole invoice."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template whose footer, memo and default payment terms are applied."}),net_terms_days:e.number().int().positive().optional().meta({description:"Days until the invoice is due. Defaults to the template's terms, then the org default."}),tax_rate_id:e.string().optional().meta({description:"Stripe tax rate ID (txr_...) applied to every line."}),period_start:o.optional().meta({description:"Start of the period being invoiced, in milliseconds. Prorated lines are charged for period_start \u2192 period_end against one price interval starting at period_start."}),period_end:o.optional().meta({description:"End of the period being invoiced, in milliseconds."}),preview:e.boolean().optional().meta({description:"If true, returns the calculated lines and totals without creating an invoice."})}).strict().refine(l=>l.period_start===void 0==(l.period_end===void 0),{message:"period_start and period_end must be provided together."}).refine(l=>l.period_start===void 0||l.period_end===void 0||l.period_end>l.period_start,{message:"period_end must be after period_start."})}))(Q,ed,jm,fc,Am);var wc=i.strictObject({requestId:i.uuid(),predecessorOperationId:i.uuid().optional(),invoiceMode:qt.optional(),entityId:i.uuid().optional(),billingSubscriptionId:i.uuid().optional(),newBillingSubscription:i.literal(!0).optional(),offerId:i.uuid().optional(),nativeOffer:pn.optional(),plans:i.array(i.strictObject({productVersionId:i.uuid(),seatQuantities:i.record(Ar,i.number().int().min(0).max(1e4)).optional(),featureQuantities:i.record(i.uuid(),i.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100,"At most 100 feature quantities").optional()})).min(1).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Plan versions must be unique"),provider:i.enum(["stripe","apple","google","merchant"]),currency:ie}).refine(e=>!e.offerId||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.nativeOffer!==void 0),"Held offers apply to new purchases; existing subscriptions use billing coupons").refine(e=>!e.nativeOffer||["apple","google"].includes(e.provider)&&e.plans.length===1,"A store selection applies to exactly one native SKU").refine(e=>!e.newBillingSubscription||["stripe","merchant"].includes(e.provider)&&!e.billingSubscriptionId,"A new billing subscription has no existing subscription target").refine(e=>!e.invoiceMode?.enabled||e.provider==="stripe"&&!e.entityId,"Invoice mode requires a Stripe subscription without an Entity target"),Nt=i.strictObject({operationId:i.uuid()}),Ee=i.number().int().min(0).max(1e8),td=i.strictObject({lineId:i.uuid(),productVersionId:i.uuid(),productName:i.string().min(1).max(80),interval:i.enum(["free","week","month","year","one_time"]),intervalCount:i.number().int().min(1).max(156).optional(),baseAmountMinor:Ee,seats:i.array(i.strictObject({key:Ar,quantity:i.number().int().min(0).max(1e4),includedQuantity:i.number().int().min(0).max(1e4),maximumQuantity:i.number().int().min(0).max(1e4),unitAmountMinor:Ee})).max(20),prepaid:i.array($s).max(100).optional(),catalogAmountMinor:Ee,trial:i.strictObject({days:i.number().int().min(1).max(730),cardRequired:i.boolean()}).nullable()}).refine(e=>new Set(e.seats.map(t=>t.key)).size===e.seats.length&&e.seats.every(t=>t.quantity>=t.includedQuantity&&t.quantity<=t.maximumQuantity)&&e.baseAmountMinor+e.seats.reduce((t,n)=>t+n.unitAmountMinor*(n.quantity-n.includedQuantity),0)+(e.prepaid??[]).reduce((t,n)=>t+or({quantity:n.quantity,unitAmountMinor:n.unitAmountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}}),0)===e.catalogAmountMinor,"Quote must retain its published base price and component quantities"),_c=i.string().regex(/^[A-Za-z0-9_-]{1,200}$/),nd=i.strictObject({id:_c,name:i.string().min(1).max(40),percent_off:i.number().gt(0).max(100).optional(),amount_off:i.number().int().positive().optional(),currency:i.string().regex(/^[a-z]{3}$/).optional(),duration:i.enum(["once","repeating","forever"]),duration_in_months:i.number().int().min(1).max(36).optional()}).refine(e=>e.percent_off===void 0!=(e.amount_off===void 0)&&e.amount_off===void 0==(e.currency===void 0)&&e.duration==="repeating"==(e.duration_in_months!==void 0),"A Stripe coupon has one percentage or amount and months only when repeating"),rd=i.strictObject({subscriptionId:i.string().regex(/^sub_[A-Za-z0-9]+$/),customerId:i.string().regex(/^cus_[A-Za-z0-9]+$/),sourceItems:i.array(i.strictObject({id:i.string(),price_id:i.string(),quantity:i.number().int().nonnegative(),discounts:i.array(i.strictObject({id:i.string(),coupon:i.string(),start:i.number(),end:i.number().nullable()})).optional()})).min(1).max(100),prorationDate:i.number().int().nonnegative(),amountMinor:i.number().int().positive(),periodStartMs:i.number(),periodEndMs:i.number()}),Pc=i.strictObject({invoiceMode:qt.optional(),append:rd.optional(),provider:i.literal("stripe"),executor:i.enum(["indiana","merchant"]),accountId:i.string().regex(/^acct_[A-Za-z0-9]+$/),mode:i.enum(["payment","subscription"]),lineItems:i.array(i.strictObject({price:i.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),quantity:i.number().int().min(1).max(1e4),priceId:i.uuid(),productName:i.string().min(1).max(80),amountMinor:i.number().int().min(0).max(1e8),currency:i.string().regex(/^[a-z]{3}$/),interval:i.enum(["week","month","year","one_off"]),intervalCount:i.number().int().min(1).max(52),slot:i.enum(["stripe_price_id","stripe_empty_price_id"]),tiers:i.strictObject({mode:i.enum(["graduated","volume"]),tiers:i.array(i.strictObject({upTo:i.number().int().min(1).max(1e6).nullable(),unitAmountMinor:i.number().int().min(0).max(1e8),flatAmountMinor:i.number().int().min(0).max(1e8).optional()})).min(2).max(12)}).nullable()})).min(1).max(100),discounts:i.array(i.strictObject({coupon:_c,terms:nd})).max(1),trialPeriodDays:i.number().int().min(1).max(730).nullable(),metadata:i.strictObject({grooveCheckoutId:i.uuid(),grooveCustomerId:i.uuid()}),expiresAt:i.iso.datetime({offset:!0})}),mn=i.strictObject({operationId:i.uuid(),entityId:i.uuid().nullable(),billingSubscriptionId:i.uuid().nullable(),discount:i.strictObject({offerId:i.uuid(),couponId:i.uuid(),discount:At,duration:He,amountMinor:Ee,allocations:i.array(i.strictObject({productVersionId:i.uuid(),amountMinor:Ee})).min(1).max(20),expiresAt:i.iso.datetime({offset:!0})}).nullable(),charge:i.strictObject({effectiveAt:i.iso.datetime({offset:!0}),periodEndsAt:i.iso.datetime({offset:!0}),debitMinor:Ee,discountMinor:Ee,taxMinor:Ee,totalMinor:Ee}).nullable(),expiresAt:i.iso.datetime({offset:!0}),provider:i.enum(["stripe","apple","google","merchant"]),nativeOffer:pn.optional(),currency:ie,lines:i.array(td).min(1).max(20),catalogAmountMinor:Ee,automaticTax:i.boolean(),execution:i.union([Pc,mr]).nullable()}).refine(e=>e.provider==="merchant"?e.execution?.provider==="merchant"&&e.execution.operationId===e.operationId&&e.execution.catalogAmountMinor===e.catalogAmountMinor&&e.execution.currency===e.currency&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&e.execution.discount?.grantId===e.discount?.offerId:e.provider==="stripe"?e.execution?.provider!=="merchant"&&(e.lines[0]?.trial?.cardRequired===!1&&!e.execution?.invoiceMode?.enabled?e.execution===null&&e.discount===null:e.execution!==null&&e.execution.metadata.grooveCheckoutId===e.operationId&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.mode===(e.lines.some(t=>!["one_time","free"].includes(t.interval))?"subscription":"payment")&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&(e.execution.executor==="indiana"||e.execution.lineItems.every(t=>t.price!==null))&&e.execution.discounts.every(t=>t.coupon===t.terms.id)&&e.execution.discounts.length===(e.discount?1:0)&&e.execution.discounts.every(t=>e.discount!==null&&(t.coupon===e.discount.couponId||e.discount.discount.type==="amount"&&t.coupon===`${e.discount.couponId}_credit_${e.discount.offerId}_${t.terms.amount_off}`&&t.terms.amount_off===e.discount.discount.amountOffCents&&t.terms.currency?.toUpperCase()===e.currency&&t.terms.duration==="once"))):e.execution===null,"Stripe execution must carry the quote identity, expiry, mode, trial and held coupon").refine(e=>(!e.discount||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.discount.duration.type==="once")&&e.discount.amountMinor<=e.catalogAmountMinor&&e.discount.allocations.length===e.lines.length&&e.discount.allocations.every((t,n)=>{let r=e.lines[n];return r!==void 0&&t.productVersionId===r.productVersionId&&t.amountMinor<=r.catalogAmountMinor})&&e.discount.allocations.reduce((t,n)=>t+n.amountMinor,0)===e.discount.amountMinor)&&(["stripe","merchant"].includes(e.provider)?e.nativeOffer===void 0:e.nativeOffer!==void 0&&e.lines.length===1&&e.nativeOffer.discountMinor<=e.catalogAmountMinor&&e.nativeOffer.trialDays===(e.lines[0]?.trial?.days??null)&&(!e.discount||e.nativeOffer.discountMinor===e.discount.amountMinor))&&(!e.charge||e.billingSubscriptionId!==null&&e.charge.totalMinor===e.charge.debitMinor-e.charge.discountMinor+e.charge.taxMinor&&e.charge.discountMinor<=e.charge.debitMinor&&Date.parse(e.charge.periodEndsAt)>Date.parse(e.charge.effectiveAt))&&new Set(e.lines.map(t=>t.lineId)).size===e.lines.length&&e.lines.reduce((t,n)=>t+n.catalogAmountMinor,0)===e.catalogAmountMinor,"Quote lines must conserve the catalog amount"),dn=i.strictObject({operationId:i.uuid(),orderId:i.uuid(),append:i.boolean().optional(),invoiceMode:i.boolean().optional(),status:i.enum(["pending","complete","cancelled","failed"]),executor:i.enum(["indiana","merchant"]),checkoutUrl:i.url().refine(e=>new URL(e).protocol==="https:").nullable(),execution:i.union([Pc,mr]).nullable(),currency:ie,catalogAmountMinor:Ee,taxMinor:Ee,totalMinor:i.number().int().min(0).max(2e8).nullable(),quoteFinalized:i.boolean(),nativePurchase:Zi.nullable(),confirmedAt:i.iso.datetime({offset:!0}).nullable().optional(),quote:mn.optional(),merchantExecution:Mt.nullable().optional(),problem:Rn.nullable().optional(),authority:br.optional()}).refine(e=>(e.checkoutUrl===null||e.executor==="indiana"||e.merchantExecution?.type==="purchase")&&(e.execution===null||e.executor==="merchant"),"Only Indiana-executed purchases carry a Checkout URL and only record-only purchases carry execution instructions"),Dr=i.strictObject({enabled:i.literal(!0),featureIds:i.array(i.uuid()).min(1).max(100).refine(e=>new Set(e).size===e.length,"Feature IDs must be unique").optional()}),Cc=i.strictObject({requestId:i.uuid(),invoiceMode:qt.optional(),membershipId:i.uuid(),carryOverBalances:Dr.optional(),carryOverUsages:Dr.optional(),membershipIds:i.array(i.uuid()).min(1).max(20).optional(),prorationBehavior:i.enum(["prorate_immediately","none","bill_difference"]).optional(),timing:i.enum(["immediate","renewal","store"]),change:i.discriminatedUnion("type",[i.strictObject({type:i.literal("plan"),productVersionId:i.uuid()}),i.strictObject({type:i.literal("seats"),licenseKey:Ar,quantity:i.number().int().min(0).max(1e4)}),i.strictObject({type:i.literal("quantity"),internal_feature_id:i.uuid(),quantity:i.number().int().min(0).max(1e4)}),i.strictObject({type:i.literal("cancel")}),i.strictObject({type:i.literal("uncancel")}),i.strictObject({type:i.literal("billing_cycle"),billingCycleAnchor:i.union([i.literal("now"),i.number().int().positive().max(0xe677d21fdbff)])})])}).refine(e=>e.timing!=="store"||e.change.type==="plan","Store timing applies to a native plan replacement").refine(e=>e.change.type!=="billing_cycle"||e.timing===(e.change.billingCycleAnchor==="now"?"immediate":"renewal"),"Use immediate for now and renewal for a future millisecond anchor").refine(e=>!e.membershipIds||["cancel","uncancel"].includes(e.change.type)&&e.membershipIds.includes(e.membershipId)&&new Set(e.membershipIds).size===e.membershipIds.length,"Grouped actions require unique cancel/uncancel targets including the primary membership").refine(e=>!e.carryOverBalances&&!e.carryOverUsages||e.change.type==="plan"&&e.timing==="immediate","Carry applies only to immediate upgrades").refine(e=>!e.prorationBehavior||e.change.type==="quantity","prorationBehavior applies to prepaid quantity changes"),Tr=i.string().regex(/^price_[A-Za-z0-9]+$/),jc=i.strictObject({grooveUpdateId:i.uuid(),grooveCustomerId:i.uuid()}),Ac=i.strictObject({price:Tr.nullable(),priceId:i.uuid().optional(),quantity:i.number().int().min(0).max(1e4)}),kc=i.strictObject({provider:i.literal("stripe"),invoiceMode:qt.optional(),executor:i.enum(["indiana","merchant"]),accountId:i.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:i.string().regex(/^sub_[A-Za-z0-9]+$/),action:i.enum(["update","cancel","schedule","release"]),update:i.strictObject({items:i.array(Ac).max(20),remove:i.array(Tr).max(20),restoreItems:i.array(i.strictObject({price:Tr,quantity:i.number().int().min(0).max(1e4)})).min(1).max(20).optional(),prorationBehavior:i.enum(["always_invoice","create_prorations","none"]).optional(),prorationDate:i.number().int().positive().optional(),paymentBehavior:i.literal("error_if_incomplete").optional(),cancelAtPeriodEnd:i.boolean().optional(),clearCancelAt:i.literal(!0).optional(),billingCycleAnchorNow:i.literal(!0).optional(),metadata:jc}).nullable(),cancel:i.strictObject({prorate:i.literal(!1),invoiceNow:i.literal(!1)}).nullable(),schedule:i.strictObject({currentItems:i.array(i.strictObject({price:Tr,quantity:i.number().int().min(0).max(1e4)})).max(20),nextItems:i.array(Ac).min(1).max(20),switchAt:i.number().int().positive(),interval:i.enum(["week","month","year"]),intervalCount:i.number().int().min(1).max(52),resetBillingCycleAnchor:i.literal(!0).optional(),metadata:jc}).nullable(),release:i.strictObject({schedule:i.string().regex(/^sub_sched_[A-Za-z0-9]+$/)}).nullable(),expiresAt:i.iso.datetime({offset:!0})}).refine(e=>["update","cancel","schedule","release"].every(t=>e[t]!==null==(e.action===t))&&(e.executor==="indiana"||[...e.update?.items??[],...e.schedule?.nextItems??[]].every(t=>t.price!==null)),"Stripe update execution carries exactly its action, with bound Prices for the merchant"),zr=i.strictObject({carryOverBalances:Dr.optional(),carryOverUsages:Dr.optional(),operationId:i.uuid(),membershipId:i.uuid(),productVersionId:i.uuid(),timing:i.enum(["immediate","renewal"]),effectiveAt:i.iso.datetime({offset:!0}),expiresAt:i.iso.datetime({offset:!0}),currency:ie,creditMinor:Ee,debitMinor:Ee,discountMinor:Ee,taxMinor:Ee,totalMinor:Ee,retainedProductVersionIds:i.array(i.uuid()).max(19),execution:i.union([kc,dr])}),id=i.strictObject({operationId:i.uuid(),invoiceMode:i.boolean().optional(),membershipId:i.uuid(),productVersionId:i.uuid(),status:i.enum(["prepared","quoted","confirmed","pending","scheduled","effective","cancelled","failed"]),timing:i.enum(["immediate","renewal"]),effectiveAt:i.iso.datetime({offset:!0}),checkoutUrl:i.url().refine(e=>new URL(e).protocol==="https:").nullable(),executor:i.enum(["indiana","merchant"]),execution:i.union([kc,dr]).nullable(),confirmedAt:i.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:Mt.nullable().optional(),problem:Rn.nullable().optional(),quote:zr.optional(),authority:br.optional()}).refine(e=>e.execution===null||e.executor==="merchant","Only record-only changes carry execution instructions"),od=i.strictObject({operationId:i.uuid(),membershipId:i.uuid(),productVersionId:i.uuid(),timing:i.literal("store"),effectiveAt:i.null(),expiresAt:i.iso.datetime({offset:!0}),currency:ie,creditMinor:i.null(),debitMinor:i.null(),discountMinor:i.null(),taxMinor:i.null(),totalMinor:i.null(),retainedProductVersionIds:i.array(i.uuid()).max(19),store:i.strictObject({provider:i.enum(["apple","google"]),productId:i.string().min(1).max(255),catalogAmountMinor:Ee,policy:i.enum(["apple_store","google_full_price"])})}),ad=i.strictObject({operationId:i.uuid(),membershipId:i.uuid(),productVersionId:i.uuid(),status:i.enum(["prepared","pending","effective","cancelled","failed"]),timing:i.literal("store"),effectiveAt:i.iso.datetime({offset:!0}).nullable(),checkoutUrl:i.null(),nativePurchase:Zi.nullable()}),Rc=i.union([zr,od]),Ji=i.union([id,ad]),Un=i.number().int().positive().max(2e8),Ft=i.number().int().min(0).max(2e8),Ec=i.strictObject({requestId:i.uuid(),invoiceId:i.uuid(),mode:i.enum(["full","partial"]),amountMinor:Un.optional(),entitlementAction:i.enum(["retain","revoke"])}).refine(e=>e.mode==="partial"==(e.amountMinor!==void 0),"A partial refund states amountMinor; a full refund refunds the remaining amount"),Mc=i.strictObject({provider:i.literal("stripe"),executor:i.enum(["indiana","merchant"]),accountId:i.string().regex(/^acct_[A-Za-z0-9]+$/),invoice:i.string().regex(/^in_[A-Za-z0-9]+$/),amountMinor:Un,currency:i.string().regex(/^[a-z]{3}$/),metadata:i.strictObject({indianaRefundId:i.uuid()}),idempotencyKey:i.string().regex(/^indiana-refund-[0-9a-f-]{36}$/),cancelSubscriptions:i.array(i.string().regex(/^sub_[A-Za-z0-9]+$/)).max(20)}),Wi=i.strictObject({operationId:i.uuid(),invoiceId:i.uuid(),providerInvoiceId:i.string().min(1).max(200),currency:ie,paidMinor:Ft,refundedMinor:Ft,pendingMinor:Ft,amountMinor:Un,mode:i.enum(["full","partial"]),entitlementAction:i.enum(["retain","revoke"]),revokes:i.strictObject({customerProductIds:i.array(i.uuid()).max(100),subscriptionIds:i.array(i.string().min(1).max(200)).max(20)}),execution:i.union([Mc,fr]),expiresAt:i.iso.datetime({offset:!0})}).refine(e=>e.amountMinor<=e.paidMinor-e.refundedMinor-e.pendingMinor&&e.execution.amountMinor===e.amountMinor&&(e.execution.provider==="merchant"?e.execution.merchantInvoiceId===e.providerInvoiceId&&e.execution.operationId===e.operationId&&e.execution.currency===e.currency:e.execution.invoice===e.providerInvoiceId&&e.execution.metadata.indianaRefundId===e.operationId&&e.execution.currency===e.currency.toLowerCase())&&(e.entitlementAction==="revoke"||e.revokes.customerProductIds.length===0&&e.revokes.subscriptionIds.length===0),"Refund quote must stay within the refundable amount and match its execution"),Br=i.strictObject({operationId:i.uuid(),invoiceId:i.uuid(),providerInvoiceId:i.string().min(1).max(200),status:i.enum(["quoted","pending","succeeded","failed","expired"]),executor:i.enum(["indiana","merchant"]),currency:ie,amountMinor:Un,mode:i.enum(["full","partial"]),entitlementAction:i.enum(["retain","revoke"]),refundId:i.string().min(1).max(200).nullable(),quote:Wi.optional(),execution:i.union([Mc,fr]).nullable(),confirmedAt:i.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:Mt.nullable().optional(),problem:Rn.nullable().optional(),authority:br.optional(),failureReason:i.string().min(1).max(200).nullable(),createdAt:i.iso.datetime({offset:!0}),completedAt:i.iso.datetime({offset:!0}).nullable()}).refine(e=>(e.execution===null||e.executor==="merchant"&&e.status==="quoted")&&(e.status!=="succeeded"||e.refundId!==null),"Only quoted record-only refunds carry instructions; a succeeded refund names its Stripe refund"),gy=i.strictObject({invoiceId:i.uuid(),currency:ie,paidMinor:Ft,refundedMinor:Ft,pendingMinor:Ft,refundableMinor:Ft,executor:i.enum(["indiana","merchant"]).nullable(),canRefund:i.boolean(),operations:i.array(Br).max(50)}).refine(e=>e.operations.every(t=>t.invoiceId===e.invoiceId),"Refund operations belong to the invoice"),hy=i.strictObject({requestId:i.uuid(),mode:i.enum(["full","partial"]),amountMinor:Un.optional(),entitlementAction:i.enum(["retain","revoke"])}).refine(e=>e.mode==="partial"==(e.amountMinor!==void 0),"A partial refund states amountMinor; a full refund refunds the remaining amount");var Tc=ye.strictObject({requestId:ye.uuid(),targets:ye.array(ye.strictObject({membershipId:ye.uuid(),action:ye.enum(["cancel","uncancel"]),timing:ye.enum(["immediate","renewal"])}).refine(e=>e.action!=="uncancel"||e.timing==="immediate","Restoration is immediate")).min(1).max(100)}).refine(e=>new Set(e.targets.map(t=>t.membershipId)).size===e.targets.length,"Duplicate batch target"),qr=ye.strictObject({batchId:ye.uuid()}),sd=ye.strictObject({operationId:ye.uuid(),membershipIds:ye.array(ye.uuid()).min(1).max(20),provider:ye.enum(["stripe","apple","google"]),action:ye.enum(["cancel","uncancel"]),timing:ye.enum(["immediate","renewal"]),status:ye.enum(["prepared","confirmed","pending","scheduled","effective","cancelled","failed","store_action_required"]),quote:zr.nullable(),managementUrl:ye.url().nullable(),failureCode:ye.enum(["provider_unavailable","invalid_evidence","pending_payment"]).nullable()}),$n=ye.strictObject({batchId:ye.uuid(),ready:ye.boolean(),status:ye.enum(["prepared","cancelled","expired","pending","partial","effective","action_required"]),createdAt:ye.iso.datetime({offset:!0}),acceptedAt:ye.iso.datetime({offset:!0}).nullable(),groups:ye.array(sd).min(1).max(100)});import{z as te}from"zod";var cd=te.string().trim().min(1).max(240),Qi={requestId:te.uuid(),reason:cd},Fr=te.discriminatedUnion("action",[te.strictObject({...Qi,action:te.literal("start"),productVersionId:te.uuid(),entityId:te.uuid().optional(),days:te.number().int().min(1).max(730).optional()}),te.strictObject({...Qi,action:te.literal("extend"),membershipId:te.uuid(),days:te.number().int().min(1).max(730)}),te.strictObject({...Qi,action:te.literal("end"),membershipId:te.uuid()})]),Dc=te.strictObject({operationId:te.uuid()}),zc=te.iso.datetime({offset:!0}),ud=te.strictObject({provider:te.literal("stripe"),executor:te.enum(["indiana","merchant"]),accountId:te.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:te.string().regex(/^sub_[A-Za-z0-9]+$/),trialEnd:te.union([te.literal("now"),zc]),prorationBehavior:te.literal("none")}),Xi=te.strictObject({operationId:te.uuid(),action:te.enum(["start","extend","end"]),status:te.enum(["pending","effective"]),managedBy:te.enum(["indiana","stripe"]),membershipIds:te.array(te.uuid()).min(1).max(20),endsAt:zc.nullable(),execution:ud.nullable()}).refine(e=>e.execution!==null==(e.managedBy==="stripe"&&e.status==="pending")&&e.action==="end"==(e.endsAt===null)&&(e.action!=="start"||e.managedBy==="indiana")&&(e.execution===null||e.execution.trialEnd==="now"==(e.action==="end")),"Only a pending Stripe trial change carries execution instructions"),Iy=te.strictObject({groupId:te.uuid(),productVersionId:te.uuid(),enabled:te.boolean()});import{z as me}from"zod";var Bc=me.strictObject({requestId:me.uuid(),currency:ie,makeDefault:me.boolean()}),qc=me.strictObject({setupId:me.uuid()}),pd=me.strictObject({provider:me.literal("stripe"),executor:me.literal("merchant"),accountId:me.string().regex(/^acct_[A-Za-z0-9]+$/),mode:me.literal("setup"),currency:me.string().regex(/^[a-z]{3}$/),customer:me.string().regex(/^cus_[A-Za-z0-9]+$/).nullable(),clientReferenceId:me.uuid(),metadata:me.strictObject({grooveProjectId:me.uuid(),grooveEnvironmentId:me.uuid(),grooveCustomerId:me.uuid(),groovePaymentSetupId:me.uuid()}),setDefaultPaymentMethod:me.boolean(),expiresAt:me.iso.datetime({offset:!0})}),Yi=me.strictObject({id:me.uuid(),provider:me.literal("stripe"),status:me.enum(["prepared","complete","expired"]),currency:ie,makeDefault:me.boolean(),url:me.url().nullable(),createdAt:me.iso.datetime({offset:!0}),expiresAt:me.iso.datetime({offset:!0}),completedAt:me.iso.datetime({offset:!0}).nullable(),execution:pd.nullable()});import{z as Me}from"zod";var Fc=Me.union([Me.string(),Me.number(),Me.boolean(),Me.null()]),Nc=Me.strictObject({customerId:Me.uuid()}),Vc=Me.strictObject({customerId:Me.uuid(),provider:Me.literal("stripe"),checkedAt:Me.iso.datetime({offset:!0}),status:Me.enum(["consistent","drifted","incomplete"]),checkedSubscriptions:Me.number().int().nonnegative(),differences:Me.array(Me.strictObject({subscriptionId:Me.string().startsWith("sub_"),itemId:Me.string().nullable(),field:Me.enum(["subscription","status","currency","cancelAtPeriodEnd","item","price","product","quantity","periodStart","periodEnd","trialEnd","evidence"]),expected:Fc,actual:Fc})).max(1e4)});import{z as J}from"zod";var Nr=J.iso.datetime({offset:!0}),Vr=J.strictObject({createdAt:Nr,id:J.uuid()}),Ur=J.strictObject({customerId:J.uuid().optional(),entityId:J.uuid().optional(),productId:J.string().min(1).max(256).optional(),provider:J.enum(["stripe","apple","google","merchant","free"]).optional(),status:J.enum(["trial","active","past_due","ended","refunded"]).optional(),cursor:Vr.optional(),limit:J.number().int().min(1).max(100).optional()}),eo={id:J.uuid(),customerId:J.uuid(),entityId:J.uuid().nullable(),productId:J.string().min(1).max(256),productVersionId:J.uuid(),name:J.string().min(1).max(120),provider:J.enum(["stripe","apple","google","merchant","free"]),createdAt:Nr},ld=J.strictObject({...eo,status:J.enum(["trial","active","past_due","ended"]),cancelAtPeriodEnd:J.boolean(),billingSubscriptionId:J.uuid().nullable()}),md=J.strictObject({...eo,status:J.enum(["active","ended","refunded"]),orderId:J.uuid().nullable(),transactionId:J.uuid().nullable(),currency:ie.nullable(),amountMinor:J.string().regex(/^(0|[1-9]\d{0,17})$/).nullable()}),dd=J.strictObject({...eo,status:J.enum(["blocked","resolved"]),conflict:J.strictObject({detectedAt:Nr,blockingMembershipIds:J.array(J.uuid()).min(1).max(100),transactionId:J.uuid()}),resolvedAt:Nr.nullable()}),Uc=Ur.extend({status:J.enum(["blocked","resolved"]).optional()}),$c=J.strictObject({customerId:J.uuid(),orderId:J.uuid()}),Gc=J.strictObject({orderId:J.uuid(),status:J.enum(["blocked","resolved"])}),Kc=J.strictObject({items:J.array(ld).max(100),nextCursor:Vr.nullable()}),Lc=J.strictObject({items:J.array(md).max(100),nextCursor:Vr.nullable()}),Zc=J.strictObject({items:J.array(dd).max(100),nextCursor:Vr.nullable()});import{z as ge}from"zod";var Hc=ge.union([ge.strictObject({intent:ge.literal("read"),requestId:ge.uuid(),purchaseIntentId:ge.uuid()}),ge.strictObject({requestId:ge.uuid(),provider:ge.literal("apple"),purchaseIntentId:ge.uuid(),productId:ge.string().min(1).max(255).optional(),signedTransaction:ge.string().min(1).max(131072)}),ge.strictObject({requestId:ge.uuid(),provider:ge.literal("google"),purchaseIntentId:ge.uuid(),productId:ge.string().min(1).max(255).optional(),purchaseToken:ge.string().min(1).max(16384)})]),Jc=ge.strictObject({requestId:ge.uuid(),orderId:ge.uuid(),purchaseIntentId:ge.uuid(),status:ge.enum(["created","pending","trialing","paid","cancelled","failed"]),currency:ie,refunded:ge.boolean(),completion:ge.strictObject({transactionIds:ge.array(ge.string().min(1).max(255)).min(1).max(50).refine(e=>new Set(e).size===e.length),membership:ge.boolean()}).nullable()});import{z as j}from"zod";var no=j.uuid().refine(e=>e===e.toLowerCase(),"Product references require canonical lowercase UUIDs"),fd=j.record(j.string(),j.json()).refine(e=>Array.from(JSON.stringify(e)).length<=4e3,"Offering metadata exceeds 4000 characters"),gd=3,Gn=20,hd=gd*Gn,to=j.strictObject({type:j.literal("product"),productId:no}),Wc={type:j.literal("group"),key:j.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),name:j.string().trim().min(1).max(80)},bd=j.discriminatedUnion("type",[to,j.strictObject({...Wc,items:j.array(to).max(Gn)})]),yd=j.discriminatedUnion("type",[to,j.strictObject({...Wc,items:j.array(bd).max(Gn)})]),xd=j.array(yd).max(Gn).superRefine((e,t)=>{let n=new Set,r=new Set,o=0;function a(l){for(let p of l){o++;let d=p.type==="product"?n:r,v=p.type==="product"?p.productId:p.key;d.has(v)&&t.addIssue({code:"custom",message:p.type==="product"?"Duplicate Offering Product reference":"Duplicate Offering group key"}),d.add(v),p.type==="group"&&a(p.items)}}a(e),(n.size>Gn||o>hd)&&t.addIssue({code:"custom",message:"Offering item limit exceeded"})});function ro(e){return e.items.flatMap(t=>t.type==="product"?[t.productId]:ro(t))}var fn=j.strictObject({lookupKey:j.string().trim().min(1).max(200),displayName:j.string().trim().min(1).max(1500),items:xd,metadata:fd}),Sd=j.strictObject({product:j.record(j.string(),j.json()),prices:j.array(j.record(j.string(),j.json())),entitlements:j.array(j.record(j.string(),j.json())),freeTrials:j.array(j.record(j.string(),j.json())),licenses:j.array(j.record(j.string(),j.json()))}),Qc=fn.extend({id:j.uuid(),projectId:j.uuid(),environmentId:j.uuid(),state:j.enum(["active","archived"]),isCurrent:j.boolean(),revision:j.number().int().nonnegative(),publishedVersionId:j.uuid().nullable(),createdAt:j.iso.datetime({offset:!0})}).superRefine((e,t)=>{e.isCurrent&&(e.state!=="active"||!e.publishedVersionId)&&t.addIssue({code:"custom",message:"Current Offering must be active and published"})}),Xc=j.strictObject({id:j.uuid(),offeringId:j.uuid(),projectId:j.uuid(),environmentId:j.uuid(),version:j.number().int().positive(),document:fn,productEvidence:j.record(no,Sd),createdAt:j.iso.datetime({offset:!0})}).superRefine((e,t)=>{let n=ro(e.document);(!n.length||Od(e.document).length>0||Object.keys(e.productEvidence).length!==n.length||n.some(r=>!Object.hasOwn(e.productEvidence,r)))&&t.addIssue({code:"custom",message:"Published Offering requires evidence for every Product"})}),vd=j.strictObject({rows:j.array(Qc).max(200),versions:j.array(Xc).max(500)}),zy=j.discriminatedUnion("action",[j.strictObject({action:j.literal("create"),document:fn}),j.strictObject({action:j.literal("save"),id:j.uuid(),revision:j.number().int().nonnegative(),document:fn}),j.strictObject({action:j.enum(["publish","set_current","archive","restore"]),id:j.uuid(),revision:j.number().int().nonnegative()})]),By=j.strictObject({record:Qc,version:Xc.nullable()}),Yc=j.discriminatedUnion("type",[j.strictObject({type:j.literal("current")}),j.strictObject({type:j.literal("id"),id:j.uuid()}),j.strictObject({type:j.literal("lookup_key"),lookupKey:j.string().min(1).max(200)}),j.strictObject({type:j.literal("version"),versionId:j.uuid()})]),Id=j.strictObject({internalId:no,id:j.string(),name:j.string().nullable(),version:j.number().int().positive(),archived:j.boolean()}),qy=vd.extend({products:j.array(Id).max(500),pagination:j.strictObject({rows:j.string().nullable(),versions:j.string().nullable(),products:j.string().nullable()}).optional()});function Od(e){let t=[];ro(e).length||t.push("Select at least one Product before publishing");function n(r){for(let o of r)o.type==="group"&&(o.items.length||t.push("Every published group requires a Product"),n(o.items))}return n(e.items),t}import{z as $r}from"zod";var eu=$r.strictObject({id:$r.uuid(),offeringId:$r.uuid(),version:$r.number().int().positive(),document:fn});import{z as _e}from"zod";import{z as U}from"zod";import{z as we}from"zod";var jd=we.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Gr=we.discriminatedUnion("type",[we.object({type:we.literal("fixed"),productVersionId:we.string().min(1).max(200)}).strict(),we.object({type:we.literal("picker"),pickerId:jd,allowedProductVersionIds:we.array(we.string().min(1).max(200)).min(1).max(20)}).strict().refine(e=>new Set(e.allowedProductVersionIds).size===e.allowedProductVersionIds.length,"Product choices must be unique")]),yt=we.discriminatedUnion("type",[we.object({type:we.literal("modal"),size:we.enum(["sm","md","lg"])}).strict(),we.object({type:we.literal("sheet"),size:we.enum(["sm","md","lg"])}).strict(),we.object({type:we.literal("fullscreen")}).strict(),we.object({type:we.literal("inline")}).strict()]);var io=U.discriminatedUnion("type",[U.strictObject({type:U.literal("event"),event:U.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),U.strictObject({type:U.literal("open_url"),url:U.url().refine(e=>new URL(e).protocol==="https:")})]),Ad=Le,wd=U.discriminatedUnion("type",[U.object({type:U.literal("checkout"),product:Gr}).strict(),U.object({type:U.literal("close")}).strict(),U.object({type:U.literal("action"),action:io}).strict()]),gn=U.object({schemaVersion:U.literal(3),kind:U.literal("paywall"),name:U.string().trim().min(1).max(80),presentation:yt,requirement:Qt.optional(),products:vr,offeringVersionId:U.uuid().nullable(),offeringId:U.uuid(),screen:Ad,buttons:U.record(U.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),wd)}).strict(),Xy=gn.superRefine((e,t)=>{(e.screen.surface!=="paywall"||e.screen.actions.some(r=>!["event","navigate"].includes(r.type)||r.close))&&t.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let r of Pd(e))t.addIssue({code:"custom",message:r});for(let r of _d(e))t.addIssue({code:"custom",message:r});It(e.screen).some(r=>!r.complete)&&t.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(e.buttons).length!==e.screen.actions.filter(r=>r.type!=="navigate").length||e.screen.actions.some(r=>r.type!=="navigate"&&!Object.hasOwn(e.buttons,r.id)))&&t.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(e.buttons).some(r=>r.type==="checkout")||t.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _d(e){let t=e.products.items.map(a=>a.productVersionId),n=Ra(e.screen),r=new Set,o=[];(!t.length||!e.products.defaultProductVersionId||!t.includes(e.products.defaultProductVersionId))&&o.push("products"),e.offeringVersionId||o.push("offering"),e.products.grouping&&(!Ma(e.products.grouping,t)||e.products.grouping.tiers.some(a=>!e.products.grouping.assignments.some(l=>l.tierId===a.id)))&&o.push("grouping");for(let a of Object.values(e.buttons))if(a.type==="checkout"){let l=a.product;if(l.type==="fixed")r.add(l.productVersionId);else{l.allowedProductVersionIds.forEach(v=>r.add(v));let p=!1,d=n[l.pickerId];d&&(p=!0,(l.allowedProductVersionIds.some(v=>!d.ids.includes(v))||d.ids.some(v=>!l.allowedProductVersionIds.includes(v)))&&o.push("picker")),gt(e.screen,v=>{if(v.id!==l.pickerId||v.type!=="plan_picker")return;p=!0,(JSON.stringify(v.planIds)!==JSON.stringify(t)||JSON.stringify(l.allowedProductVersionIds)!==JSON.stringify(t)||v.defaultPlan!==e.products.defaultProductVersionId)&&o.push("picker");let h=v.grouping?{tiers:v.grouping.tiers,assignments:v.grouping.assignments}:void 0;JSON.stringify(h)!==JSON.stringify(e.products.grouping)&&o.push("grouping")}),p||o.push("picker")}}return(!r.size||[...r].some(a=>!t.includes(a)))&&o.push("purchase"),gt(e.screen,a=>{a.type==="stack"&&a.productSlot&&!a.bind?.plan&&o.push(`productBinding:${a.id}`),(a.type==="stack"||a.type==="button")&&a.bind?.plan&&!t.includes(a.bind.plan)&&o.push("binding"),a.type==="plan_picker"&&(!a.planIds?.length||a.planIds.some(l=>!t.includes(l)))&&o.push("binding")}),[...new Set(o)]}function Pd(e){let t=[],n=e.screen.pages.at(-1),r=new Map;for(let p of e.screen.pages)r.set(p.id,[]),Yt(p.root,d=>{let v=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(v){let h=e.screen.actions.find($=>$.id===v);h?.type==="navigate"&&r.get(p.id).push(h.pageId);let T=e.buttons[v];p.id!==n.id&&T&&T.type!=="close"&&t.push(`purchaseScreen:${d.id}`)}p.id!==n.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&t.push(`packageScreen:${d.id}`)});let o=new Set;function a(p){if(!o.has(p)){o.add(p);for(let d of r.get(p)??[])a(d)}}let l=e.screen.initialPageId??e.screen.pages[0]?.id;l?a(l):t.push("initialPage");for(let p of e.screen.pages)o.has(p.id)||t.push(`unreachableScreen:${p.id}`);return[...new Set(t)]}var tu=U.object({id:U.uuid(),projectId:U.uuid(),environmentId:U.uuid(),revision:U.number().int().nonnegative(),state:U.enum(["active","archived"]),publishedVersionId:U.uuid().nullable(),updatedAt:U.iso.datetime({offset:!0}),draft:gn}).strict(),Yy=U.object({rows:U.array(tu).max(200),nextCursor:U.uuid().nullable()}).strict(),ex=tu.omit({draft:!0}).extend({name:U.string(),productCount:U.number().int().nonnegative()}).strict(),tx=U.discriminatedUnion("action",[U.object({action:U.literal("save"),id:U.uuid().nullable(),revision:U.number().int().nonnegative(),document:gn}).strict(),U.object({action:U.enum(["publish","archive"]),id:U.uuid(),revision:U.number().int().nonnegative()}).strict()]),nx=U.object({paywalls:U.array(U.object({id:U.uuid(),paywallId:U.uuid(),version:U.number().int().positive(),name:U.string().min(1).max(80),presentation:yt,buttons:gn.shape.buttons}).strict()).max(500),limited:U.boolean()}).strict();import{z as X}from"zod";import{z as Ne}from"zod";var hn=Ne.string().regex(/^[a-f0-9]{64}$/),Cd=Ca.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),nu=Ne.strictObject({couponDigests:Ne.record(Ne.uuid(),hn),variables:Ne.record(Jt,Ne.record(Ne.uuid(),Ne.partialRecord(Ne.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),Ne.string()))),locales:Ne.record(Jt,Xt.extend({nodes:Ne.record(Ne.string(),Ne.strictObject({base:Cd})),plans:Ne.object({}).strict(),pickers:Ne.object({}).strict()}).omit({paywall:!0}))});import{z as se}from"zod";import{z as Kr}from"zod";var oo=Kr.strictObject({eventsEnabled:Kr.boolean(),experimentViewsEnabled:Kr.boolean(),featureUsageEnabled:Kr.boolean()}),ux=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function px(e,t){return t==="Experiment Viewed"?e.experimentViewsEnabled:t==="Feature Evaluated"?e.featureUsageEnabled:e.eventsEnabled}import{z as w}from"zod";var ao=w.tuple([w.number().min(0).max(1),w.number().min(0).max(1)]).refine(([e,t])=>e<=t),kd=w.strictObject({attribute:w.string().optional(),seed:w.string(),hashVersion:w.literal(2),ranges:w.array(ao).max(100)}),Rd=w.strictObject({id:w.string().min(1).max(255),condition:it,gate:w.boolean().optional()}),Ed=w.strictObject({key:w.string().optional(),name:w.string().optional(),passthrough:w.boolean().optional()}),ru={condition:it.optional(),parentConditions:w.array(Rd).max(100).optional(),weights:w.array(w.number().min(0).max(1)).max(20).optional(),coverage:w.number().min(0).max(1).optional(),hashAttribute:w.string().optional(),fallbackAttribute:w.string().optional(),hashVersion:w.literal(2).optional(),disableStickyBucketing:w.boolean().optional(),bucketVersion:w.number().int().nonnegative().optional(),minBucketVersion:w.number().int().nonnegative().optional(),filters:w.array(kd).max(100).optional(),ranges:w.array(ao).max(20).optional(),meta:w.array(Ed).max(20).optional(),seed:w.string().optional(),name:w.string().optional(),phase:w.string().optional()},bn=w.strictObject({...ru,key:w.string().min(1).max(255),variations:w.tuple([ee,ee]).rest(ee).refine(e=>e.length<=20),urlPatterns:w.array(w.strictObject({include:w.boolean(),type:w.enum(["regex","simple"]),pattern:w.string()})).max(100).optional(),force:w.number().int().nonnegative().optional(),active:w.boolean().optional(),persistQueryString:w.boolean().optional()}),so=w.strictObject({value:ee,variationId:w.number().int(),key:w.string(),name:w.string().optional(),bucket:w.number().optional(),passthrough:w.boolean().optional(),inExperiment:w.boolean(),hashUsed:w.boolean().optional(),hashAttribute:w.string(),hashValue:w.string(),featureId:w.string().nullable(),stickyBucketUsed:w.boolean().optional()}),Md=w.strictObject({...ru,id:w.string().max(255).optional(),force:ee.optional(),variations:w.array(ee).min(2).max(20).optional(),key:w.string().optional(),range:ao.optional(),tracks:w.array(w.strictObject({experiment:bn,result:so})).max(100).optional()}),Td=w.strictObject({defaultValue:ee.optional(),rules:w.array(Md).max(500).optional()}),Kn=w.record(w.string(),w.union([w.strictObject({type:w.literal("hashed"),attributeKey:w.string(),values:w.array(w.string().regex(/^[a-f0-9]{64}$/))}),w.strictObject({type:w.literal("list"),attributeKey:w.string(),values:w.array(w.union([w.string(),w.number()]))}),w.strictObject({type:w.literal("condition"),condition:it})])),_t=w.strictObject({scope:le,generation:w.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:w.iso.datetime({offset:!0}),expiresAt:w.iso.datetime({offset:!0}).nullable(),features:w.record(w.string(),Td),savedGroups:Kn,experiments:w.record(w.uuid(),bn)});var co=_t.extend({analyticsConfig:oo,remoteFeatures:se.array(se.string().min(1).max(255)).max(500)}),Dd=co.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((e,t)=>{for(let n of e.remoteFeatures)Object.hasOwn(e.features,n)&&t.addIssue({code:"custom",path:["features",n],message:"Remote Feature definitions cannot be public"});for(let[n,r]of Object.entries(e.savedGroups))r.type==="list"&&t.addIssue({code:"custom",path:["savedGroups",n],message:"Raw Saved Group lists cannot be public"})}),iu=se.strictObject({attributes:Ke,features:se.array(se.string().min(1).max(255)).max(500).optional(),customerId:se.uuid().optional()}),zd=se.strictObject({value:ee,source:se.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:se.boolean(),off:se.boolean(),ruleId:se.string(),experimentResult:so.optional()}),ou=se.strictObject({generation:_t.shape.generation,evaluatedAt:_t.shape.evaluatedAt,expiresAt:_t.shape.expiresAt,features:se.record(se.string(),zd),merchandiseContext:se.strictObject({merchandiseId:se.uuid(),merchandise:Ke}).optional()}),au=se.strictObject({customerId:se.uuid().optional(),events:se.array(se.strictObject({eventUuid:se.uuid(),timestamp:se.iso.datetime({offset:!0}),name:se.string().min(1).max(255),merchandise:ys.optional(),properties:se.record(se.string(),ee).default({}),deviceId:se.string().min(1).max(255).optional(),sessionId:se.string().min(1).max(255).optional()})).min(1).max(100)}),su=se.strictObject({inserted:se.number().int().nonnegative(),duplicates:se.number().int().nonnegative(),rejected:se.number().int().nonnegative(),skipped:se.number().int().nonnegative(),analyticsConfig:oo});import{z as A}from"zod";import{z as Bd}from"zod";var uo=Bd.enum(["funnel-run/1","funnel-process/1"]),po="funnel-process/1";function lo(e,t=[]){let n=[];gt(e,o=>{o.hidden&&n.push("Hidden components must not be delivered"),t.includes(o.type)&&n.push(`Node type ${o.type} cannot be delivered`)});let r=new Set(fi(e).map(o=>o.key));for(let[o,a]of Object.entries(e.strings.locales))for(let l of Object.keys(a))r.has(l)||n.push(`Unused string ${l} must not be delivered (${o})`);return n}function cu(e){return e.hidden?null:e.type!=="stack"?e:{...e,children:e.children.flatMap(t=>cu(t)??[])}}function qd(e){let t=e.pages.map(o=>{let a=cu(o.root);return a?.type==="stack"?{...o,root:a}:{...o,root:{type:"stack",id:o.root.id,...o.root.name===void 0?{}:{name:o.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(fi({pages:t}).map(o=>o.key)),r=Object.fromEntries(Object.entries(e.strings.locales).map(([o,a])=>[o,Object.fromEntries(Object.entries(a).filter(([l])=>n.has(l)))]));return{...e,pages:t,strings:{...e.strings,locales:r}}}function uu(e,t=[]){let n=Le.parse(structuredClone(qd(e))),r=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(r);for(let a of n.pages)if(!r(a.root))throw new Error(`Page ${a.id} has no visible content`);let o=lo(n,t);if(o.length)throw new Error(o.join("; "));return n}import{z as P}from"zod";import{z as x}from"zod";import{z as ve}from"zod";var Lr=ve.strictObject({schemaVersion:ve.literal(1),renderKey:ve.string().min(1).max(256),routeTemplate:ve.string().startsWith("/").max(2048),selectors:ve.array(ve.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:ve.array(ve.number().int().min(0)).min(1),absent:ve.array(ve.number().int().min(0))}).superRefine((e,t)=>{let n=[...e.present,...e.absent];(new Set(e.selectors).size!==e.selectors.length||new Set(n).size!==n.length||n.length!==e.selectors.length||n.some(r=>r>=e.selectors.length))&&t.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),pu=ve.strictObject({renderKey:ve.string().min(1).max(256),routeKey:ve.string().min(1).max(256),stateKey:ve.string().min(1).max(256),documentKey:ve.string().min(1).max(256),documentHash:ve.string().regex(/^[a-f0-9]{64}$/),compositionKey:ve.string().min(1).max(256),entryMode:ve.enum(["hard","soft"]),match:ve.strictObject({present:ve.array(ve.number().int().min(0)),absent:ve.array(ve.number().int().min(0))})});import{z as Vt}from"zod";var Fd=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],mo="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",Nd=Vt.string().regex(new RegExp(`^${mo}/${mo}/${mo}/manifest\\.json$`)),lu=Vt.strictObject({kind:Vt.literal("gcs-resumable"),url:Vt.url(),bucket:Vt.enum(Fd),objectKey:Nd,byteLength:Vt.number().int().positive(),expiresAt:Vt.iso.datetime()}).superRefine((e,t)=>{let n=new URL(e.url),r=n.searchParams,o=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${e.bucket}/o`||[...r.keys()].some(a=>!o.includes(a)||r.getAll(a).length!==1)||r.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(r.get("upload_id")??"")||r.has("name")&&r.get("name")!==`app-manifests/${e.objectKey}`||r.has("upload_protocol")&&r.get("upload_protocol")!=="resumable"||r.has("ifGenerationMatch")&&r.get("ifGenerationMatch")!=="0")&&t.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var Ie=x.string().min(1).max(256),Je=x.string().regex(/^[a-f0-9]{64}$/),Zr=x.strictObject({versionId:x.uuid(),manifestDigest:Je,sourceGraphDigest:Je,pageKey:Ie,stateKey:Ie,documentKey:Ie,documentHash:Je,elementKey:Ie.optional(),nodeId:Ie.optional(),contentHash:Je.optional(),renderKey:Ie.optional()}),mu=x.strictObject({pageKey:Ie,documentKey:Ie,expectedDocumentHash:Je,renderKey:Ie.optional(),nodeId:Ie,elementKey:Ie,expectedContentHash:Je,property:x.enum(["text","fontSize","color"]),value:x.union([x.string().max(4e3),x.number().finite()])}),du=x.strictObject({versionId:x.uuid(),manifestDigest:Je,sourceGraphDigest:Je,pageKey:Ie,stateKey:Ie,documentKey:Ie,documentHash:Je,renderKey:Ie.optional(),patches:x.array(mu.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),Vd=/^[a-z][a-z0-9-]{0,39}$/,Ln=x.string().regex(Vd),go=x.enum(["web","ios","android"]),Mx=x.discriminatedUnion("action",[x.strictObject({action:x.literal("register"),requestId:x.uuid(),client:Ln,platform:go,label:x.string().trim().min(1).max(100),sha256:Je,bytes:x.number().int().min(1),transferBytes:x.number().int().min(1)}),x.strictObject({action:x.literal("complete"),versionId:x.uuid()}),x.strictObject({action:x.literal("current"),versionId:x.uuid(),expectedCurrent:x.uuid().nullable()}),x.strictObject({action:x.literal("delivery"),enabled:x.boolean()}),x.strictObject({action:x.literal("changes"),versionId:x.uuid(),experimentId:x.uuid(),variationId:Ie,changesetId:x.uuid().nullable(),expectedRevision:Je.nullable(),editorUrl:x.string().url().max(2048),patches:x.array(mu).max(200)})]),ho=x.strictObject({id:x.uuid(),projectId:x.uuid(),environmentId:x.uuid(),clientKey:Ln,platform:go,label:x.string(),sha256:Je,bytes:x.number().int().positive(),objectKey:x.string(),state:x.enum(["uploading","ready","rejected"]),isCurrent:x.boolean(),revision:x.number().int().nonnegative(),createdAt:x.string(),expiresAt:x.string(),readyAt:x.string().nullable(),summary:x.record(x.string(),x.json()),routeTree:x.json().nullable(),validation:x.record(x.string(),x.json())}),Ud=x.strictObject({key:Ln,platform:go,currentId:x.uuid().nullable()}),Tx=x.strictObject({rows:x.array(ho).max(100),nextCursor:x.uuid().nullable(),clients:x.array(Ud).max(20)}),fo=x.strictObject({storedBytes:x.number().int().nonnegative(),reservedBytes:x.number().int().nonnegative(),chargedBytes:x.number().int().nonnegative(),versions:x.number().int().nonnegative(),objects:x.number().int().nonnegative(),orphanObjects:x.number().int().nonnegative(),missingReadyObjects:x.number().int().nonnegative(),unknownObjectSizes:x.number().int().nonnegative(),byteLimit:x.number().int().positive(),versionLimit:x.number().int().positive(),remainingBytes:x.number().int().nonnegative()}),Dx=x.strictObject({asOf:x.iso.datetime({offset:!0}),reclamation:x.literal("manual-review-required"),buckets:x.strictObject({source:fo,runtime:fo,previews:fo})}),zx=x.strictObject({version:ho,actorId:x.uuid(),claims:x.record(x.string(),x.json())}),Bx=x.strictObject({version:ho,upload:lu.nullable()}),qx=x.object({format:x.literal("indiana-route-state-index"),schemaVersion:x.literal(3),routes:x.array(x.object({routeKey:Ie,path:x.string(),documentKey:Ie,documentHash:Je,initialStateKey:Ie,initialRenderKey:Ie})),renders:x.array(pu)}).loose().superRefine((e,t)=>{(!e.renders||e.routes.some(n=>!e.renders?.some(r=>r.renderKey===n.initialRenderKey&&r.routeKey===n.routeKey&&r.documentKey===n.documentKey&&r.stateKey===n.initialStateKey&&r.documentHash===n.documentHash&&r.entryMode==="hard")))&&t.addIssue({code:"custom",message:"Incomplete render catalog"})}),Fx=x.strictObject({rows:x.array(x.object({id:x.uuid(),name:x.string(),status:x.string(),variations:x.array(x.object({id:Ie,key:Ie,name:x.string().optional()}).loose())}).loose()),limited:x.boolean()}),Nx=x.strictObject({enabled:x.boolean(),allowedOrigins:x.array(x.string())});import{z as yn}from"zod";var fu=yn.strictObject({id:yn.uuid(),name:yn.string().trim().min(1).max(80),client:Ln,source:Zr,event:yn.enum(["screen_enter","button_click"]),cooldownSeconds:yn.number().int().min(0).max(2592e3),behavior:yn.literal("observe")}).superRefine((e,t)=>{e.event==="button_click"&&(!e.source.nodeId||!e.source.elementKey)&&t.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});import{z as ue}from"zod";var bo=ee,$d=["parameters","answers","results","variables"];function yo(e){return $d.some(t=>e===t||e.startsWith(t+"."))}function xo(e){let t={};for(let[r,o]of Object.entries(Mn(e.declarations,e))){let a=r.split(".");if(a.some(d=>["__proto__","constructor","prototype"].includes(d)))throw new Error("Reserved result path");let l=t;for(let d of a.slice(0,-1)){Object.hasOwn(l,d)||(l[d]={});let v=l[d];if(!v||typeof v!="object"||Array.isArray(v))throw new Error("Ambiguous result path");l=v}let p=a.at(-1);if(p===void 0)throw new Error("Empty result path");l[p]=o}return{...Object.fromEntries(Object.entries(e.attributes).filter(([r])=>!yo(r))),variables:t}}import{z as Gd}from"zod";var Hr=Gd.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/);var So=ue.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),gu=ue.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),hu=ut.refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=8192,"Task data exceeds 8 KiB"),vo=ue.record(So,ue.enum(["string","number","boolean","strings"])).refine(e=>Object.keys(e).length<=20,"Too many output fields"),Kd=lt,bu=ue.strictObject({type:ue.literal("external_task"),endpointId:ue.uuid(),taskKey:So,inputs:ue.record(So,Kd).refine(e=>Object.keys(e).length<=20),outputs:vo}),yu=ue.strictObject({maxAttempts:ue.number().int().min(1).max(5),retryDelaySeconds:ue.number().int().min(1).max(30),backoff:ue.enum(["fixed","exponential"]),requestTimeoutSeconds:ue.number().int().min(1).max(10),timeoutSeconds:ue.number().int().min(1).max(300)}).refine(e=>e.requestTimeoutSeconds<=e.timeoutSeconds,"Request timeout exceeds action deadline");var rS=ue.strictObject({outcome:ue.enum(["success","failure"]),data:hu});var iS=ue.discriminatedUnion("operation",[ue.strictObject({operation:ue.literal("signal"),runId:ue.uuid(),nodeId:gu,eventName:Hr,eventId:ue.uuid(),data:hu}),ue.strictObject({operation:ue.literal("read_results"),runId:ue.uuid()})]),oS=ue.strictObject({scope:le,runId:ue.uuid(),eventId:ue.uuid(),accepted:ue.boolean()}),Ld=ue.record(gu,bo),aS=ue.strictObject({scope:le,runId:ue.uuid(),results:Ld});var at={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},xu="00000000-0000-0000-0000-000000000000";import{z as k}from"zod";import{z as de}from"zod";var mS=de.enum(["local","remote"]),Io=de.strictObject({port:de.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:ee.optional(),sticky:de.array(de.strictObject({expected:cr.nullable(),next:cr})).max(100),exposures:de.array(ee).max(100),features:de.array(ee).max(100)}),Su=de.strictObject({type:de.literal("evaluate"),receiptId:de.uuid(),environmentId:de.uuid(),policyRevision:de.number().int().nonnegative(),attributes:Ke,sticky:de.record(de.string(),cr)}),vu=Su.extend({runId:de.uuid(),versionId:de.uuid(),nodeId:de.string().min(1).max(64),visit:de.number().int().nonnegative(),revision:de.number().int().nonnegative()}),Oo=Su.omit({type:!0,receiptId:!0}).extend({type:de.literal("evaluate_segment")}),Iu=de.strictObject({nodeId:de.string().min(1).max(64),result:Io}),Ou=Oo.extend({runId:de.uuid(),versionId:de.uuid(),nodeId:de.string().min(1).max(64),visit:de.number().int().nonnegative(),revision:de.number().int().nonnegative(),parameters:ut,answers:Et,variables:de.record(de.string(),ee)});import{z as F}from"zod";var jo=F.array(F.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),Jr=F.intersection(Ke,F.looseObject({tags:jo.optional()})).refine(e=>!["id","externalUserId","createdAt","ageDays","subscription","parameters","answers","results"].some(t=>Object.hasOwn(e,t)),"Reserved customer attribute"),Wr=F.string().trim().max(80),Qr=F.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),Xr=F.union([F.email().max(254),F.literal("")]),Yr=F.string().trim().min(1).max(255).refine(e=>!/\p{Cc}/u.test(e),"Fingerprint must not contain control characters"),ju=F.string().trim().min(1).max(255).refine(e=>!e.startsWith("gg_guest_"),"Reserved guest identity namespace"),Au=F.object({externalUserId:ju.optional(),name:Wr.default(""),email:Xr.default(""),phone:Qr.optional(),attributes:Jr.default({})}).strict().refine(e=>e.externalUserId!==void 0||e.email!=="","\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u7528\u6237 ID \u6216\u90AE\u7BB1"),xt=F.discriminatedUnion("type",[F.strictObject({type:F.literal("id"),value:F.uuid()}),F.strictObject({type:F.literal("externalUserId"),value:ju})]),Pt=F.strictObject({name:Wr.optional(),email:Xr.optional(),phone:Qr.optional(),attributes:Jr.optional(),fingerprint:Yr.optional()}),Ut=e=>!e.customerData||e.customer?.type==="externalUserId",$t="customerData requires an externalUserId customer",xn=F.object({id:F.uuid(),externalUserId:F.string().min(1).max(255).nullable(),name:Wr,email:Xr,phone:Qr.optional(),attributes:Jr,createdAt:F.iso.datetime()}).strict(),wu=F.object({customer:xn,changed:F.boolean(),replayed:F.boolean()}).strict(),Zd=F.discriminatedUnion("type",[F.object({type:F.literal("id"),value:F.uuid()}).strict(),F.object({type:F.literal("externalUserId"),value:F.string().trim().min(1).max(255)}).strict()]),Hd=F.object({name:Wr.optional(),email:Xr.optional(),phone:Qr.optional(),attributes:Jr.refine(e=>!Object.hasOwn(e,"tags"),"Use incremental tagChanges").optional(),removeAttributes:F.array(F.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(e=>!e.includes("tags")).optional(),tagChanges:F.strictObject({add:jo,remove:jo}).optional()}).strict().refine(e=>Object.keys(e).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),Ao=F.object({lookup:Zd}).strict(),_u=Ao.extend({requestId:F.uuid(),patch:Hd}).strict(),Pu=F.object({search:F.string().trim().max(200).default(""),tag:F.string().trim().max(40).default(""),planId:F.string().max(200).default(""),versionId:F.string().max(200).default(""),holdingStatus:F.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:F.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:F.union([F.iso.datetime(),F.literal("")]).default(""),createdUntil:F.union([F.iso.datetime(),F.literal("")]).default(""),offset:F.coerce.number().int().min(0).max(1e5).default(0),limit:F.coerce.number().int().min(1).max(100).default(50)}).strict(),Cu=F.object({customers:xn.array(),hasMore:F.boolean(),total:F.number().int().nonnegative().nullable(),evaluatedAt:F.iso.datetime()}).strict();var Zn=k.discriminatedUnion("type",[k.strictObject({type:k.literal("literal"),value:ee}),k.strictObject({type:k.literal("variable"),key:Ae,path:ot.optional()}),k.strictObject({type:k.literal("feature"),featureKey:k.string().min(1).max(128)})]),Jd=k.strictObject({requestId:k.uuid(),decisionId:k.uuid(),customerId:k.uuid(),externalUserId:k.string().min(1).max(255).nullable(),versionId:k.uuid(),receiptId:k.uuid(),value:ee}),wo={funnelId:k.uuid(),requestId:k.uuid(),customer:xt,customerData:Pt.optional(),attributes:Ke.refine(e=>!["parameters","answers","results","variables"].some(t=>Object.hasOwn(e,t)),"parameters, answers, results and variables are reserved flow namespaces")},jS=k.discriminatedUnion("operation",[k.strictObject({operation:k.literal("decide"),...wo}).refine(Ut,$t),k.strictObject({operation:k.literal("read_decision"),decisionId:k.uuid()}),k.strictObject({operation:k.literal("evaluate_decision"),decisionId:k.uuid(),requestId:k.uuid(),nodeId:k.string().min(1).max(64),visit:k.number().int().nonnegative(),revision:k.number().int().nonnegative(),receiptId:k.uuid(),policyRevision:k.number().int().nonnegative(),generation:k.string().min(1).max(256),result:Io}),k.strictObject({operation:k.literal("feature_config"),funnelId:k.uuid()}),k.strictObject({operation:k.literal("commit_decision_segment"),decisionId:k.uuid(),requestId:k.uuid(),nodeId:k.string().min(1).max(64),visit:k.number().int().nonnegative(),revision:k.number().int().nonnegative(),policyRevision:k.number().int().nonnegative(),generation:k.string().min(1).max(256),steps:k.array(Iu).max(32),boundary:k.strictObject({nodeId:k.string().min(1).max(64),visit:k.number().int().nonnegative()}).optional()}),k.strictObject({operation:k.literal("segment_configuration"),funnelId:k.uuid(),versionId:k.uuid()}),k.strictObject({operation:k.literal("configuration"),funnelId:k.uuid(),versionId:k.uuid().optional()}),k.strictObject({operation:k.literal("local_configuration"),funnelId:k.uuid()}),k.strictObject({operation:k.literal("report_used"),decisionId:k.uuid(),eventId:k.uuid(),occurredAt:k.iso.datetime({offset:!0}),reference:k.string().min(1).max(128).optional()})]),AS=k.strictObject({scope:le,decisionId:k.uuid(),requestId:k.uuid(),status:k.enum(["pending","completed","failed"]),decision:Jd.nullable(),evaluation:k.discriminatedUnion("type",[vu,Ou]).optional()}).refine(e=>e.status==="completed"==(e.decision!==null)&&(!e.decision||e.decision.decisionId===e.decisionId&&e.decision.requestId===e.requestId),"Completed decisions carry their committed result"),wS=k.strictObject({scope:le,decisionId:k.uuid(),eventId:k.uuid(),source:k.literal("caller_reported")});import{z as Te}from"zod";var ku=Te.strictObject({type:Te.literal("bundle"),paywall:lt.optional(),offering:lt.optional(),coupons:lt,data:lt}),Wd=e=>Te.strictObject({type:Te.literal(e),id:Te.uuid()}),ES=Te.strictObject({type:Te.literal("bundle"),paywallVersionId:Te.uuid().optional(),offeringVersionId:Te.uuid().optional(),couponIds:Te.array(Te.uuid()).max(20).refine(e=>new Set(e).size===e.length),data:ee});var MS=Te.strictObject({type:Te.literal("bundle"),offering:Wd("offering_version").nullable(),paywall:Te.strictObject({versionId:Te.uuid(),paywallId:Te.uuid(),offeringVersionId:Te.uuid()}).nullable(),coupons:Te.array(Dn).max(20),data:ee});import{z as st}from"zod";import{z as Ye}from"zod";var Ru=Ye.union([Ye.string(),Ye.number().finite(),Ye.boolean(),Ye.null()]),Qd=Ye.union([Ru,Ye.array(Ru).min(1).max(20)]),Xd=Ye.record(ot,Qd).refine(e=>Object.keys(e).length<=10),Eu=Ye.strictObject({path:ot,type:Ye.enum(["string","number","boolean","strings"]),nullable:Ye.boolean().optional(),aggregation:Ye.enum(["count","exists"]).optional(),where:Xd.optional()}).superRefine((e,t)=>{(e.aggregation==="count"&&e.type!=="number"||e.aggregation==="exists"&&e.type!=="boolean"||!e.aggregation&&e.where)&&t.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Yd=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],Mu=st.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),ef=lt,Tu=st.discriminatedUnion("type",[bu,st.strictObject({type:st.literal("claim_offer"),coupon:lt}),st.strictObject({type:st.literal("event"),event:Mu}),st.strictObject({type:st.literal("api"),operation:st.enum(Yd),inputs:st.record(ot,ef).refine(e=>Object.keys(e).length<=40),outputs:st.record(Mu,Eu).refine(e=>Object.keys(e).length<=20)})]);var xe=Hr,tf=P.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),We={id:xe,name:P.string().trim().min(1).max(80),position:P.strictObject({x:P.number().finite(),y:P.number().finite()}).optional()},nf={success:xe,cancel:xe,unavailable:xe,failure:xe},_o=P.url().max(2048).refine(e=>{try{return new URL(e).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),Po=P.enum(["same_window","new_window"]),rf=P.discriminatedUnion("type",[P.strictObject({...We,type:P.literal("entry"),next:xe,triggers:P.array(fu).max(20).refine(e=>new Set(e.map(t=>t.id)).size===e.length,"Entry trigger IDs must be unique").optional()}),P.strictObject({...We,type:P.literal("screen"),screenId:xe,presentation:yt,outputs:P.record(xe,xe),offering:P.discriminatedUnion("source",[P.strictObject({source:P.literal("variable"),key:Ae}),P.strictObject({source:P.literal("fixed"),versionId:P.uuid()})]).optional()}),P.strictObject({...We,type:P.literal("offering"),configuration:P.discriminatedUnion("source",[P.strictObject({source:P.literal("fixed"),versionId:P.uuid()}),P.strictObject({source:P.literal("feature"),featureKey:P.string().min(1).max(128)})]),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...We,type:P.literal("coupon"),couponId:P.uuid(),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...We,type:P.literal("coupons"),couponIds:P.array(P.uuid()).max(20).refine(e=>new Set(e).size===e.length),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...We,type:P.literal("output"),value:P.discriminatedUnion("type",[...Zn.options,ku,P.strictObject({type:P.literal("selection"),screenId:xe,offeringKey:Ae})])}),P.strictObject({...We,type:P.literal("condition"),cases:P.array(P.strictObject({condition:it,target:xe})).min(1).max(50),default:xe}),P.strictObject({...We,type:P.literal("feature"),featureKey:P.string().min(1).max(128),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...We,type:P.literal("split"),experimentId:P.uuid(),applyPageExperiment:P.literal(!0).optional(),routes:P.record(tf,xe).refine(e=>Object.keys(e).length>=2&&Object.keys(e).length<=20),notParticipating:xe}),P.strictObject({...We,type:P.literal("action"),...nf,execution:yu,action:Tu,writes:yr.optional()}),P.strictObject({...We,type:P.literal("external_page"),appManifest:Zr.optional(),url:_o,openIn:Po,opened:xe,failed:xe}),P.strictObject({...We,type:P.literal("end"),outcome:P.enum(["completed","closed","ineligible","failed"]),output:Zn.optional()}),P.strictObject({...We,type:P.literal("wait"),writes:yr.optional(),wait:P.discriminatedUnion("type",[P.strictObject({type:P.literal("duration"),delaySeconds:P.number().int().min(1).max(2592e3),elapsed:xe}),P.strictObject({type:P.literal("event"),eventName:xe,outputs:vo,timeoutSeconds:P.number().int().min(1).max(2592e3),received:xe,timeout:xe})])})]),Co=P.strictObject({version:P.literal(5),entry:xe,nodes:P.array(rf).min(1).max(at.flowNodes)}),ko=Co.superRefine((e,t)=>{of(e,n=>t.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function ei(e){switch(e.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[e.next];case"screen":return Object.values(e.outputs);case"condition":return[...e.cases.map(t=>t.target),e.default];case"split":return[...Object.values(e.routes),e.notParticipating];case"action":return[e.success,e.cancel,e.unavailable,e.failure];case"external_page":return[e.opened,e.failed];case"end":case"output":return[];case"wait":return e.wait.type==="duration"?[e.wait.elapsed]:[e.wait.received,e.wait.timeout]}}function of(e,t){let n=[],r=new Map(e.nodes.map(h=>[h.id,h])),o=(h,T,$)=>{n.push(h),t?.({message:h,reason:T,path:$?["nodes",e.nodes.indexOf($)]:[]})};r.size!==e.nodes.length&&o("Node identifiers must be unique","uniqueNodes"),(r.get(e.entry)?.type!=="entry"||e.nodes.filter(h=>h.type==="entry").length!==1)&&o("A flow has exactly one entry node","entry"),(e.nodes.filter(h=>h.type==="screen").length>at.pages||e.nodes.filter(h=>!["screen","entry","end","output"].includes(h.type)).length>at.logicNodes)&&o("Flow node limit exceeded","budget");let a=new Set;for(let h of e.nodes){for(let T of ei(h))T===e.entry&&o("An entry cannot be a transition target","entryTarget",h),r.has(T)||o(`Missing target ${T}`,"missingTarget",h);h.type==="screen"&&(a.has(h.screenId)&&o("Every screen has exactly one node owner","screenOwner",h),a.add(h.screenId))}let l=new Set,p=new Set,d=new Set;function v(h){if(l.has(h)){o("Flow edges must not form a cycle","cycle",r.get(h));return}if(!(p.has(h)||!r.has(h))){l.add(h),d.add(h);for(let T of ei(r.get(h)))v(T);l.delete(h),p.add(h)}}v(e.entry);for(let h of e.nodes)d.has(h.id)||o("Every node must be reachable from Entry","unreachable",h);return[...new Set(n)]}var Ro={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Du(e,t,n){let r=[...t].sort((p,d)=>d.length-p.length),o=new Set,a=(p,d=!1)=>{let v=r.find(h=>p===h||d&&p.startsWith(h+"."));o.add(v??p)};if(e.type==="condition"){let p=n?.startsWith("case_")?Number(n.slice(5)):e.cases.length-1;for(let d of e.cases.slice(0,p+1))for(let v of jt(d.condition))v.startsWith("variables.")&&a(v.slice(10),!0)}if(e.type==="screen"&&e.offering?.source==="variable"&&a(e.offering.key),e.type==="action"&&(e.action.type==="api"||e.action.type==="external_task"))for(let p of Object.values(e.action.inputs))p.source==="variable"&&a(p.key);e.type==="action"&&e.action.type==="claim_offer"&&e.action.coupon.source==="variable"&&a(e.action.coupon.key);let l=e.type==="output"?e.value:e.type==="end"?e.output:null;if(l?.type==="variable"&&a(l.key),l?.type==="bundle")for(let p of[l.paywall,l.offering,l.coupons,l.data])p?.source==="variable"&&a(p.key);return l?.type==="selection"&&a(l.offeringKey),[...o]}import{z as S}from"zod";var Sn=S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ti=e=>S.record(S.string(),ee).refine(t=>Ze(t)<=e,"Funnel evidence exceeds its byte budget"),pv=S.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Mo=S.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),To=S.discriminatedUnion("type",[S.strictObject({type:S.literal("flag"),key:S.string().min(1).max(128)}),S.strictObject({type:S.literal("experiment"),id:S.uuid()}),S.strictObject({type:S.literal("saved_group"),id:S.uuid()}),S.strictObject({type:S.literal("config"),key:S.string().min(1).max(128)}),S.strictObject({type:S.literal("constant"),key:S.string().min(1).max(128)}),S.strictObject({type:S.literal("paywall_version"),id:S.uuid()}),S.strictObject({type:S.literal("offering_version"),id:S.uuid()}),S.strictObject({type:S.literal("reward"),id:S.uuid()})]),Hn=S.strictObject({schemaVersion:S.literal(1),kind:Mo,selector:To.nullable(),context:ti(131072),contract:S.strictObject({version:S.number().int().positive(),evaluator:S.string().min(1).max(128),policyRevision:S.number().int().nonnegative()})}).refine(e=>Ze(e)<=131072,"Node input exceeds its byte budget"),zu=S.strictObject({schemaVersion:S.literal(1),kind:Mo,outcome:S.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ti(131072),route:S.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ti(131072)}).refine(e=>Ze(e)<=131072,"Node result exceeds its byte budget"),lv=S.strictObject({schemaVersion:S.literal(1),operations:S.record(Sn,S.strictObject({attempts:S.number().int().nonnegative(),maxAttempts:S.number().int().min(1).max(5),deadlineAt:S.iso.datetime({offset:!0}),retryAt:S.iso.datetime({offset:!0}).nullable(),error:S.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:S.strictObject({type:Sn,id:S.uuid()}).nullable()}))}).refine(e=>Ze(e)<=65536,"Execution state exceeds its byte budget"),Gt={receiptId:S.uuid()},Eo=S.iso.datetime({offset:!0}),mv=S.discriminatedUnion("type",[S.strictObject({type:S.literal("node_entered"),details:S.strictObject({kind:Mo})}),S.strictObject({type:S.literal("presentation_shown"),details:S.strictObject({...Gt,source:S.literal("client"),occurredAt:Eo.optional()})}),S.strictObject({type:S.literal("decision_accepted"),details:S.strictObject(Gt)}),S.strictObject({type:S.literal("signal_received"),details:S.strictObject({signalId:S.uuid(),nodeId:Sn,eventName:Sn,data:ti(8192),source:S.literal("server"),occurredAt:Eo})}),S.strictObject({type:S.literal("signal_consumed"),details:S.strictObject({...Gt,signalId:S.uuid()})}),S.strictObject({type:S.literal("wait_elapsed"),details:S.strictObject(Gt)}),S.strictObject({type:S.literal("wait_timeout"),details:S.strictObject(Gt)}),S.strictObject({type:S.literal("operation_completed"),details:S.strictObject({...Gt,operation:Sn,reference:S.strictObject({type:Sn,id:S.uuid()}).nullable()})}),S.strictObject({type:S.literal("execution_recovered"),details:S.strictObject({generation:S.number().int().positive(),reason:S.enum(["interrupted","expired_lease","delivery_failed"])})}),S.strictObject({type:S.literal("execution_failed"),details:S.strictObject({generation:S.number().int().positive(),code:S.string().regex(/^[a-z_]{1,64}$/)})}),S.strictObject({type:S.literal("run_completed"),details:S.strictObject({outcome:S.enum(["completed","ineligible","failed"])})}),S.strictObject({type:S.literal("run_closed"),details:S.strictObject({source:S.enum(["client","server","expiry"])})}),S.strictObject({type:S.literal("treatment_used"),details:S.strictObject({...Gt,source:S.enum(["client","server"]),occurredAt:Eo,reference:S.string().min(1).max(128).optional()})})]);var et=A.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),af=A.discriminatedUnion("type",[A.strictObject({id:et,type:A.literal("owned"),publicData:nu.optional(),document:Le.refine(e=>["page","popup","onboarding"].includes(e.surface)&&e.pages.length===1&&e.actions.every(t=>t.type==="event"&&!t.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),A.strictObject({id:et,type:A.literal("paywall"),paywallVersionId:A.uuid()})]),Do={executionContract:uo.optional(),kind:A.literal("funnel"),schemaVersion:A.literal(4),screens:A.array(af).max(at.pages),references:A.record(et,To).refine(e=>Object.keys(e).length<=500),inputs:A.array(A.strictObject({variable:et,screenId:et,componentId:et,required:A.boolean()})).max(at.questions),variables:A.record(Ae,on).refine(e=>Object.keys(e).length<=at.logicNodes),outputSchema:rn,execution:A.strictObject({runTimeoutSeconds:A.number().int().min(1).max(Ro.runTimeoutSeconds),maxTransitions:A.number().int().min(1).max(Ro.maxTransitions)})},Ev=A.strictObject({...Do,graph:Co});function sf(e,t){let n=!1,r=(o,a)=>{let l=o.type==="stack"||o.type==="button"?o.bind?.coupon??a:a;o.type==="text"&&Object.values(e.strings.locales).some(p=>p[o.text]?.includes("{{offer."))&&!(l&&t(l))&&(n=!0),o.type==="stack"&&o.children.forEach(p=>r(p,l))};for(let o of e.pages)r(o.root);return n}function ri(e){return Array.isArray(e)?e.some(ri):!e||typeof e!="object"?!1:Object.entries(e).some(([t,n])=>t==="productVersionId"?n===xu:ri(n))}function cf(e){let t=[],n=new Set(Object.values(e.references).flatMap(r=>r.type==="reward"?[r.id]:[]));for(let[r,o]of e.screens.entries()){if(o.type!=="owned")continue;let a;try{a=uu(o.document)}catch(l){t.push({message:l instanceof Error?l.message:"Screen cannot be delivered",reason:"screen",path:["screens",r,"document"]});continue}for(let[l,p]of e.inputs.entries())p.screenId===o.id&&!gi(a,p.componentId)&&t.push({message:`Local Funnel input ${p.variable} targets hidden component ${p.componentId} on screen ${p.screenId}`,reason:"inputBinding",path:["inputs",l]})}for(let[r,o]of e.graph.nodes.entries()){let a=["graph","nodes",r],l=o.type==="screen"?e.screens.find(p=>p.id===o.screenId):void 0;l?.type==="owned"&&(l.document.actions.some(p=>typeof p.properties.templateKey=="string"&&p.properties.templateKey.startsWith("popup-coupon-"))&&t.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),sf(l.document,p=>n.has(p))&&t.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(o.type==="output"&&o.value.type==="literal"&&ri(o.value.value)||o.type==="end"&&o.output?.type==="literal"&&ri(o.output.value))&&t.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return t}function Bu(e,t){for(let{message:n,reason:r,path:o}of cf(e))t.addIssue({code:"custom",message:n,path:o,params:{reason:r}})}function qu(e,t){let n=(C,u,b=[])=>t.addIssue({code:"custom",message:C,path:b,params:{reason:u}}),r=Object.values(e.references),o=new Map(e.screens.map(C=>[C.id,C])),a=(C,u)=>r.some(b=>b.type===C&&("id"in b?b.id:b.key)===u);o.size!==e.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let l=e.graph.nodes.filter(C=>C.type==="screen");(l.length!==o.size||l.some(C=>!o.has(C.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let p=new Map,d=Object.keys(e.variables);d.some(C=>d.some(u=>C!==u&&u.startsWith(C+".")))&&n("Variable paths must not overlap","variable");function v(C,u){Object.hasOwn(e.variables,C)||n("Every produced variable needs a declaration","variable",["graph","nodes",e.graph.nodes.indexOf(u)]);let b=p.get(C)??new Set;b.add(u.id),p.set(C,b)}for(let[C,u]of e.graph.nodes.entries()){let b=["graph","nodes",C],Z=u.type==="feature"?u.featureKey:u.type==="offering"&&u.configuration.source==="feature"?u.configuration.featureKey:u.type==="output"&&u.value.type==="feature"?u.value.featureKey:u.type==="end"&&u.output?.type==="feature"?u.output.featureKey:null;Z&&!a("flag",Z)&&n("Flag selectors require an explicit GB resource reference","feature",b);let E=u.type==="feature"||u.type==="offering"||u.type==="coupon"||u.type==="coupons"||u.type==="action"&&u.action.type==="api"?["value"]:u.type==="action"&&u.action.type==="external_task"?Object.keys(u.action.outputs):u.type==="wait"&&u.wait.type==="event"?Object.keys(u.wait.outputs):[],oe="writes"in u?u.writes??{}:{};(E.length!==Object.keys(oe).length||E.some(L=>!Object.hasOwn(oe,L))||new Set(Object.values(oe)).size!==Object.values(oe).length)&&n("Node writes must map every named output exactly once","variable",b);for(let[L,Y]of Object.entries(oe)){v(Y,u);let pe=e.variables[Y],H=u.type==="offering"?"offering_version":u.type==="coupon"?"reward":u.type==="action"&&u.action.type==="api"?"json":u.type==="action"&&u.action.type==="external_task"?u.action.outputs[L]:u.type==="wait"&&u.wait.type==="event"?u.wait.outputs[L]:void 0;(pe?.source.type!=="node"||H&&pe.type!==H)&&n("Node writer source or output type does not match declaration","variable",b)}if(u.type==="coupons"){let L=e.variables[u.writes.value];(L?.type!=="array"||L.items?.type!=="reward"||L.items.nullable||L.nullable)&&n("Coupons output requires a non-null Reward array","variable",b);for(let Y of u.couponIds)a("reward",Y)||n("Coupons require Reward references","coupon",b)}if(u.type==="split"&&!a("experiment",u.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",b),u.type==="coupon"&&!a("reward",u.couponId)&&n("Coupon selectors require a Reward reference","coupon",b),u.type==="action"&&u.action.type==="claim_offer"&&u.action.coupon.source==="literal"){let L=u.action.coupon.value;(!L||typeof L!="object"||Array.isArray(L)||L.type!=="reward"||typeof L.id!="string"||Object.keys(L).length!==2||!a("reward",L.id))&&n("Coupon claims require a Reward reference","coupon",b)}if(u.type==="offering"&&u.configuration.source==="fixed"&&!a("offering_version",u.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",b),u.type==="screen"&&u.offering?.source==="variable"&&e.variables[u.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",b),u.type==="action"&&u.action.type==="claim_offer"&&u.action.coupon.source==="variable"&&(e.variables[u.action.coupon.key]?.type!=="reward"||u.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",b),u.type==="screen"){let L=o.get(u.screenId);if(u.offering?.source==="fixed"&&!a("offering_version",u.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",b),L?.type==="paywall"&&u.offering&&n("Paywall owns its fixed Offering Version","offering",b),L?.type==="paywall"&&!a("paywall_version",L.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",b),L?.type==="owned"){let Y=L.document.pages[0];if(!Y){n("Owned screen requires a page","screen",b);continue}It(L.document).some(H=>!H.complete)&&n("Owned screens require complete local content","translations",b);let pe=new Set(L.document.actions.map(H=>H.id));(pe.size!==Object.keys(u.outputs).length||Object.keys(u.outputs).some(H=>!pe.has(H)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",b),Yt(Y.root,H=>{!u.offering&&(H.type==="plan_picker"||(H.type==="stack"||H.type==="button")&&H.bind?.plan||H.type==="customer_data"&&["customer_plans","credit_packs"].includes(H.data.source))&&n("Product presentation requires an Offering Version","offering",b),H.type==="customer_data"&&Object.values(H.data.outputs??{}).some(St=>St!==void 0&&!pe.has(St))&&n("Customer components require declared screen outcomes","componentOutput",b)})}}u.type==="end"&&["completed","ineligible"].includes(u.outcome)&&!u.output&&n("Completed and ineligible ends require a declared output","output",b),u.type==="end"&&u.output?.type==="literal"&&!Xe(e.outputSchema,u.output.value)&&n("Terminal output does not match outputSchema","output",b),u.type==="output"&&u.value.type==="literal"&&!Xe(e.outputSchema,u.value.value)&&n("Terminal output does not match outputSchema","output",b);let ke=u.type==="output"?u.value:u.type==="end"?u.output:void 0;if(ke?.type==="variable"&&!ke.path){let L=e.variables[ke.key];L&&!Ai(L,e.outputSchema)&&n("Variable output does not match outputSchema","output",b)}if(u.type==="screen"){let L=o.get(u.screenId);if(L?.type==="owned")for(let Y of Ci(L.document))(/^(input|params)\./.test(Y)||Y.startsWith("variables.")&&!Pi(Y.slice(10),d))&&n("Screen values must reference registered variables","variable",b)}if(u.type==="condition")for(let L of u.cases){for(let Y of vt(L.condition))a("saved_group",Y)||n("Conditions require explicit Saved Group references","savedGroup",b);for(let Y of jt(L.condition))Y.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",b)}if(u.type==="output"&&u.value.type==="bundle"){e.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",b);for(let[L,Y]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let pe=u.value[L];if(pe)if(pe.source==="literal"){let H=L==="coupons"?pe.value:[pe.value];(!Array.isArray(H)||H.length>20||H.some(St=>!Xe({type:Y,nullable:!1},St)||!a(Y,St.id))||L==="coupons"&&new Set(H.map(St=>St.id)).size!==H.length)&&n("Bundle requires distinct scoped resource references",L==="coupons"?"coupon":L==="paywall"?"paywall":"offering",[...b,"value",L])}else{let H=e.variables[pe.key];(pe.path||!H||H.nullable||(L==="coupons"?H.type!=="array"||H.items?.type!=="reward"||H.items.nullable:H.type!==Y))&&n("Bundle binding type does not match its slot","output",b)}}}}for(let[C,u]of e.graph.nodes.entries()){let b=u.type==="screen"?o.get(u.screenId):void 0,Z=[...Du(u,d),...b?.type==="owned"?xr(b.document).map(E=>Pi(E,d)?.key??E):[]];for(let E of new Set(Z)){let Y=function(pe){if(pe===u.id)return!0;if(L.has(pe))return!1;L.add(pe);let H=e.graph.nodes.find(nl=>nl.id===pe);return H?(ke.has(pe)?H.type==="action"?[H.cancel,H.unavailable,H.failure]:H.type==="wait"&&H.wait.type==="event"?[H.wait.timeout]:[]:ei(H)).some(Y):!1};var $=Y;if(!Object.hasOwn(e.variables,E)){n("Consumed variable is undeclared","variable",["graph","nodes",C]);continue}let oe=e.variables[E];if(u.type==="screen"&&oe.source.type==="input"&&e.inputs.some(pe=>pe.screenId===u.screenId&&pe.variable===E)||oe.source.type==="parameter"||oe.source.type==="attribute")continue;let ke=oe.source.type==="input"?new Set(e.inputs.filter(pe=>pe.variable===E&&pe.required).flatMap(pe=>l.filter(H=>H.screenId===pe.screenId).map(H=>H.id))):p.get(E)??new Set,L=new Set;(!ke.size||Y(e.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",C])}}(new Set(e.inputs.map(C=>C.variable)).size!==e.inputs.length||new Set(e.inputs.map(C=>`${C.screenId}:${C.componentId}`)).size!==e.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[C,u]of e.inputs.entries()){e.variables[u.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",C]);let b=o.get(u.screenId),Z=b?.type==="owned"?gi(b.document,u.componentId):null;if((Z?.type!=="stack"||!Z.interaction||!["input","toggle","select","multiselect","tabs"].includes(Z.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",C]),Z?.type==="stack"&&Z.interaction){let E=Z.interaction.type==="toggle"?"boolean":Z.interaction.type==="multiselect"?"strings":"string";e.variables[u.variable]?.type!==E&&n("Input variable type does not match component","inputBinding",["inputs",C]);let oe=e.variables[u.variable]?.enum;oe&&!Z.children.filter(ke=>!ke.hidden).every(ke=>oe.includes(ke.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",C])}}for(let[C,u]of Object.entries(e.variables))u.enum&&u.type!=="string"&&n("Only string variables support enum","variable",["variables",C]),u.source.type==="input"&&!e.inputs.some(b=>b.variable===C)&&n("Input variable requires a component binding","inputBinding",["variables",C]);let h=0,T=0;for(let C of e.screens)if(C.type==="owned"){for(let u of C.document.pages)Yt(u.root,()=>{h++});T+=C.document.actions.length}(h>at.components||T>at.actions||Ze(e)>at.documentBytes)&&n("Funnel document exceeds its budget","budget")}var uf=A.strictObject({...Do,graph:ko}).superRefine(qu),Ct=A.strictObject({...Do,graph:ko,displayName:A.string().trim().min(1).max(80)}).superRefine(qu),Mv=Ct.superRefine(Bu),Tv=uf.superRefine(Bu),ni=A.string().regex(pt),Jn={requestId:A.uuid(),nodeId:et,visit:A.number().int().nonnegative(),revision:A.number().int().nonnegative(),customerToken:ni.optional()},pf=A.discriminatedUnion("type",[A.strictObject({type:A.literal("screen"),output:et,answers:Et,selection:A.record(et,A.union([A.string().max(200),A.boolean(),A.number().int().min(0).max(1e4)])).optional()}),A.strictObject({type:A.literal("paywall_quote"),featureQuantities:A.record(A.uuid(),A.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100).optional(),actionId:et,productVersionId:A.uuid(),offerId:A.uuid().optional(),nativeOffer:pn.optional(),predecessor:A.strictObject({operationId:A.uuid().nullable(),generation:A.number().int().positive()}).optional()}),A.strictObject({type:A.literal("paywall_confirm"),operationId:A.uuid()}),A.strictObject({type:A.literal("paywall_cancel"),operationId:A.uuid()}),A.strictObject({type:A.literal("client_action"),receiptId:A.uuid(),outcome:A.enum(["success","cancel","failure","opened","failed"])})]),lf=A.object({nodeId:et,visit:A.number().int().nonnegative(),revision:A.number().int().nonnegative(),components:A.record(et,A.object({resourceKey:A.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:A.number().int().min(1).max(1e5),after:pr.nullable(),filter:A.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(e=>Object.keys(e).length<=150)}).strict(),tt=A.discriminatedUnion("operation",[A.strictObject({operation:A.literal("start"),funnelId:A.uuid(),requestId:A.uuid(),customer:xt.optional(),customerData:Pt.optional(),locale:A.string().min(1).max(35),parameters:ut}).refine(Ut,$t),A.strictObject({operation:A.literal("get"),settlementRequestId:A.uuid().optional(),data:lf.optional(),purchase:A.strictObject({receiptId:A.uuid(),operationId:A.uuid()}).optional(),customerToken:ni.optional()}),A.strictObject({operation:A.literal("resume"),requestId:A.uuid(),customerToken:ni.optional()}),A.strictObject({operation:A.literal("submit"),...Jn,input:pf}),A.strictObject({operation:A.literal("back"),...Jn}),A.strictObject({operation:A.literal("shown"),...Jn}),A.strictObject({operation:A.literal("close"),...Jn}),A.strictObject({operation:A.literal("commit_segment"),...Jn,policyRevision:A.number().int().nonnegative(),generation:A.string().min(1).max(256)}),A.strictObject({operation:A.literal("review"),receiptId:A.uuid().optional(),customerToken:ni.optional()})]);function ii(e,t){let n=new Set,r=new Set,o=new Set,a=[],l=new Map,p=new Map,d=new Map;function v(u){for(let b of vt(u))h(b)}function h(u){if(o.has(u)||!Object.hasOwn(t.savedGroups,u))return;let b=t.savedGroups[u];b&&(o.add(u),d.set(u,b),a.push(()=>{!Array.isArray(b)&&b.type==="condition"&&v(b.condition)}))}function T(u){for(let b of["hashAttribute","fallbackAttribute"])if(u[b]!==void 0&&yo(u[b]))throw new Error(`Funnel GB ${b} uses a reserved flow namespace`);v(u.condition);for(let b of u.parentConditions??[])$(b.id),v(b.condition)}function $(u,b=!1){let Z=Object.hasOwn(t.features,u)?t.features[u]:void 0;if(!Z){if(b)throw new Error("Required GB Feature is unavailable");return}n.has(u)||(n.add(u),l.set(u,Z),a.push(()=>{for(let E of Z.rules??[]){T(E);for(let oe of E.tracks??[])T(oe.experiment)}}))}function C(u){let b=Object.hasOwn(t.experiments,u)?t.experiments[u]:void 0;if(!b)throw new Error("Required GB Experiment is unavailable");r.has(u)||(r.add(u),p.set(u,b),a.push(()=>T(b)))}for(let u of e.graph.nodes){u.type==="feature"&&$(u.featureKey,!0),u.type==="split"&&C(u.experimentId),u.type==="condition"&&u.cases.forEach(Z=>v(Z.condition)),u.type==="offering"&&u.configuration.source==="feature"&&$(u.configuration.featureKey,!0);let b=u.type==="output"?u.value:u.type==="end"?u.output:null;b?.type==="feature"&&$(b.featureKey,!0)}for(let u of a)u();return{...t,features:Object.fromEntries(l),experiments:Object.fromEntries(p),savedGroups:Object.fromEntries(d)}}import{z as B}from"zod";import{z as Wn}from"zod";var Fu=Wn.object({defaultLocale:Jt,locales:Wn.record(Jt,Wn.object({name:Wn.string().max(80),description:Wn.string().max(500)}).strict())}).strict().superRefine((e,t)=>{let n=Object.keys(e.locales);(!n.length||n.length>20||!e.locales[e.defaultLocale])&&t.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(e)).length>5e4&&t.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var mf=["customer_data","coupon_code"],df=B.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Nu=B.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),oi=(e,t)=>new Set(e.map(t)).size===e.length,ff=B.strictObject({currency:ie,amountMinor:B.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),gf=B.strictObject({featureId:B.uuid(),name:B.string().trim().min(1).max(120),allowance:B.string().max(40).nullable(),access:B.boolean()}),hf=B.strictObject({stripe:B.strictObject({prices:B.array(ff).min(1).max(50)}).optional(),apple:B.strictObject({productIds:B.array(df).min(1).max(10)}).optional(),google:B.strictObject({products:B.array(B.strictObject({productId:Nu,basePlanId:Nu.nullable()})).min(1).max(10)}).optional()}).superRefine((e,t)=>{(e.stripe&&!oi(e.stripe.prices,n=>n.currency)||e.apple&&!oi(e.apple.productIds,n=>n)||e.google&&!oi(e.google.products,n=>`${n.productId}:${n.basePlanId}`))&&t.addIssue({code:"custom",message:"Duplicate channel entry"})}),bf=B.strictObject({name:B.string().trim().min(1).max(80),interval:B.enum(["free","week","month","year","one_time"]),intervalCount:B.number().int().min(1).max(100),trial:B.strictObject({days:B.number().int().min(1).max(730),cardRequired:B.boolean()}).nullable(),benefits:B.array(gf).max(50).refine(e=>oi(e,t=>t.featureId),"Duplicate benefit"),channels:hf,prepaid:B.array(Aa).max(100).optional()}),yf=B.strictObject({digest:hn,content:B.strictObject({discount:At,duration:He,appliesTo:Fi,displayCopy:Fu.nullable(),firstPurchaseOnly:B.boolean(),qualificationRequired:B.boolean(),startsAt:B.iso.datetime().nullable(),endsAt:B.iso.datetime().nullable(),grantWindowHours:B.number().int().positive(),perCustomerLimit:B.number().int().positive()})}),xf=B.discriminatedUnion("type",[B.strictObject({type:B.literal("checkout"),product:Gr}),B.strictObject({type:B.literal("close")}),B.strictObject({type:B.literal("action"),action:io})]),Vu=B.strictObject({kind:B.literal("paywall"),formatVersion:B.literal(1),name:B.string().trim().min(1).max(80),offeringVersionId:B.uuid(),presentation:yt,screen:Le,products:vr,catalog:B.record(B.uuid(),bf),buttons:B.record(kn,xf),coupons:B.record(B.uuid(),yf)}).superRefine((e,t)=>{let n=b=>t.addIssue({code:"custom",message:b}),{screen:r}=e;Da(r,e.catalog).forEach(n),r.surface!=="paywall"&&n("Screen must be a Paywall"),lo(r,mf).forEach(n),It(r).some(b=>!b.complete)&&n("Every published locale must be complete");let o=new Set,a=new Set,l=new Set;gt(r,b=>{let Z="bind"in b?b.bind:void 0;Z?.promotionCode&&n("Promotion codes must not be published"),Z?.plan&&o.add(Z.plan),Z?.coupon&&a.add(Z.coupon),b.type==="plan_picker"&&(b.planIds?.forEach(E=>o.add(E)),b.defaultPlan&&o.add(b.defaultPlan)),b.type==="text"&&b.feature&&l.add(b.feature.id)});let p=e.products.items.map(b=>b.productVersionId),d=Object.keys(e.catalog);(p.length!==d.length||p.some(b=>!Object.hasOwn(e.catalog,b)))&&n("Catalog must contain exactly the displayed Products");let v=new Set(p);e.products.defaultProductVersionId!==null&&!v.has(e.products.defaultProductVersionId)&&n("Default Product must be displayed");for(let b of o)v.has(b)||n("Screen references a Product that is not displayed");for(let b of Object.values(e.catalog))!b.channels.stripe&&!b.channels.apple&&!b.channels.google&&n("A displayed Product needs at least one sales channel");let h=new Set(Object.values(e.catalog).flatMap(b=>b.benefits.map(Z=>Z.featureId)));for(let b of l)h.has(b)||n("Feature text must read a displayed benefit");let T=r.actions.filter(b=>b.type!=="navigate");r.actions.some(b=>b.type!=="event"&&b.type!=="navigate")&&n("Paywall actions are events or navigation"),(Object.keys(e.buttons).length!==T.length||T.some(b=>!Object.hasOwn(e.buttons,b.id)))&&n("Buttons must match the screen's actions");let C=!1;for(let b of Object.values(e.buttons)){if(b.type!=="checkout")continue;C=!0,(b.product.type==="fixed"?[b.product.productVersionId]:b.product.allowedProductVersionIds).some(E=>!v.has(E))&&n("Checkout may only sell displayed Products")}C||n("A Paywall needs a checkout button");let u=Object.keys(e.coupons);(u.length!==a.size||u.some(b=>!a.has(b)))&&n("Coupons must be exactly the bound Coupons")}),Uu=B.strictObject({state:B.enum(["published","archived"]),controlRevision:B.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:B.uuid(),versions:B.record(B.uuid(),B.strictObject({version:B.number().int().positive(),artifact:B.string().min(1),sourceDigest:B.string().regex(/^[a-f0-9]{64}$/)}))}).refine(e=>Object.keys(e.versions).length>0,"Reviewed Paywall Versions are required");var Sf={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},zo=X.string().regex(/^[a-f0-9]{64}$/),Bo=X.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),vf=le.extend({environmentId:X.uuid()}),$u=X.strictObject({features:X.array(X.string()).max(500),experiments:X.record(X.uuid(),X.array(X.string()).max(20)),savedGroups:X.array(X.string()).max(1e3)}),No=X.strictObject({kind:X.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:X.number().int().positive(),url:X.string().min(1).max(2048),sha256:zo,byteLength:X.number().int().positive().max(Sf.maxArtifactBytes),generation:zo.optional()}),If=X.strictObject({state:X.enum(["active","paused","archived"]),controlRevision:Bo,evaluationMode:X.enum(["local","remote"]),evaluationRevision:Bo,currentVersionId:X.uuid(),versions:X.record(X.uuid(),X.strictObject({artifact:X.string(),dependencies:$u,definitionDigest:hn.optional(),couponDigests:X.record(X.uuid(),hn).optional()}))}),lI=X.strictObject({kind:X.literal("sdk_configuration"),schemaVersion:X.literal(1),scope:vf,revision:Bo,generation:zo,policy:X.strictObject({refreshIntervalSeconds:X.number().positive().max(15),maxControlAgeSeconds:X.number().positive().max(60)}),gb:X.strictObject({features:X.string().nullable(),pageExperiments:X.string().nullable()}),artifacts:X.record(X.string(),No),funnels:X.record(X.uuid(),If),paywalls:X.record(X.uuid(),Uu).optional()}).superRefine((e,t)=>{let n=(r,o)=>{r!==null&&e.artifacts[r]?.kind!==o&&t.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};n(e.gb.features,"gb_features"),n(e.gb.pageExperiments,"gb_page_experiments");for(let r of Object.values(e.paywalls??{}))for(let o of Object.values(r.versions))n(o.artifact,"paywall");for(let r of Object.values(e.funnels)){r.evaluationMode==="remote"&&Object.keys(r.versions).length&&t.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),r.evaluationMode==="local"&&!r.versions[r.currentVersionId]&&t.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let o of Object.values(r.versions))n(o.artifact,"funnel")}});function qo(e){if(Array.isArray(e))return`[${e.map(qo).join(",")}]`;if(e!==null&&typeof e=="object")return`{${Object.entries(e).sort(([n],[r])=>n<r?-1:n>r?1:0).map(([n,r])=>`${JSON.stringify(n)}:${qo(r)}`).join(",")}}`;let t=JSON.stringify(e);if(t===void 0)throw new Error("Configuration must contain JSON values");return t}function Of(e){return ar(sr(typeof e=="string"?new TextEncoder().encode(e):e))}function mI(e){return Of(qo(e))}var Fo=class extends Error{constructor(n,r){super(n);this.dependency=r}dependency};function dI(e,t){let n=h=>h.type==="feature"?h.featureKey:h.type==="end"&&h.output?.type==="feature"?h.output.featureKey:h.type==="output"&&h.value.type==="feature"?h.value.featureKey:void 0,r=(h,T)=>e.graph.nodes.find($=>h==="experiment"?$.type==="split"&&$.experimentId===T:h==="feature"&&n($)===T)?.name,o=(h,T,$=r(T.type,T.resource))=>new Fo(h,{...T,...$?{step:$}:{}});for(let h of Object.values(e.references)){let T=h.type==="flag"?!Object.hasOwn(t.features,h.key)||t.remoteFeatures.includes(h.key)?{type:"feature",resource:h.key}:null:h.type==="experiment"?Object.hasOwn(t.experiments,h.id)?null:{type:"experiment",resource:h.id}:h.type==="saved_group"&&!Object.hasOwn(t.savedGroups,h.id)?{type:"saved_group",resource:h.id}:null;if(T)throw o("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...T})}let a=ii(e,{...t,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),l=new Set(t.remoteFeatures);for(let h of e.graph.nodes){let T=n(h);if(!T)continue;let $=a.features[T],C=h.type==="feature"?e.variables[h.writes.value]:e.outputSchema,u={type:"feature",resource:T};if(!$||!C)throw o("Required public Feature declaration is unavailable",{reason:"unavailable",...u},h.name);if([$.defaultValue,...($.rules??[]).flatMap(Z=>[...Object.hasOwn(Z,"force")?[Z.force]:[],...Z.variations??[],...(Z.tracks??[]).flatMap(E=>E.experiment.variations)])].some(Z=>Z===void 0||!Xe(C,Z)))throw o("GB Feature values violate the Funnel type contract",{reason:"value_type",...u},h.name)}let p=new Set,d=(h,T)=>{for(let $ of vt(h)){if(p.has($))continue;let C=t.savedGroups[$];if(!C)throw o("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:$},T);p.add($),!Array.isArray(C)&&C.type==="condition"&&d(C.condition,T)}},v=(h,T)=>{if(l.has(h)||!t.features[h])throw o("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:h},T)};for(let h of e.graph.nodes)if(h.type==="condition")for(let T of h.cases)d(T.condition,h.name);for(let[h,T]of Object.entries(a.features)){let $=r("feature",h);for(let C of T.rules??[]){d(C.condition,$);for(let u of[...C.parentConditions??[],...(C.tracks??[]).flatMap(b=>b.experiment.parentConditions??[])])v(u.id,$),d(u.condition,$);for(let u of C.tracks??[])d(u.experiment.condition,$)}}for(let[h,T]of Object.entries(a.experiments)){let $=r("experiment",h);d(T.condition,$);for(let C of T.parentConditions??[])v(C.id,$),d(C.condition,$)}for(let h of e.graph.nodes)if(h.type==="split"){let T=a.experiments[h.experimentId],$={type:"experiment",resource:h.experimentId};if(!T)throw o("Local Funnel requires a public Experiment",{reason:"unavailable",...$},h.name);for(let C of T.variations)if(typeof C!="string"||!Object.hasOwn(h.routes,C))throw o("Experiment variation has no declared Funnel route",{reason:"variation_route",...$},h.name)}return $u.parse({features:Object.keys(a.features).sort(),experiments:Object.fromEntries(Object.entries(a.experiments).map(([h,T])=>[h,T.variations.map(String)])),savedGroups:[...p].sort()})}function fI(e){return Ct.parse(e)}var Gu=_e.strictObject({processContext:Mr.optional(),...un,selector:_e.discriminatedUnion("type",[_e.strictObject({type:_e.literal("paywall"),paywallId:_e.uuid()}),_e.strictObject({type:_e.literal("version"),versionId:_e.uuid()})]),customerId:_e.uuid().optional(),commerce:ur,locale:_e.string().min(1).max(35),requirement:Qt.optional()}),Qn=_e.strictObject({id:_e.uuid(),paywallId:_e.uuid(),version:_e.number().int().positive(),document:gn.omit({requirement:!0,offeringId:!0}),offering:_e.strictObject({id:_e.uuid()}),content:_e.strictObject({environmentId:_e.uuid(),offeringVersionId:_e.uuid(),artifact:No.refine(e=>e.kind==="paywall"&&e.formatVersion===1)}).optional(),capabilities:Xt,check:Cn.nullable()}).superRefine((e,t)=>{let n=new Set(e.document.products.items.map(r=>r.productVersionId));(e.document.offeringVersionId!==e.offering.id||Object.values(e.capabilities.plans).some(r=>!n.has(r.versionId)))&&t.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),Xn=_e.strictObject(Qn.shape).omit({document:!0,offering:!0}).extend({content:Qn.shape.content.unwrap()});function wI(e,t){let n=Vu.parse(t);if(n.offeringVersionId!==e.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let r=structuredClone(e.capabilities);for(let[o,a]of Object.entries(n.catalog)){let l=r.plans[o],p=a.channels.stripe?.prices.find(d=>d.currency===l?.currency);l&&p&&Object.assign(l,{amountMinor:p.amountMinor,interval:a.interval,intervalCount:a.intervalCount,...a.prepaid?.length?{prepaid:a.prepaid}:{}})}return Qn.parse({...e,capabilities:r,document:{schemaVersion:3,kind:n.kind,name:n.name,presentation:n.presentation,products:n.products,offeringVersionId:n.offeringVersionId,screen:n.screen,buttons:n.buttons},offering:{id:n.offeringVersionId}})}import{z as Ve}from"zod";var Ku={requestId:Ve.uuid(),sourceId:Ve.uuid(),expectedAvailable:Wt},Lu=Ve.discriminatedUnion("action",[Ve.strictObject({...Ku,action:Ve.enum(["add","subtract","set_remaining"]),amount:be}),Ve.strictObject({...Ku,action:Ve.literal("edit"),granted:be,expiresAt:Ve.iso.datetime({offset:!0}).nullable(),nextResetAt:Ve.iso.datetime({offset:!0}).nullable(),expectedRevision:Ve.number().int().nonnegative()})]),Vo=Ve.strictObject({sourceId:Ve.uuid(),available:Wt,held:Wt,spent:Wt,adjustmentGrantId:Ve.uuid().nullable()}),Zu=Vo.extend({granted:Wt,expiresAt:Ve.iso.datetime({offset:!0}).nullable(),nextResetAt:Ve.iso.datetime({offset:!0}).nullable(),revision:Ve.number().int().nonnegative()});import{z as Qe}from"zod";var Hu=Qe.discriminatedUnion("action",[Qe.object({action:Qe.literal("upsert"),externalId:Qe.string().min(1).max(128),name:Qe.string().trim().min(1).max(80)}).strict(),Qe.object({action:Qe.literal("archive"),entityId:Qe.uuid()}).strict()]),Ju=Qe.object({id:Qe.uuid(),externalId:Qe.string().min(1).max(128),name:Qe.string().min(1).max(80),archived:Qe.boolean()}).strict();import{z as ze}from"zod";import{z as Lt}from"zod";var Qu=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],Wu=Lt.string().regex(/.+\/.+/),Uo=Lt.number().min(-100),Kt=Lt.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),jf=Lt.strictObject({input:Kt,output:Kt,cache_read:Kt.optional(),cache_write:Kt.optional(),reasoning:Kt.optional(),input_audio:Kt.optional(),output_audio:Kt.optional()}),$o=(e,t)=>Lt.record(e,t).refine(n=>Object.keys(n).length<=100,"At most 100 AI overrides"),DI=Lt.strictObject({defaultMarkup:Uo,providerMarkups:$o(Lt.string().min(1),Uo),modelMarkups:$o(Wu,Uo),customModels:$o(Wu,jf.partial())});import{z as K}from"zod";var Zt=K.iso.datetime({offset:!0}),kt=K.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,12})?$/),Af=K.discriminatedUnion("kind",[K.object({kind:K.literal("absolute"),from:Zt,to:Zt}).strict(),K.object({kind:K.literal("last_days"),days:K.union([K.literal(1),K.literal(7),K.literal(30),K.literal(90)])}).strict(),K.object({kind:K.literal("billing_cycles"),membershipId:K.uuid(),count:K.number().int().min(1).max(12),includeCurrent:K.boolean()}).strict()]),Xu=K.string().max(100).refine(e=>{if(e!=="UTC"&&!/^[A-Za-z_]+(?:\/[A-Za-z0-9_+\-]+)+$/.test(e))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:e}),!0}catch{return!1}},"Use an IANA timezone"),wf=K.object({key:K.string().regex(/^[a-z][a-z0-9_]{0,63}$/),values:K.array(K.string().max(120)).min(1).max(20).refine(e=>new Set(e).size===e.length)}).strict(),Ht=K.object({range:Af,timezone:Xu,filterBy:K.array(wf).max(5).refine(e=>new Set(e.map(t=>t.key)).size===e.length),interval:K.enum(["hour","day","week","month"]),internal_feature_id:K.uuid().nullable(),entityId:K.uuid().nullable(),topN:K.number().int().min(1).max(50).nullable(),groupBy:K.union([K.enum(["customer","entity","entitlement","source","resource","dimension","plan"]),K.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:K.object({bucket:Zt,group:K.string().max(240),isOther:K.boolean(),internal_feature_id:K.uuid(),resourceId:K.uuid()}).strict().nullable(),limit:K.number().int().min(1).max(100)}).strict().superRefine((e,t)=>{if(e.range.kind!=="absolute"){e.interval==="hour"&&e.range.kind==="last_days"&&e.range.days>31&&t.addIssue({code:"custom",message:"Hourly reports are bounded to 31 days"});return}let n=Date.parse(e.range.to)-Date.parse(e.range.from);(n<=0||n>366*864e5||e.interval==="hour"&&n>31*864e5)&&t.addIssue({code:"custom",message:"Reporting range must be positive and bounded (31 days hourly, 366 days otherwise)"})}),Yu=K.object({from:Zt,to:Zt,interval:K.enum(["hour","day","week","month"]),timezone:Xu,rows:K.array(K.object({bucket:Zt,group:K.string().max(240),isOther:K.boolean(),internal_feature_id:K.uuid(),resourceId:K.uuid(),consumedUnits:kt,refundedUnits:kt,reservedUnits:kt,charged:kt,refunded:kt,reserved:kt,netUnits:kt,netCharged:kt}).strict()).max(100),nextCursor:K.object({bucket:Zt,group:K.string().max(240),isOther:K.boolean(),internal_feature_id:K.uuid(),resourceId:K.uuid()}).strict().nullable()}).strict();var vn=ze.string().regex(/^(0|[1-9]\d{0,29})$/),ep=ze.string().regex(/^(0|[1-9]\d{0,29})(\.\d{1,18})?$/),Go=ze.strictObject({bucket:ze.iso.datetime({offset:!0}),group:ze.string().max(240),isOther:ze.boolean(),internal_feature_id:ze.uuid()}),tp=ze.strictObject({...Ht.shape,groupBy:ze.union([ze.enum(["customer","entity","entitlement"]),ze.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:Go.nullable()}).superRefine((e,t)=>{let n=Ht.safeParse({...e,after:null});if(!n.success)for(let r of n.error.issues)t.addIssue({code:"custom",path:r.path,message:r.message})}),np=ze.strictObject({from:ze.iso.datetime({offset:!0}),to:ze.iso.datetime({offset:!0}),interval:Ht.shape.interval,timezone:Ht.shape.timezone,rows:ze.array(ze.strictObject({...Go.shape,eventCount:vn,units:ep,tokenEventCount:vn,tokens:ze.strictObject(Object.fromEntries(Qu.map(e=>[e,vn]))),totalTokens:vn,providerCostEventCount:vn,providerCostUsd:ep,invalidTelemetryEventCount:vn})).max(100),nextCursor:Go.nullable()});import{z as Oe}from"zod";var rp=Oe.object({requestId:Oe.uuid(),items:Oe.array(Oe.object({customerId:Oe.uuid(),command:_n.options[1]}).strict()).min(1).max(1e3)}).strict().refine(e=>new Set(e.items.map(t=>t.customerId+":"+t.command.idempotencyKey)).size===e.items.length,"Each logical event must appear once in a batch"),ip=Oe.object({batchId:Oe.uuid(),after:Oe.number().int().min(-1).max(999),limit:Oe.number().int().min(1).max(100)}).strict(),op=Oe.object({batchId:Oe.uuid(),status:Oe.enum(["queued","complete"]),total:Oe.number().int().min(1).max(1e3),processed:Oe.number().int().min(0).max(1e3),items:Oe.array(Oe.object({position:Oe.number().int().min(0).max(999),customerId:Oe.uuid(),idempotencyKey:Oe.string().min(1).max(120),status:Oe.enum(["queued","accepted","rejected","failed"]),receipt:Pn.nullable(),errorCode:Oe.enum(["invalid_request","forbidden","conflict","internal_error"]).nullable()}).strict().refine(e=>e.status==="queued"?e.receipt===null&&e.errorCode===null:e.status==="failed"?e.receipt===null&&e.errorCode!==null:e.receipt!==null&&e.errorCode===null&&e.receipt.accepted===(e.status==="accepted"))).max(100),nextAfter:Oe.number().int().min(0).max(999).nullable()}).strict();import{z as f}from"zod";var _f=f.enum(["percentage_discount","fixed_discount","free_product","invoice_credits","feature_grant"]),ap=f.enum(["draft","active","paused","archived"]),sp=f.string().min(1).max(256),cp=f.array(sp).max(50).refine(e=>new Set(e).size===e.length,"Duplicate products"),Pf=f.strictObject({duration:f.enum(["day","week","month","year"]),length:f.number().int().min(1).max(3660)}),Cf=f.strictObject({internal_feature_id:f.uuid(),allowance:f.number().nonnegative().max(1e15).nullable(),expiry:Pf.nullable()}),kf=f.discriminatedUnion("type",[f.strictObject({type:f.literal("feature_grant"),grants:f.array(Cf).min(1).max(100).refine(e=>new Set(e.map(t=>t.internal_feature_id)).size===e.length,"Duplicate entitlement grants")}),f.strictObject({type:f.literal("free_product"),productId:sp,duration:He}),f.strictObject({type:f.literal("invoice_credits"),amount:f.number().positive().max(1e8),duration:He,rollover:f.boolean(),productIds:cp})]),Rf=f.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),up=f.object({key:Rf,name:f.string().trim().min(1).max(80),configuration:kf}).strict(),pp=f.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),Ko=f.object({code:pp,maxUses:f.number().int().min(1).max(1e6).nullable(),firstPurchaseOnly:f.boolean()}).strict(),lp=f.object({key:f.string().regex(/^[a-z][a-z0-9_]{0,63}$/),name:f.string().trim().min(1).max(80),rewardId:f.uuid(),redeemOn:f.enum(["customer_creation","checkout"]),receivedBy:f.enum(["referrer","all"]),maxRedemptions:f.number().int().min(1).max(1e6).nullable(),productIds:cp,excludeTrial:f.boolean()}).strict().refine(e=>e.redeemOn==="checkout"||e.productIds.length===0&&!e.excludeTrial,"Purchase restrictions require checkout trigger"),mp={id:f.uuid(),projectId:f.uuid(),environmentId:f.uuid(),revision:f.number().int().nonnegative(),status:ap,createdAt:f.iso.datetime({offset:!0}),updatedAt:f.iso.datetime({offset:!0})},Ef=up.extend(mp).strict(),Mf=lp.safeExtend(mp).strict(),JI=f.strictObject({id:f.uuid(),key:f.string(),name:f.string(),type:_f,status:ap}),WI=f.discriminatedUnion("action",[f.object({action:f.literal("save"),id:f.uuid().nullable(),revision:f.number().int().nonnegative(),input:up}).strict(),f.object({action:f.enum(["activate","pause","resume","archive","delete"]),id:f.uuid(),revision:f.number().int().nonnegative()}).strict()]),QI=f.discriminatedUnion("action",[f.object({action:f.literal("save"),id:f.uuid().nullable(),revision:f.number().int().nonnegative(),input:lp}).strict(),f.object({action:f.enum(["activate","pause","resume","archive","delete"]),id:f.uuid(),revision:f.number().int().nonnegative()}).strict()]),dp=f.object({id:f.uuid(),rewardId:f.uuid(),programId:f.uuid().nullable(),customerId:f.uuid(),referrerId:f.uuid().nullable(),status:f.enum(["pending","applied","unavailable"]),result:f.record(f.string(),f.unknown()).nullable(),createdAt:f.iso.datetime({offset:!0})}).strict(),fp=f.object({code:pp,requestId:f.uuid()}).strict(),gp=f.strictObject({redemptionId:f.uuid(),currency:ie,requestId:f.uuid(),accepted:f.literal(!0)}),Tf=f.strictObject({type:f.literal("checkout"),orderId:f.uuid(),productVersionId:f.uuid(),currency:ie,duration:He,renewalAmountMinor:f.number().int().positive().max(1e8),status:f.enum(["created","pending","trialing","paid","cancelled","failed"]),url:f.url().nullable()}),hp=f.discriminatedUnion("type",[Tf,f.strictObject({type:f.literal("subscription"),operationId:f.uuid(),membershipId:f.uuid(),productVersionId:f.uuid(),currency:ie,duration:He,renewalAmountMinor:f.number().int().positive().max(1e8),status:f.enum(["pending","running","applied","failed"])})]),bp=f.object({programId:f.uuid(),requestId:f.uuid()}).strict(),yp=f.object({id:f.uuid(),programId:f.uuid(),code:Ko.shape.code,createdAt:f.iso.datetime({offset:!0})}).strict(),XI=f.object({rows:f.array(Ef).max(100),nextCursor:f.uuid().nullable()}).strict(),YI=f.object({rows:f.array(Mf).max(100),nextCursor:f.uuid().nullable()}).strict(),Df=Ko.extend({id:f.uuid(),redemptions:f.number().int().nonnegative()}).strict(),zf=f.strictObject({id:f.uuid(),programId:f.uuid().nullable(),customerId:f.uuid().nullable(),referrerId:f.uuid().nullable(),code:f.string().nullable(),status:f.enum(["pending","triggered","applied"]),createdAt:f.iso.datetime({offset:!0})}),e0=f.object({codes:f.array(Df).max(100),redemptions:f.array(zf).max(100),customers:f.record(f.uuid(),f.string()),codesCursor:f.uuid().nullable(),redemptionsCursor:f.uuid().nullable()}).strict(),t0=f.discriminatedUnion("action",[f.object({action:f.literal("create"),rewardId:f.uuid(),revision:f.number().int().nonnegative(),input:Ko}).strict(),f.object({action:f.literal("remove"),rewardId:f.uuid(),revision:f.number().int().nonnegative(),codeId:f.uuid()}).strict()]);import{z as c}from"zod";import{z as R}from"zod";var dt={repositories:20,branches:4,keys:2e3,references:1e4,referencesPerKey:2e3,reportBytes:1048576,files:1e4,sourceBytes:1e8},Yn=e=>new Set(e).size===e.length,Lo=R.string().regex(/^[a-zA-Z0-9_.:|-]{1,256}$/),Bf=R.string().max(512).regex(/^[\w.-]+(?:\/[\w.-]+){1,5}$/).refine(e=>!e.split("/").some(t=>t==="."||t==="..")),er=R.string().min(1).max(200).regex(/^[a-zA-Z0-9_./-]+$/).refine(e=>!e.includes("..")&&!e.endsWith(".")&&!e.split("/").some(t=>!t||t.startsWith(".")||t.endsWith(".lock"))),qf=R.string().min(1).max(512).refine(e=>!/[\\\u0000-\u001f\u007f]/.test(e)&&!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t==="..")),xp=R.string().min(1).max(256).regex(/^[a-zA-Z0-9_./*?-]+$/).refine(e=>!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t===".."));var Sp=R.strictObject({id:R.uuid(),repo:Bf,platform:R.enum(["github","gitlab","bitbucket"]),branches:R.array(er).min(1).max(4).refine(Yn),workflow:R.string().regex(/^\.github\/workflows\/[a-zA-Z0-9_-]+\.ya?ml$/),keyIds:R.array(R.uuid()).min(1).max(4).refine(Yn),include:R.array(xp).min(1).max(16),exclude:R.array(xp).max(16),methods:R.array(R.string().regex(/^[a-zA-Z_$][\w$]{0,63}$/)).min(1).max(32).refine(Yn),maxAgeHours:R.number().int().min(1).max(720)}),vp=Sp.extend({revision:R.number().int().positive()}),i0=R.strictObject({repository:Sp,expectedRevision:R.number().int().min(0)}).refine(({repository:e})=>e.platform==="gitlab"||e.repo.split("/").length===2,{path:["repository","repo"]}),Ip=R.strictObject({repositoryId:R.uuid(),branch:er}),Ff=R.array(Lo).max(dt.keys).refine(Yn),Op=R.strictObject({repository:vp.omit({keyIds:!0}),branch:er,keys:Ff,keySetHash:R.string().regex(/^[a-f0-9]{64}$/)}),Nf=R.strictObject({filePath:qf,startingLineNumber:R.number().int().min(1).max(1e7)}),Zo=R.strictObject({protocol:R.literal(1),repositoryId:R.uuid(),branch:er,workflow:R.string().max(200),configurationRevision:R.number().int().positive(),keySetHash:R.string().regex(/^[a-f0-9]{64}$/),commit:R.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),scanId:R.uuid(),runNumber:R.number().int().min(1).max(Number.MAX_SAFE_INTEGER),runAttempt:R.number().int().min(1).max(1e4),scannerVersion:R.literal("1"),scannedAt:R.iso.datetime({offset:!0}),coverage:R.strictObject({complete:R.literal(!0),files:R.number().int().min(0).max(dt.files),sourceBytes:R.number().int().min(0).max(dt.sourceBytes),unresolvedCalls:R.number().int().min(0).max(1e6),unsupportedFiles:R.number().int().min(0).max(dt.files)}),features:R.array(R.strictObject({key:Lo,refs:R.array(Nf).max(dt.referencesPerKey)})).max(dt.keys)}).superRefine((e,t)=>{Yn(e.features.map(n=>n.key))||t.addIssue({code:"custom",path:["features"],message:"Duplicate feature"}),e.features.reduce((n,r)=>n+r.refs.length,0)>dt.references&&t.addIssue({code:"custom",path:["features"],message:"Reference budget exceeded"})}),Ho=R.strictObject({scanId:R.uuid(),commit:R.string(),receivedAt:R.string(),references:R.number().int().nonnegative(),removedReferences:R.number().int().nonnegative()}),Vf=Ho.extend({repositoryId:R.uuid(),branch:er,workflow:R.string(),digest:R.string(),configurationRevision:R.number().int().positive(),runNumber:R.number().int().positive(),runAttempt:R.number().int().positive(),scannedAt:R.string(),keySetHash:R.string(),coverage:Zo.shape.coverage}),Uf=R.strictObject({repositories:R.array(vp).max(dt.repositories),scans:R.array(Vf).max(dt.repositories*dt.branches)}),$f=R.strictObject({key:Lo,references:R.number().int().nonnegative(),coveredTargets:R.number().int().nonnegative(),expiredTargets:R.number().int().nonnegative(),uncertainTargets:R.number().int().nonnegative()}),o0=R.strictObject({available:R.boolean().default(!0),settings:Uf,expectedTargets:R.number().int().min(0).max(80),features:R.array($f).max(2001),truncated:R.boolean()});import{z as Pe}from"zod";var Gf=Pe.enum(["checkout.session.completed","checkout.session.expired","checkout.session.async_payment_succeeded","checkout.session.async_payment_failed","customer.subscription.created","customer.subscription.updated","customer.subscription.deleted","customer.subscription.paused","customer.subscription.resumed","invoice.created","invoice.paid","customer.discount.created","customer.discount.updated","refund.created","refund.updated","refund.failed","charge.refunded"]),Kf=Pe.strictObject({provider:Pe.literal("stripe"),accountId:Pe.string().regex(/^acct_[A-Za-z0-9]+$/),eventId:Pe.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),type:Gf,occurredAt:Pe.number().int().positive().max(Number.MAX_SAFE_INTEGER),data:Pe.record(Pe.string(),Pe.unknown()).and(Pe.object({id:Pe.string().min(1).max(255),object:Pe.enum(["checkout.session","subscription","invoice","discount","refund","charge"]),livemode:Pe.boolean()}))}),jp=Pe.union([Kf,Va]),Ap=Pe.strictObject({id:Pe.uuid(),eventId:Pe.string().min(1).max(200),source:Pe.literal("merchant"),providerVerified:Pe.literal(!1),outcome:Pe.string().min(1).max(100)});import{z as Ue}from"zod";var _p={customerId:Ue.uuid(),eventId:Ue.string().trim().min(1).max(200),grantId:Ue.uuid(),occurredAt:Ue.iso.datetime({offset:!0})},Pp=Ue.strictObject({..._p,productVersionId:Ue.uuid(),subscriptionId:Ue.string().trim().min(1).max(255)}),Cp=Ue.strictObject({..._p,merchandiseId:Ue.uuid()}),kp=Ue.union([Pp,Cp]),wp={id:Ue.uuid(),couponId:Ue.uuid(),status:Ue.literal("redeemed"),source:Ue.literal("merchant"),recordedAt:Ue.iso.datetime({offset:!0})},Rp=Ue.union([Pp.extend(wp),Cp.extend(wp)]);import{z}from"zod";var Ep=gc,Lf=Ep.extend({invoice_id:Ep.shape.invoice_id.meta({description:"The Indiana invoice ID to void and replace.",example:"9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"})}),Jo=z.strictObject({name:z.string().trim().min(1).max(255),memo:z.string().max(1e4).nullable().optional(),footer:z.string().max(1e4).nullable().optional(),net_terms_days:z.number().int().positive().nullable().optional()}),Zf=Jo.extend({id:z.string().min(1).max(255),created_at:z.number().nullable()}),Mp=z.strictObject({items:z.array(Zf).max(50),nextCursor:z.uuid().nullable()}),f0=z.discriminatedUnion("action",[z.strictObject({action:z.literal("create"),requestId:z.uuid(),values:Jo}),z.strictObject({action:z.literal("update"),id:z.string().min(1).max(255),values:Jo}),z.strictObject({action:z.literal("delete"),id:z.string().min(1).max(255)})]),Tp=z.discriminatedUnion("action",[z.strictObject({action:z.literal("create"),requestId:z.uuid(),params:ln}),z.strictObject({action:z.enum(["finalize","send","pay","void"]),requestId:z.uuid(),invoiceId:z.uuid()}),z.strictObject({action:z.literal("reissue"),requestId:z.uuid(),invoiceId:z.uuid(),params:Lf})]),Wo=z.strictObject({id:z.uuid(),customerId:z.uuid(),providerInvoiceId:z.string().nullable(),status:z.enum(["draft","open","paid","void","uncollectible"]),currency:z.string(),totalMinor:z.string().regex(/^-?\d+$/),paidMinor:z.string().regex(/^\d+$/),refundedMinor:z.string().regex(/^\d+$/),hostedInvoiceUrl:z.url().nullable(),createdAt:z.number(),collectionMethod:z.enum(["send_invoice","charge_automatically"]).nullable()}),Dp=Wo.extend({lines:z.array(z.strictObject({id:z.uuid(),description:z.string(),amountMinor:z.string().regex(/^-?\d+$/),netAmountMinor:z.string().regex(/^-?\d+$/),quantity:z.number().nullable(),periodStart:z.number().nullable(),periodEnd:z.number().nullable()})).max(1e3)}),In=z.strictObject({taskId:z.uuid(),status:z.enum(["ready","running","done","dead"]),invoice:Wo.nullable(),errorCode:z.string().nullable()}),zp=z.strictObject({items:z.array(Wo).max(50),nextCursor:z.uuid().nullable(),operations:z.array(In).max(50),operationsLimited:z.boolean()});var Hf=c.enum(["customers:read","customers:write","entitlements:read","content:read","sessions:create","funnels:run","offers:resolve","offers:grant","billing:read","billing:write","credits:read","credits:consume","credits:manage","features:read","events:write","messaging:write","code-references:read","code-references:write","app-manifests:write"]),Bp={scope:le,permissions:c.array(Hf),expiresAt:c.iso.datetime().nullable()},aO=c.discriminatedUnion("kind",[c.object({...Bp,kind:c.literal("server"),keyId:c.string().min(1)}),c.object({...Bp,kind:c.literal("customer"),customerId:c.string().min(1),identityKind:c.enum(["identified","guest"]),expiresAt:c.iso.datetime()})]),O=c.object({requestId:c.uuid(),scope:le}).strict(),Jf=Au.safeExtend({fingerprint:Yr.optional()}).strict(),Wf=O.extend({customer:xn,created:c.boolean()});function qp(){return O.extend({offer:Dn.nullable(),reason:Ss.nullable()})}var I={sendMessage:{method:"POST",path:"messaging/send",permission:"messaging:write",audience:"server",request:nc,response:O.extend({message:c.object({messageId:c.uuid(),channel:Vn,acceptedAt:c.iso.datetime({offset:!0}),status:c.enum(["accepted","sending","completed","canceled"]),replayed:c.boolean()})})},readMessage:{method:"POST",path:"messaging/read",permission:"messaging:write",audience:"server",request:c.strictObject({messageId:c.uuid()}),response:O.extend({message:c.object({id:c.uuid(),channel:Vn,status:c.enum(["accepted","sending","completed","canceled"]),deliveries:c.array(c.object({id:c.uuid(),status:ic,attempts:c.number().int().nonnegative(),receipts:c.array(c.object({kind:oc,occurredAt:c.iso.datetime({offset:!0}).nullable()}))}))})})},bindPushInstallation:{method:"POST",path:"push/installations/bind",permission:"messaging:write",audience:"customer",request:ss,response:O.extend({installation:jr})},readPushInstallation:{method:"POST",path:"push/installations/read",permission:"messaging:write",audience:"customer",request:cs,response:O.extend({installation:jr})},updatePushAddress:{method:"POST",path:"push/installations/address",permission:"messaging:write",audience:"customer",request:Or,response:O.extend({installation:jr})},readMessagingPreference:{method:"POST",path:"messaging/preferences/read",permission:"messaging:write",audience:"customer",request:c.strictObject({channel:Vn}),response:O.extend({preference:Mi})},setMessagingPreference:{method:"POST",path:"messaging/preferences/set",permission:"messaging:write",audience:"customer",request:rc,response:O.extend({preference:Mi})},listInvoiceTemplates:{method:"POST",path:"invoices/templates",permission:"billing:read",audience:"server",request:c.strictObject({cursor:c.uuid().optional()}),response:O.extend({templates:Mp})},previewInvoice:{method:"POST",path:"invoices/preview",permission:"billing:write",audience:"server",request:c.strictObject({customerId:c.uuid(),params:ln}),response:O.extend({preview:Hi})},createInvoice:{method:"POST",path:"invoices/create",permission:"billing:write",audience:"server",request:c.strictObject({customerId:c.uuid(),requestId:c.uuid(),params:ln}).refine(e=>e.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:O.extend({operation:In})},manageInvoice:{method:"POST",path:"invoices/manage",permission:"billing:write",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Tp}).refine(e=>e.command.action!=="create"||e.command.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:O.extend({operation:In})},readInvoiceOperation:{method:"POST",path:"invoices/operations/read",permission:"billing:read",audience:"server",request:c.strictObject({customerId:c.uuid(),taskId:c.uuid()}),response:O.extend({operation:In})},listInvoices:{method:"POST",path:"invoices/list",permission:"billing:read",audience:"server",request:c.strictObject({customerId:c.uuid(),cursor:c.uuid().optional()}),response:O.extend({invoices:zp})},getInvoice:{method:"POST",path:"invoices/read",permission:"billing:read",audience:"server",request:c.strictObject({customerId:c.uuid(),invoiceId:c.uuid()}),response:O.extend({invoice:Dp})},getCodeReferenceConfig:{method:"POST",path:"code-references/config",permission:"code-references:read",audience:"server",request:Ip,response:O.extend({config:Op})},submitCodeReferences:{method:"POST",path:"code-references",permission:"code-references:write",audience:"server",request:Zo,response:O.extend({receipt:Ho})},getFeatures:{method:"GET",path:"features",permission:"features:read",audience:"mixed",request:c.strictObject({}),response:O.extend({payload:co})},evaluateFeatures:{method:"POST",path:"features/evaluate",permission:"features:read",audience:"mixed",request:iu,response:O.merge(ou)},trackEvents:{method:"POST",path:"events",permission:"events:write",audience:"mixed",request:au,response:O.merge(su)},readBalanceSource:{method:"POST",path:"balances/source/read",permission:"credits:read",audience:"server",request:c.strictObject({customerId:c.uuid(),sourceId:c.uuid()}),response:O.extend({balance:Zu})},adjustBalance:{method:"POST",path:"balances/source/adjust",permission:"credits:manage",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Lu}),response:O.extend({balance:Vo})},readAiPricing:{method:"POST",path:"ai/pricing/read",permission:"credits:read",audience:"server",request:c.strictObject({internal_feature_id:c.uuid(),customerId:c.uuid().optional(),entityId:c.uuid().optional()}).refine(e=>!e.entityId||!!e.customerId,"Entity pricing requires a customer"),response:O.extend({internal_feature_id:c.uuid(),config:zi,model_markups:Pr})},readUsage:{method:"POST",path:"usage/read",permission:"credits:read",audience:"server",request:c.strictObject({customerId:c.uuid(),query:Sa}),response:O.extend({usage:di})},setUsage:{method:"POST",path:"usage/set",permission:"credits:manage",audience:"server",request:c.strictObject({customerId:c.uuid(),command:va}),response:O.extend({usage:di})},manageBalanceGrant:{method:"POST",path:"balances/grants/manage",permission:"credits:manage",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Ls}),response:O.extend({grant:Ui})},listBalanceGrants:{method:"POST",path:"balances/grants/list",permission:"credits:read",audience:"server",request:Zs,response:O.extend({grants:Hs})},restoreNativePurchase:{method:"POST",path:"subscriptions/native/restore",permission:"billing:write",audience:"mixed",request:c.union(Hc.options.map(e=>e.extend({customerId:c.uuid().optional(),customerToken:c.string().regex(pt).optional()}))),response:O.extend({operation:Jc})},setupPayment:{method:"POST",path:"billing/setup-payment",permission:"billing:write",audience:"mixed",request:Bc.extend({customerId:c.uuid().optional()}),response:O.extend({setup:Yi})},readPaymentSetup:{method:"POST",path:"billing/payment-setup",permission:"billing:read",audience:"mixed",request:qc.extend({customerId:c.uuid().optional()}),response:O.extend({setup:Yi})},previewSubscriptionBatch:{method:"POST",path:"subscriptions/batches/preview",permission:"billing:write",audience:"server",request:Tc.safeExtend({customerId:c.uuid()}),response:O.extend({batch:$n})},confirmSubscriptionBatch:{method:"POST",path:"subscriptions/batches/confirm",permission:"billing:write",audience:"server",request:qr.extend({customerId:c.uuid()}),response:O.extend({batch:$n})},readSubscriptionBatch:{method:"POST",path:"subscriptions/batches/read",permission:"billing:read",audience:"server",request:qr.extend({customerId:c.uuid()}),response:O.extend({batch:$n})},abandonSubscriptionBatch:{method:"POST",path:"subscriptions/batches/abandon",permission:"billing:write",audience:"server",request:qr.extend({customerId:c.uuid()}),response:O.extend({batch:$n})},manageSubscriptionTrial:{method:"POST",path:"subscriptions/trials/manage",permission:"billing:write",audience:"server",request:c.discriminatedUnion("action",[Fr.options[0].extend({customerId:c.uuid()}),Fr.options[1].extend({customerId:c.uuid()}),Fr.options[2].extend({customerId:c.uuid()})]),response:O.extend({trial:Xi})},readSubscriptionTrial:{method:"POST",path:"subscriptions/trials/read",permission:"billing:read",audience:"server",request:Dc.extend({customerId:c.uuid()}),response:O.extend({trial:Xi})},listSubscriptions:{method:"POST",path:"subscriptions/list",permission:"billing:read",audience:"server",request:Ur,response:O.extend({subscriptions:Kc})},listPurchases:{method:"POST",path:"purchases/list",permission:"billing:read",audience:"server",request:Ur,response:O.extend({purchases:Lc})},listSubscriptionConflicts:{method:"POST",path:"subscriptions/conflicts/list",permission:"billing:read",audience:"server",request:Uc,response:O.extend({conflicts:Zc})},retrySubscriptionConflict:{method:"POST",path:"subscriptions/conflicts/retry",permission:"billing:write",audience:"server",request:$c,response:O.extend({resolution:Gc})},verifySubscriptions:{method:"POST",path:"subscriptions/verify",permission:"billing:read",audience:"server",request:Nc,response:O.extend({verification:Vc})},previewAttach:{method:"POST",path:"subscriptions/preview-attach",permission:"billing:read",audience:"mixed",request:wc.safeExtend({...un,customerId:c.uuid().optional()}),response:O.extend({quote:mn})},recordBillingEvent:{method:"POST",path:"billing/events/record",permission:"billing:write",audience:"server",request:jp,response:O.extend({record:Ap})},attach:{method:"POST",path:"subscriptions/attach",permission:"billing:write",audience:"mixed",request:Nt.extend({customerId:c.uuid().optional(),intent:c.enum(["confirm","cancel"]).optional()}),response:O.extend({operation:dn})},readSubscriptionOperation:{method:"POST",path:"subscriptions/operations/read",permission:"billing:read",audience:"mixed",request:Nt.extend({customerId:c.uuid().optional()}),response:O.extend({operation:dn})},previewUpdate:{method:"POST",path:"subscriptions/preview-update",permission:"billing:read",audience:"mixed",request:Cc.safeExtend({customerId:c.uuid().optional()}),response:O.extend({quote:Rc})},update:{method:"POST",path:"subscriptions/update",permission:"billing:write",audience:"mixed",request:Nt.extend({customerId:c.uuid().optional(),intent:c.enum(["confirm","cancel"]).optional()}),response:O.extend({operation:Ji})},readSubscriptionUpdate:{method:"POST",path:"subscriptions/updates/read",permission:"billing:read",audience:"mixed",request:Nt.extend({customerId:c.uuid().optional()}),response:O.extend({operation:Ji})},previewRefund:{method:"POST",path:"subscriptions/refunds/preview",permission:"billing:read",audience:"server",request:Ec.safeExtend({customerId:c.uuid()}),response:O.extend({quote:Wi})},refund:{method:"POST",path:"subscriptions/refunds/confirm",permission:"billing:write",audience:"server",request:Nt.extend({customerId:c.uuid()}),response:O.extend({operation:Br})},readRefund:{method:"POST",path:"subscriptions/refunds/read",permission:"billing:read",audience:"server",request:Nt.extend({customerId:c.uuid()}),response:O.extend({operation:Br})},readBillingControls:{method:"POST",path:"billing/controls/read",permission:"billing:read",audience:"customer",request:Ts,response:O.extend({controls:Vi})},prepareBillingAuthorization:{method:"POST",path:"billing/authorizations/prepare",permission:"billing:write",audience:"customer",request:_s,response:O.extend({prepared:Cs})},confirmBillingAuthorization:{method:"POST",path:"billing/authorizations/confirm",permission:"billing:write",audience:"customer",request:ks,response:O.extend({authorization:kr})},setBillingCoupons:{method:"POST",path:"billing/coupons",permission:"billing:write",audience:"customer",request:Fs,response:O.extend({coupons:Ns})},revokeBillingAuthorization:{method:"POST",path:"billing/authorizations/revoke",permission:"billing:write",audience:"customer",request:Rs,response:O.extend({authorization:kr})},listBillingInvoices:{method:"POST",path:"billing/invoices/read",permission:"billing:read",audience:"customer",request:Bs,response:O.extend({invoices:qs})},prepareBillingAdjustment:{method:"POST",path:"billing/invoices/prepare-adjustment",permission:"billing:write",audience:"server",request:zs.extend({customerId:c.uuid()}),response:O.extend({operation:In})},confirmBillingAdjustment:{method:"POST",path:"billing/invoices/confirm-adjustment",permission:"billing:write",audience:"customer",request:Ds,response:O.extend({invoice:qn})},manageBillingLimits:{method:"POST",path:"billing/controls/manage",permission:"billing:write",audience:"server",request:c.object({customerId:c.uuid(),command:Ms}).strict(),response:O.extend({controls:Vi})},manageUsageEntity:{method:"POST",path:"usage/entities",permission:"credits:manage",audience:"server",request:c.object({customerId:c.uuid(),command:Hu}).strict(),response:O.extend({entity:Ju})},readUsageAnalytics:{method:"POST",path:"usage/analytics",permission:"credits:read",audience:"server",request:c.strictObject({customerId:c.uuid().nullable(),query:tp}),response:O.extend({analytics:np})},readCreditAnalytics:{method:"POST",path:"credits/analytics",permission:"credits:read",audience:"server",request:c.object({customerId:c.uuid().nullable(),query:Ht}).strict(),response:O.extend({analytics:Yu})},submitUsageBatch:{method:"POST",path:"usage/batch",permission:"credits:consume",audience:"server",request:rp,response:O.extend({batchId:c.uuid()})},readUsageBatch:{method:"POST",path:"usage/batch/read",permission:"credits:read",audience:"server",request:ip,response:O.extend({batch:op})},checkEntitlement:{method:"POST",path:"entitlements/check",permission:"entitlements:read",audience:"mixed",request:_a.extend({customerId:c.string().min(1).optional()}),response:O.extend({check:Cn})},resolveContent:{method:"POST",path:"content/resolve",permission:"content:read",audience:"mixed",request:c.strictObject({kind:Ot,selector:c.discriminatedUnion("type",[c.strictObject({type:c.literal("resource"),id:c.uuid()}),c.strictObject({type:c.literal("version"),id:c.uuid()})]),customerId:c.string().min(1).optional()}),response:O.extend({content:ki})},resolvePaywall:{method:"POST",path:"paywalls/resolve",permission:"entitlements:read",audience:"mixed",request:Gu,response:O.extend({paywall:Xn})},resolveOffering:{method:"POST",path:"offerings/resolve",permission:"entitlements:read",audience:"mixed",request:c.strictObject({processContext:Mr.optional(),...un,selector:Yc,customerId:c.string().min(1).optional(),commerce:ur,requirement:Qt.optional()}),response:O.extend({offering:eu,candidates:c.array(Pa).max(20),availability:c.array(c.strictObject({productVersionId:c.uuid(),available:c.boolean(),reason:c.enum(["platform_binding_missing","commercial_runtime_pending","commerce_not_configured","currency_mismatch","product_unavailable","already_attached","attach_in_progress","already_scheduled","subscription_change_required","purchase_conflict"]).nullable()})).max(20),check:Cn.nullable()})},readHoldings:{method:"POST",path:"customer-holdings",permission:"entitlements:read",audience:"mixed",request:c.object({customerId:c.uuid().optional(),entityId:c.uuid().optional()}).strict(),response:O.extend({holdings:Ia})},readLedger:{method:"POST",path:"customer-ledger",permission:"credits:read",audience:"mixed",request:c.object({customerId:c.uuid().optional(),query:Oa}).strict(),response:O.extend({ledger:ja})},readBillingInvoice:{method:"POST",path:"billing/invoices/detail",permission:"billing:read",audience:"mixed",request:Js.extend({customerId:c.uuid().optional()}),response:O.extend({detail:Ws})},readCreditStatement:{method:"POST",path:"credit-statements/read",permission:"credits:read",audience:"mixed",request:$i.safeExtend({customerId:c.uuid().optional()}),response:O.extend({statement:Qs})},quoteBalance:{method:"POST",path:"balances/quote",permission:"credits:read",audience:"mixed",request:c.object({customerId:c.uuid().optional(),command:_n.options[0]}).strict(),response:O.extend({quote:xa})},trackUsage:{method:"POST",path:"usage/track",permission:"credits:consume",audience:"server",request:c.strictObject({customerId:c.uuid(),command:c.union([c.strictObject({eventName:c.string().min(1),quantity:be.optional(),properties:ft.optional(),entityId:c.uuid().optional(),idempotencyKey:c.string().min(1).max(120)}),c.strictObject({internal_feature_id:c.uuid(),quantity:be.optional(),properties:ft.optional(),entityId:c.uuid().optional(),idempotencyKey:c.string().min(1).max(120)})])}),response:O.extend({receipts:c.array(Pn).min(1)})},mutateBalance:{method:"POST",path:"balances/execute",permission:"credits:consume",audience:"server",request:c.object({customerId:c.uuid(),command:_n.refine(e=>e.operation!=="quote","Use the quote endpoint for a read")}).strict(),response:O.extend({receipt:Pn})},redeemReward:{method:"POST",path:"rewards/redeem",permission:"offers:resolve",audience:"customer",request:fp,response:O.extend({redemption:dp})},createReferralCode:{method:"POST",path:"rewards/referral-code",permission:"offers:resolve",audience:"customer",request:bp,response:O.extend({referralCode:yp})},claimRewardProduct:{method:"POST",path:"rewards/product/claim",permission:"offers:resolve",audience:"customer",request:gp,response:O.extend({checkout:hp})},readSeats:{method:"POST",path:"seats/list",permission:"customers:read",audience:"server",request:Ys,response:O.extend({seats:Li})},manageSeat:{method:"POST",path:"seats/manage",permission:"billing:write",audience:"server",request:ec,response:O.extend({seats:Li})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:Jf,response:Wf},getCustomer:{method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:Ao,response:O.extend({customer:xn})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:Pu,response:O.extend(Cu.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:_u,response:O.extend(wu.shape)},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:c.object({customerId:c.uuid()}).strict(),response:O.extend(tn.shape)},refreshSession:{method:"POST",path:"customer-sessions/refresh",permission:"sessions:create",audience:"refresh",request:c.strictObject({}),response:O.extend(tn.shape)},revokeSessions:{method:"POST",path:"customer-sessions/revoke",permission:"sessions:create",audience:"server",request:c.strictObject({customerId:c.uuid(),sessionId:c.uuid().optional()}),response:O.extend({revoked:c.number().int().nonnegative()})},createGuestCustomer:{method:"POST",path:"customers/guests",permission:"sessions:create",audience:"server",request:c.strictObject({guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),fingerprint:Yr.optional()}),response:O.extend({customerId:c.uuid(),guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),guestExpiresAt:c.iso.datetime()})},resumeGuestSession:{method:"POST",path:"customers/guests/session",permission:"sessions:create",audience:"server",request:c.strictObject({guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/)}),response:O.extend(tn.shape)},claimGuestCustomer:{method:"POST",path:"customers/guests/claim",permission:"customers:write",audience:"server",request:c.strictObject({guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),externalUserId:c.string().trim().min(1).max(255).refine(e=>!e.startsWith("gg_guest_")),requestId:c.uuid()}),response:O.extend({customer:xn,switched:c.boolean(),replayed:c.boolean()})},redeemCoupon:{method:"POST",path:"offers/redeem",permission:"offers:resolve",audience:"customer",request:c.strictObject({code:c.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),requestId:c.uuid()}),response:qp()},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:c.object({}).strict(),response:O.extend({offers:c.array(Dn)})},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"mixed",customerPermission:"offers:resolve",request:c.object({customerId:c.string().min(1).max(255).optional(),couponId:c.uuid(),...un,requestId:c.uuid(),couponContentDigest:c.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),response:qp()},recordCouponRedemption:{method:"POST",path:"offers/redemptions",permission:"billing:write",audience:"server",request:kp,response:O.extend({receipt:Rp})}},sO={recordBillingEvent:I.recordBillingEvent,sendMessage:I.sendMessage,readMessage:I.readMessage,bindPushInstallation:I.bindPushInstallation,readPushInstallation:I.readPushInstallation,updatePushAddress:I.updatePushAddress,readMessagingPreference:I.readMessagingPreference,setMessagingPreference:I.setMessagingPreference,listInvoiceTemplates:I.listInvoiceTemplates,previewInvoice:I.previewInvoice,createInvoice:I.createInvoice,manageInvoice:I.manageInvoice,readInvoiceOperation:I.readInvoiceOperation,listInvoices:I.listInvoices,getInvoice:I.getInvoice,getCodeReferenceConfig:I.getCodeReferenceConfig,submitCodeReferences:I.submitCodeReferences,getFeatures:I.getFeatures,evaluateFeatures:I.evaluateFeatures,trackEvents:I.trackEvents,setupPayment:I.setupPayment,readPaymentSetup:I.readPaymentSetup,previewSubscriptionBatch:I.previewSubscriptionBatch,confirmSubscriptionBatch:I.confirmSubscriptionBatch,readSubscriptionBatch:I.readSubscriptionBatch,abandonSubscriptionBatch:I.abandonSubscriptionBatch,manageSubscriptionTrial:I.manageSubscriptionTrial,readSubscriptionTrial:I.readSubscriptionTrial,listSubscriptions:I.listSubscriptions,listPurchases:I.listPurchases,listSubscriptionConflicts:I.listSubscriptionConflicts,retrySubscriptionConflict:I.retrySubscriptionConflict,readAiPricing:I.readAiPricing,readUsage:I.readUsage,setUsage:I.setUsage,previewRefund:I.previewRefund,refund:I.refund,readRefund:I.readRefund,previewUpdate:I.previewUpdate,update:I.update,readSubscriptionUpdate:I.readSubscriptionUpdate,restoreNativePurchase:I.restoreNativePurchase,verifySubscriptions:I.verifySubscriptions,previewAttach:I.previewAttach,attach:I.attach,readSubscriptionOperation:I.readSubscriptionOperation,manageBalanceGrant:I.manageBalanceGrant,readBalanceSource:I.readBalanceSource,adjustBalance:I.adjustBalance,listBalanceGrants:I.listBalanceGrants,readBillingControls:I.readBillingControls,prepareBillingAuthorization:I.prepareBillingAuthorization,confirmBillingAuthorization:I.confirmBillingAuthorization,setBillingCoupons:I.setBillingCoupons,revokeBillingAuthorization:I.revokeBillingAuthorization,listBillingInvoices:I.listBillingInvoices,confirmBillingAdjustment:I.confirmBillingAdjustment,prepareBillingAdjustment:I.prepareBillingAdjustment,manageBillingLimits:I.manageBillingLimits,createCustomer:I.createCustomer,getCustomer:I.getCustomer,listCustomers:I.listCustomers,updateCustomer:I.updateCustomer,createSession:I.createSession,refreshSession:I.refreshSession,revokeSessions:I.revokeSessions,createGuestCustomer:I.createGuestCustomer,resumeGuestSession:I.resumeGuestSession,claimGuestCustomer:I.claimGuestCustomer,checkEntitlement:I.checkEntitlement,resolveOffering:I.resolveOffering,resolveContent:I.resolveContent,resolvePaywall:I.resolvePaywall,readHoldings:I.readHoldings,readLedger:I.readLedger,readBillingInvoice:I.readBillingInvoice,readCreditStatement:I.readCreditStatement,quoteBalance:I.quoteBalance,trackUsage:I.trackUsage,mutateBalance:I.mutateBalance,manageUsageEntity:I.manageUsageEntity,readUsageAnalytics:I.readUsageAnalytics,readCreditAnalytics:I.readCreditAnalytics,submitUsageBatch:I.submitUsageBatch,readUsageBatch:I.readUsageBatch,listOffers:I.listOffers,grantOffer:I.grantOffer,recordCouponRedemption:I.recordCouponRedemption,redeemCoupon:I.redeemCoupon,redeemReward:I.redeemReward,createReferralCode:I.createReferralCode,claimRewardProduct:I.claimRewardProduct,readSeats:I.readSeats,manageSeat:I.manageSeat};import{z as Qo}from"zod";var tr=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function Xo(e,t,n){let r={},o,a,l,p="next",d;switch(e.type){case"entry":d=e.next;break;case"condition":{let v=e.cases.findIndex(h=>mi(t.attributes??{},h.condition,t.savedGroups??{}));p=v<0?"default":`case:${v}`,d=v<0?e.default:e.cases[v].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new tr("Required GB Feature is unavailable");o=wn(e.featureKey,t),l=o.value,Object.assign(r,Dt(e,{value:l})),d=e.next;break;case"split":{let v=n[e.experimentId];if(!v)throw new tr("Required GB Experiment is unavailable");if(a=ga(v,t),l=a.value,p=a.inExperiment&&!a.passthrough&&typeof l=="string"?l:"notParticipating",d=p==="notParticipating"?e.notParticipating:e.routes[p],!d)throw new tr("Experiment Variation has no published route");break}case"offering":{let v=e.configuration.source==="fixed"?e.configuration.versionId:wn(e.configuration.featureKey,t).value;l={type:"offering_version",id:Qo.uuid().parse(v)},Object.assign(r,Dt(e,{value:l})),d=e.next;break}case"coupon":case"coupons":l=e.type==="coupons"?e.couponIds.map(v=>({type:"reward",id:v})):{type:"reward",id:e.couponId},Object.assign(r,Dt(e,{value:l})),d=e.next;break}return{port:p,target:d,projections:r,...l===void 0?{}:{value:l},...o?{feature:o}:{},...a?{experiment:a}:{}}}function gO(e,t,n){Qo.uuid().parse(e),Qo.number().int().nonnegative().parse(t);let r=ar(sr(new TextEncoder().encode(JSON.stringify([e,t,n])))).slice(0,32);return`${r.slice(0,8)}-${r.slice(8,12)}-5${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20)}`}import{z as _}from"zod";var Rt=_.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qf=_.enum(["running","waiting","completed","closed","ineligible","failed"]),Yo=_.discriminatedUnion("type",[Oo,_.strictObject({type:_.literal("wait"),receiptId:_.uuid(),kind:_.enum(["timer","event","operation"]),deadline:_.iso.datetime({offset:!0}).nullable(),eventName:Rt.optional()}),_.strictObject({type:_.literal("open_url"),receiptId:_.uuid(),url:_o,openIn:Po}),_.strictObject({type:_.literal("event"),receiptId:_.uuid(),event:Rt})]),Xf=_.strictObject({type:_.literal("funnel"),id:_.uuid(),versionId:_.uuid()}),Yf={id:Rt,presentation:yt,outputs:_.array(Rt).max(250),inputs:hi,values:_.record(_.string(),ee).optional(),offeringKey:Ae.optional(),capabilities:Xt,customerData:Ta,dataCursors:_.record(Rt,pr.nullable())},eg=_.strictObject({...Yf,content:_.strictObject({type:_.literal("document"),document:Le})}),nr=_.strictObject({id:_.uuid(),source:Xf,revision:_.number().int().nonnegative(),visit:_.number().int().nonnegative(),nodeId:Rt,nodeType:_.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),status:Qf,stopped:_.boolean(),canBack:_.boolean(),authenticated:_.boolean(),locale:_.string().min(1).max(35),answers:Et,parameters:ut,variables:_.record(_.string(),ee),output:ee.nullable(),screen:eg.nullable(),paywall:_.strictObject({receiptId:_.uuid(),resolution:_.union([Qn,Xn]),quote:mn.nullable(),operation:dn.nullable(),purchaseRequestId:_.uuid().nullable(),selectionGeneration:_.number().int().nonnegative().optional(),canReselect:_.boolean().optional()}).nullable(),instruction:Yo.nullable(),pendingRequest:_.strictObject({requestId:_.uuid(),authenticationRequired:_.boolean()}).nullable(),runExpiresAt:_.iso.datetime({offset:!0}),credentialExpiresAt:_.iso.datetime({offset:!0}).nullable()}),On=_.strictObject({scope:le,run:nr,settlement:_.strictObject({requestId:_.uuid(),state:_.enum(["pending","unknown","settled"]),operationId:_.uuid().nullable(),receiptId:_.uuid().nullable().optional()}).optional(),purchase:_.strictObject({receiptId:_.uuid(),quote:mn.nullable(),operation:dn.nullable(),canReselect:_.boolean().optional()}).optional(),review:_.strictObject({activeOperationId:_.uuid().nullable(),pages:_.array(_.strictObject({receiptId:_.uuid(),nodeId:Rt,visit:_.number().int().nonnegative()})).max(100),page:_.strictObject({receiptId:_.uuid(),nodeId:Rt,visit:_.number().int().nonnegative(),document:Le,answers:Et,inputs:hi,values:_.record(_.string(),ee).optional()}).nullable(),coupons:_.array(_.strictObject({grantId:_.uuid(),status:_.enum(["issued","reserved","redeemed","expired","revoked","unknown"]),expiresAt:_.string().nullable()})).max(100),purchases:_.array(_.strictObject({receiptId:_.uuid(),operationId:_.uuid(),status:_.enum(["pending","complete","cancelled","failed","unknown"])})).max(100)}).optional(),runToken:_.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/).optional(),customerId:_.uuid().optional()}),Fp=On.extend({run:nr.extend({paywall:nr.shape.paywall.unwrap().extend({resolution:Xn}).nullable()})});var RO="X-Indiana-Server-Key";import{z as q}from"zod";import{z as G}from"zod";import{z as Ce}from"zod";var tg=Ce.strictObject({selector:Ce.string().min(1).max(2048),action:Ce.enum(["set","append","remove"]),attribute:Ce.string().min(1).max(128).refine(e=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e)),value:Ce.string().max(5e4).optional(),parentSelector:Ce.string().max(2048).optional(),insertBeforeSelector:Ce.string().max(2048).optional()}),ng=Ce.strictObject({variation:Ce.string().min(1).max(128),description:Ce.string().max(2e3).default(""),css:Ce.string().max(1e5).default(""),js:Ce.string().max(1e5).default(""),domMutations:Ce.array(tg).max(200).default([]),iam:du.optional(),renderGuard:Lr.optional()}),ea=ng.omit({variation:!0,description:!0,iam:!0}),rg=bn.omit({variations:!0,active:!0}).extend({changeId:Ce.string().regex(/^[a-f0-9]{64}$/),variations:Ce.tuple([ea,ea]).rest(ea).refine(e=>e.length<=20)}),Np=Ce.strictObject({trackExposures:Ce.boolean(),environmentId:Ce.uuid(),generation:Ce.string().regex(/^[a-f0-9]{64}$/),experiments:Ce.array(rg).max(100),savedGroups:Kn});var rr=G.string().regex(/^[a-f0-9]{64}$/),$O=G.strictObject({iam:rr,executionContracts:G.union([G.tuple([G.literal("funnel-run/1")]),G.tuple([G.literal("funnel-process/1")])]).default(["funnel-run/1"])}),ig=G.strictObject({release:rr,render:Lr,button:G.strictObject({selector:G.string().min(1).max(512),elementKey:G.string().min(1).max(256),tag:G.enum(["button","a","input"])}).nullable()}),GO=G.strictObject({scope:le.extend({environmentId:G.uuid()}),release:rr,validatedAt:G.iso.datetime({offset:!0}),validUntil:G.iso.datetime({offset:!0}),entries:G.array(G.strictObject({id:G.uuid(),funnelId:G.uuid(),versionId:G.uuid(),event:G.enum(["screen_enter","button_click"]),target:ig})).max(4e3)}),Vp=G.strictObject({operation:G.literal("entry_start"),funnelId:G.uuid(),versionId:G.uuid(),entryId:G.uuid(),release:rr,requestId:G.uuid(),locale:G.string().min(1).max(35).default("en")}),Up=G.strictObject({scope:le,suppressed:G.literal(!0),reason:G.enum(["frequency","in_progress"]),retryAt:G.iso.datetime({offset:!0}).nullable()}),KO=G.strictObject({experimentId:G.uuid(),splitNodeId:G.string().min(1).max(128)}),og=G.strictObject({experimentId:G.uuid(),experimentKey:G.string().min(1).max(128),variationKey:G.string().min(1).max(128),inExperiment:G.boolean(),generation:G.string().min(1).max(256)}),$p=G.strictObject({operation:G.literal("page_experiments"),release:rr,usedReceiptIds:G.array(G.uuid()).max(20).default([]),customerToken:G.string().regex(pt).optional()}),LO=G.strictObject({scope:le,runId:G.uuid(),assignments:G.array(og.extend({receiptId:G.uuid()})).max(100),payload:Np});var ct=q.literal(po),ag=q.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),ta=q.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),Gp=q.discriminatedUnion("type",[q.strictObject({type:q.literal("guest"),guestToken:ta}),q.strictObject({type:q.literal("customer"),customer:xt,customerData:Pt.optional()})]),na=q.strictObject({id:q.uuid(),runId:q.uuid(),customerId:q.uuid(),requestId:q.uuid(),acceptedAt:q.iso.datetime({offset:!0})}),sg=q.strictObject({participantId:q.uuid(),startedAs:q.enum(["guest","identified"]),binding:na.omit({runId:!0,requestId:!0}).nullable()}),cg=q.union([Yo,q.strictObject({type:q.literal("authentication_required"),reason:q.enum(["customer_required","customer_experiment_required"]),nodeId:q.string().min(1).max(64),visit:q.number().int().nonnegative()})]),ug=nr.omit({authenticated:!0}).extend({identity:sg,instruction:cg.nullable()}),pg=q.discriminatedUnion("operation",[tt.options[2].omit({customerToken:!0}),tt.options[3].omit({customerToken:!0}),tt.options[4].omit({customerToken:!0}),tt.options[5].omit({customerToken:!0}),tt.options[6].omit({customerToken:!0}),tt.options[7].omit({customerToken:!0})]),ai={contract:ct,customerToken:q.string().regex(pt)},Kp={contract:ct,requestId:q.uuid(),runToken:ag,externalUserId:xt.options[1].shape.value},Lp=q.discriminatedUnion("operation",[q.strictObject({contract:ct,operation:q.literal("describe")}),q.strictObject({contract:ct,operation:q.literal("start"),source:Gp,funnelId:tt.options[0].shape.funnelId,requestId:q.uuid(),locale:tt.options[0].shape.locale,parameters:tt.options[0].shape.parameters}),Vp.omit({operation:!0}).extend({contract:ct,operation:q.literal("entry_start"),source:Gp}),q.strictObject({...Kp,operation:q.literal("bind_customer"),guestToken:ta,claimRequestId:q.uuid(),expectedBindingId:q.null()}),q.strictObject({...Kp,operation:q.literal("binding_status"),guestToken:ta.optional()}),tt.options[1].omit({operation:!0,customerToken:!0}).extend({...ai,operation:q.literal("get"),settlementBindingId:q.uuid().nullable().optional()}),tt.options[8].omit({operation:!0,customerToken:!0}).extend({...ai,operation:q.literal("review")}),$p.omit({customerToken:!0}).extend(ai),q.strictObject({...ai,operation:q.literal("command"),identity:q.strictObject({bindingId:q.uuid().nullable()}),command:pg})]),lg=On.omit({run:!0}).extend({contract:ct,run:ug,settlement:On.shape.settlement.unwrap().extend({accepted:q.boolean().nullable().optional()}).optional()}),nj=Up.extend({contract:ct}),rj=q.discriminatedUnion("operation",[Lp.options[1].omit({contract:!0,source:!0,requestId:!0}),Lp.options[2].omit({contract:!0,source:!0,requestId:!0})]),ij=lg.extend({binding:na,outcome:q.enum(["bound","already_bound"]),replayed:q.boolean()}),oj=q.discriminatedUnion("state",[q.strictObject({contract:ct,scope:le,state:q.literal("not_accepted")}),q.strictObject({contract:ct,scope:le,state:q.literal("conflict")}),q.strictObject({contract:ct,scope:le,state:q.literal("bound"),binding:na})]),aj=q.strictObject({contract:ct,scope:le,keyId:q.uuid(),operations:q.array(q.string()).max(20)});import{z as Ge}from"zod";import{z as si}from"zod";var lj=si.strictObject({operation:si.literal("renew_run"),runId:si.uuid(),customerId:si.uuid()}),Zp=On.refine(e=>!!e.runToken,"Renewal returns a credential"),Hp=Fp.refine(e=>!!e.runToken,"Renewal returns a credential");var xj=Ge.discriminatedUnion("operation",[Ge.strictObject({operation:Ge.literal("campaign_decide"),...wo}).refine(Ut,$t),Ge.strictObject({operation:Ge.literal("campaign_start"),funnelId:Ge.uuid(),requestId:Ge.uuid(),customer:xt,customerData:Pt.optional(),locale:Ge.string().min(1).max(35),parameters:ut,cooldownSeconds:Ge.number().int().min(1).max(2592e3)}).refine(Ut,$t)]),mg=Ge.union([Ge.strictObject({scope:le,suppressed:Ge.literal(!0),reason:Ge.enum(["frequency","in_progress"]),retryAt:Ge.iso.datetime({offset:!0})}),Zp]),Sj=Ge.union([mg.options[0],Hp]);import{z as re}from"zod";var jn=re.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Wp=re.strictObject({entry:jn,nodes:re.array(re.strictObject({id:jn,type:re.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),outputs:re.record(re.string(),jn),writes:re.record(Ae,Ae),resources:re.strictObject({screenId:jn.optional(),paywallVersionId:re.uuid().optional(),couponId:re.uuid().optional(),couponIds:re.array(re.uuid()).max(20).optional(),experimentId:re.uuid().optional(),featureKey:re.string().optional(),offeringVersionId:re.uuid().optional()})})).min(1).max(500)}),Jp={scope:le,funnelId:re.uuid(),versionId:re.uuid(),evaluationRevision:re.number().int().nonnegative(),expiresAt:re.iso.datetime({offset:!0}).nullable(),topology:Wp},An=re.discriminatedUnion("evaluationMode",[re.strictObject({...Jp,evaluationMode:re.literal("local"),growth:_t,conditions:re.record(jn,re.array(re.strictObject({condition:it,port:re.string()})))}),re.strictObject({...Jp,evaluationMode:re.literal("remote")})]),dg=An.options[0].extend({evaluation:re.strictObject({maxTransitions:re.number().int().min(1).max(1e4),variables:re.record(Ae,on),outputSchema:rn,terminals:re.record(jn,re.strictObject({outcome:re.enum(["completed","closed","ineligible","failed"]),output:Zn.nullable()}))})});function fg(e){return Wp.parse({entry:e.graph.entry,nodes:e.graph.nodes.map(t=>{let n={},r={};switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":n.next=t.next;break;case"screen":Object.assign(n,t.outputs),r.screenId=t.screenId;{let a=e.screens.find(l=>l.id===t.screenId);a?.type==="paywall"&&(r.paywallVersionId=a.paywallVersionId)}break;case"condition":t.cases.forEach((a,l)=>{n[`case:${l}`]=a.target}),n.default=t.default;break;case"split":Object.assign(n,t.routes),n.notParticipating=t.notParticipating,r.experimentId=t.experimentId;break;case"action":for(let a of["success","cancel","unavailable","failure"])n[a]=t[a];t.action.type==="claim_offer"&&t.action.coupon.source==="literal"&&t.action.coupon.value&&typeof t.action.coupon.value=="object"&&!Array.isArray(t.action.coupon.value)&&(r.couponId=re.uuid().parse(t.action.coupon.value.id));break;case"external_page":n.opened=t.opened,n.failed=t.failed;break;case"wait":t.wait.type==="duration"?n.elapsed=t.wait.elapsed:(n.received=t.wait.received,n.timeout=t.wait.timeout);break;case"end":case"output":break}t.type==="feature"&&(r.featureKey=t.featureKey),t.type==="offering"&&t.configuration.source==="feature"&&(r.featureKey=t.configuration.featureKey);let o=t.type==="output"?t.value:t.type==="end"?t.output:void 0;return o?.type==="feature"&&(r.featureKey=o.featureKey),t.type==="coupon"&&(r.couponId=t.couponId),t.type==="coupons"&&(r.couponIds=t.couponIds),t.type==="offering"&&t.configuration.source==="fixed"&&(r.offeringVersionId=t.configuration.versionId),{id:t.id,type:t.type,outputs:n,resources:r,writes:"writes"in t?t.writes??{}:{}}})})}function gg(e){let t=Ct.parse(e.document),n=e.evaluationMode==="local"?_t.parse(e.payload):null;if(n&&(n.scope.projectId!==e.scope.projectId||n.scope.environment!==e.scope.environment))throw new Error("GB payload belongs to another App or environment");let r={scope:e.scope,funnelId:e.funnelId,versionId:e.versionId,evaluationRevision:e.evaluationRevision,evaluationMode:e.evaluationMode,expiresAt:n?.expiresAt??null,topology:fg(t)};return An.parse(e.evaluationMode==="remote"?r:{...r,growth:ii(t,n),conditions:Object.fromEntries(t.graph.nodes.filter(o=>o.type==="condition").map(o=>[o.id,o.cases.map((a,l)=>({condition:a.condition,port:`case:${l}`}))]))})}function kj(e){let t=gg(e);if(t.evaluationMode!=="local")throw new Error("Remote Funnel cannot disclose local rules");let n=Ct.parse(e.document);return dg.parse({...t,evaluation:{maxTransitions:n.execution.maxTransitions,variables:n.variables,outputSchema:n.outputSchema,terminals:Object.fromEntries(n.graph.nodes.flatMap(r=>{let o=r.type==="end"?r.output:r.type==="output"?r.value:void 0;return r.type!=="end"&&r.type!=="output"?[]:o&&o.type!=="literal"&&o.type!=="feature"&&o.type!=="variable"?[]:[[r.id,{outcome:r.type==="end"?r.outcome:"completed",output:o??null}]]}))}})}import{z as nt}from"zod";import{z as Be}from"zod";var Qp=Be.discriminatedUnion("provider",[Be.strictObject({provider:Be.literal("apple"),orderId:Be.uuid(),receiptId:Be.uuid(),signedTransaction:Be.string().min(1).max(131072)}),Be.strictObject({provider:Be.literal("google"),orderId:Be.uuid(),receiptId:Be.uuid(),purchaseToken:Be.string().min(1).max(16384)})]),Xp=Be.strictObject({orderId:Be.uuid(),receiptId:Be.uuid(),transactionIds:Be.array(Be.string().min(1).max(255)).min(1).max(50),membership:Be.boolean()});var qj=nt.strictObject({operation:nt.literal("native_receipt"),requestId:nt.uuid(),customerToken:nt.string().regex(pt),orderId:nt.uuid(),receiptId:nt.uuid(),nativeEvidence:Qp.nullable()}).refine(e=>e.nativeEvidence===null||e.nativeEvidence.orderId===e.orderId&&e.nativeEvidence.receiptId===e.receiptId,"Evidence must use this current order receipt"),Fj=nt.strictObject({scope:le,requestId:nt.uuid(),orderId:nt.uuid(),receiptId:nt.uuid(),orderStatus:nt.enum(["created","pending","trialing","paid","cancelled","failed"]),refunded:nt.boolean(),nativeCompletion:Xp.optional()});import{z as he}from"zod";var Yp=he.string().regex(/^[a-f0-9]{64}$/),hg=bn.omit({variations:!0,active:!0}).extend({changeId:Yp,variations:he.array(he.strictObject({urlRedirect:he.string().max(2048)})).min(2).max(20)}),$j=he.strictObject({environmentId:he.uuid(),trackExposures:he.boolean(),generation:Yp,experiments:he.array(hg).max(100),savedGroups:Kn}),bg=he.strictObject({eventUuid:he.uuid(),timestamp:he.iso.datetime({offset:!0}).optional(),deviceId:he.string().min(1).max(128),sessionId:he.string().min(1).max(128).optional(),url:he.url().max(2048),pageTitle:he.string().max(512).optional(),experimentKey:he.string().min(1).max(255),variationKey:he.string().min(1).max(64)}),Gj=he.strictObject({events:he.array(bg).min(1).max(20)}),Kj=he.strictObject({inserted:he.number().int().nonnegative(),duplicates:he.number().int().nonnegative(),skipped:he.number().int().nonnegative(),rejected:he.array(he.strictObject({index:he.number().int().nonnegative(),reason:he.string()}))});import{z as Se}from"zod";var ia=32,yg=522240;function oa(e){if(["entry","condition","feature","split","offering","coupon","coupons"].includes(e.type))return!0;if(e.type!=="end"&&e.type!=="output")return!1;let t=e.type==="end"?e.output:e.value;return t?.type!=="bundle"&&t?.type!=="selection"}var xg=Se.strictObject({nodeId:Se.string().min(1).max(64),visit:Se.number().int().nonnegative(),revision:Se.number().int().nonnegative()}),ra=Se.record(Se.string(),ee),Sg=Se.strictObject({id:Se.uuid(),nodeId:Se.string().min(1).max(64),visit:Se.number().int().nonnegative(),input:Se.strictObject({schemaVersion:Hn.shape.schemaVersion,kind:Hn.shape.kind,selector:Hn.shape.selector,contract:Hn.shape.contract}),context:ra,removed:Se.array(Se.string()).max(100),attributes:ra,removedAttributes:Se.array(Se.string()).max(100),result:zu,offeringVersionId:Se.uuid().nullable(),events:Se.strictObject({entered:Se.string().regex(/^[1-9][0-9]{0,18}$/),decision:Se.string().regex(/^[1-9][0-9]{0,18}$/).nullable()})}),Qj=Se.strictObject({schemaVersion:Se.literal(1),mode:Se.enum(["local","remote"]),versionId:Se.uuid(),generation:Se.number().int().positive(),base:xg,context:ra,steps:Se.array(Sg).min(1).max(ia)}).refine(e=>Ze(e)<=yg,"Segment exceeds its byte budget");var vg=/^(parameters(?:\.|$)|answers(?:\.|$)|results(?:\.|$)|variables(?:\.|$)|funnelParticipantId$)/;function ir(e){return Array.isArray(e)?e.some(ir):!e||typeof e!="object"?!1:Object.entries(e).some(([t,n])=>t.startsWith("$")?["$and","$or","$nor","$not"].includes(t)&&ir(n):!vg.test(t))}function el(e,t,n,r){if(e.executionContract!=="funnel-process/1"||r)return null;if(["offering","coupon","coupons"].includes(t.type)||t.type==="action"&&t.action.type!=="event"||t.type==="screen"&&(t.offering||e.screens.some(p=>p.id===t.screenId&&p.type==="paywall")))return"customer_required";let o=t.type==="end"?t.output:t.type==="output"?t.value:void 0;if(o&&["bundle","selection","offering"].includes(o.type)||t.type==="condition"&&t.cases.some(p=>ir(p.condition)))return"customer_required";let a=JSON.stringify([t,t.type==="screen"?e.screens.find(p=>p.id===t.screenId):null]);for(let[p,d]of Object.entries(e.variables))if(d.source.type==="attribute"&&d.source.key!=="funnelParticipantId"&&(a.includes(`variables.${p}`)||a.includes(JSON.stringify(p))))return"customer_required";if(t.type==="split"){let p=n.experiments?.[t.experimentId];if((p?.hashAttribute??"id")!=="funnelParticipantId"||ir(p?.condition)||p?.parentConditions?.length)return"customer_experiment_required"}let l=t.type==="feature"?t.featureKey:o?.type==="feature"?o.featureKey:void 0;return l&&n.features?.[l]?.rules?.some(p=>(p.hashAttribute??"id")!=="funnelParticipantId"||ir(p.condition)||p.parentConditions?.length)?"customer_experiment_required":null}var aa=class extends Error{constructor(n,r){super(r);this.code=n;this.name="FunnelLocalCalculationError"}code},ci=(e,t)=>new aa(e,t),Ig=e=>({experiments:e.experiments,features:e.features});function Og(e,t=ci){let n=new Map(e.topology.nodes.map(l=>[l.id,l])),r=fa(e.growth.savedGroups),o=Ig(e.growth);function a(l,p){if(!Object.hasOwn(e.growth.features,l))throw t("INVALID_RESPONSE","Required GB Feature is unavailable");return wn(l,p).value}return{nodes:n,savedGroups:r,features:o.features,feature:a,evaluate(l,p){let d=n.get(l);if(!d)throw t("NOT_FOUND","Funnel node is unavailable");let v,h;if(d.type==="condition"){let $=e.conditions[d.id];if(!$)throw t("INVALID_RESPONSE","Local condition rules are unavailable");v=Xo({id:d.id,name:d.id,type:"condition",cases:$.map(C=>({condition:C.condition,target:d.outputs[C.port]})),default:d.outputs.default},p,o.experiments).port}else if(d.type==="feature"){if(!d.resources.featureKey)throw t("INVALID_RESPONSE","Feature reference is unavailable");h=a(d.resources.featureKey,p),v="next"}else if(d.type==="split"){if(!(d.resources.experimentId?e.growth.experiments[d.resources.experimentId]:void 0))throw t("INVALID_RESPONSE","Experiment reference is unavailable");let C=Xo({id:d.id,name:d.id,type:"split",experimentId:d.resources.experimentId,routes:d.outputs,notParticipating:d.outputs.notParticipating},p,o.experiments);h=C.value,v=C.port}else if(["offering","end","output"].includes(d.type)&&d.resources.featureKey)h=a(d.resources.featureKey,p),v=d.type==="offering"?"next":"value";else throw t("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let T=d.outputs[v]??(v==="value"?d.id:void 0);if(!T)throw t("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:l,port:v,target:T,...h===void 0?{}:{value:h}}}}}function pA(e,t,n,r=ci){return sa(e,r)(t,n)}function sa(e,t){let n=An.parse(e);if(n.evaluationMode!=="local")throw t("EVALUATION_MODE","Remote nodes are evaluated by Grow");let r=n.expiresAt?Date.parse(n.expiresAt):null,o=()=>{if(r!==null&&r<=Date.now())throw t("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition")};o();let a=Og(n,t);return(l,p)=>(o(),jg(a,l,p))}function jg(e,t,n){let r=Ke.parse(n.attributes??{}),{saveStickyBucketAssignmentDoc:o,onFeatureUsage:a,onExperimentViewed:l}=n,p={attributes:r,...o?{saveStickyBucketAssignmentDoc:d=>o(structuredClone(d))}:{},...a?{onFeatureUsage:(d,v)=>a(d,structuredClone(v))}:{},...l?{onExperimentViewed:(d,v)=>l(structuredClone(d),structuredClone(v))}:{},features:e.features,savedGroups:e.savedGroups,...n.stickyBucketAssignmentDocs?{stickyBucketAssignmentDocs:structuredClone(n.stickyBucketAssignmentDocs)}:{}};return e.evaluate(t,p)}function lA(e,t,n,r=ci){return tl(sa(e,r),t,n)}function tl(e,t,n){let r=[],o=[],a=[],l=e(t,{...n.attributes?{attributes:n.attributes}:{},stickyBucketAssignmentDocs:n.sticky,saveStickyBucketAssignmentDoc(p){let d=r.findIndex(T=>T.next.attributeName===p.attributeName&&T.next.attributeValue===p.attributeValue),v=p.attributeName+"||"+p.attributeValue,h={expected:n.sticky[v]??null,next:p};d<0?r.push(h):r[d]=h},onExperimentViewed(p,d){d.inExperiment&&d.hashUsed&&!d.passthrough&&o.push(ee.parse({key:p.key,variationId:d.variationId,keyUsed:d.key,hashAttribute:d.hashAttribute,hashValue:d.hashValue}))},onFeatureUsage(p,d){a.push(ee.parse({feature:p,value:d.value,source:d.source,...d.ruleId?{ruleId:d.ruleId}:{}}))}});return{port:l.port,...l.value===void 0?{}:{value:l.value},sticky:r,exposures:o,features:a}}function mA(e,t,n,r=ci){let o=n,a=new Map(t.graph.nodes.map(Z=>[Z.id,Z])),l=structuredClone(n.variables),p=structuredClone(o.sticky),d=[],v=n.nodeId,h=n.visit,T=!1,$,C=Z=>el(t,Z,e.evaluationMode==="local"?e.growth:{features:{},experiments:{}},o.attributes.funnelCustomerBound===!0),u=Z=>($??=sa(e,r),tl($,Z,{attributes:xo({declarations:t.variables,attributes:o.attributes,parameters:n.parameters,answers:n.answers,results:l,savedGroups:{}}),sticky:p}));for(let Z=0;Z<ia;Z++){let E=a.get(v);if(!E||!oa(E)||C(E))break;if(h>=t.execution.maxTransitions&&(h>t.execution.maxTransitions||E.type!=="end"&&E.type!=="output")){if(!d.length)throw r("TRANSITION_LIMIT","Local Funnel transition budget exceeded");break}let oe,ke;if(["condition","feature","split"].includes(E.type)||E.type==="offering"&&E.configuration.source==="feature")oe=u(E.id),E.type==="offering"&&(oe.value={type:"offering_version",id:String(oe.value)}),E.type==="condition"?ke=oe.port==="default"?E.default:E.cases[Number(oe.port.slice(5))]?.target:E.type==="split"?ke=oe.port==="notParticipating"?E.notParticipating:E.routes[oe.port]:(E.type==="feature"||E.type==="offering")&&(ke=E.next);else if(oe={port:"next",sticky:[],exposures:[],features:[]},(E.type==="entry"||E.type==="coupon"||E.type==="coupons")&&(ke=E.next),E.type==="offering"&&E.configuration.source==="fixed"&&(oe.value={type:"offering_version",id:E.configuration.versionId},ke=E.next),E.type==="end"||E.type==="output"){let Y=E.type==="end"?E.output:E.value;if(oe=Y?.type==="feature"?u(E.id):{...oe,port:"value",value:Y?.type==="literal"?Y.value:Y?.type==="variable"?_i({source:"variable",key:Y.key,...Y.path?{path:Y.path}:{}},{declarations:t.variables,answers:n.answers,results:l,parameters:n.parameters,attributes:o.attributes,savedGroups:{}}):null},Y&&(oe.value===void 0||!Xe(t.outputSchema,oe.value)))throw r("INVALID_RESPONSE","Local terminal violates its declared output")}let L=[...d,{nodeId:v,result:oe}];if(Ze({steps:L})>6e4){if(!d.length)throw r("INVALID_REQUEST","Local step exceeds its command budget");break}if(d.push({nodeId:v,result:oe}),E.type==="feature"||E.type==="offering"||E.type==="coupon"||E.type==="coupons"){let Y=E.type==="coupons"?E.couponIds.map(H=>({type:"reward",id:H})):E.type==="coupon"?{type:"reward",id:E.couponId}:oe.value;if(Y===void 0)throw r("INVALID_RESPONSE","Node output is missing");let pe=Dt(E,{value:Y});wi(t.variables,E,pe),Object.assign(l,pe)}for(let Y of oe.sticky)p[`${Y.next.attributeName}||${Y.next.attributeValue}`]=structuredClone(Y.next);if(E.type==="end"||E.type==="output"){T=!0;break}if(!ke)throw r("INVALID_RESPONSE","Local pure exit is unavailable");v=ke,h++}let b=a.get(v);return{steps:d,...!T&&b&&(!oa(b)||C(b))?{boundary:{nodeId:v,visit:h}}:{}}}import{z as Ag}from"zod";var bA=Ag.strictObject({document:Ct,configuration:An.options[0]});var D_={name:"@tinkerlandai/longplay-sdk",version:"0.10.11",description:"Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",license:"UNLICENSED",repository:{type:"git",url:"git+https://github.com/tinkerlandai/Indiana.git",directory:"packages/sdk"},engines:{node:">=22"},publishConfig:{access:"public",tag:"beta"},type:"module",sideEffects:!1,files:["dist","README.md","README.zh-CN.md","CHANGELOG.md","THIRD_PARTY_NOTICES.md"],exports:{"./react-native":{types:"./dist/react-native.d.ts","react-native":"./dist/react-native.js",import:"./dist/react-native.js",default:"./dist/react-native.js"},".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./popup":{types:"./dist/popup.d.ts",import:"./dist/popup.js"},"./server":{types:"./dist/server.d.ts",import:"./dist/server.js"},"./openrouter":{types:"./dist/openrouter.d.ts",import:"./dist/openrouter.js"},"./native-shell":{types:"./dist/native-shell.d.ts",import:"./dist/native-shell.js"},"./page":{types:"./dist/page.d.ts",import:"./dist/page.js"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit",lint:"node ../../scripts/ci/lint.mjs --workspace packages/sdk"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1","dom-mutator":"0.7.0",dompurify:"^3.4.15",zod:"4.6.6"},devDependencies:{"@indiana/contracts":"workspace:*","@openrouter/sdk":"^1.4.25","@types/css-tree":"^3.2.0",ai:"7.0.136",tsup:"^8.5.1",typescript:"^5.9.3","whatwg-url-minimum":"0.2.0"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};var z_="https://api.longplayai.com";export{le as a,Ph as b,Ch as c,kh as d,Rh as e,jr as f,Mh as g,Dh as h,zh as i,Bh as j,Cg as k,kg as l,Fa as m,pt as n,tn as o,nn as p,$a as q,Bg as r,qg as s,cl as t,Za as u,Vg as v,pl as w,ll as x,ml as y,gr as z,br as A,vi as B,gl as C,Ug as D,hl as E,$g as F,Gg as G,Wa as H,Zg as I,Hg as J,yl as K,xl as L,Xg as M,Xe as N,wi as O,_i as P,ki as Q,Oh as R,px as S,_t as T,co as U,Dd as V,ou as W,po as X,xo as Y,iS as Z,oS as _,aS as $,jS as aa,AS as ba,wS as ca,tt as da,Vu as ea,Sf as fa,vf as ga,lI as ha,qo as ia,Of as ja,mI as ka,dI as la,fI as ma,Xn as na,wI as oa,Qu as pa,Wu as qa,Uo as ra,jf as sa,DI as ta,I as ua,gO as va,Xf as wa,On as xa,Fp as ya,RO as za,ig as Aa,GO as Ba,Vp as Ca,Up as Da,$p as Ea,LO as Fa,Lp as Ga,lg as Ha,nj as Ia,rj as Ja,ij as Ka,oj as La,aj as Ma,lj as Na,Zp as Oa,xj as Pa,Sj as Qa,An as Ra,dg as Sa,gg as Ta,kj as Ua,qj as Va,Fj as Wa,$j as Xa,Og as Ya,pA as Za,lA as _a,mA as $a,bA as ab,D_ as bb,z_ as cb};