@lightspeed/crane 3.4.4-rc.2 → 3.4.4-rc.4
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/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import*as pt from"fs";import C,{existsSync as H,readFileSync as on,statSync as Qe,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 ke 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.4-rc.2",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 Pe(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:Pe(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:Pe(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 ze 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 je(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 je(e)?{...e}:Array.isArray(e)?[...e]:e}const Wi=new Set(["string","number","symbol"]);function Ue(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(!je(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(!je(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 Fe(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 Me(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 et(...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 ze;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 ze;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=Ue(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(`^${Ue(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(`.*${Ue(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),
|
|
3
|
-
`))}}const
|
|
1
|
+
import*as ft from"fs";import C,{existsSync as V,readFileSync as sn,statSync as Qe,promises as rn,writeFileSync as an,createReadStream as gi,mkdtempSync as _i,mkdirSync as yi,rmSync as co}from"fs";import*as ht from"path";import z,{resolve as S,dirname as lo,relative as uo,basename as Si,sep as cn,parse as po,join as ne}from"path";import Ti from"cac";import{green as ce,yellow as Oi,red as Ii,gray as wi}from"kolorist";import Pe from"prompts";import fo from"adm-zip";import{glob as I,globSync as ho}from"glob";import le from"typescript";import{normalizePath as vi,build as ge,defineConfig as mt,createServer as Ci}from"vite";import"vue";import"vue/server-renderer";import*as F from"process";import Et from"process";import{JSONPath as Ri}from"jsonpath-plus";import{readFile as ln,writeFile as bi}from"fs/promises";import{pathToFileURL as mo,URL as Ai}from"url";import un,{AxiosError as Eo}from"axios";import Ni from"tinycolor2";import{builtinModules as go}from"module";import{viteExternalsPlugin as _o}from"vite-plugin-externals";import $i from"vite-plugin-compression";import Li from"@vitejs/plugin-vue";import Di from"vite-tsconfig-paths";import ki from"vite-plugin-checker";import{encode as Pi}from"@jridgewell/sourcemap-codec";import{promisify as yo}from"node:util";import So from"node:zlib";import L from"node:fs";import W from"node:path";import j from"node:process";import zi from"micromatch";import{fileURLToPath as ji}from"node:url";import{ConcurrencyManager as Ui}from"axios-concurrency";import{inc as Fi}from"semver";import Mi from"cli-progress";import{WebSocketServer as Gi,WebSocket as xi}from"ws";import*as Bi from"os";import{spawnSync as Zi}from"child_process";const Hi="3.4.4-rc.4";function u(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 l=i.prototype,d=Object.keys(l);for(let m=0;m<d.length;m++){const y=d[m];y in a||(a[y]=l[y].bind(a))}}const s=n?.Parent??Object;class r extends s{}Object.defineProperty(r,"name",{value:e});function i(a){var c;const l=n?.Parent?new r:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}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 ze 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 _e(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,s])=>t.indexOf(+o)===-1).map(([o,s])=>s)}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 Vi(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let s=(o.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c?.[1]&&(s=Number.parseInt(c[1]))}const r=n>s?n:s,i=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return i%a/10**r}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(s){Object.defineProperty(e,t,{value:s})},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 Wi(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 Yi=gt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function je(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 je(e)?{...e}:Array.isArray(e)?[...e]:e}const Ki=new Set(["string","number","symbol"]);function Ue(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 Ji(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Xi={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 Qi(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 r=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,r)}function qi(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 r=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,r)}function ea(e,t){if(!je(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(r,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=Ie(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return be(this,"shape",r),r}});return we(e,s)}function ta(e,t){if(!je(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 na(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 oa(e,t,n){const s=t._zod.def.checks;if(s&&s.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 l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return be(this,"shape",c),c},checks:[]});return we(t,i)}function sa(e,t,n){const o=Ie(t._zod.def,{get shape(){const s=t._zod.def.shape,r={...s};if(n)for(const i in n){if(!(i in r))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(r[i]=new e({type:"nonoptional",innerType:s[i]}))}else for(const i in s)r[i]=new e({type:"nonoptional",innerType:s[i]});return be(this,"shape",r),r}});return we(t,o)}function Fe(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 Me(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 s=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(n.customError?.(e))??_t(n.localeError?.(e))??"Invalid input";o.message=s}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 et(...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=u("$ZodError",Ro),Ao=u("$ZodError",Ro,{Parent:Error});function ra(e,t=n=>n.message){const n={},o=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):o.push(t(s));return{formErrors:o,fieldErrors:n}}function ia(e,t=n=>n.message){const n={_errors:[]},o=s=>{for(const r of s.issues)if(r.code==="invalid_union"&&r.errors.length)r.errors.map(i=>o({issues:i}));else if(r.code==="invalid_key")o({issues:r.issues});else if(r.code==="invalid_element")o({issues:r.issues});else if(r.path.length===0)n._errors.push(t(r));else{let i=n,a=0;for(;a<r.path.length;){const c=r.path[a];a===r.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(r))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const En=e=>(t,n,o,s)=>{const r=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new ze;if(i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>ve(c,r,_e())));throw vo(a,s?.callee),a}return i.value},gn=e=>async(t,n,o,s)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>ve(c,r,_e())));throw vo(a,s?.callee),a}return i.value},yt=e=>(t,n,o)=>{const s=o?{...o,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},s);if(r instanceof Promise)throw new ze;return r.issues.length?{success:!1,error:new(e??bo)(r.issues.map(i=>ve(i,s,_e())))}:{success:!0,data:r.value}},aa=yt(Ao),St=e=>async(t,n,o)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(i=>ve(i,s,_e())))}:{success:!0,data:r.value}},ca=St(Ao),la=e=>(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,s)},ua=e=>(t,n,o)=>En(e)(t,n,o),da=e=>async(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,s)},pa=e=>async(t,n,o)=>gn(e)(t,n,o),fa=e=>(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return yt(e)(t,n,s)},ha=e=>(t,n,o)=>yt(e)(t,n,o),ma=e=>async(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return St(e)(t,n,s)},Ea=e=>async(t,n,o)=>St(e)(t,n,o),ga=/^[cC][^\s-]{8,}$/,_a=/^[0-9a-z]+$/,ya=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sa=/^[0-9a-vA-V]{20}$/,Ta=/^[A-Za-z0-9]{27}$/,Oa=/^[a-zA-Z0-9_-]{21}$/,Ia=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wa=/^([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)$/,va=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ca="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ra(){return new RegExp(Ca,"u")}const 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])$/,Aa=/^(([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}|:))$/,Na=/^((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])$/,$a=/^(([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])$/,La=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$o=/^[A-Za-z0-9_-]*$/,Da=/^\+[1-9]\d{6,14}$/,Lo="(?:(?:\\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])))",ka=new RegExp(`^${Lo}$`);function Do(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 Pa(e){return new RegExp(`^${Do(e)}$`)}function za(e){const t=Do({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(`^${Lo}T(?:${o})$`)}const ja=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ua=/^-?\d+$/,ko=/^-?\d+(?:\.\d+)?$/,Fa=/^(?:true|false)$/i,Ma=/^[^A-Z]*$/,Ga=/^[^a-z]*$/,J=u("$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=u("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Po[typeof t.value];e._zod.onattach.push(o=>{const s=o._zod.bag,r=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?s.maximum=t.value:s.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=u("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Po[typeof t.value];e._zod.onattach.push(o=>{const s=o._zod.bag,r=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?s.minimum=t.value:s.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})}}),xa=u("$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):Vi(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})}}),Ba=u("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[s,r]=Xi[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=s,a.maximum=r,n&&(a.pattern=Ua)}),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<s&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Za=u("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const s=o.value;return!fn(s)&&s.length!==void 0}),e._zod.onattach.push(o=>{const s=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const s=o.value;if(s.length<=t.maximum)return;const i=mn(s);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Ha=u("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const s=o.value;return!fn(s)&&s.length!==void 0}),e._zod.onattach.push(o=>{const s=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const s=o.value;if(s.length>=t.minimum)return;const i=mn(s);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Va=u("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const s=o.value;return!fn(s)&&s.length!==void 0}),e._zod.onattach.push(o=>{const s=o._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=o=>{const s=o.value,r=s.length;if(r===t.length)return;const i=mn(s),a=r>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=u("$ZodCheckStringFormat",(e,t)=>{var n,o;J.init(e,t),e._zod.onattach.push(s=>{const r=s._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Wa=u("$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})}}),Ya=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ma),Tt.init(e,t)}),Ka=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ga),Tt.init(e,t)}),Ja=u("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=Ue(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(s=>{const r=s._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),Xa=u("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${Ue(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),Qa=u("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${Ue(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),qa=u("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ec{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),s=Math.min(...o.map(i=>i.length-i.trimStart().length)),r=o.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of r)this.content.push(i)}compile(){const t=Function,n=this?.args,s=[...(this?.content??[""]).map(r=>` ${r}`)];return new t(...n,s.join(`
|
|
3
|
+
`))}}const tc={major:4,minor:3,patch:6},D=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tc;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const s of o)for(const r of s._zod.onattach)r(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(i,a,c)=>{let l=Fe(i),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(i))continue}else if(l)continue;const y=i.issues.length,T=m._zod.check(i);if(T instanceof Promise&&c?.async===!1)throw new ze;if(d||T instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await T,i.issues.length!==y&&(l||(l=Fe(i,y)))});else{if(i.issues.length===y)continue;l||(l=Fe(i,y))}}return d?d.then(()=>i):i},r=(i,a,c)=>{if(Fe(i))return i.aborted=!0,i;const l=s(a,o,c);if(l instanceof Promise){if(c.async===!1)throw new ze;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(d=>r(d,i,a)):r(l,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new ze;return c.then(l=>s(l,o,a))}return s(c,o,a)}}b(e,"~standard",()=>({validate:s=>{try{const r=aa(e,s);return r.success?{value:r.data}:{issues:r.error?.issues}}catch{return ca(e,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),_n=u("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ja(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}}),$=u("$ZodStringFormat",(e,t)=>{Tt.init(e,t),_n.init(e,t)}),nc=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wa),$.init(e,t)}),oc=u("$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)}),sc=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=va),$.init(e,t)}),rc=u("$ZodURL",(e,t)=>{$.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),s=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.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(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.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=s.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ic=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ra()),$.init(e,t)}),ac=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Oa),$.init(e,t)}),cc=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ga),$.init(e,t)}),lc=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_a),$.init(e,t)}),uc=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ya),$.init(e,t)}),dc=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Sa),$.init(e,t)}),pc=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ta),$.init(e,t)}),fc=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=za(t)),$.init(e,t)}),hc=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ka),$.init(e,t)}),mc=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Pa(t)),$.init(e,t)}),Ec=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ia),$.init(e,t)}),gc=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ba),$.init(e,t),e._zod.bag.format="ipv4"}),_c=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Aa),$.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})}}}),yc=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Na),$.init(e,t)}),Sc=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$a),$.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[s,r]=o;if(!r)throw new Error;const i=Number(r);if(`${i}`!==r)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${s}]`)}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 Tc=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=La),$.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 Oc(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 Ic=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$o),$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Oc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),wc=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Da),$.init(e,t)});function vc(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const s=JSON.parse(atob(o));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Cc=u("$ZodJWT",(e,t)=>{$.init(e,t),e._zod.check=n=>{vc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Fo=u("$ZodNumber",(e,t)=>{D.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 s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const r=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...r?{received:r}:{}}),n}}),Rc=u("$ZodNumberFormat",(e,t)=>{Ba.init(e,t),Fo.init(e,t)}),bc=u("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Fa,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}}),Ac=u("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=n=>n}),Nc=u("$ZodNever",(e,t)=>{D.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(...Me(n,e.issues)),t.value[n]=e.value}const $c=u("$ZodArray",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const r=[];for(let i=0;i<s.length;i++){const a=s[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?r.push(c.then(l=>Mo(l,n,i))):Mo(c,n,i)}return r.length?Promise.all(r).then(()=>n):n}});function Ot(e,t,n,o,s){if(e.issues.length){if(s&&!(n in o))return;t.issues.push(...Me(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=Ji(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xo(e,t,n,o,s,r){const i=[],a=s.keySet,c=s.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(l==="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:r}),e.length?Promise.all(e).then(()=>n):n}const Lc=u("$ZodObject",(e,t)=>{if(D.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 l in a){const d=a[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const m of d.values)c[l].add(m)}}return c});const s=qe,r=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const l=a.value;if(!s(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const d=[],m=i.shape;for(const y of i.keys){const T=m[y],H=T._zod.optout==="optional",B=T._zod.run({value:l[y],issues:[]},c);B instanceof Promise?d.push(B.then(pt=>Ot(pt,a,y,l,H))):Ot(B,a,y,l,H)}return r?xo(d,l,a,c,o.value,e):d.length?Promise.all(d).then(()=>a):a}}),Dc=u("$ZodObjectJIT",(e,t)=>{Lc.init(e,t);const n=e._zod.parse,o=gt(()=>Go(t)),s=y=>{const T=new ec(["shape","payload","ctx"]),H=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 pt=Object.create(null);let hi=0;for(const fe of H.keys)pt[fe]=`key_${hi++}`;T.write("const newResult = {};");for(const fe of H.keys){const K=pt[fe],ae=wo(fe),Ei=y[fe]?._zod?.optout==="optional";T.write(`const ${K} = ${B(fe)};`),Ei?T.write(`
|
|
4
4
|
if (${K}.issues.length) {
|
|
5
5
|
if (${ae} in input) {
|
|
6
6
|
payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
|
|
@@ -34,32 +34,32 @@ import*as pt from"fs";import C,{existsSync as H,readFileSync as on,statSync as Q
|
|
|
34
34
|
newResult[${ae}] = ${K}.value;
|
|
35
35
|
}
|
|
36
36
|
|
|
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=>!Fe(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(je(e)&&je(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}),Fe(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(!je(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(...Me(u,m.issues)),n.value[u]=m.value})):(d.issues.length&&n.issues.push(...Me(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(...Me(a,m.issues)),n.value[c.value]=m.value})):(d.issues.length&&n.issues.push(...Me(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"?Ue(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"?Ue(o):o?Ue(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 ze;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(et(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 tt=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 Ge(e){return new Xa({check:"overwrite",tx:e})}function $u(e){return Ge(t=>t.normalize(e))}function Du(){return Ge(e=>e.trim())}function Lu(){return Ge(e=>e.toLowerCase())}function ku(){return Ge(e=>e.toUpperCase())}function Pu(){return Ge(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(et(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(et(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??tt,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>
|
|
37
|
+
`)}T.write("payload.value = newResult;"),T.write("return payload;");const mi=T.compile();return(fe,K)=>mi(y,fe,K)};let r;const i=qe,a=!dn.jitless,l=a&&Yi.value,d=t.catchall;let m;e._zod.parse=(y,T)=>{m??(m=o.value);const H=y.value;return i(H)?a&&l&&T?.async===!1&&T.jitless!==!0?(r||(r=s(t.shape)),y=r(y,T),d?xo([],H,y,T,m,e):y):n(y,T):(y.issues.push({expected:"object",code:"invalid_type",input:H,inst:e}),y)}});function Bo(e,t,n,o){for(const r of e)if(r.issues.length===0)return t.value=r.value,t;const s=e.filter(r=>!Fe(r));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(r=>r.issues.map(i=>ve(i,o,_e())))}),t)}const Zo=u("$ZodUnion",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${s.map(r=>hn(r.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(s,r)=>{if(n)return o(s,r);let i=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:s.value,issues:[]},r);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>Bo(c,s,e,r)):Bo(a,s,e,r)}}),kc=u("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zo.init(e,t);const n=e._zod.parse;b(e._zod,"propValues",()=>{const s={};for(const r of t.options){const i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(const l of c)s[a].add(l)}}return s});const o=gt(()=>{const s=t.options,r=new Map;for(const i of s){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(r.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);r.set(c,i)}}return r});e._zod.parse=(s,r)=>{const i=s.value;if(!qe(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;const a=o.value.get(i?.[t.discriminator]);return a?a._zod.run(s,r):t.unionFallback?n(s,r):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),s)}}),Pc=u("$ZodIntersection",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const s=n.value,r=t.left._zod.run({value:s,issues:[]},o),i=t.right._zod.run({value:s,issues:[]},o);return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([c,l])=>Ho(n,c,l)):Ho(n,r,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(je(e)&&je(t)){const n=Object.keys(t),o=Object.keys(e).filter(r=>n.indexOf(r)!==-1),s={...e,...t};for(const r of o){const i=yn(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};s[r]=i.data}return{valid:!0,data:s}}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 s=e[o],r=t[o],i=yn(s,r);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 s;for(const a of t.issues)if(a.code==="unrecognized_keys"){s??(s=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 r=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(r.length&&s&&e.issues.push({...s,keys:r}),Fe(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 zc=u("$ZodRecord",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const s=n.value;if(!je(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const r=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:s[l],issues:[]},o);d instanceof Promise?r.push(d.then(m=>{m.issues.length&&n.issues.push(...Me(l,m.issues)),n.value[l]=m.value})):(d.issues.length&&n.issues.push(...Me(l,d.issues)),n.value[l]=d.value)}let c;for(const l in s)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){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]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>ve(m,o,_e())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:s[a],issues:[]},o);d instanceof Promise?r.push(d.then(m=>{m.issues.length&&n.issues.push(...Me(a,m.issues)),n.value[c.value]=m.value})):(d.issues.length&&n.issues.push(...Me(a,d.issues)),n.value[c.value]=d.value)}}return r.length?Promise.all(r).then(()=>n):n}}),jc=u("$ZodEnum",(e,t)=>{D.init(e,t);const n=Oo(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(s=>Ki.has(typeof s)).map(s=>typeof s=="string"?Ue(s):s.toString()).join("|")})$`),e._zod.parse=(s,r)=>{const i=s.value;return o.has(i)||s.issues.push({code:"invalid_value",values:n,input:i,inst:e}),s}}),Uc=u("$ZodLiteral",(e,t)=>{if(D.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"?Ue(o):o?Ue(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,s)=>{const r=o.value;return n.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),Fc=u("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);const s=t.transform(n.value,n);if(o.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(n.value=i,n));if(s instanceof Promise)throw new ze;return n.value=s,n}});function Vo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Wo=u("$ZodOptional",(e,t)=>{D.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 s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>Vo(r,n.value)):Vo(s,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Mc=u("$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)}),Gc=u("$ZodNullable",(e,t)=>{D.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)}),xc=u("$ZodDefault",(e,t)=>{D.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 s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>Yo(r,t)):Yo(s,t)}});function Yo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Bc=u("$ZodPrefault",(e,t)=>{D.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))}),Zc=u("$ZodNonOptional",(e,t)=>{D.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 s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>Ko(r,e)):Ko(s,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 Hc=u("$ZodCatch",(e,t)=>{D.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 s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>ve(i,o,_e()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(r=>ve(r,o,_e()))},input:n.value}),n.issues=[]),n)}}),Vc=u("$ZodPipe",(e,t)=>{D.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 r=t.out._zod.run(n,o);return r instanceof Promise?r.then(i=>It(i,t.in,o)):It(r,t.in,o)}const s=t.in._zod.run(n,o);return s instanceof Promise?s.then(r=>It(r,t.out,o)):It(s,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 Wc=u("$ZodReadonly",(e,t)=>{D.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 s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(Jo):Jo(s)}});function Jo(e){return e.value=Object.freeze(e.value),e}const Yc=u("$ZodCustom",(e,t)=>{J.init(e,t),D.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,s=t.fn(o);if(s instanceof Promise)return s.then(r=>Xo(r,n,o,e));Xo(s,n,o,e)}});function Xo(e,t,n,o){if(!e){const s={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(s.params=o._zod.def.params),t.issues.push(et(s))}}var Qo;class Kc{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 s={...o,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Jc(){return new Kc}(Qo=globalThis).__zod_globalRegistry??(Qo.__zod_globalRegistry=Jc());const tt=globalThis.__zod_globalRegistry;function Xc(e,t){return new e({type:"string",...g(t)})}function Qc(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 qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function el(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function tl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function nl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function es(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function ol(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function sl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function rl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function al(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function cl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function ll(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function ul(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function dl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function pl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function fl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function hl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function ml(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function El(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function gl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function _l(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function yl(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Sl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Tl(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Ol(e,t){return new e({type:"number",checks:[],...g(t)})}function Il(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function wl(e,t){return new e({type:"boolean",...g(t)})}function vl(e){return new e({type:"unknown"})}function Cl(e,t){return new e({type:"never",...g(t)})}function ts(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 ns(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 os(e,t){return new xa({check:"multiple_of",...g(t),value:e})}function ss(e,t){return new Za({check:"max_length",...g(t),maximum:e})}function wt(e,t){return new Ha({check:"min_length",...g(t),minimum:e})}function rs(e,t){return new Va({check:"length_equals",...g(t),length:e})}function Rl(e,t){return new Wa({check:"string_format",format:"regex",...g(t),pattern:e})}function bl(e){return new Ya({check:"string_format",format:"lowercase",...g(e)})}function Al(e){return new Ka({check:"string_format",format:"uppercase",...g(e)})}function Nl(e,t){return new Ja({check:"string_format",format:"includes",...g(t),includes:e})}function $l(e,t){return new Xa({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Ll(e,t){return new Qa({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Ge(e){return new qa({check:"overwrite",tx:e})}function Dl(e){return Ge(t=>t.normalize(e))}function kl(){return Ge(e=>e.trim())}function Pl(){return Ge(e=>e.toLowerCase())}function zl(){return Ge(e=>e.toUpperCase())}function jl(){return Ge(e=>Wi(e))}function Ul(e,t,n){return new e({type:"array",element:t,...g(n)})}function Fl(e,t,n){const o=g(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Ml(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Gl(e){const t=xl(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(et(o,n.value,t._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(et(s))}},e(n.value,n)));return t}function xl(e,t){const n=new J({check:"custom",...g(t)});return n._zod.check=e,n}function is(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??tt,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 s=e._zod.def,r=t.seen.get(e);if(r)return r.count++,n.schemaPath.includes(e)&&(r.cycle=n.path),r.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[s.type];if(!T)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.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"&&Y(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 as(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 s=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??(H=>H);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 l=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},r=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:l}=s(i);a.def={...a.schema},l&&(a.defId=l);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 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(Ge(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 tt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return tt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return tt.get(e);const o=e.clone();return tt.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(et(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(et(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 xe(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 Be={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},bd=U(Object.values(Be)),nt={CONTENT:"Content",DESIGN:"Design"};U(Object.values(nt));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()});xe(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()});xe(e=>typeof e=="string"&&Rr.test(e),{message:X.VALID_GLOBAL_COLOR()});const le=xe(e=>typeof e=="string"&&(wr.test(e)||Rr.test(e)),{message:X.VALID_COLOR()}),Nr=xe(e=>typeof e=="string"?le.safeParse(e).success:Array.isArray(e)&&e.every(t=>le.safeParse(t).success),{message:X.VALID_COLOR()});xe(e=>typeof e=="string"&&Cr.test(e),{message:X.VALID_GLOBAL_TEXT_SIZE()});const $r=xe(e=>typeof e=="number"?Number.isInteger(e)&&e>=1:typeof e=="string"&&Cr.test(e),{message:X.VALID_TEXT_SIZE()}),ot=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 #"}),rt=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:rt.optional(),WEBP_LOW_RES:rt.optional(),WEBP_HI_2X_RES:rt.optional(),MOBILE_WEBP_LOW_RES:rt.optional(),MOBILE_WEBP_HI_RES:rt.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 Be.HEADER:return tf;default:return{}}}function gs(e){switch(e){case Be.HEADER:return nf;default:return{}}}function _s({validationType:e,sectionType:t}){switch(e){case nt.CONTENT:return Es(t);case nt.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:nt.CONTENT,sectionType:e.type}),r=_s({validationType:nt.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);ot.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,ot.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:ot,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);ot.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,ot.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",Ze="layouts",Is="preview",Q=`dist/${Ze}`,st="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
|
|
41
|
-
`).map((o,
|
|
42
|
-
`)}function
|
|
43
|
-
`):e?.message??"Unknown error";if(!t||t.length===0)return o;const
|
|
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 De(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 De({appearance:t,size:n,style:o,font:r,color:s,visible:i})}function Yf(e){const t=de(e.color);return De({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],o=e.visible,r={type:Kf(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}};return De({overlay:r,visible:o})}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,c=e.visible;return De({font:t,color:n,size:o,frame:Gf(e.frame),bold:r,italic:s,spacing:i,capitalization:a,visible:c})}function Qf(e){const t=e.value;return De({value:t})}function qf(e){const t=Zn(e.font),n=de(e.color),o=vs(e.size),r=e.bold,s=e.italic,i=e.visible;return De({font:t,color:n,size:o,bold:r,italic:s,visible:i})}function eh(e){const t=e.enabled;return De({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 He(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return rh(e)?e:e.map(r=>He(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]=He(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 He(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 Pe(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 He(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 Pe(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 He(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 Ve={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],We={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 Ye(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})=>Ye(e,t,"")},[R.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Ye(e,t,"assets/")},[R.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(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})=>Ye(e,t,"slots",n,"js/main/client/")},[R.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/chunks/")},[R.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/assets/")},[R.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${st}/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:
|
|
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]){r(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){r(i);continue}}if(e.metadataRegistry.get(i[0])?.id){r(i);continue}if(a.cycle){r(i);continue}if(a.count>1&&e.reused==="ref"){r(i);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 o=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,l={...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,l),i._zod.parent===d)for(const B in c)B==="$ref"||B==="allOf"||B in l||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 s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$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");s.$id=e.external.uri(i)}Object.assign(s,n.def??n.schema);const r=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(r[a.defId]=a.def)}e.external||Object.keys(r).length>0&&(e.target==="draft-2020-12"?s.$defs=r:s.definitions=r);try{const i=JSON.parse(JSON.stringify(s));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 Y(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 Y(o.element,n);if(o.type==="set")return Y(o.valueType,n);if(o.type==="lazy")return Y(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 Y(o.innerType,n);if(o.type==="intersection")return Y(o.left,n)||Y(o.right,n);if(o.type==="record"||o.type==="map")return Y(o.keyType,n)||Y(o.valueType,n);if(o.type==="pipe")return Y(o.in,n)||Y(o.out,n);if(o.type==="object"){for(const s in o.shape)if(Y(o.shape[s],n))return!0;return!1}if(o.type==="union"){for(const s of o.options)if(Y(s,n))return!0;return!1}if(o.type==="tuple"){for(const s of o.items)if(Y(s,n))return!0;return!!(o.rest&&Y(o.rest,n))}return!1}const Bl=(e,t={})=>n=>{const o=is({...n,processors:t});return M(e,o),as(o,e),cs(o,e)},vt=(e,t,n={})=>o=>{const{libraryOptions:s,target:r}=o??{},i=is({...s??{},target:r,io:t,processors:n});return M(e,i),as(i,e),cs(i,e)},Zl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Hl=(e,t,n,o)=>{const s=n;s.type="string";const{minimum:r,maximum:i,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof r=="number"&&(s.minLength=r),typeof i=="number"&&(s.maxLength=i),a&&(s.format=Zl[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Vl=(e,t,n,o)=>{const s=n,{minimum:r,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof r=="number"&&(s.minimum=r,typeof d=="number"&&t.target!=="draft-04"&&(d>=r?delete s.minimum:delete s.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(s.maximum=l,s.exclusiveMaximum=!0):s.exclusiveMaximum=l),typeof i=="number"&&(s.maximum=i,typeof l=="number"&&t.target!=="draft-04"&&(l<=i?delete s.maximum:delete s.exclusiveMaximum)),typeof c=="number"&&(s.multipleOf=c)},Wl=(e,t,n,o)=>{n.type="boolean"},Yl=(e,t,n,o)=>{n.not={}},Kl=(e,t,n,o)=>{},Jl=(e,t,n,o)=>{const s=e._zod.def,r=Oo(s.entries);r.every(i=>typeof i=="number")&&(n.type="number"),r.every(i=>typeof i=="string")&&(n.type="string"),n.enum=r},Xl=(e,t,n,o)=>{const s=e._zod.def,r=[];for(const i of s.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");r.push(Number(i))}else r.push(i);if(r.length!==0)if(r.length===1){const i=r[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else r.every(i=>typeof i=="number")&&(n.type="number"),r.every(i=>typeof i=="string")&&(n.type="string"),r.every(i=>typeof i=="boolean")&&(n.type="boolean"),r.every(i=>i===null)&&(n.type="null"),n.enum=r},Ql=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ql=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},eu=(e,t,n,o)=>{const s=n,r=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(s.minItems=i),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=M(r.element,t,{...o,path:[...o.path,"items"]})},tu=(e,t,n,o)=>{const s=n,r=e._zod.def;s.type="object",s.properties={};const i=r.shape;for(const l in i)s.properties[l]=M(i[l],t,{...o,path:[...o.path,"properties",l]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(l=>{const d=r.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(s.required=Array.from(c)),r.catchall?._zod.def.type==="never"?s.additionalProperties=!1:r.catchall?r.catchall&&(s.additionalProperties=M(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},nu=(e,t,n,o)=>{const s=e._zod.def,r=s.inclusive===!1,i=s.options.map((a,c)=>M(a,t,{...o,path:[...o.path,r?"oneOf":"anyOf",c]}));r?n.oneOf=i:n.anyOf=i},ou=(e,t,n,o)=>{const s=e._zod.def,r=M(s.left,t,{...o,path:[...o.path,"allOf",0]}),i=M(s.right,t,{...o,path:[...o.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(r)?r.allOf:[r],...a(i)?i.allOf:[i]];n.allOf=c},su=(e,t,n,o)=>{const s=n,r=e._zod.def;s.type="object";const i=r.keyType,c=i._zod.bag?.patterns;if(r.mode==="loose"&&c&&c.size>0){const d=M(r.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});s.patternProperties={};for(const m of c)s.patternProperties[m.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(s.propertyNames=M(r.keyType,t,{...o,path:[...o.path,"propertyNames"]})),s.additionalProperties=M(r.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=i._zod.values;if(l){const d=[...l].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(s.required=d)}},ru=(e,t,n,o)=>{const s=e._zod.def,r=M(s.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=s.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]},iu=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType},au=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},cu=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},lu=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType;let i;try{i=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},uu=(e,t,n,o)=>{const s=e._zod.def,r=t.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;M(r,t,o);const i=t.seen.get(e);i.ref=r},du=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType,n.readOnly=!0},ls=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType},pu=u("ZodISODateTime",(e,t)=>{fc.init(e,t),P.init(e,t)});function fu(e){return _l(pu,e)}const hu=u("ZodISODate",(e,t)=>{hc.init(e,t),P.init(e,t)});function mu(e){return yl(hu,e)}const Eu=u("ZodISOTime",(e,t)=>{mc.init(e,t),P.init(e,t)});function gu(e){return Sl(Eu,e)}const _u=u("ZodISODuration",(e,t)=>{Ec.init(e,t),P.init(e,t)});function yu(e){return Tl(_u,e)}const Su=(e,t)=>{bo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ia(e,n)},flatten:{value:n=>ra(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}}})},oe=u("ZodError",Su,{Parent:Error}),Tu=En(oe),Ou=gn(oe),Iu=yt(oe),wu=St(oe),vu=la(oe),Cu=ua(oe),Ru=da(oe),bu=pa(oe),Au=fa(oe),Nu=ha(oe),$u=ma(oe),Lu=Ea(oe),k=u("ZodType",(e,t)=>(D.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vt(e,"input"),output:vt(e,"output")}}),e.toJSONSchema=Bl(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)=>Tu(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Iu(e,n,o),e.parseAsync=async(n,o)=>Ou(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>wu(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>vu(e,n,o),e.decode=(n,o)=>Cu(e,n,o),e.encodeAsync=async(n,o)=>Ru(e,n,o),e.decodeAsync=async(n,o)=>bu(e,n,o),e.safeEncode=(n,o)=>Au(e,n,o),e.safeDecode=(n,o)=>Nu(e,n,o),e.safeEncodeAsync=async(n,o)=>$u(e,n,o),e.safeDecodeAsync=async(n,o)=>Lu(e,n,o),e.refine=(n,o)=>e.check(wd(n,o)),e.superRefine=n=>e.check(vd(n)),e.overwrite=n=>e.check(Ge(n)),e.optional=()=>_s(e),e.exactOptional=()=>pd(e),e.nullable=()=>ys(e),e.nullish=()=>_s(ys(e)),e.nonoptional=n=>_d(e,n),e.array=()=>A(e),e.or=n=>od([e,n]),e.and=n=>id(e,n),e.transform=n=>Ts(e,ud(n)),e.default=n=>md(e,n),e.prefault=n=>gd(e,n),e.catch=n=>Sd(e,n),e.pipe=n=>Ts(e,n),e.readonly=()=>Id(e),e.describe=n=>{const o=e.clone();return tt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return tt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return tt.get(e);const o=e.clone();return tt.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),us=u("_ZodString",(e,t)=>{_n.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,s,r)=>Hl(e,o,s);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(Rl(...o)),e.includes=(...o)=>e.check(Nl(...o)),e.startsWith=(...o)=>e.check($l(...o)),e.endsWith=(...o)=>e.check(Ll(...o)),e.min=(...o)=>e.check(wt(...o)),e.max=(...o)=>e.check(ss(...o)),e.length=(...o)=>e.check(rs(...o)),e.nonempty=(...o)=>e.check(wt(1,...o)),e.lowercase=o=>e.check(bl(o)),e.uppercase=o=>e.check(Al(o)),e.trim=()=>e.check(kl()),e.normalize=(...o)=>e.check(Dl(...o)),e.toLowerCase=()=>e.check(Pl()),e.toUpperCase=()=>e.check(zl()),e.slugify=()=>e.check(jl())}),Du=u("ZodString",(e,t)=>{_n.init(e,t),us.init(e,t),e.email=n=>e.check(Qc(ku,n)),e.url=n=>e.check(es(ps,n)),e.jwt=n=>e.check(gl(Ku,n)),e.emoji=n=>e.check(ol(Pu,n)),e.guid=n=>e.check(qo(ds,n)),e.uuid=n=>e.check(qc(Ct,n)),e.uuidv4=n=>e.check(el(Ct,n)),e.uuidv6=n=>e.check(tl(Ct,n)),e.uuidv7=n=>e.check(nl(Ct,n)),e.nanoid=n=>e.check(sl(zu,n)),e.guid=n=>e.check(qo(ds,n)),e.cuid=n=>e.check(rl(ju,n)),e.cuid2=n=>e.check(il(Uu,n)),e.ulid=n=>e.check(al(Fu,n)),e.base64=n=>e.check(hl(Vu,n)),e.base64url=n=>e.check(ml(Wu,n)),e.xid=n=>e.check(cl(Mu,n)),e.ksuid=n=>e.check(ll(Gu,n)),e.ipv4=n=>e.check(ul(xu,n)),e.ipv6=n=>e.check(dl(Bu,n)),e.cidrv4=n=>e.check(pl(Zu,n)),e.cidrv6=n=>e.check(fl(Hu,n)),e.e164=n=>e.check(El(Yu,n)),e.datetime=n=>e.check(fu(n)),e.date=n=>e.check(mu(n)),e.time=n=>e.check(gu(n)),e.duration=n=>e.check(yu(n))});function h(e){return Xc(Du,e)}const P=u("ZodStringFormat",(e,t)=>{$.init(e,t),us.init(e,t)}),ku=u("ZodEmail",(e,t)=>{sc.init(e,t),P.init(e,t)}),ds=u("ZodGUID",(e,t)=>{nc.init(e,t),P.init(e,t)}),Ct=u("ZodUUID",(e,t)=>{oc.init(e,t),P.init(e,t)}),ps=u("ZodURL",(e,t)=>{rc.init(e,t),P.init(e,t)});function fs(e){return es(ps,e)}const Pu=u("ZodEmoji",(e,t)=>{ic.init(e,t),P.init(e,t)}),zu=u("ZodNanoID",(e,t)=>{ac.init(e,t),P.init(e,t)}),ju=u("ZodCUID",(e,t)=>{cc.init(e,t),P.init(e,t)}),Uu=u("ZodCUID2",(e,t)=>{lc.init(e,t),P.init(e,t)}),Fu=u("ZodULID",(e,t)=>{uc.init(e,t),P.init(e,t)}),Mu=u("ZodXID",(e,t)=>{dc.init(e,t),P.init(e,t)}),Gu=u("ZodKSUID",(e,t)=>{pc.init(e,t),P.init(e,t)}),xu=u("ZodIPv4",(e,t)=>{gc.init(e,t),P.init(e,t)}),Bu=u("ZodIPv6",(e,t)=>{_c.init(e,t),P.init(e,t)}),Zu=u("ZodCIDRv4",(e,t)=>{yc.init(e,t),P.init(e,t)}),Hu=u("ZodCIDRv6",(e,t)=>{Sc.init(e,t),P.init(e,t)}),Vu=u("ZodBase64",(e,t)=>{Tc.init(e,t),P.init(e,t)}),Wu=u("ZodBase64URL",(e,t)=>{Ic.init(e,t),P.init(e,t)}),Yu=u("ZodE164",(e,t)=>{wc.init(e,t),P.init(e,t)}),Ku=u("ZodJWT",(e,t)=>{Cc.init(e,t),P.init(e,t)}),hs=u("ZodNumber",(e,t)=>{Fo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,s,r)=>Vl(e,o,s),e.gt=(o,s)=>e.check(ns(o,s)),e.gte=(o,s)=>e.check(Tn(o,s)),e.min=(o,s)=>e.check(Tn(o,s)),e.lt=(o,s)=>e.check(ts(o,s)),e.lte=(o,s)=>e.check(Sn(o,s)),e.max=(o,s)=>e.check(Sn(o,s)),e.int=o=>e.check(he(o)),e.safe=o=>e.check(he(o)),e.positive=o=>e.check(ns(0,o)),e.nonnegative=o=>e.check(Tn(0,o)),e.negative=o=>e.check(ts(0,o)),e.nonpositive=o=>e.check(Sn(0,o)),e.multipleOf=(o,s)=>e.check(os(o,s)),e.step=(o,s)=>e.check(os(o,s)),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 Ol(hs,e)}const Ju=u("ZodNumberFormat",(e,t)=>{Rc.init(e,t),hs.init(e,t)});function he(e){return Il(Ju,e)}const Xu=u("ZodBoolean",(e,t)=>{bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Wl(e,n,o)});function v(e){return wl(Xu,e)}const Qu=u("ZodUnknown",(e,t)=>{Ac.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Kl()});function ms(){return vl(Qu)}const qu=u("ZodNever",(e,t)=>{Nc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Yl(e,n,o)});function ed(e){return Cl(qu,e)}const td=u("ZodArray",(e,t)=>{$c.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>eu(e,n,o,s),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(ss(n,o)),e.length=(n,o)=>e.check(rs(n,o)),e.unwrap=()=>e.element});function A(e,t){return Ul(td,e,t)}const nd=u("ZodObject",(e,t)=>{Dc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>tu(e,n,o,s),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:ms()}),e.loose=()=>e.clone({...e._zod.def,catchall:ms()}),e.strict=()=>e.clone({...e._zod.def,catchall:ed()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>ea(e,n),e.safeExtend=n=>ta(e,n),e.merge=n=>na(e,n),e.pick=n=>Qi(e,n),e.omit=n=>qi(e,n),e.partial=(...n)=>oa(gs,e,n[0]),e.required=(...n)=>sa(Ss,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...g(t)};return new nd(n)}const Es=u("ZodUnion",(e,t)=>{Zo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>nu(e,n,o,s),e.options=t.options});function od(e,t){return new Es({type:"union",options:e,...g(t)})}const sd=u("ZodDiscriminatedUnion",(e,t)=>{Es.init(e,t),kc.init(e,t)});function q(e,t,n){return new sd({type:"union",options:t,discriminator:e,...g(n)})}const rd=u("ZodIntersection",(e,t)=>{Pc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ou(e,n,o,s)});function id(e,t){return new rd({type:"intersection",left:e,right:t})}const ad=u("ZodRecord",(e,t)=>{zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>su(e,n,o,s),e.keyType=t.keyType,e.valueType=t.valueType});function Z(e,t,n){return new ad({type:"record",keyType:e,valueType:t,...g(n)})}const On=u("ZodEnum",(e,t)=>{jc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,s,r)=>Jl(e,o,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,s)=>{const r={};for(const i of o)if(n.has(i))r[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new On({...t,checks:[],...g(s),entries:r})},e.exclude=(o,s)=>{const r={...t.entries};for(const i of o)if(n.has(i))delete r[i];else throw new Error(`Key ${i} not found in enum`);return new On({...t,checks:[],...g(s),entries:r})}});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 cd=u("ZodLiteral",(e,t)=>{Uc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Xl(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 cd({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const ld=u("ZodTransform",(e,t)=>{Fc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ql(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);n.addIssue=r=>{if(typeof r=="string")n.issues.push(et(r,n.value,t));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(et(i))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(r=>(n.value=r,n)):(n.value=s,n)}});function ud(e){return new ld({type:"transform",transform:e})}const gs=u("ZodOptional",(e,t)=>{Wo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ls(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function _s(e){return new gs({type:"optional",innerType:e})}const dd=u("ZodExactOptional",(e,t)=>{Mc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ls(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function pd(e){return new dd({type:"optional",innerType:e})}const fd=u("ZodNullable",(e,t)=>{Gc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ru(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function ys(e){return new fd({type:"nullable",innerType:e})}const hd=u("ZodDefault",(e,t)=>{xc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>au(e,n,o,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function md(e,t){return new hd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Ed=u("ZodPrefault",(e,t)=>{Bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>cu(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function gd(e,t){return new Ed({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Ss=u("ZodNonOptional",(e,t)=>{Zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>iu(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function _d(e,t){return new Ss({type:"nonoptional",innerType:e,...g(t)})}const yd=u("ZodCatch",(e,t)=>{Hc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>lu(e,n,o,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Sd(e,t){return new yd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Td=u("ZodPipe",(e,t)=>{Vc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>uu(e,n,o,s),e.in=t.in,e.out=t.out});function Ts(e,t){return new Td({type:"pipe",in:e,out:t})}const Od=u("ZodReadonly",(e,t)=>{Wc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>du(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function Id(e){return new Od({type:"readonly",innerType:e})}const Os=u("ZodCustom",(e,t)=>{Yc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Ql(e,n)});function xe(e,t){return Fl(Os,e??(()=>!0),t)}function wd(e,t={}){return Ml(Os,e,t)}function vd(e){return Gl(e)}const 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"},Cd=U(Object.values(Ce)),nt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Rd=U(Object.values(nt)),bt=nt,Is={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},bd=U(Object.values(Is)),Ad=Is,ws={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},Nd=U(Object.values(ws)),$d=ws,vs={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},Ld=U(Object.values(vs)),Dd=vs,At={COLOR:"COLOR",GRADIENT:"GRADIENT"},kd=U(Object.values(At)),In=At,Ae={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Pd=U(Object.values(Ae)),ye=Ae;var ee=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(ee||{}),N=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e[e.CollectionDescriptor=14]="CollectionDescriptor",e[e.CollectionAsset=15]="CollectionAsset",e))(N||{}),zd=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(zd||{});const 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 te=w,ot={CONTENT:"Content",DESIGN:"Design"};U(Object.values(ot));const jd={TEXT:"TEXT",IMAGE:"IMAGE"},Ud=U(Object.values(jd));var Fd=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(Fd||{}),Md=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(Md||{});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)),G={[ye.SECTION]:{source:"sections",dist:"dist/sections"},[ye.HEADER]:{source:"headers",dist:"dist/headers"},[ye.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 Be(e){const t={};for(const[n,o]of Object.entries(e)){let s={...o};if(o.type==="DECK"&&o.cards&&typeof o.cards=="object"&&"defaultCardContent"in o.cards){const r=o.cards;r.defaultCardContent?.settings&&(s={...s,cards:{...r,defaultCardContent:{...r.defaultCardContent,settings:Be(r.defaultCardContent.settings)}}})}if(o.type==="ACCORDION"&&o.cards&&typeof o.cards=="object"&&!("defaultCardContent"in o.cards)){const r=o.cards,i={};for(const[a,c]of Object.entries(r))c.editors?i[a]={...c,editors:Be(c.editors)}:i[a]=c;s={...s,cards:i}}if(s.defaults&&typeof s.defaults=="object"&&!("type"in s.defaults)){const r=Object.assign({type:s.type},s.defaults);s={...s,defaults:r}}t[n]=s}return t}const Bd={url:"must be a valid URL",email:"must be a valid email address"},Zd=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Hd=e=>e===null?"null":typeof e,Vd=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Zd(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Hd(t)}`}}case"invalid_format":{const t=Bd[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}};U(["none","all","small"]);const Ne={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Cs={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},Wd=U(Object.values(Ne));U(Object.values(Cs));const Yd={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"},Kd=U(Object.values(Yd)),Jd={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"},Xd={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"},Qd=U(Object.values(Xd)),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"},Rs=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,bs=/^global\.fontFamily\.(title|body)$/,As=/^global\.textSize\.(title|subtitle|body)$/,Ns=/^global\.color\.(title|body|button|link|background)$/,qd=/^[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(),$s=p({size:Rt().nonnegative()}).strict(),_=h().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),ep=p({r:Re(0,255),g:Re(0,255),b:Re(0,255),a:Re(0,1)}).strict(),Ls=h().regex(Rs,{message:X.VALID_HEX_COLOR()});xe(e=>typeof e=="string"&&bs.test(e),{message:X.VALID_GLOBAL_FONT()});const vn=h().refine(e=>!e.startsWith("global.")||bs.test(e),{message:X.VALID_GLOBAL_FONT()});xe(e=>typeof e=="string"&&Ns.test(e),{message:X.VALID_GLOBAL_COLOR()});const ue=xe(e=>typeof e=="string"&&(Rs.test(e)||Ns.test(e)),{message:X.VALID_COLOR()}),Ds=xe(e=>typeof e=="string"?ue.safeParse(e).success:Array.isArray(e)&&e.every(t=>ue.safeParse(t).success),{message:X.VALID_COLOR()});xe(e=>typeof e=="string"&&As.test(e),{message:X.VALID_GLOBAL_TEXT_SIZE()});const ks=xe(e=>typeof e=="number"?Number.isInteger(e)&&e>=1:typeof e=="string"&&As.test(e),{message:X.VALID_TEXT_SIZE()}),st=U(["catalog","category","product"]),Nt=h().refine(e=>e.startsWith("#")||fs().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),rt=p({url:h(),width:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional(),height:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional()}).strict(),tp=p({homogeneity:v().optional(),color:ep.optional()}).strict(),np=p({ORIGINAL:rt.optional(),WEBP_LOW_RES:rt.optional(),WEBP_HI_2X_RES:rt.optional(),MOBILE_WEBP_LOW_RES:rt.optional(),MOBILE_WEBP_HI_RES:rt.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),$t=p({set:np,borderInfo:tp.optional()}).strict(),Cn=p({type:E(O.IMAGE),imageData:$t}).strict(),Ps=p({type:E(O.IMAGE),label:_,static:v().optional(),defaults:Cn.optional()}).strict(),op=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Rn(e){return e===Ne.PRODUCT||e===Ne.CATALOG||e===Ne.CATEGORY}function zs(e,t,n){if(!e)return;const o=Ri({path:"$..set..url",json:e,resultType:"all"}),s=/^https?:\/\//;o.forEach(r=>{const i=r.value;if(!s.test(i)&&!t.includes(i)){const a=r.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",i)}})}function js(e,t,n){e===Ce.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Us(e,t,n){(e===Ce.GO_TO_CATEGORY||e===Ce.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function Fs(e,t,n){e===Ce.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Ms(e,t,n){e===Ce.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Gs(e,t,n,o){if(e===Ce.SCROLL_TO_TILE&&!(t??n)){const s=t?"tileId":"tileIdForScroll";o.at(s).addIssue("BUTTON_TILE_ID_REQUIRED",s)}}function sp(e,t,n){e===Ce.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const rp="custom";function x(e,t=[]){const n=s=>Array.isArray(s)?s:[s],o=n(t);return{raw:e,addIssue(s,...r){e.addIssue({code:rp,message:X[s](...r),path:o,params:{errorMessageKey:s}})},at(s){const r=o.concat(n(s));return x(e,r)}}}const bn=p({type:E(O.BUTTON),title:_,buttonType:Cd,link:h().optional(),linkTarget:h().optional(),email:h().regex(op,{message:X.VALID_EMAIL()}).optional(),phone:h().optional(),tileId:h().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=x(t);js(e.buttonType,e.link,n),Us(e.buttonType,e.categoryId,n),Fs(e.buttonType,e.email,n),Ms(e.buttonType,e.phone,n),Gs(e.buttonType,e.tileId,void 0,n)}),xs=p({type:E(O.BUTTON),label:_,defaults:bn.optional()}).strict(),An=p({type:E(O.CATEGORY_SELECTOR)}).strict(),Bs=p({type:E(O.CATEGORY_SELECTOR),label:_,maxCategories:Re(1,32),defaults:An.optional()}).strict(),Nn=p({type:E(O.DIVIDER)}).strict(),Zs=p({type:E(O.DIVIDER),label:_,defaults:Nn.optional()}).strict(),ip=p({label:_,link:Nt}).strict(),ap=p({title:_.optional(),link:Nt.optional()}).strict(),$n=p({type:E(O.INFO),text:_.optional(),button:ap.optional()}).strict(),Hs=p({type:E(O.INFO),label:_,description:_,button:ip.optional(),defaults:$n.optional()}).strict(),Ln=p({type:E(O.INPUTBOX),text:_}).strict(),Vs=p({type:E(O.INPUTBOX),label:_,placeholder:_,defaults:Ln.optional()}).strict(),Dn=p({type:E(O.PRODUCT_SELECTOR)}).strict(),Ws=p({type:E(O.PRODUCT_SELECTOR),label:_,maxProducts:Re(1,32),defaults:Dn.optional()}).strict(),kn=p({type:E(O.SELECTBOX),value:h()}).strict(),cp=p({value:h().min(1,{message:"value must not be empty"}),label:_}).strict(),Ys=p({type:E(O.SELECTBOX),label:_,placeholder:_,description:_,options:A(cp).min(1,{message:"must have at least one option"}),defaults:kn.optional()}).strict(),Pn=p({type:E(O.TEXTAREA),text:_}).strict(),Ks=p({type:E(O.TEXTAREA),label:_,placeholder:_,defaults:Pn.optional()}).strict(),zn=p({type:E(O.TOGGLE),enabled:v()}).strict(),Js=p({type:E(O.TOGGLE),label:_,description:_,defaults:zn.optional()}).strict(),Xs=p({type:E(O.DECK)}).strict(),Qs=[Ln,Pn,bn,Cn,zn,kn,Nn,$n,Dn,An],lp=q("type",[...Qs]),up=p({type:E(O.DECK),cards:A(p({settings:Z(h(),lp).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(),dp=q("type",[...Qs,up]),pp=p({type:E(O.DECK),cards:A(p({settings:Z(h(),dp).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(),qs=[Vs,Ks,xs,Ps,Js,Ys,Zs,Hs,Bs,Ws],fp=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Z(h(),q("type",[...qs])).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Xs.optional()}).strict(),hp=q("type",[...qs,fp]),mp=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Z(h(),hp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Xs.optional()}).strict(),er=p({type:E(O.LOGO),logoType:Ud.optional(),text:_.optional(),imageData:$t.optional()}).strict(),Ep=p({type:E(O.LOGO),label:_.optional(),defaults:er.optional()}).strict(),tr=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);js(e.type,e.link,n),Us(e.type,e.categoryId,n),Fs(e.type,e.email,n),Ms(e.type,e.phone,n),Gs(e.type,void 0,e.tileIdForScroll,n),sp(e.type,e.pageIdForNavigate,n)}),nr=p({type:E(O.MENU),items:A(tr).optional()}).strict(),gp=p({type:E(O.MENU),label:_.optional(),defaults:nr.optional()}).strict(),or=p({type:E(O.NAVIGATION_MENU),items:A(tr).optional()}).strict(),_p=p({type:E(O.NAVIGATION_MENU),defaults:or.optional()}).strict(),Lt=p({type:E(w.BACKGROUND),style:kd.optional(),color:Ds.optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.style===At.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===At.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),yp=p({type:E(w.BACKGROUND),fieldName:h(),defaults:Lt.optional()}).strict(),sr=p({type:E(w.BACKGROUND),label:_,colors:A(ue).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:Lt.optional()}).strict(),Dt=p({type:E(w.BUTTON),appearance:bd.optional(),size:Nd.optional(),shape:Ld.optional(),font:vn.optional(),color:ue.optional(),visible:v().optional()}).strict(),Sp=p({type:E(w.BUTTON),fieldName:h(),defaults:Dt.optional()}).strict(),rr=p({type:E(w.BUTTON),label:_,colors:A(ue).optional(),enableAutoColor:v().optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Dt.optional()}).strict(),kt=p({type:E(w.COLOR_PICKER),color:ue.optional()}).strict(),Tp=p({type:E(w.COLOR_PICKER),fieldName:h(),defaults:kt.optional()}).strict(),ir=p({type:E(w.COLOR_PICKER),label:_,description:_.optional(),colors:A(ue).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:kt.optional()}).strict(),Pt=p({type:E(w.DIVIDER)}).strict(),Op=p({type:E(w.DIVIDER),fieldName:h(),defaults:Pt.optional()}).strict(),ar=p({type:E(w.DIVIDER),label:_,defaults:Pt.optional()}).strict(),zt=p({type:E(w.IMAGE),overlay:Rd.optional(),color:Ds.optional(),visible:v().optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.overlay===nt.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===nt.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===nt.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),Ip=p({type:E(w.IMAGE),fieldName:h(),defaults:zt.optional()}).strict(),cr=p({type:E(w.IMAGE),label:_,static:v().optional(),colors:A(Ls).optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),defaults:zt.optional()}).strict(),wp=p({label:_,link:Nt}).strict(),vp=p({label:_.optional(),link:Nt.optional()}).strict(),jt=p({type:E(w.INFO),description:_.optional(),button:vp.optional()}).strict(),Cp=p({type:E(w.INFO),fieldName:h(),defaults:jt.optional()}).strict(),lr=p({type:E(w.INFO),label:_,description:_,button:wp.optional(),defaults:jt.optional()}).strict(),Rp=p({visible:v(),width:Re(1,49).optional(),color:ue.optional()}).strict(),Ut=p({type:E(w.LOGO),font:vn.optional(),size:ks.optional(),bold:v().optional(),italic:v().optional(),color:ue.optional(),visible:v().optional(),spacing:Re(1,9).optional(),frame:Rp.optional(),capitalization:U(["none","all","small"]).optional()}).strict(),bp=p({type:E(w.LOGO),fieldName:h(),defaults:Ut.optional()}).strict(),ur=p({type:E(w.LOGO),label:_,colors:A(ue).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),defaults:Ut.optional()}).strict(),Ap=p({value:h().optional(),label:_.optional()}).strict(),Ft=p({type:E(w.SELECTBOX),value:h().optional()}).strict(),Np=p({type:E(w.SELECTBOX),fieldName:h(),defaults:Ft.optional()}).strict(),dr=p({type:E(w.SELECTBOX),label:_,description:_.optional(),options:A(Ap).optional(),defaults:Ft.optional()}).strict(),Mt=p({type:E(w.TEXT),font:vn.optional(),size:ks.optional(),bold:v().optional(),italic:v().optional(),color:ue.optional(),visible:v().optional()}).strict(),$p=p({type:E(w.TEXT),fieldName:h(),defaults:Mt.optional()}).strict(),pr=p({type:E(w.TEXT),label:_,colors:A(Ls).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:Mt.optional()}).strict(),Gt=p({type:E(w.TOGGLE),enabled:v().optional()}).strict(),Lp=p({type:E(w.TOGGLE),fieldName:h(),defaults:Gt.optional()}).strict(),fr=p({type:E(w.TOGGLE),label:_,defaults:Gt.optional()}).strict();function Dp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function kp(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 Pp(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function zp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function jp(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 Up(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 hr=p({type:E(w.ACCORDION)}).strict(),Fp=q("type",[Mt,Dt,zt,Gt,Ft,Lt,kt,Ut,Pt,jt]),Mp=p({editors:Z(h(),Fp)}).strict(),Gp=p({type:E(w.ACCORDION),items:Z(h(),Mp)}).strict().superRefine((e,t)=>{const n=x(t);Dp(e.items,n),kp(e.items,n)}),xp=p({type:E(w.ACCORDION),fieldName:h(),defaults:hr.optional()}).strict(),Bp=q("type",[pr,rr,cr,fr,dr,sr,ir,ur,ar,lr]),Zp=p({label:_,positionFieldName:h().optional(),editors:Z(h(),Bp)}).strict().superRefine((e,t)=>{Pp(e.editors,e.label,x(t))}),Hp=p({type:E(w.ACCORDION),sortable:v().optional(),items:Z(h(),Zp),defaults:hr.optional()}).strict().superRefine((e,t)=>{const n=x(t);zp(e.items,n),e.sortable===!0&&(jp(e.items,n),Up(e.items,n))}),mr=q("type",[Ln,Pn,bn,Cn,zn,kn,nr,or,er,Nn,$n,pp,Dn,An]),Er=q("type",[Mt,Dt,zt,Gt,Ft,Lt,kt,Ut,Pt,Gp,jt]),Vp=p({showcaseId:h(),blockName:h(),previewImage:$t,content:Z(h(),mr),design:Z(h(),Er),layoutId:h().optional()}).strict(),Wp=p({blockName:h(),content:Z(h(),mr).optional(),design:Z(h(),Er).optional(),layoutId:h().optional()}).strict();function Yp(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 Kp(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 Jp(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 Xp=new RegExp(`^(${Object.values(Jd).join("|")})(_\\d{3})?$`),Qp=h().regex(Xp,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),qp=h().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),gr=p({type:E("default"),id:Qp,showcase_id:qp.optional()}).strict(),jn=p({type:E("custom"),id:h(),showcase_id:h().optional(),showcase_overrides:Wp.optional(),category:Qd.optional()}).strict(),ef=p({type:E("store"),id:h().optional()}).strict(),tf=q("type",[gr,jn,ef]),nf=p({title:h()}).strict(),of=p({metadata:nf.optional(),sections:A(tf)}).strict(),sf=of.safeExtend({type:Wd,id:h().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=x(t);Kp(e,n),Yp(e,n),Jp(e,n)}),_r=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:fs({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:$t,categories:A(xd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),rf=gr.extend({id:h()}),yr=q("type",[rf,jn]),af=p({metadata:_r,header:yr,footer:yr}).strict(),cf=p({id:h().min(1,{message:"id is required"}),assets:wn.array().optional(),configuration:af,pages:A(sf)}).strict(),xt=2097152,Bt=512e3;function Se(e,t=2){if(!+e)return"0 Bytes";const n=1024,o=t<0?0:t,s=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],r=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**r).toFixed(o))} ${s[r]}`}const lf={menu:{type:O.NAVIGATION_MENU},logo:{type:O.LOGO}},uf={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 Sr(e){switch(e){case Ae.HEADER:return lf;default:return{}}}function Tr(e){switch(e){case Ae.HEADER:return uf;default:return{}}}function Or({validationType:e,sectionType:t}){switch(e){case ot.CONTENT:return Sr(t);case ot.DESIGN:return Tr(t);default:return{}}}const df=jn.extend({id:h().min(1,{message:"section id is required"})}),pf=p({metadata:_r,sections:A(df).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")}),ff=p({id:h().min(1,{message:"id is required"}),descriptor:pf}).strict(),hf=q("type",[Vs,Ks,xs,Ps,Js,Ys,mp,gp,_p,Ep,Zs,Hs,Ws,Bs]),Un=Z(h(),hf),mf=q("type",[pr,rr,cr,fr,dr,sr,ir,ur,ar,Hp,lr]),Fn=Z(h(),mf),Ef=q("type",[$p,Sp,Ip,Lp,Np,yp,Tp,bp,Op,Cp,xp]),Mn=p({layoutId:h(),layoutIcon:Kd.optional(),selectedContentSettings:A(h()),selectedDesignSettings:A(Ef)}).strict(),gf=h().regex(qd,X.VALID_LANGUAGE_CODE()),Zt=Z(gf,Z(_,h()));function Ir(e,t,n){if(!e||Object.keys(t).length===0)return;const o=Object.entries(t),s=o.map(([,{type:i}])=>i),r=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:l}])=>l===a.type)?.[0];c&&i!==c&&n.at(i).addIssue("MANDATORY_SETTING_NAME_MISMATCH",i,a.type,c)}),new Set(r.filter(i=>s.includes(i))).forEach(i=>{if(r.filter(a=>a===i).length>1){const a=o.findLast(([,{type:c}])=>c===i)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",i)}})}function wr(e,t,n){zs(e,t,n)}function vr(e,t,n){if(e.type!==O.DECK||t.type!==O.DECK)return;const o=t.cards?.defaultCardContent?.settings,s=e.cards;!o||!Array.isArray(s)||s.forEach((r,i)=>{r.settings&&Object.entries(r.settings).forEach(([a,c])=>{const l=o[a],d=n.at(["cards",i,"settings",a]);if(!l){d.addIssue("INVALID_DECK_CARD_SETTING",a);return}if(c.type!==l.type){d.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",a,c.type,l.type);return}c.type===O.DECK&&l.type===O.DECK&&vr(c,l,d)})})}function _f(e,t,n){e.content&&Object.entries(e.content).forEach(([o,s])=>{const r=n.at(["content",o]),i=t[o];if(!i){r.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",o);return}if(s.type!==i.type){r.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",o,s.type,i.type);return}if(s.type===O.SELECTBOX&&i.type===O.SELECTBOX){const a=i,c=s;a.options&&c.value!==void 0&&(new Set(a.options.map(l=>l.value)).has(c.value)||r.addIssue("INVALID_SELECTBOX_OPTION",c.value,o))}s.type===O.DECK&&vr(s,i,r)})}function yf(e,t,n){e.design&&Object.entries(e.design).forEach(([o,s])=>{const r=n.at(["design",o]),i=t[o];if(!i){r.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",o);return}s.type!==i.type&&r.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",o,s.type,i.type)})}function Sf(e,t){Object.entries(e).flatMap(([n,o])=>{switch(o.type){case w.ACCORDION:return Object.entries(o.items).flatMap(([s,r])=>Object.keys(r.editors).map(i=>({name:i,path:[n,"items",s,"editors",i]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},o,s)=>s.findIndex(r=>r.name===n)<o).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function Tf(e,t,n){e.layoutId&&((t||[]).some(o=>o.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function Of(e,t){const n=new Set;e.forEach((o,s)=>{if(n.has(o.showcaseId)){t.at([s,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",o.showcaseId);return}n.add(o.showcaseId)})}function Cr(e,t,n){for(const[o,s]of Object.entries(e)){const r=s;if(r.type===O.IMAGE){const i=t[o];if(i?.type===w.IMAGE){const a=r.static??!1,c=i.static??!1;a!==c&&n.at(o).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",o)}}else if(r.type===O.DECK){const i=r;i.cards?.defaultCardContent?.settings&&Cr(i.cards.defaultCardContent.settings,t,n.at([o,"cards","defaultCardContent","settings"]))}}}function If(e,t,n){t>xt&&n.at(z.basename(e)).addIssue("REQUIRED_SECTION_ASSET",Se(t),Se(xt))}function wf(e,t){e>Bt&&t.addIssue("REQUIRED_SERVER_SIZE",Se(e),Se(Bt))}const vf=p({id:h(),type:Pd,name:h(),content:Un,design:Fn,layout:A(Mn).optional(),showcase:A(Vp),translationsSettings:Zt.optional(),translationsShowcases:Zt.optional(),assets:wn.array().optional(),server:$s,previewCount:he().optional()}).strict().superRefine((e,t)=>{const n=x(t),o=Or({validationType:ot.CONTENT,sectionType:e.type}),s=Or({validationType:ot.DESIGN,sectionType:e.type});Ir(e.content,o,n.at("content")),Ir(e.design,s,n.at("design")),Cr(e.content,e.design,n.at("content")),Sf(e.design,n.at("design")),e.assets&&e.assets.forEach(i=>{If(i.path,i.size,n.at("assets"))}),wf(e.server.size,n.at("server"));const r=e.assets?.map(i=>i.path)??[];wr(e.content,r,n.at("content")),Of(e.showcase,n.at("showcase")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);wr(i,r,c),_f(i,e.content,c),yf(i,e.design,c),Tf(i,e.layout,c)})}),Cf=p({translations:Zt.optional()}).strict(),Rf=U(["products","category","product"]),bf=p({id:h(),sectionId:h(),assets:wn.array().optional(),content:Un.optional(),design:Fn.optional(),translationsSettings:Zt.optional(),layouts:Mn.array().optional()}).strict().superRefine((e,t)=>{const n=x(t);st.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,st.options.join(", ")),e.assets&&e.assets.forEach(o=>{o.size>xt&&n.at(["assets",z.basename(o.path)]).addIssue("REQUIRED_SECTION_ASSET",Se(o.size),Se(xt))})});p({id:h(),sectionId:st,pageId:Rf,content:Un.optional(),design:Fn.optional(),layouts:Mn.array().optional()}).strict();const Af=p({id:h(),sectionId:h(),layoutId:h(),server:$s}).strict().superRefine((e,t)=>{const n=x(t);st.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,st.options.join(", ")),e.server.size>Bt&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",Se(e.server.size),Se(Bt))});function Nf(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(s=>s.id===e.id);o?(o.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(s=>s.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 $f(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(s=>s.id===e.id);o?(o.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(s=>s.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 Lf(e,t,n){if(!e)return;const o=n.at(["showcase_overrides"]);["content","design"].forEach(r=>{const i=e[r];if(i){const a=t[r]||{};Object.keys(i).forEach(c=>{if(!(c in a)){const l=r==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";o.at([r,c]).addIssue(l,c)}})}}),e.layoutId&&((t.layout||[]).some(r=>r.layoutId===e.layoutId)||o.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const s=t.assets?.map(r=>r.path)??[];e.content&&zs(e.content,s,o.at(["content"]))}function Rr(e,t,n,o=!1){if(!e.id)return;const s=t.find(r=>r.id===e.id);if(!s){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}!o&&(s.type==="HEADER"||s.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),Lf(e.showcase_overrides,s,n),e.showcase_id&&((s.showcase||[]).some(r=>r.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function Df(e,t,n,o){e.id&&(n.some(s=>s.sectionId===t.type.toLowerCase()&&s.id===e.id)||o.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const kf=p({version:h(),name:h(),shared:Cf.optional(),sections:A(vf),templates:A(cf),layouts:A(bf),slots:A(Af),collections:A(ff),compressionEnabled:v(),externalizationEnabled:v(),vueVersion:h(),openSource:v().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,o)=>{const s=x(t).at(["templates",o]);Nf(n.configuration.header,e.sections,s.at(["configuration","header"])),$f(n.configuration.footer,e.sections,s.at(["configuration","footer"])),n.pages.forEach((r,i)=>{const a=s.at(["pages",i]);r.sections.forEach((c,l)=>{const d=a.at(["sections",l]);c.type==="custom"?Rr(c,e.sections,d):c.type==="store"&&Df(c,r,e.layouts,d)})})}),e.collections.forEach((n,o)=>{n.descriptor.sections.forEach((s,r)=>{const i=x(t).at(["collections",o,"sections",r]);Rr(s,e.sections,i,!0)})})});_e({customError:Vd});const f={error:e=>console.log(Ii(e)),warn:e=>console.log(Oi(e)),info:e=>console.log(ce(e))},Pf="dist",zf="dist/shared",me="dist/sections",Gn="dist/headers",xn="dist/footers",Te="dist/templates",Ze="layouts",br="preview",Q=`dist/${Ze}`,it="dist/collections",Ar="dist/manifest.json",jf=[me,Gn,xn,Te,Q];function Ht(e){return!!e}function $e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Uf="Resource name can only contain alphanumeric characters, dashes, and underscores";function Ff(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:Uf}}function Mf(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function Gf(e){return z.parse(e).name}function xf(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Vt(){const e=await ln(S(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function Bf(e){return e.includes(`
|
|
40
|
+
`)}function Zf(e,t,n){return e.split(`
|
|
41
|
+
`).map((o,s)=>s>=n?t+o:o).join(`
|
|
42
|
+
`)}function Le(e,t){const n=[];if(e instanceof Eo){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const r=e.response?.data;if(r?.errorCode&&n.push(` Error Code: ${r.errorCode}`),r?.errorMessage){const i=Bf(r.errorMessage)?Zf(r.errorMessage," ",1):r.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 s=n.length>0?`
|
|
44
|
+
`:" ";return`${t}${s}${o}`}function Bn(e,t){return Object.keys(e).reduce((n,o)=>{const s=e[o],r=t[o];return $e(s)&&$e(r)?n[o]=Bn(s,r):n[o]=s,n},{...t})}function Hf({contentSettings:e,sectionType:t}){const n=Sr(t);return Bn(e,n)}function Vf({designSettings:e,sectionType:t}){const n=Tr(t);return Bn(e,n)}async function se(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=Ni(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Nr(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 Wf(e){if(e!==void 0)return{...e,color:de(e.color)}}function De(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Yf(e){if(e!==void 0)switch(e){case In.COLOR:return"solid";case In.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(In)}`)}}function Kf({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:Yf(e),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Jf(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(Ad)}`)}}function Xf(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($d)}`)}}function Qf(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(Dd)}`)}}function qf(e){const t=Jf(e.appearance),n=Xf(e.size),o=Qf(e.shape),s=Zn(e.font),r=de(e.color),i=e.visible;return De({appearance:t,size:n,style:o,font:s,color:r,visible:i})}function eh(e){const t=de(e.color);return De({color:t})}function th(e){if(e!==void 0)switch(e){case bt.COLOR:return"solid";case bt.GRADIENT:return"gradient";case bt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(bt)}`)}}function nh(e){const t=e.color,n=Array.isArray(t)?t:[t,t],o=e.visible,s={type:th(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}};return De({overlay:s,visible:o})}function oh(e){const t=Zn(e.font),n=de(e.color),o=Nr(e.size),s=e.bold,r=e.italic,i=e.spacing,a=e.capitalization,c=e.visible;return De({font:t,color:n,size:o,frame:Wf(e.frame),bold:s,italic:r,spacing:i,capitalization:a,visible:c})}function sh(e){const t=e.value;return De({value:t})}function rh(e){const t=Zn(e.font),n=de(e.color),o=Nr(e.size),s=e.bold,r=e.italic,i=e.visible;return De({font:t,color:n,size:o,bold:s,italic:r,visible:i})}function ih(e){const t=e.enabled;return De({enabled:t})}function Hn(e,t){if(t.defaults===void 0)return;let n={};switch(e){case te.TEXT:{n=rh(t.defaults);break}case te.BUTTON:{n=qf(t.defaults);break}case te.IMAGE:{n=nh(t.defaults);break}case te.BACKGROUND:{n=Kf(t.defaults);break}case te.COLOR_PICKER:{n=eh(t.defaults);break}case te.LOGO:{n=oh(t.defaults);break}case te.SELECTBOX:{n=sh(t.defaults);break}case te.TOGGLE:{n=ih(t.defaults);break}case te.DIVIDER:case te.INFO:break;case te.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function $r(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],s=o.type;if(s===te.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:$r(c.editors)}]));t[n]={...o,items:i};return}const r=Hn(s,o);r&&o.defaults?t[n]={...o,defaults:r}:t[n]=o}),t}function ah(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],s=o.type;if(s===te.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 r=Hn(s,{defaults:o});r!==void 0?t[n]={...o,...r,type:o.type}:t[n]=o}),t}function ch(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function lh(e){const t={};for(const n in e){const o=e[n];for(const s in o){const r=t[s],i=o[s];if(r===void 0){const a={};a[n]=i,t[s]=a}else r[n]=i}}return t}function uh(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function He(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return uh(e)?e:e.map(s=>He(s,t));const n=e,o={};for(const s in n){const r=n[s];typeof r=="string"&&r.startsWith("$")?o[s]=ch(t,r):typeof r=="object"&&r!==null?o[s]=He(r,t):o[s]=r}return o}async function at(e){return e?lh(e):{}}async function dh(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await se(n)}async function Wt(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await se(n)}async function ph(e,t){const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/translations.mjs`);if(V(n))return await se(n)}async function Wn(e,t,n){const o=n?Hf({contentSettings:e,sectionType:n}):e;return He(o,t)}async function fh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/content.mjs`),o=await se(n);return Be(o)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Yn(e,t,n){const o=n?Vf({designSettings:e,sectionType:n}):e,s=$r(o);return He(s,t)}async function hh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/design.mjs`),o=await se(n);return Be(o)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function mh(e,t){return Promise.all(e.map(async n=>{const o=n.design?Vn(n.design):void 0,s={...n,design:o??n.design};return He(s,t)}))}async function Eh(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 s=S(F.cwd(),`${t}/${e}/js/showcases/${o}`);return await se(s)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Lr(e){return e?.map(t=>({...t,selectedDesignSettings:ah(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function gh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/layout.mjs`);return V(n)?await se(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function _h(e){let t={};const n=S(F.cwd(),`${br}/shared/analytics.json`);if(!V(n))return 0;try{const o=sn(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}const Ve={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Kn="https://blockbuster.ecwid.com",yh="/api/v1/custom-apps/resources/sections/upload",Sh="/api/v1/custom-apps/resources/templates/upload",Th="/api/v1/custom-apps/manifests/sections",Oh="/api/v1/custom-apps/manifests/templates",Ih=5,wh=3,vh=[R.Server,R.Client,R.ClientChunks,R.ClientAsset,R.Asset],Ch=[R.LayoutClient,R.LayoutAsset],Rh=[R.SlotServer,R.SlotClient,R.SlotClientChunks,R.SlotClientAsset],bh=[R.Dependency,R.TemplateAsset,R.SourceCode,R.CollectionAsset],We={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.`},Dr={catalog:"products",category:"category",product:"product"},kr=e=>Dr[e],Pr=e=>e in Dr;function Ah(e){return e.replace(/\\/g,"/")}function Nh(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Yt(e){return Nh(Ah(e))}function $h(e){const t=Yt(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(!Pr(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const s=kr(n);return{id:o,sectionId:n,pageId:s}}async function Lh(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=kr(n),s=await at(t.translationsSettings),r=await Wn(t.content??{},s),i=await Yn(t.design??{},s),a=await Lr(t.layouts);return{id:t.id,sectionId:n,pageId:o,contentEditors:r,designEditors:i,layouts:a}}))}function Ye(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 ct=(e=ye.SECTION)=>G[e].dist,lt={[R.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/server/`},[R.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/`},[R.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[R.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/assets/`},[R.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(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})=>Ye(e,t,"")},[R.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Ye(e,t,"assets/")},[R.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(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})=>Ye(e,t,"slots",n,"js/main/client/")},[R.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/chunks/")},[R.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/assets/")},[R.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${it}/assets/`}};function Dh(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 ln(e),n=JSON.parse(t.toString());if(Dh(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const kh={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Ph(e,t){const n=kh[e];return n?n(t):t.id}const zh=new Set(["content","design"]);function Kt(e,t,n=0,o=[]){if(n>=t.length)return o;const s=t[n],r=t[n+1];if(typeof s=="string"&&typeof r=="number"&&$e(e)){const i=e[s],a=Array.isArray(i)?i[r]:void 0;if($e(a)){const c=Ph(s,a);return o.push(`${s}[${c||r}]`),Kt(a,t,n+2,o)}}if(typeof s=="string"&&typeof r=="string"&&zh.has(s)){o.push(`${s}[${r}]`);const i=$e(e)&&!Array.isArray(e)?e[s]:void 0,a=$e(i)&&!Array.isArray(i)?i[r]:void 0;return Kt(a,t,n+2,o)}return o.push(s),Kt($e(e)?e[s]:void 0,t,n+1,o)}function jh(e){const t=e.errors.map(o=>Kt(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,s)=>{const r=o.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[s].padEnd(n.path," ")} | ${o.message.padEnd(n.message," ")} | ${r}`}).forEach(o=>f.error(o))}async function Uh(e){const t=kf.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const Fh=`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 o=0,
|
|
49
|
-
`,0),a=-1;for(;i>=0&&
|
|
50
|
-
`,i+1)}const c=[this.generatedCodeColumn,t,o.line,o.column];
|
|
51
|
-
`?(
|
|
46
|
+
For deploy run: npx @lightspeed/crane@latest deploy`;function Mh(e,t){if(e.errors.length===0){f.info(Fh);return}f.error("Invalid configuration detected:"),jh(e),t||process.exit(1)}const zr={"process.env":{NODE_ENV:"production"}},Gh=[...go,...go.map(e=>`node:${e}`)],xh=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],jr=e=>({pluginType:ee.Server,define:zr,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...Gh,...xh],inlineDynamicImports:!0,...e,outDir:e.outDir}),Ur=e=>({pluginType:ee.Client,define:zr,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),Ke=e=>({pluginType:ee.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),Bh=e=>({pluginType:ee.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),Jt=e=>({pluginType:ee.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let Xt=!1;function Zh(e){Xt=e}function Xn(){return Xt}const Fr=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Hh=80,Vh="\x1B[?25l",Wh="\x1B[?25h",Yh="\x1B[2K\r",Kh=44;let Jh=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){Xt||(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(Vh),this.render(),this.timer=setInterval(()=>this.render(),Hh))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(Kh-1," "),n=ce(Fr[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%Fr.length}stop(){if(!Xt&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${Yh}${Wh}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Mr=new Jh,Xh=()=>$i({ext:".gz",algorithm:"gzip",verbose:Xn()}),Qh="/* EXTERNAL_IMPORTS_START */",qh="/* EXTERNAL_IMPORTS_END */",em=()=>({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 s=/import.*\?commonjs-external["'];/g,r=o.code.match(s);if(r!==null){const i=r.join(""),a=Qh+i+qh,c=o.code.replace(s,"");o.code=a+c}}}}}),tm=()=>({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})}}),nm=()=>{const e=process.env.npm_lifecycle_event;return ki({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:()=>Li(),tsconfigPaths:()=>Di(),checker:()=>nm()};class on{constructor(t){this.bits=t instanceof on?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class dt{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 dt(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),s=this.original.slice(n);this.original=o;const r=new dt(t,this.end,s);return r.outro=this.outro,this.outro="",this.end=t,this.edited?(r.edit("",!1),this.content=""):this.content=o,r.next=this.next,r.next&&(r.next.previous=r),r.previous=this,this.next=r,r}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 om(){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 sm=om();class rm{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Pi(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,"+sm(this.toString())}}function im(e){const t=e.split(`
|
|
47
|
+
`),n=t.filter(r=>/^\t+/.test(r)),o=t.filter(r=>/^ {2,}/.test(r));if(n.length===0&&o.length===0)return null;if(n.length>=o.length)return" ";const s=o.reduce((r,i)=>{const a=/^ +/.exec(i)[0].length;return Math.min(a,r)},1/0);return new Array(s+1).join(" ")}function am(e,t){const n=e.split(/[/\\]/),o=t.split(/[/\\]/);for(n.pop();n[0]===o[0];)n.shift(),o.shift();if(n.length){let s=n.length;for(;s--;)n[s]=".."}return n.concat(o).join("/")}const cm=Object.prototype.toString;function lm(e){return cm.call(e)==="[object Object]"}function Gr(e){const t=e.split(`
|
|
48
|
+
`),n=[];for(let o=0,s=0;o<t.length;o++)n.push(s),s+=t[o].length+1;return function(s){let r=0,i=n.length;for(;r<i;){const l=r+i>>1;s<n[l]?i=l:r=l+1}const a=r-1,c=s-n[a];return{line:a,column:c}}}const um=/\w/;class dm{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,s){if(n.length){const r=n.length-1;let i=n.indexOf(`
|
|
49
|
+
`,0),a=-1;for(;i>=0&&r>i;){const l=[this.generatedCodeColumn,t,o.line,o.column];s>=0&&l.push(s),this.rawSegments.push(l),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];s>=0&&c.push(s),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,s,r){let i=n.start,a=!0,c=!1;for(;i<n.end;){if(this.hires||a||r.has(i)){const l=[this.generatedCodeColumn,t,s.line,s.column];this.hires==="boundary"?um.test(o[i])?c||(this.rawSegments.push(l),c=!0):(this.rawSegments.push(l),c=!1):this.rawSegments.push(l)}o[i]===`
|
|
51
|
+
`?(s.line+=1,s.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0):(s.column+=1,this.generatedCodeColumn+=1,a=!1),i+=1}this.pending=null}advance(t){if(!t)return;const n=t.split(`
|
|
52
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
|
-
`,Je={insertLeft:!1,insertRight:!1,storeName:!1};class ao{constructor(t,n={}){const o=new
|
|
54
|
-
`));else for(a=c.start;a<
|
|
55
|
-
`?
|
|
56
|
-
${
|
|
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]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ke({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]:Ke({entryFileNames:"[name].mjs",outDir:()=>`./${Te}/js`}),[N.PageTemplateDescriptor]:Ke({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]:Ke({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]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${st}/${e}`}),[N.CollectionAsset]:Kt({outDir:()=>`./${st}/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(`./${Ze}/{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(`./${Ze}/${r}/${o}/settings/{content,design,translations,layout}.{js,ts}`,e),I(`./${Ze}/${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:Ve.Server,sectionType:e.type}))}),se({entryPoints:e.clientEntrypoint,configType:Ve.Client,name:e.name,sectionType:e.type}),se({entryPoints:e.assetEntryPoints,configType:Ve.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:Ve.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(`${Ze}/{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(`${Ze}/${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:Ve.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:Ve.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:Qe(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,Be.SECTION)),...t.map(async o=>Qn(o,Be.HEADER)),...n.map(async o=>Qn(o,Be.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:Qe(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 Pe(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 Pe(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:Qe(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(`${st}/*/configuration*.mjs`,{ignore:["node_modules/**",`${st}/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 He(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
|
|
59
|
-
`)}function
|
|
53
|
+
`,Je={insertLeft:!1,insertRight:!1,storeName:!1};class ao{constructor(t,n={}){const o=new dt(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 on},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 s=n.next,r=s&&s.clone();r&&(o.next=r,r.previous=o,o=r),n=s}return t.lastChunk=o,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new on(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const n=0,o=Object.keys(this.storedNames),s=new dm(t.hires),r=Gr(this.original);return this.intro&&s.advance(this.intro),this.firstChunk.eachNext(i=>{const a=r(i.start);i.intro.length&&s.advance(i.intro),i.edited?s.addEdit(n,i.content,a,i.storeName?o.indexOf(i.original):-1):s.addUneditedChunk(n,i,this.original,a,this.sourcemapLocations),i.outro.length&&s.advance(i.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?am(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:o,mappings:s.raw,x_google_ignoreList:this.ignoreList?[n]:void 0}}generateMap(t){return new rm(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=im(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(lm(t)&&(n=t,t=void 0),t===void 0&&(this._ensureindentStr(),t=this.indentStr||" "),t==="")return this;n=n||{};const s={};n.exclude&&(typeof n.exclude[0]=="number"?[n.exclude]:n.exclude).forEach(d=>{for(let m=d[0];m<d[1];m+=1)s[m]=!0});let r=n.indentStart!==!1;const i=l=>r?`${t}${l}`:(r=!0,l);this.intro=this.intro.replace(o,i);let a=0,c=this.firstChunk;for(;c;){const l=c.end;if(c.edited)s[a]||(c.content=c.content.replace(o,i),c.content.length&&(r=c.content[c.content.length-1]===`
|
|
54
|
+
`));else for(a=c.start;a<l;){if(!s[a]){const d=this.original[a];d===`
|
|
55
|
+
`?r=!0:d!=="\r"&&r&&(r=!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 Je.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Je.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Je.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Je.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 s=this.byStart[t],r=this.byEnd[n],i=s.previous,a=r.next,c=this.byStart[o];if(!c&&r===this.lastChunk)return this;const l=c?c.previous:this.lastChunk;return i&&(i.next=a),a&&(a.previous=i),l&&(l.next=s),c&&(c.previous=r),s.previous||(this.firstChunk=r.next),r.next||(this.lastChunk=s.previous,this.lastChunk.next=null),s.previous=l,r.next=c||null,l||(this.firstChunk=s),c||(this.lastChunk=r),this}overwrite(t,n,o,s){return s=s||{},this.update(t,n,o,{...s,overwrite:!s.contentOnly})}update(t,n,o,s){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),s===!0&&(Je.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Je.storeName=!0),s={storeName:!0});const r=s!==void 0?s.storeName:!1,i=s!==void 0?s.overwrite:!1;if(r){const l=this.original.slice(t,n);Object.defineProperty(this.storedNames,l,{writable:!0,value:!0,enumerable:!0})}const a=this.byStart[t],c=this.byEnd[n];if(a){let l=a;for(;l!==c;){if(l.next!==this.byStart[l.end])throw new Error("Cannot overwrite across a split point");l=l.next,l.edit("",!1)}a.edit(o,r,!i)}else{const l=new dt(t,n,"").edit(o,r);c.next=l,l.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="",s=this.firstChunk;for(;s&&(s.start>t||s.end<=t);){if(s.start<n&&s.end>=n)return o;s=s.next}if(s&&s.edited&&s.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const r=s;for(;s;){s.intro&&(r!==s||s.start===t)&&(o+=s.intro);const i=s.start<n&&s.end>=n;if(i&&s.edited&&s.end!==n)throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);const a=r===s?t-s.start:0,c=i?s.content.length+n-s.end:s.content.length;if(o+=s.content.slice(a,c),s.outro&&(!i||s.end===n)&&(o+=s.outro),i)break;s=s.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 s=Gr(this.original)(n);throw new Error(`Cannot split a chunk that has already been edited (${s.line}:${s.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 s=o.end,r=o.trimEnd(n);if(o.end!==s&&(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),r)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 s=o.end,r=o.trimStart(n);if(o.end!==s&&(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),r)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(r,i){return typeof n=="string"?n.replace(/\$(\$|&|\d+)/g,(a,c)=>c==="$"?"$":c==="&"?r[0]:+c<r.length?r[+c]:`$${c}`):n(...r,r.index,i,r.groups)}function s(r,i){let a;const c=[];for(;a=r.exec(i);)c.push(a);return c}if(t.global)s(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 r=this.original.match(t);if(r&&r.index!=null){const i=o(r,this.original);i!==r[0]&&this.overwrite(r.index,r.index+r[0].length,i)}}return this}_replaceString(t,n){const{original:o}=this,s=o.indexOf(t);return s!==-1&&this.overwrite(s,s+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,s=t.length;for(let r=o.indexOf(t);r!==-1;r=o.indexOf(t,r+s))o.slice(r,r+s)!==n&&this.overwrite(r,r+s,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 xr=S(process.cwd(),"shared/translation.ts"),Br="globalThis.craneSharedTranslation = translation",pm=e=>`import translation from '${e}';
|
|
56
|
+
${Br};
|
|
57
|
+
`,fm=(e,t)=>{const n=e.split("?")[0],o=Si(n);return(o==="server.ts"||o==="client.ts")&&!t.includes(Br)},Zr=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=V(xr)},transform(t,n){if(!e||!fm(n,t))return null;const o=n.split("?")[0],s=lo(o),r=vi(uo(s,xr)),i=pm(r),a=new ao(t);return a.prepend(i),{code:a.toString()}}}},Hr={[ee.Server]:()=>[pe.vue(),pe.tsconfigPaths(),em(),Xh(),Zr()],[ee.Client]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:"EcVue"}),Zr()],[ee.Misc]:()=>[pe.tsconfigPaths()],[ee.Layout]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:["EcExternals","Vue"]})],[ee.Asset]:()=>[tm()],[ee.SharedFiles]:()=>[pe.tsconfigPaths()]},Vr={[N.Server]:jr({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/server`}),[N.Client]:Ur({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/client`}),[N.SectionSetting]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/showcases`}),[N.SectionAsset]:Jt({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/assets`}),[N.TemplateDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:()=>`./${Te}/js`}),[N.PageTemplateDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Te}/${e}`}),[N.TemplateAsset]:Jt({outDir:()=>`./${Te}/assets`}),[N.Layout]:Bh({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}`}),[N.LayoutSettings]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/js/settings`}),[N.LayoutAsset]:Jt({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/assets`}),[N.SlotServer]:jr({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/server`}),[N.SlotClient]:Ur({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/client`}),[N.CollectionDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${it}/${e}`}),[N.CollectionAsset]:Jt({outDir:()=>`./${it}/assets`}),[N.SharedTranslation]:{pluginType:ee.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function hm(e){switch(typeof e){case"string":return[S(process.cwd(),e)];case"object":return e.map(t=>S(process.cwd(),t));default:return[]}}function Wr({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:s,sectionType:r=ye.SECTION}){const i=Vr[n],a=i.define,c=i.ssrOptions,l=i.entryFileNames,d=i.chunkFileNames,m=i.assetFileNames,y=i.inlineDynamicImports,T=i.externalOption;return{logLevel:Xn()?void 0:"silent",plugins:Hr[i.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:i.ssr,outDir:i.outDir({name:e,sectionType:r,layoutId:o,sectionId:s}),emptyOutDir:!0,minify:i.ssr?"terser":"esbuild",...i.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:T,preserveEntrySignatures:"strict",input:hm(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:y,entryFileNames:l,chunkFileNames:d,assetFileNames:m}}},assetsInclude:["**/*.json"]}}const mm=Object.values(G).map(e=>e.source).join("|");function Yr(e,t,n){if(!e)return`${t}.mjs`;const o=uo(process.cwd(),e).replace(/\\/g,"/").match(`^(${mm})/([^/]+)/${n}/([^/.]+)`);return o?`${o[1]}/${o[2]}/js/${n}/${o[3]}.mjs`:`${t}.mjs`}function Kr(e,t){const n=Vr[N.SectionSetting];return{logLevel:Xn()?void 0:"silent",plugins:Hr[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 Em(e){return Kr(e,t=>Yr(t.facadeModuleId??void 0,t.name,"settings"))}function gm(e){return Kr(e,t=>Yr(t.facadeModuleId??void 0,t.name,"showcases"))}async function _m(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`./${Ze}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:o,sectionId:s,pageId:r}=$h(n),[i,a]=await Promise.all([I(`./${Ze}/${s}/${o}/settings/{content,design,translations,layout}.{js,ts}`,e),I(`./${Ze}/${s}/${o}/assets/*`,e)]);return{name:o,sectionId:s,pageId:r,clientEntrypoint:n,settingsEntryPoints:i,assetsEntrypoints:a}}))}async function ym(e){await re({entryPoints:[e.clientEntrypoint],configType:N.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([re({entryPoints:e.settingsEntryPoints,configType:N.LayoutSettings,name:e.name,sectionId:e.sectionId}),re({entryPoints:e.assetsEntrypoints,configType:N.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function Sm(e){e===void 0||e.length===0||await Promise.all(e.map(t=>ym(t)))}async function Tm(e){const t=e.flatMap(o=>o.settingsEntryPoints),n=e.flatMap(o=>o.showcaseEntryPoints);t.length>0&&await ge({configFile:!1,...mt(Em(t))}),n.length>0&&await ge({configFile:!1,...mt(gm(n))})}async function Om(e){await Promise.all([ge({configFile:!1,...mt(Wr({name:e.name,entryPoints:e.serverEntrypoint,configType:Ve.Server,sectionType:e.type}))}),re({entryPoints:e.clientEntrypoint,configType:Ve.Client,name:e.name,sectionType:e.type}),re({entryPoints:e.assetEntryPoints,configType:Ve.SectionAsset,name:e.name,sectionType:e.type})])}async function Im(){const e=S(process.cwd(),"shared/translation.ts");V(e)&&await re({entryPoints:["shared/translation.ts"],configType:Ve.SharedTranslation})}async function Jr(e){await Promise.all([Tm(e),...e.map(Om)])}function wm(e){const t=Yt(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,,s]=t;if(!Pr(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:s,sectionId:n,layoutId:o}}async function vm(e,t){return Promise.all(e.map(async n=>{const o=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),s=await at(o?.translationsSettings),r=await Wn(o?.content??{},s),i=await Yn(o?.design??{},s);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:r,designEditors:i}}))}async function Cm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`${Ze}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:o,sectionId:s,layoutId:r}=wm(n),i=(await I(`${Ze}/${s}/${r}/slots/${o}/client.{js,ts}`,e))[0];if(i===void 0)throw new Error(`Cannot find client entrypoint file for slot ${o} of section ${s}`);return{id:o,sectionId:s,layoutId:r,serverEntrypoint:n,clientEntrypoint:i}}))}async function Rm(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([re({entryPoints:[e.serverEntrypoint],configType:N.SlotServer,...t}),re({entryPoints:[e.clientEntrypoint],configType:N.SlotClient,...t})])}async function bm(e){e?.length&&await Promise.all(e.map(Rm))}async function Am(e){return(await I(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(Cs).includes(n)})}async function Nm(){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(cn),o=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const s=await I(`**/templates/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=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/**"]}),l=await Am(o);return{name:o,configurationEntrypoint:s.at(0),homeEntrypoint:r.at(0),categoryEntrypoint:i.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:l.length>0?l:void 0}}))}async function $m(){const e=await I("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await I("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Nm(),templates:e,assets:t}}async function Lm({templateBuildConfig:e}){await Promise.all([re({entryPoints:e.assets,configType:Ve.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Ht);if(n.length===0)throw new Error("No entry points provided for page template");await re({entryPoints:n,configType:Ve.PageTemplateDescriptor,name:t.name})})||[]])}async function Dm(){const e=await $m();await Lm({templateBuildConfig:e})}async function km(){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(cn),s=o.pop()??"default";if(o.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const r=await I(`**/collections/${s}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:s,configurationEntrypoint:r.at(0),assetsEntrypoints:t}}))}async function Pm(){const e=await km();e.length!==0&&await Promise.all(e.flatMap(t=>[re({entryPoints:t.assetsEntrypoints,configType:N.CollectionAsset,name:t.name}),re({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:N.CollectionDescriptor,name:t.name})]))}function Xr(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Ht).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Ht),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Ht),assetEntryPoints:e.assetsEntrypoints??[]}}function Qr(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 zm(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),o=yo(So.gunzip),s=await C.promises.readFile(n);return{size:(await o(s)).length}}async function jm(e,t=me){try{const n=S(process.cwd(),`${t}/${e}/assets/`);return(await I("*",{cwd:n})).map(o=>{const s=S(n,o);return{path:o,size:Qe(s).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Qn(e,t){const n=await dh(e,G[t].dist),o=await Wt(e,G[t].dist),s=await fh(e,G[t].dist),r=await hh(e,G[t].dist),i=await Eh(e,G[t].dist),a=await gh(e,G[t].dist),c=Qr(a),l=await jm(e,G[t].dist),d=await zm(e,G[t].dist),m=_h(e);return{id:e,type:t,name:e,content:s,design:r,layout:c,showcase:i,translationsSettings:n,translationsShowcases:o,assets:l,server:d,previewCount:m}}async function Um(){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,Ae.SECTION)),...t.map(async o=>Qn(o,Ae.HEADER)),...n.map(async o=>Qn(o,Ae.FOOTER))])}async function Fm(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:Qe(o).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function Mm(e){const t=Yt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t,[s,r,i,a,c]=await Promise.all([xm(o,n),Bm(o,n),ph(o,n),Fm(e),Zm(o,n)]);return{id:o,sectionId:n,content:s,design:r,translationsSettings:i,assets:a,layouts:c}}async function Gm(){const e=`${Q}/{product,catalog,category}/*`,t=await I(e,{ignore:["node_modules/**"]});return Promise.all(t.map(Mm))}async function xm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/content.mjs`),o=await se(n);return Be(o)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Bm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/design.mjs`),o=await se(n);return Be(o)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Zm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/layout.mjs`);if(!C.existsSync(n))return[];const o=await se(n);return Qr(o)}catch(n){throw new Error(`Layout settings descriptor for layout [${e}] in section [${t}] is either invalid or undefined: ${n}`)}}async function Hm(e,t,n){const o=S(process.cwd(),`${Q}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),s=yo(So.gunzip),r=await C.promises.readFile(o);return{size:(await s(r)).length}}async function Vm(e){const t=Yt(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,,s]=t,r=await Hm(s,o,n);return{id:s,sectionId:n,layoutId:o,server:r}}async function Wm(){const e=`${Q}/{product,catalog,category}/*/slots/*`,t=await I(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(Vm))}async function Ym(){try{const e=S(process.cwd(),`${Te}/assets/`);return(await I("*",{cwd:e})).map(t=>{const n=S(e,t);return{path:t,size:Qe(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function Km(e){return e in Ne?Ne[e]:Ne.CUSTOM}async function Jm(e){const t=await I(`${Te}/${e}/*.mjs`,{ignore:[`${Te}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:s}=await qn(n),r=Gf(n);return{type:Km(r.toUpperCase()),id:r,metadata:s,sections:o}}))}async function qn(e){try{return await se(S(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function Xm(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 Ym(),configuration:await qn(n),pages:await Jm(o)}}))}async function Qm(e){return await Xm(e)}async function qm(){const e=S(process.cwd(),`${zf}/translation.mjs`);return await se(e)}async function eE(){return{translations:await qm()}}async function tE(e){const t=await I(`${it}/*/configuration*.mjs`,{ignore:["node_modules/**",`${it}/assets/**`]});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n)),s=await qn(n);return{id:`${e}_${o}`,descriptor:s}}))}async function qr(){const e=await Vt(),[t,n,o,s,r,i,a]=await Promise.all([Jn(),eE(),Um(),Gm(),Wm(),Qm(e.appClientId),tE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:o,templates:i,layouts:s,slots:r,collections:a,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue,openSource:t.openSource}}function eo(e){return V(`${Gn}/${e}`)?ye.HEADER:V(`${xn}/${e}`)?ye.FOOTER:ye.SECTION}async function to(e,t){const n=e.design?Vn(e.design):void 0,o={...e,design:n??e.design},s=await at(t);return He(o,s)}function no(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function ei(e){if(no(e)){const t=await Wt(e.id,G[eo(e.id)].dist);return{...e,showcase_overrides:await to(e.showcase_overrides,t)}}return e}async function nE(e){const t=no(e.header)?{...e.header,showcase_overrides:await to(e.header.showcase_overrides,await Wt(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 Wt(e.footer.id,G[eo(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 o=>({...o,sections:await Promise.all(o.sections.map(s=>ei(s)))}))),n=await nE(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function sE(e){return Promise.all(e.map(t=>oE(t)))}async function rE(e){const t=new Map;return await Promise.all(e.map(async n=>{const[o,s]=await Promise.all([at(n.translationsSettings),at(n.translationsShowcases)]);t.set(n.id,{settings:o,showcases:s})})),t}async function iE(e,t,n){const[o,s,r,i]=await Promise.all([Wn(e.content,t,e.type),Yn(e.design,t,e.type),mh(e.showcase,n),Lr(e.layout)]);return{id:e.id,type:e.type,name:{en:e.name},contentEditors:o,designEditors:s,layouts:i,showcases:r,previewCount:e.previewCount}}async function aE(e,t){return Promise.all(e.map(async n=>{const o=t.get(n.id)??{settings:{},showcases:{}};return iE(n,o.settings,o.showcases)}))}async function cE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(o=>ei(o)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function ti(e){const t=await rE(e.sections),[n,o,s,r,i]=await Promise.all([aE(e.sections,t),Lh(e.layouts),vm(e.slots,e.layouts),sE(e.templates),cE(e.collections)]);return{version:e.version,name:e.name,blocks:n,templates:r,layouts:o,slots:s,compressionEnabled:e.compressionEnabled,externalizationEnabled:e.externalizationEnabled,vueVersion:e.vueVersion,collections:i,openSource:e.openSource}}async function lE(e){const t=S(Et.cwd(),Ar);return bi(t,JSON.stringify(e))}function uE(e){return Object.entries(G).find(t=>t[1].source===e)?.[0]}async function ni(){const e=await I("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=lo(t).split(cn),o=n.pop()??"default",s=n.pop();if(s===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const r=["node_modules/**","dist/**"],[i,a,c,l,d,m,y,T]=await Promise.all([I(`**/${o}/client.{js,ts}`,{ignore:r}),I(`**/${o}/settings/content.{js,ts}`,{ignore:r}),I(`**/${o}/settings/design.{js,ts}`,{ignore:r}),I(`**/${o}/settings/layout.{js,ts}`,{ignore:r}),I(`**/${o}/settings/translations.{js,ts}`,{ignore:r}),I(`**/${o}/showcases/*.{js,ts}`,{ignore:[...r,`**/${o}/showcases/translations.{js,ts}`]}),I(`**/${o}/showcases/translations.{js,ts}`,{ignore:r}),I(`**/${o}/assets/*`,{ignore:r})]);return{name:o,type:uE(s),serverEntrypoint:t,clientEntrypoint:i.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:l.at(0),settingsTranslationsEntrypoint:d.at(0),showcasesEntrypoints:m,showcasesTranslationsEntrypoint:y.at(0),assetsEntrypoints:T}}))}const dE=["/settings/","/showcases/"];function pE(e){return dE.some(t=>e.includes(t))}function fE(){const e=le.findConfigFile(process.cwd(),le.sys.fileExists,"tsconfig.json");if(!e)return;const t=le.readConfigFile(e,le.sys.readFile),n=le.parseJsonConfigFileContent(t.config,le.sys,process.cwd()),o=le.createProgram(n.fileNames,n.options),s=le.getPreEmitDiagnostics(o).filter(r=>!r.file||!pE(r.file.fileName));if(s.length>0){const r={getCanonicalFileName:i=>i,getCurrentDirectory:le.sys.getCurrentDirectory,getNewLine:()=>le.sys.newLine};throw console.error(le.formatDiagnosticsWithColorAndContext(s,r)),new Error(`TypeScript found ${s.length} error(s)`)}}async function hE(e){fE(),await ge({configFile:!1,logLevel:"error",plugins:[pe.vue(),pe.tsconfigPaths(),pe.checker()],build:{write:!1,rollupOptions:{input:S(process.cwd(),e)}}})}function mE(){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 EE(){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(r=>{const i=S(process.cwd(),r);e.addLocalFile(i,po(r).dir)});const o=lt[R.SourceCode].fileName,s=S(process.cwd(),o);await e.writeZipPromise(s)}catch(o){throw f.error("Error while zipping source files"),o}}async function Qt(e=!1,t=!1){Zh(t),Mr.start(),await mE();try{const[n,o,s]=await Promise.all([_m(),ni(),Cm()]),r=o.map(Xr);o.length>0&&await hE(o[0].serverEntrypoint);try{await Promise.all([Im(),Jr(r),Dm(),Pm(),Sm(n),bm(s),EE()])}finally{Mr.stop()}const i=await qr(),a=await Uh(i);Mh(a,e);const c=await ti(i);await lE(c)}catch(n){f.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function re({entryPoints:e,configType:t,name:n,sectionType:o,sectionId:s,layoutId:r}){if(e.length!==0){const i=mt(Wr({name:n,entryPoints:e,configType:t,sectionType:o,sectionId:s,layoutId:r}));await ge({configFile:!1,...i})}}function oi(e,t,n){ft.statSync(e).isDirectory()?(ft.mkdirSync(t,{recursive:!0}),ft.readdirSync(e).forEach(o=>{const s=ht.resolve(e,o),r=ht.resolve(t,o);oi(s,r,n)})):zi.isMatch(e,n,{dot:!0})||ft.copyFileSync(e,t)}function Oe(e,t,n,o,s=[]){const r=ht.join(e,o?.[n]??n);oi(ht.join(t,n),r,s)}function gE(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 W.resolve(ji(import.meta.url),"../..",e)}function _E(){const e=Ee("package.json");return e!==""?JSON.parse(L.readFileSync(e,"utf8")):{}}async function yE(e){try{const t=e,n=j.cwd(),o=W.join(n,t),s=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],r={_gitignore:".gitignore"};L.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)):L.mkdirSync(o);const i=Ee("template");L.readdirSync(i).filter(d=>d!=="package.json").filter(d=>!s.includes(d)).forEach(async d=>Oe(o,i,d,r));const a=JSON.parse(L.readFileSync(W.join(i,"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 l=W.join(o,"package.json");L.writeFileSync(l,`${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 s=j.cwd(),r=z.join(s,t);C.existsSync(r)||C.mkdirSync(r);const i=z.join(s,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(s){f.error(`Error while creating ${o}: ${s.message}`),j.exit(1)}}function so(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 s=>Oe(o,n,s)))}async function SE(e,t,n,o){if(!C.existsSync(n)){C.copyFileSync(t,n);return}const s=C.readFileSync(t),r=C.readFileSync(n);s.equals(r)||(o?(await Pe({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(r,i,a){const c=z.join(i,r.name),l=z.join(a,r.name);r.isDirectory()?await qt(c,l,n):await SE(r,c,l,n)}const s=C.readdirSync(e,{withFileTypes:!0});C.existsSync(t)||C.mkdirSync(t,{recursive:!0}),await s.reduce(async(r,i)=>(await r,o(i,e,t)),Promise.resolve())}async function ro(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 TE(e,t){await ro(),oo(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function OE(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>f.info(`Collection [${e}] has been created`)}}async function IE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onCollectionCreated:s}=OE(e);try{const r=j.cwd(),i=W.join(r,"collections"),a=Ee(o),c=L.readdirSync(a);L.existsSync(i)?L.existsSync(W.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)):L.mkdirSync(i),c.forEach(l=>Oe(i,a,l,n)),s()}catch(r){f.error(`Error while creating collection: ${r.message}`),j.exit(1)}}async function wE(e){await ro(),oo("template/footers/example-footer","footers",e,"Footer")}async function vE(e){await ro(),oo("template/headers/example-header","headers",e,"Header")}async function CE(e,t){try{const n=j.cwd(),o=W.join(n,"templates"),s=Ee("template/page-templates/example-template/pages");L.existsSync(W.join(o,e))||(f.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),j.exit(1)),L.existsSync(W.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 r=L.readFileSync(W.join(s,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${xf(t)}'`),i=W.join(o,e,"pages",`${t}.ts`);L.writeFileSync(i,r),f.info(`Page [${t}.ts] created for template ${e}`)}catch(n){f.error(`Error while creating page: ${n.message}`),j.exit(1)}}async function RE(){try{const e=j.cwd(),t=Ee("template/reference"),n=L.readdirSync(t);let o=!1;for(const s of n){const r=W.join(t,s),i=W.join(e,s);L.existsSync(i)||L.mkdirSync(i,{recursive:!0});const a=L.readdirSync(r),c=L.readdirSync(i);if(s==="shared"){a.forEach(l=>{Oe(i,r,l)});continue}for(const l of a){if(l==="assets"){Oe(i,r,l);continue}if(c.includes(l)){const{name:d}=await Pe({type:"text",name:"name",message:`The "${l}" already exists in ${s} directory: provide a new name to keep both or press Esc to skip this one.`});d?(Oe(i,r,l,{[l]:d}),o=!0):f.info(`Skipped: ${l}`)}else Oe(i,r,l)}}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 bE=["**/example-template/pages/custom.ts"];async function AE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onTemplateCreated:s}=gE(e);try{const r=j.cwd(),i=W.join(r,"templates"),a=Ee(o),c=L.readdirSync(a);L.existsSync(i)?L.existsSync(W.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)):L.mkdirSync(i),c.forEach(l=>Oe(i,a,l,n,bE)),so("headers"),so("footers"),so("layouts"),s()}catch(r){f.error(`Error while creating template descriptors: ${r.message}`),j.exit(1)}}function NE(){try{const e=S(Et.cwd(),`${br}/shared/analytics.json`);V(e)&&an(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function en({deploymentContext:e,sectionType:t=ye.SECTION}){const n=e.pathContext,o=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),s=o===void 0?ho(n.fileName):ho(n.fileName,{cwd:S(process.cwd(),o),ignore:n.ignore});return(n.isSingleton?s.splice(0):s).map(r=>({url:r,sectionType:t,context:e}))}const $E=e=>e.app.manifest.blocks.flatMap(t=>vh.flatMap(n=>{const o={config:e,currentSection:t.id,pathContext:lt[n]};return en({deploymentContext:o,sectionType:t.type})})),LE=e=>bh.flatMap(t=>{const n={config:e,pathContext:lt[t]};return en({deploymentContext:n})}),DE=e=>e.app.manifest.layouts.flatMap(t=>Ch.flatMap(n=>{const o={config:e,pathContext:lt[n],currentSection:t.sectionId,layoutId:t.id};return en({deploymentContext:o})})),kE=e=>e.app.manifest.slots.flatMap(t=>Rh.flatMap(n=>{const o={config:e,pathContext:lt[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return en({deploymentContext:o})})),PE=e=>`\x1B[32m${e}\x1B[0m`,zE=(e,t,n,o,s)=>{if(!e.total)return;const{loaded:r}=e,i=(Date.now()-s)/1e3;n.value+=r-o.value,o.value=r,t.update({speed:`${Se(n.value/i,2)}/s`})},jE=()=>new Mi.SingleBar({format:`|${PE("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function si(e){await new Promise(t=>setTimeout(t,e))}const ri="Please ensure you have built your application before deploying.";async function UE(){try{const e=await ln(S(Et.cwd(),Ar));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${ri}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${ri}`):e}}const FE={value:0},ie=jE();let ii=Date.now();const ai=e=>2**e*500;async function ME(e){const t=Fi(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,an(S(F.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
59
|
+
`)}function GE(e){return e instanceof Eo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function ci(e,t){return e<wh&&GE(t)}async function li(e,t,n,o){const s={value:0},r=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?Sh:yh;return e.config.axios.post(r,{file:gi(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=>zE(i,ie,FE,s,ii)}).then(i=>(ie.increment(),i)).catch(async i=>{if(ci(o,i))return await si(ai(o)),li(e,t,n,o+1);throw ie.increment(),i})}function xE(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 li(n,t.url,o,0)})}function BE(e){const t=[...$E(e),...LE(e),...DE(e),...kE(e)];return xE(t)}async function ui(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?Oh:Th;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(ci(t,o))return await si(ai(t)),ui(e,t+1);throw o})}async function ZE(e){try{if(!jf.some(i=>V(S(F.cwd(),i))))throw new Error(We.INCORRECT_DISTRIBUTION_FOLDER(Pf));const t=e??Kn;f.info("Custom application deployment :: Started");const n=un.create({baseURL:t});Ui(n,Ih),f.info("Loading configuration files ...");const o=await Promise.all([Vt(),Jn(),UE()]).then(([i,a,c])=>({axios:n,app:{crane:i,packageJson:a,manifest:c}}));f.info("Uploading files ..."),ii=Date.now(),await Promise.all(BE(o)).catch(i=>{ie.stop(),i.response?.status===404?f.error(Le(i,We.DEPRECATED_VERSION_DEPLOYMENT)):f.error(Le(i,We.ASSET_FILES_UPLOAD)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()}),ie.update({speed:"N/A",status:"Finalising deployment"}),await ui(o).catch(i=>{ie.stop(),i.response?.status===404?f.error(Le(i,We.DEPRECATED_VERSION_DEPLOYMENT)):f.error(Le(i,We.MANIFEST_DEPLOYMENT)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()});const s=o.app.manifest.blocks.map(i=>i.id),r=o.app.packageJson.version;f.info("Custom application deployment :: Successful"),f.info(`Current app version: ${r}`),f.info(`Deployed sections: ${s.sort().join(", ")}`),await ME(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(Le(t,We.DEFAULT)),F.exit(1)}finally{NE()}}function HE(){process.env.CRANE_DEBUG_ENABLED="true"}function VE(){return process.env.CRANE_DEBUG_ENABLED==="true"}function WE(e,...t){VE()&&console.debug(wi(`[DEBUG] ${e}`),...t)}function YE(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,o)=>{e.moduleGraph.invalidateAll();const s=new Ai(t.url||"",`http://${t.headers.host}`);if(s.pathname==="/api/v1/block-config"&&t.method==="GET"){const r=s.searchParams.get("section");if(!r){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}try{const i=await qr(),a=(await ti(i)).blocks.find(c=>c.id===r);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 ke=null;function KE(){ke&&ke.clients.forEach(e=>{e.readyState===xi.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function JE(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 XE(e,t){const n=S(`${e}/shared/preview.ts`),o=S(`${e}/shared/utils.ts`),s=S(`${e}/shared/api-routes.ts`),r=S(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ge({build:{lib:{entry:o,formats:["es"],fileName:()=>"utils.js"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ge({build:{lib:{entry:s,formats:["es"],fileName:()=>"api-routes.js"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function QE(){const e="preview",t=`${e}/shared`,n="vite.config.js",o=`${e}/sections`,s=`${o}/preview.html`;[e,o].forEach(c=>{C.existsSync(c)||C.mkdirSync(c,{recursive:!0})});const r=Ee("template/preview");C.copyFileSync(`${r}/${n}`,`${e}/${n}`),await JE(r,e),C.copyFileSync(`${r}/sections/preview.html`,s);const i=`${r}/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 XE(r,t)}function qE(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function eg(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function tg(e){const t=(await ni()).find(o=>o.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await Qt(!0);return}const n=Xr(t);await Jr([n]),console.log(`Block ${e} rebuilt successfully`)}var ng=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(ng||{});function og(){return{timeout:null,inProgress:!1,pendingBuild:null}}function sg(e,t){const n=async o=>{e.inProgress=!0;try{o.type==="incremental"&&o.blockName?await tg(o.blockName):await Qt(!0),t.ws.send({type:"full-reload",path:"*"}),KE()}catch(s){console.error("Build error:",s)}finally{if(e.inProgress=!1,e.pendingBuild){const s=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(s),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 rg(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),o=t.match(/headers\/([^/]+)/),s=t.match(/footers\/([^/]+)/),r=t.match(/shared\//);return!!(n||o||s||r)}function ig(e,t){return async n=>{if(!rg(n))return;e.timeout&&clearTimeout(e.timeout);const o=qE(n),s=eg(n);e.timeout=setTimeout(async()=>{s?await t({type:"full"}):o&&await t({type:"incremental",blockName:o})},1e3)}}function ag(e,t){const n=og(),o=sg(n,e),s=ig(n,o);e.watcher.add(t),e.watcher.on("add",s),e.watcher.on("change",s),e.watcher.on("unlink",s)}async function cg(){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:s}=await n.startServer();return{server:o,port:s}}function lg(){ke=new Gi({port:0}),ke.on("listening",()=>{const e=ke?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function ug(){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/**/*"),s=z.resolve(process.cwd(),"shared/**/*"),r=await Ci({configFile:e,root:process.cwd(),plugins:[YE()]});return await r.listen(),ag(r,[t,n,o,s]),r}async function dg(){await Qt(),await QE(),console.log(`
|
|
60
60
|
\u{1F4E6} Starting preview servers...
|
|
61
|
-
`);let e=null,t=null;
|
|
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
|
|
63
|
-
The pulled source code uses ${o.length} ${
|
|
61
|
+
`);let e=null,t=null;WE("Starting SSR server");const n=await cg();e=n.server,t=n.port,process.env.PREVIEW_SSR_PORT=String(t),lg();const o=await ug(),s=()=>{e&&e.close(),ke&&ke.close(),o.close(),process.exit(0)};return process.on("SIGINT",s),process.on("SIGTERM",s),o}const pg=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,fg=/^[-a-zA-Z0-9_.^~<>=|* +]+$/;function di({name:e,version:t}){return pg.test(e)&&fg.test(t)}function tn(e){if(!V(e))return{dependencies:{},devDependencies:{},overrides:{}};let t;try{t=JSON.parse(sn(e,"utf-8"))}catch{return{dependencies:{},devDependencies:{},overrides:{}}}const n=t.overrides??{},o=Object.fromEntries(Object.entries(n).filter(s=>typeof s[1]=="string"));return{dependencies:t.dependencies??{},devDependencies:t.devDependencies??{},overrides:o}}function hg(e,t){const n=tn(ne(e,"package.json")),o=tn(ne(t,"package.json")),s={...o.dependencies,...o.devDependencies},r=[];for(const[i,a]of Object.entries(n.dependencies))s[i]||r.push({name:i,version:a,isDev:!1});for(const[i,a]of Object.entries(n.devDependencies))s[i]||r.push({name:i,version:a,isDev:!0});return r.sort((i,a)=>i.name.localeCompare(a.name))}function mg(e,t){const n=tn(ne(e,"package.json")).overrides,o=tn(ne(t,"package.json")).overrides;return Object.fromEntries(Object.entries(n).filter(([s,r])=>o[s]!==r))}function Eg(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 pi(e){return e.map(t=>`${t.name}@${t.version}`).join(" ")}function gg(e){const t=e.filter(s=>!s.isDev),n=e.filter(s=>s.isDev),o=[];return t.length>0&&o.push(`npm install ${pi(t)}`),n.length>0&&o.push(`npm install -D ${pi(n)}`),o}function _g(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:s}of n){if(s.length===0)continue;const r=[...o,...s];f.info(`Running: npm ${r.join(" ")}`);const i=Zi("npm",r,{cwd:t,stdio:"inherit"});if(i.status!==0)throw new Error(`npm ${o.join(" ")} exited with code ${i.status}`)}}async function yg(e,t){if(e.length===0)return;const n=e.filter(c=>!di(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(di);if(o.length===0)return;const s=o.length===1?"dependency":"dependencies";f.warn(`
|
|
63
|
+
The pulled source code uses ${o.length} ${s} not found in your project:`);const r=o.filter(c=>!c.isDev),i=o.filter(c=>c.isDev);if(r.length>0){f.warn(" dependencies:");for(const c of r)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=gg(o);switch((await Pe({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{_g(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=ne(t,"package.json"),l=JSON.parse(sn(c,"utf-8"));if(r.length>0){l.dependencies||(l.dependencies={});for(const d of r)l.dependencies[d.name]=d.version;l.dependencies=Object.fromEntries(Object.entries(l.dependencies).sort(([d],[m])=>d.localeCompare(m)))}if(i.length>0){l.devDependencies||(l.devDependencies={});for(const d of i)l.devDependencies[d.name]=d.version;l.devDependencies=Object.fromEntries(Object.entries(l.devDependencies).sort(([d],[m])=>d.localeCompare(m)))}an(c,`${JSON.stringify(l,null,2)}
|
|
64
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
|
|
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 Sg(e,t,n){const o=t.split("_").pop()??t,s=ne(e,"sections",o),r=ne(e,o);let i=null;if(V(s)&&Qe(s).isDirectory()?i=s:V(r)&&Qe(r).isDirectory()&&(i=r),i){const a=ne(n,o);V(a)&&((await Pe({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 Tg(e,t,n){const o=_i(ne(Bi.tmpdir(),"crane-source-"));new fo(Buffer.from(e)).extractAllTo(o,!0);try{const s=F.cwd(),r=ne(s,"sections");V(r)||yi(r,{recursive:!0}),await Sg(o,t,r);const i=ne(o,"shared");if(V(i)){const c=ne(s,"shared");f.info("Copying shared folder..."),await qt(i,c,!0)}const a=hg(o,s);await yg(a,s),Eg(mg(o,s)),f.info(`Source code for section [${n}] has been copied.`)}finally{co(o,{recursive:!0,force:!0})}}async function fi(e){const t=e??Kn,n=un.create({baseURL:t}),o=await Vt();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:o.appClientId},headers:{Authorization:`Bearer ${o.appSecretKey}`}})).data.sections]}async function Og(e,t){const n=(await fi(t)).find(o=>o.sectionId===e);return n||(f.error(`Section [${e}] not found in collection sections list.`),F.exit(1)),n}async function Ig(e,t,n){const o=n??Kn,s=un.create({baseURL:o}),r=await Vt();f.info(`Downloading source code for section [${e}]...`);const i=await s.get(`/api/v1/custom-apps/manifests/collections/sections/${e}/source-code`,{params:{appClientId:r.appClientId},headers:{Authorization:`Bearer ${r.appSecretKey}`},responseType:"arraybuffer"});await Tg(i.data,t,e)}async function wg(e){try{f.info("Fetching sections list...");const t=await fi(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(Le(t,"Error while fetching sections list")),F.exit(1)}}async function vg(e,t){try{const n=await Og(e,t);n.openSource||(f.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),F.exit(1)),await Ig(e,n.sectionId,t)}catch(n){f.error(Le(n,"Error while pulling section")),F.exit(1)}}async function Cg(e,t){const{list:n,section:o}=e;if(n){await wg(t);return}if(o){await vg(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 Rg={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},bg=["preview","build","deploy","pull"];function Ag(e,t){return bg.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function Ng(e){return e.includes("-h")||e.includes("--help")}function $g(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!Rg[e.rawName]?.includes(n))}function Lg(e){return e.length!==0}function Dg(e,t,n){return e.matchedCommand!==void 0&&(Ag(e.matchedCommand,n)||Ng(e.rawArgs)||$g(e.matchedCommand,e.options)||Lg(t))}function kg(e,t,n){e.matchedCommand&&!Dg(e,t,n)?e.runMatchedCommand():e.outputHelp()}function nn(e){if(Mf(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=Ff(e);return n&&console.log(n),t}async function io(e){const t=await Pe({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=z.basename(t.name);return nn(n)?n:io(e)}}async function Pg(e,t,n,o){const s=await io(t);return s===void 0?(console.log(`You can use ${n} to directly specify the name of the ${t}.`),e.outputHelp()):o(s)}async function Xe(e,t,n,o,s){if(s!==void 0)if(!nn(s))await Pg(e,t,n,o);else{const r=z.basename(s.toString());await o(r)}}function zg(){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 jg(e){const t=zg();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();nn(e)?f.warn(`Template [${e}] doesn't exist`):f.error(`[${e}] is an invalid template name.`)}const n=await Pe({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 Ug(e,t){if(typeof t=="string"||typeof t=="number"){if(nn(t))return t.toString();f.error(`${t} is invalid name.`)}return io(e)}async function Fg(e,t,n){const o=await jg(t),s=await Ug("page",n);if(s===void 0)return console.log(`You can use ${ce("init --page <name>")} to directly specify the name of the page.`),e.outputHelp();await CE(o,s)}async function Mg(e,t){try{const{app:n,section:o,header:s,footer:r,template:i,referenceTemplate:a,page:c,blank:l,collection:d}=e;await Xe(t,"app",ce("init --app <name>"),yE,n),await Xe(t,"section",ce(`init --section <name>${l?" --blank":""}`),m=>TE(m,l===!0),o),await Xe(t,"header",ce("init --header <name>"),vE,s),await Xe(t,"footer",ce("init --footer <name>"),wE,r),c===void 0?await Xe(t,"template",ce("init --template <name>"),AE,i):await Fg(t,i,c),await Xe(t,"collection",ce("init --collection <name>"),IE,d),a&&await RE()}catch(n){f.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function Gg(){try{const e=Ti("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=>Mg(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>Qt(!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&&HE(),await dg()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>ZE(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=>Cg(n,e.options.url)),e.version(Hi),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});kg(e,t.args,t.options)}catch(e){f.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{Gg as run};
|