@lightspeed/crane 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/UPGRADE.md +25 -0
- package/dist/cli.mjs +57 -34
- package/package.json +11 -13
- package/template/collections/example-collection/configuration.ts +6 -5
- package/template/eslint.config.js +1 -0
- package/template/footers/example-footer/component/MadeWith.vue +24 -8
- package/template/layouts/catalog/example-catalog/client.ts +6 -0
- package/template/layouts/category/example-category/client.ts +6 -0
- package/template/layouts/category/example-category/settings/translations.ts +1 -0
- package/template/layouts/product/example-product/client.ts +6 -0
- package/template/layouts/product/example-product/settings/translations.ts +1 -0
- package/template/package.json +1 -1
- package/template/preview/shared/api-routes.ts +27 -4
- package/template/preview/shared/mock.ts +9 -0
- package/template/preview/shared/preview.ts +3 -0
- package/template/preview/vite.config.js +4 -0
- package/template/reference/sections/tag-lines/TagLines.vue +6 -6
- package/template/eslint.config.cjs +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,58 +1,81 @@
|
|
|
1
|
-
import*as tn from"fs";import re,{existsSync as Ie,writeFileSync as ao,readFileSync as fa,createReadStream as ha,statSync as zt,promises as Kn,mkdtempSync as ma,mkdirSync as Ea,rmSync as co}from"fs";import*as rt from"path";import ue,{resolve as U,dirname as uo,relative as lo,basename as ga,sep as Yn,parse as po,join as dt}from"path";import _a from"cac";import{red as ya,yellow as Sa,green as Ke,gray as Ta}from"kolorist";import Gt from"prompts";import fo from"adm-zip";import{glob as z,globSync as ho}from"glob";import Ye from"typescript";import{normalizePath as Ra,build as ot,defineConfig as nn,createServer as Ca}from"vite";import{SectionTypeEnum as we,BackgroundStyleEnum as Xn,ButtonAppearanceEnum as Ia,ButtonSizeEnum as wa,ButtonShapeEnum as va,OverlayTypeEnum as rn,DesignEditorType as Ue,PluginTypeEnum as Ge,ConfigTypeEnum as le}from"@lightspeed/crane-api";import{readFile as mo}from"fs/promises";import{pathToFileURL as Eo,URL as Oa}from"url";import Qn,{AxiosError as go}from"axios";import*as ae from"process";import{ConcurrencyManager as Aa}from"axios-concurrency";import{inc as ba}from"semver";import{JSONPath as $a}from"jsonpath-plus";import Na from"tinycolor2";import La from"cli-progress";import{builtinModules as _o}from"module";import{viteExternalsPlugin as yo}from"vite-plugin-externals";import Da from"vite-plugin-compression";import ka from"@vitejs/plugin-vue";import Pa from"vite-tsconfig-paths";import xa from"vite-plugin-checker";import{encode as Ua}from"@jridgewell/sourcemap-codec";import{promisify as So}from"node:util";import To from"node:zlib";import fe from"node:fs";import Le from"node:path";import Te from"node:process";import Ro from"util";import{fileURLToPath as Ma}from"node:url";import{WebSocketServer as Fa,WebSocket as za}from"ws";import*as Ga from"os";const Ha="3.1.0",ie={[we.SECTION]:{source:"sections",dist:"dist/sections"},[we.HEADER]:{source:"headers",dist:"dist/headers"},[we.FOOTER]:{source:"footers",dist:"dist/footers"}};var te=(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))(te||{});const St={Server:0,Client:1,SectionSetting:2,SectionShowcase:3,SectionAsset:4,TemplateDescriptor:5,PageTemplateDescriptor:6,TemplateAsset:7,Layout:8,LayoutSettings:9,LayoutAsset:10,SlotServer:11,SlotClient:12,SharedTranslation:13},qn="https://blockbuster.ecwid.com",ja="/api/v1/custom-apps/resources/sections/upload",Ba="/api/v1/custom-apps/resources/templates/upload",Za="/api/v1/custom-apps/manifests/sections",Va="/api/v1/custom-apps/manifests/templates",Wa=5,Ka=3,Ya=[te.Server,te.Client,te.ClientChunks,te.ClientAsset,te.Asset],Xa=[te.LayoutClient,te.LayoutAsset],Qa=[te.SlotServer,te.SlotClient,te.SlotClientChunks,te.SlotClientAsset],qa=[te.Dependency,te.TemplateAsset,te.SourceCode,te.CollectionAsset],Tt={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.`},Co={catalog:"products",category:"category",product:"product"},Ja=e=>Co[e],Io=e=>e in Co,N={error:e=>console.log(ya(e)),warn:e=>console.log(Sa(e)),info:e=>console.log(Ke(e))},ec="dist",tc="dist/shared",Ae="dist/sections",Ht="dist/headers",jt="dist/footers",He="dist/templates",Rt="layouts",wo="preview",ve=`dist/${Rt}`,on="dist/collections",nc=[Ae,Ht,jt,He,ve];function sn(e){return!!e}function ft(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const rc="Resource name can only contain alphanumeric characters, dashes, and underscores";function oc(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:rc}}function sc(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function vo(e){return ue.parse(e).name}function ic(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function an(){const e=await mo(U(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function ac(e){return e.includes(`
|
|
2
|
-
`)}function cc(e,t,n){return e.split(`
|
|
3
|
-
`).map((r,o)=>o>=n?t+r:r).join(`
|
|
4
|
-
`)}function ht(e,t){const n=[];if(e instanceof go){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const i=e.response?.data;if(i?.errorCode&&n.push(` Error Code: ${i.errorCode}`),i?.errorMessage){const s=ac(i.errorMessage)?cc(i.errorMessage," ",1):i.errorMessage;n.push(` Error Message: ${s}`)}}const r=n.length>0?n.join(`
|
|
5
|
-
`):e?.message??"Unknown error";if(!t||t.length===0)return r;const o=n.length>0?`
|
|
6
|
-
`:" ";return`${t}${o}${r}`}function uc(e){return e.replace(/\\/g,"/")}function lc(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Ct(e){return lc(uc(e))}function pc(e){const t=Ct(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t;if(!Io(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const o=Ja(n);return{id:r,sectionId:n,pageId:o}}const dc={catalog:"products",category:"category",product:"product"};async function fc(e){const t=Ct(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t;return{id:r,sectionId:n}}async function hc(e){return Promise.all(e.map(async t=>{const n=t.sectionId,r=dc[n];return{id:t.id,sectionId:n,pageId:r}}))}async function mc(){const e=`${ve}/{product,catalog,category}/*`,t=await z(e,{ignore:["node_modules/**"]});return Promise.all(t.map(fc))}async function Ec(){const e=await mc();return await hc(e)}function It(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${ve}/${e}/${t}/${n.join("/")}`}const Bt=(e=we.SECTION)=>ie[e].dist,Zt={[te.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${Bt(t)}/${e}/js/main/server/`},[te.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${Bt(t)}/${e}/js/main/client/`},[te.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${Bt(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[te.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${Bt(t)}/${e}/js/main/client/assets/`},[te.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${Bt(t)}/${e}/assets/`},[te.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${He}/assets/`},[te.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[te.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[te.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>It(e,t,"")},[te.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>It(e,t,"assets/")},[te.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>It(e,t,"slots",n,"js/main/server/")},[te.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>It(e,t,"slots",n,"js/main/client/")},[te.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>It(e,t,"slots",n,"js/main/client/chunks/")},[te.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>It(e,t,"slots",n,"js/main/client/assets/")},[te.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${on}/assets/`}};function wt(e){const t={};for(const[n,r]of Object.entries(e)){let o={...r};if(r.type==="DECK"&&r.cards&&typeof r.cards=="object"&&"defaultCardContent"in r.cards){const i=r.cards;i.defaultCardContent?.settings&&(o={...o,cards:{...i,defaultCardContent:{...i.defaultCardContent,settings:wt(i.defaultCardContent.settings)}}})}if(r.type==="ACCORDION"&&r.cards&&typeof r.cards=="object"&&!("defaultCardContent"in r.cards)){const i=r.cards,s={};for(const[a,c]of Object.entries(i))c.editors?s[a]={...c,editors:wt(c.editors)}:s[a]=c;o={...o,cards:s}}if(o.defaults&&typeof o.defaults=="object"&&!("type"in o.defaults)){const i=Object.assign({type:o.type},o.defaults);o={...o,defaults:i}}t[n]=o}return t}function f(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,l=Object.keys(u);for(let h=0;h<l.length;h++){const d=l[h];d in a||(a[d]=u[d].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class vt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Oo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Jn={};function st(e){return e&&Object.assign(Jn,e),Jn}function gc(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function er(e,t){return typeof t=="bigint"?t.toString():t}function cn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function tr(e){return e==null}function nr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _c(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}const Ao=Symbol("evaluating");function se(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ao)return r===void 0&&(r=Ao,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function mt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Et(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function bo(e){return JSON.stringify(e)}function yc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const $o="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Sc=cn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ot(e){if(Vt(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Vt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function No(e){return Ot(e)?{...e}:Array.isArray(e)?[...e]:e}const Tc=new Set(["string","number","symbol"]);function At(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ct(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Rc(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Cc={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 Ic(e,t){const n=e._zod.def,r=Et(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return mt(this,"shape",o),o},checks:[]});return ct(e,r)}function wc(e,t){const n=e._zod.def,r=Et(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return mt(this,"shape",o),o},checks:[]});return ct(e,r)}function vc(e,t){if(!Ot(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=Et(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return mt(this,"shape",i),i},checks:[]});return ct(e,o)}function Oc(e,t){if(!Ot(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return mt(this,"shape",r),r},checks:e._zod.def.checks};return ct(e,n)}function Ac(e,t){const n=Et(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return mt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return ct(e,n)}function bc(e,t,n){const r=Et(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:o[s]}):o[s])}else for(const s in o)i[s]=e?new e({type:"optional",innerType:o[s]}):o[s];return mt(this,"shape",i),i},checks:[]});return ct(t,r)}function $c(e,t,n){const r=Et(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return mt(this,"shape",i),i},checks:[]});return ct(t,r)}function bt(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 $t(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function un(e){return typeof e=="string"?e:e?.message}function ut(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=un(e.inst?._zod.def?.error?.(e))??un(t?.error?.(e))??un(n.customError?.(e))??un(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function rr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Wt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Lo=(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,er,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Do=f("$ZodError",Lo),ko=f("$ZodError",Lo,{Parent:Error});function Nc(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Lc(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){const c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return r(e),n}const or=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new vt;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>ut(c,i,st())));throw $o(a,o?.callee),a}return s.value},sr=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>ut(c,i,st())));throw $o(a,o?.callee),a}return s.value},ln=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new vt;return i.issues.length?{success:!1,error:new(e??Do)(i.issues.map(s=>ut(s,o,st())))}:{success:!0,data:i.value}},Dc=ln(ko),pn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>ut(s,o,st())))}:{success:!0,data:i.value}},kc=pn(ko),Pc=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return or(e)(t,n,o)},xc=e=>(t,n,r)=>or(e)(t,n,r),Uc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return sr(e)(t,n,o)},Mc=e=>async(t,n,r)=>sr(e)(t,n,r),Fc=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ln(e)(t,n,o)},zc=e=>(t,n,r)=>ln(e)(t,n,r),Gc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return pn(e)(t,n,o)},Hc=e=>async(t,n,r)=>pn(e)(t,n,r),jc=/^[cC][^\s-]{8,}$/,Bc=/^[0-9a-z]+$/,Zc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vc=/^[0-9a-vA-V]{20}$/,Wc=/^[A-Za-z0-9]{27}$/,Kc=/^[a-zA-Z0-9_-]{21}$/,Yc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Xc=/^([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})$/,Po=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)$/,Qc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Jc(){return new RegExp(qc,"u")}const eu=/^(?:(?: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])$/,tu=/^(([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}|:))$/,nu=/^((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])$/,ru=/^(([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])$/,ou=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xo=/^[A-Za-z0-9_-]*$/,su=/^\+(?:[0-9]){6,14}[0-9]$/,Uo="(?:(?:\\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])))",iu=new RegExp(`^${Uo}$`);function Mo(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 au(e){return new RegExp(`^${Mo(e)}$`)}function cu(e){const t=Mo({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Uo}T(?:${r})$`)}const uu=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},lu=/^-?\d+$/,pu=/^-?\d+(?:\.\d+)?/,du=/^(?:true|false)$/i,fu=/^[^A-Z]*$/,hu=/^[^a-z]*$/,De=f("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Fo={number:"number",bigint:"bigint",object:"date"},zo=f("$ZodCheckLessThan",(e,t)=>{De.init(e,t);const n=Fo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Go=f("$ZodCheckGreaterThan",(e,t)=>{De.init(e,t);const n=Fo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mu=f("$ZodCheckMultipleOf",(e,t)=>{De.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):_c(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})}}),Eu=f("$ZodCheckNumberFormat",(e,t)=>{De.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Cc[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=lu)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inst:e})}}),gu=f("$ZodCheckMaxLength",(e,t)=>{var n;De.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!tr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const s=rr(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),_u=f("$ZodCheckMinLength",(e,t)=>{var n;De.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!tr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const s=rr(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),yu=f("$ZodCheckLengthEquals",(e,t)=>{var n;De.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!tr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=rr(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),dn=f("$ZodCheckStringFormat",(e,t)=>{var n,r;De.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Su=f("$ZodCheckRegex",(e,t)=>{dn.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})}}),Tu=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fu),dn.init(e,t)}),Ru=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hu),dn.init(e,t)}),Cu=f("$ZodCheckIncludes",(e,t)=>{De.init(e,t);const n=At(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Iu=f("$ZodCheckStartsWith",(e,t)=>{De.init(e,t);const n=new RegExp(`^${At(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),wu=f("$ZodCheckEndsWith",(e,t)=>{De.init(e,t);const n=new RegExp(`.*${At(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),vu=f("$ZodCheckOverwrite",(e,t)=>{De.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Ou{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
1
|
+
import*as un from"fs";import ie,{existsSync as $e,readFileSync as nr,statSync as Vt,promises as rr,writeFileSync as or,createReadStream as xa,mkdtempSync as za,mkdirSync as Ma,rmSync as Co}from"fs";import*as ln from"path";import le,{resolve as j,dirname as wo,relative as Io,basename as Ua,sep as sr,parse as Ao,join as He}from"path";import ja from"cac";import{green as Qe,yellow as Fa,red as Ga,gray as Ha}from"kolorist";import At from"prompts";import bo from"adm-zip";import{glob as W,globSync as $o}from"glob";import qe from"typescript";import{normalizePath as Ba,build as ct,defineConfig as pn,createServer as Za}from"vite";import{SectionTypeEnum as ut,BackgroundStyleEnum as ir,ButtonAppearanceEnum as Va,ButtonSizeEnum as Wa,ButtonShapeEnum as Ka,OverlayTypeEnum as fn,DesignEditorType as Me,PluginTypeEnum as Be,ConfigTypeEnum as pe}from"@lightspeed/crane-api";import*as Oe from"process";import dn from"process";import{JSONPath as Ya}from"jsonpath-plus";import{readFile as ar,writeFile as Xa}from"fs/promises";import{pathToFileURL as No,URL as Qa}from"url";import cr,{AxiosError as Lo}from"axios";import qa from"tinycolor2";import{builtinModules as Do}from"module";import{viteExternalsPlugin as ko}from"vite-plugin-externals";import Ja from"vite-plugin-compression";import ec from"@vitejs/plugin-vue";import tc from"vite-tsconfig-paths";import nc from"vite-plugin-checker";import{encode as rc}from"@jridgewell/sourcemap-codec";import{promisify as Po}from"node:util";import xo from"node:zlib";import he from"node:fs";import Ne from"node:path";import Se from"node:process";import zo from"util";import{fileURLToPath as oc}from"node:url";import{ConcurrencyManager as sc}from"axios-concurrency";import{inc as ic}from"semver";import ac from"cli-progress";import{WebSocketServer as cc,WebSocket as uc}from"ws";import*as lc from"os";import{spawnSync as pc}from"child_process";const fc="3.2.1",we={[ut.SECTION]:{source:"sections",dist:"dist/sections"},[ut.HEADER]:{source:"headers",dist:"dist/headers"},[ut.FOOTER]:{source:"footers",dist:"dist/footers"}};var ee=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientChunks=2]="ClientChunks",e[e.ClientAsset=3]="ClientAsset",e[e.Asset=4]="Asset",e[e.TemplateAsset=5]="TemplateAsset",e[e.Dependency=6]="Dependency",e[e.SourceCode=7]="SourceCode",e[e.LayoutClient=8]="LayoutClient",e[e.LayoutAsset=9]="LayoutAsset",e[e.SlotServer=10]="SlotServer",e[e.SlotClient=11]="SlotClient",e[e.SlotClientChunks=12]="SlotClientChunks",e[e.SlotClientAsset=13]="SlotClientAsset",e[e.CollectionAsset=14]="CollectionAsset",e))(ee||{});function bt(e){const t={};for(const[n,r]of Object.entries(e)){let o={...r};if(r.type==="DECK"&&r.cards&&typeof r.cards=="object"&&"defaultCardContent"in r.cards){const i=r.cards;i.defaultCardContent?.settings&&(o={...o,cards:{...i,defaultCardContent:{...i.defaultCardContent,settings:bt(i.defaultCardContent.settings)}}})}if(r.type==="ACCORDION"&&r.cards&&typeof r.cards=="object"&&!("defaultCardContent"in r.cards)){const i=r.cards,s={};for(const[a,c]of Object.entries(i))c.editors?s[a]={...c,editors:bt(c.editors)}:s[a]=c;o={...o,cards:s}}if(o.defaults&&typeof o.defaults=="object"&&!("type"in o.defaults)){const i=Object.assign({type:o.type},o.defaults);o={...o,defaults:i}}t[n]=o}return t}function g(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,f=Object.keys(u);for(let h=0;h<f.length;h++){const T=f[h];T in a||(a[T]=u[T].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class $t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ur={};function lt(e){return e&&Object.assign(ur,e),ur}function Uo(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function lr(e,t){return typeof t=="bigint"?t.toString():t}function hn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function pr(e){return e==null}function fr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dc(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}const jo=Symbol("evaluating");function ne(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jo)return r===void 0&&(r=jo,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Rt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gt(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Fo(e){return JSON.stringify(e)}function hc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Go="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const mc=hn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Nt(e){if(Wt(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Wt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ho(e){return Nt(e)?{...e}:Array.isArray(e)?[...e]:e}const gc=new Set(["string","number","symbol"]);function Lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Et(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ec(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const _c={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function yc(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=gt(e._zod.def,{get shape(){const s={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return Rt(this,"shape",s),s},checks:[]});return Et(e,i)}function Sc(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=gt(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Rt(this,"shape",s),s},checks:[]});return Et(e,i)}function Tc(e,t){if(!Nt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=gt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Rt(this,"shape",i),i}});return Et(e,o)}function Rc(e,t){if(!Nt(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Rt(this,"shape",r),r}});return Et(e,n)}function Oc(e,t){const n=gt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Rt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Et(e,n)}function vc(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=gt(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Rt(this,"shape",c),c},checks:[]});return Et(t,s)}function Cc(e,t,n){const r=gt(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return Rt(this,"shape",i),i}});return Et(t,r)}function Dt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function kt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function mn(e){return typeof e=="string"?e:e?.message}function _t(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=mn(e.inst?._zod.def?.error?.(e))??mn(t?.error?.(e))??mn(n.customError?.(e))??mn(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function dr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Kt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Bo=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,lr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zo=g("$ZodError",Bo),Vo=g("$ZodError",Bo,{Parent:Error});function wc(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Ic(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){const c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return r(e),n}const hr=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new $t;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>_t(c,i,lt())));throw Go(a,o?.callee),a}return s.value},mr=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>_t(c,i,lt())));throw Go(a,o?.callee),a}return s.value},gn=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new $t;return i.issues.length?{success:!1,error:new(e??Zo)(i.issues.map(s=>_t(s,o,lt())))}:{success:!0,data:i.value}},Ac=gn(Vo),En=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>_t(s,o,lt())))}:{success:!0,data:i.value}},bc=En(Vo),$c=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return hr(e)(t,n,o)},Nc=e=>(t,n,r)=>hr(e)(t,n,r),Lc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return mr(e)(t,n,o)},Dc=e=>async(t,n,r)=>mr(e)(t,n,r),kc=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,o)},Pc=e=>(t,n,r)=>gn(e)(t,n,r),xc=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,o)},zc=e=>async(t,n,r)=>En(e)(t,n,r),Mc=/^[cC][^\s-]{8,}$/,Uc=/^[0-9a-z]+$/,jc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fc=/^[0-9a-vA-V]{20}$/,Gc=/^[A-Za-z0-9]{27}$/,Hc=/^[a-zA-Z0-9_-]{21}$/,Bc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Wo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Vc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Wc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Kc(){return new RegExp(Wc,"u")}const Yc=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Qc=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,qc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Jc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ko=/^[A-Za-z0-9_-]*$/,eu=/^\+[1-9]\d{6,14}$/,Yo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",tu=new RegExp(`^${Yo}$`);function Xo(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function nu(e){return new RegExp(`^${Xo(e)}$`)}function ru(e){const t=Xo({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Yo}T(?:${r})$`)}const ou=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},su=/^-?\d+$/,Qo=/^-?\d+(?:\.\d+)?$/,iu=/^(?:true|false)$/i,au=/^[^A-Z]*$/,cu=/^[^a-z]*$/,Pe=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qo={number:"number",bigint:"bigint",object:"date"},Jo=g("$ZodCheckLessThan",(e,t)=>{Pe.init(e,t);const n=qo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),es=g("$ZodCheckGreaterThan",(e,t)=>{Pe.init(e,t);const n=qo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uu=g("$ZodCheckMultipleOf",(e,t)=>{Pe.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):dc(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),lu=g("$ZodCheckNumberFormat",(e,t)=>{Pe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=_c[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=su)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),pu=g("$ZodCheckMaxLength",(e,t)=>{var n;Pe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!pr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const s=dr(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fu=g("$ZodCheckMinLength",(e,t)=>{var n;Pe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!pr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const s=dr(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),du=g("$ZodCheckLengthEquals",(e,t)=>{var n;Pe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!pr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=dr(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),_n=g("$ZodCheckStringFormat",(e,t)=>{var n,r;Pe.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hu=g("$ZodCheckRegex",(e,t)=>{_n.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),mu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=au),_n.init(e,t)}),gu=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cu),_n.init(e,t)}),Eu=g("$ZodCheckIncludes",(e,t)=>{Pe.init(e,t);const n=Lt(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),_u=g("$ZodCheckStartsWith",(e,t)=>{Pe.init(e,t);const n=new RegExp(`^${Lt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),yu=g("$ZodCheckEndsWith",(e,t)=>{Pe.init(e,t);const n=new RegExp(`.*${Lt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Su=g("$ZodCheckOverwrite",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Tu{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
7
2
|
`).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
|
|
8
|
-
`))}}const
|
|
9
|
-
if (${
|
|
10
|
-
|
|
3
|
+
`))}}const Ru={major:4,minor:3,patch:6},me=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ru;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,c)=>{let u=Dt(s),f;for(const h of a){if(h._zod.def.when){if(!h._zod.def.when(s))continue}else if(u)continue;const T=s.issues.length,w=h._zod.check(s);if(w instanceof Promise&&c?.async===!1)throw new $t;if(f||w instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await w,s.issues.length!==T&&(u||(u=Dt(s,T)))});else{if(s.issues.length===T)continue;u||(u=Dt(s,T))}}return f?f.then(()=>s):s},i=(s,a,c)=>{if(Dt(s))return s.aborted=!0,s;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new $t;return u.then(f=>e._zod.parse(f,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(f=>i(f,s,a)):i(u,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new $t;return c.then(u=>o(u,r,a))}return o(c,r,a)}}ne(e,"~standard",()=>({validate:o=>{try{const i=Ac(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return bc(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),gr=g("$ZodString",(e,t)=>{me.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ou(e._zod.bag),e._zod.parse=(n,r)=>{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}}),fe=g("$ZodStringFormat",(e,t)=>{_n.init(e,t),gr.init(e,t)}),Ou=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Zc),fe.init(e,t)}),vu=g("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wo(r))}else t.pattern??(t.pattern=Wo());fe.init(e,t)}),Cu=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Vc),fe.init(e,t)}),wu=g("$ZodURL",(e,t)=>{fe.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.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=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Iu=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Kc()),fe.init(e,t)}),Au=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Hc),fe.init(e,t)}),bu=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Mc),fe.init(e,t)}),$u=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Uc),fe.init(e,t)}),Nu=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=jc),fe.init(e,t)}),Lu=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fc),fe.init(e,t)}),Du=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Gc),fe.init(e,t)}),ku=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ru(t)),fe.init(e,t)}),Pu=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=tu),fe.init(e,t)}),xu=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=nu(t)),fe.init(e,t)}),zu=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bc),fe.init(e,t)}),Mu=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yc),fe.init(e,t),e._zod.bag.format="ipv4"}),Uu=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xc),fe.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})}}}),ju=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qc),fe.init(e,t)}),Fu=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=qc),fe.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ts(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Gu=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Jc),fe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ts(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Hu(e){if(!Ko.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ts(n)}const Bu=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ko),fe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Hu(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Zu=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=eu),fe.init(e,t)});function Vu(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Wu=g("$ZodJWT",(e,t)=>{fe.init(e,t),e._zod.check=n=>{Vu(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ns=g("$ZodNumber",(e,t)=>{me.init(e,t),e._zod.pattern=e._zod.bag.pattern??Qo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Ku=g("$ZodNumberFormat",(e,t)=>{lu.init(e,t),ns.init(e,t)}),Yu=g("$ZodBoolean",(e,t)=>{me.init(e,t),e._zod.pattern=iu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Xu=g("$ZodUnknown",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),Qu=g("$ZodNever",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function rs(e,t,n){e.issues.length&&t.issues.push(...kt(n,e.issues)),t.value[n]=e.value}const qu=g("$ZodArray",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(u=>rs(u,n,s))):rs(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function yn(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...kt(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function os(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Ec(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ss(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,f=c.optout==="optional";for(const h in t){if(a.has(h))continue;if(u==="never"){s.push(h);continue}const T=c.run({value:t[h],issues:[]},r);T instanceof Promise?e.push(T.then(w=>yn(w,n,h,t,f))):yn(T,n,h,t,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Ju=g("$ZodObject",(e,t)=>{if(me.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 r=hn(()=>os(t));ne(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const f=a[u]._zod;if(f.values){c[u]??(c[u]=new Set);for(const h of f.values)c[u].add(h)}}return c});const o=Wt,i=t.catchall;let s;e._zod.parse=(a,c)=>{s??(s=r.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const f=[],h=s.shape;for(const T of s.keys){const w=h[T],k=w._zod.optout==="optional",M=w._zod.run({value:u[T],issues:[]},c);M instanceof Promise?f.push(M.then(b=>yn(b,a,T,u,k))):yn(M,a,T,u,k)}return i?ss(f,u,a,c,r.value,e):f.length?Promise.all(f).then(()=>a):a}}),el=g("$ZodObjectJIT",(e,t)=>{Ju.init(e,t);const n=e._zod.parse,r=hn(()=>os(t)),o=T=>{const w=new Tu(["shape","payload","ctx"]),k=r.value,M=p=>{const l=Fo(p);return`shape[${l}]._zod.run({ value: input[${l}], issues: [] }, ctx)`};w.write("const input = payload.value;");const b=Object.create(null);let v=0;for(const p of k.keys)b[p]=`key_${v++}`;w.write("const newResult = {};");for(const p of k.keys){const l=b[p],d=Fo(p),m=T[p]?._zod?.optout==="optional";w.write(`const ${l} = ${M(p)};`),m?w.write(`
|
|
4
|
+
if (${l}.issues.length) {
|
|
5
|
+
if (${d} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${l}.issues.map(iss => ({
|
|
7
|
+
...iss,
|
|
8
|
+
path: iss.path ? [${d}, ...iss.path] : [${d}]
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (${l}.value === undefined) {
|
|
14
|
+
if (${d} in input) {
|
|
15
|
+
newResult[${d}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
newResult[${d}] = ${l}.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
`):w.write(`
|
|
22
|
+
if (${l}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${l}.issues.map(iss => ({
|
|
11
24
|
...iss,
|
|
12
|
-
path: iss.path ? [${
|
|
25
|
+
path: iss.path ? [${d}, ...iss.path] : [${d}]
|
|
13
26
|
})));
|
|
14
27
|
}
|
|
15
28
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
newResult[${m}] = undefined;
|
|
29
|
+
if (${l}.value === undefined) {
|
|
30
|
+
if (${d} in input) {
|
|
31
|
+
newResult[${d}] = undefined;
|
|
20
32
|
}
|
|
21
33
|
} else {
|
|
22
|
-
newResult[${
|
|
34
|
+
newResult[${d}] = ${l}.value;
|
|
23
35
|
}
|
|
24
36
|
|
|
25
|
-
`)}b.write("payload.value = newResult;"),b.write("return payload;");const k=b.compile();return(p,S)=>k(d,p,S)};let i;const s=Vt,a=!Jn.jitless,u=a&&Sc.value,l=t.catchall;let h;e._zod.parse=(d,b)=>{h??(h=r.value);const A=d.value;return s(A)?a&&u&&b?.async===!1&&b.jitless!==!0?(i||(i=o(t.shape)),d=i(d,b),l?Vo([],A,d,b,h,e):d):n(d,b):(d.issues.push({expected:"object",code:"invalid_type",input:A,inst:e}),d)}});function Wo(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!bt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>ut(s,r,st())))}),t)}const Ko=f("$ZodUnion",(e,t)=>{he.init(e,t),se(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),se(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),se(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),se(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>nr(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>Wo(c,o,e,i)):Wo(a,o,e,i)}}),al=f("$ZodDiscriminatedUnion",(e,t)=>{Ko.init(e,t);const n=e._zod.parse;se(e._zod,"propValues",()=>{const o={};for(const i of t.options){const s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,c]of Object.entries(s)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const r=cn(()=>{const o=t.options,i=new Map;for(const s of o){const a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const c of a){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(o,i)=>{const s=o.value;if(!Vt(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),cl=f("$ZodIntersection",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Yo(n,c,u)):Yo(n,i,s)}});function ar(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(Ot(e)&&Ot(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=ar(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=ar(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yo(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),bt(e))return e;const r=ar(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const ul=f("$ZodRecord",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Ot(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const l=t.valueType._zod.run({value:o[u],issues:[]},r);l instanceof Promise?i.push(l.then(h=>{h.issues.length&&n.issues.push(...$t(u,h.issues)),n.value[u]=h.value})):(l.issues.length&&n.issues.push(...$t(u,l.issues)),n.value[u]=l.value)}let c;for(const u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if(a==="__proto__")continue;const c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(c.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(l=>ut(l,r,st())),input:a,path:[a],inst:e}),n.value[c.value]=c.value;continue}const u=t.valueType._zod.run({value:o[a],issues:[]},r);u instanceof Promise?i.push(u.then(l=>{l.issues.length&&n.issues.push(...$t(a,l.issues)),n.value[c.value]=l.value})):(u.issues.length&&n.issues.push(...$t(a,u.issues)),n.value[c.value]=u.value)}}return i.length?Promise.all(i).then(()=>n):n}}),ll=f("$ZodEnum",(e,t)=>{he.init(e,t);const n=gc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Tc.has(typeof o)).map(o=>typeof o=="string"?At(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),pl=f("$ZodLiteral",(e,t)=>{if(he.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?At(r):r?At(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),dl=f("$ZodTransform",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Oo(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new vt;return n.value=o,n}});function Xo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const fl=f("$ZodOptional",(e,t)=>{he.init(e,t),e._zod.optin="optional",e._zod.optout="optional",se(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),se(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${nr(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Xo(i,n.value)):Xo(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),hl=f("$ZodNullable",(e,t)=>{he.init(e,t),se(e._zod,"optin",()=>t.innerType._zod.optin),se(e._zod,"optout",()=>t.innerType._zod.optout),se(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${nr(n.source)}|null)$`):void 0}),se(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),ml=f("$ZodDefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",se(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Qo(i,t)):Qo(o,t)}});function Qo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const El=f("$ZodPrefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",se(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),gl=f("$ZodNonOptional",(e,t)=>{he.init(e,t),se(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>qo(i,e)):qo(o,e)}});function qo(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 _l=f("$ZodCatch",(e,t)=>{he.init(e,t),se(e._zod,"optin",()=>t.innerType._zod.optin),se(e._zod,"optout",()=>t.innerType._zod.optout),se(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>ut(s,r,st()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>ut(i,r,st()))},input:n.value}),n.issues=[]),n)}}),yl=f("$ZodPipe",(e,t)=>{he.init(e,t),se(e._zod,"values",()=>t.in._zod.values),se(e._zod,"optin",()=>t.in._zod.optin),se(e._zod,"optout",()=>t.out._zod.optout),se(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>hn(s,t.in,r)):hn(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>hn(i,t.out,r)):hn(o,t.out,r)}});function hn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Sl=f("$ZodReadonly",(e,t)=>{he.init(e,t),se(e._zod,"propValues",()=>t.innerType._zod.propValues),se(e._zod,"values",()=>t.innerType._zod.values),se(e._zod,"optin",()=>t.innerType?._zod?.optin),se(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Jo):Jo(o)}});function Jo(e){return e.value=Object.freeze(e.value),e}const Tl=f("$ZodCustom",(e,t)=>{De.init(e,t),he.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>es(i,n,r,e));es(o,n,r,e)}});function es(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Wt(o))}}var ts;class Rl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Cl(){return new Rl}(ts=globalThis).__zod_globalRegistry??(ts.__zod_globalRegistry=Cl());const mn=globalThis.__zod_globalRegistry;function Il(e,t){return new e({type:"string",...x(t)})}function wl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function ns(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function vl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function Ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function Al(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function bl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function rs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function $l(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function Nl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function Ll(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function Dl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function kl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function Pl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function xl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function Ul(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function Ml(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function Fl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function zl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function Gl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function Hl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function jl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function Bl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function Zl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function Vl(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function Wl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function Kl(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function Yl(e,t){return new e({type:"number",checks:[],...x(t)})}function Xl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function Ql(e,t){return new e({type:"boolean",...x(t)})}function ql(e){return new e({type:"unknown"})}function Jl(e,t){return new e({type:"never",...x(t)})}function os(e,t){return new zo({check:"less_than",...x(t),value:e,inclusive:!1})}function cr(e,t){return new zo({check:"less_than",...x(t),value:e,inclusive:!0})}function ss(e,t){return new Go({check:"greater_than",...x(t),value:e,inclusive:!1})}function ur(e,t){return new Go({check:"greater_than",...x(t),value:e,inclusive:!0})}function is(e,t){return new mu({check:"multiple_of",...x(t),value:e})}function as(e,t){return new gu({check:"max_length",...x(t),maximum:e})}function En(e,t){return new _u({check:"min_length",...x(t),minimum:e})}function cs(e,t){return new yu({check:"length_equals",...x(t),length:e})}function ep(e,t){return new Su({check:"string_format",format:"regex",...x(t),pattern:e})}function tp(e){return new Tu({check:"string_format",format:"lowercase",...x(e)})}function np(e){return new Ru({check:"string_format",format:"uppercase",...x(e)})}function rp(e,t){return new Cu({check:"string_format",format:"includes",...x(t),includes:e})}function op(e,t){return new Iu({check:"string_format",format:"starts_with",...x(t),prefix:e})}function sp(e,t){return new wu({check:"string_format",format:"ends_with",...x(t),suffix:e})}function Nt(e){return new vu({check:"overwrite",tx:e})}function ip(e){return Nt(t=>t.normalize(e))}function ap(){return Nt(e=>e.trim())}function cp(){return Nt(e=>e.toLowerCase())}function up(){return Nt(e=>e.toUpperCase())}function lp(){return Nt(e=>yc(e))}function pp(e,t,n){return new e({type:"array",element:t,...x(n)})}function dp(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}function fp(e){const t=hp(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Wt(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Wt(o))}},e(n.value,n)));return t}function hp(e,t){const n=new De({check:"custom",...x(t)});return n._zod.check=e,n}const mp=f("ZodISODateTime",(e,t)=>{zu.init(e,t),me.init(e,t)});function Ep(e){return Zl(mp,e)}const gp=f("ZodISODate",(e,t)=>{Gu.init(e,t),me.init(e,t)});function _p(e){return Vl(gp,e)}const yp=f("ZodISOTime",(e,t)=>{Hu.init(e,t),me.init(e,t)});function Sp(e){return Wl(yp,e)}const Tp=f("ZodISODuration",(e,t)=>{ju.init(e,t),me.init(e,t)});function Rp(e){return Kl(Tp,e)}const Cp=(e,t)=>{Do.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Lc(e,n)},flatten:{value:n=>Nc(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,er,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,er,2)}},isEmpty:{get(){return e.issues.length===0}}})},je=f("ZodError",Cp,{Parent:Error}),Ip=or(je),wp=sr(je),vp=ln(je),Op=pn(je),Ap=Pc(je),bp=xc(je),$p=Uc(je),Np=Mc(je),Lp=Fc(je),Dp=zc(je),kp=Gc(je),Pp=Hc(je),ge=f("ZodType",(e,t)=>(he.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Et(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>ct(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Ip(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>vp(e,n,r),e.parseAsync=async(n,r)=>wp(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Op(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Ap(e,n,r),e.decode=(n,r)=>bp(e,n,r),e.encodeAsync=async(n,r)=>$p(e,n,r),e.decodeAsync=async(n,r)=>Np(e,n,r),e.safeEncode=(n,r)=>Lp(e,n,r),e.safeDecode=(n,r)=>Dp(e,n,r),e.safeEncodeAsync=async(n,r)=>kp(e,n,r),e.safeDecodeAsync=async(n,r)=>Pp(e,n,r),e.refine=(n,r)=>e.check(wd(n,r)),e.superRefine=n=>e.check(vd(n)),e.overwrite=n=>e.check(Nt(n)),e.optional=()=>Es(e),e.nullable=()=>gs(e),e.nullish=()=>Es(gs(e)),e.nonoptional=n=>_d(e,n),e.array=()=>oe(e),e.or=n=>Lt([e,n]),e.and=n=>cd(e,n),e.transform=n=>ys(e,dd(n)),e.default=n=>md(e,n),e.prefault=n=>gd(e,n),e.catch=n=>Sd(e,n),e.pipe=n=>ys(e,n),e.readonly=()=>Cd(e),e.describe=n=>{const r=e.clone();return mn.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return mn.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return mn.get(e);const r=e.clone();return mn.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),us=f("_ZodString",(e,t)=>{ir.init(e,t),ge.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(ep(...r)),e.includes=(...r)=>e.check(rp(...r)),e.startsWith=(...r)=>e.check(op(...r)),e.endsWith=(...r)=>e.check(sp(...r)),e.min=(...r)=>e.check(En(...r)),e.max=(...r)=>e.check(as(...r)),e.length=(...r)=>e.check(cs(...r)),e.nonempty=(...r)=>e.check(En(1,...r)),e.lowercase=r=>e.check(tp(r)),e.uppercase=r=>e.check(np(r)),e.trim=()=>e.check(ap()),e.normalize=(...r)=>e.check(ip(...r)),e.toLowerCase=()=>e.check(cp()),e.toUpperCase=()=>e.check(up()),e.slugify=()=>e.check(lp())}),xp=f("ZodString",(e,t)=>{ir.init(e,t),us.init(e,t),e.email=n=>e.check(wl(Up,n)),e.url=n=>e.check(rs(ps,n)),e.jwt=n=>e.check(Bl(qp,n)),e.emoji=n=>e.check($l(Mp,n)),e.guid=n=>e.check(ns(ls,n)),e.uuid=n=>e.check(vl(gn,n)),e.uuidv4=n=>e.check(Ol(gn,n)),e.uuidv6=n=>e.check(Al(gn,n)),e.uuidv7=n=>e.check(bl(gn,n)),e.nanoid=n=>e.check(Nl(Fp,n)),e.guid=n=>e.check(ns(ls,n)),e.cuid=n=>e.check(Ll(zp,n)),e.cuid2=n=>e.check(Dl(Gp,n)),e.ulid=n=>e.check(kl(Hp,n)),e.base64=n=>e.check(Gl(Yp,n)),e.base64url=n=>e.check(Hl(Xp,n)),e.xid=n=>e.check(Pl(jp,n)),e.ksuid=n=>e.check(xl(Bp,n)),e.ipv4=n=>e.check(Ul(Zp,n)),e.ipv6=n=>e.check(Ml(Vp,n)),e.cidrv4=n=>e.check(Fl(Wp,n)),e.cidrv6=n=>e.check(zl(Kp,n)),e.e164=n=>e.check(jl(Qp,n)),e.datetime=n=>e.check(Ep(n)),e.date=n=>e.check(_p(n)),e.time=n=>e.check(Sp(n)),e.duration=n=>e.check(Rp(n))});function w(e){return Il(xp,e)}const me=f("ZodStringFormat",(e,t)=>{pe.init(e,t),us.init(e,t)}),Up=f("ZodEmail",(e,t)=>{Nu.init(e,t),me.init(e,t)}),ls=f("ZodGUID",(e,t)=>{bu.init(e,t),me.init(e,t)}),gn=f("ZodUUID",(e,t)=>{$u.init(e,t),me.init(e,t)}),ps=f("ZodURL",(e,t)=>{Lu.init(e,t),me.init(e,t)});function Kt(e){return rs(ps,e)}const Mp=f("ZodEmoji",(e,t)=>{Du.init(e,t),me.init(e,t)}),Fp=f("ZodNanoID",(e,t)=>{ku.init(e,t),me.init(e,t)}),zp=f("ZodCUID",(e,t)=>{Pu.init(e,t),me.init(e,t)}),Gp=f("ZodCUID2",(e,t)=>{xu.init(e,t),me.init(e,t)}),Hp=f("ZodULID",(e,t)=>{Uu.init(e,t),me.init(e,t)}),jp=f("ZodXID",(e,t)=>{Mu.init(e,t),me.init(e,t)}),Bp=f("ZodKSUID",(e,t)=>{Fu.init(e,t),me.init(e,t)}),Zp=f("ZodIPv4",(e,t)=>{Bu.init(e,t),me.init(e,t)}),Vp=f("ZodIPv6",(e,t)=>{Zu.init(e,t),me.init(e,t)}),Wp=f("ZodCIDRv4",(e,t)=>{Vu.init(e,t),me.init(e,t)}),Kp=f("ZodCIDRv6",(e,t)=>{Wu.init(e,t),me.init(e,t)}),Yp=f("ZodBase64",(e,t)=>{Ku.init(e,t),me.init(e,t)}),Xp=f("ZodBase64URL",(e,t)=>{Xu.init(e,t),me.init(e,t)}),Qp=f("ZodE164",(e,t)=>{Qu.init(e,t),me.init(e,t)}),qp=f("ZodJWT",(e,t)=>{Ju.init(e,t),me.init(e,t)}),ds=f("ZodNumber",(e,t)=>{jo.init(e,t),ge.init(e,t),e.gt=(r,o)=>e.check(ss(r,o)),e.gte=(r,o)=>e.check(ur(r,o)),e.min=(r,o)=>e.check(ur(r,o)),e.lt=(r,o)=>e.check(os(r,o)),e.lte=(r,o)=>e.check(cr(r,o)),e.max=(r,o)=>e.check(cr(r,o)),e.int=r=>e.check(Xe(r)),e.safe=r=>e.check(Xe(r)),e.positive=r=>e.check(ss(0,r)),e.nonnegative=r=>e.check(ur(0,r)),e.negative=r=>e.check(os(0,r)),e.nonpositive=r=>e.check(cr(0,r)),e.multipleOf=(r,o)=>e.check(is(r,o)),e.step=(r,o)=>e.check(is(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function _n(e){return Yl(ds,e)}const Jp=f("ZodNumberFormat",(e,t)=>{el.init(e,t),ds.init(e,t)});function Xe(e){return Xl(Jp,e)}const ed=f("ZodBoolean",(e,t)=>{tl.init(e,t),ge.init(e,t)});function ee(e){return Ql(ed,e)}const td=f("ZodUnknown",(e,t)=>{nl.init(e,t),ge.init(e,t)});function fs(){return ql(td)}const nd=f("ZodNever",(e,t)=>{rl.init(e,t),ge.init(e,t)});function rd(e){return Jl(nd,e)}const od=f("ZodArray",(e,t)=>{ol.init(e,t),ge.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(En(n,r)),e.nonempty=n=>e.check(En(1,n)),e.max=(n,r)=>e.check(as(n,r)),e.length=(n,r)=>e.check(cs(n,r)),e.unwrap=()=>e.element});function oe(e,t){return pp(od,e,t)}const sd=f("ZodObject",(e,t)=>{il.init(e,t),ge.init(e,t),se(e,"shape",()=>t.shape),e.keyof=()=>Ee(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:fs()}),e.loose=()=>e.clone({...e._zod.def,catchall:fs()}),e.strict=()=>e.clone({...e._zod.def,catchall:rd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>vc(e,n),e.safeExtend=n=>Oc(e,n),e.merge=n=>Ac(e,n),e.pick=n=>Ic(e,n),e.omit=n=>wc(e,n),e.partial=(...n)=>bc(ms,e,n[0]),e.required=(...n)=>$c(_s,e,n[0])});function R(e,t){const n={type:"object",shape:e??{},...x(t)};return new sd(n)}const hs=f("ZodUnion",(e,t)=>{Ko.init(e,t),ge.init(e,t),e.options=t.options});function Lt(e,t){return new hs({type:"union",options:e,...x(t)})}const id=f("ZodDiscriminatedUnion",(e,t)=>{hs.init(e,t),al.init(e,t)});function Qe(e,t,n){return new id({type:"union",options:t,discriminator:e,...x(n)})}const ad=f("ZodIntersection",(e,t)=>{cl.init(e,t),ge.init(e,t)});function cd(e,t){return new ad({type:"intersection",left:e,right:t})}const ud=f("ZodRecord",(e,t)=>{ul.init(e,t),ge.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ke(e,t,n){return new ud({type:"record",keyType:e,valueType:t,...x(n)})}const lr=f("ZodEnum",(e,t)=>{ll.init(e,t),ge.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new lr({...t,checks:[],...x(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new lr({...t,checks:[],...x(o),entries:i})}});function Ee(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new lr({type:"enum",entries:n,...x(t)})}const ld=f("ZodLiteral",(e,t)=>{pl.init(e,t),ge.init(e,t),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 L(e,t){return new ld({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const pd=f("ZodTransform",(e,t)=>{dl.init(e,t),ge.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Oo(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Wt(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Wt(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function dd(e){return new pd({type:"transform",transform:e})}const ms=f("ZodOptional",(e,t)=>{fl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Es(e){return new ms({type:"optional",innerType:e})}const fd=f("ZodNullable",(e,t)=>{hl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function gs(e){return new fd({type:"nullable",innerType:e})}const hd=f("ZodDefault",(e,t)=>{ml.init(e,t),ge.init(e,t),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():No(t)}})}const Ed=f("ZodPrefault",(e,t)=>{El.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function gd(e,t){return new Ed({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():No(t)}})}const _s=f("ZodNonOptional",(e,t)=>{gl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _d(e,t){return new _s({type:"nonoptional",innerType:e,...x(t)})}const yd=f("ZodCatch",(e,t)=>{_l.init(e,t),ge.init(e,t),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=f("ZodPipe",(e,t)=>{yl.init(e,t),ge.init(e,t),e.in=t.in,e.out=t.out});function ys(e,t){return new Td({type:"pipe",in:e,out:t})}const Rd=f("ZodReadonly",(e,t)=>{Sl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Cd(e){return new Rd({type:"readonly",innerType:e})}const Id=f("ZodCustom",(e,t)=>{Tl.init(e,t),ge.init(e,t)});function wd(e,t={}){return dp(Id,e,t)}function vd(e){return fp(e)}const Od={url:"must be a valid URL",email:"must be a valid email address"},Ad=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},bd=e=>e===null?"null":typeof e,$d=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Ad(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${bd(t)}`}}case"invalid_format":{const t=Od[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}},K={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"};Ee(Object.values(K));const q={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};Ee(Object.values(q));const Dt={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Nd=Ee(Object.values(Dt)),Yt={CONTENT:"Content",DESIGN:"Design"};Ee(Object.values(Yt));const Ld={TEXT:"TEXT",IMAGE:"IMAGE"},Dd=Ee(Object.values(Ld)),lt={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"},kd=Ee(Object.values(lt)),yn={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Pd=Ee(Object.values(yn)),xd={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},Ud=Ee(Object.values(xd)),Md={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},Fd=Ee(Object.values(Md)),zd={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},Gd=Ee(Object.values(zd)),pr={COLOR:"COLOR",GRADIENT:"GRADIENT"},Hd=Ee(Object.values(pr));Ee(["none","all","small"]);const et={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Ss={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},jd=Ee(Object.values(et));Ee(Object.values(Ss));const Bd={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"},Zd=Ee(Object.values(Bd)),Vd={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",COVER_FULLSCREEN_CENTER:"COVER_FULLSCREEN_CENTER",COVER_FULLSCREEN_LEFT:"COVER_FULLSCREEN_LEFT",COVER_FULLSCREEN_CENTER_LEFT:"COVER_FULLSCREEN_CENTER_LEFT",COVER_FULLSCREEN_RIGHT:"COVER_FULLSCREEN_RIGHT",COVER_FULLSCREEN_BOTTOM:"COVER_FULLSCREEN_BOTTOM",COVER_FULLSCREEN_BOTTOM_RIGHT:"COVER_FULLSCREEN_BOTTOM_RIGHT",COVER_FULLSCREEN_BOTTOM_LEFT:"COVER_FULLSCREEN_BOTTOM_LEFT",COVER_FULLSCREEN_TOP:"COVER_FULLSCREEN_TOP",COVER_SIDEBAR_RIGHT:"COVER_SIDEBAR_RIGHT",COVER_SIDEBAR_LEFT:"COVER_SIDEBAR_LEFT",COVER_HALFSCREEN_LEFT:"COVER_HALFSCREEN_LEFT",COVER_HALFSCREEN_CENTER:"COVER_HALFSCREEN_CENTER",COVER_COLLAGE_BOTTOM:"COVER_COLLAGE_BOTTOM",COVER_COLLAGE_LEFT:"COVER_COLLAGE_LEFT",IMAGE_SUBTITLE_RIGHT:"IMAGE_SUBTITLE_RIGHT",IMAGE_TITLE_LEFT:"IMAGE_TITLE_LEFT",IMAGE_LEFT:"IMAGE_LEFT",IMAGE_RIGHT:"IMAGE_RIGHT",IMAGE_CENTER:"IMAGE_CENTER",IMAGE_SIDE_TITLE:"IMAGE_SIDE_TITLE",LOCATION_MAP_RIGHT:"LOCATION_MAP_RIGHT",LOCATION_MAP_LEFT:"LOCATION_MAP_LEFT",LOCATION_IMAGE_RIGHT:"LOCATION_IMAGE_RIGHT",LOCATION_IMAGE_LEFT:"LOCATION_IMAGE_LEFT",LOCATION_BACKGROUND_RIGHT:"LOCATION_BACKGROUND_RIGHT",LOCATION_BACKGROUND_LEFT:"LOCATION_BACKGROUND_LEFT",LOCATION_FULL:"LOCATION_FULL",LOCATION_SHORT:"LOCATION_SHORT",REVIEWS_MINIMAL:"REVIEWS_MINIMAL",REVIEWS_CARDS:"REVIEWS_CARDS",REVIEWS:"REVIEWS",REVIEWS_CLASSIC:"REVIEWS_CLASSIC",REVIEWS_FULLSCREEN_BG:"REVIEWS_FULLSCREEN_BG",REVIEWS_FULLSCREEN_SIDEBAR_LEFT:"REVIEWS_FULLSCREEN_SIDEBAR_LEFT",REVIEWS_FULLSCREEN_SIDEBAR_RIGHT:"REVIEWS_FULLSCREEN_SIDEBAR_RIGHT",REVIEWS_CARDS_PHOTO:"REVIEWS_CARDS_PHOTO",REVIEWS_PHOTO_SPEECH_RIGHT:"REVIEWS_PHOTO_SPEECH_RIGHT",REVIEWS_PHOTO_SPEECH_LEFT:"REVIEWS_PHOTO_SPEECH_LEFT",REVIEWS_SOCIAL_FEED:"REVIEWS_SOCIAL_FEED",REVIEWS_ADAPTIVE:"REVIEWS_ADAPTIVE",FEATURES_CLASSIC_CENTER:"FEATURES_CLASSIC_CENTER",FEATURES_CLASSIC_LEFT:"FEATURES_CLASSIC_LEFT",FEATURES_ACCORDION:"FEATURES_ACCORDION",FEATURES_MINIMAL:"FEATURES_MINIMAL",FEATURES_SMALL_ICONS:"FEATURES_SMALL_ICONS",FEATURES_CAROUSEL:"FEATURES_CAROUSEL",FEATURES_IMAGE_LEFT:"FEATURES_IMAGE_LEFT",FEATURES_IMAGE_RIGHT:"FEATURES_IMAGE_RIGHT",ANNOUNCEMENT_CENTER:"ANNOUNCEMENT_CENTER",SLIDER_FULLSCREEN_CENTER:"SLIDER_FULLSCREEN_CENTER",SLIDER_FULLSCREEN_LEFT:"SLIDER_FULLSCREEN_LEFT",SLIDER_BASIC:"SLIDER_BASIC",SLIDER_CAROUSEL:"SLIDER_CAROUSEL",SLIDER_CAROUSEL_PORTRAIT:"SLIDER_CAROUSEL_PORTRAIT",SLIDER_SPLIT:"SLIDER_SPLIT",SLIDER_SPLIT_REVERSE:"SLIDER_SPLIT_REVERSE"},Wd=Ee(Object.values(Vd)),Kd={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"},Yd={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"},Xd=Ee(Object.values(Yd)),gt={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`,INVALID_SELECTBOX_OPTION:(...e)=>`Option value "${e[0]}" for element "${e[1]}" is not defined in content.ts options`,REQUIRED_STORE_LAYOUT:(...e)=>`Store section with id "${e[0]}" and page type "${e[1]}" must have a corresponding layout defined`,INVALID_STORE_SECTION_ID:(...e)=>`Store layout sectionId "${e[0]}" must be one of: ${e[1]}`,REQUIRED_SECTION_ASSET:(...e)=>`Asset size ${e[0]} exceeds threshold of ${e[1]}.`,REQUIRED_SERVER_SIZE:(...e)=>`Size of individual server file [${e[0]}] must not exceed threshold [${e[1]}].`,MISSING_IMAGE_ASSET:(...e)=>`Image ${e[0]} is missing from assets folder`,MANDATORY_SETTING_TYPE_MISMATCH:(...e)=>`Editor type "${e[0]}" for reserved key "${e[1]}" does not match the required type "${e[2]}".`,MANDATORY_SETTING_NAME_MISMATCH:(...e)=>`Editor key "${e[0]}" for overridden content type "${e[1]}" does not match the required key name "${e[2]}".`,DUPLICATED_MANDATORY_SETTING:(...e)=>`Editor type "${e[0]}" can only be used once.`,IMAGE_EDITOR_STATIC_MISMATCH:(...e)=>`Both "${e[0]}" content and design editor need to have same value for attribute static`,DUPLICATE_DESIGN_EDITOR_NAME:()=>"Non-unique design editor name detected",COLOR_REQUIRED_GRADIENT:()=>"color is required when overlay is GRADIENT",COLOR_MUST_BE_ARRAY_GRADIENT:()=>"color must be an array when overlay is GRADIENT",COLOR_ARRAY_LENGTH_GRADIENT:()=>"color array must have exactly 2 items when overlay is GRADIENT",COLOR_REQUIRED_COLOR:()=>"color is required when overlay is COLOR",COLOR_MUST_BE_SINGLE_COLOR:()=>"color must be a single value when overlay is COLOR",COLOR_MUST_BE_UNDEFINED_NONE:()=>"color must be undefined when overlay is NONE or not set",COLOR_REQUIRED_STYLE_GRADIENT:()=>"color is required when style is GRADIENT",COLOR_MUST_BE_ARRAY_STYLE_GRADIENT:()=>"color must be an array when style is GRADIENT",COLOR_ARRAY_LENGTH_STYLE_GRADIENT:()=>"color array must have exactly 2 items when style is GRADIENT",COLOR_REQUIRED_STYLE_COLOR:()=>"color is required when style is COLOR",COLOR_MUST_BE_SINGLE_STYLE_COLOR:()=>"color must be a single value when style is COLOR",BUTTON_LINK_REQUIRED:()=>"link is required when buttonType is HYPER_LINK",BUTTON_CATEGORY_ID_REQUIRED:()=>"categoryId is required when buttonType is GO_TO_CATEGORY or GO_TO_CATEGORY_LINK",BUTTON_EMAIL_REQUIRED:()=>"email is required when buttonType is MAIL_LINK",BUTTON_PHONE_REQUIRED:()=>"phone is required when buttonType is TEL_LINK",BUTTON_TILE_ID_REQUIRED:(...e)=>`${e[0]} is required when buttonType is SCROLL_TO_TILE`,BUTTON_PAGE_ID_REQUIRED:()=>"pageIdForNavigate is required when type is GO_TO_PAGE",TEMPLATE_PAGE_SECTIONS_REQUIRED:()=>"sections must contain at least one section",TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have exactly one section`,TEMPLATE_PAGE_STORE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have a section of type "store"`,TEMPLATE_PAGE_NO_STORE_SECTIONS:(...e)=>`Page type "${e[0]}" cannot contain store sections`,TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED:()=>'Page type "CUSTOM" must have a metadata property',TEMPLATE_PAGE_METADATA_NOT_ALLOWED:(...e)=>`Page type "${e[0]}" must not have a metadata property`,NON_NEGATIVE_INTEGER:()=>"must be a non-negative integer",INTEGER_RANGE:(...e)=>`must be between ${e[0]} and ${e[1]}`,VALID_HEX_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA)",VALID_LANGUAGE_CODE:()=>"must be a valid language code (e.g., en, nl, fr, en_US, en_GB, zh_Hans)",VALID_URL:()=>"must be a valid URL",VALID_EMAIL:()=>"must be a valid email address",ACCORDION_ITEM_POSITION_FIELD_REQUIRED:(...e)=>`Item "${e[0]}" must have positionFieldName when sortable is true`,ACCORDION_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor`,ACCORDION_SHOWCASE_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor override`,ACCORDION_DUPLICATE_POSITION_FIELD_NAME:()=>"positionFieldName must be unique across accordion items when sortable is true"},Qd=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,qd=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,pt=(e,t)=>{const n=gt.INTEGER_RANGE(e.toString(),t.toString());return Xe().min(e,{message:n}).max(t,{message:n})},dr=R({path:w(),size:_n().nonnegative()}).strict(),Ts=R({size:_n().nonnegative()}).strict(),F=w().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),Jd=R({r:pt(0,255),g:pt(0,255),b:pt(0,255),a:pt(0,1)}).strict(),fr=w().regex(Qd,{message:gt.VALID_HEX_COLOR()}),Me=Lt([fr,Ee(["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"])]),Rs=Ee(["global.textSize.title","global.textSize.subtitle","global.textSize.body"]),Xt=Ee(["catalog","category","product"]),ef=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function hr(e){return e===et.PRODUCT||e===et.CATALOG||e===et.CATEGORY}function Cs(e,t,n){if(!e)return;const r=$a({path:"$..set..url",json:e,resultType:"all"}),o=/^https?:\/\//;r.forEach(i=>{const s=i.value;if(!o.test(s)&&!t.includes(s)){const a=i.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",s)}})}function Is(e,t,n){e===lt.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function ws(e,t,n){(e===lt.GO_TO_CATEGORY||e===lt.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function vs(e,t,n){e===lt.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Os(e,t,n){e===lt.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function As(e,t,n,r){if(e===lt.SCROLL_TO_TILE&&!(t??n)){const o=t?"tileId":"tileIdForScroll";r.at(o).addIssue("BUTTON_TILE_ID_REQUIRED",o)}}function tf(e,t,n){e===lt.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const nf="custom";function Fe(e,t=[]){const n=o=>Array.isArray(o)?o:[o],r=n(t);return{raw:e,addIssue(o,...i){e.addIssue({code:nf,message:gt[o](...i),path:r,params:{errorMessageKey:o}})},at(o){const i=r.concat(n(o));return Fe(e,i)}}}const mr=R({type:L(K.BUTTON),title:F,buttonType:kd,link:w().optional(),linkTarget:w().optional(),email:w().regex(ef,{message:gt.VALID_EMAIL()}).optional(),phone:w().optional(),tileId:w().optional(),categoryId:_n().optional()}).strict().superRefine((e,t)=>{const n=Fe(t);Is(e.buttonType,e.link,n),ws(e.buttonType,e.categoryId,n),vs(e.buttonType,e.email,n),Os(e.buttonType,e.phone,n),As(e.buttonType,e.tileId,void 0,n)}),bs=R({type:L(K.BUTTON),label:F,defaults:mr.optional()}).strict(),Er=R({type:L(K.CATEGORY_SELECTOR)}).strict(),$s=R({type:L(K.CATEGORY_SELECTOR),label:F,maxCategories:pt(1,32),defaults:Er.optional()}).strict(),gr=R({type:L(K.DIVIDER)}).strict(),Ns=R({type:L(K.DIVIDER),label:F,defaults:gr.optional()}).strict(),Qt=R({url:w(),width:Xe().min(0,{message:gt.NON_NEGATIVE_INTEGER()}).optional(),height:Xe().min(0,{message:gt.NON_NEGATIVE_INTEGER()}).optional()}).strict(),rf=R({homogeneity:ee().optional(),color:Jd.optional()}).strict(),of=R({ORIGINAL:Qt.optional(),WEBP_LOW_RES:Qt.optional(),WEBP_HI_2X_RES:Qt.optional(),MOBILE_WEBP_LOW_RES:Qt.optional(),MOBILE_WEBP_HI_RES:Qt.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),Sn=R({set:of,borderInfo:rf.optional()}).strict(),_r=R({type:L(K.IMAGE),imageData:Sn}).strict(),Ls=R({type:L(K.IMAGE),label:F,static:ee().optional(),defaults:_r.optional()}).strict(),sf=R({label:F,link:Kt()}).strict(),af=R({title:F.optional(),link:Kt().optional()}).strict(),yr=R({type:L(K.INFO),text:F.optional(),button:af.optional()}).strict(),Ds=R({type:L(K.INFO),label:F,description:F,button:sf.optional(),defaults:yr.optional()}).strict(),Sr=R({type:L(K.INPUTBOX),text:F}).strict(),ks=R({type:L(K.INPUTBOX),label:F,placeholder:F,defaults:Sr.optional()}).strict(),Tr=R({type:L(K.PRODUCT_SELECTOR)}).strict(),Ps=R({type:L(K.PRODUCT_SELECTOR),label:F,maxProducts:pt(1,32),defaults:Tr.optional()}).strict(),Rr=R({type:L(K.SELECTBOX),value:w()}).strict(),cf=R({value:w().min(1,{message:"value must not be empty"}),label:F}).strict(),xs=R({type:L(K.SELECTBOX),label:F,placeholder:F,description:F,options:oe(cf).min(1,{message:"must have at least one option"}),defaults:Rr.optional()}).strict(),Cr=R({type:L(K.TEXTAREA),text:F}).strict(),Us=R({type:L(K.TEXTAREA),label:F,placeholder:F,defaults:Cr.optional()}).strict(),Ir=R({type:L(K.TOGGLE),enabled:ee()}).strict(),Ms=R({type:L(K.TOGGLE),label:F,description:F,defaults:Ir.optional()}).strict(),uf=R({type:L(K.DECK)}).strict(),lf=Qe("type",[Sr,Cr,mr,_r,Ir,Rr,gr,yr,Tr,Er]),pf=R({type:L(K.DECK),cards:oe(R({settings:ke(w(),lf).refine(e=>Object.keys(e).length>=1,{message:"settings must have at least one property"})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),df=R({type:L(K.DECK),label:F,addButtonLabel:F,maxCards:Xe().min(1,{message:"must be a positive integer"}),cards:R({defaultCardContent:R({label:F,settings:ke(w(),Qe("type",[ks,Us,bs,Ls,Ms,xs,Ns,Ds,$s,Ps])).refine(e=>Object.keys(e).length>=1,{message:"settings must have at least one property"})}).strict()}).strict(),defaults:uf.optional()}).strict(),Fs=R({type:L(K.LOGO),logoType:Dd.optional(),text:F.optional(),imageData:Sn.optional()}).strict(),ff=R({type:L(K.LOGO),label:F.optional(),defaults:Fs.optional()}).strict(),zs=R({id:w(),title:w().optional(),type:w().optional(),link:w().optional(),email:w().optional(),phone:w().optional(),tileIdForScroll:w().optional(),pageIdForNavigate:w().optional(),showStoreCategories:ee().optional(),isSubmenuOpened:ee().optional(),categoryId:_n().optional()}).strict().superRefine((e,t)=>{const n=Fe(t);Is(e.type,e.link,n),ws(e.type,e.categoryId,n),vs(e.type,e.email,n),Os(e.type,e.phone,n),As(e.type,void 0,e.tileIdForScroll,n),tf(e.type,e.pageIdForNavigate,n)}),Gs=R({type:L(K.MENU),items:oe(zs).optional()}).strict(),hf=R({type:L(K.MENU),label:F.optional(),defaults:Gs.optional()}).strict(),Hs=R({type:L(K.NAVIGATION_MENU),items:oe(zs).optional()}).strict(),mf=R({type:L(K.NAVIGATION_MENU),defaults:Hs.optional()}).strict(),Ef=Qe("type",[ks,Us,bs,Ls,Ms,xs,df,hf,mf,ff,Ns,Ds,Ps,$s]),js=ke(w(),Ef),Tn=R({type:L(q.BACKGROUND),style:Hd.optional(),color:Lt([Me,oe(Me)]).optional()}).strict().superRefine((e,t)=>{const n=Fe(t).at("color");e.style===pr.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===pr.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),gf=R({type:L(q.BACKGROUND),fieldName:w(),defaults:Tn.optional()}).strict(),Bs=R({type:L(q.BACKGROUND),label:F,colors:oe(Me).optional(),enableAlphaColor:ee().optional(),enableAutoColor:ee().optional(),defaults:Tn.optional()}).strict(),Rn=R({type:L(q.BUTTON),appearance:Ud.optional(),size:Fd.optional(),shape:Gd.optional(),font:w().optional(),color:Me.optional(),visible:ee().optional()}).strict(),_f=R({type:L(q.BUTTON),fieldName:w(),defaults:Rn.optional()}).strict(),Zs=R({type:L(q.BUTTON),label:F,colors:oe(Me).optional(),enableAutoColor:ee().optional(),enableAlphaColor:ee().optional(),hideVisibleToggle:ee().optional(),hideSize:ee().optional(),defaults:Rn.optional()}).strict(),Cn=R({type:L(q.COLOR_PICKER),color:Me.optional()}).strict(),yf=R({type:L(q.COLOR_PICKER),fieldName:w(),defaults:Cn.optional()}).strict(),Vs=R({type:L(q.COLOR_PICKER),label:F,colors:oe(Me).optional(),enableAlphaColor:ee().optional(),enableAutoColor:ee().optional(),defaults:Cn.optional()}).strict(),In=R({type:L(q.DIVIDER)}).strict(),Sf=R({type:L(q.DIVIDER),fieldName:w(),defaults:In.optional()}).strict(),Ws=R({type:L(q.DIVIDER),label:F,defaults:In.optional()}).strict(),wn=R({type:L(q.IMAGE),overlay:Pd.optional(),color:Lt([Me,oe(Me)]).optional(),visible:ee().optional()}).strict().superRefine((e,t)=>{const n=Fe(t).at("color");e.overlay===yn.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===yn.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===yn.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),Tf=R({type:L(q.IMAGE),fieldName:w(),defaults:wn.optional()}).strict(),Ks=R({type:L(q.IMAGE),label:F,static:ee().optional(),colors:oe(fr).optional(),enableAlphaColor:ee().optional(),hideVisibleToggle:ee().optional(),defaults:wn.optional()}).strict(),Rf=R({visible:ee(),width:pt(1,49).optional(),color:Me.optional()}).strict(),vn=R({type:L(q.LOGO),font:w().optional(),size:Lt([Xe().min(1,{message:"must be at least 1"}),Rs]).optional(),bold:ee().optional(),italic:ee().optional(),color:Me.optional(),visible:ee().optional(),spacing:pt(1,9).optional(),frame:Rf.optional(),capitalization:Ee(["none","all","small"]).optional()}).strict(),Cf=R({type:L(q.LOGO),fieldName:w(),defaults:vn.optional()}).strict(),Ys=R({type:L(q.LOGO),label:F,colors:oe(Me).optional(),sizes:oe(Xe().min(1,{message:"must be at least 1"})).optional(),defaults:vn.optional()}).strict(),If=R({value:w().optional(),label:F.optional()}).strict(),On=R({type:L(q.SELECTBOX),value:w().optional()}).strict(),wf=R({type:L(q.SELECTBOX),fieldName:w(),defaults:On.optional()}).strict(),Xs=R({type:L(q.SELECTBOX),label:F,description:F.optional(),options:oe(If).optional(),defaults:On.optional()}).strict(),An=R({type:L(q.TEXT),font:w().optional(),size:Lt([Xe().min(1,{message:"must be at least 1"}),Rs]).optional(),bold:ee().optional(),italic:ee().optional(),color:Me.optional(),visible:ee().optional()}).strict(),vf=R({type:L(q.TEXT),fieldName:w(),defaults:An.optional()}).strict(),Qs=R({type:L(q.TEXT),label:F,colors:oe(fr).optional(),sizes:oe(Xe().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:ee().optional(),enableAutoColor:ee().optional(),hideVisibleToggle:ee().optional(),hideSize:ee().optional(),defaults:An.optional()}).strict(),bn=R({type:L(q.TOGGLE),enabled:ee().optional()}).strict(),Of=R({type:L(q.TOGGLE),fieldName:w(),defaults:bn.optional()}).strict(),qs=R({type:L(q.TOGGLE),label:F,defaults:bn.optional()}).strict();function Af(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function bf(e,t){for(const[n,r]of Object.entries(e))Object.keys(r.editors).length===0&&t.at(["items",n,"editors"]).addIssue("ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED",n)}function $f(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Nf(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function Lf(e,t){for(const[n,r]of Object.entries(e))r.positionFieldName||t.at(["items",n,"positionFieldName"]).addIssue("ACCORDION_ITEM_POSITION_FIELD_REQUIRED",n)}function Df(e,t){const n=Object.values(e).map(r=>r.positionFieldName).filter(Boolean);new Set(n).size!==n.length&&t.at("items").addIssue("ACCORDION_DUPLICATE_POSITION_FIELD_NAME")}const Js=R({type:L(q.ACCORDION)}).strict(),kf=Qe("type",[An,Rn,wn,bn,On,Tn,Cn,vn,In]),Pf=R({editors:ke(w(),kf)}).strict(),xf=R({type:L(q.ACCORDION),items:ke(w(),Pf)}).strict().superRefine((e,t)=>{const n=Fe(t);Af(e.items,n),bf(e.items,n)}),Uf=R({type:L(q.ACCORDION),fieldName:w(),defaults:Js.optional()}).strict(),Mf=Qe("type",[Qs,Zs,Ks,qs,Xs,Bs,Vs,Ys,Ws]),Ff=R({label:F,positionFieldName:w().optional(),editors:ke(w(),Mf)}).strict().superRefine((e,t)=>{$f(e.editors,e.label,Fe(t))}),zf=R({type:L(q.ACCORDION),sortable:ee().optional(),items:ke(w(),Ff),defaults:Js.optional()}).strict().superRefine((e,t)=>{const n=Fe(t);Nf(e.items,n),e.sortable===!0&&(Lf(e.items,n),Df(e.items,n))}),Gf=R({label:F,link:Kt()}).strict(),Hf=R({label:F.optional(),link:Kt().optional()}).strict(),wr=R({type:L(q.INFO),description:F.optional(),button:Hf.optional()}).strict(),jf=R({type:L(q.INFO),fieldName:w(),defaults:wr.optional()}).strict(),Bf=R({type:L(q.INFO),label:F,description:F,button:Gf.optional(),defaults:wr.optional()}).strict(),Zf=Qe("type",[Qs,Zs,Ks,qs,Xs,Bs,Vs,Ys,Ws,zf,Bf]),ei=ke(w(),Zf),Vf=Qe("type",[vf,_f,Tf,Of,wf,gf,yf,Cf,Sf,jf,Uf]),Wf=R({layoutId:w(),layoutIcon:Wd.optional(),selectedContentSettings:oe(w()),selectedDesignSettings:oe(Vf)}).strict(),ti=Qe("type",[Sr,Cr,mr,_r,Ir,Rr,Gs,Hs,Fs,gr,yr,pf,Tr,Er]),ni=Qe("type",[An,Rn,wn,bn,On,Tn,Cn,vn,In,xf,wr]),Kf=R({showcaseId:w(),blockName:w(),previewImage:Sn,content:ke(w(),ti),design:ke(w(),ni),layoutId:w().optional()}).strict(),Yf=R({blockName:w(),content:ke(w(),ti).optional(),design:ke(w(),ni).optional(),layoutId:w().optional()}).strict(),Xf=w().regex(qd,gt.VALID_LANGUAGE_CODE()),$n=ke(Xf,ke(F,w())),Qf={menu:{type:K.NAVIGATION_MENU},logo:{type:K.LOGO}},qf={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 ri(e){switch(e){case Dt.HEADER:return Qf;default:return{}}}function oi(e){switch(e){case Dt.HEADER:return qf;default:return{}}}function si({validationType:e,sectionType:t}){switch(e){case Yt.CONTENT:return ri(t);case Yt.DESIGN:return oi(t);default:return{}}}const Nn=2097152,Ln=512e3;function it(e,t=2){if(!+e)return"0 Bytes";const n=1024,r=t<0?0:t,o=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**i).toFixed(r))} ${o[i]}`}function ii(e,t,n){if(!e||Object.keys(t).length===0)return;const r=Object.entries(t),o=r.map(([,{type:s}])=>s),i=Object.values(e).map(({type:s})=>s);Object.entries(e).forEach(([s,a])=>{const c=t[s];c&&"type"in c&&a.type!==c.type&&n.at(s).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,s,c.type)}),Object.entries(e).forEach(([s,a])=>{const c=r.find(([,{type:u}])=>u===a.type)?.[0];c&&s!==c&&n.at(s).addIssue("MANDATORY_SETTING_NAME_MISMATCH",s,a.type,c)}),new Set(i.filter(s=>o.includes(s))).forEach(s=>{if(i.filter(a=>a===s).length>1){const a=r.findLast(([,{type:c}])=>c===s)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",s)}})}function ai(e,t,n){Cs(e,t,n)}function Jf(e,t,n){if(e.type!==K.DECK||t.type!==K.DECK)return;const r=t.cards?.defaultCardContent?.settings,o=e.cards;if(!r||!Array.isArray(o))return;const i=new Set(Object.keys(r));o.forEach((s,a)=>{s.settings&&Object.keys(s.settings).forEach(c=>{i.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function eh(e,t,n){e.content&&Object.entries(e.content).forEach(([r,o])=>{const i=n.at(["content",r]),s=t[r];if(!s){i.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",r);return}if(o.type!==s.type){i.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",r,o.type,s.type);return}if(o.type===K.SELECTBOX&&s.type===K.SELECTBOX){const a=s,c=o;a.options&&c.value!==void 0&&(new Set(a.options.map(u=>u.value)).has(c.value)||i.addIssue("INVALID_SELECTBOX_OPTION",c.value,r))}o.type===K.DECK&&Jf(o,s,i)})}function th(e,t,n){e.design&&Object.entries(e.design).forEach(([r,o])=>{const i=n.at(["design",r]),s=t[r];if(!s){i.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",r);return}o.type!==s.type&&i.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",r,o.type,s.type)})}function nh(e,t){Object.entries(e).flatMap(([n,r])=>{switch(r.type){case q.ACCORDION:return Object.entries(r.items).flatMap(([o,i])=>Object.keys(i.editors).map(s=>({name:s,path:[n,"items",o,"editors",s]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},r,o)=>o.findIndex(i=>i.name===n)<r).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function rh(e,t,n){e.layoutId&&((t||[]).some(r=>r.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function oh(e,t){const n=new Set;e.forEach((r,o)=>{if(n.has(r.showcaseId)){t.at([o,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",r.showcaseId);return}n.add(r.showcaseId)})}function ci(e,t,n){for(const[r,o]of Object.entries(e)){const i=o;if(i.type===K.IMAGE){const s=t[r];if(s?.type===q.IMAGE){const a=i.static??!1,c=s.static??!1;a!==c&&n.at(r).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",r)}}else if(i.type===K.DECK){const s=i;s.cards?.defaultCardContent?.settings&&ci(s.cards.defaultCardContent.settings,t,n.at([r,"cards","defaultCardContent","settings"]))}}}function sh(e,t,n){t>Nn&&n.at(ue.basename(e)).addIssue("REQUIRED_SECTION_ASSET",it(t),it(Nn))}function ih(e,t){e>Ln&&t.addIssue("REQUIRED_SERVER_SIZE",it(e),it(Ln))}const ah=R({id:w(),type:Nd,name:w(),content:js,design:ei,layout:oe(Wf).optional(),showcase:oe(Kf),translationsSettings:$n.optional(),translationsShowcases:$n.optional(),assets:dr.array().optional(),server:Ts,previewCount:Xe().optional()}).strict().superRefine((e,t)=>{const n=Fe(t),r=si({validationType:Yt.CONTENT,sectionType:e.type}),o=si({validationType:Yt.DESIGN,sectionType:e.type});ii(e.content,r,n.at("content")),ii(e.design,o,n.at("design")),ci(e.content,e.design,n.at("content")),nh(e.design,n.at("design")),e.assets&&e.assets.forEach(s=>{sh(s.path,s.size,n.at("assets"))}),ih(e.server.size,n.at("server"));const i=e.assets?.map(s=>s.path)??[];ai(e.content,i,n.at("content")),oh(e.showcase,n.at("showcase")),e.showcase.forEach((s,a)=>{const c=n.at(["showcase",a]);ai(s,i,c),eh(s,e.content,c),th(s,e.design,c),rh(s,e.layout,c)})}),ch=R({translations:$n.optional()}).strict(),uh=Ee(["products","category","product"]),lh=R({id:w(),sectionId:w(),content:js,design:ei,translationsSettings:$n.optional(),assets:dr.array().optional()}).strict().superRefine((e,t)=>{const n=Fe(t);Xt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Xt.options.join(", ")),e.assets&&e.assets.forEach(r=>{r.size>Nn&&n.at(["assets",ue.basename(r.path)]).addIssue("REQUIRED_SECTION_ASSET",it(r.size),it(Nn))})});R({id:w(),sectionId:Xt,pageId:uh}).strict();const ph=R({id:w(),sectionId:w(),layoutId:w(),server:Ts}).strict().superRefine((e,t)=>{const n=Fe(t);Xt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Xt.options.join(", ")),e.server.size>Ln&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",it(e.server.size),it(Ln))});function dh(e,t){hr(e.type)&&(e.sections.length!==1?t.at("sections").addIssue("TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED",e.type):e.sections[0]?.type!=="store"&&t.at(["sections",0,"type"]).addIssue("TEMPLATE_PAGE_STORE_SECTION_REQUIRED",e.type))}function fh(e,t){hr(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,r)=>{hr(e.type)||n.type==="store"&&t.at(["sections",r,"type"]).addIssue("TEMPLATE_PAGE_NO_STORE_SECTIONS",e.type),n.type==="default"&&n.id&&(n.id==="header"||n.id==="footer")&&t.at(["sections",r,"id"]).addIssue("REQUIRED_PAGE_SECTION_TYPE")})}function hh(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 mh=new RegExp(`^(${Object.values(Kd).join("|")})(_\\d{3})?$`),Eh=w().regex(mh,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),gh=w().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),ui=R({type:L("default"),id:Eh,showcase_id:gh.optional()}).strict(),vr=R({type:L("custom"),id:w(),showcase_id:w().optional(),showcase_overrides:Yf.optional(),category:Xd.optional()}).strict(),_h=R({type:L("store"),id:w().optional()}).strict(),yh=Qe("type",[ui,vr,_h]),Sh=R({title:w()}).strict(),Th=R({metadata:Sh.optional(),sections:oe(yh)}).strict(),Rh=Th.safeExtend({type:jd,id:w().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=Fe(t);fh(e,n),dh(e,n),hh(e,n)}),li=R({name:w().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:w().min(2,{message:"description must be at least 2 characters"}).max(150,{message:"description must be at most 150 characters"}),preview_url:Kt({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:Sn,categories:oe(Zd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),Ch=ui.extend({id:w()}),pi=Qe("type",[Ch,vr]),Ih=R({metadata:li,header:pi,footer:pi}).strict(),wh=R({id:w().min(1,{message:"id is required"}),assets:dr.array().optional(),configuration:Ih,pages:oe(Rh)}).strict();function vh(e,t,n){if(e){if(e.type==="default")e.id!=="header"&&n.at("id").addIssue("REQUIRED_HEADER_ID");else if(e.type==="custom"&&e.id){const r=t.find(o=>o.id===e.id);r?(r.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_HEADER",e.id)}}}function Oh(e,t,n){if(e){if(e.type==="default")e.id!=="footer"&&n.at("id").addIssue("REQUIRED_FOOTER_ID");else if(e.type==="custom"&&e.id){const r=t.find(o=>o.id===e.id);r?(r.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER",e.id)}}}function Ah(e,t,n){if(!e)return;const r=n.at(["showcase_overrides"]);["content","design"].forEach(i=>{const s=e[i];if(s){const a=t[i]||{};Object.keys(s).forEach(c=>{if(!(c in a)){const u=i==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";r.at([i,c]).addIssue(u,c)}})}}),e.layoutId&&((t.layout||[]).some(i=>i.layoutId===e.layoutId)||r.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const o=t.assets?.map(i=>i.path)??[];e.content&&Cs(e.content,o,r.at(["content"]))}function bh(e,t,n){if(!e.id)return;const r=t.find(o=>o.id===e.id);if(!r){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}(r.type==="HEADER"||r.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),Ah(e.showcase_overrides,r,n),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function $h(e,t,n,r){e.id&&(n.some(o=>o.sectionId===t.type.toLowerCase()&&o.id===e.id)||r.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const Nh=R({version:w(),name:w(),shared:ch.optional(),sections:oe(ah),templates:oe(wh),layouts:oe(lh),slots:oe(ph),compressionEnabled:ee(),externalizationEnabled:ee(),vueVersion:w()}).strict().superRefine((e,t)=>{e.templates.forEach((n,r)=>{const o=Fe(t).at(["templates",r]);vh(n.configuration.header,e.sections,o.at(["configuration","header"])),Oh(n.configuration.footer,e.sections,o.at(["configuration","footer"])),n.pages.forEach((i,s)=>{const a=o.at(["pages",s]);i.sections.forEach((c,u)=>{const l=a.at(["sections",u]);c.type==="custom"?bh(c,e.sections,l):c.type==="store"&&$h(c,i,e.layouts,l)})})})}),Lh=R({metadata:li,sections:oe(vr)});R({id:w().min(1,{message:"id is required"}),descriptor:Lh}),st({customError:$d});function Or(e,t){return Object.keys(e).reduce((n,r)=>{const o=e[r],i=t[r];return ft(o)&&ft(i)?n[r]=Or(o,i):n[r]=o,n},{...t})}function Dh({contentSettings:e,sectionType:t}){const n=ri(t);return Or(e,n)}function kh({designSettings:e,sectionType:t}){const n=oi(t);return Or(e,n)}function kt(e){return Ie(`${Ht}/${e}`)?we.HEADER:Ie(`${jt}/${e}`)?we.FOOTER:we.SECTION}async function Pe(e){return(await import(Eo(e).href+`?t=${Date.now()}`)).default}function Ar(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function qe(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Na(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function di(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 Ph(e){if(e!==void 0)return{...e,color:qe(e.color)}}function br(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function xh(e){if(e!==void 0)switch(e){case Xn.COLOR:return"solid";case Xn.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(Xn)}`)}}function Uh({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:xh(e),solid:{color:qe(n.at(0))},gradient:{fromColor:qe(n.at(0)),toColor:qe(n.at(1))}}}}function Mh(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(Ia)}`)}}function Fh(e){if(e!==void 0)switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(wa)}`)}}function zh(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(va)}`)}}function Gh(e){const t=Mh(e.appearance),n=Fh(e.size),r=zh(e.shape),o=Ar(e.font),i=qe(e.color),s=e.visible;return br({appearance:t,size:n,style:r,font:o,color:i,visible:s})}function Hh(e){const t=qe(e.color);return br({color:t})}function jh(e){if(e!==void 0)switch(e){case rn.COLOR:return"solid";case rn.GRADIENT:return"gradient";case rn.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(rn)}`)}}function Bh(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:jh(e.overlay),solid:{color:qe(n.at(0))},gradient:{fromColor:qe(n.at(0)),toColor:qe(n.at(1))}}}}function Zh(e){const t=Ar(e.font),n=qe(e.color),r=di(e.size),o=e.bold,i=e.italic,s=e.spacing,a=e.capitalization;return{font:t,color:n,size:r,frame:Ph(e.frame),bold:o,italic:i,spacing:s,capitalization:a}}function Vh(e){const t=Ar(e.font),n=qe(e.color),r=di(e.size),o=e.bold,i=e.italic;return br({font:t,color:n,size:r,bold:o,italic:i})}function $r(e,t){if(t.defaults===void 0)return;let n={};switch(e){case Ue.TEXT:{n=Vh(t.defaults);break}case Ue.BUTTON:{n=Gh(t.defaults);break}case Ue.IMAGE:{n=Bh(t.defaults);break}case Ue.BACKGROUND:{n=Uh(t.defaults);break}case Ue.COLOR_PICKER:{n=Hh(t.defaults);break}case Ue.LOGO:{n=Zh(t.defaults);break}case Ue.TOGGLE:case Ue.SELECTBOX:case Ue.DIVIDER:case Ue.INFO:break;case Ue.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function fi(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type;if(o===Ue.ACCORDION){const s=Object.fromEntries(Object.entries(r.items).map(([a,c])=>[a,{...c,editors:fi(c.editors)}]));t[n]={...r,items:s};return}const i=$r(o,r);i&&r.defaults?t[n]={...r,defaults:i}:t[n]=r}),t}function Wh(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...$r(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Dn(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type;if(o===Ue.ACCORDION){const s=Object.fromEntries(Object.entries(r.items).map(([a,c])=>[a,{...c,editors:Dn(c.editors)??c.editors}]));t[n]={type:r.type,items:s};return}const i=$r(o,{defaults:r});i!==void 0?t[n]={...r,...i,type:r.type}:t[n]=r}),t}function Kh(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Yh(e){const t={};for(const n in e){const r=e[n];for(const o in r){const i=t[o],s=r[o];if(i===void 0){const a={};a[n]=s,t[o]=a}else i[n]=s}}return t}function Xh(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function _t(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return Xh(e)?e:e.map(o=>_t(o,t));const n=e,r={};for(const o in n){const i=n[o];typeof i=="string"&&i.startsWith("$")?r[o]=Kh(t,i):typeof i=="object"&&i!==null?r[o]=_t(i,t):r[o]=i}return r}async function kn(e){return e?Yh(e):{}}async function hi(e,t=Ae){const n=U(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await Pe(n)}async function Pt(e,t=Ae){const n=U(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await Pe(n)}async function mi(e,t){const n=U(process.cwd(),`${ve}/${t}/${e}/js/settings/translations.mjs`);if(Ie(n))return await Pe(n)}async function Ei(e,t,n){const r=n?Dh({contentSettings:e,sectionType:n}):e;return _t(r,t)}async function gi(e,t=Ae){try{const n=U(ae.cwd(),`${t}/${e}/js/settings/content.mjs`),r=await Pe(n);return wt(r)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Qh(e,t,n=Ae){const r=await gi(e,n);return await Ei(r,t,kt(e))}async function _i(e,t,n){const r=n?kh({designSettings:e,sectionType:n}):e,o=fi(r);return _t(o,t)}async function yi(e,t=Ae){try{const n=U(ae.cwd(),`${t}/${e}/js/settings/design.mjs`),r=await Pe(n);return wt(r)}catch(n){const r=n;throw new Error(`Design settings is invalid or undefined. Error ${r.stack}`)}}async function qh(e,t,n=Ae){const r=await yi(e,n);return _i(r,t,kt(e))}async function Jh(e,t){return Promise.all(e.map(async n=>{const r=n.design?Dn(n.design):void 0,o={...n,design:r??n.design};return _t(o,t)}))}async function Si(e,t=Ae){try{const n=await z("*.mjs",{cwd:U(ae.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async r=>{const o=U(ae.cwd(),`${t}/${e}/js/showcases/${r}`);return await Pe(o)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function em(e,t,n=Ae){const r=await Si(e,n);return Jh(r,t)}async function tm(e){return e?.map(t=>({...t,selectedDesignSettings:Wh(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function Ti(e,t=Ae){try{const n=U(ae.cwd(),`${t}/${e}/js/settings/layout.mjs`);return Ie(n)?await Pe(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function nm(e,t=Ae){const n=await Ti(e,t);return await tm(n)}function Ri(e){let t={};const n=U(ae.cwd(),`${wo}/shared/analytics.json`);if(!Ie(n))return 0;try{const r=fa(n,"utf-8");t=JSON.parse(r)}catch(r){console.warn("Error processing analytics.json file",r)}return t[e]||0}function rm(){try{const e=U(ae.cwd(),`${wo}/shared/analytics.json`);Ie(e)&&ao(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}async function Pn(e,t){const n=await hi(e,ie[t].dist),r=await kn(n),o=await Pt(e,ie[t].dist),i=await kn(o),s=await Qh(e,r,ie[t].dist),a=await qh(e,r,ie[t].dist),c=await em(e,i,ie[t].dist),u=await nm(e,ie[t].dist),l=Ri(e);return{id:e,type:t,name:{en:e},contentEditors:s,designEditors:a,layouts:u,showcases:c,previewCount:l}}async function om(){const e=await z("*/",{cwd:U(ae.cwd(),`${Ae}/`)}),t=await z("*/",{cwd:U(ae.cwd(),`${Ht}/`)}),n=await z("*/",{cwd:U(ae.cwd(),`${jt}/`)});return Promise.all([...e.map(async r=>Pn(r,we.SECTION)),...t.map(async r=>Pn(r,we.HEADER)),...n.map(async r=>Pn(r,we.FOOTER))])}async function sm(e){if(!e||e.type!=="custom")return;const t=kt(e.id),n=await Pt(e.id,ie[t].dist);e.showcase_overrides!==void 0&&(_t(e.showcase_overrides,n),e.showcase_overrides.design&&Dn(e.showcase_overrides.design))}async function im(e){const t=e.filter(n=>n.type==="custom");await Promise.all(t.map(n=>sm(n)))}async function Nr(e){try{return await Pe(rt.resolve(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}function am(e){return e in et?et[e]:et.CUSTOM}async function Lr(e,t){const n=e.design?Dn(e.design):void 0,r={...e,design:n??e.design},o=await kn(t);return _t(r,o)}function Dr(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function cm(e){if(Dr(e)){const t=await Pt(e.id,ie[kt(e.id)].dist);return{...e,showcase_overrides:await Lr(e.showcase_overrides,t)}}return e}async function um(e){const t=Dr(e.header)?{...e.header,showcase_overrides:await Lr(e.header.showcase_overrides,await Pt(e.header.id,ie[kt(e.header.id)].dist))}:e.header,n=Dr(e.footer)?{...e.footer,showcase_overrides:await Lr(e.footer.showcase_overrides,await Pt(e.footer.id,ie[kt(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function lm(e){const t=await Promise.all(e.pages.map(async r=>({...r,sections:await Promise.all(r.sections.map(o=>cm(o)))}))),n=await um(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function pm(e){return Promise.all(e.map(t=>lm(t)))}async function dm(e){const t=await z(`${He}/${e}/*.mjs`,{ignore:[`${He}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:r,metadata:o}=await Nr(n),i=vo(n);return{type:am(i.toUpperCase()),id:i,sections:r,metadata:o}}))}async function fm(e){const t=await z(`${He}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=rt.basename(rt.dirname(n));return{id:`${e}_${r}`,configuration:await Nr(n),pages:await dm(r)}}))}async function hm(e){const t=await fm(e);return pm(t)}async function mm(e){const t=await z(`${on}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=await Nr(n),o=ue.basename(ue.dirname(n));return await im(r.sections),{id:`${e}_${o}`,descriptor:r}}))}function xn({deploymentContext:e,sectionType:t=we.SECTION}){const n=e.pathContext,r=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),o=r===void 0?ho(n.fileName):ho(n.fileName,{cwd:U(process.cwd(),r),ignore:n.ignore});return(n.isSingleton?o.splice(0):o).map(i=>({url:i,sectionType:t,context:e}))}const Em=e=>e.app.sections.flatMap(t=>Ya.flatMap(n=>{const r={config:e,currentSection:t.id,pathContext:Zt[n]};return xn({deploymentContext:r,sectionType:t.type})})),gm=e=>qa.flatMap(t=>{const n={config:e,pathContext:Zt[t]};return xn({deploymentContext:n})}),_m=e=>e.app.layouts.flatMap(t=>Xa.flatMap(n=>{const r={config:e,pathContext:Zt[n],currentSection:t.sectionId,layoutId:t.id};return xn({deploymentContext:r})})),ym=e=>e.app.slots.flatMap(t=>Qa.flatMap(n=>{const r={config:e,pathContext:Zt[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return xn({deploymentContext:r})}));async function Ci(e){await new Promise(t=>setTimeout(t,e))}const Sm=e=>`\x1B[32m${e}\x1B[0m`,Tm=(e,t,n,r,o)=>{if(!e.total)return;const{loaded:i}=e,s=(Date.now()-o)/1e3;n.value+=i-r.value,r.value=i,t.update({speed:`${it(n.value/s,2)}/s`})},Rm=()=>new La.SingleBar({format:`|${Sm("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});function Cm(e){const t=Ct(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t;if(!Io(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:o,sectionId:n,layoutId:r}}async function Im(e){return Promise.all(e.map(async t=>{const n=await kn(t.translationsSettings),r=await Ei(t.content,n),o=await _i(t.design,n);return{id:t.id,sectionId:t.sectionId,layoutId:t.layoutId,contentEditors:r,designEditors:o}}))}async function wm(e,t){try{const n=rt.resolve(process.cwd(),`${ve}/${t}/${e}/js/settings/content.mjs`);return await Pe(n)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function vm(e,t){try{const n=rt.resolve(process.cwd(),`${ve}/${t}/${e}/js/settings/design.mjs`);return await Pe(n)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Om(e){const t=Ct(e).split("/"),[n,r,,o]=t,i=await mi(r,n),s=await wm(r,n),a=await vm(r,n);return{id:o,sectionId:n,layoutId:r,content:s,design:a,translationsSettings:i}}async function Am(){const e=`${ve}/{product,catalog,category}/*/slots/*`,t=await z(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(Om))}async function bm(){const e=await Am();return await Im(e)}const $m={value:0},Be=Rm();let Ii=Date.now();const wi=e=>2**e*500;function Nm(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function kr(){const e=U(ae.cwd(),"package.json"),t=await mo(e),n=JSON.parse(t.toString());if(Nm(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}async function Lm(e){const t=ba(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,ao(U(ae.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
26
|
-
`)}function Dm(e){return e instanceof go&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function vi(e,t){return e<Ka&&Dm(t)}async function Oi(e,t,n,r){const o={value:0},i=e.config.app.templates.length>0||e.config.app.collections.length>0?Ba:ja;return e.config.axios.post(i,{file:ha(U(ae.cwd(),n!==void 0?n+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.layoutId!==void 0&&{layoutId:e.layoutId},...e.slotId!==void 0&&{slotId:e.slotId},...!["dependencies","source_code"].includes(e.pathContext.type)&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`},onUploadProgress:s=>Tm(s,Be,$m,o,Ii)}).then(s=>(Be.increment(),s)).catch(async s=>{if(vi(r,s))return await Ci(wi(r)),Oi(e,t,n,r+1);throw Be.increment(),s})}function km(e){return Be.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,r=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return Oi(n,t.url,r,0)})}function Pm(e){const t=[...Em(e),...gm(e),..._m(e),...ym(e)];return km(t)}async function Ai(e,t=0){const n=e.app.templates.length>0||e.app.collections.length>0?Va:Za;return e.axios.post(n,{version:e.app.packageJson.version,name:"Custom Block App",blocks:e.app.sections,templates:e.app.templates,layouts:e.app.layouts,slots:e.app.slots,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:e.app.packageJson.dependencies.vue,collections:e.app.collections,openSource:e.app.packageJson.openSource},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async r=>{if(vi(t,r))return await Ci(wi(t)),Ai(e,t+1);throw r})}async function xm(e){try{if(!nc.some(s=>Ie(U(ae.cwd(),s))))throw new Error(Tt.INCORRECT_DISTRIBUTION_FOLDER(ec));const t=e??qn;N.info("Custom application deployment :: Started");const n=Qn.create({baseURL:t});Aa(n,Wa),N.info("Loading configuration files ...");const r=await Promise.all([an(),kr(),om(),Ec(),bm()]).then(async([s,a,c,u,l])=>({axios:n,app:{crane:s,packageJson:a,sections:c,layouts:u,slots:l,templates:await hm(s.appClientId),collections:await mm(s.appClientId)}}));N.info("Uploading files ..."),Ii=Date.now(),await Promise.all(Pm(r)).catch(s=>{Be.stop(),s.response?.status===404?N.error(ht(s,Tt.DEPRECATED_VERSION_DEPLOYMENT)):N.error(ht(s,Tt.ASSET_FILES_UPLOAD)),ae.exit(1)}).finally(()=>{Be.increment(),Be.stop()}),Be.update({speed:"N/A",status:"Finalising deployment"}),await Ai(r).catch(s=>{Be.stop(),s.response?.status===404?N.error(ht(s,Tt.DEPRECATED_VERSION_DEPLOYMENT)):N.error(ht(s,Tt.MANIFEST_DEPLOYMENT)),ae.exit(1)}).finally(()=>{Be.increment(),Be.stop()});const o=r.app.sections.map(s=>s.id),i=r.app.packageJson.version;N.info("Custom application deployment :: Successful"),N.info(`Current app version: ${i}`),N.info(`Deployed sections: ${o.sort().join(", ")}`),await Lm(r.app.packageJson),r.app.templates.length>0&&N.info(`Deployed templates: ${r.app.templates.map(s=>s.id).sort().join(", ")}`),r.app.slots.length>0&&N.info(`Deployed slots: ${r.app.slots.map(s=>s.id).sort().join(", ")}`),r.app.collections.length>0&&N.info(`Deployed collections: ${r.app.collections.map(s=>s.id).sort().join(", ")}`)}catch(t){Be.stop(),N.error(ht(t,Tt.DEFAULT)),ae.exit(1)}finally{rm()}}const Um={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Mm(e,t){const n=Um[e];return n?n(t):t.id}const Fm=new Set(["content","design"]);function Un(e,t,n=0,r=[]){if(n>=t.length)return r;const o=t[n],i=t[n+1];if(typeof o=="string"&&typeof i=="number"&&ft(e)){const s=e[o],a=Array.isArray(s)?s[i]:void 0;if(ft(a)){const c=Mm(o,a);return r.push(`${o}[${c||i}]`),Un(a,t,n+2,r)}}if(typeof o=="string"&&typeof i=="string"&&Fm.has(o)){r.push(`${o}[${i}]`);const s=ft(e)&&!Array.isArray(e)?e[o]:void 0,a=ft(s)&&!Array.isArray(s)?s[i]:void 0;return Un(a,t,n+2,r)}return r.push(o),Un(ft(e)?e[o]:void 0,t,n+1,r)}function zm(e){const t=e.errors.map(r=>Un(e.manifest,r.path).join(".")),n={path:Math.max(...t.map(r=>r.length),0),message:Math.max(...e.errors.map(r=>r.message.length),0)};e.errors.map((r,o)=>{const i=r.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[o].padEnd(n.path," ")} | ${r.message.padEnd(n.message," ")} | ${i}`}).forEach(r=>N.error(r))}async function Gm(e){const t=Nh.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const bi={"process.env":{NODE_ENV:"production"}},Hm=[..._o,..._o.map(e=>`node:${e}`)],jm=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],$i=e=>({pluginType:Ge.Server,define:bi,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...Hm,...jm],inlineDynamicImports:!0,...e,outDir:e.outDir}),Ni=e=>({pluginType:Ge.Client,define:bi,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),xt=e=>({pluginType:Ge.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),Bm=e=>({pluginType:Ge.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),Mn=e=>({pluginType:Ge.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let Fn=!1;function Zm(e){Fn=e}function Pr(){return Fn}const Li=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Vm=80,Wm="\x1B[?25l",Km="\x1B[?25h",Ym="\x1B[2K\r",Xm=44;let Qm=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){Fn||(this.frameIndex=0,this.buffer=[],this.realWrite=process.stdout.write.bind(process.stdout),process.stdout.write=((t,n,r)=>(this.buffer.push(typeof t=="string"?t:String(t)),typeof n=="function"&&(r=n),r&&r(),!0)),this.realWrite(Wm),this.render(),this.timer=setInterval(()=>this.render(),Vm))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(Xm-1," "),n=Ke(Li[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%Li.length}stop(){if(!Fn&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${Ym}${Km}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Di=new Qm,qm=()=>Da({ext:".gz",algorithm:"gzip",verbose:Pr()}),Jm="/* EXTERNAL_IMPORTS_START */",eE="/* EXTERNAL_IMPORTS_END */",tE=()=>({name:"external-imports-wrapper-plugin",enforce:"post",apply:"build",generateBundle(e,t){for(const n of Object.keys(t)){const r=t[n];if(r.type==="chunk"){const o=/import.*\?commonjs-external["'];/g,i=r.code.match(o);if(i!==null){const s=i.join(""),a=Jm+s+eE,c=r.code.replace(o,"");r.code=a+c}}}}}),nE=()=>({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})}}),rE=()=>{const e=process.env.npm_lifecycle_event;return xa({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"`}})},Je={vue:()=>ka(),tsconfigPaths:()=>Pa(),checker:()=>rE()};class Zn{constructor(t){this.bits=t instanceof Zn?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class Jt{constructor(t,n,r){this.start=t,this.end=n,this.original=r,this.intro="",this.outro="",this.content=r,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 Jt(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,r){return this.content=t,r||(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,r=this.original.slice(0,n),o=this.original.slice(n);this.original=r;const i=new Jt(t,this.end,o);return i.outro=this.outro,this.outro="",this.end=t,this.edited?(i.edit("",!1),this.content=""):this.content=r,i.next=this.next,i.next&&(i.next.previous=i),i.previous=this,this.next=i,i}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 r=this.split(this.end-n.length);this.edited&&r.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 oE(){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 sE=oE();class iE{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Ua(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,"+sE(this.toString())}}function aE(e){const t=e.split(`
|
|
27
|
-
`),n=t.filter(i=>/^\t+/.test(i)),r=t.filter(i=>/^ {2,}/.test(i));if(n.length===0&&r.length===0)return null;if(n.length>=r.length)return" ";const o=r.reduce((i,s)=>{const a=/^ +/.exec(s)[0].length;return Math.min(a,i)},1/0);return new Array(o+1).join(" ")}function cE(e,t){const n=e.split(/[/\\]/),r=t.split(/[/\\]/);for(n.pop();n[0]===r[0];)n.shift(),r.shift();if(n.length){let o=n.length;for(;o--;)n[o]=".."}return n.concat(r).join("/")}const uE=Object.prototype.toString;function lE(e){return uE.call(e)==="[object Object]"}function ki(e){const t=e.split(`
|
|
28
|
-
`)
|
|
37
|
+
`)}w.write("payload.value = newResult;"),w.write("return payload;");const R=w.compile();return(p,l)=>R(T,p,l)};let i;const s=Wt,a=!ur.jitless,u=a&&mc.value,f=t.catchall;let h;e._zod.parse=(T,w)=>{h??(h=r.value);const k=T.value;return s(k)?a&&u&&w?.async===!1&&w.jitless!==!0?(i||(i=o(t.shape)),T=i(T,w),f?ss([],k,T,w,h,e):T):n(T,w):(T.issues.push({expected:"object",code:"invalid_type",input:k,inst:e}),T)}});function is(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Dt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>_t(s,r,lt())))}),t)}const as=g("$ZodUnion",(e,t)=>{me.init(e,t),ne(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>fr(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>is(c,o,e,i)):is(a,o,e,i)}}),tl=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,as.init(e,t);const n=e._zod.parse;ne(e._zod,"propValues",()=>{const o={};for(const i of t.options){const s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,c]of Object.entries(s)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const r=hn(()=>{const o=t.options,i=new Map;for(const s of o){const a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const c of a){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(o,i)=>{const s=o.value;if(!Wt(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),nl=g("$ZodIntersection",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>cs(n,c,u)):cs(n,i,s)}});function Er(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Nt(e)&&Nt(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Er(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Er(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cs(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),Dt(e))return e;const s=Er(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const rl=g("$ZodRecord",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Nt(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const f=t.valueType._zod.run({value:o[u],issues:[]},r);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...kt(u,h.issues)),n.value[u]=h.value})):(f.issues.length&&n.issues.push(...kt(u,f.issues)),n.value[u]=f.value)}let c;for(const u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Qo.test(a)&&c.issues.length){const h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(c=h)}if(c.issues.length){t.mode==="loose"?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>_t(h,r,lt())),input:a,path:[a],inst:e});continue}const f=t.valueType._zod.run({value:o[a],issues:[]},r);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...kt(a,h.issues)),n.value[c.value]=h.value})):(f.issues.length&&n.issues.push(...kt(a,f.issues)),n.value[c.value]=f.value)}}return i.length?Promise.all(i).then(()=>n):n}}),ol=g("$ZodEnum",(e,t)=>{me.init(e,t);const n=Uo(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>gc.has(typeof o)).map(o=>typeof o=="string"?Lt(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),sl=g("$ZodLiteral",(e,t)=>{if(me.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Lt(r):r?Lt(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),il=g("$ZodTransform",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mo(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new $t;return n.value=o,n}});function us(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const ls=g("$ZodOptional",(e,t)=>{me.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fr(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>us(i,n.value)):us(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),al=g("$ZodExactOptional",(e,t)=>{ls.init(e,t),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),cl=g("$ZodNullable",(e,t)=>{me.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fr(n.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),ul=g("$ZodDefault",(e,t)=>{me.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>ps(i,t)):ps(o,t)}});function ps(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ll=g("$ZodPrefault",(e,t)=>{me.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),pl=g("$ZodNonOptional",(e,t)=>{me.init(e,t),ne(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>fs(i,e)):fs(o,e)}});function fs(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const fl=g("$ZodCatch",(e,t)=>{me.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>_t(s,r,lt()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>_t(i,r,lt()))},input:n.value}),n.issues=[]),n)}}),dl=g("$ZodPipe",(e,t)=>{me.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>Sn(s,t.in,r)):Sn(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Sn(i,t.out,r)):Sn(o,t.out,r)}});function Sn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const hl=g("$ZodReadonly",(e,t)=>{me.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>t.innerType?._zod?.optin),ne(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(ds):ds(o)}});function ds(e){return e.value=Object.freeze(e.value),e}const ml=g("$ZodCustom",(e,t)=>{Pe.init(e,t),me.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>hs(i,n,r,e));hs(o,n,r,e)}});function hs(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Kt(o))}}var ms;class gl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function El(){return new gl}(ms=globalThis).__zod_globalRegistry??(ms.__zod_globalRegistry=El());const Yt=globalThis.__zod_globalRegistry;function _l(e,t){return new e({type:"string",...x(t)})}function yl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function gs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function Sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function Tl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function Rl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function Ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function Es(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function vl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function Cl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function wl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function Il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function Al(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function bl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function $l(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function Nl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function Ll(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function Dl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function kl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function Pl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function xl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function zl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function Ml(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function Ul(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function jl(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function Fl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function Gl(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function Hl(e,t){return new e({type:"number",checks:[],...x(t)})}function Bl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function Zl(e,t){return new e({type:"boolean",...x(t)})}function Vl(e){return new e({type:"unknown"})}function Wl(e,t){return new e({type:"never",...x(t)})}function _s(e,t){return new Jo({check:"less_than",...x(t),value:e,inclusive:!1})}function _r(e,t){return new Jo({check:"less_than",...x(t),value:e,inclusive:!0})}function ys(e,t){return new es({check:"greater_than",...x(t),value:e,inclusive:!1})}function yr(e,t){return new es({check:"greater_than",...x(t),value:e,inclusive:!0})}function Ss(e,t){return new uu({check:"multiple_of",...x(t),value:e})}function Ts(e,t){return new pu({check:"max_length",...x(t),maximum:e})}function Tn(e,t){return new fu({check:"min_length",...x(t),minimum:e})}function Rs(e,t){return new du({check:"length_equals",...x(t),length:e})}function Kl(e,t){return new hu({check:"string_format",format:"regex",...x(t),pattern:e})}function Yl(e){return new mu({check:"string_format",format:"lowercase",...x(e)})}function Xl(e){return new gu({check:"string_format",format:"uppercase",...x(e)})}function Ql(e,t){return new Eu({check:"string_format",format:"includes",...x(t),includes:e})}function ql(e,t){return new _u({check:"string_format",format:"starts_with",...x(t),prefix:e})}function Jl(e,t){return new yu({check:"string_format",format:"ends_with",...x(t),suffix:e})}function Pt(e){return new Su({check:"overwrite",tx:e})}function ep(e){return Pt(t=>t.normalize(e))}function tp(){return Pt(e=>e.trim())}function np(){return Pt(e=>e.toLowerCase())}function rp(){return Pt(e=>e.toUpperCase())}function op(){return Pt(e=>hc(e))}function sp(e,t,n){return new e({type:"array",element:t,...x(n)})}function ip(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}function ap(e){const t=cp(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Kt(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Kt(o))}},e(n.value,n)));return t}function cp(e,t){const n=new Pe({check:"custom",...x(t)});return n._zod.check=e,n}function Os(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Yt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function ve(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,f);else{const T=s.schema,w=t.processors[o.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);w(e,t,T,f)}const h=e._zod.parent;h&&(s.ref||(s.ref=h),ve(h,t,f),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&Le(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function vs(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(s[0])?.id,T=e.external.uri??(k=>k);if(h)return{ref:T(h)};const w=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=w,{defId:w,ref:`${T("__shared")}#/${a}/${w}`}}if(s[1]===n)return{ref:"#"};const u=`#/${a}/`,f=s[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+f}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const h in f)delete f[h];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
38
|
+
|
|
39
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function Cs(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const a=e.seen.get(s);if(a.ref===null)return;const c=a.def??a.schema,u={...c},f=a.ref;if(a.ref=null,f){r(f);const T=e.seen.get(f),w=T.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(w)):Object.assign(c,w),Object.assign(c,u),s._zod.parent===f)for(const M in c)M==="$ref"||M==="allOf"||M in u||delete c[M];if(w.$ref&&T.def)for(const M in c)M==="$ref"||M==="allOf"||M in T.def&&JSON.stringify(c[M])===JSON.stringify(T.def[M])&&delete c[M]}const h=s._zod.parent;if(h&&h!==f){r(h);const T=e.seen.get(h);if(T?.schema.$ref&&(c.$ref=T.schema.$ref,T.def))for(const w in c)w==="$ref"||w==="allOf"||w in T.def&&JSON.stringify(c[w])===JSON.stringify(T.def[w])&&delete c[w]}e.override({zodSchema:s,jsonSchema:c,path:a.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const a=s[1];a.def&&a.defId&&(i[a.defId]=a.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rn(t,"input",e.processors),output:Rn(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Le(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Le(r.element,n);if(r.type==="set")return Le(r.valueType,n);if(r.type==="lazy")return Le(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Le(r.innerType,n);if(r.type==="intersection")return Le(r.left,n)||Le(r.right,n);if(r.type==="record"||r.type==="map")return Le(r.keyType,n)||Le(r.valueType,n);if(r.type==="pipe")return Le(r.in,n)||Le(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Le(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Le(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Le(o,n))return!0;return!!(r.rest&&Le(r.rest,n))}return!1}const up=(e,t={})=>n=>{const r=Os({...n,processors:t});return ve(e,r),vs(r,e),Cs(r,e)},Rn=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Os({...o??{},target:i,io:t,processors:n});return ve(e,s),vs(s,e),Cs(s,e)},lp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pp=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=lp[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},fp=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof i=="number"&&(o.minimum=i,typeof f=="number"&&t.target!=="draft-04"&&(f>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof s=="number"&&(o.maximum=s,typeof u=="number"&&t.target!=="draft-04"&&(u<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},dp=(e,t,n,r)=>{n.type="boolean"},hp=(e,t,n,r)=>{n.not={}},mp=(e,t,n,r)=>{},gp=(e,t,n,r)=>{const o=e._zod.def,i=Uo(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Ep=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},_p=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Sp=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ve(i.element,t,{...r,path:[...r.path,"items"]})},Tp=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=ve(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const f=i.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=ve(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Rp=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>ve(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},Op=(e,t,n,r)=>{const o=e._zod.def,i=ve(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=ve(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},vp=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const f=ve(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const h of c)o.patternProperties[h.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=ve(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=ve(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=s._zod.values;if(u){const f=[...u].filter(h=>typeof h=="string"||typeof h=="number");f.length>0&&(o.required=f)}},Cp=(e,t,n,r)=>{const o=e._zod.def,i=ve(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},wp=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ip=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ap=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},bp=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},$p=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;ve(i,t,r);const s=t.seen.get(e);s.ref=i},Np=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},ws=(e,t,n,r)=>{const o=e._zod.def;ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Lp=g("ZodISODateTime",(e,t)=>{ku.init(e,t),Ee.init(e,t)});function Dp(e){return Ul(Lp,e)}const kp=g("ZodISODate",(e,t)=>{Pu.init(e,t),Ee.init(e,t)});function Pp(e){return jl(kp,e)}const xp=g("ZodISOTime",(e,t)=>{xu.init(e,t),Ee.init(e,t)});function zp(e){return Fl(xp,e)}const Mp=g("ZodISODuration",(e,t)=>{zu.init(e,t),Ee.init(e,t)});function Up(e){return Gl(Mp,e)}const jp=(e,t)=>{Zo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ic(e,n)},flatten:{value:n=>wc(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,lr,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,lr,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ze=g("ZodError",jp,{Parent:Error}),Fp=hr(Ze),Gp=mr(Ze),Hp=gn(Ze),Bp=En(Ze),Zp=$c(Ze),Vp=Nc(Ze),Wp=Lc(Ze),Kp=Dc(Ze),Yp=kc(Ze),Xp=Pc(Ze),Qp=xc(Ze),qp=zc(Ze),ge=g("ZodType",(e,t)=>(me.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Rn(e,"input"),output:Rn(e,"output")}}),e.toJSONSchema=up(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(gt(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>Et(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Fp(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Hp(e,n,r),e.parseAsync=async(n,r)=>Gp(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Bp(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Zp(e,n,r),e.decode=(n,r)=>Vp(e,n,r),e.encodeAsync=async(n,r)=>Wp(e,n,r),e.decodeAsync=async(n,r)=>Kp(e,n,r),e.safeEncode=(n,r)=>Yp(e,n,r),e.safeDecode=(n,r)=>Xp(e,n,r),e.safeEncodeAsync=async(n,r)=>Qp(e,n,r),e.safeDecodeAsync=async(n,r)=>qp(e,n,r),e.refine=(n,r)=>e.check(Zf(n,r)),e.superRefine=n=>e.check(Vf(n)),e.overwrite=n=>e.check(Pt(n)),e.optional=()=>Ps(e),e.exactOptional=()=>Lf(e),e.nullable=()=>xs(e),e.nullish=()=>Ps(xs(e)),e.nonoptional=n=>Mf(e,n),e.array=()=>oe(e),e.or=n=>xt([e,n]),e.and=n=>wf(e,n),e.transform=n=>Ms(e,$f(n)),e.default=n=>Pf(e,n),e.prefault=n=>zf(e,n),e.catch=n=>jf(e,n),e.pipe=n=>Ms(e,n),e.readonly=()=>Hf(e),e.describe=n=>{const r=e.clone();return Yt.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Yt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Yt.get(e);const r=e.clone();return Yt.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Is=g("_ZodString",(e,t)=>{gr.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,i)=>pp(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Kl(...r)),e.includes=(...r)=>e.check(Ql(...r)),e.startsWith=(...r)=>e.check(ql(...r)),e.endsWith=(...r)=>e.check(Jl(...r)),e.min=(...r)=>e.check(Tn(...r)),e.max=(...r)=>e.check(Ts(...r)),e.length=(...r)=>e.check(Rs(...r)),e.nonempty=(...r)=>e.check(Tn(1,...r)),e.lowercase=r=>e.check(Yl(r)),e.uppercase=r=>e.check(Xl(r)),e.trim=()=>e.check(tp()),e.normalize=(...r)=>e.check(ep(...r)),e.toLowerCase=()=>e.check(np()),e.toUpperCase=()=>e.check(rp()),e.slugify=()=>e.check(op())}),Jp=g("ZodString",(e,t)=>{gr.init(e,t),Is.init(e,t),e.email=n=>e.check(yl(ef,n)),e.url=n=>e.check(Es(bs,n)),e.jwt=n=>e.check(Ml(gf,n)),e.emoji=n=>e.check(vl(tf,n)),e.guid=n=>e.check(gs(As,n)),e.uuid=n=>e.check(Sl(On,n)),e.uuidv4=n=>e.check(Tl(On,n)),e.uuidv6=n=>e.check(Rl(On,n)),e.uuidv7=n=>e.check(Ol(On,n)),e.nanoid=n=>e.check(Cl(nf,n)),e.guid=n=>e.check(gs(As,n)),e.cuid=n=>e.check(wl(rf,n)),e.cuid2=n=>e.check(Il(of,n)),e.ulid=n=>e.check(Al(sf,n)),e.base64=n=>e.check(Pl(df,n)),e.base64url=n=>e.check(xl(hf,n)),e.xid=n=>e.check(bl(af,n)),e.ksuid=n=>e.check($l(cf,n)),e.ipv4=n=>e.check(Nl(uf,n)),e.ipv6=n=>e.check(Ll(lf,n)),e.cidrv4=n=>e.check(Dl(pf,n)),e.cidrv6=n=>e.check(kl(ff,n)),e.e164=n=>e.check(zl(mf,n)),e.datetime=n=>e.check(Dp(n)),e.date=n=>e.check(Pp(n)),e.time=n=>e.check(zp(n)),e.duration=n=>e.check(Up(n))});function A(e){return _l(Jp,e)}const Ee=g("ZodStringFormat",(e,t)=>{fe.init(e,t),Is.init(e,t)}),ef=g("ZodEmail",(e,t)=>{Cu.init(e,t),Ee.init(e,t)}),As=g("ZodGUID",(e,t)=>{Ou.init(e,t),Ee.init(e,t)}),On=g("ZodUUID",(e,t)=>{vu.init(e,t),Ee.init(e,t)}),bs=g("ZodURL",(e,t)=>{wu.init(e,t),Ee.init(e,t)});function $s(e){return Es(bs,e)}const tf=g("ZodEmoji",(e,t)=>{Iu.init(e,t),Ee.init(e,t)}),nf=g("ZodNanoID",(e,t)=>{Au.init(e,t),Ee.init(e,t)}),rf=g("ZodCUID",(e,t)=>{bu.init(e,t),Ee.init(e,t)}),of=g("ZodCUID2",(e,t)=>{$u.init(e,t),Ee.init(e,t)}),sf=g("ZodULID",(e,t)=>{Nu.init(e,t),Ee.init(e,t)}),af=g("ZodXID",(e,t)=>{Lu.init(e,t),Ee.init(e,t)}),cf=g("ZodKSUID",(e,t)=>{Du.init(e,t),Ee.init(e,t)}),uf=g("ZodIPv4",(e,t)=>{Mu.init(e,t),Ee.init(e,t)}),lf=g("ZodIPv6",(e,t)=>{Uu.init(e,t),Ee.init(e,t)}),pf=g("ZodCIDRv4",(e,t)=>{ju.init(e,t),Ee.init(e,t)}),ff=g("ZodCIDRv6",(e,t)=>{Fu.init(e,t),Ee.init(e,t)}),df=g("ZodBase64",(e,t)=>{Gu.init(e,t),Ee.init(e,t)}),hf=g("ZodBase64URL",(e,t)=>{Bu.init(e,t),Ee.init(e,t)}),mf=g("ZodE164",(e,t)=>{Zu.init(e,t),Ee.init(e,t)}),gf=g("ZodJWT",(e,t)=>{Wu.init(e,t),Ee.init(e,t)}),Ns=g("ZodNumber",(e,t)=>{ns.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,i)=>fp(e,r,o),e.gt=(r,o)=>e.check(ys(r,o)),e.gte=(r,o)=>e.check(yr(r,o)),e.min=(r,o)=>e.check(yr(r,o)),e.lt=(r,o)=>e.check(_s(r,o)),e.lte=(r,o)=>e.check(_r(r,o)),e.max=(r,o)=>e.check(_r(r,o)),e.int=r=>e.check(Ve(r)),e.safe=r=>e.check(Ve(r)),e.positive=r=>e.check(ys(0,r)),e.nonnegative=r=>e.check(yr(0,r)),e.negative=r=>e.check(_s(0,r)),e.nonpositive=r=>e.check(_r(0,r)),e.multipleOf=(r,o)=>e.check(Ss(r,o)),e.step=(r,o)=>e.check(Ss(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function vn(e){return Hl(Ns,e)}const Ef=g("ZodNumberFormat",(e,t)=>{Ku.init(e,t),Ns.init(e,t)});function Ve(e){return Bl(Ef,e)}const _f=g("ZodBoolean",(e,t)=>{Yu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dp(e,n,r)});function J(e){return Zl(_f,e)}const yf=g("ZodUnknown",(e,t)=>{Xu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mp()});function Ls(){return Vl(yf)}const Sf=g("ZodNever",(e,t)=>{Qu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hp(e,n,r)});function Tf(e){return Wl(Sf,e)}const Rf=g("ZodArray",(e,t)=>{qu.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sp(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Tn(n,r)),e.nonempty=n=>e.check(Tn(1,n)),e.max=(n,r)=>e.check(Ts(n,r)),e.length=(n,r)=>e.check(Rs(n,r)),e.unwrap=()=>e.element});function oe(e,t){return sp(Rf,e,t)}const Of=g("ZodObject",(e,t)=>{el.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Tp(e,n,r,o),ne(e,"shape",()=>t.shape),e.keyof=()=>_e(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ls()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ls()}),e.strict=()=>e.clone({...e._zod.def,catchall:Tf()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Tc(e,n),e.safeExtend=n=>Rc(e,n),e.merge=n=>Oc(e,n),e.pick=n=>yc(e,n),e.omit=n=>Sc(e,n),e.partial=(...n)=>vc(ks,e,n[0]),e.required=(...n)=>Cc(zs,e,n[0])});function O(e,t){const n={type:"object",shape:e??{},...x(t)};return new Of(n)}const Ds=g("ZodUnion",(e,t)=>{as.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rp(e,n,r,o),e.options=t.options});function xt(e,t){return new Ds({type:"union",options:e,...x(t)})}const vf=g("ZodDiscriminatedUnion",(e,t)=>{Ds.init(e,t),tl.init(e,t)});function We(e,t,n){return new vf({type:"union",options:t,discriminator:e,...x(n)})}const Cf=g("ZodIntersection",(e,t)=>{nl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Op(e,n,r,o)});function wf(e,t){return new Cf({type:"intersection",left:e,right:t})}const If=g("ZodRecord",(e,t)=>{rl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vp(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function De(e,t,n){return new If({type:"record",keyType:e,valueType:t,...x(n)})}const Sr=g("ZodEnum",(e,t)=>{ol.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,i)=>gp(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Sr({...t,checks:[],...x(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Sr({...t,checks:[],...x(o),entries:i})}});function _e(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Sr({type:"enum",entries:n,...x(t)})}const Af=g("ZodLiteral",(e,t)=>{sl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ep(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new Af({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const bf=g("ZodTransform",(e,t)=>{il.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yp(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Mo(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Kt(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Kt(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function $f(e){return new bf({type:"transform",transform:e})}const ks=g("ZodOptional",(e,t)=>{ls.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ps(e){return new ks({type:"optional",innerType:e})}const Nf=g("ZodExactOptional",(e,t)=>{al.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Lf(e){return new Nf({type:"optional",innerType:e})}const Df=g("ZodNullable",(e,t)=>{cl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new Df({type:"nullable",innerType:e})}const kf=g("ZodDefault",(e,t)=>{ul.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ip(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Pf(e,t){return new kf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ho(t)}})}const xf=g("ZodPrefault",(e,t)=>{ll.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ap(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function zf(e,t){return new xf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ho(t)}})}const zs=g("ZodNonOptional",(e,t)=>{pl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Mf(e,t){return new zs({type:"nonoptional",innerType:e,...x(t)})}const Uf=g("ZodCatch",(e,t)=>{fl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jf(e,t){return new Uf({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ff=g("ZodPipe",(e,t)=>{dl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$p(e,n,r,o),e.in=t.in,e.out=t.out});function Ms(e,t){return new Ff({type:"pipe",in:e,out:t})}const Gf=g("ZodReadonly",(e,t)=>{hl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Np(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Hf(e){return new Gf({type:"readonly",innerType:e})}const Bf=g("ZodCustom",(e,t)=>{ml.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_p(e,n)});function Zf(e,t={}){return ip(Bf,e,t)}function Vf(e){return ap(e)}const Wf={url:"must be a valid URL",email:"must be a valid email address"},Kf=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Yf=e=>e===null?"null":typeof e,Xf=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Kf(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Yf(t)}`}}case"invalid_format":{const t=Wf[e.format];return t?{message:t}:void 0}case"unrecognized_keys":return{message:`Unrecognized property: ${e.keys.map(t=>`'${t}'`).join(", ")}`};case"invalid_union":{const t=e.path?.at(-1);return typeof t=="string"?{message:`'${t}' is required or has invalid value`}:void 0}case"invalid_value":{const{values:t}=e;return t?{message:`Expected one of: ${t.map(n=>`'${String(n)}'`).join(", ")}`}:void 0}case"invalid_key":{const t=e.issues?.[0];return t?{message:t.message}:void 0}default:return}},V={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};_e(Object.values(V));const Q={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};_e(Object.values(Q));const zt={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Qf=_e(Object.values(zt)),Xt={CONTENT:"Content",DESIGN:"Design"};_e(Object.values(Xt));const qf={TEXT:"TEXT",IMAGE:"IMAGE"},Jf=_e(Object.values(qf)),yt={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"},ed=_e(Object.values(yt)),Cn={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},td=_e(Object.values(Cn)),nd={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},rd=_e(Object.values(nd)),od={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},sd=_e(Object.values(od)),id={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},ad=_e(Object.values(id)),Tr={COLOR:"COLOR",GRADIENT:"GRADIENT"},cd=_e(Object.values(Tr));_e(["none","all","small"]);const Ot={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Us={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},ud=_e(Object.values(Ot));_e(Object.values(Us));const ld={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},pd=_e(Object.values(ld)),fd={HEADER_LEFT:"HEADER_LEFT",HEADER_CENTER_LOGO_BURGER:"HEADER_CENTER_LOGO_BURGER",HEADER_CENTER_LOGO_COMPACT:"HEADER_CENTER_LOGO_COMPACT",HEADER_CENTER_LOGO_DETAILED:"HEADER_CENTER_LOGO_DETAILED",HEADER_LEFT_LOGO_BURGER:"HEADER_LEFT_LOGO_BURGER",HEADER_LEFT_LOGO_COMPACT:"HEADER_LEFT_LOGO_COMPACT",HEADER_LEFT_LOGO_DETAILED:"HEADER_LEFT_LOGO_DETAILED",HEADER_LEFT_LOGO_SEARCH:"HEADER_LEFT_LOGO_SEARCH",HEADER_LEFT_LOGO_TEXT:"HEADER_LEFT_LOGO_TEXT",TEXT_ONE_COLUMN:"TEXT_ONE_COLUMN",TEXT_TITLE_LEFT:"TEXT_TITLE_LEFT",TEXT_SUBTITLE_RIGHT:"TEXT_SUBTITLE_RIGHT",TEXT_TWO_COLUMNS:"TEXT_TWO_COLUMNS",TEXT_CENTER:"TEXT_CENTER",TEXT_DESCRIPTION_RIGHT:"TEXT_DESCRIPTION_RIGHT",CTA_BANNER_LEFT:"CTA_BANNER_LEFT",CTA_BANNER_RIGHT:"CTA_BANNER_RIGHT",CTA_BANNER_CENTER:"CTA_BANNER_CENTER",CTA_BANNER_BOTTOM:"CTA_BANNER_BOTTOM",CTA_PROMO_BAR_LEFT:"CTA_PROMO_BAR_LEFT",CTA_PROMO_BAR_RIGHT:"CTA_PROMO_BAR_RIGHT",CTA_STORY_LEFT:"CTA_STORY_LEFT",CTA_STORY_RIGHT:"CTA_STORY_RIGHT",CTA_FULLWIDTH_CENTER:"CTA_FULLWIDTH_CENTER",CTA_FULLWIDTH_LEFT:"CTA_FULLWIDTH_LEFT",CTA_FULLWIDTH_NO_IMAGE:"CTA_FULLWIDTH_NO_IMAGE",COVER_FULLSCREEN_CENTER:"COVER_FULLSCREEN_CENTER",COVER_FULLSCREEN_LEFT:"COVER_FULLSCREEN_LEFT",COVER_FULLSCREEN_CENTER_LEFT:"COVER_FULLSCREEN_CENTER_LEFT",COVER_FULLSCREEN_RIGHT:"COVER_FULLSCREEN_RIGHT",COVER_FULLSCREEN_BOTTOM:"COVER_FULLSCREEN_BOTTOM",COVER_FULLSCREEN_BOTTOM_RIGHT:"COVER_FULLSCREEN_BOTTOM_RIGHT",COVER_FULLSCREEN_BOTTOM_LEFT:"COVER_FULLSCREEN_BOTTOM_LEFT",COVER_FULLSCREEN_TOP:"COVER_FULLSCREEN_TOP",COVER_SIDEBAR_RIGHT:"COVER_SIDEBAR_RIGHT",COVER_SIDEBAR_LEFT:"COVER_SIDEBAR_LEFT",COVER_HALFSCREEN_LEFT:"COVER_HALFSCREEN_LEFT",COVER_HALFSCREEN_CENTER:"COVER_HALFSCREEN_CENTER",COVER_COLLAGE_BOTTOM:"COVER_COLLAGE_BOTTOM",COVER_COLLAGE_LEFT:"COVER_COLLAGE_LEFT",IMAGE_SUBTITLE_RIGHT:"IMAGE_SUBTITLE_RIGHT",IMAGE_TITLE_LEFT:"IMAGE_TITLE_LEFT",IMAGE_LEFT:"IMAGE_LEFT",IMAGE_RIGHT:"IMAGE_RIGHT",IMAGE_CENTER:"IMAGE_CENTER",IMAGE_SIDE_TITLE:"IMAGE_SIDE_TITLE",LOCATION_MAP_RIGHT:"LOCATION_MAP_RIGHT",LOCATION_MAP_LEFT:"LOCATION_MAP_LEFT",LOCATION_IMAGE_RIGHT:"LOCATION_IMAGE_RIGHT",LOCATION_IMAGE_LEFT:"LOCATION_IMAGE_LEFT",LOCATION_BACKGROUND_RIGHT:"LOCATION_BACKGROUND_RIGHT",LOCATION_BACKGROUND_LEFT:"LOCATION_BACKGROUND_LEFT",LOCATION_FULL:"LOCATION_FULL",LOCATION_SHORT:"LOCATION_SHORT",REVIEWS_MINIMAL:"REVIEWS_MINIMAL",REVIEWS_CARDS:"REVIEWS_CARDS",REVIEWS:"REVIEWS",REVIEWS_CLASSIC:"REVIEWS_CLASSIC",REVIEWS_FULLSCREEN_BG:"REVIEWS_FULLSCREEN_BG",REVIEWS_FULLSCREEN_SIDEBAR_LEFT:"REVIEWS_FULLSCREEN_SIDEBAR_LEFT",REVIEWS_FULLSCREEN_SIDEBAR_RIGHT:"REVIEWS_FULLSCREEN_SIDEBAR_RIGHT",REVIEWS_CARDS_PHOTO:"REVIEWS_CARDS_PHOTO",REVIEWS_PHOTO_SPEECH_RIGHT:"REVIEWS_PHOTO_SPEECH_RIGHT",REVIEWS_PHOTO_SPEECH_LEFT:"REVIEWS_PHOTO_SPEECH_LEFT",REVIEWS_SOCIAL_FEED:"REVIEWS_SOCIAL_FEED",REVIEWS_ADAPTIVE:"REVIEWS_ADAPTIVE",FEATURES_CLASSIC_CENTER:"FEATURES_CLASSIC_CENTER",FEATURES_CLASSIC_LEFT:"FEATURES_CLASSIC_LEFT",FEATURES_ACCORDION:"FEATURES_ACCORDION",FEATURES_MINIMAL:"FEATURES_MINIMAL",FEATURES_SMALL_ICONS:"FEATURES_SMALL_ICONS",FEATURES_CAROUSEL:"FEATURES_CAROUSEL",FEATURES_IMAGE_LEFT:"FEATURES_IMAGE_LEFT",FEATURES_IMAGE_RIGHT:"FEATURES_IMAGE_RIGHT",ANNOUNCEMENT_CENTER:"ANNOUNCEMENT_CENTER",SLIDER_FULLSCREEN_CENTER:"SLIDER_FULLSCREEN_CENTER",SLIDER_FULLSCREEN_LEFT:"SLIDER_FULLSCREEN_LEFT",SLIDER_BASIC:"SLIDER_BASIC",SLIDER_CAROUSEL:"SLIDER_CAROUSEL",SLIDER_CAROUSEL_PORTRAIT:"SLIDER_CAROUSEL_PORTRAIT",SLIDER_SPLIT:"SLIDER_SPLIT",SLIDER_SPLIT_REVERSE:"SLIDER_SPLIT_REVERSE"},dd=_e(Object.values(fd)),hd={HEADER:"header",COVER:"cover",ANNOUNCEMENT_BAR:"announcement_bar",SLIDER:"slider",SPECIAL_OFFER:"special_offer",CUSTOMER_REVIEW:"customer_review",COMPANY_INFO:"company_info",SHIPPING_PAYMENT:"shipping_payment",LOCATION:"location",STORE:"store",FOOTER:"footer",VIDEO:"video",IMAGE_GALLERY:"image_gallery",CONTACT_INFO:"contact_info",CONTACTS_WIDGET_WHATSAPP:"contacts_widget_whatsapp",CONTACTS_WIDGET_INSTAGRAM:"contacts_widget_instagram",CONTACTS_WIDGET_FACEBOOK:"contacts_widget_facebook",CONTACTS_WIDGET_PHONE:"contacts_widget_phone"},md={COVER:"COVER",ANNOUNCEMENT:"ANNOUNCEMENT",STORE:"STORE",SLIDER:"SLIDER",VIDEO:"VIDEO",SPECIAL_OFFER:"SPECIAL_OFFER",CUSTOMER_REVIEW:"CUSTOMER_REVIEW",COMPANY_INFO:"COMPANY_INFO",SHIPPING_PAYMENT:"SHIPPING_PAYMENT",LOCATION:"LOCATION",COLLECTIONS:"COLLECTIONS",BRANDS:"BRANDS",CONTACT_INFO:"CONTACT_INFO"},gd=_e(Object.values(md)),vt={REQUIRED_HEADER_ID:()=>'Header section must have id "header" when type is "default"',REQUIRED_CUSTOM_HEADER:(...e)=>`Custom header section with id "${e[0]}" must exist in headers directory`,REQUIRED_CUSTOM_HEADER_TYPE:(...e)=>`Custom header section with id "${e[0]}" must be of type "HEADER"`,REQUIRED_FOOTER_ID:()=>'Footer section must have id "footer" when type is "default"',REQUIRED_CUSTOM_FOOTER:(...e)=>`Custom footer section with id "${e[0]}" must exist in footers directory`,REQUIRED_CUSTOM_FOOTER_TYPE:(...e)=>`Custom footer section with id "${e[0]}" must be of type "FOOTER"`,REQUIRED_PAGE_SECTION:(...e)=>`Custom section with id "${e[0]}" must exist in sections directory`,REQUIRED_PAGE_SECTION_TYPE:()=>'Section "header" or "footer" is not allowed among page sections',SHOWCASE_ID_NOT_FOUND:(...e)=>`Showcase with id "${e[0]}" must exist in section's showcase directory`,DUPLICATE_SHOWCASE_ID:(...e)=>`Showcase id "${e[0]}" must be unique within section showcases`,SHOWCASE_OVERRIDE_CONTENT:(...e)=>`Content editor "${e[0]}" in showcase_overrides must exist in section's content configuration file`,SHOWCASE_OVERRIDE_DESIGN:(...e)=>`Design editor "${e[0]}" in showcase_overrides must exist in section's design configuration file`,SHOWCASE_OVERRIDE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase_overrides must exist in section's layout configuration file`,SHOWCASE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase must exist in section's layout configuration file`,INVALID_SHOWCASE_CONTENT_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in content.ts`,SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but content.ts has type "${e[2]}"`,INVALID_SHOWCASE_DESIGN_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in design.ts`,SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but design.ts has type "${e[2]}"`,INVALID_DECK_CARD_SETTING:(...e)=>`Setting "${e[0]}" is not defined in content.ts defaultCardContent.settings`,DECK_SETTINGS_REQUIRED:()=>"settings must have at least one property",INVALID_SELECTBOX_OPTION:(...e)=>`Option value "${e[0]}" for element "${e[1]}" is not defined in content.ts options`,REQUIRED_STORE_LAYOUT:(...e)=>`Store section with id "${e[0]}" and page type "${e[1]}" must have a corresponding layout defined`,INVALID_STORE_SECTION_ID:(...e)=>`Store layout sectionId "${e[0]}" must be one of: ${e[1]}`,REQUIRED_SECTION_ASSET:(...e)=>`Asset size ${e[0]} exceeds threshold of ${e[1]}.`,REQUIRED_SERVER_SIZE:(...e)=>`Size of individual server file [${e[0]}] must not exceed threshold [${e[1]}].`,MISSING_IMAGE_ASSET:(...e)=>`Image ${e[0]} is missing from assets folder`,MANDATORY_SETTING_TYPE_MISMATCH:(...e)=>`Editor type "${e[0]}" for reserved key "${e[1]}" does not match the required type "${e[2]}".`,MANDATORY_SETTING_NAME_MISMATCH:(...e)=>`Editor key "${e[0]}" for overridden content type "${e[1]}" does not match the required key name "${e[2]}".`,DUPLICATED_MANDATORY_SETTING:(...e)=>`Editor type "${e[0]}" can only be used once.`,IMAGE_EDITOR_STATIC_MISMATCH:(...e)=>`Both "${e[0]}" content and design editor need to have same value for attribute static`,DUPLICATE_DESIGN_EDITOR_NAME:()=>"Non-unique design editor name detected",COLOR_REQUIRED_GRADIENT:()=>"color is required when overlay is GRADIENT",COLOR_MUST_BE_ARRAY_GRADIENT:()=>"color must be an array when overlay is GRADIENT",COLOR_ARRAY_LENGTH_GRADIENT:()=>"color array must have exactly 2 items when overlay is GRADIENT",COLOR_REQUIRED_COLOR:()=>"color is required when overlay is COLOR",COLOR_MUST_BE_SINGLE_COLOR:()=>"color must be a single value when overlay is COLOR",COLOR_MUST_BE_UNDEFINED_NONE:()=>"color must be undefined when overlay is NONE or not set",COLOR_REQUIRED_STYLE_GRADIENT:()=>"color is required when style is GRADIENT",COLOR_MUST_BE_ARRAY_STYLE_GRADIENT:()=>"color must be an array when style is GRADIENT",COLOR_ARRAY_LENGTH_STYLE_GRADIENT:()=>"color array must have exactly 2 items when style is GRADIENT",COLOR_REQUIRED_STYLE_COLOR:()=>"color is required when style is COLOR",COLOR_MUST_BE_SINGLE_STYLE_COLOR:()=>"color must be a single value when style is COLOR",BUTTON_LINK_REQUIRED:()=>"link is required when buttonType is HYPER_LINK",BUTTON_CATEGORY_ID_REQUIRED:()=>"categoryId is required when buttonType is GO_TO_CATEGORY or GO_TO_CATEGORY_LINK",BUTTON_EMAIL_REQUIRED:()=>"email is required when buttonType is MAIL_LINK",BUTTON_PHONE_REQUIRED:()=>"phone is required when buttonType is TEL_LINK",BUTTON_TILE_ID_REQUIRED:(...e)=>`${e[0]} is required when buttonType is SCROLL_TO_TILE`,BUTTON_PAGE_ID_REQUIRED:()=>"pageIdForNavigate is required when type is GO_TO_PAGE",TEMPLATE_PAGE_SECTIONS_REQUIRED:()=>"sections must contain at least one section",TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have exactly one section`,TEMPLATE_PAGE_STORE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have a section of type "store"`,TEMPLATE_PAGE_NO_STORE_SECTIONS:(...e)=>`Page type "${e[0]}" cannot contain store sections`,TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED:()=>'Page type "CUSTOM" must have a metadata property',TEMPLATE_PAGE_METADATA_NOT_ALLOWED:(...e)=>`Page type "${e[0]}" must not have a metadata property`,NON_NEGATIVE_INTEGER:()=>"must be a non-negative integer",INTEGER_RANGE:(...e)=>`must be between ${e[0]} and ${e[1]}`,VALID_HEX_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA)",VALID_LANGUAGE_CODE:()=>"must be a valid language code (e.g., en, nl, fr, en_US, en_GB, zh_Hans)",VALID_URL:()=>"must be a valid URL",VALID_EMAIL:()=>"must be a valid email address",ACCORDION_ITEM_POSITION_FIELD_REQUIRED:(...e)=>`Item "${e[0]}" must have positionFieldName when sortable is true`,ACCORDION_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor`,ACCORDION_SHOWCASE_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor override`,ACCORDION_DUPLICATE_POSITION_FIELD_NAME:()=>"positionFieldName must be unique across accordion items when sortable is true",REQUIRED_COLLECTION_NAME:()=>"Collection must have a name in metadata"},Ed=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,_d=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,St=(e,t)=>{const n=vt.INTEGER_RANGE(e.toString(),t.toString());return Ve().min(e,{message:n}).max(t,{message:n})},Rr=O({path:A(),size:vn().nonnegative()}).strict(),js=O({size:vn().nonnegative()}).strict(),z=A().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),yd=O({r:St(0,255),g:St(0,255),b:St(0,255),a:St(0,1)}).strict(),Or=A().regex(Ed,{message:vt.VALID_HEX_COLOR()}),Ue=xt([Or,_e(["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"])]),Fs=_e(["global.textSize.title","global.textSize.subtitle","global.textSize.body"]),Qt=_e(["catalog","category","product"]),wn=A().refine(e=>e.startsWith("#")||$s().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),qt=O({url:A(),width:Ve().min(0,{message:vt.NON_NEGATIVE_INTEGER()}).optional(),height:Ve().min(0,{message:vt.NON_NEGATIVE_INTEGER()}).optional()}).strict(),Sd=O({homogeneity:J().optional(),color:yd.optional()}).strict(),Td=O({ORIGINAL:qt.optional(),WEBP_LOW_RES:qt.optional(),WEBP_HI_2X_RES:qt.optional(),MOBILE_WEBP_LOW_RES:qt.optional(),MOBILE_WEBP_HI_RES:qt.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),In=O({set:Td,borderInfo:Sd.optional()}).strict(),vr=O({type:P(V.IMAGE),imageData:In}).strict(),Gs=O({type:P(V.IMAGE),label:z,static:J().optional(),defaults:vr.optional()}).strict(),Rd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Cr(e){return e===Ot.PRODUCT||e===Ot.CATALOG||e===Ot.CATEGORY}function Hs(e,t,n){if(!e)return;const r=Ya({path:"$..set..url",json:e,resultType:"all"}),o=/^https?:\/\//;r.forEach(i=>{const s=i.value;if(!o.test(s)&&!t.includes(s)){const a=i.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",s)}})}function Bs(e,t,n){e===yt.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Zs(e,t,n){(e===yt.GO_TO_CATEGORY||e===yt.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function Vs(e,t,n){e===yt.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Ws(e,t,n){e===yt.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Ks(e,t,n,r){if(e===yt.SCROLL_TO_TILE&&!(t??n)){const o=t?"tileId":"tileIdForScroll";r.at(o).addIssue("BUTTON_TILE_ID_REQUIRED",o)}}function Od(e,t,n){e===yt.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const vd="custom";function Ie(e,t=[]){const n=o=>Array.isArray(o)?o:[o],r=n(t);return{raw:e,addIssue(o,...i){e.addIssue({code:vd,message:vt[o](...i),path:r,params:{errorMessageKey:o}})},at(o){const i=r.concat(n(o));return Ie(e,i)}}}const wr=O({type:P(V.BUTTON),title:z,buttonType:ed,link:A().optional(),linkTarget:A().optional(),email:A().regex(Rd,{message:vt.VALID_EMAIL()}).optional(),phone:A().optional(),tileId:A().optional(),categoryId:vn().optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Bs(e.buttonType,e.link,n),Zs(e.buttonType,e.categoryId,n),Vs(e.buttonType,e.email,n),Ws(e.buttonType,e.phone,n),Ks(e.buttonType,e.tileId,void 0,n)}),Ys=O({type:P(V.BUTTON),label:z,defaults:wr.optional()}).strict(),Ir=O({type:P(V.CATEGORY_SELECTOR)}).strict(),Xs=O({type:P(V.CATEGORY_SELECTOR),label:z,maxCategories:St(1,32),defaults:Ir.optional()}).strict(),Ar=O({type:P(V.DIVIDER)}).strict(),Qs=O({type:P(V.DIVIDER),label:z,defaults:Ar.optional()}).strict(),Cd=O({label:z,link:wn}).strict(),wd=O({title:z.optional(),link:wn.optional()}).strict(),br=O({type:P(V.INFO),text:z.optional(),button:wd.optional()}).strict(),qs=O({type:P(V.INFO),label:z,description:z,button:Cd.optional(),defaults:br.optional()}).strict(),$r=O({type:P(V.INPUTBOX),text:z}).strict(),Js=O({type:P(V.INPUTBOX),label:z,placeholder:z,defaults:$r.optional()}).strict(),Nr=O({type:P(V.PRODUCT_SELECTOR)}).strict(),ei=O({type:P(V.PRODUCT_SELECTOR),label:z,maxProducts:St(1,32),defaults:Nr.optional()}).strict(),Lr=O({type:P(V.SELECTBOX),value:A()}).strict(),Id=O({value:A().min(1,{message:"value must not be empty"}),label:z}).strict(),ti=O({type:P(V.SELECTBOX),label:z,placeholder:z,description:z,options:oe(Id).min(1,{message:"must have at least one option"}),defaults:Lr.optional()}).strict(),Dr=O({type:P(V.TEXTAREA),text:z}).strict(),ni=O({type:P(V.TEXTAREA),label:z,placeholder:z,defaults:Dr.optional()}).strict(),kr=O({type:P(V.TOGGLE),enabled:J()}).strict(),ri=O({type:P(V.TOGGLE),label:z,description:z,defaults:kr.optional()}).strict(),oi=O({type:P(V.DECK)}).strict(),Ad=We("type",[$r,Dr,wr,vr,kr,Lr,Ar,br,Nr,Ir]),bd=O({type:P(V.DECK),cards:oe(O({settings:De(A(),Ad).superRefine((e,t)=>{Object.keys(e).length<1&&Ie(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),si=[Js,ni,Ys,Gs,ri,ti,Qs,qs,Xs,ei],$d=O({type:P(V.DECK),label:z,addButtonLabel:z,maxCards:Ve().min(1,{message:"must be a positive integer"}),cards:O({defaultCardContent:O({label:z,settings:De(A(),We("type",[...si])).superRefine((e,t)=>{Object.keys(e).length<1&&Ie(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:oi.optional()}).strict(),Nd=We("type",[...si,$d]),Ld=O({type:P(V.DECK),label:z,addButtonLabel:z,maxCards:Ve().min(1,{message:"must be a positive integer"}),cards:O({defaultCardContent:O({label:z,settings:De(A(),Nd).superRefine((e,t)=>{Object.keys(e).length<1&&Ie(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:oi.optional()}).strict(),ii=O({type:P(V.LOGO),logoType:Jf.optional(),text:z.optional(),imageData:In.optional()}).strict(),Dd=O({type:P(V.LOGO),label:z.optional(),defaults:ii.optional()}).strict(),ai=O({id:A(),title:A().optional(),type:A().optional(),link:A().optional(),email:A().optional(),phone:A().optional(),tileIdForScroll:A().optional(),pageIdForNavigate:A().optional(),showStoreCategories:J().optional(),isSubmenuOpened:J().optional(),categoryId:vn().optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Bs(e.type,e.link,n),Zs(e.type,e.categoryId,n),Vs(e.type,e.email,n),Ws(e.type,e.phone,n),Ks(e.type,void 0,e.tileIdForScroll,n),Od(e.type,e.pageIdForNavigate,n)}),ci=O({type:P(V.MENU),items:oe(ai).optional()}).strict(),kd=O({type:P(V.MENU),label:z.optional(),defaults:ci.optional()}).strict(),ui=O({type:P(V.NAVIGATION_MENU),items:oe(ai).optional()}).strict(),Pd=O({type:P(V.NAVIGATION_MENU),defaults:ui.optional()}).strict(),An=O({type:P(Q.BACKGROUND),style:cd.optional(),color:xt([Ue,oe(Ue)]).optional()}).strict().superRefine((e,t)=>{const n=Ie(t).at("color");e.style===Tr.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_STYLE_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_STYLE_GRADIENT"):e.style===Tr.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),xd=O({type:P(Q.BACKGROUND),fieldName:A(),defaults:An.optional()}).strict(),li=O({type:P(Q.BACKGROUND),label:z,colors:oe(Ue).optional(),enableAlphaColor:J().optional(),enableAutoColor:J().optional(),defaults:An.optional()}).strict(),bn=O({type:P(Q.BUTTON),appearance:rd.optional(),size:sd.optional(),shape:ad.optional(),font:A().optional(),color:Ue.optional(),visible:J().optional()}).strict(),zd=O({type:P(Q.BUTTON),fieldName:A(),defaults:bn.optional()}).strict(),pi=O({type:P(Q.BUTTON),label:z,colors:oe(Ue).optional(),enableAutoColor:J().optional(),enableAlphaColor:J().optional(),hideVisibleToggle:J().optional(),hideSize:J().optional(),defaults:bn.optional()}).strict(),$n=O({type:P(Q.COLOR_PICKER),color:Ue.optional()}).strict(),Md=O({type:P(Q.COLOR_PICKER),fieldName:A(),defaults:$n.optional()}).strict(),fi=O({type:P(Q.COLOR_PICKER),label:z,description:z.optional(),colors:oe(Ue).optional(),enableAlphaColor:J().optional(),enableAutoColor:J().optional(),defaults:$n.optional()}).strict(),Nn=O({type:P(Q.DIVIDER)}).strict(),Ud=O({type:P(Q.DIVIDER),fieldName:A(),defaults:Nn.optional()}).strict(),di=O({type:P(Q.DIVIDER),label:z,defaults:Nn.optional()}).strict(),Ln=O({type:P(Q.IMAGE),overlay:td.optional(),color:xt([Ue,oe(Ue)]).optional(),visible:J().optional()}).strict().superRefine((e,t)=>{const n=Ie(t).at("color");e.overlay===Cn.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_GRADIENT"):e.overlay===Cn.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===Cn.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),jd=O({type:P(Q.IMAGE),fieldName:A(),defaults:Ln.optional()}).strict(),hi=O({type:P(Q.IMAGE),label:z,static:J().optional(),colors:oe(Or).optional(),enableAlphaColor:J().optional(),hideVisibleToggle:J().optional(),defaults:Ln.optional()}).strict(),Fd=O({label:z,link:wn}).strict(),Gd=O({label:z.optional(),link:wn.optional()}).strict(),Dn=O({type:P(Q.INFO),description:z.optional(),button:Gd.optional()}).strict(),Hd=O({type:P(Q.INFO),fieldName:A(),defaults:Dn.optional()}).strict(),mi=O({type:P(Q.INFO),label:z,description:z,button:Fd.optional(),defaults:Dn.optional()}).strict(),Bd=O({visible:J(),width:St(1,49).optional(),color:Ue.optional()}).strict(),kn=O({type:P(Q.LOGO),font:A().optional(),size:xt([Ve().min(1,{message:"must be at least 1"}),Fs]).optional(),bold:J().optional(),italic:J().optional(),color:Ue.optional(),visible:J().optional(),spacing:St(1,9).optional(),frame:Bd.optional(),capitalization:_e(["none","all","small"]).optional()}).strict(),Zd=O({type:P(Q.LOGO),fieldName:A(),defaults:kn.optional()}).strict(),gi=O({type:P(Q.LOGO),label:z,colors:oe(Ue).optional(),sizes:oe(Ve().min(1,{message:"must be at least 1"})).optional(),defaults:kn.optional()}).strict(),Vd=O({value:A().optional(),label:z.optional()}).strict(),Pn=O({type:P(Q.SELECTBOX),value:A().optional()}).strict(),Wd=O({type:P(Q.SELECTBOX),fieldName:A(),defaults:Pn.optional()}).strict(),Ei=O({type:P(Q.SELECTBOX),label:z,description:z.optional(),options:oe(Vd).optional(),defaults:Pn.optional()}).strict(),xn=O({type:P(Q.TEXT),font:A().optional(),size:xt([Ve().min(1,{message:"must be at least 1"}),Fs]).optional(),bold:J().optional(),italic:J().optional(),color:Ue.optional(),visible:J().optional()}).strict(),Kd=O({type:P(Q.TEXT),fieldName:A(),defaults:xn.optional()}).strict(),_i=O({type:P(Q.TEXT),label:z,colors:oe(Or).optional(),sizes:oe(Ve().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:J().optional(),enableAutoColor:J().optional(),hideVisibleToggle:J().optional(),hideSize:J().optional(),defaults:xn.optional()}).strict(),zn=O({type:P(Q.TOGGLE),enabled:J().optional()}).strict(),Yd=O({type:P(Q.TOGGLE),fieldName:A(),defaults:zn.optional()}).strict(),yi=O({type:P(Q.TOGGLE),label:z,defaults:zn.optional()}).strict();function Xd(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function Qd(e,t){for(const[n,r]of Object.entries(e))Object.keys(r.editors).length===0&&t.at(["items",n,"editors"]).addIssue("ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED",n)}function qd(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Jd(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function eh(e,t){for(const[n,r]of Object.entries(e))r.positionFieldName||t.at(["items",n,"positionFieldName"]).addIssue("ACCORDION_ITEM_POSITION_FIELD_REQUIRED",n)}function th(e,t){const n=Object.values(e).map(r=>r.positionFieldName).filter(Boolean);new Set(n).size!==n.length&&t.at("items").addIssue("ACCORDION_DUPLICATE_POSITION_FIELD_NAME")}const Si=O({type:P(Q.ACCORDION)}).strict(),nh=We("type",[xn,bn,Ln,zn,Pn,An,$n,kn,Nn,Dn]),rh=O({editors:De(A(),nh)}).strict(),oh=O({type:P(Q.ACCORDION),items:De(A(),rh)}).strict().superRefine((e,t)=>{const n=Ie(t);Xd(e.items,n),Qd(e.items,n)}),sh=O({type:P(Q.ACCORDION),fieldName:A(),defaults:Si.optional()}).strict(),ih=We("type",[_i,pi,hi,yi,Ei,li,fi,gi,di,mi]),ah=O({label:z,positionFieldName:A().optional(),editors:De(A(),ih)}).strict().superRefine((e,t)=>{qd(e.editors,e.label,Ie(t))}),ch=O({type:P(Q.ACCORDION),sortable:J().optional(),items:De(A(),ah),defaults:Si.optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Jd(e.items,n),e.sortable===!0&&(eh(e.items,n),th(e.items,n))}),Ti=We("type",[$r,Dr,wr,vr,kr,Lr,ci,ui,ii,Ar,br,bd,Nr,Ir]),Ri=We("type",[xn,bn,Ln,zn,Pn,An,$n,kn,Nn,oh,Dn]),uh=O({showcaseId:A(),blockName:A(),previewImage:In,content:De(A(),Ti),design:De(A(),Ri),layoutId:A().optional()}).strict(),lh=O({blockName:A(),content:De(A(),Ti).optional(),design:De(A(),Ri).optional(),layoutId:A().optional()}).strict();function ph(e,t){Cr(e.type)&&(e.sections.length!==1?t.at("sections").addIssue("TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED",e.type):e.sections[0]?.type!=="store"&&t.at(["sections",0,"type"]).addIssue("TEMPLATE_PAGE_STORE_SECTION_REQUIRED",e.type))}function fh(e,t){Cr(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,r)=>{Cr(e.type)||n.type==="store"&&t.at(["sections",r,"type"]).addIssue("TEMPLATE_PAGE_NO_STORE_SECTIONS",e.type),n.type==="default"&&n.id&&(n.id==="header"||n.id==="footer")&&t.at(["sections",r,"id"]).addIssue("REQUIRED_PAGE_SECTION_TYPE")})}function dh(e,t){e.type==="CUSTOM"?e.metadata||t.at("metadata").addIssue("TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED"):e.metadata!==void 0&&t.at("metadata").addIssue("TEMPLATE_PAGE_METADATA_NOT_ALLOWED",e.type)}const hh=new RegExp(`^(${Object.values(hd).join("|")})(_\\d{3})?$`),mh=A().regex(hh,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),gh=A().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),Oi=O({type:P("default"),id:mh,showcase_id:gh.optional()}).strict(),Pr=O({type:P("custom"),id:A(),showcase_id:A().optional(),showcase_overrides:lh.optional(),category:gd.optional()}).strict(),Eh=O({type:P("store"),id:A().optional()}).strict(),_h=We("type",[Oi,Pr,Eh]),yh=O({title:A()}).strict(),Sh=O({metadata:yh.optional(),sections:oe(_h)}).strict(),Th=Sh.safeExtend({type:ud,id:A().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=Ie(t);fh(e,n),ph(e,n),dh(e,n)}),vi=O({name:A().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:A().min(2,{message:"description must be at least 2 characters"}).max(150,{message:"description must be at most 150 characters"}),preview_url:$s({message:"preview_url must be a valid URL"}).regex(/^(https?):\/\/([^.]+?\.)?(company\.site|ecwid\.qa)($|\/[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=]*)?$/,"preview_url must match pattern: (https?)://([^.]+?\\.)?(company\\.site|ecwid\\.qa)(...)?").optional(),cover_image:In,categories:oe(pd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),Rh=Oi.extend({id:A()}),Ci=We("type",[Rh,Pr]),Oh=O({metadata:vi,header:Ci,footer:Ci}).strict(),vh=O({id:A().min(1,{message:"id is required"}),assets:Rr.array().optional(),configuration:Oh,pages:oe(Th)}).strict(),Mn=2097152,Un=512e3;function pt(e,t=2){if(!+e)return"0 Bytes";const n=1024,r=t<0?0:t,o=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**i).toFixed(r))} ${o[i]}`}const Ch={menu:{type:V.NAVIGATION_MENU},logo:{type:V.LOGO}},wh={logo:{type:"LOGO",label:"$label.logo.label",colors:["#FFFFFF66","#0000004D","#00000099","#64C7FF66","#F9947266","#C794CD66","#FFD17466"],sizes:[18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60],defaults:{type:"LOGO",font:"global.fontFamily.body",size:40,bold:!0,italic:!1,color:"#313131",visible:!0,spacing:2,capitalization:"all",frame:{visible:!0,width:3,color:"#313131"}}}};function wi(e){switch(e){case zt.HEADER:return Ch;default:return{}}}function Ii(e){switch(e){case zt.HEADER:return wh;default:return{}}}function Ai({validationType:e,sectionType:t}){switch(e){case Xt.CONTENT:return wi(t);case Xt.DESIGN:return Ii(t);default:return{}}}const Ih=Pr.extend({id:A().min(1,{message:"section id is required"})}),Ah=O({metadata:vi,sections:oe(Ih).min(1,{message:"sections must contain at least one section"}).max(20,{message:"sections must contain at most 20 sections"})}).strict().superRefine((e,t)=>{e.metadata.name.trim().length===0&&Ie(t).at(["collection","metadata","name"]).addIssue("REQUIRED_COLLECTION_NAME")}),bh=O({id:A().min(1,{message:"id is required"}),descriptor:Ah}).strict(),$h=We("type",[Js,ni,Ys,Gs,ri,ti,Ld,kd,Pd,Dd,Qs,qs,ei,Xs]),xr=De(A(),$h),Nh=We("type",[_i,pi,hi,yi,Ei,li,fi,gi,di,ch,mi]),zr=De(A(),Nh),Lh=We("type",[Kd,zd,jd,Yd,Wd,xd,Md,Zd,Ud,Hd,sh]),Dh=O({layoutId:A(),layoutIcon:dd.optional(),selectedContentSettings:oe(A()),selectedDesignSettings:oe(Lh)}).strict(),kh=A().regex(_d,vt.VALID_LANGUAGE_CODE()),jn=De(kh,De(z,A()));function bi(e,t,n){if(!e||Object.keys(t).length===0)return;const r=Object.entries(t),o=r.map(([,{type:s}])=>s),i=Object.values(e).map(({type:s})=>s);Object.entries(e).forEach(([s,a])=>{const c=t[s];c&&"type"in c&&a.type!==c.type&&n.at(s).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,s,c.type)}),Object.entries(e).forEach(([s,a])=>{const c=r.find(([,{type:u}])=>u===a.type)?.[0];c&&s!==c&&n.at(s).addIssue("MANDATORY_SETTING_NAME_MISMATCH",s,a.type,c)}),new Set(i.filter(s=>o.includes(s))).forEach(s=>{if(i.filter(a=>a===s).length>1){const a=r.findLast(([,{type:c}])=>c===s)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",s)}})}function $i(e,t,n){Hs(e,t,n)}function Ph(e,t,n){if(e.type!==V.DECK||t.type!==V.DECK)return;const r=t.cards?.defaultCardContent?.settings,o=e.cards;if(!r||!Array.isArray(o))return;const i=new Set(Object.keys(r));o.forEach((s,a)=>{s.settings&&Object.keys(s.settings).forEach(c=>{i.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function xh(e,t,n){e.content&&Object.entries(e.content).forEach(([r,o])=>{const i=n.at(["content",r]),s=t[r];if(!s){i.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",r);return}if(o.type!==s.type){i.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",r,o.type,s.type);return}if(o.type===V.SELECTBOX&&s.type===V.SELECTBOX){const a=s,c=o;a.options&&c.value!==void 0&&(new Set(a.options.map(u=>u.value)).has(c.value)||i.addIssue("INVALID_SELECTBOX_OPTION",c.value,r))}o.type===V.DECK&&Ph(o,s,i)})}function zh(e,t,n){e.design&&Object.entries(e.design).forEach(([r,o])=>{const i=n.at(["design",r]),s=t[r];if(!s){i.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",r);return}o.type!==s.type&&i.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",r,o.type,s.type)})}function Mh(e,t){Object.entries(e).flatMap(([n,r])=>{switch(r.type){case Q.ACCORDION:return Object.entries(r.items).flatMap(([o,i])=>Object.keys(i.editors).map(s=>({name:s,path:[n,"items",o,"editors",s]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},r,o)=>o.findIndex(i=>i.name===n)<r).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function Uh(e,t,n){e.layoutId&&((t||[]).some(r=>r.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function jh(e,t){const n=new Set;e.forEach((r,o)=>{if(n.has(r.showcaseId)){t.at([o,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",r.showcaseId);return}n.add(r.showcaseId)})}function Ni(e,t,n){for(const[r,o]of Object.entries(e)){const i=o;if(i.type===V.IMAGE){const s=t[r];if(s?.type===Q.IMAGE){const a=i.static??!1,c=s.static??!1;a!==c&&n.at(r).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",r)}}else if(i.type===V.DECK){const s=i;s.cards?.defaultCardContent?.settings&&Ni(s.cards.defaultCardContent.settings,t,n.at([r,"cards","defaultCardContent","settings"]))}}}function Fh(e,t,n){t>Mn&&n.at(le.basename(e)).addIssue("REQUIRED_SECTION_ASSET",pt(t),pt(Mn))}function Gh(e,t){e>Un&&t.addIssue("REQUIRED_SERVER_SIZE",pt(e),pt(Un))}const Hh=O({id:A(),type:Qf,name:A(),content:xr,design:zr,layout:oe(Dh).optional(),showcase:oe(uh),translationsSettings:jn.optional(),translationsShowcases:jn.optional(),assets:Rr.array().optional(),server:js,previewCount:Ve().optional()}).strict().superRefine((e,t)=>{const n=Ie(t),r=Ai({validationType:Xt.CONTENT,sectionType:e.type}),o=Ai({validationType:Xt.DESIGN,sectionType:e.type});bi(e.content,r,n.at("content")),bi(e.design,o,n.at("design")),Ni(e.content,e.design,n.at("content")),Mh(e.design,n.at("design")),e.assets&&e.assets.forEach(s=>{Fh(s.path,s.size,n.at("assets"))}),Gh(e.server.size,n.at("server"));const i=e.assets?.map(s=>s.path)??[];$i(e.content,i,n.at("content")),jh(e.showcase,n.at("showcase")),e.showcase.forEach((s,a)=>{const c=n.at(["showcase",a]);$i(s,i,c),xh(s,e.content,c),zh(s,e.design,c),Uh(s,e.layout,c)})}),Bh=O({translations:jn.optional()}).strict(),Zh=_e(["products","category","product"]),Vh=O({id:A(),sectionId:A(),assets:Rr.array().optional(),content:xr.optional(),design:zr.optional(),translationsSettings:jn.optional()}).strict().superRefine((e,t)=>{const n=Ie(t);Qt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Qt.options.join(", ")),e.assets&&e.assets.forEach(r=>{r.size>Mn&&n.at(["assets",le.basename(r.path)]).addIssue("REQUIRED_SECTION_ASSET",pt(r.size),pt(Mn))})});O({id:A(),sectionId:Qt,pageId:Zh,content:xr.optional(),design:zr.optional()}).strict();const Wh=O({id:A(),sectionId:A(),layoutId:A(),server:js}).strict().superRefine((e,t)=>{const n=Ie(t);Qt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Qt.options.join(", ")),e.server.size>Un&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",pt(e.server.size),pt(Un))});function Kh(e,t,n){if(e){if(e.type==="default")e.id!=="header"&&n.at("id").addIssue("REQUIRED_HEADER_ID");else if(e.type==="custom"&&e.id){const r=t.find(o=>o.id===e.id);r?(r.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_HEADER",e.id)}}}function Yh(e,t,n){if(e){if(e.type==="default")e.id!=="footer"&&n.at("id").addIssue("REQUIRED_FOOTER_ID");else if(e.type==="custom"&&e.id){const r=t.find(o=>o.id===e.id);r?(r.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((r.showcase||[]).some(o=>o.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER",e.id)}}}function Xh(e,t,n){if(!e)return;const r=n.at(["showcase_overrides"]);["content","design"].forEach(i=>{const s=e[i];if(s){const a=t[i]||{};Object.keys(s).forEach(c=>{if(!(c in a)){const u=i==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";r.at([i,c]).addIssue(u,c)}})}}),e.layoutId&&((t.layout||[]).some(i=>i.layoutId===e.layoutId)||r.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const o=t.assets?.map(i=>i.path)??[];e.content&&Hs(e.content,o,r.at(["content"]))}function Li(e,t,n,r=!1){if(!e.id)return;const o=t.find(i=>i.id===e.id);if(!o){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}!r&&(o.type==="HEADER"||o.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),Xh(e.showcase_overrides,o,n),e.showcase_id&&((o.showcase||[]).some(i=>i.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function Qh(e,t,n,r){e.id&&(n.some(o=>o.sectionId===t.type.toLowerCase()&&o.id===e.id)||r.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const qh=O({version:A(),name:A(),shared:Bh.optional(),sections:oe(Hh),templates:oe(vh),layouts:oe(Vh),slots:oe(Wh),collections:oe(bh),compressionEnabled:J(),externalizationEnabled:J(),vueVersion:A(),openSource:J().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,r)=>{const o=Ie(t).at(["templates",r]);Kh(n.configuration.header,e.sections,o.at(["configuration","header"])),Yh(n.configuration.footer,e.sections,o.at(["configuration","footer"])),n.pages.forEach((i,s)=>{const a=o.at(["pages",s]);i.sections.forEach((c,u)=>{const f=a.at(["sections",u]);c.type==="custom"?Li(c,e.sections,f):c.type==="store"&&Qh(c,i,e.layouts,f)})})}),e.collections.forEach((n,r)=>{n.descriptor.sections.forEach((o,i)=>{const s=Ie(t).at(["collections",r,"sections",i]);Li(o,e.sections,s,!0)})})});lt({customError:Xf});const I={error:e=>console.log(Ga(e)),warn:e=>console.log(Fa(e)),info:e=>console.log(Qe(e))},Jh="dist",em="dist/shared",st="dist/sections",Mr="dist/headers",Ur="dist/footers",ft="dist/templates",Mt="layouts",Di="preview",je=`dist/${Mt}`,Jt="dist/collections",ki="dist/manifest.json",tm=[st,Mr,Ur,ft,je];function Fn(e){return!!e}function Ct(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const nm="Resource name can only contain alphanumeric characters, dashes, and underscores";function rm(e){if(typeof e=="string"||typeof e=="number"){const t=/^[a-zA-Z0-9_-]+$/.test(e.toString());if(t)return{isValid:t,errorMessage:null}}return{isValid:!1,errorMessage:nm}}function om(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function sm(e){return le.parse(e).name}function im(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Gn(){const e=await ar(j(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function am(e){return e.includes(`
|
|
40
|
+
`)}function cm(e,t,n){return e.split(`
|
|
41
|
+
`).map((r,o)=>o>=n?t+r:r).join(`
|
|
42
|
+
`)}function wt(e,t){const n=[];if(e instanceof Lo){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const i=e.response?.data;if(i?.errorCode&&n.push(` Error Code: ${i.errorCode}`),i?.errorMessage){const s=am(i.errorMessage)?cm(i.errorMessage," ",1):i.errorMessage;n.push(` Error Message: ${s}`)}}const r=n.length>0?n.join(`
|
|
43
|
+
`):e?.message??"Unknown error";if(!t||t.length===0)return r;const o=n.length>0?`
|
|
44
|
+
`:" ";return`${t}${o}${r}`}function jr(e,t){return Object.keys(e).reduce((n,r)=>{const o=e[r],i=t[r];return Ct(o)&&Ct(i)?n[r]=jr(o,i):n[r]=o,n},{...t})}function um({contentSettings:e,sectionType:t}){const n=wi(t);return jr(e,n)}function lm({designSettings:e,sectionType:t}){const n=Ii(t);return jr(e,n)}async function Je(e){return(await import(No(e).href+`?t=${Date.now()}`)).default}function Fr(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function et(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=qa(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Pi(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:Number(e)}}function pm(e){if(e!==void 0)return{...e,color:et(e.color)}}function en(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function fm(e){if(e!==void 0)switch(e){case ir.COLOR:return"solid";case ir.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(ir)}`)}}function dm({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:fm(e),solid:{color:et(n.at(0))},gradient:{fromColor:et(n.at(0)),toColor:et(n.at(1))}}}}function hm(e){if(e!==void 0)switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(Va)}`)}}function mm(e){if(e!==void 0)switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(Wa)}`)}}function gm(e){if(e!==void 0)switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys(Ka)}`)}}function Em(e){const t=hm(e.appearance),n=mm(e.size),r=gm(e.shape),o=Fr(e.font),i=et(e.color),s=e.visible;return en({appearance:t,size:n,style:r,font:o,color:i,visible:s})}function _m(e){const t=et(e.color);return en({color:t})}function ym(e){if(e!==void 0)switch(e){case fn.COLOR:return"solid";case fn.GRADIENT:return"gradient";case fn.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(fn)}`)}}function Sm(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:ym(e.overlay),solid:{color:et(n.at(0))},gradient:{fromColor:et(n.at(0)),toColor:et(n.at(1))}}}}function Tm(e){const t=Fr(e.font),n=et(e.color),r=Pi(e.size),o=e.bold,i=e.italic,s=e.spacing,a=e.capitalization;return{font:t,color:n,size:r,frame:pm(e.frame),bold:o,italic:i,spacing:s,capitalization:a}}function Rm(e){const t=e.value;return en({value:t})}function Om(e){const t=Fr(e.font),n=et(e.color),r=Pi(e.size),o=e.bold,i=e.italic;return en({font:t,color:n,size:r,bold:o,italic:i})}function vm(e){const t=e.enabled;return en({enabled:t})}function Gr(e,t){if(t.defaults===void 0)return;let n={};switch(e){case Me.TEXT:{n=Om(t.defaults);break}case Me.BUTTON:{n=Em(t.defaults);break}case Me.IMAGE:{n=Sm(t.defaults);break}case Me.BACKGROUND:{n=dm(t.defaults);break}case Me.COLOR_PICKER:{n=_m(t.defaults);break}case Me.LOGO:{n=Tm(t.defaults);break}case Me.SELECTBOX:{n=Rm(t.defaults);break}case Me.TOGGLE:{n=vm(t.defaults);break}case Me.DIVIDER:case Me.INFO:break;case Me.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function xi(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type;if(o===Me.ACCORDION){const s=Object.fromEntries(Object.entries(r.items).map(([a,c])=>[a,{...c,editors:xi(c.editors)}]));t[n]={...r,items:s};return}const i=Gr(o,r);i&&r.defaults?t[n]={...r,defaults:i}:t[n]=r}),t}function Cm(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...Gr(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Hr(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type;if(o===Me.ACCORDION){const s=Object.fromEntries(Object.entries(r.items).map(([a,c])=>[a,{...c,editors:Hr(c.editors)??c.editors}]));t[n]={type:r.type,items:s};return}const i=Gr(o,{defaults:r});i!==void 0?t[n]={...r,...i,type:r.type}:t[n]=r}),t}function wm(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Im(e){const t={};for(const n in e){const r=e[n];for(const o in r){const i=t[o],s=r[o];if(i===void 0){const a={};a[n]=s,t[o]=a}else i[n]=s}}return t}function Am(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function Ut(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return Am(e)?e:e.map(o=>Ut(o,t));const n=e,r={};for(const o in n){const i=n[o];typeof i=="string"&&i.startsWith("$")?r[o]=wm(t,i):typeof i=="object"&&i!==null?r[o]=Ut(i,t):r[o]=i}return r}async function tn(e){return e?Im(e):{}}async function bm(e,t=st){const n=j(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await Je(n)}async function Hn(e,t=st){const n=j(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await Je(n)}async function $m(e,t){const n=j(process.cwd(),`${je}/${t}/${e}/js/settings/translations.mjs`);if($e(n))return await Je(n)}async function Br(e,t,n){const r=n?um({contentSettings:e,sectionType:n}):e;return Ut(r,t)}async function Nm(e,t=st){try{const n=j(Oe.cwd(),`${t}/${e}/js/settings/content.mjs`),r=await Je(n);return bt(r)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Zr(e,t,n){const r=n?lm({designSettings:e,sectionType:n}):e,o=xi(r);return Ut(o,t)}async function Lm(e,t=st){try{const n=j(Oe.cwd(),`${t}/${e}/js/settings/design.mjs`),r=await Je(n);return bt(r)}catch(n){const r=n;throw new Error(`Design settings is invalid or undefined. Error ${r.stack}`)}}async function Dm(e,t){return Promise.all(e.map(async n=>{const r=n.design?Hr(n.design):void 0,o={...n,design:r??n.design};return Ut(o,t)}))}async function km(e,t=st){try{const n=await W("*.mjs",{cwd:j(Oe.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async r=>{const o=j(Oe.cwd(),`${t}/${e}/js/showcases/${r}`);return await Je(o)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Pm(e){return e?.map(t=>({...t,selectedDesignSettings:Cm(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function xm(e,t=st){try{const n=j(Oe.cwd(),`${t}/${e}/js/settings/layout.mjs`);return $e(n)?await Je(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function zm(e){let t={};const n=j(Oe.cwd(),`${Di}/shared/analytics.json`);if(!$e(n))return 0;try{const r=nr(n,"utf-8");t=JSON.parse(r)}catch(r){console.warn("Error processing analytics.json file",r)}return t[e]||0}const jt={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Vr="https://blockbuster.ecwid.com",Mm="/api/v1/custom-apps/resources/sections/upload",Um="/api/v1/custom-apps/resources/templates/upload",jm="/api/v1/custom-apps/manifests/sections",Fm="/api/v1/custom-apps/manifests/templates",Gm=5,Hm=3,Bm=[ee.Server,ee.Client,ee.ClientChunks,ee.ClientAsset,ee.Asset],Zm=[ee.LayoutClient,ee.LayoutAsset],Vm=[ee.SlotServer,ee.SlotClient,ee.SlotClientChunks,ee.SlotClientAsset],Wm=[ee.Dependency,ee.TemplateAsset,ee.SourceCode,ee.CollectionAsset],Ft={DEFAULT:"Error while deploying:",ASSET_FILES_UPLOAD:"Error while uploading asset files:",MANIFEST_DEPLOYMENT:"Error while deploying manifest file:",DEPRECATED_VERSION_DEPLOYMENT:"You are using a non-supported version of crane. Please update to the latest crane version to continue.",INCORRECT_DISTRIBUTION_FOLDER:e=>`Distribution folder [${e}] is not found or has incorrect structure, please execute the build command first.`},zi={catalog:"products",category:"category",product:"product"},Mi=e=>zi[e],Ui=e=>e in zi;function Km(e){return e.replace(/\\/g,"/")}function Ym(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Bn(e){return Ym(Km(e))}function Xm(e){const t=Bn(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t;if(!Ui(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const o=Mi(n);return{id:r,sectionId:n,pageId:o}}async function Qm(e){return Promise.all(e.map(async t=>{const n=t.sectionId,r=Mi(n),o=await tn(t.translationsSettings),i=await Br(t.content??{},o),s=await Zr(t.design??{},o);return{id:t.id,sectionId:n,pageId:r,contentEditors:i,designEditors:s}}))}function Gt(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${je}/${e}/${t}/${n.join("/")}`}const nn=(e=ut.SECTION)=>we[e].dist,rn={[ee.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/server/`},[ee.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/client/`},[ee.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[ee.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/js/main/client/assets/`},[ee.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${nn(t)}/${e}/assets/`},[ee.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${ft}/assets/`},[ee.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[ee.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[ee.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>Gt(e,t,"")},[ee.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Gt(e,t,"assets/")},[ee.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/server/")},[ee.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/client/")},[ee.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/client/chunks/")},[ee.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Gt(e,t,"slots",n,"js/main/client/assets/")},[ee.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Jt}/assets/`}};function qm(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function Wr(){const e=j(dn.cwd(),"package.json"),t=await ar(e),n=JSON.parse(t.toString());if(qm(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const Jm={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function eg(e,t){const n=Jm[e];return n?n(t):t.id}const tg=new Set(["content","design"]);function Zn(e,t,n=0,r=[]){if(n>=t.length)return r;const o=t[n],i=t[n+1];if(typeof o=="string"&&typeof i=="number"&&Ct(e)){const s=e[o],a=Array.isArray(s)?s[i]:void 0;if(Ct(a)){const c=eg(o,a);return r.push(`${o}[${c||i}]`),Zn(a,t,n+2,r)}}if(typeof o=="string"&&typeof i=="string"&&tg.has(o)){r.push(`${o}[${i}]`);const s=Ct(e)&&!Array.isArray(e)?e[o]:void 0,a=Ct(s)&&!Array.isArray(s)?s[i]:void 0;return Zn(a,t,n+2,r)}return r.push(o),Zn(Ct(e)?e[o]:void 0,t,n+1,r)}function ng(e){const t=e.errors.map(r=>Zn(e.manifest,r.path).join(".")),n={path:Math.max(...t.map(r=>r.length),0),message:Math.max(...e.errors.map(r=>r.message.length),0)};e.errors.map((r,o)=>{const i=r.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[o].padEnd(n.path," ")} | ${r.message.padEnd(n.message," ")} | ${i}`}).forEach(r=>I.error(r))}async function rg(e){const t=qh.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const og=`Build successful:
|
|
45
|
+
For preview run: npx @lightspeed/crane@latest preview
|
|
46
|
+
For deploy run: npx @lightspeed/crane@latest deploy`;function sg(e,t){if(e.errors.length===0){I.info(og);return}I.error("Invalid configuration detected:"),ng(e),t||process.exit(1)}const ji={"process.env":{NODE_ENV:"production"}},ig=[...Do,...Do.map(e=>`node:${e}`)],ag=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],Fi=e=>({pluginType:Be.Server,define:ji,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...ig,...ag],inlineDynamicImports:!0,...e,outDir:e.outDir}),Gi=e=>({pluginType:Be.Client,define:ji,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),Ht=e=>({pluginType:Be.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),cg=e=>({pluginType:Be.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),Vn=e=>({pluginType:Be.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let Wn=!1;function ug(e){Wn=e}function Kr(){return Wn}const Hi=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],lg=80,pg="\x1B[?25l",fg="\x1B[?25h",dg="\x1B[2K\r",hg=44;let mg=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){Wn||(this.frameIndex=0,this.buffer=[],this.realWrite=process.stdout.write.bind(process.stdout),process.stdout.write=((t,n,r)=>(this.buffer.push(typeof t=="string"?t:String(t)),typeof n=="function"&&(r=n),r&&r(),!0)),this.realWrite(pg),this.render(),this.timer=setInterval(()=>this.render(),lg))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(hg-1," "),n=Qe(Hi[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%Hi.length}stop(){if(!Wn&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${dg}${fg}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Bi=new mg,gg=()=>Ja({ext:".gz",algorithm:"gzip",verbose:Kr()}),Eg="/* EXTERNAL_IMPORTS_START */",_g="/* EXTERNAL_IMPORTS_END */",yg=()=>({name:"external-imports-wrapper-plugin",enforce:"post",apply:"build",generateBundle(e,t){for(const n of Object.keys(t)){const r=t[n];if(r.type==="chunk"){const o=/import.*\?commonjs-external["'];/g,i=r.code.match(o);if(i!==null){const s=i.join(""),a=Eg+s+_g,c=r.code.replace(o,"");r.code=a+c}}}}}),Sg=()=>({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})}}),Tg=()=>{const e=process.env.npm_lifecycle_event;return nc({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"`}})},tt={vue:()=>ec(),tsconfigPaths:()=>tc(),checker:()=>Tg()};class tr{constructor(t){this.bits=t instanceof tr?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class sn{constructor(t,n,r){this.start=t,this.end=n,this.original=r,this.intro="",this.outro="",this.content=r,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 sn(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,r){return this.content=t,r||(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,r=this.original.slice(0,n),o=this.original.slice(n);this.original=r;const i=new sn(t,this.end,o);return i.outro=this.outro,this.outro="",this.end=t,this.edited?(i.edit("",!1),this.content=""):this.content=r,i.next=this.next,i.next&&(i.next.previous=i),i.previous=this,this.next=i,i}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 r=this.split(this.end-n.length);this.edited&&r.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 Rg(){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 Og=Rg();class vg{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=rc(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,"+Og(this.toString())}}function Cg(e){const t=e.split(`
|
|
47
|
+
`),n=t.filter(i=>/^\t+/.test(i)),r=t.filter(i=>/^ {2,}/.test(i));if(n.length===0&&r.length===0)return null;if(n.length>=r.length)return" ";const o=r.reduce((i,s)=>{const a=/^ +/.exec(s)[0].length;return Math.min(a,i)},1/0);return new Array(o+1).join(" ")}function wg(e,t){const n=e.split(/[/\\]/),r=t.split(/[/\\]/);for(n.pop();n[0]===r[0];)n.shift(),r.shift();if(n.length){let o=n.length;for(;o--;)n[o]=".."}return n.concat(r).join("/")}const Ig=Object.prototype.toString;function Ag(e){return Ig.call(e)==="[object Object]"}function Zi(e){const t=e.split(`
|
|
48
|
+
`),n=[];for(let r=0,o=0;r<t.length;r++)n.push(o),o+=t[r].length+1;return function(o){let i=0,s=n.length;for(;i<s;){const u=i+s>>1;o<n[u]?s=u:i=u+1}const a=i-1,c=o-n[a];return{line:a,column:c}}}const bg=/\w/;class $g{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,r,o){if(n.length){const i=n.length-1;let s=n.indexOf(`
|
|
29
49
|
`,0),a=-1;for(;s>=0&&i>s;){const u=[this.generatedCodeColumn,t,r.line,r.column];o>=0&&u.push(o),this.rawSegments.push(u),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=s,s=n.indexOf(`
|
|
30
|
-
`,s+1)}const c=[this.generatedCodeColumn,t,r.line,r.column];o>=0&&c.push(o),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,r,o,i){let s=n.start,a=!0,c=!1;for(;s<n.end;){if(this.hires||a||i.has(s)){const u=[this.generatedCodeColumn,t,o.line,o.column];this.hires==="boundary"?
|
|
50
|
+
`,s+1)}const c=[this.generatedCodeColumn,t,r.line,r.column];o>=0&&c.push(o),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,r,o,i){let s=n.start,a=!0,c=!1;for(;s<n.end;){if(this.hires||a||i.has(s)){const u=[this.generatedCodeColumn,t,o.line,o.column];this.hires==="boundary"?bg.test(r[s])?c||(this.rawSegments.push(u),c=!0):(this.rawSegments.push(u),c=!1):this.rawSegments.push(u)}r[s]===`
|
|
31
51
|
`?(o.line+=1,o.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0):(o.column+=1,this.generatedCodeColumn+=1,a=!1),s+=1}this.pending=null}advance(t){if(!t)return;const n=t.split(`
|
|
32
|
-
`);if(n.length>1){for(let r=0;r<n.length-1;r++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=n[n.length-1].length}}const
|
|
33
|
-
`,
|
|
34
|
-
`));else for(a=c.start;a<u;){if(!o[a]){const
|
|
35
|
-
`?i=!0:
|
|
36
|
-
${
|
|
37
|
-
`,hE=(e,t)=>{const n=e.split("?")[0],r=ga(n);return(r==="server.ts"||r==="client.ts")&&!t.includes(xi)},Ui=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=Ie(Pi)},transform(t,n){if(!e||!hE(n,t))return null;const r=n.split("?")[0],o=uo(r),i=Ra(lo(o,Pi)),s=fE(i),a=new io(t);return a.prepend(s),{code:a.toString()}}}},Mi={[Ge.Server]:()=>[Je.vue(),Je.tsconfigPaths(),tE(),qm(),Ui()],[Ge.Client]:()=>[Je.vue(),Je.tsconfigPaths(),yo({vue:"EcVue"}),Ui()],[Ge.Misc]:()=>[Je.tsconfigPaths()],[Ge.Layout]:()=>[Je.vue(),Je.tsconfigPaths(),yo({vue:["EcExternals","Vue"]})],[Ge.Asset]:()=>[nE()],[Ge.SharedFiles]:()=>[Je.tsconfigPaths()]},Fi={[le.Server]:$i({outDir:({name:e,sectionType:t})=>`./${ie[t].dist}/${e}/js/main/server`}),[le.Client]:Ni({outDir:({name:e,sectionType:t})=>`./${ie[t].dist}/${e}/js/main/client`}),[le.SectionSetting]:xt({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${ie[t].dist}/${e}/js/settings`}),[le.SectionShowcase]:xt({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${ie[t].dist}/${e}/js/showcases`}),[le.SectionAsset]:Mn({outDir:({name:e,sectionType:t})=>`./${ie[t].dist}/${e}/assets`}),[le.TemplateDescriptor]:xt({entryFileNames:"[name].mjs",outDir:()=>`./${He}/js`}),[le.PageTemplateDescriptor]:xt({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${He}/${e}`}),[le.TemplateAsset]:Mn({outDir:()=>`./${He}/assets`}),[le.Layout]:Bm({outDir:({name:e,sectionId:t})=>`./${ve}/${t}/${e}`}),[le.LayoutSettings]:xt({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${ve}/${t}/${e}/js/settings`}),[le.LayoutAsset]:Mn({outDir:({name:e,sectionId:t})=>`./${ve}/${t}/${e}/assets`}),[le.SlotServer]:$i({outDir:({name:e,layoutId:t,sectionId:n})=>`./${ve}/${n}/${t}/slots/${e}/js/main/server`}),[le.SlotClient]:Ni({outDir:({name:e,layoutId:t,sectionId:n})=>`./${ve}/${n}/${t}/slots/${e}/js/main/client`}),[le.CollectionDescriptor]:xt({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${on}/${e}`}),[le.CollectionAsset]:Mn({outDir:()=>`./${on}/assets`}),[le.SharedTranslation]:{pluginType:Ge.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function mE(e){switch(typeof e){case"string":return[U(process.cwd(),e)];case"object":return e.map(t=>U(process.cwd(),t));default:return[]}}function zi({name:e,entryPoints:t,configType:n,layoutId:r,sectionId:o,sectionType:i=we.SECTION}){const s=Fi[n],a=s.define,c=s.ssrOptions,u=s.entryFileNames,l=s.chunkFileNames,h=s.assetFileNames,d=s.inlineDynamicImports,b=s.externalOption;return{logLevel:Pr()?void 0:"silent",plugins:Mi[s.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:s.ssr,outDir:s.outDir({name:e,sectionType:i,layoutId:r,sectionId:o}),emptyOutDir:!0,minify:s.ssr?"terser":"esbuild",...s.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:b,preserveEntrySignatures:"strict",input:mE(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:d,entryFileNames:u,chunkFileNames:l,assetFileNames:h}}},assetsInclude:["**/*.json"]}}const EE=Object.values(ie).map(e=>e.source).join("|");function Gi(e,t,n){if(!e)return`${t}.mjs`;const r=lo(process.cwd(),e).replace(/\\/g,"/").match(`^(${EE})/([^/]+)/${n}/([^/.]+)`);return r?`${r[1]}/${r[2]}/js/${n}/${r[3]}.mjs`:`${t}.mjs`}function Hi(e,t){const n=Fi[le.SectionSetting];return{logLevel:Pr()?void 0:"silent",plugins:Mi[n.pluginType](),define:n.define,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:n.ssr,outDir:"./dist",emptyOutDir:!1,minify:"esbuild",rollupOptions:{external:n.externalOption,preserveEntrySignatures:"strict",input:e.map(r=>U(process.cwd(),r)),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:n.inlineDynamicImports,entryFileNames:t,chunkFileNames:"chunks/[name]-[hash].js",assetFileNames:n.assetFileNames}}},assetsInclude:["**/*.json"]}}function gE(e){return Hi(e,t=>Gi(t.facadeModuleId??void 0,t.name,"settings"))}function _E(e){return Hi(e,t=>Gi(t.facadeModuleId??void 0,t.name,"showcases"))}async function yE(){const e={ignore:["node_modules/**","dist/**"]},t=await z(`./${Rt}/{product,category,catalog}/*/Main.vue`,e);return await Promise.all(t.map(async n=>{const{id:r,sectionId:o,pageId:i}=pc(n),[s,a]=await Promise.all([z(`./${Rt}/${o}/${r}/settings/{content,design,translations}.{js,ts}`,e),z(`./${Rt}/${o}/${r}/assets/*`,e)]);return{name:r,sectionId:o,pageId:i,clientEntrypoint:n,settingsEntryPoints:s,assetsEntrypoints:a}}))}async function SE(e){await Ze({entryPoints:[e.clientEntrypoint],configType:le.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([Ze({entryPoints:e.settingsEntryPoints,configType:le.LayoutSettings,name:e.name,sectionId:e.sectionId}),Ze({entryPoints:e.assetsEntrypoints,configType:le.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function TE(e){e===void 0||e.length===0||await Promise.all(e.map(t=>SE(t)))}async function RE(e){const t=e.flatMap(r=>r.settingsEntryPoints),n=e.flatMap(r=>r.showcaseEntryPoints);t.length>0&&await ot({configFile:!1,...nn(gE(t))}),n.length>0&&await ot({configFile:!1,...nn(_E(n))})}async function CE(e){await Promise.all([ot({configFile:!1,...nn(zi({name:e.name,entryPoints:e.serverEntrypoint,configType:St.Server,sectionType:e.type}))}),Ze({entryPoints:e.clientEntrypoint,configType:St.Client,name:e.name,sectionType:e.type}),Ze({entryPoints:e.assetEntryPoints,configType:St.SectionAsset,name:e.name,sectionType:e.type})])}async function IE(){const e=U(process.cwd(),"shared/translation.ts");Ie(e)&&await Ze({entryPoints:["shared/translation.ts"],configType:St.SharedTranslation})}async function ji(e){await Promise.all([RE(e),...e.map(CE)])}async function wE(){const e={ignore:["node_modules/**","dist/**"]},t=await z(`${Rt}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:r,sectionId:o,layoutId:i}=Cm(n),s=(await z(`${Rt}/${o}/${i}/slots/${r}/client.{js,ts}`,e))[0];if(s===void 0)throw new Error(`Cannot find client entrypoint file for slot ${r} of section ${o}`);return{id:r,sectionId:o,layoutId:i,serverEntrypoint:n,clientEntrypoint:s}}))}async function vE(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([Ze({entryPoints:[e.serverEntrypoint],configType:le.SlotServer,...t}),Ze({entryPoints:[e.clientEntrypoint],configType:le.SlotClient,...t})])}async function OE(e){e?.length&&await Promise.all(e.map(vE))}async function AE(e){return(await z(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(Ss).includes(n)})}async function bE(){const e=await z("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(N.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(Yn),r=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const o=await z(`**/templates/${r}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await z(`**/templates/${r}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await z(`**/templates/${r}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await z(`**/templates/${r}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await z(`**/templates/${r}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await AE(r);return{name:r,configurationEntrypoint:o.at(0),homeEntrypoint:i.at(0),categoryEntrypoint:s.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:u.length>0?u:void 0}}))}async function $E(){const e=await z("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await z("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await bE(),templates:e,assets:t}}async function NE({templateBuildConfig:e}){await Promise.all([Ze({entryPoints:e.assets,configType:St.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(sn);if(n.length===0)throw new Error("No entry points provided for page template");await Ze({entryPoints:n,configType:St.PageTemplateDescriptor,name:t.name})})||[]])}async function LE(){const e=await $E();await NE({templateBuildConfig:e})}async function DE(){const e=await z("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(N.error(`Error while getting collection entry points: ${n}`),[])),t=await z("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const r=n.split(Yn),o=r.pop()??"default";if(r.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const i=await z(`**/collections/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:o,configurationEntrypoint:i.at(0),assetsEntrypoints:t}}))}async function kE(){const e=await DE();e.length!==0&&await Promise.all(e.flatMap(t=>[Ze({entryPoints:t.assetsEntrypoints,configType:le.CollectionAsset,name:t.name}),Ze({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:le.CollectionDescriptor,name:t.name})]))}function Bi(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(sn).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(sn),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(sn),assetEntryPoints:e.assetsEntrypoints??[]}}function PE(e){return e.map(t=>({...t,selectedDesignSettings:t.selectedDesignSettings.map(n=>{const r=n.defaults;return r&&typeof r=="object"&&!("type"in r)?{...n,defaults:{type:n.type,...r}}:n})}))}async function xE(e,t=Ae){const n=U(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),r=So(To.gunzip),o=await re.promises.readFile(n);return{size:(await r(o)).length}}async function UE(e,t=Ae){try{const n=U(process.cwd(),`${t}/${e}/assets/`);return(await z("*",{cwd:n})).map(r=>{const o=U(n,r);return{path:r,size:zt(o).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function xr(e,t){const n=await hi(e,ie[t].dist),r=await Pt(e,ie[t].dist),o=await gi(e,ie[t].dist),i=await yi(e,ie[t].dist),s=await Si(e,ie[t].dist),a=await Ti(e,ie[t].dist),c=PE(a),u=await UE(e,ie[t].dist),l=await xE(e,ie[t].dist),h=Ri(e);return{id:e,type:t,name:e,content:o,design:i,layout:c,showcase:s,translationsSettings:n,translationsShowcases:r,assets:u,server:l,previewCount:h}}async function ME(){const e=await z("*/",{cwd:U(process.cwd(),`${Ae}/`)}),t=await z("*/",{cwd:U(process.cwd(),`${Ht}/`)}),n=await z("*/",{cwd:U(process.cwd(),`${jt}/`)});return Promise.all([...e.map(async r=>xr(r,Dt.SECTION)),...t.map(async r=>xr(r,Dt.HEADER)),...n.map(async r=>xr(r,Dt.FOOTER))])}async function FE(e){try{const t=U(process.cwd(),`${e}/assets/`);return(await z("*",{cwd:t})).map(n=>{const r=U(t,n);return{path:n,size:zt(r).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function zE(e){const t=Ct(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t,[o,i,s,a]=await Promise.all([HE(r,n),jE(r,n),mi(r,n),FE(e)]);return{id:r,sectionId:n,content:o,design:i,translationsSettings:s,assets:a}}async function GE(){const e=`${ve}/{product,catalog,category}/*`,t=await z(e,{ignore:["node_modules/**"]});return Promise.all(t.map(zE))}async function HE(e,t){try{const n=U(process.cwd(),`${ve}/${t}/${e}/js/settings/content.mjs`),r=await Pe(n);return wt(r)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function jE(e,t){try{const n=U(process.cwd(),`${ve}/${t}/${e}/js/settings/design.mjs`),r=await Pe(n);return wt(r)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function BE(e,t,n){const r=U(process.cwd(),`${ve}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),o=So(To.gunzip),i=await re.promises.readFile(r);return{size:(await o(i)).length}}async function ZE(e){const t=Ct(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t,i=await BE(o,r,n);return{id:o,sectionId:n,layoutId:r,server:i}}async function VE(){const e=`${ve}/{product,catalog,category}/*/slots/*`,t=await z(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(ZE))}async function WE(){try{const e=U(process.cwd(),`${He}/assets/`);return(await z("*",{cwd:e})).map(t=>{const n=U(e,t);return{path:t,size:zt(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function KE(e){return e in et?et[e]:et.CUSTOM}async function YE(e){const t=await z(`${He}/${e}/*.mjs`,{ignore:[`${He}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:r,metadata:o}=await Zi(n),i=vo(n);return{type:KE(i.toUpperCase()),id:i,metadata:o,sections:r}}))}async function Zi(e){try{return await Pe(U(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function XE(e){const t=await z(`${He}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=ue.basename(ue.dirname(n));return{id:`${e}_${r}`,assets:await WE(),configuration:await Zi(n),pages:await YE(r)}}))}async function QE(e){return await XE(e)}async function qE(){const e=U(process.cwd(),`${tc}/translation.mjs`);return await Pe(e)}async function JE(){return{translations:await qE()}}async function eg(){const e=await an(),[t,n,r,o,i,s]=await Promise.all([kr(),JE(),ME(),GE(),VE(),QE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:r,templates:s,layouts:o,slots:i,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue}}function tg(e){return Object.entries(ie).find(t=>t[1].source===e)?.[0]}async function Vi(){const e=await z("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=uo(t).split(Yn),r=n.pop()??"default",o=n.pop();if(o===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const i=["node_modules/**","dist/**"],[s,a,c,u,l,h,d,b]=await Promise.all([z(`**/${r}/client.{js,ts}`,{ignore:i}),z(`**/${r}/settings/content.{js,ts}`,{ignore:i}),z(`**/${r}/settings/design.{js,ts}`,{ignore:i}),z(`**/${r}/settings/layout.{js,ts}`,{ignore:i}),z(`**/${r}/settings/translations.{js,ts}`,{ignore:i}),z(`**/${r}/showcases/*.{js,ts}`,{ignore:[...i,`**/${r}/showcases/translations.{js,ts}`]}),z(`**/${r}/showcases/translations.{js,ts}`,{ignore:i}),z(`**/${r}/assets/*`,{ignore:i})]);return{name:r,type:tg(o),serverEntrypoint:t,clientEntrypoint:s.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:u.at(0),settingsTranslationsEntrypoint:l.at(0),showcasesEntrypoints:h,showcasesTranslationsEntrypoint:d.at(0),assetsEntrypoints:b}}))}const ng=["/settings/","/showcases/"];function rg(e){return ng.some(t=>e.includes(t))}function og(){const e=Ye.findConfigFile(process.cwd(),Ye.sys.fileExists,"tsconfig.json");if(!e)return;const t=Ye.readConfigFile(e,Ye.sys.readFile),n=Ye.parseJsonConfigFileContent(t.config,Ye.sys,process.cwd()),r=Ye.createProgram(n.fileNames,n.options),o=Ye.getPreEmitDiagnostics(r).filter(i=>!i.file||!rg(i.file.fileName));if(o.length>0){const i={getCanonicalFileName:s=>s,getCurrentDirectory:Ye.sys.getCurrentDirectory,getNewLine:()=>Ye.sys.newLine};throw console.error(Ye.formatDiagnosticsWithColorAndContext(o,i)),new Error(`TypeScript found ${o.length} error(s)`)}}async function sg(e){og(),await ot({configFile:!1,logLevel:"error",plugins:[Je.vue(),Je.tsconfigPaths(),Je.checker()],build:{write:!1,rollupOptions:{input:U(process.cwd(),e)}}})}function ig(){return Promise.all([Kn.rm("dist",{recursive:!0,force:!0}),Kn.rm("source-code",{recursive:!0,force:!0}),Kn.rm("source-code.zip",{force:!0})])}async function ag(){const e=new fo,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"];(await kr()).openSource===!0&&t.splice(t.indexOf("**/assets/**/*"),1);const n=await z("**/*",{cwd:U(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(i=>{const s=U(process.cwd(),i);e.addLocalFile(s,po(i).dir)});const r=Zt[te.SourceCode].fileName,o=U(process.cwd(),r);await e.writeZipPromise(o)}catch(r){throw N.error("Error while zipping source files"),r}}async function zn(e=!1,t=!1){Zm(t),Di.start(),await ig();try{const[n,r,o]=await Promise.all([yE(),Vi(),wE()]),i=r.map(Bi);r.length>0&&await sg(r[0].serverEntrypoint);try{await Promise.all([IE(),ji(i),LE(),kE(),TE(n),OE(o),ag()])}finally{Di.stop()}const s=await eg(),a=await Gm(s);a.errors.length===0?N.info(`Build successful:
|
|
38
|
-
For preview run: npx @lightspeed/crane@latest preview
|
|
39
|
-
For deploy run: npx @lightspeed/crane@latest deploy`):(N.error("Invalid configuration detected:"),zm(a))}catch(n){N.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function Ze({entryPoints:e,configType:t,name:n,sectionType:r,sectionId:o,layoutId:i}){if(e.length!==0){const s=nn(zi({name:n,entryPoints:e,configType:t,sectionType:r,sectionId:o,layoutId:i}));await ot({configFile:!1,...s})}}function cg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ur={},Wi;function Mr(){return Wi||(Wi=1,(function(e){e.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1,e.find=(t,n)=>t.nodes.find(r=>r.type===n),e.exceedsLimit=(t,n,r=1,o)=>o===!1||!e.isInteger(t)||!e.isInteger(n)?!1:(Number(n)-Number(t))/Number(r)>=o,e.escapeNode=(t,n=0,r)=>{const o=t.nodes[n];o&&(r&&o.type===r||o.type==="open"||o.type==="close")&&o.escaped!==!0&&(o.value="\\"+o.value,o.escaped=!0)},e.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1,e.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1,e.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0,e.reduce=t=>t.reduce((n,r)=>(r.type==="text"&&n.push(r.value),r.type==="range"&&(r.type="text"),n),[]),e.flatten=(...t)=>{const n=[],r=o=>{for(let i=0;i<o.length;i++){const s=o[i];if(Array.isArray(s)){r(s);continue}s!==void 0&&n.push(s)}return n};return r(t),n}})(Ur)),Ur}var Fr,Ki;function zr(){if(Ki)return Fr;Ki=1;const e=Mr();return Fr=(t,n={})=>{const r=(o,i={})=>{const s=n.escapeInvalid&&e.isInvalidBrace(i),a=o.invalid===!0&&n.escapeInvalid===!0;let c="";if(o.value)return(s||a)&&e.isOpenOrClose(o)?"\\"+o.value:o.value;if(o.value)return o.value;if(o.nodes)for(const u of o.nodes)c+=r(u);return c};return r(t)},Fr}/*!
|
|
52
|
+
`);if(n.length>1){for(let r=0;r<n.length-1;r++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=n[n.length-1].length}}const on=`
|
|
53
|
+
`,Bt={insertLeft:!1,insertRight:!1,storeName:!1};class vo{constructor(t,n={}){const r=new sn(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:r},lastChunk:{writable:!0,value:r},lastSearchedChunk:{writable:!0,value:r},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 tr},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:n.ignoreList}}),this.byStart[0]=r,this.byEnd[t.length]=r}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 r=this.byEnd[t];return r?r.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 r=this.byStart[t];return r?r.appendRight(n):this.outro+=n,this}clone(){const t=new vo(this.original,{filename:this.filename});let n=this.firstChunk,r=t.firstChunk=t.lastSearchedChunk=n.clone();for(;n;){t.byStart[r.start]=r,t.byEnd[r.end]=r;const o=n.next,i=o&&o.clone();i&&(r.next=i,i.previous=r,r=i),n=o}return t.lastChunk=r,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new tr(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const n=0,r=Object.keys(this.storedNames),o=new $g(t.hires),i=Zi(this.original);return this.intro&&o.advance(this.intro),this.firstChunk.eachNext(s=>{const a=i(s.start);s.intro.length&&o.advance(s.intro),s.edited?o.addEdit(n,s.content,a,s.storeName?r.indexOf(s.original):-1):o.addUneditedChunk(n,s,this.original,a,this.sourcemapLocations),s.outro.length&&o.advance(s.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?wg(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:r,mappings:o.raw,x_google_ignoreList:this.ignoreList?[n]:void 0}}generateMap(t){return new vg(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=Cg(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(t,n){const r=/^[^\r\n]/gm;if(Ag(t)&&(n=t,t=void 0),t===void 0&&(this._ensureindentStr(),t=this.indentStr||" "),t==="")return this;n=n||{};const o={};n.exclude&&(typeof n.exclude[0]=="number"?[n.exclude]:n.exclude).forEach(f=>{for(let h=f[0];h<f[1];h+=1)o[h]=!0});let i=n.indentStart!==!1;const s=u=>i?`${t}${u}`:(i=!0,u);this.intro=this.intro.replace(r,s);let a=0,c=this.firstChunk;for(;c;){const u=c.end;if(c.edited)o[a]||(c.content=c.content.replace(r,s),c.content.length&&(i=c.content[c.content.length-1]===`
|
|
54
|
+
`));else for(a=c.start;a<u;){if(!o[a]){const f=this.original[a];f===`
|
|
55
|
+
`?i=!0:f!=="\r"&&i&&(i=!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(r,s),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,n){return Bt.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Bt.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Bt.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Bt.insertRight=!0),this.prependRight(t,n)}move(t,n,r){if(r>=t&&r<=n)throw new Error("Cannot move a selection inside itself");this._split(t),this._split(n),this._split(r);const o=this.byStart[t],i=this.byEnd[n],s=o.previous,a=i.next,c=this.byStart[r];if(!c&&i===this.lastChunk)return this;const u=c?c.previous:this.lastChunk;return s&&(s.next=a),a&&(a.previous=s),u&&(u.next=o),c&&(c.previous=i),o.previous||(this.firstChunk=i.next),i.next||(this.lastChunk=o.previous,this.lastChunk.next=null),o.previous=u,i.next=c||null,u||(this.firstChunk=o),c||(this.lastChunk=i),this}overwrite(t,n,r,o){return o=o||{},this.update(t,n,r,{...o,overwrite:!o.contentOnly})}update(t,n,r,o){if(typeof r!="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),o===!0&&(Bt.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Bt.storeName=!0),o={storeName:!0});const i=o!==void 0?o.storeName:!1,s=o!==void 0?o.overwrite:!1;if(i){const u=this.original.slice(t,n);Object.defineProperty(this.storedNames,u,{writable:!0,value:!0,enumerable:!0})}const a=this.byStart[t],c=this.byEnd[n];if(a){let u=a;for(;u!==c;){if(u.next!==this.byStart[u.end])throw new Error("Cannot overwrite across a split point");u=u.next,u.edit("",!1)}a.edit(r,i,!s)}else{const u=new sn(t,n,"").edit(r,i);c.next=u,u.previous=c}return this}prepend(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const r=this.byEnd[t];return r?r.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 r=this.byStart[t];return r?r.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 r=this.byStart[t];for(;r;)r.intro="",r.outro="",r.edit(""),r=n>r.end?this.byStart[r.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 r=this.byStart[t];for(;r;)r.reset(),r=n>r.end?this.byStart[r.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(on);if(t!==-1)return this.outro.substr(t+1);let n=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(t=r.outro.lastIndexOf(on),t!==-1)return r.outro.substr(t+1)+n;n=r.outro+n}if(r.content.length>0){if(t=r.content.lastIndexOf(on),t!==-1)return r.content.substr(t+1)+n;n=r.content+n}if(r.intro.length>0){if(t=r.intro.lastIndexOf(on),t!==-1)return r.intro.substr(t+1)+n;n=r.intro+n}}while(r=r.previous);return t=this.intro.lastIndexOf(on),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 r="",o=this.firstChunk;for(;o&&(o.start>t||o.end<=t);){if(o.start<n&&o.end>=n)return r;o=o.next}if(o&&o.edited&&o.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const i=o;for(;o;){o.intro&&(i!==o||o.start===t)&&(r+=o.intro);const s=o.start<n&&o.end>=n;if(s&&o.edited&&o.end!==n)throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);const a=i===o?t-o.start:0,c=s?o.content.length+n-o.end:o.content.length;if(r+=o.content.slice(a,c),o.outro&&(!s||o.end===n)&&(r+=o.outro),s)break;o=o.next}return r}snip(t,n){const r=this.clone();return r.remove(0,t),r.remove(n,r.original.length),r}_split(t){if(this.byStart[t]||this.byEnd[t])return;let n=this.lastSearchedChunk;const r=t>n.end;for(;n;){if(n.contains(t))return this._splitChunk(n,t);n=r?this.byStart[n.end]:this.byEnd[n.start]}}_splitChunk(t,n){if(t.edited&&t.content.length){const o=Zi(this.original)(n);throw new Error(`Cannot split a chunk that has already been edited (${o.line}:${o.column} \u2013 "${t.original}")`)}const r=t.split(n);return this.byEnd[n]=t,this.byStart[n]=r,this.byEnd[r.end]=r,t===this.lastChunk&&(this.lastChunk=r),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 r=this.lastChunk;do{const o=r.end,i=r.trimEnd(n);if(r.end!==o&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),i)return!0;r=r.previous}while(r);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 r=this.firstChunk;do{const o=r.end,i=r.trimStart(n);if(r.end!==o&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),i)return!0;r=r.next}while(r);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(t,n){function r(i,s){return typeof n=="string"?n.replace(/\$(\$|&|\d+)/g,(a,c)=>c==="$"?"$":c==="&"?i[0]:+c<i.length?i[+c]:`$${c}`):n(...i,i.index,s,i.groups)}function o(i,s){let a;const c=[];for(;a=i.exec(s);)c.push(a);return c}if(t.global)o(t,this.original).forEach(s=>{if(s.index!=null){const a=r(s,this.original);a!==s[0]&&this.overwrite(s.index,s.index+s[0].length,a)}});else{const i=this.original.match(t);if(i&&i.index!=null){const s=r(i,this.original);s!==i[0]&&this.overwrite(i.index,i.index+i[0].length,s)}}return this}_replaceString(t,n){const{original:r}=this,o=r.indexOf(t);return o!==-1&&this.overwrite(o,o+t.length,n),this}replace(t,n){return typeof t=="string"?this._replaceString(t,n):this._replaceRegexp(t,n)}_replaceAllString(t,n){const{original:r}=this,o=t.length;for(let i=r.indexOf(t);i!==-1;i=r.indexOf(t,i+o))r.slice(i,i+o)!==n&&this.overwrite(i,i+o,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 Vi=j(process.cwd(),"shared/translation.ts"),Wi="globalThis.craneSharedTranslation = translation",Ng=e=>`import translation from '${e}';
|
|
56
|
+
${Wi};
|
|
57
|
+
`,Lg=(e,t)=>{const n=e.split("?")[0],r=Ua(n);return(r==="server.ts"||r==="client.ts")&&!t.includes(Wi)},Ki=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=$e(Vi)},transform(t,n){if(!e||!Lg(n,t))return null;const r=n.split("?")[0],o=wo(r),i=Ba(Io(o,Vi)),s=Ng(i),a=new vo(t);return a.prepend(s),{code:a.toString()}}}},Yi={[Be.Server]:()=>[tt.vue(),tt.tsconfigPaths(),yg(),gg(),Ki()],[Be.Client]:()=>[tt.vue(),tt.tsconfigPaths(),ko({vue:"EcVue"}),Ki()],[Be.Misc]:()=>[tt.tsconfigPaths()],[Be.Layout]:()=>[tt.vue(),tt.tsconfigPaths(),ko({vue:["EcExternals","Vue"]})],[Be.Asset]:()=>[Sg()],[Be.SharedFiles]:()=>[tt.tsconfigPaths()]},Xi={[pe.Server]:Fi({outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/main/server`}),[pe.Client]:Gi({outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/main/client`}),[pe.SectionSetting]:Ht({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/settings`}),[pe.SectionShowcase]:Ht({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/js/showcases`}),[pe.SectionAsset]:Vn({outDir:({name:e,sectionType:t})=>`./${we[t].dist}/${e}/assets`}),[pe.TemplateDescriptor]:Ht({entryFileNames:"[name].mjs",outDir:()=>`./${ft}/js`}),[pe.PageTemplateDescriptor]:Ht({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${ft}/${e}`}),[pe.TemplateAsset]:Vn({outDir:()=>`./${ft}/assets`}),[pe.Layout]:cg({outDir:({name:e,sectionId:t})=>`./${je}/${t}/${e}`}),[pe.LayoutSettings]:Ht({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${je}/${t}/${e}/js/settings`}),[pe.LayoutAsset]:Vn({outDir:({name:e,sectionId:t})=>`./${je}/${t}/${e}/assets`}),[pe.SlotServer]:Fi({outDir:({name:e,layoutId:t,sectionId:n})=>`./${je}/${n}/${t}/slots/${e}/js/main/server`}),[pe.SlotClient]:Gi({outDir:({name:e,layoutId:t,sectionId:n})=>`./${je}/${n}/${t}/slots/${e}/js/main/client`}),[pe.CollectionDescriptor]:Ht({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Jt}/${e}`}),[pe.CollectionAsset]:Vn({outDir:()=>`./${Jt}/assets`}),[pe.SharedTranslation]:{pluginType:Be.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function Dg(e){switch(typeof e){case"string":return[j(process.cwd(),e)];case"object":return e.map(t=>j(process.cwd(),t));default:return[]}}function Qi({name:e,entryPoints:t,configType:n,layoutId:r,sectionId:o,sectionType:i=ut.SECTION}){const s=Xi[n],a=s.define,c=s.ssrOptions,u=s.entryFileNames,f=s.chunkFileNames,h=s.assetFileNames,T=s.inlineDynamicImports,w=s.externalOption;return{logLevel:Kr()?void 0:"silent",plugins:Yi[s.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:s.ssr,outDir:s.outDir({name:e,sectionType:i,layoutId:r,sectionId:o}),emptyOutDir:!0,minify:s.ssr?"terser":"esbuild",...s.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:w,preserveEntrySignatures:"strict",input:Dg(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:T,entryFileNames:u,chunkFileNames:f,assetFileNames:h}}},assetsInclude:["**/*.json"]}}const kg=Object.values(we).map(e=>e.source).join("|");function qi(e,t,n){if(!e)return`${t}.mjs`;const r=Io(process.cwd(),e).replace(/\\/g,"/").match(`^(${kg})/([^/]+)/${n}/([^/.]+)`);return r?`${r[1]}/${r[2]}/js/${n}/${r[3]}.mjs`:`${t}.mjs`}function Ji(e,t){const n=Xi[pe.SectionSetting];return{logLevel:Kr()?void 0:"silent",plugins:Yi[n.pluginType](),define:n.define,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:n.ssr,outDir:"./dist",emptyOutDir:!1,minify:"esbuild",rollupOptions:{external:n.externalOption,preserveEntrySignatures:"strict",input:e.map(r=>j(process.cwd(),r)),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:n.inlineDynamicImports,entryFileNames:t,chunkFileNames:"chunks/[name]-[hash].js",assetFileNames:n.assetFileNames}}},assetsInclude:["**/*.json"]}}function Pg(e){return Ji(e,t=>qi(t.facadeModuleId??void 0,t.name,"settings"))}function xg(e){return Ji(e,t=>qi(t.facadeModuleId??void 0,t.name,"showcases"))}async function zg(){const e={ignore:["node_modules/**","dist/**"]},t=await W(`./${Mt}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:r,sectionId:o,pageId:i}=Xm(n),[s,a]=await Promise.all([W(`./${Mt}/${o}/${r}/settings/{content,design,translations}.{js,ts}`,e),W(`./${Mt}/${o}/${r}/assets/*`,e)]);return{name:r,sectionId:o,pageId:i,clientEntrypoint:n,settingsEntryPoints:s,assetsEntrypoints:a}}))}async function Mg(e){await Ke({entryPoints:[e.clientEntrypoint],configType:pe.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([Ke({entryPoints:e.settingsEntryPoints,configType:pe.LayoutSettings,name:e.name,sectionId:e.sectionId}),Ke({entryPoints:e.assetsEntrypoints,configType:pe.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function Ug(e){e===void 0||e.length===0||await Promise.all(e.map(t=>Mg(t)))}async function jg(e){const t=e.flatMap(r=>r.settingsEntryPoints),n=e.flatMap(r=>r.showcaseEntryPoints);t.length>0&&await ct({configFile:!1,...pn(Pg(t))}),n.length>0&&await ct({configFile:!1,...pn(xg(n))})}async function Fg(e){await Promise.all([ct({configFile:!1,...pn(Qi({name:e.name,entryPoints:e.serverEntrypoint,configType:jt.Server,sectionType:e.type}))}),Ke({entryPoints:e.clientEntrypoint,configType:jt.Client,name:e.name,sectionType:e.type}),Ke({entryPoints:e.assetEntryPoints,configType:jt.SectionAsset,name:e.name,sectionType:e.type})])}async function Gg(){const e=j(process.cwd(),"shared/translation.ts");$e(e)&&await Ke({entryPoints:["shared/translation.ts"],configType:jt.SharedTranslation})}async function ea(e){await Promise.all([jg(e),...e.map(Fg)])}function Hg(e){const t=Bn(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t;if(!Ui(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:o,sectionId:n,layoutId:r}}async function Bg(e,t){return Promise.all(e.map(async n=>{const r=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),o=await tn(r?.translationsSettings),i=await Br(r?.content??{},o),s=await Zr(r?.design??{},o);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:i,designEditors:s}}))}async function Zg(){const e={ignore:["node_modules/**","dist/**"]},t=await W(`${Mt}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:r,sectionId:o,layoutId:i}=Hg(n),s=(await W(`${Mt}/${o}/${i}/slots/${r}/client.{js,ts}`,e))[0];if(s===void 0)throw new Error(`Cannot find client entrypoint file for slot ${r} of section ${o}`);return{id:r,sectionId:o,layoutId:i,serverEntrypoint:n,clientEntrypoint:s}}))}async function Vg(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([Ke({entryPoints:[e.serverEntrypoint],configType:pe.SlotServer,...t}),Ke({entryPoints:[e.clientEntrypoint],configType:pe.SlotClient,...t})])}async function Wg(e){e?.length&&await Promise.all(e.map(Vg))}async function Kg(e){return(await W(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=Ao(t).name.toLowerCase();return!Object.values(Us).includes(n)})}async function Yg(){const e=await W("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(I.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(sr),r=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const o=await W(`**/templates/${r}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await W(`**/templates/${r}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await W(`**/templates/${r}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await W(`**/templates/${r}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await W(`**/templates/${r}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await Kg(r);return{name:r,configurationEntrypoint:o.at(0),homeEntrypoint:i.at(0),categoryEntrypoint:s.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:u.length>0?u:void 0}}))}async function Xg(){const e=await W("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await W("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Yg(),templates:e,assets:t}}async function Qg({templateBuildConfig:e}){await Promise.all([Ke({entryPoints:e.assets,configType:jt.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Fn);if(n.length===0)throw new Error("No entry points provided for page template");await Ke({entryPoints:n,configType:jt.PageTemplateDescriptor,name:t.name})})||[]])}async function qg(){const e=await Xg();await Qg({templateBuildConfig:e})}async function Jg(){const e=await W("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(I.error(`Error while getting collection entry points: ${n}`),[])),t=await W("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const r=n.split(sr),o=r.pop()??"default";if(r.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const i=await W(`**/collections/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:o,configurationEntrypoint:i.at(0),assetsEntrypoints:t}}))}async function eE(){const e=await Jg();e.length!==0&&await Promise.all(e.flatMap(t=>[Ke({entryPoints:t.assetsEntrypoints,configType:pe.CollectionAsset,name:t.name}),Ke({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:pe.CollectionDescriptor,name:t.name})]))}function ta(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Fn).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Fn),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Fn),assetEntryPoints:e.assetsEntrypoints??[]}}function tE(e){return e.map(t=>({...t,selectedDesignSettings:t.selectedDesignSettings.map(n=>{const r=n.defaults;return r&&typeof r=="object"&&!("type"in r)?{...n,defaults:{type:n.type,...r}}:n})}))}async function nE(e,t=st){const n=j(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),r=Po(xo.gunzip),o=await ie.promises.readFile(n);return{size:(await r(o)).length}}async function rE(e,t=st){try{const n=j(process.cwd(),`${t}/${e}/assets/`);return(await W("*",{cwd:n})).map(r=>{const o=j(n,r);return{path:r,size:Vt(o).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Yr(e,t){const n=await bm(e,we[t].dist),r=await Hn(e,we[t].dist),o=await Nm(e,we[t].dist),i=await Lm(e,we[t].dist),s=await km(e,we[t].dist),a=await xm(e,we[t].dist),c=tE(a),u=await rE(e,we[t].dist),f=await nE(e,we[t].dist),h=zm(e);return{id:e,type:t,name:e,content:o,design:i,layout:c,showcase:s,translationsSettings:n,translationsShowcases:r,assets:u,server:f,previewCount:h}}async function oE(){const e=await W("*/",{cwd:j(process.cwd(),`${st}/`)}),t=await W("*/",{cwd:j(process.cwd(),`${Mr}/`)}),n=await W("*/",{cwd:j(process.cwd(),`${Ur}/`)});return Promise.all([...e.map(async r=>Yr(r,zt.SECTION)),...t.map(async r=>Yr(r,zt.HEADER)),...n.map(async r=>Yr(r,zt.FOOTER))])}async function sE(e){try{const t=j(process.cwd(),`${e}/assets/`);return(await W("*",{cwd:t})).map(n=>{const r=j(t,n);return{path:n,size:Vt(r).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function iE(e){const t=Bn(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t,[o,i,s,a]=await Promise.all([cE(r,n),uE(r,n),$m(r,n),sE(e)]);return{id:r,sectionId:n,content:o,design:i,translationsSettings:s,assets:a}}async function aE(){const e=`${je}/{product,catalog,category}/*`,t=await W(e,{ignore:["node_modules/**"]});return Promise.all(t.map(iE))}async function cE(e,t){try{const n=j(process.cwd(),`${je}/${t}/${e}/js/settings/content.mjs`),r=await Je(n);return bt(r)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function uE(e,t){try{const n=j(process.cwd(),`${je}/${t}/${e}/js/settings/design.mjs`),r=await Je(n);return bt(r)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function lE(e,t,n){const r=j(process.cwd(),`${je}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),o=Po(xo.gunzip),i=await ie.promises.readFile(r);return{size:(await o(i)).length}}async function pE(e){const t=Bn(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t,i=await lE(o,r,n);return{id:o,sectionId:n,layoutId:r,server:i}}async function fE(){const e=`${je}/{product,catalog,category}/*/slots/*`,t=await W(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(pE))}async function dE(){try{const e=j(process.cwd(),`${ft}/assets/`);return(await W("*",{cwd:e})).map(t=>{const n=j(e,t);return{path:t,size:Vt(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function hE(e){return e in Ot?Ot[e]:Ot.CUSTOM}async function mE(e){const t=await W(`${ft}/${e}/*.mjs`,{ignore:[`${ft}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:r,metadata:o}=await Xr(n),i=sm(n);return{type:hE(i.toUpperCase()),id:i,metadata:o,sections:r}}))}async function Xr(e){try{return await Je(j(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function gE(e){const t=await W(`${ft}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=le.basename(le.dirname(n));return{id:`${e}_${r}`,assets:await dE(),configuration:await Xr(n),pages:await mE(r)}}))}async function EE(e){return await gE(e)}async function _E(){const e=j(process.cwd(),`${em}/translation.mjs`);return await Je(e)}async function yE(){return{translations:await _E()}}async function SE(e){const t=await W(`${Jt}/*/configuration*.mjs`,{ignore:["node_modules/**",`${Jt}/assets/**`]});return Promise.all(t.map(async n=>{const r=le.basename(le.dirname(n)),o=await Xr(n);return{id:`${e}_${r}`,descriptor:o}}))}async function TE(){const e=await Gn(),[t,n,r,o,i,s,a]=await Promise.all([Wr(),yE(),oE(),aE(),fE(),EE(e.appClientId),SE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:r,templates:s,layouts:o,slots:i,collections:a,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue,openSource:t.openSource}}function Qr(e){return $e(`${Mr}/${e}`)?ut.HEADER:$e(`${Ur}/${e}`)?ut.FOOTER:ut.SECTION}async function qr(e,t){const n=e.design?Hr(e.design):void 0,r={...e,design:n??e.design},o=await tn(t);return Ut(r,o)}function Jr(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function na(e){if(Jr(e)){const t=await Hn(e.id,we[Qr(e.id)].dist);return{...e,showcase_overrides:await qr(e.showcase_overrides,t)}}return e}async function RE(e){const t=Jr(e.header)?{...e.header,showcase_overrides:await qr(e.header.showcase_overrides,await Hn(e.header.id,we[Qr(e.header.id)].dist))}:e.header,n=Jr(e.footer)?{...e.footer,showcase_overrides:await qr(e.footer.showcase_overrides,await Hn(e.footer.id,we[Qr(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function OE(e){const t=await Promise.all(e.pages.map(async r=>({...r,sections:await Promise.all(r.sections.map(o=>na(o)))}))),n=await RE(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function vE(e){return Promise.all(e.map(t=>OE(t)))}async function CE(e){const t=new Map;return await Promise.all(e.map(async n=>{const[r,o]=await Promise.all([tn(n.translationsSettings),tn(n.translationsShowcases)]);t.set(n.id,{settings:r,showcases:o})})),t}async function wE(e,t,n){const[r,o,i,s]=await Promise.all([Br(e.content,t,e.type),Zr(e.design,t,e.type),Dm(e.showcase,n),Pm(e.layout)]);return{id:e.id,type:e.type,name:{en:e.name},contentEditors:r,designEditors:o,layouts:s,showcases:i,previewCount:e.previewCount}}async function IE(e,t){return Promise.all(e.map(async n=>{const r=t.get(n.id)??{settings:{},showcases:{}};return wE(n,r.settings,r.showcases)}))}async function AE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(r=>na(r)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function bE(e){const t=await CE(e.sections),[n,r,o,i,s]=await Promise.all([IE(e.sections,t),Qm(e.layouts),Bg(e.slots,e.layouts),vE(e.templates),AE(e.collections)]);return{version:e.version,name:e.name,blocks:n,templates:i,layouts:r,slots:o,compressionEnabled:e.compressionEnabled,externalizationEnabled:e.externalizationEnabled,vueVersion:e.vueVersion,collections:s,openSource:e.openSource}}async function $E(e){const t=j(dn.cwd(),ki);return Xa(t,JSON.stringify(e))}function NE(e){return Object.entries(we).find(t=>t[1].source===e)?.[0]}async function ra(){const e=await W("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=wo(t).split(sr),r=n.pop()??"default",o=n.pop();if(o===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const i=["node_modules/**","dist/**"],[s,a,c,u,f,h,T,w]=await Promise.all([W(`**/${r}/client.{js,ts}`,{ignore:i}),W(`**/${r}/settings/content.{js,ts}`,{ignore:i}),W(`**/${r}/settings/design.{js,ts}`,{ignore:i}),W(`**/${r}/settings/layout.{js,ts}`,{ignore:i}),W(`**/${r}/settings/translations.{js,ts}`,{ignore:i}),W(`**/${r}/showcases/*.{js,ts}`,{ignore:[...i,`**/${r}/showcases/translations.{js,ts}`]}),W(`**/${r}/showcases/translations.{js,ts}`,{ignore:i}),W(`**/${r}/assets/*`,{ignore:i})]);return{name:r,type:NE(o),serverEntrypoint:t,clientEntrypoint:s.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:u.at(0),settingsTranslationsEntrypoint:f.at(0),showcasesEntrypoints:h,showcasesTranslationsEntrypoint:T.at(0),assetsEntrypoints:w}}))}const LE=["/settings/","/showcases/"];function DE(e){return LE.some(t=>e.includes(t))}function kE(){const e=qe.findConfigFile(process.cwd(),qe.sys.fileExists,"tsconfig.json");if(!e)return;const t=qe.readConfigFile(e,qe.sys.readFile),n=qe.parseJsonConfigFileContent(t.config,qe.sys,process.cwd()),r=qe.createProgram(n.fileNames,n.options),o=qe.getPreEmitDiagnostics(r).filter(i=>!i.file||!DE(i.file.fileName));if(o.length>0){const i={getCanonicalFileName:s=>s,getCurrentDirectory:qe.sys.getCurrentDirectory,getNewLine:()=>qe.sys.newLine};throw console.error(qe.formatDiagnosticsWithColorAndContext(o,i)),new Error(`TypeScript found ${o.length} error(s)`)}}async function PE(e){kE(),await ct({configFile:!1,logLevel:"error",plugins:[tt.vue(),tt.tsconfigPaths(),tt.checker()],build:{write:!1,rollupOptions:{input:j(process.cwd(),e)}}})}function xE(){return Promise.all([rr.rm("dist",{recursive:!0,force:!0}),rr.rm("source-code",{recursive:!0,force:!0}),rr.rm("source-code.zip",{force:!0})])}async function zE(){const e=new bo,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"];(await Wr()).openSource===!0&&t.splice(t.indexOf("**/assets/**/*"),1);const n=await W("**/*",{cwd:j(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(i=>{const s=j(process.cwd(),i);e.addLocalFile(s,Ao(i).dir)});const r=rn[ee.SourceCode].fileName,o=j(process.cwd(),r);await e.writeZipPromise(o)}catch(r){throw I.error("Error while zipping source files"),r}}async function Kn(e=!1,t=!1){ug(t),Bi.start(),await xE();try{const[n,r,o]=await Promise.all([zg(),ra(),Zg()]),i=r.map(ta);r.length>0&&await PE(r[0].serverEntrypoint);try{await Promise.all([Gg(),ea(i),qg(),eE(),Ug(n),Wg(o),zE()])}finally{Bi.stop()}const s=await TE(),a=await rg(s);sg(a,e);const c=await bE(s);await $E(c)}catch(n){I.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function Ke({entryPoints:e,configType:t,name:n,sectionType:r,sectionId:o,layoutId:i}){if(e.length!==0){const s=pn(Qi({name:n,entryPoints:e,configType:t,sectionType:r,sectionId:o,layoutId:i}));await ct({configFile:!1,...s})}}function ME(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var eo={},oa;function to(){return oa||(oa=1,(function(e){e.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1,e.find=(t,n)=>t.nodes.find(r=>r.type===n),e.exceedsLimit=(t,n,r=1,o)=>o===!1||!e.isInteger(t)||!e.isInteger(n)?!1:(Number(n)-Number(t))/Number(r)>=o,e.escapeNode=(t,n=0,r)=>{const o=t.nodes[n];o&&(r&&o.type===r||o.type==="open"||o.type==="close")&&o.escaped!==!0&&(o.value="\\"+o.value,o.escaped=!0)},e.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1,e.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1,e.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0,e.reduce=t=>t.reduce((n,r)=>(r.type==="text"&&n.push(r.value),r.type==="range"&&(r.type="text"),n),[]),e.flatten=(...t)=>{const n=[],r=o=>{for(let i=0;i<o.length;i++){const s=o[i];if(Array.isArray(s)){r(s);continue}s!==void 0&&n.push(s)}return n};return r(t),n}})(eo)),eo}var no,sa;function ro(){if(sa)return no;sa=1;const e=to();return no=(t,n={})=>{const r=(o,i={})=>{const s=n.escapeInvalid&&e.isInvalidBrace(i),a=o.invalid===!0&&n.escapeInvalid===!0;let c="";if(o.value)return(s||a)&&e.isOpenOrClose(o)?"\\"+o.value:o.value;if(o.value)return o.value;if(o.nodes)for(const u of o.nodes)c+=r(u);return c};return r(t)},no}/*!
|
|
40
58
|
* is-number <https://github.com/jonschlinkert/is-number>
|
|
41
59
|
*
|
|
42
60
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
43
61
|
* Released under the MIT License.
|
|
44
|
-
*/var
|
|
62
|
+
*/var oo,ia;function UE(){return ia||(ia=1,oo=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}),oo}/*!
|
|
45
63
|
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
46
64
|
*
|
|
47
65
|
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
48
66
|
* Released under the MIT License.
|
|
49
|
-
*/var
|
|
67
|
+
*/var so,aa;function jE(){if(aa)return so;aa=1;const e=UE(),t=(b,v,R)=>{if(e(b)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(v===void 0||b===v)return String(b);if(e(v)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let p={relaxZeros:!0,...R};typeof p.strictZeros=="boolean"&&(p.relaxZeros=p.strictZeros===!1);let l=String(p.relaxZeros),d=String(p.shorthand),E=String(p.capture),m=String(p.wrap),C=b+":"+v+"="+l+d+E+m;if(t.cache.hasOwnProperty(C))return t.cache[C].result;let $=Math.min(b,v),U=Math.max(b,v);if(Math.abs($-U)===1){let F=b+"|"+v;return p.capture?`(${F})`:p.wrap===!1?F:`(?:${F})`}let K=k(b)||k(v),G={min:b,max:v,a:$,b:U},D=[],te=[];if(K&&(G.isPadded=K,G.maxLen=String(G.max).length),$<0){let F=U<0?Math.abs(U):1;te=i(F,Math.abs($),G,p),$=G.a=0}return U>=0&&(D=i($,U,G,p)),G.negatives=te,G.positives=D,G.result=n(te,D),p.capture===!0?G.result=`(${G.result})`:p.wrap!==!1&&D.length+te.length>1&&(G.result=`(?:${G.result})`),t.cache[C]=G,G.result};function n(b,v,R){let p=s(b,v,"-",!1)||[],l=s(v,b,"",!1)||[],d=s(b,v,"-?",!0)||[];return p.concat(d).concat(l).join("|")}function r(b,v){let R=1,p=1,l=f(b,R),d=new Set([v]);for(;b<=l&&l<=v;)d.add(l),R+=1,l=f(b,R);for(l=h(v+1,p)-1;b<l&&l<=v;)d.add(l),p+=1,l=h(v+1,p)-1;return d=[...d],d.sort(c),d}function o(b,v,R){if(b===v)return{pattern:b,count:[],digits:0};let p=a(b,v),l=p.length,d="",E=0;for(let m=0;m<l;m++){let[C,$]=p[m];C===$?d+=C:C!=="0"||$!=="9"?d+=w(C,$):E++}return E&&(d+=R.shorthand===!0?"\\d":"[0-9]"),{pattern:d,count:[E],digits:l}}function i(b,v,R,p){let l=r(b,v),d=[],E=b,m;for(let C=0;C<l.length;C++){let $=l[C],U=o(String(E),String($),p),K="";if(!R.isPadded&&m&&m.pattern===U.pattern){m.count.length>1&&m.count.pop(),m.count.push(U.count[0]),m.string=m.pattern+T(m.count),E=$+1;continue}R.isPadded&&(K=M($,R,p)),U.string=K+U.pattern+T(U.count),d.push(U),E=$+1,m=U}return d}function s(b,v,R,p,l){let d=[];for(let E of b){let{string:m}=E;!p&&!u(v,"string",m)&&d.push(R+m),p&&u(v,"string",m)&&d.push(R+m)}return d}function a(b,v){let R=[];for(let p=0;p<b.length;p++)R.push([b[p],v[p]]);return R}function c(b,v){return b>v?1:v>b?-1:0}function u(b,v,R){return b.some(p=>p[v]===R)}function f(b,v){return Number(String(b).slice(0,-v)+"9".repeat(v))}function h(b,v){return b-b%Math.pow(10,v)}function T(b){let[v=0,R=""]=b;return R||v>1?`{${v+(R?","+R:"")}}`:""}function w(b,v,R){return`[${b}${v-b===1?"":"-"}${v}]`}function k(b){return/^-?(0+)\d/.test(b)}function M(b,v,R){if(!v.isPadded)return b;let p=Math.abs(v.maxLen-String(b).length),l=R.relaxZeros!==!1;switch(p){case 0:return"";case 1:return l?"0?":"0";case 2:return l?"0{0,2}":"00";default:return l?`0{0,${p}}`:`0{${p}}`}}return t.cache={},t.clearCache=()=>t.cache={},so=t,so}/*!
|
|
50
68
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
51
69
|
*
|
|
52
70
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
53
71
|
* Licensed under the MIT License.
|
|
54
|
-
*/var
|
|
55
|
-
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}),Vr}var Wr,na;function hg(){if(na)return Wr;na=1;const e=zr(),{MAX_LENGTH:t,CHAR_BACKSLASH:n,CHAR_BACKTICK:r,CHAR_COMMA:o,CHAR_DOT:i,CHAR_LEFT_PARENTHESES:s,CHAR_RIGHT_PARENTHESES:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_RIGHT_CURLY_BRACE:u,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_RIGHT_SQUARE_BRACKET:h,CHAR_DOUBLE_QUOTE:d,CHAR_SINGLE_QUOTE:b,CHAR_NO_BREAK_SPACE:A,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Z}=fg();return Wr=(T,k={})=>{if(typeof T!="string")throw new TypeError("Expected a string");const p=k||{},S=typeof p.maxLength=="number"?Math.min(t,p.maxLength):t;if(T.length>S)throw new SyntaxError(`Input length (${T.length}), exceeds max characters (${S})`);const m={type:"root",input:T,nodes:[]},O=[m];let y=m,D=m,P=0;const G=T.length;let Y=0,H=0,I;const J=()=>T[Y++],V=X=>{if(X.type==="text"&&D.type==="dot"&&(D.type="text"),D&&D.type==="text"&&X.type==="text"){D.value+=X.value;return}return y.nodes.push(X),X.parent=y,X.prev=D,D=X,X};for(V({type:"bos"});Y<G;)if(y=O[O.length-1],I=J(),!(I===Z||I===A)){if(I===n){V({type:"text",value:(k.keepEscaping?I:"")+J()});continue}if(I===h){V({type:"text",value:"\\"+I});continue}if(I===l){P++;let X;for(;Y<G&&(X=J());){if(I+=X,X===l){P++;continue}if(X===n){I+=J();continue}if(X===h&&(P--,P===0))break}V({type:"text",value:I});continue}if(I===s){y=V({type:"paren",nodes:[]}),O.push(y),V({type:"text",value:I});continue}if(I===a){if(y.type!=="paren"){V({type:"text",value:I});continue}y=O.pop(),V({type:"text",value:I}),y=O[O.length-1];continue}if(I===d||I===b||I===r){const X=I;let j;for(k.keepQuotes!==!0&&(I="");Y<G&&(j=J());){if(j===n){I+=j+J();continue}if(j===X){k.keepQuotes===!0&&(I+=j);break}I+=j}V({type:"text",value:I});continue}if(I===c){H++;const j={type:"brace",open:!0,close:!1,dollar:D.value&&D.value.slice(-1)==="$"||y.dollar===!0,depth:H,commas:0,ranges:0,nodes:[]};y=V(j),O.push(y),V({type:"open",value:I});continue}if(I===u){if(y.type!=="brace"){V({type:"text",value:I});continue}const X="close";y=O.pop(),y.close=!0,V({type:X,value:I}),H--,y=O[O.length-1];continue}if(I===o&&H>0){if(y.ranges>0){y.ranges=0;const X=y.nodes.shift();y.nodes=[X,{type:"text",value:e(y)}]}V({type:"comma",value:I}),y.commas++;continue}if(I===i&&H>0&&y.commas===0){const X=y.nodes;if(H===0||X.length===0){V({type:"text",value:I});continue}if(D.type==="dot"){if(y.range=[],D.value+=I,D.type="range",y.nodes.length!==3&&y.nodes.length!==5){y.invalid=!0,y.ranges=0,D.type="text";continue}y.ranges++,y.args=[];continue}if(D.type==="range"){X.pop();const j=X[X.length-1];j.value+=D.value+I,D=j,y.ranges--;continue}V({type:"dot",value:I});continue}V({type:"text",value:I})}do if(y=O.pop(),y.type!=="root"){y.nodes.forEach(ce=>{ce.nodes||(ce.type==="open"&&(ce.isOpen=!0),ce.type==="close"&&(ce.isClose=!0),ce.nodes||(ce.type="text"),ce.invalid=!0)});const X=O[O.length-1],j=X.nodes.indexOf(y);X.nodes.splice(j,1,...y.nodes)}while(O.length>0);return V({type:"eos"}),m},Wr}var Kr,ra;function mg(){if(ra)return Kr;ra=1;const e=zr(),t=pg(),n=dg(),r=hg(),o=(i,s={})=>{let a=[];if(Array.isArray(i))for(const c of i){const u=o.create(c,s);Array.isArray(u)?a.push(...u):a.push(u)}else a=[].concat(o.create(i,s));return s&&s.expand===!0&&s.nodupes===!0&&(a=[...new Set(a)]),a};return o.parse=(i,s={})=>r(i,s),o.stringify=(i,s={})=>e(typeof i=="string"?o.parse(i,s):i,s),o.compile=(i,s={})=>(typeof i=="string"&&(i=o.parse(i,s)),t(i,s)),o.expand=(i,s={})=>{typeof i=="string"&&(i=o.parse(i,s));let a=n(i,s);return s.noempty===!0&&(a=a.filter(Boolean)),s.nodupes===!0&&(a=[...new Set(a)]),a},o.create=(i,s={})=>i===""||i.length<3?[i]:s.expand!==!0?o.compile(i,s):o.expand(i,s),Kr=o,Kr}var Yr={},Xr,oa;function Gn(){if(oa)return Xr;oa=1;const e=ue,t="\\\\/",n=`[^${t}]`,r="\\.",o="\\+",i="\\?",s="\\/",a="(?=.)",c="[^/]",u=`(?:${s}|$)`,l=`(?:^|${s})`,h=`${r}{1,2}${u}`,d=`(?!${r})`,b=`(?!${l}${h})`,A=`(?!${r}{0,1}${u})`,Z=`(?!${h})`,C=`[^.${s}]`,T=`${c}*?`,k={DOT_LITERAL:r,PLUS_LITERAL:o,QMARK_LITERAL:i,SLASH_LITERAL:s,ONE_CHAR:a,QMARK:c,END_ANCHOR:u,DOTS_SLASH:h,NO_DOT:d,NO_DOTS:b,NO_DOT_SLASH:A,NO_DOTS_SLASH:Z,QMARK_NO_DOT:C,STAR:T,START_ANCHOR:l},p={...k,SLASH_LITERAL:`[${t}]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`${r}{1,2}(?:[${t}]|$)`,NO_DOT:`(?!${r})`,NO_DOTS:`(?!(?:^|[${t}])${r}{1,2}(?:[${t}]|$))`,NO_DOT_SLASH:`(?!${r}{0,1}(?:[${t}]|$))`,NO_DOTS_SLASH:`(?!${r}{1,2}(?:[${t}]|$))`,QMARK_NO_DOT:`[^.${t}]`,START_ANCHOR:`(?:^|[${t}])`,END_ANCHOR:`(?:[${t}]|$)`},S={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return Xr={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:S,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:e.sep,extglobChars(m){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${m.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(m){return m===!0?p:k}},Xr}var sa;function Hn(){return sa||(sa=1,(function(e){const t=ue,n=process.platform==="win32",{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:o,REGEX_SPECIAL_CHARS:i,REGEX_SPECIAL_CHARS_GLOBAL:s}=Gn();e.isObject=a=>a!==null&&typeof a=="object"&&!Array.isArray(a),e.hasRegexChars=a=>i.test(a),e.isRegexChar=a=>a.length===1&&e.hasRegexChars(a),e.escapeRegex=a=>a.replace(s,"\\$1"),e.toPosixSlashes=a=>a.replace(r,"/"),e.removeBackslashes=a=>a.replace(o,c=>c==="\\"?"":c),e.supportsLookbehinds=()=>{const a=process.version.slice(1).split(".").map(Number);return a.length===3&&a[0]>=9||a[0]===8&&a[1]>=10},e.isWindows=a=>a&&typeof a.windows=="boolean"?a.windows:n===!0||t.sep==="\\",e.escapeLast=(a,c,u)=>{const l=a.lastIndexOf(c,u);return l===-1?a:a[l-1]==="\\"?e.escapeLast(a,c,l-1):`${a.slice(0,l)}\\${a.slice(l)}`},e.removePrefix=(a,c={})=>{let u=a;return u.startsWith("./")&&(u=u.slice(2),c.prefix="./"),u},e.wrapOutput=(a,c={},u={})=>{const l=u.contains?"":"^",h=u.contains?"":"$";let d=`${l}(?:${a})${h}`;return c.negated===!0&&(d=`(?:^(?!${d}).*$)`),d}})(Yr)),Yr}var Qr,ia;function Eg(){if(ia)return Qr;ia=1;const e=Hn(),{CHAR_ASTERISK:t,CHAR_AT:n,CHAR_BACKWARD_SLASH:r,CHAR_COMMA:o,CHAR_DOT:i,CHAR_EXCLAMATION_MARK:s,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_LEFT_PARENTHESES:u,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_PLUS:h,CHAR_QUESTION_MARK:d,CHAR_RIGHT_CURLY_BRACE:b,CHAR_RIGHT_PARENTHESES:A,CHAR_RIGHT_SQUARE_BRACKET:Z}=Gn(),C=p=>p===a||p===r,T=p=>{p.isPrefix!==!0&&(p.depth=p.isGlobstar?1/0:1)};return Qr=(p,S)=>{const m=S||{},O=p.length-1,y=m.parts===!0||m.scanToEnd===!0,D=[],P=[],G=[];let Y=p,H=-1,I=0,J=0,V=!1,X=!1,j=!1,ce=!1,ze=!1,_e=!1,g=!1,be=!1,Ve=!1,Oe=!1,E=0,_,W,B={value:"",depth:0,isGlob:!1};const xe=()=>H>=O,nt=()=>Y.charCodeAt(H+1),ye=()=>(_=W,Y.charCodeAt(++H));for(;H<O;){W=ye();let M;if(W===r){g=B.backslashes=!0,W=ye(),W===c&&(_e=!0);continue}if(_e===!0||W===c){for(E++;xe()!==!0&&(W=ye());){if(W===r){g=B.backslashes=!0,ye();continue}if(W===c){E++;continue}if(_e!==!0&&W===i&&(W=ye())===i){if(V=B.isBrace=!0,j=B.isGlob=!0,Oe=!0,y===!0)continue;break}if(_e!==!0&&W===o){if(V=B.isBrace=!0,j=B.isGlob=!0,Oe=!0,y===!0)continue;break}if(W===b&&(E--,E===0)){_e=!1,V=B.isBrace=!0,Oe=!0;break}}if(y===!0)continue;break}if(W===a){if(D.push(H),P.push(B),B={value:"",depth:0,isGlob:!1},Oe===!0)continue;if(_===i&&H===I+1){I+=2;continue}J=H+1;continue}if(m.noext!==!0&&(W===h||W===n||W===t||W===d||W===s)===!0&&nt()===u){if(j=B.isGlob=!0,ce=B.isExtglob=!0,Oe=!0,W===s&&H===I&&(Ve=!0),y===!0){for(;xe()!==!0&&(W=ye());){if(W===r){g=B.backslashes=!0,W=ye();continue}if(W===A){j=B.isGlob=!0,Oe=!0;break}}continue}break}if(W===t){if(_===t&&(ze=B.isGlobstar=!0),j=B.isGlob=!0,Oe=!0,y===!0)continue;break}if(W===d){if(j=B.isGlob=!0,Oe=!0,y===!0)continue;break}if(W===l){for(;xe()!==!0&&(M=ye());){if(M===r){g=B.backslashes=!0,ye();continue}if(M===Z){X=B.isBracket=!0,j=B.isGlob=!0,Oe=!0;break}}if(y===!0)continue;break}if(m.nonegate!==!0&&W===s&&H===I){be=B.negated=!0,I++;continue}if(m.noparen!==!0&&W===u){if(j=B.isGlob=!0,y===!0){for(;xe()!==!0&&(W=ye());){if(W===u){g=B.backslashes=!0,W=ye();continue}if(W===A){Oe=!0;break}}continue}break}if(j===!0){if(Oe=!0,y===!0)continue;break}}m.noext===!0&&(ce=!1,j=!1);let Se=Y,Ft="",We="";I>0&&(Ft=Y.slice(0,I),Y=Y.slice(I),J-=I),Se&&j===!0&&J>0?(Se=Y.slice(0,J),We=Y.slice(J)):j===!0?(Se="",We=Y):Se=Y,Se&&Se!==""&&Se!=="/"&&Se!==Y&&C(Se.charCodeAt(Se.length-1))&&(Se=Se.slice(0,-1)),m.unescape===!0&&(We&&(We=e.removeBackslashes(We)),Se&&g===!0&&(Se=e.removeBackslashes(Se)));const $e={prefix:Ft,input:p,start:I,base:Se,glob:We,isBrace:V,isBracket:X,isGlob:j,isExtglob:ce,isGlobstar:ze,negated:be,negatedExtglob:Ve};if(m.tokens===!0&&($e.maxDepth=0,C(W)||P.push(B),$e.tokens=P),m.parts===!0||m.tokens===!0){let M;for(let Re=0;Re<D.length;Re++){const Vn=M?M+1:I,$=D[Re],ne=p.slice(Vn,$);m.tokens&&(Re===0&&I!==0?(P[Re].isPrefix=!0,P[Re].value=Ft):P[Re].value=ne,T(P[Re]),$e.maxDepth+=P[Re].depth),(Re!==0||ne!=="")&&G.push(ne),M=$}if(M&&M+1<p.length){const Re=p.slice(M+1);G.push(Re),m.tokens&&(P[P.length-1].value=Re,T(P[P.length-1]),$e.maxDepth+=P[P.length-1].depth)}$e.slashes=D,$e.parts=G}return $e},Qr}var qr,aa;function gg(){if(aa)return qr;aa=1;const e=Gn(),t=Hn(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:r,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:i,REPLACEMENTS:s}=e,a=(l,h)=>{if(typeof h.expandRange=="function")return h.expandRange(...l,h);l.sort();const d=`[${l.join("-")}]`;try{new RegExp(d)}catch{return l.map(A=>t.escapeRegex(A)).join("..")}return d},c=(l,h)=>`Missing ${l}: "${h}" - use "\\\\${h}" to match literal characters`,u=(l,h)=>{if(typeof l!="string")throw new TypeError("Expected a string");l=s[l]||l;const d={...h},b=typeof d.maxLength=="number"?Math.min(n,d.maxLength):n;let A=l.length;if(A>b)throw new SyntaxError(`Input length: ${A}, exceeds maximum allowed length: ${b}`);const Z={type:"bos",value:"",output:d.prepend||""},C=[Z],T=d.capture?"":"?:",k=t.isWindows(h),p=e.globChars(k),S=e.extglobChars(p),{DOT_LITERAL:m,PLUS_LITERAL:O,SLASH_LITERAL:y,ONE_CHAR:D,DOTS_SLASH:P,NO_DOT:G,NO_DOT_SLASH:Y,NO_DOTS_SLASH:H,QMARK:I,QMARK_NO_DOT:J,STAR:V,START_ANCHOR:X}=p,j=$=>`(${T}(?:(?!${X}${$.dot?P:m}).)*?)`,ce=d.dot?"":G,ze=d.dot?I:J;let _e=d.bash===!0?j(d):V;d.capture&&(_e=`(${_e})`),typeof d.noext=="boolean"&&(d.noextglob=d.noext);const g={input:l,index:-1,start:0,dot:d.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:C};l=t.removePrefix(l,g),A=l.length;const be=[],Ve=[],Oe=[];let E=Z,_;const W=()=>g.index===A-1,B=g.peek=($=1)=>l[g.index+$],xe=g.advance=()=>l[++g.index]||"",nt=()=>l.slice(g.index+1),ye=($="",ne=0)=>{g.consumed+=$,g.index+=ne},Se=$=>{g.output+=$.output!=null?$.output:$.value,ye($.value)},Ft=()=>{let $=1;for(;B()==="!"&&(B(2)!=="("||B(3)==="?");)xe(),g.start++,$++;return $%2===0?!1:(g.negated=!0,g.start++,!0)},We=$=>{g[$]++,Oe.push($)},$e=$=>{g[$]--,Oe.pop()},M=$=>{if(E.type==="globstar"){const ne=g.braces>0&&($.type==="comma"||$.type==="brace"),v=$.extglob===!0||be.length&&($.type==="pipe"||$.type==="paren");$.type!=="slash"&&$.type!=="paren"&&!ne&&!v&&(g.output=g.output.slice(0,-E.output.length),E.type="star",E.value="*",E.output=_e,g.output+=E.output)}if(be.length&&$.type!=="paren"&&(be[be.length-1].inner+=$.value),($.value||$.output)&&Se($),E&&E.type==="text"&&$.type==="text"){E.value+=$.value,E.output=(E.output||"")+$.value;return}$.prev=E,C.push($),E=$},Re=($,ne)=>{const v={...S[ne],conditions:1,inner:""};v.prev=E,v.parens=g.parens,v.output=g.output;const Q=(d.capture?"(":"")+v.open;We("parens"),M({type:$,value:ne,output:g.output?"":D}),M({type:"paren",extglob:!0,value:xe(),output:Q}),be.push(v)},Vn=$=>{let ne=$.close+(d.capture?")":""),v;if($.type==="negate"){let Q=_e;if($.inner&&$.inner.length>1&&$.inner.includes("/")&&(Q=j(d)),(Q!==_e||W()||/^\)+$/.test(nt()))&&(ne=$.close=`)$))${Q}`),$.inner.includes("*")&&(v=nt())&&/^\.[^\\/.]+$/.test(v)){const de=u(v,{...h,fastpaths:!1}).output;ne=$.close=`)${de})${Q})`}$.prev.type==="bos"&&(g.negatedExtglob=!0)}M({type:"paren",extglob:!0,value:_,output:ne}),$e("parens")};if(d.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(l)){let $=!1,ne=l.replace(i,(v,Q,de,Ne,Ce,Wn)=>Ne==="\\"?($=!0,v):Ne==="?"?Q?Q+Ne+(Ce?I.repeat(Ce.length):""):Wn===0?ze+(Ce?I.repeat(Ce.length):""):I.repeat(de.length):Ne==="."?m.repeat(de.length):Ne==="*"?Q?Q+Ne+(Ce?_e:""):_e:Q?v:`\\${v}`);return $===!0&&(d.unescape===!0?ne=ne.replace(/\\/g,""):ne=ne.replace(/\\+/g,v=>v.length%2===0?"\\\\":v?"\\":"")),ne===l&&d.contains===!0?(g.output=l,g):(g.output=t.wrapOutput(ne,g,h),g)}for(;!W();){if(_=xe(),_==="\0")continue;if(_==="\\"){const v=B();if(v==="/"&&d.bash!==!0||v==="."||v===";")continue;if(!v){_+="\\",M({type:"text",value:_});continue}const Q=/^\\+/.exec(nt());let de=0;if(Q&&Q[0].length>2&&(de=Q[0].length,g.index+=de,de%2!==0&&(_+="\\")),d.unescape===!0?_=xe():_+=xe(),g.brackets===0){M({type:"text",value:_});continue}}if(g.brackets>0&&(_!=="]"||E.value==="["||E.value==="[^")){if(d.posix!==!1&&_===":"){const v=E.value.slice(1);if(v.includes("[")&&(E.posix=!0,v.includes(":"))){const Q=E.value.lastIndexOf("["),de=E.value.slice(0,Q),Ne=E.value.slice(Q+2),Ce=r[Ne];if(Ce){E.value=de+Ce,g.backtrack=!0,xe(),!Z.output&&C.indexOf(E)===1&&(Z.output=D);continue}}}(_==="["&&B()!==":"||_==="-"&&B()==="]")&&(_=`\\${_}`),_==="]"&&(E.value==="["||E.value==="[^")&&(_=`\\${_}`),d.posix===!0&&_==="!"&&E.value==="["&&(_="^"),E.value+=_,Se({value:_});continue}if(g.quotes===1&&_!=='"'){_=t.escapeRegex(_),E.value+=_,Se({value:_});continue}if(_==='"'){g.quotes=g.quotes===1?0:1,d.keepQuotes===!0&&M({type:"text",value:_});continue}if(_==="("){We("parens"),M({type:"paren",value:_});continue}if(_===")"){if(g.parens===0&&d.strictBrackets===!0)throw new SyntaxError(c("opening","("));const v=be[be.length-1];if(v&&g.parens===v.parens+1){Vn(be.pop());continue}M({type:"paren",value:_,output:g.parens?")":"\\)"}),$e("parens");continue}if(_==="["){if(d.nobracket===!0||!nt().includes("]")){if(d.nobracket!==!0&&d.strictBrackets===!0)throw new SyntaxError(c("closing","]"));_=`\\${_}`}else We("brackets");M({type:"bracket",value:_});continue}if(_==="]"){if(d.nobracket===!0||E&&E.type==="bracket"&&E.value.length===1){M({type:"text",value:_,output:`\\${_}`});continue}if(g.brackets===0){if(d.strictBrackets===!0)throw new SyntaxError(c("opening","["));M({type:"text",value:_,output:`\\${_}`});continue}$e("brackets");const v=E.value.slice(1);if(E.posix!==!0&&v[0]==="^"&&!v.includes("/")&&(_=`/${_}`),E.value+=_,Se({value:_}),d.literalBrackets===!1||t.hasRegexChars(v))continue;const Q=t.escapeRegex(E.value);if(g.output=g.output.slice(0,-E.value.length),d.literalBrackets===!0){g.output+=Q,E.value=Q;continue}E.value=`(${T}${Q}|${E.value})`,g.output+=E.value;continue}if(_==="{"&&d.nobrace!==!0){We("braces");const v={type:"brace",value:_,output:"(",outputIndex:g.output.length,tokensIndex:g.tokens.length};Ve.push(v),M(v);continue}if(_==="}"){const v=Ve[Ve.length-1];if(d.nobrace===!0||!v){M({type:"text",value:_,output:_});continue}let Q=")";if(v.dots===!0){const de=C.slice(),Ne=[];for(let Ce=de.length-1;Ce>=0&&(C.pop(),de[Ce].type!=="brace");Ce--)de[Ce].type!=="dots"&&Ne.unshift(de[Ce].value);Q=a(Ne,d),g.backtrack=!0}if(v.comma!==!0&&v.dots!==!0){const de=g.output.slice(0,v.outputIndex),Ne=g.tokens.slice(v.tokensIndex);v.value=v.output="\\{",_=Q="\\}",g.output=de;for(const Ce of Ne)g.output+=Ce.output||Ce.value}M({type:"brace",value:_,output:Q}),$e("braces"),Ve.pop();continue}if(_==="|"){be.length>0&&be[be.length-1].conditions++,M({type:"text",value:_});continue}if(_===","){let v=_;const Q=Ve[Ve.length-1];Q&&Oe[Oe.length-1]==="braces"&&(Q.comma=!0,v="|"),M({type:"comma",value:_,output:v});continue}if(_==="/"){if(E.type==="dot"&&g.index===g.start+1){g.start=g.index+1,g.consumed="",g.output="",C.pop(),E=Z;continue}M({type:"slash",value:_,output:y});continue}if(_==="."){if(g.braces>0&&E.type==="dot"){E.value==="."&&(E.output=m);const v=Ve[Ve.length-1];E.type="dots",E.output+=_,E.value+=_,v.dots=!0;continue}if(g.braces+g.parens===0&&E.type!=="bos"&&E.type!=="slash"){M({type:"text",value:_,output:m});continue}M({type:"dot",value:_,output:m});continue}if(_==="?"){if(!(E&&E.value==="(")&&d.noextglob!==!0&&B()==="("&&B(2)!=="?"){Re("qmark",_);continue}if(E&&E.type==="paren"){const Q=B();let de=_;if(Q==="<"&&!t.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(E.value==="("&&!/[!=<:]/.test(Q)||Q==="<"&&!/<([!=]|\w+>)/.test(nt()))&&(de=`\\${_}`),M({type:"text",value:_,output:de});continue}if(d.dot!==!0&&(E.type==="slash"||E.type==="bos")){M({type:"qmark",value:_,output:J});continue}M({type:"qmark",value:_,output:I});continue}if(_==="!"){if(d.noextglob!==!0&&B()==="("&&(B(2)!=="?"||!/[!=<:]/.test(B(3)))){Re("negate",_);continue}if(d.nonegate!==!0&&g.index===0){Ft();continue}}if(_==="+"){if(d.noextglob!==!0&&B()==="("&&B(2)!=="?"){Re("plus",_);continue}if(E&&E.value==="("||d.regex===!1){M({type:"plus",value:_,output:O});continue}if(E&&(E.type==="bracket"||E.type==="paren"||E.type==="brace")||g.parens>0){M({type:"plus",value:_});continue}M({type:"plus",value:O});continue}if(_==="@"){if(d.noextglob!==!0&&B()==="("&&B(2)!=="?"){M({type:"at",extglob:!0,value:_,output:""});continue}M({type:"text",value:_});continue}if(_!=="*"){(_==="$"||_==="^")&&(_=`\\${_}`);const v=o.exec(nt());v&&(_+=v[0],g.index+=v[0].length),M({type:"text",value:_});continue}if(E&&(E.type==="globstar"||E.star===!0)){E.type="star",E.star=!0,E.value+=_,E.output=_e,g.backtrack=!0,g.globstar=!0,ye(_);continue}let $=nt();if(d.noextglob!==!0&&/^\([^?]/.test($)){Re("star",_);continue}if(E.type==="star"){if(d.noglobstar===!0){ye(_);continue}const v=E.prev,Q=v.prev,de=v.type==="slash"||v.type==="bos",Ne=Q&&(Q.type==="star"||Q.type==="globstar");if(d.bash===!0&&(!de||$[0]&&$[0]!=="/")){M({type:"star",value:_,output:""});continue}const Ce=g.braces>0&&(v.type==="comma"||v.type==="brace"),Wn=be.length&&(v.type==="pipe"||v.type==="paren");if(!de&&v.type!=="paren"&&!Ce&&!Wn){M({type:"star",value:_,output:""});continue}for(;$.slice(0,3)==="/**";){const en=l[g.index+4];if(en&&en!=="/")break;$=$.slice(3),ye("/**",3)}if(v.type==="bos"&&W()){E.type="globstar",E.value+=_,E.output=j(d),g.output=E.output,g.globstar=!0,ye(_);continue}if(v.type==="slash"&&v.prev.type!=="bos"&&!Ne&&W()){g.output=g.output.slice(0,-(v.output+E.output).length),v.output=`(?:${v.output}`,E.type="globstar",E.output=j(d)+(d.strictSlashes?")":"|$)"),E.value+=_,g.globstar=!0,g.output+=v.output+E.output,ye(_);continue}if(v.type==="slash"&&v.prev.type!=="bos"&&$[0]==="/"){const en=$[1]!==void 0?"|$":"";g.output=g.output.slice(0,-(v.output+E.output).length),v.output=`(?:${v.output}`,E.type="globstar",E.output=`${j(d)}${y}|${y}${en})`,E.value+=_,g.output+=v.output+E.output,g.globstar=!0,ye(_+xe()),M({type:"slash",value:"/",output:""});continue}if(v.type==="bos"&&$[0]==="/"){E.type="globstar",E.value+=_,E.output=`(?:^|${y}|${j(d)}${y})`,g.output=E.output,g.globstar=!0,ye(_+xe()),M({type:"slash",value:"/",output:""});continue}g.output=g.output.slice(0,-E.output.length),E.type="globstar",E.output=j(d),E.value+=_,g.output+=E.output,g.globstar=!0,ye(_);continue}const ne={type:"star",value:_,output:_e};if(d.bash===!0){ne.output=".*?",(E.type==="bos"||E.type==="slash")&&(ne.output=ce+ne.output),M(ne);continue}if(E&&(E.type==="bracket"||E.type==="paren")&&d.regex===!0){ne.output=_,M(ne);continue}(g.index===g.start||E.type==="slash"||E.type==="dot")&&(E.type==="dot"?(g.output+=Y,E.output+=Y):d.dot===!0?(g.output+=H,E.output+=H):(g.output+=ce,E.output+=ce),B()!=="*"&&(g.output+=D,E.output+=D)),M(ne)}for(;g.brackets>0;){if(d.strictBrackets===!0)throw new SyntaxError(c("closing","]"));g.output=t.escapeLast(g.output,"["),$e("brackets")}for(;g.parens>0;){if(d.strictBrackets===!0)throw new SyntaxError(c("closing",")"));g.output=t.escapeLast(g.output,"("),$e("parens")}for(;g.braces>0;){if(d.strictBrackets===!0)throw new SyntaxError(c("closing","}"));g.output=t.escapeLast(g.output,"{"),$e("braces")}if(d.strictSlashes!==!0&&(E.type==="star"||E.type==="bracket")&&M({type:"maybe_slash",value:"",output:`${y}?`}),g.backtrack===!0){g.output="";for(const $ of g.tokens)g.output+=$.output!=null?$.output:$.value,$.suffix&&(g.output+=$.suffix)}return g};return u.fastpaths=(l,h)=>{const d={...h},b=typeof d.maxLength=="number"?Math.min(n,d.maxLength):n,A=l.length;if(A>b)throw new SyntaxError(`Input length: ${A}, exceeds maximum allowed length: ${b}`);l=s[l]||l;const Z=t.isWindows(h),{DOT_LITERAL:C,SLASH_LITERAL:T,ONE_CHAR:k,DOTS_SLASH:p,NO_DOT:S,NO_DOTS:m,NO_DOTS_SLASH:O,STAR:y,START_ANCHOR:D}=e.globChars(Z),P=d.dot?m:S,G=d.dot?O:S,Y=d.capture?"":"?:",H={negated:!1,prefix:""};let I=d.bash===!0?".*?":y;d.capture&&(I=`(${I})`);const J=ce=>ce.noglobstar===!0?I:`(${Y}(?:(?!${D}${ce.dot?p:C}).)*?)`,V=ce=>{switch(ce){case"*":return`${P}${k}${I}`;case".*":return`${C}${k}${I}`;case"*.*":return`${P}${I}${C}${k}${I}`;case"*/*":return`${P}${I}${T}${k}${G}${I}`;case"**":return P+J(d);case"**/*":return`(?:${P}${J(d)}${T})?${G}${k}${I}`;case"**/*.*":return`(?:${P}${J(d)}${T})?${G}${I}${C}${k}${I}`;case"**/.*":return`(?:${P}${J(d)}${T})?${C}${k}${I}`;default:{const ze=/^(.*?)\.(\w+)$/.exec(ce);if(!ze)return;const _e=V(ze[1]);return _e?_e+C+ze[2]:void 0}}},X=t.removePrefix(l,H);let j=V(X);return j&&d.strictSlashes!==!0&&(j+=`${T}?`),j},qr=u,qr}var Jr,ca;function _g(){if(ca)return Jr;ca=1;const e=ue,t=Eg(),n=gg(),r=Hn(),o=Gn(),i=a=>a&&typeof a=="object"&&!Array.isArray(a),s=(a,c,u=!1)=>{if(Array.isArray(a)){const T=a.map(p=>s(p,c,u));return p=>{for(const S of T){const m=S(p);if(m)return m}return!1}}const l=i(a)&&a.tokens&&a.input;if(a===""||typeof a!="string"&&!l)throw new TypeError("Expected pattern to be a non-empty string");const h=c||{},d=r.isWindows(c),b=l?s.compileRe(a,c):s.makeRe(a,c,!1,!0),A=b.state;delete b.state;let Z=()=>!1;if(h.ignore){const T={...c,ignore:null,onMatch:null,onResult:null};Z=s(h.ignore,T,u)}const C=(T,k=!1)=>{const{isMatch:p,match:S,output:m}=s.test(T,b,c,{glob:a,posix:d}),O={glob:a,state:A,regex:b,posix:d,input:T,output:m,match:S,isMatch:p};return typeof h.onResult=="function"&&h.onResult(O),p===!1?(O.isMatch=!1,k?O:!1):Z(T)?(typeof h.onIgnore=="function"&&h.onIgnore(O),O.isMatch=!1,k?O:!1):(typeof h.onMatch=="function"&&h.onMatch(O),k?O:!0)};return u&&(C.state=A),C};return s.test=(a,c,u,{glob:l,posix:h}={})=>{if(typeof a!="string")throw new TypeError("Expected input to be a string");if(a==="")return{isMatch:!1,output:""};const d=u||{},b=d.format||(h?r.toPosixSlashes:null);let A=a===l,Z=A&&b?b(a):a;return A===!1&&(Z=b?b(a):a,A=Z===l),(A===!1||d.capture===!0)&&(d.matchBase===!0||d.basename===!0?A=s.matchBase(a,c,u,h):A=c.exec(Z)),{isMatch:!!A,match:A,output:Z}},s.matchBase=(a,c,u,l=r.isWindows(u))=>(c instanceof RegExp?c:s.makeRe(c,u)).test(e.basename(a)),s.isMatch=(a,c,u)=>s(c,u)(a),s.parse=(a,c)=>Array.isArray(a)?a.map(u=>s.parse(u,c)):n(a,{...c,fastpaths:!1}),s.scan=(a,c)=>t(a,c),s.compileRe=(a,c,u=!1,l=!1)=>{if(u===!0)return a.output;const h=c||{},d=h.contains?"":"^",b=h.contains?"":"$";let A=`${d}(?:${a.output})${b}`;a&&a.negated===!0&&(A=`^(?!${A}).*$`);const Z=s.toRegex(A,c);return l===!0&&(Z.state=a),Z},s.makeRe=(a,c={},u=!1,l=!1)=>{if(!a||typeof a!="string")throw new TypeError("Expected a non-empty string");let h={negated:!1,fastpaths:!0};return c.fastpaths!==!1&&(a[0]==="."||a[0]==="*")&&(h.output=n.fastpaths(a,c)),h.output||(h=n(a,c)),s.compileRe(h,c,u,l)},s.toRegex=(a,c)=>{try{const u=c||{};return new RegExp(a,u.flags||(u.nocase?"i":""))}catch(u){if(c&&c.debug===!0)throw u;return/$^/}},s.constants=o,Jr=s,Jr}var eo,ua;function yg(){return ua||(ua=1,eo=_g()),eo}var to,la;function Sg(){if(la)return to;la=1;const e=Ro,t=mg(),n=yg(),r=Hn(),o=a=>a===""||a==="./",i=a=>{const c=a.indexOf("{");return c>-1&&a.indexOf("}",c)>-1},s=(a,c,u)=>{c=[].concat(c),a=[].concat(a);let l=new Set,h=new Set,d=new Set,b=0,A=T=>{d.add(T.output),u&&u.onResult&&u.onResult(T)};for(let T=0;T<c.length;T++){let k=n(String(c[T]),{...u,onResult:A},!0),p=k.state.negated||k.state.negatedExtglob;p&&b++;for(let S of a){let m=k(S,!0);(p?!m.isMatch:m.isMatch)&&(p?l.add(m.output):(l.delete(m.output),h.add(m.output)))}}let C=(b===c.length?[...d]:[...h]).filter(T=>!l.has(T));if(u&&C.length===0){if(u.failglob===!0)throw new Error(`No matches found for "${c.join(", ")}"`);if(u.nonull===!0||u.nullglob===!0)return u.unescape?c.map(T=>T.replace(/\\/g,"")):c}return C};return s.match=s,s.matcher=(a,c)=>n(a,c),s.isMatch=(a,c,u)=>n(c,u)(a),s.any=s.isMatch,s.not=(a,c,u={})=>{c=[].concat(c).map(String);let l=new Set,h=[],d=A=>{u.onResult&&u.onResult(A),h.push(A.output)},b=new Set(s(a,c,{...u,onResult:d}));for(let A of h)b.has(A)||l.add(A);return[...l]},s.contains=(a,c,u)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);if(Array.isArray(c))return c.some(l=>s.contains(a,l,u));if(typeof c=="string"){if(o(a)||o(c))return!1;if(a.includes(c)||a.startsWith("./")&&a.slice(2).includes(c))return!0}return s.isMatch(a,c,{...u,contains:!0})},s.matchKeys=(a,c,u)=>{if(!r.isObject(a))throw new TypeError("Expected the first argument to be an object");let l=s(Object.keys(a),c,u),h={};for(let d of l)h[d]=a[d];return h},s.some=(a,c,u)=>{let l=[].concat(a);for(let h of[].concat(c)){let d=n(String(h),u);if(l.some(b=>d(b)))return!0}return!1},s.every=(a,c,u)=>{let l=[].concat(a);for(let h of[].concat(c)){let d=n(String(h),u);if(!l.every(b=>d(b)))return!1}return!0},s.all=(a,c,u)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);return[].concat(c).every(l=>n(l,u)(a))},s.capture=(a,c,u)=>{let l=r.isWindows(u),d=n.makeRe(String(a),{...u,capture:!0}).exec(l?r.toPosixSlashes(c):c);if(d)return d.slice(1).map(b=>b===void 0?"":b)},s.makeRe=(...a)=>n.makeRe(...a),s.scan=(...a)=>n.scan(...a),s.parse=(a,c)=>{let u=[];for(let l of[].concat(a||[]))for(let h of t(String(l),c))u.push(n.parse(h,c));return u},s.braces=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return c&&c.nobrace===!0||!i(a)?[a]:t(a,c)},s.braceExpand=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return s.braces(a,{...c,expand:!0})},s.hasBraces=i,to=s,to}var Tg=Sg();const Rg=cg(Tg);function pa(e,t,n){tn.statSync(e).isDirectory()?(tn.mkdirSync(t,{recursive:!0}),tn.readdirSync(e).forEach(r=>{const o=rt.resolve(e,r),i=rt.resolve(t,r);pa(o,i,n)})):Rg.isMatch(e,n)||tn.copyFileSync(e,t)}function at(e,t,n,r,o=[]){const i=rt.join(e,r?.[n]??n);pa(rt.join(t,n),i,o)}function Cg(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>N.info(`Template [${e}] with pages structure named has been created`)}}function tt(e){return Le.resolve(Ma(import.meta.url),"../..",e)}function Ig(){const e=tt("package.json");return e!==""?JSON.parse(fe.readFileSync(e,"utf8")):{}}async function wg(e){try{const t=e,n=Te.cwd(),r=Le.join(n,t),o=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],i={_gitignore:".gitignore"};fe.existsSync(r)?(N.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):fe.mkdirSync(r);const s=tt("template");fe.readdirSync(s).filter(l=>l!=="package.json").filter(l=>!o.includes(l)).forEach(async l=>at(r,s,l,i));const a=JSON.parse(fe.readFileSync(Le.join(s,"package.json"),"utf-8"));a.name=e;const c=Ig();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=Le.join(r,"package.json");fe.writeFileSync(u,`${JSON.stringify(a,null,2)}
|
|
56
|
-
`),N.info(`App ${e} created`)}catch(t){N.error(`Error while creating app: ${t.message}`),Te.exit(1)}}function no(e,t,n,r){try{const o=Te.cwd(),i=ue.join(o,t);re.existsSync(i)||re.mkdirSync(i);const s=ue.join(o,t,n);re.existsSync(s)?(N.error(`${r} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):re.mkdirSync(s);const a=tt(e);re.readdirSync(a).forEach(async c=>at(s,a,c)),N.info(`${r} ${n} created`)}catch(o){N.error(`Error while creating ${r}: ${o.message}`),Te.exit(1)}}function ro(e){const t=Te.cwd(),n=tt(`template/${e}`),r=ue.join(t,e);re.existsSync(r)||(re.mkdirSync(r),re.readdirSync(n).forEach(async o=>at(r,n,o)))}async function vg(e,t,n,r){if(!re.existsSync(n)){re.copyFileSync(t,n);return}const o=re.readFileSync(t),i=re.readFileSync(n);o.equals(i)||(r?(await Gt({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"?(re.copyFileSync(t,n),N.info(`Replaced "${e.name}" with template version.`)):N.info(`Kept existing "${e.name}".`):N.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function jn(e,t,n=!1){async function r(i,s,a){const c=ue.join(s,i.name),u=ue.join(a,i.name);i.isDirectory()?await jn(c,u,n):await vg(i,c,u,n)}const o=re.readdirSync(e,{withFileTypes:!0});re.existsSync(t)||re.mkdirSync(t,{recursive:!0}),await o.reduce(async(i,s)=>(await i,r(s,e,t)),Promise.resolve())}async function oo(e=!1){try{const t=Te.cwd(),n=ue.join(t,"shared"),r=tt("template/shared");if(!re.existsSync(r))return;await jn(r,n,e)}catch(t){N.error(`Error while processing shared folder: ${t.message}`),Te.exit(1)}}async function Og(e,t){await oo(),no(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function Ag(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>N.info(`Collection [${e}] has been created`)}}async function bg(e){const{targetPath:t,renameFiles:n,sourcePath:r,onCollectionCreated:o}=Ag(e);try{const i=Te.cwd(),s=Le.join(i,"collections"),a=tt(r),c=fe.readdirSync(a);fe.existsSync(s)?fe.existsSync(Le.join(s,t))&&(N.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):fe.mkdirSync(s),c.forEach(u=>at(s,a,u,n)),o()}catch(i){N.error(`Error while creating collection: ${i.message}`),Te.exit(1)}}async function $g(e){await oo(),no("template/footers/example-footer","footers",e,"Footer")}async function Ng(e){await oo(),no("template/headers/example-header","headers",e,"Header")}async function Lg(e,t){try{const n=Te.cwd(),r=Le.join(n,"templates"),o=tt("template/page-templates/example-template/pages");fe.existsSync(Le.join(r,e))||(N.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),Te.exit(1)),fe.existsSync(Le.join(r,e,"pages",`${t}.ts`))&&(N.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),Te.exit(1));const i=fe.readFileSync(Le.join(o,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${ic(t)}'`),s=Le.join(r,e,"pages",`${t}.ts`);fe.writeFileSync(s,i),N.info(`Page [${t}.ts] created for template ${e}`)}catch(n){N.error(`Error while creating page: ${n.message}`),Te.exit(1)}}async function Dg(){try{const e=Te.cwd(),t=tt("template/reference"),n=fe.readdirSync(t);let r=!1;for(const o of n){const i=Le.join(t,o),s=Le.join(e,o);fe.existsSync(s)||fe.mkdirSync(s,{recursive:!0});const a=fe.readdirSync(i),c=fe.readdirSync(s);if(o==="shared"){a.forEach(u=>{at(s,i,u)});continue}for(const u of a){if(u==="assets"){at(s,i,u);continue}if(c.includes(u)){const{name:l}=await Gt({type:"text",name:"name",message:`The "${u}" already exists in ${o} directory: provide a new name to keep both or press Esc to skip this one.`});l?(at(s,i,u,{[u]:l}),r=!0):N.info(`Skipped: ${u}`)}else at(s,i,u)}}N.info("Reference templates have been added to the app"),r&&N.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){N.error(`Error while creating template descriptors: ${e.message}`),Te.exit(1)}}const kg=["**/example-template/pages/custom.ts"];async function Pg(e){const{targetPath:t,renameFiles:n,sourcePath:r,onTemplateCreated:o}=Cg(e);try{const i=Te.cwd(),s=Le.join(i,"templates"),a=tt(r),c=fe.readdirSync(a);fe.existsSync(s)?fe.existsSync(Le.join(s,t))&&(N.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):fe.mkdirSync(s),c.forEach(u=>at(s,a,u,n,kg)),ro("headers"),ro("footers"),ro("layouts"),o()}catch(i){N.error(`Error while creating template descriptors: ${i.message}`),Te.exit(1)}}function xg(){process.env.CRANE_DEBUG_ENABLED="true"}function Ug(){return process.env.CRANE_DEBUG_ENABLED==="true"}function Mg(e,...t){Ug()&&console.debug(Ta(`[DEBUG] ${e}`),...t)}function Fg(e){const t=U(process.cwd(),`${Ae}/${e}`);if(Ie(t))return we.SECTION;const n=U(process.cwd(),`${Ht}/${e}`);if(Ie(n))return we.HEADER;const r=U(process.cwd(),`${jt}/${e}`);return Ie(r)?we.FOOTER:we.SECTION}function zg(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,r)=>{e.moduleGraph.invalidateAll();const o=new Oa(t.url||"",`http://${t.headers.host}`);if(o.pathname==="/api/v1/block-config"&&t.method==="GET"){const i=o.searchParams.get("section"),s=o.searchParams.get("type");if(!i){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}const a=s&&we[s]||Fg(i);try{const c=await Pn(i,a);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(c))}catch(c){n.statusCode=500,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:c.message}))}return}r()})}}}let yt=null;function Gg(){yt&&yt.clients.forEach(e=>{e.readyState===za.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function Hg(e,t){const n=U(`${e}/ssr-server.ts`),r=U(t);await ot({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function jg(e,t){const n=U(`${e}/shared/preview.ts`),r=U(`${e}/shared/utils.ts`),o=U(`${e}/shared/api-routes.ts`),i=U(t);await ot({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ot({build:{lib:{entry:r,formats:["es"],fileName:()=>"utils.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ot({build:{lib:{entry:o,formats:["es"],fileName:()=>"api-routes.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function Bg(){const e="preview",t=`${e}/shared`,n="vite.config.js",r=`${e}/sections`,o=`${r}/preview.html`;[e,r].forEach(s=>{re.existsSync(s)||re.mkdirSync(s,{recursive:!0})});const i=tt("template/preview");re.copyFileSync(`${i}/${n}`,`${e}/${n}`),await Hg(i,e),re.copyFileSync(`${i}/sections/preview.html`,o),re.existsSync(t)||re.mkdirSync(t),await jg(i,t)}function Zg(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function Vg(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function Wg(e){const t=(await Vi()).find(r=>r.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await zn(!0);return}const n=Bi(t);await ji([n]),console.log(`Block ${e} rebuilt successfully`)}var Kg=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(Kg||{});function Yg(){return{timeout:null,inProgress:!1,pendingBuild:null}}function Xg(e,t){const n=async r=>{e.inProgress=!0;try{r.type==="incremental"&&r.blockName?await Wg(r.blockName):await zn(!0),t.ws.send({type:"full-reload",path:"*"}),Gg()}catch(o){console.error("Build error:",o)}finally{if(e.inProgress=!1,e.pendingBuild){const o=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(o),0)}}};return async r=>{if(e.inProgress){r.type==="full"||e.pendingBuild?.type==="full"?e.pendingBuild={type:"full"}:e.pendingBuild=r;return}await n(r)}}function Qg(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),r=t.match(/headers\/([^/]+)/),o=t.match(/footers\/([^/]+)/),i=t.match(/shared\//);return!!(n||r||o||i)}function qg(e,t){return async n=>{if(!Qg(n))return;e.timeout&&clearTimeout(e.timeout);const r=Zg(n),o=Vg(n);e.timeout=setTimeout(async()=>{o?await t({type:"full"}):r&&await t({type:"incremental",blockName:r})},1e3)}}function Jg(e,t){const n=Yg(),r=Xg(n,e),o=qg(n,r);e.watcher.add(t),e.watcher.on("add",o),e.watcher.on("change",o),e.watcher.on("unlink",o)}async function e_(){const e=ue.resolve(process.cwd(),"preview/ssr-server.mjs");if(!re.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=Eo(e).href);const n=await import(t),{server:r,port:o}=await n.startServer();return{server:r,port:o}}function t_(){yt=new Fa({port:0}),yt.on("listening",()=>{const e=yt?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function n_(){const e=ue.resolve(process.cwd(),"preview/vite.config.js"),t=ue.resolve(process.cwd(),"sections/**/*"),n=ue.resolve(process.cwd(),"headers/**/*"),r=ue.resolve(process.cwd(),"footers/**/*"),o=ue.resolve(process.cwd(),"shared/**/*"),i=await Ca({configFile:e,root:process.cwd(),plugins:[zg()]});return await i.listen(),Jg(i,[t,n,r,o]),i}async function r_(){await zn(),await Bg(),console.log(`
|
|
72
|
+
*/var io,ca;function ua(){if(ca)return io;ca=1;const e=zo,t=jE(),n=p=>p!==null&&typeof p=="object"&&!Array.isArray(p),r=p=>l=>p===!0?Number(l):String(l),o=p=>typeof p=="number"||typeof p=="string"&&p!=="",i=p=>Number.isInteger(+p),s=p=>{let l=`${p}`,d=-1;if(l[0]==="-"&&(l=l.slice(1)),l==="0")return!1;for(;l[++d]==="0";);return d>0},a=(p,l,d)=>typeof p=="string"||typeof l=="string"?!0:d.stringify===!0,c=(p,l,d)=>{if(l>0){let E=p[0]==="-"?"-":"";E&&(p=p.slice(1)),p=E+p.padStart(E?l-1:l,"0")}return d===!1?String(p):p},u=(p,l)=>{let d=p[0]==="-"?"-":"";for(d&&(p=p.slice(1),l--);p.length<l;)p="0"+p;return d?"-"+p:p},f=(p,l,d)=>{p.negatives.sort((U,K)=>U<K?-1:U>K?1:0),p.positives.sort((U,K)=>U<K?-1:U>K?1:0);let E=l.capture?"":"?:",m="",C="",$;return p.positives.length&&(m=p.positives.map(U=>u(String(U),d)).join("|")),p.negatives.length&&(C=`-(${E}${p.negatives.map(U=>u(String(U),d)).join("|")})`),m&&C?$=`${m}|${C}`:$=m||C,l.wrap?`(${E}${$})`:$},h=(p,l,d,E)=>{if(d)return t(p,l,{wrap:!1,...E});let m=String.fromCharCode(p);if(p===l)return m;let C=String.fromCharCode(l);return`[${m}-${C}]`},T=(p,l,d)=>{if(Array.isArray(p)){let E=d.wrap===!0,m=d.capture?"":"?:";return E?`(${m}${p.join("|")})`:p.join("|")}return t(p,l,d)},w=(...p)=>new RangeError("Invalid range arguments: "+e.inspect(...p)),k=(p,l,d)=>{if(d.strictRanges===!0)throw w([p,l]);return[]},M=(p,l)=>{if(l.strictRanges===!0)throw new TypeError(`Expected step "${p}" to be a number`);return[]},b=(p,l,d=1,E={})=>{let m=Number(p),C=Number(l);if(!Number.isInteger(m)||!Number.isInteger(C)){if(E.strictRanges===!0)throw w([p,l]);return[]}m===0&&(m=0),C===0&&(C=0);let $=m>C,U=String(p),K=String(l),G=String(d);d=Math.max(Math.abs(d),1);let D=s(U)||s(K)||s(G),te=D?Math.max(U.length,K.length,G.length):0,F=D===!1&&a(p,l,E)===!1,H=E.transform||r(F);if(E.toRegex&&d===1)return h(u(p,te),u(l,te),!0,E);let B={negatives:[],positives:[]},Te=re=>B[re<0?"negatives":"positives"].push(Math.abs(re)),Xe=[],xe=0;for(;$?m>=C:m<=C;)E.toRegex===!0&&d>1?Te(m):Xe.push(c(H(m,xe),te,F)),m=$?m-d:m+d,xe++;return E.toRegex===!0?d>1?f(B,E,te):T(Xe,null,{wrap:!1,...E}):Xe},v=(p,l,d=1,E={})=>{if(!i(p)&&p.length>1||!i(l)&&l.length>1)return k(p,l,E);let m=E.transform||(F=>String.fromCharCode(F)),C=`${p}`.charCodeAt(0),$=`${l}`.charCodeAt(0),U=C>$,K=Math.min(C,$),G=Math.max(C,$);if(E.toRegex&&d===1)return h(K,G,!1,E);let D=[],te=0;for(;U?C>=$:C<=$;)D.push(m(C,te)),C=U?C-d:C+d,te++;return E.toRegex===!0?T(D,null,{wrap:!1,options:E}):D},R=(p,l,d,E={})=>{if(l==null&&o(p))return[p];if(!o(p)||!o(l))return k(p,l,E);if(typeof d=="function")return R(p,l,1,{transform:d});if(n(d))return R(p,l,0,d);let m={...E};return m.capture===!0&&(m.wrap=!0),d=d||m.step||1,i(d)?i(p)&&i(l)?b(p,l,d,m):v(p,l,Math.max(Math.abs(d),1),m):d!=null&&!n(d)?M(d,m):R(p,l,1,d)};return io=R,io}var ao,la;function FE(){if(la)return ao;la=1;const e=ua(),t=to();return ao=(r,o={})=>{const i=(s,a={})=>{const c=t.isInvalidBrace(a),u=s.invalid===!0&&o.escapeInvalid===!0,f=c===!0||u===!0,h=o.escapeInvalid===!0?"\\":"";let T="";if(s.isOpen===!0)return h+s.value;if(s.isClose===!0)return console.log("node.isClose",h,s.value),h+s.value;if(s.type==="open")return f?h+s.value:"(";if(s.type==="close")return f?h+s.value:")";if(s.type==="comma")return s.prev.type==="comma"?"":f?s.value:"|";if(s.value)return s.value;if(s.nodes&&s.ranges>0){const w=t.reduce(s.nodes),k=e(...w,{...o,wrap:!1,toRegex:!0,strictZeros:!0});if(k.length!==0)return w.length>1&&k.length>1?`(${k})`:k}if(s.nodes)for(const w of s.nodes)T+=i(w,s);return T};return i(r)},ao}var co,pa;function GE(){if(pa)return co;pa=1;const e=ua(),t=ro(),n=to(),r=(i="",s="",a=!1)=>{const c=[];if(i=[].concat(i),s=[].concat(s),!s.length)return i;if(!i.length)return a?n.flatten(s).map(u=>`{${u}}`):s;for(const u of i)if(Array.isArray(u))for(const f of u)c.push(r(f,s,a));else for(let f of s)a===!0&&typeof f=="string"&&(f=`{${f}}`),c.push(Array.isArray(f)?r(u,f,a):u+f);return n.flatten(c)};return co=(i,s={})=>{const a=s.rangeLimit===void 0?1e3:s.rangeLimit,c=(u,f={})=>{u.queue=[];let h=f,T=f.queue;for(;h.type!=="brace"&&h.type!=="root"&&h.parent;)h=h.parent,T=h.queue;if(u.invalid||u.dollar){T.push(r(T.pop(),t(u,s)));return}if(u.type==="brace"&&u.invalid!==!0&&u.nodes.length===2){T.push(r(T.pop(),["{}"]));return}if(u.nodes&&u.ranges>0){const b=n.reduce(u.nodes);if(n.exceedsLimit(...b,s.step,a))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let v=e(...b,s);v.length===0&&(v=t(u,s)),T.push(r(T.pop(),v)),u.nodes=[];return}const w=n.encloseBrace(u);let k=u.queue,M=u;for(;M.type!=="brace"&&M.type!=="root"&&M.parent;)M=M.parent,k=M.queue;for(let b=0;b<u.nodes.length;b++){const v=u.nodes[b];if(v.type==="comma"&&u.type==="brace"){b===1&&k.push(""),k.push("");continue}if(v.type==="close"){T.push(r(T.pop(),k,w));continue}if(v.value&&v.type!=="open"){k.push(r(k.pop(),v.value));continue}v.nodes&&c(v,u)}return k};return n.flatten(c(i))},co}var uo,fa;function HE(){return fa||(fa=1,uo={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
73
|
+
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}),uo}var lo,da;function BE(){if(da)return lo;da=1;const e=ro(),{MAX_LENGTH:t,CHAR_BACKSLASH:n,CHAR_BACKTICK:r,CHAR_COMMA:o,CHAR_DOT:i,CHAR_LEFT_PARENTHESES:s,CHAR_RIGHT_PARENTHESES:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_RIGHT_CURLY_BRACE:u,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_RIGHT_SQUARE_BRACKET:h,CHAR_DOUBLE_QUOTE:T,CHAR_SINGLE_QUOTE:w,CHAR_NO_BREAK_SPACE:k,CHAR_ZERO_WIDTH_NOBREAK_SPACE:M}=HE();return lo=(v,R={})=>{if(typeof v!="string")throw new TypeError("Expected a string");const p=R||{},l=typeof p.maxLength=="number"?Math.min(t,p.maxLength):t;if(v.length>l)throw new SyntaxError(`Input length (${v.length}), exceeds max characters (${l})`);const d={type:"root",input:v,nodes:[]},E=[d];let m=d,C=d,$=0;const U=v.length;let K=0,G=0,D;const te=()=>v[K++],F=H=>{if(H.type==="text"&&C.type==="dot"&&(C.type="text"),C&&C.type==="text"&&H.type==="text"){C.value+=H.value;return}return m.nodes.push(H),H.parent=m,H.prev=C,C=H,H};for(F({type:"bos"});K<U;)if(m=E[E.length-1],D=te(),!(D===M||D===k)){if(D===n){F({type:"text",value:(R.keepEscaping?D:"")+te()});continue}if(D===h){F({type:"text",value:"\\"+D});continue}if(D===f){$++;let H;for(;K<U&&(H=te());){if(D+=H,H===f){$++;continue}if(H===n){D+=te();continue}if(H===h&&($--,$===0))break}F({type:"text",value:D});continue}if(D===s){m=F({type:"paren",nodes:[]}),E.push(m),F({type:"text",value:D});continue}if(D===a){if(m.type!=="paren"){F({type:"text",value:D});continue}m=E.pop(),F({type:"text",value:D}),m=E[E.length-1];continue}if(D===T||D===w||D===r){const H=D;let B;for(R.keepQuotes!==!0&&(D="");K<U&&(B=te());){if(B===n){D+=B+te();continue}if(B===H){R.keepQuotes===!0&&(D+=B);break}D+=B}F({type:"text",value:D});continue}if(D===c){G++;const B={type:"brace",open:!0,close:!1,dollar:C.value&&C.value.slice(-1)==="$"||m.dollar===!0,depth:G,commas:0,ranges:0,nodes:[]};m=F(B),E.push(m),F({type:"open",value:D});continue}if(D===u){if(m.type!=="brace"){F({type:"text",value:D});continue}const H="close";m=E.pop(),m.close=!0,F({type:H,value:D}),G--,m=E[E.length-1];continue}if(D===o&&G>0){if(m.ranges>0){m.ranges=0;const H=m.nodes.shift();m.nodes=[H,{type:"text",value:e(m)}]}F({type:"comma",value:D}),m.commas++;continue}if(D===i&&G>0&&m.commas===0){const H=m.nodes;if(G===0||H.length===0){F({type:"text",value:D});continue}if(C.type==="dot"){if(m.range=[],C.value+=D,C.type="range",m.nodes.length!==3&&m.nodes.length!==5){m.invalid=!0,m.ranges=0,C.type="text";continue}m.ranges++,m.args=[];continue}if(C.type==="range"){H.pop();const B=H[H.length-1];B.value+=C.value+D,C=B,m.ranges--;continue}F({type:"dot",value:D});continue}F({type:"text",value:D})}do if(m=E.pop(),m.type!=="root"){m.nodes.forEach(Te=>{Te.nodes||(Te.type==="open"&&(Te.isOpen=!0),Te.type==="close"&&(Te.isClose=!0),Te.nodes||(Te.type="text"),Te.invalid=!0)});const H=E[E.length-1],B=H.nodes.indexOf(m);H.nodes.splice(B,1,...m.nodes)}while(E.length>0);return F({type:"eos"}),d},lo}var po,ha;function ZE(){if(ha)return po;ha=1;const e=ro(),t=FE(),n=GE(),r=BE(),o=(i,s={})=>{let a=[];if(Array.isArray(i))for(const c of i){const u=o.create(c,s);Array.isArray(u)?a.push(...u):a.push(u)}else a=[].concat(o.create(i,s));return s&&s.expand===!0&&s.nodupes===!0&&(a=[...new Set(a)]),a};return o.parse=(i,s={})=>r(i,s),o.stringify=(i,s={})=>e(typeof i=="string"?o.parse(i,s):i,s),o.compile=(i,s={})=>(typeof i=="string"&&(i=o.parse(i,s)),t(i,s)),o.expand=(i,s={})=>{typeof i=="string"&&(i=o.parse(i,s));let a=n(i,s);return s.noempty===!0&&(a=a.filter(Boolean)),s.nodupes===!0&&(a=[...new Set(a)]),a},o.create=(i,s={})=>i===""||i.length<3?[i]:s.expand!==!0?o.compile(i,s):o.expand(i,s),po=o,po}var fo={},ho,ma;function Yn(){if(ma)return ho;ma=1;const e=le,t="\\\\/",n=`[^${t}]`,r=0,o="\\.",i="\\+",s="\\?",a="\\/",c="(?=.)",u="[^/]",f=`(?:${a}|$)`,h=`(?:^|${a})`,T=`${o}{1,2}${f}`,w=`(?!${o})`,k=`(?!${h}${T})`,M=`(?!${o}{0,1}${f})`,b=`(?!${T})`,v=`[^.${a}]`,R=`${u}*?`,p={DOT_LITERAL:o,PLUS_LITERAL:i,QMARK_LITERAL:s,SLASH_LITERAL:a,ONE_CHAR:c,QMARK:u,END_ANCHOR:f,DOTS_SLASH:T,NO_DOT:w,NO_DOTS:k,NO_DOT_SLASH:M,NO_DOTS_SLASH:b,QMARK_NO_DOT:v,STAR:R,START_ANCHOR:h},l={...p,SLASH_LITERAL:`[${t}]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`${o}{1,2}(?:[${t}]|$)`,NO_DOT:`(?!${o})`,NO_DOTS:`(?!(?:^|[${t}])${o}{1,2}(?:[${t}]|$))`,NO_DOT_SLASH:`(?!${o}{0,1}(?:[${t}]|$))`,NO_DOTS_SLASH:`(?!${o}{1,2}(?:[${t}]|$))`,QMARK_NO_DOT:`[^.${t}]`,START_ANCHOR:`(?:^|[${t}])`,END_ANCHOR:`(?:[${t}]|$)`},d={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return ho={DEFAULT_MAX_EXTGLOB_RECURSION:r,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:d,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:e.sep,extglobChars(E){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${E.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(E){return E===!0?l:p}},ho}var ga;function Xn(){return ga||(ga=1,(function(e){const t=le,n=process.platform==="win32",{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:o,REGEX_SPECIAL_CHARS:i,REGEX_SPECIAL_CHARS_GLOBAL:s}=Yn();e.isObject=a=>a!==null&&typeof a=="object"&&!Array.isArray(a),e.hasRegexChars=a=>i.test(a),e.isRegexChar=a=>a.length===1&&e.hasRegexChars(a),e.escapeRegex=a=>a.replace(s,"\\$1"),e.toPosixSlashes=a=>a.replace(r,"/"),e.removeBackslashes=a=>a.replace(o,c=>c==="\\"?"":c),e.supportsLookbehinds=()=>{const a=process.version.slice(1).split(".").map(Number);return a.length===3&&a[0]>=9||a[0]===8&&a[1]>=10},e.isWindows=a=>a&&typeof a.windows=="boolean"?a.windows:n===!0||t.sep==="\\",e.escapeLast=(a,c,u)=>{const f=a.lastIndexOf(c,u);return f===-1?a:a[f-1]==="\\"?e.escapeLast(a,c,f-1):`${a.slice(0,f)}\\${a.slice(f)}`},e.removePrefix=(a,c={})=>{let u=a;return u.startsWith("./")&&(u=u.slice(2),c.prefix="./"),u},e.wrapOutput=(a,c={},u={})=>{const f=u.contains?"":"^",h=u.contains?"":"$";let T=`${f}(?:${a})${h}`;return c.negated===!0&&(T=`(?:^(?!${T}).*$)`),T}})(fo)),fo}var mo,Ea;function VE(){if(Ea)return mo;Ea=1;const e=Xn(),{CHAR_ASTERISK:t,CHAR_AT:n,CHAR_BACKWARD_SLASH:r,CHAR_COMMA:o,CHAR_DOT:i,CHAR_EXCLAMATION_MARK:s,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_LEFT_PARENTHESES:u,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:h,CHAR_QUESTION_MARK:T,CHAR_RIGHT_CURLY_BRACE:w,CHAR_RIGHT_PARENTHESES:k,CHAR_RIGHT_SQUARE_BRACKET:M}=Yn(),b=p=>p===a||p===r,v=p=>{p.isPrefix!==!0&&(p.depth=p.isGlobstar?1/0:1)};return mo=(p,l)=>{const d=l||{},E=p.length-1,m=d.parts===!0||d.scanToEnd===!0,C=[],$=[],U=[];let K=p,G=-1,D=0,te=0,F=!1,H=!1,B=!1,Te=!1,Xe=!1,xe=!1,re=!1,nt=!1,Tt=!1,be=!1,Ae=0,ze,Z,q={value:"",depth:0,isGlob:!1};const y=()=>G>=E,ke=()=>K.charCodeAt(G+1),Re=()=>(ze=Z,K.charCodeAt(++G));for(;G<E;){Z=Re();let se;if(Z===r){re=q.backslashes=!0,Z=Re(),Z===c&&(xe=!0);continue}if(xe===!0||Z===c){for(Ae++;y()!==!0&&(Z=Re());){if(Z===r){re=q.backslashes=!0,Re();continue}if(Z===c){Ae++;continue}if(xe!==!0&&Z===i&&(Z=Re())===i){if(F=q.isBrace=!0,B=q.isGlob=!0,be=!0,m===!0)continue;break}if(xe!==!0&&Z===o){if(F=q.isBrace=!0,B=q.isGlob=!0,be=!0,m===!0)continue;break}if(Z===w&&(Ae--,Ae===0)){xe=!1,F=q.isBrace=!0,be=!0;break}}if(m===!0)continue;break}if(Z===a){if(C.push(G),$.push(q),q={value:"",depth:0,isGlob:!1},be===!0)continue;if(ze===i&&G===D+1){D+=2;continue}te=G+1;continue}if(d.noext!==!0&&(Z===h||Z===n||Z===t||Z===T||Z===s)===!0&&ke()===u){if(B=q.isGlob=!0,Te=q.isExtglob=!0,be=!0,Z===s&&G===D&&(Tt=!0),m===!0){for(;y()!==!0&&(Z=Re());){if(Z===r){re=q.backslashes=!0,Z=Re();continue}if(Z===k){B=q.isGlob=!0,be=!0;break}}continue}break}if(Z===t){if(ze===t&&(Xe=q.isGlobstar=!0),B=q.isGlob=!0,be=!0,m===!0)continue;break}if(Z===T){if(B=q.isGlob=!0,be=!0,m===!0)continue;break}if(Z===f){for(;y()!==!0&&(se=Re());){if(se===r){re=q.backslashes=!0,Re();continue}if(se===M){H=q.isBracket=!0,B=q.isGlob=!0,be=!0;break}}if(m===!0)continue;break}if(d.nonegate!==!0&&Z===s&&G===D){nt=q.negated=!0,D++;continue}if(d.noparen!==!0&&Z===u){if(B=q.isGlob=!0,m===!0){for(;y()!==!0&&(Z=Re());){if(Z===u){re=q.backslashes=!0,Z=Re();continue}if(Z===k){be=!0;break}}continue}break}if(B===!0){if(be=!0,m===!0)continue;break}}d.noext===!0&&(Te=!1,B=!1);let ye=K,S="",_="";D>0&&(S=K.slice(0,D),K=K.slice(D),te-=D),ye&&B===!0&&te>0?(ye=K.slice(0,te),_=K.slice(te)):B===!0?(ye="",_=K):ye=K,ye&&ye!==""&&ye!=="/"&&ye!==K&&b(ye.charCodeAt(ye.length-1))&&(ye=ye.slice(0,-1)),d.unescape===!0&&(_&&(_=e.removeBackslashes(_)),ye&&re===!0&&(ye=e.removeBackslashes(ye)));const Fe={prefix:S,input:p,start:D,base:ye,glob:_,isBrace:F,isBracket:H,isGlob:B,isExtglob:Te,isGlobstar:Xe,negated:nt,negatedExtglob:Tt};if(d.tokens===!0&&(Fe.maxDepth=0,b(Z)||$.push(q),Fe.tokens=$),d.parts===!0||d.tokens===!0){let se;for(let de=0;de<C.length;de++){const at=se?se+1:D,Ge=C[de],ht=p.slice(at,Ge);d.tokens&&(de===0&&D!==0?($[de].isPrefix=!0,$[de].value=S):$[de].value=ht,v($[de]),Fe.maxDepth+=$[de].depth),(de!==0||ht!=="")&&U.push(ht),se=Ge}if(se&&se+1<p.length){const de=p.slice(se+1);U.push(de),d.tokens&&($[$.length-1].value=de,v($[$.length-1]),Fe.maxDepth+=$[$.length-1].depth)}Fe.slashes=C,Fe.parts=U}return Fe},mo}var go,_a;function WE(){if(_a)return go;_a=1;const e=Yn(),t=Xn(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:r,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:i,REPLACEMENTS:s}=e,a=(R,p)=>{if(typeof p.expandRange=="function")return p.expandRange(...R,p);R.sort();const l=`[${R.join("-")}]`;try{new RegExp(l)}catch{return R.map(E=>t.escapeRegex(E)).join("..")}return l},c=(R,p)=>`Missing ${R}: "${p}" - use "\\\\${p}" to match literal characters`,u=R=>{const p=[];let l=0,d=0,E=0,m="",C=!1;for(const $ of R){if(C===!0){m+=$,C=!1;continue}if($==="\\"){m+=$,C=!0;continue}if($==='"'){E=E===1?0:1,m+=$;continue}if(E===0){if($==="[")l++;else if($==="]"&&l>0)l--;else if(l===0){if($==="(")d++;else if($===")"&&d>0)d--;else if($==="|"&&d===0){p.push(m),m="";continue}}}m+=$}return p.push(m),p},f=R=>{let p=!1;for(const l of R){if(p===!0){p=!1;continue}if(l==="\\"){p=!0;continue}if(/[?*+@!()[\]{}]/.test(l))return!1}return!0},h=R=>{let p=R.trim(),l=!0;for(;l===!0;)l=!1,/^@\([^\\()[\]{}|]+\)$/.test(p)&&(p=p.slice(2,-1),l=!0);if(f(p))return p.replace(/\\(.)/g,"$1")},T=R=>{const p=R.map(h).filter(Boolean);for(let l=0;l<p.length;l++)for(let d=l+1;d<p.length;d++){const E=p[l],m=p[d],C=E[0];if(!(!C||E!==C.repeat(E.length)||m!==C.repeat(m.length))&&(E===m||E.startsWith(m)||m.startsWith(E)))return!0}return!1},w=(R,p=!0)=>{if(R[0]!=="+"&&R[0]!=="*"||R[1]!=="(")return;let l=0,d=0,E=0,m=!1;for(let C=1;C<R.length;C++){const $=R[C];if(m===!0){m=!1;continue}if($==="\\"){m=!0;continue}if($==='"'){E=E===1?0:1;continue}if(E!==1){if($==="["){l++;continue}if($==="]"&&l>0){l--;continue}if(!(l>0)){if($==="("){d++;continue}if($===")"&&(d--,d===0))return p===!0&&C!==R.length-1?void 0:{type:R[0],body:R.slice(2,C),end:C}}}}},k=R=>{let p=0;const l=[];for(;p<R.length;){const E=w(R.slice(p),!1);if(!E||E.type!=="*")return;const m=u(E.body).map($=>$.trim());if(m.length!==1)return;const C=h(m[0]);if(!C||C.length!==1)return;l.push(C),p+=E.end+1}return l.length<1?void 0:`${l.length===1?t.escapeRegex(l[0]):`[${l.map(E=>t.escapeRegex(E)).join("")}]`}*`},M=R=>{let p=0,l=R.trim(),d=w(l);for(;d;)p++,l=d.body.trim(),d=w(l);return p},b=(R,p)=>{if(p.maxExtglobRecursion===!1)return{risky:!1};const l=typeof p.maxExtglobRecursion=="number"?p.maxExtglobRecursion:e.DEFAULT_MAX_EXTGLOB_RECURSION,d=u(R).map(E=>E.trim());if(d.length>1&&(d.some(E=>E==="")||d.some(E=>/^[*?]+$/.test(E))||T(d)))return{risky:!0};for(const E of d){const m=k(E);if(m)return{risky:!0,safeOutput:m};if(M(E)>l)return{risky:!0}}return{risky:!1}},v=(R,p)=>{if(typeof R!="string")throw new TypeError("Expected a string");R=s[R]||R;const l={...p},d=typeof l.maxLength=="number"?Math.min(n,l.maxLength):n;let E=R.length;if(E>d)throw new SyntaxError(`Input length: ${E}, exceeds maximum allowed length: ${d}`);const m={type:"bos",value:"",output:l.prepend||""},C=[m],$=l.capture?"":"?:",U=t.isWindows(p),K=e.globChars(U),G=e.extglobChars(K),{DOT_LITERAL:D,PLUS_LITERAL:te,SLASH_LITERAL:F,ONE_CHAR:H,DOTS_SLASH:B,NO_DOT:Te,NO_DOT_SLASH:Xe,NO_DOTS_SLASH:xe,QMARK:re,QMARK_NO_DOT:nt,STAR:Tt,START_ANCHOR:be}=K,Ae=L=>`(${$}(?:(?!${be}${L.dot?B:D}).)*?)`,ze=l.dot?"":Te,Z=l.dot?re:nt;let q=l.bash===!0?Ae(l):Tt;l.capture&&(q=`(${q})`),typeof l.noext=="boolean"&&(l.noextglob=l.noext);const y={input:R,index:-1,start:0,dot:l.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:C};R=t.removePrefix(R,y),E=R.length;const ke=[],Re=[],ye=[];let S=m,_;const Fe=()=>y.index===E-1,se=y.peek=(L=1)=>R[y.index+L],de=y.advance=()=>R[++y.index]||"",at=()=>R.slice(y.index+1),Ge=(L="",ue=0)=>{y.consumed+=L,y.index+=ue},ht=L=>{y.output+=L.output!=null?L.output:L.value,Ge(L.value)},ka=()=>{let L=1;for(;se()==="!"&&(se(2)!=="("||se(3)==="?");)de(),y.start++,L++;return L%2===0?!1:(y.negated=!0,y.start++,!0)},an=L=>{y[L]++,ye.push(L)},mt=L=>{y[L]--,ye.pop()},X=L=>{if(S.type==="globstar"){const ue=y.braces>0&&(L.type==="comma"||L.type==="brace"),N=L.extglob===!0||ke.length&&(L.type==="pipe"||L.type==="paren");L.type!=="slash"&&L.type!=="paren"&&!ue&&!N&&(y.output=y.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=q,y.output+=S.output)}if(ke.length&&L.type!=="paren"&&(ke[ke.length-1].inner+=L.value),(L.value||L.output)&&ht(L),S&&S.type==="text"&&L.type==="text"){S.value+=L.value,S.output=(S.output||"")+L.value;return}L.prev=S,C.push(L),S=L},cn=(L,ue)=>{const N={...G[ue],conditions:1,inner:""};N.prev=S,N.parens=y.parens,N.output=y.output,N.startIndex=y.index,N.tokensIndex=C.length;const Y=(l.capture?"(":"")+N.open;an("parens"),X({type:L,value:ue,output:y.output?"":H}),X({type:"paren",extglob:!0,value:de(),output:Y}),ke.push(N)},Pa=L=>{const ue=R.slice(L.startIndex,y.index+1),N=R.slice(L.startIndex+2,y.index),Y=b(N,l);if((L.type==="plus"||L.type==="star")&&Y.risky){const ae=Y.safeOutput?(L.output?"":H)+(l.capture?`(${Y.safeOutput})`:Y.safeOutput):void 0,rt=C[L.tokensIndex];rt.type="text",rt.value=ue,rt.output=ae||t.escapeRegex(ue);for(let ot=L.tokensIndex+1;ot<C.length;ot++)C[ot].value="",C[ot].output="",delete C[ot].suffix;y.output=L.output+rt.output,y.backtrack=!0,X({type:"paren",extglob:!0,value:_,output:""}),mt("parens");return}let ce=L.close+(l.capture?")":""),Ce;if(L.type==="negate"){let ae=q;if(L.inner&&L.inner.length>1&&L.inner.includes("/")&&(ae=Ae(l)),(ae!==q||Fe()||/^\)+$/.test(at()))&&(ce=L.close=`)$))${ae}`),L.inner.includes("*")&&(Ce=at())&&/^\.[^\\/.]+$/.test(Ce)){const rt=v(Ce,{...p,fastpaths:!1}).output;ce=L.close=`)${rt})${ae})`}L.prev.type==="bos"&&(y.negatedExtglob=!0)}X({type:"paren",extglob:!0,value:_,output:ce}),mt("parens")};if(l.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(R)){let L=!1,ue=R.replace(i,(N,Y,ce,Ce,ae,rt)=>Ce==="\\"?(L=!0,N):Ce==="?"?Y?Y+Ce+(ae?re.repeat(ae.length):""):rt===0?Z+(ae?re.repeat(ae.length):""):re.repeat(ce.length):Ce==="."?D.repeat(ce.length):Ce==="*"?Y?Y+Ce+(ae?q:""):q:Y?N:`\\${N}`);return L===!0&&(l.unescape===!0?ue=ue.replace(/\\/g,""):ue=ue.replace(/\\+/g,N=>N.length%2===0?"\\\\":N?"\\":"")),ue===R&&l.contains===!0?(y.output=R,y):(y.output=t.wrapOutput(ue,y,p),y)}for(;!Fe();){if(_=de(),_==="\0")continue;if(_==="\\"){const N=se();if(N==="/"&&l.bash!==!0||N==="."||N===";")continue;if(!N){_+="\\",X({type:"text",value:_});continue}const Y=/^\\+/.exec(at());let ce=0;if(Y&&Y[0].length>2&&(ce=Y[0].length,y.index+=ce,ce%2!==0&&(_+="\\")),l.unescape===!0?_=de():_+=de(),y.brackets===0){X({type:"text",value:_});continue}}if(y.brackets>0&&(_!=="]"||S.value==="["||S.value==="[^")){if(l.posix!==!1&&_===":"){const N=S.value.slice(1);if(N.includes("[")&&(S.posix=!0,N.includes(":"))){const Y=S.value.lastIndexOf("["),ce=S.value.slice(0,Y),Ce=S.value.slice(Y+2),ae=r[Ce];if(ae){S.value=ce+ae,y.backtrack=!0,de(),!m.output&&C.indexOf(S)===1&&(m.output=H);continue}}}(_==="["&&se()!==":"||_==="-"&&se()==="]")&&(_=`\\${_}`),_==="]"&&(S.value==="["||S.value==="[^")&&(_=`\\${_}`),l.posix===!0&&_==="!"&&S.value==="["&&(_="^"),S.value+=_,ht({value:_});continue}if(y.quotes===1&&_!=='"'){_=t.escapeRegex(_),S.value+=_,ht({value:_});continue}if(_==='"'){y.quotes=y.quotes===1?0:1,l.keepQuotes===!0&&X({type:"text",value:_});continue}if(_==="("){an("parens"),X({type:"paren",value:_});continue}if(_===")"){if(y.parens===0&&l.strictBrackets===!0)throw new SyntaxError(c("opening","("));const N=ke[ke.length-1];if(N&&y.parens===N.parens+1){Pa(ke.pop());continue}X({type:"paren",value:_,output:y.parens?")":"\\)"}),mt("parens");continue}if(_==="["){if(l.nobracket===!0||!at().includes("]")){if(l.nobracket!==!0&&l.strictBrackets===!0)throw new SyntaxError(c("closing","]"));_=`\\${_}`}else an("brackets");X({type:"bracket",value:_});continue}if(_==="]"){if(l.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){X({type:"text",value:_,output:`\\${_}`});continue}if(y.brackets===0){if(l.strictBrackets===!0)throw new SyntaxError(c("opening","["));X({type:"text",value:_,output:`\\${_}`});continue}mt("brackets");const N=S.value.slice(1);if(S.posix!==!0&&N[0]==="^"&&!N.includes("/")&&(_=`/${_}`),S.value+=_,ht({value:_}),l.literalBrackets===!1||t.hasRegexChars(N))continue;const Y=t.escapeRegex(S.value);if(y.output=y.output.slice(0,-S.value.length),l.literalBrackets===!0){y.output+=Y,S.value=Y;continue}S.value=`(${$}${Y}|${S.value})`,y.output+=S.value;continue}if(_==="{"&&l.nobrace!==!0){an("braces");const N={type:"brace",value:_,output:"(",outputIndex:y.output.length,tokensIndex:y.tokens.length};Re.push(N),X(N);continue}if(_==="}"){const N=Re[Re.length-1];if(l.nobrace===!0||!N){X({type:"text",value:_,output:_});continue}let Y=")";if(N.dots===!0){const ce=C.slice(),Ce=[];for(let ae=ce.length-1;ae>=0&&(C.pop(),ce[ae].type!=="brace");ae--)ce[ae].type!=="dots"&&Ce.unshift(ce[ae].value);Y=a(Ce,l),y.backtrack=!0}if(N.comma!==!0&&N.dots!==!0){const ce=y.output.slice(0,N.outputIndex),Ce=y.tokens.slice(N.tokensIndex);N.value=N.output="\\{",_=Y="\\}",y.output=ce;for(const ae of Ce)y.output+=ae.output||ae.value}X({type:"brace",value:_,output:Y}),mt("braces"),Re.pop();continue}if(_==="|"){ke.length>0&&ke[ke.length-1].conditions++,X({type:"text",value:_});continue}if(_===","){let N=_;const Y=Re[Re.length-1];Y&&ye[ye.length-1]==="braces"&&(Y.comma=!0,N="|"),X({type:"comma",value:_,output:N});continue}if(_==="/"){if(S.type==="dot"&&y.index===y.start+1){y.start=y.index+1,y.consumed="",y.output="",C.pop(),S=m;continue}X({type:"slash",value:_,output:F});continue}if(_==="."){if(y.braces>0&&S.type==="dot"){S.value==="."&&(S.output=D);const N=Re[Re.length-1];S.type="dots",S.output+=_,S.value+=_,N.dots=!0;continue}if(y.braces+y.parens===0&&S.type!=="bos"&&S.type!=="slash"){X({type:"text",value:_,output:D});continue}X({type:"dot",value:_,output:D});continue}if(_==="?"){if(!(S&&S.value==="(")&&l.noextglob!==!0&&se()==="("&&se(2)!=="?"){cn("qmark",_);continue}if(S&&S.type==="paren"){const Y=se();let ce=_;if(Y==="<"&&!t.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(Y)||Y==="<"&&!/<([!=]|\w+>)/.test(at()))&&(ce=`\\${_}`),X({type:"text",value:_,output:ce});continue}if(l.dot!==!0&&(S.type==="slash"||S.type==="bos")){X({type:"qmark",value:_,output:nt});continue}X({type:"qmark",value:_,output:re});continue}if(_==="!"){if(l.noextglob!==!0&&se()==="("&&(se(2)!=="?"||!/[!=<:]/.test(se(3)))){cn("negate",_);continue}if(l.nonegate!==!0&&y.index===0){ka();continue}}if(_==="+"){if(l.noextglob!==!0&&se()==="("&&se(2)!=="?"){cn("plus",_);continue}if(S&&S.value==="("||l.regex===!1){X({type:"plus",value:_,output:te});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||y.parens>0){X({type:"plus",value:_});continue}X({type:"plus",value:te});continue}if(_==="@"){if(l.noextglob!==!0&&se()==="("&&se(2)!=="?"){X({type:"at",extglob:!0,value:_,output:""});continue}X({type:"text",value:_});continue}if(_!=="*"){(_==="$"||_==="^")&&(_=`\\${_}`);const N=o.exec(at());N&&(_+=N[0],y.index+=N[0].length),X({type:"text",value:_});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=_,S.output=q,y.backtrack=!0,y.globstar=!0,Ge(_);continue}let L=at();if(l.noextglob!==!0&&/^\([^?]/.test(L)){cn("star",_);continue}if(S.type==="star"){if(l.noglobstar===!0){Ge(_);continue}const N=S.prev,Y=N.prev,ce=N.type==="slash"||N.type==="bos",Ce=Y&&(Y.type==="star"||Y.type==="globstar");if(l.bash===!0&&(!ce||L[0]&&L[0]!=="/")){X({type:"star",value:_,output:""});continue}const ae=y.braces>0&&(N.type==="comma"||N.type==="brace"),rt=ke.length&&(N.type==="pipe"||N.type==="paren");if(!ce&&N.type!=="paren"&&!ae&&!rt){X({type:"star",value:_,output:""});continue}for(;L.slice(0,3)==="/**";){const ot=R[y.index+4];if(ot&&ot!=="/")break;L=L.slice(3),Ge("/**",3)}if(N.type==="bos"&&Fe()){S.type="globstar",S.value+=_,S.output=Ae(l),y.output=S.output,y.globstar=!0,Ge(_);continue}if(N.type==="slash"&&N.prev.type!=="bos"&&!Ce&&Fe()){y.output=y.output.slice(0,-(N.output+S.output).length),N.output=`(?:${N.output}`,S.type="globstar",S.output=Ae(l)+(l.strictSlashes?")":"|$)"),S.value+=_,y.globstar=!0,y.output+=N.output+S.output,Ge(_);continue}if(N.type==="slash"&&N.prev.type!=="bos"&&L[0]==="/"){const ot=L[1]!==void 0?"|$":"";y.output=y.output.slice(0,-(N.output+S.output).length),N.output=`(?:${N.output}`,S.type="globstar",S.output=`${Ae(l)}${F}|${F}${ot})`,S.value+=_,y.output+=N.output+S.output,y.globstar=!0,Ge(_+de()),X({type:"slash",value:"/",output:""});continue}if(N.type==="bos"&&L[0]==="/"){S.type="globstar",S.value+=_,S.output=`(?:^|${F}|${Ae(l)}${F})`,y.output=S.output,y.globstar=!0,Ge(_+de()),X({type:"slash",value:"/",output:""});continue}y.output=y.output.slice(0,-S.output.length),S.type="globstar",S.output=Ae(l),S.value+=_,y.output+=S.output,y.globstar=!0,Ge(_);continue}const ue={type:"star",value:_,output:q};if(l.bash===!0){ue.output=".*?",(S.type==="bos"||S.type==="slash")&&(ue.output=ze+ue.output),X(ue);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&l.regex===!0){ue.output=_,X(ue);continue}(y.index===y.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(y.output+=Xe,S.output+=Xe):l.dot===!0?(y.output+=xe,S.output+=xe):(y.output+=ze,S.output+=ze),se()!=="*"&&(y.output+=H,S.output+=H)),X(ue)}for(;y.brackets>0;){if(l.strictBrackets===!0)throw new SyntaxError(c("closing","]"));y.output=t.escapeLast(y.output,"["),mt("brackets")}for(;y.parens>0;){if(l.strictBrackets===!0)throw new SyntaxError(c("closing",")"));y.output=t.escapeLast(y.output,"("),mt("parens")}for(;y.braces>0;){if(l.strictBrackets===!0)throw new SyntaxError(c("closing","}"));y.output=t.escapeLast(y.output,"{"),mt("braces")}if(l.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&X({type:"maybe_slash",value:"",output:`${F}?`}),y.backtrack===!0){y.output="";for(const L of y.tokens)y.output+=L.output!=null?L.output:L.value,L.suffix&&(y.output+=L.suffix)}return y};return v.fastpaths=(R,p)=>{const l={...p},d=typeof l.maxLength=="number"?Math.min(n,l.maxLength):n,E=R.length;if(E>d)throw new SyntaxError(`Input length: ${E}, exceeds maximum allowed length: ${d}`);R=s[R]||R;const m=t.isWindows(p),{DOT_LITERAL:C,SLASH_LITERAL:$,ONE_CHAR:U,DOTS_SLASH:K,NO_DOT:G,NO_DOTS:D,NO_DOTS_SLASH:te,STAR:F,START_ANCHOR:H}=e.globChars(m),B=l.dot?D:G,Te=l.dot?te:G,Xe=l.capture?"":"?:",xe={negated:!1,prefix:""};let re=l.bash===!0?".*?":F;l.capture&&(re=`(${re})`);const nt=ze=>ze.noglobstar===!0?re:`(${Xe}(?:(?!${H}${ze.dot?K:C}).)*?)`,Tt=ze=>{switch(ze){case"*":return`${B}${U}${re}`;case".*":return`${C}${U}${re}`;case"*.*":return`${B}${re}${C}${U}${re}`;case"*/*":return`${B}${re}${$}${U}${Te}${re}`;case"**":return B+nt(l);case"**/*":return`(?:${B}${nt(l)}${$})?${Te}${U}${re}`;case"**/*.*":return`(?:${B}${nt(l)}${$})?${Te}${re}${C}${U}${re}`;case"**/.*":return`(?:${B}${nt(l)}${$})?${C}${U}${re}`;default:{const Z=/^(.*?)\.(\w+)$/.exec(ze);if(!Z)return;const q=Tt(Z[1]);return q?q+C+Z[2]:void 0}}},be=t.removePrefix(R,xe);let Ae=Tt(be);return Ae&&l.strictSlashes!==!0&&(Ae+=`${$}?`),Ae},go=v,go}var Eo,ya;function KE(){if(ya)return Eo;ya=1;const e=le,t=VE(),n=WE(),r=Xn(),o=Yn(),i=a=>a&&typeof a=="object"&&!Array.isArray(a),s=(a,c,u=!1)=>{if(Array.isArray(a)){const v=a.map(p=>s(p,c,u));return p=>{for(const l of v){const d=l(p);if(d)return d}return!1}}const f=i(a)&&a.tokens&&a.input;if(a===""||typeof a!="string"&&!f)throw new TypeError("Expected pattern to be a non-empty string");const h=c||{},T=r.isWindows(c),w=f?s.compileRe(a,c):s.makeRe(a,c,!1,!0),k=w.state;delete w.state;let M=()=>!1;if(h.ignore){const v={...c,ignore:null,onMatch:null,onResult:null};M=s(h.ignore,v,u)}const b=(v,R=!1)=>{const{isMatch:p,match:l,output:d}=s.test(v,w,c,{glob:a,posix:T}),E={glob:a,state:k,regex:w,posix:T,input:v,output:d,match:l,isMatch:p};return typeof h.onResult=="function"&&h.onResult(E),p===!1?(E.isMatch=!1,R?E:!1):M(v)?(typeof h.onIgnore=="function"&&h.onIgnore(E),E.isMatch=!1,R?E:!1):(typeof h.onMatch=="function"&&h.onMatch(E),R?E:!0)};return u&&(b.state=k),b};return s.test=(a,c,u,{glob:f,posix:h}={})=>{if(typeof a!="string")throw new TypeError("Expected input to be a string");if(a==="")return{isMatch:!1,output:""};const T=u||{},w=T.format||(h?r.toPosixSlashes:null);let k=a===f,M=k&&w?w(a):a;return k===!1&&(M=w?w(a):a,k=M===f),(k===!1||T.capture===!0)&&(T.matchBase===!0||T.basename===!0?k=s.matchBase(a,c,u,h):k=c.exec(M)),{isMatch:!!k,match:k,output:M}},s.matchBase=(a,c,u,f=r.isWindows(u))=>(c instanceof RegExp?c:s.makeRe(c,u)).test(e.basename(a)),s.isMatch=(a,c,u)=>s(c,u)(a),s.parse=(a,c)=>Array.isArray(a)?a.map(u=>s.parse(u,c)):n(a,{...c,fastpaths:!1}),s.scan=(a,c)=>t(a,c),s.compileRe=(a,c,u=!1,f=!1)=>{if(u===!0)return a.output;const h=c||{},T=h.contains?"":"^",w=h.contains?"":"$";let k=`${T}(?:${a.output})${w}`;a&&a.negated===!0&&(k=`^(?!${k}).*$`);const M=s.toRegex(k,c);return f===!0&&(M.state=a),M},s.makeRe=(a,c={},u=!1,f=!1)=>{if(!a||typeof a!="string")throw new TypeError("Expected a non-empty string");let h={negated:!1,fastpaths:!0};return c.fastpaths!==!1&&(a[0]==="."||a[0]==="*")&&(h.output=n.fastpaths(a,c)),h.output||(h=n(a,c)),s.compileRe(h,c,u,f)},s.toRegex=(a,c)=>{try{const u=c||{};return new RegExp(a,u.flags||(u.nocase?"i":""))}catch(u){if(c&&c.debug===!0)throw u;return/$^/}},s.constants=o,Eo=s,Eo}var _o,Sa;function YE(){return Sa||(Sa=1,_o=KE()),_o}var yo,Ta;function XE(){if(Ta)return yo;Ta=1;const e=zo,t=ZE(),n=YE(),r=Xn(),o=a=>a===""||a==="./",i=a=>{const c=a.indexOf("{");return c>-1&&a.indexOf("}",c)>-1},s=(a,c,u)=>{c=[].concat(c),a=[].concat(a);let f=new Set,h=new Set,T=new Set,w=0,k=v=>{T.add(v.output),u&&u.onResult&&u.onResult(v)};for(let v=0;v<c.length;v++){let R=n(String(c[v]),{...u,onResult:k},!0),p=R.state.negated||R.state.negatedExtglob;p&&w++;for(let l of a){let d=R(l,!0);(p?!d.isMatch:d.isMatch)&&(p?f.add(d.output):(f.delete(d.output),h.add(d.output)))}}let b=(w===c.length?[...T]:[...h]).filter(v=>!f.has(v));if(u&&b.length===0){if(u.failglob===!0)throw new Error(`No matches found for "${c.join(", ")}"`);if(u.nonull===!0||u.nullglob===!0)return u.unescape?c.map(v=>v.replace(/\\/g,"")):c}return b};return s.match=s,s.matcher=(a,c)=>n(a,c),s.isMatch=(a,c,u)=>n(c,u)(a),s.any=s.isMatch,s.not=(a,c,u={})=>{c=[].concat(c).map(String);let f=new Set,h=[],T=k=>{u.onResult&&u.onResult(k),h.push(k.output)},w=new Set(s(a,c,{...u,onResult:T}));for(let k of h)w.has(k)||f.add(k);return[...f]},s.contains=(a,c,u)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);if(Array.isArray(c))return c.some(f=>s.contains(a,f,u));if(typeof c=="string"){if(o(a)||o(c))return!1;if(a.includes(c)||a.startsWith("./")&&a.slice(2).includes(c))return!0}return s.isMatch(a,c,{...u,contains:!0})},s.matchKeys=(a,c,u)=>{if(!r.isObject(a))throw new TypeError("Expected the first argument to be an object");let f=s(Object.keys(a),c,u),h={};for(let T of f)h[T]=a[T];return h},s.some=(a,c,u)=>{let f=[].concat(a);for(let h of[].concat(c)){let T=n(String(h),u);if(f.some(w=>T(w)))return!0}return!1},s.every=(a,c,u)=>{let f=[].concat(a);for(let h of[].concat(c)){let T=n(String(h),u);if(!f.every(w=>T(w)))return!1}return!0},s.all=(a,c,u)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);return[].concat(c).every(f=>n(f,u)(a))},s.capture=(a,c,u)=>{let f=r.isWindows(u),T=n.makeRe(String(a),{...u,capture:!0}).exec(f?r.toPosixSlashes(c):c);if(T)return T.slice(1).map(w=>w===void 0?"":w)},s.makeRe=(...a)=>n.makeRe(...a),s.scan=(...a)=>n.scan(...a),s.parse=(a,c)=>{let u=[];for(let f of[].concat(a||[]))for(let h of t(String(f),c))u.push(n.parse(h,c));return u},s.braces=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return c&&c.nobrace===!0||!i(a)?[a]:t(a,c)},s.braceExpand=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return s.braces(a,{...c,expand:!0})},s.hasBraces=i,yo=s,yo}var QE=XE();const qE=ME(QE);function Ra(e,t,n){un.statSync(e).isDirectory()?(un.mkdirSync(t,{recursive:!0}),un.readdirSync(e).forEach(r=>{const o=ln.resolve(e,r),i=ln.resolve(t,r);Ra(o,i,n)})):qE.isMatch(e,n)||un.copyFileSync(e,t)}function dt(e,t,n,r,o=[]){const i=ln.join(e,r?.[n]??n);Ra(ln.join(t,n),i,o)}function JE(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>I.info(`Template [${e}] with pages structure named has been created`)}}function it(e){return Ne.resolve(oc(import.meta.url),"../..",e)}function e_(){const e=it("package.json");return e!==""?JSON.parse(he.readFileSync(e,"utf8")):{}}async function t_(e){try{const t=e,n=Se.cwd(),r=Ne.join(n,t),o=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],i={_gitignore:".gitignore"};he.existsSync(r)?(I.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):he.mkdirSync(r);const s=it("template");he.readdirSync(s).filter(f=>f!=="package.json").filter(f=>!o.includes(f)).forEach(async f=>dt(r,s,f,i));const a=JSON.parse(he.readFileSync(Ne.join(s,"package.json"),"utf-8"));a.name=e;const c=e_();c.version&&(a.dependencies["@lightspeed/crane-api"]=c.dependencies["@lightspeed/crane-api"]),c.dependencies["@lightspeed/eslint-config-crane"]&&(a.dependencies["@lightspeed/eslint-config-crane"]=c.dependencies["@lightspeed/eslint-config-crane"]);const u=Ne.join(r,"package.json");he.writeFileSync(u,`${JSON.stringify(a,null,2)}
|
|
74
|
+
`),I.info(`App ${e} created`)}catch(t){I.error(`Error while creating app: ${t.message}`),Se.exit(1)}}function So(e,t,n,r){try{const o=Se.cwd(),i=le.join(o,t);ie.existsSync(i)||ie.mkdirSync(i);const s=le.join(o,t,n);ie.existsSync(s)?(I.error(`${r} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):ie.mkdirSync(s);const a=it(e);ie.readdirSync(a).forEach(async c=>dt(s,a,c)),I.info(`${r} ${n} created`)}catch(o){I.error(`Error while creating ${r}: ${o.message}`),Se.exit(1)}}function To(e){const t=Se.cwd(),n=it(`template/${e}`),r=le.join(t,e);ie.existsSync(r)||(ie.mkdirSync(r),ie.readdirSync(n).forEach(async o=>dt(r,n,o)))}async function n_(e,t,n,r){if(!ie.existsSync(n)){ie.copyFileSync(t,n);return}const o=ie.readFileSync(t),i=ie.readFileSync(n);o.equals(i)||(r?(await At({type:"select",name:"value",message:`File "${e.name}" exists but differs from template. What would you like to do?`,choices:[{title:"Keep existing file",value:"keep"},{title:"Replace with template version",value:"replace"}],initial:0})).value==="replace"?(ie.copyFileSync(t,n),I.info(`Replaced "${e.name}" with template version.`)):I.info(`Kept existing "${e.name}".`):I.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function Qn(e,t,n=!1){async function r(i,s,a){const c=le.join(s,i.name),u=le.join(a,i.name);i.isDirectory()?await Qn(c,u,n):await n_(i,c,u,n)}const o=ie.readdirSync(e,{withFileTypes:!0});ie.existsSync(t)||ie.mkdirSync(t,{recursive:!0}),await o.reduce(async(i,s)=>(await i,r(s,e,t)),Promise.resolve())}async function Ro(e=!1){try{const t=Se.cwd(),n=le.join(t,"shared"),r=it("template/shared");if(!ie.existsSync(r))return;await Qn(r,n,e)}catch(t){I.error(`Error while processing shared folder: ${t.message}`),Se.exit(1)}}async function r_(e,t){await Ro(),So(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function o_(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>I.info(`Collection [${e}] has been created`)}}async function s_(e){const{targetPath:t,renameFiles:n,sourcePath:r,onCollectionCreated:o}=o_(e);try{const i=Se.cwd(),s=Ne.join(i,"collections"),a=it(r),c=he.readdirSync(a);he.existsSync(s)?he.existsSync(Ne.join(s,t))&&(I.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):he.mkdirSync(s),c.forEach(u=>dt(s,a,u,n)),o()}catch(i){I.error(`Error while creating collection: ${i.message}`),Se.exit(1)}}async function i_(e){await Ro(),So("template/footers/example-footer","footers",e,"Footer")}async function a_(e){await Ro(),So("template/headers/example-header","headers",e,"Header")}async function c_(e,t){try{const n=Se.cwd(),r=Ne.join(n,"templates"),o=it("template/page-templates/example-template/pages");he.existsSync(Ne.join(r,e))||(I.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),Se.exit(1)),he.existsSync(Ne.join(r,e,"pages",`${t}.ts`))&&(I.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),Se.exit(1));const i=he.readFileSync(Ne.join(o,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${im(t)}'`),s=Ne.join(r,e,"pages",`${t}.ts`);he.writeFileSync(s,i),I.info(`Page [${t}.ts] created for template ${e}`)}catch(n){I.error(`Error while creating page: ${n.message}`),Se.exit(1)}}async function u_(){try{const e=Se.cwd(),t=it("template/reference"),n=he.readdirSync(t);let r=!1;for(const o of n){const i=Ne.join(t,o),s=Ne.join(e,o);he.existsSync(s)||he.mkdirSync(s,{recursive:!0});const a=he.readdirSync(i),c=he.readdirSync(s);if(o==="shared"){a.forEach(u=>{dt(s,i,u)});continue}for(const u of a){if(u==="assets"){dt(s,i,u);continue}if(c.includes(u)){const{name:f}=await At({type:"text",name:"name",message:`The "${u}" already exists in ${o} directory: provide a new name to keep both or press Esc to skip this one.`});f?(dt(s,i,u,{[u]:f}),r=!0):I.info(`Skipped: ${u}`)}else dt(s,i,u)}}I.info("Reference templates have been added to the app"),r&&I.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){I.error(`Error while creating template descriptors: ${e.message}`),Se.exit(1)}}const l_=["**/example-template/pages/custom.ts"];async function p_(e){const{targetPath:t,renameFiles:n,sourcePath:r,onTemplateCreated:o}=JE(e);try{const i=Se.cwd(),s=Ne.join(i,"templates"),a=it(r),c=he.readdirSync(a);he.existsSync(s)?he.existsSync(Ne.join(s,t))&&(I.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Se.exit(1)):he.mkdirSync(s),c.forEach(u=>dt(s,a,u,n,l_)),To("headers"),To("footers"),To("layouts"),o()}catch(i){I.error(`Error while creating template descriptors: ${i.message}`),Se.exit(1)}}function f_(){try{const e=j(dn.cwd(),`${Di}/shared/analytics.json`);$e(e)&&or(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function qn({deploymentContext:e,sectionType:t=ut.SECTION}){const n=e.pathContext,r=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),o=r===void 0?$o(n.fileName):$o(n.fileName,{cwd:j(process.cwd(),r),ignore:n.ignore});return(n.isSingleton?o.splice(0):o).map(i=>({url:i,sectionType:t,context:e}))}const d_=e=>e.app.manifest.blocks.flatMap(t=>Bm.flatMap(n=>{const r={config:e,currentSection:t.id,pathContext:rn[n]};return qn({deploymentContext:r,sectionType:t.type})})),h_=e=>Wm.flatMap(t=>{const n={config:e,pathContext:rn[t]};return qn({deploymentContext:n})}),m_=e=>e.app.manifest.layouts.flatMap(t=>Zm.flatMap(n=>{const r={config:e,pathContext:rn[n],currentSection:t.sectionId,layoutId:t.id};return qn({deploymentContext:r})})),g_=e=>e.app.manifest.slots.flatMap(t=>Vm.flatMap(n=>{const r={config:e,pathContext:rn[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return qn({deploymentContext:r})})),E_=e=>`\x1B[32m${e}\x1B[0m`,__=(e,t,n,r,o)=>{if(!e.total)return;const{loaded:i}=e,s=(Date.now()-o)/1e3;n.value+=i-r.value,r.value=i,t.update({speed:`${pt(n.value/s,2)}/s`})},y_=()=>new ac.SingleBar({format:`|${E_("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function Oa(e){await new Promise(t=>setTimeout(t,e))}const va="Please ensure you have built your application before deploying.";async function Ca(){try{const e=await ar(j(dn.cwd(),ki));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${va}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${va}`):e}}const S_={value:0},Ye=y_();let wa=Date.now();const Ia=e=>2**e*500;async function T_(e){const t=ic(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,or(j(Oe.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
75
|
+
`)}function R_(e){return e instanceof Lo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function Aa(e,t){return e<Hm&&R_(t)}async function ba(e,t,n,r){const o={value:0},i=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?Um:Mm;return e.config.axios.post(i,{file:xa(j(Oe.cwd(),n!==void 0?n+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.layoutId!==void 0&&{layoutId:e.layoutId},...e.slotId!==void 0&&{slotId:e.slotId},...!["dependencies","source_code"].includes(e.pathContext.type)&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`},onUploadProgress:s=>__(s,Ye,S_,o,wa)}).then(s=>(Ye.increment(),s)).catch(async s=>{if(Aa(r,s))return await Oa(Ia(r)),ba(e,t,n,r+1);throw Ye.increment(),s})}function O_(e){return Ye.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,r=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return ba(n,t.url,r,0)})}function v_(e){const t=[...d_(e),...h_(e),...m_(e),...g_(e)];return O_(t)}async function $a(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?Fm:jm;return e.axios.post(n,e.app.manifest,{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async r=>{if(Aa(t,r))return await Oa(Ia(t)),$a(e,t+1);throw r})}async function C_(e){try{if(!tm.some(s=>$e(j(Oe.cwd(),s))))throw new Error(Ft.INCORRECT_DISTRIBUTION_FOLDER(Jh));const t=e??Vr;I.info("Custom application deployment :: Started");const n=cr.create({baseURL:t});sc(n,Gm),I.info("Loading configuration files ...");const r=await Promise.all([Gn(),Wr(),Ca()]).then(([s,a,c])=>({axios:n,app:{crane:s,packageJson:a,manifest:c}}));I.info("Uploading files ..."),wa=Date.now(),await Promise.all(v_(r)).catch(s=>{Ye.stop(),s.response?.status===404?I.error(wt(s,Ft.DEPRECATED_VERSION_DEPLOYMENT)):I.error(wt(s,Ft.ASSET_FILES_UPLOAD)),Oe.exit(1)}).finally(()=>{Ye.increment(),Ye.stop()}),Ye.update({speed:"N/A",status:"Finalising deployment"}),await $a(r).catch(s=>{Ye.stop(),s.response?.status===404?I.error(wt(s,Ft.DEPRECATED_VERSION_DEPLOYMENT)):I.error(wt(s,Ft.MANIFEST_DEPLOYMENT)),Oe.exit(1)}).finally(()=>{Ye.increment(),Ye.stop()});const o=r.app.manifest.blocks.map(s=>s.id),i=r.app.packageJson.version;I.info("Custom application deployment :: Successful"),I.info(`Current app version: ${i}`),I.info(`Deployed sections: ${o.sort().join(", ")}`),await T_(r.app.packageJson),r.app.manifest.templates.length>0&&I.info(`Deployed templates: ${r.app.manifest.templates.map(s=>s.id).sort().join(", ")}`),r.app.manifest.slots.length>0&&I.info(`Deployed slots: ${r.app.manifest.slots.map(s=>s.id).sort().join(", ")}`),r.app.manifest.collections.length>0&&I.info(`Deployed collections: ${r.app.manifest.collections.map(s=>s.id).sort().join(", ")}`)}catch(t){Ye.stop(),I.error(wt(t,Ft.DEFAULT)),Oe.exit(1)}finally{f_()}}function w_(){process.env.CRANE_DEBUG_ENABLED="true"}function I_(){return process.env.CRANE_DEBUG_ENABLED==="true"}function A_(e,...t){I_()&&console.debug(Ha(`[DEBUG] ${e}`),...t)}function b_(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,r)=>{e.moduleGraph.invalidateAll();const o=new Qa(t.url||"",`http://${t.headers.host}`);if(o.pathname==="/api/v1/block-config"&&t.method==="GET"){const i=o.searchParams.get("section");if(!i){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}try{const s=(await Ca()).blocks.find(a=>a.id===i);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(s))}catch(s){n.statusCode=500,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:s.message}))}return}r()})}}}let It=null;function $_(){It&&It.clients.forEach(e=>{e.readyState===uc.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function N_(e,t){const n=j(`${e}/ssr-server.ts`),r=j(t);await ct({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function L_(e,t){const n=j(`${e}/shared/preview.ts`),r=j(`${e}/shared/utils.ts`),o=j(`${e}/shared/api-routes.ts`),i=j(t);await ct({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ct({build:{lib:{entry:r,formats:["es"],fileName:()=>"utils.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ct({build:{lib:{entry:o,formats:["es"],fileName:()=>"api-routes.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function D_(){const e="preview",t=`${e}/shared`,n="vite.config.js",r=`${e}/sections`,o=`${r}/preview.html`;[e,r].forEach(s=>{ie.existsSync(s)||ie.mkdirSync(s,{recursive:!0})});const i=it("template/preview");ie.copyFileSync(`${i}/${n}`,`${e}/${n}`),await N_(i,e),ie.copyFileSync(`${i}/sections/preview.html`,o),ie.existsSync(t)||ie.mkdirSync(t),await L_(i,t)}function k_(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function P_(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function x_(e){const t=(await ra()).find(r=>r.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await Kn(!0);return}const n=ta(t);await ea([n]),console.log(`Block ${e} rebuilt successfully`)}var z_=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(z_||{});function M_(){return{timeout:null,inProgress:!1,pendingBuild:null}}function U_(e,t){const n=async r=>{e.inProgress=!0;try{r.type==="incremental"&&r.blockName?await x_(r.blockName):await Kn(!0),t.ws.send({type:"full-reload",path:"*"}),$_()}catch(o){console.error("Build error:",o)}finally{if(e.inProgress=!1,e.pendingBuild){const o=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(o),0)}}};return async r=>{if(e.inProgress){r.type==="full"||e.pendingBuild?.type==="full"?e.pendingBuild={type:"full"}:e.pendingBuild=r;return}await n(r)}}function j_(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),r=t.match(/headers\/([^/]+)/),o=t.match(/footers\/([^/]+)/),i=t.match(/shared\//);return!!(n||r||o||i)}function F_(e,t){return async n=>{if(!j_(n))return;e.timeout&&clearTimeout(e.timeout);const r=k_(n),o=P_(n);e.timeout=setTimeout(async()=>{o?await t({type:"full"}):r&&await t({type:"incremental",blockName:r})},1e3)}}function G_(e,t){const n=M_(),r=U_(n,e),o=F_(n,r);e.watcher.add(t),e.watcher.on("add",o),e.watcher.on("change",o),e.watcher.on("unlink",o)}async function H_(){const e=le.resolve(process.cwd(),"preview/ssr-server.mjs");if(!ie.existsSync(e))throw console.warn(`\u26A0\uFE0F SSR server not found at ${e}`),new Error(`SSR server not found at ${e}`);process.env.PREVIEW_SSR_PORT="0";let t=e;process.platform==="win32"&&(t=No(e).href);const n=await import(t),{server:r,port:o}=await n.startServer();return{server:r,port:o}}function B_(){It=new cc({port:0}),It.on("listening",()=>{const e=It?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function Z_(){const e=le.resolve(process.cwd(),"preview/vite.config.js"),t=le.resolve(process.cwd(),"sections/**/*"),n=le.resolve(process.cwd(),"headers/**/*"),r=le.resolve(process.cwd(),"footers/**/*"),o=le.resolve(process.cwd(),"shared/**/*"),i=await Za({configFile:e,root:process.cwd(),plugins:[b_()]});return await i.listen(),G_(i,[t,n,r,o]),i}async function V_(){await Kn(),await D_(),console.log(`
|
|
57
76
|
\u{1F4E6} Starting preview servers...
|
|
58
|
-
`);let e=null,t=null;
|
|
77
|
+
`);let e=null,t=null;A_("Starting SSR server");const n=await H_();e=n.server,t=n.port,process.env.PREVIEW_SSR_PORT=String(t),B_();const r=await Z_(),o=()=>{e&&e.close(),It&&It.close(),r.close(),process.exit(0)};return process.on("SIGINT",o),process.on("SIGTERM",o),r}const W_=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,K_=/^[-a-zA-Z0-9_.^~<>=|* +]+$/;function Na({name:e,version:t}){return W_.test(e)&&K_.test(t)}function Jn(e){if(!$e(e))return{dependencies:{},devDependencies:{},overrides:{}};let t;try{t=JSON.parse(nr(e,"utf-8"))}catch{return{dependencies:{},devDependencies:{},overrides:{}}}const n=t.overrides??{},r=Object.fromEntries(Object.entries(n).filter(o=>typeof o[1]=="string"));return{dependencies:t.dependencies??{},devDependencies:t.devDependencies??{},overrides:r}}function Y_(e,t){const n=Jn(He(e,"package.json")),r=Jn(He(t,"package.json")),o={...r.dependencies,...r.devDependencies},i=[];for(const[s,a]of Object.entries(n.dependencies))o[s]||i.push({name:s,version:a,isDev:!1});for(const[s,a]of Object.entries(n.devDependencies))o[s]||i.push({name:s,version:a,isDev:!0});return i.sort((s,a)=>s.name.localeCompare(a.name))}function X_(e,t){const n=Jn(He(e,"package.json")).overrides,r=Jn(He(t,"package.json")).overrides;return Object.fromEntries(Object.entries(n).filter(([o,i])=>r[o]!==i))}function Q_(e){const t=Object.entries(e);if(t.length!==0){I.warn(`
|
|
78
|
+
The pulled source code defines npm overrides not present in your project:`);for(const[n,r]of t)I.warn(` - ${n}: "${r}"`);I.warn('Review these and add them to your package.json "overrides" section if needed.')}}function La(e){return e.map(t=>`${t.name}@${t.version}`).join(" ")}function q_(e){const t=e.filter(o=>!o.isDev),n=e.filter(o=>o.isDev),r=[];return t.length>0&&r.push(`npm install ${La(t)}`),n.length>0&&r.push(`npm install -D ${La(n)}`),r}function J_(e,t){const n=[{args:["install"],specs:e.filter(r=>!r.isDev).map(r=>`${r.name}@${r.version}`)},{args:["install","-D"],specs:e.filter(r=>r.isDev).map(r=>`${r.name}@${r.version}`)}];for(const{args:r,specs:o}of n){if(o.length===0)continue;const i=[...r,...o];I.info(`Running: npm ${i.join(" ")}`);const s=pc("npm",i,{cwd:t,stdio:"inherit"});if(s.status!==0)throw new Error(`npm ${r.join(" ")} exited with code ${s.status}`)}}async function ey(e,t){if(e.length===0)return;const n=e.filter(c=>!Na(c));if(n.length>0){I.warn("Skipping dependencies with unsafe names/versions:");for(const c of n)I.warn(` - ${c.name}@${c.version}`)}const r=e.filter(Na);if(r.length===0)return;const o=r.length===1?"dependency":"dependencies";I.warn(`
|
|
79
|
+
The pulled source code uses ${r.length} ${o} not found in your project:`);const i=r.filter(c=>!c.isDev),s=r.filter(c=>c.isDev);if(i.length>0){I.warn(" dependencies:");for(const c of i)I.warn(` - ${c.name}@${c.version}`)}if(s.length>0){I.warn(" devDependencies:");for(const c of s)I.warn(` - ${c.name}@${c.version}`)}const a=q_(r);switch((await At({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{J_(r,t),I.info("Dependencies installed successfully.")}catch{I.error("Failed to install dependencies. You can try running the commands manually:");for(const c of a)I.warn(` ${c}`)}break;case"add":{const c=He(t,"package.json"),u=JSON.parse(nr(c,"utf-8"));if(i.length>0){u.dependencies||(u.dependencies={});for(const f of i)u.dependencies[f.name]=f.version;u.dependencies=Object.fromEntries(Object.entries(u.dependencies).sort(([f],[h])=>f.localeCompare(h)))}if(s.length>0){u.devDependencies||(u.devDependencies={});for(const f of s)u.devDependencies[f.name]=f.version;u.devDependencies=Object.fromEntries(Object.entries(u.devDependencies).sort(([f],[h])=>f.localeCompare(h)))}or(c,`${JSON.stringify(u,null,2)}
|
|
80
|
+
`),I.info('Dependencies added to package.json. Run "npm install" to install them.');break}case"show":I.info(`
|
|
81
|
+
Run the following command(s) to install the dependencies:`);for(const c of a)I.info(` ${c}`);break;default:I.info("Skipping dependency installation.");break}}async function ty(e,t,n){const r=t.split("_").pop()??t,o=He(e,"sections",r),i=He(e,r);let s=null;if($e(o)&&Vt(o).isDirectory()?s=o:$e(i)&&Vt(i).isDirectory()&&(s=i),s){const a=He(n,r);$e(a)&&((await At({type:"confirm",name:"value",message:`Section directory [sections/${r}/] already exists. Do you want to overwrite it?`,initial:!1})).value||(I.error("Operation cancelled. Section directory already exists."),Oe.exit(1)),I.info(`Deleting existing section directory [sections/${r}/]...`),Co(a,{recursive:!0,force:!0})),I.info(`Copying section [sections/${r}/]...`),await Qn(s,a,!1)}else I.error(`Section directory [sections/${r}/] not found in source code.`),Oe.exit(1)}async function ny(e,t,n){const r=za(He(lc.tmpdir(),"crane-source-"));new bo(Buffer.from(e)).extractAllTo(r,!0);try{const o=Oe.cwd(),i=He(o,"sections");$e(i)||Ma(i,{recursive:!0}),await ty(r,t,i);const s=He(r,"shared");if($e(s)){const c=He(o,"shared");I.info("Copying shared folder..."),await Qn(s,c,!0)}const a=Y_(r,o);await ey(a,o),Q_(X_(r,o)),I.info(`Source code for section [${n}] has been copied.`)}finally{Co(r,{recursive:!0,force:!0})}}async function Da(e){const t=e??Vr,n=cr.create({baseURL:t}),r=await Gn();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:r.appClientId},headers:{Authorization:`Bearer ${r.appSecretKey}`}})).data.sections]}async function ry(e,t){const n=(await Da(t)).find(r=>r.sectionId===e);return n||(I.error(`Section [${e}] not found in collection sections list.`),Oe.exit(1)),n}async function oy(e,t,n){const r=n??Vr,o=cr.create({baseURL:r}),i=await Gn();I.info(`Downloading source code for section [${e}]...`);const s=await o.get(`/api/v1/custom-apps/manifests/collections/sections/${e}/source-code`,{params:{appClientId:i.appClientId},headers:{Authorization:`Bearer ${i.appSecretKey}`},responseType:"arraybuffer"});await ny(s.data,t,e)}async function sy(e){try{I.info("Fetching sections list...");const t=await Da(e);I.info("Sections list retrieved successfully:");const n=t.map(r=>({sectionId:r.sectionId,openSource:r.openSource,type:r.type}));console.log(JSON.stringify({sections:n},null,2))}catch(t){I.error(wt(t,"Error while fetching sections list")),Oe.exit(1)}}async function iy(e,t){try{const n=await ry(e,t);n.openSource||(I.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),Oe.exit(1)),await oy(e,n.sectionId,t)}catch(n){I.error(wt(n,"Error while pulling section")),Oe.exit(1)}}async function ay(e,t){const{list:n,section:r}=e;if(n){await sy(t);return}if(r){await iy(r,t);return}I.error("Please specify an action. Use --list to fetch sections list or --section to pull a section."),Oe.exit(1)}const cy={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},uy=["preview","build","deploy","pull"];function ly(e,t){return uy.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function py(e){return e.includes("-h")||e.includes("--help")}function fy(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!cy[e.rawName]?.includes(n))}function dy(e){return e.length!==0}function hy(e,t,n){return e.matchedCommand!==void 0&&(ly(e.matchedCommand,n)||py(e.rawArgs)||fy(e.matchedCommand,e.options)||dy(t))}function my(e,t,n){e.matchedCommand&&!hy(e,t,n)?e.runMatchedCommand():e.outputHelp()}function er(e){if(om(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=rm(e);return n&&console.log(n),t}async function Oo(e){const t=await At({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=le.basename(t.name);return er(n)?n:Oo(e)}}async function gy(e,t,n,r){const o=await Oo(t);return o===void 0?(console.log(`You can use ${n} to directly specify the name of the ${t}.`),e.outputHelp()):r(o)}async function Zt(e,t,n,r,o){if(o!==void 0)if(!er(o))await gy(e,t,n,r);else{const i=le.basename(o.toString());await r(i)}}function Ey(){ie.existsSync("./templates")||(I.error(`No template found. Please create a template first using ${Qe("init --template <name>")}`),process.exit(1));const e=ie.readdirSync("./templates",{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).filter(t=>t!=="assets");return e.length===0&&(I.error(`No template found. Please create a template first using ${Qe("init --template <name>")}`),process.exit(1)),e}async function _y(e){const t=Ey();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();er(e)?I.warn(`Template [${e}] doesn't exist`):I.error(`[${e}] is an invalid template name.`)}const n=await At({type:"select",name:"choice",message:"Please choose a template:",choices:t.map(r=>({title:r,value:r}))});return n.choice||(I.error("No template selected"),process.exit(1)),n.choice}async function yy(e,t){if(typeof t=="string"||typeof t=="number"){if(er(t))return t.toString();I.error(`${t} is invalid name.`)}return Oo(e)}async function Sy(e,t,n){const r=await _y(t),o=await yy("page",n);if(o===void 0)return console.log(`You can use ${Qe("init --page <name>")} to directly specify the name of the page.`),e.outputHelp();await c_(r,o)}async function Ty(e,t){try{const{app:n,section:r,header:o,footer:i,template:s,referenceTemplate:a,page:c,blank:u,collection:f}=e;await Zt(t,"app",Qe("init --app <name>"),t_,n),await Zt(t,"section",Qe(`init --section <name>${u?" --blank":""}`),h=>r_(h,u===!0),r),await Zt(t,"header",Qe("init --header <name>"),a_,o),await Zt(t,"footer",Qe("init --footer <name>"),i_,i),c===void 0?await Zt(t,"template",Qe("init --template <name>"),p_,s):await Sy(t,s,c),await Zt(t,"collection",Qe("init --collection <name>"),s_,f),a&&await u_()}catch(n){I.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function Ry(){try{const e=ja("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=>Ty(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>Kn(!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&&w_(),await V_()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>C_(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=>ay(n,e.options.url)),e.version(fc),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});my(e,t.args,t.options)}catch(e){I.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{Ry as run};
|