@shoppexio/storefront 1.0.5 → 1.0.6

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.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).shoppex={})}(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=class e extends Error{constructor(t,n,o){super(t),this.name="ShoppexError",this.code=n,this.statusCode=o,Object.setPrototypeOf(this,e.prototype)}},n=class e extends t{constructor(){super("SDK not initialized. Call shoppex.init() first.","NOT_INITIALIZED"),this.name="NotInitializedError",Object.setPrototypeOf(this,e.prototype)}},o=class e extends t{constructor(t,n){super(t,"NETWORK_ERROR",n),this.name="NetworkError",Object.setPrototypeOf(this,e.prototype)}},i=class e extends t{constructor(t){super(t,"BASKET_ERROR"),this.name="CartError",Object.setPrototypeOf(this,e.prototype)}},r=/\{[^{}]+\}/g;function a(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:o=globalThis.fetch,querySerializer:i,bodySerializer:r,pathSerializer:a,headers:s,requestInitExt:l,...u}={...e};l="object"==typeof process&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici?l:void 0,t=m(t);const h=[];async function _(e,_){const{baseUrl:y,fetch:g=o,Request:b=n,headers:v,params:w={},parseAs:S="json",querySerializer:k,bodySerializer:z=r??p,pathSerializer:x,body:O,middleware:E=[],...T}=_||{};let $=t;y&&($=m(y)??t);let A="function"==typeof i?i:c(i);k&&(A="function"==typeof k?k:c({..."object"==typeof i?i:{},...k}));const I=x||a||d,N=void 0===O?void 0:z(O,f(s,v,w.header)),C=f(void 0===N||N instanceof FormData?{}:{"Content-Type":"application/json"},s,v,w.header),P=[...h,...E],R={redirect:"follow",...u,...T,body:N,headers:C};let U,q,j,D=new b(function(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let o=t.querySerializer(t.params.query??{});o.startsWith("?")&&(o=o.substring(1));o&&(n+=`?${o}`);return n}(e,{baseUrl:$,params:w,querySerializer:A,pathSerializer:I}),R);for(const t in T)t in D||(D[t]=T[t]);if(P.length){U=Math.random().toString(36).slice(2,11),q=Object.freeze({baseUrl:$,fetch:g,parseAs:S,querySerializer:A,bodySerializer:z,pathSerializer:I});for(const t of P)if(t&&"object"==typeof t&&"function"==typeof t.onRequest){const n=await t.onRequest({request:D,schemaPath:e,params:w,options:q,id:U});if(n){if(!(n instanceof b)){if(n instanceof Response){j=n;break}throw new Error("onRequest: must return new Request() or Response() when modifying the request")}D=n}}}if(!j){try{j=await g(D,l)}catch(L){let t=L;if(P.length)for(let n=P.length-1;n>=0;n--){const o=P[n];if(o&&"object"==typeof o&&"function"==typeof o.onError){const n=await o.onError({request:D,error:t,schemaPath:e,params:w,options:q,id:U});if(n){if(n instanceof Response){t=void 0,j=n;break}if(n instanceof Error){t=n;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(t)throw t}if(P.length)for(let t=P.length-1;t>=0;t--){const n=P[t];if(n&&"object"==typeof n&&"function"==typeof n.onResponse){const t=await n.onResponse({request:D,response:j,schemaPath:e,params:w,options:q,id:U});if(t){if(!(t instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");j=t}}}}const Z=j.headers.get("Content-Length");if(204===j.status||"HEAD"===D.method||"0"===Z&&!j.headers.get("Transfer-Encoding")?.includes("chunked"))return j.ok?{data:void 0,response:j}:{error:void 0,response:j};if(j.ok){const e=async()=>{if("stream"===S)return j.body;if("json"===S&&!Z){const e=await j.text();return e?JSON.parse(e):void 0}return await j[S]()};return{data:await e(),response:j}}let M=await j.text();try{M=JSON.parse(M)}catch{}return{error:M,response:j}}return{request:(e,t,n)=>_(t,{...n,method:e.toUpperCase()}),GET:(e,t)=>_(e,{...t,method:"GET"}),PUT:(e,t)=>_(e,{...t,method:"PUT"}),POST:(e,t)=>_(e,{...t,method:"POST"}),DELETE:(e,t)=>_(e,{...t,method:"DELETE"}),OPTIONS:(e,t)=>_(e,{...t,method:"OPTIONS"}),HEAD:(e,t)=>_(e,{...t,method:"HEAD"}),PATCH:(e,t)=>_(e,{...t,method:"PATCH"}),TRACE:(e,t)=>_(e,{...t,method:"TRACE"}),use(...e){for(const t of e)if(t){if("object"!=typeof t||!("onRequest"in t||"onResponse"in t||"onError"in t))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");h.push(t)}},eject(...e){for(const t of e){const e=h.indexOf(t);-1!==e&&h.splice(e,1)}}}}function s(e,t,n){if(null==t)return"";if("object"==typeof t)throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${!0===n?.allowReserved?t:encodeURIComponent(t)}`}function l(e,t,n){if(!t||"object"!=typeof t)return"";const o=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if("deepObject"!==n.style&&!1===n.explode){for(const e in t)o.push(e,!0===n.allowReserved?t[e]:encodeURIComponent(t[e]));const i=o.join(",");switch(n.style){case"form":return`${e}=${i}`;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return i}}for(const a in t){const i="deepObject"===n.style?`${e}[${a}]`:a;o.push(s(i,t[a],n))}const r=o.join(i);return"label"===n.style||"matrix"===n.style?`${i}${r}`:r}function u(e,t,n){if(!Array.isArray(t))return"";if(!1===n.explode){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",i=(!0===n.allowReserved?t:t.map(e=>encodeURIComponent(e))).join(o);switch(n.style){case"simple":return i;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return`${e}=${i}`}}const o={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const r of t)"simple"===n.style||"label"===n.style?i.push(!0===n.allowReserved?r:encodeURIComponent(r)):i.push(s(e,r,n));return"label"===n.style||"matrix"===n.style?`${o}${i.join(o)}`:i.join(o)}function c(e){return function(t){const n=[];if(t&&"object"==typeof t)for(const o in t){const i=t[o];if(null!=i)if(Array.isArray(i)){if(0===i.length)continue;n.push(u(o,i,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof i?n.push(s(o,i,e)):n.push(l(o,i,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}))}return n.join("&")}}function d(e,t){let n=e;for(const o of e.match(r)??[]){let e=o.substring(1,o.length-1),i=!1,r="simple";if(e.endsWith("*")&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(".")?(r="label",e=e.substring(1)):e.startsWith(";")&&(r="matrix",e=e.substring(1)),!t||void 0===t[e]||null===t[e])continue;const a=t[e];Array.isArray(a)?n=n.replace(o,u(e,a,{style:r,explode:i})):n="object"!=typeof a?"matrix"!==r?n.replace(o,"label"===r?`.${encodeURIComponent(a)}`:encodeURIComponent(a)):n.replace(o,`;${s(e,a)}`):n.replace(o,l(e,a,{style:r,explode:i}))}return n}function p(e,t){return e instanceof FormData?e:t&&"application/x-www-form-urlencoded"===(t.get instanceof Function?t.get("Content-Type")??t.get("content-type"):t["Content-Type"]??t["content-type"])?new URLSearchParams(e).toString():JSON.stringify(e)}function f(...e){const t=new Headers;for(const n of e){if(!n||"object"!=typeof n)continue;const e=n instanceof Headers?n.entries():Object.entries(n);for(const[n,o]of e)if(null===o)t.delete(n);else if(Array.isArray(o))for(const e of o)t.append(n,e);else void 0!==o&&t.set(n,o)}return t}function m(e){return e.endsWith("/")?e.substring(0,e.length-1):e}var h={header:{title:"Header",aliases:["Header Menu"]},footer:{title:"Footer",aliases:["Footer Links","Legal Links"]}};var _;Object.keys(h);function y(e,t,n){function o(n,o){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:o,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,o);const i=a.prototype,r=Object.keys(i);for(let e=0;e<r.length;e++){const t=r[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class r extends i{}function a(e){var t;const i=n?.Parent?new r:this;o(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var g=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},b=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(_=globalThis).__zod_globalConfig??(_.__zod_globalConfig={});var v=globalThis.__zod_globalConfig;function w(e){return e&&Object.assign(v,e),v}function S(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function k(e,t){return"bigint"==typeof t?t.toString():t}function z(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function x(e){return null==e}function O(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var E=Symbol("evaluating");function T(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==E)return void 0===o&&(o=E,o=n()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function $(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function A(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function I(e){return JSON.stringify(e)}var N="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function C(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var P=z(()=>{if(v.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function R(e){if(!1===C(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==C(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function U(e){return R(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var q=new Set(["string","number","symbol"]);function j(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e,t,n){const o=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(o._zod.parent=e),o}function Z(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}var M={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function L(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function F(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function B(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Y(e){return"string"==typeof e?e:e?.message}function J(e,t,n){const o=e.message?e.message:Y(e.inst?._zod.def?.error?.(e))??Y(t?.error?.(e))??Y(n.customError?.(e))??Y(n.localeError?.(e))??"Invalid input",{inst:i,continue:r,input:a,...s}=e;return s.path??(s.path=[]),s.message=o,t?.reportInput&&(s.input=a),s}function W(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function V(...e){const[t,n,o]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:o}:{...t}}var G=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,k,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},H=y("$ZodError",G),K=y("$ZodError",G,{Parent:Error});var X=e=>(t,n,o,i)=>{const r=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise)throw new g;if(a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>J(e,r,w())));throw N(t,i?.callee),t}return a.value},Q=e=>async(t,n,o,i)=>{const r=o?{...o,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>J(e,r,w())));throw N(t,i?.callee),t}return a.value},ee=e=>(t,n,o)=>{const i=o?{...o,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new g;return r.issues.length?{success:!1,error:new(e??H)(r.issues.map(e=>J(e,i,w())))}:{success:!0,data:r.value}},te=ee(K),ne=e=>async(t,n,o)=>{const i=o?{...o,async:!0}:{async:!0};let r=t._zod.run({value:n,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>J(e,i,w())))}:{success:!0,data:r.value}},oe=ne(K),ie=e=>(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return X(e)(t,n,i)},re=e=>(t,n,o)=>X(e)(t,n,o),ae=e=>async(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return Q(e)(t,n,i)},se=e=>async(t,n,o)=>Q(e)(t,n,o),le=e=>(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return ee(e)(t,n,i)},ue=e=>(t,n,o)=>ee(e)(t,n,o),ce=e=>async(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return ne(e)(t,n,i)},de=e=>async(t,n,o)=>ne(e)(t,n,o),pe=/^[cC][0-9a-z]{6,}$/,fe=/^[0-9a-z]+$/,me=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,he=/^[0-9a-vA-V]{20}$/,_e=/^[A-Za-z0-9]{27}$/,ye=/^[a-zA-Z0-9_-]{21}$/,ge=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,be=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ve=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,we=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Se=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ke=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ze=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Oe=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ee=/^[A-Za-z0-9_-]*$/,Te=/^https?$/,$e=/^\+[1-9]\d{6,14}$/,Ae="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ie=new RegExp(`^${Ae}$`);function Ne(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}var Ce=/^-?\d+$/,Pe=/^-?\d+(?:\.\d+)?$/,Re=/^(?:true|false)$/i,Ue=/^[^A-Z]*$/,qe=/^[^a-z]*$/,je=y("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),De={number:"number",bigint:"bigint",object:"date"},Ze=y("$ZodCheckLessThan",(e,t)=>{je.init(e,t);const n=De[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Me=y("$ZodCheckGreaterThan",(e,t)=>{je.init(e,t);const n=De[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Le=y("$ZodCheckMultipleOf",(e,t)=>{je.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value!==BigInt(0):0!==function(e,t){const n=e/t,o=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<i?0:n-o}(n.value,t.value))&&n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Fe=y("$ZodCheckNumberFormat",(e,t)=>{je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[i,r]=M[t.format];e._zod.onattach.push(e=>{const o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=r,n&&(o.pattern=Ce)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}))}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>r&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Be=y("$ZodCheckMaxLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!x(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=W(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ye=y("$ZodCheckMinLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!x(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=W(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Je=y("$ZodCheckLengthEquals",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!x(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const r=W(o),a=i>t.length;n.issues.push({origin:r,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),We=y("$ZodCheckStringFormat",(e,t)=>{var n,o;je.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Ve=y("$ZodCheckRegex",(e,t)=>{We.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ge=y("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ue),We.init(e,t)}),He=y("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=qe),We.init(e,t)}),Ke=y("$ZodCheckIncludes",(e,t)=>{je.init(e,t);const n=j(t.includes),o=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Xe=y("$ZodCheckStartsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`^${j(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Qe=y("$ZodCheckEndsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`.*${j(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),et=y("$ZodCheckOverwrite",(e,t)=>{je.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),tt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),o=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const i of o)this.content.push(i)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},nt={major:4,minor:4,patch:3},ot=y("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nt;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const i of o)for(const t of i._zod.onattach)t(e);if(0===o.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let o,i=L(e);for(const r of t){if(r._zod.def.when){if(F(e))continue;if(!r._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=r._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new g;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(i||(i=L(e,t)))});else{if(e.issues.length===t)continue;i||(i=L(e,t))}}return o?o.then(()=>e):e},n=(n,i,r)=>{if(L(n))return n.aborted=!0,n;const a=t(i,o,r);if(a instanceof Promise){if(!1===r.async)throw new g;return a.then(t=>e._zod.parse(t,r))}return e._zod.parse(a,r)};e._zod.run=(i,r)=>{if(r.skipChecks)return e._zod.parse(i,r);if("backward"===r.direction){const t=e._zod.parse({value:i.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,r)):n(t,i,r)}const a=e._zod.parse(i,r);if(a instanceof Promise){if(!1===r.async)throw new g;return a.then(e=>t(e,o,r))}return t(a,o,r)}}T(e,"~standard",()=>({validate:t=>{try{const n=te(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return oe(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),it=y("$ZodString",(e,t)=>{var n;ot.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),rt=y("$ZodStringFormat",(e,t)=>{We.init(e,t),it.init(e,t)}),at=y("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=be),rt.init(e,t)}),st=y("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ve(e))}else t.pattern??(t.pattern=ve());rt.init(e,t)}),lt=y("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=we),rt.init(e,t)}),ut=y("$ZodURL",(e,t)=>{rt.init(e,t),e._zod.check=n=>{try{const o=n.value.trim();if(!t.normalize&&t.protocol?.source===Te.source&&!/^https?:\/\//i.test(o))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const i=new URL(o);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=o)}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ct=y("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),rt.init(e,t)}),dt=y("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ye),rt.init(e,t)}),pt=y("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pe),rt.init(e,t)}),ft=y("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=fe),rt.init(e,t)}),mt=y("$ZodULID",(e,t)=>{t.pattern??(t.pattern=me),rt.init(e,t)}),ht=y("$ZodXID",(e,t)=>{t.pattern??(t.pattern=he),rt.init(e,t)}),_t=y("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_e),rt.init(e,t)}),yt=y("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=Ne({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ae}T(?:${o})$`)}(t)),rt.init(e,t)}),gt=y("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ie),rt.init(e,t)}),bt=y("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Ne(t)}$`)),rt.init(e,t)}),vt=y("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ge),rt.init(e,t)}),wt=y("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Se),rt.init(e,t),e._zod.bag.format="ipv4"}),St=y("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ke),rt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),kt=y("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ze),rt.init(e,t)}),zt=y("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xe),rt.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(2!==o.length)throw new Error;const[e,t]=o;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function xt(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ot=y("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Oe),rt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{xt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Et=y("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ee),rt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Ee.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return xt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Tt=y("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$e),rt.init(e,t)});var $t=y("$ZodJWT",(e,t)=>{rt.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[o]=n;if(!o)return!1;const i=JSON.parse(atob(o));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),At=y("$ZodNumber",(e,t)=>{ot.init(e,t),e._zod.pattern=e._zod.bag.pattern??Pe,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const r="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...r?{received:r}:{}}),n}}),It=y("$ZodNumberFormat",(e,t)=>{Fe.init(e,t),At.init(e,t)}),Nt=y("$ZodBoolean",(e,t)=>{ot.init(e,t),e._zod.pattern=Re,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(r){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),Ct=y("$ZodUnknown",(e,t)=>{ot.init(e,t),e._zod.parse=e=>e}),Pt=y("$ZodNever",(e,t)=>{ot.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Rt(e,t,n){e.issues.length&&t.issues.push(...B(n,e.issues)),t.value[n]=e.value}var Ut=y("$ZodArray",(e,t)=>{ot.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const r=[];for(let e=0;e<i.length;e++){const a=i[e],s=t.element._zod.run({value:a,issues:[]},o);s instanceof Promise?r.push(s.then(t=>Rt(t,n,e))):Rt(s,n,e)}return r.length?Promise.all(r).then(()=>n):n}});function qt(e,t,n,o,i,r){const a=n in o;if(e.issues.length){if(i&&r&&!a)return;t.issues.push(...B(n,e.issues))}a||i?void 0===e.value?a&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function jt(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=(o=e.shape,Object.keys(o).filter(e=>"optional"===o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Dt(e,t,n,o,i,r){const a=[],s=i.keySet,l=i.catchall._zod,u=l.def.type,c="optional"===l.optin,d="optional"===l.optout;for(const p in t){if("__proto__"===p)continue;if(s.has(p))continue;if("never"===u){a.push(p);continue}const i=l.run({value:t[p],issues:[]},o);i instanceof Promise?e.push(i.then(e=>qt(e,n,p,t,c,d))):qt(i,n,p,t,c,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}var Zt=y("$ZodObject",(e,t)=>{if(ot.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=z(()=>jt(t));T(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const o=e[t]._zod;if(o.values){n[t]??(n[t]=new Set);for(const e of o.values)n[t].add(e)}}return n});const o=C,i=t.catchall;let r;e._zod.parse=(t,a)=>{r??(r=n.value);const s=t.value;if(!o(s))return t.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),t;t.value={};const l=[],u=r.shape;for(const e of r.keys){const n=u[e],o="optional"===n._zod.optin,i="optional"===n._zod.optout,r=n._zod.run({value:s[e],issues:[]},a);r instanceof Promise?l.push(r.then(n=>qt(n,t,e,s,o,i))):qt(r,t,e,s,o,i)}return i?Dt(l,s,t,a,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Mt=y("$ZodObjectJIT",(e,t)=>{Zt.init(e,t);const n=e._zod.parse,o=z(()=>jt(t));let i;const r=C,a=!v.jitless,s=a&&P.value,l=t.catchall;let u;e._zod.parse=(c,d)=>{u??(u=o.value);const p=c.value;return r(p)?a&&s&&!1===d?.async&&!0!==d.jitless?(i||(i=(e=>{const t=new tt(["shape","payload","ctx"]),n=o.value,i=e=>{const t=I(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let a=0;for(const o of n.keys)r[o]="key_"+a++;t.write("const newResult = {};");for(const o of n.keys){const n=r[o],a=I(o),s=e[o],l="optional"===s?._zod?.optin,u="optional"===s?._zod?.optout;t.write(`const ${n} = ${i(o)};`),l&&u?t.write(`\n if (${n}.issues.length) {\n if (${a} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):l?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${a} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${a}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${a}] = undefined;\n } else {\n newResult[${a}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,n)=>s(e,t,n)})(t.shape)),c=i(c,d),l?Dt([],p,c,d,u,e):c):n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c)}});function Lt(e,t,n,o){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;const i=e.filter(e=>!L(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>J(e,o,w())))}),t)}var Ft=y("$ZodUnion",(e,t)=>{ot.init(e,t),T(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),T(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),T(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),T(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>O(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(o,i)=>{if(n)return n(o,i);let r=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)a.push(t),r=!0;else{if(0===t.issues.length)return t;a.push(t)}}return r?Promise.all(a).then(t=>Lt(t,o,e,i)):Lt(a,o,e,i)}}),Bt=y("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ft.init(e,t);const n=e._zod.parse;T(e._zod,"propValues",()=>{const e={};for(const n of t.options){const o=n._zod.propValues;if(!o||0===Object.keys(o).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(o)){e[t]||(e[t]=new Set);for(const o of n)e[t].add(o)}}return e});const o=z(()=>{const e=t.options,n=new Map;for(const o of e){const e=o._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,o)}}return n});e._zod.parse=(i,r)=>{const a=i.value;if(!C(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(i,r):t.unionFallback||"backward"===r.direction?n(i,r):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:a,path:[t.discriminator],inst:e}),i)}}),Yt=y("$ZodIntersection",(e,t)=>{ot.init(e,t),e._zod.parse=(e,n)=>{const o=e.value,i=t.left._zod.run({value:o,issues:[]},n),r=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([t,n])=>Wt(e,t,n)):Wt(e,i,r)}});function Jt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(R(e)&&R(t)){const n=Object.keys(t),o=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const r of o){const n=Jt(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};i[r]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const i=Jt(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wt(e,t,n){const o=new Map;let i;for(const s of t.issues)if("unrecognized_keys"===s.code){i??(i=s);for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).l=!0}else e.issues.push(s);for(const s of n.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).r=!0;else e.issues.push(s);const r=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(r.length&&i&&e.issues.push({...i,keys:r}),L(e))return e;const a=Jt(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Vt=y("$ZodRecord",(e,t)=>{ot.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!R(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const r=[],a=t.keyType._zod.values;if(a){n.value={};const s=new Set;for(const u of a)if("string"==typeof u||"number"==typeof u||"symbol"==typeof u){s.add("number"==typeof u?u.toString():u);const a=t.keyType._zod.run({value:u,issues:[]},o);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>J(e,o,w())),input:u,path:[u],inst:e});continue}const l=a.value,c=t.valueType._zod.run({value:i[u],issues:[]},o);c instanceof Promise?r.push(c.then(e=>{e.issues.length&&n.issues.push(...B(u,e.issues)),n.value[l]=e.value})):(c.issues.length&&n.issues.push(...B(u,c.issues)),n.value[l]=c.value)}let l;for(const e in i)s.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(i)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(i,a))continue;let s=t.keyType._zod.run({value:a,issues:[]},o);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&Pe.test(a)&&s.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},o);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>J(e,o,w())),input:a,path:[a],inst:e});continue}const l=t.valueType._zod.run({value:i[a],issues:[]},o);l instanceof Promise?r.push(l.then(e=>{e.issues.length&&n.issues.push(...B(a,e.issues)),n.value[s.value]=e.value})):(l.issues.length&&n.issues.push(...B(a,l.issues)),n.value[s.value]=l.value)}}return r.length?Promise.all(r).then(()=>n):n}}),Gt=y("$ZodEnum",(e,t)=>{ot.init(e,t);const n=S(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(e=>q.has(typeof e)).map(e=>"string"==typeof e?j(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const r=t.value;return o.has(r)||t.issues.push({code:"invalid_value",values:n,input:r,inst:e}),t}}),Ht=y("$ZodLiteral",(e,t)=>{if(ot.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?j(e):e?j(e.toString()):String(e)).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return n.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),Kt=y("$ZodTransform",(e,t)=>{ot.init(e,t),e._zod.optin="optional",e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new b(e.constructor.name);const i=t.transform(n.value,n);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new g;return n.value=i,n.fallback=!0,n}});function Xt(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Qt=y("$ZodOptional",(e,t)=>{ot.init(e,t),e._zod.optin="optional",e._zod.optout="optional",T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${O(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const o=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Xt(e,o)):Xt(i,o)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),en=y("$ZodExactOptional",(e,t)=>{Qt.init(e,t),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),tn=y("$ZodNullable",(e,t)=>{ot.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${O(e.source)}|null)$`):void 0}),T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),nn=y("$ZodDefault",(e,t)=>{ot.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>on(e,t)):on(o,t)}});function on(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var rn=y("$ZodPrefault",(e,t)=>{ot.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),an=y("$ZodNonOptional",(e,t)=>{ot.init(e,t),T(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,o)=>{const i=t.innerType._zod.run(n,o);return i instanceof Promise?i.then(t=>sn(t,e)):sn(i,e)}});function sn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var ln=y("$ZodCatch",(e,t)=>{ot.init(e,t),e._zod.optin="optional",T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(o=>(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>J(e,n,w()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>J(e,n,w()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),un=y("$ZodPipe",(e,t)=>{ot.init(e,t),T(e._zod,"values",()=>t.in._zod.values),T(e._zod,"optin",()=>t.in._zod.optin),T(e._zod,"optout",()=>t.out._zod.optout),T(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const o=t.out._zod.run(e,n);return o instanceof Promise?o.then(e=>cn(e,t.in,n)):cn(o,t.in,n)}const o=t.in._zod.run(e,n);return o instanceof Promise?o.then(e=>cn(e,t.out,n)):cn(o,t.out,n)}});function cn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var dn=y("$ZodReadonly",(e,t)=>{ot.init(e,t),T(e._zod,"propValues",()=>t.innerType._zod.propValues),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"optin",()=>t.innerType?._zod?.optin),T(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(pn):pn(o)}});function pn(e){return e.value=Object.freeze(e.value),e}var fn,mn=y("$ZodCustom",(e,t)=>{je.init(e,t),ot.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const o=n.value,i=t.fn(o);if(i instanceof Promise)return i.then(t=>hn(t,n,o,e));hn(i,n,o,e)}});function hn(e,t,n,o){if(!e){const e={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),t.issues.push(V(e))}}var _n=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(fn=globalThis).__zod_globalRegistry??(fn.__zod_globalRegistry=new _n);var yn=globalThis.__zod_globalRegistry;function gn(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Z(t)})}function bn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Z(t)})}function vn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Z(t)})}function wn(e,t){return new Ze({check:"less_than",...Z(t),value:e,inclusive:!1})}function Sn(e,t){return new Ze({check:"less_than",...Z(t),value:e,inclusive:!0})}function kn(e,t){return new Me({check:"greater_than",...Z(t),value:e,inclusive:!1})}function zn(e,t){return new Me({check:"greater_than",...Z(t),value:e,inclusive:!0})}function xn(e,t){return new Le({check:"multiple_of",...Z(t),value:e})}function On(e,t){return new Be({check:"max_length",...Z(t),maximum:e})}function En(e,t){return new Ye({check:"min_length",...Z(t),minimum:e})}function Tn(e,t){return new Je({check:"length_equals",...Z(t),length:e})}function $n(e){return new et({check:"overwrite",tx:e})}function An(e,t){const n=new je({check:"custom",...Z(t)});return n._zod.check=e,n}function In(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??yn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Nn(e,t,n={path:[],schemaPath:[]}){var o;const i=e._zod.def,r=t.seen.get(e);if(r)return r.count++,n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const o={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,o);else{const n=a.schema,r=t.processors[i.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);r(e,t,n,o)}const r=e._zod.parent;r&&(a.ref||(a.ref=r),Nn(r,t,o),t.seen.get(r).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),"input"===t.io&&Rn(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Cn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const r of e.seen.entries()){const t=e.metadataRegistry.get(r[0])?.id;if(t){const e=o.get(t);if(e&&e!==r[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(t,r[0])}}const i=t=>{if(t[1].schema.$ref)return;const o=t[1],{ref:i,defId:r}=(t=>{const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const r=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=r,{defId:r,ref:`${i("__shared")}#/${o}/${r}`}}if(t[1]===n)return{ref:"#"};const i=`#/${o}/`,r=t[1].schema.id??"__schema"+e.counter++;return{defId:r,ref:i+r}})(t);o.def={...o.schema},r&&(o.defId=r);const a=o.schema;for(const e in a)delete a[e];a.$ref=i};if("throw"===e.cycles)for(const r of e.seen.entries()){const e=r[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const n=r[1];if(t!==r[0]){if(e.external){const n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){i(r);continue}}(e.metadataRegistry.get(r[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(r)}else i(r)}}function Pn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,r={...i},a=n.ref;if(n.ref=null,a){o(a);const n=e.seen.get(a),s=n.schema;if(!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,s):(i.allOf=i.allOf??[],i.allOf.push(s)),Object.assign(i,r),t._zod.parent===a)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in r||delete i[e]);if(s.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const s=t._zod.parent;if(s&&s!==a){o(s);const t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const r=e.metadataRegistry.get(t)?.id;void 0!==r&&i.id===r&&delete i.id;const a=e.external?.defs??{};for(const l of e.seen.entries()){const e=l[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?i.$defs=a:i.definitions=a);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Un(t,"input",e.processors),output:Un(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(s){throw new Error("Error converting schema to JSON.")}}function Rn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if("transform"===o.type)return!0;if("array"===o.type)return Rn(o.element,n);if("set"===o.type)return Rn(o.valueType,n);if("lazy"===o.type)return Rn(o.getter(),n);if("promise"===o.type||"optional"===o.type||"nonoptional"===o.type||"nullable"===o.type||"readonly"===o.type||"default"===o.type||"prefault"===o.type)return Rn(o.innerType,n);if("intersection"===o.type)return Rn(o.left,n)||Rn(o.right,n);if("record"===o.type||"map"===o.type)return Rn(o.keyType,n)||Rn(o.valueType,n);if("pipe"===o.type)return!!e._zod.traits.has("$ZodCodec")||(Rn(o.in,n)||Rn(o.out,n));if("object"===o.type){for(const e in o.shape)if(Rn(o.shape[e],n))return!0;return!1}if("union"===o.type){for(const e of o.options)if(Rn(e,n))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(Rn(e,n))return!0;return!(!o.rest||!Rn(o.rest,n))}return!1}var Un=(e,t,n={})=>o=>{const{libraryOptions:i,target:r}=o??{},a=In({...i??{},target:r,io:t,processors:n});return Nn(e,a),Cn(a,e),Pn(a,e)},qn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jn=(e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o);t.seen.get(e).ref=i.innerType},Dn=y("ZodISODateTime",(e,t)=>{yt.init(e,t),mo.init(e,t)});function Zn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Z(t)})}(Dn,e)}var Mn=y("ZodISODate",(e,t)=>{gt.init(e,t),mo.init(e,t)});function Ln(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Z(t)})}(Mn,e)}var Fn=y("ZodISOTime",(e,t)=>{bt.init(e,t),mo.init(e,t)});function Bn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Z(t)})}(Fn,e)}var Yn=y("ZodISODuration",(e,t)=>{vt.init(e,t),mo.init(e,t)});function Jn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Z(t)})}(Yn,e)}var Wn=(e,t)=>{H.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},o=(e,i=[])=>{for(const r of e.issues)if("invalid_union"===r.code&&r.errors.length)r.errors.map(e=>o({issues:e},[...i,...r.path]));else if("invalid_key"===r.code)o({issues:r.issues},[...i,...r.path]);else if("invalid_element"===r.code)o({issues:r.issues},[...i,...r.path]);else{const e=[...i,...r.path];if(0===e.length)n._errors.push(t(r));else{let o=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?o[n]=o[n]||{_errors:[]}:(o[n]=o[n]||{_errors:[]},o[n]._errors.push(t(r))),o=o[n],i++}}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):o.push(t(i));return{formErrors:o,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,k,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,k,2)}},isEmpty:{get:()=>0===e.issues.length}})},Vn=y("ZodError",Wn,{Parent:Error}),Gn=X(Vn),Hn=Q(Vn),Kn=ee(Vn),Xn=ne(Vn),Qn=ie(Vn),eo=re(Vn),to=ae(Vn),no=se(Vn),oo=le(Vn),io=ue(Vn),ro=ce(Vn),ao=de(Vn),so=new WeakMap;function lo(e,t,n){const o=Object.getPrototypeOf(e);let i=so.get(o);if(i||(i=new Set,so.set(o,i)),!i.has(t)){i.add(t);for(const e in n){const t=n[e];Object.defineProperty(o,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var uo=y("ZodType",(e,t)=>(ot.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Un(e,"input"),output:Un(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const o=In({...n,processors:t});return Nn(e,o),Cn(o,e),Pn(o,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Gn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Kn(e,t,n),e.parseAsync=async(t,n)=>Hn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Xn(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Qn(e,t,n),e.decode=(t,n)=>eo(e,t,n),e.encodeAsync=async(t,n)=>to(e,t,n),e.decodeAsync=async(t,n)=>no(e,t,n),e.safeEncode=(t,n)=>oo(e,t,n),e.safeDecode=(t,n)=>io(e,t,n),e.safeEncodeAsync=async(t,n)=>ro(e,t,n),e.safeDecodeAsync=async(t,n)=>ao(e,t,n),lo(e,"ZodType",{check(...e){const t=this.def;return this.clone(A(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return D(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Z(n)})}(bi,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=An(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(V(e,t.value,n._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(V(o))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check($n(e))},optional(){return li(this)},exactOptional(){return new ui({type:"optional",innerType:this})},nullable(){return di(this)},nullish(){return li(di(this))},nonoptional(e){return function(e,t){return new mi({type:"nonoptional",innerType:e,...Z(t)})}(this,e)},array(){return Jo(this)},or(e){return Ho([this,e])},and(e){return new Qo({type:"intersection",left:this,right:e})},transform(e){return yi(this,new ai({type:"transform",transform:e}))},default(e){return t=e,new pi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():U(t)}});var t},prefault(e){return t=e,new fi({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():U(t)}});var t},catch(e){return new hi({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return yi(this,e)},readonly(){return new gi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return yn.add(t,{description:e}),t},meta(...e){if(0===e.length)return yn.get(this);const t=this.clone();return yn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>yn.get(e)?.description,configurable:!0}),e)),co=y("_ZodString",(e,t)=>{it.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:a,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof r&&(o.maxLength=r),a&&(o.format=qn[a]??a,""===o.format&&delete o.format,"time"===a&&delete o.format),l&&(o.contentEncoding=l),s&&s.size>0){const e=[...s];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,lo(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ve({check:"string_format",format:"regex",...Z(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Ke({check:"string_format",format:"includes",...Z(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Xe({check:"string_format",format:"starts_with",...Z(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Qe({check:"string_format",format:"ends_with",...Z(t),suffix:e})}(...e))},min(...e){return this.check(En(...e))},max(...e){return this.check(On(...e))},length(...e){return this.check(Tn(...e))},nonempty(...e){return this.check(En(1,...e))},lowercase(e){return this.check(function(e){return new Ge({check:"string_format",format:"lowercase",...Z(e)})}(e))},uppercase(e){return this.check(function(e){return new He({check:"string_format",format:"uppercase",...Z(e)})}(e))},trim(){return this.check($n(e=>e.trim()))},normalize(...e){return this.check(function(e){return $n(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check($n(e=>e.toLowerCase()))},toUpperCase(){return this.check($n(e=>e.toUpperCase()))},slugify(){return this.check($n(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),po=y("ZodString",(e,t)=>{it.init(e,t),co.init(e,t),e.email=t=>e.check(gn(ho,t)),e.url=t=>e.check(vn(bo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Z(t)})}(Po,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Z(t)})}(vo,t)),e.guid=t=>e.check(bn(yo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Z(t)})}(go,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Z(t)})}(go,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Z(t)})}(go,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Z(t)})}(go,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Z(t)})}(wo,t)),e.guid=t=>e.check(bn(yo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Z(t)})}(So,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Z(t)})}(ko,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Z(t)})}(zo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Z(t)})}(Io,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Z(t)})}(No,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Z(t)})}(xo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Z(t)})}(Oo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Z(t)})}(Eo,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Z(t)})}(To,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Z(t)})}($o,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Z(t)})}(Ao,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Z(t)})}(Co,t)),e.datetime=t=>e.check(Zn(t)),e.date=t=>e.check(Ln(t)),e.time=t=>e.check(Bn(t)),e.duration=t=>e.check(Jn(t))});function fo(e){return function(e,t){return new e({type:"string",...Z(t)})}(po,e)}var mo=y("ZodStringFormat",(e,t)=>{rt.init(e,t),co.init(e,t)}),ho=y("ZodEmail",(e,t)=>{lt.init(e,t),mo.init(e,t)});function _o(e){return gn(ho,e)}var yo=y("ZodGUID",(e,t)=>{at.init(e,t),mo.init(e,t)}),go=y("ZodUUID",(e,t)=>{st.init(e,t),mo.init(e,t)}),bo=y("ZodURL",(e,t)=>{ut.init(e,t),mo.init(e,t)});var vo=y("ZodEmoji",(e,t)=>{ct.init(e,t),mo.init(e,t)}),wo=y("ZodNanoID",(e,t)=>{dt.init(e,t),mo.init(e,t)}),So=y("ZodCUID",(e,t)=>{pt.init(e,t),mo.init(e,t)}),ko=y("ZodCUID2",(e,t)=>{ft.init(e,t),mo.init(e,t)}),zo=y("ZodULID",(e,t)=>{mt.init(e,t),mo.init(e,t)}),xo=y("ZodXID",(e,t)=>{ht.init(e,t),mo.init(e,t)}),Oo=y("ZodKSUID",(e,t)=>{_t.init(e,t),mo.init(e,t)}),Eo=y("ZodIPv4",(e,t)=>{wt.init(e,t),mo.init(e,t)}),To=y("ZodIPv6",(e,t)=>{St.init(e,t),mo.init(e,t)}),$o=y("ZodCIDRv4",(e,t)=>{kt.init(e,t),mo.init(e,t)}),Ao=y("ZodCIDRv6",(e,t)=>{zt.init(e,t),mo.init(e,t)}),Io=y("ZodBase64",(e,t)=>{Ot.init(e,t),mo.init(e,t)}),No=y("ZodBase64URL",(e,t)=>{Et.init(e,t),mo.init(e,t)}),Co=y("ZodE164",(e,t)=>{Tt.init(e,t),mo.init(e,t)}),Po=y("ZodJWT",(e,t)=>{$t.init(e,t),mo.init(e,t)}),Ro=y("ZodNumber",(e,t)=>{At.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:i,maximum:r,format:a,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const c="number"==typeof u&&u>=(i??Number.NEGATIVE_INFINITY),d="number"==typeof l&&l<=(r??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;c?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:"number"==typeof i&&(o.minimum=i),d?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof r&&(o.maximum=r),"number"==typeof s&&(o.multipleOf=s)})(e,t,n),lo(e,"ZodNumber",{gt(e,t){return this.check(kn(e,t))},gte(e,t){return this.check(zn(e,t))},min(e,t){return this.check(zn(e,t))},lt(e,t){return this.check(wn(e,t))},lte(e,t){return this.check(Sn(e,t))},max(e,t){return this.check(Sn(e,t))},int(e){return this.check(jo(e))},safe(e){return this.check(jo(e))},positive(e){return this.check(kn(0,e))},nonnegative(e){return this.check(zn(0,e))},negative(e){return this.check(wn(0,e))},nonpositive(e){return this.check(Sn(0,e))},multipleOf(e,t){return this.check(xn(e,t))},step(e,t){return this.check(xn(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Uo(e){return function(e,t){return new e({type:"number",checks:[],...Z(t)})}(Ro,e)}var qo=y("ZodNumberFormat",(e,t)=>{It.init(e,t),Ro.init(e,t)});function jo(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Z(t)})}(qo,e)}var Do=y("ZodBoolean",(e,t)=>{Nt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Zo(e){return function(e,t){return new e({type:"boolean",...Z(t)})}(Do,e)}var Mo=y("ZodUnknown",(e,t)=>{Ct.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Lo(){return new Mo({type:"unknown"})}var Fo=y("ZodNever",(e,t)=>{Pt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Bo(e){return function(e,t){return new e({type:"never",...Z(t)})}(Fo,e)}var Yo=y("ZodArray",(e,t)=>{Ut.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(i.minItems=a),"number"==typeof s&&(i.maxItems=s),i.type="array",i.items=Nn(r.element,t,{...o,path:[...o.path,"items"]})})(e,t,n,o),e.element=t.element,lo(e,"ZodArray",{min(e,t){return this.check(En(e,t))},nonempty(e){return this.check(En(1,e))},max(e,t){return this.check(On(e,t))},length(e,t){return this.check(Tn(e,t))},unwrap(){return this.element}})});function Jo(e,t){return function(e,t,n){return new e({type:"array",element:t,...Z(n)})}(Yo,e,t)}var Wo=y("ZodObject",(e,t)=>{Mt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object",i.properties={};const a=r.shape;for(const u in a)i.properties[u]=Nn(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(i.required=Array.from(l)),"never"===r.catchall?._zod.def.type?i.additionalProperties=!1:r.catchall?r.catchall&&(i.additionalProperties=Nn(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,o),T(e,"shape",()=>t.shape),lo(e,"ZodObject",{keyof(){return oi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Lo()})},loose(){return this.clone({...this._zod.def,catchall:Lo()})},strict(){return this.clone({...this._zod.def,catchall:Bo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!R(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return D(e,A(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return $(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!R(t))throw new Error("Invalid input to safeExtend: expected a plain object");return D(e,A(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return $(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return D(e,A(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return $(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return D(e,A(e._zod.def,{get shape(){const e={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(e[o]=n.shape[o])}return $(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return D(e,A(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete o[e]}return $(this,"shape",o),o},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return D(t,A(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)i[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return $(this,"shape",i),i},checks:[]}))}(si,this,e[0])},required(...e){return t=mi,n=this,o=e[0],D(n,A(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(o)for(const n in o){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);o[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return $(this,"shape",i),i}}));var t,n,o}})});function Vo(e,t){return new Wo({type:"object",shape:e??{},...Z(t)})}var Go=y("ZodUnion",(e,t)=>{Ft.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=!1===i.inclusive,a=i.options.map((e,n)=>Nn(e,t,{...o,path:[...o.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=a:n.anyOf=a})(e,t,n,o),e.options=t.options});function Ho(e,t){return new Go({type:"union",options:e,...Z(t)})}var Ko=y("ZodDiscriminatedUnion",(e,t)=>{Go.init(e,t),Bt.init(e,t)});function Xo(e,t,n){return new Ko({type:"union",options:t,discriminator:e,...Z(n)})}var Qo=y("ZodIntersection",(e,t)=>{Yt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Nn(i.left,t,{...o,path:[...o.path,"allOf",0]}),a=Nn(i.right,t,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(r)?r.allOf:[r],...s(a)?a.allOf:[a]]})(e,t,n,o)});var ei=y("ZodRecord",(e,t)=>{Vt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object";const a=r.keyType,s=a._zod.bag?.patterns;if("loose"===r.mode&&s&&s.size>0){const e=Nn(r.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});i.patternProperties={};for(const t of s)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=Nn(r.keyType,t,{...o,path:[...o.path,"propertyNames"]})),i.additionalProperties=Nn(r.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=a._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ti(e,t,n){return t&&t._zod?new ei({type:"record",keyType:e,valueType:t,...Z(n)}):new ei({type:"record",keyType:fo(),valueType:e,...Z(t)})}var ni=y("ZodEnum",(e,t)=>{Gt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=S(e._zod.def.entries);o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=o})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,o)=>{const i={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new ni({...t,checks:[],...Z(o),entries:i})},e.exclude=(e,o)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new ni({...t,checks:[],...Z(o),entries:i})}});function oi(e,t){return new ni({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Z(t)})}var ii=y("ZodLiteral",(e,t)=>{Ht.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=e._zod.def,i=[];for(const r of o.values)if(void 0===r){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof r){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(r))}else i.push(r);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ri(e,t){return new ii({type:"literal",values:Array.isArray(e)?e:[e],...Z(t)})}var ai=y("ZodTransform",(e,t)=>{Kt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new b(e.constructor.name);n.addIssue=o=>{if("string"==typeof o)n.issues.push(V(o,n.value,t));else{const t=o;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(V(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});var si=y("ZodOptional",(e,t)=>{Qt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>jn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});function li(e){return new si({type:"optional",innerType:e})}var ui=y("ZodExactOptional",(e,t)=>{en.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>jn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var ci=y("ZodNullable",(e,t)=>{tn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Nn(i.innerType,t,o),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function di(e){return new ci({type:"nullable",innerType:e})}var pi=y("ZodDefault",(e,t)=>{nn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var fi=y("ZodPrefault",(e,t)=>{rn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var mi=y("ZodNonOptional",(e,t)=>{an.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var hi=y("ZodCatch",(e,t)=>{ln.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;let r;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var _i=y("ZodPipe",(e,t)=>{un.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=i.in._zod.traits.has("$ZodTransform"),a="input"===t.io?r?i.out:i.in:i.out;Nn(a,t,o),t.seen.get(e).ref=a})(e,t,0,o),e.in=t.in,e.out=t.out});function yi(e,t){return new _i({type:"pipe",in:e,out:t})}var gi=y("ZodReadonly",(e,t)=>{dn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var bi=y("ZodCustom",(e,t)=>{mn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});var vi,wi=oi(["CONSENT","SOFT_OPT_IN","TRANSACTIONAL_ONLY","UNKNOWN"]),Si=oi(["MANUAL_UNSUB","ONE_CLICK_UNSUB","HARD_BOUNCE","COMPLAINT","ADMIN_BLOCK"]),ki=oi(["BROADCAST","AUTOMATION"]),zi=oi(["ABANDONED_CART","POST_PURCHASE","WELCOME","WIN_BACK","RE_ENGAGEMENT","TAG_ADDED"]),xi=(Vo({email:_o(),name:fo().trim().min(1).nullable().optional(),customer_id:fo().uuid().nullable().optional(),tags:Jo(fo().trim().min(1)).default([]),consent_basis:wi.default("UNKNOWN"),source:fo().trim().min(1).default("dashboard")}),Vo({name:fo().trim().min(1),subject:fo().trim().min(1),preheader:fo().nullable().optional(),mjml_source:fo().trim().min(1),builder_project_json:ti(fo(),Lo()).nullable().optional(),thumbnail_url:vn(bo,vi).nullable().optional()}),Vo({mjml_source:fo().trim().min(1),sample_variables:ti(fo(),Lo()).optional()}),Vo({recipient_email:_o(),sample_variables:ti(fo(),Lo()).optional()}),Vo({marketing_enabled:Zo().optional(),default_from_name:fo().trim().min(1).nullable().optional(),default_from_email:_o().nullable().optional(),default_reply_to_email:_o().nullable().optional(),physical_address:fo().trim().min(1).nullable().optional(),physical_address_line2:fo().trim().min(1).nullable().optional(),physical_city:fo().trim().min(1).nullable().optional(),physical_postal_code:fo().trim().min(1).nullable().optional(),physical_country:fo().trim().length(2).nullable().optional(),daily_limit:Uo().int().positive().optional(),monthly_soft_cap:Uo().int().positive().optional()}),Vo({type:ki.default("BROADCAST"),name:fo().trim().min(1),subject:fo().trim().min(1),template_id:fo().uuid(),list_id:fo().uuid().nullable().optional(),segment_id:fo().uuid().nullable().optional(),from_name:fo().trim().min(1),from_email:_o(),reply_to_email:_o().nullable().optional(),schedule_at:fo().datetime().nullable().optional(),target_emails:Jo(_o()).max(0,"Direct recipient entry is disabled. Use lists or segments built from Shoppex customers and paid order buyers.").default([]),idempotency_key:fo().trim().min(1).nullable().optional()}),Vo({name:fo().trim().min(1),subject:fo().trim().min(1),template_id:fo().uuid(),from_name:fo().trim().min(1),from_email:_o(),reply_to_email:_o().nullable().optional(),trigger:zi,delay_seconds:Uo().int().min(0).default(0),conditions:ti(fo(),Lo()).default({})}),Vo({trigger:zi,email:_o(),customer_id:fo().uuid().nullable().optional(),name:fo().trim().min(1).nullable().optional(),consent_basis:wi.default("UNKNOWN"),variables:ti(fo(),Lo()).default({}),idempotency_key:fo().trim().min(1).nullable().optional()}),Vo({email:_o(),reason:Si.default("ADMIN_BLOCK"),notes:fo().nullable().optional()}),["BITCOIN","LITECOIN","ETHEREUM","BITCOIN_CASH","MONERO","RIPPLE","TRON","SOLANA","POLYGON","BINANCE_COIN","CRONOS","CONCORDIUM","NANO","DOGECOIN","DASH"]),Oi=["NOWPAYMENTS","CRYPTOMUS","OXAPAY"],Ei=["NOWPAYMENTS_WHITELABEL"],Ti={USDT:["USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL"],USDC:["USDC_ERC20","USDC_TRC20","USDC_BEP20","USDC_POLYGON","USDC_SOL"],DAI:["DAI_ERC20"]},$i=Object.keys(Ti),Ai=[...Ti.USDT,...Ti.USDC,...Ti.DAI],Ii=[...xi,...Ai],Ni=["BITCOIN_LN"],Ci=[...Oi,...Ei],Pi=[...Ii,...Ni],Ri=Ii,Ui=new Set(xi),qi=new Set(Ai),ji=(new Set(Ii),new Set(Ni),new Set(Oi),new Set(Ei),new Set(Ci),new Set(Pi),new Set($i),new Set(["STRIPE","PAYPAL","PAYPAL_FF","MOLLIE","AUTHORIZENET","NMI","SQUARE","SUMUP","SHOPIFY","SUBY","PANDABASE","STORRIK","VENPAYR","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","CASHAPP","VENMO","CRYPTO","CUSTOMER_BALANCE","MANUAL"]),{CASHAPP:"CASH_APP",PAYPAL_CREDIT_CARD:"PAYPAL",EUTHEREUM:"ETHEREUM",USDT_MATIC:"USDT_POLYGON",USDC_MATIC:"USDC_POLYGON"});function Di(e,t){if(new Set(t).size!==t.length)throw new Error(`${e} contains duplicate entries`)}Di("COIN_GATEWAY_KEYS",xi),Di("TOKEN_GATEWAY_KEYS",Ai),Di("CRYPTO_GATEWAY_KEYS",Ii),Di("LEGACY_CRYPTO_GATEWAY_KEYS",Ni),Di("CRYPTO_PROVIDER_KEYS",Oi),Di("MANAGED_CRYPTO_PROVIDER_KEYS",Ei),Di("CRYPTO_PROVIDER_GATEWAY_KEYS",Ci),Di("DEFAULT_NOWPAYMENTS_CRYPTO_GATEWAY_KEYS",Ri),Di("DEFAULT_CRYPTOMUS_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL","USDC_ERC20","USDC_BEP20","USDC_POLYGON","DAI_ERC20"]),Di("DEFAULT_OXAPAY_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDC_ERC20"]);for(const Rl of Ii)if(!Ui.has(Rl)&&!qi.has(Rl))throw new Error(`CRYPTO_GATEWAY_KEYS contains an unclassified gateway: ${Rl}`);new Set(["STRIPE","PAYPAL","PAYPAL_FF","SKRILL","CASHAPP","CASH_APP","PERFECT_MONEY","SQUARE","SUMUP","SHOPIFY","SUBY","PANDABASE","STORRIK","VENPAYR","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","VENMO","MOLLIE","AUTHORIZENET","NMI"].map(e=>function(e){const t=e.trim();if(!t)return"";if(/^manual:/i.test(t)){const e=t.slice(t.indexOf(":")+1).trim();return e?`MANUAL:${e}`:"MANUAL"}let n=t.toUpperCase();const o=n.match(/^(USDT|USDC|DAI):([A-Z0-9_]+)$/);if(o){const[,e,t]=o;n=`${e}_${"MATIC"===t?"POLYGON":t}`}return ji[n]??n}(e))),new Set(["WHITE_LABEL","NATIVE"]);var Zi=[...Ci,"NATIVE"],Mi=(new Set(Zi),Vo({set:Zo()})),Li=Vo({status:oi(["READY","NEEDS_ATTENTION"]).optional(),code:fo().optional(),message:fo().optional(),checked_at:fo().optional()}),Fi=(Vo({provider:fo(),type:fo(),enabled:Zo(),connected:Zo(),credentials:ti(fo(),Mi),public_config:ti(fo(),Lo()),webhook:ti(fo(),Lo()).optional(),health:Li.optional()}),"#2563eb"),Bi=["comfortable","compact"],Yi=["top","side","background"],Ji=oi(["checkout","payment_link","embed"]),Wi=oi(["current","clean-light","clean-dark","v2","v3"]),Vi=oi(Bi),Gi=oi(["light","dark","system"]),Hi=oi(Yi),Ki=oi(["ghost","outlined","filled"]),Xi=oi(["sheet","fullscreen","center"]),Qi=(oi(["checkout.shell","checkout.panel","checkout.header","brand.logo","product.card","product.image","product.title","product.description","product.price","product.quantity","product.addon","paymentLink.hero","summary.panel","summary.line","summary.total","form.field","form.label","form.help","coupon.input","input.base","input.error","button.primary","button.secondary","payment.methods","payment.method","payment.method.icon","payment.method.label","payment.method.meta","payment.method.fee","payment.method.indicator","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.launcher","embed.launcher.icon","embed.productCard","embed.productCard.image","embed.productCard.title","embed.productCard.price","embed.cart","embed.cart.row","embed.cart.summary","embed.modal","embed.modal.header","embed.modal.close","embed.skeleton","embed.loader","embed.branding"]),oi(["product.title","product.price","summary.total","payment.method.label","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.modal.close","embed.branding"]),fo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),er=fo().trim().min(1).max(200).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS color or gradient"),tr=fo().trim().min(1).max(400).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS box-shadow value"),nr=oi(["Inter","Geist","Manrope","Plus Jakarta Sans","DM Sans","Space Grotesk","Sora","IBM Plex Sans","JetBrains Mono","Arial","System UI"]),or=fo().trim().min(1).max(60).regex(/^[A-Za-z0-9 +\-_]+$/,"Use a Google Fonts family name"),ir=fo().url(),rr=Vo({brand:Vo({logoUrl:ir.optional().nullable(),logoDarkUrl:ir.optional().nullable(),logoMaxHeight:Uo().int().min(16).max(80).optional(),faviconUrl:ir.optional().nullable()}).strict().optional(),color:Vo({brand:Qi.optional(),brandContrast:Qi.optional(),background:Qi.optional(),surface:Qi.optional(),surfaceRaised:Qi.optional(),text:Qi.optional(),textMuted:Qi.optional(),border:Qi.optional(),focus:Qi.optional(),success:Qi.optional(),warning:Qi.optional(),error:Qi.optional()}).strict().optional(),typography:Vo({fontFamily:nr.optional(),googleFontFamily:or.optional(),baseSize:Uo().int().min(12).max(18).optional()}).strict().optional(),shape:Vo({buttonRadius:Uo().int().min(0).max(24).optional(),inputRadius:Uo().int().min(0).max(24).optional(),cardRadius:Uo().int().min(0).max(28).optional()}).strict().optional(),spacing:Vo({density:Vi.optional(),controlHeight:Uo().int().min(36).max(56).optional()}).strict().optional(),component:Vo({primaryButton:Vo({background:Qi.optional(),text:Qi.optional()}).strict().optional(),input:Vo({background:Qi.optional(),border:Qi.optional(),focusRing:er.optional()}).strict().optional(),summary:Vo({background:Qi.optional()}).strict().optional(),paymentMethod:Vo({background:er.optional(),cardBackground:er.optional(),border:er.optional(),selectedBackground:er.optional()}).strict().optional(),productCard:Vo({background:er.optional(),border:er.optional(),shadow:tr.optional()}).strict().optional(),productImage:Vo({background:er.optional(),border:er.optional(),icon:er.optional()}).strict().optional(),brandAvatar:Vo({background:er.optional(),text:Qi.optional(),border:er.optional()}).strict().optional(),pill:Vo({background:er.optional(),border:er.optional(),text:Qi.optional()}).strict().optional(),errorBanner:Vo({background:er.optional(),border:er.optional(),text:Qi.optional()}).strict().optional(),warningBanner:Vo({background:er.optional(),border:er.optional(),text:Qi.optional()}).strict().optional(),radio:Vo({idleRing:er.optional(),checkedFill:Qi.optional(),checkedIcon:Qi.optional()}).strict().optional(),divider:Vo({color:er.optional()}).strict().optional()}).strict().optional(),paymentLink:Vo({heroImageUrl:ir.optional().nullable(),heroPosition:Hi.optional()}).strict().optional(),embed:Vo({launcher:Vo({background:er.optional(),text:Qi.optional(),radius:Uo().int().min(0).max(28).optional(),paddingX:Uo().int().min(8).max(32).optional(),paddingY:Uo().int().min(6).max(24).optional(),shadow:tr.optional()}).strict().optional(),productCard:Vo({background:er.optional(),border:er.optional(),imageRadius:Uo().int().min(0).max(24).optional(),padding:Uo().int().min(8).max(32).optional()}).strict().optional(),cart:Vo({background:er.optional(),rowBorder:er.optional(),itemSpacing:Uo().int().min(4).max(28).optional()}).strict().optional(),modal:Vo({background:er.optional(),radius:Uo().int().min(0).max(32).optional(),maxWidth:Uo().int().min(360).max(960).optional(),shadow:tr.optional()}).strict().optional(),backdrop:Vo({color:er.optional(),blur:Uo().int().min(0).max(24).optional(),opacity:Uo().min(0).max(1).optional()}).strict().optional(),skeleton:Vo({background:er.optional(),shimmer:er.optional()}).strict().optional(),spinner:Vo({color:er.optional()}).strict().optional(),closeButton:Vo({style:Ki.optional()}).strict().optional(),mobile:Vo({layout:Xi.optional()}).strict().optional()}).strict().optional()}).strict(),ar=Vo({mode:Gi.default("system"),fontSource:oi(["curated"]).default("curated")}).strict(),sr=oi(["standalone","bundle","pointer"]),lr=Vo({name:fo().trim().min(1).max(80),fingerprint:fo().trim().min(1).max(128)}).strict(),ur=Vo({type:ri("shoppex.style_theme"),surface:ri("checkout"),format_version:Ho([ri(1),ri(2)]),name:fo().trim().min(1).max(80),description:fo().trim().max(240).optional(),embed_design:Wi.default("current"),token_schema_version:ri(1),tokens:rr.default({}),custom_css:fo().max(2e4).default(""),settings:ar.default({mode:"system",fontSource:"curated"}),_meta:ti(fo(),Lo()).optional()}).strict(),cr=(Vo({type:ri("shoppex.style_theme"),surface:Ji,format_version:Ho([ri(1),ri(2)]),name:fo().trim().min(1).max(80),description:fo().trim().max(240).optional(),embed_design:Wi.default("current"),token_schema_version:ri(1),tokens:rr.default({}),custom_css:fo().max(2e4).default(""),settings:ar.default({mode:"system",fontSource:"curated"}),share_mode:sr.default("standalone"),parent_hint:lr.optional(),bundled_parent:ur.optional(),_meta:ti(fo(),Lo()).optional()}).strict(),Vo({theme_id:fo().uuid().nullable(),surface:Ji,embed_design:Wi,token_schema_version:ri(1),revision:Uo().int().min(1),tokens:rr,custom_css:fo(),css_variables:ti(fo(),fo())}).strict(),Vo({theme_id:fo().uuid().nullable(),parent_theme_id:fo().uuid().nullable(),surface:ri("embed"),embed_design:Wi,token_schema_version:ri(1),revision:Uo().int().min(1),parent_revision:Uo().int().min(1).nullable(),tokens:rr,custom_css:fo(),css_variables:ti(fo(),fo())}).strict(),Vo({shop_id:fo().uuid(),product_id:fo().uuid().nullable(),product_group_id:fo().uuid().nullable(),payment_link_id:fo().uuid().nullable(),invoice_id:fo().nullable()}).strict(),Vo({embed_runtime:fo().min(16).max(128),embed_design:Wi,revision:Uo().int().min(1),parent_revision:Uo().int().min(1).nullable(),theme_id:fo().uuid().nullable(),css_variables:ti(fo(),fo()),custom_css:fo()}).strict(),Vo({embed_design:Wi.optional(),embed_style_revision:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...Z(t)})}(Ro,e)}().int().min(1).optional(),embed_runtime:fo().min(16).max(128).optional(),preview:Zo().optional()}).strict(),oi(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal"]),oi(["layout.header.before","layout.header.after","layout.overlay","home.hero.after","home.grid.before","product.buybox.after","layout.footer.before","floating.bottom_right"])),dr=(oi(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal"]),fo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),pr=oi(["static","marquee"]),fr=oi(["brand_blue","emerald","sunset","rose","charcoal","custom"]),mr=oi(["hide","message"]),hr=oi(["compact","comfortable"]),_r=oi(["subtle","outline","solid"]),yr=oi(["minimal","boxed"]),gr=oi(["indigo","emerald","amber","rose","slate","custom"]),br=oi(["compact","feature","alert"]),vr=oi(["compact","comfortable"]),wr=oi(["subtle","outline","solid"]),Sr=oi(["sparkles","megaphone","gift","truck","shield","support","none"]),kr=oi(["show","hide"]),zr=oi(["midnight","ocean","ember","forest","custom"]),xr=oi(["delay","exit_intent"]),Or=fo().trim().refine(e=>{if(e.startsWith("/"))return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}},'Use a valid absolute URL or a path starting with "/"'),Er=fo().trim().refine(e=>{const t=new Date(e);return!Number.isNaN(t.getTime())},"Use a valid date and time"),Tr=Vo({text:fo().trim().min(1,"Text is required").max(160,"Text must be 160 characters or fewer"),linkLabel:fo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Or.optional().nullable(),dismissible:Zo().default(!1),displayMode:pr.default("marquee"),themePreset:fr.default("custom"),animationSpeedSeconds:Uo().int().min(8).max(40).default(30),backgroundColor:dr.default("#111827"),textColor:dr.default("#f9fafb")}),$r=Vo({text:fo().trim().min(1,"Text is required").max(120,"Text must be 120 characters or fewer"),endAt:Er,linkLabel:fo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Or.optional().nullable(),dismissible:Zo().default(!1),themePreset:fr.default("brand_blue"),expiredBehavior:mr.default("hide"),expiredMessage:fo().trim().max(120,"Expired message must be 120 characters or fewer").optional().nullable(),density:hr.default("compact"),ctaStyle:_r.default("subtle"),timerStyle:yr.default("boxed"),backgroundColor:dr.default("#111827"),textColor:dr.default("#f9fafb")}),Ar=Vo({eyebrow:fo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:fo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:fo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),linkLabel:fo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Or.optional().nullable(),themePreset:gr.default("indigo"),layoutStyle:br.default("feature"),density:vr.default("comfortable"),ctaStyle:wr.default("outline"),icon:Sr.default("sparkles"),iconVisibility:kr.default("show"),backgroundColor:dr.default("#111827"),textColor:dr.default("#f9fafb"),accentColor:dr.default("#818cf8")}),Ir=Vo({title:fo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer").default("Recent purchases"),lookbackHours:Uo().int().min(1).max(168).default(24),cooldownSeconds:Uo().int().min(5).max(300).default(20),maxItems:Uo().int().min(1).max(20).default(8),anonymizeMode:oi(["first_name_city","first_name_country","initial_country","anonymous"]).default("first_name_city"),includedProductIds:Jo(fo().min(1)).max(50).default([])}),Nr=Vo({eyebrow:fo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:fo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:fo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),couponCode:fo().trim().min(2,"Coupon code is required").max(40,"Coupon code must be 40 characters or fewer"),primaryButtonLabel:fo().trim().min(1,"Primary button label is required").max(24,"Primary button label must be 24 characters or fewer").default("Copy code"),secondaryButtonLabel:fo().trim().min(1,"Secondary button label is required").max(24,"Secondary button label must be 24 characters or fewer").default("Maybe later"),disclaimer:fo().trim().max(100,"Disclaimer must be 100 characters or fewer").optional().nullable(),themePreset:zr.default("midnight"),trigger:xr.default("delay"),delaySeconds:Uo().int().min(0).max(60).default(6),showOncePerSession:Zo().default(!0),reminderHours:Uo().int().min(1).max(720).default(24),backgroundColor:dr.default("#111827"),textColor:dr.default("#f8fafc"),accentColor:dr.default("#7c9cff"),heroImageUrl:Or.optional().nullable(),discountDisplay:fo().trim().max(24,"Discount display must be 24 characters or fewer").optional().nullable(),expiresAt:Er.optional().nullable()}),Cr=Vo({type:ri("announcement_bar"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Tr}),Pr=Vo({type:ri("recent_purchase_popup"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Ir}),Rr=Vo({type:ri("countdown_bar"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:$r}),Ur=Vo({type:ri("promo_info_card"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Ar}),qr=Vo({type:ri("coupon_popup_modal"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Nr}),jr=(Xo("type",[Cr,Rr,Ur,Pr,qr]),Xo("type",[Cr.extend({id:fo().min(1)}),Rr.extend({id:fo().min(1)}),Ur.extend({id:fo().min(1)}),Pr.extend({id:fo().min(1)}),qr.extend({id:fo().min(1)})]),new Set(["amount","currency","invoice_id","customer_email","id","email","price","price_usd","product_name","quantity"].map(e=>e.toLowerCase())),ti(fo(),Lo())),Dr=Ho([fo(),Uo()]),Zr=Vo({default_value:fo().optional(),min_length:Uo().optional(),name:fo(),placeholder:fo().optional(),regex:fo().optional(),required:Zo(),type:fo()}),Mr=Vo({id:fo(),price:Uo(),quantity:Uo(),title:fo()}),Lr=Vo({addons:Jo(Mr).optional(),available_addons:Jo(Lo()).optional(),cloudflare_image_id:fo().nullable(),created_at:fo().optional(),currency:fo(),custom_fields:jr.nullable().optional(),custom_fields_config:Jo(Zr).nullable().optional(),delivery_instruction:Lo().optional(),delivery_instruction_config:Lo().optional(),delivery_instruction_label:Lo().optional(),delivery_text:fo().nullable().optional(),delivery_time:Uo().optional(),description:fo().nullable(),discount_percent:Uo().optional(),discount_display:Uo().optional(),discounted_total_display:Uo().optional(),gateways:Jo(fo()).nullable().optional(),id:fo().optional(),image_name:fo().nullable(),image_storage:fo().optional(),line_item_id:fo().nullable().optional(),pay_what_you_want:Zo().optional(),price:fo().optional(),price_display:Dr,quantity:Uo(),quantity_max:Uo().optional(),quantity_min:Uo().optional(),recurring_interval:fo().nullable().optional(),recurring_interval_count:Uo().nullable().optional(),redirect_link:fo().nullable().optional(),redirect_time:Uo().nullable().optional(),service_text:fo().nullable().optional(),setup_cost:fo().optional(),slug:fo().optional(),status:fo().nullable().optional(),subtype:fo().nullable().optional(),terms_of_service:fo().nullable().optional(),title:fo(),total:Uo(),trial_period:Uo().nullable().optional(),type:fo().nullable().optional(),uniqid:fo().nullable(),unit_price:Uo().optional(),unit_price_display:Dr.optional(),unit_quantity:Uo(),updated_at:fo().optional(),variant_title:fo().nullable().optional(),video_link:fo().nullable().optional(),volume_discounts:Lo().optional(),warranty_days:Uo().nullable().optional(),warranty_text:fo().nullable().optional()}),Fr=Vo({amount:Uo(),gateway:fo()}),Br=Vo({custom_tip_enabled:Zo().optional(),enabled:Zo(),preset_percentages:Jo(Uo()).optional()}),Yr=Vo({allow_partial_payment:Zo().optional(),auto_apply:Zo().optional(),available:fo(),currency:fo()}),Jr=Vo({affiliate_code:fo().nullable().optional(),already_paid:Dr.nullable().optional(),amount_due:Dr.nullable().optional(),currency:fo().nullable().optional(),discount:Dr.nullable().optional(),discount_label:fo().nullable().optional(),gateway_fee:Dr.nullable().optional(),platform_fee:Dr.nullable().optional(),subtotal:Dr.nullable().optional(),tip:Dr.nullable().optional(),total:Dr.nullable().optional()}),Wr=Vo({active:Zo(),expires_at:fo()}),Vr=Vo({faq_url:fo().nullable(),support_email:fo().nullable(),support_url:fo().nullable(),telegram_invite:fo().nullable()}),Gr=Vo({currency:fo().nullable().optional(),enabled:Zo(),max_amount:Uo().nullable().optional(),min_amount:Uo().nullable().optional(),reason:oi(["BELOW_MIN_AMOUNT","ABOVE_MAX_AMOUNT"]).nullable().optional()}),Hr=Vo({delivered_items:Jo(Lo()),downloads:Jo(Lo()),external_urls:Jo(Lo()),license_keys:Jo(Lo()),tracking_codes:Jo(Lo())}),Kr=Vo({active:Zo().optional(),attempt_id:fo().optional(),buyer_actionable:Zo().nullable().optional(),crypto_currency:fo().nullable().optional(),currency:fo().optional(),expected_amount:fo().nullable().optional(),expected_crypto_amount:fo().nullable().optional(),last_checked_at:fo().optional(),missing_amount:fo().nullable().optional(),missing_crypto_amount:fo().nullable().optional(),provider_reference:fo().nullable().optional(),provider_status:fo().nullable().optional(),received_amount:fo().nullable().optional(),received_crypto_amount:fo().nullable().optional(),shortfall_percent:fo().nullable().optional()}),Xr=Vo({created_at:fo().nullable(),details:fo().nullable(),id:fo(),invoice_id:fo(),status:fo().nullable()}),Qr=Vo({billing_address_mode:oi(["INHERIT","REQUIRED","DISABLED"]).optional(),button_label:fo().nullable().optional(),display_name:fo().nullable().optional(),gateway:fo(),hide_provider_attribution:Zo().optional(),icon_url:fo().nullable().optional(),terms_mode:oi(["INHERIT","REQUIRED","DISABLED"]).optional()}),ea=Vo({custom_fields:Jo(Lo()).optional(),description:fo().nullable(),display_order:Uo(),icon_preset:fo().nullable(),icon_url:fo().nullable(),id:fo(),instructions:fo().nullable(),is_active:Zo().optional(),name:fo(),payment_type:oi(["INSTRUCTIONS","REDIRECT"]),redirect_url:fo().nullable(),require_proof:Zo(),void_after_hours:Uo()}),ta=Vo({email:Vo({masked:fo().nullable(),persisted:Zo(),required_for_provider_session:Zo().optional()})}),na=Vo({amount:fo().nullable(),confirmations:Uo().nullable(),created_at:Uo().optional(),hash:fo().nullable(),status:fo().optional()}),oa=Vo({conf:Vo({partial:Uo().optional(),void:Uo(),waiting_for_confirmations:Uo().optional()}),gateways:Jo(fo())}),ia=Vo({invoice_payable:Zo(),resumable:Zo(),resumable_gateway:fo().nullable(),gateway:fo().nullable().optional(),crypto_gateway:fo().nullable().optional(),processor:fo().nullable().optional(),flow_type:fo().nullable().optional(),status:fo().nullable().optional(),provider_reference:fo().nullable().optional(),provider_reference_type:fo().nullable().optional(),capture_id:fo().nullable().optional(),manual_confirmation_pending:Zo().optional(),payment_method_switch_locked:Zo().optional(),awaiting_payment_method:Zo().optional(),started_at:Uo().nullable().optional(),completed_at:Uo().nullable().optional()}),ra=(Vo({already_paid_amount:Dr.nullable().optional(),apm_method:fo().nullable().optional(),blockchain:fo().nullable(),buyer_identity:ta.nullable().optional(),checkout_tipping:Br.nullable().optional(),country_regulations:fo().nullable().optional(),coupon_applied:Zo().optional(),crypto_mode:fo().nullable().optional(),crypto_transactions:Jo(na).optional(),currency:fo().nullable(),custom_fields:jr.nullable().optional(),custom_gateways:Jo(ea).optional(),customer_balance:Yr.nullable().optional(),customer_email_masked:fo().nullable().optional(),dark_mode:Ho([ri(0),ri(1)]).optional(),delivery:Hr.optional(),delivery_info:Hr.optional(),discount:Uo().optional(),discount_display:Dr.optional(),eligible_gateways:Jo(fo()).optional(),environment:fo().optional(),fee_breakdown:jr.nullable().optional(),gateway:fo().nullable(),gateway_data:jr.nullable().optional(),gateway_eligibility:ti(fo(),Gr).optional(),gateway_fee_previews:Jo(Fr).optional(),gateways_available:Jo(fo()),license:Ho([jr,ri(!1)]).optional(),name:fo().nullable(),paddle_token:fo().nullable().optional(),paddle_transaction_id:Lo().optional(),payment_link_id:fo().nullable().optional(),payment_method_overrides:Jo(Qr).optional(),payment_session_state:ia.nullable().optional(),polling:Wr,pricing_breakdown:Jr.nullable().optional(),product:Jo(Lr).optional(),quantity:Uo().nullable(),rates_snapshot:ti(fo(),Uo()).optional(),remaining_amount:Dr.nullable().optional(),selected_gateway:fo().nullable().optional(),shop_checkout_ambient_color:fo().nullable().optional(),shop_cloudflare_image_id:fo().nullable(),shop_domain:fo().nullable().optional(),shop_force_paypal_email_delivery:Ho([ri(0),ri(1)]).optional(),shop_image_name:fo().nullable(),shop_image_storage:fo().nullable().optional(),shop_payment_gateways_fees:Jo(jr).optional(),shop_paypal_credit_card:Ho([ri(0),ri(1)]).optional(),shop_return_url:fo().nullable().optional(),shop_slug:fo().nullable().optional(),shop_terms_enabled:Zo().optional(),shop_terms_of_service:fo().nullable().optional(),shop_terms_url:fo().nullable().optional(),shop_walletconnect_id:fo().nullable().optional(),status:fo().nullable(),status_history:Jo(Xr).optional(),status_history_legacy:Jo(Xr).optional(),status_history_raw:Jo(Xr).optional(),stripe_publishable_key:fo().nullable().optional(),stripe_user_id:fo().nullable().optional(),subtotal:Uo().optional(),subtype:fo().nullable().optional(),support:Vr.optional(),theme:fo().optional(),tip_amount:Dr.nullable().optional(),tip_amount_display:Dr.nullable().optional(),tip_metadata:Lo().optional(),total:Dr,total_conversions:jr.optional(),total_display:Dr,type:fo().nullable(),underpayment:Kr.nullable().optional(),underpayment_status:fo().nullable().optional(),uniqid:fo(),void_times:Jo(oa).optional(),addons:Lo().optional(),affiliate_data:Lo().optional(),affiliate_revenue_customer_id:fo().nullable().optional(),bill_info:Lo().optional(),binance_checkout_url:fo().nullable().optional(),binance_invoice_id:fo().nullable().optional(),binance_qrcode:fo().nullable().optional(),bundle_config:Lo().optional(),bundles:Lo().optional(),cashapp_cashtag:fo().nullable().optional(),cashapp_note:fo().nullable().optional(),cashapp_qrcode:fo().nullable().optional(),created_at:fo().optional(),crypto_address:fo().nullable().optional(),crypto_amount:Dr.optional(),crypto_confirmations_needed:Uo().nullable().optional(),crypto_exchange_rate:Dr.nullable().optional(),crypto_received:Dr.optional(),crypto_uri:fo().nullable().optional(),developer_invoice:Lo().optional(),developer_return_url:fo().nullable().optional(),developer_title:fo().nullable().optional(),exchange_rate:Dr.nullable().optional(),external_order_id:fo().nullable().optional(),lex_order_id:fo().nullable().optional(),lex_payment_method:fo().nullable().optional(),paydash_payment_id:fo().nullable().optional(),paypal_apm:fo().nullable().optional(),paypal_email_delivery:Zo().optional(),paypal_fee:Dr.nullable().optional(),paypal_order_id:fo().nullable().optional(),paypal_payer_email:fo().nullable().optional(),paypal_subscription_id:fo().nullable().optional(),paypal_subscription_link:fo().nullable().optional(),perfectmoney_id:fo().nullable().optional(),product_addons:Lo().optional(),product_id:fo().nullable().optional(),product_title:fo().nullable().optional(),product_type:fo().nullable().optional(),product_variants:Lo().optional(),recurring_billing_id:fo().nullable().optional(),skrill_link:fo().nullable().optional(),skrill_sid:fo().nullable().optional(),status_details:Lo().optional(),stripe_apm:fo().nullable().optional(),stripe_client_secret:fo().nullable().optional(),stripe_id:fo().nullable().optional(),stripe_price_id:fo().nullable().optional(),subscription:Lo().optional(),subscription_id:fo().nullable().optional(),sumup_id:fo().nullable().optional(),telegram_stars_payment_link:fo().nullable().optional(),telegram_stars_payment_note:fo().nullable().optional(),updated_at:fo().optional(),virtual_payments_id:fo().nullable().optional(),void_details:Lo().optional()}).catchall(Lo()),fo().nullable()),aa=ti(fo(),Lo()),sa=Vo({logo_url:ra,primary_color:fo(),secondary_color:fo(),accent_color:fo()}),la=Vo({attachment_image_id:Vo({cloudflare_image_id:ra}).nullable()}),ua=Vo({attachment_imageId:Vo({cloudflareImageId:ra}).nullable()}),ca=Vo({uniqid:fo(),status:fo(),total:fo(),total_display:ra,currency:fo(),created_at:fo(),line_items:Jo(Vo({product_title:ra,quantity:Uo(),product:la.nullable()}))}),da=Vo({uniqid:fo(),status:fo(),total:fo(),totalDisplay:ra,currency:fo(),createdAt:fo(),lineItems:Jo(Vo({productTitle:ra,quantity:Uo(),product:ua.nullable()}))}),pa=(Vo({invoices:Jo(da),pagination:Vo({page:Uo(),limit:Uo(),total:Uo(),has_more:Zo()})}),Vo({gateway:fo(),blockchain:ra,cryptoAddress:ra,apmMethod:ra})),fa=(Vo({id:fo(),uniqid:fo(),status:fo(),statusDetails:ra,total:fo(),totalDisplay:ra,subtotal:fo(),discount:fo(),discountDisplay:ra,tax:fo(),taxPercentage:fo(),currency:fo(),createdAt:fo(),updatedAt:fo(),gatewayUpdatedAt:ra,customFields:aa.nullable(),balancePaidAmount:fo(),currentPaymentAttemptId:ra,lineItems:Jo(Vo({id:fo(),productTitle:fo(),productType:fo(),variantTitle:ra,unitPrice:fo(),quantity:Uo(),total:fo(),deliverySummary:Vo({codes:Jo(fo()),links:Jo(Vo({label:fo(),value:fo(),href:ra.optional()})),notes:Jo(fo())}).nullable(),deliveredAt:ra,customFields:aa.nullable(),product:Vo({uniqid:fo(),slug:ra,serviceText:ra,deliveryText:ra,attachment_imageId:Vo({cloudflareImageId:ra}).nullable()}).nullable()})),currentPayment:pa.nullable(),payments:Jo(pa)}),Vo({quote:Vo({enabled:Zo(),currency:fo(),min_amount:fo(),max_amount:ra,bonus_tiers:Jo(Vo({min_amount:fo(),bonus_percent:Uo()}))})}),Vo({invoice_id:fo(),url:fo()}),Vo({id:fo(),type:fo(),status:fo(),amount:ra,currency:ra,coupon_code:ra,reason:fo(),trigger_reference_type:fo(),trigger_reference_id:fo(),created_at:Uo(),fulfilled_at:Uo().nullable(),expires_at:Uo().nullable()})),ma=Vo({summary:Vo({available:fo(),pending:fo(),lifetime_earned:fo(),redeemed:ra,currency:fo()}),activity:Jo(fa),earned_after_invoice:Jo(fa),pending_after_invoice:Jo(fa)}),ha=Vo({id:fo(),uniqid:fo(),code:fo(),url:ra,total_clicks:Uo(),total_sales:Uo(),total_revenue:fo(),is_active:Zo(),is_approved:Zo(),created_at:ra,updated_at:ra}),_a=Vo({customer:Vo({id:fo(),email:fo(),name:ra}).nullable(),state:fo(),can_edit_custom_code:Zo(),custom_code_edit_disabled_reason:ra,commission_shareback:Vo({enabled:Zo(),percent:Uo(),max_percent:Uo()}),link:ha.nullable(),links:Jo(ha),preferred_payout:Vo({asset:fo(),network:fo(),address:fo()}).nullable(),balance_currency:fo(),balances:Vo({pending:fo(),available:fo(),requested:fo(),converted:fo(),paid:fo(),approved_total:fo()}),commissions:Jo(Vo({id:fo(),invoice_id:fo(),commission_amount:fo(),base_amount:fo(),discount_amount:fo(),status:fo(),created_at:ra,paid_at:ra,converted_at:ra})),claims:Jo(Vo({id:fo(),type:fo(),status:fo(),amount:fo(),currency:fo(),allocations:Jo(Vo({source_type:fo(),commission_id:ra,adjustment_id:ra,amount:fo()})),wallet_transaction_id:ra,payout_asset:ra,payout_network:ra,payout_address:ra,note:ra,metadata:Lo(),completed_at:ra,rejected_at:ra,cancelled_at:ra,created_at:ra,updated_at:ra}))}),ya=Vo({uniqid:fo(),status:fo(),gateway:fo(),current_period_start:fo(),current_period_end:fo(),trial_end:ra,cancel_at_period_end:Zo(),canceled_at:ra,created_at:fo(),plan:Vo({id:fo(),uniqid:fo(),name:fo(),price:fo(),currency:fo(),interval:fo(),interval_count:Uo(),trial_days:Uo()}).nullable(),payment_method:Vo({id:fo(),gateway:fo(),type:fo(),card_brand:ra,card_last4:ra,card_exp_month:Uo().nullable(),card_exp_year:Uo().nullable(),is_default:Zo()}).nullable(),actions:Vo({can_pause:Zo(),can_resume:Zo(),can_cancel:Zo(),can_manage_payment_method:Zo()})}),ga=(Vo({shop:Vo({id:fo(),slug:fo(),name:fo(),currency:fo(),branding:sa}),customer:Vo({email:fo(),name:fo()}),stats:Vo({invoices_count:Uo(),licenses_count:Uo(),deliverables_count:Uo(),tickets_count:Uo()}),wallet:Vo({available:fo(),total:fo(),hold:fo(),currency:fo(),enabled:Zo()}).nullable(),rewards:ma,affiliate:_a,invoices:Jo(ca),subscriptions:Jo(ya),licenses:Jo(Vo({uniqid:fo(),license_key:fo(),hardware_id:ra,expires_at:Uo().nullable(),product:Vo({title:fo().optional()}).optional()})),deliverables:Jo(Vo({id:fo(),invoice_uniqid:fo(),product_title:fo(),kind:oi(["file","serial","license"]),label:fo(),value:fo(),href:ra,created_at:fo()})),tickets:Jo(Vo({uniqid:fo(),title:fo(),status:fo(),updated_at:fo(),created_at:ra}))}),fo().nullable()),ba=Vo({id:fo(),uniqid:fo(),title:fo()}),va=Vo({id:fo(),title:ga}),wa=Vo({id:fo(),title:ga,price:Uo(),stock:Uo().nullable(),commission_percent:Uo().nullable(),wholesale_price:Uo().nullable(),auto_fulfilled_enabled:Zo(),min_resale_price:Uo().nullable(),max_resale_price:Uo().nullable(),min_quantity:Uo().nullable(),max_quantity:Uo().nullable()}),Sa=(Vo({products:Jo(Vo({id:fo(),uniqid:fo(),title:fo(),type:fo(),currency:fo(),price:Uo(),stock:Uo().nullable(),commission_percent:Uo().nullable(),wholesale_price:Uo().nullable(),auto_fulfilled_enabled:Zo(),min_resale_price:Uo().nullable(),max_resale_price:Uo().nullable(),min_quantity:Uo().nullable(),max_quantity:Uo().nullable(),variants:Jo(wa)}))}),Vo({balances:Vo({pending:Uo(),available:Uo(),requested:Uo(),converted:Uo(),paid:Uo(),approved_total:Uo()}),preferred_payout:Vo({asset:fo(),network:fo(),address:fo()}).nullable(),payout_requests:Jo(Vo({id:fo(),status:fo(),amount:Uo(),currency:ga,payout_asset:ga,payout_network:ga,payout_address:ga,note:ga,processing_mode:oi(["manual","invoice_funding","automatic"]).nullable(),funding_invoice:Vo({invoice_id:ga,invoice_uniqid:ga,invoice_status:ga,checkout_url:ga}).nullable(),created_at:fo(),updated_at:ga,completed_at:ga,rejected_at:ga,cancelled_at:ga}))}),Vo({id:fo(),name:fo(),slug:fo()})),ka=(Vo({summary:Vo({total:Uo(),available:Uo(),delivered:Uo(),revoked:Uo()}),items:Jo(Vo({id:fo(),transfer_id:fo(),reseller_relationship_id:fo(),status:fo(),merchant_shop:Sa,product:ba,variant:va.nullable(),serial_id:ga,delivered_to_email:ga,delivered_at:ga,created_at:fo()}))}),Vo({summary:Vo({available:Uo()}),items:Jo(Vo({id:fo(),transfer_id:fo(),reseller_relationship_id:fo(),serial_id:ga,serial:ga,merchant_shop:Sa,product:ba,variant:va.nullable(),created_at:fo()}))}),Vo({item:Vo({id:fo(),transfer_id:fo(),reseller_relationship_id:fo(),product_id:fo(),variant_id:ga,serial_id:ga,serial:ga,status:fo(),delivered_to_email:ga,delivered_at:ga,created_at:fo(),updated_at:fo()})}),Vo({id:fo(),reseller_relationship_id:fo(),invoice_id:ga,product_id:fo(),variant_id:ga,status:fo(),quantity:Uo(),wholesale_unit_price:Uo(),currency:fo(),created_at:fo(),updated_at:fo()})),za=(Vo({transfer:ka.extend({product:ba})}),Vo({id:fo(),uniqid:fo(),type:ga,status:ga,total:Uo(),currency:ga,checkout_url:fo(),created_at:ga}));Vo({transfers:Jo(ka.extend({product:ba,variant:va.nullable(),invoice:Vo({id:fo(),uniqid:fo(),status:ga,checkout_url:fo()}).nullable()}))}),Vo({transfer:ka,invoice:za});var xa=null,Oa=null;var Ea=null,Ta=null;function $a(e,t){const n=t?.shopId?.trim();return Ta=n||null,xa=null,Oa=null,Ea={storeSlug:e,locale:t?.locale,currency:t?.currency,apiBaseUrl:t?.apiBaseUrl??"https://api.shoppex.io",checkoutBaseUrl:t?.checkoutBaseUrl??"https://checkout.shoppex.io"}}function Aa(){if(!Ea)throw new n;return Ea}function Ia(){return null!==Ea}function Na(e){Ta=e}function Ca(){return Ta}function Pa(e){const t=e?.trim().toLowerCase()??"";return"true"===t||"1"===t||"yes"===t||"on"===t}function Ra(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):null}function Ua(e){if(!0===e)return!0;if("number"==typeof e&&Number.isFinite(e))return 0!==e;if("string"==typeof e){const t=e.trim().toLowerCase();return"true"===t||"1"===t}return!1}function qa(e){if(!e)return-1;if("string"==typeof e.type&&"SERIALS"===e.type.toUpperCase())return Ra(e.stock)??-1;const t=function(e){const t=Array.isArray(e.price_variants)?e.price_variants.map(e=>Ra(e.stock)):[];return t.length>0?t:Array.isArray(e.variants)?e.variants.map(e=>Ra(e.stock)):[]}(e);return t.length>0?t.some(e=>null===e||e<0)?-1:t.filter(e=>null!==e).reduce((e,t)=>e+Math.max(t,0),0):Ra(e.stock)??-1}function ja(e){return!!function(e){return!!e&&(Ua(e.on_hold)||Ua(e.onHold)||Ua(e.is_on_hold)||Ua(e.isOnHold))}(e)||0===qa(e)}function Da(e){return!ja(e)}function Za(e=[]){const t=new Map;for(const n of e)n?.uniqid&&!t.has(n.uniqid)&&t.set(n.uniqid,n);return t}function Ma(e,t=[]){const n=t instanceof Map?t:Za(t);return(e.product_uniqids??[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})}function La(e=[]){return Array.from(Za(e).values())}function Fa(e){return e?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():""}function Ba(e){return e.trim().toLowerCase()}function Ya(e,t){const n=Fa(t).toLowerCase();n&&e.push(n)}function Ja(e){const t=[];Ya(t,e.title),Ya(t,e.slug??void 0),Ya(t,e.description);for(const n of e.product_highlights??[])Ya(t,n);for(const n of e.variants??[])Ya(t,n.title);for(const n of e.price_variants??[])Ya(t,n.title??n.label);return t}function Wa(e,t){const n=Ba(t);return!!n&&Ja(e).some(e=>e.includes(n))}function Va(e,t){const n=Ba(t);if(!n)return!1;const o=Fa(e.title).toLowerCase(),i=Fa(e.slug??e.name??void 0).toLowerCase(),r=Fa(e.description).toLowerCase();return o.includes(n)||i.includes(n)||r.includes(n)}function Ga(e,t){return 0!==e.length&&(!t||e.some(e=>Da(e)))}function Ha(e,t,n,o){const i=Ba(n);if(!i)return[];const r=!0===o?.hideOutOfStock,a=new Set,s=new Set,l=[],u=Za(e);for(const d of t){const e=d.uniqid??d.id;if(!e||s.has(e))continue;if(!Va(d,i))continue;const t=Ma(d,u);if(Ga(t,r)){s.add(e);for(const e of t)e?.uniqid&&a.add(e.uniqid);l.push({type:"group",group:d,products:t})}}const c=La(e);for(const d of c)d?.uniqid&&!a.has(d.uniqid)&&Wa(d,i)&&(r&&!Da(d)||(a.add(d.uniqid),l.push({type:"product",product:d})));return null!=o?.maxResults?l.slice(0,o.maxResults):l}function Ka(e,t,n,o){const i=Ha(e,t,n,o),r=new Set,a=[],s=e=>{e?.uniqid&&!r.has(e.uniqid)&&(o?.hideOutOfStock&&!Da(e)||(r.add(e.uniqid),a.push(e)))};for(const l of i)if("product"!==l.type)for(const e of l.products)s(e);else s(l.product);return null!=o?.maxResults?a.slice(0,o.maxResults):a}function Xa(e){if(e?.apiBaseUrl?.trim())return e.apiBaseUrl.replace(/\/+$/,"");const t=e?.hostname??("undefined"!=typeof window?window.location.hostname:"");if(t&&!function(e){if("localhost"===e||"127.0.0.1"===e||"::1"===e||e.endsWith(".localhost"))return!0;if(/^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e))return!0;if(/^192\.168\.\d{1,3}\.\d{1,3}$/.test(e))return!0;const t=e.match(/^172\.(\d{1,2})\.\d{1,3}\.\d{1,3}$/);if(t){const e=Number(t[1]);return e>=16&&e<=31}return!1}(t))return"https://api.shoppex.io";if("undefined"!=typeof window){const e=window.apiBaseUrl;if("string"==typeof e&&e.trim())return e.replace(/\/+$/,"")}return"http://localhost:3001".replace(/\/+$/,"")}function Qa(e){const t=e.name?.trim()??"",n=`${t?`Name: ${t}\n\n`:""}${e.message.trim()}`,o=e.maxLength??2e3;return n.slice(0,o)}var es=new Map,ts=new Map,ns={hits:0,misses:0};function os(e,t,n){const o=Date.now();es.set(e,{data:t,ttl:n,updatedAt:o,expiresAt:o+n})}async function is(e,t,n,o=()=>!0){const i=function(e){const t=es.get(e);return t||null}(e);if(i&&!function(e){return Date.now()>e.expiresAt}(i))return ns.hits+=1,i.data;if(i&&n.staleWhileRevalidate){if(ns.hits+=1,!ts.has(e)){const i=(async()=>{try{const i=await t();return o(i)&&os(e,i,n.ttl),i}finally{ts.delete(e)}})();ts.set(e,i)}return i.data}if(ts.has(e))return ts.get(e);ns.misses+=1;const r=(async()=>{try{const i=await t();return o(i)&&os(e,i,n.ttl),i}finally{ts.delete(e)}})();return ts.set(e,r),r}var rs=/:([A-Za-z0-9_]+)/g;function as(e,t){return e.replace(rs,(e,n)=>{const o=t[n];if(null==o)throw new Error(`Missing endpoint param: ${n}`);const i=String(o).trim();if(!i)throw new Error(`Endpoint param "${n}" must not be empty`);return encodeURIComponent(i)})}function ss(e){return`shoppex_${e}`}function ls(e){try{const t=localStorage.getItem(ss(e));return t?JSON.parse(t):null}catch{return null}}function us(e,t){try{localStorage.setItem(ss(e),JSON.stringify(t))}catch{console.warn("[shoppex] Failed to save to localStorage")}}function cs(e){try{localStorage.removeItem(ss(e))}catch{}}function ds(e){if("undefined"==typeof window)return null;const t=`presence_connection_${e}`,n=ls(t);if(n&&n.trim())return n;const o="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`spx_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;return us(t,o),o}async function ps(e){if(!Ia())return;if("undefined"==typeof window)return;if(function(e){const t=`client_error_${function(e){return[e.method,e.endpoint,e.statusCode??"none",e.message.trim().toLowerCase(),e.responseReceived?"response":"no-response"].join("|")}(e)}`,n=Date.now(),o=ls(t);return"number"==typeof o&&n-o<15e3||(us(t,n),!1)}(e))return;const t=Aa(),n=Ca(),o=n?as("/v1/storefront/shops/id/:id/ping",{id:n}):as("/v1/storefront/shops/:storeSlug/ping",{storeSlug:t.storeSlug}),i=JSON.stringify({event_type:"client_error",referer:document.referrer||void 0,connection_id:ds(t.storeSlug)??void 0,client_error:{source:e.source??"sdk",phase:e.phase??"request",endpoint:e.endpoint,method:e.method,message:e.message,status_code:e.statusCode,attempt_count:e.attemptCount,response_received:e.responseReceived??!1,page_url:e.pageUrl??window.location.href,request_url:e.requestUrl,online:e.online??("undefined"!=typeof navigator?navigator.onLine:void 0),visibility_state:e.visibilityState??("undefined"!=typeof document?document.visibilityState:void 0)}}),r=`${t.apiBaseUrl}${o}`;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const e=new Blob([i],{type:"application/json"});if(navigator.sendBeacon(r,e))return}await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0})}catch{}}var fs=1e4;async function ms(e){return new Promise(t=>setTimeout(t,e))}async function hs(e,t={}){const n=t.baseUrl?null:Aa(),{method:i="GET",body:r,timeout:a=fs,retries:s,baseUrl:l,cache:u}=t,c=s??("GET"===i?2:0),d=`${l??n?.apiBaseUrl??""}${e}`,p={"Content-Type":"application/json",Accept:"application/json"};let f=null;const m=async()=>{for(let t=0;t<=c;t++)try{const e=new AbortController,t=setTimeout(()=>e.abort(),a),n=await fetch(d,{method:i,headers:p,body:r?JSON.stringify(r):void 0,signal:e.signal});clearTimeout(t);const s=await _s(n);if(!n.ok){const e=n.statusText?`HTTP ${n.status}: ${n.statusText}`:`HTTP ${n.status}`;throw new o((s.data&&"object"==typeof s.data&&"error"in s.data&&"string"==typeof s.data.error?s.data.error:null)??(s.data&&"object"==typeof s.data&&"message"in s.data&&"string"==typeof s.data.message?s.data.message:null)??s.rawText??e,n.status)}if(204===n.status&&null===s.data)return{success:!0};if(!s.data||"object"!=typeof s.data||!("status"in s.data))throw new o("Invalid API response",n.status);return ys(s.data)}catch(e){let n=e instanceof Error?e:new Error(String(e));e instanceof DOMException&&"AbortError"===e.name&&(n=new o("Request timeout",408));const i=n instanceof o?n.statusCode:void 0;if(f={message:n.message,statusCode:i,isTransport:void 0===i||408===i},t<c){await ms(500*Math.pow(2,t));continue}}return{success:!1,message:f?.message??"Unknown error"}},h="GET"===i&&u&&u.ttl>0?await is(u.key??`GET:${d}`,m,{ttl:u.ttl,staleWhileRevalidate:u.staleWhileRevalidate},e=>e.success):await m(),_=f;return!h.success&&_?.isTransport&&await ps({endpoint:e,method:i,message:h.message??_.message,statusCode:_.statusCode,attemptCount:c+1,requestUrl:d,responseReceived:void 0!==_.statusCode&&408!==_.statusCode}),h}async function _s(e){const t=e;if("function"!=typeof t.text){if("function"==typeof t.json)try{return{data:await t.json(),rawText:null}}catch{return{data:null,rawText:null}}return{data:null,rawText:null}}try{const e=await t.text();if(!e)return{data:null,rawText:null};try{return{data:JSON.parse(e),rawText:null}}catch{const t=e.trim();return{data:null,rawText:t.length>0?t:null}}}catch{return{data:null,rawText:null}}}function ys(e){return e.status>=200&&e.status<300?{success:!0,data:e.data,...e.message?{message:e.message}:{}}:{success:!1,message:e.error??e.message??`Request failed with status ${e.status}`}}async function gs(e,t){return hs(e,{...t,method:"GET"})}async function bs(e,t,n){return hs(e,{...n,method:"POST",body:t})}var vs=3e5;async function ws(){const e=Aa(),t=await gs(as("/v1/storefront/shops/name/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`store:${e.storeSlug}`,ttl:vs,staleWhileRevalidate:!0}});return t.success&&t.data?(t.data.shop?.id&&Na(t.data.shop.id),{success:!0,data:t.data.shop}):{success:!1,message:t.message}}async function Ss(e){const t=Aa(),n=new URLSearchParams;Number.isFinite(e?.productsLimit)&&n.set("products_limit",String(Math.max(1,Math.floor(e?.productsLimit??0)))),"string"==typeof e?.productsCursor&&e.productsCursor.trim().length>0&&n.set("products_cursor",e.productsCursor);const o=n.size>0?`?${n.toString()}`:"",i=await gs(`${as("/v1/storefront/shops/name/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`storefront:${t.storeSlug}:${e?.productsLimit??"full"}:${e?.productsCursor??"start"}`,ttl:vs,staleWhileRevalidate:!0}});return i.success&&i.data?(i.data.shop?.id&&Na(i.data.shop.id),{success:!0,data:{shop:i.data.shop,products:i.data.products??[],products_pagination:i.data.products_pagination??null,groups:i.data.groups??[],items:i.data.items??[],categories:i.data.categories??[],addons:i.data.addons??{items:[]}}}):{success:!1,message:i.message}}var ks=12e4;function zs(e){if(e.variants&&e.variants.length>0)return e;const t=e.price_variants;return Array.isArray(t)&&0!==t.length?{...e,variants:t.map(e=>function(e){return{id:e.id,title:e.title??e.label??"",price:"number"==typeof e.price?e.price:Number(e.price)||0,stock:"number"==typeof e.stock?e.stock:void 0,quantity_min:e.quantity_min,quantity_max:e.quantity_max,quantityMin:e.quantityMin,quantityMax:e.quantityMax,image_id:e.image_id,imageId:e.imageId,cloudflare_image_id:e.cloudflare_image_id,cloudflareImageId:e.cloudflareImageId,image_url:e.image_url,imageUrl:e.imageUrl}}(e))}:e}async function xs(){const e=Aa(),t=await gs(as("/v1/storefront/products/public/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`products:${e.storeSlug}`,ttl:ks,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:La(t.data.products.map(zs))}:{success:!1,message:t.message,data:[]}}function Os(e){if(!e)return{};const t=Object.entries(e).filter(([,e])=>"string"==typeof e).sort(([e],[t])=>e.localeCompare(t));return Object.fromEntries(t)}function Es(e){const t={product_id:e.product_id,variant_id:e.variant_id,price_variant_id:e.price_variant_id??null,addons:(n=e.addons,n?.length?[...n].map(e=>({id:e.id,quantity:e.quantity??1})).sort((e,t)=>e.id.localeCompare(t.id)):[]),custom_fields:Os(e.custom_fields),unit_price:"number"==typeof e.price_data?.unit_price&&Number.isFinite(e.price_data.unit_price)?e.price_data.unit_price:null};var n;return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(t))}function Ts(e){return"string"==typeof e.line_id&&e.line_id.trim()?e:{...e,line_id:Es(e)}}var $s={cart:"cart",cartBackup:"cart_backup",meta:"cart_meta",metaBackup:"cart_backup_meta",coupon:"cart_coupon",couponBackup:"cart_coupon_backup"};function As(e){return`${$s[e]}_${Aa().storeSlug}`}function Is(e){return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(e))}function Ns(e){if(!Number.isFinite(e))throw new i("quantity must be a finite number");return Math.floor(e)}function Cs(e){const t=e?.trim().toUpperCase();return t||null}function Ps(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e=n,o="string"==typeof e.product_id?e.product_id.trim():"",i="string"==typeof e.variant_id?e.variant_id.trim():"",r=Number(e.quantity);if(!o||!i||!Number.isFinite(r)||r<1)continue;const a={line_id:"",product_id:o,variant_id:i,quantity:Math.floor(r)};if("string"==typeof e.price_variant_id&&(a.price_variant_id=e.price_variant_id),e.price_data&&"object"==typeof e.price_data){const t=e.price_data;"number"==typeof t.unit_price&&Number.isFinite(t.unit_price)&&(a.price_data={unit_price:t.unit_price})}Array.isArray(e.addons)&&(a.addons=e.addons),e.custom_fields&&"object"==typeof e.custom_fields&&!Array.isArray(e.custom_fields)&&(a.custom_fields=e.custom_fields),"string"==typeof e.title&&(a.title=e.title),"string"==typeof e.variant_title&&(a.variant_title=e.variant_title),"string"==typeof e.image_url&&(a.image_url=e.image_url),Array.isArray(e.addon_labels)&&(a.addon_labels=e.addon_labels.filter(e=>"string"==typeof e)),"number"==typeof e.max_quantity&&Number.isFinite(e.max_quantity)&&(a.max_quantity=e.max_quantity),"number"==typeof e.min_quantity&&Number.isFinite(e.min_quantity)&&(a.min_quantity=e.min_quantity),Ls(a),a.line_id=("string"==typeof e.line_id?e.line_id.trim():"")||Es(a),t.push(Ts(a))}return t}function Rs(){return ls(As("meta"))}function Us(){const e=ls(As("coupon"));return"string"!=typeof e?null:Cs(e)}function qs(e){const t=Cs(e);return t?(us(As("coupon"),t),t):(cs(As("coupon")),null)}function js(){cs(As("coupon"))}function Ds(e){const t=Ps(e);us(As("cart"),t);const n=Date.now(),o=Rs(),i={created_at:o?.created_at??n,last_modified:n,version:(o?.version??0)+1,checksum:Is(t)};us(As("meta"),i),0===t.length&&js()}function Zs(e,t){const n=Ps(e);us(As("cart"),n);const o=Date.now(),i=t??Rs(),r={created_at:i?.created_at??o,last_modified:o,version:i?.version??1,checksum:Is(n)};us(As("meta"),r)}function Ms(){return Ps(ls(As("cart")))}function Ls(e){const t=e.min_quantity;"number"==typeof t&&Number.isFinite(t)&&e.quantity<t&&(e.quantity=Math.floor(t));const n=e.max_quantity;"number"==typeof n&&Number.isFinite(n)&&e.quantity>n&&(e.quantity=Math.floor(n)),e.quantity<1&&(e.quantity=1)}function Fs(){cs(As("cart")),cs(As("meta")),js()}function Bs(){const e=Ms();us(As("cartBackup"),e);const t=Us();t?us(As("couponBackup"),t):cs(As("couponBackup"));const n=Rs();if(n)us(As("metaBackup"),n);else{const t=Date.now();us(As("metaBackup"),{created_at:t,last_modified:t,version:1,checksum:Is(e)})}}function Ys(){const e=Ms(),t=Rs(),n=Is(e);return t?t.checksum===n:(Zs(e,null),!0)}var Js="shoppex:affiliate_code:v1";function Ws(){return Date.now()}function Vs(e){const t=e?.trim().toLowerCase();return t||null}function Gs(e,t=30){const n=Vs(e);return n?(function(e){if("undefined"!=typeof window)try{window.localStorage.setItem(Js,JSON.stringify(e))}catch{}}({code:n,expiresAt:Ws()+(o=t,24*Math.max(1,o)*60*60*1e3)}),n):(Hs(),null);var o}function Hs(){if("undefined"!=typeof window)try{window.localStorage.removeItem(Js)}catch{}}function Ks(){const e=function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(Js);if(!e)return null;const t=JSON.parse(e);return t&&"string"==typeof t.code&&"number"==typeof t.expiresAt?t:null}catch{return null}}();return e?e.expiresAt<=Ws()?(Hs(),null):Vs(e.code):null}async function Xs(e){const t=Vs(e);if(!t)return{success:!1,data:{valid:!1,affiliate_code:null,discount_active:!1,discount_percent:0},message:"Affiliate code is required"};const n=await bs("/v1/storefront/affiliates/resolve",{shop_slug:Aa().storeSlug,code:t},{retries:0});if(!n.success)return n;if(!n.data?.valid||!n.data.affiliate_code){const e=!1===n.data?.program_enabled;return{success:!1,data:{valid:!1,...void 0!==n.data?.program_enabled?{program_enabled:n.data.program_enabled}:{},affiliate_code:null,discount_active:!1,discount_percent:0},message:n.message??(e?"Affiliate program is disabled for this shop.":"Invalid affiliate code.")}}return{success:!0,data:{valid:!0,...void 0!==n.data.program_enabled?{program_enabled:n.data.program_enabled}:{},affiliate_code:Vs(n.data.affiliate_code),discount_active:Boolean(n.data.discount_active),discount_percent:Number(n.data.discount_percent??0)},...n.message?{message:n.message}:{}}}function Qs(e){const t=e?.trim();return t||null}function el(e){const t=e?.trim();return t||null}function tl(e){const t=e?.trim().toUpperCase();return t&&/^[A-Z]{3}$/.test(t)?t:null}function nl(e){return tl(e.currency)??function(){if("undefined"==typeof window||!window.location)return null;const e="string"==typeof window.location.search?window.location.search:"";if(e)return tl(new URLSearchParams(e).get("currency"));const t="string"==typeof window.location.href?window.location.href:"";if(!t)return null;try{return tl(new URL(t,"https://storefront.shoppex.local").searchParams.get("currency"))}catch{return null}}()}function ol(e){const t=e?.trim()??"";if(!t)return"Checkout failed. Please try again.";if(il(t))return"Your cart is outdated. Please add the products again.";const n=t.match(/^HTTP\s+(\d{3})(?::\s*(.*))?$/i);if(n){const e=Number(n[1]),t=n[2]?.trim();return t&&t.length>0?`Checkout failed: ${t}`:e>=500?"Checkout is temporarily unavailable. Please try again.":400===e?"Checkout failed. Please check your details and try again.":401===e||403===e?"Checkout is currently unavailable for this request.":"Checkout failed. Please try again."}return/^internal server error$/i.test(t)?"Checkout is temporarily unavailable. Please try again.":t}function il(e){const t=e?.trim().toLowerCase()??"";return!!t&&(t.includes("product not found")||t.includes("product not available")||t.includes("products are no longer available")||t.includes("outdated product"))}function rl(e,t,n){const o=t?.trim();if(!o)return null;try{const t=new URL(e),i=new URL(o);if(t.origin!==i.origin)return null;const r=t.pathname.replace(/\/+$/,""),a=`${i.pathname.replace(/\/+$/,"")}/invoice/`.replace(/\/{2,}/g,"/");if(!r.startsWith(a))return null;const s=r.slice(a.length);if(!s||s.includes("/"))return null;if(n){const e=n.trim();if(!e||decodeURIComponent(s)!==e)return null}return t.toString()}catch{return null}}function al(e,t){const n=el(t.email),o="string"==typeof t.locale?t.locale.trim():"";if(!n&&!o)return e;try{const t=new URL(e);if(o&&t.searchParams.set("locale",o),n){const e=new URLSearchParams(t.hash.startsWith("#")?t.hash.slice(1):t.hash);e.set("shoppex_prefill_email",n),t.hash=e.toString()}return t.toString()}catch{return e}}function sl(e,t){const n=e?.invoice,o=e?.invoiceId?.trim()||e?.invoice_id?.trim()||e?.uniqid?.trim()||n?.invoiceId?.trim()||n?.invoice_id?.trim()||n?.uniqid?.trim();let i=e?.checkoutUrl?.trim()||e?.checkout_url?.trim()||e?.url_branded?.trim()||e?.url?.trim()||n?.checkoutUrl?.trim()||n?.checkout_url?.trim()||n?.url_branded?.trim()||n?.url?.trim();return!i&&o&&n&&(i=function(e,t){const n=e?.trim();if(!n)return null;try{const e=new URL(n);return e.pathname=`${e.pathname.replace(/\/+$/,"")}/invoice/${encodeURIComponent(t)}`.replace(/\/{2,}/g,"/"),e.search="",e.hash="",e.toString()}catch{return null}}(t,o)??void 0),o&&i?{invoiceId:o,checkoutUrl:i,rewards:e?.rewards??n?.rewards??null}:null}function ll(e,t){return"string"==typeof e?{...t,coupon:e}:e??t??{}}function ul(e){const t=e.affiliateCode??e.referralCode;return"string"==typeof t&&t.trim().length>0?t.trim().toLowerCase():Ks()}function cl(e){const t=e=>{const t=e?.trim();return t?"default"===t.toLowerCase()?null:t:null};return e.map(e=>({product_id:e.product_id,variant_id:t(e.variant_id),quantity:e.quantity,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1})),custom_fields:e.custom_fields,price_variant_id:e.price_variant_id||null}))}function dl(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function pl(...e){for(const t of e)if("string"==typeof t&&t.length>0)return t}function fl(e,t){const n=e,o=dl(n.rating)??dl(n.score)??0,i=pl(n.comment,n.message),r=pl(n.author,n.customer_name),a=n.created_at??n.createdAt,s="number"==typeof a||"string"==typeof a?String(a):"",l=pl(n.id,n.uniqid)??`review:${s||t}`;return{...n,id:l,rating:o,...i?{comment:i}:{},...r?{author:r}:{},created_at:s}}async function ml(e){const t=Aa(),n=new URLSearchParams;n.set("limit",String(100)),"string"==typeof e&&e.trim().length>0&&n.set("cursor",e);const o=`?${n.toString()}`,i=await gs(`${as("/v1/storefront/feedback/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`reviews:${t.storeSlug}:${e??"start"}:100`,ttl:12e4,staleWhileRevalidate:!0}});return i.success&&i.data?{success:!0,data:i.data}:{success:!1,message:i.message}}function hl(e){const t=e.trim();return t||null}var _l=3e5;var yl=3e5;async function gl(){const e=Aa(),t=await gs(as("/v1/storefront/shops/name/:storeSlug/menus",{storeSlug:e.storeSlug}),{cache:{key:`menus:${e.storeSlug}`,ttl:yl,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.menus}:{success:!1,message:t.message}}async function bl(e){const t=Aa(),n=await gs(as("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu:${t.storeSlug}:${e}`,ttl:yl,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}async function vl(e){return bl(e)}async function wl(e){const t=Aa(),n=await gs(as("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu-slot:${t.storeSlug}:${e}`,ttl:yl,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}function Sl(e){return function(e){const t=h[e];return[t.title,...t.aliases]}(e)}async function kl(e,t){if(!Ia())return;if("undefined"==typeof document)return;const n=Aa(),o=ds(n.storeSlug);try{const i=as("/v1/storefront/shops/:storeSlug/ping",{storeSlug:n.storeSlug});await fetch(`${n.apiBaseUrl}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({referer:document.referrer||void 0,cart_value:e??void 0,item_count:t??void 0,connection_id:o??void 0})})}catch{}}async function zl(){if(!Ia())return{success:!1,message:"SDK not initialized"};const e=Aa(),t=Ca();return gs(t?as("/v1/storefront/shops/id/:id/recent-sales",{id:t}):as("/v1/storefront/shops/:storeSlug/recent-sales",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function xl(){if(!Ia())return{success:!1,message:"SDK not initialized"};const e=Aa(),t=Ca();return gs(t?as("/v1/storefront/shops/id/:id/online-users",{id:t}):as("/v1/storefront/shops/:storeSlug/online-users",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function Ol(){if(!Ia())return{success:!1,message:"SDK not initialized"};if("undefined"==typeof document)return{success:!1,message:"Document is not available"};const e=Aa(),t=Ca();return bs(t?as("/v1/storefront/shops/id/:id/ping",{id:t}):as("/v1/storefront/shops/:storeSlug/ping",{storeSlug:e.storeSlug}),{referer:document.referrer||void 0,connection_id:ds(e.storeSlug)??void 0},{retries:0,timeout:5e3})}function El(e,t){const n=Aa();return new Intl.NumberFormat(t??n.locale??"en-US",{style:"currency",currency:e??n.currency??"USD"})}function Tl(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function $l(e){return Tl(e)&&Tl(e.theme)?{...e,version:"number"==typeof e.version?e.version:0,revision:"number"==typeof e.revision?e.revision:0,theme:{...e.theme,content:Tl(e.theme.content)?e.theme.content:{},layout:Tl(e.theme.layout)?e.theme.layout:{},style_slots:Tl(e.theme.style_slots)?e.theme.style_slots:{},...Array.isArray(e.theme.pages)?{pages:e.theme.pages}:{},...Tl(e.theme.terms)?{terms:e.theme.terms}:{}}}:null}async function Al(e){const t=await gs(as("/v1/storefront/themes/builder/published/:shopSlug",{shopSlug:e}));return t.success&&t.data?Tl(n=t.data)?{settings:Tl(n.settings)?n.settings:{},builder_settings:$l(n.builder_settings),content:Tl(n.content)?n.content:{},style_slots:Tl(n.style_slots)?n.style_slots:{}}:null:null;var n}async function Il(e){const t=await Al(e);return t?t.settings:null}function Nl(e){const t={};for(const[n,o]of Object.entries(e.settings)){t[n]={};for(const[e,i]of Object.entries(o))t[n][e]=i.default}return t}function Cl(e,t){const n={...e};for(const[o,i]of Object.entries(t))i&&(n[o]={...n[o],...i});return n}var Pl={init:function(e,t){"string"==typeof e?$a(e,t):$a(e.storeId,e)},isInitialized:Ia,getConfig:Aa,client:function(e){const t=Aa().apiBaseUrl??"https://api.shoppex.io";if(xa&&Oa===t&&!e)return xa;const n=function(e,t){return a({baseUrl:e,headers:t?{Authorization:`Bearer ${t}`}:void 0})}(t,e);return e||(xa=n,Oa=t),n},getStore:ws,getStorefront:Ss,getStoreLogoUrl:async function(){const e=await ws();return e.success&&e.data?.logo?e.data.logo:null},getStoreBannerUrl:async function(){const e=await ws();return e.success&&e.data?.banner?e.data.banner:null},resolveStoreByDomain:async function(e,t){const n=e??("undefined"!=typeof window?window.location.hostname:"");if(!n)return{success:!1,message:"Domain is required to resolve store"};const o=n.replace(/^https?:\/\//,"").split("/")[0].trim(),i=t??(Ia()?Aa().apiBaseUrl:"https://api.shoppex.io"),r=await gs(as("/v1/storefront/shops/domain/:domain",{domain:o}),{baseUrl:i,cache:{key:`store:domain:${o}`,ttl:vs,staleWhileRevalidate:!0}});return r.success&&r.data?.shop?(r.data.shop.id&&Na(r.data.shop.id),{success:!0,data:r.data.shop}):{success:!1,message:r.message??"Failed to resolve store"}},getProducts:xs,getStorefrontProductsPage:async function(e){const t=Aa(),n=new URLSearchParams;"string"==typeof e?.cursor&&e.cursor.trim().length>0&&n.set("cursor",e.cursor),Number.isFinite(e?.limit)&&n.set("limit",String(Math.max(1,Math.floor(e?.limit??0)))),"string"==typeof e?.sort&&e.sort.trim().length>0&&n.set("sort",e.sort.trim()),"string"==typeof e?.category&&e.category.trim().length>0&&n.set("category",e.category.trim()),!0===e?.hideOutOfStock&&n.set("hide_out_of_stock","true");const o=n.size>0?`?${n.toString()}`:"",i=await gs(`${as("/v1/storefront/products/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`products:page:${t.storeSlug}:${e?.limit??"default"}:${e?.cursor??"start"}:${e?.sort??"featured"}:${r=e?.category,void 0===r?"category:unset":null===r?"category:null":`category:${r}`}:${!0===e?.hideOutOfStock?"in-stock":"all-stock"}`,ttl:ks,staleWhileRevalidate:!0}});var r;return i.success&&i.data?{success:!0,data:{products:i.data.products.map(zs),pagination:i.data.pagination??null}}:{success:!1,message:i.message}},getProduct:async function(e){let t=Ca();if(!t){const e=await ws();t=e.success?e.data?.id??null:null}const n=t?`?slug_shop_id=${encodeURIComponent(t)}`:"",o=await gs(`${as("/v1/storefront/products/unique/:idOrSlug",{idOrSlug:e})}${n}`,{cache:{key:`product:${e}:${t??"no-shop"}`,ttl:ks,staleWhileRevalidate:!0}});return o.success&&o.data?.product?{success:!0,data:zs(o.data.product)}:{success:!1,message:o.message}},getCategories:async function(){const e=await xs();if(!e.success||!e.data)return{success:!1,message:e.message};const t=new Set;for(const n of e.data)if(n.categories)for(const e of n.categories)"string"==typeof e?t.add(e):e&&"object"==typeof e&&"uniqid"in e&&t.add(e.uniqid);return{success:!0,data:Array.from(t)}},getCart:Ms,getCartItemCount:function(){return Ms().reduce((e,t)=>e+t.quantity,0)},getCartCoupon:Us,setCartCoupon:qs,clearCartCoupon:js,addToCart:function(e,t,n=1,o){if(!e||!t)throw new i("product_id and variant_id are required");const r=Ns(n);if(r<1)throw new i("quantity must be at least 1");const a=Ms(),s=Es({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data}),l=a.findIndex(e=>e.line_id===s);if(l>=0)a[l].quantity+=r,o?.addons&&(a[l].addons=o.addons),o?.custom_fields&&(a[l].custom_fields=o.custom_fields),o?.price_variant_id&&(a[l].price_variant_id=o.price_variant_id),o?.price_data&&(a[l].price_data=o.price_data),function(e,t){if(t?.replace_display_snapshot)return e.title=t.title,e.variant_title=t.variant_title,e.image_url=t.image_url,e.addon_labels=t.addon_labels,e.max_quantity=t.max_quantity,void(e.min_quantity=t.min_quantity);void 0!==t?.title&&(e.title=t.title);void 0!==t?.variant_title&&(e.variant_title=t.variant_title);void 0!==t?.image_url&&(e.image_url=t.image_url);void 0!==t?.addon_labels&&(e.addon_labels=t.addon_labels);void 0!==t?.max_quantity&&(e.max_quantity=t.max_quantity);void 0!==t?.min_quantity&&(e.min_quantity=t.min_quantity)}(a[l],o),Ls(a[l]);else{const n={line_id:s,product_id:e,variant_id:t,quantity:r,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Ls(n),a.push(n)}Ds(a)},setCartItem:function(e,t,n=1,o){if(!e||!t)throw new i("product_id and variant_id are required");const r=Ns(n);if(r<1)throw new i("quantity must be at least 1");const a=Ms(),s=Es({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data});for(let i=a.length-1;i>=0;i-=1)a[i].product_id===e&&a[i].variant_id===t&&a.splice(i,1);const l={line_id:s,product_id:e,variant_id:t,quantity:r,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Ls(l),a.push(l),Ds(a)},updateCartItem:function(e,t){const n=Ms(),o=e.trim();if(!o)throw new i("line_id is required");const r=n.findIndex(e=>e.line_id===o);if(r<0)throw new i("Item not found in cart");if(void 0!==t.quantity){const e=Ns(t.quantity);if(e<1)return n.splice(r,1),void Ds(n);n[r].quantity=e}void 0!==t.addons&&(n[r].addons=t.addons),void 0!==t.custom_fields&&(n[r].custom_fields=t.custom_fields),void 0!==t.price_variant_id&&(n[r].price_variant_id=t.price_variant_id),void 0!==t.price_data&&(n[r].price_data=t.price_data),void 0!==t.max_quantity&&(n[r].max_quantity=t.max_quantity),void 0!==t.min_quantity&&(n[r].min_quantity=t.min_quantity),Ls(n[r]),Ds(n)},removeFromCart:function(e){const t=e.trim();if(!t)throw new i("line_id is required");Ds(Ms().filter(e=>e.line_id!==t))},clearCart:Fs,createCartBackup:Bs,restoreCartFromBackup:function(){const e=Ps(ls(As("cartBackup"))),t=ls(As("metaBackup")),n=ls(As("couponBackup"));return!!(e&&e.length>0)&&(Zs(e,t),"string"==typeof n?qs(n):js(),!0)},mergeBaskets:function(e){const t=Ms();for(const n of e){const e="string"==typeof n.product_id?n.product_id.trim():"",o="string"==typeof n.variant_id?n.variant_id.trim():"";if(!e||!o)continue;let i;try{i=Ns(n.quantity)}catch{continue}if(i<1)continue;const r=Ts({...n,line_id:n.line_id??Es(n),product_id:e,variant_id:o,quantity:i}),a=t.findIndex(e=>e.line_id===r.line_id);a>=0?(t[a].quantity=Math.max(t[a].quantity,i),Ls(t[a])):(Ls(r),t.push(r))}return Ds(t),t},moveBasketItem:function(e,t,n,o){const r=Ms(),a=r.findIndex(n=>n.product_id===e&&n.variant_id===t);if(a<0)throw new i("Item not found in cart");const[s]=r.splice(a,1),l=Es({...s,product_id:n,variant_id:o}),u=r.findIndex(e=>e.line_id===l);if(u>=0)r[u].quantity+=s.quantity,Ls(r[u]);else{const e=Ts({...s,product_id:n,variant_id:o,line_id:l});Ls(e),r.push(e)}Ds(r)},getCartStats:function(){const e=Ms(),t=Ys(),n=Rs(),o=ls(As("cartBackup"))??[],i=e.length>0&&e.every(e=>"number"==typeof e.price_data?.unit_price),r=e.reduce((e,t)=>e+(t.price_data?.unit_price??0)*t.quantity,0);return{item_count:e.length,total_quantity:e.reduce((e,t)=>e+t.quantity,0),last_modified:n?.last_modified??0,version:n?.version??0,has_backup:o.length>0,integrity_valid:t,total_price:r,total_price_is_estimate:e.length>0&&!i}},validateCartIntegrity:Ys,quoteCart:async function(e){const t=function(e){const t=Aa(),n=Cs(e)??Us()??void 0;return{store_slug:t.storeSlug,items:Ms(),coupon:n}}(e);return bs("/v1/storefront/cart/quote",{shop_slug:t.store_slug,cart:t.items,coupon:t.coupon})},resolveCartLineId:function(e,t,n=Ms()){const o=n.filter(n=>n.product_id===e&&n.variant_id===t);if(0===o.length)throw new i(`No cart line found for ${e}/${t}`);return o[0].line_id},checkout:async function(e,t){const n=ll(e,t),{autoRedirect:o=!0,email:i,coupon:r}=n,a=void 0===r?Us():Qs(r),s=el(i),l=ul(n),u=nl(n),c=Ms();if(0===c.length)return{success:!1,message:"Cart is empty"};Bs();const d=Aa();let p=await bs("/v1/storefront/invoices/from-cart",{shop_slug:d.storeSlug,cart:cl(c),email:s,coupon:a,currency:u,affiliate_code:l},{retries:0});if(!p.success||!p.data)return il(p.message)&&Fs(),{success:!1,message:ol(p.message)};const f=sl(p.data,d.checkoutBaseUrl);if(!f)return{success:!1,message:"Failed to create invoice"};const{invoiceId:m}=f,h=rl(f.checkoutUrl,d.checkoutBaseUrl,m);if(!h)return{success:!1,message:"Failed to create invoice"};const _=al(h,{email:s,locale:n.locale});return o&&"undefined"!=typeof window&&window?.location&&(window.location.href=_,Fs()),{success:!0,redirectUrl:_,invoiceId:m,rewards:f.rewards}},buildCheckoutUrl:async function(e,t){const n=ll(e,t),{email:o,coupon:i}=n,r=void 0===i?Us():Qs(i),a=el(o),s=ul(n),l=nl(n),u=Ms();if(0===u.length)throw new Error("Cart is empty");const c=Aa();let d=await bs("/v1/storefront/invoices/from-cart",{shop_slug:c.storeSlug,cart:cl(u),email:a,coupon:r,currency:l,affiliate_code:s},{retries:0});if(!d.success||!d.data)throw il(d.message)&&Fs(),new Error(ol(d.message));const p=sl(d.data,c.checkoutBaseUrl);if(!p)throw new Error("Failed to create invoice");const f=rl(p.checkoutUrl,c.checkoutBaseUrl,p.invoiceId);if(!f)throw new Error("Failed to create invoice");return al(f,{email:a,locale:n.locale})},buildCheckoutUrlSync:function(){throw new Error("buildCheckoutUrlSync is deprecated. Use buildCheckoutUrl (async) instead.")},captureAffiliateFromUrl:async function(e="ref"){if("undefined"==typeof window)return null;let t=null;try{const n=new URL(window.location.href).searchParams.get(e);t=n?n.trim():null}catch{t=null}if(t=Vs(t),!t)return null;if(Gs(t),Ia())try{const e=await bs("/v1/storefront/affiliates/attribution",{shop_slug:Aa().storeSlug,code:t},{retries:0});return e.success&&e.data?.accepted&&e.data?.affiliate_code?(Gs(e.data.affiliate_code),e.data.affiliate_code):(Hs(),null)}catch{return t}return t},validateAffiliateCode:Xs,applyAffiliateCode:async function(e){const t=await Xs(e);return t.success&&t.data?.affiliate_code&&Gs(t.data.affiliate_code),t},getAffiliateCode:Ks,setAffiliateCode:Gs,clearAffiliateCode:Hs,validateCoupon:async function(e,t){const n=e.trim();if(!n)return{success:!1,message:"Coupon code is required"};const o={code:n},i="string"==typeof t?t:t?.productId,r="string"==typeof t?void 0:t?.variantId;if(r&&!i)return{success:!1,message:"productId is required when variantId is provided"};if(i)o.product_id=i,r&&(o.variant_id=r);else{const e=Ms();if(0===e.length)return{success:!1,message:"Cart is empty"};const t=await async function(){const e=Ca();if(e)return e;const t=await ws();return t.success&&t.data?.id?t.data.id:null}();if(!t)return{success:!1,message:"Failed to resolve store"};o.cart=JSON.stringify({shop_id:t,products:e.map(e=>({uniqid:e.product_id,quantity:e.quantity,variant_id:e.variant_id,price_variant_id:e.price_variant_id,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1}))}))})}return await bs("/v1/storefront/coupons/check",o)},getShopReviews:async function(){const e=[],t=new Set;let n=null;for(;;){const o=await ml(n);if(!o.success||!o.data)return{success:!1,message:o.message,data:[]};e.push(...(o.data.feedback??[]).map((t,n)=>fl(t,e.length+n)));const i=o.data.pagination;if(!i?.has_more||!i.next_cursor)break;if(t.has(i.next_cursor))break;t.add(i.next_cursor),n=i.next_cursor}return{success:!0,data:e}},searchProducts:async function(e,t){if(!Ia())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Ss();return o.success&&o.data?{success:!0,data:Ka(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},searchCatalogItems:async function(e,t){if(!Ia())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Ss();return o.success&&o.data?{success:!0,data:Ha(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},getInvoice:async function(e){const t=hl(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await gs(as("/v1/storefront/invoices/unique/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?{success:!0,data:n.data.invoice}:{success:!1,message:"Invalid invoice response"}:{success:!1,message:n.message}},getInvoiceStatus:async function(e){const t=hl(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await gs(as("/v1/storefront/invoices/status/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?.status?{success:!0,data:{status:n.data.invoice.status}}:{success:!1,message:"Invalid invoice status response"}:{success:!1,message:n.message}},getPages:async function(){const e=Aa(),t=await gs(as("/v1/storefront/shops/name/:storeSlug/pages",{storeSlug:e.storeSlug}),{cache:{key:`pages:${e.storeSlug}`,ttl:_l,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.pages}:{success:!1,message:t.message}},getPage:async function(e){const t=Aa(),n=await gs(as("/v1/storefront/shops/name/:storeSlug/pages/:slug",{storeSlug:t.storeSlug,slug:e}),{cache:{key:`page:${t.storeSlug}:${e}`,ttl:_l,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.page}:{success:!1,message:n.message}},getMenus:gl,getMenu:vl,getMenuBySlot:wl,getMenuByTitle:bl,getMenuSlotTitles:Sl,trackPageView:kl,getStorefrontOnlineUsers:xl,getStorefrontRecentSales:zl,touchStorefrontPresence:Ol,createFormatter:El,formatPrice:function(e,t,n){const o="string"==typeof e?parseFloat(e):e;return Number.isNaN(o)?El(t,n).format(0):El(t,n).format(o)},clearCache:function(){es.clear(),ts.clear()},invalidateCache:function(e){for(const t of es.keys())(t===e||t.startsWith(e))&&es.delete(t)},getCacheStats:function(){return{hits:ns.hits,misses:ns.misses,pendingRequests:ts.size,entries:es.size}},fetchPublishedBuilderSettings:Al,fetchPublishedThemeSettings:Il,resolveDefaults:Nl,mergeSettings:Cl};if("undefined"!=typeof window){const e=window;e.shoppex?.isInitialized?.()||(e.shoppex=Pl)}e.CartError=i,e.NetworkError=o,e.NotInitializedError=n,e.ShoppexError=t,e.ValidationError=class e extends t{constructor(t,n){super(t,"VALIDATION_ERROR"),this.name="ValidationError",this.invalidFields=n,Object.setPrototypeOf(this,e.prototype)}},e.buildStorefrontContactMessage=Qa,e.buildStorefrontCustomFieldPayload=function(e,t){const n={};return e.forEach(e=>{const o=t[e.name]??e.defaultValue??"";if("checkbox"===e.type)return void(Pa(o)&&(n[e.name]="true"));const i=o.trim();i.length>0&&(n[e.name]=i)}),n},e.buildStorefrontProductLookup=Za,e.collectProductSearchHaystack=Ja,e.computeCartLineId=Es,e.default=Pl,e.shoppex=Pl,e.ensureCartLineId=Ts,e.fetchPublishedBuilderSettings=Al,e.fetchPublishedThemeSettings=Il,e.filterProductsBySearchQuery=function(e,t,n){const o=Ba(t);if(!o)return[];let i=e.filter(e=>Wa(e,o));return n?.hideOutOfStock&&(i=i.filter(e=>Da(e))),null!=n?.maxResults?i.slice(0,n.maxResults):i},e.getMenu=vl,e.getMenuBySlot=wl,e.getMenuByTitle=bl,e.getMenuSlotTitles=Sl,e.getMenus=gl,e.getMergedStorefrontProducts=La,e.getStorefrontGroupProducts=Ma,e.getStorefrontOnlineUsers=xl,e.getStorefrontRecentSales=zl,e.groupMatchesSearchQuery=Va,e.isProductInStock=Da,e.isProductOutOfStock=ja,e.isStorefrontCheckboxCustomFieldValueChecked=Pa,e.isVariantOutOfStock=function(e){return 0===Ra(e?.stock)},e.mergeSettings=Cl,e.normalizeSearchQuery=Ba,e.normalizeStorefrontCustomFields=function(e){return function(e){if(Array.isArray(e))return e;if("string"==typeof e){try{const t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){const e=t.custom_fields??t.customFields;return Array.isArray(e)?e:[]}}catch{return[]}return[]}if(e&&"object"==typeof e){const t=e.custom_fields??e.customFields;return Array.isArray(t)?t:[]}return[]}(e).filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)).map(e=>{const t="string"==typeof e.type?e.type.trim().toLowerCase():"text",n=t.length>0?t:"text",o=[e.default_value,e.default,e.value].find(e=>"string"==typeof e&&e.trim().length>0);return{name:"string"==typeof e.name?e.name.trim():"",type:n,required:!0===e.required||"true"===e.required||1===e.required||"1"===e.required,defaultValue:"string"==typeof o?o:"",placeholder:"string"==typeof e.placeholder?e.placeholder:"",regex:"string"==typeof e.regex?e.regex:void 0}}).filter(e=>e.name.length>0&&"hidden"!==e.type)},e.productMatchesSearchQuery=Wa,e.resolveDefaults=Nl,e.resolveDisplayStock=qa,e.resolveStorefrontApiBaseUrl=Xa,e.resolveStorefrontSocialLinks=function(e){return{discord:e?.discord_link??e?.social?.discord??null,telegram:e?.telegram_link??e?.social?.telegram??null}},e.resolveVariantStockValue=function(e){return Ra(e?.stock)??-1},e.searchMergedStorefrontCatalog=Ka,e.searchMergedStorefrontCatalogItems=Ha,e.stripHtmlFromText=Fa,e.submitStorefrontContactTicket=async function(e){const t=e.shopSlug.trim();if(!t)throw new Error("Store data is not ready yet. Please try again in a moment.");const n=e.email.trim().toLowerCase(),o=e.title?.trim()??"",i=o.length>=2?o.slice(0,30):"Contact Request",r=Qa({name:e.name,message:e.message}),a=e.invoiceId?.trim()||void 0,s=Xa({apiBaseUrl:e.apiBaseUrl}),l=await fetch(`${s}/v1/storefront/shops/name/${encodeURIComponent(t)}/tickets`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({email:n,title:i,message:r,...a?{invoice_id:a}:{}})}),u=await l.json().catch(()=>null);if(!l.ok)throw new Error(u?.message||u?.error||"Failed to send your message.");const c=u?.data?.uniqid;if(!c)throw new Error("Ticket created, but the response was incomplete.");return{uniqid:c}},e.touchStorefrontPresence=Ol,e.trackPageView=kl,e.validateStorefrontCustomFieldValue=function(e,t){if("checkbox"===e.type)return e.required&&!Pa(t)?`${e.name} is required.`:null;const n=t.trim();if(e.required&&!n)return`${e.name} is required.`;if(e.regex&&n)try{if(!new RegExp(e.regex).test(n))return`${e.name} has an invalid format.`}catch{return null}return null}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).shoppex={})}(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=class e extends Error{constructor(t,n,o){super(t),this.name="ShoppexError",this.code=n,this.statusCode=o,Object.setPrototypeOf(this,e.prototype)}},n=class e extends t{constructor(){super("SDK not initialized. Call shoppex.init() first.","NOT_INITIALIZED"),this.name="NotInitializedError",Object.setPrototypeOf(this,e.prototype)}},o=class e extends t{constructor(t,n){super(t,"NETWORK_ERROR",n),this.name="NetworkError",Object.setPrototypeOf(this,e.prototype)}},i=class e extends t{constructor(t){super(t,"BASKET_ERROR"),this.name="CartError",Object.setPrototypeOf(this,e.prototype)}},r=/\{[^{}]+\}/g;function a(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:o=globalThis.fetch,querySerializer:i,bodySerializer:r,pathSerializer:a,headers:s,requestInitExt:l,...u}={...e};l="object"==typeof process&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici?l:void 0,t=m(t);const h=[];async function _(e,_){const{baseUrl:y,fetch:g=o,Request:b=n,headers:v,params:w={},parseAs:S="json",querySerializer:k,bodySerializer:z=r??p,pathSerializer:x,body:O,middleware:E=[],...T}=_||{};let $=t;y&&($=m(y)??t);let A="function"==typeof i?i:c(i);k&&(A="function"==typeof k?k:c({..."object"==typeof i?i:{},...k}));const I=x||a||d,N=void 0===O?void 0:z(O,f(s,v,w.header)),C=f(void 0===N||N instanceof FormData?{}:{"Content-Type":"application/json"},s,v,w.header),P=[...h,...E],R={redirect:"follow",...u,...T,body:N,headers:C};let U,q,j,D=new b(function(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let o=t.querySerializer(t.params.query??{});o.startsWith("?")&&(o=o.substring(1));o&&(n+=`?${o}`);return n}(e,{baseUrl:$,params:w,querySerializer:A,pathSerializer:I}),R);for(const t in T)t in D||(D[t]=T[t]);if(P.length){U=Math.random().toString(36).slice(2,11),q=Object.freeze({baseUrl:$,fetch:g,parseAs:S,querySerializer:A,bodySerializer:z,pathSerializer:I});for(const t of P)if(t&&"object"==typeof t&&"function"==typeof t.onRequest){const n=await t.onRequest({request:D,schemaPath:e,params:w,options:q,id:U});if(n){if(!(n instanceof b)){if(n instanceof Response){j=n;break}throw new Error("onRequest: must return new Request() or Response() when modifying the request")}D=n}}}if(!j){try{j=await g(D,l)}catch(L){let t=L;if(P.length)for(let n=P.length-1;n>=0;n--){const o=P[n];if(o&&"object"==typeof o&&"function"==typeof o.onError){const n=await o.onError({request:D,error:t,schemaPath:e,params:w,options:q,id:U});if(n){if(n instanceof Response){t=void 0,j=n;break}if(n instanceof Error){t=n;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(t)throw t}if(P.length)for(let t=P.length-1;t>=0;t--){const n=P[t];if(n&&"object"==typeof n&&"function"==typeof n.onResponse){const t=await n.onResponse({request:D,response:j,schemaPath:e,params:w,options:q,id:U});if(t){if(!(t instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");j=t}}}}const Z=j.headers.get("Content-Length");if(204===j.status||"HEAD"===D.method||"0"===Z&&!j.headers.get("Transfer-Encoding")?.includes("chunked"))return j.ok?{data:void 0,response:j}:{error:void 0,response:j};if(j.ok){const e=async()=>{if("stream"===S)return j.body;if("json"===S&&!Z){const e=await j.text();return e?JSON.parse(e):void 0}return await j[S]()};return{data:await e(),response:j}}let M=await j.text();try{M=JSON.parse(M)}catch{}return{error:M,response:j}}return{request:(e,t,n)=>_(t,{...n,method:e.toUpperCase()}),GET:(e,t)=>_(e,{...t,method:"GET"}),PUT:(e,t)=>_(e,{...t,method:"PUT"}),POST:(e,t)=>_(e,{...t,method:"POST"}),DELETE:(e,t)=>_(e,{...t,method:"DELETE"}),OPTIONS:(e,t)=>_(e,{...t,method:"OPTIONS"}),HEAD:(e,t)=>_(e,{...t,method:"HEAD"}),PATCH:(e,t)=>_(e,{...t,method:"PATCH"}),TRACE:(e,t)=>_(e,{...t,method:"TRACE"}),use(...e){for(const t of e)if(t){if("object"!=typeof t||!("onRequest"in t||"onResponse"in t||"onError"in t))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");h.push(t)}},eject(...e){for(const t of e){const e=h.indexOf(t);-1!==e&&h.splice(e,1)}}}}function s(e,t,n){if(null==t)return"";if("object"==typeof t)throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${!0===n?.allowReserved?t:encodeURIComponent(t)}`}function l(e,t,n){if(!t||"object"!=typeof t)return"";const o=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if("deepObject"!==n.style&&!1===n.explode){for(const e in t)o.push(e,!0===n.allowReserved?t[e]:encodeURIComponent(t[e]));const i=o.join(",");switch(n.style){case"form":return`${e}=${i}`;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return i}}for(const a in t){const i="deepObject"===n.style?`${e}[${a}]`:a;o.push(s(i,t[a],n))}const r=o.join(i);return"label"===n.style||"matrix"===n.style?`${i}${r}`:r}function u(e,t,n){if(!Array.isArray(t))return"";if(!1===n.explode){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",i=(!0===n.allowReserved?t:t.map(e=>encodeURIComponent(e))).join(o);switch(n.style){case"simple":return i;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return`${e}=${i}`}}const o={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const r of t)"simple"===n.style||"label"===n.style?i.push(!0===n.allowReserved?r:encodeURIComponent(r)):i.push(s(e,r,n));return"label"===n.style||"matrix"===n.style?`${o}${i.join(o)}`:i.join(o)}function c(e){return function(t){const n=[];if(t&&"object"==typeof t)for(const o in t){const i=t[o];if(null!=i)if(Array.isArray(i)){if(0===i.length)continue;n.push(u(o,i,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof i?n.push(s(o,i,e)):n.push(l(o,i,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}))}return n.join("&")}}function d(e,t){let n=e;for(const o of e.match(r)??[]){let e=o.substring(1,o.length-1),i=!1,r="simple";if(e.endsWith("*")&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(".")?(r="label",e=e.substring(1)):e.startsWith(";")&&(r="matrix",e=e.substring(1)),!t||void 0===t[e]||null===t[e])continue;const a=t[e];Array.isArray(a)?n=n.replace(o,u(e,a,{style:r,explode:i})):n="object"!=typeof a?"matrix"!==r?n.replace(o,"label"===r?`.${encodeURIComponent(a)}`:encodeURIComponent(a)):n.replace(o,`;${s(e,a)}`):n.replace(o,l(e,a,{style:r,explode:i}))}return n}function p(e,t){return e instanceof FormData?e:t&&"application/x-www-form-urlencoded"===(t.get instanceof Function?t.get("Content-Type")??t.get("content-type"):t["Content-Type"]??t["content-type"])?new URLSearchParams(e).toString():JSON.stringify(e)}function f(...e){const t=new Headers;for(const n of e){if(!n||"object"!=typeof n)continue;const e=n instanceof Headers?n.entries():Object.entries(n);for(const[n,o]of e)if(null===o)t.delete(n);else if(Array.isArray(o))for(const e of o)t.append(n,e);else void 0!==o&&t.set(n,o)}return t}function m(e){return e.endsWith("/")?e.substring(0,e.length-1):e}var h={header:{title:"Header",aliases:["Header Menu"]},footer:{title:"Footer",aliases:["Footer Links","Legal Links"]}};var _;Object.keys(h);function y(e,t,n){function o(n,o){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:o,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,o);const i=a.prototype,r=Object.keys(i);for(let e=0;e<r.length;e++){const t=r[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class r extends i{}function a(e){var t;const i=n?.Parent?new r:this;o(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const n of i._zod.deferred)n();return i}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var g=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},b=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(_=globalThis).__zod_globalConfig??(_.__zod_globalConfig={});var v=globalThis.__zod_globalConfig;function w(e){return e&&Object.assign(v,e),v}function S(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function k(e,t){return"bigint"==typeof t?t.toString():t}function z(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function x(e){return null==e}function O(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var E=Symbol("evaluating");function T(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==E)return void 0===o&&(o=E,o=n()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function $(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function A(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function I(e){return JSON.stringify(e)}var N="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function C(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var P=z(()=>{if(v.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function R(e){if(!1===C(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==C(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function U(e){return R(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var q=new Set(["string","number","symbol"]);function j(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e,t,n){const o=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(o._zod.parent=e),o}function Z(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}var M={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function L(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function F(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function B(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Y(e){return"string"==typeof e?e:e?.message}function J(e,t,n){const o=e.message?e.message:Y(e.inst?._zod.def?.error?.(e))??Y(t?.error?.(e))??Y(n.customError?.(e))??Y(n.localeError?.(e))??"Invalid input",{inst:i,continue:r,input:a,...s}=e;return s.path??(s.path=[]),s.message=o,t?.reportInput&&(s.input=a),s}function W(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function V(...e){const[t,n,o]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:o}:{...t}}var G=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,k,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},H=y("$ZodError",G),K=y("$ZodError",G,{Parent:Error});var X=e=>(t,n,o,i)=>{const r=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise)throw new g;if(a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>J(e,r,w())));throw N(t,i?.callee),t}return a.value},Q=e=>async(t,n,o,i)=>{const r=o?{...o,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>J(e,r,w())));throw N(t,i?.callee),t}return a.value},ee=e=>(t,n,o)=>{const i=o?{...o,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new g;return r.issues.length?{success:!1,error:new(e??H)(r.issues.map(e=>J(e,i,w())))}:{success:!0,data:r.value}},te=ee(K),ne=e=>async(t,n,o)=>{const i=o?{...o,async:!0}:{async:!0};let r=t._zod.run({value:n,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>J(e,i,w())))}:{success:!0,data:r.value}},oe=ne(K),ie=e=>(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return X(e)(t,n,i)},re=e=>(t,n,o)=>X(e)(t,n,o),ae=e=>async(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return Q(e)(t,n,i)},se=e=>async(t,n,o)=>Q(e)(t,n,o),le=e=>(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return ee(e)(t,n,i)},ue=e=>(t,n,o)=>ee(e)(t,n,o),ce=e=>async(t,n,o)=>{const i=o?{...o,direction:"backward"}:{direction:"backward"};return ne(e)(t,n,i)},de=e=>async(t,n,o)=>ne(e)(t,n,o),pe=/^[cC][0-9a-z]{6,}$/,fe=/^[0-9a-z]+$/,me=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,he=/^[0-9a-vA-V]{20}$/,_e=/^[A-Za-z0-9]{27}$/,ye=/^[a-zA-Z0-9_-]{21}$/,ge=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,be=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ve=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,we=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Se=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ke=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ze=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Oe=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ee=/^[A-Za-z0-9_-]*$/,Te=/^https?$/,$e=/^\+[1-9]\d{6,14}$/,Ae="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ie=new RegExp(`^${Ae}$`);function Ne(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}var Ce=/^-?\d+$/,Pe=/^-?\d+(?:\.\d+)?$/,Re=/^(?:true|false)$/i,Ue=/^[^A-Z]*$/,qe=/^[^a-z]*$/,je=y("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),De={number:"number",bigint:"bigint",object:"date"},Ze=y("$ZodCheckLessThan",(e,t)=>{je.init(e,t);const n=De[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Me=y("$ZodCheckGreaterThan",(e,t)=>{je.init(e,t);const n=De[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Le=y("$ZodCheckMultipleOf",(e,t)=>{je.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value!==BigInt(0):0!==function(e,t){const n=e/t,o=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<i?0:n-o}(n.value,t.value))&&n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Fe=y("$ZodCheckNumberFormat",(e,t)=>{je.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[i,r]=M[t.format];e._zod.onattach.push(e=>{const o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=r,n&&(o.pattern=Ce)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}))}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>r&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Be=y("$ZodCheckMaxLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!x(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=W(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ye=y("$ZodCheckMinLength",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!x(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=W(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Je=y("$ZodCheckLengthEquals",(e,t)=>{var n;je.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!x(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const r=W(o),a=i>t.length;n.issues.push({origin:r,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),We=y("$ZodCheckStringFormat",(e,t)=>{var n,o;je.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Ve=y("$ZodCheckRegex",(e,t)=>{We.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ge=y("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ue),We.init(e,t)}),He=y("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=qe),We.init(e,t)}),Ke=y("$ZodCheckIncludes",(e,t)=>{je.init(e,t);const n=j(t.includes),o=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Xe=y("$ZodCheckStartsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`^${j(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Qe=y("$ZodCheckEndsWith",(e,t)=>{je.init(e,t);const n=new RegExp(`.*${j(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),et=y("$ZodCheckOverwrite",(e,t)=>{je.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),tt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),o=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const i of o)this.content.push(i)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}},nt={major:4,minor:4,patch:3},ot=y("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nt;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const i of o)for(const t of i._zod.onattach)t(e);if(0===o.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let o,i=L(e);for(const r of t){if(r._zod.def.when){if(F(e))continue;if(!r._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=r._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new g;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(i||(i=L(e,t)))});else{if(e.issues.length===t)continue;i||(i=L(e,t))}}return o?o.then(()=>e):e},n=(n,i,r)=>{if(L(n))return n.aborted=!0,n;const a=t(i,o,r);if(a instanceof Promise){if(!1===r.async)throw new g;return a.then(t=>e._zod.parse(t,r))}return e._zod.parse(a,r)};e._zod.run=(i,r)=>{if(r.skipChecks)return e._zod.parse(i,r);if("backward"===r.direction){const t=e._zod.parse({value:i.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,r)):n(t,i,r)}const a=e._zod.parse(i,r);if(a instanceof Promise){if(!1===r.async)throw new g;return a.then(e=>t(e,o,r))}return t(a,o,r)}}T(e,"~standard",()=>({validate:t=>{try{const n=te(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return oe(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),it=y("$ZodString",(e,t)=>{var n;ot.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),rt=y("$ZodStringFormat",(e,t)=>{We.init(e,t),it.init(e,t)}),at=y("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=be),rt.init(e,t)}),st=y("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ve(e))}else t.pattern??(t.pattern=ve());rt.init(e,t)}),lt=y("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=we),rt.init(e,t)}),ut=y("$ZodURL",(e,t)=>{rt.init(e,t),e._zod.check=n=>{try{const o=n.value.trim();if(!t.normalize&&t.protocol?.source===Te.source&&!/^https?:\/\//i.test(o))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const i=new URL(o);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=o)}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ct=y("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),rt.init(e,t)}),dt=y("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ye),rt.init(e,t)}),pt=y("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pe),rt.init(e,t)}),ft=y("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=fe),rt.init(e,t)}),mt=y("$ZodULID",(e,t)=>{t.pattern??(t.pattern=me),rt.init(e,t)}),ht=y("$ZodXID",(e,t)=>{t.pattern??(t.pattern=he),rt.init(e,t)}),_t=y("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_e),rt.init(e,t)}),yt=y("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=Ne({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ae}T(?:${o})$`)}(t)),rt.init(e,t)}),gt=y("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ie),rt.init(e,t)}),bt=y("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Ne(t)}$`)),rt.init(e,t)}),vt=y("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ge),rt.init(e,t)}),wt=y("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Se),rt.init(e,t),e._zod.bag.format="ipv4"}),St=y("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ke),rt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),kt=y("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ze),rt.init(e,t)}),zt=y("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xe),rt.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(2!==o.length)throw new Error;const[e,t]=o;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function xt(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ot=y("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Oe),rt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{xt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Et=y("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ee),rt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Ee.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return xt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Tt=y("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$e),rt.init(e,t)});var $t=y("$ZodJWT",(e,t)=>{rt.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[o]=n;if(!o)return!1;const i=JSON.parse(atob(o));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),At=y("$ZodNumber",(e,t)=>{ot.init(e,t),e._zod.pattern=e._zod.bag.pattern??Pe,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const r="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...r?{received:r}:{}}),n}}),It=y("$ZodNumberFormat",(e,t)=>{Fe.init(e,t),At.init(e,t)}),Nt=y("$ZodBoolean",(e,t)=>{ot.init(e,t),e._zod.pattern=Re,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(r){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),Ct=y("$ZodUnknown",(e,t)=>{ot.init(e,t),e._zod.parse=e=>e}),Pt=y("$ZodNever",(e,t)=>{ot.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Rt(e,t,n){e.issues.length&&t.issues.push(...B(n,e.issues)),t.value[n]=e.value}var Ut=y("$ZodArray",(e,t)=>{ot.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const r=[];for(let e=0;e<i.length;e++){const a=i[e],s=t.element._zod.run({value:a,issues:[]},o);s instanceof Promise?r.push(s.then(t=>Rt(t,n,e))):Rt(s,n,e)}return r.length?Promise.all(r).then(()=>n):n}});function qt(e,t,n,o,i,r){const a=n in o;if(e.issues.length){if(i&&r&&!a)return;t.issues.push(...B(n,e.issues))}a||i?void 0===e.value?a&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function jt(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=(o=e.shape,Object.keys(o).filter(e=>"optional"===o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Dt(e,t,n,o,i,r){const a=[],s=i.keySet,l=i.catchall._zod,u=l.def.type,c="optional"===l.optin,d="optional"===l.optout;for(const p in t){if("__proto__"===p)continue;if(s.has(p))continue;if("never"===u){a.push(p);continue}const i=l.run({value:t[p],issues:[]},o);i instanceof Promise?e.push(i.then(e=>qt(e,n,p,t,c,d))):qt(i,n,p,t,c,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}var Zt=y("$ZodObject",(e,t)=>{if(ot.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=z(()=>jt(t));T(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const o=e[t]._zod;if(o.values){n[t]??(n[t]=new Set);for(const e of o.values)n[t].add(e)}}return n});const o=C,i=t.catchall;let r;e._zod.parse=(t,a)=>{r??(r=n.value);const s=t.value;if(!o(s))return t.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),t;t.value={};const l=[],u=r.shape;for(const e of r.keys){const n=u[e],o="optional"===n._zod.optin,i="optional"===n._zod.optout,r=n._zod.run({value:s[e],issues:[]},a);r instanceof Promise?l.push(r.then(n=>qt(n,t,e,s,o,i))):qt(r,t,e,s,o,i)}return i?Dt(l,s,t,a,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Mt=y("$ZodObjectJIT",(e,t)=>{Zt.init(e,t);const n=e._zod.parse,o=z(()=>jt(t));let i;const r=C,a=!v.jitless,s=a&&P.value,l=t.catchall;let u;e._zod.parse=(c,d)=>{u??(u=o.value);const p=c.value;return r(p)?a&&s&&!1===d?.async&&!0!==d.jitless?(i||(i=(e=>{const t=new tt(["shape","payload","ctx"]),n=o.value,i=e=>{const t=I(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let a=0;for(const o of n.keys)r[o]="key_"+a++;t.write("const newResult = {};");for(const o of n.keys){const n=r[o],a=I(o),s=e[o],l="optional"===s?._zod?.optin,u="optional"===s?._zod?.optout;t.write(`const ${n} = ${i(o)};`),l&&u?t.write(`\n if (${n}.issues.length) {\n if (${a} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):l?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${a} in input) {\n newResult[${a}] = undefined;\n }\n } else {\n newResult[${a}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${a} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${a}, ...iss.path] : [${a}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${a}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${a}] = undefined;\n } else {\n newResult[${a}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,n)=>s(e,t,n)})(t.shape)),c=i(c,d),l?Dt([],p,c,d,u,e):c):n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c)}});function Lt(e,t,n,o){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;const i=e.filter(e=>!L(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>J(e,o,w())))}),t)}var Ft=y("$ZodUnion",(e,t)=>{ot.init(e,t),T(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),T(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),T(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),T(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>O(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(o,i)=>{if(n)return n(o,i);let r=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)a.push(t),r=!0;else{if(0===t.issues.length)return t;a.push(t)}}return r?Promise.all(a).then(t=>Lt(t,o,e,i)):Lt(a,o,e,i)}}),Bt=y("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ft.init(e,t);const n=e._zod.parse;T(e._zod,"propValues",()=>{const e={};for(const n of t.options){const o=n._zod.propValues;if(!o||0===Object.keys(o).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(o)){e[t]||(e[t]=new Set);for(const o of n)e[t].add(o)}}return e});const o=z(()=>{const e=t.options,n=new Map;for(const o of e){const e=o._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,o)}}return n});e._zod.parse=(i,r)=>{const a=i.value;if(!C(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(i,r):t.unionFallback||"backward"===r.direction?n(i,r):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:a,path:[t.discriminator],inst:e}),i)}}),Yt=y("$ZodIntersection",(e,t)=>{ot.init(e,t),e._zod.parse=(e,n)=>{const o=e.value,i=t.left._zod.run({value:o,issues:[]},n),r=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([t,n])=>Wt(e,t,n)):Wt(e,i,r)}});function Jt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(R(e)&&R(t)){const n=Object.keys(t),o=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const r of o){const n=Jt(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};i[r]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const i=Jt(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wt(e,t,n){const o=new Map;let i;for(const s of t.issues)if("unrecognized_keys"===s.code){i??(i=s);for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).l=!0}else e.issues.push(s);for(const s of n.issues)if("unrecognized_keys"===s.code)for(const e of s.keys)o.has(e)||o.set(e,{}),o.get(e).r=!0;else e.issues.push(s);const r=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(r.length&&i&&e.issues.push({...i,keys:r}),L(e))return e;const a=Jt(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Vt=y("$ZodRecord",(e,t)=>{ot.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!R(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const r=[],a=t.keyType._zod.values;if(a){n.value={};const s=new Set;for(const u of a)if("string"==typeof u||"number"==typeof u||"symbol"==typeof u){s.add("number"==typeof u?u.toString():u);const a=t.keyType._zod.run({value:u,issues:[]},o);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>J(e,o,w())),input:u,path:[u],inst:e});continue}const l=a.value,c=t.valueType._zod.run({value:i[u],issues:[]},o);c instanceof Promise?r.push(c.then(e=>{e.issues.length&&n.issues.push(...B(u,e.issues)),n.value[l]=e.value})):(c.issues.length&&n.issues.push(...B(u,c.issues)),n.value[l]=c.value)}let l;for(const e in i)s.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(i)){if("__proto__"===a)continue;if(!Object.prototype.propertyIsEnumerable.call(i,a))continue;let s=t.keyType._zod.run({value:a,issues:[]},o);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof a&&Pe.test(a)&&s.issues.length){const e=t.keyType._zod.run({value:Number(a),issues:[]},o);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>J(e,o,w())),input:a,path:[a],inst:e});continue}const l=t.valueType._zod.run({value:i[a],issues:[]},o);l instanceof Promise?r.push(l.then(e=>{e.issues.length&&n.issues.push(...B(a,e.issues)),n.value[s.value]=e.value})):(l.issues.length&&n.issues.push(...B(a,l.issues)),n.value[s.value]=l.value)}}return r.length?Promise.all(r).then(()=>n):n}}),Gt=y("$ZodEnum",(e,t)=>{ot.init(e,t);const n=S(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(e=>q.has(typeof e)).map(e=>"string"==typeof e?j(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const r=t.value;return o.has(r)||t.issues.push({code:"invalid_value",values:n,input:r,inst:e}),t}}),Ht=y("$ZodLiteral",(e,t)=>{if(ot.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?j(e):e?j(e.toString()):String(e)).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return n.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),Kt=y("$ZodTransform",(e,t)=>{ot.init(e,t),e._zod.optin="optional",e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new b(e.constructor.name);const i=t.transform(n.value,n);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new g;return n.value=i,n.fallback=!0,n}});function Xt(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Qt=y("$ZodOptional",(e,t)=>{ot.init(e,t),e._zod.optin="optional",e._zod.optout="optional",T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${O(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const o=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Xt(e,o)):Xt(i,o)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),en=y("$ZodExactOptional",(e,t)=>{Qt.init(e,t),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),tn=y("$ZodNullable",(e,t)=>{ot.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${O(e.source)}|null)$`):void 0}),T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),nn=y("$ZodDefault",(e,t)=>{ot.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>on(e,t)):on(o,t)}});function on(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var rn=y("$ZodPrefault",(e,t)=>{ot.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),an=y("$ZodNonOptional",(e,t)=>{ot.init(e,t),T(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,o)=>{const i=t.innerType._zod.run(n,o);return i instanceof Promise?i.then(t=>sn(t,e)):sn(i,e)}});function sn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var ln=y("$ZodCatch",(e,t)=>{ot.init(e,t),e._zod.optin="optional",T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(o=>(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>J(e,n,w()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>J(e,n,w()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),un=y("$ZodPipe",(e,t)=>{ot.init(e,t),T(e._zod,"values",()=>t.in._zod.values),T(e._zod,"optin",()=>t.in._zod.optin),T(e._zod,"optout",()=>t.out._zod.optout),T(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const o=t.out._zod.run(e,n);return o instanceof Promise?o.then(e=>cn(e,t.in,n)):cn(o,t.in,n)}const o=t.in._zod.run(e,n);return o instanceof Promise?o.then(e=>cn(e,t.out,n)):cn(o,t.out,n)}});function cn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var dn=y("$ZodReadonly",(e,t)=>{ot.init(e,t),T(e._zod,"propValues",()=>t.innerType._zod.propValues),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"optin",()=>t.innerType?._zod?.optin),T(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(pn):pn(o)}});function pn(e){return e.value=Object.freeze(e.value),e}var fn,mn=y("$ZodCustom",(e,t)=>{je.init(e,t),ot.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const o=n.value,i=t.fn(o);if(i instanceof Promise)return i.then(t=>hn(t,n,o,e));hn(i,n,o,e)}});function hn(e,t,n,o){if(!e){const e={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),t.issues.push(V(e))}}var _n=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(fn=globalThis).__zod_globalRegistry??(fn.__zod_globalRegistry=new _n);var yn=globalThis.__zod_globalRegistry;function gn(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Z(t)})}function bn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Z(t)})}function vn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Z(t)})}function wn(e,t){return new Ze({check:"less_than",...Z(t),value:e,inclusive:!1})}function Sn(e,t){return new Ze({check:"less_than",...Z(t),value:e,inclusive:!0})}function kn(e,t){return new Me({check:"greater_than",...Z(t),value:e,inclusive:!1})}function zn(e,t){return new Me({check:"greater_than",...Z(t),value:e,inclusive:!0})}function xn(e,t){return new Le({check:"multiple_of",...Z(t),value:e})}function On(e,t){return new Be({check:"max_length",...Z(t),maximum:e})}function En(e,t){return new Ye({check:"min_length",...Z(t),minimum:e})}function Tn(e,t){return new Je({check:"length_equals",...Z(t),length:e})}function $n(e){return new et({check:"overwrite",tx:e})}function An(e,t){const n=new je({check:"custom",...Z(t)});return n._zod.check=e,n}function In(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??yn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Nn(e,t,n={path:[],schemaPath:[]}){var o;const i=e._zod.def,r=t.seen.get(e);if(r)return r.count++,n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const o={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,o);else{const n=a.schema,r=t.processors[i.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);r(e,t,n,o)}const r=e._zod.parent;r&&(a.ref||(a.ref=r),Nn(r,t,o),t.seen.get(r).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),"input"===t.io&&Rn(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Cn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const r of e.seen.entries()){const t=e.metadataRegistry.get(r[0])?.id;if(t){const e=o.get(t);if(e&&e!==r[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(t,r[0])}}const i=t=>{if(t[1].schema.$ref)return;const o=t[1],{ref:i,defId:r}=(t=>{const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const r=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=r,{defId:r,ref:`${i("__shared")}#/${o}/${r}`}}if(t[1]===n)return{ref:"#"};const i=`#/${o}/`,r=t[1].schema.id??"__schema"+e.counter++;return{defId:r,ref:i+r}})(t);o.def={...o.schema},r&&(o.defId=r);const a=o.schema;for(const e in a)delete a[e];a.$ref=i};if("throw"===e.cycles)for(const r of e.seen.entries()){const e=r[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const n=r[1];if(t!==r[0]){if(e.external){const n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){i(r);continue}}(e.metadataRegistry.get(r[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&i(r)}else i(r)}}function Pn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,r={...i},a=n.ref;if(n.ref=null,a){o(a);const n=e.seen.get(a),s=n.schema;if(!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,s):(i.allOf=i.allOf??[],i.allOf.push(s)),Object.assign(i,r),t._zod.parent===a)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in r||delete i[e]);if(s.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const s=t._zod.parent;if(s&&s!==a){o(s);const t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const r=e.metadataRegistry.get(t)?.id;void 0!==r&&i.id===r&&delete i.id;const a=e.external?.defs??{};for(const l of e.seen.entries()){const e=l[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?i.$defs=a:i.definitions=a);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Un(t,"input",e.processors),output:Un(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(s){throw new Error("Error converting schema to JSON.")}}function Rn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if("transform"===o.type)return!0;if("array"===o.type)return Rn(o.element,n);if("set"===o.type)return Rn(o.valueType,n);if("lazy"===o.type)return Rn(o.getter(),n);if("promise"===o.type||"optional"===o.type||"nonoptional"===o.type||"nullable"===o.type||"readonly"===o.type||"default"===o.type||"prefault"===o.type)return Rn(o.innerType,n);if("intersection"===o.type)return Rn(o.left,n)||Rn(o.right,n);if("record"===o.type||"map"===o.type)return Rn(o.keyType,n)||Rn(o.valueType,n);if("pipe"===o.type)return!!e._zod.traits.has("$ZodCodec")||(Rn(o.in,n)||Rn(o.out,n));if("object"===o.type){for(const e in o.shape)if(Rn(o.shape[e],n))return!0;return!1}if("union"===o.type){for(const e of o.options)if(Rn(e,n))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(Rn(e,n))return!0;return!(!o.rest||!Rn(o.rest,n))}return!1}var Un=(e,t,n={})=>o=>{const{libraryOptions:i,target:r}=o??{},a=In({...i??{},target:r,io:t,processors:n});return Nn(e,a),Cn(a,e),Pn(a,e)},qn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jn=(e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o);t.seen.get(e).ref=i.innerType},Dn=y("ZodISODateTime",(e,t)=>{yt.init(e,t),mo.init(e,t)});function Zn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Z(t)})}(Dn,e)}var Mn=y("ZodISODate",(e,t)=>{gt.init(e,t),mo.init(e,t)});function Ln(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Z(t)})}(Mn,e)}var Fn=y("ZodISOTime",(e,t)=>{bt.init(e,t),mo.init(e,t)});function Bn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Z(t)})}(Fn,e)}var Yn=y("ZodISODuration",(e,t)=>{vt.init(e,t),mo.init(e,t)});function Jn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Z(t)})}(Yn,e)}var Wn=(e,t)=>{H.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},o=(e,i=[])=>{for(const r of e.issues)if("invalid_union"===r.code&&r.errors.length)r.errors.map(e=>o({issues:e},[...i,...r.path]));else if("invalid_key"===r.code)o({issues:r.issues},[...i,...r.path]);else if("invalid_element"===r.code)o({issues:r.issues},[...i,...r.path]);else{const e=[...i,...r.path];if(0===e.length)n._errors.push(t(r));else{let o=n,i=0;for(;i<e.length;){const n=e[i];i!==e.length-1?o[n]=o[n]||{_errors:[]}:(o[n]=o[n]||{_errors:[]},o[n]._errors.push(t(r))),o=o[n],i++}}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):o.push(t(i));return{formErrors:o,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,k,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,k,2)}},isEmpty:{get:()=>0===e.issues.length}})},Vn=y("ZodError",Wn,{Parent:Error}),Gn=X(Vn),Hn=Q(Vn),Kn=ee(Vn),Xn=ne(Vn),Qn=ie(Vn),eo=re(Vn),to=ae(Vn),no=se(Vn),oo=le(Vn),io=ue(Vn),ro=ce(Vn),ao=de(Vn),so=new WeakMap;function lo(e,t,n){const o=Object.getPrototypeOf(e);let i=so.get(o);if(i||(i=new Set,so.set(o,i)),!i.has(t)){i.add(t);for(const e in n){const t=n[e];Object.defineProperty(o,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var uo=y("ZodType",(e,t)=>(ot.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Un(e,"input"),output:Un(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const o=In({...n,processors:t});return Nn(e,o),Cn(o,e),Pn(o,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Gn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Kn(e,t,n),e.parseAsync=async(t,n)=>Hn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Xn(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Qn(e,t,n),e.decode=(t,n)=>eo(e,t,n),e.encodeAsync=async(t,n)=>to(e,t,n),e.decodeAsync=async(t,n)=>no(e,t,n),e.safeEncode=(t,n)=>oo(e,t,n),e.safeDecode=(t,n)=>io(e,t,n),e.safeEncodeAsync=async(t,n)=>ro(e,t,n),e.safeDecodeAsync=async(t,n)=>ao(e,t,n),lo(e,"ZodType",{check(...e){const t=this.def;return this.clone(A(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return D(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Z(n)})}(bi,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=An(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(V(e,t.value,n._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(V(o))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check($n(e))},optional(){return li(this)},exactOptional(){return new ui({type:"optional",innerType:this})},nullable(){return di(this)},nullish(){return li(di(this))},nonoptional(e){return function(e,t){return new mi({type:"nonoptional",innerType:e,...Z(t)})}(this,e)},array(){return Jo(this)},or(e){return Ho([this,e])},and(e){return new Qo({type:"intersection",left:this,right:e})},transform(e){return yi(this,new ai({type:"transform",transform:e}))},default(e){return t=e,new pi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():U(t)}});var t},prefault(e){return t=e,new fi({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():U(t)}});var t},catch(e){return new hi({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return yi(this,e)},readonly(){return new gi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return yn.add(t,{description:e}),t},meta(...e){if(0===e.length)return yn.get(this);const t=this.clone();return yn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>yn.get(e)?.description,configurable:!0}),e)),co=y("_ZodString",(e,t)=>{it.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:a,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof r&&(o.maxLength=r),a&&(o.format=qn[a]??a,""===o.format&&delete o.format,"time"===a&&delete o.format),l&&(o.contentEncoding=l),s&&s.size>0){const e=[...s];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,lo(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ve({check:"string_format",format:"regex",...Z(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Ke({check:"string_format",format:"includes",...Z(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Xe({check:"string_format",format:"starts_with",...Z(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Qe({check:"string_format",format:"ends_with",...Z(t),suffix:e})}(...e))},min(...e){return this.check(En(...e))},max(...e){return this.check(On(...e))},length(...e){return this.check(Tn(...e))},nonempty(...e){return this.check(En(1,...e))},lowercase(e){return this.check(function(e){return new Ge({check:"string_format",format:"lowercase",...Z(e)})}(e))},uppercase(e){return this.check(function(e){return new He({check:"string_format",format:"uppercase",...Z(e)})}(e))},trim(){return this.check($n(e=>e.trim()))},normalize(...e){return this.check(function(e){return $n(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check($n(e=>e.toLowerCase()))},toUpperCase(){return this.check($n(e=>e.toUpperCase()))},slugify(){return this.check($n(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),po=y("ZodString",(e,t)=>{it.init(e,t),co.init(e,t),e.email=t=>e.check(gn(ho,t)),e.url=t=>e.check(vn(bo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Z(t)})}(Po,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Z(t)})}(vo,t)),e.guid=t=>e.check(bn(yo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Z(t)})}(go,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Z(t)})}(go,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Z(t)})}(go,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Z(t)})}(go,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Z(t)})}(wo,t)),e.guid=t=>e.check(bn(yo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Z(t)})}(So,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Z(t)})}(ko,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Z(t)})}(zo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Z(t)})}(Io,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Z(t)})}(No,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Z(t)})}(xo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Z(t)})}(Oo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Z(t)})}(Eo,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Z(t)})}(To,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Z(t)})}($o,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Z(t)})}(Ao,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Z(t)})}(Co,t)),e.datetime=t=>e.check(Zn(t)),e.date=t=>e.check(Ln(t)),e.time=t=>e.check(Bn(t)),e.duration=t=>e.check(Jn(t))});function fo(e){return function(e,t){return new e({type:"string",...Z(t)})}(po,e)}var mo=y("ZodStringFormat",(e,t)=>{rt.init(e,t),co.init(e,t)}),ho=y("ZodEmail",(e,t)=>{lt.init(e,t),mo.init(e,t)});function _o(e){return gn(ho,e)}var yo=y("ZodGUID",(e,t)=>{at.init(e,t),mo.init(e,t)}),go=y("ZodUUID",(e,t)=>{st.init(e,t),mo.init(e,t)}),bo=y("ZodURL",(e,t)=>{ut.init(e,t),mo.init(e,t)});var vo=y("ZodEmoji",(e,t)=>{ct.init(e,t),mo.init(e,t)}),wo=y("ZodNanoID",(e,t)=>{dt.init(e,t),mo.init(e,t)}),So=y("ZodCUID",(e,t)=>{pt.init(e,t),mo.init(e,t)}),ko=y("ZodCUID2",(e,t)=>{ft.init(e,t),mo.init(e,t)}),zo=y("ZodULID",(e,t)=>{mt.init(e,t),mo.init(e,t)}),xo=y("ZodXID",(e,t)=>{ht.init(e,t),mo.init(e,t)}),Oo=y("ZodKSUID",(e,t)=>{_t.init(e,t),mo.init(e,t)}),Eo=y("ZodIPv4",(e,t)=>{wt.init(e,t),mo.init(e,t)}),To=y("ZodIPv6",(e,t)=>{St.init(e,t),mo.init(e,t)}),$o=y("ZodCIDRv4",(e,t)=>{kt.init(e,t),mo.init(e,t)}),Ao=y("ZodCIDRv6",(e,t)=>{zt.init(e,t),mo.init(e,t)}),Io=y("ZodBase64",(e,t)=>{Ot.init(e,t),mo.init(e,t)}),No=y("ZodBase64URL",(e,t)=>{Et.init(e,t),mo.init(e,t)}),Co=y("ZodE164",(e,t)=>{Tt.init(e,t),mo.init(e,t)}),Po=y("ZodJWT",(e,t)=>{$t.init(e,t),mo.init(e,t)}),Ro=y("ZodNumber",(e,t)=>{At.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:i,maximum:r,format:a,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const c="number"==typeof u&&u>=(i??Number.NEGATIVE_INFINITY),d="number"==typeof l&&l<=(r??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;c?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:"number"==typeof i&&(o.minimum=i),d?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof r&&(o.maximum=r),"number"==typeof s&&(o.multipleOf=s)})(e,t,n),lo(e,"ZodNumber",{gt(e,t){return this.check(kn(e,t))},gte(e,t){return this.check(zn(e,t))},min(e,t){return this.check(zn(e,t))},lt(e,t){return this.check(wn(e,t))},lte(e,t){return this.check(Sn(e,t))},max(e,t){return this.check(Sn(e,t))},int(e){return this.check(jo(e))},safe(e){return this.check(jo(e))},positive(e){return this.check(kn(0,e))},nonnegative(e){return this.check(zn(0,e))},negative(e){return this.check(wn(0,e))},nonpositive(e){return this.check(Sn(0,e))},multipleOf(e,t){return this.check(xn(e,t))},step(e,t){return this.check(xn(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Uo(e){return function(e,t){return new e({type:"number",checks:[],...Z(t)})}(Ro,e)}var qo=y("ZodNumberFormat",(e,t)=>{It.init(e,t),Ro.init(e,t)});function jo(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Z(t)})}(qo,e)}var Do=y("ZodBoolean",(e,t)=>{Nt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Zo(e){return function(e,t){return new e({type:"boolean",...Z(t)})}(Do,e)}var Mo=y("ZodUnknown",(e,t)=>{Ct.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Lo(){return new Mo({type:"unknown"})}var Fo=y("ZodNever",(e,t)=>{Pt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Bo(e){return function(e,t){return new e({type:"never",...Z(t)})}(Fo,e)}var Yo=y("ZodArray",(e,t)=>{Ut.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;"number"==typeof a&&(i.minItems=a),"number"==typeof s&&(i.maxItems=s),i.type="array",i.items=Nn(r.element,t,{...o,path:[...o.path,"items"]})})(e,t,n,o),e.element=t.element,lo(e,"ZodArray",{min(e,t){return this.check(En(e,t))},nonempty(e){return this.check(En(1,e))},max(e,t){return this.check(On(e,t))},length(e,t){return this.check(Tn(e,t))},unwrap(){return this.element}})});function Jo(e,t){return function(e,t,n){return new e({type:"array",element:t,...Z(n)})}(Yo,e,t)}var Wo=y("ZodObject",(e,t)=>{Mt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object",i.properties={};const a=r.shape;for(const u in a)i.properties[u]=Nn(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(i.required=Array.from(l)),"never"===r.catchall?._zod.def.type?i.additionalProperties=!1:r.catchall?r.catchall&&(i.additionalProperties=Nn(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,o),T(e,"shape",()=>t.shape),lo(e,"ZodObject",{keyof(){return oi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Lo()})},loose(){return this.clone({...this._zod.def,catchall:Lo()})},strict(){return this.clone({...this._zod.def,catchall:Bo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!R(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return D(e,A(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return $(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!R(t))throw new Error("Invalid input to safeExtend: expected a plain object");return D(e,A(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return $(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return D(e,A(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return $(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return D(e,A(e._zod.def,{get shape(){const e={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(e[o]=n.shape[o])}return $(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return D(e,A(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete o[e]}return $(this,"shape",o),o},checks:[]}))}(this,e)},partial(...e){return function(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return D(t,A(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)i[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return $(this,"shape",i),i},checks:[]}))}(si,this,e[0])},required(...e){return t=mi,n=this,o=e[0],D(n,A(n._zod.def,{get shape(){const e=n._zod.def.shape,i={...e};if(o)for(const n in o){if(!(n in i))throw new Error(`Unrecognized key: "${n}"`);o[n]&&(i[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)i[n]=new t({type:"nonoptional",innerType:e[n]});return $(this,"shape",i),i}}));var t,n,o}})});function Vo(e,t){return new Wo({type:"object",shape:e??{},...Z(t)})}var Go=y("ZodUnion",(e,t)=>{Ft.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=!1===i.inclusive,a=i.options.map((e,n)=>Nn(e,t,{...o,path:[...o.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=a:n.anyOf=a})(e,t,n,o),e.options=t.options});function Ho(e,t){return new Go({type:"union",options:e,...Z(t)})}var Ko=y("ZodDiscriminatedUnion",(e,t)=>{Go.init(e,t),Bt.init(e,t)});function Xo(e,t,n){return new Ko({type:"union",options:t,discriminator:e,...Z(n)})}var Qo=y("ZodIntersection",(e,t)=>{Yt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Nn(i.left,t,{...o,path:[...o.path,"allOf",0]}),a=Nn(i.right,t,{...o,path:[...o.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...s(r)?r.allOf:[r],...s(a)?a.allOf:[a]]})(e,t,n,o)});var ei=y("ZodRecord",(e,t)=>{Vt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object";const a=r.keyType,s=a._zod.bag?.patterns;if("loose"===r.mode&&s&&s.size>0){const e=Nn(r.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});i.patternProperties={};for(const t of s)i.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(i.propertyNames=Nn(r.keyType,t,{...o,path:[...o.path,"propertyNames"]})),i.additionalProperties=Nn(r.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=a._zod.values;if(l){const e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e)}})(e,t,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ti(e,t,n){return t&&t._zod?new ei({type:"record",keyType:e,valueType:t,...Z(n)}):new ei({type:"record",keyType:fo(),valueType:e,...Z(t)})}var ni=y("ZodEnum",(e,t)=>{Gt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=S(e._zod.def.entries);o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=o})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,o)=>{const i={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new ni({...t,checks:[],...Z(o),entries:i})},e.exclude=(e,o)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new ni({...t,checks:[],...Z(o),entries:i})}});function oi(e,t){return new ni({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Z(t)})}var ii=y("ZodLiteral",(e,t)=>{Ht.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=e._zod.def,i=[];for(const r of o.values)if(void 0===r){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof r){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(r))}else i.push(r);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ri(e,t){return new ii({type:"literal",values:Array.isArray(e)?e:[e],...Z(t)})}var ai=y("ZodTransform",(e,t)=>{Kt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new b(e.constructor.name);n.addIssue=o=>{if("string"==typeof o)n.issues.push(V(o,n.value,t));else{const t=o;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(V(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});var si=y("ZodOptional",(e,t)=>{Qt.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>jn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});function li(e){return new si({type:"optional",innerType:e})}var ui=y("ZodExactOptional",(e,t)=>{en.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>jn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var ci=y("ZodNullable",(e,t)=>{tn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=Nn(i.innerType,t,o),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function di(e){return new ci({type:"nullable",innerType:e})}var pi=y("ZodDefault",(e,t)=>{nn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var fi=y("ZodPrefault",(e,t)=>{rn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var mi=y("ZodNonOptional",(e,t)=>{an.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});var hi=y("ZodCatch",(e,t)=>{ln.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;let r;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var _i=y("ZodPipe",(e,t)=>{un.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=i.in._zod.traits.has("$ZodTransform"),a="input"===t.io?r?i.out:i.in:i.out;Nn(a,t,o),t.seen.get(e).ref=a})(e,t,0,o),e.in=t.in,e.out=t.out});function yi(e,t){return new _i({type:"pipe",in:e,out:t})}var gi=y("ZodReadonly",(e,t)=>{dn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;Nn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});var bi=y("ZodCustom",(e,t)=>{mn.init(e,t),uo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});var vi,wi=oi(["CONSENT","SOFT_OPT_IN","TRANSACTIONAL_ONLY","UNKNOWN"]),Si=oi(["MANUAL_UNSUB","ONE_CLICK_UNSUB","HARD_BOUNCE","COMPLAINT","ADMIN_BLOCK"]),ki=oi(["BROADCAST","AUTOMATION"]),zi=oi(["ABANDONED_CART","POST_PURCHASE","WELCOME","WIN_BACK","RE_ENGAGEMENT","TAG_ADDED"]),xi=(Vo({email:_o(),name:fo().trim().min(1).nullable().optional(),customer_id:fo().uuid().nullable().optional(),tags:Jo(fo().trim().min(1)).default([]),consent_basis:wi.default("UNKNOWN"),source:fo().trim().min(1).default("dashboard")}),Vo({name:fo().trim().min(1),subject:fo().trim().min(1),preheader:fo().nullable().optional(),mjml_source:fo().trim().min(1),builder_project_json:ti(fo(),Lo()).nullable().optional(),thumbnail_url:vn(bo,vi).nullable().optional()}),Vo({mjml_source:fo().trim().min(1),sample_variables:ti(fo(),Lo()).optional()}),Vo({recipient_email:_o(),sample_variables:ti(fo(),Lo()).optional()}),Vo({marketing_enabled:Zo().optional(),default_from_name:fo().trim().min(1).nullable().optional(),default_from_email:_o().nullable().optional(),default_reply_to_email:_o().nullable().optional(),physical_address:fo().trim().min(1).nullable().optional(),physical_address_line2:fo().trim().min(1).nullable().optional(),physical_city:fo().trim().min(1).nullable().optional(),physical_postal_code:fo().trim().min(1).nullable().optional(),physical_country:fo().trim().length(2).nullable().optional(),daily_limit:Uo().int().positive().optional(),monthly_soft_cap:Uo().int().positive().optional()}),Vo({type:ki.default("BROADCAST"),name:fo().trim().min(1),subject:fo().trim().min(1),template_id:fo().uuid(),list_id:fo().uuid().nullable().optional(),segment_id:fo().uuid().nullable().optional(),from_name:fo().trim().min(1),from_email:_o(),reply_to_email:_o().nullable().optional(),schedule_at:fo().datetime().nullable().optional(),target_emails:Jo(_o()).max(0,"Direct recipient entry is disabled. Use lists or segments built from Shoppex customers and paid order buyers.").default([]),idempotency_key:fo().trim().min(1).nullable().optional()}),Vo({name:fo().trim().min(1),subject:fo().trim().min(1),template_id:fo().uuid(),from_name:fo().trim().min(1),from_email:_o(),reply_to_email:_o().nullable().optional(),trigger:zi,delay_seconds:Uo().int().min(0).default(0),conditions:ti(fo(),Lo()).default({})}),Vo({trigger:zi,email:_o(),customer_id:fo().uuid().nullable().optional(),name:fo().trim().min(1).nullable().optional(),consent_basis:wi.default("UNKNOWN"),variables:ti(fo(),Lo()).default({}),idempotency_key:fo().trim().min(1).nullable().optional()}),Vo({email:_o(),reason:Si.default("ADMIN_BLOCK"),notes:fo().nullable().optional()}),["BITCOIN","LITECOIN","ETHEREUM","BITCOIN_CASH","MONERO","RIPPLE","TRON","SOLANA","POLYGON","BINANCE_COIN","CRONOS","CONCORDIUM","NANO","DOGECOIN","DASH"]),Oi=["NOWPAYMENTS","CRYPTOMUS","OXAPAY"],Ei=["NOWPAYMENTS_WHITELABEL"],Ti={USDT:["USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL"],USDC:["USDC_ERC20","USDC_TRC20","USDC_BEP20","USDC_POLYGON","USDC_SOL"],DAI:["DAI_ERC20"]},$i=Object.keys(Ti),Ai=[...Ti.USDT,...Ti.USDC,...Ti.DAI],Ii=[...xi,...Ai],Ni=["BITCOIN_LN"],Ci=[...Oi,...Ei],Pi=[...Ii,...Ni],Ri=Ii,Ui=new Set(xi),qi=new Set(Ai),ji=(new Set(Ii),new Set(Ni),new Set(Oi),new Set(Ei),new Set(Ci),new Set(Pi),new Set($i),new Set(["STRIPE","PAYPAL","PAYPAL_FF","MOLLIE","AUTHORIZENET","NMI","SQUARE","SUMUP","SHOPIFY","SUBY","PANDABASE","STORRIK","VENPAYR","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","CASHAPP","VENMO","CRYPTO","CUSTOMER_BALANCE","MANUAL"]),{CASHAPP:"CASH_APP",PAYPAL_CREDIT_CARD:"PAYPAL",EUTHEREUM:"ETHEREUM",USDT_MATIC:"USDT_POLYGON",USDC_MATIC:"USDC_POLYGON"});function Di(e,t){if(new Set(t).size!==t.length)throw new Error(`${e} contains duplicate entries`)}Di("COIN_GATEWAY_KEYS",xi),Di("TOKEN_GATEWAY_KEYS",Ai),Di("CRYPTO_GATEWAY_KEYS",Ii),Di("LEGACY_CRYPTO_GATEWAY_KEYS",Ni),Di("CRYPTO_PROVIDER_KEYS",Oi),Di("MANAGED_CRYPTO_PROVIDER_KEYS",Ei),Di("CRYPTO_PROVIDER_GATEWAY_KEYS",Ci),Di("DEFAULT_NOWPAYMENTS_CRYPTO_GATEWAY_KEYS",Ri),Di("DEFAULT_CRYPTOMUS_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDT_SOL","USDC_ERC20","USDC_BEP20","USDC_POLYGON","DAI_ERC20"]),Di("DEFAULT_OXAPAY_CRYPTO_GATEWAY_KEYS",["BITCOIN","LITECOIN","ETHEREUM","TRON","SOLANA","POLYGON","BINANCE_COIN","BITCOIN_CASH","MONERO","RIPPLE","DOGECOIN","USDT_TRC20","USDT_ERC20","USDT_BEP20","USDT_POLYGON","USDC_ERC20"]);for(const Rl of Ii)if(!Ui.has(Rl)&&!qi.has(Rl))throw new Error(`CRYPTO_GATEWAY_KEYS contains an unclassified gateway: ${Rl}`);new Set(["STRIPE","PAYPAL","PAYPAL_FF","SKRILL","CASHAPP","CASH_APP","PERFECT_MONEY","SQUARE","SUMUP","SHOPIFY","SUBY","PANDABASE","STORRIK","VENPAYR","MONEYMOTION","OVGC","WHOP","DODO","MAVERICK","VENMO","MOLLIE","AUTHORIZENET","NMI"].map(e=>function(e){const t=e.trim();if(!t)return"";if(/^manual:/i.test(t)){const e=t.slice(t.indexOf(":")+1).trim();return e?`MANUAL:${e}`:"MANUAL"}let n=t.toUpperCase();const o=n.match(/^(USDT|USDC|DAI):([A-Z0-9_]+)$/);if(o){const[,e,t]=o;n=`${e}_${"MATIC"===t?"POLYGON":t}`}return ji[n]??n}(e))),new Set(["WHITE_LABEL","NATIVE"]);var Zi=[...Ci,"NATIVE"],Mi=(new Set(Zi),Vo({set:Zo()})),Li=Vo({status:oi(["READY","NEEDS_ATTENTION"]).optional(),code:fo().optional(),message:fo().optional(),checked_at:fo().optional()}),Fi=(Vo({provider:fo(),type:fo(),enabled:Zo(),connected:Zo(),credentials:ti(fo(),Mi),public_config:ti(fo(),Lo()),webhook:ti(fo(),Lo()).optional(),health:Li.optional()}),"#2563eb"),Bi=["comfortable","compact"],Yi=["top","side","background"],Ji=oi(["checkout","payment_link","embed"]),Wi=oi(["current","clean-light","clean-dark","v2","v3"]),Vi=oi(Bi),Gi=oi(["light","dark","system"]),Hi=oi(Yi),Ki=oi(["ghost","outlined","filled"]),Xi=oi(["sheet","fullscreen","center"]),Qi=(oi(["checkout.shell","checkout.panel","checkout.header","brand.logo","product.card","product.image","product.title","product.description","product.price","product.quantity","product.addon","paymentLink.hero","summary.panel","summary.line","summary.total","form.field","form.label","form.help","coupon.input","input.base","input.error","button.primary","button.secondary","payment.methods","payment.method","payment.method.icon","payment.method.label","payment.method.meta","payment.method.fee","payment.method.indicator","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.launcher","embed.launcher.icon","embed.productCard","embed.productCard.image","embed.productCard.title","embed.productCard.price","embed.cart","embed.cart.row","embed.cart.summary","embed.modal","embed.modal.header","embed.modal.close","embed.skeleton","embed.loader","embed.branding"]),oi(["product.title","product.price","summary.total","payment.method.label","payment.provider_widget","payment.loading","payment.error","payment.warning","legal.terms","status.success","status.processing","embed.modal.close","embed.branding"]),fo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),er=fo().trim().min(1).max(200).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS color or gradient"),tr=fo().trim().min(1).max(400).refine(e=>!/[;{}]|@import|expression\s*\(/i.test(e),"Use a valid CSS box-shadow value"),nr=oi(["Inter","Geist","Manrope","Plus Jakarta Sans","DM Sans","Space Grotesk","Sora","IBM Plex Sans","JetBrains Mono","Arial","System UI"]),or=fo().trim().min(1).max(60).regex(/^[A-Za-z0-9 +\-_]+$/,"Use a Google Fonts family name"),ir=fo().url(),rr=Vo({brand:Vo({logoUrl:ir.optional().nullable(),logoDarkUrl:ir.optional().nullable(),logoMaxHeight:Uo().int().min(16).max(80).optional(),faviconUrl:ir.optional().nullable()}).strict().optional(),color:Vo({brand:Qi.optional(),brandContrast:Qi.optional(),background:Qi.optional(),surface:Qi.optional(),surfaceRaised:Qi.optional(),text:Qi.optional(),textMuted:Qi.optional(),border:Qi.optional(),focus:Qi.optional(),success:Qi.optional(),warning:Qi.optional(),error:Qi.optional()}).strict().optional(),typography:Vo({fontFamily:nr.optional(),googleFontFamily:or.optional(),baseSize:Uo().int().min(12).max(18).optional()}).strict().optional(),shape:Vo({buttonRadius:Uo().int().min(0).max(24).optional(),inputRadius:Uo().int().min(0).max(24).optional(),cardRadius:Uo().int().min(0).max(28).optional()}).strict().optional(),spacing:Vo({density:Vi.optional(),controlHeight:Uo().int().min(36).max(56).optional()}).strict().optional(),component:Vo({primaryButton:Vo({background:Qi.optional(),text:Qi.optional()}).strict().optional(),input:Vo({background:Qi.optional(),border:Qi.optional(),focusRing:er.optional()}).strict().optional(),summary:Vo({background:Qi.optional()}).strict().optional(),paymentMethod:Vo({background:er.optional(),cardBackground:er.optional(),border:er.optional(),selectedBackground:er.optional()}).strict().optional(),productCard:Vo({background:er.optional(),border:er.optional(),shadow:tr.optional()}).strict().optional(),productImage:Vo({background:er.optional(),border:er.optional(),icon:er.optional()}).strict().optional(),brandAvatar:Vo({background:er.optional(),text:Qi.optional(),border:er.optional()}).strict().optional(),pill:Vo({background:er.optional(),border:er.optional(),text:Qi.optional()}).strict().optional(),errorBanner:Vo({background:er.optional(),border:er.optional(),text:Qi.optional()}).strict().optional(),warningBanner:Vo({background:er.optional(),border:er.optional(),text:Qi.optional()}).strict().optional(),radio:Vo({idleRing:er.optional(),checkedFill:Qi.optional(),checkedIcon:Qi.optional()}).strict().optional(),divider:Vo({color:er.optional()}).strict().optional()}).strict().optional(),paymentLink:Vo({heroImageUrl:ir.optional().nullable(),heroPosition:Hi.optional()}).strict().optional(),embed:Vo({launcher:Vo({background:er.optional(),text:Qi.optional(),radius:Uo().int().min(0).max(28).optional(),paddingX:Uo().int().min(8).max(32).optional(),paddingY:Uo().int().min(6).max(24).optional(),shadow:tr.optional()}).strict().optional(),productCard:Vo({background:er.optional(),border:er.optional(),imageRadius:Uo().int().min(0).max(24).optional(),padding:Uo().int().min(8).max(32).optional()}).strict().optional(),cart:Vo({background:er.optional(),rowBorder:er.optional(),itemSpacing:Uo().int().min(4).max(28).optional()}).strict().optional(),modal:Vo({background:er.optional(),radius:Uo().int().min(0).max(32).optional(),maxWidth:Uo().int().min(360).max(960).optional(),shadow:tr.optional()}).strict().optional(),backdrop:Vo({color:er.optional(),blur:Uo().int().min(0).max(24).optional(),opacity:Uo().min(0).max(1).optional()}).strict().optional(),skeleton:Vo({background:er.optional(),shimmer:er.optional()}).strict().optional(),spinner:Vo({color:er.optional()}).strict().optional(),closeButton:Vo({style:Ki.optional()}).strict().optional(),mobile:Vo({layout:Xi.optional()}).strict().optional()}).strict().optional()}).strict(),ar=Vo({mode:Gi.default("system"),fontSource:oi(["curated"]).default("curated")}).strict(),sr=oi(["standalone","bundle","pointer"]),lr=Vo({name:fo().trim().min(1).max(80),fingerprint:fo().trim().min(1).max(128)}).strict(),ur=Vo({type:ri("shoppex.style_theme"),surface:ri("checkout"),format_version:Ho([ri(1),ri(2)]),name:fo().trim().min(1).max(80),description:fo().trim().max(240).optional(),embed_design:Wi.default("current"),token_schema_version:ri(1),tokens:rr.default({}),custom_css:fo().max(2e4).default(""),settings:ar.default({mode:"system",fontSource:"curated"}),_meta:ti(fo(),Lo()).optional()}).strict(),cr=(Vo({type:ri("shoppex.style_theme"),surface:Ji,format_version:Ho([ri(1),ri(2)]),name:fo().trim().min(1).max(80),description:fo().trim().max(240).optional(),embed_design:Wi.default("current"),token_schema_version:ri(1),tokens:rr.default({}),custom_css:fo().max(2e4).default(""),settings:ar.default({mode:"system",fontSource:"curated"}),share_mode:sr.default("standalone"),parent_hint:lr.optional(),bundled_parent:ur.optional(),_meta:ti(fo(),Lo()).optional()}).strict(),Vo({theme_id:fo().uuid().nullable(),surface:Ji,embed_design:Wi,token_schema_version:ri(1),revision:Uo().int().min(1),tokens:rr,custom_css:fo(),css_variables:ti(fo(),fo())}).strict(),Vo({theme_id:fo().uuid().nullable(),parent_theme_id:fo().uuid().nullable(),surface:ri("embed"),embed_design:Wi,token_schema_version:ri(1),revision:Uo().int().min(1),parent_revision:Uo().int().min(1).nullable(),tokens:rr,custom_css:fo(),css_variables:ti(fo(),fo())}).strict(),Vo({shop_id:fo().uuid(),product_id:fo().uuid().nullable(),product_group_id:fo().uuid().nullable(),payment_link_id:fo().uuid().nullable(),invoice_id:fo().nullable()}).strict(),Vo({embed_runtime:fo().min(16).max(128),embed_design:Wi,revision:Uo().int().min(1),parent_revision:Uo().int().min(1).nullable(),theme_id:fo().uuid().nullable(),css_variables:ti(fo(),fo()),custom_css:fo()}).strict(),Vo({embed_design:Wi.optional(),embed_style_revision:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...Z(t)})}(Ro,e)}().int().min(1).optional(),embed_runtime:fo().min(16).max(128).optional(),preview:Zo().optional()}).strict(),oi(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal"]),oi(["layout.header.before","layout.header.after","layout.overlay","home.hero.after","home.grid.before","product.buybox.after","layout.footer.before","floating.bottom_right"])),dr=(oi(["announcement_bar","countdown_bar","promo_info_card","recent_purchase_popup","coupon_popup_modal"]),fo().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,"Use a valid hex color")),pr=oi(["static","marquee"]),fr=oi(["brand_blue","emerald","sunset","rose","charcoal","custom"]),mr=oi(["hide","message"]),hr=oi(["compact","comfortable"]),_r=oi(["subtle","outline","solid"]),yr=oi(["minimal","boxed"]),gr=oi(["indigo","emerald","amber","rose","slate","custom"]),br=oi(["compact","feature","alert"]),vr=oi(["compact","comfortable"]),wr=oi(["subtle","outline","solid"]),Sr=oi(["sparkles","megaphone","gift","truck","shield","support","none"]),kr=oi(["show","hide"]),zr=oi(["midnight","ocean","ember","forest","custom"]),xr=oi(["delay","exit_intent"]),Or=fo().trim().refine(e=>{if(e.startsWith("/"))return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}},'Use a valid absolute URL or a path starting with "/"'),Er=fo().trim().refine(e=>{const t=new Date(e);return!Number.isNaN(t.getTime())},"Use a valid date and time"),Tr=Vo({text:fo().trim().min(1,"Text is required").max(160,"Text must be 160 characters or fewer"),linkLabel:fo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Or.optional().nullable(),dismissible:Zo().default(!1),displayMode:pr.default("marquee"),themePreset:fr.default("custom"),animationSpeedSeconds:Uo().int().min(8).max(40).default(30),backgroundColor:dr.default("#111827"),textColor:dr.default("#f9fafb")}),$r=Vo({text:fo().trim().min(1,"Text is required").max(120,"Text must be 120 characters or fewer"),endAt:Er,linkLabel:fo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Or.optional().nullable(),dismissible:Zo().default(!1),themePreset:fr.default("brand_blue"),expiredBehavior:mr.default("hide"),expiredMessage:fo().trim().max(120,"Expired message must be 120 characters or fewer").optional().nullable(),density:hr.default("compact"),ctaStyle:_r.default("subtle"),timerStyle:yr.default("boxed"),backgroundColor:dr.default("#111827"),textColor:dr.default("#f9fafb")}),Ar=Vo({eyebrow:fo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:fo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:fo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),linkLabel:fo().trim().max(32,"Link label must be 32 characters or fewer").optional().nullable(),linkUrl:Or.optional().nullable(),themePreset:gr.default("indigo"),layoutStyle:br.default("feature"),density:vr.default("comfortable"),ctaStyle:wr.default("outline"),icon:Sr.default("sparkles"),iconVisibility:kr.default("show"),backgroundColor:dr.default("#111827"),textColor:dr.default("#f9fafb"),accentColor:dr.default("#818cf8")}),Ir=Vo({title:fo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer").default("Recent purchases"),lookbackHours:Uo().int().min(1).max(168).default(24),cooldownSeconds:Uo().int().min(5).max(300).default(20),maxItems:Uo().int().min(1).max(20).default(8),anonymizeMode:oi(["first_name_city","first_name_country","initial_country","anonymous"]).default("first_name_city"),includedProductIds:Jo(fo().min(1)).max(50).default([])}),Nr=Vo({eyebrow:fo().trim().max(32,"Eyebrow must be 32 characters or fewer").optional().nullable(),title:fo().trim().min(1,"Title is required").max(80,"Title must be 80 characters or fewer"),body:fo().trim().min(1,"Body is required").max(240,"Body must be 240 characters or fewer"),couponCode:fo().trim().min(2,"Coupon code is required").max(40,"Coupon code must be 40 characters or fewer"),primaryButtonLabel:fo().trim().min(1,"Primary button label is required").max(24,"Primary button label must be 24 characters or fewer").default("Copy code"),secondaryButtonLabel:fo().trim().min(1,"Secondary button label is required").max(24,"Secondary button label must be 24 characters or fewer").default("Maybe later"),disclaimer:fo().trim().max(100,"Disclaimer must be 100 characters or fewer").optional().nullable(),themePreset:zr.default("midnight"),trigger:xr.default("delay"),delaySeconds:Uo().int().min(0).max(60).default(6),showOncePerSession:Zo().default(!0),reminderHours:Uo().int().min(1).max(720).default(24),backgroundColor:dr.default("#111827"),textColor:dr.default("#f8fafc"),accentColor:dr.default("#7c9cff"),heroImageUrl:Or.optional().nullable(),discountDisplay:fo().trim().max(24,"Discount display must be 24 characters or fewer").optional().nullable(),expiresAt:Er.optional().nullable()}),Cr=Vo({type:ri("announcement_bar"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Tr}),Pr=Vo({type:ri("recent_purchase_popup"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Ir}),Rr=Vo({type:ri("countdown_bar"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:$r}),Ur=Vo({type:ri("promo_info_card"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Ar}),qr=Vo({type:ri("coupon_popup_modal"),slot:cr,enabled:Zo().default(!0),sortOrder:Uo().int().min(0).max(999).default(0),config:Nr}),jr=(Xo("type",[Cr,Rr,Ur,Pr,qr]),Xo("type",[Cr.extend({id:fo().min(1)}),Rr.extend({id:fo().min(1)}),Ur.extend({id:fo().min(1)}),Pr.extend({id:fo().min(1)}),qr.extend({id:fo().min(1)})]),new Set(["amount","currency","invoice_id","customer_email","id","email","price","price_usd","product_name","quantity"].map(e=>e.toLowerCase())),ti(fo(),Lo())),Dr=Ho([fo(),Uo()]),Zr=Vo({default_value:fo().optional(),min_length:Uo().optional(),name:fo(),placeholder:fo().optional(),regex:fo().optional(),required:Zo(),type:fo()}),Mr=Vo({id:fo(),price:Uo(),quantity:Uo(),title:fo()}),Lr=Vo({addons:Jo(Mr).optional(),available_addons:Jo(Lo()).optional(),cloudflare_image_id:fo().nullable(),created_at:fo().optional(),currency:fo(),custom_fields:jr.nullable().optional(),custom_fields_config:Jo(Zr).nullable().optional(),delivery_instruction:Lo().optional(),delivery_instruction_config:Lo().optional(),delivery_instruction_label:Lo().optional(),delivery_text:fo().nullable().optional(),delivery_time:Uo().optional(),description:fo().nullable(),discount_percent:Uo().optional(),discount_display:Uo().optional(),discounted_total_display:Uo().optional(),gateways:Jo(fo()).nullable().optional(),id:fo().optional(),image_name:fo().nullable(),image_storage:fo().optional(),line_item_id:fo().nullable().optional(),pay_what_you_want:Zo().optional(),price:fo().optional(),price_display:Dr,quantity:Uo(),quantity_max:Uo().optional(),quantity_min:Uo().optional(),recurring_interval:fo().nullable().optional(),recurring_interval_count:Uo().nullable().optional(),redirect_link:fo().nullable().optional(),redirect_time:Uo().nullable().optional(),service_text:fo().nullable().optional(),setup_cost:fo().optional(),slug:fo().optional(),status:fo().nullable().optional(),subtype:fo().nullable().optional(),terms_of_service:fo().nullable().optional(),title:fo(),total:Uo(),trial_period:Uo().nullable().optional(),type:fo().nullable().optional(),uniqid:fo().nullable(),unit_price:Uo().optional(),unit_price_display:Dr.optional(),unit_quantity:Uo(),updated_at:fo().optional(),variant_title:fo().nullable().optional(),video_link:fo().nullable().optional(),volume_discounts:Lo().optional(),warranty_days:Uo().nullable().optional(),warranty_text:fo().nullable().optional()}),Fr=Vo({amount:Uo(),gateway:fo()}),Br=Vo({custom_tip_enabled:Zo().optional(),enabled:Zo(),preset_percentages:Jo(Uo()).optional()}),Yr=Vo({allow_partial_payment:Zo().optional(),auto_apply:Zo().optional(),available:fo(),currency:fo()}),Jr=Vo({affiliate_code:fo().nullable().optional(),already_paid:Dr.nullable().optional(),amount_due:Dr.nullable().optional(),currency:fo().nullable().optional(),discount:Dr.nullable().optional(),discount_label:fo().nullable().optional(),gateway_fee:Dr.nullable().optional(),platform_fee:Dr.nullable().optional(),subtotal:Dr.nullable().optional(),tip:Dr.nullable().optional(),total:Dr.nullable().optional()}),Wr=Vo({active:Zo(),expires_at:fo()}),Vr=Vo({faq_url:fo().nullable(),support_email:fo().nullable(),support_url:fo().nullable(),telegram_invite:fo().nullable()}),Gr=Vo({currency:fo().nullable().optional(),enabled:Zo(),max_amount:Uo().nullable().optional(),min_amount:Uo().nullable().optional(),reason:oi(["BELOW_MIN_AMOUNT","ABOVE_MAX_AMOUNT"]).nullable().optional()}),Hr=Vo({delivered_items:Jo(Lo()),downloads:Jo(Lo()),external_urls:Jo(Lo()),license_keys:Jo(Lo()),tracking_codes:Jo(Lo())}),Kr=Vo({active:Zo().optional(),attempt_id:fo().optional(),buyer_actionable:Zo().nullable().optional(),crypto_currency:fo().nullable().optional(),currency:fo().optional(),expected_amount:fo().nullable().optional(),expected_crypto_amount:fo().nullable().optional(),last_checked_at:fo().optional(),missing_amount:fo().nullable().optional(),missing_crypto_amount:fo().nullable().optional(),provider_reference:fo().nullable().optional(),provider_status:fo().nullable().optional(),received_amount:fo().nullable().optional(),received_crypto_amount:fo().nullable().optional(),shortfall_percent:fo().nullable().optional()}),Xr=Vo({created_at:fo().nullable(),details:fo().nullable(),id:fo(),invoice_id:fo(),status:fo().nullable()}),Qr=Vo({billing_address_mode:oi(["INHERIT","REQUIRED","DISABLED"]).optional(),button_label:fo().nullable().optional(),display_name:fo().nullable().optional(),gateway:fo(),hide_provider_attribution:Zo().optional(),icon_url:fo().nullable().optional(),terms_mode:oi(["INHERIT","REQUIRED","DISABLED"]).optional()}),ea=Vo({custom_fields:Jo(Lo()).optional(),description:fo().nullable(),display_order:Uo(),icon_preset:fo().nullable(),icon_url:fo().nullable(),id:fo(),instructions:fo().nullable(),is_active:Zo().optional(),name:fo(),payment_type:oi(["INSTRUCTIONS","REDIRECT"]),redirect_url:fo().nullable(),require_proof:Zo(),void_after_hours:Uo()}),ta=Vo({email:Vo({masked:fo().nullable(),persisted:Zo(),required_for_provider_session:Zo().optional()})}),na=Vo({amount:fo().nullable(),confirmations:Uo().nullable(),created_at:Uo().optional(),hash:fo().nullable(),status:fo().optional()}),oa=Vo({conf:Vo({partial:Uo().optional(),void:Uo(),waiting_for_confirmations:Uo().optional()}),gateways:Jo(fo())}),ia=Vo({invoice_payable:Zo(),resumable:Zo(),resumable_gateway:fo().nullable(),gateway:fo().nullable().optional(),crypto_gateway:fo().nullable().optional(),processor:fo().nullable().optional(),flow_type:fo().nullable().optional(),status:fo().nullable().optional(),provider_reference:fo().nullable().optional(),provider_reference_type:fo().nullable().optional(),capture_id:fo().nullable().optional(),manual_confirmation_pending:Zo().optional(),payment_method_switch_locked:Zo().optional(),awaiting_payment_method:Zo().optional(),started_at:Uo().nullable().optional(),completed_at:Uo().nullable().optional()}),ra=(Vo({already_paid_amount:Dr.nullable().optional(),apm_method:fo().nullable().optional(),blockchain:fo().nullable(),buyer_identity:ta.nullable().optional(),checkout_tipping:Br.nullable().optional(),country_regulations:fo().nullable().optional(),coupon_applied:Zo().optional(),crypto_mode:fo().nullable().optional(),crypto_transactions:Jo(na).optional(),currency:fo().nullable(),custom_fields:jr.nullable().optional(),custom_gateways:Jo(ea).optional(),customer_balance:Yr.nullable().optional(),customer_email_masked:fo().nullable().optional(),dark_mode:Ho([ri(0),ri(1)]).optional(),delivery:Hr.optional(),delivery_info:Hr.optional(),discount:Uo().optional(),discount_display:Dr.optional(),eligible_gateways:Jo(fo()).optional(),environment:fo().optional(),fee_breakdown:jr.nullable().optional(),gateway:fo().nullable(),gateway_data:jr.nullable().optional(),gateway_eligibility:ti(fo(),Gr).optional(),gateway_fee_previews:Jo(Fr).optional(),gateways_available:Jo(fo()),license:Ho([jr,ri(!1)]).optional(),name:fo().nullable(),paddle_token:fo().nullable().optional(),paddle_transaction_id:Lo().optional(),payment_link_id:fo().nullable().optional(),payment_method_overrides:Jo(Qr).optional(),payment_session_state:ia.nullable().optional(),polling:Wr,pricing_breakdown:Jr.nullable().optional(),product:Jo(Lr).optional(),quantity:Uo().nullable(),rates_snapshot:ti(fo(),Uo()).optional(),remaining_amount:Dr.nullable().optional(),selected_gateway:fo().nullable().optional(),shop_checkout_ambient_color:fo().nullable().optional(),shop_cloudflare_image_id:fo().nullable(),shop_domain:fo().nullable().optional(),shop_force_paypal_email_delivery:Ho([ri(0),ri(1)]).optional(),shop_image_name:fo().nullable(),shop_image_storage:fo().nullable().optional(),shop_payment_gateways_fees:Jo(jr).optional(),shop_paypal_credit_card:Ho([ri(0),ri(1)]).optional(),shop_return_url:fo().nullable().optional(),shop_slug:fo().nullable().optional(),shop_terms_enabled:Zo().optional(),shop_terms_of_service:fo().nullable().optional(),shop_terms_url:fo().nullable().optional(),shop_walletconnect_id:fo().nullable().optional(),status:fo().nullable(),status_history:Jo(Xr).optional(),status_history_legacy:Jo(Xr).optional(),status_history_raw:Jo(Xr).optional(),stripe_publishable_key:fo().nullable().optional(),stripe_user_id:fo().nullable().optional(),subtotal:Uo().optional(),subtype:fo().nullable().optional(),support:Vr.optional(),theme:fo().optional(),tip_amount:Dr.nullable().optional(),tip_amount_display:Dr.nullable().optional(),tip_metadata:Lo().optional(),total:Dr,total_conversions:jr.optional(),total_display:Dr,type:fo().nullable(),underpayment:Kr.nullable().optional(),underpayment_status:fo().nullable().optional(),uniqid:fo(),void_times:Jo(oa).optional(),addons:Lo().optional(),affiliate_data:Lo().optional(),affiliate_revenue_customer_id:fo().nullable().optional(),bill_info:Lo().optional(),binance_checkout_url:fo().nullable().optional(),binance_invoice_id:fo().nullable().optional(),binance_qrcode:fo().nullable().optional(),bundle_config:Lo().optional(),bundles:Lo().optional(),cashapp_cashtag:fo().nullable().optional(),cashapp_note:fo().nullable().optional(),cashapp_qrcode:fo().nullable().optional(),created_at:fo().optional(),crypto_address:fo().nullable().optional(),crypto_amount:Dr.optional(),crypto_confirmations_needed:Uo().nullable().optional(),crypto_exchange_rate:Dr.nullable().optional(),crypto_received:Dr.optional(),crypto_uri:fo().nullable().optional(),developer_invoice:Lo().optional(),developer_return_url:fo().nullable().optional(),developer_title:fo().nullable().optional(),exchange_rate:Dr.nullable().optional(),external_order_id:fo().nullable().optional(),lex_order_id:fo().nullable().optional(),lex_payment_method:fo().nullable().optional(),paydash_payment_id:fo().nullable().optional(),paypal_apm:fo().nullable().optional(),paypal_email_delivery:Zo().optional(),paypal_fee:Dr.nullable().optional(),paypal_order_id:fo().nullable().optional(),paypal_payer_email:fo().nullable().optional(),paypal_subscription_id:fo().nullable().optional(),paypal_subscription_link:fo().nullable().optional(),perfectmoney_id:fo().nullable().optional(),product_addons:Lo().optional(),product_id:fo().nullable().optional(),product_title:fo().nullable().optional(),product_type:fo().nullable().optional(),product_variants:Lo().optional(),recurring_billing_id:fo().nullable().optional(),skrill_link:fo().nullable().optional(),skrill_sid:fo().nullable().optional(),status_details:Lo().optional(),stripe_apm:fo().nullable().optional(),stripe_client_secret:fo().nullable().optional(),stripe_id:fo().nullable().optional(),stripe_price_id:fo().nullable().optional(),subscription:Lo().optional(),subscription_id:fo().nullable().optional(),sumup_id:fo().nullable().optional(),telegram_stars_payment_link:fo().nullable().optional(),telegram_stars_payment_note:fo().nullable().optional(),updated_at:fo().optional(),virtual_payments_id:fo().nullable().optional(),void_details:Lo().optional()}).catchall(Lo()),fo().nullable()),aa=ti(fo(),Lo()),sa=Vo({logo_url:ra,primary_color:fo(),secondary_color:fo(),accent_color:fo()}),la=Vo({attachment_image_id:Vo({cloudflare_image_id:ra}).nullable()}),ua=Vo({attachment_imageId:Vo({cloudflareImageId:ra}).nullable()}),ca=Vo({uniqid:fo(),status:fo(),total:fo(),total_display:ra,currency:fo(),created_at:fo(),line_items:Jo(Vo({product_title:ra,quantity:Uo(),product:la.nullable()}))}),da=Vo({uniqid:fo(),status:fo(),total:fo(),totalDisplay:ra,currency:fo(),createdAt:fo(),lineItems:Jo(Vo({productTitle:ra,quantity:Uo(),product:ua.nullable()}))}),pa=(Vo({invoices:Jo(da),pagination:Vo({page:Uo(),limit:Uo(),total:Uo(),has_more:Zo()})}),Vo({gateway:fo(),blockchain:ra,cryptoAddress:ra,apmMethod:ra})),fa=(Vo({id:fo(),uniqid:fo(),status:fo(),statusDetails:ra,total:fo(),totalDisplay:ra,subtotal:fo(),discount:fo(),discountDisplay:ra,tax:fo(),taxPercentage:fo(),currency:fo(),createdAt:fo(),updatedAt:fo(),gatewayUpdatedAt:ra,customFields:aa.nullable(),balancePaidAmount:fo(),currentPaymentAttemptId:ra,lineItems:Jo(Vo({id:fo(),productTitle:fo(),productType:fo(),variantTitle:ra,unitPrice:fo(),quantity:Uo(),total:fo(),deliverySummary:Vo({codes:Jo(fo()),links:Jo(Vo({label:fo(),value:fo(),href:ra.optional()})),notes:Jo(fo()),serials:Jo(Vo({value:fo(),is_replacement:Zo(),is_replaced:Zo()}))}).nullable(),deliveredAt:ra,customFields:aa.nullable(),product:Vo({uniqid:fo(),slug:ra,serviceText:ra,deliveryText:ra,attachment_imageId:Vo({cloudflareImageId:ra}).nullable()}).nullable()})),currentPayment:pa.nullable(),payments:Jo(pa)}),Vo({quote:Vo({enabled:Zo(),currency:fo(),min_amount:fo(),max_amount:ra,bonus_tiers:Jo(Vo({min_amount:fo(),bonus_percent:Uo()}))})}),Vo({invoice_id:fo(),url:fo()}),Vo({id:fo(),type:fo(),status:fo(),amount:ra,currency:ra,coupon_code:ra,reason:fo(),trigger_reference_type:fo(),trigger_reference_id:fo(),created_at:Uo(),fulfilled_at:Uo().nullable(),expires_at:Uo().nullable()})),ma=Vo({summary:Vo({available:fo(),pending:fo(),lifetime_earned:fo(),redeemed:ra,currency:fo()}),activity:Jo(fa),earned_after_invoice:Jo(fa),pending_after_invoice:Jo(fa)}),ha=Vo({id:fo(),uniqid:fo(),code:fo(),url:ra,total_clicks:Uo(),total_sales:Uo(),total_revenue:fo(),is_active:Zo(),is_approved:Zo(),created_at:ra,updated_at:ra}),_a=Vo({customer:Vo({id:fo(),email:fo(),name:ra}).nullable(),state:fo(),can_edit_custom_code:Zo(),custom_code_edit_disabled_reason:ra,commission_shareback:Vo({enabled:Zo(),percent:Uo(),max_percent:Uo()}),cash_payout_enabled:Zo(),link:ha.nullable(),links:Jo(ha),preferred_payout:Vo({asset:fo(),network:fo(),address:fo()}).nullable(),balance_currency:fo(),balances:Vo({pending:fo(),available:fo(),requested:fo(),converted:fo(),paid:fo(),approved_total:fo()}),commissions:Jo(Vo({id:fo(),invoice_id:fo(),commission_amount:fo(),base_amount:fo(),discount_amount:fo(),status:fo(),created_at:ra,paid_at:ra,converted_at:ra})),claims:Jo(Vo({id:fo(),type:fo(),status:fo(),amount:fo(),currency:fo(),allocations:Jo(Vo({source_type:fo(),commission_id:ra,adjustment_id:ra,amount:fo()})),wallet_transaction_id:ra,payout_asset:ra,payout_network:ra,payout_address:ra,note:ra,metadata:Lo(),completed_at:ra,rejected_at:ra,cancelled_at:ra,created_at:ra,updated_at:ra}))}),ya=Vo({uniqid:fo(),status:fo(),gateway:fo(),current_period_start:fo(),current_period_end:fo(),trial_end:ra,cancel_at_period_end:Zo(),canceled_at:ra,created_at:fo(),plan:Vo({id:fo(),uniqid:fo(),name:fo(),price:fo(),currency:fo(),interval:fo(),interval_count:Uo(),trial_days:Uo()}).nullable(),payment_method:Vo({id:fo(),gateway:fo(),type:fo(),card_brand:ra,card_last4:ra,card_exp_month:Uo().nullable(),card_exp_year:Uo().nullable(),is_default:Zo()}).nullable(),actions:Vo({can_pause:Zo(),can_resume:Zo(),can_cancel:Zo(),can_manage_payment_method:Zo()})}),ga=(Vo({shop:Vo({id:fo(),slug:fo(),name:fo(),currency:fo(),branding:sa}),customer:Vo({email:fo(),name:fo()}),stats:Vo({invoices_count:Uo(),licenses_count:Uo(),deliverables_count:Uo(),tickets_count:Uo()}),wallet:Vo({available:fo(),total:fo(),hold:fo(),currency:fo(),enabled:Zo()}).nullable(),rewards:ma,affiliate:_a,invoices:Jo(ca),subscriptions:Jo(ya),licenses:Jo(Vo({uniqid:fo(),license_key:fo(),hardware_id:ra,expires_at:Uo().nullable(),product:Vo({title:fo().optional()}).optional()})),deliverables:Jo(Vo({id:fo(),invoice_uniqid:fo(),product_title:fo(),kind:oi(["file","serial","license"]),label:fo(),value:fo(),href:ra,created_at:fo()})),tickets:Jo(Vo({uniqid:fo(),title:fo(),status:fo(),updated_at:fo(),created_at:ra}))}),fo().nullable()),ba=Vo({id:fo(),uniqid:fo(),title:fo()}),va=Vo({id:fo(),title:ga}),wa=Vo({id:fo(),title:ga,price:Uo(),stock:Uo().nullable(),commission_percent:Uo().nullable(),wholesale_price:Uo().nullable(),auto_fulfilled_enabled:Zo(),min_resale_price:Uo().nullable(),max_resale_price:Uo().nullable(),min_quantity:Uo().nullable(),max_quantity:Uo().nullable()}),Sa=(Vo({products:Jo(Vo({id:fo(),uniqid:fo(),title:fo(),type:fo(),currency:fo(),price:Uo(),stock:Uo().nullable(),commission_percent:Uo().nullable(),wholesale_price:Uo().nullable(),auto_fulfilled_enabled:Zo(),min_resale_price:Uo().nullable(),max_resale_price:Uo().nullable(),min_quantity:Uo().nullable(),max_quantity:Uo().nullable(),variants:Jo(wa)}))}),Vo({balances:Vo({pending:Uo(),available:Uo(),requested:Uo(),converted:Uo(),paid:Uo(),approved_total:Uo()}),preferred_payout:Vo({asset:fo(),network:fo(),address:fo()}).nullable(),payout_requests:Jo(Vo({id:fo(),status:fo(),amount:Uo(),currency:ga,payout_asset:ga,payout_network:ga,payout_address:ga,note:ga,processing_mode:oi(["manual","invoice_funding","automatic"]).nullable(),funding_invoice:Vo({invoice_id:ga,invoice_uniqid:ga,invoice_status:ga,checkout_url:ga}).nullable(),created_at:fo(),updated_at:ga,completed_at:ga,rejected_at:ga,cancelled_at:ga}))}),Vo({id:fo(),name:fo(),slug:fo()})),ka=(Vo({summary:Vo({total:Uo(),available:Uo(),delivered:Uo(),revoked:Uo()}),items:Jo(Vo({id:fo(),transfer_id:fo(),reseller_relationship_id:fo(),status:fo(),merchant_shop:Sa,product:ba,variant:va.nullable(),serial_id:ga,delivered_to_email:ga,delivered_at:ga,created_at:fo()}))}),Vo({summary:Vo({available:Uo()}),items:Jo(Vo({id:fo(),transfer_id:fo(),reseller_relationship_id:fo(),serial_id:ga,serial:ga,merchant_shop:Sa,product:ba,variant:va.nullable(),created_at:fo()}))}),Vo({item:Vo({id:fo(),transfer_id:fo(),reseller_relationship_id:fo(),product_id:fo(),variant_id:ga,serial_id:ga,serial:ga,status:fo(),delivered_to_email:ga,delivered_at:ga,created_at:fo(),updated_at:fo()})}),Vo({id:fo(),reseller_relationship_id:fo(),invoice_id:ga,product_id:fo(),variant_id:ga,status:fo(),quantity:Uo(),wholesale_unit_price:Uo(),currency:fo(),created_at:fo(),updated_at:fo()})),za=(Vo({transfer:ka.extend({product:ba})}),Vo({id:fo(),uniqid:fo(),type:ga,status:ga,total:Uo(),currency:ga,checkout_url:fo(),created_at:ga}));Vo({transfers:Jo(ka.extend({product:ba,variant:va.nullable(),invoice:Vo({id:fo(),uniqid:fo(),status:ga,checkout_url:fo()}).nullable()}))}),Vo({transfer:ka,invoice:za});var xa=null,Oa=null;var Ea=null,Ta=null;function $a(e,t){const n=t?.shopId?.trim();return Ta=n||null,xa=null,Oa=null,Ea={storeSlug:e,locale:t?.locale,currency:t?.currency,apiBaseUrl:t?.apiBaseUrl??"https://api.shoppex.io",checkoutBaseUrl:t?.checkoutBaseUrl??"https://checkout.shoppex.io"}}function Aa(){if(!Ea)throw new n;return Ea}function Ia(){return null!==Ea}function Na(e){Ta=e}function Ca(){return Ta}function Pa(e){const t=e?.trim().toLowerCase()??"";return"true"===t||"1"===t||"yes"===t||"on"===t}function Ra(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):null}function Ua(e){if(!0===e)return!0;if("number"==typeof e&&Number.isFinite(e))return 0!==e;if("string"==typeof e){const t=e.trim().toLowerCase();return"true"===t||"1"===t}return!1}function qa(e){if(!e)return-1;if("string"==typeof e.type&&"SERIALS"===e.type.toUpperCase())return Ra(e.stock)??-1;const t=function(e){const t=Array.isArray(e.price_variants)?e.price_variants.map(e=>Ra(e.stock)):[];return t.length>0?t:Array.isArray(e.variants)?e.variants.map(e=>Ra(e.stock)):[]}(e);return t.length>0?t.some(e=>null===e||e<0)?-1:t.filter(e=>null!==e).reduce((e,t)=>e+Math.max(t,0),0):Ra(e.stock)??-1}function ja(e){return!!function(e){return!!e&&(Ua(e.on_hold)||Ua(e.onHold)||Ua(e.is_on_hold)||Ua(e.isOnHold))}(e)||0===qa(e)}function Da(e){return!ja(e)}function Za(e=[]){const t=new Map;for(const n of e)n?.uniqid&&!t.has(n.uniqid)&&t.set(n.uniqid,n);return t}function Ma(e,t=[]){const n=t instanceof Map?t:Za(t);return(e.product_uniqids??[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})}function La(e=[]){return Array.from(Za(e).values())}function Fa(e){return e?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():""}function Ba(e){return e.trim().toLowerCase()}function Ya(e,t){const n=Fa(t).toLowerCase();n&&e.push(n)}function Ja(e){const t=[];Ya(t,e.title),Ya(t,e.slug??void 0),Ya(t,e.description);for(const n of e.product_highlights??[])Ya(t,n);for(const n of e.variants??[])Ya(t,n.title);for(const n of e.price_variants??[])Ya(t,n.title??n.label);return t}function Wa(e,t){const n=Ba(t);return!!n&&Ja(e).some(e=>e.includes(n))}function Va(e,t){const n=Ba(t);if(!n)return!1;const o=Fa(e.title).toLowerCase(),i=Fa(e.slug??e.name??void 0).toLowerCase(),r=Fa(e.description).toLowerCase();return o.includes(n)||i.includes(n)||r.includes(n)}function Ga(e,t){return 0!==e.length&&(!t||e.some(e=>Da(e)))}function Ha(e,t,n,o){const i=Ba(n);if(!i)return[];const r=!0===o?.hideOutOfStock,a=new Set,s=new Set,l=[],u=Za(e);for(const d of t){const e=d.uniqid??d.id;if(!e||s.has(e))continue;if(!Va(d,i))continue;const t=Ma(d,u);if(Ga(t,r)){s.add(e);for(const e of t)e?.uniqid&&a.add(e.uniqid);l.push({type:"group",group:d,products:t})}}const c=La(e);for(const d of c)d?.uniqid&&!a.has(d.uniqid)&&Wa(d,i)&&(r&&!Da(d)||(a.add(d.uniqid),l.push({type:"product",product:d})));return null!=o?.maxResults?l.slice(0,o.maxResults):l}function Ka(e,t,n,o){const i=Ha(e,t,n,o),r=new Set,a=[],s=e=>{e?.uniqid&&!r.has(e.uniqid)&&(o?.hideOutOfStock&&!Da(e)||(r.add(e.uniqid),a.push(e)))};for(const l of i)if("product"!==l.type)for(const e of l.products)s(e);else s(l.product);return null!=o?.maxResults?a.slice(0,o.maxResults):a}function Xa(e){if(e?.apiBaseUrl?.trim())return e.apiBaseUrl.replace(/\/+$/,"");const t=e?.hostname??("undefined"!=typeof window?window.location.hostname:"");if(t&&!function(e){if("localhost"===e||"127.0.0.1"===e||"::1"===e||e.endsWith(".localhost"))return!0;if(/^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e))return!0;if(/^192\.168\.\d{1,3}\.\d{1,3}$/.test(e))return!0;const t=e.match(/^172\.(\d{1,2})\.\d{1,3}\.\d{1,3}$/);if(t){const e=Number(t[1]);return e>=16&&e<=31}return!1}(t))return"https://api.shoppex.io";if("undefined"!=typeof window){const e=window.apiBaseUrl;if("string"==typeof e&&e.trim())return e.replace(/\/+$/,"")}return"http://localhost:3001".replace(/\/+$/,"")}function Qa(e){const t=e.name?.trim()??"",n=`${t?`Name: ${t}\n\n`:""}${e.message.trim()}`,o=e.maxLength??2e3;return n.slice(0,o)}var es=new Map,ts=new Map,ns={hits:0,misses:0};function os(e,t,n){const o=Date.now();es.set(e,{data:t,ttl:n,updatedAt:o,expiresAt:o+n})}async function is(e,t,n,o=()=>!0){const i=function(e){const t=es.get(e);return t||null}(e);if(i&&!function(e){return Date.now()>e.expiresAt}(i))return ns.hits+=1,i.data;if(i&&n.staleWhileRevalidate){if(ns.hits+=1,!ts.has(e)){const i=(async()=>{try{const i=await t();return o(i)&&os(e,i,n.ttl),i}finally{ts.delete(e)}})();ts.set(e,i)}return i.data}if(ts.has(e))return ts.get(e);ns.misses+=1;const r=(async()=>{try{const i=await t();return o(i)&&os(e,i,n.ttl),i}finally{ts.delete(e)}})();return ts.set(e,r),r}var rs=/:([A-Za-z0-9_]+)/g;function as(e,t){return e.replace(rs,(e,n)=>{const o=t[n];if(null==o)throw new Error(`Missing endpoint param: ${n}`);const i=String(o).trim();if(!i)throw new Error(`Endpoint param "${n}" must not be empty`);return encodeURIComponent(i)})}function ss(e){return`shoppex_${e}`}function ls(e){try{const t=localStorage.getItem(ss(e));return t?JSON.parse(t):null}catch{return null}}function us(e,t){try{localStorage.setItem(ss(e),JSON.stringify(t))}catch{console.warn("[shoppex] Failed to save to localStorage")}}function cs(e){try{localStorage.removeItem(ss(e))}catch{}}function ds(e){if("undefined"==typeof window)return null;const t=`presence_connection_${e}`,n=ls(t);if(n&&n.trim())return n;const o="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`spx_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;return us(t,o),o}async function ps(e){if(!Ia())return;if("undefined"==typeof window)return;if(function(e){const t=`client_error_${function(e){return[e.method,e.endpoint,e.statusCode??"none",e.message.trim().toLowerCase(),e.responseReceived?"response":"no-response"].join("|")}(e)}`,n=Date.now(),o=ls(t);return"number"==typeof o&&n-o<15e3||(us(t,n),!1)}(e))return;const t=Aa(),n=Ca(),o=n?as("/v1/storefront/shops/id/:id/ping",{id:n}):as("/v1/storefront/shops/:storeSlug/ping",{storeSlug:t.storeSlug}),i=JSON.stringify({event_type:"client_error",referer:document.referrer||void 0,connection_id:ds(t.storeSlug)??void 0,client_error:{source:e.source??"sdk",phase:e.phase??"request",endpoint:e.endpoint,method:e.method,message:e.message,status_code:e.statusCode,attempt_count:e.attemptCount,response_received:e.responseReceived??!1,page_url:e.pageUrl??window.location.href,request_url:e.requestUrl,online:e.online??("undefined"!=typeof navigator?navigator.onLine:void 0),visibility_state:e.visibilityState??("undefined"!=typeof document?document.visibilityState:void 0)}}),r=`${t.apiBaseUrl}${o}`;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const e=new Blob([i],{type:"application/json"});if(navigator.sendBeacon(r,e))return}await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0})}catch{}}var fs=1e4;async function ms(e){return new Promise(t=>setTimeout(t,e))}async function hs(e,t={}){const n=t.baseUrl?null:Aa(),{method:i="GET",body:r,timeout:a=fs,retries:s,baseUrl:l,cache:u}=t,c=s??("GET"===i?2:0),d=`${l??n?.apiBaseUrl??""}${e}`,p={"Content-Type":"application/json",Accept:"application/json"};let f=null;const m=async()=>{for(let t=0;t<=c;t++)try{const e=new AbortController,t=setTimeout(()=>e.abort(),a),n=await fetch(d,{method:i,headers:p,body:r?JSON.stringify(r):void 0,signal:e.signal});clearTimeout(t);const s=await _s(n);if(!n.ok){const e=n.statusText?`HTTP ${n.status}: ${n.statusText}`:`HTTP ${n.status}`;throw new o((s.data&&"object"==typeof s.data&&"error"in s.data&&"string"==typeof s.data.error?s.data.error:null)??(s.data&&"object"==typeof s.data&&"message"in s.data&&"string"==typeof s.data.message?s.data.message:null)??s.rawText??e,n.status)}if(204===n.status&&null===s.data)return{success:!0};if(!s.data||"object"!=typeof s.data||!("status"in s.data))throw new o("Invalid API response",n.status);return ys(s.data)}catch(e){let n=e instanceof Error?e:new Error(String(e));e instanceof DOMException&&"AbortError"===e.name&&(n=new o("Request timeout",408));const i=n instanceof o?n.statusCode:void 0;if(f={message:n.message,statusCode:i,isTransport:void 0===i||408===i},t<c){await ms(500*Math.pow(2,t));continue}}return{success:!1,message:f?.message??"Unknown error"}},h="GET"===i&&u&&u.ttl>0?await is(u.key??`GET:${d}`,m,{ttl:u.ttl,staleWhileRevalidate:u.staleWhileRevalidate},e=>e.success):await m(),_=f;return!h.success&&_?.isTransport&&await ps({endpoint:e,method:i,message:h.message??_.message,statusCode:_.statusCode,attemptCount:c+1,requestUrl:d,responseReceived:void 0!==_.statusCode&&408!==_.statusCode}),h}async function _s(e){const t=e;if("function"!=typeof t.text){if("function"==typeof t.json)try{return{data:await t.json(),rawText:null}}catch{return{data:null,rawText:null}}return{data:null,rawText:null}}try{const e=await t.text();if(!e)return{data:null,rawText:null};try{return{data:JSON.parse(e),rawText:null}}catch{const t=e.trim();return{data:null,rawText:t.length>0?t:null}}}catch{return{data:null,rawText:null}}}function ys(e){return e.status>=200&&e.status<300?{success:!0,data:e.data,...e.message?{message:e.message}:{}}:{success:!1,message:e.error??e.message??`Request failed with status ${e.status}`}}async function gs(e,t){return hs(e,{...t,method:"GET"})}async function bs(e,t,n){return hs(e,{...n,method:"POST",body:t})}var vs=3e5;async function ws(){const e=Aa(),t=await gs(as("/v1/storefront/shops/name/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`store:${e.storeSlug}`,ttl:vs,staleWhileRevalidate:!0}});return t.success&&t.data?(t.data.shop?.id&&Na(t.data.shop.id),{success:!0,data:t.data.shop}):{success:!1,message:t.message}}async function Ss(e){const t=Aa(),n=new URLSearchParams;Number.isFinite(e?.productsLimit)&&n.set("products_limit",String(Math.max(1,Math.floor(e?.productsLimit??0)))),"string"==typeof e?.productsCursor&&e.productsCursor.trim().length>0&&n.set("products_cursor",e.productsCursor);const o=n.size>0?`?${n.toString()}`:"",i=await gs(`${as("/v1/storefront/shops/name/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`storefront:${t.storeSlug}:${e?.productsLimit??"full"}:${e?.productsCursor??"start"}`,ttl:vs,staleWhileRevalidate:!0}});return i.success&&i.data?(i.data.shop?.id&&Na(i.data.shop.id),{success:!0,data:{shop:i.data.shop,products:i.data.products??[],products_pagination:i.data.products_pagination??null,groups:i.data.groups??[],items:i.data.items??[],categories:i.data.categories??[],addons:i.data.addons??{items:[]}}}):{success:!1,message:i.message}}var ks=12e4;function zs(e){if(e.variants&&e.variants.length>0)return e;const t=e.price_variants;return Array.isArray(t)&&0!==t.length?{...e,variants:t.map(e=>function(e){return{id:e.id,title:e.title??e.label??"",price:"number"==typeof e.price?e.price:Number(e.price)||0,stock:"number"==typeof e.stock?e.stock:void 0,quantity_min:e.quantity_min,quantity_max:e.quantity_max,quantityMin:e.quantityMin,quantityMax:e.quantityMax,image_id:e.image_id,imageId:e.imageId,cloudflare_image_id:e.cloudflare_image_id,cloudflareImageId:e.cloudflareImageId,image_url:e.image_url,imageUrl:e.imageUrl}}(e))}:e}async function xs(){const e=Aa(),t=await gs(as("/v1/storefront/products/public/:storeSlug",{storeSlug:e.storeSlug}),{cache:{key:`products:${e.storeSlug}`,ttl:ks,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:La(t.data.products.map(zs))}:{success:!1,message:t.message,data:[]}}function Os(e){if(!e)return{};const t=Object.entries(e).filter(([,e])=>"string"==typeof e).sort(([e],[t])=>e.localeCompare(t));return Object.fromEntries(t)}function Es(e){const t={product_id:e.product_id,variant_id:e.variant_id,price_variant_id:e.price_variant_id??null,addons:(n=e.addons,n?.length?[...n].map(e=>({id:e.id,quantity:e.quantity??1})).sort((e,t)=>e.id.localeCompare(t.id)):[]),custom_fields:Os(e.custom_fields),unit_price:"number"==typeof e.price_data?.unit_price&&Number.isFinite(e.price_data.unit_price)?e.price_data.unit_price:null};var n;return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(t))}function Ts(e){return"string"==typeof e.line_id&&e.line_id.trim()?e:{...e,line_id:Es(e)}}var $s={cart:"cart",cartBackup:"cart_backup",meta:"cart_meta",metaBackup:"cart_backup_meta",coupon:"cart_coupon",couponBackup:"cart_coupon_backup"};function As(e){return`${$s[e]}_${Aa().storeSlug}`}function Is(e){return function(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16)}(JSON.stringify(e))}function Ns(e){if(!Number.isFinite(e))throw new i("quantity must be a finite number");return Math.floor(e)}function Cs(e){const t=e?.trim().toUpperCase();return t||null}function Ps(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e=n,o="string"==typeof e.product_id?e.product_id.trim():"",i="string"==typeof e.variant_id?e.variant_id.trim():"",r=Number(e.quantity);if(!o||!i||!Number.isFinite(r)||r<1)continue;const a={line_id:"",product_id:o,variant_id:i,quantity:Math.floor(r)};if("string"==typeof e.price_variant_id&&(a.price_variant_id=e.price_variant_id),e.price_data&&"object"==typeof e.price_data){const t=e.price_data;"number"==typeof t.unit_price&&Number.isFinite(t.unit_price)&&(a.price_data={unit_price:t.unit_price})}Array.isArray(e.addons)&&(a.addons=e.addons),e.custom_fields&&"object"==typeof e.custom_fields&&!Array.isArray(e.custom_fields)&&(a.custom_fields=e.custom_fields),"string"==typeof e.title&&(a.title=e.title),"string"==typeof e.variant_title&&(a.variant_title=e.variant_title),"string"==typeof e.image_url&&(a.image_url=e.image_url),Array.isArray(e.addon_labels)&&(a.addon_labels=e.addon_labels.filter(e=>"string"==typeof e)),"number"==typeof e.max_quantity&&Number.isFinite(e.max_quantity)&&(a.max_quantity=e.max_quantity),"number"==typeof e.min_quantity&&Number.isFinite(e.min_quantity)&&(a.min_quantity=e.min_quantity),Ls(a),a.line_id=("string"==typeof e.line_id?e.line_id.trim():"")||Es(a),t.push(Ts(a))}return t}function Rs(){return ls(As("meta"))}function Us(){const e=ls(As("coupon"));return"string"!=typeof e?null:Cs(e)}function qs(e){const t=Cs(e);return t?(us(As("coupon"),t),t):(cs(As("coupon")),null)}function js(){cs(As("coupon"))}function Ds(e){const t=Ps(e);us(As("cart"),t);const n=Date.now(),o=Rs(),i={created_at:o?.created_at??n,last_modified:n,version:(o?.version??0)+1,checksum:Is(t)};us(As("meta"),i),0===t.length&&js()}function Zs(e,t){const n=Ps(e);us(As("cart"),n);const o=Date.now(),i=t??Rs(),r={created_at:i?.created_at??o,last_modified:o,version:i?.version??1,checksum:Is(n)};us(As("meta"),r)}function Ms(){return Ps(ls(As("cart")))}function Ls(e){const t=e.min_quantity;"number"==typeof t&&Number.isFinite(t)&&e.quantity<t&&(e.quantity=Math.floor(t));const n=e.max_quantity;"number"==typeof n&&Number.isFinite(n)&&e.quantity>n&&(e.quantity=Math.floor(n)),e.quantity<1&&(e.quantity=1)}function Fs(){cs(As("cart")),cs(As("meta")),js()}function Bs(){const e=Ms();us(As("cartBackup"),e);const t=Us();t?us(As("couponBackup"),t):cs(As("couponBackup"));const n=Rs();if(n)us(As("metaBackup"),n);else{const t=Date.now();us(As("metaBackup"),{created_at:t,last_modified:t,version:1,checksum:Is(e)})}}function Ys(){const e=Ms(),t=Rs(),n=Is(e);return t?t.checksum===n:(Zs(e,null),!0)}var Js="shoppex:affiliate_code:v1";function Ws(){return Date.now()}function Vs(e){const t=e?.trim().toLowerCase();return t||null}function Gs(e,t=30){const n=Vs(e);return n?(function(e){if("undefined"!=typeof window)try{window.localStorage.setItem(Js,JSON.stringify(e))}catch{}}({code:n,expiresAt:Ws()+(o=t,24*Math.max(1,o)*60*60*1e3)}),n):(Hs(),null);var o}function Hs(){if("undefined"!=typeof window)try{window.localStorage.removeItem(Js)}catch{}}function Ks(){const e=function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(Js);if(!e)return null;const t=JSON.parse(e);return t&&"string"==typeof t.code&&"number"==typeof t.expiresAt?t:null}catch{return null}}();return e?e.expiresAt<=Ws()?(Hs(),null):Vs(e.code):null}async function Xs(e){const t=Vs(e);if(!t)return{success:!1,data:{valid:!1,affiliate_code:null,discount_active:!1,discount_percent:0},message:"Affiliate code is required"};const n=await bs("/v1/storefront/affiliates/resolve",{shop_slug:Aa().storeSlug,code:t},{retries:0});if(!n.success)return n;if(!n.data?.valid||!n.data.affiliate_code){const e=!1===n.data?.program_enabled;return{success:!1,data:{valid:!1,...void 0!==n.data?.program_enabled?{program_enabled:n.data.program_enabled}:{},affiliate_code:null,discount_active:!1,discount_percent:0},message:n.message??(e?"Affiliate program is disabled for this shop.":"Invalid affiliate code.")}}return{success:!0,data:{valid:!0,...void 0!==n.data.program_enabled?{program_enabled:n.data.program_enabled}:{},affiliate_code:Vs(n.data.affiliate_code),discount_active:Boolean(n.data.discount_active),discount_percent:Number(n.data.discount_percent??0)},...n.message?{message:n.message}:{}}}function Qs(e){const t=e?.trim();return t||null}function el(e){const t=e?.trim();return t||null}function tl(e){const t=e?.trim().toUpperCase();return t&&/^[A-Z]{3}$/.test(t)?t:null}function nl(e){return tl(e.currency)??function(){if("undefined"==typeof window||!window.location)return null;const e="string"==typeof window.location.search?window.location.search:"";if(e)return tl(new URLSearchParams(e).get("currency"));const t="string"==typeof window.location.href?window.location.href:"";if(!t)return null;try{return tl(new URL(t,"https://storefront.shoppex.local").searchParams.get("currency"))}catch{return null}}()}function ol(e){const t=e?.trim()??"";if(!t)return"Checkout failed. Please try again.";if(il(t))return"Your cart is outdated. Please add the products again.";const n=t.match(/^HTTP\s+(\d{3})(?::\s*(.*))?$/i);if(n){const e=Number(n[1]),t=n[2]?.trim();return t&&t.length>0?`Checkout failed: ${t}`:e>=500?"Checkout is temporarily unavailable. Please try again.":400===e?"Checkout failed. Please check your details and try again.":401===e||403===e?"Checkout is currently unavailable for this request.":"Checkout failed. Please try again."}return/^internal server error$/i.test(t)?"Checkout is temporarily unavailable. Please try again.":t}function il(e){const t=e?.trim().toLowerCase()??"";return!!t&&(t.includes("product not found")||t.includes("product not available")||t.includes("products are no longer available")||t.includes("outdated product"))}function rl(e,t,n){const o=t?.trim();if(!o)return null;try{const t=new URL(e),i=new URL(o);if(t.origin!==i.origin)return null;const r=t.pathname.replace(/\/+$/,""),a=`${i.pathname.replace(/\/+$/,"")}/invoice/`.replace(/\/{2,}/g,"/");if(!r.startsWith(a))return null;const s=r.slice(a.length);if(!s||s.includes("/"))return null;if(n){const e=n.trim();if(!e||decodeURIComponent(s)!==e)return null}return t.toString()}catch{return null}}function al(e,t){const n=el(t.email),o="string"==typeof t.locale?t.locale.trim():"";if(!n&&!o)return e;try{const t=new URL(e);if(o&&t.searchParams.set("locale",o),n){const e=new URLSearchParams(t.hash.startsWith("#")?t.hash.slice(1):t.hash);e.set("shoppex_prefill_email",n),t.hash=e.toString()}return t.toString()}catch{return e}}function sl(e,t){const n=e?.invoice,o=e?.invoiceId?.trim()||e?.invoice_id?.trim()||e?.uniqid?.trim()||n?.invoiceId?.trim()||n?.invoice_id?.trim()||n?.uniqid?.trim();let i=e?.checkoutUrl?.trim()||e?.checkout_url?.trim()||e?.url_branded?.trim()||e?.url?.trim()||n?.checkoutUrl?.trim()||n?.checkout_url?.trim()||n?.url_branded?.trim()||n?.url?.trim();return!i&&o&&n&&(i=function(e,t){const n=e?.trim();if(!n)return null;try{const e=new URL(n);return e.pathname=`${e.pathname.replace(/\/+$/,"")}/invoice/${encodeURIComponent(t)}`.replace(/\/{2,}/g,"/"),e.search="",e.hash="",e.toString()}catch{return null}}(t,o)??void 0),o&&i?{invoiceId:o,checkoutUrl:i,rewards:e?.rewards??n?.rewards??null}:null}function ll(e,t){return"string"==typeof e?{...t,coupon:e}:e??t??{}}function ul(e){const t=e.affiliateCode??e.referralCode;return"string"==typeof t&&t.trim().length>0?t.trim().toLowerCase():Ks()}function cl(e){const t=e=>{const t=e?.trim();return t?"default"===t.toLowerCase()?null:t:null};return e.map(e=>({product_id:e.product_id,variant_id:t(e.variant_id),quantity:e.quantity,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1})),custom_fields:e.custom_fields,price_variant_id:e.price_variant_id||null}))}function dl(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function pl(...e){for(const t of e)if("string"==typeof t&&t.length>0)return t}function fl(e,t){const n=e,o=dl(n.rating)??dl(n.score)??0,i=pl(n.comment,n.message),r=pl(n.author,n.customer_name),a=n.created_at??n.createdAt,s="number"==typeof a||"string"==typeof a?String(a):"",l=pl(n.id,n.uniqid)??`review:${s||t}`;return{...n,id:l,rating:o,...i?{comment:i}:{},...r?{author:r}:{},created_at:s}}async function ml(e){const t=Aa(),n=new URLSearchParams;n.set("limit",String(100)),"string"==typeof e&&e.trim().length>0&&n.set("cursor",e);const o=`?${n.toString()}`,i=await gs(`${as("/v1/storefront/feedback/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`reviews:${t.storeSlug}:${e??"start"}:100`,ttl:12e4,staleWhileRevalidate:!0}});return i.success&&i.data?{success:!0,data:i.data}:{success:!1,message:i.message}}function hl(e){const t=e.trim();return t||null}var _l=3e5;var yl=3e5;async function gl(){const e=Aa(),t=await gs(as("/v1/storefront/shops/name/:storeSlug/menus",{storeSlug:e.storeSlug}),{cache:{key:`menus:${e.storeSlug}`,ttl:yl,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.menus}:{success:!1,message:t.message}}async function bl(e){const t=Aa(),n=await gs(as("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu:${t.storeSlug}:${e}`,ttl:yl,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}async function vl(e){return bl(e)}async function wl(e){const t=Aa(),n=await gs(as("/v1/storefront/shops/name/:storeSlug/menus/:title",{storeSlug:t.storeSlug,title:e}),{cache:{key:`menu-slot:${t.storeSlug}:${e}`,ttl:yl,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.menu}:{success:!1,message:n.message}}function Sl(e){return function(e){const t=h[e];return[t.title,...t.aliases]}(e)}async function kl(e,t){if(!Ia())return;if("undefined"==typeof document)return;const n=Aa(),o=ds(n.storeSlug);try{const i=as("/v1/storefront/shops/:storeSlug/ping",{storeSlug:n.storeSlug});await fetch(`${n.apiBaseUrl}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({referer:document.referrer||void 0,cart_value:e??void 0,item_count:t??void 0,connection_id:o??void 0})})}catch{}}async function zl(){if(!Ia())return{success:!1,message:"SDK not initialized"};const e=Aa(),t=Ca();return gs(t?as("/v1/storefront/shops/id/:id/recent-sales",{id:t}):as("/v1/storefront/shops/:storeSlug/recent-sales",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function xl(){if(!Ia())return{success:!1,message:"SDK not initialized"};const e=Aa(),t=Ca();return gs(t?as("/v1/storefront/shops/id/:id/online-users",{id:t}):as("/v1/storefront/shops/:storeSlug/online-users",{storeSlug:e.storeSlug}),{cache:!1,retries:0,timeout:5e3})}async function Ol(){if(!Ia())return{success:!1,message:"SDK not initialized"};if("undefined"==typeof document)return{success:!1,message:"Document is not available"};const e=Aa(),t=Ca();return bs(t?as("/v1/storefront/shops/id/:id/ping",{id:t}):as("/v1/storefront/shops/:storeSlug/ping",{storeSlug:e.storeSlug}),{referer:document.referrer||void 0,connection_id:ds(e.storeSlug)??void 0},{retries:0,timeout:5e3})}function El(e,t){const n=Aa();return new Intl.NumberFormat(t??n.locale??"en-US",{style:"currency",currency:e??n.currency??"USD"})}function Tl(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function $l(e){return Tl(e)&&Tl(e.theme)?{...e,version:"number"==typeof e.version?e.version:0,revision:"number"==typeof e.revision?e.revision:0,theme:{...e.theme,content:Tl(e.theme.content)?e.theme.content:{},layout:Tl(e.theme.layout)?e.theme.layout:{},style_slots:Tl(e.theme.style_slots)?e.theme.style_slots:{},...Array.isArray(e.theme.pages)?{pages:e.theme.pages}:{},...Tl(e.theme.terms)?{terms:e.theme.terms}:{}}}:null}async function Al(e){const t=await gs(as("/v1/storefront/themes/builder/published/:shopSlug",{shopSlug:e}));return t.success&&t.data?Tl(n=t.data)?{settings:Tl(n.settings)?n.settings:{},builder_settings:$l(n.builder_settings),content:Tl(n.content)?n.content:{},style_slots:Tl(n.style_slots)?n.style_slots:{}}:null:null;var n}async function Il(e){const t=await Al(e);return t?t.settings:null}function Nl(e){const t={};for(const[n,o]of Object.entries(e.settings)){t[n]={};for(const[e,i]of Object.entries(o))t[n][e]=i.default}return t}function Cl(e,t){const n={...e};for(const[o,i]of Object.entries(t))i&&(n[o]={...n[o],...i});return n}var Pl={init:function(e,t){"string"==typeof e?$a(e,t):$a(e.storeId,e)},isInitialized:Ia,getConfig:Aa,client:function(e){const t=Aa().apiBaseUrl??"https://api.shoppex.io";if(xa&&Oa===t&&!e)return xa;const n=function(e,t){return a({baseUrl:e,headers:t?{Authorization:`Bearer ${t}`}:void 0})}(t,e);return e||(xa=n,Oa=t),n},getStore:ws,getStorefront:Ss,getStoreLogoUrl:async function(){const e=await ws();return e.success&&e.data?.logo?e.data.logo:null},getStoreBannerUrl:async function(){const e=await ws();return e.success&&e.data?.banner?e.data.banner:null},resolveStoreByDomain:async function(e,t){const n=e??("undefined"!=typeof window?window.location.hostname:"");if(!n)return{success:!1,message:"Domain is required to resolve store"};const o=n.replace(/^https?:\/\//,"").split("/")[0].trim(),i=t??(Ia()?Aa().apiBaseUrl:"https://api.shoppex.io"),r=await gs(as("/v1/storefront/shops/domain/:domain",{domain:o}),{baseUrl:i,cache:{key:`store:domain:${o}`,ttl:vs,staleWhileRevalidate:!0}});return r.success&&r.data?.shop?(r.data.shop.id&&Na(r.data.shop.id),{success:!0,data:r.data.shop}):{success:!1,message:r.message??"Failed to resolve store"}},getProducts:xs,getStorefrontProductsPage:async function(e){const t=Aa(),n=new URLSearchParams;"string"==typeof e?.cursor&&e.cursor.trim().length>0&&n.set("cursor",e.cursor),Number.isFinite(e?.limit)&&n.set("limit",String(Math.max(1,Math.floor(e?.limit??0)))),"string"==typeof e?.sort&&e.sort.trim().length>0&&n.set("sort",e.sort.trim()),"string"==typeof e?.category&&e.category.trim().length>0&&n.set("category",e.category.trim()),!0===e?.hideOutOfStock&&n.set("hide_out_of_stock","true");const o=n.size>0?`?${n.toString()}`:"",i=await gs(`${as("/v1/storefront/products/shop/:storeSlug",{storeSlug:t.storeSlug})}${o}`,{cache:{key:`products:page:${t.storeSlug}:${e?.limit??"default"}:${e?.cursor??"start"}:${e?.sort??"featured"}:${r=e?.category,void 0===r?"category:unset":null===r?"category:null":`category:${r}`}:${!0===e?.hideOutOfStock?"in-stock":"all-stock"}`,ttl:ks,staleWhileRevalidate:!0}});var r;return i.success&&i.data?{success:!0,data:{products:i.data.products.map(zs),pagination:i.data.pagination??null}}:{success:!1,message:i.message}},getProduct:async function(e){let t=Ca();if(!t){const e=await ws();t=e.success?e.data?.id??null:null}const n=t?`?slug_shop_id=${encodeURIComponent(t)}`:"",o=await gs(`${as("/v1/storefront/products/unique/:idOrSlug",{idOrSlug:e})}${n}`,{cache:{key:`product:${e}:${t??"no-shop"}`,ttl:ks,staleWhileRevalidate:!0}});return o.success&&o.data?.product?{success:!0,data:zs(o.data.product)}:{success:!1,message:o.message}},getCategories:async function(){const e=await xs();if(!e.success||!e.data)return{success:!1,message:e.message};const t=new Set;for(const n of e.data)if(n.categories)for(const e of n.categories)"string"==typeof e?t.add(e):e&&"object"==typeof e&&"uniqid"in e&&t.add(e.uniqid);return{success:!0,data:Array.from(t)}},getCart:Ms,getCartItemCount:function(){return Ms().reduce((e,t)=>e+t.quantity,0)},getCartCoupon:Us,setCartCoupon:qs,clearCartCoupon:js,addToCart:function(e,t,n=1,o){if(!e||!t)throw new i("product_id and variant_id are required");const r=Ns(n);if(r<1)throw new i("quantity must be at least 1");const a=Ms(),s=Es({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data}),l=a.findIndex(e=>e.line_id===s);if(l>=0)a[l].quantity+=r,o?.addons&&(a[l].addons=o.addons),o?.custom_fields&&(a[l].custom_fields=o.custom_fields),o?.price_variant_id&&(a[l].price_variant_id=o.price_variant_id),o?.price_data&&(a[l].price_data=o.price_data),function(e,t){if(t?.replace_display_snapshot)return e.title=t.title,e.variant_title=t.variant_title,e.image_url=t.image_url,e.addon_labels=t.addon_labels,e.max_quantity=t.max_quantity,void(e.min_quantity=t.min_quantity);void 0!==t?.title&&(e.title=t.title);void 0!==t?.variant_title&&(e.variant_title=t.variant_title);void 0!==t?.image_url&&(e.image_url=t.image_url);void 0!==t?.addon_labels&&(e.addon_labels=t.addon_labels);void 0!==t?.max_quantity&&(e.max_quantity=t.max_quantity);void 0!==t?.min_quantity&&(e.min_quantity=t.min_quantity)}(a[l],o),Ls(a[l]);else{const n={line_id:s,product_id:e,variant_id:t,quantity:r,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Ls(n),a.push(n)}Ds(a)},setCartItem:function(e,t,n=1,o){if(!e||!t)throw new i("product_id and variant_id are required");const r=Ns(n);if(r<1)throw new i("quantity must be at least 1");const a=Ms(),s=Es({product_id:e,variant_id:t,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data});for(let i=a.length-1;i>=0;i-=1)a[i].product_id===e&&a[i].variant_id===t&&a.splice(i,1);const l={line_id:s,product_id:e,variant_id:t,quantity:r,addons:o?.addons,custom_fields:o?.custom_fields,price_variant_id:o?.price_variant_id,price_data:o?.price_data,title:o?.title,variant_title:o?.variant_title,image_url:o?.image_url,addon_labels:o?.addon_labels,max_quantity:o?.max_quantity,min_quantity:o?.min_quantity};Ls(l),a.push(l),Ds(a)},updateCartItem:function(e,t){const n=Ms(),o=e.trim();if(!o)throw new i("line_id is required");const r=n.findIndex(e=>e.line_id===o);if(r<0)throw new i("Item not found in cart");if(void 0!==t.quantity){const e=Ns(t.quantity);if(e<1)return n.splice(r,1),void Ds(n);n[r].quantity=e}void 0!==t.addons&&(n[r].addons=t.addons),void 0!==t.custom_fields&&(n[r].custom_fields=t.custom_fields),void 0!==t.price_variant_id&&(n[r].price_variant_id=t.price_variant_id),void 0!==t.price_data&&(n[r].price_data=t.price_data),void 0!==t.max_quantity&&(n[r].max_quantity=t.max_quantity),void 0!==t.min_quantity&&(n[r].min_quantity=t.min_quantity),Ls(n[r]),Ds(n)},removeFromCart:function(e){const t=e.trim();if(!t)throw new i("line_id is required");Ds(Ms().filter(e=>e.line_id!==t))},clearCart:Fs,createCartBackup:Bs,restoreCartFromBackup:function(){const e=Ps(ls(As("cartBackup"))),t=ls(As("metaBackup")),n=ls(As("couponBackup"));return!!(e&&e.length>0)&&(Zs(e,t),"string"==typeof n?qs(n):js(),!0)},mergeBaskets:function(e){const t=Ms();for(const n of e){const e="string"==typeof n.product_id?n.product_id.trim():"",o="string"==typeof n.variant_id?n.variant_id.trim():"";if(!e||!o)continue;let i;try{i=Ns(n.quantity)}catch{continue}if(i<1)continue;const r=Ts({...n,line_id:n.line_id??Es(n),product_id:e,variant_id:o,quantity:i}),a=t.findIndex(e=>e.line_id===r.line_id);a>=0?(t[a].quantity=Math.max(t[a].quantity,i),Ls(t[a])):(Ls(r),t.push(r))}return Ds(t),t},moveBasketItem:function(e,t,n,o){const r=Ms(),a=r.findIndex(n=>n.product_id===e&&n.variant_id===t);if(a<0)throw new i("Item not found in cart");const[s]=r.splice(a,1),l=Es({...s,product_id:n,variant_id:o}),u=r.findIndex(e=>e.line_id===l);if(u>=0)r[u].quantity+=s.quantity,Ls(r[u]);else{const e=Ts({...s,product_id:n,variant_id:o,line_id:l});Ls(e),r.push(e)}Ds(r)},getCartStats:function(){const e=Ms(),t=Ys(),n=Rs(),o=ls(As("cartBackup"))??[],i=e.length>0&&e.every(e=>"number"==typeof e.price_data?.unit_price),r=e.reduce((e,t)=>e+(t.price_data?.unit_price??0)*t.quantity,0);return{item_count:e.length,total_quantity:e.reduce((e,t)=>e+t.quantity,0),last_modified:n?.last_modified??0,version:n?.version??0,has_backup:o.length>0,integrity_valid:t,total_price:r,total_price_is_estimate:e.length>0&&!i}},validateCartIntegrity:Ys,quoteCart:async function(e){const t=function(e){const t=Aa(),n=Cs(e)??Us()??void 0;return{store_slug:t.storeSlug,items:Ms(),coupon:n}}(e);return bs("/v1/storefront/cart/quote",{shop_slug:t.store_slug,cart:t.items,coupon:t.coupon})},resolveCartLineId:function(e,t,n=Ms()){const o=n.filter(n=>n.product_id===e&&n.variant_id===t);if(0===o.length)throw new i(`No cart line found for ${e}/${t}`);return o[0].line_id},checkout:async function(e,t){const n=ll(e,t),{autoRedirect:o=!0,email:i,coupon:r}=n,a=void 0===r?Us():Qs(r),s=el(i),l=ul(n),u=nl(n),c=Ms();if(0===c.length)return{success:!1,message:"Cart is empty"};Bs();const d=Aa();let p=await bs("/v1/storefront/invoices/from-cart",{shop_slug:d.storeSlug,cart:cl(c),email:s,coupon:a,currency:u,affiliate_code:l},{retries:0});if(!p.success||!p.data)return il(p.message)&&Fs(),{success:!1,message:ol(p.message)};const f=sl(p.data,d.checkoutBaseUrl);if(!f)return{success:!1,message:"Failed to create invoice"};const{invoiceId:m}=f,h=rl(f.checkoutUrl,d.checkoutBaseUrl,m);if(!h)return{success:!1,message:"Failed to create invoice"};const _=al(h,{email:s,locale:n.locale});return o&&"undefined"!=typeof window&&window?.location&&(window.location.href=_,Fs()),{success:!0,redirectUrl:_,invoiceId:m,rewards:f.rewards}},buildCheckoutUrl:async function(e,t){const n=ll(e,t),{email:o,coupon:i}=n,r=void 0===i?Us():Qs(i),a=el(o),s=ul(n),l=nl(n),u=Ms();if(0===u.length)throw new Error("Cart is empty");const c=Aa();let d=await bs("/v1/storefront/invoices/from-cart",{shop_slug:c.storeSlug,cart:cl(u),email:a,coupon:r,currency:l,affiliate_code:s},{retries:0});if(!d.success||!d.data)throw il(d.message)&&Fs(),new Error(ol(d.message));const p=sl(d.data,c.checkoutBaseUrl);if(!p)throw new Error("Failed to create invoice");const f=rl(p.checkoutUrl,c.checkoutBaseUrl,p.invoiceId);if(!f)throw new Error("Failed to create invoice");return al(f,{email:a,locale:n.locale})},buildCheckoutUrlSync:function(){throw new Error("buildCheckoutUrlSync is deprecated. Use buildCheckoutUrl (async) instead.")},captureAffiliateFromUrl:async function(e="ref"){if("undefined"==typeof window)return null;let t=null;try{const n=new URL(window.location.href).searchParams.get(e);t=n?n.trim():null}catch{t=null}if(t=Vs(t),!t)return null;if(Gs(t),Ia())try{const e=await bs("/v1/storefront/affiliates/attribution",{shop_slug:Aa().storeSlug,code:t},{retries:0});return e.success&&e.data?.accepted&&e.data?.affiliate_code?(Gs(e.data.affiliate_code),e.data.affiliate_code):(Hs(),null)}catch{return t}return t},validateAffiliateCode:Xs,applyAffiliateCode:async function(e){const t=await Xs(e);return t.success&&t.data?.affiliate_code&&Gs(t.data.affiliate_code),t},getAffiliateCode:Ks,setAffiliateCode:Gs,clearAffiliateCode:Hs,validateCoupon:async function(e,t){const n=e.trim();if(!n)return{success:!1,message:"Coupon code is required"};const o={code:n},i="string"==typeof t?t:t?.productId,r="string"==typeof t?void 0:t?.variantId;if(r&&!i)return{success:!1,message:"productId is required when variantId is provided"};if(i)o.product_id=i,r&&(o.variant_id=r);else{const e=Ms();if(0===e.length)return{success:!1,message:"Cart is empty"};const t=await async function(){const e=Ca();if(e)return e;const t=await ws();return t.success&&t.data?.id?t.data.id:null}();if(!t)return{success:!1,message:"Failed to resolve store"};o.cart=JSON.stringify({shop_id:t,products:e.map(e=>({uniqid:e.product_id,quantity:e.quantity,variant_id:e.variant_id,price_variant_id:e.price_variant_id,addons:e.addons?.map(e=>({id:e.id,quantity:e.quantity??1}))}))})}return await bs("/v1/storefront/coupons/check",o)},getShopReviews:async function(){const e=[],t=new Set;let n=null;for(;;){const o=await ml(n);if(!o.success||!o.data)return{success:!1,message:o.message,data:[]};e.push(...(o.data.feedback??[]).map((t,n)=>fl(t,e.length+n)));const i=o.data.pagination;if(!i?.has_more||!i.next_cursor)break;if(t.has(i.next_cursor))break;t.add(i.next_cursor),n=i.next_cursor}return{success:!0,data:e}},searchProducts:async function(e,t){if(!Ia())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Ss();return o.success&&o.data?{success:!0,data:Ka(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},searchCatalogItems:async function(e,t){if(!Ia())return{success:!1,message:"SDK not initialized"};const n=e.trim();if(!n)return{success:!0,data:[]};const o=await Ss();return o.success&&o.data?{success:!0,data:Ha(o.data.products??[],o.data.groups??[],n,{hideOutOfStock:t?.hideOutOfStock,maxResults:t?.maxResults})}:{success:!1,message:o.message??"Failed to fetch storefront catalog"}},getInvoice:async function(e){const t=hl(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await gs(as("/v1/storefront/invoices/unique/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?{success:!0,data:n.data.invoice}:{success:!1,message:"Invalid invoice response"}:{success:!1,message:n.message}},getInvoiceStatus:async function(e){const t=hl(e);if(!t)return{success:!1,message:"Invoice ID is required"};const n=await gs(as("/v1/storefront/invoices/status/:invoiceId",{invoiceId:t}));return n.success?n.data?.invoice?.status?{success:!0,data:{status:n.data.invoice.status}}:{success:!1,message:"Invalid invoice status response"}:{success:!1,message:n.message}},getPages:async function(){const e=Aa(),t=await gs(as("/v1/storefront/shops/name/:storeSlug/pages",{storeSlug:e.storeSlug}),{cache:{key:`pages:${e.storeSlug}`,ttl:_l,staleWhileRevalidate:!0}});return t.success&&t.data?{success:!0,data:t.data.pages}:{success:!1,message:t.message}},getPage:async function(e){const t=Aa(),n=await gs(as("/v1/storefront/shops/name/:storeSlug/pages/:slug",{storeSlug:t.storeSlug,slug:e}),{cache:{key:`page:${t.storeSlug}:${e}`,ttl:_l,staleWhileRevalidate:!0}});return n.success&&n.data?{success:!0,data:n.data.page}:{success:!1,message:n.message}},getMenus:gl,getMenu:vl,getMenuBySlot:wl,getMenuByTitle:bl,getMenuSlotTitles:Sl,trackPageView:kl,getStorefrontOnlineUsers:xl,getStorefrontRecentSales:zl,touchStorefrontPresence:Ol,createFormatter:El,formatPrice:function(e,t,n){const o="string"==typeof e?parseFloat(e):e;return Number.isNaN(o)?El(t,n).format(0):El(t,n).format(o)},clearCache:function(){es.clear(),ts.clear()},invalidateCache:function(e){for(const t of es.keys())(t===e||t.startsWith(e))&&es.delete(t)},getCacheStats:function(){return{hits:ns.hits,misses:ns.misses,pendingRequests:ts.size,entries:es.size}},fetchPublishedBuilderSettings:Al,fetchPublishedThemeSettings:Il,resolveDefaults:Nl,mergeSettings:Cl};if("undefined"!=typeof window){const e=window;e.shoppex?.isInitialized?.()||(e.shoppex=Pl)}e.CartError=i,e.NetworkError=o,e.NotInitializedError=n,e.ShoppexError=t,e.ValidationError=class e extends t{constructor(t,n){super(t,"VALIDATION_ERROR"),this.name="ValidationError",this.invalidFields=n,Object.setPrototypeOf(this,e.prototype)}},e.buildStorefrontContactMessage=Qa,e.buildStorefrontCustomFieldPayload=function(e,t){const n={};return e.forEach(e=>{const o=t[e.name]??e.defaultValue??"";if("checkbox"===e.type)return void(Pa(o)&&(n[e.name]="true"));const i=o.trim();i.length>0&&(n[e.name]=i)}),n},e.buildStorefrontProductLookup=Za,e.collectProductSearchHaystack=Ja,e.computeCartLineId=Es,e.default=Pl,e.shoppex=Pl,e.ensureCartLineId=Ts,e.fetchPublishedBuilderSettings=Al,e.fetchPublishedThemeSettings=Il,e.filterProductsBySearchQuery=function(e,t,n){const o=Ba(t);if(!o)return[];let i=e.filter(e=>Wa(e,o));return n?.hideOutOfStock&&(i=i.filter(e=>Da(e))),null!=n?.maxResults?i.slice(0,n.maxResults):i},e.getMenu=vl,e.getMenuBySlot=wl,e.getMenuByTitle=bl,e.getMenuSlotTitles=Sl,e.getMenus=gl,e.getMergedStorefrontProducts=La,e.getStorefrontGroupProducts=Ma,e.getStorefrontOnlineUsers=xl,e.getStorefrontRecentSales=zl,e.groupMatchesSearchQuery=Va,e.isProductInStock=Da,e.isProductOutOfStock=ja,e.isStorefrontCheckboxCustomFieldValueChecked=Pa,e.isVariantOutOfStock=function(e){return 0===Ra(e?.stock)},e.mergeSettings=Cl,e.normalizeSearchQuery=Ba,e.normalizeStorefrontCustomFields=function(e){return function(e){if(Array.isArray(e))return e;if("string"==typeof e){try{const t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){const e=t.custom_fields??t.customFields;return Array.isArray(e)?e:[]}}catch{return[]}return[]}if(e&&"object"==typeof e){const t=e.custom_fields??e.customFields;return Array.isArray(t)?t:[]}return[]}(e).filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)).map(e=>{const t="string"==typeof e.type?e.type.trim().toLowerCase():"text",n=t.length>0?t:"text",o=[e.default_value,e.default,e.value].find(e=>"string"==typeof e&&e.trim().length>0);return{name:"string"==typeof e.name?e.name.trim():"",type:n,required:!0===e.required||"true"===e.required||1===e.required||"1"===e.required,defaultValue:"string"==typeof o?o:"",placeholder:"string"==typeof e.placeholder?e.placeholder:"",regex:"string"==typeof e.regex?e.regex:void 0}}).filter(e=>e.name.length>0&&"hidden"!==e.type)},e.productMatchesSearchQuery=Wa,e.resolveDefaults=Nl,e.resolveDisplayStock=qa,e.resolveStorefrontApiBaseUrl=Xa,e.resolveStorefrontSocialLinks=function(e){return{discord:e?.discord_link??e?.social?.discord??null,telegram:e?.telegram_link??e?.social?.telegram??null}},e.resolveVariantStockValue=function(e){return Ra(e?.stock)??-1},e.searchMergedStorefrontCatalog=Ka,e.searchMergedStorefrontCatalogItems=Ha,e.stripHtmlFromText=Fa,e.submitStorefrontContactTicket=async function(e){const t=e.shopSlug.trim();if(!t)throw new Error("Store data is not ready yet. Please try again in a moment.");const n=e.email.trim().toLowerCase(),o=e.title?.trim()??"",i=o.length>=2?o.slice(0,30):"Contact Request",r=Qa({name:e.name,message:e.message}),a=e.invoiceId?.trim()||void 0,s=Xa({apiBaseUrl:e.apiBaseUrl}),l=await fetch(`${s}/v1/storefront/shops/name/${encodeURIComponent(t)}/tickets`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({email:n,title:i,message:r,...a?{invoice_id:a}:{}})}),u=await l.json().catch(()=>null);if(!l.ok)throw new Error(u?.message||u?.error||"Failed to send your message.");const c=u?.data?.uniqid;if(!c)throw new Error("Ticket created, but the response was incomplete.");return{uniqid:c}},e.touchStorefrontPresence=Ol,e.trackPageView=kl,e.validateStorefrontCustomFieldValue=function(e,t){if("checkbox"===e.type)return e.required&&!Pa(t)?`${e.name} is required.`:null;const n=t.trim();if(e.required&&!n)return`${e.name} is required.`;if(e.regex&&n)try{if(!new RegExp(e.regex).test(n))return`${e.name} has an invalid format.`}catch{return null}return null}});
2
2
  //# sourceMappingURL=shoppex.umd.js.map