@lightspeed/crane 2.0.5 → 3.1.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 +50 -0
- package/UPGRADE.md +96 -0
- package/dist/cli.mjs +44 -25
- package/package.json +6 -3
- package/template/blank/sections/blank-section/BlankSection.vue +9 -0
- package/template/blank/sections/blank-section/assets/blank_section_showcase_1_preview.jpg +0 -0
- package/template/blank/sections/blank-section/client.ts +6 -0
- package/template/blank/sections/blank-section/server.ts +6 -0
- package/template/blank/sections/blank-section/settings/content.ts +2 -0
- package/template/blank/sections/blank-section/settings/design.ts +2 -0
- package/template/blank/sections/blank-section/settings/layout.ts +2 -0
- package/template/blank/sections/blank-section/settings/translations.ts +8 -0
- package/template/blank/sections/blank-section/showcases/1.ts +15 -0
- package/template/blank/sections/blank-section/showcases/translations.ts +10 -0
- package/template/blank/sections/blank-section/type.ts +5 -0
- package/template/collections/assets/collection_cover_image.png +0 -0
- package/template/collections/example-collection/configuration.ts +21 -0
- package/template/crane.config.json +1 -1
- package/template/footers/example-footer/ExampleFooter.vue +4 -4
- package/template/footers/example-footer/component/LegalLinks.vue +1 -1
- package/template/footers/example-footer/component/MadeWith.vue +1 -1
- package/template/footers/example-footer/component/ReportAbuse.vue +1 -1
- package/template/footers/example-footer/settings/design.ts +5 -4
- package/template/footers/example-footer/settings/translations.ts +4 -3
- package/template/footers/example-footer/showcases/1.ts +4 -2
- package/template/footers/example-footer/showcases/translations.ts +4 -2
- package/template/headers/example-header/ExampleHeader.vue +1 -1
- package/template/headers/example-header/component/Account.vue +1 -1
- package/template/headers/example-header/component/CategoriesDropdown.vue +1 -1
- package/template/headers/example-header/component/Logo.vue +7 -7
- package/template/headers/example-header/component/NavigationMenu.vue +1 -1
- package/template/headers/example-header/settings/content.ts +8 -1
- package/template/headers/example-header/settings/design.ts +7 -1
- package/template/headers/example-header/settings/layout.ts +1 -1
- package/template/headers/example-header/settings/translations.ts +4 -2
- package/template/headers/example-header/showcases/1.ts +15 -11
- package/template/headers/example-header/showcases/2.ts +12 -8
- package/template/headers/example-header/showcases/translations.ts +4 -2
- package/template/layouts/catalog/example-catalog/components/Icon.vue +14 -14
- package/template/layouts/catalog/example-catalog/slots/custom-bottom-bar/CustomBottomBar.vue +1 -1
- package/template/package.json +1 -0
- package/template/page-templates/example-template/configuration.ts +8 -10
- package/template/page-templates/example-template/pages/catalog.ts +3 -6
- package/template/page-templates/example-template/pages/category.ts +3 -6
- package/template/page-templates/example-template/pages/home.ts +42 -57
- package/template/page-templates/example-template/pages/product.ts +3 -6
- package/template/preview/sections/preview.html +10 -6
- package/template/preview/shared/api-routes.ts +236 -103
- package/template/preview/shared/logger.ts +9 -0
- package/template/preview/shared/preview.ts +117 -76
- package/template/preview/shared/utils.ts +68 -43
- package/template/preview/ssr-server.ts +1 -1
- package/template/reference/sections/about-us/AboutUs.vue +20 -22
- package/template/reference/sections/about-us/component/Image.vue +18 -18
- package/template/reference/sections/about-us/component/Stats.vue +40 -40
- package/template/reference/sections/about-us/component/Title.vue +1 -1
- package/template/reference/sections/about-us/settings/content.ts +15 -19
- package/template/reference/sections/about-us/settings/design.ts +14 -18
- package/template/reference/sections/about-us/settings/layout.ts +7 -5
- package/template/reference/sections/about-us/settings/translations.ts +4 -2
- package/template/reference/sections/about-us/showcases/1.ts +48 -62
- package/template/reference/sections/about-us/showcases/2.ts +44 -56
- package/template/reference/sections/about-us/showcases/translations.ts +4 -2
- package/template/reference/sections/featured-products/FeaturedProducts.vue +12 -6
- package/template/reference/sections/featured-products/component/ProductItem.vue +18 -1
- package/template/reference/sections/featured-products/component/ProductPlaceholder.vue +42 -0
- package/template/reference/sections/featured-products/component/Title.vue +1 -1
- package/template/reference/sections/featured-products/settings/content.ts +8 -10
- package/template/reference/sections/featured-products/settings/design.ts +7 -7
- package/template/reference/sections/featured-products/settings/translations.ts +4 -2
- package/template/reference/sections/featured-products/showcases/1.ts +8 -12
- package/template/reference/sections/featured-products/showcases/translations.ts +4 -2
- package/template/reference/sections/intro-slider/IntroSlider.vue +6 -6
- package/template/reference/sections/intro-slider/component/Slider.vue +42 -43
- package/template/reference/sections/intro-slider/component/Title.vue +7 -7
- package/template/reference/sections/intro-slider/settings/content.ts +33 -36
- package/template/reference/sections/intro-slider/settings/design.ts +17 -22
- package/template/reference/sections/intro-slider/settings/layout.ts +6 -4
- package/template/reference/sections/intro-slider/settings/translations.ts +4 -2
- package/template/reference/sections/intro-slider/showcases/1.ts +52 -75
- package/template/reference/sections/intro-slider/showcases/2.ts +50 -72
- package/template/reference/sections/intro-slider/showcases/translations.ts +4 -2
- package/template/reference/sections/tag-lines/TagLines.vue +41 -47
- package/template/reference/sections/tag-lines/component/HighlightedText.vue +1 -1
- package/template/reference/sections/tag-lines/component/SectionImage.vue +18 -18
- package/template/reference/sections/tag-lines/component/Title.vue +1 -1
- package/template/reference/sections/tag-lines/settings/content.ts +47 -47
- package/template/reference/sections/tag-lines/settings/design.ts +15 -19
- package/template/reference/sections/tag-lines/settings/layout.ts +6 -4
- package/template/reference/sections/tag-lines/settings/translations.ts +4 -2
- package/template/reference/sections/tag-lines/showcases/1.ts +40 -50
- package/template/reference/sections/tag-lines/showcases/2.ts +40 -50
- package/template/reference/sections/tag-lines/showcases/translations.ts +4 -2
- package/template/reference/sections/trending-categories/TrendingCategories.vue +1 -1
- package/template/reference/sections/trending-categories/component/CategoryItem.vue +18 -1
- package/template/reference/sections/trending-categories/component/Title.vue +1 -1
- package/template/reference/sections/trending-categories/settings/content.ts +8 -10
- package/template/reference/sections/trending-categories/settings/design.ts +7 -7
- package/template/reference/sections/trending-categories/settings/translations.ts +4 -2
- package/template/reference/sections/trending-categories/showcases/1.ts +14 -15
- package/template/reference/sections/trending-categories/showcases/translations.ts +4 -2
- package/template/reference/shared/components/Button.vue +6 -6
- package/template/reference/shared/components/SectionWrapper.vue +5 -5
- package/template/reference/shared/components/Tagline.vue +12 -11
- package/template/reference/templates/reference-template-apparel/configuration.ts +8 -8
- package/template/reference/templates/reference-template-apparel/pages/catalog.ts +3 -6
- package/template/reference/templates/reference-template-apparel/pages/category.ts +3 -6
- package/template/reference/templates/reference-template-apparel/pages/home.ts +14 -18
- package/template/reference/templates/reference-template-apparel/pages/product.ts +3 -6
- package/template/reference/templates/reference-template-bike/configuration.ts +9 -9
- package/template/reference/templates/reference-template-bike/pages/catalog.ts +3 -6
- package/template/reference/templates/reference-template-bike/pages/category.ts +3 -6
- package/template/reference/templates/reference-template-bike/pages/home.ts +14 -18
- package/template/reference/templates/reference-template-bike/pages/product.ts +3 -6
- package/template/sections/example-section/ExampleSection.vue +3 -5
- package/template/sections/example-section/component/button/Button.vue +1 -1
- package/template/sections/example-section/component/image/Image.vue +43 -43
- package/template/sections/example-section/component/image/ImagesGrid.vue +21 -32
- package/template/sections/example-section/component/selectbox/Selectbox.vue +1 -1
- package/template/sections/example-section/component/title/Title.vue +1 -1
- package/template/sections/example-section/component/toggle/Toggle.vue +4 -4
- package/template/sections/example-section/settings/content.ts +25 -34
- package/template/sections/example-section/settings/design.ts +23 -19
- package/template/sections/example-section/settings/layout.ts +18 -14
- package/template/sections/example-section/settings/translations.ts +17 -2
- package/template/sections/example-section/showcases/1.ts +55 -79
- package/template/sections/example-section/showcases/2.ts +49 -62
- package/template/sections/example-section/showcases/3.ts +53 -76
- package/template/sections/example-section/showcases/translations.ts +13 -2
- package/template/shared/components/LanguageSelector.vue +1 -1
- package/template/shared/components/SectionWrapper.vue +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -1,39 +1,58 @@
|
|
|
1
|
-
import*as ct from"fs";import V,{existsSync as re,statSync as ni,rename as pn,unlink as un,writeFileSync as fn,readFileSync as oi,promises as _t,createReadStream as si}from"fs";import*as Oe from"path";import W,{resolve as U,parse as He,dirname as dn,relative as ri,basename as ii,sep as hn}from"path";import ai from"cac";import{red as ci,yellow as li,green as Le}from"kolorist";import St from"prompts";import pi from"adm-zip";import{glob as z,globSync as mn}from"glob";import{normalizePath as ui,defineConfig as yn,build as qe,createServer as fi}from"vite";import{SectionTypeEnum as ue,ValidationTypeEnum as Me,PluginTypeEnum as Ee,ConfigTypeEnum as Y,BackgroundStyleEnum as Tt,ButtonAppearanceEnum as di,ButtonSizeEnum as hi,ButtonShapeEnum as mi,OverlayTypeEnum as lt,DesignEditorType as Pe,TemplatePageEnum as be,ReservedTemplatePageNameEnum as yi}from"@lightspeed/crane-api";import{pathToFileURL as gn,URL as gi}from"url";import $i from"ajv/dist/2020.js";import Ei from"ajv-formats";import bi from"node:zlib";import{promisify as _i}from"node:util";import{JSONPath as Si}from"jsonpath-plus";import{builtinModules as $n}from"module";import{viteExternalsPlugin as En}from"vite-plugin-externals";import Ti from"vite-plugin-compression";import wi from"@vitejs/plugin-vue";import Ci from"vite-tsconfig-paths";import Ai from"vite-plugin-checker";import{encode as Ri}from"@jridgewell/sourcemap-codec";import*as ie from"process";import Oi from"tinycolor2";import se from"node:fs";import ye from"node:path";import ae from"node:process";import bn from"util";import{fileURLToPath as vi}from"node:url";import{readFile as _n}from"fs/promises";import Ii,{AxiosError as Sn}from"axios";import{ConcurrencyManager as Li}from"axios-concurrency";import{inc as ji}from"semver";import xi from"cli-progress";const Ni="2.0.4",ce={[ue.SECTION]:{source:"sections",dist:"dist/sections"},[ue.HEADER]:{source:"headers",dist:"dist/headers"},[ue.FOOTER]:{source:"footers",dist:"dist/footers"}};var K=(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))(K||{});const Pi="https://blockbuster.ecwid.com",Di="/api/v1/custom-apps/resources/sections/upload",ki="/api/v1/custom-apps/resources/templates/upload",Fi="/api/v1/custom-apps/manifests/sections",Hi="/api/v1/custom-apps/manifests/templates",Mi=5,Gi=3,Bi=[K.Server,K.Client,K.ClientChunks,K.ClientAsset,K.Asset],qi=[K.LayoutClient,K.LayoutAsset],Ui=[K.SlotServer,K.SlotClient,K.SlotClientChunks,K.SlotClientAsset],zi=[K.Dependency,K.TemplateAsset,K.SourceCode],Ue={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.`},Tn={catalog:"products",category:"category",product:"product"},Ki=e=>Tn[e],wn=e=>e in Tn;function Qe(e,t=2){if(!+e)return"0 Bytes";const n=1024,o=t<0?0:t,s=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**i).toFixed(o))} ${s[i]}`}const I={error:e=>console.log(ci(e)),warn:e=>console.log(li(e)),info:e=>console.log(Le(e))},je="_temp",Xi="dist",le="dist/sections",ze="dist/headers",Ke="dist/footers",Ce="dist/templates",Xe="layouts",Cn="preview",_e=`dist/${Xe}`,Vi=[le,ze,Ke,Ce,_e],An=2*1024*1024,Rn=500*1024;function pt(e){return!!e}function On(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Wi="Resource name can only contain alphanumeric characters, dashes, and underscores";function Yi(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:Wi}}function Zi(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}async function xe(e,t){try{const n=U(process.cwd(),t?`${e}${je}.mjs`:`${e}.mjs`),o=`?timestamp=${Date.now()}`;return(await import(gn(n).href+o)).default}catch(n){const o=`File [${e}${t?je:""}.mjs] is either invalid or undefined`,s=n instanceof Error?n.message:o;throw new Error(s)}}function vn(e){return Object.keys(e).length===0}function Qi(e){return W.parse(e).name}function Ji(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ea(e){return e.replace(/\\/g,"/")}function ta(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Je(e){return ta(ea(e))}function na(e){const t=Je(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t;if(!wn(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const s=Ki(n);return{id:o,sectionId:n,pageId:s}}const oa={catalog:"products",category:"category",product:"product"};async function sa(e){const t=Je(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t;return{id:o,sectionId:n}}async function ra(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=oa[n];return{id:t.id,sectionId:n,pageId:o}}))}async function ia(){const e=`${_e}/{product,catalog,category}/*`,t=await z(e,{ignore:["node_modules/**"]});return Promise.all(t.map(sa))}async function aa(){const e=await ia();return await ra(e)}function Ve(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${_e}/${e}/${t}/${n.join("/")}`}const et=(e=ue.SECTION)=>ce[e].dist,We={[K.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${et(t)}/${e}/js/main/server/`},[K.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${et(t)}/${e}/js/main/client/`},[K.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${et(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[K.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${et(t)}/${e}/js/main/client/assets/`},[K.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${et(t)}/${e}/assets/`},[K.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Ce}/assets/`},[K.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[K.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[K.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>Ve(e,t,"")},[K.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Ve(e,t,"assets/")},[K.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ve(e,t,"slots",n,"js/main/server/")},[K.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ve(e,t,"slots",n,"js/main/client/")},[K.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ve(e,t,"slots",n,"js/main/client/chunks/")},[K.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ve(e,t,"slots",n,"js/main/client/assets/")}},In="https://json-schema.org/draft/2020-12/schema",Ln="https://lightspeedhq.com/template-default.schema.json",jn="Default Section",xn="Default section for a Custom Template",Nn="object",Pn={"default-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",const:"default"},id:{description:"Identification of the section",type:"string",pattern:"^((header|cover|announcement_bar|slider|special_offer|customer_review|company_info|shipping_payment|location|store|footer)(_\\d{3})?)$"},showcase_id:{description:"Showcase id of the section",type:"string"}},required:["type","id"],additionalProperties:!1}},ca={$schema:In,$id:Ln,title:jn,description:xn,type:Nn,$defs:Pn},Dn={__proto__:null,$defs:Pn,$id:Ln,$schema:In,default:ca,description:xn,title:jn,type:Nn},kn="https://json-schema.org/draft/2020-12/schema",Fn="https://lightspeedhq.com/template-custom.schema.json",Hn="Custom Section",Mn="Custom section for a Custom Template",Gn="object",Bn={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",const:"custom"},id:{description:"Identification of the section",type:"string"},showcase_id:{description:"Showcase id of the section",type:"string"},showcase_overrides:{$ref:"showcase_overrides.schema.json"}},required:["type","id"],additionalProperties:!1}},la={$schema:kn,$id:Fn,title:Hn,description:Mn,type:Gn,$defs:Bn},qn={__proto__:null,$defs:Bn,$id:Fn,$schema:kn,default:la,description:Mn,title:Hn,type:Gn},Un="https://json-schema.org/draft/2020-12/schema",zn="https://lightspeedhq.com/template-custom-content.schema.json",Kn="Custom Section :: Content Configuration",Xn="Content tab configuration of a Custom Section for a Custom Template",Vn="object",Wn={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"INPUTBOX"},text:{$ref:"common.schema.json#/$defs/label_type"}},required:["type","text"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"TEXTAREA"},text:{$ref:"common.schema.json#/$defs/label_type"}},required:["type","text"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"BUTTON"},title:{$ref:"common.schema.json#/$defs/label_type"},buttonType:{type:"string",enum:["SCROLL_TO_TILE","HYPER_LINK","MAIL_LINK","TEL_LINK","GO_TO_STORE_LINK","GO_TO_PAGE"]},link:{type:"string",format:"uri"},linkTarget:{type:"string"},email:{type:"string"},phone:{type:"string"},tileId:{type:"string"}},required:["type","title","buttonType"],additionalProperties:!0},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"IMAGE"},static:{type:"boolean"},imageData:{type:"object",properties:{set:{type:"object",properties:{MOBILE_WEBP_LOW_RES:{type:"object"},MOBILE_WEBP_HI_RES:{type:"object"},WEBP_LOW_RES:{type:"object"},WEBP_HI_2X_RES:{type:"object"},ORIGINAL:{type:"object"}},additionalProperties:!1,minProperties:1},borderInfo:{type:"object"},bucket:{type:"string"}},required:["set"]}},required:["type"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"TOGGLE"},enabled:{type:"boolean"}},required:["type"],additionalProperties:!0},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"SELECTBOX"},value:{type:"string"}},required:["type"],additionalProperties:!0},logo:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"LOGO"},logoType:{description:"Type of the logo content",type:"string",enum:["TEXT","IMAGE"]},text:{description:"Logo content text",$ref:"common.schema.json#/$defs/label_type"},imageData:{type:"object",properties:{set:{type:"object"},borderInfo:{type:"object"},bucket:{type:"string"}},required:["set"]}},required:["type"],additionalProperties:!1},menu:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"MENU"}},required:["type"],additionalProperties:!1},deck:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"DECK"},cards:{type:"array",items:{type:"object",properties:{settings:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the settings configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","PRODUCT_SELECTOR","CATEGORY_SELECTOR"]}},required:["type"],allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}}]}},minProperties:1}},required:["settings"]}}},required:["type","cards"]},product_selector:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"PRODUCT_SELECTOR"},product:{type:"object",properties:{id:{type:"number"}}},products:{type:"object",properties:{productIds:{type:"array",items:{type:"number"}}}},categoryId:{type:"number"},maxProducts:{type:"number"}},required:["type"],additionalProperties:!1},category_selector:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",const:"CATEGORY_SELECTOR"},categories:{type:"object",properties:{categoryIds:{type:"array",items:{type:"number"}}}},maxCategories:{type:"number"}},required:["type"],additionalProperties:!1}},pa={$schema:Un,$id:zn,title:Kn,description:Xn,type:Vn,$defs:Wn},Yn={__proto__:null,$defs:Wn,$id:zn,$schema:Un,default:pa,description:Xn,title:Kn,type:Vn},Zn="https://json-schema.org/draft/2020-12/schema",Qn="https://lightspeedhq.com/template-custom-design.schema.json",Jn="Custom Section :: Design Configuration",eo="Design tab configuration of a Custom Section for a Custom Template",to="object",no={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",const:"TEXT"},font:{description:"Default font for the text",type:"string"},size:{oneOf:[{description:"Default size for the text",type:"integer",minimum:1},{description:"Default global size string for the text",type:"string",enum:["global.textSize.title","global.textSize.subtitle","global.textSize.body"]}]},bold:{description:"Default boldness for the text",type:"boolean"},italic:{description:"Default italic style for the text",type:"boolean"},color:{oneOf:[{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the text",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},visible:{description:"Default visibility for the text",type:"boolean"}},additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",const:"BUTTON"},font:{description:"Default font for the button",type:"string"},size:{description:"Default size for the button",type:"string",enum:["SMALL","MEDIUM","LARGE"]},appearance:{description:"Default appearance for the button",type:"string",enum:["SOLID","OUTLINE","TEXT"]},shape:{description:"Default shape for the button",type:"string",enum:["ROUND_CORNER","RECTANGLE","PILL"]},color:{oneOf:[{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the button",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},visible:{description:"Default visibility for the button",type:"boolean"}},additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",const:"IMAGE"},static:{type:"boolean"},overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]}},if:{properties:{overlay:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default color for the image overlay",type:"array",items:{oneOf:[{description:"Default color for the image overlay",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the image overlay",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},minItems:2,maxItems:2}}},else:{properties:{color:{oneOf:[{description:"Default color for the image overlay",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the image overlay",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]}}}},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",const:"TOGGLE"},enabled:{description:"Default enabled status for the toggle",type:"boolean"}},additionalProperties:!1},info:{type:"object",properties:{type:{description:"Type of the info",type:"string",const:"INFO"},font:{description:"Default font for the info",type:"string"},size:{description:"Default size for the info",type:"integer",minimum:1},bold:{description:"Default boldness for the info",type:"boolean"},italic:{description:"Default italic style for the info",type:"boolean"},color:{description:"Default color for the info",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},visible:{description:"Default visibility for the info",type:"boolean"}},required:["type"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",const:"SELECTBOX"},value:{description:"Default option for the checkbox",type:"string"}},additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",const:"BACKGROUND"},style:{description:"Style of the background",type:"string",enum:["COLOR","GRADIENT"]}},if:{properties:{style:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default colors for the background",type:"array",items:{oneOf:[{description:"Default color for the background",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the background",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},minItems:2,maxItems:2}}},else:{properties:{color:{oneOf:[{description:"Default color for the background",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the background",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]}}}},logo:{type:"object",properties:{type:{description:"Type of the logo",type:"string",const:"LOGO"},font:{description:"Default font for the text logo",type:"string"},size:{oneOf:[{description:"Default size for the logo text",type:"integer",minimum:1},{description:"Default global size string for the logo text",type:"string",enum:["global.textSize.title","global.textSize.subtitle","global.textSize.body"]}]},bold:{description:"Default boldness for the text logo",type:"boolean"},italic:{description:"Default italic style for the text logo",type:"boolean"},color:{oneOf:[{description:"Default color for the logo text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the logo text",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},visible:{description:"Default visibility for the logo",type:"boolean"},spacing:{description:"Default spacing size for the text logo",type:"integer",minimum:1,exclusiveMaximum:10},capitalization:{description:"Default capitalization style for the text logo",type:"string",enum:["none","all","small"]},frame:{description:"Default frame for the text logo",type:"object",properties:{visible:{description:"Default visibility for the frame on text logo",type:"boolean"},width:{description:"Default width size for the frame on text logo",type:"integer",minimum:1,exclusiveMaximum:50},color:{oneOf:[{description:"Default color for frame on logo text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for frame on logo text",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]}},required:["visible","width","color"],additionalProperties:!1}},additionalProperties:!1}},ua={$schema:Zn,$id:Qn,title:Jn,description:eo,type:to,$defs:no},oo={__proto__:null,$defs:no,$id:Qn,$schema:Zn,default:ua,description:eo,title:Jn,type:to},so="https://json-schema.org/draft/2020-12/schema",ro="https://lightspeedhq.com/section-content.schema.json",io="Custom Section - Content",ao="The content of a custom section",co="object",lo={"^.*$":{type:"object",properties:{type:{type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","INFO","DECK","MENU","NAVIGATION_MENU","LOGO","DIVIDER","PRODUCT_SELECTOR","CATEGORY_SELECTOR"]}},required:["type"],allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"#/$defs/Inputbox"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"#/$defs/Textarea"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"#/$defs/Button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"#/$defs/Image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"#/$defs/Toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"#/$defs/Selectbox"}},{if:{properties:{type:{const:"INFO"}}},then:{$ref:"#/$defs/Info"}},{if:{properties:{type:{const:"DECK"}}},then:{$ref:"#/$defs/Deck"}},{if:{properties:{type:{const:"MENU"}}},then:{$ref:"#/$defs/Menu"}},{if:{properties:{type:{const:"NAVIGATION_MENU"}}},then:{$ref:"#/$defs/NavigationMenu"}},{if:{properties:{type:{const:"LOGO"}}},then:{$ref:"#/$defs/Logo"}},{if:{properties:{type:{const:"DIVIDER"}}},then:{$ref:"#/$defs/Divider"}},{if:{properties:{type:{const:"PRODUCT_SELECTOR"}}},then:{$ref:"#/$defs/ProductSelector"}},{if:{properties:{type:{const:"CATEGORY_SELECTOR"}}},then:{$ref:"#/$defs/CategorySelector"}}]}},po={Inputbox:{type:"object",properties:{type:{const:"INPUTBOX"},label:{$ref:"../common.schema.json#/$defs/label_type"},placeholder:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/InputboxDefaults"}},required:["type","label","placeholder"]},Textarea:{type:"object",properties:{type:{const:"TEXTAREA"},label:{$ref:"../common.schema.json#/$defs/label_type"},placeholder:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/TextareaDefaults"}},required:["type","label","placeholder"]},Button:{type:"object",properties:{type:{const:"BUTTON"},label:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/ButtonDefaults"}},required:["type","label"]},Image:{type:"object",properties:{type:{const:"IMAGE"},label:{$ref:"../common.schema.json#/$defs/label_type"},static:{type:"boolean"},defaults:{$ref:"#/$defs/ImageDefaults"}},required:["type","label"]},Toggle:{type:"object",properties:{type:{const:"TOGGLE"},label:{$ref:"../common.schema.json#/$defs/label_type"},description:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/ToggleDefaults"}},required:["type","label","description"]},Selectbox:{type:"object",properties:{type:{const:"SELECTBOX"},label:{$ref:"../common.schema.json#/$defs/label_type"},placeholder:{$ref:"../common.schema.json#/$defs/label_type"},description:{$ref:"../common.schema.json#/$defs/label_type"},options:{type:"array",items:{$ref:"#/$defs/SelectboxOption"}},defaults:{$ref:"#/$defs/SelectboxDefaults"}},required:["type","label","placeholder","description","options"]},Menu:{type:"object",properties:{type:{const:"MENU"},label:{$ref:"../common.schema.json#/$defs/label_type"}},required:["type"]},NavigationMenu:{type:"object",properties:{type:{const:"NAVIGATION_MENU"}},required:["type"]},Logo:{type:"object",properties:{type:{const:"LOGO"},label:{$ref:"../common.schema.json#/$defs/label_type"}},required:["type"]},Info:{type:"object",properties:{type:{const:"INFO"},label:{$ref:"../common.schema.json#/$defs/label_type"},description:{$ref:"../common.schema.json#/$defs/label_type"},button:{$ref:"#/$defs/InfoEditorButton"},defaults:{$ref:"#/$defs/InfoDefaults"}},required:["type","label","description"]},Divider:{type:"object",properties:{type:{const:"DIVIDER"},label:{$ref:"../common.schema.json#/$defs/label_type"}},required:["type","label"]},InputboxDefaults:{type:"object",properties:{text:{$ref:"../common.schema.json#/$defs/label_type"}},required:["text"]},TextareaDefaults:{type:"object",properties:{text:{$ref:"../common.schema.json#/$defs/label_type"}},required:["text"]},ButtonDefaults:{type:"object",properties:{title:{$ref:"../common.schema.json#/$defs/label_type"},buttonType:{type:"string",enum:["SCROLL_TO_TILE","HYPER_LINK","MAIL_LINK","TEL_LINK","GO_TO_STORE_LINK","GO_TO_PAGE"]},link:{type:"string",format:"uri"},linkTarget:{type:"string"},email:{type:"string"},phone:{type:"string"},tileId:{type:"string"}},required:["title"]},ImageDefaults:{type:"object",properties:{imageData:{$ref:"section-commons.schema.json#/$defs/Image"}}},ToggleDefaults:{type:"object",properties:{enabled:{type:"boolean"}}},SelectboxDefaults:{type:"object",properties:{value:{type:"string"}}},InfoDefaults:{type:"object",properties:{text:{$ref:"../common.schema.json#/$defs/label_type"},button:{$ref:"#/$defs/InfoButtonDefaults"}}},SelectboxOption:{type:"object",properties:{label:{$ref:"../common.schema.json#/$defs/label_type"},value:{type:"string"}}},InfoEditorButton:{type:"object",properties:{label:{$ref:"../common.schema.json#/$defs/label_type"},link:{type:"string"}}},InfoButtonDefaults:{type:"object",properties:{title:{$ref:"../common.schema.json#/$defs/label_type"},link:{type:"string",minLength:0}}},Deck:{type:"object",properties:{type:{const:"DECK"},cards:{description:"Cards of the content configuration element",type:"object",properties:{defaultCardContent:{type:"object",properties:{label:{$ref:"../common.schema.json#/$defs/label_type"},settings:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the settings configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","PRODUCT_SELECTOR","CATEGORY_SELECTOR"]}},required:["type"],allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"#/$defs/Inputbox"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"#/$defs/Textarea"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"#/$defs/ButtonDefaults"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"#/$defs/Image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"#/$defs/Toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"#/$defs/Selectbox"}}]}},minProperties:1}},required:["label","settings"]}},required:["defaultCardContent"]},label:{$ref:"../common.schema.json#/$defs/label_type"},addButtonLabel:{$ref:"../common.schema.json#/$defs/label_type"},maxCards:{type:"number"}},required:["cards","maxCards","label","addButtonLabel","type"]},ProductSelector:{type:"object",properties:{type:{const:"PRODUCT_SELECTOR"},label:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/ProductSelectorDefaults"}},required:["type","label"]},ProductSelectorDefaults:{type:"object",properties:{maxProducts:{type:"number"}}},CategorySelector:{type:"object",properties:{type:{const:"CATEGORY_SELECTOR"},label:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/CategorySelectorDefaults"}},required:["type","label"]},CategorySelectorDefaults:{type:"object",properties:{maxCategories:{type:"number"}}}},uo=!1,fa={$schema:so,$id:ro,title:io,description:ao,type:co,patternProperties:lo,$defs:po,additionalProperties:uo},fo={__proto__:null,$defs:po,$id:ro,$schema:so,additionalProperties:uo,default:fa,description:ao,patternProperties:lo,title:io,type:co},ho="https://json-schema.org/draft/2020-12/schema",mo="https://lightspeedhq.com/section-layout.schema.json",yo="Section Layout Schema",go="Schema for validating section layout configurations",$o="array",Eo={type:"object",required:["layoutId","selectedContentSettings","selectedDesignSettings"],properties:{layoutId:{type:"string",description:"Unique identifier for the layout"},layoutIcon:{type:"string",description:"Icon identifier used in the layout selector",enum:["HEADER_LEFT","HEADER_CENTER_LOGO_BURGER","HEADER_CENTER_LOGO_COMPACT","HEADER_CENTER_LOGO_DETAILED","HEADER_LEFT_LOGO_BURGER","HEADER_LEFT_LOGO_COMPACT","HEADER_LEFT_LOGO_DETAILED","HEADER_LEFT_LOGO_SEARCH","HEADER_LEFT_LOGO_TEXT","TEXT_ONE_COLUMN","TEXT_TITLE_LEFT","TEXT_SUBTITLE_RIGHT","TEXT_TWO_COLUMNS","TEXT_CENTER","TEXT_DESCRIPTION_RIGHT","CTA_BANNER_LEFT","CTA_BANNER_RIGHT","CTA_BANNER_CENTER","CTA_BANNER_BOTTOM","CTA_PROMO_BAR_LEFT","CTA_PROMO_BAR_RIGHT","CTA_STORY_LEFT","CTA_STORY_RIGHT","CTA_FULLWIDTH_CENTER","CTA_FULLWIDTH_LEFT","COVER_FULLSCREEN_CENTER","COVER_FULLSCREEN_LEFT","COVER_FULLSCREEN_CENTER_LEFT","COVER_FULLSCREEN_RIGHT","COVER_FULLSCREEN_BOTTOM","COVER_FULLSCREEN_BOTTOM_RIGHT","COVER_FULLSCREEN_BOTTOM_LEFT","COVER_FULLSCREEN_TOP","COVER_SIDEBAR_RIGHT","COVER_SIDEBAR_LEFT","COVER_HALFSCREEN_LEFT","COVER_HALFSCREEN_CENTER","COVER_COLLAGE_BOTTOM","COVER_COLLAGE_LEFT","IMAGE_SUBTITLE_RIGHT","IMAGE_TITLE_LEFT","IMAGE_LEFT","IMAGE_RIGHT","IMAGE_CENTER","IMAGE_SIDE_TITLE","LOCATION_MAP_RIGHT","LOCATION_MAP_LEFT","LOCATION_IMAGE_RIGHT","LOCATION_IMAGE_LEFT","LOCATION_BACKGROUND_RIGHT","LOCATION_BACKGROUND_LEFT","LOCATION_FULL","LOCATION_SHORT","REVIEWS_MINIMAL","REVIEWS_CARDS","REVIEWS","REVIEWS_CLASSIC","REVIEWS_FULLSCREEN_BG","REVIEWS_FULLSCREEN_SIDEBAR_LEFT","REVIEWS_FULLSCREEN_SIDEBAR_RIGHT","REVIEWS_CARDS_PHOTO","REVIEWS_PHOTO_SPEECH_RIGHT","REVIEWS_PHOTO_SPEECH_LEFT","REVIEWS_SOCIAL_FEED","REVIEWS_ADAPTIVE","FEATURES_CLASSIC_CENTER","FEATURES_CLASSIC_LEFT","FEATURES_ACCORDION","FEATURES_MINIMAL","FEATURES_SMALL_ICONS","FEATURES_CAROUSEL","FEATURES_IMAGE_LEFT","FEATURES_IMAGE_RIGHT","ANNOUNCEMENT_CENTER","SLIDER_FULLSCREEN_CENTER","SLIDER_FULLSCREEN_LEFT"]},selectedContentSettings:{type:"array",description:"Array of selected content settings (field names only)",items:{type:"string"}},selectedDesignSettings:{type:"array",description:"Array of selected design settings with optional overrides",items:{$ref:"#/$defs/selectionItem"}}},additionalProperties:!1},bo={selectionItem:{type:"object",description:"Pick a design field by name; optionally override its defaults for this layout.",required:["fieldName"],properties:{fieldName:{type:"string"},type:{type:"string",enum:["TEXT","IMAGE","BUTTON","BACKGROUND","TOGGLE","COLOR_PICKER","RATING","SELECTBOX","SOCIAL_PROFILES","LOGO","INFO","DIVIDER"]},defaults:{type:"object",description:"Design editor defaults; shape depends on the type property"}},allOf:[{if:{required:["type"],properties:{type:{const:"TEXT"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/TextDesignDefaults"}}}},{if:{required:["type"],properties:{type:{const:"IMAGE"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/ImageDesignDefaults"}}}},{if:{required:["type"],properties:{type:{const:"BUTTON"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/ButtonDesignDefaults"}}}},{if:{required:["type"],properties:{type:{const:"BACKGROUND"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/BackgroundDesignDefaults"}}}},{if:{required:["type"],properties:{type:{const:"TOGGLE"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/ToggleDesignDefaults"}}}},{if:{required:["type"],properties:{type:{const:"COLOR_PICKER"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/ColorPickerDefaults"}}}},{if:{required:["type"],properties:{type:{const:"RATING"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/RatingDefaults"}}}},{if:{required:["type"],properties:{type:{const:"SELECTBOX"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/SelectboxDefaults"}}}},{if:{required:["type"],properties:{type:{const:"SOCIAL_PROFILES"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/SocialProfilesDefaults"}}}},{if:{required:["type"],properties:{type:{const:"LOGO"}}},then:{required:["defaults"],properties:{defaults:{$ref:"./section-design.schema.json#/$defs/LogoDesignDefaults"}}}},{if:{required:["defaults"]},then:{required:["type"]}}],additionalProperties:!1}},da={$schema:ho,$id:mo,title:yo,description:go,type:$o,items:Eo,$defs:bo},_o={__proto__:null,$defs:bo,$id:mo,$schema:ho,default:da,description:go,items:Eo,title:yo,type:$o},So="https://json-schema.org/draft/2020-12/schema",To="https://lightspeedhq.com/sections/section-translation.schema.json",wo="Custom Section - Translations",Co="The translation of the section's labels",Ao="object",Ro={"^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$":{type:"object",patternProperties:{"^\\$.*$":{type:"string"}},additionalProperties:!1}},Oo=!1,ha={$schema:So,$id:To,title:wo,description:Co,type:Ao,patternProperties:Ro,additionalProperties:Oo},wt={__proto__:null,$id:To,$schema:So,additionalProperties:Oo,default:ha,description:Co,patternProperties:Ro,title:wo,type:Ao},vo="https://json-schema.org/draft/2020-12/schema",Io="https://lightspeedhq.com/section-design.schema.json",Lo="Custom Section - Design",jo="The design of a custom section",xo="object",No={"^.*$":{type:"object",properties:{type:{type:"string",enum:["TEXT","IMAGE","BUTTON","BACKGROUND","TOGGLE","COLOR_PICKER","RATING","SELECTBOX","SOCIAL_PROFILES","LOGO","INFO","DIVIDER"]}},required:["type"],allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"#/$defs/Text"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"#/$defs/Image"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"#/$defs/Button"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"#/$defs/Background"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"#/$defs/Toggle"}},{if:{properties:{type:{const:"COLOR_PICKER"}}},then:{$ref:"#/$defs/Color"}},{if:{properties:{type:{const:"RATING"}}},then:{$ref:"#/$defs/Rating"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"#/$defs/Selectbox"}},{if:{properties:{type:{const:"SOCIAL_PROFILES"}}},then:{$ref:"#/$defs/SocialProfile"}},{if:{properties:{type:{const:"LOGO"}}},then:{$ref:"#/$defs/Logo"}},{if:{properties:{type:{const:"INFO"}}},then:{$ref:"#/$defs/Info"}},{if:{properties:{type:{const:"DIVIDER"}}},then:{$ref:"#/$defs/Divider"}}],additionalProperties:!0}},Po={Text:{type:"object",properties:{type:{const:"TEXT"},label:{$ref:"../common.schema.json#/$defs/label_type"},sizes:{type:"array",items:{type:"integer"}},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAlphaColor:{type:["boolean","null"]},enableAutoColor:{type:["boolean","null"]},hideVisibleToggle:{type:["boolean","null"]},hideSize:{type:["boolean","null"]},defaults:{$ref:"#/$defs/TextDesignDefaults"}},required:["type","label"]},Image:{type:"object",properties:{type:{const:"IMAGE"},label:{$ref:"../common.schema.json#/$defs/label_type"},static:{type:"boolean"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAlphaColor:{type:["boolean","null"]},hideVisibleToggle:{type:["boolean","null"]},defaults:{$ref:"#/$defs/ImageDesignDefaults"}},required:["type","label"]},Button:{type:"object",properties:{type:{const:"BUTTON"},label:{$ref:"../common.schema.json#/$defs/label_type"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAutoColor:{type:["boolean","null"]},enableAlphaColor:{type:["boolean","null"]},hideVisibleToggle:{type:["boolean","null"]},hideSize:{type:["boolean","null"]},defaults:{$ref:"#/$defs/ButtonDesignDefaults"}},required:["type","label"]},Background:{type:"object",properties:{type:{const:"BACKGROUND"},label:{$ref:"../common.schema.json#/$defs/label_type"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAlphaColor:{type:["boolean","null"]},enableAutoColor:{type:["boolean","null"]},defaults:{$ref:"#/$defs/BackgroundDesignDefaults"}},required:["type","label"]},Toggle:{type:"object",properties:{type:{const:"TOGGLE"},label:{$ref:"../common.schema.json#/$defs/label_type"},description:{$ref:"../common.schema.json#/$defs/label_type"},defaults:{$ref:"#/$defs/ToggleDesignDefaults"}},required:["type","label"]},Color:{type:"object",properties:{type:{const:"COLOR_PICKER"},label:{$ref:"../common.schema.json#/$defs/label_type"},description:{$ref:"../common.schema.json#/$defs/label_type"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAlphaColor:{type:["boolean","null"]},enableAutoColor:{type:["boolean","null"]},defaults:{$ref:"#/$defs/ColorPickerDefaults"}},required:["type","label"]},Rating:{type:"object",properties:{type:{const:"RATING"},label:{$ref:"../common.schema.json#/$defs/label_type"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAlphaColor:{type:["boolean","null"]},enableAutoColor:{type:["boolean","null"]},hideVisibleToggle:{type:["boolean","null"]},options:{type:"array",items:{$ref:"#/$defs/SelectboxOption"}},defaults:{$ref:"#/$defs/RatingDefaults"}},required:["type","label"]},Selectbox:{type:"object",properties:{type:{const:"SELECTBOX"},label:{$ref:"../common.schema.json#/$defs/label_type"},description:{$ref:"../common.schema.json#/$defs/label_type"},options:{type:"array",items:{$ref:"#/$defs/SelectboxOption"}},defaults:{$ref:"#/$defs/SelectboxDefaults"}},required:["type","label"]},SocialProfile:{type:"object",properties:{type:{const:"SOCIAL_PROFILES"},label:{$ref:"../common.schema.json#/$defs/label_type"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},enableAlphaColor:{type:["boolean","null"]},enableAutoColor:{type:["boolean","null"]},options:{type:"array",items:{$ref:"#/$defs/SelectboxOption"}},defaults:{$ref:"#/$defs/SocialProfilesDefaults"}},required:["type","label"]},Logo:{type:"object",properties:{type:{const:"LOGO"},label:{$ref:"../common.schema.json#/$defs/label_type"},colors:{type:"array",items:{type:"string",pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$"}},sizes:{type:"array",items:{type:"integer"}},defaults:{$ref:"#/$defs/LogoDesignDefaults"}},required:["type"]},Info:{type:"object",properties:{type:{const:"INFO"},text:{type:"string"},button:{type:"object",properties:{title:{type:"string"},link:{type:"string"}},additionalProperties:!0}},required:["type","text"],additionalProperties:!0},Divider:{type:"object",properties:{type:{const:"DIVIDER"},label:{$ref:"../common.schema.json#/$defs/label_type"}},required:["type","label"]},TextDesignDefaults:{type:"object",properties:{font:{type:"string"},size:{oneOf:[{description:"Default size for the text",type:"integer",minimum:1},{description:"Default global size string for the text",type:"string",enum:["global.textSize.title","global.textSize.subtitle","global.textSize.body"]}]},bold:{type:"boolean"},italic:{type:"boolean"},color:{oneOf:[{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the text",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},visible:{type:"boolean"}},required:[]},ImageDesignDefaults:{type:"object",properties:{overlay:{type:"string"},visible:{type:"boolean"}},if:{properties:{overlay:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default colors for the image overlay",type:"array",items:{oneOf:[{description:"Default color for the image overlay",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the image overlay",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},minItems:2,maxItems:2}}},else:{properties:{color:{oneOf:[{description:"Default color for the image overlay",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the image overlay",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]}}},required:[]},ButtonDesignDefaults:{type:"object",properties:{appearance:{type:"string",enum:["SOLID","OUTLINE","TEXT"]},font:{type:"string"},size:{type:"string",enum:["SMALL","MEDIUM","LARGE"]},style:{type:"string",enum:["round-corner","rectangle","pill"]},color:{oneOf:[{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the button",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},visible:{type:"boolean"}},required:[]},BackgroundDesignDefaults:{type:"object",properties:{type:{description:"Type of the background",type:"string",const:"BACKGROUND"},style:{description:"Style of the background",type:"string",enum:["COLOR","GRADIENT"]}},if:{properties:{style:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default colors for the background",type:"array",items:{oneOf:[{description:"Default color for the background",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the background",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},minItems:2,maxItems:2}}},else:{properties:{color:{oneOf:[{description:"Default color for the background",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the background",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]}}}},ToggleDesignDefaults:{type:"object",properties:{enabled:{type:"boolean"}},required:[]},ColorPickerDefaults:{type:"object",properties:{appearance:{$ref:"section-commons.schema.json#/$defs/Color"}},required:[]},RatingDefaults:{type:"object",properties:{color:{$ref:"section-commons.schema.json#/$defs/Color"},visible:{type:"boolean"},style:{type:"string"}},required:[]},SelectboxDefaults:{type:"object",properties:{value:{type:"string"}},required:[]},SocialProfilesDefaults:{type:"object",properties:{color:{$ref:"section-commons.schema.json#/$defs/Color"},visible:{type:"boolean"},appearance:{type:"string"}},required:[]},LogoDesignDefaults:{type:"object",properties:{font:{type:"string"},size:{oneOf:[{description:"Default size for the logo text",type:"integer",minimum:1},{description:"Default global size string for the logo text",type:"string",enum:["global.textSize.title","global.textSize.subtitle","global.textSize.body"]}]},bold:{type:"boolean"},italic:{type:"boolean"},color:{oneOf:[{description:"Default color for the logo text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},{description:"Default global color string for the logo text",type:"string",enum:["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"]}]},visible:{type:"boolean"}},required:[]},SelectboxOption:{type:"object",properties:{value:{type:"string"},label:{$ref:"../common.schema.json#/$defs/label_type"}},required:[]}},ma={$schema:vo,$id:Io,title:Lo,description:jo,type:xo,patternProperties:No,$defs:Po},Do={__proto__:null,$defs:Po,$id:Io,$schema:vo,default:ma,description:jo,patternProperties:No,title:Lo,type:xo},ko="https://json-schema.org/draft/2020-12/schema",Fo="https://lightspeedhq.com/section-commons.schema.json",Ho="Custom Section - Content",Mo="The content of a custom section",Go="object",Bo={Image:{type:"object",properties:{set:{type:"object",properties:{MOBILE_WEBP_LOW_RES:{$ref:"#/$defs/ImageInfo"},MOBILE_WEBP_HI_RES:{$ref:"#/$defs/ImageInfo"},WEBP_LOW_RES:{$ref:"#/$defs/ImageInfo"},WEBP_HI_2X_RES:{$ref:"#/$defs/ImageInfo"},ORIGINAL:{$ref:"#/$defs/ImageInfo"}},additionalProperties:!1,minProperties:1},borderInfo:{$ref:"#/$defs/BorderInfo"}},additionalProperties:!1,required:["set"]},ImageInfo:{type:"object",properties:{url:{type:"string"},width:{type:"integer",minimum:0},height:{type:"integer",minimum:0}}},BorderInfo:{type:"object",properties:{homogeneity:{type:"boolean"},color:{$ref:"#/$defs/RGBA"}}},RGBA:{type:"object",properties:{r:{type:"integer",minimum:0,maximum:255},g:{type:"integer",minimum:0,maximum:255},b:{type:"integer",minimum:0,maximum:255},a:{type:"number",format:"double",minimum:0,maximum:1}},required:["r","g","b","a"]},HSL:{type:"object",properties:{h:{type:"number",format:"double"},s:{type:"number",format:"double"},l:{type:"number",format:"double"},a:{type:"number",format:"double"}},required:["h","s","l","a"]},Overlay:{type:"object",properties:{type:{type:"string",enum:["solid","gradient","none"]},solid:{$ref:"#/$defs/Solid"},gradient:{$ref:"#/$defs/Gradient"}}},Solid:{type:"object",properties:{color:{$ref:"#/$defs/Color"}}},Gradient:{type:"object",properties:{fromColor:{$ref:"#/$defs/Color"},toColor:{$ref:"#/$defs/Color"}}},Background:{type:"object",properties:{type:{type:"string",enum:["solid","gradient"]},solid:{$ref:"#/$defs/Solid"},gradient:{$ref:"#/$defs/Gradient"}}},Color:{type:"object",properties:{raw:{type:"string"},hex:{type:"string"},auto:{type:"boolean"},rgba:{$ref:"#/$defs/RGBA"},hsl:{$ref:"#/$defs/HSL"}}}},qo=!1,ya={$schema:ko,$id:Fo,title:Ho,description:Mo,type:Go,$defs:Bo,additionalProperties:qo},Uo={__proto__:null,$defs:Bo,$id:Fo,$schema:ko,additionalProperties:qo,default:ya,description:Mo,title:Ho,type:Go},zo="https://json-schema.org/draft/2020-12/schema",Ko="https://lightspeedhq.com/section-showcase.schema.json",Xo="Custom Section - Showcase settings",Vo="The setting of a showcase",Wo="object",Yo=["showcaseId","previewImage"],Zo=[{properties:{showcaseId:{description:"Showcase id of the section",type:"string"},previewImage:{$ref:"section-commons.schema.json#/$defs/Image"}}},{$ref:"../showcase_overrides.schema.json"}],ga={$schema:zo,$id:Ko,title:Xo,description:Vo,type:Wo,required:Yo,allOf:Zo},Qo={__proto__:null,$id:Ko,$schema:zo,allOf:Zo,default:ga,description:Vo,required:Yo,title:Xo,type:Wo},Jo="https://json-schema.org/draft/2020-12/schema",es="https://lightspeedhq.com/template.schema.json",ts="Custom Template",ns="A custom template enclosing the necessary custom and default blocks",os="object",ss={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},preview_url:{description:"Preview url of the demo website",type:"string",format:"uri",pattern:"^(https?)://([^.]+?\\.)?(company\\.site|ecwid\\.qa)($|/[A-Za-z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=]*)?$"},cover_image:{type:"object",properties:{set:{description:"Name of the image set",type:"object",patternProperties:{".*":{type:"object",properties:{url:{description:"Path to the preview image relative to the 'assets' folder for a specific resolution",type:"string"}},required:["url"],additionalProperties:!1}}}},required:["set"],additionalProperties:!1},categories:{description:"List of template categories for Template Market filtering",type:"array",items:{type:"string",enum:["apparel_footwear","vape_smoke","home_garden","sport_outdoor","jewelry_accessories","pet_animals","bikes","health_beauty","gift_shop","electronics","other"]},uniqueItems:!0}},required:["name","description","cover_image"],additionalProperties:!1},sections:{description:"List of sections contained by this template",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"default"}}},then:{$ref:"template-default.schema.json#/$defs/default-section"}},{if:{properties:{type:{const:"custom"}}},then:{$ref:"template-custom.schema.json#/$defs/custom-section"}}]},minItems:1,uniqueItems:!1}},rs=["metadata","sections"],$a={$schema:Jo,$id:es,title:ts,description:ns,type:os,properties:ss,required:rs},is={__proto__:null,$id:es,$schema:Jo,default:$a,description:ns,properties:ss,required:rs,title:ts,type:os},as="https://json-schema.org/draft/2020-12/schema",cs="https://lightspeedhq.com/showcase_overrides.schema.json",ls="Showcase overrides",ps="Overrides for the showcase",us="object",fs={content:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","LOGO","DECK","MENU","NAVIGATION_MENU","INFO","PRODUCT_SELECTOR","CATEGORY_SELECTOR"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"LOGO"}}},then:{$ref:"template-custom-content.schema.json#/$defs/logo"}},{if:{properties:{type:{const:"DECK"}}},then:{$ref:"template-custom-content.schema.json#/$defs/deck"}},{if:{properties:{type:{const:"PRODUCT_SELECTOR"}}},then:{$ref:"template-custom-content.schema.json#/$defs/product_selector"}},{if:{properties:{type:{const:"CATEGORY_SELECTOR"}}},then:{$ref:"template-custom-content.schema.json#/$defs/category_selector"}}]}}},design:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the design configuration element",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND","LOGO"]}},allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"template-custom-design.schema.json#/$defs/text"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-design.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-design.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"template-custom-design.schema.json#/$defs/background"}},{if:{properties:{type:{const:"LOGO"}}},then:{$ref:"template-custom-design.schema.json#/$defs/logo"}},{if:{properties:{type:{const:"INFO"}}},then:{$ref:"template-custom-design.schema.json#/$defs/info"}}]}}},layoutId:{description:"Layout ID for the showcase",type:"string"},blockName:{description:"Section name for the showcase",$ref:"common.schema.json#/$defs/label_type"}},Ea={$schema:as,$id:cs,title:ls,description:ps,type:us,properties:fs},ds={__proto__:null,$id:cs,$schema:as,default:Ea,description:ps,properties:fs,title:ls,type:us},hs="https://json-schema.org/draft/2020-12/schema",ms="https://lightspeedhq.com/common.schema.json",ys="Common Type Definitions",gs="Common type definitions, used throughout other schemas",$s="object",Es={label_type:{type:"string",pattern:"^\\$.+"}},ba={$schema:hs,$id:ms,title:ys,description:gs,type:$s,$defs:Es},bs={__proto__:null,$defs:Es,$id:ms,$schema:hs,default:ba,description:gs,title:ys,type:$s};function De(e){return re(`${ze}/${e}`)?ue.HEADER:re(`${Ke}/${e}`)?ue.FOOTER:ue.SECTION}function Ct(e){const t=De(e);return ce[t].dist}const _a={menu:{type:"NAVIGATION_MENU"},logo:{type:"LOGO"}},Sa={logo:{type:"LOGO",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:{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 _s(e){switch(e){case ue.HEADER:return _a;default:return{}}}function Ss(e){switch(e){case ue.HEADER:return Sa;default:return{}}}function Ta({validationType:e,sectionType:t}){switch(e){case Me.CONTENT:return _s(t);case Me.DESIGN:return Ss(t);default:return{}}}function wa({sectionSettings:e,mandatorySettings:t}){const n=[];return Object.entries(e).filter(([o])=>t[o]!==void 0).forEach(([o,s])=>{const i=t[o];s.type!==i.type&&n.push({instancePath:o,keyword:"type-mismatch",message:`Editor type "${s.type}" for reserved key "${o}" does not match the required type "${i.type}".`})}),n}function Ca({type:e,mandatorySettings:t}){return Object.keys(t).find(n=>t[n].type===e)}function Aa({sectionSettings:e,mandatorySettings:t}){const n=[];return Object.entries(e).forEach(([o,s])=>{const i=Ca({type:s.type,mandatorySettings:t});i&&o!==i&&n.push({instancePath:o,keyword:"key-mismatch",message:`Editor key "${o}" for overriden content type "${s.type}" does not match the required key name "${i}".`})}),n}function Ra({type:e,mandatorySettings:t}){return Object.keys(t).findLast(n=>t[n].type===e)}function Oa({sectionSettings:e,mandatorySettings:t}){const n=[],o=Object.values(t).map(({type:i})=>i),s=Object.values(e).map(({type:i})=>i);return new Set(s.filter(i=>o.includes(i))).forEach(i=>{if(s.filter(r=>r===i).length>1){const r=Ra({type:i,mandatorySettings:t});n.push({instancePath:r,keyword:"duplicate-type",message:`Editor type "${i}" can only be used once.`})}}),n}function va(e,t){const{sectionSettings:n,sectionType:o}=t,s=Ta({validationType:e,sectionType:o});return s===void 0||vn(s)?[]:[...wa({sectionSettings:n,mandatorySettings:s}),...Aa({sectionSettings:n,mandatorySettings:s}),...Oa({sectionSettings:n,mandatorySettings:s})]}function Ia(e,t){const n=[];if(!e.cards?.defaultCardContent)return n;const o=e.cards.defaultCardContent.settings;for(const[s,i]of Object.entries(o)){const r=i;r?.type==="IMAGE"&&n.push({key:s,editor:r,path:`${t}/cards/defaultCardContent/settings/${s}`})}return n}function La(e,t){const n=e[t];if(n?.type==="IMAGE")return n}function Ts(e,t,n,o,s){const i=La(n,e);if(i?.type!=="IMAGE")return;const r=t.static,a=i.static;(r??!1)!==(a??!1)&&s.push({instancePath:o,message:`Both "${e} content and design editor need to have same value for attribute static`,keyword:"image-editor-mismatch"})}function ja(e,t,n,o){for(const[s,i]of Object.entries(e)){const r=i,a=`/${s}`;if(r.type==="IMAGE")Ts(s,r,t,a,o);else if(r.type==="DECK"){const c=Ia(r,a);for(const{key:l,editor:f,path:E}of c)Ts(l,f,t,E,o)}}}async function xa(e,t,n){if(!e.sectionName||e.validationType!==Me.CONTENT)return[];const o=W.resolve(`${n}/${e.sectionName}/js/settings/design`),s=await xe(o,!1),i=[];return ja(t,s,"",i),i}const Ge=[Uo,Do,fo,_o,Qo,is,Dn,qn,Yn,oo,ds,bs];function ke(e,t){const n=new $i({allErrors:!0,schemas:e});return Ei(n),n.getSchema(t.$id)||n.compile(t)}function Na(){return ke(Ge,is)}function ut(e){return e.map(t=>({instancePath:t.instancePath,message:t.message??"",keyword:t.keyword}))}const Pa=e=>(()=>{const t=Ct(e.name),n=t.split("/").pop()?.toLowerCase();return[{source:`./${n}/${e.name}/settings/content.ts`,dist:W.resolve(`${t}/${e.name}/js/settings/content`),ajv:ke(Ge,fo),validationType:Me.CONTENT,sectionName:e.name,type:e.type},{source:`./${n}/${e.name}/settings/design.ts`,dist:W.resolve(`${t}/${e.name}/js/settings/design`),ajv:ke(Ge,Do),validationType:Me.DESIGN,sectionName:e.name,type:e.type},...V.existsSync(`./${n}/${e.name}/settings/layout.ts`)?[{source:`./${n}/${e.name}/settings/layout.ts`,dist:W.resolve(`${t}/${e.name}/js/settings/layout`),ajv:ke(Ge,_o),sectionName:e.name,type:e.type}]:[],{source:`./${n}/${e.name}/settings/translations.ts`,dist:W.resolve(`${t}/${e.name}/js/settings/translations`),ajv:ke(Ge,wt),type:e.type},...e.showcaseEntryPoints.map(o=>({source:`./${n}/${e.name}/showcases/${He(o).name}.ts`,dist:W.resolve(`${t}/${e.name}/js/showcases/${He(o).name}`),ajv:ke(Ge,o.indexOf("translations")===-1?Qo:wt),type:e.type,sectionName:e.name}))]})();function Da(e){const t=s=>{const i=(s??"").split("/").filter(r=>r.length>0);return i.length===0?"$":`$${i.map(r=>`.${r}`).join("")}`};let n=0,o=0;Object.keys(e).forEach(s=>{const i=e[s];n=Math.max(n,Math.max(...i.map(r=>t(r.instancePath).length))),o=Math.max(o,Math.max(...i.map(r=>r.message.length)))}),Object.keys(e).forEach(s=>{const i=e[s].filter((r,a,c)=>a===c.findIndex(l=>`${r.instancePath}${r.message}${r.keyword}`==`${l.instancePath}${l.message}${l.keyword}`));I.error(s),i.filter(r=>r.keyword!=="if").forEach(r=>{I.error(`${t(r.instancePath).padEnd(n," ")} | ${r.message.padEnd(o," ")} | ${r.keyword||"-"}`)})})}function ka(e,t){if(e.validationType===void 0||e.sectionName===void 0)return[];const{sectionName:n,validationType:o}=e,s=De(n);return[...va(o,{sectionSettings:t,sectionType:s})]}function ws(e,t){return Si({path:"$..set..url",json:t,resultType:"value"}).map(n=>{if(new RegExp(/^https?:\/\//).test(n))return null;const o=`${e}/assets/${n}`;return re(o)?null:{message:`Image ${n} is missing from assets folder`,keyword:"missing-asset"}}).filter(n=>n!==null)}function Fa(e,t,n,o){const s=[],i=t.cards?.defaultCardContent?.settings;if(!i)return s;const r=new Set(Object.keys(i));return e.cards.forEach((a,c)=>{const l=a.settings;l&&Object.keys(l).forEach(f=>{r.has(f)||s.push({instancePath:`showcases/${o}/content/${n}/cards/${c}/settings/${f}`,message:`Setting '${f}' is not defined in content.ts defaultCardContent.settings`,keyword:"invalid-deck-card-setting"})})}),s}async function Ha(e,t){const n=[];if(!e.source||!e.source.includes("/sections/")||e.validationType!==Me.CONTENT||!e.sectionName)return n;const o=Ct(e.sectionName),s=W.resolve(`${o}/${e.sectionName}/js/showcases`);if(!re(s))return n;const i=V.readdirSync(s).filter(a=>a.endsWith(".mjs")&&a!=="translations.mjs").map(async a=>{const c=W.resolve(`${s}/${a.replace(".mjs","")}`),l=await xe(c,!1);return{showcaseFile:a,showcaseData:l}}),r=await Promise.all(i);for(const{showcaseFile:a,showcaseData:c}of r){if(!c.content)continue;const l=c.content;Object.keys(l).forEach(f=>{const E=l[f],u=t[f];if(!u){n.push({instancePath:`showcases/${a.replace(".mjs","")}/content/${f}`,message:`Element '${f}' is not defined in content.ts`,keyword:"invalid-showcase-element"});return}if(E.type!==u.type){n.push({instancePath:`showcases/${a.replace(".mjs","")}/content/${f}`,message:`Element '${f}' type mismatch: showcase has type '${E.type}' but content.ts has type '${u.type}'`,keyword:"type-mismatch"});return}E.type==="DECK"&&u.type==="DECK"&&n.push(...Fa(E,u,f,a.replace(".mjs","")))})}return n}async function Ma(e){const t=await xe(e.dist,!1),n={},o=[],s=Ct(e.sectionName??""),i=s.split("/").pop()?.toLowerCase();if(e.ajv(t)||o.push(...ut(e.ajv.errors??[])),o.push(...ka(e,t),...ws(`${i}/${e.sectionName}`,t),...await xa(e,t,s)),e.source&&e.source.includes("/sections/")&&e.validationType===Me.CONTENT){const r=await Ha(e,t);o.push(...r)}return o.length>0&&(n[e.source]=o),n}async function Ga(e){const t=_i(bi.gunzip),n=await V.promises.readFile(e);return(await t(n)).length}async function Cs(e,t){const n=We[e],o=W.resolve(`${n.toPath(t)}${n.fileName}`),s=await Ga(o);if(s>Rn)throw I.error(`Size of individual server file must not exceed threshold [${Qe(Rn)}]!`),I.error(`${`File: ${o}`.padEnd(o.length+10)}| ${Qe(s)}`),new Error("Invalid server file size")}function As(e){const t=e.reduce((n,o)=>{const s=ni(o);return s.size>An&&(n[o]=Qe(s.size)),n},{});if(Object.keys(t).length!==0){const n=Math.max(...Object.keys(t).map(o=>o.length));I.error(`Size of individual assets must not exceed threshold [${Qe(An)}]!`);for(const o in t)I.error(`${`File: ${o}`.padEnd(n+10)}| ${t[o]}`);throw new Error("Invalid asset file size")}}function Ba(e,t,n,o){const s={};return e(t)&&o===void 0?pn(`${n}${je}.mjs`,`${n}.mjs`,()=>{}):(un(`${n}${je}.mjs`,()=>{}),s[W.resolve(`./templates/${He(n).name}.ts`)]=[...ut(e.errors??[]),...o??[]]),s}async function qa(){const e={},t="dist/shared/translation",n=W.resolve(process.cwd(),`${t}.mjs`);if(!re(n))return e;try{const o=await xe(t,!1),s=ke(Ge,wt);s(o)||(e[t]=ut(s.errors??[]))}catch(o){e[t]=[{instancePath:"shared/translation.ts",message:`Failed to load translation file: ${o.message}`,keyword:"import"}]}return e}const Rs={"process.env":{NODE_ENV:"production"}},Ua=[...$n,...$n.map(e=>`node:${e}`)],za=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],Os=e=>({pluginType:Ee.Server,define:Rs,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...Ua,...za],inlineDynamicImports:!0,...e,outDir:e.outDir}),vs=e=>({pluginType:Ee.Client,define:Rs,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),tt=e=>({pluginType:Ee.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),Ka=e=>({pluginType:Ee.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),At=e=>({pluginType:Ee.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir}),Xa=()=>Ti({ext:".gz",algorithm:"gzip"}),Va="/* EXTERNAL_IMPORTS_START */",Wa="/* EXTERNAL_IMPORTS_END */",Ya=()=>({name:"external-imports-wrapper-plugin",enforce:"post",apply:"build",generateBundle(e,t){for(const n of Object.keys(t)){const o=t[n];if(o.type==="chunk"){const s=/import.*\?commonjs-external["'];/g,i=o.code.match(s);if(i!==null){const r=i.join(""),a=Va+r+Wa,c=o.code.replace(s,"");o.code=a+c}}}}}),Za=()=>({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})}}),Qa=()=>{const e=process.env.npm_lifecycle_event;return Ai({typescript:!0,vueTsc:!1,eslint:e==="test"?!1:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})},Ae={VUE:wi(),TS_CONFIG_PATHS:Ci(),CHECKER:Qa()};class $t{constructor(t){this.bits=t instanceof $t?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class it{constructor(t,n,o){this.start=t,this.end=n,this.original=o,this.intro="",this.outro="",this.content=o,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(t){this.outro+=t}appendRight(t){this.intro=this.intro+t}clone(){const t=new it(this.start,this.end,this.original);return t.intro=this.intro,t.outro=this.outro,t.content=this.content,t.storeName=this.storeName,t.edited=this.edited,t}contains(t){return this.start<t&&t<this.end}eachNext(t){let n=this;for(;n;)t(n),n=n.next}eachPrevious(t){let n=this;for(;n;)t(n),n=n.previous}edit(t,n,o){return this.content=t,o||(this.intro="",this.outro=""),this.storeName=n,this.edited=!0,this}prependLeft(t){this.outro=t+this.outro}prependRight(t){this.intro=t+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(t){const n=t-this.start,o=this.original.slice(0,n),s=this.original.slice(n);this.original=o;const i=new it(t,this.end,s);return i.outro=this.outro,this.outro="",this.end=t,this.edited?(i.edit("",!1),this.content=""):this.content=o,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 o=this.split(this.end-n.length);this.edited&&o.edit(n,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(t,""),this.outro.length)return!0}}function Ja(){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 ec=Ja();class tc{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Ri(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,"+ec(this.toString())}}function nc(e){const t=e.split(`
|
|
2
|
-
`)
|
|
3
|
-
`)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`?(s.line+=1,s.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0):(s.column+=1,this.generatedCodeColumn+=1,a=!1),r+=1}this.pending=null}advance(t){if(!t)return;const n=t.split(`
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`,lc=(e,t)=>{const n=e.split("?")[0],o=ii(n);return(o==="server.ts"||o==="client.ts")&&!t.includes(js)},xs=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=re(Ls)},transform(t,n){if(!e||!lc(n,t))return null;const o=n.split("?")[0],s=dn(o),i=ui(ri(s,Ls)),r=cc(i),a=new ln(t);return a.prepend(r),{code:a.toString()}}}},pc={[Ee.Server]:[Ae.VUE,Ae.TS_CONFIG_PATHS,Ya(),Xa(),xs()],[Ee.Client]:[Ae.VUE,Ae.TS_CONFIG_PATHS,Ae.CHECKER,En({vue:"EcVue"}),xs()],[Ee.Misc]:[Ae.TS_CONFIG_PATHS,Ae.CHECKER],[Ee.Layout]:[Ae.VUE,Ae.TS_CONFIG_PATHS,Ae.CHECKER,En({vue:["EcExternals","Vue"]})],[Ee.Asset]:[Za()],[Ee.SharedFiles]:[Ae.TS_CONFIG_PATHS]},uc={[Y.Server]:Os({outDir:({name:e,sectionType:t})=>`./${ce[t].dist}/${e}/js/main/server`}),[Y.Client]:vs({outDir:({name:e,sectionType:t})=>`./${ce[t].dist}/${e}/js/main/client`}),[Y.SectionSetting]:tt({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${ce[t].dist}/${e}/js/settings`}),[Y.SectionShowcase]:tt({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${ce[t].dist}/${e}/js/showcases`}),[Y.SectionAsset]:At({outDir:({name:e,sectionType:t})=>`./${ce[t].dist}/${e}/assets`}),[Y.TemplateDescriptor]:tt({entryFileNames:`[name]${je}.mjs`,outDir:()=>`./${Ce}/js`}),[Y.PageTemplateDescriptor]:tt({entryFileNames:`[name]${je}.mjs`,outDir:({name:e})=>`./${Ce}/${e}`}),[Y.TemplateAsset]:At({outDir:()=>`./${Ce}/assets`}),[Y.Layout]:Ka({outDir:({name:e,sectionId:t})=>`./${_e}/${t}/${e}`}),[Y.LayoutSettings]:tt({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${_e}/${t}/${e}/js/settings`}),[Y.LayoutAsset]:At({outDir:({name:e,sectionId:t})=>`./${_e}/${t}/${e}/assets`}),[Y.SlotServer]:Os({outDir:({name:e,layoutId:t,sectionId:n})=>`./${_e}/${n}/${t}/slots/${e}/js/main/server`}),[Y.SlotClient]:vs({outDir:({name:e,layoutId:t,sectionId:n})=>`./${_e}/${n}/${t}/slots/${e}/js/main/client`}),[Y.SharedTranslation]:{pluginType:Ee.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function fc(e){switch(typeof e){case"string":return[U(process.cwd(),e)];case"object":return e.map(t=>U(process.cwd(),t));default:return[]}}function Ns({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:s,sectionType:i=ue.SECTION}){const r=uc[n],a=r.define,c=r.ssrOptions,l=r.entryFileNames,f=r.chunkFileNames,E=r.assetFileNames,u=r.inlineDynamicImports,L=r.externalOption;return{plugins:pc[r.pluginType],ssr:c,define:a,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:r.ssr,outDir:r.outDir({name:e,sectionType:i,layoutId:o,sectionId:s}),emptyOutDir:!0,minify:"terser",terserOptions:{compress:{drop_console:!1,pure_getters:!0}},rollupOptions:{external:L,preserveEntrySignatures:"strict",input:fc(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:u,entryFileNames:l,chunkFileNames:f,assetFileNames:E}}},assetsInclude:["**/*.json"]}}async function dc(){const e={ignore:["node_modules/**","dist/**"]},t=await z(`./${Xe}/{product,category,catalog}/*/Main.vue`,e);return await Promise.all(t.map(async n=>{const{id:o,sectionId:s,pageId:i}=na(n),[r,a]=await Promise.all([z(`./${Xe}/${s}/${o}/settings/{content,design,translations}.{js,ts}`,e),z(`./${Xe}/${s}/${o}/assets/*`,e)]);return{name:o,sectionId:s,pageId:i,clientEntrypoint:n,settingsEntryPoints:r,assetsEntrypoints:a}}))}async function hc(e){As(e.assetsEntrypoints),await ge({entryPoints:[e.clientEntrypoint],configType:Y.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([ge({entryPoints:e.settingsEntryPoints,configType:Y.LayoutSettings,name:e.name,sectionId:e.sectionId}),ge({entryPoints:e.assetsEntrypoints,configType:Y.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function mc(e){e===void 0||e.length===0||await Promise.all(e.map(t=>hc(t)))}async function yc(e){const t=yn(Ns({name:e.name,entryPoints:e.serverEntrypoint,configType:Y.Server,sectionType:e.type}));return As(e.assetEntryPoints),await qe({configFile:!1,...t}),await Cs(K.Server,{sectionId:e.name,sectionType:e.type}),await Promise.all([ge({entryPoints:e.clientEntrypoint,configType:Y.Client,name:e.name,sectionType:e.type}),ge({entryPoints:e.settingsEntryPoints,configType:Y.SectionSetting,name:e.name,sectionType:e.type}),ge({entryPoints:e.showcaseEntryPoints,configType:Y.SectionShowcase,name:e.name,sectionType:e.type}),ge({entryPoints:e.assetEntryPoints,configType:Y.SectionAsset,name:e.name,sectionType:e.type})]),await Pa(e).reduce(async(n,o)=>{const s=await n,i=await Ma(o);return{...s,...i}},Promise.resolve({}))}async function gc(){const e=U(process.cwd(),"shared/translation.ts");re(e)&&await ge({entryPoints:["shared/translation.ts"],configType:Y.SharedTranslation})}async function $c(e){return e.reduce(async(t,n)=>{const o=await t,s=await yc(n);return{...o,...s}},Promise.resolve({}))}async function ve(e){return(await import(gn(e).href+`?t=${Date.now()}`)).default}function Rt(e,t){return Object.keys(e).reduce((n,o)=>{const s=e[o],i=t[o];return On(s)&&On(i)?n[o]=Rt(s,i):n[o]=s,n},{...t})}function Ec({contentSettings:e,sectionType:t}){const n=_s(t);return Rt(e,n)}function bc({designSettings:e,sectionType:t}){const n=Ss(t);return Rt(e,n)}function Ot(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function Re(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Oi(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Ps(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 _c(e){if(e!==void 0)return{...e,color:Re(e.color)}}function vt(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Sc(e){if(e!==void 0)switch(e){case Tt.COLOR:return"solid";case Tt.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(Tt)}`)}}function Tc({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:Sc(e),solid:{color:Re(n.at(0))},gradient:{fromColor:Re(n.at(0)),toColor:Re(n.at(1))}}}}function wc(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(di)}`)}}function Cc(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(hi)}`)}}function Ac(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(mi)}`)}}function Rc(e){const t=wc(e.appearance),n=Cc(e.size),o=Ac(e.shape),s=Ot(e.font),i=Re(e.color),r=e.visible;return vt({appearance:t,size:n,style:o,font:s,color:i,visible:r})}function Oc(e){const t=Re(e.color);return vt({color:t})}function vc(e){if(e!==void 0)switch(e){case lt.COLOR:return"solid";case lt.GRADIENT:return"gradient";case lt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(lt)}`)}}function Ic(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:vc(e.overlay),solid:{color:Re(n.at(0))},gradient:{fromColor:Re(n.at(0)),toColor:Re(n.at(1))}}}}function Lc(e){const t=Ot(e.font),n=Re(e.color),o=Ps(e.size);return{font:t,color:n,size:o,frame:_c(e.frame)}}function jc(e){const t=Ot(e.font),n=Re(e.color),o=Ps(e.size);return vt({font:t,color:n,size:o})}function It(e,t){if(t.defaults===void 0)return;let n={};switch(e){case Pe.TEXT:{n=jc(t.defaults);break}case Pe.BUTTON:{n=Rc(t.defaults);break}case Pe.IMAGE:{n=Ic(t.defaults);break}case Pe.BACKGROUND:{n=Tc(t.defaults);break}case Pe.COLOR_PICKER:{n=Oc(t.defaults);break}case Pe.LOGO:{n=Lc(t.defaults);break}case Pe.TOGGLE:case Pe.SELECTBOX:break;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function xc(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],s=o.type,i=It(s,o);i&&o.defaults?t[n]={...o,defaults:i}:t[n]=o}),t}function Nc(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...It(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Lt(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const o=e[n],s=o.type,i=It(s,{defaults:o});i!==void 0?t[n]={...o,...i}:t[n]=o}),t}function Pc(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Dc(e){const t={};for(const n in e){const o=e[n];for(const s in o){const i=t[s],r=o[s];if(i===void 0){const a={};a[n]=r,t[s]=a}else i[n]=r}}return t}function kc(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function Be(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return kc(e)?e:e.map(s=>Be(s,t));const n=e,o={};for(const s in n){const i=n[s];typeof i=="string"&&i.startsWith("$")?o[s]=Pc(t,i):typeof i=="object"&&i!==null?o[s]=Be(i,t):o[s]=i}return o}async function ft(e){return e?Dc(e):{}}async function Fc(e,t=le){const n=U(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await ve(n)}async function ot(e,t=le){const n=U(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await ve(n)}async function Hc(e,t){const n=U(process.cwd(),`${_e}/${t}/${e}/js/settings/translations.mjs`);return await ve(n)}async function Ds(e,t,n){const o=n?Ec({contentSettings:e,sectionType:n}):e;return Be(o,t)}async function Mc(e,t=le){try{const n=U(ie.cwd(),`${t}/${e}/js/settings/content.mjs`);return await ve(n)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Gc(e,t,n=le){const o=await Mc(e,n);return await Ds(o,t,De(e))}async function ks(e,t,n){const o=n?bc({designSettings:e,sectionType:n}):e,s=xc(o);return Be(s,t)}async function Bc(e,t=le){try{const n=U(ie.cwd(),`${t}/${e}/js/settings/design.mjs`);return await ve(n)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function qc(e,t,n=le){const o=await Bc(e,n);return ks(o,t,De(e))}async function Uc(e,t){return Promise.all(e.map(async n=>{const o=n.design?Lt(n.design):void 0,s={...n,design:o??n.design};return Be(s,t)}))}async function zc(e,t=le){try{const n=await z("*.mjs",{cwd:U(ie.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async o=>{const s=U(ie.cwd(),`${t}/${e}/js/showcases/${o}`);return await ve(s)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Kc(e,t,n=le){const o=await zc(e,n);return Uc(o,t)}async function Xc(e){return e?.map(t=>({...t,selectedDesignSettings:Nc(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function Vc(e,t=le){try{const n=U(ie.cwd(),`${t}/${e}/js/settings/layout.mjs`);return re(n)?await ve(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function Wc(e,t=le){const n=await Vc(e,t);return await Xc(n)}function Yc(e){let t={};const n=U(ie.cwd(),`${Cn}/shared/analytics.json`);if(!re(n))return 0;try{const o=oi(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}function Zc(){try{const e=U(ie.cwd(),`${Cn}/shared/analytics.json`);re(e)&&fn(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}async function dt(e,t){const n=await Fc(e,ce[t].dist),o=await ft(n),s=await ot(e,ce[t].dist),i=await ft(s),r=await Gc(e,o,ce[t].dist),a=await qc(e,o,ce[t].dist),c=await Kc(e,i,ce[t].dist),l=await Wc(e,ce[t].dist),f=Yc(e);return{id:e,type:t,name:{en:e},contentEditors:r,designEditors:a,layouts:l,showcases:c,previewCount:f}}async function Qc(){const e=await z("*/",{cwd:U(ie.cwd(),`${le}/`)}),t=await z("*/",{cwd:U(ie.cwd(),`${ze}/`)}),n=await z("*/",{cwd:U(ie.cwd(),`${Ke}/`)});return Promise.all([...e.map(async o=>dt(o,ue.SECTION)),...t.map(async o=>dt(o,ue.HEADER)),...n.map(async o=>dt(o,ue.FOOTER))])}async function Jc(e){if(!e||e.type!=="custom")return;const t=De(e.id),n=await ot(e.id,ce[t].dist);e.showcase_overrides!==void 0&&(Be(e.showcase_overrides,n),e.showcase_overrides.design&&Lt(e.showcase_overrides.design))}async function el(e){const t=e.filter(n=>n.type==="custom");await Promise.all(t.map(n=>Jc(n)))}function tl(e){const t=Je(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,s]=t;if(!wn(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:s,sectionId:n,layoutId:o}}async function nl(e){return Promise.all(e.map(async t=>{const n=await ft(t.translationsSettings),o=await Ds(t.content,n),s=await ks(t.design,n);return{id:t.id,sectionId:t.sectionId,layoutId:t.layoutId,contentEditors:o,designEditors:s}}))}async function ol(e,t){try{const n=Oe.resolve(process.cwd(),`${_e}/${t}/${e}/js/settings/content.mjs`);return await ve(n)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function sl(e,t){try{const n=Oe.resolve(process.cwd(),`${_e}/${t}/${e}/js/settings/design.mjs`);return await ve(n)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function rl(e){const t=Je(e).split("/"),[n,o,,s]=t,i=await Hc(o,n),r=await ol(o,n),a=await sl(o,n);return{id:s,sectionId:n,layoutId:o,content:r,design:a,translationsSettings:i}}async function il(){const e=`${_e}/{product,catalog,category}/*/slots/*`,t=await z(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(rl))}async function al(){const e=await il();return await nl(e)}async function cl(){const e={ignore:["node_modules/**","dist/**"]},t=await z(`${Xe}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:o,sectionId:s,layoutId:i}=tl(n),r=(await z(`${Xe}/${s}/${i}/slots/${o}/client.{js,ts}`,e))[0];if(r===void 0)throw new Error(`Cannot find client entrypoint file for slot ${o} of section ${s}`);return{id:o,sectionId:s,layoutId:i,serverEntrypoint:n,clientEntrypoint:r}}))}async function ll(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await ge({entryPoints:[e.serverEntrypoint],configType:Y.SlotServer,...t}),await Cs(K.SlotServer,{slotId:e.id,layoutId:e.layoutId,sectionId:e.sectionId}),await ge({entryPoints:[e.clientEntrypoint],configType:Y.SlotClient,...t})}async function pl(e){e===void 0||e.length===0||await e.reduce(async(t,n)=>{await t,await ll(n)},Promise.resolve())}const Fs="https://json-schema.org/draft/2020-12/schema",Hs="https://lightspeedhq.com/metadata.schema.json",Ms="Custom Multi Page Template metadata",Gs="Metadata of a multi page template",Bs="object",qs={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},preview_url:{description:"Preview url of the demo website",type:"string",format:"uri",pattern:"^(https?)://([^.]+?\\.)company\\.site($|/[A-Za-z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=]*)?$"},cover_image:{type:"object",properties:{set:{description:"Name of the image set",type:"object",patternProperties:{".*":{type:"object",properties:{url:{description:"Path to the preview image relative to the 'assets' folder for a specific resolution",type:"string"}},required:["url"],additionalProperties:!1}}}},required:["set"],additionalProperties:!1},categories:{description:"List of template categories for Template Market filtering",type:"array",items:{type:"string",enum:["apparel_footwear","vape_smoke","home_garden","sport_outdoor","jewelry_accessories","pet_animals","bikes","health_beauty","gift_shop","electronics","other"]},uniqueItems:!0}},required:["name","description","cover_image"],additionalProperties:!1},header:{$ref:"./header_footer.schema.json"},footer:{$ref:"./header_footer.schema.json"}},Us=["metadata","header","footer"],zs=!1,ul={$schema:Fs,$id:Hs,title:Ms,description:Gs,type:Bs,properties:qs,required:Us,additionalProperties:zs},fl={__proto__:null,$id:Hs,$schema:Fs,additionalProperties:zs,default:ul,description:Gs,properties:qs,required:Us,title:Ms,type:Bs},Ks="https://json-schema.org/draft/2020-12/schema",Xs="https://lightspeedhq.com/header_footer.schema.json",Vs="Header/Footer definition for a page template",Ws="object",Ys=["type","id"],Zs={type:{type:"string",enum:["custom","default"]},id:{type:"string"},showcase_id:{type:"string"},showcase_overrides:{$ref:"../showcase_overrides.schema.json"}},Qs=!1,Js=[{if:{properties:{type:{const:"default"}}},then:{properties:{id:{enum:["header","footer"]}}}},{if:{properties:{type:{const:"custom"}}},then:{properties:{showcase_id:{type:"string"},showcase_overrides:{$ref:"../showcase_overrides.schema.json"}}}}],dl={$schema:Ks,$id:Xs,title:Vs,type:Ws,required:Ys,properties:Zs,additionalProperties:Qs,allOf:Js},hl={__proto__:null,$id:Xs,$schema:Ks,additionalProperties:Qs,allOf:Js,default:dl,properties:Zs,required:Ys,title:Vs,type:Ws},er="https://json-schema.org/draft/2020-12/schema",tr="https://lightspeedhq.com/page.schema.json",nr="Homepage",or="Homepage enclosing the necessary custom and default blocks",sr="object",rr={sections:{description:"List of sections contained by this page",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"custom"}}},then:{$ref:"../template-custom.schema.json#/$defs/custom-section"}},{if:{properties:{type:{const:"default"}}},then:{$ref:"../template-default.schema.json#/$defs/default-section"}},{not:{properties:{id:{enum:["header","footer"]}},required:["id"]}}]},minItems:1,uniqueItems:!1}},ir=!1,ar=["sections"],ml={$schema:er,$id:tr,title:nr,description:or,type:sr,properties:rr,additionalProperties:ir,required:ar},yl={__proto__:null,$id:tr,$schema:er,additionalProperties:ir,default:ml,description:or,properties:rr,required:ar,title:nr,type:sr},cr="https://json-schema.org/draft/2020-12/schema",lr="https://lightspeedhq.com/page.schema.json",pr="Custom Page",ur="A custom page enclosing the necessary custom and default blocks",fr="object",dr={sections:{description:"List of sections contained by this page",type:"array",minItems:1,maxItems:1,uniqueItems:!1,contains:{type:"object",properties:{type:{const:"store"}},required:["type"]},items:{type:"object",required:["type"],allOf:[{if:{properties:{type:{const:"store"}}},then:{$ref:"./store-section.schema.json"},else:{properties:{type:{description:"Type of the section",type:"string"},id:{description:"Unique identifier for the section",type:"string"}},required:["type","id"]}}]}}},hr=!1,mr=["sections"],gl={$schema:cr,$id:lr,title:pr,description:ur,type:fr,properties:dr,additionalProperties:hr,required:mr},jt={__proto__:null,$id:lr,$schema:cr,additionalProperties:hr,default:gl,description:ur,properties:dr,required:mr,title:pr,type:fr},yr="https://json-schema.org/draft/2020-12/schema",gr="https://lightspeedhq.com/page.schema.json",$r="Custom page",Er="Custom page enclosing the necessary custom and default blocks",br="object",_r={metadata:{description:"Metadata of custom page",type:"object",properties:{title:{type:"string",description:"Title of the custom page"}},required:["title"],additionalProperties:!1},sections:{description:"List of sections contained by this page",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"custom"}}},then:{$ref:"../template-custom.schema.json#/$defs/custom-section"}},{if:{properties:{type:{const:"default"}}},then:{$ref:"../template-default.schema.json#/$defs/default-section"}},{not:{properties:{id:{enum:["header","footer"]}},required:["id"]}}]},minItems:0,uniqueItems:!1}},Sr=!1,Tr=["sections"],$l={$schema:yr,$id:gr,title:$r,description:Er,type:br,properties:_r,additionalProperties:Sr,required:Tr},El={__proto__:null,$id:gr,$schema:yr,additionalProperties:Sr,default:$l,description:Er,properties:_r,required:Tr,title:$r,type:br},wr="https://json-schema.org/draft/2020-12/schema",Cr="https://lightspeedhq.com/store-section.schema.json",Ar="Store Section",Rr="Store section for a custom page",Or="object",vr=[{type:"object",properties:{type:{description:"Type of the section",type:"string",const:"store"},id:{description:"Layout identifier of the section. When not provided, the section will use the default layout.",type:"string"}},required:["type"],additionalProperties:!1}],bl={$schema:wr,$id:Cr,title:Ar,description:Rr,type:Or,allOf:vr},_l={__proto__:null,$id:Cr,$schema:wr,allOf:vr,default:bl,description:Rr,title:Ar,type:Or};function Sl(e){switch(e){case be.PRODUCT:return"product";case be.CATALOG:return"catalog";case be.CATEGORY:return"category";default:return null}}const Tl=[Uo,Dn,qn,ds,oo,Yn,_l,hl,bs],wl=e=>{const t=[],n={},o=(s,i,r,a)=>{if(!s){n[e.name]||(n[e.name]=[]),n[e.name].push({instancePath:`/templates/${e.name}/${i}`,message:`Missing file: ${i}`,keyword:"required"});return}t.push({templateName:e.name,source:s,dist:W.resolve(`dist/templates/${e.name}/${i}`),ajv:ke(Tl,r),templatePageType:a})};return o(e.catalogEntrypoint,"catalog",jt,be.CATALOG),o(e.productEntrypoint,"product",jt,be.PRODUCT),o(e.homeEntrypoint,"home",yl,be.HOME),o(e.categoryEntrypoint,"category",jt,be.CATEGORY),o(e.configurationEntrypoint,"configuration",fl,be.CUSTOM),e.customEntrypoint?.forEach(s=>{o(s,He(s).name,El,be.CUSTOM)}),[t,n]};function Cl({section:e,context:t,normalizedPaths:n}){const o=Sl(t.templatePageType);if(o===null)return{instancePath:`/sections/${e.id}/id`,message:`Source folder not found for template page type "${t.templatePageType}".`,keyword:"source_folder_not_found"};const s=`${o}/${e.id}`;return n.some(i=>i.startsWith(s))?null:{instancePath:`/sections/${e.id}/id`,message:`Source layout for section "${e.id}" not found in "layouts/${o}/${e.id}".`,keyword:"layout_not_found"}}function Al(e){const{type:t,id:n}=e;return t==="store"&&n!==void 0&&n!==""}async function Rl({content:e,context:t,layoutBuildConfigs:n}){const o=n.map(s=>Je(s.clientEntrypoint));return e.sections.filter(Al).map(s=>Cl({section:s,context:t,normalizedPaths:o})).filter(s=>s!==null)}function Ol(e){return"sections"in e}async function vl(e,t){const n=await xe(e.dist,!0),o={},s=[];if(e.ajv(n)?pn(`${e.dist}${je}.mjs`,`${e.dist}.mjs`,()=>{}):(s.push(...ut(e.ajv.errors??[])),un(`${e.dist}${je}.mjs`,()=>{})),Ol(n)&&t!==void 0){const i=await Rl({content:n,context:e,layoutBuildConfigs:t});s.push(...i)}return s.length>0&&(o[e.source]=s),o}const Il=async(e,t)=>{const[n,o]=wl(e);return(await Promise.all(n.map(s=>vl(s,t)))).reduce((s,i)=>(Object.entries(i).forEach(([r,a])=>{s[r]=s[r]?[...s[r],...a]:[...a]}),s),{...o})};async function Ll(e,t,n,o=le){if(t.showcase_overrides?.content!==void 0)if(!re(`${o}/${t.id}/js/settings/content.mjs`))e.push({instancePath:`/sections/${n}/showcase_overrides/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder",keyword:"required"});else{const s=await xe(`${o}/${t.id}/js/settings/content`,!1),i=new Set(Object.keys(s));Object.keys(t.showcase_overrides.content).every(r=>i.has(r))||e.push({instancePath:`/sections/${n}/showcase_overrides/content`,message:"Content descriptor must be a subset of the default content descriptor",keyword:"type"})}}async function jl(e,t,n,o=le){if(t.showcase_overrides?.design!==void 0)if(!re(`${o}/${t.id}/js/settings/design.mjs`))e.push({instancePath:`/sections/${n}/showcase_overrides/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder",keyword:"required"});else{const s=await xe(`${o}/${t.id}/js/settings/design`,!1),i=new Set(Object.keys(s));Object.keys(t.showcase_overrides.design).every(r=>i.has(r))||e.push({instancePath:`/sections/${n}/showcase_overrides/design`,message:"Design descriptor must be a subset of the default design descriptor",keyword:"type"})}}async function xl(e,t,n,o=le){if(t.showcase_overrides?.layoutId!==void 0)if(!re(`${o}/${t.id}/js/settings/layout.mjs`))e.push({instancePath:`/sections/${n}/showcase_overrides/layout`,message:"Layout id descriptor is set, please provide a default descriptor in the block's settings folder",keyword:"required"});else{const s=await xe(`${o}/${t.id}/js/settings/layout`,!1);new Set(s.map(i=>i.layoutId)).has(t.showcase_overrides.layoutId)||e.push({instancePath:`/sections/${n}/showcase_overrides/layout`,message:"Layout id descriptor must be a valid id in the default layout descriptor",keyword:"type"})}}async function xt(e,t,n,o=le){t.showcase_overrides!==void 0&&(await Ll(e,t,n,o),await jl(e,t,n,o),await xl(e,t,n,o))}function Nt(e,t,n,o=le){t.showcase_id!==void 0&&(re(`${o}/${t.id}/js/showcases/${t.showcase_id}.mjs`)||e.push({instancePath:`/sections/${n}/showcase-id`,message:"Custom section must have a corresponding showcase defined in case showcase_id is specified",keyword:"required"}))}async function Nl(e,t){const n=t.id==="header"&&t.type==="default",o=re(`${ze}/${t.id}`);!n&&!o&&e.push({instancePath:"/sections/0/id",message:"The first section must be a `header`",keyword:"required"}),o&&(await xt(e,t,0,ze),Nt(e,t,0,ze))}async function Pl(e,t,n){const o=t.id==="footer"&&t.type==="default",s=re(`${Ke}/${t.id}`);!o&&!s&&e.push({instancePath:`/sections/${n}/id`,message:"The last section must be a `footer`",keyword:"required"}),s&&(await xt(e,t,n,Ke),Nt(e,t,n,Ke))}async function Dl(e,t){t.showcase_overrides&&e.push(...ws(`sections/${t.id}`,t.showcase_overrides))}async function kl(e){const t=await e.sections.reduce(async(n,o,s)=>{const i=await n;return s===0?await Nl(i,o):s===e.sections.length-1?await Pl(i,o,e.sections.length-1):o.type==="custom"?re(`${le}/${o.id}`)?(await xt(i,o,s),Nt(i,o,s),await Dl(i,o)):i.push({instancePath:`/sections/${s}/id`,message:"Custom section must have a corresponding block defined",keyword:"required"}):o.type==="default"&&(o.id==="header"&&i.push({instancePath:`/sections/${s}/id`,message:"Header can only be placed as the first section",keyword:"required"}),o.id==="footer"&&i.push({instancePath:`/sections/${s}/id`,message:"Footer can only be placed as the last section",keyword:"required"})),i},Promise.resolve([]));return t.length>0?t:void 0}async function Fl(e){return(await z(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=He(t).name.toLowerCase();return!Object.values(yi).includes(n)})}async function Hl(){const e=await z("./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(hn),o=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const s=await z(`**/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await z(`**/${o}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await z(`**/${o}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await z(`**/${o}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await z(`**/${o}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),l=await Fl(o);return{name:o,configurationEntrypoint:s.at(0),homeEntrypoint:i.at(0),categoryEntrypoint:r.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:l.length>0?l:void 0}}))}async function Ml(){const e=await z("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await z("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Hl(),templates:e,assets:t}}async function Gl(e){if(e.templates.length===0&&e.pageTemplates?.length===0)return{};const t=Na();return await Promise.all([ge({entryPoints:e.assets,configType:Y.TemplateAsset}),ge({entryPoints:e.templates,configType:Y.TemplateDescriptor})]),e.templates.reduce(async(n,o)=>{const s=await n,i=`${Ce}/js/${He(o).name}`,r=await xe(i,!0);return{...s,...Ba(t,r,i,await kl(r))}},Promise.resolve({}))}async function Bl({templateBuildConfig:e,layoutBuildConfigs:t}){return e.pageTemplates?.reduce(async(n,o)=>{const s=await n,i=[o.configurationEntrypoint,o.homeEntrypoint,o.categoryEntrypoint,o.catalogEntrypoint,o.productEntrypoint,...o.customEntrypoint??[]].filter(pt);if(i.length===0)throw new Error("No entry points provided for page template");return await ge({entryPoints:i,configType:Y.PageTemplateDescriptor,name:o.name}),{...s,...await Il(o,t)}},Promise.resolve({}))??{}}async function ql(e){const t=await Ml(),n=await Promise.all([Gl(t),Bl({templateBuildConfig:t,layoutBuildConfigs:e})]);return n.some(o=>!vn(o))?n.reduce((o,s)=>({...o,...s}),{}):{}}function Ul(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(pt).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(pt),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(pt),assetEntryPoints:e.assetsEntrypoints??[]}}function zl(e){return Object.entries(ce).find(t=>t[1].source===e)?.[0]}async function Kl(){const e=await z("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**"]});return Promise.all(e.map(async t=>{const n=dn(t).split(hn),o=n.pop()??"default",s=n.pop();if(s===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const i=await z(`**/${o}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await z(`**/${o}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await z(`**/${o}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await z(`**/${o}/settings/layout.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),l=await z(`**/${o}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),f=await z(`**/${o}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**",`**/${o}/showcases/translations.{js,ts}`]}),E=await z(`**/${o}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await z(`**/${o}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:o,type:zl(s),serverEntrypoint:t,clientEntrypoint:i.at(0),contentSettingsEntrypoint:r.at(0),designSettingsEntrypoint:a.at(0),layoutSettingsEntrypoint:c.at(0),settingsTranslationsEntrypoint:l.at(0),showcasesEntrypoints:f,showcasesTranslationsEntrypoint:E.at(0),assetsEntrypoints:u}}))}function Xl(){return Promise.all([_t.rm("dist",{recursive:!0,force:!0}),_t.rm("source-code",{recursive:!0,force:!0}),_t.rm("source-code.zip",{force:!0})])}async function Vl(){const e=new pi,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"],n=await z("**/*",{cwd:U(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(i=>{const r=U(process.cwd(),i);e.addLocalFile(r,He(i).dir)});const o=We[K.SourceCode].fileName,s=U(process.cwd(),o);await e.writeZipPromise(s)}catch(o){throw I.error("Error while zipping source files"),o}}async function Pt(e=!1){await Xl();try{const[t,n,o]=await Promise.all([dc(),Kl(),cl()]),s=n.map(Ul);await gc();const i={...await qa(),...await $c(s),...await ql(t)};Object.keys(i).length===0?(await Promise.all([pl(o),mc(t),Vl()]),I.info(`Build successful:
|
|
1
|
+
import*as tn from"fs";import re,{existsSync as Ce,writeFileSync as ao,readFileSync as ta,createReadStream as na,statSync as Ft,promises as Un,mkdtempSync as ra,mkdirSync as oa,rmSync as co}from"fs";import*as nt from"path";import ue,{resolve as M,dirname as uo,relative as lo,basename as ia,sep as Fn,parse as po,join as dt}from"path";import sa from"cac";import{red as aa,yellow as ca,green as Ze,gray as ua}from"kolorist";import zt from"prompts";import fo from"adm-zip";import{glob as F,globSync as ho}from"glob";import Ve from"typescript";import{normalizePath as la,build as rt,defineConfig as nn,createServer as pa}from"vite";import{SectionTypeEnum as ve,BackgroundStyleEnum as zn,ButtonAppearanceEnum as da,ButtonSizeEnum as fa,ButtonShapeEnum as ha,OverlayTypeEnum as rn,DesignEditorType as Xe,PluginTypeEnum as Ue,ConfigTypeEnum as le}from"@lightspeed/crane-api";import{readFile as mo}from"fs/promises";import{pathToFileURL as ma,URL as Ea}from"url";import Gn,{AxiosError as Eo}from"axios";import*as ae from"process";import{ConcurrencyManager as ga}from"axios-concurrency";import{inc as _a}from"semver";import{JSONPath as ya}from"jsonpath-plus";import Sa from"tinycolor2";import Ta from"cli-progress";import{builtinModules as go}from"module";import{viteExternalsPlugin as _o}from"vite-plugin-externals";import Ra from"vite-plugin-compression";import wa from"@vitejs/plugin-vue";import Ca from"vite-tsconfig-paths";import va from"vite-plugin-checker";import{encode as Aa}from"@jridgewell/sourcemap-codec";import{promisify as yo}from"node:util";import So from"node:zlib";import fe from"node:fs";import Ne from"node:path";import Te from"node:process";import To from"util";import{fileURLToPath as Ia}from"node:url";import{WebSocketServer as Oa,WebSocket as ba}from"ws";import*as $a from"os";const La="3.0.0",se={[ve.SECTION]:{source:"sections",dist:"dist/sections"},[ve.HEADER]:{source:"headers",dist:"dist/headers"},[ve.FOOTER]:{source:"footers",dist:"dist/footers"}};var J=(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))(J||{});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},Hn="https://blockbuster.ecwid.com",Na="/api/v1/custom-apps/resources/sections/upload",Da="/api/v1/custom-apps/resources/templates/upload",ka="/api/v1/custom-apps/manifests/sections",xa="/api/v1/custom-apps/manifests/templates",Pa=5,Ma=3,Ua=[J.Server,J.Client,J.ClientChunks,J.ClientAsset,J.Asset],Fa=[J.LayoutClient,J.LayoutAsset],za=[J.SlotServer,J.SlotClient,J.SlotClientChunks,J.SlotClientAsset],Ga=[J.Dependency,J.TemplateAsset,J.SourceCode,J.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.`},Ro={catalog:"products",category:"category",product:"product"},Ha=e=>Ro[e],wo=e=>e in Ro,L={error:e=>console.log(aa(e)),warn:e=>console.log(ca(e)),info:e=>console.log(Ze(e))},ja="dist",Ba="dist/shared",Oe="dist/sections",Gt="dist/headers",Ht="dist/footers",Fe="dist/templates",Rt="layouts",Co="preview",Ae=`dist/${Rt}`,on="dist/collections",Za=[Oe,Gt,Ht,Fe,Ae];function sn(e){return!!e}function ft(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Va="Resource name can only contain alphanumeric characters, dashes, and underscores";function Wa(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:Va}}function Ka(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function vo(e){return ue.parse(e).name}function Ya(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function an(){const e=await mo(M(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function Xa(e){return e.includes(`
|
|
2
|
+
`)}function Qa(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 Eo){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const s=e.response?.data;if(s?.errorCode&&n.push(` Error Code: ${s.errorCode}`),s?.errorMessage){const i=Xa(s.errorMessage)?Qa(s.errorMessage," ",1):s.errorMessage;n.push(` Error Message: ${i}`)}}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 qa(e){return e.replace(/\\/g,"/")}function Ja(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function wt(e){return Ja(qa(e))}function ec(e){const t=wt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t;if(!wo(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const o=Ha(n);return{id:r,sectionId:n,pageId:o}}const tc={catalog:"products",category:"category",product:"product"};async function nc(e){const t=wt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t;return{id:r,sectionId:n}}async function rc(e){return Promise.all(e.map(async t=>{const n=t.sectionId,r=tc[n];return{id:t.id,sectionId:n,pageId:r}}))}async function oc(){const e=`${Ae}/{product,catalog,category}/*`,t=await F(e,{ignore:["node_modules/**"]});return Promise.all(t.map(nc))}async function ic(){const e=await oc();return await rc(e)}function Ct(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${Ae}/${e}/${t}/${n.join("/")}`}const jt=(e=ve.SECTION)=>se[e].dist,Bt={[J.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${jt(t)}/${e}/js/main/server/`},[J.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${jt(t)}/${e}/js/main/client/`},[J.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${jt(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[J.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${jt(t)}/${e}/js/main/client/assets/`},[J.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${jt(t)}/${e}/assets/`},[J.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Fe}/assets/`},[J.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[J.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[J.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>Ct(e,t,"")},[J.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Ct(e,t,"assets/")},[J.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ct(e,t,"slots",n,"js/main/server/")},[J.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ct(e,t,"slots",n,"js/main/client/")},[J.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ct(e,t,"slots",n,"js/main/client/chunks/")},[J.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ct(e,t,"slots",n,"js/main/client/assets/")},[J.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${on}/assets/`}};function Zt(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 s=r.cards;s.defaultCardContent?.settings&&(o={...o,cards:{...s,defaultCardContent:{...s.defaultCardContent,settings:Zt(s.defaultCardContent.settings)}}})}if(o.defaults&&typeof o.defaults=="object"&&!("type"in o.defaults)){const s=Object.assign({type:o.type},o.defaults);o={...o,defaults:s}}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:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.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 s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class vt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ao extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const jn={};function ot(e){return e&&Object.assign(jn,e),jn}function sc(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 Bn(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 Zn(e){return e==null}function Vn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ac(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 s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Io=Symbol("evaluating");function ie(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Io)return r===void 0&&(r=Io,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 Oo(e){return JSON.stringify(e)}function cc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const bo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const uc=cn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function At(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 $o(e){return At(e)?{...e}:Array.isArray(e)?[...e]:e}const lc=new Set(["string","number","symbol"]);function It(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 P(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 pc(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const dc={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 fc(e,t){const n=e._zod.def,r=Et(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return mt(this,"shape",o),o},checks:[]});return ct(e,r)}function hc(e,t){const n=e._zod.def,r=Et(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return mt(this,"shape",o),o},checks:[]});return ct(e,r)}function mc(e,t){if(!At(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 s={...e._zod.def.shape,...t};return mt(this,"shape",s),s},checks:[]});return ct(e,o)}function Ec(e,t){if(!At(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 gc(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 _c(e,t,n){const r=Et(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return mt(this,"shape",s),s},checks:[]});return ct(t,r)}function yc(e,t,n){const r=Et(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return mt(this,"shape",s),s},checks:[]});return ct(t,r)}function Ot(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 bt(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 Wn(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,Bn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},No=f("$ZodError",Lo),Do=f("$ZodError",Lo,{Parent:Error});function Sc(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 Tc(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return r(e),n}const Kn=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new vt;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>ut(c,s,ot())));throw bo(a,o?.callee),a}return i.value},Yn=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>ut(c,s,ot())));throw bo(a,o?.callee),a}return i.value},ln=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new vt;return s.issues.length?{success:!1,error:new(e??No)(s.issues.map(i=>ut(i,o,ot())))}:{success:!0,data:s.value}},Rc=ln(Do),pn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>ut(i,o,ot())))}:{success:!0,data:s.value}},wc=pn(Do),Cc=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Kn(e)(t,n,o)},vc=e=>(t,n,r)=>Kn(e)(t,n,r),Ac=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Yn(e)(t,n,o)},Ic=e=>async(t,n,r)=>Yn(e)(t,n,r),Oc=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ln(e)(t,n,o)},bc=e=>(t,n,r)=>ln(e)(t,n,r),$c=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return pn(e)(t,n,o)},Lc=e=>async(t,n,r)=>pn(e)(t,n,r),Nc=/^[cC][^\s-]{8,}$/,Dc=/^[0-9a-z]+$/,kc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xc=/^[0-9a-vA-V]{20}$/,Pc=/^[A-Za-z0-9]{27}$/,Mc=/^[a-zA-Z0-9_-]{21}$/,Uc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fc=/^([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})$/,ko=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)$/,zc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Hc(){return new RegExp(Gc,"u")}const jc=/^(?:(?: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])$/,Bc=/^(([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}|:))$/,Zc=/^((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])$/,Vc=/^(([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])$/,Wc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xo=/^[A-Za-z0-9_-]*$/,Kc=/^\+(?:[0-9]){6,14}[0-9]$/,Po="(?:(?:\\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])))",Yc=new RegExp(`^${Po}$`);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 Xc(e){return new RegExp(`^${Mo(e)}$`)}function Qc(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(`^${Po}T(?:${r})$`)}const qc=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Jc=/^-?\d+$/,eu=/^-?\d+(?:\.\d+)?/,tu=/^(?:true|false)$/i,nu=/^[^A-Z]*$/,ru=/^[^a-z]*$/,De=f("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Uo={number:"number",bigint:"bigint",object:"date"},Fo=f("$ZodCheckLessThan",(e,t)=>{De.init(e,t);const n=Uo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(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})}}),zo=f("$ZodCheckGreaterThan",(e,t)=>{De.init(e,t);const n=Uo[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(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})}}),ou=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):ac(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})}}),iu=f("$ZodCheckNumberFormat",(e,t)=>{De.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=dc[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=Jc)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}}),su=f("$ZodCheckMaxLength",(e,t)=>{var n;De.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Zn(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 i=Wn(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),au=f("$ZodCheckMinLength",(e,t)=>{var n;De.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Zn(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 i=Wn(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),cu=f("$ZodCheckLengthEquals",(e,t)=>{var n;De.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Zn(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,s=o.length;if(s===t.length)return;const i=Wn(o),a=s>t.length;r.issues.push({origin:i,...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 s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=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=()=>{})}),uu=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})}}),lu=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=nu),dn.init(e,t)}),pu=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ru),dn.init(e,t)}),du=f("$ZodCheckIncludes",(e,t)=>{De.init(e,t);const n=It(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),fu=f("$ZodCheckStartsWith",(e,t)=>{De.init(e,t);const n=new RegExp(`^${It(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})}}),hu=f("$ZodCheckEndsWith",(e,t)=>{De.init(e,t);const n=new RegExp(`.*${It(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})}}),mu=f("$ZodCheckOverwrite",(e,t)=>{De.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Eu{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
|
+
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
8
|
+
`))}}const gu={major:4,minor:1,patch:13},he=f("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gu;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,a,c)=>{let u=Ot(i),l;for(const h of a){if(h._zod.def.when){if(!h._zod.def.when(i))continue}else if(u)continue;const d=i.issues.length,b=h._zod.check(i);if(b instanceof Promise&&c?.async===!1)throw new vt;if(l||b instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await b,i.issues.length!==d&&(u||(u=Ot(i,d)))});else{if(i.issues.length===d)continue;u||(u=Ot(i,d))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(Ot(i))return i.aborted=!0,i;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new vt;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new vt;return c.then(u=>o(u,r,a))}return o(c,r,a)}}e["~standard"]={validate:o=>{try{const s=Rc(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return wc(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Xn=f("$ZodString",(e,t)=>{he.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??qc(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}}),pe=f("$ZodStringFormat",(e,t)=>{dn.init(e,t),Xn.init(e,t)}),_u=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fc),pe.init(e,t)}),yu=f("$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=ko(r))}else t.pattern??(t.pattern=ko());pe.init(e,t)}),Su=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=zc),pe.init(e,t)}),Tu=f("$ZodURL",(e,t)=>{pe.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})}}}),Ru=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Hc()),pe.init(e,t)}),wu=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Mc),pe.init(e,t)}),Cu=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Nc),pe.init(e,t)}),vu=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dc),pe.init(e,t)}),Au=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=kc),pe.init(e,t)}),Iu=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xc),pe.init(e,t)}),Ou=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Pc),pe.init(e,t)}),bu=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Qc(t)),pe.init(e,t)}),$u=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Yc),pe.init(e,t)}),Lu=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Xc(t)),pe.init(e,t)}),Nu=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Uc),pe.init(e,t)}),Du=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jc),pe.init(e,t),e._zod.bag.format="ipv4"}),ku=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Bc),pe.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})}}}),xu=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Zc),pe.init(e,t)}),Pu=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Vc),pe.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Go(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Mu=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Wc),pe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Go(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Uu(e){if(!xo.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Go(n)}const Fu=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xo),pe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Uu(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),zu=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Kc),pe.init(e,t)});function Gu(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 Hu=f("$ZodJWT",(e,t)=>{pe.init(e,t),e._zod.check=n=>{Gu(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ho=f("$ZodNumber",(e,t)=>{he.init(e,t),e._zod.pattern=e._zod.bag.pattern??eu,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 s=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,...s?{received:s}:{}}),n}}),ju=f("$ZodNumberFormat",(e,t)=>{iu.init(e,t),Ho.init(e,t)}),Bu=f("$ZodBoolean",(e,t)=>{he.init(e,t),e._zod.pattern=tu,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}}),Zu=f("$ZodUnknown",(e,t)=>{he.init(e,t),e._zod.parse=n=>n}),Vu=f("$ZodNever",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function jo(e,t,n){e.issues.length&&t.issues.push(...bt(n,e.issues)),t.value[n]=e.value}const Wu=f("$ZodArray",(e,t)=>{he.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 s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>jo(u,n,i))):jo(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function fn(e,t,n,r){e.issues.length&&t.issues.push(...bt(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Bo(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=pc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Zo(e,t,n,r,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type;for(const l in t){if(a.has(l))continue;if(u==="never"){i.push(l);continue}const h=c.run({value:t[l],issues:[]},r);h instanceof Promise?e.push(h.then(d=>fn(d,n,l,t))):fn(h,n,l,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Ku=f("$ZodObject",(e,t)=>{if(he.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=cn(()=>Bo(t));ie(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(const h of l.values)c[u].add(h)}}return c});const o=Vt,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=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 l=[],h=i.shape;for(const d of i.keys){const O=h[d]._zod.run({value:u[d],issues:[]},c);O instanceof Promise?l.push(O.then(Z=>fn(Z,a,d,u))):fn(O,a,d,u)}return s?Zo(l,u,a,c,r.value,e):l.length?Promise.all(l).then(()=>a):a}}),Yu=f("$ZodObjectJIT",(e,t)=>{Ku.init(e,t);const n=e._zod.parse,r=cn(()=>Bo(t)),o=d=>{const b=new Eu(["shape","payload","ctx"]),O=r.value,Z=p=>{const S=Oo(p);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};b.write("const input = payload.value;");const w=Object.create(null);let T=0;for(const p of O.keys)w[p]=`key_${T++}`;b.write("const newResult = {};");for(const p of O.keys){const S=w[p],m=Oo(p);b.write(`const ${S} = ${Z(p)};`),b.write(`
|
|
9
|
+
if (${S}.issues.length) {
|
|
10
|
+
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
11
|
+
...iss,
|
|
12
|
+
path: iss.path ? [${m}, ...iss.path] : [${m}]
|
|
13
|
+
})));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if (${S}.value === undefined) {
|
|
18
|
+
if (${m} in input) {
|
|
19
|
+
newResult[${m}] = undefined;
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
newResult[${m}] = ${S}.value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
`)}b.write("payload.value = newResult;"),b.write("return payload;");const D=b.compile();return(p,S)=>D(d,p,S)};let s;const i=Vt,a=!jn.jitless,u=a&&uc.value,l=t.catchall;let h;e._zod.parse=(d,b)=>{h??(h=r.value);const O=d.value;return i(O)?a&&u&&b?.async===!1&&b.jitless!==!0?(s||(s=o(t.shape)),d=s(d,b),l?Zo([],O,d,b,h,e):d):n(d,b):(d.issues.push({expected:"object",code:"invalid_type",input:O,inst:e}),d)}});function Vo(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!Ot(s));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(s=>s.issues.map(i=>ut(i,r,ot())))}),t)}const Wo=f("$ZodUnion",(e,t)=>{he.init(e,t),ie(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),ie(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),ie(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),ie(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Vn(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>Vo(c,o,e,s)):Vo(a,o,e,s)}}),Xu=f("$ZodDiscriminatedUnion",(e,t)=>{Wo.init(e,t);const n=e._zod.parse;ie(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const r=cn(()=>{const o=t.options,s=new Map;for(const i of o){const a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!Vt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),o)}}),Qu=f("$ZodIntersection",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Ko(n,c,u)):Ko(n,s,i)}});function Qn(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(At(e)&&At(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Qn(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.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],s=t[r],i=Qn(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ko(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Ot(e))return e;const r=Qn(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 qu=f("$ZodRecord",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!At(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const l=t.valueType._zod.run({value:o[u],issues:[]},r);l instanceof Promise?s.push(l.then(h=>{h.issues.length&&n.issues.push(...bt(u,h.issues)),n.value[u]=h.value})):(l.issues.length&&n.issues.push(...bt(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,ot())),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?s.push(u.then(l=>{l.issues.length&&n.issues.push(...bt(a,l.issues)),n.value[c.value]=l.value})):(u.issues.length&&n.issues.push(...bt(a,u.issues)),n.value[c.value]=u.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Ju=f("$ZodEnum",(e,t)=>{he.init(e,t);const n=sc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>lc.has(typeof o)).map(o=>typeof o=="string"?It(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),el=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"?It(r):r?It(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),tl=f("$ZodTransform",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ao(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new vt;return n.value=o,n}});function Yo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const nl=f("$ZodOptional",(e,t)=>{he.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Vn(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(s=>Yo(s,n.value)):Yo(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),rl=f("$ZodNullable",(e,t)=>{he.init(e,t),ie(e._zod,"optin",()=>t.innerType._zod.optin),ie(e._zod,"optout",()=>t.innerType._zod.optout),ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Vn(n.source)}|null)$`):void 0}),ie(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)}),ol=f("$ZodDefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",ie(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(s=>Xo(s,t)):Xo(o,t)}});function Xo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const il=f("$ZodPrefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",ie(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))}),sl=f("$ZodNonOptional",(e,t)=>{he.init(e,t),ie(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(s=>Qo(s,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 al=f("$ZodCatch",(e,t)=>{he.init(e,t),ie(e._zod,"optin",()=>t.innerType._zod.optin),ie(e._zod,"optout",()=>t.innerType._zod.optout),ie(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(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>ut(i,r,ot()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>ut(s,r,ot()))},input:n.value}),n.issues=[]),n)}}),cl=f("$ZodPipe",(e,t)=>{he.init(e,t),ie(e._zod,"values",()=>t.in._zod.values),ie(e._zod,"optin",()=>t.in._zod.optin),ie(e._zod,"optout",()=>t.out._zod.optout),ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>hn(i,t.in,r)):hn(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>hn(s,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 ul=f("$ZodReadonly",(e,t)=>{he.init(e,t),ie(e._zod,"propValues",()=>t.innerType._zod.propValues),ie(e._zod,"values",()=>t.innerType._zod.values),ie(e._zod,"optin",()=>t.innerType?._zod?.optin),ie(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(qo):qo(o)}});function qo(e){return e.value=Object.freeze(e.value),e}const ll=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(s=>Jo(s,n,r,e));Jo(o,n,r,e)}});function Jo(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 ei;class pl{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 dl(){return new pl}(ei=globalThis).__zod_globalRegistry??(ei.__zod_globalRegistry=dl());const mn=globalThis.__zod_globalRegistry;function fl(e,t){return new e({type:"string",...P(t)})}function hl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function ti(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function ml(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function El(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function gl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function _l(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function ni(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function yl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function Sl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function Tl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function Rl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function wl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function Cl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function vl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function Al(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function Il(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function Ol(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function bl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function $l(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function Ll(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function Nl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function Dl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}function kl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function xl(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Pl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Ml(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function Ul(e,t){return new e({type:"number",checks:[],...P(t)})}function Fl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function zl(e,t){return new e({type:"boolean",...P(t)})}function Gl(e){return new e({type:"unknown"})}function Hl(e,t){return new e({type:"never",...P(t)})}function ri(e,t){return new Fo({check:"less_than",...P(t),value:e,inclusive:!1})}function qn(e,t){return new Fo({check:"less_than",...P(t),value:e,inclusive:!0})}function oi(e,t){return new zo({check:"greater_than",...P(t),value:e,inclusive:!1})}function Jn(e,t){return new zo({check:"greater_than",...P(t),value:e,inclusive:!0})}function ii(e,t){return new ou({check:"multiple_of",...P(t),value:e})}function si(e,t){return new su({check:"max_length",...P(t),maximum:e})}function En(e,t){return new au({check:"min_length",...P(t),minimum:e})}function ai(e,t){return new cu({check:"length_equals",...P(t),length:e})}function jl(e,t){return new uu({check:"string_format",format:"regex",...P(t),pattern:e})}function Bl(e){return new lu({check:"string_format",format:"lowercase",...P(e)})}function Zl(e){return new pu({check:"string_format",format:"uppercase",...P(e)})}function Vl(e,t){return new du({check:"string_format",format:"includes",...P(t),includes:e})}function Wl(e,t){return new fu({check:"string_format",format:"starts_with",...P(t),prefix:e})}function Kl(e,t){return new hu({check:"string_format",format:"ends_with",...P(t),suffix:e})}function $t(e){return new mu({check:"overwrite",tx:e})}function Yl(e){return $t(t=>t.normalize(e))}function Xl(){return $t(e=>e.trim())}function Ql(){return $t(e=>e.toLowerCase())}function ql(){return $t(e=>e.toUpperCase())}function Jl(){return $t(e=>cc(e))}function ep(e,t,n){return new e({type:"array",element:t,...P(n)})}function tp(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function np(e){const t=rp(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 rp(e,t){const n=new De({check:"custom",...P(t)});return n._zod.check=e,n}const op=f("ZodISODateTime",(e,t)=>{bu.init(e,t),me.init(e,t)});function ip(e){return kl(op,e)}const sp=f("ZodISODate",(e,t)=>{$u.init(e,t),me.init(e,t)});function ap(e){return xl(sp,e)}const cp=f("ZodISOTime",(e,t)=>{Lu.init(e,t),me.init(e,t)});function up(e){return Pl(cp,e)}const lp=f("ZodISODuration",(e,t)=>{Nu.init(e,t),me.init(e,t)});function pp(e){return Ml(lp,e)}const dp=(e,t)=>{No.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Tc(e,n)},flatten:{value:n=>Sc(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Bn,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Bn,2)}},isEmpty:{get(){return e.issues.length===0}}})},ze=f("ZodError",dp,{Parent:Error}),fp=Kn(ze),hp=Yn(ze),mp=ln(ze),Ep=pn(ze),gp=Cc(ze),_p=vc(ze),yp=Ac(ze),Sp=Ic(ze),Tp=Oc(ze),Rp=bc(ze),wp=$c(ze),Cp=Lc(ze),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)=>fp(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>mp(e,n,r),e.parseAsync=async(n,r)=>hp(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ep(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>gp(e,n,r),e.decode=(n,r)=>_p(e,n,r),e.encodeAsync=async(n,r)=>yp(e,n,r),e.decodeAsync=async(n,r)=>Sp(e,n,r),e.safeEncode=(n,r)=>Tp(e,n,r),e.safeDecode=(n,r)=>Rp(e,n,r),e.safeEncodeAsync=async(n,r)=>wp(e,n,r),e.safeDecodeAsync=async(n,r)=>Cp(e,n,r),e.refine=(n,r)=>e.check(hd(n,r)),e.superRefine=n=>e.check(md(n)),e.overwrite=n=>e.check($t(n)),e.optional=()=>mi(e),e.nullable=()=>Ei(e),e.nullish=()=>mi(Ei(e)),e.nonoptional=n=>ad(e,n),e.array=()=>oe(e),e.or=n=>Lt([e,n]),e.and=n=>Qp(e,n),e.transform=n=>_i(e,td(n)),e.default=n=>od(e,n),e.prefault=n=>sd(e,n),e.catch=n=>ud(e,n),e.pipe=n=>_i(e,n),e.readonly=()=>dd(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)),ci=f("_ZodString",(e,t)=>{Xn.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(jl(...r)),e.includes=(...r)=>e.check(Vl(...r)),e.startsWith=(...r)=>e.check(Wl(...r)),e.endsWith=(...r)=>e.check(Kl(...r)),e.min=(...r)=>e.check(En(...r)),e.max=(...r)=>e.check(si(...r)),e.length=(...r)=>e.check(ai(...r)),e.nonempty=(...r)=>e.check(En(1,...r)),e.lowercase=r=>e.check(Bl(r)),e.uppercase=r=>e.check(Zl(r)),e.trim=()=>e.check(Xl()),e.normalize=(...r)=>e.check(Yl(...r)),e.toLowerCase=()=>e.check(Ql()),e.toUpperCase=()=>e.check(ql()),e.slugify=()=>e.check(Jl())}),vp=f("ZodString",(e,t)=>{Xn.init(e,t),ci.init(e,t),e.email=n=>e.check(hl(Ap,n)),e.url=n=>e.check(ni(li,n)),e.jwt=n=>e.check(Dl(Gp,n)),e.emoji=n=>e.check(yl(Ip,n)),e.guid=n=>e.check(ti(ui,n)),e.uuid=n=>e.check(ml(gn,n)),e.uuidv4=n=>e.check(El(gn,n)),e.uuidv6=n=>e.check(gl(gn,n)),e.uuidv7=n=>e.check(_l(gn,n)),e.nanoid=n=>e.check(Sl(Op,n)),e.guid=n=>e.check(ti(ui,n)),e.cuid=n=>e.check(Tl(bp,n)),e.cuid2=n=>e.check(Rl($p,n)),e.ulid=n=>e.check(wl(Lp,n)),e.base64=n=>e.check($l(Up,n)),e.base64url=n=>e.check(Ll(Fp,n)),e.xid=n=>e.check(Cl(Np,n)),e.ksuid=n=>e.check(vl(Dp,n)),e.ipv4=n=>e.check(Al(kp,n)),e.ipv6=n=>e.check(Il(xp,n)),e.cidrv4=n=>e.check(Ol(Pp,n)),e.cidrv6=n=>e.check(bl(Mp,n)),e.e164=n=>e.check(Nl(zp,n)),e.datetime=n=>e.check(ip(n)),e.date=n=>e.check(ap(n)),e.time=n=>e.check(up(n)),e.duration=n=>e.check(pp(n))});function I(e){return fl(vp,e)}const me=f("ZodStringFormat",(e,t)=>{pe.init(e,t),ci.init(e,t)}),Ap=f("ZodEmail",(e,t)=>{Su.init(e,t),me.init(e,t)}),ui=f("ZodGUID",(e,t)=>{_u.init(e,t),me.init(e,t)}),gn=f("ZodUUID",(e,t)=>{yu.init(e,t),me.init(e,t)}),li=f("ZodURL",(e,t)=>{Tu.init(e,t),me.init(e,t)});function Kt(e){return ni(li,e)}const Ip=f("ZodEmoji",(e,t)=>{Ru.init(e,t),me.init(e,t)}),Op=f("ZodNanoID",(e,t)=>{wu.init(e,t),me.init(e,t)}),bp=f("ZodCUID",(e,t)=>{Cu.init(e,t),me.init(e,t)}),$p=f("ZodCUID2",(e,t)=>{vu.init(e,t),me.init(e,t)}),Lp=f("ZodULID",(e,t)=>{Au.init(e,t),me.init(e,t)}),Np=f("ZodXID",(e,t)=>{Iu.init(e,t),me.init(e,t)}),Dp=f("ZodKSUID",(e,t)=>{Ou.init(e,t),me.init(e,t)}),kp=f("ZodIPv4",(e,t)=>{Du.init(e,t),me.init(e,t)}),xp=f("ZodIPv6",(e,t)=>{ku.init(e,t),me.init(e,t)}),Pp=f("ZodCIDRv4",(e,t)=>{xu.init(e,t),me.init(e,t)}),Mp=f("ZodCIDRv6",(e,t)=>{Pu.init(e,t),me.init(e,t)}),Up=f("ZodBase64",(e,t)=>{Mu.init(e,t),me.init(e,t)}),Fp=f("ZodBase64URL",(e,t)=>{Fu.init(e,t),me.init(e,t)}),zp=f("ZodE164",(e,t)=>{zu.init(e,t),me.init(e,t)}),Gp=f("ZodJWT",(e,t)=>{Hu.init(e,t),me.init(e,t)}),pi=f("ZodNumber",(e,t)=>{Ho.init(e,t),ge.init(e,t),e.gt=(r,o)=>e.check(oi(r,o)),e.gte=(r,o)=>e.check(Jn(r,o)),e.min=(r,o)=>e.check(Jn(r,o)),e.lt=(r,o)=>e.check(ri(r,o)),e.lte=(r,o)=>e.check(qn(r,o)),e.max=(r,o)=>e.check(qn(r,o)),e.int=r=>e.check(We(r)),e.safe=r=>e.check(We(r)),e.positive=r=>e.check(oi(0,r)),e.nonnegative=r=>e.check(Jn(0,r)),e.negative=r=>e.check(ri(0,r)),e.nonpositive=r=>e.check(qn(0,r)),e.multipleOf=(r,o)=>e.check(ii(r,o)),e.step=(r,o)=>e.check(ii(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 Ul(pi,e)}const Hp=f("ZodNumberFormat",(e,t)=>{ju.init(e,t),pi.init(e,t)});function We(e){return Fl(Hp,e)}const jp=f("ZodBoolean",(e,t)=>{Bu.init(e,t),ge.init(e,t)});function ee(e){return zl(jp,e)}const Bp=f("ZodUnknown",(e,t)=>{Zu.init(e,t),ge.init(e,t)});function di(){return Gl(Bp)}const Zp=f("ZodNever",(e,t)=>{Vu.init(e,t),ge.init(e,t)});function Vp(e){return Hl(Zp,e)}const Wp=f("ZodArray",(e,t)=>{Wu.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(si(n,r)),e.length=(n,r)=>e.check(ai(n,r)),e.unwrap=()=>e.element});function oe(e,t){return ep(Wp,e,t)}const Kp=f("ZodObject",(e,t)=>{Yu.init(e,t),ge.init(e,t),ie(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:di()}),e.loose=()=>e.clone({...e._zod.def,catchall:di()}),e.strict=()=>e.clone({...e._zod.def,catchall:Vp()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>mc(e,n),e.safeExtend=n=>Ec(e,n),e.merge=n=>gc(e,n),e.pick=n=>fc(e,n),e.omit=n=>hc(e,n),e.partial=(...n)=>_c(hi,e,n[0]),e.required=(...n)=>yc(gi,e,n[0])});function R(e,t){const n={type:"object",shape:e??{},...P(t)};return new Kp(n)}const fi=f("ZodUnion",(e,t)=>{Wo.init(e,t),ge.init(e,t),e.options=t.options});function Lt(e,t){return new fi({type:"union",options:e,...P(t)})}const Yp=f("ZodDiscriminatedUnion",(e,t)=>{fi.init(e,t),Xu.init(e,t)});function it(e,t,n){return new Yp({type:"union",options:t,discriminator:e,...P(n)})}const Xp=f("ZodIntersection",(e,t)=>{Qu.init(e,t),ge.init(e,t)});function Qp(e,t){return new Xp({type:"intersection",left:e,right:t})}const qp=f("ZodRecord",(e,t)=>{qu.init(e,t),ge.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Qe(e,t,n){return new qp({type:"record",keyType:e,valueType:t,...P(n)})}const er=f("ZodEnum",(e,t)=>{Ju.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 s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new er({...t,checks:[],...P(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new er({...t,checks:[],...P(o),entries:s})}});function Ee(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new er({type:"enum",entries:n,...P(t)})}const Jp=f("ZodLiteral",(e,t)=>{el.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 k(e,t){return new Jp({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}const ed=f("ZodTransform",(e,t)=>{tl.init(e,t),ge.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ao(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Wt(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(Wt(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function td(e){return new ed({type:"transform",transform:e})}const hi=f("ZodOptional",(e,t)=>{nl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function mi(e){return new hi({type:"optional",innerType:e})}const nd=f("ZodNullable",(e,t)=>{rl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ei(e){return new nd({type:"nullable",innerType:e})}const rd=f("ZodDefault",(e,t)=>{ol.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function od(e,t){return new rd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$o(t)}})}const id=f("ZodPrefault",(e,t)=>{il.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function sd(e,t){return new id({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$o(t)}})}const gi=f("ZodNonOptional",(e,t)=>{sl.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ad(e,t){return new gi({type:"nonoptional",innerType:e,...P(t)})}const cd=f("ZodCatch",(e,t)=>{al.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ud(e,t){return new cd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ld=f("ZodPipe",(e,t)=>{cl.init(e,t),ge.init(e,t),e.in=t.in,e.out=t.out});function _i(e,t){return new ld({type:"pipe",in:e,out:t})}const pd=f("ZodReadonly",(e,t)=>{ul.init(e,t),ge.init(e,t),e.unwrap=()=>e._zod.def.innerType});function dd(e){return new pd({type:"readonly",innerType:e})}const fd=f("ZodCustom",(e,t)=>{ll.init(e,t),ge.init(e,t)});function hd(e,t={}){return tp(fd,e,t)}function md(e){return np(e)}const Ed={url:"must be a valid URL",email:"must be a valid email address"},gd=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},_d=e=>e===null?"null":typeof e,yd=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${gd(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${_d(t)}`}}case"invalid_format":{const t=Ed[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 te={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO"};Ee(Object.values(te));const Nt={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Sd=Ee(Object.values(Nt)),Yt={CONTENT:"Content",DESIGN:"Design"};Ee(Object.values(Yt));const Td={TEXT:"TEXT",IMAGE:"IMAGE"},Rd=Ee(Object.values(Td)),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"},wd=Ee(Object.values(lt)),yn={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Cd=Ee(Object.values(yn)),vd={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},Ad=Ee(Object.values(vd)),Id={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},Od=Ee(Object.values(Id)),bd={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},$d=Ee(Object.values(bd)),tr={COLOR:"COLOR",GRADIENT:"GRADIENT"},Ld=Ee(Object.values(tr));Ee(["none","all","small"]);const qe={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},yi={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},Nd=Ee(Object.values(qe));Ee(Object.values(yi));const Dd={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"},kd=Ee(Object.values(Dd)),xd={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"},Pd=Ee(Object.values(xd)),Md={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"},Ud={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"},Fd=Ee(Object.values(Ud)),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`,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`,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`,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"},zd=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,Gd=/^[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 We().min(e,{message:n}).max(t,{message:n})},nr=R({path:I(),size:_n().nonnegative()}).strict(),Si=R({size:_n().nonnegative()}).strict(),z=I().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),Hd=R({r:pt(0,255),g:pt(0,255),b:pt(0,255),a:pt(0,1)}).strict(),rr=I().regex(zd,{message:gt.VALID_HEX_COLOR()}),Pe=Lt([rr,Ee(["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"])]),Ti=Ee(["global.textSize.title","global.textSize.subtitle","global.textSize.body"]),Xt=Ee(["catalog","category","product"]),jd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function or(e){return e===qe.PRODUCT||e===qe.CATALOG||e===qe.CATEGORY}function Ri(e,t,n){if(!e)return;const r=ya({path:"$..set..url",json:e,resultType:"all"}),o=/^https?:\/\//;r.forEach(s=>{const i=s.value;if(!o.test(i)&&!t.includes(i)){const a=s.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",i)}})}function wi(e,t,n){e===lt.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Ci(e,t,n){(e===lt.GO_TO_CATEGORY||e===lt.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function vi(e,t,n){e===lt.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Ai(e,t,n){e===lt.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Ii(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 Bd(e,t,n){e===lt.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const Zd="custom";function Je(e,t=[]){const n=o=>Array.isArray(o)?o:[o],r=n(t);return{raw:e,addIssue(o,...s){e.addIssue({code:Zd,message:gt[o](...s),path:r,params:{errorMessageKey:o}})},at(o){const s=r.concat(n(o));return Je(e,s)}}}const ir=R({type:k(K.BUTTON),title:z,buttonType:wd,link:I().optional(),linkTarget:I().optional(),email:I().regex(jd,{message:gt.VALID_EMAIL()}).optional(),phone:I().optional(),tileId:I().optional(),categoryId:_n().optional()}).strict().superRefine((e,t)=>{const n=Je(t);wi(e.buttonType,e.link,n),Ci(e.buttonType,e.categoryId,n),vi(e.buttonType,e.email,n),Ai(e.buttonType,e.phone,n),Ii(e.buttonType,e.tileId,void 0,n)}),Oi=R({type:k(K.BUTTON),label:z,defaults:ir.optional()}).strict(),sr=R({type:k(K.CATEGORY_SELECTOR)}).strict(),bi=R({type:k(K.CATEGORY_SELECTOR),label:z,maxCategories:pt(1,32),defaults:sr.optional()}).strict(),ar=R({type:k(K.DIVIDER)}).strict(),$i=R({type:k(K.DIVIDER),label:z,defaults:ar.optional()}).strict(),Qt=R({url:I(),width:We().min(0,{message:gt.NON_NEGATIVE_INTEGER()}).optional(),height:We().min(0,{message:gt.NON_NEGATIVE_INTEGER()}).optional()}).strict(),Vd=R({homogeneity:ee().optional(),color:Hd.optional()}).strict(),Wd=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:Wd,borderInfo:Vd.optional()}).strict(),cr=R({type:k(K.IMAGE),imageData:Sn}).strict(),Li=R({type:k(K.IMAGE),label:z,static:ee().optional(),defaults:cr.optional()}).strict(),Kd=R({label:z,link:Kt()}).strict(),Yd=R({title:z.optional(),link:Kt().optional()}).strict(),ur=R({type:k(K.INFO),text:z.optional(),button:Yd.optional()}).strict(),Ni=R({type:k(K.INFO),label:z,description:z,button:Kd.optional(),defaults:ur.optional()}).strict(),lr=R({type:k(K.INPUTBOX),text:z}).strict(),Di=R({type:k(K.INPUTBOX),label:z,placeholder:z,defaults:lr.optional()}).strict(),pr=R({type:k(K.PRODUCT_SELECTOR)}).strict(),ki=R({type:k(K.PRODUCT_SELECTOR),label:z,maxProducts:pt(1,32),defaults:pr.optional()}).strict(),dr=R({type:k(K.SELECTBOX),value:I()}).strict(),Xd=R({value:I().min(1,{message:"value must not be empty"}),label:z}).strict(),xi=R({type:k(K.SELECTBOX),label:z,placeholder:z,description:z,options:oe(Xd).min(1,{message:"must have at least one option"}),defaults:dr.optional()}).strict(),fr=R({type:k(K.TEXTAREA),text:z}).strict(),Pi=R({type:k(K.TEXTAREA),label:z,placeholder:z,defaults:fr.optional()}).strict(),hr=R({type:k(K.TOGGLE),enabled:ee()}).strict(),Mi=R({type:k(K.TOGGLE),label:z,description:z,defaults:hr.optional()}).strict(),Qd=R({type:k(K.DECK)}).strict(),qd=it("type",[lr,fr,ir,cr,hr,dr,ar,ur,pr,sr]),Jd=R({type:k(K.DECK),cards:oe(R({settings:Qe(I(),qd).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(),ef=R({type:k(K.DECK),label:z,addButtonLabel:z,maxCards:We().min(1,{message:"must be a positive integer"}),cards:R({defaultCardContent:R({label:z,settings:Qe(I(),it("type",[Di,Pi,Oi,Li,Mi,xi,$i,Ni,bi,ki])).refine(e=>Object.keys(e).length>=1,{message:"settings must have at least one property"})}).strict()}).strict(),defaults:Qd.optional()}).strict(),Ui=R({type:k(K.LOGO),logoType:Rd.optional(),text:z.optional(),imageData:Sn.optional()}).strict(),tf=R({type:k(K.LOGO),label:z.optional(),defaults:Ui.optional()}).strict(),Fi=R({id:I(),title:I().optional(),type:I().optional(),link:I().optional(),email:I().optional(),phone:I().optional(),tileIdForScroll:I().optional(),pageIdForNavigate:I().optional(),showStoreCategories:ee().optional(),isSubmenuOpened:ee().optional(),categoryId:_n().optional()}).strict().superRefine((e,t)=>{const n=Je(t);wi(e.type,e.link,n),Ci(e.type,e.categoryId,n),vi(e.type,e.email,n),Ai(e.type,e.phone,n),Ii(e.type,void 0,e.tileIdForScroll,n),Bd(e.type,e.pageIdForNavigate,n)}),zi=R({type:k(K.MENU),items:oe(Fi).optional()}).strict(),nf=R({type:k(K.MENU),label:z.optional(),defaults:zi.optional()}).strict(),Gi=R({type:k(K.NAVIGATION_MENU),items:oe(Fi).optional()}).strict(),rf=R({type:k(K.NAVIGATION_MENU),defaults:Gi.optional()}).strict(),of=it("type",[Di,Pi,Oi,Li,Mi,xi,ef,nf,rf,tf,$i,Ni,ki,bi]),Hi=Qe(I(),of),mr=R({type:k(te.BACKGROUND),style:Ld.optional(),color:Lt([Pe,oe(Pe)]).optional()}).strict().superRefine((e,t)=>{const n=Je(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"))}),sf=R({type:k(te.BACKGROUND),fieldName:I(),defaults:mr.optional()}).strict(),af=R({type:k(te.BACKGROUND),label:z,colors:oe(Pe).optional(),enableAlphaColor:ee().optional(),enableAutoColor:ee().optional(),defaults:mr.optional()}).strict(),Er=R({type:k(te.BUTTON),appearance:Ad.optional(),size:Od.optional(),shape:$d.optional(),font:I().optional(),color:Pe.optional(),visible:ee().optional()}).strict(),cf=R({type:k(te.BUTTON),fieldName:I(),defaults:Er.optional()}).strict(),uf=R({type:k(te.BUTTON),label:z,colors:oe(Pe).optional(),enableAutoColor:ee().optional(),enableAlphaColor:ee().optional(),hideVisibleToggle:ee().optional(),hideSize:ee().optional(),defaults:Er.optional()}).strict(),gr=R({type:k(te.COLOR_PICKER),color:Pe.optional()}).strict(),lf=R({type:k(te.COLOR_PICKER),fieldName:I(),defaults:gr.optional()}).strict(),pf=R({type:k(te.COLOR_PICKER),label:z,colors:oe(Pe).optional(),enableAlphaColor:ee().optional(),enableAutoColor:ee().optional(),defaults:gr.optional()}).strict(),_r=R({type:k(te.DIVIDER)}).strict(),df=R({type:k(te.DIVIDER),fieldName:I(),defaults:_r.optional()}).strict(),ff=R({type:k(te.DIVIDER),label:z,defaults:_r.optional()}).strict(),yr=R({type:k(te.IMAGE),overlay:Cd.optional(),color:Lt([Pe,oe(Pe)]).optional(),visible:ee().optional()}).strict().superRefine((e,t)=>{const n=Je(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")}),hf=R({type:k(te.IMAGE),fieldName:I(),defaults:yr.optional()}).strict(),mf=R({type:k(te.IMAGE),label:z,static:ee().optional(),colors:oe(rr).optional(),enableAlphaColor:ee().optional(),hideVisibleToggle:ee().optional(),defaults:yr.optional()}).strict(),Ef=R({label:z,link:Kt()}).strict(),gf=R({label:z.optional(),link:Kt().optional()}).strict(),Sr=R({type:k(te.INFO),description:z.optional(),button:gf.optional()}).strict(),_f=R({type:k(te.INFO),fieldName:I(),defaults:Sr.optional()}).strict(),yf=R({type:k(te.INFO),label:z,description:z,button:Ef.optional(),defaults:Sr.optional()}).strict(),Sf=R({visible:ee(),width:pt(1,49).optional(),color:Pe.optional()}).strict(),Tr=R({type:k(te.LOGO),font:I().optional(),size:Lt([We().min(1,{message:"must be at least 1"}),Ti]).optional(),bold:ee().optional(),italic:ee().optional(),color:Pe.optional(),visible:ee().optional(),spacing:pt(1,9).optional(),frame:Sf.optional(),capitalization:Ee(["none","all","small"]).optional()}).strict(),Tf=R({type:k(te.LOGO),fieldName:I(),defaults:Tr.optional()}).strict(),Rf=R({type:k(te.LOGO),label:z,colors:oe(Pe).optional(),sizes:oe(We().min(1,{message:"must be at least 1"})).optional(),defaults:Tr.optional()}).strict(),wf=R({value:I().optional(),label:z.optional()}).strict(),Rr=R({type:k(te.SELECTBOX),value:I().optional()}).strict(),Cf=R({type:k(te.SELECTBOX),fieldName:I(),defaults:Rr.optional()}).strict(),vf=R({type:k(te.SELECTBOX),label:z,description:z.optional(),options:oe(wf).optional(),defaults:Rr.optional()}).strict(),wr=R({type:k(te.TEXT),font:I().optional(),size:Lt([We().min(1,{message:"must be at least 1"}),Ti]).optional(),bold:ee().optional(),italic:ee().optional(),color:Pe.optional(),visible:ee().optional()}).strict(),Af=R({type:k(te.TEXT),fieldName:I(),defaults:wr.optional()}).strict(),If=R({type:k(te.TEXT),label:z,colors:oe(rr).optional(),sizes:oe(We().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:ee().optional(),enableAutoColor:ee().optional(),hideVisibleToggle:ee().optional(),hideSize:ee().optional(),defaults:wr.optional()}).strict(),Cr=R({type:k(te.TOGGLE),enabled:ee().optional()}).strict(),Of=R({type:k(te.TOGGLE),fieldName:I(),defaults:Cr.optional()}).strict(),bf=R({type:k(te.TOGGLE),label:z,defaults:Cr.optional()}).strict(),$f=it("type",[If,uf,mf,bf,vf,af,pf,Rf,ff,yf]),ji=Qe(I(),$f),Lf=it("type",[Af,cf,hf,Of,Cf,sf,lf,Tf,df,_f]),Nf=R({layoutId:I(),layoutIcon:Pd.optional(),selectedContentSettings:oe(I()),selectedDesignSettings:oe(Lf)}).strict(),Bi=it("type",[lr,fr,ir,cr,hr,dr,zi,Gi,Ui,ar,ur,Jd,pr,sr]),Zi=it("type",[wr,Er,yr,Cr,Rr,mr,gr,Tr,_r,Sr]),Df=R({showcaseId:I(),blockName:I(),previewImage:Sn,content:Qe(I(),Bi),design:Qe(I(),Zi),layoutId:I().optional()}).strict(),kf=R({blockName:I(),content:Qe(I(),Bi).optional(),design:Qe(I(),Zi).optional(),layoutId:I().optional()}).strict(),xf=I().regex(Gd,gt.VALID_LANGUAGE_CODE()),Tn=Qe(xf,Qe(z,I())),Pf={menu:{type:K.NAVIGATION_MENU},logo:{type:K.LOGO}},Mf={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 Vi(e){switch(e){case Nt.HEADER:return Pf;default:return{}}}function Wi(e){switch(e){case Nt.HEADER:return Mf;default:return{}}}function Ki({validationType:e,sectionType:t}){switch(e){case Yt.CONTENT:return Vi(t);case Yt.DESIGN:return Wi(t);default:return{}}}const Rn=2097152,wn=512e3;function st(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"],s=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**s).toFixed(r))} ${o[s]}`}function Yi(e,t,n){if(!e||Object.keys(t).length===0)return;const r=Object.entries(t),o=r.map(([,{type:i}])=>i),s=Object.values(e).map(({type:i})=>i);Object.entries(e).forEach(([i,a])=>{const c=t[i];c&&"type"in c&&a.type!==c.type&&n.at(i).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,i,c.type)}),Object.entries(e).forEach(([i,a])=>{const c=r.find(([,{type:u}])=>u===a.type)?.[0];c&&i!==c&&n.at(i).addIssue("MANDATORY_SETTING_NAME_MISMATCH",i,a.type,c)}),new Set(s.filter(i=>o.includes(i))).forEach(i=>{if(s.filter(a=>a===i).length>1){const a=r.findLast(([,{type:c}])=>c===i)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",i)}})}function Xi(e,t,n){Ri(e,t,n)}function Uf(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 s=new Set(Object.keys(r));o.forEach((i,a)=>{i.settings&&Object.keys(i.settings).forEach(c=>{s.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function Ff(e,t,n){e.content&&Object.entries(e.content).forEach(([r,o])=>{const s=n.at(["content",r]),i=t[r];if(!i){s.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",r);return}if(o.type!==i.type){s.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",r,o.type,i.type);return}if(o.type===K.SELECTBOX&&i.type===K.SELECTBOX){const a=i,c=o;a.options&&c.value!==void 0&&(new Set(a.options.map(u=>u.value)).has(c.value)||s.addIssue("INVALID_SELECTBOX_OPTION",c.value,r))}o.type===K.DECK&&Uf(o,i,s)})}function zf(e,t,n){e.design&&Object.entries(e.design).forEach(([r,o])=>{const s=n.at(["design",r]),i=t[r];if(!i){s.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",r);return}o.type!==i.type&&s.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",r,o.type,i.type)})}function Qi(e,t,n){for(const[r,o]of Object.entries(e)){const s=o;if(s.type===K.IMAGE){const i=t[r];if(i?.type===te.IMAGE){const a=s.static??!1,c=i.static??!1;a!==c&&n.at(r).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",r)}}else if(s.type===K.DECK){const i=s;i.cards?.defaultCardContent?.settings&&Qi(i.cards.defaultCardContent.settings,t,n.at([r,"cards","defaultCardContent","settings"]))}}}function Gf(e,t,n){t>Rn&&n.at(ue.basename(e)).addIssue("REQUIRED_SECTION_ASSET",st(t),st(Rn))}function Hf(e,t){e>wn&&t.addIssue("REQUIRED_SERVER_SIZE",st(e),st(wn))}const jf=R({id:I(),type:Sd,name:I(),content:Hi,design:ji,layout:oe(Nf).optional(),showcase:oe(Df),translationsSettings:Tn.optional(),translationsShowcases:Tn.optional(),assets:nr.array().optional(),server:Si,previewCount:We().optional()}).strict().superRefine((e,t)=>{const n=Je(t),r=Ki({validationType:Yt.CONTENT,sectionType:e.type}),o=Ki({validationType:Yt.DESIGN,sectionType:e.type});Yi(e.content,r,n.at("content")),Yi(e.design,o,n.at("design")),Qi(e.content,e.design,n.at("content")),e.assets&&e.assets.forEach(i=>{Gf(i.path,i.size,n.at("assets"))}),Hf(e.server.size,n.at("server"));const s=e.assets?.map(i=>i.path)??[];Xi(e.content,s,n.at("content")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);Xi(i,s,c),Ff(i,e.content,c),zf(i,e.design,c)})}),Bf=R({translations:Tn.optional()}).strict(),Zf=Ee(["products","category","product"]),Vf=R({id:I(),sectionId:I(),content:Hi,design:ji,translationsSettings:Tn.optional(),assets:nr.array().optional()}).strict().superRefine((e,t)=>{const n=Je(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>Rn&&n.at(["assets",ue.basename(r.path)]).addIssue("REQUIRED_SECTION_ASSET",st(r.size),st(Rn))})});R({id:I(),sectionId:Xt,pageId:Zf}).strict();const Wf=R({id:I(),sectionId:I(),layoutId:I(),server:Si}).strict().superRefine((e,t)=>{const n=Je(t);Xt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,Xt.options.join(", ")),e.server.size>wn&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",st(e.server.size),st(wn))});function Kf(e,t){or(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 Yf(e,t){or(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,r)=>{or(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 Xf(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 Qf=new RegExp(`^(${Object.values(Md).join("|")})(_\\d{3})?$`),qf=I().regex(Qf,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),Jf=I().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),qi=R({type:k("default"),id:qf,showcase_id:Jf.optional()}).strict(),vr=R({type:k("custom"),id:I(),showcase_id:I().optional(),showcase_overrides:kf.optional(),category:Fd.optional()}).strict(),eh=R({type:k("store"),id:I().optional()}).strict(),th=it("type",[qi,vr,eh]),nh=R({title:I()}).strict(),rh=R({metadata:nh.optional(),sections:oe(th)}).strict(),oh=rh.safeExtend({type:Nd,id:I().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=Je(t);Yf(e,n),Kf(e,n),Xf(e,n)}),Ji=R({name:I().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:I().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(kd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),ih=qi.extend({id:I()}),es=it("type",[ih,vr]),sh=R({metadata:Ji,header:es,footer:es}).strict(),ah=R({id:I().min(1,{message:"id is required"}),assets:nr.array().optional(),configuration:sh,pages:oe(oh)}).strict();function ch(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 uh(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 lh(e,t,n){if(!e)return;const r=n.at(["showcase_overrides"]);["content","design"].forEach(s=>{const i=e[s];if(i){const a=t[s]||{};Object.keys(i).forEach(c=>{if(!(c in a)){const u=s==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";r.at([s,c]).addIssue(u,c)}})}}),e.layoutId&&((t.layout||[]).some(s=>s.layoutId===e.layoutId)||r.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const o=t.assets?.map(s=>s.path)??[];e.content&&Ri(e.content,o,r.at(["content"]))}function ph(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"),lh(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 dh(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 fh=R({version:I(),name:I(),shared:Bf.optional(),sections:oe(jf),templates:oe(ah),layouts:oe(Vf),slots:oe(Wf),compressionEnabled:ee(),externalizationEnabled:ee(),vueVersion:I()}).strict().superRefine((e,t)=>{e.templates.forEach((n,r)=>{const o=Je(t).at(["templates",r]);ch(n.configuration.header,e.sections,o.at(["configuration","header"])),uh(n.configuration.footer,e.sections,o.at(["configuration","footer"])),n.pages.forEach((s,i)=>{const a=o.at(["pages",i]);s.sections.forEach((c,u)=>{const l=a.at(["sections",u]);c.type==="custom"?ph(c,e.sections,l):c.type==="store"&&dh(c,s,e.layouts,l)})})})}),hh=R({metadata:Ji,sections:oe(vr)});R({id:I().min(1,{message:"id is required"}),descriptor:hh}),ot({customError:yd});function Ar(e,t){return Object.keys(e).reduce((n,r)=>{const o=e[r],s=t[r];return ft(o)&&ft(s)?n[r]=Ar(o,s):n[r]=o,n},{...t})}function mh({contentSettings:e,sectionType:t}){const n=Vi(t);return Ar(e,n)}function Eh({designSettings:e,sectionType:t}){const n=Wi(t);return Ar(e,n)}function Dt(e){return Ce(`${Gt}/${e}`)?ve.HEADER:Ce(`${Ht}/${e}`)?ve.FOOTER:ve.SECTION}async function ke(e){return(await import(ma(e).href+`?t=${Date.now()}`)).default}function Ir(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function Ke(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Sa(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function ts(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 gh(e){if(e!==void 0)return{...e,color:Ke(e.color)}}function Or(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function _h(e){if(e!==void 0)switch(e){case zn.COLOR:return"solid";case zn.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(zn)}`)}}function yh({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:_h(e),solid:{color:Ke(n.at(0))},gradient:{fromColor:Ke(n.at(0)),toColor:Ke(n.at(1))}}}}function Sh(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(da)}`)}}function Th(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(fa)}`)}}function Rh(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(ha)}`)}}function wh(e){const t=Sh(e.appearance),n=Th(e.size),r=Rh(e.shape),o=Ir(e.font),s=Ke(e.color),i=e.visible;return Or({appearance:t,size:n,style:r,font:o,color:s,visible:i})}function Ch(e){const t=Ke(e.color);return Or({color:t})}function vh(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 Ah(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:vh(e.overlay),solid:{color:Ke(n.at(0))},gradient:{fromColor:Ke(n.at(0)),toColor:Ke(n.at(1))}}}}function Ih(e){const t=Ir(e.font),n=Ke(e.color),r=ts(e.size),o=e.bold,s=e.italic,i=e.spacing,a=e.capitalization;return{font:t,color:n,size:r,frame:gh(e.frame),bold:o,italic:s,spacing:i,capitalization:a}}function Oh(e){const t=Ir(e.font),n=Ke(e.color),r=ts(e.size),o=e.bold,s=e.italic;return Or({font:t,color:n,size:r,bold:o,italic:s})}function br(e,t){if(t.defaults===void 0)return;let n={};switch(e){case Xe.TEXT:{n=Oh(t.defaults);break}case Xe.BUTTON:{n=wh(t.defaults);break}case Xe.IMAGE:{n=Ah(t.defaults);break}case Xe.BACKGROUND:{n=yh(t.defaults);break}case Xe.COLOR_PICKER:{n=Ch(t.defaults);break}case Xe.LOGO:{n=Ih(t.defaults);break}case Xe.TOGGLE:case Xe.SELECTBOX:case Xe.DIVIDER:case Xe.INFO:break;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function bh(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type,s=br(o,r);s&&r.defaults?t[n]={...r,defaults:s}:t[n]=r}),t}function $h(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...br(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function $r(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const r=e[n],o=r.type,s=br(o,{defaults:r});s!==void 0?t[n]={...r,...s,type:r.type}:t[n]=r}),t}function Lh(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Nh(e){const t={};for(const n in e){const r=e[n];for(const o in r){const s=t[o],i=r[o];if(s===void 0){const a={};a[n]=i,t[o]=a}else s[n]=i}}return t}function Dh(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 Dh(e)?e:e.map(o=>_t(o,t));const n=e,r={};for(const o in n){const s=n[o];typeof s=="string"&&s.startsWith("$")?r[o]=Lh(t,s):typeof s=="object"&&s!==null?r[o]=_t(s,t):r[o]=s}return r}async function Cn(e){return e?Nh(e):{}}async function ns(e,t=Oe){const n=M(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await ke(n)}async function kt(e,t=Oe){const n=M(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await ke(n)}async function rs(e,t){const n=M(process.cwd(),`${Ae}/${t}/${e}/js/settings/translations.mjs`);if(Ce(n))return await ke(n)}async function os(e,t,n){const r=n?mh({contentSettings:e,sectionType:n}):e;return _t(r,t)}async function is(e,t=Oe){try{const n=M(ae.cwd(),`${t}/${e}/js/settings/content.mjs`),r=await ke(n);return Zt(r)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function kh(e,t,n=Oe){const r=await is(e,n);return await os(r,t,Dt(e))}async function ss(e,t,n){const r=n?Eh({designSettings:e,sectionType:n}):e,o=bh(r);return _t(o,t)}async function as(e,t=Oe){try{const n=M(ae.cwd(),`${t}/${e}/js/settings/design.mjs`),r=await ke(n);return Zt(r)}catch(n){const r=n;throw new Error(`Design settings is invalid or undefined. Error ${r.stack}`)}}async function xh(e,t,n=Oe){const r=await as(e,n);return ss(r,t,Dt(e))}async function Ph(e,t){return Promise.all(e.map(async n=>{const r=n.design?$r(n.design):void 0,o={...n,design:r??n.design};return _t(o,t)}))}async function cs(e,t=Oe){try{const n=await F("*.mjs",{cwd:M(ae.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async r=>{const o=M(ae.cwd(),`${t}/${e}/js/showcases/${r}`);return await ke(o)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Mh(e,t,n=Oe){const r=await cs(e,n);return Ph(r,t)}async function Uh(e){return e?.map(t=>({...t,selectedDesignSettings:$h(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function us(e,t=Oe){try{const n=M(ae.cwd(),`${t}/${e}/js/settings/layout.mjs`);return Ce(n)?await ke(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function Fh(e,t=Oe){const n=await us(e,t);return await Uh(n)}function ls(e){let t={};const n=M(ae.cwd(),`${Co}/shared/analytics.json`);if(!Ce(n))return 0;try{const r=ta(n,"utf-8");t=JSON.parse(r)}catch(r){console.warn("Error processing analytics.json file",r)}return t[e]||0}function zh(){try{const e=M(ae.cwd(),`${Co}/shared/analytics.json`);Ce(e)&&ao(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}async function vn(e,t){const n=await ns(e,se[t].dist),r=await Cn(n),o=await kt(e,se[t].dist),s=await Cn(o),i=await kh(e,r,se[t].dist),a=await xh(e,r,se[t].dist),c=await Mh(e,s,se[t].dist),u=await Fh(e,se[t].dist),l=ls(e);return{id:e,type:t,name:{en:e},contentEditors:i,designEditors:a,layouts:u,showcases:c,previewCount:l}}async function Gh(){const e=await F("*/",{cwd:M(ae.cwd(),`${Oe}/`)}),t=await F("*/",{cwd:M(ae.cwd(),`${Gt}/`)}),n=await F("*/",{cwd:M(ae.cwd(),`${Ht}/`)});return Promise.all([...e.map(async r=>vn(r,ve.SECTION)),...t.map(async r=>vn(r,ve.HEADER)),...n.map(async r=>vn(r,ve.FOOTER))])}async function Hh(e){if(!e||e.type!=="custom")return;const t=Dt(e.id),n=await kt(e.id,se[t].dist);e.showcase_overrides!==void 0&&(_t(e.showcase_overrides,n),e.showcase_overrides.design&&$r(e.showcase_overrides.design))}async function jh(e){const t=e.filter(n=>n.type==="custom");await Promise.all(t.map(n=>Hh(n)))}async function Lr(e){try{return await ke(nt.resolve(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}function Bh(e){return e in qe?qe[e]:qe.CUSTOM}async function Nr(e,t){const n=e.design?$r(e.design):void 0,r={...e,design:n??e.design},o=await Cn(t);return _t(r,o)}function Dr(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function Zh(e){if(Dr(e)){const t=await kt(e.id,se[Dt(e.id)].dist);return{...e,showcase_overrides:await Nr(e.showcase_overrides,t)}}return e}async function Vh(e){const t=Dr(e.header)?{...e.header,showcase_overrides:await Nr(e.header.showcase_overrides,await kt(e.header.id,se[Dt(e.header.id)].dist))}:e.header,n=Dr(e.footer)?{...e.footer,showcase_overrides:await Nr(e.footer.showcase_overrides,await kt(e.footer.id,se[Dt(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function Wh(e){const t=await Promise.all(e.pages.map(async r=>({...r,sections:await Promise.all(r.sections.map(o=>Zh(o)))}))),n=await Vh(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function Kh(e){return Promise.all(e.map(t=>Wh(t)))}async function Yh(e){const t=await F(`${Fe}/${e}/*.mjs`,{ignore:[`${Fe}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:r,metadata:o}=await Lr(n),s=vo(n);return{type:Bh(s.toUpperCase()),id:s,sections:r,metadata:o}}))}async function Xh(e){const t=await F(`${Fe}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=nt.basename(nt.dirname(n));return{id:`${e}_${r}`,configuration:await Lr(n),pages:await Yh(r)}}))}async function Qh(e){const t=await Xh(e);return Kh(t)}async function qh(e){const t=await F(`${on}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=await Lr(n),o=ue.basename(ue.dirname(n));return await jh(r.sections),{id:`${e}_${o}`,descriptor:r}}))}function An({deploymentContext:e,sectionType:t=ve.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:M(process.cwd(),r),ignore:n.ignore});return(n.isSingleton?o.splice(0):o).map(s=>({url:s,sectionType:t,context:e}))}const Jh=e=>e.app.sections.flatMap(t=>Ua.flatMap(n=>{const r={config:e,currentSection:t.id,pathContext:Bt[n]};return An({deploymentContext:r,sectionType:t.type})})),em=e=>Ga.flatMap(t=>{const n={config:e,pathContext:Bt[t]};return An({deploymentContext:n})}),tm=e=>e.app.layouts.flatMap(t=>Fa.flatMap(n=>{const r={config:e,pathContext:Bt[n],currentSection:t.sectionId,layoutId:t.id};return An({deploymentContext:r})})),nm=e=>e.app.slots.flatMap(t=>za.flatMap(n=>{const r={config:e,pathContext:Bt[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return An({deploymentContext:r})}));async function ps(e){await new Promise(t=>setTimeout(t,e))}const rm=e=>`\x1B[32m${e}\x1B[0m`,om=(e,t,n,r,o)=>{if(!e.total)return;const{loaded:s}=e,i=(Date.now()-o)/1e3;n.value+=s-r.value,r.value=s,t.update({speed:`${st(n.value/i,2)}/s`})},im=()=>new Ta.SingleBar({format:`|${rm("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});function sm(e){const t=wt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t;if(!wo(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:o,sectionId:n,layoutId:r}}async function am(e){return Promise.all(e.map(async t=>{const n=await Cn(t.translationsSettings),r=await os(t.content,n),o=await ss(t.design,n);return{id:t.id,sectionId:t.sectionId,layoutId:t.layoutId,contentEditors:r,designEditors:o}}))}async function cm(e,t){try{const n=nt.resolve(process.cwd(),`${Ae}/${t}/${e}/js/settings/content.mjs`);return await ke(n)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function um(e,t){try{const n=nt.resolve(process.cwd(),`${Ae}/${t}/${e}/js/settings/design.mjs`);return await ke(n)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function lm(e){const t=wt(e).split("/"),[n,r,,o]=t,s=await rs(r,n),i=await cm(r,n),a=await um(r,n);return{id:o,sectionId:n,layoutId:r,content:i,design:a,translationsSettings:s}}async function pm(){const e=`${Ae}/{product,catalog,category}/*/slots/*`,t=await F(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(lm))}async function dm(){const e=await pm();return await am(e)}const fm={value:0},Ge=im();let ds=Date.now();const fs=e=>2**e*500;function hm(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function kr(){const e=M(ae.cwd(),"package.json"),t=await mo(e),n=JSON.parse(t.toString());if(hm(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}async function mm(e){const t=_a(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,ao(M(ae.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
26
|
+
`)}function Em(e){return e instanceof Eo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function hs(e,t){return e<Ma&&Em(t)}async function ms(e,t,n,r){const o={value:0},s=e.config.app.templates.length>0||e.config.app.collections.length>0?Da:Na;return e.config.axios.post(s,{file:na(M(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:i=>om(i,Ge,fm,o,ds)}).then(i=>(Ge.increment(),i)).catch(async i=>{if(hs(r,i))return await ps(fs(r)),ms(e,t,n,r+1);throw Ge.increment(),i})}function gm(e){return Ge.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 ms(n,t.url,r,0)})}function _m(e){const t=[...Jh(e),...em(e),...tm(e),...nm(e)];return gm(t)}async function Es(e,t=0){const n=e.app.templates.length>0||e.app.collections.length>0?xa:ka;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(hs(t,r))return await ps(fs(t)),Es(e,t+1);throw r})}async function ym(e){try{if(!Za.some(i=>Ce(M(ae.cwd(),i))))throw new Error(Tt.INCORRECT_DISTRIBUTION_FOLDER(ja));const t=e??Hn;L.info("Custom application deployment :: Started");const n=Gn.create({baseURL:t});ga(n,Pa),L.info("Loading configuration files ...");const r=await Promise.all([an(),kr(),Gh(),ic(),dm()]).then(async([i,a,c,u,l])=>({axios:n,app:{crane:i,packageJson:a,sections:c,layouts:u,slots:l,templates:await Qh(i.appClientId),collections:await qh(i.appClientId)}}));L.info("Uploading files ..."),ds=Date.now(),await Promise.all(_m(r)).catch(i=>{Ge.stop(),i.response?.status===404?L.error(ht(i,Tt.DEPRECATED_VERSION_DEPLOYMENT)):L.error(ht(i,Tt.ASSET_FILES_UPLOAD)),ae.exit(1)}).finally(()=>{Ge.increment(),Ge.stop()}),Ge.update({speed:"N/A",status:"Finalising deployment"}),await Es(r).catch(i=>{Ge.stop(),i.response?.status===404?L.error(ht(i,Tt.DEPRECATED_VERSION_DEPLOYMENT)):L.error(ht(i,Tt.MANIFEST_DEPLOYMENT)),ae.exit(1)}).finally(()=>{Ge.increment(),Ge.stop()});const o=r.app.sections.map(i=>i.id),s=r.app.packageJson.version;L.info("Custom application deployment :: Successful"),L.info(`Current app version: ${s}`),L.info(`Deployed sections: ${o.sort().join(", ")}`),await mm(r.app.packageJson),r.app.templates.length>0&&L.info(`Deployed templates: ${r.app.templates.map(i=>i.id).sort().join(", ")}`),r.app.slots.length>0&&L.info(`Deployed slots: ${r.app.slots.map(i=>i.id).sort().join(", ")}`),r.app.collections.length>0&&L.info(`Deployed collections: ${r.app.collections.map(i=>i.id).sort().join(", ")}`)}catch(t){Ge.stop(),L.error(ht(t,Tt.DEFAULT)),ae.exit(1)}finally{zh()}}const Sm={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Tm(e,t){const n=Sm[e];return n?n(t):t.id}const Rm=new Set(["content","design"]);function In(e,t,n=0,r=[]){if(n>=t.length)return r;const o=t[n],s=t[n+1];if(typeof o=="string"&&typeof s=="number"&&ft(e)){const i=e[o],a=Array.isArray(i)?i[s]:void 0;if(ft(a)){const c=Tm(o,a);return r.push(`${o}[${c||s}]`),In(a,t,n+2,r)}}if(typeof o=="string"&&typeof s=="string"&&Rm.has(o)){r.push(`${o}[${s}]`);const i=ft(e)&&!Array.isArray(e)?e[o]:void 0,a=ft(i)&&!Array.isArray(i)?i[s]:void 0;return In(a,t,n+2,r)}return r.push(o),In(ft(e)?e[o]:void 0,t,n+1,r)}function wm(e){const t=e.errors.map(r=>In(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 s=r.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[o].padEnd(n.path," ")} | ${r.message.padEnd(n.message," ")} | ${s}`}).forEach(r=>L.error(r))}async function Cm(e){const t=fh.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const gs={"process.env":{NODE_ENV:"production"}},vm=[...go,...go.map(e=>`node:${e}`)],Am=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],_s=e=>({pluginType:Ue.Server,define:gs,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...vm,...Am],inlineDynamicImports:!0,...e,outDir:e.outDir}),ys=e=>({pluginType:Ue.Client,define:gs,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),xt=e=>({pluginType:Ue.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),Im=e=>({pluginType:Ue.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),On=e=>({pluginType:Ue.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let bn=!1;function Om(e){bn=e}function xr(){return bn}const Ss=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],bm=80,$m="\x1B[?25l",Lm="\x1B[?25h",Nm="\x1B[2K\r",Dm=44;let km=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){bn||(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($m),this.render(),this.timer=setInterval(()=>this.render(),bm))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(Dm-1," "),n=Ze(Ss[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%Ss.length}stop(){if(!bn&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${Nm}${Lm}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Ts=new km,xm=()=>Ra({ext:".gz",algorithm:"gzip",verbose:xr()}),Pm="/* EXTERNAL_IMPORTS_START */",Mm="/* EXTERNAL_IMPORTS_END */",Um=()=>({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,s=r.code.match(o);if(s!==null){const i=s.join(""),a=Pm+i+Mm,c=r.code.replace(o,"");r.code=a+c}}}}}),Fm=()=>({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})}}),zm=()=>{const e=process.env.npm_lifecycle_event;return va({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"`}})},Ye={vue:()=>wa(),tsconfigPaths:()=>Ca(),checker:()=>zm()};class xn{constructor(t){this.bits=t instanceof xn?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 s=new Jt(t,this.end,o);return s.outro=this.outro,this.outro="",this.end=t,this.edited?(s.edit("",!1),this.content=""):this.content=r,s.next=this.next,s.next&&(s.next.previous=s),s.previous=this,this.next=s,s}toString(){return this.intro+this.content+this.outro}trimEnd(t){if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;const n=this.content.replace(t,"");if(n.length)return n!==this.content&&(this.split(this.start+n.length).edit("",void 0,!0),this.edited&&this.edit(n,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(t,""),this.intro.length)return!0}trimStart(t){if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;const n=this.content.replace(t,"");if(n.length){if(n!==this.content){const 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 Gm(){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 Hm=Gm();class jm{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Aa(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,"+Hm(this.toString())}}function Bm(e){const t=e.split(`
|
|
27
|
+
`),n=t.filter(s=>/^\t+/.test(s)),r=t.filter(s=>/^ {2,}/.test(s));if(n.length===0&&r.length===0)return null;if(n.length>=r.length)return" ";const o=r.reduce((s,i)=>{const a=/^ +/.exec(i)[0].length;return Math.min(a,s)},1/0);return new Array(o+1).join(" ")}function Zm(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 Vm=Object.prototype.toString;function Wm(e){return Vm.call(e)==="[object Object]"}function Rs(e){const t=e.split(`
|
|
28
|
+
`),n=[];for(let r=0,o=0;r<t.length;r++)n.push(o),o+=t[r].length+1;return function(o){let s=0,i=n.length;for(;s<i;){const u=s+i>>1;o<n[u]?i=u:s=u+1}const a=s-1,c=o-n[a];return{line:a,column:c}}}const Km=/\w/;class Ym{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 s=n.length-1;let i=n.indexOf(`
|
|
29
|
+
`,0),a=-1;for(;i>=0&&s>i;){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=i,i=n.indexOf(`
|
|
30
|
+
`,i+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,s){let i=n.start,a=!0,c=!1;for(;i<n.end;){if(this.hires||a||s.has(i)){const u=[this.generatedCodeColumn,t,o.line,o.column];this.hires==="boundary"?Km.test(r[i])?c||(this.rawSegments.push(u),c=!0):(this.rawSegments.push(u),c=!1):this.rawSegments.push(u)}r[i]===`
|
|
31
|
+
`?(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),i+=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 qt=`
|
|
33
|
+
`,Pt={insertLeft:!1,insertRight:!1,storeName:!1};class so{constructor(t,n={}){const r=new Jt(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 xn},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 so(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,s=o&&o.clone();s&&(r.next=s,s.previous=r,r=s),n=o}return t.lastChunk=r,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new xn(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 Ym(t.hires),s=Rs(this.original);return this.intro&&o.advance(this.intro),this.firstChunk.eachNext(i=>{const a=s(i.start);i.intro.length&&o.advance(i.intro),i.edited?o.addEdit(n,i.content,a,i.storeName?r.indexOf(i.original):-1):o.addUneditedChunk(n,i,this.original,a,this.sourcemapLocations),i.outro.length&&o.advance(i.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?Zm(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 jm(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=Bm(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(Wm(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(l=>{for(let h=l[0];h<l[1];h+=1)o[h]=!0});let s=n.indentStart!==!1;const i=u=>s?`${t}${u}`:(s=!0,u);this.intro=this.intro.replace(r,i);let a=0,c=this.firstChunk;for(;c;){const u=c.end;if(c.edited)o[a]||(c.content=c.content.replace(r,i),c.content.length&&(s=c.content[c.content.length-1]===`
|
|
34
|
+
`));else for(a=c.start;a<u;){if(!o[a]){const l=this.original[a];l===`
|
|
35
|
+
`?s=!0:l!=="\r"&&s&&(s=!1,a===c.start||(this._splitChunk(c,a),c=c.next),c.prependRight(t))}a+=1}a=c.end,c=c.next}return this.outro=this.outro.replace(r,i),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,n){return Pt.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Pt.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Pt.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Pt.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],s=this.byEnd[n],i=o.previous,a=s.next,c=this.byStart[r];if(!c&&s===this.lastChunk)return this;const u=c?c.previous:this.lastChunk;return i&&(i.next=a),a&&(a.previous=i),u&&(u.next=o),c&&(c.previous=s),o.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=o.previous,this.lastChunk.next=null),o.previous=u,s.next=c||null,u||(this.firstChunk=o),c||(this.lastChunk=s),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&&(Pt.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Pt.storeName=!0),o={storeName:!0});const s=o!==void 0?o.storeName:!1,i=o!==void 0?o.overwrite:!1;if(s){const u=this.original.slice(t,n);Object.defineProperty(this.storedNames,u,{writable:!0,value:!0,enumerable:!0})}const a=this.byStart[t],c=this.byEnd[n];if(a){let u=a;for(;u!==c;){if(u.next!==this.byStart[u.end])throw new Error("Cannot overwrite across a split point");u=u.next,u.edit("",!1)}a.edit(r,s,!i)}else{const u=new Jt(t,n,"").edit(r,s);c.next=u,u.previous=c}return this}prepend(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const 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(qt);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(qt),t!==-1)return r.outro.substr(t+1)+n;n=r.outro+n}if(r.content.length>0){if(t=r.content.lastIndexOf(qt),t!==-1)return r.content.substr(t+1)+n;n=r.content+n}if(r.intro.length>0){if(t=r.intro.lastIndexOf(qt),t!==-1)return r.intro.substr(t+1)+n;n=r.intro+n}}while(r=r.previous);return t=this.intro.lastIndexOf(qt),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 s=o;for(;o;){o.intro&&(s!==o||o.start===t)&&(r+=o.intro);const i=o.start<n&&o.end>=n;if(i&&o.edited&&o.end!==n)throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);const a=s===o?t-o.start:0,c=i?o.content.length+n-o.end:o.content.length;if(r+=o.content.slice(a,c),o.outro&&(!i||o.end===n)&&(r+=o.outro),i)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=Rs(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,s=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),s)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,s=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),s)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(s,i){return typeof n=="string"?n.replace(/\$(\$|&|\d+)/g,(a,c)=>c==="$"?"$":c==="&"?s[0]:+c<s.length?s[+c]:`$${c}`):n(...s,s.index,i,s.groups)}function o(s,i){let a;const c=[];for(;a=s.exec(i);)c.push(a);return c}if(t.global)o(t,this.original).forEach(i=>{if(i.index!=null){const a=r(i,this.original);a!==i[0]&&this.overwrite(i.index,i.index+i[0].length,a)}});else{const s=this.original.match(t);if(s&&s.index!=null){const i=r(s,this.original);i!==s[0]&&this.overwrite(s.index,s.index+s[0].length,i)}}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 s=r.indexOf(t);s!==-1;s=r.indexOf(t,s+o))r.slice(s,s+o)!==n&&this.overwrite(s,s+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 ws=M(process.cwd(),"shared/translation.ts"),Cs="globalThis.craneSharedTranslation = translation",Xm=e=>`import translation from '${e}';
|
|
36
|
+
${Cs};
|
|
37
|
+
`,Qm=(e,t)=>{const n=e.split("?")[0],r=ia(n);return(r==="server.ts"||r==="client.ts")&&!t.includes(Cs)},vs=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=Ce(ws)},transform(t,n){if(!e||!Qm(n,t))return null;const r=n.split("?")[0],o=uo(r),s=la(lo(o,ws)),i=Xm(s),a=new so(t);return a.prepend(i),{code:a.toString()}}}},As={[Ue.Server]:()=>[Ye.vue(),Ye.tsconfigPaths(),Um(),xm(),vs()],[Ue.Client]:()=>[Ye.vue(),Ye.tsconfigPaths(),_o({vue:"EcVue"}),vs()],[Ue.Misc]:()=>[Ye.tsconfigPaths()],[Ue.Layout]:()=>[Ye.vue(),Ye.tsconfigPaths(),_o({vue:["EcExternals","Vue"]})],[Ue.Asset]:()=>[Fm()],[Ue.SharedFiles]:()=>[Ye.tsconfigPaths()]},Is={[le.Server]:_s({outDir:({name:e,sectionType:t})=>`./${se[t].dist}/${e}/js/main/server`}),[le.Client]:ys({outDir:({name:e,sectionType:t})=>`./${se[t].dist}/${e}/js/main/client`}),[le.SectionSetting]:xt({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${se[t].dist}/${e}/js/settings`}),[le.SectionShowcase]:xt({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${se[t].dist}/${e}/js/showcases`}),[le.SectionAsset]:On({outDir:({name:e,sectionType:t})=>`./${se[t].dist}/${e}/assets`}),[le.TemplateDescriptor]:xt({entryFileNames:"[name].mjs",outDir:()=>`./${Fe}/js`}),[le.PageTemplateDescriptor]:xt({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Fe}/${e}`}),[le.TemplateAsset]:On({outDir:()=>`./${Fe}/assets`}),[le.Layout]:Im({outDir:({name:e,sectionId:t})=>`./${Ae}/${t}/${e}`}),[le.LayoutSettings]:xt({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${Ae}/${t}/${e}/js/settings`}),[le.LayoutAsset]:On({outDir:({name:e,sectionId:t})=>`./${Ae}/${t}/${e}/assets`}),[le.SlotServer]:_s({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Ae}/${n}/${t}/slots/${e}/js/main/server`}),[le.SlotClient]:ys({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Ae}/${n}/${t}/slots/${e}/js/main/client`}),[le.CollectionDescriptor]:xt({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${on}/${e}`}),[le.CollectionAsset]:On({outDir:()=>`./${on}/assets`}),[le.SharedTranslation]:{pluginType:Ue.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function qm(e){switch(typeof e){case"string":return[M(process.cwd(),e)];case"object":return e.map(t=>M(process.cwd(),t));default:return[]}}function Os({name:e,entryPoints:t,configType:n,layoutId:r,sectionId:o,sectionType:s=ve.SECTION}){const i=Is[n],a=i.define,c=i.ssrOptions,u=i.entryFileNames,l=i.chunkFileNames,h=i.assetFileNames,d=i.inlineDynamicImports,b=i.externalOption;return{logLevel:xr()?void 0:"silent",plugins:As[i.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:i.ssr,outDir:i.outDir({name:e,sectionType:s,layoutId:r,sectionId:o}),emptyOutDir:!0,minify:"esbuild",rollupOptions:{external:b,preserveEntrySignatures:"strict",input:qm(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:d,entryFileNames:u,chunkFileNames:l,assetFileNames:h}}},assetsInclude:["**/*.json"]}}const Jm=Object.values(se).map(e=>e.source).join("|");function bs(e,t,n){if(!e)return`${t}.mjs`;const r=lo(process.cwd(),e).replace(/\\/g,"/").match(`^(${Jm})/([^/]+)/${n}/([^/.]+)`);return r?`${r[1]}/${r[2]}/js/${n}/${r[3]}.mjs`:`${t}.mjs`}function $s(e,t){const n=Is[le.SectionSetting];return{logLevel:xr()?void 0:"silent",plugins:As[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=>M(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 eE(e){return $s(e,t=>bs(t.facadeModuleId??void 0,t.name,"settings"))}function tE(e){return $s(e,t=>bs(t.facadeModuleId??void 0,t.name,"showcases"))}async function nE(){const e={ignore:["node_modules/**","dist/**"]},t=await F(`./${Rt}/{product,category,catalog}/*/Main.vue`,e);return await Promise.all(t.map(async n=>{const{id:r,sectionId:o,pageId:s}=ec(n),[i,a]=await Promise.all([F(`./${Rt}/${o}/${r}/settings/{content,design,translations}.{js,ts}`,e),F(`./${Rt}/${o}/${r}/assets/*`,e)]);return{name:r,sectionId:o,pageId:s,clientEntrypoint:n,settingsEntryPoints:i,assetsEntrypoints:a}}))}async function rE(e){await He({entryPoints:[e.clientEntrypoint],configType:le.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([He({entryPoints:e.settingsEntryPoints,configType:le.LayoutSettings,name:e.name,sectionId:e.sectionId}),He({entryPoints:e.assetsEntrypoints,configType:le.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function oE(e){e===void 0||e.length===0||await Promise.all(e.map(t=>rE(t)))}async function iE(e){const t=e.flatMap(r=>r.settingsEntryPoints),n=e.flatMap(r=>r.showcaseEntryPoints);t.length>0&&await rt({configFile:!1,...nn(eE(t))}),n.length>0&&await rt({configFile:!1,...nn(tE(n))})}async function sE(e){await Promise.all([rt({configFile:!1,...nn(Os({name:e.name,entryPoints:e.serverEntrypoint,configType:St.Server,sectionType:e.type}))}),He({entryPoints:e.clientEntrypoint,configType:St.Client,name:e.name,sectionType:e.type}),He({entryPoints:e.assetEntryPoints,configType:St.SectionAsset,name:e.name,sectionType:e.type})])}async function aE(){const e=M(process.cwd(),"shared/translation.ts");Ce(e)&&await He({entryPoints:["shared/translation.ts"],configType:St.SharedTranslation})}async function Ls(e){await Promise.all([iE(e),...e.map(sE)])}async function cE(){const e={ignore:["node_modules/**","dist/**"]},t=await F(`${Rt}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:r,sectionId:o,layoutId:s}=sm(n),i=(await F(`${Rt}/${o}/${s}/slots/${r}/client.{js,ts}`,e))[0];if(i===void 0)throw new Error(`Cannot find client entrypoint file for slot ${r} of section ${o}`);return{id:r,sectionId:o,layoutId:s,serverEntrypoint:n,clientEntrypoint:i}}))}async function uE(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([He({entryPoints:[e.serverEntrypoint],configType:le.SlotServer,...t}),He({entryPoints:[e.clientEntrypoint],configType:le.SlotClient,...t})])}async function lE(e){e?.length&&await Promise.all(e.map(uE))}async function pE(e){return(await F(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(yi).includes(n)})}async function dE(){const e=await F("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(L.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(Fn),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 F(`**/templates/${r}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await F(`**/templates/${r}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await F(`**/templates/${r}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await F(`**/templates/${r}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await F(`**/templates/${r}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await pE(r);return{name:r,configurationEntrypoint:o.at(0),homeEntrypoint:s.at(0),categoryEntrypoint:i.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:u.length>0?u:void 0}}))}async function fE(){const e=await F("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await F("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await dE(),templates:e,assets:t}}async function hE({templateBuildConfig:e}){await Promise.all([He({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 He({entryPoints:n,configType:St.PageTemplateDescriptor,name:t.name})})||[]])}async function mE(){const e=await fE();await hE({templateBuildConfig:e})}async function EE(){const e=await F("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(L.error(`Error while getting collection entry points: ${n}`),[])),t=await F("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const r=n.split(Fn),o=r.pop()??"default";if(r.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const s=await F(`**/collections/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:o,configurationEntrypoint:s.at(0),assetsEntrypoints:t}}))}async function gE(){const e=await EE();e.length!==0&&await Promise.all(e.flatMap(t=>[He({entryPoints:t.assetsEntrypoints,configType:le.CollectionAsset,name:t.name}),He({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:le.CollectionDescriptor,name:t.name})]))}function Ns(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 _E(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 yE(e,t=Oe){const n=M(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),r=yo(So.gunzip),o=await re.promises.readFile(n);return{size:(await r(o)).length}}async function SE(e,t=Oe){try{const n=M(process.cwd(),`${t}/${e}/assets/`);return(await F("*",{cwd:n})).map(r=>{const o=M(n,r);return{path:r,size:Ft(o).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Pr(e,t){const n=await ns(e,se[t].dist),r=await kt(e,se[t].dist),o=await is(e,se[t].dist),s=await as(e,se[t].dist),i=await cs(e,se[t].dist),a=await us(e,se[t].dist),c=_E(a),u=await SE(e,se[t].dist),l=await yE(e,se[t].dist),h=ls(e);return{id:e,type:t,name:e,content:o,design:s,layout:c,showcase:i,translationsSettings:n,translationsShowcases:r,assets:u,server:l,previewCount:h}}async function TE(){const e=await F("*/",{cwd:M(process.cwd(),`${Oe}/`)}),t=await F("*/",{cwd:M(process.cwd(),`${Gt}/`)}),n=await F("*/",{cwd:M(process.cwd(),`${Ht}/`)});return Promise.all([...e.map(async r=>Pr(r,Nt.SECTION)),...t.map(async r=>Pr(r,Nt.HEADER)),...n.map(async r=>Pr(r,Nt.FOOTER))])}async function RE(e){try{const t=M(process.cwd(),`${e}/assets/`);return(await F("*",{cwd:t})).map(n=>{const r=M(t,n);return{path:n,size:Ft(r).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function wE(e){const t=wt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,r]=t,[o,s,i,a]=await Promise.all([vE(r,n),AE(r,n),rs(r,n),RE(e)]);return{id:r,sectionId:n,content:o,design:s,translationsSettings:i,assets:a}}async function CE(){const e=`${Ae}/{product,catalog,category}/*`,t=await F(e,{ignore:["node_modules/**"]});return Promise.all(t.map(wE))}async function vE(e,t){try{const n=M(process.cwd(),`${Ae}/${t}/${e}/js/settings/content.mjs`),r=await ke(n);return Zt(r)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function AE(e,t){try{const n=M(process.cwd(),`${Ae}/${t}/${e}/js/settings/design.mjs`),r=await ke(n);return Zt(r)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function IE(e,t,n){const r=M(process.cwd(),`${Ae}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),o=yo(So.gunzip),s=await re.promises.readFile(r);return{size:(await o(s)).length}}async function OE(e){const t=wt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,r,,o]=t,s=await IE(o,r,n);return{id:o,sectionId:n,layoutId:r,server:s}}async function bE(){const e=`${Ae}/{product,catalog,category}/*/slots/*`,t=await F(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(OE))}async function $E(){try{const e=M(process.cwd(),`${Fe}/assets/`);return(await F("*",{cwd:e})).map(t=>{const n=M(e,t);return{path:t,size:Ft(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function LE(e){return e in qe?qe[e]:qe.CUSTOM}async function NE(e){const t=await F(`${Fe}/${e}/*.mjs`,{ignore:[`${Fe}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:r,metadata:o}=await Ds(n),s=vo(n);return{type:LE(s.toUpperCase()),id:s,metadata:o,sections:r}}))}async function Ds(e){try{return await ke(M(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function DE(e){const t=await F(`${Fe}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const r=ue.basename(ue.dirname(n));return{id:`${e}_${r}`,assets:await $E(),configuration:await Ds(n),pages:await NE(r)}}))}async function kE(e){return await DE(e)}async function xE(){const e=M(process.cwd(),`${Ba}/translation.mjs`);return await ke(e)}async function PE(){return{translations:await xE()}}async function ME(){const e=await an(),[t,n,r,o,s,i]=await Promise.all([kr(),PE(),TE(),CE(),bE(),kE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:r,templates:i,layouts:o,slots:s,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue}}function UE(e){return Object.entries(se).find(t=>t[1].source===e)?.[0]}async function ks(){const e=await F("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=uo(t).split(Fn),r=n.pop()??"default",o=n.pop();if(o===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const s=["node_modules/**","dist/**"],[i,a,c,u,l,h,d,b]=await Promise.all([F(`**/${r}/client.{js,ts}`,{ignore:s}),F(`**/${r}/settings/content.{js,ts}`,{ignore:s}),F(`**/${r}/settings/design.{js,ts}`,{ignore:s}),F(`**/${r}/settings/layout.{js,ts}`,{ignore:s}),F(`**/${r}/settings/translations.{js,ts}`,{ignore:s}),F(`**/${r}/showcases/*.{js,ts}`,{ignore:[...s,`**/${r}/showcases/translations.{js,ts}`]}),F(`**/${r}/showcases/translations.{js,ts}`,{ignore:s}),F(`**/${r}/assets/*`,{ignore:s})]);return{name:r,type:UE(o),serverEntrypoint:t,clientEntrypoint:i.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 FE=["/settings/","/showcases/"];function zE(e){return FE.some(t=>e.includes(t))}function GE(){const e=Ve.findConfigFile(process.cwd(),Ve.sys.fileExists,"tsconfig.json");if(!e)return;const t=Ve.readConfigFile(e,Ve.sys.readFile),n=Ve.parseJsonConfigFileContent(t.config,Ve.sys,process.cwd()),r=Ve.createProgram(n.fileNames,n.options),o=Ve.getPreEmitDiagnostics(r).filter(s=>!s.file||!zE(s.file.fileName));if(o.length>0){const s={getCanonicalFileName:i=>i,getCurrentDirectory:Ve.sys.getCurrentDirectory,getNewLine:()=>Ve.sys.newLine};throw console.error(Ve.formatDiagnosticsWithColorAndContext(o,s)),new Error(`TypeScript found ${o.length} error(s)`)}}async function HE(e){GE(),await rt({configFile:!1,logLevel:"error",plugins:[Ye.vue(),Ye.tsconfigPaths(),Ye.checker()],build:{write:!1,rollupOptions:{input:M(process.cwd(),e)}}})}function jE(){return Promise.all([Un.rm("dist",{recursive:!0,force:!0}),Un.rm("source-code",{recursive:!0,force:!0}),Un.rm("source-code.zip",{force:!0})])}async function BE(){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 F("**/*",{cwd:M(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(s=>{const i=M(process.cwd(),s);e.addLocalFile(i,po(s).dir)});const r=Bt[J.SourceCode].fileName,o=M(process.cwd(),r);await e.writeZipPromise(o)}catch(r){throw L.error("Error while zipping source files"),r}}async function $n(e=!1,t=!1){Om(t),Ts.start(),await jE();try{const[n,r,o]=await Promise.all([nE(),ks(),cE()]),s=r.map(Ns);r.length>0&&await HE(r[0].serverEntrypoint);try{await Promise.all([aE(),Ls(s),mE(),gE(),oE(n),lE(o),BE()])}finally{Ts.stop()}const i=await ME(),a=await Cm(i);a.errors.length===0?L.info(`Build successful:
|
|
13
38
|
For preview run: npx @lightspeed/crane@latest preview
|
|
14
|
-
For deploy run: npx @lightspeed/crane@latest deploy`)
|
|
39
|
+
For deploy run: npx @lightspeed/crane@latest deploy`):(L.error("Invalid configuration detected:"),wm(a))}catch(n){L.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function He({entryPoints:e,configType:t,name:n,sectionType:r,sectionId:o,layoutId:s}){if(e.length!==0){const i=nn(Os({name:n,entryPoints:e,configType:t,sectionType:r,sectionId:o,layoutId:s}));await rt({configFile:!1,...i})}}function ZE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mr={},xs;function Ur(){return xs||(xs=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 s=0;s<o.length;s++){const i=o[s];if(Array.isArray(i)){r(i);continue}i!==void 0&&n.push(i)}return n};return r(t),n}})(Mr)),Mr}var Fr,Ps;function zr(){if(Ps)return Fr;Ps=1;const e=Ur();return Fr=(t,n={})=>{const r=(o,s={})=>{const i=n.escapeInvalid&&e.isInvalidBrace(s),a=o.invalid===!0&&n.escapeInvalid===!0;let c="";if(o.value)return(i||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}/*!
|
|
15
40
|
* is-number <https://github.com/jonschlinkert/is-number>
|
|
16
41
|
*
|
|
17
42
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
18
43
|
* Released under the MIT License.
|
|
19
|
-
*/var
|
|
44
|
+
*/var Gr,Ms;function VE(){return Ms||(Ms=1,Gr=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}),Gr}/*!
|
|
20
45
|
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
21
46
|
*
|
|
22
47
|
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
23
48
|
* Released under the MIT License.
|
|
24
|
-
*/var
|
|
49
|
+
*/var Hr,Us;function WE(){if(Us)return Hr;Us=1;const e=VE(),t=(w,T,D)=>{if(e(w)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(T===void 0||w===T)return String(w);if(e(T)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let p={relaxZeros:!0,...D};typeof p.strictZeros=="boolean"&&(p.relaxZeros=p.strictZeros===!1);let S=String(p.relaxZeros),m=String(p.shorthand),A=String(p.capture),y=String(p.wrap),N=w+":"+T+"="+S+m+A+y;if(t.cache.hasOwnProperty(N))return t.cache[N].result;let x=Math.min(w,T),G=Math.max(w,T);if(Math.abs(x-G)===1){let V=w+"|"+T;return p.capture?`(${V})`:p.wrap===!1?V:`(?:${V})`}let Y=O(w)||O(T),H={min:w,max:T,a:x,b:G},C=[],q=[];if(Y&&(H.isPadded=Y,H.maxLen=String(H.max).length),x<0){let V=G<0?Math.abs(G):1;q=s(V,Math.abs(x),H,p),x=H.a=0}return G>=0&&(C=s(x,G,H,p)),H.negatives=q,H.positives=C,H.result=n(q,C),p.capture===!0?H.result=`(${H.result})`:p.wrap!==!1&&C.length+q.length>1&&(H.result=`(?:${H.result})`),t.cache[N]=H,H.result};function n(w,T,D){let p=i(w,T,"-",!1)||[],S=i(T,w,"",!1)||[],m=i(w,T,"-?",!0)||[];return p.concat(m).concat(S).join("|")}function r(w,T){let D=1,p=1,S=l(w,D),m=new Set([T]);for(;w<=S&&S<=T;)m.add(S),D+=1,S=l(w,D);for(S=h(T+1,p)-1;w<S&&S<=T;)m.add(S),p+=1,S=h(T+1,p)-1;return m=[...m],m.sort(c),m}function o(w,T,D){if(w===T)return{pattern:w,count:[],digits:0};let p=a(w,T),S=p.length,m="",A=0;for(let y=0;y<S;y++){let[N,x]=p[y];N===x?m+=N:N!=="0"||x!=="9"?m+=b(N,x):A++}return A&&(m+=D.shorthand===!0?"\\d":"[0-9]"),{pattern:m,count:[A],digits:S}}function s(w,T,D,p){let S=r(w,T),m=[],A=w,y;for(let N=0;N<S.length;N++){let x=S[N],G=o(String(A),String(x),p),Y="";if(!D.isPadded&&y&&y.pattern===G.pattern){y.count.length>1&&y.count.pop(),y.count.push(G.count[0]),y.string=y.pattern+d(y.count),A=x+1;continue}D.isPadded&&(Y=Z(x,D,p)),G.string=Y+G.pattern+d(G.count),m.push(G),A=x+1,y=G}return m}function i(w,T,D,p,S){let m=[];for(let A of w){let{string:y}=A;!p&&!u(T,"string",y)&&m.push(D+y),p&&u(T,"string",y)&&m.push(D+y)}return m}function a(w,T){let D=[];for(let p=0;p<w.length;p++)D.push([w[p],T[p]]);return D}function c(w,T){return w>T?1:T>w?-1:0}function u(w,T,D){return w.some(p=>p[T]===D)}function l(w,T){return Number(String(w).slice(0,-T)+"9".repeat(T))}function h(w,T){return w-w%Math.pow(10,T)}function d(w){let[T=0,D=""]=w;return D||T>1?`{${T+(D?","+D:"")}}`:""}function b(w,T,D){return`[${w}${T-w===1?"":"-"}${T}]`}function O(w){return/^-?(0+)\d/.test(w)}function Z(w,T,D){if(!T.isPadded)return w;let p=Math.abs(T.maxLen-String(w).length),S=D.relaxZeros!==!1;switch(p){case 0:return"";case 1:return S?"0?":"0";case 2:return S?"0{0,2}":"00";default:return S?`0{0,${p}}`:`0{${p}}`}}return t.cache={},t.clearCache=()=>t.cache={},Hr=t,Hr}/*!
|
|
25
50
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
26
51
|
*
|
|
27
52
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
28
53
|
* Licensed under the MIT License.
|
|
29
|
-
*/var
|
|
30
|
-
`,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"}),zt}var Kt,Hr;function tp(){if(Hr)return Kt;Hr=1;const e=Ht(),{MAX_LENGTH:t,CHAR_BACKSLASH:n,CHAR_BACKTICK:o,CHAR_COMMA:s,CHAR_DOT:i,CHAR_LEFT_PARENTHESES:r,CHAR_RIGHT_PARENTHESES:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_RIGHT_CURLY_BRACE:l,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_RIGHT_SQUARE_BRACKET:E,CHAR_DOUBLE_QUOTE:u,CHAR_SINGLE_QUOTE:L,CHAR_NO_BREAK_SPACE:O,CHAR_ZERO_WIDTH_NOBREAK_SPACE:B}=ep();return Kt=($,R={})=>{if(typeof $!="string")throw new TypeError("Expected a string");const p=R||{},b=typeof p.maxLength=="number"?Math.min(t,p.maxLength):t;if($.length>b)throw new SyntaxError(`Input length (${$.length}), exceeds max characters (${b})`);const m={type:"root",input:$,nodes:[]},w=[m];let g=m,A=m,v=0;const x=$.length;let H=0,N=0,S;const q=()=>$[H++],k=M=>{if(M.type==="text"&&A.type==="dot"&&(A.type="text"),A&&A.type==="text"&&M.type==="text"){A.value+=M.value;return}return g.nodes.push(M),M.parent=g,M.prev=A,A=M,M};for(k({type:"bos"});H<x;)if(g=w[w.length-1],S=q(),!(S===B||S===O)){if(S===n){k({type:"text",value:(R.keepEscaping?S:"")+q()});continue}if(S===E){k({type:"text",value:"\\"+S});continue}if(S===f){v++;let M;for(;H<x&&(M=q());){if(S+=M,M===f){v++;continue}if(M===n){S+=q();continue}if(M===E&&(v--,v===0))break}k({type:"text",value:S});continue}if(S===r){g=k({type:"paren",nodes:[]}),w.push(g),k({type:"text",value:S});continue}if(S===a){if(g.type!=="paren"){k({type:"text",value:S});continue}g=w.pop(),k({type:"text",value:S}),g=w[w.length-1];continue}if(S===u||S===L||S===o){const M=S;let P;for(R.keepQuotes!==!0&&(S="");H<x&&(P=q());){if(P===n){S+=P+q();continue}if(P===M){R.keepQuotes===!0&&(S+=P);break}S+=P}k({type:"text",value:S});continue}if(S===c){N++;const P={type:"brace",open:!0,close:!1,dollar:A.value&&A.value.slice(-1)==="$"||g.dollar===!0,depth:N,commas:0,ranges:0,nodes:[]};g=k(P),w.push(g),k({type:"open",value:S});continue}if(S===l){if(g.type!=="brace"){k({type:"text",value:S});continue}const M="close";g=w.pop(),g.close=!0,k({type:M,value:S}),N--,g=w[w.length-1];continue}if(S===s&&N>0){if(g.ranges>0){g.ranges=0;const M=g.nodes.shift();g.nodes=[M,{type:"text",value:e(g)}]}k({type:"comma",value:S}),g.commas++;continue}if(S===i&&N>0&&g.commas===0){const M=g.nodes;if(N===0||M.length===0){k({type:"text",value:S});continue}if(A.type==="dot"){if(g.range=[],A.value+=S,A.type="range",g.nodes.length!==3&&g.nodes.length!==5){g.invalid=!0,g.ranges=0,A.type="text";continue}g.ranges++,g.args=[];continue}if(A.type==="range"){M.pop();const P=M[M.length-1];P.value+=A.value+S,A=P,g.ranges--;continue}k({type:"dot",value:S});continue}k({type:"text",value:S})}do if(g=w.pop(),g.type!=="root"){g.nodes.forEach(Z=>{Z.nodes||(Z.type==="open"&&(Z.isOpen=!0),Z.type==="close"&&(Z.isClose=!0),Z.nodes||(Z.type="text"),Z.invalid=!0)});const M=w[w.length-1],P=M.nodes.indexOf(g);M.nodes.splice(P,1,...g.nodes)}while(w.length>0);return k({type:"eos"}),m},Kt}var Xt,Mr;function np(){if(Mr)return Xt;Mr=1;const e=Ht(),t=Ql(),n=Jl(),o=tp(),s=(i,r={})=>{let a=[];if(Array.isArray(i))for(const c of i){const l=s.create(c,r);Array.isArray(l)?a.push(...l):a.push(l)}else a=[].concat(s.create(i,r));return r&&r.expand===!0&&r.nodupes===!0&&(a=[...new Set(a)]),a};return s.parse=(i,r={})=>o(i,r),s.stringify=(i,r={})=>e(typeof i=="string"?s.parse(i,r):i,r),s.compile=(i,r={})=>(typeof i=="string"&&(i=s.parse(i,r)),t(i,r)),s.expand=(i,r={})=>{typeof i=="string"&&(i=s.parse(i,r));let a=n(i,r);return r.noempty===!0&&(a=a.filter(Boolean)),r.nodupes===!0&&(a=[...new Set(a)]),a},s.create=(i,r={})=>i===""||i.length<3?[i]:r.expand!==!0?s.compile(i,r):s.expand(i,r),Xt=s,Xt}var Vt={},Wt,Gr;function ht(){if(Gr)return Wt;Gr=1;const e=W,t="\\\\/",n=`[^${t}]`,o="\\.",s="\\+",i="\\?",r="\\/",a="(?=.)",c="[^/]",l=`(?:${r}|$)`,f=`(?:^|${r})`,E=`${o}{1,2}${l}`,u=`(?!${o})`,L=`(?!${f}${E})`,O=`(?!${o}{0,1}${l})`,B=`(?!${E})`,_=`[^.${r}]`,$=`${c}*?`,R={DOT_LITERAL:o,PLUS_LITERAL:s,QMARK_LITERAL:i,SLASH_LITERAL:r,ONE_CHAR:a,QMARK:c,END_ANCHOR:l,DOTS_SLASH:E,NO_DOT:u,NO_DOTS:L,NO_DOT_SLASH:O,NO_DOTS_SLASH:B,QMARK_NO_DOT:_,STAR:$,START_ANCHOR:f},p={...R,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}]|$)`},b={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 Wt={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:b,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:R}},Wt}var Br;function mt(){return Br||(Br=1,(function(e){const t=W,n=process.platform==="win32",{REGEX_BACKSLASH:o,REGEX_REMOVE_BACKSLASH:s,REGEX_SPECIAL_CHARS:i,REGEX_SPECIAL_CHARS_GLOBAL:r}=ht();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(r,"\\$1"),e.toPosixSlashes=a=>a.replace(o,"/"),e.removeBackslashes=a=>a.replace(s,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,l)=>{const f=a.lastIndexOf(c,l);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 l=a;return l.startsWith("./")&&(l=l.slice(2),c.prefix="./"),l},e.wrapOutput=(a,c={},l={})=>{const f=l.contains?"":"^",E=l.contains?"":"$";let u=`${f}(?:${a})${E}`;return c.negated===!0&&(u=`(?:^(?!${u}).*$)`),u}})(Vt)),Vt}var Yt,qr;function op(){if(qr)return Yt;qr=1;const e=mt(),{CHAR_ASTERISK:t,CHAR_AT:n,CHAR_BACKWARD_SLASH:o,CHAR_COMMA:s,CHAR_DOT:i,CHAR_EXCLAMATION_MARK:r,CHAR_FORWARD_SLASH:a,CHAR_LEFT_CURLY_BRACE:c,CHAR_LEFT_PARENTHESES:l,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:E,CHAR_QUESTION_MARK:u,CHAR_RIGHT_CURLY_BRACE:L,CHAR_RIGHT_PARENTHESES:O,CHAR_RIGHT_SQUARE_BRACKET:B}=ht(),_=p=>p===a||p===o,$=p=>{p.isPrefix!==!0&&(p.depth=p.isGlobstar?1/0:1)};return Yt=(p,b)=>{const m=b||{},w=p.length-1,g=m.parts===!0||m.scanToEnd===!0,A=[],v=[],x=[];let H=p,N=-1,S=0,q=0,k=!1,M=!1,P=!1,Z=!1,$e=!1,J=!1,h=!1,fe=!1,Te=!1,pe=!1,d=0,y,F,D={value:"",depth:0,isGlob:!1};const me=()=>N>=w,Ie=()=>H.charCodeAt(N+1),ee=()=>(y=F,H.charCodeAt(++N));for(;N<w;){F=ee();let j;if(F===o){h=D.backslashes=!0,F=ee(),F===c&&(J=!0);continue}if(J===!0||F===c){for(d++;me()!==!0&&(F=ee());){if(F===o){h=D.backslashes=!0,ee();continue}if(F===c){d++;continue}if(J!==!0&&F===i&&(F=ee())===i){if(k=D.isBrace=!0,P=D.isGlob=!0,pe=!0,g===!0)continue;break}if(J!==!0&&F===s){if(k=D.isBrace=!0,P=D.isGlob=!0,pe=!0,g===!0)continue;break}if(F===L&&(d--,d===0)){J=!1,k=D.isBrace=!0,pe=!0;break}}if(g===!0)continue;break}if(F===a){if(A.push(N),v.push(D),D={value:"",depth:0,isGlob:!1},pe===!0)continue;if(y===i&&N===S+1){S+=2;continue}q=N+1;continue}if(m.noext!==!0&&(F===E||F===n||F===t||F===u||F===r)===!0&&Ie()===l){if(P=D.isGlob=!0,Z=D.isExtglob=!0,pe=!0,F===r&&N===S&&(Te=!0),g===!0){for(;me()!==!0&&(F=ee());){if(F===o){h=D.backslashes=!0,F=ee();continue}if(F===O){P=D.isGlob=!0,pe=!0;break}}continue}break}if(F===t){if(y===t&&($e=D.isGlobstar=!0),P=D.isGlob=!0,pe=!0,g===!0)continue;break}if(F===u){if(P=D.isGlob=!0,pe=!0,g===!0)continue;break}if(F===f){for(;me()!==!0&&(j=ee());){if(j===o){h=D.backslashes=!0,ee();continue}if(j===B){M=D.isBracket=!0,P=D.isGlob=!0,pe=!0;break}}if(g===!0)continue;break}if(m.nonegate!==!0&&F===r&&N===S){fe=D.negated=!0,S++;continue}if(m.noparen!==!0&&F===l){if(P=D.isGlob=!0,g===!0){for(;me()!==!0&&(F=ee());){if(F===l){h=D.backslashes=!0,F=ee();continue}if(F===O){pe=!0;break}}continue}break}if(P===!0){if(pe=!0,g===!0)continue;break}}m.noext===!0&&(Z=!1,P=!1);let te=H,Ze="",we="";S>0&&(Ze=H.slice(0,S),H=H.slice(S),q-=S),te&&P===!0&&q>0?(te=H.slice(0,q),we=H.slice(q)):P===!0?(te="",we=H):te=H,te&&te!==""&&te!=="/"&&te!==H&&_(te.charCodeAt(te.length-1))&&(te=te.slice(0,-1)),m.unescape===!0&&(we&&(we=e.removeBackslashes(we)),te&&h===!0&&(te=e.removeBackslashes(te)));const de={prefix:Ze,input:p,start:S,base:te,glob:we,isBrace:k,isBracket:M,isGlob:P,isExtglob:Z,isGlobstar:$e,negated:fe,negatedExtglob:Te};if(m.tokens===!0&&(de.maxDepth=0,_(F)||v.push(D),de.tokens=v),m.parts===!0||m.tokens===!0){let j;for(let ne=0;ne<A.length;ne++){const Et=j?j+1:S,C=A[ne],X=p.slice(Et,C);m.tokens&&(ne===0&&S!==0?(v[ne].isPrefix=!0,v[ne].value=Ze):v[ne].value=X,$(v[ne]),de.maxDepth+=v[ne].depth),(ne!==0||X!=="")&&x.push(X),j=C}if(j&&j+1<p.length){const ne=p.slice(j+1);x.push(ne),m.tokens&&(v[v.length-1].value=ne,$(v[v.length-1]),de.maxDepth+=v[v.length-1].depth)}de.slashes=A,de.parts=x}return de},Yt}var Zt,Ur;function sp(){if(Ur)return Zt;Ur=1;const e=ht(),t=mt(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:o,REGEX_NON_SPECIAL_CHARS:s,REGEX_SPECIAL_CHARS_BACKREF:i,REPLACEMENTS:r}=e,a=(f,E)=>{if(typeof E.expandRange=="function")return E.expandRange(...f,E);f.sort();const u=`[${f.join("-")}]`;try{new RegExp(u)}catch{return f.map(O=>t.escapeRegex(O)).join("..")}return u},c=(f,E)=>`Missing ${f}: "${E}" - use "\\\\${E}" to match literal characters`,l=(f,E)=>{if(typeof f!="string")throw new TypeError("Expected a string");f=r[f]||f;const u={...E},L=typeof u.maxLength=="number"?Math.min(n,u.maxLength):n;let O=f.length;if(O>L)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${L}`);const B={type:"bos",value:"",output:u.prepend||""},_=[B],$=u.capture?"":"?:",R=t.isWindows(E),p=e.globChars(R),b=e.extglobChars(p),{DOT_LITERAL:m,PLUS_LITERAL:w,SLASH_LITERAL:g,ONE_CHAR:A,DOTS_SLASH:v,NO_DOT:x,NO_DOT_SLASH:H,NO_DOTS_SLASH:N,QMARK:S,QMARK_NO_DOT:q,STAR:k,START_ANCHOR:M}=p,P=C=>`(${$}(?:(?!${M}${C.dot?v:m}).)*?)`,Z=u.dot?"":x,$e=u.dot?S:q;let J=u.bash===!0?P(u):k;u.capture&&(J=`(${J})`),typeof u.noext=="boolean"&&(u.noextglob=u.noext);const h={input:f,index:-1,start:0,dot:u.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:_};f=t.removePrefix(f,h),O=f.length;const fe=[],Te=[],pe=[];let d=B,y;const F=()=>h.index===O-1,D=h.peek=(C=1)=>f[h.index+C],me=h.advance=()=>f[++h.index]||"",Ie=()=>f.slice(h.index+1),ee=(C="",X=0)=>{h.consumed+=C,h.index+=X},te=C=>{h.output+=C.output!=null?C.output:C.value,ee(C.value)},Ze=()=>{let C=1;for(;D()==="!"&&(D(2)!=="("||D(3)==="?");)me(),h.start++,C++;return C%2===0?!1:(h.negated=!0,h.start++,!0)},we=C=>{h[C]++,pe.push(C)},de=C=>{h[C]--,pe.pop()},j=C=>{if(d.type==="globstar"){const X=h.braces>0&&(C.type==="comma"||C.type==="brace"),T=C.extglob===!0||fe.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!X&&!T&&(h.output=h.output.slice(0,-d.output.length),d.type="star",d.value="*",d.output=J,h.output+=d.output)}if(fe.length&&C.type!=="paren"&&(fe[fe.length-1].inner+=C.value),(C.value||C.output)&&te(C),d&&d.type==="text"&&C.type==="text"){d.value+=C.value,d.output=(d.output||"")+C.value;return}C.prev=d,_.push(C),d=C},ne=(C,X)=>{const T={...b[X],conditions:1,inner:""};T.prev=d,T.parens=h.parens,T.output=h.output;const G=(u.capture?"(":"")+T.open;we("parens"),j({type:C,value:X,output:h.output?"":A}),j({type:"paren",extglob:!0,value:me(),output:G}),fe.push(T)},Et=C=>{let X=C.close+(u.capture?")":""),T;if(C.type==="negate"){let G=J;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=P(u)),(G!==J||F()||/^\)+$/.test(Ie()))&&(X=C.close=`)$))${G}`),C.inner.includes("*")&&(T=Ie())&&/^\.[^\\/.]+$/.test(T)){const Q=l(T,{...E,fastpaths:!1}).output;X=C.close=`)${Q})${G})`}C.prev.type==="bos"&&(h.negatedExtglob=!0)}j({type:"paren",extglob:!0,value:y,output:X}),de("parens")};if(u.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(f)){let C=!1,X=f.replace(i,(T,G,Q,he,oe,bt)=>he==="\\"?(C=!0,T):he==="?"?G?G+he+(oe?S.repeat(oe.length):""):bt===0?$e+(oe?S.repeat(oe.length):""):S.repeat(Q.length):he==="."?m.repeat(Q.length):he==="*"?G?G+he+(oe?J:""):J:G?T:`\\${T}`);return C===!0&&(u.unescape===!0?X=X.replace(/\\/g,""):X=X.replace(/\\+/g,T=>T.length%2===0?"\\\\":T?"\\":"")),X===f&&u.contains===!0?(h.output=f,h):(h.output=t.wrapOutput(X,h,E),h)}for(;!F();){if(y=me(),y==="\0")continue;if(y==="\\"){const T=D();if(T==="/"&&u.bash!==!0||T==="."||T===";")continue;if(!T){y+="\\",j({type:"text",value:y});continue}const G=/^\\+/.exec(Ie());let Q=0;if(G&&G[0].length>2&&(Q=G[0].length,h.index+=Q,Q%2!==0&&(y+="\\")),u.unescape===!0?y=me():y+=me(),h.brackets===0){j({type:"text",value:y});continue}}if(h.brackets>0&&(y!=="]"||d.value==="["||d.value==="[^")){if(u.posix!==!1&&y===":"){const T=d.value.slice(1);if(T.includes("[")&&(d.posix=!0,T.includes(":"))){const G=d.value.lastIndexOf("["),Q=d.value.slice(0,G),he=d.value.slice(G+2),oe=o[he];if(oe){d.value=Q+oe,h.backtrack=!0,me(),!B.output&&_.indexOf(d)===1&&(B.output=A);continue}}}(y==="["&&D()!==":"||y==="-"&&D()==="]")&&(y=`\\${y}`),y==="]"&&(d.value==="["||d.value==="[^")&&(y=`\\${y}`),u.posix===!0&&y==="!"&&d.value==="["&&(y="^"),d.value+=y,te({value:y});continue}if(h.quotes===1&&y!=='"'){y=t.escapeRegex(y),d.value+=y,te({value:y});continue}if(y==='"'){h.quotes=h.quotes===1?0:1,u.keepQuotes===!0&&j({type:"text",value:y});continue}if(y==="("){we("parens"),j({type:"paren",value:y});continue}if(y===")"){if(h.parens===0&&u.strictBrackets===!0)throw new SyntaxError(c("opening","("));const T=fe[fe.length-1];if(T&&h.parens===T.parens+1){Et(fe.pop());continue}j({type:"paren",value:y,output:h.parens?")":"\\)"}),de("parens");continue}if(y==="["){if(u.nobracket===!0||!Ie().includes("]")){if(u.nobracket!==!0&&u.strictBrackets===!0)throw new SyntaxError(c("closing","]"));y=`\\${y}`}else we("brackets");j({type:"bracket",value:y});continue}if(y==="]"){if(u.nobracket===!0||d&&d.type==="bracket"&&d.value.length===1){j({type:"text",value:y,output:`\\${y}`});continue}if(h.brackets===0){if(u.strictBrackets===!0)throw new SyntaxError(c("opening","["));j({type:"text",value:y,output:`\\${y}`});continue}de("brackets");const T=d.value.slice(1);if(d.posix!==!0&&T[0]==="^"&&!T.includes("/")&&(y=`/${y}`),d.value+=y,te({value:y}),u.literalBrackets===!1||t.hasRegexChars(T))continue;const G=t.escapeRegex(d.value);if(h.output=h.output.slice(0,-d.value.length),u.literalBrackets===!0){h.output+=G,d.value=G;continue}d.value=`(${$}${G}|${d.value})`,h.output+=d.value;continue}if(y==="{"&&u.nobrace!==!0){we("braces");const T={type:"brace",value:y,output:"(",outputIndex:h.output.length,tokensIndex:h.tokens.length};Te.push(T),j(T);continue}if(y==="}"){const T=Te[Te.length-1];if(u.nobrace===!0||!T){j({type:"text",value:y,output:y});continue}let G=")";if(T.dots===!0){const Q=_.slice(),he=[];for(let oe=Q.length-1;oe>=0&&(_.pop(),Q[oe].type!=="brace");oe--)Q[oe].type!=="dots"&&he.unshift(Q[oe].value);G=a(he,u),h.backtrack=!0}if(T.comma!==!0&&T.dots!==!0){const Q=h.output.slice(0,T.outputIndex),he=h.tokens.slice(T.tokensIndex);T.value=T.output="\\{",y=G="\\}",h.output=Q;for(const oe of he)h.output+=oe.output||oe.value}j({type:"brace",value:y,output:G}),de("braces"),Te.pop();continue}if(y==="|"){fe.length>0&&fe[fe.length-1].conditions++,j({type:"text",value:y});continue}if(y===","){let T=y;const G=Te[Te.length-1];G&&pe[pe.length-1]==="braces"&&(G.comma=!0,T="|"),j({type:"comma",value:y,output:T});continue}if(y==="/"){if(d.type==="dot"&&h.index===h.start+1){h.start=h.index+1,h.consumed="",h.output="",_.pop(),d=B;continue}j({type:"slash",value:y,output:g});continue}if(y==="."){if(h.braces>0&&d.type==="dot"){d.value==="."&&(d.output=m);const T=Te[Te.length-1];d.type="dots",d.output+=y,d.value+=y,T.dots=!0;continue}if(h.braces+h.parens===0&&d.type!=="bos"&&d.type!=="slash"){j({type:"text",value:y,output:m});continue}j({type:"dot",value:y,output:m});continue}if(y==="?"){if(!(d&&d.value==="(")&&u.noextglob!==!0&&D()==="("&&D(2)!=="?"){ne("qmark",y);continue}if(d&&d.type==="paren"){const G=D();let Q=y;if(G==="<"&&!t.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(d.value==="("&&!/[!=<:]/.test(G)||G==="<"&&!/<([!=]|\w+>)/.test(Ie()))&&(Q=`\\${y}`),j({type:"text",value:y,output:Q});continue}if(u.dot!==!0&&(d.type==="slash"||d.type==="bos")){j({type:"qmark",value:y,output:q});continue}j({type:"qmark",value:y,output:S});continue}if(y==="!"){if(u.noextglob!==!0&&D()==="("&&(D(2)!=="?"||!/[!=<:]/.test(D(3)))){ne("negate",y);continue}if(u.nonegate!==!0&&h.index===0){Ze();continue}}if(y==="+"){if(u.noextglob!==!0&&D()==="("&&D(2)!=="?"){ne("plus",y);continue}if(d&&d.value==="("||u.regex===!1){j({type:"plus",value:y,output:w});continue}if(d&&(d.type==="bracket"||d.type==="paren"||d.type==="brace")||h.parens>0){j({type:"plus",value:y});continue}j({type:"plus",value:w});continue}if(y==="@"){if(u.noextglob!==!0&&D()==="("&&D(2)!=="?"){j({type:"at",extglob:!0,value:y,output:""});continue}j({type:"text",value:y});continue}if(y!=="*"){(y==="$"||y==="^")&&(y=`\\${y}`);const T=s.exec(Ie());T&&(y+=T[0],h.index+=T[0].length),j({type:"text",value:y});continue}if(d&&(d.type==="globstar"||d.star===!0)){d.type="star",d.star=!0,d.value+=y,d.output=J,h.backtrack=!0,h.globstar=!0,ee(y);continue}let C=Ie();if(u.noextglob!==!0&&/^\([^?]/.test(C)){ne("star",y);continue}if(d.type==="star"){if(u.noglobstar===!0){ee(y);continue}const T=d.prev,G=T.prev,Q=T.type==="slash"||T.type==="bos",he=G&&(G.type==="star"||G.type==="globstar");if(u.bash===!0&&(!Q||C[0]&&C[0]!=="/")){j({type:"star",value:y,output:""});continue}const oe=h.braces>0&&(T.type==="comma"||T.type==="brace"),bt=fe.length&&(T.type==="pipe"||T.type==="paren");if(!Q&&T.type!=="paren"&&!oe&&!bt){j({type:"star",value:y,output:""});continue}for(;C.slice(0,3)==="/**";){const at=f[h.index+4];if(at&&at!=="/")break;C=C.slice(3),ee("/**",3)}if(T.type==="bos"&&F()){d.type="globstar",d.value+=y,d.output=P(u),h.output=d.output,h.globstar=!0,ee(y);continue}if(T.type==="slash"&&T.prev.type!=="bos"&&!he&&F()){h.output=h.output.slice(0,-(T.output+d.output).length),T.output=`(?:${T.output}`,d.type="globstar",d.output=P(u)+(u.strictSlashes?")":"|$)"),d.value+=y,h.globstar=!0,h.output+=T.output+d.output,ee(y);continue}if(T.type==="slash"&&T.prev.type!=="bos"&&C[0]==="/"){const at=C[1]!==void 0?"|$":"";h.output=h.output.slice(0,-(T.output+d.output).length),T.output=`(?:${T.output}`,d.type="globstar",d.output=`${P(u)}${g}|${g}${at})`,d.value+=y,h.output+=T.output+d.output,h.globstar=!0,ee(y+me()),j({type:"slash",value:"/",output:""});continue}if(T.type==="bos"&&C[0]==="/"){d.type="globstar",d.value+=y,d.output=`(?:^|${g}|${P(u)}${g})`,h.output=d.output,h.globstar=!0,ee(y+me()),j({type:"slash",value:"/",output:""});continue}h.output=h.output.slice(0,-d.output.length),d.type="globstar",d.output=P(u),d.value+=y,h.output+=d.output,h.globstar=!0,ee(y);continue}const X={type:"star",value:y,output:J};if(u.bash===!0){X.output=".*?",(d.type==="bos"||d.type==="slash")&&(X.output=Z+X.output),j(X);continue}if(d&&(d.type==="bracket"||d.type==="paren")&&u.regex===!0){X.output=y,j(X);continue}(h.index===h.start||d.type==="slash"||d.type==="dot")&&(d.type==="dot"?(h.output+=H,d.output+=H):u.dot===!0?(h.output+=N,d.output+=N):(h.output+=Z,d.output+=Z),D()!=="*"&&(h.output+=A,d.output+=A)),j(X)}for(;h.brackets>0;){if(u.strictBrackets===!0)throw new SyntaxError(c("closing","]"));h.output=t.escapeLast(h.output,"["),de("brackets")}for(;h.parens>0;){if(u.strictBrackets===!0)throw new SyntaxError(c("closing",")"));h.output=t.escapeLast(h.output,"("),de("parens")}for(;h.braces>0;){if(u.strictBrackets===!0)throw new SyntaxError(c("closing","}"));h.output=t.escapeLast(h.output,"{"),de("braces")}if(u.strictSlashes!==!0&&(d.type==="star"||d.type==="bracket")&&j({type:"maybe_slash",value:"",output:`${g}?`}),h.backtrack===!0){h.output="";for(const C of h.tokens)h.output+=C.output!=null?C.output:C.value,C.suffix&&(h.output+=C.suffix)}return h};return l.fastpaths=(f,E)=>{const u={...E},L=typeof u.maxLength=="number"?Math.min(n,u.maxLength):n,O=f.length;if(O>L)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${L}`);f=r[f]||f;const B=t.isWindows(E),{DOT_LITERAL:_,SLASH_LITERAL:$,ONE_CHAR:R,DOTS_SLASH:p,NO_DOT:b,NO_DOTS:m,NO_DOTS_SLASH:w,STAR:g,START_ANCHOR:A}=e.globChars(B),v=u.dot?m:b,x=u.dot?w:b,H=u.capture?"":"?:",N={negated:!1,prefix:""};let S=u.bash===!0?".*?":g;u.capture&&(S=`(${S})`);const q=Z=>Z.noglobstar===!0?S:`(${H}(?:(?!${A}${Z.dot?p:_}).)*?)`,k=Z=>{switch(Z){case"*":return`${v}${R}${S}`;case".*":return`${_}${R}${S}`;case"*.*":return`${v}${S}${_}${R}${S}`;case"*/*":return`${v}${S}${$}${R}${x}${S}`;case"**":return v+q(u);case"**/*":return`(?:${v}${q(u)}${$})?${x}${R}${S}`;case"**/*.*":return`(?:${v}${q(u)}${$})?${x}${S}${_}${R}${S}`;case"**/.*":return`(?:${v}${q(u)}${$})?${_}${R}${S}`;default:{const $e=/^(.*?)\.(\w+)$/.exec(Z);if(!$e)return;const J=k($e[1]);return J?J+_+$e[2]:void 0}}},M=t.removePrefix(f,N);let P=k(M);return P&&u.strictSlashes!==!0&&(P+=`${$}?`),P},Zt=l,Zt}var Qt,zr;function rp(){if(zr)return Qt;zr=1;const e=W,t=op(),n=sp(),o=mt(),s=ht(),i=a=>a&&typeof a=="object"&&!Array.isArray(a),r=(a,c,l=!1)=>{if(Array.isArray(a)){const $=a.map(p=>r(p,c,l));return p=>{for(const b of $){const m=b(p);if(m)return m}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 E=c||{},u=o.isWindows(c),L=f?r.compileRe(a,c):r.makeRe(a,c,!1,!0),O=L.state;delete L.state;let B=()=>!1;if(E.ignore){const $={...c,ignore:null,onMatch:null,onResult:null};B=r(E.ignore,$,l)}const _=($,R=!1)=>{const{isMatch:p,match:b,output:m}=r.test($,L,c,{glob:a,posix:u}),w={glob:a,state:O,regex:L,posix:u,input:$,output:m,match:b,isMatch:p};return typeof E.onResult=="function"&&E.onResult(w),p===!1?(w.isMatch=!1,R?w:!1):B($)?(typeof E.onIgnore=="function"&&E.onIgnore(w),w.isMatch=!1,R?w:!1):(typeof E.onMatch=="function"&&E.onMatch(w),R?w:!0)};return l&&(_.state=O),_};return r.test=(a,c,l,{glob:f,posix:E}={})=>{if(typeof a!="string")throw new TypeError("Expected input to be a string");if(a==="")return{isMatch:!1,output:""};const u=l||{},L=u.format||(E?o.toPosixSlashes:null);let O=a===f,B=O&&L?L(a):a;return O===!1&&(B=L?L(a):a,O=B===f),(O===!1||u.capture===!0)&&(u.matchBase===!0||u.basename===!0?O=r.matchBase(a,c,l,E):O=c.exec(B)),{isMatch:!!O,match:O,output:B}},r.matchBase=(a,c,l,f=o.isWindows(l))=>(c instanceof RegExp?c:r.makeRe(c,l)).test(e.basename(a)),r.isMatch=(a,c,l)=>r(c,l)(a),r.parse=(a,c)=>Array.isArray(a)?a.map(l=>r.parse(l,c)):n(a,{...c,fastpaths:!1}),r.scan=(a,c)=>t(a,c),r.compileRe=(a,c,l=!1,f=!1)=>{if(l===!0)return a.output;const E=c||{},u=E.contains?"":"^",L=E.contains?"":"$";let O=`${u}(?:${a.output})${L}`;a&&a.negated===!0&&(O=`^(?!${O}).*$`);const B=r.toRegex(O,c);return f===!0&&(B.state=a),B},r.makeRe=(a,c={},l=!1,f=!1)=>{if(!a||typeof a!="string")throw new TypeError("Expected a non-empty string");let E={negated:!1,fastpaths:!0};return c.fastpaths!==!1&&(a[0]==="."||a[0]==="*")&&(E.output=n.fastpaths(a,c)),E.output||(E=n(a,c)),r.compileRe(E,c,l,f)},r.toRegex=(a,c)=>{try{const l=c||{};return new RegExp(a,l.flags||(l.nocase?"i":""))}catch(l){if(c&&c.debug===!0)throw l;return/$^/}},r.constants=s,Qt=r,Qt}var Jt,Kr;function ip(){return Kr||(Kr=1,Jt=rp()),Jt}var en,Xr;function ap(){if(Xr)return en;Xr=1;const e=bn,t=np(),n=ip(),o=mt(),s=a=>a===""||a==="./",i=a=>{const c=a.indexOf("{");return c>-1&&a.indexOf("}",c)>-1},r=(a,c,l)=>{c=[].concat(c),a=[].concat(a);let f=new Set,E=new Set,u=new Set,L=0,O=$=>{u.add($.output),l&&l.onResult&&l.onResult($)};for(let $=0;$<c.length;$++){let R=n(String(c[$]),{...l,onResult:O},!0),p=R.state.negated||R.state.negatedExtglob;p&&L++;for(let b of a){let m=R(b,!0);(p?!m.isMatch:m.isMatch)&&(p?f.add(m.output):(f.delete(m.output),E.add(m.output)))}}let _=(L===c.length?[...u]:[...E]).filter($=>!f.has($));if(l&&_.length===0){if(l.failglob===!0)throw new Error(`No matches found for "${c.join(", ")}"`);if(l.nonull===!0||l.nullglob===!0)return l.unescape?c.map($=>$.replace(/\\/g,"")):c}return _};return r.match=r,r.matcher=(a,c)=>n(a,c),r.isMatch=(a,c,l)=>n(c,l)(a),r.any=r.isMatch,r.not=(a,c,l={})=>{c=[].concat(c).map(String);let f=new Set,E=[],u=O=>{l.onResult&&l.onResult(O),E.push(O.output)},L=new Set(r(a,c,{...l,onResult:u}));for(let O of E)L.has(O)||f.add(O);return[...f]},r.contains=(a,c,l)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);if(Array.isArray(c))return c.some(f=>r.contains(a,f,l));if(typeof c=="string"){if(s(a)||s(c))return!1;if(a.includes(c)||a.startsWith("./")&&a.slice(2).includes(c))return!0}return r.isMatch(a,c,{...l,contains:!0})},r.matchKeys=(a,c,l)=>{if(!o.isObject(a))throw new TypeError("Expected the first argument to be an object");let f=r(Object.keys(a),c,l),E={};for(let u of f)E[u]=a[u];return E},r.some=(a,c,l)=>{let f=[].concat(a);for(let E of[].concat(c)){let u=n(String(E),l);if(f.some(L=>u(L)))return!0}return!1},r.every=(a,c,l)=>{let f=[].concat(a);for(let E of[].concat(c)){let u=n(String(E),l);if(!f.every(L=>u(L)))return!1}return!0},r.all=(a,c,l)=>{if(typeof a!="string")throw new TypeError(`Expected a string: "${e.inspect(a)}"`);return[].concat(c).every(f=>n(f,l)(a))},r.capture=(a,c,l)=>{let f=o.isWindows(l),u=n.makeRe(String(a),{...l,capture:!0}).exec(f?o.toPosixSlashes(c):c);if(u)return u.slice(1).map(L=>L===void 0?"":L)},r.makeRe=(...a)=>n.makeRe(...a),r.scan=(...a)=>n.scan(...a),r.parse=(a,c)=>{let l=[];for(let f of[].concat(a||[]))for(let E of t(String(f),c))l.push(n.parse(E,c));return l},r.braces=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return c&&c.nobrace===!0||!i(a)?[a]:t(a,c)},r.braceExpand=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return r.braces(a,{...c,expand:!0})},r.hasBraces=i,en=r,en}var cp=ap();const lp=Wl(cp);function Vr(e,t,n){ct.statSync(e).isDirectory()?(ct.mkdirSync(t,{recursive:!0}),ct.readdirSync(e).forEach(o=>{const s=Oe.resolve(e,o),i=Oe.resolve(t,o);Vr(s,i,n)})):lp.isMatch(e,n)||ct.copyFileSync(e,t)}function Fe(e,t,n,o,s=[]){const i=Oe.join(e,o?.[n]??n);Vr(Oe.join(t,n),i,s)}function pp(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 Ne(e){return ye.resolve(vi(import.meta.url),"../..",e)}function up(){const e=Ne("package.json");return e!==""?JSON.parse(se.readFileSync(e,"utf8")):{}}async function fp(e){try{const t=e,n=ae.cwd(),o=ye.join(n,t),s=["templates","headers","preview","footers","reference","page-templates","layouts"],i={_gitignore:".gitignore"};se.existsSync(o)?(I.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),ae.exit(1)):se.mkdirSync(o);const r=Ne("template");se.readdirSync(r).filter(f=>f!=="package.json").filter(f=>!s.includes(f)).forEach(async f=>Fe(o,r,f,i));const a=JSON.parse(se.readFileSync(ye.join(r,"package.json"),"utf-8"));a.name=e;const c=up();c.version&&(a.dependencies["@lightspeed/crane-api"]=c.dependencies["@lightspeed/crane-api"]),c.dependencies["@lightspeed/eslint-config-crane"]&&(a.dependencies["@lightspeed/eslint-config-crane"]=c.dependencies["@lightspeed/eslint-config-crane"]);const l=ye.join(o,"package.json");se.writeFileSync(l,`${JSON.stringify(a,null,2)}
|
|
31
|
-
`),I.info(`App ${e} created`)}catch(t){I.error(`Error while creating app: ${t.message}`),ae.exit(1)}}function tn(e,t,n,o){try{const s=ae.cwd(),i=W.join(s,t);V.existsSync(i)||V.mkdirSync(i);const r=W.join(s,t,n);V.existsSync(r)?(I.error(`${o} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),ae.exit(1)):V.mkdirSync(r);const a=Ne(e);V.readdirSync(a).forEach(async c=>Fe(r,a,c)),I.info(`${o} ${n} created`)}catch(s){I.error(`Error while creating ${o}: ${s.message}`),ae.exit(1)}}function nn(e){const t=ae.cwd(),n=Ne(`template/${e}`),o=W.join(t,e);V.existsSync(o)||(V.mkdirSync(o),V.readdirSync(n).forEach(async s=>Fe(o,n,s)))}function dp(e,t,n){if(!V.existsSync(n)){V.copyFileSync(t,n);return}const o=V.readFileSync(t),s=V.readFileSync(n);o.equals(s)||I.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`)}function Wr(e,t){const n=V.readdirSync(e,{withFileTypes:!0});V.existsSync(t)||V.mkdirSync(t,{recursive:!0}),n.forEach(o=>{const s=W.join(e,o.name),i=W.join(t,o.name);o.isDirectory()?Wr(s,i):dp(o,s,i)})}function on(){try{const e=ae.cwd(),t=W.join(e,"shared"),n=Ne("template/shared");if(!V.existsSync(n))return;Wr(n,t)}catch(e){I.error(`Error while processing shared folder: ${e.message}`),ae.exit(1)}}async function hp(e){on(),tn("template/sections/example-section","sections",e,"Section")}async function mp(e){on(),tn("template/footers/example-footer","footers",e,"Footer")}async function yp(e){on(),tn("template/headers/example-header","headers",e,"Header")}async function gp(e,t){try{const n=ae.cwd(),o=ye.join(n,"templates"),s=Ne("template/page-templates/example-template/pages");se.existsSync(ye.join(o,e))||(I.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),ae.exit(1)),se.existsSync(ye.join(o,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`),ae.exit(1));const i=se.readFileSync(ye.join(s,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${Ji(t)}'`),r=ye.join(o,e,"pages",`${t}.ts`);se.writeFileSync(r,i),I.info(`Page [${t}.ts] created for template ${e}`)}catch(n){I.error(`Error while creating page: ${n.message}`),ae.exit(1)}}async function $p(){try{const e=ae.cwd(),t=Ne("template/reference"),n=se.readdirSync(t);let o=!1;for(const s of n){const i=ye.join(t,s),r=ye.join(e,s);se.existsSync(r)||se.mkdirSync(r,{recursive:!0});const a=se.readdirSync(i),c=se.readdirSync(r);if(s==="shared"){a.forEach(l=>{Fe(r,i,l)});continue}for(const l of a){if(l==="assets"){Fe(r,i,l);continue}if(c.includes(l)){const{name:f}=await St({type:"text",name:"name",message:`The "${l}" already exists in ${s} directory: provide a new name to keep both or press Esc to skip this one.`});f?(Fe(r,i,l,{[l]:f}),o=!0):I.info(`Skipped: ${l}`)}else Fe(r,i,l)}}I.info("Reference templates have been added to the app"),o&&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}`),ae.exit(1)}}const Ep=["**/example-template/pages/custom.ts"];async function bp(e){const{targetPath:t,renameFiles:n,sourcePath:o,onTemplateCreated:s}=pp(e);try{const i=ae.cwd(),r=ye.join(i,"templates"),a=Ne(o),c=se.readdirSync(a);se.existsSync(r)?se.existsSync(ye.join(r,t))&&(I.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),ae.exit(1)):se.mkdirSync(r),c.forEach(l=>Fe(r,a,l,n,Ep)),nn("headers"),nn("footers"),nn("layouts"),s()}catch(i){I.error(`Error while creating template descriptors: ${i.message}`),ae.exit(1)}}function yt({deploymentContext:e,sectionType:t=ue.SECTION}){const n=e.pathContext,o=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),s=o===void 0?mn(n.fileName):mn(n.fileName,{cwd:U(process.cwd(),o),ignore:n.ignore});return(n.isSingleton?s.splice(0):s).map(i=>({url:i,sectionType:t,context:e}))}const _p=e=>e.app.sections.flatMap(t=>Bi.flatMap(n=>{const o={config:e,currentSection:t.id,pathContext:We[n]};return yt({deploymentContext:o,sectionType:t.type})})),Sp=e=>zi.flatMap(t=>{const n={config:e,pathContext:We[t]};return yt({deploymentContext:n})}),Tp=e=>e.app.layouts.flatMap(t=>qi.flatMap(n=>{const o={config:e,pathContext:We[n],currentSection:t.sectionId,layoutId:t.id};return yt({deploymentContext:o})})),wp=e=>e.app.slots.flatMap(t=>Ui.flatMap(n=>{const o={config:e,pathContext:We[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return yt({deploymentContext:o})}));async function Yr(e){await new Promise(t=>setTimeout(t,e))}const Cp=e=>`\x1B[32m${e}\x1B[0m`,Ap=(e,t,n,o,s)=>{if(!e.total)return;const{loaded:i}=e,r=(Date.now()-s)/1e3;n.value+=i-o.value,o.value=i,t.update({speed:`${Qe(n.value/r,2)}/s`})},Rp=()=>new xi.SingleBar({format:`|${Cp("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function sn(e){try{return await ve(Oe.resolve(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function Op(e){const t=await z(`${Ce}/js/**.mjs`,{ignore:[`${Ce}/js/**${je}.mjs`]});return Promise.all(t.map(async n=>{const o=await sn(n);return await el(o.sections),{id:`${e}_${Oe.parse(n).name}`,descriptor:o}}))}function vp(e){return e in be?be[e]:be.CUSTOM}async function rn(e,t){const n=e.design?Lt(e.design):void 0,o={...e,design:n??e.design},s=await ft(t);return Be(o,s)}function an(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function Ip(e){if(an(e)){const t=await ot(e.id,ce[De(e.id)].dist);return{...e,showcase_overrides:await rn(e.showcase_overrides,t)}}return e}async function Lp(e){const t=an(e.header)?{...e.header,showcase_overrides:await rn(e.header.showcase_overrides,await ot(e.header.id,ce[De(e.header.id)].dist))}:e.header,n=an(e.footer)?{...e.footer,showcase_overrides:await rn(e.footer.showcase_overrides,await ot(e.footer.id,ce[De(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function jp(e){const t=await Promise.all(e.pages.map(async o=>({...o,sections:await Promise.all(o.sections.map(s=>Ip(s)))}))),n=await Lp(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function xp(e){return Promise.all(e.map(t=>jp(t)))}async function Np(e){const t=await z(`${Ce}/${e}/*.mjs`,{ignore:[`${Ce}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:s}=await sn(n),i=Qi(n);return{type:vp(i.toUpperCase()),id:i,sections:o,metadata:s}}))}async function Pp(e){const t=await z(`${Ce}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const o=Oe.basename(Oe.dirname(n));return{id:`${e}_${o}`,configuration:await sn(n),pages:await Np(o)}}))}async function Dp(e){const t=await Pp(e);return xp(t)}async function kp(e){return[...await Op(e),...await Dp(e)]}const Fp={value:0},Se=Rp();let Zr=Date.now();const Qr=e=>2**e*500;async function Hp(){const e=await _n(U(ie.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function Mp(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function Gp(){const e=U(ie.cwd(),"package.json"),t=await _n(e),n=JSON.parse(t.toString());if(Mp(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}async function Bp(e){const t=ji(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,fn(U(ie.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
32
|
-
`)}function qp(e){return e instanceof Sn&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function Jr(e,t){return e<Gi&&qp(t)}async function ei(e,t,n,o){const s={value:0},i=e.config.app.templates.length>0?ki:Di;return e.config.axios.post(i,{file:si(U(ie.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:r=>Ap(r,Se,Fp,s,Zr)}).then(r=>(Se.increment(),r)).catch(async r=>{if(Jr(o,r))return await Yr(Qr(o)),ei(e,t,n,o+1);throw Se.increment(),r})}function Up(e){return Se.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,o=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return ei(n,t.url,o,0)})}function zp(e){const t=[..._p(e),...Sp(e),...Tp(e),...wp(e)];return Up(t)}function Kp(e){return e.includes(`
|
|
33
|
-
`)}function Xp(e,t,n){return e.split(`
|
|
34
|
-
`).map((o,s)=>s>=n?t+o:o).join(`
|
|
35
|
-
`)}function st(e,t){const n=[];if(e instanceof Sn){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 r=Kp(i.errorMessage)?Xp(i.errorMessage," ",1):i.errorMessage;n.push(` Error Message: ${r}`)}}const o=n.length>0?n.join(`
|
|
36
|
-
`):e?.message??"Unknown error";if(!t||t.length===0)return o;const s=n.length>0?`
|
|
37
|
-
`:" ";return`${t}${s}${o}`}async function ti(e,t=0){const n=e.app.templates.length>0?Hi:Fi;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},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async o=>{if(Jr(t,o))return await Yr(Qr(t)),ti(e,t+1);throw o})}async function Vp(e){try{if(!Vi.some(r=>re(U(ie.cwd(),r))))throw new Error(Ue.INCORRECT_DISTRIBUTION_FOLDER(Xi));const t=e??Pi;I.info("Custom application deployment :: Started");const n=Ii.create({baseURL:t});Li(n,Mi),I.info("Loading configuration files ...");const o=await Promise.all([Hp(),Gp(),Qc(),aa(),al()]).then(async([r,a,c,l,f])=>({axios:n,app:{crane:r,packageJson:a,sections:c,layouts:l,slots:f,templates:await kp(r.appClientId)}}));I.info("Uploading files ..."),Zr=Date.now(),await Promise.all(zp(o)).catch(r=>{Se.stop(),r.response?.status===404?I.error(st(r,Ue.DEPRECATED_VERSION_DEPLOYMENT)):I.error(st(r,Ue.ASSET_FILES_UPLOAD)),ie.exit(1)}).finally(()=>{Se.increment(),Se.stop()}),Se.update({speed:"N/A",status:"Finalising deployment"}),await ti(o).catch(r=>{Se.stop(),r.response?.status===404?I.error(st(r,Ue.DEPRECATED_VERSION_DEPLOYMENT)):I.error(st(r,Ue.MANIFEST_DEPLOYMENT)),ie.exit(1)}).finally(()=>{Se.increment(),Se.stop()});const s=o.app.sections.map(r=>r.id),i=o.app.packageJson.version;I.info("Custom application deployment :: Successful"),I.info(`Current app version: ${i}`),I.info(`Deployed sections: ${s.sort().join(", ")}`),await Bp(o.app.packageJson),o.app.templates.length>0&&I.info(`Deployed templates: ${o.app.templates.map(r=>r.id).sort().join(", ")}`),o.app.slots.length>0&&I.info(`Deployed slots: ${o.app.slots.map(r=>r.id).sort().join(", ")}`)}catch(t){Se.stop(),I.error(st(t,Ue.DEFAULT)),ie.exit(1)}finally{Zc()}}function Wp(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,o)=>{e.moduleGraph.invalidateAll();const s=new gi(t.url||"",`http://${t.headers.host}`);if(s.pathname==="/api/v1/block-config"&&t.method==="GET"){const i=s.searchParams.get("section"),r=s.searchParams.get("type")||"SECTION";if(!i){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}const a=ue[r]||ue.SECTION;try{const c=await dt(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}o()})}}}async function Yp(e,t){const n=U(`${e}/ssr-server.ts`),o=U(t);await qe({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:o,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function Zp(e,t){const n=U(`${e}/shared/preview.ts`),o=U(`${e}/shared/utils.ts`),s=U(`${e}/shared/api-routes.ts`),i=U(t);await qe({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await qe({build:{lib:{entry:o,formats:["es"],fileName:()=>"utils.js"},outDir:i,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await qe({build:{lib:{entry:s,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 Qp(){const e="preview",t=`${e}/shared`,n="vite.config.js",o=`${e}/sections`,s=`${o}/preview.html`;[e,o].forEach(r=>{V.existsSync(r)||V.mkdirSync(r,{recursive:!0})});const i=Ne("template/preview");V.copyFileSync(`${i}/${n}`,`${e}/${n}`),await Yp(i,e),V.copyFileSync(`${i}/sections/preview.html`,s),V.existsSync(t)||V.mkdirSync(t),await Zp(i,t)}function Jp(){return{timeout:null,inProgress:!1,hasPending:!1}}function eu(e,t){const n=async()=>{e.inProgress=!0;try{await Pt(!0),t.ws.send({type:"full-reload",path:"*"})}catch(o){console.error("Build error:",o)}finally{e.inProgress=!1,e.hasPending&&(e.hasPending=!1,setTimeout(()=>n(),0))}};return async()=>{if(e.inProgress){e.hasPending=!0;return}await n()}}function tu(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),o=t.match(/shared\/components/);return!!(n||o)}function nu(e,t){return async n=>{tu(n)&&(e.timeout&&clearTimeout(e.timeout),e.timeout=setTimeout(async()=>{await t()},1e3))}}function ou(e,t){const n=Jp(),o=eu(n,e),s=nu(n,o);e.watcher.add(t),e.watcher.on("add",s),e.watcher.on("change",s),e.watcher.on("unlink",s)}async function su(){const e=W.resolve(process.cwd(),"preview/ssr-server.mjs");if(!V.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";const t=await import(e),{server:n,port:o}=await t.startServer();return{server:n,port:o}}async function ru(){const e=W.resolve(process.cwd(),"preview/vite.config.js"),t=W.resolve(process.cwd(),"/sections/**/*"),n=W.resolve(process.cwd(),"/shared/components/*"),o=await fi({configFile:e,root:process.cwd(),plugins:[Wp()]});return await o.listen(),ou(o,[t,n]),o}async function iu(){await Pt(),await Qp(),console.log(`
|
|
54
|
+
*/var jr,Fs;function zs(){if(Fs)return jr;Fs=1;const e=To,t=WE(),n=p=>p!==null&&typeof p=="object"&&!Array.isArray(p),r=p=>S=>p===!0?Number(S):String(S),o=p=>typeof p=="number"||typeof p=="string"&&p!=="",s=p=>Number.isInteger(+p),i=p=>{let S=`${p}`,m=-1;if(S[0]==="-"&&(S=S.slice(1)),S==="0")return!1;for(;S[++m]==="0";);return m>0},a=(p,S,m)=>typeof p=="string"||typeof S=="string"?!0:m.stringify===!0,c=(p,S,m)=>{if(S>0){let A=p[0]==="-"?"-":"";A&&(p=p.slice(1)),p=A+p.padStart(A?S-1:S,"0")}return m===!1?String(p):p},u=(p,S)=>{let m=p[0]==="-"?"-":"";for(m&&(p=p.slice(1),S--);p.length<S;)p="0"+p;return m?"-"+p:p},l=(p,S,m)=>{p.negatives.sort((G,Y)=>G<Y?-1:G>Y?1:0),p.positives.sort((G,Y)=>G<Y?-1:G>Y?1:0);let A=S.capture?"":"?:",y="",N="",x;return p.positives.length&&(y=p.positives.map(G=>u(String(G),m)).join("|")),p.negatives.length&&(N=`-(${A}${p.negatives.map(G=>u(String(G),m)).join("|")})`),y&&N?x=`${y}|${N}`:x=y||N,S.wrap?`(${A}${x})`:x},h=(p,S,m,A)=>{if(m)return t(p,S,{wrap:!1,...A});let y=String.fromCharCode(p);if(p===S)return y;let N=String.fromCharCode(S);return`[${y}-${N}]`},d=(p,S,m)=>{if(Array.isArray(p)){let A=m.wrap===!0,y=m.capture?"":"?:";return A?`(${y}${p.join("|")})`:p.join("|")}return t(p,S,m)},b=(...p)=>new RangeError("Invalid range arguments: "+e.inspect(...p)),O=(p,S,m)=>{if(m.strictRanges===!0)throw b([p,S]);return[]},Z=(p,S)=>{if(S.strictRanges===!0)throw new TypeError(`Expected step "${p}" to be a number`);return[]},w=(p,S,m=1,A={})=>{let y=Number(p),N=Number(S);if(!Number.isInteger(y)||!Number.isInteger(N)){if(A.strictRanges===!0)throw b([p,S]);return[]}y===0&&(y=0),N===0&&(N=0);let x=y>N,G=String(p),Y=String(S),H=String(m);m=Math.max(Math.abs(m),1);let C=i(G)||i(Y)||i(H),q=C?Math.max(G.length,Y.length,H.length):0,V=C===!1&&a(p,S,A)===!1,X=A.transform||r(V);if(A.toRegex&&m===1)return h(u(p,q),u(S,q),!0,A);let j={negatives:[],positives:[]},ce=g=>j[g<0?"negatives":"positives"].push(Math.abs(g)),Me=[],_e=0;for(;x?y>=N:y<=N;)A.toRegex===!0&&m>1?ce(y):Me.push(c(X(y,_e),q,V)),y=x?y-m:y+m,_e++;return A.toRegex===!0?m>1?l(j,A,q):d(Me,null,{wrap:!1,...A}):Me},T=(p,S,m=1,A={})=>{if(!s(p)&&p.length>1||!s(S)&&S.length>1)return O(p,S,A);let y=A.transform||(V=>String.fromCharCode(V)),N=`${p}`.charCodeAt(0),x=`${S}`.charCodeAt(0),G=N>x,Y=Math.min(N,x),H=Math.max(N,x);if(A.toRegex&&m===1)return h(Y,H,!1,A);let C=[],q=0;for(;G?N>=x:N<=x;)C.push(y(N,q)),N=G?N-m:N+m,q++;return A.toRegex===!0?d(C,null,{wrap:!1,options:A}):C},D=(p,S,m,A={})=>{if(S==null&&o(p))return[p];if(!o(p)||!o(S))return O(p,S,A);if(typeof m=="function")return D(p,S,1,{transform:m});if(n(m))return D(p,S,0,m);let y={...A};return y.capture===!0&&(y.wrap=!0),m=m||y.step||1,s(m)?s(p)&&s(S)?w(p,S,m,y):T(p,S,Math.max(Math.abs(m),1),y):m!=null&&!n(m)?Z(m,y):D(p,S,1,m)};return jr=D,jr}var Br,Gs;function KE(){if(Gs)return Br;Gs=1;const e=zs(),t=Ur();return Br=(r,o={})=>{const s=(i,a={})=>{const c=t.isInvalidBrace(a),u=i.invalid===!0&&o.escapeInvalid===!0,l=c===!0||u===!0,h=o.escapeInvalid===!0?"\\":"";let d="";if(i.isOpen===!0)return h+i.value;if(i.isClose===!0)return console.log("node.isClose",h,i.value),h+i.value;if(i.type==="open")return l?h+i.value:"(";if(i.type==="close")return l?h+i.value:")";if(i.type==="comma")return i.prev.type==="comma"?"":l?i.value:"|";if(i.value)return i.value;if(i.nodes&&i.ranges>0){const b=t.reduce(i.nodes),O=e(...b,{...o,wrap:!1,toRegex:!0,strictZeros:!0});if(O.length!==0)return b.length>1&&O.length>1?`(${O})`:O}if(i.nodes)for(const b of i.nodes)d+=s(b,i);return d};return s(r)},Br}var Zr,Hs;function YE(){if(Hs)return Zr;Hs=1;const e=zs(),t=zr(),n=Ur(),r=(s="",i="",a=!1)=>{const c=[];if(s=[].concat(s),i=[].concat(i),!i.length)return s;if(!s.length)return a?n.flatten(i).map(u=>`{${u}}`):i;for(const u of s)if(Array.isArray(u))for(const l of u)c.push(r(l,i,a));else for(let l of i)a===!0&&typeof l=="string"&&(l=`{${l}}`),c.push(Array.isArray(l)?r(u,l,a):u+l);return n.flatten(c)};return Zr=(s,i={})=>{const a=i.rangeLimit===void 0?1e3:i.rangeLimit,c=(u,l={})=>{u.queue=[];let h=l,d=l.queue;for(;h.type!=="brace"&&h.type!=="root"&&h.parent;)h=h.parent,d=h.queue;if(u.invalid||u.dollar){d.push(r(d.pop(),t(u,i)));return}if(u.type==="brace"&&u.invalid!==!0&&u.nodes.length===2){d.push(r(d.pop(),["{}"]));return}if(u.nodes&&u.ranges>0){const w=n.reduce(u.nodes);if(n.exceedsLimit(...w,i.step,a))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let T=e(...w,i);T.length===0&&(T=t(u,i)),d.push(r(d.pop(),T)),u.nodes=[];return}const b=n.encloseBrace(u);let O=u.queue,Z=u;for(;Z.type!=="brace"&&Z.type!=="root"&&Z.parent;)Z=Z.parent,O=Z.queue;for(let w=0;w<u.nodes.length;w++){const T=u.nodes[w];if(T.type==="comma"&&u.type==="brace"){w===1&&O.push(""),O.push("");continue}if(T.type==="close"){d.push(r(d.pop(),O,b));continue}if(T.value&&T.type!=="open"){O.push(r(O.pop(),T.value));continue}T.nodes&&c(T,u)}return O};return n.flatten(c(s))},Zr}var Vr,js;function XE(){return js||(js=1,Vr={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:`
|
|
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,Bs;function QE(){if(Bs)return Wr;Bs=1;const e=zr(),{MAX_LENGTH:t,CHAR_BACKSLASH:n,CHAR_BACKTICK:r,CHAR_COMMA:o,CHAR_DOT:s,CHAR_LEFT_PARENTHESES:i,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:O,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Z}=XE();return Wr=(T,D={})=>{if(typeof T!="string")throw new TypeError("Expected a string");const p=D||{},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:[]},A=[m];let y=m,N=m,x=0;const G=T.length;let Y=0,H=0,C;const q=()=>T[Y++],V=X=>{if(X.type==="text"&&N.type==="dot"&&(N.type="text"),N&&N.type==="text"&&X.type==="text"){N.value+=X.value;return}return y.nodes.push(X),X.parent=y,X.prev=N,N=X,X};for(V({type:"bos"});Y<G;)if(y=A[A.length-1],C=q(),!(C===Z||C===O)){if(C===n){V({type:"text",value:(D.keepEscaping?C:"")+q()});continue}if(C===h){V({type:"text",value:"\\"+C});continue}if(C===l){x++;let X;for(;Y<G&&(X=q());){if(C+=X,X===l){x++;continue}if(X===n){C+=q();continue}if(X===h&&(x--,x===0))break}V({type:"text",value:C});continue}if(C===i){y=V({type:"paren",nodes:[]}),A.push(y),V({type:"text",value:C});continue}if(C===a){if(y.type!=="paren"){V({type:"text",value:C});continue}y=A.pop(),V({type:"text",value:C}),y=A[A.length-1];continue}if(C===d||C===b||C===r){const X=C;let j;for(D.keepQuotes!==!0&&(C="");Y<G&&(j=q());){if(j===n){C+=j+q();continue}if(j===X){D.keepQuotes===!0&&(C+=j);break}C+=j}V({type:"text",value:C});continue}if(C===c){H++;const j={type:"brace",open:!0,close:!1,dollar:N.value&&N.value.slice(-1)==="$"||y.dollar===!0,depth:H,commas:0,ranges:0,nodes:[]};y=V(j),A.push(y),V({type:"open",value:C});continue}if(C===u){if(y.type!=="brace"){V({type:"text",value:C});continue}const X="close";y=A.pop(),y.close=!0,V({type:X,value:C}),H--,y=A[A.length-1];continue}if(C===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:C}),y.commas++;continue}if(C===s&&H>0&&y.commas===0){const X=y.nodes;if(H===0||X.length===0){V({type:"text",value:C});continue}if(N.type==="dot"){if(y.range=[],N.value+=C,N.type="range",y.nodes.length!==3&&y.nodes.length!==5){y.invalid=!0,y.ranges=0,N.type="text";continue}y.ranges++,y.args=[];continue}if(N.type==="range"){X.pop();const j=X[X.length-1];j.value+=N.value+C,N=j,y.ranges--;continue}V({type:"dot",value:C});continue}V({type:"text",value:C})}do if(y=A.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=A[A.length-1],j=X.nodes.indexOf(y);X.nodes.splice(j,1,...y.nodes)}while(A.length>0);return V({type:"eos"}),m},Wr}var Kr,Zs;function qE(){if(Zs)return Kr;Zs=1;const e=zr(),t=KE(),n=YE(),r=QE(),o=(s,i={})=>{let a=[];if(Array.isArray(s))for(const c of s){const u=o.create(c,i);Array.isArray(u)?a.push(...u):a.push(u)}else a=[].concat(o.create(s,i));return i&&i.expand===!0&&i.nodupes===!0&&(a=[...new Set(a)]),a};return o.parse=(s,i={})=>r(s,i),o.stringify=(s,i={})=>e(typeof s=="string"?o.parse(s,i):s,i),o.compile=(s,i={})=>(typeof s=="string"&&(s=o.parse(s,i)),t(s,i)),o.expand=(s,i={})=>{typeof s=="string"&&(s=o.parse(s,i));let a=n(s,i);return i.noempty===!0&&(a=a.filter(Boolean)),i.nodupes===!0&&(a=[...new Set(a)]),a},o.create=(s,i={})=>s===""||s.length<3?[s]:i.expand!==!0?o.compile(s,i):o.expand(s,i),Kr=o,Kr}var Yr={},Xr,Vs;function Ln(){if(Vs)return Xr;Vs=1;const e=ue,t="\\\\/",n=`[^${t}]`,r="\\.",o="\\+",s="\\?",i="\\/",a="(?=.)",c="[^/]",u=`(?:${i}|$)`,l=`(?:^|${i})`,h=`${r}{1,2}${u}`,d=`(?!${r})`,b=`(?!${l}${h})`,O=`(?!${r}{0,1}${u})`,Z=`(?!${h})`,w=`[^.${i}]`,T=`${c}*?`,D={DOT_LITERAL:r,PLUS_LITERAL:o,QMARK_LITERAL:s,SLASH_LITERAL:i,ONE_CHAR:a,QMARK:c,END_ANCHOR:u,DOTS_SLASH:h,NO_DOT:d,NO_DOTS:b,NO_DOT_SLASH:O,NO_DOTS_SLASH:Z,QMARK_NO_DOT:w,STAR:T,START_ANCHOR:l},p={...D,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:D}},Xr}var Ws;function Nn(){return Ws||(Ws=1,(function(e){const t=ue,n=process.platform==="win32",{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:o,REGEX_SPECIAL_CHARS:s,REGEX_SPECIAL_CHARS_GLOBAL:i}=Ln();e.isObject=a=>a!==null&&typeof a=="object"&&!Array.isArray(a),e.hasRegexChars=a=>s.test(a),e.isRegexChar=a=>a.length===1&&e.hasRegexChars(a),e.escapeRegex=a=>a.replace(i,"\\$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,Ks;function JE(){if(Ks)return Qr;Ks=1;const e=Nn(),{CHAR_ASTERISK:t,CHAR_AT:n,CHAR_BACKWARD_SLASH:r,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:i,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:O,CHAR_RIGHT_SQUARE_BRACKET:Z}=Ln(),w=p=>p===a||p===r,T=p=>{p.isPrefix!==!0&&(p.depth=p.isGlobstar?1/0:1)};return Qr=(p,S)=>{const m=S||{},A=p.length-1,y=m.parts===!0||m.scanToEnd===!0,N=[],x=[],G=[];let Y=p,H=-1,C=0,q=0,V=!1,X=!1,j=!1,ce=!1,Me=!1,_e=!1,g=!1,be=!1,je=!1,Ie=!1,E=0,_,W,B={value:"",depth:0,isGlob:!1};const xe=()=>H>=A,tt=()=>Y.charCodeAt(H+1),ye=()=>(_=W,Y.charCodeAt(++H));for(;H<A;){W=ye();let U;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===s&&(W=ye())===s){if(V=B.isBrace=!0,j=B.isGlob=!0,Ie=!0,y===!0)continue;break}if(_e!==!0&&W===o){if(V=B.isBrace=!0,j=B.isGlob=!0,Ie=!0,y===!0)continue;break}if(W===b&&(E--,E===0)){_e=!1,V=B.isBrace=!0,Ie=!0;break}}if(y===!0)continue;break}if(W===a){if(N.push(H),x.push(B),B={value:"",depth:0,isGlob:!1},Ie===!0)continue;if(_===s&&H===C+1){C+=2;continue}q=H+1;continue}if(m.noext!==!0&&(W===h||W===n||W===t||W===d||W===i)===!0&&tt()===u){if(j=B.isGlob=!0,ce=B.isExtglob=!0,Ie=!0,W===i&&H===C&&(je=!0),y===!0){for(;xe()!==!0&&(W=ye());){if(W===r){g=B.backslashes=!0,W=ye();continue}if(W===O){j=B.isGlob=!0,Ie=!0;break}}continue}break}if(W===t){if(_===t&&(Me=B.isGlobstar=!0),j=B.isGlob=!0,Ie=!0,y===!0)continue;break}if(W===d){if(j=B.isGlob=!0,Ie=!0,y===!0)continue;break}if(W===l){for(;xe()!==!0&&(U=ye());){if(U===r){g=B.backslashes=!0,ye();continue}if(U===Z){X=B.isBracket=!0,j=B.isGlob=!0,Ie=!0;break}}if(y===!0)continue;break}if(m.nonegate!==!0&&W===i&&H===C){be=B.negated=!0,C++;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===O){Ie=!0;break}}continue}break}if(j===!0){if(Ie=!0,y===!0)continue;break}}m.noext===!0&&(ce=!1,j=!1);let Se=Y,Ut="",Be="";C>0&&(Ut=Y.slice(0,C),Y=Y.slice(C),q-=C),Se&&j===!0&&q>0?(Se=Y.slice(0,q),Be=Y.slice(q)):j===!0?(Se="",Be=Y):Se=Y,Se&&Se!==""&&Se!=="/"&&Se!==Y&&w(Se.charCodeAt(Se.length-1))&&(Se=Se.slice(0,-1)),m.unescape===!0&&(Be&&(Be=e.removeBackslashes(Be)),Se&&g===!0&&(Se=e.removeBackslashes(Se)));const $e={prefix:Ut,input:p,start:C,base:Se,glob:Be,isBrace:V,isBracket:X,isGlob:j,isExtglob:ce,isGlobstar:Me,negated:be,negatedExtglob:je};if(m.tokens===!0&&($e.maxDepth=0,w(W)||x.push(B),$e.tokens=x),m.parts===!0||m.tokens===!0){let U;for(let Re=0;Re<N.length;Re++){const Pn=U?U+1:C,$=N[Re],ne=p.slice(Pn,$);m.tokens&&(Re===0&&C!==0?(x[Re].isPrefix=!0,x[Re].value=Ut):x[Re].value=ne,T(x[Re]),$e.maxDepth+=x[Re].depth),(Re!==0||ne!=="")&&G.push(ne),U=$}if(U&&U+1<p.length){const Re=p.slice(U+1);G.push(Re),m.tokens&&(x[x.length-1].value=Re,T(x[x.length-1]),$e.maxDepth+=x[x.length-1].depth)}$e.slashes=N,$e.parts=G}return $e},Qr}var qr,Ys;function eg(){if(Ys)return qr;Ys=1;const e=Ln(),t=Nn(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:r,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:i}=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(O=>t.escapeRegex(O)).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=i[l]||l;const d={...h},b=typeof d.maxLength=="number"?Math.min(n,d.maxLength):n;let O=l.length;if(O>b)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${b}`);const Z={type:"bos",value:"",output:d.prepend||""},w=[Z],T=d.capture?"":"?:",D=t.isWindows(h),p=e.globChars(D),S=e.extglobChars(p),{DOT_LITERAL:m,PLUS_LITERAL:A,SLASH_LITERAL:y,ONE_CHAR:N,DOTS_SLASH:x,NO_DOT:G,NO_DOT_SLASH:Y,NO_DOTS_SLASH:H,QMARK:C,QMARK_NO_DOT:q,STAR:V,START_ANCHOR:X}=p,j=$=>`(${T}(?:(?!${X}${$.dot?x:m}).)*?)`,ce=d.dot?"":G,Me=d.dot?C:q;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:w};l=t.removePrefix(l,g),O=l.length;const be=[],je=[],Ie=[];let E=Z,_;const W=()=>g.index===O-1,B=g.peek=($=1)=>l[g.index+$],xe=g.advance=()=>l[++g.index]||"",tt=()=>l.slice(g.index+1),ye=($="",ne=0)=>{g.consumed+=$,g.index+=ne},Se=$=>{g.output+=$.output!=null?$.output:$.value,ye($.value)},Ut=()=>{let $=1;for(;B()==="!"&&(B(2)!=="("||B(3)==="?");)xe(),g.start++,$++;return $%2===0?!1:(g.negated=!0,g.start++,!0)},Be=$=>{g[$]++,Ie.push($)},$e=$=>{g[$]--,Ie.pop()},U=$=>{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,w.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;Be("parens"),U({type:$,value:ne,output:g.output?"":N}),U({type:"paren",extglob:!0,value:xe(),output:Q}),be.push(v)},Pn=$=>{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(tt()))&&(ne=$.close=`)$))${Q}`),$.inner.includes("*")&&(v=tt())&&/^\.[^\\/.]+$/.test(v)){const de=u(v,{...h,fastpaths:!1}).output;ne=$.close=`)${de})${Q})`}$.prev.type==="bos"&&(g.negatedExtglob=!0)}U({type:"paren",extglob:!0,value:_,output:ne}),$e("parens")};if(d.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(l)){let $=!1,ne=l.replace(s,(v,Q,de,Le,we,Mn)=>Le==="\\"?($=!0,v):Le==="?"?Q?Q+Le+(we?C.repeat(we.length):""):Mn===0?Me+(we?C.repeat(we.length):""):C.repeat(de.length):Le==="."?m.repeat(de.length):Le==="*"?Q?Q+Le+(we?_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){_+="\\",U({type:"text",value:_});continue}const Q=/^\\+/.exec(tt());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){U({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),Le=E.value.slice(Q+2),we=r[Le];if(we){E.value=de+we,g.backtrack=!0,xe(),!Z.output&&w.indexOf(E)===1&&(Z.output=N);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&&U({type:"text",value:_});continue}if(_==="("){Be("parens"),U({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){Pn(be.pop());continue}U({type:"paren",value:_,output:g.parens?")":"\\)"}),$e("parens");continue}if(_==="["){if(d.nobracket===!0||!tt().includes("]")){if(d.nobracket!==!0&&d.strictBrackets===!0)throw new SyntaxError(c("closing","]"));_=`\\${_}`}else Be("brackets");U({type:"bracket",value:_});continue}if(_==="]"){if(d.nobracket===!0||E&&E.type==="bracket"&&E.value.length===1){U({type:"text",value:_,output:`\\${_}`});continue}if(g.brackets===0){if(d.strictBrackets===!0)throw new SyntaxError(c("opening","["));U({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){Be("braces");const v={type:"brace",value:_,output:"(",outputIndex:g.output.length,tokensIndex:g.tokens.length};je.push(v),U(v);continue}if(_==="}"){const v=je[je.length-1];if(d.nobrace===!0||!v){U({type:"text",value:_,output:_});continue}let Q=")";if(v.dots===!0){const de=w.slice(),Le=[];for(let we=de.length-1;we>=0&&(w.pop(),de[we].type!=="brace");we--)de[we].type!=="dots"&&Le.unshift(de[we].value);Q=a(Le,d),g.backtrack=!0}if(v.comma!==!0&&v.dots!==!0){const de=g.output.slice(0,v.outputIndex),Le=g.tokens.slice(v.tokensIndex);v.value=v.output="\\{",_=Q="\\}",g.output=de;for(const we of Le)g.output+=we.output||we.value}U({type:"brace",value:_,output:Q}),$e("braces"),je.pop();continue}if(_==="|"){be.length>0&&be[be.length-1].conditions++,U({type:"text",value:_});continue}if(_===","){let v=_;const Q=je[je.length-1];Q&&Ie[Ie.length-1]==="braces"&&(Q.comma=!0,v="|"),U({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="",w.pop(),E=Z;continue}U({type:"slash",value:_,output:y});continue}if(_==="."){if(g.braces>0&&E.type==="dot"){E.value==="."&&(E.output=m);const v=je[je.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"){U({type:"text",value:_,output:m});continue}U({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(tt()))&&(de=`\\${_}`),U({type:"text",value:_,output:de});continue}if(d.dot!==!0&&(E.type==="slash"||E.type==="bos")){U({type:"qmark",value:_,output:q});continue}U({type:"qmark",value:_,output:C});continue}if(_==="!"){if(d.noextglob!==!0&&B()==="("&&(B(2)!=="?"||!/[!=<:]/.test(B(3)))){Re("negate",_);continue}if(d.nonegate!==!0&&g.index===0){Ut();continue}}if(_==="+"){if(d.noextglob!==!0&&B()==="("&&B(2)!=="?"){Re("plus",_);continue}if(E&&E.value==="("||d.regex===!1){U({type:"plus",value:_,output:A});continue}if(E&&(E.type==="bracket"||E.type==="paren"||E.type==="brace")||g.parens>0){U({type:"plus",value:_});continue}U({type:"plus",value:A});continue}if(_==="@"){if(d.noextglob!==!0&&B()==="("&&B(2)!=="?"){U({type:"at",extglob:!0,value:_,output:""});continue}U({type:"text",value:_});continue}if(_!=="*"){(_==="$"||_==="^")&&(_=`\\${_}`);const v=o.exec(tt());v&&(_+=v[0],g.index+=v[0].length),U({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 $=tt();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",Le=Q&&(Q.type==="star"||Q.type==="globstar");if(d.bash===!0&&(!de||$[0]&&$[0]!=="/")){U({type:"star",value:_,output:""});continue}const we=g.braces>0&&(v.type==="comma"||v.type==="brace"),Mn=be.length&&(v.type==="pipe"||v.type==="paren");if(!de&&v.type!=="paren"&&!we&&!Mn){U({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"&&!Le&&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()),U({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()),U({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),U(ne);continue}if(E&&(E.type==="bracket"||E.type==="paren")&&d.regex===!0){ne.output=_,U(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+=N,E.output+=N)),U(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")&&U({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,O=l.length;if(O>b)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${b}`);l=i[l]||l;const Z=t.isWindows(h),{DOT_LITERAL:w,SLASH_LITERAL:T,ONE_CHAR:D,DOTS_SLASH:p,NO_DOT:S,NO_DOTS:m,NO_DOTS_SLASH:A,STAR:y,START_ANCHOR:N}=e.globChars(Z),x=d.dot?m:S,G=d.dot?A:S,Y=d.capture?"":"?:",H={negated:!1,prefix:""};let C=d.bash===!0?".*?":y;d.capture&&(C=`(${C})`);const q=ce=>ce.noglobstar===!0?C:`(${Y}(?:(?!${N}${ce.dot?p:w}).)*?)`,V=ce=>{switch(ce){case"*":return`${x}${D}${C}`;case".*":return`${w}${D}${C}`;case"*.*":return`${x}${C}${w}${D}${C}`;case"*/*":return`${x}${C}${T}${D}${G}${C}`;case"**":return x+q(d);case"**/*":return`(?:${x}${q(d)}${T})?${G}${D}${C}`;case"**/*.*":return`(?:${x}${q(d)}${T})?${G}${C}${w}${D}${C}`;case"**/.*":return`(?:${x}${q(d)}${T})?${w}${D}${C}`;default:{const Me=/^(.*?)\.(\w+)$/.exec(ce);if(!Me)return;const _e=V(Me[1]);return _e?_e+w+Me[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,Xs;function tg(){if(Xs)return Jr;Xs=1;const e=ue,t=JE(),n=eg(),r=Nn(),o=Ln(),s=a=>a&&typeof a=="object"&&!Array.isArray(a),i=(a,c,u=!1)=>{if(Array.isArray(a)){const T=a.map(p=>i(p,c,u));return p=>{for(const S of T){const m=S(p);if(m)return m}return!1}}const l=s(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?i.compileRe(a,c):i.makeRe(a,c,!1,!0),O=b.state;delete b.state;let Z=()=>!1;if(h.ignore){const T={...c,ignore:null,onMatch:null,onResult:null};Z=i(h.ignore,T,u)}const w=(T,D=!1)=>{const{isMatch:p,match:S,output:m}=i.test(T,b,c,{glob:a,posix:d}),A={glob:a,state:O,regex:b,posix:d,input:T,output:m,match:S,isMatch:p};return typeof h.onResult=="function"&&h.onResult(A),p===!1?(A.isMatch=!1,D?A:!1):Z(T)?(typeof h.onIgnore=="function"&&h.onIgnore(A),A.isMatch=!1,D?A:!1):(typeof h.onMatch=="function"&&h.onMatch(A),D?A:!0)};return u&&(w.state=O),w};return i.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 O=a===l,Z=O&&b?b(a):a;return O===!1&&(Z=b?b(a):a,O=Z===l),(O===!1||d.capture===!0)&&(d.matchBase===!0||d.basename===!0?O=i.matchBase(a,c,u,h):O=c.exec(Z)),{isMatch:!!O,match:O,output:Z}},i.matchBase=(a,c,u,l=r.isWindows(u))=>(c instanceof RegExp?c:i.makeRe(c,u)).test(e.basename(a)),i.isMatch=(a,c,u)=>i(c,u)(a),i.parse=(a,c)=>Array.isArray(a)?a.map(u=>i.parse(u,c)):n(a,{...c,fastpaths:!1}),i.scan=(a,c)=>t(a,c),i.compileRe=(a,c,u=!1,l=!1)=>{if(u===!0)return a.output;const h=c||{},d=h.contains?"":"^",b=h.contains?"":"$";let O=`${d}(?:${a.output})${b}`;a&&a.negated===!0&&(O=`^(?!${O}).*$`);const Z=i.toRegex(O,c);return l===!0&&(Z.state=a),Z},i.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)),i.compileRe(h,c,u,l)},i.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/$^/}},i.constants=o,Jr=i,Jr}var eo,Qs;function ng(){return Qs||(Qs=1,eo=tg()),eo}var to,qs;function rg(){if(qs)return to;qs=1;const e=To,t=qE(),n=ng(),r=Nn(),o=a=>a===""||a==="./",s=a=>{const c=a.indexOf("{");return c>-1&&a.indexOf("}",c)>-1},i=(a,c,u)=>{c=[].concat(c),a=[].concat(a);let l=new Set,h=new Set,d=new Set,b=0,O=T=>{d.add(T.output),u&&u.onResult&&u.onResult(T)};for(let T=0;T<c.length;T++){let D=n(String(c[T]),{...u,onResult:O},!0),p=D.state.negated||D.state.negatedExtglob;p&&b++;for(let S of a){let m=D(S,!0);(p?!m.isMatch:m.isMatch)&&(p?l.add(m.output):(l.delete(m.output),h.add(m.output)))}}let w=(b===c.length?[...d]:[...h]).filter(T=>!l.has(T));if(u&&w.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 w};return i.match=i,i.matcher=(a,c)=>n(a,c),i.isMatch=(a,c,u)=>n(c,u)(a),i.any=i.isMatch,i.not=(a,c,u={})=>{c=[].concat(c).map(String);let l=new Set,h=[],d=O=>{u.onResult&&u.onResult(O),h.push(O.output)},b=new Set(i(a,c,{...u,onResult:d}));for(let O of h)b.has(O)||l.add(O);return[...l]},i.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=>i.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 i.isMatch(a,c,{...u,contains:!0})},i.matchKeys=(a,c,u)=>{if(!r.isObject(a))throw new TypeError("Expected the first argument to be an object");let l=i(Object.keys(a),c,u),h={};for(let d of l)h[d]=a[d];return h},i.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},i.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},i.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))},i.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)},i.makeRe=(...a)=>n.makeRe(...a),i.scan=(...a)=>n.scan(...a),i.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},i.braces=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return c&&c.nobrace===!0||!s(a)?[a]:t(a,c)},i.braceExpand=(a,c)=>{if(typeof a!="string")throw new TypeError("Expected a string");return i.braces(a,{...c,expand:!0})},i.hasBraces=s,to=i,to}var og=rg();const ig=ZE(og);function Js(e,t,n){tn.statSync(e).isDirectory()?(tn.mkdirSync(t,{recursive:!0}),tn.readdirSync(e).forEach(r=>{const o=nt.resolve(e,r),s=nt.resolve(t,r);Js(o,s,n)})):ig.isMatch(e,n)||tn.copyFileSync(e,t)}function at(e,t,n,r,o=[]){const s=nt.join(e,r?.[n]??n);Js(nt.join(t,n),s,o)}function sg(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>L.info(`Template [${e}] with pages structure named has been created`)}}function et(e){return Ne.resolve(Ia(import.meta.url),"../..",e)}function ag(){const e=et("package.json");return e!==""?JSON.parse(fe.readFileSync(e,"utf8")):{}}async function cg(e){try{const t=e,n=Te.cwd(),r=Ne.join(n,t),o=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],s={_gitignore:".gitignore"};fe.existsSync(r)?(L.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 i=et("template");fe.readdirSync(i).filter(l=>l!=="package.json").filter(l=>!o.includes(l)).forEach(async l=>at(r,i,l,s));const a=JSON.parse(fe.readFileSync(Ne.join(i,"package.json"),"utf-8"));a.name=e;const c=ag();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");fe.writeFileSync(u,`${JSON.stringify(a,null,2)}
|
|
56
|
+
`),L.info(`App ${e} created`)}catch(t){L.error(`Error while creating app: ${t.message}`),Te.exit(1)}}function no(e,t,n,r){try{const o=Te.cwd(),s=ue.join(o,t);re.existsSync(s)||re.mkdirSync(s);const i=ue.join(o,t,n);re.existsSync(i)?(L.error(`${r} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):re.mkdirSync(i);const a=et(e);re.readdirSync(a).forEach(async c=>at(i,a,c)),L.info(`${r} ${n} created`)}catch(o){L.error(`Error while creating ${r}: ${o.message}`),Te.exit(1)}}function ro(e){const t=Te.cwd(),n=et(`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 ug(e,t,n,r){if(!re.existsSync(n)){re.copyFileSync(t,n);return}const o=re.readFileSync(t),s=re.readFileSync(n);o.equals(s)||(r?(await zt({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),L.info(`Replaced "${e.name}" with template version.`)):L.info(`Kept existing "${e.name}".`):L.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function Dn(e,t,n=!1){async function r(s,i,a){const c=ue.join(i,s.name),u=ue.join(a,s.name);s.isDirectory()?await Dn(c,u,n):await ug(s,c,u,n)}const o=re.readdirSync(e,{withFileTypes:!0});re.existsSync(t)||re.mkdirSync(t,{recursive:!0}),await o.reduce(async(s,i)=>(await s,r(i,e,t)),Promise.resolve())}async function oo(e=!1){try{const t=Te.cwd(),n=ue.join(t,"shared"),r=et("template/shared");if(!re.existsSync(r))return;await Dn(r,n,e)}catch(t){L.error(`Error while processing shared folder: ${t.message}`),Te.exit(1)}}async function lg(e,t){await oo(),no(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function pg(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>L.info(`Collection [${e}] has been created`)}}async function dg(e){const{targetPath:t,renameFiles:n,sourcePath:r,onCollectionCreated:o}=pg(e);try{const s=Te.cwd(),i=Ne.join(s,"collections"),a=et(r),c=fe.readdirSync(a);fe.existsSync(i)?fe.existsSync(Ne.join(i,t))&&(L.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):fe.mkdirSync(i),c.forEach(u=>at(i,a,u,n)),o()}catch(s){L.error(`Error while creating collection: ${s.message}`),Te.exit(1)}}async function fg(e){await oo(),no("template/footers/example-footer","footers",e,"Footer")}async function hg(e){await oo(),no("template/headers/example-header","headers",e,"Header")}async function mg(e,t){try{const n=Te.cwd(),r=Ne.join(n,"templates"),o=et("template/page-templates/example-template/pages");fe.existsSync(Ne.join(r,e))||(L.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),Te.exit(1)),fe.existsSync(Ne.join(r,e,"pages",`${t}.ts`))&&(L.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),Te.exit(1));const s=fe.readFileSync(Ne.join(o,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${Ya(t)}'`),i=Ne.join(r,e,"pages",`${t}.ts`);fe.writeFileSync(i,s),L.info(`Page [${t}.ts] created for template ${e}`)}catch(n){L.error(`Error while creating page: ${n.message}`),Te.exit(1)}}async function Eg(){try{const e=Te.cwd(),t=et("template/reference"),n=fe.readdirSync(t);let r=!1;for(const o of n){const s=Ne.join(t,o),i=Ne.join(e,o);fe.existsSync(i)||fe.mkdirSync(i,{recursive:!0});const a=fe.readdirSync(s),c=fe.readdirSync(i);if(o==="shared"){a.forEach(u=>{at(i,s,u)});continue}for(const u of a){if(u==="assets"){at(i,s,u);continue}if(c.includes(u)){const{name:l}=await zt({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(i,s,u,{[u]:l}),r=!0):L.info(`Skipped: ${u}`)}else at(i,s,u)}}L.info("Reference templates have been added to the app"),r&&L.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){L.error(`Error while creating template descriptors: ${e.message}`),Te.exit(1)}}const gg=["**/example-template/pages/custom.ts"];async function _g(e){const{targetPath:t,renameFiles:n,sourcePath:r,onTemplateCreated:o}=sg(e);try{const s=Te.cwd(),i=Ne.join(s,"templates"),a=et(r),c=fe.readdirSync(a);fe.existsSync(i)?fe.existsSync(Ne.join(i,t))&&(L.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),Te.exit(1)):fe.mkdirSync(i),c.forEach(u=>at(i,a,u,n,gg)),ro("headers"),ro("footers"),ro("layouts"),o()}catch(s){L.error(`Error while creating template descriptors: ${s.message}`),Te.exit(1)}}function yg(){process.env.CRANE_DEBUG_ENABLED="true"}function Sg(){return process.env.CRANE_DEBUG_ENABLED==="true"}function Tg(e,...t){Sg()&&console.debug(ua(`[DEBUG] ${e}`),...t)}function Rg(e){const t=M(process.cwd(),`${Oe}/${e}`);if(Ce(t))return ve.SECTION;const n=M(process.cwd(),`${Gt}/${e}`);if(Ce(n))return ve.HEADER;const r=M(process.cwd(),`${Ht}/${e}`);return Ce(r)?ve.FOOTER:ve.SECTION}function wg(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,r)=>{e.moduleGraph.invalidateAll();const o=new Ea(t.url||"",`http://${t.headers.host}`);if(o.pathname==="/api/v1/block-config"&&t.method==="GET"){const s=o.searchParams.get("section"),i=o.searchParams.get("type");if(!s){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}const a=i&&ve[i]||Rg(s);try{const c=await vn(s,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 Cg(){yt&&yt.clients.forEach(e=>{e.readyState===ba.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function vg(e,t){const n=M(`${e}/ssr-server.ts`),r=M(t);await rt({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 Ag(e,t){const n=M(`${e}/shared/preview.ts`),r=M(`${e}/shared/utils.ts`),o=M(`${e}/shared/api-routes.ts`),s=M(t);await rt({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await rt({build:{lib:{entry:r,formats:["es"],fileName:()=>"utils.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await rt({build:{lib:{entry:o,formats:["es"],fileName:()=>"api-routes.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function Ig(){const e="preview",t=`${e}/shared`,n="vite.config.js",r=`${e}/sections`,o=`${r}/preview.html`;[e,r].forEach(i=>{re.existsSync(i)||re.mkdirSync(i,{recursive:!0})});const s=et("template/preview");re.copyFileSync(`${s}/${n}`,`${e}/${n}`),await vg(s,e),re.copyFileSync(`${s}/sections/preview.html`,o),re.existsSync(t)||re.mkdirSync(t),await Ag(s,t)}function Og(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function bg(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function $g(e){const t=(await ks()).find(r=>r.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await $n(!0);return}const n=Ns(t);await Ls([n]),console.log(`Block ${e} rebuilt successfully`)}var Lg=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(Lg||{});function Ng(){return{timeout:null,inProgress:!1,pendingBuild:null}}function Dg(e,t){const n=async r=>{e.inProgress=!0;try{r.type==="incremental"&&r.blockName?await $g(r.blockName):await $n(!0),t.ws.send({type:"full-reload",path:"*"}),Cg()}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 kg(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),r=t.match(/headers\/([^/]+)/),o=t.match(/footers\/([^/]+)/),s=t.match(/shared\//);return!!(n||r||o||s)}function xg(e,t){return async n=>{if(!kg(n))return;e.timeout&&clearTimeout(e.timeout);const r=Og(n),o=bg(n);e.timeout=setTimeout(async()=>{o?await t({type:"full"}):r&&await t({type:"incremental",blockName:r})},1e3)}}function Pg(e,t){const n=Ng(),r=Dg(n,e),o=xg(n,r);e.watcher.add(t),e.watcher.on("add",o),e.watcher.on("change",o),e.watcher.on("unlink",o)}async function Mg(){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";const t=await import(e),{server:n,port:r}=await t.startServer();return{server:n,port:r}}function Ug(){yt=new Oa({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 Fg(){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/**/*"),s=await pa({configFile:e,root:process.cwd(),plugins:[wg()]});return await s.listen(),Pg(s,[t,n,r,o]),s}async function zg(){await $n(),await Ig(),console.log(`
|
|
38
57
|
\u{1F4E6} Starting preview servers...
|
|
39
|
-
`);let e=null,t=null;if(process.platform!=="win32"){const
|
|
58
|
+
`);let e=null,t=null;if(process.platform!=="win32"){Tg("Starting SSR server");const o=await Mg();e=o.server,t=o.port,process.env.PREVIEW_SSR_PORT=String(t),Ug()}const n=await Fg(),r=()=>{e&&e.close(),yt&&yt.close(),n.close(),process.exit(0)};return process.on("SIGINT",r),process.on("SIGTERM",r),n}async function Gg(e,t,n){const r=t.split("_").pop()??t,o=dt(e,"sections",r),s=dt(e,r);let i=null;if(Ce(o)&&Ft(o).isDirectory()?i=o:Ce(s)&&Ft(s).isDirectory()&&(i=s),i){const a=dt(n,r);Ce(a)&&((await zt({type:"confirm",name:"value",message:`Section directory [sections/${r}/] already exists. Do you want to overwrite it?`,initial:!1})).value||(L.error("Operation cancelled. Section directory already exists."),ae.exit(1)),L.info(`Deleting existing section directory [sections/${r}/]...`),co(a,{recursive:!0,force:!0})),L.info(`Copying section [sections/${r}/]...`),await Dn(i,a,!1)}else L.error(`Section directory [sections/${r}/] not found in source code.`),ae.exit(1)}async function Hg(e,t,n){const r=ra(dt($a.tmpdir(),"crane-source-"));new fo(Buffer.from(e)).extractAllTo(r,!0);try{const o=ae.cwd(),s=dt(o,"sections");Ce(s)||oa(s,{recursive:!0}),await Gg(r,t,s);const i=dt(r,"shared");if(Ce(i)){const a=dt(o,"shared");L.info("Copying shared folder..."),await Dn(i,a,!0)}L.info(`Source code for section [${n}] has been copied.`)}finally{co(r,{recursive:!0,force:!0})}}async function ea(e){const t=e??Hn,n=Gn.create({baseURL:t}),r=await an();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:r.appClientId},headers:{Authorization:`Bearer ${r.appSecretKey}`}})).data.sections]}async function jg(e,t){const n=(await ea(t)).find(r=>r.sectionId===e);return n||(L.error(`Section [${e}] not found in collection sections list.`),ae.exit(1)),n}async function Bg(e,t,n){const r=n??Hn,o=Gn.create({baseURL:r}),s=await an();L.info(`Downloading source code for section [${e}]...`);const i=await o.get(`/api/v1/custom-apps/manifests/collections/sections/${e}/source-code`,{params:{appClientId:s.appClientId},headers:{Authorization:`Bearer ${s.appSecretKey}`},responseType:"arraybuffer"});await Hg(i.data,t,e)}async function Zg(e){try{L.info("Fetching sections list...");const t=await ea(e);L.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){L.error(ht(t,"Error while fetching sections list")),ae.exit(1)}}async function Vg(e,t){try{const n=await jg(e,t);n.openSource||(L.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),ae.exit(1)),await Bg(e,n.sectionId,t)}catch(n){L.error(ht(n,"Error while pulling section")),ae.exit(1)}}async function Wg(e,t){const{list:n,section:r}=e;if(n){await Zg(t);return}if(r){await Vg(r,t);return}L.error("Please specify an action. Use --list to fetch sections list or --section to pull a section."),ae.exit(1)}const Kg={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},Yg=["preview","build","deploy","pull"];function Xg(e,t){return Yg.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function Qg(e){return e.includes("-h")||e.includes("--help")}function qg(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!Kg[e.rawName]?.includes(n))}function Jg(e){return e.length!==0}function e_(e,t,n){return e.matchedCommand!==void 0&&(Xg(e.matchedCommand,n)||Qg(e.rawArgs)||qg(e.matchedCommand,e.options)||Jg(t))}function t_(e,t,n){e.matchedCommand&&!e_(e,t,n)?e.runMatchedCommand():e.outputHelp()}function kn(e){if(Ka(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=Wa(e);return n&&console.log(n),t}async function io(e){const t=await zt({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=ue.basename(t.name);return kn(n)?n:io(e)}}async function n_(e,t,n,r){const o=await io(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 Mt(e,t,n,r,o){if(o!==void 0)if(!kn(o))await n_(e,t,n,r);else{const s=ue.basename(o.toString());await r(s)}}function r_(){re.existsSync("./templates")||(L.error(`No template found. Please create a template first using ${Ze("init --template <name>")}`),process.exit(1));const e=re.readdirSync("./templates",{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).filter(t=>t!=="assets");return e.length===0&&(L.error(`No template found. Please create a template first using ${Ze("init --template <name>")}`),process.exit(1)),e}async function o_(e){const t=r_();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();kn(e)?L.warn(`Template [${e}] doesn't exist`):L.error(`[${e}] is an invalid template name.`)}const n=await zt({type:"select",name:"choice",message:"Please choose a template:",choices:t.map(r=>({title:r,value:r}))});return n.choice||(L.error("No template selected"),process.exit(1)),n.choice}async function i_(e,t){if(typeof t=="string"||typeof t=="number"){if(kn(t))return t.toString();L.error(`${t} is invalid name.`)}return io(e)}async function s_(e,t,n){const r=await o_(t),o=await i_("page",n);if(o===void 0)return console.log(`You can use ${Ze("init --page <name>")} to directly specify the name of the page.`),e.outputHelp();await mg(r,o)}async function a_(e,t){try{const{app:n,section:r,header:o,footer:s,template:i,referenceTemplate:a,page:c,blank:u,collection:l}=e;await Mt(t,"app",Ze("init --app <name>"),cg,n),await Mt(t,"section",Ze(`init --section <name>${u?" --blank":""}`),h=>lg(h,u===!0),r),await Mt(t,"header",Ze("init --header <name>"),hg,o),await Mt(t,"footer",Ze("init --footer <name>"),fg,s),c===void 0?await Mt(t,"template",Ze("init --template <name>"),_g,i):await s_(t,i,c),await Mt(t,"collection",Ze("init --collection <name>"),dg,l),a&&await Eg()}catch(n){L.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function c_(){try{const e=sa("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=>a_(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>$n(!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&&yg(),await zg()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>ym(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=>Wg(n,e.options.url)),e.version(La),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});t_(e,t.args,t.options)}catch(e){L.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{c_ as run};
|