@tinkerlandai/longplay-sdk 0.10.36 → 0.10.37

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 (87) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +8 -0
  3. package/README.zh-CN.md +8 -0
  4. package/dist/check-response-N22NNTIT.js +1 -0
  5. package/dist/chunk-2HBIBIOF.js +1 -0
  6. package/dist/{chunk-VWMFR22O.js → chunk-2KJLN65C.js} +1 -1
  7. package/dist/{chunk-VKG6BB3Z.js → chunk-2VMEDQHT.js} +1 -1
  8. package/dist/{chunk-5XKFUFXK.js → chunk-4KLXQKNO.js} +1 -1
  9. package/dist/{chunk-IOBB6KFK.js → chunk-6F4JS3RK.js} +1 -1
  10. package/dist/{chunk-HVVJGLYZ.js → chunk-7XDQKZYA.js} +1 -1
  11. package/dist/{chunk-35VG2IYD.js → chunk-AB7GEGZ2.js} +1 -1
  12. package/dist/{chunk-RHF4NFCZ.js → chunk-AHUYZ6IW.js} +1 -1
  13. package/dist/{chunk-YQX27SBG.js → chunk-AOGDCT4T.js} +1 -1
  14. package/dist/{chunk-MHWPEMX7.js → chunk-CY7OKV7E.js} +1 -1
  15. package/dist/{chunk-2HSD2SEU.js → chunk-D3OYXTMC.js} +1 -1
  16. package/dist/chunk-DDLSQSWO.js +10 -0
  17. package/dist/{chunk-RHWZRHK7.js → chunk-E7CCHUSO.js} +1 -1
  18. package/dist/{chunk-U4WUX3WB.js → chunk-ECKVJGXQ.js} +1 -1
  19. package/dist/chunk-GH6FM44P.js +1 -0
  20. package/dist/{chunk-DHT3AWJQ.js → chunk-HEHLFHW7.js} +1 -1
  21. package/dist/chunk-HKXFCRVT.js +1 -0
  22. package/dist/chunk-KFIL73QY.js +1 -0
  23. package/dist/{chunk-UHTTCVSL.js → chunk-LC6UCDWE.js} +1 -1
  24. package/dist/{chunk-LAGGWYH3.js → chunk-LOLMUXHW.js} +1 -1
  25. package/dist/{chunk-LVG5ED52.js → chunk-OCWSWXCW.js} +1 -1
  26. package/dist/{chunk-BL7E4RZ2.js → chunk-OQRMAU2B.js} +1 -1
  27. package/dist/{chunk-5XIKN35D.js → chunk-OX2A3UD2.js} +1 -1
  28. package/dist/{chunk-BTPEXSNY.js → chunk-PW5PIBSO.js} +1 -1
  29. package/dist/chunk-Q676H74B.js +1 -0
  30. package/dist/{chunk-MYBUQFTC.js → chunk-RE4OLOOT.js} +1 -1
  31. package/dist/{chunk-2KKLY323.js → chunk-S43TYW3V.js} +1 -1
  32. package/dist/{chunk-XE7GU6FZ.js → chunk-T2KWLYCW.js} +1 -1
  33. package/dist/chunk-TASEZY5T.js +1 -0
  34. package/dist/{chunk-TIQS5DUF.js → chunk-U7NX5ET2.js} +1 -1
  35. package/dist/{chunk-XQTCEQXI.js → chunk-UV4H6VCS.js} +1 -1
  36. package/dist/{chunk-UVUFJO2V.js → chunk-VIBJNB5B.js} +1 -1
  37. package/dist/chunk-VLSP3LRH.js +1 -0
  38. package/dist/{chunk-R3YVDRTB.js → chunk-W74JLL2O.js} +1 -1
  39. package/dist/chunk-WQ3O5RXN.js +1 -0
  40. package/dist/{chunk-QHJWVLJC.js → chunk-WZMZMJCK.js} +1 -1
  41. package/dist/{chunk-I6D25FWU.js → chunk-XGNXZWZL.js} +1 -1
  42. package/dist/{chunk-ZYF6TRJ3.js → chunk-XJRDO3NI.js} +1 -1
  43. package/dist/chunk-YV6UFESO.js +1 -0
  44. package/dist/{chunk-M3GGR53D.js → chunk-ZYOZSUZS.js} +1 -1
  45. package/dist/{chunk-HS56A4IK.js → chunk-ZZIBLQCJ.js} +1 -1
  46. package/dist/content-QNBATPA2.js +1 -0
  47. package/dist/{funnel-host-purchase-M7MM33EC.js → funnel-host-purchase-FVYPBPET.js} +1 -1
  48. package/dist/funnel-paywall-prerender-Z7RA4YDY.js +1 -0
  49. package/dist/funnel-runtime-host-TJPF3FJS.js +1 -0
  50. package/dist/index.d.ts +23 -3
  51. package/dist/index.js +1 -1
  52. package/dist/merchant-bridge-contracts-67AYXZFI.js +1 -0
  53. package/dist/native-shell.js +1 -1
  54. package/dist/openrouter.js +1 -1
  55. package/dist/operation-contracts-EK4RCUWJ.js +1 -0
  56. package/dist/page.js +1 -1
  57. package/dist/paywall-OAVC654P.js +1 -0
  58. package/dist/paywall-content-75XEM7K3.js +1 -0
  59. package/dist/paywall-session-U6SPRJRS.js +1 -0
  60. package/dist/popup.d.ts +1 -1
  61. package/dist/popup.js +1 -1
  62. package/dist/react-native.js +1 -1
  63. package/dist/screen-renderer-YIIT742O.js +1 -0
  64. package/dist/server.js +1 -1
  65. package/dist/visual.js +1 -1
  66. package/package.json +10 -9
  67. package/dist/check-response-DHY6T5Z2.js +0 -1
  68. package/dist/chunk-7ZEXY4GC.js +0 -1
  69. package/dist/chunk-C4GBV32U.js +0 -10
  70. package/dist/chunk-CGXNU5BC.js +0 -1
  71. package/dist/chunk-DB4EO3JG.js +0 -1
  72. package/dist/chunk-GLYFT5WW.js +0 -1
  73. package/dist/chunk-HYE2YQYM.js +0 -1
  74. package/dist/chunk-JOIPLLHK.js +0 -1
  75. package/dist/chunk-OL2AI6DA.js +0 -1
  76. package/dist/chunk-W3K5ARMY.js +0 -1
  77. package/dist/chunk-WRLVPHPE.js +0 -1
  78. package/dist/content-RGKTEV23.js +0 -1
  79. package/dist/funnel-paywall-prerender-OSBI4VMY.js +0 -1
  80. package/dist/funnel-runtime-host-AMJXEASH.js +0 -1
  81. package/dist/merchant-bridge-contracts-GJQVKEAG.js +0 -1
  82. package/dist/operation-contracts-MFK2KORK.js +0 -1
  83. package/dist/paywall-ATZ2IZPS.js +0 -1
  84. package/dist/paywall-content-XERXGNND.js +0 -1
  85. package/dist/paywall-session-EMMF6IYS.js +0 -1
  86. package/dist/screen-renderer-B7LUTPTJ.js +0 -1
  87. /package/dist/{chunk-ZYN4CRHS.js → chunk-CR2XJ2CX.js} +0 -0
@@ -0,0 +1 @@
1
+ import{a as ge}from"./chunk-WQ3O5RXN.js";import{a as Le}from"./chunk-XJRDO3NI.js";import{$ as B,A as Z,B as xe,C as et,F as Se,I as v,J as N,K as G,L as W,M as Q,Z as tt,_ as X,f as Ze,g as We,h as Qe,q as Xe,s as be,t as Ye,y as H,z as J}from"./chunk-WZMZMJCK.js";import{a as he,b as He,c as Je}from"./chunk-T2KWLYCW.js";import{b as U}from"./chunk-HEHLFHW7.js";import{b as e}from"./chunk-CR2XJ2CX.js";var nt={"zh-Hans":{merchandise:"\u51CF {discount}\uFF08\u5355\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u51CF {discount}",repeating:"\u524D {months} \u4E2A\u6708\u6BCF\u6708\u51CF {discount}",forever:"\u6BCF\u671F\u51CF {discount}"},"zh-Hant":{merchandise:"\u6E1B {discount}\uFF08\u55AE\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u6E1B {discount}",repeating:"\u524D {months} \u500B\u6708\u6BCF\u6708\u6E1B {discount}",forever:"\u6BCF\u671F\u6E1B {discount}"},en:{merchandise:"{discount} off \xB7 one use",once:"{discount} off your first payment",repeating:"{discount} off each month for the first {months} months",repeatingOne:"{discount} off the first month",forever:"{discount} off every payment"},ja:{merchandise:"{discount} \u5272\u5F15\uFF081\u56DE\u306E\u307F\uFF09",once:"\u521D\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15",repeating:"\u6700\u521D\u306E {months} \u304B\u6708\u9593\u3001\u6BCE\u6708 {discount} \u5272\u5F15",forever:"\u6BCE\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15"},ko:{merchandise:"{discount} \uD560\uC778 \xB7 1\uD68C \uC0AC\uC6A9",once:"\uCCAB \uACB0\uC81C {discount} \uD560\uC778",repeating:"\uCCAB {months}\uAC1C\uC6D4 \uB3D9\uC548 \uB9E4\uC6D4 {discount} \uD560\uC778",forever:"\uB9E4 \uACB0\uC81C {discount} \uD560\uC778"},es:{merchandise:"{discount} de descuento \xB7 un uso",once:"{discount} de descuento en el primer pago",repeating:"{discount} de descuento cada mes durante los primeros {months} meses",forever:"{discount} de descuento en cada pago",repeatingOne:"{discount} de descuento durante el primer mes"},fr:{merchandise:"{discount} de r\xE9duction \xB7 une utilisation",once:"{discount} de r\xE9duction sur le premier paiement",repeating:"{discount} de r\xE9duction par mois pendant les {months} premiers mois",forever:"{discount} de r\xE9duction sur chaque paiement",repeatingOne:"{discount} de r\xE9duction pendant le premier mois"},de:{merchandise:"{discount} Rabatt \xB7 einmalig",once:"{discount} Rabatt auf die erste Zahlung",repeating:"{discount} Rabatt pro Monat f\xFCr die ersten {months} Monate",forever:"{discount} Rabatt auf jede Zahlung",repeatingOne:"{discount} Rabatt im ersten Monat"},pt:{merchandise:"{discount} de desconto \xB7 um uso",once:"{discount} de desconto no primeiro pagamento",repeating:"{discount} de desconto por m\xEAs nos primeiros {months} meses",forever:"{discount} de desconto em cada pagamento",repeatingOne:"{discount} de desconto no primeiro m\xEAs"},it:{merchandise:"{discount} di sconto \xB7 un utilizzo",once:"{discount} di sconto sul primo pagamento",repeating:"{discount} di sconto al mese per i primi {months} mesi",forever:"{discount} di sconto su ogni pagamento",repeatingOne:"{discount} di sconto per il primo mese"},ru:{merchandise:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \xB7 \u043E\u0434\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435",once:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436",repeating:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",repeatingOne:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u0432 \u043F\u0435\u0440\u0432\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",forever:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043A\u0430\u0436\u0434\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436"},vi:{merchandise:"Gi\u1EA3m {discount} \xB7 d\xF9ng m\u1ED9t l\u1EA7n",once:"Gi\u1EA3m {discount} cho l\u1EA7n thanh to\xE1n \u0111\u1EA7u ti\xEAn",repeating:"Gi\u1EA3m {discount} m\u1ED7i th\xE1ng trong {months} th\xE1ng \u0111\u1EA7u",forever:"Gi\u1EA3m {discount} cho m\u1ED7i l\u1EA7n thanh to\xE1n"},th:{merchandise:"\u0E25\u0E14 {discount} \xB7 \u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E04\u0E23\u0E31\u0E49\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27",once:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01",repeating:"\u0E25\u0E14 {discount} \u0E15\u0E48\u0E2D\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",forever:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E17\u0E38\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07"},id:{merchandise:"Diskon {discount} \xB7 sekali pakai",once:"Diskon {discount} untuk pembayaran pertama",repeating:"Diskon {discount} setiap bulan selama {months} bulan pertama",forever:"Diskon {discount} untuk setiap pembayaran"},ar:{merchandise:"\u062E\u0635\u0645 {discount} \xB7 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0648\u0627\u062D\u062F",once:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u062F\u0641\u0639\u0629 \u0627\u0644\u0623\u0648\u0644\u0649",repeating:"\u062E\u0635\u0645 {discount} \u0634\u0647\u0631\u064A\u064B\u0627 \u0644\u0645\u062F\u0629 {period}",forever:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0643\u0644 \u062F\u0641\u0639\u0629"}};function ve(t){let r=Ye(t)??"en",n=r.split("-"),s=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(a=>["TW","HK","MO"].includes(a))?"zh-Hant":"zh-Hans":n[0]??"en",i=nt[s];return i?{locale:r,copy:i}:{locale:"en",copy:nt.en}}function Tt(t,r,n="zh-CN"){let s=He(r);return Je(t,r,ve(n).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:t%10**s===0?0:s,maximumFractionDigits:s})}function Ut(t,r="zh-CN"){let n=ve(r).locale;return t.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:2}).format(t.percentOff/100):Tt(t.amountOffCents,t.currency,n)}var rt={zh:"\u524D {months} \u4E2A\u6708\u5185\u5F00\u51FA\u7684\u8D26\u5355\u51CF {discount}","zh-Hant":"\u524D {months} \u500B\u6708\u5167\u958B\u51FA\u7684\u5E33\u55AE\u6E1B {discount}",en:"{discount} off invoices issued within the first {months} months",ja:"\u6700\u521D\u306E {months} \u304B\u6708\u4EE5\u5185\u306E\u8ACB\u6C42\u304C {discount} \u5272\u5F15",ko:"\uCCAB {months}\uAC1C\uC6D4 \uB0B4 \uCCAD\uAD6C\uC11C {discount} \uD560\uC778",es:"{discount} de descuento en facturas emitidas durante los primeros {months} meses",fr:"{discount} de r\xE9duction sur les factures \xE9mises pendant les {months} premiers mois",de:"{discount} Rabatt auf Rechnungen innerhalb der ersten {months} Monate",pt:"{discount} de desconto nas faturas emitidas nos primeiros {months} meses",it:"{discount} di sconto sulle fatture emesse nei primi {months} mesi",ru:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u0441\u0447\u0435\u0442\u0430 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",vi:"Gi\u1EA3m {discount} cho h\xF3a \u0111\u01A1n trong {months} th\xE1ng \u0111\u1EA7u",th:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E43\u0E1A\u0E41\u0E08\u0E49\u0E07\u0E2B\u0E19\u0E35\u0E49\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",id:"Diskon {discount} untuk tagihan dalam {months} bulan pertama",ar:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u0641\u0648\u0627\u062A\u064A\u0631 \u0627\u0644\u0635\u0627\u062F\u0631\u0629 \u062E\u0644\u0627\u0644 \u0623\u0648\u0644 {period}"};function Mn(t,r="zh-CN",n="month"){let s=ve(r),i=Ut(t.discount,s.locale);if(t.appliesTo?.type==="merchandise")return s.copy.merchandise.replace("{discount}",i);let a=t.duration.type==="repeating"?new Intl.NumberFormat(s.locale).format(t.duration.months):"",u=s.locale.split("-")[0]??"en",c=u==="zh"&&/(?:Hant|TW|HK|MO)/.test(s.locale)?"zh-Hant":u,f=t.duration.type==="repeating"&&n!=="month"?rt[c]??rt.en:t.duration.type==="repeating"&&t.duration.months===1?s.copy.repeatingOne??s.copy.repeating:s.copy[t.duration.type],g=t.duration.type==="repeating"?new Intl.NumberFormat(s.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(t.duration.months):"";return f.replace("{discount}",i).replace("{months}",a).replace("{period}",g)}var I=e.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_.:-]*$/).refine(t=>t.split(".").every(r=>r.length>0&&!["__proto__","constructor","prototype"].includes(r)),"Reserved or empty variable path"),we=e.strictObject({type:e.enum(["string","number","boolean","strings","json","offering_version","reward","paywall_version"]),nullable:e.boolean(),enum:e.array(e.string().max(255)).min(1).max(100).optional()}),Y=we.extend({type:e.enum([...we.shape.type.options,"array"]),items:we.optional()}).superRefine((t,r)=>{(t.type==="array"!=!!t.items||t.enum&&t.type!=="string"||t.items?.enum&&t.items.type!=="string")&&r.addIssue({code:"custom",message:"Array requires items; only strings support enum"})}),ee=Y.safeExtend({source:e.discriminatedUnion("type",[e.strictObject({type:e.literal("input")}),e.strictObject({type:e.literal("node")}),e.strictObject({type:e.enum(["parameter","attribute"]),key:I})])}),Bn=e.record(I,ee),Ie=e.record(I,I).refine(t=>Object.keys(t).length<=20);function P(t,r){return t?r===null?t.nullable:t.enum&&(typeof r!="string"||!t.enum.includes(r))?!1:t.type==="array"?Array.isArray(r)&&r.length<=100&&!!t.items&&r.every(n=>P(t.items,n)):["offering_version","reward","paywall_version"].includes(t.type)?typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===2&&r.type===t.type&&e.uuid().safeParse(r.id).success:t.type==="json"||(t.type==="strings"?Array.isArray(r)&&r.every(n=>typeof n=="string"):typeof r===t.type):!1}function Oe(t,r){return t.nullable&&!r.nullable?!1:r.type==="json"?!0:t.type!==r.type||r.enum&&(!t.enum||t.enum.some(n=>!r.enum.includes(n)))?!1:t.type!=="array"||!!t.items&&!!r.items&&Oe(t.items,r.items)}function te(t,r){let n={};for(let[s,i]of Object.entries(t)){let a=i.source,u=a.type==="input"?r.answers:a.type==="node"?r.results??{}:a.type==="parameter"?r.parameters:r.attributes,c=a.type==="parameter"||a.type==="attribute"?a.key:s,f=Object.hasOwn(u,c),g=u[c];if(a.type==="attribute"&&c.includes(".")&&(!f||c.startsWith("merchandise."))){g=u,f=!0;for(let l of c.split(".")){if(!g||typeof g!="object"||!Object.hasOwn(g,l)||Array.isArray(g)&&(!/^(0|[1-9]\d*)$/.test(l)||Number(l)>=g.length)){f=!1;break}g=g[l]}}if(!(!f||g===void 0)){if(!P(i,g))throw new Error(`Invalid variable value: ${s}`);n[s]=g}}return n}function $n(t,r){let n={};for(let[s,i]of Object.entries(t.writes??{})){if(!Object.hasOwn(r,s))throw new Error(`Node output is missing: ${s}`);if(Object.hasOwn(n,i))throw new Error("Node outputs cannot overwrite one another");n[i]=r[s]}return n}function Gn(t,r,n){let s=new Set(Object.values(r.writes??{}));for(let[i,a]of Object.entries(n))if(!s.has(i)||t[i]?.source.type!=="node"||!P(t[i],a))throw new Error(`Invalid node variable write: ${i}`);if(s.size!==Object.keys(n).length)throw new Error("Node output is incomplete")}var R=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(r=>!["__proto__","constructor","prototype"].includes(r)),"Reserved value path"),E=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:v}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:R.optional()})]);function it(t,r){if(!r)return t;for(let n of R.parse(r).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function Bt(t,r){if(t.source==="literal")return structuredClone(t.value);let n=te(r.declarations,r);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(v.parse(it(n[t.key],t.path)))}function je(t,r){let n=[...r].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!R.safeParse(s).success?null:{key:n,path:s}}function ke(t){let r=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return H(t,n=>{n.type==="custom_html"&&r.push(...Object.values(n.html))}),[...new Set(r.flatMap(Qe))]}function ot(t){return ke(t).filter(r=>r.startsWith("variables.")).map(r=>r.slice(10))}function M(t){let r=JSON.stringify(t);if(r===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(r).length,s=!1;for(let i=0;i<r.length;i++){let a=r.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let u=i;for(;i+1<r.length&&/[0-9.eE+-]/.test(r.charAt(i+1));)i++;let c=r.slice(u,i+1);if(!/[eE]/.test(c))continue;let[f="",g]=c.split(/[eE]/),l=f.replace(/^-/,""),w=l.replace(".","").length,K=(l.includes(".")?l.indexOf("."):w)+Number(g),y=K<=0?2-K+w:K>=w?K:w+1;n+=y+(f.startsWith("-")?1:0)-c.length}}return n}function F(t){let r=new Set,n=a=>a!==null&&typeof a=="object"&&!Array.isArray(a);function s(a,u){if(n(a))for(let[c,f]of Object.entries(a))c==="$elemMatch"?i(f,u):c==="$not"?s(f,u):c==="$all"&&Array.isArray(f)&&f.forEach(g=>s(g,u))}function i(a,u=""){if(n(a)){for(let[c,f]of Object.entries(a))if(["$and","$or","$nor"].includes(c)&&Array.isArray(f))f.forEach(g=>i(g,u));else if(c==="$not")i(f,u);else if(c==="$savedGroup"&&n(f))typeof f.attributeKey=="string"&&r.add(f.attributeKey);else if(!c.startsWith("$")){let g=u?`${u}.${c}`:c;r.add(g),s(f,g)}}}return i(t),[...r]}var $t=e.enum(["active","inactive"]),Gt=e.preprocess((t,r)=>{let n=0;function s(i,a){if(!(++n>1e4||a>20)){if(Array.isArray(i))i.forEach(u=>s(u,a+1));else if(i&&typeof i=="object")for(let[u,c]of Object.entries(i))["__proto__","constructor","prototype"].includes(u)&&r.addIssue({code:"custom",message:"Reserved merchandise attribute"}),s(c,a+1)}}return s(t,0),t},N),qt=e.strictObject({id:e.string().trim().min(1).max(255),name:e.string().trim().min(1).max(255),status:$t,metadata:Gt}),sr=qt.extend({internal_id:e.uuid(),project_id:e.uuid(),environment_id:e.uuid(),created_at:e.iso.datetime({offset:!0}),updated_at:e.iso.datetime({offset:!0})}),ar=e.union([e.strictObject({id:e.string().trim().min(1).max(255)}),e.strictObject({internalId:e.uuid()})]),cr=e.enum(["customer","merchandise","context"]),ur=e.enum(["system","stored","request"]),lr=e.enum(["customer","merchandise","mixed"]),st=t=>t==="merchandiseId"||t==="merchandise"||t.startsWith("merchandise.");function Ae(t,r={},n=new Set){if(F(t).some(st))return!0;for(let s of W(t)){if(n.has(s))continue;n.add(s);let i=r[s];if(i?.type==="list"&&st(i.attributeKey)||i?.type==="condition"&&Ae(i.condition,r,n))return!0}return!1}var hr=e.enum(["draft","active","paused","archived"]),at=e.discriminatedUnion("type",[e.object({type:e.literal("percent"),percentOff:e.number().min(1).max(100).multipleOf(.01)}).strict(),e.object({type:e.literal("amount"),amountOffCents:e.number().int().min(1).max(1e8),currency:he}).strict()]),ct=e.discriminatedUnion("type",[e.object({type:e.literal("once")}).strict(),e.object({type:e.literal("repeating"),months:e.number().int().min(1).max(36)}).strict(),e.object({type:e.literal("forever")}).strict()]),ut=[e.object({type:e.literal("all")}).strict(),e.object({type:e.literal("plans"),planIds:e.array(e.uuid()).min(1).max(50).refine(t=>new Set(t).size===t.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()],Lt=e.discriminatedUnion("type",[...ut,e.strictObject({type:e.literal("merchandise"),scope:e.discriminatedUnion("type",[e.strictObject({type:e.literal("all")}),e.strictObject({type:e.literal("selected"),merchandiseIds:e.array(e.uuid()).min(1).max(1e3).refine(t=>new Set(t).size===t.length,"Duplicate merchandise")}),e.strictObject({type:e.literal("condition"),condition:G})])})]),Ht=e.discriminatedUnion("type",[...ut,e.strictObject({type:e.literal("merchandise"),scope:e.strictObject({type:e.enum(["all","selected","condition"])})})]),Jt=e.strictObject({firstPurchaseOnly:e.boolean(),condition:G}),br=e.object({name:e.string().trim().min(1).max(80),description:e.string().max(500),discount:at,duration:ct,nativeDiscountPolicy:ge.optional(),appliesTo:Lt,eligibility:Jt,selfClaimEnabled:e.boolean().default(!1),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),totalLimit:e.number().int().min(1).max(1e6).nullable(),perCustomerLimit:e.number().int().min(1).max(10),grantWindowHours:e.number().int().min(1).max(2160)}).strict().refine(t=>!t.startsAt||!t.endsAt||Date.parse(t.endsAt)>Date.parse(t.startsAt),{message:"\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4",path:["endsAt"]}).refine(t=>!Ae(t.eligibility.condition),{message:"Customer eligibility cannot read merchandise; use merchandise applicability",path:["eligibility","condition"]}).refine(t=>t.appliesTo.type!=="merchandise"||t.duration.type==="once",{message:"Merchandise Coupons apply to one purchase",path:["duration"]}).refine(t=>t.appliesTo.type!=="merchandise"||!t.eligibility.firstPurchaseOnly,{message:"Merchant purchase eligibility requires trusted targeting attributes",path:["eligibility","firstPurchaseOnly"]}),xr=e.object({code:e.string().trim().transform(t=>t.toUpperCase()).pipe(e.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/,"\u4F18\u60E0\u7801\u53EA\u80FD\u7528 3\u201332 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934")),maxRedemptions:e.number().int().min(1).max(1e6).nullable(),expiresAt:e.iso.datetime().nullable(),firstPurchaseOnly:e.boolean(),minimumAmountCents:e.number().int().min(1).max(1e8).nullable(),minimumAmountCurrency:he.nullable()}).strict().refine(t=>t.minimumAmountCents===null==(t.minimumAmountCurrency===null),"Minimum amount requires its currency");var lt=e.object({id:e.uuid(),couponId:e.uuid(),status:e.enum(["issued","reserved","redeemed","revoked","expired"]),issuedAt:e.iso.datetime(),expiresAt:e.iso.datetime(),coupon:e.object({name:e.string(),discount:at,duration:ct,nativeDiscountPolicy:ge.optional(),appliesTo:Ht}).strict()}).strict(),Sr=e.enum(["claim_disabled","unavailable","inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var Zt=e.string().regex(/^[a-f0-9]{64}$/),Wt=Ze.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),pt=e.strictObject({couponDigests:e.record(e.uuid(),Zt),variables:e.record(be,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(be,We.extend({nodes:e.record(e.string(),e.strictObject({base:Wt})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var dt=e.enum(["funnel-run/1","funnel-process/1"]),Ar="funnel-process/1";var Ce=v,Qt=["parameters","answers","results","variables"];function Xt(t){return Qt.some(r=>t===r||t.startsWith(r+"."))}function Yt(t){let r={};for(let[s,i]of Object.entries(te(t.declarations,t))){let a=s.split(".");if(a.some(f=>["__proto__","constructor","prototype"].includes(f)))throw new Error("Reserved result path");let u=r;for(let f of a.slice(0,-1)){Object.hasOwn(u,f)||(u[f]={});let g=u[f];if(!g||typeof g!="object"||Array.isArray(g))throw new Error("Ambiguous result path");u=g}let c=a.at(-1);if(c===void 0)throw new Error("Empty result path");u[c]=i}return{...Object.fromEntries(Object.entries(t.attributes).filter(([s])=>!Xt(s))),variables:r}}var ne=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/);var _e=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),mt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),ft=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),Re=e.record(_e,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),en=E,yt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:_e,inputs:e.record(_e,en).refine(t=>Object.keys(t).length<=20),outputs:Re}),gt=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Br=e.strictObject({outcome:e.enum(["success","failure"]),data:ft});var $r=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:mt,eventName:ne,eventId:e.uuid(),data:ft}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Gr=e.strictObject({scope:U,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),tn=e.record(mt,Ce),qr=e.strictObject({scope:U,runId:e.uuid(),results:tn});var nn=["id","externalUserId","createdAt","ageDays","subscription"],De=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(t=>new Set(t).size===t.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),re=e.intersection(N,e.looseObject({tags:De.optional()})).refine(t=>![...nn,"parameters","answers","results"].some(r=>Object.hasOwn(t,r)),"Reserved customer attribute"),ie=e.string().trim().max(80),oe=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),se=e.union([e.email().max(254),e.literal("")]),rn=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ht=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Zr=e.object({externalUserId:ht.optional(),name:ie.default(""),email:se.default(""),phone:oe.optional(),attributes:re.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u7528\u6237 ID \u6216\u90AE\u7BB1"),ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ht})]),ce=e.strictObject({name:ie.optional(),email:se.optional(),phone:oe.optional(),attributes:re.optional(),fingerprint:rn.optional()}),ue=t=>!t.customerData||t.customer?.type==="externalUserId",le="customerData requires an externalUserId customer",bt=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:ie,email:se,phone:oe.optional(),attributes:re,createdAt:e.iso.datetime()}).strict(),Wr=e.object({customer:bt,changed:e.boolean(),replayed:e.boolean()}).strict(),on=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),sn=e.object({name:ie.optional(),email:se.optional(),phone:oe.optional(),attributes:re.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:De,remove:De}).optional()}).strict().refine(t=>Object.keys(t).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),an=e.object({lookup:on}).strict(),Qr=an.extend({requestId:e.uuid(),patch:sn}).strict(),Xr=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Yr=e.object({customers:bt.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var ii=e.enum(["local","remote"]),ze=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:v.optional(),sticky:e.array(e.strictObject({expected:Q.nullable(),next:Q})).max(100),exposures:e.array(v).max(100),features:e.array(v).max(100)}),xt=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:N,sticky:e.record(e.string(),Q)}),St=xt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),cn=xt.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),vt=e.strictObject({nodeId:e.string().min(1).max(64),result:ze}),wt=cn.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:X,variables:e.record(e.string(),v)});var Ee=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:v}),e.strictObject({type:e.literal("variable"),key:I,path:R.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),un=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:v}),ln={funnelId:e.uuid(),requestId:e.uuid(),customer:ae,customerData:ce.optional(),attributes:N.refine(t=>!["parameters","answers","results","variables"].some(r=>Object.hasOwn(t,r)),"parameters, answers, results and variables are reserved flow namespaces")},mi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...ln}).refine(ue,le),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:ze}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(vt).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),fi=e.strictObject({scope:U,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:un.nullable(),evaluation:e.discriminatedUnion("type",[St,wt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),yi=e.strictObject({scope:U,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function pn(t,r=[]){let n=[];H(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),r.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(xe(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let u of Object.keys(a))s.has(u)||n.push(`Unused string ${u} must not be delivered (${i})`);return n}function It(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(r=>It(r)??[])}}function dn(t){let r=t.pages.map(i=>{let a=It(i.root);return a?.type==="stack"?{...i,root:a}:{...i,root:{type:"stack",id:i.root.id,...i.root.name===void 0?{}:{name:i.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(xe({pages:r}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([u])=>n.has(u)))]));return{...t,pages:r,strings:{...t.strings,locales:s}}}function Ot(t,r=[]){let n=J.parse(structuredClone(dn(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=pn(n,r);if(i.length)throw new Error(i.join("; "));return n}var Si=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),couponId:e.uuid(),productBindingId:e.uuid(),storeOfferId:e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),storeOfferType:e.enum(["introductory","promotional"])}),e.strictObject({action:e.literal("set_enabled"),id:e.uuid(),revision:e.number().int().nonnegative(),enabled:e.boolean()})]),vi=e.array(e.strictObject({id:e.uuid(),couponId:e.uuid(),productBindingId:e.uuid(),storeOfferId:e.string().min(1).max(255).nullable(),storeOfferType:e.enum(["introductory","promotional"]),enabled:e.boolean(),revision:e.number().int().nonnegative()})).max(500),Ke=e.strictObject({offerKind:e.enum(["none","introductory","promotional"]),offerId:e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),discountMinor:e.number().int().min(0).max(1e8),trialDays:e.number().int().min(1).max(730).nullable()}).superRefine((t,r)=>{(t.offerKind==="none"&&(t.offerId!==null||t.discountMinor!==0||t.trialDays!==null)||t.trialDays!==null&&t.discountMinor!==0)&&r.addIssue({code:"custom",message:"Select one store purchase option with its exact terms"})}),wi=e.record(e.uuid(),Ke).refine(t=>Object.keys(t).length<=20,"At most 20 native store selections");var ji=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,r)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&r.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),jt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var mn=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],Ve="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",fn=e.string().regex(new RegExp(`^${Ve}/${Ve}/${Ve}/manifest\\.json$`)),kt=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(mn),objectKey:fn,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,r)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&r.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var S=e.string().min(1).max(256),A=e.string().regex(/^[a-f0-9]{64}$/),pe=e.strictObject({versionId:e.uuid(),manifestDigest:A,sourceGraphDigest:A,pageKey:S,stateKey:S,documentKey:S,documentHash:A,elementKey:S.optional(),nodeId:S.optional(),contentHash:A.optional(),renderKey:S.optional()}),At=e.strictObject({pageKey:S,documentKey:S,expectedDocumentHash:A,renderKey:S.optional(),nodeId:S,elementKey:S,expectedContentHash:A,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),zi=e.strictObject({versionId:e.uuid(),manifestDigest:A,sourceGraphDigest:A,pageKey:S,stateKey:S,documentKey:S,documentHash:A,renderKey:S.optional(),patches:e.array(At.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),yn=/^[a-z][a-z0-9-]{0,39}$/,q=e.string().regex(yn),Pe=e.enum(["web","ios","android"]),Ct={requestId:e.uuid(),client:q,platform:Pe,label:e.string().trim().min(1).max(100),sha256:A,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},gn=e.strictObject({action:e.literal("upload"),...Ct,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ei=e.discriminatedUnion("action",[gn,e.strictObject({action:e.literal("register"),...Ct}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:S,changesetId:e.uuid().nullable(),expectedRevision:A.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(At).max(200)})]),Fe=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:q,platform:Pe,label:e.string(),sha256:A,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),hn=e.strictObject({key:q,platform:Pe,currentId:e.uuid().nullable()}),Ki=e.strictObject({rows:e.array(Fe).max(100),nextCursor:e.uuid().nullable(),clients:e.array(hn).max(20)}),Ne=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),Vi=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:Ne,runtime:Ne,previews:Ne})}),Ni=e.strictObject({version:Fe,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Pi=e.strictObject({version:Fe,upload:kt.nullable()}),Fi=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:S,path:e.string(),documentKey:S,documentHash:A,initialStateKey:S,initialRenderKey:S})),renders:e.array(jt)}).loose().superRefine((t,r)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&r.addIssue({code:"custom",message:"Incomplete render catalog"})}),Mi=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:S,key:S,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Ti=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var bn=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),_t=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:q,source:pe,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:bn.optional()}).superRefine((t,r)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&r.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},Rt="00000000-0000-0000-0000-000000000000";var Dt=e.strictObject({type:e.literal("bundle"),paywall:E.optional(),offering:E.optional(),coupons:E,data:E}),xn=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Wi=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:v});var Qi=e.strictObject({type:e.literal("bundle"),offering:xn("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(lt).max(20),data:v});var zt=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Sn=e.union([zt,e.array(zt).min(1).max(20)]),vn=e.record(R,Sn).refine(t=>Object.keys(t).length<=10),Et=e.strictObject({path:R,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:vn.optional()}).superRefine((t,r)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&r.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var wn=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],Kt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),In=E,Vt=e.discriminatedUnion("type",[yt,e.strictObject({type:e.literal("claim_offer"),coupon:E}),e.strictObject({type:e.literal("event"),event:Kt}),e.strictObject({type:e.literal("api"),operation:e.enum(wn),inputs:e.record(R,In).refine(t=>Object.keys(t).length<=40),outputs:e.record(Kt,Et).refine(t=>Object.keys(t).length<=20)})]);var b=ne,On=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),C={id:b,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},jn={success:b,cancel:b,unavailable:b,failure:b},kn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),An=e.enum(["same_window","new_window"]),Cn=e.discriminatedUnion("type",[e.strictObject({...C,type:e.literal("entry"),next:b,triggers:e.array(_t).max(20).refine(t=>new Set(t.map(r=>r.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...C,type:e.literal("screen"),screenId:b,presentation:Xe,outputs:e.record(b,b),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:I}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...C,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("output"),value:e.discriminatedUnion("type",[...Ee.options,Dt,e.strictObject({type:e.literal("selection"),screenId:b,offeringKey:I})])}),e.strictObject({...C,type:e.literal("condition"),cases:e.array(e.strictObject({condition:G,target:b})).min(1).max(50),default:b}),e.strictObject({...C,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(On,b).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:b}),e.strictObject({...C,type:e.literal("action"),...jn,execution:gt,action:Vt,writes:Ie.optional()}),e.strictObject({...C,type:e.literal("external_page"),appManifest:pe.optional(),url:kn,openIn:An,opened:b,failed:b}),e.strictObject({...C,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Ee.optional()}),e.strictObject({...C,type:e.literal("wait"),writes:Ie.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:b}),e.strictObject({type:e.literal("event"),eventName:b,outputs:Re,timeoutSeconds:e.number().int().min(1).max(2592e3),received:b,timeout:b})])})]),Me=e.strictObject({version:e.literal(5),entry:b,nodes:e.array(Cn).min(1).max(D.flowNodes)}),Te=Me.superRefine((t,r)=>{_n(t,n=>r.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function de(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(r=>r.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function _n(t,r){let n=[],s=new Map(t.nodes.map(l=>[l.id,l])),i=(l,w,K)=>{n.push(l),r?.({message:l,reason:w,path:K?["nodes",t.nodes.indexOf(K)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(l=>l.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(l=>l.type==="screen").length>D.pages||t.nodes.filter(l=>!["screen","entry","end","output"].includes(l.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let l of t.nodes){for(let w of de(l))w===t.entry&&i("An entry cannot be a transition target","entryTarget",l),s.has(w)||i(`Missing target ${w}`,"missingTarget",l);l.type==="screen"&&(a.has(l.screenId)&&i("Every screen has exactly one node owner","screenOwner",l),a.add(l.screenId))}let u=new Set,c=new Set,f=new Set;function g(l){if(u.has(l)){i("Flow edges must not form a cycle","cycle",s.get(l));return}if(!(c.has(l)||!s.has(l))){u.add(l),f.add(l);for(let w of de(s.get(l)))g(w);u.delete(l),c.add(l)}}g(t.entry);for(let l of t.nodes)f.has(l.id)||i("Every node must be reachable from Entry","unreachable",l);return[...new Set(n)]}var Ue={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Nt(t,r,n){let s=[...r].sort((c,f)=>f.length-c.length),i=new Set,a=(c,f=!1)=>{let g=s.find(l=>c===l||f&&c.startsWith(l+"."));i.add(g??c)};if(t.type==="condition"){let c=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let f of t.cases.slice(0,c+1))for(let g of F(f.condition))g.startsWith("variables.")&&a(g.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let c of Object.values(t.action.inputs))c.source==="variable"&&a(c.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let u=t.type==="output"?t.value:t.type==="end"?t.output:null;if(u?.type==="variable"&&a(u.key),u?.type==="bundle")for(let c of[u.paywall,u.offering,u.coupons,u.data])c?.source==="variable"&&a(c.key);return u?.type==="selection"&&a(u.offeringKey),[...i]}var $=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),me=t=>e.record(e.string(),v).refine(r=>M(r)<=t,"Funnel evidence exceeds its byte budget"),_o=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),$e=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ge=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Ro=e.strictObject({schemaVersion:e.literal(1),kind:$e,selector:Ge.nullable(),context:me(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>M(t)<=131072,"Node input exceeds its byte budget"),Do=e.strictObject({schemaVersion:e.literal(1),kind:$e,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:me(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:me(131072)}).refine(t=>M(t)<=131072,"Node result exceeds its byte budget"),zo=e.strictObject({schemaVersion:e.literal(1),operations:e.record($,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:$,id:e.uuid()}).nullable()}))}).refine(t=>M(t)<=65536,"Execution state exceeds its byte budget"),T={receiptId:e.uuid()},Be=e.iso.datetime({offset:!0}),Eo=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:$e})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...T,source:e.literal("client"),occurredAt:Be.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(T)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:$,eventName:$,data:me(8192),source:e.literal("server"),occurredAt:Be})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...T,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(T)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(T)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...T,operation:$,reference:e.strictObject({type:$,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...T,source:e.enum(["client","server"]),occurredAt:Be,reference:e.string().min(1).max(128).optional()})})]);var _=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Rn=e.discriminatedUnion("type",[e.strictObject({id:_,type:e.literal("owned"),publicData:pt.optional(),document:J.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(r=>r.type==="event"&&!r.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:_,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),qe={executionContract:dt.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(Rn).max(D.pages),references:e.record(_,Ge).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:_,screenId:_,componentId:_,required:e.boolean()})).max(D.questions),variables:e.record(I,ee).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:Y,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(Ue.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(Ue.maxTransitions)})},Yo=e.strictObject({...qe,graph:Me});function Dn(t,r){let n=!1,s=(i,a)=>{let u=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(c=>c[i.text]?.includes("{{offer."))&&!(u&&r(u))&&(n=!0),i.type==="stack"&&i.children.forEach(c=>s(c,u))};for(let i of t.pages)s(i.root);return n}function ye(t){return Array.isArray(t)?t.some(ye):!t||typeof t!="object"?!1:Object.entries(t).some(([r,n])=>r==="productVersionId"?n===Rt:ye(n))}function zn(t){let r=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=Ot(i.document)}catch(u){r.push({message:u instanceof Error?u.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[u,c]of t.inputs.entries())c.screenId===i.id&&!Se(a,c.componentId)&&r.push({message:`Local Funnel input ${c.variable} targets hidden component ${c.componentId} on screen ${c.screenId}`,reason:"inputBinding",path:["inputs",u]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],u=i.type==="screen"?t.screens.find(c=>c.id===i.screenId):void 0;u?.type==="owned"&&(u.document.actions.some(c=>typeof c.properties.templateKey=="string"&&c.properties.templateKey.startsWith("popup-coupon-"))&&r.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),Dn(u.document,c=>n.has(c))&&r.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&ye(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&ye(i.output.value))&&r.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return r}function Pt(t,r){for(let{message:n,reason:s,path:i}of zn(t))r.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function Ft(t,r){let n=(y,o,p=[])=>r.addIssue({code:"custom",message:y,path:p,params:{reason:o}}),s=Object.values(t.references),i=new Map(t.screens.map(y=>[y.id,y])),a=(y,o)=>s.some(p=>p.type===y&&("id"in p?p.id:p.key)===o);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let u=t.graph.nodes.filter(y=>y.type==="screen");(u.length!==i.size||u.some(y=>!i.has(y.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let c=new Map,f=Object.keys(t.variables);f.some(y=>f.some(o=>y!==o&&o.startsWith(y+".")))&&n("Variable paths must not overlap","variable");function g(y,o){Object.hasOwn(t.variables,y)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(o)]);let p=c.get(y)??new Set;p.add(o.id),c.set(y,p)}for(let[y,o]of t.graph.nodes.entries()){let p=["graph","nodes",y],O=o.type==="feature"?o.featureKey:o.type==="offering"&&o.configuration.source==="feature"?o.configuration.featureKey:o.type==="output"&&o.value.type==="feature"?o.value.featureKey:o.type==="end"&&o.output?.type==="feature"?o.output.featureKey:null;O&&!a("flag",O)&&n("Flag selectors require an explicit GB resource reference","feature",p);let j=o.type==="feature"||o.type==="offering"||o.type==="coupon"||o.type==="coupons"||o.type==="action"&&o.action.type==="api"?["value"]:o.type==="action"&&o.action.type==="external_task"?Object.keys(o.action.outputs):o.type==="wait"&&o.wait.type==="event"?Object.keys(o.wait.outputs):[],k="writes"in o?o.writes??{}:{};(j.length!==Object.keys(k).length||j.some(d=>!Object.hasOwn(k,d))||new Set(Object.values(k)).size!==Object.values(k).length)&&n("Node writes must map every named output exactly once","variable",p);for(let[d,x]of Object.entries(k)){g(x,o);let h=t.variables[x],m=o.type==="offering"?"offering_version":o.type==="coupon"?"reward":o.type==="action"&&o.action.type==="api"?"json":o.type==="action"&&o.action.type==="external_task"?o.action.outputs[d]:o.type==="wait"&&o.wait.type==="event"?o.wait.outputs[d]:void 0;(h?.source.type!=="node"||m&&h.type!==m)&&n("Node writer source or output type does not match declaration","variable",p)}if(o.type==="coupons"){let d=t.variables[o.writes.value];(d?.type!=="array"||d.items?.type!=="reward"||d.items.nullable||d.nullable)&&n("Coupons output requires a non-null Reward array","variable",p);for(let x of o.couponIds)a("reward",x)||n("Coupons require Reward references","coupon",p)}if(o.type==="split"&&!a("experiment",o.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",p),o.type==="coupon"&&!a("reward",o.couponId)&&n("Coupon selectors require a Reward reference","coupon",p),o.type==="action"&&o.action.type==="claim_offer"&&o.action.coupon.source==="literal"){let d=o.action.coupon.value;(!d||typeof d!="object"||Array.isArray(d)||d.type!=="reward"||typeof d.id!="string"||Object.keys(d).length!==2||!a("reward",d.id))&&n("Coupon claims require a Reward reference","coupon",p)}if(o.type==="offering"&&o.configuration.source==="fixed"&&!a("offering_version",o.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",p),o.type==="screen"&&o.offering?.source==="variable"&&t.variables[o.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",p),o.type==="action"&&o.action.type==="claim_offer"&&o.action.coupon.source==="variable"&&(t.variables[o.action.coupon.key]?.type!=="reward"||o.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",p),o.type==="screen"){let d=i.get(o.screenId);if(o.offering?.source==="fixed"&&!a("offering_version",o.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",p),d?.type==="paywall"&&o.offering&&n("Paywall owns its fixed Offering Version","offering",p),d?.type==="paywall"&&!a("paywall_version",d.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",p),d?.type==="owned"){let x=d.document.pages[0];if(!x){n("Owned screen requires a page","screen",p);continue}et(d.document).some(m=>!m.complete)&&n("Owned screens require complete local content","translations",p);let h=new Set(d.document.actions.map(m=>m.id));(h.size!==Object.keys(o.outputs).length||Object.keys(o.outputs).some(m=>!h.has(m)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",p),Z(x.root,m=>{!o.offering&&(m.type==="plan_picker"||(m.type==="stack"||m.type==="button")&&m.bind?.plan||m.type==="customer_data"&&["customer_plans","credit_packs"].includes(m.data.source))&&n("Product presentation requires an Offering Version","offering",p),m.type==="customer_data"&&Object.values(m.data.outputs??{}).some(V=>V!==void 0&&!h.has(V))&&n("Customer components require declared screen outcomes","componentOutput",p)})}}o.type==="end"&&["completed","ineligible"].includes(o.outcome)&&!o.output&&n("Completed and ineligible ends require a declared output","output",p),o.type==="end"&&o.output?.type==="literal"&&!P(t.outputSchema,o.output.value)&&n("Terminal output does not match outputSchema","output",p),o.type==="output"&&o.value.type==="literal"&&!P(t.outputSchema,o.value.value)&&n("Terminal output does not match outputSchema","output",p);let z=o.type==="output"?o.value:o.type==="end"?o.output:void 0;if(z?.type==="variable"&&!z.path){let d=t.variables[z.key];d&&!Oe(d,t.outputSchema)&&n("Variable output does not match outputSchema","output",p)}if(o.type==="screen"){let d=i.get(o.screenId);if(d?.type==="owned")for(let x of ke(d.document))(/^(input|params)\./.test(x)||x.startsWith("variables.")&&!je(x.slice(10),f))&&n("Screen values must reference registered variables","variable",p)}if(o.type==="condition")for(let d of o.cases){for(let x of W(d.condition))a("saved_group",x)||n("Conditions require explicit Saved Group references","savedGroup",p);for(let x of F(d.condition))x.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",p)}if(o.type==="output"&&o.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",p);for(let[d,x]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let h=o.value[d];if(h)if(h.source==="literal"){let m=d==="coupons"?h.value:[h.value];(!Array.isArray(m)||m.length>20||m.some(V=>!P({type:x,nullable:!1},V)||!a(x,V.id))||d==="coupons"&&new Set(m.map(V=>V.id)).size!==m.length)&&n("Bundle requires distinct scoped resource references",d==="coupons"?"coupon":d==="paywall"?"paywall":"offering",[...p,"value",d])}else{let m=t.variables[h.key];(h.path||!m||m.nullable||(d==="coupons"?m.type!=="array"||m.items?.type!=="reward"||m.items.nullable:m.type!==x))&&n("Bundle binding type does not match its slot","output",p)}}}}for(let[y,o]of t.graph.nodes.entries()){let p=o.type==="screen"?i.get(o.screenId):void 0,O=[...Nt(o,f),...p?.type==="owned"?ot(p.document).map(j=>je(j,f)?.key??j):[]];for(let j of new Set(O)){let x=function(h){if(h===o.id)return!0;if(d.has(h))return!1;d.add(h);let m=t.graph.nodes.find(Mt=>Mt.id===h);return m?(z.has(h)?m.type==="action"?[m.cancel,m.unavailable,m.failure]:m.type==="wait"&&m.wait.type==="event"?[m.wait.timeout]:[]:de(m)).some(x):!1};var K=x;if(!Object.hasOwn(t.variables,j)){n("Consumed variable is undeclared","variable",["graph","nodes",y]);continue}let k=t.variables[j];if(o.type==="screen"&&k.source.type==="input"&&t.inputs.some(h=>h.screenId===o.screenId&&h.variable===j)||k.source.type==="parameter"||k.source.type==="attribute")continue;let z=k.source.type==="input"?new Set(t.inputs.filter(h=>h.variable===j&&h.required).flatMap(h=>u.filter(m=>m.screenId===h.screenId).map(m=>m.id))):c.get(j)??new Set,d=new Set;(!z.size||x(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",y])}}(new Set(t.inputs.map(y=>y.variable)).size!==t.inputs.length||new Set(t.inputs.map(y=>`${y.screenId}:${y.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[y,o]of t.inputs.entries()){t.variables[o.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",y]);let p=i.get(o.screenId),O=p?.type==="owned"?Se(p.document,o.componentId):null;if((O?.type!=="stack"||!O.interaction||!["input","toggle","select","multiselect","tabs"].includes(O.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",y]),O?.type==="stack"&&O.interaction){let j=O.interaction.type==="toggle"?"boolean":O.interaction.type==="multiselect"?"strings":"string";t.variables[o.variable]?.type!==j&&n("Input variable type does not match component","inputBinding",["inputs",y]);let k=t.variables[o.variable]?.enum;k&&!O.children.filter(z=>!z.hidden).every(z=>k.includes(z.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",y])}}for(let[y,o]of Object.entries(t.variables))o.enum&&o.type!=="string"&&n("Only string variables support enum","variable",["variables",y]),o.source.type==="input"&&!t.inputs.some(p=>p.variable===y)&&n("Input variable requires a component binding","inputBinding",["variables",y]);let l=0,w=0;for(let y of t.screens)if(y.type==="owned"){for(let o of y.document.pages)Z(o.root,()=>{l++});w+=y.document.actions.length}(l>D.components||w>D.actions||M(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var En=e.strictObject({...qe,graph:Te}).superRefine(Ft),Kn=e.strictObject({...qe,graph:Te,displayName:e.string().trim().min(1).max(80)}).superRefine(Ft),es=Kn.superRefine(Pt),ts=En.superRefine(Pt),fe=e.string().regex(Le),L={requestId:e.uuid(),nodeId:_,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:fe.optional()},Vn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:_,answers:X,selection:e.record(_,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:_,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:Ke.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),Nn=e.object({nodeId:_,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(_,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:tt.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),ns=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ae.optional(),customerData:ce.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ue,le),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:Nn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:fe.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:fe.optional()}),e.strictObject({operation:e.literal("submit"),...L,input:Vn}),e.strictObject({operation:e.literal("back"),...L}),e.strictObject({operation:e.literal("shown"),...L}),e.strictObject({operation:e.literal("close"),...L}),e.strictObject({operation:e.literal("commit_segment"),...L,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:fe.optional()})]);export{I as a,Y as b,ee as c,P as d,$n as e,Gn as f,Bt as g,ot as h,M as i,Ke as j,ar as k,Tt as l,Ut as m,Mn as n,at as o,ct as p,Ht as q,lt as r,Sr as s,Zt as t,Ar as u,pn as v,ji as w,zi as x,bn as y,Xt as z,Yt as A,$r as B,Gr as C,qr as D,cn as E,nn as F,rn as G,Zr as H,ae as I,ce as J,ue as K,le as L,bt as M,Wr as N,an as O,Qr as P,Xr as Q,Yr as R,Ee as S,ln as T,mi as U,fi as V,yi as W,kn as X,An as Y,Ro as Z,Do as _,Kn as $,ns as aa};
@@ -1 +1 @@
1
- import{a,b as o,c as i}from"./chunk-MHWPEMX7.js";import{a as p}from"./chunk-TIQS5DUF.js";function c(e){if(e!==null&&typeof e=="object"&&"customerId"in e)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function I(e){return{async previewUpdate(t){t=a(t),c(t);let r=await o(e,"previewUpdate");return i(e,r,t)},async update(t){t=a(t),c(t);let r=await o(e,"update");return i(e,r,t)},async readSubscriptionUpdate(t){t=a(t),c(t);let r=await o(e,"readSubscriptionUpdate");return i(e,r,t)},async restoreNativePurchase(t){t=a(t),c(t);let r=await o(e,"restoreNativePurchase");return i(e,r,t)},async previewAttach(t){t=a(t),c(t);let r=await o(e,"previewAttach");return i(e,r,t)},async attach(t){t=a(t),c(t);let r=await o(e,"attach");return i(e,r,t)},async readSubscriptionOperation(t){t=a(t),c(t);let r=await o(e,"readSubscriptionOperation");return i(e,r,t)}}}export{c as a,I as b};
1
+ import{a,b as o,c as i}from"./chunk-CY7OKV7E.js";import{a as p}from"./chunk-U7NX5ET2.js";function c(e){if(e!==null&&typeof e=="object"&&"customerId"in e)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function I(e){return{async previewUpdate(t){t=a(t),c(t);let r=await o(e,"previewUpdate");return i(e,r,t)},async update(t){t=a(t),c(t);let r=await o(e,"update");return i(e,r,t)},async readSubscriptionUpdate(t){t=a(t),c(t);let r=await o(e,"readSubscriptionUpdate");return i(e,r,t)},async restoreNativePurchase(t){t=a(t),c(t);let r=await o(e,"restoreNativePurchase");return i(e,r,t)},async previewAttach(t){t=a(t),c(t);let r=await o(e,"previewAttach");return i(e,r,t)},async attach(t){t=a(t),c(t);let r=await o(e,"attach");return i(e,r,t)},async readSubscriptionOperation(t){t=a(t),c(t);let r=await o(e,"readSubscriptionOperation");return i(e,r,t)}}}export{c as a,I as b};
@@ -1 +1 @@
1
- import{A as et,B as fe,F as tt,c as Be,d as Je,e as we,i as qe,j as He,k as $e,o as Ke,r as We}from"./chunk-HYE2YQYM.js";import{a as Xe}from"./chunk-R3YVDRTB.js";import{c as Fe,d as Ne,e as Te,f as _e,g as Le,i as De,m as Me,n as k,o as ke,q as ye,r as N,t as Ge,u as je,v as ze}from"./chunk-JOIPLLHK.js";import{I as he,J as Ve,aa as D,u as Ue}from"./chunk-GLYFT5WW.js";import{a as de,b as Qe}from"./chunk-HVVJGLYZ.js";import{a as ce}from"./chunk-ZYF6TRJ3.js";import{I as le}from"./chunk-QHJWVLJC.js";import{b as oe}from"./chunk-DHT3AWJQ.js";import{a as L}from"./chunk-TIQS5DUF.js";import{b as Ze}from"./chunk-3VUPVXAV.js";import{b as Ye}from"./chunk-RHF4NFCZ.js";import{b as e}from"./chunk-ZYN4CRHS.js";import{c as Ae,f as Pe}from"./chunk-O4KXODTJ.js";var G=e.literal(Ue),ft=e.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),Ie=e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),nt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("guest"),guestToken:Ie}),e.strictObject({type:e.literal("customer"),customer:he,customerData:Ve.optional()})]),ve=e.strictObject({id:e.uuid(),runId:e.uuid(),customerId:e.uuid(),requestId:e.uuid(),acceptedAt:e.iso.datetime({offset:!0})}),mt=e.strictObject({participantId:e.uuid(),startedAs:e.enum(["guest","identified"]),binding:ve.omit({runId:!0,requestId:!0}).nullable()}),pt=e.union([Be,e.strictObject({type:e.literal("authentication_required"),reason:e.enum(["customer_required","customer_experiment_required"]),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()})]),gt=Je.omit({authenticated:!0}).extend({identity:mt,instruction:pt.nullable()}),ht=e.discriminatedUnion("operation",[D.options[2].omit({customerToken:!0}),D.options[3].omit({customerToken:!0}),D.options[4].omit({customerToken:!0}),D.options[5].omit({customerToken:!0}),D.options[6].omit({customerToken:!0}),D.options[7].omit({customerToken:!0})]),me={contract:G,customerToken:e.string().regex(ce)},rt={contract:G,requestId:e.uuid(),runToken:ft,externalUserId:he.options[1].shape.value},ot=e.discriminatedUnion("operation",[e.strictObject({contract:G,operation:e.literal("describe")}),e.strictObject({contract:G,operation:e.literal("start"),source:nt,funnelId:D.options[0].shape.funnelId,requestId:e.uuid(),locale:D.options[0].shape.locale,parameters:D.options[0].shape.parameters}),qe.omit({operation:!0}).extend({contract:G,operation:e.literal("entry_start"),source:nt}),e.strictObject({...rt,operation:e.literal("bind_customer"),guestToken:Ie,claimRequestId:e.uuid(),expectedBindingId:e.null()}),e.strictObject({...rt,operation:e.literal("binding_status"),guestToken:Ie.optional()}),D.options[1].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("get"),settlementBindingId:e.uuid().nullable().optional()}),D.options[8].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("review")}),$e.omit({customerToken:!0}).extend(me),e.strictObject({...me,operation:e.literal("command"),identity:e.strictObject({bindingId:e.uuid().nullable()}),command:ht})]),yt=we.omit({run:!0}).extend({contract:G,run:gt,settlement:we.shape.settlement.unwrap().extend({accepted:e.boolean().nullable().optional()}).optional()}),Nt=He.extend({contract:G}),Tt=e.discriminatedUnion("operation",[ot.options[1].omit({contract:!0,source:!0,requestId:!0}),ot.options[2].omit({contract:!0,source:!0,requestId:!0})]),_t=yt.extend({binding:ve,outcome:e.enum(["bound","already_bound"]),replayed:e.boolean()}),Lt=e.discriminatedUnion("state",[e.strictObject({contract:G,scope:oe,state:e.literal("not_accepted")}),e.strictObject({contract:G,scope:oe,state:e.literal("conflict")}),e.strictObject({contract:G,scope:oe,state:e.literal("bound"),binding:ve})]),Dt=e.strictObject({contract:G,scope:oe,keyId:e.uuid(),operations:e.array(e.string()).max(20)});var it=e.string().regex(/^[a-f0-9]{64}$/),wt=Fe.omit({variations:!0,active:!0}).extend({changeId:it,variations:e.array(e.strictObject({urlRedirect:e.string().max(2048)})).min(2).max(20)}),at=e.strictObject({environmentId:e.uuid(),trackExposures:e.boolean(),generation:it,experiments:e.array(wt).max(100),savedGroups:Ne}),It=e.strictObject({eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}).optional(),deviceId:e.string().min(1).max(128),sessionId:e.string().min(1).max(128).optional(),url:e.url().max(2048),pageTitle:e.string().max(512).optional(),experimentKey:e.string().min(1).max(255),variationKey:e.string().min(1).max(64)}),kt=e.strictObject({events:e.array(It).min(1).max(20)}),Gt=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejected:e.array(e.strictObject({index:e.number().int().nonnegative(),reason:e.string()}))});function Ht(r){let o=null,f=null,E=0,b=0,C=new Set,c=null,y=null,d=new Set,v=()=>{for(let s of d)try{s()}catch{}},l={attributes:le.parse(r.attributes??{}),onFeatureUsage:r.onFeatureUsage?(s,w)=>{!C.has(s)&&o&&(!("analyticsConfig"in o)||o.analyticsConfig.featureUsageEnabled)&&r.onFeatureUsage(s,structuredClone(w),structuredClone(l.attributes),o.generation)}:void 0,onExperimentViewed:r.onExperimentViewed?(s,w)=>o&&(!("analyticsConfig"in o)||o.analyticsConfig.experimentViewsEnabled)&&r.onExperimentViewed(structuredClone(s),structuredClone(w),structuredClone(l.attributes),o.generation):void 0,stickyBucketAssignmentDocs:structuredClone(r.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:r.saveStickyBucketAssignmentDoc?s=>r.saveStickyBucketAssignmentDoc(structuredClone(s)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},S=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function p(s,w=new Set){return C.has(s)?!c||!c.features[s]||["unknownFeature","cyclicPrerequisite"].includes(c.features[s].source):w.has(s)?!1:(w.add(s),(o?.features[s]?.rules??[]).some(O=>[...O.parentConditions??[],...(O.tracks??[]).flatMap(A=>A.experiment.parentConditions??[])].some(A=>p(A.id,w))))}let x=s=>{if(r.assertUsable?.(o?.generation),!o)throw new Error("Initialize the Feature client before evaluation");if(o.expiresAt&&Date.parse(o.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return c?.expiresAt&&Date.parse(c.expiresAt)<=Date.now()&&(c=null,l.features=o.features),C.has(s)?!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now()?S():structuredClone(c.features[s]??S()):r.evaluateRemote&&(l.attributes?.merchandise||l.attributes?.merchandiseId)&&!c||p(s)?S():structuredClone(Pe(s,l))};async function U(){if(!o||!C.size&&!l.attributes?.merchandise&&!l.attributes?.merchandiseId)return;if(!r.evaluateRemote){if(C.size)throw new Error("Remote Feature evaluation requires a server loader");return}let s=b;if(y?.revision===s)return y.loading;let w=E,O=o,A=[...C],R=(async()=>{let h=De.parse(await r.evaluateRemote({attributes:structuredClone(l.attributes),features:A}));if(!(w!==E||s!==b||O!==o)){if(r.assertUsable?.(O.generation),h.generation!==O.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(A.some(P=>!Object.hasOwn(h.features,P))||Object.keys(h.features).some(P=>!C.has(P)))throw new Error("Invalid remote Feature results");if(l.attributes?.merchandise||l.attributes?.merchandiseId){if(!h.merchandiseContext)throw new Error("Server did not resolve merchandise context");l.attributes=le.parse({...l.attributes,...h.merchandiseContext})}c=structuredClone(h),l.features={...O.features,...Object.fromEntries(Object.entries(c.features).map(([P,z])=>[P,{defaultValue:z.value}]))},v()}})();y={revision:s,loading:R};try{await R}finally{y?.loading===R&&(y=null)}}function T(){U().catch(s=>{try{r.onError?.(s)}catch{}})}async function M(){if(f)return f;let s=E,w=(async()=>{let O=await r.load(),A="remoteFeatures"in O?_e.parse(O):null,R=A??Te.parse(O);if(R.scope.projectId!==r.scope.projectId||R.scope.environment!==r.scope.environment)throw new Error("Feature payload scope changed");if(s!==E)throw new Error("Feature client was reset");if(r.assertUsable&&o?.generation===R.generation){let{evaluatedAt:P,expiresAt:z,...ie}=o,{evaluatedAt:Y,expiresAt:pe,...j}=R;if(N(ie)!==N(j))throw new Error("Immutable Feature generation changed content");return o.evaluatedAt=R.evaluatedAt,o.expiresAt=R.expiresAt,v(),(!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now())&&T(),structuredClone(o)}let h=new Set(A?.remoteFeatures??[]);if([...h].some(P=>Object.hasOwn(R.features,P)))throw new Error("Remote Feature definitions must not be delivered locally");return o&&"analyticsConfig"in o&&"analyticsConfig"in R&&!o.analyticsConfig.experimentViewsEnabled&&A?.analyticsConfig.experimentViewsEnabled&&l.trackedExperiments?.clear(),o=structuredClone(R),C=h,c=null,y=null,b++,l.features=o.features,l.savedGroups=Ae(o.savedGroups),l.trackedFeatureUsage={},v(),T(),structuredClone(o)})();f=w;try{return await w}finally{f===w&&(f=null)}}return{init:M,refresh:M,refreshRemote:U,get generation(){return o?.generation??null},get expiresAt(){return o?.expiresAt??null},subscribe(s){return d.add(s),()=>{d.delete(s)}},setAttributes(s){let w=le.parse(s);(l.attributes?.merchandise||l.attributes?.merchandiseId||s.merchandise||s.merchandiseId)&&l.trackedExperiments?.clear(),l.attributes=w,b++,c=null,y=null,l.features=o?.features??{},l.trackedFeatureUsage={},v(),T()},evalFeature:x,isOn(s){return x(s).on},isOff(s){return x(s).off},getFeatureValue(s,w){let O=x(s).value;return structuredClone(O===null?w:O)},reset(){E++,b++,f=null,y=null,o=null,c=null,C.clear(),l.features={},l.savedGroups={},l.stickyBucketAssignmentDocs={},l.attributes={},l.trackedFeatureUsage={},l.trackedExperiments?.clear(),v()}}}var vt=e.record(e.string().regex(/^[a-f0-9]{64}$/),e.strictObject({at:e.number(),text:e.string()})),K=2*1048576,bt=100;function St(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function st(r,o){let f=o===void 0?St():o,E=new Map,b=0,C=!1,c=!1,y,d;async function v(S){if(!f)return null;let p;try{let x=await Promise.race([Promise.resolve().then(()=>f.getItem(S)),new Promise(U=>{p=setTimeout(()=>U(null),bt)})]);return typeof x=="string"&&x.length<=K&&new TextEncoder().encode(x).byteLength<=K?x:null}catch{return null}finally{clearTimeout(p)}}function l(){if(d)return d;let S=(async()=>{try{let p=await v(`${r}:artifacts`);if(p)return vt.parse(JSON.parse(p))}catch{}return{}})();return d=S,S.finally(()=>{d===S&&(d=void 0)}),S}return{async readManifest(){return v(r)},writeManifest(S){!f||S.length>K||new TextEncoder().encode(S).byteLength>K||(y=S,!c&&(c=!0,Promise.resolve().then(async()=>{try{for(;y!==void 0;){let p=y;try{await f.setItem(r,p)}catch{}y===p&&(y=void 0)}}finally{c=!1}})))},async readArtifact(S){let p=(await l())[S],x=Date.now();return p&&x>=p.at&&x-p.at<=k.retentionMs?p.text:void 0},writeArtifact(S,p){if(!f||p.length>K)return;let x=E.get(S);if(x?.text===p||!x&&E.size>=128)return;let U=new TextEncoder().encode(p).byteLength;b-(x?.byteLength??0)+U>K||(E.set(S,{text:p,byteLength:U}),b+=U-(x?.byteLength??0),!C&&(C=!0,Promise.resolve().then(async()=>{try{for(;E.size;){let T=new Map(E);try{let M={...await l()},s=Date.now();for(let[R,h]of T)M[R]={at:s,text:h.text};let w={},O=2,A=0;for(let[R,h]of Object.entries(M).sort(([,P],[,z])=>z.at-P.at)){if(h.at>s||s-h.at>k.retentionMs)continue;let P=new TextEncoder().encode(JSON.stringify({[R]:h})).byteLength;O+P>K||A>=128||(w[R]=h,O+=P,A++)}await f.setItem(`${r}:artifacts`,JSON.stringify(w))}catch{}finally{for(let[M,s]of T)E.get(M)===s&&(E.delete(M),b-=s.byteLength)}}}finally{C=!1}})))}}}var u=(r,o)=>new L(r,o),q=()=>performance.now(),ut=r=>{typeof r=="object"&&"unref"in r&&r.unref()};function ln(r){let o=ke.parse(r.scope),f=new de(r.origin??Ye);if(f.username||f.password||f.search||f.hash||f.pathname!=="/"||f.protocol!=="https:"&&!(f.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(f.hostname)))throw u("INVALID_URL","Configuration requires a trusted HTTPS origin");let E=new Set([f.origin,...(r.assetOrigins??[]).map(n=>{let t=new de(n);if(t.protocol!=="https:"||t.username||t.password||t.search||t.hash||t.pathname!=="/")throw u("INVALID_URL","Invalid configuration asset origin");return t.origin})]),b=r.fetch??globalThis.fetch.bind(globalThis),C=`/api/v1/configuration/${o.environmentId}`,c=`indiana:configuration:1:${f.origin}:${N(o)}`,y=st(c,r.storage),d,v=0,l=0,S=!1,p=!1,x=0,U=0,T,M,s,w,O=0,A=new Set,R=new Set,h=new Map,P=new Map,z=0,ie=!1;function Y(){for(let n of A)try{n()}catch{}}function pe(n){try{r.onError?.(n)}catch{}}let j=()=>!p&&!S&&!!d&&q()<v&&Date.now()<l;function ne(){if(!j())throw u("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function be(n,t,i){if(!h.has(n)){for(;h.size&&(h.size>=128||z+i>k.maxCacheBytes);){let a=h.entries().next().value;z-=a[1].byteLength,h.delete(a[0])}h.set(n,{text:t,byteLength:i}),z+=i}}function Se(n,t,i){return Ze(n,t,{signal:i,error:a=>u("INVALID_RESPONSE",a==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function xe(n){let t=new de(n,f);if(!E.has(t.origin)||t.username||t.password||t.hash||t.search)throw u("INVALID_URL","Configuration artifact origin is not trusted");return t.href}async function ge(n,t,i=!1){let a=await b(xe(n),{method:"GET",credentials:"omit",redirect:"error",cache:i?"default":"no-cache",signal:t,headers:{}});if(a.status===429){let g=a.headers.get("retry-after")??"";O=/^\d+$/.test(g)?Number(g)*1e3:Math.max(0,Date.parse(g)-Date.now())||15e3}if(!a.ok&&a.status!==304)throw u(`CONFIGURATION_HTTP_${a.status}`,"Configuration synchronization failed");return a}function lt(n,t,i){let a=Date.parse(n.headers.get("x-indiana-config-validated-at")??""),g=Date.parse(n.headers.get("x-indiana-config-valid-until")??""),I=Date.parse(n.headers.get("date")??""),m=n.headers.get("age"),V=m!==null&&/^\d+(\.\d+)?$/.test(m)?Number(m)*1e3:NaN;if(![a,g,I,V].every(Number.isFinite)||g<=a||g-a>k.maxControlAgeMs||a>I+1e3)throw u("INVALID_RESPONSE","Configuration freshness evidence is invalid");let F=Math.min(g-a,i.maxControlAgeSeconds*1e3,k.maxControlAgeMs)-Math.max(V,I-a,0)-(q()-t);if(F<=0)throw u("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return q()+F}function ae(){if(clearTimeout(s),clearTimeout(w),p||!A.size||(j()&&(w=setTimeout(()=>{j()?ae():Y()},Math.max(1,v-q())),ut(w)),typeof document<"u"&&document.visibilityState==="hidden"))return;let n=U?Math.min(15e3,1e3*2**Math.min(U-1,4)):Math.min(15e3,(d?.policy.refreshIntervalSeconds??15)*1e3);s=setTimeout(()=>{Q().catch(pe)},Math.max(O,n*(.8+Math.random()*.2))),ut(s)}async function Q(){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(T)return T;let n=x,t=new AbortController;M=t;let i=(async()=>{if(!ie){ie=!0;try{let ue=await y.readManifest();if(ue&&!d){let J=ye.parse(JSON.parse(ue));N(J.scope)===N(o)&&(d=J)}}catch{}}t.signal.throwIfAborted();let m=d,V=q(),_=await ge(C,t.signal);_.status===304&&(!m||!_.headers.has("x-indiana-config-validated-at")||!_.headers.has("x-indiana-config-valid-until")||!_.headers.has("age"))&&(_=await ge(C,t.signal));let F=_.status===304?m:ye.parse(JSON.parse(await Se(_,k.maxManifestBytes,t.signal))),{generation:ee,...te}=F,B=_.headers.get("etag");if(N(F.scope)!==N(o)||Ge(te)!==ee||B!==`"${ee}"`&&B!==`W/"${ee}"`)throw u("INVALID_RESPONSE","Configuration scope or content identity changed");if(m&&(F.revision<m.revision||F.revision===m.revision&&F.generation!==m.generation))throw u("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[ue,J]of Object.entries(m?.funnels??{})){let $=F.funnels[ue];if($&&($.controlRevision<J.controlRevision||$.evaluationRevision<J.evaluationRevision||$.controlRevision===J.controlRevision&&$.state!==J.state||$.evaluationRevision===J.evaluationRevision&&$.evaluationMode!==J.evaluationMode))throw u("INVALID_RESPONSE","Funnel control revision changed identity")}let H=lt(_,V,F.policy);if(t.signal.throwIfAborted(),n!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return d=F,v=H,l=Date.now()+Math.max(0,H-q()),S=!1,U=0,O=0,y.writeManifest(N(F)),Y(),structuredClone(F)})(),a=setTimeout(()=>t.abort(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs),g=new Promise((m,V)=>t.signal.addEventListener("abort",()=>V(t.signal.reason),{once:!0})),I=Promise.race([i,g]).catch(m=>{throw U++,(m instanceof e.ZodError||m instanceof SyntaxError||m instanceof L&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(m.code))&&(v=0,S=!0,Y()),m}).finally(()=>{clearTimeout(a),T===I&&(T=void 0),ae()});return T=I,I}async function se(n){let t=n.sha256,i=te=>Xe(te,n);xe(n.url);let a=h.get(t);if(a){if(a.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return h.delete(t),h.set(t,a),a.text}let g=P.get(t);if(g){if(g.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return g.promise}let I=new AbortController;R.add(I);let m=x,V=(async()=>{try{let H=await y.readArtifact(t);if(H&&i(H)){if(I.signal.throwIfAborted(),p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,H,n.byteLength),H}}catch{}I.signal.throwIfAborted();let te=await ge(n.url,I.signal,!0),B=await Se(te,n.byteLength,I.signal);if(!i(B))throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,B,n.byteLength),y.writeArtifact(t,B),B})(),_=setTimeout(()=>I.abort(u("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),k.initializationMs),F=new Promise((te,B)=>I.signal.addEventListener("abort",()=>B(I.signal.reason),{once:!0})),ee=Promise.race([V,F]).finally(()=>{clearTimeout(_),R.delete(I),P.delete(t)});return P.set(t,{promise:ee,byteLength:n.byteLength}),ee}async function re(){return j()||await Q(),ne(),d}async function W(n){let t,i=new Promise((a,g)=>{t=setTimeout(()=>g(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs)});try{return await Promise.race([n(),i])}finally{clearTimeout(t)}}function Z(n,t){if(ne(),d?.generation!==n.generation)throw u("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(t&&d.funnels[t]?.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function Ee(n){let t=n.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let a=Le.parse(JSON.parse(await se(i)));if(N(a.scope)!==N({projectId:o.projectId,environment:o.environment})||a.generation!==i.generation||a.remoteFeatures.some(g=>Object.hasOwn(a.features,g)))throw u("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return Z(n),{...a,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,v-q())).toISOString()}}async function Ce(n,t){let i=await re(),a=i.funnels[n];t&&(!a||a.evaluationMode==="local"&&!a.versions[t])&&(T&&await T,i=await Q()),Z(i,n);let g=i.funnels[n];if(g.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let I=t??g.currentVersionId,m=g.versions[I];if(!m)throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(i.artifacts[m.artifact].formatVersion!==3)throw u("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[V,_]=await Promise.all([se(i.artifacts[m.artifact]).then(F=>ze(JSON.parse(F))),g.evaluationMode==="local"?Ee(i):void 0]);if(_&&N(je(V,_))!==N(m.dependencies))throw u("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return Z(i,n),{document:V,growth:_,versionId:I,control:structuredClone(g),manifest:structuredClone(i)}}async function Re(n,t){try{return await Ce(n,t)}catch(i){if(!(i instanceof L)||!(i.code==="CONFIGURATION_CHANGED"||i.code==="CONFIGURATION_HTTP_404"&&j()))throw i;let a=d?.generation;if(T&&await T,await Q(),i.code!=="CONFIGURATION_CHANGED"&&d?.generation===a)throw i;return Ce(n,t)}}function X(){if(j()||Y(),typeof document<"u"&&document.visibilityState==="hidden"){ae();return}Q().catch(pe)}function dt(n){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return A.add(n),A.size===1&&(typeof window<"u"&&(window.addEventListener("online",X),window.addEventListener("focus",X),document.addEventListener("visibilitychange",X)),ae()),()=>{A.delete(n),A.size||(clearTimeout(s),clearTimeout(w),Oe())}}function Oe(){typeof window<"u"&&(window.removeEventListener("online",X),window.removeEventListener("focus",X),document.removeEventListener("visibilitychange",X))}return{scope:Object.freeze({...o}),refresh:Q,subscribe:dt,assertFresh:ne,assertFeatures(n){ne();let t=d.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(n!==void 0&&d.artifacts[t].generation!==n)throw u("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return j()},get snapshot(){return d?structuredClone(d):null},get remainingMs(){return j()?Math.max(0,v-q()):0},async features(){return W(async()=>Ee(await re()))},pageExperiments:()=>W(async()=>{let n=await re(),t=n.gb.pageExperiments;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let a=at.parse(JSON.parse(await se(i)));if(a.environmentId!==o.environmentId||a.generation!==i.generation)throw u("INVALID_RESPONSE","Page experiment scope or generation changed");return Z(n),a}),funnel:(n,t)=>W(()=>Re(n,t)),funnelControl:n=>W(async()=>{let t=await re();return Z(t,n),structuredClone(t.funnels[n])}),paywall:(n,t)=>W(async()=>{let i=await re(),a=i.paywalls?.[n];if(!a||!t&&a.state!=="published")throw u("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let g=t??a.currentVersionId,I=a.versions[g],m=I&&i.artifacts[I.artifact];if(!m||m.kind!=="paywall"||m.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let V=Me.parse(JSON.parse(await se(m)));return Z(i),{document:V,versionId:g,version:I.version,control:structuredClone(a),manifest:structuredClone(i)}}),async localFunnel(n,t){let i=await W(()=>Re(n,t));if(!i.growth)throw u("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:a,remoteFeatures:g,...I}=i.growth;return Ke({scope:{projectId:o.projectId,environment:o.environment},funnelId:n,versionId:i.versionId,evaluationMode:"local",evaluationRevision:i.control.evaluationRevision,document:i.document,payload:I})},assertFunnel(n,t,i){ne();let a=d.funnels[n];if(!a||a.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable");if(a.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel now executes at Longplay");if(t!==void 0&&a.controlRevision!==t)throw u("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(i!==void 0&&!a.versions[i])throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!p){p=!0,x++,v=0,M?.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(s),clearTimeout(w),Oe(),Y(),A.clear();for(let n of R)n.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));h.clear(),z=0}}}}function ct(r){let o=ce.test(r.apiKey);if(typeof window<"u"&&!o)throw new L("SERVER_ONLY","Funnel starts are issued by your backend");if(!o&&!fe.test(r.apiKey))throw new L("INVALID_TOKEN","A customer credential or server API key is required");return{async start(f){let E=D.safeParse({...f,operation:"start"});if(!E.success||E.data.operation!=="start"||(o?E.data.customer!==void 0:E.data.customer===void 0))throw new L("INVALID_REQUEST","Invalid current Funnel start");let b=E.data,C=Qe({...r,timeoutMs:r.timeoutMs??35e3});try{r.session||C.identify(r.apiKey);let c=We(r,await C.request("funnels",b));if(!c.runToken)throw new L("INVALID_RESPONSE","Funnel start credentials are missing");if(c.run.source.id!==b.funnelId||c.run.locale!==(b.locale??"en")||!et(c.run.parameters,b.parameters??{})||(b.customer?!c.customerId||b.customer.type==="id"&&c.customerId!==b.customer.value:c.customerId!==void 0))throw new L("INVALID_RESPONSE","Funnel start contract changed");return{...c,runToken:c.runToken}}finally{C.dispose()}}}}async function En(r){r={...r};let o=r.configuration;if(!o)throw new L("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let f={projectId:o.scope.projectId,environment:o.scope.environment};if(r.scope&&N(f)!==N(r.scope))throw new L("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await o.funnelControl(r.funnelId)).evaluationMode!=="local")throw new L("EVALUATION_MODE","This Funnel uses Remote evaluation");let b=fe.test(r.credential);if(b?!r.customerId:r.customerId!==void 0)throw new L("INVALID_REQUEST","Only Server-Key starts name their Customer");let C=ct({...r,scope:f,apiKey:r.credential}),c=(y,d)=>{let v=tt({...r,scope:f,runToken:y,initialResponse:d,...b?{serverKey:r.credential}:{}});return b||v.identify(r.credential),v};return{async start(y){let d=await C.start({...y,funnelId:r.funnelId,...b?{customer:{type:"id",value:r.customerId}}:{}}),v=c(d.runToken,d),l=await v.get();return{...d,...l,controller:v}},async restore(y){let d=c(y),v=await d.get();if(v.run.source.id!==r.funnelId)throw d.reset(),new L("SCOPE_MISMATCH","Run belongs to another Funnel");return{...v,runToken:y,controller:d}}}}export{ot as a,yt as b,Nt as c,Tt as d,_t as e,Lt as f,Dt as g,Ht as h,ln as i,ct as j,En as k};
1
+ import{A as et,B as fe,F as tt,c as Be,d as Je,e as we,i as qe,j as He,k as $e,o as Ke,r as We}from"./chunk-KFIL73QY.js";import{a as Xe}from"./chunk-W74JLL2O.js";import{c as Fe,d as Ne,e as Te,f as _e,g as Le,i as De,m as Me,n as k,o as ke,q as ye,r as N,t as Ge,u as je,v as ze}from"./chunk-GH6FM44P.js";import{I as he,J as Ve,aa as D,u as Ue}from"./chunk-YV6UFESO.js";import{a as de,b as Qe}from"./chunk-7XDQKZYA.js";import{a as ce}from"./chunk-XJRDO3NI.js";import{J as le}from"./chunk-WZMZMJCK.js";import{b as oe}from"./chunk-HEHLFHW7.js";import{a as L}from"./chunk-U7NX5ET2.js";import{b as Ze}from"./chunk-3VUPVXAV.js";import{b as Ye}from"./chunk-AHUYZ6IW.js";import{b as e}from"./chunk-CR2XJ2CX.js";import{c as Ae,f as Pe}from"./chunk-O4KXODTJ.js";var G=e.literal(Ue),ft=e.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),Ie=e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),nt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("guest"),guestToken:Ie}),e.strictObject({type:e.literal("customer"),customer:he,customerData:Ve.optional()})]),ve=e.strictObject({id:e.uuid(),runId:e.uuid(),customerId:e.uuid(),requestId:e.uuid(),acceptedAt:e.iso.datetime({offset:!0})}),mt=e.strictObject({participantId:e.uuid(),startedAs:e.enum(["guest","identified"]),binding:ve.omit({runId:!0,requestId:!0}).nullable()}),pt=e.union([Be,e.strictObject({type:e.literal("authentication_required"),reason:e.enum(["customer_required","customer_experiment_required"]),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()})]),gt=Je.omit({authenticated:!0}).extend({identity:mt,instruction:pt.nullable()}),ht=e.discriminatedUnion("operation",[D.options[2].omit({customerToken:!0}),D.options[3].omit({customerToken:!0}),D.options[4].omit({customerToken:!0}),D.options[5].omit({customerToken:!0}),D.options[6].omit({customerToken:!0}),D.options[7].omit({customerToken:!0})]),me={contract:G,customerToken:e.string().regex(ce)},rt={contract:G,requestId:e.uuid(),runToken:ft,externalUserId:he.options[1].shape.value},ot=e.discriminatedUnion("operation",[e.strictObject({contract:G,operation:e.literal("describe")}),e.strictObject({contract:G,operation:e.literal("start"),source:nt,funnelId:D.options[0].shape.funnelId,requestId:e.uuid(),locale:D.options[0].shape.locale,parameters:D.options[0].shape.parameters}),qe.omit({operation:!0}).extend({contract:G,operation:e.literal("entry_start"),source:nt}),e.strictObject({...rt,operation:e.literal("bind_customer"),guestToken:Ie,claimRequestId:e.uuid(),expectedBindingId:e.null()}),e.strictObject({...rt,operation:e.literal("binding_status"),guestToken:Ie.optional()}),D.options[1].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("get"),settlementBindingId:e.uuid().nullable().optional()}),D.options[8].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("review")}),$e.omit({customerToken:!0}).extend(me),e.strictObject({...me,operation:e.literal("command"),identity:e.strictObject({bindingId:e.uuid().nullable()}),command:ht})]),yt=we.omit({run:!0}).extend({contract:G,run:gt,settlement:we.shape.settlement.unwrap().extend({accepted:e.boolean().nullable().optional()}).optional()}),Nt=He.extend({contract:G}),Tt=e.discriminatedUnion("operation",[ot.options[1].omit({contract:!0,source:!0,requestId:!0}),ot.options[2].omit({contract:!0,source:!0,requestId:!0})]),_t=yt.extend({binding:ve,outcome:e.enum(["bound","already_bound"]),replayed:e.boolean()}),Lt=e.discriminatedUnion("state",[e.strictObject({contract:G,scope:oe,state:e.literal("not_accepted")}),e.strictObject({contract:G,scope:oe,state:e.literal("conflict")}),e.strictObject({contract:G,scope:oe,state:e.literal("bound"),binding:ve})]),Dt=e.strictObject({contract:G,scope:oe,keyId:e.uuid(),operations:e.array(e.string()).max(20)});var it=e.string().regex(/^[a-f0-9]{64}$/),wt=Fe.omit({variations:!0,active:!0}).extend({changeId:it,variations:e.array(e.strictObject({urlRedirect:e.string().max(2048)})).min(2).max(20)}),at=e.strictObject({environmentId:e.uuid(),trackExposures:e.boolean(),generation:it,experiments:e.array(wt).max(100),savedGroups:Ne}),It=e.strictObject({eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}).optional(),deviceId:e.string().min(1).max(128),sessionId:e.string().min(1).max(128).optional(),url:e.url().max(2048),pageTitle:e.string().max(512).optional(),experimentKey:e.string().min(1).max(255),variationKey:e.string().min(1).max(64)}),kt=e.strictObject({events:e.array(It).min(1).max(20)}),Gt=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejected:e.array(e.strictObject({index:e.number().int().nonnegative(),reason:e.string()}))});function Ht(r){let o=null,f=null,E=0,b=0,C=new Set,c=null,y=null,d=new Set,v=()=>{for(let s of d)try{s()}catch{}},l={attributes:le.parse(r.attributes??{}),onFeatureUsage:r.onFeatureUsage?(s,w)=>{!C.has(s)&&o&&(!("analyticsConfig"in o)||o.analyticsConfig.featureUsageEnabled)&&r.onFeatureUsage(s,structuredClone(w),structuredClone(l.attributes),o.generation)}:void 0,onExperimentViewed:r.onExperimentViewed?(s,w)=>o&&(!("analyticsConfig"in o)||o.analyticsConfig.experimentViewsEnabled)&&r.onExperimentViewed(structuredClone(s),structuredClone(w),structuredClone(l.attributes),o.generation):void 0,stickyBucketAssignmentDocs:structuredClone(r.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:r.saveStickyBucketAssignmentDoc?s=>r.saveStickyBucketAssignmentDoc(structuredClone(s)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},S=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function p(s,w=new Set){return C.has(s)?!c||!c.features[s]||["unknownFeature","cyclicPrerequisite"].includes(c.features[s].source):w.has(s)?!1:(w.add(s),(o?.features[s]?.rules??[]).some(O=>[...O.parentConditions??[],...(O.tracks??[]).flatMap(A=>A.experiment.parentConditions??[])].some(A=>p(A.id,w))))}let x=s=>{if(r.assertUsable?.(o?.generation),!o)throw new Error("Initialize the Feature client before evaluation");if(o.expiresAt&&Date.parse(o.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return c?.expiresAt&&Date.parse(c.expiresAt)<=Date.now()&&(c=null,l.features=o.features),C.has(s)?!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now()?S():structuredClone(c.features[s]??S()):r.evaluateRemote&&(l.attributes?.merchandise||l.attributes?.merchandiseId)&&!c||p(s)?S():structuredClone(Pe(s,l))};async function U(){if(!o||!C.size&&!l.attributes?.merchandise&&!l.attributes?.merchandiseId)return;if(!r.evaluateRemote){if(C.size)throw new Error("Remote Feature evaluation requires a server loader");return}let s=b;if(y?.revision===s)return y.loading;let w=E,O=o,A=[...C],R=(async()=>{let h=De.parse(await r.evaluateRemote({attributes:structuredClone(l.attributes),features:A}));if(!(w!==E||s!==b||O!==o)){if(r.assertUsable?.(O.generation),h.generation!==O.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(A.some(P=>!Object.hasOwn(h.features,P))||Object.keys(h.features).some(P=>!C.has(P)))throw new Error("Invalid remote Feature results");if(l.attributes?.merchandise||l.attributes?.merchandiseId){if(!h.merchandiseContext)throw new Error("Server did not resolve merchandise context");l.attributes=le.parse({...l.attributes,...h.merchandiseContext})}c=structuredClone(h),l.features={...O.features,...Object.fromEntries(Object.entries(c.features).map(([P,z])=>[P,{defaultValue:z.value}]))},v()}})();y={revision:s,loading:R};try{await R}finally{y?.loading===R&&(y=null)}}function T(){U().catch(s=>{try{r.onError?.(s)}catch{}})}async function M(){if(f)return f;let s=E,w=(async()=>{let O=await r.load(),A="remoteFeatures"in O?_e.parse(O):null,R=A??Te.parse(O);if(R.scope.projectId!==r.scope.projectId||R.scope.environment!==r.scope.environment)throw new Error("Feature payload scope changed");if(s!==E)throw new Error("Feature client was reset");if(r.assertUsable&&o?.generation===R.generation){let{evaluatedAt:P,expiresAt:z,...ie}=o,{evaluatedAt:Y,expiresAt:pe,...j}=R;if(N(ie)!==N(j))throw new Error("Immutable Feature generation changed content");return o.evaluatedAt=R.evaluatedAt,o.expiresAt=R.expiresAt,v(),(!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now())&&T(),structuredClone(o)}let h=new Set(A?.remoteFeatures??[]);if([...h].some(P=>Object.hasOwn(R.features,P)))throw new Error("Remote Feature definitions must not be delivered locally");return o&&"analyticsConfig"in o&&"analyticsConfig"in R&&!o.analyticsConfig.experimentViewsEnabled&&A?.analyticsConfig.experimentViewsEnabled&&l.trackedExperiments?.clear(),o=structuredClone(R),C=h,c=null,y=null,b++,l.features=o.features,l.savedGroups=Ae(o.savedGroups),l.trackedFeatureUsage={},v(),T(),structuredClone(o)})();f=w;try{return await w}finally{f===w&&(f=null)}}return{init:M,refresh:M,refreshRemote:U,get generation(){return o?.generation??null},get expiresAt(){return o?.expiresAt??null},subscribe(s){return d.add(s),()=>{d.delete(s)}},setAttributes(s){let w=le.parse(s);(l.attributes?.merchandise||l.attributes?.merchandiseId||s.merchandise||s.merchandiseId)&&l.trackedExperiments?.clear(),l.attributes=w,b++,c=null,y=null,l.features=o?.features??{},l.trackedFeatureUsage={},v(),T()},evalFeature:x,isOn(s){return x(s).on},isOff(s){return x(s).off},getFeatureValue(s,w){let O=x(s).value;return structuredClone(O===null?w:O)},reset(){E++,b++,f=null,y=null,o=null,c=null,C.clear(),l.features={},l.savedGroups={},l.stickyBucketAssignmentDocs={},l.attributes={},l.trackedFeatureUsage={},l.trackedExperiments?.clear(),v()}}}var vt=e.record(e.string().regex(/^[a-f0-9]{64}$/),e.strictObject({at:e.number(),text:e.string()})),K=2*1048576,bt=100;function St(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function st(r,o){let f=o===void 0?St():o,E=new Map,b=0,C=!1,c=!1,y,d;async function v(S){if(!f)return null;let p;try{let x=await Promise.race([Promise.resolve().then(()=>f.getItem(S)),new Promise(U=>{p=setTimeout(()=>U(null),bt)})]);return typeof x=="string"&&x.length<=K&&new TextEncoder().encode(x).byteLength<=K?x:null}catch{return null}finally{clearTimeout(p)}}function l(){if(d)return d;let S=(async()=>{try{let p=await v(`${r}:artifacts`);if(p)return vt.parse(JSON.parse(p))}catch{}return{}})();return d=S,S.finally(()=>{d===S&&(d=void 0)}),S}return{async readManifest(){return v(r)},writeManifest(S){!f||S.length>K||new TextEncoder().encode(S).byteLength>K||(y=S,!c&&(c=!0,Promise.resolve().then(async()=>{try{for(;y!==void 0;){let p=y;try{await f.setItem(r,p)}catch{}y===p&&(y=void 0)}}finally{c=!1}})))},async readArtifact(S){let p=(await l())[S],x=Date.now();return p&&x>=p.at&&x-p.at<=k.retentionMs?p.text:void 0},writeArtifact(S,p){if(!f||p.length>K)return;let x=E.get(S);if(x?.text===p||!x&&E.size>=128)return;let U=new TextEncoder().encode(p).byteLength;b-(x?.byteLength??0)+U>K||(E.set(S,{text:p,byteLength:U}),b+=U-(x?.byteLength??0),!C&&(C=!0,Promise.resolve().then(async()=>{try{for(;E.size;){let T=new Map(E);try{let M={...await l()},s=Date.now();for(let[R,h]of T)M[R]={at:s,text:h.text};let w={},O=2,A=0;for(let[R,h]of Object.entries(M).sort(([,P],[,z])=>z.at-P.at)){if(h.at>s||s-h.at>k.retentionMs)continue;let P=new TextEncoder().encode(JSON.stringify({[R]:h})).byteLength;O+P>K||A>=128||(w[R]=h,O+=P,A++)}await f.setItem(`${r}:artifacts`,JSON.stringify(w))}catch{}finally{for(let[M,s]of T)E.get(M)===s&&(E.delete(M),b-=s.byteLength)}}}finally{C=!1}})))}}}var u=(r,o)=>new L(r,o),q=()=>performance.now(),ut=r=>{typeof r=="object"&&"unref"in r&&r.unref()};function ln(r){let o=ke.parse(r.scope),f=new de(r.origin??Ye);if(f.username||f.password||f.search||f.hash||f.pathname!=="/"||f.protocol!=="https:"&&!(f.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(f.hostname)))throw u("INVALID_URL","Configuration requires a trusted HTTPS origin");let E=new Set([f.origin,...(r.assetOrigins??[]).map(n=>{let t=new de(n);if(t.protocol!=="https:"||t.username||t.password||t.search||t.hash||t.pathname!=="/")throw u("INVALID_URL","Invalid configuration asset origin");return t.origin})]),b=r.fetch??globalThis.fetch.bind(globalThis),C=`/api/v1/configuration/${o.environmentId}`,c=`indiana:configuration:1:${f.origin}:${N(o)}`,y=st(c,r.storage),d,v=0,l=0,S=!1,p=!1,x=0,U=0,T,M,s,w,O=0,A=new Set,R=new Set,h=new Map,P=new Map,z=0,ie=!1;function Y(){for(let n of A)try{n()}catch{}}function pe(n){try{r.onError?.(n)}catch{}}let j=()=>!p&&!S&&!!d&&q()<v&&Date.now()<l;function ne(){if(!j())throw u("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function be(n,t,i){if(!h.has(n)){for(;h.size&&(h.size>=128||z+i>k.maxCacheBytes);){let a=h.entries().next().value;z-=a[1].byteLength,h.delete(a[0])}h.set(n,{text:t,byteLength:i}),z+=i}}function Se(n,t,i){return Ze(n,t,{signal:i,error:a=>u("INVALID_RESPONSE",a==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function xe(n){let t=new de(n,f);if(!E.has(t.origin)||t.username||t.password||t.hash||t.search)throw u("INVALID_URL","Configuration artifact origin is not trusted");return t.href}async function ge(n,t,i=!1){let a=await b(xe(n),{method:"GET",credentials:"omit",redirect:"error",cache:i?"default":"no-cache",signal:t,headers:{}});if(a.status===429){let g=a.headers.get("retry-after")??"";O=/^\d+$/.test(g)?Number(g)*1e3:Math.max(0,Date.parse(g)-Date.now())||15e3}if(!a.ok&&a.status!==304)throw u(`CONFIGURATION_HTTP_${a.status}`,"Configuration synchronization failed");return a}function lt(n,t,i){let a=Date.parse(n.headers.get("x-indiana-config-validated-at")??""),g=Date.parse(n.headers.get("x-indiana-config-valid-until")??""),I=Date.parse(n.headers.get("date")??""),m=n.headers.get("age"),V=m!==null&&/^\d+(\.\d+)?$/.test(m)?Number(m)*1e3:NaN;if(![a,g,I,V].every(Number.isFinite)||g<=a||g-a>k.maxControlAgeMs||a>I+1e3)throw u("INVALID_RESPONSE","Configuration freshness evidence is invalid");let F=Math.min(g-a,i.maxControlAgeSeconds*1e3,k.maxControlAgeMs)-Math.max(V,I-a,0)-(q()-t);if(F<=0)throw u("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return q()+F}function ae(){if(clearTimeout(s),clearTimeout(w),p||!A.size||(j()&&(w=setTimeout(()=>{j()?ae():Y()},Math.max(1,v-q())),ut(w)),typeof document<"u"&&document.visibilityState==="hidden"))return;let n=U?Math.min(15e3,1e3*2**Math.min(U-1,4)):Math.min(15e3,(d?.policy.refreshIntervalSeconds??15)*1e3);s=setTimeout(()=>{Q().catch(pe)},Math.max(O,n*(.8+Math.random()*.2))),ut(s)}async function Q(){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(T)return T;let n=x,t=new AbortController;M=t;let i=(async()=>{if(!ie){ie=!0;try{let ue=await y.readManifest();if(ue&&!d){let J=ye.parse(JSON.parse(ue));N(J.scope)===N(o)&&(d=J)}}catch{}}t.signal.throwIfAborted();let m=d,V=q(),_=await ge(C,t.signal);_.status===304&&(!m||!_.headers.has("x-indiana-config-validated-at")||!_.headers.has("x-indiana-config-valid-until")||!_.headers.has("age"))&&(_=await ge(C,t.signal));let F=_.status===304?m:ye.parse(JSON.parse(await Se(_,k.maxManifestBytes,t.signal))),{generation:ee,...te}=F,B=_.headers.get("etag");if(N(F.scope)!==N(o)||Ge(te)!==ee||B!==`"${ee}"`&&B!==`W/"${ee}"`)throw u("INVALID_RESPONSE","Configuration scope or content identity changed");if(m&&(F.revision<m.revision||F.revision===m.revision&&F.generation!==m.generation))throw u("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[ue,J]of Object.entries(m?.funnels??{})){let $=F.funnels[ue];if($&&($.controlRevision<J.controlRevision||$.evaluationRevision<J.evaluationRevision||$.controlRevision===J.controlRevision&&$.state!==J.state||$.evaluationRevision===J.evaluationRevision&&$.evaluationMode!==J.evaluationMode))throw u("INVALID_RESPONSE","Funnel control revision changed identity")}let H=lt(_,V,F.policy);if(t.signal.throwIfAborted(),n!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return d=F,v=H,l=Date.now()+Math.max(0,H-q()),S=!1,U=0,O=0,y.writeManifest(N(F)),Y(),structuredClone(F)})(),a=setTimeout(()=>t.abort(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs),g=new Promise((m,V)=>t.signal.addEventListener("abort",()=>V(t.signal.reason),{once:!0})),I=Promise.race([i,g]).catch(m=>{throw U++,(m instanceof e.ZodError||m instanceof SyntaxError||m instanceof L&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(m.code))&&(v=0,S=!0,Y()),m}).finally(()=>{clearTimeout(a),T===I&&(T=void 0),ae()});return T=I,I}async function se(n){let t=n.sha256,i=te=>Xe(te,n);xe(n.url);let a=h.get(t);if(a){if(a.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return h.delete(t),h.set(t,a),a.text}let g=P.get(t);if(g){if(g.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return g.promise}let I=new AbortController;R.add(I);let m=x,V=(async()=>{try{let H=await y.readArtifact(t);if(H&&i(H)){if(I.signal.throwIfAborted(),p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,H,n.byteLength),H}}catch{}I.signal.throwIfAborted();let te=await ge(n.url,I.signal,!0),B=await Se(te,n.byteLength,I.signal);if(!i(B))throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,B,n.byteLength),y.writeArtifact(t,B),B})(),_=setTimeout(()=>I.abort(u("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),k.initializationMs),F=new Promise((te,B)=>I.signal.addEventListener("abort",()=>B(I.signal.reason),{once:!0})),ee=Promise.race([V,F]).finally(()=>{clearTimeout(_),R.delete(I),P.delete(t)});return P.set(t,{promise:ee,byteLength:n.byteLength}),ee}async function re(){return j()||await Q(),ne(),d}async function W(n){let t,i=new Promise((a,g)=>{t=setTimeout(()=>g(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs)});try{return await Promise.race([n(),i])}finally{clearTimeout(t)}}function Z(n,t){if(ne(),d?.generation!==n.generation)throw u("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(t&&d.funnels[t]?.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function Ee(n){let t=n.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let a=Le.parse(JSON.parse(await se(i)));if(N(a.scope)!==N({projectId:o.projectId,environment:o.environment})||a.generation!==i.generation||a.remoteFeatures.some(g=>Object.hasOwn(a.features,g)))throw u("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return Z(n),{...a,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,v-q())).toISOString()}}async function Ce(n,t){let i=await re(),a=i.funnels[n];t&&(!a||a.evaluationMode==="local"&&!a.versions[t])&&(T&&await T,i=await Q()),Z(i,n);let g=i.funnels[n];if(g.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let I=t??g.currentVersionId,m=g.versions[I];if(!m)throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(i.artifacts[m.artifact].formatVersion!==3)throw u("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[V,_]=await Promise.all([se(i.artifacts[m.artifact]).then(F=>ze(JSON.parse(F))),g.evaluationMode==="local"?Ee(i):void 0]);if(_&&N(je(V,_))!==N(m.dependencies))throw u("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return Z(i,n),{document:V,growth:_,versionId:I,control:structuredClone(g),manifest:structuredClone(i)}}async function Re(n,t){try{return await Ce(n,t)}catch(i){if(!(i instanceof L)||!(i.code==="CONFIGURATION_CHANGED"||i.code==="CONFIGURATION_HTTP_404"&&j()))throw i;let a=d?.generation;if(T&&await T,await Q(),i.code!=="CONFIGURATION_CHANGED"&&d?.generation===a)throw i;return Ce(n,t)}}function X(){if(j()||Y(),typeof document<"u"&&document.visibilityState==="hidden"){ae();return}Q().catch(pe)}function dt(n){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return A.add(n),A.size===1&&(typeof window<"u"&&(window.addEventListener("online",X),window.addEventListener("focus",X),document.addEventListener("visibilitychange",X)),ae()),()=>{A.delete(n),A.size||(clearTimeout(s),clearTimeout(w),Oe())}}function Oe(){typeof window<"u"&&(window.removeEventListener("online",X),window.removeEventListener("focus",X),document.removeEventListener("visibilitychange",X))}return{scope:Object.freeze({...o}),refresh:Q,subscribe:dt,assertFresh:ne,assertFeatures(n){ne();let t=d.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(n!==void 0&&d.artifacts[t].generation!==n)throw u("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return j()},get snapshot(){return d?structuredClone(d):null},get remainingMs(){return j()?Math.max(0,v-q()):0},async features(){return W(async()=>Ee(await re()))},pageExperiments:()=>W(async()=>{let n=await re(),t=n.gb.pageExperiments;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let a=at.parse(JSON.parse(await se(i)));if(a.environmentId!==o.environmentId||a.generation!==i.generation)throw u("INVALID_RESPONSE","Page experiment scope or generation changed");return Z(n),a}),funnel:(n,t)=>W(()=>Re(n,t)),funnelControl:n=>W(async()=>{let t=await re();return Z(t,n),structuredClone(t.funnels[n])}),paywall:(n,t)=>W(async()=>{let i=await re(),a=i.paywalls?.[n];if(!a||!t&&a.state!=="published")throw u("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let g=t??a.currentVersionId,I=a.versions[g],m=I&&i.artifacts[I.artifact];if(!m||m.kind!=="paywall"||m.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let V=Me.parse(JSON.parse(await se(m)));return Z(i),{document:V,versionId:g,version:I.version,control:structuredClone(a),manifest:structuredClone(i)}}),async localFunnel(n,t){let i=await W(()=>Re(n,t));if(!i.growth)throw u("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:a,remoteFeatures:g,...I}=i.growth;return Ke({scope:{projectId:o.projectId,environment:o.environment},funnelId:n,versionId:i.versionId,evaluationMode:"local",evaluationRevision:i.control.evaluationRevision,document:i.document,payload:I})},assertFunnel(n,t,i){ne();let a=d.funnels[n];if(!a||a.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable");if(a.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel now executes at Longplay");if(t!==void 0&&a.controlRevision!==t)throw u("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(i!==void 0&&!a.versions[i])throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!p){p=!0,x++,v=0,M?.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(s),clearTimeout(w),Oe(),Y(),A.clear();for(let n of R)n.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));h.clear(),z=0}}}}function ct(r){let o=ce.test(r.apiKey);if(typeof window<"u"&&!o)throw new L("SERVER_ONLY","Funnel starts are issued by your backend");if(!o&&!fe.test(r.apiKey))throw new L("INVALID_TOKEN","A customer credential or server API key is required");return{async start(f){let E=D.safeParse({...f,operation:"start"});if(!E.success||E.data.operation!=="start"||(o?E.data.customer!==void 0:E.data.customer===void 0))throw new L("INVALID_REQUEST","Invalid current Funnel start");let b=E.data,C=Qe({...r,timeoutMs:r.timeoutMs??35e3});try{r.session||C.identify(r.apiKey);let c=We(r,await C.request("funnels",b));if(!c.runToken)throw new L("INVALID_RESPONSE","Funnel start credentials are missing");if(c.run.source.id!==b.funnelId||c.run.locale!==(b.locale??"en")||!et(c.run.parameters,b.parameters??{})||(b.customer?!c.customerId||b.customer.type==="id"&&c.customerId!==b.customer.value:c.customerId!==void 0))throw new L("INVALID_RESPONSE","Funnel start contract changed");return{...c,runToken:c.runToken}}finally{C.dispose()}}}}async function En(r){r={...r};let o=r.configuration;if(!o)throw new L("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let f={projectId:o.scope.projectId,environment:o.scope.environment};if(r.scope&&N(f)!==N(r.scope))throw new L("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await o.funnelControl(r.funnelId)).evaluationMode!=="local")throw new L("EVALUATION_MODE","This Funnel uses Remote evaluation");let b=fe.test(r.credential);if(b?!r.customerId:r.customerId!==void 0)throw new L("INVALID_REQUEST","Only Server-Key starts name their Customer");let C=ct({...r,scope:f,apiKey:r.credential}),c=(y,d)=>{let v=tt({...r,scope:f,runToken:y,initialResponse:d,...b?{serverKey:r.credential}:{}});return b||v.identify(r.credential),v};return{async start(y){let d=await C.start({...y,funnelId:r.funnelId,...b?{customer:{type:"id",value:r.customerId}}:{}}),v=c(d.runToken,d),l=await v.get();return{...d,...l,controller:v}},async restore(y){let d=c(y),v=await d.get();if(v.run.source.id!==r.funnelId)throw d.reset(),new L("SCOPE_MISMATCH","Run belongs to another Funnel");return{...v,runToken:y,controller:d}}}}export{ot as a,yt as b,Nt as c,Tt as d,_t as e,Lt as f,Dt as g,Ht as h,ln as i,ct as j,En as k};
@@ -0,0 +1 @@
1
+ import{i as ie}from"./chunk-DDLSQSWO.js";import{a as Z,c as ee,e as te,f as ne,h as N,j as re,k as oe,l as se}from"./chunk-AOGDCT4T.js";import{b as X}from"./chunk-UV4H6VCS.js";import{r as V}from"./chunk-GH6FM44P.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-AB7GEGZ2.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import{$ as Y,D as G,I as R,aa as K,r as $}from"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import{a as p}from"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-AHUYZ6IW.js";import{b as u}from"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
@@ -1 +1 @@
1
- import{b as B}from"./chunk-OL2AI6DA.js";import{a as z}from"./chunk-I6D25FWU.js";import{b as S}from"./chunk-DB4EO3JG.js";import{b as V}from"./chunk-BL7E4RZ2.js";import"./chunk-VWMFR22O.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-YQX27SBG.js";import"./chunk-M3GGR53D.js";import"./chunk-UVUFJO2V.js";import"./chunk-HYE2YQYM.js";import"./chunk-MHWPEMX7.js";import"./chunk-5XKFUFXK.js";import"./chunk-2KKLY323.js";import"./chunk-R3YVDRTB.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as v}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import"./chunk-LVG5ED52.js";import"./chunk-3VUPVXAV.js";import"./chunk-RHF4NFCZ.js";import"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
1
+ import{b as B}from"./chunk-HKXFCRVT.js";import{a as z}from"./chunk-XGNXZWZL.js";import{b as S}from"./chunk-TASEZY5T.js";import{b as V}from"./chunk-OQRMAU2B.js";import"./chunk-2KJLN65C.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-AOGDCT4T.js";import"./chunk-ZYOZSUZS.js";import"./chunk-VIBJNB5B.js";import"./chunk-KFIL73QY.js";import"./chunk-CY7OKV7E.js";import"./chunk-4KLXQKNO.js";import"./chunk-S43TYW3V.js";import"./chunk-W74JLL2O.js";import"./chunk-ECKVJGXQ.js";import"./chunk-GH6FM44P.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-3NCMYTNG.js";import"./chunk-AB7GEGZ2.js";import"./chunk-Q676H74B.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import{a as v}from"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-SLUA7ABW.js";import"./chunk-OCWSWXCW.js";import"./chunk-3VUPVXAV.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-TASEZY5T.js";import"./chunk-Q676H74B.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-CR2XJ2CX.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-HKXFCRVT.js";import"./chunk-XGNXZWZL.js";import"./chunk-TASEZY5T.js";import"./chunk-2KJLN65C.js";import"./chunk-W32FI2A2.js";import"./chunk-AOGDCT4T.js";import"./chunk-YV6UFESO.js";import"./chunk-WQ3O5RXN.js";import"./chunk-3NCMYTNG.js";import"./chunk-AB7GEGZ2.js";import"./chunk-Q676H74B.js";import"./chunk-7XDQKZYA.js";import"./chunk-XJRDO3NI.js";import"./chunk-WZMZMJCK.js";import"./chunk-T2KWLYCW.js";import"./chunk-LOLMUXHW.js";import"./chunk-HEHLFHW7.js";import"./chunk-U7NX5ET2.js";import"./chunk-VLSP3LRH.js";import"./chunk-SLUA7ABW.js";import"./chunk-OCWSWXCW.js";import"./chunk-AHUYZ6IW.js";import"./chunk-CR2XJ2CX.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
package/dist/index.d.ts CHANGED
@@ -5,10 +5,10 @@ import { J as JsonValue } from './growth-rules-B4YYy64R.js';
5
5
  import { S as StackNode, a as ScreenSelection } from './screen-qUBRsUi9.js';
6
6
  import { P as PaywallSession, S as SubscriptionOperation, F as FunnelCommandStorage, s as scopeSchema, a as FunnelStartInput, I as IndianaOptions, b as SessionCredentials, c as FunnelExecutionPolicy, d as PaywallRecovery, e as SubscriptionAttachQuote, f as FunnelRunController, g as PaywallResolution, h as FunnelRunView, i as IamFunnelEntryDelivery, j as FunnelProcessRunView, k as createPaywallSession$1 } from './funnel-local-client-DR8OpKGU.js';
7
7
  export { C as CustomerSession, l as FeatureClient, m as FeatureClientOptions, n as FunnelControllerResponse, o as FunnelPendingEntry, p as FunnelPurchaseRecovery, q as FunnelRuntimeResponse, r as FunnelSegmentPrediction, L as LocalFunnelClient, t as LocalFunnelClientOptions, u as LongplayError, v as PaywallPurchaseInput, w as PaywallStartInput, x as PushHost, y as PushJournal, z as createFeatureClient, A as createFunnelRunController, B as createLocalFunnelClient, D as getPaywallRecovery, E as preparePaywallFallback } from './funnel-local-client-DR8OpKGU.js';
8
+ import { C as CouponInput, O as Offer } from './coupon-kfkIVf9n.js';
9
+ export { a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
8
10
  import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-COxXtZEQ.js';
9
11
  export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-COxXtZEQ.js';
10
- import { C as CouponInput } from './coupon-kfkIVf9n.js';
11
- export { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
12
12
  import { c as createFunnelProcess } from './funnel-process-client-C87U4r_G.js';
13
13
  export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-C87U4r_G.js';
14
14
  export { C as ConfigurationStorage, a as ConfigurationSync, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-BHrAf-ql.js';
@@ -304,6 +304,8 @@ type PaywallPurchaseIntent = {
304
304
  featureQuantities: Record<string, number>;
305
305
  };
306
306
  type PaywallHostOptions = PresentationLoadingOptions & {
307
+ /** Mount host controls inside this Paywall. Return synchronous teardown for destroy, cancellation or failure. */
308
+ mountControls?: (container: HTMLElement) => void | (() => void);
307
309
  /** An already available Paywall design for the first frame. */
308
310
  loadingDocument?: PaywallLoadingDocument;
309
311
  /** Coordinates presentation reads with an enclosing host. */
@@ -344,6 +346,13 @@ type PaywallHostOptions = PresentationLoadingOptions & {
344
346
  productVersionId: string;
345
347
  featureQuantities: Readonly<Record<string, number>>;
346
348
  }) => string | undefined | Promise<string | undefined>;
349
+ /**
350
+ * Opt in to the Coupon an authored purchase button is bound to: the SDK claims it for the
351
+ * Customer at the click and quotes with that offer instead of calling `resolveOfferId`.
352
+ */
353
+ claimCoupon?: (couponId: string, requestId: string) => Promise<{
354
+ offer: Offer | null;
355
+ }>;
347
356
  onOpenUrl?: (url: string) => unknown;
348
357
  onEvent?: (name: string) => unknown;
349
358
  /** An authored non-purchase button completed its action. */
@@ -1611,6 +1620,7 @@ declare function prerenderFunnelPurchase$1(container: HTMLElement, input: {
1611
1620
 
1612
1621
  type FunnelHostOptions = PresentationLoadingOptions & {
1613
1622
  client: FunnelRunController;
1623
+ closeActions?: readonly string[];
1614
1624
  /**
1615
1625
  * A pre-rendered Paywall, handed to the SDK: revealed, the first Paywall takes it over when it is
1616
1626
  * the same and untouched; otherwise it is released. Closed before the takeover, the Run closes.
@@ -1631,6 +1641,7 @@ type FunnelHostOptions = PresentationLoadingOptions & {
1631
1641
  terminateCheckout?: PaywallHostOptions["terminateCheckout"];
1632
1642
  confirmOnHostedCheckout?: PaywallHostOptions["confirmOnHostedCheckout"];
1633
1643
  resolveOfferId?: PaywallHostOptions["resolveOfferId"];
1644
+ claimCoupon?: PaywallHostOptions["claimCoupon"];
1634
1645
  /**
1635
1646
  * Opens an external page or a Paywall link. Return `false` (or throw) when the page could not be
1636
1647
  * opened; an external page then takes its `failed` route. Without a handler, `same_window` navigates
@@ -2407,6 +2418,8 @@ declare function showPaywall(container: HTMLElement, options: PaywallHostOptions
2407
2418
  }>;
2408
2419
  };
2409
2420
  }>;
2421
+ /** Load presentation code without starting a session; return the public Paywall factory. */
2422
+ declare function preloadPaywall(): Promise<typeof showPaywall>;
2410
2423
  declare function createPaywallSession(...args: Parameters<typeof createPaywallSession$1>): Promise<PaywallSession>;
2411
2424
 
2412
2425
  /** Loading customer API clients does not initialize the UI renderer. */
@@ -2438,6 +2451,13 @@ declare function showFunnelPurchase(...args: Parameters<typeof showFunnelPurchas
2438
2451
  * `locale` are required while `start` is a promise.
2439
2452
  */
2440
2453
  declare function prerenderFunnelPurchase(...args: Parameters<typeof prerenderFunnelPurchase$1>): Promise<PreparedFunnelPurchase>;
2454
+ /**
2455
+ * Loads the code a Funnel purchase presents with, before any Customer is known: the pre-render,
2456
+ * the purchase host, the Paywall and its renderer. No session, request or DOM. Call it as soon as
2457
+ * the page can spare the download, so a later `prerenderFunnelPurchase` reads its Paywall at once
2458
+ * instead of waiting for these chunks one after another.
2459
+ */
2460
+ declare function preloadFunnelPurchase(): Promise<void>;
2441
2461
 
2442
2462
  declare function mountContent(...args: Parameters<typeof mountContent$1>): Promise<{
2443
2463
  destroy: () => void;
@@ -2457,4 +2477,4 @@ declare function prepareContent(...args: Parameters<typeof prepareContent$1>): P
2457
2477
  updateCapabilities(data: SurfaceData): void;
2458
2478
  }>;
2459
2479
 
2460
- export { type ContentActionIntent, type ContentHostOptions, EntitlementCheckResult, FunnelCommandStorage, FunnelExecutionPolicy, type FunnelHostOptions, type FunnelPurchaseAttempt, type FunnelPurchaseClient, type FunnelPurchaseEntry, type FunnelPurchaseHostOptions, type FunnelPurchaseOptions, type FunnelPurchaseStart, type FunnelPurchaseState, type FunnelPurchaseStorage, FunnelRunController, type IamFunnelEntriesOptions, type IamFunnelProcessEntriesOptions, IndianaOptions as LongplayOptions, MerchantBridgeError, type MerchantBridgeOptions, type PaywallHostOptions, PaywallLoadingDocument, type PaywallPurchaseIntent, PaywallRecovery, PaywallSession, type PreparedFunnelPurchase, type PreparedState, PresentationLoadingOptions, SessionCredentials, createBrowserFunnelCommandStorage, createBrowserFunnelPurchaseStorage, createFunnelPageExperiments, createFunnelProcess, createFunnelPurchaseClient, createIamFunnelEntries, createIamFunnelProcessEntries, createMerchantBridge, createPaywallSession, formatCouponDiscount, formatCouponMoney, formatCouponTerms, mountContent, prepareContent, prerenderFunnelPurchase, showFunnelPurchase, showFunnelRun, showPaywall };
2480
+ export { type ContentActionIntent, type ContentHostOptions, EntitlementCheckResult, FunnelCommandStorage, FunnelExecutionPolicy, type FunnelHostOptions, type FunnelPurchaseAttempt, type FunnelPurchaseClient, type FunnelPurchaseEntry, type FunnelPurchaseHostOptions, type FunnelPurchaseOptions, type FunnelPurchaseStart, type FunnelPurchaseState, type FunnelPurchaseStorage, FunnelRunController, type IamFunnelEntriesOptions, type IamFunnelProcessEntriesOptions, IndianaOptions as LongplayOptions, MerchantBridgeError, type MerchantBridgeOptions, Offer, type PaywallHostOptions, PaywallLoadingDocument, type PaywallPurchaseIntent, PaywallRecovery, PaywallSession, type PreparedFunnelPurchase, type PreparedState, PresentationLoadingOptions, SessionCredentials, createBrowserFunnelCommandStorage, createBrowserFunnelPurchaseStorage, createFunnelPageExperiments, createFunnelProcess, createFunnelPurchaseClient, createIamFunnelEntries, createIamFunnelProcessEntries, createMerchantBridge, createPaywallSession, formatCouponDiscount, formatCouponMoney, formatCouponTerms, mountContent, preloadFunnelPurchase, preloadPaywall, prepareContent, prerenderFunnelPurchase, showFunnelPurchase, showFunnelRun, showPaywall };