@tinkerlandai/longplay-sdk 0.10.40 → 0.10.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +57 -1
- package/README.zh-CN.md +5 -1
- package/dist/{ai-usage-DXwAGTxT.d.ts → ai-usage-B-qsCn-k.d.ts} +1 -1
- package/dist/{api-r6FfVQpg.d.ts → api-DpRb_Pd3.d.ts} +52 -0
- package/dist/check-response-OIBVUP72.js +1 -0
- package/dist/chunk-2EVGXJ4R.js +1 -0
- package/dist/chunk-3SXPCVIP.js +1 -0
- package/dist/chunk-3WTVQ6OV.js +1 -0
- package/dist/{chunk-LSPHUA7V.js → chunk-5JRBCW6V.js} +1 -1
- package/dist/chunk-5TJISOWN.js +1 -0
- package/dist/{chunk-X6ONZGRY.js → chunk-67SIVUOS.js} +1 -1
- package/dist/chunk-6XRXHFM6.js +1 -0
- package/dist/chunk-7MYS52FL.js +1 -0
- package/dist/chunk-ABXCDVC7.js +1 -0
- package/dist/{chunk-2DPNSTCN.js → chunk-AC53CUJE.js} +1 -1
- package/dist/chunk-ANXDWUPK.js +1 -0
- package/dist/chunk-AQONMY2H.js +1 -0
- package/dist/chunk-ASL7TJFU.js +1 -0
- package/dist/{chunk-ORMQJAQE.js → chunk-AV2WZSII.js} +1 -1
- package/dist/chunk-B4AELNLE.js +1 -0
- package/dist/{chunk-O4KXODTJ.js → chunk-C4NG6RVA.js} +1 -1
- package/dist/chunk-CALDEF4M.js +1 -0
- package/dist/chunk-CSLTAXC7.js +1 -0
- package/dist/chunk-CWD36SJO.js +1 -0
- package/dist/chunk-DCZWNTG2.js +1 -0
- package/dist/chunk-DGZCD3AY.js +1 -0
- package/dist/{chunk-57GPGWSK.js → chunk-FTGRTYBL.js} +1 -1
- package/dist/chunk-HLCDAU5A.js +1 -0
- package/dist/{chunk-CZ4TQCUV.js → chunk-HTXB2WVI.js} +1 -1
- package/dist/chunk-JWTA2OCB.js +1 -0
- package/dist/{chunk-VC2HPREX.js → chunk-KEF6HIFK.js} +1 -1
- package/dist/chunk-KP4QI4RX.js +1 -0
- package/dist/{chunk-FCDWCQYC.js → chunk-LSVTH3TS.js} +1 -1
- package/dist/chunk-LUGZNBIW.js +1 -0
- package/dist/{chunk-YLPQLD2A.js → chunk-LZ3OJYBY.js} +1 -1
- package/dist/{chunk-5DZJCFNQ.js → chunk-MEDW4N3F.js} +1 -1
- package/dist/{chunk-7QDT6DO7.js → chunk-MPD3UIY4.js} +1 -1
- package/dist/chunk-MWICFZUF.js +1 -0
- package/dist/{chunk-POCDWUD3.js → chunk-NVF54BDR.js} +1 -1
- package/dist/{chunk-C2KT5ZFU.js → chunk-O6CUNETH.js} +1 -1
- package/dist/chunk-OXXPMJRJ.js +1 -0
- package/dist/{chunk-P6C3PNMQ.js → chunk-P6TNBX2S.js} +1 -1
- package/dist/{chunk-EREQZWGI.js → chunk-PBZSOTKZ.js} +1 -1
- package/dist/chunk-QHWR5UHD.js +1 -0
- package/dist/{chunk-33ZVZOSC.js → chunk-RDUKCMST.js} +1 -1
- package/dist/{chunk-ASDJTOGM.js → chunk-RJY5CUTB.js} +1 -1
- package/dist/chunk-S7A3IBAF.js +10 -0
- package/dist/{chunk-QZTTKH2H.js → chunk-SVLEVNHP.js} +1 -1
- package/dist/{chunk-WLGLQJ6M.js → chunk-TL67SYPH.js} +1 -1
- package/dist/{chunk-YY445FBU.js → chunk-UJMP7AMY.js} +1 -1
- package/dist/{chunk-67AY54E2.js → chunk-V65FSNYO.js} +1 -1
- package/dist/chunk-VILB5M4X.js +1 -0
- package/dist/{chunk-RV6UAUK2.js → chunk-ZICZN6WO.js} +1 -1
- package/dist/{configuration-sync-BHrAf-ql.d.ts → configuration-sync-7ruSsSrL.d.ts} +150 -1
- package/dist/content-KSIF5AXD.js +1 -0
- package/dist/funnel-host-purchase-YNC4LQJS.js +1 -0
- package/dist/{funnel-local-client-DR8OpKGU.d.ts → funnel-local-client-BMxDQWE6.d.ts} +51987 -22983
- package/dist/{funnel-node-evaluation-COxXtZEQ.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -0
- package/dist/funnel-paywall-prerender-DAAQUEEZ.js +1 -0
- package/dist/{funnel-process-client-C87U4r_G.d.ts → funnel-process-client-DNR9nHs8.d.ts} +7338 -3163
- package/dist/funnel-route-prediction-XGCMCIKA.js +1 -0
- package/dist/funnel-route-source-O76QSUYU.js +1 -0
- package/dist/funnel-runtime-host-WPU42YVT.js +1 -0
- package/dist/index.d.ts +273 -22
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-FB63H7NE.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-YSFIINLK.js +1 -0
- package/dist/page.d.ts +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-PZ4BBEFG.js +1 -0
- package/dist/paywall-content-5IWLT7YD.js +1 -0
- package/dist/paywall-session-K7GPR3UF.js +1 -0
- package/dist/popup.d.ts +2 -2
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-B_v5XZtM.d.ts → presentation-loading-B2OeFzRN.d.ts} +1 -0
- package/dist/react-native.d.ts +6 -6
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-RDXKWHYE.js +1 -0
- package/dist/server.d.ts +34204 -17797
- package/dist/server.js +1 -1
- package/dist/{visual-dom-5LUN4AHO.js → visual-dom-IN6DRNX3.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-DRQCUWDW.js +0 -1
- package/dist/chunk-3NCMYTNG.js +0 -1
- package/dist/chunk-4TEZZZYK.js +0 -1
- package/dist/chunk-6PG3AS3G.js +0 -1
- package/dist/chunk-AZFWG352.js +0 -1
- package/dist/chunk-BYP4KVB3.js +0 -10
- package/dist/chunk-C3GYAKIU.js +0 -1
- package/dist/chunk-ESAHTG3Y.js +0 -1
- package/dist/chunk-GC6JBIRQ.js +0 -1
- package/dist/chunk-IJKAQNK6.js +0 -1
- package/dist/chunk-IOJVF52Q.js +0 -1
- package/dist/chunk-OOD2VDDP.js +0 -1
- package/dist/chunk-P23JOPR5.js +0 -1
- package/dist/chunk-PJS7M6X3.js +0 -1
- package/dist/chunk-PZOQV6MU.js +0 -1
- package/dist/chunk-RFNIGJOL.js +0 -1
- package/dist/chunk-RULQQ7WI.js +0 -1
- package/dist/chunk-U7GH4VME.js +0 -1
- package/dist/chunk-VOKEZHAH.js +0 -1
- package/dist/chunk-XDOKFAE6.js +0 -1
- package/dist/chunk-Y6HL2IY2.js +0 -1
- package/dist/content-QUEVNSXD.js +0 -1
- package/dist/funnel-host-purchase-LMVMJNUO.js +0 -1
- package/dist/funnel-paywall-prerender-LGUSHEP3.js +0 -1
- package/dist/funnel-runtime-host-H5FM67UC.js +0 -1
- package/dist/merchant-bridge-contracts-LZSQYE3O.js +0 -1
- package/dist/operation-contracts-O7TCDGV4.js +0 -1
- package/dist/paywall-UANWOKKC.js +0 -1
- package/dist/paywall-content-CHPX2P77.js +0 -1
- package/dist/paywall-session-3BNUC5ZE.js +0 -1
- package/dist/screen-renderer-FFVZ64MR.js +0 -1
- /package/dist/{chunk-RGEBK6UF.js → chunk-GPJF3T43.js} +0 -0
- /package/dist/{chunk-OJM6ORHE.js → chunk-RA7GZ67U.js} +0 -0
- /package/dist/{chunk-CILM5XMH.js → chunk-WPFTSHP2.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./chunk-
|
|
1
|
+
import{b as e}from"./chunk-GPJF3T43.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as d,D as u}from"./chunk-KP4QI4RX.js";function f(r){let{quote:o,operation:e,requestId:s}=r,a={type:"recover",operationId:e?.operationId??o?.operationId??null,requestId:s};if(r.destroyed||r.pending)return a;if(!e)return o?{type:"cancel",operationId:o.operationId}:a;let t=e.merchantExecution;if(d(e)){if(t&&t.type!=="subscription_change")return a;if(t?.type==="subscription_change"){if(["applied","scheduled"].includes(t.status))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&u(e)&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&!e.problem&&!t.problem&&t.nextAction?.type==="redirect"&&(!e.checkoutUrl||t.nextAction.url===e.checkoutUrl)&&Date.parse(t.nextAction.expiresAt)>Date.now()&&t.status==="pending")return{type:"checkout",operationId:e.operationId,checkoutUrl:t.nextAction.url}}if(!e.problem&&!t?.problem&&u(e)&&e.executor!=="merchant")return{type:"complete",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let n=p=>!p||p.phase==="execution"&&p.reason==="STATE_CHANGED";return r.canReselect===!0&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&n(e.problem)&&n(t?.problem)&&(!t||t.status==="failed"&&t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable")?{type:"native",operationId:e.operationId}:["prepared","quoted"].includes(e.status)&&!e.confirmedAt&&!t&&!e.checkoutUrl&&!e.problem?{type:"cancel",operationId:e.operationId}:a}if(t?.type==="purchase"){if(["succeeded","not_required"].includes(t.paymentStatus))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&!e.problem&&!t.problem&&t.checkoutUrl===e.checkoutUrl&&t.checkoutExpiresAt&&Date.parse(t.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(t.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let c=[e.problem,t?.problem],i=c.every(n=>!n||n.phase==="execution"&&n.reason!=="RESULT_UNKNOWN"),y=e.status==="cancelled"&&!c.some(Boolean)&&t?.type==="purchase"&&["pending","not_started","expired"].includes(t.paymentStatus)&&["not_started","not_applicable"].includes(t.fulfillmentStatus);return r.canReselect===!0&&i&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"||!t||t.type==="purchase"&&!["succeeded","not_required"].includes(t.paymentStatus)&&(y||t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable"))?{type:"native",operationId:e.operationId}:!c.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:i&&r.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!t&&!e.quoteFinalized||t?.type==="purchase"&&["failed","expired"].includes(t.paymentStatus)&&t.fulfillmentStatus==="not_applicable"&&t.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&i&&!e.quoteFinalized&&!t&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:a}function h(r,o=!0){if(!r)return!1;let e=f({quote:r.quote??null,operation:r,requestId:null,pending:!1,destroyed:!1,canReselect:o});return e.type==="complete"||e.type==="native"}function l(r){return r.recovery??{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}}function b(r){return!!(r?.operationId&&(r.type==="checkout"||r.type==="recover"||r.type==="fulfillment"||r.type==="recording"))}async function g(r){let o=l(r);if(o.type==="recover"&&r.quote)try{await r.read(),o=l(r)}catch{return o}if(o.type!=="cancel"&&!(o.type==="recover"&&r.pendingCancellation))return o;try{await r.cancel();let e=l(r);return e.type==="cancel"?{type:"recover",operationId:o.operationId,requestId:null}:e}catch{let e=l(r);return e.type==="recover"?e:{type:"recover",operationId:o.operationId,requestId:null}}}export{f as a,h as b,l as c,b as d,g as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as I,b as L}from"./chunk-CILM5XMH.js";function M(e){try{let n=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(n)}catch{return}}function j(e,n){if(!n.length)return!1;let t=!1,r=!1;for(let o of n){let s=pe(e,o.type,o.pattern);if(o.include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function he(e,n,t){try{let r=n.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function be(e,n){try{let t=new URL(n.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,t.host,!1],[e.pathname,t.pathname,!0]];return t.hash&&r.push([e.hash,t.hash,!1]),t.searchParams.forEach((o,s)=>{r.push([e.searchParams.get(s)||"",o,!1])}),!r.some(o=>!he(o[0],o[1],o[2]))}catch{return!1}}function pe(e,n,t){try{let r=new URL(e,"https://_");if(n==="regex"){let o=M(t);return o?o.test(r.href)||o.test(r.href.substring(r.origin.length)):!1}else if(n==="simple")return be(r,t);return!1}catch{return!1}}function K(e){for(let t of["namespace","status","url","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired experiment field: ${t}`);let n=e;if(n.hashVersion!==void 0&&n.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(n.filters?.some(t=>t.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function T(e){for(let n of Object.values(e)){if(Array.isArray(n))throw new TypeError("Saved groups require typed list or condition entries");if(n&&Object.hasOwn(n,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function H(e){for(let n of["overrides","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired evaluation context field: ${n}`);T(e.savedGroups??{})}function J(e){let n=2166136261,t=e.length;for(let r=0;r<t;r++)n^=e.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0}function C(e,n,t){return t===2?J(J(e+n)+"")%1e4/1e4:null}function me(e){return e<=0?[]:new Array(e).fill(1/e)}function $(e,n){return e>=n[0]&&e<n[1]}function W(e,n){for(let[t,r]of n.entries())if($(e,r))return t;return-1}function Q(e,n,t){n=n===void 0?1:n,n<0?n=0:n>1&&(n=1);let r=me(e);t=t||r,t.length!==e&&(t=r);let o=t.reduce((a,u)=>u+a,0);(o<.99||o>1.01)&&(t=r);let s=0,i=n;return t.map(a=>{let u=s;return s+=a,[u,u+i*a]})}function z(e,n,t){if(!n)return null;let r=n.split("?")[1];if(!r)return null;let s=r.replace(/#.*/,"").split("&").map(i=>i.split("=",2)).filter(([i])=>i===e).map(([,i])=>i===void 0?NaN:parseInt(i))[0];return s!==void 0&&s>=0&&s<t?s:null}function X(e){try{return e()}catch{return!1}}function E(e){return typeof e=="string"?e:JSON.stringify(e)}function y(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let n=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return n.length===3&&n.push("~"),n.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}var Y=new Map,D=32,Z=new WeakMap,ee=new WeakMap;function Se(e){return I(L(new TextEncoder().encode(String(e))))}var B=e=>Array.isArray(e)?e.map(B):typeof e=="string"||typeof e=="number"?Se(e):null,O=e=>typeof e=="string"?e.toLowerCase():e;function oe(e){let n=Z.get(e);return n||(n=new Set(e),Z.set(e,n)),n}function ve(e){let n=ee.get(e);return n||(n=new Set(e.map(O)),ee.set(e,n)),n}function Ae(e){T(e);for(let n of Object.values(e)){let t=n?.type==="list"||n?.type==="hashed"?n.values:null;t&&t.length>=D&&oe(t)}return e}function h(e,n,t,r){t=t||{},r||T(t),r=r||new Set;for(let[o,s]of Object.entries(n))switch(o){case"$or":if(!ie(e,s,t,r))return!1;break;case"$nor":if(ie(e,s,t,r))return!1;break;case"$and":if(!Fe(e,s,t,r))return!1;break;case"$not":if(h(e,s,t,r))return!1;break;case"$savedGroup":if(!we(e,s,t,r))return!1;break;default:if(!V(s,se(e,o),t,!1,r))return!1}return!0}function we(e,n,t,r){if(!n||typeof n!="object"||Array.isArray(n))return!1;let{id:o,attributeKey:s}=n;if(typeof o!="string"||r.has(o)||s!==void 0&&typeof s!="string")return!1;let i=t[o];if(!i||Array.isArray(i)||typeof i!="object")return!1;let a=new Set(r).add(o);if(i.type==="list"||i.type==="hashed"){let u=s??i.attributeKey;if(typeof u!="string"||!Array.isArray(i.values))return!1;let f=se(e,u);return S(i.type==="hashed"?B(f):f,i.values)}return i.type==="condition"?!i.condition||typeof i.condition!="object"?!1:h(e,i.condition,t,a):!1}function se(e,n){let t=n.split("."),r=e;for(let o of t)if(r&&typeof r=="object"&&o in r)r=r[o];else return null;return r}function ne(e,n=!1){let t=`${e}${n?"/i":""}`,r=Y.get(t);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),n?"i":void 0),Y.set(t,r)),r}function V(e,n,t,r=!1,o=new Set){if(typeof e=="string")return r?String(n).toLowerCase()===e.toLowerCase():n+""===e;if(typeof e=="number")return n*1===e;if(typeof e=="boolean")return n!==null&&!!n===e;if(e===null)return n===null;if(Array.isArray(e)||!ae(e))return JSON.stringify(n)===JSON.stringify(e);let s=e;for(let i in s)if(!Re(i,n,s[i],t,o))return!1;return!0}function ae(e){let n=Object.keys(e);return n.length>0&&n.filter(t=>t[0]==="$").length===n.length}function Ee(e){if(e===null)return"null";if(Array.isArray(e))return"array";let n=typeof e;return["string","number","boolean","object","undefined"].includes(n)?n:"unknown"}function Ve(e,n,t,r){if(!Array.isArray(e))return!1;let o=ae(n)?s=>V(n,s,t,!1,r):s=>h(s,n,t,r);for(let s=0;s<e.length;s++)if((e[s]??null)!==null&&o(e[s]))return!0;return!1}function S(e,n,t=!1){if(t){let o;if(n.length>=D){let s=ve(n);o=i=>{let a=O(i);return!(typeof a=="number"&&Number.isNaN(a))&&s.has(a)}}else o=s=>n.some(i=>O(s)===O(i));return Array.isArray(e)?e.some(s=>o(s)):o(e)}let r=n.length>=D?(o=>s=>o.has(s))(oe(n)):o=>n.includes(o);return Array.isArray(e)?e.some(o=>r(o)):r(e)}function te(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function re(e,n,t,r=!1,o=new Set){if(!Array.isArray(e))return!1;for(let s=0;s<n.length;s++){let i=!1;for(let a=0;a<e.length;a++)if(V(n[s],e[a],t,r,o)){i=!0;break}if(!i)return!1}return!0}function Re(e,n,t,r,o=new Set){let s=n,i=t;switch(e){case"$veq":return y(n)===y(t);case"$vne":return y(n)!==y(t);case"$vgt":return y(n)>y(t);case"$vgte":return y(n)>=y(t);case"$vlt":return y(n)<y(t);case"$vlte":return y(n)<=y(t);case"$eq":return n===t;case"$ne":return n!==t;case"$lt":return s<i;case"$lte":return s<=i;case"$gt":return s>i;case"$gte":return s>=i;case"$exists":return t?n!=null:n==null;case"$in":return Array.isArray(t)?S(n,t):!1;case"$ini":return Array.isArray(t)?S(n,t,!0):!1;case"$inGroup":{let a=r[t],u=te(a);return u===null?!1:S(a?.type==="hashed"?B(n):n,u)}case"$notInGroup":{let a=r[t],u=te(a);return u===null?!1:!S(a?.type==="hashed"?B(n):n,u)}case"$nin":return Array.isArray(t)?!S(n,t):!1;case"$nini":return Array.isArray(t)?!S(n,t,!0):!1;case"$not":return!V(t,n,r,!1,o);case"$size":return Array.isArray(n)?V(t,n.length,r,!1,o):!1;case"$elemMatch":return Ve(n,t,r,o);case"$all":return Array.isArray(t)?re(n,t,r,!1,o):!1;case"$alli":return Array.isArray(t)?re(n,t,r,!0,o):!1;case"$regex":try{return ne(t).test(n)}catch{return!1}case"$regexi":try{return ne(t,!0).test(n)}catch{return!1}case"$type":return Ee(n)===t;default:return!1}}function ie(e,n,t,r){if(!n.length)return!0;for(let o of n)if(h(e,o,t,r))return!0;return!1}function Fe(e,n,t,r){for(let o of n)if(!h(e,o,t,r))return!1;return!0}function ue(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function U(e){return H(e),{context:e,stack:{evaluatedFeatures:new Set}}}function _(e){return{...e.attributes,...e.attributeOverrides}}function p(e,n,t){let r=n||"id",o="",s=_(e);return s[r]&&(o=s[r]),!o&&t&&(s[t]&&(o=s[t]),o&&(r=t)),{hashAttribute:r,hashValue:o}}function l(e,n,t){e.context.log?.(n,t)}function x(e,n){return n=n||0,`${e}__${n}`}function q(e,n){return`${e}||${n}`}function Te(e,n,t){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:o,hashValue:s}=p(e,n),i=q(o,E(s)),{hashAttribute:a,hashValue:u}=p(e,t),f=u?q(a,E(u)):null,c={};return f&&r[f]&&Object.assign(c,r[f].assignments||{}),r[i]&&Object.assign(c,r[i].assignments||{}),c}function le({context:e,expKey:n,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:o,expMinBucketVersion:s,expMeta:i}){t=t||0,s=s||0,r=r||"id",i=i||[];let a=x(n,t),u=Te(e,r,o);if(s>0)for(let d=0;d<s;d++){let k=x(n,d);if(u[k]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[a];if(f===void 0)return{variation:-1};let c=i.findIndex(d=>d.key===f);return c<0?{variation:-1}:{variation:c}}function fe(e,n,t,r){let o=q(n,t),s=e.stickyBucketAssignmentDocs,i=s&&s[o]?s[o].assignments||{}:{},a={...i,...r},u=JSON.stringify(i)!==JSON.stringify(a);return{key:o,doc:{attributeName:n,attributeValue:t,assignments:a},changed:u}}function Ce(e,n){let t=U(n),r=ge(e,null,t);return n.onExperimentEval?.(e,r),r}function $e(e,n){return N(e,U(n))}function Oe(e){return e.forcedVariations||{}}function ce(e,n,t){let{context:r}=e;if(r.trackedExperiments){let o=ke(n,t);if(r.trackedExperiments.has(o))return;r.trackedExperiments.add(o)}G(()=>r.onExperimentViewed?.(n,t))}function Be(e,n,t){let{context:r}=e;if(r.trackedFeatureUsage){let o=JSON.stringify(t.value);if(r.trackedFeatureUsage[n]===o)return;r.trackedFeatureUsage[n]=o}G(()=>r.onFeatureUsage?.(n,t))}function G(e){try{let n=e();n&&typeof n.catch=="function"&&n.catch(()=>{})}catch{}}function N(e,n){let{context:t}=n;if(n.stack.evaluatedFeatures.has(e))return l(n,`evalFeature: circular dependency detected: ${n.stack.id} -> ${e}`,{from:n.stack.id,to:e}),m(n,e,null,"cyclicPrerequisite");n.stack.evaluatedFeatures.add(e),n.stack.id=e;let r=t.features?.[e];for(let s of r?.rules??[])K(s);let o=t.forcedFeatureValues;if(o&&o.has(e))return l(n,"Global override",{id:e,value:o.get(e)}),m(n,e,o.get(e),"override");if(!r)return l(n,"Unknown feature",{id:e}),m(n,e,null,"unknownFeature");if(r.rules){let s=new Set(n.stack.evaluatedFeatures);e:for(let i of r.rules){if(i.parentConditions)for(let f of i.parentConditions){n.stack.evaluatedFeatures=new Set(s);let c=N(f.id,n);if(c.source==="cyclicPrerequisite")return m(n,e,null,"cyclicPrerequisite");let d={value:c.value};if(!h(d,f.condition||{},t.savedGroups||{})){if(f.gate)return l(n,"Feature blocked by prerequisite",{id:e,rule:i}),m(n,e,null,"prerequisite");l(n,"Skip rule because prerequisite evaluation fails",{id:e,rule:i});continue e}}if(i.filters&&ye(i.filters,n)){l(n,"Skip rule because of filters",{id:e,rule:i});continue}if("force"in i){if(i.condition&&!de(i.condition,n)){l(n,"Skip rule because of condition ff",{id:e,rule:i});continue}if(!xe(n,i.seed||e,i.hashAttribute,t.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion)){l(n,"Skip rule because user not included in rollout",{id:e,rule:i});continue}return l(n,"Force value from rule",{id:e,rule:i}),i.tracks&&i.tracks.forEach(f=>{ce(n,f.experiment,f.result)}),m(n,e,i.force,"force",i.id)}if(!i.variations){l(n,"Skip invalid rule",{id:e,rule:i});continue}let a={variations:i.variations,key:i.key||e};"coverage"in i&&(a.coverage=i.coverage),i.weights&&(a.weights=i.weights),i.hashAttribute&&(a.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(a.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(a.disableStickyBucketing=i.disableStickyBucketing),i.bucketVersion!==void 0&&(a.bucketVersion=i.bucketVersion),i.minBucketVersion!==void 0&&(a.minBucketVersion=i.minBucketVersion),i.meta&&(a.meta=i.meta),i.ranges&&(a.ranges=i.ranges),i.name&&(a.name=i.name),i.phase&&(a.phase=i.phase),i.seed&&(a.seed=i.seed),i.hashVersion&&(a.hashVersion=i.hashVersion),i.filters&&(a.filters=i.filters),i.condition&&(a.condition=i.condition);let u=ge(a,e,n);if(t.onExperimentEval?.(a,u),u.inExperiment&&!u.passthrough)return m(n,e,u.value,"experiment",i.id,a,u)}}return l(n,"Use default value",{id:e,value:r.defaultValue}),m(n,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function ge(e,n,t){let{context:r}=t;K(e);let o=e.key,s=e.variations.length;if(s<2)return l(t,"Invalid experiment",{id:o}),g(t,e,-1,!1,n);if(r.enabled===!1)return l(t,"Context disabled",{id:o}),g(t,e,-1,!1,n);if(e.urlPatterns&&!j(r.url||"",e.urlPatterns))return l(t,"Skip because of url targeting",{id:o}),g(t,e,-1,!1,n);let i=z(o,r.url||"",s);if(i!==null)return l(t,"Force via querystring",{id:o,variation:i}),g(t,e,i,!1,n);let u=Oe(r)[o];if(u!==void 0)return l(t,"Force via dev tools",{id:o,variation:u}),g(t,e,u,!1,n);if(e.active===!1)return l(t,"Skip because inactive",{id:o}),g(t,e,-1,!1,n);let{hashAttribute:f,hashValue:c}=p(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!c)return l(t,"Skip because missing hashAttribute",{id:o}),g(t,e,-1,!1,n);let d=-1,k=!1,R=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:b,versionIsBlocked:v}=le(ue({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));k=b>=0,d=b,R=!!v}if(!k){if(e.filters&&ye(e.filters,t))return l(t,"Skip because of filters",{id:o}),g(t,e,-1,!1,n);if(e.include&&!X(e.include))return l(t,"Skip because of include function",{id:o}),g(t,e,-1,!1,n);if(e.condition&&!de(e.condition,t))return l(t,"Skip because of condition exp",{id:o}),g(t,e,-1,!1,n);if(e.parentConditions){let b=new Set(t.stack.evaluatedFeatures);for(let v of e.parentConditions){t.stack.evaluatedFeatures=new Set(b);let w=N(v.id,t);if(w.source==="cyclicPrerequisite")return g(t,e,-1,!1,n);let P={value:w.value};if(!h(P,v.condition||{},r.savedGroups||{}))return l(t,"Skip because prerequisite evaluation fails",{id:o}),g(t,e,-1,!1,n)}}}let A=C(e.seed||o,c,e.hashVersion??2);if(A===null)return l(t,"Skip because of invalid hash version",{id:o}),g(t,e,-1,!1,n);if(!k){let b=e.ranges||Q(s,e.coverage===void 0?1:e.coverage,e.weights);d=W(A,b)}if(R)return l(t,"Skip because sticky bucket version is blocked",{id:o}),g(t,e,-1,!1,n,void 0,!0);if(d<0)return l(t,"Skip because of coverage",{id:o}),g(t,e,-1,!1,n);if("force"in e)return l(t,"Force variation",{id:o,variation:e.force}),g(t,e,e.force===void 0?-1:e.force,!1,n);if(r.qaMode)return l(t,"Skip because QA mode",{id:o}),g(t,e,-1,!1,n);let F=g(t,e,d,!0,n,A,k);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:b,key:v,doc:w}=fe(r,f,E(c),{[x(e.key,e.bucketVersion)]:F.key});if(b){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[v]=w;let P=r.saveStickyBucketAssignmentDoc;G(()=>P(w))}}return ce(t,e,F),l(t,"In experiment",{id:o,variation:F.variationId}),F}function m(e,n,t,r,o,s,i){let a={value:t,on:!!t,off:!t,source:r,ruleId:o||""};return s&&(a.experiment=s),i&&(a.experimentResult=i),r!=="override"&&Be(e,n,a),a}function de(e,n){return h(_(n.context),e,n.context.savedGroups||{})}function ye(e,n){return e.some(t=>{let{hashValue:r}=p(n.context,t.attribute);if(!r)return!0;let o=C(t.seed,r,t.hashVersion||2);return o===null?!0:!t.ranges.some(s=>$(o,s))})}function xe(e,n,t,r,o,s,i){if(!o&&s===void 0)return!0;if(!o&&s===0)return!1;let{hashValue:a}=p(e.context,t,r);if(!a)return!1;let u=C(n,a,i??2);return u===null?!1:o?$(u,o):s!==void 0?u<=s:!0}function g(e,n,t,r,o,s,i){let a=!0;(t<0||t>=n.variations.length)&&(t=0,a=!1);let{hashAttribute:u,hashValue:f}=p(e.context,n.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0),c=n.meta?.[t]??{},d=n.variations[0];for(let[R,A]of n.variations.entries())if(R===t){d=A;break}let k={key:c.key||""+t,featureId:o,inExperiment:a,hashUsed:r,variationId:t,value:d,hashAttribute:u,hashValue:f,stickyBucketUsed:!!i};return c.name&&(k.name=c.name),s!==void 0&&(k.bucket=s),c.passthrough&&(k.passthrough=c.passthrough),k}function ke(e,n){return n.hashAttribute+n.hashValue+e.key+n.variationId}/*!
|
|
1
|
+
import{a as I,b as L}from"./chunk-WPFTSHP2.js";function M(e){try{let n=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(n)}catch{return}}function j(e,n){if(!n.length)return!1;let t=!1,r=!1;for(let o of n){let s=pe(e,o.type,o.pattern);if(o.include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function he(e,n,t){try{let r=n.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function be(e,n){try{let t=new URL(n.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,t.host,!1],[e.pathname,t.pathname,!0]];return t.hash&&r.push([e.hash,t.hash,!1]),t.searchParams.forEach((o,s)=>{r.push([e.searchParams.get(s)||"",o,!1])}),!r.some(o=>!he(o[0],o[1],o[2]))}catch{return!1}}function pe(e,n,t){try{let r=new URL(e,"https://_");if(n==="regex"){let o=M(t);return o?o.test(r.href)||o.test(r.href.substring(r.origin.length)):!1}else if(n==="simple")return be(r,t);return!1}catch{return!1}}function K(e){for(let t of["namespace","status","url","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired experiment field: ${t}`);let n=e;if(n.hashVersion!==void 0&&n.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(n.filters?.some(t=>t.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function T(e){for(let n of Object.values(e)){if(Array.isArray(n))throw new TypeError("Saved groups require typed list or condition entries");if(n&&Object.hasOwn(n,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function H(e){for(let n of["overrides","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired evaluation context field: ${n}`);T(e.savedGroups??{})}function J(e){let n=2166136261,t=e.length;for(let r=0;r<t;r++)n^=e.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0}function C(e,n,t){return t===2?J(J(e+n)+"")%1e4/1e4:null}function me(e){return e<=0?[]:new Array(e).fill(1/e)}function $(e,n){return e>=n[0]&&e<n[1]}function W(e,n){for(let[t,r]of n.entries())if($(e,r))return t;return-1}function Q(e,n,t){n=n===void 0?1:n,n<0?n=0:n>1&&(n=1);let r=me(e);t=t||r,t.length!==e&&(t=r);let o=t.reduce((a,u)=>u+a,0);(o<.99||o>1.01)&&(t=r);let s=0,i=n;return t.map(a=>{let u=s;return s+=a,[u,u+i*a]})}function z(e,n,t){if(!n)return null;let r=n.split("?")[1];if(!r)return null;let s=r.replace(/#.*/,"").split("&").map(i=>i.split("=",2)).filter(([i])=>i===e).map(([,i])=>i===void 0?NaN:parseInt(i))[0];return s!==void 0&&s>=0&&s<t?s:null}function X(e){try{return e()}catch{return!1}}function E(e){return typeof e=="string"?e:JSON.stringify(e)}function y(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let n=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return n.length===3&&n.push("~"),n.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}var Y=new Map,D=32,Z=new WeakMap,ee=new WeakMap;function Se(e){return I(L(new TextEncoder().encode(String(e))))}var B=e=>Array.isArray(e)?e.map(B):typeof e=="string"||typeof e=="number"?Se(e):null,O=e=>typeof e=="string"?e.toLowerCase():e;function oe(e){let n=Z.get(e);return n||(n=new Set(e),Z.set(e,n)),n}function ve(e){let n=ee.get(e);return n||(n=new Set(e.map(O)),ee.set(e,n)),n}function Ae(e){T(e);for(let n of Object.values(e)){let t=n?.type==="list"||n?.type==="hashed"?n.values:null;t&&t.length>=D&&oe(t)}return e}function h(e,n,t,r){t=t||{},r||T(t),r=r||new Set;for(let[o,s]of Object.entries(n))switch(o){case"$or":if(!ie(e,s,t,r))return!1;break;case"$nor":if(ie(e,s,t,r))return!1;break;case"$and":if(!Fe(e,s,t,r))return!1;break;case"$not":if(h(e,s,t,r))return!1;break;case"$savedGroup":if(!we(e,s,t,r))return!1;break;default:if(!V(s,se(e,o),t,!1,r))return!1}return!0}function we(e,n,t,r){if(!n||typeof n!="object"||Array.isArray(n))return!1;let{id:o,attributeKey:s}=n;if(typeof o!="string"||r.has(o)||s!==void 0&&typeof s!="string")return!1;let i=t[o];if(!i||Array.isArray(i)||typeof i!="object")return!1;let a=new Set(r).add(o);if(i.type==="list"||i.type==="hashed"){let u=s??i.attributeKey;if(typeof u!="string"||!Array.isArray(i.values))return!1;let f=se(e,u);return S(i.type==="hashed"?B(f):f,i.values)}return i.type==="condition"?!i.condition||typeof i.condition!="object"?!1:h(e,i.condition,t,a):!1}function se(e,n){let t=n.split("."),r=e;for(let o of t)if(r&&typeof r=="object"&&o in r)r=r[o];else return null;return r}function ne(e,n=!1){let t=`${e}${n?"/i":""}`,r=Y.get(t);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),n?"i":void 0),Y.set(t,r)),r}function V(e,n,t,r=!1,o=new Set){if(typeof e=="string")return r?String(n).toLowerCase()===e.toLowerCase():n+""===e;if(typeof e=="number")return n*1===e;if(typeof e=="boolean")return n!==null&&!!n===e;if(e===null)return n===null;if(Array.isArray(e)||!ae(e))return JSON.stringify(n)===JSON.stringify(e);let s=e;for(let i in s)if(!Re(i,n,s[i],t,o))return!1;return!0}function ae(e){let n=Object.keys(e);return n.length>0&&n.filter(t=>t[0]==="$").length===n.length}function Ee(e){if(e===null)return"null";if(Array.isArray(e))return"array";let n=typeof e;return["string","number","boolean","object","undefined"].includes(n)?n:"unknown"}function Ve(e,n,t,r){if(!Array.isArray(e))return!1;let o=ae(n)?s=>V(n,s,t,!1,r):s=>h(s,n,t,r);for(let s=0;s<e.length;s++)if((e[s]??null)!==null&&o(e[s]))return!0;return!1}function S(e,n,t=!1){if(t){let o;if(n.length>=D){let s=ve(n);o=i=>{let a=O(i);return!(typeof a=="number"&&Number.isNaN(a))&&s.has(a)}}else o=s=>n.some(i=>O(s)===O(i));return Array.isArray(e)?e.some(s=>o(s)):o(e)}let r=n.length>=D?(o=>s=>o.has(s))(oe(n)):o=>n.includes(o);return Array.isArray(e)?e.some(o=>r(o)):r(e)}function te(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function re(e,n,t,r=!1,o=new Set){if(!Array.isArray(e))return!1;for(let s=0;s<n.length;s++){let i=!1;for(let a=0;a<e.length;a++)if(V(n[s],e[a],t,r,o)){i=!0;break}if(!i)return!1}return!0}function Re(e,n,t,r,o=new Set){let s=n,i=t;switch(e){case"$veq":return y(n)===y(t);case"$vne":return y(n)!==y(t);case"$vgt":return y(n)>y(t);case"$vgte":return y(n)>=y(t);case"$vlt":return y(n)<y(t);case"$vlte":return y(n)<=y(t);case"$eq":return n===t;case"$ne":return n!==t;case"$lt":return s<i;case"$lte":return s<=i;case"$gt":return s>i;case"$gte":return s>=i;case"$exists":return t?n!=null:n==null;case"$in":return Array.isArray(t)?S(n,t):!1;case"$ini":return Array.isArray(t)?S(n,t,!0):!1;case"$inGroup":{let a=r[t],u=te(a);return u===null?!1:S(a?.type==="hashed"?B(n):n,u)}case"$notInGroup":{let a=r[t],u=te(a);return u===null?!1:!S(a?.type==="hashed"?B(n):n,u)}case"$nin":return Array.isArray(t)?!S(n,t):!1;case"$nini":return Array.isArray(t)?!S(n,t,!0):!1;case"$not":return!V(t,n,r,!1,o);case"$size":return Array.isArray(n)?V(t,n.length,r,!1,o):!1;case"$elemMatch":return Ve(n,t,r,o);case"$all":return Array.isArray(t)?re(n,t,r,!1,o):!1;case"$alli":return Array.isArray(t)?re(n,t,r,!0,o):!1;case"$regex":try{return ne(t).test(n)}catch{return!1}case"$regexi":try{return ne(t,!0).test(n)}catch{return!1}case"$type":return Ee(n)===t;default:return!1}}function ie(e,n,t,r){if(!n.length)return!0;for(let o of n)if(h(e,o,t,r))return!0;return!1}function Fe(e,n,t,r){for(let o of n)if(!h(e,o,t,r))return!1;return!0}function ue(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function U(e){return H(e),{context:e,stack:{evaluatedFeatures:new Set}}}function _(e){return{...e.attributes,...e.attributeOverrides}}function p(e,n,t){let r=n||"id",o="",s=_(e);return s[r]&&(o=s[r]),!o&&t&&(s[t]&&(o=s[t]),o&&(r=t)),{hashAttribute:r,hashValue:o}}function l(e,n,t){e.context.log?.(n,t)}function x(e,n){return n=n||0,`${e}__${n}`}function q(e,n){return`${e}||${n}`}function Te(e,n,t){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:o,hashValue:s}=p(e,n),i=q(o,E(s)),{hashAttribute:a,hashValue:u}=p(e,t),f=u?q(a,E(u)):null,c={};return f&&r[f]&&Object.assign(c,r[f].assignments||{}),r[i]&&Object.assign(c,r[i].assignments||{}),c}function le({context:e,expKey:n,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:o,expMinBucketVersion:s,expMeta:i}){t=t||0,s=s||0,r=r||"id",i=i||[];let a=x(n,t),u=Te(e,r,o);if(s>0)for(let d=0;d<s;d++){let k=x(n,d);if(u[k]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[a];if(f===void 0)return{variation:-1};let c=i.findIndex(d=>d.key===f);return c<0?{variation:-1}:{variation:c}}function fe(e,n,t,r){let o=q(n,t),s=e.stickyBucketAssignmentDocs,i=s&&s[o]?s[o].assignments||{}:{},a={...i,...r},u=JSON.stringify(i)!==JSON.stringify(a);return{key:o,doc:{attributeName:n,attributeValue:t,assignments:a},changed:u}}function Ce(e,n){let t=U(n),r=ge(e,null,t);return n.onExperimentEval?.(e,r),r}function $e(e,n){return N(e,U(n))}function Oe(e){return e.forcedVariations||{}}function ce(e,n,t){let{context:r}=e;if(r.trackedExperiments){let o=ke(n,t);if(r.trackedExperiments.has(o))return;r.trackedExperiments.add(o)}G(()=>r.onExperimentViewed?.(n,t))}function Be(e,n,t){let{context:r}=e;if(r.trackedFeatureUsage){let o=JSON.stringify(t.value);if(r.trackedFeatureUsage[n]===o)return;r.trackedFeatureUsage[n]=o}G(()=>r.onFeatureUsage?.(n,t))}function G(e){try{let n=e();n&&typeof n.catch=="function"&&n.catch(()=>{})}catch{}}function N(e,n){let{context:t}=n;if(n.stack.evaluatedFeatures.has(e))return l(n,`evalFeature: circular dependency detected: ${n.stack.id} -> ${e}`,{from:n.stack.id,to:e}),m(n,e,null,"cyclicPrerequisite");n.stack.evaluatedFeatures.add(e),n.stack.id=e;let r=t.features?.[e];for(let s of r?.rules??[])K(s);let o=t.forcedFeatureValues;if(o&&o.has(e))return l(n,"Global override",{id:e,value:o.get(e)}),m(n,e,o.get(e),"override");if(!r)return l(n,"Unknown feature",{id:e}),m(n,e,null,"unknownFeature");if(r.rules){let s=new Set(n.stack.evaluatedFeatures);e:for(let i of r.rules){if(i.parentConditions)for(let f of i.parentConditions){n.stack.evaluatedFeatures=new Set(s);let c=N(f.id,n);if(c.source==="cyclicPrerequisite")return m(n,e,null,"cyclicPrerequisite");let d={value:c.value};if(!h(d,f.condition||{},t.savedGroups||{})){if(f.gate)return l(n,"Feature blocked by prerequisite",{id:e,rule:i}),m(n,e,null,"prerequisite");l(n,"Skip rule because prerequisite evaluation fails",{id:e,rule:i});continue e}}if(i.filters&&ye(i.filters,n)){l(n,"Skip rule because of filters",{id:e,rule:i});continue}if("force"in i){if(i.condition&&!de(i.condition,n)){l(n,"Skip rule because of condition ff",{id:e,rule:i});continue}if(!xe(n,i.seed||e,i.hashAttribute,t.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion)){l(n,"Skip rule because user not included in rollout",{id:e,rule:i});continue}return l(n,"Force value from rule",{id:e,rule:i}),i.tracks&&i.tracks.forEach(f=>{ce(n,f.experiment,f.result)}),m(n,e,i.force,"force",i.id)}if(!i.variations){l(n,"Skip invalid rule",{id:e,rule:i});continue}let a={variations:i.variations,key:i.key||e};"coverage"in i&&(a.coverage=i.coverage),i.weights&&(a.weights=i.weights),i.hashAttribute&&(a.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(a.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(a.disableStickyBucketing=i.disableStickyBucketing),i.bucketVersion!==void 0&&(a.bucketVersion=i.bucketVersion),i.minBucketVersion!==void 0&&(a.minBucketVersion=i.minBucketVersion),i.meta&&(a.meta=i.meta),i.ranges&&(a.ranges=i.ranges),i.name&&(a.name=i.name),i.phase&&(a.phase=i.phase),i.seed&&(a.seed=i.seed),i.hashVersion&&(a.hashVersion=i.hashVersion),i.filters&&(a.filters=i.filters),i.condition&&(a.condition=i.condition);let u=ge(a,e,n);if(t.onExperimentEval?.(a,u),u.inExperiment&&!u.passthrough)return m(n,e,u.value,"experiment",i.id,a,u)}}return l(n,"Use default value",{id:e,value:r.defaultValue}),m(n,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function ge(e,n,t){let{context:r}=t;K(e);let o=e.key,s=e.variations.length;if(s<2)return l(t,"Invalid experiment",{id:o}),g(t,e,-1,!1,n);if(r.enabled===!1)return l(t,"Context disabled",{id:o}),g(t,e,-1,!1,n);if(e.urlPatterns&&!j(r.url||"",e.urlPatterns))return l(t,"Skip because of url targeting",{id:o}),g(t,e,-1,!1,n);let i=z(o,r.url||"",s);if(i!==null)return l(t,"Force via querystring",{id:o,variation:i}),g(t,e,i,!1,n);let u=Oe(r)[o];if(u!==void 0)return l(t,"Force via dev tools",{id:o,variation:u}),g(t,e,u,!1,n);if(e.active===!1)return l(t,"Skip because inactive",{id:o}),g(t,e,-1,!1,n);let{hashAttribute:f,hashValue:c}=p(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!c)return l(t,"Skip because missing hashAttribute",{id:o}),g(t,e,-1,!1,n);let d=-1,k=!1,R=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:b,versionIsBlocked:v}=le(ue({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));k=b>=0,d=b,R=!!v}if(!k){if(e.filters&&ye(e.filters,t))return l(t,"Skip because of filters",{id:o}),g(t,e,-1,!1,n);if(e.include&&!X(e.include))return l(t,"Skip because of include function",{id:o}),g(t,e,-1,!1,n);if(e.condition&&!de(e.condition,t))return l(t,"Skip because of condition exp",{id:o}),g(t,e,-1,!1,n);if(e.parentConditions){let b=new Set(t.stack.evaluatedFeatures);for(let v of e.parentConditions){t.stack.evaluatedFeatures=new Set(b);let w=N(v.id,t);if(w.source==="cyclicPrerequisite")return g(t,e,-1,!1,n);let P={value:w.value};if(!h(P,v.condition||{},r.savedGroups||{}))return l(t,"Skip because prerequisite evaluation fails",{id:o}),g(t,e,-1,!1,n)}}}let A=C(e.seed||o,c,e.hashVersion??2);if(A===null)return l(t,"Skip because of invalid hash version",{id:o}),g(t,e,-1,!1,n);if(!k){let b=e.ranges||Q(s,e.coverage===void 0?1:e.coverage,e.weights);d=W(A,b)}if(R)return l(t,"Skip because sticky bucket version is blocked",{id:o}),g(t,e,-1,!1,n,void 0,!0);if(d<0)return l(t,"Skip because of coverage",{id:o}),g(t,e,-1,!1,n);if("force"in e)return l(t,"Force variation",{id:o,variation:e.force}),g(t,e,e.force===void 0?-1:e.force,!1,n);if(r.qaMode)return l(t,"Skip because QA mode",{id:o}),g(t,e,-1,!1,n);let F=g(t,e,d,!0,n,A,k);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:b,key:v,doc:w}=fe(r,f,E(c),{[x(e.key,e.bucketVersion)]:F.key});if(b){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[v]=w;let P=r.saveStickyBucketAssignmentDoc;G(()=>P(w))}}return ce(t,e,F),l(t,"In experiment",{id:o,variation:F.variationId}),F}function m(e,n,t,r,o,s,i){let a={value:t,on:!!t,off:!t,source:r,ruleId:o||""};return s&&(a.experiment=s),i&&(a.experimentResult=i),r!=="override"&&Be(e,n,a),a}function de(e,n){return h(_(n.context),e,n.context.savedGroups||{})}function ye(e,n){return e.some(t=>{let{hashValue:r}=p(n.context,t.attribute);if(!r)return!0;let o=C(t.seed,r,t.hashVersion||2);return o===null?!0:!t.ranges.some(s=>$(o,s))})}function xe(e,n,t,r,o,s,i){if(!o&&s===void 0)return!0;if(!o&&s===0)return!1;let{hashValue:a}=p(e.context,t,r);if(!a)return!1;let u=C(n,a,i??2);return u===null?!1:o?$(u,o):s!==void 0?u<=s:!0}function g(e,n,t,r,o,s,i){let a=!0;(t<0||t>=n.variations.length)&&(t=0,a=!1);let{hashAttribute:u,hashValue:f}=p(e.context,n.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0),c=n.meta?.[t]??{},d=n.variations[0];for(let[R,A]of n.variations.entries())if(R===t){d=A;break}let k={key:c.key||""+t,featureId:o,inExperiment:a,hashUsed:r,variationId:t,value:d,hashAttribute:u,hashValue:f,stickyBucketUsed:!!i};return c.name&&(k.name=c.name),s!==void 0&&(k.bucket=s),c.passthrough&&(k.passthrough=c.passthrough),k}function ke(e,n){return n.hashAttribute+n.hashValue+e.key+n.variationId}/*!
|
|
2
2
|
Copyright (c) 2025 GrowthBook, Inc.
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as c}from"./chunk-ASL7TJFU.js";import{b as p}from"./chunk-GPJF3T43.js";import{d as x,e as y,f as g}from"./chunk-C4NG6RVA.js";import{a as m,b as d}from"./chunk-WPFTSHP2.js";var u=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function F(e,t,f){let i={},l,s,n,o="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let r=e.cases.findIndex(b=>x(t.attributes??{},b.condition,t.savedGroups??{}));o=r<0?"default":`case:${r}`,a=r<0?e.default:e.cases[r].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new u("Required GB Feature is unavailable");l=g(e.featureKey,t),n=l.value,Object.assign(i,c(e,{value:n})),a=e.next;break;case"split":{let r=f[e.experimentId];if(!r)throw new u("Required GB Experiment is unavailable");if(s=y(r,t),n=s.value,o=s.inExperiment&&!s.passthrough&&typeof n=="string"?n:"notParticipating",a=o==="notParticipating"?e.notParticipating:e.routes[o],!a)throw new u("Experiment Variation has no published route");break}case"offering":{let r=e.configuration.source==="fixed"?e.configuration.versionId:g(e.configuration.featureKey,t).value;n={type:"offering_version",id:p.uuid().parse(r)},Object.assign(i,c(e,{value:n})),a=e.next;break}case"coupon":case"coupons":n=e.type==="coupons"?e.couponIds.map(r=>({type:"reward",id:r})):{type:"reward",id:e.couponId},Object.assign(i,c(e,{value:n})),a=e.next;break}return{port:o,target:a,projections:i,...n===void 0?{}:{value:n},...l?{feature:l}:{},...s?{experiment:s}:{}}}function E(e,t,f){p.uuid().parse(e),p.number().int().nonnegative().parse(t);let i=m(d(new TextEncoder().encode(JSON.stringify([e,t,f])))).slice(0,32);return`${i.slice(0,8)}-${i.slice(8,12)}-5${i.slice(13,16)}-a${i.slice(17,20)}-${i.slice(20)}`}export{F as a,E as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./chunk-DGZCD3AY.js";async function u(e,n){try{let{route:r}=await e.funnelRoute(n.funnelId),a=t(r,{customerId:n.customerId,parameters:n.parameters??{}});return{funnelId:n.funnelId,...a}}catch(r){return{funnelId:n.funnelId,type:"unavailable",reason:r?.code?.toLowerCase()??"error",path:[]}}}function l(e){switch(e.type){case"paywall":return null;case"screen":return`first_screen_${e.surface}`;case"external_page":return"first_screen_external_page";case"end":return`route_end_${e.outcome}`;case"unknown":return`route_unknown_${e.reason}`;case"unavailable":return e.reason.startsWith("route_")?e.reason:`route_${e.reason}`}}async function s(e,n){if(n.type!=="paywall")return null;try{let{document:r}=await e.paywall(n.paywallId,n.paywallVersionId);return{presentation:r.presentation,screen:r.screen,buttons:r.buttons}}catch{return null}}export{u as a,l as b,s as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,b as c,c as u}from"./chunk-5JRBCW6V.js";import{j as m,m as p}from"./chunk-6XRXHFM6.js";import{b as e}from"./chunk-GPJF3T43.js";var y=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(y);function x(t){let n=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(n)?0:2}function I(t,n,r="en",f={}){let a=i.parse(n.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:a,...f}).format(t/10**x(a))}var l=e.enum(["stripe","apple","google","merchant"]),w=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var d=e.object({provider:l,currency:i,intent:e.literal("subscription_change").optional()}).strict();var o=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:o,commerce:d.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),b=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:c,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function S(t,n){return u({subject:c.parse(t),requirement:o.parse(n)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(b).max(20)}).nullable()}).superRefine((t,n)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(r=>r.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&n.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:o}),U=e.strictObject({subject:c,requirement:o}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,n){let r=o.parse(t);return n.internal_feature_id===r.internal_feature_id&&n.quantity===r.quantity&&(!n.observation||n.observation.requirementDigest===S(n.observation.subject,r))}export{i as a,x as b,I as c,w as d,d as e,o as f,B as g,b as h,S as i,C as j,U as k,$ as l,F as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as K,b as fe,c as ge,d as ye,e as T,f as $e,g as Le,j as be,m as Q}from"./chunk-ASL7TJFU.js";import{a as He,i as Ze,y as We}from"./chunk-KP4QI4RX.js";import{v as Pe}from"./chunk-5TJISOWN.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-LSVTH3TS.js";import{m as Je,n as J,o as B}from"./chunk-7MYS52FL.js";import{C as me,f as Ve,g as Ue,h as Be,p as pe,v as L,w as H,x as Z,y as de,z as Te}from"./chunk-MWICFZUF.js";import{b as Me,d as S,e as U,f as qe,g as Ge,h as W}from"./chunk-3SXPCVIP.js";import{h as V}from"./chunk-6XRXHFM6.js";import{b as e}from"./chunk-GPJF3T43.js";var E=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(o=>!["__proto__","constructor","prototype"].includes(o)),"Reserved value path"),C=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:S}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:E.optional()})]);function Qe(t,o){if(!o)return t;for(let n of E.parse(o).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function _t(t,o){if(t.source==="literal")return structuredClone(t.value);let n=Le(o.declarations,o);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(S.parse(Qe(n[t.key],t.path)))}function he(t,o){let n=[...o].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!E.safeParse(s).success?null:{key:n,path:s}}function xe(t){let o=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return L(t,n=>{n.type==="custom_html"&&o.push(...Object.values(n.html))}),[...new Set(o.flatMap(Be))]}function Xe(t){return xe(t).filter(o=>o.startsWith("variables.")).map(o=>o.slice(10))}function F(t){let o=JSON.stringify(t);if(o===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(o).length,s=!1;for(let i=0;i<o.length;i++){let a=o.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let f=i;for(;i+1<o.length&&/[0-9.eE+-]/.test(o.charAt(i+1));)i++;let m=o.slice(f,i+1);if(!/[eE]/.test(m))continue;let[x="",_]=m.split(/[eE]/),p=x.replace(/^-/,""),v=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):v)+Number(_),d=N<=0?2-N+v:N>=v?N:v+1;n+=d+(x.startsWith("-")?1:0)-m.length}}return n}var Kt=e.string().regex(/^[a-f0-9]{64}$/),Et=Ve.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),Ye=e.strictObject({couponDigests:e.record(e.uuid(),Kt),variables:e.record(pe,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(pe,Ue.extend({nodes:e.record(e.string(),e.strictObject({base:Et})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var et=e.enum(["funnel-run/1","funnel-process/1"]),Kn="funnel-process/1";var Se=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),tt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),nt=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),ve=e.record(Se,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),Dt=C,rt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:Se,inputs:e.record(Se,Dt).refine(t=>Object.keys(t).length<=20),outputs:ve}),it=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Pn=e.strictObject({outcome:e.enum(["success","failure"]),data:nt});var Vn=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:tt,eventName:Q,eventId:e.uuid(),data:nt}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Un=e.strictObject({scope:V,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),At=e.record(tt,be),Bn=e.strictObject({scope:V,runId:e.uuid(),results:At});var Ct=["id","externalUserId","createdAt","ageDays","subscription"],we=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(t=>new Set(t).size===t.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),X=e.intersection(U,e.looseObject({tags:we.optional()})).refine(t=>![...Ct,"parameters","answers","results"].some(o=>Object.hasOwn(t,o)),"Reserved customer attribute"),Y=e.string().trim().max(80),ee=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),te=e.union([e.email().max(254),e.literal("")]),Nt=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ot=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Gn=e.object({externalUserId:ot.optional(),name:Y.default(""),email:te.default(""),phone:ee.optional(),attributes:X.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u7528\u6237 ID \u6216\u90AE\u7BB1"),ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ot})]),re=e.strictObject({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.optional(),fingerprint:Nt.optional()}),ie=t=>!t.customerData||t.customer?.type==="externalUserId",oe="customerData requires an externalUserId customer",at=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:Y,email:te,phone:ee.optional(),attributes:X,createdAt:e.iso.datetime()}).strict(),$n=e.object({customer:at,changed:e.boolean(),replayed:e.boolean()}).strict(),zt=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),Ft=e.object({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:we,remove:we}).optional()}).strict().refine(t=>Object.keys(t).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),Pt=e.object({lookup:zt}).strict(),Ln=Pt.extend({requestId:e.uuid(),patch:Ft}).strict(),Hn=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Zn=e.object({customers:at.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var Yn=e.enum(["local","remote"]),Ie=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:S.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(S).max(100),features:e.array(S).max(100)}),st=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:U,sticky:e.record(e.string(),W)}),ct=st.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),Vt=st.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),ut=e.strictObject({nodeId:e.string().min(1).max(64),result:Ie}),lt=Vt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:J,variables:e.record(e.string(),S)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:S}),e.strictObject({type:e.literal("variable"),key:K,path:E.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),Ut=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:S}),Bt={funnelId:e.uuid(),requestId:e.uuid(),customer:ne,customerData:re.optional(),attributes:U.refine(t=>!["parameters","answers","results","variables"].some(o=>Object.hasOwn(t,o)),"parameters, answers, results and variables are reserved flow namespaces")},cr=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...Bt}).refine(ie,oe),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:Ie}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(ut).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),ur=e.strictObject({scope:V,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:Ut.nullable(),evaluation:e.discriminatedUnion("type",[ct,lt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),lr=e.strictObject({scope:V,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function Mt(t,o=[]){let n=[];L(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),o.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(de(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let f of Object.keys(a))s.has(f)||n.push(`Unused string ${f} must not be delivered (${i})`);return n}function pt(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(o=>pt(o)??[])}}function Tt(t){let o=t.pages.map(i=>{let a=pt(i.root);return a?.type==="stack"?{...i,root:a}:{...i,root:{type:"stack",id:i.root.id,...i.root.name===void 0?{}:{name:i.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(de({pages:o}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([f])=>n.has(f)))]));return{...t,pages:o,strings:{...t.strings,locales:s}}}function dt(t,o=[]){let n=H.parse(structuredClone(Tt(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=Mt(n,o);if(i.length)throw new Error(i.join("; "));return n}var gr=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,o)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&o.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),mt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var qt=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],je="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",Gt=e.string().regex(new RegExp(`^${je}/${je}/${je}/manifest\\.json$`)),ft=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(qt),objectKey:Gt,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,o)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&o.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var h=e.string().min(1).max(256),j=e.string().regex(/^[a-f0-9]{64}$/),ae=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,elementKey:h.optional(),nodeId:h.optional(),contentHash:j.optional(),renderKey:h.optional()}),gt=e.strictObject({pageKey:h,documentKey:h,expectedDocumentHash:j,renderKey:h.optional(),nodeId:h,elementKey:h,expectedContentHash:j,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),wr=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,renderKey:h.optional(),patches:e.array(gt.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),$t=/^[a-z][a-z0-9-]{0,39}$/,G=e.string().regex($t),Re=e.enum(["web","ios","android"]),yt={requestId:e.uuid(),client:G,platform:Re,label:e.string().trim().min(1).max(100),sha256:j,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},Lt=e.strictObject({action:e.literal("upload"),...yt,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ir=e.discriminatedUnion("action",[Lt,e.strictObject({action:e.literal("register"),...yt}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:h,changesetId:e.uuid().nullable(),expectedRevision:j.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(gt).max(200)})]),_e=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:G,platform:Re,label:e.string(),sha256:j,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),Ht=e.strictObject({key:G,platform:Re,currentId:e.uuid().nullable()}),Or=e.strictObject({rows:e.array(_e).max(100),nextCursor:e.uuid().nullable(),clients:e.array(Ht).max(20)}),ke=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),jr=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:ke,runtime:ke,previews:ke})}),kr=e.strictObject({version:_e,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Rr=e.strictObject({version:_e,upload:ft.nullable()}),_r=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:h,path:e.string(),documentKey:h,documentHash:j,initialStateKey:h,initialRenderKey:h})),renders:e.array(mt)}).loose().superRefine((t,o)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&o.addIssue({code:"custom",message:"Incomplete render catalog"})}),Kr=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:h,key:h,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Er=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var Zt=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),bt=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:G,source:ae,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:Zt.optional()}).superRefine((t,o)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&o.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},ht="00000000-0000-0000-0000-000000000000";var xt=e.strictObject({type:e.literal("bundle"),paywall:C.optional(),offering:C.optional(),coupons:C,data:C}),Wt=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Br=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:S});var Mr=e.strictObject({type:e.literal("bundle"),offering:Wt("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(Ze).max(20),data:S});var St=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([St,e.array(St).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),vt=e.strictObject({path:E,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:Qt.optional()}).superRefine((t,o)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&o.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Xt=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],wt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Yt=C,It=e.discriminatedUnion("type",[rt,e.strictObject({type:e.literal("claim_offer"),coupon:C}),e.strictObject({type:e.literal("event"),event:wt}),e.strictObject({type:e.literal("api"),operation:e.enum(Xt),inputs:e.record(E,Yt).refine(t=>Object.keys(t).length<=40),outputs:e.record(wt,vt).refine(t=>Object.keys(t).length<=20)})]);var y=Q,en=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),k={id:y,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},tn={success:y,cancel:y,unavailable:y,failure:y},nn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),rn=e.enum(["same_window","new_window"]),on=e.discriminatedUnion("type",[e.strictObject({...k,type:e.literal("entry"),next:y,triggers:e.array(bt).max(20).refine(t=>new Set(t.map(o=>o.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...k,type:e.literal("screen"),screenId:y,presentation:Me,outputs:e.record(y,y),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:K}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...k,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("output"),value:e.discriminatedUnion("type",[...Oe.options,xt,e.strictObject({type:e.literal("selection"),screenId:y,offeringKey:K})])}),e.strictObject({...k,type:e.literal("condition"),cases:e.array(e.strictObject({condition:qe,target:y})).min(1).max(50),default:y}),e.strictObject({...k,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(en,y).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:y}),e.strictObject({...k,type:e.literal("action"),...tn,execution:it,action:It,writes:ye.optional()}),e.strictObject({...k,type:e.literal("external_page"),appManifest:ae.optional(),url:nn,openIn:rn,opened:y,failed:y}),e.strictObject({...k,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Oe.optional()}),e.strictObject({...k,type:e.literal("wait"),writes:ye.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:y}),e.strictObject({type:e.literal("event"),eventName:y,outputs:ve,timeoutSeconds:e.number().int().min(1).max(2592e3),received:y,timeout:y})])})]),Ke=e.strictObject({version:e.literal(5),entry:y,nodes:e.array(on).min(1).max(D.flowNodes)}),Ee=Ke.superRefine((t,o)=>{an(t,n=>o.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function se(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(o=>o.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function an(t,o){let n=[],s=new Map(t.nodes.map(p=>[p.id,p])),i=(p,v,N)=>{n.push(p),o?.({message:p,reason:v,path:N?["nodes",t.nodes.indexOf(N)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(p=>p.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(p=>p.type==="screen").length>D.pages||t.nodes.filter(p=>!["screen","entry","end","output"].includes(p.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let p of t.nodes){for(let v of se(p))v===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(v)||i(`Missing target ${v}`,"missingTarget",p);p.type==="screen"&&(a.has(p.screenId)&&i("Every screen has exactly one node owner","screenOwner",p),a.add(p.screenId))}let f=new Set,m=new Set,x=new Set;function _(p){if(f.has(p)){i("Flow edges must not form a cycle","cycle",s.get(p));return}if(!(m.has(p)||!s.has(p))){f.add(p),x.add(p);for(let v of se(s.get(p)))_(v);f.delete(p),m.add(p)}}_(t.entry);for(let p of t.nodes)x.has(p.id)||i("Every node must be reachable from Entry","unreachable",p);return[...new Set(n)]}var De={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Ot(t,o,n){let s=[...o].sort((m,x)=>x.length-m.length),i=new Set,a=(m,x=!1)=>{let _=s.find(p=>m===p||x&&m.startsWith(p+"."));i.add(_??m)};if(t.type==="condition"){let m=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let x of t.cases.slice(0,m+1))for(let _ of q(x.condition))_.startsWith("variables.")&&a(_.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let m of Object.values(t.action.inputs))m.source==="variable"&&a(m.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let f=t.type==="output"?t.value:t.type==="end"?t.output:null;if(f?.type==="variable"&&a(f.key),f?.type==="bundle")for(let m of[f.paywall,f.offering,f.coupons,f.data])m?.source==="variable"&&a(m.key);return f?.type==="selection"&&a(f.offeringKey),[...i]}var M=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ce=t=>e.record(e.string(),S).refine(o=>F(o)<=t,"Funnel evidence exceeds its byte budget"),xi=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Ce=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Si=e.strictObject({schemaVersion:e.literal(1),kind:Ce,selector:Ne.nullable(),context:ce(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>F(t)<=131072,"Node input exceeds its byte budget"),vi=e.strictObject({schemaVersion:e.literal(1),kind:Ce,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ce(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ce(131072)}).refine(t=>F(t)<=131072,"Node result exceeds its byte budget"),wi=e.strictObject({schemaVersion:e.literal(1),operations:e.record(M,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:M,id:e.uuid()}).nullable()}))}).refine(t=>F(t)<=65536,"Execution state exceeds its byte budget"),P={receiptId:e.uuid()},Ae=e.iso.datetime({offset:!0}),Ii=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:Ce})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...P,source:e.literal("client"),occurredAt:Ae.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(P)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:M,eventName:M,data:ce(8192),source:e.literal("server"),occurredAt:Ae})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...P,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(P)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(P)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...P,operation:M,reference:e.strictObject({type:M,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...P,source:e.enum(["client","server"]),occurredAt:Ae,reference:e.string().min(1).max(128).optional()})})]);var R=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),sn=e.discriminatedUnion("type",[e.strictObject({id:R,type:e.literal("owned"),publicData:Ye.optional(),document:H.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(o=>o.type==="event"&&!o.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:R,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),ze={executionContract:et.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(sn).max(D.pages),references:e.record(R,Ne).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:R,screenId:R,componentId:R,required:e.boolean()})).max(D.questions),variables:e.record(K,ge).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:fe,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(De.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(De.maxTransitions)})},$i=e.strictObject({...ze,graph:Ke});function cn(t,o){let n=!1,s=(i,a)=>{let f=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(m=>m[i.text]?.includes("{{offer."))&&!(f&&o(f))&&(n=!0),i.type==="stack"&&i.children.forEach(m=>s(m,f))};for(let i of t.pages)s(i.root);return n}function le(t){return Array.isArray(t)?t.some(le):!t||typeof t!="object"?!1:Object.entries(t).some(([o,n])=>o==="productVersionId"?n===ht:le(n))}function un(t){let o=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=dt(i.document)}catch(f){o.push({message:f instanceof Error?f.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[f,m]of t.inputs.entries())m.screenId===i.id&&!me(a,m.componentId)&&o.push({message:`Local Funnel input ${m.variable} targets hidden component ${m.componentId} on screen ${m.screenId}`,reason:"inputBinding",path:["inputs",f]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],f=i.type==="screen"?t.screens.find(m=>m.id===i.screenId):void 0;f?.type==="owned"&&(f.document.actions.some(m=>typeof m.properties.templateKey=="string"&&m.properties.templateKey.startsWith("popup-coupon-"))&&o.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),cn(f.document,m=>n.has(m))&&o.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&le(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&le(i.output.value))&&o.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return o}function jt(t,o){for(let{message:n,reason:s,path:i}of un(t))o.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function kt(t,o){let n=(d,r,c=[])=>o.addIssue({code:"custom",message:d,path:c,params:{reason:r}}),s=Object.values(t.references),i=new Map(t.screens.map(d=>[d.id,d])),a=(d,r)=>s.some(c=>c.type===d&&("id"in c?c.id:c.key)===r);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let f=t.graph.nodes.filter(d=>d.type==="screen");(f.length!==i.size||f.some(d=>!i.has(d.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let m=new Map,x=Object.keys(t.variables);x.some(d=>x.some(r=>d!==r&&r.startsWith(d+".")))&&n("Variable paths must not overlap","variable");function _(d,r){Object.hasOwn(t.variables,d)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(r)]);let c=m.get(d)??new Set;c.add(r.id),m.set(d,c)}for(let[d,r]of t.graph.nodes.entries()){let c=["graph","nodes",d],w=r.type==="feature"?r.featureKey:r.type==="offering"&&r.configuration.source==="feature"?r.configuration.featureKey:r.type==="output"&&r.value.type==="feature"?r.value.featureKey:r.type==="end"&&r.output?.type==="feature"?r.output.featureKey:null;w&&!a("flag",w)&&n("Flag selectors require an explicit GB resource reference","feature",c);let I=r.type==="feature"||r.type==="offering"||r.type==="coupon"||r.type==="coupons"||r.type==="action"&&r.action.type==="api"?["value"]:r.type==="action"&&r.action.type==="external_task"?Object.keys(r.action.outputs):r.type==="wait"&&r.wait.type==="event"?Object.keys(r.wait.outputs):[],O="writes"in r?r.writes??{}:{};(I.length!==Object.keys(O).length||I.some(u=>!Object.hasOwn(O,u))||new Set(Object.values(O)).size!==Object.values(O).length)&&n("Node writes must map every named output exactly once","variable",c);for(let[u,b]of Object.entries(O)){_(b,r);let g=t.variables[b],l=r.type==="offering"?"offering_version":r.type==="coupon"?"reward":r.type==="action"&&r.action.type==="api"?"json":r.type==="action"&&r.action.type==="external_task"?r.action.outputs[u]:r.type==="wait"&&r.wait.type==="event"?r.wait.outputs[u]:void 0;(g?.source.type!=="node"||l&&g.type!==l)&&n("Node writer source or output type does not match declaration","variable",c)}if(r.type==="coupons"){let u=t.variables[r.writes.value];(u?.type!=="array"||u.items?.type!=="reward"||u.items.nullable||u.nullable)&&n("Coupons output requires a non-null Reward array","variable",c);for(let b of r.couponIds)a("reward",b)||n("Coupons require Reward references","coupon",c)}if(r.type==="split"&&!a("experiment",r.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",c),r.type==="coupon"&&!a("reward",r.couponId)&&n("Coupon selectors require a Reward reference","coupon",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="literal"){let u=r.action.coupon.value;(!u||typeof u!="object"||Array.isArray(u)||u.type!=="reward"||typeof u.id!="string"||Object.keys(u).length!==2||!a("reward",u.id))&&n("Coupon claims require a Reward reference","coupon",c)}if(r.type==="offering"&&r.configuration.source==="fixed"&&!a("offering_version",r.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",c),r.type==="screen"&&r.offering?.source==="variable"&&t.variables[r.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="variable"&&(t.variables[r.action.coupon.key]?.type!=="reward"||r.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",c),r.type==="screen"){let u=i.get(r.screenId);if(r.offering?.source==="fixed"&&!a("offering_version",r.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",c),u?.type==="paywall"&&r.offering&&n("Paywall owns its fixed Offering Version","offering",c),u?.type==="paywall"&&!a("paywall_version",u.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",c),u?.type==="owned"){let b=u.document.pages[0];if(!b){n("Owned screen requires a page","screen",c);continue}Te(u.document).some(l=>!l.complete)&&n("Owned screens require complete local content","translations",c);let g=new Set(u.document.actions.map(l=>l.id));(g.size!==Object.keys(r.outputs).length||Object.keys(r.outputs).some(l=>!g.has(l)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",c),Z(b.root,l=>{!r.offering&&(l.type==="plan_picker"||(l.type==="stack"||l.type==="button")&&l.bind?.plan||l.type==="customer_data"&&["customer_plans","credit_packs"].includes(l.data.source))&&n("Product presentation requires an Offering Version","offering",c),l.type==="customer_data"&&Object.values(l.data.outputs??{}).some(z=>z!==void 0&&!g.has(z))&&n("Customer components require declared screen outcomes","componentOutput",c)})}}r.type==="end"&&["completed","ineligible"].includes(r.outcome)&&!r.output&&n("Completed and ineligible ends require a declared output","output",c),r.type==="end"&&r.output?.type==="literal"&&!T(t.outputSchema,r.output.value)&&n("Terminal output does not match outputSchema","output",c),r.type==="output"&&r.value.type==="literal"&&!T(t.outputSchema,r.value.value)&&n("Terminal output does not match outputSchema","output",c);let A=r.type==="output"?r.value:r.type==="end"?r.output:void 0;if(A?.type==="variable"&&!A.path){let u=t.variables[A.key];u&&!$e(u,t.outputSchema)&&n("Variable output does not match outputSchema","output",c)}if(r.type==="screen"){let u=i.get(r.screenId);if(u?.type==="owned")for(let b of xe(u.document))(/^(input|params)\./.test(b)||b.startsWith("variables.")&&!he(b.slice(10),x))&&n("Screen values must reference registered variables","variable",c)}if(r.type==="condition")for(let u of r.cases){for(let b of Ge(u.condition))a("saved_group",b)||n("Conditions require explicit Saved Group references","savedGroup",c);for(let b of q(u.condition))b.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",c)}if(r.type==="output"&&r.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",c);for(let[u,b]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let g=r.value[u];if(g)if(g.source==="literal"){let l=u==="coupons"?g.value:[g.value];(!Array.isArray(l)||l.length>20||l.some(z=>!T({type:b,nullable:!1},z)||!a(b,z.id))||u==="coupons"&&new Set(l.map(z=>z.id)).size!==l.length)&&n("Bundle requires distinct scoped resource references",u==="coupons"?"coupon":u==="paywall"?"paywall":"offering",[...c,"value",u])}else{let l=t.variables[g.key];(g.path||!l||l.nullable||(u==="coupons"?l.type!=="array"||l.items?.type!=="reward"||l.items.nullable:l.type!==b))&&n("Bundle binding type does not match its slot","output",c)}}}}for(let[d,r]of t.graph.nodes.entries()){let c=r.type==="screen"?i.get(r.screenId):void 0,w=[...Ot(r,x),...c?.type==="owned"?Xe(c.document).map(I=>he(I,x)?.key??I):[]];for(let I of new Set(w)){let b=function(g){if(g===r.id)return!0;if(u.has(g))return!1;u.add(g);let l=t.graph.nodes.find(Rt=>Rt.id===g);return l?(A.has(g)?l.type==="action"?[l.cancel,l.unavailable,l.failure]:l.type==="wait"&&l.wait.type==="event"?[l.wait.timeout]:[]:se(l)).some(b):!1};var N=b;if(!Object.hasOwn(t.variables,I)){n("Consumed variable is undeclared","variable",["graph","nodes",d]);continue}let O=t.variables[I];if(r.type==="screen"&&O.source.type==="input"&&t.inputs.some(g=>g.screenId===r.screenId&&g.variable===I)||O.source.type==="parameter"||O.source.type==="attribute")continue;let A=O.source.type==="input"?new Set(t.inputs.filter(g=>g.variable===I&&g.required).flatMap(g=>f.filter(l=>l.screenId===g.screenId).map(l=>l.id))):m.get(I)??new Set,u=new Set;(!A.size||b(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",d])}}(new Set(t.inputs.map(d=>d.variable)).size!==t.inputs.length||new Set(t.inputs.map(d=>`${d.screenId}:${d.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[d,r]of t.inputs.entries()){t.variables[r.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",d]);let c=i.get(r.screenId),w=c?.type==="owned"?me(c.document,r.componentId):null;if((w?.type!=="stack"||!w.interaction||!["input","toggle","select","multiselect","tabs"].includes(w.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",d]),w?.type==="stack"&&w.interaction){let I=w.interaction.type==="toggle"?"boolean":w.interaction.type==="multiselect"?"strings":"string";t.variables[r.variable]?.type!==I&&n("Input variable type does not match component","inputBinding",["inputs",d]);let O=t.variables[r.variable]?.enum;O&&!w.children.filter(A=>!A.hidden).every(A=>O.includes(A.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",d])}}for(let[d,r]of Object.entries(t.variables))r.enum&&r.type!=="string"&&n("Only string variables support enum","variable",["variables",d]),r.source.type==="input"&&!t.inputs.some(c=>c.variable===d)&&n("Input variable requires a component binding","inputBinding",["variables",d]);let p=0,v=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});v+=d.document.actions.length}(p>D.components||v>D.actions||F(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var ln=e.strictObject({...ze,graph:Ee}).superRefine(kt),pn=e.strictObject({...ze,graph:Ee,displayName:e.string().trim().min(1).max(80)}).superRefine(kt),Li=pn.superRefine(jt),Hi=ln.superRefine(jt),ue=e.string().regex(Fe),$={requestId:e.uuid(),nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:ue.optional()},dn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:R,answers:J,selection:e.record(R,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:R,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:He.optional(),subscriptionChange:We.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid(),merchantConfirmation:Pe.optional()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),mn=e.object({nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(R,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:Je.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),Zi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ne.optional(),customerData:re.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ie,oe),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:mn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("submit"),...$,input:dn}),e.strictObject({operation:e.literal("back"),...$}),e.strictObject({operation:e.literal("shown"),...$}),e.strictObject({operation:e.literal("close"),...$}),e.strictObject({operation:e.literal("commit_segment"),...$,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:ue.optional()})]);export{_t as a,Xe as b,F as c,Kt as d,Kn as e,Mt as f,gr as g,wr as h,Zt as i,Vn as j,Un as k,Bn as l,Vt as m,Ct as n,Nt as o,Gn as p,ne as q,re as r,ie as s,oe as t,at as u,$n as v,Pt as w,Ln as x,Hn as y,Zn as z,Oe as A,Bt as B,cr as C,ur as D,lr as E,nn as F,rn as G,Si as H,vi as I,pn as J,Zi as K};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as h}from"./chunk-CALDEF4M.js";import{a as b,c as w,l as x,m as O}from"./chunk-ASL7TJFU.js";import{a as I}from"./chunk-VILB5M4X.js";import{b as y,f as g,g as v}from"./chunk-3SXPCVIP.js";import{b as t}from"./chunk-GPJF3T43.js";var d=O,R=t.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),j=t.tuple([t.number().min(0).max(1),t.number().min(0).max(1)]).refine(([e,r])=>e<=r),F=t.strictObject({seed:t.string().min(1).max(255),variations:t.array(R).min(2).max(20),weights:t.array(t.number().min(0).max(1)).max(20).optional(),coverage:t.number().min(0).max(1).optional(),ranges:t.array(j).max(20).optional(),filters:t.array(t.strictObject({seed:t.string().min(1).max(255),ranges:t.array(j).max(100)})).max(100).optional(),passthrough:t.array(t.number().int().min(0).max(19)).max(20).optional(),condition:g.optional(),active:t.literal(!1).optional(),force:t.number().int().min(-1).max(19).optional()}),_=t.discriminatedUnion("type",[t.strictObject({type:t.literal("pass"),next:d}),t.strictObject({type:t.literal("condition"),cases:t.array(t.strictObject({condition:g,target:d})).min(1).max(50),default:d}),t.strictObject({type:t.literal("split"),experimentId:t.uuid(),bucketing:F,routes:t.record(R,d).refine(e=>Object.keys(e).length>=2&&Object.keys(e).length<=20),notParticipating:d}),t.strictObject({type:t.literal("paywall"),paywallId:t.uuid(),paywallVersionId:t.uuid(),presentation:y}),t.strictObject({type:t.literal("screen"),surface:t.enum(["page","popup","onboarding"]),presentation:y}),t.strictObject({type:t.literal("external_page")}),t.strictObject({type:t.literal("end"),outcome:t.enum(["completed","closed","ineligible","failed"])}),t.strictObject({type:t.literal("server"),reason:t.enum(["action","wait","feature","condition","experiment","resource"])})]),P={nodes:500,maxBytes:262144},S=t.strictObject({kind:t.literal("funnel_route"),formatVersion:t.literal(1),funnelId:t.uuid(),versionId:t.uuid(),entry:d,maxTransitions:t.number().int().min(1).max(1e4),variables:t.record(b,w),nodes:t.record(d,_)}).superRefine((e,r)=>{let s=a=>r.addIssue({code:"custom",message:a});Object.keys(e.nodes).length>P.nodes&&s("Too many route nodes"),Object.hasOwn(e.nodes,e.entry)||s("Route entry is missing");for(let a of Object.values(e.variables))["parameter","input"].includes(a.source.type)||s("Only start parameters and inputs can be public");for(let a of Object.values(e.nodes)){for(let c of V(a))Object.hasOwn(e.nodes,c)||s("Route target is missing");a.type==="split"&&a.bucketing.variations.some(c=>!Object.hasOwn(a.routes,c))&&s("Every Variation needs a route")}});function V(e){switch(e.type){case"pass":return[e.next];case"condition":return[...e.cases.map(r=>r.target),e.default];case"split":return[...Object.values(e.routes),e.notParticipating];default:return[]}}function E(e,r,s=[]){if(e==="id")return!0;if(!e.startsWith("variables."))return!1;let a=e.slice(10),c=i=>a===i||a.startsWith(`${i}.`)||i.startsWith(`${a}.`);return r.some(i=>a===i||a.startsWith(`${i}.`))&&!s.some(c)}function m(e,r,s=[]){return v(e).length===0&&I(e).every(a=>E(a,r,s))}function W(e){let{document:r}=e,s={},a=[];for(let[n,o]of Object.entries(r.variables))["parameter","input"].includes(o.source.type)?s[n]=o:a.push(n);let c=Object.keys(s),i=new Map(r.graph.nodes.map(n=>[n.id,n])),l={},u=[r.graph.entry],f=n=>{switch(n.type){case"entry":case"offering":case"coupon":case"coupons":return{type:"pass",next:n.next};case"condition":return n.cases.every(o=>m(o.condition,c,a))?{type:"condition",cases:n.cases.map(o=>({condition:o.condition,target:o.target})),default:n.default}:{type:"server",reason:"condition"};case"split":{let o=N(Object.hasOwn(e.experiments,n.experimentId)?e.experiments[n.experimentId]:void 0,n.routes,c,a);return o?{type:"split",experimentId:n.experimentId,bucketing:o,routes:{...n.routes},notParticipating:n.notParticipating}:{type:"server",reason:"experiment"}}case"screen":{let o=r.screens.find(p=>p.id===n.screenId);if(o?.type==="paywall"){let p=e.paywallOf(o.paywallVersionId);return p?{type:"paywall",paywallId:p,paywallVersionId:o.paywallVersionId,presentation:n.presentation}:{type:"server",reason:"resource"}}return o?.type==="owned"?{type:"screen",surface:o.document.surface,presentation:n.presentation}:{type:"server",reason:"resource"}}case"external_page":return{type:"external_page"};case"end":return{type:"end",outcome:n.outcome};case"output":return{type:"end",outcome:"completed"};case"feature":return{type:"server",reason:"feature"};case"action":return{type:"server",reason:"action"};case"wait":return{type:"server",reason:"wait"}}};for(;u.length;){let n=u.shift();if(Object.hasOwn(l,n))continue;let o=i.get(n);if(!o)throw new Error("Funnel route target is missing");let p=f(o);l[n]=p,u.push(...V(p))}return S.parse({kind:"funnel_route",formatVersion:1,funnelId:e.funnelId,versionId:e.versionId,entry:r.graph.entry,maxTransitions:r.execution.maxTransitions,variables:s,nodes:l})}function N(e,r,s,a){if(!e||(e.hashAttribute??"id")!=="id"||e.fallbackAttribute||e.parentConditions?.length||e.urlPatterns?.length||(e.hashVersion??2)!==2||(e.filters??[]).some(i=>(i.attribute??"id")!=="id")||e.condition&&!m(e.condition,s,a)||e.variations.some(i=>typeof i!="string"||!Object.hasOwn(r,i)))return;let c=(e.meta??[]).flatMap((i,l)=>i.passthrough?[l]:[]);return F.parse({seed:e.seed??e.key,variations:e.variations,...e.weights?{weights:e.weights}:{},...e.coverage!==void 0?{coverage:e.coverage}:{},...e.ranges?{ranges:e.ranges}:{},...e.filters?.length?{filters:e.filters.map(i=>({seed:i.seed,ranges:i.ranges}))}:{},...c.length?{passthrough:c}:{},...e.condition?{condition:e.condition}:{},...e.active===!1?{active:!1}:{},...e.force!==void 0?{force:e.force}:{}})}function G(e,r){return{key:e,seed:r.seed,hashAttribute:"id",hashVersion:2,variations:r.variations,...r.weights?{weights:r.weights}:{},...r.coverage!==void 0?{coverage:r.coverage}:{},...r.ranges?{ranges:r.ranges}:{},...r.filters?{filters:r.filters.map(s=>({attribute:"id",seed:s.seed,hashVersion:2,ranges:s.ranges}))}:{},...r.passthrough?{meta:r.variations.map((s,a)=>({passthrough:r.passthrough.includes(a)}))}:{},...r.condition?{condition:r.condition}:{},...r.active===!1?{active:!1}:{},...r.force!==void 0?{force:r.force}:{}}}function $(e,r){let s=[],a={versionId:e.versionId,path:s},c=f=>({...a,type:"unknown",reason:f}),i;try{i=x({declarations:e.variables,answers:{},parameters:r.parameters,attributes:{id:r.customerId},savedGroups:{},results:{}})}catch{return c("invalid_parameters")}let l=Object.keys(e.variables),u=e.entry;for(let f=0;;f++){let n=e.nodes[u];switch(s.push(u),n.type){case"paywall":return{...a,type:"paywall",paywallId:n.paywallId,paywallVersionId:n.paywallVersionId,presentation:n.presentation};case"screen":return{...a,type:"screen",surface:n.surface,presentation:n.presentation};case"external_page":return{...a,type:"external_page"};case"end":return{...a,type:"end",outcome:n.outcome};case"server":return c("server_step")}if(f>=e.maxTransitions)return c("transition_limit");if(n.type==="pass"){u=n.next;continue}if(n.type==="condition"){if(!n.cases.every(o=>m(o.condition,l)))return c("server_attribute");u=h({id:u,name:u,type:"condition",cases:n.cases,default:n.default},{attributes:i,savedGroups:{}},{}).target;continue}if(n.bucketing.condition&&!m(n.bucketing.condition,l))return c("server_attribute");u=h({id:u,name:u,type:"split",experimentId:n.experimentId,routes:n.routes,notParticipating:n.notParticipating},{attributes:i,savedGroups:{}},{[n.experimentId]:G(n.experimentId,n.bucketing)}).target}}export{P as a,S as b,W as c,$ as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o}from"./chunk-
|
|
1
|
+
import{b as o}from"./chunk-GPJF3T43.js";var s=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],n=o.string().regex(/.+\/.+/),e=o.number().min(-100),t=o.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),p=o.strictObject({input:t,output:t,cache_read:t.optional(),cache_write:t.optional(),reasoning:t.optional(),input_audio:t.optional(),output_audio:t.optional()}),i=(r,a)=>o.record(r,a).refine(c=>Object.keys(c).length<=100,"At most 100 AI overrides"),d=o.strictObject({defaultMarkup:e,providerMarkups:i(o.string().min(1),e),modelMarkups:i(n,e),customModels:i(n,p.partial())});export{s as a,n as b,e as c,p as d,d as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{J as se,d as O,f as ie}from"./chunk-DCZWNTG2.js";import{e as ee,k as ae}from"./chunk-ASL7TJFU.js";import{a as F}from"./chunk-RDUKCMST.js";import{b as te,f as ne,g as re,h as oe}from"./chunk-KP4QI4RX.js";import{s as ce}from"./chunk-7MYS52FL.js";import{C as Y,e as J,j as Z,l as W,p as R,s as X,t as H,v as w,w as P,x as Q,z as k}from"./chunk-MWICFZUF.js";import{a as T,f as K}from"./chunk-CWD36SJO.js";import{a as I,b as S,d as h,e as D,f as C,g as A}from"./chunk-3SXPCVIP.js";import{h as j}from"./chunk-6XRXHFM6.js";import{b as e}from"./chunk-GPJF3T43.js";import{a as L,b as U}from"./chunk-WPFTSHP2.js";var V=e.strictObject({eventsEnabled:e.boolean(),experimentViewsEnabled:e.boolean(),featureUsageEnabled:e.boolean()}),Ze=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function We(t,r){return r==="experiment_exposure"?t.experimentViewsEnabled:r==="feature_usage"?t.featureUsageEnabled:t.eventsEnabled}var z=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,r])=>t<=r),Se=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),we=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Oe=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),ue={condition:C.optional(),parentConditions:e.array(we).max(100).optional(),weights:e.array(e.number().min(0).max(1)).max(20).optional(),coverage:e.number().min(0).max(1).optional(),hashAttribute:e.string().optional(),fallbackAttribute:e.string().optional(),hashVersion:e.literal(2).optional(),disableStickyBucketing:e.boolean().optional(),bucketVersion:e.number().int().nonnegative().optional(),minBucketVersion:e.number().int().nonnegative().optional(),filters:e.array(Se).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Oe).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},pe=e.strictObject({...ue,key:e.string().min(1).max(255),variations:e.tuple([h,h]).rest(h).refine(t=>t.length<=20),urlPatterns:e.array(e.strictObject({include:e.boolean(),type:e.enum(["regex","simple"]),pattern:e.string()})).max(100).optional(),force:e.number().int().nonnegative().optional(),active:e.boolean().optional(),persistQueryString:e.boolean().optional()}),G=e.strictObject({value:h,variationId:e.number().int(),key:e.string(),name:e.string().optional(),bucket:e.number().optional(),passthrough:e.boolean().optional(),inExperiment:e.boolean(),hashUsed:e.boolean().optional(),hashAttribute:e.string(),hashValue:e.string(),featureId:e.string().nullable(),stickyBucketUsed:e.boolean().optional()}),je=e.strictObject({...ue,id:e.string().max(255).optional(),force:h.optional(),variations:e.array(h).min(2).max(20).optional(),key:e.string().optional(),range:z.optional(),tracks:e.array(e.strictObject({experiment:pe,result:G})).max(100).optional()}),Ie=e.strictObject({defaultValue:h.optional(),rules:e.array(je).max(500).optional()}),Pe=e.record(e.string(),e.union([e.strictObject({type:e.literal("hashed"),attributeKey:e.string(),values:e.array(e.string().regex(/^[a-f0-9]{64}$/))}),e.strictObject({type:e.literal("list"),attributeKey:e.string(),values:e.array(e.union([e.string(),e.number()]))}),e.strictObject({type:e.literal("condition"),condition:C})])),v=e.strictObject({scope:j,generation:e.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}).nullable(),features:e.record(e.string(),Ie),savedGroups:Pe,experiments:e.record(e.uuid(),pe)});var ke=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),it=ke.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((t,r)=>{for(let a of t.remoteFeatures)Object.hasOwn(t.features,a)&&r.addIssue({code:"custom",path:["features",a],message:"Remote Feature definitions cannot be public"});for(let[a,o]of Object.entries(t.savedGroups))o.type==="list"&&r.addIssue({code:"custom",path:["savedGroups",a],message:"Raw Saved Group lists cannot be public"})}),at=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),me=e.strictObject({value:h,source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:e.boolean(),off:e.boolean(),ruleId:e.string(),experimentResult:G.optional()}),st=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),me),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),de={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:te.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},le={...de,generation:v.shape.generation},Ce=e.discriminatedUnion("kind",[e.strictObject({...de,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...le,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...le,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:me.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),ct=e.strictObject({customerId:e.uuid().optional(),events:e.array(Ce).min(1).max(100)}),Ae=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),ut=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejections:e.array(Ae).max(100),analyticsConfig:V});function fe(t,r){let a=new Set,o=new Set,c=new Set,p=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(c.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(c.add(s),d.set(s,n),p.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function u(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ae(s[n]))throw new Error(`Funnel GB ${n} uses a reserved flow namespace`);m(s.condition);for(let n of s.parentConditions??[])l(n.id),m(n.condition)}function l(s,n=!1){let b=Object.hasOwn(r.features,s)?r.features[s]:void 0;if(!b){if(n)throw new Error("Required GB Feature is unavailable");return}a.has(s)||(a.add(s),g.set(s,b),p.push(()=>{for(let x of b.rules??[]){u(x);for(let ve of x.tracks??[])u(ve.experiment)}}))}function y(s){let n=Object.hasOwn(r.experiments,s)?r.experiments[s]:void 0;if(!n)throw new Error("Required GB Experiment is unavailable");o.has(s)||(o.add(s),f.set(s,n),p.push(()=>u(n)))}for(let s of t.graph.nodes){s.type==="feature"&&l(s.featureKey,!0),s.type==="split"&&y(s.experimentId),s.type==="condition"&&s.cases.forEach(b=>m(b.condition)),s.type==="offering"&&s.configuration.source==="feature"&&l(s.configuration.featureKey,!0);let n=s.type==="output"?s.value:s.type==="end"?s.output:null;n?.type==="feature"&&l(n.featureKey,!0)}for(let s of p)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var ge=e.object({defaultLocale:R,locales:e.record(R,e.object({name:e.string().max(80),description:e.string().max(500)}).strict())}).strict().superRefine((t,r)=>{let a=Object.keys(t.locales);(!a.length||a.length>20||!t.locales[t.defaultLocale])&&r.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(t)).length>5e4&&r.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var M=e.discriminatedUnion("type",[e.strictObject({type:e.literal("event"),event:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),e.strictObject({type:e.literal("open_url"),url:e.url().refine(t=>new URL(t).protocol==="https:")})]),Fe=P,Ee=e.discriminatedUnion("type",[e.object({type:e.literal("checkout"),product:I}).strict(),e.object({type:e.literal("close")}).strict(),e.object({type:e.literal("action"),action:M}).strict()]),E=e.object({schemaVersion:e.literal(3),kind:e.literal("paywall"),name:e.string().trim().min(1).max(80),presentation:S,requirement:K.optional(),products:F,offeringVersionId:e.uuid().nullable(),offeringId:e.uuid(),screen:Fe,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ee)}).strict(),Pt=E.superRefine((t,r)=>{(t.screen.surface!=="paywall"||t.screen.actions.some(o=>!["event","navigate"].includes(o.type)||o.close))&&r.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let o of Re(t))r.addIssue({code:"custom",message:o});for(let o of _e(t))r.addIssue({code:"custom",message:o});for(let o of t.screen.actions){let c=o.properties.closeControl;c!==void 0&&(c!=="content"||t.buttons[o.id]?.type!=="close")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:'Only a close button can carry closeControl, and its value is "content"'})}for(let o of t.screen.actions){let c=o.properties.couponBinding;c!==void 0&&(typeof c!="string"||!X.safeParse(c).success||t.buttons[o.id]?.type!=="checkout"||Y(t.screen,c)?.type!=="text")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:"Choose a Coupon text binding for this checkout action"})}k(t.screen).some(o=>!o.complete)&&r.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(t.buttons).length!==t.screen.actions.filter(o=>o.type!=="navigate").length||t.screen.actions.some(o=>o.type!=="navigate"&&!Object.hasOwn(t.buttons,o.id)))&&r.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(t.buttons).some(o=>o.type==="checkout")||r.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _e(t){let r=t.products.items.map(p=>p.productVersionId),a=Z(t.screen),o=new Set,c=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&c.push("products"),t.offeringVersionId||c.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(p=>!t.products.grouping.assignments.some(g=>g.tierId===p.id)))&&c.push("grouping");for(let p of Object.values(t.buttons))if(p.type==="checkout"){let g=p.product;if(g.type==="fixed")o.add(g.productVersionId);else{g.allowedProductVersionIds.forEach(m=>o.add(m));let f=!1,d=a[g.pickerId];d&&(f=!0,(g.allowedProductVersionIds.some(m=>!d.ids.includes(m))||d.ids.some(m=>!g.allowedProductVersionIds.includes(m)))&&c.push("picker")),w(t.screen,m=>{if(m.id!==g.pickerId||m.type!=="plan_picker")return;f=!0,(JSON.stringify(m.planIds)!==JSON.stringify(r)||JSON.stringify(g.allowedProductVersionIds)!==JSON.stringify(r)||m.defaultPlan!==t.products.defaultProductVersionId)&&c.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&c.push("grouping")}),f||c.push("picker")}}return(!o.size||[...o].some(p=>!r.includes(p)))&&c.push("purchase"),w(t.screen,p=>{p.type==="stack"&&p.productSlot&&!p.bind?.plan&&c.push(`productBinding:${p.id}`),(p.type==="stack"||p.type==="button")&&p.bind?.plan&&!r.includes(p.bind.plan)&&c.push("binding"),p.type==="plan_picker"&&(!p.planIds?.length||p.planIds.some(g=>!r.includes(g)))&&c.push("binding")}),[...new Set(c)]}function Re(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),Q(f.root,d=>{let m=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(m){let i=t.screen.actions.find(l=>l.id===m);i?.type==="navigate"&&o.get(f.id).push(i.pageId);let u=t.buttons[m];f.id!==a.id&&u&&u.type!=="close"&&r.push(`purchaseScreen:${d.id}`)}f.id!==a.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&r.push(`packageScreen:${d.id}`)});let c=new Set;function p(f){if(!c.has(f)){c.add(f);for(let d of o.get(f)??[])p(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?p(g):r.push("initialPage");for(let f of t.screen.pages)c.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var ye=e.object({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),state:e.enum(["active","archived"]),publishedVersionId:e.uuid().nullable(),updatedAt:e.iso.datetime({offset:!0}),draft:E}).strict(),kt=e.object({rows:e.array(ye).max(200),nextCursor:e.uuid().nullable()}).strict(),Ct=ye.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),At=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),document:E}).strict(),e.object({action:e.enum(["publish","archive"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Ft=e.object({paywalls:e.array(e.object({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),name:e.string().min(1).max(80),presentation:S,buttons:E.shape.buttons}).strict()).max(500),limited:e.boolean()}).strict();var De=["customer_data","coupon_code"],be=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Ve=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,ze=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ge=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),Me=e.strictObject({stripe:e.strictObject({prices:e.array(ze).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(be).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:be,basePlanId:Ve.nullable()})).min(1).max(10)}).optional()}).superRefine((t,r)=>{(t.stripe&&!_(t.stripe.prices,a=>a.currency)||t.apple&&!_(t.apple.productIds,a=>a)||t.google&&!_(t.google.products,a=>`${a.productId}:${a.basePlanId}`))&&r.addIssue({code:"custom",message:"Duplicate channel entry"})}),qe=e.strictObject({name:e.string().trim().min(1).max(80),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(100),trial:e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}).nullable(),benefits:e.array(Ge).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:Me,prepaid:e.array(J).max(100).optional()}),Be=e.strictObject({digest:O,content:e.strictObject({discount:ne,duration:re,appliesTo:oe,displayCopy:ge.nullable(),firstPurchaseOnly:e.boolean(),qualificationRequired:e.boolean(),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),grantWindowHours:e.number().int().positive(),perCustomerLimit:e.number().int().positive()})}),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("checkout"),product:I}),e.strictObject({type:e.literal("close")}),e.strictObject({type:e.literal("action"),action:M})]),Lt=e.strictObject({kind:e.literal("paywall"),formatVersion:e.literal(1),name:e.string().trim().min(1).max(80),offeringVersionId:e.uuid(),presentation:S,screen:P,products:F,catalog:e.record(e.uuid(),qe),buttons:e.record(H,Ne),coupons:e.record(e.uuid(),Be)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ce(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),ie(o,De).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let c=new Set,p=new Set,g=new Set;w(o,n=>{let b="bind"in n?n.bind:void 0;b?.promotionCode&&a("Promotion codes must not be published"),b?.plan&&c.add(b.plan),b?.coupon&&p.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>c.add(x)),n.defaultPlan&&c.add(n.defaultPlan)),n.type==="text"&&n.feature&&g.add(n.feature.id)});let f=t.products.items.map(n=>n.productVersionId),d=Object.keys(t.catalog);(f.length!==d.length||f.some(n=>!Object.hasOwn(t.catalog,n)))&&a("Catalog must contain exactly the displayed Products");let m=new Set(f);t.products.defaultProductVersionId!==null&&!m.has(t.products.defaultProductVersionId)&&a("Default Product must be displayed");for(let n of c)m.has(n)||a("Screen references a Product that is not displayed");for(let n of Object.values(t.catalog))!n.channels.stripe&&!n.channels.apple&&!n.channels.google&&a("A displayed Product needs at least one sales channel");let i=new Set(Object.values(t.catalog).flatMap(n=>n.benefits.map(b=>b.featureId)));for(let n of g)i.has(n)||a("Feature text must read a displayed benefit");let u=o.actions.filter(n=>n.type!=="navigate");o.actions.some(n=>n.type!=="event"&&n.type!=="navigate")&&a("Paywall actions are events or navigation"),(Object.keys(t.buttons).length!==u.length||u.some(n=>!Object.hasOwn(t.buttons,n.id)))&&a("Buttons must match the screen's actions");let y=!1;for(let n of Object.values(t.buttons)){if(n.type!=="checkout")continue;y=!0,(n.product.type==="fixed"?[n.product.productVersionId]:n.product.allowedProductVersionIds).some(x=>!m.has(x))&&a("Checkout may only sell displayed Products")}y||a("A Paywall needs a checkout button");let s=Object.keys(t.coupons);(s.length!==p.size||s.some(n=>!p.has(n)))&&a("Coupons must be exactly the bound Coupons")}),he=e.strictObject({state:e.enum(["published","archived"]),controlRevision:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({version:e.number().int().positive(),artifact:e.string().min(1),sourceDigest:e.string().regex(/^[a-f0-9]{64}$/)}))}).refine(t=>Object.keys(t.versions).length>0,"Reviewed Paywall Versions are required");var $e={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},q=e.string().regex(/^[a-f0-9]{64}$/),B=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Le=j.extend({environmentId:e.uuid()}),xe=e.strictObject({features:e.array(e.string()).max(500),experiments:e.record(e.uuid(),e.array(e.string()).max(20)),savedGroups:e.array(e.string()).max(1e3)}),Ue=e.strictObject({kind:e.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:e.number().int().positive(),url:e.string().min(1).max(2048),sha256:q,byteLength:e.number().int().positive().max($e.maxArtifactBytes),generation:q.optional()}),Te=e.strictObject({state:e.enum(["active","paused","archived"]),controlRevision:B,evaluationMode:e.enum(["local","remote"]),evaluationRevision:B,currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({artifact:e.string(),dependencies:xe,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),en=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Le,revision:B,generation:q,policy:e.strictObject({refreshIntervalSeconds:e.number().positive().max(15),maxControlAgeSeconds:e.number().positive().max(60)}),gb:e.strictObject({features:e.string().nullable(),pageExperiments:e.string().nullable()}),artifacts:e.record(e.string(),Ue),funnels:e.record(e.uuid(),Te),paywalls:e.record(e.uuid(),he).optional()}).superRefine((t,r)=>{let a=(o,c)=>{o!==null&&t.artifacts[o]?.kind!==c&&r.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};a(t.gb.features,"gb_features"),a(t.gb.pageExperiments,"gb_page_experiments");for(let o of Object.values(t.paywalls??{}))for(let c of Object.values(o.versions))a(c.artifact,"paywall");for(let o of Object.values(t.funnels)){o.evaluationMode==="remote"&&Object.keys(o.versions).length&&r.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),o.evaluationMode==="local"&&!o.versions[o.currentVersionId]&&r.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let c of Object.values(o.versions))a(c.artifact,"funnel")}});function N(t){if(Array.isArray(t))return`[${t.map(N).join(",")}]`;if(t!==null&&typeof t=="object")return`{${Object.entries(t).sort(([a],[o])=>a<o?-1:a>o?1:0).map(([a,o])=>`${JSON.stringify(a)}:${N(o)}`).join(",")}}`;let r=JSON.stringify(t);if(r===void 0)throw new Error("Configuration must contain JSON values");return r}function Je(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function tn(t){return Je(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function nn(t,r){let a=i=>i.type==="feature"?i.featureKey:i.type==="end"&&i.output?.type==="feature"?i.output.featureKey:i.type==="output"&&i.value.type==="feature"?i.value.featureKey:void 0,o=(i,u)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===u:i==="feature"&&a(l)===u)?.name,c=(i,u,l=o(u.type,u.resource))=>new $(i,{...u,...l?{step:l}:{}});for(let i of Object.values(t.references)){let u=i.type==="flag"?!Object.hasOwn(r.features,i.key)||r.remoteFeatures.includes(i.key)?{type:"feature",resource:i.key}:null:i.type==="experiment"?Object.hasOwn(r.experiments,i.id)?null:{type:"experiment",resource:i.id}:i.type==="saved_group"&&!Object.hasOwn(r.savedGroups,i.id)?{type:"saved_group",resource:i.id}:null;if(u)throw c("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...u})}let p=fe(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let u=a(i);if(!u)continue;let l=p.features[u],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:u};if(!l||!y)throw c("Required public Feature declaration is unavailable",{reason:"unavailable",...s},i.name);if([l.defaultValue,...(l.rules??[]).flatMap(b=>[...Object.hasOwn(b,"force")?[b.force]:[],...b.variations??[],...(b.tracks??[]).flatMap(x=>x.experiment.variations)])].some(b=>b===void 0||!ee(y,b)))throw c("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,u)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw c("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},u);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,u)}},m=(i,u)=>{if(g.has(i)||!r.features[i])throw c("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},u)};for(let i of t.graph.nodes)if(i.type==="condition")for(let u of i.cases)d(u.condition,i.name);for(let[i,u]of Object.entries(p.features)){let l=o("feature",i);for(let y of u.rules??[]){d(y.condition,l);for(let s of[...y.parentConditions??[],...(y.tracks??[]).flatMap(n=>n.experiment.parentConditions??[])])m(s.id,l),d(s.condition,l);for(let s of y.tracks??[])d(s.experiment.condition,l)}}for(let[i,u]of Object.entries(p.experiments)){let l=o("experiment",i);d(u.condition,l);for(let y of u.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let u=p.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!u)throw c("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of u.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw c("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return xe.parse({features:Object.keys(p.features).sort(),experiments:Object.fromEntries(Object.entries(p.experiments).map(([i,u])=>[i,u.variations.map(String)])),savedGroups:[...f].sort()})}function rn(t){return se.parse(t)}export{E as a,We as b,pe as c,Pe as d,v as e,ke as f,it as g,at as h,st as i,ct as j,ut as k,fe as l,Lt as m,$e as n,Le as o,Ue as p,en as q,N as r,Je as s,tn as t,nn as u,rn as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as x}from"./chunk-
|
|
1
|
+
import{d as x}from"./chunk-P6TNBX2S.js";import{a as l}from"./chunk-TL67SYPH.js";function D(e,t,n,s,i){let{presentation:o,screen:a}=n,b=Object.entries(n.buttons??{}).filter(([,p])=>p.type==="close").map(([p])=>p),c=e.ownerDocument.defaultView,u=a.pages.find(p=>p.id===a.initialPageId)?.theme??a.theme,w={background:a.theme.background,text:a.theme.text};t.inert=!0,t.style.cssText="width:100%;min-width:0;overflow:hidden;visibility:hidden";let f=!1,d,m=p=>{c&&d?.resizeViewport(Math.max(1,c.innerHeight-(p==="modal"?32:0)),c.innerWidth)},r=o.type==="inline"?void 0:x(e,{...a,presentation:o,theme:w},m);return r?.latch(),c&&r?.responsive&&r.setContentHeight(c.innerHeight-(r.type==="modal"?32:0)),e.style.background=u.background,e.style.color=u.text,r?(o.type==="fullscreen"||o.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",import("./screen-renderer-RDXKWHYE.js").then(({mountScreenPreview:p})=>{f||(d=p(t,{mode:"live",skeleton:!0,closeActions:b,hostPresentation:()=>r?.type??o.type,reportContentHeight:r?.responsive,onResize(k){if(!c||!r?.responsive)return;let v=r.type==="modal"?32:0,g=Math.min(k,Math.max(0,c.innerHeight-v));t.style.height=`${g}px`,r.setContentHeight(g)},onRendered:i,onError(){d&&(d.destroy(),d=void 0)}}),r?.responsive&&m(r.type),d.update({...a,presentation:o},s,{serverInput:{bindings:[],answers:{}}}))}).catch(()=>{d?.destroy(),d=void 0}),()=>{f=!0,d?.destroy(),r?.destroy()}}var $={none:0,sm:4,md:8,lg:14,full:9999},T={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},R={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function y(e){let[t,n,s]=[1,3,5].map(i=>{let o=Number.parseInt(e.slice(i,i+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*s}function H(e,t=!0){let n=y(e.primary),s=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",i=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,o=`${$[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${o};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;${t?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${T[e.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",pinned:`position:sticky;bottom:0;z-index:1;box-sizing:border-box;padding-top:12px;background:${e.background};border-top:1px solid ${i}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${i}`,message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",status:"margin:0;font-size:13px;opacity:.72",alert:`flex:1 1 200px;min-width:0;margin:0;font-size:13px;font-weight:500;color:${y(e.background)>.4?"#B42318":"#FDA29B"}`,panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${i};border-radius:${o}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${a};background:${e.primary};color:${s}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${i}`,link:`${a};background:transparent;color:${e.text};opacity:.72;font-weight:500`,stage:"display:flex;justify-content:center;padding:24px 20px",history:"display:flex;flex-direction:column;gap:12px;padding:20px",historyTitle:"margin:0;padding-inline-end:40px;font-size:17px;font-weight:600;line-height:1.3",historyNote:"margin:0;font-size:13px;opacity:.72",historyPages:"display:flex;gap:8px;flex-wrap:wrap;margin:0;padding:0;list-style:none",historyPage:`border:1px solid ${i};border-radius:${o};overflow:hidden`,historyRecords:`display:flex;flex-direction:column;gap:4px;margin:0;padding:12px 0 0;list-style:none;font-size:13px;border-top:1px solid ${i}`,focus:e.text}}function S(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function L(e,t){e.addEventListener("focus",()=>{let n=!0;try{n=e.matches(":focus-visible")}catch{}n&&(e.style.outline=`2px solid ${t()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var h={en:{network:"Connection problem. Check your network and try again.",timeout:"This is taking longer than expected. Try again.",other:"Something went wrong. Try again.",required:"Answer the questions marked * to continue.",permission:"This isn\u2019t available right now. Contact the merchant for help."},zh:{network:"\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",timeout:"\u54CD\u5E94\u65F6\u95F4\u8FC7\u957F\uFF0C\u8BF7\u91CD\u8BD5\u3002",other:"\u51FA\u4E86\u70B9\u95EE\u9898\uFF0C\u8BF7\u91CD\u8BD5\u3002",required:"\u8BF7\u5148\u56DE\u7B54\u5E26 * \u7684\u95EE\u9898\u3002",permission:"\u5F53\u524D\u65E0\u6CD5\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u3002"}};function A(e,t){let n=h[t?"zh":"en"],s=e instanceof l?e.code:void 0;return s==="NETWORK_ERROR"?n.network:s==="TIMEOUT"?n.timeout:z(e)?n.permission:n.other}function z(e){return e instanceof l&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function O(e,t){if(!(e instanceof l)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let n=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return n!==void 0&&t.some(s=>s.variable===n)}function C(e){return h[e?"zh":"en"].required}function I(e,t){return e.filter(({variable:n,required:s})=>{let i=t[n];return s&&(i==null||i===""||Array.isArray(i)&&i.length===0)})}var E={zh:{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4",prepared:"\u62A5\u4EF7\u5F85\u786E\u8BA4",quoted:"\u62A5\u4EF7\u5F85\u786E\u8BA4",confirmed:"\u5904\u7406\u4E2D",effective:"\u5DF2\u751F\u6548",scheduled:"\u5DF2\u5B89\u6392\u7EED\u671F\u53D8\u66F4"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed",prepared:"Quote ready",quoted:"Quote ready",confirmed:"Processing",effective:"Effective",scheduled:"Scheduled for renewal"}};function _(e,t){return E[t?"zh":"en"][e]}export{D as a,R as b,H as c,S as d,L as e,A as f,z as g,O as h,C as i,I as j,_ as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as pe,b as ye}from"./chunk-CSLTAXC7.js";import{d as fe,e as $}from"./chunk-AQONMY2H.js";import{a as ue}from"./chunk-TL67SYPH.js";import{a as P}from"./chunk-DSPLGTQI.js";var Ce=5*6e4,Ee=15e3,me=new WeakMap;function Oe(i){return me.get(i)}var C=i=>Array.isArray(i)?i.map(C):i&&typeof i=="object"?Object.fromEntries(Object.keys(i).sort().map(n=>[n,C(i[n])])):i,R=(i,n)=>JSON.stringify(C(i))===JSON.stringify(C(n)),we=i=>JSON.stringify(C([i.funnelId,i.locale??null,i.parameters??{}])),ke=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","confirmOnHostedCheckout","resolveOfferId","resolveSubscriptionChange","onOpenUrl","onEvent","onAction","onComplete","onError"];function Fe(i,n){let z=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),y,Q="",Y=n.start instanceof Promise?void 0:z(n.start),D=e=>e?.parameters?.commerce,Z=Promise.resolve(n.start).then(e=>e?z(e):void 0),M=n.maxAgeMs??Ce,ee=new AbortController,p=AbortSignal.any([ee.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),q=()=>o("released","aborted"),t="preparing",ne,_,x=()=>{},V=0,h=null,m=null,g=null,d=null,b,L,ae=new Map,u=null,O=new Set,S=new Map,j,te=new Promise(e=>j=e),T,ge=new Promise(e=>T=e);function F(e,a){t!==e&&(t=e,ne=a,P(n.onState,e))}function he(){p.removeEventListener("abort",q),H(),m?.destroy(),m=null,h?.remove(),h=null,g=null}function o(e,a){["adopted","unavailable","released","closed"].includes(t)||(F(e,a),he(),j(!1),T(null))}let J=e=>`error:${e?.code??e?.name??"unknown"}`,U=i.ownerDocument.defaultView,E=!0,re=null,I=!1,be=e=>e.storageArea===U?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),oe=e=>{be(e)&&N()},ve=n.client.subscribe(()=>N());function H(){E&&(E=!1,U?.removeEventListener("storage",oe),ve(),x())}let G=()=>E&&(t==="ready"||t==="preparing");function W(e){(t==="ready"||t==="preparing")&&o("unavailable",e)}function N(){if(t==="ready"&&Date.now()-V>=M)return H();I=!0,re??=(async()=>{for(;I&&y&&G();){I=!1;try{await n.client.retained()==="pending"&&W("purchase_pending")}catch(e){p.aborted?o("released","aborted"):W(J(e))}}})().finally(()=>{re=null,I&&y&&G()&&N()})}U?.addEventListener("storage",oe),p.addEventListener("abort",q,{once:!0});let le=n.client.findPurchase();le.catch(()=>{});let k;function K(e){let a=JSON.stringify(C(e)),r=ae.get(a);return r||(r=n.client.readPaywall({paywallVersionId:k?.paywallVersionId??n.paywallVersionId??d?.id,...k?.paywallVersionId||n.paywallVersionId||d?{}:{paywallId:k?.paywallId??n.paywallId},...e}),ae.set(a,r)),r}function B(e){let a=Object.values(e.capabilities.plans);return!(Object.values(e.document.buttons).some(s=>s.type==="checkout")&&a.length===0)&&!a.some(s=>!s.available)}function ie(e,a){if(d&&!$(e,d))return o("unavailable","paywall_changed"),!1;d=e,L=a;for(let r of S.keys())P(r,structuredClone(e));return!0}async function A(){let e=await ge;if(!e)throw new ue("PURCHASE_PENDING","The purchase did not start; open it again");return e}let Pe={get view(){return u?u.view:d},get signal(){return u?.signal??n.client.identitySignal},get quote(){return u?.quote??null},get operation(){return u?.operation??null},webViewUrl:"bundled",get canReselect(){return u?.canReselect},get recovery(){return u?.recovery},get pendingCancellation(){return u?.pendingCancellation},subscribe(e){return S.set(e,u?.subscribe?.(e)??(()=>{})),()=>{S.get(e)?.(),S.delete(e)}},refresh:async()=>u?u.refresh():structuredClone(d),preview:async e=>(await A()).preview(e),confirm:async()=>(await A()).confirm(),cancel:async()=>(await A()).cancel(),read:async()=>(await A()).read(),destroy(){u?.destroy()}},f={options:{},handoff:{}},se={loading:"host",focusAtReveal:!0,signal:n.client.identitySignal,start:async()=>Pe,canInteract:()=>f.options.canInteract?f.options.canInteract():!["unavailable","released","closed"].includes(t),async beforeAction(){let e=t!=="adopted",a=d?.capabilities,r=await A();if(e&&!R(r.view?.capabilities,a))throw new fe;await f.options.beforeAction?.()}};for(let e of ke)Object.defineProperty(se,e,{enumerable:!0,get:()=>f.options[e]});function X(){t!=="preparing"||!g||!m||!y||!R(L?.commerce,D(y))||L?.locale!==y.locale||(F("ready"),j(!0))}let Se={present(e){if(f.handoff.present)return f.handoff.present(e);t==="preparing"&&(g=e,V=Date.now(),X())},async dismiss(){if(f.handoff.dismiss)return f.handoff.dismiss();o("closed");for(let e of[...O])P(e)},quoteError(e){f.handoff.quoteError?f.handoff.quoteError(e):P(f.options.onError,e)}};async function Ie(){if(n.paywallVersionId||n.paywallId)return{paywallVersionId:n.paywallVersionId,paywallId:n.paywallId};let e=n.configuration;if(!e)return o("unavailable","paywall_missing"),null;let a=await Promise.resolve(n.start).catch(()=>null);if(!a||t!=="preparing")return null;let r=()=>pe(e,{funnelId:a.funnelId,customerId:n.client.customerId,parameters:a.parameters??{}});if(_=await r(),t!=="preparing")return null;let s=_;if(s.type!=="paywall")return o("unavailable",ye(s)??"route"),null;let l=!1;return x=e.subscribe(()=>{l||!G()||(l=!0,r().then(c=>{!(c.type==="unavailable"&&!["funnel_stopped","route_unavailable"].includes(c.reason))&&(c.type!=="paywall"||c.paywallVersionId!==s.paywallVersionId)&&W("route_changed")}).finally(()=>l=!1))}),E||x(),{paywallVersionId:s.paywallVersionId}}(async()=>{try{let[{showPaywall:e},a]=await Promise.all([import("./paywall-PZ4BBEFG.js"),Ie()]);if(p.throwIfAborted(),t!=="preparing"||!a)return;let r=n.commerce??D(Y),s=n.locale??Y?.locale;if(!r)return o("unavailable","commerce_missing");if(!s)return o("unavailable","locale_missing");k=a;let l={commerce:r,locale:s},c=await K(l);if(p.throwIfAborted(),t!=="preparing"||(!B(c)&&n.start instanceof Promise&&!b&&await Z,b&&!R(l,b)&&(l=b,c=await K(l)),p.throwIfAborted(),t!=="preparing"))return;if(!B(c))return o("unavailable","plan_unavailable");if(!ie(c,l))return;h=i.ownerDocument.createElement("div"),i.append(h);let v=setTimeout(()=>t==="preparing"&&o("unavailable","timeout"),Ee);te.then(()=>clearTimeout(v));let w=await e(h,se,Se);if(!w.host||p.aborted||t!=="preparing"){w.host?.destroy(),o(p.aborted?"released":"unavailable","error");return}m=w.host,X()}catch(e){o(p.aborted?"released":"unavailable",J(e))}})(),Z.then(async e=>{if(!e)return o("unavailable","gated");let a=e,r=D(a),s=n.commerce??r;if(!R(r&&{...r,intent:void 0},s&&{...s,intent:void 0})||n.locale!==void 0&&a.locale!==n.locale)return o("unavailable","start_mismatch");if(!r)return o("unavailable","commerce_missing");b={commerce:r,locale:a.locale};try{let l=await le,c=l==="pending"?"purchase_pending":l==="found"?"original_purchase":l==="blocked"?"purchase_blocked":void 0;if(c)return o("unavailable",c);if(t!=="preparing")return;if(E&&(I=!1,await n.client.retained()==="pending"))return o("unavailable","purchase_pending");if(k||n.paywallId||n.paywallVersionId||d){let v=await K(b);if(p.throwIfAborted(),t!=="preparing")return;if(d){if(!B(v))return o("unavailable","plan_unavailable");if(!ie(v,b))return}}}catch(l){return o(p.aborted?"released":"unavailable",J(l))}t==="preparing"&&(y=a,Q=we(a),X(),I&&N())},()=>o("unavailable","gated"));let ce={get state(){return t},get reason(){return ne},ready:te,get start(){return y},get prediction(){return _?structuredClone(_):void 0},matches:e=>!!y&&we(e)===Q,open(){if(t==="preparing")return"pending";if(t!=="ready"||!g)return!1;if(Date.now()-V>=M)return o("unavailable","expired"),!1;let e=g;return g=null,H(),F("shown"),e(),"shown"},destroy(){ee.abort()}};return me.set(ce,{onClose(e){return t==="closed"?(P(e),()=>{}):(O.add(e),()=>{O.delete(e)})},claim(){H()},async adopt(e,a){let r=e.paywall?.resolution,s=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(t!=="shown"||!m||!d||!r||!s||e.source.id!==y?.funnelId||e.locale!==y?.locale||!R(e.parameters??{},y?.parameters??{})||!["running","waiting"].includes(e.status)||!$(r,d))return null;let l;try{l=await a.start()}catch{return null}if(t!=="shown"||!m)return l.destroy(),null;u=l,f.options=a.options,f.handoff=a.handoff;for(let[w]of S)S.set(w,l.subscribe?.(w)??(()=>{})),l.view&&P(w,structuredClone(l.view));p.removeEventListener("abort",q),F("adopted"),T(l),O.clear();let c=m,v=h;return m=null,h=null,g=null,new Proxy(c,{get(w,de){return de==="destroy"?()=>{w.destroy(),v?.remove()}:Reflect.get(w,de,w)}})},get modal(){return d?.document.presentation.type!=="inline"},get revealable(){return t==="ready"&&!!g&&Date.now()-V<M},release(){o("released")}}),ce}export{Ce as a,Oe as b,Fe as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A}from"./chunk-W32FI2A2.js";import{b as D,e as L}from"./chunk-SLUA7ABW.js";import{d as T}from"./chunk-
|
|
1
|
+
import{a as A}from"./chunk-W32FI2A2.js";import{b as D,e as L}from"./chunk-SLUA7ABW.js";import{d as T}from"./chunk-O6CUNETH.js";import{a as R}from"./chunk-DSPLGTQI.js";import{b as O}from"./chunk-C4NG6RVA.js";var m=new WeakMap;function B(e){let o=e.view,n=o?.paywall?.resolution;if(!o||!["running","waiting"].includes(o.status)||o.stopped||!n||"document"in n||!e.resolvePaywall||e.identitySignal?.aborted)return;let a=JSON.stringify(n);if(m.get(e)?.key===a)return;let i=JSON.parse(a),c=e.identitySignal,u=Promise.resolve().then(async()=>{c?.throwIfAborted();let v=await e.resolvePaywall(i);return c?.throwIfAborted(),v}),f={key:a,content:u};return m.set(e,f),u.catch(()=>{}),()=>{m.get(e)===f&&m.delete(e)}}function Q(e,o){let n=m.get(e);return m.delete(e),n?.key===JSON.stringify(o)?n.content:e.resolvePaywall(o)}function re(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let o=e.client.pageExperiments.bind(e.client),n=!1,a=!1,i=0,c=!1,u=!1,f="",v=()=>{let t=e.client.view;return JSON.stringify([t?.id,t?.source.versionId,t?.visit,t?.revision,t?.status,t?.stopped])},s=new Map,x=new Set,q={},d=new Map,U=D(e.appManifestRelease),C=()=>{for(let t of s.values())t.effect.revert();s.clear()},g=()=>{C();for(let t of d.values())t();d.clear()};function E(t){if(n||x.has(t))return;x.add(t);let h=i;o(e.appManifestRelease,[t]).catch(k=>{x.delete(t),!n&&h===i&&R(e.onError,k)})}async function w(){if(n)return;f=v();let t=e.client.view;if(!t||t.stopped||!["running","waiting"].includes(t.status)){i++,g();return}if(document.visibilityState==="hidden")return;if(c){u=!0;return}c=!0;let h=++i,k=`${t.id}:${t.visit}:${t.revision}`,W=location.href;try{let[P,{applyVisualVariation:j}]=await Promise.all([o(e.appManifestRelease),import("./visual-dom-IN6DRNX3.js")]),p=e.client.view;if(n||h!==i||!p||p.stopped||!["running","waiting"].includes(p.status)||`${p.id}:${p.visit}:${p.revision}`!==k||location.href!==W)return;let $=new Set,I=new Set;for(let r of P.assignments){let l=`${P.payload.environmentId}:${r.experimentKey}`;if(I.add(l),d.has(l)||d.set(l,L(l,q)),!!r.inExperiment)for(let y of P.payload.experiments){if(y.key!==r.experimentKey||!O(location.href,y.urlPatterns??[]))continue;let z=y.meta?.findIndex(F=>F.key===r.variationKey)??-1,S=y.variations[z];if(!S?.renderGuard)continue;let b=r.receiptId+":"+y.changeId,J=JSON.stringify([r.variationKey,S]);$.add(b);let N=s.get(b);if(N?.signature===J){N.effect.applied&&E(r.receiptId);continue}s.get(b)?.effect.revert(),s.delete(b);let K=j(S,{requireUniqueTargets:!0,boundVariations:y.variations,allowJs:!1,onApplied:()=>E(r.receiptId),onError:F=>R(e.onError,F)});s.set(b,{signature:J,effect:K}),K.applied&&E(r.receiptId)}}for(let[r,l]of s)$.has(r)||(l.effect.revert(),s.delete(r));for(let[r,l]of d)I.has(r)||(l(),d.delete(r))}catch(P){h===i&&g(),!n&&h===i&&R(e.onError,P)}finally{c=!1,u&&!n&&(u=!1,w())}}let G=e.client.subscribe(()=>{if(v()===f)return;f=v(),i++;let t=e.client.view;(!t||t.stopped||!["running","waiting"].includes(t.status))&&g(),a&&w()}),H=T(()=>{i++,g(),a&&w()}),V=()=>{i++,C()};document.addEventListener("visibilitychange",V);let M=A({document,run:async()=>{a&&await w()},delay:()=>a&&!n?15e3:void 0});return{async start(){a||n||(a=!0,await M.refresh())},refresh:w,destroy(){n=!0,i++,M.destroy(),document.removeEventListener("visibilitychange",V),G(),H(),g(),U.destroy()}}}export{B as a,Q as b,re as c};
|