@tinkerlandai/longplay-sdk 0.10.27 → 0.10.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-XZMM34BS.js → chunk-2JTMXZ5M.js} +1 -1
  3. package/dist/chunk-3GT4A3TA.js +1 -0
  4. package/dist/{chunk-SYQMGS6O.js → chunk-4OBCF5H3.js} +2 -2
  5. package/dist/{chunk-TJMODHSS.js → chunk-4WBIACS2.js} +1 -1
  6. package/dist/{chunk-AEERSTTW.js → chunk-5X6WAPH3.js} +1 -1
  7. package/dist/{chunk-2TQEJ6GM.js → chunk-6QJRT23Q.js} +1 -1
  8. package/dist/{chunk-67JOPO63.js → chunk-77GCT2VP.js} +1 -1
  9. package/dist/{chunk-S4X6YX5D.js → chunk-7EPE2PUN.js} +1 -1
  10. package/dist/{chunk-ANZB6OLR.js → chunk-AZ53RDWO.js} +1 -1
  11. package/dist/{chunk-HWQVZL7I.js → chunk-CGSZBPSX.js} +1 -1
  12. package/dist/{chunk-MBLWCMAI.js → chunk-EUVKRGMO.js} +1 -1
  13. package/dist/{chunk-COMWJEMO.js → chunk-FDCINOOI.js} +1 -1
  14. package/dist/{chunk-WKH23DZE.js → chunk-GOYKJHDV.js} +1 -1
  15. package/dist/{chunk-G2QO6ZWP.js → chunk-HZYCK4XJ.js} +1 -1
  16. package/dist/chunk-IDMOAV63.js +1 -0
  17. package/dist/chunk-JAUJZWYJ.js +1 -0
  18. package/dist/{chunk-D4CDG535.js → chunk-JPHYIUIR.js} +1 -1
  19. package/dist/chunk-K72QA2PO.js +1 -0
  20. package/dist/{chunk-26YREQNF.js → chunk-KAXKYBSI.js} +1 -1
  21. package/dist/{chunk-LHOSUSTZ.js → chunk-MBKZYWPF.js} +1 -1
  22. package/dist/{chunk-WU4SDY27.js → chunk-MMZR4I5X.js} +1 -1
  23. package/dist/{chunk-5OJVM7Q4.js → chunk-O4KXODTJ.js} +1 -1
  24. package/dist/{chunk-EBXWLW4D.js → chunk-PKY55SBA.js} +1 -1
  25. package/dist/{chunk-FB7X4MFC.js → chunk-PNHGULO2.js} +1 -1
  26. package/dist/{chunk-WCKOWAIL.js → chunk-PQJJ5BSY.js} +1 -1
  27. package/dist/{chunk-VTZHKUZO.js → chunk-Q2TQLDEH.js} +1 -1
  28. package/dist/{chunk-7CFSTOTX.js → chunk-QZG2YXM4.js} +1 -1
  29. package/dist/{chunk-DC7UHEC6.js → chunk-S4JIOALC.js} +1 -1
  30. package/dist/{chunk-LHXRT32T.js → chunk-SBSLHDBE.js} +1 -1
  31. package/dist/{chunk-S67P7ZQ6.js → chunk-TLGKBSXC.js} +1 -1
  32. package/dist/chunk-TNN4S6VO.js +1 -0
  33. package/dist/{chunk-5M536ISX.js → chunk-UWAZDSWO.js} +1 -1
  34. package/dist/{chunk-2ZPCWVFU.js → chunk-VC2H3LFP.js} +1 -1
  35. package/dist/chunk-VKDBROTE.js +1 -0
  36. package/dist/{chunk-LI4B43FT.js → chunk-VSWKFI3L.js} +1 -1
  37. package/dist/{chunk-MTKM26F7.js → chunk-YBX2LLRG.js} +1 -1
  38. package/dist/{content-4V7YBP3O.js → content-S5MXIR7Y.js} +1 -1
  39. package/dist/{funnel-host-purchase-LJYQF6AX.js → funnel-host-purchase-7BRXGIJX.js} +1 -1
  40. package/dist/funnel-runtime-host-ITKTYBDS.js +1 -0
  41. package/dist/index.js +1 -1
  42. package/dist/merchant-bridge-contracts-JCDMP54Z.js +1 -0
  43. package/dist/native-shell.js +1 -1
  44. package/dist/openrouter.js +1 -1
  45. package/dist/operation-contracts-B7I45NS3.js +1 -0
  46. package/dist/page.js +1 -1
  47. package/dist/paywall-BEFHTZW7.js +1 -0
  48. package/dist/paywall-session-YVGZPSFM.js +1 -0
  49. package/dist/popup.d.ts +2 -0
  50. package/dist/popup.js +1 -1
  51. package/dist/react-native.js +1 -1
  52. package/dist/screen-renderer-ITUUNF4E.js +1 -0
  53. package/dist/server.js +1 -1
  54. package/dist/{visual-dom-CAOVBSVC.js → visual-dom-5LUN4AHO.js} +1 -1
  55. package/dist/visual.js +1 -1
  56. package/package.json +1 -1
  57. package/dist/chunk-2GMWNOOE.js +0 -1
  58. package/dist/chunk-JGG4R75K.js +0 -1
  59. package/dist/chunk-VRCN5YLM.js +0 -1
  60. package/dist/chunk-WPLSGFYT.js +0 -1
  61. package/dist/chunk-XBVJHXSP.js +0 -1
  62. package/dist/chunk-Z6RZQ5KJ.js +0 -1
  63. package/dist/funnel-runtime-host-XWXG4SIU.js +0 -1
  64. package/dist/merchant-bridge-contracts-OL3ME2AL.js +0 -1
  65. package/dist/operation-contracts-NJPUHGUM.js +0 -1
  66. package/dist/paywall-INF4ZZ7J.js +0 -1
  67. package/dist/paywall-session-3JV2JMUI.js +0 -1
  68. package/dist/screen-renderer-ZRSVFBLQ.js +0 -1
  69. /package/dist/{chunk-ZGBSTK22.js → chunk-7GD2UTBU.js} +0 -0
  70. /package/dist/{chunk-QENDBHBQ.js → chunk-CILM5XMH.js} +0 -0
  71. /package/dist/{chunk-D6SDVDXZ.js → chunk-OJM6ORHE.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as I,b as L}from"./chunk-QENDBHBQ.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-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}/*!
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
@@ -1 +1 @@
1
- import{s as g,t as w}from"./chunk-5M536ISX.js";import{n as I,s as h}from"./chunk-2GMWNOOE.js";import{a as y}from"./chunk-MTKM26F7.js";import{a}from"./chunk-S4X6YX5D.js";import{a as T}from"./chunk-3VUPVXAV.js";import{b as P}from"./chunk-AEERSTTW.js";import{a as f}from"./chunk-ZGBSTK22.js";function b(r,n,o){if(!["subscriptions/operations/read","subscriptions/updates/read","subscriptions/refunds/read"].includes(r))return;let e=n,c=o,s=c.operation;if(s.operationId!==e.operationId||[s.authority,s.merchantExecution].some(t=>t&&(t.operationId!==e.operationId||e.customerId!==void 0&&t.customerId!==e.customerId))||s.authority&&(s.authority.scope.projectId!==c.scope.projectId||s.authority.scope.environment!==c.scope.environment))throw new a("INVALID_RESPONSE","Original commerce operation changed")}function D(r){try{return structuredClone(r)}catch{return r}}async function q(r,n){let o=r.captureIdentity?.(),{apiOperations:e}=await import("./operation-contracts-NJPUHGUM.js");return o?.(),e[n]}function E(r,n,o,e){try{return r.parse(n)}catch(c){throw e&&c instanceof f?new a(o,e):c}}async function x(r,n,o,e={},c){let s=typeof e=="function"?{}:e,t=E(n.request,o,"INVALID_REQUEST",s.request);try{let i=await r(n.path,t,n.method,c),u=typeof e=="function"?e:e.parseResponse,d=u?u(n.response,i):E(n.response,i,"INVALID_RESPONSE",s.response);return b(n.path,t,d),d}catch(i){throw i instanceof a&&t!==null&&typeof t=="object"&&"requestId"in t&&typeof t.requestId=="string"&&(i.commandRequestId??=t.requestId),i}}function O(r,n){let o=typeof r=="string"?new TextEncoder().encode(r):r;return o.byteLength===n.byteLength&&h(o)===n.sha256}async function F(r,n){let o=g.parse(n),{artifact:e,environmentId:c}=o.content,s=new y(r.baseUrl??P).origin,t=new y(e.url,s);if(t.origin!==s||t.username||t.password||t.search||t.hash||t.pathname!==`/api/v1/configuration/${c}/artifacts/${e.sha256}`)throw new a("INVALID_RESPONSE","Public Paywall locator is not trusted");let i=new AbortController,u,d=new Promise((p,l)=>{u=setTimeout(()=>{let m=new a("TIMEOUT","Public Paywall read timed out");i.abort(m),l(m)},I.initializationMs)}),R=(async()=>{let p=await(r.fetch??globalThis.fetch)(t,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:i.signal});if(i.signal.aborted&&(p.body?.cancel().catch(()=>{}),i.signal.throwIfAborted()),!p.ok||!p.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(p.headers.get("content-length"))>e.byteLength)throw p.body?.cancel().catch(()=>{}),new a("INVALID_RESPONSE","Public Paywall is unavailable");let l=await T(p,e.byteLength,{signal:i.signal,error:m=>new a("INVALID_RESPONSE",m==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!O(l,e))throw new a("INVALID_RESPONSE","Public Paywall digest or size changed");return w(o,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([R,d])}finally{clearTimeout(u)}}export{D as a,q as b,x as c,O as d,F as e};
1
+ import{s as g,t as w}from"./chunk-UWAZDSWO.js";import{n as I,s as h}from"./chunk-TNN4S6VO.js";import{a as y}from"./chunk-YBX2LLRG.js";import{a}from"./chunk-7EPE2PUN.js";import{a as T}from"./chunk-3VUPVXAV.js";import{b as P}from"./chunk-5X6WAPH3.js";import{a as f}from"./chunk-7GD2UTBU.js";function b(r,n,o){if(!["subscriptions/operations/read","subscriptions/updates/read","subscriptions/refunds/read"].includes(r))return;let e=n,c=o,s=c.operation;if(s.operationId!==e.operationId||[s.authority,s.merchantExecution].some(t=>t&&(t.operationId!==e.operationId||e.customerId!==void 0&&t.customerId!==e.customerId))||s.authority&&(s.authority.scope.projectId!==c.scope.projectId||s.authority.scope.environment!==c.scope.environment))throw new a("INVALID_RESPONSE","Original commerce operation changed")}function D(r){try{return structuredClone(r)}catch{return r}}async function q(r,n){let o=r.captureIdentity?.(),{apiOperations:e}=await import("./operation-contracts-B7I45NS3.js");return o?.(),e[n]}function E(r,n,o,e){try{return r.parse(n)}catch(c){throw e&&c instanceof f?new a(o,e):c}}async function x(r,n,o,e={},c){let s=typeof e=="function"?{}:e,t=E(n.request,o,"INVALID_REQUEST",s.request);try{let i=await r(n.path,t,n.method,c),u=typeof e=="function"?e:e.parseResponse,d=u?u(n.response,i):E(n.response,i,"INVALID_RESPONSE",s.response);return b(n.path,t,d),d}catch(i){throw i instanceof a&&t!==null&&typeof t=="object"&&"requestId"in t&&typeof t.requestId=="string"&&(i.commandRequestId??=t.requestId),i}}function O(r,n){let o=typeof r=="string"?new TextEncoder().encode(r):r;return o.byteLength===n.byteLength&&h(o)===n.sha256}async function F(r,n){let o=g.parse(n),{artifact:e,environmentId:c}=o.content,s=new y(r.baseUrl??P).origin,t=new y(e.url,s);if(t.origin!==s||t.username||t.password||t.search||t.hash||t.pathname!==`/api/v1/configuration/${c}/artifacts/${e.sha256}`)throw new a("INVALID_RESPONSE","Public Paywall locator is not trusted");let i=new AbortController,u,d=new Promise((p,l)=>{u=setTimeout(()=>{let m=new a("TIMEOUT","Public Paywall read timed out");i.abort(m),l(m)},I.initializationMs)}),R=(async()=>{let p=await(r.fetch??globalThis.fetch)(t,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:i.signal});if(i.signal.aborted&&(p.body?.cancel().catch(()=>{}),i.signal.throwIfAborted()),!p.ok||!p.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(p.headers.get("content-length"))>e.byteLength)throw p.body?.cancel().catch(()=>{}),new a("INVALID_RESPONSE","Public Paywall is unavailable");let l=await T(p,e.byteLength,{signal:i.signal,error:m=>new a("INVALID_RESPONSE",m==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!O(l,e))throw new a("INVALID_RESPONSE","Public Paywall digest or size changed");return w(o,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([R,d])}finally{clearTimeout(u)}}export{D as a,q as b,x as c,O as d,F as e};
@@ -1 +1 @@
1
- import{a as G}from"./chunk-XBVJHXSP.js";import{b as Z}from"./chunk-S67P7ZQ6.js";import{a as j,b as Q,c as x}from"./chunk-G2QO6ZWP.js";import{a as L,b as F,c as H,j as l}from"./chunk-2ZPCWVFU.js";import{b as e}from"./chunk-ZGBSTK22.js";var fe=["purchase.subscription","purchase.one_time","purchase.prepaid","purchase.trial","purchase.seats","purchase.tiered","tax.automatic","discount.percent.once","discount.percent.repeating","discount.percent.forever","discount.amount.once","discount.amount.repeating","discount.amount.forever","subscription.cancel.immediate","subscription.cancel.renewal","subscription.resume","subscription.plan.immediate","subscription.plan.renewal","subscription.seats","subscription.quantity","subscription.billing_cycle","subscription.proration","refund.full","refund.partial","refund.revoke"],K=e.enum(fe),W=e.enum(["purchase.completed","purchase.closed","subscription.observed","subscription.change.completed","subscription.change.closed","invoice.paid","refund.updated"]);var o=e.string().min(1).max(200),c=e.iso.datetime({offset:!0}),i=e.number().int().nonnegative().max(1e8),y=e.string().regex(/^[A-Z]{3}$/),m=e.strictObject({priceId:e.uuid(),productVersionId:e.uuid(),productId:o,quantity:e.number().int().min(1).max(1e6),unitAmountMinor:i,totalMinor:i,interval:e.enum(["week","month","year","one_off"]),intervalCount:e.number().int().min(1).max(52),kind:e.enum(["fixed","prepaid","seat"]),tiers:e.strictObject({mode:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().positive().nullable(),unitAmountMinor:i,flatAmountMinor:i.optional()})).min(2).max(12)}).nullable()}),I=e.strictObject({grantId:e.uuid(),couponId:e.uuid(),amountMinor:i,applicationPolicy:G.optional(),applicableProductIds:e.array(o).min(1).max(100).optional(),terms:e.discriminatedUnion("type",[e.strictObject({type:e.literal("percent"),percentOff:e.number().gt(0).max(100)}),e.strictObject({type:e.literal("amount"),amountOffMinor:i,currency:y})]),duration:e.discriminatedUnion("type",[e.strictObject({type:e.literal("once")}),e.strictObject({type:e.literal("forever")}),e.strictObject({type:e.literal("repeating"),months:e.number().int().min(1).max(36)})])}),E={provider:e.literal("merchant"),executor:e.literal("merchant"),operationId:e.uuid(),customerId:e.uuid(),configurationRevision:e.number().int().nonnegative(),connectionRevision:e.number().int().nonnegative(),currency:y,expiresAt:c},ge=e.strictObject({...E,type:e.literal("purchase"),mode:e.enum(["payment","subscription"]),lineItems:e.array(m).min(1).max(100),catalogAmountMinor:i,nativeDiscountMinor:i.optional(),discount:I.nullable(),trialPeriodDays:e.number().int().min(1).max(730).nullable(),automaticTax:e.boolean()}).refine(t=>t.lineItems.reduce((n,r)=>n+r.totalMinor,0)===t.catalogAmountMinor&&(t.discount?.amountMinor??0)+(t.nativeDiscountMinor??0)<=t.catalogAmountMinor&&new Set(t.lineItems.map(n=>n.priceId)).size===t.lineItems.length,"Purchase lines must retain the original total and unique Price identities"),S=e.strictObject({...E,type:e.literal("subscription_change"),subscriptionId:e.uuid(),merchantSubscriptionId:o,membershipId:e.uuid(),subscriptionAction:e.enum(["update","cancel","schedule","release"]),supersedesOperationId:e.uuid().nullable(),change:e.discriminatedUnion("type",[e.strictObject({type:e.literal("cancel")}),e.strictObject({type:e.literal("uncancel")}),e.strictObject({type:e.literal("plan"),productVersionId:e.uuid()}),e.strictObject({type:e.literal("seats"),licenseKey:o,quantity:e.number().int().nonnegative().max(1e6)}),e.strictObject({type:e.literal("quantity"),internal_feature_id:e.uuid(),quantity:e.number().int().nonnegative().max(1e6)}),e.strictObject({type:e.literal("billing_cycle"),billingCycleAnchor:e.union([e.literal("now"),e.number().int().positive()])})]),timing:e.enum(["immediate","renewal"]),effectiveAt:c,creditMinor:i,debitMinor:i,totalMinor:i,discountMinor:i,discount:I.nullable().optional(),taxMinor:i,proration:e.enum(["none","create_prorations","always_invoice"]),lineItems:e.array(m.extend({quantity:e.number().int().nonnegative().max(1e6)})).max(100),removePriceIds:e.array(e.uuid()).max(100),sourceLineItems:e.array(m).min(1).max(100).optional()}),xe=e.strictObject({...E,type:e.literal("refund"),invoiceId:e.uuid(),merchantInvoiceId:o,amountMinor:i.refine(t=>t>0),mode:e.enum(["full","partial"]),entitlementAction:e.enum(["retain","revoke"]),cancelSubscriptions:e.array(o).max(100)}),Y=e.discriminatedUnion("type",[ge,S,xe]);function We(t){let n=new Set;if(t.type==="purchase")n.add(t.mode==="subscription"?"purchase.subscription":"purchase.one_time"),t.lineItems.some(r=>r.kind==="prepaid")&&n.add("purchase.prepaid"),t.lineItems.some(r=>r.kind==="seat")&&n.add("purchase.seats"),t.lineItems.some(r=>r.tiers!==null)&&n.add("purchase.tiered"),t.trialPeriodDays!==null&&n.add("purchase.trial"),t.automaticTax&&n.add("tax.automatic"),t.discount&&n.add(`discount.${t.discount.terms.type}.${t.discount.duration.type}`);else if(t.type==="refund")n.add(`refund.${t.mode}`),t.entitlementAction==="revoke"&&n.add("refund.revoke");else{let r=t.change.type;r==="cancel"?n.add(`subscription.cancel.${t.timing}`):r==="uncancel"?n.add("subscription.resume"):r==="plan"?n.add(`subscription.plan.${t.timing}`):n.add(`subscription.${r}`),t.proration!=="none"&&n.add("subscription.proration"),t.discount&&n.add(`discount.${t.discount.terms.type}.${t.discount.duration.type}`)}return[...n].sort()}function Xe(t){return t.type==="purchase"?t.mode==="subscription"?["purchase.completed","purchase.closed","subscription.observed","invoice.paid"]:["purchase.completed","purchase.closed"]:t.type==="subscription_change"?["subscription.change.completed","subscription.change.closed","subscription.observed",...t.change.type==="cancel"||t.change.type==="uncancel"?[]:["invoice.paid"]]:["refund.updated",...t.entitlementAction==="revoke"&&t.cancelSubscriptions.length?["subscription.observed"]:[]]}var ye=e.strictObject({phase:e.enum(["execution","payment","fulfillment","recording"]),code:L,reason:H.optional(),recovery:F,retryable:e.boolean()}).refine(t=>t.reason!=="RESULT_UNKNOWN"||!t.retryable&&t.recovery==="recover_operation","Unknown financial effects require recovery of the original operation"),Ie=e.strictObject({type:e.literal("redirect"),url:e.url().startsWith("https://"),expiresAt:c}),B={operationId:e.uuid(),customerId:e.uuid(),merchantExecutionId:o,fulfillmentStatus:e.enum(["not_started","pending","applied","failed","not_applicable"]),recordingStatus:e.enum(["not_ready","pending","accepted","failed"]),updatedAt:c,problem:ye.nullable(),pollAfterMs:e.number().int().min(1e3).max(6e4).nullable()},T=e.discriminatedUnion("type",[e.strictObject({...B,type:e.literal("purchase"),merchantOrderId:o.nullable(),paymentStatus:e.enum(["not_started","pending","succeeded","not_required","failed","expired","unknown"]),checkoutUrl:e.url().refine(t=>new URL(t).protocol==="https:").nullable(),checkoutExpiresAt:c.nullable()}).refine(t=>!t.checkoutUrl||["not_started","pending"].includes(t.paymentStatus)&&t.checkoutExpiresAt!==null,"Only an unfinished original purchase may expose its checkout"),e.strictObject({...B,type:e.literal("subscription_change"),status:e.enum(["pending","scheduled","applied","failed","unknown"]),merchantSubscriptionId:o,scheduledFor:c.nullable(),nextAction:Ie.optional()}).refine(t=>t.status==="scheduled"==(t.scheduledFor!==null),"A scheduled change retains its future effective time"),e.strictObject({...B,type:e.literal("refund"),status:e.enum(["pending","succeeded","failed","unknown"]),merchantRefundId:o.nullable()}).refine(t=>t.status!=="succeeded"||t.merchantRefundId!==null,"A successful refund retains its original merchant identity")]),ee=e.discriminatedUnion("lookup",[e.strictObject({lookup:e.literal("found"),operationId:e.uuid(),customerId:e.uuid(),execution:T,readAt:c}),e.strictObject({lookup:e.literal("not_received"),operationId:e.uuid(),customerId:e.uuid(),execution:e.null(),readAt:c})]).refine(t=>!t.execution||t.execution.operationId===t.operationId&&t.execution.customerId===t.customerId,"Lookup must retain the original Customer and operation"),te=e.strictObject({merchantPriceId:o,productId:o,kind:e.enum(["fixed","prepaid"]),currency:y,unitAmountMinor:i,interval:e.enum(["one_off","day","week","month","year"]),intervalCount:e.number().int().min(1).max(100)}),X={merchantItemId:o,quantity:e.number().int().positive().max(1e6)},Se=t=>t.priceId??JSON.stringify(t.nativePrice),k=e.strictObject({merchantSubscriptionId:o,revision:e.number().int().positive(),status:e.enum(["incomplete","trialing","active","past_due","canceled","unpaid","paused","incomplete_expired"]),periodStartsAt:c,periodEndsAt:c,cancelAtPeriodEnd:e.boolean(),hasDiscounts:e.boolean(),items:e.array(e.union([e.strictObject({...X,priceId:e.uuid()}),e.strictObject({...X,nativePrice:te})])).min(1).max(100)}).refine(t=>Date.parse(t.periodEndsAt)>Date.parse(t.periodStartsAt)&&new Set(t.items.map(Se)).size===t.items.length&&new Set(t.items.map(n=>n.merchantItemId)).size===t.items.length,"Subscription periods and Price identities must be unambiguous"),J={merchantLineId:o,quantity:e.number().int().nonnegative().max(1e6),subtotalMinor:e.number().int().min(-1e8).max(1e8),discountMinor:i,taxMinor:i,totalMinor:e.number().int().min(-1e8).max(2e8),periodStartsAt:c.nullable(),periodEndsAt:c.nullable()},R=e.strictObject({merchantInvoiceId:o,reason:e.enum(["renewal","adjustment"]).optional(),currency:y,subtotalMinor:i,discountMinor:i,taxMinor:i,totalMinor:i,paidMinor:i,periodStartsAt:c.nullable(),periodEndsAt:c.nullable(),lines:e.array(e.union([e.strictObject({...J,priceId:e.uuid()}),e.strictObject({...J,nativePrice:te})]).refine(t=>t.subtotalMinor-t.discountMinor+t.taxMinor===t.totalMinor&&(t.subtotalMinor<0?t.discountMinor===0&&t.taxMinor===0:t.discountMinor<=t.subtotalMinor),"Invoice line amounts must retain the complete debit or credit")).min(1).max(100)}).refine(t=>t.subtotalMinor-t.discountMinor+t.taxMinor===t.totalMinor&&t.discountMinor<=t.subtotalMinor&&t.paidMinor===t.totalMinor&&new Set(t.lines.map(n=>n.merchantLineId)).size===t.lines.length&&t.lines.reduce((n,r)=>n+r.subtotalMinor,0)===t.subtotalMinor&&t.lines.reduce((n,r)=>n+r.discountMinor,0)===t.discountMinor&&t.lines.reduce((n,r)=>n+r.taxMinor,0)===t.taxMinor&&t.lines.reduce((n,r)=>n+r.totalMinor,0)===t.totalMinor,"A paid Invoice retains the complete financial amounts"),p={eventId:e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),customerId:e.uuid(),occurredAt:c},Me=e.strictObject({...p,type:e.literal("purchase.completed"),operationId:e.uuid(),merchantOrderId:o,paymentStatus:e.enum(["paid","trialing","no_payment_required"]),invoice:R.refine(t=>t.lines.every(n=>"priceId"in n),"An operation result retains its quoted Price identities").nullable(),subscription:k.refine(t=>t.items.every(n=>"priceId"in n),"An operation result retains its quoted Price identities").nullable()}),_e=e.strictObject({...p,type:e.literal("purchase.closed"),operationId:e.uuid(),status:e.enum(["failed","expired","canceled"])}),Oe=e.strictObject({...p,type:e.literal("subscription.observed"),operationId:e.uuid().nullable(),subscription:k}),ve=e.strictObject({...p,type:e.literal("subscription.change.completed"),operationId:e.uuid(),status:e.enum(["scheduled","applied"]),scheduledFor:c.nullable(),subscription:k.refine(t=>t.items.every(n=>"priceId"in n),"An operation result retains its quoted Price identities"),invoice:R.refine(t=>t.lines.every(n=>"priceId"in n),"An operation result retains its quoted Price identities").nullable()}),Ae=e.strictObject({...p,type:e.literal("subscription.change.closed"),operationId:e.uuid(),merchantSubscriptionId:o,merchantInvoiceId:o.nullable(),status:e.enum(["failed","expired","canceled"])}),je=e.strictObject({...p,type:e.literal("invoice.paid"),merchantSubscriptionId:o.nullable(),invoice:R}),Pe=e.strictObject({...p,type:e.literal("refund.updated"),operationId:e.uuid().nullable(),merchantInvoiceId:o.optional(),merchantRefundId:o,status:e.enum(["pending","succeeded","failed"]),amountMinor:i.refine(t=>t>0),currency:y}),Je=[Me.refine(t=>t.paymentStatus!=="paid"||t.invoice!==null,"A paid purchase includes its Invoice"),_e,Oe.refine(t=>t.operationId===null||t.subscription.items.every(n=>"priceId"in n),"Native Price references cannot replace an operation's quoted Prices"),ve.refine(t=>t.status==="scheduled"==(t.scheduledFor!==null),"Scheduled and applied changes are distinct facts"),Ae,je,Pe.refine(t=>t.operationId!==null||t.merchantInvoiceId!==void 0,"A native refund names its Invoice")];var z=e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}),rt=e.object({...z.shape,featureAllowances:e.record(e.uuid(),e.number().int().min(0).max(1e9)),creditAmounts:e.record(e.uuid(),l)}).strict(),it=e.object({id:e.uuid(),planVersionId:e.uuid(),slot:e.string(),cardRequired:e.boolean(),status:e.enum(["pending","active","converted","canceled","expired","failed"]),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),createdAt:e.iso.datetime()}).strict();var qe=e.number().int().positive().max(2e8),ne=e.number().int().min(0).max(2e8),re=t=>t.mode==="partial"==(t.amountMinor!==void 0),P=e.strictObject({mode:e.enum(["full","partial"]),amountMinor:qe.optional(),entitlementAction:e.enum(["retain","revoke"])});var a=e.string().min(1).max(200),b=e.iso.datetime({offset:!0}),f=ne,ie=f.maxValue,C=e.number().int().min(-ie).max(ie),q=e.string().regex(/^[A-Z]{3}$/),oe=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),ae=e.array(a).max(100).refine(t=>new Set(t).size===t.length),Ce=e.strictObject({merchantProductId:a,merchantPriceId:a,productVersionId:e.uuid().optional(),quantity:l.refine(t=>/[1-9]/.test(t))}),w={subject:Q,operationId:e.uuid(),configurationRevision:oe,connectionRevision:oe,expiresAt:b},D=e.discriminatedUnion("action",[e.strictObject({...w,action:e.literal("purchase"),mode:e.enum(["payment","subscription"]),currency:q,items:e.array(Ce).min(1).max(100),offerRefs:ae}),e.strictObject({...w,action:e.literal("subscription_change"),currency:q,merchantSubscriptionId:a,change:S.shape.change,timing:S.shape.timing,proration:S.shape.proration,offerRefs:ae}),e.strictObject({...w,action:e.literal("refund"),currency:q,merchantInvoiceId:a,mode:P.shape.mode,amountMinor:P.shape.amountMinor,entitlementAction:P.shape.entitlementAction}).refine(re,"Only a partial refund chooses amountMinor")]),ht=e.strictObject({request:D,requestedAt:b,preparationAllowed:e.boolean()}).refine(t=>!t.preparationAllowed||Date.parse(t.requestedAt)<Date.parse(t.request.expiresAt),"Preparation authority must be within its original validity"),Be=e.strictObject({merchantLineId:a,merchantPriceId:a.nullable(),quantity:l.refine(t=>/[1-9]/.test(t)),subtotalMinor:C,discountMinor:f,taxMinor:f.nullable(),totalMinor:C.nullable()}).refine(t=>t.taxMinor===null==(t.totalMinor===null)&&(t.totalMinor===null||t.totalMinor===t.subtotalMinor-t.discountMinor+t.taxMinor),"A quote line retains exact known totals; unknown tax is not zero"),Ee=e.strictObject({items:e.array(e.strictObject({merchantPriceId:a,quantity:l.refine(t=>/[1-9]/.test(t)),interval:m.shape.interval.exclude(["one_off"]),intervalCount:m.shape.intervalCount,amountMinor:m.shape.totalMinor,amountAfterOfferMinor:m.shape.totalMinor.optional()})).min(1).max(100),trial:z.nullable(),discount:I.nullable().optional(),discountExpiresAt:b.nullable().optional(),initialAmountMinor:m.shape.totalMinor.optional()}),ce=e.strictObject({request:D,requestDigest:j,merchantQuoteId:a,quoteTermsDigest:j,termsVersion:a,sourceRevisions:e.array(e.strictObject({reference:a,revision:a})).max(100),observedAt:b,expiresAt:b,currency:q,automaticTax:e.boolean(),lines:e.array(Be).max(100),subscriptionTerms:Ee.nullable(),subtotalMinor:C,discountMinor:f,nativeDiscountMinor:f.optional(),discount:I.nullable().optional(),taxMinor:f.nullable(),totalMinor:C.nullable(),effectiveAt:b.nullable(),expectedEffects:e.array(e.strictObject({reference:a,kind:e.enum(["grant","revoke","change"]),description:e.string().min(1).max(1e3),quantity:l.nullable(),unit:a.nullable()}).refine(t=>t.quantity===null==(t.unit===null),"Quantified effects name their native unit")).max(100),requiredConsents:e.array(e.strictObject({reference:a,version:a,summary:e.string().min(1).max(1e3)})).max(20)}),U=ce.superRefine((t,n)=>{let{quoteTermsDigest:r,...u}=t,h=t.lines.every(s=>s.taxMinor!==null),A=t.request.action==="purchase"&&t.request.mode==="subscription"!=(t.subscriptionTerms!==null),be=t.subscriptionTerms!==null&&(t.request.action==="refund"||t.request.action==="subscription_change"&&t.request.change.type==="cancel");(t.requestDigest!==x(t.request)||t.quoteTermsDigest!==x(u)||t.currency!==t.request.currency||A||be||t.lines.length===0&&(t.request.action!=="subscription_change"||t.subtotalMinor!==0||t.discountMinor!==0||t.taxMinor!==0||t.totalMinor!==0)||Date.parse(t.observedAt)>=Date.parse(t.expiresAt)||Date.parse(t.expiresAt)>Date.parse(t.request.expiresAt)||new Set(t.lines.map(s=>s.merchantLineId)).size!==t.lines.length||new Set(t.sourceRevisions.map(s=>s.reference)).size!==t.sourceRevisions.length||new Set(t.requiredConsents.map(s=>s.reference)).size!==t.requiredConsents.length||t.subtotalMinor!==t.lines.reduce((s,g)=>s+g.subtotalMinor,0)||t.discountMinor!==t.lines.reduce((s,g)=>s+g.discountMinor,0)||t.taxMinor!==null!==h||!h&&!t.automaticTax||t.taxMinor===null!=(t.totalMinor===null)||h&&(t.taxMinor!==t.lines.reduce((s,g)=>s+g.taxMinor,0)||t.totalMinor!==t.subtotalMinor-t.discountMinor+t.taxMinor)||t.request.action!=="subscription_change"&&(t.subtotalMinor<0||t.totalMinor!==null&&t.totalMinor<0)||t.request.action==="refund"&&(t.taxMinor===null||t.totalMinor===null||t.totalMinor<=0||t.request.mode==="partial"&&t.totalMinor!==t.request.amountMinor))&&n.addIssue({code:"custom",message:"Merchant terms must retain the original selection, scope, validity, digest and totals"})});function bt(t,n,r,u){return t.request.operationId===n&&t.request.action===r&&t.currency===u}function ft(t){return x(D.parse(t))}function gt(t){return x(ce.omit({quoteTermsDigest:!0}).parse(t))}var Te=e.strictObject({quoteTermsDigest:j,consents:e.array(e.strictObject({reference:a,version:a})).max(20)});function xt(t){return{quoteTermsDigest:t.quoteTermsDigest,consents:t.requiredConsents.map(({reference:n,version:r})=>({reference:n,version:r}))}}var ke=Te.extend({operationId:e.uuid()}).refine(t=>new Set(t.consents.map(n=>n.reference)).size===t.consents.length);function yt(t,n){let r=U.parse(t),u=ke.parse(n);return u.operationId===r.request.operationId&&u.quoteTermsDigest===r.quoteTermsDigest&&u.consents.length===r.requiredConsents.length&&r.requiredConsents.every(h=>u.consents.some(A=>A.reference===h.reference&&A.version===h.version))}var M=3,Ot="/integrations/indiana",vt="X-Indiana-Merchant-Bridge-Version",Re=["session","catalog","customer_commerce","presentation","presentation_events","purchases","operation_status","billing_records","subscription_changes","refunds"],ze=e.enum(Re),At={session:{command:"session.create",authority:"merchant_user"},catalog:{command:"catalog.read",authority:"merchant_catalog_reader"},customer_commerce:{command:"customer.commerce.read",authority:"merchant_user"},presentation:{command:"presentation.resolve",authority:"merchant_user"},presentation_events:{command:"presentation.report",authority:"merchant_user"},purchases:{command:"purchase.execute",authority:"merchant_user"},operation_status:{command:"operation.read",authority:"merchant_user"},billing_records:{command:null,authority:"indiana_server_key"},subscription_changes:{command:"subscription.change",authority:"merchant_user"},refunds:{command:"refund.execute",authority:"merchant_refund_authority"}},$=e.enum(["bridge.ping","bridge.describe","session.create","catalog.read","customer.commerce.read","presentation.resolve","presentation.report","purchase.execute","operation.read","subscription.change","refund.execute"]),ue=e.string().regex(/^[A-Za-z0-9_-]{1,64}$/),we=e.string().regex(/^[A-Za-z0-9_-]{43}$/).refine(t=>"AEIMQUYcgkosw048".includes(t.at(-1)),"Use canonical base64url for a 32-byte key"),De=e.strictObject({keyId:ue,signingSecret:we}),Ue=e.string().max(300).superRefine((t,n)=>{try{let r=new URL(t);if(r.protocol!=="https:"||r.username||r.password||r.search||r.hash||r.pathname!=="/"||r.port&&r.port!=="443"||!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,63}$/.test(r.hostname)||/(?:^|\.)(?:localhost|local|internal)$/.test(r.hostname))throw new Error("invalid origin")}catch{n.addIssue({code:"custom",message:"Use an exact public HTTPS origin"})}}).transform(t=>new URL(t).origin),me=e.array(ze).max(10).refine(t=>new Set(t).size===t.length,"Capabilities must be unique"),V=e.strictObject({bridgeVersion:e.literal(M),projectId:e.uuid(),environmentId:e.uuid(),environment:e.enum(["sandbox","live"]),capabilities:me,catalog:e.enum(["endpoint","static","none"]),billingEvents:e.array(W).max(7),profiles:e.array(K).max(32).refine(t=>new Set(t).size===t.length,"Profiles must be unique")}).superRefine((t,n)=>{let r=u=>t.capabilities.includes(u);r("catalog")!==(t.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(r("billing_records")!==t.billingEvents.length>0||new Set(t.billingEvents).size!==t.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare the unique supported billing events"})}),de=e.strictObject({origin:Ue,requiredCapabilities:me}),$e=e.strictObject({revision:e.number().int().nonnegative(),checkedAt:e.iso.datetime(),outcome:e.enum(["valid","unreachable","invalid","scope_mismatch","authentication_failed","credentials_missing"]),diagnostics:e.strictObject({ping:e.enum(["passed","failed","not_checked"]),authentication:e.enum(["passed","failed","not_checked"]),catalog:e.enum(["passed","failed","not_checked","static","unsupported"])}),manifest:V.nullable()}).superRefine((t,n)=>{t.outcome==="valid"!=(t.manifest!==null)&&n.addIssue({code:"custom",path:["manifest"],message:"Only a valid declaration carries a manifest"})}),jt=e.strictObject({projectId:e.uuid(),environmentId:e.uuid(),environment:e.enum(["sandbox","live"]),execution:e.enum(["indiana","record_only"]),accountId:e.string().nullable(),revision:e.number().int().nonnegative(),authentication:e.strictObject({keyId:ue}).nullable(),secretStoreConfigured:e.boolean().optional(),connection:de.nullable(),check:$e.nullable()});var se=e.strictObject({projectId:e.uuid(),environmentId:e.uuid()}),Pt=e.discriminatedUnion("action",[se.extend({action:e.literal("save"),revision:e.number().int().nonnegative(),connection:de,authentication:De.optional()}),se.extend({action:e.literal("check"),revision:e.number().int().nonnegative()})]),_=e.strictObject({projectId:e.uuid(),environmentId:e.uuid(),environment:e.enum(["sandbox","live"])});function qt(t){return e.strictObject({bridgeVersion:e.literal(M),requestId:e.uuid(),command:$,scope:_,data:t})}var le=e.strictObject({nativeUserId:e.string().min(1).max(128),session:Z.strict()}),pe=e.strictObject({nativeUserId:e.string().min(1).max(128),presentation:e.strictObject({customerId:e.uuid(),decisionId:e.uuid(),offeringVersionId:e.uuid(),paywallVersionId:e.uuid(),variant:e.string().min(1).max(128)}).nullable()}),he=e.strictObject({decisionId:e.uuid(),eventId:e.uuid()}),O=e.strictObject({operationId:e.uuid(),customerId:e.uuid()}),Ct=e.strictObject({bridgeVersion:e.literal(M),requestId:e.uuid(),command:e.string().min(1).max(64),scope:_,error:e.strictObject({code:e.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:e.string().min(1).max(500),retryable:e.boolean(),recovery:e.string().min(1).max(80)})});var zt=e.strictObject({scope:_,operationId:e.uuid(),customerId:e.uuid(),confirmedAt:e.iso.datetime({offset:!0}).nullable(),initialExecutionAllowed:e.boolean(),instruction:Y,merchantTerms:U.optional()}).refine(t=>t.operationId===t.instruction.operationId&&t.customerId===t.instruction.customerId&&(!t.merchantTerms||t.merchantTerms.request.operationId===t.operationId&&t.merchantTerms.request.subject.customerId===t.customerId&&t.merchantTerms.request.action===t.instruction.type&&t.merchantTerms.currency===t.instruction.currency&&Object.entries(t.scope).every(([n,r])=>t.merchantTerms.request.subject.scope[n]===r)),"Authority must refer to the original Customer and operation"),N=T,d=e.string().min(1).max(120),Ve=e.string().regex(/^-?[0-9]+(?:\.[0-9]{1,6})?$/),Ne=e.strictObject({revision:d,updatedAt:e.iso.datetime(),provider:e.literal("merchant"),items:e.array(e.strictObject({merchantProductId:d,productVersionId:e.uuid(),name:e.string().min(1).max(255),kind:e.enum(["subscription","credit_pack"]),merchantPriceId:d,currency:e.string().regex(/^[a-z]{3}$/),amountMinor:e.number().int().nonnegative().max(1e8),interval:e.enum(["one_time","month","year"]),intervalCount:e.literal(1),includedCredits:e.string().regex(/^[0-9]{1,18}(?:\.[0-9]{1,6})?$/),creditReset:e.enum(["none","month"]),creditPolicyId:d,available:e.boolean()}).superRefine((t,n)=>{(t.kind==="credit_pack"&&(t.interval!=="one_time"||t.creditReset!=="none")||t.kind==="subscription"&&t.interval==="one_time"||t.available&&t.amountMinor===0)&&n.addIssue({code:"custom",message:"Unsupported version 1 catalog terms"})})).max(500)}),Le=e.strictObject({customerId:e.uuid(),revision:e.string().min(1).max(128),observedAt:e.iso.datetime(),subscriptions:e.array(e.strictObject({merchantSubscriptionId:d,merchantProductId:d,productVersionId:e.uuid().nullable(),status:e.enum(["active","trialing","past_due","cancelled","expired"]),currentPeriodStartsAt:e.iso.datetime().nullable(),currentPeriodEndsAt:e.iso.datetime().nullable(),cancelAtPeriodEnd:e.boolean(),scheduledChange:e.strictObject({effectiveAt:e.iso.datetime(),merchantProductId:d}).nullable()})).max(100),purchaseHistory:e.strictObject({complete:e.boolean(),hasPaidPurchase:e.boolean(),lastPaidAt:e.iso.datetime().nullable()}),balances:e.array(e.strictObject({bucketId:d,key:d,available:Ve,expiresAt:e.iso.datetime().nullable(),nextResetAt:e.iso.datetime().nullable()})).max(100)}),v=e.strictObject({}),Fe={"bridge.ping":e.strictObject({challenge:e.uuid()}),"bridge.describe":v,"session.create":v,"catalog.read":v,"customer.commerce.read":v,"presentation.resolve":v,"presentation.report":he,"purchase.execute":O,"operation.read":O,"subscription.change":O,"refund.execute":O},wt={"bridge.ping":e.strictObject({challenge:e.uuid()}),"bridge.describe":V,"session.create":le,"catalog.read":Ne,"customer.commerce.read":Le,"presentation.resolve":pe,"presentation.report":e.strictObject({queued:e.literal(!0)}),"purchase.execute":N,"operation.read":ee,"subscription.change":N,"refund.execute":N},Dt=e.strictObject({bridgeVersion:e.literal(M),requestId:e.uuid(),scope:_,command:$,data:e.unknown()}).superRefine((t,n)=>{Fe[t.command].safeParse(t.data).success||n.addIssue({code:"custom",path:["data"],message:"Invalid command data"})});export{ge as a,S as b,xe as c,We as d,Xe as e,ye as f,T as g,ee as h,p as i,Je as j,z as k,qe as l,ne as m,re as n,P as o,ht as p,U as q,bt as r,ft as s,gt as t,Te as u,xt as v,yt as w,M as x,Ot as y,vt as z,Re as A,At as B,De as C,Ue as D,V as E,_ as F,qt as G,le as H,pe as I,he as J,O as K,Ct as L,zt as M,N,Le as O,Fe as P,wt as Q,Dt as R};
1
+ import{a as G}from"./chunk-3GT4A3TA.js";import{b as Z}from"./chunk-TLGKBSXC.js";import{a as j,b as Q,c as x}from"./chunk-HZYCK4XJ.js";import{a as L,b as F,c as H,j as l}from"./chunk-VC2H3LFP.js";import{b as e}from"./chunk-7GD2UTBU.js";var fe=["purchase.subscription","purchase.one_time","purchase.prepaid","purchase.trial","purchase.seats","purchase.tiered","tax.automatic","discount.percent.once","discount.percent.repeating","discount.percent.forever","discount.amount.once","discount.amount.repeating","discount.amount.forever","subscription.cancel.immediate","subscription.cancel.renewal","subscription.resume","subscription.plan.immediate","subscription.plan.renewal","subscription.seats","subscription.quantity","subscription.billing_cycle","subscription.proration","refund.full","refund.partial","refund.revoke"],K=e.enum(fe),W=e.enum(["purchase.completed","purchase.closed","subscription.observed","subscription.change.completed","subscription.change.closed","invoice.paid","refund.updated"]);var o=e.string().min(1).max(200),c=e.iso.datetime({offset:!0}),i=e.number().int().nonnegative().max(1e8),y=e.string().regex(/^[A-Z]{3}$/),m=e.strictObject({priceId:e.uuid(),productVersionId:e.uuid(),productId:o,quantity:e.number().int().min(1).max(1e6),unitAmountMinor:i,totalMinor:i,interval:e.enum(["week","month","year","one_off"]),intervalCount:e.number().int().min(1).max(52),kind:e.enum(["fixed","prepaid","seat"]),tiers:e.strictObject({mode:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().positive().nullable(),unitAmountMinor:i,flatAmountMinor:i.optional()})).min(2).max(12)}).nullable()}),I=e.strictObject({grantId:e.uuid(),couponId:e.uuid(),amountMinor:i,applicationPolicy:G.optional(),applicableProductIds:e.array(o).min(1).max(100).optional(),terms:e.discriminatedUnion("type",[e.strictObject({type:e.literal("percent"),percentOff:e.number().gt(0).max(100)}),e.strictObject({type:e.literal("amount"),amountOffMinor:i,currency:y})]),duration:e.discriminatedUnion("type",[e.strictObject({type:e.literal("once")}),e.strictObject({type:e.literal("forever")}),e.strictObject({type:e.literal("repeating"),months:e.number().int().min(1).max(36)})])}),E={provider:e.literal("merchant"),executor:e.literal("merchant"),operationId:e.uuid(),customerId:e.uuid(),configurationRevision:e.number().int().nonnegative(),connectionRevision:e.number().int().nonnegative(),currency:y,expiresAt:c},ge=e.strictObject({...E,type:e.literal("purchase"),mode:e.enum(["payment","subscription"]),lineItems:e.array(m).min(1).max(100),catalogAmountMinor:i,nativeDiscountMinor:i.optional(),discount:I.nullable(),trialPeriodDays:e.number().int().min(1).max(730).nullable(),automaticTax:e.boolean()}).refine(t=>t.lineItems.reduce((n,r)=>n+r.totalMinor,0)===t.catalogAmountMinor&&(t.discount?.amountMinor??0)+(t.nativeDiscountMinor??0)<=t.catalogAmountMinor&&new Set(t.lineItems.map(n=>n.priceId)).size===t.lineItems.length,"Purchase lines must retain the original total and unique Price identities"),S=e.strictObject({...E,type:e.literal("subscription_change"),subscriptionId:e.uuid(),merchantSubscriptionId:o,membershipId:e.uuid(),subscriptionAction:e.enum(["update","cancel","schedule","release"]),supersedesOperationId:e.uuid().nullable(),change:e.discriminatedUnion("type",[e.strictObject({type:e.literal("cancel")}),e.strictObject({type:e.literal("uncancel")}),e.strictObject({type:e.literal("plan"),productVersionId:e.uuid()}),e.strictObject({type:e.literal("seats"),licenseKey:o,quantity:e.number().int().nonnegative().max(1e6)}),e.strictObject({type:e.literal("quantity"),internal_feature_id:e.uuid(),quantity:e.number().int().nonnegative().max(1e6)}),e.strictObject({type:e.literal("billing_cycle"),billingCycleAnchor:e.union([e.literal("now"),e.number().int().positive()])})]),timing:e.enum(["immediate","renewal"]),effectiveAt:c,creditMinor:i,debitMinor:i,totalMinor:i,discountMinor:i,discount:I.nullable().optional(),taxMinor:i,proration:e.enum(["none","create_prorations","always_invoice"]),lineItems:e.array(m.extend({quantity:e.number().int().nonnegative().max(1e6)})).max(100),removePriceIds:e.array(e.uuid()).max(100),sourceLineItems:e.array(m).min(1).max(100).optional()}),xe=e.strictObject({...E,type:e.literal("refund"),invoiceId:e.uuid(),merchantInvoiceId:o,amountMinor:i.refine(t=>t>0),mode:e.enum(["full","partial"]),entitlementAction:e.enum(["retain","revoke"]),cancelSubscriptions:e.array(o).max(100)}),Y=e.discriminatedUnion("type",[ge,S,xe]);function We(t){let n=new Set;if(t.type==="purchase")n.add(t.mode==="subscription"?"purchase.subscription":"purchase.one_time"),t.lineItems.some(r=>r.kind==="prepaid")&&n.add("purchase.prepaid"),t.lineItems.some(r=>r.kind==="seat")&&n.add("purchase.seats"),t.lineItems.some(r=>r.tiers!==null)&&n.add("purchase.tiered"),t.trialPeriodDays!==null&&n.add("purchase.trial"),t.automaticTax&&n.add("tax.automatic"),t.discount&&n.add(`discount.${t.discount.terms.type}.${t.discount.duration.type}`);else if(t.type==="refund")n.add(`refund.${t.mode}`),t.entitlementAction==="revoke"&&n.add("refund.revoke");else{let r=t.change.type;r==="cancel"?n.add(`subscription.cancel.${t.timing}`):r==="uncancel"?n.add("subscription.resume"):r==="plan"?n.add(`subscription.plan.${t.timing}`):n.add(`subscription.${r}`),t.proration!=="none"&&n.add("subscription.proration"),t.discount&&n.add(`discount.${t.discount.terms.type}.${t.discount.duration.type}`)}return[...n].sort()}function Xe(t){return t.type==="purchase"?t.mode==="subscription"?["purchase.completed","purchase.closed","subscription.observed","invoice.paid"]:["purchase.completed","purchase.closed"]:t.type==="subscription_change"?["subscription.change.completed","subscription.change.closed","subscription.observed",...t.change.type==="cancel"||t.change.type==="uncancel"?[]:["invoice.paid"]]:["refund.updated",...t.entitlementAction==="revoke"&&t.cancelSubscriptions.length?["subscription.observed"]:[]]}var ye=e.strictObject({phase:e.enum(["execution","payment","fulfillment","recording"]),code:L,reason:H.optional(),recovery:F,retryable:e.boolean()}).refine(t=>t.reason!=="RESULT_UNKNOWN"||!t.retryable&&t.recovery==="recover_operation","Unknown financial effects require recovery of the original operation"),Ie=e.strictObject({type:e.literal("redirect"),url:e.url().startsWith("https://"),expiresAt:c}),B={operationId:e.uuid(),customerId:e.uuid(),merchantExecutionId:o,fulfillmentStatus:e.enum(["not_started","pending","applied","failed","not_applicable"]),recordingStatus:e.enum(["not_ready","pending","accepted","failed"]),updatedAt:c,problem:ye.nullable(),pollAfterMs:e.number().int().min(1e3).max(6e4).nullable()},T=e.discriminatedUnion("type",[e.strictObject({...B,type:e.literal("purchase"),merchantOrderId:o.nullable(),paymentStatus:e.enum(["not_started","pending","succeeded","not_required","failed","expired","unknown"]),checkoutUrl:e.url().refine(t=>new URL(t).protocol==="https:").nullable(),checkoutExpiresAt:c.nullable()}).refine(t=>!t.checkoutUrl||["not_started","pending"].includes(t.paymentStatus)&&t.checkoutExpiresAt!==null,"Only an unfinished original purchase may expose its checkout"),e.strictObject({...B,type:e.literal("subscription_change"),status:e.enum(["pending","scheduled","applied","failed","unknown"]),merchantSubscriptionId:o,scheduledFor:c.nullable(),nextAction:Ie.optional()}).refine(t=>t.status==="scheduled"==(t.scheduledFor!==null),"A scheduled change retains its future effective time"),e.strictObject({...B,type:e.literal("refund"),status:e.enum(["pending","succeeded","failed","unknown"]),merchantRefundId:o.nullable()}).refine(t=>t.status!=="succeeded"||t.merchantRefundId!==null,"A successful refund retains its original merchant identity")]),ee=e.discriminatedUnion("lookup",[e.strictObject({lookup:e.literal("found"),operationId:e.uuid(),customerId:e.uuid(),execution:T,readAt:c}),e.strictObject({lookup:e.literal("not_received"),operationId:e.uuid(),customerId:e.uuid(),execution:e.null(),readAt:c})]).refine(t=>!t.execution||t.execution.operationId===t.operationId&&t.execution.customerId===t.customerId,"Lookup must retain the original Customer and operation"),te=e.strictObject({merchantPriceId:o,productId:o,kind:e.enum(["fixed","prepaid"]),currency:y,unitAmountMinor:i,interval:e.enum(["one_off","day","week","month","year"]),intervalCount:e.number().int().min(1).max(100)}),X={merchantItemId:o,quantity:e.number().int().positive().max(1e6)},Se=t=>t.priceId??JSON.stringify(t.nativePrice),k=e.strictObject({merchantSubscriptionId:o,revision:e.number().int().positive(),status:e.enum(["incomplete","trialing","active","past_due","canceled","unpaid","paused","incomplete_expired"]),periodStartsAt:c,periodEndsAt:c,cancelAtPeriodEnd:e.boolean(),hasDiscounts:e.boolean(),items:e.array(e.union([e.strictObject({...X,priceId:e.uuid()}),e.strictObject({...X,nativePrice:te})])).min(1).max(100)}).refine(t=>Date.parse(t.periodEndsAt)>Date.parse(t.periodStartsAt)&&new Set(t.items.map(Se)).size===t.items.length&&new Set(t.items.map(n=>n.merchantItemId)).size===t.items.length,"Subscription periods and Price identities must be unambiguous"),J={merchantLineId:o,quantity:e.number().int().nonnegative().max(1e6),subtotalMinor:e.number().int().min(-1e8).max(1e8),discountMinor:i,taxMinor:i,totalMinor:e.number().int().min(-1e8).max(2e8),periodStartsAt:c.nullable(),periodEndsAt:c.nullable()},R=e.strictObject({merchantInvoiceId:o,reason:e.enum(["renewal","adjustment"]).optional(),currency:y,subtotalMinor:i,discountMinor:i,taxMinor:i,totalMinor:i,paidMinor:i,periodStartsAt:c.nullable(),periodEndsAt:c.nullable(),lines:e.array(e.union([e.strictObject({...J,priceId:e.uuid()}),e.strictObject({...J,nativePrice:te})]).refine(t=>t.subtotalMinor-t.discountMinor+t.taxMinor===t.totalMinor&&(t.subtotalMinor<0?t.discountMinor===0&&t.taxMinor===0:t.discountMinor<=t.subtotalMinor),"Invoice line amounts must retain the complete debit or credit")).min(1).max(100)}).refine(t=>t.subtotalMinor-t.discountMinor+t.taxMinor===t.totalMinor&&t.discountMinor<=t.subtotalMinor&&t.paidMinor===t.totalMinor&&new Set(t.lines.map(n=>n.merchantLineId)).size===t.lines.length&&t.lines.reduce((n,r)=>n+r.subtotalMinor,0)===t.subtotalMinor&&t.lines.reduce((n,r)=>n+r.discountMinor,0)===t.discountMinor&&t.lines.reduce((n,r)=>n+r.taxMinor,0)===t.taxMinor&&t.lines.reduce((n,r)=>n+r.totalMinor,0)===t.totalMinor,"A paid Invoice retains the complete financial amounts"),p={eventId:e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),customerId:e.uuid(),occurredAt:c},Me=e.strictObject({...p,type:e.literal("purchase.completed"),operationId:e.uuid(),merchantOrderId:o,paymentStatus:e.enum(["paid","trialing","no_payment_required"]),invoice:R.refine(t=>t.lines.every(n=>"priceId"in n),"An operation result retains its quoted Price identities").nullable(),subscription:k.refine(t=>t.items.every(n=>"priceId"in n),"An operation result retains its quoted Price identities").nullable()}),_e=e.strictObject({...p,type:e.literal("purchase.closed"),operationId:e.uuid(),status:e.enum(["failed","expired","canceled"])}),Oe=e.strictObject({...p,type:e.literal("subscription.observed"),operationId:e.uuid().nullable(),subscription:k}),ve=e.strictObject({...p,type:e.literal("subscription.change.completed"),operationId:e.uuid(),status:e.enum(["scheduled","applied"]),scheduledFor:c.nullable(),subscription:k.refine(t=>t.items.every(n=>"priceId"in n),"An operation result retains its quoted Price identities"),invoice:R.refine(t=>t.lines.every(n=>"priceId"in n),"An operation result retains its quoted Price identities").nullable()}),Ae=e.strictObject({...p,type:e.literal("subscription.change.closed"),operationId:e.uuid(),merchantSubscriptionId:o,merchantInvoiceId:o.nullable(),status:e.enum(["failed","expired","canceled"])}),je=e.strictObject({...p,type:e.literal("invoice.paid"),merchantSubscriptionId:o.nullable(),invoice:R}),Pe=e.strictObject({...p,type:e.literal("refund.updated"),operationId:e.uuid().nullable(),merchantInvoiceId:o.optional(),merchantRefundId:o,status:e.enum(["pending","succeeded","failed"]),amountMinor:i.refine(t=>t>0),currency:y}),Je=[Me.refine(t=>t.paymentStatus!=="paid"||t.invoice!==null,"A paid purchase includes its Invoice"),_e,Oe.refine(t=>t.operationId===null||t.subscription.items.every(n=>"priceId"in n),"Native Price references cannot replace an operation's quoted Prices"),ve.refine(t=>t.status==="scheduled"==(t.scheduledFor!==null),"Scheduled and applied changes are distinct facts"),Ae,je,Pe.refine(t=>t.operationId!==null||t.merchantInvoiceId!==void 0,"A native refund names its Invoice")];var z=e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}),rt=e.object({...z.shape,featureAllowances:e.record(e.uuid(),e.number().int().min(0).max(1e9)),creditAmounts:e.record(e.uuid(),l)}).strict(),it=e.object({id:e.uuid(),planVersionId:e.uuid(),slot:e.string(),cardRequired:e.boolean(),status:e.enum(["pending","active","converted","canceled","expired","failed"]),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),createdAt:e.iso.datetime()}).strict();var qe=e.number().int().positive().max(2e8),ne=e.number().int().min(0).max(2e8),re=t=>t.mode==="partial"==(t.amountMinor!==void 0),P=e.strictObject({mode:e.enum(["full","partial"]),amountMinor:qe.optional(),entitlementAction:e.enum(["retain","revoke"])});var a=e.string().min(1).max(200),b=e.iso.datetime({offset:!0}),f=ne,ie=f.maxValue,C=e.number().int().min(-ie).max(ie),q=e.string().regex(/^[A-Z]{3}$/),oe=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),ae=e.array(a).max(100).refine(t=>new Set(t).size===t.length),Ce=e.strictObject({merchantProductId:a,merchantPriceId:a,productVersionId:e.uuid().optional(),quantity:l.refine(t=>/[1-9]/.test(t))}),w={subject:Q,operationId:e.uuid(),configurationRevision:oe,connectionRevision:oe,expiresAt:b},D=e.discriminatedUnion("action",[e.strictObject({...w,action:e.literal("purchase"),mode:e.enum(["payment","subscription"]),currency:q,items:e.array(Ce).min(1).max(100),offerRefs:ae}),e.strictObject({...w,action:e.literal("subscription_change"),currency:q,merchantSubscriptionId:a,change:S.shape.change,timing:S.shape.timing,proration:S.shape.proration,offerRefs:ae}),e.strictObject({...w,action:e.literal("refund"),currency:q,merchantInvoiceId:a,mode:P.shape.mode,amountMinor:P.shape.amountMinor,entitlementAction:P.shape.entitlementAction}).refine(re,"Only a partial refund chooses amountMinor")]),ht=e.strictObject({request:D,requestedAt:b,preparationAllowed:e.boolean()}).refine(t=>!t.preparationAllowed||Date.parse(t.requestedAt)<Date.parse(t.request.expiresAt),"Preparation authority must be within its original validity"),Be=e.strictObject({merchantLineId:a,merchantPriceId:a.nullable(),quantity:l.refine(t=>/[1-9]/.test(t)),subtotalMinor:C,discountMinor:f,taxMinor:f.nullable(),totalMinor:C.nullable()}).refine(t=>t.taxMinor===null==(t.totalMinor===null)&&(t.totalMinor===null||t.totalMinor===t.subtotalMinor-t.discountMinor+t.taxMinor),"A quote line retains exact known totals; unknown tax is not zero"),Ee=e.strictObject({items:e.array(e.strictObject({merchantPriceId:a,quantity:l.refine(t=>/[1-9]/.test(t)),interval:m.shape.interval.exclude(["one_off"]),intervalCount:m.shape.intervalCount,amountMinor:m.shape.totalMinor,amountAfterOfferMinor:m.shape.totalMinor.optional()})).min(1).max(100),trial:z.nullable(),discount:I.nullable().optional(),discountExpiresAt:b.nullable().optional(),initialAmountMinor:m.shape.totalMinor.optional()}),ce=e.strictObject({request:D,requestDigest:j,merchantQuoteId:a,quoteTermsDigest:j,termsVersion:a,sourceRevisions:e.array(e.strictObject({reference:a,revision:a})).max(100),observedAt:b,expiresAt:b,currency:q,automaticTax:e.boolean(),lines:e.array(Be).max(100),subscriptionTerms:Ee.nullable(),subtotalMinor:C,discountMinor:f,nativeDiscountMinor:f.optional(),discount:I.nullable().optional(),taxMinor:f.nullable(),totalMinor:C.nullable(),effectiveAt:b.nullable(),expectedEffects:e.array(e.strictObject({reference:a,kind:e.enum(["grant","revoke","change"]),description:e.string().min(1).max(1e3),quantity:l.nullable(),unit:a.nullable()}).refine(t=>t.quantity===null==(t.unit===null),"Quantified effects name their native unit")).max(100),requiredConsents:e.array(e.strictObject({reference:a,version:a,summary:e.string().min(1).max(1e3)})).max(20)}),U=ce.superRefine((t,n)=>{let{quoteTermsDigest:r,...u}=t,h=t.lines.every(s=>s.taxMinor!==null),A=t.request.action==="purchase"&&t.request.mode==="subscription"!=(t.subscriptionTerms!==null),be=t.subscriptionTerms!==null&&(t.request.action==="refund"||t.request.action==="subscription_change"&&t.request.change.type==="cancel");(t.requestDigest!==x(t.request)||t.quoteTermsDigest!==x(u)||t.currency!==t.request.currency||A||be||t.lines.length===0&&(t.request.action!=="subscription_change"||t.subtotalMinor!==0||t.discountMinor!==0||t.taxMinor!==0||t.totalMinor!==0)||Date.parse(t.observedAt)>=Date.parse(t.expiresAt)||Date.parse(t.expiresAt)>Date.parse(t.request.expiresAt)||new Set(t.lines.map(s=>s.merchantLineId)).size!==t.lines.length||new Set(t.sourceRevisions.map(s=>s.reference)).size!==t.sourceRevisions.length||new Set(t.requiredConsents.map(s=>s.reference)).size!==t.requiredConsents.length||t.subtotalMinor!==t.lines.reduce((s,g)=>s+g.subtotalMinor,0)||t.discountMinor!==t.lines.reduce((s,g)=>s+g.discountMinor,0)||t.taxMinor!==null!==h||!h&&!t.automaticTax||t.taxMinor===null!=(t.totalMinor===null)||h&&(t.taxMinor!==t.lines.reduce((s,g)=>s+g.taxMinor,0)||t.totalMinor!==t.subtotalMinor-t.discountMinor+t.taxMinor)||t.request.action!=="subscription_change"&&(t.subtotalMinor<0||t.totalMinor!==null&&t.totalMinor<0)||t.request.action==="refund"&&(t.taxMinor===null||t.totalMinor===null||t.totalMinor<=0||t.request.mode==="partial"&&t.totalMinor!==t.request.amountMinor))&&n.addIssue({code:"custom",message:"Merchant terms must retain the original selection, scope, validity, digest and totals"})});function bt(t,n,r,u){return t.request.operationId===n&&t.request.action===r&&t.currency===u}function ft(t){return x(D.parse(t))}function gt(t){return x(ce.omit({quoteTermsDigest:!0}).parse(t))}var Te=e.strictObject({quoteTermsDigest:j,consents:e.array(e.strictObject({reference:a,version:a})).max(20)});function xt(t){return{quoteTermsDigest:t.quoteTermsDigest,consents:t.requiredConsents.map(({reference:n,version:r})=>({reference:n,version:r}))}}var ke=Te.extend({operationId:e.uuid()}).refine(t=>new Set(t.consents.map(n=>n.reference)).size===t.consents.length);function yt(t,n){let r=U.parse(t),u=ke.parse(n);return u.operationId===r.request.operationId&&u.quoteTermsDigest===r.quoteTermsDigest&&u.consents.length===r.requiredConsents.length&&r.requiredConsents.every(h=>u.consents.some(A=>A.reference===h.reference&&A.version===h.version))}var M=3,Ot="/integrations/indiana",vt="X-Indiana-Merchant-Bridge-Version",Re=["session","catalog","customer_commerce","presentation","presentation_events","purchases","operation_status","billing_records","subscription_changes","refunds"],ze=e.enum(Re),At={session:{command:"session.create",authority:"merchant_user"},catalog:{command:"catalog.read",authority:"merchant_catalog_reader"},customer_commerce:{command:"customer.commerce.read",authority:"merchant_user"},presentation:{command:"presentation.resolve",authority:"merchant_user"},presentation_events:{command:"presentation.report",authority:"merchant_user"},purchases:{command:"purchase.execute",authority:"merchant_user"},operation_status:{command:"operation.read",authority:"merchant_user"},billing_records:{command:null,authority:"indiana_server_key"},subscription_changes:{command:"subscription.change",authority:"merchant_user"},refunds:{command:"refund.execute",authority:"merchant_refund_authority"}},$=e.enum(["bridge.ping","bridge.describe","session.create","catalog.read","customer.commerce.read","presentation.resolve","presentation.report","purchase.execute","operation.read","subscription.change","refund.execute"]),ue=e.string().regex(/^[A-Za-z0-9_-]{1,64}$/),we=e.string().regex(/^[A-Za-z0-9_-]{43}$/).refine(t=>"AEIMQUYcgkosw048".includes(t.at(-1)),"Use canonical base64url for a 32-byte key"),De=e.strictObject({keyId:ue,signingSecret:we}),Ue=e.string().max(300).superRefine((t,n)=>{try{let r=new URL(t);if(r.protocol!=="https:"||r.username||r.password||r.search||r.hash||r.pathname!=="/"||r.port&&r.port!=="443"||!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,63}$/.test(r.hostname)||/(?:^|\.)(?:localhost|local|internal)$/.test(r.hostname))throw new Error("invalid origin")}catch{n.addIssue({code:"custom",message:"Use an exact public HTTPS origin"})}}).transform(t=>new URL(t).origin),me=e.array(ze).max(10).refine(t=>new Set(t).size===t.length,"Capabilities must be unique"),V=e.strictObject({bridgeVersion:e.literal(M),projectId:e.uuid(),environmentId:e.uuid(),environment:e.enum(["sandbox","live"]),capabilities:me,catalog:e.enum(["endpoint","static","none"]),billingEvents:e.array(W).max(7),profiles:e.array(K).max(32).refine(t=>new Set(t).size===t.length,"Profiles must be unique")}).superRefine((t,n)=>{let r=u=>t.capabilities.includes(u);r("catalog")!==(t.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(r("billing_records")!==t.billingEvents.length>0||new Set(t.billingEvents).size!==t.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare the unique supported billing events"})}),de=e.strictObject({origin:Ue,requiredCapabilities:me}),$e=e.strictObject({revision:e.number().int().nonnegative(),checkedAt:e.iso.datetime(),outcome:e.enum(["valid","unreachable","invalid","scope_mismatch","authentication_failed","credentials_missing"]),diagnostics:e.strictObject({ping:e.enum(["passed","failed","not_checked"]),authentication:e.enum(["passed","failed","not_checked"]),catalog:e.enum(["passed","failed","not_checked","static","unsupported"])}),manifest:V.nullable()}).superRefine((t,n)=>{t.outcome==="valid"!=(t.manifest!==null)&&n.addIssue({code:"custom",path:["manifest"],message:"Only a valid declaration carries a manifest"})}),jt=e.strictObject({projectId:e.uuid(),environmentId:e.uuid(),environment:e.enum(["sandbox","live"]),execution:e.enum(["indiana","record_only"]),accountId:e.string().nullable(),revision:e.number().int().nonnegative(),authentication:e.strictObject({keyId:ue}).nullable(),secretStoreConfigured:e.boolean().optional(),connection:de.nullable(),check:$e.nullable()});var se=e.strictObject({projectId:e.uuid(),environmentId:e.uuid()}),Pt=e.discriminatedUnion("action",[se.extend({action:e.literal("save"),revision:e.number().int().nonnegative(),connection:de,authentication:De.optional()}),se.extend({action:e.literal("check"),revision:e.number().int().nonnegative()})]),_=e.strictObject({projectId:e.uuid(),environmentId:e.uuid(),environment:e.enum(["sandbox","live"])});function qt(t){return e.strictObject({bridgeVersion:e.literal(M),requestId:e.uuid(),command:$,scope:_,data:t})}var le=e.strictObject({nativeUserId:e.string().min(1).max(128),session:Z.strict()}),pe=e.strictObject({nativeUserId:e.string().min(1).max(128),presentation:e.strictObject({customerId:e.uuid(),decisionId:e.uuid(),offeringVersionId:e.uuid(),paywallVersionId:e.uuid(),variant:e.string().min(1).max(128)}).nullable()}),he=e.strictObject({decisionId:e.uuid(),eventId:e.uuid()}),O=e.strictObject({operationId:e.uuid(),customerId:e.uuid()}),Ct=e.strictObject({bridgeVersion:e.literal(M),requestId:e.uuid(),command:e.string().min(1).max(64),scope:_,error:e.strictObject({code:e.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:e.string().min(1).max(500),retryable:e.boolean(),recovery:e.string().min(1).max(80)})});var zt=e.strictObject({scope:_,operationId:e.uuid(),customerId:e.uuid(),confirmedAt:e.iso.datetime({offset:!0}).nullable(),initialExecutionAllowed:e.boolean(),instruction:Y,merchantTerms:U.optional()}).refine(t=>t.operationId===t.instruction.operationId&&t.customerId===t.instruction.customerId&&(!t.merchantTerms||t.merchantTerms.request.operationId===t.operationId&&t.merchantTerms.request.subject.customerId===t.customerId&&t.merchantTerms.request.action===t.instruction.type&&t.merchantTerms.currency===t.instruction.currency&&Object.entries(t.scope).every(([n,r])=>t.merchantTerms.request.subject.scope[n]===r)),"Authority must refer to the original Customer and operation"),N=T,d=e.string().min(1).max(120),Ve=e.string().regex(/^-?[0-9]+(?:\.[0-9]{1,6})?$/),Ne=e.strictObject({revision:d,updatedAt:e.iso.datetime(),provider:e.literal("merchant"),items:e.array(e.strictObject({merchantProductId:d,productVersionId:e.uuid(),name:e.string().min(1).max(255),kind:e.enum(["subscription","credit_pack"]),merchantPriceId:d,currency:e.string().regex(/^[a-z]{3}$/),amountMinor:e.number().int().nonnegative().max(1e8),interval:e.enum(["one_time","month","year"]),intervalCount:e.literal(1),includedCredits:e.string().regex(/^[0-9]{1,18}(?:\.[0-9]{1,6})?$/),creditReset:e.enum(["none","month"]),creditPolicyId:d,available:e.boolean()}).superRefine((t,n)=>{(t.kind==="credit_pack"&&(t.interval!=="one_time"||t.creditReset!=="none")||t.kind==="subscription"&&t.interval==="one_time"||t.available&&t.amountMinor===0)&&n.addIssue({code:"custom",message:"Unsupported version 1 catalog terms"})})).max(500)}),Le=e.strictObject({customerId:e.uuid(),revision:e.string().min(1).max(128),observedAt:e.iso.datetime(),subscriptions:e.array(e.strictObject({merchantSubscriptionId:d,merchantProductId:d,productVersionId:e.uuid().nullable(),status:e.enum(["active","trialing","past_due","cancelled","expired"]),currentPeriodStartsAt:e.iso.datetime().nullable(),currentPeriodEndsAt:e.iso.datetime().nullable(),cancelAtPeriodEnd:e.boolean(),scheduledChange:e.strictObject({effectiveAt:e.iso.datetime(),merchantProductId:d}).nullable()})).max(100),purchaseHistory:e.strictObject({complete:e.boolean(),hasPaidPurchase:e.boolean(),lastPaidAt:e.iso.datetime().nullable()}),balances:e.array(e.strictObject({bucketId:d,key:d,available:Ve,expiresAt:e.iso.datetime().nullable(),nextResetAt:e.iso.datetime().nullable()})).max(100)}),v=e.strictObject({}),Fe={"bridge.ping":e.strictObject({challenge:e.uuid()}),"bridge.describe":v,"session.create":v,"catalog.read":v,"customer.commerce.read":v,"presentation.resolve":v,"presentation.report":he,"purchase.execute":O,"operation.read":O,"subscription.change":O,"refund.execute":O},wt={"bridge.ping":e.strictObject({challenge:e.uuid()}),"bridge.describe":V,"session.create":le,"catalog.read":Ne,"customer.commerce.read":Le,"presentation.resolve":pe,"presentation.report":e.strictObject({queued:e.literal(!0)}),"purchase.execute":N,"operation.read":ee,"subscription.change":N,"refund.execute":N},Dt=e.strictObject({bridgeVersion:e.literal(M),requestId:e.uuid(),scope:_,command:$,data:e.unknown()}).superRefine((t,n)=>{Fe[t.command].safeParse(t.data).success||n.addIssue({code:"custom",path:["data"],message:"Invalid command data"})});export{ge as a,S as b,xe as c,We as d,Xe as e,ye as f,T as g,ee as h,p as i,Je as j,z as k,qe as l,ne as m,re as n,P as o,ht as p,U as q,bt as r,ft as s,gt as t,Te as u,xt as v,yt as w,M as x,Ot as y,vt as z,Re as A,At as B,De as C,Ue as D,V as E,_ as F,qt as G,le as H,pe as I,he as J,O as K,Ct as L,zt as M,N,Le as O,Fe as P,wt as Q,Dt as R};
@@ -1 +1 @@
1
- import{a,b as o,c as i}from"./chunk-EBXWLW4D.js";import{a as p}from"./chunk-S4X6YX5D.js";function c(e){if(e!==null&&typeof e=="object"&&"customerId"in e)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function I(e){return{async previewUpdate(t){t=a(t),c(t);let r=await o(e,"previewUpdate");return i(e,r,t)},async update(t){t=a(t),c(t);let r=await o(e,"update");return i(e,r,t)},async readSubscriptionUpdate(t){t=a(t),c(t);let r=await o(e,"readSubscriptionUpdate");return i(e,r,t)},async restoreNativePurchase(t){t=a(t),c(t);let r=await o(e,"restoreNativePurchase");return i(e,r,t)},async previewAttach(t){t=a(t),c(t);let r=await o(e,"previewAttach");return i(e,r,t)},async attach(t){t=a(t),c(t);let r=await o(e,"attach");return i(e,r,t)},async readSubscriptionOperation(t){t=a(t),c(t);let r=await o(e,"readSubscriptionOperation");return i(e,r,t)}}}export{c as a,I as b};
1
+ import{a,b as o,c as i}from"./chunk-PKY55SBA.js";import{a as p}from"./chunk-7EPE2PUN.js";function c(e){if(e!==null&&typeof e=="object"&&"customerId"in e)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function I(e){return{async previewUpdate(t){t=a(t),c(t);let r=await o(e,"previewUpdate");return i(e,r,t)},async update(t){t=a(t),c(t);let r=await o(e,"update");return i(e,r,t)},async readSubscriptionUpdate(t){t=a(t),c(t);let r=await o(e,"readSubscriptionUpdate");return i(e,r,t)},async restoreNativePurchase(t){t=a(t),c(t);let r=await o(e,"restoreNativePurchase");return i(e,r,t)},async previewAttach(t){t=a(t),c(t);let r=await o(e,"previewAttach");return i(e,r,t)},async attach(t){t=a(t),c(t);let r=await o(e,"attach");return i(e,r,t)},async readSubscriptionOperation(t){t=a(t),c(t);let r=await o(e,"readSubscriptionOperation");return i(e,r,t)}}}export{c as a,I as b};