@lightspeed/crane 3.3.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/UPGRADE.md +14 -0
- package/dist/cli.mjs +45 -61
- package/package.json +3 -2
- package/template/layouts/catalog/example-catalog/settings/design.ts +229 -1
- package/template/layouts/catalog/example-catalog/settings/layout.ts +1 -0
- package/template/layouts/catalog/example-catalog/settings/translations.ts +285 -1
- package/template/layouts/category/example-category/Main.vue +2 -1
- package/template/layouts/category/example-category/settings/design.ts +229 -1
- package/template/layouts/category/example-category/settings/layout.ts +1 -0
- package/template/layouts/category/example-category/settings/translations.ts +285 -1
- package/template/layouts/product/example-product/Main.vue +2 -1
- package/template/layouts/product/example-product/settings/layout.ts +1 -0
- package/template/preview/assets/close.svg +3 -0
- package/template/preview/assets/crane-logo.svg +16 -0
- package/template/preview/sections/preview.html +99 -1
- package/template/preview/shared/preview.ts +6 -4
- package/template/preview/vite.config.js +1 -0
- package/template/reference/sections/intro-slider/settings/translations.ts +1 -0
- package/template/sections/example-section/component/image/Image.vue +4 -3
- package/template/footers/example-footer/entity/color.ts +0 -4
- package/template/reference/sections/featured-products/entity/color.ts +0 -4
- package/template/reference/sections/intro-slider/entity/color.ts +0 -4
- package/template/reference/sections/trending-categories/entity/color.ts +0 -4
- package/template/sections/example-section/entity/color.ts +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -1,81 +1,65 @@
|
|
|
1
|
-
import*as un from"fs";import ie,{existsSync as $e,readFileSync as nr,statSync as Vt,promises as rr,writeFileSync as or,createReadStream as xa,mkdtempSync as za,mkdirSync as Ma,rmSync as Co}from"fs";import*as ln from"path";import le,{resolve as j,dirname as wo,relative as Io,basename as Ua,sep as sr,parse as Ao,join as He}from"path";import ja from"cac";import{green as Qe,yellow as Fa,red as Ga,gray as Ha}from"kolorist";import At from"prompts";import bo from"adm-zip";import{glob as W,globSync as $o}from"glob";import qe from"typescript";import{normalizePath as Ba,build as ct,defineConfig as pn,createServer as Za}from"vite";import{SectionTypeEnum as ut,BackgroundStyleEnum as ir,ButtonAppearanceEnum as Va,ButtonSizeEnum as Wa,ButtonShapeEnum as Ka,OverlayTypeEnum as fn,DesignEditorType as Me,PluginTypeEnum as Be,ConfigTypeEnum as pe}from"@lightspeed/crane-api";import*as Oe from"process";import dn from"process";import{JSONPath as Ya}from"jsonpath-plus";import{readFile as ar,writeFile as Xa}from"fs/promises";import{pathToFileURL as No,URL as Qa}from"url";import cr,{AxiosError as Lo}from"axios";import qa from"tinycolor2";import{builtinModules as Do}from"module";import{viteExternalsPlugin as ko}from"vite-plugin-externals";import Ja from"vite-plugin-compression";import ec from"@vitejs/plugin-vue";import tc from"vite-tsconfig-paths";import nc from"vite-plugin-checker";import{encode as rc}from"@jridgewell/sourcemap-codec";import{promisify as Po}from"node:util";import xo from"node:zlib";import he from"node:fs";import Ne from"node:path";import Se from"node:process";import zo from"util";import{fileURLToPath as oc}from"node:url";import{ConcurrencyManager as sc}from"axios-concurrency";import{inc as ic}from"semver";import ac from"cli-progress";import{WebSocketServer as cc,WebSocket as uc}from"ws";import*as lc from"os";import{spawnSync as pc}from"child_process";const fc="3.2.1",we={[ut.SECTION]:{source:"sections",dist:"dist/sections"},[ut.HEADER]:{source:"headers",dist:"dist/headers"},[ut.FOOTER]:{source:"footers",dist:"dist/footers"}};var ee=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientChunks=2]="ClientChunks",e[e.ClientAsset=3]="ClientAsset",e[e.Asset=4]="Asset",e[e.TemplateAsset=5]="TemplateAsset",e[e.Dependency=6]="Dependency",e[e.SourceCode=7]="SourceCode",e[e.LayoutClient=8]="LayoutClient",e[e.LayoutAsset=9]="LayoutAsset",e[e.SlotServer=10]="SlotServer",e[e.SlotClient=11]="SlotClient",e[e.SlotClientChunks=12]="SlotClientChunks",e[e.SlotClientAsset=13]="SlotClientAsset",e[e.CollectionAsset=14]="CollectionAsset",e))(ee||{});function bt(e){const t={};for(const[n,r]of Object.entries(e)){let o={...r};if(r.type==="DECK"&&r.cards&&typeof r.cards=="object"&&"defaultCardContent"in r.cards){const i=r.cards;i.defaultCardContent?.settings&&(o={...o,cards:{...i,defaultCardContent:{...i.defaultCardContent,settings:bt(i.defaultCardContent.settings)}}})}if(r.type==="ACCORDION"&&r.cards&&typeof r.cards=="object"&&!("defaultCardContent"in r.cards)){const i=r.cards,s={};for(const[a,c]of Object.entries(i))c.editors?s[a]={...c,editors:bt(c.editors)}:s[a]=c;o={...o,cards:s}}if(o.defaults&&typeof o.defaults=="object"&&!("type"in o.defaults)){const i=Object.assign({type:o.type},o.defaults);o={...o,defaults:i}}t[n]=o}return t}function g(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,f=Object.keys(u);for(let h=0;h<f.length;h++){const T=f[h];T in a||(a[T]=u[T].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class $t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ur={};function lt(e){return e&&Object.assign(ur,e),ur}function Uo(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function lr(e,t){return typeof t=="bigint"?t.toString():t}function hn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function pr(e){return e==null}function fr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dc(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}const jo=Symbol("evaluating");function ne(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jo)return r===void 0&&(r=jo,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Rt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gt(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Fo(e){return JSON.stringify(e)}function hc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Go="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const mc=hn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Nt(e){if(Wt(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Wt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ho(e){return Nt(e)?{...e}:Array.isArray(e)?[...e]:e}const gc=new Set(["string","number","symbol"]);function Lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Et(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ec(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const _c={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 yc(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=gt(e._zod.def,{get shape(){const s={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return Rt(this,"shape",s),s},checks:[]});return Et(e,i)}function Sc(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=gt(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Rt(this,"shape",s),s},checks:[]});return Et(e,i)}function Tc(e,t){if(!Nt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=gt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Rt(this,"shape",i),i}});return Et(e,o)}function Rc(e,t){if(!Nt(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Rt(this,"shape",r),r}});return Et(e,n)}function Oc(e,t){const n=gt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Rt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Et(e,n)}function vc(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");const s=gt(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Rt(this,"shape",c),c},checks:[]});return Et(t,s)}function Cc(e,t,n){const r=gt(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return Rt(this,"shape",i),i}});return Et(t,r)}function Dt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function kt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function mn(e){return typeof e=="string"?e:e?.message}function _t(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=mn(e.inst?._zod.def?.error?.(e))??mn(t?.error?.(e))??mn(n.customError?.(e))??mn(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function dr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Kt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Bo=(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,lr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zo=g("$ZodError",Bo),Vo=g("$ZodError",Bo,{Parent:Error});function wc(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Ic(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){const c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return r(e),n}const hr=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new $t;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>_t(c,i,lt())));throw Go(a,o?.callee),a}return s.value},mr=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>_t(c,i,lt())));throw Go(a,o?.callee),a}return s.value},gn=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new $t;return i.issues.length?{success:!1,error:new(e??Zo)(i.issues.map(s=>_t(s,o,lt())))}:{success:!0,data:i.value}},Ac=gn(Vo),En=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>_t(s,o,lt())))}:{success:!0,data:i.value}},bc=En(Vo),$c=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return hr(e)(t,n,o)},Nc=e=>(t,n,r)=>hr(e)(t,n,r),Lc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return mr(e)(t,n,o)},Dc=e=>async(t,n,r)=>mr(e)(t,n,r),kc=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,o)},Pc=e=>(t,n,r)=>gn(e)(t,n,r),xc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,o)},zc=e=>async(t,n,r)=>En(e)(t,n,r),Mc=/^[cC][^\s-]{8,}$/,Uc=/^[0-9a-z]+$/,jc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fc=/^[0-9a-vA-V]{20}$/,Gc=/^[A-Za-z0-9]{27}$/,Hc=/^[a-zA-Z0-9_-]{21}$/,Bc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zc=/^([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})$/,Wo=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)$/,Vc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Wc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Kc(){return new RegExp(Wc,"u")}const Yc=/^(?:(?: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])$/,Xc=/^(([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}|:))$/,Qc=/^((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])$/,qc=/^(([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])$/,Jc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ko=/^[A-Za-z0-9_-]*$/,eu=/^\+[1-9]\d{6,14}$/,Yo="(?:(?:\\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])))",tu=new RegExp(`^${Yo}$`);function Xo(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function nu(e){return new RegExp(`^${Xo(e)}$`)}function ru(e){const t=Xo({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Yo}T(?:${r})$`)}const ou=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},su=/^-?\d+$/,Qo=/^-?\d+(?:\.\d+)?$/,iu=/^(?:true|false)$/i,au=/^[^A-Z]*$/,cu=/^[^a-z]*$/,Pe=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qo={number:"number",bigint:"bigint",object:"date"},Jo=g("$ZodCheckLessThan",(e,t)=>{Pe.init(e,t);const n=qo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),es=g("$ZodCheckGreaterThan",(e,t)=>{Pe.init(e,t);const n=qo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uu=g("$ZodCheckMultipleOf",(e,t)=>{Pe.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.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.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):dc(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),lu=g("$ZodCheckNumberFormat",(e,t)=>{Pe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=_c[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=su)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),pu=g("$ZodCheckMaxLength",(e,t)=>{var n;Pe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!pr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const s=dr(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fu=g("$ZodCheckMinLength",(e,t)=>{var n;Pe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!pr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const s=dr(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),du=g("$ZodCheckLengthEquals",(e,t)=>{var n;Pe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!pr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=dr(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),_n=g("$ZodCheckStringFormat",(e,t)=>{var n,r;Pe.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hu=g("$ZodCheckRegex",(e,t)=>{_n.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})}}),mu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=au),_n.init(e,t)}),gu=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cu),_n.init(e,t)}),Eu=g("$ZodCheckIncludes",(e,t)=>{Pe.init(e,t);const n=Lt(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),_u=g("$ZodCheckStartsWith",(e,t)=>{Pe.init(e,t);const n=new RegExp(`^${Lt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),yu=g("$ZodCheckEndsWith",(e,t)=>{Pe.init(e,t);const n=new RegExp(`.*${Lt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Su=g("$ZodCheckOverwrite",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Tu{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
|
-
`).filter(
|
|
3
|
-
`))}}const
|
|
4
|
-
if (${
|
|
5
|
-
if (${
|
|
6
|
-
payload.issues = payload.issues.concat(${
|
|
1
|
+
import*as pt from"fs";import C,{existsSync as H,readFileSync as on,statSync as Xe,promises as rn,writeFileSync as sn,createReadStream as pi,mkdtempSync as fi,mkdirSync as hi,rmSync as co}from"fs";import*as ft from"path";import z,{resolve as S,dirname as uo,relative as lo,basename as mi,sep as an,parse as po,join as ee}from"path";import Ei from"cac";import{green as ce,yellow as gi,red as _i,gray as yi}from"kolorist";import Le from"prompts";import fo from"adm-zip";import{glob as I,globSync as ho}from"glob";import ue from"typescript";import{normalizePath as Si,build as ge,defineConfig as ht,createServer as Ti}from"vite";import{SectionTypeEnum as _e,BackgroundStyleEnum as cn,ButtonAppearanceEnum as Oi,ButtonSizeEnum as Ii,ButtonShapeEnum as wi,OverlayTypeEnum as mt,DesignEditorType as q,PluginTypeEnum as te,ConfigTypeEnum as N}from"@lightspeed/crane-api";import*as F from"process";import Et from"process";import{JSONPath as vi}from"jsonpath-plus";import{readFile as un,writeFile as Ci}from"fs/promises";import{pathToFileURL as mo,URL as Ri}from"url";import ln,{AxiosError as Eo}from"axios";import bi from"tinycolor2";import{builtinModules as go}from"module";import{viteExternalsPlugin as _o}from"vite-plugin-externals";import Ai from"vite-plugin-compression";import Ni from"@vitejs/plugin-vue";import $i from"vite-tsconfig-paths";import Di from"vite-plugin-checker";import{encode as Li}from"@jridgewell/sourcemap-codec";import{promisify as yo}from"node:util";import So from"node:zlib";import D from"node:fs";import V from"node:path";import j from"node:process";import ki from"micromatch";import{fileURLToPath as Pi}from"node:url";import{ConcurrencyManager as zi}from"axios-concurrency";import{inc as ji}from"semver";import Ui from"cli-progress";import{WebSocketServer as Fi,WebSocket as Mi}from"ws";import*as Gi from"os";import{spawnSync as xi}from"child_process";const Bi="3.4.0",G={[_e.SECTION]:{source:"sections",dist:"dist/sections"},[_e.HEADER]:{source:"headers",dist:"dist/headers"},[_e.FOOTER]:{source:"footers",dist:"dist/footers"}};var R=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientChunks=2]="ClientChunks",e[e.ClientAsset=3]="ClientAsset",e[e.Asset=4]="Asset",e[e.TemplateAsset=5]="TemplateAsset",e[e.Dependency=6]="Dependency",e[e.SourceCode=7]="SourceCode",e[e.LayoutClient=8]="LayoutClient",e[e.LayoutAsset=9]="LayoutAsset",e[e.SlotServer=10]="SlotServer",e[e.SlotClient=11]="SlotClient",e[e.SlotClientChunks=12]="SlotClientChunks",e[e.SlotClientAsset=13]="SlotClientAsset",e[e.CollectionAsset=14]="CollectionAsset",e))(R||{});function ke(e){const t={};for(const[n,o]of Object.entries(e)){let r={...o};if(o.type==="DECK"&&o.cards&&typeof o.cards=="object"&&"defaultCardContent"in o.cards){const s=o.cards;s.defaultCardContent?.settings&&(r={...r,cards:{...s,defaultCardContent:{...s.defaultCardContent,settings:ke(s.defaultCardContent.settings)}}})}if(o.type==="ACCORDION"&&o.cards&&typeof o.cards=="object"&&!("defaultCardContent"in o.cards)){const s=o.cards,i={};for(const[a,c]of Object.entries(s))c.editors?i[a]={...c,editors:ke(c.editors)}:i[a]=c;r={...r,cards:i}}if(r.defaults&&typeof r.defaults=="object"&&!("type"in r.defaults)){const s=Object.assign({type:r.type},r.defaults);r={...r,defaults:s}}t[n]=r}return t}function l(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,d=Object.keys(u);for(let m=0;m<d.length;m++){const y=d[m];y in a||(a[y]=u[y].bind(a))}}const r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Pe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class To extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const dn={};function ye(e){return e&&Object.assign(dn,e),dn}function Oo(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function pn(e,t){return typeof t=="bigint"?t.toString():t}function gt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function fn(e){return e==null}function hn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Zi(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]))}const s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Io=Symbol("evaluating");function b(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Io)return o===void 0&&(o=Io,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ie(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function wo(e){return JSON.stringify(e)}function Hi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const vo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Vi=gt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ze(e){if(Qe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Qe(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Co(e){return ze(e)?{...e}:Array.isArray(e)?[...e]:e}const Wi=new Set(["string","number","symbol"]);function je(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function we(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Yi(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ki={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 Ji(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");const s=Ie(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return be(this,"shape",i),i},checks:[]});return we(e,s)}function Xi(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");const s=Ie(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return be(this,"shape",i),i},checks:[]});return we(e,s)}function Qi(e,t){if(!ze(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Ie(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return be(this,"shape",s),s}});return we(e,r)}function qi(e,t){if(!ze(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return be(this,"shape",o),o}});return we(e,n)}function ea(e,t){const n=Ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return be(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return we(e,n)}function ta(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=Ie(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return be(this,"shape",c),c},checks:[]});return we(t,i)}function na(e,t,n){const o=Ie(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return be(this,"shape",s),s}});return we(t,o)}function Ue(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Fe(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function _t(e){return typeof e=="string"?e:e?.message}function ve(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(n.customError?.(e))??_t(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function mn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function qe(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const Ro=(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,pn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bo=l("$ZodError",Ro),Ao=l("$ZodError",Ro,{Parent:Error});function oa(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function ra(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const En=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Pe;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>ve(c,s,ye())));throw vo(a,r?.callee),a}return i.value},gn=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>ve(c,s,ye())));throw vo(a,r?.callee),a}return i.value},yt=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Pe;return s.issues.length?{success:!1,error:new(e??bo)(s.issues.map(i=>ve(i,r,ye())))}:{success:!0,data:s.value}},sa=yt(Ao),St=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>ve(i,r,ye())))}:{success:!0,data:s.value}},ia=St(Ao),aa=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,r)},ca=e=>(t,n,o)=>En(e)(t,n,o),ua=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,r)},la=e=>async(t,n,o)=>gn(e)(t,n,o),da=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return yt(e)(t,n,r)},pa=e=>(t,n,o)=>yt(e)(t,n,o),fa=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return St(e)(t,n,r)},ha=e=>async(t,n,o)=>St(e)(t,n,o),ma=/^[cC][^\s-]{8,}$/,Ea=/^[0-9a-z]+$/,ga=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_a=/^[0-9a-vA-V]{20}$/,ya=/^[A-Za-z0-9]{27}$/,Sa=/^[a-zA-Z0-9_-]{21}$/,Ta=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Oa=/^([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})$/,No=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)$/,Ia=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function va(){return new RegExp(wa,"u")}const Ca=/^(?:(?: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])$/,Ra=/^(([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}|:))$/,ba=/^((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])$/,Aa=/^(([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])$/,Na=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$o=/^[A-Za-z0-9_-]*$/,$a=/^\+[1-9]\d{6,14}$/,Do="(?:(?:\\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])))",Da=new RegExp(`^${Do}$`);function Lo(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function La(e){return new RegExp(`^${Lo(e)}$`)}function ka(e){const t=Lo({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(`^${Do}T(?:${o})$`)}const Pa=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},za=/^-?\d+$/,ko=/^-?\d+(?:\.\d+)?$/,ja=/^(?:true|false)$/i,Ua=/^[^A-Z]*$/,Fa=/^[^a-z]*$/,J=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Po={number:"number",bigint:"bigint",object:"date"},zo=l("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Po[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.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:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jo=l("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Po[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.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:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ma=l("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.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.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Zi(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ga=l("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,s]=Ki[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=r,a.maximum=s,n&&(a.pattern=za)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,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}):i.issues.push({input:a,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});return}}a<r&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),xa=l("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=mn(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ba=l("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=mn(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Za=l("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=mn(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Tt=l("$ZodCheckStringFormat",(e,t)=>{var n,o;J.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Ha=l("$ZodCheckRegex",(e,t)=>{Tt.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})}}),Va=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ua),Tt.init(e,t)}),Wa=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Fa),Tt.init(e,t)}),Ya=l("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=je(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Ka=l("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${je(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ja=l("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${je(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),Xa=l("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Qa{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
2
|
+
`).filter(i=>i),r=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,r.join(`
|
|
3
|
+
`))}}const qa={major:4,minor:3,patch:6},L=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qa;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const s of r._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(i,a,c)=>{let u=Ue(i),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(i))continue}else if(u)continue;const y=i.issues.length,T=m._zod.check(i);if(T instanceof Promise&&c?.async===!1)throw new Pe;if(d||T instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await T,i.issues.length!==y&&(u||(u=Ue(i,y)))});else{if(i.issues.length===y)continue;u||(u=Ue(i,y))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(Ue(i))return i.aborted=!0,i;const u=r(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Pe;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Pe;return c.then(u=>r(u,o,a))}return r(c,o,a)}}b(e,"~standard",()=>({validate:r=>{try{const s=sa(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return ia(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),_n=l("$ZodString",(e,t)=>{L.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Pa(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),$=l("$ZodStringFormat",(e,t)=>{Tt.init(e,t),_n.init(e,t)}),ec=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Oa),$.init(e,t)}),tc=l("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=No(o))}else t.pattern??(t.pattern=No());$.init(e,t)}),nc=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ia),$.init(e,t)}),oc=l("$ZodURL",(e,t)=>{$.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),rc=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=va()),$.init(e,t)}),sc=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Sa),$.init(e,t)}),ic=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ma),$.init(e,t)}),ac=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ea),$.init(e,t)}),cc=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ga),$.init(e,t)}),uc=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_a),$.init(e,t)}),lc=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ya),$.init(e,t)}),dc=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ka(t)),$.init(e,t)}),pc=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Da),$.init(e,t)}),fc=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=La(t)),$.init(e,t)}),hc=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ta),$.init(e,t)}),mc=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ca),$.init(e,t),e._zod.bag.format="ipv4"}),Ec=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ra),$.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})}}}),gc=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ba),$.init(e,t)}),_c=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Aa),$.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Uo(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const yc=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Na),$.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Uo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Sc(e){if(!$o.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Uo(n)}const Tc=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$o),$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Sc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Oc=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$a),$.init(e,t)});function Ic(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const wc=l("$ZodJWT",(e,t)=>{$.init(e,t),e._zod.check=n=>{Ic(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Fo=l("$ZodNumber",(e,t)=>{L.init(e,t),e._zod.pattern=e._zod.bag.pattern??ko,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),vc=l("$ZodNumberFormat",(e,t)=>{Ga.init(e,t),Fo.init(e,t)}),Cc=l("$ZodBoolean",(e,t)=>{L.init(e,t),e._zod.pattern=ja,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Rc=l("$ZodUnknown",(e,t)=>{L.init(e,t),e._zod.parse=n=>n}),bc=l("$ZodNever",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Mo(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}const Ac=l("$ZodArray",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>Mo(u,n,i))):Mo(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Ot(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...Fe(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Go(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=Yi(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xo(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(u==="never"){i.push(m);continue}const y=c.run({value:t[m],issues:[]},o);y instanceof Promise?e.push(y.then(T=>Ot(T,n,m,t,d))):Ot(y,n,m,t,d)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Nc=l("$ZodObject",(e,t)=>{if(L.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=gt(()=>Go(t));b(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const m of d.values)c[u].add(m)}}return c});const r=Qe,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const u=a.value;if(!r(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const d=[],m=i.shape;for(const y of i.keys){const T=m[y],Z=T._zod.optout==="optional",B=T._zod.run({value:u[y],issues:[]},c);B instanceof Promise?d.push(B.then(dt=>Ot(dt,a,y,u,Z))):Ot(B,a,y,u,Z)}return s?xo(d,u,a,c,o.value,e):d.length?Promise.all(d).then(()=>a):a}}),$c=l("$ZodObjectJIT",(e,t)=>{Nc.init(e,t);const n=e._zod.parse,o=gt(()=>Go(t)),r=y=>{const T=new Qa(["shape","payload","ctx"]),Z=o.value,B=fe=>{const K=wo(fe);return`shape[${K}]._zod.run({ value: input[${K}], issues: [] }, ctx)`};T.write("const input = payload.value;");const dt=Object.create(null);let ui=0;for(const fe of Z.keys)dt[fe]=`key_${ui++}`;T.write("const newResult = {};");for(const fe of Z.keys){const K=dt[fe],ae=wo(fe),di=y[fe]?._zod?.optout==="optional";T.write(`const ${K} = ${B(fe)};`),di?T.write(`
|
|
4
|
+
if (${K}.issues.length) {
|
|
5
|
+
if (${ae} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
|
|
7
7
|
...iss,
|
|
8
|
-
path: iss.path ? [${
|
|
8
|
+
path: iss.path ? [${ae}, ...iss.path] : [${ae}]
|
|
9
9
|
})));
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
if (${
|
|
14
|
-
if (${
|
|
15
|
-
newResult[${
|
|
13
|
+
if (${K}.value === undefined) {
|
|
14
|
+
if (${ae} in input) {
|
|
15
|
+
newResult[${ae}] = undefined;
|
|
16
16
|
}
|
|
17
17
|
} else {
|
|
18
|
-
newResult[${
|
|
18
|
+
newResult[${ae}] = ${K}.value;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
`):
|
|
22
|
-
if (${
|
|
23
|
-
payload.issues = payload.issues.concat(${
|
|
21
|
+
`):T.write(`
|
|
22
|
+
if (${K}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
|
|
24
24
|
...iss,
|
|
25
|
-
path: iss.path ? [${
|
|
25
|
+
path: iss.path ? [${ae}, ...iss.path] : [${ae}]
|
|
26
26
|
})));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if (${
|
|
30
|
-
if (${
|
|
31
|
-
newResult[${
|
|
29
|
+
if (${K}.value === undefined) {
|
|
30
|
+
if (${ae} in input) {
|
|
31
|
+
newResult[${ae}] = undefined;
|
|
32
32
|
}
|
|
33
33
|
} else {
|
|
34
|
-
newResult[${
|
|
34
|
+
newResult[${ae}] = ${K}.value;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
`)}w.write("payload.value = newResult;"),w.write("return payload;");const R=w.compile();return(p,l)=>R(T,p,l)};let i;const s=Wt,a=!ur.jitless,u=a&&mc.value,f=t.catchall;let h;e._zod.parse=(T,w)=>{h??(h=r.value);const k=T.value;return s(k)?a&&u&&w?.async===!1&&w.jitless!==!0?(i||(i=o(t.shape)),T=i(T,w),f?ss([],k,T,w,h,e):T):n(T,w):(T.issues.push({expected:"object",code:"invalid_type",input:k,inst:e}),T)}});function is(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Dt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>_t(s,r,lt())))}),t)}const as=g("$ZodUnion",(e,t)=>{me.init(e,t),ne(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>fr(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>is(c,o,e,i)):is(a,o,e,i)}}),tl=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,as.init(e,t);const n=e._zod.parse;ne(e._zod,"propValues",()=>{const o={};for(const i of t.options){const s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,c]of Object.entries(s)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const r=hn(()=>{const o=t.options,i=new Map;for(const s of o){const a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const c of a){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(o,i)=>{const s=o.value;if(!Wt(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),nl=g("$ZodIntersection",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>cs(n,c,u)):cs(n,i,s)}});function Er(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(Nt(e)&&Nt(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Er(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Er(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cs(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),Dt(e))return e;const s=Er(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const rl=g("$ZodRecord",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Nt(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const f=t.valueType._zod.run({value:o[u],issues:[]},r);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...kt(u,h.issues)),n.value[u]=h.value})):(f.issues.length&&n.issues.push(...kt(u,f.issues)),n.value[u]=f.value)}let c;for(const u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Qo.test(a)&&c.issues.length){const h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(c=h)}if(c.issues.length){t.mode==="loose"?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>_t(h,r,lt())),input:a,path:[a],inst:e});continue}const f=t.valueType._zod.run({value:o[a],issues:[]},r);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...kt(a,h.issues)),n.value[c.value]=h.value})):(f.issues.length&&n.issues.push(...kt(a,f.issues)),n.value[c.value]=f.value)}}return i.length?Promise.all(i).then(()=>n):n}}),ol=g("$ZodEnum",(e,t)=>{me.init(e,t);const n=Uo(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>gc.has(typeof o)).map(o=>typeof o=="string"?Lt(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),sl=g("$ZodLiteral",(e,t)=>{if(me.init(e,t),t.values.length===0)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(r=>typeof r=="string"?Lt(r):r?Lt(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),il=g("$ZodTransform",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mo(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new $t;return n.value=o,n}});function us(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const ls=g("$ZodOptional",(e,t)=>{me.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fr(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>us(i,n.value)):us(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),al=g("$ZodExactOptional",(e,t)=>{ls.init(e,t),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),cl=g("$ZodNullable",(e,t)=>{me.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fr(n.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),ul=g("$ZodDefault",(e,t)=>{me.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>ps(i,t)):ps(o,t)}});function ps(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ll=g("$ZodPrefault",(e,t)=>{me.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),pl=g("$ZodNonOptional",(e,t)=>{me.init(e,t),ne(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>fs(i,e)):fs(o,e)}});function fs(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const fl=g("$ZodCatch",(e,t)=>{me.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>_t(s,r,lt()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>_t(i,r,lt()))},input:n.value}),n.issues=[]),n)}}),dl=g("$ZodPipe",(e,t)=>{me.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>Sn(s,t.in,r)):Sn(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Sn(i,t.out,r)):Sn(o,t.out,r)}});function Sn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const hl=g("$ZodReadonly",(e,t)=>{me.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>t.innerType?._zod?.optin),ne(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(ds):ds(o)}});function ds(e){return e.value=Object.freeze(e.value),e}const ml=g("$ZodCustom",(e,t)=>{Pe.init(e,t),me.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>hs(i,n,r,e));hs(o,n,r,e)}});function hs(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Kt(o))}}var ms;class gl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function El(){return new gl}(ms=globalThis).__zod_globalRegistry??(ms.__zod_globalRegistry=El());const Yt=globalThis.__zod_globalRegistry;function _l(e,t){return new e({type:"string",...x(t)})}function yl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function gs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function Sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function Tl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function Rl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function Ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function Es(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function vl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function Cl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function wl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function Il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function Al(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function bl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function $l(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function Nl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function Ll(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function Dl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function kl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function Pl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function xl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function zl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function Ml(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function Ul(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function jl(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function Fl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function Gl(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function Hl(e,t){return new e({type:"number",checks:[],...x(t)})}function Bl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function Zl(e,t){return new e({type:"boolean",...x(t)})}function Vl(e){return new e({type:"unknown"})}function Wl(e,t){return new e({type:"never",...x(t)})}function _s(e,t){return new Jo({check:"less_than",...x(t),value:e,inclusive:!1})}function _r(e,t){return new Jo({check:"less_than",...x(t),value:e,inclusive:!0})}function ys(e,t){return new es({check:"greater_than",...x(t),value:e,inclusive:!1})}function yr(e,t){return new es({check:"greater_than",...x(t),value:e,inclusive:!0})}function Ss(e,t){return new uu({check:"multiple_of",...x(t),value:e})}function Ts(e,t){return new pu({check:"max_length",...x(t),maximum:e})}function Tn(e,t){return new fu({check:"min_length",...x(t),minimum:e})}function Rs(e,t){return new du({check:"length_equals",...x(t),length:e})}function Kl(e,t){return new hu({check:"string_format",format:"regex",...x(t),pattern:e})}function Yl(e){return new mu({check:"string_format",format:"lowercase",...x(e)})}function Xl(e){return new gu({check:"string_format",format:"uppercase",...x(e)})}function Ql(e,t){return new Eu({check:"string_format",format:"includes",...x(t),includes:e})}function ql(e,t){return new _u({check:"string_format",format:"starts_with",...x(t),prefix:e})}function Jl(e,t){return new yu({check:"string_format",format:"ends_with",...x(t),suffix:e})}function Pt(e){return new Su({check:"overwrite",tx:e})}function ep(e){return Pt(t=>t.normalize(e))}function tp(){return Pt(e=>e.trim())}function np(){return Pt(e=>e.toLowerCase())}function rp(){return Pt(e=>e.toUpperCase())}function op(){return Pt(e=>hc(e))}function sp(e,t,n){return new e({type:"array",element:t,...x(n)})}function ip(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}function ap(e){const t=cp(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Kt(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Kt(o))}},e(n.value,n)));return t}function cp(e,t){const n=new Pe({check:"custom",...x(t)});return n._zod.check=e,n}function Os(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Yt,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 ve(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,f);else{const T=s.schema,w=t.processors[o.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);w(e,t,T,f)}const h=e._zod.parent;h&&(s.ref||(s.ref=h),ve(h,t,f),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&Le(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function vs(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(s[0])?.id,T=e.external.uri??(k=>k);if(h)return{ref:T(h)};const w=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=w,{defId:w,ref:`${T("__shared")}#/${a}/${w}`}}if(s[1]===n)return{ref:"#"};const u=`#/${a}/`,f=s[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+f}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const h in f)delete f[h];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
37
|
+
`)}T.write("payload.value = newResult;"),T.write("return payload;");const li=T.compile();return(fe,K)=>li(y,fe,K)};let s;const i=Qe,a=!dn.jitless,u=a&&Vi.value,d=t.catchall;let m;e._zod.parse=(y,T)=>{m??(m=o.value);const Z=y.value;return i(Z)?a&&u&&T?.async===!1&&T.jitless!==!0?(s||(s=r(t.shape)),y=s(y,T),d?xo([],Z,y,T,m,e):y):n(y,T):(y.issues.push({expected:"object",code:"invalid_type",input:Z,inst:e}),y)}});function Bo(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!Ue(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>ve(i,o,ye())))}),t)}const Zo=l("$ZodUnion",(e,t)=>{L.init(e,t),b(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>hn(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>Bo(c,r,e,s)):Bo(a,r,e,s)}}),Dc=l("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zo.init(e,t);const n=e._zod.parse;b(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){r[a]||(r[a]=new Set);for(const u of c)r[a].add(u)}}return r});const o=gt(()=>{const r=t.options,s=new Map;for(const i of r){const a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!Qe(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const a=o.value.get(i?.[t.discriminator]);return a?a._zod.run(r,s):t.unionFallback?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),r)}}),Lc=l("$ZodIntersection",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Ho(n,c,u)):Ho(n,s,i)}});function yn(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(ze(e)&&ze(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=yn(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}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 r=e[o],s=t[o],i=yn(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ho(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),Ue(e))return e;const i=yn(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const kc=l("$ZodRecord",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!ze(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=t.valueType._zod.run({value:r[u],issues:[]},o);d instanceof Promise?s.push(d.then(m=>{m.issues.length&&n.issues.push(...Fe(u,m.issues)),n.value[u]=m.value})):(d.issues.length&&n.issues.push(...Fe(u,d.issues)),n.value[u]=d.value)}let c;for(const u in r)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&ko.test(a)&&c.issues.length){const m=t.keyType._zod.run({value:Number(a),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(c=m)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>ve(m,o,ye())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:r[a],issues:[]},o);d instanceof Promise?s.push(d.then(m=>{m.issues.length&&n.issues.push(...Fe(a,m.issues)),n.value[c.value]=m.value})):(d.issues.length&&n.issues.push(...Fe(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Pc=l("$ZodEnum",(e,t)=>{L.init(e,t);const n=Oo(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>Wi.has(typeof r)).map(r=>typeof r=="string"?je(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),zc=l("$ZodLiteral",(e,t)=>{if(L.init(e,t),t.values.length===0)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(o=>typeof o=="string"?je(o):o?je(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}}),jc=l("$ZodTransform",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new Pe;return n.value=r,n}});function Vo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Wo=l("$ZodOptional",(e,t)=>{L.init(e,t),e._zod.optin="optional",e._zod.optout="optional",b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${hn(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Vo(s,n.value)):Vo(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Uc=l("$ZodExactOptional",(e,t)=>{Wo.init(e,t),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Fc=l("$ZodNullable",(e,t)=>{L.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${hn(n.source)}|null)$`):void 0}),b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),Mc=l("$ZodDefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Yo(s,t)):Yo(r,t)}});function Yo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gc=l("$ZodPrefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),xc=l("$ZodNonOptional",(e,t)=>{L.init(e,t),b(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Ko(s,e)):Ko(r,e)}});function Ko(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Bc=l("$ZodCatch",(e,t)=>{L.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>ve(i,o,ye()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>ve(s,o,ye()))},input:n.value}),n.issues=[]),n)}}),Zc=l("$ZodPipe",(e,t)=>{L.init(e,t),b(e._zod,"values",()=>t.in._zod.values),b(e._zod,"optin",()=>t.in._zod.optin),b(e._zod,"optout",()=>t.out._zod.optout),b(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>It(i,t.in,o)):It(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>It(s,t.out,o)):It(r,t.out,o)}});function It(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Hc=l("$ZodReadonly",(e,t)=>{L.init(e,t),b(e._zod,"propValues",()=>t.innerType._zod.propValues),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"optin",()=>t.innerType?._zod?.optin),b(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(Jo):Jo(r)}});function Jo(e){return e.value=Object.freeze(e.value),e}const Vc=l("$ZodCustom",(e,t)=>{J.init(e,t),L.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>Xo(s,n,o,e));Xo(r,n,o,e)}});function Xo(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(qe(r))}}var Qo;class Wc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Yc(){return new Wc}(Qo=globalThis).__zod_globalRegistry??(Qo.__zod_globalRegistry=Yc());const et=globalThis.__zod_globalRegistry;function Kc(e,t){return new e({type:"string",...g(t)})}function Jc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function qo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function Xc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function Qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function eu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function er(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function tu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function nu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function ou(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function ru(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function su(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function iu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function au(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function cu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function uu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function lu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function du(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function pu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function fu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function hu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function mu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function Eu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function gu(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function _u(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function yu(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Su(e,t){return new e({type:"number",checks:[],...g(t)})}function Tu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Ou(e,t){return new e({type:"boolean",...g(t)})}function Iu(e){return new e({type:"unknown"})}function wu(e,t){return new e({type:"never",...g(t)})}function tr(e,t){return new zo({check:"less_than",...g(t),value:e,inclusive:!1})}function Sn(e,t){return new zo({check:"less_than",...g(t),value:e,inclusive:!0})}function nr(e,t){return new jo({check:"greater_than",...g(t),value:e,inclusive:!1})}function Tn(e,t){return new jo({check:"greater_than",...g(t),value:e,inclusive:!0})}function or(e,t){return new Ma({check:"multiple_of",...g(t),value:e})}function rr(e,t){return new xa({check:"max_length",...g(t),maximum:e})}function wt(e,t){return new Ba({check:"min_length",...g(t),minimum:e})}function sr(e,t){return new Za({check:"length_equals",...g(t),length:e})}function vu(e,t){return new Ha({check:"string_format",format:"regex",...g(t),pattern:e})}function Cu(e){return new Va({check:"string_format",format:"lowercase",...g(e)})}function Ru(e){return new Wa({check:"string_format",format:"uppercase",...g(e)})}function bu(e,t){return new Ya({check:"string_format",format:"includes",...g(t),includes:e})}function Au(e,t){return new Ka({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Nu(e,t){return new Ja({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Me(e){return new Xa({check:"overwrite",tx:e})}function $u(e){return Me(t=>t.normalize(e))}function Du(){return Me(e=>e.trim())}function Lu(){return Me(e=>e.toLowerCase())}function ku(){return Me(e=>e.toUpperCase())}function Pu(){return Me(e=>Hi(e))}function zu(e,t,n){return new e({type:"array",element:t,...g(n)})}function ju(e,t,n){const o=g(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Uu(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Fu(e){const t=Mu(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(qe(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(qe(r))}},e(n.value,n)));return t}function Mu(e,t){const n=new J({check:"custom",...g(t)});return n._zod.check=e,n}function ir(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??et,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 M(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{const y=i.schema,T=t.processors[r.type];if(!T)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);T(e,t,y,d)}const m=e._zod.parent;m&&(i.ref||(i.ref=m),M(m,t,d),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&W(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ar(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 i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}const r=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=e.external.registry.get(i[0])?.id,y=e.external.uri??(Z=>Z);if(m)return{ref:y(m)};const T=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=T,{defId:T,ref:`${y("__shared")}#/${a}/${T}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=r(i);a.def={...a.schema},u&&(a.defId=u);const d=a.schema;for(const m in d)delete d[m];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
38
38
|
|
|
39
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function Cs(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const a=e.seen.get(s);if(a.ref===null)return;const c=a.def??a.schema,u={...c},f=a.ref;if(a.ref=null,f){r(f);const T=e.seen.get(f),w=T.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(w)):Object.assign(c,w),Object.assign(c,u),s._zod.parent===f)for(const M in c)M==="$ref"||M==="allOf"||M in u||delete c[M];if(w.$ref&&T.def)for(const M in c)M==="$ref"||M==="allOf"||M in T.def&&JSON.stringify(c[M])===JSON.stringify(T.def[M])&&delete c[M]}const h=s._zod.parent;if(h&&h!==f){r(h);const T=e.seen.get(h);if(T?.schema.$ref&&(c.$ref=T.schema.$ref,T.def))for(const w in c)w==="$ref"||w==="allOf"||w in T.def&&JSON.stringify(c[w])===JSON.stringify(T.def[w])&&delete c[w]}e.override({zodSchema:s,jsonSchema:c,path:a.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const a=s[1];a.def&&a.defId&&(i[a.defId]=a.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rn(t,"input",e.processors),output:Rn(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Le(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Le(r.element,n);if(r.type==="set")return Le(r.valueType,n);if(r.type==="lazy")return Le(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Le(r.innerType,n);if(r.type==="intersection")return Le(r.left,n)||Le(r.right,n);if(r.type==="record"||r.type==="map")return Le(r.keyType,n)||Le(r.valueType,n);if(r.type==="pipe")return Le(r.in,n)||Le(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Le(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Le(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Le(o,n))return!0;return!!(r.rest&&Le(r.rest,n))}return!1}const up=(e,t={})=>n=>{const r=Os({...n,processors:t});return ve(e,r),vs(r,e),Cs(r,e)},Rn=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Os({...o??{},target:i,io:t,processors:n});return ve(e,s),vs(s,e),Cs(s,e)},lp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pp=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=lp[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},fp=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof i=="number"&&(o.minimum=i,typeof f=="number"&&t.target!=="draft-04"&&(f>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof s=="number"&&(o.maximum=s,typeof u=="number"&&t.target!=="draft-04"&&(u<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},dp=(e,t,n,r)=>{n.type="boolean"},hp=(e,t,n,r)=>{n.not={}},mp=(e,t,n,r)=>{},gp=(e,t,n,r)=>{const o=e._zod.def,i=Uo(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Ep=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},_p=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Sp=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ve(i.element,t,{...r,path:[...r.path,"items"]})},Tp=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=ve(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const f=i.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=ve(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Rp=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>ve(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},Op=(e,t,n,r)=>{const o=e._zod.def,i=ve(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=ve(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},vp=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const f=ve(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const h of c)o.patternProperties[h.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=ve(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=ve(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=s._zod.values;if(u){const f=[...u].filter(h=>typeof h=="string"||typeof h=="number");f.length>0&&(o.required=f)}},Cp=(e,t,n,r)=>{const o=e._zod.def,i=ve(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},wp=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ip=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ap=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},bp=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},$p=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;ve(i,t,r);const s=t.seen.get(e);s.ref=i},Np=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},ws=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Lp=g("ZodISODateTime",(e,t)=>{ku.init(e,t),Ee.init(e,t)});function Dp(e){return Ul(Lp,e)}const kp=g("ZodISODate",(e,t)=>{Pu.init(e,t),Ee.init(e,t)});function Pp(e){return jl(kp,e)}const xp=g("ZodISOTime",(e,t)=>{xu.init(e,t),Ee.init(e,t)});function zp(e){return Fl(xp,e)}const Mp=g("ZodISODuration",(e,t)=>{zu.init(e,t),Ee.init(e,t)});function Up(e){return Gl(Mp,e)}const jp=(e,t)=>{Zo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ic(e,n)},flatten:{value:n=>wc(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,lr,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,lr,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ze=g("ZodError",jp,{Parent:Error}),Fp=hr(Ze),Gp=mr(Ze),Hp=gn(Ze),Bp=En(Ze),Zp=$c(Ze),Vp=Nc(Ze),Wp=Lc(Ze),Kp=Dc(Ze),Yp=kc(Ze),Xp=Pc(Ze),Qp=xc(Ze),qp=zc(Ze),ge=g("ZodType",(e,t)=>(me.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Rn(e,"input"),output:Rn(e,"output")}}),e.toJSONSchema=up(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(gt(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>Et(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Fp(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Hp(e,n,r),e.parseAsync=async(n,r)=>Gp(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Bp(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Zp(e,n,r),e.decode=(n,r)=>Vp(e,n,r),e.encodeAsync=async(n,r)=>Wp(e,n,r),e.decodeAsync=async(n,r)=>Kp(e,n,r),e.safeEncode=(n,r)=>Yp(e,n,r),e.safeDecode=(n,r)=>Xp(e,n,r),e.safeEncodeAsync=async(n,r)=>Qp(e,n,r),e.safeDecodeAsync=async(n,r)=>qp(e,n,r),e.refine=(n,r)=>e.check(Zf(n,r)),e.superRefine=n=>e.check(Vf(n)),e.overwrite=n=>e.check(Pt(n)),e.optional=()=>Ps(e),e.exactOptional=()=>Lf(e),e.nullable=()=>xs(e),e.nullish=()=>Ps(xs(e)),e.nonoptional=n=>Mf(e,n),e.array=()=>oe(e),e.or=n=>xt([e,n]),e.and=n=>wf(e,n),e.transform=n=>Ms(e,$f(n)),e.default=n=>Pf(e,n),e.prefault=n=>zf(e,n),e.catch=n=>jf(e,n),e.pipe=n=>Ms(e,n),e.readonly=()=>Hf(e),e.describe=n=>{const r=e.clone();return Yt.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Yt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Yt.get(e);const r=e.clone();return Yt.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Is=g("_ZodString",(e,t)=>{gr.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,i)=>pp(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Kl(...r)),e.includes=(...r)=>e.check(Ql(...r)),e.startsWith=(...r)=>e.check(ql(...r)),e.endsWith=(...r)=>e.check(Jl(...r)),e.min=(...r)=>e.check(Tn(...r)),e.max=(...r)=>e.check(Ts(...r)),e.length=(...r)=>e.check(Rs(...r)),e.nonempty=(...r)=>e.check(Tn(1,...r)),e.lowercase=r=>e.check(Yl(r)),e.uppercase=r=>e.check(Xl(r)),e.trim=()=>e.check(tp()),e.normalize=(...r)=>e.check(ep(...r)),e.toLowerCase=()=>e.check(np()),e.toUpperCase=()=>e.check(rp()),e.slugify=()=>e.check(op())}),Jp=g("ZodString",(e,t)=>{gr.init(e,t),Is.init(e,t),e.email=n=>e.check(yl(ef,n)),e.url=n=>e.check(Es(bs,n)),e.jwt=n=>e.check(Ml(gf,n)),e.emoji=n=>e.check(vl(tf,n)),e.guid=n=>e.check(gs(As,n)),e.uuid=n=>e.check(Sl(On,n)),e.uuidv4=n=>e.check(Tl(On,n)),e.uuidv6=n=>e.check(Rl(On,n)),e.uuidv7=n=>e.check(Ol(On,n)),e.nanoid=n=>e.check(Cl(nf,n)),e.guid=n=>e.check(gs(As,n)),e.cuid=n=>e.check(wl(rf,n)),e.cuid2=n=>e.check(Il(of,n)),e.ulid=n=>e.check(Al(sf,n)),e.base64=n=>e.check(Pl(df,n)),e.base64url=n=>e.check(xl(hf,n)),e.xid=n=>e.check(bl(af,n)),e.ksuid=n=>e.check($l(cf,n)),e.ipv4=n=>e.check(Nl(uf,n)),e.ipv6=n=>e.check(Ll(lf,n)),e.cidrv4=n=>e.check(Dl(pf,n)),e.cidrv6=n=>e.check(kl(ff,n)),e.e164=n=>e.check(zl(mf,n)),e.datetime=n=>e.check(Dp(n)),e.date=n=>e.check(Pp(n)),e.time=n=>e.check(zp(n)),e.duration=n=>e.check(Up(n))});function A(e){return _l(Jp,e)}const Ee=g("ZodStringFormat",(e,t)=>{fe.init(e,t),Is.init(e,t)}),ef=g("ZodEmail",(e,t)=>{Cu.init(e,t),Ee.init(e,t)}),As=g("ZodGUID",(e,t)=>{Ou.init(e,t),Ee.init(e,t)}),On=g("ZodUUID",(e,t)=>{vu.init(e,t),Ee.init(e,t)}),bs=g("ZodURL",(e,t)=>{wu.init(e,t),Ee.init(e,t)});function $s(e){return Es(bs,e)}const tf=g("ZodEmoji",(e,t)=>{Iu.init(e,t),Ee.init(e,t)}),nf=g("ZodNanoID",(e,t)=>{Au.init(e,t),Ee.init(e,t)}),rf=g("ZodCUID",(e,t)=>{bu.init(e,t),Ee.init(e,t)}),of=g("ZodCUID2",(e,t)=>{$u.init(e,t),Ee.init(e,t)}),sf=g("ZodULID",(e,t)=>{Nu.init(e,t),Ee.init(e,t)}),af=g("ZodXID",(e,t)=>{Lu.init(e,t),Ee.init(e,t)}),cf=g("ZodKSUID",(e,t)=>{Du.init(e,t),Ee.init(e,t)}),uf=g("ZodIPv4",(e,t)=>{Mu.init(e,t),Ee.init(e,t)}),lf=g("ZodIPv6",(e,t)=>{Uu.init(e,t),Ee.init(e,t)}),pf=g("ZodCIDRv4",(e,t)=>{ju.init(e,t),Ee.init(e,t)}),ff=g("ZodCIDRv6",(e,t)=>{Fu.init(e,t),Ee.init(e,t)}),df=g("ZodBase64",(e,t)=>{Gu.init(e,t),Ee.init(e,t)}),hf=g("ZodBase64URL",(e,t)=>{Bu.init(e,t),Ee.init(e,t)}),mf=g("ZodE164",(e,t)=>{Zu.init(e,t),Ee.init(e,t)}),gf=g("ZodJWT",(e,t)=>{Wu.init(e,t),Ee.init(e,t)}),Ns=g("ZodNumber",(e,t)=>{ns.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,i)=>fp(e,r,o),e.gt=(r,o)=>e.check(ys(r,o)),e.gte=(r,o)=>e.check(yr(r,o)),e.min=(r,o)=>e.check(yr(r,o)),e.lt=(r,o)=>e.check(_s(r,o)),e.lte=(r,o)=>e.check(_r(r,o)),e.max=(r,o)=>e.check(_r(r,o)),e.int=r=>e.check(Ve(r)),e.safe=r=>e.check(Ve(r)),e.positive=r=>e.check(ys(0,r)),e.nonnegative=r=>e.check(yr(0,r)),e.negative=r=>e.check(_s(0,r)),e.nonpositive=r=>e.check(_r(0,r)),e.multipleOf=(r,o)=>e.check(Ss(r,o)),e.step=(r,o)=>e.check(Ss(r,o)),e.finite=()=>e;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 vn(e){return Hl(Ns,e)}const Ef=g("ZodNumberFormat",(e,t)=>{Ku.init(e,t),Ns.init(e,t)});function Ve(e){return Bl(Ef,e)}const _f=g("ZodBoolean",(e,t)=>{Yu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dp(e,n,r)});function J(e){return Zl(_f,e)}const yf=g("ZodUnknown",(e,t)=>{Xu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mp()});function Ls(){return Vl(yf)}const Sf=g("ZodNever",(e,t)=>{Qu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hp(e,n,r)});function Tf(e){return Wl(Sf,e)}const Rf=g("ZodArray",(e,t)=>{qu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sp(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Tn(n,r)),e.nonempty=n=>e.check(Tn(1,n)),e.max=(n,r)=>e.check(Ts(n,r)),e.length=(n,r)=>e.check(Rs(n,r)),e.unwrap=()=>e.element});function oe(e,t){return sp(Rf,e,t)}const Of=g("ZodObject",(e,t)=>{el.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Tp(e,n,r,o),ne(e,"shape",()=>t.shape),e.keyof=()=>_e(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ls()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ls()}),e.strict=()=>e.clone({...e._zod.def,catchall:Tf()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Tc(e,n),e.safeExtend=n=>Rc(e,n),e.merge=n=>Oc(e,n),e.pick=n=>yc(e,n),e.omit=n=>Sc(e,n),e.partial=(...n)=>vc(ks,e,n[0]),e.required=(...n)=>Cc(zs,e,n[0])});function O(e,t){const n={type:"object",shape:e??{},...x(t)};return new Of(n)}const Ds=g("ZodUnion",(e,t)=>{as.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rp(e,n,r,o),e.options=t.options});function xt(e,t){return new Ds({type:"union",options:e,...x(t)})}const vf=g("ZodDiscriminatedUnion",(e,t)=>{Ds.init(e,t),tl.init(e,t)});function We(e,t,n){return new vf({type:"union",options:t,discriminator:e,...x(n)})}const Cf=g("ZodIntersection",(e,t)=>{nl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Op(e,n,r,o)});function wf(e,t){return new Cf({type:"intersection",left:e,right:t})}const If=g("ZodRecord",(e,t)=>{rl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vp(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function De(e,t,n){return new If({type:"record",keyType:e,valueType:t,...x(n)})}const Sr=g("ZodEnum",(e,t)=>{ol.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,i)=>gp(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Sr({...t,checks:[],...x(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Sr({...t,checks:[],...x(o),entries:i})}});function _e(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Sr({type:"enum",entries:n,...x(t)})}const Af=g("ZodLiteral",(e,t)=>{sl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ep(e,n,r),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 P(e,t){return new Af({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const bf=g("ZodTransform",(e,t)=>{il.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yp(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mo(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Kt(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Kt(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function $f(e){return new bf({type:"transform",transform:e})}const ks=g("ZodOptional",(e,t)=>{ls.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ps(e){return new ks({type:"optional",innerType:e})}const Nf=g("ZodExactOptional",(e,t)=>{al.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Lf(e){return new Nf({type:"optional",innerType:e})}const Df=g("ZodNullable",(e,t)=>{cl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new Df({type:"nullable",innerType:e})}const kf=g("ZodDefault",(e,t)=>{ul.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ip(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Pf(e,t){return new kf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ho(t)}})}const xf=g("ZodPrefault",(e,t)=>{ll.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ap(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function zf(e,t){return new xf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ho(t)}})}const zs=g("ZodNonOptional",(e,t)=>{pl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Mf(e,t){return new zs({type:"nonoptional",innerType:e,...x(t)})}const Uf=g("ZodCatch",(e,t)=>{fl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jf(e,t){return new Uf({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ff=g("ZodPipe",(e,t)=>{dl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$p(e,n,r,o),e.in=t.in,e.out=t.out});function Ms(e,t){return new Ff({type:"pipe",in:e,out:t})}const Gf=g("ZodReadonly",(e,t)=>{hl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Np(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Hf(e){return new Gf({type:"readonly",innerType:e})}const Bf=g("ZodCustom",(e,t)=>{ml.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_p(e,n)});function Zf(e,t={}){return ip(Bf,e,t)}function Vf(e){return ap(e)}const Wf={url:"must be a valid URL",email:"must be a valid email address"},Kf=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Yf=e=>e===null?"null":typeof e,Xf=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Kf(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Yf(t)}`}}case"invalid_format":{const t=Wf[e.format];return t?{message:t}:void 0}case"unrecognized_keys":return{message:`Unrecognized property: ${e.keys.map(t=>`'${t}'`).join(", ")}`};case"invalid_union":{const t=e.path?.at(-1);return typeof t=="string"?{message:`'${t}' is required or has invalid value`}:void 0}case"invalid_value":{const{values:t}=e;return t?{message:`Expected one of: ${t.map(n=>`'${String(n)}'`).join(", ")}`}:void 0}case"invalid_key":{const t=e.issues?.[0];return t?{message:t.message}:void 0}default:return}},V={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};_e(Object.values(V));const Q={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};_e(Object.values(Q));const zt={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Qf=_e(Object.values(zt)),Xt={CONTENT:"Content",DESIGN:"Design"};_e(Object.values(Xt));const qf={TEXT:"TEXT",IMAGE:"IMAGE"},Jf=_e(Object.values(qf)),yt={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"},ed=_e(Object.values(yt)),Cn={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},td=_e(Object.values(Cn)),nd={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},rd=_e(Object.values(nd)),od={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},sd=_e(Object.values(od)),id={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},ad=_e(Object.values(id)),Tr={COLOR:"COLOR",GRADIENT:"GRADIENT"},cd=_e(Object.values(Tr));_e(["none","all","small"]);const Ot={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Us={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},ud=_e(Object.values(Ot));_e(Object.values(Us));const ld={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},pd=_e(Object.values(ld)),fd={HEADER_LEFT:"HEADER_LEFT",HEADER_CENTER_LOGO_BURGER:"HEADER_CENTER_LOGO_BURGER",HEADER_CENTER_LOGO_COMPACT:"HEADER_CENTER_LOGO_COMPACT",HEADER_CENTER_LOGO_DETAILED:"HEADER_CENTER_LOGO_DETAILED",HEADER_LEFT_LOGO_BURGER:"HEADER_LEFT_LOGO_BURGER",HEADER_LEFT_LOGO_COMPACT:"HEADER_LEFT_LOGO_COMPACT",HEADER_LEFT_LOGO_DETAILED:"HEADER_LEFT_LOGO_DETAILED",HEADER_LEFT_LOGO_SEARCH:"HEADER_LEFT_LOGO_SEARCH",HEADER_LEFT_LOGO_TEXT:"HEADER_LEFT_LOGO_TEXT",TEXT_ONE_COLUMN:"TEXT_ONE_COLUMN",TEXT_TITLE_LEFT:"TEXT_TITLE_LEFT",TEXT_SUBTITLE_RIGHT:"TEXT_SUBTITLE_RIGHT",TEXT_TWO_COLUMNS:"TEXT_TWO_COLUMNS",TEXT_CENTER:"TEXT_CENTER",TEXT_DESCRIPTION_RIGHT:"TEXT_DESCRIPTION_RIGHT",CTA_BANNER_LEFT:"CTA_BANNER_LEFT",CTA_BANNER_RIGHT:"CTA_BANNER_RIGHT",CTA_BANNER_CENTER:"CTA_BANNER_CENTER",CTA_BANNER_BOTTOM:"CTA_BANNER_BOTTOM",CTA_PROMO_BAR_LEFT:"CTA_PROMO_BAR_LEFT",CTA_PROMO_BAR_RIGHT:"CTA_PROMO_BAR_RIGHT",CTA_STORY_LEFT:"CTA_STORY_LEFT",CTA_STORY_RIGHT:"CTA_STORY_RIGHT",CTA_FULLWIDTH_CENTER:"CTA_FULLWIDTH_CENTER",CTA_FULLWIDTH_LEFT:"CTA_FULLWIDTH_LEFT",CTA_FULLWIDTH_NO_IMAGE:"CTA_FULLWIDTH_NO_IMAGE",COVER_FULLSCREEN_CENTER:"COVER_FULLSCREEN_CENTER",COVER_FULLSCREEN_LEFT:"COVER_FULLSCREEN_LEFT",COVER_FULLSCREEN_CENTER_LEFT:"COVER_FULLSCREEN_CENTER_LEFT",COVER_FULLSCREEN_RIGHT:"COVER_FULLSCREEN_RIGHT",COVER_FULLSCREEN_BOTTOM:"COVER_FULLSCREEN_BOTTOM",COVER_FULLSCREEN_BOTTOM_RIGHT:"COVER_FULLSCREEN_BOTTOM_RIGHT",COVER_FULLSCREEN_BOTTOM_LEFT:"COVER_FULLSCREEN_BOTTOM_LEFT",COVER_FULLSCREEN_TOP:"COVER_FULLSCREEN_TOP",COVER_SIDEBAR_RIGHT:"COVER_SIDEBAR_RIGHT",COVER_SIDEBAR_LEFT:"COVER_SIDEBAR_LEFT",COVER_HALFSCREEN_LEFT:"COVER_HALFSCREEN_LEFT",COVER_HALFSCREEN_CENTER:"COVER_HALFSCREEN_CENTER",COVER_COLLAGE_BOTTOM:"COVER_COLLAGE_BOTTOM",COVER_COLLAGE_LEFT:"COVER_COLLAGE_LEFT",IMAGE_SUBTITLE_RIGHT:"IMAGE_SUBTITLE_RIGHT",IMAGE_TITLE_LEFT:"IMAGE_TITLE_LEFT",IMAGE_LEFT:"IMAGE_LEFT",IMAGE_RIGHT:"IMAGE_RIGHT",IMAGE_CENTER:"IMAGE_CENTER",IMAGE_SIDE_TITLE:"IMAGE_SIDE_TITLE",LOCATION_MAP_RIGHT:"LOCATION_MAP_RIGHT",LOCATION_MAP_LEFT:"LOCATION_MAP_LEFT",LOCATION_IMAGE_RIGHT:"LOCATION_IMAGE_RIGHT",LOCATION_IMAGE_LEFT:"LOCATION_IMAGE_LEFT",LOCATION_BACKGROUND_RIGHT:"LOCATION_BACKGROUND_RIGHT",LOCATION_BACKGROUND_LEFT:"LOCATION_BACKGROUND_LEFT",LOCATION_FULL:"LOCATION_FULL",LOCATION_SHORT:"LOCATION_SHORT",REVIEWS_MINIMAL:"REVIEWS_MINIMAL",REVIEWS_CARDS:"REVIEWS_CARDS",REVIEWS:"REVIEWS",REVIEWS_CLASSIC:"REVIEWS_CLASSIC",REVIEWS_FULLSCREEN_BG:"REVIEWS_FULLSCREEN_BG",REVIEWS_FULLSCREEN_SIDEBAR_LEFT:"REVIEWS_FULLSCREEN_SIDEBAR_LEFT",REVIEWS_FULLSCREEN_SIDEBAR_RIGHT:"REVIEWS_FULLSCREEN_SIDEBAR_RIGHT",REVIEWS_CARDS_PHOTO:"REVIEWS_CARDS_PHOTO",REVIEWS_PHOTO_SPEECH_RIGHT:"REVIEWS_PHOTO_SPEECH_RIGHT",REVIEWS_PHOTO_SPEECH_LEFT:"REVIEWS_PHOTO_SPEECH_LEFT",REVIEWS_SOCIAL_FEED:"REVIEWS_SOCIAL_FEED",REVIEWS_ADAPTIVE:"REVIEWS_ADAPTIVE",FEATURES_CLASSIC_CENTER:"FEATURES_CLASSIC_CENTER",FEATURES_CLASSIC_LEFT:"FEATURES_CLASSIC_LEFT",FEATURES_ACCORDION:"FEATURES_ACCORDION",FEATURES_MINIMAL:"FEATURES_MINIMAL",FEATURES_SMALL_ICONS:"FEATURES_SMALL_ICONS",FEATURES_CAROUSEL:"FEATURES_CAROUSEL",FEATURES_IMAGE_LEFT:"FEATURES_IMAGE_LEFT",FEATURES_IMAGE_RIGHT:"FEATURES_IMAGE_RIGHT",ANNOUNCEMENT_CENTER:"ANNOUNCEMENT_CENTER",SLIDER_FULLSCREEN_CENTER:"SLIDER_FULLSCREEN_CENTER",SLIDER_FULLSCREEN_LEFT:"SLIDER_FULLSCREEN_LEFT",SLIDER_BASIC:"SLIDER_BASIC",SLIDER_CAROUSEL:"SLIDER_CAROUSEL",SLIDER_CAROUSEL_PORTRAIT:"SLIDER_CAROUSEL_PORTRAIT",SLIDER_SPLIT:"SLIDER_SPLIT",SLIDER_SPLIT_REVERSE:"SLIDER_SPLIT_REVERSE"},dd=_e(Object.values(fd)),hd={HEADER:"header",COVER:"cover",ANNOUNCEMENT_BAR:"announcement_bar",SLIDER:"slider",SPECIAL_OFFER:"special_offer",CUSTOMER_REVIEW:"customer_review",COMPANY_INFO:"company_info",SHIPPING_PAYMENT:"shipping_payment",LOCATION:"location",STORE:"store",FOOTER:"footer",VIDEO:"video",IMAGE_GALLERY:"image_gallery",CONTACT_INFO:"contact_info",CONTACTS_WIDGET_WHATSAPP:"contacts_widget_whatsapp",CONTACTS_WIDGET_INSTAGRAM:"contacts_widget_instagram",CONTACTS_WIDGET_FACEBOOK:"contacts_widget_facebook",CONTACTS_WIDGET_PHONE:"contacts_widget_phone"},md={COVER:"COVER",ANNOUNCEMENT:"ANNOUNCEMENT",STORE:"STORE",SLIDER:"SLIDER",VIDEO:"VIDEO",SPECIAL_OFFER:"SPECIAL_OFFER",CUSTOMER_REVIEW:"CUSTOMER_REVIEW",COMPANY_INFO:"COMPANY_INFO",SHIPPING_PAYMENT:"SHIPPING_PAYMENT",LOCATION:"LOCATION",COLLECTIONS:"COLLECTIONS",BRANDS:"BRANDS",CONTACT_INFO:"CONTACT_INFO"},gd=_e(Object.values(md)),vt={REQUIRED_HEADER_ID:()=>'Header section must have id "header" when type is "default"',REQUIRED_CUSTOM_HEADER:(...e)=>`Custom header section with id "${e[0]}" must exist in headers directory`,REQUIRED_CUSTOM_HEADER_TYPE:(...e)=>`Custom header section with id "${e[0]}" must be of type "HEADER"`,REQUIRED_FOOTER_ID:()=>'Footer section must have id "footer" when type is "default"',REQUIRED_CUSTOM_FOOTER:(...e)=>`Custom footer section with id "${e[0]}" must exist in footers directory`,REQUIRED_CUSTOM_FOOTER_TYPE:(...e)=>`Custom footer section with id "${e[0]}" must be of type "FOOTER"`,REQUIRED_PAGE_SECTION:(...e)=>`Custom section with id "${e[0]}" must exist in sections directory`,REQUIRED_PAGE_SECTION_TYPE:()=>'Section "header" or "footer" is not allowed among page sections',SHOWCASE_ID_NOT_FOUND:(...e)=>`Showcase with id "${e[0]}" must exist in section's showcase directory`,DUPLICATE_SHOWCASE_ID:(...e)=>`Showcase id "${e[0]}" must be unique within section showcases`,SHOWCASE_OVERRIDE_CONTENT:(...e)=>`Content editor "${e[0]}" in showcase_overrides must exist in section's content configuration file`,SHOWCASE_OVERRIDE_DESIGN:(...e)=>`Design editor "${e[0]}" in showcase_overrides must exist in section's design configuration file`,SHOWCASE_OVERRIDE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase_overrides must exist in section's layout configuration file`,SHOWCASE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase must exist in section's layout configuration file`,INVALID_SHOWCASE_CONTENT_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in content.ts`,SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but content.ts has type "${e[2]}"`,INVALID_SHOWCASE_DESIGN_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in design.ts`,SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but design.ts has type "${e[2]}"`,INVALID_DECK_CARD_SETTING:(...e)=>`Setting "${e[0]}" is not defined in content.ts defaultCardContent.settings`,DECK_SETTINGS_REQUIRED:()=>"settings must have at least one property",INVALID_SELECTBOX_OPTION:(...e)=>`Option value "${e[0]}" for element "${e[1]}" is not defined in content.ts options`,REQUIRED_STORE_LAYOUT:(...e)=>`Store section with id "${e[0]}" and page type "${e[1]}" must have a corresponding layout defined`,INVALID_STORE_SECTION_ID:(...e)=>`Store layout sectionId "${e[0]}" must be one of: ${e[1]}`,REQUIRED_SECTION_ASSET:(...e)=>`Asset size ${e[0]} exceeds threshold of ${e[1]}.`,REQUIRED_SERVER_SIZE:(...e)=>`Size of individual server file [${e[0]}] must not exceed threshold [${e[1]}].`,MISSING_IMAGE_ASSET:(...e)=>`Image ${e[0]} is missing from assets folder`,MANDATORY_SETTING_TYPE_MISMATCH:(...e)=>`Editor type "${e[0]}" for reserved key "${e[1]}" does not match the required type "${e[2]}".`,MANDATORY_SETTING_NAME_MISMATCH:(...e)=>`Editor key "${e[0]}" for overridden content type "${e[1]}" does not match the required key name "${e[2]}".`,DUPLICATED_MANDATORY_SETTING:(...e)=>`Editor type "${e[0]}" can only be used once.`,IMAGE_EDITOR_STATIC_MISMATCH:(...e)=>`Both "${e[0]}" content and design editor need to have same value for attribute static`,DUPLICATE_DESIGN_EDITOR_NAME:()=>"Non-unique design editor name detected",COLOR_REQUIRED_GRADIENT:()=>"color is required when overlay is GRADIENT",COLOR_MUST_BE_ARRAY_GRADIENT:()=>"color must be an array when overlay is GRADIENT",COLOR_ARRAY_LENGTH_GRADIENT:()=>"color array must have exactly 2 items when overlay is GRADIENT",COLOR_REQUIRED_COLOR:()=>"color is required when overlay is COLOR",COLOR_MUST_BE_SINGLE_COLOR:()=>"color must be a single value when overlay is COLOR",COLOR_MUST_BE_UNDEFINED_NONE:()=>"color must be undefined when overlay is NONE or not set",COLOR_REQUIRED_STYLE_GRADIENT:()=>"color is required when style is GRADIENT",COLOR_MUST_BE_ARRAY_STYLE_GRADIENT:()=>"color must be an array when style is GRADIENT",COLOR_ARRAY_LENGTH_STYLE_GRADIENT:()=>"color array must have exactly 2 items when style is GRADIENT",COLOR_REQUIRED_STYLE_COLOR:()=>"color is required when style is COLOR",COLOR_MUST_BE_SINGLE_STYLE_COLOR:()=>"color must be a single value when style is COLOR",BUTTON_LINK_REQUIRED:()=>"link is required when buttonType is HYPER_LINK",BUTTON_CATEGORY_ID_REQUIRED:()=>"categoryId is required when buttonType is GO_TO_CATEGORY or GO_TO_CATEGORY_LINK",BUTTON_EMAIL_REQUIRED:()=>"email is required when buttonType is MAIL_LINK",BUTTON_PHONE_REQUIRED:()=>"phone is required when buttonType is TEL_LINK",BUTTON_TILE_ID_REQUIRED:(...e)=>`${e[0]} is required when buttonType is SCROLL_TO_TILE`,BUTTON_PAGE_ID_REQUIRED:()=>"pageIdForNavigate is required when type is GO_TO_PAGE",TEMPLATE_PAGE_SECTIONS_REQUIRED:()=>"sections must contain at least one section",TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have exactly one section`,TEMPLATE_PAGE_STORE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have a section of type "store"`,TEMPLATE_PAGE_NO_STORE_SECTIONS:(...e)=>`Page type "${e[0]}" cannot contain store sections`,TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED:()=>'Page type "CUSTOM" must have a metadata property',TEMPLATE_PAGE_METADATA_NOT_ALLOWED:(...e)=>`Page type "${e[0]}" must not have a metadata property`,NON_NEGATIVE_INTEGER:()=>"must be a non-negative integer",INTEGER_RANGE:(...e)=>`must be between ${e[0]} and ${e[1]}`,VALID_HEX_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA)",VALID_LANGUAGE_CODE:()=>"must be a valid language code (e.g., en, nl, fr, en_US, en_GB, zh_Hans)",VALID_URL:()=>"must be a valid URL",VALID_EMAIL:()=>"must be a valid email address",ACCORDION_ITEM_POSITION_FIELD_REQUIRED:(...e)=>`Item "${e[0]}" must have positionFieldName when sortable is true`,ACCORDION_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor`,ACCORDION_SHOWCASE_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor override`,ACCORDION_DUPLICATE_POSITION_FIELD_NAME:()=>"positionFieldName must be unique across accordion items when sortable is true",REQUIRED_COLLECTION_NAME:()=>"Collection must have a name in metadata"},Ed=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,_d=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,St=(e,t)=>{const n=vt.INTEGER_RANGE(e.toString(),t.toString());return Ve().min(e,{message:n}).max(t,{message:n})},Rr=O({path:A(),size:vn().nonnegative()}).strict(),js=O({size:vn().nonnegative()}).strict(),z=A().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),yd=O({r:St(0,255),g:St(0,255),b:St(0,255),a:St(0,1)}).strict(),Or=A().regex(Ed,{message:vt.VALID_HEX_COLOR()}),Ue=xt([Or,_e(["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"])]),Fs=_e(["global.textSize.title","global.textSize.subtitle","global.textSize.body"]),Qt=_e(["catalog","category","product"]),wn=A().refine(e=>e.startsWith("#")||$s().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),qt=O({url:A(),width:Ve().min(0,{message:vt.NON_NEGATIVE_INTEGER()}).optional(),height:Ve().min(0,{message:vt.NON_NEGATIVE_INTEGER()}).optional()}).strict(),Sd=O({homogeneity:J().optional(),color:yd.optional()}).strict(),Td=O({ORIGINAL:qt.optional(),WEBP_LOW_RES:qt.optional(),WEBP_HI_2X_RES:qt.optional(),MOBILE_WEBP_LOW_RES:qt.optional(),MOBILE_WEBP_HI_RES:qt.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),In=O({set:Td,borderInfo:Sd.optional()}).strict(),vr=O({type:P(V.IMAGE),imageData:In}).strict(),Gs=O({type:P(V.IMAGE),label:z,static:J().optional(),defaults:vr.optional()}).strict(),Rd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Cr(e){return e===Ot.PRODUCT||e===Ot.CATALOG||e===Ot.CATEGORY}function Hs(e,t,n){if(!e)return;const r=Ya({path:"$..set..url",json:e,resultType:"all"}),o=/^https?:\/\//;r.forEach(i=>{const s=i.value;if(!o.test(s)&&!t.includes(s)){const a=i.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",s)}})}function Bs(e,t,n){e===yt.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Zs(e,t,n){(e===yt.GO_TO_CATEGORY||e===yt.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function Vs(e,t,n){e===yt.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Ws(e,t,n){e===yt.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Ks(e,t,n,r){if(e===yt.SCROLL_TO_TILE&&!(t??n)){const o=t?"tileId":"tileIdForScroll";r.at(o).addIssue("BUTTON_TILE_ID_REQUIRED",o)}}function Od(e,t,n){e===yt.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const vd="custom";function Ie(e,t=[]){const n=o=>Array.isArray(o)?o:[o],r=n(t);return{raw:e,addIssue(o,...i){e.addIssue({code:vd,message:vt[o](...i),path:r,params:{errorMessageKey:o}})},at(o){const i=r.concat(n(o));return Ie(e,i)}}}const wr=O({type:P(V.BUTTON),title:z,buttonType:ed,link:A().optional(),linkTarget:A().optional(),email:A().regex(Rd,{message:vt.VALID_EMAIL()}).optional(),phone:A().optional(),tileId:A().optional(),categoryId:vn().optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Bs(e.buttonType,e.link,n),Zs(e.buttonType,e.categoryId,n),Vs(e.buttonType,e.email,n),Ws(e.buttonType,e.phone,n),Ks(e.buttonType,e.tileId,void 0,n)}),Ys=O({type:P(V.BUTTON),label:z,defaults:wr.optional()}).strict(),Ir=O({type:P(V.CATEGORY_SELECTOR)}).strict(),Xs=O({type:P(V.CATEGORY_SELECTOR),label:z,maxCategories:St(1,32),defaults:Ir.optional()}).strict(),Ar=O({type:P(V.DIVIDER)}).strict(),Qs=O({type:P(V.DIVIDER),label:z,defaults:Ar.optional()}).strict(),Cd=O({label:z,link:wn}).strict(),wd=O({title:z.optional(),link:wn.optional()}).strict(),br=O({type:P(V.INFO),text:z.optional(),button:wd.optional()}).strict(),qs=O({type:P(V.INFO),label:z,description:z,button:Cd.optional(),defaults:br.optional()}).strict(),$r=O({type:P(V.INPUTBOX),text:z}).strict(),Js=O({type:P(V.INPUTBOX),label:z,placeholder:z,defaults:$r.optional()}).strict(),Nr=O({type:P(V.PRODUCT_SELECTOR)}).strict(),ei=O({type:P(V.PRODUCT_SELECTOR),label:z,maxProducts:St(1,32),defaults:Nr.optional()}).strict(),Lr=O({type:P(V.SELECTBOX),value:A()}).strict(),Id=O({value:A().min(1,{message:"value must not be empty"}),label:z}).strict(),ti=O({type:P(V.SELECTBOX),label:z,placeholder:z,description:z,options:oe(Id).min(1,{message:"must have at least one option"}),defaults:Lr.optional()}).strict(),Dr=O({type:P(V.TEXTAREA),text:z}).strict(),ni=O({type:P(V.TEXTAREA),label:z,placeholder:z,defaults:Dr.optional()}).strict(),kr=O({type:P(V.TOGGLE),enabled:J()}).strict(),ri=O({type:P(V.TOGGLE),label:z,description:z,defaults:kr.optional()}).strict(),oi=O({type:P(V.DECK)}).strict(),Ad=We("type",[$r,Dr,wr,vr,kr,Lr,Ar,br,Nr,Ir]),bd=O({type:P(V.DECK),cards:oe(O({settings:De(A(),Ad).superRefine((e,t)=>{Object.keys(e).length<1&&Ie(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),si=[Js,ni,Ys,Gs,ri,ti,Qs,qs,Xs,ei],$d=O({type:P(V.DECK),label:z,addButtonLabel:z,maxCards:Ve().min(1,{message:"must be a positive integer"}),cards:O({defaultCardContent:O({label:z,settings:De(A(),We("type",[...si])).superRefine((e,t)=>{Object.keys(e).length<1&&Ie(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:oi.optional()}).strict(),Nd=We("type",[...si,$d]),Ld=O({type:P(V.DECK),label:z,addButtonLabel:z,maxCards:Ve().min(1,{message:"must be a positive integer"}),cards:O({defaultCardContent:O({label:z,settings:De(A(),Nd).superRefine((e,t)=>{Object.keys(e).length<1&&Ie(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:oi.optional()}).strict(),ii=O({type:P(V.LOGO),logoType:Jf.optional(),text:z.optional(),imageData:In.optional()}).strict(),Dd=O({type:P(V.LOGO),label:z.optional(),defaults:ii.optional()}).strict(),ai=O({id:A(),title:A().optional(),type:A().optional(),link:A().optional(),email:A().optional(),phone:A().optional(),tileIdForScroll:A().optional(),pageIdForNavigate:A().optional(),showStoreCategories:J().optional(),isSubmenuOpened:J().optional(),categoryId:vn().optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Bs(e.type,e.link,n),Zs(e.type,e.categoryId,n),Vs(e.type,e.email,n),Ws(e.type,e.phone,n),Ks(e.type,void 0,e.tileIdForScroll,n),Od(e.type,e.pageIdForNavigate,n)}),ci=O({type:P(V.MENU),items:oe(ai).optional()}).strict(),kd=O({type:P(V.MENU),label:z.optional(),defaults:ci.optional()}).strict(),ui=O({type:P(V.NAVIGATION_MENU),items:oe(ai).optional()}).strict(),Pd=O({type:P(V.NAVIGATION_MENU),defaults:ui.optional()}).strict(),An=O({type:P(Q.BACKGROUND),style:cd.optional(),color:xt([Ue,oe(Ue)]).optional()}).strict().superRefine((e,t)=>{const n=Ie(t).at("color");e.style===Tr.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_STYLE_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_STYLE_GRADIENT"):e.style===Tr.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),xd=O({type:P(Q.BACKGROUND),fieldName:A(),defaults:An.optional()}).strict(),li=O({type:P(Q.BACKGROUND),label:z,colors:oe(Ue).optional(),enableAlphaColor:J().optional(),enableAutoColor:J().optional(),defaults:An.optional()}).strict(),bn=O({type:P(Q.BUTTON),appearance:rd.optional(),size:sd.optional(),shape:ad.optional(),font:A().optional(),color:Ue.optional(),visible:J().optional()}).strict(),zd=O({type:P(Q.BUTTON),fieldName:A(),defaults:bn.optional()}).strict(),pi=O({type:P(Q.BUTTON),label:z,colors:oe(Ue).optional(),enableAutoColor:J().optional(),enableAlphaColor:J().optional(),hideVisibleToggle:J().optional(),hideSize:J().optional(),defaults:bn.optional()}).strict(),$n=O({type:P(Q.COLOR_PICKER),color:Ue.optional()}).strict(),Md=O({type:P(Q.COLOR_PICKER),fieldName:A(),defaults:$n.optional()}).strict(),fi=O({type:P(Q.COLOR_PICKER),label:z,description:z.optional(),colors:oe(Ue).optional(),enableAlphaColor:J().optional(),enableAutoColor:J().optional(),defaults:$n.optional()}).strict(),Nn=O({type:P(Q.DIVIDER)}).strict(),Ud=O({type:P(Q.DIVIDER),fieldName:A(),defaults:Nn.optional()}).strict(),di=O({type:P(Q.DIVIDER),label:z,defaults:Nn.optional()}).strict(),Ln=O({type:P(Q.IMAGE),overlay:td.optional(),color:xt([Ue,oe(Ue)]).optional(),visible:J().optional()}).strict().superRefine((e,t)=>{const n=Ie(t).at("color");e.overlay===Cn.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_GRADIENT"):e.overlay===Cn.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===Cn.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),jd=O({type:P(Q.IMAGE),fieldName:A(),defaults:Ln.optional()}).strict(),hi=O({type:P(Q.IMAGE),label:z,static:J().optional(),colors:oe(Or).optional(),enableAlphaColor:J().optional(),hideVisibleToggle:J().optional(),defaults:Ln.optional()}).strict(),Fd=O({label:z,link:wn}).strict(),Gd=O({label:z.optional(),link:wn.optional()}).strict(),Dn=O({type:P(Q.INFO),description:z.optional(),button:Gd.optional()}).strict(),Hd=O({type:P(Q.INFO),fieldName:A(),defaults:Dn.optional()}).strict(),mi=O({type:P(Q.INFO),label:z,description:z,button:Fd.optional(),defaults:Dn.optional()}).strict(),Bd=O({visible:J(),width:St(1,49).optional(),color:Ue.optional()}).strict(),kn=O({type:P(Q.LOGO),font:A().optional(),size:xt([Ve().min(1,{message:"must be at least 1"}),Fs]).optional(),bold:J().optional(),italic:J().optional(),color:Ue.optional(),visible:J().optional(),spacing:St(1,9).optional(),frame:Bd.optional(),capitalization:_e(["none","all","small"]).optional()}).strict(),Zd=O({type:P(Q.LOGO),fieldName:A(),defaults:kn.optional()}).strict(),gi=O({type:P(Q.LOGO),label:z,colors:oe(Ue).optional(),sizes:oe(Ve().min(1,{message:"must be at least 1"})).optional(),defaults:kn.optional()}).strict(),Vd=O({value:A().optional(),label:z.optional()}).strict(),Pn=O({type:P(Q.SELECTBOX),value:A().optional()}).strict(),Wd=O({type:P(Q.SELECTBOX),fieldName:A(),defaults:Pn.optional()}).strict(),Ei=O({type:P(Q.SELECTBOX),label:z,description:z.optional(),options:oe(Vd).optional(),defaults:Pn.optional()}).strict(),xn=O({type:P(Q.TEXT),font:A().optional(),size:xt([Ve().min(1,{message:"must be at least 1"}),Fs]).optional(),bold:J().optional(),italic:J().optional(),color:Ue.optional(),visible:J().optional()}).strict(),Kd=O({type:P(Q.TEXT),fieldName:A(),defaults:xn.optional()}).strict(),_i=O({type:P(Q.TEXT),label:z,colors:oe(Or).optional(),sizes:oe(Ve().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:J().optional(),enableAutoColor:J().optional(),hideVisibleToggle:J().optional(),hideSize:J().optional(),defaults:xn.optional()}).strict(),zn=O({type:P(Q.TOGGLE),enabled:J().optional()}).strict(),Yd=O({type:P(Q.TOGGLE),fieldName:A(),defaults:zn.optional()}).strict(),yi=O({type:P(Q.TOGGLE),label:z,defaults:zn.optional()}).strict();function Xd(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function Qd(e,t){for(const[n,r]of Object.entries(e))Object.keys(r.editors).length===0&&t.at(["items",n,"editors"]).addIssue("ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED",n)}function qd(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Jd(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function eh(e,t){for(const[n,r]of Object.entries(e))r.positionFieldName||t.at(["items",n,"positionFieldName"]).addIssue("ACCORDION_ITEM_POSITION_FIELD_REQUIRED",n)}function th(e,t){const n=Object.values(e).map(r=>r.positionFieldName).filter(Boolean);new Set(n).size!==n.length&&t.at("items").addIssue("ACCORDION_DUPLICATE_POSITION_FIELD_NAME")}const Si=O({type:P(Q.ACCORDION)}).strict(),nh=We("type",[xn,bn,Ln,zn,Pn,An,$n,kn,Nn,Dn]),rh=O({editors:De(A(),nh)}).strict(),oh=O({type:P(Q.ACCORDION),items:De(A(),rh)}).strict().superRefine((e,t)=>{const n=Ie(t);Xd(e.items,n),Qd(e.items,n)}),sh=O({type:P(Q.ACCORDION),fieldName:A(),defaults:Si.optional()}).strict(),ih=We("type",[_i,pi,hi,yi,Ei,li,fi,gi,di,mi]),ah=O({label:z,positionFieldName:A().optional(),editors:De(A(),ih)}).strict().superRefine((e,t)=>{qd(e.editors,e.label,Ie(t))}),ch=O({type:P(Q.ACCORDION),sortable:J().optional(),items:De(A(),ah),defaults:Si.optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Jd(e.items,n),e.sortable===!0&&(eh(e.items,n),th(e.items,n))}),Ti=We("type",[$r,Dr,wr,vr,kr,Lr,ci,ui,ii,Ar,br,bd,Nr,Ir]),Ri=We("type",[xn,bn,Ln,zn,Pn,An,$n,kn,Nn,oh,Dn]),uh=O({showcaseId:A(),blockName:A(),previewImage:In,content:De(A(),Ti),design:De(A(),Ri),layoutId:A().optional()}).strict(),lh=O({blockName:A(),content:De(A(),Ti).optional(),design:De(A(),Ri).optional(),layoutId:A().optional()}).strict();function ph(e,t){Cr(e.type)&&(e.sections.length!==1?t.at("sections").addIssue("TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED",e.type):e.sections[0]?.type!=="store"&&t.at(["sections",0,"type"]).addIssue("TEMPLATE_PAGE_STORE_SECTION_REQUIRED",e.type))}function fh(e,t){Cr(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,r)=>{Cr(e.type)||n.type==="store"&&t.at(["sections",r,"type"]).addIssue("TEMPLATE_PAGE_NO_STORE_SECTIONS",e.type),n.type==="default"&&n.id&&(n.id==="header"||n.id==="footer")&&t.at(["sections",r,"id"]).addIssue("REQUIRED_PAGE_SECTION_TYPE")})}function dh(e,t){e.type==="CUSTOM"?e.metadata||t.at("metadata").addIssue("TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED"):e.metadata!==void 0&&t.at("metadata").addIssue("TEMPLATE_PAGE_METADATA_NOT_ALLOWED",e.type)}const hh=new RegExp(`^(${Object.values(hd).join("|")})(_\\d{3})?$`),mh=A().regex(hh,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),gh=A().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),Oi=O({type:P("default"),id:mh,showcase_id:gh.optional()}).strict(),Pr=O({type:P("custom"),id:A(),showcase_id:A().optional(),showcase_overrides:lh.optional(),category:gd.optional()}).strict(),Eh=O({type:P("store"),id:A().optional()}).strict(),_h=We("type",[Oi,Pr,Eh]),yh=O({title:A()}).strict(),Sh=O({metadata:yh.optional(),sections:oe(_h)}).strict(),Th=Sh.safeExtend({type:ud,id:A().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=Ie(t);fh(e,n),ph(e,n),dh(e,n)}),vi=O({name:A().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:A().min(2,{message:"description must be at least 2 characters"}).max(150,{message:"description must be at most 150 characters"}),preview_url:$s({message:"preview_url must be a valid URL"}).regex(/^(https?):\/\/([^.]+?\.)?(company\.site|ecwid\.qa)($|\/[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=]*)?$/,"preview_url must match pattern: (https?)://([^.]+?\\.)?(company\\.site|ecwid\\.qa)(...)?").optional(),cover_image:In,categories:oe(pd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),Rh=Oi.extend({id:A()}),Ci=We("type",[Rh,Pr]),Oh=O({metadata:vi,header:Ci,footer:Ci}).strict(),vh=O({id:A().min(1,{message:"id is required"}),assets:Rr.array().optional(),configuration:Oh,pages:oe(Th)}).strict(),Mn=2097152,Un=512e3;function pt(e,t=2){if(!+e)return"0 Bytes";const n=1024,r=t<0?0:t,o=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**i).toFixed(r))} ${o[i]}`}const Ch={menu:{type:V.NAVIGATION_MENU},logo:{type:V.LOGO}},wh={logo:{type:"LOGO",label:"$label.logo.label",colors:["#FFFFFF66","#0000004D","#00000099","#64C7FF66","#F9947266","#C794CD66","#FFD17466"],sizes:[18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60],defaults:{type:"LOGO",font:"global.fontFamily.body",size:40,bold:!0,italic:!1,color:"#313131",visible:!0,spacing:2,capitalization:"all",frame:{visible:!0,width:3,color:"#313131"}}}};function wi(e){switch(e){case zt.HEADER:return Ch;default:return{}}}function Ii(e){switch(e){case zt.HEADER:return wh;default:return{}}}function Ai({validationType:e,sectionType:t}){switch(e){case Xt.CONTENT:return wi(t);case Xt.DESIGN:return Ii(t);default:return{}}}const Ih=Pr.extend({id:A().min(1,{message:"section id is required"})}),Ah=O({metadata:vi,sections:oe(Ih).min(1,{message:"sections must contain at least one section"}).max(20,{message:"sections must contain at most 20 sections"})}).strict().superRefine((e,t)=>{e.metadata.name.trim().length===0&&Ie(t).at(["collection","metadata","name"]).addIssue("REQUIRED_COLLECTION_NAME")}),bh=O({id:A().min(1,{message:"id is required"}),descriptor:Ah}).strict(),$h=We("type",[Js,ni,Ys,Gs,ri,ti,Ld,kd,Pd,Dd,Qs,qs,ei,Xs]),xr=De(A(),$h),Nh=We("type",[_i,pi,hi,yi,Ei,li,fi,gi,di,ch,mi]),zr=De(A(),Nh),Lh=We("type",[Kd,zd,jd,Yd,Wd,xd,Md,Zd,Ud,Hd,sh]),Dh=O({layoutId:A(),layoutIcon:dd.optional(),selectedContentSettings:oe(A()),selectedDesignSettings:oe(Lh)}).strict(),kh=A().regex(_d,vt.VALID_LANGUAGE_CODE()),jn=De(kh,De(z,A()));function bi(e,t,n){if(!e||Object.keys(t).length===0)return;const r=Object.entries(t),o=r.map(([,{type:s}])=>s),i=Object.values(e).map(({type:s})=>s);Object.entries(e).forEach(([s,a])=>{const c=t[s];c&&"type"in c&&a.type!==c.type&&n.at(s).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,s,c.type)}),Object.entries(e).forEach(([s,a])=>{const c=r.find(([,{type:u}])=>u===a.type)?.[0];c&&s!==c&&n.at(s).addIssue("MANDATORY_SETTING_NAME_MISMATCH",s,a.type,c)}),new Set(i.filter(s=>o.includes(s))).forEach(s=>{if(i.filter(a=>a===s).length>1){const a=r.findLast(([,{type:c}])=>c===s)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",s)}})}function $i(e,t,n){Hs(e,t,n)}function Ph(e,t,n){if(e.type!==V.DECK||t.type!==V.DECK)return;const r=t.cards?.defaultCardContent?.settings,o=e.cards;if(!r||!Array.isArray(o))return;const i=new Set(Object.keys(r));o.forEach((s,a)=>{s.settings&&Object.keys(s.settings).forEach(c=>{i.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function xh(e,t,n){e.content&&Object.entries(e.content).forEach(([r,o])=>{const i=n.at(["content",r]),s=t[r];if(!s){i.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",r);return}if(o.type!==s.type){i.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",r,o.type,s.type);return}if(o.type===V.SELECTBOX&&s.type===V.SELECTBOX){const a=s,c=o;a.options&&c.value!==void 0&&(new Set(a.options.map(u=>u.value)).has(c.value)||i.addIssue("INVALID_SELECTBOX_OPTION",c.value,r))}o.type===V.DECK&&Ph(o,s,i)})}function zh(e,t,n){e.design&&Object.entries(e.design).forEach(([r,o])=>{const i=n.at(["design",r]),s=t[r];if(!s){i.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",r);return}o.type!==s.type&&i.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",r,o.type,s.type)})}function Mh(e,t){Object.entries(e).flatMap(([n,r])=>{switch(r.type){case Q.ACCORDION:return Object.entries(r.items).flatMap(([o,i])=>Object.keys(i.editors).map(s=>({name:s,path:[n,"items",o,"editors",s]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},r,o)=>o.findIndex(i=>i.name===n)<r).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function Uh(e,t,n){e.layoutId&&((t||[]).some(r=>r.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function jh(e,t){const n=new Set;e.forEach((r,o)=>{if(n.has(r.showcaseId)){t.at([o,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",r.showcaseId);return}n.add(r.showcaseId)})}function Ni(e,t,n){for(const[r,o]of Object.entries(e)){const i=o;if(i.type===V.IMAGE){const s=t[r];if(s?.type===Q.IMAGE){const a=i.static??!1,c=s.static??!1;a!==c&&n.at(r).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",r)}}else if(i.type===V.DECK){const s=i;s.cards?.defaultCardContent?.settings&&Ni(s.cards.defaultCardContent.settings,t,n.at([r,"cards","defaultCardContent","settings"]))}}}function Fh(e,t,n){t>Mn&&n.at(le.basename(e)).addIssue("REQUIRED_SECTION_ASSET",pt(t),pt(Mn))}function Gh(e,t){e>Un&&t.addIssue("REQUIRED_SERVER_SIZE",pt(e),pt(Un))}const Hh=O({id:A(),type:Qf,name:A(),content:xr,design:zr,layout:oe(Dh).optional(),showcase:oe(uh),translationsSettings:jn.optional(),translationsShowcases:jn.optional(),assets:Rr.array().optional(),server:js,previewCount:Ve().optional()}).strict().superRefine((e,t)=>{const n=Ie(t),r=Ai({validationType:Xt.CONTENT,sectionType:e.type}),o=Ai({validationType:Xt.DESIGN,sectionType:e.type});bi(e.content,r,n.at("content")),bi(e.design,o,n.at("design")),Ni(e.content,e.design,n.at("content")),Mh(e.design,n.at("design")),e.assets&&e.assets.forEach(s=>{Fh(s.path,s.size,n.at("assets"))}),Gh(e.server.size,n.at("server"));const i=e.assets?.map(s=>s.path)??[];$i(e.content,i,n.at("content")),jh(e.showcase,n.at("showcase")),e.showcase.forEach((s,a)=>{const c=n.at(["showcase",a]);$i(s,i,c),xh(s,e.content,c),zh(s,e.design,c),Uh(s,e.layout,c)})}),Bh=O({translations:jn.optional()}).strict(),Zh=_e(["products","category","product"]),Vh=O({id:A(),sectionId:A(),assets:Rr.array().optional(),content:xr.optional(),design:zr.optional(),translationsSettings:jn.optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Qt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Qt.options.join(", ")),e.assets&&e.assets.forEach(r=>{r.size>Mn&&n.at(["assets",le.basename(r.path)]).addIssue("REQUIRED_SECTION_ASSET",pt(r.size),pt(Mn))})});O({id:A(),sectionId:Qt,pageId:Zh,content:xr.optional(),design:zr.optional()}).strict();const Wh=O({id:A(),sectionId:A(),layoutId:A(),server:js}).strict().superRefine((e,t)=>{const n=Ie(t);Qt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Qt.options.join(", ")),e.server.size>Un&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",pt(e.server.size),pt(Un))});function Kh(e,t,n){if(e){if(e.type==="default")e.id!=="header"&&n.at("id").addIssue("REQUIRED_HEADER_ID");else if(e.type==="custom"&&e.id){const r=t.find(o=>o.id===e.id);r?(r.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_HEADER",e.id)}}}function Yh(e,t,n){if(e){if(e.type==="default")e.id!=="footer"&&n.at("id").addIssue("REQUIRED_FOOTER_ID");else if(e.type==="custom"&&e.id){const r=t.find(o=>o.id===e.id);r?(r.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER",e.id)}}}function Xh(e,t,n){if(!e)return;const r=n.at(["showcase_overrides"]);["content","design"].forEach(i=>{const s=e[i];if(s){const a=t[i]||{};Object.keys(s).forEach(c=>{if(!(c in a)){const u=i==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";r.at([i,c]).addIssue(u,c)}})}}),e.layoutId&&((t.layout||[]).some(i=>i.layoutId===e.layoutId)||r.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const o=t.assets?.map(i=>i.path)??[];e.content&&Hs(e.content,o,r.at(["content"]))}function Li(e,t,n,r=!1){if(!e.id)return;const o=t.find(i=>i.id===e.id);if(!o){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}!r&&(o.type==="HEADER"||o.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),Xh(e.showcase_overrides,o,n),e.showcase_id&&((o.showcase||[]).some(i=>i.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function Qh(e,t,n,r){e.id&&(n.some(o=>o.sectionId===t.type.toLowerCase()&&o.id===e.id)||r.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const qh=O({version:A(),name:A(),shared:Bh.optional(),sections:oe(Hh),templates:oe(vh),layouts:oe(Vh),slots:oe(Wh),collections:oe(bh),compressionEnabled:J(),externalizationEnabled:J(),vueVersion:A(),openSource:J().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,r)=>{const o=Ie(t).at(["templates",r]);Kh(n.configuration.header,e.sections,o.at(["configuration","header"])),Yh(n.configuration.footer,e.sections,o.at(["configuration","footer"])),n.pages.forEach((i,s)=>{const a=o.at(["pages",s]);i.sections.forEach((c,u)=>{const f=a.at(["sections",u]);c.type==="custom"?Li(c,e.sections,f):c.type==="store"&&Qh(c,i,e.layouts,f)})})}),e.collections.forEach((n,r)=>{n.descriptor.sections.forEach((o,i)=>{const s=Ie(t).at(["collections",r,"sections",i]);Li(o,e.sections,s,!0)})})});lt({customError:Xf});const I={error:e=>console.log(Ga(e)),warn:e=>console.log(Fa(e)),info:e=>console.log(Qe(e))},Jh="dist",em="dist/shared",st="dist/sections",Mr="dist/headers",Ur="dist/footers",ft="dist/templates",Mt="layouts",Di="preview",je=`dist/${Mt}`,Jt="dist/collections",ki="dist/manifest.json",tm=[st,Mr,Ur,ft,je];function Fn(e){return!!e}function Ct(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const nm="Resource name can only contain alphanumeric characters, dashes, and underscores";function rm(e){if(typeof e=="string"||typeof e=="number"){const t=/^[a-zA-Z0-9_-]+$/.test(e.toString());if(t)return{isValid:t,errorMessage:null}}return{isValid:!1,errorMessage:nm}}function om(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function sm(e){return le.parse(e).name}function im(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Gn(){const e=await ar(j(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function am(e){return e.includes(`
|
|
40
|
-
`)}function
|
|
41
|
-
`).map((r
|
|
42
|
-
`)}function
|
|
43
|
-
`):e?.message??"Unknown error";if(!t||t.length===0)return
|
|
44
|
-
`:" ";return`${t}${o}${r}`}function jr(e,t){return Object.keys(e).reduce((n,r)=>{const o=e[r],i=t[r];return Ct(o)&&Ct(i)?n[r]=jr(o,i):n[r]=o,n},{...t})}function um({contentSettings:e,sectionType:t}){const n=wi(t);return jr(e,n)}function lm({designSettings:e,sectionType:t}){const n=Ii(t);return jr(e,n)}async function Je(e){return(await import(No(e).href+`?t=${Date.now()}`)).default}function Fr(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function et(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=qa(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Pi(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:Number(e)}}function pm(e){if(e!==void 0)return{...e,color:et(e.color)}}function en(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function fm(e){if(e!==void 0)switch(e){case ir.COLOR:return"solid";case ir.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(ir)}`)}}function dm({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:fm(e),solid:{color:et(n.at(0))},gradient:{fromColor:et(n.at(0)),toColor:et(n.at(1))}}}}function hm(e){if(e!==void 0)switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(Va)}`)}}function mm(e){if(e!==void 0)switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(Wa)}`)}}function gm(e){if(e!==void 0)switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys(Ka)}`)}}function Em(e){const t=hm(e.appearance),n=mm(e.size),r=gm(e.shape),o=Fr(e.font),i=et(e.color),s=e.visible;return en({appearance:t,size:n,style:r,font:o,color:i,visible:s})}function _m(e){const t=et(e.color);return en({color:t})}function ym(e){if(e!==void 0)switch(e){case fn.COLOR:return"solid";case fn.GRADIENT:return"gradient";case fn.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(fn)}`)}}function Sm(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:ym(e.overlay),solid:{color:et(n.at(0))},gradient:{fromColor:et(n.at(0)),toColor:et(n.at(1))}}}}function Tm(e){const t=Fr(e.font),n=et(e.color),r=Pi(e.size),o=e.bold,i=e.italic,s=e.spacing,a=e.capitalization;return{font:t,color:n,size:r,frame:pm(e.frame),bold:o,italic:i,spacing:s,capitalization:a}}function Rm(e){const t=e.value;return en({value:t})}function Om(e){const t=Fr(e.font),n=et(e.color),r=Pi(e.size),o=e.bold,i=e.italic;return en({font:t,color:n,size:r,bold:o,italic:i})}function vm(e){const t=e.enabled;return en({enabled:t})}function Gr(e,t){if(t.defaults===void 0)return;let n={};switch(e){case Me.TEXT:{n=Om(t.defaults);break}case Me.BUTTON:{n=Em(t.defaults);break}case Me.IMAGE:{n=Sm(t.defaults);break}case Me.BACKGROUND:{n=dm(t.defaults);break}case Me.COLOR_PICKER:{n=_m(t.defaults);break}case Me.LOGO:{n=Tm(t.defaults);break}case Me.SELECTBOX:{n=Rm(t.defaults);break}case Me.TOGGLE:{n=vm(t.defaults);break}case Me.DIVIDER:case Me.INFO:break;case Me.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function xi(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type;if(o===Me.ACCORDION){const s=Object.fromEntries(Object.entries(r.items).map(([a,c])=>[a,{...c,editors:xi(c.editors)}]));t[n]={...r,items:s};return}const i=Gr(o,r);i&&r.defaults?t[n]={...r,defaults:i}:t[n]=r}),t}function Cm(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...Gr(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Hr(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type;if(o===Me.ACCORDION){const s=Object.fromEntries(Object.entries(r.items).map(([a,c])=>[a,{...c,editors:Hr(c.editors)??c.editors}]));t[n]={type:r.type,items:s};return}const i=Gr(o,{defaults:r});i!==void 0?t[n]={...r,...i,type:r.type}:t[n]=r}),t}function wm(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Im(e){const t={};for(const n in e){const r=e[n];for(const o in r){const i=t[o],s=r[o];if(i===void 0){const a={};a[n]=s,t[o]=a}else i[n]=s}}return t}function Am(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function Ut(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return Am(e)?e:e.map(o=>Ut(o,t));const n=e,r={};for(const o in n){const i=n[o];typeof i=="string"&&i.startsWith("$")?r[o]=wm(t,i):typeof i=="object"&&i!==null?r[o]=Ut(i,t):r[o]=i}return r}async function tn(e){return e?Im(e):{}}async function bm(e,t=st){const n=j(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await Je(n)}async function Hn(e,t=st){const n=j(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await Je(n)}async function $m(e,t){const n=j(process.cwd(),`${je}/${t}/${e}/js/settings/translations.mjs`);if($e(n))return await Je(n)}async function Br(e,t,n){const r=n?um({contentSettings:e,sectionType:n}):e;return Ut(r,t)}async function Nm(e,t=st){try{const n=j(Oe.cwd(),`${t}/${e}/js/settings/content.mjs`),r=await Je(n);return bt(r)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Zr(e,t,n){const r=n?lm({designSettings:e,sectionType:n}):e,o=xi(r);return Ut(o,t)}async function Lm(e,t=st){try{const n=j(Oe.cwd(),`${t}/${e}/js/settings/design.mjs`),r=await Je(n);return bt(r)}catch(n){const r=n;throw new Error(`Design settings is invalid or undefined. Error ${r.stack}`)}}async function Dm(e,t){return Promise.all(e.map(async n=>{const r=n.design?Hr(n.design):void 0,o={...n,design:r??n.design};return Ut(o,t)}))}async function km(e,t=st){try{const n=await W("*.mjs",{cwd:j(Oe.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async r=>{const o=j(Oe.cwd(),`${t}/${e}/js/showcases/${r}`);return await Je(o)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Pm(e){return e?.map(t=>({...t,selectedDesignSettings:Cm(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function xm(e,t=st){try{const n=j(Oe.cwd(),`${t}/${e}/js/settings/layout.mjs`);return $e(n)?await Je(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function zm(e){let t={};const n=j(Oe.cwd(),`${Di}/shared/analytics.json`);if(!$e(n))return 0;try{const r=nr(n,"utf-8");t=JSON.parse(r)}catch(r){console.warn("Error processing analytics.json file",r)}return t[e]||0}const jt={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Vr="https://blockbuster.ecwid.com",Mm="/api/v1/custom-apps/resources/sections/upload",Um="/api/v1/custom-apps/resources/templates/upload",jm="/api/v1/custom-apps/manifests/sections",Fm="/api/v1/custom-apps/manifests/templates",Gm=5,Hm=3,Bm=[ee.Server,ee.Client,ee.ClientChunks,ee.ClientAsset,ee.Asset],Zm=[ee.LayoutClient,ee.LayoutAsset],Vm=[ee.SlotServer,ee.SlotClient,ee.SlotClientChunks,ee.SlotClientAsset],Wm=[ee.Dependency,ee.TemplateAsset,ee.SourceCode,ee.CollectionAsset],Ft={DEFAULT:"Error while deploying:",ASSET_FILES_UPLOAD:"Error while uploading asset files:",MANIFEST_DEPLOYMENT:"Error while deploying manifest file:",DEPRECATED_VERSION_DEPLOYMENT:"You are using a non-supported version of crane. Please update to the latest crane version to continue.",INCORRECT_DISTRIBUTION_FOLDER:e=>`Distribution folder [${e}] is not found or has incorrect structure, please execute the build command first.`},zi={catalog:"products",category:"category",product:"product"},Mi=e=>zi[e],Ui=e=>e in zi;function Km(e){return e.replace(/\\/g,"/")}function Ym(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Bn(e){return Ym(Km(e))}function Xm(e){const t=Bn(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t;if(!Ui(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const o=Mi(n);return{id:r,sectionId:n,pageId:o}}async function Qm(e){return Promise.all(e.map(async t=>{const n=t.sectionId,r=Mi(n),o=await tn(t.translationsSettings),i=await Br(t.content??{},o),s=await Zr(t.design??{},o);return{id:t.id,sectionId:n,pageId:r,contentEditors:i,designEditors:s}}))}function Gt(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${je}/${e}/${t}/${n.join("/")}`}const nn=(e=ut.SECTION)=>we[e].dist,rn={[ee.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/server/`},[ee.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/client/`},[ee.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[ee.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/client/assets/`},[ee.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/assets/`},[ee.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${ft}/assets/`},[ee.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[ee.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[ee.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>Gt(e,t,"")},[ee.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Gt(e,t,"assets/")},[ee.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/server/")},[ee.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/client/")},[ee.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/client/chunks/")},[ee.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/client/assets/")},[ee.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Jt}/assets/`}};function qm(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function Wr(){const e=j(dn.cwd(),"package.json"),t=await ar(e),n=JSON.parse(t.toString());if(qm(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const Jm={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function eg(e,t){const n=Jm[e];return n?n(t):t.id}const tg=new Set(["content","design"]);function Zn(e,t,n=0,r=[]){if(n>=t.length)return r;const o=t[n],i=t[n+1];if(typeof o=="string"&&typeof i=="number"&&Ct(e)){const s=e[o],a=Array.isArray(s)?s[i]:void 0;if(Ct(a)){const c=eg(o,a);return r.push(`${o}[${c||i}]`),Zn(a,t,n+2,r)}}if(typeof o=="string"&&typeof i=="string"&&tg.has(o)){r.push(`${o}[${i}]`);const s=Ct(e)&&!Array.isArray(e)?e[o]:void 0,a=Ct(s)&&!Array.isArray(s)?s[i]:void 0;return Zn(a,t,n+2,r)}return r.push(o),Zn(Ct(e)?e[o]:void 0,t,n+1,r)}function ng(e){const t=e.errors.map(r=>Zn(e.manifest,r.path).join(".")),n={path:Math.max(...t.map(r=>r.length),0),message:Math.max(...e.errors.map(r=>r.message.length),0)};e.errors.map((r,o)=>{const i=r.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[o].padEnd(n.path," ")} | ${r.message.padEnd(n.message," ")} | ${i}`}).forEach(r=>I.error(r))}async function rg(e){const t=qh.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const og=`Build successful:
|
|
39
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function cr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,u={...c},d=a.ref;if(a.ref=null,d){o(d);const y=e.seen.get(d),T=y.schema;if(T.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(T)):Object.assign(c,T),Object.assign(c,u),i._zod.parent===d)for(const B in c)B==="$ref"||B==="allOf"||B in u||delete c[B];if(T.$ref&&y.def)for(const B in c)B==="$ref"||B==="allOf"||B in y.def&&JSON.stringify(c[B])===JSON.stringify(y.def[B])&&delete c[B]}const m=i._zod.parent;if(m&&m!==d){o(m);const y=e.seen.get(m);if(y?.schema.$ref&&(c.$ref=y.schema.$ref,y.def))for(const T in c)T==="$ref"||T==="allOf"||T in y.def&&JSON.stringify(c[T])===JSON.stringify(y.def[T])&&delete c[T]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())o(i[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(i)}Object.assign(r,n.def??n.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(s[a.defId]=a.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const i=JSON.parse(JSON.stringify(r));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:vt(t,"input",e.processors),output:vt(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function W(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(o.type==="transform")return!0;if(o.type==="array")return W(o.element,n);if(o.type==="set")return W(o.valueType,n);if(o.type==="lazy")return W(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return W(o.innerType,n);if(o.type==="intersection")return W(o.left,n)||W(o.right,n);if(o.type==="record"||o.type==="map")return W(o.keyType,n)||W(o.valueType,n);if(o.type==="pipe")return W(o.in,n)||W(o.out,n);if(o.type==="object"){for(const r in o.shape)if(W(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(W(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(W(r,n))return!0;return!!(o.rest&&W(o.rest,n))}return!1}const Gu=(e,t={})=>n=>{const o=ir({...n,processors:t});return M(e,o),ar(o,e),cr(o,e)},vt=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=ir({...r??{},target:s,io:t,processors:n});return M(e,i),ar(i,e),cr(i,e)},xu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Bu=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=xu[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?r.pattern=d[0].source:d.length>1&&(r.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Zu=(e,t,n,o)=>{const r=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=d,r.exclusiveMinimum=!0):r.exclusiveMinimum=d),typeof s=="number"&&(r.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?delete r.minimum:delete r.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u),typeof i=="number"&&(r.maximum=i,typeof u=="number"&&t.target!=="draft-04"&&(u<=i?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},Hu=(e,t,n,o)=>{n.type="boolean"},Vu=(e,t,n,o)=>{n.not={}},Wu=(e,t,n,o)=>{},Yu=(e,t,n,o)=>{const r=e._zod.def,s=Oo(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Ku=(e,t,n,o)=>{const r=e._zod.def,s=[];for(const i of r.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},Ju=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Xu=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Qu=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=M(s.element,t,{...o,path:[...o.path,"items"]})},qu=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const u in i)r.properties[u]=M(i[u],t,{...o,path:[...o.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(r.required=Array.from(c)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=M(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},el=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>M(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},tl=(e,t,n,o)=>{const r=e._zod.def,s=M(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=M(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},nl=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object";const i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=M(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const m of c)r.patternProperties[m.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=M(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=M(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const u=i._zod.values;if(u){const d=[...u].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(r.required=d)}},ol=(e,t,n,o)=>{const r=e._zod.def,s=M(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},rl=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},sl=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},il=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},al=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},cl=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;M(s,t,o);const i=t.seen.get(e);i.ref=s},ul=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},ur=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ll=l("ZodISODateTime",(e,t)=>{dc.init(e,t),P.init(e,t)});function dl(e){return Eu(ll,e)}const pl=l("ZodISODate",(e,t)=>{pc.init(e,t),P.init(e,t)});function fl(e){return gu(pl,e)}const hl=l("ZodISOTime",(e,t)=>{fc.init(e,t),P.init(e,t)});function ml(e){return _u(hl,e)}const El=l("ZodISODuration",(e,t)=>{hc.init(e,t),P.init(e,t)});function gl(e){return yu(El,e)}const _l=(e,t)=>{bo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ra(e,n)},flatten:{value:n=>oa(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,pn,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,pn,2)}},isEmpty:{get(){return e.issues.length===0}}})},ne=l("ZodError",_l,{Parent:Error}),yl=En(ne),Sl=gn(ne),Tl=yt(ne),Ol=St(ne),Il=aa(ne),wl=ca(ne),vl=ua(ne),Cl=la(ne),Rl=da(ne),bl=pa(ne),Al=fa(ne),Nl=ha(ne),k=l("ZodType",(e,t)=>(L.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vt(e,"input"),output:vt(e,"output")}}),e.toJSONSchema=Gu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ie(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>we(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>yl(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Tl(e,n,o),e.parseAsync=async(n,o)=>Sl(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Ol(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>Il(e,n,o),e.decode=(n,o)=>wl(e,n,o),e.encodeAsync=async(n,o)=>vl(e,n,o),e.decodeAsync=async(n,o)=>Cl(e,n,o),e.safeEncode=(n,o)=>Rl(e,n,o),e.safeDecode=(n,o)=>bl(e,n,o),e.safeEncodeAsync=async(n,o)=>Al(e,n,o),e.safeDecodeAsync=async(n,o)=>Nl(e,n,o),e.refine=(n,o)=>e.check(Od(n,o)),e.superRefine=n=>e.check(Id(n)),e.overwrite=n=>e.check(Me(n)),e.optional=()=>_r(e),e.exactOptional=()=>ld(e),e.nullable=()=>yr(e),e.nullish=()=>_r(yr(e)),e.nonoptional=n=>Ed(e,n),e.array=()=>A(e),e.or=n=>td([e,n]),e.and=n=>rd(e,n),e.transform=n=>Tr(e,cd(n)),e.default=n=>fd(e,n),e.prefault=n=>md(e,n),e.catch=n=>_d(e,n),e.pipe=n=>Tr(e,n),e.readonly=()=>Td(e),e.describe=n=>{const o=e.clone();return et.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return et.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return et.get(e);const o=e.clone();return et.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),lr=l("_ZodString",(e,t)=>{_n.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Bu(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(vu(...o)),e.includes=(...o)=>e.check(bu(...o)),e.startsWith=(...o)=>e.check(Au(...o)),e.endsWith=(...o)=>e.check(Nu(...o)),e.min=(...o)=>e.check(wt(...o)),e.max=(...o)=>e.check(rr(...o)),e.length=(...o)=>e.check(sr(...o)),e.nonempty=(...o)=>e.check(wt(1,...o)),e.lowercase=o=>e.check(Cu(o)),e.uppercase=o=>e.check(Ru(o)),e.trim=()=>e.check(Du()),e.normalize=(...o)=>e.check($u(...o)),e.toLowerCase=()=>e.check(Lu()),e.toUpperCase=()=>e.check(ku()),e.slugify=()=>e.check(Pu())}),$l=l("ZodString",(e,t)=>{_n.init(e,t),lr.init(e,t),e.email=n=>e.check(Jc(Dl,n)),e.url=n=>e.check(er(pr,n)),e.jwt=n=>e.check(mu(Wl,n)),e.emoji=n=>e.check(tu(Ll,n)),e.guid=n=>e.check(qo(dr,n)),e.uuid=n=>e.check(Xc(Ct,n)),e.uuidv4=n=>e.check(Qc(Ct,n)),e.uuidv6=n=>e.check(qc(Ct,n)),e.uuidv7=n=>e.check(eu(Ct,n)),e.nanoid=n=>e.check(nu(kl,n)),e.guid=n=>e.check(qo(dr,n)),e.cuid=n=>e.check(ou(Pl,n)),e.cuid2=n=>e.check(ru(zl,n)),e.ulid=n=>e.check(su(jl,n)),e.base64=n=>e.check(pu(Zl,n)),e.base64url=n=>e.check(fu(Hl,n)),e.xid=n=>e.check(iu(Ul,n)),e.ksuid=n=>e.check(au(Fl,n)),e.ipv4=n=>e.check(cu(Ml,n)),e.ipv6=n=>e.check(uu(Gl,n)),e.cidrv4=n=>e.check(lu(xl,n)),e.cidrv6=n=>e.check(du(Bl,n)),e.e164=n=>e.check(hu(Vl,n)),e.datetime=n=>e.check(dl(n)),e.date=n=>e.check(fl(n)),e.time=n=>e.check(ml(n)),e.duration=n=>e.check(gl(n))});function h(e){return Kc($l,e)}const P=l("ZodStringFormat",(e,t)=>{$.init(e,t),lr.init(e,t)}),Dl=l("ZodEmail",(e,t)=>{nc.init(e,t),P.init(e,t)}),dr=l("ZodGUID",(e,t)=>{ec.init(e,t),P.init(e,t)}),Ct=l("ZodUUID",(e,t)=>{tc.init(e,t),P.init(e,t)}),pr=l("ZodURL",(e,t)=>{oc.init(e,t),P.init(e,t)});function fr(e){return er(pr,e)}const Ll=l("ZodEmoji",(e,t)=>{rc.init(e,t),P.init(e,t)}),kl=l("ZodNanoID",(e,t)=>{sc.init(e,t),P.init(e,t)}),Pl=l("ZodCUID",(e,t)=>{ic.init(e,t),P.init(e,t)}),zl=l("ZodCUID2",(e,t)=>{ac.init(e,t),P.init(e,t)}),jl=l("ZodULID",(e,t)=>{cc.init(e,t),P.init(e,t)}),Ul=l("ZodXID",(e,t)=>{uc.init(e,t),P.init(e,t)}),Fl=l("ZodKSUID",(e,t)=>{lc.init(e,t),P.init(e,t)}),Ml=l("ZodIPv4",(e,t)=>{mc.init(e,t),P.init(e,t)}),Gl=l("ZodIPv6",(e,t)=>{Ec.init(e,t),P.init(e,t)}),xl=l("ZodCIDRv4",(e,t)=>{gc.init(e,t),P.init(e,t)}),Bl=l("ZodCIDRv6",(e,t)=>{_c.init(e,t),P.init(e,t)}),Zl=l("ZodBase64",(e,t)=>{yc.init(e,t),P.init(e,t)}),Hl=l("ZodBase64URL",(e,t)=>{Tc.init(e,t),P.init(e,t)}),Vl=l("ZodE164",(e,t)=>{Oc.init(e,t),P.init(e,t)}),Wl=l("ZodJWT",(e,t)=>{wc.init(e,t),P.init(e,t)}),hr=l("ZodNumber",(e,t)=>{Fo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Zu(e,o,r),e.gt=(o,r)=>e.check(nr(o,r)),e.gte=(o,r)=>e.check(Tn(o,r)),e.min=(o,r)=>e.check(Tn(o,r)),e.lt=(o,r)=>e.check(tr(o,r)),e.lte=(o,r)=>e.check(Sn(o,r)),e.max=(o,r)=>e.check(Sn(o,r)),e.int=o=>e.check(he(o)),e.safe=o=>e.check(he(o)),e.positive=o=>e.check(nr(0,o)),e.nonnegative=o=>e.check(Tn(0,o)),e.negative=o=>e.check(tr(0,o)),e.nonpositive=o=>e.check(Sn(0,o)),e.multipleOf=(o,r)=>e.check(or(o,r)),e.step=(o,r)=>e.check(or(o,r)),e.finite=()=>e;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 Rt(e){return Su(hr,e)}const Yl=l("ZodNumberFormat",(e,t)=>{vc.init(e,t),hr.init(e,t)});function he(e){return Tu(Yl,e)}const Kl=l("ZodBoolean",(e,t)=>{Cc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hu(e,n,o)});function v(e){return Ou(Kl,e)}const Jl=l("ZodUnknown",(e,t)=>{Rc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wu()});function mr(){return Iu(Jl)}const Xl=l("ZodNever",(e,t)=>{bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vu(e,n,o)});function Ql(e){return wu(Xl,e)}const ql=l("ZodArray",(e,t)=>{Ac.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qu(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(wt(n,o)),e.nonempty=n=>e.check(wt(1,n)),e.max=(n,o)=>e.check(rr(n,o)),e.length=(n,o)=>e.check(sr(n,o)),e.unwrap=()=>e.element});function A(e,t){return zu(ql,e,t)}const ed=l("ZodObject",(e,t)=>{$c.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qu(e,n,o,r),b(e,"shape",()=>t.shape),e.keyof=()=>U(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:mr()}),e.loose=()=>e.clone({...e._zod.def,catchall:mr()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ql()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Qi(e,n),e.safeExtend=n=>qi(e,n),e.merge=n=>ea(e,n),e.pick=n=>Ji(e,n),e.omit=n=>Xi(e,n),e.partial=(...n)=>ta(gr,e,n[0]),e.required=(...n)=>na(Sr,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...g(t)};return new ed(n)}const Er=l("ZodUnion",(e,t)=>{Zo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>el(e,n,o,r),e.options=t.options});function td(e,t){return new Er({type:"union",options:e,...g(t)})}const nd=l("ZodDiscriminatedUnion",(e,t)=>{Er.init(e,t),Dc.init(e,t)});function oe(e,t,n){return new nd({type:"union",options:t,discriminator:e,...g(n)})}const od=l("ZodIntersection",(e,t)=>{Lc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>tl(e,n,o,r)});function rd(e,t){return new od({type:"intersection",left:e,right:t})}const sd=l("ZodRecord",(e,t)=>{kc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>nl(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Y(e,t,n){return new sd({type:"record",keyType:e,valueType:t,...g(n)})}const On=l("ZodEnum",(e,t)=>{Pc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Yu(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new On({...t,checks:[],...g(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new On({...t,checks:[],...g(r),entries:s})}});function U(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new On({type:"enum",entries:n,...g(t)})}const id=l("ZodLiteral",(e,t)=>{zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ku(e,n,o),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 E(e,t){return new id({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const ad=l("ZodTransform",(e,t)=>{jc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xu(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(qe(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(qe(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function cd(e){return new ad({type:"transform",transform:e})}const gr=l("ZodOptional",(e,t)=>{Wo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ur(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function _r(e){return new gr({type:"optional",innerType:e})}const ud=l("ZodExactOptional",(e,t)=>{Uc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ur(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ld(e){return new ud({type:"optional",innerType:e})}const dd=l("ZodNullable",(e,t)=>{Fc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ol(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function yr(e){return new dd({type:"nullable",innerType:e})}const pd=l("ZodDefault",(e,t)=>{Mc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>sl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fd(e,t){return new pd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const hd=l("ZodPrefault",(e,t)=>{Gc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>il(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function md(e,t){return new hd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Sr=l("ZodNonOptional",(e,t)=>{xc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>rl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Ed(e,t){return new Sr({type:"nonoptional",innerType:e,...g(t)})}const gd=l("ZodCatch",(e,t)=>{Bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>al(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _d(e,t){return new gd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const yd=l("ZodPipe",(e,t)=>{Zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>cl(e,n,o,r),e.in=t.in,e.out=t.out});function Tr(e,t){return new yd({type:"pipe",in:e,out:t})}const Sd=l("ZodReadonly",(e,t)=>{Hc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ul(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Td(e){return new Sd({type:"readonly",innerType:e})}const Or=l("ZodCustom",(e,t)=>{Vc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ju(e,n)});function Ge(e,t){return ju(Or,e??(()=>!0),t)}function Od(e,t={}){return Uu(Or,e,t)}function Id(e){return Fu(e)}const wd={url:"must be a valid URL",email:"must be a valid email address"},vd=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Cd=e=>e===null?"null":typeof e,Rd=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${vd(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Cd(t)}`}}case"invalid_format":{const t=wd[e.format];return t?{message:t}:void 0}case"unrecognized_keys":return{message:`Unrecognized property: ${e.keys.map(t=>`'${t}'`).join(", ")}`};case"invalid_union":{const t=e.path?.at(-1);return typeof t=="string"?{message:`'${t}' is required or has invalid value`}:void 0}case"invalid_value":{const{values:t}=e;return t?{message:`Expected one of: ${t.map(n=>`'${String(n)}'`).join(", ")}`}:void 0}case"invalid_key":{const t=e.issues?.[0];return t?{message:t.message}:void 0}default:return}},O={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};U(Object.values(O));const w={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};U(Object.values(w));const xe={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},bd=U(Object.values(xe)),tt={CONTENT:"Content",DESIGN:"Design"};U(Object.values(tt));const Ad={TEXT:"TEXT",IMAGE:"IMAGE"},Nd=U(Object.values(Ad)),Ce={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"},$d=U(Object.values(Ce)),bt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Dd=U(Object.values(bt)),Ld={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},kd=U(Object.values(Ld)),Pd={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},zd=U(Object.values(Pd)),jd={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},Ud=U(Object.values(jd)),In={COLOR:"COLOR",GRADIENT:"GRADIENT"},Fd=U(Object.values(In));U(["none","all","small"]);const Ae={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Ir={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},Md=U(Object.values(Ae));U(Object.values(Ir));const Gd={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},xd=U(Object.values(Gd)),Bd={HEADER_LEFT:"HEADER_LEFT",HEADER_CENTER_LOGO_BURGER:"HEADER_CENTER_LOGO_BURGER",HEADER_CENTER_LOGO_COMPACT:"HEADER_CENTER_LOGO_COMPACT",HEADER_CENTER_LOGO_DETAILED:"HEADER_CENTER_LOGO_DETAILED",HEADER_LEFT_LOGO_BURGER:"HEADER_LEFT_LOGO_BURGER",HEADER_LEFT_LOGO_COMPACT:"HEADER_LEFT_LOGO_COMPACT",HEADER_LEFT_LOGO_DETAILED:"HEADER_LEFT_LOGO_DETAILED",HEADER_LEFT_LOGO_SEARCH:"HEADER_LEFT_LOGO_SEARCH",HEADER_LEFT_LOGO_TEXT:"HEADER_LEFT_LOGO_TEXT",TEXT_ONE_COLUMN:"TEXT_ONE_COLUMN",TEXT_TITLE_LEFT:"TEXT_TITLE_LEFT",TEXT_SUBTITLE_RIGHT:"TEXT_SUBTITLE_RIGHT",TEXT_TWO_COLUMNS:"TEXT_TWO_COLUMNS",TEXT_CENTER:"TEXT_CENTER",TEXT_DESCRIPTION_RIGHT:"TEXT_DESCRIPTION_RIGHT",CTA_BANNER_LEFT:"CTA_BANNER_LEFT",CTA_BANNER_RIGHT:"CTA_BANNER_RIGHT",CTA_BANNER_CENTER:"CTA_BANNER_CENTER",CTA_BANNER_BOTTOM:"CTA_BANNER_BOTTOM",CTA_PROMO_BAR_LEFT:"CTA_PROMO_BAR_LEFT",CTA_PROMO_BAR_RIGHT:"CTA_PROMO_BAR_RIGHT",CTA_STORY_LEFT:"CTA_STORY_LEFT",CTA_STORY_RIGHT:"CTA_STORY_RIGHT",CTA_FULLWIDTH_CENTER:"CTA_FULLWIDTH_CENTER",CTA_FULLWIDTH_LEFT:"CTA_FULLWIDTH_LEFT",CTA_FULLWIDTH_NO_IMAGE:"CTA_FULLWIDTH_NO_IMAGE",COVER_FULLSCREEN_CENTER:"COVER_FULLSCREEN_CENTER",COVER_FULLSCREEN_LEFT:"COVER_FULLSCREEN_LEFT",COVER_FULLSCREEN_CENTER_LEFT:"COVER_FULLSCREEN_CENTER_LEFT",COVER_FULLSCREEN_RIGHT:"COVER_FULLSCREEN_RIGHT",COVER_FULLSCREEN_BOTTOM:"COVER_FULLSCREEN_BOTTOM",COVER_FULLSCREEN_BOTTOM_RIGHT:"COVER_FULLSCREEN_BOTTOM_RIGHT",COVER_FULLSCREEN_BOTTOM_LEFT:"COVER_FULLSCREEN_BOTTOM_LEFT",COVER_FULLSCREEN_TOP:"COVER_FULLSCREEN_TOP",COVER_SIDEBAR_RIGHT:"COVER_SIDEBAR_RIGHT",COVER_SIDEBAR_LEFT:"COVER_SIDEBAR_LEFT",COVER_HALFSCREEN_LEFT:"COVER_HALFSCREEN_LEFT",COVER_HALFSCREEN_CENTER:"COVER_HALFSCREEN_CENTER",COVER_COLLAGE_BOTTOM:"COVER_COLLAGE_BOTTOM",COVER_COLLAGE_LEFT:"COVER_COLLAGE_LEFT",IMAGE_SUBTITLE_RIGHT:"IMAGE_SUBTITLE_RIGHT",IMAGE_TITLE_LEFT:"IMAGE_TITLE_LEFT",IMAGE_LEFT:"IMAGE_LEFT",IMAGE_RIGHT:"IMAGE_RIGHT",IMAGE_CENTER:"IMAGE_CENTER",IMAGE_SIDE_TITLE:"IMAGE_SIDE_TITLE",LOCATION_MAP_RIGHT:"LOCATION_MAP_RIGHT",LOCATION_MAP_LEFT:"LOCATION_MAP_LEFT",LOCATION_IMAGE_RIGHT:"LOCATION_IMAGE_RIGHT",LOCATION_IMAGE_LEFT:"LOCATION_IMAGE_LEFT",LOCATION_BACKGROUND_RIGHT:"LOCATION_BACKGROUND_RIGHT",LOCATION_BACKGROUND_LEFT:"LOCATION_BACKGROUND_LEFT",LOCATION_FULL:"LOCATION_FULL",LOCATION_SHORT:"LOCATION_SHORT",REVIEWS_MINIMAL:"REVIEWS_MINIMAL",REVIEWS_CARDS:"REVIEWS_CARDS",REVIEWS:"REVIEWS",REVIEWS_CLASSIC:"REVIEWS_CLASSIC",REVIEWS_FULLSCREEN_BG:"REVIEWS_FULLSCREEN_BG",REVIEWS_FULLSCREEN_SIDEBAR_LEFT:"REVIEWS_FULLSCREEN_SIDEBAR_LEFT",REVIEWS_FULLSCREEN_SIDEBAR_RIGHT:"REVIEWS_FULLSCREEN_SIDEBAR_RIGHT",REVIEWS_CARDS_PHOTO:"REVIEWS_CARDS_PHOTO",REVIEWS_PHOTO_SPEECH_RIGHT:"REVIEWS_PHOTO_SPEECH_RIGHT",REVIEWS_PHOTO_SPEECH_LEFT:"REVIEWS_PHOTO_SPEECH_LEFT",REVIEWS_SOCIAL_FEED:"REVIEWS_SOCIAL_FEED",REVIEWS_ADAPTIVE:"REVIEWS_ADAPTIVE",FEATURES_CLASSIC_CENTER:"FEATURES_CLASSIC_CENTER",FEATURES_CLASSIC_LEFT:"FEATURES_CLASSIC_LEFT",FEATURES_ACCORDION:"FEATURES_ACCORDION",FEATURES_MINIMAL:"FEATURES_MINIMAL",FEATURES_SMALL_ICONS:"FEATURES_SMALL_ICONS",FEATURES_CAROUSEL:"FEATURES_CAROUSEL",FEATURES_IMAGE_LEFT:"FEATURES_IMAGE_LEFT",FEATURES_IMAGE_RIGHT:"FEATURES_IMAGE_RIGHT",ANNOUNCEMENT_CENTER:"ANNOUNCEMENT_CENTER",TWO_COLUMNS_SIDEBAR_ON_THE_LEFT:"TWO_COLUMNS_SIDEBAR_ON_THE_LEFT",TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT:"TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT",THREE_COLUMNS_SIDEBAR_ON_THE_RIGHT:"THREE_COLUMNS_SIDEBAR_ON_THE_RIGHT",THREE_COLUMNS_SIDEBAR_ON_THE_LEFT:"THREE_COLUMNS_SIDEBAR_ON_THE_LEFT",TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT_DESCRIPTION_UNDER_IMAGE:"TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT_DESCRIPTION_UNDER_IMAGE",SLIDER_FULLSCREEN_CENTER:"SLIDER_FULLSCREEN_CENTER",SLIDER_FULLSCREEN_LEFT:"SLIDER_FULLSCREEN_LEFT",SLIDER_BASIC:"SLIDER_BASIC",SLIDER_CAROUSEL:"SLIDER_CAROUSEL",SLIDER_CAROUSEL_PORTRAIT:"SLIDER_CAROUSEL_PORTRAIT",SLIDER_SPLIT:"SLIDER_SPLIT",SLIDER_SPLIT_REVERSE:"SLIDER_SPLIT_REVERSE"},Zd=U(Object.values(Bd)),Hd={HEADER:"header",COVER:"cover",ANNOUNCEMENT_BAR:"announcement_bar",SLIDER:"slider",SPECIAL_OFFER:"special_offer",CUSTOMER_REVIEW:"customer_review",COMPANY_INFO:"company_info",SHIPPING_PAYMENT:"shipping_payment",LOCATION:"location",STORE:"store",FOOTER:"footer",VIDEO:"video",IMAGE_GALLERY:"image_gallery",CONTACT_INFO:"contact_info",CONTACTS_WIDGET_WHATSAPP:"contacts_widget_whatsapp",CONTACTS_WIDGET_INSTAGRAM:"contacts_widget_instagram",CONTACTS_WIDGET_FACEBOOK:"contacts_widget_facebook",CONTACTS_WIDGET_PHONE:"contacts_widget_phone"},Vd={COVER:"COVER",ANNOUNCEMENT:"ANNOUNCEMENT",STORE:"STORE",SLIDER:"SLIDER",VIDEO:"VIDEO",SPECIAL_OFFER:"SPECIAL_OFFER",CUSTOMER_REVIEW:"CUSTOMER_REVIEW",COMPANY_INFO:"COMPANY_INFO",SHIPPING_PAYMENT:"SHIPPING_PAYMENT",LOCATION:"LOCATION",COLLECTIONS:"COLLECTIONS",BRANDS:"BRANDS",CONTACT_INFO:"CONTACT_INFO"},Wd=U(Object.values(Vd)),X={REQUIRED_HEADER_ID:()=>'Header section must have id "header" when type is "default"',REQUIRED_CUSTOM_HEADER:(...e)=>`Custom header section with id "${e[0]}" must exist in headers directory`,REQUIRED_CUSTOM_HEADER_TYPE:(...e)=>`Custom header section with id "${e[0]}" must be of type "HEADER"`,REQUIRED_FOOTER_ID:()=>'Footer section must have id "footer" when type is "default"',REQUIRED_CUSTOM_FOOTER:(...e)=>`Custom footer section with id "${e[0]}" must exist in footers directory`,REQUIRED_CUSTOM_FOOTER_TYPE:(...e)=>`Custom footer section with id "${e[0]}" must be of type "FOOTER"`,REQUIRED_PAGE_SECTION:(...e)=>`Custom section with id "${e[0]}" must exist in sections directory`,REQUIRED_PAGE_SECTION_TYPE:()=>'Section "header" or "footer" is not allowed among page sections',SHOWCASE_ID_NOT_FOUND:(...e)=>`Showcase with id "${e[0]}" must exist in section's showcase directory`,DUPLICATE_SHOWCASE_ID:(...e)=>`Showcase id "${e[0]}" must be unique within section showcases`,SHOWCASE_OVERRIDE_CONTENT:(...e)=>`Content editor "${e[0]}" in showcase_overrides must exist in section's content configuration file`,SHOWCASE_OVERRIDE_DESIGN:(...e)=>`Design editor "${e[0]}" in showcase_overrides must exist in section's design configuration file`,SHOWCASE_OVERRIDE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase_overrides must exist in section's layout configuration file`,SHOWCASE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase must exist in section's layout configuration file`,INVALID_SHOWCASE_CONTENT_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in content.ts`,SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but content.ts has type "${e[2]}"`,INVALID_SHOWCASE_DESIGN_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in design.ts`,SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but design.ts has type "${e[2]}"`,INVALID_DECK_CARD_SETTING:(...e)=>`Setting "${e[0]}" is not defined in content.ts defaultCardContent.settings`,DECK_SETTINGS_REQUIRED:()=>"settings must have at least one property",INVALID_SELECTBOX_OPTION:(...e)=>`Option value "${e[0]}" for element "${e[1]}" is not defined in content.ts options`,REQUIRED_STORE_LAYOUT:(...e)=>`Store section with id "${e[0]}" and page type "${e[1]}" must have a corresponding layout defined`,INVALID_STORE_SECTION_ID:(...e)=>`Store layout sectionId "${e[0]}" must be one of: ${e[1]}`,REQUIRED_SECTION_ASSET:(...e)=>`Asset size ${e[0]} exceeds threshold of ${e[1]}.`,REQUIRED_SERVER_SIZE:(...e)=>`Size of individual server file [${e[0]}] must not exceed threshold [${e[1]}].`,MISSING_IMAGE_ASSET:(...e)=>`Image ${e[0]} is missing from assets folder`,MANDATORY_SETTING_TYPE_MISMATCH:(...e)=>`Editor type "${e[0]}" for reserved key "${e[1]}" does not match the required type "${e[2]}".`,MANDATORY_SETTING_NAME_MISMATCH:(...e)=>`Editor key "${e[0]}" for overridden content type "${e[1]}" does not match the required key name "${e[2]}".`,DUPLICATED_MANDATORY_SETTING:(...e)=>`Editor type "${e[0]}" can only be used once.`,IMAGE_EDITOR_STATIC_MISMATCH:(...e)=>`Both "${e[0]}" content and design editor need to have same value for attribute static`,DUPLICATE_DESIGN_EDITOR_NAME:()=>"Non-unique design editor name detected",COLOR_REQUIRED_GRADIENT:()=>"color is required when overlay is GRADIENT",COLOR_MUST_BE_ARRAY_GRADIENT:()=>"color must be an array when overlay is GRADIENT",COLOR_ARRAY_LENGTH_GRADIENT:()=>"color array must have exactly 2 items when overlay is GRADIENT",COLOR_REQUIRED_COLOR:()=>"color is required when overlay is COLOR",COLOR_MUST_BE_SINGLE_COLOR:()=>"color must be a single value when overlay is COLOR",COLOR_MUST_BE_UNDEFINED_NONE:()=>"color must be undefined when overlay is NONE or not set",COLOR_REQUIRED_STYLE_GRADIENT:()=>"color is required when style is GRADIENT",COLOR_MUST_BE_ARRAY_STYLE_GRADIENT:()=>"color must be an array when style is GRADIENT",COLOR_ARRAY_LENGTH_STYLE_GRADIENT:()=>"color array must have exactly 2 items when style is GRADIENT",COLOR_REQUIRED_STYLE_COLOR:()=>"color is required when style is COLOR",COLOR_MUST_BE_SINGLE_STYLE_COLOR:()=>"color must be a single value when style is COLOR",BUTTON_LINK_REQUIRED:()=>"link is required when buttonType is HYPER_LINK",BUTTON_CATEGORY_ID_REQUIRED:()=>"categoryId is required when buttonType is GO_TO_CATEGORY or GO_TO_CATEGORY_LINK",BUTTON_EMAIL_REQUIRED:()=>"email is required when buttonType is MAIL_LINK",BUTTON_PHONE_REQUIRED:()=>"phone is required when buttonType is TEL_LINK",BUTTON_TILE_ID_REQUIRED:(...e)=>`${e[0]} is required when buttonType is SCROLL_TO_TILE`,BUTTON_PAGE_ID_REQUIRED:()=>"pageIdForNavigate is required when type is GO_TO_PAGE",TEMPLATE_PAGE_SECTIONS_REQUIRED:()=>"sections must contain at least one section",TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have exactly one section`,TEMPLATE_PAGE_STORE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have a section of type "store"`,TEMPLATE_PAGE_NO_STORE_SECTIONS:(...e)=>`Page type "${e[0]}" cannot contain store sections`,TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED:()=>'Page type "CUSTOM" must have a metadata property',TEMPLATE_PAGE_METADATA_NOT_ALLOWED:(...e)=>`Page type "${e[0]}" must not have a metadata property`,NON_NEGATIVE_INTEGER:()=>"must be a non-negative integer",INTEGER_RANGE:(...e)=>`must be between ${e[0]} and ${e[1]}`,VALID_HEX_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA)",VALID_GLOBAL_FONT:()=>"must be a valid global font reference (global.fontFamily.title or global.fontFamily.body)",VALID_GLOBAL_TEXT_SIZE:()=>"must be a valid global text size reference (global.textSize.title, global.textSize.subtitle, or global.textSize.body)",VALID_GLOBAL_COLOR:()=>"must be a valid global color reference (global.color.title, global.color.body, global.color.button, global.color.link, or global.color.background)",VALID_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA) or global color reference (global.color.title, global.color.body, global.color.button, global.color.link, or global.color.background)",VALID_TEXT_SIZE:()=>"must be an integer of at least 1 or a valid global text size reference (global.textSize.title, global.textSize.subtitle, or global.textSize.body)",VALID_LANGUAGE_CODE:()=>"must be a valid language code (e.g., en, nl, fr, en_US, en_GB, zh_Hans)",VALID_URL:()=>"must be a valid URL",VALID_EMAIL:()=>"must be a valid email address",ACCORDION_ITEM_POSITION_FIELD_REQUIRED:(...e)=>`Item "${e[0]}" must have positionFieldName when sortable is true`,ACCORDION_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor`,ACCORDION_SHOWCASE_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor override`,ACCORDION_DUPLICATE_POSITION_FIELD_NAME:()=>"positionFieldName must be unique across accordion items when sortable is true",REQUIRED_COLLECTION_NAME:()=>"Collection must have a name in metadata"},wr=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,vr=/^global\.fontFamily\.(title|body)$/,Cr=/^global\.textSize\.(title|subtitle|body)$/,Rr=/^global\.color\.(title|body|button|link|background)$/,Yd=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,Re=(e,t)=>{const n=X.INTEGER_RANGE(e.toString(),t.toString());return he().min(e,{message:n}).max(t,{message:n})},wn=p({path:h(),size:Rt().nonnegative()}).strict(),br=p({size:Rt().nonnegative()}).strict(),_=h().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),Kd=p({r:Re(0,255),g:Re(0,255),b:Re(0,255),a:Re(0,1)}).strict(),Ar=h().regex(wr,{message:X.VALID_HEX_COLOR()});Ge(e=>typeof e=="string"&&vr.test(e),{message:X.VALID_GLOBAL_FONT()});const vn=h().refine(e=>!e.startsWith("global.")||vr.test(e),{message:X.VALID_GLOBAL_FONT()});Ge(e=>typeof e=="string"&&Rr.test(e),{message:X.VALID_GLOBAL_COLOR()});const le=Ge(e=>typeof e=="string"&&(wr.test(e)||Rr.test(e)),{message:X.VALID_COLOR()}),Nr=Ge(e=>typeof e=="string"?le.safeParse(e).success:Array.isArray(e)&&e.every(t=>le.safeParse(t).success),{message:X.VALID_COLOR()});Ge(e=>typeof e=="string"&&Cr.test(e),{message:X.VALID_GLOBAL_TEXT_SIZE()});const $r=Ge(e=>typeof e=="number"?Number.isInteger(e)&&e>=1:typeof e=="string"&&Cr.test(e),{message:X.VALID_TEXT_SIZE()}),nt=U(["catalog","category","product"]),At=h().refine(e=>e.startsWith("#")||fr().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),ot=p({url:h(),width:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional(),height:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional()}).strict(),Jd=p({homogeneity:v().optional(),color:Kd.optional()}).strict(),Xd=p({ORIGINAL:ot.optional(),WEBP_LOW_RES:ot.optional(),WEBP_HI_2X_RES:ot.optional(),MOBILE_WEBP_LOW_RES:ot.optional(),MOBILE_WEBP_HI_RES:ot.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),Nt=p({set:Xd,borderInfo:Jd.optional()}).strict(),Cn=p({type:E(O.IMAGE),imageData:Nt}).strict(),Dr=p({type:E(O.IMAGE),label:_,static:v().optional(),defaults:Cn.optional()}).strict(),Qd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Rn(e){return e===Ae.PRODUCT||e===Ae.CATALOG||e===Ae.CATEGORY}function Lr(e,t,n){if(!e)return;const o=vi({path:"$..set..url",json:e,resultType:"all"}),r=/^https?:\/\//;o.forEach(s=>{const i=s.value;if(!r.test(i)&&!t.includes(i)){const a=s.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",i)}})}function kr(e,t,n){e===Ce.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Pr(e,t,n){(e===Ce.GO_TO_CATEGORY||e===Ce.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function zr(e,t,n){e===Ce.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function jr(e,t,n){e===Ce.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Ur(e,t,n,o){if(e===Ce.SCROLL_TO_TILE&&!(t??n)){const r=t?"tileId":"tileIdForScroll";o.at(r).addIssue("BUTTON_TILE_ID_REQUIRED",r)}}function qd(e,t,n){e===Ce.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const ep="custom";function x(e,t=[]){const n=r=>Array.isArray(r)?r:[r],o=n(t);return{raw:e,addIssue(r,...s){e.addIssue({code:ep,message:X[r](...s),path:o,params:{errorMessageKey:r}})},at(r){const s=o.concat(n(r));return x(e,s)}}}const bn=p({type:E(O.BUTTON),title:_,buttonType:$d,link:h().optional(),linkTarget:h().optional(),email:h().regex(Qd,{message:X.VALID_EMAIL()}).optional(),phone:h().optional(),tileId:h().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=x(t);kr(e.buttonType,e.link,n),Pr(e.buttonType,e.categoryId,n),zr(e.buttonType,e.email,n),jr(e.buttonType,e.phone,n),Ur(e.buttonType,e.tileId,void 0,n)}),Fr=p({type:E(O.BUTTON),label:_,defaults:bn.optional()}).strict(),An=p({type:E(O.CATEGORY_SELECTOR)}).strict(),Mr=p({type:E(O.CATEGORY_SELECTOR),label:_,maxCategories:Re(1,32),defaults:An.optional()}).strict(),Nn=p({type:E(O.DIVIDER)}).strict(),Gr=p({type:E(O.DIVIDER),label:_,defaults:Nn.optional()}).strict(),tp=p({label:_,link:At}).strict(),np=p({title:_.optional(),link:At.optional()}).strict(),$n=p({type:E(O.INFO),text:_.optional(),button:np.optional()}).strict(),xr=p({type:E(O.INFO),label:_,description:_,button:tp.optional(),defaults:$n.optional()}).strict(),Dn=p({type:E(O.INPUTBOX),text:_}).strict(),Br=p({type:E(O.INPUTBOX),label:_,placeholder:_,defaults:Dn.optional()}).strict(),Ln=p({type:E(O.PRODUCT_SELECTOR)}).strict(),Zr=p({type:E(O.PRODUCT_SELECTOR),label:_,maxProducts:Re(1,32),defaults:Ln.optional()}).strict(),kn=p({type:E(O.SELECTBOX),value:h()}).strict(),op=p({value:h().min(1,{message:"value must not be empty"}),label:_}).strict(),Hr=p({type:E(O.SELECTBOX),label:_,placeholder:_,description:_,options:A(op).min(1,{message:"must have at least one option"}),defaults:kn.optional()}).strict(),Pn=p({type:E(O.TEXTAREA),text:_}).strict(),Vr=p({type:E(O.TEXTAREA),label:_,placeholder:_,defaults:Pn.optional()}).strict(),zn=p({type:E(O.TOGGLE),enabled:v()}).strict(),Wr=p({type:E(O.TOGGLE),label:_,description:_,defaults:zn.optional()}).strict(),Yr=p({type:E(O.DECK)}).strict(),rp=oe("type",[Dn,Pn,bn,Cn,zn,kn,Nn,$n,Ln,An]),sp=p({type:E(O.DECK),cards:A(p({settings:Y(h(),rp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),Kr=[Br,Vr,Fr,Dr,Wr,Hr,Gr,xr,Mr,Zr],ip=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Y(h(),oe("type",[...Kr])).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Yr.optional()}).strict(),ap=oe("type",[...Kr,ip]),cp=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Y(h(),ap).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Yr.optional()}).strict(),Jr=p({type:E(O.LOGO),logoType:Nd.optional(),text:_.optional(),imageData:Nt.optional()}).strict(),up=p({type:E(O.LOGO),label:_.optional(),defaults:Jr.optional()}).strict(),Xr=p({id:h(),title:h().optional(),type:h().optional(),link:h().optional(),email:h().optional(),phone:h().optional(),tileIdForScroll:h().optional(),pageIdForNavigate:h().optional(),showStoreCategories:v().optional(),isSubmenuOpened:v().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=x(t);kr(e.type,e.link,n),Pr(e.type,e.categoryId,n),zr(e.type,e.email,n),jr(e.type,e.phone,n),Ur(e.type,void 0,e.tileIdForScroll,n),qd(e.type,e.pageIdForNavigate,n)}),Qr=p({type:E(O.MENU),items:A(Xr).optional()}).strict(),lp=p({type:E(O.MENU),label:_.optional(),defaults:Qr.optional()}).strict(),qr=p({type:E(O.NAVIGATION_MENU),items:A(Xr).optional()}).strict(),dp=p({type:E(O.NAVIGATION_MENU),defaults:qr.optional()}).strict(),$t=p({type:E(w.BACKGROUND),style:Fd.optional(),color:Nr.optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.style===In.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_STYLE_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_STYLE_GRADIENT"):e.style===In.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),pp=p({type:E(w.BACKGROUND),fieldName:h(),defaults:$t.optional()}).strict(),es=p({type:E(w.BACKGROUND),label:_,colors:A(le).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:$t.optional()}).strict(),Dt=p({type:E(w.BUTTON),appearance:kd.optional(),size:zd.optional(),shape:Ud.optional(),font:vn.optional(),color:le.optional(),visible:v().optional()}).strict(),fp=p({type:E(w.BUTTON),fieldName:h(),defaults:Dt.optional()}).strict(),ts=p({type:E(w.BUTTON),label:_,colors:A(le).optional(),enableAutoColor:v().optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Dt.optional()}).strict(),Lt=p({type:E(w.COLOR_PICKER),color:le.optional()}).strict(),hp=p({type:E(w.COLOR_PICKER),fieldName:h(),defaults:Lt.optional()}).strict(),ns=p({type:E(w.COLOR_PICKER),label:_,description:_.optional(),colors:A(le).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:Lt.optional()}).strict(),kt=p({type:E(w.DIVIDER)}).strict(),mp=p({type:E(w.DIVIDER),fieldName:h(),defaults:kt.optional()}).strict(),os=p({type:E(w.DIVIDER),label:_,defaults:kt.optional()}).strict(),Pt=p({type:E(w.IMAGE),overlay:Dd.optional(),color:Nr.optional(),visible:v().optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.overlay===bt.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_GRADIENT"):e.overlay===bt.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===bt.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),Ep=p({type:E(w.IMAGE),fieldName:h(),defaults:Pt.optional()}).strict(),rs=p({type:E(w.IMAGE),label:_,static:v().optional(),colors:A(Ar).optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),defaults:Pt.optional()}).strict(),gp=p({label:_,link:At}).strict(),_p=p({label:_.optional(),link:At.optional()}).strict(),zt=p({type:E(w.INFO),description:_.optional(),button:_p.optional()}).strict(),yp=p({type:E(w.INFO),fieldName:h(),defaults:zt.optional()}).strict(),ss=p({type:E(w.INFO),label:_,description:_,button:gp.optional(),defaults:zt.optional()}).strict(),Sp=p({visible:v(),width:Re(1,49).optional(),color:le.optional()}).strict(),jt=p({type:E(w.LOGO),font:vn.optional(),size:$r.optional(),bold:v().optional(),italic:v().optional(),color:le.optional(),visible:v().optional(),spacing:Re(1,9).optional(),frame:Sp.optional(),capitalization:U(["none","all","small"]).optional()}).strict(),Tp=p({type:E(w.LOGO),fieldName:h(),defaults:jt.optional()}).strict(),is=p({type:E(w.LOGO),label:_,colors:A(le).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),defaults:jt.optional()}).strict(),Op=p({value:h().optional(),label:_.optional()}).strict(),Ut=p({type:E(w.SELECTBOX),value:h().optional()}).strict(),Ip=p({type:E(w.SELECTBOX),fieldName:h(),defaults:Ut.optional()}).strict(),as=p({type:E(w.SELECTBOX),label:_,description:_.optional(),options:A(Op).optional(),defaults:Ut.optional()}).strict(),Ft=p({type:E(w.TEXT),font:vn.optional(),size:$r.optional(),bold:v().optional(),italic:v().optional(),color:le.optional(),visible:v().optional()}).strict(),wp=p({type:E(w.TEXT),fieldName:h(),defaults:Ft.optional()}).strict(),cs=p({type:E(w.TEXT),label:_,colors:A(Ar).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Ft.optional()}).strict(),Mt=p({type:E(w.TOGGLE),enabled:v().optional()}).strict(),vp=p({type:E(w.TOGGLE),fieldName:h(),defaults:Mt.optional()}).strict(),us=p({type:E(w.TOGGLE),label:_,defaults:Mt.optional()}).strict();function Cp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function Rp(e,t){for(const[n,o]of Object.entries(e))Object.keys(o.editors).length===0&&t.at(["items",n,"editors"]).addIssue("ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED",n)}function bp(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Ap(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function Np(e,t){for(const[n,o]of Object.entries(e))o.positionFieldName||t.at(["items",n,"positionFieldName"]).addIssue("ACCORDION_ITEM_POSITION_FIELD_REQUIRED",n)}function $p(e,t){const n=Object.values(e).map(o=>o.positionFieldName).filter(Boolean);new Set(n).size!==n.length&&t.at("items").addIssue("ACCORDION_DUPLICATE_POSITION_FIELD_NAME")}const ls=p({type:E(w.ACCORDION)}).strict(),Dp=oe("type",[Ft,Dt,Pt,Mt,Ut,$t,Lt,jt,kt,zt]),Lp=p({editors:Y(h(),Dp)}).strict(),kp=p({type:E(w.ACCORDION),items:Y(h(),Lp)}).strict().superRefine((e,t)=>{const n=x(t);Cp(e.items,n),Rp(e.items,n)}),Pp=p({type:E(w.ACCORDION),fieldName:h(),defaults:ls.optional()}).strict(),zp=oe("type",[cs,ts,rs,us,as,es,ns,is,os,ss]),jp=p({label:_,positionFieldName:h().optional(),editors:Y(h(),zp)}).strict().superRefine((e,t)=>{bp(e.editors,e.label,x(t))}),Up=p({type:E(w.ACCORDION),sortable:v().optional(),items:Y(h(),jp),defaults:ls.optional()}).strict().superRefine((e,t)=>{const n=x(t);Ap(e.items,n),e.sortable===!0&&(Np(e.items,n),$p(e.items,n))}),ds=oe("type",[Dn,Pn,bn,Cn,zn,kn,Qr,qr,Jr,Nn,$n,sp,Ln,An]),ps=oe("type",[Ft,Dt,Pt,Mt,Ut,$t,Lt,jt,kt,kp,zt]),Fp=p({showcaseId:h(),blockName:h(),previewImage:Nt,content:Y(h(),ds),design:Y(h(),ps),layoutId:h().optional()}).strict(),Mp=p({blockName:h(),content:Y(h(),ds).optional(),design:Y(h(),ps).optional(),layoutId:h().optional()}).strict();function Gp(e,t){Rn(e.type)&&(e.sections.length!==1?t.at("sections").addIssue("TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED",e.type):e.sections[0]?.type!=="store"&&t.at(["sections",0,"type"]).addIssue("TEMPLATE_PAGE_STORE_SECTION_REQUIRED",e.type))}function xp(e,t){Rn(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,o)=>{Rn(e.type)||n.type==="store"&&t.at(["sections",o,"type"]).addIssue("TEMPLATE_PAGE_NO_STORE_SECTIONS",e.type),n.type==="default"&&n.id&&(n.id==="header"||n.id==="footer")&&t.at(["sections",o,"id"]).addIssue("REQUIRED_PAGE_SECTION_TYPE")})}function Bp(e,t){e.type==="CUSTOM"?e.metadata||t.at("metadata").addIssue("TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED"):e.metadata!==void 0&&t.at("metadata").addIssue("TEMPLATE_PAGE_METADATA_NOT_ALLOWED",e.type)}const Zp=new RegExp(`^(${Object.values(Hd).join("|")})(_\\d{3})?$`),Hp=h().regex(Zp,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),Vp=h().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),fs=p({type:E("default"),id:Hp,showcase_id:Vp.optional()}).strict(),jn=p({type:E("custom"),id:h(),showcase_id:h().optional(),showcase_overrides:Mp.optional(),category:Wd.optional()}).strict(),Wp=p({type:E("store"),id:h().optional()}).strict(),Yp=oe("type",[fs,jn,Wp]),Kp=p({title:h()}).strict(),Jp=p({metadata:Kp.optional(),sections:A(Yp)}).strict(),Xp=Jp.safeExtend({type:Md,id:h().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=x(t);xp(e,n),Gp(e,n),Bp(e,n)}),hs=p({name:h().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:h().min(2,{message:"description must be at least 2 characters"}).max(150,{message:"description must be at most 150 characters"}),preview_url:fr({message:"preview_url must be a valid URL"}).regex(/^(https?):\/\/([^.]+?\.)?(company\.site|ecwid\.qa)($|\/[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=]*)?$/,"preview_url must match pattern: (https?)://([^.]+?\\.)?(company\\.site|ecwid\\.qa)(...)?").optional(),cover_image:Nt,categories:A(xd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),Qp=fs.extend({id:h()}),ms=oe("type",[Qp,jn]),qp=p({metadata:hs,header:ms,footer:ms}).strict(),ef=p({id:h().min(1,{message:"id is required"}),assets:wn.array().optional(),configuration:qp,pages:A(Xp)}).strict(),Gt=2097152,xt=512e3;function Se(e,t=2){if(!+e)return"0 Bytes";const n=1024,o=t<0?0:t,r=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],s=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**s).toFixed(o))} ${r[s]}`}const tf={menu:{type:O.NAVIGATION_MENU},logo:{type:O.LOGO}},nf={logo:{type:"LOGO",label:"$label.logo.label",colors:["#FFFFFF66","#0000004D","#00000099","#64C7FF66","#F9947266","#C794CD66","#FFD17466"],sizes:[18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60],defaults:{type:"LOGO",font:"global.fontFamily.body",size:40,bold:!0,italic:!1,color:"#313131",visible:!0,spacing:2,capitalization:"all",frame:{visible:!0,width:3,color:"#313131"}}}};function Es(e){switch(e){case xe.HEADER:return tf;default:return{}}}function gs(e){switch(e){case xe.HEADER:return nf;default:return{}}}function _s({validationType:e,sectionType:t}){switch(e){case tt.CONTENT:return Es(t);case tt.DESIGN:return gs(t);default:return{}}}const of=jn.extend({id:h().min(1,{message:"section id is required"})}),rf=p({metadata:hs,sections:A(of).min(1,{message:"sections must contain at least one section"}).max(20,{message:"sections must contain at most 20 sections"})}).strict().superRefine((e,t)=>{e.metadata.name.trim().length===0&&x(t).at(["collection","metadata","name"]).addIssue("REQUIRED_COLLECTION_NAME")}),sf=p({id:h().min(1,{message:"id is required"}),descriptor:rf}).strict(),af=oe("type",[Br,Vr,Fr,Dr,Wr,Hr,cp,lp,dp,up,Gr,xr,Zr,Mr]),Un=Y(h(),af),cf=oe("type",[cs,ts,rs,us,as,es,ns,is,os,Up,ss]),Fn=Y(h(),cf),uf=oe("type",[wp,fp,Ep,vp,Ip,pp,hp,Tp,mp,yp,Pp]),Mn=p({layoutId:h(),layoutIcon:Zd.optional(),selectedContentSettings:A(h()),selectedDesignSettings:A(uf)}).strict(),lf=h().regex(Yd,X.VALID_LANGUAGE_CODE()),Bt=Y(lf,Y(_,h()));function ys(e,t,n){if(!e||Object.keys(t).length===0)return;const o=Object.entries(t),r=o.map(([,{type:i}])=>i),s=Object.values(e).map(({type:i})=>i);Object.entries(e).forEach(([i,a])=>{const c=t[i];c&&"type"in c&&a.type!==c.type&&n.at(i).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,i,c.type)}),Object.entries(e).forEach(([i,a])=>{const c=o.find(([,{type:u}])=>u===a.type)?.[0];c&&i!==c&&n.at(i).addIssue("MANDATORY_SETTING_NAME_MISMATCH",i,a.type,c)}),new Set(s.filter(i=>r.includes(i))).forEach(i=>{if(s.filter(a=>a===i).length>1){const a=o.findLast(([,{type:c}])=>c===i)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",i)}})}function Ss(e,t,n){Lr(e,t,n)}function df(e,t,n){if(e.type!==O.DECK||t.type!==O.DECK)return;const o=t.cards?.defaultCardContent?.settings,r=e.cards;if(!o||!Array.isArray(r))return;const s=new Set(Object.keys(o));r.forEach((i,a)=>{i.settings&&Object.keys(i.settings).forEach(c=>{s.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function pf(e,t,n){e.content&&Object.entries(e.content).forEach(([o,r])=>{const s=n.at(["content",o]),i=t[o];if(!i){s.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",o);return}if(r.type!==i.type){s.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",o,r.type,i.type);return}if(r.type===O.SELECTBOX&&i.type===O.SELECTBOX){const a=i,c=r;a.options&&c.value!==void 0&&(new Set(a.options.map(u=>u.value)).has(c.value)||s.addIssue("INVALID_SELECTBOX_OPTION",c.value,o))}r.type===O.DECK&&df(r,i,s)})}function ff(e,t,n){e.design&&Object.entries(e.design).forEach(([o,r])=>{const s=n.at(["design",o]),i=t[o];if(!i){s.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",o);return}r.type!==i.type&&s.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",o,r.type,i.type)})}function hf(e,t){Object.entries(e).flatMap(([n,o])=>{switch(o.type){case w.ACCORDION:return Object.entries(o.items).flatMap(([r,s])=>Object.keys(s.editors).map(i=>({name:i,path:[n,"items",r,"editors",i]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},o,r)=>r.findIndex(s=>s.name===n)<o).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function mf(e,t,n){e.layoutId&&((t||[]).some(o=>o.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function Ef(e,t){const n=new Set;e.forEach((o,r)=>{if(n.has(o.showcaseId)){t.at([r,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",o.showcaseId);return}n.add(o.showcaseId)})}function Ts(e,t,n){for(const[o,r]of Object.entries(e)){const s=r;if(s.type===O.IMAGE){const i=t[o];if(i?.type===w.IMAGE){const a=s.static??!1,c=i.static??!1;a!==c&&n.at(o).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",o)}}else if(s.type===O.DECK){const i=s;i.cards?.defaultCardContent?.settings&&Ts(i.cards.defaultCardContent.settings,t,n.at([o,"cards","defaultCardContent","settings"]))}}}function gf(e,t,n){t>Gt&&n.at(z.basename(e)).addIssue("REQUIRED_SECTION_ASSET",Se(t),Se(Gt))}function _f(e,t){e>xt&&t.addIssue("REQUIRED_SERVER_SIZE",Se(e),Se(xt))}const yf=p({id:h(),type:bd,name:h(),content:Un,design:Fn,layout:A(Mn).optional(),showcase:A(Fp),translationsSettings:Bt.optional(),translationsShowcases:Bt.optional(),assets:wn.array().optional(),server:br,previewCount:he().optional()}).strict().superRefine((e,t)=>{const n=x(t),o=_s({validationType:tt.CONTENT,sectionType:e.type}),r=_s({validationType:tt.DESIGN,sectionType:e.type});ys(e.content,o,n.at("content")),ys(e.design,r,n.at("design")),Ts(e.content,e.design,n.at("content")),hf(e.design,n.at("design")),e.assets&&e.assets.forEach(i=>{gf(i.path,i.size,n.at("assets"))}),_f(e.server.size,n.at("server"));const s=e.assets?.map(i=>i.path)??[];Ss(e.content,s,n.at("content")),Ef(e.showcase,n.at("showcase")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);Ss(i,s,c),pf(i,e.content,c),ff(i,e.design,c),mf(i,e.layout,c)})}),Sf=p({translations:Bt.optional()}).strict(),Tf=U(["products","category","product"]),Of=p({id:h(),sectionId:h(),assets:wn.array().optional(),content:Un.optional(),design:Fn.optional(),translationsSettings:Bt.optional(),layouts:Mn.array().optional()}).strict().superRefine((e,t)=>{const n=x(t);nt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,nt.options.join(", ")),e.assets&&e.assets.forEach(o=>{o.size>Gt&&n.at(["assets",z.basename(o.path)]).addIssue("REQUIRED_SECTION_ASSET",Se(o.size),Se(Gt))})});p({id:h(),sectionId:nt,pageId:Tf,content:Un.optional(),design:Fn.optional(),layouts:Mn.array().optional()}).strict();const If=p({id:h(),sectionId:h(),layoutId:h(),server:br}).strict().superRefine((e,t)=>{const n=x(t);nt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,nt.options.join(", ")),e.server.size>xt&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",Se(e.server.size),Se(xt))});function wf(e,t,n){if(e){if(e.type==="default")e.id!=="header"&&n.at("id").addIssue("REQUIRED_HEADER_ID");else if(e.type==="custom"&&e.id){const o=t.find(r=>r.id===e.id);o?(o.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(r=>r.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_HEADER",e.id)}}}function vf(e,t,n){if(e){if(e.type==="default")e.id!=="footer"&&n.at("id").addIssue("REQUIRED_FOOTER_ID");else if(e.type==="custom"&&e.id){const o=t.find(r=>r.id===e.id);o?(o.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(r=>r.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER",e.id)}}}function Cf(e,t,n){if(!e)return;const o=n.at(["showcase_overrides"]);["content","design"].forEach(s=>{const i=e[s];if(i){const a=t[s]||{};Object.keys(i).forEach(c=>{if(!(c in a)){const u=s==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";o.at([s,c]).addIssue(u,c)}})}}),e.layoutId&&((t.layout||[]).some(s=>s.layoutId===e.layoutId)||o.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const r=t.assets?.map(s=>s.path)??[];e.content&&Lr(e.content,r,o.at(["content"]))}function Os(e,t,n,o=!1){if(!e.id)return;const r=t.find(s=>s.id===e.id);if(!r){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}!o&&(r.type==="HEADER"||r.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),Cf(e.showcase_overrides,r,n),e.showcase_id&&((r.showcase||[]).some(s=>s.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function Rf(e,t,n,o){e.id&&(n.some(r=>r.sectionId===t.type.toLowerCase()&&r.id===e.id)||o.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const bf=p({version:h(),name:h(),shared:Sf.optional(),sections:A(yf),templates:A(ef),layouts:A(Of),slots:A(If),collections:A(sf),compressionEnabled:v(),externalizationEnabled:v(),vueVersion:h(),openSource:v().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,o)=>{const r=x(t).at(["templates",o]);wf(n.configuration.header,e.sections,r.at(["configuration","header"])),vf(n.configuration.footer,e.sections,r.at(["configuration","footer"])),n.pages.forEach((s,i)=>{const a=r.at(["pages",i]);s.sections.forEach((c,u)=>{const d=a.at(["sections",u]);c.type==="custom"?Os(c,e.sections,d):c.type==="store"&&Rf(c,s,e.layouts,d)})})}),e.collections.forEach((n,o)=>{n.descriptor.sections.forEach((r,s)=>{const i=x(t).at(["collections",o,"sections",s]);Os(r,e.sections,i,!0)})})});ye({customError:Rd});const f={error:e=>console.log(_i(e)),warn:e=>console.log(gi(e)),info:e=>console.log(ce(e))},Af="dist",Nf="dist/shared",me="dist/sections",Gn="dist/headers",xn="dist/footers",Te="dist/templates",Be="layouts",Is="preview",Q=`dist/${Be}`,rt="dist/collections",ws="dist/manifest.json",$f=[me,Gn,xn,Te,Q];function Zt(e){return!!e}function Ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Df="Resource name can only contain alphanumeric characters, dashes, and underscores";function Lf(e){if(typeof e=="string"||typeof e=="number"){const t=/^[a-zA-Z0-9_-]+$/.test(e.toString());if(t)return{isValid:t,errorMessage:null}}return{isValid:!1,errorMessage:Df}}function kf(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function Pf(e){return z.parse(e).name}function zf(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Ht(){const e=await un(S(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function jf(e){return e.includes(`
|
|
40
|
+
`)}function Uf(e,t,n){return e.split(`
|
|
41
|
+
`).map((o,r)=>r>=n?t+o:o).join(`
|
|
42
|
+
`)}function $e(e,t){const n=[];if(e instanceof Eo){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const s=e.response?.data;if(s?.errorCode&&n.push(` Error Code: ${s.errorCode}`),s?.errorMessage){const i=jf(s.errorMessage)?Uf(s.errorMessage," ",1):s.errorMessage;n.push(` Error Message: ${i}`)}}const o=n.length>0?n.join(`
|
|
43
|
+
`):e?.message??"Unknown error";if(!t||t.length===0)return o;const r=n.length>0?`
|
|
44
|
+
`:" ";return`${t}${r}${o}`}function Bn(e,t){return Object.keys(e).reduce((n,o)=>{const r=e[o],s=t[o];return Ne(r)&&Ne(s)?n[o]=Bn(r,s):n[o]=r,n},{...t})}function Ff({contentSettings:e,sectionType:t}){const n=Es(t);return Bn(e,n)}function Mf({designSettings:e,sectionType:t}){const n=gs(t);return Bn(e,n)}async function re(e){return(await import(mo(e).href+`?t=${Date.now()}`)).default}function Zn(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function de(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=bi(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function vs(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:Number(e)}}function Gf(e){if(e!==void 0)return{...e,color:de(e.color)}}function st(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function xf(e){if(e!==void 0)switch(e){case cn.COLOR:return"solid";case cn.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(cn)}`)}}function Bf({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:xf(e),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Zf(e){if(e!==void 0)switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(Oi)}`)}}function Hf(e){if(e!==void 0)switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(Ii)}`)}}function Vf(e){if(e!==void 0)switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys(wi)}`)}}function Wf(e){const t=Zf(e.appearance),n=Hf(e.size),o=Vf(e.shape),r=Zn(e.font),s=de(e.color),i=e.visible;return st({appearance:t,size:n,style:o,font:r,color:s,visible:i})}function Yf(e){const t=de(e.color);return st({color:t})}function Kf(e){if(e!==void 0)switch(e){case mt.COLOR:return"solid";case mt.GRADIENT:return"gradient";case mt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(mt)}`)}}function Jf(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:Kf(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Xf(e){const t=Zn(e.font),n=de(e.color),o=vs(e.size),r=e.bold,s=e.italic,i=e.spacing,a=e.capitalization;return{font:t,color:n,size:o,frame:Gf(e.frame),bold:r,italic:s,spacing:i,capitalization:a}}function Qf(e){const t=e.value;return st({value:t})}function qf(e){const t=Zn(e.font),n=de(e.color),o=vs(e.size),r=e.bold,s=e.italic;return st({font:t,color:n,size:o,bold:r,italic:s})}function eh(e){const t=e.enabled;return st({enabled:t})}function Hn(e,t){if(t.defaults===void 0)return;let n={};switch(e){case q.TEXT:{n=qf(t.defaults);break}case q.BUTTON:{n=Wf(t.defaults);break}case q.IMAGE:{n=Jf(t.defaults);break}case q.BACKGROUND:{n=Bf(t.defaults);break}case q.COLOR_PICKER:{n=Yf(t.defaults);break}case q.LOGO:{n=Xf(t.defaults);break}case q.SELECTBOX:{n=Qf(t.defaults);break}case q.TOGGLE:{n=eh(t.defaults);break}case q.DIVIDER:case q.INFO:break;case q.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function Cs(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===q.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:Cs(c.editors)}]));t[n]={...o,items:i};return}const s=Hn(r,o);s&&o.defaults?t[n]={...o,defaults:s}:t[n]=o}),t}function th(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...Hn(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Vn(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===q.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:Vn(c.editors)??c.editors}]));t[n]={type:o.type,items:i};return}const s=Hn(r,{defaults:o});s!==void 0?t[n]={...o,...s,type:o.type}:t[n]=o}),t}function nh(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function oh(e){const t={};for(const n in e){const o=e[n];for(const r in o){const s=t[r],i=o[r];if(s===void 0){const a={};a[n]=i,t[r]=a}else s[n]=i}}return t}function rh(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function Ze(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return rh(e)?e:e.map(r=>Ze(r,t));const n=e,o={};for(const r in n){const s=n[r];typeof s=="string"&&s.startsWith("$")?o[r]=nh(t,s):typeof s=="object"&&s!==null?o[r]=Ze(s,t):o[r]=s}return o}async function it(e){return e?oh(e):{}}async function sh(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await re(n)}async function Vt(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await re(n)}async function ih(e,t){const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/translations.mjs`);if(H(n))return await re(n)}async function Wn(e,t,n){const o=n?Ff({contentSettings:e,sectionType:n}):e;return Ze(o,t)}async function ah(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/content.mjs`),o=await re(n);return ke(o)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Yn(e,t,n){const o=n?Mf({designSettings:e,sectionType:n}):e,r=Cs(o);return Ze(r,t)}async function ch(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/design.mjs`),o=await re(n);return ke(o)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function uh(e,t){return Promise.all(e.map(async n=>{const o=n.design?Vn(n.design):void 0,r={...n,design:o??n.design};return Ze(r,t)}))}async function lh(e,t=me){try{const n=await I("*.mjs",{cwd:S(F.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async o=>{const r=S(F.cwd(),`${t}/${e}/js/showcases/${o}`);return await re(r)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Rs(e){return e?.map(t=>({...t,selectedDesignSettings:th(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function dh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/layout.mjs`);return H(n)?await re(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function ph(e){let t={};const n=S(F.cwd(),`${Is}/shared/analytics.json`);if(!H(n))return 0;try{const o=on(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}const He={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Kn="https://blockbuster.ecwid.com",fh="/api/v1/custom-apps/resources/sections/upload",hh="/api/v1/custom-apps/resources/templates/upload",mh="/api/v1/custom-apps/manifests/sections",Eh="/api/v1/custom-apps/manifests/templates",gh=5,_h=3,yh=[R.Server,R.Client,R.ClientChunks,R.ClientAsset,R.Asset],Sh=[R.LayoutClient,R.LayoutAsset],Th=[R.SlotServer,R.SlotClient,R.SlotClientChunks,R.SlotClientAsset],Oh=[R.Dependency,R.TemplateAsset,R.SourceCode,R.CollectionAsset],Ve={DEFAULT:"Error while deploying:",ASSET_FILES_UPLOAD:"Error while uploading asset files:",MANIFEST_DEPLOYMENT:"Error while deploying manifest file:",DEPRECATED_VERSION_DEPLOYMENT:"You are using a non-supported version of crane. Please update to the latest crane version to continue.",INCORRECT_DISTRIBUTION_FOLDER:e=>`Distribution folder [${e}] is not found or has incorrect structure, please execute the build command first.`},bs={catalog:"products",category:"category",product:"product"},As=e=>bs[e],Ns=e=>e in bs;function Ih(e){return e.replace(/\\/g,"/")}function wh(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Wt(e){return wh(Ih(e))}function vh(e){const t=Wt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t;if(!Ns(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const r=As(n);return{id:o,sectionId:n,pageId:r}}async function Ch(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=As(n),r=await it(t.translationsSettings),s=await Wn(t.content??{},r),i=await Yn(t.design??{},r),a=await Rs(t.layouts);return{id:t.id,sectionId:n,pageId:o,contentEditors:s,designEditors:i,layouts:a}}))}function We(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${Q}/${e}/${t}/${n.join("/")}`}const at=(e=_e.SECTION)=>G[e].dist,ct={[R.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/server/`},[R.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/`},[R.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[R.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/assets/`},[R.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/assets/`},[R.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Te}/assets/`},[R.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[R.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[R.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>We(e,t,"")},[R.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>We(e,t,"assets/")},[R.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/server/")},[R.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/")},[R.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/chunks/")},[R.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/assets/")},[R.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${rt}/assets/`}};function Rh(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function Jn(){const e=S(Et.cwd(),"package.json"),t=await un(e),n=JSON.parse(t.toString());if(Rh(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const bh={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Ah(e,t){const n=bh[e];return n?n(t):t.id}const Nh=new Set(["content","design"]);function Yt(e,t,n=0,o=[]){if(n>=t.length)return o;const r=t[n],s=t[n+1];if(typeof r=="string"&&typeof s=="number"&&Ne(e)){const i=e[r],a=Array.isArray(i)?i[s]:void 0;if(Ne(a)){const c=Ah(r,a);return o.push(`${r}[${c||s}]`),Yt(a,t,n+2,o)}}if(typeof r=="string"&&typeof s=="string"&&Nh.has(r)){o.push(`${r}[${s}]`);const i=Ne(e)&&!Array.isArray(e)?e[r]:void 0,a=Ne(i)&&!Array.isArray(i)?i[s]:void 0;return Yt(a,t,n+2,o)}return o.push(r),Yt(Ne(e)?e[r]:void 0,t,n+1,o)}function $h(e){const t=e.errors.map(o=>Yt(e.manifest,o.path).join(".")),n={path:Math.max(...t.map(o=>o.length),0),message:Math.max(...e.errors.map(o=>o.message.length),0)};e.errors.map((o,r)=>{const s=o.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[r].padEnd(n.path," ")} | ${o.message.padEnd(n.message," ")} | ${s}`}).forEach(o=>f.error(o))}async function Dh(e){const t=bf.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const Lh=`Build successful:
|
|
45
45
|
For preview run: npx @lightspeed/crane@latest preview
|
|
46
|
-
For deploy run: npx @lightspeed/crane@latest deploy`;function
|
|
47
|
-
`),n=t.filter(
|
|
48
|
-
`),n=[];for(let
|
|
49
|
-
`,0),a=-1;for(;
|
|
50
|
-
`,
|
|
51
|
-
`?(
|
|
52
|
-
`);if(n.length>1){for(let
|
|
53
|
-
`,
|
|
54
|
-
`));else for(a=c.start;a<u;){if(!
|
|
55
|
-
`?
|
|
56
|
-
${
|
|
57
|
-
`,Lg=(e,t)=>{const n=e.split("?")[0],r=Ua(n);return(r==="server.ts"||r==="client.ts")&&!t.includes(Wi)},Ki=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=$e(Vi)},transform(t,n){if(!e||!Lg(n,t))return null;const r=n.split("?")[0],o=wo(r),i=Ba(Io(o,Vi)),s=Ng(i),a=new vo(t);return a.prepend(s),{code:a.toString()}}}},Yi={[Be.Server]:()=>[tt.vue(),tt.tsconfigPaths(),yg(),gg(),Ki()],[Be.Client]:()=>[tt.vue(),tt.tsconfigPaths(),ko({vue:"EcVue"}),Ki()],[Be.Misc]:()=>[tt.tsconfigPaths()],[Be.Layout]:()=>[tt.vue(),tt.tsconfigPaths(),ko({vue:["EcExternals","Vue"]})],[Be.Asset]:()=>[Sg()],[Be.SharedFiles]:()=>[tt.tsconfigPaths()]},Xi={[pe.Server]:Fi({outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/main/server`}),[pe.Client]:Gi({outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/main/client`}),[pe.SectionSetting]:Ht({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/settings`}),[pe.SectionShowcase]:Ht({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/showcases`}),[pe.SectionAsset]:Vn({outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/assets`}),[pe.TemplateDescriptor]:Ht({entryFileNames:"[name].mjs",outDir:()=>`./${ft}/js`}),[pe.PageTemplateDescriptor]:Ht({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${ft}/${e}`}),[pe.TemplateAsset]:Vn({outDir:()=>`./${ft}/assets`}),[pe.Layout]:cg({outDir:({name:e,sectionId:t})=>`./${je}/${t}/${e}`}),[pe.LayoutSettings]:Ht({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${je}/${t}/${e}/js/settings`}),[pe.LayoutAsset]:Vn({outDir:({name:e,sectionId:t})=>`./${je}/${t}/${e}/assets`}),[pe.SlotServer]:Fi({outDir:({name:e,layoutId:t,sectionId:n})=>`./${je}/${n}/${t}/slots/${e}/js/main/server`}),[pe.SlotClient]:Gi({outDir:({name:e,layoutId:t,sectionId:n})=>`./${je}/${n}/${t}/slots/${e}/js/main/client`}),[pe.CollectionDescriptor]:Ht({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Jt}/${e}`}),[pe.CollectionAsset]:Vn({outDir:()=>`./${Jt}/assets`}),[pe.SharedTranslation]:{pluginType:Be.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function Dg(e){switch(typeof e){case"string":return[j(process.cwd(),e)];case"object":return e.map(t=>j(process.cwd(),t));default:return[]}}function Qi({name:e,entryPoints:t,configType:n,layoutId:r,sectionId:o,sectionType:i=ut.SECTION}){const s=Xi[n],a=s.define,c=s.ssrOptions,u=s.entryFileNames,f=s.chunkFileNames,h=s.assetFileNames,T=s.inlineDynamicImports,w=s.externalOption;return{logLevel:Kr()?void 0:"silent",plugins:Yi[s.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:s.ssr,outDir:s.outDir({name:e,sectionType:i,layoutId:r,sectionId:o}),emptyOutDir:!0,minify:s.ssr?"terser":"esbuild",...s.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:w,preserveEntrySignatures:"strict",input:Dg(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:T,entryFileNames:u,chunkFileNames:f,assetFileNames:h}}},assetsInclude:["**/*.json"]}}const kg=Object.values(we).map(e=>e.source).join("|");function qi(e,t,n){if(!e)return`${t}.mjs`;const r=Io(process.cwd(),e).replace(/\\/g,"/").match(`^(${kg})/([^/]+)/${n}/([^/.]+)`);return r?`${r[1]}/${r[2]}/js/${n}/${r[3]}.mjs`:`${t}.mjs`}function Ji(e,t){const n=Xi[pe.SectionSetting];return{logLevel:Kr()?void 0:"silent",plugins:Yi[n.pluginType](),define:n.define,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:n.ssr,outDir:"./dist",emptyOutDir:!1,minify:"esbuild",rollupOptions:{external:n.externalOption,preserveEntrySignatures:"strict",input:e.map(r=>j(process.cwd(),r)),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:n.inlineDynamicImports,entryFileNames:t,chunkFileNames:"chunks/[name]-[hash].js",assetFileNames:n.assetFileNames}}},assetsInclude:["**/*.json"]}}function Pg(e){return Ji(e,t=>qi(t.facadeModuleId??void 0,t.name,"settings"))}function xg(e){return Ji(e,t=>qi(t.facadeModuleId??void 0,t.name,"showcases"))}async function zg(){const e={ignore:["node_modules/**","dist/**"]},t=await W(`./${Mt}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:r,sectionId:o,pageId:i}=Xm(n),[s,a]=await Promise.all([W(`./${Mt}/${o}/${r}/settings/{content,design,translations}.{js,ts}`,e),W(`./${Mt}/${o}/${r}/assets/*`,e)]);return{name:r,sectionId:o,pageId:i,clientEntrypoint:n,settingsEntryPoints:s,assetsEntrypoints:a}}))}async function Mg(e){await Ke({entryPoints:[e.clientEntrypoint],configType:pe.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([Ke({entryPoints:e.settingsEntryPoints,configType:pe.LayoutSettings,name:e.name,sectionId:e.sectionId}),Ke({entryPoints:e.assetsEntrypoints,configType:pe.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function Ug(e){e===void 0||e.length===0||await Promise.all(e.map(t=>Mg(t)))}async function jg(e){const t=e.flatMap(r=>r.settingsEntryPoints),n=e.flatMap(r=>r.showcaseEntryPoints);t.length>0&&await ct({configFile:!1,...pn(Pg(t))}),n.length>0&&await ct({configFile:!1,...pn(xg(n))})}async function Fg(e){await Promise.all([ct({configFile:!1,...pn(Qi({name:e.name,entryPoints:e.serverEntrypoint,configType:jt.Server,sectionType:e.type}))}),Ke({entryPoints:e.clientEntrypoint,configType:jt.Client,name:e.name,sectionType:e.type}),Ke({entryPoints:e.assetEntryPoints,configType:jt.SectionAsset,name:e.name,sectionType:e.type})])}async function Gg(){const e=j(process.cwd(),"shared/translation.ts");$e(e)&&await Ke({entryPoints:["shared/translation.ts"],configType:jt.SharedTranslation})}async function ea(e){await Promise.all([jg(e),...e.map(Fg)])}function Hg(e){const t=Bn(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t;if(!Ui(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:o,sectionId:n,layoutId:r}}async function Bg(e,t){return Promise.all(e.map(async n=>{const r=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),o=await tn(r?.translationsSettings),i=await Br(r?.content??{},o),s=await Zr(r?.design??{},o);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:i,designEditors:s}}))}async function Zg(){const e={ignore:["node_modules/**","dist/**"]},t=await W(`${Mt}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:r,sectionId:o,layoutId:i}=Hg(n),s=(await W(`${Mt}/${o}/${i}/slots/${r}/client.{js,ts}`,e))[0];if(s===void 0)throw new Error(`Cannot find client entrypoint file for slot ${r} of section ${o}`);return{id:r,sectionId:o,layoutId:i,serverEntrypoint:n,clientEntrypoint:s}}))}async function Vg(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([Ke({entryPoints:[e.serverEntrypoint],configType:pe.SlotServer,...t}),Ke({entryPoints:[e.clientEntrypoint],configType:pe.SlotClient,...t})])}async function Wg(e){e?.length&&await Promise.all(e.map(Vg))}async function Kg(e){return(await W(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=Ao(t).name.toLowerCase();return!Object.values(Us).includes(n)})}async function Yg(){const e=await W("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(I.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(sr),r=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const o=await W(`**/templates/${r}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await W(`**/templates/${r}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await W(`**/templates/${r}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await W(`**/templates/${r}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await W(`**/templates/${r}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await Kg(r);return{name:r,configurationEntrypoint:o.at(0),homeEntrypoint:i.at(0),categoryEntrypoint:s.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:u.length>0?u:void 0}}))}async function Xg(){const e=await W("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await W("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Yg(),templates:e,assets:t}}async function Qg({templateBuildConfig:e}){await Promise.all([Ke({entryPoints:e.assets,configType:jt.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Fn);if(n.length===0)throw new Error("No entry points provided for page template");await Ke({entryPoints:n,configType:jt.PageTemplateDescriptor,name:t.name})})||[]])}async function qg(){const e=await Xg();await Qg({templateBuildConfig:e})}async function Jg(){const e=await W("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(I.error(`Error while getting collection entry points: ${n}`),[])),t=await W("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const r=n.split(sr),o=r.pop()??"default";if(r.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const i=await W(`**/collections/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:o,configurationEntrypoint:i.at(0),assetsEntrypoints:t}}))}async function eE(){const e=await Jg();e.length!==0&&await Promise.all(e.flatMap(t=>[Ke({entryPoints:t.assetsEntrypoints,configType:pe.CollectionAsset,name:t.name}),Ke({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:pe.CollectionDescriptor,name:t.name})]))}function ta(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Fn).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Fn),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Fn),assetEntryPoints:e.assetsEntrypoints??[]}}function tE(e){return e.map(t=>({...t,selectedDesignSettings:t.selectedDesignSettings.map(n=>{const r=n.defaults;return r&&typeof r=="object"&&!("type"in r)?{...n,defaults:{type:n.type,...r}}:n})}))}async function nE(e,t=st){const n=j(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),r=Po(xo.gunzip),o=await ie.promises.readFile(n);return{size:(await r(o)).length}}async function rE(e,t=st){try{const n=j(process.cwd(),`${t}/${e}/assets/`);return(await W("*",{cwd:n})).map(r=>{const o=j(n,r);return{path:r,size:Vt(o).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Yr(e,t){const n=await bm(e,we[t].dist),r=await Hn(e,we[t].dist),o=await Nm(e,we[t].dist),i=await Lm(e,we[t].dist),s=await km(e,we[t].dist),a=await xm(e,we[t].dist),c=tE(a),u=await rE(e,we[t].dist),f=await nE(e,we[t].dist),h=zm(e);return{id:e,type:t,name:e,content:o,design:i,layout:c,showcase:s,translationsSettings:n,translationsShowcases:r,assets:u,server:f,previewCount:h}}async function oE(){const e=await W("*/",{cwd:j(process.cwd(),`${st}/`)}),t=await W("*/",{cwd:j(process.cwd(),`${Mr}/`)}),n=await W("*/",{cwd:j(process.cwd(),`${Ur}/`)});return Promise.all([...e.map(async r=>Yr(r,zt.SECTION)),...t.map(async r=>Yr(r,zt.HEADER)),...n.map(async r=>Yr(r,zt.FOOTER))])}async function sE(e){try{const t=j(process.cwd(),`${e}/assets/`);return(await W("*",{cwd:t})).map(n=>{const r=j(t,n);return{path:n,size:Vt(r).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function iE(e){const t=Bn(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t,[o,i,s,a]=await Promise.all([cE(r,n),uE(r,n),$m(r,n),sE(e)]);return{id:r,sectionId:n,content:o,design:i,translationsSettings:s,assets:a}}async function aE(){const e=`${je}/{product,catalog,category}/*`,t=await W(e,{ignore:["node_modules/**"]});return Promise.all(t.map(iE))}async function cE(e,t){try{const n=j(process.cwd(),`${je}/${t}/${e}/js/settings/content.mjs`),r=await Je(n);return bt(r)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function uE(e,t){try{const n=j(process.cwd(),`${je}/${t}/${e}/js/settings/design.mjs`),r=await Je(n);return bt(r)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function lE(e,t,n){const r=j(process.cwd(),`${je}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),o=Po(xo.gunzip),i=await ie.promises.readFile(r);return{size:(await o(i)).length}}async function pE(e){const t=Bn(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t,i=await lE(o,r,n);return{id:o,sectionId:n,layoutId:r,server:i}}async function fE(){const e=`${je}/{product,catalog,category}/*/slots/*`,t=await W(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(pE))}async function dE(){try{const e=j(process.cwd(),`${ft}/assets/`);return(await W("*",{cwd:e})).map(t=>{const n=j(e,t);return{path:t,size:Vt(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function hE(e){return e in Ot?Ot[e]:Ot.CUSTOM}async function mE(e){const t=await W(`${ft}/${e}/*.mjs`,{ignore:[`${ft}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:r,metadata:o}=await Xr(n),i=sm(n);return{type:hE(i.toUpperCase()),id:i,metadata:o,sections:r}}))}async function Xr(e){try{return await Je(j(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function gE(e){const t=await W(`${ft}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=le.basename(le.dirname(n));return{id:`${e}_${r}`,assets:await dE(),configuration:await Xr(n),pages:await mE(r)}}))}async function EE(e){return await gE(e)}async function _E(){const e=j(process.cwd(),`${em}/translation.mjs`);return await Je(e)}async function yE(){return{translations:await _E()}}async function SE(e){const t=await W(`${Jt}/*/configuration*.mjs`,{ignore:["node_modules/**",`${Jt}/assets/**`]});return Promise.all(t.map(async n=>{const r=le.basename(le.dirname(n)),o=await Xr(n);return{id:`${e}_${r}`,descriptor:o}}))}async function TE(){const e=await Gn(),[t,n,r,o,i,s,a]=await Promise.all([Wr(),yE(),oE(),aE(),fE(),EE(e.appClientId),SE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:r,templates:s,layouts:o,slots:i,collections:a,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue,openSource:t.openSource}}function Qr(e){return $e(`${Mr}/${e}`)?ut.HEADER:$e(`${Ur}/${e}`)?ut.FOOTER:ut.SECTION}async function qr(e,t){const n=e.design?Hr(e.design):void 0,r={...e,design:n??e.design},o=await tn(t);return Ut(r,o)}function Jr(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function na(e){if(Jr(e)){const t=await Hn(e.id,we[Qr(e.id)].dist);return{...e,showcase_overrides:await qr(e.showcase_overrides,t)}}return e}async function RE(e){const t=Jr(e.header)?{...e.header,showcase_overrides:await qr(e.header.showcase_overrides,await Hn(e.header.id,we[Qr(e.header.id)].dist))}:e.header,n=Jr(e.footer)?{...e.footer,showcase_overrides:await qr(e.footer.showcase_overrides,await Hn(e.footer.id,we[Qr(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function OE(e){const t=await Promise.all(e.pages.map(async r=>({...r,sections:await Promise.all(r.sections.map(o=>na(o)))}))),n=await RE(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function vE(e){return Promise.all(e.map(t=>OE(t)))}async function CE(e){const t=new Map;return await Promise.all(e.map(async n=>{const[r,o]=await Promise.all([tn(n.translationsSettings),tn(n.translationsShowcases)]);t.set(n.id,{settings:r,showcases:o})})),t}async function wE(e,t,n){const[r,o,i,s]=await Promise.all([Br(e.content,t,e.type),Zr(e.design,t,e.type),Dm(e.showcase,n),Pm(e.layout)]);return{id:e.id,type:e.type,name:{en:e.name},contentEditors:r,designEditors:o,layouts:s,showcases:i,previewCount:e.previewCount}}async function IE(e,t){return Promise.all(e.map(async n=>{const r=t.get(n.id)??{settings:{},showcases:{}};return wE(n,r.settings,r.showcases)}))}async function AE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(r=>na(r)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function bE(e){const t=await CE(e.sections),[n,r,o,i,s]=await Promise.all([IE(e.sections,t),Qm(e.layouts),Bg(e.slots,e.layouts),vE(e.templates),AE(e.collections)]);return{version:e.version,name:e.name,blocks:n,templates:i,layouts:r,slots:o,compressionEnabled:e.compressionEnabled,externalizationEnabled:e.externalizationEnabled,vueVersion:e.vueVersion,collections:s,openSource:e.openSource}}async function $E(e){const t=j(dn.cwd(),ki);return Xa(t,JSON.stringify(e))}function NE(e){return Object.entries(we).find(t=>t[1].source===e)?.[0]}async function ra(){const e=await W("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=wo(t).split(sr),r=n.pop()??"default",o=n.pop();if(o===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const i=["node_modules/**","dist/**"],[s,a,c,u,f,h,T,w]=await Promise.all([W(`**/${r}/client.{js,ts}`,{ignore:i}),W(`**/${r}/settings/content.{js,ts}`,{ignore:i}),W(`**/${r}/settings/design.{js,ts}`,{ignore:i}),W(`**/${r}/settings/layout.{js,ts}`,{ignore:i}),W(`**/${r}/settings/translations.{js,ts}`,{ignore:i}),W(`**/${r}/showcases/*.{js,ts}`,{ignore:[...i,`**/${r}/showcases/translations.{js,ts}`]}),W(`**/${r}/showcases/translations.{js,ts}`,{ignore:i}),W(`**/${r}/assets/*`,{ignore:i})]);return{name:r,type:NE(o),serverEntrypoint:t,clientEntrypoint:s.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:u.at(0),settingsTranslationsEntrypoint:f.at(0),showcasesEntrypoints:h,showcasesTranslationsEntrypoint:T.at(0),assetsEntrypoints:w}}))}const LE=["/settings/","/showcases/"];function DE(e){return LE.some(t=>e.includes(t))}function kE(){const e=qe.findConfigFile(process.cwd(),qe.sys.fileExists,"tsconfig.json");if(!e)return;const t=qe.readConfigFile(e,qe.sys.readFile),n=qe.parseJsonConfigFileContent(t.config,qe.sys,process.cwd()),r=qe.createProgram(n.fileNames,n.options),o=qe.getPreEmitDiagnostics(r).filter(i=>!i.file||!DE(i.file.fileName));if(o.length>0){const i={getCanonicalFileName:s=>s,getCurrentDirectory:qe.sys.getCurrentDirectory,getNewLine:()=>qe.sys.newLine};throw console.error(qe.formatDiagnosticsWithColorAndContext(o,i)),new Error(`TypeScript found ${o.length} error(s)`)}}async function PE(e){kE(),await ct({configFile:!1,logLevel:"error",plugins:[tt.vue(),tt.tsconfigPaths(),tt.checker()],build:{write:!1,rollupOptions:{input:j(process.cwd(),e)}}})}function xE(){return Promise.all([rr.rm("dist",{recursive:!0,force:!0}),rr.rm("source-code",{recursive:!0,force:!0}),rr.rm("source-code.zip",{force:!0})])}async function zE(){const e=new bo,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"];(await Wr()).openSource===!0&&t.splice(t.indexOf("**/assets/**/*"),1);const n=await W("**/*",{cwd:j(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(i=>{const s=j(process.cwd(),i);e.addLocalFile(s,Ao(i).dir)});const r=rn[ee.SourceCode].fileName,o=j(process.cwd(),r);await e.writeZipPromise(o)}catch(r){throw I.error("Error while zipping source files"),r}}async function Kn(e=!1,t=!1){ug(t),Bi.start(),await xE();try{const[n,r,o]=await Promise.all([zg(),ra(),Zg()]),i=r.map(ta);r.length>0&&await PE(r[0].serverEntrypoint);try{await Promise.all([Gg(),ea(i),qg(),eE(),Ug(n),Wg(o),zE()])}finally{Bi.stop()}const s=await TE(),a=await rg(s);sg(a,e);const c=await bE(s);await $E(c)}catch(n){I.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function Ke({entryPoints:e,configType:t,name:n,sectionType:r,sectionId:o,layoutId:i}){if(e.length!==0){const s=pn(Qi({name:n,entryPoints:e,configType:t,sectionType:r,sectionId:o,layoutId:i}));await ct({configFile:!1,...s})}}function ME(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var eo={},oa;function to(){return oa||(oa=1,(function(e){e.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1,e.find=(t,n)=>t.nodes.find(r=>r.type===n),e.exceedsLimit=(t,n,r=1,o)=>o===!1||!e.isInteger(t)||!e.isInteger(n)?!1:(Number(n)-Number(t))/Number(r)>=o,e.escapeNode=(t,n=0,r)=>{const o=t.nodes[n];o&&(r&&o.type===r||o.type==="open"||o.type==="close")&&o.escaped!==!0&&(o.value="\\"+o.value,o.escaped=!0)},e.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1,e.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1,e.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0,e.reduce=t=>t.reduce((n,r)=>(r.type==="text"&&n.push(r.value),r.type==="range"&&(r.type="text"),n),[]),e.flatten=(...t)=>{const n=[],r=o=>{for(let i=0;i<o.length;i++){const s=o[i];if(Array.isArray(s)){r(s);continue}s!==void 0&&n.push(s)}return n};return r(t),n}})(eo)),eo}var no,sa;function ro(){if(sa)return no;sa=1;const e=to();return no=(t,n={})=>{const r=(o,i={})=>{const s=n.escapeInvalid&&e.isInvalidBrace(i),a=o.invalid===!0&&n.escapeInvalid===!0;let c="";if(o.value)return(s||a)&&e.isOpenOrClose(o)?"\\"+o.value:o.value;if(o.value)return o.value;if(o.nodes)for(const u of o.nodes)c+=r(u);return c};return r(t)},no}/*!
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
61
|
-
* Released under the MIT License.
|
|
62
|
-
*/var oo,ia;function UE(){return ia||(ia=1,oo=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}),oo}/*!
|
|
63
|
-
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
64
|
-
*
|
|
65
|
-
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
66
|
-
* Released under the MIT License.
|
|
67
|
-
*/var so,aa;function jE(){if(aa)return so;aa=1;const e=UE(),t=(b,v,R)=>{if(e(b)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(v===void 0||b===v)return String(b);if(e(v)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let p={relaxZeros:!0,...R};typeof p.strictZeros=="boolean"&&(p.relaxZeros=p.strictZeros===!1);let l=String(p.relaxZeros),d=String(p.shorthand),E=String(p.capture),m=String(p.wrap),C=b+":"+v+"="+l+d+E+m;if(t.cache.hasOwnProperty(C))return t.cache[C].result;let $=Math.min(b,v),U=Math.max(b,v);if(Math.abs($-U)===1){let F=b+"|"+v;return p.capture?`(${F})`:p.wrap===!1?F:`(?:${F})`}let K=k(b)||k(v),G={min:b,max:v,a:$,b:U},D=[],te=[];if(K&&(G.isPadded=K,G.maxLen=String(G.max).length),$<0){let F=U<0?Math.abs(U):1;te=i(F,Math.abs($),G,p),$=G.a=0}return U>=0&&(D=i($,U,G,p)),G.negatives=te,G.positives=D,G.result=n(te,D),p.capture===!0?G.result=`(${G.result})`:p.wrap!==!1&&D.length+te.length>1&&(G.result=`(?:${G.result})`),t.cache[C]=G,G.result};function n(b,v,R){let p=s(b,v,"-",!1)||[],l=s(v,b,"",!1)||[],d=s(b,v,"-?",!0)||[];return p.concat(d).concat(l).join("|")}function r(b,v){let R=1,p=1,l=f(b,R),d=new Set([v]);for(;b<=l&&l<=v;)d.add(l),R+=1,l=f(b,R);for(l=h(v+1,p)-1;b<l&&l<=v;)d.add(l),p+=1,l=h(v+1,p)-1;return d=[...d],d.sort(c),d}function o(b,v,R){if(b===v)return{pattern:b,count:[],digits:0};let p=a(b,v),l=p.length,d="",E=0;for(let m=0;m<l;m++){let[C,$]=p[m];C===$?d+=C:C!=="0"||$!=="9"?d+=w(C,$):E++}return E&&(d+=R.shorthand===!0?"\\d":"[0-9]"),{pattern:d,count:[E],digits:l}}function i(b,v,R,p){let l=r(b,v),d=[],E=b,m;for(let C=0;C<l.length;C++){let $=l[C],U=o(String(E),String($),p),K="";if(!R.isPadded&&m&&m.pattern===U.pattern){m.count.length>1&&m.count.pop(),m.count.push(U.count[0]),m.string=m.pattern+T(m.count),E=$+1;continue}R.isPadded&&(K=M($,R,p)),U.string=K+U.pattern+T(U.count),d.push(U),E=$+1,m=U}return d}function s(b,v,R,p,l){let d=[];for(let E of b){let{string:m}=E;!p&&!u(v,"string",m)&&d.push(R+m),p&&u(v,"string",m)&&d.push(R+m)}return d}function a(b,v){let R=[];for(let p=0;p<b.length;p++)R.push([b[p],v[p]]);return R}function c(b,v){return b>v?1:v>b?-1:0}function u(b,v,R){return b.some(p=>p[v]===R)}function f(b,v){return Number(String(b).slice(0,-v)+"9".repeat(v))}function h(b,v){return b-b%Math.pow(10,v)}function T(b){let[v=0,R=""]=b;return R||v>1?`{${v+(R?","+R:"")}}`:""}function w(b,v,R){return`[${b}${v-b===1?"":"-"}${v}]`}function k(b){return/^-?(0+)\d/.test(b)}function M(b,v,R){if(!v.isPadded)return b;let p=Math.abs(v.maxLen-String(b).length),l=R.relaxZeros!==!1;switch(p){case 0:return"";case 1:return l?"0?":"0";case 2:return l?"0{0,2}":"00";default:return l?`0{0,${p}}`:`0{${p}}`}}return t.cache={},t.clearCache=()=>t.cache={},so=t,so}/*!
|
|
68
|
-
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
69
|
-
*
|
|
70
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
71
|
-
* Licensed under the MIT License.
|
|
72
|
-
*/var io,ca;function ua(){if(ca)return io;ca=1;const e=zo,t=jE(),n=p=>p!==null&&typeof p=="object"&&!Array.isArray(p),r=p=>l=>p===!0?Number(l):String(l),o=p=>typeof p=="number"||typeof p=="string"&&p!=="",i=p=>Number.isInteger(+p),s=p=>{let l=`${p}`,d=-1;if(l[0]==="-"&&(l=l.slice(1)),l==="0")return!1;for(;l[++d]==="0";);return d>0},a=(p,l,d)=>typeof p=="string"||typeof l=="string"?!0:d.stringify===!0,c=(p,l,d)=>{if(l>0){let E=p[0]==="-"?"-":"";E&&(p=p.slice(1)),p=E+p.padStart(E?l-1:l,"0")}return d===!1?String(p):p},u=(p,l)=>{let d=p[0]==="-"?"-":"";for(d&&(p=p.slice(1),l--);p.length<l;)p="0"+p;return d?"-"+p:p},f=(p,l,d)=>{p.negatives.sort((U,K)=>U<K?-1:U>K?1:0),p.positives.sort((U,K)=>U<K?-1:U>K?1:0);let E=l.capture?"":"?:",m="",C="",$;return p.positives.length&&(m=p.positives.map(U=>u(String(U),d)).join("|")),p.negatives.length&&(C=`-(${E}${p.negatives.map(U=>u(String(U),d)).join("|")})`),m&&C?$=`${m}|${C}`:$=m||C,l.wrap?`(${E}${$})`:$},h=(p,l,d,E)=>{if(d)return t(p,l,{wrap:!1,...E});let m=String.fromCharCode(p);if(p===l)return m;let C=String.fromCharCode(l);return`[${m}-${C}]`},T=(p,l,d)=>{if(Array.isArray(p)){let E=d.wrap===!0,m=d.capture?"":"?:";return E?`(${m}${p.join("|")})`:p.join("|")}return t(p,l,d)},w=(...p)=>new RangeError("Invalid range arguments: "+e.inspect(...p)),k=(p,l,d)=>{if(d.strictRanges===!0)throw w([p,l]);return[]},M=(p,l)=>{if(l.strictRanges===!0)throw new TypeError(`Expected step "${p}" to be a number`);return[]},b=(p,l,d=1,E={})=>{let m=Number(p),C=Number(l);if(!Number.isInteger(m)||!Number.isInteger(C)){if(E.strictRanges===!0)throw w([p,l]);return[]}m===0&&(m=0),C===0&&(C=0);let $=m>C,U=String(p),K=String(l),G=String(d);d=Math.max(Math.abs(d),1);let D=s(U)||s(K)||s(G),te=D?Math.max(U.length,K.length,G.length):0,F=D===!1&&a(p,l,E)===!1,H=E.transform||r(F);if(E.toRegex&&d===1)return h(u(p,te),u(l,te),!0,E);let B={negatives:[],positives:[]},Te=re=>B[re<0?"negatives":"positives"].push(Math.abs(re)),Xe=[],xe=0;for(;$?m>=C:m<=C;)E.toRegex===!0&&d>1?Te(m):Xe.push(c(H(m,xe),te,F)),m=$?m-d:m+d,xe++;return E.toRegex===!0?d>1?f(B,E,te):T(Xe,null,{wrap:!1,...E}):Xe},v=(p,l,d=1,E={})=>{if(!i(p)&&p.length>1||!i(l)&&l.length>1)return k(p,l,E);let m=E.transform||(F=>String.fromCharCode(F)),C=`${p}`.charCodeAt(0),$=`${l}`.charCodeAt(0),U=C>$,K=Math.min(C,$),G=Math.max(C,$);if(E.toRegex&&d===1)return h(K,G,!1,E);let D=[],te=0;for(;U?C>=$:C<=$;)D.push(m(C,te)),C=U?C-d:C+d,te++;return E.toRegex===!0?T(D,null,{wrap:!1,options:E}):D},R=(p,l,d,E={})=>{if(l==null&&o(p))return[p];if(!o(p)||!o(l))return k(p,l,E);if(typeof d=="function")return R(p,l,1,{transform:d});if(n(d))return R(p,l,0,d);let m={...E};return m.capture===!0&&(m.wrap=!0),d=d||m.step||1,i(d)?i(p)&&i(l)?b(p,l,d,m):v(p,l,Math.max(Math.abs(d),1),m):d!=null&&!n(d)?M(d,m):R(p,l,1,d)};return io=R,io}var ao,la;function FE(){if(la)return ao;la=1;const e=ua(),t=to();return ao=(r,o={})=>{const i=(s,a={})=>{const c=t.isInvalidBrace(a),u=s.invalid===!0&&o.escapeInvalid===!0,f=c===!0||u===!0,h=o.escapeInvalid===!0?"\\":"";let T="";if(s.isOpen===!0)return h+s.value;if(s.isClose===!0)return console.log("node.isClose",h,s.value),h+s.value;if(s.type==="open")return f?h+s.value:"(";if(s.type==="close")return f?h+s.value:")";if(s.type==="comma")return s.prev.type==="comma"?"":f?s.value:"|";if(s.value)return s.value;if(s.nodes&&s.ranges>0){const w=t.reduce(s.nodes),k=e(...w,{...o,wrap:!1,toRegex:!0,strictZeros:!0});if(k.length!==0)return w.length>1&&k.length>1?`(${k})`:k}if(s.nodes)for(const w of s.nodes)T+=i(w,s);return T};return i(r)},ao}var co,pa;function GE(){if(pa)return co;pa=1;const e=ua(),t=ro(),n=to(),r=(i="",s="",a=!1)=>{const c=[];if(i=[].concat(i),s=[].concat(s),!s.length)return i;if(!i.length)return a?n.flatten(s).map(u=>`{${u}}`):s;for(const u of i)if(Array.isArray(u))for(const f of u)c.push(r(f,s,a));else for(let f of s)a===!0&&typeof f=="string"&&(f=`{${f}}`),c.push(Array.isArray(f)?r(u,f,a):u+f);return n.flatten(c)};return co=(i,s={})=>{const a=s.rangeLimit===void 0?1e3:s.rangeLimit,c=(u,f={})=>{u.queue=[];let h=f,T=f.queue;for(;h.type!=="brace"&&h.type!=="root"&&h.parent;)h=h.parent,T=h.queue;if(u.invalid||u.dollar){T.push(r(T.pop(),t(u,s)));return}if(u.type==="brace"&&u.invalid!==!0&&u.nodes.length===2){T.push(r(T.pop(),["{}"]));return}if(u.nodes&&u.ranges>0){const b=n.reduce(u.nodes);if(n.exceedsLimit(...b,s.step,a))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let v=e(...b,s);v.length===0&&(v=t(u,s)),T.push(r(T.pop(),v)),u.nodes=[];return}const w=n.encloseBrace(u);let k=u.queue,M=u;for(;M.type!=="brace"&&M.type!=="root"&&M.parent;)M=M.parent,k=M.queue;for(let b=0;b<u.nodes.length;b++){const v=u.nodes[b];if(v.type==="comma"&&u.type==="brace"){b===1&&k.push(""),k.push("");continue}if(v.type==="close"){T.push(r(T.pop(),k,w));continue}if(v.value&&v.type!=="open"){k.push(r(k.pop(),v.value));continue}v.nodes&&c(v,u)}return k};return n.flatten(c(i))},co}var uo,fa;function HE(){return fa||(fa=1,uo={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
73
|
-
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}),uo}var lo,da;function BE(){if(da)return lo;da=1;const e=ro(),{MAX_LENGTH:t,CHAR_BACKSLASH:n,CHAR_BACKTICK:r,CHAR_COMMA:o,CHAR_DOT:i,CHAR_LEFT_PARENTHESES:s,CHAR_RIGHT_PARENTHESES:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_RIGHT_CURLY_BRACE:u,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_RIGHT_SQUARE_BRACKET:h,CHAR_DOUBLE_QUOTE:T,CHAR_SINGLE_QUOTE:w,CHAR_NO_BREAK_SPACE:k,CHAR_ZERO_WIDTH_NOBREAK_SPACE:M}=HE();return lo=(v,R={})=>{if(typeof v!="string")throw new TypeError("Expected a string");const p=R||{},l=typeof p.maxLength=="number"?Math.min(t,p.maxLength):t;if(v.length>l)throw new SyntaxError(`Input length (${v.length}), exceeds max characters (${l})`);const d={type:"root",input:v,nodes:[]},E=[d];let m=d,C=d,$=0;const U=v.length;let K=0,G=0,D;const te=()=>v[K++],F=H=>{if(H.type==="text"&&C.type==="dot"&&(C.type="text"),C&&C.type==="text"&&H.type==="text"){C.value+=H.value;return}return m.nodes.push(H),H.parent=m,H.prev=C,C=H,H};for(F({type:"bos"});K<U;)if(m=E[E.length-1],D=te(),!(D===M||D===k)){if(D===n){F({type:"text",value:(R.keepEscaping?D:"")+te()});continue}if(D===h){F({type:"text",value:"\\"+D});continue}if(D===f){$++;let H;for(;K<U&&(H=te());){if(D+=H,H===f){$++;continue}if(H===n){D+=te();continue}if(H===h&&($--,$===0))break}F({type:"text",value:D});continue}if(D===s){m=F({type:"paren",nodes:[]}),E.push(m),F({type:"text",value:D});continue}if(D===a){if(m.type!=="paren"){F({type:"text",value:D});continue}m=E.pop(),F({type:"text",value:D}),m=E[E.length-1];continue}if(D===T||D===w||D===r){const H=D;let B;for(R.keepQuotes!==!0&&(D="");K<U&&(B=te());){if(B===n){D+=B+te();continue}if(B===H){R.keepQuotes===!0&&(D+=B);break}D+=B}F({type:"text",value:D});continue}if(D===c){G++;const B={type:"brace",open:!0,close:!1,dollar:C.value&&C.value.slice(-1)==="$"||m.dollar===!0,depth:G,commas:0,ranges:0,nodes:[]};m=F(B),E.push(m),F({type:"open",value:D});continue}if(D===u){if(m.type!=="brace"){F({type:"text",value:D});continue}const H="close";m=E.pop(),m.close=!0,F({type:H,value:D}),G--,m=E[E.length-1];continue}if(D===o&&G>0){if(m.ranges>0){m.ranges=0;const H=m.nodes.shift();m.nodes=[H,{type:"text",value:e(m)}]}F({type:"comma",value:D}),m.commas++;continue}if(D===i&&G>0&&m.commas===0){const H=m.nodes;if(G===0||H.length===0){F({type:"text",value:D});continue}if(C.type==="dot"){if(m.range=[],C.value+=D,C.type="range",m.nodes.length!==3&&m.nodes.length!==5){m.invalid=!0,m.ranges=0,C.type="text";continue}m.ranges++,m.args=[];continue}if(C.type==="range"){H.pop();const B=H[H.length-1];B.value+=C.value+D,C=B,m.ranges--;continue}F({type:"dot",value:D});continue}F({type:"text",value:D})}do if(m=E.pop(),m.type!=="root"){m.nodes.forEach(Te=>{Te.nodes||(Te.type==="open"&&(Te.isOpen=!0),Te.type==="close"&&(Te.isClose=!0),Te.nodes||(Te.type="text"),Te.invalid=!0)});const H=E[E.length-1],B=H.nodes.indexOf(m);H.nodes.splice(B,1,...m.nodes)}while(E.length>0);return F({type:"eos"}),d},lo}var po,ha;function ZE(){if(ha)return po;ha=1;const e=ro(),t=FE(),n=GE(),r=BE(),o=(i,s={})=>{let a=[];if(Array.isArray(i))for(const c of i){const u=o.create(c,s);Array.isArray(u)?a.push(...u):a.push(u)}else a=[].concat(o.create(i,s));return s&&s.expand===!0&&s.nodupes===!0&&(a=[...new Set(a)]),a};return o.parse=(i,s={})=>r(i,s),o.stringify=(i,s={})=>e(typeof i=="string"?o.parse(i,s):i,s),o.compile=(i,s={})=>(typeof i=="string"&&(i=o.parse(i,s)),t(i,s)),o.expand=(i,s={})=>{typeof i=="string"&&(i=o.parse(i,s));let a=n(i,s);return s.noempty===!0&&(a=a.filter(Boolean)),s.nodupes===!0&&(a=[...new Set(a)]),a},o.create=(i,s={})=>i===""||i.length<3?[i]:s.expand!==!0?o.compile(i,s):o.expand(i,s),po=o,po}var fo={},ho,ma;function Yn(){if(ma)return ho;ma=1;const e=le,t="\\\\/",n=`[^${t}]`,r=0,o="\\.",i="\\+",s="\\?",a="\\/",c="(?=.)",u="[^/]",f=`(?:${a}|$)`,h=`(?:^|${a})`,T=`${o}{1,2}${f}`,w=`(?!${o})`,k=`(?!${h}${T})`,M=`(?!${o}{0,1}${f})`,b=`(?!${T})`,v=`[^.${a}]`,R=`${u}*?`,p={DOT_LITERAL:o,PLUS_LITERAL:i,QMARK_LITERAL:s,SLASH_LITERAL:a,ONE_CHAR:c,QMARK:u,END_ANCHOR:f,DOTS_SLASH:T,NO_DOT:w,NO_DOTS:k,NO_DOT_SLASH:M,NO_DOTS_SLASH:b,QMARK_NO_DOT:v,STAR:R,START_ANCHOR:h},l={...p,SLASH_LITERAL:`[${t}]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`${o}{1,2}(?:[${t}]|$)`,NO_DOT:`(?!${o})`,NO_DOTS:`(?!(?:^|[${t}])${o}{1,2}(?:[${t}]|$))`,NO_DOT_SLASH:`(?!${o}{0,1}(?:[${t}]|$))`,NO_DOTS_SLASH:`(?!${o}{1,2}(?:[${t}]|$))`,QMARK_NO_DOT:`[^.${t}]`,START_ANCHOR:`(?:^|[${t}])`,END_ANCHOR:`(?:[${t}]|$)`},d={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return ho={DEFAULT_MAX_EXTGLOB_RECURSION:r,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:d,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:e.sep,extglobChars(E){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${E.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(E){return E===!0?l:p}},ho}var ga;function Xn(){return ga||(ga=1,(function(e){const t=le,n=process.platform==="win32",{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:o,REGEX_SPECIAL_CHARS:i,REGEX_SPECIAL_CHARS_GLOBAL:s}=Yn();e.isObject=a=>a!==null&&typeof a=="object"&&!Array.isArray(a),e.hasRegexChars=a=>i.test(a),e.isRegexChar=a=>a.length===1&&e.hasRegexChars(a),e.escapeRegex=a=>a.replace(s,"\\$1"),e.toPosixSlashes=a=>a.replace(r,"/"),e.removeBackslashes=a=>a.replace(o,c=>c==="\\"?"":c),e.supportsLookbehinds=()=>{const a=process.version.slice(1).split(".").map(Number);return a.length===3&&a[0]>=9||a[0]===8&&a[1]>=10},e.isWindows=a=>a&&typeof a.windows=="boolean"?a.windows:n===!0||t.sep==="\\",e.escapeLast=(a,c,u)=>{const f=a.lastIndexOf(c,u);return f===-1?a:a[f-1]==="\\"?e.escapeLast(a,c,f-1):`${a.slice(0,f)}\\${a.slice(f)}`},e.removePrefix=(a,c={})=>{let u=a;return u.startsWith("./")&&(u=u.slice(2),c.prefix="./"),u},e.wrapOutput=(a,c={},u={})=>{const f=u.contains?"":"^",h=u.contains?"":"$";let T=`${f}(?:${a})${h}`;return c.negated===!0&&(T=`(?:^(?!${T}).*$)`),T}})(fo)),fo}var mo,Ea;function VE(){if(Ea)return mo;Ea=1;const e=Xn(),{CHAR_ASTERISK:t,CHAR_AT:n,CHAR_BACKWARD_SLASH:r,CHAR_COMMA:o,CHAR_DOT:i,CHAR_EXCLAMATION_MARK:s,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_LEFT_PARENTHESES:u,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:h,CHAR_QUESTION_MARK:T,CHAR_RIGHT_CURLY_BRACE:w,CHAR_RIGHT_PARENTHESES:k,CHAR_RIGHT_SQUARE_BRACKET:M}=Yn(),b=p=>p===a||p===r,v=p=>{p.isPrefix!==!0&&(p.depth=p.isGlobstar?1/0:1)};return mo=(p,l)=>{const d=l||{},E=p.length-1,m=d.parts===!0||d.scanToEnd===!0,C=[],$=[],U=[];let K=p,G=-1,D=0,te=0,F=!1,H=!1,B=!1,Te=!1,Xe=!1,xe=!1,re=!1,nt=!1,Tt=!1,be=!1,Ae=0,ze,Z,q={value:"",depth:0,isGlob:!1};const y=()=>G>=E,ke=()=>K.charCodeAt(G+1),Re=()=>(ze=Z,K.charCodeAt(++G));for(;G<E;){Z=Re();let se;if(Z===r){re=q.backslashes=!0,Z=Re(),Z===c&&(xe=!0);continue}if(xe===!0||Z===c){for(Ae++;y()!==!0&&(Z=Re());){if(Z===r){re=q.backslashes=!0,Re();continue}if(Z===c){Ae++;continue}if(xe!==!0&&Z===i&&(Z=Re())===i){if(F=q.isBrace=!0,B=q.isGlob=!0,be=!0,m===!0)continue;break}if(xe!==!0&&Z===o){if(F=q.isBrace=!0,B=q.isGlob=!0,be=!0,m===!0)continue;break}if(Z===w&&(Ae--,Ae===0)){xe=!1,F=q.isBrace=!0,be=!0;break}}if(m===!0)continue;break}if(Z===a){if(C.push(G),$.push(q),q={value:"",depth:0,isGlob:!1},be===!0)continue;if(ze===i&&G===D+1){D+=2;continue}te=G+1;continue}if(d.noext!==!0&&(Z===h||Z===n||Z===t||Z===T||Z===s)===!0&&ke()===u){if(B=q.isGlob=!0,Te=q.isExtglob=!0,be=!0,Z===s&&G===D&&(Tt=!0),m===!0){for(;y()!==!0&&(Z=Re());){if(Z===r){re=q.backslashes=!0,Z=Re();continue}if(Z===k){B=q.isGlob=!0,be=!0;break}}continue}break}if(Z===t){if(ze===t&&(Xe=q.isGlobstar=!0),B=q.isGlob=!0,be=!0,m===!0)continue;break}if(Z===T){if(B=q.isGlob=!0,be=!0,m===!0)continue;break}if(Z===f){for(;y()!==!0&&(se=Re());){if(se===r){re=q.backslashes=!0,Re();continue}if(se===M){H=q.isBracket=!0,B=q.isGlob=!0,be=!0;break}}if(m===!0)continue;break}if(d.nonegate!==!0&&Z===s&&G===D){nt=q.negated=!0,D++;continue}if(d.noparen!==!0&&Z===u){if(B=q.isGlob=!0,m===!0){for(;y()!==!0&&(Z=Re());){if(Z===u){re=q.backslashes=!0,Z=Re();continue}if(Z===k){be=!0;break}}continue}break}if(B===!0){if(be=!0,m===!0)continue;break}}d.noext===!0&&(Te=!1,B=!1);let ye=K,S="",_="";D>0&&(S=K.slice(0,D),K=K.slice(D),te-=D),ye&&B===!0&&te>0?(ye=K.slice(0,te),_=K.slice(te)):B===!0?(ye="",_=K):ye=K,ye&&ye!==""&&ye!=="/"&&ye!==K&&b(ye.charCodeAt(ye.length-1))&&(ye=ye.slice(0,-1)),d.unescape===!0&&(_&&(_=e.removeBackslashes(_)),ye&&re===!0&&(ye=e.removeBackslashes(ye)));const Fe={prefix:S,input:p,start:D,base:ye,glob:_,isBrace:F,isBracket:H,isGlob:B,isExtglob:Te,isGlobstar:Xe,negated:nt,negatedExtglob:Tt};if(d.tokens===!0&&(Fe.maxDepth=0,b(Z)||$.push(q),Fe.tokens=$),d.parts===!0||d.tokens===!0){let se;for(let de=0;de<C.length;de++){const at=se?se+1:D,Ge=C[de],ht=p.slice(at,Ge);d.tokens&&(de===0&&D!==0?($[de].isPrefix=!0,$[de].value=S):$[de].value=ht,v($[de]),Fe.maxDepth+=$[de].depth),(de!==0||ht!=="")&&U.push(ht),se=Ge}if(se&&se+1<p.length){const de=p.slice(se+1);U.push(de),d.tokens&&($[$.length-1].value=de,v($[$.length-1]),Fe.maxDepth+=$[$.length-1].depth)}Fe.slashes=C,Fe.parts=U}return Fe},mo}var go,_a;function WE(){if(_a)return go;_a=1;const e=Yn(),t=Xn(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:r,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:i,REPLACEMENTS:s}=e,a=(R,p)=>{if(typeof p.expandRange=="function")return p.expandRange(...R,p);R.sort();const l=`[${R.join("-")}]`;try{new RegExp(l)}catch{return R.map(E=>t.escapeRegex(E)).join("..")}return l},c=(R,p)=>`Missing ${R}: "${p}" - use "\\\\${p}" to match literal characters`,u=R=>{const p=[];let l=0,d=0,E=0,m="",C=!1;for(const $ of R){if(C===!0){m+=$,C=!1;continue}if($==="\\"){m+=$,C=!0;continue}if($==='"'){E=E===1?0:1,m+=$;continue}if(E===0){if($==="[")l++;else if($==="]"&&l>0)l--;else if(l===0){if($==="(")d++;else if($===")"&&d>0)d--;else if($==="|"&&d===0){p.push(m),m="";continue}}}m+=$}return p.push(m),p},f=R=>{let p=!1;for(const l of R){if(p===!0){p=!1;continue}if(l==="\\"){p=!0;continue}if(/[?*+@!()[\]{}]/.test(l))return!1}return!0},h=R=>{let p=R.trim(),l=!0;for(;l===!0;)l=!1,/^@\([^\\()[\]{}|]+\)$/.test(p)&&(p=p.slice(2,-1),l=!0);if(f(p))return p.replace(/\\(.)/g,"$1")},T=R=>{const p=R.map(h).filter(Boolean);for(let l=0;l<p.length;l++)for(let d=l+1;d<p.length;d++){const E=p[l],m=p[d],C=E[0];if(!(!C||E!==C.repeat(E.length)||m!==C.repeat(m.length))&&(E===m||E.startsWith(m)||m.startsWith(E)))return!0}return!1},w=(R,p=!0)=>{if(R[0]!=="+"&&R[0]!=="*"||R[1]!=="(")return;let l=0,d=0,E=0,m=!1;for(let C=1;C<R.length;C++){const $=R[C];if(m===!0){m=!1;continue}if($==="\\"){m=!0;continue}if($==='"'){E=E===1?0:1;continue}if(E!==1){if($==="["){l++;continue}if($==="]"&&l>0){l--;continue}if(!(l>0)){if($==="("){d++;continue}if($===")"&&(d--,d===0))return p===!0&&C!==R.length-1?void 0:{type:R[0],body:R.slice(2,C),end:C}}}}},k=R=>{let p=0;const l=[];for(;p<R.length;){const E=w(R.slice(p),!1);if(!E||E.type!=="*")return;const m=u(E.body).map($=>$.trim());if(m.length!==1)return;const C=h(m[0]);if(!C||C.length!==1)return;l.push(C),p+=E.end+1}return l.length<1?void 0:`${l.length===1?t.escapeRegex(l[0]):`[${l.map(E=>t.escapeRegex(E)).join("")}]`}*`},M=R=>{let p=0,l=R.trim(),d=w(l);for(;d;)p++,l=d.body.trim(),d=w(l);return p},b=(R,p)=>{if(p.maxExtglobRecursion===!1)return{risky:!1};const l=typeof p.maxExtglobRecursion=="number"?p.maxExtglobRecursion:e.DEFAULT_MAX_EXTGLOB_RECURSION,d=u(R).map(E=>E.trim());if(d.length>1&&(d.some(E=>E==="")||d.some(E=>/^[*?]+$/.test(E))||T(d)))return{risky:!0};for(const E of d){const m=k(E);if(m)return{risky:!0,safeOutput:m};if(M(E)>l)return{risky:!0}}return{risky:!1}},v=(R,p)=>{if(typeof R!="string")throw new TypeError("Expected a string");R=s[R]||R;const l={...p},d=typeof l.maxLength=="number"?Math.min(n,l.maxLength):n;let E=R.length;if(E>d)throw new SyntaxError(`Input length: ${E}, exceeds maximum allowed length: ${d}`);const m={type:"bos",value:"",output:l.prepend||""},C=[m],$=l.capture?"":"?:",U=t.isWindows(p),K=e.globChars(U),G=e.extglobChars(K),{DOT_LITERAL:D,PLUS_LITERAL:te,SLASH_LITERAL:F,ONE_CHAR:H,DOTS_SLASH:B,NO_DOT:Te,NO_DOT_SLASH:Xe,NO_DOTS_SLASH:xe,QMARK:re,QMARK_NO_DOT:nt,STAR:Tt,START_ANCHOR:be}=K,Ae=L=>`(${$}(?:(?!${be}${L.dot?B:D}).)*?)`,ze=l.dot?"":Te,Z=l.dot?re:nt;let q=l.bash===!0?Ae(l):Tt;l.capture&&(q=`(${q})`),typeof l.noext=="boolean"&&(l.noextglob=l.noext);const y={input:R,index:-1,start:0,dot:l.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:C};R=t.removePrefix(R,y),E=R.length;const ke=[],Re=[],ye=[];let S=m,_;const Fe=()=>y.index===E-1,se=y.peek=(L=1)=>R[y.index+L],de=y.advance=()=>R[++y.index]||"",at=()=>R.slice(y.index+1),Ge=(L="",ue=0)=>{y.consumed+=L,y.index+=ue},ht=L=>{y.output+=L.output!=null?L.output:L.value,Ge(L.value)},ka=()=>{let L=1;for(;se()==="!"&&(se(2)!=="("||se(3)==="?");)de(),y.start++,L++;return L%2===0?!1:(y.negated=!0,y.start++,!0)},an=L=>{y[L]++,ye.push(L)},mt=L=>{y[L]--,ye.pop()},X=L=>{if(S.type==="globstar"){const ue=y.braces>0&&(L.type==="comma"||L.type==="brace"),N=L.extglob===!0||ke.length&&(L.type==="pipe"||L.type==="paren");L.type!=="slash"&&L.type!=="paren"&&!ue&&!N&&(y.output=y.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=q,y.output+=S.output)}if(ke.length&&L.type!=="paren"&&(ke[ke.length-1].inner+=L.value),(L.value||L.output)&&ht(L),S&&S.type==="text"&&L.type==="text"){S.value+=L.value,S.output=(S.output||"")+L.value;return}L.prev=S,C.push(L),S=L},cn=(L,ue)=>{const N={...G[ue],conditions:1,inner:""};N.prev=S,N.parens=y.parens,N.output=y.output,N.startIndex=y.index,N.tokensIndex=C.length;const Y=(l.capture?"(":"")+N.open;an("parens"),X({type:L,value:ue,output:y.output?"":H}),X({type:"paren",extglob:!0,value:de(),output:Y}),ke.push(N)},Pa=L=>{const ue=R.slice(L.startIndex,y.index+1),N=R.slice(L.startIndex+2,y.index),Y=b(N,l);if((L.type==="plus"||L.type==="star")&&Y.risky){const ae=Y.safeOutput?(L.output?"":H)+(l.capture?`(${Y.safeOutput})`:Y.safeOutput):void 0,rt=C[L.tokensIndex];rt.type="text",rt.value=ue,rt.output=ae||t.escapeRegex(ue);for(let ot=L.tokensIndex+1;ot<C.length;ot++)C[ot].value="",C[ot].output="",delete C[ot].suffix;y.output=L.output+rt.output,y.backtrack=!0,X({type:"paren",extglob:!0,value:_,output:""}),mt("parens");return}let ce=L.close+(l.capture?")":""),Ce;if(L.type==="negate"){let ae=q;if(L.inner&&L.inner.length>1&&L.inner.includes("/")&&(ae=Ae(l)),(ae!==q||Fe()||/^\)+$/.test(at()))&&(ce=L.close=`)$))${ae}`),L.inner.includes("*")&&(Ce=at())&&/^\.[^\\/.]+$/.test(Ce)){const rt=v(Ce,{...p,fastpaths:!1}).output;ce=L.close=`)${rt})${ae})`}L.prev.type==="bos"&&(y.negatedExtglob=!0)}X({type:"paren",extglob:!0,value:_,output:ce}),mt("parens")};if(l.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(R)){let L=!1,ue=R.replace(i,(N,Y,ce,Ce,ae,rt)=>Ce==="\\"?(L=!0,N):Ce==="?"?Y?Y+Ce+(ae?re.repeat(ae.length):""):rt===0?Z+(ae?re.repeat(ae.length):""):re.repeat(ce.length):Ce==="."?D.repeat(ce.length):Ce==="*"?Y?Y+Ce+(ae?q:""):q:Y?N:`\\${N}`);return L===!0&&(l.unescape===!0?ue=ue.replace(/\\/g,""):ue=ue.replace(/\\+/g,N=>N.length%2===0?"\\\\":N?"\\":"")),ue===R&&l.contains===!0?(y.output=R,y):(y.output=t.wrapOutput(ue,y,p),y)}for(;!Fe();){if(_=de(),_==="\0")continue;if(_==="\\"){const N=se();if(N==="/"&&l.bash!==!0||N==="."||N===";")continue;if(!N){_+="\\",X({type:"text",value:_});continue}const Y=/^\\+/.exec(at());let ce=0;if(Y&&Y[0].length>2&&(ce=Y[0].length,y.index+=ce,ce%2!==0&&(_+="\\")),l.unescape===!0?_=de():_+=de(),y.brackets===0){X({type:"text",value:_});continue}}if(y.brackets>0&&(_!=="]"||S.value==="["||S.value==="[^")){if(l.posix!==!1&&_===":"){const N=S.value.slice(1);if(N.includes("[")&&(S.posix=!0,N.includes(":"))){const Y=S.value.lastIndexOf("["),ce=S.value.slice(0,Y),Ce=S.value.slice(Y+2),ae=r[Ce];if(ae){S.value=ce+ae,y.backtrack=!0,de(),!m.output&&C.indexOf(S)===1&&(m.output=H);continue}}}(_==="["&&se()!==":"||_==="-"&&se()==="]")&&(_=`\\${_}`),_==="]"&&(S.value==="["||S.value==="[^")&&(_=`\\${_}`),l.posix===!0&&_==="!"&&S.value==="["&&(_="^"),S.value+=_,ht({value:_});continue}if(y.quotes===1&&_!=='"'){_=t.escapeRegex(_),S.value+=_,ht({value:_});continue}if(_==='"'){y.quotes=y.quotes===1?0:1,l.keepQuotes===!0&&X({type:"text",value:_});continue}if(_==="("){an("parens"),X({type:"paren",value:_});continue}if(_===")"){if(y.parens===0&&l.strictBrackets===!0)throw new SyntaxError(c("opening","("));const N=ke[ke.length-1];if(N&&y.parens===N.parens+1){Pa(ke.pop());continue}X({type:"paren",value:_,output:y.parens?")":"\\)"}),mt("parens");continue}if(_==="["){if(l.nobracket===!0||!at().includes("]")){if(l.nobracket!==!0&&l.strictBrackets===!0)throw new SyntaxError(c("closing","]"));_=`\\${_}`}else an("brackets");X({type:"bracket",value:_});continue}if(_==="]"){if(l.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){X({type:"text",value:_,output:`\\${_}`});continue}if(y.brackets===0){if(l.strictBrackets===!0)throw new SyntaxError(c("opening","["));X({type:"text",value:_,output:`\\${_}`});continue}mt("brackets");const N=S.value.slice(1);if(S.posix!==!0&&N[0]==="^"&&!N.includes("/")&&(_=`/${_}`),S.value+=_,ht({value:_}),l.literalBrackets===!1||t.hasRegexChars(N))continue;const Y=t.escapeRegex(S.value);if(y.output=y.output.slice(0,-S.value.length),l.literalBrackets===!0){y.output+=Y,S.value=Y;continue}S.value=`(${$}${Y}|${S.value})`,y.output+=S.value;continue}if(_==="{"&&l.nobrace!==!0){an("braces");const N={type:"brace",value:_,output:"(",outputIndex:y.output.length,tokensIndex:y.tokens.length};Re.push(N),X(N);continue}if(_==="}"){const N=Re[Re.length-1];if(l.nobrace===!0||!N){X({type:"text",value:_,output:_});continue}let Y=")";if(N.dots===!0){const ce=C.slice(),Ce=[];for(let ae=ce.length-1;ae>=0&&(C.pop(),ce[ae].type!=="brace");ae--)ce[ae].type!=="dots"&&Ce.unshift(ce[ae].value);Y=a(Ce,l),y.backtrack=!0}if(N.comma!==!0&&N.dots!==!0){const ce=y.output.slice(0,N.outputIndex),Ce=y.tokens.slice(N.tokensIndex);N.value=N.output="\\{",_=Y="\\}",y.output=ce;for(const ae of Ce)y.output+=ae.output||ae.value}X({type:"brace",value:_,output:Y}),mt("braces"),Re.pop();continue}if(_==="|"){ke.length>0&&ke[ke.length-1].conditions++,X({type:"text",value:_});continue}if(_===","){let N=_;const Y=Re[Re.length-1];Y&&ye[ye.length-1]==="braces"&&(Y.comma=!0,N="|"),X({type:"comma",value:_,output:N});continue}if(_==="/"){if(S.type==="dot"&&y.index===y.start+1){y.start=y.index+1,y.consumed="",y.output="",C.pop(),S=m;continue}X({type:"slash",value:_,output:F});continue}if(_==="."){if(y.braces>0&&S.type==="dot"){S.value==="."&&(S.output=D);const N=Re[Re.length-1];S.type="dots",S.output+=_,S.value+=_,N.dots=!0;continue}if(y.braces+y.parens===0&&S.type!=="bos"&&S.type!=="slash"){X({type:"text",value:_,output:D});continue}X({type:"dot",value:_,output:D});continue}if(_==="?"){if(!(S&&S.value==="(")&&l.noextglob!==!0&&se()==="("&&se(2)!=="?"){cn("qmark",_);continue}if(S&&S.type==="paren"){const Y=se();let ce=_;if(Y==="<"&&!t.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(Y)||Y==="<"&&!/<([!=]|\w+>)/.test(at()))&&(ce=`\\${_}`),X({type:"text",value:_,output:ce});continue}if(l.dot!==!0&&(S.type==="slash"||S.type==="bos")){X({type:"qmark",value:_,output:nt});continue}X({type:"qmark",value:_,output:re});continue}if(_==="!"){if(l.noextglob!==!0&&se()==="("&&(se(2)!=="?"||!/[!=<:]/.test(se(3)))){cn("negate",_);continue}if(l.nonegate!==!0&&y.index===0){ka();continue}}if(_==="+"){if(l.noextglob!==!0&&se()==="("&&se(2)!=="?"){cn("plus",_);continue}if(S&&S.value==="("||l.regex===!1){X({type:"plus",value:_,output:te});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||y.parens>0){X({type:"plus",value:_});continue}X({type:"plus",value:te});continue}if(_==="@"){if(l.noextglob!==!0&&se()==="("&&se(2)!=="?"){X({type:"at",extglob:!0,value:_,output:""});continue}X({type:"text",value:_});continue}if(_!=="*"){(_==="$"||_==="^")&&(_=`\\${_}`);const N=o.exec(at());N&&(_+=N[0],y.index+=N[0].length),X({type:"text",value:_});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=_,S.output=q,y.backtrack=!0,y.globstar=!0,Ge(_);continue}let L=at();if(l.noextglob!==!0&&/^\([^?]/.test(L)){cn("star",_);continue}if(S.type==="star"){if(l.noglobstar===!0){Ge(_);continue}const N=S.prev,Y=N.prev,ce=N.type==="slash"||N.type==="bos",Ce=Y&&(Y.type==="star"||Y.type==="globstar");if(l.bash===!0&&(!ce||L[0]&&L[0]!=="/")){X({type:"star",value:_,output:""});continue}const ae=y.braces>0&&(N.type==="comma"||N.type==="brace"),rt=ke.length&&(N.type==="pipe"||N.type==="paren");if(!ce&&N.type!=="paren"&&!ae&&!rt){X({type:"star",value:_,output:""});continue}for(;L.slice(0,3)==="/**";){const ot=R[y.index+4];if(ot&&ot!=="/")break;L=L.slice(3),Ge("/**",3)}if(N.type==="bos"&&Fe()){S.type="globstar",S.value+=_,S.output=Ae(l),y.output=S.output,y.globstar=!0,Ge(_);continue}if(N.type==="slash"&&N.prev.type!=="bos"&&!Ce&&Fe()){y.output=y.output.slice(0,-(N.output+S.output).length),N.output=`(?:${N.output}`,S.type="globstar",S.output=Ae(l)+(l.strictSlashes?")":"|$)"),S.value+=_,y.globstar=!0,y.output+=N.output+S.output,Ge(_);continue}if(N.type==="slash"&&N.prev.type!=="bos"&&L[0]==="/"){const ot=L[1]!==void 0?"|$":"";y.output=y.output.slice(0,-(N.output+S.output).length),N.output=`(?:${N.output}`,S.type="globstar",S.output=`${Ae(l)}${F}|${F}${ot})`,S.value+=_,y.output+=N.output+S.output,y.globstar=!0,Ge(_+de()),X({type:"slash",value:"/",output:""});continue}if(N.type==="bos"&&L[0]==="/"){S.type="globstar",S.value+=_,S.output=`(?:^|${F}|${Ae(l)}${F})`,y.output=S.output,y.globstar=!0,Ge(_+de()),X({type:"slash",value:"/",output:""});continue}y.output=y.output.slice(0,-S.output.length),S.type="globstar",S.output=Ae(l),S.value+=_,y.output+=S.output,y.globstar=!0,Ge(_);continue}const ue={type:"star",value:_,output:q};if(l.bash===!0){ue.output=".*?",(S.type==="bos"||S.type==="slash")&&(ue.output=ze+ue.output),X(ue);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&l.regex===!0){ue.output=_,X(ue);continue}(y.index===y.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(y.output+=Xe,S.output+=Xe):l.dot===!0?(y.output+=xe,S.output+=xe):(y.output+=ze,S.output+=ze),se()!=="*"&&(y.output+=H,S.output+=H)),X(ue)}for(;y.brackets>0;){if(l.strictBrackets===!0)throw new SyntaxError(c("closing","]"));y.output=t.escapeLast(y.output,"["),mt("brackets")}for(;y.parens>0;){if(l.strictBrackets===!0)throw new SyntaxError(c("closing",")"));y.output=t.escapeLast(y.output,"("),mt("parens")}for(;y.braces>0;){if(l.strictBrackets===!0)throw new SyntaxError(c("closing","}"));y.output=t.escapeLast(y.output,"{"),mt("braces")}if(l.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&X({type:"maybe_slash",value:"",output:`${F}?`}),y.backtrack===!0){y.output="";for(const L of y.tokens)y.output+=L.output!=null?L.output:L.value,L.suffix&&(y.output+=L.suffix)}return y};return v.fastpaths=(R,p)=>{const l={...p},d=typeof l.maxLength=="number"?Math.min(n,l.maxLength):n,E=R.length;if(E>d)throw new SyntaxError(`Input length: ${E}, exceeds maximum allowed length: ${d}`);R=s[R]||R;const m=t.isWindows(p),{DOT_LITERAL:C,SLASH_LITERAL:$,ONE_CHAR:U,DOTS_SLASH:K,NO_DOT:G,NO_DOTS:D,NO_DOTS_SLASH:te,STAR:F,START_ANCHOR:H}=e.globChars(m),B=l.dot?D:G,Te=l.dot?te:G,Xe=l.capture?"":"?:",xe={negated:!1,prefix:""};let re=l.bash===!0?".*?":F;l.capture&&(re=`(${re})`);const nt=ze=>ze.noglobstar===!0?re:`(${Xe}(?:(?!${H}${ze.dot?K:C}).)*?)`,Tt=ze=>{switch(ze){case"*":return`${B}${U}${re}`;case".*":return`${C}${U}${re}`;case"*.*":return`${B}${re}${C}${U}${re}`;case"*/*":return`${B}${re}${$}${U}${Te}${re}`;case"**":return B+nt(l);case"**/*":return`(?:${B}${nt(l)}${$})?${Te}${U}${re}`;case"**/*.*":return`(?:${B}${nt(l)}${$})?${Te}${re}${C}${U}${re}`;case"**/.*":return`(?:${B}${nt(l)}${$})?${C}${U}${re}`;default:{const Z=/^(.*?)\.(\w+)$/.exec(ze);if(!Z)return;const q=Tt(Z[1]);return q?q+C+Z[2]:void 0}}},be=t.removePrefix(R,xe);let Ae=Tt(be);return Ae&&l.strictSlashes!==!0&&(Ae+=`${$}?`),Ae},go=v,go}var Eo,ya;function KE(){if(ya)return Eo;ya=1;const e=le,t=VE(),n=WE(),r=Xn(),o=Yn(),i=a=>a&&typeof a=="object"&&!Array.isArray(a),s=(a,c,u=!1)=>{if(Array.isArray(a)){const v=a.map(p=>s(p,c,u));return p=>{for(const l of v){const d=l(p);if(d)return d}return!1}}const f=i(a)&&a.tokens&&a.input;if(a===""||typeof a!="string"&&!f)throw new TypeError("Expected pattern to be a non-empty string");const h=c||{},T=r.isWindows(c),w=f?s.compileRe(a,c):s.makeRe(a,c,!1,!0),k=w.state;delete w.state;let M=()=>!1;if(h.ignore){const v={...c,ignore:null,onMatch:null,onResult:null};M=s(h.ignore,v,u)}const b=(v,R=!1)=>{const{isMatch:p,match:l,output:d}=s.test(v,w,c,{glob:a,posix:T}),E={glob:a,state:k,regex:w,posix:T,input:v,output:d,match:l,isMatch:p};return typeof h.onResult=="function"&&h.onResult(E),p===!1?(E.isMatch=!1,R?E:!1):M(v)?(typeof h.onIgnore=="function"&&h.onIgnore(E),E.isMatch=!1,R?E:!1):(typeof h.onMatch=="function"&&h.onMatch(E),R?E:!0)};return u&&(b.state=k),b};return s.test=(a,c,u,{glob:f,posix:h}={})=>{if(typeof a!="string")throw new TypeError("Expected input to be a string");if(a==="")return{isMatch:!1,output:""};const T=u||{},w=T.format||(h?r.toPosixSlashes:null);let k=a===f,M=k&&w?w(a):a;return k===!1&&(M=w?w(a):a,k=M===f),(k===!1||T.capture===!0)&&(T.matchBase===!0||T.basename===!0?k=s.matchBase(a,c,u,h):k=c.exec(M)),{isMatch:!!k,match:k,output:M}},s.matchBase=(a,c,u,f=r.isWindows(u))=>(c instanceof RegExp?c:s.makeRe(c,u)).test(e.basename(a)),s.isMatch=(a,c,u)=>s(c,u)(a),s.parse=(a,c)=>Array.isArray(a)?a.map(u=>s.parse(u,c)):n(a,{...c,fastpaths:!1}),s.scan=(a,c)=>t(a,c),s.compileRe=(a,c,u=!1,f=!1)=>{if(u===!0)return a.output;const h=c||{},T=h.contains?"":"^",w=h.contains?"":"$";let k=`${T}(?:${a.output})${w}`;a&&a.negated===!0&&(k=`^(?!${k}).*$`);const M=s.toRegex(k,c);return f===!0&&(M.state=a),M},s.makeRe=(a,c={},u=!1,f=!1)=>{if(!a||typeof a!="string")throw new TypeError("Expected a non-empty string");let h={negated:!1,fastpaths:!0};return c.fastpaths!==!1&&(a[0]==="."||a[0]==="*")&&(h.output=n.fastpaths(a,c)),h.output||(h=n(a,c)),s.compileRe(h,c,u,f)},s.toRegex=(a,c)=>{try{const u=c||{};return new RegExp(a,u.flags||(u.nocase?"i":""))}catch(u){if(c&&c.debug===!0)throw u;return/$^/}},s.constants=o,Eo=s,Eo}var _o,Sa;function YE(){return Sa||(Sa=1,_o=KE()),_o}var yo,Ta;function XE(){if(Ta)return yo;Ta=1;const e=zo,t=ZE(),n=YE(),r=Xn(),o=a=>a===""||a==="./",i=a=>{const c=a.indexOf("{");return c>-1&&a.indexOf("}",c)>-1},s=(a,c,u)=>{c=[].concat(c),a=[].concat(a);let f=new Set,h=new Set,T=new Set,w=0,k=v=>{T.add(v.output),u&&u.onResult&&u.onResult(v)};for(let v=0;v<c.length;v++){let R=n(String(c[v]),{...u,onResult:k},!0),p=R.state.negated||R.state.negatedExtglob;p&&w++;for(let l of a){let d=R(l,!0);(p?!d.isMatch:d.isMatch)&&(p?f.add(d.output):(f.delete(d.output),h.add(d.output)))}}let b=(w===c.length?[...T]:[...h]).filter(v=>!f.has(v));if(u&&b.length===0){if(u.failglob===!0)throw new Error(`No matches found for "${c.join(", ")}"`);if(u.nonull===!0||u.nullglob===!0)return u.unescape?c.map(v=>v.replace(/\\/g,"")):c}return b};return s.match=s,s.matcher=(a,c)=>n(a,c),s.isMatch=(a,c,u)=>n(c,u)(a),s.any=s.isMatch,s.not=(a,c,u={})=>{c=[].concat(c).map(String);let f=new Set,h=[],T=k=>{u.onResult&&u.onResult(k),h.push(k.output)},w=new Set(s(a,c,{...u,onResult:T}));for(let k of h)w.has(k)||f.add(k);return[...f]},s.contains=(a,c,u)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);if(Array.isArray(c))return c.some(f=>s.contains(a,f,u));if(typeof c=="string"){if(o(a)||o(c))return!1;if(a.includes(c)||a.startsWith("./")&&a.slice(2).includes(c))return!0}return s.isMatch(a,c,{...u,contains:!0})},s.matchKeys=(a,c,u)=>{if(!r.isObject(a))throw new TypeError("Expected the first argument to be an object");let f=s(Object.keys(a),c,u),h={};for(let T of f)h[T]=a[T];return h},s.some=(a,c,u)=>{let f=[].concat(a);for(let h of[].concat(c)){let T=n(String(h),u);if(f.some(w=>T(w)))return!0}return!1},s.every=(a,c,u)=>{let f=[].concat(a);for(let h of[].concat(c)){let T=n(String(h),u);if(!f.every(w=>T(w)))return!1}return!0},s.all=(a,c,u)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);return[].concat(c).every(f=>n(f,u)(a))},s.capture=(a,c,u)=>{let f=r.isWindows(u),T=n.makeRe(String(a),{...u,capture:!0}).exec(f?r.toPosixSlashes(c):c);if(T)return T.slice(1).map(w=>w===void 0?"":w)},s.makeRe=(...a)=>n.makeRe(...a),s.scan=(...a)=>n.scan(...a),s.parse=(a,c)=>{let u=[];for(let f of[].concat(a||[]))for(let h of t(String(f),c))u.push(n.parse(h,c));return u},s.braces=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return c&&c.nobrace===!0||!i(a)?[a]:t(a,c)},s.braceExpand=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return s.braces(a,{...c,expand:!0})},s.hasBraces=i,yo=s,yo}var QE=XE();const qE=ME(QE);function Ra(e,t,n){un.statSync(e).isDirectory()?(un.mkdirSync(t,{recursive:!0}),un.readdirSync(e).forEach(r=>{const o=ln.resolve(e,r),i=ln.resolve(t,r);Ra(o,i,n)})):qE.isMatch(e,n)||un.copyFileSync(e,t)}function dt(e,t,n,r,o=[]){const i=ln.join(e,r?.[n]??n);Ra(ln.join(t,n),i,o)}function JE(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>I.info(`Template [${e}] with pages structure named has been created`)}}function it(e){return Ne.resolve(oc(import.meta.url),"../..",e)}function e_(){const e=it("package.json");return e!==""?JSON.parse(he.readFileSync(e,"utf8")):{}}async function t_(e){try{const t=e,n=Se.cwd(),r=Ne.join(n,t),o=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],i={_gitignore:".gitignore"};he.existsSync(r)?(I.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):he.mkdirSync(r);const s=it("template");he.readdirSync(s).filter(f=>f!=="package.json").filter(f=>!o.includes(f)).forEach(async f=>dt(r,s,f,i));const a=JSON.parse(he.readFileSync(Ne.join(s,"package.json"),"utf-8"));a.name=e;const c=e_();c.version&&(a.dependencies["@lightspeed/crane-api"]=c.dependencies["@lightspeed/crane-api"]),c.dependencies["@lightspeed/eslint-config-crane"]&&(a.dependencies["@lightspeed/eslint-config-crane"]=c.dependencies["@lightspeed/eslint-config-crane"]);const u=Ne.join(r,"package.json");he.writeFileSync(u,`${JSON.stringify(a,null,2)}
|
|
74
|
-
`),I.info(`App ${e} created`)}catch(t){I.error(`Error while creating app: ${t.message}`),Se.exit(1)}}function So(e,t,n,r){try{const o=Se.cwd(),i=le.join(o,t);ie.existsSync(i)||ie.mkdirSync(i);const s=le.join(o,t,n);ie.existsSync(s)?(I.error(`${r} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):ie.mkdirSync(s);const a=it(e);ie.readdirSync(a).forEach(async c=>dt(s,a,c)),I.info(`${r} ${n} created`)}catch(o){I.error(`Error while creating ${r}: ${o.message}`),Se.exit(1)}}function To(e){const t=Se.cwd(),n=it(`template/${e}`),r=le.join(t,e);ie.existsSync(r)||(ie.mkdirSync(r),ie.readdirSync(n).forEach(async o=>dt(r,n,o)))}async function n_(e,t,n,r){if(!ie.existsSync(n)){ie.copyFileSync(t,n);return}const o=ie.readFileSync(t),i=ie.readFileSync(n);o.equals(i)||(r?(await At({type:"select",name:"value",message:`File "${e.name}" exists but differs from template. What would you like to do?`,choices:[{title:"Keep existing file",value:"keep"},{title:"Replace with template version",value:"replace"}],initial:0})).value==="replace"?(ie.copyFileSync(t,n),I.info(`Replaced "${e.name}" with template version.`)):I.info(`Kept existing "${e.name}".`):I.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function Qn(e,t,n=!1){async function r(i,s,a){const c=le.join(s,i.name),u=le.join(a,i.name);i.isDirectory()?await Qn(c,u,n):await n_(i,c,u,n)}const o=ie.readdirSync(e,{withFileTypes:!0});ie.existsSync(t)||ie.mkdirSync(t,{recursive:!0}),await o.reduce(async(i,s)=>(await i,r(s,e,t)),Promise.resolve())}async function Ro(e=!1){try{const t=Se.cwd(),n=le.join(t,"shared"),r=it("template/shared");if(!ie.existsSync(r))return;await Qn(r,n,e)}catch(t){I.error(`Error while processing shared folder: ${t.message}`),Se.exit(1)}}async function r_(e,t){await Ro(),So(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function o_(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>I.info(`Collection [${e}] has been created`)}}async function s_(e){const{targetPath:t,renameFiles:n,sourcePath:r,onCollectionCreated:o}=o_(e);try{const i=Se.cwd(),s=Ne.join(i,"collections"),a=it(r),c=he.readdirSync(a);he.existsSync(s)?he.existsSync(Ne.join(s,t))&&(I.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):he.mkdirSync(s),c.forEach(u=>dt(s,a,u,n)),o()}catch(i){I.error(`Error while creating collection: ${i.message}`),Se.exit(1)}}async function i_(e){await Ro(),So("template/footers/example-footer","footers",e,"Footer")}async function a_(e){await Ro(),So("template/headers/example-header","headers",e,"Header")}async function c_(e,t){try{const n=Se.cwd(),r=Ne.join(n,"templates"),o=it("template/page-templates/example-template/pages");he.existsSync(Ne.join(r,e))||(I.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),Se.exit(1)),he.existsSync(Ne.join(r,e,"pages",`${t}.ts`))&&(I.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),Se.exit(1));const i=he.readFileSync(Ne.join(o,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${im(t)}'`),s=Ne.join(r,e,"pages",`${t}.ts`);he.writeFileSync(s,i),I.info(`Page [${t}.ts] created for template ${e}`)}catch(n){I.error(`Error while creating page: ${n.message}`),Se.exit(1)}}async function u_(){try{const e=Se.cwd(),t=it("template/reference"),n=he.readdirSync(t);let r=!1;for(const o of n){const i=Ne.join(t,o),s=Ne.join(e,o);he.existsSync(s)||he.mkdirSync(s,{recursive:!0});const a=he.readdirSync(i),c=he.readdirSync(s);if(o==="shared"){a.forEach(u=>{dt(s,i,u)});continue}for(const u of a){if(u==="assets"){dt(s,i,u);continue}if(c.includes(u)){const{name:f}=await At({type:"text",name:"name",message:`The "${u}" already exists in ${o} directory: provide a new name to keep both or press Esc to skip this one.`});f?(dt(s,i,u,{[u]:f}),r=!0):I.info(`Skipped: ${u}`)}else dt(s,i,u)}}I.info("Reference templates have been added to the app"),r&&I.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){I.error(`Error while creating template descriptors: ${e.message}`),Se.exit(1)}}const l_=["**/example-template/pages/custom.ts"];async function p_(e){const{targetPath:t,renameFiles:n,sourcePath:r,onTemplateCreated:o}=JE(e);try{const i=Se.cwd(),s=Ne.join(i,"templates"),a=it(r),c=he.readdirSync(a);he.existsSync(s)?he.existsSync(Ne.join(s,t))&&(I.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):he.mkdirSync(s),c.forEach(u=>dt(s,a,u,n,l_)),To("headers"),To("footers"),To("layouts"),o()}catch(i){I.error(`Error while creating template descriptors: ${i.message}`),Se.exit(1)}}function f_(){try{const e=j(dn.cwd(),`${Di}/shared/analytics.json`);$e(e)&&or(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function qn({deploymentContext:e,sectionType:t=ut.SECTION}){const n=e.pathContext,r=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),o=r===void 0?$o(n.fileName):$o(n.fileName,{cwd:j(process.cwd(),r),ignore:n.ignore});return(n.isSingleton?o.splice(0):o).map(i=>({url:i,sectionType:t,context:e}))}const d_=e=>e.app.manifest.blocks.flatMap(t=>Bm.flatMap(n=>{const r={config:e,currentSection:t.id,pathContext:rn[n]};return qn({deploymentContext:r,sectionType:t.type})})),h_=e=>Wm.flatMap(t=>{const n={config:e,pathContext:rn[t]};return qn({deploymentContext:n})}),m_=e=>e.app.manifest.layouts.flatMap(t=>Zm.flatMap(n=>{const r={config:e,pathContext:rn[n],currentSection:t.sectionId,layoutId:t.id};return qn({deploymentContext:r})})),g_=e=>e.app.manifest.slots.flatMap(t=>Vm.flatMap(n=>{const r={config:e,pathContext:rn[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return qn({deploymentContext:r})})),E_=e=>`\x1B[32m${e}\x1B[0m`,__=(e,t,n,r,o)=>{if(!e.total)return;const{loaded:i}=e,s=(Date.now()-o)/1e3;n.value+=i-r.value,r.value=i,t.update({speed:`${pt(n.value/s,2)}/s`})},y_=()=>new ac.SingleBar({format:`|${E_("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function Oa(e){await new Promise(t=>setTimeout(t,e))}const va="Please ensure you have built your application before deploying.";async function Ca(){try{const e=await ar(j(dn.cwd(),ki));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${va}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${va}`):e}}const S_={value:0},Ye=y_();let wa=Date.now();const Ia=e=>2**e*500;async function T_(e){const t=ic(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,or(j(Oe.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
75
|
-
`)}function R_(e){return e instanceof Lo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function Aa(e,t){return e<Hm&&R_(t)}async function ba(e,t,n,r){const o={value:0},i=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?Um:Mm;return e.config.axios.post(i,{file:xa(j(Oe.cwd(),n!==void 0?n+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.layoutId!==void 0&&{layoutId:e.layoutId},...e.slotId!==void 0&&{slotId:e.slotId},...!["dependencies","source_code"].includes(e.pathContext.type)&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`},onUploadProgress:s=>__(s,Ye,S_,o,wa)}).then(s=>(Ye.increment(),s)).catch(async s=>{if(Aa(r,s))return await Oa(Ia(r)),ba(e,t,n,r+1);throw Ye.increment(),s})}function O_(e){return Ye.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,r=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return ba(n,t.url,r,0)})}function v_(e){const t=[...d_(e),...h_(e),...m_(e),...g_(e)];return O_(t)}async function $a(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?Fm:jm;return e.axios.post(n,e.app.manifest,{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async r=>{if(Aa(t,r))return await Oa(Ia(t)),$a(e,t+1);throw r})}async function C_(e){try{if(!tm.some(s=>$e(j(Oe.cwd(),s))))throw new Error(Ft.INCORRECT_DISTRIBUTION_FOLDER(Jh));const t=e??Vr;I.info("Custom application deployment :: Started");const n=cr.create({baseURL:t});sc(n,Gm),I.info("Loading configuration files ...");const r=await Promise.all([Gn(),Wr(),Ca()]).then(([s,a,c])=>({axios:n,app:{crane:s,packageJson:a,manifest:c}}));I.info("Uploading files ..."),wa=Date.now(),await Promise.all(v_(r)).catch(s=>{Ye.stop(),s.response?.status===404?I.error(wt(s,Ft.DEPRECATED_VERSION_DEPLOYMENT)):I.error(wt(s,Ft.ASSET_FILES_UPLOAD)),Oe.exit(1)}).finally(()=>{Ye.increment(),Ye.stop()}),Ye.update({speed:"N/A",status:"Finalising deployment"}),await $a(r).catch(s=>{Ye.stop(),s.response?.status===404?I.error(wt(s,Ft.DEPRECATED_VERSION_DEPLOYMENT)):I.error(wt(s,Ft.MANIFEST_DEPLOYMENT)),Oe.exit(1)}).finally(()=>{Ye.increment(),Ye.stop()});const o=r.app.manifest.blocks.map(s=>s.id),i=r.app.packageJson.version;I.info("Custom application deployment :: Successful"),I.info(`Current app version: ${i}`),I.info(`Deployed sections: ${o.sort().join(", ")}`),await T_(r.app.packageJson),r.app.manifest.templates.length>0&&I.info(`Deployed templates: ${r.app.manifest.templates.map(s=>s.id).sort().join(", ")}`),r.app.manifest.slots.length>0&&I.info(`Deployed slots: ${r.app.manifest.slots.map(s=>s.id).sort().join(", ")}`),r.app.manifest.collections.length>0&&I.info(`Deployed collections: ${r.app.manifest.collections.map(s=>s.id).sort().join(", ")}`)}catch(t){Ye.stop(),I.error(wt(t,Ft.DEFAULT)),Oe.exit(1)}finally{f_()}}function w_(){process.env.CRANE_DEBUG_ENABLED="true"}function I_(){return process.env.CRANE_DEBUG_ENABLED==="true"}function A_(e,...t){I_()&&console.debug(Ha(`[DEBUG] ${e}`),...t)}function b_(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,r)=>{e.moduleGraph.invalidateAll();const o=new Qa(t.url||"",`http://${t.headers.host}`);if(o.pathname==="/api/v1/block-config"&&t.method==="GET"){const i=o.searchParams.get("section");if(!i){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}try{const s=(await Ca()).blocks.find(a=>a.id===i);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(s))}catch(s){n.statusCode=500,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:s.message}))}return}r()})}}}let It=null;function $_(){It&&It.clients.forEach(e=>{e.readyState===uc.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function N_(e,t){const n=j(`${e}/ssr-server.ts`),r=j(t);await ct({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function L_(e,t){const n=j(`${e}/shared/preview.ts`),r=j(`${e}/shared/utils.ts`),o=j(`${e}/shared/api-routes.ts`),i=j(t);await ct({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ct({build:{lib:{entry:r,formats:["es"],fileName:()=>"utils.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ct({build:{lib:{entry:o,formats:["es"],fileName:()=>"api-routes.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function D_(){const e="preview",t=`${e}/shared`,n="vite.config.js",r=`${e}/sections`,o=`${r}/preview.html`;[e,r].forEach(s=>{ie.existsSync(s)||ie.mkdirSync(s,{recursive:!0})});const i=it("template/preview");ie.copyFileSync(`${i}/${n}`,`${e}/${n}`),await N_(i,e),ie.copyFileSync(`${i}/sections/preview.html`,o),ie.existsSync(t)||ie.mkdirSync(t),await L_(i,t)}function k_(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function P_(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function x_(e){const t=(await ra()).find(r=>r.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await Kn(!0);return}const n=ta(t);await ea([n]),console.log(`Block ${e} rebuilt successfully`)}var z_=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(z_||{});function M_(){return{timeout:null,inProgress:!1,pendingBuild:null}}function U_(e,t){const n=async r=>{e.inProgress=!0;try{r.type==="incremental"&&r.blockName?await x_(r.blockName):await Kn(!0),t.ws.send({type:"full-reload",path:"*"}),$_()}catch(o){console.error("Build error:",o)}finally{if(e.inProgress=!1,e.pendingBuild){const o=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(o),0)}}};return async r=>{if(e.inProgress){r.type==="full"||e.pendingBuild?.type==="full"?e.pendingBuild={type:"full"}:e.pendingBuild=r;return}await n(r)}}function j_(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),r=t.match(/headers\/([^/]+)/),o=t.match(/footers\/([^/]+)/),i=t.match(/shared\//);return!!(n||r||o||i)}function F_(e,t){return async n=>{if(!j_(n))return;e.timeout&&clearTimeout(e.timeout);const r=k_(n),o=P_(n);e.timeout=setTimeout(async()=>{o?await t({type:"full"}):r&&await t({type:"incremental",blockName:r})},1e3)}}function G_(e,t){const n=M_(),r=U_(n,e),o=F_(n,r);e.watcher.add(t),e.watcher.on("add",o),e.watcher.on("change",o),e.watcher.on("unlink",o)}async function H_(){const e=le.resolve(process.cwd(),"preview/ssr-server.mjs");if(!ie.existsSync(e))throw console.warn(`\u26A0\uFE0F SSR server not found at ${e}`),new Error(`SSR server not found at ${e}`);process.env.PREVIEW_SSR_PORT="0";let t=e;process.platform==="win32"&&(t=No(e).href);const n=await import(t),{server:r,port:o}=await n.startServer();return{server:r,port:o}}function B_(){It=new cc({port:0}),It.on("listening",()=>{const e=It?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function Z_(){const e=le.resolve(process.cwd(),"preview/vite.config.js"),t=le.resolve(process.cwd(),"sections/**/*"),n=le.resolve(process.cwd(),"headers/**/*"),r=le.resolve(process.cwd(),"footers/**/*"),o=le.resolve(process.cwd(),"shared/**/*"),i=await Za({configFile:e,root:process.cwd(),plugins:[b_()]});return await i.listen(),G_(i,[t,n,r,o]),i}async function V_(){await Kn(),await D_(),console.log(`
|
|
46
|
+
For deploy run: npx @lightspeed/crane@latest deploy`;function kh(e,t){if(e.errors.length===0){f.info(Lh);return}f.error("Invalid configuration detected:"),$h(e),t||process.exit(1)}const $s={"process.env":{NODE_ENV:"production"}},Ph=[...go,...go.map(e=>`node:${e}`)],zh=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],Ds=e=>({pluginType:te.Server,define:$s,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...Ph,...zh],inlineDynamicImports:!0,...e,outDir:e.outDir}),Ls=e=>({pluginType:te.Client,define:$s,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),Ye=e=>({pluginType:te.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),jh=e=>({pluginType:te.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),Kt=e=>({pluginType:te.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let Jt=!1;function Uh(e){Jt=e}function Xn(){return Jt}const ks=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Fh=80,Mh="\x1B[?25l",Gh="\x1B[?25h",xh="\x1B[2K\r",Bh=44;let Zh=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){Jt||(this.frameIndex=0,this.buffer=[],this.realWrite=process.stdout.write.bind(process.stdout),process.stdout.write=((t,n,o)=>(this.buffer.push(typeof t=="string"?t:String(t)),typeof n=="function"&&(o=n),o&&o(),!0)),this.realWrite(Mh),this.render(),this.timer=setInterval(()=>this.render(),Fh))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(Bh-1," "),n=ce(ks[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%ks.length}stop(){if(!Jt&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${xh}${Gh}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Ps=new Zh,Hh=()=>Ai({ext:".gz",algorithm:"gzip",verbose:Xn()}),Vh="/* EXTERNAL_IMPORTS_START */",Wh="/* EXTERNAL_IMPORTS_END */",Yh=()=>({name:"external-imports-wrapper-plugin",enforce:"post",apply:"build",generateBundle(e,t){for(const n of Object.keys(t)){const o=t[n];if(o.type==="chunk"){const r=/import.*\?commonjs-external["'];/g,s=o.code.match(r);if(s!==null){const i=s.join(""),a=Vh+i+Wh,c=o.code.replace(r,"");o.code=a+c}}}}}),Kh=()=>({name:"disable-json-plugin",enforce:"pre",apply:"build",configResolved(e){const t=e.plugins?.findIndex(n=>n?.name==="vite:json");t!==-1&&(e.plugins[t]={name:"vite:json",load:()=>null,transform:()=>null})}}),Jh=()=>{const e=process.env.npm_lifecycle_event;return Di({typescript:!1,vueTsc:!1,eslint:e?.startsWith("test")?!1:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})},pe={vue:()=>Ni(),tsconfigPaths:()=>$i(),checker:()=>Jh()};class nn{constructor(t){this.bits=t instanceof nn?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class lt{constructor(t,n,o){this.start=t,this.end=n,this.original=o,this.intro="",this.outro="",this.content=o,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(t){this.outro+=t}appendRight(t){this.intro=this.intro+t}clone(){const t=new lt(this.start,this.end,this.original);return t.intro=this.intro,t.outro=this.outro,t.content=this.content,t.storeName=this.storeName,t.edited=this.edited,t}contains(t){return this.start<t&&t<this.end}eachNext(t){let n=this;for(;n;)t(n),n=n.next}eachPrevious(t){let n=this;for(;n;)t(n),n=n.previous}edit(t,n,o){return this.content=t,o||(this.intro="",this.outro=""),this.storeName=n,this.edited=!0,this}prependLeft(t){this.outro=t+this.outro}prependRight(t){this.intro=t+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(t){const n=t-this.start,o=this.original.slice(0,n),r=this.original.slice(n);this.original=o;const s=new lt(t,this.end,r);return s.outro=this.outro,this.outro="",this.end=t,this.edited?(s.edit("",!1),this.content=""):this.content=o,s.next=this.next,s.next&&(s.next.previous=s),s.previous=this,this.next=s,s}toString(){return this.intro+this.content+this.outro}trimEnd(t){if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;const n=this.content.replace(t,"");if(n.length)return n!==this.content&&(this.split(this.start+n.length).edit("",void 0,!0),this.edited&&this.edit(n,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(t,""),this.intro.length)return!0}trimStart(t){if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;const n=this.content.replace(t,"");if(n.length){if(n!==this.content){const o=this.split(this.end-n.length);this.edited&&o.edit(n,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(t,""),this.outro.length)return!0}}function Xh(){return typeof globalThis<"u"&&typeof globalThis.btoa=="function"?e=>globalThis.btoa(unescape(encodeURIComponent(e))):typeof Buffer=="function"?e=>Buffer.from(e,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}const Qh=Xh();class qh{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Li(t.mappings),typeof t.x_google_ignoreList<"u"&&(this.x_google_ignoreList=t.x_google_ignoreList)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+Qh(this.toString())}}function em(e){const t=e.split(`
|
|
47
|
+
`),n=t.filter(s=>/^\t+/.test(s)),o=t.filter(s=>/^ {2,}/.test(s));if(n.length===0&&o.length===0)return null;if(n.length>=o.length)return" ";const r=o.reduce((s,i)=>{const a=/^ +/.exec(i)[0].length;return Math.min(a,s)},1/0);return new Array(r+1).join(" ")}function tm(e,t){const n=e.split(/[/\\]/),o=t.split(/[/\\]/);for(n.pop();n[0]===o[0];)n.shift(),o.shift();if(n.length){let r=n.length;for(;r--;)n[r]=".."}return n.concat(o).join("/")}const nm=Object.prototype.toString;function om(e){return nm.call(e)==="[object Object]"}function zs(e){const t=e.split(`
|
|
48
|
+
`),n=[];for(let o=0,r=0;o<t.length;o++)n.push(r),r+=t[o].length+1;return function(r){let s=0,i=n.length;for(;s<i;){const u=s+i>>1;r<n[u]?i=u:s=u+1}const a=s-1,c=r-n[a];return{line:a,column:c}}}const rm=/\w/;class sm{constructor(t){this.hires=t,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(t,n,o,r){if(n.length){const s=n.length-1;let i=n.indexOf(`
|
|
49
|
+
`,0),a=-1;for(;i>=0&&s>i;){const u=[this.generatedCodeColumn,t,o.line,o.column];r>=0&&u.push(r),this.rawSegments.push(u),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=i,i=n.indexOf(`
|
|
50
|
+
`,i+1)}const c=[this.generatedCodeColumn,t,o.line,o.column];r>=0&&c.push(r),this.rawSegments.push(c),this.advance(n.slice(a+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(n));this.pending=null}addUneditedChunk(t,n,o,r,s){let i=n.start,a=!0,c=!1;for(;i<n.end;){if(this.hires||a||s.has(i)){const u=[this.generatedCodeColumn,t,r.line,r.column];this.hires==="boundary"?rm.test(o[i])?c||(this.rawSegments.push(u),c=!0):(this.rawSegments.push(u),c=!1):this.rawSegments.push(u)}o[i]===`
|
|
51
|
+
`?(r.line+=1,r.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0):(r.column+=1,this.generatedCodeColumn+=1,a=!1),i+=1}this.pending=null}advance(t){if(!t)return;const n=t.split(`
|
|
52
|
+
`);if(n.length>1){for(let o=0;o<n.length-1;o++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=n[n.length-1].length}}const ut=`
|
|
53
|
+
`,Ke={insertLeft:!1,insertRight:!1,storeName:!1};class ao{constructor(t,n={}){const o=new lt(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:o},lastChunk:{writable:!0,value:o},lastSearchedChunk:{writable:!0,value:o},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:n.filename},indentExclusionRanges:{writable:!0,value:n.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new nn},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:n.ignoreList}}),this.byStart[0]=o,this.byEnd[t.length]=o}addSourcemapLocation(t){this.sourcemapLocations.add(t)}append(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.outro+=t,this}appendLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byEnd[t];return o?o.appendLeft(n):this.intro+=n,this}appendRight(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byStart[t];return o?o.appendRight(n):this.outro+=n,this}clone(){const t=new ao(this.original,{filename:this.filename});let n=this.firstChunk,o=t.firstChunk=t.lastSearchedChunk=n.clone();for(;n;){t.byStart[o.start]=o,t.byEnd[o.end]=o;const r=n.next,s=r&&r.clone();s&&(o.next=s,s.previous=o,o=s),n=r}return t.lastChunk=o,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new nn(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const n=0,o=Object.keys(this.storedNames),r=new sm(t.hires),s=zs(this.original);return this.intro&&r.advance(this.intro),this.firstChunk.eachNext(i=>{const a=s(i.start);i.intro.length&&r.advance(i.intro),i.edited?r.addEdit(n,i.content,a,i.storeName?o.indexOf(i.original):-1):r.addUneditedChunk(n,i,this.original,a,this.sourcemapLocations),i.outro.length&&r.advance(i.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?tm(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:o,mappings:r.raw,x_google_ignoreList:this.ignoreList?[n]:void 0}}generateMap(t){return new qh(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=em(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(t,n){const o=/^[^\r\n]/gm;if(om(t)&&(n=t,t=void 0),t===void 0&&(this._ensureindentStr(),t=this.indentStr||" "),t==="")return this;n=n||{};const r={};n.exclude&&(typeof n.exclude[0]=="number"?[n.exclude]:n.exclude).forEach(d=>{for(let m=d[0];m<d[1];m+=1)r[m]=!0});let s=n.indentStart!==!1;const i=u=>s?`${t}${u}`:(s=!0,u);this.intro=this.intro.replace(o,i);let a=0,c=this.firstChunk;for(;c;){const u=c.end;if(c.edited)r[a]||(c.content=c.content.replace(o,i),c.content.length&&(s=c.content[c.content.length-1]===`
|
|
54
|
+
`));else for(a=c.start;a<u;){if(!r[a]){const d=this.original[a];d===`
|
|
55
|
+
`?s=!0:d!=="\r"&&s&&(s=!1,a===c.start||(this._splitChunk(c,a),c=c.next),c.prependRight(t))}a+=1}a=c.end,c=c.next}return this.outro=this.outro.replace(o,i),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,n){return Ke.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Ke.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Ke.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Ke.insertRight=!0),this.prependRight(t,n)}move(t,n,o){if(o>=t&&o<=n)throw new Error("Cannot move a selection inside itself");this._split(t),this._split(n),this._split(o);const r=this.byStart[t],s=this.byEnd[n],i=r.previous,a=s.next,c=this.byStart[o];if(!c&&s===this.lastChunk)return this;const u=c?c.previous:this.lastChunk;return i&&(i.next=a),a&&(a.previous=i),u&&(u.next=r),c&&(c.previous=s),r.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=r.previous,this.lastChunk.next=null),r.previous=u,s.next=c||null,u||(this.firstChunk=r),c||(this.lastChunk=s),this}overwrite(t,n,o,r){return r=r||{},this.update(t,n,o,{...r,overwrite:!r.contentOnly})}update(t,n,o,r){if(typeof o!="string")throw new TypeError("replacement content must be a string");for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(n>this.original.length)throw new Error("end is out of bounds");if(t===n)throw new Error("Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead");this._split(t),this._split(n),r===!0&&(Ke.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Ke.storeName=!0),r={storeName:!0});const s=r!==void 0?r.storeName:!1,i=r!==void 0?r.overwrite:!1;if(s){const u=this.original.slice(t,n);Object.defineProperty(this.storedNames,u,{writable:!0,value:!0,enumerable:!0})}const a=this.byStart[t],c=this.byEnd[n];if(a){let u=a;for(;u!==c;){if(u.next!==this.byStart[u.end])throw new Error("Cannot overwrite across a split point");u=u.next,u.edit("",!1)}a.edit(o,s,!i)}else{const u=new lt(t,n,"").edit(o,s);c.next=u,u.previous=c}return this}prepend(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byEnd[t];return o?o.prependLeft(n):this.intro=n+this.intro,this}prependRight(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byStart[t];return o?o.prependRight(n):this.outro=n+this.outro,this}remove(t,n){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(t===n)return this;if(t<0||n>this.original.length)throw new Error("Character is out of bounds");if(t>n)throw new Error("end must be greater than start");this._split(t),this._split(n);let o=this.byStart[t];for(;o;)o.intro="",o.outro="",o.edit(""),o=n>o.end?this.byStart[o.end]:null;return this}reset(t,n){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(t===n)return this;if(t<0||n>this.original.length)throw new Error("Character is out of bounds");if(t>n)throw new Error("end must be greater than start");this._split(t),this._split(n);let o=this.byStart[t];for(;o;)o.reset(),o=n>o.end?this.byStart[o.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let t=this.lastChunk;do{if(t.outro.length)return t.outro[t.outro.length-1];if(t.content.length)return t.content[t.content.length-1];if(t.intro.length)return t.intro[t.intro.length-1]}while(t=t.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let t=this.outro.lastIndexOf(ut);if(t!==-1)return this.outro.substr(t+1);let n=this.outro,o=this.lastChunk;do{if(o.outro.length>0){if(t=o.outro.lastIndexOf(ut),t!==-1)return o.outro.substr(t+1)+n;n=o.outro+n}if(o.content.length>0){if(t=o.content.lastIndexOf(ut),t!==-1)return o.content.substr(t+1)+n;n=o.content+n}if(o.intro.length>0){if(t=o.intro.lastIndexOf(ut),t!==-1)return o.intro.substr(t+1)+n;n=o.intro+n}}while(o=o.previous);return t=this.intro.lastIndexOf(ut),t!==-1?this.intro.substr(t+1)+n:this.intro+n}slice(t=0,n=this.original.length){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;let o="",r=this.firstChunk;for(;r&&(r.start>t||r.end<=t);){if(r.start<n&&r.end>=n)return o;r=r.next}if(r&&r.edited&&r.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const s=r;for(;r;){r.intro&&(s!==r||r.start===t)&&(o+=r.intro);const i=r.start<n&&r.end>=n;if(i&&r.edited&&r.end!==n)throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);const a=s===r?t-r.start:0,c=i?r.content.length+n-r.end:r.content.length;if(o+=r.content.slice(a,c),r.outro&&(!i||r.end===n)&&(o+=r.outro),i)break;r=r.next}return o}snip(t,n){const o=this.clone();return o.remove(0,t),o.remove(n,o.original.length),o}_split(t){if(this.byStart[t]||this.byEnd[t])return;let n=this.lastSearchedChunk;const o=t>n.end;for(;n;){if(n.contains(t))return this._splitChunk(n,t);n=o?this.byStart[n.end]:this.byEnd[n.start]}}_splitChunk(t,n){if(t.edited&&t.content.length){const r=zs(this.original)(n);throw new Error(`Cannot split a chunk that has already been edited (${r.line}:${r.column} \u2013 "${t.original}")`)}const o=t.split(n);return this.byEnd[n]=t,this.byStart[n]=o,this.byEnd[o.end]=o,t===this.lastChunk&&(this.lastChunk=o),this.lastSearchedChunk=t,!0}toString(){let t=this.intro,n=this.firstChunk;for(;n;)t+=n.toString(),n=n.next;return t+this.outro}isEmpty(){let t=this.firstChunk;do if(t.intro.length&&t.intro.trim()||t.content.length&&t.content.trim()||t.outro.length&&t.outro.trim())return!1;while(t=t.next);return!0}length(){let t=this.firstChunk,n=0;do n+=t.intro.length+t.content.length+t.outro.length;while(t=t.next);return n}trimLines(){return this.trim("[\\r\\n]")}trim(t){return this.trimStart(t).trimEnd(t)}trimEndAborted(t){const n=new RegExp((t||"\\s")+"+$");if(this.outro=this.outro.replace(n,""),this.outro.length)return!0;let o=this.lastChunk;do{const r=o.end,s=o.trimEnd(n);if(o.end!==r&&(this.lastChunk===o&&(this.lastChunk=o.next),this.byEnd[o.end]=o,this.byStart[o.next.start]=o.next,this.byEnd[o.next.end]=o.next),s)return!0;o=o.previous}while(o);return!1}trimEnd(t){return this.trimEndAborted(t),this}trimStartAborted(t){const n=new RegExp("^"+(t||"\\s")+"+");if(this.intro=this.intro.replace(n,""),this.intro.length)return!0;let o=this.firstChunk;do{const r=o.end,s=o.trimStart(n);if(o.end!==r&&(o===this.lastChunk&&(this.lastChunk=o.next),this.byEnd[o.end]=o,this.byStart[o.next.start]=o.next,this.byEnd[o.next.end]=o.next),s)return!0;o=o.next}while(o);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(t,n){function o(s,i){return typeof n=="string"?n.replace(/\$(\$|&|\d+)/g,(a,c)=>c==="$"?"$":c==="&"?s[0]:+c<s.length?s[+c]:`$${c}`):n(...s,s.index,i,s.groups)}function r(s,i){let a;const c=[];for(;a=s.exec(i);)c.push(a);return c}if(t.global)r(t,this.original).forEach(i=>{if(i.index!=null){const a=o(i,this.original);a!==i[0]&&this.overwrite(i.index,i.index+i[0].length,a)}});else{const s=this.original.match(t);if(s&&s.index!=null){const i=o(s,this.original);i!==s[0]&&this.overwrite(s.index,s.index+s[0].length,i)}}return this}_replaceString(t,n){const{original:o}=this,r=o.indexOf(t);return r!==-1&&this.overwrite(r,r+t.length,n),this}replace(t,n){return typeof t=="string"?this._replaceString(t,n):this._replaceRegexp(t,n)}_replaceAllString(t,n){const{original:o}=this,r=t.length;for(let s=o.indexOf(t);s!==-1;s=o.indexOf(t,s+r))o.slice(s,s+r)!==n&&this.overwrite(s,s+r,n);return this}replaceAll(t,n){if(typeof t=="string")return this._replaceAllString(t,n);if(!t.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(t,n)}}const js=S(process.cwd(),"shared/translation.ts"),Us="globalThis.craneSharedTranslation = translation",im=e=>`import translation from '${e}';
|
|
56
|
+
${Us};
|
|
57
|
+
`,am=(e,t)=>{const n=e.split("?")[0],o=mi(n);return(o==="server.ts"||o==="client.ts")&&!t.includes(Us)},Fs=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=H(js)},transform(t,n){if(!e||!am(n,t))return null;const o=n.split("?")[0],r=uo(o),s=Si(lo(r,js)),i=im(s),a=new ao(t);return a.prepend(i),{code:a.toString()}}}},Ms={[te.Server]:()=>[pe.vue(),pe.tsconfigPaths(),Yh(),Hh(),Fs()],[te.Client]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:"EcVue"}),Fs()],[te.Misc]:()=>[pe.tsconfigPaths()],[te.Layout]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:["EcExternals","Vue"]})],[te.Asset]:()=>[Kh()],[te.SharedFiles]:()=>[pe.tsconfigPaths()]},Gs={[N.Server]:Ds({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/server`}),[N.Client]:Ls({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/client`}),[N.SectionSetting]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/showcases`}),[N.SectionAsset]:Kt({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/assets`}),[N.TemplateDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:()=>`./${Te}/js`}),[N.PageTemplateDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Te}/${e}`}),[N.TemplateAsset]:Kt({outDir:()=>`./${Te}/assets`}),[N.Layout]:jh({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}`}),[N.LayoutSettings]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/js/settings`}),[N.LayoutAsset]:Kt({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/assets`}),[N.SlotServer]:Ds({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/server`}),[N.SlotClient]:Ls({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/client`}),[N.CollectionDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${rt}/${e}`}),[N.CollectionAsset]:Kt({outDir:()=>`./${rt}/assets`}),[N.SharedTranslation]:{pluginType:te.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function cm(e){switch(typeof e){case"string":return[S(process.cwd(),e)];case"object":return e.map(t=>S(process.cwd(),t));default:return[]}}function xs({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:r,sectionType:s=_e.SECTION}){const i=Gs[n],a=i.define,c=i.ssrOptions,u=i.entryFileNames,d=i.chunkFileNames,m=i.assetFileNames,y=i.inlineDynamicImports,T=i.externalOption;return{logLevel:Xn()?void 0:"silent",plugins:Ms[i.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:i.ssr,outDir:i.outDir({name:e,sectionType:s,layoutId:o,sectionId:r}),emptyOutDir:!0,minify:i.ssr?"terser":"esbuild",...i.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:T,preserveEntrySignatures:"strict",input:cm(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:y,entryFileNames:u,chunkFileNames:d,assetFileNames:m}}},assetsInclude:["**/*.json"]}}const um=Object.values(G).map(e=>e.source).join("|");function Bs(e,t,n){if(!e)return`${t}.mjs`;const o=lo(process.cwd(),e).replace(/\\/g,"/").match(`^(${um})/([^/]+)/${n}/([^/.]+)`);return o?`${o[1]}/${o[2]}/js/${n}/${o[3]}.mjs`:`${t}.mjs`}function Zs(e,t){const n=Gs[N.SectionSetting];return{logLevel:Xn()?void 0:"silent",plugins:Ms[n.pluginType](),define:n.define,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:n.ssr,outDir:"./dist",emptyOutDir:!1,minify:"esbuild",rollupOptions:{external:n.externalOption,preserveEntrySignatures:"strict",input:e.map(o=>S(process.cwd(),o)),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:n.inlineDynamicImports,entryFileNames:t,chunkFileNames:"chunks/[name]-[hash].js",assetFileNames:n.assetFileNames}}},assetsInclude:["**/*.json"]}}function lm(e){return Zs(e,t=>Bs(t.facadeModuleId??void 0,t.name,"settings"))}function dm(e){return Zs(e,t=>Bs(t.facadeModuleId??void 0,t.name,"showcases"))}async function pm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`./${Be}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:o,sectionId:r,pageId:s}=vh(n),[i,a]=await Promise.all([I(`./${Be}/${r}/${o}/settings/{content,design,translations,layout}.{js,ts}`,e),I(`./${Be}/${r}/${o}/assets/*`,e)]);return{name:o,sectionId:r,pageId:s,clientEntrypoint:n,settingsEntryPoints:i,assetsEntrypoints:a}}))}async function fm(e){await se({entryPoints:[e.clientEntrypoint],configType:N.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([se({entryPoints:e.settingsEntryPoints,configType:N.LayoutSettings,name:e.name,sectionId:e.sectionId}),se({entryPoints:e.assetsEntrypoints,configType:N.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function hm(e){e===void 0||e.length===0||await Promise.all(e.map(t=>fm(t)))}async function mm(e){const t=e.flatMap(o=>o.settingsEntryPoints),n=e.flatMap(o=>o.showcaseEntryPoints);t.length>0&&await ge({configFile:!1,...ht(lm(t))}),n.length>0&&await ge({configFile:!1,...ht(dm(n))})}async function Em(e){await Promise.all([ge({configFile:!1,...ht(xs({name:e.name,entryPoints:e.serverEntrypoint,configType:He.Server,sectionType:e.type}))}),se({entryPoints:e.clientEntrypoint,configType:He.Client,name:e.name,sectionType:e.type}),se({entryPoints:e.assetEntryPoints,configType:He.SectionAsset,name:e.name,sectionType:e.type})])}async function gm(){const e=S(process.cwd(),"shared/translation.ts");H(e)&&await se({entryPoints:["shared/translation.ts"],configType:He.SharedTranslation})}async function Hs(e){await Promise.all([mm(e),...e.map(Em)])}function _m(e){const t=Wt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,r]=t;if(!Ns(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:r,sectionId:n,layoutId:o}}async function ym(e,t){return Promise.all(e.map(async n=>{const o=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),r=await it(o?.translationsSettings),s=await Wn(o?.content??{},r),i=await Yn(o?.design??{},r);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:s,designEditors:i}}))}async function Sm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`${Be}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:o,sectionId:r,layoutId:s}=_m(n),i=(await I(`${Be}/${r}/${s}/slots/${o}/client.{js,ts}`,e))[0];if(i===void 0)throw new Error(`Cannot find client entrypoint file for slot ${o} of section ${r}`);return{id:o,sectionId:r,layoutId:s,serverEntrypoint:n,clientEntrypoint:i}}))}async function Tm(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([se({entryPoints:[e.serverEntrypoint],configType:N.SlotServer,...t}),se({entryPoints:[e.clientEntrypoint],configType:N.SlotClient,...t})])}async function Om(e){e?.length&&await Promise.all(e.map(Tm))}async function Im(e){return(await I(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(Ir).includes(n)})}async function wm(){const e=await I("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(f.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(an),o=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const r=await I(`**/templates/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await I(`**/templates/${o}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await I(`**/templates/${o}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await I(`**/templates/${o}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await I(`**/templates/${o}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await Im(o);return{name:o,configurationEntrypoint:r.at(0),homeEntrypoint:s.at(0),categoryEntrypoint:i.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:u.length>0?u:void 0}}))}async function vm(){const e=await I("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await I("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await wm(),templates:e,assets:t}}async function Cm({templateBuildConfig:e}){await Promise.all([se({entryPoints:e.assets,configType:He.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Zt);if(n.length===0)throw new Error("No entry points provided for page template");await se({entryPoints:n,configType:He.PageTemplateDescriptor,name:t.name})})||[]])}async function Rm(){const e=await vm();await Cm({templateBuildConfig:e})}async function bm(){const e=await I("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(f.error(`Error while getting collection entry points: ${n}`),[])),t=await I("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const o=n.split(an),r=o.pop()??"default";if(o.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const s=await I(`**/collections/${r}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:r,configurationEntrypoint:s.at(0),assetsEntrypoints:t}}))}async function Am(){const e=await bm();e.length!==0&&await Promise.all(e.flatMap(t=>[se({entryPoints:t.assetsEntrypoints,configType:N.CollectionAsset,name:t.name}),se({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:N.CollectionDescriptor,name:t.name})]))}function Vs(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Zt).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Zt),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Zt),assetEntryPoints:e.assetsEntrypoints??[]}}function Ws(e){return e.map(t=>({...t,selectedDesignSettings:t.selectedDesignSettings.map(n=>{const o=n.defaults;return o&&typeof o=="object"&&!("type"in o)?{...n,defaults:{type:n.type,...o}}:n})}))}async function Nm(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),o=yo(So.gunzip),r=await C.promises.readFile(n);return{size:(await o(r)).length}}async function $m(e,t=me){try{const n=S(process.cwd(),`${t}/${e}/assets/`);return(await I("*",{cwd:n})).map(o=>{const r=S(n,o);return{path:o,size:Xe(r).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Qn(e,t){const n=await sh(e,G[t].dist),o=await Vt(e,G[t].dist),r=await ah(e,G[t].dist),s=await ch(e,G[t].dist),i=await lh(e,G[t].dist),a=await dh(e,G[t].dist),c=Ws(a),u=await $m(e,G[t].dist),d=await Nm(e,G[t].dist),m=ph(e);return{id:e,type:t,name:e,content:r,design:s,layout:c,showcase:i,translationsSettings:n,translationsShowcases:o,assets:u,server:d,previewCount:m}}async function Dm(){const e=await I("*/",{cwd:S(process.cwd(),`${me}/`)}),t=await I("*/",{cwd:S(process.cwd(),`${Gn}/`)}),n=await I("*/",{cwd:S(process.cwd(),`${xn}/`)});return Promise.all([...e.map(async o=>Qn(o,xe.SECTION)),...t.map(async o=>Qn(o,xe.HEADER)),...n.map(async o=>Qn(o,xe.FOOTER))])}async function Lm(e){try{const t=S(process.cwd(),`${e}/assets/`);return(await I("*",{cwd:t})).map(n=>{const o=S(t,n);return{path:n,size:Xe(o).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function km(e){const t=Wt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t,[r,s,i,a,c]=await Promise.all([zm(o,n),jm(o,n),ih(o,n),Lm(e),Um(o,n)]);return{id:o,sectionId:n,content:r,design:s,translationsSettings:i,assets:a,layouts:c}}async function Pm(){const e=`${Q}/{product,catalog,category}/*`,t=await I(e,{ignore:["node_modules/**"]});return Promise.all(t.map(km))}async function zm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/content.mjs`),o=await re(n);return ke(o)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function jm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/design.mjs`),o=await re(n);return ke(o)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Um(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/layout.mjs`);if(!C.existsSync(n))return[];const o=await re(n);return Ws(o)}catch(n){throw new Error(`Layout settings descriptor for layout [${e}] in section [${t}] is either invalid or undefined: ${n}`)}}async function Fm(e,t,n){const o=S(process.cwd(),`${Q}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),r=yo(So.gunzip),s=await C.promises.readFile(o);return{size:(await r(s)).length}}async function Mm(e){const t=Wt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,r]=t,s=await Fm(r,o,n);return{id:r,sectionId:n,layoutId:o,server:s}}async function Gm(){const e=`${Q}/{product,catalog,category}/*/slots/*`,t=await I(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(Mm))}async function xm(){try{const e=S(process.cwd(),`${Te}/assets/`);return(await I("*",{cwd:e})).map(t=>{const n=S(e,t);return{path:t,size:Xe(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function Bm(e){return e in Ae?Ae[e]:Ae.CUSTOM}async function Zm(e){const t=await I(`${Te}/${e}/*.mjs`,{ignore:[`${Te}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:r}=await qn(n),s=Pf(n);return{type:Bm(s.toUpperCase()),id:s,metadata:r,sections:o}}))}async function qn(e){try{return await re(S(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function Hm(e){const t=await I(`${Te}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n));return{id:`${e}_${o}`,assets:await xm(),configuration:await qn(n),pages:await Zm(o)}}))}async function Vm(e){return await Hm(e)}async function Wm(){const e=S(process.cwd(),`${Nf}/translation.mjs`);return await re(e)}async function Ym(){return{translations:await Wm()}}async function Km(e){const t=await I(`${rt}/*/configuration*.mjs`,{ignore:["node_modules/**",`${rt}/assets/**`]});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n)),r=await qn(n);return{id:`${e}_${o}`,descriptor:r}}))}async function Ys(){const e=await Ht(),[t,n,o,r,s,i,a]=await Promise.all([Jn(),Ym(),Dm(),Pm(),Gm(),Vm(e.appClientId),Km(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:o,templates:i,layouts:r,slots:s,collections:a,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue,openSource:t.openSource}}function eo(e){return H(`${Gn}/${e}`)?_e.HEADER:H(`${xn}/${e}`)?_e.FOOTER:_e.SECTION}async function to(e,t){const n=e.design?Vn(e.design):void 0,o={...e,design:n??e.design},r=await it(t);return Ze(o,r)}function no(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function Ks(e){if(no(e)){const t=await Vt(e.id,G[eo(e.id)].dist);return{...e,showcase_overrides:await to(e.showcase_overrides,t)}}return e}async function Jm(e){const t=no(e.header)?{...e.header,showcase_overrides:await to(e.header.showcase_overrides,await Vt(e.header.id,G[eo(e.header.id)].dist))}:e.header,n=no(e.footer)?{...e.footer,showcase_overrides:await to(e.footer.showcase_overrides,await Vt(e.footer.id,G[eo(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function Xm(e){const t=await Promise.all(e.pages.map(async o=>({...o,sections:await Promise.all(o.sections.map(r=>Ks(r)))}))),n=await Jm(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function Qm(e){return Promise.all(e.map(t=>Xm(t)))}async function qm(e){const t=new Map;return await Promise.all(e.map(async n=>{const[o,r]=await Promise.all([it(n.translationsSettings),it(n.translationsShowcases)]);t.set(n.id,{settings:o,showcases:r})})),t}async function eE(e,t,n){const[o,r,s,i]=await Promise.all([Wn(e.content,t,e.type),Yn(e.design,t,e.type),uh(e.showcase,n),Rs(e.layout)]);return{id:e.id,type:e.type,name:{en:e.name},contentEditors:o,designEditors:r,layouts:i,showcases:s,previewCount:e.previewCount}}async function tE(e,t){return Promise.all(e.map(async n=>{const o=t.get(n.id)??{settings:{},showcases:{}};return eE(n,o.settings,o.showcases)}))}async function nE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(o=>Ks(o)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function Js(e){const t=await qm(e.sections),[n,o,r,s,i]=await Promise.all([tE(e.sections,t),Ch(e.layouts),ym(e.slots,e.layouts),Qm(e.templates),nE(e.collections)]);return{version:e.version,name:e.name,blocks:n,templates:s,layouts:o,slots:r,compressionEnabled:e.compressionEnabled,externalizationEnabled:e.externalizationEnabled,vueVersion:e.vueVersion,collections:i,openSource:e.openSource}}async function oE(e){const t=S(Et.cwd(),ws);return Ci(t,JSON.stringify(e))}function rE(e){return Object.entries(G).find(t=>t[1].source===e)?.[0]}async function Xs(){const e=await I("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=uo(t).split(an),o=n.pop()??"default",r=n.pop();if(r===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const s=["node_modules/**","dist/**"],[i,a,c,u,d,m,y,T]=await Promise.all([I(`**/${o}/client.{js,ts}`,{ignore:s}),I(`**/${o}/settings/content.{js,ts}`,{ignore:s}),I(`**/${o}/settings/design.{js,ts}`,{ignore:s}),I(`**/${o}/settings/layout.{js,ts}`,{ignore:s}),I(`**/${o}/settings/translations.{js,ts}`,{ignore:s}),I(`**/${o}/showcases/*.{js,ts}`,{ignore:[...s,`**/${o}/showcases/translations.{js,ts}`]}),I(`**/${o}/showcases/translations.{js,ts}`,{ignore:s}),I(`**/${o}/assets/*`,{ignore:s})]);return{name:o,type:rE(r),serverEntrypoint:t,clientEntrypoint:i.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:u.at(0),settingsTranslationsEntrypoint:d.at(0),showcasesEntrypoints:m,showcasesTranslationsEntrypoint:y.at(0),assetsEntrypoints:T}}))}const sE=["/settings/","/showcases/"];function iE(e){return sE.some(t=>e.includes(t))}function aE(){const e=ue.findConfigFile(process.cwd(),ue.sys.fileExists,"tsconfig.json");if(!e)return;const t=ue.readConfigFile(e,ue.sys.readFile),n=ue.parseJsonConfigFileContent(t.config,ue.sys,process.cwd()),o=ue.createProgram(n.fileNames,n.options),r=ue.getPreEmitDiagnostics(o).filter(s=>!s.file||!iE(s.file.fileName));if(r.length>0){const s={getCanonicalFileName:i=>i,getCurrentDirectory:ue.sys.getCurrentDirectory,getNewLine:()=>ue.sys.newLine};throw console.error(ue.formatDiagnosticsWithColorAndContext(r,s)),new Error(`TypeScript found ${r.length} error(s)`)}}async function cE(e){aE(),await ge({configFile:!1,logLevel:"error",plugins:[pe.vue(),pe.tsconfigPaths(),pe.checker()],build:{write:!1,rollupOptions:{input:S(process.cwd(),e)}}})}function uE(){return Promise.all([rn.rm("dist",{recursive:!0,force:!0}),rn.rm("source-code",{recursive:!0,force:!0}),rn.rm("source-code.zip",{force:!0})])}async function lE(){const e=new fo,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"];(await Jn()).openSource===!0&&t.splice(t.indexOf("**/assets/**/*"),1);const n=await I("**/*",{cwd:S(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(s=>{const i=S(process.cwd(),s);e.addLocalFile(i,po(s).dir)});const o=ct[R.SourceCode].fileName,r=S(process.cwd(),o);await e.writeZipPromise(r)}catch(o){throw f.error("Error while zipping source files"),o}}async function Xt(e=!1,t=!1){Uh(t),Ps.start(),await uE();try{const[n,o,r]=await Promise.all([pm(),Xs(),Sm()]),s=o.map(Vs);o.length>0&&await cE(o[0].serverEntrypoint);try{await Promise.all([gm(),Hs(s),Rm(),Am(),hm(n),Om(r),lE()])}finally{Ps.stop()}const i=await Ys(),a=await Dh(i);kh(a,e);const c=await Js(i);await oE(c)}catch(n){f.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function se({entryPoints:e,configType:t,name:n,sectionType:o,sectionId:r,layoutId:s}){if(e.length!==0){const i=ht(xs({name:n,entryPoints:e,configType:t,sectionType:o,sectionId:r,layoutId:s}));await ge({configFile:!1,...i})}}function Qs(e,t,n){pt.statSync(e).isDirectory()?(pt.mkdirSync(t,{recursive:!0}),pt.readdirSync(e).forEach(o=>{const r=ft.resolve(e,o),s=ft.resolve(t,o);Qs(r,s,n)})):ki.isMatch(e,n,{dot:!0})||pt.copyFileSync(e,t)}function Oe(e,t,n,o,r=[]){const s=ft.join(e,o?.[n]??n);Qs(ft.join(t,n),s,r)}function dE(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>f.info(`Template [${e}] with pages structure named has been created`)}}function Ee(e){return V.resolve(Pi(import.meta.url),"../..",e)}function pE(){const e=Ee("package.json");return e!==""?JSON.parse(D.readFileSync(e,"utf8")):{}}async function fE(e){try{const t=e,n=j.cwd(),o=V.join(n,t),r=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],s={_gitignore:".gitignore"};D.existsSync(o)?(f.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):D.mkdirSync(o);const i=Ee("template");D.readdirSync(i).filter(d=>d!=="package.json").filter(d=>!r.includes(d)).forEach(async d=>Oe(o,i,d,s));const a=JSON.parse(D.readFileSync(V.join(i,"package.json"),"utf-8"));a.name=e;const c=pE();c.version&&(a.dependencies["@lightspeed/crane-api"]=c.dependencies["@lightspeed/crane-api"]),c.dependencies["@lightspeed/eslint-config-crane"]&&(a.dependencies["@lightspeed/eslint-config-crane"]=c.dependencies["@lightspeed/eslint-config-crane"]);const u=V.join(o,"package.json");D.writeFileSync(u,`${JSON.stringify(a,null,2)}
|
|
58
|
+
`),f.info(`App ${e} created`)}catch(t){f.error(`Error while creating app: ${t.message}`),j.exit(1)}}function oo(e,t,n,o){try{const r=j.cwd(),s=z.join(r,t);C.existsSync(s)||C.mkdirSync(s);const i=z.join(r,t,n);C.existsSync(i)?(f.error(`${o} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):C.mkdirSync(i);const a=Ee(e);C.readdirSync(a).forEach(async c=>Oe(i,a,c)),f.info(`${o} ${n} created`)}catch(r){f.error(`Error while creating ${o}: ${r.message}`),j.exit(1)}}function ro(e){const t=j.cwd(),n=Ee(`template/${e}`),o=z.join(t,e);C.existsSync(o)||(C.mkdirSync(o),C.readdirSync(n).forEach(async r=>Oe(o,n,r)))}async function hE(e,t,n,o){if(!C.existsSync(n)){C.copyFileSync(t,n);return}const r=C.readFileSync(t),s=C.readFileSync(n);r.equals(s)||(o?(await Le({type:"select",name:"value",message:`File "${e.name}" exists but differs from template. What would you like to do?`,choices:[{title:"Keep existing file",value:"keep"},{title:"Replace with template version",value:"replace"}],initial:0})).value==="replace"?(C.copyFileSync(t,n),f.info(`Replaced "${e.name}" with template version.`)):f.info(`Kept existing "${e.name}".`):f.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function Qt(e,t,n=!1){async function o(s,i,a){const c=z.join(i,s.name),u=z.join(a,s.name);s.isDirectory()?await Qt(c,u,n):await hE(s,c,u,n)}const r=C.readdirSync(e,{withFileTypes:!0});C.existsSync(t)||C.mkdirSync(t,{recursive:!0}),await r.reduce(async(s,i)=>(await s,o(i,e,t)),Promise.resolve())}async function so(e=!1){try{const t=j.cwd(),n=z.join(t,"shared"),o=Ee("template/shared");if(!C.existsSync(o))return;await Qt(o,n,e)}catch(t){f.error(`Error while processing shared folder: ${t.message}`),j.exit(1)}}async function mE(e,t){await so(),oo(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function EE(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>f.info(`Collection [${e}] has been created`)}}async function gE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onCollectionCreated:r}=EE(e);try{const s=j.cwd(),i=V.join(s,"collections"),a=Ee(o),c=D.readdirSync(a);D.existsSync(i)?D.existsSync(V.join(i,t))&&(f.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):D.mkdirSync(i),c.forEach(u=>Oe(i,a,u,n)),r()}catch(s){f.error(`Error while creating collection: ${s.message}`),j.exit(1)}}async function _E(e){await so(),oo("template/footers/example-footer","footers",e,"Footer")}async function yE(e){await so(),oo("template/headers/example-header","headers",e,"Header")}async function SE(e,t){try{const n=j.cwd(),o=V.join(n,"templates"),r=Ee("template/page-templates/example-template/pages");D.existsSync(V.join(o,e))||(f.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),j.exit(1)),D.existsSync(V.join(o,e,"pages",`${t}.ts`))&&(f.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),j.exit(1));const s=D.readFileSync(V.join(r,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${zf(t)}'`),i=V.join(o,e,"pages",`${t}.ts`);D.writeFileSync(i,s),f.info(`Page [${t}.ts] created for template ${e}`)}catch(n){f.error(`Error while creating page: ${n.message}`),j.exit(1)}}async function TE(){try{const e=j.cwd(),t=Ee("template/reference"),n=D.readdirSync(t);let o=!1;for(const r of n){const s=V.join(t,r),i=V.join(e,r);D.existsSync(i)||D.mkdirSync(i,{recursive:!0});const a=D.readdirSync(s),c=D.readdirSync(i);if(r==="shared"){a.forEach(u=>{Oe(i,s,u)});continue}for(const u of a){if(u==="assets"){Oe(i,s,u);continue}if(c.includes(u)){const{name:d}=await Le({type:"text",name:"name",message:`The "${u}" already exists in ${r} directory: provide a new name to keep both or press Esc to skip this one.`});d?(Oe(i,s,u,{[u]:d}),o=!0):f.info(`Skipped: ${u}`)}else Oe(i,s,u)}}f.info("Reference templates have been added to the app"),o&&f.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){f.error(`Error while creating template descriptors: ${e.message}`),j.exit(1)}}const OE=["**/example-template/pages/custom.ts"];async function IE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onTemplateCreated:r}=dE(e);try{const s=j.cwd(),i=V.join(s,"templates"),a=Ee(o),c=D.readdirSync(a);D.existsSync(i)?D.existsSync(V.join(i,t))&&(f.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):D.mkdirSync(i),c.forEach(u=>Oe(i,a,u,n,OE)),ro("headers"),ro("footers"),ro("layouts"),r()}catch(s){f.error(`Error while creating template descriptors: ${s.message}`),j.exit(1)}}function wE(){try{const e=S(Et.cwd(),`${Is}/shared/analytics.json`);H(e)&&sn(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function qt({deploymentContext:e,sectionType:t=_e.SECTION}){const n=e.pathContext,o=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),r=o===void 0?ho(n.fileName):ho(n.fileName,{cwd:S(process.cwd(),o),ignore:n.ignore});return(n.isSingleton?r.splice(0):r).map(s=>({url:s,sectionType:t,context:e}))}const vE=e=>e.app.manifest.blocks.flatMap(t=>yh.flatMap(n=>{const o={config:e,currentSection:t.id,pathContext:ct[n]};return qt({deploymentContext:o,sectionType:t.type})})),CE=e=>Oh.flatMap(t=>{const n={config:e,pathContext:ct[t]};return qt({deploymentContext:n})}),RE=e=>e.app.manifest.layouts.flatMap(t=>Sh.flatMap(n=>{const o={config:e,pathContext:ct[n],currentSection:t.sectionId,layoutId:t.id};return qt({deploymentContext:o})})),bE=e=>e.app.manifest.slots.flatMap(t=>Th.flatMap(n=>{const o={config:e,pathContext:ct[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return qt({deploymentContext:o})})),AE=e=>`\x1B[32m${e}\x1B[0m`,NE=(e,t,n,o,r)=>{if(!e.total)return;const{loaded:s}=e,i=(Date.now()-r)/1e3;n.value+=s-o.value,o.value=s,t.update({speed:`${Se(n.value/i,2)}/s`})},$E=()=>new Ui.SingleBar({format:`|${AE("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function qs(e){await new Promise(t=>setTimeout(t,e))}const ei="Please ensure you have built your application before deploying.";async function DE(){try{const e=await un(S(Et.cwd(),ws));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${ei}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${ei}`):e}}const LE={value:0},ie=$E();let ti=Date.now();const ni=e=>2**e*500;async function kE(e){const t=ji(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,sn(S(F.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
59
|
+
`)}function PE(e){return e instanceof Eo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function oi(e,t){return e<_h&&PE(t)}async function ri(e,t,n,o){const r={value:0},s=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?hh:fh;return e.config.axios.post(s,{file:pi(S(F.cwd(),n!==void 0?n+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.layoutId!==void 0&&{layoutId:e.layoutId},...e.slotId!==void 0&&{slotId:e.slotId},...!["dependencies","source_code"].includes(e.pathContext.type)&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`},onUploadProgress:i=>NE(i,ie,LE,r,ti)}).then(i=>(ie.increment(),i)).catch(async i=>{if(oi(o,i))return await qs(ni(o)),ri(e,t,n,o+1);throw ie.increment(),i})}function zE(e){return ie.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,o=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return ri(n,t.url,o,0)})}function jE(e){const t=[...vE(e),...CE(e),...RE(e),...bE(e)];return zE(t)}async function si(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?Eh:mh;return e.axios.post(n,e.app.manifest,{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async o=>{if(oi(t,o))return await qs(ni(t)),si(e,t+1);throw o})}async function UE(e){try{if(!$f.some(i=>H(S(F.cwd(),i))))throw new Error(Ve.INCORRECT_DISTRIBUTION_FOLDER(Af));const t=e??Kn;f.info("Custom application deployment :: Started");const n=ln.create({baseURL:t});zi(n,gh),f.info("Loading configuration files ...");const o=await Promise.all([Ht(),Jn(),DE()]).then(([i,a,c])=>({axios:n,app:{crane:i,packageJson:a,manifest:c}}));f.info("Uploading files ..."),ti=Date.now(),await Promise.all(jE(o)).catch(i=>{ie.stop(),i.response?.status===404?f.error($e(i,Ve.DEPRECATED_VERSION_DEPLOYMENT)):f.error($e(i,Ve.ASSET_FILES_UPLOAD)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()}),ie.update({speed:"N/A",status:"Finalising deployment"}),await si(o).catch(i=>{ie.stop(),i.response?.status===404?f.error($e(i,Ve.DEPRECATED_VERSION_DEPLOYMENT)):f.error($e(i,Ve.MANIFEST_DEPLOYMENT)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()});const r=o.app.manifest.blocks.map(i=>i.id),s=o.app.packageJson.version;f.info("Custom application deployment :: Successful"),f.info(`Current app version: ${s}`),f.info(`Deployed sections: ${r.sort().join(", ")}`),await kE(o.app.packageJson),o.app.manifest.templates.length>0&&f.info(`Deployed templates: ${o.app.manifest.templates.map(i=>i.id).sort().join(", ")}`),o.app.manifest.slots.length>0&&f.info(`Deployed slots: ${o.app.manifest.slots.map(i=>i.id).sort().join(", ")}`),o.app.manifest.collections.length>0&&f.info(`Deployed collections: ${o.app.manifest.collections.map(i=>i.id).sort().join(", ")}`)}catch(t){ie.stop(),f.error($e(t,Ve.DEFAULT)),F.exit(1)}finally{wE()}}function FE(){process.env.CRANE_DEBUG_ENABLED="true"}function ME(){return process.env.CRANE_DEBUG_ENABLED==="true"}function GE(e,...t){ME()&&console.debug(yi(`[DEBUG] ${e}`),...t)}function xE(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,o)=>{e.moduleGraph.invalidateAll();const r=new Ri(t.url||"",`http://${t.headers.host}`);if(r.pathname==="/api/v1/block-config"&&t.method==="GET"){const s=r.searchParams.get("section");if(!s){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}try{const i=await Ys(),a=(await Js(i)).blocks.find(c=>c.id===s);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(a))}catch(i){n.statusCode=500,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:i.message}))}return}o()})}}}let De=null;function BE(){De&&De.clients.forEach(e=>{e.readyState===Mi.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function ZE(e,t){const n=S(`${e}/ssr-server.ts`),o=S(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:o,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function HE(e,t){const n=S(`${e}/shared/preview.ts`),o=S(`${e}/shared/utils.ts`),r=S(`${e}/shared/api-routes.ts`),s=S(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ge({build:{lib:{entry:o,formats:["es"],fileName:()=>"utils.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ge({build:{lib:{entry:r,formats:["es"],fileName:()=>"api-routes.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function VE(){const e="preview",t=`${e}/shared`,n="vite.config.js",o=`${e}/sections`,r=`${o}/preview.html`;[e,o].forEach(c=>{C.existsSync(c)||C.mkdirSync(c,{recursive:!0})});const s=Ee("template/preview");C.copyFileSync(`${s}/${n}`,`${e}/${n}`),await ZE(s,e),C.copyFileSync(`${s}/sections/preview.html`,r);const i=`${s}/assets`,a=`${e}/assets`;C.existsSync(i)&&(C.mkdirSync(a,{recursive:!0}),C.readdirSync(i).forEach(c=>{C.copyFileSync(`${i}/${c}`,`${a}/${c}`)})),C.existsSync(t)||C.mkdirSync(t),await HE(s,t)}function WE(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function YE(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function KE(e){const t=(await Xs()).find(o=>o.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await Xt(!0);return}const n=Vs(t);await Hs([n]),console.log(`Block ${e} rebuilt successfully`)}var JE=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(JE||{});function XE(){return{timeout:null,inProgress:!1,pendingBuild:null}}function QE(e,t){const n=async o=>{e.inProgress=!0;try{o.type==="incremental"&&o.blockName?await KE(o.blockName):await Xt(!0),t.ws.send({type:"full-reload",path:"*"}),BE()}catch(r){console.error("Build error:",r)}finally{if(e.inProgress=!1,e.pendingBuild){const r=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(r),0)}}};return async o=>{if(e.inProgress){o.type==="full"||e.pendingBuild?.type==="full"?e.pendingBuild={type:"full"}:e.pendingBuild=o;return}await n(o)}}function qE(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),o=t.match(/headers\/([^/]+)/),r=t.match(/footers\/([^/]+)/),s=t.match(/shared\//);return!!(n||o||r||s)}function eg(e,t){return async n=>{if(!qE(n))return;e.timeout&&clearTimeout(e.timeout);const o=WE(n),r=YE(n);e.timeout=setTimeout(async()=>{r?await t({type:"full"}):o&&await t({type:"incremental",blockName:o})},1e3)}}function tg(e,t){const n=XE(),o=QE(n,e),r=eg(n,o);e.watcher.add(t),e.watcher.on("add",r),e.watcher.on("change",r),e.watcher.on("unlink",r)}async function ng(){const e=z.resolve(process.cwd(),"preview/ssr-server.mjs");if(!C.existsSync(e))throw console.warn(`\u26A0\uFE0F SSR server not found at ${e}`),new Error(`SSR server not found at ${e}`);process.env.PREVIEW_SSR_PORT="0";let t=e;process.platform==="win32"&&(t=mo(e).href);const n=await import(t),{server:o,port:r}=await n.startServer();return{server:o,port:r}}function og(){De=new Fi({port:0}),De.on("listening",()=>{const e=De?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function rg(){const e=z.resolve(process.cwd(),"preview/vite.config.js"),t=z.resolve(process.cwd(),"sections/**/*"),n=z.resolve(process.cwd(),"headers/**/*"),o=z.resolve(process.cwd(),"footers/**/*"),r=z.resolve(process.cwd(),"shared/**/*"),s=await Ti({configFile:e,root:process.cwd(),plugins:[xE()]});return await s.listen(),tg(s,[t,n,o,r]),s}async function sg(){await Xt(),await VE(),console.log(`
|
|
76
60
|
\u{1F4E6} Starting preview servers...
|
|
77
|
-
`);let e=null,t=null;
|
|
78
|
-
The pulled source code defines npm overrides not present in your project:`);for(const[n,
|
|
79
|
-
The pulled source code uses ${
|
|
80
|
-
`),
|
|
81
|
-
Run the following command(s) to install the dependencies:`);for(const c of a)
|
|
61
|
+
`);let e=null,t=null;GE("Starting SSR server");const n=await ng();e=n.server,t=n.port,process.env.PREVIEW_SSR_PORT=String(t),og();const o=await rg(),r=()=>{e&&e.close(),De&&De.close(),o.close(),process.exit(0)};return process.on("SIGINT",r),process.on("SIGTERM",r),o}const ig=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,ag=/^[-a-zA-Z0-9_.^~<>=|* +]+$/;function ii({name:e,version:t}){return ig.test(e)&&ag.test(t)}function en(e){if(!H(e))return{dependencies:{},devDependencies:{},overrides:{}};let t;try{t=JSON.parse(on(e,"utf-8"))}catch{return{dependencies:{},devDependencies:{},overrides:{}}}const n=t.overrides??{},o=Object.fromEntries(Object.entries(n).filter(r=>typeof r[1]=="string"));return{dependencies:t.dependencies??{},devDependencies:t.devDependencies??{},overrides:o}}function cg(e,t){const n=en(ee(e,"package.json")),o=en(ee(t,"package.json")),r={...o.dependencies,...o.devDependencies},s=[];for(const[i,a]of Object.entries(n.dependencies))r[i]||s.push({name:i,version:a,isDev:!1});for(const[i,a]of Object.entries(n.devDependencies))r[i]||s.push({name:i,version:a,isDev:!0});return s.sort((i,a)=>i.name.localeCompare(a.name))}function ug(e,t){const n=en(ee(e,"package.json")).overrides,o=en(ee(t,"package.json")).overrides;return Object.fromEntries(Object.entries(n).filter(([r,s])=>o[r]!==s))}function lg(e){const t=Object.entries(e);if(t.length!==0){f.warn(`
|
|
62
|
+
The pulled source code defines npm overrides not present in your project:`);for(const[n,o]of t)f.warn(` - ${n}: "${o}"`);f.warn('Review these and add them to your package.json "overrides" section if needed.')}}function ai(e){return e.map(t=>`${t.name}@${t.version}`).join(" ")}function dg(e){const t=e.filter(r=>!r.isDev),n=e.filter(r=>r.isDev),o=[];return t.length>0&&o.push(`npm install ${ai(t)}`),n.length>0&&o.push(`npm install -D ${ai(n)}`),o}function pg(e,t){const n=[{args:["install"],specs:e.filter(o=>!o.isDev).map(o=>`${o.name}@${o.version}`)},{args:["install","-D"],specs:e.filter(o=>o.isDev).map(o=>`${o.name}@${o.version}`)}];for(const{args:o,specs:r}of n){if(r.length===0)continue;const s=[...o,...r];f.info(`Running: npm ${s.join(" ")}`);const i=xi("npm",s,{cwd:t,stdio:"inherit"});if(i.status!==0)throw new Error(`npm ${o.join(" ")} exited with code ${i.status}`)}}async function fg(e,t){if(e.length===0)return;const n=e.filter(c=>!ii(c));if(n.length>0){f.warn("Skipping dependencies with unsafe names/versions:");for(const c of n)f.warn(` - ${c.name}@${c.version}`)}const o=e.filter(ii);if(o.length===0)return;const r=o.length===1?"dependency":"dependencies";f.warn(`
|
|
63
|
+
The pulled source code uses ${o.length} ${r} not found in your project:`);const s=o.filter(c=>!c.isDev),i=o.filter(c=>c.isDev);if(s.length>0){f.warn(" dependencies:");for(const c of s)f.warn(` - ${c.name}@${c.version}`)}if(i.length>0){f.warn(" devDependencies:");for(const c of i)f.warn(` - ${c.name}@${c.version}`)}const a=dg(o);switch((await Le({type:"select",name:"value",message:"How would you like to handle these dependencies?",choices:[{title:"Install dependencies now",value:"install",description:`Runs: ${a.join(" && ")}`},{title:"Add to package.json without installing",value:"add"},{title:"Show install command (copy & run later)",value:"show"},{title:"Skip",value:"skip"}],initial:0})).value){case"install":try{pg(o,t),f.info("Dependencies installed successfully.")}catch{f.error("Failed to install dependencies. You can try running the commands manually:");for(const c of a)f.warn(` ${c}`)}break;case"add":{const c=ee(t,"package.json"),u=JSON.parse(on(c,"utf-8"));if(s.length>0){u.dependencies||(u.dependencies={});for(const d of s)u.dependencies[d.name]=d.version;u.dependencies=Object.fromEntries(Object.entries(u.dependencies).sort(([d],[m])=>d.localeCompare(m)))}if(i.length>0){u.devDependencies||(u.devDependencies={});for(const d of i)u.devDependencies[d.name]=d.version;u.devDependencies=Object.fromEntries(Object.entries(u.devDependencies).sort(([d],[m])=>d.localeCompare(m)))}sn(c,`${JSON.stringify(u,null,2)}
|
|
64
|
+
`),f.info('Dependencies added to package.json. Run "npm install" to install them.');break}case"show":f.info(`
|
|
65
|
+
Run the following command(s) to install the dependencies:`);for(const c of a)f.info(` ${c}`);break;default:f.info("Skipping dependency installation.");break}}async function hg(e,t,n){const o=t.split("_").pop()??t,r=ee(e,"sections",o),s=ee(e,o);let i=null;if(H(r)&&Xe(r).isDirectory()?i=r:H(s)&&Xe(s).isDirectory()&&(i=s),i){const a=ee(n,o);H(a)&&((await Le({type:"confirm",name:"value",message:`Section directory [sections/${o}/] already exists. Do you want to overwrite it?`,initial:!1})).value||(f.error("Operation cancelled. Section directory already exists."),F.exit(1)),f.info(`Deleting existing section directory [sections/${o}/]...`),co(a,{recursive:!0,force:!0})),f.info(`Copying section [sections/${o}/]...`),await Qt(i,a,!1)}else f.error(`Section directory [sections/${o}/] not found in source code.`),F.exit(1)}async function mg(e,t,n){const o=fi(ee(Gi.tmpdir(),"crane-source-"));new fo(Buffer.from(e)).extractAllTo(o,!0);try{const r=F.cwd(),s=ee(r,"sections");H(s)||hi(s,{recursive:!0}),await hg(o,t,s);const i=ee(o,"shared");if(H(i)){const c=ee(r,"shared");f.info("Copying shared folder..."),await Qt(i,c,!0)}const a=cg(o,r);await fg(a,r),lg(ug(o,r)),f.info(`Source code for section [${n}] has been copied.`)}finally{co(o,{recursive:!0,force:!0})}}async function ci(e){const t=e??Kn,n=ln.create({baseURL:t}),o=await Ht();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:o.appClientId},headers:{Authorization:`Bearer ${o.appSecretKey}`}})).data.sections]}async function Eg(e,t){const n=(await ci(t)).find(o=>o.sectionId===e);return n||(f.error(`Section [${e}] not found in collection sections list.`),F.exit(1)),n}async function gg(e,t,n){const o=n??Kn,r=ln.create({baseURL:o}),s=await Ht();f.info(`Downloading source code for section [${e}]...`);const i=await r.get(`/api/v1/custom-apps/manifests/collections/sections/${e}/source-code`,{params:{appClientId:s.appClientId},headers:{Authorization:`Bearer ${s.appSecretKey}`},responseType:"arraybuffer"});await mg(i.data,t,e)}async function _g(e){try{f.info("Fetching sections list...");const t=await ci(e);f.info("Sections list retrieved successfully:");const n=t.map(o=>({sectionId:o.sectionId,openSource:o.openSource,type:o.type}));console.log(JSON.stringify({sections:n},null,2))}catch(t){f.error($e(t,"Error while fetching sections list")),F.exit(1)}}async function yg(e,t){try{const n=await Eg(e,t);n.openSource||(f.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),F.exit(1)),await gg(e,n.sectionId,t)}catch(n){f.error($e(n,"Error while pulling section")),F.exit(1)}}async function Sg(e,t){const{list:n,section:o}=e;if(n){await _g(t);return}if(o){await yg(o,t);return}f.error("Please specify an action. Use --list to fetch sections list or --section to pull a section."),F.exit(1)}const Tg={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},Og=["preview","build","deploy","pull"];function Ig(e,t){return Og.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function wg(e){return e.includes("-h")||e.includes("--help")}function vg(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!Tg[e.rawName]?.includes(n))}function Cg(e){return e.length!==0}function Rg(e,t,n){return e.matchedCommand!==void 0&&(Ig(e.matchedCommand,n)||wg(e.rawArgs)||vg(e.matchedCommand,e.options)||Cg(t))}function bg(e,t,n){e.matchedCommand&&!Rg(e,t,n)?e.runMatchedCommand():e.outputHelp()}function tn(e){if(kf(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=Lf(e);return n&&console.log(n),t}async function io(e){const t=await Le({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=z.basename(t.name);return tn(n)?n:io(e)}}async function Ag(e,t,n,o){const r=await io(t);return r===void 0?(console.log(`You can use ${n} to directly specify the name of the ${t}.`),e.outputHelp()):o(r)}async function Je(e,t,n,o,r){if(r!==void 0)if(!tn(r))await Ag(e,t,n,o);else{const s=z.basename(r.toString());await o(s)}}function Ng(){C.existsSync("./templates")||(f.error(`No template found. Please create a template first using ${ce("init --template <name>")}`),process.exit(1));const e=C.readdirSync("./templates",{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).filter(t=>t!=="assets");return e.length===0&&(f.error(`No template found. Please create a template first using ${ce("init --template <name>")}`),process.exit(1)),e}async function $g(e){const t=Ng();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();tn(e)?f.warn(`Template [${e}] doesn't exist`):f.error(`[${e}] is an invalid template name.`)}const n=await Le({type:"select",name:"choice",message:"Please choose a template:",choices:t.map(o=>({title:o,value:o}))});return n.choice||(f.error("No template selected"),process.exit(1)),n.choice}async function Dg(e,t){if(typeof t=="string"||typeof t=="number"){if(tn(t))return t.toString();f.error(`${t} is invalid name.`)}return io(e)}async function Lg(e,t,n){const o=await $g(t),r=await Dg("page",n);if(r===void 0)return console.log(`You can use ${ce("init --page <name>")} to directly specify the name of the page.`),e.outputHelp();await SE(o,r)}async function kg(e,t){try{const{app:n,section:o,header:r,footer:s,template:i,referenceTemplate:a,page:c,blank:u,collection:d}=e;await Je(t,"app",ce("init --app <name>"),fE,n),await Je(t,"section",ce(`init --section <name>${u?" --blank":""}`),m=>mE(m,u===!0),o),await Je(t,"header",ce("init --header <name>"),yE,r),await Je(t,"footer",ce("init --footer <name>"),_E,s),c===void 0?await Je(t,"template",ce("init --template <name>"),IE,i):await Lg(t,i,c),await Je(t,"collection",ce("init --collection <name>"),gE,d),a&&await TE()}catch(n){f.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function Pg(){try{const e=Ei("crane");e.option("-h, --help","Display this message"),e.command("init","Initialize a new resource in the form of a directory.").option("--app [name]","Creates an app folder inside your current directory.").option("--section [name]","Creates the files necessary for one custom section with the given name, this can be repeated for each section.").option("--header [name]","Creates the files necessary for one custom header with the given name, this can be repeated for each header.").option("--footer [name]","Creates the files necessary for one custom footer with the given name, this can be repeated for each footer.").option("--template [name]","Creates the directory and files necessary to build a custom template inside your app folder.").option("--collection [name]","Creates a collection folder containing custom sections, headers, and footers.").option("--reference-template","Adds files necessary for the reference templates inside your app folder. ").option("--page [name]","Create the file necessary for one custom page with the given name, this can be repeated for each custom page.").option("--blank","Creates an empty resource with minimal files (use with section).").allowUnknownOptions().action(async n=>kg(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>Xt(!1,n.verbose===!0)),e.command("preview","Runs a local server to preview resources").option("--verbose","Show debug logs").allowUnknownOptions().action(async n=>{n.verbose&&FE(),await sg()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>UE(e.options.url)),e.command("pull","Pulls resources from the API").option("--list","Fetches the list of sections from the API").option("--section [name]","Downloads source code for an open source section").allowUnknownOptions().action(async n=>Sg(n,e.options.url)),e.version(Bi),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});bg(e,t.args,t.options)}catch(e){f.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{Pg as run};
|