@tinkerlandai/longplay-sdk 0.10.51 → 0.10.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/check-response-AVQ7PY5I.js +1 -0
- package/dist/{chunk-IDDPWGQE.js → chunk-2MDJ3JE5.js} +1 -1
- package/dist/{chunk-SZZIYCXK.js → chunk-3LWZFXLN.js} +1 -1
- package/dist/{chunk-TIOPNTMP.js → chunk-3TV3CVNP.js} +1 -1
- package/dist/{chunk-7GU34JD4.js → chunk-4CRUNNTC.js} +1 -1
- package/dist/{chunk-TIUD3N72.js → chunk-4OSW2Y67.js} +1 -1
- package/dist/{chunk-IVXYLNAF.js → chunk-5YQZEJBM.js} +1 -1
- package/dist/{chunk-FN462OVO.js → chunk-7LHRBNSH.js} +1 -1
- package/dist/{chunk-3ITNAFAH.js → chunk-7Q25R5GL.js} +1 -1
- package/dist/{chunk-LE32WTZ7.js → chunk-7UXQJJFZ.js} +1 -1
- package/dist/{chunk-N3PZMMOO.js → chunk-AFZB2AYU.js} +1 -1
- package/dist/{chunk-US65SQX4.js → chunk-AN7CPDBU.js} +1 -1
- package/dist/{chunk-JDIFYMSA.js → chunk-BBA64POP.js} +1 -1
- package/dist/{chunk-ZDIWOE4Q.js → chunk-BYHBBZIO.js} +1 -1
- package/dist/{chunk-HYX3EDZS.js → chunk-CBOIDISB.js} +1 -1
- package/dist/{chunk-KSME3N3A.js → chunk-CJUVMNDB.js} +1 -1
- package/dist/{chunk-4NO6U4X6.js → chunk-DJYLJBU2.js} +1 -1
- package/dist/{chunk-PJAZ2UP4.js → chunk-EDV6ZNPQ.js} +1 -1
- package/dist/chunk-EJAF6OGO.js +1 -0
- package/dist/{chunk-FRRKTQNZ.js → chunk-FAMPOY6L.js} +1 -1
- package/dist/{chunk-GJSQZGBE.js → chunk-FKC7TJWM.js} +1 -1
- package/dist/{chunk-W3B4GT74.js → chunk-I643NVMZ.js} +1 -1
- package/dist/{chunk-HP6OV6WF.js → chunk-JRHJO4BR.js} +1 -1
- package/dist/{chunk-Y2ASROJH.js → chunk-K644WUOE.js} +1 -1
- package/dist/{chunk-YFLVGOCJ.js → chunk-KVIGHX2B.js} +1 -1
- package/dist/{chunk-VKFLQEW4.js → chunk-KXSZTBAG.js} +1 -1
- package/dist/chunk-L66EXWTK.js +1 -0
- package/dist/{chunk-FYD7CMS7.js → chunk-LDLS2VL2.js} +1 -1
- package/dist/{chunk-67LPUJMN.js → chunk-NVHRWZIZ.js} +1 -1
- package/dist/{chunk-IXXVMGMF.js → chunk-OEUA65JK.js} +1 -1
- package/dist/{chunk-HYCLLEFU.js → chunk-PGZZKX5K.js} +1 -1
- package/dist/{chunk-MQ5LJEWV.js → chunk-POX2ELNS.js} +1 -1
- package/dist/{chunk-3Z3HL42M.js → chunk-PZZLYHKR.js} +2 -2
- package/dist/chunk-QIY6PCYC.js +1 -0
- package/dist/{chunk-OPUIFAQS.js → chunk-RUMGXXVJ.js} +1 -1
- package/dist/{chunk-RFWVXTZ7.js → chunk-S4YBFFFY.js} +1 -1
- package/dist/{chunk-VPYKAEHU.js → chunk-S6MXUFVF.js} +1 -1
- package/dist/{chunk-EGFVGCDG.js → chunk-TSBXPDUQ.js} +1 -1
- package/dist/{chunk-LSHIR6QM.js → chunk-UCDQJB53.js} +1 -1
- package/dist/{chunk-2I2S5ZIH.js → chunk-USM6HOXG.js} +1 -1
- package/dist/{chunk-B4SM2KRI.js → chunk-VGEH7B6S.js} +1 -1
- package/dist/{chunk-A5KU4MMN.js → chunk-VPT5MFDG.js} +2 -2
- package/dist/{chunk-DB5S72HJ.js → chunk-W3V7DTPC.js} +1 -1
- package/dist/{chunk-KCN6OGYG.js → chunk-XI2NNZBS.js} +1 -1
- package/dist/{chunk-3TSFGU4T.js → chunk-XO6GV6O7.js} +1 -1
- package/dist/{chunk-2LEDTNKQ.js → chunk-YGOXUDDF.js} +1 -1
- package/dist/{chunk-PF6PRPRO.js → chunk-YJRO7NXN.js} +1 -1
- package/dist/{chunk-2G23BYBI.js → chunk-ZNOVEJLM.js} +1 -1
- package/dist/{chunk-TNPBYYAX.js → chunk-ZVLZLBDA.js} +1 -1
- package/dist/chunk-ZY4YDPSI.js +1 -0
- package/dist/{content-VTHRQSFT.js → content-2EEYM7U7.js} +1 -1
- package/dist/funnel-host-purchase-UONTZRRJ.js +1 -0
- package/dist/funnel-paywall-prerender-AT4BXZIY.js +1 -0
- package/dist/funnel-route-prediction-Z3J2HSHI.js +1 -0
- package/dist/funnel-route-source-LFE6GSHU.js +1 -0
- package/dist/funnel-runtime-host-7ROIR7CU.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-O6WIWC7T.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-H7NKQ373.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-25MAYQ4B.js +1 -0
- package/dist/paywall-content-7KTEQLRN.js +1 -0
- package/dist/paywall-session-7HGW5IKN.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-XZWKIJWF.js +1 -0
- package/dist/server.js +1 -1
- package/dist/{visual-dom-IN6DRNX3.js → visual-dom-5LUN4AHO.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-MCT5RGOM.js +0 -1
- package/dist/chunk-CGJZIDG3.js +0 -1
- package/dist/chunk-MVUNV5XR.js +0 -1
- package/dist/chunk-TM72XBM5.js +0 -1
- package/dist/funnel-host-purchase-HBQOWEES.js +0 -1
- package/dist/funnel-paywall-prerender-MD4UI2AP.js +0 -1
- package/dist/funnel-route-prediction-XNIKDJIM.js +0 -1
- package/dist/funnel-route-source-EUIA4M3Y.js +0 -1
- package/dist/funnel-runtime-host-NZAV6C5O.js +0 -1
- package/dist/merchant-bridge-contracts-7EHDNPJJ.js +0 -1
- package/dist/operation-contracts-C6CMAO6S.js +0 -1
- package/dist/paywall-DKTGQZDJ.js +0 -1
- package/dist/paywall-content-SML4CL2Q.js +0 -1
- package/dist/paywall-session-YKE2CHHI.js +0 -1
- package/dist/screen-renderer-HW2WXDTR.js +0 -1
- /package/dist/{chunk-WPFTSHP2.js → chunk-CILM5XMH.js} +0 -0
- /package/dist/{chunk-RA7GZ67U.js → chunk-OJM6ORHE.js} +0 -0
- /package/dist/{chunk-XVCSRZX4.js → chunk-PY3AC5KD.js} +0 -0
- /package/dist/{chunk-3Z3HL42M.js.LEGAL.txt → chunk-PZZLYHKR.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-A5KU4MMN.js.LEGAL.txt → chunk-VPT5MFDG.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as K,b as fe,c as ge,d as ye,e as T,f as $e,g as Le,j as be,m as Q}from"./chunk-IDDPWGQE.js";import{a as He,i as Ze,y as We}from"./chunk-EGFVGCDG.js";import{w as Pe}from"./chunk-YFLVGOCJ.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-FRRKTQNZ.js";import{m as Je,n as J,o as B}from"./chunk-MQ5LJEWV.js";import{C as me,f as Ve,g as Ue,h as Be,p as pe,v as L,w as H,x as Z,y as de,z as Te}from"./chunk-JDIFYMSA.js";import{b as Me,d as S,e as U,f as qe,g as Ge,h as W}from"./chunk-PF6PRPRO.js";import{h as V}from"./chunk-FYD7CMS7.js";import{b as e}from"./chunk-XVCSRZX4.js";var E=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(o=>!["__proto__","constructor","prototype"].includes(o)),"Reserved value path"),C=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:S}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:E.optional()})]);function Qe(t,o){if(!o)return t;for(let n of E.parse(o).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function _t(t,o){if(t.source==="literal")return structuredClone(t.value);let n=Le(o.declarations,o);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(S.parse(Qe(n[t.key],t.path)))}function he(t,o){let n=[...o].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!E.safeParse(s).success?null:{key:n,path:s}}function xe(t){let o=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return L(t,n=>{n.type==="custom_html"&&o.push(...Object.values(n.html))}),[...new Set(o.flatMap(Be))]}function Xe(t){return xe(t).filter(o=>o.startsWith("variables.")).map(o=>o.slice(10))}function F(t){let o=JSON.stringify(t);if(o===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(o).length,s=!1;for(let i=0;i<o.length;i++){let a=o.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let f=i;for(;i+1<o.length&&/[0-9.eE+-]/.test(o.charAt(i+1));)i++;let m=o.slice(f,i+1);if(!/[eE]/.test(m))continue;let[x="",_]=m.split(/[eE]/),p=x.replace(/^-/,""),v=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):v)+Number(_),d=N<=0?2-N+v:N>=v?N:v+1;n+=d+(x.startsWith("-")?1:0)-m.length}}return n}var Kt=e.string().regex(/^[a-f0-9]{64}$/),Et=Ve.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),Ye=e.strictObject({couponDigests:e.record(e.uuid(),Kt),variables:e.record(pe,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(pe,Ue.extend({nodes:e.record(e.string(),e.strictObject({base:Et})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var et=e.enum(["funnel-run/1","funnel-process/1"]),Kn="funnel-process/1";var Se=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),tt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),nt=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),ve=e.record(Se,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),Dt=C,rt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:Se,inputs:e.record(Se,Dt).refine(t=>Object.keys(t).length<=20),outputs:ve}),it=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Pn=e.strictObject({outcome:e.enum(["success","failure"]),data:nt});var Vn=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:tt,eventName:Q,eventId:e.uuid(),data:nt}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Un=e.strictObject({scope:V,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),At=e.record(tt,be),Bn=e.strictObject({scope:V,runId:e.uuid(),results:At});var Ct=["id","externalUserId","createdAt","ageDays","subscription"],we=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"标签不能包含逗号")).max(20).refine(t=>new Set(t).size===t.length,"标签不能重复"),X=e.intersection(U,e.looseObject({tags:we.optional()})).refine(t=>![...Ct,"parameters","answers","results"].some(o=>Object.hasOwn(t,o)),"Reserved customer attribute"),Y=e.string().trim().max(80),ee=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),te=e.union([e.email().max(254),e.literal("")]),Nt=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ot=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Gn=e.object({externalUserId:ot.optional(),name:Y.default(""),email:te.default(""),phone:ee.optional(),attributes:X.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","请提供业务用户 ID 或邮箱"),ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ot})]),re=e.strictObject({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.optional(),fingerprint:Nt.optional()}),ie=t=>!t.customerData||t.customer?.type==="externalUserId",oe="customerData requires an externalUserId customer",at=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:Y,email:te,phone:ee.optional(),attributes:X,createdAt:e.iso.datetime()}).strict(),$n=e.object({customer:at,changed:e.boolean(),replayed:e.boolean()}).strict(),zt=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),Ft=e.object({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:we,remove:we}).optional()}).strict().refine(t=>Object.keys(t).length>0,"请提供需要修改的字段"),Pt=e.object({lookup:zt}).strict(),Ln=Pt.extend({requestId:e.uuid(),patch:Ft}).strict(),Hn=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Zn=e.object({customers:at.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var Yn=e.enum(["local","remote"]),Ie=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:S.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(S).max(100),features:e.array(S).max(100)}),st=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:U,sticky:e.record(e.string(),W)}),ct=st.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),Vt=st.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),ut=e.strictObject({nodeId:e.string().min(1).max(64),result:Ie}),lt=Vt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:J,variables:e.record(e.string(),S)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:S}),e.strictObject({type:e.literal("variable"),key:K,path:E.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),Ut=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:S}),Bt={funnelId:e.uuid(),requestId:e.uuid(),customer:ne,customerData:re.optional(),attributes:U.refine(t=>!["parameters","answers","results","variables"].some(o=>Object.hasOwn(t,o)),"parameters, answers, results and variables are reserved flow namespaces")},cr=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...Bt}).refine(ie,oe),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:Ie}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(ut).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),ur=e.strictObject({scope:V,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:Ut.nullable(),evaluation:e.discriminatedUnion("type",[ct,lt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),lr=e.strictObject({scope:V,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function Mt(t,o=[]){let n=[];L(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),o.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(de(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let f of Object.keys(a))s.has(f)||n.push(`Unused string ${f} must not be delivered (${i})`);return n}function pt(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(o=>pt(o)??[])}}function Tt(t){let o=t.pages.map(i=>{let a=pt(i.root);return a?.type==="stack"?{...i,root:a}:{...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(de({pages:o}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([f])=>n.has(f)))]));return{...t,pages:o,strings:{...t.strings,locales:s}}}function dt(t,o=[]){let n=H.parse(structuredClone(Tt(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=Mt(n,o);if(i.length)throw new Error(i.join("; "));return n}var gr=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,o)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&o.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),mt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var qt=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],je="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",Gt=e.string().regex(new RegExp(`^${je}/${je}/${je}/manifest\\.json$`)),ft=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(qt),objectKey:Gt,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,o)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&o.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var h=e.string().min(1).max(256),j=e.string().regex(/^[a-f0-9]{64}$/),ae=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,elementKey:h.optional(),nodeId:h.optional(),contentHash:j.optional(),renderKey:h.optional()}),gt=e.strictObject({pageKey:h,documentKey:h,expectedDocumentHash:j,renderKey:h.optional(),nodeId:h,elementKey:h,expectedContentHash:j,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),wr=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,renderKey:h.optional(),patches:e.array(gt.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),$t=/^[a-z][a-z0-9-]{0,39}$/,G=e.string().regex($t),Re=e.enum(["web","ios","android"]),yt={requestId:e.uuid(),client:G,platform:Re,label:e.string().trim().min(1).max(100),sha256:j,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},Lt=e.strictObject({action:e.literal("upload"),...yt,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ir=e.discriminatedUnion("action",[Lt,e.strictObject({action:e.literal("register"),...yt}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:h,changesetId:e.uuid().nullable(),expectedRevision:j.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(gt).max(200)})]),_e=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:G,platform:Re,label:e.string(),sha256:j,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),Ht=e.strictObject({key:G,platform:Re,currentId:e.uuid().nullable()}),Or=e.strictObject({rows:e.array(_e).max(100),nextCursor:e.uuid().nullable(),clients:e.array(Ht).max(20)}),ke=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),jr=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:ke,runtime:ke,previews:ke})}),kr=e.strictObject({version:_e,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Rr=e.strictObject({version:_e,upload:ft.nullable()}),_r=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:h,path:e.string(),documentKey:h,documentHash:j,initialStateKey:h,initialRenderKey:h})),renders:e.array(mt)}).loose().superRefine((t,o)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&o.addIssue({code:"custom",message:"Incomplete render catalog"})}),Kr=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:h,key:h,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Er=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var Zt=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),bt=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:G,source:ae,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:Zt.optional()}).superRefine((t,o)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&o.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},ht="00000000-0000-0000-0000-000000000000";var xt=e.strictObject({type:e.literal("bundle"),paywall:C.optional(),offering:C.optional(),coupons:C,data:C}),Wt=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Br=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:S});var Mr=e.strictObject({type:e.literal("bundle"),offering:Wt("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(Ze).max(20),data:S});var St=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([St,e.array(St).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),vt=e.strictObject({path:E,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:Qt.optional()}).superRefine((t,o)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&o.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Xt=["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"],wt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Yt=C,It=e.discriminatedUnion("type",[rt,e.strictObject({type:e.literal("claim_offer"),coupon:C}),e.strictObject({type:e.literal("event"),event:wt}),e.strictObject({type:e.literal("api"),operation:e.enum(Xt),inputs:e.record(E,Yt).refine(t=>Object.keys(t).length<=40),outputs:e.record(wt,vt).refine(t=>Object.keys(t).length<=20)})]);var y=Q,en=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),k={id:y,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},tn={success:y,cancel:y,unavailable:y,failure:y},nn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),rn=e.enum(["same_window","new_window"]),on=e.discriminatedUnion("type",[e.strictObject({...k,type:e.literal("entry"),next:y,triggers:e.array(bt).max(20).refine(t=>new Set(t.map(o=>o.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...k,type:e.literal("screen"),screenId:y,presentation:Me,outputs:e.record(y,y),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:K}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...k,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("output"),value:e.discriminatedUnion("type",[...Oe.options,xt,e.strictObject({type:e.literal("selection"),screenId:y,offeringKey:K})])}),e.strictObject({...k,type:e.literal("condition"),cases:e.array(e.strictObject({condition:qe,target:y})).min(1).max(50),default:y}),e.strictObject({...k,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(en,y).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:y}),e.strictObject({...k,type:e.literal("action"),...tn,execution:it,action:It,writes:ye.optional()}),e.strictObject({...k,type:e.literal("external_page"),appManifest:ae.optional(),url:nn,openIn:rn,opened:y,failed:y}),e.strictObject({...k,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Oe.optional()}),e.strictObject({...k,type:e.literal("wait"),writes:ye.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:y}),e.strictObject({type:e.literal("event"),eventName:y,outputs:ve,timeoutSeconds:e.number().int().min(1).max(2592e3),received:y,timeout:y})])})]),Ke=e.strictObject({version:e.literal(5),entry:y,nodes:e.array(on).min(1).max(D.flowNodes)}),Ee=Ke.superRefine((t,o)=>{an(t,n=>o.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function se(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(o=>o.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function an(t,o){let n=[],s=new Map(t.nodes.map(p=>[p.id,p])),i=(p,v,N)=>{n.push(p),o?.({message:p,reason:v,path:N?["nodes",t.nodes.indexOf(N)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(p=>p.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(p=>p.type==="screen").length>D.pages||t.nodes.filter(p=>!["screen","entry","end","output"].includes(p.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let p of t.nodes){for(let v of se(p))v===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(v)||i(`Missing target ${v}`,"missingTarget",p);p.type==="screen"&&(a.has(p.screenId)&&i("Every screen has exactly one node owner","screenOwner",p),a.add(p.screenId))}let f=new Set,m=new Set,x=new Set;function _(p){if(f.has(p)){i("Flow edges must not form a cycle","cycle",s.get(p));return}if(!(m.has(p)||!s.has(p))){f.add(p),x.add(p);for(let v of se(s.get(p)))_(v);f.delete(p),m.add(p)}}_(t.entry);for(let p of t.nodes)x.has(p.id)||i("Every node must be reachable from Entry","unreachable",p);return[...new Set(n)]}var De={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Ot(t,o,n){let s=[...o].sort((m,x)=>x.length-m.length),i=new Set,a=(m,x=!1)=>{let _=s.find(p=>m===p||x&&m.startsWith(p+"."));i.add(_??m)};if(t.type==="condition"){let m=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let x of t.cases.slice(0,m+1))for(let _ of q(x.condition))_.startsWith("variables.")&&a(_.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let m of Object.values(t.action.inputs))m.source==="variable"&&a(m.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let f=t.type==="output"?t.value:t.type==="end"?t.output:null;if(f?.type==="variable"&&a(f.key),f?.type==="bundle")for(let m of[f.paywall,f.offering,f.coupons,f.data])m?.source==="variable"&&a(m.key);return f?.type==="selection"&&a(f.offeringKey),[...i]}var M=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ce=t=>e.record(e.string(),S).refine(o=>F(o)<=t,"Funnel evidence exceeds its byte budget"),xi=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Ce=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Si=e.strictObject({schemaVersion:e.literal(1),kind:Ce,selector:Ne.nullable(),context:ce(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>F(t)<=131072,"Node input exceeds its byte budget"),vi=e.strictObject({schemaVersion:e.literal(1),kind:Ce,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ce(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ce(131072)}).refine(t=>F(t)<=131072,"Node result exceeds its byte budget"),wi=e.strictObject({schemaVersion:e.literal(1),operations:e.record(M,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:M,id:e.uuid()}).nullable()}))}).refine(t=>F(t)<=65536,"Execution state exceeds its byte budget"),P={receiptId:e.uuid()},Ae=e.iso.datetime({offset:!0}),Ii=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:Ce})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...P,source:e.literal("client"),occurredAt:Ae.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(P)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:M,eventName:M,data:ce(8192),source:e.literal("server"),occurredAt:Ae})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...P,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(P)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(P)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...P,operation:M,reference:e.strictObject({type:M,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...P,source:e.enum(["client","server"]),occurredAt:Ae,reference:e.string().min(1).max(128).optional()})})]);var R=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),sn=e.discriminatedUnion("type",[e.strictObject({id:R,type:e.literal("owned"),publicData:Ye.optional(),document:H.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(o=>o.type==="event"&&!o.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:R,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),ze={executionContract:et.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(sn).max(D.pages),references:e.record(R,Ne).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:R,screenId:R,componentId:R,required:e.boolean()})).max(D.questions),variables:e.record(K,ge).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:fe,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(De.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(De.maxTransitions)})},$i=e.strictObject({...ze,graph:Ke});function cn(t,o){let n=!1,s=(i,a)=>{let f=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(m=>m[i.text]?.includes("{{offer."))&&!(f&&o(f))&&(n=!0),i.type==="stack"&&i.children.forEach(m=>s(m,f))};for(let i of t.pages)s(i.root);return n}function le(t){return Array.isArray(t)?t.some(le):!t||typeof t!="object"?!1:Object.entries(t).some(([o,n])=>o==="productVersionId"?n===ht:le(n))}function un(t){let o=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=dt(i.document)}catch(f){o.push({message:f instanceof Error?f.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[f,m]of t.inputs.entries())m.screenId===i.id&&!me(a,m.componentId)&&o.push({message:`Local Funnel input ${m.variable} targets hidden component ${m.componentId} on screen ${m.screenId}`,reason:"inputBinding",path:["inputs",f]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],f=i.type==="screen"?t.screens.find(m=>m.id===i.screenId):void 0;f?.type==="owned"&&(f.document.actions.some(m=>typeof m.properties.templateKey=="string"&&m.properties.templateKey.startsWith("popup-coupon-"))&&o.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),cn(f.document,m=>n.has(m))&&o.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&le(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&le(i.output.value))&&o.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return o}function jt(t,o){for(let{message:n,reason:s,path:i}of un(t))o.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function kt(t,o){let n=(d,r,c=[])=>o.addIssue({code:"custom",message:d,path:c,params:{reason:r}}),s=Object.values(t.references),i=new Map(t.screens.map(d=>[d.id,d])),a=(d,r)=>s.some(c=>c.type===d&&("id"in c?c.id:c.key)===r);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let f=t.graph.nodes.filter(d=>d.type==="screen");(f.length!==i.size||f.some(d=>!i.has(d.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let m=new Map,x=Object.keys(t.variables);x.some(d=>x.some(r=>d!==r&&r.startsWith(d+".")))&&n("Variable paths must not overlap","variable");function _(d,r){Object.hasOwn(t.variables,d)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(r)]);let c=m.get(d)??new Set;c.add(r.id),m.set(d,c)}for(let[d,r]of t.graph.nodes.entries()){let c=["graph","nodes",d],w=r.type==="feature"?r.featureKey:r.type==="offering"&&r.configuration.source==="feature"?r.configuration.featureKey:r.type==="output"&&r.value.type==="feature"?r.value.featureKey:r.type==="end"&&r.output?.type==="feature"?r.output.featureKey:null;w&&!a("flag",w)&&n("Flag selectors require an explicit GB resource reference","feature",c);let I=r.type==="feature"||r.type==="offering"||r.type==="coupon"||r.type==="coupons"||r.type==="action"&&r.action.type==="api"?["value"]:r.type==="action"&&r.action.type==="external_task"?Object.keys(r.action.outputs):r.type==="wait"&&r.wait.type==="event"?Object.keys(r.wait.outputs):[],O="writes"in r?r.writes??{}:{};(I.length!==Object.keys(O).length||I.some(u=>!Object.hasOwn(O,u))||new Set(Object.values(O)).size!==Object.values(O).length)&&n("Node writes must map every named output exactly once","variable",c);for(let[u,b]of Object.entries(O)){_(b,r);let g=t.variables[b],l=r.type==="offering"?"offering_version":r.type==="coupon"?"reward":r.type==="action"&&r.action.type==="api"?"json":r.type==="action"&&r.action.type==="external_task"?r.action.outputs[u]:r.type==="wait"&&r.wait.type==="event"?r.wait.outputs[u]:void 0;(g?.source.type!=="node"||l&&g.type!==l)&&n("Node writer source or output type does not match declaration","variable",c)}if(r.type==="coupons"){let u=t.variables[r.writes.value];(u?.type!=="array"||u.items?.type!=="reward"||u.items.nullable||u.nullable)&&n("Coupons output requires a non-null Reward array","variable",c);for(let b of r.couponIds)a("reward",b)||n("Coupons require Reward references","coupon",c)}if(r.type==="split"&&!a("experiment",r.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",c),r.type==="coupon"&&!a("reward",r.couponId)&&n("Coupon selectors require a Reward reference","coupon",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="literal"){let u=r.action.coupon.value;(!u||typeof u!="object"||Array.isArray(u)||u.type!=="reward"||typeof u.id!="string"||Object.keys(u).length!==2||!a("reward",u.id))&&n("Coupon claims require a Reward reference","coupon",c)}if(r.type==="offering"&&r.configuration.source==="fixed"&&!a("offering_version",r.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",c),r.type==="screen"&&r.offering?.source==="variable"&&t.variables[r.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="variable"&&(t.variables[r.action.coupon.key]?.type!=="reward"||r.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",c),r.type==="screen"){let u=i.get(r.screenId);if(r.offering?.source==="fixed"&&!a("offering_version",r.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",c),u?.type==="paywall"&&r.offering&&n("Paywall owns its fixed Offering Version","offering",c),u?.type==="paywall"&&!a("paywall_version",u.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",c),u?.type==="owned"){let b=u.document.pages[0];if(!b){n("Owned screen requires a page","screen",c);continue}Te(u.document).some(l=>!l.complete)&&n("Owned screens require complete local content","translations",c);let g=new Set(u.document.actions.map(l=>l.id));(g.size!==Object.keys(r.outputs).length||Object.keys(r.outputs).some(l=>!g.has(l)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",c),Z(b.root,l=>{!r.offering&&(l.type==="plan_picker"||(l.type==="stack"||l.type==="button")&&l.bind?.plan||l.type==="customer_data"&&["customer_plans","credit_packs"].includes(l.data.source))&&n("Product presentation requires an Offering Version","offering",c),l.type==="customer_data"&&Object.values(l.data.outputs??{}).some(z=>z!==void 0&&!g.has(z))&&n("Customer components require declared screen outcomes","componentOutput",c)})}}r.type==="end"&&["completed","ineligible"].includes(r.outcome)&&!r.output&&n("Completed and ineligible ends require a declared output","output",c),r.type==="end"&&r.output?.type==="literal"&&!T(t.outputSchema,r.output.value)&&n("Terminal output does not match outputSchema","output",c),r.type==="output"&&r.value.type==="literal"&&!T(t.outputSchema,r.value.value)&&n("Terminal output does not match outputSchema","output",c);let A=r.type==="output"?r.value:r.type==="end"?r.output:void 0;if(A?.type==="variable"&&!A.path){let u=t.variables[A.key];u&&!$e(u,t.outputSchema)&&n("Variable output does not match outputSchema","output",c)}if(r.type==="screen"){let u=i.get(r.screenId);if(u?.type==="owned")for(let b of xe(u.document))(/^(input|params)\./.test(b)||b.startsWith("variables.")&&!he(b.slice(10),x))&&n("Screen values must reference registered variables","variable",c)}if(r.type==="condition")for(let u of r.cases){for(let b of Ge(u.condition))a("saved_group",b)||n("Conditions require explicit Saved Group references","savedGroup",c);for(let b of q(u.condition))b.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",c)}if(r.type==="output"&&r.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",c);for(let[u,b]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let g=r.value[u];if(g)if(g.source==="literal"){let l=u==="coupons"?g.value:[g.value];(!Array.isArray(l)||l.length>20||l.some(z=>!T({type:b,nullable:!1},z)||!a(b,z.id))||u==="coupons"&&new Set(l.map(z=>z.id)).size!==l.length)&&n("Bundle requires distinct scoped resource references",u==="coupons"?"coupon":u==="paywall"?"paywall":"offering",[...c,"value",u])}else{let l=t.variables[g.key];(g.path||!l||l.nullable||(u==="coupons"?l.type!=="array"||l.items?.type!=="reward"||l.items.nullable:l.type!==b))&&n("Bundle binding type does not match its slot","output",c)}}}}for(let[d,r]of t.graph.nodes.entries()){let c=r.type==="screen"?i.get(r.screenId):void 0,w=[...Ot(r,x),...c?.type==="owned"?Xe(c.document).map(I=>he(I,x)?.key??I):[]];for(let I of new Set(w)){let b=function(g){if(g===r.id)return!0;if(u.has(g))return!1;u.add(g);let l=t.graph.nodes.find(Rt=>Rt.id===g);return l?(A.has(g)?l.type==="action"?[l.cancel,l.unavailable,l.failure]:l.type==="wait"&&l.wait.type==="event"?[l.wait.timeout]:[]:se(l)).some(b):!1};var N=b;if(!Object.hasOwn(t.variables,I)){n("Consumed variable is undeclared","variable",["graph","nodes",d]);continue}let O=t.variables[I];if(r.type==="screen"&&O.source.type==="input"&&t.inputs.some(g=>g.screenId===r.screenId&&g.variable===I)||O.source.type==="parameter"||O.source.type==="attribute")continue;let A=O.source.type==="input"?new Set(t.inputs.filter(g=>g.variable===I&&g.required).flatMap(g=>f.filter(l=>l.screenId===g.screenId).map(l=>l.id))):m.get(I)??new Set,u=new Set;(!A.size||b(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",d])}}(new Set(t.inputs.map(d=>d.variable)).size!==t.inputs.length||new Set(t.inputs.map(d=>`${d.screenId}:${d.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[d,r]of t.inputs.entries()){t.variables[r.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",d]);let c=i.get(r.screenId),w=c?.type==="owned"?me(c.document,r.componentId):null;if((w?.type!=="stack"||!w.interaction||!["input","toggle","select","multiselect","tabs"].includes(w.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",d]),w?.type==="stack"&&w.interaction){let I=w.interaction.type==="toggle"?"boolean":w.interaction.type==="multiselect"?"strings":"string";t.variables[r.variable]?.type!==I&&n("Input variable type does not match component","inputBinding",["inputs",d]);let O=t.variables[r.variable]?.enum;O&&!w.children.filter(A=>!A.hidden).every(A=>O.includes(A.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",d])}}for(let[d,r]of Object.entries(t.variables))r.enum&&r.type!=="string"&&n("Only string variables support enum","variable",["variables",d]),r.source.type==="input"&&!t.inputs.some(c=>c.variable===d)&&n("Input variable requires a component binding","inputBinding",["variables",d]);let p=0,v=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});v+=d.document.actions.length}(p>D.components||v>D.actions||F(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var ln=e.strictObject({...ze,graph:Ee}).superRefine(kt),pn=e.strictObject({...ze,graph:Ee,displayName:e.string().trim().min(1).max(80)}).superRefine(kt),Li=pn.superRefine(jt),Hi=ln.superRefine(jt),ue=e.string().regex(Fe),$={requestId:e.uuid(),nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:ue.optional()},dn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:R,answers:J,selection:e.record(R,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:R,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:He.optional(),subscriptionChange:We.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid(),merchantConfirmation:Pe.optional()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),mn=e.object({nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(R,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:Je.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),Zi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ne.optional(),customerData:re.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ie,oe),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:mn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("submit"),...$,input:dn}),e.strictObject({operation:e.literal("back"),...$}),e.strictObject({operation:e.literal("shown"),...$}),e.strictObject({operation:e.literal("close"),...$}),e.strictObject({operation:e.literal("commit_segment"),...$,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:ue.optional()})]);export{_t as a,Xe as b,F as c,Kt as d,Kn as e,Mt as f,gr as g,wr as h,Zt as i,Vn as j,Un as k,Bn as l,Vt as m,Ct as n,Nt as o,Gn as p,ne as q,re as r,ie as s,oe as t,at as u,$n as v,Pt as w,Ln as x,Hn as y,Zn as z,Oe as A,Bt as B,cr as C,ur as D,lr as E,nn as F,rn as G,Si as H,vi as I,pn as J,Zi as K};
|
|
1
|
+
import{a as K,b as fe,c as ge,d as ye,e as T,f as $e,g as Le,j as be,m as Q}from"./chunk-2MDJ3JE5.js";import{a as He,i as Ze,y as We}from"./chunk-TSBXPDUQ.js";import{w as Pe}from"./chunk-KVIGHX2B.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-FAMPOY6L.js";import{m as Je,n as J,o as B}from"./chunk-POX2ELNS.js";import{C as me,f as Ve,g as Ue,h as Be,p as pe,v as L,w as H,x as Z,y as de,z as Te}from"./chunk-BBA64POP.js";import{b as Me,d as S,e as U,f as qe,g as Ge,h as W}from"./chunk-YJRO7NXN.js";import{h as V}from"./chunk-LDLS2VL2.js";import{b as e}from"./chunk-PY3AC5KD.js";var E=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(o=>!["__proto__","constructor","prototype"].includes(o)),"Reserved value path"),C=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:S}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:E.optional()})]);function Qe(t,o){if(!o)return t;for(let n of E.parse(o).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function _t(t,o){if(t.source==="literal")return structuredClone(t.value);let n=Le(o.declarations,o);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(S.parse(Qe(n[t.key],t.path)))}function he(t,o){let n=[...o].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!E.safeParse(s).success?null:{key:n,path:s}}function xe(t){let o=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return L(t,n=>{n.type==="custom_html"&&o.push(...Object.values(n.html))}),[...new Set(o.flatMap(Be))]}function Xe(t){return xe(t).filter(o=>o.startsWith("variables.")).map(o=>o.slice(10))}function F(t){let o=JSON.stringify(t);if(o===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(o).length,s=!1;for(let i=0;i<o.length;i++){let a=o.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let f=i;for(;i+1<o.length&&/[0-9.eE+-]/.test(o.charAt(i+1));)i++;let m=o.slice(f,i+1);if(!/[eE]/.test(m))continue;let[x="",_]=m.split(/[eE]/),p=x.replace(/^-/,""),v=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):v)+Number(_),d=N<=0?2-N+v:N>=v?N:v+1;n+=d+(x.startsWith("-")?1:0)-m.length}}return n}var Kt=e.string().regex(/^[a-f0-9]{64}$/),Et=Ve.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),Ye=e.strictObject({couponDigests:e.record(e.uuid(),Kt),variables:e.record(pe,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(pe,Ue.extend({nodes:e.record(e.string(),e.strictObject({base:Et})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var et=e.enum(["funnel-run/1","funnel-process/1"]),Kn="funnel-process/1";var Se=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),tt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),nt=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),ve=e.record(Se,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),Dt=C,rt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:Se,inputs:e.record(Se,Dt).refine(t=>Object.keys(t).length<=20),outputs:ve}),it=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Pn=e.strictObject({outcome:e.enum(["success","failure"]),data:nt});var Vn=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:tt,eventName:Q,eventId:e.uuid(),data:nt}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Un=e.strictObject({scope:V,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),At=e.record(tt,be),Bn=e.strictObject({scope:V,runId:e.uuid(),results:At});var Ct=["id","externalUserId","createdAt","ageDays","subscription"],we=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"标签不能包含逗号")).max(20).refine(t=>new Set(t).size===t.length,"标签不能重复"),X=e.intersection(U,e.looseObject({tags:we.optional()})).refine(t=>![...Ct,"parameters","answers","results"].some(o=>Object.hasOwn(t,o)),"Reserved customer attribute"),Y=e.string().trim().max(80),ee=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),te=e.union([e.email().max(254),e.literal("")]),Nt=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ot=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Gn=e.object({externalUserId:ot.optional(),name:Y.default(""),email:te.default(""),phone:ee.optional(),attributes:X.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","请提供业务用户 ID 或邮箱"),ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ot})]),re=e.strictObject({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.optional(),fingerprint:Nt.optional()}),ie=t=>!t.customerData||t.customer?.type==="externalUserId",oe="customerData requires an externalUserId customer",at=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:Y,email:te,phone:ee.optional(),attributes:X,createdAt:e.iso.datetime()}).strict(),$n=e.object({customer:at,changed:e.boolean(),replayed:e.boolean()}).strict(),zt=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),Ft=e.object({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:we,remove:we}).optional()}).strict().refine(t=>Object.keys(t).length>0,"请提供需要修改的字段"),Pt=e.object({lookup:zt}).strict(),Ln=Pt.extend({requestId:e.uuid(),patch:Ft}).strict(),Hn=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Zn=e.object({customers:at.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var Yn=e.enum(["local","remote"]),Ie=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:S.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(S).max(100),features:e.array(S).max(100)}),st=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:U,sticky:e.record(e.string(),W)}),ct=st.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),Vt=st.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),ut=e.strictObject({nodeId:e.string().min(1).max(64),result:Ie}),lt=Vt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:J,variables:e.record(e.string(),S)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:S}),e.strictObject({type:e.literal("variable"),key:K,path:E.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),Ut=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:S}),Bt={funnelId:e.uuid(),requestId:e.uuid(),customer:ne,customerData:re.optional(),attributes:U.refine(t=>!["parameters","answers","results","variables"].some(o=>Object.hasOwn(t,o)),"parameters, answers, results and variables are reserved flow namespaces")},cr=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...Bt}).refine(ie,oe),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:Ie}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(ut).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),ur=e.strictObject({scope:V,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:Ut.nullable(),evaluation:e.discriminatedUnion("type",[ct,lt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),lr=e.strictObject({scope:V,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function Mt(t,o=[]){let n=[];L(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),o.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(de(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let f of Object.keys(a))s.has(f)||n.push(`Unused string ${f} must not be delivered (${i})`);return n}function pt(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(o=>pt(o)??[])}}function Tt(t){let o=t.pages.map(i=>{let a=pt(i.root);return a?.type==="stack"?{...i,root:a}:{...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(de({pages:o}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([f])=>n.has(f)))]));return{...t,pages:o,strings:{...t.strings,locales:s}}}function dt(t,o=[]){let n=H.parse(structuredClone(Tt(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=Mt(n,o);if(i.length)throw new Error(i.join("; "));return n}var gr=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,o)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&o.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),mt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var qt=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],je="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",Gt=e.string().regex(new RegExp(`^${je}/${je}/${je}/manifest\\.json$`)),ft=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(qt),objectKey:Gt,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,o)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&o.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var h=e.string().min(1).max(256),j=e.string().regex(/^[a-f0-9]{64}$/),ae=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,elementKey:h.optional(),nodeId:h.optional(),contentHash:j.optional(),renderKey:h.optional()}),gt=e.strictObject({pageKey:h,documentKey:h,expectedDocumentHash:j,renderKey:h.optional(),nodeId:h,elementKey:h,expectedContentHash:j,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),wr=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,renderKey:h.optional(),patches:e.array(gt.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),$t=/^[a-z][a-z0-9-]{0,39}$/,G=e.string().regex($t),Re=e.enum(["web","ios","android"]),yt={requestId:e.uuid(),client:G,platform:Re,label:e.string().trim().min(1).max(100),sha256:j,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},Lt=e.strictObject({action:e.literal("upload"),...yt,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ir=e.discriminatedUnion("action",[Lt,e.strictObject({action:e.literal("register"),...yt}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:h,changesetId:e.uuid().nullable(),expectedRevision:j.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(gt).max(200)})]),_e=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:G,platform:Re,label:e.string(),sha256:j,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),Ht=e.strictObject({key:G,platform:Re,currentId:e.uuid().nullable()}),Or=e.strictObject({rows:e.array(_e).max(100),nextCursor:e.uuid().nullable(),clients:e.array(Ht).max(20)}),ke=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),jr=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:ke,runtime:ke,previews:ke})}),kr=e.strictObject({version:_e,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Rr=e.strictObject({version:_e,upload:ft.nullable()}),_r=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:h,path:e.string(),documentKey:h,documentHash:j,initialStateKey:h,initialRenderKey:h})),renders:e.array(mt)}).loose().superRefine((t,o)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&o.addIssue({code:"custom",message:"Incomplete render catalog"})}),Kr=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:h,key:h,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Er=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var Zt=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),bt=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:G,source:ae,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:Zt.optional()}).superRefine((t,o)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&o.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},ht="00000000-0000-0000-0000-000000000000";var xt=e.strictObject({type:e.literal("bundle"),paywall:C.optional(),offering:C.optional(),coupons:C,data:C}),Wt=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Br=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:S});var Mr=e.strictObject({type:e.literal("bundle"),offering:Wt("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(Ze).max(20),data:S});var St=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([St,e.array(St).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),vt=e.strictObject({path:E,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:Qt.optional()}).superRefine((t,o)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&o.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Xt=["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"],wt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Yt=C,It=e.discriminatedUnion("type",[rt,e.strictObject({type:e.literal("claim_offer"),coupon:C}),e.strictObject({type:e.literal("event"),event:wt}),e.strictObject({type:e.literal("api"),operation:e.enum(Xt),inputs:e.record(E,Yt).refine(t=>Object.keys(t).length<=40),outputs:e.record(wt,vt).refine(t=>Object.keys(t).length<=20)})]);var y=Q,en=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),k={id:y,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},tn={success:y,cancel:y,unavailable:y,failure:y},nn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),rn=e.enum(["same_window","new_window"]),on=e.discriminatedUnion("type",[e.strictObject({...k,type:e.literal("entry"),next:y,triggers:e.array(bt).max(20).refine(t=>new Set(t.map(o=>o.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...k,type:e.literal("screen"),screenId:y,presentation:Me,outputs:e.record(y,y),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:K}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...k,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("output"),value:e.discriminatedUnion("type",[...Oe.options,xt,e.strictObject({type:e.literal("selection"),screenId:y,offeringKey:K})])}),e.strictObject({...k,type:e.literal("condition"),cases:e.array(e.strictObject({condition:qe,target:y})).min(1).max(50),default:y}),e.strictObject({...k,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(en,y).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:y}),e.strictObject({...k,type:e.literal("action"),...tn,execution:it,action:It,writes:ye.optional()}),e.strictObject({...k,type:e.literal("external_page"),appManifest:ae.optional(),url:nn,openIn:rn,opened:y,failed:y}),e.strictObject({...k,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Oe.optional()}),e.strictObject({...k,type:e.literal("wait"),writes:ye.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:y}),e.strictObject({type:e.literal("event"),eventName:y,outputs:ve,timeoutSeconds:e.number().int().min(1).max(2592e3),received:y,timeout:y})])})]),Ke=e.strictObject({version:e.literal(5),entry:y,nodes:e.array(on).min(1).max(D.flowNodes)}),Ee=Ke.superRefine((t,o)=>{an(t,n=>o.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function se(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(o=>o.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function an(t,o){let n=[],s=new Map(t.nodes.map(p=>[p.id,p])),i=(p,v,N)=>{n.push(p),o?.({message:p,reason:v,path:N?["nodes",t.nodes.indexOf(N)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(p=>p.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(p=>p.type==="screen").length>D.pages||t.nodes.filter(p=>!["screen","entry","end","output"].includes(p.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let p of t.nodes){for(let v of se(p))v===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(v)||i(`Missing target ${v}`,"missingTarget",p);p.type==="screen"&&(a.has(p.screenId)&&i("Every screen has exactly one node owner","screenOwner",p),a.add(p.screenId))}let f=new Set,m=new Set,x=new Set;function _(p){if(f.has(p)){i("Flow edges must not form a cycle","cycle",s.get(p));return}if(!(m.has(p)||!s.has(p))){f.add(p),x.add(p);for(let v of se(s.get(p)))_(v);f.delete(p),m.add(p)}}_(t.entry);for(let p of t.nodes)x.has(p.id)||i("Every node must be reachable from Entry","unreachable",p);return[...new Set(n)]}var De={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Ot(t,o,n){let s=[...o].sort((m,x)=>x.length-m.length),i=new Set,a=(m,x=!1)=>{let _=s.find(p=>m===p||x&&m.startsWith(p+"."));i.add(_??m)};if(t.type==="condition"){let m=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let x of t.cases.slice(0,m+1))for(let _ of q(x.condition))_.startsWith("variables.")&&a(_.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let m of Object.values(t.action.inputs))m.source==="variable"&&a(m.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let f=t.type==="output"?t.value:t.type==="end"?t.output:null;if(f?.type==="variable"&&a(f.key),f?.type==="bundle")for(let m of[f.paywall,f.offering,f.coupons,f.data])m?.source==="variable"&&a(m.key);return f?.type==="selection"&&a(f.offeringKey),[...i]}var M=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ce=t=>e.record(e.string(),S).refine(o=>F(o)<=t,"Funnel evidence exceeds its byte budget"),xi=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Ce=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Si=e.strictObject({schemaVersion:e.literal(1),kind:Ce,selector:Ne.nullable(),context:ce(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>F(t)<=131072,"Node input exceeds its byte budget"),vi=e.strictObject({schemaVersion:e.literal(1),kind:Ce,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ce(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ce(131072)}).refine(t=>F(t)<=131072,"Node result exceeds its byte budget"),wi=e.strictObject({schemaVersion:e.literal(1),operations:e.record(M,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:M,id:e.uuid()}).nullable()}))}).refine(t=>F(t)<=65536,"Execution state exceeds its byte budget"),P={receiptId:e.uuid()},Ae=e.iso.datetime({offset:!0}),Ii=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:Ce})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...P,source:e.literal("client"),occurredAt:Ae.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(P)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:M,eventName:M,data:ce(8192),source:e.literal("server"),occurredAt:Ae})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...P,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(P)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(P)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...P,operation:M,reference:e.strictObject({type:M,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...P,source:e.enum(["client","server"]),occurredAt:Ae,reference:e.string().min(1).max(128).optional()})})]);var R=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),sn=e.discriminatedUnion("type",[e.strictObject({id:R,type:e.literal("owned"),publicData:Ye.optional(),document:H.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(o=>o.type==="event"&&!o.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:R,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),ze={executionContract:et.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(sn).max(D.pages),references:e.record(R,Ne).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:R,screenId:R,componentId:R,required:e.boolean()})).max(D.questions),variables:e.record(K,ge).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:fe,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(De.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(De.maxTransitions)})},$i=e.strictObject({...ze,graph:Ke});function cn(t,o){let n=!1,s=(i,a)=>{let f=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(m=>m[i.text]?.includes("{{offer."))&&!(f&&o(f))&&(n=!0),i.type==="stack"&&i.children.forEach(m=>s(m,f))};for(let i of t.pages)s(i.root);return n}function le(t){return Array.isArray(t)?t.some(le):!t||typeof t!="object"?!1:Object.entries(t).some(([o,n])=>o==="productVersionId"?n===ht:le(n))}function un(t){let o=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=dt(i.document)}catch(f){o.push({message:f instanceof Error?f.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[f,m]of t.inputs.entries())m.screenId===i.id&&!me(a,m.componentId)&&o.push({message:`Local Funnel input ${m.variable} targets hidden component ${m.componentId} on screen ${m.screenId}`,reason:"inputBinding",path:["inputs",f]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],f=i.type==="screen"?t.screens.find(m=>m.id===i.screenId):void 0;f?.type==="owned"&&(f.document.actions.some(m=>typeof m.properties.templateKey=="string"&&m.properties.templateKey.startsWith("popup-coupon-"))&&o.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),cn(f.document,m=>n.has(m))&&o.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&le(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&le(i.output.value))&&o.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return o}function jt(t,o){for(let{message:n,reason:s,path:i}of un(t))o.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function kt(t,o){let n=(d,r,c=[])=>o.addIssue({code:"custom",message:d,path:c,params:{reason:r}}),s=Object.values(t.references),i=new Map(t.screens.map(d=>[d.id,d])),a=(d,r)=>s.some(c=>c.type===d&&("id"in c?c.id:c.key)===r);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let f=t.graph.nodes.filter(d=>d.type==="screen");(f.length!==i.size||f.some(d=>!i.has(d.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let m=new Map,x=Object.keys(t.variables);x.some(d=>x.some(r=>d!==r&&r.startsWith(d+".")))&&n("Variable paths must not overlap","variable");function _(d,r){Object.hasOwn(t.variables,d)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(r)]);let c=m.get(d)??new Set;c.add(r.id),m.set(d,c)}for(let[d,r]of t.graph.nodes.entries()){let c=["graph","nodes",d],w=r.type==="feature"?r.featureKey:r.type==="offering"&&r.configuration.source==="feature"?r.configuration.featureKey:r.type==="output"&&r.value.type==="feature"?r.value.featureKey:r.type==="end"&&r.output?.type==="feature"?r.output.featureKey:null;w&&!a("flag",w)&&n("Flag selectors require an explicit GB resource reference","feature",c);let I=r.type==="feature"||r.type==="offering"||r.type==="coupon"||r.type==="coupons"||r.type==="action"&&r.action.type==="api"?["value"]:r.type==="action"&&r.action.type==="external_task"?Object.keys(r.action.outputs):r.type==="wait"&&r.wait.type==="event"?Object.keys(r.wait.outputs):[],O="writes"in r?r.writes??{}:{};(I.length!==Object.keys(O).length||I.some(u=>!Object.hasOwn(O,u))||new Set(Object.values(O)).size!==Object.values(O).length)&&n("Node writes must map every named output exactly once","variable",c);for(let[u,b]of Object.entries(O)){_(b,r);let g=t.variables[b],l=r.type==="offering"?"offering_version":r.type==="coupon"?"reward":r.type==="action"&&r.action.type==="api"?"json":r.type==="action"&&r.action.type==="external_task"?r.action.outputs[u]:r.type==="wait"&&r.wait.type==="event"?r.wait.outputs[u]:void 0;(g?.source.type!=="node"||l&&g.type!==l)&&n("Node writer source or output type does not match declaration","variable",c)}if(r.type==="coupons"){let u=t.variables[r.writes.value];(u?.type!=="array"||u.items?.type!=="reward"||u.items.nullable||u.nullable)&&n("Coupons output requires a non-null Reward array","variable",c);for(let b of r.couponIds)a("reward",b)||n("Coupons require Reward references","coupon",c)}if(r.type==="split"&&!a("experiment",r.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",c),r.type==="coupon"&&!a("reward",r.couponId)&&n("Coupon selectors require a Reward reference","coupon",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="literal"){let u=r.action.coupon.value;(!u||typeof u!="object"||Array.isArray(u)||u.type!=="reward"||typeof u.id!="string"||Object.keys(u).length!==2||!a("reward",u.id))&&n("Coupon claims require a Reward reference","coupon",c)}if(r.type==="offering"&&r.configuration.source==="fixed"&&!a("offering_version",r.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",c),r.type==="screen"&&r.offering?.source==="variable"&&t.variables[r.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="variable"&&(t.variables[r.action.coupon.key]?.type!=="reward"||r.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",c),r.type==="screen"){let u=i.get(r.screenId);if(r.offering?.source==="fixed"&&!a("offering_version",r.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",c),u?.type==="paywall"&&r.offering&&n("Paywall owns its fixed Offering Version","offering",c),u?.type==="paywall"&&!a("paywall_version",u.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",c),u?.type==="owned"){let b=u.document.pages[0];if(!b){n("Owned screen requires a page","screen",c);continue}Te(u.document).some(l=>!l.complete)&&n("Owned screens require complete local content","translations",c);let g=new Set(u.document.actions.map(l=>l.id));(g.size!==Object.keys(r.outputs).length||Object.keys(r.outputs).some(l=>!g.has(l)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",c),Z(b.root,l=>{!r.offering&&(l.type==="plan_picker"||(l.type==="stack"||l.type==="button")&&l.bind?.plan||l.type==="customer_data"&&["customer_plans","credit_packs"].includes(l.data.source))&&n("Product presentation requires an Offering Version","offering",c),l.type==="customer_data"&&Object.values(l.data.outputs??{}).some(z=>z!==void 0&&!g.has(z))&&n("Customer components require declared screen outcomes","componentOutput",c)})}}r.type==="end"&&["completed","ineligible"].includes(r.outcome)&&!r.output&&n("Completed and ineligible ends require a declared output","output",c),r.type==="end"&&r.output?.type==="literal"&&!T(t.outputSchema,r.output.value)&&n("Terminal output does not match outputSchema","output",c),r.type==="output"&&r.value.type==="literal"&&!T(t.outputSchema,r.value.value)&&n("Terminal output does not match outputSchema","output",c);let A=r.type==="output"?r.value:r.type==="end"?r.output:void 0;if(A?.type==="variable"&&!A.path){let u=t.variables[A.key];u&&!$e(u,t.outputSchema)&&n("Variable output does not match outputSchema","output",c)}if(r.type==="screen"){let u=i.get(r.screenId);if(u?.type==="owned")for(let b of xe(u.document))(/^(input|params)\./.test(b)||b.startsWith("variables.")&&!he(b.slice(10),x))&&n("Screen values must reference registered variables","variable",c)}if(r.type==="condition")for(let u of r.cases){for(let b of Ge(u.condition))a("saved_group",b)||n("Conditions require explicit Saved Group references","savedGroup",c);for(let b of q(u.condition))b.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",c)}if(r.type==="output"&&r.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",c);for(let[u,b]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let g=r.value[u];if(g)if(g.source==="literal"){let l=u==="coupons"?g.value:[g.value];(!Array.isArray(l)||l.length>20||l.some(z=>!T({type:b,nullable:!1},z)||!a(b,z.id))||u==="coupons"&&new Set(l.map(z=>z.id)).size!==l.length)&&n("Bundle requires distinct scoped resource references",u==="coupons"?"coupon":u==="paywall"?"paywall":"offering",[...c,"value",u])}else{let l=t.variables[g.key];(g.path||!l||l.nullable||(u==="coupons"?l.type!=="array"||l.items?.type!=="reward"||l.items.nullable:l.type!==b))&&n("Bundle binding type does not match its slot","output",c)}}}}for(let[d,r]of t.graph.nodes.entries()){let c=r.type==="screen"?i.get(r.screenId):void 0,w=[...Ot(r,x),...c?.type==="owned"?Xe(c.document).map(I=>he(I,x)?.key??I):[]];for(let I of new Set(w)){let b=function(g){if(g===r.id)return!0;if(u.has(g))return!1;u.add(g);let l=t.graph.nodes.find(Rt=>Rt.id===g);return l?(A.has(g)?l.type==="action"?[l.cancel,l.unavailable,l.failure]:l.type==="wait"&&l.wait.type==="event"?[l.wait.timeout]:[]:se(l)).some(b):!1};var N=b;if(!Object.hasOwn(t.variables,I)){n("Consumed variable is undeclared","variable",["graph","nodes",d]);continue}let O=t.variables[I];if(r.type==="screen"&&O.source.type==="input"&&t.inputs.some(g=>g.screenId===r.screenId&&g.variable===I)||O.source.type==="parameter"||O.source.type==="attribute")continue;let A=O.source.type==="input"?new Set(t.inputs.filter(g=>g.variable===I&&g.required).flatMap(g=>f.filter(l=>l.screenId===g.screenId).map(l=>l.id))):m.get(I)??new Set,u=new Set;(!A.size||b(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",d])}}(new Set(t.inputs.map(d=>d.variable)).size!==t.inputs.length||new Set(t.inputs.map(d=>`${d.screenId}:${d.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[d,r]of t.inputs.entries()){t.variables[r.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",d]);let c=i.get(r.screenId),w=c?.type==="owned"?me(c.document,r.componentId):null;if((w?.type!=="stack"||!w.interaction||!["input","toggle","select","multiselect","tabs"].includes(w.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",d]),w?.type==="stack"&&w.interaction){let I=w.interaction.type==="toggle"?"boolean":w.interaction.type==="multiselect"?"strings":"string";t.variables[r.variable]?.type!==I&&n("Input variable type does not match component","inputBinding",["inputs",d]);let O=t.variables[r.variable]?.enum;O&&!w.children.filter(A=>!A.hidden).every(A=>O.includes(A.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",d])}}for(let[d,r]of Object.entries(t.variables))r.enum&&r.type!=="string"&&n("Only string variables support enum","variable",["variables",d]),r.source.type==="input"&&!t.inputs.some(c=>c.variable===d)&&n("Input variable requires a component binding","inputBinding",["variables",d]);let p=0,v=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});v+=d.document.actions.length}(p>D.components||v>D.actions||F(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var ln=e.strictObject({...ze,graph:Ee}).superRefine(kt),pn=e.strictObject({...ze,graph:Ee,displayName:e.string().trim().min(1).max(80)}).superRefine(kt),Li=pn.superRefine(jt),Hi=ln.superRefine(jt),ue=e.string().regex(Fe),$={requestId:e.uuid(),nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:ue.optional()},dn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:R,answers:J,selection:e.record(R,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:R,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:He.optional(),subscriptionChange:We.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid(),merchantConfirmation:Pe.optional()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),mn=e.object({nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(R,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:Je.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),Zi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ne.optional(),customerData:re.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ie,oe),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:mn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("submit"),...$,input:dn}),e.strictObject({operation:e.literal("back"),...$}),e.strictObject({operation:e.literal("shown"),...$}),e.strictObject({operation:e.literal("close"),...$}),e.strictObject({operation:e.literal("commit_segment"),...$,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:ue.optional()})]);export{_t as a,Xe as b,F as c,Kt as d,Kn as e,Mt as f,gr as g,wr as h,Zt as i,Vn as j,Un as k,Bn as l,Vt as m,Ct as n,Nt as o,Gn as p,ne as q,re as r,ie as s,oe as t,at as u,$n as v,Pt as w,Ln as x,Hn as y,Zn as z,Oe as A,Bt as B,cr as C,ur as D,lr as E,nn as F,rn as G,Si as H,vi as I,pn as J,Zi as K};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t}from"./chunk-
|
|
1
|
+
import{d as t}from"./chunk-YGOXUDDF.js";async function u(e,n){try{let{route:r}=await e.funnelRoute(n.funnelId),a=t(r,{customerId:n.customerId,parameters:n.parameters??{}});return{funnelId:n.funnelId,...a}}catch(r){return{funnelId:n.funnelId,type:"unavailable",reason:r?.code?.toLowerCase()??"error",path:[]}}}function l(e){switch(e.type){case"paywall":return null;case"screen":return`first_screen_${e.surface}`;case"external_page":return"first_screen_external_page";case"end":return`route_end_${e.outcome}`;case"unknown":return`route_unknown_${e.reason}`;case"unavailable":return e.reason.startsWith("route_")?e.reason:`route_${e.reason}`}}async function s(e,n){if(n.type!=="paywall")return null;try{let{document:r}=await e.paywall(n.paywallId,n.paywallVersionId);return{presentation:r.presentation,screen:r.screen,buttons:r.buttons}}catch{return null}}export{u as a,l as b,s as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as w,f as b}from"./chunk-
|
|
1
|
+
import{e as w,f as b}from"./chunk-PGZZKX5K.js";import{n as h,s as u}from"./chunk-CJUVMNDB.js";import{a as y}from"./chunk-7LHRBNSH.js";import{a as n}from"./chunk-BYHBBZIO.js";import{a as g}from"./chunk-3VUPVXAV.js";import{b as f}from"./chunk-VGEH7B6S.js";function p(r,s){let a=typeof r=="string"?new TextEncoder().encode(r):r;return a.byteLength===s.byteLength&&u(a)===s.sha256}async function _(r,s){let a=w.parse(s),{artifact:i,environmentId:P}=a.content,m=new y(r.baseUrl??f).origin,e=new y(i.url,m);if(e.origin!==m||e.username||e.password||e.search||e.hash||e.pathname!==`/api/v1/configuration/${P}/artifacts/${i.sha256}`)throw new n("INVALID_RESPONSE","Public Paywall locator is not trusted");let o=new AbortController,d,I=new Promise((t,l)=>{d=setTimeout(()=>{let c=new n("TIMEOUT","Public Paywall read timed out");o.abort(c),l(c)},h.initializationMs)}),E=(async()=>{let t=await(r.fetch??globalThis.fetch)(e,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:o.signal});if(o.signal.aborted&&(t.body?.cancel().catch(()=>{}),o.signal.throwIfAborted()),!t.ok||!t.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(t.headers.get("content-length"))>i.byteLength)throw t.body?.cancel().catch(()=>{}),new n("INVALID_RESPONSE","Public Paywall is unavailable");let l=await g(t,i.byteLength,{signal:o.signal,error:c=>new n("INVALID_RESPONSE",c==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!p(l,i))throw new n("INVALID_RESPONSE","Public Paywall digest or size changed");return b(a,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([E,I])}finally{clearTimeout(d)}}export{p as a,_ as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,j as J}from"./chunk-TNPBYYAX.js";import{b as X}from"./chunk-PF6PRPRO.js";import{j as K,l as E}from"./chunk-FYD7CMS7.js";import{b as e}from"./chunk-XVCSRZX4.js";var Y=e.number().int().min(0).max(1e8),V=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Y,flatAmountMinor:Y.optional()})).min(1).max(12)}).refine(t=>t.tiers.at(-1)?.upTo===null&&t.tiers.slice(0,-1).every((n,i)=>{let r=t.tiers[i-1]?.upTo;return n.upTo!==null&&(i===0||r!=null&&n.upTo>r)}),"Tier ceilings must increase and end unbounded").refine(t=>!t.tiers.some(n=>(n.flatAmountMinor??0)>0)||t.kind==="volume"&&t.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function M(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?V.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,o=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let a of i.tiers){let s=a.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else n>o&&(r+=BigInt(Math.min(n,s)-o)*BigInt(a.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function wt(t){return M({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ve=K.refine(t=>/[1-9]/.test(t)),te=e.strictObject({units:ve,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:V.optional()})).min(1).max(20).refine(t=>new Set(t.map(n=>n.currency)).size===t.length,"Currencies must be unique").refine(t=>t.every(n=>!n.pricing||n.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:e.number().int().min(0).max(1e4),maximumQuantity:e.number().int().min(0).max(1e4)}).refine(t=>t.maximumQuantity>=t.minimumQuantity,"Purchased quantity must fit its published bounds").refine(t=>{try{for(let n of t.prices)for(let i of[t.maximumQuantity,...n.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])i<=t.maximumQuantity&&M({amountMinor:n.amountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}},i);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function ee(t){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(t))throw new Error("Invalid quantity");let[n,i=""]=t.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*1000000n+BigInt(i.padEnd(6,"0"))}function Ot(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=ee(t)+ee(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let o=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(o?"."+o:"")}var ne=e.strictObject({internalFeatureId:e.uuid(),name:e.string().min(1).max(120),includedAmount:e.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:e.enum(["hour","day","week","month","year","lifetime"]),resetCount:e.number().int().min(1).max(100),terms:te});var _e=["plan.name","plan.price","plan.period","plan.price_per_month","trial.headline","trial.terms","offer.headline","offer.name","offer.description","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.price","offer.original_price","offer.months","offer.code","offer.ends_at","offer.expires_at","paywall.feature","paywall.message","paywall.action"],T=e.object({plan:e.string().min(1).max(200).optional(),coupon:e.uuid().optional(),promotionCode:e.uuid().optional(),picker:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),re=e.object({text:e.string().optional(),label:e.string().optional(),alt:e.string().optional(),html:e.string().max(32768).optional(),price:e.object({current:e.string(),original:e.string().nullable(),period:e.string()}).optional(),code:e.string().optional(),countdownAt:e.iso.datetime().optional(),planId:e.string().min(1).max(200).optional(),planVersionId:e.string().min(1).max(200).optional(),currency:C.optional(),couponId:e.uuid().optional(),offerId:e.uuid().optional(),unavailable:e.boolean().optional(),unavailableReason:e.string().optional(),missing:e.array(e.string()).optional()}).strict(),Et=e.object({paywall:J.optional(),nodes:e.record(e.string(),e.object({base:re,picker:e.string().optional(),byPlan:e.record(e.string(),re).optional()}).strict()),plans:e.record(e.string(),e.object({id:e.string().min(1).max(200),versionId:e.string().min(1).max(200),available:e.boolean(),name:e.string(),price:e.string(),period:e.string(),currency:C.optional(),amountMinor:e.number().int().nonnegative().optional(),interval:e.enum(["free","week","month","year","one_time"]).optional(),intervalCount:e.number().int().positive().optional(),prepaid:e.array(ne).max(100).optional()}).strict()),pickers:e.record(e.string(),e.object({options:e.array(e.string().min(1).max(200)).max(20),selected:e.string().min(1).max(200).nullable()}).strict()),quantities:e.record(e.string(),e.strictObject({minimum:e.number().int().nonnegative(),maximum:e.number().int().nonnegative(),step:e.number().int().positive(),value:e.number().int().nonnegative(),label:e.string(),available:e.boolean()})).optional(),diagnostics:e.array(e.object({nodeId:e.string(),message:e.string()}).strict())}).strict();function ie(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function Z(t){let n=ie(t).filter(r=>!_e.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),i=t.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(i.includes("{{")||i.includes("}}"))&&n.push("无效变量语法"),[...new Set(n)]}function Vt(t,n,i={}){let r=t?.nodes[n];if(!r)return;let o=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}var Ne=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],oe=e.enum(Ne),ae=e.object({source:oe,layout:e.enum(["full","compact"]),resourceKey:E.optional(),pageSize:e.number().int().min(1).max(50),showSources:e.boolean(),allowPurchase:e.boolean(),outputs:e.object({billing_adjustment:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((t,n)=>{(t.outputs?.billing_authorization||t.outputs?.billing_adjustment)&&t.source!=="billing_controls"&&n.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),t.resourceKey&&!["credit_balance","credit_transactions"].includes(t.source)&&n.addIssue({code:"custom",message:"这个数据源不能绑定积分资源。"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"只有积分余额可以展开来源。"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"只有积分包、套餐与会员组件可以启用交易。"})}),x=e.string().max(2e3),se=e.object({id:e.string().max(100),label:x,detail:e.array(x).max(12),value:x.optional(),status:x.optional(),facts:e.array(e.object({label:x,value:x}).strict()).max(1e3),purchaseId:e.uuid().optional(),invoiceUrl:e.url().max(2048).refine(t=>{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}).optional(),billingActions:e.array(e.strictObject({action:e.literal("invoice_open"),label:x})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:x}).strict()).max(3).optional()}).strict(),Pe=e.object({key:E,name:x,spendable:x,reserved:x,available:x,expiry:x.nullable(),sources:e.array(se).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),Oe=e.object({source:oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:x.optional(),resources:e.array(Pe).max(500),rows:e.array(se).max(50),hasNext:e.boolean(),hasPrevious:e.boolean(),page:e.number().int().positive(),filter:e.string().max(40),updatedAt:e.iso.datetime().optional(),buyingId:e.uuid().optional(),membershipBusy:e.boolean().optional(),billingBusy:e.boolean().optional(),membershipReview:e.object({title:x,note:x,facts:e.array(e.object({label:x,value:x}).strict()).max(100)}).strict().optional(),membershipResult:x.optional()}).strict(),Qt=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oe)}).strict(),Ft=e.object({nodeId:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:e.enum(["refresh","next","previous","filter","buy_pack","billing_portal","billing_authorization","billing_adjustment","invoice_open","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:e.string().max(100).optional()}).strict();function ce(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function le(t){let n={};function i(r){if(ce(r)){let o=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let l=s.type==="stack"?s.bind?.plan:void 0;l&&!o.ids.includes(l)&&o.ids.push(l)}let a=r.children[r.interaction.defaultIndex];!o.defaultId&&a?.type==="stack"&&(o.defaultId=a.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function pe(t,n,i){let r={};function o(u){if(u.hidden)return;if(u.type==="plan_picker"){let b=i.pickers[u.id];r[u.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let y=u.children.filter(b=>!b.hidden),c=u.interaction;if(ce(u)){let b=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},k=i.pickers[u.interaction.pickerId]?.options??[];for(let p of y){let d=p.type==="stack"?p.bind?.plan:void 0;d&&k.includes(d)&&!b.ids.includes(d)&&b.ids.push(d),d&&p.id===n[u.id]&&b.remembered.push(d)}let m=u.children[u.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(c?.type==="tabs"){let b=y.find(k=>k.id===n[u.id])??u.children[c.defaultIndex];b&&o(b)}else if(c?.type==="toggle"){let b=typeof n[u.id]=="boolean"?n[u.id]:c.defaultEnabled,k=u.children[b?0:1];k&&o(k)}else y.forEach(o)}let a=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(u=>u.id===a);s&&o(s.root);let l={};for(let[u,y]of Object.entries(r)){let c=n[u],b=y.remembered[0]??(y.ids.includes(i.pickers[u]?.selected??"")?i.pickers[u]?.selected:y.defaults[0]);l[u]=typeof c=="string"?y.ids.includes(c)?c:"":b&&y.ids.includes(b)?b:""}for(let u of Object.keys(le(t)))l[u]??="";return l}var ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),me=e.strictObject({tiers:e.array(e.strictObject({id:ue,name:e.string().trim().min(1).max(80)})).min(1).max(8),assignments:e.array(e.strictObject({productVersionId:e.string().min(1).max(200),tierId:ue,period:e.enum(["month","year"])})).max(20)}).superRefine((t,n)=>{let i=t.tiers.map(r=>r.id);(new Set(i).size!==i.length||new Set(t.assignments.map(r=>r.productVersionId)).size!==t.assignments.length||new Set(t.assignments.map(r=>`${r.tierId}:${r.period}`)).size!==t.assignments.length||t.assignments.some(r=>!i.includes(r.tierId)))&&n.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function fe(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function Jt(t){let n=Z(t).map(i=>`未知变量:${i}`);for(let i=0;i<t.length;i++){if(t[i]!=="<"||!/[A-Za-z!/?{]/.test(t[i+1]??""))continue;let r=i;if(t.startsWith("<!--",i)){let o=t.indexOf("-->",i+4);i=o<0?t.length:o+2}else{let o="";for(i++;i<t.length;i++){let a=t[i];if(o)a===o&&(o="");else if(a==='"'||a==="'")o=a;else if(a===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("变量只能放在 HTML 文字中,不能放入标签、属性或注释")}return[...new Set(n)]}var h={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},ge=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),S=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!ge.has(t),"Reserved UI identifier"),B=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),Ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(B).min(1).max(h.enumValues),default:B}),e.strictObject({type:e.literal("number"),min:e.number().finite(),max:e.number().finite(),step:e.number().finite().positive(),default:e.number().finite()}),e.strictObject({type:e.literal("text"),maxLength:e.number().int().min(0).max(2e3),default:e.string().max(2e3).nullable()}),e.strictObject({type:e.literal("boolean"),default:e.boolean()})]);function D(t,n){if(t.type==="enum")return t.values.some(r=>r===n);if(t.type==="boolean")return typeof n=="boolean";if(t.type==="text")return n===null||typeof n=="string"&&n.length<=t.maxLength;if(typeof n!="number"||!Number.isFinite(n)||n<t.min||n>t.max)return!1;let i=(n-t.min)/t.step;return Number.isFinite(i)&&Math.abs(i-Math.round(i))<=Math.min(1e-7,Math.max(1,Math.abs(i))*Number.EPSILON*8)}var Ce=Ae.superRefine((t,n)=>{t.type==="enum"&&new Set(t.values).size!==t.values.length&&n.addIssue({code:"custom",path:["values"],message:"UI enum values must be unique"}),t.type==="number"&&t.min>t.max&&n.addIssue({code:"custom",path:["max"],message:"UI number range is reversed"}),D(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),$e=["add","sub","mul","div","min","max","round","floor","eq","ne","gt","gte","lt","lte","and","or","not","if","concat","number","parse_number","money","lookup","now","duration"];function Ue(t,n){return t==="now"?n===0:t==="concat"?!0:t==="lookup"?n>=4&&n%2===0:t==="if"?n===3:["sub","div","eq","ne","gt","gte","lt","lte"].includes(t)?n===2:["round","floor","not","number","parse_number","money","duration"].includes(t)?n===1:n>=1}var N=e.lazy(()=>e.union([B,e.strictObject({ref:S}),e.strictObject({op:e.enum($e),args:e.array(N).max(h.expressionNodes)}).superRefine((t,n)=>{Ue(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function _(t,n,i){if(!t||typeof t!="object")return!0;if(!j(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(ge.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let o=Object.getOwnPropertyDescriptor(t,r);if(o&&!Object.hasOwn(o,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function O(t,n,i,r){let o=[{value:t,depth:1,path:i}];for(;o.length;){let a=o.pop();if(++r.nodes>h.expressionNodes||a.depth>h.depth){n.addIssue({code:"custom",path:a.path,message:"UI expression budget exceeded"});return}if(!_(a.value,n,a.path))return;if(j(a.value)&&Array.isArray(a.value.args)){if(a.value.args.length>h.expressionNodes){n.addIssue({code:"custom",path:[...a.path,"args"],message:"UI expression budget exceeded"});return}for(let s=a.value.args.length-1;s>=0;s--)o.push({value:a.value.args[s],depth:a.depth+1,path:[...a.path,"args",s]})}}}var en=e.unknown().superRefine((t,n)=>{O(t,n,[],{nodes:0})}).pipe(N),Q=e.record(S,N).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=h.state,"UI assignments need 1–32 state keys"),Le=e.strictObject({target:S,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:N,className:S.optional()}).superRefine((t,n)=>{t.property==="class"!=(t.className!==void 0)&&n.addIssue({code:"custom",path:["className"],message:"Only class bindings require a safe className"})}),Te=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:S,state:S}),e.strictObject({type:e.literal("input"),target:S,state:S,set:Q.optional()}),e.strictObject({type:e.literal("action"),target:S,set:Q}),e.strictObject({type:e.literal("carousel"),target:S,state:S,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:S.optional(),nextTarget:S.optional(),inactiveTargets:e.array(S).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),De=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:Q}),Re=e.strictObject({type:e.literal("mosaic_waves"),target:S,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:N.optional(),speed:e.number().min(0).max(4).optional(),pitch:e.number().min(.05).max(4).optional(),fill:e.number().min(.05).max(1).optional(),feather:e.number().min(0).max(1).optional(),warp:e.number().min(0).max(4).optional(),warpScale:e.number().min(0).max(32).optional(),detailScale:e.number().min(0).max(32).optional(),waveScale:e.number().min(0).max(32).optional(),falloff:e.number().min(.1).max(32).optional(),brightness:e.number().min(0).max(32).optional(),ambient:e.number().min(0).max(1).optional(),gamma:e.number().min(.05).max(8).optional(),vignette:e.number().min(0).max(1).optional(),opacity:e.number().min(0).max(1).optional()}),Ee=e.strictObject({type:e.literal("number_counter"),target:S,value:N,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),Ve=e.strictObject({state:e.record(S,Ce).refine(t=>Object.keys(t).length<=h.state,"Too many UI state keys").optional(),derived:e.record(S,N).refine(t=>Object.keys(t).length<=h.derived,"Too many UI derived keys").optional(),bindings:e.array(Le).max(h.bindings).optional(),controls:e.array(Te).max(h.controls).optional(),timers:e.array(De).max(h.timers).optional(),effects:e.array(e.discriminatedUnion("type",[Re,Ee])).max(h.effects).optional(),clock:e.boolean().optional()});function Me(t,n){if(!_(t,n,[])||!j(t))return;for(let[r,o]of[["state",h.state],["derived",h.derived]]){let a=t[r];if(!_(a,n,[r]))return;if(j(a)&&Object.keys(a).length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,o]of[["bindings",h.bindings],["controls",h.controls],["timers",h.timers],["effects",h.effects]])if(Array.isArray(t[r])&&t[r].length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,o]of t.effects.entries())if(!_(o,n,["effects",r]))return}if(j(t.state))for(let[r,o]of Object.entries(t.state)){if(!_(o,n,["state",r]))return;if(j(o)&&Array.isArray(o.values)&&o.values.length>h.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(j(t.derived))for(let[r,o]of Object.entries(t.derived))O(o,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let o=t[r];if(Array.isArray(o)){for(let[a,s]of o.entries())if(!(!_(s,n,[r,a])||!j(s))){if(r==="bindings")O(s.expression,n,[r,a,"expression"],i);else if(_(s.set,n,[r,a,"set"])&&j(s.set)){if(Object.keys(s.set).length>h.state){n.addIssue({code:"custom",path:[r,a,"set"],message:"Too many UI assignments"});return}for(let[l,u]of Object.entries(s.set))O(u,n,[r,a,"set",l],i)}if(i.nodes>h.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,o]of t.effects.entries())j(o)&&o.type==="number_counter"?O(o.value,n,["effects",r,"value"],i):j(o)&&o.enabled!==void 0&&O(o.enabled,n,["effects",r,"enabled"],i)}function de(t){let n=[],i=[t];for(;i.length;){let r=i.pop();!r||typeof r!="object"||("ref"in r?n.push(r.ref):i.push(...r.args))}return n}var be=e.unknown().superRefine(Me).pipe(Ve).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},o=new Set([...Object.keys(i),...Object.keys(r)]),a=(m,p)=>{for(let d of de(m))o.has(d)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${d}`})};for(let[m,p]of Object.entries(t.derived??{}))Object.hasOwn(i,m)&&n.addIssue({code:"custom",path:["derived",m],message:"UI state and derived identifiers must be distinct"}),a(p,["derived",m]);let s=new Set,l=new Set,u=m=>{if(s.has(m))return!1;if(l.has(m))return!0;s.add(m);for(let p of de(r[m]))if(Object.hasOwn(r,p)&&!u(p))return!1;return s.delete(m),l.add(m),!0};for(let m of Object.keys(r))if(!u(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())a(p.expression,["bindings",m,"expression"]);let y=new Set;for(let[m,p]of(t.effects??[]).entries())y.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),y.add(p.target),p.type==="number_counter"?(a(p.value,["effects",m,"value"]),typeof p.value=="number"&&Math.abs(p.value)>1e12&&n.addIssue({code:"custom",path:["effects",m,"value"],message:"Counter values must be within the display bound"})):p.enabled!==void 0&&a(p.enabled,["effects",m,"enabled"]);let c=(m,p)=>{for(let[d,v]of Object.entries(m))Object.hasOwn(i,d)||n.addIssue({code:"custom",path:[...p,d],message:"UI assignments can only update declared state"}),a(v,[...p,d])},b=new Set,k=new Set;for(let[m,p]of(t.controls??[]).entries()){if(p.type==="carousel"&&p.inactiveMaxWidth!==void 0&&p.inactiveTargets===void 0&&n.addIssue({code:"custom",path:["controls",m,"inactiveMaxWidth"],message:"Inactive width requires inactive article targets"}),p.type==="carousel")for(let d of p.inactiveTargets??[])(d===p.target||k.has(d))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),k.add(d);if(p.type==="carousel")for(let d of["previousTarget","nextTarget"]){let v=p[d];v!==void 0&&((v===p.target||b.has(v)||(t.controls??[]).some(ze=>ze.target===v))&&n.addIssue({code:"custom",path:["controls",m,d],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(v))}if(p.type!=="action"){let d=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!d||p.type==="input"&&d.type==="enum"&&d.values.some(v=>typeof v!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(d?.type!=="number"||!Number.isInteger(d.min)||d.min<0||!Number.isInteger(d.max)||d.step!==1||p.initialIndex!==void 0&&!D(d,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&d?.type!=="boolean"&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Scroll latches require boolean UI state"})}(p.type==="input"||p.type==="action")&&p.set&&c(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())c(p.set,["timers",m,"set"])});var he=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,A=e.string().max(16).regex(he,"语言代码格式不正确,例如 zh-CN、en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"持久化语言代码必须使用规范写法");function F(t){if(typeof t!="string")return null;try{let n=Intl.getCanonicalLocales(t.trim().replaceAll("_","-"))[0];if(!n)return null;let{language:i,script:r,region:o}=new Intl.Locale(n),a=[i,r,o].filter(Boolean).join("-");return he.test(a)?a:null}catch{return null}}var Ze=new Set(["TW","HK","MO"]);function ye(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let o=i?.length===4?i:void 0,a=i?.length===4?r:i;return o?`zh-${o}`:a&&Ze.has(a)?"zh-Hant":"zh-Hans"}function xe(t,n,i){let r=n.map(o=>({code:A.parse(o),normalized:o}));for(let o of t){let a=F(o);if(!a)continue;let s=r.find(c=>c.normalized===a);if(s)return s.code;let l=ye(a),u=r.filter(c=>ye(c.normalized)===l),y=u.find(c=>!c.normalized.includes("-")||c.normalized===l)??u[0];if(y)return y.code}return i}var Be=4,z={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},U=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),g=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qe=e.enum(["none","xs","sm","md","lg","xl"]),Fe=e.enum(["none","sm","md","lg","full"]),H=e.string().regex(/^#[0-9a-fA-F]{6}$/),G=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"只支持 https 链接"),q=e.union([G,e.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Se=e.object({primary:H,background:H,text:H,radius:Fe,font:e.enum(["system","serif","rounded","mono"]),fontAssets:e.object({family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/),faces:e.array(e.object({url:G,weight:e.number().int().min(100).max(900).multipleOf(100),family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/).optional()}).strict()).min(1).max(4)}).strict().optional()}).strict(),L=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),f=(t,n)=>e.number().int().min(t).max(n),ke=e.union([e.enum(["fit","fill"]),f(1,1200)]),He=e.object({top:f(0,200),right:f(0,200),bottom:f(0,200),left:f(0,200)}).strict(),qe=e.object({top:f(-100,200),right:f(-100,200),bottom:f(-100,200),left:f(-100,200)}).strict(),Ie=e.object({x:f(0,100),y:f(0,100)}).strict(),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:L}).strict(),e.object({type:e.literal("linear"),angle:f(0,360),stops:e.array(e.object({color:L,at:f(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:q,fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict()]),We=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([f(0,200),e.object({topLeft:f(0,200),topRight:f(0,200),bottomRight:f(0,200),bottomLeft:f(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ke=e.object({width:f(0,12),color:L,style:e.enum(["solid","dashed"])}).strict(),Je=e.object({x:f(-40,40),y:f(-40,40),blur:f(0,80),spread:f(-20,40),color:L}).strict(),Xe=e.object({font:e.enum(["system","serif","rounded","mono"]),size:f(8,96),weight:e.number().int().min(100).max(900).multipleOf(100),lineHeight:e.number().min(.8).max(3),letterSpacing:e.number().min(-5).max(20),color:L,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),P=e.object({width:ke,height:ke,padding:He,margin:qe,gap:f(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Ge,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:We,border:Ke,shadow:Je,text:Xe}).strict().partial(),I={id:U,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:P.optional(),fallback:g.optional()},Ye=e.object({...I,type:e.literal("text"),productField:e.enum(["name","price","trial","period"]).optional(),feature:e.object({id:e.uuid(),field:e.enum(["name","allowance"])}).strict().optional(),text:g,variant:e.enum(["title","heading","body","caption"])}).strict(),et=e.object({...I,type:e.literal("image"),src:q,localizedSrc:e.record(A,q).optional(),alt:g,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict(),tt=e.object({...I,type:e.literal("button"),label:g,variant:e.enum(["primary","secondary","link"]),action:g,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:T.optional()}).strict(),nt=e.object({...I,type:e.literal("divider")}).strict(),rt=e.object({...I,type:e.literal("customer_data"),title:g,data:ae}).strict(),it=e.object({...I,type:e.literal("spacer"),size:Qe}).strict(),ot=e.object({...I,type:e.literal("custom_html"),html:e.record(A,e.string().max(z.customHtml)),css:e.string().max(z.customCss),ui:be.optional()}).strict(),at=e.object({...I,type:e.literal("price"),fallback:g,parts:e.object({current:P.optional(),original:P.optional(),period:P.optional()}).strict().optional()}).strict(),st=e.object({...I,type:e.literal("coupon_code"),label:g,fallback:g}).strict(),ct=e.object({...I,type:e.literal("countdown"),source:e.enum(["offer.ends_at","offer.expires_at","fixed"]),at:e.iso.datetime().optional(),granularity:e.enum(["day","hour","minute","second"]),expired:g,fallback:g}).strict().refine(t=>t.source!=="fixed"||!!t.at,"固定倒计时需要结束时间"),lt=e.object({...I,type:e.literal("plan_picker"),label:g,fallback:g,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"套餐不能重复").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:me.safeExtend({monthLabel:g,yearLabel:g,unavailableLabel:g}).optional(),states:e.object({selected:P.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!fe(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),pt=e.object({...I,type:e.literal("quantity_picker"),bind:T.optional(),label:g,fallback:g,internalFeatureId:e.uuid(),minimumQuantity:f(0,1e4),maximumQuantity:f(0,1e4),defaultQuantity:f(0,1e4),step:f(1,1e4)}).strict().refine(t=>t.minimumQuantity<=t.defaultQuantity&&t.defaultQuantity<=t.maximumQuantity&&(t.defaultQuantity-t.minimumQuantity)%t.step===0,"Quantity controls require a Product binding and valid bounds"),ut=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:g,keyboard:e.enum(["text","email","tel","url"]),maxLength:f(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:g,min:f(0,50),max:f(1,50)}).strict(),e.object({type:e.literal("select"),label:g,defaultIndex:f(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:U.optional(),selectedStyle:P.optional()}).strict(),e.object({type:e.literal("tabs"),label:g,defaultIndex:f(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:g,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:g}).strict()]),w={...I,type:e.literal("stack"),direction:e.enum(["vertical","horizontal","overlay"]),align:e.enum(["start","center","end","stretch"]),justify:e.enum(["start","center","end","between"]),productSlot:e.object({index:f(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:ut.optional(),states:e.object({selected:P.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:g.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:T.optional()},je=e.lazy(()=>e.object({...I,type:w.type,direction:w.direction,align:w.align,justify:w.justify,children:e.array(mt).max(z.children),productSlot:w.productSlot,interaction:w.interaction,states:w.states,purpose:w.purpose,purchaseAction:w.purchaseAction,buttonVariant:w.buttonVariant,bind:w.bind}).strict()),mt=e.lazy(()=>e.union([je,Ye,et,tt,nt,it,ot,at,st,ct,lt,pt,rt])),ft=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),$={id:g,event:g,properties:e.record(g,ft).refine(t=>Object.keys(t).length<=20,"最多 20 个参数")},dt=e.discriminatedUnion("type",[e.object({...$,type:e.literal("navigate"),close:e.literal(!1),pageId:U}).strict(),e.object({...$,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...$,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...$,type:e.literal("open_url"),close:e.boolean(),url:G}).strict(),e.object({...$,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),gt=e.object({defaultLocale:A,locales:e.record(A,e.record(g,e.string().max(z.stringLength)))}).strict(),bt=e.enum(["popup","paywall","onboarding","page","banner"]);var yt=e.object({kind:e.literal("screen"),schemaVersion:e.literal(Be),name:e.string().trim().min(1).max(80),surface:bt,initialPageId:U.optional(),presentation:X,theme:Se,pages:e.array(e.object({id:U,name:e.string().trim().min(1).max(60),root:je,theme:Se.optional(),editorPosition:e.object({x:e.number().finite().min(-1e5).max(1e5),y:e.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(z.pages),strings:gt,actions:e.array(dt).max(z.actions)}).strict();function R(t,n){for(let i of t.pages)W(i.root,n)}var dn=yt.superRefine((t,n)=>{let i=z;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(c=>c.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let c of t.actions)c.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===c.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`页面最多 ${i.pages} 个`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`动作最多 ${i.actions} 个`});let r=c=>n.addIssue({code:"custom",message:c}),o=Object.keys(t.strings.locales);o.includes(t.strings.defaultLocale)||r("默认语言必须在语言列表里"),o.length>z.locales&&r(`最多 ${z.locales} 种语言`);let a=new Set;for(let c of t.actions)a.has(c.id)&&r(`动作标识重复:${c.id}`),a.add(c.id);let s=new Set;for(let c of t.pages)["next","back"].includes(c.id)&&r(`页面 id 不能使用保留名称:${c.id}`),s.has(c.id)&&r(`页面 id 重复:${c.id}`),s.add(c.id);let l=new Set,u=0,y=!1;R(t,(c,b)=>{if(u++,b>z.depth&&(y=!0),l.has(c.id)&&r(`组件 id 重复:${c.id}`),l.add(c.id),c.type==="button"&&!a.has(c.action)&&r(`按钮 ${c.id} 引用的动作不存在:${c.action}`),c.type==="custom_html")for(let k of Object.keys(c.html))o.includes(k)||r(`自定义 HTML ${c.id} 含有未启用的语言:${k}`);if(c.type==="image")for(let k of Object.keys(c.localizedSrc??{}))o.includes(k)||r(`图片 ${c.id} 含有未启用的语言:${k}`)}),u>i.nodes&&r(`组件最多 ${i.nodes} 个`),y&&r(`层级最多 ${z.depth} 层`)});function W(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let o of t.children)W(o,n,i+1,t)}function we(t){let n=[],i=new Set;return R(t,r=>{let o=(a,s,l)=>{i.has(a)||(i.add(a),n.push({key:a,nodeId:r.id,nodeType:r.type,field:s,required:l}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(o(r.grouping.monthLabel,"label",!0),o(r.grouping.yearLabel,"label",!0),o(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),n}function ht(t,n,i){if(n.field==="html"){let r;return R(t,o=>{o.id===n.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(n.field==="src"){let r=It(t,n.nodeId);return r?.type==="image"?r.localizedSrc?.[i]??(i===t.strings.defaultLocale?r.src:void 0):void 0}return t.strings.locales[i]?.[n.key]}function xt(t){let n=we(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,o)=>r===t.strings.defaultLocale?-1:o===t.strings.defaultLocale?1:0).map(r=>{let o=n.filter(a=>!ht(t,a,r)?.trim()).map(a=>a.key);return{locale:r,total:n.length,filled:n.length-o.length,missing:o,complete:o.length===0}})}function St(t){return xt(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function gn(t,n){return xe(n,St(t),t.strings.defaultLocale)}function bn(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},o={};for(let s of we(t)){if(s.field==="html"||s.field==="src")continue;let l=i[s.key]?.trim()?i[s.key]:r[s.key];l!==void 0&&(o[s.key]=l)}let a=s=>{if(s.type==="stack")return{...s,children:s.children.map(a)};if(s.type==="custom_html"){let l=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:l===void 0?{}:{[n]:l}}}if(s.type==="image"){let{localizedSrc:l,...u}=s;return{...u,src:l?.[n]??l?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:a(s.root)})),strings:{defaultLocale:n,locales:{[n]:o}}}}function kt(t,n){let i=null;return W(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function It(t,n){for(let i of t.pages){let r=kt(i.root,n);if(r)return r}return null}function yn(t){let n=F(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function hn(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n;if(R(t,a=>{if(a.type==="quantity_picker"){let l=o[a.id];typeof l=="number"&&Number.isSafeInteger(l)&&l>=a.minimumQuantity&&l<=a.maximumQuantity&&(l-a.minimumQuantity)%a.step===0&&(r[a.id]=l);return}if(a.type==="plan_picker"){let l=o[a.id];typeof l=="string"&&(r[a.id]=i?.pickers[a.id]?.options.includes(l)?l:"");return}if(a.type==="custom_html"&&a.ui)for(let[l,u]of Object.entries(a.ui.state??{})){let y=`${a.id}.${l}`,c=o[y];c!==null&&D(u,c)&&(r[y]=c)}if(a.type!=="stack"||!a.interaction)return;let s=Object.hasOwn(o,a.id)?o[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof s=="string"&&a.children.some(l=>l.id===s)&&(r[a.id]=s),a.interaction.type==="toggle"&&typeof s=="boolean"&&(r[a.id]=s)}),t.surface==="paywall"&&typeof o.__page=="string"&&t.pages.some(a=>a.id===o.__page)&&(r.__page=o.__page),i){let a={...r};for(let[s,l]of Object.entries(o))(typeof l=="string"||typeof l=="boolean")&&(a[s]=l);Object.assign(r,pe(t,a,i))}return r}export{V as a,wt as b,te as c,Ot as d,ne as e,re as f,Et as g,ie as h,Vt as i,le as j,me as k,fe as l,Qt as m,Ft as n,Jt as o,A as p,F as q,z as r,U as s,g as t,q as u,R as v,dn as w,W as x,we as y,xt as z,gn as A,bn as B,It as C,yn as D,hn as E};
|
|
1
|
+
import{a as C,j as J}from"./chunk-ZVLZLBDA.js";import{b as X}from"./chunk-YJRO7NXN.js";import{j as K,l as E}from"./chunk-LDLS2VL2.js";import{b as e}from"./chunk-PY3AC5KD.js";var Y=e.number().int().min(0).max(1e8),V=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Y,flatAmountMinor:Y.optional()})).min(1).max(12)}).refine(t=>t.tiers.at(-1)?.upTo===null&&t.tiers.slice(0,-1).every((n,i)=>{let r=t.tiers[i-1]?.upTo;return n.upTo!==null&&(i===0||r!=null&&n.upTo>r)}),"Tier ceilings must increase and end unbounded").refine(t=>!t.tiers.some(n=>(n.flatAmountMinor??0)>0)||t.kind==="volume"&&t.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function M(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?V.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,o=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let a of i.tiers){let s=a.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else n>o&&(r+=BigInt(Math.min(n,s)-o)*BigInt(a.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function wt(t){return M({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ve=K.refine(t=>/[1-9]/.test(t)),te=e.strictObject({units:ve,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:V.optional()})).min(1).max(20).refine(t=>new Set(t.map(n=>n.currency)).size===t.length,"Currencies must be unique").refine(t=>t.every(n=>!n.pricing||n.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:e.number().int().min(0).max(1e4),maximumQuantity:e.number().int().min(0).max(1e4)}).refine(t=>t.maximumQuantity>=t.minimumQuantity,"Purchased quantity must fit its published bounds").refine(t=>{try{for(let n of t.prices)for(let i of[t.maximumQuantity,...n.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])i<=t.maximumQuantity&&M({amountMinor:n.amountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}},i);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function ee(t){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(t))throw new Error("Invalid quantity");let[n,i=""]=t.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*1000000n+BigInt(i.padEnd(6,"0"))}function Ot(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=ee(t)+ee(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let o=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(o?"."+o:"")}var ne=e.strictObject({internalFeatureId:e.uuid(),name:e.string().min(1).max(120),includedAmount:e.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:e.enum(["hour","day","week","month","year","lifetime"]),resetCount:e.number().int().min(1).max(100),terms:te});var _e=["plan.name","plan.price","plan.period","plan.price_per_month","trial.headline","trial.terms","offer.headline","offer.name","offer.description","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.price","offer.original_price","offer.months","offer.code","offer.ends_at","offer.expires_at","paywall.feature","paywall.message","paywall.action"],T=e.object({plan:e.string().min(1).max(200).optional(),coupon:e.uuid().optional(),promotionCode:e.uuid().optional(),picker:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),re=e.object({text:e.string().optional(),label:e.string().optional(),alt:e.string().optional(),html:e.string().max(32768).optional(),price:e.object({current:e.string(),original:e.string().nullable(),period:e.string()}).optional(),code:e.string().optional(),countdownAt:e.iso.datetime().optional(),planId:e.string().min(1).max(200).optional(),planVersionId:e.string().min(1).max(200).optional(),currency:C.optional(),couponId:e.uuid().optional(),offerId:e.uuid().optional(),unavailable:e.boolean().optional(),unavailableReason:e.string().optional(),missing:e.array(e.string()).optional()}).strict(),Et=e.object({paywall:J.optional(),nodes:e.record(e.string(),e.object({base:re,picker:e.string().optional(),byPlan:e.record(e.string(),re).optional()}).strict()),plans:e.record(e.string(),e.object({id:e.string().min(1).max(200),versionId:e.string().min(1).max(200),available:e.boolean(),name:e.string(),price:e.string(),period:e.string(),currency:C.optional(),amountMinor:e.number().int().nonnegative().optional(),interval:e.enum(["free","week","month","year","one_time"]).optional(),intervalCount:e.number().int().positive().optional(),prepaid:e.array(ne).max(100).optional()}).strict()),pickers:e.record(e.string(),e.object({options:e.array(e.string().min(1).max(200)).max(20),selected:e.string().min(1).max(200).nullable()}).strict()),quantities:e.record(e.string(),e.strictObject({minimum:e.number().int().nonnegative(),maximum:e.number().int().nonnegative(),step:e.number().int().positive(),value:e.number().int().nonnegative(),label:e.string(),available:e.boolean()})).optional(),diagnostics:e.array(e.object({nodeId:e.string(),message:e.string()}).strict())}).strict();function ie(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function Z(t){let n=ie(t).filter(r=>!_e.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),i=t.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(i.includes("{{")||i.includes("}}"))&&n.push("无效变量语法"),[...new Set(n)]}function Vt(t,n,i={}){let r=t?.nodes[n];if(!r)return;let o=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}var Ne=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],oe=e.enum(Ne),ae=e.object({source:oe,layout:e.enum(["full","compact"]),resourceKey:E.optional(),pageSize:e.number().int().min(1).max(50),showSources:e.boolean(),allowPurchase:e.boolean(),outputs:e.object({billing_adjustment:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((t,n)=>{(t.outputs?.billing_authorization||t.outputs?.billing_adjustment)&&t.source!=="billing_controls"&&n.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),t.resourceKey&&!["credit_balance","credit_transactions"].includes(t.source)&&n.addIssue({code:"custom",message:"这个数据源不能绑定积分资源。"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"只有积分余额可以展开来源。"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"只有积分包、套餐与会员组件可以启用交易。"})}),x=e.string().max(2e3),se=e.object({id:e.string().max(100),label:x,detail:e.array(x).max(12),value:x.optional(),status:x.optional(),facts:e.array(e.object({label:x,value:x}).strict()).max(1e3),purchaseId:e.uuid().optional(),invoiceUrl:e.url().max(2048).refine(t=>{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}).optional(),billingActions:e.array(e.strictObject({action:e.literal("invoice_open"),label:x})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:x}).strict()).max(3).optional()}).strict(),Pe=e.object({key:E,name:x,spendable:x,reserved:x,available:x,expiry:x.nullable(),sources:e.array(se).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),Oe=e.object({source:oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:x.optional(),resources:e.array(Pe).max(500),rows:e.array(se).max(50),hasNext:e.boolean(),hasPrevious:e.boolean(),page:e.number().int().positive(),filter:e.string().max(40),updatedAt:e.iso.datetime().optional(),buyingId:e.uuid().optional(),membershipBusy:e.boolean().optional(),billingBusy:e.boolean().optional(),membershipReview:e.object({title:x,note:x,facts:e.array(e.object({label:x,value:x}).strict()).max(100)}).strict().optional(),membershipResult:x.optional()}).strict(),Qt=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oe)}).strict(),Ft=e.object({nodeId:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:e.enum(["refresh","next","previous","filter","buy_pack","billing_portal","billing_authorization","billing_adjustment","invoice_open","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:e.string().max(100).optional()}).strict();function ce(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function le(t){let n={};function i(r){if(ce(r)){let o=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let l=s.type==="stack"?s.bind?.plan:void 0;l&&!o.ids.includes(l)&&o.ids.push(l)}let a=r.children[r.interaction.defaultIndex];!o.defaultId&&a?.type==="stack"&&(o.defaultId=a.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function pe(t,n,i){let r={};function o(u){if(u.hidden)return;if(u.type==="plan_picker"){let b=i.pickers[u.id];r[u.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let y=u.children.filter(b=>!b.hidden),c=u.interaction;if(ce(u)){let b=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},k=i.pickers[u.interaction.pickerId]?.options??[];for(let p of y){let d=p.type==="stack"?p.bind?.plan:void 0;d&&k.includes(d)&&!b.ids.includes(d)&&b.ids.push(d),d&&p.id===n[u.id]&&b.remembered.push(d)}let m=u.children[u.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(c?.type==="tabs"){let b=y.find(k=>k.id===n[u.id])??u.children[c.defaultIndex];b&&o(b)}else if(c?.type==="toggle"){let b=typeof n[u.id]=="boolean"?n[u.id]:c.defaultEnabled,k=u.children[b?0:1];k&&o(k)}else y.forEach(o)}let a=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(u=>u.id===a);s&&o(s.root);let l={};for(let[u,y]of Object.entries(r)){let c=n[u],b=y.remembered[0]??(y.ids.includes(i.pickers[u]?.selected??"")?i.pickers[u]?.selected:y.defaults[0]);l[u]=typeof c=="string"?y.ids.includes(c)?c:"":b&&y.ids.includes(b)?b:""}for(let u of Object.keys(le(t)))l[u]??="";return l}var ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),me=e.strictObject({tiers:e.array(e.strictObject({id:ue,name:e.string().trim().min(1).max(80)})).min(1).max(8),assignments:e.array(e.strictObject({productVersionId:e.string().min(1).max(200),tierId:ue,period:e.enum(["month","year"])})).max(20)}).superRefine((t,n)=>{let i=t.tiers.map(r=>r.id);(new Set(i).size!==i.length||new Set(t.assignments.map(r=>r.productVersionId)).size!==t.assignments.length||new Set(t.assignments.map(r=>`${r.tierId}:${r.period}`)).size!==t.assignments.length||t.assignments.some(r=>!i.includes(r.tierId)))&&n.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function fe(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function Jt(t){let n=Z(t).map(i=>`未知变量:${i}`);for(let i=0;i<t.length;i++){if(t[i]!=="<"||!/[A-Za-z!/?{]/.test(t[i+1]??""))continue;let r=i;if(t.startsWith("<!--",i)){let o=t.indexOf("-->",i+4);i=o<0?t.length:o+2}else{let o="";for(i++;i<t.length;i++){let a=t[i];if(o)a===o&&(o="");else if(a==='"'||a==="'")o=a;else if(a===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("变量只能放在 HTML 文字中,不能放入标签、属性或注释")}return[...new Set(n)]}var h={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},ge=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),S=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!ge.has(t),"Reserved UI identifier"),B=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),Ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(B).min(1).max(h.enumValues),default:B}),e.strictObject({type:e.literal("number"),min:e.number().finite(),max:e.number().finite(),step:e.number().finite().positive(),default:e.number().finite()}),e.strictObject({type:e.literal("text"),maxLength:e.number().int().min(0).max(2e3),default:e.string().max(2e3).nullable()}),e.strictObject({type:e.literal("boolean"),default:e.boolean()})]);function D(t,n){if(t.type==="enum")return t.values.some(r=>r===n);if(t.type==="boolean")return typeof n=="boolean";if(t.type==="text")return n===null||typeof n=="string"&&n.length<=t.maxLength;if(typeof n!="number"||!Number.isFinite(n)||n<t.min||n>t.max)return!1;let i=(n-t.min)/t.step;return Number.isFinite(i)&&Math.abs(i-Math.round(i))<=Math.min(1e-7,Math.max(1,Math.abs(i))*Number.EPSILON*8)}var Ce=Ae.superRefine((t,n)=>{t.type==="enum"&&new Set(t.values).size!==t.values.length&&n.addIssue({code:"custom",path:["values"],message:"UI enum values must be unique"}),t.type==="number"&&t.min>t.max&&n.addIssue({code:"custom",path:["max"],message:"UI number range is reversed"}),D(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),$e=["add","sub","mul","div","min","max","round","floor","eq","ne","gt","gte","lt","lte","and","or","not","if","concat","number","parse_number","money","lookup","now","duration"];function Ue(t,n){return t==="now"?n===0:t==="concat"?!0:t==="lookup"?n>=4&&n%2===0:t==="if"?n===3:["sub","div","eq","ne","gt","gte","lt","lte"].includes(t)?n===2:["round","floor","not","number","parse_number","money","duration"].includes(t)?n===1:n>=1}var N=e.lazy(()=>e.union([B,e.strictObject({ref:S}),e.strictObject({op:e.enum($e),args:e.array(N).max(h.expressionNodes)}).superRefine((t,n)=>{Ue(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function _(t,n,i){if(!t||typeof t!="object")return!0;if(!j(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(ge.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let o=Object.getOwnPropertyDescriptor(t,r);if(o&&!Object.hasOwn(o,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function O(t,n,i,r){let o=[{value:t,depth:1,path:i}];for(;o.length;){let a=o.pop();if(++r.nodes>h.expressionNodes||a.depth>h.depth){n.addIssue({code:"custom",path:a.path,message:"UI expression budget exceeded"});return}if(!_(a.value,n,a.path))return;if(j(a.value)&&Array.isArray(a.value.args)){if(a.value.args.length>h.expressionNodes){n.addIssue({code:"custom",path:[...a.path,"args"],message:"UI expression budget exceeded"});return}for(let s=a.value.args.length-1;s>=0;s--)o.push({value:a.value.args[s],depth:a.depth+1,path:[...a.path,"args",s]})}}}var en=e.unknown().superRefine((t,n)=>{O(t,n,[],{nodes:0})}).pipe(N),Q=e.record(S,N).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=h.state,"UI assignments need 1–32 state keys"),Le=e.strictObject({target:S,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:N,className:S.optional()}).superRefine((t,n)=>{t.property==="class"!=(t.className!==void 0)&&n.addIssue({code:"custom",path:["className"],message:"Only class bindings require a safe className"})}),Te=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:S,state:S}),e.strictObject({type:e.literal("input"),target:S,state:S,set:Q.optional()}),e.strictObject({type:e.literal("action"),target:S,set:Q}),e.strictObject({type:e.literal("carousel"),target:S,state:S,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:S.optional(),nextTarget:S.optional(),inactiveTargets:e.array(S).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),De=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:Q}),Re=e.strictObject({type:e.literal("mosaic_waves"),target:S,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:N.optional(),speed:e.number().min(0).max(4).optional(),pitch:e.number().min(.05).max(4).optional(),fill:e.number().min(.05).max(1).optional(),feather:e.number().min(0).max(1).optional(),warp:e.number().min(0).max(4).optional(),warpScale:e.number().min(0).max(32).optional(),detailScale:e.number().min(0).max(32).optional(),waveScale:e.number().min(0).max(32).optional(),falloff:e.number().min(.1).max(32).optional(),brightness:e.number().min(0).max(32).optional(),ambient:e.number().min(0).max(1).optional(),gamma:e.number().min(.05).max(8).optional(),vignette:e.number().min(0).max(1).optional(),opacity:e.number().min(0).max(1).optional()}),Ee=e.strictObject({type:e.literal("number_counter"),target:S,value:N,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),Ve=e.strictObject({state:e.record(S,Ce).refine(t=>Object.keys(t).length<=h.state,"Too many UI state keys").optional(),derived:e.record(S,N).refine(t=>Object.keys(t).length<=h.derived,"Too many UI derived keys").optional(),bindings:e.array(Le).max(h.bindings).optional(),controls:e.array(Te).max(h.controls).optional(),timers:e.array(De).max(h.timers).optional(),effects:e.array(e.discriminatedUnion("type",[Re,Ee])).max(h.effects).optional(),clock:e.boolean().optional()});function Me(t,n){if(!_(t,n,[])||!j(t))return;for(let[r,o]of[["state",h.state],["derived",h.derived]]){let a=t[r];if(!_(a,n,[r]))return;if(j(a)&&Object.keys(a).length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,o]of[["bindings",h.bindings],["controls",h.controls],["timers",h.timers],["effects",h.effects]])if(Array.isArray(t[r])&&t[r].length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,o]of t.effects.entries())if(!_(o,n,["effects",r]))return}if(j(t.state))for(let[r,o]of Object.entries(t.state)){if(!_(o,n,["state",r]))return;if(j(o)&&Array.isArray(o.values)&&o.values.length>h.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(j(t.derived))for(let[r,o]of Object.entries(t.derived))O(o,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let o=t[r];if(Array.isArray(o)){for(let[a,s]of o.entries())if(!(!_(s,n,[r,a])||!j(s))){if(r==="bindings")O(s.expression,n,[r,a,"expression"],i);else if(_(s.set,n,[r,a,"set"])&&j(s.set)){if(Object.keys(s.set).length>h.state){n.addIssue({code:"custom",path:[r,a,"set"],message:"Too many UI assignments"});return}for(let[l,u]of Object.entries(s.set))O(u,n,[r,a,"set",l],i)}if(i.nodes>h.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,o]of t.effects.entries())j(o)&&o.type==="number_counter"?O(o.value,n,["effects",r,"value"],i):j(o)&&o.enabled!==void 0&&O(o.enabled,n,["effects",r,"enabled"],i)}function de(t){let n=[],i=[t];for(;i.length;){let r=i.pop();!r||typeof r!="object"||("ref"in r?n.push(r.ref):i.push(...r.args))}return n}var be=e.unknown().superRefine(Me).pipe(Ve).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},o=new Set([...Object.keys(i),...Object.keys(r)]),a=(m,p)=>{for(let d of de(m))o.has(d)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${d}`})};for(let[m,p]of Object.entries(t.derived??{}))Object.hasOwn(i,m)&&n.addIssue({code:"custom",path:["derived",m],message:"UI state and derived identifiers must be distinct"}),a(p,["derived",m]);let s=new Set,l=new Set,u=m=>{if(s.has(m))return!1;if(l.has(m))return!0;s.add(m);for(let p of de(r[m]))if(Object.hasOwn(r,p)&&!u(p))return!1;return s.delete(m),l.add(m),!0};for(let m of Object.keys(r))if(!u(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())a(p.expression,["bindings",m,"expression"]);let y=new Set;for(let[m,p]of(t.effects??[]).entries())y.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),y.add(p.target),p.type==="number_counter"?(a(p.value,["effects",m,"value"]),typeof p.value=="number"&&Math.abs(p.value)>1e12&&n.addIssue({code:"custom",path:["effects",m,"value"],message:"Counter values must be within the display bound"})):p.enabled!==void 0&&a(p.enabled,["effects",m,"enabled"]);let c=(m,p)=>{for(let[d,v]of Object.entries(m))Object.hasOwn(i,d)||n.addIssue({code:"custom",path:[...p,d],message:"UI assignments can only update declared state"}),a(v,[...p,d])},b=new Set,k=new Set;for(let[m,p]of(t.controls??[]).entries()){if(p.type==="carousel"&&p.inactiveMaxWidth!==void 0&&p.inactiveTargets===void 0&&n.addIssue({code:"custom",path:["controls",m,"inactiveMaxWidth"],message:"Inactive width requires inactive article targets"}),p.type==="carousel")for(let d of p.inactiveTargets??[])(d===p.target||k.has(d))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),k.add(d);if(p.type==="carousel")for(let d of["previousTarget","nextTarget"]){let v=p[d];v!==void 0&&((v===p.target||b.has(v)||(t.controls??[]).some(ze=>ze.target===v))&&n.addIssue({code:"custom",path:["controls",m,d],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(v))}if(p.type!=="action"){let d=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!d||p.type==="input"&&d.type==="enum"&&d.values.some(v=>typeof v!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(d?.type!=="number"||!Number.isInteger(d.min)||d.min<0||!Number.isInteger(d.max)||d.step!==1||p.initialIndex!==void 0&&!D(d,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&d?.type!=="boolean"&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Scroll latches require boolean UI state"})}(p.type==="input"||p.type==="action")&&p.set&&c(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())c(p.set,["timers",m,"set"])});var he=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,A=e.string().max(16).regex(he,"语言代码格式不正确,例如 zh-CN、en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"持久化语言代码必须使用规范写法");function F(t){if(typeof t!="string")return null;try{let n=Intl.getCanonicalLocales(t.trim().replaceAll("_","-"))[0];if(!n)return null;let{language:i,script:r,region:o}=new Intl.Locale(n),a=[i,r,o].filter(Boolean).join("-");return he.test(a)?a:null}catch{return null}}var Ze=new Set(["TW","HK","MO"]);function ye(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let o=i?.length===4?i:void 0,a=i?.length===4?r:i;return o?`zh-${o}`:a&&Ze.has(a)?"zh-Hant":"zh-Hans"}function xe(t,n,i){let r=n.map(o=>({code:A.parse(o),normalized:o}));for(let o of t){let a=F(o);if(!a)continue;let s=r.find(c=>c.normalized===a);if(s)return s.code;let l=ye(a),u=r.filter(c=>ye(c.normalized)===l),y=u.find(c=>!c.normalized.includes("-")||c.normalized===l)??u[0];if(y)return y.code}return i}var Be=4,z={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},U=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),g=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qe=e.enum(["none","xs","sm","md","lg","xl"]),Fe=e.enum(["none","sm","md","lg","full"]),H=e.string().regex(/^#[0-9a-fA-F]{6}$/),G=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"只支持 https 链接"),q=e.union([G,e.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Se=e.object({primary:H,background:H,text:H,radius:Fe,font:e.enum(["system","serif","rounded","mono"]),fontAssets:e.object({family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/),faces:e.array(e.object({url:G,weight:e.number().int().min(100).max(900).multipleOf(100),family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/).optional()}).strict()).min(1).max(4)}).strict().optional()}).strict(),L=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),f=(t,n)=>e.number().int().min(t).max(n),ke=e.union([e.enum(["fit","fill"]),f(1,1200)]),He=e.object({top:f(0,200),right:f(0,200),bottom:f(0,200),left:f(0,200)}).strict(),qe=e.object({top:f(-100,200),right:f(-100,200),bottom:f(-100,200),left:f(-100,200)}).strict(),Ie=e.object({x:f(0,100),y:f(0,100)}).strict(),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:L}).strict(),e.object({type:e.literal("linear"),angle:f(0,360),stops:e.array(e.object({color:L,at:f(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:q,fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict()]),We=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([f(0,200),e.object({topLeft:f(0,200),topRight:f(0,200),bottomRight:f(0,200),bottomLeft:f(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ke=e.object({width:f(0,12),color:L,style:e.enum(["solid","dashed"])}).strict(),Je=e.object({x:f(-40,40),y:f(-40,40),blur:f(0,80),spread:f(-20,40),color:L}).strict(),Xe=e.object({font:e.enum(["system","serif","rounded","mono"]),size:f(8,96),weight:e.number().int().min(100).max(900).multipleOf(100),lineHeight:e.number().min(.8).max(3),letterSpacing:e.number().min(-5).max(20),color:L,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),P=e.object({width:ke,height:ke,padding:He,margin:qe,gap:f(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Ge,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:We,border:Ke,shadow:Je,text:Xe}).strict().partial(),I={id:U,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:P.optional(),fallback:g.optional()},Ye=e.object({...I,type:e.literal("text"),productField:e.enum(["name","price","trial","period"]).optional(),feature:e.object({id:e.uuid(),field:e.enum(["name","allowance"])}).strict().optional(),text:g,variant:e.enum(["title","heading","body","caption"])}).strict(),et=e.object({...I,type:e.literal("image"),src:q,localizedSrc:e.record(A,q).optional(),alt:g,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict(),tt=e.object({...I,type:e.literal("button"),label:g,variant:e.enum(["primary","secondary","link"]),action:g,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:T.optional()}).strict(),nt=e.object({...I,type:e.literal("divider")}).strict(),rt=e.object({...I,type:e.literal("customer_data"),title:g,data:ae}).strict(),it=e.object({...I,type:e.literal("spacer"),size:Qe}).strict(),ot=e.object({...I,type:e.literal("custom_html"),html:e.record(A,e.string().max(z.customHtml)),css:e.string().max(z.customCss),ui:be.optional()}).strict(),at=e.object({...I,type:e.literal("price"),fallback:g,parts:e.object({current:P.optional(),original:P.optional(),period:P.optional()}).strict().optional()}).strict(),st=e.object({...I,type:e.literal("coupon_code"),label:g,fallback:g}).strict(),ct=e.object({...I,type:e.literal("countdown"),source:e.enum(["offer.ends_at","offer.expires_at","fixed"]),at:e.iso.datetime().optional(),granularity:e.enum(["day","hour","minute","second"]),expired:g,fallback:g}).strict().refine(t=>t.source!=="fixed"||!!t.at,"固定倒计时需要结束时间"),lt=e.object({...I,type:e.literal("plan_picker"),label:g,fallback:g,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"套餐不能重复").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:me.safeExtend({monthLabel:g,yearLabel:g,unavailableLabel:g}).optional(),states:e.object({selected:P.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!fe(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),pt=e.object({...I,type:e.literal("quantity_picker"),bind:T.optional(),label:g,fallback:g,internalFeatureId:e.uuid(),minimumQuantity:f(0,1e4),maximumQuantity:f(0,1e4),defaultQuantity:f(0,1e4),step:f(1,1e4)}).strict().refine(t=>t.minimumQuantity<=t.defaultQuantity&&t.defaultQuantity<=t.maximumQuantity&&(t.defaultQuantity-t.minimumQuantity)%t.step===0,"Quantity controls require a Product binding and valid bounds"),ut=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:g,keyboard:e.enum(["text","email","tel","url"]),maxLength:f(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:g,min:f(0,50),max:f(1,50)}).strict(),e.object({type:e.literal("select"),label:g,defaultIndex:f(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:U.optional(),selectedStyle:P.optional()}).strict(),e.object({type:e.literal("tabs"),label:g,defaultIndex:f(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:g,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:g}).strict()]),w={...I,type:e.literal("stack"),direction:e.enum(["vertical","horizontal","overlay"]),align:e.enum(["start","center","end","stretch"]),justify:e.enum(["start","center","end","between"]),productSlot:e.object({index:f(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:ut.optional(),states:e.object({selected:P.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:g.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:T.optional()},je=e.lazy(()=>e.object({...I,type:w.type,direction:w.direction,align:w.align,justify:w.justify,children:e.array(mt).max(z.children),productSlot:w.productSlot,interaction:w.interaction,states:w.states,purpose:w.purpose,purchaseAction:w.purchaseAction,buttonVariant:w.buttonVariant,bind:w.bind}).strict()),mt=e.lazy(()=>e.union([je,Ye,et,tt,nt,it,ot,at,st,ct,lt,pt,rt])),ft=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),$={id:g,event:g,properties:e.record(g,ft).refine(t=>Object.keys(t).length<=20,"最多 20 个参数")},dt=e.discriminatedUnion("type",[e.object({...$,type:e.literal("navigate"),close:e.literal(!1),pageId:U}).strict(),e.object({...$,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...$,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...$,type:e.literal("open_url"),close:e.boolean(),url:G}).strict(),e.object({...$,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),gt=e.object({defaultLocale:A,locales:e.record(A,e.record(g,e.string().max(z.stringLength)))}).strict(),bt=e.enum(["popup","paywall","onboarding","page","banner"]);var yt=e.object({kind:e.literal("screen"),schemaVersion:e.literal(Be),name:e.string().trim().min(1).max(80),surface:bt,initialPageId:U.optional(),presentation:X,theme:Se,pages:e.array(e.object({id:U,name:e.string().trim().min(1).max(60),root:je,theme:Se.optional(),editorPosition:e.object({x:e.number().finite().min(-1e5).max(1e5),y:e.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(z.pages),strings:gt,actions:e.array(dt).max(z.actions)}).strict();function R(t,n){for(let i of t.pages)W(i.root,n)}var dn=yt.superRefine((t,n)=>{let i=z;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(c=>c.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let c of t.actions)c.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===c.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`页面最多 ${i.pages} 个`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`动作最多 ${i.actions} 个`});let r=c=>n.addIssue({code:"custom",message:c}),o=Object.keys(t.strings.locales);o.includes(t.strings.defaultLocale)||r("默认语言必须在语言列表里"),o.length>z.locales&&r(`最多 ${z.locales} 种语言`);let a=new Set;for(let c of t.actions)a.has(c.id)&&r(`动作标识重复:${c.id}`),a.add(c.id);let s=new Set;for(let c of t.pages)["next","back"].includes(c.id)&&r(`页面 id 不能使用保留名称:${c.id}`),s.has(c.id)&&r(`页面 id 重复:${c.id}`),s.add(c.id);let l=new Set,u=0,y=!1;R(t,(c,b)=>{if(u++,b>z.depth&&(y=!0),l.has(c.id)&&r(`组件 id 重复:${c.id}`),l.add(c.id),c.type==="button"&&!a.has(c.action)&&r(`按钮 ${c.id} 引用的动作不存在:${c.action}`),c.type==="custom_html")for(let k of Object.keys(c.html))o.includes(k)||r(`自定义 HTML ${c.id} 含有未启用的语言:${k}`);if(c.type==="image")for(let k of Object.keys(c.localizedSrc??{}))o.includes(k)||r(`图片 ${c.id} 含有未启用的语言:${k}`)}),u>i.nodes&&r(`组件最多 ${i.nodes} 个`),y&&r(`层级最多 ${z.depth} 层`)});function W(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let o of t.children)W(o,n,i+1,t)}function we(t){let n=[],i=new Set;return R(t,r=>{let o=(a,s,l)=>{i.has(a)||(i.add(a),n.push({key:a,nodeId:r.id,nodeType:r.type,field:s,required:l}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(o(r.grouping.monthLabel,"label",!0),o(r.grouping.yearLabel,"label",!0),o(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),n}function ht(t,n,i){if(n.field==="html"){let r;return R(t,o=>{o.id===n.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(n.field==="src"){let r=It(t,n.nodeId);return r?.type==="image"?r.localizedSrc?.[i]??(i===t.strings.defaultLocale?r.src:void 0):void 0}return t.strings.locales[i]?.[n.key]}function xt(t){let n=we(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,o)=>r===t.strings.defaultLocale?-1:o===t.strings.defaultLocale?1:0).map(r=>{let o=n.filter(a=>!ht(t,a,r)?.trim()).map(a=>a.key);return{locale:r,total:n.length,filled:n.length-o.length,missing:o,complete:o.length===0}})}function St(t){return xt(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function gn(t,n){return xe(n,St(t),t.strings.defaultLocale)}function bn(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},o={};for(let s of we(t)){if(s.field==="html"||s.field==="src")continue;let l=i[s.key]?.trim()?i[s.key]:r[s.key];l!==void 0&&(o[s.key]=l)}let a=s=>{if(s.type==="stack")return{...s,children:s.children.map(a)};if(s.type==="custom_html"){let l=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:l===void 0?{}:{[n]:l}}}if(s.type==="image"){let{localizedSrc:l,...u}=s;return{...u,src:l?.[n]??l?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:a(s.root)})),strings:{defaultLocale:n,locales:{[n]:o}}}}function kt(t,n){let i=null;return W(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function It(t,n){for(let i of t.pages){let r=kt(i.root,n);if(r)return r}return null}function yn(t){let n=F(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function hn(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n;if(R(t,a=>{if(a.type==="quantity_picker"){let l=o[a.id];typeof l=="number"&&Number.isSafeInteger(l)&&l>=a.minimumQuantity&&l<=a.maximumQuantity&&(l-a.minimumQuantity)%a.step===0&&(r[a.id]=l);return}if(a.type==="plan_picker"){let l=o[a.id];typeof l=="string"&&(r[a.id]=i?.pickers[a.id]?.options.includes(l)?l:"");return}if(a.type==="custom_html"&&a.ui)for(let[l,u]of Object.entries(a.ui.state??{})){let y=`${a.id}.${l}`,c=o[y];c!==null&&D(u,c)&&(r[y]=c)}if(a.type!=="stack"||!a.interaction)return;let s=Object.hasOwn(o,a.id)?o[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof s=="string"&&a.children.some(l=>l.id===s)&&(r[a.id]=s),a.interaction.type==="toggle"&&typeof s=="boolean"&&(r[a.id]=s)}),t.surface==="paywall"&&typeof o.__page=="string"&&t.pages.some(a=>a.id===o.__page)&&(r.__page=o.__page),i){let a={...r};for(let[s,l]of Object.entries(o))(typeof l=="string"||typeof l=="boolean")&&(a[s]=l);Object.assign(r,pe(t,a,i))}return r}export{V as a,wt as b,te as c,Ot as d,ne as e,re as f,Et as g,ie as h,Vt as i,le as j,me as k,fe as l,Qt as m,Ft as n,Jt as o,A as p,F as q,z as r,U as s,g as t,q as u,R as v,dn as w,W as x,we as y,xt as z,gn as A,bn as B,It as C,yn as D,hn as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as o}from"./chunk-
|
|
1
|
+
import{f as o}from"./chunk-LDLS2VL2.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;commandRequestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as c}from"./chunk-
|
|
1
|
+
import{k as c}from"./chunk-BBA64POP.js";import{b as r}from"./chunk-PY3AC5KD.js";var s=r.strictObject({items:r.array(r.strictObject({productVersionId:r.string().min(1).max(200),label:r.string().trim().max(40)})).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Duplicate Paywall Product"),defaultProductVersionId:r.string().min(1).max(200).nullable(),grouping:c.optional()});function p(e,t,n){let i=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof i!="string"||!Object.values(n.plans).some(o=>o.versionId===i&&o.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(i)||!n.pickers[e.pickerId]?.options.includes(i))?null:i}export{s as a,p as b};
|