@tinkerlandai/indiana-sdk 0.9.2 → 0.9.5

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 (63) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +60 -4
  3. package/README.zh-CN.md +26 -3
  4. package/dist/{ai-usage-DMNKvCiq.d.ts → ai-usage-CUTIHAU0.d.ts} +5 -5
  5. package/dist/{api--Zf0gxfj.d.ts → api-BXu6TAoB.d.ts} +274 -127
  6. package/dist/{chunk-65TBYVCS.js → chunk-4C3HUZ3B.js} +1 -1
  7. package/dist/chunk-5ZWSFE2C.js +1 -0
  8. package/dist/chunk-6ZZUNGNE.js +1 -0
  9. package/dist/chunk-AOGPGUWE.js +1 -0
  10. package/dist/chunk-BOCKPUCM.js +2 -0
  11. package/dist/chunk-CLXORAOK.js +1 -0
  12. package/dist/chunk-HEGNIATD.js +1 -0
  13. package/dist/{chunk-WSVH6IQA.js → chunk-LMO3FXRT.js} +1 -1
  14. package/dist/chunk-M7JWCLYX.js +173 -0
  15. package/dist/chunk-MKV726FV.js +1 -0
  16. package/dist/chunk-QYECMZJJ.js +1 -0
  17. package/dist/chunk-UBMPFTGE.js +1 -0
  18. package/dist/chunk-UWFYBRM2.js +6 -0
  19. package/dist/chunk-XRXI3DMZ.js +1 -0
  20. package/dist/chunk-XSOEA4A5.js +4 -0
  21. package/dist/{configuration-sync-E98CqVwh.d.ts → configuration-sync-DuJl4SbM.d.ts} +64 -11
  22. package/dist/content-PQJYLAGQ.js +1 -0
  23. package/dist/coupon-fA1QujHt.d.ts +184 -0
  24. package/dist/{customer-page-9B97Qdt_.d.ts → customer-page-km5f1PJZ.d.ts} +86 -182
  25. package/dist/{funnel-local-client-BjPwXlQb.d.ts → funnel-local-client-BhHdi5_V.d.ts} +2843 -1187
  26. package/dist/funnel-node-evaluation-DuPmqIo1.d.ts +998 -0
  27. package/dist/funnel-resource-client-BoIhL_my.d.ts +9674 -0
  28. package/dist/funnel-runtime-host-3YUGXD3Y.js +1 -0
  29. package/dist/index.d.ts +1292 -9349
  30. package/dist/index.js +1 -1
  31. package/dist/native-shell.js +1 -1
  32. package/dist/openrouter.d.ts +3 -3
  33. package/dist/openrouter.js +1 -1
  34. package/dist/page.d.ts +3 -3
  35. package/dist/page.js +1 -1
  36. package/dist/paywall-CSAGKPCP.js +1 -0
  37. package/dist/popup.d.ts +7 -5
  38. package/dist/popup.js +1 -1
  39. package/dist/react-native.d.ts +23680 -173
  40. package/dist/react-native.js +1 -1
  41. package/dist/{screen-BITZ11jn.d.ts → screen-CvfI_L41.d.ts} +157 -4
  42. package/dist/{screen-renderer-A6VYE2QL.js → screen-renderer-VAMWY7ID.js} +1 -1
  43. package/dist/server.d.ts +355 -95
  44. package/dist/server.js +1 -1
  45. package/dist/visual-dom-OFB7BFFB.js +1 -0
  46. package/dist/visual.d.ts +1 -1
  47. package/dist/visual.js +1 -1
  48. package/package.json +1 -1
  49. package/dist/chunk-5O667MKA.js +0 -1
  50. package/dist/chunk-67A7I6MB.js +0 -1
  51. package/dist/chunk-CCQHYQ4P.js +0 -1
  52. package/dist/chunk-CPLLMISZ.js +0 -1
  53. package/dist/chunk-G23YNWWI.js +0 -1
  54. package/dist/chunk-L7LKE3MG.js +0 -173
  55. package/dist/chunk-NH2PTTNK.js +0 -2
  56. package/dist/chunk-PK5HYUHD.js +0 -1
  57. package/dist/chunk-SEW4YVR7.js +0 -1
  58. package/dist/chunk-UYSOTMY3.js +0 -1
  59. package/dist/chunk-YZSQDZXW.js +0 -4
  60. package/dist/content-3LOJVYQO.js +0 -1
  61. package/dist/errors-0TSUIbUi.d.ts +0 -115
  62. package/dist/funnel-runtime-host-NYHKQT6T.js +0 -1
  63. package/dist/paywall-ISCYOGPZ.js +0 -1
@@ -0,0 +1,6 @@
1
+ import{$ as Ct,A as Va,B as La,C as $a,D as Ga,E as Ka,F as xr,G as ln,H as Ha,I as Za,J as qn,K as Qa,L as pn,M as Ja,O as Wa,P as Xa,Q as Ya,R as es,V as zn,X as Ot,Y as et,Z as Nn,_ as wi,a as xi,b as _a,c as Pa,ca as ji,d as Ca,e as ae,f as Si,fa as vr,g as ka,ga as $t,h as lt,ha as ht,i as Oe,ia as _i,j as vi,k as It,l as Ra,la as as,m as hr,n as Ea,o as Da,oa as ce,p as cn,q as Ba,r as Mn,s as qa,t as za,u as Na,v as Bn,w as Fa,x as Ua,y as Oi,z as un}from"./chunk-HEGNIATD.js";import{a as Se,b as ts,c as ns,d as rs,e as kt,f as is,g as Sr,h as os,i as ss}from"./chunk-G56XGVMS.js";import{a as cs,b as us}from"./chunk-LMO3FXRT.js";import{a as de,b as Ye,c as Lt,d as Pt,e as yr}from"./chunk-7DXL3LHT.js";import{c as gr,d as br,e as Ta,f as Ii,g as Ma,h as Tn}from"./chunk-3PZ4Y6UD.js";import{z as A}from"zod";import{z as Be}from"zod";var Pi=Be.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"]),ls=Be.strictObject({provider:Be.literal("stripe"),accountId:Be.string().regex(/^acct_[A-Za-z0-9]+$/),eventId:Be.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),type:Pi,occurredAt:Be.number().int().positive().max(Number.MAX_SAFE_INTEGER),data:Be.record(Be.string(),Be.unknown()).and(Be.object({id:Be.string().min(1).max(255),object:Be.enum(["checkout.session","subscription","invoice","discount","refund","charge"]),livemode:Be.boolean()}))}),ps=Be.strictObject({id:Be.uuid(),eventId:Be.string().min(1).max(200),source:Be.literal("merchant"),providerVerified:Be.literal(!1),outcome:Be.string().min(1).max(100)});import{z as Gt}from"zod";var Rt=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,Et=Gt.object({customerId:Gt.uuid(),sessionId:Gt.uuid(),accessToken:Gt.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:Gt.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:Gt.iso.datetime(),refreshExpiresAt:Gt.iso.datetime()});var dn=2,ms="/integrations/indiana",vh="X-Indiana-Merchant-Bridge-Version",qp=["session","catalog","customer_commerce","presentation","presentation_events","purchases","operation_status","billing_records","subscription_changes","refunds"],zp=A.enum(qp),Ih={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"}},fs=A.enum(["bridge.ping","bridge.describe","session.create","catalog.read","customer.commerce.read","presentation.resolve","presentation.report","purchase.execute","operation.read","subscription.change","refund.execute"]),As=A.string().regex(/^[A-Za-z0-9_-]{1,64}$/),Np=A.string().regex(/^[A-Za-z0-9_-]{43}$/).refine(e=>"AEIMQUYcgkosw048".includes(e.at(-1)),"Use canonical base64url for a 32-byte key"),Ci=A.strictObject({keyId:As,signingSecret:Np}),Fp=A.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),hs=A.array(zp).max(10).refine(e=>new Set(e).size===e.length,"Capabilities must be unique"),gs=A.strictObject({bridgeVersion:A.literal(dn),projectId:A.uuid(),environmentId:A.uuid(),environment:A.enum(["sandbox","live"]),accountId:A.string().regex(/^acct_[A-Za-z0-9]+$/).optional(),capabilities:hs,catalog:A.enum(["endpoint","static","none"]),billingEvents:A.array(Pi).max(18)}).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"})}),bs=A.strictObject({origin:Fp,requiredCapabilities:hs}),Up=A.strictObject({revision:A.number().int().nonnegative(),checkedAt:A.iso.datetime(),outcome:A.enum(["valid","unreachable","invalid","scope_mismatch","authentication_failed","credentials_missing"]),diagnostics:A.strictObject({ping:A.enum(["passed","failed","not_checked"]),authentication:A.enum(["passed","failed","not_checked"]),catalog:A.enum(["passed","failed","not_checked","static","unsupported"])}),manifest:gs.nullable()}).superRefine((e,t)=>{e.outcome==="valid"!=(e.manifest!==null)&&t.addIssue({code:"custom",path:["manifest"],message:"Only a valid declaration carries a manifest"})}),Oh=A.strictObject({projectId:A.uuid(),environmentId:A.uuid(),environment:A.enum(["sandbox","live"]),execution:A.enum(["indiana","record_only"]),accountId:A.string().nullable(),revision:A.number().int().nonnegative(),authentication:A.strictObject({keyId:As}).nullable(),secretStoreConfigured:A.boolean().optional(),connection:bs.nullable(),check:Up.nullable()});var ds=A.strictObject({projectId:A.uuid(),environmentId:A.uuid()}),wh=A.discriminatedUnion("action",[ds.extend({action:A.literal("save"),revision:A.number().int().nonnegative(),connection:bs,authentication:Ci.optional()}),ds.extend({action:A.literal("check"),revision:A.number().int().nonnegative()})]),ki=A.strictObject({projectId:A.uuid(),environmentId:A.uuid(),accountId:A.string().regex(/^acct_[A-Za-z0-9]+$/).optional(),environment:A.enum(["sandbox","live"])});function jh(e){return A.strictObject({bridgeVersion:A.literal(dn),requestId:A.uuid(),command:fs,scope:ki,data:e})}var Vp=A.strictObject({nativeUserId:A.string().min(1).max(128),session:Et.strict()}),Lp=A.strictObject({nativeUserId:A.string().min(1).max(128),presentation:A.strictObject({customerId:A.uuid(),decisionId:A.uuid(),offeringVersionId:A.uuid(),paywallVersionId:A.uuid(),variant:A.string().min(1).max(128)}).nullable()}),$p=A.strictObject({decisionId:A.uuid(),eventId:A.uuid()}),Ir=A.strictObject({operationId:A.uuid()}),Or=A.strictObject({operationId:A.uuid(),customerId:A.uuid(),merchantExecutionId:A.string().min(1).max(120),merchantOrderId:A.string().min(1).max(255).nullable(),providerSessionId:A.string().regex(/^cs_[A-Za-z0-9_]+$/).nullable(),paymentStatus:A.enum(["not_started","pending","succeeded","failed","expired","unknown"]),fulfillmentStatus:A.enum(["not_started","pending","applied","failed","not_applicable"]),recordingStatus:A.enum(["not_ready","pending","accepted","failed"]),indianaStatus:A.enum(["pending","complete","cancelled","failed"]).nullable(),checkoutUrl:A.url().max(2048).refine(e=>{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}).nullable(),checkoutExpiresAt:A.iso.datetime().nullable(),updatedAt:A.iso.datetime(),pollAfterMs:A.number().int().min(1e3).max(3e4).nullable()}).superRefine((e,t)=>{e.checkoutUrl!==null&&(e.paymentStatus!=="pending"||e.checkoutExpiresAt===null)&&t.addIssue({code:"custom",path:["checkoutUrl"],message:"Only a safe pending execution returns a Checkout destination"}),e.indianaStatus==="complete"&&(e.paymentStatus!=="succeeded"||!["applied","not_applicable"].includes(e.fulfillmentStatus)||e.recordingStatus!=="accepted"||e.pollAfterMs!==null)&&t.addIssue({code:"custom",path:["indianaStatus"],message:"Completion requires payment, fulfilment and accepted recording"})}),Dt=A.string().min(1).max(120),Gp=A.string().regex(/^-?[0-9]+(?:\.[0-9]{1,6})?$/),Kp=A.strictObject({revision:Dt,updatedAt:A.iso.datetime(),provider:A.literal("stripe"),accountId:A.string().regex(/^acct_[A-Za-z0-9]+$/),items:A.array(A.strictObject({merchantProductId:Dt,productVersionId:A.uuid(),name:A.string().min(1).max(255),kind:A.enum(["subscription","credit_pack"]),stripePriceId:A.string().regex(/^price_[A-Za-z0-9]+$/),currency:A.string().regex(/^[a-z]{3}$/),amountMinor:A.number().int().nonnegative().max(1e8),interval:A.enum(["one_time","month","year"]),intervalCount:A.literal(1),includedCredits:A.string().regex(/^[0-9]{1,18}(?:\.[0-9]{1,6})?$/),creditReset:A.enum(["none","month"]),creditPolicyId:Dt,available:A.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)}),Hp=A.strictObject({customerId:A.uuid(),revision:A.string().min(1).max(128),observedAt:A.iso.datetime(),subscriptions:A.array(A.strictObject({merchantSubscriptionId:Dt,merchantProductId:Dt,productVersionId:A.uuid().nullable(),status:A.enum(["active","trialing","past_due","cancelled","expired"]),currentPeriodStartsAt:A.iso.datetime().nullable(),currentPeriodEndsAt:A.iso.datetime().nullable(),cancelAtPeriodEnd:A.boolean(),scheduledChange:A.strictObject({effectiveAt:A.iso.datetime(),merchantProductId:Dt}).nullable()})).max(100),purchaseHistory:A.strictObject({complete:A.boolean(),hasPaidPurchase:A.boolean(),lastPaidAt:A.iso.datetime().nullable()}),balances:A.array(A.strictObject({bucketId:Dt,key:Dt,available:Gp,expiresAt:A.iso.datetime().nullable(),nextResetAt:A.iso.datetime().nullable()})).max(100)}),_h=A.strictObject({bridgeVersion:A.literal(dn),requestId:A.uuid(),command:A.string().min(1).max(64),scope:ki,error:A.strictObject({code:A.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:A.string().min(1).max(500),retryable:A.boolean(),recovery:A.string().min(1).max(80)})}),Fn=A.strictObject({}),Zp={"bridge.ping":A.strictObject({challenge:A.uuid()}),"bridge.describe":Fn,"session.create":Fn,"catalog.read":Fn,"customer.commerce.read":Fn,"presentation.resolve":Fn,"presentation.report":$p,"purchase.execute":Ir,"operation.read":Ir,"subscription.change":Ir,"refund.execute":Ir},Ph={"bridge.ping":A.strictObject({challenge:A.uuid()}),"bridge.describe":gs,"session.create":Vp,"catalog.read":Kp,"customer.commerce.read":Hp,"presentation.resolve":Lp,"presentation.report":A.strictObject({queued:A.literal(!0)}),"purchase.execute":Or,"operation.read":Or,"subscription.change":Or,"refund.execute":Or},Ch=A.strictObject({bridgeVersion:A.literal(dn),requestId:A.uuid(),scope:ki,command:fs,data:A.unknown()}).superRefine((e,t)=>{!e.scope.accountId&&!["bridge.ping","bridge.describe"].includes(e.command)&&t.addIssue({code:"custom",path:["scope","accountId"],message:"This business command requires its current payment binding"}),Zp[e.command].safeParse(e.data).success||t.addIssue({code:"custom",path:["data"],message:"Invalid command data"})});var ys="X-Indiana-Bridge-Signature",xs="X-Indiana-Bridge-Key-Id";function Qp(e){return new TextEncoder().encode(e)}function Ss(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),t=>t.charCodeAt(0))}function vs(e,t,n){return Qp(`indiana-merchant-bridge:${dn}
2
+ ${t}
3
+ POST
4
+ ${ms}
5
+ ${n}
6
+ ${e}`)}async function Is(e){let t=Ci.parse(e);return crypto.subtle.importKey("raw",Ss(t.signingSecret),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}async function Eh(e,t,n,r=Date.now()){let i=String(Math.floor(r/1e3)),o=new Uint8Array(await crypto.subtle.sign("HMAC",await Is(t),vs(e,n,i))),a=btoa(String.fromCharCode(...o)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"");return{[xs]:t.keyId,[ys]:`t=${i},v1=${a}`}}async function Dh(e,t,n,r,i=Date.now()){try{if(t.get(xs)!==n.keyId)return!1;let o=/^t=([0-9]{1,12}),v1=([A-Za-z0-9_-]{43})$/.exec(t.get(ys)??"");return!o||Math.abs(i/1e3-Number(o[1]))>300?!1:await crypto.subtle.verify("HMAC",await Is(n),Ss(o[2]),vs(e,r,o[1]))}catch{return!1}}var Os={"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 Ri(e){let t=Ba(e)??"en",n=t.split("-"),r=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(o=>["TW","HK","MO"].includes(o))?"zh-Hant":"zh-Hans":n[0]??"en",i=Os[r];return i?{locale:t,copy:i}:{locale:"en",copy:Os.en}}function Jp(e,t,n="zh-CN"){let r=Si(t);return ka(e,t,Ri(n).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:e%10**r===0?0:r,maximumFractionDigits:r})}function Wp(e,t="zh-CN"){let n=Ri(t).locale;return e.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:2}).format(e.percentOff/100):Jp(e.amountOffCents,e.currency,n)}var ws={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 qh(e,t="zh-CN",n="month"){let r=Ri(t),i=Wp(e.discount,r.locale);if(e.appliesTo?.type==="merchandise")return r.copy.merchandise.replace("{discount}",i);let o=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale).format(e.duration.months):"",a=r.locale.split("-")[0]??"en",c=a==="zh"&&/(?:Hant|TW|HK|MO)/.test(r.locale)?"zh-Hant":a,u=e.duration.type==="repeating"&&n!=="month"?ws[c]??ws.en:e.duration.type==="repeating"&&e.duration.months===1?r.copy.repeatingOne??r.copy.repeating:r.copy[e.duration.type],p=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(e.duration.months):"";return u.replace("{discount}",i).replace("{months}",o).replace("{period}",p)}import{z as W}from"zod";import{z as Ve}from"zod";var Ee=Ve.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"),Ei=Ve.strictObject({type:Ve.enum(["string","number","boolean","strings","json","offering_version","reward","paywall_version"]),nullable:Ve.boolean(),enum:Ve.array(Ve.string().max(255)).min(1).max(100).optional()}),mn=Ei.extend({type:Ve.enum([...Ei.shape.type.options,"array"]),items:Ei.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"})}),fn=mn.safeExtend({source:Ve.discriminatedUnion("type",[Ve.strictObject({type:Ve.literal("input")}),Ve.strictObject({type:Ve.literal("node")}),Ve.strictObject({type:Ve.enum(["parameter","attribute"]),key:Ee})])}),Xp=Ve.record(Ee,fn),wr=Ve.record(Ee,Ee).refine(e=>Object.keys(e).length<=20);function at(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=>at(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&&Ve.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 Di(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&&Di(e.items,t.items)}function Un(e,t){let n={};for(let[r,i]of Object.entries(e)){let o=i.source,a=o.type==="input"?t.answers:o.type==="node"?t.results??{}:o.type==="parameter"?t.parameters:t.attributes,c=o.type==="parameter"||o.type==="attribute"?o.key:r,u=Object.hasOwn(a,c),p=a[c];if(o.type==="attribute"&&c.includes(".")&&(!u||c.startsWith("merchandise."))){p=a,u=!0;for(let b of c.split(".")){if(!p||typeof p!="object"||!Object.hasOwn(p,b)||Array.isArray(p)&&(!/^(0|[1-9]\d*)$/.test(b)||Number(b)>=p.length)){u=!1;break}p=p[b]}}if(!(!u||p===void 0)){if(!at(i,p))throw new Error(`Invalid variable value: ${r}`);n[r]=p}}return n}function Kt(e,t){let n={};for(let[r,i]of Object.entries(e.writes??{})){if(!Object.hasOwn(t,r))throw new Error(`Node output is missing: ${r}`);if(Object.hasOwn(n,i))throw new Error("Node outputs cannot overwrite one another");n[i]=t[r]}return n}function Ti(e,t,n){let r=new Set(Object.values(t.writes??{}));for(let[i,o]of Object.entries(n))if(!r.has(i)||e[i]?.source.type!=="node"||!at(e[i],o))throw new Error(`Invalid node variable write: ${i}`);if(r.size!==Object.keys(n).length)throw new Error("Node output is incomplete")}import{z as Ht}from"zod";var pt=Ht.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"),gt=Ht.discriminatedUnion("source",[Ht.strictObject({source:Ht.literal("literal"),value:de}),Ht.strictObject({source:Ht.literal("variable"),key:Ht.string().min(1).max(255),path:pt.optional()})]);function js(e,t){if(!t)return e;for(let n of pt.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 Mi(e,t){if(e.source==="literal")return structuredClone(e.value);let n=Un(t.declarations,t);if(!Object.hasOwn(n,e.key))throw new Error("Capability input is missing");return structuredClone(de.parse(js(n[e.key],e.path)))}function Bi(e,t){let n=[...t].sort((i,o)=>o.length-i.length).find(i=>e===i||e.startsWith(i+"."));if(!n)return null;let r=e===n?void 0:e.slice(n.length+1);return r&&!pt.safeParse(r).success?null:{key:n,path:r}}function qi(e){let t=Object.values(e.strings.locales).flatMap(n=>Object.values(n));return Ot(e,n=>{n.type==="custom_html"&&t.push(...Object.values(n.html))}),[...new Set(t.flatMap(Ja))]}function jr(e){return qi(e).filter(t=>t.startsWith("variables.")).map(t=>t.slice(10))}function tt(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 i=0;i<t.length;i++){let o=t.charAt(i);if(r)o==="\\"?i++:o==='"'&&(r=!1);else if(o==='"')r=!0;else if(o===":"||o===",")n++;else if(o==="-"||o>="0"&&o<="9"){let a=i;for(;i+1<t.length&&/[0-9.eE+-]/.test(t.charAt(i+1));)i++;let c=t.slice(a,i+1);if(!/[eE]/.test(c))continue;let[u="",p]=c.split(/[eE]/),b=u.replace(/^-/,""),O=b.replace(".","").length,z=(b.includes(".")?b.indexOf("."):O)+Number(p),I=z<=0?2-z+O:z>=O?z:O+1;n+=I+(u.startsWith("-")?1:0)-c.length}}return n}var Tt=W.enum(["page","popup","banner"]),Yp=3e5,_s=W.strictObject({type:W.enum(["string","number","boolean","strings","json"]),nullable:W.boolean()}),ed=W.strictObject({inputs:W.record(zn,_s.extend({required:W.boolean()})).refine(e=>Object.keys(e).length<=40,"Too many content inputs"),outputs:W.record(zn,_s).refine(e=>Object.keys(e).length<=40,"Too many content outputs")}),td=W.strictObject({kind:Tt,schemaVersion:W.literal(1),name:W.string().trim().min(1).max(80),screen:et,contract:ed}),_r=td.superRefine((e,t)=>{let n=(i,o)=>t.addIssue({code:"custom",message:i,path:o});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(i=>i.type!=="event"&&i.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let r=new Set(e.screen.actions.filter(i=>i.type==="event").map(i=>i.id));(Object.keys(e.contract.outputs).some(i=>!r.has(i))||[...r].some(i=>!Object.hasOwn(e.contract.outputs,i)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),tt(e)>Yp&&n("Content document exceeds its byte budget",[])});function nd(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 rd=_r.superRefine((e,t)=>{for(let n of jr(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],i=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;r&&!nd(i,r)&&t.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}Ct(e.screen).some(n=>!n.complete)&&t.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),Ps=W.strictObject({id:W.uuid(),kind:Tt,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})}),eg=Ps.extend({draft:_r}),tg=W.strictObject({rows:W.array(Ps).max(200),nextCursor:W.uuid().nullable()}),zi=W.strictObject({id:W.uuid(),kind:Tt,resourceId:W.uuid(),projectId:W.uuid(),environmentId:W.uuid(),version:W.number().int().positive(),sourceRevision:W.number().int().nonnegative(),document:rd,createdAt:W.iso.datetime({offset:!0})}),ng=zi.omit({document:!0}),rg=W.discriminatedUnion("action",[W.strictObject({action:W.literal("create"),kind:Tt,id:W.uuid(),document:_r}),W.strictObject({action:W.literal("save"),kind:Tt,id:W.uuid(),revision:W.number().int().nonnegative(),document:_r}),W.strictObject({action:W.enum(["publish","archive"]),kind:Tt,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 Pr=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:Xa.optional()});function sg(e,t,n){let r=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof r!="string"||!Object.values(n.plans).some(i=>i.versionId===r&&i.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(r)||!n.pickers[e.pickerId]?.options.includes(r))?null:r}import{z as me}from"zod";var Vn=me.number().int().min(1).max(Number.MAX_SAFE_INTEGER),Cs=me.enum(["unknown","denied","provisional","granted"]),ks=me.enum(["ios","android"]),Cr=me.strictObject({installationId:me.uuid(),publicKey:me.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:me.iso.datetime({offset:!0}),signature:me.string().regex(/^[A-Za-z0-9_-]{86}$/)}),Ni=me.string().regex(/^[a-f0-9]{64}$/),Rs=Cr.extend({sequence:Vn,platform:ks,credentialDigest:Ni}),Es=Cr.extend({credentialDigest:Ni}),lg=Cr.extend({sequence:Vn,platform:ks}),kr=Cr.extend({sequence:Vn,credentialDigest:Ni,connectionId:me.uuid().nullable(),kind:me.enum(["fcm_token","apns_token"]).nullable(),token:me.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:Cs}),pg=kr,dg=kr.extend({challenge:me.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),mg=me.strictObject({requested:me.literal(!0),expiresAt:me.iso.datetime({offset:!0})}),Rr=me.strictObject({installationId:me.uuid(),bound:me.boolean(),identitySeq:Vn,bindingGeneration:Vn,addressSeq:me.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:me.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:me.uuid().nullable(),addressStatus:me.enum(["active","invalid"]).nullable(),permission:Cs}),Fi=me.strictObject({channel:me.enum(["email","sms","voice","push"]),state:me.enum(["unknown","allowed","denied"]),revision:me.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:me.iso.datetime({offset:!0}).nullable()}),fg=me.strictObject({state:me.enum(["allowed","denied"]),revision:me.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function Ag(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 i=JSON.stringify(r);if([...i].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(i,o=>o.charCodeAt(0))}var Ui="X-Indiana-Protocol",Ds="X-Indiana-SDK-Version";var Vi={current:"0.9"};import{z as hn}from"zod";var Er=hn.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"),xg=hn.object({amountCents:hn.number().int().min(0).max(1e8),currency:ae,interval:hn.enum(["free","month","year"]),currencyOptions:hn.partialRecord(ae,hn.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 id=y.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),Bs=y.enum(["single_use","continuous_use"]),Li=y.record(y.string(),y.union([y.string(),y.number(),y.boolean()]).transform(String).pipe(y.string())),Ts=y.string().min(1).max(64).refine(e=>!e.includes("::")),qs={credit_amount:y.number(),tier_behavior:y.never().optional(),tiers:y.never().optional()},zs={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()}))},od=y.union([y.strictObject({match:Li,priority:y.number().int().optional(),...qs}),y.strictObject({match:Li,priority:y.number().int().optional(),...zs})]),ad=y.strictObject({match:Li,factor:y.number().positive().optional(),add:y.number().optional()}).refine(e=>e.factor!==void 0||e.add!==void 0),Ms={metered_feature_id:y.string(),feature_amount:y.number().optional(),dimensions:y.record(Ts,od).optional(),multipliers:y.record(Ts,ad).optional()},$i=y.union([y.strictObject({...Ms,...qs}),y.strictObject({...Ms,...zs})]),Tr=y.number().min(-100),Ns=y.record(y.string(),y.strictObject({markup:Tr})).nullish(),Mr=y.record(y.string().regex(/.+\/.+/),y.strictObject({markup:Tr.optional(),input_cost:y.number().min(0).optional(),output_cost:y.number().min(0).optional()})).nullish(),sd=y.strictObject({default_markup:Tr.optional(),provider_markups:Ns,model_markups:Mr}),Ig=y.strictObject({schema:y.array($i).optional(),markups:sd.optional()}),cd=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:Bs}),Fs=y.strictObject({schema:y.array($i).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:Bs.default("single_use").overwrite(()=>"single_use"),default_markup:Tr.optional(),provider_markups:Ns}),Gi=Fs.safeExtend({schema:y.array($i).length(0)}),Dr={id,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:Mr,stripe_meter:y.strictObject({id:y.string(),event_name:y.string()}).nullish(),stripe_product_id:y.string().nullish()},Ki=e=>y.discriminatedUnion("type",[y.strictObject({...Dr,...e,type:y.literal("boolean"),config:y.null()}),y.strictObject({...Dr,...e,type:y.literal("metered"),config:cd}),y.strictObject({...Dr,...e,type:y.literal("credit_system"),config:Fs}),y.strictObject({...Dr,...e,type:y.literal("ai_credit_system"),config:Gi})]),Og=Ki({}),ud=y.strictObject({id:y.boolean(),type:y.boolean(),usage_type:y.boolean()}),ld={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:ud},Us=Ki(ld),wg=y.strictObject({rows:y.array(Us).max(200),nextCursor:y.uuid().nullable()}),jg=y.strictObject({features:y.array(Us).max(500),limited:y.boolean()}),_g=y.union([Ki({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 l}from"zod";import{z as q}from"zod";import{z as qe}from"zod";function Mt(e){let t=new Set,n=o=>o!==null&&typeof o=="object"&&!Array.isArray(o);function r(o,a){if(n(o))for(let[c,u]of Object.entries(o))c==="$elemMatch"?i(u,a):c==="$not"?r(u,a):c==="$all"&&Array.isArray(u)&&u.forEach(p=>r(p,a))}function i(o,a=""){if(n(o)){for(let[c,u]of Object.entries(o))if(["$and","$or","$nor"].includes(c)&&Array.isArray(u))u.forEach(p=>i(p,a));else if(c==="$not")i(u,a);else if(c==="$savedGroup"&&n(u))typeof u.attributeKey=="string"&&t.add(u.attributeKey);else if(!c.startsWith("$")){let p=a?`${a}.${c}`:c;t.add(p),r(u,p)}}}return i(e),[...t]}var pd=qe.enum(["active","inactive"]),dd=qe.preprocess((e,t)=>{let n=0;function r(i,o){if(!(++n>1e4||o>20)){if(Array.isArray(i))i.forEach(a=>r(a,o+1));else if(i&&typeof i=="object")for(let[a,c]of Object.entries(i))["__proto__","constructor","prototype"].includes(a)&&t.addIssue({code:"custom",message:"Reserved merchandise attribute"}),r(c,o+1)}}return r(e,0),e},Ye),md=qe.strictObject({id:qe.string().trim().min(1).max(255),name:qe.string().trim().min(1).max(255),status:pd,metadata:dd}),Dg=md.extend({internal_id:qe.uuid(),project_id:qe.uuid(),environment_id:qe.uuid(),created_at:qe.iso.datetime({offset:!0}),updated_at:qe.iso.datetime({offset:!0})}),Ls=qe.union([qe.strictObject({id:qe.string().trim().min(1).max(255)}),qe.strictObject({internalId:qe.uuid()})]),Tg=qe.enum(["customer","merchandise","context"]),Mg=qe.enum(["system","stored","request"]),Bg=qe.enum(["customer","merchandise","mixed"]),Vs=e=>e==="merchandiseId"||e==="merchandise"||e.startsWith("merchandise.");function Hi(e,t={},n=new Set){if(Mt(e).some(Vs))return!0;for(let r of Pt(e)){if(n.has(r))continue;n.add(r);let i=t[r];if(i?.type==="list"&&Vs(i.attributeKey)||i?.type==="condition"&&Hi(i.condition,t,n))return!0}return!1}var Vg=q.enum(["draft","active","paused","archived"]),Bt=q.discriminatedUnion("type",[q.object({type:q.literal("percent"),percentOff:q.number().min(1).max(100).multipleOf(.01)}).strict(),q.object({type:q.literal("amount"),amountOffCents:q.number().int().min(1).max(1e8),currency:ae}).strict()]),nt=q.discriminatedUnion("type",[q.object({type:q.literal("once")}).strict(),q.object({type:q.literal("repeating"),months:q.number().int().min(1).max(36)}).strict(),q.object({type:q.literal("forever")}).strict()]),$s=[q.object({type:q.literal("all")}).strict(),q.object({type:q.literal("plans"),planIds:q.array(q.uuid()).min(1).max(50).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()],fd=q.discriminatedUnion("type",[...$s,q.strictObject({type:q.literal("merchandise"),scope:q.discriminatedUnion("type",[q.strictObject({type:q.literal("all")}),q.strictObject({type:q.literal("selected"),merchandiseIds:q.array(q.uuid()).min(1).max(1e3).refine(e=>new Set(e).size===e.length,"Duplicate merchandise")}),q.strictObject({type:q.literal("condition"),condition:Lt})])})]),Zi=q.discriminatedUnion("type",[...$s,q.strictObject({type:q.literal("merchandise"),scope:q.strictObject({type:q.enum(["all","selected","condition"])})})]),Ad=q.strictObject({firstPurchaseOnly:q.boolean(),condition:Lt}),Lg=q.object({name:q.string().trim().min(1).max(80),description:q.string().max(500),discount:Bt,duration:nt,appliesTo:fd,eligibility:Ad,selfClaimEnabled:q.boolean().default(!1),startsAt:q.iso.datetime().nullable(),endsAt:q.iso.datetime().nullable(),totalLimit:q.number().int().min(1).max(1e6).nullable(),perCustomerLimit:q.number().int().min(1).max(10),grantWindowHours:q.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=>!Hi(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"]}),$g=q.object({code:q.string().trim().transform(e=>e.toUpperCase()).pipe(q.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:q.number().int().min(1).max(1e6).nullable(),expiresAt:q.iso.datetime().nullable(),firstPurchaseOnly:q.boolean(),minimumAmountCents:q.number().int().min(1).max(1e8).nullable(),minimumAmountCurrency:ae.nullable()}).strict().refine(e=>e.minimumAmountCents===null==(e.minimumAmountCurrency===null),"Minimum amount requires its currency");var Ln=q.object({id:q.uuid(),couponId:q.uuid(),status:q.enum(["issued","reserved","redeemed","revoked","expired"]),issuedAt:q.iso.datetime(),expiresAt:q.iso.datetime(),coupon:q.object({name:q.string(),discount:Bt,duration:nt,appliesTo:Zi}).strict()}).strict(),Gs=q.enum(["claim_disabled","unavailable","inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var Js=l.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),Qi=l.string().regex(/^(0|[1-9]\d{0,14})$/),gn=l.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,30})?$/),hd=l.string().regex(/^(?:[1-9]\d{0,7}|1\d{8}|200000000)$/),$n=hd,wt=Oe.refine(e=>/[1-9]/.test(e)),Ge=l.iso.datetime({offset:!0}),Br=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"))},gd=l.array(l.object({upTo:wt.nullable(),unitAmountMinor:Js,flatAmountMinor:l.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&&Br(t.upTo)>Br(r))})}catch{return!1}},"Tier ceilings must increase and the final tier must be unbounded"),bd=l.discriminatedUnion("kind",[l.object({kind:l.literal("flat"),units:wt,unitAmountMinor:Js}).strict(),l.object({kind:l.enum(["graduated","volume"]),units:wt,tiers:gd}).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"),yd=l.strictObject({interval:l.enum(["month","year"]),count:l.number().int().min(1).max(12),anchor:l.enum(["membership","calendar"])}),Gn=l.object({currency:ae,pricing:bd,billingCycle:yd.optional()}).strict().refine(e=>e.pricing.kind!=="volume"||e.pricing.tiers.length===1,"Multiple volume tiers require prepaid billing");var Ks={requestId:l.uuid(),productVersionId:l.uuid(),internal_feature_id:l.uuid(),currency:ae},Ws=l.strictObject({interval:l.enum(["hour","day","week","month"]),intervalCount:l.number().int().min(1).max(12),limit:l.number().int().min(1).max(1e6)}),Xs=l.discriminatedUnion("kind",[l.object({...Ks,kind:l.literal("auto_topup"),threshold:vi,quantity:wt.refine(e=>Number(e)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:Ws.optional()}).strict(),l.object({...Ks,kind:l.literal("postpaid"),maxAmountMinorPerPeriod:$n,maxOutstandingMinor:$n}).strict()]),Hs={productVersionId:l.uuid(),internal_feature_id:l.uuid(),currency:ae},Ys=l.discriminatedUnion("kind",[l.object({...Hs,kind:l.literal("auto_topup"),threshold:vi,quantity:wt.refine(e=>Number(e)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:Ws.optional(),purchaseAmountMinor:$n,purchaseUnits:wt}).strict(),l.object({...Hs,kind:l.literal("postpaid"),maxAmountMinorPerPeriod:$n,maxOutstandingMinor:$n,cashPrice:Gn}).strict().refine(e=>e.cashPrice.currency===e.currency,"Currency must match")]),qr=l.object({id:l.uuid(),terms:Ys,status:l.enum(["prepared","active","revoked","blocked"]),createdAt:Ge,acceptedAt:Ge.nullable(),effectiveAt:Ge.nullable(),revokedAt:Ge.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"),ec=l.object({authorizationId:l.uuid(),terms:Ys,setupUrl:l.url().nullable()}).strict(),tc=l.object({authorizationId:l.uuid(),accepted:l.literal(!0)}).strict(),nc=l.object({authorizationId:l.uuid(),requestId:l.uuid()}).strict(),rc=l.object({internal_feature_id:l.uuid(),entityId:l.uuid().nullable(),interval:l.enum(["day","week","month","year"]),anchor:l.enum(["billing_cycle","utc"]).optional(),basis:l.enum(["usage","credits"]),filter:It.optional(),limit:Oe.nullable(),thresholds:l.array(l.number().positive().max(1)).max(8),includedThresholds:l.array(l.number().positive().max(1)).max(8).optional(),absoluteThresholds:l.array(wt).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 i=r[n-1];return n===0||i!==void 0&&t>i})&&(e.absoluteThresholds??[]).every((t,n,r)=>{let i=r[n-1];return n===0||i!==void 0&&Br(t)>Br(i)}),"Notification thresholds must increase"),xd=rc.safeExtend({requestId:l.uuid()}),Zs={control:l.literal("overage"),requestId:l.uuid(),internal_feature_id:l.uuid(),entityId:l.uuid().nullable()},Sd=l.discriminatedUnion("action",[l.strictObject({...Zs,action:l.literal("set"),allowed:l.boolean().nullable(),overageLimit:Oe.nullable(),skipOverageBilling:l.boolean()}),l.strictObject({...Zs,action:l.literal("remove")})]),ic=l.union([xd,Sd]),vd=l.strictObject({internal_feature_id:l.uuid(),entityId:l.uuid().nullable(),allowed:l.boolean().nullable(),overageLimit:Oe.nullable(),skipOverageBilling:l.boolean(),interval:l.enum(["day","week","month","year"]),startsAt:Ge,endsAt:Ge,used:l.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),reserved:l.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),remaining:l.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,6})?$/).nullable()}),Id=l.object({internal_feature_id:l.uuid(),entityId:l.uuid().nullable(),interval:l.enum(["day","week","month","year"]),anchor:l.enum(["billing_cycle","utc"]).optional(),basis:l.enum(["usage","credits"]),filter:It.optional(),startsAt:Ge,endsAt:Ge,used:lt,reserved:lt,limit:Oe.nullable(),thresholds:l.array(l.number().positive().max(1)).max(8),notifiedThresholds:l.array(l.number().positive().max(1)).max(1024),includedThresholds:l.array(l.number().positive().max(1)).max(8).optional(),includedAllowance:l.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/).optional(),notifiedIncludedThresholds:l.array(l.number().positive().max(1)).max(1024).optional(),absoluteThresholds:l.array(wt).max(8).optional(),notifiedAbsoluteThresholds:l.array(wt).max(1024).optional()}).strict().refine(e=>e.basis!=="usage"||Oe.safeParse(e.used).success&&Oe.safeParse(e.reserved).success,"Usage counters retain six decimals; credit costs retain twelve"),Od=l.object({authorizationId:l.uuid(),status:l.enum(["idle","pending","blocked"]),taskId:l.uuid().nullable(),invoiceId:l.uuid().nullable(),hostedInvoiceUrl:l.url().nullable(),purchaseCount:l.number().int().nonnegative(),purchaseWindowEndsAt:Ge.nullable(),attemptCount:l.number().int().nonnegative(),failedAttemptCount:l.number().int().nonnegative(),suspendedAt:Ge.nullable(),nextAttemptAt:Ge.nullable(),failureReason:l.string().min(1).max(240).nullable()}).strict(),oc=l.object({internal_feature_id:l.uuid().optional(),entityId:l.uuid().optional()}).strict(),Ji=l.object({authorizations:l.array(qr).max(100),limits:l.array(rc).max(100),overages:l.array(vd).max(100).optional(),windows:l.array(Id).max(200),autoTopups:l.array(Od).max(100),limited:l.boolean()}).strict(),wd=l.object({id:l.uuid(),internal_feature_id:l.uuid(),productVersionId:l.uuid(),authorizationId:l.uuid(),entityId:l.uuid().nullable(),units:Oe,amountMinor:gn,cashPrice:Gn}).strict(),Kn=l.object({id:l.uuid(),sourceKind:l.enum(["product","usage","manual"]),providerInvoiceId:l.string().min(1).max(240).nullable(),status:l.enum(["accruing","open","pending","paid","failed","void"]),currency:ae,startsAt:Ge.nullable(),endsAt:Ge.nullable(),amountMinor:l.string().regex(/^-?(0|[1-9]\d{0,14})$/),grossAmountMinor:l.string().regex(/^-?(0|[1-9]\d{0,14})$/),discountMinor:Qi,paidAmountMinor:Qi,refundedAmountMinor:Qi,createdAt:Ge,hostedInvoiceUrl:l.url().nullable(),adjustment:l.object({originalInvoiceId:l.uuid(),amountMinor:l.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:Ge.nullable()}).strict().nullable(),lines:l.array(wd).max(100),linesLimited:l.boolean()}).strict(),ac=l.object({invoiceId:l.uuid(),accepted:l.literal(!0)}).strict(),sc=l.object({after:l.uuid().nullable(),limit:l.number().int().min(1).max(100)}).strict(),cc=l.object({rows:l.array(Kn).max(100),nextCursor:l.uuid().nullable()}).strict(),Qs=l.strictObject({id:l.string(),coupon:l.string(),start:l.number().nonnegative(),end:l.number().nullable()}),jd=l.strictObject({subscriptionId:l.string(),customerId:l.string(),accountId:l.string(),sourceItems:l.array(l.strictObject({id:l.string(),price_id:l.string(),quantity:l.number().int(),discounts:l.array(Qs).optional()})).max(100),items:l.array(l.strictObject({id:l.string(),price:l.string(),quantity:l.number().int(),discounts:l.array(l.strictObject({coupon:l.string().optional(),terms:l.strictObject({id:l.string(),name:l.string().optional(),percent_off:l.number().optional(),amount_off:l.number().optional(),currency:l.string().optional(),duration:l.enum(["once","forever","repeating"]),duration_in_months:l.number().optional()}).optional(),discount:l.string().optional(),receipt:Qs.optional()})).max(20)})).max(100)}),uc=l.strictObject({membershipId:l.uuid(),requestId:l.uuid(),grantIds:l.array(l.uuid()).max(20).refine(e=>new Set(e).size===e.length,"Duplicate Coupon grants")}),lc=l.strictObject({membershipId:l.uuid(),operationId:l.uuid(),status:l.enum(["pending","effective"]),execution:jd.nullable(),grants:l.array(l.strictObject({id:l.uuid(),couponId:l.uuid(),name:l.string(),discount:Bt,duration:nt,startedAt:Ge.nullable()})).max(20)});import{z as Hn}from"zod";var pc=Hn.enum(["minute","hour","day","week","month","quarter","semi_annual","year","lifetime"]),dc=Hn.number().int().min(1).max(1e3),zr=Hn.object({cap:Oe.refine(e=>/[1-9]/.test(e)).nullable(),capPercentage:Hn.number().positive().max(1e4).nullable(),cycles:Hn.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 qt}from"zod";var mc=qt.strictObject({itemKey:qt.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:qt.uuid(),includedAmount:qt.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),quantity:qt.number().int().min(0).max(1e4),terms:Ea,pricing:Ra.optional(),unitAmountMinor:qt.number().int().min(0).max(1e8),productId:qt.string().min(1).max(255).nullable(),priceId:qt.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),hr({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 ie}from"zod";var Zt=ie.iso.datetime({offset:!0}),fc=Oe.refine(e=>/[1-9]/.test(e)),Ac=ie.strictObject({interval:pc.exclude(["lifetime"]),count:dc}),_d=ie.strictObject({action:ie.literal("create"),requestId:ie.uuid(),internal_feature_id:ie.uuid(),entityId:ie.uuid().nullable(),amount:fc.nullable(),expiresAt:Zt.nullable(),reset:Ac.nullable(),rollover:zr.nullable(),nextResetAt:Zt.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"),hc=ie.discriminatedUnion("action",[_d,ie.strictObject({action:ie.literal("update"),requestId:ie.uuid(),grantId:ie.uuid(),revision:ie.number().int().nonnegative(),amount:fc.nullable(),expiresAt:Zt.nullable(),rollover:zr.nullable(),nextResetAt:Zt.nullable()}),ie.strictObject({action:ie.enum(["add","subtract","set_remaining"]),requestId:ie.uuid(),grantId:ie.uuid(),revision:ie.number().int().nonnegative(),amount:Oe}),ie.strictObject({action:ie.literal("revoke"),requestId:ie.uuid(),grantId:ie.uuid(),revision:ie.number().int().nonnegative()})]),Wi=ie.strictObject({id:ie.uuid(),internal_feature_id:ie.uuid(),entityId:ie.uuid().nullable(),amount:Oe.nullable(),reset:Ac.nullable(),rollover:zr.nullable(),nextResetAt:Zt.nullable(),startsAt:Zt,expiresAt:Zt.nullable(),revision:ie.number().int().nonnegative(),revoked:ie.boolean(),available:lt,held:lt,spent:lt}),gc=ie.strictObject({customerId:ie.uuid(),after:ie.uuid().nullable(),limit:ie.number().int().min(1).max(100)}),bc=ie.strictObject({rows:ie.array(Wi).max(100),nextCursor:ie.uuid().nullable()});import{z as N}from"zod";var bt=N.iso.datetime({offset:!0}),yc=N.strictObject({invoiceId:N.uuid(),after:N.string().min(1).max(180).nullable(),limit:N.number().int().min(1).max(100)}),Pd=N.strictObject({kind:N.literal("product"),key:N.string(),productVersionId:N.uuid(),productName:N.string(),itemKey:N.string(),entityId:N.uuid().nullable(),quantity:N.number().positive(),subtotalMinor:N.string().regex(/^-?\d+$/),discountMinor:N.string().regex(/^\d+$/),taxMinor:N.string().regex(/^-?\d+$/).nullable(),totalMinor:N.string().regex(/^-?\d+$/),startsAt:bt.nullable(),endsAt:bt.nullable(),providerLineId:N.string().nullable(),providerItemId:N.string()}),xc=N.strictObject({invoice:Kn,items:N.array(N.discriminatedUnion("kind",[Pd,N.strictObject({kind:N.literal("invoice_credit"),key:N.string(),internal_feature_id:N.uuid(),internal_credit_feature_id:N.uuid(),name:N.string(),units:Oe,reserved:Oe,amountMinor:gn,grossAmountMinor:gn,creditsAppliedMinor:gn,properties:It,cashPrice:Gn,providerItemId:N.string().nullable(),creditProviderItemId:N.string().nullable()}),N.strictObject({kind:N.literal("usage"),key:N.string(),internal_feature_id:N.uuid(),name:N.string(),units:Oe,reserved:Oe,amountMinor:gn,cashPrice:Gn})])).max(100),nextCursor:N.string().min(1).max(180).nullable()}),Cd=N.string().regex(/^-?(0|[1-9]\d{0,17})(\.\d{1,12})?$/).refine(e=>!/^\-0(?:\.0+)?$/.test(e)),Xi=N.strictObject({from:bt,to:bt,entityId:N.uuid().optional(),snapshotAt:bt.nullable(),after:N.strictObject({at:bt,id:N.uuid(),position:N.number().int().nonnegative()}).nullable(),limit:N.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"),Sc=N.strictObject({customerId:N.uuid(),entityId:N.uuid().nullable(),from:bt,to:bt,snapshotAt:bt,totals:N.array(N.strictObject({internal_credit_feature_id:N.uuid(),name:N.string(),consumed:lt,refunded:lt,net:Cd})).max(1e3),rows:N.array(N.strictObject({operationId:N.uuid(),position:N.number().int().nonnegative(),kind:N.enum(["consume","confirm","refund"]),originalId:N.uuid().nullable(),occurredAt:bt,internal_feature_id:N.uuid(),entitlementName:N.string(),sourceId:N.uuid(),internal_credit_feature_id:N.uuid(),creditName:N.string(),units:za,amount:lt,pricing:N.array(qa).max(12),properties:It})).max(100),nextCursor:Xi.shape.after});import{z as G}from"zod";var Ic=G.object({customerId:G.uuid()}).strict(),Oc=G.discriminatedUnion("action",[G.object({customerId:G.uuid(),requestId:G.uuid(),action:G.literal("assign"),poolId:G.uuid(),memberCustomerId:G.uuid()}).strict(),G.strictObject({customerId:G.uuid(),requestId:G.uuid(),action:G.literal("assign_entity"),poolId:G.uuid(),entityId:G.uuid()}),G.object({customerId:G.uuid(),requestId:G.uuid(),action:G.literal("release"),poolId:G.uuid(),slotId:G.uuid()}).strict()]),Zn=G.number().int().nonnegative(),Yi=G.iso.datetime({offset:!0}),eo=G.strictObject({internalId:G.uuid(),id:G.string(),name:G.string().nullable(),version:G.number().int().positive()}),vc=G.enum(["active","past_due"]),to=G.strictObject({customerId:G.uuid(),licenses:G.array(G.strictObject({id:G.uuid(),linkId:G.uuid(),parent:G.strictObject({customerProductId:G.uuid(),status:vc,product:eo}),product:eo,planLicense:G.strictObject({id:G.uuid(),prepaidOnly:G.boolean(),isCustom:G.boolean()}).nullable(),granted:Zn,included:Zn,paidQuantity:Zn,usage:Zn,remaining:Zn,createdAt:Yi}).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:G.array(G.strictObject({id:G.uuid(),linkId:G.uuid(),status:vc,product:eo,entity:G.strictObject({internalId:G.uuid(),id:G.string().nullable(),name:G.string().nullable()}).nullable(),beneficiary:G.strictObject({internalId:G.uuid(),id:G.string().nullable(),name:G.string().nullable()}).nullable(),startedAt:Yi.nullable(),endedAt:Yi.nullable()}).refine(e=>e.entity!==null||e.beneficiary!==null,"A seat assignment has a holder")).max(1e4),limited:G.boolean()});import{z as $}from"zod";var Qn=$.enum(["email","sms","voice","push"]),hb=$.enum(["resend","twilio","fcm","apns"]);var gb=$.string().regex(/^\+[1-9]\d{1,14}$/),kd=$.enum(["email_recipient","sms_segment","voice_second","push_device"]);var Rd=$.string().trim().min(1).max(200).refine(e=>!/[\r\n\0]/.test(e),"Invalid email header"),Ed=$.strictObject({subject:Rd,html:$.string().min(1).max(131072).optional(),text:$.string().min(1).max(65536).optional()}).refine(e=>e.html!==void 0||e.text!==void 0,{message:"Email requires HTML or text content"}),Dd=$.strictObject({body:$.string().min(1).max(1600).refine(e=>e.trim().length>0)}),Td=$.strictObject({text:$.string().trim().min(1).max(4e3),language:$.string().regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(35),maxDurationSeconds:$.number().int().min(1).max(900)}),Md=$.record($.string().min(1).max(64),$.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"),Bd=$.strictObject({title:$.string().trim().min(1).max(200),body:$.string().trim().min(1).max(2e3),url:$.url().max(2048).refine(e=>!/^(?:javascript|data|file|vbscript):/i.test(e)).optional(),data:Md.optional()}).refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=3072,"Push content exceeds the provider payload budget"),wc=$.discriminatedUnion("channel",[$.strictObject({channel:$.literal("email"),content:Ed}),$.strictObject({channel:$.literal("sms"),content:Dd}),$.strictObject({channel:$.literal("voice"),content:Td}),$.strictObject({channel:$.literal("push"),content:Bd})]),jc=$.strictObject({requestId:$.uuid(),customerId:$.uuid(),connectionId:$.uuid().optional(),message:wc,expiresAt:$.iso.datetime({offset:!0})}),qd=$.array($.uuid()).min(1).max(1e4).refine(e=>new Set(e).size===e.length,"Duplicate Customer"),zd=$.discriminatedUnion("kind",[$.strictObject({kind:$.literal("all")}),$.strictObject({kind:$.literal("customers"),customerIds:qd})]),bb=$.strictObject({name:$.string().trim().min(1).max(120),connectionId:$.uuid().optional(),message:wc,audience:zd,frequencyLimit:$.number().int().min(1).max(100)}),_c=$.strictObject({requestId:$.uuid(),channel:Qn,state:$.enum(["allowed","denied"]),expectedRevision:$.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)}),Pc=$.enum(["queued","leased","dispatching","accepted","unknown","retry","skipped","failed","canceled"]),Cc=$.enum(["accepted","sent","delivered","delayed","bounced","complained","unsubscribed","opened","clicked","ringing","answered","completed","busy","no_answer","failed","cost_finalized"]),yb=$.strictObject({meter:kd,estimatedUnits:$.string().regex(/^(0|[1-9]\d{0,11})$/),observedUnits:$.string().regex(/^(0|[1-9]\d{0,11})$/).nullable()});import{z as kc}from"zod";var bn={funnelId:kc.uuid().optional(),funnelVersionId:kc.uuid().optional()};import{z as we}from"zod";import{z as ue}from"zod";import{z as ye}from"zod";var Ob=ye.discriminatedUnion("action",[ye.strictObject({action:ye.literal("create"),couponId:ye.uuid(),productBindingId:ye.uuid(),storeOfferId:ye.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),storeOfferType:ye.enum(["introductory","promotional"])}),ye.strictObject({action:ye.literal("set_enabled"),id:ye.uuid(),revision:ye.number().int().nonnegative(),enabled:ye.boolean()})]),wb=ye.array(ye.strictObject({id:ye.uuid(),couponId:ye.uuid(),productBindingId:ye.uuid(),storeOfferId:ye.string().min(1).max(255).nullable(),storeOfferType:ye.enum(["introductory","promotional"]),enabled:ye.boolean(),revision:ye.number().int().nonnegative()})).max(500),yn=ye.strictObject({offerKind:ye.enum(["none","introductory","promotional"]),offerId:ye.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),discountMinor:ye.number().int().min(0).max(1e8),trialDays:ye.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=ye.record(ye.uuid(),yn).refine(e=>Object.keys(e).length<=20,"At most 20 native store selections");var no=ue.object({type:ue.literal("native_purchase"),receiptId:ue.uuid(),orderId:ue.uuid(),productVersionId:ue.uuid(),provider:ue.enum(["apple","google"]),productId:ue.string().min(1).max(255),productKind:Ka,replacement:ue.strictObject({sourceOrderId:ue.uuid(),sourceProductId:ue.string().min(1).max(255),policy:ue.enum(["apple_store","google_full_price"]),sourceAccountTokens:ue.array(ue.uuid()).max(50)}).nullable(),appAccountToken:ue.uuid().optional(),obfuscatedAccountId:ue.string().min(1).max(64).optional(),obfuscatedProfileId:ue.uuid().optional(),basePlanId:ue.string().min(1).max(255).optional(),offerId:ue.string().min(1).max(255).optional(),offerKind:ue.enum(["none","introductory","promotional"]),currency:ae,catalogAmountMinor:ue.number().int().nonnegative().max(1e8),discountMinor:ue.number().int().nonnegative().max(1e8),trialDays:ue.number().int().min(1).max(730).nullable(),seatBundle:ue.array(ue.strictObject({key:ue.string().regex(/^[a-z][a-z0-9_]{0,63}$/),quantity:ue.number().int().min(1).max(1e4)})).max(20),applePromotionalOffer:ue.strictObject({offerId:ue.string().min(1).max(255),keyId:ue.string().min(1).max(255),nonce:ue.uuid(),signature:ue.string().min(1).max(1024),timestamp:ue.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(i=>i.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 s}from"zod";import{z as Y}from"zod/v4";import{z as Nd}from"zod/v4";var Fd=Nd.registry(),{BillingInterval:Rc}=(()=>{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:Ud}=(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')."})})}))(Y),{withSpecDefault:Vd}=(e=>({withSpecDefault:({schema:n,defaultValue:r,description:i})=>(e.add(n,{description:i,default:r}),n)}))(Fd),{COMMON:Ec}={COMMON:["usd","eur","gbp","cad","aud","jpy","chf","cny","inr"]},{STRIPE_PRESENTMENT_CURRENCIES:Ld}={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:$d}=(e=>({COMMON_SET:new Set(e)}))(Ec),{hasNoDuplicateCurrencies:Dc}={hasNoDuplicateCurrencies:t=>{let n=new Set;for(let{currency:r}of t){let i=r.toLowerCase();if(n.has(i))return!1;n.add(i)}return!0}},{DUPLICATE_CURRENCY_MESSAGE:Tc}={DUPLICATE_CURRENCY_MESSAGE:"Each currency may appear at most once in additional_currencies."},{ApiStripePriceProcessorSchema:Gd}=(e=>({ApiStripePriceProcessorSchema:e.object({price_id:e.string().meta({description:"Stripe price ID. For prepaid with included > 0 this is the V2 price."})})}))(Y),{Infinite:Kd}={Infinite:"inf"},{TierBehavior:Hd}=(()=>{var e;return(function(t){t.Graduated="graduated",t.VolumeBased="volume"})(e||(e={})),{TierBehavior:e}})(),{BillingMethod:Mc}=(()=>{var e;return(function(t){t.Prepaid="prepaid",t.UsageBased="usage_based"})(e||(e={})),{BillingMethod:e}})(),{AllocatedBilling:Zd}=(()=>{var e;return(function(t){t.Arrear="arrear",t.ProratedLegacy="prorated_legacy"})(e||(e={})),{AllocatedBilling:e}})(),{CREDIT_DIMENSION_NAME_MAX_LENGTH:Qd}={CREDIT_DIMENSION_NAME_MAX_LENGTH:64},{USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:Jd}={USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:"::"},{CreditMatchSchema:Wd}=(e=>({CreditMatchSchema:e.record(e.string(),e.union([e.string(),e.number(),e.boolean()]).transform(String).pipe(e.string()))}))(Y),{ApiCreditTierSchema:Bc}=(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."})})}))(Y),{VIOLATION_MESSAGES:Xd}={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:qc}=(e=>({MarkupEntrySchema:e.object({markup:e.number().min(-100)})}))(Y),{ModelMarkupsSchema:Yd}=((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()}))(Y,qc),{InvoiceUsageEntrySchema:em}=(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()}))(Y),{AttachDiscountSchema:zc}=(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."})}))(Y),{CustomLineItemSchema:tm}=(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."})})}))(Y),{UnixMsTimestampSchema:nm}=(e=>({UnixMsTimestampSchema:e.number().int().safe().nonnegative()}))(Y),{CreateInvoicePreviewLineSchema:rm}=(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()})}))(Y),{ReissueInvoiceParamsSchema:ro}=(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."})})}))(Y),{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."})}))(Y),{InvoiceTemplateSchema:im}=(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."})})}))(Y),{BasePriceSchema:om}=((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."})})}))(Y,Rc,Ud),{CURRENCY_CODES:am}=((e,t,n)=>({CURRENCY_CODES:[...e,...t.filter(i=>!n.has(i)).sort()]}))(Ec,Ld,$d),{ApiPriceProcessorsSchema:Nc}=((e,t)=>({ApiPriceProcessorsSchema:e.object({stripe:t.nullish()}).meta({"x-atmn-mapping":!0})}))(Y,Gd),{AllocatedBillingFieldSchema:sm}=((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'."})}))(Y,Zd),{CreditDimensionNameSchema:cm}=((e,t,n)=>({CreditDimensionNameSchema:e.string().min(1).max(t).refine(i=>!i.includes(n),{message:`Dimension names cannot contain "${n}"`})}))(Y,Qd,Jd),{ApiCreditMatchSchema:Fc}=(e=>({ApiCreditMatchSchema:e.meta({description:"Event properties this entry applies to. Every key must equal the tracked property, compared as strings."})}))(Wd),{findCreditTierViolations:um}=(e=>({findCreditTierViolations:n=>{let r=[],i=(a,c)=>r.push({index:a,reason:c,message:e[c]}),o=0;for(let[a,c]of n.entries()){let u=a===n.length-1;if(c==="inf"){u||i(a,"non_final_infinity");continue}(!Number.isFinite(c)||c<=o)&&i(a,"not_increasing"),o=c,u&&i(a,"final_not_infinity")}return r}}))(Xd),{ApiCreditMultiplierSchema:lm}=((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."})}))(Y,Fc),{ProviderMarkupsSchema:pm}=((e,t)=>({ProviderMarkupsSchema:e.record(e.string(),t).nullish()}))(Y,qc),{InvoiceFeatureQuantitySchema:Uc}=((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(i=>i.quantity!==void 0!=(i.usage!==void 0),{message:"Provide exactly one of quantity or usage."})}))(Y,Mc,em),{CreateInvoicePreviewSchema:io}=((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()})}))(Y,rm),{SUPPORTED_SET:dm}=(e=>({SUPPORTED_SET:new Set(e)}))(am),{ApiCreditDimensionBaseSchema:mm}=((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."})})}))(Y,Fc),{refineGraduatedTiers:Vc}=(e=>({refineGraduatedTiers:(n,r)=>{let i=e(n.tiers.map(o=>o.to));for(let{index:o,message:a}of i)r.addIssue({code:"custom",message:a,path:["tiers",o,"to"]})}}))(um),{ApiFeatureMarkupsOverrideSchema:fm}=((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."})})}))(Y,pm,Yd),{isValidCurrencyCode:Am}=(e=>({isValidCurrencyCode:n=>!!n&&e.has(n.toLowerCase())}))(dm),{ApiCreditDimensionSchema:hm}=((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()])}))(Y,mm,Bc,Vc),{CurrencyCodeSchema:Lc}=((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')."})}))(Y,Am),{AdditionalCurrencyTierSchema:gm}=((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"]})}))(Y,Lc),{ApiCreditSchemaItemBaseSchema:$c}=((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."})})}))(Y,cm,hm,lm),{ApiFlatCreditSchemaItemSchema:bm}=((e,t)=>({ApiFlatCreditSchemaItemSchema:e.extend({credit_cost:t.number().min(0).meta({description:"Credits consumed per billing-unit group."})}).strict()}))($c,Y),{AdditionalCurrencyPriceSchema:ym}=((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."})})}))(Y,Lc),{AdditionalCurrencyTierArraySchema:xm}=((e,t,n,r)=>({AdditionalCurrencyTierArraySchema:e.array(t).refine(n,{message:r})}))(Y,gm,Dc,Tc),{ApiGraduatedCreditSchemaItemSchema:Sm}=((e,t,n,r)=>({ApiGraduatedCreditSchemaItemSchema:e.extend({tier_behavior:t.literal("graduated"),tiers:t.array(n).min(1)}).strict().superRefine(r)}))($c,Y,Bc,Vc),{AdditionalCurrencyPriceArraySchema:Gc}=((e,t,n,r)=>({AdditionalCurrencyPriceArraySchema:e.array(t).refine(n,{message:r})}))(Y,ym,Dc,Tc),{ApiUsageTierWithCurrenciesSchema:vm}=((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(i=>i.amount!==void 0||i.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]}).transform(i=>({...i,amount:i.amount??0})).pipe(e.object({to:e.number().or(e.literal(t)),amount:e.number(),flat_amount:e.number().optional(),additional_currencies:n.optional()}))}))(Y,Kd,xm),{ApiCreditSchemaItemSchema:Im}=((e,t,n)=>({ApiCreditSchemaItemSchema:e.union([t,n])}))(Y,Sm,bm),{BasePriceParamsSchema:Om}=((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."})}))(om,Vd,Y,Gc),{PlanItemPriceParamsSchema:wm}=((e,t,n,r,i,o,a)=>({PlanItemPriceParamsSchema:e.object({stripe_price_id:e.string().nullish().transform(u=>u??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(i).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(o).meta({description:"'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go."}),allocated_billing:a,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."})})}))(Y,Gc,vm,Hd,Rc,Mc,sm),{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."})})}))(Y,Im,fm),{InvoiceBasePriceParamsSchema:Kc}=((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()}))(Om,Nc),{InvoiceItemPriceParamsSchema:_m}=((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()}))(wm,Nc),{InvoiceLicenseQuantitySchema:Pm}=((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()}))(Y,Kc,Uc),{InvoiceCustomizeItemSchema:Cm}=((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()}))(Y,_m,jm),{InvoiceCustomizeSchema:km}=((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."})}))(Y,Kc,Cm),{InvoicePlanParamsSchema:Rm}=((e,t,n,r,i)=>({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(i).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()}))(Y,km,Uc,Pm,zc),{CreateInvoiceParamsSchema:xn}=((e,t,n,r,i)=>({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:i.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:i.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(a=>a.period_start===void 0==(a.period_end===void 0),{message:"period_start and period_end must be provided together."}).refine(a=>a.period_start===void 0||a.period_end===void 0||a.period_end>a.period_start,{message:"period_end must be after period_start."})}))(Y,Rm,tm,zc,nm);var Qc=s.strictObject({requestId:s.uuid(),predecessorOperationId:s.uuid().optional(),invoiceMode:Qt.optional(),entityId:s.uuid().optional(),billingSubscriptionId:s.uuid().optional(),newBillingSubscription:s.literal(!0).optional(),offerId:s.uuid().optional(),nativeOffer:yn.optional(),plans:s.array(s.strictObject({productVersionId:s.uuid(),seatQuantities:s.record(Er,s.number().int().min(0).max(1e4)).optional(),featureQuantities:s.record(s.uuid(),s.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:s.enum(["stripe","apple","google"]),currency:ae}).refine(e=>!e.offerId||!e.billingSubscriptionId&&(e.provider==="stripe"||e.nativeOffer!==void 0),"Held offers apply to new purchases; existing subscriptions use billing coupons").refine(e=>!e.nativeOffer||e.provider!=="stripe"&&e.plans.length===1,"A store selection applies to exactly one native SKU").refine(e=>!e.newBillingSubscription||e.provider==="stripe"&&!e.billingSubscriptionId,"A new billing subscription requires Stripe and no existing subscription target").refine(e=>!e.invoiceMode?.enabled||e.provider==="stripe"&&!e.entityId,"Invoice mode requires a Stripe subscription without an Entity target"),Wt=s.strictObject({operationId:s.uuid()}),ze=s.number().int().min(0).max(1e8),Em=s.strictObject({lineId:s.uuid(),productVersionId:s.uuid(),productName:s.string().min(1).max(80),interval:s.enum(["free","week","month","year","one_time"]),intervalCount:s.number().int().min(1).max(156).optional(),baseAmountMinor:ze,seats:s.array(s.strictObject({key:Er,quantity:s.number().int().min(0).max(1e4),includedQuantity:s.number().int().min(0).max(1e4),maximumQuantity:s.number().int().min(0).max(1e4),unitAmountMinor:ze})).max(20),prepaid:s.array(mc).max(100).optional(),catalogAmountMinor:ze,trial:s.strictObject({days:s.number().int().min(1).max(730),cardRequired:s.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+hr({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"),Jc=s.string().regex(/^[A-Za-z0-9_-]{1,200}$/),Dm=s.strictObject({id:Jc,name:s.string().min(1).max(40),percent_off:s.number().gt(0).max(100).optional(),amount_off:s.number().int().positive().optional(),currency:s.string().regex(/^[a-z]{3}$/).optional(),duration:s.enum(["once","repeating","forever"]),duration_in_months:s.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"),Tm=s.strictObject({subscriptionId:s.string().regex(/^sub_[A-Za-z0-9]+$/),customerId:s.string().regex(/^cus_[A-Za-z0-9]+$/),sourceItems:s.array(s.strictObject({id:s.string(),price_id:s.string(),quantity:s.number().int().nonnegative(),discounts:s.array(s.strictObject({id:s.string(),coupon:s.string(),start:s.number(),end:s.number().nullable()})).optional()})).min(1).max(100),prorationDate:s.number().int().nonnegative(),amountMinor:s.number().int().positive(),periodStartMs:s.number(),periodEndMs:s.number()}),Wc=s.strictObject({invoiceMode:Qt.optional(),append:Tm.optional(),provider:s.literal("stripe"),executor:s.enum(["indiana","merchant"]),accountId:s.string().regex(/^acct_[A-Za-z0-9]+$/),mode:s.enum(["payment","subscription"]),lineItems:s.array(s.strictObject({price:s.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),quantity:s.number().int().min(1).max(1e4),priceId:s.uuid(),productName:s.string().min(1).max(80),amountMinor:s.number().int().min(0).max(1e8),currency:s.string().regex(/^[a-z]{3}$/),interval:s.enum(["week","month","year","one_off"]),intervalCount:s.number().int().min(1).max(52),slot:s.enum(["stripe_price_id","stripe_empty_price_id"]),tiers:s.strictObject({mode:s.enum(["graduated","volume"]),tiers:s.array(s.strictObject({upTo:s.number().int().min(1).max(1e6).nullable(),unitAmountMinor:s.number().int().min(0).max(1e8),flatAmountMinor:s.number().int().min(0).max(1e8).optional()})).min(2).max(12)}).nullable()})).min(1).max(100),discounts:s.array(s.strictObject({coupon:Jc,terms:Dm})).max(1),trialPeriodDays:s.number().int().min(1).max(730).nullable(),metadata:s.strictObject({grooveCheckoutId:s.uuid(),grooveCustomerId:s.uuid()}),expiresAt:s.iso.datetime({offset:!0})}),Jn=s.strictObject({operationId:s.uuid(),entityId:s.uuid().nullable(),billingSubscriptionId:s.uuid().nullable(),discount:s.strictObject({offerId:s.uuid(),couponId:s.uuid(),discount:Bt,duration:nt,amountMinor:ze,allocations:s.array(s.strictObject({productVersionId:s.uuid(),amountMinor:ze})).min(1).max(20),expiresAt:s.iso.datetime({offset:!0})}).nullable(),charge:s.strictObject({effectiveAt:s.iso.datetime({offset:!0}),periodEndsAt:s.iso.datetime({offset:!0}),debitMinor:ze,discountMinor:ze,taxMinor:ze,totalMinor:ze}).nullable(),expiresAt:s.iso.datetime({offset:!0}),provider:s.enum(["stripe","apple","google"]),nativeOffer:yn.optional(),currency:ae,lines:s.array(Em).min(1).max(20),catalogAmountMinor:ze,automaticTax:s.boolean(),execution:Wc.nullable()}).refine(e=>e.provider==="stripe"?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&&(e.provider==="stripe"||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)&&(e.provider==="stripe"?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"),Sn=s.strictObject({operationId:s.uuid(),orderId:s.uuid(),append:s.boolean().optional(),invoiceMode:s.boolean().optional(),status:s.enum(["pending","complete","cancelled","failed"]),executor:s.enum(["indiana","merchant"]),checkoutUrl:s.url().refine(e=>new URL(e).protocol==="https:").nullable(),execution:Wc.nullable(),currency:ae,catalogAmountMinor:ze,taxMinor:ze,totalMinor:s.number().int().min(0).max(2e8).nullable(),quoteFinalized:s.boolean(),nativePurchase:no.nullable()}).refine(e=>(e.checkoutUrl===null||e.executor==="indiana")&&(e.execution===null||e.executor==="merchant"),"Only Indiana-executed purchases carry a Checkout URL and only record-only purchases carry execution instructions"),Fr=s.strictObject({enabled:s.literal(!0),featureIds:s.array(s.uuid()).min(1).max(100).refine(e=>new Set(e).size===e.length,"Feature IDs must be unique").optional()}),Xc=s.strictObject({requestId:s.uuid(),invoiceMode:Qt.optional(),membershipId:s.uuid(),carryOverBalances:Fr.optional(),carryOverUsages:Fr.optional(),membershipIds:s.array(s.uuid()).min(1).max(20).optional(),prorationBehavior:s.enum(["prorate_immediately","none","bill_difference"]).optional(),timing:s.enum(["immediate","renewal","store"]),change:s.discriminatedUnion("type",[s.strictObject({type:s.literal("plan"),productVersionId:s.uuid()}),s.strictObject({type:s.literal("seats"),licenseKey:Er,quantity:s.number().int().min(0).max(1e4)}),s.strictObject({type:s.literal("quantity"),internal_feature_id:s.uuid(),quantity:s.number().int().min(0).max(1e4)}),s.strictObject({type:s.literal("cancel")}),s.strictObject({type:s.literal("uncancel")}),s.strictObject({type:s.literal("billing_cycle"),billingCycleAnchor:s.union([s.literal("now"),s.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"),Nr=s.string().regex(/^price_[A-Za-z0-9]+$/),Hc=s.strictObject({grooveUpdateId:s.uuid(),grooveCustomerId:s.uuid()}),Zc=s.strictObject({price:Nr.nullable(),priceId:s.uuid().optional(),quantity:s.number().int().min(0).max(1e4)}),Yc=s.strictObject({provider:s.literal("stripe"),invoiceMode:Qt.optional(),executor:s.enum(["indiana","merchant"]),accountId:s.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:s.string().regex(/^sub_[A-Za-z0-9]+$/),action:s.enum(["update","cancel","schedule","release"]),update:s.strictObject({items:s.array(Zc).max(20),remove:s.array(Nr).max(20),restoreItems:s.array(s.strictObject({price:Nr,quantity:s.number().int().min(0).max(1e4)})).min(1).max(20).optional(),prorationBehavior:s.enum(["always_invoice","create_prorations","none"]).optional(),prorationDate:s.number().int().positive().optional(),paymentBehavior:s.literal("error_if_incomplete").optional(),cancelAtPeriodEnd:s.boolean().optional(),clearCancelAt:s.literal(!0).optional(),billingCycleAnchorNow:s.literal(!0).optional(),metadata:Hc}).nullable(),cancel:s.strictObject({prorate:s.literal(!1),invoiceNow:s.literal(!1)}).nullable(),schedule:s.strictObject({currentItems:s.array(s.strictObject({price:Nr,quantity:s.number().int().min(0).max(1e4)})).max(20),nextItems:s.array(Zc).min(1).max(20),switchAt:s.number().int().positive(),interval:s.enum(["week","month","year"]),intervalCount:s.number().int().min(1).max(52),resetBillingCycleAnchor:s.literal(!0).optional(),metadata:Hc}).nullable(),release:s.strictObject({schedule:s.string().regex(/^sub_sched_[A-Za-z0-9]+$/)}).nullable(),expiresAt:s.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"),oo=s.strictObject({carryOverBalances:Fr.optional(),carryOverUsages:Fr.optional(),operationId:s.uuid(),membershipId:s.uuid(),productVersionId:s.uuid(),timing:s.enum(["immediate","renewal"]),effectiveAt:s.iso.datetime({offset:!0}),expiresAt:s.iso.datetime({offset:!0}),currency:ae,creditMinor:ze,debitMinor:ze,discountMinor:ze,taxMinor:ze,totalMinor:ze,retainedProductVersionIds:s.array(s.uuid()).max(19),execution:Yc}),Mm=s.strictObject({operationId:s.uuid(),invoiceMode:s.boolean().optional(),membershipId:s.uuid(),productVersionId:s.uuid(),status:s.enum(["prepared","quoted","confirmed","pending","scheduled","effective","cancelled","failed"]),timing:s.enum(["immediate","renewal"]),effectiveAt:s.iso.datetime({offset:!0}),checkoutUrl:s.url().refine(e=>new URL(e).protocol==="https:").nullable(),executor:s.enum(["indiana","merchant"]),execution:Yc.nullable()}).refine(e=>e.execution===null||e.executor==="merchant","Only record-only changes carry execution instructions"),Bm=s.strictObject({operationId:s.uuid(),membershipId:s.uuid(),productVersionId:s.uuid(),timing:s.literal("store"),effectiveAt:s.null(),expiresAt:s.iso.datetime({offset:!0}),currency:ae,creditMinor:s.null(),debitMinor:s.null(),discountMinor:s.null(),taxMinor:s.null(),totalMinor:s.null(),retainedProductVersionIds:s.array(s.uuid()).max(19),store:s.strictObject({provider:s.enum(["apple","google"]),productId:s.string().min(1).max(255),catalogAmountMinor:ze,policy:s.enum(["apple_store","google_full_price"])})}),qm=s.strictObject({operationId:s.uuid(),membershipId:s.uuid(),productVersionId:s.uuid(),status:s.enum(["prepared","pending","effective","cancelled","failed"]),timing:s.literal("store"),effectiveAt:s.iso.datetime({offset:!0}).nullable(),checkoutUrl:s.null(),nativePurchase:no.nullable()}),eu=s.union([oo,Bm]),ao=s.union([Mm,qm]),Wn=s.number().int().positive().max(2e8),Jt=s.number().int().min(0).max(2e8),tu=s.strictObject({requestId:s.uuid(),invoiceId:s.uuid(),mode:s.enum(["full","partial"]),amountMinor:Wn.optional(),entitlementAction:s.enum(["retain","revoke"])}).refine(e=>e.mode==="partial"==(e.amountMinor!==void 0),"A partial refund states amountMinor; a full refund refunds the remaining amount"),nu=s.strictObject({provider:s.literal("stripe"),executor:s.enum(["indiana","merchant"]),accountId:s.string().regex(/^acct_[A-Za-z0-9]+$/),invoice:s.string().regex(/^in_[A-Za-z0-9]+$/),amountMinor:Wn,currency:s.string().regex(/^[a-z]{3}$/),metadata:s.strictObject({indianaRefundId:s.uuid()}),idempotencyKey:s.string().regex(/^indiana-refund-[0-9a-f-]{36}$/),cancelSubscriptions:s.array(s.string().regex(/^sub_[A-Za-z0-9]+$/)).max(20)}),ru=s.strictObject({operationId:s.uuid(),invoiceId:s.uuid(),providerInvoiceId:s.string().regex(/^in_[A-Za-z0-9]+$/),currency:ae,paidMinor:Jt,refundedMinor:Jt,pendingMinor:Jt,amountMinor:Wn,mode:s.enum(["full","partial"]),entitlementAction:s.enum(["retain","revoke"]),revokes:s.strictObject({customerProductIds:s.array(s.uuid()).max(100),subscriptionIds:s.array(s.string().regex(/^sub_[A-Za-z0-9]+$/)).max(20)}),execution:nu,expiresAt:s.iso.datetime({offset:!0})}).refine(e=>e.amountMinor<=e.paidMinor-e.refundedMinor-e.pendingMinor&&e.execution.amountMinor===e.amountMinor&&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"),Ur=s.strictObject({operationId:s.uuid(),invoiceId:s.uuid(),providerInvoiceId:s.string().regex(/^in_[A-Za-z0-9]+$/),status:s.enum(["quoted","pending","succeeded","failed","expired"]),executor:s.enum(["indiana","merchant"]),currency:ae,amountMinor:Wn,mode:s.enum(["full","partial"]),entitlementAction:s.enum(["retain","revoke"]),refundId:s.string().regex(/^(re|pyr)_[A-Za-z0-9]+$/).nullable(),execution:nu.nullable(),failureReason:s.string().min(1).max(200).nullable(),createdAt:s.iso.datetime({offset:!0}),completedAt:s.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"),$b=s.strictObject({invoiceId:s.uuid(),currency:ae,paidMinor:Jt,refundedMinor:Jt,pendingMinor:Jt,refundableMinor:Jt,executor:s.enum(["indiana","merchant"]).nullable(),canRefund:s.boolean(),operations:s.array(Ur).max(50)}).refine(e=>e.operations.every(t=>t.invoiceId===e.invoiceId),"Refund operations belong to the invoice"),Gb=s.strictObject({requestId:s.uuid(),mode:s.enum(["full","partial"]),amountMinor:Wn.optional(),entitlementAction:s.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 iu=we.strictObject({requestId:we.uuid(),targets:we.array(we.strictObject({membershipId:we.uuid(),action:we.enum(["cancel","uncancel"]),timing:we.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"),Vr=we.strictObject({batchId:we.uuid()}),zm=we.strictObject({operationId:we.uuid(),membershipIds:we.array(we.uuid()).min(1).max(20),provider:we.enum(["stripe","apple","google"]),action:we.enum(["cancel","uncancel"]),timing:we.enum(["immediate","renewal"]),status:we.enum(["prepared","confirmed","pending","scheduled","effective","cancelled","failed","store_action_required"]),quote:oo.nullable(),managementUrl:we.url().nullable(),failureCode:we.enum(["provider_unavailable","invalid_evidence","pending_payment"]).nullable()}),Xn=we.strictObject({batchId:we.uuid(),ready:we.boolean(),status:we.enum(["prepared","cancelled","expired","pending","partial","effective","action_required"]),createdAt:we.iso.datetime({offset:!0}),acceptedAt:we.iso.datetime({offset:!0}).nullable(),groups:we.array(zm).min(1).max(100)});import{z as ne}from"zod";var Nm=ne.string().trim().min(1).max(240),so={requestId:ne.uuid(),reason:Nm},Lr=ne.discriminatedUnion("action",[ne.strictObject({...so,action:ne.literal("start"),productVersionId:ne.uuid(),entityId:ne.uuid().optional(),days:ne.number().int().min(1).max(730).optional()}),ne.strictObject({...so,action:ne.literal("extend"),membershipId:ne.uuid(),days:ne.number().int().min(1).max(730)}),ne.strictObject({...so,action:ne.literal("end"),membershipId:ne.uuid()})]),ou=ne.strictObject({operationId:ne.uuid()}),au=ne.iso.datetime({offset:!0}),Fm=ne.strictObject({provider:ne.literal("stripe"),executor:ne.enum(["indiana","merchant"]),accountId:ne.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:ne.string().regex(/^sub_[A-Za-z0-9]+$/),trialEnd:ne.union([ne.literal("now"),au]),prorationBehavior:ne.literal("none")}),co=ne.strictObject({operationId:ne.uuid(),action:ne.enum(["start","extend","end"]),status:ne.enum(["pending","effective"]),managedBy:ne.enum(["indiana","stripe"]),membershipIds:ne.array(ne.uuid()).min(1).max(20),endsAt:au.nullable(),execution:Fm.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"),Wb=ne.strictObject({groupId:ne.uuid(),productVersionId:ne.uuid(),enabled:ne.boolean()});import{z as ge}from"zod";var su=ge.strictObject({requestId:ge.uuid(),currency:ae,makeDefault:ge.boolean()}),cu=ge.strictObject({setupId:ge.uuid()}),Um=ge.strictObject({provider:ge.literal("stripe"),executor:ge.literal("merchant"),accountId:ge.string().regex(/^acct_[A-Za-z0-9]+$/),mode:ge.literal("setup"),currency:ge.string().regex(/^[a-z]{3}$/),customer:ge.string().regex(/^cus_[A-Za-z0-9]+$/).nullable(),clientReferenceId:ge.uuid(),metadata:ge.strictObject({grooveProjectId:ge.uuid(),grooveEnvironmentId:ge.uuid(),grooveCustomerId:ge.uuid(),groovePaymentSetupId:ge.uuid()}),setDefaultPaymentMethod:ge.boolean(),expiresAt:ge.iso.datetime({offset:!0})}),uo=ge.strictObject({id:ge.uuid(),provider:ge.literal("stripe"),status:ge.enum(["prepared","complete","expired"]),currency:ae,makeDefault:ge.boolean(),url:ge.url().nullable(),createdAt:ge.iso.datetime({offset:!0}),expiresAt:ge.iso.datetime({offset:!0}),completedAt:ge.iso.datetime({offset:!0}).nullable(),execution:Um.nullable()});import{z as Ne}from"zod";var uu=Ne.union([Ne.string(),Ne.number(),Ne.boolean(),Ne.null()]),lu=Ne.strictObject({customerId:Ne.uuid()}),pu=Ne.strictObject({customerId:Ne.uuid(),provider:Ne.literal("stripe"),checkedAt:Ne.iso.datetime({offset:!0}),status:Ne.enum(["consistent","drifted","incomplete"]),checkedSubscriptions:Ne.number().int().nonnegative(),differences:Ne.array(Ne.strictObject({subscriptionId:Ne.string().startsWith("sub_"),itemId:Ne.string().nullable(),field:Ne.enum(["subscription","status","currency","cancelAtPeriodEnd","item","price","product","quantity","periodStart","periodEnd","trialEnd","evidence"]),expected:uu,actual:uu})).max(1e4)});import{z as Z}from"zod";var $r=Z.iso.datetime({offset:!0}),Gr=Z.strictObject({createdAt:$r,id:Z.uuid()}),Kr=Z.strictObject({customerId:Z.uuid().optional(),entityId:Z.uuid().optional(),productId:Z.string().min(1).max(256).optional(),provider:Z.enum(["stripe","apple","google","free"]).optional(),status:Z.enum(["trial","active","past_due","ended","refunded"]).optional(),cursor:Gr.optional(),limit:Z.number().int().min(1).max(100).optional()}),lo={id:Z.uuid(),customerId:Z.uuid(),entityId:Z.uuid().nullable(),productId:Z.string().min(1).max(256),productVersionId:Z.uuid(),name:Z.string().min(1).max(120),provider:Z.enum(["stripe","apple","google","free"]),createdAt:$r},Vm=Z.strictObject({...lo,status:Z.enum(["trial","active","past_due","ended"]),cancelAtPeriodEnd:Z.boolean(),billingSubscriptionId:Z.uuid().nullable()}),Lm=Z.strictObject({...lo,status:Z.enum(["active","ended","refunded"]),orderId:Z.uuid().nullable(),transactionId:Z.uuid().nullable(),currency:ae.nullable(),amountMinor:Z.string().regex(/^(0|[1-9]\d{0,17})$/).nullable()}),$m=Z.strictObject({...lo,status:Z.enum(["blocked","resolved"]),conflict:Z.strictObject({detectedAt:$r,blockingMembershipIds:Z.array(Z.uuid()).min(1).max(100),transactionId:Z.uuid()}),resolvedAt:$r.nullable()}),du=Kr.extend({status:Z.enum(["blocked","resolved"]).optional()}),mu=Z.strictObject({customerId:Z.uuid(),orderId:Z.uuid()}),fu=Z.strictObject({orderId:Z.uuid(),status:Z.enum(["blocked","resolved"])}),Au=Z.strictObject({items:Z.array(Vm).max(100),nextCursor:Gr.nullable()}),hu=Z.strictObject({items:Z.array(Lm).max(100),nextCursor:Gr.nullable()}),gu=Z.strictObject({items:Z.array($m).max(100),nextCursor:Gr.nullable()});import{z as ve}from"zod";var bu=ve.union([ve.strictObject({intent:ve.literal("read"),requestId:ve.uuid(),purchaseIntentId:ve.uuid()}),ve.strictObject({requestId:ve.uuid(),provider:ve.literal("apple"),purchaseIntentId:ve.uuid(),productId:ve.string().min(1).max(255).optional(),signedTransaction:ve.string().min(1).max(131072)}),ve.strictObject({requestId:ve.uuid(),provider:ve.literal("google"),purchaseIntentId:ve.uuid(),productId:ve.string().min(1).max(255).optional(),purchaseToken:ve.string().min(1).max(16384)})]),yu=ve.strictObject({requestId:ve.uuid(),orderId:ve.uuid(),purchaseIntentId:ve.uuid(),status:ve.enum(["created","pending","trialing","paid","cancelled","failed"]),currency:ae,refunded:ve.boolean(),completion:ve.strictObject({transactionIds:ve.array(ve.string().min(1).max(255)).min(1).max(50).refine(e=>new Set(e).size===e.length),membership:ve.boolean()}).nullable()});import{z as w}from"zod";var mo=w.uuid().refine(e=>e===e.toLowerCase(),"Product references require canonical lowercase UUIDs"),Gm=w.record(w.string(),w.json()).refine(e=>Array.from(JSON.stringify(e)).length<=4e3,"Offering metadata exceeds 4000 characters"),Km=3,Yn=20,Hm=Km*Yn,po=w.strictObject({type:w.literal("product"),productId:mo}),xu={type:w.literal("group"),key:w.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),name:w.string().trim().min(1).max(80)},Zm=w.discriminatedUnion("type",[po,w.strictObject({...xu,items:w.array(po).max(Yn)})]),Qm=w.discriminatedUnion("type",[po,w.strictObject({...xu,items:w.array(Zm).max(Yn)})]),Jm=w.array(Qm).max(Yn).superRefine((e,t)=>{let n=new Set,r=new Set,i=0;function o(a){for(let c of a){i++;let u=c.type==="product"?n:r,p=c.type==="product"?c.productId:c.key;u.has(p)&&t.addIssue({code:"custom",message:c.type==="product"?"Duplicate Offering Product reference":"Duplicate Offering group key"}),u.add(p),c.type==="group"&&o(c.items)}}o(e),(n.size>Yn||i>Hm)&&t.addIssue({code:"custom",message:"Offering item limit exceeded"})});function fo(e){return e.items.flatMap(t=>t.type==="product"?[t.productId]:fo(t))}var vn=w.strictObject({lookupKey:w.string().trim().min(1).max(200),displayName:w.string().trim().min(1).max(1500),items:Jm,metadata:Gm}),Wm=w.strictObject({product:w.record(w.string(),w.json()),prices:w.array(w.record(w.string(),w.json())),entitlements:w.array(w.record(w.string(),w.json())),freeTrials:w.array(w.record(w.string(),w.json())),licenses:w.array(w.record(w.string(),w.json()))}),Su=vn.extend({id:w.uuid(),projectId:w.uuid(),environmentId:w.uuid(),state:w.enum(["active","archived"]),isCurrent:w.boolean(),revision:w.number().int().nonnegative(),publishedVersionId:w.uuid().nullable(),createdAt:w.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"})}),vu=w.strictObject({id:w.uuid(),offeringId:w.uuid(),projectId:w.uuid(),environmentId:w.uuid(),version:w.number().int().positive(),document:vn,productEvidence:w.record(mo,Wm),createdAt:w.iso.datetime({offset:!0})}).superRefine((e,t)=>{let n=fo(e.document);(!n.length||ef(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"})}),Xm=w.strictObject({rows:w.array(Su).max(200),versions:w.array(vu).max(500)}),py=w.discriminatedUnion("action",[w.strictObject({action:w.literal("create"),document:vn}),w.strictObject({action:w.literal("save"),id:w.uuid(),revision:w.number().int().nonnegative(),document:vn}),w.strictObject({action:w.enum(["publish","set_current","archive","restore"]),id:w.uuid(),revision:w.number().int().nonnegative()})]),dy=w.strictObject({record:Su,version:vu.nullable()}),Iu=w.discriminatedUnion("type",[w.strictObject({type:w.literal("current")}),w.strictObject({type:w.literal("id"),id:w.uuid()}),w.strictObject({type:w.literal("lookup_key"),lookupKey:w.string().min(1).max(200)}),w.strictObject({type:w.literal("version"),versionId:w.uuid()})]),Ym=w.strictObject({internalId:mo,id:w.string(),name:w.string().nullable(),version:w.number().int().positive(),archived:w.boolean()}),my=Xm.extend({products:w.array(Ym).max(500),pagination:w.strictObject({rows:w.string().nullable(),versions:w.string().nullable(),products:w.string().nullable()}).optional()});function ef(e){let t=[];fo(e).length||t.push("Select at least one Product before publishing");function n(r){for(let i of r)i.type==="group"&&(i.items.length||t.push("Every published group requires a Product"),n(i.items))}return n(e.items),t}import{z as Hr}from"zod";var Ou=Hr.strictObject({id:Hr.uuid(),offeringId:Hr.uuid(),version:Hr.number().int().positive(),document:vn});import{z as Te}from"zod";import{z as K}from"zod";import{z as De}from"zod";var tf=De.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Zr=De.discriminatedUnion("type",[De.object({type:De.literal("fixed"),productVersionId:De.string().min(1).max(200)}).strict(),De.object({type:De.literal("picker"),pickerId:tf,allowedProductVersionIds:De.array(De.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")]),jt=De.discriminatedUnion("type",[De.object({type:De.literal("modal"),size:De.enum(["sm","md","lg"])}).strict(),De.object({type:De.literal("sheet"),size:De.enum(["sm","md","lg"])}).strict(),De.object({type:De.literal("fullscreen")}).strict(),De.object({type:De.literal("inline")}).strict()]);var Ao=K.discriminatedUnion("type",[K.strictObject({type:K.literal("event"),event:K.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),K.strictObject({type:K.literal("open_url"),url:K.url().refine(e=>new URL(e).protocol==="https:")})]),nf=et,rf=K.discriminatedUnion("type",[K.object({type:K.literal("checkout"),product:Zr}).strict(),K.object({type:K.literal("close")}).strict(),K.object({type:K.literal("action"),action:Ao}).strict()]),In=K.object({schemaVersion:K.literal(3),kind:K.literal("paywall"),name:K.string().trim().min(1).max(80),presentation:jt,requirement:ln.optional(),products:Pr,offeringVersionId:K.uuid().nullable(),offeringId:K.uuid(),screen:nf,buttons:K.record(K.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),rf)}).strict(),_y=In.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 af(e))t.addIssue({code:"custom",message:r});for(let r of of(e))t.addIssue({code:"custom",message:r});Ct(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 of(e){let t=e.products.items.map(o=>o.productVersionId),n=Wa(e.screen),r=new Set,i=[];(!t.length||!e.products.defaultProductVersionId||!t.includes(e.products.defaultProductVersionId))&&i.push("products"),e.offeringVersionId||i.push("offering"),e.products.grouping&&(!Ya(e.products.grouping,t)||e.products.grouping.tiers.some(o=>!e.products.grouping.assignments.some(a=>a.tierId===o.id)))&&i.push("grouping");for(let o of Object.values(e.buttons))if(o.type==="checkout"){let a=o.product;if(a.type==="fixed")r.add(a.productVersionId);else{a.allowedProductVersionIds.forEach(p=>r.add(p));let c=!1,u=n[a.pickerId];u&&(c=!0,(a.allowedProductVersionIds.some(p=>!u.ids.includes(p))||u.ids.some(p=>!a.allowedProductVersionIds.includes(p)))&&i.push("picker")),Ot(e.screen,p=>{if(p.id!==a.pickerId||p.type!=="plan_picker")return;c=!0,(JSON.stringify(p.planIds)!==JSON.stringify(t)||JSON.stringify(a.allowedProductVersionIds)!==JSON.stringify(t)||p.defaultPlan!==e.products.defaultProductVersionId)&&i.push("picker");let b=p.grouping?{tiers:p.grouping.tiers,assignments:p.grouping.assignments}:void 0;JSON.stringify(b)!==JSON.stringify(e.products.grouping)&&i.push("grouping")}),c||i.push("picker")}}return(!r.size||[...r].some(o=>!t.includes(o)))&&i.push("purchase"),Ot(e.screen,o=>{o.type==="stack"&&o.productSlot&&!o.bind?.plan&&i.push(`productBinding:${o.id}`),(o.type==="stack"||o.type==="button")&&o.bind?.plan&&!t.includes(o.bind.plan)&&i.push("binding"),o.type==="plan_picker"&&(!o.planIds?.length||o.planIds.some(a=>!t.includes(a)))&&i.push("binding")}),[...new Set(i)]}function af(e){let t=[],n=e.screen.pages.at(-1),r=new Map;for(let c of e.screen.pages)r.set(c.id,[]),Nn(c.root,u=>{let p=u.type==="button"?u.action:u.type==="stack"?u.purchaseAction:void 0;if(p){let b=e.screen.actions.find(z=>z.id===p);b?.type==="navigate"&&r.get(c.id).push(b.pageId);let O=e.buttons[p];c.id!==n.id&&O&&O.type!=="close"&&t.push(`purchaseScreen:${u.id}`)}c.id!==n.id&&(u.type==="plan_picker"||u.type==="stack"&&u.productSlot)&&t.push(`packageScreen:${u.id}`)});let i=new Set;function o(c){if(!i.has(c)){i.add(c);for(let u of r.get(c)??[])o(u)}}let a=e.screen.initialPageId??e.screen.pages[0]?.id;a?o(a):t.push("initialPage");for(let c of e.screen.pages)i.has(c.id)||t.push(`unreachableScreen:${c.id}`);return[...new Set(t)]}var wu=K.object({id:K.uuid(),projectId:K.uuid(),environmentId:K.uuid(),revision:K.number().int().nonnegative(),state:K.enum(["active","archived"]),publishedVersionId:K.uuid().nullable(),updatedAt:K.iso.datetime({offset:!0}),draft:In}).strict(),Py=K.object({rows:K.array(wu).max(200),nextCursor:K.uuid().nullable()}).strict(),Cy=wu.omit({draft:!0}).extend({name:K.string(),productCount:K.number().int().nonnegative()}).strict(),ky=K.discriminatedUnion("action",[K.object({action:K.literal("save"),id:K.uuid().nullable(),revision:K.number().int().nonnegative(),document:In}).strict(),K.object({action:K.enum(["publish","archive"]),id:K.uuid(),revision:K.number().int().nonnegative()}).strict()]),Ry=K.object({paywalls:K.array(K.object({id:K.uuid(),paywallId:K.uuid(),version:K.number().int().positive(),name:K.string().min(1).max(80),presentation:jt,buttons:In.shape.buttons}).strict()).max(500),limited:K.boolean()}).strict();import{z as ee}from"zod";import{z as Ke}from"zod";var On=Ke.string().regex(/^[a-f0-9]{64}$/),sf=Qa.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),ju=Ke.strictObject({couponDigests:Ke.record(Ke.uuid(),On),variables:Ke.record(cn,Ke.record(Ke.uuid(),Ke.partialRecord(Ke.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),Ke.string()))),locales:Ke.record(cn,pn.extend({nodes:Ke.record(Ke.string(),Ke.strictObject({base:sf})),plans:Ke.object({}).strict(),pickers:Ke.object({}).strict()}).omit({paywall:!0}))});import{z as le}from"zod";import{z as Qr}from"zod";var ho=Qr.strictObject({eventsEnabled:Qr.boolean(),experimentViewsEnabled:Qr.boolean(),featureUsageEnabled:Qr.boolean()}),zy=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function Ny(e,t){return t==="Experiment Viewed"?e.experimentViewsEnabled:t==="Feature Evaluated"?e.featureUsageEnabled:e.eventsEnabled}var go=kt.extend({analyticsConfig:ho,remoteFeatures:le.array(le.string().min(1).max(255)).max(500)}),cf=go.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"})}),_u=le.strictObject({attributes:Ye,features:le.array(le.string().min(1).max(255)).max(500).optional(),customerId:le.uuid().optional()}),uf=le.strictObject({value:de,source:le.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:le.boolean(),off:le.boolean(),ruleId:le.string(),experimentResult:ns.optional()}),Pu=le.strictObject({generation:kt.shape.generation,evaluatedAt:kt.shape.evaluatedAt,expiresAt:kt.shape.expiresAt,features:le.record(le.string(),uf),merchandiseContext:le.strictObject({merchandiseId:le.uuid(),merchandise:Ye}).optional()}),Cu=le.strictObject({customerId:le.uuid().optional(),events:le.array(le.strictObject({eventUuid:le.uuid(),timestamp:le.iso.datetime({offset:!0}),name:le.string().min(1).max(255),merchandise:Ls.optional(),properties:le.record(le.string(),de).default({}),deviceId:le.string().min(1).max(255).optional(),sessionId:le.string().min(1).max(255).optional()})).min(1).max(100)}),ku=le.strictObject({inserted:le.number().int().nonnegative(),duplicates:le.number().int().nonnegative(),rejected:le.number().int().nonnegative(),skipped:le.number().int().nonnegative(),analyticsConfig:ho});import{z as j}from"zod";function bo(e,t=[]){let n=[];Ot(e,i=>{i.hidden&&n.push("Hidden components must not be delivered"),t.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let r=new Set(wi(e).map(i=>i.key));for(let[i,o]of Object.entries(e.strings.locales))for(let a of Object.keys(o))r.has(a)||n.push(`Unused string ${a} must not be delivered (${i})`);return n}function Ru(e){return e.hidden?null:e.type!=="stack"?e:{...e,children:e.children.flatMap(t=>Ru(t)??[])}}function lf(e){let t=e.pages.map(i=>{let o=Ru(i.root);return o?.type==="stack"?{...i,root:o}:{...i,root:{type:"stack",id:i.root.id,...i.root.name===void 0?{}:{name:i.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(wi({pages:t}).map(i=>i.key)),r=Object.fromEntries(Object.entries(e.strings.locales).map(([i,o])=>[i,Object.fromEntries(Object.entries(o).filter(([a])=>n.has(a)))]));return{...e,pages:t,strings:{...e.strings,locales:r}}}function Eu(e,t=[]){let n=et.parse(structuredClone(lf(e))),r=o=>o.type!=="stack"||o.interaction!==void 0||o.children.some(r);for(let o of n.pages)if(!r(o.root))throw new Error(`Page ${o.id} has no visible content`);let i=bo(n,t);if(i.length)throw new Error(i.join("; "));return n}import{z as R}from"zod";import{z as wn}from"zod";var Du=wn.strictObject({id:wn.uuid(),name:wn.string().trim().min(1).max(80),client:os,source:Sr,event:wn.enum(["screen_enter","button_click"]),cooldownSeconds:wn.number().int().min(0).max(2592e3),behavior:wn.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 fe}from"zod";var yo=de,pf=["parameters","answers","results","variables"];function xo(e){return pf.some(t=>e===t||e.startsWith(t+"."))}function So(e){let t={};for(let[r,i]of Object.entries(Un(e.declarations,e))){let o=r.split(".");if(o.some(u=>["__proto__","constructor","prototype"].includes(u)))throw new Error("Reserved result path");let a=t;for(let u of o.slice(0,-1)){Object.hasOwn(a,u)||(a[u]={});let p=a[u];if(!p||typeof p!="object"||Array.isArray(p))throw new Error("Ambiguous result path");a=p}let c=o.at(-1);if(c===void 0)throw new Error("Empty result path");a[c]=i}return{...Object.fromEntries(Object.entries(e.attributes).filter(([r])=>!xo(r))),variables:t}}import{z as df}from"zod";var Jr=df.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/);var vo=fe.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Tu=fe.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),Mu=ht.refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=8192,"Task data exceeds 8 KiB"),Io=fe.record(vo,fe.enum(["string","number","boolean","strings"])).refine(e=>Object.keys(e).length<=20,"Too many output fields"),mf=gt,Bu=fe.strictObject({type:fe.literal("external_task"),endpointId:fe.uuid(),taskKey:vo,inputs:fe.record(vo,mf).refine(e=>Object.keys(e).length<=20),outputs:Io}),qu=fe.strictObject({maxAttempts:fe.number().int().min(1).max(5),retryDelaySeconds:fe.number().int().min(1).max(30),backoff:fe.enum(["fixed","exponential"]),requestTimeoutSeconds:fe.number().int().min(1).max(10),timeoutSeconds:fe.number().int().min(1).max(300)}).refine(e=>e.requestTimeoutSeconds<=e.timeoutSeconds,"Request timeout exceeds action deadline");var lx=fe.strictObject({outcome:fe.enum(["success","failure"]),data:Mu});var px=fe.discriminatedUnion("operation",[fe.strictObject({operation:fe.literal("signal"),runId:fe.uuid(),nodeId:Tu,eventName:Jr,eventId:fe.uuid(),data:Mu}),fe.strictObject({operation:fe.literal("read_results"),runId:fe.uuid()})]),dx=fe.strictObject({scope:Se,runId:fe.uuid(),eventId:fe.uuid(),accepted:fe.boolean()}),ff=fe.record(Tu,yo),mx=fe.strictObject({scope:Se,runId:fe.uuid(),results:ff});var dt={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},zu="00000000-0000-0000-0000-000000000000";import{z as D}from"zod";import{z as be}from"zod";var yx=be.enum(["local","remote"]),Oo=be.strictObject({port:be.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:de.optional(),sticky:be.array(be.strictObject({expected:yr.nullable(),next:yr})).max(100),exposures:be.array(de).max(100),features:be.array(de).max(100)}),Nu=be.strictObject({type:be.literal("evaluate"),receiptId:be.uuid(),environmentId:be.uuid(),policyRevision:be.number().int().nonnegative(),attributes:Ye,sticky:be.record(be.string(),yr)}),Fu=Nu.extend({runId:be.uuid(),versionId:be.uuid(),nodeId:be.string().min(1).max(64),visit:be.number().int().nonnegative(),revision:be.number().int().nonnegative()}),wo=Nu.omit({type:!0,receiptId:!0}).extend({type:be.literal("evaluate_segment")}),Uu=be.strictObject({nodeId:be.string().min(1).max(64),result:Oo}),Vu=wo.extend({runId:be.uuid(),versionId:be.uuid(),nodeId:be.string().min(1).max(64),visit:be.number().int().nonnegative(),revision:be.number().int().nonnegative(),parameters:ht,answers:$t,variables:be.record(be.string(),de)});import{z as L}from"zod";var jo=L.array(L.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"),Wr=L.intersection(Ye,L.looseObject({tags:jo.optional()})).refine(e=>!["id","externalUserId","createdAt","ageDays","subscription","parameters","answers","results"].some(t=>Object.hasOwn(e,t)),"Reserved customer attribute"),Xr=L.string().trim().max(80),Yr=L.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),ei=L.union([L.email().max(254),L.literal("")]),ti=L.string().trim().min(1).max(255).refine(e=>!/\p{Cc}/u.test(e),"Fingerprint must not contain control characters"),Lu=L.string().trim().min(1).max(255).refine(e=>!e.startsWith("gg_guest_"),"Reserved guest identity namespace"),$u=L.object({externalUserId:Lu.optional(),name:Xr.default(""),email:ei.default(""),phone:Yr.optional(),attributes:Wr.default({})}).strict().refine(e=>e.externalUserId!==void 0||e.email!=="","\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u7528\u6237 ID \u6216\u90AE\u7BB1"),jn=L.discriminatedUnion("type",[L.strictObject({type:L.literal("id"),value:L.uuid()}),L.strictObject({type:L.literal("externalUserId"),value:Lu})]),_n=L.strictObject({name:Xr.optional(),email:ei.optional(),phone:Yr.optional(),attributes:Wr.optional(),fingerprint:ti.optional()}),Xt=e=>!e.customerData||e.customer?.type==="externalUserId",Yt="customerData requires an externalUserId customer",Pn=L.object({id:L.uuid(),externalUserId:L.string().min(1).max(255).nullable(),name:Xr,email:ei,phone:Yr.optional(),attributes:Wr,createdAt:L.iso.datetime()}).strict(),Gu=L.object({customer:Pn,changed:L.boolean(),replayed:L.boolean()}).strict(),Af=L.discriminatedUnion("type",[L.object({type:L.literal("id"),value:L.uuid()}).strict(),L.object({type:L.literal("externalUserId"),value:L.string().trim().min(1).max(255)}).strict()]),hf=L.object({name:Xr.optional(),email:ei.optional(),phone:Yr.optional(),attributes:Wr.refine(e=>!Object.hasOwn(e,"tags"),"Use incremental tagChanges").optional(),removeAttributes:L.array(L.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(e=>!e.includes("tags")).optional(),tagChanges:L.strictObject({add:jo,remove:jo}).optional()}).strict().refine(e=>Object.keys(e).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),_o=L.object({lookup:Af}).strict(),Ku=_o.extend({requestId:L.uuid(),patch:hf}).strict(),Hu=L.object({search:L.string().trim().max(200).default(""),tag:L.string().trim().max(40).default(""),planId:L.string().max(200).default(""),versionId:L.string().max(200).default(""),holdingStatus:L.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:L.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:L.union([L.iso.datetime(),L.literal("")]).default(""),createdUntil:L.union([L.iso.datetime(),L.literal("")]).default(""),offset:L.coerce.number().int().min(0).max(1e5).default(0),limit:L.coerce.number().int().min(1).max(100).default(50)}).strict(),Zu=L.object({customers:Pn.array(),hasMore:L.boolean(),total:L.number().int().nonnegative().nullable(),evaluatedAt:L.iso.datetime()}).strict();var er=D.discriminatedUnion("type",[D.strictObject({type:D.literal("literal"),value:de}),D.strictObject({type:D.literal("variable"),key:Ee,path:pt.optional()}),D.strictObject({type:D.literal("feature"),featureKey:D.string().min(1).max(128)})]),gf=D.strictObject({requestId:D.uuid(),decisionId:D.uuid(),customerId:D.uuid(),externalUserId:D.string().min(1).max(255).nullable(),versionId:D.uuid(),receiptId:D.uuid(),value:de}),Po={funnelId:D.uuid(),requestId:D.uuid(),customer:jn,customerData:_n.optional(),attributes:Ye.refine(e=>!["parameters","answers","results","variables"].some(t=>Object.hasOwn(e,t)),"parameters, answers, results and variables are reserved flow namespaces")},Rx=D.discriminatedUnion("operation",[D.strictObject({operation:D.literal("decide"),...Po}).refine(Xt,Yt),D.strictObject({operation:D.literal("read_decision"),decisionId:D.uuid()}),D.strictObject({operation:D.literal("evaluate_decision"),decisionId:D.uuid(),requestId:D.uuid(),nodeId:D.string().min(1).max(64),visit:D.number().int().nonnegative(),revision:D.number().int().nonnegative(),receiptId:D.uuid(),policyRevision:D.number().int().nonnegative(),generation:D.string().min(1).max(256),result:Oo}),D.strictObject({operation:D.literal("feature_config"),funnelId:D.uuid()}),D.strictObject({operation:D.literal("commit_decision_segment"),decisionId:D.uuid(),requestId:D.uuid(),nodeId:D.string().min(1).max(64),visit:D.number().int().nonnegative(),revision:D.number().int().nonnegative(),policyRevision:D.number().int().nonnegative(),generation:D.string().min(1).max(256),steps:D.array(Uu).max(32),boundary:D.strictObject({nodeId:D.string().min(1).max(64),visit:D.number().int().nonnegative()}).optional()}),D.strictObject({operation:D.literal("segment_configuration"),funnelId:D.uuid(),versionId:D.uuid()}),D.strictObject({operation:D.literal("configuration"),funnelId:D.uuid(),versionId:D.uuid().optional()}),D.strictObject({operation:D.literal("local_configuration"),funnelId:D.uuid()}),D.strictObject({operation:D.literal("report_used"),decisionId:D.uuid(),eventId:D.uuid(),occurredAt:D.iso.datetime({offset:!0}),reference:D.string().min(1).max(128).optional()})]),Ex=D.strictObject({scope:Se,decisionId:D.uuid(),requestId:D.uuid(),status:D.enum(["pending","completed","failed"]),decision:gf.nullable(),evaluation:D.discriminatedUnion("type",[Fu,Vu]).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"),Dx=D.strictObject({scope:Se,decisionId:D.uuid(),eventId:D.uuid(),source:D.literal("caller_reported")});import{z as Fe}from"zod";var Qu=Fe.strictObject({type:Fe.literal("bundle"),paywall:gt.optional(),offering:gt.optional(),coupons:gt,data:gt}),bf=e=>Fe.strictObject({type:Fe.literal(e),id:Fe.uuid()}),Nx=Fe.strictObject({type:Fe.literal("bundle"),paywallVersionId:Fe.uuid().optional(),offeringVersionId:Fe.uuid().optional(),couponIds:Fe.array(Fe.uuid()).max(20).refine(e=>new Set(e).size===e.length),data:de});var Fx=Fe.strictObject({type:Fe.literal("bundle"),offering:bf("offering_version").nullable(),paywall:Fe.strictObject({versionId:Fe.uuid(),paywallId:Fe.uuid(),offeringVersionId:Fe.uuid()}).nullable(),coupons:Fe.array(Ln).max(20),data:de});import{z as mt}from"zod";import{z as st}from"zod";var Ju=st.union([st.string(),st.number().finite(),st.boolean(),st.null()]),yf=st.union([Ju,st.array(Ju).min(1).max(20)]),xf=st.record(pt,yf).refine(e=>Object.keys(e).length<=10),Wu=st.strictObject({path:pt,type:st.enum(["string","number","boolean","strings"]),nullable:st.boolean().optional(),aggregation:st.enum(["count","exists"]).optional(),where:xf.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 Sf=["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"],Xu=mt.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),vf=gt,Yu=mt.discriminatedUnion("type",[Bu,mt.strictObject({type:mt.literal("claim_offer"),coupon:gt}),mt.strictObject({type:mt.literal("event"),event:Xu}),mt.strictObject({type:mt.literal("api"),operation:mt.enum(Sf),inputs:mt.record(pt,vf).refine(e=>Object.keys(e).length<=40),outputs:mt.record(Xu,Wu).refine(e=>Object.keys(e).length<=20)})]);var _e=Jr,If=R.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),rt={id:_e,name:R.string().trim().min(1).max(80),position:R.strictObject({x:R.number().finite(),y:R.number().finite()}).optional()},Of={success:_e,cancel:_e,unavailable:_e,failure:_e},Co=R.url().max(2048).refine(e=>{try{return new URL(e).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),ko=R.enum(["same_window","new_window"]),wf=R.discriminatedUnion("type",[R.strictObject({...rt,type:R.literal("entry"),next:_e,triggers:R.array(Du).max(20).refine(e=>new Set(e.map(t=>t.id)).size===e.length,"Entry trigger IDs must be unique").optional()}),R.strictObject({...rt,type:R.literal("screen"),screenId:_e,presentation:jt,outputs:R.record(_e,_e),offering:R.discriminatedUnion("source",[R.strictObject({source:R.literal("variable"),key:Ee}),R.strictObject({source:R.literal("fixed"),versionId:R.uuid()})]).optional()}),R.strictObject({...rt,type:R.literal("offering"),configuration:R.discriminatedUnion("source",[R.strictObject({source:R.literal("fixed"),versionId:R.uuid()}),R.strictObject({source:R.literal("feature"),featureKey:R.string().min(1).max(128)})]),writes:R.strictObject({value:Ee}),next:_e}),R.strictObject({...rt,type:R.literal("coupon"),couponId:R.uuid(),writes:R.strictObject({value:Ee}),next:_e}),R.strictObject({...rt,type:R.literal("coupons"),couponIds:R.array(R.uuid()).max(20).refine(e=>new Set(e).size===e.length),writes:R.strictObject({value:Ee}),next:_e}),R.strictObject({...rt,type:R.literal("output"),value:R.discriminatedUnion("type",[...er.options,Qu,R.strictObject({type:R.literal("selection"),screenId:_e,offeringKey:Ee})])}),R.strictObject({...rt,type:R.literal("condition"),cases:R.array(R.strictObject({condition:Lt,target:_e})).min(1).max(50),default:_e}),R.strictObject({...rt,type:R.literal("feature"),featureKey:R.string().min(1).max(128),writes:R.strictObject({value:Ee}),next:_e}),R.strictObject({...rt,type:R.literal("split"),experimentId:R.uuid(),applyPageExperiment:R.literal(!0).optional(),routes:R.record(If,_e).refine(e=>Object.keys(e).length>=2&&Object.keys(e).length<=20),notParticipating:_e}),R.strictObject({...rt,type:R.literal("action"),...Of,execution:qu,action:Yu,writes:wr.optional()}),R.strictObject({...rt,type:R.literal("external_page"),appManifest:Sr.optional(),url:Co,openIn:ko,opened:_e,failed:_e}),R.strictObject({...rt,type:R.literal("end"),outcome:R.enum(["completed","closed","ineligible","failed"]),output:er.optional()}),R.strictObject({...rt,type:R.literal("wait"),writes:wr.optional(),wait:R.discriminatedUnion("type",[R.strictObject({type:R.literal("duration"),delaySeconds:R.number().int().min(1).max(2592e3),elapsed:_e}),R.strictObject({type:R.literal("event"),eventName:_e,outputs:Io,timeoutSeconds:R.number().int().min(1).max(2592e3),received:_e,timeout:_e})])})]),Ro=R.strictObject({version:R.literal(5),entry:_e,nodes:R.array(wf).min(1).max(dt.flowNodes)}),Eo=Ro.superRefine((e,t)=>{jf(e,n=>t.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function ni(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 jf(e,t){let n=[],r=new Map(e.nodes.map(b=>[b.id,b])),i=(b,O,z)=>{n.push(b),t?.({message:b,reason:O,path:z?["nodes",e.nodes.indexOf(z)]:[]})};r.size!==e.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(r.get(e.entry)?.type!=="entry"||e.nodes.filter(b=>b.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(e.nodes.filter(b=>b.type==="screen").length>dt.pages||e.nodes.filter(b=>!["screen","entry","end","output"].includes(b.type)).length>dt.logicNodes)&&i("Flow node limit exceeded","budget");let o=new Set;for(let b of e.nodes){for(let O of ni(b))O===e.entry&&i("An entry cannot be a transition target","entryTarget",b),r.has(O)||i(`Missing target ${O}`,"missingTarget",b);b.type==="screen"&&(o.has(b.screenId)&&i("Every screen has exactly one node owner","screenOwner",b),o.add(b.screenId))}let a=new Set,c=new Set,u=new Set;function p(b){if(a.has(b)){i("Flow edges must not form a cycle","cycle",r.get(b));return}if(!(c.has(b)||!r.has(b))){a.add(b),u.add(b);for(let O of ni(r.get(b)))p(O);a.delete(b),c.add(b)}}p(e.entry);for(let b of e.nodes)u.has(b.id)||i("Every node must be reachable from Entry","unreachable",b);return[...new Set(n)]}var Do={maxTransitions:1e4,runTimeoutSeconds:2592e3};function el(e,t,n){let r=[...t].sort((c,u)=>u.length-c.length),i=new Set,o=(c,u=!1)=>{let p=r.find(b=>c===b||u&&c.startsWith(b+"."));i.add(p??c)};if(e.type==="condition"){let c=n?.startsWith("case_")?Number(n.slice(5)):e.cases.length-1;for(let u of e.cases.slice(0,c+1))for(let p of Mt(u.condition))p.startsWith("variables.")&&o(p.slice(10),!0)}if(e.type==="screen"&&e.offering?.source==="variable"&&o(e.offering.key),e.type==="action"&&(e.action.type==="api"||e.action.type==="external_task"))for(let c of Object.values(e.action.inputs))c.source==="variable"&&o(c.key);e.type==="action"&&e.action.type==="claim_offer"&&e.action.coupon.source==="variable"&&o(e.action.coupon.key);let a=e.type==="output"?e.value:e.type==="end"?e.output:null;if(a?.type==="variable"&&o(a.key),a?.type==="bundle")for(let c of[a.paywall,a.offering,a.coupons,a.data])c?.source==="variable"&&o(c.key);return a?.type==="selection"&&o(a.offeringKey),[...i]}import{z as x}from"zod";var Cn=x.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ri=e=>x.record(x.string(),de).refine(t=>tt(t)<=e,"Funnel evidence exceeds its byte budget"),gS=x.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Mo=x.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Bo=x.discriminatedUnion("type",[x.strictObject({type:x.literal("flag"),key:x.string().min(1).max(128)}),x.strictObject({type:x.literal("experiment"),id:x.uuid()}),x.strictObject({type:x.literal("saved_group"),id:x.uuid()}),x.strictObject({type:x.literal("config"),key:x.string().min(1).max(128)}),x.strictObject({type:x.literal("constant"),key:x.string().min(1).max(128)}),x.strictObject({type:x.literal("paywall_version"),id:x.uuid()}),x.strictObject({type:x.literal("offering_version"),id:x.uuid()}),x.strictObject({type:x.literal("reward"),id:x.uuid()})]),tr=x.strictObject({schemaVersion:x.literal(1),kind:Mo,selector:Bo.nullable(),context:ri(131072),contract:x.strictObject({version:x.number().int().positive(),evaluator:x.string().min(1).max(128),policyRevision:x.number().int().nonnegative()})}).refine(e=>tt(e)<=131072,"Node input exceeds its byte budget"),tl=x.strictObject({schemaVersion:x.literal(1),kind:Mo,outcome:x.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ri(131072),route:x.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ri(131072)}).refine(e=>tt(e)<=131072,"Node result exceeds its byte budget"),bS=x.strictObject({schemaVersion:x.literal(1),operations:x.record(Cn,x.strictObject({attempts:x.number().int().nonnegative(),maxAttempts:x.number().int().min(1).max(5),deadlineAt:x.iso.datetime({offset:!0}),retryAt:x.iso.datetime({offset:!0}).nullable(),error:x.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:x.strictObject({type:Cn,id:x.uuid()}).nullable()}))}).refine(e=>tt(e)<=65536,"Execution state exceeds its byte budget"),en={receiptId:x.uuid()},To=x.iso.datetime({offset:!0}),yS=x.discriminatedUnion("type",[x.strictObject({type:x.literal("node_entered"),details:x.strictObject({kind:Mo})}),x.strictObject({type:x.literal("presentation_shown"),details:x.strictObject({...en,source:x.literal("client"),occurredAt:To.optional()})}),x.strictObject({type:x.literal("decision_accepted"),details:x.strictObject(en)}),x.strictObject({type:x.literal("signal_received"),details:x.strictObject({signalId:x.uuid(),nodeId:Cn,eventName:Cn,data:ri(8192),source:x.literal("server"),occurredAt:To})}),x.strictObject({type:x.literal("signal_consumed"),details:x.strictObject({...en,signalId:x.uuid()})}),x.strictObject({type:x.literal("wait_elapsed"),details:x.strictObject(en)}),x.strictObject({type:x.literal("wait_timeout"),details:x.strictObject(en)}),x.strictObject({type:x.literal("operation_completed"),details:x.strictObject({...en,operation:Cn,reference:x.strictObject({type:Cn,id:x.uuid()}).nullable()})}),x.strictObject({type:x.literal("execution_recovered"),details:x.strictObject({generation:x.number().int().positive(),reason:x.enum(["interrupted","expired_lease","delivery_failed"])})}),x.strictObject({type:x.literal("execution_failed"),details:x.strictObject({generation:x.number().int().positive(),code:x.string().regex(/^[a-z_]{1,64}$/)})}),x.strictObject({type:x.literal("run_completed"),details:x.strictObject({outcome:x.enum(["completed","ineligible","failed"])})}),x.strictObject({type:x.literal("run_closed"),details:x.strictObject({source:x.enum(["client","server","expiry"])})}),x.strictObject({type:x.literal("treatment_used"),details:x.strictObject({...en,source:x.enum(["client","server"]),occurredAt:To,reference:x.string().min(1).max(128).optional()})})]);var ct=j.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),_f=j.discriminatedUnion("type",[j.strictObject({id:ct,type:j.literal("owned"),publicData:ju.optional(),document:et.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")}),j.strictObject({id:ct,type:j.literal("paywall"),paywallVersionId:j.uuid()})]),qo={kind:j.literal("funnel"),schemaVersion:j.literal(4),screens:j.array(_f).max(dt.pages),references:j.record(ct,Bo).refine(e=>Object.keys(e).length<=500),inputs:j.array(j.strictObject({variable:ct,screenId:ct,componentId:ct,required:j.boolean()})).max(dt.questions),variables:j.record(Ee,fn).refine(e=>Object.keys(e).length<=dt.logicNodes),outputSchema:mn,execution:j.strictObject({runTimeoutSeconds:j.number().int().min(1).max(Do.runTimeoutSeconds),maxTransitions:j.number().int().min(1).max(Do.maxTransitions)})},zS=j.strictObject({...qo,graph:Ro});function Pf(e,t){let n=!1,r=(i,o)=>{let a=i.type==="stack"||i.type==="button"?i.bind?.coupon??o:o;i.type==="text"&&Object.values(e.strings.locales).some(c=>c[i.text]?.includes("{{offer."))&&!(a&&t(a))&&(n=!0),i.type==="stack"&&i.children.forEach(c=>r(c,a))};for(let i of e.pages)r(i.root);return n}function oi(e){return Array.isArray(e)?e.some(oi):!e||typeof e!="object"?!1:Object.entries(e).some(([t,n])=>t==="productVersionId"?n===zu:oi(n))}function Cf(e){let t=[],n=new Set(Object.values(e.references).flatMap(r=>r.type==="reward"?[r.id]:[]));for(let[r,i]of e.screens.entries()){if(i.type!=="owned")continue;let o;try{o=Eu(i.document)}catch(a){t.push({message:a instanceof Error?a.message:"Screen cannot be delivered",reason:"screen",path:["screens",r,"document"]});continue}for(let[a,c]of e.inputs.entries())c.screenId===i.id&&!ji(o,c.componentId)&&t.push({message:`Local Funnel input ${c.variable} targets hidden component ${c.componentId} on screen ${c.screenId}`,reason:"inputBinding",path:["inputs",a]})}for(let[r,i]of e.graph.nodes.entries()){let o=["graph","nodes",r],a=i.type==="screen"?e.screens.find(c=>c.id===i.screenId):void 0;a?.type==="owned"&&(a.document.actions.some(c=>typeof c.properties.templateKey=="string"&&c.properties.templateKey.startsWith("popup-coupon-"))&&t.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:o}),Pf(a.document,c=>n.has(c))&&t.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:o})),(i.type==="output"&&i.value.type==="literal"&&oi(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&oi(i.output.value))&&t.push({message:"Checkout outputs require a Product Version",reason:"product",path:o})}return t}function nl(e,t){for(let{message:n,reason:r,path:i}of Cf(e))t.addIssue({code:"custom",message:n,path:i,params:{reason:r}})}function rl(e,t){let n=(I,d,g=[])=>t.addIssue({code:"custom",message:I,path:g,params:{reason:d}}),r=Object.values(e.references),i=new Map(e.screens.map(I=>[I.id,I])),o=(I,d)=>r.some(g=>g.type===I&&("id"in g?g.id:g.key)===d);i.size!==e.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let a=e.graph.nodes.filter(I=>I.type==="screen");(a.length!==i.size||a.some(I=>!i.has(I.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let c=new Map,u=Object.keys(e.variables);u.some(I=>u.some(d=>I!==d&&d.startsWith(I+".")))&&n("Variable paths must not overlap","variable");function p(I,d){Object.hasOwn(e.variables,I)||n("Every produced variable needs a declaration","variable",["graph","nodes",e.graph.nodes.indexOf(d)]);let g=c.get(I)??new Set;g.add(d.id),c.set(I,g)}for(let[I,d]of e.graph.nodes.entries()){let g=["graph","nodes",I],E=d.type==="feature"?d.featureKey:d.type==="offering"&&d.configuration.source==="feature"?d.configuration.featureKey:d.type==="output"&&d.value.type==="feature"?d.value.featureKey:d.type==="end"&&d.output?.type==="feature"?d.output.featureKey:null;E&&!o("flag",E)&&n("Flag selectors require an explicit GB resource reference","feature",g);let X=d.type==="feature"||d.type==="offering"||d.type==="coupon"||d.type==="coupons"||d.type==="action"&&d.action.type==="api"?["value"]:d.type==="action"&&d.action.type==="external_task"?Object.keys(d.action.outputs):d.type==="wait"&&d.wait.type==="event"?Object.keys(d.wait.outputs):[],te="writes"in d?d.writes??{}:{};(X.length!==Object.keys(te).length||X.some(M=>!Object.hasOwn(te,M))||new Set(Object.values(te)).size!==Object.values(te).length)&&n("Node writes must map every named output exactly once","variable",g);for(let[M,se]of Object.entries(te)){p(se,d);let re=e.variables[se],V=d.type==="offering"?"offering_version":d.type==="coupon"?"reward":d.type==="action"&&d.action.type==="api"?"json":d.type==="action"&&d.action.type==="external_task"?d.action.outputs[M]:d.type==="wait"&&d.wait.type==="event"?d.wait.outputs[M]:void 0;(re?.source.type!=="node"||V&&re.type!==V)&&n("Node writer source or output type does not match declaration","variable",g)}if(d.type==="coupons"){let M=e.variables[d.writes.value];(M?.type!=="array"||M.items?.type!=="reward"||M.items.nullable||M.nullable)&&n("Coupons output requires a non-null Reward array","variable",g);for(let se of d.couponIds)o("reward",se)||n("Coupons require Reward references","coupon",g)}if(d.type==="split"&&!o("experiment",d.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",g),d.type==="coupon"&&!o("reward",d.couponId)&&n("Coupon selectors require a Reward reference","coupon",g),d.type==="action"&&d.action.type==="claim_offer"&&d.action.coupon.source==="literal"){let M=d.action.coupon.value;(!M||typeof M!="object"||Array.isArray(M)||M.type!=="reward"||typeof M.id!="string"||Object.keys(M).length!==2||!o("reward",M.id))&&n("Coupon claims require a Reward reference","coupon",g)}if(d.type==="offering"&&d.configuration.source==="fixed"&&!o("offering_version",d.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",g),d.type==="screen"&&d.offering?.source==="variable"&&e.variables[d.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",g),d.type==="action"&&d.action.type==="claim_offer"&&d.action.coupon.source==="variable"&&(e.variables[d.action.coupon.key]?.type!=="reward"||d.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",g),d.type==="screen"){let M=i.get(d.screenId);if(d.offering?.source==="fixed"&&!o("offering_version",d.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",g),M?.type==="paywall"&&d.offering&&n("Paywall owns its fixed Offering Version","offering",g),M?.type==="paywall"&&!o("paywall_version",M.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",g),M?.type==="owned"){let se=M.document.pages[0];if(!se){n("Owned screen requires a page","screen",g);continue}Ct(M.document).some(V=>!V.complete)&&n("Owned screens require complete local content","translations",g);let re=new Set(M.document.actions.map(V=>V.id));(re.size!==Object.keys(d.outputs).length||Object.keys(d.outputs).some(V=>!re.has(V)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",g),Nn(se.root,V=>{!d.offering&&(V.type==="plan_picker"||(V.type==="stack"||V.type==="button")&&V.bind?.plan||V.type==="customer_data"&&["customer_plans","credit_packs"].includes(V.data.source))&&n("Product presentation requires an Offering Version","offering",g),V.type==="customer_data"&&Object.values(V.data.outputs??{}).some(Qe=>Qe!==void 0&&!re.has(Qe))&&n("Customer components require declared screen outcomes","componentOutput",g)})}}d.type==="end"&&["completed","ineligible"].includes(d.outcome)&&!d.output&&n("Completed and ineligible ends require a declared output","output",g),d.type==="end"&&d.output?.type==="literal"&&!at(e.outputSchema,d.output.value)&&n("Terminal output does not match outputSchema","output",g),d.type==="output"&&d.value.type==="literal"&&!at(e.outputSchema,d.value.value)&&n("Terminal output does not match outputSchema","output",g);let xe=d.type==="output"?d.value:d.type==="end"?d.output:void 0;if(xe?.type==="variable"&&!xe.path){let M=e.variables[xe.key];M&&!Di(M,e.outputSchema)&&n("Variable output does not match outputSchema","output",g)}if(d.type==="screen"){let M=i.get(d.screenId);if(M?.type==="owned")for(let se of qi(M.document))(/^(input|params)\./.test(se)||se.startsWith("variables.")&&!Bi(se.slice(10),u))&&n("Screen values must reference registered variables","variable",g)}if(d.type==="condition")for(let M of d.cases){for(let se of Pt(M.condition))o("saved_group",se)||n("Conditions require explicit Saved Group references","savedGroup",g);for(let se of Mt(M.condition))se.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",g)}if(d.type==="output"&&d.value.type==="bundle"){e.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",g);for(let[M,se]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let re=d.value[M];if(re)if(re.source==="literal"){let V=M==="coupons"?re.value:[re.value];(!Array.isArray(V)||V.length>20||V.some(Qe=>!at({type:se,nullable:!1},Qe)||!o(se,Qe.id))||M==="coupons"&&new Set(V.map(Qe=>Qe.id)).size!==V.length)&&n("Bundle requires distinct scoped resource references",M==="coupons"?"coupon":M==="paywall"?"paywall":"offering",[...g,"value",M])}else{let V=e.variables[re.key];(re.path||!V||V.nullable||(M==="coupons"?V.type!=="array"||V.items?.type!=="reward"||V.items.nullable:V.type!==se))&&n("Bundle binding type does not match its slot","output",g)}}}}for(let[I,d]of e.graph.nodes.entries()){let g=d.type==="screen"?i.get(d.screenId):void 0,E=[...el(d,u),...g?.type==="owned"?jr(g.document).map(X=>Bi(X,u)?.key??X):[]];for(let X of new Set(E)){let se=function(re){if(re===d.id)return!0;if(M.has(re))return!1;M.add(re);let V=e.graph.nodes.find(Je=>Je.id===re);return V?(xe.has(re)?V.type==="action"?[V.cancel,V.unavailable,V.failure]:V.type==="wait"&&V.wait.type==="event"?[V.wait.timeout]:[]:ni(V)).some(se):!1};var z=se;if(!Object.hasOwn(e.variables,X)){n("Consumed variable is undeclared","variable",["graph","nodes",I]);continue}let te=e.variables[X];if(d.type==="screen"&&te.source.type==="input"&&e.inputs.some(re=>re.screenId===d.screenId&&re.variable===X)||te.source.type==="parameter"||te.source.type==="attribute")continue;let xe=te.source.type==="input"?new Set(e.inputs.filter(re=>re.variable===X&&re.required).flatMap(re=>a.filter(V=>V.screenId===re.screenId).map(V=>V.id))):c.get(X)??new Set,M=new Set;(!xe.size||se(e.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",I])}}(new Set(e.inputs.map(I=>I.variable)).size!==e.inputs.length||new Set(e.inputs.map(I=>`${I.screenId}:${I.componentId}`)).size!==e.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[I,d]of e.inputs.entries()){e.variables[d.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",I]);let g=i.get(d.screenId),E=g?.type==="owned"?ji(g.document,d.componentId):null;if((E?.type!=="stack"||!E.interaction||!["input","toggle","select","multiselect","tabs"].includes(E.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",I]),E?.type==="stack"&&E.interaction){let X=E.interaction.type==="toggle"?"boolean":E.interaction.type==="multiselect"?"strings":"string";e.variables[d.variable]?.type!==X&&n("Input variable type does not match component","inputBinding",["inputs",I]);let te=e.variables[d.variable]?.enum;te&&!E.children.filter(xe=>!xe.hidden).every(xe=>te.includes(xe.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",I])}}for(let[I,d]of Object.entries(e.variables))d.enum&&d.type!=="string"&&n("Only string variables support enum","variable",["variables",I]),d.source.type==="input"&&!e.inputs.some(g=>g.variable===I)&&n("Input variable requires a component binding","inputBinding",["variables",I]);let b=0,O=0;for(let I of e.screens)if(I.type==="owned"){for(let d of I.document.pages)Nn(d.root,()=>{b++});O+=I.document.actions.length}(b>dt.components||O>dt.actions||tt(e)>dt.documentBytes)&&n("Funnel document exceeds its budget","budget")}var kf=j.strictObject({...qo,graph:Eo}).superRefine(rl),zt=j.strictObject({...qo,graph:Eo,displayName:j.string().trim().min(1).max(80)}).superRefine(rl),NS=zt.superRefine(nl),FS=kf.superRefine(nl),ii=j.string().regex(Rt),nr={requestId:j.uuid(),nodeId:ct,visit:j.number().int().nonnegative(),revision:j.number().int().nonnegative(),customerToken:ii.optional()},Rf=j.discriminatedUnion("type",[j.strictObject({type:j.literal("screen"),output:ct,answers:$t,selection:j.record(ct,j.union([j.string().max(200),j.boolean(),j.number().int().min(0).max(1e4)])).optional()}),j.strictObject({type:j.literal("paywall_quote"),featureQuantities:j.record(j.uuid(),j.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100).optional(),actionId:ct,productVersionId:j.uuid(),offerId:j.uuid().optional(),nativeOffer:yn.optional(),predecessor:j.strictObject({operationId:j.uuid().nullable(),generation:j.number().int().positive()}).optional()}),j.strictObject({type:j.literal("paywall_confirm"),operationId:j.uuid()}),j.strictObject({type:j.literal("paywall_cancel"),operationId:j.uuid()}),j.strictObject({type:j.literal("client_action"),receiptId:j.uuid(),outcome:j.enum(["success","cancel","failure","opened","failed"])})]),Ef=j.object({nodeId:ct,visit:j.number().int().nonnegative(),revision:j.number().int().nonnegative(),components:j.record(ct,j.object({resourceKey:j.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:j.number().int().min(1).max(1e5),after:vr.nullable(),filter:j.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(e=>Object.keys(e).length<=150)}).strict(),US=j.discriminatedUnion("operation",[j.strictObject({operation:j.literal("start"),funnelId:j.uuid(),requestId:j.uuid(),customer:jn.optional(),customerData:_n.optional(),locale:j.string().min(1).max(35),parameters:ht}).refine(Xt,Yt),j.strictObject({operation:j.literal("get"),settlementRequestId:j.uuid().optional(),data:Ef.optional(),purchase:j.strictObject({receiptId:j.uuid(),operationId:j.uuid()}).optional(),customerToken:ii.optional()}),j.strictObject({operation:j.literal("resume"),requestId:j.uuid(),customerToken:ii.optional()}),j.strictObject({operation:j.literal("submit"),...nr,input:Rf}),j.strictObject({operation:j.literal("back"),...nr}),j.strictObject({operation:j.literal("shown"),...nr}),j.strictObject({operation:j.literal("close"),...nr}),j.strictObject({operation:j.literal("commit_segment"),...nr,policyRevision:j.number().int().nonnegative(),generation:j.string().min(1).max(256)}),j.strictObject({operation:j.literal("review"),receiptId:j.uuid().optional(),customerToken:ii.optional()})]);function ai(e,t){let n=new Set,r=new Set,i=new Set,o=[],a=new Map,c=new Map,u=new Map;function p(d){for(let g of Pt(d))b(g)}function b(d){if(i.has(d)||!Object.hasOwn(t.savedGroups,d))return;let g=t.savedGroups[d];g&&(i.add(d),u.set(d,g),o.push(()=>{!Array.isArray(g)&&g.type==="condition"&&p(g.condition)}))}function O(d){for(let g of["hashAttribute","fallbackAttribute"])if(d[g]!==void 0&&xo(d[g]))throw new Error(`Funnel GB ${g} uses a reserved flow namespace`);p(d.condition);for(let g of d.parentConditions??[])z(g.id),p(g.condition)}function z(d,g=!1){let E=Object.hasOwn(t.features,d)?t.features[d]:void 0;if(!E){if(g)throw new Error("Required GB Feature is unavailable");return}n.has(d)||(n.add(d),a.set(d,E),o.push(()=>{for(let X of E.rules??[]){O(X);for(let te of X.tracks??[])O(te.experiment)}}))}function I(d){let g=Object.hasOwn(t.experiments,d)?t.experiments[d]:void 0;if(!g)throw new Error("Required GB Experiment is unavailable");r.has(d)||(r.add(d),c.set(d,g),o.push(()=>O(g)))}for(let d of e.graph.nodes){d.type==="feature"&&z(d.featureKey,!0),d.type==="split"&&I(d.experimentId),d.type==="condition"&&d.cases.forEach(E=>p(E.condition)),d.type==="offering"&&d.configuration.source==="feature"&&z(d.configuration.featureKey,!0);let g=d.type==="output"?d.value:d.type==="end"?d.output:null;g?.type==="feature"&&z(g.featureKey,!0)}for(let d of o)d();return{...t,features:Object.fromEntries(a),experiments:Object.fromEntries(c),savedGroups:Object.fromEntries(u)}}import{z as U}from"zod";import{z as rr}from"zod";var il=rr.object({defaultLocale:cn,locales:rr.record(cn,rr.object({name:rr.string().max(80),description:rr.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 Df=["customer_data","coupon_code"],Tf=U.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),ol=U.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),si=(e,t)=>new Set(e.map(t)).size===e.length,Mf=U.strictObject({currency:ae,amountMinor:U.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Bf=U.strictObject({featureId:U.uuid(),name:U.string().trim().min(1).max(120),allowance:U.string().max(40).nullable(),access:U.boolean()}),qf=U.strictObject({stripe:U.strictObject({prices:U.array(Mf).min(1).max(50)}).optional(),apple:U.strictObject({productIds:U.array(Tf).min(1).max(10)}).optional(),google:U.strictObject({products:U.array(U.strictObject({productId:ol,basePlanId:ol.nullable()})).min(1).max(10)}).optional()}).superRefine((e,t)=>{(e.stripe&&!si(e.stripe.prices,n=>n.currency)||e.apple&&!si(e.apple.productIds,n=>n)||e.google&&!si(e.google.products,n=>`${n.productId}:${n.basePlanId}`))&&t.addIssue({code:"custom",message:"Duplicate channel entry"})}),zf=U.strictObject({name:U.string().trim().min(1).max(80),interval:U.enum(["free","week","month","year","one_time"]),intervalCount:U.number().int().min(1).max(100),trial:U.strictObject({days:U.number().int().min(1).max(730),cardRequired:U.boolean()}).nullable(),benefits:U.array(Bf).max(50).refine(e=>si(e,t=>t.featureId),"Duplicate benefit"),channels:qf,prepaid:U.array(Ga).max(100).optional()}),Nf=U.strictObject({digest:On,content:U.strictObject({discount:Bt,duration:nt,appliesTo:Zi,displayCopy:il.nullable(),firstPurchaseOnly:U.boolean(),qualificationRequired:U.boolean(),startsAt:U.iso.datetime().nullable(),endsAt:U.iso.datetime().nullable(),grantWindowHours:U.number().int().positive(),perCustomerLimit:U.number().int().positive()})}),Ff=U.discriminatedUnion("type",[U.strictObject({type:U.literal("checkout"),product:Zr}),U.strictObject({type:U.literal("close")}),U.strictObject({type:U.literal("action"),action:Ao})]),al=U.strictObject({kind:U.literal("paywall"),formatVersion:U.literal(1),name:U.string().trim().min(1).max(80),offeringVersionId:U.uuid(),presentation:jt,screen:et,products:Pr,catalog:U.record(U.uuid(),zf),buttons:U.record(zn,Ff),coupons:U.record(U.uuid(),Nf)}).superRefine((e,t)=>{let n=g=>t.addIssue({code:"custom",message:g}),{screen:r}=e;as(r,e.catalog).forEach(n),r.surface!=="paywall"&&n("Screen must be a Paywall"),bo(r,Df).forEach(n),Ct(r).some(g=>!g.complete)&&n("Every published locale must be complete");let i=new Set,o=new Set,a=new Set;Ot(r,g=>{let E="bind"in g?g.bind:void 0;E?.promotionCode&&n("Promotion codes must not be published"),E?.plan&&i.add(E.plan),E?.coupon&&o.add(E.coupon),g.type==="plan_picker"&&(g.planIds?.forEach(X=>i.add(X)),g.defaultPlan&&i.add(g.defaultPlan)),g.type==="text"&&g.feature&&a.add(g.feature.id)});let c=e.products.items.map(g=>g.productVersionId),u=Object.keys(e.catalog);(c.length!==u.length||c.some(g=>!Object.hasOwn(e.catalog,g)))&&n("Catalog must contain exactly the displayed Products");let p=new Set(c);e.products.defaultProductVersionId!==null&&!p.has(e.products.defaultProductVersionId)&&n("Default Product must be displayed");for(let g of i)p.has(g)||n("Screen references a Product that is not displayed");for(let g of Object.values(e.catalog))!g.channels.stripe&&!g.channels.apple&&!g.channels.google&&n("A displayed Product needs at least one sales channel");let b=new Set(Object.values(e.catalog).flatMap(g=>g.benefits.map(E=>E.featureId)));for(let g of a)b.has(g)||n("Feature text must read a displayed benefit");let O=r.actions.filter(g=>g.type!=="navigate");r.actions.some(g=>g.type!=="event"&&g.type!=="navigate")&&n("Paywall actions are events or navigation"),(Object.keys(e.buttons).length!==O.length||O.some(g=>!Object.hasOwn(e.buttons,g.id)))&&n("Buttons must match the screen's actions");let I=!1;for(let g of Object.values(e.buttons)){if(g.type!=="checkout")continue;I=!0,(g.product.type==="fixed"?[g.product.productVersionId]:g.product.allowedProductVersionIds).some(X=>!p.has(X))&&n("Checkout may only sell displayed Products")}I||n("A Paywall needs a checkout button");let d=Object.keys(e.coupons);(d.length!==o.size||d.some(g=>!o.has(g)))&&n("Coupons must be exactly the bound Coupons")}),sl=U.strictObject({state:U.enum(["published","archived"]),controlRevision:U.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:U.uuid(),versions:U.record(U.uuid(),U.strictObject({version:U.number().int().positive(),artifact:U.string().min(1),sourceDigest:U.string().regex(/^[a-f0-9]{64}$/)}))}).refine(e=>Object.keys(e.versions).length>0,"Reviewed Paywall Versions are required");var Uf={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},zo=ee.string().regex(/^[a-f0-9]{64}$/),No=ee.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Vf=Se.extend({environmentId:ee.uuid()}),cl=ee.strictObject({features:ee.array(ee.string()).max(500),experiments:ee.record(ee.uuid(),ee.array(ee.string()).max(20)),savedGroups:ee.array(ee.string()).max(1e3)}),Uo=ee.strictObject({kind:ee.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:ee.number().int().positive(),url:ee.string().min(1).max(2048),sha256:zo,byteLength:ee.number().int().positive().max(Uf.maxArtifactBytes),generation:zo.optional()}),Lf=ee.strictObject({state:ee.enum(["active","paused","archived"]),controlRevision:No,evaluationMode:ee.enum(["local","remote"]),evaluationRevision:No,currentVersionId:ee.uuid(),versions:ee.record(ee.uuid(),ee.strictObject({artifact:ee.string(),dependencies:cl,definitionDigest:On.optional(),couponDigests:ee.record(ee.uuid(),On).optional()}))}),bv=ee.strictObject({kind:ee.literal("sdk_configuration"),schemaVersion:ee.literal(1),scope:Vf,revision:No,generation:zo,policy:ee.strictObject({refreshIntervalSeconds:ee.number().positive().max(15),maxControlAgeSeconds:ee.number().positive().max(60)}),gb:ee.strictObject({features:ee.string().nullable(),pageExperiments:ee.string().nullable()}),artifacts:ee.record(ee.string(),Uo),funnels:ee.record(ee.uuid(),Lf),paywalls:ee.record(ee.uuid(),sl).optional()}).superRefine((e,t)=>{let n=(r,i)=>{r!==null&&e.artifacts[r]?.kind!==i&&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 i of Object.values(r.versions))n(i.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 i of Object.values(r.versions))n(i.artifact,"funnel")}});function Fo(e){if(Array.isArray(e))return`[${e.map(Fo).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)}:${Fo(r)}`).join(",")}}`;let t=JSON.stringify(e);if(t===void 0)throw new Error("Configuration must contain JSON values");return t}function $f(e){return gr(br(typeof e=="string"?new TextEncoder().encode(e):e))}function yv(e){return $f(Fo(e))}function xv(e,t){for(let a of Object.values(e.references))if(a.type==="flag"&&(!Object.hasOwn(t.features,a.key)||t.remoteFeatures.includes(a.key))||a.type==="experiment"&&!Object.hasOwn(t.experiments,a.id)||a.type==="saved_group"&&!Object.hasOwn(t.savedGroups,a.id))throw new Error("Funnel dependency is absent from GB public delivery");let n=ai(e,{...t,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),r=new Set(t.remoteFeatures);for(let a of e.graph.nodes){let c=a.type==="feature"?a.featureKey:a.type==="end"&&a.output?.type==="feature"?a.output.featureKey:a.type==="output"&&a.value.type==="feature"?a.value.featureKey:void 0;if(!c)continue;let u=n.features[c],p=a.type==="feature"?e.variables[a.writes.value]:e.outputSchema;if(!u||!p)throw new Error("Required public Feature declaration is unavailable");if([u.defaultValue,...(u.rules??[]).flatMap(O=>[...Object.hasOwn(O,"force")?[O.force]:[],...O.variations??[],...(O.tracks??[]).flatMap(z=>z.experiment.variations)])].some(O=>O===void 0||!at(p,O)))throw new Error("GB Feature values violate the Funnel type contract")}let i=new Set,o=a=>{for(let c of Pt(a)){if(i.has(c))continue;let u=t.savedGroups[c];if(!u)throw new Error("Required public Saved Group is unavailable");i.add(c),!Array.isArray(u)&&u.type==="condition"&&o(u.condition)}};for(let a of e.graph.nodes)if(a.type==="condition")for(let c of a.cases)o(c.condition);for(let a of Object.values(n.features))for(let c of a.rules??[]){o(c.condition);for(let u of[...c.parentConditions??[],...(c.tracks??[]).flatMap(p=>p.experiment.parentConditions??[])]){if(r.has(u.id)||!t.features[u.id])throw new Error("Local Funnel requires public Local prerequisites");o(u.condition)}for(let u of c.tracks??[])o(u.experiment.condition)}for(let a of Object.values(n.experiments)){o(a.condition);for(let c of a.parentConditions??[]){if(r.has(c.id)||!t.features[c.id])throw new Error("Local Funnel requires public Local prerequisites");o(c.condition)}}for(let a of e.graph.nodes)if(a.type==="split"){let c=n.experiments[a.experimentId];if(!c)throw new Error("Local Funnel requires a public Experiment");for(let u=0;u<c.variations.length;u++){let p=c.meta?.[u]?.key??String(u);if(!a.routes[p])throw new Error("Experiment variation has no declared Funnel route")}}return cl.parse({features:Object.keys(n.features).sort(),experiments:Object.fromEntries(Object.entries(n.experiments).map(([a,c])=>[a,c.variations.map((u,p)=>c.meta?.[p]?.key??String(p))])),savedGroups:[...i].sort()})}function Sv(e){return zt.parse(e)}var ul=Te.strictObject({...bn,selector:Te.discriminatedUnion("type",[Te.strictObject({type:Te.literal("paywall"),paywallId:Te.uuid()}),Te.strictObject({type:Te.literal("version"),versionId:Te.uuid()})]),customerId:Te.uuid().optional(),commerce:xr,locale:Te.string().min(1).max(35),requirement:ln.optional()}),ir=Te.strictObject({id:Te.uuid(),paywallId:Te.uuid(),version:Te.number().int().positive(),document:In.omit({requirement:!0,offeringId:!0}),offering:Te.strictObject({id:Te.uuid()}),content:Te.strictObject({environmentId:Te.uuid(),offeringVersionId:Te.uuid(),artifact:Uo.refine(e=>e.kind==="paywall"&&e.formatVersion===1)}).optional(),capabilities:pn,check:qn.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"})}),or=Te.strictObject(ir.shape).omit({document:!0,offering:!0}).extend({content:ir.shape.content.unwrap()});function Ev(e,t){let n=al.parse(t);if(n.offeringVersionId!==e.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let r=structuredClone(e.capabilities);for(let[i,o]of Object.entries(n.catalog)){let a=r.plans[i],c=o.channels.stripe?.prices.find(u=>u.currency===a?.currency);a&&c&&Object.assign(a,{amountMinor:c.amountMinor,interval:o.interval,intervalCount:o.intervalCount,...o.prepaid?.length?{prepaid:o.prepaid}:{}})}return ir.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 He}from"zod";var ll={requestId:He.uuid(),sourceId:He.uuid(),expectedAvailable:un},pl=He.discriminatedUnion("action",[He.strictObject({...ll,action:He.enum(["add","subtract","set_remaining"]),amount:Oe}),He.strictObject({...ll,action:He.literal("edit"),granted:Oe,expiresAt:He.iso.datetime({offset:!0}).nullable(),nextResetAt:He.iso.datetime({offset:!0}).nullable(),expectedRevision:He.number().int().nonnegative()})]),Vo=He.strictObject({sourceId:He.uuid(),available:un,held:un,spent:un,adjustmentGrantId:He.uuid().nullable()}),dl=Vo.extend({granted:un,expiresAt:He.iso.datetime({offset:!0}).nullable(),nextResetAt:He.iso.datetime({offset:!0}).nullable(),revision:He.number().int().nonnegative()});import{z as it}from"zod";var ml=it.discriminatedUnion("action",[it.object({action:it.literal("upsert"),externalId:it.string().min(1).max(128),name:it.string().trim().min(1).max(80)}).strict(),it.object({action:it.literal("archive"),entityId:it.uuid()}).strict()]),fl=it.object({id:it.uuid(),externalId:it.string().min(1).max(128),name:it.string().min(1).max(80),archived:it.boolean()}).strict();import{z as Le}from"zod";import{z as nn}from"zod";var hl=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],Al=nn.string().regex(/.+\/.+/),Lo=nn.number().min(-100),tn=nn.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),Gf=nn.strictObject({input:tn,output:tn,cache_read:tn.optional(),cache_write:tn.optional(),reasoning:tn.optional(),input_audio:tn.optional(),output_audio:tn.optional()}),$o=(e,t)=>nn.record(e,t).refine(n=>Object.keys(n).length<=100,"At most 100 AI overrides"),Uv=nn.strictObject({defaultMarkup:Lo,providerMarkups:$o(nn.string().min(1),Lo),modelMarkups:$o(Al,Lo),customModels:$o(Al,Gf.partial())});import{z as H}from"zod";var rn=H.iso.datetime({offset:!0}),Nt=H.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,12})?$/),Kf=H.discriminatedUnion("kind",[H.object({kind:H.literal("absolute"),from:rn,to:rn}).strict(),H.object({kind:H.literal("last_days"),days:H.union([H.literal(1),H.literal(7),H.literal(30),H.literal(90)])}).strict(),H.object({kind:H.literal("billing_cycles"),membershipId:H.uuid(),count:H.number().int().min(1).max(12),includeCurrent:H.boolean()}).strict()]),gl=H.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"),Hf=H.object({key:H.string().regex(/^[a-z][a-z0-9_]{0,63}$/),values:H.array(H.string().max(120)).min(1).max(20).refine(e=>new Set(e).size===e.length)}).strict(),on=H.object({range:Kf,timezone:gl,filterBy:H.array(Hf).max(5).refine(e=>new Set(e.map(t=>t.key)).size===e.length),interval:H.enum(["hour","day","week","month"]),internal_feature_id:H.uuid().nullable(),entityId:H.uuid().nullable(),topN:H.number().int().min(1).max(50).nullable(),groupBy:H.union([H.enum(["customer","entity","entitlement","source","resource","dimension","plan"]),H.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:H.object({bucket:rn,group:H.string().max(240),isOther:H.boolean(),internal_feature_id:H.uuid(),resourceId:H.uuid()}).strict().nullable(),limit:H.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)"})}),bl=H.object({from:rn,to:rn,interval:H.enum(["hour","day","week","month"]),timezone:gl,rows:H.array(H.object({bucket:rn,group:H.string().max(240),isOther:H.boolean(),internal_feature_id:H.uuid(),resourceId:H.uuid(),consumedUnits:Nt,refundedUnits:Nt,reservedUnits:Nt,charged:Nt,refunded:Nt,reserved:Nt,netUnits:Nt,netCharged:Nt}).strict()).max(100),nextCursor:H.object({bucket:rn,group:H.string().max(240),isOther:H.boolean(),internal_feature_id:H.uuid(),resourceId:H.uuid()}).strict().nullable()}).strict();var kn=Le.string().regex(/^(0|[1-9]\d{0,29})$/),yl=Le.string().regex(/^(0|[1-9]\d{0,29})(\.\d{1,18})?$/),Go=Le.strictObject({bucket:Le.iso.datetime({offset:!0}),group:Le.string().max(240),isOther:Le.boolean(),internal_feature_id:Le.uuid()}),xl=Le.strictObject({...on.shape,groupBy:Le.union([Le.enum(["customer","entity","entitlement"]),Le.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:Go.nullable()}).superRefine((e,t)=>{let n=on.safeParse({...e,after:null});if(!n.success)for(let r of n.error.issues)t.addIssue({code:"custom",path:r.path,message:r.message})}),Sl=Le.strictObject({from:Le.iso.datetime({offset:!0}),to:Le.iso.datetime({offset:!0}),interval:on.shape.interval,timezone:on.shape.timezone,rows:Le.array(Le.strictObject({...Go.shape,eventCount:kn,units:yl,tokenEventCount:kn,tokens:Le.strictObject(Object.fromEntries(hl.map(e=>[e,kn]))),totalTokens:kn,providerCostEventCount:kn,providerCostUsd:yl,invalidTelemetryEventCount:kn})).max(100),nextCursor:Go.nullable()});import{z as Re}from"zod";var vl=Re.object({requestId:Re.uuid(),items:Re.array(Re.object({customerId:Re.uuid(),command:Mn.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"),Il=Re.object({batchId:Re.uuid(),after:Re.number().int().min(-1).max(999),limit:Re.number().int().min(1).max(100)}).strict(),Ol=Re.object({batchId:Re.uuid(),status:Re.enum(["queued","complete"]),total:Re.number().int().min(1).max(1e3),processed:Re.number().int().min(0).max(1e3),items:Re.array(Re.object({position:Re.number().int().min(0).max(999),customerId:Re.uuid(),idempotencyKey:Re.string().min(1).max(120),status:Re.enum(["queued","accepted","rejected","failed"]),receipt:Bn.nullable(),errorCode:Re.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:Re.number().int().min(0).max(999).nullable()}).strict();import{z as h}from"zod";var Zf=h.enum(["percentage_discount","fixed_discount","free_product","invoice_credits","feature_grant"]),wl=h.enum(["draft","active","paused","archived"]),jl=h.string().min(1).max(256),_l=h.array(jl).max(50).refine(e=>new Set(e).size===e.length,"Duplicate products"),Qf=h.strictObject({duration:h.enum(["day","week","month","year"]),length:h.number().int().min(1).max(3660)}),Jf=h.strictObject({internal_feature_id:h.uuid(),allowance:h.number().nonnegative().max(1e15).nullable(),expiry:Qf.nullable()}),Wf=h.discriminatedUnion("type",[h.strictObject({type:h.literal("feature_grant"),grants:h.array(Jf).min(1).max(100).refine(e=>new Set(e.map(t=>t.internal_feature_id)).size===e.length,"Duplicate entitlement grants")}),h.strictObject({type:h.literal("free_product"),productId:jl,duration:nt}),h.strictObject({type:h.literal("invoice_credits"),amount:h.number().positive().max(1e8),duration:nt,rollover:h.boolean(),productIds:_l})]),Xf=h.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),Pl=h.object({key:Xf,name:h.string().trim().min(1).max(80),configuration:Wf}).strict(),Cl=h.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),Ko=h.object({code:Cl,maxUses:h.number().int().min(1).max(1e6).nullable(),firstPurchaseOnly:h.boolean()}).strict(),kl=h.object({key:h.string().regex(/^[a-z][a-z0-9_]{0,63}$/),name:h.string().trim().min(1).max(80),rewardId:h.uuid(),redeemOn:h.enum(["customer_creation","checkout"]),receivedBy:h.enum(["referrer","all"]),maxRedemptions:h.number().int().min(1).max(1e6).nullable(),productIds:_l,excludeTrial:h.boolean()}).strict().refine(e=>e.redeemOn==="checkout"||e.productIds.length===0&&!e.excludeTrial,"Purchase restrictions require checkout trigger"),Rl={id:h.uuid(),projectId:h.uuid(),environmentId:h.uuid(),revision:h.number().int().nonnegative(),status:wl,createdAt:h.iso.datetime({offset:!0}),updatedAt:h.iso.datetime({offset:!0})},Yf=Pl.extend(Rl).strict(),eA=kl.safeExtend(Rl).strict(),t0=h.strictObject({id:h.uuid(),key:h.string(),name:h.string(),type:Zf,status:wl}),n0=h.discriminatedUnion("action",[h.object({action:h.literal("save"),id:h.uuid().nullable(),revision:h.number().int().nonnegative(),input:Pl}).strict(),h.object({action:h.enum(["activate","pause","resume","archive","delete"]),id:h.uuid(),revision:h.number().int().nonnegative()}).strict()]),r0=h.discriminatedUnion("action",[h.object({action:h.literal("save"),id:h.uuid().nullable(),revision:h.number().int().nonnegative(),input:kl}).strict(),h.object({action:h.enum(["activate","pause","resume","archive","delete"]),id:h.uuid(),revision:h.number().int().nonnegative()}).strict()]),El=h.object({id:h.uuid(),rewardId:h.uuid(),programId:h.uuid().nullable(),customerId:h.uuid(),referrerId:h.uuid().nullable(),status:h.enum(["pending","applied","unavailable"]),result:h.record(h.string(),h.unknown()).nullable(),createdAt:h.iso.datetime({offset:!0})}).strict(),Dl=h.object({code:Cl,requestId:h.uuid()}).strict(),Tl=h.strictObject({redemptionId:h.uuid(),currency:ae,requestId:h.uuid(),accepted:h.literal(!0)}),tA=h.strictObject({type:h.literal("checkout"),orderId:h.uuid(),productVersionId:h.uuid(),currency:ae,duration:nt,renewalAmountMinor:h.number().int().positive().max(1e8),status:h.enum(["created","pending","trialing","paid","cancelled","failed"]),url:h.url().nullable()}),Ml=h.discriminatedUnion("type",[tA,h.strictObject({type:h.literal("subscription"),operationId:h.uuid(),membershipId:h.uuid(),productVersionId:h.uuid(),currency:ae,duration:nt,renewalAmountMinor:h.number().int().positive().max(1e8),status:h.enum(["pending","running","applied","failed"])})]),Bl=h.object({programId:h.uuid(),requestId:h.uuid()}).strict(),ql=h.object({id:h.uuid(),programId:h.uuid(),code:Ko.shape.code,createdAt:h.iso.datetime({offset:!0})}).strict(),i0=h.object({rows:h.array(Yf).max(100),nextCursor:h.uuid().nullable()}).strict(),o0=h.object({rows:h.array(eA).max(100),nextCursor:h.uuid().nullable()}).strict(),nA=Ko.extend({id:h.uuid(),redemptions:h.number().int().nonnegative()}).strict(),rA=h.strictObject({id:h.uuid(),programId:h.uuid().nullable(),customerId:h.uuid().nullable(),referrerId:h.uuid().nullable(),code:h.string().nullable(),status:h.enum(["pending","triggered","applied"]),createdAt:h.iso.datetime({offset:!0})}),a0=h.object({codes:h.array(nA).max(100),redemptions:h.array(rA).max(100),customers:h.record(h.uuid(),h.string()),codesCursor:h.uuid().nullable(),redemptionsCursor:h.uuid().nullable()}).strict(),s0=h.discriminatedUnion("action",[h.object({action:h.literal("create"),rewardId:h.uuid(),revision:h.number().int().nonnegative(),input:Ko}).strict(),h.object({action:h.literal("remove"),rewardId:h.uuid(),revision:h.number().int().nonnegative(),codeId:h.uuid()}).strict()]);import{z as m}from"zod";import{z as T}from"zod";var yt={repositories:20,branches:4,keys:2e3,references:1e4,referencesPerKey:2e3,reportBytes:1048576,files:1e4,sourceBytes:1e8},ar=e=>new Set(e).size===e.length,Ho=T.string().regex(/^[a-zA-Z0-9_.:|-]{1,256}$/),iA=T.string().max(512).regex(/^[\w.-]+(?:\/[\w.-]+){1,5}$/).refine(e=>!e.split("/").some(t=>t==="."||t==="..")),sr=T.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"))),oA=T.string().min(1).max(512).refine(e=>!/[\\\u0000-\u001f\u007f]/.test(e)&&!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t==="..")),zl=T.string().min(1).max(256).regex(/^[a-zA-Z0-9_./*?-]+$/).refine(e=>!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t===".."));var Nl=T.strictObject({id:T.uuid(),repo:iA,platform:T.enum(["github","gitlab","bitbucket"]),branches:T.array(sr).min(1).max(4).refine(ar),workflow:T.string().regex(/^\.github\/workflows\/[a-zA-Z0-9_-]+\.ya?ml$/),keyIds:T.array(T.uuid()).min(1).max(4).refine(ar),include:T.array(zl).min(1).max(16),exclude:T.array(zl).max(16),methods:T.array(T.string().regex(/^[a-zA-Z_$][\w$]{0,63}$/)).min(1).max(32).refine(ar),maxAgeHours:T.number().int().min(1).max(720)}),Fl=Nl.extend({revision:T.number().int().positive()}),l0=T.strictObject({repository:Nl,expectedRevision:T.number().int().min(0)}).refine(({repository:e})=>e.platform==="gitlab"||e.repo.split("/").length===2,{path:["repository","repo"]}),Ul=T.strictObject({repositoryId:T.uuid(),branch:sr}),aA=T.array(Ho).max(yt.keys).refine(ar),Vl=T.strictObject({repository:Fl.omit({keyIds:!0}),branch:sr,keys:aA,keySetHash:T.string().regex(/^[a-f0-9]{64}$/)}),sA=T.strictObject({filePath:oA,startingLineNumber:T.number().int().min(1).max(1e7)}),Zo=T.strictObject({protocol:T.literal(1),repositoryId:T.uuid(),branch:sr,workflow:T.string().max(200),configurationRevision:T.number().int().positive(),keySetHash:T.string().regex(/^[a-f0-9]{64}$/),commit:T.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),scanId:T.uuid(),runNumber:T.number().int().min(1).max(Number.MAX_SAFE_INTEGER),runAttempt:T.number().int().min(1).max(1e4),scannerVersion:T.literal("1"),scannedAt:T.iso.datetime({offset:!0}),coverage:T.strictObject({complete:T.literal(!0),files:T.number().int().min(0).max(yt.files),sourceBytes:T.number().int().min(0).max(yt.sourceBytes),unresolvedCalls:T.number().int().min(0).max(1e6),unsupportedFiles:T.number().int().min(0).max(yt.files)}),features:T.array(T.strictObject({key:Ho,refs:T.array(sA).max(yt.referencesPerKey)})).max(yt.keys)}).superRefine((e,t)=>{ar(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)>yt.references&&t.addIssue({code:"custom",path:["features"],message:"Reference budget exceeded"})}),Qo=T.strictObject({scanId:T.uuid(),commit:T.string(),receivedAt:T.string(),references:T.number().int().nonnegative(),removedReferences:T.number().int().nonnegative()}),cA=Qo.extend({repositoryId:T.uuid(),branch:sr,workflow:T.string(),digest:T.string(),configurationRevision:T.number().int().positive(),runNumber:T.number().int().positive(),runAttempt:T.number().int().positive(),scannedAt:T.string(),keySetHash:T.string(),coverage:Zo.shape.coverage}),uA=T.strictObject({repositories:T.array(Fl).max(yt.repositories),scans:T.array(cA).max(yt.repositories*yt.branches)}),lA=T.strictObject({key:Ho,references:T.number().int().nonnegative(),coveredTargets:T.number().int().nonnegative(),expiredTargets:T.number().int().nonnegative(),uncertainTargets:T.number().int().nonnegative()}),p0=T.strictObject({available:T.boolean().default(!0),settings:uA,expectedTargets:T.number().int().min(0).max(80),features:T.array(lA).max(2001),truncated:T.boolean()});import{z as Ze}from"zod";var $l={customerId:Ze.uuid(),eventId:Ze.string().trim().min(1).max(200),grantId:Ze.uuid(),occurredAt:Ze.iso.datetime({offset:!0})},Gl=Ze.strictObject({...$l,productVersionId:Ze.uuid(),subscriptionId:Ze.string().trim().min(1).max(255)}),Kl=Ze.strictObject({...$l,merchandiseId:Ze.uuid()}),Hl=Ze.union([Gl,Kl]),Ll={id:Ze.uuid(),couponId:Ze.uuid(),status:Ze.literal("redeemed"),source:Ze.literal("merchant"),recordedAt:Ze.iso.datetime({offset:!0})},Zl=Ze.union([Gl.extend(Ll),Kl.extend(Ll)]);import{z as F}from"zod";var Jo=F.strictObject({name:F.string().trim().min(1).max(255),memo:F.string().max(1e4).nullable().optional(),footer:F.string().max(1e4).nullable().optional(),net_terms_days:F.number().int().positive().nullable().optional()}),pA=Jo.extend({id:F.string().min(1).max(255),created_at:F.number().nullable()}),Ql=F.strictObject({items:F.array(pA).max(50),nextCursor:F.uuid().nullable()}),g0=F.discriminatedUnion("action",[F.strictObject({action:F.literal("create"),requestId:F.uuid(),values:Jo}),F.strictObject({action:F.literal("update"),id:F.string().min(1).max(255),values:Jo}),F.strictObject({action:F.literal("delete"),id:F.string().min(1).max(255)})]),Jl=F.discriminatedUnion("action",[F.strictObject({action:F.literal("create"),requestId:F.uuid(),params:xn}),F.strictObject({action:F.enum(["finalize","send","pay","void"]),requestId:F.uuid(),invoiceId:F.uuid()}),F.strictObject({action:F.literal("reissue"),requestId:F.uuid(),invoiceId:F.uuid(),params:ro})]),Wo=F.strictObject({id:F.uuid(),customerId:F.uuid(),providerInvoiceId:F.string().nullable(),status:F.enum(["draft","open","paid","void","uncollectible"]),currency:F.string(),totalMinor:F.string().regex(/^-?\d+$/),paidMinor:F.string().regex(/^\d+$/),refundedMinor:F.string().regex(/^\d+$/),hostedInvoiceUrl:F.url().nullable(),createdAt:F.number(),collectionMethod:F.enum(["send_invoice","charge_automatically"]).nullable()}),Wl=Wo.extend({lines:F.array(F.strictObject({id:F.uuid(),description:F.string(),amountMinor:F.string().regex(/^-?\d+$/),netAmountMinor:F.string().regex(/^-?\d+$/),quantity:F.number().nullable(),periodStart:F.number().nullable(),periodEnd:F.number().nullable()})).max(1e3)}),cr=F.strictObject({taskId:F.uuid(),status:F.enum(["ready","running","done","dead"]),invoice:Wo.nullable(),errorCode:F.string().nullable()}),Xl=F.strictObject({items:F.array(Wo).max(50),nextCursor:F.uuid().nullable(),operations:F.array(cr).max(50),operationsLimited:F.boolean()});var dA=m.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"]),Yl={scope:Se,permissions:m.array(dA),expiresAt:m.iso.datetime().nullable()},cI=m.discriminatedUnion("kind",[m.object({...Yl,kind:m.literal("server"),keyId:m.string().min(1)}),m.object({...Yl,kind:m.literal("customer"),customerId:m.string().min(1),identityKind:m.enum(["identified","guest"]),expiresAt:m.iso.datetime()})]),P=m.object({requestId:m.uuid(),scope:Se}).strict(),mA=$u.safeExtend({fingerprint:ti.optional()}).strict(),fA=P.extend({customer:Pn,created:m.boolean()});function ep(){return P.extend({offer:Ln.nullable(),reason:Gs.nullable()})}var _={sendMessage:{method:"POST",path:"messaging/send",permission:"messaging:write",audience:"server",request:jc,response:P.extend({message:m.object({messageId:m.uuid(),channel:Qn,acceptedAt:m.iso.datetime({offset:!0}),status:m.enum(["accepted","sending","completed","canceled"]),replayed:m.boolean()})})},readMessage:{method:"POST",path:"messaging/read",permission:"messaging:write",audience:"server",request:m.strictObject({messageId:m.uuid()}),response:P.extend({message:m.object({id:m.uuid(),channel:Qn,status:m.enum(["accepted","sending","completed","canceled"]),deliveries:m.array(m.object({id:m.uuid(),status:Pc,attempts:m.number().int().nonnegative(),receipts:m.array(m.object({kind:Cc,occurredAt:m.iso.datetime({offset:!0}).nullable()}))}))})})},bindPushInstallation:{method:"POST",path:"push/installations/bind",permission:"messaging:write",audience:"customer",request:Rs,response:P.extend({installation:Rr})},readPushInstallation:{method:"POST",path:"push/installations/read",permission:"messaging:write",audience:"customer",request:Es,response:P.extend({installation:Rr})},updatePushAddress:{method:"POST",path:"push/installations/address",permission:"messaging:write",audience:"customer",request:kr,response:P.extend({installation:Rr})},readMessagingPreference:{method:"POST",path:"messaging/preferences/read",permission:"messaging:write",audience:"customer",request:m.strictObject({channel:Qn}),response:P.extend({preference:Fi})},setMessagingPreference:{method:"POST",path:"messaging/preferences/set",permission:"messaging:write",audience:"customer",request:_c,response:P.extend({preference:Fi})},listInvoiceTemplates:{method:"POST",path:"invoices/templates",permission:"billing:read",audience:"server",request:m.strictObject({cursor:m.uuid().optional()}),response:P.extend({templates:Ql})},previewInvoice:{method:"POST",path:"invoices/preview",permission:"billing:write",audience:"server",request:m.strictObject({customerId:m.uuid(),params:xn}),response:P.extend({preview:io})},createInvoice:{method:"POST",path:"invoices/create",permission:"billing:write",audience:"server",request:m.strictObject({customerId:m.uuid(),requestId:m.uuid(),params:xn}).refine(e=>e.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:P.extend({operation:cr})},manageInvoice:{method:"POST",path:"invoices/manage",permission:"billing:write",audience:"server",request:m.strictObject({customerId:m.uuid(),command:Jl}).refine(e=>e.command.action!=="create"||e.command.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:P.extend({operation:cr})},readInvoiceOperation:{method:"POST",path:"invoices/operations/read",permission:"billing:read",audience:"server",request:m.strictObject({customerId:m.uuid(),taskId:m.uuid()}),response:P.extend({operation:cr})},listInvoices:{method:"POST",path:"invoices/list",permission:"billing:read",audience:"server",request:m.strictObject({customerId:m.uuid(),cursor:m.uuid().optional()}),response:P.extend({invoices:Xl})},getInvoice:{method:"POST",path:"invoices/read",permission:"billing:read",audience:"server",request:m.strictObject({customerId:m.uuid(),invoiceId:m.uuid()}),response:P.extend({invoice:Wl})},getCodeReferenceConfig:{method:"POST",path:"code-references/config",permission:"code-references:read",audience:"server",request:Ul,response:P.extend({config:Vl})},submitCodeReferences:{method:"POST",path:"code-references",permission:"code-references:write",audience:"server",request:Zo,response:P.extend({receipt:Qo})},getFeatures:{method:"GET",path:"features",permission:"features:read",audience:"mixed",request:m.strictObject({}),response:P.extend({payload:go})},evaluateFeatures:{method:"POST",path:"features/evaluate",permission:"features:read",audience:"mixed",request:_u,response:P.merge(Pu)},trackEvents:{method:"POST",path:"events",permission:"events:write",audience:"mixed",request:Cu,response:P.merge(ku)},readBalanceSource:{method:"POST",path:"balances/source/read",permission:"credits:read",audience:"server",request:m.strictObject({customerId:m.uuid(),sourceId:m.uuid()}),response:P.extend({balance:dl})},adjustBalance:{method:"POST",path:"balances/source/adjust",permission:"credits:manage",audience:"server",request:m.strictObject({customerId:m.uuid(),command:pl}),response:P.extend({balance:Vo})},readAiPricing:{method:"POST",path:"ai/pricing/read",permission:"credits:read",audience:"server",request:m.strictObject({internal_feature_id:m.uuid(),customerId:m.uuid().optional(),entityId:m.uuid().optional()}).refine(e=>!e.entityId||!!e.customerId,"Entity pricing requires a customer"),response:P.extend({internal_feature_id:m.uuid(),config:Gi,model_markups:Mr})},readUsage:{method:"POST",path:"usage/read",permission:"credits:read",audience:"server",request:m.strictObject({customerId:m.uuid(),query:Fa}),response:P.extend({usage:Oi})},setUsage:{method:"POST",path:"usage/set",permission:"credits:manage",audience:"server",request:m.strictObject({customerId:m.uuid(),command:Ua}),response:P.extend({usage:Oi})},manageBalanceGrant:{method:"POST",path:"balances/grants/manage",permission:"credits:manage",audience:"server",request:m.strictObject({customerId:m.uuid(),command:hc}),response:P.extend({grant:Wi})},listBalanceGrants:{method:"POST",path:"balances/grants/list",permission:"credits:read",audience:"server",request:gc,response:P.extend({grants:bc})},restoreNativePurchase:{method:"POST",path:"subscriptions/native/restore",permission:"billing:write",audience:"mixed",request:m.union(bu.options.map(e=>e.extend({customerId:m.uuid().optional(),customerToken:m.string().regex(Rt).optional()}))),response:P.extend({operation:yu})},setupPayment:{method:"POST",path:"billing/setup-payment",permission:"billing:write",audience:"mixed",request:su.extend({customerId:m.uuid().optional()}),response:P.extend({setup:uo})},readPaymentSetup:{method:"POST",path:"billing/payment-setup",permission:"billing:read",audience:"mixed",request:cu.extend({customerId:m.uuid().optional()}),response:P.extend({setup:uo})},previewSubscriptionBatch:{method:"POST",path:"subscriptions/batches/preview",permission:"billing:write",audience:"server",request:iu.safeExtend({customerId:m.uuid()}),response:P.extend({batch:Xn})},confirmSubscriptionBatch:{method:"POST",path:"subscriptions/batches/confirm",permission:"billing:write",audience:"server",request:Vr.extend({customerId:m.uuid()}),response:P.extend({batch:Xn})},readSubscriptionBatch:{method:"POST",path:"subscriptions/batches/read",permission:"billing:read",audience:"server",request:Vr.extend({customerId:m.uuid()}),response:P.extend({batch:Xn})},abandonSubscriptionBatch:{method:"POST",path:"subscriptions/batches/abandon",permission:"billing:write",audience:"server",request:Vr.extend({customerId:m.uuid()}),response:P.extend({batch:Xn})},manageSubscriptionTrial:{method:"POST",path:"subscriptions/trials/manage",permission:"billing:write",audience:"server",request:m.discriminatedUnion("action",[Lr.options[0].extend({customerId:m.uuid()}),Lr.options[1].extend({customerId:m.uuid()}),Lr.options[2].extend({customerId:m.uuid()})]),response:P.extend({trial:co})},readSubscriptionTrial:{method:"POST",path:"subscriptions/trials/read",permission:"billing:read",audience:"server",request:ou.extend({customerId:m.uuid()}),response:P.extend({trial:co})},listSubscriptions:{method:"POST",path:"subscriptions/list",permission:"billing:read",audience:"server",request:Kr,response:P.extend({subscriptions:Au})},listPurchases:{method:"POST",path:"purchases/list",permission:"billing:read",audience:"server",request:Kr,response:P.extend({purchases:hu})},listSubscriptionConflicts:{method:"POST",path:"subscriptions/conflicts/list",permission:"billing:read",audience:"server",request:du,response:P.extend({conflicts:gu})},retrySubscriptionConflict:{method:"POST",path:"subscriptions/conflicts/retry",permission:"billing:write",audience:"server",request:mu,response:P.extend({resolution:fu})},verifySubscriptions:{method:"POST",path:"subscriptions/verify",permission:"billing:read",audience:"server",request:lu,response:P.extend({verification:pu})},previewAttach:{method:"POST",path:"subscriptions/preview-attach",permission:"billing:read",audience:"mixed",request:Qc.safeExtend({...bn,customerId:m.uuid().optional()}),response:P.extend({quote:Jn})},recordBillingEvent:{method:"POST",path:"billing/events/record",permission:"billing:write",audience:"server",request:ls,response:P.extend({record:ps})},attach:{method:"POST",path:"subscriptions/attach",permission:"billing:write",audience:"mixed",request:Wt.extend({customerId:m.uuid().optional(),intent:m.enum(["confirm","cancel"]).optional()}),response:P.extend({operation:Sn})},readSubscriptionOperation:{method:"POST",path:"subscriptions/operations/read",permission:"billing:read",audience:"mixed",request:Wt.extend({customerId:m.uuid().optional()}),response:P.extend({operation:Sn})},previewUpdate:{method:"POST",path:"subscriptions/preview-update",permission:"billing:read",audience:"mixed",request:Xc.safeExtend({customerId:m.uuid().optional()}),response:P.extend({quote:eu})},update:{method:"POST",path:"subscriptions/update",permission:"billing:write",audience:"mixed",request:Wt.extend({customerId:m.uuid().optional(),intent:m.enum(["confirm","cancel"]).optional()}),response:P.extend({operation:ao})},readSubscriptionUpdate:{method:"POST",path:"subscriptions/updates/read",permission:"billing:read",audience:"mixed",request:Wt.extend({customerId:m.uuid().optional()}),response:P.extend({operation:ao})},previewRefund:{method:"POST",path:"subscriptions/refunds/preview",permission:"billing:read",audience:"server",request:tu.safeExtend({customerId:m.uuid()}),response:P.extend({quote:ru})},refund:{method:"POST",path:"subscriptions/refunds/confirm",permission:"billing:write",audience:"server",request:Wt.extend({customerId:m.uuid()}),response:P.extend({operation:Ur})},readRefund:{method:"POST",path:"subscriptions/refunds/read",permission:"billing:read",audience:"server",request:Wt.extend({customerId:m.uuid()}),response:P.extend({operation:Ur})},readBillingControls:{method:"POST",path:"billing/controls/read",permission:"billing:read",audience:"customer",request:oc,response:P.extend({controls:Ji})},prepareBillingAuthorization:{method:"POST",path:"billing/authorizations/prepare",permission:"billing:write",audience:"customer",request:Xs,response:P.extend({prepared:ec})},confirmBillingAuthorization:{method:"POST",path:"billing/authorizations/confirm",permission:"billing:write",audience:"customer",request:tc,response:P.extend({authorization:qr})},setBillingCoupons:{method:"POST",path:"billing/coupons",permission:"billing:write",audience:"customer",request:uc,response:P.extend({coupons:lc})},revokeBillingAuthorization:{method:"POST",path:"billing/authorizations/revoke",permission:"billing:write",audience:"customer",request:nc,response:P.extend({authorization:qr})},listBillingInvoices:{method:"POST",path:"billing/invoices/read",permission:"billing:read",audience:"customer",request:sc,response:P.extend({invoices:cc})},confirmBillingAdjustment:{method:"POST",path:"billing/invoices/confirm-adjustment",permission:"billing:write",audience:"customer",request:ac,response:P.extend({invoice:Kn})},manageBillingLimits:{method:"POST",path:"billing/controls/manage",permission:"billing:write",audience:"server",request:m.object({customerId:m.uuid(),command:ic}).strict(),response:P.extend({controls:Ji})},manageUsageEntity:{method:"POST",path:"usage/entities",permission:"credits:manage",audience:"server",request:m.object({customerId:m.uuid(),command:ml}).strict(),response:P.extend({entity:fl})},readUsageAnalytics:{method:"POST",path:"usage/analytics",permission:"credits:read",audience:"server",request:m.strictObject({customerId:m.uuid().nullable(),query:xl}),response:P.extend({analytics:Sl})},readCreditAnalytics:{method:"POST",path:"credits/analytics",permission:"credits:read",audience:"server",request:m.object({customerId:m.uuid().nullable(),query:on}).strict(),response:P.extend({analytics:bl})},submitUsageBatch:{method:"POST",path:"usage/batch",permission:"credits:consume",audience:"server",request:vl,response:P.extend({batchId:m.uuid()})},readUsageBatch:{method:"POST",path:"usage/batch/read",permission:"credits:read",audience:"server",request:Il,response:P.extend({batch:Ol})},checkEntitlement:{method:"POST",path:"entitlements/check",permission:"entitlements:read",audience:"mixed",request:Ha.extend({customerId:m.string().min(1).optional()}),response:P.extend({check:qn})},resolveContent:{method:"POST",path:"content/resolve",permission:"content:read",audience:"mixed",request:m.strictObject({kind:Tt,selector:m.discriminatedUnion("type",[m.strictObject({type:m.literal("resource"),id:m.uuid()}),m.strictObject({type:m.literal("version"),id:m.uuid()})]),customerId:m.string().min(1).optional()}),response:P.extend({content:zi})},resolvePaywall:{method:"POST",path:"paywalls/resolve",permission:"entitlements:read",audience:"mixed",request:ul,response:P.extend({paywall:or})},resolveOffering:{method:"POST",path:"offerings/resolve",permission:"entitlements:read",audience:"mixed",request:m.strictObject({...bn,selector:Iu,customerId:m.string().min(1).optional(),commerce:xr,requirement:ln.optional()}),response:P.extend({offering:Ou,candidates:m.array(Za).max(20),availability:m.array(m.strictObject({productVersionId:m.uuid(),available:m.boolean(),reason:m.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:qn.nullable()})},readHoldings:{method:"POST",path:"customer-holdings",permission:"entitlements:read",audience:"mixed",request:m.object({customerId:m.uuid().optional(),entityId:m.uuid().optional()}).strict(),response:P.extend({holdings:Va})},readLedger:{method:"POST",path:"customer-ledger",permission:"credits:read",audience:"mixed",request:m.object({customerId:m.uuid().optional(),query:La}).strict(),response:P.extend({ledger:$a})},readBillingInvoice:{method:"POST",path:"billing/invoices/detail",permission:"billing:read",audience:"mixed",request:yc.extend({customerId:m.uuid().optional()}),response:P.extend({detail:xc})},readCreditStatement:{method:"POST",path:"credit-statements/read",permission:"credits:read",audience:"mixed",request:Xi.safeExtend({customerId:m.uuid().optional()}),response:P.extend({statement:Sc})},quoteBalance:{method:"POST",path:"balances/quote",permission:"credits:read",audience:"mixed",request:m.object({customerId:m.uuid().optional(),command:Mn.options[0]}).strict(),response:P.extend({quote:Na})},trackUsage:{method:"POST",path:"usage/track",permission:"credits:consume",audience:"server",request:m.strictObject({customerId:m.uuid(),command:m.union([m.strictObject({eventName:m.string().min(1),quantity:Oe.optional(),properties:It.optional(),entityId:m.uuid().optional(),idempotencyKey:m.string().min(1).max(120)}),m.strictObject({internal_feature_id:m.uuid(),quantity:Oe.optional(),properties:It.optional(),entityId:m.uuid().optional(),idempotencyKey:m.string().min(1).max(120)})])}),response:P.extend({receipts:m.array(Bn).min(1)})},mutateBalance:{method:"POST",path:"balances/execute",permission:"credits:consume",audience:"server",request:m.object({customerId:m.uuid(),command:Mn.refine(e=>e.operation!=="quote","Use the quote endpoint for a read")}).strict(),response:P.extend({receipt:Bn})},redeemReward:{method:"POST",path:"rewards/redeem",permission:"offers:resolve",audience:"customer",request:Dl,response:P.extend({redemption:El})},createReferralCode:{method:"POST",path:"rewards/referral-code",permission:"offers:resolve",audience:"customer",request:Bl,response:P.extend({referralCode:ql})},claimRewardProduct:{method:"POST",path:"rewards/product/claim",permission:"offers:resolve",audience:"customer",request:Tl,response:P.extend({checkout:Ml})},readSeats:{method:"POST",path:"seats/list",permission:"customers:read",audience:"server",request:Ic,response:P.extend({seats:to})},manageSeat:{method:"POST",path:"seats/manage",permission:"billing:write",audience:"server",request:Oc,response:P.extend({seats:to})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:mA,response:fA},getCustomer:{method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:_o,response:P.extend({customer:Pn})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:Hu,response:P.extend(Zu.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:Ku,response:P.extend(Gu.shape)},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:m.object({customerId:m.uuid()}).strict(),response:P.extend(Et.shape)},refreshSession:{method:"POST",path:"customer-sessions/refresh",permission:"sessions:create",audience:"refresh",request:m.strictObject({}),response:P.extend(Et.shape)},revokeSessions:{method:"POST",path:"customer-sessions/revoke",permission:"sessions:create",audience:"server",request:m.strictObject({customerId:m.uuid(),sessionId:m.uuid().optional()}),response:P.extend({revoked:m.number().int().nonnegative()})},createGuestCustomer:{method:"POST",path:"customers/guests",permission:"sessions:create",audience:"server",request:m.strictObject({guestToken:m.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),fingerprint:ti.optional()}),response:P.extend({customerId:m.uuid(),guestToken:m.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),guestExpiresAt:m.iso.datetime()})},resumeGuestSession:{method:"POST",path:"customers/guests/session",permission:"sessions:create",audience:"server",request:m.strictObject({guestToken:m.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/)}),response:P.extend(Et.shape)},claimGuestCustomer:{method:"POST",path:"customers/guests/claim",permission:"customers:write",audience:"server",request:m.strictObject({guestToken:m.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),externalUserId:m.string().trim().min(1).max(255).refine(e=>!e.startsWith("gg_guest_")),requestId:m.uuid()}),response:P.extend({customer:Pn,switched:m.boolean(),replayed:m.boolean()})},redeemCoupon:{method:"POST",path:"offers/redeem",permission:"offers:resolve",audience:"customer",request:m.strictObject({code:m.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),requestId:m.uuid()}),response:ep()},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:m.object({}).strict(),response:P.extend({offers:m.array(Ln)})},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"mixed",customerPermission:"offers:resolve",request:m.object({customerId:m.string().min(1).max(255).optional(),couponId:m.uuid(),...bn,requestId:m.uuid(),couponContentDigest:m.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),response:ep()},recordCouponRedemption:{method:"POST",path:"offers/redemptions",permission:"billing:write",audience:"server",request:Hl,response:P.extend({receipt:Zl})}},uI={sendMessage:_.sendMessage,readMessage:_.readMessage,bindPushInstallation:_.bindPushInstallation,readPushInstallation:_.readPushInstallation,updatePushAddress:_.updatePushAddress,readMessagingPreference:_.readMessagingPreference,setMessagingPreference:_.setMessagingPreference,listInvoiceTemplates:_.listInvoiceTemplates,previewInvoice:_.previewInvoice,createInvoice:_.createInvoice,manageInvoice:_.manageInvoice,readInvoiceOperation:_.readInvoiceOperation,listInvoices:_.listInvoices,getInvoice:_.getInvoice,getCodeReferenceConfig:_.getCodeReferenceConfig,submitCodeReferences:_.submitCodeReferences,getFeatures:_.getFeatures,evaluateFeatures:_.evaluateFeatures,trackEvents:_.trackEvents,setupPayment:_.setupPayment,readPaymentSetup:_.readPaymentSetup,previewSubscriptionBatch:_.previewSubscriptionBatch,confirmSubscriptionBatch:_.confirmSubscriptionBatch,readSubscriptionBatch:_.readSubscriptionBatch,abandonSubscriptionBatch:_.abandonSubscriptionBatch,manageSubscriptionTrial:_.manageSubscriptionTrial,readSubscriptionTrial:_.readSubscriptionTrial,listSubscriptions:_.listSubscriptions,listPurchases:_.listPurchases,listSubscriptionConflicts:_.listSubscriptionConflicts,retrySubscriptionConflict:_.retrySubscriptionConflict,readAiPricing:_.readAiPricing,readUsage:_.readUsage,setUsage:_.setUsage,previewRefund:_.previewRefund,refund:_.refund,readRefund:_.readRefund,previewUpdate:_.previewUpdate,update:_.update,readSubscriptionUpdate:_.readSubscriptionUpdate,restoreNativePurchase:_.restoreNativePurchase,verifySubscriptions:_.verifySubscriptions,previewAttach:_.previewAttach,attach:_.attach,readSubscriptionOperation:_.readSubscriptionOperation,manageBalanceGrant:_.manageBalanceGrant,readBalanceSource:_.readBalanceSource,adjustBalance:_.adjustBalance,listBalanceGrants:_.listBalanceGrants,readBillingControls:_.readBillingControls,prepareBillingAuthorization:_.prepareBillingAuthorization,confirmBillingAuthorization:_.confirmBillingAuthorization,setBillingCoupons:_.setBillingCoupons,revokeBillingAuthorization:_.revokeBillingAuthorization,listBillingInvoices:_.listBillingInvoices,confirmBillingAdjustment:_.confirmBillingAdjustment,manageBillingLimits:_.manageBillingLimits,createCustomer:_.createCustomer,getCustomer:_.getCustomer,listCustomers:_.listCustomers,updateCustomer:_.updateCustomer,createSession:_.createSession,refreshSession:_.refreshSession,revokeSessions:_.revokeSessions,createGuestCustomer:_.createGuestCustomer,resumeGuestSession:_.resumeGuestSession,claimGuestCustomer:_.claimGuestCustomer,checkEntitlement:_.checkEntitlement,resolveOffering:_.resolveOffering,resolveContent:_.resolveContent,resolvePaywall:_.resolvePaywall,readHoldings:_.readHoldings,readLedger:_.readLedger,readBillingInvoice:_.readBillingInvoice,readCreditStatement:_.readCreditStatement,quoteBalance:_.quoteBalance,trackUsage:_.trackUsage,mutateBalance:_.mutateBalance,manageUsageEntity:_.manageUsageEntity,readUsageAnalytics:_.readUsageAnalytics,readCreditAnalytics:_.readCreditAnalytics,submitUsageBatch:_.submitUsageBatch,readUsageBatch:_.readUsageBatch,listOffers:_.listOffers,grantOffer:_.grantOffer,recordCouponRedemption:_.recordCouponRedemption,redeemCoupon:_.redeemCoupon,redeemReward:_.redeemReward,createReferralCode:_.createReferralCode,claimRewardProduct:_.claimRewardProduct,readSeats:_.readSeats,manageSeat:_.manageSeat};import{z as Xo}from"zod";var ur=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function Yo(e,t,n){let r={},i,o,a,c="next",u;switch(e.type){case"entry":u=e.next;break;case"condition":{let p=e.cases.findIndex(b=>Ii(t.attributes??{},b.condition,t.savedGroups??{}));c=p<0?"default":`case:${p}`,u=p<0?e.default:e.cases[p].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new ur("Required GB Feature is unavailable");i=Tn(e.featureKey,t),a=i.value,Object.assign(r,Kt(e,{value:a})),u=e.next;break;case"split":{let p=n[e.experimentId];if(!p)throw new ur("Required GB Experiment is unavailable");if(o=Ma(p,t),a=o.value,c=o.inExperiment&&!o.passthrough&&typeof a=="string"?a:"notParticipating",u=c==="notParticipating"?e.notParticipating:e.routes[c],!u)throw new ur("Experiment Variation has no published route");break}case"offering":{let p=e.configuration.source==="fixed"?e.configuration.versionId:Tn(e.configuration.featureKey,t).value;a={type:"offering_version",id:Xo.uuid().parse(p)},Object.assign(r,Kt(e,{value:a})),u=e.next;break}case"coupon":case"coupons":a=e.type==="coupons"?e.couponIds.map(p=>({type:"reward",id:p})):{type:"reward",id:e.couponId},Object.assign(r,Kt(e,{value:a})),u=e.next;break}return{port:c,target:u,projections:r,...a===void 0?{}:{value:a},...i?{feature:i}:{},...o?{experiment:o}:{}}}function gI(e,t,n){Xo.uuid().parse(e),Xo.number().int().nonnegative().parse(t);let r=gr(br(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 k}from"zod";var Ft=k.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),AA=k.enum(["running","waiting","completed","closed","ineligible","failed"]),hA=k.discriminatedUnion("type",[wo,k.strictObject({type:k.literal("wait"),receiptId:k.uuid(),kind:k.enum(["timer","event","operation"]),deadline:k.iso.datetime({offset:!0}).nullable(),eventName:Ft.optional()}),k.strictObject({type:k.literal("open_url"),receiptId:k.uuid(),url:Co,openIn:ko}),k.strictObject({type:k.literal("event"),receiptId:k.uuid(),event:Ft})]),gA=k.strictObject({type:k.literal("funnel"),id:k.uuid(),versionId:k.uuid()}),bA={id:Ft,presentation:jt,outputs:k.array(Ft).max(250),inputs:_i,values:k.record(k.string(),de).optional(),offeringKey:Ee.optional(),capabilities:pn,customerData:es,dataCursors:k.record(Ft,vr.nullable())},yA=k.strictObject({...bA,content:k.strictObject({type:k.literal("document"),document:et})}),ea=k.strictObject({id:k.uuid(),source:gA,revision:k.number().int().nonnegative(),visit:k.number().int().nonnegative(),nodeId:Ft,nodeType:k.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),status:AA,stopped:k.boolean(),canBack:k.boolean(),authenticated:k.boolean(),locale:k.string().min(1).max(35),answers:$t,parameters:ht,variables:k.record(k.string(),de),output:de.nullable(),screen:yA.nullable(),paywall:k.strictObject({receiptId:k.uuid(),resolution:k.union([ir,or]),quote:Jn.nullable(),operation:Sn.nullable(),purchaseRequestId:k.uuid().nullable(),selectionGeneration:k.number().int().nonnegative().optional(),canReselect:k.boolean().optional()}).nullable(),instruction:hA.nullable(),pendingRequest:k.strictObject({requestId:k.uuid(),authenticationRequired:k.boolean()}).nullable(),runExpiresAt:k.iso.datetime({offset:!0}),credentialExpiresAt:k.iso.datetime({offset:!0}).nullable()}),ta=k.strictObject({scope:Se,run:ea,settlement:k.strictObject({requestId:k.uuid(),state:k.enum(["pending","unknown","settled"]),operationId:k.uuid().nullable(),receiptId:k.uuid().nullable().optional()}).optional(),purchase:k.strictObject({receiptId:k.uuid(),quote:Jn.nullable(),operation:Sn.nullable(),canReselect:k.boolean().optional()}).optional(),review:k.strictObject({activeOperationId:k.uuid().nullable(),pages:k.array(k.strictObject({receiptId:k.uuid(),nodeId:Ft,visit:k.number().int().nonnegative()})).max(100),page:k.strictObject({receiptId:k.uuid(),nodeId:Ft,visit:k.number().int().nonnegative(),document:et,answers:$t,inputs:_i,values:k.record(k.string(),de).optional()}).nullable(),coupons:k.array(k.strictObject({grantId:k.uuid(),status:k.enum(["issued","reserved","redeemed","expired","revoked","unknown"]),expiresAt:k.string().nullable()})).max(100),purchases:k.array(k.strictObject({receiptId:k.uuid(),operationId:k.uuid(),status:k.enum(["pending","complete","cancelled","failed","unknown"])})).max(100)}).optional(),runToken:k.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/).optional(),customerId:k.uuid().optional()}),tp=ta.extend({run:ea.extend({paywall:ea.shape.paywall.unwrap().extend({resolution:or}).nullable()})});var DI="X-Indiana-Server-Key";import{z as We}from"zod";import{z as ci}from"zod";var qI=ci.strictObject({operation:ci.literal("renew_run"),runId:ci.uuid(),customerId:ci.uuid()}),np=ta.refine(e=>!!e.runToken,"Renewal returns a credential"),rp=tp.refine(e=>!!e.runToken,"Renewal returns a credential");var GI=We.discriminatedUnion("operation",[We.strictObject({operation:We.literal("campaign_decide"),...Po}).refine(Xt,Yt),We.strictObject({operation:We.literal("campaign_start"),funnelId:We.uuid(),requestId:We.uuid(),customer:jn,customerData:_n.optional(),locale:We.string().min(1).max(35),parameters:ht,cooldownSeconds:We.number().int().min(1).max(2592e3)}).refine(Xt,Yt)]),xA=We.union([We.strictObject({scope:Se,suppressed:We.literal(!0),reason:We.enum(["frequency","in_progress"]),retryAt:We.iso.datetime({offset:!0})}),np]),KI=We.union([xA.options[0],rp]);import{z as oe}from"zod";var Rn=oe.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),op=oe.strictObject({entry:Rn,nodes:oe.array(oe.strictObject({id:Rn,type:oe.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),outputs:oe.record(oe.string(),Rn),writes:oe.record(Ee,Ee),resources:oe.strictObject({screenId:Rn.optional(),paywallVersionId:oe.uuid().optional(),couponId:oe.uuid().optional(),couponIds:oe.array(oe.uuid()).max(20).optional(),experimentId:oe.uuid().optional(),featureKey:oe.string().optional(),offeringVersionId:oe.uuid().optional()})})).min(1).max(500)}),ip={scope:Se,funnelId:oe.uuid(),versionId:oe.uuid(),evaluationRevision:oe.number().int().nonnegative(),expiresAt:oe.iso.datetime({offset:!0}).nullable(),topology:op},En=oe.discriminatedUnion("evaluationMode",[oe.strictObject({...ip,evaluationMode:oe.literal("local"),growth:kt,conditions:oe.record(Rn,oe.array(oe.strictObject({condition:Lt,port:oe.string()})))}),oe.strictObject({...ip,evaluationMode:oe.literal("remote")})]),SA=En.options[0].extend({evaluation:oe.strictObject({maxTransitions:oe.number().int().min(1).max(1e4),variables:oe.record(Ee,fn),outputSchema:mn,terminals:oe.record(Rn,oe.strictObject({outcome:oe.enum(["completed","closed","ineligible","failed"]),output:er.nullable()}))})});function vA(e){return op.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 o=e.screens.find(a=>a.id===t.screenId);o?.type==="paywall"&&(r.paywallVersionId=o.paywallVersionId)}break;case"condition":t.cases.forEach((o,a)=>{n[`case:${a}`]=o.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 o of["success","cancel","unavailable","failure"])n[o]=t[o];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=oe.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 i=t.type==="output"?t.value:t.type==="end"?t.output:void 0;return i?.type==="feature"&&(r.featureKey=i.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 IA(e){let t=zt.parse(e.document),n=e.evaluationMode==="local"?kt.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:vA(t)};return En.parse(e.evaluationMode==="remote"?r:{...r,growth:ai(t,n),conditions:Object.fromEntries(t.graph.nodes.filter(i=>i.type==="condition").map(i=>[i.id,i.cases.map((o,a)=>({condition:o.condition,port:`case:${a}`}))]))})}function nO(e){let t=IA(e);if(t.evaluationMode!=="local")throw new Error("Remote Funnel cannot disclose local rules");let n=zt.parse(e.document);return SA.parse({...t,evaluation:{maxTransitions:n.execution.maxTransitions,variables:n.variables,outputSchema:n.outputSchema,terminals:Object.fromEntries(n.graph.nodes.flatMap(r=>{let i=r.type==="end"?r.output:r.type==="output"?r.value:void 0;return r.type!=="end"&&r.type!=="output"?[]:i&&i.type!=="literal"&&i.type!=="feature"&&i.type!=="variable"?[]:[[r.id,{outcome:r.type==="end"?r.outcome:"completed",output:i??null}]]}))}})}import{z as ut}from"zod";import{z as $e}from"zod";var ap=$e.discriminatedUnion("provider",[$e.strictObject({provider:$e.literal("apple"),orderId:$e.uuid(),receiptId:$e.uuid(),signedTransaction:$e.string().min(1).max(131072)}),$e.strictObject({provider:$e.literal("google"),orderId:$e.uuid(),receiptId:$e.uuid(),purchaseToken:$e.string().min(1).max(16384)})]),sp=$e.strictObject({orderId:$e.uuid(),receiptId:$e.uuid(),transactionIds:$e.array($e.string().min(1).max(255)).min(1).max(50),membership:$e.boolean()});var lO=ut.strictObject({operation:ut.literal("native_receipt"),requestId:ut.uuid(),customerToken:ut.string().regex(Rt),orderId:ut.uuid(),receiptId:ut.uuid(),nativeEvidence:ap.nullable()}).refine(e=>e.nativeEvidence===null||e.nativeEvidence.orderId===e.orderId&&e.nativeEvidence.receiptId===e.receiptId,"Evidence must use this current order receipt"),pO=ut.strictObject({scope:Se,requestId:ut.uuid(),orderId:ut.uuid(),receiptId:ut.uuid(),orderStatus:ut.enum(["created","pending","trialing","paid","cancelled","failed"]),refunded:ut.boolean(),nativeCompletion:sp.optional()});import{z as Ie}from"zod";var cp=Ie.string().regex(/^[a-f0-9]{64}$/),OA=ts.omit({variations:!0,active:!0}).extend({changeId:cp,variations:Ie.array(Ie.strictObject({urlRedirect:Ie.string().max(2048)})).min(2).max(20)}),AO=Ie.strictObject({environmentId:Ie.uuid(),trackExposures:Ie.boolean(),generation:cp,experiments:Ie.array(OA).max(100),savedGroups:rs}),wA=Ie.strictObject({eventUuid:Ie.uuid(),timestamp:Ie.iso.datetime({offset:!0}).optional(),deviceId:Ie.string().min(1).max(128),sessionId:Ie.string().min(1).max(128).optional(),url:Ie.url().max(2048),pageTitle:Ie.string().max(512).optional(),experimentKey:Ie.string().min(1).max(255),variationKey:Ie.string().min(1).max(64)}),hO=Ie.strictObject({events:Ie.array(wA).min(1).max(20)}),gO=Ie.strictObject({inserted:Ie.number().int().nonnegative(),duplicates:Ie.number().int().nonnegative(),skipped:Ie.number().int().nonnegative(),rejected:Ie.array(Ie.strictObject({index:Ie.number().int().nonnegative(),reason:Ie.string()}))});import{z as Pe}from"zod";var ra=32,jA=522240;function ia(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 _A=Pe.strictObject({nodeId:Pe.string().min(1).max(64),visit:Pe.number().int().nonnegative(),revision:Pe.number().int().nonnegative()}),na=Pe.record(Pe.string(),de),PA=Pe.strictObject({id:Pe.uuid(),nodeId:Pe.string().min(1).max(64),visit:Pe.number().int().nonnegative(),input:Pe.strictObject({schemaVersion:tr.shape.schemaVersion,kind:tr.shape.kind,selector:tr.shape.selector,contract:tr.shape.contract}),context:na,removed:Pe.array(Pe.string()).max(100),attributes:na,removedAttributes:Pe.array(Pe.string()).max(100),result:tl,offeringVersionId:Pe.uuid().nullable(),events:Pe.strictObject({entered:Pe.string().regex(/^[1-9][0-9]{0,18}$/),decision:Pe.string().regex(/^[1-9][0-9]{0,18}$/).nullable()})}),IO=Pe.strictObject({schemaVersion:Pe.literal(1),mode:Pe.enum(["local","remote"]),versionId:Pe.uuid(),generation:Pe.number().int().positive(),base:_A,context:na,steps:Pe.array(PA).min(1).max(ra)}).refine(e=>tt(e)<=jA,"Segment exceeds its byte budget");var oa=class extends Error{constructor(n,r){super(r);this.code=n;this.name="FunnelLocalCalculationError"}code},ui=(e,t)=>new oa(e,t),CA=e=>({experiments:e.experiments,features:e.features});function kA(e,t=ui){let n=new Map(e.topology.nodes.map(a=>[a.id,a])),r=Ta(e.growth.savedGroups),i=CA(e.growth);function o(a,c){if(!Object.hasOwn(e.growth.features,a))throw t("INVALID_RESPONSE","Required GB Feature is unavailable");return Tn(a,c).value}return{nodes:n,savedGroups:r,features:i.features,feature:o,evaluate(a,c){let u=n.get(a);if(!u)throw t("NOT_FOUND","Funnel node is unavailable");let p,b;if(u.type==="condition"){let z=e.conditions[u.id];if(!z)throw t("INVALID_RESPONSE","Local condition rules are unavailable");p=Yo({id:u.id,name:u.id,type:"condition",cases:z.map(I=>({condition:I.condition,target:u.outputs[I.port]})),default:u.outputs.default},c,i.experiments).port}else if(u.type==="feature"){if(!u.resources.featureKey)throw t("INVALID_RESPONSE","Feature reference is unavailable");b=o(u.resources.featureKey,c),p="next"}else if(u.type==="split"){if(!(u.resources.experimentId?e.growth.experiments[u.resources.experimentId]:void 0))throw t("INVALID_RESPONSE","Experiment reference is unavailable");let I=Yo({id:u.id,name:u.id,type:"split",experimentId:u.resources.experimentId,routes:u.outputs,notParticipating:u.outputs.notParticipating},c,i.experiments);b=I.value,p=I.port}else if(["offering","end","output"].includes(u.type)&&u.resources.featureKey)b=o(u.resources.featureKey,c),p=u.type==="offering"?"next":"value";else throw t("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let O=u.outputs[p]??(p==="value"?u.id:void 0);if(!O)throw t("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:a,port:p,target:O,...b===void 0?{}:{value:b}}}}}function TO(e,t,n,r=ui){return aa(e,r)(t,n)}function aa(e,t){let n=En.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,i=()=>{if(r!==null&&r<=Date.now())throw t("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition")};i();let o=kA(n,t);return(a,c)=>(i(),RA(o,a,c))}function RA(e,t,n){let r=Ye.parse(n.attributes??{}),{saveStickyBucketAssignmentDoc:i,onFeatureUsage:o,onExperimentViewed:a}=n,c={attributes:r,...i?{saveStickyBucketAssignmentDoc:u=>i(structuredClone(u))}:{},...o?{onFeatureUsage:(u,p)=>o(u,structuredClone(p))}:{},...a?{onExperimentViewed:(u,p)=>a(structuredClone(u),structuredClone(p))}:{},features:e.features,savedGroups:e.savedGroups,...n.stickyBucketAssignmentDocs?{stickyBucketAssignmentDocs:structuredClone(n.stickyBucketAssignmentDocs)}:{}};return e.evaluate(t,c)}function MO(e,t,n,r=ui){return up(aa(e,r),t,n)}function up(e,t,n){let r=[],i=[],o=[],a=e(t,{...n.attributes?{attributes:n.attributes}:{},stickyBucketAssignmentDocs:n.sticky,saveStickyBucketAssignmentDoc(c){let u=r.findIndex(O=>O.next.attributeName===c.attributeName&&O.next.attributeValue===c.attributeValue),p=c.attributeName+"||"+c.attributeValue,b={expected:n.sticky[p]??null,next:c};u<0?r.push(b):r[u]=b},onExperimentViewed(c,u){u.inExperiment&&u.hashUsed&&!u.passthrough&&i.push(de.parse({key:c.key,variationId:u.variationId,keyUsed:u.key,hashAttribute:u.hashAttribute,hashValue:u.hashValue}))},onFeatureUsage(c,u){o.push(de.parse({feature:c,value:u.value,source:u.source,...u.ruleId?{ruleId:u.ruleId}:{}}))}});return{port:a.port,...a.value===void 0?{}:{value:a.value},sticky:r,exposures:i,features:o}}function BO(e,t,n,r=ui){let i=n,o=new Map(t.graph.nodes.map(g=>[g.id,g])),a=structuredClone(n.variables),c=structuredClone(i.sticky),u=[],p=n.nodeId,b=n.visit,O=!1,z,I=g=>(z??=aa(e,r),up(z,g,{attributes:So({declarations:t.variables,attributes:i.attributes,parameters:n.parameters,answers:n.answers,results:a,savedGroups:{}}),sticky:c}));for(let g=0;g<ra;g++){let E=o.get(p);if(!E||!ia(E))break;if(b>=t.execution.maxTransitions&&(b>t.execution.maxTransitions||E.type!=="end"&&E.type!=="output")){if(!u.length)throw r("TRANSITION_LIMIT","Local Funnel transition budget exceeded");break}let X,te;if(["condition","feature","split"].includes(E.type)||E.type==="offering"&&E.configuration.source==="feature")X=I(E.id),E.type==="offering"&&(X.value={type:"offering_version",id:String(X.value)}),E.type==="condition"?te=X.port==="default"?E.default:E.cases[Number(X.port.slice(5))]?.target:E.type==="split"?te=X.port==="notParticipating"?E.notParticipating:E.routes[X.port]:(E.type==="feature"||E.type==="offering")&&(te=E.next);else if(X={port:"next",sticky:[],exposures:[],features:[]},(E.type==="entry"||E.type==="coupon"||E.type==="coupons")&&(te=E.next),E.type==="offering"&&E.configuration.source==="fixed"&&(X.value={type:"offering_version",id:E.configuration.versionId},te=E.next),E.type==="end"||E.type==="output"){let M=E.type==="end"?E.output:E.value;if(X=M?.type==="feature"?I(E.id):{...X,port:"value",value:M?.type==="literal"?M.value:M?.type==="variable"?Mi({source:"variable",key:M.key,...M.path?{path:M.path}:{}},{declarations:t.variables,answers:n.answers,results:a,parameters:n.parameters,attributes:i.attributes,savedGroups:{}}):null},M&&(X.value===void 0||!at(t.outputSchema,X.value)))throw r("INVALID_RESPONSE","Local terminal violates its declared output")}let xe=[...u,{nodeId:p,result:X}];if(tt({steps:xe})>6e4){if(!u.length)throw r("INVALID_REQUEST","Local step exceeds its command budget");break}if(u.push({nodeId:p,result:X}),E.type==="feature"||E.type==="offering"||E.type==="coupon"||E.type==="coupons"){let M=E.type==="coupons"?E.couponIds.map(re=>({type:"reward",id:re})):E.type==="coupon"?{type:"reward",id:E.couponId}:X.value;if(M===void 0)throw r("INVALID_RESPONSE","Node output is missing");let se=Kt(E,{value:M});Ti(t.variables,E,se),Object.assign(a,se)}for(let M of X.sticky)c[`${M.next.attributeName}||${M.next.attributeValue}`]=structuredClone(M.next);if(E.type==="end"||E.type==="output"){O=!0;break}if(!te)throw r("INVALID_RESPONSE","Local pure exit is unavailable");p=te,b++}let d=o.get(p);return{steps:u,...!O&&d&&!ia(d)?{boundary:{nodeId:p,visit:b}}:{}}}import{z as EA}from"zod";var UO=EA.strictObject({document:zt,configuration:En.options[0]});import{z as Q}from"zod";var li=Q.string().regex(/^[a-f0-9]{64}$/),DA=Q.strictObject({release:li,render:is,button:Q.strictObject({selector:Q.string().min(1).max(512),elementKey:Q.string().min(1).max(256),tag:Q.enum(["button","a","input"])}).nullable()}),ZO=Q.strictObject({scope:Se.extend({environmentId:Q.uuid()}),release:li,validatedAt:Q.iso.datetime({offset:!0}),validUntil:Q.iso.datetime({offset:!0}),entries:Q.array(Q.strictObject({id:Q.uuid(),funnelId:Q.uuid(),versionId:Q.uuid(),event:Q.enum(["screen_enter","button_click"]),target:DA})).max(4e3)}),QO=Q.strictObject({operation:Q.literal("entry_start"),funnelId:Q.uuid(),versionId:Q.uuid(),entryId:Q.uuid(),release:li,requestId:Q.uuid(),locale:Q.string().min(1).max(35).default("en")}),JO=Q.strictObject({scope:Se,suppressed:Q.literal(!0),reason:Q.enum(["frequency","in_progress"]),retryAt:Q.iso.datetime({offset:!0}).nullable()}),WO=Q.strictObject({experimentId:Q.uuid(),splitNodeId:Q.string().min(1).max(128)}),TA=Q.strictObject({experimentId:Q.uuid(),experimentKey:Q.string().min(1).max(128),variationKey:Q.string().min(1).max(128),inExperiment:Q.boolean(),generation:Q.string().min(1).max(256)}),XO=Q.strictObject({operation:Q.literal("page_experiments"),release:li,usedReceiptIds:Q.array(Q.uuid()).max(20).default([]),customerToken:Q.string().regex(Rt).optional()}),YO=Q.strictObject({scope:Se,runId:Q.uuid(),assignments:Q.array(TA.extend({receiptId:Q.uuid()})).max(20),payload:ss});function he(e){return typeof e=="string"?e:String(e)}var MA=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function BA(e){return e.replace(MA,"$1\uFFFD")}function la(e,t){if(typeof e!="object"||e==null){let n="";throw n+="The provided value is not an object",new TypeError(n)}return e}function bp(e){if(e!=null&&(typeof e=="object"||typeof e=="function")){let t=e[Symbol.iterator];if(t==null)return;if(typeof t!="function")throw new TypeError("The provided value is not iterable");let n=t.call(e);if(!n||typeof n!="object")throw new TypeError("Result of the Symbol.iterator method is not an object");return n}}function lp(e){let t;if(Array.isArray(e)){let n=e.map(he);if(n.length===2)return n}else if((t=bp(e))!=null){let n=la(t.next()),r=la(t.next());if(!n.done&&!r.done)return[he(n.value),he(r.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var pp="0123456789ABCDEF",qA=/(?:%[0-9A-Fa-f]{2})+/g;function xt(e){return`%${pp[e>>4&15]}${pp[15&e]}`}function yp(e,t,n=!1){return e>=55296&&e<=57343&&(e=65533),e<=127?n&&e===32?"+":t(e)?xt(e):String.fromCharCode(e):e<=2047?xt(192|e>>6)+xt(128|63&e):e<=65535?xt(224|e>>12)+xt(128|e>>6&63)+xt(128|63&e):xt(240|e>>18)+xt(128|e>>12&63)+xt(128|e>>6&63)+xt(128|63&e)}function pa(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:-1}function da(e,t=!1){let n=0;for(;n<e.length;n++){let r=e.charCodeAt(n);if(r===37||t&&r===43)break}return n===e.length?e:(t?e.replace(/\+/g," "):e).replace(qA,r=>{try{return decodeURIComponent(r)}catch{return"\uFFFD".repeat(r.length/3)}})}function dr(e){return e<=31||e>126}function zA(e){switch(e){case 32:case 34:case 60:case 62:case 96:return!0;default:return dr(e)}}function ya(e){switch(e){case 32:case 34:case 35:case 60:case 62:return!0;default:return dr(e)}}function NA(e){return ya(e)||e===39}function ma(e){switch(e){case 63:case 94:case 96:case 123:case 125:return!0;default:return ya(e)}}function Ai(e){switch(e){case 47:case 58:case 59:case 61:case 64:case 91:case 92:case 93:case 124:return!0;default:return ma(e)}}function dp(e){switch(e){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(n){switch(n){case 36:case 37:case 38:case 43:case 44:return!0;default:return Ai(n)}})(e)}}function xp(e,t){return yp(e=e||0,t)}function St(e,t,n=!1){let r=0;for(;r<e.length;r++){let o=e.charCodeAt(r);if(o>=128||n&&o===32||t(o))break}if(r===e.length)return e;let i=e.slice(0,r);for(;r<e.length;r++){let o=e.charCodeAt(r),a=o;if(o>=55296&&o<=56319&&r+1<e.length){let c=e.charCodeAt(r+1);c>=56320&&c<=57343&&(a=(o-55296<<10)+c-56320+65536,r++)}i+=yp(a,t,n)}return i}function xa(e){let t=[],n=0,r=0;for(;r<=e.length;){if(r=e.indexOf("&",n),r<0&&(r=e.length),r!==n){let i=e.slice(n,r),o=i.indexOf("=");o<0&&(o=i.length),t.push([da(i.slice(0,o),!0),da(i.slice(o+1),!0)])}if(n=r+1,r===e.length)break}return t}function fa(e){let t="";for(let n=0;n<e.length;n++){let r=St(e[n][0],dp,!0),i=St(e[n][1],dp,!0);t+=n!==0?`&${r}=${i}`:`${r}=${i}`}return t}var FA=[2191,2191,3164,3164,3292,3292,6863,6877,6880,6891,8385,8385,11158,11158,42958,42959,42962,42962,42964,42964,42993,42993,64451,64466,64912,64913,64968,64974,67904,67929,69317,69319,69328,69336,69370,69371,72544,72551,73136,73179,73184,73193,93856,93880,93883,93907,94194,94198,100344,100351,101641,101662,101760,101874,118010,118012,118458,118480,118496,118512,124608,124638,124640,124661,124670,124671,128728,128728,128887,128890,129232,129240,129620,129623,129674,129674,129678,129678,129736,129736,129741,129741,129770,129770,129775,129775,130042,130042,177978,177983,183970,183981,205744,210041],UA=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],VA=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],LA=[2381,2381,2509,2509,2637,2637,2765,2765,2893,2893,3021,3021,3149,3149,3277,3277,3387,3388,3405,3405,3530,3530,3642,3642,3770,3770,3972,3972,4153,4154,5908,5909,5940,5940,6098,6098,6752,6752,6980,6980,7082,7083,7154,7155,11647,11647,43014,43014,43052,43052,43204,43204,43347,43347,43456,43456,43766,43766,44013,44013,68159,68159,69702,69702,69744,69744,69759,69759,69817,69817,69939,69940,70080,70080,70197,70197,70378,70378,70477,70477,70606,70608,70722,70722,70850,70850,71103,71103,71231,71231,71350,71350,71467,71467,71737,71737,71997,71998,72160,72160,72244,72244,72263,72263,72345,72345,72767,72767,73028,73029,73111,73111,73537,73538,90415,90415];function $A(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>65535&&t++,n<=32||n===37||n===127||n>=55296&&n<=57343||n>=128&&n<=159||n>=64976&&n<=65007||!(65534&~n)||n===65533)return!0}return!1}var[GA,KA,HA,mp]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([t,n,r]){return[t,n.split(",").map(i=>parseInt(i,36)),Uint8Array.from(atob(r),i=>i.charCodeAt(0))]});function ZA(e,t){return t===931||t===1010||t===120531||t===120589||t===120647||t===120705||t===120763?"\u03C3":t>=5112&&t<=5117?String.fromCodePoint(t-8):t>=43888&&t<=43967?String.fromCodePoint(t-38864):t>=93856&&t<=93880?String.fromCodePoint(t+27):t===837||t===890||t>=8064&&t<=8111||t>=8114&&t<=8188?e.normalize("NFD").replace(/\u0345/g,"\u03B9").normalize("NFC").toLowerCase():""}function Sp(e,t){for(let n=0;n<e.length;n+=2)if(t>=e[n]&&t<=e[n+1])return!0;return!1}function lr(e,t){let[n,r,i]=e,o=t>>8;for(let u=0;u<n.length;u+=2)if(o>=n[u]&&o<=n[u+1])return!0;let a=r.indexOf(o);if(a<0)return!1;let c=255&t;return!!(i[32*a+(c>>3)]&1<<(7&c))}function QA(e){let t=Array.from(e,n=>n.codePointAt(0));for(let n=0;n<t.length;n++){let r=t[n];if(r!==8204&&r!==8205||n>0&&Sp(LA,t[n-1]))continue;if(r===8205)return!1;let i=n-1;for(;i>=0&&lr(mp,t[i]);)i--;let o=n+1;for(;o<t.length&&lr(mp,t[o]);)o++;if(!(i>=0&&o<t.length&&lr(KA,t[i])&&lr(HA,t[o])))return!1}return!0}var JA=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,WA=/\p{Script=Latin}/u;function XA(e){return!JA.test(e)||!WA.test(e)}var Ut=36,di=1,Aa=26,YA=38,eh=700,th=72,nh=128,rh=2147483647;function fp(e){return String.fromCharCode(e+22+75*+(e<26))}function ih(e,t,n){let r=0;for(e=n?Math.floor(e/eh):e>>1,e+=Math.floor(e/t);e>(Ut-di)*Aa>>1;r+=Ut)e=Math.floor(e/(Ut-di));return Math.floor(r+(Ut-di+1)*e/(e+YA))}function oh(e){let t=Array.from(e,u=>u.codePointAt(0)),n="",r=0;for(let u=0;u<t.length;u++){let p=t[u];p<128&&(n+=String.fromCharCode(p),r++)}let i=r;i&&(n+="-");let o=nh,a=0,c=th;for(;r<t.length;){let u=rh;for(let p=0;p<t.length;p++){let b=t[p];b>=o&&b<u&&(u=b)}a+=(u-o)*(r+1),o=u;for(let p=0;p<t.length;p++){let b=t[p];if(b<o&&a++,b===o){let O=a;for(let z=Ut;;z+=Ut){let I=z<=c?di:z>=c+Aa?Aa:z-c;if(O<I)break;n+=fp(I+(O-I)%(Ut-I)),O=Math.floor((O-I)/(Ut-I))}n+=fp(O),c=ih(a,r+1,r===i),a=0,r++}}a++,o++}return n}function sa(e){let t=10;if(e.length>=2&&e[0]==="0"&&(e[1]==="x"||e[1]==="X"))e=e.slice(2),t=16;else if(e.length>=2&&e[0]==="0")e=e.slice(1),t=8;else if(e==="")return-1;let n=0;for(let r=0;r<e.length;r++){let i=pa(e.charCodeAt(r));if(i>=t||i<0)return-1;n=n*t+i}return n}function Ap(e){switch(e){case".":case"%2e":case"%2E":return!0;default:return!1}}function vp(e,t){return(e>=65&&e<=90||e>=97&&e<=122)&&(t===58||t===124)}function Ip(e){return e.length===2&&vp(e.codePointAt(0),e.codePointAt(1))}function hp(e){return e.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function Ce(e){switch(e){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function Op(e){switch(e){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function ha(e,t){if(e[0]==="[")return e[e.length-1]==="]"?(function(r){let i=[0,0,0,0,0,0,0,0],o=null,a=0,c=0,u=Array.from(r,p=>p.codePointAt(0));if(u[c]===58){if(u[c+1]!==58)return null;c+=2,a++,o=a}for(;c<u.length;){if(a===8)return null;if(u[c]===58){if(o!==null)return null;c++,a++,o=a;continue}let p=0,b=0,O=0;for(;O<4&&(p=pa(u[c]))>=0;)b=(b<<4)+p,c++,O++;if(u[c]===46){if(O===0||a>6)return null;c-=O;let z=0;for(;u[c]!==void 0;){let I=0;if(z>0)if(u[c]===46&&z<4)c++;else return null;if(u[c]==null||u[c]<48||u[c]>57)return null;for(;u[c]>=48&&u[c]<=57;){if(I=10*I+pa(u[c]),I>255)return null;c++}i[a]=256*i[a]+I,z++,z%2==0&&a++}if(z!==4)return null;break}else if(u[c]===58){if(u[++c]===void 0)return null}else if(u[c]!==void 0)return null;i[a]=b,a++}if(o!==null){let p=a-o;for(a=7;a!==0&&p>0;){let b=i[o+p-1];i[o+p-1]=i[a],i[a]=b,a--,p--}}else if(o===null&&a!==8)return null;return i})(e.substring(1,e.length-1)):null;if(t)return(function(r){return hp(r)?null:St(r,dr)})(e);{let n=(function(i){let o=!1,a=!1;for(let u=0;u<i.length;u++){let p=i.charCodeAt(u);if(p<=32||p===37||p===127)return null;if(p>=128){o=!0;break}p>=65&&p<=90&&(a=!0)}if(!o)return i!==""?a?i.toLowerCase():i:null;if((function(p){for(let b of p){let O=b.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(b)&&!Sp(FA,O)||lr(GA,O))return!0}return!1})(i))return null;let c=(i=(function(p){let b="";for(let O of p){let z=O.codePointAt(0);if(z!==8204&&z!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(O))continue;let I=ZA(O,z);if(I){b+=I;continue}let d=UA.indexOf(z);b+=d<0?O:VA[d]}return b})(i).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let u=0;u<c.length;u++){let p=c[u];if(p==="")continue;let b=/[^\0-\x7f]/.test(p);if($A(p)||b&&(/^\p{Mark}/u.test(p)||!QA(p)||!XA(p)||p.startsWith("xn--")))return null;b&&(c[u]=`xn--${oh(p)}`)}return(i=c.join("."))!==""?i:null})(e.indexOf("%")===-1?e:da(e));return n===null||hp(n)?null:(function(i){let o=i.length,a=i.lastIndexOf(".",o-2)+1;if(i.charCodeAt(o-1)===46&&o--,o<=a)return!1;if(sa(i.slice(a,o))>=0)return!0;for(;a<o;a++){let c=i.charCodeAt(a);if(c<48||c>57)return!1}return!0})(n)?(function(i){let o=i.split("."),a=o.length;if(o[a-1]||a--,a>4)return null;let c=0;for(let p=0;p<a-1;p++){let b=sa(o[p]);if(b<0||b>255)return null;c+=b*(1<<8*(3-p))}let u=sa(o[a-1]);return u<0||u>=256**(5-a)?null:(c+=u,c)})(n):n}}function ga(e){return typeof e=="number"?(function(n){let i="";return i+=`${(n>>>24&255).toString(10)}.`,i+=`${(n>>>16&255).toString(10)}.`,i+=`${(n>>>8&255).toString(10)}.`,i+=(n&255).toString(10),i})(e):Array.isArray(e)?`[${(function(n){let r=(function(c){let u=-1,p=-1,b=1,O=0;for(let z=0;z<c.length;++z)c[z]!==0?(O>b&&(u=p,b=O),p=-1,O=0):(p===-1&&(p=z),++O);return O>b?p:u})(n),i="",o=!1;for(let a=0;a<=7;++a)if(!(o&&n[a]===0)){if(o&&(o=!1),r===a){i+=a===0?"::":":",o=!0;continue}i+=n[a].toString(16),a!==7&&(i+=":")}return i})(e)}]`:e}function wp(e){e.path.length>0&&(e.path.length!==1||e.scheme!=="file"||!(function(n){return/^[A-Za-z]:$/u.test(n)})(e.path[0]))&&e.path.pop()}function jp(e){return e.username!==""||e.password!==""}function ca(e){return e.host===null||e.host===""||e.scheme==="file"}var f=0,S="",J="",pe=null,v,mi=!1,fi=!1,an=!1,ke;function ot(e,t,n,r){t||(e=(function(a){let c=0,u=a.length;for(;c<u&&!(a.charCodeAt(c)>32);++c);for(;u>c&&!(a.charCodeAt(u-1)>32);--u);return a.substring(c,u)})(e)),e=(function(a){let c=0;for(;c<a.length;c++){let p=a.charCodeAt(c);if(p===9||p===10||p===13)break}if(c===a.length)return a;let u=a.slice(0,c);for(;c<a.length;c++){let p=a.charCodeAt(c);p!==9&&p!==10&&p!==13&&(u+=a[c])}return u})(e),f=0,S=e,J="",pe=n||null,v=t||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},mi=!1,fi=!1,an=!1,ke=r||0;let i=ah;switch(r){case 3:case 4:i=hi;break;case 5:i=va;break;case 6:i=sn;break;case 7:i=Vt;break;case 8:i=vt}return i(C(e,f))!==1?v:null}function B(e,t){return f+=f===e?ft(t):1,f<=S.length}function C(e,t){return t<e.length?e.codePointAt(t):void 0}function ft(e){return e!=null&&e>65535?2:1}function _p(e){return e==null?"":e<=65535?String.fromCharCode(e):String.fromCodePoint(e)}var ah=e=>{let t=f;if(e!=null&&(e>=65&&e<=90||e>=97&&e<=122)){let n=f+1;for(e=S.charCodeAt(n);e===43||e===45||e===46||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57;)n++,e=S.charCodeAt(n);return J=S.slice(f,n).toLowerCase(),f=n,sh(n<S.length?e:void 0)}else return ke?1:(--f,B(t,e)?Pp(C(S,f)):0)},sh=e=>{let t=f;if(e===58){if(ke){if(Ce(v.scheme)!==Ce(J))return 0;if((jp(v)||v.port!==null)&&J==="file")return 0;if(v.scheme==="file"&&v.host==="")return 0}return v.scheme=J,ke?(v.port===Op(v.scheme)&&(v.port=null),0):(J="",v.scheme==="file"?B(t,e)?Ia(C(S,f)):0:Ce(v.scheme)&&pe!==null&&pe.scheme===v.scheme?B(t,e)?ch(C(S,f)):0:Ce(v.scheme)?B(t,e)?lh(C(S,f)):0:C(S,f+1)===47?(f++,B(t,e)?uh(C(S,f)):0):(v.path=[""],v.opaquePath=!0,B(t,e)?kp(C(S,f)):0))}else return ke?1:(J="",f=-1,B(t,e)?Pp(C(S,f)):0)},Pp=e=>{let t=f;return pe===null||pe.opaquePath&&e!==35?1:pe.opaquePath&&e===35?(v.scheme=pe.scheme,v.path=pe.path.slice(),v.opaquePath=pe.opaquePath,v.query=pe.query,v.fragment="",B(t,e)?vt(C(S,f)):0):pe.scheme==="file"?(f--,B(t,e)?Ia(C(S,f)):0):(f--,B(t,e)?Sa(C(S,f)):0)},ch=e=>{let t=f;return e===47&&C(S,f+1)===47?(++f,B(t,e)?bi(C(S,f)):0):(f--,B(t,e)?Sa(C(S,f)):0)},uh=e=>{let t=f;return e===47?B(t,e)?Dn(C(S,f)):0:(f--,B(t,e)?At(C(S,f)):0)},Sa=e=>{let t=f;return v.scheme=pe.scheme,e===47||Ce(v.scheme)&&e===92?B(t,e)?gp(C(S,f)):0:(v.username=pe.username,v.password=pe.password,v.host=pe.host,v.port=pe.port,v.path=pe.path.slice(),v.query=pe.query,e===63?(v.query="",B(t,e)?Vt(C(S,f)):0):e===35?(v.fragment="",B(t,e)?vt(C(S,f)):0):e!=null?(v.query=null,v.path.pop(),f--,B(t,e)?At(C(S,f)):0):B(t,e)?Sa(C(S,f)):0)},gp=e=>{let t=f;return Ce(v.scheme)&&(e===47||e===92)?B(t,e)?bi(C(S,f)):0:e===47?B(t,e)?Dn(C(S,f)):0:(v.username=pe.username,v.password=pe.password,v.host=pe.host,v.port=pe.port,f--,B(t,e)?At(C(S,f)):0)},lh=e=>{let t=f;return e===47&&C(S,f+1)===47?f++:f--,B(t,e)?bi(C(S,f)):0},bi=e=>{let t=f;return e!==47&&e!==92?(f--,B(t,e)?Dn(C(S,f)):0):B(t,e)?bi(C(S,f)):0},Dn=e=>{let t=f;if(e!=null&&e!==64&&e!==35&&e!==47&&e!==63&&(e!==92||!Ce(v.scheme))){let n=f+ft(e);for(;n<S.length;){let r=C(S,n);if(r==null||r===64||r===35||r===47||r===63||r===92&&Ce(v.scheme))break;n+=ft(r)}return J+=S.slice(f,n),f=n-1,B(t,e)?Dn(C(S,f)):0}if(e===64){mi&&(J=`%40${J}`),mi=!0;for(let n=0;n<J.length;n++){let r=J.codePointAt(n);if(r===58&&!fi){fi=!0;continue}let i=xp(r,Ai);fi?v.password+=i:v.username+=i,r!=null&&r>65535&&n++}return J="",B(t,e)?Dn(C(S,f)):0}else return e==null||e===35||e===47||e===63||e===92&&Ce(v.scheme)?mi&&J===""?1:(f-=J.length+1,J="",B(t,e)?hi(C(S,f)):0):(J+=_p(e),B(t,e)?Dn(C(S,f)):0)},hi=e=>{let t=f;if(ke&&v.scheme==="file")return f--,B(t,e)?Oa(C(S,f)):0;if(e!=null&&e!==58&&e!==35&&e!==47&&e!==63&&(e!==92||!Ce(v.scheme))){let n=f+ft(e);for(e===91?an=!0:e===93&&(an=!1);n<S.length;){let r=C(S,n);if(r==null||!an&&r===58||r===35||r===47||r===63||r===92&&Ce(v.scheme))break;r===91?an=!0:r===93&&(an=!1),n+=ft(r)}return J+=S.slice(f,n),f=n-1,B(t,e)?hi(C(S,f)):0}else if(e===58&&!an){if(J===""||ke===4)return 1;let n=ha(J,!Ce(v.scheme));return n===null?1:(v.host=ga(n),J="",B(t,e)?va(C(S,f)):0)}else if(e==null||e===35||e===47||e===63||e===92&&Ce(v.scheme)){if(f--,Ce(v.scheme)&&J==="")return 1;if(ke&&J===""&&(jp(v)||v.port!==null))return 1;let n=ha(J,!Ce(v.scheme));return n===null?1:(v.host=ga(n),J="",ke?0:B(t,e)?sn(C(S,f)):0)}else return J+=_p(e),B(t,e)?hi(C(S,f)):0},va=e=>{let t=f;if(e!=null&&e>=48&&e<=57){let n=f+1;for(;n<S.length;){let r=S.charCodeAt(n);if(r<48||r>57)break;n++}return J+=S.slice(f,n),f=n-1,B(t,e)?va(C(S,f)):0}else if(ke||e==null||e===35||e===47||e===63||e===92&&Ce(v.scheme)){if(J!==""){let n=parseInt(J,10);if(n>65535)return 1;if(v.port=n===Op(v.scheme)?null:n,J="",ke)return 0}return ke?1:(f--,B(t,e)?sn(C(S,f)):0)}else return 1};function Cp(e,t){let n=e.length-t;if(n<2)return!1;if(vp(C(e,t),C(e,t+1))){if(n===2)return!0;{let r=C(e,t+2);return r===47||r===92||r===63||r===35}}else return!1}var Ia=e=>{let t=f;return v.scheme="file",v.host="",e===47||e===92?B(t,e)?ph(C(S,f)):0:pe?.scheme==="file"?(v.host=pe.host,v.path=pe.path.slice(),v.opaquePath=pe.opaquePath,v.query=pe.query,e===63?(v.query="",B(t,e)?Vt(C(S,f)):0):e===35?(v.fragment="",B(t,e)?vt(C(S,f)):0):e!=null?(v.query=null,Cp(S,f)?v.path=[]:wp(v),f--,B(t,e)?At(C(S,f)):0):B(t,e)?Ia(C(S,f)):0):(f--,B(t,e)?At(C(S,f)):0)},ph=e=>{let t=f;return e===47||e===92?B(t,e)?Oa(C(S,f)):0:(pe!==null&&pe.scheme==="file"&&(!Cp(S,f)&&(function(r){if(r.length===2){let i=r.codePointAt(0),o=r.codePointAt(1);return(i>=65&&i<=90||i>=97&&i<=122)&&o===58}else return!1})(pe.path[0])&&v.path.push(pe.path[0]),v.host=pe.host),f--,B(t,e)?At(C(S,f)):0)},Oa=e=>{let t=f;if(e!=null&&e!==47&&e!==92&&e!==63&&e!==35){let n=f+ft(e);for(;n<S.length;){let r=C(S,n);if(r==null||r===47||r===92||r===63||r===35)break;n+=ft(r)}return J+=S.slice(f,n),f=n-1,B(t,e)?Oa(C(S,f)):0}else if(e==null||e===47||e===92||e===63||e===35){if(f--,!ke&&Ip(J))return B(t,e)?At(C(S,f)):0;if(J==="")return v.host="",ke?0:B(t,e)?sn(C(S,f)):0;{let n=ha(J,!Ce(v.scheme));return n===null?1:(n==="localhost"&&(n=""),v.host=ga(n),J="",ke?0:B(t,e)?sn(C(S,f)):0)}}return 1},sn=e=>{let t=f;return Ce(v.scheme)?(e!==92&&e!==47&&f--,B(t,e)?At(C(S,f)):0):!ke&&e===63?(v.query="",B(t,e)?Vt(C(S,f)):0):!ke&&e===35?(v.fragment="",B(t,e)?vt(C(S,f)):0):e!=null?(e!==47&&f--,B(t,e)?At(C(S,f)):0):(ke&&v.host===null&&v.path.push(""),B(t,e)?sn(C(S,f)):0)},At=e=>{let t=f;if(e!=null&&e!==47&&(!Ce(v.scheme)||e!==92)&&(ke||e!==63&&e!==35)){let n=f+ft(e);for(;n<S.length;){let r=C(S,n);if(r==null||r===47||Ce(v.scheme)&&r===92||!ke&&(r===63||r===35))break;n+=ft(r)}J+=St(S.slice(f,n),ma),f=n,e=C(S,n)}if(e==null||e===47||Ce(v.scheme)&&e===92||!ke&&(e===63||e===35)){let n=Ce(v.scheme)&&e===92;return(function(i){switch(i){case"..":case"%2e.":case"%2E.":case".%2e":case".%2E":case"%2e%2e":case"%2E%2e":case"%2e%2E":case"%2E%2E":return!0;default:return!1}})(J)?(wp(v),e!==47&&!n&&v.path.push("")):Ap(J)&&e!==47&&!n?v.path.push(""):Ap(J)||(v.scheme==="file"&&v.path.length===0&&Ip(J)&&(J=`${J[0]}:`),v.path.push(J)),J="",e===63?(v.query="",B(t,e)?Vt(C(S,f)):0):e===35?(v.fragment="",B(t,e)?vt(C(S,f)):0):B(t,e)?At(C(S,f)):0}else return J+=xp(e,ma),B(t,e)?At(C(S,f)):0},kp=e=>{let t=f;if(e===63)return v.query="",B(t,e)?Vt(C(S,f)):0;if(e===35)return v.fragment="",B(t,e)?vt(C(S,f)):0;if(e!=null){let n=f+ft(e);for(;n<S.length;){let i=C(S,n);if(i===63||i===35)break;n+=ft(i)}let r=S.slice(f,n);if(n<S.length&&r.charCodeAt(r.length-1)===32?v.path[0]+=St(r.slice(0,-1),dr)+"%20":v.path[0]+=St(r,dr),f=n,(e=C(S,n))===63)return v.query="",B(t,e)?Vt(C(S,f)):0;if(e===35)return v.fragment="",B(t,e)?vt(C(S,f)):0}return B(t,e)?kp(C(S,f)):0},Vt=e=>{let t=f,n=f;if(e!=null){if(ke)n=S.length;else{let i=S.indexOf("#",f);n=i===-1?S.length:i}let r=Ce(v.scheme)?NA:ya;v.query+=St(S.slice(f,n),r)}return f=n,C(S,n)===35&&!ke?(v.fragment="",B(t,e)?vt(C(S,f)):0):B(t,e)?Vt(C(S,f)):0},vt=e=>{let t=f;return e!=null&&(v.fragment+=St(S.slice(f),zA),f=S.length),B(t,e)?vt(C(S,f)):0};function ba(e){if(e.opaquePath)return e.path[0];{let t="";for(let n of e.path)t+=`/${n}`;return t}}function Rp(e){switch(e.scheme){case"blob":{let t=ot(ba(e),null,null,0);return t===null||t.scheme!=="http"&&t.scheme!=="https"?"null":Rp(t)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(n){let r=`${n.scheme}://`;return r+=n.host,n.port!==null&&(r+=`:${n.port}`),r})(e);default:return"null"}}var Ae=Symbol("URLImpl"),mr=class e{constructor(t,n){if(t===void 0&&n===void 0)throw new TypeError('The "url" argument must be specified.');t=he(t),n!=null&&(n=he(n));let r=null;if(n!=null&&(r=ot(n,null,null,0),r==null))throw new TypeError(`Invalid base URL: ${n}`);let i=ot(t,null,r,0);if(i==null)throw new TypeError(`Invalid URL: ${t}`);this[Ae]={url:i,query:null}}static createObjectURL(t){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(t){}static parse(t,n){t=he(t),n!==void 0&&(n=he(n));try{return new e(t,n)}catch{return null}}static canParse(t,n){t=he(t),n!==void 0&&(n=he(n));let r=null;return n!=null&&(r=ot(n,null,null,0),r==null)?!1:ot(t,null,r,0)!=null}get href(){return(function(n){let r=`${n.scheme}:`;return n.host!==null&&(r+="//",(n.username!==""||n.password!=="")&&(r+=n.username,n.password!==""&&(r+=`:${n.password}`),r+="@"),r+=n.host,n.port!==null&&(r+=`:${n.port}`)),n.host===null&&!n.opaquePath&&n.path.length>1&&n.path[0]===""&&(r+="/."),r+=ba(n),n.query!==null&&(r+=`?${n.query}`),n.fragment!==null&&(r+=`#${n.fragment}`),r})(this[Ae].url)}set href(t){let n=ot(t=he(t),null,null,0);if(n==null)throw new TypeError(`Invalid URL: ${t}`);this[Ae].url=n,this[Ae].query&&ua(this[Ae].query,n.query)}get origin(){return Rp(this[Ae].url)}get protocol(){return`${this[Ae].url.scheme}:`}set protocol(t){ot(`${t=he(t)}:`,this[Ae].url,null,2)}get username(){return this[Ae].url.username}set username(t){t=he(t),ca(this[Ae].url)||(function(r,i){r.username=St(i,Ai)})(this[Ae].url,t)}get password(){return this[Ae].url.password}set password(t){t=he(t),ca(this[Ae].url)||(function(r,i){r.password=St(i,Ai)})(this[Ae].url,t)}get host(){let{url:t}=this[Ae];return t.host==null?"":t.port==null?t.host:`${t.host}:${t.port}`}set host(t){t=he(t),this[Ae].url.opaquePath||ot(t,this[Ae].url,null,3)}get hostname(){let{url:t}=this[Ae];return t.host!=null?t.host:""}set hostname(t){t=he(t),this[Ae].url.opaquePath||ot(t,this[Ae].url,null,4)}get port(){let{url:t}=this[Ae];return t.port!=null?`${t.port}`:""}set port(t){t=he(t);let{url:n}=this[Ae];ca(n)||(t?ot(t,n,null,5):n.port=null)}get pathname(){return ba(this[Ae].url)}set pathname(t){t=he(t);let{url:n}=this[Ae];n.opaquePath||(n.path=[],ot(t,n,null,6))}get search(){let{url:t}=this[Ae];return t.query?`?${t.query}`:""}set search(t){t=he(t);let{url:n,query:r}=this[Ae];if(!t)n.query=null,r&&ua(r,null);else{let i=t[0]==="?"?t.substring(1):t;n.query="",ot(i,n,null,7),r&&ua(r,n.query)}}get searchParams(){let t=this[Ae],n=t.query;return n==null&&(n=t.query=(function(i,o){let a=new gi;return a[je].url=i,a[je].serialized=o==null,o&&(a[je].list=xa(o)),a})(this,t.url.query)),n}get hash(){let{url:t}=this[Ae];return t.fragment?`#${t.fragment}`:""}set hash(t){t=he(t);let{url:n}=this[Ae];if(!t)n.fragment=null;else{let r=t[0]==="#"?t.substring(1):t;n.fragment="",ot(r,n,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(mr.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var je=Symbol("URLSearchParamsImpl"),dh=Symbol.dispose||Symbol.for("dispose");function ua(e,t){t?e[je].list=xa(t):e[je].list.length=0,e[je].serialized=t==null}function pi(e){if(e.url){let t=fa(e.list);(function(r,i){r[Ae].url.query=i})(e.url,t||null),e.serialized=!0}}var mh=typeof Iterator<"u"?Iterator:Object,pr=class extends mh{constructor(t,n){super(),this[je]={ptr:t,map:n,index:0}}next(){let t=this[je];return t.index<t.ptr.list.length?{value:t.map(t.ptr.list[t.index++]),done:!1}:{value:void 0,done:!0}}[Symbol.iterator](){return this}[dh](){}},gi=class{constructor(t){let n=this[je]={list:[],url:null,serialized:!0},r;if(Array.isArray(t))for(let i=0;i<t.length;i++)n.list.push(lp(t[i]));else if((r=bp(t))!=null){let i;for(;!(i=la(r.next())).done;)n.list.push(lp(i.value))}else if((typeof t=="object"||typeof t=="function")&&t!=null){let i=Object.keys(t);for(let o=0;o<i.length;o++){let a=i[o],c=BA(a),u=he(t[a]),p=n.list.find(b=>b[0]===c);p?p[1]=u:n.list.push([c,u])}}else if(t!==void 0){let i=he(t);i=i[0]==="?"?i.substring(1):i,n.list=xa(i)}}get size(){return this[je].list.length}append(t,n){t=he(t),n=he(n),this[je].list.push([t,n]);let r=this[je];r.url&&r.serialized?(function(o,a){let c=o[Ae].url;c.query=c.query?`${c.query}&${a}`:a})(r.url,fa([[t,n]])):pi(r)}delete(t,n){t=he(t),n=n!=null?he(n):void 0;let{list:r}=this[je],i=0;for(;i<r.length;)r[i][0]===t&&(n==null||r[i][1]===n)?r.splice(i,1):i++;pi(this[je])}get(t){t=he(t);let{list:n}=this[je];for(let r=0;r<n.length;r++)if(n[r][0]===t)return n[r][1];return null}getAll(t){t=he(t);let n=[],{list:r}=this[je];for(let i=0;i<r.length;i++)r[i][0]===t&&n.push(r[i][1]);return n}has(t,n){t=he(t),n=n!=null?he(n):void 0;let{list:r}=this[je];for(let i=0;i<r.length;i++)if(r[i][0]===t&&(n==null||r[i][1]===n))return!0;return!1}set(t,n){t=he(t),n=he(n);let{list:r}=this[je],i=!1,o=!1,a=0;for(;a<r.length;)r[a][0]===t?i?(r.splice(a,1),o=!0):(i=!0,r[a][1]!==n&&(r[a][1]=n,o=!0),a++):a++;i||(r.push([t,n]),o=!0),o&&pi(this[je])}sort(){this[je].list.sort((t,n)=>t[0]<n[0]?-1:t[0]>n[0]?1:0),pi(this[je])}forEach(t,n){if(typeof t!="function")throw new TypeError('The "callback" argument must be of type function');let{list:r}=this[je];for(let i=0;i<r.length;i++)t.call(n,r[i][1],r[i][0],this)}entries(){return new pr(this[je],t=>t)}keys(){return new pr(this[je],t=>t[0])}values(){return new pr(this[je],t=>t[1])}toString(){return fa(this[je].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(gi.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});function Ep(e){let t,n,r=0,i,o=new Map,a=()=>{for(let O of[...o.keys()])try{O()}catch{}};function c(O,z){let I=++r;i=void 0,t=void 0,n=void 0;for(let d of[...o.values()])try{d?.()}catch{}I===r&&(t=O,n=z,a())}let u=()=>c();function p(O,z=!1){let I=Et.safeParse(O);if(!I.success||z&&Date.parse(I.data.expiresAt)<=Date.now()||Date.parse(I.data.refreshExpiresAt)<=Date.now()||Date.parse(I.data.refreshExpiresAt)<Date.parse(I.data.expiresAt))throw new ce("INVALID_RESPONSE","Invalid customer session credentials");return I.data}async function b(){if(i)return i;let O=t,z=r;if(!O||Date.parse(O.refreshExpiresAt)<=Date.now())throw O&&u(),new ce("UNAUTHENTICATED","Customer authentication is required",401);let I=(async()=>{try{let d=await e(O.refreshToken);if(z!==r)throw new ce("IDENTITY_CHANGED","Customer identity changed during refresh");let g=p(d,!0);if(g.customerId!==O.customerId||g.sessionId!==O.sessionId)throw new ce("SCOPE_MISMATCH","Refresh changed the customer session");return t=g,n=g.accessToken,{...g}}catch(d){throw z!==r?new ce("IDENTITY_CHANGED","Customer identity changed during refresh"):(d instanceof ce&&d.status===401&&u(),d)}})();i=I;try{return await I}finally{i===I&&(i=void 0)}}return{identify(O){let z=typeof O=="string"?void 0:p(O),I=typeof O=="string"?O:z.accessToken;if(!I.trim()||/\s/.test(I)||I.length>4096)throw new ce("INVALID_TOKEN","A server-issued token is required");c(z,I)},reset:u,subscribeIdentity(O,z){return o.set(O,z),()=>{o.delete(O)}},access(){if(t&&Date.parse(t.expiresAt)<=Date.now()+3e4)return b().then(()=>{if(!n)throw new ce("NOT_IDENTIFIED","Customer authentication is required");return n});if(!n)throw new ce("NOT_IDENTIFIED","Identify a customer session before making a request");return n},peek:()=>n,snapshot:()=>t&&{...t},refresh:b}}var Dp=Symbol("IndianaNoContent");function Oj(e,t,n=mr){let r=e.configuration?.scope,i=e.scope??(r&&{projectId:r.projectId,environment:r.environment}),o=i?Se.parse(i):void 0;if(o&&r&&(o.projectId!==r.projectId||o.environment!==r.environment))throw new ce("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=new n(e.baseUrl??us);if(a.username||a.password||a.search||a.hash)throw new ce("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(a.protocol!=="https:"&&!(a.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(a.hostname)))throw new ce("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let c=e.fetch??globalThis.fetch.bind(globalThis),u=e.timeoutMs??1e4;if(!Number.isFinite(u)||u<1||u>12e4)throw new ce("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let p=null,b=0,O=null,z=new Set,I=e.session??Ep(async te=>{let xe=await X("customer-sessions/refresh",{},"POST",{},te);if(!xe||typeof xe!="object")throw new ce("INVALID_RESPONSE","Invalid refresh response");let{requestId:M,scope:se,...re}=xe;return re});function d(){b+=1,p=null,O=null;for(let te of z)te.abort();z.clear()}let g=I.subscribeIdentity(d);function E(){I.reset()}async function X(te,xe={},M="POST",se={},re){let V=se.installationDetach===!0;if(V&&(te!=="push/installations/detach"||M!=="POST"))throw new ce("INVALID_REQUEST","Installation authority only detaches this installation");if(!re&&!p&&!V)throw new ce("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let Qe=b,Je=new AbortController;V||z.add(Je);let fr=()=>!V&&Qe!==b?new ce("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new ce("TIMEOUT","Indiana request timed out"),yi,Tp=new Promise((Ue,Xe)=>{yi=()=>Xe(fr()),Je.signal.addEventListener("abort",yi,{once:!0})}),Mp=setTimeout(()=>Je.abort(),u),Bp=async()=>{let Ue=await c(`${a.href.replace(/\/$/,"")}/api/v1/${te}`,{method:M,headers:{"Content-Type":"application/json",...V?{}:{Authorization:`Bearer ${re??p}`},[Ui]:Vi.current,[Ds]:cs.version,...o?{"X-Indiana-Project":o.projectId,"X-Indiana-Environment":o.environment}:{}},body:M==="POST"?JSON.stringify(xe):void 0,signal:Je.signal,credentials:"omit",cache:"no-store",redirect:"error",...se.keepalive?{keepalive:!0}:{}});if(Je.signal.aborted)throw fr();let Xe;try{Xe=Ue.status===204?Dp:await Ue.json()}catch{throw Je.signal.aborted?fr():new ce(Ue.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",Ue.status,Ue.headers.get("X-Request-Id")??void 0)}if(Je.signal.aborted)throw fr();if(!V&&Qe!==b)throw new ce("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!Ue.ok){let Me=Pa.safeParse(Xe),_t=Me.success&&(!xi.safeParse(Me.data.error.code).success||_a(Me.data.error.code,Ue.status)),wa=_t?Me.data.error.code:"HTTP_ERROR",ja=Ca(wa,Ue.status,{retryAfter:Ue.headers.get("Retry-After"),recovery:_t?Me.data.error.recovery:void 0,reason:_t?Me.data.error.reason:void 0});throw new ce(wa,_t?Me.data.error.message:"Indiana request failed",Ue.status,Ue.headers.get("X-Request-Id")??(Me.success?Me.data.requestId:void 0),{...ja,...Me.success&&Me.data.error.retryable===!1?{retryable:!1}:{},...ja.retryAfterSeconds===void 0&&Me.success&&Me.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:Me.data.error.retryAfterSeconds}:{}})}if(Ue.headers.get(Ui)!==Vi.current)throw new ce("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(o&&Xe!==Dp){let Me=Xe&&typeof Xe=="object"&&"scope"in Xe?Xe:Xe&&typeof Xe=="object"&&"configuration"in Xe?Xe.configuration:null;if(!Me||typeof Me!="object"||!("scope"in Me))throw new ce("INVALID_RESPONSE","Response is missing its App/environment scope");let _t=Se.safeParse(Me.scope);if(!_t.success||_t.data.projectId!==o.projectId||_t.data.environment!==o.environment)throw new ce("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let Ar=Ue.headers.get("X-Indiana-Telemetry-Subject");if(Ar){if(!/^[a-f0-9]{64}$/.test(Ar))throw new ce("INVALID_RESPONSE","Invalid telemetry identity");O!==Ar&&(O=Ar,t?.(O))}return Xe};try{return await Promise.race([Bp(),Tp])}catch(Ue){throw!V&&Qe!==b?new ce("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):Ue instanceof ce?Ue:new ce(Je.signal.aborted?"TIMEOUT":"NETWORK_ERROR",Je.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(Mp),Je.signal.removeEventListener("abort",yi),z.delete(Je)}}return{session:I,requestWithCredential(te,xe,M){return X(te,xe,"POST",{},M)},subjectKey:()=>O,identify(te){if(o&&typeof te=="object"&&"scope"in te){let xe=Se.safeParse(te.scope);if(!xe.success||xe.data.projectId!==o.projectId||xe.data.environment!==o.environment)throw new ce("SCOPE_MISMATCH","Customer session belongs to another App/environment")}I.identify(te),p=I.peek()??null},reset:E,dispose(){g(),d()},request(te,xe={},M="POST",se={}){if(se.installationDetach)return X(te,xe,M,se);let re=b;try{let V=I.access(),Qe=Je=>{if(re!==b)throw new ce("IDENTITY_CHANGED","Customer identity changed before dispatch");return X(te,xe,M,se,Je)};return typeof V=="string"?Qe(V):V.then(Qe)}catch(V){return Promise.reject(V)}}}}export{lg as a,pg as b,dg as c,mg as d,Rr as e,Ag as f,Rt as g,dn as h,ms as i,vh as j,Ih as k,Fp as l,gs as m,jh as n,Vp as o,Lp as p,$p as q,Ir as r,Or as s,Hp as t,_h as u,Zp as v,Ph as w,Ch as x,xs as y,Eh as z,Dh as A,Jp as B,Wp as C,qh as D,at as E,Ti as F,Mi as G,zi as H,sg as I,Ny as J,go as K,cf as L,Pu as M,So as N,px as O,dx as P,mx as Q,Rx as R,Ex as S,Dx as T,US as U,al as V,Uf as W,Vf as X,bv as Y,Fo as Z,$f as _,yv as $,xv as aa,Sv as ba,or as ca,Ev as da,hl as ea,Al as fa,Lo as ga,Gf as ha,Uv as ia,_ as ja,gI as ka,gA as la,ta as ma,tp as na,DI as oa,qI as pa,np as qa,GI as ra,xA as sa,KI as ta,En as ua,SA as va,IA as wa,nO as xa,lO as ya,pO as za,AO as Aa,kA as Ba,TO as Ca,MO as Da,BO as Ea,UO as Fa,ZO as Ga,QO as Ha,JO as Ia,XO as Ja,YO as Ka,mr as La,Oj as Ma};