@tinkerlandai/longplay-sdk 0.10.37 → 0.10.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/check-response-MNFEOKKE.js +1 -0
  3. package/dist/{chunk-T2KWLYCW.js → chunk-2Y5SGDC6.js} +1 -1
  4. package/dist/{chunk-LOLMUXHW.js → chunk-3JD3U45R.js} +1 -1
  5. package/dist/{chunk-VLSP3LRH.js → chunk-3S25TLC3.js} +1 -1
  6. package/dist/{chunk-XGNXZWZL.js → chunk-525K7BPJ.js} +1 -1
  7. package/dist/chunk-73ISTR7P.js +1 -0
  8. package/dist/{chunk-WZMZMJCK.js → chunk-BIT6YWM7.js} +1 -1
  9. package/dist/{chunk-6F4JS3RK.js → chunk-CBZ5GW4J.js} +1 -1
  10. package/dist/{chunk-AB7GEGZ2.js → chunk-CE5MAAIR.js} +1 -1
  11. package/dist/{chunk-ECKVJGXQ.js → chunk-CEMHQQAJ.js} +1 -1
  12. package/dist/chunk-CKVAV2W5.js +1 -0
  13. package/dist/{chunk-E7CCHUSO.js → chunk-DPIQ3SV7.js} +1 -1
  14. package/dist/{chunk-ZZIBLQCJ.js → chunk-GDD26ZDV.js} +1 -1
  15. package/dist/{chunk-PW5PIBSO.js → chunk-GGYBZWWY.js} +1 -1
  16. package/dist/{chunk-DDLSQSWO.js → chunk-GNAMACMK.js} +1 -1
  17. package/dist/{chunk-7XDQKZYA.js → chunk-HFD4CLCJ.js} +1 -1
  18. package/dist/{chunk-4KLXQKNO.js → chunk-HX36OZPQ.js} +1 -1
  19. package/dist/{chunk-XJRDO3NI.js → chunk-IGANLTKS.js} +1 -1
  20. package/dist/{chunk-YV6UFESO.js → chunk-IYHXEKAD.js} +1 -1
  21. package/dist/{chunk-UV4H6VCS.js → chunk-JAZHNQKO.js} +1 -1
  22. package/dist/{chunk-AHUYZ6IW.js → chunk-JBVZ6A6V.js} +1 -1
  23. package/dist/{chunk-AOGDCT4T.js → chunk-KIPUBMU3.js} +1 -1
  24. package/dist/{chunk-RE4OLOOT.js → chunk-LJBTEB2Q.js} +1 -1
  25. package/dist/{chunk-ZYOZSUZS.js → chunk-LZBJHWVH.js} +1 -1
  26. package/dist/{chunk-S43TYW3V.js → chunk-MTIOLSVM.js} +1 -1
  27. package/dist/{chunk-KFIL73QY.js → chunk-N774V4SQ.js} +1 -1
  28. package/dist/chunk-NSAEHRIT.js +1 -0
  29. package/dist/{chunk-LC6UCDWE.js → chunk-O2D3A4CS.js} +1 -1
  30. package/dist/{chunk-W74JLL2O.js → chunk-ONMIBSOC.js} +1 -1
  31. package/dist/{chunk-VIBJNB5B.js → chunk-PFPMK4IO.js} +1 -1
  32. package/dist/{chunk-OX2A3UD2.js → chunk-QCMFCK7Z.js} +1 -1
  33. package/dist/{chunk-OQRMAU2B.js → chunk-QXOUDODX.js} +1 -1
  34. package/dist/{chunk-TASEZY5T.js → chunk-TA4W6SXG.js} +1 -1
  35. package/dist/{chunk-2VMEDQHT.js → chunk-TLRRBUGP.js} +1 -1
  36. package/dist/{chunk-U7NX5ET2.js → chunk-TPXRO63H.js} +1 -1
  37. package/dist/{chunk-D3OYXTMC.js → chunk-U7XD4ZR5.js} +1 -1
  38. package/dist/{chunk-2KJLN65C.js → chunk-UKVWANDE.js} +1 -1
  39. package/dist/{chunk-Q676H74B.js → chunk-VYI6QRJW.js} +1 -1
  40. package/dist/{chunk-GH6FM44P.js → chunk-W3G4YIM5.js} +1 -1
  41. package/dist/{chunk-OCWSWXCW.js → chunk-YJS6NNIO.js} +1 -1
  42. package/dist/{chunk-HEHLFHW7.js → chunk-YURGISSB.js} +1 -1
  43. package/dist/{chunk-CY7OKV7E.js → chunk-ZORZA4WG.js} +1 -1
  44. package/dist/{content-QNBATPA2.js → content-HSMBQFM3.js} +1 -1
  45. package/dist/{funnel-host-purchase-FVYPBPET.js → funnel-host-purchase-4KOOLMXV.js} +1 -1
  46. package/dist/funnel-paywall-prerender-NX6ZQ7EU.js +1 -0
  47. package/dist/funnel-runtime-host-6XYYLVCI.js +1 -0
  48. package/dist/index.js +1 -1
  49. package/dist/merchant-bridge-contracts-ACGAMHU6.js +1 -0
  50. package/dist/native-shell.js +1 -1
  51. package/dist/openrouter.js +1 -1
  52. package/dist/operation-contracts-H27WHXQC.js +1 -0
  53. package/dist/page.js +1 -1
  54. package/dist/paywall-ZGG6DXO3.js +1 -0
  55. package/dist/paywall-content-ZQBE2EZP.js +1 -0
  56. package/dist/paywall-session-DBTBLLWI.js +1 -0
  57. package/dist/popup.js +1 -1
  58. package/dist/react-native.js +1 -1
  59. package/dist/screen-renderer-5SJCTMJH.js +1 -0
  60. package/dist/server.js +1 -1
  61. package/dist/visual.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/check-response-N22NNTIT.js +0 -1
  64. package/dist/chunk-2HBIBIOF.js +0 -1
  65. package/dist/chunk-HKXFCRVT.js +0 -1
  66. package/dist/chunk-WQ3O5RXN.js +0 -1
  67. package/dist/funnel-paywall-prerender-Z7RA4YDY.js +0 -1
  68. package/dist/funnel-runtime-host-TJPF3FJS.js +0 -1
  69. package/dist/merchant-bridge-contracts-67AYXZFI.js +0 -1
  70. package/dist/operation-contracts-EK4RCUWJ.js +0 -1
  71. package/dist/paywall-OAVC654P.js +0 -1
  72. package/dist/paywall-content-75XEM7K3.js +0 -1
  73. package/dist/paywall-session-U6SPRJRS.js +0 -1
  74. package/dist/screen-renderer-YIIT742O.js +0 -1
  75. /package/dist/{chunk-CR2XJ2CX.js → chunk-NOOIJXRN.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.39
4
+
5
+ - After a purchase is confirmed, the Paywall reads it every 700 ms, for up to 15 seconds, until the merchant's Checkout arrives. It used to wait 2 seconds, then 3, so a ready Checkout could sit for seconds before the Customer was sent to it. Once a Checkout exists the wait backs off as before.
6
+ - Wire protocol remains `0.10`.
7
+
8
+ ## 0.10.38
9
+
10
+ - A Funnel screen that has no earlier page no longer shows History. Opened from there, it listed nothing.
11
+ - A Funnel footer with nothing in it takes no room. It used to keep its padding and rule below the screen, which left a strip under a modal Popup.
12
+ - Wire protocol remains `0.10`.
13
+
3
14
  ## 0.10.37
4
15
 
5
16
  - Add `preloadFunnelPurchase()`. It downloads the code a Funnel purchase presents with, before any Customer is known, and makes no request and no DOM change.
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-GGYBZWWY.js";import"./chunk-2Y5SGDC6.js";import"./chunk-3JD3U45R.js";import"./chunk-YURGISSB.js";import"./chunk-TPXRO63H.js";import"./chunk-3S25TLC3.js";import"./chunk-NOOIJXRN.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
@@ -1 +1 @@
1
- import{a as s,b as o,c as u}from"./chunk-LOLMUXHW.js";import{d as m,g as p}from"./chunk-HEHLFHW7.js";import{b as e}from"./chunk-CR2XJ2CX.js";var f=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(f);function x(t){let r=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(r)?0:2}function I(t,r,n="en",y={}){let a=i.parse(r.toUpperCase());return new Intl.NumberFormat(n,{style:"currency",currency:a,...y}).format(t/10**x(a))}var d=e.enum(["stripe","apple","google","merchant"]),_=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var l=e.object({provider:d,currency:i}).strict();var c=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:c,commerce:l.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),S=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:o,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function b(t,r){return u({subject:o.parse(t),requirement:c.parse(r)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(S).max(20)}).nullable()}).superRefine((t,r)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(n=>n.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(n=>n.action==="upgrade"!=(n.membershipId!==null)))&&r.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:c}),U=e.strictObject({subject:o,requirement:c}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,r){let n=c.parse(t);return r.internal_feature_id===n.internal_feature_id&&r.quantity===n.quantity&&(!r.observation||r.observation.requirementDigest===b(r.observation.subject,n))}export{i as a,x as b,I as c,_ as d,l as e,c as f,B as g,S as h,b as i,C as j,U as k,$ as l,F as m};
1
+ import{a as s,b as o,c as u}from"./chunk-3JD3U45R.js";import{d as m,g as p}from"./chunk-YURGISSB.js";import{b as e}from"./chunk-NOOIJXRN.js";var f=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(f);function x(t){let r=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(r)?0:2}function I(t,r,n="en",y={}){let a=i.parse(r.toUpperCase());return new Intl.NumberFormat(n,{style:"currency",currency:a,...y}).format(t/10**x(a))}var d=e.enum(["stripe","apple","google","merchant"]),_=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var l=e.object({provider:d,currency:i}).strict();var c=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:c,commerce:l.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),S=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:o,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function b(t,r){return u({subject:o.parse(t),requirement:c.parse(r)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(S).max(20)}).nullable()}).superRefine((t,r)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(n=>n.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(n=>n.action==="upgrade"!=(n.membershipId!==null)))&&r.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:c}),U=e.strictObject({subject:o,requirement:c}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,r){let n=c.parse(t);return r.internal_feature_id===n.internal_feature_id&&r.quantity===n.quantity&&(!r.observation||r.observation.requirementDigest===b(r.observation.subject,n))}export{i as a,x as b,I as c,_ as d,l as e,c as f,B as g,S as h,b as i,C as j,U as k,$ as l,F as m};
@@ -1 +1 @@
1
- import{a as p}from"./chunk-HEHLFHW7.js";import{b as r}from"./chunk-CR2XJ2CX.js";import{a as i,b as s}from"./chunk-CILM5XMH.js";var b=r.string().regex(/^[a-f0-9]{64}$/),j=r.strictObject({scope:r.strictObject({projectId:r.uuid(),environmentId:r.uuid(),environment:p}),customerId:r.uuid()});function l(u){let n=e=>{if(Array.isArray(e))return`[${e.map(n).join(",")}]`;if(e!==null&&typeof e=="object"){let c=Object.getPrototypeOf(e);if(c!==Object.prototype&&c!==null)throw new TypeError("Commerce protocol digests require JSON objects");return`{${Object.entries(e).filter(([,o])=>o!==void 0).sort(([o],[t])=>o<t?-1:o>t?1:0).map(([o,t])=>`${JSON.stringify(o)}:${n(t)}`).join(",")}}`}if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return JSON.stringify(e);throw new TypeError("Commerce protocol digests require JSON values")};return i(s(new TextEncoder().encode(n(u))))}export{b as a,j as b,l as c};
1
+ import{a as p}from"./chunk-YURGISSB.js";import{b as r}from"./chunk-NOOIJXRN.js";import{a as i,b as s}from"./chunk-CILM5XMH.js";var b=r.string().regex(/^[a-f0-9]{64}$/),j=r.strictObject({scope:r.strictObject({projectId:r.uuid(),environmentId:r.uuid(),environment:p}),customerId:r.uuid()});function l(u){let n=e=>{if(Array.isArray(e))return`[${e.map(n).join(",")}]`;if(e!==null&&typeof e=="object"){let c=Object.getPrototypeOf(e);if(c!==Object.prototype&&c!==null)throw new TypeError("Commerce protocol digests require JSON objects");return`{${Object.entries(e).filter(([,o])=>o!==void 0).sort(([o],[t])=>o<t?-1:o>t?1:0).map(([o,t])=>`${JSON.stringify(o)}:${n(t)}`).join(",")}}`}if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return JSON.stringify(e);throw new TypeError("Commerce protocol digests require JSON values")};return i(s(new TextEncoder().encode(n(u))))}export{b as a,j as b,l as c};
@@ -1 +1 @@
1
- import{b as r}from"./chunk-CR2XJ2CX.js";var I=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),L=r.enum([...I.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),C=r.enum([...I.options,"stale_revision"]),s=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),c=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),A={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var N={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function i(e,E){if(e==="CONFLICT"&&E===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&E===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(N,e)){let o=N[e];return{retryable:o==="retry_same_request",recovery:o}}let t=I.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:A[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function D(e,E){let t=I.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(E):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(E):e==="INVALID_REQUEST"?[400,405,415,422].includes(E):e==="NOT_CONFIGURED"?[501,503].includes(E):A[t.data].status===E;let o={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(o,e)&&(o[e]?.includes(E)??!1)}function O(e,E=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let _=Number(t);return Number.isSafeInteger(_)?_:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let o=Date.parse(t);return Number.isFinite(o)?Math.max(0,Math.ceil((o-E)/1e3)):void 0}var R=r.object({retryable:r.boolean(),recovery:s,reason:c.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),T=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...R.partial().shape})}),S=r.object({error:T.shape.error.extend({requestId:r.uuid().optional()})}),U=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...R.shape});function l(e,E,t={}){let o=i(e,E),_=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??o.recovery,a=o.retryable&&t.retryable!==!1&&_!=="recover_operation",n=a?O(t.retryAfter??null):void 0;return{...o,retryable:a,recovery:_,...n===void 0?{}:{retryAfterSeconds:n},...t.reason?{reason:t.reason}:{}}}export{I as a,s as b,c,D as d,T as e,l as f};
1
+ import{b as r}from"./chunk-NOOIJXRN.js";var I=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),L=r.enum([...I.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),C=r.enum([...I.options,"stale_revision"]),s=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),c=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),A={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var N={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function i(e,E){if(e==="CONFLICT"&&E===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&E===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(N,e)){let o=N[e];return{retryable:o==="retry_same_request",recovery:o}}let t=I.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:A[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function D(e,E){let t=I.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(E):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(E):e==="INVALID_REQUEST"?[400,405,415,422].includes(E):e==="NOT_CONFIGURED"?[501,503].includes(E):A[t.data].status===E;let o={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(o,e)&&(o[e]?.includes(E)??!1)}function O(e,E=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let _=Number(t);return Number.isSafeInteger(_)?_:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let o=Date.parse(t);return Number.isFinite(o)?Math.max(0,Math.ceil((o-E)/1e3)):void 0}var R=r.object({retryable:r.boolean(),recovery:s,reason:c.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),T=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...R.partial().shape})}),S=r.object({error:T.shape.error.extend({requestId:r.uuid().optional()})}),U=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...R.shape});function l(e,E,t={}){let o=i(e,E),_=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??o.recovery,a=o.retryable&&t.retryable!==!1&&_!=="recover_operation",n=a?O(t.retryAfter??null):void 0;return{...o,retryable:a,recovery:_,...n===void 0?{}:{retryAfterSeconds:n},...t.reason?{reason:t.reason}:{}}}export{I as a,s as b,c,D as d,T as e,l as f};
@@ -1 +1 @@
1
- import{d as x}from"./chunk-AOGDCT4T.js";import{a as l}from"./chunk-U7NX5ET2.js";function F(e,t,n,s,i){let{presentation:o,screen:a}=n,b=Object.entries(n.buttons??{}).filter(([,p])=>p.type==="close").map(([p])=>p),c=e.ownerDocument.defaultView,u=a.pages.find(p=>p.id===a.initialPageId)?.theme??a.theme,w={background:a.theme.background,text:a.theme.text};t.inert=!0,t.style.cssText="width:100%;min-width:0;overflow:hidden;visibility:hidden";let f=!1,d,m=p=>{c&&d?.resizeViewport(Math.max(1,c.innerHeight-(p==="modal"?32:0)),c.innerWidth)},r=o.type==="inline"?void 0:x(e,{...a,presentation:o,theme:w},m);return r?.latch(),c&&r?.responsive&&r.setContentHeight(c.innerHeight-(r.type==="modal"?32:0)),e.style.background=u.background,e.style.color=u.text,r?(o.type==="fullscreen"||o.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",import("./screen-renderer-YIIT742O.js").then(({mountScreenPreview:p})=>{f||(d=p(t,{mode:"live",skeleton:!0,closeActions:b,hostPresentation:()=>r?.type??o.type,reportContentHeight:r?.responsive,onResize(k){if(!c||!r?.responsive)return;let $=r.type==="modal"?32:0,g=Math.min(k,Math.max(0,c.innerHeight-$));t.style.height=`${g}px`,r.setContentHeight(g)},onRendered:i,onError(){d&&(d.destroy(),d=void 0)}}),r?.responsive&&m(r.type),d.update({...a,presentation:o},s,{serverInput:{bindings:[],answers:{}}}))}).catch(()=>{d?.destroy(),d=void 0}),()=>{f=!0,d?.destroy(),r?.destroy()}}var v={none:0,sm:4,md:8,lg:14,full:9999},T={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},P={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function y(e){let[t,n,s]=[1,3,5].map(i=>{let o=Number.parseInt(e.slice(i,i+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*s}function S(e,t=!0){let n=y(e.primary),s=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",i=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,o=`${v[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${o};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;${t?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${T[e.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",pinned:`position:sticky;bottom:0;z-index:1;box-sizing:border-box;padding-top:12px;background:${e.background};border-top:1px solid ${i}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${i}`,message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",status:"margin:0;font-size:13px;opacity:.72",alert:`flex:1 1 200px;min-width:0;margin:0;font-size:13px;font-weight:500;color:${y(e.background)>.4?"#B42318":"#FDA29B"}`,panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${i};border-radius:${o}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${a};background:${e.primary};color:${s}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${i}`,link:`${a};background:transparent;color:${e.text};opacity:.72;font-weight:500`,stage:"display:flex;justify-content:center;padding:24px 20px",history:"display:flex;flex-direction:column;gap:12px;padding:20px",historyTitle:"margin:0;padding-inline-end:40px;font-size:17px;font-weight:600;line-height:1.3",historyNote:"margin:0;font-size:13px;opacity:.72",historyPages:"display:flex;gap:8px;flex-wrap:wrap;margin:0;padding:0;list-style:none",historyPage:`border:1px solid ${i};border-radius:${o};overflow:hidden`,historyRecords:`display:flex;flex-direction:column;gap:4px;margin:0;padding:12px 0 0;list-style:none;font-size:13px;border-top:1px solid ${i}`,focus:e.text}}function H(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function L(e,t){e.addEventListener("focus",()=>{let n=!0;try{n=e.matches(":focus-visible")}catch{}n&&(e.style.outline=`2px solid ${t()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var h={en:{network:"Connection problem. Check your network and try again.",timeout:"This is taking longer than expected. Try again.",other:"Something went wrong. Try again.",required:"Answer the questions marked * to continue.",permission:"This isn\u2019t available right now. Contact the merchant for help."},zh:{network:"\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",timeout:"\u54CD\u5E94\u65F6\u95F4\u8FC7\u957F\uFF0C\u8BF7\u91CD\u8BD5\u3002",other:"\u51FA\u4E86\u70B9\u95EE\u9898\uFF0C\u8BF7\u91CD\u8BD5\u3002",required:"\u8BF7\u5148\u56DE\u7B54\u5E26 * \u7684\u95EE\u9898\u3002",permission:"\u5F53\u524D\u65E0\u6CD5\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u3002"}};function O(e,t){let n=h[t?"zh":"en"],s=e instanceof l?e.code:void 0;return s==="NETWORK_ERROR"?n.network:s==="TIMEOUT"?n.timeout:z(e)?n.permission:n.other}function z(e){return e instanceof l&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function q(e,t){if(!(e instanceof l)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let n=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return n!==void 0&&t.some(s=>s.variable===n)}function C(e){return h[e?"zh":"en"].required}function I(e,t){return e.filter(({variable:n,required:s})=>{let i=t[n];return s&&(i==null||i===""||Array.isArray(i)&&i.length===0)})}var D={zh:{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"}};function _(e,t){return D[t?"zh":"en"][e]}export{F as a,P as b,S as c,H as d,L as e,O as f,z as g,q as h,C as i,I as j,_ as k};
1
+ import{d as x}from"./chunk-KIPUBMU3.js";import{a as l}from"./chunk-TPXRO63H.js";function F(e,t,n,s,i){let{presentation:o,screen:a}=n,b=Object.entries(n.buttons??{}).filter(([,p])=>p.type==="close").map(([p])=>p),c=e.ownerDocument.defaultView,u=a.pages.find(p=>p.id===a.initialPageId)?.theme??a.theme,w={background:a.theme.background,text:a.theme.text};t.inert=!0,t.style.cssText="width:100%;min-width:0;overflow:hidden;visibility:hidden";let f=!1,d,m=p=>{c&&d?.resizeViewport(Math.max(1,c.innerHeight-(p==="modal"?32:0)),c.innerWidth)},r=o.type==="inline"?void 0:x(e,{...a,presentation:o,theme:w},m);return r?.latch(),c&&r?.responsive&&r.setContentHeight(c.innerHeight-(r.type==="modal"?32:0)),e.style.background=u.background,e.style.color=u.text,r?(o.type==="fullscreen"||o.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",import("./screen-renderer-5SJCTMJH.js").then(({mountScreenPreview:p})=>{f||(d=p(t,{mode:"live",skeleton:!0,closeActions:b,hostPresentation:()=>r?.type??o.type,reportContentHeight:r?.responsive,onResize(k){if(!c||!r?.responsive)return;let $=r.type==="modal"?32:0,g=Math.min(k,Math.max(0,c.innerHeight-$));t.style.height=`${g}px`,r.setContentHeight(g)},onRendered:i,onError(){d&&(d.destroy(),d=void 0)}}),r?.responsive&&m(r.type),d.update({...a,presentation:o},s,{serverInput:{bindings:[],answers:{}}}))}).catch(()=>{d?.destroy(),d=void 0}),()=>{f=!0,d?.destroy(),r?.destroy()}}var v={none:0,sm:4,md:8,lg:14,full:9999},T={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},P={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function y(e){let[t,n,s]=[1,3,5].map(i=>{let o=Number.parseInt(e.slice(i,i+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*s}function S(e,t=!0){let n=y(e.primary),s=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",i=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,o=`${v[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${o};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;${t?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${T[e.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",pinned:`position:sticky;bottom:0;z-index:1;box-sizing:border-box;padding-top:12px;background:${e.background};border-top:1px solid ${i}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${i}`,message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",status:"margin:0;font-size:13px;opacity:.72",alert:`flex:1 1 200px;min-width:0;margin:0;font-size:13px;font-weight:500;color:${y(e.background)>.4?"#B42318":"#FDA29B"}`,panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${i};border-radius:${o}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${a};background:${e.primary};color:${s}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${i}`,link:`${a};background:transparent;color:${e.text};opacity:.72;font-weight:500`,stage:"display:flex;justify-content:center;padding:24px 20px",history:"display:flex;flex-direction:column;gap:12px;padding:20px",historyTitle:"margin:0;padding-inline-end:40px;font-size:17px;font-weight:600;line-height:1.3",historyNote:"margin:0;font-size:13px;opacity:.72",historyPages:"display:flex;gap:8px;flex-wrap:wrap;margin:0;padding:0;list-style:none",historyPage:`border:1px solid ${i};border-radius:${o};overflow:hidden`,historyRecords:`display:flex;flex-direction:column;gap:4px;margin:0;padding:12px 0 0;list-style:none;font-size:13px;border-top:1px solid ${i}`,focus:e.text}}function H(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function L(e,t){e.addEventListener("focus",()=>{let n=!0;try{n=e.matches(":focus-visible")}catch{}n&&(e.style.outline=`2px solid ${t()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var h={en:{network:"Connection problem. Check your network and try again.",timeout:"This is taking longer than expected. Try again.",other:"Something went wrong. Try again.",required:"Answer the questions marked * to continue.",permission:"This isn\u2019t available right now. Contact the merchant for help."},zh:{network:"\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",timeout:"\u54CD\u5E94\u65F6\u95F4\u8FC7\u957F\uFF0C\u8BF7\u91CD\u8BD5\u3002",other:"\u51FA\u4E86\u70B9\u95EE\u9898\uFF0C\u8BF7\u91CD\u8BD5\u3002",required:"\u8BF7\u5148\u56DE\u7B54\u5E26 * \u7684\u95EE\u9898\u3002",permission:"\u5F53\u524D\u65E0\u6CD5\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u3002"}};function O(e,t){let n=h[t?"zh":"en"],s=e instanceof l?e.code:void 0;return s==="NETWORK_ERROR"?n.network:s==="TIMEOUT"?n.timeout:z(e)?n.permission:n.other}function z(e){return e instanceof l&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function q(e,t){if(!(e instanceof l)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let n=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return n!==void 0&&t.some(s=>s.variable===n)}function C(e){return h[e?"zh":"en"].required}function I(e,t){return e.filter(({variable:n,required:s})=>{let i=t[n];return s&&(i==null||i===""||Array.isArray(i)&&i.length===0)})}var D={zh:{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"}};function _(e,t){return D[t?"zh":"en"][e]}export{F as a,P as b,S as c,H as d,L as e,O as f,z as g,q as h,C as i,I as j,_ as k};
@@ -0,0 +1 @@
1
+ import{b as e}from"./chunk-NOOIJXRN.js";var c=e.enum(["replace","stack_native"]);export{c as a};
@@ -1 +1 @@
1
- import{a as C,c as ie,j as Ie}from"./chunk-T2KWLYCW.js";import{c as J,d as k,f as T,g as $}from"./chunk-HEHLFHW7.js";import{b as e}from"./chunk-CR2XJ2CX.js";var ke=e.number().int().min(0).max(1e8),ae=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:ke,flatAmountMinor:ke.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 oe(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?ae.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,a=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let o of i.tiers){let s=o.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(o.unitAmountMinor)+BigInt(o.flatAmountMinor??0);break}}else n>a&&(r+=BigInt(Math.min(n,s)-a)*BigInt(o.unitAmountMinor));a=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function we(t){return oe({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ot=k.refine(t=>/[1-9]/.test(t)),_e=e.strictObject({units:ot,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:ae.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&&oe({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 je(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 ze(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=je(t)+je(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let a=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(a?"."+a:"")}var se=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:_e});var st=["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"],X=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(),Ae=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(),Mn=e.object({paywall:Ie.optional(),nodes:e.record(e.string(),e.object({base:Ae,picker:e.string().optional(),byPlan:e.record(e.string(),Ae).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(se).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 ve(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function ce(t){let n=ve(t).filter(r=>!st.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("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(n)]}function Qn(t,n,i={}){let r=t?.nodes[n];if(!r)return;let a=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof a=="string"?r.byPlan?.[a]??r.base:r.base}var ct=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],Oe=e.enum(ct),Pe=e.object({source:Oe,layout:e.enum(["full","compact"]),resourceKey:T.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:"\u8FD9\u4E2A\u6570\u636E\u6E90\u4E0D\u80FD\u7ED1\u5B9A\u79EF\u5206\u8D44\u6E90\u3002"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u4F59\u989D\u53EF\u4EE5\u5C55\u5F00\u6765\u6E90\u3002"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u3001\u5957\u9910\u4E0E\u4F1A\u5458\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u4EA4\u6613\u3002"})}),S=e.string().max(2e3),Ne=e.object({id:e.string().max(100),label:S,detail:e.array(S).max(12),value:S.optional(),status:S.optional(),facts:e.array(e.object({label:S,value:S}).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:S})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:S}).strict()).max(3).optional()}).strict(),ut=e.object({key:T,name:S,spendable:S,reserved:S,available:S,expiry:S.nullable(),sources:e.array(Ne).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),lt=e.object({source:Oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:S.optional(),resources:e.array(ut).max(500),rows:e.array(Ne).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:S,note:S,facts:e.array(e.object({label:S,value:S}).strict()).max(100)}).strict().optional(),membershipResult:S.optional()}).strict(),Kn=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),lt)}).strict(),Hn=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();var pt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Xn=e.discriminatedUnion("type",[e.object({type:e.literal("fixed"),productVersionId:e.string().min(1).max(200)}).strict(),e.object({type:e.literal("picker"),pickerId:pt,allowedProductVersionIds:e.array(e.string().min(1).max(200)).min(1).max(20)}).strict().refine(t=>new Set(t.allowedProductVersionIds).size===t.allowedProductVersionIds.length,"Product choices must be unique")]),mt=e.strictObject({min:e.number().finite().min(1).max(1800),max:e.number().finite().min(1).max(1800),viewport:e.number().finite().min(1).max(100)}).refine(t=>t.min<=t.max,"Desktop width range is reversed"),$e={desktopWidth:mt.optional(),mobile:e.enum(["sheet","fullscreen"]).optional(),backdrop:e.enum(["none","scrim","dim","strong-dim","blur"]).optional()},Ce=e.discriminatedUnion("type",[e.strictObject({type:e.literal("modal"),position:e.enum(["center","top","bottom"]).optional(),size:e.enum(["sm","md","lg"]),...$e}),e.strictObject({type:e.literal("sheet"),size:e.enum(["sm","md","lg"]),...$e}),e.strictObject({type:e.literal("fullscreen")}),e.strictObject({type:e.literal("inline")})]),dt={sm:360,md:420,lg:560};function De(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function Ee(t){let n={};function i(r){if(De(r)){let a=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let c=s.type==="stack"?s.bind?.plan:void 0;c&&!a.ids.includes(c)&&a.ids.push(c)}let o=r.children[r.interaction.defaultIndex];!a.defaultId&&o?.type==="stack"&&(a.defaultId=o.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function Re(t,n,i){let r={};function a(l){if(l.hidden)return;if(l.type==="plan_picker"){let b=i.pickers[l.id];r[l.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(l.type!=="stack")return;let d=l.children.filter(b=>!b.hidden),u=l.interaction;if(De(l)){let b=r[l.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},h=i.pickers[l.interaction.pickerId]?.options??[];for(let p of d){let f=p.type==="stack"?p.bind?.plan:void 0;f&&h.includes(f)&&!b.ids.includes(f)&&b.ids.push(f),f&&p.id===n[l.id]&&b.remembered.push(f)}let m=l.children[l.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(u?.type==="tabs"){let b=d.find(h=>h.id===n[l.id])??l.children[u.defaultIndex];b&&a(b)}else if(u?.type==="toggle"){let b=typeof n[l.id]=="boolean"?n[l.id]:u.defaultEnabled,h=l.children[b?0:1];h&&a(h)}else d.forEach(a)}let o=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(l=>l.id===o);s&&a(s.root);let c={};for(let[l,d]of Object.entries(r)){let u=n[l],b=d.remembered[0]??(d.ids.includes(i.pickers[l]?.selected??"")?i.pickers[l]?.selected:d.defaults[0]);c[l]=typeof u=="string"?d.ids.includes(u)?u:"":b&&d.ids.includes(b)?b:""}for(let l of Object.keys(Ee(t)))c[l]??="";return c}var Ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Le=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 Te(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function ir(t){let n=ce(t).map(i=>`\u672A\u77E5\u53D8\u91CF\uFF1A${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 a=t.indexOf("-->",i+4);i=a<0?t.length:a+2}else{let a="";for(i++;i<t.length;i++){let o=t[i];if(a)o===a&&(a="");else if(o==='"'||o==="'")a=o;else if(o===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("\u53D8\u91CF\u53EA\u80FD\u653E\u5728 HTML \u6587\u5B57\u4E2D\uFF0C\u4E0D\u80FD\u653E\u5165\u6807\u7B7E\u3001\u5C5E\u6027\u6216\u6CE8\u91CA")}return[...new Set(n)]}var x={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},Ve=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),I=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!Ve.has(t),"Reserved UI identifier"),ue=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),ft=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(ue).min(1).max(x.enumValues),default:ue}),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 Y(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 gt=ft.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"}),Y(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),bt=["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 yt(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 R=e.lazy(()=>e.union([ue,e.strictObject({ref:I}),e.strictObject({op:e.enum(bt),args:e.array(R).max(x.expressionNodes)}).superRefine((t,n)=>{yt(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function z(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function E(t,n,i){if(!t||typeof t!="object")return!0;if(!z(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(Ve.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let a=Object.getOwnPropertyDescriptor(t,r);if(a&&!Object.hasOwn(a,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function F(t,n,i,r){let a=[{value:t,depth:1,path:i}];for(;a.length;){let o=a.pop();if(++r.nodes>x.expressionNodes||o.depth>x.depth){n.addIssue({code:"custom",path:o.path,message:"UI expression budget exceeded"});return}if(!E(o.value,n,o.path))return;if(z(o.value)&&Array.isArray(o.value.args)){if(o.value.args.length>x.expressionNodes){n.addIssue({code:"custom",path:[...o.path,"args"],message:"UI expression budget exceeded"});return}for(let s=o.value.args.length-1;s>=0;s--)a.push({value:o.value.args[s],depth:o.depth+1,path:[...o.path,"args",s]})}}}var sr=e.unknown().superRefine((t,n)=>{F(t,n,[],{nodes:0})}).pipe(R),le=e.record(I,R).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=x.state,"UI assignments need 1\u201332 state keys"),ht=e.strictObject({target:I,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:R,className:I.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"})}),xt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:I,state:I}),e.strictObject({type:e.literal("input"),target:I,state:I,set:le.optional()}),e.strictObject({type:e.literal("action"),target:I,set:le}),e.strictObject({type:e.literal("carousel"),target:I,state:I,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:I.optional(),nextTarget:I.optional(),inactiveTargets:e.array(I).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),St=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:le}),It=e.strictObject({type:e.literal("mosaic_waves"),target:I,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:R.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()}),kt=e.strictObject({type:e.literal("number_counter"),target:I,value:R,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),wt=e.strictObject({state:e.record(I,gt).refine(t=>Object.keys(t).length<=x.state,"Too many UI state keys").optional(),derived:e.record(I,R).refine(t=>Object.keys(t).length<=x.derived,"Too many UI derived keys").optional(),bindings:e.array(ht).max(x.bindings).optional(),controls:e.array(xt).max(x.controls).optional(),timers:e.array(St).max(x.timers).optional(),effects:e.array(e.discriminatedUnion("type",[It,kt])).max(x.effects).optional(),clock:e.boolean().optional()});function jt(t,n){if(!E(t,n,[])||!z(t))return;for(let[r,a]of[["state",x.state],["derived",x.derived]]){let o=t[r];if(!E(o,n,[r]))return;if(z(o)&&Object.keys(o).length>a){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,a]of[["bindings",x.bindings],["controls",x.controls],["timers",x.timers],["effects",x.effects]])if(Array.isArray(t[r])&&t[r].length>a){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,a]of t.effects.entries())if(!E(a,n,["effects",r]))return}if(z(t.state))for(let[r,a]of Object.entries(t.state)){if(!E(a,n,["state",r]))return;if(z(a)&&Array.isArray(a.values)&&a.values.length>x.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(z(t.derived))for(let[r,a]of Object.entries(t.derived))F(a,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let a=t[r];if(Array.isArray(a)){for(let[o,s]of a.entries())if(!(!E(s,n,[r,o])||!z(s))){if(r==="bindings")F(s.expression,n,[r,o,"expression"],i);else if(E(s.set,n,[r,o,"set"])&&z(s.set)){if(Object.keys(s.set).length>x.state){n.addIssue({code:"custom",path:[r,o,"set"],message:"Too many UI assignments"});return}for(let[c,l]of Object.entries(s.set))F(l,n,[r,o,"set",c],i)}if(i.nodes>x.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,a]of t.effects.entries())z(a)&&a.type==="number_counter"?F(a.value,n,["effects",r,"value"],i):z(a)&&a.enabled!==void 0&&F(a.enabled,n,["effects",r,"enabled"],i)}function Fe(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 qe=e.unknown().superRefine(jt).pipe(wt).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},a=new Set([...Object.keys(i),...Object.keys(r)]),o=(m,p)=>{for(let f of Fe(m))a.has(f)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${f}`})};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"}),o(p,["derived",m]);let s=new Set,c=new Set,l=m=>{if(s.has(m))return!1;if(c.has(m))return!0;s.add(m);for(let p of Fe(r[m]))if(Object.hasOwn(r,p)&&!l(p))return!1;return s.delete(m),c.add(m),!0};for(let m of Object.keys(r))if(!l(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())o(p.expression,["bindings",m,"expression"]);let d=new Set;for(let[m,p]of(t.effects??[]).entries())d.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),d.add(p.target),p.type==="number_counter"?(o(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&&o(p.enabled,["effects",m,"enabled"]);let u=(m,p)=>{for(let[f,w]of Object.entries(m))Object.hasOwn(i,f)||n.addIssue({code:"custom",path:[...p,f],message:"UI assignments can only update declared state"}),o(w,[...p,f])},b=new Set,h=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 f of p.inactiveTargets??[])(f===p.target||h.has(f))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),h.add(f);if(p.type==="carousel")for(let f of["previousTarget","nextTarget"]){let w=p[f];w!==void 0&&((w===p.target||b.has(w)||(t.controls??[]).some(M=>M.target===w))&&n.addIssue({code:"custom",path:["controls",m,f],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(w))}if(p.type!=="action"){let f=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!f||p.type==="input"&&f.type==="enum"&&f.values.some(w=>typeof w!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(f?.type!=="number"||!Number.isInteger(f.min)||f.min<0||!Number.isInteger(f.max)||f.step!==1||p.initialIndex!==void 0&&!Y(f,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&f?.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&&u(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())u(p.set,["timers",m,"set"])});var Qe=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,V=e.string().max(16).regex(Qe,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"\u6301\u4E45\u5316\u8BED\u8A00\u4EE3\u7801\u5FC5\u987B\u4F7F\u7528\u89C4\u8303\u5199\u6CD5");function pe(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:a}=new Intl.Locale(n),o=[i,r,a].filter(Boolean).join("-");return Qe.test(o)?o:null}catch{return null}}var _t=new Set(["TW","HK","MO"]);function Me(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let a=i?.length===4?i:void 0,o=i?.length===4?r:i;return a?`zh-${a}`:o&&_t.has(o)?"zh-Hant":"zh-Hans"}function Be(t,n,i){let r=n.map(a=>({code:V.parse(a),normalized:a}));for(let a of t){let o=pe(a);if(!o)continue;let s=r.find(u=>u.normalized===o);if(s)return s.code;let c=Me(o),l=r.filter(u=>Me(u.normalized)===c),d=l.find(u=>!u.normalized.includes("-")||u.normalized===c)??l[0];if(d)return d.code}return i}var zt=4,v={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},B=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),y=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),At=e.enum(["none","xs","sm","md","lg","xl"]),vt=e.enum(["none","sm","md","lg","full"]),me=e.string().regex(/^#[0-9a-fA-F]{6}$/),fe=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),de=e.union([fe,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}$/)]),Ze=e.object({primary:me,background:me,text:me,radius:vt,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:fe,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(),Z=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),g=(t,n)=>e.number().int().min(t).max(n),Ge=e.union([e.enum(["fit","fill"]),g(1,1200)]),Ot=e.object({top:g(0,200),right:g(0,200),bottom:g(0,200),left:g(0,200)}).strict(),Pt=e.object({top:g(-100,200),right:g(-100,200),bottom:g(-100,200),left:g(-100,200)}).strict(),Ke=e.object({x:g(0,100),y:g(0,100)}).strict(),Nt=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:Z}).strict(),e.object({type:e.literal("linear"),angle:g(0,360),stops:e.array(e.object({color:Z,at:g(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:de,fit:e.enum(["cover","contain"]),position:Ke.optional()}).strict()]),$t=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([g(0,200),e.object({topLeft:g(0,200),topRight:g(0,200),bottomRight:g(0,200),bottomLeft:g(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ct=e.object({width:g(0,12),color:Z,style:e.enum(["solid","dashed"])}).strict(),Dt=e.object({x:g(-40,40),y:g(-40,40),blur:g(0,80),spread:g(-20,40),color:Z}).strict(),Et=e.object({font:e.enum(["system","serif","rounded","mono"]),size:g(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:Z,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),U=e.object({width:Ge,height:Ge,padding:Ot,margin:Pt,gap:g(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Nt,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:$t,border:Ct,shadow:Dt,text:Et}).strict().partial(),j={id:B,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:U.optional(),fallback:y.optional()},Rt=e.object({...j,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:y,variant:e.enum(["title","heading","body","caption"])}).strict(),Ut=e.object({...j,type:e.literal("image"),src:de,localizedSrc:e.record(V,de).optional(),alt:y,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ke.optional()}).strict(),Lt=e.object({...j,type:e.literal("button"),label:y,variant:e.enum(["primary","secondary","link"]),action:y,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:X.optional()}).strict(),Tt=e.object({...j,type:e.literal("divider")}).strict(),Ft=e.object({...j,type:e.literal("customer_data"),title:y,data:Pe}).strict(),Vt=e.object({...j,type:e.literal("spacer"),size:At}).strict(),qt=e.object({...j,type:e.literal("custom_html"),html:e.record(V,e.string().max(v.customHtml)),css:e.string().max(v.customCss),ui:qe.optional()}).strict(),Mt=e.object({...j,type:e.literal("price"),fallback:y,parts:e.object({current:U.optional(),original:U.optional(),period:U.optional()}).strict().optional()}).strict(),Qt=e.object({...j,type:e.literal("coupon_code"),label:y,fallback:y}).strict(),Bt=e.object({...j,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:y,fallback:y}).strict().refine(t=>t.source!=="fixed"||!!t.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),Zt=e.object({...j,type:e.literal("plan_picker"),label:y,fallback:y,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:Le.safeExtend({monthLabel:y,yearLabel:y,unavailableLabel:y}).optional(),states:e.object({selected:U.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!Te(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),Gt=e.object({...j,type:e.literal("quantity_picker"),bind:X.optional(),label:y,fallback:y,internalFeatureId:e.uuid(),minimumQuantity:g(0,1e4),maximumQuantity:g(0,1e4),defaultQuantity:g(0,1e4),step:g(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"),Kt=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:y,keyboard:e.enum(["text","email","tel","url"]),maxLength:g(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:y,min:g(0,50),max:g(1,50)}).strict(),e.object({type:e.literal("select"),label:y,defaultIndex:g(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:B.optional(),selectedStyle:U.optional()}).strict(),e.object({type:e.literal("tabs"),label:y,defaultIndex:g(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:y,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:y}).strict()]),A={...j,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:g(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:Kt.optional(),states:e.object({selected:U.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:y.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:X.optional()},He=e.lazy(()=>e.object({...j,type:A.type,direction:A.direction,align:A.align,justify:A.justify,children:e.array(Ht).max(v.children),productSlot:A.productSlot,interaction:A.interaction,states:A.states,purpose:A.purpose,purchaseAction:A.purchaseAction,buttonVariant:A.buttonVariant,bind:A.bind}).strict()),Ht=e.lazy(()=>e.union([He,Rt,Ut,Lt,Tt,Vt,qt,Mt,Qt,Bt,Zt,Gt,Ft])),Wt=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),Q={id:y,event:y,properties:e.record(y,Wt).refine(t=>Object.keys(t).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},Jt=e.discriminatedUnion("type",[e.object({...Q,type:e.literal("navigate"),close:e.literal(!1),pageId:B}).strict(),e.object({...Q,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...Q,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...Q,type:e.literal("open_url"),close:e.boolean(),url:fe}).strict(),e.object({...Q,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),Xt=e.object({defaultLocale:V,locales:e.record(V,e.record(y,e.string().max(v.stringLength)))}).strict(),Yt=e.enum(["popup","paywall","onboarding","page","banner"]);var en=e.object({kind:e.literal("screen"),schemaVersion:e.literal(zt),name:e.string().trim().min(1).max(80),surface:Yt,initialPageId:B.optional(),presentation:Ce,theme:Ze,pages:e.array(e.object({id:B,name:e.string().trim().min(1).max(60),root:He,theme:Ze.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(v.pages),strings:Xt,actions:e.array(Jt).max(v.actions)}).strict();function P(t,n){for(let i of t.pages)ge(i.root,n)}var xr=en.superRefine((t,n)=>{let i=v;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(u=>u.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let u of t.actions)u.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===u.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`\u9875\u9762\u6700\u591A ${i.pages} \u4E2A`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`\u52A8\u4F5C\u6700\u591A ${i.actions} \u4E2A`});let r=u=>n.addIssue({code:"custom",message:u}),a=Object.keys(t.strings.locales);a.includes(t.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),a.length>v.locales&&r(`\u6700\u591A ${v.locales} \u79CD\u8BED\u8A00`);let o=new Set;for(let u of t.actions)o.has(u.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${u.id}`),o.add(u.id);let s=new Set;for(let u of t.pages)["next","back"].includes(u.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${u.id}`),s.has(u.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${u.id}`),s.add(u.id);let c=new Set,l=0,d=!1;P(t,(u,b)=>{if(l++,b>v.depth&&(d=!0),c.has(u.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${u.id}`),c.add(u.id),u.type==="button"&&!o.has(u.action)&&r(`\u6309\u94AE ${u.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${u.action}`),u.type==="custom_html")for(let h of Object.keys(u.html))a.includes(h)||r(`\u81EA\u5B9A\u4E49 HTML ${u.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${h}`);if(u.type==="image")for(let h of Object.keys(u.localizedSrc??{}))a.includes(h)||r(`\u56FE\u7247 ${u.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${h}`)}),l>i.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${i.nodes} \u4E2A`),d&&r(`\u5C42\u7EA7\u6700\u591A ${v.depth} \u5C42`)});function ge(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let a of t.children)ge(a,n,i+1,t)}function We(t){let n=[],i=new Set;return P(t,r=>{let a=(o,s,c)=>{i.has(o)||(i.add(o),n.push({key:o,nodeId:r.id,nodeType:r.type,field:s,required:c}))};r.type==="stack"&&r.interaction&&a(r.interaction.label,"label",!0),r.fallback&&a(r.fallback,"text",!0),r.type==="text"&&a(r.text,"text",!0),r.type==="customer_data"&&a(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&a(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(a(r.grouping.monthLabel,"label",!0),a(r.grouping.yearLabel,"label",!0),a(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&a(r.expired,"text",!0),r.type==="button"&&a(r.label,"label",!0),r.type==="image"&&(a(`image:${r.id}`,"src",!1),a(r.alt,"alt",!1)),r.type==="custom_html"&&a(`html:${r.id}`,"html",!0)}),n}function tn(t,n,i){if(n.field==="html"){let r;return P(t,a=>{a.id===n.nodeId&&a.type==="custom_html"&&(r=a.html[i])}),r}if(n.field==="src"){let r=be(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 nn(t){let n=We(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,a)=>r===t.strings.defaultLocale?-1:a===t.strings.defaultLocale?1:0).map(r=>{let a=n.filter(o=>!tn(t,o,r)?.trim()).map(o=>o.key);return{locale:r,total:n.length,filled:n.length-a.length,missing:a,complete:a.length===0}})}function rn(t){return nn(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function Sr(t,n){return Be(n,rn(t),t.strings.defaultLocale)}function Ir(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},a={};for(let s of We(t)){if(s.field==="html"||s.field==="src")continue;let c=i[s.key]?.trim()?i[s.key]:r[s.key];c!==void 0&&(a[s.key]=c)}let o=s=>{if(s.type==="stack")return{...s,children:s.children.map(o)};if(s.type==="custom_html"){let c=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:c===void 0?{}:{[n]:c}}}if(s.type==="image"){let{localizedSrc:c,...l}=s;return{...l,src:c?.[n]??c?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:o(s.root)})),strings:{defaultLocale:n,locales:{[n]:a}}}}function an(t,n){let i=null;return ge(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function be(t,n){for(let i of t.pages){let r=an(i.root,n);if(r)return r}return null}function kr(t){let n=pe(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function wr(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let a=n;if(P(t,o=>{if(o.type==="quantity_picker"){let c=a[o.id];typeof c=="number"&&Number.isSafeInteger(c)&&c>=o.minimumQuantity&&c<=o.maximumQuantity&&(c-o.minimumQuantity)%o.step===0&&(r[o.id]=c);return}if(o.type==="plan_picker"){let c=a[o.id];typeof c=="string"&&(r[o.id]=i?.pickers[o.id]?.options.includes(c)?c:"");return}if(o.type==="custom_html"&&o.ui)for(let[c,l]of Object.entries(o.ui.state??{})){let d=`${o.id}.${c}`,u=a[d];u!==null&&Y(l,u)&&(r[d]=u)}if(o.type!=="stack"||!o.interaction)return;let s=Object.hasOwn(a,o.id)?a[o.id]:void 0;["select","tabs"].includes(o.interaction.type)&&typeof s=="string"&&o.children.some(c=>c.id===s)&&(r[o.id]=s),o.interaction.type==="toggle"&&typeof s=="boolean"&&(r[o.id]=s)}),t.surface==="paywall"&&typeof a.__page=="string"&&t.pages.some(o=>o.id===a.__page)&&(r.__page=a.__page),i){let o={...r};for(let[s,c]of Object.entries(a))(typeof c=="string"||typeof c=="boolean")&&(o[s]=c);Object.assign(r,Re(t,o,i))}return r}var D=e.json().superRefine((t,n)=>{let i=0;function r(a,o){if(++i>1e4||o>20){n.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof a=="string"&&(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a))&&n.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(a))a.forEach(s=>r(s,o+1));else if(a&&typeof a=="object")for(let[s,c]of Object.entries(a))(s.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(s)||["__proto__","prototype","constructor"].includes(s))&&n.addIssue({code:"custom",message:"Reserved JSON property"}),r(c,o+1)}r(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&n.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),he=e.record(e.string().min(1).max(128),D).superRefine((t,n)=>{(!D.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(i=>Object.hasOwn(t,i)))&&n.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),on=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),ee=he.superRefine((t,n)=>{function i(r){if(Array.isArray(r))r.forEach(i);else if(r&&typeof r=="object")for(let[a,o]of Object.entries(r)){if(a==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(o).success&&n.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!a.startsWith("$")&&a.split(".").some(s=>["__proto__","prototype","constructor"].includes(s))&&n.addIssue({code:"custom",message:"Reserved attribute path"}),a.startsWith("$")&&!on.has(a)&&n.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${a}`}),["$regex","$regexi"].includes(a)&&typeof o=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(o)||[...o.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(s=>Number(s[1])>255||Number(s[2]||0)>255)||a==="$regexi"&&/[^\x00-\x7f]/.test(o.replace(/\\u([0-9a-f]{4})/gi,(s,c)=>String.fromCharCode(Number.parseInt(c,16)))))&&n.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(o)}catch{n.addIssue({code:"custom",message:"Invalid regular expression"})}}i(o)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&n.addIssue({code:"custom",message:"Obsolete condition protocol"}),i(t)}),sn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:ee}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function cn(t){let n=new Set;function i(r){if(Array.isArray(r))r.forEach(i);else if(r&&typeof r=="object")for(let[a,o]of Object.entries(r))a==="$savedGroup"&&o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.id=="string"?n.add(o.id):["$inGroup","$notInGroup"].includes(a)&&typeof o=="string"?n.add(o):["$eq","$ne","$in","$nin","$ini","$nini"].includes(a)||i(o)}return i(t),[...n]}var un=e.record(e.uuid(),sn).superRefine((t,n)=>{let i=new Set,r=new Set;function a(o){if(i.has(o)){n.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(r.has(o))return;let s=t[o];if(!s){n.addIssue({code:"custom",message:"Missing saved group dependency"});return}i.add(o),s.type==="condition"&&cn(s.condition).forEach(a),i.delete(o),r.add(o)}Object.keys(t).forEach(a)}),xe=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,n])=>t<=n),Je=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(xe).min(1).max(100)}),ln=e.strictObject({id:e.string().min(1).max(128),condition:ee,gate:e.boolean().optional()}),ye={id:e.string().max(128).optional(),condition:ee.optional(),parentConditions:e.array(ln).max(50).optional(),filters:e.array(Je).max(20).optional()},pn=e.union([e.strictObject({...ye}),e.strictObject({...ye,force:D,coverage:e.number().min(0).max(1).optional(),range:xe.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...ye,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),D),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),mn=e.strictObject({defaultValue:D,rules:e.array(pn).max(100)}),$r=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),mn).superRefine((t,n)=>{Object.keys(t).length>100&&n.addIssue({code:"custom",message:"Too many Features"});let i=new Set,r=new Set;function a(o){if(i.has(o)){n.addIssue({code:"custom",message:`Cyclic Feature dependency: ${o}`});return}if(r.has(o))return;let s=t[o];if(!s){n.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${o}`});return}i.add(o);for(let c of s.rules)for(let l of c.parentConditions??[])a(l.id);i.delete(o),r.add(o)}Object.keys(t).forEach(a)}),dn=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((n,i)=>n+i,0)-1)<=.01),condition:ee,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(xe).min(1)}).nullable(),seed:e.string().min(1).max(128)}),fn=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(dn).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,n)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((i,r)=>{if(r===0)return!1;let a=t.phases[r-1];return!a?.dateEnded||Date.parse(i.dateStarted)<Date.parse(a.dateStarted)||Date.parse(a.dateEnded)>Date.parse(i.dateStarted)})||new Set(t.variations.map(i=>i.key)).size!==t.variations.length||new Set(t.variations.map(i=>i.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(i=>i.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(i=>i.dateEnded&&Date.parse(i.dateStarted)>=Date.parse(i.dateEnded)||i.namespace?.ranges.some(([r,a],o,s)=>r>=a||s.some(([c,l],d)=>d!==o&&r<l&&c<a)))||t.phases.some(i=>i.variationWeights.length!==t.variations.length))&&n.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var gn=fn.safeExtend({filters:e.array(Je).optional()}),bn=e.strictObject({experiments:e.record(e.uuid(),gn),savedGroups:un}),yn=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),Cr=e.strictObject({snapshot:bn,attributes:he,results:he,stickyBucketAssignmentDocs:e.record(e.string(),yn)}),Dr=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});var L=k.refine(t=>/[1-9]/.test(t),"Quantity must be positive"),G=e.string().min(1).max(120),te=e.enum(["cap","overflow"]),_=(t,n)=>{let[i,r=""]=t.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");return BigInt(i)*10n**BigInt(n)+BigInt(r.padEnd(n,"0"))},K=t=>{try{return t()}catch{return!1}},Lr=e.discriminatedUnion("operation",[e.object({operation:e.literal("quote"),overageBehavior:te.optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:L,properties:$}).strict(),e.object({operation:e.literal("consume"),overageBehavior:te.optional(),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:k,properties:$,idempotencyKey:G}).strict(),e.object({operation:e.literal("reserve"),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:L,properties:$,idempotencyKey:G,expiresInSeconds:e.number().int().min(1).max(86400)}).strict(),e.object({operation:e.literal("confirm"),operationId:e.uuid(),quantity:L,properties:$.optional(),idempotencyKey:G}).strict(),e.object({operation:e.literal("refund"),operationId:e.uuid(),quantity:L,idempotencyKey:G}).strict(),e.object({operation:e.literal("release"),operationId:e.uuid(),idempotencyKey:G}).strict()]),hn=e.object({internal_credit_feature_id:e.uuid().nullable(),internal_metered_feature_id:e.uuid(),dimension:e.string().min(1).max(64),counterKey:e.string().min(1).max(240),cycleStart:e.iso.datetime({offset:!0}),unitCost:k,units:L,amount:J,tier:e.number().int().min(1).max(12).nullable()}).strict(),H=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function Xe(t,n){let i=t.reduce((r,a)=>r+_(a.units,12),0n)-_(n,12);return t.some(r=>r.funding==="balance")?i>=-100n&&i<=100n:i===0n}var Ye=e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:H.refine(t=>/[1-9]/.test(t)),amount:J}),e.strictObject({funding:e.literal("unbilled"),units:H.refine(t=>/[1-9]/.test(t))}),e.object({funding:e.literal("prepaid"),sourceId:e.uuid(),units:L,amount:J,pricing:e.array(hn).min(1).max(12)}).strict().refine(t=>K(()=>t.pricing.reduce((n,i)=>n+_(i.units,6),0n)===_(t.units,6)&&t.pricing.reduce((n,i)=>n+_(i.amount,12),0n)===_(t.amount,12)&&t.pricing.every(n=>_(n.unitCost,6)*_(n.units,6)===_(n.amount,12))),"Frozen pricing must conserve allocated units and amounts"),e.object({funding:e.literal("postpaid"),invoiceLineId:e.uuid().nullable(),units:L,authorizationId:e.uuid()}).strict()]),ne=e.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),Tr=e.object({allowed:e.boolean(),internal_feature_id:e.uuid(),quantity:k,requestedQuantity:k.optional(),overageBehavior:te.optional(),reason:ne.nullable(),allocations:e.array(Ye).max(500)}).strict().refine(t=>K(()=>t.allowed?t.reason===null&&Xe(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"A quote must conserve its accepted units").refine(t=>K(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0&&/[1-9]/.test(t.quantity):t.requestedQuantity!==void 0&&_(t.requestedQuantity,6)>=_(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Explicit overage behavior must retain the requested quantity"),Fr=e.object({id:e.uuid(),internal_feature_id:e.uuid(),kind:e.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:k,requestedQuantity:k.optional(),overageBehavior:te.optional(),accepted:e.boolean(),reason:e.enum([...ne.options,"expired"]).nullable(),createdAt:e.iso.datetime({offset:!0}),reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:e.iso.datetime({offset:!0}).nullable(),allocations:e.array(Ye).max(500)}).strict().refine(t=>K(()=>t.accepted?t.reason===null&&Xe(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"An operation must conserve its requested units").refine(t=>K(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0:t.kind==="consume"&&t.requestedQuantity!==void 0&&_(t.requestedQuantity,6)>=_(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(t=>/[1-9]/.test(t.quantity)||t.kind==="consume","Only consumption can record a zero cost event").refine(t=>t.allocations.every(n=>n.funding!=="postpaid"||n.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(t=>t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null)&&(t.kind!=="reserve"||!t.accepted||t.reservationStatus!==null),"Operation provenance and reservation state must be explicit");var xn=e.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Sn=e.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),et=e.strictObject({internal_feature_id:e.uuid(),entityId:e.uuid().nullable()}),Qr=et.extend({quantity:k,expectedRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:e.string().min(1).max(120),properties:$.refine(t=>Object.keys(t).length<=13&&!Object.keys(t).some(n=>n.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),tt=et.extend({operationId:e.uuid().nullable(),usage:k,capacity:xn.nullable(),remaining:Sn.nullable(),withinLimit:e.boolean(),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}).strict().superRefine((t,n)=>{let i=r=>{let a=r.startsWith("-"),[o,s=""]=(a?r.slice(1):r).split(".");if(o===void 0||o==="")throw new Error("Invalid decimal value");return(a?-1n:1n)*(BigInt(o)*10n**12n+BigInt(s.padEnd(12,"0")))};(t.capacity===null!=(t.remaining===null)||(t.capacity===null?!t.withinLimit:t.remaining===null||i(t.remaining)!==i(t.capacity)-i(t.usage)||t.withinLimit!==i(t.remaining)>=0n)||t.revision===0!=(t.operationId===null)||t.operationId===null!=(t.updatedAt===null))&&n.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var N=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),O=e.iso.datetime({offset:!0}),In=e.enum(["access","metered","credit"]),W={internal_feature_id:e.uuid(),key:T,name:e.string().min(1).max(120),kind:In},Jr=e.object({customerId:e.uuid(),snapshotAt:O,memberships:e.array(e.object({id:e.uuid(),productId:e.string().min(1).max(255),productVersionId:e.uuid(),billingProductVersionId:e.uuid(),version:e.number().int().positive(),key:e.string().min(1).max(64),name:e.string().min(1).max(120),groupId:e.string().max(255).nullable(),membershipType:e.enum(["main","addon"]),status:e.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:e.boolean(),accessEnabled:e.boolean(),renewalChange:e.object({productVersionId:e.uuid(),name:e.string().min(1).max(120),version:e.number().int().positive(),effectiveAt:O,benefitsAppliedAt:O.nullable(),timing:e.enum(["immediate","renewal"]),changeKind:e.enum(["plan","seats","quantity"]),feature:e.strictObject({internal_feature_id:e.uuid(),name:e.string().min(1).max(80),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).optional(),seat:e.object({key:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).strict().nullable(),status:e.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(t=>t.changeKind==="seats"==(t.seat!==null)&&t.changeKind==="quantity"==(t.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:e.object({phase:e.enum(["paid","trial"]),startsAt:O,endsAt:O.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:e.boolean(),balances:e.array(e.object({...W,usageType:e.enum(["consumable","non_consumable"]).nullable(),accessible:e.boolean(),unlimited:e.boolean(),available:N,held:N,debt:N,nextExpiresAt:O.nullable(),usage:tt.nullable()}).strict().refine(t=>t.kind==="metered"==(t.usageType!==null)&&(t.accessible||t.available==="0"&&t.held==="0")&&(t.usageType==="non_consumable"?t.usage!==null&&t.usage.internal_feature_id===t.internal_feature_id&&t.unlimited===(t.usage.capacity===null)&&t.available===(t.usage.remaining===null||t.usage.remaining.startsWith("-")?"0":t.usage.remaining)&&t.held==="0"&&t.debt==="0":t.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:e.boolean()}).strict(),nt=e.enum(["source","usage","transaction","invoice","debt","settlement"]),re=e.object({at:O,id:e.uuid(),type:nt}).strict(),Xr=e.object({type:nt.nullable(),resourceKey:T.optional(),kind:e.enum(["purchase","refund"]).optional(),topup:e.boolean().optional(),from:e.iso.date().nullable(),to:e.iso.date().nullable(),after:re.nullable(),limit:e.number().int().min(1).max(50)}).strict().refine(t=>!t.from||!t.to||t.from<=t.to,"Date range is reversed"),q={id:e.uuid(),occurredAt:O},kn=e.discriminatedUnion("type",[e.strictObject({...q,type:e.literal("invoice"),status:e.string().min(1).max(80),paid:N,refunded:N,currency:C,externalId:e.string().nullable()}),e.object({...q,...W,type:e.literal("source"),reason:e.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:N,unlimited:e.boolean(),status:e.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:O,expiresAt:O.nullable(),orderId:e.uuid().nullable(),parentSourceId:e.uuid().nullable()}).strict(),e.object({...q,type:e.literal("usage"),internal_feature_id:e.uuid(),name:e.string().min(1).max(120),kind:e.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:k,accepted:e.boolean(),reason:e.enum([...ne.options,"expired"]).nullable(),properties:$,reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:O.nullable(),charges:e.array(e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:H,amount:N}),e.strictObject({funding:e.literal("unbilled"),units:H}),e.object({...W,funding:e.literal("prepaid"),amount:N}).strict(),e.object({funding:e.literal("postpaid"),invoiceId:e.uuid(),invoiceLineId:e.uuid(),authorizationId:e.uuid(),units:k,currency:C}).strict()])).max(500)}).strict().refine(t=>(t.kind==="set_usage"||t.kind==="consume"&&t.quantity==="0"?t.accepted&&t.reason===null&&t.charges.length===0&&t.reservationStatus===null:t.accepted?t.reason===null&&t.charges.length>0:t.reason!==null&&t.charges.length===0)&&t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),e.object({...q,type:e.literal("transaction"),purpose:e.enum(["product","invoice"]),productVersionId:e.uuid().nullable(),productName:e.string().min(1).max(120).nullable(),productVersion:e.number().int().positive().nullable(),invoiceId:e.uuid().nullable(),orderId:e.uuid(),originalId:e.uuid().nullable(),kind:e.enum(["purchase","refund"]),amountMinor:e.number().int().nonnegative().max(2e8).nullable(),currency:C.nullable()}).strict().refine(t=>t.currency===null==(t.amountMinor===null)&&(t.purpose==="product"?t.productVersionId!==null&&t.productName!==null&&t.productVersion!==null&&t.invoiceId===null:t.productVersionId===null&&t.productName===null&&t.productVersion===null&&t.invoiceId!==null)&&t.kind==="refund"==(t.originalId!==null)&&(t.kind!=="refund"||t.amountMinor===null||t.amountMinor>0),"Payment fact provenance is incomplete"),e.object({...q,...W,type:e.literal("debt"),sourceId:e.uuid(),transactionId:e.uuid(),amount:N}).strict(),e.object({...q,...W,type:e.literal("settlement"),sourceId:e.uuid(),debtId:e.uuid(),kind:e.enum(["payment","usage_refund","payment_return"]),amount:N}).strict()]),Yr=e.object({customerId:e.uuid(),rows:e.array(kn).max(50),nextCursor:re.nullable()}).strict().refine(t=>new Set(t.rows.map(n=>n.type+n.id)).size===t.rows.length,"A page cannot repeat a fact").refine(t=>{let n=t.rows.at(-1);return!t.nextCursor||!!(n&&n.id===t.nextCursor.id&&n.type===t.nextCursor.type&&n.occurredAt===t.nextCursor.at)},"Cursor must name the final displayed fact");var ii=e.discriminatedUnion("kind",[e.object({kind:e.literal("ledger"),cursor:re}).strict(),e.object({kind:e.literal("billing"),cursor:e.uuid()}).strict()]),wn=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),jn=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),e.union([e.string().max(500),e.boolean(),e.array(e.string().max(500)).max(50)])).refine(t=>Object.keys(t).length<=40,"Too many answers"),_n=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function Se(t,n=0){return n>20?!0:!!t&&typeof t=="object"&&(Array.isArray(t)?t.some(i=>Se(i,n+1)):Object.entries(t).some(([i,r])=>["__proto__","constructor","prototype"].includes(i)||_n.test(i)||Se(r,n+1)))}var zn=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,ai=e.record(wn,D).refine(t=>Object.keys(t).length<=20,"Too many parameters").refine(t=>!Se(t)&&!zn.test(JSON.stringify(t)),"Credentials cannot be screen parameters");var rt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),An=e.array(e.object({variable:rt,componentId:rt,required:e.boolean()}).strict()).max(40).refine(t=>new Set(t.map(n=>n.variable)).size===t.length&&new Set(t.map(n=>n.componentId)).size===t.length,"Input bindings must be unique"),oi=e.object({bindings:An,answers:jn,values:e.record(e.string(),D).optional()}).strict();function it(t,n,i=1){if(t==="free")return"";if(t==="one_time")return n.startsWith("zh")?" \xB7 \u4E00\u6B21\u4ED8\u6B3E":" \xB7 one-time";let r=n.split("-")[0]??"en",a={zh:["/\u6708","/\u5E74"],en:["/month","/year"],ja:["/\u6708","/\u5E74"],ko:["/\uC6D4","/\uB144"],es:["/mes","/a\xF1o"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/m\xEAs","/ano"],it:["/mese","/anno"],ar:["/\u0634\u0647\u0631","/\u0633\u0646\u0629"]},o={zh:"\u5468",en:"week",ja:"\u9031",ko:"\uC8FC",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"\u0623\u0633\u0628\u0648\u0639"},s=t==="week"?`/${o[r]??o.en}`:(a[r]??a.en)[t==="month"?0:1];return i===1?s:`/${i} ${s.slice(1)}${r==="en"?"s":""}`}function fi(t,n){let i=[],r={};P(t,a=>{if(a.hidden)return!1;if(a.type!=="quantity_picker")return;let o=a.bind?.plan?[a.bind.plan]:[];a.bind?.picker&&P(t,s=>{if(s.type==="plan_picker"&&s.id===a.bind?.picker&&o.push(...s.planIds??[]),s.type==="stack"&&s.interaction?.type==="select"&&s.interaction.pickerId===a.bind?.picker)for(let c of s.children)c.type==="stack"&&c.bind?.plan&&o.push(c.bind.plan)}),o.length||i.push(`Quantity control ${a.id} needs a Product binding`);for(let s of new Set(o)){let c=n[s]?.prepaid?.find(d=>d.internalFeatureId===a.internalFeatureId)?.terms,l=r[s]??=new Set;(!c||l.has(a.internalFeatureId)||a.minimumQuantity<c.minimumQuantity||a.maximumQuantity>c.maximumQuantity)&&i.push(`Quantity control ${a.id} must match its Product's prepaid Feature and bounds`),l.add(a.internalFeatureId)}});for(let[a,o]of Object.entries(n))for(let s of o.prepaid??[])r[a]?.has(s.internalFeatureId)||i.push(`Product ${a} needs a quantity control for ${s.internalFeatureId}`);return i}function gi(t,n,i,r){let a=r.plans[n];if(!a?.available)throw new Error("Selected Product is unavailable");let o={};if(P(t,s=>{if(s.hidden)return!1;if(s.type!=="quantity_picker"||s.hidden||(s.bind?.plan??(s.bind?.picker?i[s.bind.picker]:void 0))!==n)return;let l=a.prepaid?.find(u=>u.internalFeatureId===s.internalFeatureId)?.terms,d=i[s.id];if(!l||typeof d!="number"||!Number.isSafeInteger(d)||d<Math.max(l.minimumQuantity,s.minimumQuantity)||d>Math.min(l.maximumQuantity,s.maximumQuantity)||(d-s.minimumQuantity)%s.step!==0||o[s.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");o[s.internalFeatureId]=d}),(a.prepaid??[]).some(s=>o[s.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return o}function vn(t,n,i){let r=t.terms.prices.find(a=>a.currency===n);if(!r||i<t.terms.minimumQuantity||i>t.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:we({quantity:i,unitAmountMinor:r.amountMinor,...r.pricing?{pricing:r.pricing}:{}}),allowance:ze(t.includedAmount,t.terms.units,i)}}function bi(t,n,i,r){let a=!1;if(P(t,c=>{c.type==="quantity_picker"&&(a=!0)}),!a)return n;let o=structuredClone(n);o.quantities={};let s=new Map;P(t,c=>{if(c.hidden)return!1;if(c.type!=="quantity_picker")return;let l=c.bind?.plan??(c.bind?.picker?i[c.bind.picker]??o.pickers[c.bind.picker]?.selected:void 0),d=typeof l=="string"?o.plans[l]:void 0,u=d?.prepaid?.find(at=>at.internalFeatureId===c.internalFeatureId),b=Math.max(c.minimumQuantity,u?.terms.minimumQuantity??0),h=Math.min(c.maximumQuantity,u?.terms.maximumQuantity??0),m=i[c.id]??c.defaultQuantity,p=typeof m=="number"&&Number.isSafeInteger(m)?m:c.defaultQuantity,f=!!u&&!!d?.available&&p>=b&&p<=h&&(p-c.minimumQuantity)%c.step===0,w=o.quantities[c.id]={minimum:b,maximum:Math.max(b,h),step:c.step,value:p,label:"",available:f};if(!f||!u||!d?.currency||d.amountMinor===void 0)return;let M=vn(u,d.currency,p);w.label=`${new Intl.NumberFormat(r).format(Number(M.allowance))} ${u.name}${["week","month","year"].includes(u.reset)?it(u.reset,r,u.resetCount):u.reset==="lifetime"?"":` / ${u.resetCount} ${u.reset}`}`,M.amountMinor!==0&&s.set(String(l),(s.get(String(l))??d.amountMinor)+M.amountMinor)});for(let[c,l]of s){let d=o.plans[c];if(!d?.currency)continue;let u=ie(l,d.currency,r);d.price=u;for(let[b,h]of Object.entries(o.nodes)){let m=be(t,b),p=f=>{if(f.price&&(f.price={...f.price,current:u,original:null}),m?.type==="text"){let w=t.strings.locales[r]?.[m.text]??t.strings.locales[t.strings.defaultLocale]?.[m.text];w?.includes("{{plan.price")&&(f.text=w.replace(/\{\{\s*plan.price\s*\}\}/g,u).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,ie(Math.round(l/((d.interval==="year"?12:1)*(d.intervalCount??1))),d.currency,r)))}};h.byPlan?.[c]&&p(h.byPlan[c]),(h.base.planVersionId===c||m&&"bind"in m&&m.bind?.plan===c)&&p(h.base)}}return o}export{ae as a,we as b,_e as c,ze as d,se as e,Ae as f,Mn as g,ve as h,Qn as i,Ee as j,Le as k,Te as l,Kn as m,Hn as n,ir as o,Xn as p,Ce as q,dt as r,V as s,pe as t,v as u,B as v,y as w,de as x,P as y,xr as z,ge as A,We as B,nn as C,Sr as D,Ir as E,be as F,kr as G,wr as H,D as I,he as J,ee as K,cn as L,yn as M,Lr as N,hn as O,H as P,Tr as Q,Fr as R,et as S,Qr as T,tt as U,N as V,Jr as W,Xr as X,Yr as Y,ii as Z,jn as _,ai as $,An as aa,oi as ba,it as ca,fi as da,gi as ea,bi as fa};
1
+ import{a as C,c as ie,j as Ie}from"./chunk-2Y5SGDC6.js";import{c as J,d as k,f as T,g as $}from"./chunk-YURGISSB.js";import{b as e}from"./chunk-NOOIJXRN.js";var ke=e.number().int().min(0).max(1e8),ae=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:ke,flatAmountMinor:ke.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 oe(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?ae.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,a=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let o of i.tiers){let s=o.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(o.unitAmountMinor)+BigInt(o.flatAmountMinor??0);break}}else n>a&&(r+=BigInt(Math.min(n,s)-a)*BigInt(o.unitAmountMinor));a=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function we(t){return oe({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ot=k.refine(t=>/[1-9]/.test(t)),_e=e.strictObject({units:ot,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:ae.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&&oe({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 je(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 ze(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=je(t)+je(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let a=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(a?"."+a:"")}var se=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:_e});var st=["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"],X=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(),Ae=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(),Mn=e.object({paywall:Ie.optional(),nodes:e.record(e.string(),e.object({base:Ae,picker:e.string().optional(),byPlan:e.record(e.string(),Ae).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(se).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 ve(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function ce(t){let n=ve(t).filter(r=>!st.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("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(n)]}function Qn(t,n,i={}){let r=t?.nodes[n];if(!r)return;let a=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof a=="string"?r.byPlan?.[a]??r.base:r.base}var ct=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],Oe=e.enum(ct),Pe=e.object({source:Oe,layout:e.enum(["full","compact"]),resourceKey:T.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:"\u8FD9\u4E2A\u6570\u636E\u6E90\u4E0D\u80FD\u7ED1\u5B9A\u79EF\u5206\u8D44\u6E90\u3002"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u4F59\u989D\u53EF\u4EE5\u5C55\u5F00\u6765\u6E90\u3002"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u3001\u5957\u9910\u4E0E\u4F1A\u5458\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u4EA4\u6613\u3002"})}),S=e.string().max(2e3),Ne=e.object({id:e.string().max(100),label:S,detail:e.array(S).max(12),value:S.optional(),status:S.optional(),facts:e.array(e.object({label:S,value:S}).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:S})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:S}).strict()).max(3).optional()}).strict(),ut=e.object({key:T,name:S,spendable:S,reserved:S,available:S,expiry:S.nullable(),sources:e.array(Ne).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),lt=e.object({source:Oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:S.optional(),resources:e.array(ut).max(500),rows:e.array(Ne).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:S,note:S,facts:e.array(e.object({label:S,value:S}).strict()).max(100)}).strict().optional(),membershipResult:S.optional()}).strict(),Kn=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),lt)}).strict(),Hn=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();var pt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Xn=e.discriminatedUnion("type",[e.object({type:e.literal("fixed"),productVersionId:e.string().min(1).max(200)}).strict(),e.object({type:e.literal("picker"),pickerId:pt,allowedProductVersionIds:e.array(e.string().min(1).max(200)).min(1).max(20)}).strict().refine(t=>new Set(t.allowedProductVersionIds).size===t.allowedProductVersionIds.length,"Product choices must be unique")]),mt=e.strictObject({min:e.number().finite().min(1).max(1800),max:e.number().finite().min(1).max(1800),viewport:e.number().finite().min(1).max(100)}).refine(t=>t.min<=t.max,"Desktop width range is reversed"),$e={desktopWidth:mt.optional(),mobile:e.enum(["sheet","fullscreen"]).optional(),backdrop:e.enum(["none","scrim","dim","strong-dim","blur"]).optional()},Ce=e.discriminatedUnion("type",[e.strictObject({type:e.literal("modal"),position:e.enum(["center","top","bottom"]).optional(),size:e.enum(["sm","md","lg"]),...$e}),e.strictObject({type:e.literal("sheet"),size:e.enum(["sm","md","lg"]),...$e}),e.strictObject({type:e.literal("fullscreen")}),e.strictObject({type:e.literal("inline")})]),dt={sm:360,md:420,lg:560};function De(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function Ee(t){let n={};function i(r){if(De(r)){let a=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let c=s.type==="stack"?s.bind?.plan:void 0;c&&!a.ids.includes(c)&&a.ids.push(c)}let o=r.children[r.interaction.defaultIndex];!a.defaultId&&o?.type==="stack"&&(a.defaultId=o.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function Re(t,n,i){let r={};function a(l){if(l.hidden)return;if(l.type==="plan_picker"){let b=i.pickers[l.id];r[l.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(l.type!=="stack")return;let d=l.children.filter(b=>!b.hidden),u=l.interaction;if(De(l)){let b=r[l.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},h=i.pickers[l.interaction.pickerId]?.options??[];for(let p of d){let f=p.type==="stack"?p.bind?.plan:void 0;f&&h.includes(f)&&!b.ids.includes(f)&&b.ids.push(f),f&&p.id===n[l.id]&&b.remembered.push(f)}let m=l.children[l.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(u?.type==="tabs"){let b=d.find(h=>h.id===n[l.id])??l.children[u.defaultIndex];b&&a(b)}else if(u?.type==="toggle"){let b=typeof n[l.id]=="boolean"?n[l.id]:u.defaultEnabled,h=l.children[b?0:1];h&&a(h)}else d.forEach(a)}let o=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(l=>l.id===o);s&&a(s.root);let c={};for(let[l,d]of Object.entries(r)){let u=n[l],b=d.remembered[0]??(d.ids.includes(i.pickers[l]?.selected??"")?i.pickers[l]?.selected:d.defaults[0]);c[l]=typeof u=="string"?d.ids.includes(u)?u:"":b&&d.ids.includes(b)?b:""}for(let l of Object.keys(Ee(t)))c[l]??="";return c}var Ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Le=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 Te(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function ir(t){let n=ce(t).map(i=>`\u672A\u77E5\u53D8\u91CF\uFF1A${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 a=t.indexOf("-->",i+4);i=a<0?t.length:a+2}else{let a="";for(i++;i<t.length;i++){let o=t[i];if(a)o===a&&(a="");else if(o==='"'||o==="'")a=o;else if(o===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("\u53D8\u91CF\u53EA\u80FD\u653E\u5728 HTML \u6587\u5B57\u4E2D\uFF0C\u4E0D\u80FD\u653E\u5165\u6807\u7B7E\u3001\u5C5E\u6027\u6216\u6CE8\u91CA")}return[...new Set(n)]}var x={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},Ve=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),I=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!Ve.has(t),"Reserved UI identifier"),ue=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),ft=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(ue).min(1).max(x.enumValues),default:ue}),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 Y(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 gt=ft.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"}),Y(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),bt=["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 yt(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 R=e.lazy(()=>e.union([ue,e.strictObject({ref:I}),e.strictObject({op:e.enum(bt),args:e.array(R).max(x.expressionNodes)}).superRefine((t,n)=>{yt(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function z(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function E(t,n,i){if(!t||typeof t!="object")return!0;if(!z(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(Ve.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let a=Object.getOwnPropertyDescriptor(t,r);if(a&&!Object.hasOwn(a,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function F(t,n,i,r){let a=[{value:t,depth:1,path:i}];for(;a.length;){let o=a.pop();if(++r.nodes>x.expressionNodes||o.depth>x.depth){n.addIssue({code:"custom",path:o.path,message:"UI expression budget exceeded"});return}if(!E(o.value,n,o.path))return;if(z(o.value)&&Array.isArray(o.value.args)){if(o.value.args.length>x.expressionNodes){n.addIssue({code:"custom",path:[...o.path,"args"],message:"UI expression budget exceeded"});return}for(let s=o.value.args.length-1;s>=0;s--)a.push({value:o.value.args[s],depth:o.depth+1,path:[...o.path,"args",s]})}}}var sr=e.unknown().superRefine((t,n)=>{F(t,n,[],{nodes:0})}).pipe(R),le=e.record(I,R).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=x.state,"UI assignments need 1\u201332 state keys"),ht=e.strictObject({target:I,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:R,className:I.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"})}),xt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:I,state:I}),e.strictObject({type:e.literal("input"),target:I,state:I,set:le.optional()}),e.strictObject({type:e.literal("action"),target:I,set:le}),e.strictObject({type:e.literal("carousel"),target:I,state:I,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:I.optional(),nextTarget:I.optional(),inactiveTargets:e.array(I).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),St=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:le}),It=e.strictObject({type:e.literal("mosaic_waves"),target:I,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:R.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()}),kt=e.strictObject({type:e.literal("number_counter"),target:I,value:R,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),wt=e.strictObject({state:e.record(I,gt).refine(t=>Object.keys(t).length<=x.state,"Too many UI state keys").optional(),derived:e.record(I,R).refine(t=>Object.keys(t).length<=x.derived,"Too many UI derived keys").optional(),bindings:e.array(ht).max(x.bindings).optional(),controls:e.array(xt).max(x.controls).optional(),timers:e.array(St).max(x.timers).optional(),effects:e.array(e.discriminatedUnion("type",[It,kt])).max(x.effects).optional(),clock:e.boolean().optional()});function jt(t,n){if(!E(t,n,[])||!z(t))return;for(let[r,a]of[["state",x.state],["derived",x.derived]]){let o=t[r];if(!E(o,n,[r]))return;if(z(o)&&Object.keys(o).length>a){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,a]of[["bindings",x.bindings],["controls",x.controls],["timers",x.timers],["effects",x.effects]])if(Array.isArray(t[r])&&t[r].length>a){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,a]of t.effects.entries())if(!E(a,n,["effects",r]))return}if(z(t.state))for(let[r,a]of Object.entries(t.state)){if(!E(a,n,["state",r]))return;if(z(a)&&Array.isArray(a.values)&&a.values.length>x.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(z(t.derived))for(let[r,a]of Object.entries(t.derived))F(a,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let a=t[r];if(Array.isArray(a)){for(let[o,s]of a.entries())if(!(!E(s,n,[r,o])||!z(s))){if(r==="bindings")F(s.expression,n,[r,o,"expression"],i);else if(E(s.set,n,[r,o,"set"])&&z(s.set)){if(Object.keys(s.set).length>x.state){n.addIssue({code:"custom",path:[r,o,"set"],message:"Too many UI assignments"});return}for(let[c,l]of Object.entries(s.set))F(l,n,[r,o,"set",c],i)}if(i.nodes>x.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,a]of t.effects.entries())z(a)&&a.type==="number_counter"?F(a.value,n,["effects",r,"value"],i):z(a)&&a.enabled!==void 0&&F(a.enabled,n,["effects",r,"enabled"],i)}function Fe(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 qe=e.unknown().superRefine(jt).pipe(wt).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},a=new Set([...Object.keys(i),...Object.keys(r)]),o=(m,p)=>{for(let f of Fe(m))a.has(f)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${f}`})};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"}),o(p,["derived",m]);let s=new Set,c=new Set,l=m=>{if(s.has(m))return!1;if(c.has(m))return!0;s.add(m);for(let p of Fe(r[m]))if(Object.hasOwn(r,p)&&!l(p))return!1;return s.delete(m),c.add(m),!0};for(let m of Object.keys(r))if(!l(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())o(p.expression,["bindings",m,"expression"]);let d=new Set;for(let[m,p]of(t.effects??[]).entries())d.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),d.add(p.target),p.type==="number_counter"?(o(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&&o(p.enabled,["effects",m,"enabled"]);let u=(m,p)=>{for(let[f,w]of Object.entries(m))Object.hasOwn(i,f)||n.addIssue({code:"custom",path:[...p,f],message:"UI assignments can only update declared state"}),o(w,[...p,f])},b=new Set,h=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 f of p.inactiveTargets??[])(f===p.target||h.has(f))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),h.add(f);if(p.type==="carousel")for(let f of["previousTarget","nextTarget"]){let w=p[f];w!==void 0&&((w===p.target||b.has(w)||(t.controls??[]).some(M=>M.target===w))&&n.addIssue({code:"custom",path:["controls",m,f],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(w))}if(p.type!=="action"){let f=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!f||p.type==="input"&&f.type==="enum"&&f.values.some(w=>typeof w!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(f?.type!=="number"||!Number.isInteger(f.min)||f.min<0||!Number.isInteger(f.max)||f.step!==1||p.initialIndex!==void 0&&!Y(f,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&f?.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&&u(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())u(p.set,["timers",m,"set"])});var Qe=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,V=e.string().max(16).regex(Qe,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"\u6301\u4E45\u5316\u8BED\u8A00\u4EE3\u7801\u5FC5\u987B\u4F7F\u7528\u89C4\u8303\u5199\u6CD5");function pe(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:a}=new Intl.Locale(n),o=[i,r,a].filter(Boolean).join("-");return Qe.test(o)?o:null}catch{return null}}var _t=new Set(["TW","HK","MO"]);function Me(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let a=i?.length===4?i:void 0,o=i?.length===4?r:i;return a?`zh-${a}`:o&&_t.has(o)?"zh-Hant":"zh-Hans"}function Be(t,n,i){let r=n.map(a=>({code:V.parse(a),normalized:a}));for(let a of t){let o=pe(a);if(!o)continue;let s=r.find(u=>u.normalized===o);if(s)return s.code;let c=Me(o),l=r.filter(u=>Me(u.normalized)===c),d=l.find(u=>!u.normalized.includes("-")||u.normalized===c)??l[0];if(d)return d.code}return i}var zt=4,v={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},B=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),y=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),At=e.enum(["none","xs","sm","md","lg","xl"]),vt=e.enum(["none","sm","md","lg","full"]),me=e.string().regex(/^#[0-9a-fA-F]{6}$/),fe=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),de=e.union([fe,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}$/)]),Ze=e.object({primary:me,background:me,text:me,radius:vt,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:fe,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(),Z=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),g=(t,n)=>e.number().int().min(t).max(n),Ge=e.union([e.enum(["fit","fill"]),g(1,1200)]),Ot=e.object({top:g(0,200),right:g(0,200),bottom:g(0,200),left:g(0,200)}).strict(),Pt=e.object({top:g(-100,200),right:g(-100,200),bottom:g(-100,200),left:g(-100,200)}).strict(),Ke=e.object({x:g(0,100),y:g(0,100)}).strict(),Nt=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:Z}).strict(),e.object({type:e.literal("linear"),angle:g(0,360),stops:e.array(e.object({color:Z,at:g(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:de,fit:e.enum(["cover","contain"]),position:Ke.optional()}).strict()]),$t=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([g(0,200),e.object({topLeft:g(0,200),topRight:g(0,200),bottomRight:g(0,200),bottomLeft:g(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ct=e.object({width:g(0,12),color:Z,style:e.enum(["solid","dashed"])}).strict(),Dt=e.object({x:g(-40,40),y:g(-40,40),blur:g(0,80),spread:g(-20,40),color:Z}).strict(),Et=e.object({font:e.enum(["system","serif","rounded","mono"]),size:g(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:Z,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),U=e.object({width:Ge,height:Ge,padding:Ot,margin:Pt,gap:g(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Nt,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:$t,border:Ct,shadow:Dt,text:Et}).strict().partial(),j={id:B,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:U.optional(),fallback:y.optional()},Rt=e.object({...j,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:y,variant:e.enum(["title","heading","body","caption"])}).strict(),Ut=e.object({...j,type:e.literal("image"),src:de,localizedSrc:e.record(V,de).optional(),alt:y,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ke.optional()}).strict(),Lt=e.object({...j,type:e.literal("button"),label:y,variant:e.enum(["primary","secondary","link"]),action:y,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:X.optional()}).strict(),Tt=e.object({...j,type:e.literal("divider")}).strict(),Ft=e.object({...j,type:e.literal("customer_data"),title:y,data:Pe}).strict(),Vt=e.object({...j,type:e.literal("spacer"),size:At}).strict(),qt=e.object({...j,type:e.literal("custom_html"),html:e.record(V,e.string().max(v.customHtml)),css:e.string().max(v.customCss),ui:qe.optional()}).strict(),Mt=e.object({...j,type:e.literal("price"),fallback:y,parts:e.object({current:U.optional(),original:U.optional(),period:U.optional()}).strict().optional()}).strict(),Qt=e.object({...j,type:e.literal("coupon_code"),label:y,fallback:y}).strict(),Bt=e.object({...j,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:y,fallback:y}).strict().refine(t=>t.source!=="fixed"||!!t.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),Zt=e.object({...j,type:e.literal("plan_picker"),label:y,fallback:y,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:Le.safeExtend({monthLabel:y,yearLabel:y,unavailableLabel:y}).optional(),states:e.object({selected:U.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!Te(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),Gt=e.object({...j,type:e.literal("quantity_picker"),bind:X.optional(),label:y,fallback:y,internalFeatureId:e.uuid(),minimumQuantity:g(0,1e4),maximumQuantity:g(0,1e4),defaultQuantity:g(0,1e4),step:g(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"),Kt=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:y,keyboard:e.enum(["text","email","tel","url"]),maxLength:g(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:y,min:g(0,50),max:g(1,50)}).strict(),e.object({type:e.literal("select"),label:y,defaultIndex:g(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:B.optional(),selectedStyle:U.optional()}).strict(),e.object({type:e.literal("tabs"),label:y,defaultIndex:g(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:y,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:y}).strict()]),A={...j,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:g(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:Kt.optional(),states:e.object({selected:U.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:y.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:X.optional()},He=e.lazy(()=>e.object({...j,type:A.type,direction:A.direction,align:A.align,justify:A.justify,children:e.array(Ht).max(v.children),productSlot:A.productSlot,interaction:A.interaction,states:A.states,purpose:A.purpose,purchaseAction:A.purchaseAction,buttonVariant:A.buttonVariant,bind:A.bind}).strict()),Ht=e.lazy(()=>e.union([He,Rt,Ut,Lt,Tt,Vt,qt,Mt,Qt,Bt,Zt,Gt,Ft])),Wt=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),Q={id:y,event:y,properties:e.record(y,Wt).refine(t=>Object.keys(t).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},Jt=e.discriminatedUnion("type",[e.object({...Q,type:e.literal("navigate"),close:e.literal(!1),pageId:B}).strict(),e.object({...Q,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...Q,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...Q,type:e.literal("open_url"),close:e.boolean(),url:fe}).strict(),e.object({...Q,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),Xt=e.object({defaultLocale:V,locales:e.record(V,e.record(y,e.string().max(v.stringLength)))}).strict(),Yt=e.enum(["popup","paywall","onboarding","page","banner"]);var en=e.object({kind:e.literal("screen"),schemaVersion:e.literal(zt),name:e.string().trim().min(1).max(80),surface:Yt,initialPageId:B.optional(),presentation:Ce,theme:Ze,pages:e.array(e.object({id:B,name:e.string().trim().min(1).max(60),root:He,theme:Ze.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(v.pages),strings:Xt,actions:e.array(Jt).max(v.actions)}).strict();function P(t,n){for(let i of t.pages)ge(i.root,n)}var xr=en.superRefine((t,n)=>{let i=v;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(u=>u.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let u of t.actions)u.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===u.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`\u9875\u9762\u6700\u591A ${i.pages} \u4E2A`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`\u52A8\u4F5C\u6700\u591A ${i.actions} \u4E2A`});let r=u=>n.addIssue({code:"custom",message:u}),a=Object.keys(t.strings.locales);a.includes(t.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),a.length>v.locales&&r(`\u6700\u591A ${v.locales} \u79CD\u8BED\u8A00`);let o=new Set;for(let u of t.actions)o.has(u.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${u.id}`),o.add(u.id);let s=new Set;for(let u of t.pages)["next","back"].includes(u.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${u.id}`),s.has(u.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${u.id}`),s.add(u.id);let c=new Set,l=0,d=!1;P(t,(u,b)=>{if(l++,b>v.depth&&(d=!0),c.has(u.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${u.id}`),c.add(u.id),u.type==="button"&&!o.has(u.action)&&r(`\u6309\u94AE ${u.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${u.action}`),u.type==="custom_html")for(let h of Object.keys(u.html))a.includes(h)||r(`\u81EA\u5B9A\u4E49 HTML ${u.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${h}`);if(u.type==="image")for(let h of Object.keys(u.localizedSrc??{}))a.includes(h)||r(`\u56FE\u7247 ${u.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${h}`)}),l>i.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${i.nodes} \u4E2A`),d&&r(`\u5C42\u7EA7\u6700\u591A ${v.depth} \u5C42`)});function ge(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let a of t.children)ge(a,n,i+1,t)}function We(t){let n=[],i=new Set;return P(t,r=>{let a=(o,s,c)=>{i.has(o)||(i.add(o),n.push({key:o,nodeId:r.id,nodeType:r.type,field:s,required:c}))};r.type==="stack"&&r.interaction&&a(r.interaction.label,"label",!0),r.fallback&&a(r.fallback,"text",!0),r.type==="text"&&a(r.text,"text",!0),r.type==="customer_data"&&a(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&a(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(a(r.grouping.monthLabel,"label",!0),a(r.grouping.yearLabel,"label",!0),a(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&a(r.expired,"text",!0),r.type==="button"&&a(r.label,"label",!0),r.type==="image"&&(a(`image:${r.id}`,"src",!1),a(r.alt,"alt",!1)),r.type==="custom_html"&&a(`html:${r.id}`,"html",!0)}),n}function tn(t,n,i){if(n.field==="html"){let r;return P(t,a=>{a.id===n.nodeId&&a.type==="custom_html"&&(r=a.html[i])}),r}if(n.field==="src"){let r=be(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 nn(t){let n=We(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,a)=>r===t.strings.defaultLocale?-1:a===t.strings.defaultLocale?1:0).map(r=>{let a=n.filter(o=>!tn(t,o,r)?.trim()).map(o=>o.key);return{locale:r,total:n.length,filled:n.length-a.length,missing:a,complete:a.length===0}})}function rn(t){return nn(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function Sr(t,n){return Be(n,rn(t),t.strings.defaultLocale)}function Ir(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},a={};for(let s of We(t)){if(s.field==="html"||s.field==="src")continue;let c=i[s.key]?.trim()?i[s.key]:r[s.key];c!==void 0&&(a[s.key]=c)}let o=s=>{if(s.type==="stack")return{...s,children:s.children.map(o)};if(s.type==="custom_html"){let c=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:c===void 0?{}:{[n]:c}}}if(s.type==="image"){let{localizedSrc:c,...l}=s;return{...l,src:c?.[n]??c?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:o(s.root)})),strings:{defaultLocale:n,locales:{[n]:a}}}}function an(t,n){let i=null;return ge(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function be(t,n){for(let i of t.pages){let r=an(i.root,n);if(r)return r}return null}function kr(t){let n=pe(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function wr(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let a=n;if(P(t,o=>{if(o.type==="quantity_picker"){let c=a[o.id];typeof c=="number"&&Number.isSafeInteger(c)&&c>=o.minimumQuantity&&c<=o.maximumQuantity&&(c-o.minimumQuantity)%o.step===0&&(r[o.id]=c);return}if(o.type==="plan_picker"){let c=a[o.id];typeof c=="string"&&(r[o.id]=i?.pickers[o.id]?.options.includes(c)?c:"");return}if(o.type==="custom_html"&&o.ui)for(let[c,l]of Object.entries(o.ui.state??{})){let d=`${o.id}.${c}`,u=a[d];u!==null&&Y(l,u)&&(r[d]=u)}if(o.type!=="stack"||!o.interaction)return;let s=Object.hasOwn(a,o.id)?a[o.id]:void 0;["select","tabs"].includes(o.interaction.type)&&typeof s=="string"&&o.children.some(c=>c.id===s)&&(r[o.id]=s),o.interaction.type==="toggle"&&typeof s=="boolean"&&(r[o.id]=s)}),t.surface==="paywall"&&typeof a.__page=="string"&&t.pages.some(o=>o.id===a.__page)&&(r.__page=a.__page),i){let o={...r};for(let[s,c]of Object.entries(a))(typeof c=="string"||typeof c=="boolean")&&(o[s]=c);Object.assign(r,Re(t,o,i))}return r}var D=e.json().superRefine((t,n)=>{let i=0;function r(a,o){if(++i>1e4||o>20){n.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof a=="string"&&(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a))&&n.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(a))a.forEach(s=>r(s,o+1));else if(a&&typeof a=="object")for(let[s,c]of Object.entries(a))(s.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(s)||["__proto__","prototype","constructor"].includes(s))&&n.addIssue({code:"custom",message:"Reserved JSON property"}),r(c,o+1)}r(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&n.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),he=e.record(e.string().min(1).max(128),D).superRefine((t,n)=>{(!D.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(i=>Object.hasOwn(t,i)))&&n.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),on=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),ee=he.superRefine((t,n)=>{function i(r){if(Array.isArray(r))r.forEach(i);else if(r&&typeof r=="object")for(let[a,o]of Object.entries(r)){if(a==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(o).success&&n.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!a.startsWith("$")&&a.split(".").some(s=>["__proto__","prototype","constructor"].includes(s))&&n.addIssue({code:"custom",message:"Reserved attribute path"}),a.startsWith("$")&&!on.has(a)&&n.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${a}`}),["$regex","$regexi"].includes(a)&&typeof o=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(o)||[...o.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(s=>Number(s[1])>255||Number(s[2]||0)>255)||a==="$regexi"&&/[^\x00-\x7f]/.test(o.replace(/\\u([0-9a-f]{4})/gi,(s,c)=>String.fromCharCode(Number.parseInt(c,16)))))&&n.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(o)}catch{n.addIssue({code:"custom",message:"Invalid regular expression"})}}i(o)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&n.addIssue({code:"custom",message:"Obsolete condition protocol"}),i(t)}),sn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:ee}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function cn(t){let n=new Set;function i(r){if(Array.isArray(r))r.forEach(i);else if(r&&typeof r=="object")for(let[a,o]of Object.entries(r))a==="$savedGroup"&&o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.id=="string"?n.add(o.id):["$inGroup","$notInGroup"].includes(a)&&typeof o=="string"?n.add(o):["$eq","$ne","$in","$nin","$ini","$nini"].includes(a)||i(o)}return i(t),[...n]}var un=e.record(e.uuid(),sn).superRefine((t,n)=>{let i=new Set,r=new Set;function a(o){if(i.has(o)){n.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(r.has(o))return;let s=t[o];if(!s){n.addIssue({code:"custom",message:"Missing saved group dependency"});return}i.add(o),s.type==="condition"&&cn(s.condition).forEach(a),i.delete(o),r.add(o)}Object.keys(t).forEach(a)}),xe=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,n])=>t<=n),Je=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(xe).min(1).max(100)}),ln=e.strictObject({id:e.string().min(1).max(128),condition:ee,gate:e.boolean().optional()}),ye={id:e.string().max(128).optional(),condition:ee.optional(),parentConditions:e.array(ln).max(50).optional(),filters:e.array(Je).max(20).optional()},pn=e.union([e.strictObject({...ye}),e.strictObject({...ye,force:D,coverage:e.number().min(0).max(1).optional(),range:xe.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...ye,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),D),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),mn=e.strictObject({defaultValue:D,rules:e.array(pn).max(100)}),$r=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),mn).superRefine((t,n)=>{Object.keys(t).length>100&&n.addIssue({code:"custom",message:"Too many Features"});let i=new Set,r=new Set;function a(o){if(i.has(o)){n.addIssue({code:"custom",message:`Cyclic Feature dependency: ${o}`});return}if(r.has(o))return;let s=t[o];if(!s){n.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${o}`});return}i.add(o);for(let c of s.rules)for(let l of c.parentConditions??[])a(l.id);i.delete(o),r.add(o)}Object.keys(t).forEach(a)}),dn=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((n,i)=>n+i,0)-1)<=.01),condition:ee,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(xe).min(1)}).nullable(),seed:e.string().min(1).max(128)}),fn=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(dn).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,n)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((i,r)=>{if(r===0)return!1;let a=t.phases[r-1];return!a?.dateEnded||Date.parse(i.dateStarted)<Date.parse(a.dateStarted)||Date.parse(a.dateEnded)>Date.parse(i.dateStarted)})||new Set(t.variations.map(i=>i.key)).size!==t.variations.length||new Set(t.variations.map(i=>i.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(i=>i.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(i=>i.dateEnded&&Date.parse(i.dateStarted)>=Date.parse(i.dateEnded)||i.namespace?.ranges.some(([r,a],o,s)=>r>=a||s.some(([c,l],d)=>d!==o&&r<l&&c<a)))||t.phases.some(i=>i.variationWeights.length!==t.variations.length))&&n.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var gn=fn.safeExtend({filters:e.array(Je).optional()}),bn=e.strictObject({experiments:e.record(e.uuid(),gn),savedGroups:un}),yn=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),Cr=e.strictObject({snapshot:bn,attributes:he,results:he,stickyBucketAssignmentDocs:e.record(e.string(),yn)}),Dr=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});var L=k.refine(t=>/[1-9]/.test(t),"Quantity must be positive"),G=e.string().min(1).max(120),te=e.enum(["cap","overflow"]),_=(t,n)=>{let[i,r=""]=t.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");return BigInt(i)*10n**BigInt(n)+BigInt(r.padEnd(n,"0"))},K=t=>{try{return t()}catch{return!1}},Lr=e.discriminatedUnion("operation",[e.object({operation:e.literal("quote"),overageBehavior:te.optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:L,properties:$}).strict(),e.object({operation:e.literal("consume"),overageBehavior:te.optional(),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:k,properties:$,idempotencyKey:G}).strict(),e.object({operation:e.literal("reserve"),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:L,properties:$,idempotencyKey:G,expiresInSeconds:e.number().int().min(1).max(86400)}).strict(),e.object({operation:e.literal("confirm"),operationId:e.uuid(),quantity:L,properties:$.optional(),idempotencyKey:G}).strict(),e.object({operation:e.literal("refund"),operationId:e.uuid(),quantity:L,idempotencyKey:G}).strict(),e.object({operation:e.literal("release"),operationId:e.uuid(),idempotencyKey:G}).strict()]),hn=e.object({internal_credit_feature_id:e.uuid().nullable(),internal_metered_feature_id:e.uuid(),dimension:e.string().min(1).max(64),counterKey:e.string().min(1).max(240),cycleStart:e.iso.datetime({offset:!0}),unitCost:k,units:L,amount:J,tier:e.number().int().min(1).max(12).nullable()}).strict(),H=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function Xe(t,n){let i=t.reduce((r,a)=>r+_(a.units,12),0n)-_(n,12);return t.some(r=>r.funding==="balance")?i>=-100n&&i<=100n:i===0n}var Ye=e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:H.refine(t=>/[1-9]/.test(t)),amount:J}),e.strictObject({funding:e.literal("unbilled"),units:H.refine(t=>/[1-9]/.test(t))}),e.object({funding:e.literal("prepaid"),sourceId:e.uuid(),units:L,amount:J,pricing:e.array(hn).min(1).max(12)}).strict().refine(t=>K(()=>t.pricing.reduce((n,i)=>n+_(i.units,6),0n)===_(t.units,6)&&t.pricing.reduce((n,i)=>n+_(i.amount,12),0n)===_(t.amount,12)&&t.pricing.every(n=>_(n.unitCost,6)*_(n.units,6)===_(n.amount,12))),"Frozen pricing must conserve allocated units and amounts"),e.object({funding:e.literal("postpaid"),invoiceLineId:e.uuid().nullable(),units:L,authorizationId:e.uuid()}).strict()]),ne=e.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),Tr=e.object({allowed:e.boolean(),internal_feature_id:e.uuid(),quantity:k,requestedQuantity:k.optional(),overageBehavior:te.optional(),reason:ne.nullable(),allocations:e.array(Ye).max(500)}).strict().refine(t=>K(()=>t.allowed?t.reason===null&&Xe(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"A quote must conserve its accepted units").refine(t=>K(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0&&/[1-9]/.test(t.quantity):t.requestedQuantity!==void 0&&_(t.requestedQuantity,6)>=_(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Explicit overage behavior must retain the requested quantity"),Fr=e.object({id:e.uuid(),internal_feature_id:e.uuid(),kind:e.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:k,requestedQuantity:k.optional(),overageBehavior:te.optional(),accepted:e.boolean(),reason:e.enum([...ne.options,"expired"]).nullable(),createdAt:e.iso.datetime({offset:!0}),reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:e.iso.datetime({offset:!0}).nullable(),allocations:e.array(Ye).max(500)}).strict().refine(t=>K(()=>t.accepted?t.reason===null&&Xe(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"An operation must conserve its requested units").refine(t=>K(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0:t.kind==="consume"&&t.requestedQuantity!==void 0&&_(t.requestedQuantity,6)>=_(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(t=>/[1-9]/.test(t.quantity)||t.kind==="consume","Only consumption can record a zero cost event").refine(t=>t.allocations.every(n=>n.funding!=="postpaid"||n.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(t=>t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null)&&(t.kind!=="reserve"||!t.accepted||t.reservationStatus!==null),"Operation provenance and reservation state must be explicit");var xn=e.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Sn=e.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),et=e.strictObject({internal_feature_id:e.uuid(),entityId:e.uuid().nullable()}),Qr=et.extend({quantity:k,expectedRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:e.string().min(1).max(120),properties:$.refine(t=>Object.keys(t).length<=13&&!Object.keys(t).some(n=>n.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),tt=et.extend({operationId:e.uuid().nullable(),usage:k,capacity:xn.nullable(),remaining:Sn.nullable(),withinLimit:e.boolean(),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}).strict().superRefine((t,n)=>{let i=r=>{let a=r.startsWith("-"),[o,s=""]=(a?r.slice(1):r).split(".");if(o===void 0||o==="")throw new Error("Invalid decimal value");return(a?-1n:1n)*(BigInt(o)*10n**12n+BigInt(s.padEnd(12,"0")))};(t.capacity===null!=(t.remaining===null)||(t.capacity===null?!t.withinLimit:t.remaining===null||i(t.remaining)!==i(t.capacity)-i(t.usage)||t.withinLimit!==i(t.remaining)>=0n)||t.revision===0!=(t.operationId===null)||t.operationId===null!=(t.updatedAt===null))&&n.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var N=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),O=e.iso.datetime({offset:!0}),In=e.enum(["access","metered","credit"]),W={internal_feature_id:e.uuid(),key:T,name:e.string().min(1).max(120),kind:In},Jr=e.object({customerId:e.uuid(),snapshotAt:O,memberships:e.array(e.object({id:e.uuid(),productId:e.string().min(1).max(255),productVersionId:e.uuid(),billingProductVersionId:e.uuid(),version:e.number().int().positive(),key:e.string().min(1).max(64),name:e.string().min(1).max(120),groupId:e.string().max(255).nullable(),membershipType:e.enum(["main","addon"]),status:e.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:e.boolean(),accessEnabled:e.boolean(),renewalChange:e.object({productVersionId:e.uuid(),name:e.string().min(1).max(120),version:e.number().int().positive(),effectiveAt:O,benefitsAppliedAt:O.nullable(),timing:e.enum(["immediate","renewal"]),changeKind:e.enum(["plan","seats","quantity"]),feature:e.strictObject({internal_feature_id:e.uuid(),name:e.string().min(1).max(80),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).optional(),seat:e.object({key:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).strict().nullable(),status:e.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(t=>t.changeKind==="seats"==(t.seat!==null)&&t.changeKind==="quantity"==(t.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:e.object({phase:e.enum(["paid","trial"]),startsAt:O,endsAt:O.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:e.boolean(),balances:e.array(e.object({...W,usageType:e.enum(["consumable","non_consumable"]).nullable(),accessible:e.boolean(),unlimited:e.boolean(),available:N,held:N,debt:N,nextExpiresAt:O.nullable(),usage:tt.nullable()}).strict().refine(t=>t.kind==="metered"==(t.usageType!==null)&&(t.accessible||t.available==="0"&&t.held==="0")&&(t.usageType==="non_consumable"?t.usage!==null&&t.usage.internal_feature_id===t.internal_feature_id&&t.unlimited===(t.usage.capacity===null)&&t.available===(t.usage.remaining===null||t.usage.remaining.startsWith("-")?"0":t.usage.remaining)&&t.held==="0"&&t.debt==="0":t.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:e.boolean()}).strict(),nt=e.enum(["source","usage","transaction","invoice","debt","settlement"]),re=e.object({at:O,id:e.uuid(),type:nt}).strict(),Xr=e.object({type:nt.nullable(),resourceKey:T.optional(),kind:e.enum(["purchase","refund"]).optional(),topup:e.boolean().optional(),from:e.iso.date().nullable(),to:e.iso.date().nullable(),after:re.nullable(),limit:e.number().int().min(1).max(50)}).strict().refine(t=>!t.from||!t.to||t.from<=t.to,"Date range is reversed"),q={id:e.uuid(),occurredAt:O},kn=e.discriminatedUnion("type",[e.strictObject({...q,type:e.literal("invoice"),status:e.string().min(1).max(80),paid:N,refunded:N,currency:C,externalId:e.string().nullable()}),e.object({...q,...W,type:e.literal("source"),reason:e.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:N,unlimited:e.boolean(),status:e.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:O,expiresAt:O.nullable(),orderId:e.uuid().nullable(),parentSourceId:e.uuid().nullable()}).strict(),e.object({...q,type:e.literal("usage"),internal_feature_id:e.uuid(),name:e.string().min(1).max(120),kind:e.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:k,accepted:e.boolean(),reason:e.enum([...ne.options,"expired"]).nullable(),properties:$,reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:O.nullable(),charges:e.array(e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:H,amount:N}),e.strictObject({funding:e.literal("unbilled"),units:H}),e.object({...W,funding:e.literal("prepaid"),amount:N}).strict(),e.object({funding:e.literal("postpaid"),invoiceId:e.uuid(),invoiceLineId:e.uuid(),authorizationId:e.uuid(),units:k,currency:C}).strict()])).max(500)}).strict().refine(t=>(t.kind==="set_usage"||t.kind==="consume"&&t.quantity==="0"?t.accepted&&t.reason===null&&t.charges.length===0&&t.reservationStatus===null:t.accepted?t.reason===null&&t.charges.length>0:t.reason!==null&&t.charges.length===0)&&t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),e.object({...q,type:e.literal("transaction"),purpose:e.enum(["product","invoice"]),productVersionId:e.uuid().nullable(),productName:e.string().min(1).max(120).nullable(),productVersion:e.number().int().positive().nullable(),invoiceId:e.uuid().nullable(),orderId:e.uuid(),originalId:e.uuid().nullable(),kind:e.enum(["purchase","refund"]),amountMinor:e.number().int().nonnegative().max(2e8).nullable(),currency:C.nullable()}).strict().refine(t=>t.currency===null==(t.amountMinor===null)&&(t.purpose==="product"?t.productVersionId!==null&&t.productName!==null&&t.productVersion!==null&&t.invoiceId===null:t.productVersionId===null&&t.productName===null&&t.productVersion===null&&t.invoiceId!==null)&&t.kind==="refund"==(t.originalId!==null)&&(t.kind!=="refund"||t.amountMinor===null||t.amountMinor>0),"Payment fact provenance is incomplete"),e.object({...q,...W,type:e.literal("debt"),sourceId:e.uuid(),transactionId:e.uuid(),amount:N}).strict(),e.object({...q,...W,type:e.literal("settlement"),sourceId:e.uuid(),debtId:e.uuid(),kind:e.enum(["payment","usage_refund","payment_return"]),amount:N}).strict()]),Yr=e.object({customerId:e.uuid(),rows:e.array(kn).max(50),nextCursor:re.nullable()}).strict().refine(t=>new Set(t.rows.map(n=>n.type+n.id)).size===t.rows.length,"A page cannot repeat a fact").refine(t=>{let n=t.rows.at(-1);return!t.nextCursor||!!(n&&n.id===t.nextCursor.id&&n.type===t.nextCursor.type&&n.occurredAt===t.nextCursor.at)},"Cursor must name the final displayed fact");var ii=e.discriminatedUnion("kind",[e.object({kind:e.literal("ledger"),cursor:re}).strict(),e.object({kind:e.literal("billing"),cursor:e.uuid()}).strict()]),wn=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),jn=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),e.union([e.string().max(500),e.boolean(),e.array(e.string().max(500)).max(50)])).refine(t=>Object.keys(t).length<=40,"Too many answers"),_n=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function Se(t,n=0){return n>20?!0:!!t&&typeof t=="object"&&(Array.isArray(t)?t.some(i=>Se(i,n+1)):Object.entries(t).some(([i,r])=>["__proto__","constructor","prototype"].includes(i)||_n.test(i)||Se(r,n+1)))}var zn=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,ai=e.record(wn,D).refine(t=>Object.keys(t).length<=20,"Too many parameters").refine(t=>!Se(t)&&!zn.test(JSON.stringify(t)),"Credentials cannot be screen parameters");var rt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),An=e.array(e.object({variable:rt,componentId:rt,required:e.boolean()}).strict()).max(40).refine(t=>new Set(t.map(n=>n.variable)).size===t.length&&new Set(t.map(n=>n.componentId)).size===t.length,"Input bindings must be unique"),oi=e.object({bindings:An,answers:jn,values:e.record(e.string(),D).optional()}).strict();function it(t,n,i=1){if(t==="free")return"";if(t==="one_time")return n.startsWith("zh")?" \xB7 \u4E00\u6B21\u4ED8\u6B3E":" \xB7 one-time";let r=n.split("-")[0]??"en",a={zh:["/\u6708","/\u5E74"],en:["/month","/year"],ja:["/\u6708","/\u5E74"],ko:["/\uC6D4","/\uB144"],es:["/mes","/a\xF1o"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/m\xEAs","/ano"],it:["/mese","/anno"],ar:["/\u0634\u0647\u0631","/\u0633\u0646\u0629"]},o={zh:"\u5468",en:"week",ja:"\u9031",ko:"\uC8FC",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"\u0623\u0633\u0628\u0648\u0639"},s=t==="week"?`/${o[r]??o.en}`:(a[r]??a.en)[t==="month"?0:1];return i===1?s:`/${i} ${s.slice(1)}${r==="en"?"s":""}`}function fi(t,n){let i=[],r={};P(t,a=>{if(a.hidden)return!1;if(a.type!=="quantity_picker")return;let o=a.bind?.plan?[a.bind.plan]:[];a.bind?.picker&&P(t,s=>{if(s.type==="plan_picker"&&s.id===a.bind?.picker&&o.push(...s.planIds??[]),s.type==="stack"&&s.interaction?.type==="select"&&s.interaction.pickerId===a.bind?.picker)for(let c of s.children)c.type==="stack"&&c.bind?.plan&&o.push(c.bind.plan)}),o.length||i.push(`Quantity control ${a.id} needs a Product binding`);for(let s of new Set(o)){let c=n[s]?.prepaid?.find(d=>d.internalFeatureId===a.internalFeatureId)?.terms,l=r[s]??=new Set;(!c||l.has(a.internalFeatureId)||a.minimumQuantity<c.minimumQuantity||a.maximumQuantity>c.maximumQuantity)&&i.push(`Quantity control ${a.id} must match its Product's prepaid Feature and bounds`),l.add(a.internalFeatureId)}});for(let[a,o]of Object.entries(n))for(let s of o.prepaid??[])r[a]?.has(s.internalFeatureId)||i.push(`Product ${a} needs a quantity control for ${s.internalFeatureId}`);return i}function gi(t,n,i,r){let a=r.plans[n];if(!a?.available)throw new Error("Selected Product is unavailable");let o={};if(P(t,s=>{if(s.hidden)return!1;if(s.type!=="quantity_picker"||s.hidden||(s.bind?.plan??(s.bind?.picker?i[s.bind.picker]:void 0))!==n)return;let l=a.prepaid?.find(u=>u.internalFeatureId===s.internalFeatureId)?.terms,d=i[s.id];if(!l||typeof d!="number"||!Number.isSafeInteger(d)||d<Math.max(l.minimumQuantity,s.minimumQuantity)||d>Math.min(l.maximumQuantity,s.maximumQuantity)||(d-s.minimumQuantity)%s.step!==0||o[s.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");o[s.internalFeatureId]=d}),(a.prepaid??[]).some(s=>o[s.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return o}function vn(t,n,i){let r=t.terms.prices.find(a=>a.currency===n);if(!r||i<t.terms.minimumQuantity||i>t.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:we({quantity:i,unitAmountMinor:r.amountMinor,...r.pricing?{pricing:r.pricing}:{}}),allowance:ze(t.includedAmount,t.terms.units,i)}}function bi(t,n,i,r){let a=!1;if(P(t,c=>{c.type==="quantity_picker"&&(a=!0)}),!a)return n;let o=structuredClone(n);o.quantities={};let s=new Map;P(t,c=>{if(c.hidden)return!1;if(c.type!=="quantity_picker")return;let l=c.bind?.plan??(c.bind?.picker?i[c.bind.picker]??o.pickers[c.bind.picker]?.selected:void 0),d=typeof l=="string"?o.plans[l]:void 0,u=d?.prepaid?.find(at=>at.internalFeatureId===c.internalFeatureId),b=Math.max(c.minimumQuantity,u?.terms.minimumQuantity??0),h=Math.min(c.maximumQuantity,u?.terms.maximumQuantity??0),m=i[c.id]??c.defaultQuantity,p=typeof m=="number"&&Number.isSafeInteger(m)?m:c.defaultQuantity,f=!!u&&!!d?.available&&p>=b&&p<=h&&(p-c.minimumQuantity)%c.step===0,w=o.quantities[c.id]={minimum:b,maximum:Math.max(b,h),step:c.step,value:p,label:"",available:f};if(!f||!u||!d?.currency||d.amountMinor===void 0)return;let M=vn(u,d.currency,p);w.label=`${new Intl.NumberFormat(r).format(Number(M.allowance))} ${u.name}${["week","month","year"].includes(u.reset)?it(u.reset,r,u.resetCount):u.reset==="lifetime"?"":` / ${u.resetCount} ${u.reset}`}`,M.amountMinor!==0&&s.set(String(l),(s.get(String(l))??d.amountMinor)+M.amountMinor)});for(let[c,l]of s){let d=o.plans[c];if(!d?.currency)continue;let u=ie(l,d.currency,r);d.price=u;for(let[b,h]of Object.entries(o.nodes)){let m=be(t,b),p=f=>{if(f.price&&(f.price={...f.price,current:u,original:null}),m?.type==="text"){let w=t.strings.locales[r]?.[m.text]??t.strings.locales[t.strings.defaultLocale]?.[m.text];w?.includes("{{plan.price")&&(f.text=w.replace(/\{\{\s*plan.price\s*\}\}/g,u).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,ie(Math.round(l/((d.interval==="year"?12:1)*(d.intervalCount??1))),d.currency,r)))}};h.byPlan?.[c]&&p(h.byPlan[c]),(h.base.planVersionId===c||m&&"bind"in m&&m.bind?.plan===c)&&p(h.base)}}return o}export{ae as a,we as b,_e as c,ze as d,se as e,Ae as f,Mn as g,ve as h,Qn as i,Ee as j,Le as k,Te as l,Kn as m,Hn as n,ir as o,Xn as p,Ce as q,dt as r,V as s,pe as t,v as u,B as v,y as w,de as x,P as y,xr as z,ge as A,We as B,nn as C,Sr as D,Ir as E,be as F,kr as G,wr as H,D as I,he as J,ee as K,cn as L,yn as M,Lr as N,hn as O,H as P,Tr as Q,Fr as R,et as S,Qr as T,tt as U,N as V,Jr as W,Xr as X,Yr as Y,ii as Z,jn as _,ai as $,An as aa,oi as ba,it as ca,fi as da,gi as ea,bi as fa};
@@ -1,4 +1,4 @@
1
- import{a as $,b as N,c as J,d as q}from"./chunk-OCWSWXCW.js";import{a as P}from"./chunk-3VUPVXAV.js";import{a as D}from"./chunk-AHUYZ6IW.js";import{b as C,c as O,e as j}from"./chunk-O4KXODTJ.js";import{a as _}from"./chunk-DSPLGTQI.js";async function B(e,t,o,n={}){let r=n.message??"Invalid SDK JSON response",s=e.headers.get("content-length");if(!e.ok||!/^application\/json(?:;|$)/i.test(e.headers.get("content-type")??"")||s!==null&&(!/^\d+$/.test(s)||Number(s)>t)||!e.body)throw e.body?.cancel().catch(()=>{}),Error(r);let u;try{u=await P(e,t,{signal:o,error:()=>Error(r)})}catch(p){throw o.aborted?Error(r):p}return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(u))}async function G(e,t){if(!e?.body)return;let o=new AbortController,n=()=>o.abort(t?.reason);t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n();let r=setTimeout(()=>o.abort(Error("Exposure response timeout")),2e3);try{return await P(e,16384,{signal:o.signal,error:()=>Error("Exposure response budget")})}finally{clearTimeout(r),t?.removeEventListener("abort",n)}}var be=2*1024*1024,V=256*1024;async function Y(e,t,o,n){let r=()=>{},s=new Promise((u,p)=>{r=()=>p(n.reason),n.addEventListener("abort",r,{once:!0}),n.aborted&&r()});try{let u=e(t,{...o,signal:n});return u.then(p=>{n.aborted&&p.body?.cancel().catch(()=>{})},()=>{}),await Promise.race([u,s])}finally{n.removeEventListener("abort",r)}}async function M(e,t,o,n=!1){if(new TextEncoder().encode(o).byteLength>65536)throw Error("Exposure request budget");let r=new URL(t);r.searchParams.set("sdkVersion",D.version);let s=new AbortController,u=setTimeout(()=>s.abort(Error("Exposure request timeout")),5e3);try{let p=await Y(e,r.href,{method:"POST",headers:{"Content-Type":"text/plain"},body:o,credentials:"omit",keepalive:n,redirect:"error"},s.signal),a=await G(p,s.signal),c;try{c=a&&JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(a))}catch{}return{response:p,receipt:c}}finally{clearTimeout(u)}}function H(e){let t,o=!1;return{async read(n,r){if(o)throw Error("Experiment client stopped");t?.abort(Error("Experiment request superseded"));let s=new AbortController;t=s;let{signal:u}=s,p=setTimeout(()=>s.abort(Error("Experiment request timeout")),5e3);try{let a=await Y(e,n,{cache:"no-cache",credentials:"omit",redirect:"error"},u),c=await B(a,r,u);return u.throwIfAborted(),c}finally{clearTimeout(p),t===s&&(t=void 0)}},destroy(){o=!0,t?.abort(Error("Experiment client stopped")),t=void 0}}}var Q=20,ie=65536,se=5e3,ae=5,K=e=>new TextEncoder().encode(JSON.stringify(e)).length;function ce(e,t){let o=e,n=r=>Number.isSafeInteger(r)&&r>=0;return!!o&&typeof o=="object"&&n(o.inserted)&&n(o.duplicates)&&n(o.skipped)&&Array.isArray(o.rejected)&&o.inserted+o.duplicates+o.skipped+o.rejected.length===t&&o.rejected.every(r=>!!r&&typeof r=="object"&&n(r.index)&&r.index<t&&typeof r.reason=="string")&&new Set(o.rejected.map(r=>r.index)).size===o.rejected.length}function F(e){let t=[],o,n,r=(a,c)=>{try{e.log?.(`${e.label} ${a}`,c)}catch{}};function s(a){o===void 0&&!n&&t.length&&(o=setTimeout(()=>{p()},a))}async function u(a,c){let g,f;try{({response:g,receipt:f}=await M(e.fetch,e.endpoint,JSON.stringify({events:a}),c))}catch(h){return r("not sent",{error:h}),!1}return g.status===408||g.status===429||g.status>=500?(r("not sent",{status:g.status}),!1):g.ok?ce(f,a.length)?(f.rejected.length&&r("rejected",{rejected:f.rejected}),!0):(r("not acknowledged",{status:g.status}),!1):(r("rejected",{status:g.status,events:a.length}),!0)}function p(a=!0){if(n)return n;clearTimeout(o),o=void 0;let c=[],g=K({events:[]});for(;t.length&&c.length<Q;){let m=K(t[0].event)+(c.length?1:0);if(c.length&&g+m>ie)break;c.push(t.shift()),g+=m}if(!c.length)return Promise.resolve();let f=1e3,h=u(c.map(m=>m.event),a).then(m=>{if(m)return;f=se;let y=c.filter(b=>++b.attempts<ae);y.length<c.length&&r("dropped after retries",{events:c.length-y.length}),t.unshift(...y)}).finally(()=>{n===h&&(n=void 0),s(f)});return n=h,h}return{push(a){t.push({event:structuredClone(a),attempts:0}),t.length>=Q?p():s(1e3)},flush:p}}/*!
1
+ import{a as $,b as N,c as J,d as q}from"./chunk-YJS6NNIO.js";import{a as P}from"./chunk-3VUPVXAV.js";import{a as D}from"./chunk-JBVZ6A6V.js";import{b as C,c as O,e as j}from"./chunk-O4KXODTJ.js";import{a as _}from"./chunk-DSPLGTQI.js";async function B(e,t,o,n={}){let r=n.message??"Invalid SDK JSON response",s=e.headers.get("content-length");if(!e.ok||!/^application\/json(?:;|$)/i.test(e.headers.get("content-type")??"")||s!==null&&(!/^\d+$/.test(s)||Number(s)>t)||!e.body)throw e.body?.cancel().catch(()=>{}),Error(r);let u;try{u=await P(e,t,{signal:o,error:()=>Error(r)})}catch(p){throw o.aborted?Error(r):p}return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(u))}async function G(e,t){if(!e?.body)return;let o=new AbortController,n=()=>o.abort(t?.reason);t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n();let r=setTimeout(()=>o.abort(Error("Exposure response timeout")),2e3);try{return await P(e,16384,{signal:o.signal,error:()=>Error("Exposure response budget")})}finally{clearTimeout(r),t?.removeEventListener("abort",n)}}var be=2*1024*1024,V=256*1024;async function Y(e,t,o,n){let r=()=>{},s=new Promise((u,p)=>{r=()=>p(n.reason),n.addEventListener("abort",r,{once:!0}),n.aborted&&r()});try{let u=e(t,{...o,signal:n});return u.then(p=>{n.aborted&&p.body?.cancel().catch(()=>{})},()=>{}),await Promise.race([u,s])}finally{n.removeEventListener("abort",r)}}async function M(e,t,o,n=!1){if(new TextEncoder().encode(o).byteLength>65536)throw Error("Exposure request budget");let r=new URL(t);r.searchParams.set("sdkVersion",D.version);let s=new AbortController,u=setTimeout(()=>s.abort(Error("Exposure request timeout")),5e3);try{let p=await Y(e,r.href,{method:"POST",headers:{"Content-Type":"text/plain"},body:o,credentials:"omit",keepalive:n,redirect:"error"},s.signal),a=await G(p,s.signal),c;try{c=a&&JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(a))}catch{}return{response:p,receipt:c}}finally{clearTimeout(u)}}function H(e){let t,o=!1;return{async read(n,r){if(o)throw Error("Experiment client stopped");t?.abort(Error("Experiment request superseded"));let s=new AbortController;t=s;let{signal:u}=s,p=setTimeout(()=>s.abort(Error("Experiment request timeout")),5e3);try{let a=await Y(e,n,{cache:"no-cache",credentials:"omit",redirect:"error"},u),c=await B(a,r,u);return u.throwIfAborted(),c}finally{clearTimeout(p),t===s&&(t=void 0)}},destroy(){o=!0,t?.abort(Error("Experiment client stopped")),t=void 0}}}var Q=20,ie=65536,se=5e3,ae=5,K=e=>new TextEncoder().encode(JSON.stringify(e)).length;function ce(e,t){let o=e,n=r=>Number.isSafeInteger(r)&&r>=0;return!!o&&typeof o=="object"&&n(o.inserted)&&n(o.duplicates)&&n(o.skipped)&&Array.isArray(o.rejected)&&o.inserted+o.duplicates+o.skipped+o.rejected.length===t&&o.rejected.every(r=>!!r&&typeof r=="object"&&n(r.index)&&r.index<t&&typeof r.reason=="string")&&new Set(o.rejected.map(r=>r.index)).size===o.rejected.length}function F(e){let t=[],o,n,r=(a,c)=>{try{e.log?.(`${e.label} ${a}`,c)}catch{}};function s(a){o===void 0&&!n&&t.length&&(o=setTimeout(()=>{p()},a))}async function u(a,c){let g,f;try{({response:g,receipt:f}=await M(e.fetch,e.endpoint,JSON.stringify({events:a}),c))}catch(h){return r("not sent",{error:h}),!1}return g.status===408||g.status===429||g.status>=500?(r("not sent",{status:g.status}),!1):g.ok?ce(f,a.length)?(f.rejected.length&&r("rejected",{rejected:f.rejected}),!0):(r("not acknowledged",{status:g.status}),!1):(r("rejected",{status:g.status,events:a.length}),!0)}function p(a=!0){if(n)return n;clearTimeout(o),o=void 0;let c=[],g=K({events:[]});for(;t.length&&c.length<Q;){let m=K(t[0].event)+(c.length?1:0);if(c.length&&g+m>ie)break;c.push(t.shift()),g+=m}if(!c.length)return Promise.resolve();let f=1e3,h=u(c.map(m=>m.event),a).then(m=>{if(m)return;f=se;let y=c.filter(b=>++b.attempts<ae);y.length<c.length&&r("dropped after retries",{events:c.length-y.length}),t.unshift(...y)}).finally(()=>{n===h&&(n=void 0),s(f)});return n=h,h}return{push(a){t.push({event:structuredClone(a),attempts:0}),t.length>=Q?p():s(1e3)},flush:p}}/*!
2
2
  Portions ported from GrowthBook sdk-js @ ed29827 (GrowthBook.ts auto experiments, util.ts mergeQueryStrings,
3
3
  plugins/auto-attributes.ts). Copyright (c) GrowthBook, Inc. MIT License.
4
4
  */function ue(e,t){let o,n;try{o=new URL(e),n=new URL(t)}catch{return t}return o.searchParams.forEach((r,s)=>{n.searchParams.has(s)||n.searchParams.set(s,r)}),n.toString()}function de(e,t){let o=navigator.userAgent,n=new URLSearchParams(t.search),r={};for(let s of["source","medium","campaign","term","content"]){let u=n.get(`utm_${s}`);u!==null&&(r[`utm${s[0].toUpperCase()}${s.slice(1)}`]=u)}return{id:e,deviceId:e,url:t.href,path:t.pathname,host:t.host,query:t.search,pageTitle:typeof document>"u"?"":document.title,browser:/Edg/.test(o)?"edge":/Chrome/.test(o)?"chrome":/Firefox/.test(o)?"firefox":/Safari/.test(o)?"safari":"unknown",deviceType:/Mobi/.test(o)?"mobile":"desktop",...r}}function le(e){let t=e;if(!(!!t&&typeof t=="object"&&typeof t.environmentId=="string"&&typeof t.trackExposures=="boolean"&&/^[a-f0-9]{64}$/.test(t.generation??"")&&Array.isArray(t.experiments)&&t.experiments.length<=100&&t.experiments.every(n=>!!n&&!["namespace","status","url","groups"].some(r=>Object.hasOwn(n,r))&&(n.hashVersion===void 0||n.hashVersion===2)&&typeof n.key=="string"&&Array.isArray(n.variations)&&n.variations.length>=2&&n.variations.every(r=>!!r&&typeof r.urlRedirect=="string")&&(n.urlPatterns===void 0||Array.isArray(n.urlPatterns)))&&!!t.savedGroups&&typeof t.savedGroups=="object"&&!Array.isArray(t.savedGroups)))throw new Error("Invalid page experiment payload");return t}function Te(e){if(e.configuration&&e.configuration.scope.environmentId!==e.environmentId)throw new Error("Page configuration belongs to another App environment");let t=J(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("environmentId must be the App environment ID");let o=e.fetch??globalThis.fetch.bind(globalThis),n=H(async(i,d)=>{let l=await o(i,d);if(!l.ok)throw l.body?.cancel().catch(()=>{}),new Error(`Page experiments unavailable (${l.status})`);return l}),r=e.log?(i,d)=>_(e.log,i,d):void 0,s=`${t}/api/v1/page-experiments/${e.environmentId}`,u=$(e.deviceIdCookie??"indiana_did"),p=N(),a=null,c={...e.attributes??{}},g="",f=!1,h=!1,m=0,y=0,b=new Map,S=F({endpoint:`${s}/events`,fetch:o,log:r,label:"Exposure"}),k=S.flush,E={trackedExperiments:new Set,log:r,onExperimentViewed:(i,d)=>{e.trackExposures===!1||a?.trackExposures===!1||S.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:u,...p?{sessionId:p}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:i.key,variationKey:d.key})}},z=()=>{E.url=location.href,E.attributes={...de(u,location),...c}};function W(i){if(!e.disableCrossOriginUrlRedirects)return!1;try{let d=new URL(location.href);return i.variations.some(l=>{if(!l.urlRedirect)return!1;let v=new URL(l.urlRedirect);return v.protocol!==d.protocol||v.host!==d.host})}catch{return!0}}function X(i,d){let l=e.configuration?.snapshot?.generation,v=y,te=location.href;g=i;let re=e.navigate??(w=>location.replace(w)),ne=e.navigateDelay??(e.navigate?0:100),oe=e.maxNavigateDelay??1e3;Promise.all([Promise.race([d,new Promise(w=>setTimeout(w,oe))]),new Promise(w=>setTimeout(w,ne))]).then(()=>{!f&&v===y&&location.href===te&&(!e.configuration||e.configuration.fresh&&e.configuration.snapshot?.generation===l)&&re(i)})}function x(){if(!(!a||f||e.configuration&&!e.configuration.fresh)){z();for(let i of a.experiments){if(W(i)){r?.("Auto experiment blocked",{id:i.key});continue}let d;try{d=j(i,E)}catch(l){r?.("Skipping page experiment",{id:i.key,error:String(l)});continue}if(b.set(i.key,d),!!d.inExperiment){if(d.value.urlRedirect){let l=i.persistQueryString?ue(location.href,d.value.urlRedirect):d.value.urlRedirect;C(l,i.urlPatterns??[])?r?.("Skipping redirect because original URL matches redirect URL",{id:i.key}):l!==g&&X(l,k())}break}}}}let R="",Z=()=>{location.href!==R&&(y++,R=location.href,g="",x())},T,L;function ee(){T??=q(Z),addEventListener("pagehide",I)}let I=()=>{k()};async function A(){if(f)return!1;let i=++m,d;try{d=e.configuration?await e.configuration.pageExperiments():await n.read(s,V)}catch(v){if(f||i!==m)return!1;throw v}if(f||i!==m)return!1;let l=le(d);if(l.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Page experiment payload scope changed");return a?.trackExposures===!1&&l.trackExposures&&E.trackedExperiments?.clear(),a=l,E.savedGroups=O(l.savedGroups),!0}function U(){f||(L??=e.configuration?.subscribe(()=>{!f&&e.configuration?.fresh&&A().then(i=>{i&&x()}).catch(i=>r?.("Page configuration unavailable",{error:String(i)}))}),ee(),R=location.href)}return{async start(){h||f||(h=!0,await A()&&(U(),x()))},async refresh(){await A()&&(y++,h&&U(),g="",x())},setAttributes(i){y++,g="",c={...i},x()},getResults(){return new Map(b)},get generation(){return a?.generation??null},destroy(){f||(f=!0,m++,n.destroy(),L?.(),T?.(),removeEventListener("pagehide",I),a=null,b.clear(),k())}}}export{be as a,H as b,F as c,ue as d,de as e,le as f,Te as g};
@@ -1 +1 @@
1
- import{k as c}from"./chunk-WZMZMJCK.js";import{b as r}from"./chunk-CR2XJ2CX.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};
1
+ import{k as c}from"./chunk-BIT6YWM7.js";import{b as r}from"./chunk-NOOIJXRN.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};
@@ -1 +1 @@
1
- import{a as m,m as f,p as y}from"./chunk-GH6FM44P.js";import{g as d}from"./chunk-WZMZMJCK.js";import{e as l,f as u,j as p}from"./chunk-T2KWLYCW.js";import{b as e}from"./chunk-CR2XJ2CX.js";var h={funnelId:e.uuid().optional(),funnelVersionId:e.uuid().optional()};var w=e.strictObject({runId:e.uuid(),bindingId:e.uuid(),receiptId:e.uuid()});var q=e.strictObject({processContext:w.optional(),...h,selector:e.discriminatedUnion("type",[e.strictObject({type:e.literal("paywall"),paywallId:e.uuid()}),e.strictObject({type:e.literal("version"),versionId:e.uuid()})]),customerId:e.uuid().optional(),commerce:l,locale:e.string().min(1).max(35),requirement:u.optional()}),c=e.strictObject({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),document:m.omit({requirement:!0,offeringId:!0}),offering:e.strictObject({id:e.uuid()}),content:e.strictObject({environmentId:e.uuid(),offeringVersionId:e.uuid(),artifact:y.refine(n=>n.kind==="paywall"&&n.formatVersion===1)}).optional(),capabilities:d,check:p.nullable()}).superRefine((n,r)=>{let t=new Set(n.document.products.items.map(o=>o.productVersionId));(n.document.offeringVersionId!==n.offering.id||Object.values(n.capabilities.plans).some(o=>!t.has(o.versionId)))&&r.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),M=e.strictObject(c.shape).omit({document:!0,offering:!0}).extend({content:c.shape.content.unwrap()});function _(n,r){let t=f.parse(r);if(t.offeringVersionId!==n.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let o=structuredClone(n.capabilities);for(let[g,i]of Object.entries(t.catalog)){let a=o.plans[g],s=i.channels.stripe?.prices.find(I=>I.currency===a?.currency);a&&s&&Object.assign(a,{amountMinor:s.amountMinor,interval:i.interval,intervalCount:i.intervalCount,...i.prepaid?.length?{prepaid:i.prepaid}:{}})}return c.parse({...n,capabilities:o,document:{schemaVersion:3,kind:t.kind,name:t.name,presentation:t.presentation,products:t.products,offeringVersionId:t.offeringVersionId,screen:t.screen,buttons:t.buttons},offering:{id:t.offeringVersionId}})}export{h as a,w as b,q as c,c as d,M as e,_ as f};
1
+ import{a as m,m as f,p as y}from"./chunk-W3G4YIM5.js";import{g as d}from"./chunk-BIT6YWM7.js";import{e as l,f as u,j as p}from"./chunk-2Y5SGDC6.js";import{b as e}from"./chunk-NOOIJXRN.js";var h={funnelId:e.uuid().optional(),funnelVersionId:e.uuid().optional()};var w=e.strictObject({runId:e.uuid(),bindingId:e.uuid(),receiptId:e.uuid()});var q=e.strictObject({processContext:w.optional(),...h,selector:e.discriminatedUnion("type",[e.strictObject({type:e.literal("paywall"),paywallId:e.uuid()}),e.strictObject({type:e.literal("version"),versionId:e.uuid()})]),customerId:e.uuid().optional(),commerce:l,locale:e.string().min(1).max(35),requirement:u.optional()}),c=e.strictObject({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),document:m.omit({requirement:!0,offeringId:!0}),offering:e.strictObject({id:e.uuid()}),content:e.strictObject({environmentId:e.uuid(),offeringVersionId:e.uuid(),artifact:y.refine(n=>n.kind==="paywall"&&n.formatVersion===1)}).optional(),capabilities:d,check:p.nullable()}).superRefine((n,r)=>{let t=new Set(n.document.products.items.map(o=>o.productVersionId));(n.document.offeringVersionId!==n.offering.id||Object.values(n.capabilities.plans).some(o=>!t.has(o.versionId)))&&r.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),M=e.strictObject(c.shape).omit({document:!0,offering:!0}).extend({content:c.shape.content.unwrap()});function _(n,r){let t=f.parse(r);if(t.offeringVersionId!==n.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let o=structuredClone(n.capabilities);for(let[g,i]of Object.entries(t.catalog)){let a=o.plans[g],s=i.channels.stripe?.prices.find(I=>I.currency===a?.currency);a&&s&&Object.assign(a,{amountMinor:s.amountMinor,interval:i.interval,intervalCount:i.intervalCount,...i.prepaid?.length?{prepaid:i.prepaid}:{}})}return c.parse({...n,capabilities:o,document:{schemaVersion:3,kind:t.kind,name:t.name,presentation:t.presentation,products:t.products,offeringVersionId:t.offeringVersionId,screen:t.screen,buttons:t.buttons},offering:{id:t.offeringVersionId}})}export{h as a,w as b,q as c,c as d,M as e,_ as f};