@donotdev/core 0.0.28 → 0.0.30

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/vite/index.js CHANGED
@@ -1,8 +1,11 @@
1
- var Xi=Object.create;var Br=Object.defineProperty;var Yi=Object.getOwnPropertyDescriptor;var Ki=Object.getOwnPropertyNames;var Qi=Object.getPrototypeOf,Zi=Object.prototype.hasOwnProperty;var V=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var eo=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ki(t))!Zi.call(e,n)&&n!==r&&Br(e,n,{get:()=>t[n],enumerable:!(s=Yi(t,n))||s.enumerable});return e};var to=(e,t,r)=>(r=e!=null?Xi(Qi(e)):{},eo(t||!e||!e.__esModule?Br(r,"default",{value:e,enumerable:!0}):r,e));var Re=_((eh,ls)=>{var as=e=>typeof e<"u"&&e!==null,So=e=>typeof e=="object",Ro=e=>Object.prototype.toString.call(e)==="[object Object]",$o=e=>typeof e=="function",ko=e=>typeof e=="boolean",Ao=e=>e instanceof Buffer,_o=e=>{if(as(e))switch(e.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},No=e=>e instanceof ArrayBuffer,Io=e=>typeof e=="string"&&e.length>0,Do=e=>typeof e=="number"&&!Number.isNaN(e),To=e=>Number.isInteger(e),Co=(e,t,r)=>e>=t&&e<=r,Fo=(e,t)=>t.includes(e),Oo=(e,t,r)=>new Error(`Expected ${t} for ${e} but received ${r} of type ${typeof r}`),jo=(e,t)=>(t.message=e.message,t);ls.exports={defined:as,object:So,plainObject:Ro,fn:$o,bool:ko,buffer:Ao,typedArray:_o,arrayBuffer:No,string:Io,number:Do,integer:To,inRange:Co,inArray:Fo,invalidParameterError:Oo,nativeError:jo}});var fs=_((th,us)=>{"use strict";var cs=()=>process.platform==="linux",Nt=null,Lo=()=>{if(!Nt)if(cs()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,Nt=process.report.getReport(),process.report.excludeNetwork=e}else Nt={};return Nt};us.exports={isLinux:cs,getReport:Lo}});var ds=_((rh,hs)=>{"use strict";var st=V("fs"),Mo="/usr/bin/ldd",zo="/proc/self/exe",It=2048,Bo=e=>{let t=st.openSync(e,"r"),r=Buffer.alloc(It),s=st.readSync(t,r,0,It,0);return st.close(t,()=>{}),r.subarray(0,s)},Uo=e=>new Promise((t,r)=>{st.open(e,"r",(s,n)=>{if(s)r(s);else{let i=Buffer.alloc(It);st.read(n,i,0,It,0,(o,a)=>{t(i.subarray(0,a)),st.close(n,()=>{})})}})});hs.exports={LDD_PATH:Mo,SELF_PATH:zo,readFileSync:Bo,readFile:Uo}});var ps=_((sh,gs)=>{"use strict";var Go=e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),r=e.readUInt16LE(54),s=e.readUInt16LE(56);for(let n=0;n<s;n++){let i=t+n*r;if(e.readUInt32LE(i)===3){let a=e.readUInt32LE(i+8),l=e.readUInt32LE(i+32);return e.subarray(a,a+l).toString().replace(/\0.*$/g,"")}}return null};gs.exports={interpreterPath:Go}});var Tt=_((nh,Ts)=>{"use strict";var bs=V("child_process"),{isLinux:nt,getReport:vs}=fs(),{LDD_PATH:Dt,SELF_PATH:ys,readFile:ar,readFileSync:lr}=ds(),{interpreterPath:ws}=ps(),$e,ke,Ae,Es="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",Be="",xs=()=>Be||new Promise(e=>{bs.exec(Es,(t,r)=>{Be=t?" ":r,e(Be)})}),Ps=()=>{if(!Be)try{Be=bs.execSync(Es,{encoding:"utf8"})}catch{Be=" "}return Be},Ce="glibc",Ss=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,Ye="musl",qo=e=>e.includes("libc.musl-")||e.includes("ld-musl-"),Rs=()=>{let e=vs();return e.header&&e.header.glibcVersionRuntime?Ce:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(qo)?Ye:null},$s=e=>{let[t,r]=e.split(/[\r\n]+/);return t&&t.includes(Ce)?Ce:r&&r.includes(Ye)?Ye:null},ks=e=>{if(e){if(e.includes("/ld-musl-"))return Ye;if(e.includes("/ld-linux-"))return Ce}return null},As=e=>(e=e.toString(),e.includes("musl")?Ye:e.includes("GNU C Library")?Ce:null),Wo=async()=>{if(ke!==void 0)return ke;ke=null;try{let e=await ar(Dt);ke=As(e)}catch{}return ke},Ho=()=>{if(ke!==void 0)return ke;ke=null;try{let e=lr(Dt);ke=As(e)}catch{}return ke},Vo=async()=>{if($e!==void 0)return $e;$e=null;try{let e=await ar(ys),t=ws(e);$e=ks(t)}catch{}return $e},Jo=()=>{if($e!==void 0)return $e;$e=null;try{let e=lr(ys),t=ws(e);$e=ks(t)}catch{}return $e},_s=async()=>{let e=null;if(nt()&&(e=await Vo(),!e&&(e=await Wo(),e||(e=Rs()),!e))){let t=await xs();e=$s(t)}return e},Ns=()=>{let e=null;if(nt()&&(e=Jo(),!e&&(e=Ho(),e||(e=Rs()),!e))){let t=Ps();e=$s(t)}return e},Xo=async()=>nt()&&await _s()!==Ce,Yo=()=>nt()&&Ns()!==Ce,Ko=async()=>{if(Ae!==void 0)return Ae;Ae=null;try{let t=(await ar(Dt)).match(Ss);t&&(Ae=t[1])}catch{}return Ae},Qo=()=>{if(Ae!==void 0)return Ae;Ae=null;try{let t=lr(Dt).match(Ss);t&&(Ae=t[1])}catch{}return Ae},Is=()=>{let e=vs();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},ms=e=>e.trim().split(/\s+/)[1],Ds=e=>{let[t,r,s]=e.split(/[\r\n]+/);return t&&t.includes(Ce)?ms(t):r&&s&&r.includes(Ye)?ms(s):null},Zo=async()=>{let e=null;if(nt()&&(e=await Ko(),e||(e=Is()),!e)){let t=await xs();e=Ds(t)}return e},ea=()=>{let e=null;if(nt()&&(e=Qo(),e||(e=Is()),!e)){let t=Ps();e=Ds(t)}return e};Ts.exports={GLIBC:Ce,MUSL:Ye,family:_s,familySync:Ns,isNonGlibcLinux:Xo,isNonGlibcLinuxSync:Yo,version:Zo,versionSync:ea}});var vt=_((ih,Cs)=>{"use strict";var ta=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>{}:()=>{};Cs.exports=ta});var Ct=_((oh,Fs)=>{"use strict";var ra="2.0.0",sa=Number.MAX_SAFE_INTEGER||9007199254740991,na=16,ia=250,oa=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Fs.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:na,MAX_SAFE_BUILD_LENGTH:ia,MAX_SAFE_INTEGER:sa,RELEASE_TYPES:oa,SEMVER_SPEC_VERSION:ra,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var yt=_((_e,Os)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:cr,MAX_SAFE_BUILD_LENGTH:aa,MAX_LENGTH:la}=Ct(),ca=vt();_e=Os.exports={};var ua=_e.re=[],fa=_e.safeRe=[],y=_e.src=[],ha=_e.safeSrc=[],w=_e.t={},da=0,ur="[a-zA-Z0-9-]",ga=[["\\s",1],["\\d",la],[ur,aa]],pa=e=>{for(let[t,r]of ga)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},R=(e,t,r)=>{let s=pa(t),n=da++;ca(e,n,t),w[e]=n,y[n]=t,ha[n]=s,ua[n]=new RegExp(t,r?"g":void 0),fa[n]=new RegExp(s,r?"g":void 0)};R("NUMERICIDENTIFIER","0|[1-9]\\d*");R("NUMERICIDENTIFIERLOOSE","\\d+");R("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${ur}*`);R("MAINVERSION",`(${y[w.NUMERICIDENTIFIER]})\\.(${y[w.NUMERICIDENTIFIER]})\\.(${y[w.NUMERICIDENTIFIER]})`);R("MAINVERSIONLOOSE",`(${y[w.NUMERICIDENTIFIERLOOSE]})\\.(${y[w.NUMERICIDENTIFIERLOOSE]})\\.(${y[w.NUMERICIDENTIFIERLOOSE]})`);R("PRERELEASEIDENTIFIER",`(?:${y[w.NONNUMERICIDENTIFIER]}|${y[w.NUMERICIDENTIFIER]})`);R("PRERELEASEIDENTIFIERLOOSE",`(?:${y[w.NONNUMERICIDENTIFIER]}|${y[w.NUMERICIDENTIFIERLOOSE]})`);R("PRERELEASE",`(?:-(${y[w.PRERELEASEIDENTIFIER]}(?:\\.${y[w.PRERELEASEIDENTIFIER]})*))`);R("PRERELEASELOOSE",`(?:-?(${y[w.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${y[w.PRERELEASEIDENTIFIERLOOSE]})*))`);R("BUILDIDENTIFIER",`${ur}+`);R("BUILD",`(?:\\+(${y[w.BUILDIDENTIFIER]}(?:\\.${y[w.BUILDIDENTIFIER]})*))`);R("FULLPLAIN",`v?${y[w.MAINVERSION]}${y[w.PRERELEASE]}?${y[w.BUILD]}?`);R("FULL",`^${y[w.FULLPLAIN]}$`);R("LOOSEPLAIN",`[v=\\s]*${y[w.MAINVERSIONLOOSE]}${y[w.PRERELEASELOOSE]}?${y[w.BUILD]}?`);R("LOOSE",`^${y[w.LOOSEPLAIN]}$`);R("GTLT","((?:<|>)?=?)");R("XRANGEIDENTIFIERLOOSE",`${y[w.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);R("XRANGEIDENTIFIER",`${y[w.NUMERICIDENTIFIER]}|x|X|\\*`);R("XRANGEPLAIN",`[v=\\s]*(${y[w.XRANGEIDENTIFIER]})(?:\\.(${y[w.XRANGEIDENTIFIER]})(?:\\.(${y[w.XRANGEIDENTIFIER]})(?:${y[w.PRERELEASE]})?${y[w.BUILD]}?)?)?`);R("XRANGEPLAINLOOSE",`[v=\\s]*(${y[w.XRANGEIDENTIFIERLOOSE]})(?:\\.(${y[w.XRANGEIDENTIFIERLOOSE]})(?:\\.(${y[w.XRANGEIDENTIFIERLOOSE]})(?:${y[w.PRERELEASELOOSE]})?${y[w.BUILD]}?)?)?`);R("XRANGE",`^${y[w.GTLT]}\\s*${y[w.XRANGEPLAIN]}$`);R("XRANGELOOSE",`^${y[w.GTLT]}\\s*${y[w.XRANGEPLAINLOOSE]}$`);R("COERCEPLAIN",`(^|[^\\d])(\\d{1,${cr}})(?:\\.(\\d{1,${cr}}))?(?:\\.(\\d{1,${cr}}))?`);R("COERCE",`${y[w.COERCEPLAIN]}(?:$|[^\\d])`);R("COERCEFULL",y[w.COERCEPLAIN]+`(?:${y[w.PRERELEASE]})?(?:${y[w.BUILD]})?(?:$|[^\\d])`);R("COERCERTL",y[w.COERCE],!0);R("COERCERTLFULL",y[w.COERCEFULL],!0);R("LONETILDE","(?:~>?)");R("TILDETRIM",`(\\s*)${y[w.LONETILDE]}\\s+`,!0);_e.tildeTrimReplace="$1~";R("TILDE",`^${y[w.LONETILDE]}${y[w.XRANGEPLAIN]}$`);R("TILDELOOSE",`^${y[w.LONETILDE]}${y[w.XRANGEPLAINLOOSE]}$`);R("LONECARET","(?:\\^)");R("CARETTRIM",`(\\s*)${y[w.LONECARET]}\\s+`,!0);_e.caretTrimReplace="$1^";R("CARET",`^${y[w.LONECARET]}${y[w.XRANGEPLAIN]}$`);R("CARETLOOSE",`^${y[w.LONECARET]}${y[w.XRANGEPLAINLOOSE]}$`);R("COMPARATORLOOSE",`^${y[w.GTLT]}\\s*(${y[w.LOOSEPLAIN]})$|^$`);R("COMPARATOR",`^${y[w.GTLT]}\\s*(${y[w.FULLPLAIN]})$|^$`);R("COMPARATORTRIM",`(\\s*)${y[w.GTLT]}\\s*(${y[w.LOOSEPLAIN]}|${y[w.XRANGEPLAIN]})`,!0);_e.comparatorTrimReplace="$1$2$3";R("HYPHENRANGE",`^\\s*(${y[w.XRANGEPLAIN]})\\s+-\\s+(${y[w.XRANGEPLAIN]})\\s*$`);R("HYPHENRANGELOOSE",`^\\s*(${y[w.XRANGEPLAINLOOSE]})\\s+-\\s+(${y[w.XRANGEPLAINLOOSE]})\\s*$`);R("STAR","(<|>)?=?\\s*\\*");R("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");R("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Ft=_((ah,js)=>{"use strict";var ma=Object.freeze({loose:!0}),ba=Object.freeze({}),va=e=>e?typeof e!="object"?ma:e:ba;js.exports=va});var Bs=_((lh,zs)=>{"use strict";var Ls=/^[0-9]+$/,Ms=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;let r=Ls.test(e),s=Ls.test(t);return r&&s&&(e=+e,t=+t),e===t?0:r&&!s?-1:s&&!r?1:e<t?-1:1},ya=(e,t)=>Ms(t,e);zs.exports={compareIdentifiers:Ms,rcompareIdentifiers:ya}});var it=_((ch,Gs)=>{"use strict";var Ot=vt(),{MAX_LENGTH:Us,MAX_SAFE_INTEGER:jt}=Ct(),{safeRe:Lt,t:Mt}=yt(),wa=Ft(),{compareIdentifiers:fr}=Bs(),hr=class e{constructor(t,r){if(r=wa(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>Us)throw new TypeError(`version is longer than ${Us} characters`);Ot("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=t.trim().match(r.loose?Lt[Mt.LOOSE]:Lt[Mt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>jt||this.major<0)throw new TypeError("Invalid major version");if(this.minor>jt||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>jt||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let i=+n;if(i>=0&&i<jt)return i}return n}):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(Ot("SemVer.compare",this.version,this.options,t),!(t instanceof e)){if(typeof t=="string"&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let s=this.prerelease[r],n=t.prerelease[r];if(Ot("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return fr(s,n)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let s=this.build[r],n=t.build[r];if(Ot("build compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return fr(s,n)}while(++r)}inc(t,r,s){if(t.startsWith("pre")){if(!r&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?Lt[Mt.PRERELEASELOOSE]:Lt[Mt.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,s),this.inc("pre",r,s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,s),this.inc("pre",r,s);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(s)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);if(i===-1){if(r===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let i=[r,n];s===!1&&(i=[r]),fr(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=i):this.prerelease=i}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Gs.exports=hr});var Hs=_((uh,Ws)=>{"use strict";var qs=it(),Ea=(e,t,r=!1)=>{if(e instanceof qs)return e;try{return new qs(e,t)}catch(s){if(!r)return null;throw s}};Ws.exports=Ea});var Js=_((fh,Vs)=>{"use strict";var xa=it(),Pa=Hs(),{safeRe:zt,t:Bt}=yt(),Sa=(e,t)=>{if(e instanceof xa)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?zt[Bt.COERCEFULL]:zt[Bt.COERCE]);else{let l=t.includePrerelease?zt[Bt.COERCERTLFULL]:zt[Bt.COERCERTL],f;for(;(f=l.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||f.index+f[0].length!==r.index+r[0].length)&&(r=f),l.lastIndex=f.index+f[1].length+f[2].length;l.lastIndex=-1}if(r===null)return null;let s=r[2],n=r[3]||"0",i=r[4]||"0",o=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return Pa(`${s}.${n}.${i}${o}${a}`,t)};Vs.exports=Sa});var Ke=_((hh,Ys)=>{"use strict";var Xs=it(),Ra=(e,t,r)=>new Xs(e,r).compare(new Xs(t,r));Ys.exports=Ra});var dr=_((dh,Ks)=>{"use strict";var $a=Ke(),ka=(e,t,r)=>$a(e,t,r)>=0;Ks.exports=ka});var Zs=_((gh,Qs)=>{"use strict";var gr=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(t,r)}return this}};Qs.exports=gr});var tn=_((ph,en)=>{"use strict";var Aa=Ke(),_a=(e,t,r)=>Aa(e,t,r)===0;en.exports=_a});var sn=_((mh,rn)=>{"use strict";var Na=Ke(),Ia=(e,t,r)=>Na(e,t,r)!==0;rn.exports=Ia});var on=_((bh,nn)=>{"use strict";var Da=Ke(),Ta=(e,t,r)=>Da(e,t,r)>0;nn.exports=Ta});var ln=_((vh,an)=>{"use strict";var Ca=Ke(),Fa=(e,t,r)=>Ca(e,t,r)<0;an.exports=Fa});var un=_((yh,cn)=>{"use strict";var Oa=Ke(),ja=(e,t,r)=>Oa(e,t,r)<=0;cn.exports=ja});var hn=_((wh,fn)=>{"use strict";var La=tn(),Ma=sn(),za=on(),Ba=dr(),Ua=ln(),Ga=un(),qa=(e,t,r,s)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return La(e,r,s);case"!=":return Ma(e,r,s);case">":return za(e,r,s);case">=":return Ba(e,r,s);case"<":return Ua(e,r,s);case"<=":return Ga(e,r,s);default:throw new TypeError(`Invalid operator: ${t}`)}};fn.exports=qa});var yn=_((Eh,vn)=>{"use strict";var wt=Symbol("SemVer ANY"),br=class e{static get ANY(){return wt}constructor(t,r){if(r=dn(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),mr("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===wt?this.value="":this.value=this.operator+this.semver.version,mr("comp",this)}parse(t){let r=this.options.loose?gn[pn.COMPARATORLOOSE]:gn[pn.COMPARATOR],s=t.match(r);if(!s)throw new TypeError(`Invalid comparator: ${t}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new mn(s[2],this.options.loose):this.semver=wt}toString(){return this.value}test(t){if(mr("Comparator.test",t,this.options.loose),this.semver===wt||t===wt)return!0;if(typeof t=="string")try{t=new mn(t,this.options)}catch{return!1}return pr(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new bn(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new bn(this.value,r).test(t.semver):(r=dn(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||pr(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||pr(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};vn.exports=br;var dn=Ft(),{safeRe:gn,t:pn}=yt(),pr=hn(),mr=vt(),mn=it(),bn=vr()});var vr=_((xh,Pn)=>{"use strict";var Wa=/\s+/g,yr=class e{constructor(t,r){if(r=Va(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof wr)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(Wa," "),this.set=this.raw.split("||").map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!En(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&el(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let r=this.set[t];for(let s=0;s<r.length;s++)s>0&&(this.formatted+=" "),this.formatted+=r[s].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let s=((this.options.includePrerelease&&Qa)|(this.options.loose&&Za))+":"+t,n=wn.get(s);if(n)return n;let i=this.options.loose,o=i?oe[se.HYPHENRANGELOOSE]:oe[se.HYPHENRANGE];t=t.replace(o,ul(this.options.includePrerelease)),H("hyphen replace",t),t=t.replace(oe[se.COMPARATORTRIM],Xa),H("comparator trim",t),t=t.replace(oe[se.TILDETRIM],Ya),H("tilde trim",t),t=t.replace(oe[se.CARETTRIM],Ka),H("caret trim",t);let a=t.split(" ").map(g=>tl(g,this.options)).join(" ").split(/\s+/).map(g=>cl(g,this.options));i&&(a=a.filter(g=>(H("loose invalid filter",g,this.options),!!g.match(oe[se.COMPARATORLOOSE])))),H("range list",a);let l=new Map,f=a.map(g=>new wr(g,this.options));for(let g of f){if(En(g))return[g];l.set(g.value,g)}l.size>1&&l.has("")&&l.delete("");let u=[...l.values()];return wn.set(s,u),u}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(s=>xn(s,r)&&t.set.some(n=>xn(n,r)&&s.every(i=>n.every(o=>i.intersects(o,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new Ja(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(fl(this.set[r],t,this.options))return!0;return!1}};Pn.exports=yr;var Ha=Zs(),wn=new Ha,Va=Ft(),wr=yn(),H=vt(),Ja=it(),{safeRe:oe,t:se,comparatorTrimReplace:Xa,tildeTrimReplace:Ya,caretTrimReplace:Ka}=yt(),{FLAG_INCLUDE_PRERELEASE:Qa,FLAG_LOOSE:Za}=Ct(),En=e=>e.value==="<0.0.0-0",el=e=>e.value==="",xn=(e,t)=>{let r=!0,s=e.slice(),n=s.pop();for(;r&&s.length;)r=s.every(i=>n.intersects(i,t)),n=s.pop();return r},tl=(e,t)=>(e=e.replace(oe[se.BUILD],""),H("comp",e,t),e=nl(e,t),H("caret",e),e=rl(e,t),H("tildes",e),e=ol(e,t),H("xrange",e),e=ll(e,t),H("stars",e),e),ae=e=>!e||e.toLowerCase()==="x"||e==="*",rl=(e,t)=>e.trim().split(/\s+/).map(r=>sl(r,t)).join(" "),sl=(e,t)=>{let r=t.loose?oe[se.TILDELOOSE]:oe[se.TILDE];return e.replace(r,(s,n,i,o,a)=>{H("tilde",e,s,n,i,o,a);let l;return ae(n)?l="":ae(i)?l=`>=${n}.0.0 <${+n+1}.0.0-0`:ae(o)?l=`>=${n}.${i}.0 <${n}.${+i+1}.0-0`:a?(H("replaceTilde pr",a),l=`>=${n}.${i}.${o}-${a} <${n}.${+i+1}.0-0`):l=`>=${n}.${i}.${o} <${n}.${+i+1}.0-0`,H("tilde return",l),l})},nl=(e,t)=>e.trim().split(/\s+/).map(r=>il(r,t)).join(" "),il=(e,t)=>{H("caret",e,t);let r=t.loose?oe[se.CARETLOOSE]:oe[se.CARET],s=t.includePrerelease?"-0":"";return e.replace(r,(n,i,o,a,l)=>{H("caret",e,n,i,o,a,l);let f;return ae(i)?f="":ae(o)?f=`>=${i}.0.0${s} <${+i+1}.0.0-0`:ae(a)?i==="0"?f=`>=${i}.${o}.0${s} <${i}.${+o+1}.0-0`:f=`>=${i}.${o}.0${s} <${+i+1}.0.0-0`:l?(H("replaceCaret pr",l),i==="0"?o==="0"?f=`>=${i}.${o}.${a}-${l} <${i}.${o}.${+a+1}-0`:f=`>=${i}.${o}.${a}-${l} <${i}.${+o+1}.0-0`:f=`>=${i}.${o}.${a}-${l} <${+i+1}.0.0-0`):(H("no pr"),i==="0"?o==="0"?f=`>=${i}.${o}.${a}${s} <${i}.${o}.${+a+1}-0`:f=`>=${i}.${o}.${a}${s} <${i}.${+o+1}.0-0`:f=`>=${i}.${o}.${a} <${+i+1}.0.0-0`),H("caret return",f),f})},ol=(e,t)=>(H("replaceXRanges",e,t),e.split(/\s+/).map(r=>al(r,t)).join(" ")),al=(e,t)=>{e=e.trim();let r=t.loose?oe[se.XRANGELOOSE]:oe[se.XRANGE];return e.replace(r,(s,n,i,o,a,l)=>{H("xRange",e,s,n,i,o,a,l);let f=ae(i),u=f||ae(o),g=u||ae(a),p=g;return n==="="&&p&&(n=""),l=t.includePrerelease?"-0":"",f?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&p?(u&&(o=0),a=0,n===">"?(n=">=",u?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):n==="<="&&(n="<",u?i=+i+1:o=+o+1),n==="<"&&(l="-0"),s=`${n+i}.${o}.${a}${l}`):u?s=`>=${i}.0.0${l} <${+i+1}.0.0-0`:g&&(s=`>=${i}.${o}.0${l} <${i}.${+o+1}.0-0`),H("xRange return",s),s})},ll=(e,t)=>(H("replaceStars",e,t),e.trim().replace(oe[se.STAR],"")),cl=(e,t)=>(H("replaceGTE0",e,t),e.trim().replace(oe[t.includePrerelease?se.GTE0PRE:se.GTE0],"")),ul=e=>(t,r,s,n,i,o,a,l,f,u,g,p)=>(ae(s)?r="":ae(n)?r=`>=${s}.0.0${e?"-0":""}`:ae(i)?r=`>=${s}.${n}.0${e?"-0":""}`:o?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,ae(f)?l="":ae(u)?l=`<${+f+1}.0.0-0`:ae(g)?l=`<${f}.${+u+1}.0-0`:p?l=`<=${f}.${u}.${g}-${p}`:e?l=`<${f}.${u}.${+g+1}-0`:l=`<=${l}`,`${r} ${l}`.trim()),fl=(e,t,r)=>{for(let s=0;s<e.length;s++)if(!e[s].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let s=0;s<e.length;s++)if(H(e[s].semver),e[s].semver!==wr.ANY&&e[s].semver.prerelease.length>0){let n=e[s].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0}});var Rn=_((Ph,Sn)=>{"use strict";var hl=vr(),dl=(e,t,r)=>{try{t=new hl(t,r)}catch{return!1}return t.test(e)};Sn.exports=dl});var Er=_((Sh,gl)=>{gl.exports={name:"sharp",description:"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",version:"0.34.5",author:"Lovell Fuller <npm@lovell.info>",homepage:"https://sharp.pixelplumbing.com",contributors:["Pierre Inglebert <pierre.inglebert@gmail.com>","Jonathan Ong <jonathanrichardong@gmail.com>","Chanon Sajjamanochai <chanon.s@gmail.com>","Juliano Julio <julianojulio@gmail.com>","Daniel Gasienica <daniel@gasienica.ch>","Julian Walker <julian@fiftythree.com>","Amit Pitaru <pitaru.amit@gmail.com>","Brandon Aaron <hello.brandon@aaron.sh>","Andreas Lind <andreas@one.com>","Maurus Cuelenaere <mcuelenaere@gmail.com>","Linus Unneb\xE4ck <linus@folkdatorn.se>","Victor Mateevitsi <mvictoras@gmail.com>","Alaric Holloway <alaric.holloway@gmail.com>","Bernhard K. Weisshuhn <bkw@codingforce.com>","Chris Riley <criley@primedia.com>","David Carley <dacarley@gmail.com>","John Tobin <john@limelightmobileinc.com>","Kenton Gray <kentongray@gmail.com>","Felix B\xFCnemann <Felix.Buenemann@gmail.com>","Samy Al Zahrani <samyalzahrany@gmail.com>","Chintan Thakkar <lemnisk8@gmail.com>","F. Orlando Galashan <frulo@gmx.de>","Kleis Auke Wolthuizen <info@kleisauke.nl>","Matt Hirsch <mhirsch@media.mit.edu>","Matthias Thoemmes <thoemmes@gmail.com>","Patrick Paskaris <patrick@paskaris.gr>","J\xE9r\xE9my Lal <kapouer@melix.org>","Rahul Nanwani <r.nanwani@gmail.com>","Alice Monday <alice0meta@gmail.com>","Kristo Jorgenson <kristo.jorgenson@gmail.com>","YvesBos <yves_bos@outlook.com>","Guy Maliar <guy@tailorbrands.com>","Nicolas Coden <nicolas@ncoden.fr>","Matt Parrish <matt.r.parrish@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Matthew McEachen <matthew+github@mceachen.org>","Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>","Kenric D'Souza <kenric.dsouza@gmail.com>","Oleh Aleinyk <oleg.aleynik@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Andrea Bianco <andrea.bianco@unibas.ch>","Rik Heywood <rik@rik.org>","Thomas Parisot <hi@oncletom.io>","Nathan Graves <nathanrgraves+github@gmail.com>","Tom Lokhorst <tom@lokhorst.eu>","Espen Hovlandsdal <espen@hovlandsdal.com>","Sylvain Dumont <sylvain.dumont35@gmail.com>","Alun Davies <alun.owain.davies@googlemail.com>","Aidan Hoolachan <ajhoolachan21@gmail.com>","Axel Eirola <axel.eirola@iki.fi>","Freezy <freezy@xbmc.org>","Daiz <taneli.vatanen@gmail.com>","Julian Aubourg <j@ubourg.net>","Keith Belovay <keith@picthrive.com>","Michael B. Klein <mbklein@gmail.com>","Jordan Prudhomme <jordan@raboland.fr>","Ilya Ovdin <iovdin@gmail.com>","Andargor <andargor@yahoo.com>","Paul Neave <paul.neave@gmail.com>","Brendan Kennedy <brenwken@gmail.com>","Brychan Bennett-Odlum <git@brychan.io>","Edward Silverton <e.silverton@gmail.com>","Roman Malieiev <aromaleev@gmail.com>","Tomas Szabo <tomas.szabo@deftomat.com>","Robert O'Rourke <robert@o-rourke.org>","Guillermo Alfonso Varela Chouci\xF1o <guillevch@gmail.com>","Christian Flintrup <chr@gigahost.dk>","Manan Jadhav <manan@motionden.com>","Leon Radley <leon@radley.se>","alza54 <alza54@thiocod.in>","Jacob Smith <jacob@frende.me>","Michael Nutt <michael@nutt.im>","Brad Parham <baparham@gmail.com>","Taneli Vatanen <taneli.vatanen@gmail.com>","Joris Dugu\xE9 <zaruike10@gmail.com>","Chris Banks <christopher.bradley.banks@gmail.com>","Ompal Singh <ompal.hitm09@gmail.com>","Brodan <christopher.hranj@gmail.com>","Ankur Parihar <ankur.github@gmail.com>","Brahim Ait elhaj <brahima@gmail.com>","Mart Jansink <m.jansink@gmail.com>","Lachlan Newman <lachnewman007@gmail.com>","Dennis Beatty <dennis@dcbeatty.com>","Ingvar Stepanyan <me@rreverser.com>","Don Denton <don@happycollision.com>"],scripts:{build:"node install/build.js",install:"node install/check.js || npm run build",clean:"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",test:"npm run lint && npm run test-unit",lint:"npm run lint-cpp && npm run lint-js && npm run lint-types","lint-cpp":"cpplint --quiet src/*.h src/*.cc","lint-js":"biome lint","lint-types":"tsd --files ./test/types/sharp.test-d.ts","test-leak":"./test/leak/leak.sh","test-unit":"node --experimental-test-coverage test/unit.mjs","package-from-local-build":"node npm/from-local-build.js","package-release-notes":"node npm/release-notes.js","docs-build":"node docs/build.mjs","docs-serve":"cd docs && npm start","docs-publish":"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"},type:"commonjs",main:"lib/index.js",types:"lib/index.d.ts",files:["install","lib","src/*.{cc,h,gyp}"],repository:{type:"git",url:"git://github.com/lovell/sharp.git"},keywords:["jpeg","png","webp","avif","tiff","gif","svg","jp2","dzi","image","resize","thumbnail","crop","embed","libvips","vips"],dependencies:{"@img/colour":"^1.0.0","detect-libc":"^2.1.2",semver:"^7.7.3"},optionalDependencies:{"@img/sharp-darwin-arm64":"0.34.5","@img/sharp-darwin-x64":"0.34.5","@img/sharp-libvips-darwin-arm64":"1.2.4","@img/sharp-libvips-darwin-x64":"1.2.4","@img/sharp-libvips-linux-arm":"1.2.4","@img/sharp-libvips-linux-arm64":"1.2.4","@img/sharp-libvips-linux-ppc64":"1.2.4","@img/sharp-libvips-linux-riscv64":"1.2.4","@img/sharp-libvips-linux-s390x":"1.2.4","@img/sharp-libvips-linux-x64":"1.2.4","@img/sharp-libvips-linuxmusl-arm64":"1.2.4","@img/sharp-libvips-linuxmusl-x64":"1.2.4","@img/sharp-linux-arm":"0.34.5","@img/sharp-linux-arm64":"0.34.5","@img/sharp-linux-ppc64":"0.34.5","@img/sharp-linux-riscv64":"0.34.5","@img/sharp-linux-s390x":"0.34.5","@img/sharp-linux-x64":"0.34.5","@img/sharp-linuxmusl-arm64":"0.34.5","@img/sharp-linuxmusl-x64":"0.34.5","@img/sharp-wasm32":"0.34.5","@img/sharp-win32-arm64":"0.34.5","@img/sharp-win32-ia32":"0.34.5","@img/sharp-win32-x64":"0.34.5"},devDependencies:{"@biomejs/biome":"^2.3.4","@cpplint/cli":"^0.1.0","@emnapi/runtime":"^1.7.0","@img/sharp-libvips-dev":"1.2.4","@img/sharp-libvips-dev-wasm32":"1.2.4","@img/sharp-libvips-win32-arm64":"1.2.4","@img/sharp-libvips-win32-ia32":"1.2.4","@img/sharp-libvips-win32-x64":"1.2.4","@types/node":"*",emnapi:"^1.7.0","exif-reader":"^2.0.2","extract-zip":"^2.0.1",icc:"^3.0.0","jsdoc-to-markdown":"^9.1.3","node-addon-api":"^8.5.0","node-gyp":"^11.5.0","tar-fs":"^3.1.1",tsd:"^0.33.0"},license:"Apache-2.0",engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},config:{libvips:">=8.17.3"},funding:{url:"https://opencollective.com/libvips"}}});var Pr=_((Rh,Fn)=>{var{spawnSync:Ut}=V("node:child_process"),{createHash:pl}=V("node:crypto"),_n=Js(),ml=dr(),bl=Rn(),$n=Tt(),{config:vl,engines:kn,optionalDependencies:yl}=Er(),wl=process.env.npm_package_config_libvips||vl.libvips,Nn=_n(wl).version,El=["darwin-arm64","darwin-x64","linux-arm","linux-arm64","linux-ppc64","linux-riscv64","linux-s390x","linux-x64","linuxmusl-arm64","linuxmusl-x64","win32-arm64","win32-ia32","win32-x64"],Gt={encoding:"utf8",shell:!0},xl=e=>{e instanceof Error},In=()=>$n.isNonGlibcLinuxSync()?$n.familySync():"",Pl=()=>`${process.platform}${In()}-${process.arch}`,ot=()=>{if(Dn())return"wasm32";let{npm_config_arch:e,npm_config_platform:t,npm_config_libc:r}=process.env,s=typeof r=="string"?r:In();return`${t||process.platform}${s}-${e||process.arch}`},Sl=()=>{try{return V(`@img/sharp-libvips-dev-${ot()}/include`)}catch{try{return V("@img/sharp-libvips-dev/include")}catch{}}return""},Rl=()=>{try{return V("@img/sharp-libvips-dev/cplusplus")}catch{}return""},$l=()=>{try{return V(`@img/sharp-libvips-dev-${ot()}/lib`)}catch{try{return V(`@img/sharp-libvips-${ot()}/lib`)}catch{}}return""},kl=()=>{if(process.release?.name==="node"&&process.versions&&!bl(process.versions.node,kn.node))return{found:process.versions.node,expected:kn.node}},Dn=()=>{let{CC:e}=process.env;return!!e?.endsWith("/emcc")},Al=()=>process.platform==="darwin"&&process.arch==="x64"?(Ut("sysctl sysctl.proc_translated",Gt).stdout||"").trim()==="sysctl.proc_translated: 1":!1,An=e=>pl("sha512").update(e).digest("hex"),_l=()=>{try{let e=An(`imgsharp-libvips-${ot()}`),t=_n(yl[`@img/sharp-libvips-${ot()}`],{includePrerelease:!0}).version;return An(`${e}npm:${t}`).slice(0,10)}catch{}return""},Nl=()=>Ut(`node-gyp rebuild --directory=src ${Dn()?"--nodedir=emscripten":""}`,{...Gt,stdio:"inherit"}).status,Tn=()=>process.platform!=="win32"?(Ut("pkg-config --modversion vips-cpp",{...Gt,env:{...process.env,PKG_CONFIG_PATH:Cn()}}).stdout||"").trim():"",Cn=()=>process.platform!=="win32"?[(Ut('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',Gt).stdout||"").trim(),process.env.PKG_CONFIG_PATH,"/usr/local/lib/pkgconfig","/usr/lib/pkgconfig","/usr/local/libdata/pkgconfig","/usr/libdata/pkgconfig"].filter(Boolean).join(":"):"",xr=(e,t,r)=>(r&&r(`Detected ${t}, skipping search for globally-installed libvips`),e),Il=e=>{if(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)return xr(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",e);if(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)return xr(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",e);if(Al())return xr(!1,"Rosetta",e);let t=Tn();return!!t&&ml(t,Nn)};Fn.exports={minimumLibvipsVersion:Nn,prebuiltPlatforms:El,buildPlatformArch:ot,buildSharpLibvipsIncludeDir:Sl,buildSharpLibvipsCPlusPlusDir:Rl,buildSharpLibvipsLibDir:$l,isUnsupportedNodeRuntime:kl,runtimePlatformArch:Pl,log:xl,yarnLocator:_l,spawnRebuild:Nl,globalLibvipsVersion:Tn,pkgConfigPath:Cn,useGlobalLibvips:Il}});var xt=_((kh,jn)=>{var{familySync:Dl,versionSync:Tl}=Tt(),{runtimePlatformArch:Cl,isUnsupportedNodeRuntime:On,prebuiltPlatforms:Fl,minimumLibvipsVersion:Ol}=Pr(),Qe=Cl(),jl=[`../src/build/Release/sharp-${Qe}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${Qe}/sharp.node`,"@img/sharp-wasm32/sharp.node"],Sr,at,Et=[];for(Sr of jl)try{at=V(Sr);break}catch(e){Et.push(e)}if(at&&Sr.startsWith("@img/sharp-linux-x64")&&!at._isUsingX64V2()){let e=new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");e.code="Unsupported CPU",Et.push(e),at=null}if(at)jn.exports=at;else{let[e,t,r]=["linux","darwin","win32"].map(i=>Qe.startsWith(i)),s=[`Could not load the "sharp" module using the ${Qe} runtime`];Et.forEach(i=>{i.code!=="MODULE_NOT_FOUND"&&s.push(`${i.code}: ${i.message}`)});let n=Et.map(i=>i.message).join(" ");if(s.push("Possible solutions:"),On()){let{found:i,expected:o}=On();s.push("- Please upgrade Node.js:",` Found ${i}`,` Requires ${o}`)}else if(Fl.includes(Qe)){let[i,o]=Qe.split("-"),a=i.endsWith("musl")?" --libc=musl":"";s.push("- Ensure optional dependencies can be installed:"," npm install --include=optional sharp","- Ensure your package manager supports multi-platform installation:"," See https://sharp.pixelplumbing.com/install#cross-platform","- Add platform-specific dependencies:",` npm install --os=${i.replace("musl","")}${a} --cpu=${o} sharp`)}else s.push(`- Manually install libvips >= ${Ol}`,"- Add experimental WebAssembly-based dependencies:"," npm install --cpu=wasm32 sharp"," npm install @img/sharp-wasm32");if(e&&/(symbol not found|CXXABI_)/i.test(n))try{let{config:i}=V(`@img/sharp-libvips-${Qe}/package`),o=`${Dl()} ${Tl()}`,a=`${i.musl?"musl":"glibc"} ${i.musl||i.glibc}`;s.push("- Update your OS:",` Found ${o}`,` Requires ${a}`)}catch{}throw e&&/\/snap\/core[0-9]{2}/.test(n)&&s.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node"),t&&/Incompatible library version/.test(n)&&s.push("- Update Homebrew:"," brew update && brew upgrade vips"),Et.some(i=>i.code==="ERR_DLOPEN_DISABLED")&&s.push("- Run Node.js without using the --no-addons flag"),r&&/The specified procedure could not be found/.test(n)&&s.push("- Using the canvas package on Windows?"," See https://sharp.pixelplumbing.com/install#canvas-and-windows","- Check for outdated versions of sharp in the dependency tree:"," npm ls sharp"),s.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),new Error(s.join(`
2
- `))}});var Mn=_((_h,Ln)=>{var Ll=V("node:util"),Rr=V("node:stream"),Ml=Re();xt();var zl=Ll.debuglog("sharp"),Bl=e=>{Ze.queue.emit("change",e)},Ze=function(e,t){if(arguments.length===1&&!Ml.defined(e))throw new Error("Invalid input");return this instanceof Ze?(Rr.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:r=>{this.emit("warning",r),zl(r)},queueListener:Bl},this.options.input=this._createInputDescriptor(e,t,{allowStream:!0}),this):new Ze(e,t)};Object.setPrototypeOf(Ze.prototype,Rr.Duplex.prototype);Object.setPrototypeOf(Ze,Rr.Duplex);function Ul(){let e=this.constructor.call(),{debuglog:t,queueListener:r,...s}=this.options;return e.options=structuredClone(s),e.options.debuglog=t,e.options.queueListener=r,this._isStreamInput()&&this.on("finish",()=>{this._flattenBufferIn(),e.options.input.buffer=this.options.input.buffer,e.emit("finish")}),e}Object.assign(Ze.prototype,{clone:Ul});Ln.exports=Ze});var Un=_((Nh,Bn)=>{var h=Re(),Ue=xt(),Gl={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},ql=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function zn(e){let t=ql.filter(r=>h.defined(e[r])).map(r=>[r,e[r]]);return t.length?Object.fromEntries(t):void 0}function Wl(e,t,r){let s={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(h.string(e))s.file=e;else if(h.buffer(e)){if(e.length===0)throw Error("Input Buffer is empty");s.buffer=e}else if(h.arrayBuffer(e)){if(e.byteLength===0)throw Error("Input bit Array is empty");s.buffer=Buffer.from(e,0,e.byteLength)}else if(h.typedArray(e)){if(e.length===0)throw Error("Input Bit Array is empty");s.buffer=Buffer.from(e.buffer,e.byteOffset,e.byteLength)}else if(h.plainObject(e)&&!h.defined(t))t=e,zn(t)&&(s.buffer=[]);else if(!h.defined(e)&&!h.defined(t)&&h.object(r)&&r.allowStream)s.buffer=[];else if(Array.isArray(e))if(e.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=e.map(n=>this._createInputDescriptor(n));else throw new Error("Recursive join is unsupported");else throw new Error("Expected at least two images to join");else throw new Error(`Unsupported input '${e}' of type ${typeof e}${h.defined(t)?` when also providing options of type ${typeof t}`:""}`);if(h.object(t)){if(h.defined(t.failOnError))if(h.bool(t.failOnError))s.failOn=t.failOnError?"warning":"none";else throw h.invalidParameterError("failOnError","boolean",t.failOnError);if(h.defined(t.failOn))if(h.string(t.failOn)&&h.inArray(t.failOn,["none","truncated","error","warning"]))s.failOn=t.failOn;else throw h.invalidParameterError("failOn","one of: none, truncated, error, warning",t.failOn);if(h.defined(t.autoOrient))if(h.bool(t.autoOrient))s.autoOrient=t.autoOrient;else throw h.invalidParameterError("autoOrient","boolean",t.autoOrient);if(h.defined(t.density))if(h.inRange(t.density,1,1e5))s.density=t.density;else throw h.invalidParameterError("density","number between 1 and 100000",t.density);if(h.defined(t.ignoreIcc))if(h.bool(t.ignoreIcc))s.ignoreIcc=t.ignoreIcc;else throw h.invalidParameterError("ignoreIcc","boolean",t.ignoreIcc);if(h.defined(t.limitInputPixels))if(h.bool(t.limitInputPixels))s.limitInputPixels=t.limitInputPixels?16383**2:0;else if(h.integer(t.limitInputPixels)&&h.inRange(t.limitInputPixels,0,Number.MAX_SAFE_INTEGER))s.limitInputPixels=t.limitInputPixels;else throw h.invalidParameterError("limitInputPixels","positive integer",t.limitInputPixels);if(h.defined(t.unlimited))if(h.bool(t.unlimited))s.unlimited=t.unlimited;else throw h.invalidParameterError("unlimited","boolean",t.unlimited);if(h.defined(t.sequentialRead))if(h.bool(t.sequentialRead))s.sequentialRead=t.sequentialRead;else throw h.invalidParameterError("sequentialRead","boolean",t.sequentialRead);if(h.defined(t.raw)){if(h.object(t.raw)&&h.integer(t.raw.width)&&t.raw.width>0&&h.integer(t.raw.height)&&t.raw.height>0&&h.integer(t.raw.channels)&&h.inRange(t.raw.channels,1,4))switch(s.rawWidth=t.raw.width,s.rawHeight=t.raw.height,s.rawChannels=t.raw.channels,e.constructor){case Uint8Array:case Uint8ClampedArray:s.rawDepth="uchar";break;case Int8Array:s.rawDepth="char";break;case Uint16Array:s.rawDepth="ushort";break;case Int16Array:s.rawDepth="short";break;case Uint32Array:s.rawDepth="uint";break;case Int32Array:s.rawDepth="int";break;case Float32Array:s.rawDepth="float";break;case Float64Array:s.rawDepth="double";break;default:s.rawDepth="uchar";break}else throw new Error("Expected width, height and channels for raw pixel input");if(s.rawPremultiplied=!1,h.defined(t.raw.premultiplied))if(h.bool(t.raw.premultiplied))s.rawPremultiplied=t.raw.premultiplied;else throw h.invalidParameterError("raw.premultiplied","boolean",t.raw.premultiplied);if(s.rawPageHeight=0,h.defined(t.raw.pageHeight))if(h.integer(t.raw.pageHeight)&&t.raw.pageHeight>0&&t.raw.pageHeight<=t.raw.height){if(t.raw.height%t.raw.pageHeight!==0)throw new Error(`Expected raw.height ${t.raw.height} to be a multiple of raw.pageHeight ${t.raw.pageHeight}`);s.rawPageHeight=t.raw.pageHeight}else throw h.invalidParameterError("raw.pageHeight","positive integer",t.raw.pageHeight)}if(h.defined(t.animated))if(h.bool(t.animated))s.pages=t.animated?-1:1;else throw h.invalidParameterError("animated","boolean",t.animated);if(h.defined(t.pages))if(h.integer(t.pages)&&h.inRange(t.pages,-1,1e5))s.pages=t.pages;else throw h.invalidParameterError("pages","integer between -1 and 100000",t.pages);if(h.defined(t.page))if(h.integer(t.page)&&h.inRange(t.page,0,1e5))s.page=t.page;else throw h.invalidParameterError("page","integer between 0 and 100000",t.page);if(h.object(t.openSlide)&&h.defined(t.openSlide.level))if(h.integer(t.openSlide.level)&&h.inRange(t.openSlide.level,0,256))s.openSlideLevel=t.openSlide.level;else throw h.invalidParameterError("openSlide.level","integer between 0 and 256",t.openSlide.level);else if(h.defined(t.level))if(h.integer(t.level)&&h.inRange(t.level,0,256))s.openSlideLevel=t.level;else throw h.invalidParameterError("level","integer between 0 and 256",t.level);if(h.object(t.tiff)&&h.defined(t.tiff.subifd))if(h.integer(t.tiff.subifd)&&h.inRange(t.tiff.subifd,-1,1e5))s.tiffSubifd=t.tiff.subifd;else throw h.invalidParameterError("tiff.subifd","integer between -1 and 100000",t.tiff.subifd);else if(h.defined(t.subifd))if(h.integer(t.subifd)&&h.inRange(t.subifd,-1,1e5))s.tiffSubifd=t.subifd;else throw h.invalidParameterError("subifd","integer between -1 and 100000",t.subifd);if(h.object(t.svg)){if(h.defined(t.svg.stylesheet))if(h.string(t.svg.stylesheet))s.svgStylesheet=t.svg.stylesheet;else throw h.invalidParameterError("svg.stylesheet","string",t.svg.stylesheet);if(h.defined(t.svg.highBitdepth))if(h.bool(t.svg.highBitdepth))s.svgHighBitdepth=t.svg.highBitdepth;else throw h.invalidParameterError("svg.highBitdepth","boolean",t.svg.highBitdepth)}if(h.object(t.pdf)&&h.defined(t.pdf.background)?s.pdfBackground=this._getBackgroundColourOption(t.pdf.background):h.defined(t.pdfBackground)&&(s.pdfBackground=this._getBackgroundColourOption(t.pdfBackground)),h.object(t.jp2)&&h.defined(t.jp2.oneshot))if(h.bool(t.jp2.oneshot))s.jp2Oneshot=t.jp2.oneshot;else throw h.invalidParameterError("jp2.oneshot","boolean",t.jp2.oneshot);if(h.defined(t.create))if(h.object(t.create)&&h.integer(t.create.width)&&t.create.width>0&&h.integer(t.create.height)&&t.create.height>0&&h.integer(t.create.channels)){if(s.createWidth=t.create.width,s.createHeight=t.create.height,s.createChannels=t.create.channels,s.createPageHeight=0,h.defined(t.create.pageHeight))if(h.integer(t.create.pageHeight)&&t.create.pageHeight>0&&t.create.pageHeight<=t.create.height){if(t.create.height%t.create.pageHeight!==0)throw new Error(`Expected create.height ${t.create.height} to be a multiple of create.pageHeight ${t.create.pageHeight}`);s.createPageHeight=t.create.pageHeight}else throw h.invalidParameterError("create.pageHeight","positive integer",t.create.pageHeight);if(h.defined(t.create.noise)){if(!h.object(t.create.noise))throw new Error("Expected noise to be an object");if(t.create.noise.type!=="gaussian")throw new Error("Only gaussian noise is supported at the moment");if(s.createNoiseType=t.create.noise.type,!h.inRange(t.create.channels,1,4))throw h.invalidParameterError("create.channels","number between 1 and 4",t.create.channels);if(s.createNoiseMean=128,h.defined(t.create.noise.mean))if(h.number(t.create.noise.mean)&&h.inRange(t.create.noise.mean,0,1e4))s.createNoiseMean=t.create.noise.mean;else throw h.invalidParameterError("create.noise.mean","number between 0 and 10000",t.create.noise.mean);if(s.createNoiseSigma=30,h.defined(t.create.noise.sigma))if(h.number(t.create.noise.sigma)&&h.inRange(t.create.noise.sigma,0,1e4))s.createNoiseSigma=t.create.noise.sigma;else throw h.invalidParameterError("create.noise.sigma","number between 0 and 10000",t.create.noise.sigma)}else if(h.defined(t.create.background)){if(!h.inRange(t.create.channels,3,4))throw h.invalidParameterError("create.channels","number between 3 and 4",t.create.channels);s.createBackground=this._getBackgroundColourOption(t.create.background)}else throw new Error("Expected valid noise or background to create a new input image");delete s.buffer}else throw new Error("Expected valid width, height and channels to create a new input image");if(h.defined(t.text))if(h.object(t.text)&&h.string(t.text.text)){if(s.textValue=t.text.text,h.defined(t.text.height)&&h.defined(t.text.dpi))throw new Error("Expected only one of dpi or height");if(h.defined(t.text.font))if(h.string(t.text.font))s.textFont=t.text.font;else throw h.invalidParameterError("text.font","string",t.text.font);if(h.defined(t.text.fontfile))if(h.string(t.text.fontfile))s.textFontfile=t.text.fontfile;else throw h.invalidParameterError("text.fontfile","string",t.text.fontfile);if(h.defined(t.text.width))if(h.integer(t.text.width)&&t.text.width>0)s.textWidth=t.text.width;else throw h.invalidParameterError("text.width","positive integer",t.text.width);if(h.defined(t.text.height))if(h.integer(t.text.height)&&t.text.height>0)s.textHeight=t.text.height;else throw h.invalidParameterError("text.height","positive integer",t.text.height);if(h.defined(t.text.align))if(h.string(t.text.align)&&h.string(this.constructor.align[t.text.align]))s.textAlign=this.constructor.align[t.text.align];else throw h.invalidParameterError("text.align","valid alignment",t.text.align);if(h.defined(t.text.justify))if(h.bool(t.text.justify))s.textJustify=t.text.justify;else throw h.invalidParameterError("text.justify","boolean",t.text.justify);if(h.defined(t.text.dpi))if(h.integer(t.text.dpi)&&h.inRange(t.text.dpi,1,1e6))s.textDpi=t.text.dpi;else throw h.invalidParameterError("text.dpi","integer between 1 and 1000000",t.text.dpi);if(h.defined(t.text.rgba))if(h.bool(t.text.rgba))s.textRgba=t.text.rgba;else throw h.invalidParameterError("text.rgba","bool",t.text.rgba);if(h.defined(t.text.spacing))if(h.integer(t.text.spacing)&&h.inRange(t.text.spacing,-1e6,1e6))s.textSpacing=t.text.spacing;else throw h.invalidParameterError("text.spacing","integer between -1000000 and 1000000",t.text.spacing);if(h.defined(t.text.wrap))if(h.string(t.text.wrap)&&h.inArray(t.text.wrap,["word","char","word-char","none"]))s.textWrap=t.text.wrap;else throw h.invalidParameterError("text.wrap","one of: word, char, word-char, none",t.text.wrap);delete s.buffer}else throw new Error("Expected a valid string to create an image with text.");if(h.defined(t.join))if(h.defined(this.options.join)){if(h.defined(t.join.animated))if(h.bool(t.join.animated))s.joinAnimated=t.join.animated;else throw h.invalidParameterError("join.animated","boolean",t.join.animated);if(h.defined(t.join.across))if(h.integer(t.join.across)&&h.inRange(t.join.across,1,1e6))s.joinAcross=t.join.across;else throw h.invalidParameterError("join.across","integer between 1 and 100000",t.join.across);if(h.defined(t.join.shim))if(h.integer(t.join.shim)&&h.inRange(t.join.shim,0,1e6))s.joinShim=t.join.shim;else throw h.invalidParameterError("join.shim","integer between 0 and 100000",t.join.shim);if(h.defined(t.join.background)&&(s.joinBackground=this._getBackgroundColourOption(t.join.background)),h.defined(t.join.halign))if(h.string(t.join.halign)&&h.string(this.constructor.align[t.join.halign]))s.joinHalign=this.constructor.align[t.join.halign];else throw h.invalidParameterError("join.halign","valid alignment",t.join.halign);if(h.defined(t.join.valign))if(h.string(t.join.valign)&&h.string(this.constructor.align[t.join.valign]))s.joinValign=this.constructor.align[t.join.valign];else throw h.invalidParameterError("join.valign","valid alignment",t.join.valign)}else throw new Error("Expected input to be an array of images to join")}else if(h.defined(t))throw new Error(`Invalid input options ${t}`);return s}function Hl(e,t,r){Array.isArray(this.options.input.buffer)?h.buffer(e)?(this.options.input.buffer.length===0&&this.on("finish",()=>{this.streamInFinished=!0}),this.options.input.buffer.push(e),r()):r(new Error("Non-Buffer data on Writable Stream")):r(new Error("Unexpected data on Writable Stream"))}function Vl(){this._isStreamInput()&&(this.options.input.buffer=Buffer.concat(this.options.input.buffer))}function Jl(){return Array.isArray(this.options.input.buffer)}function Xl(e){let t=Error();return h.fn(e)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Ue.metadata(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)})}):Ue.metadata(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{let n=()=>{this._flattenBufferIn(),Ue.metadata(this.options,(i,o)=>{i?s(h.nativeError(i,t)):r(o)})};this.writableFinished?n():this.once("finish",n)}):new Promise((r,s)=>{Ue.metadata(this.options,(n,i)=>{n?s(h.nativeError(n,t)):r(i)})})}function Yl(e){let t=Error();return h.fn(e)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Ue.stats(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)})}):Ue.stats(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{this.on("finish",function(){this._flattenBufferIn(),Ue.stats(this.options,(n,i)=>{n?s(h.nativeError(n,t)):r(i)})})}):new Promise((r,s)=>{Ue.stats(this.options,(n,i)=>{n?s(h.nativeError(n,t)):r(i)})})}Bn.exports=e=>{Object.assign(e.prototype,{_inputOptionsFromObject:zn,_createInputDescriptor:Wl,_write:Hl,_flattenBufferIn:Vl,_isStreamInput:Jl,metadata:Xl,stats:Yl}),e.align=Gl}});var Jn=_((Ih,Vn)=>{var x=Re(),qn={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},Wn={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},Gn={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},Hn={entropy:16,attention:17},$r={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},Kl={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},Ql={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function kr(e){return e.angle%360!==0||e.rotationAngle!==0}function qt(e){return e.width!==-1||e.height!==-1}function Zl(e,t,r){if(qt(this.options)&&this.options.debuglog("ignoring previous resize options"),this.options.widthPost!==-1&&this.options.debuglog("operation order will be: extract, resize, extract"),x.defined(e))if(x.object(e)&&!x.defined(r))r=e;else if(x.integer(e)&&e>0)this.options.width=e;else throw x.invalidParameterError("width","positive integer",e);else this.options.width=-1;if(x.defined(t))if(x.integer(t)&&t>0)this.options.height=t;else throw x.invalidParameterError("height","positive integer",t);else this.options.height=-1;if(x.object(r)){if(x.defined(r.width))if(x.integer(r.width)&&r.width>0)this.options.width=r.width;else throw x.invalidParameterError("width","positive integer",r.width);if(x.defined(r.height))if(x.integer(r.height)&&r.height>0)this.options.height=r.height;else throw x.invalidParameterError("height","positive integer",r.height);if(x.defined(r.fit)){let s=Ql[r.fit];if(x.string(s))this.options.canvas=s;else throw x.invalidParameterError("fit","valid fit",r.fit)}if(x.defined(r.position)){let s=x.integer(r.position)?r.position:Hn[r.position]||Wn[r.position]||qn[r.position];if(x.integer(s)&&(x.inRange(s,0,8)||x.inRange(s,16,17)))this.options.position=s;else throw x.invalidParameterError("position","valid position/gravity/strategy",r.position)}if(this._setBackgroundColourOption("resizeBackground",r.background),x.defined(r.kernel))if(x.string($r[r.kernel]))this.options.kernel=$r[r.kernel];else throw x.invalidParameterError("kernel","valid kernel name",r.kernel);x.defined(r.withoutEnlargement)&&this._setBooleanOption("withoutEnlargement",r.withoutEnlargement),x.defined(r.withoutReduction)&&this._setBooleanOption("withoutReduction",r.withoutReduction),x.defined(r.fastShrinkOnLoad)&&this._setBooleanOption("fastShrinkOnLoad",r.fastShrinkOnLoad)}return kr(this.options)&&qt(this.options)&&(this.options.rotateBefore=!0),this}function ec(e){if(x.integer(e)&&e>0)this.options.extendTop=e,this.options.extendBottom=e,this.options.extendLeft=e,this.options.extendRight=e;else if(x.object(e)){if(x.defined(e.top))if(x.integer(e.top)&&e.top>=0)this.options.extendTop=e.top;else throw x.invalidParameterError("top","positive integer",e.top);if(x.defined(e.bottom))if(x.integer(e.bottom)&&e.bottom>=0)this.options.extendBottom=e.bottom;else throw x.invalidParameterError("bottom","positive integer",e.bottom);if(x.defined(e.left))if(x.integer(e.left)&&e.left>=0)this.options.extendLeft=e.left;else throw x.invalidParameterError("left","positive integer",e.left);if(x.defined(e.right))if(x.integer(e.right)&&e.right>=0)this.options.extendRight=e.right;else throw x.invalidParameterError("right","positive integer",e.right);if(this._setBackgroundColourOption("extendBackground",e.background),x.defined(e.extendWith))if(x.string(Gn[e.extendWith]))this.options.extendWith=Gn[e.extendWith];else throw x.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",e.extendWith)}else throw x.invalidParameterError("extend","integer or object",e);return this}function tc(e){let t=qt(this.options)||this.options.widthPre!==-1?"Post":"Pre";return this.options[`width${t}`]!==-1&&this.options.debuglog("ignoring previous extract options"),["left","top","width","height"].forEach(function(r){let s=e[r];if(x.integer(s)&&s>=0)this.options[r+(r==="left"||r==="top"?"Offset":"")+t]=s;else throw x.invalidParameterError(r,"integer",s)},this),kr(this.options)&&!qt(this.options)&&(this.options.widthPre===-1||this.options.widthPost===-1)&&(this.options.rotateBefore=!0),this.options.input.autoOrient&&(this.options.orientBefore=!0),this}function rc(e){if(this.options.trimThreshold=10,x.defined(e))if(x.object(e)){if(x.defined(e.background)&&this._setBackgroundColourOption("trimBackground",e.background),x.defined(e.threshold))if(x.number(e.threshold)&&e.threshold>=0)this.options.trimThreshold=e.threshold;else throw x.invalidParameterError("threshold","positive number",e.threshold);x.defined(e.lineArt)&&this._setBooleanOption("trimLineArt",e.lineArt)}else throw x.invalidParameterError("trim","object",e);return kr(this.options)&&(this.options.rotateBefore=!0),this}Vn.exports=e=>{Object.assign(e.prototype,{resize:Zl,extend:ec,extract:tc,trim:rc}),e.gravity=qn,e.strategy=Hn,e.kernel=$r,e.fit=Kl,e.position=Wn}});var Yn=_((Dh,Xn)=>{var U=Re(),Ar={clear:"clear",source:"source",over:"over",in:"in",out:"out",atop:"atop",dest:"dest","dest-over":"dest-over","dest-in":"dest-in","dest-out":"dest-out","dest-atop":"dest-atop",xor:"xor",add:"add",saturate:"saturate",multiply:"multiply",screen:"screen",overlay:"overlay",darken:"darken",lighten:"lighten","colour-dodge":"colour-dodge","color-dodge":"colour-dodge","colour-burn":"colour-burn","color-burn":"colour-burn","hard-light":"hard-light","soft-light":"soft-light",difference:"difference",exclusion:"exclusion"};function sc(e){if(!Array.isArray(e))throw U.invalidParameterError("images to composite","array",e);return this.options.composite=e.map(t=>{if(!U.object(t))throw U.invalidParameterError("image to composite","object",t);let r=this._inputOptionsFromObject(t),s={input:this._createInputDescriptor(t.input,r,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(U.defined(t.blend))if(U.string(Ar[t.blend]))s.blend=Ar[t.blend];else throw U.invalidParameterError("blend","valid blend name",t.blend);if(U.defined(t.tile))if(U.bool(t.tile))s.tile=t.tile;else throw U.invalidParameterError("tile","boolean",t.tile);if(U.defined(t.left))if(U.integer(t.left))s.left=t.left;else throw U.invalidParameterError("left","integer",t.left);if(U.defined(t.top))if(U.integer(t.top))s.top=t.top;else throw U.invalidParameterError("top","integer",t.top);if(U.defined(t.top)!==U.defined(t.left))throw new Error("Expected both left and top to be set");if(s.hasOffset=U.integer(t.top)&&U.integer(t.left),U.defined(t.gravity))if(U.integer(t.gravity)&&U.inRange(t.gravity,0,8))s.gravity=t.gravity;else if(U.string(t.gravity)&&U.integer(this.constructor.gravity[t.gravity]))s.gravity=this.constructor.gravity[t.gravity];else throw U.invalidParameterError("gravity","valid gravity",t.gravity);if(U.defined(t.premultiplied))if(U.bool(t.premultiplied))s.premultiplied=t.premultiplied;else throw U.invalidParameterError("premultiplied","boolean",t.premultiplied);return s}),this}Xn.exports=e=>{e.prototype.composite=sc,e.blend=Ar}});var ti=_((Th,ei)=>{var d=Re(),Kn={integer:"integer",float:"float",approximate:"approximate"};function nc(e,t){if(!d.defined(e))return this.autoOrient();if((this.options.angle||this.options.rotationAngle)&&(this.options.debuglog("ignoring previous rotate options"),this.options.angle=0,this.options.rotationAngle=0),d.integer(e)&&!(e%90))this.options.angle=e;else if(d.number(e))this.options.rotationAngle=e,d.object(t)&&t.background&&this._setBackgroundColourOption("rotationBackground",t.background);else throw d.invalidParameterError("angle","numeric",e);return this}function ic(){return this.options.input.autoOrient=!0,this}function oc(e){return this.options.flip=d.bool(e)?e:!0,this}function ac(e){return this.options.flop=d.bool(e)?e:!0,this}function lc(e,t){let r=[].concat(...e);if(r.length===4&&r.every(d.number))this.options.affineMatrix=r;else throw d.invalidParameterError("matrix","1x4 or 2x2 array",e);if(d.defined(t))if(d.object(t)){if(this._setBackgroundColourOption("affineBackground",t.background),d.defined(t.idx))if(d.number(t.idx))this.options.affineIdx=t.idx;else throw d.invalidParameterError("options.idx","number",t.idx);if(d.defined(t.idy))if(d.number(t.idy))this.options.affineIdy=t.idy;else throw d.invalidParameterError("options.idy","number",t.idy);if(d.defined(t.odx))if(d.number(t.odx))this.options.affineOdx=t.odx;else throw d.invalidParameterError("options.odx","number",t.odx);if(d.defined(t.ody))if(d.number(t.ody))this.options.affineOdy=t.ody;else throw d.invalidParameterError("options.ody","number",t.ody);if(d.defined(t.interpolator))if(d.inArray(t.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=t.interpolator;else throw d.invalidParameterError("options.interpolator","valid interpolator name",t.interpolator)}else throw d.invalidParameterError("options","object",t);return this}function cc(e,t,r){if(!d.defined(e))this.options.sharpenSigma=-1;else if(d.bool(e))this.options.sharpenSigma=e?-1:0;else if(d.number(e)&&d.inRange(e,.01,1e4)){if(this.options.sharpenSigma=e,d.defined(t))if(d.number(t)&&d.inRange(t,0,1e4))this.options.sharpenM1=t;else throw d.invalidParameterError("flat","number between 0 and 10000",t);if(d.defined(r))if(d.number(r)&&d.inRange(r,0,1e4))this.options.sharpenM2=r;else throw d.invalidParameterError("jagged","number between 0 and 10000",r)}else if(d.plainObject(e)){if(d.number(e.sigma)&&d.inRange(e.sigma,1e-6,10))this.options.sharpenSigma=e.sigma;else throw d.invalidParameterError("options.sigma","number between 0.000001 and 10",e.sigma);if(d.defined(e.m1))if(d.number(e.m1)&&d.inRange(e.m1,0,1e6))this.options.sharpenM1=e.m1;else throw d.invalidParameterError("options.m1","number between 0 and 1000000",e.m1);if(d.defined(e.m2))if(d.number(e.m2)&&d.inRange(e.m2,0,1e6))this.options.sharpenM2=e.m2;else throw d.invalidParameterError("options.m2","number between 0 and 1000000",e.m2);if(d.defined(e.x1))if(d.number(e.x1)&&d.inRange(e.x1,0,1e6))this.options.sharpenX1=e.x1;else throw d.invalidParameterError("options.x1","number between 0 and 1000000",e.x1);if(d.defined(e.y2))if(d.number(e.y2)&&d.inRange(e.y2,0,1e6))this.options.sharpenY2=e.y2;else throw d.invalidParameterError("options.y2","number between 0 and 1000000",e.y2);if(d.defined(e.y3))if(d.number(e.y3)&&d.inRange(e.y3,0,1e6))this.options.sharpenY3=e.y3;else throw d.invalidParameterError("options.y3","number between 0 and 1000000",e.y3)}else throw d.invalidParameterError("sigma","number between 0.01 and 10000",e);return this}function uc(e){if(!d.defined(e))this.options.medianSize=3;else if(d.integer(e)&&d.inRange(e,1,1e3))this.options.medianSize=e;else throw d.invalidParameterError("size","integer between 1 and 1000",e);return this}function fc(e){let t;if(d.number(e))t=e;else if(d.plainObject(e)){if(!d.number(e.sigma))throw d.invalidParameterError("options.sigma","number between 0.3 and 1000",t);if(t=e.sigma,"precision"in e)if(d.string(Kn[e.precision]))this.options.precision=Kn[e.precision];else throw d.invalidParameterError("precision","one of: integer, float, approximate",e.precision);if("minAmplitude"in e)if(d.number(e.minAmplitude)&&d.inRange(e.minAmplitude,.001,1))this.options.minAmpl=e.minAmplitude;else throw d.invalidParameterError("minAmplitude","number between 0.001 and 1",e.minAmplitude)}if(!d.defined(e))this.options.blurSigma=-1;else if(d.bool(e))this.options.blurSigma=e?-1:0;else if(d.number(t)&&d.inRange(t,.3,1e3))this.options.blurSigma=t;else throw d.invalidParameterError("sigma","number between 0.3 and 1000",t);return this}function Qn(e){if(!d.defined(e))this.options.dilateWidth=1;else if(d.integer(e)&&e>0)this.options.dilateWidth=e;else throw d.invalidParameterError("dilate","positive integer",Qn);return this}function Zn(e){if(!d.defined(e))this.options.erodeWidth=1;else if(d.integer(e)&&e>0)this.options.erodeWidth=e;else throw d.invalidParameterError("erode","positive integer",Zn);return this}function hc(e){return this.options.flatten=d.bool(e)?e:!0,d.object(e)&&this._setBackgroundColourOption("flattenBackground",e.background),this}function dc(){return this.options.unflatten=!0,this}function gc(e,t){if(!d.defined(e))this.options.gamma=2.2;else if(d.number(e)&&d.inRange(e,1,3))this.options.gamma=e;else throw d.invalidParameterError("gamma","number between 1.0 and 3.0",e);if(!d.defined(t))this.options.gammaOut=this.options.gamma;else if(d.number(t)&&d.inRange(t,1,3))this.options.gammaOut=t;else throw d.invalidParameterError("gammaOut","number between 1.0 and 3.0",t);return this}function pc(e){if(this.options.negate=d.bool(e)?e:!0,d.plainObject(e)&&"alpha"in e)if(d.bool(e.alpha))this.options.negateAlpha=e.alpha;else throw d.invalidParameterError("alpha","should be boolean value",e.alpha);return this}function mc(e){if(d.plainObject(e)){if(d.defined(e.lower))if(d.number(e.lower)&&d.inRange(e.lower,0,99))this.options.normaliseLower=e.lower;else throw d.invalidParameterError("lower","number between 0 and 99",e.lower);if(d.defined(e.upper))if(d.number(e.upper)&&d.inRange(e.upper,1,100))this.options.normaliseUpper=e.upper;else throw d.invalidParameterError("upper","number between 1 and 100",e.upper)}if(this.options.normaliseLower>=this.options.normaliseUpper)throw d.invalidParameterError("range","lower to be less than upper",`${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);return this.options.normalise=!0,this}function bc(e){return this.normalise(e)}function vc(e){if(d.plainObject(e)){if(d.integer(e.width)&&e.width>0)this.options.claheWidth=e.width;else throw d.invalidParameterError("width","integer greater than zero",e.width);if(d.integer(e.height)&&e.height>0)this.options.claheHeight=e.height;else throw d.invalidParameterError("height","integer greater than zero",e.height);if(d.defined(e.maxSlope))if(d.integer(e.maxSlope)&&d.inRange(e.maxSlope,0,100))this.options.claheMaxSlope=e.maxSlope;else throw d.invalidParameterError("maxSlope","integer between 0 and 100",e.maxSlope)}else throw d.invalidParameterError("options","plain object",e);return this}function yc(e){if(!d.object(e)||!Array.isArray(e.kernel)||!d.integer(e.width)||!d.integer(e.height)||!d.inRange(e.width,3,1001)||!d.inRange(e.height,3,1001)||e.height*e.width!==e.kernel.length)throw new Error("Invalid convolution kernel");return d.integer(e.scale)||(e.scale=e.kernel.reduce((t,r)=>t+r,0)),e.scale<1&&(e.scale=1),d.integer(e.offset)||(e.offset=0),this.options.convKernel=e,this}function wc(e,t){if(!d.defined(e))this.options.threshold=128;else if(d.bool(e))this.options.threshold=e?128:0;else if(d.integer(e)&&d.inRange(e,0,255))this.options.threshold=e;else throw d.invalidParameterError("threshold","integer between 0 and 255",e);return!d.object(t)||t.greyscale===!0||t.grayscale===!0?this.options.thresholdGrayscale=!0:this.options.thresholdGrayscale=!1,this}function Ec(e,t,r){if(this.options.boolean=this._createInputDescriptor(e,r),d.string(t)&&d.inArray(t,["and","or","eor"]))this.options.booleanOp=t;else throw d.invalidParameterError("operator","one of: and, or, eor",t);return this}function xc(e,t){if(!d.defined(e)&&d.number(t)?e=1:d.number(e)&&!d.defined(t)&&(t=0),!d.defined(e))this.options.linearA=[];else if(d.number(e))this.options.linearA=[e];else if(Array.isArray(e)&&e.length&&e.every(d.number))this.options.linearA=e;else throw d.invalidParameterError("a","number or array of numbers",e);if(!d.defined(t))this.options.linearB=[];else if(d.number(t))this.options.linearB=[t];else if(Array.isArray(t)&&t.length&&t.every(d.number))this.options.linearB=t;else throw d.invalidParameterError("b","number or array of numbers",t);if(this.options.linearA.length!==this.options.linearB.length)throw new Error("Expected a and b to be arrays of the same length");return this}function Pc(e){if(!Array.isArray(e))throw d.invalidParameterError("inputMatrix","array",e);if(e.length!==3&&e.length!==4)throw d.invalidParameterError("inputMatrix","3x3 or 4x4 array",e.length);let t=e.flat().map(Number);if(t.length!==9&&t.length!==16)throw d.invalidParameterError("inputMatrix","cardinality of 9 or 16",t.length);return this.options.recombMatrix=t,this}function Sc(e){if(!d.plainObject(e))throw d.invalidParameterError("options","plain object",e);if("brightness"in e)if(d.number(e.brightness)&&e.brightness>=0)this.options.brightness=e.brightness;else throw d.invalidParameterError("brightness","number above zero",e.brightness);if("saturation"in e)if(d.number(e.saturation)&&e.saturation>=0)this.options.saturation=e.saturation;else throw d.invalidParameterError("saturation","number above zero",e.saturation);if("hue"in e)if(d.integer(e.hue))this.options.hue=e.hue%360;else throw d.invalidParameterError("hue","number",e.hue);if("lightness"in e)if(d.number(e.lightness))this.options.lightness=e.lightness;else throw d.invalidParameterError("lightness","number",e.lightness);return this}ei.exports=e=>{Object.assign(e.prototype,{autoOrient:ic,rotate:nc,flip:oc,flop:ac,affine:lc,sharpen:cc,erode:Zn,dilate:Qn,median:uc,blur:fc,flatten:hc,unflatten:dc,gamma:gc,negate:pc,normalise:mc,normalize:bc,clahe:vc,convolve:yc,threshold:wc,boolean:Ec,linear:xc,recomb:Pc,modulate:Sc})}});var ai=_((Ch,oi)=>{var Dr=Object.defineProperty,Rc=Object.getOwnPropertyDescriptor,$c=Object.getOwnPropertyNames,kc=Object.prototype.hasOwnProperty,Ac=(e,t)=>{for(var r in t)Dr(e,r,{get:t[r],enumerable:!0})},_c=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $c(t))!kc.call(e,n)&&n!==r&&Dr(e,n,{get:()=>t[n],enumerable:!(s=Rc(t,n))||s.enumerable});return e},Nc=e=>_c(Dr({},"__esModule",{value:!0}),e),ri={};Ac(ri,{default:()=>qc});oi.exports=Nc(ri);var Ne={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},si=Object.create(null);for(let e in Ne)Object.hasOwn(Ne,e)&&(si[Ne[e]]=e);var ue={to:{},get:{}};ue.get=function(e){let t=e.slice(0,3).toLowerCase(),r,s;switch(t){case"hsl":{r=ue.get.hsl(e),s="hsl";break}case"hwb":{r=ue.get.hwb(e),s="hwb";break}default:{r=ue.get.rgb(e),s="rgb";break}}return r?{model:s,value:r}:null};ue.get.rgb=function(e){if(!e)return null;let t=/^#([a-f\d]{3,4})$/i,r=/^#([a-f\d]{6})([a-f\d]{2})?$/i,s=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,n=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,i=/^(\w+)$/,o=[0,0,0,1],a,l,f;if(a=e.match(r)){for(f=a[2],a=a[1],l=0;l<3;l++){let u=l*2;o[l]=Number.parseInt(a.slice(u,u+2),16)}f&&(o[3]=Number.parseInt(f,16)/255)}else if(a=e.match(t)){for(a=a[1],f=a[3],l=0;l<3;l++)o[l]=Number.parseInt(a[l]+a[l],16);f&&(o[3]=Number.parseInt(f+f,16)/255)}else if(a=e.match(s)){for(l=0;l<3;l++)o[l]=Number.parseInt(a[l+1],10);a[4]&&(o[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=e.match(n)){for(l=0;l<3;l++)o[l]=Math.round(Number.parseFloat(a[l+1])*2.55);a[4]&&(o[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=e.match(i))?a[1]==="transparent"?[0,0,0,0]:Object.hasOwn(Ne,a[1])?(o=Ne[a[1]],o[3]=1,o):null:null;for(l=0;l<3;l++)o[l]=Ge(o[l],0,255);return o[3]=Ge(o[3],0,1),o};ue.get.hsl=function(e){if(!e)return null;let t=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=e.match(t);if(r){let s=Number.parseFloat(r[4]),n=(Number.parseFloat(r[1])%360+360)%360,i=Ge(Number.parseFloat(r[2]),0,100),o=Ge(Number.parseFloat(r[3]),0,100),a=Ge(Number.isNaN(s)?1:s,0,1);return[n,i,o,a]}return null};ue.get.hwb=function(e){if(!e)return null;let t=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=e.match(t);if(r){let s=Number.parseFloat(r[4]),n=(Number.parseFloat(r[1])%360+360)%360,i=Ge(Number.parseFloat(r[2]),0,100),o=Ge(Number.parseFloat(r[3]),0,100),a=Ge(Number.isNaN(s)?1:s,0,1);return[n,i,o,a]}return null};ue.to.hex=function(...e){return"#"+Wt(e[0])+Wt(e[1])+Wt(e[2])+(e[3]<1?Wt(Math.round(e[3]*255)):"")};ue.to.rgb=function(...e){return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};ue.to.rgb.percent=function(...e){let t=Math.round(e[0]/255*100),r=Math.round(e[1]/255*100),s=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+t+"%, "+r+"%, "+s+"%)":"rgba("+t+"%, "+r+"%, "+s+"%, "+e[3]+")"};ue.to.hsl=function(...e){return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};ue.to.hwb=function(...e){let t="";return e.length>=4&&e[3]!==1&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"};ue.to.keyword=function(...e){return si[e.slice(0,3)]};function Ge(e,t,r){return Math.min(Math.max(t,e),r)}function Wt(e){let t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}var lt=ue,ni={};for(let e of Object.keys(Ne))ni[Ne[e]]=e;var v={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},et=v,Fe=(6/29)**3;function ut(e){let t=e>.0031308?1.055*e**.4166666666666667-.055:e*12.92;return Math.min(Math.max(0,t),1)}function ft(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(let e of Object.keys(v)){if(!("channels"in v[e]))throw new Error("missing channels property: "+e);if(!("labels"in v[e]))throw new Error("missing channel labels property: "+e);if(v[e].labels.length!==v[e].channels)throw new Error("channel and label counts mismatch: "+e);let{channels:t,labels:r}=v[e];delete v[e].channels,delete v[e].labels,Object.defineProperty(v[e],"channels",{value:t}),Object.defineProperty(v[e],"labels",{value:r})}v.rgb.hsl=function(e){let t=e[0]/255,r=e[1]/255,s=e[2]/255,n=Math.min(t,r,s),i=Math.max(t,r,s),o=i-n,a,l;switch(i){case n:{a=0;break}case t:{a=(r-s)/o;break}case r:{a=2+(s-t)/o;break}case s:{a=4+(t-r)/o;break}}a=Math.min(a*60,360),a<0&&(a+=360);let f=(n+i)/2;return i===n?l=0:f<=.5?l=o/(i+n):l=o/(2-i-n),[a,l*100,f*100]};v.rgb.hsv=function(e){let t,r,s,n,i,o=e[0]/255,a=e[1]/255,l=e[2]/255,f=Math.max(o,a,l),u=f-Math.min(o,a,l),g=function(p){return(f-p)/6/u+1/2};if(u===0)n=0,i=0;else{switch(i=u/f,t=g(o),r=g(a),s=g(l),f){case o:{n=s-r;break}case a:{n=1/3+t-s;break}case l:{n=2/3+r-t;break}}n<0?n+=1:n>1&&(n-=1)}return[n*360,i*100,f*100]};v.rgb.hwb=function(e){let t=e[0],r=e[1],s=e[2],n=v.rgb.hsl(e)[0],i=1/255*Math.min(t,Math.min(r,s));return s=1-1/255*Math.max(t,Math.max(r,s)),[n,i*100,s*100]};v.rgb.oklab=function(e){let t=ft(e[0]/255),r=ft(e[1]/255),s=ft(e[2]/255),n=Math.cbrt(.4122214708*t+.5363325363*r+.0514459929*s),i=Math.cbrt(.2119034982*t+.6806995451*r+.1073969566*s),o=Math.cbrt(.0883024619*t+.2817188376*r+.6299787005*s),a=.2104542553*n+.793617785*i-.0040720468*o,l=1.9779984951*n-2.428592205*i+.4505937099*o,f=.0259040371*n+.7827717662*i-.808675766*o;return[a*100,l*100,f*100]};v.rgb.cmyk=function(e){let t=e[0]/255,r=e[1]/255,s=e[2]/255,n=Math.min(1-t,1-r,1-s),i=(1-t-n)/(1-n)||0,o=(1-r-n)/(1-n)||0,a=(1-s-n)/(1-n)||0;return[i*100,o*100,a*100,n*100]};function Ic(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}v.rgb.keyword=function(e){let t=ni[e];if(t)return t;let r=Number.POSITIVE_INFINITY,s;for(let n of Object.keys(Ne)){let i=Ne[n],o=Ic(e,i);o<r&&(r=o,s=n)}return s};v.keyword.rgb=function(e){return Ne[e]};v.rgb.xyz=function(e){let t=ft(e[0]/255),r=ft(e[1]/255),s=ft(e[2]/255),n=t*.4124564+r*.3575761+s*.1804375,i=t*.2126729+r*.7151522+s*.072175,o=t*.0193339+r*.119192+s*.9503041;return[n*100,i*100,o*100]};v.rgb.lab=function(e){let t=v.rgb.xyz(e),r=t[0],s=t[1],n=t[2];r/=95.047,s/=100,n/=108.883,r=r>Fe?r**(1/3):7.787*r+16/116,s=s>Fe?s**(1/3):7.787*s+16/116,n=n>Fe?n**(1/3):7.787*n+16/116;let i=116*s-16,o=500*(r-s),a=200*(s-n);return[i,o,a]};v.hsl.rgb=function(e){let t=e[0]/360,r=e[1]/100,s=e[2]/100,n,i;if(r===0)return i=s*255,[i,i,i];let o=s<.5?s*(1+r):s+r-s*r,a=2*s-o,l=[0,0,0];for(let f=0;f<3;f++)n=t+1/3*-(f-1),n<0&&n++,n>1&&n--,6*n<1?i=a+(o-a)*6*n:2*n<1?i=o:3*n<2?i=a+(o-a)*(2/3-n)*6:i=a,l[f]=i*255;return l};v.hsl.hsv=function(e){let t=e[0],r=e[1]/100,s=e[2]/100,n=r,i=Math.max(s,.01);s*=2,r*=s<=1?s:2-s,n*=i<=1?i:2-i;let o=(s+r)/2,a=s===0?2*n/(i+n):2*r/(s+r);return[t,a*100,o*100]};v.hsv.rgb=function(e){let t=e[0]/60,r=e[1]/100,s=e[2]/100,n=Math.floor(t)%6,i=t-Math.floor(t),o=255*s*(1-r),a=255*s*(1-r*i),l=255*s*(1-r*(1-i));switch(s*=255,n){case 0:return[s,l,o];case 1:return[a,s,o];case 2:return[o,s,l];case 3:return[o,a,s];case 4:return[l,o,s];case 5:return[s,o,a]}};v.hsv.hsl=function(e){let t=e[0],r=e[1]/100,s=e[2]/100,n=Math.max(s,.01),i,o;o=(2-r)*s;let a=(2-r)*n;return i=r*n,i/=a<=1?a:2-a,i=i||0,o/=2,[t,i*100,o*100]};v.hwb.rgb=function(e){let t=e[0]/360,r=e[1]/100,s=e[2]/100,n=r+s,i;n>1&&(r/=n,s/=n);let o=Math.floor(6*t),a=1-s;i=6*t-o,(o&1)!==0&&(i=1-i);let l=r+i*(a-r),f,u,g;switch(o){default:case 6:case 0:{f=a,u=l,g=r;break}case 1:{f=l,u=a,g=r;break}case 2:{f=r,u=a,g=l;break}case 3:{f=r,u=l,g=a;break}case 4:{f=l,u=r,g=a;break}case 5:{f=a,u=r,g=l;break}}return[f*255,u*255,g*255]};v.cmyk.rgb=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=e[3]/100,i=1-Math.min(1,t*(1-n)+n),o=1-Math.min(1,r*(1-n)+n),a=1-Math.min(1,s*(1-n)+n);return[i*255,o*255,a*255]};v.xyz.rgb=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n,i,o;return n=t*3.2404542+r*-1.5371385+s*-.4985314,i=t*-.969266+r*1.8760108+s*.041556,o=t*.0556434+r*-.2040259+s*1.0572252,n=ut(n),i=ut(i),o=ut(o),[n*255,i*255,o*255]};v.xyz.lab=function(e){let t=e[0],r=e[1],s=e[2];t/=95.047,r/=100,s/=108.883,t=t>Fe?t**(1/3):7.787*t+16/116,r=r>Fe?r**(1/3):7.787*r+16/116,s=s>Fe?s**(1/3):7.787*s+16/116;let n=116*r-16,i=500*(t-r),o=200*(r-s);return[n,i,o]};v.xyz.oklab=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=Math.cbrt(.8189330101*t+.3618667424*r-.1288597137*s),i=Math.cbrt(.0329845436*t+.9293118715*r+.0361456387*s),o=Math.cbrt(.0482003018*t+.2643662691*r+.633851707*s),a=.2104542553*n+.793617785*i-.0040720468*o,l=1.9779984951*n-2.428592205*i+.4505937099*o,f=.0259040371*n+.7827717662*i-.808675766*o;return[a*100,l*100,f*100]};v.oklab.oklch=function(e){return v.lab.lch(e)};v.oklab.xyz=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=(.999999998*t+.396337792*r+.215803758*s)**3,i=(1.000000008*t-.105561342*r-.063854175*s)**3,o=(1.000000055*t-.089484182*r-1.291485538*s)**3,a=1.227013851*n-.55779998*i+.281256149*o,l=-.040580178*n+1.11225687*i-.071676679*o,f=-.076381285*n-.421481978*i+1.58616322*o;return[a*100,l*100,f*100]};v.oklab.rgb=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=(t+.3963377774*r+.2158037573*s)**3,i=(t-.1055613458*r-.0638541728*s)**3,o=(t-.0894841775*r-1.291485548*s)**3,a=ut(4.0767416621*n-3.3077115913*i+.2309699292*o),l=ut(-1.2684380046*n+2.6097574011*i-.3413193965*o),f=ut(-.0041960863*n-.7034186147*i+1.707614701*o);return[a*255,l*255,f*255]};v.oklch.oklab=function(e){return v.lch.lab(e)};v.lab.xyz=function(e){let t=e[0],r=e[1],s=e[2],n,i,o;i=(t+16)/116,n=r/500+i,o=i-s/200;let a=i**3,l=n**3,f=o**3;return i=a>Fe?a:(i-16/116)/7.787,n=l>Fe?l:(n-16/116)/7.787,o=f>Fe?f:(o-16/116)/7.787,n*=95.047,i*=100,o*=108.883,[n,i,o]};v.lab.lch=function(e){let t=e[0],r=e[1],s=e[2],n;n=Math.atan2(s,r)*360/2/Math.PI,n<0&&(n+=360);let o=Math.sqrt(r*r+s*s);return[t,o,n]};v.lch.lab=function(e){let t=e[0],r=e[1],n=e[2]/360*2*Math.PI,i=r*Math.cos(n),o=r*Math.sin(n);return[t,i,o]};v.rgb.ansi16=function(e,t=null){let[r,s,n]=e,i=t===null?v.rgb.hsv(e)[2]:t;if(i=Math.round(i/50),i===0)return 30;let o=30+(Math.round(n/255)<<2|Math.round(s/255)<<1|Math.round(r/255));return i===2&&(o+=60),o};v.hsv.ansi16=function(e){return v.rgb.ansi16(v.hsv.rgb(e),e[2])};v.rgb.ansi256=function(e){let t=e[0],r=e[1],s=e[2];return t>>4===r>>4&&r>>4===s>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(s/255*5)};v.ansi16.rgb=function(e){e=e[0];let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let r=(Math.trunc(e>50)+1)*.5,s=(t&1)*r*255,n=(t>>1&1)*r*255,i=(t>>2&1)*r*255;return[s,n,i]};v.ansi256.rgb=function(e){if(e=e[0],e>=232){let i=(e-232)*10+8;return[i,i,i]}e-=16;let t,r=Math.floor(e/36)/5*255,s=Math.floor((t=e%36)/6)/5*255,n=t%6/5*255;return[r,s,n]};v.rgb.hex=function(e){let r=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".slice(r.length)+r};v.hex.rgb=function(e){let t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let r=t[0];t[0].length===3&&(r=[...r].map(a=>a+a).join(""));let s=Number.parseInt(r,16),n=s>>16&255,i=s>>8&255,o=s&255;return[n,i,o]};v.rgb.hcg=function(e){let t=e[0]/255,r=e[1]/255,s=e[2]/255,n=Math.max(Math.max(t,r),s),i=Math.min(Math.min(t,r),s),o=n-i,a,l=o<1?i/(1-o):0;return o<=0?a=0:n===t?a=(r-s)/o%6:n===r?a=2+(s-t)/o:a=4+(t-r)/o,a/=6,a%=1,[a*360,o*100,l*100]};v.hsl.hcg=function(e){let t=e[1]/100,r=e[2]/100,s=r<.5?2*t*r:2*t*(1-r),n=0;return s<1&&(n=(r-.5*s)/(1-s)),[e[0],s*100,n*100]};v.hsv.hcg=function(e){let t=e[1]/100,r=e[2]/100,s=t*r,n=0;return s<1&&(n=(r-s)/(1-s)),[e[0],s*100,n*100]};v.hcg.rgb=function(e){let t=e[0]/360,r=e[1]/100,s=e[2]/100;if(r===0)return[s*255,s*255,s*255];let n=[0,0,0],i=t%1*6,o=i%1,a=1-o,l=0;switch(Math.floor(i)){case 0:{n[0]=1,n[1]=o,n[2]=0;break}case 1:{n[0]=a,n[1]=1,n[2]=0;break}case 2:{n[0]=0,n[1]=1,n[2]=o;break}case 3:{n[0]=0,n[1]=a,n[2]=1;break}case 4:{n[0]=o,n[1]=0,n[2]=1;break}default:n[0]=1,n[1]=0,n[2]=a}return l=(1-r)*s,[(r*n[0]+l)*255,(r*n[1]+l)*255,(r*n[2]+l)*255]};v.hcg.hsv=function(e){let t=e[1]/100,r=e[2]/100,s=t+r*(1-t),n=0;return s>0&&(n=t/s),[e[0],n*100,s*100]};v.hcg.hsl=function(e){let t=e[1]/100,s=e[2]/100*(1-t)+.5*t,n=0;return s>0&&s<.5?n=t/(2*s):s>=.5&&s<1&&(n=t/(2*(1-s))),[e[0],n*100,s*100]};v.hcg.hwb=function(e){let t=e[1]/100,r=e[2]/100,s=t+r*(1-t);return[e[0],(s-t)*100,(1-s)*100]};v.hwb.hcg=function(e){let t=e[1]/100,s=1-e[2]/100,n=s-t,i=0;return n<1&&(i=(s-n)/(1-n)),[e[0],n*100,i*100]};v.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};v.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};v.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};v.gray.hsl=function(e){return[0,0,e[0]]};v.gray.hsv=v.gray.hsl;v.gray.hwb=function(e){return[0,100,e[0]]};v.gray.cmyk=function(e){return[0,0,0,e[0]]};v.gray.lab=function(e){return[e[0],0,0]};v.gray.hex=function(e){let t=Math.round(e[0]/100*255)&255,s=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(s.length)+s};v.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};function Dc(){let e={},t=Object.keys(et);for(let{length:r}=t,s=0;s<r;s++)e[t[s]]={distance:-1,parent:null};return e}function Tc(e){let t=Dc(),r=[e];for(t[e].distance=0;r.length>0;){let s=r.pop(),n=Object.keys(et[s]);for(let{length:i}=n,o=0;o<i;o++){let a=n[o],l=t[a];l.distance===-1&&(l.distance=t[s].distance+1,l.parent=s,r.unshift(a))}}return t}function Cc(e,t){return function(r){return t(e(r))}}function Fc(e,t){let r=[t[e].parent,e],s=et[t[e].parent][e],n=t[e].parent;for(;t[n].parent;)r.unshift(t[n].parent),s=Cc(et[t[n].parent][n],s),n=t[n].parent;return s.conversion=r,s}function Oc(e){let t=Tc(e),r={},s=Object.keys(t);for(let{length:n}=s,i=0;i<n;i++){let o=s[i];t[o].parent!==null&&(r[o]=Fc(o,t))}return r}var jc=Oc,ct={},Lc=Object.keys(et);function Mc(e){let t=function(...r){let s=r[0];return s==null?s:(s.length>1&&(r=s),e(r))};return"conversion"in e&&(t.conversion=e.conversion),t}function zc(e){let t=function(...r){let s=r[0];if(s==null)return s;s.length>1&&(r=s);let n=e(r);if(typeof n=="object")for(let{length:i}=n,o=0;o<i;o++)n[o]=Math.round(n[o]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}for(let e of Lc){ct[e]={},Object.defineProperty(ct[e],"channels",{value:et[e].channels}),Object.defineProperty(ct[e],"labels",{value:et[e].labels});let t=jc(e),r=Object.keys(t);for(let s of r){let n=t[s];ct[e][s]=zc(n),ct[e][s].raw=Mc(n)}}var he=ct,ii=["keyword","gray","hex"],_r={};for(let e of Object.keys(he))_r[[...he[e].labels].sort().join("")]=e;var Nr={};function ee(e,t){if(!(this instanceof ee))return new ee(e,t);if(t&&t in ii&&(t=null),t&&!(t in he))throw new Error("Unknown model: "+t);let r,s;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof ee)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if(typeof e=="string"){let n=lt.get(e);if(n===null)throw new Error("Unable to parse color from string: "+e);this.model=n.model,s=he[this.model].channels,this.color=n.value.slice(0,s),this.valpha=typeof n.value[s]=="number"?n.value[s]:1}else if(e.length>0){this.model=t||"rgb",s=he[this.model].channels;let n=Array.prototype.slice.call(e,0,s);this.color=Ir(n,s),this.valpha=typeof e[s]=="number"?e[s]:1}else if(typeof e=="number")this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;let n=Object.keys(e);"alpha"in e&&(n.splice(n.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);let i=n.sort().join("");if(!(i in _r))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=_r[i];let{labels:o}=he[this.model],a=[];for(r=0;r<o.length;r++)a.push(e[o[r]]);this.color=Ir(a)}if(Nr[this.model])for(s=he[this.model].channels,r=0;r<s;r++){let n=Nr[this.model][r];n&&(this.color[r]=n(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}ee.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(e){let t=this.model in lt.to?this:this.rgb();t=t.round(typeof e=="number"?e:1);let r=t.valpha===1?t.color:[...t.color,this.valpha];return lt.to[t.model](...r)},percentString(e){let t=this.rgb().round(typeof e=="number"?e:1),r=t.valpha===1?t.color:[...t.color,this.valpha];return lt.to.rgb.percent(...r)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let e={},{channels:t}=he[this.model],{labels:r}=he[this.model];for(let s=0;s<t;s++)e[r[s]]=this.color[s];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray(){let e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject(){let e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round(e){return e=Math.max(e||0,0),new ee([...this.color.map(Uc(e)),this.valpha],this.model)},alpha(e){return e!==void 0?new ee([...this.color,Math.max(0,Math.min(1,e))],this.model):this.valpha},red:J("rgb",0,K(255)),green:J("rgb",1,K(255)),blue:J("rgb",2,K(255)),hue:J(["hsl","hsv","hsl","hwb","hcg"],0,e=>(e%360+360)%360),saturationl:J("hsl",1,K(100)),lightness:J("hsl",2,K(100)),saturationv:J("hsv",1,K(100)),value:J("hsv",2,K(100)),chroma:J("hcg",1,K(100)),gray:J("hcg",2,K(100)),white:J("hwb",1,K(100)),wblack:J("hwb",2,K(100)),cyan:J("cmyk",0,K(100)),magenta:J("cmyk",1,K(100)),yellow:J("cmyk",2,K(100)),black:J("cmyk",3,K(100)),x:J("xyz",0,K(95.047)),y:J("xyz",1,K(100)),z:J("xyz",2,K(108.833)),l:J("lab",0,K(100)),a:J("lab",1),b:J("lab",2),keyword(e){return e!==void 0?new ee(e):he[this.model].keyword(this.color)},hex(e){return e!==void 0?new ee(e):lt.to.hex(...this.rgb().round().color)},hexa(e){if(e!==void 0)return new ee(e);let t=this.rgb().round().color,r=Math.round(this.valpha*255).toString(16).toUpperCase();return r.length===1&&(r="0"+r),lt.to.hex(...t)+r},rgbNumber(){let e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity(){let e=this.rgb().color,t=[];for(let[r,s]of e.entries()){let n=s/255;t[r]=n<=.04045?n/12.92:((n+.055)/1.055)**2.4}return .2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){let t=this.luminosity(),r=e.luminosity();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},level(e){let t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){let e=this.rgb().color;return(e[0]*2126+e[1]*7152+e[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){let t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){let t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){let t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){let t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){let t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){let t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){let e=this.rgb().color,t=e[0]*.3+e[1]*.59+e[2]*.11;return ee.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){let t=this.hsl(),r=t.color[0];return r=(r+e)%360,r=r<0?360+r:r,t.color[0]=r,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);let r=e.rgb(),s=this.rgb(),n=t===void 0?.5:t,i=2*n-1,o=r.alpha()-s.alpha(),a=((i*o===-1?i:(i+o)/(1+i*o))+1)/2,l=1-a;return ee.rgb(a*r.red()+l*s.red(),a*r.green()+l*s.green(),a*r.blue()+l*s.blue(),r.alpha()*n+s.alpha()*(1-n))}};for(let e of Object.keys(he)){if(ii.includes(e))continue;let{channels:t}=he[e];ee.prototype[e]=function(...r){return this.model===e?new ee(this):r.length>0?new ee(r,e):new ee([...Gc(he[this.model][e].raw(this.color)),this.valpha],e)},ee[e]=function(...r){let s=r[0];return typeof s=="number"&&(s=Ir(r,t)),new ee(s,e)}}function Bc(e,t){return Number(e.toFixed(t))}function Uc(e){return function(t){return Bc(t,e)}}function J(e,t,r){e=Array.isArray(e)?e:[e];for(let s of e)(Nr[s]||=[])[t]=r;return e=e[0],function(s){let n;return s!==void 0?(r&&(s=r(s)),n=this[e](),n.color[t]=s,n):(n=this[e]().color[t],r&&(n=r(n)),n)}}function K(e){return function(t){return Math.max(0,Math.min(e,t))}}function Gc(e){return Array.isArray(e)?e:[e]}function Ir(e,t){for(let r=0;r<t;r++)typeof e[r]!="number"&&(e[r]=0);return e}var qc=ee});var ci=_((Fh,li)=>{li.exports=ai().default});var di=_((Oh,hi)=>{var Wc=ci(),Oe=Re(),ui={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function Hc(e){return this._setBackgroundColourOption("tint",e),this}function Vc(e){return this.options.greyscale=Oe.bool(e)?e:!0,this}function Jc(e){return this.greyscale(e)}function Xc(e){if(!Oe.string(e))throw Oe.invalidParameterError("colourspace","string",e);return this.options.colourspacePipeline=e,this}function Yc(e){return this.pipelineColourspace(e)}function Kc(e){if(!Oe.string(e))throw Oe.invalidParameterError("colourspace","string",e);return this.options.colourspace=e,this}function Qc(e){return this.toColourspace(e)}function fi(e){if(Oe.object(e)||Oe.string(e)&&e.length>=3&&e.length<=200){let t=Wc(e);return[t.red(),t.green(),t.blue(),Math.round(t.alpha()*255)]}else throw Oe.invalidParameterError("background","object or string",e)}function Zc(e,t){Oe.defined(t)&&(this.options[e]=fi(t))}hi.exports=e=>{Object.assign(e.prototype,{tint:Hc,greyscale:Vc,grayscale:Jc,pipelineColourspace:Xc,pipelineColorspace:Yc,toColourspace:Kc,toColorspace:Qc,_getBackgroundColourOption:fi,_setBackgroundColourOption:Zc}),e.colourspace=ui,e.colorspace=ui}});var pi=_((jh,gi)=>{var Ie=Re(),eu={and:"and",or:"or",eor:"eor"};function tu(){return this.options.removeAlpha=!0,this}function ru(e){if(Ie.defined(e))if(Ie.number(e)&&Ie.inRange(e,0,1))this.options.ensureAlpha=e;else throw Ie.invalidParameterError("alpha","number between 0 and 1",e);else this.options.ensureAlpha=1;return this}function su(e){let t={red:0,green:1,blue:2,alpha:3};if(Object.keys(t).includes(e)&&(e=t[e]),Ie.integer(e)&&Ie.inRange(e,0,4))this.options.extractChannel=e;else throw Ie.invalidParameterError("channel","integer or one of: red, green, blue, alpha",e);return this}function nu(e,t){return Array.isArray(e)?e.forEach(function(r){this.options.joinChannelIn.push(this._createInputDescriptor(r,t))},this):this.options.joinChannelIn.push(this._createInputDescriptor(e,t)),this}function iu(e){if(Ie.string(e)&&Ie.inArray(e,["and","or","eor"]))this.options.bandBoolOp=e;else throw Ie.invalidParameterError("boolOp","one of: and, or, eor",e);return this}gi.exports=e=>{Object.assign(e.prototype,{removeAlpha:tu,ensureAlpha:ru,extractChannel:su,joinChannel:nu,bandbool:iu}),e.bool=eu}});var wi=_((Lh,yi)=>{var Tr=V("node:path"),c=Re(),ht=xt(),mi=new Map([["heic","heif"],["heif","heif"],["avif","avif"],["jpeg","jpeg"],["jpg","jpeg"],["jpe","jpeg"],["tile","tile"],["dz","tile"],["png","png"],["raw","raw"],["tiff","tiff"],["tif","tiff"],["webp","webp"],["gif","gif"],["jp2","jp2"],["jpx","jp2"],["j2k","jp2"],["j2c","jp2"],["jxl","jxl"]]),ou=/\.(jp[2x]|j2[kc])$/i,bi=()=>new Error("JP2 output requires libvips with support for OpenJPEG"),vi=e=>1<<31-Math.clz32(Math.ceil(Math.log2(e)));function au(e,t){let r;if(c.string(e)?c.string(this.options.input.file)&&Tr.resolve(this.options.input.file)===Tr.resolve(e)?r=new Error("Cannot use same file for input and output"):ou.test(Tr.extname(e))&&!this.constructor.format.jp2k.output.file&&(r=bi()):r=new Error("Missing output file path"),r)if(c.fn(t))t(r);else return Promise.reject(r);else{this.options.fileOut=e;let s=Error();return this._pipeline(t,s)}return this}function lu(e,t){c.object(e)?this._setBooleanOption("resolveWithObject",e.resolveWithObject):this.options.resolveWithObject&&(this.options.resolveWithObject=!1),this.options.fileOut="";let r=Error();return this._pipeline(c.fn(e)?e:t,r)}function cu(){return this.options.keepMetadata|=1,this}function uu(e){if(c.object(e))for(let[t,r]of Object.entries(e))if(c.object(r))for(let[s,n]of Object.entries(r))if(c.string(n))this.options.withExif[`exif-${t.toLowerCase()}-${s}`]=n;else throw c.invalidParameterError(`${t}.${s}`,"string",n);else throw c.invalidParameterError(t,"object",r);else throw c.invalidParameterError("exif","object",e);return this.options.withExifMerge=!1,this.keepExif()}function fu(e){return this.withExif(e),this.options.withExifMerge=!0,this}function hu(){return this.options.keepMetadata|=8,this}function du(e,t){if(c.string(e))this.options.withIccProfile=e;else throw c.invalidParameterError("icc","string",e);if(this.keepIccProfile(),c.object(t)&&c.defined(t.attach))if(c.bool(t.attach))t.attach||(this.options.keepMetadata&=-9);else throw c.invalidParameterError("attach","boolean",t.attach);return this}function gu(){return this.options.keepMetadata|=2,this}function pu(e){if(c.string(e)&&e.length>0)this.options.withXmp=e,this.options.keepMetadata|=2;else throw c.invalidParameterError("xmp","non-empty string",e);return this}function mu(){return this.options.keepMetadata=31,this}function bu(e){if(this.keepMetadata(),this.withIccProfile("srgb"),c.object(e)){if(c.defined(e.orientation))if(c.integer(e.orientation)&&c.inRange(e.orientation,1,8))this.options.withMetadataOrientation=e.orientation;else throw c.invalidParameterError("orientation","integer between 1 and 8",e.orientation);if(c.defined(e.density))if(c.number(e.density)&&e.density>0)this.options.withMetadataDensity=e.density;else throw c.invalidParameterError("density","positive number",e.density);c.defined(e.icc)&&this.withIccProfile(e.icc),c.defined(e.exif)&&this.withExifMerge(e.exif)}return this}function vu(e,t){let r=mi.get((c.object(e)&&c.string(e.id)?e.id:e).toLowerCase());if(!r)throw c.invalidParameterError("format",`one of: ${[...mi.keys()].join(", ")}`,e);return this[r](t)}function yu(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.jpegQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.progressive)&&this._setBooleanOption("jpegProgressive",e.progressive),c.defined(e.chromaSubsampling))if(c.string(e.chromaSubsampling)&&c.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=e.chromaSubsampling;else throw c.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling);let t=c.bool(e.optimizeCoding)?e.optimizeCoding:e.optimiseCoding;if(c.defined(t)&&this._setBooleanOption("jpegOptimiseCoding",t),c.defined(e.mozjpeg))if(c.bool(e.mozjpeg))e.mozjpeg&&(this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3);else throw c.invalidParameterError("mozjpeg","boolean",e.mozjpeg);let r=c.bool(e.trellisQuantization)?e.trellisQuantization:e.trellisQuantisation;c.defined(r)&&this._setBooleanOption("jpegTrellisQuantisation",r),c.defined(e.overshootDeringing)&&this._setBooleanOption("jpegOvershootDeringing",e.overshootDeringing);let s=c.bool(e.optimizeScans)?e.optimizeScans:e.optimiseScans;c.defined(s)&&(this._setBooleanOption("jpegOptimiseScans",s),s&&(this.options.jpegProgressive=!0));let n=c.number(e.quantizationTable)?e.quantizationTable:e.quantisationTable;if(c.defined(n))if(c.integer(n)&&c.inRange(n,0,8))this.options.jpegQuantisationTable=n;else throw c.invalidParameterError("quantisationTable","integer between 0 and 8",n)}return this._updateFormatOut("jpeg",e)}function wu(e){if(c.object(e)){if(c.defined(e.progressive)&&this._setBooleanOption("pngProgressive",e.progressive),c.defined(e.compressionLevel))if(c.integer(e.compressionLevel)&&c.inRange(e.compressionLevel,0,9))this.options.pngCompressionLevel=e.compressionLevel;else throw c.invalidParameterError("compressionLevel","integer between 0 and 9",e.compressionLevel);c.defined(e.adaptiveFiltering)&&this._setBooleanOption("pngAdaptiveFiltering",e.adaptiveFiltering);let t=e.colours||e.colors;if(c.defined(t))if(c.integer(t)&&c.inRange(t,2,256))this.options.pngBitdepth=vi(t);else throw c.invalidParameterError("colours","integer between 2 and 256",t);if(c.defined(e.palette)?this._setBooleanOption("pngPalette",e.palette):[e.quality,e.effort,e.colours,e.colors,e.dither].some(c.defined)&&this._setBooleanOption("pngPalette",!0),this.options.pngPalette){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,0,100))this.options.pngQuality=e.quality;else throw c.invalidParameterError("quality","integer between 0 and 100",e.quality);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,1,10))this.options.pngEffort=e.effort;else throw c.invalidParameterError("effort","integer between 1 and 10",e.effort);if(c.defined(e.dither))if(c.number(e.dither)&&c.inRange(e.dither,0,1))this.options.pngDither=e.dither;else throw c.invalidParameterError("dither","number between 0.0 and 1.0",e.dither)}}return this._updateFormatOut("png",e)}function Eu(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.webpQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.alphaQuality))if(c.integer(e.alphaQuality)&&c.inRange(e.alphaQuality,0,100))this.options.webpAlphaQuality=e.alphaQuality;else throw c.invalidParameterError("alphaQuality","integer between 0 and 100",e.alphaQuality);if(c.defined(e.lossless)&&this._setBooleanOption("webpLossless",e.lossless),c.defined(e.nearLossless)&&this._setBooleanOption("webpNearLossless",e.nearLossless),c.defined(e.smartSubsample)&&this._setBooleanOption("webpSmartSubsample",e.smartSubsample),c.defined(e.smartDeblock)&&this._setBooleanOption("webpSmartDeblock",e.smartDeblock),c.defined(e.preset))if(c.string(e.preset)&&c.inArray(e.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=e.preset;else throw c.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",e.preset);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,0,6))this.options.webpEffort=e.effort;else throw c.invalidParameterError("effort","integer between 0 and 6",e.effort);c.defined(e.minSize)&&this._setBooleanOption("webpMinSize",e.minSize),c.defined(e.mixed)&&this._setBooleanOption("webpMixed",e.mixed)}return Cr(e,this.options),this._updateFormatOut("webp",e)}function xu(e){if(c.object(e)){c.defined(e.reuse)&&this._setBooleanOption("gifReuse",e.reuse),c.defined(e.progressive)&&this._setBooleanOption("gifProgressive",e.progressive);let t=e.colours||e.colors;if(c.defined(t))if(c.integer(t)&&c.inRange(t,2,256))this.options.gifBitdepth=vi(t);else throw c.invalidParameterError("colours","integer between 2 and 256",t);if(c.defined(e.effort))if(c.number(e.effort)&&c.inRange(e.effort,1,10))this.options.gifEffort=e.effort;else throw c.invalidParameterError("effort","integer between 1 and 10",e.effort);if(c.defined(e.dither))if(c.number(e.dither)&&c.inRange(e.dither,0,1))this.options.gifDither=e.dither;else throw c.invalidParameterError("dither","number between 0.0 and 1.0",e.dither);if(c.defined(e.interFrameMaxError))if(c.number(e.interFrameMaxError)&&c.inRange(e.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=e.interFrameMaxError;else throw c.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",e.interFrameMaxError);if(c.defined(e.interPaletteMaxError))if(c.number(e.interPaletteMaxError)&&c.inRange(e.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=e.interPaletteMaxError;else throw c.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",e.interPaletteMaxError);if(c.defined(e.keepDuplicateFrames))if(c.bool(e.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",e.keepDuplicateFrames);else throw c.invalidParameterError("keepDuplicateFrames","boolean",e.keepDuplicateFrames)}return Cr(e,this.options),this._updateFormatOut("gif",e)}function Pu(e){if(!this.constructor.format.jp2k.output.buffer)throw bi();if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.jp2Quality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.lossless))if(c.bool(e.lossless))this.options.jp2Lossless=e.lossless;else throw c.invalidParameterError("lossless","boolean",e.lossless);if(c.defined(e.tileWidth))if(c.integer(e.tileWidth)&&c.inRange(e.tileWidth,1,32768))this.options.jp2TileWidth=e.tileWidth;else throw c.invalidParameterError("tileWidth","integer between 1 and 32768",e.tileWidth);if(c.defined(e.tileHeight))if(c.integer(e.tileHeight)&&c.inRange(e.tileHeight,1,32768))this.options.jp2TileHeight=e.tileHeight;else throw c.invalidParameterError("tileHeight","integer between 1 and 32768",e.tileHeight);if(c.defined(e.chromaSubsampling))if(c.string(e.chromaSubsampling)&&c.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=e.chromaSubsampling;else throw c.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling)}return this._updateFormatOut("jp2",e)}function Cr(e,t){if(c.object(e)&&c.defined(e.loop))if(c.integer(e.loop)&&c.inRange(e.loop,0,65535))t.loop=e.loop;else throw c.invalidParameterError("loop","integer between 0 and 65535",e.loop);if(c.object(e)&&c.defined(e.delay))if(c.integer(e.delay)&&c.inRange(e.delay,0,65535))t.delay=[e.delay];else if(Array.isArray(e.delay)&&e.delay.every(c.integer)&&e.delay.every(r=>c.inRange(r,0,65535)))t.delay=e.delay;else throw c.invalidParameterError("delay","integer or an array of integers between 0 and 65535",e.delay)}function Su(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.tiffQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.bitdepth))if(c.integer(e.bitdepth)&&c.inArray(e.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=e.bitdepth;else throw c.invalidParameterError("bitdepth","1, 2, 4 or 8",e.bitdepth);if(c.defined(e.tile)&&this._setBooleanOption("tiffTile",e.tile),c.defined(e.tileWidth))if(c.integer(e.tileWidth)&&e.tileWidth>0)this.options.tiffTileWidth=e.tileWidth;else throw c.invalidParameterError("tileWidth","integer greater than zero",e.tileWidth);if(c.defined(e.tileHeight))if(c.integer(e.tileHeight)&&e.tileHeight>0)this.options.tiffTileHeight=e.tileHeight;else throw c.invalidParameterError("tileHeight","integer greater than zero",e.tileHeight);if(c.defined(e.miniswhite)&&this._setBooleanOption("tiffMiniswhite",e.miniswhite),c.defined(e.pyramid)&&this._setBooleanOption("tiffPyramid",e.pyramid),c.defined(e.xres))if(c.number(e.xres)&&e.xres>0)this.options.tiffXres=e.xres;else throw c.invalidParameterError("xres","number greater than zero",e.xres);if(c.defined(e.yres))if(c.number(e.yres)&&e.yres>0)this.options.tiffYres=e.yres;else throw c.invalidParameterError("yres","number greater than zero",e.yres);if(c.defined(e.compression))if(c.string(e.compression)&&c.inArray(e.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=e.compression;else throw c.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",e.compression);if(c.defined(e.bigtiff)&&this._setBooleanOption("tiffBigtiff",e.bigtiff),c.defined(e.predictor))if(c.string(e.predictor)&&c.inArray(e.predictor,["none","horizontal","float"]))this.options.tiffPredictor=e.predictor;else throw c.invalidParameterError("predictor","one of: none, horizontal, float",e.predictor);if(c.defined(e.resolutionUnit))if(c.string(e.resolutionUnit)&&c.inArray(e.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=e.resolutionUnit;else throw c.invalidParameterError("resolutionUnit","one of: inch, cm",e.resolutionUnit)}return this._updateFormatOut("tiff",e)}function Ru(e){return this.heif({...e,compression:"av1"})}function $u(e){if(c.object(e)){if(c.string(e.compression)&&c.inArray(e.compression,["av1","hevc"]))this.options.heifCompression=e.compression;else throw c.invalidParameterError("compression","one of: av1, hevc",e.compression);if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.heifQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.lossless))if(c.bool(e.lossless))this.options.heifLossless=e.lossless;else throw c.invalidParameterError("lossless","boolean",e.lossless);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,0,9))this.options.heifEffort=e.effort;else throw c.invalidParameterError("effort","integer between 0 and 9",e.effort);if(c.defined(e.chromaSubsampling))if(c.string(e.chromaSubsampling)&&c.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=e.chromaSubsampling;else throw c.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling);if(c.defined(e.bitdepth))if(c.integer(e.bitdepth)&&c.inArray(e.bitdepth,[8,10,12])){if(e.bitdepth!==8&&this.constructor.versions.heif)throw c.invalidParameterError("bitdepth when using prebuilt binaries",8,e.bitdepth);this.options.heifBitdepth=e.bitdepth}else throw c.invalidParameterError("bitdepth","8, 10 or 12",e.bitdepth)}else throw c.invalidParameterError("options","Object",e);return this._updateFormatOut("heif",e)}function ku(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.jxlDistance=e.quality>=30?.1+(100-e.quality)*.09:53/3e3*e.quality*e.quality-23/20*e.quality+25;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);else if(c.defined(e.distance))if(c.number(e.distance)&&c.inRange(e.distance,0,15))this.options.jxlDistance=e.distance;else throw c.invalidParameterError("distance","number between 0.0 and 15.0",e.distance);if(c.defined(e.decodingTier))if(c.integer(e.decodingTier)&&c.inRange(e.decodingTier,0,4))this.options.jxlDecodingTier=e.decodingTier;else throw c.invalidParameterError("decodingTier","integer between 0 and 4",e.decodingTier);if(c.defined(e.lossless))if(c.bool(e.lossless))this.options.jxlLossless=e.lossless;else throw c.invalidParameterError("lossless","boolean",e.lossless);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,1,9))this.options.jxlEffort=e.effort;else throw c.invalidParameterError("effort","integer between 1 and 9",e.effort)}return Cr(e,this.options),this._updateFormatOut("jxl",e)}function Au(e){if(c.object(e)&&c.defined(e.depth))if(c.string(e.depth)&&c.inArray(e.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=e.depth;else throw c.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",e.depth);return this._updateFormatOut("raw")}function _u(e){if(c.object(e)){if(c.defined(e.size))if(c.integer(e.size)&&c.inRange(e.size,1,8192))this.options.tileSize=e.size;else throw c.invalidParameterError("size","integer between 1 and 8192",e.size);if(c.defined(e.overlap))if(c.integer(e.overlap)&&c.inRange(e.overlap,0,8192)){if(e.overlap>this.options.tileSize)throw c.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,e.overlap);this.options.tileOverlap=e.overlap}else throw c.invalidParameterError("overlap","integer between 0 and 8192",e.overlap);if(c.defined(e.container))if(c.string(e.container)&&c.inArray(e.container,["fs","zip"]))this.options.tileContainer=e.container;else throw c.invalidParameterError("container","one of: fs, zip",e.container);if(c.defined(e.layout))if(c.string(e.layout)&&c.inArray(e.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=e.layout;else throw c.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",e.layout);if(c.defined(e.angle))if(c.integer(e.angle)&&!(e.angle%90))this.options.tileAngle=e.angle;else throw c.invalidParameterError("angle","positive/negative multiple of 90",e.angle);if(this._setBackgroundColourOption("tileBackground",e.background),c.defined(e.depth))if(c.string(e.depth)&&c.inArray(e.depth,["onepixel","onetile","one"]))this.options.tileDepth=e.depth;else throw c.invalidParameterError("depth","one of: onepixel, onetile, one",e.depth);if(c.defined(e.skipBlanks))if(c.integer(e.skipBlanks)&&c.inRange(e.skipBlanks,-1,65535))this.options.tileSkipBlanks=e.skipBlanks;else throw c.invalidParameterError("skipBlanks","integer between -1 and 255/65535",e.skipBlanks);else c.defined(e.layout)&&e.layout==="google"&&(this.options.tileSkipBlanks=5);let t=c.bool(e.center)?e.center:e.centre;if(c.defined(t)&&this._setBooleanOption("tileCentre",t),c.defined(e.id))if(c.string(e.id))this.options.tileId=e.id;else throw c.invalidParameterError("id","string",e.id);if(c.defined(e.basename))if(c.string(e.basename))this.options.tileBasename=e.basename;else throw c.invalidParameterError("basename","string",e.basename)}if(c.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw c.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function Nu(e){if(!c.plainObject(e))throw c.invalidParameterError("options","object",e);if(c.integer(e.seconds)&&c.inRange(e.seconds,0,3600))this.options.timeoutSeconds=e.seconds;else throw c.invalidParameterError("seconds","integer between 0 and 3600",e.seconds);return this}function Iu(e,t){return c.object(t)&&t.force===!1||(this.options.formatOut=e),this}function Du(e,t){if(c.bool(t))this.options[e]=t;else throw c.invalidParameterError(e,"boolean",t)}function Tu(){if(!this.options.streamOut){this.options.streamOut=!0;let e=Error();this._pipeline(void 0,e)}}function Cu(e,t){return typeof e=="function"?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),ht.pipeline(this.options,(r,s,n)=>{r?e(c.nativeError(r,t)):e(null,s,n)})}):ht.pipeline(this.options,(r,s,n)=>{r?e(c.nativeError(r,t)):e(null,s,n)}),this):this.options.streamOut?(this._isStreamInput()?(this.once("finish",()=>{this._flattenBufferIn(),ht.pipeline(this.options,(r,s,n)=>{r?this.emit("error",c.nativeError(r,t)):(this.emit("info",n),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished&&this.emit("finish")):ht.pipeline(this.options,(r,s,n)=>{r?this.emit("error",c.nativeError(r,t)):(this.emit("info",n),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))}),this):this._isStreamInput()?new Promise((r,s)=>{this.once("finish",()=>{this._flattenBufferIn(),ht.pipeline(this.options,(n,i,o)=>{n?s(c.nativeError(n,t)):this.options.resolveWithObject?r({data:i,info:o}):r(i)})})}):new Promise((r,s)=>{ht.pipeline(this.options,(n,i,o)=>{n?s(c.nativeError(n,t)):this.options.resolveWithObject?r({data:i,info:o}):r(i)})})}yi.exports=e=>{Object.assign(e.prototype,{toFile:au,toBuffer:lu,keepExif:cu,withExif:uu,withExifMerge:fu,keepIccProfile:hu,withIccProfile:du,keepXmp:gu,withXmp:pu,keepMetadata:mu,withMetadata:bu,toFormat:vu,jpeg:yu,jp2:Pu,png:wu,webp:Eu,tiff:Su,avif:Ru,heif:$u,jxl:ku,gif:xu,raw:Au,tile:_u,timeout:Nu,_updateFormatOut:Iu,_setBooleanOption:Du,_read:Tu,_pipeline:Cu})}});var Si=_((Mh,Pi)=>{var Fu=V("node:events"),Ht=Tt(),ve=Re(),{runtimePlatformArch:Ou}=Pr(),le=xt(),Ei=Ou(),Fr=le.libvipsVersion(),qe=le.format();qe.heif.output.alias=["avif","heic"];qe.jpeg.output.alias=["jpe","jpg"];qe.tiff.output.alias=["tif"];qe.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var ju={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},dt={vips:Fr.semver};if(!Fr.isGlobal)if(Fr.isWasm)try{dt=V("@img/sharp-wasm32/versions")}catch{}else try{dt=V(`@img/sharp-${Ei}/versions`)}catch{try{dt=V(`@img/sharp-libvips-${Ei}/versions`)}catch{}}dt.sharp=Er().version;dt.heif&&qe.heif&&(qe.heif.input.fileSuffix=[".avif"],qe.heif.output.alias=["avif"]);function xi(e){return ve.bool(e)?e?le.cache(50,20,100):le.cache(0,0,0):ve.object(e)?le.cache(e.memory,e.files,e.items):le.cache()}xi(!0);function Lu(e){return le.concurrency(ve.integer(e)?e:null)}Ht.familySync()===Ht.GLIBC&&!le._isUsingJemalloc()?le.concurrency(1):Ht.familySync()===Ht.MUSL&&le.concurrency()===1024&&le.concurrency(V("node:os").availableParallelism());var Mu=new Fu.EventEmitter;function zu(){return le.counters()}function Bu(e){return le.simd(ve.bool(e)?e:null)}function Uu(e){if(ve.object(e))if(Array.isArray(e.operation)&&e.operation.every(ve.string))le.block(e.operation,!0);else throw ve.invalidParameterError("operation","Array<string>",e.operation);else throw ve.invalidParameterError("options","object",e)}function Gu(e){if(ve.object(e))if(Array.isArray(e.operation)&&e.operation.every(ve.string))le.block(e.operation,!1);else throw ve.invalidParameterError("operation","Array<string>",e.operation);else throw ve.invalidParameterError("options","object",e)}Pi.exports=e=>{e.cache=xi,e.concurrency=Lu,e.counters=zu,e.simd=Bu,e.format=qe,e.interpolators=ju,e.versions=dt,e.queue=Mu,e.block=Uu,e.unblock=Gu}});var $i=_((Bh,Ri)=>{var je=Mn();Un()(je);Jn()(je);Yn()(je);ti()(je);di()(je);pi()(je);wi()(je);Si()(je);Ri.exports=je});import po from"@rollup/plugin-strip";import{visualizer as mo}from"rollup-plugin-visualizer";var tr=["/react/","/react-dom/","/scheduler/","/react-router","/@radix-ui/","/react-day-picker/","/react-hook-form/","/react-i18next/","/clsx/","/class-variance-authority/"],ro={valibot:["/valibot/"],firebase:["/firebase/","/@firebase/"],lucide:["/lucide-react/","/lucide/"],i18n:["/i18next/","/i18next-browser-languagedetector/","/i18next-http-backend/","/@donotdev/i18n/"],zustand:["/zustand/"],"tanstack-query":["/@tanstack/react-query/","/@tanstack/query-core/"]};function so(e){let t=e.match(/(?:^|\0)virtual:([^?]+)/);if(t)return t[1]}function Gr(e){let t=e.replace(/\\/g,"/");if(t.includes("/node_modules/"))return t.split("?")[0]}function qr(e,t=tr){return t.some(r=>e.includes(r))}function no(e){for(let[t,r]of Object.entries(ro))if(r.some(s=>e.includes(s)))return t}function io(e){let t=so(e);if(t)return t==="i18n-mapping"?"virtual-i18n-mapping":"virtual-modules";let r=Gr(e);if(!r)return;if(qr(r))return"react-core";let s=no(r);if(s)return s}function oo(e=[]){let t=e.filter(s=>!tr.includes(s)),r=[...tr,...t];return function(s){let n=Gr(s);if(n&&qr(n,r))return"react-core"}}var Ur={development:{manualChunks:void 0},production:{manualChunks:io}};function Wr(e,t={}){let r=Ur[e]||Ur.production,s=t.reactCore||[];return s.length>0?{manualChunks:oo(s)}:r}import*as T from"node:fs";import"node:fs";import{createRequire as lo}from"node:module";import{resolve as At,join as Te,dirname as Me,relative as Xr,normalize as co,sep as Yr,extname as uo}from"node:path";import{fileURLToPath as fo}from"node:url";import ho from"fast-glob";var rr={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"};var W={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env"},ne={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},Q={next:{middleware:"middleware.ts",routeManifest:"public/route-manifest.json",assetManifest:"public/asset-manifest.json",utilities:"src/styles/utilities.generated.css",appPages:"src/app",appLayout:"src/app/layout.tsx",configRoute:"src/config/dndev-config-route.js",configTheme:"src/config/dndev-config-theme.js",configI18n:"src/config/dndev-config-i18n.js",configPwa:"src/config/dndev-config-pwa.js",configAsset:"src/config/dndev-config-asset.js",configSeo:"src/config/dndev-config-seo.js",configServer:"src/config/dndev-config-server.js"},vite:{routeInspection:"src/routes.generated.log",themeInspection:"src/themes.generated.log",i18nInspection:"src/i18n.generated.log",assetInspection:"src/assets.generated.log",envInspection:"src/env.generated.log"},manifests:{route:"route-manifest.json",theme:"theme-manifest.json",i18n:"i18n-manifest.json",asset:"asset-manifest.json",feature:"feature-manifest.json",env:"env-manifest.json"}},sr={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},mt={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},$t={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},pe={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${$t.SOURCE_EAGER}/*_*.json`],lazy:[`${$t.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]},Xe={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async","@donotdev/core","@donotdev/components","@donotdev/ui","@donotdev/templates","@donotdev/firebase"],optionalFeatures:["@donotdev/components","@donotdev/auth","@donotdev/billing","@donotdev/crud","@donotdev/oauth","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder"],coreBundled:["@donotdev/types","@donotdev/utils","@donotdev/stores","@donotdev/schemas","@donotdev/hooks","@donotdev/i18n","@donotdev/config"],componentsBundled:["class-variance-authority","clsx","lucide-react","react-day-picker"],radixUIPattern:"@radix-ui/",buildTools:["esbuild","@esbuild/win32-x64","@esbuild/darwin-x64","@esbuild/linux-x64","@esbuild/darwin-arm64","@esbuild/linux-arm64","vite","rollup","rollup-plugin-visualizer","@vitejs/plugin-react","vite-tsconfig-paths","vite-plugin-pwa","vite-plugin-compression2","vite-plugin-node-polyfills","fsevents","postcss","postcss-import","postcss-nesting","autoprefixer"],buildTimePackages:[],largeOptional:["@sentry/react","framer-motion","stripe","@tanstack/react-query","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder","sharp","semver","file-type"]},Vr=["firebase-admin","gcp-metadata","google-logging-utils","payload","undici","@fastify/busboy","image-size","@donotdev/tooling","fs","path","crypto","net","tls","http","https","child_process","os","util","stream","buffer","events","querystring","url","zlib","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","cluster","dgram","dns","http2","inspector","module","perf_hooks","process","readline","repl","trace_events","v8","wasi"],nr=["@donotdev/core/functions","@donotdev/core/server"],ir={selectors:{class:/\.([a-zA-Z0-9-]+)/g,variable:/--[a-zA-Z0-9-]+/g,keyframe:/@keyframes\s+([a-zA-Z0-9-]+)/g},themes:{themeClass:/(?::root\.|\.)([a-z][a-z0-9-]+)\s*\{([\s\S]*?)\}/gim,themeLabel:/--theme-label\s*:\s*['"]([^'"]+)['"]/,themeIcon:/--theme-icon\s*:\s*['"]([^'"]+)['"]/,themeIsDark:/--theme-is-dark\s*:\s*(0|1)/}},bt={Inter:"inter-latin","Space Grotesk":"space-grotesk-latin","Playfair Display":"playfair-display-latin","Press Start 2P":"press-start-2p-latin",Roboto:"roboto-latin"},or=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],Hr={base:{absolute:!0,onlyFiles:!0,ignore:pe.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...pe.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...pe.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:pe.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:pe.globalIgnore}};function Jr(e,t=null){let r=pe[e];if(!r)throw new Error(`Unknown pattern type: ${e}`);return t&&r.framework?{...r,framework:r.framework.map(s=>`${t}/${s}`)}:r}function kt(e){return Hr[e]||Hr.base}var rt={getGlobOptionsFor:kt||void 0,SCAN_PATTERNS:pe||void 0,getPatternsFor:Jr||void 0,I18N_PATHS:$t||void 0},Z={error:(e,t)=>{},warn:(e,t)=>{},info:e=>{}};function Kr(e,t){return e().catch(r=>{throw new Error(`${t}: ${r instanceof Error?r.message:String(r)}`)})}var Qr={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},G=class e{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(t={}){return e._instance||(e._instance=new e(t)),e._instance}static _reset(){e._instance=null}constructor(t={}){if(e._instance)return e._instance;this.options={maxLevels:t.maxLevels??10,customMarkers:t.customMarkers||[],cache:t.cache??!1,debug:t.debug??!1};try{let r=process.cwd();if(!r)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(r)}catch(r){throw new Error(`PathResolver constructor failed: ${r instanceof Error?r.message:String(r)}. cwd: ${process.cwd()}`)}this._appRoot=null,e._instance=this}normalizePath(t){if(!t)return"";try{return co(t).split(Yr).join("/")}catch{return String(t).split(Yr).join("/")}}getRelativePath(t){let r=this.getAppRoot(),s=Xr(r,t);return this.normalizePath(s)}getBasename(t){if(!t)return"";let s=this.normalizePath(t).split("/");return s[s.length-1]||""}getDirname(t){return t?this.normalizePath(Me(t)):""}resolvePackage(t,r=null){try{let s=r||this.getAppRoot(),i=lo(Te(s,"package.json")).resolve(t);return this.normalizePath(i)}catch{return null}}resolveFrameworkPackage(t,r=null){let s=this.resolvePackage(`${t}/package.json`,r);if(s)return this.getDirname(s);if(this.isMonorepo()&&t.startsWith("@donotdev/")){let o=t.replace("@donotdev/",""),a=this.resolveRepoPath(`packages/${o}`);if(this.pathExists(a))return a;if(["auth","billing","crud","oauth"].includes(o)){let l=this.resolveRepoPath(`packages/features/${o}`);if(this.pathExists(l))return l}if(o==="firebase"){let l=this.resolveRepoPath(`packages/providers/${o}`);if(this.pathExists(l))return l}}let n=this.resolveAppPath(`node_modules/${t}`);if(this.pathExists(n))return n;let i=this.resolveRepoPath(`node_modules/${t}`);return this.pathExists(i)?i:null}resolvePackageAsset(t,r=null){return this.resolvePackage(t,r)}resolveAppPath(t){let r=this.getAppRoot(),s=At(r,t);return this.normalizePath(s)}resolveRepoPath(t){let r=this.getRepoRoot(),s=this.normalizePath(t),n=At(r,s);return this.normalizePath(n)}resolvePath(t,r){let s=this.normalizePath(r),n=this.normalizePath(t),i=At(s,n);return this.normalizePath(i)}createImportPath(t){return"./"+this.getRelativePath(t)}getFileInfo(t){try{let r=T.statSync(t);return{absolutePath:this.normalizePath(t),relativePath:this.getRelativePath(t),importPath:this.createImportPath(t),size:r.size,isFile:r.isFile(),isDirectory:r.isDirectory()}}catch{return null}}_detectFormat(t,r){return r&&r!=="auto"?r:uo(t).toLowerCase()===".json"?"json":"text"}async read(t,r={}){let{format:s="auto",encoding:n="utf8"}=r,i=this._detectFormat(t,s);try{if(i==="buffer")return await T.promises.readFile(t);let o=await T.promises.readFile(t,n),a=this.stripBom(o);return i==="json"?JSON.parse(a):a}catch(o){return this.options.debug&&Z.warn(`Failed to read file: ${t}`,o),null}}readSync(t,r={}){let{format:s="auto",encoding:n="utf8"}=r,i=this._detectFormat(t,s);try{if(i==="buffer")return T.readFileSync(t);let o=T.readFileSync(t,n),a=this.stripBom(o);return i==="json"?JSON.parse(a):a}catch(o){return this.options.debug&&Z.warn(`Failed to read file: ${t}`,o),null}}async write(t,r,s={}){let{format:n="auto",overwrite:i=!1,dryRun:o=!1,verbose:a=!1}=s,l=this.normalizePath(t),f=this.normalizePath(Me(l)),u=this.pathExists(l);if(u&&!i)return a&&Z.info(`Skipping existing file: ${l}`),!1;if(o)return Z.info(`[DRY RUN] Would write file: ${l}`),!0;try{await T.promises.mkdir(f,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let g=this._detectFormat(t,n),p;Buffer.isBuffer(r)?p=r:g==="json"&&typeof r=="object"?p=JSON.stringify(r,null,2):p=String(r);try{return await Kr(async()=>(Buffer.isBuffer(p)?await T.promises.writeFile(l,p):await T.promises.writeFile(l,p,"utf8"),a&&Z.info(`${u?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(t,r,s={}){let{format:n="auto",overwrite:i=!1,dryRun:o=!1,verbose:a=!1}=s,l=this.normalizePath(t),f=this.normalizePath(Me(l)),u=this.pathExists(l);if(u&&!i)return a&&Z.info(`Skipping existing file: ${l}`),!1;if(o)return Z.info(`[DRY RUN] Would write file: ${l}`),!0;try{T.mkdirSync(f,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let g=this._detectFormat(t,n),p;Buffer.isBuffer(r)?p=r:g==="json"&&typeof r=="object"?p=JSON.stringify(r,null,2):p=String(r);try{return Buffer.isBuffer(p)?T.writeFileSync(l,p):T.writeFileSync(l,p,"utf8"),a&&Z.info(`${u?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(t,r,s={}){let{overwrite:n=!1,dryRun:i=!1,verbose:o=!1}=s,a=this.normalizePath(r),l=this.pathExists(a);if(l&&!n)return o&&Z.info(`Skipping existing file: ${a}`),!1;if(i)return Z.info(`[DRY RUN] Would copy file: ${a}`),!0;let f=this.normalizePath(Me(a));try{await T.promises.mkdir(f,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return await Kr(async()=>(await T.promises.copyFile(t,a),o&&Z.info(`${l?"Updated":"Created"} file: ${a}`),!0),`Failed to copy file from ${t} to ${a}`)}catch{return!1}}copySync(t,r,s={}){let{overwrite:n=!1,dryRun:i=!1,verbose:o=!1}=s,a=this.normalizePath(r),l=this.pathExists(a);if(l&&!n)return o&&Z.info(`Skipping existing file: ${a}`),!1;if(i)return Z.info(`[DRY RUN] Would copy file: ${a}`),!0;let f=this.normalizePath(Me(a));try{T.mkdirSync(f,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return T.copyFileSync(t,a),o&&Z.info(`${l?"Updated":"Created"} file: ${a}`),!0}catch{return!1}}pathExists(t,r=!1){try{return T.existsSync(t)}catch(s){return r||Z.error(`Error checking path existence: ${t}`,s),!1}}mkdir(t){try{let r=t.startsWith("/")||t.match(/^[A-Z]:/)?this.normalizePath(t):this.resolveAppPath(t);return T.existsSync(r)||T.mkdirSync(r,{recursive:!0}),!0}catch{return!1}}readdirSync(t,r){try{return T.readdirSync(t,r)}catch(s){return this.options.debug&&Z.warn(`Failed to read directory: ${t}`,s),r&&typeof r=="object"&&"withFileTypes"in r&&r.withFileTypes?[]:[]}}statSync(t){try{return T.statSync(t)}catch(r){return this.options.debug&&Z.warn(`Failed to stat file: ${t}`,r),null}}lstatSync(t){try{return T.lstatSync(t)}catch(r){return this.options.debug&&Z.warn(`Failed to lstat file: ${t}`,r),null}}async ensureDir(t){try{await T.promises.mkdir(t,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}ensureDirSync(t){try{T.mkdirSync(t,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}async remove(t){await T.promises.rm(t,{recursive:!0,force:!0})}removeSync(t){T.rmSync(t,{recursive:!0,force:!0})}async readdir(t,r){return T.promises.readdir(t,r)}stripBom(t){return t.charCodeAt(0)===65279?t.slice(1):t}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(t){if(!t)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(t)}isMonorepo(){let t=Te(this._repoRoot,"packages");return this.pathExists(t)}isWithinApp(t){let r=this.normalizePath(At(t)),s=this.getAppRoot(),n=Xr(s,r),i=this.normalizePath(n);return!i.startsWith("../")&&!i.startsWith("/")}async findFiles(t,r,s={}){let n=this.normalizePath(Te(t,r)),i=this.getAppRoot(),o=this.normalizePath(i),a=n.startsWith(o)?n.slice(o.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:i,ignore:rt.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([a],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(t){let r=rt.I18N_PATHS;if(!r)return null;let s=t.replace(r.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let i=this.normalizePath(Te(n,r.PUBLISHED_ROOT,s)),o=i.replace(/\/[^/]*\*.*$/,"");return this.pathExists(o),i}async _globWithNormalization(t,r){return(await ho(t,r)).map(n=>{let i=typeof n=="string"?n:n.path;return this.normalizePath(i)})}async resolveFiles(t,r="css"){if(!t||typeof t!="object")return{frameworkFiles:[],consumerFiles:[]};if(r==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(t.framework)||(t.framework=[]),!Array.isArray(t.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...t.framework,...t.consumer];for(let u of s)if(typeof u!="string"||u.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),i=rt.getGlobOptionsFor?rt.getGlobOptionsFor(r):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},o=this.normalizePath(n),a=t.framework.map(u=>{let g=this.normalizePath(u);return g.startsWith(o)?g.slice(o.length+1):g}),l=t.consumer.map(u=>{let g=this.normalizePath(u);return g.startsWith(o)?g.slice(o.length+1):g}),f={...i,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let u=a.length>0?await this._globWithNormalization(a,f):[],g=await this._globWithNormalization(l,f);return{frameworkFiles:u,consumerFiles:g}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(t){if(!rt.getPatternsFor)return{framework:[],consumer:[],all:[]};let r=this.getAppRoot(),s=this.getRepoRoot();if(t==="i18n"&&(!r||r===s))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${r}, repoRoot: ${s}). Ensure configResolved hook has run before discovery.`);let n=rt.getPatternsFor(t),i=this.isMonorepo();if(t==="i18n"){let l=n,f={eager:l.eager.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),lazy:l.lazy.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),framework:{eager:i?(l.framework?.eager||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean)),lazy:i?(l.framework?.lazy||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean))},all:[]};return f.all=[...f.eager,...f.lazy,...f.framework.eager,...f.framework.lazy],f}let o=n,a={framework:i?(o.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(o.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return a.all=[...a.consumer,...a.framework],a}getEmptyModulePath(t=!1){if(t)return"@donotdev/core/empty";let r=this.resolvePackage("@donotdev/core/empty");if(r)return r;let s=Me(fo(import.meta.url));return this.normalizePath(Te(s,"../empty.js"))}_findRepoRoot(t){let r=this.normalizePath(t),s=0,n=this.options.maxLevels;for(;s<n;){let i=this.normalizePath(Te(r,Qr.TOOLING)),o=this.normalizePath(Te(r,Qr.CORE));if(this.pathExists(i)&&this.pathExists(o))return r;let a=Te(r,"apps");if(this.pathExists(a)&&this.statSync(a)?.isDirectory())return this.normalizePath(r);let l=this.normalizePath(Te(r,"package.json"));if(this.pathExists(l)&&this.normalizePath(Me(r))===r)return r;let f=this.normalizePath(Me(r));if(f===r)break;r=f,s++}return this.normalizePath(t)}};var ce;try{ce=await import("@clack/prompts")}catch{ce={log:{message:e=>{},info:e=>{},warn:e=>{},error:e=>{},success:e=>{},step:e=>{}}}}var Ee={reset:"\x1B[0m",green:"\x1B[32m",brightGreen:"\x1B[92m",red:"\x1B[31m",brightRed:"\x1B[91m",yellow:"\x1B[33m",brightYellow:"\x1B[93m",blue:"\x1B[34m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",gray:"\x1B[90m",white:"\x1B[37m"};function go(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function Pe(e,t){return go()?`${t}${e}${Ee.reset}`:e}function M(e,t,r,s={}){let{logDir:n=".dndev-logs",fileLogging:i=!1}=s,o=G.getInstance(),a=null;if(i){let u=o.resolveAppPath(n);o.pathExists(u)||o.mkdir(u),a=o.resolveAppPath(`${n}/${e.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let g=`=== ${e} Log Started at ${new Date().toISOString()} ===
3
- `;o.writeSync(a,g)}let l=(u,g,p)=>{if(a){let m=new Date().toISOString(),S=p.length>0?" "+p.map(q=>typeof q=="object"?JSON.stringify(q,null,2):String(q)).join(" "):"",z=`${m} [${u}] ${g}${S}
4
- `;o.appendFile(a,z)}},f=(u,g)=>{if(g.length===0)return u;let p=g.map(m=>typeof m=="object"?JSON.stringify(m,null,2):String(m)).join(" ");return`${u} ${p}`};return{debug:(u,...g)=>{t&&(i?l("DEBUG",u,g):ce.log.message(Pe(f(u,g),Ee.gray)))},verbose:(u,...g)=>{r&&(i?l("VERBOSE",u,g):ce.log.message(f(u,g)))},info:(u,...g)=>{i?l("INFO",u,g):ce.log.info(Pe(f(u,g),Ee.brightCyan))},warn:(u,...g)=>{t&&i?l("WARN",u,g):ce.log.warn(Pe(f(u,g),Ee.brightYellow))},error:(u,...g)=>{t&&i?l("ERROR",u,g):ce.log.error(Pe(f(u,g),Ee.brightRed))},success:(u,...g)=>{t&&i?l("SUCCESS",u,g):ce.log.success(Pe(f(u,g),Ee.brightGreen))},when:(u,g="debug")=>(p,...m)=>{if(u){let S=f(p,m);switch(g){case"verbose":r&&(ce.log.message(S),l("VERBOSE",p,m));break;case"info":ce.log.info(Pe(S,Ee.brightCyan)),l("INFO",p,m);break;case"warn":ce.log.warn(Pe(S,Ee.brightYellow)),l("WARN",p,m);break;case"error":ce.log.error(Pe(S,Ee.brightRed)),l("ERROR",p,m);break;case"success":ce.log.success(Pe(S,Ee.brightGreen)),l("SUCCESS",p,m);break;default:t&&(ce.log.message(Pe(S,Ee.gray)),l("DEBUG",p,m))}}},getLogFilePath:()=>a}}function Zr(e={}){let{mode:t="development",chunkingOptions:r={},debug:s,verbose:n=!0,isDev:i,isDebug:o,shouldAnalyze:a,build:l={}}=e,f=M("build",s,n),u=Wr(t,r);return f.debug("\u{1F41B} DEBUG MODE ENABLED:"),f.debug(" - Minification: DISABLED"),f.debug(" - Sourcemaps: ENABLED"),f.debug(" - Console logs: PRESERVED"),f.debug(" - Debugger statements: PRESERVED"),a&&(f.info("\u{1F4CA} Bundle analysis enabled"),f.info(` Visual treemap will open after build (stats.html)
5
- `)),{outDir:"dist",sourcemap:i||o,cacheDir:"node_modules/.vite",target:"baseline-widely-available",minify:o?!1:"esbuild",reportCompressedSize:!1,chunkSizeWarningLimit:2048,assetsInlineLimit:0,esbuild:{format:"esm",drop:o?[]:["console","debugger"],legalComments:"none"},cssMinify:o?!1:"esbuild",cssCodeSplit:!0,rollupOptions:{external:bo(),output:{format:"es",entryFileNames:"assets/[name].[hash].js",chunkFileNames:"assets/[name].[hash].js",assetFileNames:"assets/[name].[hash][extname]",...u.manualChunks&&{manualChunks:u.manualChunks},compact:!0},onwarn(p,m){p.code!=="MODULE_LEVEL_DIRECTIVE"&&m(p)},plugins:[...o?[]:[po({include:["**/*.js","**/*.ts","**/*.tsx","**/*.jsx"],functions:["console.*","debugger"],labels:["debug"]})],...a?[(()=>{let p=G.getInstance(),m=p.getAppRoot(),S="dist",z=p.resolveAppPath(`${S}/stats.html`),q=()=>{try{let k=p.resolveAppPath(S);p.pathExists(k)||p.mkdir(k)}catch{}},$=mo({filename:z,open:!0,gzipSize:!0,brotliSize:!0,template:"treemap",sourcemap:i||o,projectRoot:m});if($.buildStart){let k=$.buildStart.bind($);$.buildStart=function(...D){q();let N=k.apply(this,D);return N&&typeof N.then=="function"?N.catch(E=>{}):N}}else $.buildStart=function(){q()};let C=["generateBundle","writeBundle","closeBundle"];for(let k of C)if($[k]){let D=$[k];$[k]=function(...N){try{q();let E=D.apply(this,N);return E&&typeof E.then=="function"?E.catch(B=>{let j=B?.message||B?.toString()||String(B)||"Unknown error";f.warn(`Bundle visualizer warning in ${k}: ${j}`),k==="closeBundle"&&f.warn(`You can manually open ${z} to view the bundle analysis`)}):E}catch(E){let B=E?.message||E?.toString()||String(E)||"Unknown error";buildLogger.warn(`Bundle visualizer warning in ${k}: ${B}`),k==="closeBundle"&&buildLogger.warn(` You can manually open ${z} to view the bundle analysis`)}}}return $})()]:[]]}}}function bo(e){return e?["firebase-admin","gcp-metadata","google-logging-utils","@google-cloud/firestore",/\.node$/,"esbuild",/@esbuild\/.*/]:["gcp-metadata","google-logging-utils","payload","file-type","firebase-admin","firebase-admin/app","firebase-admin/auth","firebase-admin/firestore","firebase-admin/functions","firebase-admin/credential","@google-cloud/firestore","google-auth-library","google-gax","googleapis-common"]}function vo(){let e=!1,t=G.getInstance();if((t.pathExists("/.dockerenv")||t.pathExists("/run/.containerenv"))&&(e=!0),!e&&(process.env.DOCKER_CONTAINER==="true"||process.env.IS_DOCKER==="true"||process.env.DOCKER_BUILDKIT==="1"||process.env.CI==="true"&&process.env.DOCKER==="true")&&(e=!0),!e&&process.env.DOCKER_HOST&&process.env.DOCKER_HOST.includes("docker")&&(e=!0),!e&&process.platform==="linux"&&t.pathExists("/proc/self/cgroup"))try{let n=t.readSync("/proc/self/cgroup");n&&(n.includes("docker")||n.includes("containerd"))&&(e=!0)}catch{}let r=!1;if((process.env.WSL_DISTRO_NAME||process.env.WSLENV)&&(r=!0),!r&&process.platform==="linux"&&t.pathExists("/proc/version"))try{let n=(t.readSync("/proc/version")||"").toLowerCase();r=n.includes("microsoft")||n.includes("wsl")}catch{}if(!r&&process.platform==="linux"&&t.pathExists("/proc/sys/kernel/osrelease"))try{let n=(t.readSync("/proc/sys/kernel/osrelease")||"").toLowerCase()||"";(n.includes("microsoft")||n.includes("wsl"))&&(r=!0)}catch{}if(!r&&process.platform==="win32"){let n=process.cwd();n&&(n.includes("\\wsl$")||n.includes("\\wsl.localhost"))&&(r=!0)}let s=typeof process.versions?.bun=="string";return{isDocker:e,isWSL2:r,isBun:s}}function yo(e,t){if(e!==void 0)return e;let{isDocker:r,isWSL2:s,isBun:n}=vo();if(r||s||n){let i=r?"Docker":s?"WSL2":"Bun";return t.info(`Detected ${i} environment - enabling polling mode for file watching`),!0}}function es(e,t={},r){let s=G.getInstance(),n=s.getRepoRoot(),{watch:i,hmr:o,host:a,...l}=t||{},f=o||{},u=a===!0?"localhost":a||"localhost",g={...f.port&&{port:f.port},...f.clientPort&&{clientPort:f.clientPort},host:f.host??u,...f.protocol&&{protocol:f.protocol},overlay:f.overlay??!0,timeout:f.timeout??5e3},p=a!==void 0?a:!0,m=l.https===!0;return{port:e,host:p,open:t.open!==void 0?t.open:!0,https:m,fs:{allow:[n,s.resolveRepoPath("packages"),s.resolveRepoPath("node_modules")],strict:!1},watch:{usePolling:yo(t?.watch?.usePolling,r),interval:t?.watch?.interval??2e3,...t?.watch||{}},hmr:{...g,...f},headers:{"Cross-Origin-Opener-Policy":"same-origin-allow-popups","Cross-Origin-Embedder-Policy":"unsafe-none"},middlewareMode:!1,...l}}function ts(e={}){let t=e.https===!0;return{...e,https:t}}var me={CONCATENATE_DEDUPE:"CONCATENATE_DEDUPE",SHALLOW_MERGE:"SHALLOW_MERGE",DEEP_MERGE:"DEEP_MERGE",REPLACE:"REPLACE"};function ze(e,t,r,s={}){let{protectedKeys:n=[],onConflict:i}=s;if(t==null)return e;switch(r){case me.CONCATENATE_DEDUPE:{if(!Array.isArray(e)||!Array.isArray(t))return t;let o=[...e,...t];return[...new Set(o)]}case me.SHALLOW_MERGE:return typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)||Array.isArray(t)?t:{...e,...t};case me.DEEP_MERGE:{if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)||Array.isArray(t))return t;let o={...e};for(let a in t){if(n.includes(a)){i&&i(a,e[a],t[a]);continue}typeof o[a]=="object"&&typeof t[a]=="object"&&o[a]!==null&&t[a]!==null&&!Array.isArray(o[a])&&!Array.isArray(t[a])?o[a]=ze(o[a],t[a],me.DEEP_MERGE,{protectedKeys:n,onConflict:i}):o[a]=t[a]}return o}case me.REPLACE:default:return t}}function rs(e,t,r=[],s){let n=[...e,...t||[]],i=[...new Set(n)];return[...new Set([...i,...r])]}var _t={base:"/",mode:process.env.NODE_ENV==="production"?"production":"development",debug:!1,verbose:process.env.CI!=="true",server:{port:3e3,strictPort:!0,host:!0,open:!0,cors:!0,https:!0,hmr:{overlay:!0,timeout:5e3,usePolling:void 0,interval:2e3},watch:{usePolling:void 0,interval:2e3}},build:{sourcemap:!0,target:"es2020",minify:"esbuild",cssMinify:"esbuild",analyze:!0},preview:{port:4173,strictPort:!0,host:!0,open:!1,cors:!0,https:!0},routes:{hmr:!0},themes:{},i18n:{},assets:{},features:{},pwa:{enabled:!1},seo:{disabled:!1,generateRobotsTxt:!0,generateSitemap:!0,crawlDelay:1},serverShim:{enabled:!0},chunking:{reactCore:[]},discovery:{verbose:!0,cacheTimeout:6e4,fileLogging:!1,logDir:".dndev-logs"},pluginFactory:{verbose:!0,disableHmr:!1,hmrSmartDetection:!0,hmrDebounceMs:500,hmrCacheTimeout:3e4},resolve:{alias:{"@":"/src"},preserveSymlinks:!1},define:{__DEV__:JSON.stringify(process.env.NODE_ENV==="development"),__PROD__:JSON.stringify(process.env.NODE_ENV==="production")},optimizeDeps:{include:[...Xe.mandatoryIncludes],exclude:[...Xe.buildTools,...Object.values(W)],esbuildOptions:{format:"esm",target:"es2020",platform:"browser",define:{"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"development")},external:["next","next/*"]}},plugins:[],css:{},envDir:void 0};function ss(e={},t={}){let{onConflict:r}=t,s={..._t},n=[],i=(o,a,l,f)=>{n.push({key:o,frameworkValue:a,userValue:l,reason:f}),r&&r(o,a,l,f)};return Object.keys(e).forEach(o=>{let a=e[o],l=s[o];if(o==="optimizeDeps"&&typeof a=="object"&&a!==null){let f=l?.include||[],u=l?.exclude||[],g=a.include||[],p=a.exclude||[],m=f.filter(C=>!C.startsWith("@donotdev/")),S=p.filter(C=>m.includes(C));if(S.length>0)for(let C of S)i("optimizeDeps.exclude",C,"excluded",`Framework requires ${C} to be included. It will be included despite your exclusion.`);let z=rs(f,g,m),q=ze(u,p,me.CONCATENATE_DEDUPE),$=ze(l?.esbuildOptions||{},a.esbuildOptions||{},me.DEEP_MERGE,{protectedKeys:["external"],onConflict:C=>i(`optimizeDeps.esbuildOptions.${C}`,l?.esbuildOptions?.[C],a.esbuildOptions?.[C],`Framework requires ${C} to remain as configured.`)});s[o]={...l,include:z,exclude:q,esbuildOptions:$,...Object.fromEntries(Object.entries(a).filter(([C])=>!["include","exclude","esbuildOptions"].includes(C)))};return}if(o==="css"&&typeof a=="object"&&a!==null){s[o]=ze(l||{},a,me.DEEP_MERGE,{protectedKeys:["postcss"],onConflict:()=>i("css.postcss","framework PostCSS config",a.postcss,"Framework PostCSS config is required and cannot be overridden. Your postcss config is ignored.")});return}if(o==="define"&&typeof a=="object"&&a!==null){s[o]=ze(l||{},a,me.DEEP_MERGE,{protectedKeys:["__DEV__","__PROD__"],onConflict:f=>i(`define.${f}`,l?.[f],a[f],`Framework requires ${f} to remain as configured.`)});return}if(Array.isArray(a)){Array.isArray(l)?s[o]=ze(l,a,me.CONCATENATE_DEDUPE):s[o]=a;return}if(typeof a=="object"&&a!==null&&typeof l=="object"&&l!==null&&!Array.isArray(l)){s[o]=ze(l,a,me.SHALLOW_MERGE);return}s[o]=a}),s}function ns(e){let{server:t={},preview:r={},mode:s,build:n={},resolve:i={},routes:o={},themes:a={},i18n:l={},assets:f={},features:u={},seo:g={},pwa:p={},serverShim:m={},chunking:S={},discovery:z={},pluginFactory:q={},debug:$,verbose:C,base:k,define:D={},optimizeDeps:N={},plugins:E=[],css:B={},envDir:j,...fe}=e,I=s!=="production",A=$||I,te=s==="production"&&(n.analyze??_t.build.analyze);return{mode:s,debug:$,verbose:C,isDev:I,isDebug:A,shouldAnalyze:te,serverOptions:t,previewOptions:r,buildOverrides:n,resolveOptions:i,routeOptions:o,themeOptions:a,i18nOptions:l,assetOptions:f,featureOptions:u,seoOptions:g,pwaOptions:p,serverShimOptions:m,chunkingOptions:S,discoveryOptions:z,pluginFactoryOptions:q,base:k,defineOptions:D,optimizeDepsOptions:N,pluginsOptions:E,cssOptions:B,envDir:j,restOptions:fe}}import{resolve as wo}from"node:path";import Eo from"autoprefixer";import xo from"postcss-import";import Po from"postcss-nesting";function is({postcssImport:e,postcssNesting:t,autoprefixer:r,resolve:s}){return{plugins:[s?e({resolve:s}):e,t,r({overrideBrowserslist:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"],grid:"autoplace"})]}}function os(e={}){if(e.postcss)return e.postcss;let t=G.getInstance();return is({postcssImport:xo,postcssNesting:Po,autoprefixer:Eo,resolve:(s,n)=>{let i=t.resolvePackage(s,n);if(i)return i;if(s.startsWith("@donotdev/")){let o=s.split("/")[0]+"/"+s.split("/")[1],a=s.split("/").slice(2).join("/"),l=t.resolveFrameworkPackage(o,n);if(l&&a){let f=t.resolvePath(a,l);if(t.pathExists(f))return f}}return wo(n,s)}})}import cf from"@vitejs/plugin-basic-ssl";import uf from"@vitejs/plugin-react";import ff from"vite-tsconfig-paths";var ie=class{static generateVirtualModule(t,r,s=!1,n=void 0,i=void 0){return r.isEmpty(t)?r.generateEmpty(t,s,n,i):r.generateModule(t,s,i)}static generateInspection(t,r,s,n){return r.generateInspection.length>=3?r.generateInspection(t,s,n):r.generateInspection(t,s)}static wrapVirtualModule(t,r){return`// Virtual module: ${t}
1
+ var wo=Object.create;var dr=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var xo=Object.getOwnPropertyNames;var Po=Object.getPrototypeOf,So=Object.prototype.hasOwnProperty;var Y=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var pr=(e,t)=>()=>(e&&(t=e(e=0)),t);var D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ro=(e,t)=>{for(var r in t)dr(e,r,{get:t[r],enumerable:!0})},$o=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xo(t))!So.call(e,n)&&n!==r&&dr(e,n,{get:()=>t[n],enumerable:!(s=Eo(t,n))||s.enumerable});return e};var ko=(e,t,r)=>(r=e!=null?wo(Po(e)):{},$o(t||!e||!e.__esModule?dr(r,"default",{value:e,enumerable:!0}):r,e));function cs(e,t=null){let r=Ee[e];if(!r)throw new Error(`Unknown pattern type: ${e}`);return t&&r.framework?{...r,framework:r.framework.map(s=>`${t}/${s}`)}:r}function Lt(e){return as[e]||as.base}var mr,V,le,te,br,Pt,jt,Ee,tt,ls,vr,yr,St,wr,as,re=pr(()=>{"use strict";mr={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},V={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env"},le={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},te={next:{middleware:"middleware.ts",routeManifest:"public/route-manifest.json",assetManifest:"public/asset-manifest.json",utilities:"src/styles/utilities.generated.css",appPages:"src/app",appLayout:"src/app/layout.tsx",configRoute:"src/config/dndev-config-route.js",configTheme:"src/config/dndev-config-theme.js",configI18n:"src/config/dndev-config-i18n.js",configPwa:"src/config/dndev-config-pwa.js",configAsset:"src/config/dndev-config-asset.js",configSeo:"src/config/dndev-config-seo.js",configServer:"src/config/dndev-config-server.js"},vite:{routeInspection:"src/routes.generated.log",themeInspection:"src/themes.generated.log",i18nInspection:"src/i18n.generated.log",assetInspection:"src/assets.generated.log",envInspection:"src/env.generated.log"},manifests:{route:"route-manifest.json",theme:"theme-manifest.json",i18n:"i18n-manifest.json",asset:"asset-manifest.json",feature:"feature-manifest.json",env:"env-manifest.json"}},br={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},Pt={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},jt={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},Ee={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${jt.SOURCE_EAGER}/*_*.json`],lazy:[`${jt.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]},tt={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async","@donotdev/core","@donotdev/components","@donotdev/ui","@donotdev/templates","@donotdev/firebase"],optionalFeatures:["@donotdev/components","@donotdev/auth","@donotdev/billing","@donotdev/crud","@donotdev/oauth","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder"],coreBundled:["@donotdev/types","@donotdev/utils","@donotdev/stores","@donotdev/schemas","@donotdev/hooks","@donotdev/i18n","@donotdev/config"],componentsBundled:["class-variance-authority","clsx","lucide-react","react-day-picker"],radixUIPattern:"@radix-ui/",buildTools:["esbuild","@esbuild/win32-x64","@esbuild/darwin-x64","@esbuild/linux-x64","@esbuild/darwin-arm64","@esbuild/linux-arm64","vite","rollup","rollup-plugin-visualizer","@vitejs/plugin-react","vite-tsconfig-paths","vite-plugin-pwa","vite-plugin-compression2","vite-plugin-node-polyfills","fsevents","postcss","postcss-import","postcss-nesting","autoprefixer"],buildTimePackages:[],largeOptional:["@sentry/react","framer-motion","stripe","@tanstack/react-query","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder","sharp","semver","file-type"]},ls=["firebase-admin","gcp-metadata","google-logging-utils","payload","undici","@fastify/busboy","image-size","@donotdev/tooling","fs","path","crypto","net","tls","http","https","child_process","os","util","stream","buffer","events","querystring","url","zlib","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","cluster","dgram","dns","http2","inspector","module","perf_hooks","process","readline","repl","trace_events","v8","wasi"],vr=["@donotdev/core/functions","@donotdev/core/server"],yr={selectors:{class:/\.([a-zA-Z0-9-]+)/g,variable:/--[a-zA-Z0-9-]+/g,keyframe:/@keyframes\s+([a-zA-Z0-9-]+)/g},themes:{themeClass:/(?::root\.|\.)([a-z][a-z0-9-]+)\s*\{([\s\S]*?)\}/gim,themeLabel:/--theme-label\s*:\s*['"]([^'"]+)['"]/,themeIcon:/--theme-icon\s*:\s*['"]([^'"]+)['"]/,themeIsDark:/--theme-is-dark\s*:\s*(0|1)/}},St={Inter:"inter-latin","Space Grotesk":"space-grotesk-latin","Playfair Display":"playfair-display-latin","Press Start 2P":"press-start-2p-latin",Roboto:"roboto-latin"},wr=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],as={base:{absolute:!0,onlyFiles:!0,ignore:Ee.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...Ee.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...Ee.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:Ee.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:Ee.globalIgnore}}});import*as T from"node:fs";import"node:fs";import{createRequire as Fo}from"node:module";import{resolve as Mt,join as Me,dirname as We,relative as us,normalize as Oo,sep as fs,extname as Co}from"node:path";import{fileURLToPath as jo}from"node:url";import Lo from"fast-glob";function hs(e,t){return e().catch(r=>{throw new Error(`${t}: ${r instanceof Error?r.message:String(r)}`)})}var at,se,ds,G,me=pr(()=>{"use strict";re();at={getGlobOptionsFor:Lt||void 0,SCAN_PATTERNS:Ee||void 0,getPatternsFor:cs||void 0,I18N_PATHS:jt||void 0},se={error:(e,t)=>{},warn:(e,t)=>{},info:e=>{}};ds={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},G=class e{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(t={}){return e._instance||(e._instance=new e(t)),e._instance}static _reset(){e._instance=null}constructor(t={}){if(e._instance)return e._instance;this.options={maxLevels:t.maxLevels??10,customMarkers:t.customMarkers||[],cache:t.cache??!1,debug:t.debug??!1};try{let r=process.cwd();if(!r)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(r)}catch(r){throw new Error(`PathResolver constructor failed: ${r instanceof Error?r.message:String(r)}. cwd: ${process.cwd()}`)}this._appRoot=null,e._instance=this}normalizePath(t){if(!t)return"";try{return Oo(t).split(fs).join("/")}catch{return String(t).split(fs).join("/")}}getRelativePath(t){let r=this.getAppRoot(),s=us(r,t);return this.normalizePath(s)}getBasename(t){if(!t)return"";let s=this.normalizePath(t).split("/");return s[s.length-1]||""}getDirname(t){return t?this.normalizePath(We(t)):""}resolvePackage(t,r=null){try{let s=r||this.getAppRoot(),i=Fo(Me(s,"package.json")).resolve(t);return this.normalizePath(i)}catch{return null}}resolveFrameworkPackage(t,r=null){let s=this.resolvePackage(`${t}/package.json`,r);if(s)return this.getDirname(s);if(this.isMonorepo()&&t.startsWith("@donotdev/")){let o=t.replace("@donotdev/",""),a=this.resolveRepoPath(`packages/${o}`);if(this.pathExists(a))return a;if(["auth","billing","crud","oauth"].includes(o)){let l=this.resolveRepoPath(`packages/features/${o}`);if(this.pathExists(l))return l}if(o==="firebase"){let l=this.resolveRepoPath(`packages/providers/${o}`);if(this.pathExists(l))return l}}let n=this.resolveAppPath(`node_modules/${t}`);if(this.pathExists(n))return n;let i=this.resolveRepoPath(`node_modules/${t}`);return this.pathExists(i)?i:null}resolvePackageAsset(t,r=null){return this.resolvePackage(t,r)}resolveAppPath(t){let r=this.getAppRoot(),s=Mt(r,t);return this.normalizePath(s)}resolveRepoPath(t){let r=this.getRepoRoot(),s=this.normalizePath(t),n=Mt(r,s);return this.normalizePath(n)}resolvePath(t,r){let s=this.normalizePath(r),n=this.normalizePath(t),i=Mt(s,n);return this.normalizePath(i)}createImportPath(t){return"./"+this.getRelativePath(t)}getFileInfo(t){try{let r=T.statSync(t);return{absolutePath:this.normalizePath(t),relativePath:this.getRelativePath(t),importPath:this.createImportPath(t),size:r.size,isFile:r.isFile(),isDirectory:r.isDirectory()}}catch{return null}}_detectFormat(t,r){return r&&r!=="auto"?r:Co(t).toLowerCase()===".json"?"json":"text"}async read(t,r={}){let{format:s="auto",encoding:n="utf8"}=r,i=this._detectFormat(t,s);try{if(i==="buffer")return await T.promises.readFile(t);let o=await T.promises.readFile(t,n),a=this.stripBom(o);return i==="json"?JSON.parse(a):a}catch(o){return this.options.debug&&se.warn(`Failed to read file: ${t}`,o),null}}readSync(t,r={}){let{format:s="auto",encoding:n="utf8"}=r,i=this._detectFormat(t,s);try{if(i==="buffer")return T.readFileSync(t);let o=T.readFileSync(t,n),a=this.stripBom(o);return i==="json"?JSON.parse(a):a}catch(o){return this.options.debug&&se.warn(`Failed to read file: ${t}`,o),null}}async write(t,r,s={}){let{format:n="auto",overwrite:i=!1,dryRun:o=!1,verbose:a=!1}=s,l=this.normalizePath(t),u=this.normalizePath(We(l)),f=this.pathExists(l);if(f&&!i)return a&&se.info(`Skipping existing file: ${l}`),!1;if(o)return se.info(`[DRY RUN] Would write file: ${l}`),!0;try{await T.promises.mkdir(u,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let d=this._detectFormat(t,n),g;Buffer.isBuffer(r)?g=r:d==="json"&&typeof r=="object"?g=JSON.stringify(r,null,2):g=String(r);try{return await hs(async()=>(Buffer.isBuffer(g)?await T.promises.writeFile(l,g):await T.promises.writeFile(l,g,"utf8"),a&&se.info(`${f?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(t,r,s={}){let{format:n="auto",overwrite:i=!1,dryRun:o=!1,verbose:a=!1}=s,l=this.normalizePath(t),u=this.normalizePath(We(l)),f=this.pathExists(l);if(f&&!i)return a&&se.info(`Skipping existing file: ${l}`),!1;if(o)return se.info(`[DRY RUN] Would write file: ${l}`),!0;try{T.mkdirSync(u,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let d=this._detectFormat(t,n),g;Buffer.isBuffer(r)?g=r:d==="json"&&typeof r=="object"?g=JSON.stringify(r,null,2):g=String(r);try{return Buffer.isBuffer(g)?T.writeFileSync(l,g):T.writeFileSync(l,g,"utf8"),a&&se.info(`${f?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(t,r,s={}){let{overwrite:n=!1,dryRun:i=!1,verbose:o=!1}=s,a=this.normalizePath(r),l=this.pathExists(a);if(l&&!n)return o&&se.info(`Skipping existing file: ${a}`),!1;if(i)return se.info(`[DRY RUN] Would copy file: ${a}`),!0;let u=this.normalizePath(We(a));try{await T.promises.mkdir(u,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}try{return await hs(async()=>(await T.promises.copyFile(t,a),o&&se.info(`${l?"Updated":"Created"} file: ${a}`),!0),`Failed to copy file from ${t} to ${a}`)}catch{return!1}}copySync(t,r,s={}){let{overwrite:n=!1,dryRun:i=!1,verbose:o=!1}=s,a=this.normalizePath(r),l=this.pathExists(a);if(l&&!n)return o&&se.info(`Skipping existing file: ${a}`),!1;if(i)return se.info(`[DRY RUN] Would copy file: ${a}`),!0;let u=this.normalizePath(We(a));try{T.mkdirSync(u,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}try{return T.copyFileSync(t,a),o&&se.info(`${l?"Updated":"Created"} file: ${a}`),!0}catch{return!1}}pathExists(t,r=!1){try{return T.existsSync(t)}catch(s){return r||se.error(`Error checking path existence: ${t}`,s),!1}}mkdir(t){try{let r=t.startsWith("/")||t.match(/^[A-Z]:/)?this.normalizePath(t):this.resolveAppPath(t);return T.existsSync(r)||T.mkdirSync(r,{recursive:!0}),!0}catch{return!1}}readdirSync(t,r){try{return T.readdirSync(t,r)}catch(s){return this.options.debug&&se.warn(`Failed to read directory: ${t}`,s),r&&typeof r=="object"&&"withFileTypes"in r&&r.withFileTypes?[]:[]}}statSync(t){try{return T.statSync(t)}catch(r){return this.options.debug&&se.warn(`Failed to stat file: ${t}`,r),null}}lstatSync(t){try{return T.lstatSync(t)}catch(r){return this.options.debug&&se.warn(`Failed to lstat file: ${t}`,r),null}}async ensureDir(t){try{await T.promises.mkdir(t,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}ensureDirSync(t){try{T.mkdirSync(t,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}async remove(t){await T.promises.rm(t,{recursive:!0,force:!0})}removeSync(t){T.rmSync(t,{recursive:!0,force:!0})}async readdir(t,r){return T.promises.readdir(t,r)}stripBom(t){return t.charCodeAt(0)===65279?t.slice(1):t}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(t){if(!t)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(t)}isMonorepo(){let t=Me(this._repoRoot,"packages");return this.pathExists(t)}isWithinApp(t){let r=this.normalizePath(Mt(t)),s=this.getAppRoot(),n=us(s,r),i=this.normalizePath(n);return!i.startsWith("../")&&!i.startsWith("/")}async findFiles(t,r,s={}){let n=this.normalizePath(Me(t,r)),i=this.getAppRoot(),o=this.normalizePath(i),a=n.startsWith(o)?n.slice(o.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:i,ignore:at.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([a],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(t){let r=at.I18N_PATHS;if(!r)return null;let s=t.replace(r.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let i=this.normalizePath(Me(n,r.PUBLISHED_ROOT,s)),o=i.replace(/\/[^/]*\*.*$/,"");return this.pathExists(o),i}async _globWithNormalization(t,r){return(await Lo(t,r)).map(n=>{let i=typeof n=="string"?n:n.path;return this.normalizePath(i)})}async resolveFiles(t,r="css"){if(!t||typeof t!="object")return{frameworkFiles:[],consumerFiles:[]};if(r==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(t.framework)||(t.framework=[]),!Array.isArray(t.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...t.framework,...t.consumer];for(let f of s)if(typeof f!="string"||f.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),i=at.getGlobOptionsFor?at.getGlobOptionsFor(r):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},o=this.normalizePath(n),a=t.framework.map(f=>{let d=this.normalizePath(f);return d.startsWith(o)?d.slice(o.length+1):d}),l=t.consumer.map(f=>{let d=this.normalizePath(f);return d.startsWith(o)?d.slice(o.length+1):d}),u={...i,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let f=a.length>0?await this._globWithNormalization(a,u):[],d=await this._globWithNormalization(l,u);return{frameworkFiles:f,consumerFiles:d}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(t){if(!at.getPatternsFor)return{framework:[],consumer:[],all:[]};let r=this.getAppRoot(),s=this.getRepoRoot();if(t==="i18n"&&(!r||r===s))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${r}, repoRoot: ${s}). Ensure configResolved hook has run before discovery.`);let n=at.getPatternsFor(t),i=this.isMonorepo();if(t==="i18n"){let l=n,u={eager:l.eager.map(f=>f.startsWith("!")?"!"+this.resolveAppPath(f.slice(1)):this.resolveAppPath(f)),lazy:l.lazy.map(f=>f.startsWith("!")?"!"+this.resolveAppPath(f.slice(1)):this.resolveAppPath(f)),framework:{eager:i?(l.framework?.eager||[]).map(f=>this.resolveRepoPath(f)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(f=>this._resolveFrameworkI18nPattern(f))).then(f=>f.filter(Boolean)),lazy:i?(l.framework?.lazy||[]).map(f=>this.resolveRepoPath(f)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(f=>this._resolveFrameworkI18nPattern(f))).then(f=>f.filter(Boolean))},all:[]};return u.all=[...u.eager,...u.lazy,...u.framework.eager,...u.framework.lazy],u}let o=n,a={framework:i?(o.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(o.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return a.all=[...a.consumer,...a.framework],a}getEmptyModulePath(t=!1){if(t)return"@donotdev/core/empty";let r=this.resolvePackage("@donotdev/core/empty");if(r)return r;let s=We(jo(import.meta.url));return this.normalizePath(Me(s,"../empty.js"))}_findRepoRoot(t){let r=this.normalizePath(t),s=0,n=this.options.maxLevels;for(;s<n;){let i=this.normalizePath(Me(r,ds.TOOLING)),o=this.normalizePath(Me(r,ds.CORE));if(this.pathExists(i)&&this.pathExists(o))return r;let a=Me(r,"apps");if(this.pathExists(a)&&this.statSync(a)?.isDirectory())return this.normalizePath(r);let l=this.normalizePath(Me(r,"package.json"));if(this.pathExists(l)&&this.normalizePath(We(r))===r)return r;let u=this.normalizePath(We(r));if(u===r)break;r=u,s++}return this.normalizePath(t)}}});var Ie=D((Uh,Ps)=>{var xs=e=>typeof e<"u"&&e!==null,Xo=e=>typeof e=="object",Yo=e=>Object.prototype.toString.call(e)==="[object Object]",Ko=e=>typeof e=="function",Qo=e=>typeof e=="boolean",Zo=e=>e instanceof Buffer,ea=e=>{if(xs(e))switch(e.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},ta=e=>e instanceof ArrayBuffer,ra=e=>typeof e=="string"&&e.length>0,sa=e=>typeof e=="number"&&!Number.isNaN(e),na=e=>Number.isInteger(e),ia=(e,t,r)=>e>=t&&e<=r,oa=(e,t)=>t.includes(e),aa=(e,t,r)=>new Error(`Expected ${t} for ${e} but received ${r} of type ${typeof r}`),la=(e,t)=>(t.message=e.message,t);Ps.exports={defined:xs,object:Xo,plainObject:Yo,fn:Ko,bool:Qo,buffer:Zo,typedArray:ea,arrayBuffer:ta,string:ra,number:sa,integer:na,inRange:ia,inArray:oa,invalidParameterError:aa,nativeError:la}});var $s=D((Gh,Rs)=>{"use strict";var Ss=()=>process.platform==="linux",Bt=null,ca=()=>{if(!Bt)if(Ss()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,Bt=process.report.getReport(),process.report.excludeNetwork=e}else Bt={};return Bt};Rs.exports={isLinux:Ss,getReport:ca}});var As=D((qh,ks)=>{"use strict";var lt=Y("fs"),ua="/usr/bin/ldd",fa="/proc/self/exe",Ut=2048,ha=e=>{let t=lt.openSync(e,"r"),r=Buffer.alloc(Ut),s=lt.readSync(t,r,0,Ut,0);return lt.close(t,()=>{}),r.subarray(0,s)},da=e=>new Promise((t,r)=>{lt.open(e,"r",(s,n)=>{if(s)r(s);else{let i=Buffer.alloc(Ut);lt.read(n,i,0,Ut,0,(o,a)=>{t(i.subarray(0,a)),lt.close(n,()=>{})})}})});ks.exports={LDD_PATH:ua,SELF_PATH:fa,readFileSync:ha,readFile:da}});var Ns=D((Wh,_s)=>{"use strict";var pa=e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),r=e.readUInt16LE(54),s=e.readUInt16LE(56);for(let n=0;n<s;n++){let i=t+n*r;if(e.readUInt32LE(i)===3){let a=e.readUInt32LE(i+8),l=e.readUInt32LE(i+32);return e.subarray(a,a+l).toString().replace(/\0.*$/g,"")}}return null};_s.exports={interpreterPath:pa}});var qt=D((Hh,Js)=>{"use strict";var Ds=Y("child_process"),{isLinux:ct,getReport:Ts}=$s(),{LDD_PATH:Gt,SELF_PATH:Fs,readFile:Er,readFileSync:xr}=As(),{interpreterPath:Os}=Ns(),De,Te,Fe,Cs="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",Ve="",js=()=>Ve||new Promise(e=>{Ds.exec(Cs,(t,r)=>{Ve=t?" ":r,e(Ve)})}),Ls=()=>{if(!Ve)try{Ve=Ds.execSync(Cs,{encoding:"utf8"})}catch{Ve=" "}return Ve},ze="glibc",Ms=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,rt="musl",ga=e=>e.includes("libc.musl-")||e.includes("ld-musl-"),zs=()=>{let e=Ts();return e.header&&e.header.glibcVersionRuntime?ze:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(ga)?rt:null},Bs=e=>{let[t,r]=e.split(/[\r\n]+/);return t&&t.includes(ze)?ze:r&&r.includes(rt)?rt:null},Us=e=>{if(e){if(e.includes("/ld-musl-"))return rt;if(e.includes("/ld-linux-"))return ze}return null},Gs=e=>(e=e.toString(),e.includes("musl")?rt:e.includes("GNU C Library")?ze:null),ma=async()=>{if(Te!==void 0)return Te;Te=null;try{let e=await Er(Gt);Te=Gs(e)}catch{}return Te},ba=()=>{if(Te!==void 0)return Te;Te=null;try{let e=xr(Gt);Te=Gs(e)}catch{}return Te},va=async()=>{if(De!==void 0)return De;De=null;try{let e=await Er(Fs),t=Os(e);De=Us(t)}catch{}return De},ya=()=>{if(De!==void 0)return De;De=null;try{let e=xr(Fs),t=Os(e);De=Us(t)}catch{}return De},qs=async()=>{let e=null;if(ct()&&(e=await va(),!e&&(e=await ma(),e||(e=zs()),!e))){let t=await js();e=Bs(t)}return e},Ws=()=>{let e=null;if(ct()&&(e=ya(),!e&&(e=ba(),e||(e=zs()),!e))){let t=Ls();e=Bs(t)}return e},wa=async()=>ct()&&await qs()!==ze,Ea=()=>ct()&&Ws()!==ze,xa=async()=>{if(Fe!==void 0)return Fe;Fe=null;try{let t=(await Er(Gt)).match(Ms);t&&(Fe=t[1])}catch{}return Fe},Pa=()=>{if(Fe!==void 0)return Fe;Fe=null;try{let t=xr(Gt).match(Ms);t&&(Fe=t[1])}catch{}return Fe},Hs=()=>{let e=Ts();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},Is=e=>e.trim().split(/\s+/)[1],Vs=e=>{let[t,r,s]=e.split(/[\r\n]+/);return t&&t.includes(ze)?Is(t):r&&s&&r.includes(rt)?Is(s):null},Sa=async()=>{let e=null;if(ct()&&(e=await xa(),e||(e=Hs()),!e)){let t=await js();e=Vs(t)}return e},Ra=()=>{let e=null;if(ct()&&(e=Pa(),e||(e=Hs()),!e)){let t=Ls();e=Vs(t)}return e};Js.exports={GLIBC:ze,MUSL:rt,family:qs,familySync:Ws,isNonGlibcLinux:wa,isNonGlibcLinuxSync:Ea,version:Sa,versionSync:Ra}});var Rt=D((Vh,Xs)=>{"use strict";var $a=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>{}:()=>{};Xs.exports=$a});var Wt=D((Jh,Ys)=>{"use strict";var ka="2.0.0",Aa=Number.MAX_SAFE_INTEGER||9007199254740991,_a=16,Na=250,Ia=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Ys.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:_a,MAX_SAFE_BUILD_LENGTH:Na,MAX_SAFE_INTEGER:Aa,RELEASE_TYPES:Ia,SEMVER_SPEC_VERSION:ka,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var $t=D((Oe,Ks)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:Pr,MAX_SAFE_BUILD_LENGTH:Da,MAX_LENGTH:Ta}=Wt(),Fa=Rt();Oe=Ks.exports={};var Oa=Oe.re=[],Ca=Oe.safeRe=[],y=Oe.src=[],ja=Oe.safeSrc=[],w=Oe.t={},La=0,Sr="[a-zA-Z0-9-]",Ma=[["\\s",1],["\\d",Ta],[Sr,Da]],za=e=>{for(let[t,r]of Ma)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},$=(e,t,r)=>{let s=za(t),n=La++;Fa(e,n,t),w[e]=n,y[n]=t,ja[n]=s,Oa[n]=new RegExp(t,r?"g":void 0),Ca[n]=new RegExp(s,r?"g":void 0)};$("NUMERICIDENTIFIER","0|[1-9]\\d*");$("NUMERICIDENTIFIERLOOSE","\\d+");$("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Sr}*`);$("MAINVERSION",`(${y[w.NUMERICIDENTIFIER]})\\.(${y[w.NUMERICIDENTIFIER]})\\.(${y[w.NUMERICIDENTIFIER]})`);$("MAINVERSIONLOOSE",`(${y[w.NUMERICIDENTIFIERLOOSE]})\\.(${y[w.NUMERICIDENTIFIERLOOSE]})\\.(${y[w.NUMERICIDENTIFIERLOOSE]})`);$("PRERELEASEIDENTIFIER",`(?:${y[w.NONNUMERICIDENTIFIER]}|${y[w.NUMERICIDENTIFIER]})`);$("PRERELEASEIDENTIFIERLOOSE",`(?:${y[w.NONNUMERICIDENTIFIER]}|${y[w.NUMERICIDENTIFIERLOOSE]})`);$("PRERELEASE",`(?:-(${y[w.PRERELEASEIDENTIFIER]}(?:\\.${y[w.PRERELEASEIDENTIFIER]})*))`);$("PRERELEASELOOSE",`(?:-?(${y[w.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${y[w.PRERELEASEIDENTIFIERLOOSE]})*))`);$("BUILDIDENTIFIER",`${Sr}+`);$("BUILD",`(?:\\+(${y[w.BUILDIDENTIFIER]}(?:\\.${y[w.BUILDIDENTIFIER]})*))`);$("FULLPLAIN",`v?${y[w.MAINVERSION]}${y[w.PRERELEASE]}?${y[w.BUILD]}?`);$("FULL",`^${y[w.FULLPLAIN]}$`);$("LOOSEPLAIN",`[v=\\s]*${y[w.MAINVERSIONLOOSE]}${y[w.PRERELEASELOOSE]}?${y[w.BUILD]}?`);$("LOOSE",`^${y[w.LOOSEPLAIN]}$`);$("GTLT","((?:<|>)?=?)");$("XRANGEIDENTIFIERLOOSE",`${y[w.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);$("XRANGEIDENTIFIER",`${y[w.NUMERICIDENTIFIER]}|x|X|\\*`);$("XRANGEPLAIN",`[v=\\s]*(${y[w.XRANGEIDENTIFIER]})(?:\\.(${y[w.XRANGEIDENTIFIER]})(?:\\.(${y[w.XRANGEIDENTIFIER]})(?:${y[w.PRERELEASE]})?${y[w.BUILD]}?)?)?`);$("XRANGEPLAINLOOSE",`[v=\\s]*(${y[w.XRANGEIDENTIFIERLOOSE]})(?:\\.(${y[w.XRANGEIDENTIFIERLOOSE]})(?:\\.(${y[w.XRANGEIDENTIFIERLOOSE]})(?:${y[w.PRERELEASELOOSE]})?${y[w.BUILD]}?)?)?`);$("XRANGE",`^${y[w.GTLT]}\\s*${y[w.XRANGEPLAIN]}$`);$("XRANGELOOSE",`^${y[w.GTLT]}\\s*${y[w.XRANGEPLAINLOOSE]}$`);$("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Pr}})(?:\\.(\\d{1,${Pr}}))?(?:\\.(\\d{1,${Pr}}))?`);$("COERCE",`${y[w.COERCEPLAIN]}(?:$|[^\\d])`);$("COERCEFULL",y[w.COERCEPLAIN]+`(?:${y[w.PRERELEASE]})?(?:${y[w.BUILD]})?(?:$|[^\\d])`);$("COERCERTL",y[w.COERCE],!0);$("COERCERTLFULL",y[w.COERCEFULL],!0);$("LONETILDE","(?:~>?)");$("TILDETRIM",`(\\s*)${y[w.LONETILDE]}\\s+`,!0);Oe.tildeTrimReplace="$1~";$("TILDE",`^${y[w.LONETILDE]}${y[w.XRANGEPLAIN]}$`);$("TILDELOOSE",`^${y[w.LONETILDE]}${y[w.XRANGEPLAINLOOSE]}$`);$("LONECARET","(?:\\^)");$("CARETTRIM",`(\\s*)${y[w.LONECARET]}\\s+`,!0);Oe.caretTrimReplace="$1^";$("CARET",`^${y[w.LONECARET]}${y[w.XRANGEPLAIN]}$`);$("CARETLOOSE",`^${y[w.LONECARET]}${y[w.XRANGEPLAINLOOSE]}$`);$("COMPARATORLOOSE",`^${y[w.GTLT]}\\s*(${y[w.LOOSEPLAIN]})$|^$`);$("COMPARATOR",`^${y[w.GTLT]}\\s*(${y[w.FULLPLAIN]})$|^$`);$("COMPARATORTRIM",`(\\s*)${y[w.GTLT]}\\s*(${y[w.LOOSEPLAIN]}|${y[w.XRANGEPLAIN]})`,!0);Oe.comparatorTrimReplace="$1$2$3";$("HYPHENRANGE",`^\\s*(${y[w.XRANGEPLAIN]})\\s+-\\s+(${y[w.XRANGEPLAIN]})\\s*$`);$("HYPHENRANGELOOSE",`^\\s*(${y[w.XRANGEPLAINLOOSE]})\\s+-\\s+(${y[w.XRANGEPLAINLOOSE]})\\s*$`);$("STAR","(<|>)?=?\\s*\\*");$("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");$("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Ht=D((Xh,Qs)=>{"use strict";var Ba=Object.freeze({loose:!0}),Ua=Object.freeze({}),Ga=e=>e?typeof e!="object"?Ba:e:Ua;Qs.exports=Ga});var rn=D((Yh,tn)=>{"use strict";var Zs=/^[0-9]+$/,en=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;let r=Zs.test(e),s=Zs.test(t);return r&&s&&(e=+e,t=+t),e===t?0:r&&!s?-1:s&&!r?1:e<t?-1:1},qa=(e,t)=>en(t,e);tn.exports={compareIdentifiers:en,rcompareIdentifiers:qa}});var ut=D((Kh,nn)=>{"use strict";var Vt=Rt(),{MAX_LENGTH:sn,MAX_SAFE_INTEGER:Jt}=Wt(),{safeRe:Xt,t:Yt}=$t(),Wa=Ht(),{compareIdentifiers:Rr}=rn(),$r=class e{constructor(t,r){if(r=Wa(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>sn)throw new TypeError(`version is longer than ${sn} characters`);Vt("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=t.trim().match(r.loose?Xt[Yt.LOOSE]:Xt[Yt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Jt||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Jt||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Jt||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let i=+n;if(i>=0&&i<Jt)return i}return n}):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(Vt("SemVer.compare",this.version,this.options,t),!(t instanceof e)){if(typeof t=="string"&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let s=this.prerelease[r],n=t.prerelease[r];if(Vt("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return Rr(s,n)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let s=this.build[r],n=t.build[r];if(Vt("build compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return Rr(s,n)}while(++r)}inc(t,r,s){if(t.startsWith("pre")){if(!r&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?Xt[Yt.PRERELEASELOOSE]:Xt[Yt.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,s),this.inc("pre",r,s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,s),this.inc("pre",r,s);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(s)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);if(i===-1){if(r===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let i=[r,n];s===!1&&(i=[r]),Rr(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=i):this.prerelease=i}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};nn.exports=$r});var ln=D((Qh,an)=>{"use strict";var on=ut(),Ha=(e,t,r=!1)=>{if(e instanceof on)return e;try{return new on(e,t)}catch(s){if(!r)return null;throw s}};an.exports=Ha});var un=D((Zh,cn)=>{"use strict";var Va=ut(),Ja=ln(),{safeRe:Kt,t:Qt}=$t(),Xa=(e,t)=>{if(e instanceof Va)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?Kt[Qt.COERCEFULL]:Kt[Qt.COERCE]);else{let l=t.includePrerelease?Kt[Qt.COERCERTLFULL]:Kt[Qt.COERCERTL],u;for(;(u=l.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||u.index+u[0].length!==r.index+r[0].length)&&(r=u),l.lastIndex=u.index+u[1].length+u[2].length;l.lastIndex=-1}if(r===null)return null;let s=r[2],n=r[3]||"0",i=r[4]||"0",o=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return Ja(`${s}.${n}.${i}${o}${a}`,t)};cn.exports=Xa});var st=D((ed,hn)=>{"use strict";var fn=ut(),Ya=(e,t,r)=>new fn(e,r).compare(new fn(t,r));hn.exports=Ya});var kr=D((td,dn)=>{"use strict";var Ka=st(),Qa=(e,t,r)=>Ka(e,t,r)>=0;dn.exports=Qa});var gn=D((rd,pn)=>{"use strict";var Ar=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(t,r)}return this}};pn.exports=Ar});var bn=D((sd,mn)=>{"use strict";var Za=st(),el=(e,t,r)=>Za(e,t,r)===0;mn.exports=el});var yn=D((nd,vn)=>{"use strict";var tl=st(),rl=(e,t,r)=>tl(e,t,r)!==0;vn.exports=rl});var En=D((id,wn)=>{"use strict";var sl=st(),nl=(e,t,r)=>sl(e,t,r)>0;wn.exports=nl});var Pn=D((od,xn)=>{"use strict";var il=st(),ol=(e,t,r)=>il(e,t,r)<0;xn.exports=ol});var Rn=D((ad,Sn)=>{"use strict";var al=st(),ll=(e,t,r)=>al(e,t,r)<=0;Sn.exports=ll});var kn=D((ld,$n)=>{"use strict";var cl=bn(),ul=yn(),fl=En(),hl=kr(),dl=Pn(),pl=Rn(),gl=(e,t,r,s)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return cl(e,r,s);case"!=":return ul(e,r,s);case">":return fl(e,r,s);case">=":return hl(e,r,s);case"<":return dl(e,r,s);case"<=":return pl(e,r,s);default:throw new TypeError(`Invalid operator: ${t}`)}};$n.exports=gl});var Fn=D((cd,Tn)=>{"use strict";var kt=Symbol("SemVer ANY"),Ir=class e{static get ANY(){return kt}constructor(t,r){if(r=An(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),Nr("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===kt?this.value="":this.value=this.operator+this.semver.version,Nr("comp",this)}parse(t){let r=this.options.loose?_n[Nn.COMPARATORLOOSE]:_n[Nn.COMPARATOR],s=t.match(r);if(!s)throw new TypeError(`Invalid comparator: ${t}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new In(s[2],this.options.loose):this.semver=kt}toString(){return this.value}test(t){if(Nr("Comparator.test",t,this.options.loose),this.semver===kt||t===kt)return!0;if(typeof t=="string")try{t=new In(t,this.options)}catch{return!1}return _r(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Dn(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new Dn(this.value,r).test(t.semver):(r=An(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||_r(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||_r(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};Tn.exports=Ir;var An=Ht(),{safeRe:_n,t:Nn}=$t(),_r=kn(),Nr=Rt(),In=ut(),Dn=Dr()});var Dr=D((ud,Ln)=>{"use strict";var ml=/\s+/g,Tr=class e{constructor(t,r){if(r=vl(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof Fr)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(ml," "),this.set=this.raw.split("||").map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!Cn(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&Rl(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let r=this.set[t];for(let s=0;s<r.length;s++)s>0&&(this.formatted+=" "),this.formatted+=r[s].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let s=((this.options.includePrerelease&&Pl)|(this.options.loose&&Sl))+":"+t,n=On.get(s);if(n)return n;let i=this.options.loose,o=i?ue[ae.HYPHENRANGELOOSE]:ue[ae.HYPHENRANGE];t=t.replace(o,Ol(this.options.includePrerelease)),J("hyphen replace",t),t=t.replace(ue[ae.COMPARATORTRIM],wl),J("comparator trim",t),t=t.replace(ue[ae.TILDETRIM],El),J("tilde trim",t),t=t.replace(ue[ae.CARETTRIM],xl),J("caret trim",t);let a=t.split(" ").map(d=>$l(d,this.options)).join(" ").split(/\s+/).map(d=>Fl(d,this.options));i&&(a=a.filter(d=>(J("loose invalid filter",d,this.options),!!d.match(ue[ae.COMPARATORLOOSE])))),J("range list",a);let l=new Map,u=a.map(d=>new Fr(d,this.options));for(let d of u){if(Cn(d))return[d];l.set(d.value,d)}l.size>1&&l.has("")&&l.delete("");let f=[...l.values()];return On.set(s,f),f}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(s=>jn(s,r)&&t.set.some(n=>jn(n,r)&&s.every(i=>n.every(o=>i.intersects(o,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new yl(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(Cl(this.set[r],t,this.options))return!0;return!1}};Ln.exports=Tr;var bl=gn(),On=new bl,vl=Ht(),Fr=Fn(),J=Rt(),yl=ut(),{safeRe:ue,t:ae,comparatorTrimReplace:wl,tildeTrimReplace:El,caretTrimReplace:xl}=$t(),{FLAG_INCLUDE_PRERELEASE:Pl,FLAG_LOOSE:Sl}=Wt(),Cn=e=>e.value==="<0.0.0-0",Rl=e=>e.value==="",jn=(e,t)=>{let r=!0,s=e.slice(),n=s.pop();for(;r&&s.length;)r=s.every(i=>n.intersects(i,t)),n=s.pop();return r},$l=(e,t)=>(e=e.replace(ue[ae.BUILD],""),J("comp",e,t),e=_l(e,t),J("caret",e),e=kl(e,t),J("tildes",e),e=Il(e,t),J("xrange",e),e=Tl(e,t),J("stars",e),e),fe=e=>!e||e.toLowerCase()==="x"||e==="*",kl=(e,t)=>e.trim().split(/\s+/).map(r=>Al(r,t)).join(" "),Al=(e,t)=>{let r=t.loose?ue[ae.TILDELOOSE]:ue[ae.TILDE];return e.replace(r,(s,n,i,o,a)=>{J("tilde",e,s,n,i,o,a);let l;return fe(n)?l="":fe(i)?l=`>=${n}.0.0 <${+n+1}.0.0-0`:fe(o)?l=`>=${n}.${i}.0 <${n}.${+i+1}.0-0`:a?(J("replaceTilde pr",a),l=`>=${n}.${i}.${o}-${a} <${n}.${+i+1}.0-0`):l=`>=${n}.${i}.${o} <${n}.${+i+1}.0-0`,J("tilde return",l),l})},_l=(e,t)=>e.trim().split(/\s+/).map(r=>Nl(r,t)).join(" "),Nl=(e,t)=>{J("caret",e,t);let r=t.loose?ue[ae.CARETLOOSE]:ue[ae.CARET],s=t.includePrerelease?"-0":"";return e.replace(r,(n,i,o,a,l)=>{J("caret",e,n,i,o,a,l);let u;return fe(i)?u="":fe(o)?u=`>=${i}.0.0${s} <${+i+1}.0.0-0`:fe(a)?i==="0"?u=`>=${i}.${o}.0${s} <${i}.${+o+1}.0-0`:u=`>=${i}.${o}.0${s} <${+i+1}.0.0-0`:l?(J("replaceCaret pr",l),i==="0"?o==="0"?u=`>=${i}.${o}.${a}-${l} <${i}.${o}.${+a+1}-0`:u=`>=${i}.${o}.${a}-${l} <${i}.${+o+1}.0-0`:u=`>=${i}.${o}.${a}-${l} <${+i+1}.0.0-0`):(J("no pr"),i==="0"?o==="0"?u=`>=${i}.${o}.${a}${s} <${i}.${o}.${+a+1}-0`:u=`>=${i}.${o}.${a}${s} <${i}.${+o+1}.0-0`:u=`>=${i}.${o}.${a} <${+i+1}.0.0-0`),J("caret return",u),u})},Il=(e,t)=>(J("replaceXRanges",e,t),e.split(/\s+/).map(r=>Dl(r,t)).join(" ")),Dl=(e,t)=>{e=e.trim();let r=t.loose?ue[ae.XRANGELOOSE]:ue[ae.XRANGE];return e.replace(r,(s,n,i,o,a,l)=>{J("xRange",e,s,n,i,o,a,l);let u=fe(i),f=u||fe(o),d=f||fe(a),g=d;return n==="="&&g&&(n=""),l=t.includePrerelease?"-0":"",u?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&g?(f&&(o=0),a=0,n===">"?(n=">=",f?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):n==="<="&&(n="<",f?i=+i+1:o=+o+1),n==="<"&&(l="-0"),s=`${n+i}.${o}.${a}${l}`):f?s=`>=${i}.0.0${l} <${+i+1}.0.0-0`:d&&(s=`>=${i}.${o}.0${l} <${i}.${+o+1}.0-0`),J("xRange return",s),s})},Tl=(e,t)=>(J("replaceStars",e,t),e.trim().replace(ue[ae.STAR],"")),Fl=(e,t)=>(J("replaceGTE0",e,t),e.trim().replace(ue[t.includePrerelease?ae.GTE0PRE:ae.GTE0],"")),Ol=e=>(t,r,s,n,i,o,a,l,u,f,d,g)=>(fe(s)?r="":fe(n)?r=`>=${s}.0.0${e?"-0":""}`:fe(i)?r=`>=${s}.${n}.0${e?"-0":""}`:o?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,fe(u)?l="":fe(f)?l=`<${+u+1}.0.0-0`:fe(d)?l=`<${u}.${+f+1}.0-0`:g?l=`<=${u}.${f}.${d}-${g}`:e?l=`<${u}.${f}.${+d+1}-0`:l=`<=${l}`,`${r} ${l}`.trim()),Cl=(e,t,r)=>{for(let s=0;s<e.length;s++)if(!e[s].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let s=0;s<e.length;s++)if(J(e[s].semver),e[s].semver!==Fr.ANY&&e[s].semver.prerelease.length>0){let n=e[s].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0}});var zn=D((fd,Mn)=>{"use strict";var jl=Dr(),Ll=(e,t,r)=>{try{t=new jl(t,r)}catch{return!1}return t.test(e)};Mn.exports=Ll});var Or=D((hd,Ml)=>{Ml.exports={name:"sharp",description:"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",version:"0.34.5",author:"Lovell Fuller <npm@lovell.info>",homepage:"https://sharp.pixelplumbing.com",contributors:["Pierre Inglebert <pierre.inglebert@gmail.com>","Jonathan Ong <jonathanrichardong@gmail.com>","Chanon Sajjamanochai <chanon.s@gmail.com>","Juliano Julio <julianojulio@gmail.com>","Daniel Gasienica <daniel@gasienica.ch>","Julian Walker <julian@fiftythree.com>","Amit Pitaru <pitaru.amit@gmail.com>","Brandon Aaron <hello.brandon@aaron.sh>","Andreas Lind <andreas@one.com>","Maurus Cuelenaere <mcuelenaere@gmail.com>","Linus Unneb\xE4ck <linus@folkdatorn.se>","Victor Mateevitsi <mvictoras@gmail.com>","Alaric Holloway <alaric.holloway@gmail.com>","Bernhard K. Weisshuhn <bkw@codingforce.com>","Chris Riley <criley@primedia.com>","David Carley <dacarley@gmail.com>","John Tobin <john@limelightmobileinc.com>","Kenton Gray <kentongray@gmail.com>","Felix B\xFCnemann <Felix.Buenemann@gmail.com>","Samy Al Zahrani <samyalzahrany@gmail.com>","Chintan Thakkar <lemnisk8@gmail.com>","F. Orlando Galashan <frulo@gmx.de>","Kleis Auke Wolthuizen <info@kleisauke.nl>","Matt Hirsch <mhirsch@media.mit.edu>","Matthias Thoemmes <thoemmes@gmail.com>","Patrick Paskaris <patrick@paskaris.gr>","J\xE9r\xE9my Lal <kapouer@melix.org>","Rahul Nanwani <r.nanwani@gmail.com>","Alice Monday <alice0meta@gmail.com>","Kristo Jorgenson <kristo.jorgenson@gmail.com>","YvesBos <yves_bos@outlook.com>","Guy Maliar <guy@tailorbrands.com>","Nicolas Coden <nicolas@ncoden.fr>","Matt Parrish <matt.r.parrish@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Matthew McEachen <matthew+github@mceachen.org>","Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>","Kenric D'Souza <kenric.dsouza@gmail.com>","Oleh Aleinyk <oleg.aleynik@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Andrea Bianco <andrea.bianco@unibas.ch>","Rik Heywood <rik@rik.org>","Thomas Parisot <hi@oncletom.io>","Nathan Graves <nathanrgraves+github@gmail.com>","Tom Lokhorst <tom@lokhorst.eu>","Espen Hovlandsdal <espen@hovlandsdal.com>","Sylvain Dumont <sylvain.dumont35@gmail.com>","Alun Davies <alun.owain.davies@googlemail.com>","Aidan Hoolachan <ajhoolachan21@gmail.com>","Axel Eirola <axel.eirola@iki.fi>","Freezy <freezy@xbmc.org>","Daiz <taneli.vatanen@gmail.com>","Julian Aubourg <j@ubourg.net>","Keith Belovay <keith@picthrive.com>","Michael B. Klein <mbklein@gmail.com>","Jordan Prudhomme <jordan@raboland.fr>","Ilya Ovdin <iovdin@gmail.com>","Andargor <andargor@yahoo.com>","Paul Neave <paul.neave@gmail.com>","Brendan Kennedy <brenwken@gmail.com>","Brychan Bennett-Odlum <git@brychan.io>","Edward Silverton <e.silverton@gmail.com>","Roman Malieiev <aromaleev@gmail.com>","Tomas Szabo <tomas.szabo@deftomat.com>","Robert O'Rourke <robert@o-rourke.org>","Guillermo Alfonso Varela Chouci\xF1o <guillevch@gmail.com>","Christian Flintrup <chr@gigahost.dk>","Manan Jadhav <manan@motionden.com>","Leon Radley <leon@radley.se>","alza54 <alza54@thiocod.in>","Jacob Smith <jacob@frende.me>","Michael Nutt <michael@nutt.im>","Brad Parham <baparham@gmail.com>","Taneli Vatanen <taneli.vatanen@gmail.com>","Joris Dugu\xE9 <zaruike10@gmail.com>","Chris Banks <christopher.bradley.banks@gmail.com>","Ompal Singh <ompal.hitm09@gmail.com>","Brodan <christopher.hranj@gmail.com>","Ankur Parihar <ankur.github@gmail.com>","Brahim Ait elhaj <brahima@gmail.com>","Mart Jansink <m.jansink@gmail.com>","Lachlan Newman <lachnewman007@gmail.com>","Dennis Beatty <dennis@dcbeatty.com>","Ingvar Stepanyan <me@rreverser.com>","Don Denton <don@happycollision.com>"],scripts:{build:"node install/build.js",install:"node install/check.js || npm run build",clean:"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",test:"npm run lint && npm run test-unit",lint:"npm run lint-cpp && npm run lint-js && npm run lint-types","lint-cpp":"cpplint --quiet src/*.h src/*.cc","lint-js":"biome lint","lint-types":"tsd --files ./test/types/sharp.test-d.ts","test-leak":"./test/leak/leak.sh","test-unit":"node --experimental-test-coverage test/unit.mjs","package-from-local-build":"node npm/from-local-build.js","package-release-notes":"node npm/release-notes.js","docs-build":"node docs/build.mjs","docs-serve":"cd docs && npm start","docs-publish":"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"},type:"commonjs",main:"lib/index.js",types:"lib/index.d.ts",files:["install","lib","src/*.{cc,h,gyp}"],repository:{type:"git",url:"git://github.com/lovell/sharp.git"},keywords:["jpeg","png","webp","avif","tiff","gif","svg","jp2","dzi","image","resize","thumbnail","crop","embed","libvips","vips"],dependencies:{"@img/colour":"^1.0.0","detect-libc":"^2.1.2",semver:"^7.7.3"},optionalDependencies:{"@img/sharp-darwin-arm64":"0.34.5","@img/sharp-darwin-x64":"0.34.5","@img/sharp-libvips-darwin-arm64":"1.2.4","@img/sharp-libvips-darwin-x64":"1.2.4","@img/sharp-libvips-linux-arm":"1.2.4","@img/sharp-libvips-linux-arm64":"1.2.4","@img/sharp-libvips-linux-ppc64":"1.2.4","@img/sharp-libvips-linux-riscv64":"1.2.4","@img/sharp-libvips-linux-s390x":"1.2.4","@img/sharp-libvips-linux-x64":"1.2.4","@img/sharp-libvips-linuxmusl-arm64":"1.2.4","@img/sharp-libvips-linuxmusl-x64":"1.2.4","@img/sharp-linux-arm":"0.34.5","@img/sharp-linux-arm64":"0.34.5","@img/sharp-linux-ppc64":"0.34.5","@img/sharp-linux-riscv64":"0.34.5","@img/sharp-linux-s390x":"0.34.5","@img/sharp-linux-x64":"0.34.5","@img/sharp-linuxmusl-arm64":"0.34.5","@img/sharp-linuxmusl-x64":"0.34.5","@img/sharp-wasm32":"0.34.5","@img/sharp-win32-arm64":"0.34.5","@img/sharp-win32-ia32":"0.34.5","@img/sharp-win32-x64":"0.34.5"},devDependencies:{"@biomejs/biome":"^2.3.4","@cpplint/cli":"^0.1.0","@emnapi/runtime":"^1.7.0","@img/sharp-libvips-dev":"1.2.4","@img/sharp-libvips-dev-wasm32":"1.2.4","@img/sharp-libvips-win32-arm64":"1.2.4","@img/sharp-libvips-win32-ia32":"1.2.4","@img/sharp-libvips-win32-x64":"1.2.4","@types/node":"*",emnapi:"^1.7.0","exif-reader":"^2.0.2","extract-zip":"^2.0.1",icc:"^3.0.0","jsdoc-to-markdown":"^9.1.3","node-addon-api":"^8.5.0","node-gyp":"^11.5.0","tar-fs":"^3.1.1",tsd:"^0.33.0"},license:"Apache-2.0",engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},config:{libvips:">=8.17.3"},funding:{url:"https://opencollective.com/libvips"}}});var jr=D((dd,Yn)=>{var{spawnSync:Zt}=Y("node:child_process"),{createHash:zl}=Y("node:crypto"),qn=un(),Bl=kr(),Ul=zn(),Bn=qt(),{config:Gl,engines:Un,optionalDependencies:ql}=Or(),Wl=process.env.npm_package_config_libvips||Gl.libvips,Wn=qn(Wl).version,Hl=["darwin-arm64","darwin-x64","linux-arm","linux-arm64","linux-ppc64","linux-riscv64","linux-s390x","linux-x64","linuxmusl-arm64","linuxmusl-x64","win32-arm64","win32-ia32","win32-x64"],er={encoding:"utf8",shell:!0},Vl=e=>{e instanceof Error},Hn=()=>Bn.isNonGlibcLinuxSync()?Bn.familySync():"",Jl=()=>`${process.platform}${Hn()}-${process.arch}`,ft=()=>{if(Vn())return"wasm32";let{npm_config_arch:e,npm_config_platform:t,npm_config_libc:r}=process.env,s=typeof r=="string"?r:Hn();return`${t||process.platform}${s}-${e||process.arch}`},Xl=()=>{try{return Y(`@img/sharp-libvips-dev-${ft()}/include`)}catch{try{return Y("@img/sharp-libvips-dev/include")}catch{}}return""},Yl=()=>{try{return Y("@img/sharp-libvips-dev/cplusplus")}catch{}return""},Kl=()=>{try{return Y(`@img/sharp-libvips-dev-${ft()}/lib`)}catch{try{return Y(`@img/sharp-libvips-${ft()}/lib`)}catch{}}return""},Ql=()=>{if(process.release?.name==="node"&&process.versions&&!Ul(process.versions.node,Un.node))return{found:process.versions.node,expected:Un.node}},Vn=()=>{let{CC:e}=process.env;return!!e?.endsWith("/emcc")},Zl=()=>process.platform==="darwin"&&process.arch==="x64"?(Zt("sysctl sysctl.proc_translated",er).stdout||"").trim()==="sysctl.proc_translated: 1":!1,Gn=e=>zl("sha512").update(e).digest("hex"),ec=()=>{try{let e=Gn(`imgsharp-libvips-${ft()}`),t=qn(ql[`@img/sharp-libvips-${ft()}`],{includePrerelease:!0}).version;return Gn(`${e}npm:${t}`).slice(0,10)}catch{}return""},tc=()=>Zt(`node-gyp rebuild --directory=src ${Vn()?"--nodedir=emscripten":""}`,{...er,stdio:"inherit"}).status,Jn=()=>process.platform!=="win32"?(Zt("pkg-config --modversion vips-cpp",{...er,env:{...process.env,PKG_CONFIG_PATH:Xn()}}).stdout||"").trim():"",Xn=()=>process.platform!=="win32"?[(Zt('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',er).stdout||"").trim(),process.env.PKG_CONFIG_PATH,"/usr/local/lib/pkgconfig","/usr/lib/pkgconfig","/usr/local/libdata/pkgconfig","/usr/libdata/pkgconfig"].filter(Boolean).join(":"):"",Cr=(e,t,r)=>(r&&r(`Detected ${t}, skipping search for globally-installed libvips`),e),rc=e=>{if(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)return Cr(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",e);if(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)return Cr(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",e);if(Zl())return Cr(!1,"Rosetta",e);let t=Jn();return!!t&&Bl(t,Wn)};Yn.exports={minimumLibvipsVersion:Wn,prebuiltPlatforms:Hl,buildPlatformArch:ft,buildSharpLibvipsIncludeDir:Xl,buildSharpLibvipsCPlusPlusDir:Yl,buildSharpLibvipsLibDir:Kl,isUnsupportedNodeRuntime:Ql,runtimePlatformArch:Jl,log:Vl,yarnLocator:ec,spawnRebuild:tc,globalLibvipsVersion:Jn,pkgConfigPath:Xn,useGlobalLibvips:rc}});var _t=D((gd,Qn)=>{var{familySync:sc,versionSync:nc}=qt(),{runtimePlatformArch:ic,isUnsupportedNodeRuntime:Kn,prebuiltPlatforms:oc,minimumLibvipsVersion:ac}=jr(),nt=ic(),lc=[`../src/build/Release/sharp-${nt}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${nt}/sharp.node`,"@img/sharp-wasm32/sharp.node"],Lr,ht,At=[];for(Lr of lc)try{ht=Y(Lr);break}catch(e){At.push(e)}if(ht&&Lr.startsWith("@img/sharp-linux-x64")&&!ht._isUsingX64V2()){let e=new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");e.code="Unsupported CPU",At.push(e),ht=null}if(ht)Qn.exports=ht;else{let[e,t,r]=["linux","darwin","win32"].map(i=>nt.startsWith(i)),s=[`Could not load the "sharp" module using the ${nt} runtime`];At.forEach(i=>{i.code!=="MODULE_NOT_FOUND"&&s.push(`${i.code}: ${i.message}`)});let n=At.map(i=>i.message).join(" ");if(s.push("Possible solutions:"),Kn()){let{found:i,expected:o}=Kn();s.push("- Please upgrade Node.js:",` Found ${i}`,` Requires ${o}`)}else if(oc.includes(nt)){let[i,o]=nt.split("-"),a=i.endsWith("musl")?" --libc=musl":"";s.push("- Ensure optional dependencies can be installed:"," npm install --include=optional sharp","- Ensure your package manager supports multi-platform installation:"," See https://sharp.pixelplumbing.com/install#cross-platform","- Add platform-specific dependencies:",` npm install --os=${i.replace("musl","")}${a} --cpu=${o} sharp`)}else s.push(`- Manually install libvips >= ${ac}`,"- Add experimental WebAssembly-based dependencies:"," npm install --cpu=wasm32 sharp"," npm install @img/sharp-wasm32");if(e&&/(symbol not found|CXXABI_)/i.test(n))try{let{config:i}=Y(`@img/sharp-libvips-${nt}/package`),o=`${sc()} ${nc()}`,a=`${i.musl?"musl":"glibc"} ${i.musl||i.glibc}`;s.push("- Update your OS:",` Found ${o}`,` Requires ${a}`)}catch{}throw e&&/\/snap\/core[0-9]{2}/.test(n)&&s.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node"),t&&/Incompatible library version/.test(n)&&s.push("- Update Homebrew:"," brew update && brew upgrade vips"),At.some(i=>i.code==="ERR_DLOPEN_DISABLED")&&s.push("- Run Node.js without using the --no-addons flag"),r&&/The specified procedure could not be found/.test(n)&&s.push("- Using the canvas package on Windows?"," See https://sharp.pixelplumbing.com/install#canvas-and-windows","- Check for outdated versions of sharp in the dependency tree:"," npm ls sharp"),s.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),new Error(s.join(`
2
+ `))}});var ei=D((bd,Zn)=>{var cc=Y("node:util"),Mr=Y("node:stream"),uc=Ie();_t();var fc=cc.debuglog("sharp"),hc=e=>{it.queue.emit("change",e)},it=function(e,t){if(arguments.length===1&&!uc.defined(e))throw new Error("Invalid input");return this instanceof it?(Mr.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:r=>{this.emit("warning",r),fc(r)},queueListener:hc},this.options.input=this._createInputDescriptor(e,t,{allowStream:!0}),this):new it(e,t)};Object.setPrototypeOf(it.prototype,Mr.Duplex.prototype);Object.setPrototypeOf(it,Mr.Duplex);function dc(){let e=this.constructor.call(),{debuglog:t,queueListener:r,...s}=this.options;return e.options=structuredClone(s),e.options.debuglog=t,e.options.queueListener=r,this._isStreamInput()&&this.on("finish",()=>{this._flattenBufferIn(),e.options.input.buffer=this.options.input.buffer,e.emit("finish")}),e}Object.assign(it.prototype,{clone:dc});Zn.exports=it});var si=D((vd,ri)=>{var h=Ie(),Je=_t(),pc={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},gc=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function ti(e){let t=gc.filter(r=>h.defined(e[r])).map(r=>[r,e[r]]);return t.length?Object.fromEntries(t):void 0}function mc(e,t,r){let s={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(h.string(e))s.file=e;else if(h.buffer(e)){if(e.length===0)throw Error("Input Buffer is empty");s.buffer=e}else if(h.arrayBuffer(e)){if(e.byteLength===0)throw Error("Input bit Array is empty");s.buffer=Buffer.from(e,0,e.byteLength)}else if(h.typedArray(e)){if(e.length===0)throw Error("Input Bit Array is empty");s.buffer=Buffer.from(e.buffer,e.byteOffset,e.byteLength)}else if(h.plainObject(e)&&!h.defined(t))t=e,ti(t)&&(s.buffer=[]);else if(!h.defined(e)&&!h.defined(t)&&h.object(r)&&r.allowStream)s.buffer=[];else if(Array.isArray(e))if(e.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=e.map(n=>this._createInputDescriptor(n));else throw new Error("Recursive join is unsupported");else throw new Error("Expected at least two images to join");else throw new Error(`Unsupported input '${e}' of type ${typeof e}${h.defined(t)?` when also providing options of type ${typeof t}`:""}`);if(h.object(t)){if(h.defined(t.failOnError))if(h.bool(t.failOnError))s.failOn=t.failOnError?"warning":"none";else throw h.invalidParameterError("failOnError","boolean",t.failOnError);if(h.defined(t.failOn))if(h.string(t.failOn)&&h.inArray(t.failOn,["none","truncated","error","warning"]))s.failOn=t.failOn;else throw h.invalidParameterError("failOn","one of: none, truncated, error, warning",t.failOn);if(h.defined(t.autoOrient))if(h.bool(t.autoOrient))s.autoOrient=t.autoOrient;else throw h.invalidParameterError("autoOrient","boolean",t.autoOrient);if(h.defined(t.density))if(h.inRange(t.density,1,1e5))s.density=t.density;else throw h.invalidParameterError("density","number between 1 and 100000",t.density);if(h.defined(t.ignoreIcc))if(h.bool(t.ignoreIcc))s.ignoreIcc=t.ignoreIcc;else throw h.invalidParameterError("ignoreIcc","boolean",t.ignoreIcc);if(h.defined(t.limitInputPixels))if(h.bool(t.limitInputPixels))s.limitInputPixels=t.limitInputPixels?16383**2:0;else if(h.integer(t.limitInputPixels)&&h.inRange(t.limitInputPixels,0,Number.MAX_SAFE_INTEGER))s.limitInputPixels=t.limitInputPixels;else throw h.invalidParameterError("limitInputPixels","positive integer",t.limitInputPixels);if(h.defined(t.unlimited))if(h.bool(t.unlimited))s.unlimited=t.unlimited;else throw h.invalidParameterError("unlimited","boolean",t.unlimited);if(h.defined(t.sequentialRead))if(h.bool(t.sequentialRead))s.sequentialRead=t.sequentialRead;else throw h.invalidParameterError("sequentialRead","boolean",t.sequentialRead);if(h.defined(t.raw)){if(h.object(t.raw)&&h.integer(t.raw.width)&&t.raw.width>0&&h.integer(t.raw.height)&&t.raw.height>0&&h.integer(t.raw.channels)&&h.inRange(t.raw.channels,1,4))switch(s.rawWidth=t.raw.width,s.rawHeight=t.raw.height,s.rawChannels=t.raw.channels,e.constructor){case Uint8Array:case Uint8ClampedArray:s.rawDepth="uchar";break;case Int8Array:s.rawDepth="char";break;case Uint16Array:s.rawDepth="ushort";break;case Int16Array:s.rawDepth="short";break;case Uint32Array:s.rawDepth="uint";break;case Int32Array:s.rawDepth="int";break;case Float32Array:s.rawDepth="float";break;case Float64Array:s.rawDepth="double";break;default:s.rawDepth="uchar";break}else throw new Error("Expected width, height and channels for raw pixel input");if(s.rawPremultiplied=!1,h.defined(t.raw.premultiplied))if(h.bool(t.raw.premultiplied))s.rawPremultiplied=t.raw.premultiplied;else throw h.invalidParameterError("raw.premultiplied","boolean",t.raw.premultiplied);if(s.rawPageHeight=0,h.defined(t.raw.pageHeight))if(h.integer(t.raw.pageHeight)&&t.raw.pageHeight>0&&t.raw.pageHeight<=t.raw.height){if(t.raw.height%t.raw.pageHeight!==0)throw new Error(`Expected raw.height ${t.raw.height} to be a multiple of raw.pageHeight ${t.raw.pageHeight}`);s.rawPageHeight=t.raw.pageHeight}else throw h.invalidParameterError("raw.pageHeight","positive integer",t.raw.pageHeight)}if(h.defined(t.animated))if(h.bool(t.animated))s.pages=t.animated?-1:1;else throw h.invalidParameterError("animated","boolean",t.animated);if(h.defined(t.pages))if(h.integer(t.pages)&&h.inRange(t.pages,-1,1e5))s.pages=t.pages;else throw h.invalidParameterError("pages","integer between -1 and 100000",t.pages);if(h.defined(t.page))if(h.integer(t.page)&&h.inRange(t.page,0,1e5))s.page=t.page;else throw h.invalidParameterError("page","integer between 0 and 100000",t.page);if(h.object(t.openSlide)&&h.defined(t.openSlide.level))if(h.integer(t.openSlide.level)&&h.inRange(t.openSlide.level,0,256))s.openSlideLevel=t.openSlide.level;else throw h.invalidParameterError("openSlide.level","integer between 0 and 256",t.openSlide.level);else if(h.defined(t.level))if(h.integer(t.level)&&h.inRange(t.level,0,256))s.openSlideLevel=t.level;else throw h.invalidParameterError("level","integer between 0 and 256",t.level);if(h.object(t.tiff)&&h.defined(t.tiff.subifd))if(h.integer(t.tiff.subifd)&&h.inRange(t.tiff.subifd,-1,1e5))s.tiffSubifd=t.tiff.subifd;else throw h.invalidParameterError("tiff.subifd","integer between -1 and 100000",t.tiff.subifd);else if(h.defined(t.subifd))if(h.integer(t.subifd)&&h.inRange(t.subifd,-1,1e5))s.tiffSubifd=t.subifd;else throw h.invalidParameterError("subifd","integer between -1 and 100000",t.subifd);if(h.object(t.svg)){if(h.defined(t.svg.stylesheet))if(h.string(t.svg.stylesheet))s.svgStylesheet=t.svg.stylesheet;else throw h.invalidParameterError("svg.stylesheet","string",t.svg.stylesheet);if(h.defined(t.svg.highBitdepth))if(h.bool(t.svg.highBitdepth))s.svgHighBitdepth=t.svg.highBitdepth;else throw h.invalidParameterError("svg.highBitdepth","boolean",t.svg.highBitdepth)}if(h.object(t.pdf)&&h.defined(t.pdf.background)?s.pdfBackground=this._getBackgroundColourOption(t.pdf.background):h.defined(t.pdfBackground)&&(s.pdfBackground=this._getBackgroundColourOption(t.pdfBackground)),h.object(t.jp2)&&h.defined(t.jp2.oneshot))if(h.bool(t.jp2.oneshot))s.jp2Oneshot=t.jp2.oneshot;else throw h.invalidParameterError("jp2.oneshot","boolean",t.jp2.oneshot);if(h.defined(t.create))if(h.object(t.create)&&h.integer(t.create.width)&&t.create.width>0&&h.integer(t.create.height)&&t.create.height>0&&h.integer(t.create.channels)){if(s.createWidth=t.create.width,s.createHeight=t.create.height,s.createChannels=t.create.channels,s.createPageHeight=0,h.defined(t.create.pageHeight))if(h.integer(t.create.pageHeight)&&t.create.pageHeight>0&&t.create.pageHeight<=t.create.height){if(t.create.height%t.create.pageHeight!==0)throw new Error(`Expected create.height ${t.create.height} to be a multiple of create.pageHeight ${t.create.pageHeight}`);s.createPageHeight=t.create.pageHeight}else throw h.invalidParameterError("create.pageHeight","positive integer",t.create.pageHeight);if(h.defined(t.create.noise)){if(!h.object(t.create.noise))throw new Error("Expected noise to be an object");if(t.create.noise.type!=="gaussian")throw new Error("Only gaussian noise is supported at the moment");if(s.createNoiseType=t.create.noise.type,!h.inRange(t.create.channels,1,4))throw h.invalidParameterError("create.channels","number between 1 and 4",t.create.channels);if(s.createNoiseMean=128,h.defined(t.create.noise.mean))if(h.number(t.create.noise.mean)&&h.inRange(t.create.noise.mean,0,1e4))s.createNoiseMean=t.create.noise.mean;else throw h.invalidParameterError("create.noise.mean","number between 0 and 10000",t.create.noise.mean);if(s.createNoiseSigma=30,h.defined(t.create.noise.sigma))if(h.number(t.create.noise.sigma)&&h.inRange(t.create.noise.sigma,0,1e4))s.createNoiseSigma=t.create.noise.sigma;else throw h.invalidParameterError("create.noise.sigma","number between 0 and 10000",t.create.noise.sigma)}else if(h.defined(t.create.background)){if(!h.inRange(t.create.channels,3,4))throw h.invalidParameterError("create.channels","number between 3 and 4",t.create.channels);s.createBackground=this._getBackgroundColourOption(t.create.background)}else throw new Error("Expected valid noise or background to create a new input image");delete s.buffer}else throw new Error("Expected valid width, height and channels to create a new input image");if(h.defined(t.text))if(h.object(t.text)&&h.string(t.text.text)){if(s.textValue=t.text.text,h.defined(t.text.height)&&h.defined(t.text.dpi))throw new Error("Expected only one of dpi or height");if(h.defined(t.text.font))if(h.string(t.text.font))s.textFont=t.text.font;else throw h.invalidParameterError("text.font","string",t.text.font);if(h.defined(t.text.fontfile))if(h.string(t.text.fontfile))s.textFontfile=t.text.fontfile;else throw h.invalidParameterError("text.fontfile","string",t.text.fontfile);if(h.defined(t.text.width))if(h.integer(t.text.width)&&t.text.width>0)s.textWidth=t.text.width;else throw h.invalidParameterError("text.width","positive integer",t.text.width);if(h.defined(t.text.height))if(h.integer(t.text.height)&&t.text.height>0)s.textHeight=t.text.height;else throw h.invalidParameterError("text.height","positive integer",t.text.height);if(h.defined(t.text.align))if(h.string(t.text.align)&&h.string(this.constructor.align[t.text.align]))s.textAlign=this.constructor.align[t.text.align];else throw h.invalidParameterError("text.align","valid alignment",t.text.align);if(h.defined(t.text.justify))if(h.bool(t.text.justify))s.textJustify=t.text.justify;else throw h.invalidParameterError("text.justify","boolean",t.text.justify);if(h.defined(t.text.dpi))if(h.integer(t.text.dpi)&&h.inRange(t.text.dpi,1,1e6))s.textDpi=t.text.dpi;else throw h.invalidParameterError("text.dpi","integer between 1 and 1000000",t.text.dpi);if(h.defined(t.text.rgba))if(h.bool(t.text.rgba))s.textRgba=t.text.rgba;else throw h.invalidParameterError("text.rgba","bool",t.text.rgba);if(h.defined(t.text.spacing))if(h.integer(t.text.spacing)&&h.inRange(t.text.spacing,-1e6,1e6))s.textSpacing=t.text.spacing;else throw h.invalidParameterError("text.spacing","integer between -1000000 and 1000000",t.text.spacing);if(h.defined(t.text.wrap))if(h.string(t.text.wrap)&&h.inArray(t.text.wrap,["word","char","word-char","none"]))s.textWrap=t.text.wrap;else throw h.invalidParameterError("text.wrap","one of: word, char, word-char, none",t.text.wrap);delete s.buffer}else throw new Error("Expected a valid string to create an image with text.");if(h.defined(t.join))if(h.defined(this.options.join)){if(h.defined(t.join.animated))if(h.bool(t.join.animated))s.joinAnimated=t.join.animated;else throw h.invalidParameterError("join.animated","boolean",t.join.animated);if(h.defined(t.join.across))if(h.integer(t.join.across)&&h.inRange(t.join.across,1,1e6))s.joinAcross=t.join.across;else throw h.invalidParameterError("join.across","integer between 1 and 100000",t.join.across);if(h.defined(t.join.shim))if(h.integer(t.join.shim)&&h.inRange(t.join.shim,0,1e6))s.joinShim=t.join.shim;else throw h.invalidParameterError("join.shim","integer between 0 and 100000",t.join.shim);if(h.defined(t.join.background)&&(s.joinBackground=this._getBackgroundColourOption(t.join.background)),h.defined(t.join.halign))if(h.string(t.join.halign)&&h.string(this.constructor.align[t.join.halign]))s.joinHalign=this.constructor.align[t.join.halign];else throw h.invalidParameterError("join.halign","valid alignment",t.join.halign);if(h.defined(t.join.valign))if(h.string(t.join.valign)&&h.string(this.constructor.align[t.join.valign]))s.joinValign=this.constructor.align[t.join.valign];else throw h.invalidParameterError("join.valign","valid alignment",t.join.valign)}else throw new Error("Expected input to be an array of images to join")}else if(h.defined(t))throw new Error(`Invalid input options ${t}`);return s}function bc(e,t,r){Array.isArray(this.options.input.buffer)?h.buffer(e)?(this.options.input.buffer.length===0&&this.on("finish",()=>{this.streamInFinished=!0}),this.options.input.buffer.push(e),r()):r(new Error("Non-Buffer data on Writable Stream")):r(new Error("Unexpected data on Writable Stream"))}function vc(){this._isStreamInput()&&(this.options.input.buffer=Buffer.concat(this.options.input.buffer))}function yc(){return Array.isArray(this.options.input.buffer)}function wc(e){let t=Error();return h.fn(e)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Je.metadata(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)})}):Je.metadata(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{let n=()=>{this._flattenBufferIn(),Je.metadata(this.options,(i,o)=>{i?s(h.nativeError(i,t)):r(o)})};this.writableFinished?n():this.once("finish",n)}):new Promise((r,s)=>{Je.metadata(this.options,(n,i)=>{n?s(h.nativeError(n,t)):r(i)})})}function Ec(e){let t=Error();return h.fn(e)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Je.stats(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)})}):Je.stats(this.options,(r,s)=>{r?e(h.nativeError(r,t)):e(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{this.on("finish",function(){this._flattenBufferIn(),Je.stats(this.options,(n,i)=>{n?s(h.nativeError(n,t)):r(i)})})}):new Promise((r,s)=>{Je.stats(this.options,(n,i)=>{n?s(h.nativeError(n,t)):r(i)})})}ri.exports=e=>{Object.assign(e.prototype,{_inputOptionsFromObject:ti,_createInputDescriptor:mc,_write:bc,_flattenBufferIn:vc,_isStreamInput:yc,metadata:wc,stats:Ec}),e.align=pc}});var ci=D((yd,li)=>{var x=Ie(),ii={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},oi={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},ni={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},ai={entropy:16,attention:17},zr={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},xc={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},Pc={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function Br(e){return e.angle%360!==0||e.rotationAngle!==0}function tr(e){return e.width!==-1||e.height!==-1}function Sc(e,t,r){if(tr(this.options)&&this.options.debuglog("ignoring previous resize options"),this.options.widthPost!==-1&&this.options.debuglog("operation order will be: extract, resize, extract"),x.defined(e))if(x.object(e)&&!x.defined(r))r=e;else if(x.integer(e)&&e>0)this.options.width=e;else throw x.invalidParameterError("width","positive integer",e);else this.options.width=-1;if(x.defined(t))if(x.integer(t)&&t>0)this.options.height=t;else throw x.invalidParameterError("height","positive integer",t);else this.options.height=-1;if(x.object(r)){if(x.defined(r.width))if(x.integer(r.width)&&r.width>0)this.options.width=r.width;else throw x.invalidParameterError("width","positive integer",r.width);if(x.defined(r.height))if(x.integer(r.height)&&r.height>0)this.options.height=r.height;else throw x.invalidParameterError("height","positive integer",r.height);if(x.defined(r.fit)){let s=Pc[r.fit];if(x.string(s))this.options.canvas=s;else throw x.invalidParameterError("fit","valid fit",r.fit)}if(x.defined(r.position)){let s=x.integer(r.position)?r.position:ai[r.position]||oi[r.position]||ii[r.position];if(x.integer(s)&&(x.inRange(s,0,8)||x.inRange(s,16,17)))this.options.position=s;else throw x.invalidParameterError("position","valid position/gravity/strategy",r.position)}if(this._setBackgroundColourOption("resizeBackground",r.background),x.defined(r.kernel))if(x.string(zr[r.kernel]))this.options.kernel=zr[r.kernel];else throw x.invalidParameterError("kernel","valid kernel name",r.kernel);x.defined(r.withoutEnlargement)&&this._setBooleanOption("withoutEnlargement",r.withoutEnlargement),x.defined(r.withoutReduction)&&this._setBooleanOption("withoutReduction",r.withoutReduction),x.defined(r.fastShrinkOnLoad)&&this._setBooleanOption("fastShrinkOnLoad",r.fastShrinkOnLoad)}return Br(this.options)&&tr(this.options)&&(this.options.rotateBefore=!0),this}function Rc(e){if(x.integer(e)&&e>0)this.options.extendTop=e,this.options.extendBottom=e,this.options.extendLeft=e,this.options.extendRight=e;else if(x.object(e)){if(x.defined(e.top))if(x.integer(e.top)&&e.top>=0)this.options.extendTop=e.top;else throw x.invalidParameterError("top","positive integer",e.top);if(x.defined(e.bottom))if(x.integer(e.bottom)&&e.bottom>=0)this.options.extendBottom=e.bottom;else throw x.invalidParameterError("bottom","positive integer",e.bottom);if(x.defined(e.left))if(x.integer(e.left)&&e.left>=0)this.options.extendLeft=e.left;else throw x.invalidParameterError("left","positive integer",e.left);if(x.defined(e.right))if(x.integer(e.right)&&e.right>=0)this.options.extendRight=e.right;else throw x.invalidParameterError("right","positive integer",e.right);if(this._setBackgroundColourOption("extendBackground",e.background),x.defined(e.extendWith))if(x.string(ni[e.extendWith]))this.options.extendWith=ni[e.extendWith];else throw x.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",e.extendWith)}else throw x.invalidParameterError("extend","integer or object",e);return this}function $c(e){let t=tr(this.options)||this.options.widthPre!==-1?"Post":"Pre";return this.options[`width${t}`]!==-1&&this.options.debuglog("ignoring previous extract options"),["left","top","width","height"].forEach(function(r){let s=e[r];if(x.integer(s)&&s>=0)this.options[r+(r==="left"||r==="top"?"Offset":"")+t]=s;else throw x.invalidParameterError(r,"integer",s)},this),Br(this.options)&&!tr(this.options)&&(this.options.widthPre===-1||this.options.widthPost===-1)&&(this.options.rotateBefore=!0),this.options.input.autoOrient&&(this.options.orientBefore=!0),this}function kc(e){if(this.options.trimThreshold=10,x.defined(e))if(x.object(e)){if(x.defined(e.background)&&this._setBackgroundColourOption("trimBackground",e.background),x.defined(e.threshold))if(x.number(e.threshold)&&e.threshold>=0)this.options.trimThreshold=e.threshold;else throw x.invalidParameterError("threshold","positive number",e.threshold);x.defined(e.lineArt)&&this._setBooleanOption("trimLineArt",e.lineArt)}else throw x.invalidParameterError("trim","object",e);return Br(this.options)&&(this.options.rotateBefore=!0),this}li.exports=e=>{Object.assign(e.prototype,{resize:Sc,extend:Rc,extract:$c,trim:kc}),e.gravity=ii,e.strategy=ai,e.kernel=zr,e.fit=xc,e.position=oi}});var fi=D((wd,ui)=>{var q=Ie(),Ur={clear:"clear",source:"source",over:"over",in:"in",out:"out",atop:"atop",dest:"dest","dest-over":"dest-over","dest-in":"dest-in","dest-out":"dest-out","dest-atop":"dest-atop",xor:"xor",add:"add",saturate:"saturate",multiply:"multiply",screen:"screen",overlay:"overlay",darken:"darken",lighten:"lighten","colour-dodge":"colour-dodge","color-dodge":"colour-dodge","colour-burn":"colour-burn","color-burn":"colour-burn","hard-light":"hard-light","soft-light":"soft-light",difference:"difference",exclusion:"exclusion"};function Ac(e){if(!Array.isArray(e))throw q.invalidParameterError("images to composite","array",e);return this.options.composite=e.map(t=>{if(!q.object(t))throw q.invalidParameterError("image to composite","object",t);let r=this._inputOptionsFromObject(t),s={input:this._createInputDescriptor(t.input,r,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(q.defined(t.blend))if(q.string(Ur[t.blend]))s.blend=Ur[t.blend];else throw q.invalidParameterError("blend","valid blend name",t.blend);if(q.defined(t.tile))if(q.bool(t.tile))s.tile=t.tile;else throw q.invalidParameterError("tile","boolean",t.tile);if(q.defined(t.left))if(q.integer(t.left))s.left=t.left;else throw q.invalidParameterError("left","integer",t.left);if(q.defined(t.top))if(q.integer(t.top))s.top=t.top;else throw q.invalidParameterError("top","integer",t.top);if(q.defined(t.top)!==q.defined(t.left))throw new Error("Expected both left and top to be set");if(s.hasOffset=q.integer(t.top)&&q.integer(t.left),q.defined(t.gravity))if(q.integer(t.gravity)&&q.inRange(t.gravity,0,8))s.gravity=t.gravity;else if(q.string(t.gravity)&&q.integer(this.constructor.gravity[t.gravity]))s.gravity=this.constructor.gravity[t.gravity];else throw q.invalidParameterError("gravity","valid gravity",t.gravity);if(q.defined(t.premultiplied))if(q.bool(t.premultiplied))s.premultiplied=t.premultiplied;else throw q.invalidParameterError("premultiplied","boolean",t.premultiplied);return s}),this}ui.exports=e=>{e.prototype.composite=Ac,e.blend=Ur}});var mi=D((Ed,gi)=>{var p=Ie(),hi={integer:"integer",float:"float",approximate:"approximate"};function _c(e,t){if(!p.defined(e))return this.autoOrient();if((this.options.angle||this.options.rotationAngle)&&(this.options.debuglog("ignoring previous rotate options"),this.options.angle=0,this.options.rotationAngle=0),p.integer(e)&&!(e%90))this.options.angle=e;else if(p.number(e))this.options.rotationAngle=e,p.object(t)&&t.background&&this._setBackgroundColourOption("rotationBackground",t.background);else throw p.invalidParameterError("angle","numeric",e);return this}function Nc(){return this.options.input.autoOrient=!0,this}function Ic(e){return this.options.flip=p.bool(e)?e:!0,this}function Dc(e){return this.options.flop=p.bool(e)?e:!0,this}function Tc(e,t){let r=[].concat(...e);if(r.length===4&&r.every(p.number))this.options.affineMatrix=r;else throw p.invalidParameterError("matrix","1x4 or 2x2 array",e);if(p.defined(t))if(p.object(t)){if(this._setBackgroundColourOption("affineBackground",t.background),p.defined(t.idx))if(p.number(t.idx))this.options.affineIdx=t.idx;else throw p.invalidParameterError("options.idx","number",t.idx);if(p.defined(t.idy))if(p.number(t.idy))this.options.affineIdy=t.idy;else throw p.invalidParameterError("options.idy","number",t.idy);if(p.defined(t.odx))if(p.number(t.odx))this.options.affineOdx=t.odx;else throw p.invalidParameterError("options.odx","number",t.odx);if(p.defined(t.ody))if(p.number(t.ody))this.options.affineOdy=t.ody;else throw p.invalidParameterError("options.ody","number",t.ody);if(p.defined(t.interpolator))if(p.inArray(t.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=t.interpolator;else throw p.invalidParameterError("options.interpolator","valid interpolator name",t.interpolator)}else throw p.invalidParameterError("options","object",t);return this}function Fc(e,t,r){if(!p.defined(e))this.options.sharpenSigma=-1;else if(p.bool(e))this.options.sharpenSigma=e?-1:0;else if(p.number(e)&&p.inRange(e,.01,1e4)){if(this.options.sharpenSigma=e,p.defined(t))if(p.number(t)&&p.inRange(t,0,1e4))this.options.sharpenM1=t;else throw p.invalidParameterError("flat","number between 0 and 10000",t);if(p.defined(r))if(p.number(r)&&p.inRange(r,0,1e4))this.options.sharpenM2=r;else throw p.invalidParameterError("jagged","number between 0 and 10000",r)}else if(p.plainObject(e)){if(p.number(e.sigma)&&p.inRange(e.sigma,1e-6,10))this.options.sharpenSigma=e.sigma;else throw p.invalidParameterError("options.sigma","number between 0.000001 and 10",e.sigma);if(p.defined(e.m1))if(p.number(e.m1)&&p.inRange(e.m1,0,1e6))this.options.sharpenM1=e.m1;else throw p.invalidParameterError("options.m1","number between 0 and 1000000",e.m1);if(p.defined(e.m2))if(p.number(e.m2)&&p.inRange(e.m2,0,1e6))this.options.sharpenM2=e.m2;else throw p.invalidParameterError("options.m2","number between 0 and 1000000",e.m2);if(p.defined(e.x1))if(p.number(e.x1)&&p.inRange(e.x1,0,1e6))this.options.sharpenX1=e.x1;else throw p.invalidParameterError("options.x1","number between 0 and 1000000",e.x1);if(p.defined(e.y2))if(p.number(e.y2)&&p.inRange(e.y2,0,1e6))this.options.sharpenY2=e.y2;else throw p.invalidParameterError("options.y2","number between 0 and 1000000",e.y2);if(p.defined(e.y3))if(p.number(e.y3)&&p.inRange(e.y3,0,1e6))this.options.sharpenY3=e.y3;else throw p.invalidParameterError("options.y3","number between 0 and 1000000",e.y3)}else throw p.invalidParameterError("sigma","number between 0.01 and 10000",e);return this}function Oc(e){if(!p.defined(e))this.options.medianSize=3;else if(p.integer(e)&&p.inRange(e,1,1e3))this.options.medianSize=e;else throw p.invalidParameterError("size","integer between 1 and 1000",e);return this}function Cc(e){let t;if(p.number(e))t=e;else if(p.plainObject(e)){if(!p.number(e.sigma))throw p.invalidParameterError("options.sigma","number between 0.3 and 1000",t);if(t=e.sigma,"precision"in e)if(p.string(hi[e.precision]))this.options.precision=hi[e.precision];else throw p.invalidParameterError("precision","one of: integer, float, approximate",e.precision);if("minAmplitude"in e)if(p.number(e.minAmplitude)&&p.inRange(e.minAmplitude,.001,1))this.options.minAmpl=e.minAmplitude;else throw p.invalidParameterError("minAmplitude","number between 0.001 and 1",e.minAmplitude)}if(!p.defined(e))this.options.blurSigma=-1;else if(p.bool(e))this.options.blurSigma=e?-1:0;else if(p.number(t)&&p.inRange(t,.3,1e3))this.options.blurSigma=t;else throw p.invalidParameterError("sigma","number between 0.3 and 1000",t);return this}function di(e){if(!p.defined(e))this.options.dilateWidth=1;else if(p.integer(e)&&e>0)this.options.dilateWidth=e;else throw p.invalidParameterError("dilate","positive integer",di);return this}function pi(e){if(!p.defined(e))this.options.erodeWidth=1;else if(p.integer(e)&&e>0)this.options.erodeWidth=e;else throw p.invalidParameterError("erode","positive integer",pi);return this}function jc(e){return this.options.flatten=p.bool(e)?e:!0,p.object(e)&&this._setBackgroundColourOption("flattenBackground",e.background),this}function Lc(){return this.options.unflatten=!0,this}function Mc(e,t){if(!p.defined(e))this.options.gamma=2.2;else if(p.number(e)&&p.inRange(e,1,3))this.options.gamma=e;else throw p.invalidParameterError("gamma","number between 1.0 and 3.0",e);if(!p.defined(t))this.options.gammaOut=this.options.gamma;else if(p.number(t)&&p.inRange(t,1,3))this.options.gammaOut=t;else throw p.invalidParameterError("gammaOut","number between 1.0 and 3.0",t);return this}function zc(e){if(this.options.negate=p.bool(e)?e:!0,p.plainObject(e)&&"alpha"in e)if(p.bool(e.alpha))this.options.negateAlpha=e.alpha;else throw p.invalidParameterError("alpha","should be boolean value",e.alpha);return this}function Bc(e){if(p.plainObject(e)){if(p.defined(e.lower))if(p.number(e.lower)&&p.inRange(e.lower,0,99))this.options.normaliseLower=e.lower;else throw p.invalidParameterError("lower","number between 0 and 99",e.lower);if(p.defined(e.upper))if(p.number(e.upper)&&p.inRange(e.upper,1,100))this.options.normaliseUpper=e.upper;else throw p.invalidParameterError("upper","number between 1 and 100",e.upper)}if(this.options.normaliseLower>=this.options.normaliseUpper)throw p.invalidParameterError("range","lower to be less than upper",`${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);return this.options.normalise=!0,this}function Uc(e){return this.normalise(e)}function Gc(e){if(p.plainObject(e)){if(p.integer(e.width)&&e.width>0)this.options.claheWidth=e.width;else throw p.invalidParameterError("width","integer greater than zero",e.width);if(p.integer(e.height)&&e.height>0)this.options.claheHeight=e.height;else throw p.invalidParameterError("height","integer greater than zero",e.height);if(p.defined(e.maxSlope))if(p.integer(e.maxSlope)&&p.inRange(e.maxSlope,0,100))this.options.claheMaxSlope=e.maxSlope;else throw p.invalidParameterError("maxSlope","integer between 0 and 100",e.maxSlope)}else throw p.invalidParameterError("options","plain object",e);return this}function qc(e){if(!p.object(e)||!Array.isArray(e.kernel)||!p.integer(e.width)||!p.integer(e.height)||!p.inRange(e.width,3,1001)||!p.inRange(e.height,3,1001)||e.height*e.width!==e.kernel.length)throw new Error("Invalid convolution kernel");return p.integer(e.scale)||(e.scale=e.kernel.reduce((t,r)=>t+r,0)),e.scale<1&&(e.scale=1),p.integer(e.offset)||(e.offset=0),this.options.convKernel=e,this}function Wc(e,t){if(!p.defined(e))this.options.threshold=128;else if(p.bool(e))this.options.threshold=e?128:0;else if(p.integer(e)&&p.inRange(e,0,255))this.options.threshold=e;else throw p.invalidParameterError("threshold","integer between 0 and 255",e);return!p.object(t)||t.greyscale===!0||t.grayscale===!0?this.options.thresholdGrayscale=!0:this.options.thresholdGrayscale=!1,this}function Hc(e,t,r){if(this.options.boolean=this._createInputDescriptor(e,r),p.string(t)&&p.inArray(t,["and","or","eor"]))this.options.booleanOp=t;else throw p.invalidParameterError("operator","one of: and, or, eor",t);return this}function Vc(e,t){if(!p.defined(e)&&p.number(t)?e=1:p.number(e)&&!p.defined(t)&&(t=0),!p.defined(e))this.options.linearA=[];else if(p.number(e))this.options.linearA=[e];else if(Array.isArray(e)&&e.length&&e.every(p.number))this.options.linearA=e;else throw p.invalidParameterError("a","number or array of numbers",e);if(!p.defined(t))this.options.linearB=[];else if(p.number(t))this.options.linearB=[t];else if(Array.isArray(t)&&t.length&&t.every(p.number))this.options.linearB=t;else throw p.invalidParameterError("b","number or array of numbers",t);if(this.options.linearA.length!==this.options.linearB.length)throw new Error("Expected a and b to be arrays of the same length");return this}function Jc(e){if(!Array.isArray(e))throw p.invalidParameterError("inputMatrix","array",e);if(e.length!==3&&e.length!==4)throw p.invalidParameterError("inputMatrix","3x3 or 4x4 array",e.length);let t=e.flat().map(Number);if(t.length!==9&&t.length!==16)throw p.invalidParameterError("inputMatrix","cardinality of 9 or 16",t.length);return this.options.recombMatrix=t,this}function Xc(e){if(!p.plainObject(e))throw p.invalidParameterError("options","plain object",e);if("brightness"in e)if(p.number(e.brightness)&&e.brightness>=0)this.options.brightness=e.brightness;else throw p.invalidParameterError("brightness","number above zero",e.brightness);if("saturation"in e)if(p.number(e.saturation)&&e.saturation>=0)this.options.saturation=e.saturation;else throw p.invalidParameterError("saturation","number above zero",e.saturation);if("hue"in e)if(p.integer(e.hue))this.options.hue=e.hue%360;else throw p.invalidParameterError("hue","number",e.hue);if("lightness"in e)if(p.number(e.lightness))this.options.lightness=e.lightness;else throw p.invalidParameterError("lightness","number",e.lightness);return this}gi.exports=e=>{Object.assign(e.prototype,{autoOrient:Nc,rotate:_c,flip:Ic,flop:Dc,affine:Tc,sharpen:Fc,erode:pi,dilate:di,median:Oc,blur:Cc,flatten:jc,unflatten:Lc,gamma:Mc,negate:zc,normalise:Bc,normalize:Uc,clahe:Gc,convolve:qc,threshold:Wc,boolean:Hc,linear:Vc,recomb:Jc,modulate:Xc})}});var xi=D((xd,Ei)=>{var Hr=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,Kc=Object.getOwnPropertyNames,Qc=Object.prototype.hasOwnProperty,Zc=(e,t)=>{for(var r in t)Hr(e,r,{get:t[r],enumerable:!0})},eu=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Kc(t))!Qc.call(e,n)&&n!==r&&Hr(e,n,{get:()=>t[n],enumerable:!(s=Yc(t,n))||s.enumerable});return e},tu=e=>eu(Hr({},"__esModule",{value:!0}),e),bi={};Zc(bi,{default:()=>gu});Ei.exports=tu(bi);var Ce={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},vi=Object.create(null);for(let e in Ce)Object.hasOwn(Ce,e)&&(vi[Ce[e]]=e);var ge={to:{},get:{}};ge.get=function(e){let t=e.slice(0,3).toLowerCase(),r,s;switch(t){case"hsl":{r=ge.get.hsl(e),s="hsl";break}case"hwb":{r=ge.get.hwb(e),s="hwb";break}default:{r=ge.get.rgb(e),s="rgb";break}}return r?{model:s,value:r}:null};ge.get.rgb=function(e){if(!e)return null;let t=/^#([a-f\d]{3,4})$/i,r=/^#([a-f\d]{6})([a-f\d]{2})?$/i,s=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,n=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,i=/^(\w+)$/,o=[0,0,0,1],a,l,u;if(a=e.match(r)){for(u=a[2],a=a[1],l=0;l<3;l++){let f=l*2;o[l]=Number.parseInt(a.slice(f,f+2),16)}u&&(o[3]=Number.parseInt(u,16)/255)}else if(a=e.match(t)){for(a=a[1],u=a[3],l=0;l<3;l++)o[l]=Number.parseInt(a[l]+a[l],16);u&&(o[3]=Number.parseInt(u+u,16)/255)}else if(a=e.match(s)){for(l=0;l<3;l++)o[l]=Number.parseInt(a[l+1],10);a[4]&&(o[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=e.match(n)){for(l=0;l<3;l++)o[l]=Math.round(Number.parseFloat(a[l+1])*2.55);a[4]&&(o[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=e.match(i))?a[1]==="transparent"?[0,0,0,0]:Object.hasOwn(Ce,a[1])?(o=Ce[a[1]],o[3]=1,o):null:null;for(l=0;l<3;l++)o[l]=Xe(o[l],0,255);return o[3]=Xe(o[3],0,1),o};ge.get.hsl=function(e){if(!e)return null;let t=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=e.match(t);if(r){let s=Number.parseFloat(r[4]),n=(Number.parseFloat(r[1])%360+360)%360,i=Xe(Number.parseFloat(r[2]),0,100),o=Xe(Number.parseFloat(r[3]),0,100),a=Xe(Number.isNaN(s)?1:s,0,1);return[n,i,o,a]}return null};ge.get.hwb=function(e){if(!e)return null;let t=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=e.match(t);if(r){let s=Number.parseFloat(r[4]),n=(Number.parseFloat(r[1])%360+360)%360,i=Xe(Number.parseFloat(r[2]),0,100),o=Xe(Number.parseFloat(r[3]),0,100),a=Xe(Number.isNaN(s)?1:s,0,1);return[n,i,o,a]}return null};ge.to.hex=function(...e){return"#"+rr(e[0])+rr(e[1])+rr(e[2])+(e[3]<1?rr(Math.round(e[3]*255)):"")};ge.to.rgb=function(...e){return e.length<4||e[3]===1?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"};ge.to.rgb.percent=function(...e){let t=Math.round(e[0]/255*100),r=Math.round(e[1]/255*100),s=Math.round(e[2]/255*100);return e.length<4||e[3]===1?"rgb("+t+"%, "+r+"%, "+s+"%)":"rgba("+t+"%, "+r+"%, "+s+"%, "+e[3]+")"};ge.to.hsl=function(...e){return e.length<4||e[3]===1?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"};ge.to.hwb=function(...e){let t="";return e.length>=4&&e[3]!==1&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"};ge.to.keyword=function(...e){return vi[e.slice(0,3)]};function Xe(e,t,r){return Math.min(Math.max(t,e),r)}function rr(e){let t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}var dt=ge,yi={};for(let e of Object.keys(Ce))yi[Ce[e]]=e;var v={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},ot=v,Be=(6/29)**3;function gt(e){let t=e>.0031308?1.055*e**.4166666666666667-.055:e*12.92;return Math.min(Math.max(0,t),1)}function mt(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(let e of Object.keys(v)){if(!("channels"in v[e]))throw new Error("missing channels property: "+e);if(!("labels"in v[e]))throw new Error("missing channel labels property: "+e);if(v[e].labels.length!==v[e].channels)throw new Error("channel and label counts mismatch: "+e);let{channels:t,labels:r}=v[e];delete v[e].channels,delete v[e].labels,Object.defineProperty(v[e],"channels",{value:t}),Object.defineProperty(v[e],"labels",{value:r})}v.rgb.hsl=function(e){let t=e[0]/255,r=e[1]/255,s=e[2]/255,n=Math.min(t,r,s),i=Math.max(t,r,s),o=i-n,a,l;switch(i){case n:{a=0;break}case t:{a=(r-s)/o;break}case r:{a=2+(s-t)/o;break}case s:{a=4+(t-r)/o;break}}a=Math.min(a*60,360),a<0&&(a+=360);let u=(n+i)/2;return i===n?l=0:u<=.5?l=o/(i+n):l=o/(2-i-n),[a,l*100,u*100]};v.rgb.hsv=function(e){let t,r,s,n,i,o=e[0]/255,a=e[1]/255,l=e[2]/255,u=Math.max(o,a,l),f=u-Math.min(o,a,l),d=function(g){return(u-g)/6/f+1/2};if(f===0)n=0,i=0;else{switch(i=f/u,t=d(o),r=d(a),s=d(l),u){case o:{n=s-r;break}case a:{n=1/3+t-s;break}case l:{n=2/3+r-t;break}}n<0?n+=1:n>1&&(n-=1)}return[n*360,i*100,u*100]};v.rgb.hwb=function(e){let t=e[0],r=e[1],s=e[2],n=v.rgb.hsl(e)[0],i=1/255*Math.min(t,Math.min(r,s));return s=1-1/255*Math.max(t,Math.max(r,s)),[n,i*100,s*100]};v.rgb.oklab=function(e){let t=mt(e[0]/255),r=mt(e[1]/255),s=mt(e[2]/255),n=Math.cbrt(.4122214708*t+.5363325363*r+.0514459929*s),i=Math.cbrt(.2119034982*t+.6806995451*r+.1073969566*s),o=Math.cbrt(.0883024619*t+.2817188376*r+.6299787005*s),a=.2104542553*n+.793617785*i-.0040720468*o,l=1.9779984951*n-2.428592205*i+.4505937099*o,u=.0259040371*n+.7827717662*i-.808675766*o;return[a*100,l*100,u*100]};v.rgb.cmyk=function(e){let t=e[0]/255,r=e[1]/255,s=e[2]/255,n=Math.min(1-t,1-r,1-s),i=(1-t-n)/(1-n)||0,o=(1-r-n)/(1-n)||0,a=(1-s-n)/(1-n)||0;return[i*100,o*100,a*100,n*100]};function ru(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}v.rgb.keyword=function(e){let t=yi[e];if(t)return t;let r=Number.POSITIVE_INFINITY,s;for(let n of Object.keys(Ce)){let i=Ce[n],o=ru(e,i);o<r&&(r=o,s=n)}return s};v.keyword.rgb=function(e){return Ce[e]};v.rgb.xyz=function(e){let t=mt(e[0]/255),r=mt(e[1]/255),s=mt(e[2]/255),n=t*.4124564+r*.3575761+s*.1804375,i=t*.2126729+r*.7151522+s*.072175,o=t*.0193339+r*.119192+s*.9503041;return[n*100,i*100,o*100]};v.rgb.lab=function(e){let t=v.rgb.xyz(e),r=t[0],s=t[1],n=t[2];r/=95.047,s/=100,n/=108.883,r=r>Be?r**(1/3):7.787*r+16/116,s=s>Be?s**(1/3):7.787*s+16/116,n=n>Be?n**(1/3):7.787*n+16/116;let i=116*s-16,o=500*(r-s),a=200*(s-n);return[i,o,a]};v.hsl.rgb=function(e){let t=e[0]/360,r=e[1]/100,s=e[2]/100,n,i;if(r===0)return i=s*255,[i,i,i];let o=s<.5?s*(1+r):s+r-s*r,a=2*s-o,l=[0,0,0];for(let u=0;u<3;u++)n=t+1/3*-(u-1),n<0&&n++,n>1&&n--,6*n<1?i=a+(o-a)*6*n:2*n<1?i=o:3*n<2?i=a+(o-a)*(2/3-n)*6:i=a,l[u]=i*255;return l};v.hsl.hsv=function(e){let t=e[0],r=e[1]/100,s=e[2]/100,n=r,i=Math.max(s,.01);s*=2,r*=s<=1?s:2-s,n*=i<=1?i:2-i;let o=(s+r)/2,a=s===0?2*n/(i+n):2*r/(s+r);return[t,a*100,o*100]};v.hsv.rgb=function(e){let t=e[0]/60,r=e[1]/100,s=e[2]/100,n=Math.floor(t)%6,i=t-Math.floor(t),o=255*s*(1-r),a=255*s*(1-r*i),l=255*s*(1-r*(1-i));switch(s*=255,n){case 0:return[s,l,o];case 1:return[a,s,o];case 2:return[o,s,l];case 3:return[o,a,s];case 4:return[l,o,s];case 5:return[s,o,a]}};v.hsv.hsl=function(e){let t=e[0],r=e[1]/100,s=e[2]/100,n=Math.max(s,.01),i,o;o=(2-r)*s;let a=(2-r)*n;return i=r*n,i/=a<=1?a:2-a,i=i||0,o/=2,[t,i*100,o*100]};v.hwb.rgb=function(e){let t=e[0]/360,r=e[1]/100,s=e[2]/100,n=r+s,i;n>1&&(r/=n,s/=n);let o=Math.floor(6*t),a=1-s;i=6*t-o,(o&1)!==0&&(i=1-i);let l=r+i*(a-r),u,f,d;switch(o){default:case 6:case 0:{u=a,f=l,d=r;break}case 1:{u=l,f=a,d=r;break}case 2:{u=r,f=a,d=l;break}case 3:{u=r,f=l,d=a;break}case 4:{u=l,f=r,d=a;break}case 5:{u=a,f=r,d=l;break}}return[u*255,f*255,d*255]};v.cmyk.rgb=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=e[3]/100,i=1-Math.min(1,t*(1-n)+n),o=1-Math.min(1,r*(1-n)+n),a=1-Math.min(1,s*(1-n)+n);return[i*255,o*255,a*255]};v.xyz.rgb=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n,i,o;return n=t*3.2404542+r*-1.5371385+s*-.4985314,i=t*-.969266+r*1.8760108+s*.041556,o=t*.0556434+r*-.2040259+s*1.0572252,n=gt(n),i=gt(i),o=gt(o),[n*255,i*255,o*255]};v.xyz.lab=function(e){let t=e[0],r=e[1],s=e[2];t/=95.047,r/=100,s/=108.883,t=t>Be?t**(1/3):7.787*t+16/116,r=r>Be?r**(1/3):7.787*r+16/116,s=s>Be?s**(1/3):7.787*s+16/116;let n=116*r-16,i=500*(t-r),o=200*(r-s);return[n,i,o]};v.xyz.oklab=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=Math.cbrt(.8189330101*t+.3618667424*r-.1288597137*s),i=Math.cbrt(.0329845436*t+.9293118715*r+.0361456387*s),o=Math.cbrt(.0482003018*t+.2643662691*r+.633851707*s),a=.2104542553*n+.793617785*i-.0040720468*o,l=1.9779984951*n-2.428592205*i+.4505937099*o,u=.0259040371*n+.7827717662*i-.808675766*o;return[a*100,l*100,u*100]};v.oklab.oklch=function(e){return v.lab.lch(e)};v.oklab.xyz=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=(.999999998*t+.396337792*r+.215803758*s)**3,i=(1.000000008*t-.105561342*r-.063854175*s)**3,o=(1.000000055*t-.089484182*r-1.291485538*s)**3,a=1.227013851*n-.55779998*i+.281256149*o,l=-.040580178*n+1.11225687*i-.071676679*o,u=-.076381285*n-.421481978*i+1.58616322*o;return[a*100,l*100,u*100]};v.oklab.rgb=function(e){let t=e[0]/100,r=e[1]/100,s=e[2]/100,n=(t+.3963377774*r+.2158037573*s)**3,i=(t-.1055613458*r-.0638541728*s)**3,o=(t-.0894841775*r-1.291485548*s)**3,a=gt(4.0767416621*n-3.3077115913*i+.2309699292*o),l=gt(-1.2684380046*n+2.6097574011*i-.3413193965*o),u=gt(-.0041960863*n-.7034186147*i+1.707614701*o);return[a*255,l*255,u*255]};v.oklch.oklab=function(e){return v.lch.lab(e)};v.lab.xyz=function(e){let t=e[0],r=e[1],s=e[2],n,i,o;i=(t+16)/116,n=r/500+i,o=i-s/200;let a=i**3,l=n**3,u=o**3;return i=a>Be?a:(i-16/116)/7.787,n=l>Be?l:(n-16/116)/7.787,o=u>Be?u:(o-16/116)/7.787,n*=95.047,i*=100,o*=108.883,[n,i,o]};v.lab.lch=function(e){let t=e[0],r=e[1],s=e[2],n;n=Math.atan2(s,r)*360/2/Math.PI,n<0&&(n+=360);let o=Math.sqrt(r*r+s*s);return[t,o,n]};v.lch.lab=function(e){let t=e[0],r=e[1],n=e[2]/360*2*Math.PI,i=r*Math.cos(n),o=r*Math.sin(n);return[t,i,o]};v.rgb.ansi16=function(e,t=null){let[r,s,n]=e,i=t===null?v.rgb.hsv(e)[2]:t;if(i=Math.round(i/50),i===0)return 30;let o=30+(Math.round(n/255)<<2|Math.round(s/255)<<1|Math.round(r/255));return i===2&&(o+=60),o};v.hsv.ansi16=function(e){return v.rgb.ansi16(v.hsv.rgb(e),e[2])};v.rgb.ansi256=function(e){let t=e[0],r=e[1],s=e[2];return t>>4===r>>4&&r>>4===s>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(s/255*5)};v.ansi16.rgb=function(e){e=e[0];let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let r=(Math.trunc(e>50)+1)*.5,s=(t&1)*r*255,n=(t>>1&1)*r*255,i=(t>>2&1)*r*255;return[s,n,i]};v.ansi256.rgb=function(e){if(e=e[0],e>=232){let i=(e-232)*10+8;return[i,i,i]}e-=16;let t,r=Math.floor(e/36)/5*255,s=Math.floor((t=e%36)/6)/5*255,n=t%6/5*255;return[r,s,n]};v.rgb.hex=function(e){let r=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".slice(r.length)+r};v.hex.rgb=function(e){let t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let r=t[0];t[0].length===3&&(r=[...r].map(a=>a+a).join(""));let s=Number.parseInt(r,16),n=s>>16&255,i=s>>8&255,o=s&255;return[n,i,o]};v.rgb.hcg=function(e){let t=e[0]/255,r=e[1]/255,s=e[2]/255,n=Math.max(Math.max(t,r),s),i=Math.min(Math.min(t,r),s),o=n-i,a,l=o<1?i/(1-o):0;return o<=0?a=0:n===t?a=(r-s)/o%6:n===r?a=2+(s-t)/o:a=4+(t-r)/o,a/=6,a%=1,[a*360,o*100,l*100]};v.hsl.hcg=function(e){let t=e[1]/100,r=e[2]/100,s=r<.5?2*t*r:2*t*(1-r),n=0;return s<1&&(n=(r-.5*s)/(1-s)),[e[0],s*100,n*100]};v.hsv.hcg=function(e){let t=e[1]/100,r=e[2]/100,s=t*r,n=0;return s<1&&(n=(r-s)/(1-s)),[e[0],s*100,n*100]};v.hcg.rgb=function(e){let t=e[0]/360,r=e[1]/100,s=e[2]/100;if(r===0)return[s*255,s*255,s*255];let n=[0,0,0],i=t%1*6,o=i%1,a=1-o,l=0;switch(Math.floor(i)){case 0:{n[0]=1,n[1]=o,n[2]=0;break}case 1:{n[0]=a,n[1]=1,n[2]=0;break}case 2:{n[0]=0,n[1]=1,n[2]=o;break}case 3:{n[0]=0,n[1]=a,n[2]=1;break}case 4:{n[0]=o,n[1]=0,n[2]=1;break}default:n[0]=1,n[1]=0,n[2]=a}return l=(1-r)*s,[(r*n[0]+l)*255,(r*n[1]+l)*255,(r*n[2]+l)*255]};v.hcg.hsv=function(e){let t=e[1]/100,r=e[2]/100,s=t+r*(1-t),n=0;return s>0&&(n=t/s),[e[0],n*100,s*100]};v.hcg.hsl=function(e){let t=e[1]/100,s=e[2]/100*(1-t)+.5*t,n=0;return s>0&&s<.5?n=t/(2*s):s>=.5&&s<1&&(n=t/(2*(1-s))),[e[0],n*100,s*100]};v.hcg.hwb=function(e){let t=e[1]/100,r=e[2]/100,s=t+r*(1-t);return[e[0],(s-t)*100,(1-s)*100]};v.hwb.hcg=function(e){let t=e[1]/100,s=1-e[2]/100,n=s-t,i=0;return n<1&&(i=(s-n)/(1-n)),[e[0],n*100,i*100]};v.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};v.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};v.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};v.gray.hsl=function(e){return[0,0,e[0]]};v.gray.hsv=v.gray.hsl;v.gray.hwb=function(e){return[0,100,e[0]]};v.gray.cmyk=function(e){return[0,0,0,e[0]]};v.gray.lab=function(e){return[e[0],0,0]};v.gray.hex=function(e){let t=Math.round(e[0]/100*255)&255,s=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(s.length)+s};v.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};function su(){let e={},t=Object.keys(ot);for(let{length:r}=t,s=0;s<r;s++)e[t[s]]={distance:-1,parent:null};return e}function nu(e){let t=su(),r=[e];for(t[e].distance=0;r.length>0;){let s=r.pop(),n=Object.keys(ot[s]);for(let{length:i}=n,o=0;o<i;o++){let a=n[o],l=t[a];l.distance===-1&&(l.distance=t[s].distance+1,l.parent=s,r.unshift(a))}}return t}function iu(e,t){return function(r){return t(e(r))}}function ou(e,t){let r=[t[e].parent,e],s=ot[t[e].parent][e],n=t[e].parent;for(;t[n].parent;)r.unshift(t[n].parent),s=iu(ot[t[n].parent][n],s),n=t[n].parent;return s.conversion=r,s}function au(e){let t=nu(e),r={},s=Object.keys(t);for(let{length:n}=s,i=0;i<n;i++){let o=s[i];t[o].parent!==null&&(r[o]=ou(o,t))}return r}var lu=au,pt={},cu=Object.keys(ot);function uu(e){let t=function(...r){let s=r[0];return s==null?s:(s.length>1&&(r=s),e(r))};return"conversion"in e&&(t.conversion=e.conversion),t}function fu(e){let t=function(...r){let s=r[0];if(s==null)return s;s.length>1&&(r=s);let n=e(r);if(typeof n=="object")for(let{length:i}=n,o=0;o<i;o++)n[o]=Math.round(n[o]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}for(let e of cu){pt[e]={},Object.defineProperty(pt[e],"channels",{value:ot[e].channels}),Object.defineProperty(pt[e],"labels",{value:ot[e].labels});let t=lu(e),r=Object.keys(t);for(let s of r){let n=t[s];pt[e][s]=fu(n),pt[e][s].raw=uu(n)}}var be=pt,wi=["keyword","gray","hex"],Gr={};for(let e of Object.keys(be))Gr[[...be[e].labels].sort().join("")]=e;var qr={};function ne(e,t){if(!(this instanceof ne))return new ne(e,t);if(t&&t in wi&&(t=null),t&&!(t in be))throw new Error("Unknown model: "+t);let r,s;if(e==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof ne)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if(typeof e=="string"){let n=dt.get(e);if(n===null)throw new Error("Unable to parse color from string: "+e);this.model=n.model,s=be[this.model].channels,this.color=n.value.slice(0,s),this.valpha=typeof n.value[s]=="number"?n.value[s]:1}else if(e.length>0){this.model=t||"rgb",s=be[this.model].channels;let n=Array.prototype.slice.call(e,0,s);this.color=Wr(n,s),this.valpha=typeof e[s]=="number"?e[s]:1}else if(typeof e=="number")this.model="rgb",this.color=[e>>16&255,e>>8&255,e&255],this.valpha=1;else{this.valpha=1;let n=Object.keys(e);"alpha"in e&&(n.splice(n.indexOf("alpha"),1),this.valpha=typeof e.alpha=="number"?e.alpha:0);let i=n.sort().join("");if(!(i in Gr))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=Gr[i];let{labels:o}=be[this.model],a=[];for(r=0;r<o.length;r++)a.push(e[o[r]]);this.color=Wr(a)}if(qr[this.model])for(s=be[this.model].channels,r=0;r<s;r++){let n=qr[this.model][r];n&&(this.color[r]=n(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}ne.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(e){let t=this.model in dt.to?this:this.rgb();t=t.round(typeof e=="number"?e:1);let r=t.valpha===1?t.color:[...t.color,this.valpha];return dt.to[t.model](...r)},percentString(e){let t=this.rgb().round(typeof e=="number"?e:1),r=t.valpha===1?t.color:[...t.color,this.valpha];return dt.to.rgb.percent(...r)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let e={},{channels:t}=be[this.model],{labels:r}=be[this.model];for(let s=0;s<t;s++)e[r[s]]=this.color[s];return this.valpha!==1&&(e.alpha=this.valpha),e},unitArray(){let e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,this.valpha!==1&&e.push(this.valpha),e},unitObject(){let e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,this.valpha!==1&&(e.alpha=this.valpha),e},round(e){return e=Math.max(e||0,0),new ne([...this.color.map(du(e)),this.valpha],this.model)},alpha(e){return e!==void 0?new ne([...this.color,Math.max(0,Math.min(1,e))],this.model):this.valpha},red:K("rgb",0,ee(255)),green:K("rgb",1,ee(255)),blue:K("rgb",2,ee(255)),hue:K(["hsl","hsv","hsl","hwb","hcg"],0,e=>(e%360+360)%360),saturationl:K("hsl",1,ee(100)),lightness:K("hsl",2,ee(100)),saturationv:K("hsv",1,ee(100)),value:K("hsv",2,ee(100)),chroma:K("hcg",1,ee(100)),gray:K("hcg",2,ee(100)),white:K("hwb",1,ee(100)),wblack:K("hwb",2,ee(100)),cyan:K("cmyk",0,ee(100)),magenta:K("cmyk",1,ee(100)),yellow:K("cmyk",2,ee(100)),black:K("cmyk",3,ee(100)),x:K("xyz",0,ee(95.047)),y:K("xyz",1,ee(100)),z:K("xyz",2,ee(108.833)),l:K("lab",0,ee(100)),a:K("lab",1),b:K("lab",2),keyword(e){return e!==void 0?new ne(e):be[this.model].keyword(this.color)},hex(e){return e!==void 0?new ne(e):dt.to.hex(...this.rgb().round().color)},hexa(e){if(e!==void 0)return new ne(e);let t=this.rgb().round().color,r=Math.round(this.valpha*255).toString(16).toUpperCase();return r.length===1&&(r="0"+r),dt.to.hex(...t)+r},rgbNumber(){let e=this.rgb().color;return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255},luminosity(){let e=this.rgb().color,t=[];for(let[r,s]of e.entries()){let n=s/255;t[r]=n<=.04045?n/12.92:((n+.055)/1.055)**2.4}return .2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){let t=this.luminosity(),r=e.luminosity();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},level(e){let t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){let e=this.rgb().color;return(e[0]*2126+e[1]*7152+e[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){let t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){let t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){let t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){let t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){let t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){let t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){let e=this.rgb().color,t=e[0]*.3+e[1]*.59+e[2]*.11;return ne.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){let t=this.hsl(),r=t.color[0];return r=(r+e)%360,r=r<0?360+r:r,t.color[0]=r,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);let r=e.rgb(),s=this.rgb(),n=t===void 0?.5:t,i=2*n-1,o=r.alpha()-s.alpha(),a=((i*o===-1?i:(i+o)/(1+i*o))+1)/2,l=1-a;return ne.rgb(a*r.red()+l*s.red(),a*r.green()+l*s.green(),a*r.blue()+l*s.blue(),r.alpha()*n+s.alpha()*(1-n))}};for(let e of Object.keys(be)){if(wi.includes(e))continue;let{channels:t}=be[e];ne.prototype[e]=function(...r){return this.model===e?new ne(this):r.length>0?new ne(r,e):new ne([...pu(be[this.model][e].raw(this.color)),this.valpha],e)},ne[e]=function(...r){let s=r[0];return typeof s=="number"&&(s=Wr(r,t)),new ne(s,e)}}function hu(e,t){return Number(e.toFixed(t))}function du(e){return function(t){return hu(t,e)}}function K(e,t,r){e=Array.isArray(e)?e:[e];for(let s of e)(qr[s]||=[])[t]=r;return e=e[0],function(s){let n;return s!==void 0?(r&&(s=r(s)),n=this[e](),n.color[t]=s,n):(n=this[e]().color[t],r&&(n=r(n)),n)}}function ee(e){return function(t){return Math.max(0,Math.min(e,t))}}function pu(e){return Array.isArray(e)?e:[e]}function Wr(e,t){for(let r=0;r<t;r++)typeof e[r]!="number"&&(e[r]=0);return e}var gu=ne});var Si=D((Pd,Pi)=>{Pi.exports=xi().default});var Ai=D((Sd,ki)=>{var mu=Si(),Ue=Ie(),Ri={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function bu(e){return this._setBackgroundColourOption("tint",e),this}function vu(e){return this.options.greyscale=Ue.bool(e)?e:!0,this}function yu(e){return this.greyscale(e)}function wu(e){if(!Ue.string(e))throw Ue.invalidParameterError("colourspace","string",e);return this.options.colourspacePipeline=e,this}function Eu(e){return this.pipelineColourspace(e)}function xu(e){if(!Ue.string(e))throw Ue.invalidParameterError("colourspace","string",e);return this.options.colourspace=e,this}function Pu(e){return this.toColourspace(e)}function $i(e){if(Ue.object(e)||Ue.string(e)&&e.length>=3&&e.length<=200){let t=mu(e);return[t.red(),t.green(),t.blue(),Math.round(t.alpha()*255)]}else throw Ue.invalidParameterError("background","object or string",e)}function Su(e,t){Ue.defined(t)&&(this.options[e]=$i(t))}ki.exports=e=>{Object.assign(e.prototype,{tint:bu,greyscale:vu,grayscale:yu,pipelineColourspace:wu,pipelineColorspace:Eu,toColourspace:xu,toColorspace:Pu,_getBackgroundColourOption:$i,_setBackgroundColourOption:Su}),e.colourspace=Ri,e.colorspace=Ri}});var Ni=D((Rd,_i)=>{var je=Ie(),Ru={and:"and",or:"or",eor:"eor"};function $u(){return this.options.removeAlpha=!0,this}function ku(e){if(je.defined(e))if(je.number(e)&&je.inRange(e,0,1))this.options.ensureAlpha=e;else throw je.invalidParameterError("alpha","number between 0 and 1",e);else this.options.ensureAlpha=1;return this}function Au(e){let t={red:0,green:1,blue:2,alpha:3};if(Object.keys(t).includes(e)&&(e=t[e]),je.integer(e)&&je.inRange(e,0,4))this.options.extractChannel=e;else throw je.invalidParameterError("channel","integer or one of: red, green, blue, alpha",e);return this}function _u(e,t){return Array.isArray(e)?e.forEach(function(r){this.options.joinChannelIn.push(this._createInputDescriptor(r,t))},this):this.options.joinChannelIn.push(this._createInputDescriptor(e,t)),this}function Nu(e){if(je.string(e)&&je.inArray(e,["and","or","eor"]))this.options.bandBoolOp=e;else throw je.invalidParameterError("boolOp","one of: and, or, eor",e);return this}_i.exports=e=>{Object.assign(e.prototype,{removeAlpha:$u,ensureAlpha:ku,extractChannel:Au,joinChannel:_u,bandbool:Nu}),e.bool=Ru}});var Oi=D(($d,Fi)=>{var Vr=Y("node:path"),c=Ie(),bt=_t(),Ii=new Map([["heic","heif"],["heif","heif"],["avif","avif"],["jpeg","jpeg"],["jpg","jpeg"],["jpe","jpeg"],["tile","tile"],["dz","tile"],["png","png"],["raw","raw"],["tiff","tiff"],["tif","tiff"],["webp","webp"],["gif","gif"],["jp2","jp2"],["jpx","jp2"],["j2k","jp2"],["j2c","jp2"],["jxl","jxl"]]),Iu=/\.(jp[2x]|j2[kc])$/i,Di=()=>new Error("JP2 output requires libvips with support for OpenJPEG"),Ti=e=>1<<31-Math.clz32(Math.ceil(Math.log2(e)));function Du(e,t){let r;if(c.string(e)?c.string(this.options.input.file)&&Vr.resolve(this.options.input.file)===Vr.resolve(e)?r=new Error("Cannot use same file for input and output"):Iu.test(Vr.extname(e))&&!this.constructor.format.jp2k.output.file&&(r=Di()):r=new Error("Missing output file path"),r)if(c.fn(t))t(r);else return Promise.reject(r);else{this.options.fileOut=e;let s=Error();return this._pipeline(t,s)}return this}function Tu(e,t){c.object(e)?this._setBooleanOption("resolveWithObject",e.resolveWithObject):this.options.resolveWithObject&&(this.options.resolveWithObject=!1),this.options.fileOut="";let r=Error();return this._pipeline(c.fn(e)?e:t,r)}function Fu(){return this.options.keepMetadata|=1,this}function Ou(e){if(c.object(e))for(let[t,r]of Object.entries(e))if(c.object(r))for(let[s,n]of Object.entries(r))if(c.string(n))this.options.withExif[`exif-${t.toLowerCase()}-${s}`]=n;else throw c.invalidParameterError(`${t}.${s}`,"string",n);else throw c.invalidParameterError(t,"object",r);else throw c.invalidParameterError("exif","object",e);return this.options.withExifMerge=!1,this.keepExif()}function Cu(e){return this.withExif(e),this.options.withExifMerge=!0,this}function ju(){return this.options.keepMetadata|=8,this}function Lu(e,t){if(c.string(e))this.options.withIccProfile=e;else throw c.invalidParameterError("icc","string",e);if(this.keepIccProfile(),c.object(t)&&c.defined(t.attach))if(c.bool(t.attach))t.attach||(this.options.keepMetadata&=-9);else throw c.invalidParameterError("attach","boolean",t.attach);return this}function Mu(){return this.options.keepMetadata|=2,this}function zu(e){if(c.string(e)&&e.length>0)this.options.withXmp=e,this.options.keepMetadata|=2;else throw c.invalidParameterError("xmp","non-empty string",e);return this}function Bu(){return this.options.keepMetadata=31,this}function Uu(e){if(this.keepMetadata(),this.withIccProfile("srgb"),c.object(e)){if(c.defined(e.orientation))if(c.integer(e.orientation)&&c.inRange(e.orientation,1,8))this.options.withMetadataOrientation=e.orientation;else throw c.invalidParameterError("orientation","integer between 1 and 8",e.orientation);if(c.defined(e.density))if(c.number(e.density)&&e.density>0)this.options.withMetadataDensity=e.density;else throw c.invalidParameterError("density","positive number",e.density);c.defined(e.icc)&&this.withIccProfile(e.icc),c.defined(e.exif)&&this.withExifMerge(e.exif)}return this}function Gu(e,t){let r=Ii.get((c.object(e)&&c.string(e.id)?e.id:e).toLowerCase());if(!r)throw c.invalidParameterError("format",`one of: ${[...Ii.keys()].join(", ")}`,e);return this[r](t)}function qu(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.jpegQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.progressive)&&this._setBooleanOption("jpegProgressive",e.progressive),c.defined(e.chromaSubsampling))if(c.string(e.chromaSubsampling)&&c.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=e.chromaSubsampling;else throw c.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling);let t=c.bool(e.optimizeCoding)?e.optimizeCoding:e.optimiseCoding;if(c.defined(t)&&this._setBooleanOption("jpegOptimiseCoding",t),c.defined(e.mozjpeg))if(c.bool(e.mozjpeg))e.mozjpeg&&(this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3);else throw c.invalidParameterError("mozjpeg","boolean",e.mozjpeg);let r=c.bool(e.trellisQuantization)?e.trellisQuantization:e.trellisQuantisation;c.defined(r)&&this._setBooleanOption("jpegTrellisQuantisation",r),c.defined(e.overshootDeringing)&&this._setBooleanOption("jpegOvershootDeringing",e.overshootDeringing);let s=c.bool(e.optimizeScans)?e.optimizeScans:e.optimiseScans;c.defined(s)&&(this._setBooleanOption("jpegOptimiseScans",s),s&&(this.options.jpegProgressive=!0));let n=c.number(e.quantizationTable)?e.quantizationTable:e.quantisationTable;if(c.defined(n))if(c.integer(n)&&c.inRange(n,0,8))this.options.jpegQuantisationTable=n;else throw c.invalidParameterError("quantisationTable","integer between 0 and 8",n)}return this._updateFormatOut("jpeg",e)}function Wu(e){if(c.object(e)){if(c.defined(e.progressive)&&this._setBooleanOption("pngProgressive",e.progressive),c.defined(e.compressionLevel))if(c.integer(e.compressionLevel)&&c.inRange(e.compressionLevel,0,9))this.options.pngCompressionLevel=e.compressionLevel;else throw c.invalidParameterError("compressionLevel","integer between 0 and 9",e.compressionLevel);c.defined(e.adaptiveFiltering)&&this._setBooleanOption("pngAdaptiveFiltering",e.adaptiveFiltering);let t=e.colours||e.colors;if(c.defined(t))if(c.integer(t)&&c.inRange(t,2,256))this.options.pngBitdepth=Ti(t);else throw c.invalidParameterError("colours","integer between 2 and 256",t);if(c.defined(e.palette)?this._setBooleanOption("pngPalette",e.palette):[e.quality,e.effort,e.colours,e.colors,e.dither].some(c.defined)&&this._setBooleanOption("pngPalette",!0),this.options.pngPalette){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,0,100))this.options.pngQuality=e.quality;else throw c.invalidParameterError("quality","integer between 0 and 100",e.quality);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,1,10))this.options.pngEffort=e.effort;else throw c.invalidParameterError("effort","integer between 1 and 10",e.effort);if(c.defined(e.dither))if(c.number(e.dither)&&c.inRange(e.dither,0,1))this.options.pngDither=e.dither;else throw c.invalidParameterError("dither","number between 0.0 and 1.0",e.dither)}}return this._updateFormatOut("png",e)}function Hu(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.webpQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.alphaQuality))if(c.integer(e.alphaQuality)&&c.inRange(e.alphaQuality,0,100))this.options.webpAlphaQuality=e.alphaQuality;else throw c.invalidParameterError("alphaQuality","integer between 0 and 100",e.alphaQuality);if(c.defined(e.lossless)&&this._setBooleanOption("webpLossless",e.lossless),c.defined(e.nearLossless)&&this._setBooleanOption("webpNearLossless",e.nearLossless),c.defined(e.smartSubsample)&&this._setBooleanOption("webpSmartSubsample",e.smartSubsample),c.defined(e.smartDeblock)&&this._setBooleanOption("webpSmartDeblock",e.smartDeblock),c.defined(e.preset))if(c.string(e.preset)&&c.inArray(e.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=e.preset;else throw c.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",e.preset);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,0,6))this.options.webpEffort=e.effort;else throw c.invalidParameterError("effort","integer between 0 and 6",e.effort);c.defined(e.minSize)&&this._setBooleanOption("webpMinSize",e.minSize),c.defined(e.mixed)&&this._setBooleanOption("webpMixed",e.mixed)}return Jr(e,this.options),this._updateFormatOut("webp",e)}function Vu(e){if(c.object(e)){c.defined(e.reuse)&&this._setBooleanOption("gifReuse",e.reuse),c.defined(e.progressive)&&this._setBooleanOption("gifProgressive",e.progressive);let t=e.colours||e.colors;if(c.defined(t))if(c.integer(t)&&c.inRange(t,2,256))this.options.gifBitdepth=Ti(t);else throw c.invalidParameterError("colours","integer between 2 and 256",t);if(c.defined(e.effort))if(c.number(e.effort)&&c.inRange(e.effort,1,10))this.options.gifEffort=e.effort;else throw c.invalidParameterError("effort","integer between 1 and 10",e.effort);if(c.defined(e.dither))if(c.number(e.dither)&&c.inRange(e.dither,0,1))this.options.gifDither=e.dither;else throw c.invalidParameterError("dither","number between 0.0 and 1.0",e.dither);if(c.defined(e.interFrameMaxError))if(c.number(e.interFrameMaxError)&&c.inRange(e.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=e.interFrameMaxError;else throw c.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",e.interFrameMaxError);if(c.defined(e.interPaletteMaxError))if(c.number(e.interPaletteMaxError)&&c.inRange(e.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=e.interPaletteMaxError;else throw c.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",e.interPaletteMaxError);if(c.defined(e.keepDuplicateFrames))if(c.bool(e.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",e.keepDuplicateFrames);else throw c.invalidParameterError("keepDuplicateFrames","boolean",e.keepDuplicateFrames)}return Jr(e,this.options),this._updateFormatOut("gif",e)}function Ju(e){if(!this.constructor.format.jp2k.output.buffer)throw Di();if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.jp2Quality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.lossless))if(c.bool(e.lossless))this.options.jp2Lossless=e.lossless;else throw c.invalidParameterError("lossless","boolean",e.lossless);if(c.defined(e.tileWidth))if(c.integer(e.tileWidth)&&c.inRange(e.tileWidth,1,32768))this.options.jp2TileWidth=e.tileWidth;else throw c.invalidParameterError("tileWidth","integer between 1 and 32768",e.tileWidth);if(c.defined(e.tileHeight))if(c.integer(e.tileHeight)&&c.inRange(e.tileHeight,1,32768))this.options.jp2TileHeight=e.tileHeight;else throw c.invalidParameterError("tileHeight","integer between 1 and 32768",e.tileHeight);if(c.defined(e.chromaSubsampling))if(c.string(e.chromaSubsampling)&&c.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=e.chromaSubsampling;else throw c.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling)}return this._updateFormatOut("jp2",e)}function Jr(e,t){if(c.object(e)&&c.defined(e.loop))if(c.integer(e.loop)&&c.inRange(e.loop,0,65535))t.loop=e.loop;else throw c.invalidParameterError("loop","integer between 0 and 65535",e.loop);if(c.object(e)&&c.defined(e.delay))if(c.integer(e.delay)&&c.inRange(e.delay,0,65535))t.delay=[e.delay];else if(Array.isArray(e.delay)&&e.delay.every(c.integer)&&e.delay.every(r=>c.inRange(r,0,65535)))t.delay=e.delay;else throw c.invalidParameterError("delay","integer or an array of integers between 0 and 65535",e.delay)}function Xu(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.tiffQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.bitdepth))if(c.integer(e.bitdepth)&&c.inArray(e.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=e.bitdepth;else throw c.invalidParameterError("bitdepth","1, 2, 4 or 8",e.bitdepth);if(c.defined(e.tile)&&this._setBooleanOption("tiffTile",e.tile),c.defined(e.tileWidth))if(c.integer(e.tileWidth)&&e.tileWidth>0)this.options.tiffTileWidth=e.tileWidth;else throw c.invalidParameterError("tileWidth","integer greater than zero",e.tileWidth);if(c.defined(e.tileHeight))if(c.integer(e.tileHeight)&&e.tileHeight>0)this.options.tiffTileHeight=e.tileHeight;else throw c.invalidParameterError("tileHeight","integer greater than zero",e.tileHeight);if(c.defined(e.miniswhite)&&this._setBooleanOption("tiffMiniswhite",e.miniswhite),c.defined(e.pyramid)&&this._setBooleanOption("tiffPyramid",e.pyramid),c.defined(e.xres))if(c.number(e.xres)&&e.xres>0)this.options.tiffXres=e.xres;else throw c.invalidParameterError("xres","number greater than zero",e.xres);if(c.defined(e.yres))if(c.number(e.yres)&&e.yres>0)this.options.tiffYres=e.yres;else throw c.invalidParameterError("yres","number greater than zero",e.yres);if(c.defined(e.compression))if(c.string(e.compression)&&c.inArray(e.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=e.compression;else throw c.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",e.compression);if(c.defined(e.bigtiff)&&this._setBooleanOption("tiffBigtiff",e.bigtiff),c.defined(e.predictor))if(c.string(e.predictor)&&c.inArray(e.predictor,["none","horizontal","float"]))this.options.tiffPredictor=e.predictor;else throw c.invalidParameterError("predictor","one of: none, horizontal, float",e.predictor);if(c.defined(e.resolutionUnit))if(c.string(e.resolutionUnit)&&c.inArray(e.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=e.resolutionUnit;else throw c.invalidParameterError("resolutionUnit","one of: inch, cm",e.resolutionUnit)}return this._updateFormatOut("tiff",e)}function Yu(e){return this.heif({...e,compression:"av1"})}function Ku(e){if(c.object(e)){if(c.string(e.compression)&&c.inArray(e.compression,["av1","hevc"]))this.options.heifCompression=e.compression;else throw c.invalidParameterError("compression","one of: av1, hevc",e.compression);if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.heifQuality=e.quality;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);if(c.defined(e.lossless))if(c.bool(e.lossless))this.options.heifLossless=e.lossless;else throw c.invalidParameterError("lossless","boolean",e.lossless);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,0,9))this.options.heifEffort=e.effort;else throw c.invalidParameterError("effort","integer between 0 and 9",e.effort);if(c.defined(e.chromaSubsampling))if(c.string(e.chromaSubsampling)&&c.inArray(e.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=e.chromaSubsampling;else throw c.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",e.chromaSubsampling);if(c.defined(e.bitdepth))if(c.integer(e.bitdepth)&&c.inArray(e.bitdepth,[8,10,12])){if(e.bitdepth!==8&&this.constructor.versions.heif)throw c.invalidParameterError("bitdepth when using prebuilt binaries",8,e.bitdepth);this.options.heifBitdepth=e.bitdepth}else throw c.invalidParameterError("bitdepth","8, 10 or 12",e.bitdepth)}else throw c.invalidParameterError("options","Object",e);return this._updateFormatOut("heif",e)}function Qu(e){if(c.object(e)){if(c.defined(e.quality))if(c.integer(e.quality)&&c.inRange(e.quality,1,100))this.options.jxlDistance=e.quality>=30?.1+(100-e.quality)*.09:53/3e3*e.quality*e.quality-23/20*e.quality+25;else throw c.invalidParameterError("quality","integer between 1 and 100",e.quality);else if(c.defined(e.distance))if(c.number(e.distance)&&c.inRange(e.distance,0,15))this.options.jxlDistance=e.distance;else throw c.invalidParameterError("distance","number between 0.0 and 15.0",e.distance);if(c.defined(e.decodingTier))if(c.integer(e.decodingTier)&&c.inRange(e.decodingTier,0,4))this.options.jxlDecodingTier=e.decodingTier;else throw c.invalidParameterError("decodingTier","integer between 0 and 4",e.decodingTier);if(c.defined(e.lossless))if(c.bool(e.lossless))this.options.jxlLossless=e.lossless;else throw c.invalidParameterError("lossless","boolean",e.lossless);if(c.defined(e.effort))if(c.integer(e.effort)&&c.inRange(e.effort,1,9))this.options.jxlEffort=e.effort;else throw c.invalidParameterError("effort","integer between 1 and 9",e.effort)}return Jr(e,this.options),this._updateFormatOut("jxl",e)}function Zu(e){if(c.object(e)&&c.defined(e.depth))if(c.string(e.depth)&&c.inArray(e.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=e.depth;else throw c.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",e.depth);return this._updateFormatOut("raw")}function ef(e){if(c.object(e)){if(c.defined(e.size))if(c.integer(e.size)&&c.inRange(e.size,1,8192))this.options.tileSize=e.size;else throw c.invalidParameterError("size","integer between 1 and 8192",e.size);if(c.defined(e.overlap))if(c.integer(e.overlap)&&c.inRange(e.overlap,0,8192)){if(e.overlap>this.options.tileSize)throw c.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,e.overlap);this.options.tileOverlap=e.overlap}else throw c.invalidParameterError("overlap","integer between 0 and 8192",e.overlap);if(c.defined(e.container))if(c.string(e.container)&&c.inArray(e.container,["fs","zip"]))this.options.tileContainer=e.container;else throw c.invalidParameterError("container","one of: fs, zip",e.container);if(c.defined(e.layout))if(c.string(e.layout)&&c.inArray(e.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=e.layout;else throw c.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",e.layout);if(c.defined(e.angle))if(c.integer(e.angle)&&!(e.angle%90))this.options.tileAngle=e.angle;else throw c.invalidParameterError("angle","positive/negative multiple of 90",e.angle);if(this._setBackgroundColourOption("tileBackground",e.background),c.defined(e.depth))if(c.string(e.depth)&&c.inArray(e.depth,["onepixel","onetile","one"]))this.options.tileDepth=e.depth;else throw c.invalidParameterError("depth","one of: onepixel, onetile, one",e.depth);if(c.defined(e.skipBlanks))if(c.integer(e.skipBlanks)&&c.inRange(e.skipBlanks,-1,65535))this.options.tileSkipBlanks=e.skipBlanks;else throw c.invalidParameterError("skipBlanks","integer between -1 and 255/65535",e.skipBlanks);else c.defined(e.layout)&&e.layout==="google"&&(this.options.tileSkipBlanks=5);let t=c.bool(e.center)?e.center:e.centre;if(c.defined(t)&&this._setBooleanOption("tileCentre",t),c.defined(e.id))if(c.string(e.id))this.options.tileId=e.id;else throw c.invalidParameterError("id","string",e.id);if(c.defined(e.basename))if(c.string(e.basename))this.options.tileBasename=e.basename;else throw c.invalidParameterError("basename","string",e.basename)}if(c.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw c.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function tf(e){if(!c.plainObject(e))throw c.invalidParameterError("options","object",e);if(c.integer(e.seconds)&&c.inRange(e.seconds,0,3600))this.options.timeoutSeconds=e.seconds;else throw c.invalidParameterError("seconds","integer between 0 and 3600",e.seconds);return this}function rf(e,t){return c.object(t)&&t.force===!1||(this.options.formatOut=e),this}function sf(e,t){if(c.bool(t))this.options[e]=t;else throw c.invalidParameterError(e,"boolean",t)}function nf(){if(!this.options.streamOut){this.options.streamOut=!0;let e=Error();this._pipeline(void 0,e)}}function of(e,t){return typeof e=="function"?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),bt.pipeline(this.options,(r,s,n)=>{r?e(c.nativeError(r,t)):e(null,s,n)})}):bt.pipeline(this.options,(r,s,n)=>{r?e(c.nativeError(r,t)):e(null,s,n)}),this):this.options.streamOut?(this._isStreamInput()?(this.once("finish",()=>{this._flattenBufferIn(),bt.pipeline(this.options,(r,s,n)=>{r?this.emit("error",c.nativeError(r,t)):(this.emit("info",n),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished&&this.emit("finish")):bt.pipeline(this.options,(r,s,n)=>{r?this.emit("error",c.nativeError(r,t)):(this.emit("info",n),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))}),this):this._isStreamInput()?new Promise((r,s)=>{this.once("finish",()=>{this._flattenBufferIn(),bt.pipeline(this.options,(n,i,o)=>{n?s(c.nativeError(n,t)):this.options.resolveWithObject?r({data:i,info:o}):r(i)})})}):new Promise((r,s)=>{bt.pipeline(this.options,(n,i,o)=>{n?s(c.nativeError(n,t)):this.options.resolveWithObject?r({data:i,info:o}):r(i)})})}Fi.exports=e=>{Object.assign(e.prototype,{toFile:Du,toBuffer:Tu,keepExif:Fu,withExif:Ou,withExifMerge:Cu,keepIccProfile:ju,withIccProfile:Lu,keepXmp:Mu,withXmp:zu,keepMetadata:Bu,withMetadata:Uu,toFormat:Gu,jpeg:qu,jp2:Ju,png:Wu,webp:Hu,tiff:Xu,avif:Yu,heif:Ku,jxl:Qu,gif:Vu,raw:Zu,tile:ef,timeout:tf,_updateFormatOut:rf,_setBooleanOption:sf,_read:nf,_pipeline:of})}});var Mi=D((kd,Li)=>{var af=Y("node:events"),sr=qt(),Se=Ie(),{runtimePlatformArch:lf}=jr(),he=_t(),Ci=lf(),Xr=he.libvipsVersion(),Ye=he.format();Ye.heif.output.alias=["avif","heic"];Ye.jpeg.output.alias=["jpe","jpg"];Ye.tiff.output.alias=["tif"];Ye.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var cf={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},vt={vips:Xr.semver};if(!Xr.isGlobal)if(Xr.isWasm)try{vt=Y("@img/sharp-wasm32/versions")}catch{}else try{vt=Y(`@img/sharp-${Ci}/versions`)}catch{try{vt=Y(`@img/sharp-libvips-${Ci}/versions`)}catch{}}vt.sharp=Or().version;vt.heif&&Ye.heif&&(Ye.heif.input.fileSuffix=[".avif"],Ye.heif.output.alias=["avif"]);function ji(e){return Se.bool(e)?e?he.cache(50,20,100):he.cache(0,0,0):Se.object(e)?he.cache(e.memory,e.files,e.items):he.cache()}ji(!0);function uf(e){return he.concurrency(Se.integer(e)?e:null)}sr.familySync()===sr.GLIBC&&!he._isUsingJemalloc()?he.concurrency(1):sr.familySync()===sr.MUSL&&he.concurrency()===1024&&he.concurrency(Y("node:os").availableParallelism());var ff=new af.EventEmitter;function hf(){return he.counters()}function df(e){return he.simd(Se.bool(e)?e:null)}function pf(e){if(Se.object(e))if(Array.isArray(e.operation)&&e.operation.every(Se.string))he.block(e.operation,!0);else throw Se.invalidParameterError("operation","Array<string>",e.operation);else throw Se.invalidParameterError("options","object",e)}function gf(e){if(Se.object(e))if(Array.isArray(e.operation)&&e.operation.every(Se.string))he.block(e.operation,!1);else throw Se.invalidParameterError("operation","Array<string>",e.operation);else throw Se.invalidParameterError("options","object",e)}Li.exports=e=>{e.cache=ji,e.concurrency=uf,e.counters=hf,e.simd=df,e.format=Ye,e.interpolators=cf,e.versions=vt,e.queue=ff,e.block=pf,e.unblock=gf}});var Bi=D((_d,zi)=>{var Ge=ei();si()(Ge);ci()(Ge);fi()(Ge);mi()(Ge);Ai()(Ge);Ni()(Ge);Oi()(Ge);Mi()(Ge);zi.exports=Ge});var mo={};Ro(mo,{createDndevPlugin:()=>eh});import X from"node:fs";import yt from"node:fs/promises";import H from"node:path";import{execSync as cr,spawn as Lf}from"node:child_process";async function ur(e){return fo?Bun.file(e):{async exists(){try{return await yt.access(e),!0}catch{return!1}},async text(){return yt.readFile(e,"utf-8")},async json(){return JSON.parse(await yt.readFile(e,"utf-8"))}}}async function Dt(e,t){return fo?Bun.write(e,t):(await yt.mkdir(H.dirname(e),{recursive:!0}),yt.writeFile(e,t))}function Qe(){return G.getInstance().getRepoRoot()}function wt(){return H.join(Qe(),".dndev")}function _(e,t,r=200){e.writeHead(r,{"Content-Type":"application/json"}),e.end(JSON.stringify(t))}function Tt(e,t=Mf){return new Promise((r,s)=>{let n="",i=0;e.on("data",o=>{if(i+=o.length,i>t){e.destroy(),s(new Error("Request body too large"));return}n+=o.toString()}),e.on("end",()=>r(n)),e.on("error",s)})}function zf(){let e=[],t=process.env.HOME||process.env.USERPROFILE||"";try{let s=process.platform==="win32"?"where node":"which node",n=cr(s,{encoding:"utf8"}).trim().split(`
3
+ `)[0];e.push(n)}catch{}let r=[process.env.NVM_DIR,H.join(t,".nvm")].filter(Boolean);for(let s of r)try{let n=H.join(s,"versions","node"),i=X.readdirSync(n).filter(o=>o.startsWith("v")).sort().reverse();for(let o of i)e.push(H.join(n,o,"bin","node"))}catch{}if(process.env.NVM_BIN&&e.push(H.join(process.env.NVM_BIN,"node")),process.platform==="win32"){e.push("C:\\Program Files\\nodejs\\node.exe");let s=process.env.APPDATA||"";if(s)try{let n=H.join(s,"nvm"),i=X.readdirSync(n).filter(o=>o.startsWith("v")).sort().reverse();for(let o of i)e.push(H.join(n,o,"node.exe"))}catch{}}else e.push("/usr/local/bin/node","/usr/bin/node");for(let s of e)try{let n=X.realpathSync(s);if(n.includes("bun")||!X.existsSync(n))continue;return s}catch{continue}return"node"}function ho(e){if(!e||typeof e!="string"||e.includes("\0"))return!1;let t=e.split(/[/\\]/).filter(Boolean);for(let r of t)if(r==="."||r===".."||r==="node_modules"||r===".git"||r.startsWith(".")&&r!==".dndev")return!1;return!0}function Bf(e){return e.includes("..")?!1:e.startsWith(".dndev/")||e.startsWith("docs/")||e.startsWith("guides/")}function po(e){let t=Qe(),r=H.resolve(t,e),s=o=>o.replace(/\\/g,"/"),n=s(t),i=s(r);return!i.startsWith(n+"/")&&i!==n?null:r}async function Gf(e,t){let s=new URL(e.url,`http://${e.headers.host}`).searchParams.get("path");if(!s)return _(t,{error:"path parameter required"},400);if(!ho(s))return _(t,{error:"Access denied"},403);let n=po(s);if(!n)return _(t,{error:"Access denied"},403);let i=await ur(n);if(!await i.exists())return _(t,{error:"File not found"},404);let o=H.extname(n).toLowerCase();if(Uf.has(o)){let a=await yt.readFile(n);return t.writeHead(200,{"Content-Type":go[o]||"application/octet-stream","Content-Length":a.byteLength}),void t.end(Buffer.from(a))}if(o===".json")try{let a=await i.json();return _(t,{path:s,content:a})}catch{return _(t,{error:"Invalid JSON"},500)}try{let a=await i.text();_(t,{path:s,content:a})}catch{_(t,{error:"Failed to read file"},500)}}function qf(e,t){let s=new URL(e.url,`http://${e.headers.host}`).searchParams.get("dir"),n=Qe(),i=[],o=new Set(["node_modules",".git","dist","build",".next",".expo"]);function a(u,f){try{let d=X.readdirSync(u,{withFileTypes:!0});for(let g of d){let m=f?`${f}/${g.name}`:g.name;g.isDirectory()&&o.has(g.name)||(g.isDirectory()?(i.push({path:m,name:g.name,isDirectory:!0}),a(H.join(u,g.name),m)):g.name.endsWith(".md")&&i.push({path:m,name:g.name,isDirectory:!1}))}}catch{}}let l=[".dndev","docs","guides"];if(s){if(s.includes("..")||s.includes("\0"))return _(t,{error:"Access denied"},403);if(!l.includes(s)&&!l.some(d=>s.startsWith(d+"/")))return _(t,{error:"Directory not allowed"},403);let u=H.resolve(n,s),f=d=>d.replace(/\\/g,"/");if(!f(u).startsWith(f(n)+"/"))return _(t,{error:"Access denied"},403);X.existsSync(u)&&(i.push({path:s,name:H.basename(s),isDirectory:!0}),a(u,s))}else{for(let u of l){let f=H.join(n,u);X.existsSync(f)&&(i.push({path:u,name:u,isDirectory:!0}),a(f,u))}try{let u=X.readdirSync(n,{withFileTypes:!0});for(let f of u)!f.isDirectory()&&f.name.endsWith(".md")&&i.push({path:f.name,name:f.name,isDirectory:!1})}catch{}}_(t,{entries:i})}async function Wf(e,t){let s=new URL(e.url,`http://${e.headers.host}`).searchParams.get("path");if(!s)return _(t,{error:"path parameter required"},400);if(!ho(s))return _(t,{error:"Access denied"},403);if(!Bf(s))return _(t,{error:"Write not allowed to this path"},403);let n=po(s);if(!n)return _(t,{error:"Access denied"},403);try{let i=await Tt(e),{content:o}=JSON.parse(i);if(o===void 0)return _(t,{error:"content field required"},400);let a=H.dirname(n);X.existsSync(a)||X.mkdirSync(a,{recursive:!0});let l=typeof o=="string"?o:JSON.stringify(o,null,2);await Dt(n,l),_(t,{ok:!0})}catch{_(t,{error:"Failed to write file"},500)}}async function Hf(e,t){try{let r=await Tt(e),{line:s,checked:n}=JSON.parse(r);if(typeof s!="number")return _(t,{error:"line number required"},400);let i=H.join(wt(),"implementation.md"),o=await ur(i);if(!await o.exists())return _(t,{error:"implementation.md not found"},404);let l=(await o.text()).split(`
4
+ `);if(s<0||s>=l.length)return _(t,{error:"Line out of range"},400);let u=l[s];l[s]=n?u.replace("- [ ]","- [x]"):u.replace("- [x]","- [ ]"),await Dt(i,l.join(`
5
+ `)),_(t,{ok:!0,line:l[s]})}catch{_(t,{error:"Failed to update progress"},500)}}async function Vf(e,t){try{let r=await Tt(e),{id:s,data:n}=JSON.parse(r);if(!s||!n)return _(t,{error:"id and data required"},400);if(!/^[\w-]+$/.test(s))return _(t,{error:"Invalid screenshot ID"},400);let i=H.join(wt(),"bugs");X.existsSync(i)||X.mkdirSync(i,{recursive:!0});let o=Buffer.from(n,"base64");await Dt(H.join(i,`${s}.png`),o),_(t,{ok:!0,path:`.dndev/bugs/${s}.png`})}catch{_(t,{error:"Failed to save screenshot"},500)}}async function Jf(e,t){try{let r=await Tt(e),{action:s,phase:n}=JSON.parse(r);if(!s||typeof n!="number")return _(t,{error:"action and phase required"},400);let i=H.join(wt(),"protocol.json"),o=await ur(i),a={currentPhase:0,phases:{}};if(await o.exists())try{a=await o.json()}catch{}s==="start"?(a.currentPhase=n,a.phases[n]||(a.phases[n]={}),a.phases[n].status="active",a.phases[n].startedAt=new Date().toISOString()):s==="complete"&&(a.phases[n]||(a.phases[n]={}),a.phases[n].status="completed",a.phases[n].completedAt=new Date().toISOString());let l=wt();X.existsSync(l)||X.mkdirSync(l,{recursive:!0}),await Dt(i,JSON.stringify(a,null,2)),_(t,{ok:!0,protocol:a})}catch{_(t,{error:"Failed to update phase"},500)}}function Xf(e,t){try{let r=Qe(),s=cr("git rev-parse --short HEAD",{cwd:r,encoding:"utf-8",timeout:5e3}).trim(),n=cr("git rev-parse --abbrev-ref HEAD",{cwd:r,encoding:"utf-8",timeout:5e3}).trim();_(t,{commit:s,branch:n})}catch{_(t,{commit:"unknown",branch:"unknown"})}}async function Yf(e,t){try{let r=await Tt(e),s=JSON.parse(r);if(!s.id||!s.type||!s.result)return _(t,{error:"id, type, and result required"},400);let n=H.join(wt(),"health.json"),i=wt();X.existsSync(i)||X.mkdirSync(i,{recursive:!0});let o={actions:[]},a=await ur(n);if(await a.exists())try{o=await a.json()}catch{}Array.isArray(o.actions)||(o.actions=[]);let l=o.actions.findIndex(u=>u.id===s.id);l>=0?o.actions[l]={...o.actions[l],...s}:o.actions.unshift(s),await Dt(n,JSON.stringify(o,null,2)),_(t,{ok:!0})}catch{_(t,{error:"Failed to append action"},500)}}function Kf(e,t){let r=H.join(Qe(),"apps");try{let n=X.readdirSync(r).filter(i=>{if(i==="dndev")return!1;let o=H.join(r,i);return X.statSync(o).isDirectory()&&X.existsSync(H.join(o,"package.json"))}).map(i=>{try{let o=JSON.parse(X.readFileSync(H.join(r,i,"package.json"),"utf-8"));return{name:i,packageName:o.name}}catch{return{name:i,packageName:i}}});_(t,{apps:n})}catch{_(t,{apps:[]})}}function Qf(e){if(ts)return;let t=e.config.root,r=H.join(t,"terminal-sidecar.cjs");if(!X.existsSync(r))return;try{let o=cr(`fuser ${uo}/tcp 2>/dev/null`,{encoding:"utf8"}).trim();o&&process.kill(Number(o),"SIGKILL")}catch{}ts=!0;let s=Qe(),n=zf(),i=Lf(n,[r],{cwd:s,stdio:["ignore","inherit","inherit","ipc"],env:{...process.env,TERMINAL_PORT:String(uo),TERMINAL_CWD:s}});i.on("message",o=>{o.type}),i.on("exit",o=>{ts=!1}),process.on("exit",()=>{i.kill()})}function Zf(e){let t=Qe(),r=[".dndev","docs","guides"];for(let s of r){let n=H.join(t,s);if(!X.existsSync(n))continue;let i=X.watch(n,{recursive:!0},(o,a)=>{if(!a||a==="dashboard.json")return;let l=`${s}/${a}`,u=`change:${l}`;rs.has(u)||(rs.set(u,!0),setTimeout(()=>rs.delete(u),300),e.hot.send("dndev:file-changed",{path:l,timestamp:Date.now()}))});e.httpServer?.on("close",()=>i.close())}}function eh(e={}){return{name:"dndev",configureServer(t){let r=Qe();e.debug,t.middlewares.use((s,n,i)=>{let o=s.url;if(!o?.startsWith(co))return i();let l=new URL(o,`http://${s.headers.host}`).pathname.slice(co.length),u=s.method?.toUpperCase();if(u==="GET")return l==="/file"?void Gf(s,n):l==="/tree"?void qf(s,n):l==="/git/head"?void Xf(s,n):l==="/apps"?void Kf(s,n):_(n,{error:"Not found"},404);if(u==="POST")return l==="/file"?void Wf(s,n):l==="/progress/toggle"?void Hf(s,n):l==="/bugs/screenshot"?void Vf(s,n):l==="/phase"?void Jf(s,n):l==="/actions/append"?void Yf(s,n):_(n,{error:"Not found"},404);_(n,{error:"Method not allowed"},405)}),Qf(t),Zf(t)}}}var co,fo,Mf,go,Uf,uo,ts,rs,bo=pr(()=>{"use strict";me();co="/api/dndev",fo=typeof globalThis.Bun<"u";Mf=5*1024*1024;go={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".svg":"image/svg+xml"},Uf=new Set(Object.keys(go));uo=24681,ts=!1;rs=new Map});import zo from"@rollup/plugin-strip";import{visualizer as Bo}from"rollup-plugin-visualizer";var gr=["/react/","/react-dom/","/scheduler/","/react-router","/@radix-ui/","/react-day-picker/","/react-hook-form/","/react-i18next/","/clsx/","/class-variance-authority/"],Ao={valibot:["/valibot/"],firebase:["/firebase/","/@firebase/"],lucide:["/lucide-react/","/lucide/"],i18n:["/i18next/","/i18next-browser-languagedetector/","/i18next-http-backend/","/@donotdev/i18n/"],zustand:["/zustand/"],"tanstack-query":["/@tanstack/react-query/","/@tanstack/query-core/"]};function _o(e){let t=e.match(/(?:^|\0)virtual:([^?]+)/);if(t)return t[1]}function ns(e){let t=e.replace(/\\/g,"/");if(t.includes("/node_modules/"))return t.split("?")[0]}function is(e,t=gr){return t.some(r=>e.includes(r))}function No(e){for(let[t,r]of Object.entries(Ao))if(r.some(s=>e.includes(s)))return t}function Io(e){let t=_o(e);if(t)return t==="i18n-mapping"?"virtual-i18n-mapping":"virtual-modules";let r=ns(e);if(!r)return;if(is(r))return"react-core";let s=No(r);if(s)return s}function Do(e=[]){let t=e.filter(s=>!gr.includes(s)),r=[...gr,...t];return function(s){let n=ns(s);if(n&&is(n,r))return"react-core"}}var ss={development:{manualChunks:void 0},production:{manualChunks:Io}};function os(e,t={}){let r=ss[e]||ss.production,s=t.reactCore||[];return s.length>0?{manualChunks:Do(s)}:r}me();var pe;try{pe=await import("@clack/prompts")}catch{pe={log:{message:e=>{},info:e=>{},warn:e=>{},error:e=>{},success:e=>{},step:e=>{}}}}var $e={reset:"\x1B[0m",green:"\x1B[32m",brightGreen:"\x1B[92m",red:"\x1B[31m",brightRed:"\x1B[91m",yellow:"\x1B[33m",brightYellow:"\x1B[93m",blue:"\x1B[34m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",gray:"\x1B[90m",white:"\x1B[37m"};function Mo(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function _e(e,t){return Mo()?`${t}${e}${$e.reset}`:e}function B(e,t,r,s={}){let{logDir:n=".dndev-logs",fileLogging:i=!1}=s,o=G.getInstance(),a=null;if(i){let f=o.resolveAppPath(n);o.pathExists(f)||o.mkdir(f),a=o.resolveAppPath(`${n}/${e.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let d=`=== ${e} Log Started at ${new Date().toISOString()} ===
6
+ `;o.writeSync(a,d)}let l=(f,d,g)=>{if(a){let m=new Date().toISOString(),P=g.length>0?" "+g.map(W=>typeof W=="object"?JSON.stringify(W,null,2):String(W)).join(" "):"",U=`${m} [${f}] ${d}${P}
7
+ `;o.appendFile(a,U)}},u=(f,d)=>{if(d.length===0)return f;let g=d.map(m=>typeof m=="object"?JSON.stringify(m,null,2):String(m)).join(" ");return`${f} ${g}`};return{debug:(f,...d)=>{t&&(i?l("DEBUG",f,d):pe.log.message(_e(u(f,d),$e.gray)))},verbose:(f,...d)=>{r&&(i?l("VERBOSE",f,d):pe.log.message(u(f,d)))},info:(f,...d)=>{i?l("INFO",f,d):pe.log.info(_e(u(f,d),$e.brightCyan))},warn:(f,...d)=>{t&&i?l("WARN",f,d):pe.log.warn(_e(u(f,d),$e.brightYellow))},error:(f,...d)=>{t&&i?l("ERROR",f,d):pe.log.error(_e(u(f,d),$e.brightRed))},success:(f,...d)=>{t&&i?l("SUCCESS",f,d):pe.log.success(_e(u(f,d),$e.brightGreen))},when:(f,d="debug")=>(g,...m)=>{if(f){let P=u(g,m);switch(d){case"verbose":r&&(pe.log.message(P),l("VERBOSE",g,m));break;case"info":pe.log.info(_e(P,$e.brightCyan)),l("INFO",g,m);break;case"warn":pe.log.warn(_e(P,$e.brightYellow)),l("WARN",g,m);break;case"error":pe.log.error(_e(P,$e.brightRed)),l("ERROR",g,m);break;case"success":pe.log.success(_e(P,$e.brightGreen)),l("SUCCESS",g,m);break;default:t&&(pe.log.message(_e(P,$e.gray)),l("DEBUG",g,m))}}},getLogFilePath:()=>a}}me();function ps(e={}){let{mode:t="development",chunkingOptions:r={},debug:s,verbose:n=!0,isDev:i,isDebug:o,shouldAnalyze:a,build:l={}}=e,u=B("build",s,n),f=os(t,r);return u.debug("\u{1F41B} DEBUG MODE ENABLED:"),u.debug(" - Minification: DISABLED"),u.debug(" - Sourcemaps: ENABLED"),u.debug(" - Console logs: PRESERVED"),u.debug(" - Debugger statements: PRESERVED"),a&&(u.info("\u{1F4CA} Bundle analysis enabled"),u.info(` Visual treemap will open after build (stats.html)
8
+ `)),{outDir:"dist",sourcemap:i||o,cacheDir:"node_modules/.vite",target:"baseline-widely-available",minify:o?!1:"esbuild",reportCompressedSize:!1,chunkSizeWarningLimit:2048,assetsInlineLimit:0,esbuild:{format:"esm",drop:o?[]:["console","debugger"],legalComments:"none"},cssMinify:o?!1:"esbuild",cssCodeSplit:!0,rollupOptions:{external:Uo(),output:{format:"es",entryFileNames:"assets/[name].[hash].js",chunkFileNames:"assets/[name].[hash].js",assetFileNames:"assets/[name].[hash][extname]",...f.manualChunks&&{manualChunks:f.manualChunks},compact:!0},onwarn(g,m){g.code!=="MODULE_LEVEL_DIRECTIVE"&&m(g)},plugins:[...o?[]:[zo({include:["**/*.js","**/*.ts","**/*.tsx","**/*.jsx"],functions:["console.*","debugger"],labels:["debug"]})],...a?[(()=>{let g=G.getInstance(),m=g.getAppRoot(),P="dist",U=g.resolveAppPath(`${P}/stats.html`),W=()=>{try{let C=g.resolveAppPath(P);g.pathExists(C)||g.mkdir(C)}catch{}},N=Bo({filename:U,open:!0,gzipSize:!0,brotliSize:!0,template:"treemap",sourcemap:i||o,projectRoot:m});if(N.buildStart){let C=N.buildStart.bind(N);N.buildStart=function(...R){W();let k=C.apply(this,R);return k&&typeof k.then=="function"?k.catch(E=>{}):k}}else N.buildStart=function(){W()};let O=["generateBundle","writeBundle","closeBundle"];for(let C of O)if(N[C]){let R=N[C];N[C]=function(...k){try{W();let E=R.apply(this,k);return E&&typeof E.then=="function"?E.catch(j=>{let M=j?.message||j?.toString()||String(j)||"Unknown error";u.warn(`Bundle visualizer warning in ${C}: ${M}`),C==="closeBundle"&&u.warn(`You can manually open ${U} to view the bundle analysis`)}):E}catch(E){let j=E?.message||E?.toString()||String(E)||"Unknown error";buildLogger.warn(`Bundle visualizer warning in ${C}: ${j}`),C==="closeBundle"&&buildLogger.warn(` You can manually open ${U} to view the bundle analysis`)}}}return N})()]:[]]}}}function Uo(e){return e?["firebase-admin","gcp-metadata","google-logging-utils","@google-cloud/firestore",/\.node$/,"esbuild",/@esbuild\/.*/]:["gcp-metadata","google-logging-utils","payload","file-type","firebase-admin","firebase-admin/app","firebase-admin/auth","firebase-admin/firestore","firebase-admin/functions","firebase-admin/credential","@google-cloud/firestore","google-auth-library","google-gax","googleapis-common"]}function Go(){let e=!1,t=G.getInstance();if((t.pathExists("/.dockerenv")||t.pathExists("/run/.containerenv"))&&(e=!0),!e&&(process.env.DOCKER_CONTAINER==="true"||process.env.IS_DOCKER==="true"||process.env.DOCKER_BUILDKIT==="1"||process.env.CI==="true"&&process.env.DOCKER==="true")&&(e=!0),!e&&process.env.DOCKER_HOST&&process.env.DOCKER_HOST.includes("docker")&&(e=!0),!e&&process.platform==="linux"&&t.pathExists("/proc/self/cgroup"))try{let n=t.readSync("/proc/self/cgroup");n&&(n.includes("docker")||n.includes("containerd"))&&(e=!0)}catch{}let r=!1;if((process.env.WSL_DISTRO_NAME||process.env.WSLENV)&&(r=!0),!r&&process.platform==="linux"&&t.pathExists("/proc/version"))try{let n=(t.readSync("/proc/version")||"").toLowerCase();r=n.includes("microsoft")||n.includes("wsl")}catch{}if(!r&&process.platform==="linux"&&t.pathExists("/proc/sys/kernel/osrelease"))try{let n=(t.readSync("/proc/sys/kernel/osrelease")||"").toLowerCase()||"";(n.includes("microsoft")||n.includes("wsl"))&&(r=!0)}catch{}if(!r&&process.platform==="win32"){let n=process.cwd();n&&(n.includes("\\wsl$")||n.includes("\\wsl.localhost"))&&(r=!0)}let s=typeof process.versions?.bun=="string";return{isDocker:e,isWSL2:r,isBun:s}}function qo(e,t){if(e!==void 0)return e;let{isDocker:r,isWSL2:s,isBun:n}=Go();if(r||s||n){let i=r?"Docker":s?"WSL2":"Bun";return t.info(`Detected ${i} environment - enabling polling mode for file watching`),!0}}function gs(e,t={},r){let s=G.getInstance(),n=s.getRepoRoot(),{watch:i,hmr:o,host:a,...l}=t||{},u=o||{},f=a===!0?"localhost":a||"localhost",d={...u.port&&{port:u.port},...u.clientPort&&{clientPort:u.clientPort},host:u.host??f,...u.protocol&&{protocol:u.protocol},overlay:u.overlay??!0,timeout:u.timeout??5e3},g=a!==void 0?a:!0,m=l.https===!0;return{port:e,host:g,open:t.open!==void 0?t.open:!0,https:m,fs:{allow:[n,s.resolveRepoPath("packages"),s.resolveRepoPath("node_modules")],strict:!1},watch:{usePolling:qo(t?.watch?.usePolling,r),interval:t?.watch?.interval??2e3,...t?.watch||{}},hmr:{...d,...u},headers:{"Cross-Origin-Opener-Policy":"same-origin-allow-popups","Cross-Origin-Embedder-Policy":"unsafe-none"},middlewareMode:!1,...l}}function ms(e={}){let t=e.https===!0;return{...e,https:t}}re();var xe={CONCATENATE_DEDUPE:"CONCATENATE_DEDUPE",SHALLOW_MERGE:"SHALLOW_MERGE",DEEP_MERGE:"DEEP_MERGE",REPLACE:"REPLACE"};function He(e,t,r,s={}){let{protectedKeys:n=[],onConflict:i}=s;if(t==null)return e;switch(r){case xe.CONCATENATE_DEDUPE:{if(!Array.isArray(e)||!Array.isArray(t))return t;let o=[...e,...t];return[...new Set(o)]}case xe.SHALLOW_MERGE:return typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)||Array.isArray(t)?t:{...e,...t};case xe.DEEP_MERGE:{if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)||Array.isArray(t))return t;let o={...e};for(let a in t){if(n.includes(a)){i&&i(a,e[a],t[a]);continue}typeof o[a]=="object"&&typeof t[a]=="object"&&o[a]!==null&&t[a]!==null&&!Array.isArray(o[a])&&!Array.isArray(t[a])?o[a]=He(o[a],t[a],xe.DEEP_MERGE,{protectedKeys:n,onConflict:i}):o[a]=t[a]}return o}case xe.REPLACE:default:return t}}function bs(e,t,r=[],s){let n=[...e,...t||[]],i=[...new Set(n)];return[...new Set([...i,...r])]}var zt={base:"/",mode:process.env.NODE_ENV==="production"?"production":"development",debug:!1,verbose:process.env.CI!=="true",server:{port:3e3,strictPort:!0,host:!0,open:!0,cors:!0,https:!0,hmr:{overlay:!0,timeout:5e3,usePolling:void 0,interval:2e3},watch:{usePolling:void 0,interval:2e3}},build:{sourcemap:!0,target:"es2020",minify:"esbuild",cssMinify:"esbuild",analyze:!0},preview:{port:4173,strictPort:!0,host:!0,open:!1,cors:!0,https:!0},routes:{hmr:!0},themes:{},i18n:{},assets:{},features:{},pwa:{enabled:!1},seo:{disabled:!1,generateRobotsTxt:!0,generateSitemap:!0,crawlDelay:1},serverShim:{enabled:!0},chunking:{reactCore:[]},discovery:{verbose:!0,cacheTimeout:6e4,fileLogging:!1,logDir:".dndev-logs"},pluginFactory:{verbose:!0,disableHmr:!1,hmrSmartDetection:!0,hmrDebounceMs:500,hmrCacheTimeout:3e4},resolve:{alias:{"@":"/src"},preserveSymlinks:!1},define:{__DEV__:JSON.stringify(process.env.NODE_ENV==="development"),__PROD__:JSON.stringify(process.env.NODE_ENV==="production")},optimizeDeps:{include:[...tt.mandatoryIncludes],exclude:[...tt.buildTools,...Object.values(V)],esbuildOptions:{format:"esm",target:"es2020",platform:"browser",define:{"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"development")},external:["next","next/*"]}},plugins:[],css:{},envDir:void 0};function vs(e={},t={}){let{onConflict:r}=t,s={...zt},n=[],i=(o,a,l,u)=>{n.push({key:o,frameworkValue:a,userValue:l,reason:u}),r&&r(o,a,l,u)};return Object.keys(e).forEach(o=>{let a=e[o],l=s[o];if(o==="optimizeDeps"&&typeof a=="object"&&a!==null){let u=l?.include||[],f=l?.exclude||[],d=a.include||[],g=a.exclude||[],m=u.filter(O=>!O.startsWith("@donotdev/")),P=g.filter(O=>m.includes(O));if(P.length>0)for(let O of P)i("optimizeDeps.exclude",O,"excluded",`Framework requires ${O} to be included. It will be included despite your exclusion.`);let U=bs(u,d,m),W=He(f,g,xe.CONCATENATE_DEDUPE),N=He(l?.esbuildOptions||{},a.esbuildOptions||{},xe.DEEP_MERGE,{protectedKeys:["external"],onConflict:O=>i(`optimizeDeps.esbuildOptions.${O}`,l?.esbuildOptions?.[O],a.esbuildOptions?.[O],`Framework requires ${O} to remain as configured.`)});s[o]={...l,include:U,exclude:W,esbuildOptions:N,...Object.fromEntries(Object.entries(a).filter(([O])=>!["include","exclude","esbuildOptions"].includes(O)))};return}if(o==="css"&&typeof a=="object"&&a!==null){s[o]=He(l||{},a,xe.DEEP_MERGE,{protectedKeys:["postcss"],onConflict:()=>i("css.postcss","framework PostCSS config",a.postcss,"Framework PostCSS config is required and cannot be overridden. Your postcss config is ignored.")});return}if(o==="define"&&typeof a=="object"&&a!==null){s[o]=He(l||{},a,xe.DEEP_MERGE,{protectedKeys:["__DEV__","__PROD__"],onConflict:u=>i(`define.${u}`,l?.[u],a[u],`Framework requires ${u} to remain as configured.`)});return}if(Array.isArray(a)){Array.isArray(l)?s[o]=He(l,a,xe.CONCATENATE_DEDUPE):s[o]=a;return}if(typeof a=="object"&&a!==null&&typeof l=="object"&&l!==null&&!Array.isArray(l)){s[o]=He(l,a,xe.SHALLOW_MERGE);return}s[o]=a}),s}function ys(e){let{server:t={},preview:r={},mode:s,build:n={},resolve:i={},routes:o={},themes:a={},i18n:l={},assets:u={},features:f={},seo:d={},pwa:g={},serverShim:m={},chunking:P={},discovery:U={},pluginFactory:W={},debug:N,verbose:O,base:C,define:R={},optimizeDeps:k={},plugins:E=[],css:j={},envDir:M,...ve}=e,I=s!=="production",A=N||I,ie=s==="production"&&(n.analyze??zt.build.analyze);return{mode:s,debug:N,verbose:O,isDev:I,isDebug:A,shouldAnalyze:ie,serverOptions:t,previewOptions:r,buildOverrides:n,resolveOptions:i,routeOptions:o,themeOptions:a,i18nOptions:l,assetOptions:u,featureOptions:f,seoOptions:d,pwaOptions:g,serverShimOptions:m,chunkingOptions:P,discoveryOptions:U,pluginFactoryOptions:W,base:C,defineOptions:R,optimizeDepsOptions:k,pluginsOptions:E,cssOptions:j,envDir:M,restOptions:ve}}me();import{resolve as Wo}from"node:path";import Ho from"autoprefixer";import Vo from"postcss-import";import Jo from"postcss-nesting";function ws({postcssImport:e,postcssNesting:t,autoprefixer:r,resolve:s}){return{plugins:[s?e({resolve:s}):e,t,r({overrideBrowserslist:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"],grid:"autoplace"})]}}function Es(e={}){if(e.postcss)return e.postcss;let t=G.getInstance();return ws({postcssImport:Vo,postcssNesting:Jo,autoprefixer:Ho,resolve:(s,n)=>{let i=t.resolvePackage(s,n);if(i)return i;if(s.startsWith("@donotdev/")){let o=s.split("/")[0]+"/"+s.split("/")[1],a=s.split("/").slice(2).join("/"),l=t.resolveFrameworkPackage(o,n);if(l&&a){let u=t.resolvePath(a,l);if(t.pathExists(u))return u}}return Wo(n,s)}})}import Ff from"@vitejs/plugin-basic-ssl";import Of from"@vitejs/plugin-react";import Cf from"vite-tsconfig-paths";var ce=class{static generateVirtualModule(t,r,s=!1,n=void 0,i=void 0){return r.isEmpty(t)?r.generateEmpty(t,s,n,i):r.generateModule(t,s,i)}static generateInspection(t,r,s,n){return r.generateInspection.length>=3?r.generateInspection(t,s,n):r.generateInspection(t,s)}static wrapVirtualModule(t,r){return`// Virtual module: ${t}
6
9
  // Generated by @donotdev/config discovery
7
10
  // Version: 1.0.0
8
11
 
@@ -38,13 +41,13 @@ var Xi=Object.create;var Br=Object.defineProperty;var Yi=Object.getOwnPropertyDe
38
41
  `);return`// Helper functions for ${t}
39
42
  // Generated by @donotdev/config
40
43
 
41
- ${s}`}static validateTemplates(t){return["isEmpty","generateModule","generateEmpty","generateInspection"].every(s=>t[s]&&typeof t[s]=="function")}static createTemplateConfig(t,r){let{isEmpty:s=()=>!1,generateModule:n=()=>"",generateEmpty:i=()=>"",generateInspection:o=()=>"",generateManifest:a=()=>({}),logConfig:l=()=>{},logStats:f=()=>{},logManifest:u=()=>{}}=r;return{isEmpty:s,generateModule:n,generateEmpty:i,generateInspection:o,generateManifest:a,logConfig:l,logStats:f,logManifest:u,pluginName:t,version:"1.0.0",createdAt:new Date().toISOString()}}static getEmptyResultWithError(t,r){let s=r?.message||r||"Unknown error";if(t&&typeof t._getEmptyResult=="function")try{let n=t._getEmptyResult();return n.errors&&Array.isArray(n.errors)?n.errors.push(s):n.errors===void 0&&(n.errors=[s]),n.source==="empty"&&(n.source="error"),n}catch{return{errors:[s],source:"error"}}return{errors:[s],source:"error"}}};function Se(e){let{pluginName:t,icon:r,virtualModuleId:s,DiscoveryClass:n,discoveryMethod:i,filePatterns:o,templates:a,defaultInspectionPath:l,manifestFileName:f,createDiscovery:u,discoveryOptions:g={},configKey:p}=e;return function(S={}){let{debug:z,verbose:q,virtualModuleId:$=s,inspectionFilePath:C=l,hmrDebounceMs:k,hmrCacheTimeout:D,hmrSmartDetection:N,disableHmr:E,...B}=S;if(!ie.validateTemplates(a))throw new Error(`Invalid templates for plugin ${t}`);let j={..._t.discovery,...g,debug:z,verbose:q,...B},fe=p||(()=>{let b=t.match(/dndev-vite-(\w+)-discovery/);return b?b[1]:null})(),I=M(t,z,q,{fileLogging:j.fileLogging,logDir:j.logDir}),A=G.getInstance(),te=()=>{let b=A.getAppRoot(),P=A.getRepoRoot();return b&&b!==P},gt=Date.now(),de=u?u(A,j):new n(A,j),xe="\0"+$,F="",L=!1,O=null,Y=0,He=!1,re=null,Le=!1,De=null,tt=!1;typeof global<"u"&&(global.__DNDEV_CLEAR_CACHE__=()=>(de.clearCache(),re=null,I.info("Discovery cache cleared manually"),"Cache cleared"));function Qt(b){let X=ie.generateVirtualModule(b,a,z,j,fe).replace(/mode:\s*['"]development['"]/g,"mode: typeof process !== 'undefined' && process.env.NODE_ENV === 'production' ? 'production' : 'development'");return!E&&L&&(X+=`
44
+ ${s}`}static validateTemplates(t){return["isEmpty","generateModule","generateEmpty","generateInspection"].every(s=>t[s]&&typeof t[s]=="function")}static createTemplateConfig(t,r){let{isEmpty:s=()=>!1,generateModule:n=()=>"",generateEmpty:i=()=>"",generateInspection:o=()=>"",generateManifest:a=()=>({}),logConfig:l=()=>{},logStats:u=()=>{},logManifest:f=()=>{}}=r;return{isEmpty:s,generateModule:n,generateEmpty:i,generateInspection:o,generateManifest:a,logConfig:l,logStats:u,logManifest:f,pluginName:t,version:"1.0.0",createdAt:new Date().toISOString()}}static getEmptyResultWithError(t,r){let s=r?.message||r||"Unknown error";if(t&&typeof t._getEmptyResult=="function")try{let n=t._getEmptyResult();return n.errors&&Array.isArray(n.errors)?n.errors.push(s):n.errors===void 0&&(n.errors=[s]),n.source==="empty"&&(n.source="error"),n}catch{return{errors:[s],source:"error"}}return{errors:[s],source:"error"}}};me();function Ne(e){let{pluginName:t,icon:r,virtualModuleId:s,DiscoveryClass:n,discoveryMethod:i,filePatterns:o,templates:a,defaultInspectionPath:l,manifestFileName:u,createDiscovery:f,discoveryOptions:d={},configKey:g}=e;return function(P={}){let{debug:U,verbose:W,virtualModuleId:N=s,inspectionFilePath:O=l,hmrDebounceMs:C,hmrCacheTimeout:R,hmrSmartDetection:k,disableHmr:E,...j}=P;if(!ce.validateTemplates(a))throw new Error(`Invalid templates for plugin ${t}`);let M={...zt.discovery,...d,debug:U,verbose:W,...j},ve=g||(()=>{let b=t.match(/dndev-vite-(\w+)-discovery/);return b?b[1]:null})(),I=B(t,U,W,{fileLogging:M.fileLogging,logDir:M.logDir}),A=G.getInstance(),ie=()=>{let b=A.getAppRoot(),S=A.getRepoRoot();return b&&b!==S},Et=Date.now(),ye=f?f(A,M):new n(A,M),ke="\0"+N,F="",z=!1,L=null,Z=0,Ze=!1,oe=null,Le=!1,qe=null,et=!1;typeof global<"u"&&(global.__DNDEV_CLEAR_CACHE__=()=>(ye.clearCache(),oe=null,I.info("Discovery cache cleared manually"),"Cache cleared"));function fr(b){let Q=ce.generateVirtualModule(b,a,U,M,ve).replace(/mode:\s*['"]development['"]/g,"mode: typeof process !== 'undefined' && process.env.NODE_ENV === 'production' ? 'production' : 'development'");return!E&&z&&(Q+=`
42
45
 
43
46
  // HMR boundary for ${t}
44
47
  if (import.meta.hot) {
45
48
  import.meta.hot.accept();
46
49
  }
47
- `),X}function Zt(b){return ie.generateInspection(b,a,F,j)}async function pt(){if(F)try{let b=await de[i](),P=Zt(b),X=A.resolveAppPath(C);await A.write(X,P),I.debug(`Generated inspection file: ${A.getRelativePath(X)}`)}catch(b){I.error(`${t} failed to write inspection file (${C}): ${b.message}`),I.error(`Stack: ${b.stack||"No stack trace available"}`)}}function Rt(b){let P=b.replace(/\\/g,"/");if(E||P.includes("/node_modules/")||P.includes("/.git/")||P.includes("/dist/")||P.includes("/build/")||P.includes("/coverage/")||P.includes("/.vite/")||P.includes("/.turbo/")||P.endsWith(".d.ts")||P.endsWith(".tsbuildinfo")||P.endsWith(".map")||P.endsWith(".css.map")||P.endsWith(".generated.log")||/\.generated\.[a-z]+$/.test(P))return!1;let X=A.getRelativePath(P);if(X.startsWith("packages/"))return!1;let Je=X.startsWith("src/")&&/\.(ts|tsx)$/.test(X);return Je?Array.isArray(o)&&o.length>0?o.some(ye=>typeof ye=="function"?ye(P):typeof ye=="string"?ye.startsWith("**/")?P.endsWith(ye.slice(3)):P.endsWith(ye):!1):Je:!1}function er(b){if(E)return I.debug("Virtual modules are static - HMR disabled"),[];let P=Date.now();return Le?(I.debug("HMR already in progress, skipping update"),[]):P-Y<k?(He||(He=!0,O=setTimeout(()=>{He=!1,Y=Date.now(),Ve(b)},k)),[]):(Y=P,Ve(b))}function Ve(b){let P=Date.now();if(De===b.file&&P-Y<100)return I.debug(`Same file processed too recently: ${b.file}`),[];if(!Rt(b.file))return I.debug(`Skipping irrelevant file change: ${b.file}`),[];I.debug(`Relevant file changed: ${b.file}`),Le=!0,De=b.file;try{let X=Date.now()-(re?.timestamp||0);if(X<D&&re){I.debug(`Using cached discovery data (age: ${X}ms)`);let ye=b.server.moduleGraph.getModuleById(xe);return ye&&b.server.reloadModule(ye),[]}de.clearCache();let Je=b.server.moduleGraph.getModuleById(xe);return Je&&b.server.reloadModule(Je),O&&clearTimeout(O),O=setTimeout(()=>{pt()},500),[]}finally{Le=!1,setTimeout(()=>{De===b.file&&(De=null)},200)}}return{name:t,enforce:"pre",configResolved(b){F=b.root,L=b.command==="serve",z&&I.debug(`${r} ${t} initialized`),L&&I.debug("\u{1F4A1} Dev mode: Press 'r' in terminal to restart, or use global.__DNDEV_CLEAR_CACHE__() in console"),a.logConfig&&a.logConfig(j)},config(b){return b.optimizeDeps||(b.optimizeDeps={}),b.optimizeDeps.exclude||(b.optimizeDeps.exclude=[]),b.optimizeDeps.exclude.includes($)||b.optimizeDeps.exclude.push($),b},resolveId(b){return b===$?(I.debug(`Resolving virtual module: ${b}`),{id:xe,moduleSideEffects:!0}):null},async load(b){if(b!==xe)return null;if(I.debug(`Loading virtual module: ${b}`),!te()){I.warn("\u26A0\uFE0F load() called before appRoot is set - waiting for config resolution");let P=0;for(;!te()&&P<100;)await new Promise(X=>setTimeout(X,10)),P++;if(!te())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let P;return re?(I.debug("Using cached discovery data for virtual module"),P=re):(I.warn(`\u26A0\uFE0F No cached discovery data found for ${t} - running discovery in load() hook. This may indicate buildStart() hook did not run or failed. Performance may be impacted.`),P=await de[i](),re=P,I.debug("Discovery completed for virtual module")),Qt(P)}catch(P){return I.error(`${t} virtual module (${xe}) failed to load: ${P.message}`),I.error(`Stack: ${P.stack||"No stack trace available"}`),a.generateEmpty({},z,j,fe)}},async buildStart(){if(tt=!1,!te()){I.warn("\u26A0\uFE0F buildStart() called before appRoot is set - waiting for config resolution");let b=0;for(;!te()&&b<100;)await new Promise(P=>setTimeout(P,10)),b++;if(!te())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let b=await de[i](!re);re=b,await pt(),a.logStats&&a.logStats(b,r,I)}catch(b){I.error(`${t} discovery failed during file scanning: ${b.message}`),I.error(`Stack: ${b.stack||"No stack trace available"}`),re=ie.getEmptyResultWithError(de,b)}finally{tt=!0}},configureServer(){tt=!0},handleHotUpdate(b){return E?[]:tt?er(b):(I.debug("HMR disabled - discovery not complete yet"),[])},generateBundle(){if(!re){I.warn("No cached discovery data for manifest generation - skipping");return}try{let b=ie.generateManifest(re,a.generateManifest);this.emitFile({type:"asset",fileName:f,source:JSON.stringify(b,null,2)}),q&&a.logManifest&&a.logManifest(re,t)}catch(b){I.error(`${t} manifest generation failed: ${b.message}`),I.error(`Stack: ${b.stack||"No stack trace available"}`)}},transform(b,P){return P===xe?{code:b,map:null}:null}}}}var Yf={generateGlobals:ie.generateGlobals,generateExports:ie.generateExports,generateDefaultExport:ie.generateDefaultExport,wrapVirtualModule:ie.wrapVirtualModule,generateInspectionHeader:ie.generateInspectionHeader,validateTemplates:ie.validateTemplates,createTemplateConfig:ie.createTemplateConfig};var be=class e{constructor(t,r={}){if(this.constructor===e)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=t,this.options={...r},process.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=M(this._getDiscoveryType(),this.options.debug,this.options.verbose,{fileLogging:this.options.fileLogging,logDir:this.options.logDir}),this.cache=null,this._lastDiscoveryTime=0}async discover(t=!1){if(!t&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let r=Date.now();try{let s=await this._getPatterns();this.options.verbose&&s&&(typeof s=="object"&&s.pattern?this.logger.verbose(`Pattern: ${s.pattern}`):typeof s=="string"&&this.logger.verbose(`Pattern: ${s}`),s.dirs&&this.logger.verbose(`Search directories: ${s.dirs.slice(0,3).join(", ")}${s.dirs.length>3?` (${s.dirs.length} total)`:""}`));let n=await this._scanFiles(s),i=await this._processFiles(n);this.cache={...i,timestamp:Date.now()};let o=Date.now()-r;return this.logger.debug(`Discovery completed in ${o}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){return this.logger.error(`${this._getDiscoveryType()} discovery failed during file scanning: ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),this._getEmptyResult()}}clearCache(){this.cache=null,this._lastDiscoveryTime=0,this.logger.debug("Cache cleared")}getCachedResults(){return this.cache}_getDiscoveryType(){throw new Error("_getDiscoveryType must be implemented by subclass")}_getPatterns(){throw new Error("_getPatterns must be implemented by subclass")}_getPatternType(){throw new Error("_getPatternType must be implemented by subclass")}async _processFiles(t){throw new Error("_processFiles must be implemented by subclass")}_getEmptyResult(){throw new Error("_getEmptyResult must be implemented by subclass")}_getDiscoverySummary(){throw new Error("_getDiscoverySummary must be implemented by subclass")}async _scanFiles(t){let r=this._getPatternType();return await this.pathResolver.resolveFiles(t,r)}_extractFileNameInfo(t){let r=t.split("/"),s=r[r.length-1],n=s.split(".")[0],i=s.split(".").pop();return{fileName:s,baseName:n,extension:i,directory:r.slice(0,-1).join("/")}}async _processSingleFile(t,r){try{let s=this.pathResolver.getFileInfo(t);return s?await r(s):(this.logger.debug(`Could not get file info: ${t}`),null)}catch(s){return this.logger.debug(`Error processing file ${t}: ${s.message}`),null}}async _batchProcessFiles(t,r){return(await Promise.all(t.map(n=>this._processSingleFile(n,r)))).filter(n=>n!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};var Vt=class extends be{constructor(t,r={}){super(t,{assets:pe.assets.fallback,assetPatterns:pe.assets.patterns,frameworkPackage:sr.package,assetsPath:sr.assetsPath,modernFormats:pe.assets.modern,...r}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(t){let r=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(r),n=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(n)||this.logger.warn("logo.svg not found in public/. Add your logo.svg to generate PWA assets, or copy from node_modules/@donotdev/ui/assets/logo.svg");let o=[],a=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(a)&&this.options.generateAssets!==!1&&(o=(await this._generateMissingAssets(r))?.generated||[]);let{consumerFiles:l}=t,f=await this._processAssetFiles(l),u=this._buildAssetManifest(f),g=await this._readLogoSvgContent("/logo.svg",r);return{assets:f,manifest:{...u,logoSvgContent:g},copiedAssets:s,generatedAssets:o,pwaIcons:this._extractPWAIcons(f)}}_extractPWAIcons(t){let r=[/icon-(\d+)x(\d+)\.(png|jpg|jpeg|webp|svg)/i,/apple-touch-icon/i,/android-chrome/i,/favicon\.(ico|svg)/i];return t.filter(s=>{let n=s.path.split("/").pop()||"";return r.some(i=>i.test(n))}).map(s=>{let n=s.path.split("/").pop()||"",i=n.match(/(\d+)x(\d+)/),o=i?{width:parseInt(i[1]),height:parseInt(i[2])}:this._getDefaultIconSize(n);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:o,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(n)}})}_getDefaultIconSize(t){return t.includes("apple-touch-icon")?{width:180,height:180}:t.includes("favicon")?{width:32,height:32}:{width:192,height:192}}_getFormatFromPath(t){return t.split(".").pop()?.toLowerCase()||"png"}_getIconPurpose(t){return t.includes("maskable")||t.includes("mask")?"maskable":"any"}_getEmptyResult(){return{assets:[],manifest:this._getEmptyManifest(),copiedAssets:[],timestamp:Date.now()}}_getDiscoverySummary(){let t=this.cache?.assets?.length||0,r=this.cache?.copiedAssets?.length||0;return`${t} assets, ${r} copied`}async discoverAssets(t=!1){return await this.discover(t)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(t,r){let s=this.getAssets().map(i=>i.path),n=r||this.options.modernFormats;for(let i of n){let o=`/${t}.${i}`;if(s.includes(o))return o}return null}async _ensureDefaultAssets(t){this.logger.debug("Ensuring default assets with modern format support...");let r=[];try{let s=await this._resolveFrameworkAssetsDir(t);if(this.logger.debug(`Framework assets directory resolved to: ${s}`),!s)return this.logger.debug("Framework assets directory not found, skipping defaults"),r;let n=this.pathResolver.resolveAppPath(mt.public);this.pathResolver.pathExists(n)||(this.pathResolver.mkdir(n),this.logger.debug(`Created public directory: ${n}`));for(let i of this.options.assets)await this._ensureAsset(i,n,s)&&r.push(i);r.length>0&&this.logger.debug(`Added ${r.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return r}async _ensureAsset(t,r,s){let n=this.pathResolver.resolveAppPath(`${mt.public}/${t}`);if(this.pathResolver.pathExists(n))return this.logger.debug(`Asset exists: ${t}`),!1;let i=this.pathResolver.normalizePath(`${s}/${t}`);if(this.pathResolver.pathExists(i)){if(await this.pathResolver.copy(i,n))return this.logger.debug(`Copied framework asset: ${t}`),!0;this.logger.debug(`Failed to copy framework asset: ${t}`)}return!1}async _processAssetFiles(t){let r=[];for(let s of t)try{let n=this.pathResolver.getFileInfo(s);if(n&&n.isFile){let i=s.split("/").pop()||s.split("\\").pop(),o=this._analyzeAsset(i,n.size);o&&r.push(o)}}catch(n){this.logger.debug(`Error processing asset file ${s}: ${n.message}`)}return this.logger.debug(`Processed ${r.length} assets from ${t.length} files`),r}_analyzeAsset(t,r){let s=this._determineAssetType(t),n=this._determineAssetFormat(t);return this.options.assetPatterns.some(o=>this._matchesPattern(t,o))?{path:`/${t}`,name:t,type:s,format:n,size:r,sizeFormatted:this._formatBytes(r),isModern:this.options.modernFormats.includes(n)}:(this.logger.debug(`Asset ${t} does not match any pattern, skipping`),null)}_determineAssetType(t){let r=t.toLowerCase();if(r.includes("favicon"))return"favicon";if(r.includes("logo"))return"logo";if(r.includes("icon"))return"icon";if(r.includes("apple-touch"))return"apple-touch-icon";if(r.includes("android-chrome"))return"android-icon";if(r.includes("manifest"))return"manifest";let s=t.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","avif","svg"].includes(s)?"image":["woff2","woff","ttf","otf"].includes(s)?"font":["json"].includes(s)?"json":["ico"].includes(s)?"icon":"unknown"}_determineAssetFormat(t){return t.split(".").pop()?.toLowerCase()||"unknown"}_formatBytes(t){if(t===0)return"0 Bytes";let r=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,n)).toFixed(2))+" "+s[n]}_matchesPattern(t,r){let s=t.toLowerCase(),n=r.toLowerCase();return s.includes(n.replace("*",""))}_buildAssetManifest(t){let r=t.map(n=>n.path);return{logo:{optimal:this._getOptimalAsset("logo",r,this.options.modernFormats),fallback:this._getOptimalAsset("logo",r,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",r,["svg","ico"]),fallback:this._getOptimalAsset("favicon",r,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",r,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",r,["png"]),512:this._getOptimalAsset("android-chrome-512x512",r,["png"])},manifest:r.find(n=>n.includes("manifest.json"))||null,modernFormats:t.filter(n=>n.isModern).map(n=>n.path),fallbackFormats:t.filter(n=>!n.isModern).map(n=>n.path)}}_getOptimalAsset(t,r,s){for(let n of s){let i=`/${t}.${n}`;if(r.includes(i))return i}return null}async _resolveFrameworkAssetsDir(t){try{let r=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",r);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let n=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(n)?(this.logger.debug(`Using framework assets from: ${n}`),n):(this.logger.debug(`Assets directory not found: ${n}`),null)}catch(r){return this.logger.debug(`Error resolving framework assets directory: ${r.message}`),null}}async _resolvePackage(t,r){try{let s=this.pathResolver.resolveFrameworkPackage(t,r);return s?(this.logger.debug(`Found package: ${s}`),s):(this.logger.debug(`Package ${t} not found`),null)}catch(s){return this.logger.debug(`Error resolving package ${t}: ${s.message}`),null}}_getEmptyManifest(){return{logo:{optimal:null,fallback:null},favicon:{optimal:null,fallback:null},appleTouchIcon:null,androidChrome:{192:null,512:null},manifest:null,modernFormats:[],fallbackFormats:[],logoSvgContent:null}}async _readLogoSvgContent(t,r){if(!t||!t.endsWith(".svg"))return null;try{let s=t.slice(1),n=this.pathResolver.resolveAppPath(`${mt.public}/${s}`);return this.pathResolver.pathExists(n)&&await this.pathResolver.read(n,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(t){try{let r=await this._resolveFrameworkAssetsDir(t);if(!r)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${r}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let n=this.pathResolver.resolveAppPath(mt.public);this.pathResolver.pathExists(n)||this.pathResolver.mkdir(n);let i=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,i)}catch(r){return this.logger.debug(`Failed to copy framework logo: ${r.message}`),!1}}async _generateMissingAssets(t){let r=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(r))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let n=[{name:"favicon.ico",size:32,format:"ico"},{name:"apple-touch-icon.png",size:180,format:"png"},{name:"icon-192x192.png",size:192,format:"png"},{name:"icon-512x512.png",size:512,format:"png"}],i=[{name:"favicon.svg",format:"svg"}],o=[],a=[];try{let l=await this.pathResolver.read(r,{format:"text"});if(!l)return{generated:[],skipped:[...i,...n].map(u=>u.name),error:"Failed to read logo.svg"};for(let u of i){let g=`${s}/${u.name}`;if(this.pathResolver.pathExists(g)){a.push(u.name);continue}try{await this.pathResolver.write(`public/${u.name}`,l),o.push(u.name)}catch(p){this.logger.debug(`Failed to copy ${u.name}: ${p.message}`),a.push(u.name)}}let f=await Promise.resolve().then(()=>to($i(),1)).catch(()=>null);if(!f)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),a.push(...n.map(u=>u.name));else for(let u of n){let g=`${s}/${u.name}`;if(this.pathResolver.pathExists(g)){a.push(u.name);continue}try{let p=f.default(r).resize(u.size,u.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),m;u.format==="ico"?m=await p.toFormat("png").toBuffer():m=await p.toFormat(u.format).toBuffer(),await this.pathResolver.write(`public/${u.name}`,m),o.push(u.name)}catch(p){this.logger.debug(`Failed to generate ${u.name}: ${p.message}`),a.push(u.name)}}return{generated:o,skipped:a,error:null}}catch(l){return this.logger.debug(`Asset generation failed: ${l.message}`),{generated:[],skipped:requiredAssets.map(f=>f.name),error:l.message}}}};var Or={data:null},qu={isEmpty:e=>!e.manifest||e.assets?.length===0,generateModule:(e,t,r="assets")=>{let{manifest:s,assets:n,copiedAssets:i}=e,o=s.logoSvgContent||null,a={totalAssets:n.length,copiedAssets:i.length,hasLogo:s.logo.optimal!==null,hasFavicon:s.favicon.optimal!==null,hasManifest:s.manifest!==null,timestamp:new Date().toISOString()};return`// ${W.assets} - Generated asset manifest
50
+ `),Q}function hr(b){return ce.generateInspection(b,a,F,M)}async function xt(){if(F)try{let b=await ye[i](),S=hr(b),Q=A.resolveAppPath(O);await A.write(Q,S),I.debug(`Generated inspection file: ${A.getRelativePath(Q)}`)}catch(b){I.error(`${t} failed to write inspection file (${O}): ${b.message}`),I.error(`Stack: ${b.stack||"No stack trace available"}`)}}function Ft(b){let S=b.replace(/\\/g,"/");if(E||S.includes("/node_modules/")||S.includes("/.git/")||S.includes("/dist/")||S.includes("/build/")||S.includes("/coverage/")||S.includes("/.vite/")||S.includes("/.turbo/")||S.endsWith(".d.ts")||S.endsWith(".tsbuildinfo")||S.endsWith(".map")||S.endsWith(".css.map")||S.endsWith(".generated.log")||/\.generated\.[a-z]+$/.test(S))return!1;let Q=A.getRelativePath(S);if(Q.startsWith("packages/"))return!1;let Ae=Q.startsWith("src/")&&/\.(ts|tsx)$/.test(Q);return Ae?Array.isArray(o)&&o.length>0?o.some(Re=>typeof Re=="function"?Re(S):typeof Re=="string"?Re.startsWith("**/")?S.endsWith(Re.slice(3)):S.endsWith(Re):!1):Ae:!1}function Ot(b){if(E)return I.debug("Virtual modules are static - HMR disabled"),[];let S=Date.now();return Le?(I.debug("HMR already in progress, skipping update"),[]):S-Z<C?(Ze||(Ze=!0,L=setTimeout(()=>{Ze=!1,Z=Date.now(),Ct(b)},C)),[]):(Z=S,Ct(b))}function Ct(b){let S=Date.now();if(qe===b.file&&S-Z<100)return I.debug(`Same file processed too recently: ${b.file}`),[];if(!Ft(b.file))return I.debug(`Skipping irrelevant file change: ${b.file}`),[];I.debug(`Relevant file changed: ${b.file}`),Le=!0,qe=b.file;try{let Q=Date.now()-(oe?.timestamp||0);if(Q<R&&oe){I.debug(`Using cached discovery data (age: ${Q}ms)`);let Re=b.server.moduleGraph.getModuleById(ke);return Re&&b.server.reloadModule(Re),[]}ye.clearCache();let Ae=b.server.moduleGraph.getModuleById(ke);return Ae&&b.server.reloadModule(Ae),L&&clearTimeout(L),L=setTimeout(()=>{xt()},500),[]}finally{Le=!1,setTimeout(()=>{qe===b.file&&(qe=null)},200)}}return{name:t,enforce:"pre",configResolved(b){F=b.root,z=b.command==="serve",U&&I.debug(`${r} ${t} initialized`),z&&I.debug("\u{1F4A1} Dev mode: Press 'r' in terminal to restart, or use global.__DNDEV_CLEAR_CACHE__() in console"),a.logConfig&&a.logConfig(M)},config(b){return b.optimizeDeps||(b.optimizeDeps={}),b.optimizeDeps.exclude||(b.optimizeDeps.exclude=[]),b.optimizeDeps.exclude.includes(N)||b.optimizeDeps.exclude.push(N),b},resolveId(b){return b===N?(I.debug(`Resolving virtual module: ${b}`),{id:ke,moduleSideEffects:!0}):null},async load(b){if(b!==ke)return null;if(I.debug(`Loading virtual module: ${b}`),!ie()){I.warn("\u26A0\uFE0F load() called before appRoot is set - waiting for config resolution");let S=0;for(;!ie()&&S<100;)await new Promise(Q=>setTimeout(Q,10)),S++;if(!ie())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let S;return oe?(I.debug("Using cached discovery data for virtual module"),S=oe):(I.warn(`\u26A0\uFE0F No cached discovery data found for ${t} - running discovery in load() hook. This may indicate buildStart() hook did not run or failed. Performance may be impacted.`),S=await ye[i](),oe=S,I.debug("Discovery completed for virtual module")),fr(S)}catch(S){return I.error(`${t} virtual module (${ke}) failed to load: ${S.message}`),I.error(`Stack: ${S.stack||"No stack trace available"}`),a.generateEmpty({},U,M,ve)}},async buildStart(){if(et=!1,!ie()){I.warn("\u26A0\uFE0F buildStart() called before appRoot is set - waiting for config resolution");let b=0;for(;!ie()&&b<100;)await new Promise(S=>setTimeout(S,10)),b++;if(!ie())throw new Error("App root not set before discovery. Ensure configResolved hook has set appRoot.")}try{let b=await ye[i](!oe);oe=b,await xt(),a.logStats&&a.logStats(b,r,I)}catch(b){I.error(`${t} discovery failed during file scanning: ${b.message}`),I.error(`Stack: ${b.stack||"No stack trace available"}`),oe=ce.getEmptyResultWithError(ye,b)}finally{et=!0}},configureServer(){et=!0},handleHotUpdate(b){return E?[]:et?Ot(b):(I.debug("HMR disabled - discovery not complete yet"),[])},generateBundle(){if(!oe){I.warn("No cached discovery data for manifest generation - skipping");return}try{let b=ce.generateManifest(oe,a.generateManifest);this.emitFile({type:"asset",fileName:u,source:JSON.stringify(b,null,2)}),W&&a.logManifest&&a.logManifest(oe,t)}catch(b){I.error(`${t} manifest generation failed: ${b.message}`),I.error(`Stack: ${b.stack||"No stack trace available"}`)}},transform(b,S){return S===ke?{code:b,map:null}:null}}}}var Lh={generateGlobals:ce.generateGlobals,generateExports:ce.generateExports,generateDefaultExport:ce.generateDefaultExport,wrapVirtualModule:ce.wrapVirtualModule,generateInspectionHeader:ce.generateInspectionHeader,validateTemplates:ce.validateTemplates,createTemplateConfig:ce.createTemplateConfig};re();var Pe=class e{constructor(t,r={}){if(this.constructor===e)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=t,this.options={...r},process.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=B(this._getDiscoveryType(),this.options.debug,this.options.verbose,{fileLogging:this.options.fileLogging,logDir:this.options.logDir}),this.cache=null,this._lastDiscoveryTime=0}async discover(t=!1){if(!t&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let r=Date.now();try{let s=await this._getPatterns();this.options.verbose&&s&&(typeof s=="object"&&s.pattern?this.logger.verbose(`Pattern: ${s.pattern}`):typeof s=="string"&&this.logger.verbose(`Pattern: ${s}`),s.dirs&&this.logger.verbose(`Search directories: ${s.dirs.slice(0,3).join(", ")}${s.dirs.length>3?` (${s.dirs.length} total)`:""}`));let n=await this._scanFiles(s),i=await this._processFiles(n);this.cache={...i,timestamp:Date.now()};let o=Date.now()-r;return this.logger.debug(`Discovery completed in ${o}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){return this.logger.error(`${this._getDiscoveryType()} discovery failed during file scanning: ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),this._getEmptyResult()}}clearCache(){this.cache=null,this._lastDiscoveryTime=0,this.logger.debug("Cache cleared")}getCachedResults(){return this.cache}_getDiscoveryType(){throw new Error("_getDiscoveryType must be implemented by subclass")}_getPatterns(){throw new Error("_getPatterns must be implemented by subclass")}_getPatternType(){throw new Error("_getPatternType must be implemented by subclass")}async _processFiles(t){throw new Error("_processFiles must be implemented by subclass")}_getEmptyResult(){throw new Error("_getEmptyResult must be implemented by subclass")}_getDiscoverySummary(){throw new Error("_getDiscoverySummary must be implemented by subclass")}async _scanFiles(t){let r=this._getPatternType();return await this.pathResolver.resolveFiles(t,r)}_extractFileNameInfo(t){let r=t.split("/"),s=r[r.length-1],n=s.split(".")[0],i=s.split(".").pop();return{fileName:s,baseName:n,extension:i,directory:r.slice(0,-1).join("/")}}async _processSingleFile(t,r){try{let s=this.pathResolver.getFileInfo(t);return s?await r(s):(this.logger.debug(`Could not get file info: ${t}`),null)}catch(s){return this.logger.debug(`Error processing file ${t}: ${s.message}`),null}}async _batchProcessFiles(t,r){return(await Promise.all(t.map(n=>this._processSingleFile(n,r)))).filter(n=>n!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};re();var nr=class extends Pe{constructor(t,r={}){super(t,{assets:Ee.assets.fallback,assetPatterns:Ee.assets.patterns,frameworkPackage:br.package,assetsPath:br.assetsPath,modernFormats:Ee.assets.modern,...r}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(t){let r=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(r),n=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(n)||this.logger.warn("logo.svg not found in public/. Add your logo.svg to generate PWA assets, or copy from node_modules/@donotdev/ui/assets/logo.svg");let o=[],a=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(a)&&this.options.generateAssets!==!1&&(o=(await this._generateMissingAssets(r))?.generated||[]);let{consumerFiles:l}=t,u=await this._processAssetFiles(l),f=this._buildAssetManifest(u),d=await this._readLogoSvgContent("/logo.svg",r);return{assets:u,manifest:{...f,logoSvgContent:d},copiedAssets:s,generatedAssets:o,pwaIcons:this._extractPWAIcons(u)}}_extractPWAIcons(t){let r=[/icon-(\d+)x(\d+)\.(png|jpg|jpeg|webp|svg)/i,/apple-touch-icon/i,/android-chrome/i,/favicon\.(ico|svg)/i];return t.filter(s=>{let n=s.path.split("/").pop()||"";return r.some(i=>i.test(n))}).map(s=>{let n=s.path.split("/").pop()||"",i=n.match(/(\d+)x(\d+)/),o=i?{width:parseInt(i[1]),height:parseInt(i[2])}:this._getDefaultIconSize(n);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:o,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(n)}})}_getDefaultIconSize(t){return t.includes("apple-touch-icon")?{width:180,height:180}:t.includes("favicon")?{width:32,height:32}:{width:192,height:192}}_getFormatFromPath(t){return t.split(".").pop()?.toLowerCase()||"png"}_getIconPurpose(t){return t.includes("maskable")||t.includes("mask")?"maskable":"any"}_getEmptyResult(){return{assets:[],manifest:this._getEmptyManifest(),copiedAssets:[],timestamp:Date.now()}}_getDiscoverySummary(){let t=this.cache?.assets?.length||0,r=this.cache?.copiedAssets?.length||0;return`${t} assets, ${r} copied`}async discoverAssets(t=!1){return await this.discover(t)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(t,r){let s=this.getAssets().map(i=>i.path),n=r||this.options.modernFormats;for(let i of n){let o=`/${t}.${i}`;if(s.includes(o))return o}return null}async _ensureDefaultAssets(t){this.logger.debug("Ensuring default assets with modern format support...");let r=[];try{let s=await this._resolveFrameworkAssetsDir(t);if(this.logger.debug(`Framework assets directory resolved to: ${s}`),!s)return this.logger.debug("Framework assets directory not found, skipping defaults"),r;let n=this.pathResolver.resolveAppPath(Pt.public);this.pathResolver.pathExists(n)||(this.pathResolver.mkdir(n),this.logger.debug(`Created public directory: ${n}`));for(let i of this.options.assets)await this._ensureAsset(i,n,s)&&r.push(i);r.length>0&&this.logger.debug(`Added ${r.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return r}async _ensureAsset(t,r,s){let n=this.pathResolver.resolveAppPath(`${Pt.public}/${t}`);if(this.pathResolver.pathExists(n))return this.logger.debug(`Asset exists: ${t}`),!1;let i=this.pathResolver.normalizePath(`${s}/${t}`);if(this.pathResolver.pathExists(i)){if(await this.pathResolver.copy(i,n))return this.logger.debug(`Copied framework asset: ${t}`),!0;this.logger.debug(`Failed to copy framework asset: ${t}`)}return!1}async _processAssetFiles(t){let r=[];for(let s of t)try{let n=this.pathResolver.getFileInfo(s);if(n&&n.isFile){let i=s.split("/").pop()||s.split("\\").pop(),o=this._analyzeAsset(i,n.size);o&&r.push(o)}}catch(n){this.logger.debug(`Error processing asset file ${s}: ${n.message}`)}return this.logger.debug(`Processed ${r.length} assets from ${t.length} files`),r}_analyzeAsset(t,r){let s=this._determineAssetType(t),n=this._determineAssetFormat(t);return this.options.assetPatterns.some(o=>this._matchesPattern(t,o))?{path:`/${t}`,name:t,type:s,format:n,size:r,sizeFormatted:this._formatBytes(r),isModern:this.options.modernFormats.includes(n)}:(this.logger.debug(`Asset ${t} does not match any pattern, skipping`),null)}_determineAssetType(t){let r=t.toLowerCase();if(r.includes("favicon"))return"favicon";if(r.includes("logo"))return"logo";if(r.includes("icon"))return"icon";if(r.includes("apple-touch"))return"apple-touch-icon";if(r.includes("android-chrome"))return"android-icon";if(r.includes("manifest"))return"manifest";let s=t.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","avif","svg"].includes(s)?"image":["woff2","woff","ttf","otf"].includes(s)?"font":["json"].includes(s)?"json":["ico"].includes(s)?"icon":"unknown"}_determineAssetFormat(t){return t.split(".").pop()?.toLowerCase()||"unknown"}_formatBytes(t){if(t===0)return"0 Bytes";let r=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,n)).toFixed(2))+" "+s[n]}_matchesPattern(t,r){let s=t.toLowerCase(),n=r.toLowerCase();return s.includes(n.replace("*",""))}_buildAssetManifest(t){let r=t.map(n=>n.path);return{logo:{optimal:this._getOptimalAsset("logo",r,this.options.modernFormats),fallback:this._getOptimalAsset("logo",r,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",r,["svg","ico"]),fallback:this._getOptimalAsset("favicon",r,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",r,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",r,["png"]),512:this._getOptimalAsset("android-chrome-512x512",r,["png"])},manifest:r.find(n=>n.includes("manifest.json"))||null,modernFormats:t.filter(n=>n.isModern).map(n=>n.path),fallbackFormats:t.filter(n=>!n.isModern).map(n=>n.path)}}_getOptimalAsset(t,r,s){for(let n of s){let i=`/${t}.${n}`;if(r.includes(i))return i}return null}async _resolveFrameworkAssetsDir(t){try{let r=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",r);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let n=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(n)?(this.logger.debug(`Using framework assets from: ${n}`),n):(this.logger.debug(`Assets directory not found: ${n}`),null)}catch(r){return this.logger.debug(`Error resolving framework assets directory: ${r.message}`),null}}async _resolvePackage(t,r){try{let s=this.pathResolver.resolveFrameworkPackage(t,r);return s?(this.logger.debug(`Found package: ${s}`),s):(this.logger.debug(`Package ${t} not found`),null)}catch(s){return this.logger.debug(`Error resolving package ${t}: ${s.message}`),null}}_getEmptyManifest(){return{logo:{optimal:null,fallback:null},favicon:{optimal:null,fallback:null},appleTouchIcon:null,androidChrome:{192:null,512:null},manifest:null,modernFormats:[],fallbackFormats:[],logoSvgContent:null}}async _readLogoSvgContent(t,r){if(!t||!t.endsWith(".svg"))return null;try{let s=t.slice(1),n=this.pathResolver.resolveAppPath(`${Pt.public}/${s}`);return this.pathResolver.pathExists(n)&&await this.pathResolver.read(n,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(t){try{let r=await this._resolveFrameworkAssetsDir(t);if(!r)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${r}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let n=this.pathResolver.resolveAppPath(Pt.public);this.pathResolver.pathExists(n)||this.pathResolver.mkdir(n);let i=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,i)}catch(r){return this.logger.debug(`Failed to copy framework logo: ${r.message}`),!1}}async _generateMissingAssets(t){let r=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(r))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let n=[{name:"favicon.ico",size:32,format:"ico"},{name:"apple-touch-icon.png",size:180,format:"png"},{name:"icon-192x192.png",size:192,format:"png"},{name:"icon-512x512.png",size:512,format:"png"}],i=[{name:"favicon.svg",format:"svg"}],o=[],a=[];try{let l=await this.pathResolver.read(r,{format:"text"});if(!l)return{generated:[],skipped:[...i,...n].map(f=>f.name),error:"Failed to read logo.svg"};for(let f of i){let d=`${s}/${f.name}`;if(this.pathResolver.pathExists(d)){a.push(f.name);continue}try{await this.pathResolver.write(`public/${f.name}`,l),o.push(f.name)}catch(g){this.logger.debug(`Failed to copy ${f.name}: ${g.message}`),a.push(f.name)}}let u=await Promise.resolve().then(()=>ko(Bi(),1)).catch(()=>null);if(!u)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),a.push(...n.map(f=>f.name));else for(let f of n){let d=`${s}/${f.name}`;if(this.pathResolver.pathExists(d)){a.push(f.name);continue}try{let g=u.default(r).resize(f.size,f.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),m;f.format==="ico"?m=await g.toFormat("png").toBuffer():m=await g.toFormat(f.format).toBuffer(),await this.pathResolver.write(`public/${f.name}`,m),o.push(f.name)}catch(g){this.logger.debug(`Failed to generate ${f.name}: ${g.message}`),a.push(f.name)}}return{generated:o,skipped:a,error:null}}catch(l){return this.logger.debug(`Asset generation failed: ${l.message}`),{generated:[],skipped:requiredAssets.map(u=>u.name),error:l.message}}}};me();var Yr={data:null},mf={isEmpty:e=>!e.manifest||e.assets?.length===0,generateModule:(e,t,r="assets")=>{let{manifest:s,assets:n,copiedAssets:i}=e,o=s.logoSvgContent||null,a={totalAssets:n.length,copiedAssets:i.length,hasLogo:s.logo.optimal!==null,hasFavicon:s.favicon.optimal!==null,hasManifest:s.manifest!==null,timestamp:new Date().toISOString()};return`// ${V.assets} - Generated asset manifest
48
51
  const assetManifest = ${JSON.stringify(s,null,2)};
49
52
  const assetStats = ${JSON.stringify(a,null,2)};
50
53
 
@@ -62,7 +65,7 @@ if (typeof globalThis !== 'undefined') {
62
65
  }
63
66
 
64
67
  // Populate assets configuration
65
- globalThis._DNDEV_CONFIG_.${ne[r]} = {
68
+ globalThis._DNDEV_CONFIG_.${le[r]} = {
66
69
  mapping: assetManifest,
67
70
  logoSvgContent: ${JSON.stringify(o)},
68
71
  manifest: {
@@ -114,7 +117,7 @@ export default {
114
117
  getManifest,
115
118
  getAllAssets
116
119
  };
117
- `},generateEmpty:(e,t,r,s="assets")=>{let n={totalAssets:0,copiedAssets:0,hasLogo:!1,hasFavicon:!1,hasManifest:!1,timestamp:new Date().toISOString()};return`// ${W.assets} - Empty asset manifest
120
+ `},generateEmpty:(e,t,r,s="assets")=>{let n={totalAssets:0,copiedAssets:0,hasLogo:!1,hasFavicon:!1,hasManifest:!1,timestamp:new Date().toISOString()};return`// ${V.assets} - Empty asset manifest
118
121
  const assetManifest = {
119
122
  logo: { optimal: null, fallback: null },
120
123
  favicon: { optimal: null, fallback: null },
@@ -140,7 +143,7 @@ if (typeof globalThis !== 'undefined') {
140
143
  }
141
144
 
142
145
  // Populate empty assets configuration
143
- globalThis._DNDEV_CONFIG_.${ne[s]} = {
146
+ globalThis._DNDEV_CONFIG_.${le[s]} = {
144
147
  mapping: assetManifest,
145
148
  logoSvgContent: null,
146
149
  manifest: {
@@ -213,7 +216,7 @@ export default discoveredAssets;
213
216
  `:`/**
214
217
  * Generated Asset Discovery Results
215
218
  * Generated at: ${new Date().toISOString()}
216
- * Import from '${W.assets}'
219
+ * Import from '${V.assets}'
217
220
  */
218
221
 
219
222
  export const discoveredAssets = ${JSON.stringify(t,null,2)};
@@ -230,7 +233,7 @@ export const assetStats = {
230
233
  };
231
234
 
232
235
  export default discoveredAssets;
233
- `},generateManifest:e=>({assets:e.assets?.length||0,copied:e.copiedAssets?.length||0,timestamp:Date.now(),hasLogo:e.manifest?.logo?.optimal!==null,hasFavicon:e.manifest?.favicon?.optimal!==null}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.assets?.length||0,n=e.generatedAssets?.length||0;r&&(n>0?r.info(`${t} Assets: ${s} found, ${n} generated`):r.info(`${t} Assets: ${s} found`))}},Wu=[e=>e.includes("/public/"),e=>e.endsWith(".png")||e.endsWith(".svg")||e.endsWith(".ico"),e=>e.includes("favicon")||e.includes("logo")||e.includes("manifest")];function ki(e={}){let t=Se({pluginName:"dndev-vite-asset-discovery",icon:"\u{1F3AF}",virtualModuleId:W.assets,DiscoveryClass:Vt,discoveryMethod:"discoverAssets",filePatterns:Wu,templates:qu,defaultInspectionPath:Q.vite.assetInspection,manifestFileName:Q.manifests.asset,configKey:"assets"})(e),r=G.getInstance(),s=M("asset-plugin",e.debug,e.verbose),n=t.buildStart;return t.buildStart=async function(...i){n&&await n.apply(this,i);let o=null;try{let a=r.resolveAppPath(Q.vite.assetInspection);if(r.pathExists(a)){let l=r.readSync(a,{format:"json"});l&&(o=l,Or.data=o)}}catch(a){s.debug(`Could not cache asset data: ${a.message}`)}},t}import{loadEnv as Hu}from"vite";var Ai={isEmpty:e=>!e.env||Object.keys(e.env).length===0,generateModule:(e,t,r="env")=>{let{env:s,mode:n}=e;if(!s||Object.keys(s).length===0)return Ai.generateEmpty(e,t,void 0,r);let i={totalVars:Object.keys(s).length,mode:n,source:e.source,generatedAt:new Date().toISOString()};return`// ${W.env} - Generated environment variables
236
+ `},generateManifest:e=>({assets:e.assets?.length||0,copied:e.copiedAssets?.length||0,timestamp:Date.now(),hasLogo:e.manifest?.logo?.optimal!==null,hasFavicon:e.manifest?.favicon?.optimal!==null}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.assets?.length||0,n=e.generatedAssets?.length||0;r&&(n>0?r.info(`${t} Assets: ${s} found, ${n} generated`):r.info(`${t} Assets: ${s} found`))}},bf=[e=>e.includes("/public/"),e=>e.endsWith(".png")||e.endsWith(".svg")||e.endsWith(".ico"),e=>e.includes("favicon")||e.includes("logo")||e.includes("manifest")];function Ui(e={}){let t=Ne({pluginName:"dndev-vite-asset-discovery",icon:"\u{1F3AF}",virtualModuleId:V.assets,DiscoveryClass:nr,discoveryMethod:"discoverAssets",filePatterns:bf,templates:mf,defaultInspectionPath:te.vite.assetInspection,manifestFileName:te.manifests.asset,configKey:"assets"})(e),r=G.getInstance(),s=B("asset-plugin",e.debug,e.verbose),n=t.buildStart;return t.buildStart=async function(...i){n&&await n.apply(this,i);let o=null;try{let a=r.resolveAppPath(te.vite.assetInspection);if(r.pathExists(a)){let l=r.readSync(a,{format:"json"});l&&(o=l,Yr.data=o)}}catch(a){s.debug(`Could not cache asset data: ${a.message}`)}},t}import{loadEnv as vf}from"vite";re();var Gi={isEmpty:e=>!e.env||Object.keys(e.env).length===0,generateModule:(e,t,r="env")=>{let{env:s,mode:n}=e;if(!s||Object.keys(s).length===0)return Gi.generateEmpty(e,t,void 0,r);let i={totalVars:Object.keys(s).length,mode:n,source:e.source,generatedAt:new Date().toISOString()};return`// ${V.env} - Generated environment variables
234
237
 
235
238
  const envData = ${JSON.stringify(s,null,2)};
236
239
  const envManifest = ${JSON.stringify(i,null,2)};
@@ -259,7 +262,7 @@ if (typeof globalThis !== 'undefined') {
259
262
  }
260
263
 
261
264
  // Populate env configuration (frozen to prevent tampering)
262
- globalThis._DNDEV_CONFIG_.${ne[r]} = envData;
265
+ globalThis._DNDEV_CONFIG_.${le[r]} = envData;
263
266
  // Only freeze the env property, not the entire config (other plugins need to add properties)
264
267
  }
265
268
 
@@ -270,7 +273,7 @@ export const source = '${e.source}';
270
273
 
271
274
  // Default export
272
275
  export default envData;
273
- `},generateEmpty:(e,t,r,s="env")=>{let n={totalVars:0,mode:e.mode||"development",source:"empty",generatedAt:new Date().toISOString()};return`// ${W.env} - Empty environment data
276
+ `},generateEmpty:(e,t,r,s="env")=>{let n={totalVars:0,mode:e.mode||"development",source:"empty",generatedAt:new Date().toISOString()};return`// ${V.env} - Empty environment data
274
277
 
275
278
  const envData = {};
276
279
  const envManifest = ${JSON.stringify(n,null,2)};
@@ -299,7 +302,7 @@ if (typeof globalThis !== 'undefined') {
299
302
  }
300
303
 
301
304
  // Populate empty env configuration (frozen to prevent tampering)
302
- globalThis._DNDEV_CONFIG_.${ne[s]} = envData;
305
+ globalThis._DNDEV_CONFIG_.${le[s]} = envData;
303
306
  // Only freeze the env property, not the entire config (other plugins need to add properties)
304
307
  }
305
308
 
@@ -309,15 +312,15 @@ export const source = 'empty';
309
312
 
310
313
  export default envData;
311
314
  `},generateInspection:e=>{let{env:t,mode:r}=e;return["/**"," * Generated Environment Variables",` * Mode: ${r}`,` * Generated at: ${new Date().toISOString()}`,` * Total variables: ${Object.keys(t).length}`," */","","```json",JSON.stringify(t,null,2),"```"].join(`
312
- `)},generateManifest:e=>({totalVars:Object.keys(e?.env||{}).length,mode:e?.mode||"development",variables:Object.keys(e?.env||{}),timestamp:Date.now()}),logStats:(e,t,r)=>{let s=Object.keys(e.env).length;r&&r.info(`${t} Env: ${s} VITE_* variables`)}},jr=class{constructor(t,r={}){this.pathResolver=t,this.options=r,this.mode=r.mode||"development",this.appRoot=null}async discoverEnv(){try{let t=this.pathResolver.getAppRoot();if(!t)throw new Error("App root not available in EnvDiscovery");let s={...Hu(this.mode,t,"VITE_")};return this.mode==="production"&&(delete s.VITE_USE_FIREBASE_EMULATOR,delete s.VITE_FIREBASE_EMULATOR_HOST,delete s.VITE_FIREBASE_AUTH_EMULATOR_HOST,delete s.VITE_FIREBASE_FIRESTORE_EMULATOR_HOST,delete s.VITE_FIREBASE_FUNCTIONS_EMULATOR_PORT),s.MODE=this.mode,s.DEV=this.mode==="development",s.PROD=this.mode==="production",s.SSR=!1,{env:s,mode:this.mode,source:`${t}/.env`,errors:[]}}catch(t){return{env:{},mode:this.mode,source:"error",errors:[t.message]}}}};function _i(e={}){return Se({pluginName:"dndev-vite-env-discovery",icon:"\u{1F510}",virtualModuleId:W.env,discoveryMethod:"discoverEnv",filePatterns:[],templates:Ai,defaultInspectionPath:Q.vite.envInspection,manifestFileName:Q.manifests.env,configKey:"env",createDiscovery:(t,r)=>new jr(t,{...r,mode:e.mode||r.mode||"development"})})({...e,disableHmr:!0})}import Lr from"node:fs";import Vu from"node:path";var Ni=/--(?:font-family|font-headline)\s*:\s*(?:['"]([^'"]+)['"]|([^;]+?));/g,We=class{constructor(t,r={}){if(!t)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=t,this.options={debug:!1,customPatterns:{},...r},this.logger=r.logger||{debug:(s,...n)=>{this.options.debug}},this.patterns={selectors:{...ir.selectors,...this.options.customPatterns?.selectors},themes:{...ir.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(t){if(!t||typeof t!="string")return this._debug(`Invalid CSS variable: ${t}`),null;let r=t.replace(/^--/,"");if(!r)return this._debug(`Empty CSS variable after removing --: ${t}`),null;let s=r.split("-").filter(o=>o.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${t}`),null;let n=s.map((o,a)=>{let l=o.replace(/[^a-zA-Z0-9]/g,"");return l?a===0?l.toLowerCase():l.charAt(0).toUpperCase()+l.slice(1).toLowerCase():null}).filter(Boolean).join("");return!n||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(n)?(this._debug(`Invalid JavaScript identifier generated from ${t}: ${n}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(n)?`${n}Var`:n}_stripComments(t){return t.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(t,r,s){let n=[],i,o=this.pathResolver.normalizePath(r),a=this._stripComments(t),l=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(i=l.exec(a))!==null;){let[,f,u,g]=i;if(!f||!g)continue;let p=u.match(this.patterns.themes.themeIcon),m=u.match(this.patterns.themes.themeIsDark),S={name:f,displayName:g,isDark:m?m[1]==="1":!1,meta:{icon:p?.[1]},source:this.pathResolver.getBasename(r)};this._debug(`Discovered theme: ${f} (${g})`),n.push(S),s.themes.set(f,{name:f,displayName:g,isDark:S.isDark,file:o,variables:new Set,meta:S.meta})}return n.length>0&&this._debug(`Extracted ${n.length} themes from ${o}`),n}extractClasses(t,r){(t.match(this.patterns.selectors.class)||[]).forEach(n=>{let i=n.slice(1);i.startsWith("_")||r.classes.add(i)})}extractVariables(t,r,s){(t.match(this.patterns.selectors.variable)||[]).forEach(i=>{i.startsWith("--")&&i.length>2?s==="framework"?r.variables.framework.add(i):r.variables.consumer.add(i):this._debug(`Skipping invalid CSS variable: ${i}`)})}extractFontFamilies(t){if(!t||typeof t!="string")return[];let r=this._stripComments(t),s=new Set,n;for(Ni.lastIndex=0;(n=Ni.exec(r))!==null;){let i=n[1];i&&i.trim()&&s.add(i.trim())}return Array.from(s)}extractKeyframes(t,r){(t.match(this.patterns.selectors.keyframe)||[]).forEach(n=>{let i=n.replace("@keyframes","").trim();i&&r.keyframes.add(i)})}validateCSS(t){let r=[],s=t.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(i=>{r.push(`Possible malformed CSS variable: ${i}`)}),(t.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(i=>{if(!i.includes("--theme-label")&&i.includes("--")){let o=i.match(/\.([a-z][a-z0-9-]+)/)?.[1];o&&r.push(`Theme class "${o}" missing --theme-label`)}}),r}extractAll(t,r,s="consumer"){let n={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},i=this.extractThemes(t,r,n);this.extractClasses(t,n),this.extractVariables(t,n,s),this.extractKeyframes(t,n);let o=this.validateCSS(t);return{themes:i,classes:Array.from(n.classes),variables:{framework:Array.from(n.variables.framework),consumer:Array.from(n.variables.consumer),all:[...Array.from(n.variables.framework),...Array.from(n.variables.consumer)].sort()},keyframes:Array.from(n.keyframes),warnings:o}}getPatterns(){return{...this.patterns}}setPatterns(t){this.patterns={...this.patterns,...t,selectors:{...this.patterns.selectors,...t.selectors},themes:{...this.patterns.themes,...t.themes}}}_debug(t,r){this.logger.debug(t,r||"")}};var Ju=3,Mr="<!-- DNDEV_FONT_PRELOADS -->";function Ii(e={}){let{debug:t=!1}=e,r=M("font-preload",t,!1),s,n={},i=[],o=[];return{name:"vite-font-preload-plugin",enforce:"post",configResolved(a){n={root:a.root,base:a.base&&a.base!=="/"?a.base.replace(/\/$/,""):"",outDir:a.build?.outDir??"dist"};try{s=G.getInstance()}catch(l){r.debug(`Font preload: PathResolver not ready: ${l?.message}`)}},async buildStart(){if(!(!s||!s.getAppRoot()))try{let l=await s.resolvePatterns("css"),{consumerFiles:f}=await s.resolveFiles(l,"css");if(!f?.length){i=[bt.Inter],r.debug("Font preload: no consumer CSS, using default Inter");return}let u=new We(s,{debug:t,logger:r}),g=new Set;for(let m of f)try{let S=await s.read(m,{format:"text"});S&&u.extractFontFamilies(S).forEach(q=>g.add(q))}catch(S){r.debug(`Font preload: skip read ${m}: ${S?.message}`)}if(g.size===0){i=[bt.Inter],r.debug("Font preload: no font families in CSS, using default Inter");return}let p=new Set;for(let m of g){let S=bt[m];S&&p.add(S)}i=Array.from(p),r.debug(`Font preload: stems ${i.join(", ")} from CSS`)}catch(l){r.debug(`Font preload: discovery failed, use Inter: ${l?.message}`),i=[bt.Inter]}},generateBundle(a,l){if(!i.length)return;let f=n.base||"",u=[];for(let[g,p]of Object.entries(l)){if(p.type!=="asset"||!g.endsWith(".woff2")&&!g.endsWith(".woff"))continue;let m=g.toLowerCase();if(i.some(z=>m.includes(z))){let z=f?`${f}/${g}`:`/${g}`;u.push(z)}}o=u.slice(0,Ju)},writeBundle(){if(!o.length)return;let a=n.root||process.cwd(),l=n.outDir||"dist",f=Vu.join(a,l,"index.html");try{if(!Lr.existsSync(f)){r.debug(`Font preload: index.html not found at ${f}`);return}let u=Lr.readFileSync(f,"utf8"),g=o.map(p=>`<link rel="preload" as="font" href="${p}" type="font/woff2" crossorigin="anonymous" />`).join(`
313
- `);if(u.includes(Mr))u=u.replace(Mr,`${Mr}
314
- ${g}`);else{let p=u.indexOf("<!-- Fonts:"),m=p!==-1?u.indexOf("-->",p)+3:u.indexOf("</head>");m!==-1&&(u=u.slice(0,m)+`
315
- ${g}`+u.slice(m))}Lr.writeFileSync(f,u,"utf8"),r.debug(`Font preload: injected ${o.length} link(s)`)}catch(u){r.debug(`Font preload: write failed: ${u?.message}`)}}}}var Jt=class extends be{constructor(t,r={}){super(t,{fallbackLanguage:"en",additionalPaths:[],...r})}_getDiscoveryType(){return"I18n"}async _getPatterns(){return await this.pathResolver.resolvePatterns("i18n")}_getPatternType(){return"i18n"}async _processFiles(t){let r=this.pathResolver.getAppRoot(),s=this.pathResolver.getRepoRoot();if(!r||r===s)throw this.logger.error(`I18n discovery: appRoot not properly set (appRoot: ${r}, repoRoot: ${s})`),new Error("App root not set before i18n discovery. Ensure configResolved hook has run.");this.logger.debug(`I18n discovery: appRoot=${r}, repoRoot=${s}`);let n=await this._getPatterns();this.logger.debug(`I18n patterns - eager: ${n.eager.length}, lazy: ${n.lazy.length}, framework eager: ${n.framework?.eager?.length||0}, framework lazy: ${n.framework?.lazy?.length||0}`),this.logger.debug(`isMonorepo: ${this.pathResolver.isMonorepo()}, repoRoot: ${this.pathResolver.getRepoRoot()}`);let i=kt("i18n"),o=n.eager||[],a=n.lazy||[],l=(this.options.additionalPaths||[]).map(F=>{let L=F.endsWith(".json")?F:`${F}/*_*.json`;return this.pathResolver.resolveAppPath(L)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let f=n.framework?.eager||[],u=n.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${o.join(", ")}, lazy: ${a.join(", ")}, framework eager: ${f.join(", ")}, framework lazy: ${u.join(", ")}`),f.length===0&&u.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let g=this.pathResolver.normalizePath(r),p=this.pathResolver.normalizePath(s),m=(F,L)=>{let O=this.pathResolver.normalizePath(F),Y=this.pathResolver.normalizePath(L);return O.startsWith(Y)?O.slice(Y.length+1):O},S=o.map(F=>m(F,r)),q=[...a,...l].map(F=>m(F,r)),$=f.map(F=>m(F,s)),C=u.map(F=>m(F,s)),k={...i,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r},D=await this.pathResolver._globWithNormalization(S,k),N=await this.pathResolver._globWithNormalization(q,k),E={...i,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:i.ignore?.filter(F=>F!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(E.ignore)}`);let B=await this.pathResolver._globWithNormalization($,E),j=await this.pathResolver._globWithNormalization(C,E);this.logger.debug(`Found ${D.length} eager, ${N.length} lazy, ${B.length} framework eager, ${j.length} framework lazy files`),B.length>0?this.logger.debug(`Framework eager files (first 3): ${B.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${f.join(", ")}`),j.length>0?this.logger.debug(`Framework lazy files (first 3): ${j.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${u.join(", ")}`);let fe=[...new Set([...D,...N,...B,...j])],I=new Set([...D,...B]),A={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},te=new Map,gt=[...B,...j];for(let F of gt){let L=this._processTranslationFile(F,B.includes(F),r);if(L){let O=`${L.namespace}_${L.language}`;te.set(O,L),A.allNamespaces.add(L.namespace),A.supportedLanguages.add(L.language),B.includes(F)&&A.eagerNamespaces.add(L.namespace)}}let de=new Set;for(let F of fe){if(gt.includes(F))continue;let L=this._processTranslationFile(F,I.has(F),r);if(L){let{namespace:O,language:Y,importPath:He,content:re}=L,Le=`${L.namespace}_${L.language}`;if(te.has(Le)){let De=te.get(Le);L.content=this._mergeTranslations(De.content,re)}A.allNamespaces.add(O),A.supportedLanguages.add(Y),de.add(Y),I.has(F)&&A.eagerNamespaces.add(O),A.mapping[O]||(A.mapping[O]={}),A.mapping[O][Y]=He,L.content&&(A.content[O]||(A.content[O]={}),A.content[O][Y]=L.content),A.files.push({path:F,relativePath:this.pathResolver.getRelativePath(F),namespace:O,language:Y,eager:I.has(F),size:L.content?JSON.stringify(L.content).length:0})}}for(let[F,L]of te){let[O,Y]=F.split("_");(!A.mapping[O]||!A.mapping[O][Y])&&(A.mapping[O]||(A.mapping[O]={}),A.mapping[O][Y]=L.importPath,A.content[O]||(A.content[O]={}),A.content[O][Y]=L.content)}let xe=de.size>0?[...de].sort():[this.options.fallbackLanguage];return{mapping:A.mapping,content:A.content,eagerNamespaces:[...A.eagerNamespaces].sort(),allNamespaces:[...A.allNamespaces].sort(),supportedLanguages:xe,fallbackLanguage:this.options.fallbackLanguage,files:A.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],fallbackLanguage:this.options.fallbackLanguage,files:[],timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.allNamespaces?.length||0} namespaces, ${this.cache?.supportedLanguages?.length||0} languages`}async discover(t=!1){if(!t&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let r=Date.now();try{let s=await this._processFiles([]);this.cache={...s,timestamp:Date.now()};let n=Date.now()-r;return this.logger.debug(`Discovery completed in ${n}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){throw this.logger.error(`I18n discovery failed: ${s.message}`),s}}async discoverTranslations(t=!1){return await this.discover(t)}getMapping(){return this.cache?.mapping||{}}getLanguages(){return this.cache?.supportedLanguages||[this.options.fallbackLanguage]}getNamespaces(){return this.cache?.allNamespaces||["common"]}getEagerNamespaces(){return this.cache?.eagerNamespaces||[]}_processTranslationFile(t,r,s){let n=t.split("/").pop()||t.split("\\").pop()||"",i,o,a=n.match(/^([^_]+)_([^.]+)\.json$/);if(!a)return this.logger.debug(`Invalid translation file name format: ${n}`),null;if([,i,o]=a,!i||!o)return this.logger.debug(`Invalid namespace or language in file: ${n}`),null;let f="./"+this.pathResolver.getRelativePath(t).replace(/\\/g,"/"),u;try{if(u=this.pathResolver.readSync(t,{format:"json"}),!u)return this.logger.debug(`Could not read file: ${t}`),null}catch(g){return this.logger.debug(`Error parsing JSON from ${t}: ${g.message}`),null}return{namespace:i,language:o,importPath:f,content:u}}_mergeTranslations(t,r){let s={...t};for(let[n,i]of Object.entries(r))typeof i=="object"&&i!==null&&!Array.isArray(i)?s[n]=this._mergeTranslations(s[n]||{},i):s[n]=i;return s}};var Xu={isEmpty:e=>!e.mapping||Object.keys(e.mapping).length===0,generateModule:(e,t,r="i18n")=>{let{mapping:s,eagerNamespaces:n,supportedLanguages:i,fallbackLanguage:o,stats:a,content:l={}}=e,f={mapping:s,languages:i,eager:n,fallback:o,content:l,storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:a?.totalFiles||0,totalNamespaces:a?.totalNamespaces||0,totalLanguages:a?.totalLanguages||0,eagerNamespaces:a?.eagerNamespaces||0,generatedAt:new Date().toISOString()},debug:t};return`// ${W.i18n} - Generated by @donotdev/config
315
+ `)},generateManifest:e=>({totalVars:Object.keys(e?.env||{}).length,mode:e?.mode||"development",variables:Object.keys(e?.env||{}),timestamp:Date.now()}),logStats:(e,t,r)=>{let s=Object.keys(e.env).length;r&&r.info(`${t} Env: ${s} VITE_* variables`)}},Kr=class{constructor(t,r={}){this.pathResolver=t,this.options=r,this.mode=r.mode||"development",this.appRoot=null}async discoverEnv(){try{let t=this.pathResolver.getAppRoot();if(!t)throw new Error("App root not available in EnvDiscovery");let s={...vf(this.mode,t,"VITE_")};return this.mode==="production"&&(delete s.VITE_USE_FIREBASE_EMULATOR,delete s.VITE_FIREBASE_EMULATOR_HOST,delete s.VITE_FIREBASE_AUTH_EMULATOR_HOST,delete s.VITE_FIREBASE_FIRESTORE_EMULATOR_HOST,delete s.VITE_FIREBASE_FUNCTIONS_EMULATOR_PORT),s.MODE=this.mode,s.DEV=this.mode==="development",s.PROD=this.mode==="production",s.SSR=!1,{env:s,mode:this.mode,source:`${t}/.env`,errors:[]}}catch(t){return{env:{},mode:this.mode,source:"error",errors:[t.message]}}}};function qi(e={}){return Ne({pluginName:"dndev-vite-env-discovery",icon:"\u{1F510}",virtualModuleId:V.env,discoveryMethod:"discoverEnv",filePatterns:[],templates:Gi,defaultInspectionPath:te.vite.envInspection,manifestFileName:te.manifests.env,configKey:"env",createDiscovery:(t,r)=>new Kr(t,{...r,mode:e.mode||r.mode||"development"})})({...e,disableHmr:!0})}me();import Qr from"node:fs";import yf from"node:path";re();var Wi=/--(?:font-family|font-headline)\s*:\s*(?:['"]([^'"]+)['"]|([^;]+?));/g,Ke=class{constructor(t,r={}){if(!t)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=t,this.options={debug:!1,customPatterns:{},...r},this.logger=r.logger||{debug:(s,...n)=>{this.options.debug}},this.patterns={selectors:{...yr.selectors,...this.options.customPatterns?.selectors},themes:{...yr.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(t){if(!t||typeof t!="string")return this._debug(`Invalid CSS variable: ${t}`),null;let r=t.replace(/^--/,"");if(!r)return this._debug(`Empty CSS variable after removing --: ${t}`),null;let s=r.split("-").filter(o=>o.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${t}`),null;let n=s.map((o,a)=>{let l=o.replace(/[^a-zA-Z0-9]/g,"");return l?a===0?l.toLowerCase():l.charAt(0).toUpperCase()+l.slice(1).toLowerCase():null}).filter(Boolean).join("");return!n||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(n)?(this._debug(`Invalid JavaScript identifier generated from ${t}: ${n}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(n)?`${n}Var`:n}_stripComments(t){return t.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(t,r,s){let n=[],i,o=this.pathResolver.normalizePath(r),a=this._stripComments(t),l=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(i=l.exec(a))!==null;){let[,u,f,d]=i;if(!u||!d)continue;let g=f.match(this.patterns.themes.themeIcon),m=f.match(this.patterns.themes.themeIsDark),P={name:u,displayName:d,isDark:m?m[1]==="1":!1,meta:{icon:g?.[1]},source:this.pathResolver.getBasename(r)};this._debug(`Discovered theme: ${u} (${d})`),n.push(P),s.themes.set(u,{name:u,displayName:d,isDark:P.isDark,file:o,variables:new Set,meta:P.meta})}return n.length>0&&this._debug(`Extracted ${n.length} themes from ${o}`),n}extractClasses(t,r){(t.match(this.patterns.selectors.class)||[]).forEach(n=>{let i=n.slice(1);i.startsWith("_")||r.classes.add(i)})}extractVariables(t,r,s){(t.match(this.patterns.selectors.variable)||[]).forEach(i=>{i.startsWith("--")&&i.length>2?s==="framework"?r.variables.framework.add(i):r.variables.consumer.add(i):this._debug(`Skipping invalid CSS variable: ${i}`)})}extractFontFamilies(t){if(!t||typeof t!="string")return[];let r=this._stripComments(t),s=new Set,n;for(Wi.lastIndex=0;(n=Wi.exec(r))!==null;){let i=n[1];i&&i.trim()&&s.add(i.trim())}return Array.from(s)}extractKeyframes(t,r){(t.match(this.patterns.selectors.keyframe)||[]).forEach(n=>{let i=n.replace("@keyframes","").trim();i&&r.keyframes.add(i)})}validateCSS(t){let r=[],s=t.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(i=>{r.push(`Possible malformed CSS variable: ${i}`)}),(t.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(i=>{if(!i.includes("--theme-label")&&i.includes("--")){let o=i.match(/\.([a-z][a-z0-9-]+)/)?.[1];o&&r.push(`Theme class "${o}" missing --theme-label`)}}),r}extractAll(t,r,s="consumer"){let n={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},i=this.extractThemes(t,r,n);this.extractClasses(t,n),this.extractVariables(t,n,s),this.extractKeyframes(t,n);let o=this.validateCSS(t);return{themes:i,classes:Array.from(n.classes),variables:{framework:Array.from(n.variables.framework),consumer:Array.from(n.variables.consumer),all:[...Array.from(n.variables.framework),...Array.from(n.variables.consumer)].sort()},keyframes:Array.from(n.keyframes),warnings:o}}getPatterns(){return{...this.patterns}}setPatterns(t){this.patterns={...this.patterns,...t,selectors:{...this.patterns.selectors,...t.selectors},themes:{...this.patterns.themes,...t.themes}}}_debug(t,r){this.logger.debug(t,r||"")}};re();var wf=3,Zr="<!-- DNDEV_FONT_PRELOADS -->";function Hi(e={}){let{debug:t=!1}=e,r=B("font-preload",t,!1),s,n={},i=[],o=[];return{name:"vite-font-preload-plugin",enforce:"post",configResolved(a){n={root:a.root,base:a.base&&a.base!=="/"?a.base.replace(/\/$/,""):"",outDir:a.build?.outDir??"dist"};try{s=G.getInstance()}catch(l){r.debug(`Font preload: PathResolver not ready: ${l?.message}`)}},async buildStart(){if(!(!s||!s.getAppRoot()))try{let l=await s.resolvePatterns("css"),{consumerFiles:u}=await s.resolveFiles(l,"css");if(!u?.length){i=[St.Inter],r.debug("Font preload: no consumer CSS, using default Inter");return}let f=new Ke(s,{debug:t,logger:r}),d=new Set;for(let m of u)try{let P=await s.read(m,{format:"text"});P&&f.extractFontFamilies(P).forEach(W=>d.add(W))}catch(P){r.debug(`Font preload: skip read ${m}: ${P?.message}`)}if(d.size===0){i=[St.Inter],r.debug("Font preload: no font families in CSS, using default Inter");return}let g=new Set;for(let m of d){let P=St[m];P&&g.add(P)}i=Array.from(g),r.debug(`Font preload: stems ${i.join(", ")} from CSS`)}catch(l){r.debug(`Font preload: discovery failed, use Inter: ${l?.message}`),i=[St.Inter]}},generateBundle(a,l){if(!i.length)return;let u=n.base||"",f=[];for(let[d,g]of Object.entries(l)){if(g.type!=="asset"||!d.endsWith(".woff2")&&!d.endsWith(".woff"))continue;let m=d.toLowerCase();if(i.some(U=>m.includes(U))){let U=u?`${u}/${d}`:`/${d}`;f.push(U)}}o=f.slice(0,wf)},writeBundle(){if(!o.length)return;let a=n.root||process.cwd(),l=n.outDir||"dist",u=yf.join(a,l,"index.html");try{if(!Qr.existsSync(u)){r.debug(`Font preload: index.html not found at ${u}`);return}let f=Qr.readFileSync(u,"utf8"),d=o.map(g=>`<link rel="preload" as="font" href="${g}" type="font/woff2" crossorigin="anonymous" />`).join(`
316
+ `);if(f.includes(Zr))f=f.replace(Zr,`${Zr}
317
+ ${d}`);else{let g=f.indexOf("<!-- Fonts:"),m=g!==-1?f.indexOf("-->",g)+3:f.indexOf("</head>");m!==-1&&(f=f.slice(0,m)+`
318
+ ${d}`+f.slice(m))}Qr.writeFileSync(u,f,"utf8"),r.debug(`Font preload: injected ${o.length} link(s)`)}catch(f){r.debug(`Font preload: write failed: ${f?.message}`)}}}}re();re();var ir=class extends Pe{constructor(t,r={}){super(t,{fallbackLanguage:"en",additionalPaths:[],...r})}_getDiscoveryType(){return"I18n"}async _getPatterns(){return await this.pathResolver.resolvePatterns("i18n")}_getPatternType(){return"i18n"}async _processFiles(t){let r=this.pathResolver.getAppRoot(),s=this.pathResolver.getRepoRoot();if(!r||r===s)throw this.logger.error(`I18n discovery: appRoot not properly set (appRoot: ${r}, repoRoot: ${s})`),new Error("App root not set before i18n discovery. Ensure configResolved hook has run.");this.logger.debug(`I18n discovery: appRoot=${r}, repoRoot=${s}`);let n=await this._getPatterns();this.logger.debug(`I18n patterns - eager: ${n.eager.length}, lazy: ${n.lazy.length}, framework eager: ${n.framework?.eager?.length||0}, framework lazy: ${n.framework?.lazy?.length||0}`),this.logger.debug(`isMonorepo: ${this.pathResolver.isMonorepo()}, repoRoot: ${this.pathResolver.getRepoRoot()}`);let i=Lt("i18n"),o=n.eager||[],a=n.lazy||[],l=(this.options.additionalPaths||[]).map(F=>{let z=F.endsWith(".json")?F:`${F}/*_*.json`;return this.pathResolver.resolveAppPath(z)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let u=n.framework?.eager||[],f=n.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${o.join(", ")}, lazy: ${a.join(", ")}, framework eager: ${u.join(", ")}, framework lazy: ${f.join(", ")}`),u.length===0&&f.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let d=this.pathResolver.normalizePath(r),g=this.pathResolver.normalizePath(s),m=(F,z)=>{let L=this.pathResolver.normalizePath(F),Z=this.pathResolver.normalizePath(z);return L.startsWith(Z)?L.slice(Z.length+1):L},P=o.map(F=>m(F,r)),W=[...a,...l].map(F=>m(F,r)),N=u.map(F=>m(F,s)),O=f.map(F=>m(F,s)),C={...i,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r},R=await this.pathResolver._globWithNormalization(P,C),k=await this.pathResolver._globWithNormalization(W,C),E={...i,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:i.ignore?.filter(F=>F!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(E.ignore)}`);let j=await this.pathResolver._globWithNormalization(N,E),M=await this.pathResolver._globWithNormalization(O,E);this.logger.debug(`Found ${R.length} eager, ${k.length} lazy, ${j.length} framework eager, ${M.length} framework lazy files`),j.length>0?this.logger.debug(`Framework eager files (first 3): ${j.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${u.join(", ")}`),M.length>0?this.logger.debug(`Framework lazy files (first 3): ${M.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${f.join(", ")}`);let ve=[...new Set([...R,...k,...j,...M])],I=new Set([...R,...j]),A={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},ie=new Map,Et=[...j,...M];for(let F of Et){let z=this._processTranslationFile(F,j.includes(F),r);if(z){let L=`${z.namespace}_${z.language}`;ie.set(L,z),A.allNamespaces.add(z.namespace),A.supportedLanguages.add(z.language),j.includes(F)&&A.eagerNamespaces.add(z.namespace)}}let ye=new Set;for(let F of ve){if(Et.includes(F))continue;let z=this._processTranslationFile(F,I.has(F),r);if(z){let{namespace:L,language:Z,importPath:Ze,content:oe}=z,Le=`${z.namespace}_${z.language}`;if(ie.has(Le)){let qe=ie.get(Le);z.content=this._mergeTranslations(qe.content,oe)}A.allNamespaces.add(L),A.supportedLanguages.add(Z),ye.add(Z),I.has(F)&&A.eagerNamespaces.add(L),A.mapping[L]||(A.mapping[L]={}),A.mapping[L][Z]=Ze,z.content&&(A.content[L]||(A.content[L]={}),A.content[L][Z]=z.content),A.files.push({path:F,relativePath:this.pathResolver.getRelativePath(F),namespace:L,language:Z,eager:I.has(F),size:z.content?JSON.stringify(z.content).length:0})}}for(let[F,z]of ie){let[L,Z]=F.split("_");(!A.mapping[L]||!A.mapping[L][Z])&&(A.mapping[L]||(A.mapping[L]={}),A.mapping[L][Z]=z.importPath,A.content[L]||(A.content[L]={}),A.content[L][Z]=z.content)}let ke=ye.size>0?[...ye].sort():[this.options.fallbackLanguage];return{mapping:A.mapping,content:A.content,eagerNamespaces:[...A.eagerNamespaces].sort(),allNamespaces:[...A.allNamespaces].sort(),supportedLanguages:ke,fallbackLanguage:this.options.fallbackLanguage,files:A.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],fallbackLanguage:this.options.fallbackLanguage,files:[],timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.allNamespaces?.length||0} namespaces, ${this.cache?.supportedLanguages?.length||0} languages`}async discover(t=!1){if(!t&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let r=Date.now();try{let s=await this._processFiles([]);this.cache={...s,timestamp:Date.now()};let n=Date.now()-r;return this.logger.debug(`Discovery completed in ${n}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){throw this.logger.error(`I18n discovery failed: ${s.message}`),s}}async discoverTranslations(t=!1){return await this.discover(t)}getMapping(){return this.cache?.mapping||{}}getLanguages(){return this.cache?.supportedLanguages||[this.options.fallbackLanguage]}getNamespaces(){return this.cache?.allNamespaces||["common"]}getEagerNamespaces(){return this.cache?.eagerNamespaces||[]}_processTranslationFile(t,r,s){let n=t.split("/").pop()||t.split("\\").pop()||"",i,o,a=n.match(/^([^_]+)_([^.]+)\.json$/);if(!a)return this.logger.debug(`Invalid translation file name format: ${n}`),null;if([,i,o]=a,!i||!o)return this.logger.debug(`Invalid namespace or language in file: ${n}`),null;let u="./"+this.pathResolver.getRelativePath(t).replace(/\\/g,"/"),f;try{if(f=this.pathResolver.readSync(t,{format:"json"}),!f)return this.logger.debug(`Could not read file: ${t}`),null}catch(d){return this.logger.debug(`Error parsing JSON from ${t}: ${d.message}`),null}return{namespace:i,language:o,importPath:u,content:f}}_mergeTranslations(t,r){let s={...t};for(let[n,i]of Object.entries(r))typeof i=="object"&&i!==null&&!Array.isArray(i)?s[n]=this._mergeTranslations(s[n]||{},i):s[n]=i;return s}};var Ef={isEmpty:e=>!e.mapping||Object.keys(e.mapping).length===0,generateModule:(e,t,r="i18n")=>{let{mapping:s,eagerNamespaces:n,supportedLanguages:i,fallbackLanguage:o,stats:a,content:l={}}=e,u={mapping:s,languages:i,eager:n,fallback:o,content:l,storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:a?.totalFiles||0,totalNamespaces:a?.totalNamespaces||0,totalLanguages:a?.totalLanguages||0,eagerNamespaces:a?.eagerNamespaces||0,generatedAt:new Date().toISOString()},debug:t};return`// ${V.i18n} - Generated by @donotdev/config
316
319
  // \u{1F680} STATIC INJECTION PATTERN - Zero Runtime Loading
317
320
  // Generated at: ${new Date().toISOString()}
318
321
 
319
322
  // ===== STATIC EXPORTS - IMMEDIATE AVAILABILITY =====
320
- export const I18N_CONFIG = ${JSON.stringify(f,null,2)};
323
+ export const I18N_CONFIG = ${JSON.stringify(u,null,2)};
321
324
  export const LANGUAGES = ${JSON.stringify(i,null,2)};
322
325
  export const FALLBACK_LANGUAGE = '${o}';
323
326
  export const EAGER_NAMESPACES = ${JSON.stringify(n,null,2)};
@@ -345,7 +348,7 @@ if (typeof globalThis !== 'undefined') {
345
348
  }
346
349
 
347
350
  // Add i18n plugin configuration
348
- globalThis._DNDEV_CONFIG_.${ne[r]} = i18nPluginConfig;
351
+ globalThis._DNDEV_CONFIG_.${le[r]} = i18nPluginConfig;
349
352
  }
350
353
 
351
354
  // ============================================================================
@@ -450,7 +453,7 @@ export default {
450
453
  getInlineContent,
451
454
  };
452
455
 
453
- `},generateEmpty:(e,t,r,s="i18n")=>{let n=r.fallbackLanguage||"en",i={mapping:{},languages:[n],eager:[],fallback:n,content:{},storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:0,totalNamespaces:0,totalLanguages:1,eagerNamespaces:0,generatedAt:new Date().toISOString()},debug:t};return`// ${W.i18n} - Empty i18n configuration
456
+ `},generateEmpty:(e,t,r,s="i18n")=>{let n=r.fallbackLanguage||"en",i={mapping:{},languages:[n],eager:[],fallback:n,content:{},storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:0,totalNamespaces:0,totalLanguages:1,eagerNamespaces:0,generatedAt:new Date().toISOString()},debug:t};return`// ${V.i18n} - Empty i18n configuration
454
457
  // No translation files found - using fallback configuration
455
458
  // Generated at: ${new Date().toISOString()}
456
459
 
@@ -468,7 +471,7 @@ if (typeof globalThis !== 'undefined') {
468
471
  };
469
472
  }
470
473
 
471
- globalThis._DNDEV_CONFIG_.${ne[s]} = i18nPluginConfig;
474
+ globalThis._DNDEV_CONFIG_.${le[s]} = i18nPluginConfig;
472
475
  }
473
476
 
474
477
  // Placeholder functions
@@ -570,7 +573,7 @@ export default {
570
573
  files: translationFiles,
571
574
  manifest: i18nManifest,
572
575
  };
573
- `},generateManifest:e=>({namespaces:e.stats?.totalNamespaces||0,languages:e.stats?.totalLanguages||0,fallbackLanguage:e.fallbackLanguage,eagerNamespaces:e.stats?.eagerNamespaces||0,platform:"vite",timestamp:Date.now()}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.supportedLanguages||[],n=Object.keys(e.mapping||{}).filter(i=>i!=="default").length||0;r&&r.info(`${t} I18n: ${s.length} languages, ${n} namespaces`)}},Yu=[e=>e.endsWith(".json")&&e.includes("locale"),e=>/[a-z]+_[a-z]{2}\.json$/i.test(e),e=>e.includes("/locales/")&&e.endsWith(".json")];function Di(e={}){return Se({pluginName:"dndev-vite-i18n-discovery",icon:"\u{1F310}",virtualModuleId:W.i18n,DiscoveryClass:Jt,discoveryMethod:"discoverTranslations",filePatterns:Yu,templates:Xu,defaultInspectionPath:Q.vite.i18nInspection,manifestFileName:Q.manifests.i18n,configKey:"i18n",discoveryOptions:{fallbackLanguage:e.fallbackLanguage||"en",...e}})({...e,hmrSmartDetection:!1})}function Ti(e={}){let t=[],r="";return{name:"dndev-optional-dep-resolver",enforce:"pre",configResolved(){let s=G.getInstance(),n=s.getAppRoot(),i=Xe.optionalFeatures||[];for(let o of i)s.resolvePackage(o,n)||t.push(o);r=s.getEmptyModulePath(),e.debug&&t.length>0},resolveId(s){return t.includes(s)?r:null}}}function zr(e){return!e||typeof e!="string"?null:e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0]}function Ku(e){return!e||typeof e!="string"?!1:!e.startsWith(".")&&!e.startsWith("/")&&!e.startsWith("\\")&&!e.startsWith("\0")}function Qu(e,t){if(!e||!t||!t.getRepoRoot())return!1;let s=e;e.startsWith("@fs/")&&(s=e.slice(4));let n=t.resolveRepoPath("packages"),i=t.normalizePath(s);return n&&i.startsWith(n)}function Zu(e,t){if(!e||!t)return null;let r=zr(e);if(!r)return null;let s=t.resolveAppPath(`node_modules/${r}`);return t.pathExists(s)?t.resolveAppPath(`node_modules/${e}`):null}function Ci(e,t,r){return!Ku(e)||!Qu(t,r)?null:Zu(e,r)}function Fi(e={}){let{debug:t=!1,verbose:r=!0}=e,s=M("peer-dependency-resolver",t,r);return{name:"dndev-peer-dependency-resolver",enforce:"pre",configResolved(n){let i=G.getInstance(),o=i.getAppRoot();if(!o){s.warn("App root not set, peer dependency resolution may fail");return}this.pathResolver=i,this.appRoot=o},resolveId(n,i){if(!i||!this.appRoot||!this.pathResolver)return null;if(Ci(n,i,this.pathResolver)){let a=zr(n),l=this.pathResolver.resolveAppPath(`node_modules/${n}`),f=this.pathResolver.resolveAppPath(`node_modules/${a}`);return this.pathResolver.pathExists(f)?n===a?((t||r)&&s.debug(`[PeerDeps] Resolving bare import "${n}" from app's node_modules: ${f}`),f):((t||r)&&s.debug(`[PeerDeps] Resolving subpath "${n}" from app's node_modules: ${l}`),l):(t&&s.debug(`[PeerDeps] Package directory not found: ${f}, skipping resolution`),null)}return null}}}import{VitePWA as ef}from"vite-plugin-pwa";var Xt=class extends be{constructor(t,r={}){super(t,{...r})}_getDiscoveryType(){return"PWA"}async _getPatterns(){return await this.pathResolver.resolvePatterns("pwa")}_getPatternType(){return"pwa"}async _processFiles(t){let{frameworkFiles:r,consumerFiles:s}=t,n=[...r,...s];this.logger.debug(`Processing ${n.length} PWA files`);let i=[];this.options.assetData?.pwaIcons&&(this.logger.debug(`Using ${this.options.assetData.pwaIcons.length} icons from AssetDiscovery`),i=[...this.options.assetData.pwaIcons]);let o=await this._analyzePWAFiles(n),a=o.filter(p=>p.type==="manifest"||p.type==="service-worker");i.push(...a);let l=o.filter(p=>p.type==="icon"),f=new Set(i.filter(p=>p.type==="icon").map(p=>p.path)),u=l.filter(p=>!f.has(p.path));i.push(...u);let g=this._generatePWAManifest(i);return{assets:i,manifest:g,totalFiles:n.length,timestamp:Date.now()}}_getEmptyResult(){return{assets:[],manifest:this._getDefaultManifest(),totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.assets?.length||0} PWA assets discovered`}async _analyzePWAFiles(t){let r=[];for(let s of t){let n=typeof s=="string"?{absolutePath:s,relativePath:this.pathResolver.getRelativePath(s),fileName:s.split("/").pop()||"",extension:(s.split(".").pop()||"").toLowerCase()}:s,i=await this._analyzePWAAsset(n);i&&r.push(i)}return r}async _analyzePWAAsset(t){let r=await this.pathResolver.read(t.absolutePath,{format:"text"});if(!r)return null;let s=t.relativePath,n=t.fileName;return n.includes("manifest.json")?this._parseManifestFile(r,s):n.includes("service-worker")||n.includes("sw.")?this._parseServiceWorkerFile(r,s):this._isPWAIcon(n)?this._parseIconFile(t,s):null}_parseManifestFile(t,r){try{let s=typeof t=="string"?JSON.parse(t):t;return{type:"manifest",path:r,content:s,size:typeof t=="string"?t.length:JSON.stringify(s).length}}catch(s){return this.logger.debug(`Failed to parse manifest: ${s.message}`),null}}_parseServiceWorkerFile(t,r){return{type:"service-worker",path:r,size:t.length,hasWorkbox:t.includes("workbox")}}_parseIconFile(t,r){let s=t.fileName,n=this._extractIconSize(s);return{type:"icon",path:r,size:n,format:t.extension,purpose:this._getIconPurpose(s)}}_isPWAIcon(t){return["icon","logo","apple-touch-icon","android-chrome","favicon"].some(s=>t.includes(s))}_extractIconSize(t){let r=t.match(/(\d+)x(\d+)/);return r?{width:parseInt(r[1]),height:parseInt(r[2])}:t.includes("favicon")?{width:32,height:32}:t.includes("apple-touch-icon")?{width:180,height:180}:t.includes("icon-192")?{width:192,height:192}:t.includes("icon-512")?{width:512,height:512}:{width:192,height:192}}_getIconPurpose(t){return t.includes("maskable")?"maskable":t.includes("apple-touch")?"apple-touch":t.includes("android-chrome")?"android":"any"}_generatePWAManifest(t){let r=t.filter(i=>i.type==="icon"),n=t.find(i=>i.type==="manifest")?.content||this._getDefaultManifest();return r.length>0&&(n.icons=r.map(i=>({src:`/${i.path}`,sizes:`${i.size.width}x${i.size.height}`,type:`image/${i.format}`,purpose:i.purpose}))),n}_getDefaultManifest(){let t=this.options?.app||{};return{name:t.name,short_name:t.shortName,description:t.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:[]}}generateManifestContent(t){let r=t.manifest||this._getDefaultManifest();return JSON.stringify(r,null,2)}generateServiceWorkerContent(t,r={}){let s=this._getWorkboxDefaults(r),n=r.backgroundSync!==!1&&r.backgroundSync,i=r.precacheManifest||[],o=JSON.stringify(i,null,2);return`// Generated by @donotdev/config - PWA Service Worker with Workbox
576
+ `},generateManifest:e=>({namespaces:e.stats?.totalNamespaces||0,languages:e.stats?.totalLanguages||0,fallbackLanguage:e.fallbackLanguage,eagerNamespaces:e.stats?.eagerNamespaces||0,platform:"vite",timestamp:Date.now()}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.supportedLanguages||[],n=Object.keys(e.mapping||{}).filter(i=>i!=="default").length||0;r&&r.info(`${t} I18n: ${s.length} languages, ${n} namespaces`)}},xf=[e=>e.endsWith(".json")&&e.includes("locale"),e=>/[a-z]+_[a-z]{2}\.json$/i.test(e),e=>e.includes("/locales/")&&e.endsWith(".json")];function Vi(e={}){return Ne({pluginName:"dndev-vite-i18n-discovery",icon:"\u{1F310}",virtualModuleId:V.i18n,DiscoveryClass:ir,discoveryMethod:"discoverTranslations",filePatterns:xf,templates:Ef,defaultInspectionPath:te.vite.i18nInspection,manifestFileName:te.manifests.i18n,configKey:"i18n",discoveryOptions:{fallbackLanguage:e.fallbackLanguage||"en",...e}})({...e,hmrSmartDetection:!1})}re();me();function Ji(e={}){let t=[],r="";return{name:"dndev-optional-dep-resolver",enforce:"pre",configResolved(){let s=G.getInstance(),n=s.getAppRoot(),i=tt.optionalFeatures||[];for(let o of i)s.resolvePackage(o,n)||t.push(o);r=s.getEmptyModulePath(),e.debug&&t.length>0},resolveId(s){return t.includes(s)?r:null}}}function es(e){return!e||typeof e!="string"?null:e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0]}function Pf(e){return!e||typeof e!="string"?!1:!e.startsWith(".")&&!e.startsWith("/")&&!e.startsWith("\\")&&!e.startsWith("\0")}function Sf(e,t){if(!e||!t||!t.getRepoRoot())return!1;let s=e;e.startsWith("@fs/")&&(s=e.slice(4));let n=t.resolveRepoPath("packages"),i=t.normalizePath(s);return n&&i.startsWith(n)}function Rf(e,t){if(!e||!t)return null;let r=es(e);if(!r)return null;let s=t.resolveAppPath(`node_modules/${r}`);return t.pathExists(s)?t.resolveAppPath(`node_modules/${e}`):null}function Xi(e,t,r){return!Pf(e)||!Sf(t,r)?null:Rf(e,r)}me();function Yi(e={}){let{debug:t=!1,verbose:r=!0}=e,s=B("peer-dependency-resolver",t,r);return{name:"dndev-peer-dependency-resolver",enforce:"pre",configResolved(n){let i=G.getInstance(),o=i.getAppRoot();if(!o){s.warn("App root not set, peer dependency resolution may fail");return}this.pathResolver=i,this.appRoot=o},resolveId(n,i){if(!i||!this.appRoot||!this.pathResolver)return null;if(Xi(n,i,this.pathResolver)){let a=es(n),l=this.pathResolver.resolveAppPath(`node_modules/${n}`),u=this.pathResolver.resolveAppPath(`node_modules/${a}`);return this.pathResolver.pathExists(u)?n===a?((t||r)&&s.debug(`[PeerDeps] Resolving bare import "${n}" from app's node_modules: ${u}`),u):((t||r)&&s.debug(`[PeerDeps] Resolving subpath "${n}" from app's node_modules: ${l}`),l):(t&&s.debug(`[PeerDeps] Package directory not found: ${u}, skipping resolution`),null)}return null}}}import{VitePWA as $f}from"vite-plugin-pwa";re();var or=class extends Pe{constructor(t,r={}){super(t,{...r})}_getDiscoveryType(){return"PWA"}async _getPatterns(){return await this.pathResolver.resolvePatterns("pwa")}_getPatternType(){return"pwa"}async _processFiles(t){let{frameworkFiles:r,consumerFiles:s}=t,n=[...r,...s];this.logger.debug(`Processing ${n.length} PWA files`);let i=[];this.options.assetData?.pwaIcons&&(this.logger.debug(`Using ${this.options.assetData.pwaIcons.length} icons from AssetDiscovery`),i=[...this.options.assetData.pwaIcons]);let o=await this._analyzePWAFiles(n),a=o.filter(g=>g.type==="manifest"||g.type==="service-worker");i.push(...a);let l=o.filter(g=>g.type==="icon"),u=new Set(i.filter(g=>g.type==="icon").map(g=>g.path)),f=l.filter(g=>!u.has(g.path));i.push(...f);let d=this._generatePWAManifest(i);return{assets:i,manifest:d,totalFiles:n.length,timestamp:Date.now()}}_getEmptyResult(){return{assets:[],manifest:this._getDefaultManifest(),totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.assets?.length||0} PWA assets discovered`}async _analyzePWAFiles(t){let r=[];for(let s of t){let n=typeof s=="string"?{absolutePath:s,relativePath:this.pathResolver.getRelativePath(s),fileName:s.split("/").pop()||"",extension:(s.split(".").pop()||"").toLowerCase()}:s,i=await this._analyzePWAAsset(n);i&&r.push(i)}return r}async _analyzePWAAsset(t){let r=await this.pathResolver.read(t.absolutePath,{format:"text"});if(!r)return null;let s=t.relativePath,n=t.fileName;return n.includes("manifest.json")?this._parseManifestFile(r,s):n.includes("service-worker")||n.includes("sw.")?this._parseServiceWorkerFile(r,s):this._isPWAIcon(n)?this._parseIconFile(t,s):null}_parseManifestFile(t,r){try{let s=typeof t=="string"?JSON.parse(t):t;return{type:"manifest",path:r,content:s,size:typeof t=="string"?t.length:JSON.stringify(s).length}}catch(s){return this.logger.debug(`Failed to parse manifest: ${s.message}`),null}}_parseServiceWorkerFile(t,r){return{type:"service-worker",path:r,size:t.length,hasWorkbox:t.includes("workbox")}}_parseIconFile(t,r){let s=t.fileName,n=this._extractIconSize(s);return{type:"icon",path:r,size:n,format:t.extension,purpose:this._getIconPurpose(s)}}_isPWAIcon(t){return["icon","logo","apple-touch-icon","android-chrome","favicon"].some(s=>t.includes(s))}_extractIconSize(t){let r=t.match(/(\d+)x(\d+)/);return r?{width:parseInt(r[1]),height:parseInt(r[2])}:t.includes("favicon")?{width:32,height:32}:t.includes("apple-touch-icon")?{width:180,height:180}:t.includes("icon-192")?{width:192,height:192}:t.includes("icon-512")?{width:512,height:512}:{width:192,height:192}}_getIconPurpose(t){return t.includes("maskable")?"maskable":t.includes("apple-touch")?"apple-touch":t.includes("android-chrome")?"android":"any"}_generatePWAManifest(t){let r=t.filter(i=>i.type==="icon"),n=t.find(i=>i.type==="manifest")?.content||this._getDefaultManifest();return r.length>0&&(n.icons=r.map(i=>({src:`/${i.path}`,sizes:`${i.size.width}x${i.size.height}`,type:`image/${i.format}`,purpose:i.purpose}))),n}_getDefaultManifest(){let t=this.options?.app||{};return{name:t.name,short_name:t.shortName,description:t.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:[]}}generateManifestContent(t){let r=t.manifest||this._getDefaultManifest();return JSON.stringify(r,null,2)}generateServiceWorkerContent(t,r={}){let s=this._getWorkboxDefaults(r),n=r.backgroundSync!==!1&&r.backgroundSync,i=r.precacheManifest||[],o=JSON.stringify(i,null,2);return`// Generated by @donotdev/config - PWA Service Worker with Workbox
574
577
  // Generated at ${new Date().toISOString()}
575
578
 
576
579
  importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
@@ -604,23 +607,23 @@ self.addEventListener('message', (event) => {
604
607
  self.addEventListener('activate', (event) => {
605
608
  event.waitUntil(self.clients.claim());
606
609
  });
607
- `}_getWorkboxDefaults(t={}){return{globPatterns:t.globPatterns||["**/*.{js,css,html,ico,png,svg,woff2}"],runtimeCaching:t.runtimeCaching||[{urlPattern:/^https:\/\/fonts\.googleapis\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/^https:\/\/fonts\.gstatic\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"gstatic-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/,handler:"StaleWhileRevalidate",options:{cacheName:"images-cache",expiration:{maxEntries:60,maxAgeSeconds:3600*24*30}}},{urlPattern:/\/api\/.*/i,handler:"NetworkFirst",options:{cacheName:"api-cache",expiration:{maxEntries:50,maxAgeSeconds:300},networkTimeoutSeconds:10}},{urlPattern:({request:r})=>r.destination==="document",handler:"NetworkFirst",options:{cacheName:"pages-cache",expiration:{maxEntries:32,maxAgeSeconds:3600*24},networkTimeoutSeconds:10}}],cleanupOutdatedCaches:t.cleanupOutdatedCaches!==!1,skipWaiting:t.skipWaiting!==!1,clientsClaim:t.clientsClaim!==!1,maximumFileSizeToCacheInBytes:t.maximumFileSizeToCacheInBytes||5*1024*1024,navigateFallback:t.navigateFallback||"/",navigateFallbackDenylist:t.navigateFallbackDenylist||[/^\/api\/.*/]}}_generateWorkboxRuntimeCaching(t,r={}){return t.map((s,n)=>{let{urlPattern:i,handler:o,options:a={}}=s,l=o==="CacheFirst"?"CacheFirst":o==="NetworkFirst"?"NetworkFirst":o==="StaleWhileRevalidate"?"StaleWhileRevalidate":"NetworkFirst",f;typeof i=="function"?f="({ request }) => request.destination === 'document'":i instanceof RegExp?f=i.toString():f=JSON.stringify(i);let u=[];a.expiration&&u.push(`new ExpirationPlugin({
610
+ `}_getWorkboxDefaults(t={}){return{globPatterns:t.globPatterns||["**/*.{js,css,html,ico,png,svg,woff2}"],runtimeCaching:t.runtimeCaching||[{urlPattern:/^https:\/\/fonts\.googleapis\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/^https:\/\/fonts\.gstatic\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"gstatic-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/,handler:"StaleWhileRevalidate",options:{cacheName:"images-cache",expiration:{maxEntries:60,maxAgeSeconds:3600*24*30}}},{urlPattern:/\/api\/.*/i,handler:"NetworkFirst",options:{cacheName:"api-cache",expiration:{maxEntries:50,maxAgeSeconds:300},networkTimeoutSeconds:10}},{urlPattern:({request:r})=>r.destination==="document",handler:"NetworkFirst",options:{cacheName:"pages-cache",expiration:{maxEntries:32,maxAgeSeconds:3600*24},networkTimeoutSeconds:10}}],cleanupOutdatedCaches:t.cleanupOutdatedCaches!==!1,skipWaiting:t.skipWaiting!==!1,clientsClaim:t.clientsClaim!==!1,maximumFileSizeToCacheInBytes:t.maximumFileSizeToCacheInBytes||5*1024*1024,navigateFallback:t.navigateFallback||"/",navigateFallbackDenylist:t.navigateFallbackDenylist||[/^\/api\/.*/]}}_generateWorkboxRuntimeCaching(t,r={}){return t.map((s,n)=>{let{urlPattern:i,handler:o,options:a={}}=s,l=o==="CacheFirst"?"CacheFirst":o==="NetworkFirst"?"NetworkFirst":o==="StaleWhileRevalidate"?"StaleWhileRevalidate":"NetworkFirst",u;typeof i=="function"?u="({ request }) => request.destination === 'document'":i instanceof RegExp?u=i.toString():u=JSON.stringify(i);let f=[];a.expiration&&f.push(`new ExpirationPlugin({
608
611
  maxEntries: ${a.expiration.maxEntries||50},
609
612
  maxAgeSeconds: ${a.expiration.maxAgeSeconds||3600*24},
610
- })`),a.cacheableResponse&&u.push(`new CacheableResponsePlugin({
613
+ })`),a.cacheableResponse&&f.push(`new CacheableResponsePlugin({
611
614
  statuses: ${JSON.stringify(a.cacheableResponse.statuses||[0,200])},
612
- })`),a.backgroundSync&&u.push(`new BackgroundSyncPlugin('${a.backgroundSync.queueName||"background-sync-queue"}', {
615
+ })`),a.backgroundSync&&f.push(`new BackgroundSyncPlugin('${a.backgroundSync.queueName||"background-sync-queue"}', {
613
616
  maxRetentionTime: ${a.backgroundSync.maxRetentionTime||1440},
614
- })`);let g="";return a.cacheName&&(g+=`
615
- cacheName: '${a.cacheName}',`),u.length>0&&(g+=`
617
+ })`);let d="";return a.cacheName&&(d+=`
618
+ cacheName: '${a.cacheName}',`),f.length>0&&(d+=`
616
619
  plugins: [
617
- ${u.join(`,
620
+ ${f.join(`,
618
621
  `)}
619
- ],`),a.networkTimeoutSeconds&&(g+=`
622
+ ],`),a.networkTimeoutSeconds&&(d+=`
620
623
  networkTimeoutSeconds: ${a.networkTimeoutSeconds},`),`// Runtime cache ${n+1}: ${a.cacheName||"cache-"+n}
621
624
  registerRoute(
622
- ${f},
623
- new ${l}({${g}
625
+ ${u},
626
+ new ${l}({${d}
624
627
  })
625
628
  );`}).join(`
626
629
 
@@ -638,7 +641,7 @@ registerRoute(
638
641
  }),
639
642
  'POST'
640
643
  );
641
- `}getPWAHeaders(){return[{source:"/manifest.json",headers:[{key:"Content-Type",value:"application/manifest+json"},{key:"Cache-Control",value:"public, max-age=3600"}]},{source:"/sw.js",headers:[{key:"Content-Type",value:"application/javascript"},{key:"Cache-Control",value:"no-cache"}]}]}getPWARewrites(){return{beforeFiles:[],afterFiles:[{source:"/sw.js",destination:"/sw.js"},{source:"/workbox-:path*",destination:"/workbox-:path*"}],fallback:[]}}async discoverNextBuildAssets(t=".next"){let r=this.pathResolver.resolveAppPath(`${t}/static`),s=this.pathResolver.resolveAppPath(`${t}/static/chunks`),n=this.pathResolver.resolveAppPath(`${t}/static/css`),i=[];try{let o=[`${r}/**/*.{js,css,woff2,woff,ttf,eot}`,`${s}/**/*.{js,css}`,`${n}/**/*.css`];for(let a of o){let l=await this.pathResolver.findFiles(this.pathResolver.getAppRoot(),a.replace(this.pathResolver.getAppRoot(),""),{onlyFiles:!0});for(let f of l){let u=this.pathResolver.getRelativePath(f);if(u.startsWith(`${t}/static/`)){let g=`/_next/${u.replace(`${t}/static/`,"")}`;i.push({url:g,revision:null})}}}}catch(o){this.logger?.warn(`Failed to discover Next.js build assets: ${o.message}`)}return i}generatePrecacheManifest(t=[],r=null){let s=t;return r&&typeof r=="function"&&(s=r(s)),s}async discoverPWAAssets(t=!1){return await this.discover(t)}getPWAAssets(){return this.cache?.assets||[]}getPWAManifest(){return this.cache?.manifest||this._getDefaultManifest()}};function Oi(e={}){if(!e.enabled)return null;let t=e.app||{},r=[];if(t.name||r.push("name"),t.shortName||r.push("shortName"),t.description||r.push("description"),r.length>0){let u=M("PWA",e.debug,!0);u.warn(`\u26A0\uFE0F PWA is enabled but appConfig.app is missing required fields: ${r.join(", ")}`),u.warn(" Add these to your src/config/app.ts:"),u.warn(" export const appConfig: AppConfig = {"),u.warn(" app: {"),t.name||u.warn(' name: "Your App Name",'),t.shortName||u.warn(' shortName: "App",'),t.description||u.warn(' description: "Your app description",'),u.warn(" },"),u.warn(" // ... rest of config"),u.warn(" };"),u.warn("")}let s=G.getInstance(),n=Or.data;if(!n)try{let u=s.resolveAppPath(Q.vite.assetInspection);s.pathExists(u)}catch{}let i=new Xt(s,{...e,assetData:n}),o=e.devEnabled===!0,a={registerType:e.registerType||"prompt",includeAssets:["favicon.ico","favicon.svg","apple-touch-icon.png"],manifest:async()=>{let u=e.app||{},p=(await i.discoverPWAAssets()).assets.filter(m=>m.type==="icon").map(m=>({src:`/${m.path}`,sizes:`${m.size.width}x${m.size.height}`,type:`image/${m.format}`,purpose:m.purpose}));return{name:u.name,short_name:u.shortName,description:u.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:p.length>0?p:[]}},workbox:{globPatterns:["**/*.{js,css,html,ico,png,svg,woff2}"],runtimeCaching:[{urlPattern:/^https:\/\/fonts\.googleapis\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/^https:\/\/fonts\.gstatic\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"gstatic-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/,handler:"StaleWhileRevalidate",options:{cacheName:"images-cache",expiration:{maxEntries:60,maxAgeSeconds:3600*24*30}}},{urlPattern:/\/api\/.*/i,handler:"NetworkFirst",options:{cacheName:"api-cache",expiration:{maxEntries:50,maxAgeSeconds:300},networkTimeoutSeconds:10}},{urlPattern:({request:u})=>u.destination==="document",handler:"NetworkFirst",options:{cacheName:"pages-cache",expiration:{maxEntries:32,maxAgeSeconds:3600*24},networkTimeoutSeconds:10}}],cleanupOutdatedCaches:!0,skipWaiting:!0,clientsClaim:!0,maximumFileSizeToCacheInBytes:5*1024*1024,navigateFallback:"/index.html",navigateFallbackDenylist:[/^\/api\/.*/],manifestTransforms:[u=>{let g=u.find(p=>p.url==="/index.html"||p.url==="index.html");return g&&!u.find(p=>p.url==="/")&&u.push({url:"/",revision:g.revision}),{manifest:u,warnings:[]}}]},devOptions:{enabled:o,type:"module"}},f={...a,manifest:async()=>{let u=await a.manifest();if(e.manifest){if(typeof e.manifest=="function"){let g=await e.manifest();return{...u,...g}}return{...u,...e.manifest}}return u},workbox:{...a.workbox,...e.workbox||{},runtimeCaching:[...a.workbox.runtimeCaching,...e.workbox?.runtimeCaching||[]],manifestTransforms:[...a.workbox.manifestTransforms||[],...e.workbox?.manifestTransforms||[]]}};return ef(f)}function ji(e,t="unknown"){try{let r=/export\s+const\s+meta\s*[^=]*=\s*(\{[\s\S]*?\});/,s=e.match(r);if(!s)return null;let n=s[1];n=n.replace(/icon:\s*<(\w+)[\s\/][^>]*\/?>/g,(l,f)=>`icon: '${f}'`);let i=/(?:export\s+)?const\s+(\w+)\s*=\s*['"]([^'"]+)['"]/g;return[...e.matchAll(i)].forEach(l=>{let f=l[1],u=l[2];n=n.replace(new RegExp(`\\b${f}\\b`,"g"),`'${u}'`)}),Function(`return ${n}`)()}catch{return null}}var Pt=null,Li=null;function tf(e){let r=(e.split("/").pop()?.replace(/\.tsx?$/,"")||"Component").replace(/[^a-zA-Z0-9]/g,"");return r.charAt(0).toUpperCase()+r.slice(1)}var Yt=class extends be{constructor(t,r={}){super(t,{additionalPatterns:[],...r}),this.routes=[],this.errors=[],this.source="auto-discovery"}_getDiscoveryType(){return"Route"}async _getPatterns(){return await this.pathResolver.resolvePatterns("routes")}_getPatternType(){return"routes"}async _processFiles(t){let r=this.pathResolver.getAppRoot(),s=process.env.DNDEV_BUILD_ID;if(Pt&&Li===s)return this.logger.debug("Using cached route discovery results"),this.routes=Pt.routes,this.errors=Pt.errors,this.source=Pt.source,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length};if(this.logger.debug("Route discovery mode: AUTO-DISCOVERY"),this.logger.debug(`App root: ${r}`),this.options.debug){let n=t?.consumerFiles?.length||0;this.logger.debug(`\u{1F50D} Route discovery: Scanning ${n} files in ${r}`);let i=await this._getPatterns();this.logger.debug(`Patterns: ${JSON.stringify(i)}`)}return await this._performAutoDiscovery(t,r),this.options.debug&&this.logger.debug(`\u{1F50D} Route discovery: Found ${this.routes.length} routes`),this.routes.length===0&&this.logger.warn("\u26A0\uFE0F No routes discovered! Check that pages exist in src/pages/"),Pt={routes:this.routes,errors:this.errors,source:this.source},Li=process.env.DNDEV_BUILD_ID,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length}}_getEmptyResult(){return{routes:[],errors:[],source:"empty",totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.routes?.length||0} routes discovered via ${this.cache?.source||"unknown"}`}async discoverRoutes(t=!1){return await this.discover(t)}getRoutes(){return this.cache?.routes||[]}async _performAutoDiscovery(t,r){let{consumerFiles:s}=t,n=await this._batchProcessFiles(s,f=>this._analyzePageFile(f,r)),i=await this._scanAdditionalPatterns(r),o=await this._batchProcessFiles(i,f=>this._analyzePageFile(f,r)),a=[...n,...o];this.logger.debug(`Auto-discovering from ${s.length} app + ${i.length} additional files`),this.routes=a.filter(f=>f.path==="home"||f.path==="/home"?(this.logger.debug(`Filtered reserved route: ${f.path} - Use root "/" instead (${f.file})`),!1):!0);let l=new Map;for(let f of this.routes){let u=f.path;if(l.has(u)){let g=l.get(u);throw new Error(`Route conflict: Multiple routes found for path '${u}'. Routes: ${g.file} and ${f.file}. Use PageMeta route override to specify unique paths. Example: export const meta: PageMeta = { route: '/custom-path' };`)}l.set(u,f)}this.logger.debug(`Auto-discovered ${this.routes.length} routes from ${s.length+i.length} files`)}async _scanAdditionalPatterns(t){let r=this.options.additionalPatterns.map(s=>this.pathResolver.resolveAppPath(s));if(r.length===0)return[];try{let{consumerFiles:s}=await this.pathResolver.resolveFiles({consumer:r,framework:[]},"routes");return s}catch(s){return this.logger.debug(`Error scanning additional patterns: ${s.message}`),[]}}async _analyzePageFile(t,r){let s=await this.pathResolver.read(t.absolutePath,{format:"text"});if(!s)return null;let n=t.relativePath,i="/src/"+n.replace(/\\/g,"/");i=i.replace(/src\/src\//g,"src/").replace(/src\/src\//g,"src/");let o=this._extractMetaExport(s,t.absolutePath),a=tf(i),f=a===rr.HOMEPAGE_COMPONENT?rr.HOMEPAGE_PATH:this._resolveRoutePath(o,n,t.absolutePath),u=this._extractPageMeta(n,s),{entity:g,action:p,...m}=o||{};return{path:f,component:a,importPath:i,auth:o?.auth||!1,meta:{...u,...m,entity:u.entity,action:u.action},metaExport:o,file:n}}_extractMetaExport(t,r){try{let s=ji(t,r);return s?(this.logger.debug(`Extracted meta export from ${r}: ${JSON.stringify(s)}`),s):null}catch(s){return this.logger.debug(`Error parsing meta export from ${r}: ${s.message}`),null}}_generateRoutePath(t){let r=t.replace(/\.tsx$/,"").replace(/Page$/,"").replace(/^src\//,"").replace(/^pages\//,"").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return(r.endsWith("/index")||r==="index")&&(r=r.replace(/\/index$/,"")||"/"),r==="/"?"/":"/"+r.replace(/\/+/g,"/")}_resolveRoutePath(t,r,s){if(!t?.route)return this._generateRoutePath(r);if(typeof t.route=="string"){let n=t.route.trim();return n==="/"?"/":(n=n.replace(/\/+/g,"/"),n.startsWith("/")||(n="/"+n),n)}if(typeof t.route=="object"&&t.route!==null){let n=this._generateRoutePath(r),i=t.route.params;if(Array.isArray(i)&&i.length>0){let o=i.map(a=>`:${a}`).join("/");return`${n}/${o}`}return n}return this.logger.warn(`Invalid route format in ${s}. Use string format: route: "/path/:param" or object format: route: { params: ['id'] }`),this.logger.debug(`Falling back to auto-generated path for ${s}`),this._generateRoutePath(r)}_extractPageMeta(t,r){let s=t.split("/").pop()?.replace(".tsx","")||"",n=s.replace(/Page$/,"");n=n.replace(/([A-Z])/g," $1").trim(),n=n.charAt(0).toUpperCase()+n.slice(1);let i=t.split("/"),o=null,a=null;return i.length>1&&(o=i[i.length-2],s.includes("List")?a="list":s.includes("Form")||s.includes("Create")||s.includes("Edit")?a="form":(s.includes("Detail")||s.includes("View"))&&(a="detail")),{title:n,entity:o,action:a,file:t}}};var rf={isEmpty:e=>!e.routes||e.routes.length===0,generateModule:(e,t,r="routes")=>{let s={totalRoutes:e.routes.length,authRequired:e.routes.filter(i=>i.auth&&i.auth.required).length,publicRoutes:e.routes.filter(i=>!i.auth||i.auth===!1).length,source:e.source,generatedAt:new Date().toISOString(),errors:e.errors.length},n=e.routes.map(i=>` {
644
+ `}getPWAHeaders(){return[{source:"/manifest.json",headers:[{key:"Content-Type",value:"application/manifest+json"},{key:"Cache-Control",value:"public, max-age=3600"}]},{source:"/sw.js",headers:[{key:"Content-Type",value:"application/javascript"},{key:"Cache-Control",value:"no-cache"}]}]}getPWARewrites(){return{beforeFiles:[],afterFiles:[{source:"/sw.js",destination:"/sw.js"},{source:"/workbox-:path*",destination:"/workbox-:path*"}],fallback:[]}}async discoverNextBuildAssets(t=".next"){let r=this.pathResolver.resolveAppPath(`${t}/static`),s=this.pathResolver.resolveAppPath(`${t}/static/chunks`),n=this.pathResolver.resolveAppPath(`${t}/static/css`),i=[];try{let o=[`${r}/**/*.{js,css,woff2,woff,ttf,eot}`,`${s}/**/*.{js,css}`,`${n}/**/*.css`];for(let a of o){let l=await this.pathResolver.findFiles(this.pathResolver.getAppRoot(),a.replace(this.pathResolver.getAppRoot(),""),{onlyFiles:!0});for(let u of l){let f=this.pathResolver.getRelativePath(u);if(f.startsWith(`${t}/static/`)){let d=`/_next/${f.replace(`${t}/static/`,"")}`;i.push({url:d,revision:null})}}}}catch(o){this.logger?.warn(`Failed to discover Next.js build assets: ${o.message}`)}return i}generatePrecacheManifest(t=[],r=null){let s=t;return r&&typeof r=="function"&&(s=r(s)),s}async discoverPWAAssets(t=!1){return await this.discover(t)}getPWAAssets(){return this.cache?.assets||[]}getPWAManifest(){return this.cache?.manifest||this._getDefaultManifest()}};me();function Ki(e={}){if(!e.enabled)return null;let t=e.app||{},r=[];if(t.name||r.push("name"),t.shortName||r.push("shortName"),t.description||r.push("description"),r.length>0){let f=B("PWA",e.debug,!0);f.warn(`\u26A0\uFE0F PWA is enabled but appConfig.app is missing required fields: ${r.join(", ")}`),f.warn(" Add these to your src/config/app.ts:"),f.warn(" export const appConfig: AppConfig = {"),f.warn(" app: {"),t.name||f.warn(' name: "Your App Name",'),t.shortName||f.warn(' shortName: "App",'),t.description||f.warn(' description: "Your app description",'),f.warn(" },"),f.warn(" // ... rest of config"),f.warn(" };"),f.warn("")}let s=G.getInstance(),n=Yr.data;if(!n)try{let f=s.resolveAppPath(te.vite.assetInspection);s.pathExists(f)}catch{}let i=new or(s,{...e,assetData:n}),o=e.devEnabled===!0,a={registerType:e.registerType||"prompt",includeAssets:["favicon.ico","favicon.svg","apple-touch-icon.png"],manifest:async()=>{let f=e.app||{},g=(await i.discoverPWAAssets()).assets.filter(m=>m.type==="icon").map(m=>({src:`/${m.path}`,sizes:`${m.size.width}x${m.size.height}`,type:`image/${m.format}`,purpose:m.purpose}));return{name:f.name,short_name:f.shortName,description:f.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:g.length>0?g:[]}},workbox:{globPatterns:["**/*.{js,css,html,ico,png,svg,woff2}"],runtimeCaching:[{urlPattern:/^https:\/\/fonts\.googleapis\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/^https:\/\/fonts\.gstatic\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"gstatic-fonts-cache",expiration:{maxEntries:10,maxAgeSeconds:3600*24*365},cacheableResponse:{statuses:[0,200]}}},{urlPattern:/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/,handler:"StaleWhileRevalidate",options:{cacheName:"images-cache",expiration:{maxEntries:60,maxAgeSeconds:3600*24*30}}},{urlPattern:/\/api\/.*/i,handler:"NetworkFirst",options:{cacheName:"api-cache",expiration:{maxEntries:50,maxAgeSeconds:300},networkTimeoutSeconds:10}},{urlPattern:({request:f})=>f.destination==="document",handler:"NetworkFirst",options:{cacheName:"pages-cache",expiration:{maxEntries:32,maxAgeSeconds:3600*24},networkTimeoutSeconds:10}}],cleanupOutdatedCaches:!0,skipWaiting:!0,clientsClaim:!0,maximumFileSizeToCacheInBytes:5*1024*1024,navigateFallback:"/index.html",navigateFallbackDenylist:[/^\/api\/.*/],manifestTransforms:[f=>{let d=f.find(g=>g.url==="/index.html"||g.url==="index.html");return d&&!f.find(g=>g.url==="/")&&f.push({url:"/",revision:d.revision}),{manifest:f,warnings:[]}}]},devOptions:{enabled:o,type:"module"}},u={...a,manifest:async()=>{let f=await a.manifest();if(e.manifest){if(typeof e.manifest=="function"){let d=await e.manifest();return{...f,...d}}return{...f,...e.manifest}}return f},workbox:{...a.workbox,...e.workbox||{},runtimeCaching:[...a.workbox.runtimeCaching,...e.workbox?.runtimeCaching||[]],manifestTransforms:[...a.workbox.manifestTransforms||[],...e.workbox?.manifestTransforms||[]]}};return $f(u)}re();re();function Qi(e,t="unknown"){try{let r=/export\s+const\s+meta\s*[^=]*=\s*(\{[\s\S]*?\});/,s=e.match(r);if(!s)return null;let n=s[1];n=n.replace(/icon:\s*<(\w+)[\s\/][^>]*\/?>/g,(l,u)=>`icon: '${u}'`);let i=/(?:export\s+)?const\s+(\w+)\s*=\s*['"]([^'"]+)['"]/g;return[...e.matchAll(i)].forEach(l=>{let u=l[1],f=l[2];n=n.replace(new RegExp(`\\b${u}\\b`,"g"),`'${f}'`)}),Function(`return ${n}`)()}catch{return null}}var Nt=null,Zi=null;function kf(e){let r=(e.split("/").pop()?.replace(/\.tsx?$/,"")||"Component").replace(/[^a-zA-Z0-9]/g,"");return r.charAt(0).toUpperCase()+r.slice(1)}var ar=class extends Pe{constructor(t,r={}){super(t,{additionalPatterns:[],...r}),this.routes=[],this.errors=[],this.source="auto-discovery"}_getDiscoveryType(){return"Route"}async _getPatterns(){return await this.pathResolver.resolvePatterns("routes")}_getPatternType(){return"routes"}async _processFiles(t){let r=this.pathResolver.getAppRoot(),s=process.env.DNDEV_BUILD_ID;if(Nt&&Zi===s)return this.logger.debug("Using cached route discovery results"),this.routes=Nt.routes,this.errors=Nt.errors,this.source=Nt.source,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length};if(this.logger.debug("Route discovery mode: AUTO-DISCOVERY"),this.logger.debug(`App root: ${r}`),this.options.debug){let n=t?.consumerFiles?.length||0;this.logger.debug(`\u{1F50D} Route discovery: Scanning ${n} files in ${r}`);let i=await this._getPatterns();this.logger.debug(`Patterns: ${JSON.stringify(i)}`)}return await this._performAutoDiscovery(t,r),this.options.debug&&this.logger.debug(`\u{1F50D} Route discovery: Found ${this.routes.length} routes`),this.routes.length===0&&this.logger.warn("\u26A0\uFE0F No routes discovered! Check that pages exist in src/pages/"),Nt={routes:this.routes,errors:this.errors,source:this.source},Zi=process.env.DNDEV_BUILD_ID,{routes:this.routes,errors:this.errors,source:this.source,totalFiles:this.routes.length}}_getEmptyResult(){return{routes:[],errors:[],source:"empty",totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.routes?.length||0} routes discovered via ${this.cache?.source||"unknown"}`}async discoverRoutes(t=!1){return await this.discover(t)}getRoutes(){return this.cache?.routes||[]}async _performAutoDiscovery(t,r){let{consumerFiles:s}=t,n=await this._batchProcessFiles(s,u=>this._analyzePageFile(u,r)),i=await this._scanAdditionalPatterns(r),o=await this._batchProcessFiles(i,u=>this._analyzePageFile(u,r)),a=[...n,...o];this.logger.debug(`Auto-discovering from ${s.length} app + ${i.length} additional files`),this.routes=a.filter(u=>u.path==="home"||u.path==="/home"?(this.logger.debug(`Filtered reserved route: ${u.path} - Use root "/" instead (${u.file})`),!1):!0);let l=new Map;for(let u of this.routes){let f=u.path;if(l.has(f)){let d=l.get(f);throw new Error(`Route conflict: Multiple routes found for path '${f}'. Routes: ${d.file} and ${u.file}. Use PageMeta route override to specify unique paths. Example: export const meta: PageMeta = { route: '/custom-path' };`)}l.set(f,u)}this.logger.debug(`Auto-discovered ${this.routes.length} routes from ${s.length+i.length} files`)}async _scanAdditionalPatterns(t){let r=this.options.additionalPatterns.map(s=>this.pathResolver.resolveAppPath(s));if(r.length===0)return[];try{let{consumerFiles:s}=await this.pathResolver.resolveFiles({consumer:r,framework:[]},"routes");return s}catch(s){return this.logger.debug(`Error scanning additional patterns: ${s.message}`),[]}}async _analyzePageFile(t,r){let s=await this.pathResolver.read(t.absolutePath,{format:"text"});if(!s)return null;let n=t.relativePath,i="/src/"+n.replace(/\\/g,"/");i=i.replace(/src\/src\//g,"src/").replace(/src\/src\//g,"src/");let o=this._extractMetaExport(s,t.absolutePath),a=kf(i),u=a===mr.HOMEPAGE_COMPONENT?mr.HOMEPAGE_PATH:this._resolveRoutePath(o,n,t.absolutePath),f=this._extractPageMeta(n,s),{entity:d,action:g,...m}=o||{};return{path:u,component:a,importPath:i,auth:o?.auth||!1,meta:{...f,...m,entity:f.entity,action:f.action},metaExport:o,file:n}}_extractMetaExport(t,r){try{let s=Qi(t,r);return s?(this.logger.debug(`Extracted meta export from ${r}: ${JSON.stringify(s)}`),s):null}catch(s){return this.logger.debug(`Error parsing meta export from ${r}: ${s.message}`),null}}_generateRoutePath(t){let r=t.replace(/\.tsx$/,"").replace(/Page$/,"").replace(/^src\//,"").replace(/^pages\//,"").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return(r.endsWith("/index")||r==="index")&&(r=r.replace(/\/index$/,"")||"/"),r==="/"?"/":"/"+r.replace(/\/+/g,"/")}_resolveRoutePath(t,r,s){if(!t?.route)return this._generateRoutePath(r);if(typeof t.route=="string"){let n=t.route.trim();return n==="/"?"/":(n=n.replace(/\/+/g,"/"),n.startsWith("/")||(n="/"+n),n)}if(typeof t.route=="object"&&t.route!==null){let n=this._generateRoutePath(r),i=t.route.params;if(Array.isArray(i)&&i.length>0){let o=i.map(a=>`:${a}`).join("/");return`${n}/${o}`}return n}return this.logger.warn(`Invalid route format in ${s}. Use string format: route: "/path/:param" or object format: route: { params: ['id'] }`),this.logger.debug(`Falling back to auto-generated path for ${s}`),this._generateRoutePath(r)}_extractPageMeta(t,r){let s=t.split("/").pop()?.replace(".tsx","")||"",n=s.replace(/Page$/,"");n=n.replace(/([A-Z])/g," $1").trim(),n=n.charAt(0).toUpperCase()+n.slice(1);let i=t.split("/"),o=null,a=null;return i.length>1&&(o=i[i.length-2],s.includes("List")?a="list":s.includes("Form")||s.includes("Create")||s.includes("Edit")?a="form":(s.includes("Detail")||s.includes("View"))&&(a="detail")),{title:n,entity:o,action:a,file:t}}};var Af={isEmpty:e=>!e.routes||e.routes.length===0,generateModule:(e,t,r="routes")=>{let s={totalRoutes:e.routes.length,authRequired:e.routes.filter(i=>i.auth&&i.auth.required).length,publicRoutes:e.routes.filter(i=>!i.auth||i.auth===!1).length,source:e.source,generatedAt:new Date().toISOString(),errors:e.errors.length},n=e.routes.map(i=>` {
642
645
  path: '${i.path}',
643
646
  component: () => import('${i.importPath}'),
644
647
  auth: ${JSON.stringify(i.auth,null,2).replace(/\n/g,`
@@ -647,7 +650,7 @@ registerRoute(
647
650
  `)}
648
651
  }`).join(`,
649
652
  `);return`
650
- // ${W.routes} - Generated route data
653
+ // ${V.routes} - Generated route data
651
654
  import { lazy } from 'react';
652
655
 
653
656
  const routeData = [
@@ -669,7 +672,7 @@ if (typeof globalThis !== 'undefined') {
669
672
  }
670
673
 
671
674
  // Include all routes in mapping (navigation store will filter by hideFromMenu)
672
- globalThis._DNDEV_CONFIG_.${ne[r]} = {
675
+ globalThis._DNDEV_CONFIG_.${le[r]} = {
673
676
  mapping: routeData,
674
677
  manifest: {
675
678
  totalRoutes: ${e.routes.length},
@@ -687,7 +690,7 @@ export const source = '${e.source}';
687
690
 
688
691
  export default { routes: routeData, manifest: routeManifest, source: '${e.source}' };
689
692
  `},generateEmpty:(e,t,r,s="routes")=>{let n={totalRoutes:0,authRequired:0,publicRoutes:0,source:"empty",generatedAt:new Date().toISOString()};return`
690
- // ${W.routes} - Empty route data
693
+ // ${V.routes} - Empty route data
691
694
 
692
695
  const routeData = [];
693
696
  const routeManifest = ${JSON.stringify(n,null,2)};
@@ -706,7 +709,7 @@ if (typeof globalThis !== 'undefined') {
706
709
  }
707
710
 
708
711
  // Populate empty routes configuration
709
- globalThis._DNDEV_CONFIG_.${ne[s]} = {
712
+ globalThis._DNDEV_CONFIG_.${le[s]} = {
710
713
  mapping: [],
711
714
  manifest: {
712
715
  totalRoutes: 0,
@@ -751,7 +754,7 @@ export default discoveredRoutes;
751
754
  * Generated Route Discovery Results
752
755
  * Source: ${e.source}
753
756
  * Generated at: ${new Date().toISOString()}
754
- * Import from '${W.routes}'
757
+ * Import from '${V.routes}'
755
758
  */
756
759
 
757
760
  export const discoveredRoutes = [
@@ -765,7 +768,7 @@ export const routeManifest = {
765
768
  };
766
769
 
767
770
  export default discoveredRoutes;
768
- `},generateManifest:e=>({routes:e?.routes?.length||0,source:e?.source||"unknown",timestamp:Date.now(),errors:e?.errors?.length||0}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.routes||[],n=s.filter(o=>o.auth&&o.auth.required).length,i=s.length;r&&r.info(`${t} Routes: ${i} found${n>0?`, ${n} are authguarded`:""}`)}},sf=[e=>e.endsWith("Page.tsx")];function Mi(e={}){return Se({pluginName:"dndev-vite-route-discovery",icon:"\u{1F6E3}\uFE0F",virtualModuleId:W.routes,DiscoveryClass:Yt,discoveryMethod:"discoverRoutes",filePatterns:sf,templates:rf,defaultInspectionPath:Q.vite.routeInspection,manifestFileName:Q.manifests.route,configKey:"routes"})({...e,disableHmr:e?.hmr===!1,hmrSmartDetection:!1})}import{loadEnv as lf}from"vite";import{readFileSync as nf,readdirSync as of,existsSync as af}from"fs";import{join as zi}from"path";var Kt=class{constructor(t={}){let{debug:r=!1,generateRobotsTxt:s=!0,generateSitemap:n=!0,baseUrl:i,siteName:o,crawlDelay:a=1,routes:l={},...f}=t;if(!i||!o)throw new Error("SEOGenerator requires baseUrl and siteName options");this.options={debug:r,generateRobotsTxt:s,generateSitemap:n,baseUrl:i,siteName:o,crawlDelay:a,routes:l,defaultImage:"/og-image.jpg",twitterHandle:"@donotdev",defaultAuthor:"DNDev Team",defaultLanguage:"en",staticTags:{},...f},this.appRoot=f.appRoot||null,this.logger=M("SEO Generator",t.debug,t.verbose)}async generateSEOFiles(t,r,s=null){try{let n=this.generateRouteMetaTags(t.routes||[]),i={routes:t.routes||[],routeMetaTags:n,baseUrl:this.options.baseUrl,siteName:this.options.siteName},o=this.discoverBlogPosts(),a={robotsTxt:null,sitemap:null,rss:null,manifest:null,totalRoutes:i.routes.length,publicRoutes:i.routes.filter(l=>!l.auth||l.auth===!1).length,protectedRoutes:i.routes.filter(l=>l.auth&&l.auth.required).length,blogPosts:o.length};return this.options.generateRobotsTxt&&(a.robotsTxt=await this.generateRobotsTxt(i,r,s)),this.options.generateSitemap&&(a.sitemap=await this.generateSitemap(i,r,s,o)),o.length>0&&(a.rss=await this.generateRSSFeed(o,r,s)),a.manifest=await this.generateManifest(i,r,s),a}catch(n){throw this.logger.error(`SEO generator failed to create files (robots.txt/sitemap.xml/manifest): ${n.message}`),this.logger.error(`Stack: ${n.stack||"No stack trace available"}`),n}}async generateRobotsTxt(t,r,s=null){if(s&&await s("robots.txt"))return this.logger.info("\u2705 robots.txt already exists, skipping generation"),{fileName:"robots.txt",skipped:!0};let n=[];(t.routes||[]).forEach(o=>{if(o.auth&&o.auth.required){let a=o.path.startsWith("/")?o.path:`/${o.path}`;n.push(a)}}),n.push("/admin","/api","/_next","/static");let i=this.generateRobotsTxtContent({disallowedPaths:[...new Set(n)],sitemap:`${this.options.baseUrl}/sitemap.xml`,crawlDelay:this.options.crawlDelay});return await r("robots.txt",i),{fileName:"robots.txt",content:i,disallowedPaths:n.length}}async generateSitemap(t,r,s=null,n=[]){if(s&&await s("sitemap.xml"))return this.logger.info("\u2705 sitemap.xml already exists, skipping generation"),{fileName:"sitemap.xml",skipped:!0};let o=(t.routes||[]).filter(l=>!l.auth||l.auth===!1).map(l=>({url:l.path,lastmod:new Date().toISOString().split("T")[0],changefreq:"weekly",priority:l.path==="/"?"1.0":"0.8"}));if(n.length>0){o.push({url:"/blog",lastmod:n[0]?.date||new Date().toISOString().split("T")[0],changefreq:"weekly",priority:"0.7"});for(let l of n)o.push({url:`/blog/${l.slug}`,lastmod:l.date,changefreq:"monthly",priority:"0.6"})}let a=this.generateSitemapContent(o);return await r("sitemap.xml",a),{fileName:"sitemap.xml",content:a,publicRoutes:o.length}}async generateManifest(t,r,s=null){if(s&&await s("seo-manifest.json"))return this.logger.info("\u2705 seo-manifest.json already exists, skipping generation"),{fileName:"seo-manifest.json",skipped:!0};let n={totalRoutes:t.routes?.length||0,publicRoutes:t.routes?.filter(o=>!o.auth||o.auth===!1).length||0,protectedRoutes:t.routes?.filter(o=>o.auth&&o.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString(),routeMetaTags:t.routeMetaTags||[]},i=JSON.stringify(n,null,2);return await r("seo-manifest.json",i),{fileName:"seo-manifest.json",content:i,manifest:n}}generateRobotsTxtContent(t={}){let{allowedPaths:r=["/"],disallowedPaths:s=["/admin","/api"],sitemap:n,crawlDelay:i}=t,o=l=>l?l==="*"?"*":l.startsWith("/")?l:`/${l}`:"/",a=["User-agent: *",...s.map(l=>`Disallow: ${o(l)}`),...r.map(l=>`Allow: ${o(l)}`)];return i&&a.push(`Crawl-delay: ${i}`),n&&a.push(`Sitemap: ${n}`),a.join(`
771
+ `},generateManifest:e=>({routes:e?.routes?.length||0,source:e?.source||"unknown",timestamp:Date.now(),errors:e?.errors?.length||0}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.routes||[],n=s.filter(o=>o.auth&&o.auth.required).length,i=s.length;r&&r.info(`${t} Routes: ${i} found${n>0?`, ${n} are authguarded`:""}`)}},_f=[e=>e.endsWith("Page.tsx")];function eo(e={}){return Ne({pluginName:"dndev-vite-route-discovery",icon:"\u{1F6E3}\uFE0F",virtualModuleId:V.routes,DiscoveryClass:ar,discoveryMethod:"discoverRoutes",filePatterns:_f,templates:Af,defaultInspectionPath:te.vite.routeInspection,manifestFileName:te.manifests.route,configKey:"routes"})({...e,disableHmr:e?.hmr===!1,hmrSmartDetection:!1})}import{loadEnv as Tf}from"vite";me();import{readFileSync as Nf,readdirSync as If,existsSync as Df}from"fs";import{join as to}from"path";var lr=class{constructor(t={}){let{debug:r=!1,generateRobotsTxt:s=!0,generateSitemap:n=!0,baseUrl:i,siteName:o,crawlDelay:a=1,routes:l={},...u}=t;if(!i||!o)throw new Error("SEOGenerator requires baseUrl and siteName options");this.options={debug:r,generateRobotsTxt:s,generateSitemap:n,baseUrl:i,siteName:o,crawlDelay:a,routes:l,defaultImage:"/og-image.jpg",twitterHandle:"@donotdev",defaultAuthor:"DNDev Team",defaultLanguage:"en",staticTags:{},...u},this.appRoot=u.appRoot||null,this.logger=B("SEO Generator",t.debug,t.verbose)}async generateSEOFiles(t,r,s=null){try{let n=this.generateRouteMetaTags(t.routes||[]),i={routes:t.routes||[],routeMetaTags:n,baseUrl:this.options.baseUrl,siteName:this.options.siteName},o=this.discoverBlogPosts(),a={robotsTxt:null,sitemap:null,rss:null,manifest:null,totalRoutes:i.routes.length,publicRoutes:i.routes.filter(l=>!l.auth||l.auth===!1).length,protectedRoutes:i.routes.filter(l=>l.auth&&l.auth.required).length,blogPosts:o.length};return this.options.generateRobotsTxt&&(a.robotsTxt=await this.generateRobotsTxt(i,r,s)),this.options.generateSitemap&&(a.sitemap=await this.generateSitemap(i,r,s,o)),o.length>0&&(a.rss=await this.generateRSSFeed(o,r,s)),a.manifest=await this.generateManifest(i,r,s),a}catch(n){throw this.logger.error(`SEO generator failed to create files (robots.txt/sitemap.xml/manifest): ${n.message}`),this.logger.error(`Stack: ${n.stack||"No stack trace available"}`),n}}async generateRobotsTxt(t,r,s=null){if(s&&await s("robots.txt"))return this.logger.info("\u2705 robots.txt already exists, skipping generation"),{fileName:"robots.txt",skipped:!0};let n=[];(t.routes||[]).forEach(o=>{if(o.auth&&o.auth.required){let a=o.path.startsWith("/")?o.path:`/${o.path}`;n.push(a)}}),n.push("/admin","/api","/_next","/static");let i=this.generateRobotsTxtContent({disallowedPaths:[...new Set(n)],sitemap:`${this.options.baseUrl}/sitemap.xml`,crawlDelay:this.options.crawlDelay});return await r("robots.txt",i),{fileName:"robots.txt",content:i,disallowedPaths:n.length}}async generateSitemap(t,r,s=null,n=[]){if(s&&await s("sitemap.xml"))return this.logger.info("\u2705 sitemap.xml already exists, skipping generation"),{fileName:"sitemap.xml",skipped:!0};let o=(t.routes||[]).filter(l=>!l.auth||l.auth===!1).map(l=>({url:l.path,lastmod:new Date().toISOString().split("T")[0],changefreq:"weekly",priority:l.path==="/"?"1.0":"0.8"}));if(n.length>0){o.push({url:"/blog",lastmod:n[0]?.date||new Date().toISOString().split("T")[0],changefreq:"weekly",priority:"0.7"});for(let l of n)o.push({url:`/blog/${l.slug}`,lastmod:l.date,changefreq:"monthly",priority:"0.6"})}let a=this.generateSitemapContent(o);return await r("sitemap.xml",a),{fileName:"sitemap.xml",content:a,publicRoutes:o.length}}async generateManifest(t,r,s=null){if(s&&await s("seo-manifest.json"))return this.logger.info("\u2705 seo-manifest.json already exists, skipping generation"),{fileName:"seo-manifest.json",skipped:!0};let n={totalRoutes:t.routes?.length||0,publicRoutes:t.routes?.filter(o=>!o.auth||o.auth===!1).length||0,protectedRoutes:t.routes?.filter(o=>o.auth&&o.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString(),routeMetaTags:t.routeMetaTags||[]},i=JSON.stringify(n,null,2);return await r("seo-manifest.json",i),{fileName:"seo-manifest.json",content:i,manifest:n}}generateRobotsTxtContent(t={}){let{allowedPaths:r=["/"],disallowedPaths:s=["/admin","/api"],sitemap:n,crawlDelay:i}=t,o=l=>l?l==="*"?"*":l.startsWith("/")?l:`/${l}`:"/",a=["User-agent: *",...s.map(l=>`Disallow: ${o(l)}`),...r.map(l=>`Allow: ${o(l)}`)];return i&&a.push(`Crawl-delay: ${i}`),n&&a.push(`Sitemap: ${n}`),a.join(`
769
772
  `)}generateSitemapContent(t){return`<?xml version="1.0" encoding="UTF-8"?>
770
773
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
771
774
  ${t.map(({url:s,lastmod:n,changefreq:i,priority:o})=>{let a=[` <loc>${this.options.baseUrl}${s}</loc>`];return n&&a.push(` <lastmod>${n}</lastmod>`),i&&a.push(` <changefreq>${i}</changefreq>`),o&&a.push(` <priority>${o}</priority>`),` <url>
@@ -773,8 +776,8 @@ ${a.join(`
773
776
  `)}
774
777
  </url>`}).join(`
775
778
  `)}
776
- </urlset>`}generateRouteMetaTags(t){return t.map(r=>{let s=this.options.siteName;if(r.meta?.title)s=`${r.meta.title} - ${this.options.siteName}`;else if(r.path!=="/"){let i=r.path.split("/").filter(Boolean);i.length>0&&(s=`${i[i.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")} - ${this.options.siteName}`)}let n=`Welcome to ${this.options.siteName}`;if(r.meta?.description)n=r.meta.description;else if(r.meta?.entity&&r.meta?.action)n=`${r.meta.action} ${r.meta.entity} on ${this.options.siteName}`;else if(r.path!=="/"){let i=r.path.split("/").filter(Boolean);i.length>0&&(n=`Explore ${i[i.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ").toLowerCase()} on ${this.options.siteName}`)}return{path:r.path,meta:{title:s,description:n,canonical:`${this.options.baseUrl}${r.path}`,robots:r.auth&&r.auth.required?"noindex, nofollow":"index, follow"}}})}discoverBlogPosts(){if(!this.appRoot)return[];let t=zi(this.appRoot,"src","content","blog");try{if(!af(t))return[];let r=of(t).filter(n=>n.endsWith("_en.md"));if(r.length===0)return[];let s=[];for(let n of r){let i=nf(zi(t,n),"utf-8"),o=n.replace(/_en\.md$/,""),a=i.match(/^---\r?\n([\s\S]*?)\r?\n---/),l={};if(a)for(let f of a[1].split(`
777
- `)){let u=f.indexOf(":");u!==-1&&(l[f.slice(0,u).trim()]=f.slice(u+1).trim())}s.push({slug:o,title:l.title||o,description:l.description||"",date:l.date||new Date().toISOString().split("T")[0],tags:l.tags?l.tags.split(",").map(f=>f.trim()):[],image:l.image||null})}return s.sort((n,i)=>i.date.localeCompare(n.date)),this.logger.info(`\u{1F4DD} Discovered ${s.length} blog post(s) in src/content/blog/`),s}catch(r){return this.logger.debug(`Blog content discovery skipped: ${r.message}`),[]}}async generateRSSFeed(t,r,s=null){if(s&&await s("rss.xml"))return this.logger.info("\u2705 rss.xml already exists, skipping generation"),{fileName:"rss.xml",skipped:!0};let n=t.map(o=>` <item>
779
+ </urlset>`}generateRouteMetaTags(t){return t.map(r=>{let s=this.options.siteName;if(r.meta?.title)s=`${r.meta.title} - ${this.options.siteName}`;else if(r.path!=="/"){let i=r.path.split("/").filter(Boolean);i.length>0&&(s=`${i[i.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")} - ${this.options.siteName}`)}let n=`Welcome to ${this.options.siteName}`;if(r.meta?.description)n=r.meta.description;else if(r.meta?.entity&&r.meta?.action)n=`${r.meta.action} ${r.meta.entity} on ${this.options.siteName}`;else if(r.path!=="/"){let i=r.path.split("/").filter(Boolean);i.length>0&&(n=`Explore ${i[i.length-1].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ").toLowerCase()} on ${this.options.siteName}`)}return{path:r.path,meta:{title:s,description:n,canonical:`${this.options.baseUrl}${r.path}`,robots:r.auth&&r.auth.required?"noindex, nofollow":"index, follow"}}})}discoverBlogPosts(){if(!this.appRoot)return[];let t=to(this.appRoot,"src","content","blog");try{if(!Df(t))return[];let r=If(t).filter(n=>n.endsWith("_en.md"));if(r.length===0)return[];let s=[];for(let n of r){let i=Nf(to(t,n),"utf-8"),o=n.replace(/_en\.md$/,""),a=i.match(/^---\r?\n([\s\S]*?)\r?\n---/),l={};if(a)for(let u of a[1].split(`
780
+ `)){let f=u.indexOf(":");f!==-1&&(l[u.slice(0,f).trim()]=u.slice(f+1).trim())}s.push({slug:o,title:l.title||o,description:l.description||"",date:l.date||new Date().toISOString().split("T")[0],tags:l.tags?l.tags.split(",").map(u=>u.trim()):[],image:l.image||null})}return s.sort((n,i)=>i.date.localeCompare(n.date)),this.logger.info(`\u{1F4DD} Discovered ${s.length} blog post(s) in src/content/blog/`),s}catch(r){return this.logger.debug(`Blog content discovery skipped: ${r.message}`),[]}}async generateRSSFeed(t,r,s=null){if(s&&await s("rss.xml"))return this.logger.info("\u2705 rss.xml already exists, skipping generation"),{fileName:"rss.xml",skipped:!0};let n=t.map(o=>` <item>
778
781
  <title><![CDATA[${o.title}]]></title>
779
782
  <link>${this.options.baseUrl}/blog/${o.slug}</link>
780
783
  <guid>${this.options.baseUrl}/blog/${o.slug}</guid>
@@ -793,7 +796,7 @@ ${a.join(`
793
796
  <atom:link href="${this.options.baseUrl}/rss.xml" rel="self" type="application/rss+xml"/>
794
797
  ${n}
795
798
  </channel>
796
- </rss>`;return await r("rss.xml",i),{fileName:"rss.xml",content:i,postCount:t.length}}getGenerationSummary(t){let r=t.routes?.length||0,s=t.routes?.filter(i=>!i.auth||i.auth===!1).length||0,n=t.routes?.filter(i=>i.auth&&i.auth.required).length||0;return`${r} routes (${s} public, ${n} protected)`}formatAPIResponse(t){return{totalRoutes:t.routes?.length||0,publicRoutes:t.routes?.filter(r=>!r.auth||r.auth===!1).length||0,protectedRoutes:t.routes?.filter(r=>r.auth&&r.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString()}}};function Bi(e={}){let{disabled:t=!1,debug:r,generateRobotsTxt:s,generateSitemap:n,routes:i={},baseUrl:o,siteName:a,crawlDelay:l,isDev:f,...u}=e;if(t)return{name:"seo-disabled"};let g=M("SEO Plugin",r,!0),p=G.getInstance(),m=null,S=null,z=!1;async function q(){try{let $=p.resolveAppPath("src/routes.generated.log"),C=p.readSync($,{format:"text"});if(!C)return g.error(`SEO plugin: routes discovery file not found at ${$}`),g.error("This indicates route discovery failed or did not run. SEO files will be generated with empty routes."),{routes:[],errors:[`Routes file missing: ${$}`],source:"fallback"};let k=C.match(/export const discoveredRoutes = (\[[\s\S]*?\]);/);if(!k)return g.error(`SEO plugin: failed to parse routes from ${$}`),g.error("Expected format: export const discoveredRoutes = [...];"),g.error("This indicates route discovery generated invalid output. SEO files will be generated with empty routes."),{routes:[],errors:[`Invalid routes file format: ${$}`],source:"fallback"};let D=k[1].replace(/component:\s*\(\)\s*=>\s*Promise\.resolve\(\{[^}]*\}\),?/g,"").replace(/component:\s*\(\)\s*=>\s*import\([^)]*\),?/g,"").replace(/component:\s*[^,}\n]+,?/g,"").replace(/,\s*,/g,",").replace(/,\s*}/g,"}").replace(/,\s*]/g,"]"),N=Function(`"use strict"; return ${D}`)();return{routes:N,errors:[],source:"generated",totalFiles:N.length}}catch($){return g.warn(`Error parsing generated routes: ${$.message}, falling back to empty routes`),{routes:[],errors:[],source:"fallback"}}}return{name:"vite-seo-plugin",enforce:"pre",configResolved($){let C=p.getAppRoot(),k=$.mode||"production",N=lf(k,C,"VITE_").VITE_APP_URL||process.env.VITE_APP_URL||null;N&&r&&g.debug(`Using app URL from VITE_APP_URL: ${N}`),m=a||null,S=o||N||null,g.verbose(`Name: ${m||"Not found"}`),g.verbose(`URL: ${S||"Not found"}`),m&&g.debug(` - Site name from appConfig: "${m}"`);let E=[];if(S||E.push("baseUrl (VITE_APP_URL in .env)"),m||E.push("siteName (APP_NAME in src/config/app.ts)"),E.length>0){z=!0,g.warn("\u26A0\uFE0F SEO Plugin disabled - missing required configuration:"),E.forEach(B=>g.warn(` - ${B}`)),g.warn(""),g.warn(" To fix:"),S||g.warn(" 1. Add VITE_APP_URL=https://yourdomain.com to your .env file"),m||(g.warn(" 2. Add APP_NAME export to src/config/app.ts:"),g.warn(' export const APP_NAME = "Your App Name";')),g.warn(""),g.warn(" robots.txt and sitemap.xml will NOT be generated."),g.warn("");return}g.debug(`Generate robots.txt: ${s}`),g.debug(`Generate sitemap: ${n}`)},async generateBundle(){if(!z)try{let $=new Kt({debug:r,generateRobotsTxt:s,generateSitemap:n,baseUrl:S,siteName:m,crawlDelay:l,routes:i,appRoot:p.getAppRoot(),...u}),C=await q(),k=async(E,B)=>{this.emitFile({type:"asset",fileName:E,source:B})},D=async E=>!1,N=await $.generateSEOFiles(C,k,D);N.robotsTxt&&!N.robotsTxt.skipped&&g.info(`\u{1F916} robots.txt: ${N.robotsTxt.disallowedPaths||0} disallowed paths`),N.sitemap&&!N.sitemap.skipped&&g.info(`\u{1F5FA}\uFE0F sitemap.xml: ${N.sitemap.publicRoutes||0} routes`),N.rss&&!N.rss.skipped&&g.info(`\u{1F4E1} rss.xml: ${N.rss.postCount||0} blog posts`),N.manifest&&!N.manifest.skipped&&g.info("\u{1F4C4} seo-manifest.json")}catch($){g.error(`SEO plugin failed to generate files (robots.txt/sitemap.xml): ${$.message}`),g.error(`Stack: ${$.stack||"No stack trace available"}`)}}}}function Ui(e={}){let{debug:t}=e;return{name:"dndev-server-shim",enforce:"pre",resolveId(r,s){return r.startsWith("node:")?(M("server-shim",t,!0).warn(`Blocking Node.js built-in module import: ${r}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):nr.includes(r)||nr.some(n=>r.startsWith(`${n}/`))?(M("server-shim",t,!0).warn(`Blocking server-only subpath import: ${r}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):Vr.includes(r)?(M("server-shim",t,!0).warn(`Blocking server-only import: ${r}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):null},load(r){return r==="\0virtual:empty-server-module"?`
799
+ </rss>`;return await r("rss.xml",i),{fileName:"rss.xml",content:i,postCount:t.length}}getGenerationSummary(t){let r=t.routes?.length||0,s=t.routes?.filter(i=>!i.auth||i.auth===!1).length||0,n=t.routes?.filter(i=>i.auth&&i.auth.required).length||0;return`${r} routes (${s} public, ${n} protected)`}formatAPIResponse(t){return{totalRoutes:t.routes?.length||0,publicRoutes:t.routes?.filter(r=>!r.auth||r.auth===!1).length||0,protectedRoutes:t.routes?.filter(r=>r.auth&&r.auth.required).length||0,baseUrl:this.options.baseUrl,siteName:this.options.siteName,generatedAt:new Date().toISOString()}}};function ro(e={}){let{disabled:t=!1,debug:r,generateRobotsTxt:s,generateSitemap:n,routes:i={},baseUrl:o,siteName:a,crawlDelay:l,isDev:u,...f}=e;if(t)return{name:"seo-disabled"};let d=B("SEO Plugin",r,!0),g=G.getInstance(),m=null,P=null,U=!1;async function W(){try{let N=g.resolveAppPath("src/routes.generated.log"),O=g.readSync(N,{format:"text"});if(!O)return d.error(`SEO plugin: routes discovery file not found at ${N}`),d.error("This indicates route discovery failed or did not run. SEO files will be generated with empty routes."),{routes:[],errors:[`Routes file missing: ${N}`],source:"fallback"};let C=O.match(/export const discoveredRoutes = (\[[\s\S]*?\]);/);if(!C)return d.error(`SEO plugin: failed to parse routes from ${N}`),d.error("Expected format: export const discoveredRoutes = [...];"),d.error("This indicates route discovery generated invalid output. SEO files will be generated with empty routes."),{routes:[],errors:[`Invalid routes file format: ${N}`],source:"fallback"};let R=C[1].replace(/component:\s*\(\)\s*=>\s*Promise\.resolve\(\{[^}]*\}\),?/g,"").replace(/component:\s*\(\)\s*=>\s*import\([^)]*\),?/g,"").replace(/component:\s*[^,}\n]+,?/g,"").replace(/,\s*,/g,",").replace(/,\s*}/g,"}").replace(/,\s*]/g,"]"),k=Function(`"use strict"; return ${R}`)();return{routes:k,errors:[],source:"generated",totalFiles:k.length}}catch(N){return d.warn(`Error parsing generated routes: ${N.message}, falling back to empty routes`),{routes:[],errors:[],source:"fallback"}}}return{name:"vite-seo-plugin",enforce:"pre",configResolved(N){let O=g.getAppRoot(),C=N.mode||"production",k=Tf(C,O,"VITE_").VITE_APP_URL||process.env.VITE_APP_URL||null;k&&r&&d.debug(`Using app URL from VITE_APP_URL: ${k}`),m=a||null,P=o||k||null,d.verbose(`Name: ${m||"Not found"}`),d.verbose(`URL: ${P||"Not found"}`),m&&d.debug(` - Site name from appConfig: "${m}"`);let E=[];if(P||E.push("baseUrl (VITE_APP_URL in .env)"),m||E.push("siteName (APP_NAME in src/config/app.ts)"),E.length>0){U=!0,d.warn("\u26A0\uFE0F SEO Plugin disabled - missing required configuration:"),E.forEach(j=>d.warn(` - ${j}`)),d.warn(""),d.warn(" To fix:"),P||d.warn(" 1. Add VITE_APP_URL=https://yourdomain.com to your .env file"),m||(d.warn(" 2. Add APP_NAME export to src/config/app.ts:"),d.warn(' export const APP_NAME = "Your App Name";')),d.warn(""),d.warn(" robots.txt and sitemap.xml will NOT be generated."),d.warn("");return}d.debug(`Generate robots.txt: ${s}`),d.debug(`Generate sitemap: ${n}`)},async generateBundle(){if(!U)try{let N=new lr({debug:r,generateRobotsTxt:s,generateSitemap:n,baseUrl:P,siteName:m,crawlDelay:l,routes:i,appRoot:g.getAppRoot(),...f}),O=await W(),C=async(E,j)=>{this.emitFile({type:"asset",fileName:E,source:j})},R=async E=>!1,k=await N.generateSEOFiles(O,C,R);k.robotsTxt&&!k.robotsTxt.skipped&&d.info(`\u{1F916} robots.txt: ${k.robotsTxt.disallowedPaths||0} disallowed paths`),k.sitemap&&!k.sitemap.skipped&&d.info(`\u{1F5FA}\uFE0F sitemap.xml: ${k.sitemap.publicRoutes||0} routes`),k.rss&&!k.rss.skipped&&d.info(`\u{1F4E1} rss.xml: ${k.rss.postCount||0} blog posts`),k.manifest&&!k.manifest.skipped&&d.info("\u{1F4C4} seo-manifest.json")}catch(N){d.error(`SEO plugin failed to generate files (robots.txt/sitemap.xml): ${N.message}`),d.error(`Stack: ${N.stack||"No stack trace available"}`)}}}}re();function so(e={}){let{debug:t}=e;return{name:"dndev-server-shim",enforce:"pre",resolveId(r,s){return r.startsWith("node:")?(B("server-shim",t,!0).warn(`Blocking Node.js built-in module import: ${r}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):vr.includes(r)||vr.some(n=>r.startsWith(`${n}/`))?(B("server-shim",t,!0).warn(`Blocking server-only subpath import: ${r}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):ls.includes(r)?(B("server-shim",t,!0).warn(`Blocking server-only import: ${r}${s?` from ${s}`:""}`),"\0virtual:empty-server-module"):null},load(r){return r==="\0virtual:empty-server-module"?`
797
800
  // Node.js built-in modules shims for browser compatibility
798
801
  export const URL = globalThis.URL;
799
802
  export const URLSearchParams = globalThis.URLSearchParams;
@@ -1072,7 +1075,7 @@ ${n}
1072
1075
  // Google Logging Utils shims
1073
1076
  export const LoggingWinston = class LoggingWinston {};
1074
1077
  export const LoggingBunyan = class LoggingBunyan {};
1075
- `:null}}}var St=class extends be{constructor(t,r,s={}){super(r,s),this.cssExtractor=t||new We(r,{debug:s.debug,logger:this.logger}),this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes()}_getDiscoveryType(){return"Theme"}async _getPatterns(){return await this.pathResolver.resolvePatterns("css")}_getPatternType(){return"css"}async _processFiles(t){this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes();let{frameworkFiles:r,consumerFiles:s}=t;this.logger.debug(`Scanning ${r.length} framework + ${s.length} consumer CSS files`),this.logger.debug("\u{1F50D} FILES DISCOVERED:"),this.logger.debug("Framework files:",r),this.logger.debug("Consumer files:",s),r.length>0?(this.logger.debug(`Framework files found: ${r.length}`),this.logger.debug("Framework files:",r)):this.logger.debug("No framework files found"),s.length>0?(this.logger.debug(`Consumer files found: ${s.length}`),this.logger.debug("Consumer files:",s)):this.logger.debug("No consumer files found"),await this._processFrameworkFiles(r),await this._processConsumerFiles(s);let n=this._serializeThemes();return this.logger.debug(`Discovered ${n.length} themes:`,n.map(i=>i.name)),{themes:n,variables:{framework:Array.from(this.discovered.variables.framework).sort(),consumer:Array.from(this.discovered.variables.consumer).sort(),all:[...Array.from(this.discovered.variables.framework),...Array.from(this.discovered.variables.consumer)].sort()},classes:Array.from(this.discovered.classes).sort(),keyframes:Array.from(this.discovered.keyframes).sort()}}_getEmptyResult(){let t=this._serializeThemes();return{themes:t.length>0?t:this._getEssentialThemesFallback(),variables:{framework:[],consumer:[],all:[]},classes:[],keyframes:[],timestamp:Date.now()}}_getEssentialThemesFallback(){return or.map(t=>({name:t.name,displayName:t.displayName,meta:{icon:t.icon,category:t.isDark?"dark":"light"},essential:!0,isDark:t.isDark,source:"built-in",variableCount:0}))}_getDiscoverySummary(){return""}async discoverThemes(t=!1){return await this.discover(t)}getThemes(){return this.cache?.themes||[]}getVariables(){return this.cache?.variables||{framework:[],consumer:[],all:[]}}getClasses(){return this.cache?.classes||[]}async _processFrameworkFiles(t){for(let r of t)try{let s=await this.pathResolver.read(r,{format:"text"}),n=this.pathResolver.normalizePath(r);this.cssExtractor.extractThemes(s,n,this.discovered),this.cssExtractor.extractClasses(s,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"framework"),this.cssExtractor.extractKeyframes(s,this.discovered),this.logger.debug(`\u2705 Processed framework: ${this.pathResolver.getRelativePath(n)}`)}catch(s){this.logger.debug(`Error scanning framework file ${r}: ${s.message}`)}}async _processConsumerFiles(t){for(let r of t)try{let s=await this.pathResolver.read(r,{format:"text"}),n=this.pathResolver.normalizePath(r);this.cssExtractor.extractThemes(s,n,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"consumer"),this.logger.debug(`\u2705 Processed consumer: ${this.pathResolver.getRelativePath(n)}`)}catch(s){this.logger.debug(`Error scanning consumer file ${r}: ${s.message}`)}}_addEssentialThemes(){or.forEach(t=>{this.discovered.themes.set(t.name,{name:t.name,displayName:t.displayName,meta:{icon:t.icon,category:t.isDark?"dark":"light"},essential:!0,isDark:t.isDark,source:"built-in",variables:new Set})})}_serializeThemes(){return Array.from(this.discovered.themes.values()).map(t=>({name:t.name,displayName:t.displayName,meta:t.meta,source:t.source,essential:t.essential||!1,isDark:t.isDark||!1,variableCount:t.variables?.size||0}))}};var Gi={isEmpty:e=>!e.themes||e.themes.length===0,generateModule:(e,t,r="themes")=>{let{themes:s}=e;if(!s||s.length===0)return Gi.generateEmpty(e,t,void 0,r);let n=s.find(o=>o.essential&&o.name==="light")||s[0],i={totalThemes:s.length,defaultTheme:n?.name||"light",hasCustomThemes:s.some(o=>!o.essential),timestamp:new Date().toISOString()};return`// Virtual module: ${W.themes}
1078
+ `:null}}}re();re();var It=class extends Pe{constructor(t,r,s={}){super(r,s),this.cssExtractor=t||new Ke(r,{debug:s.debug,logger:this.logger}),this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes()}_getDiscoveryType(){return"Theme"}async _getPatterns(){return await this.pathResolver.resolvePatterns("css")}_getPatternType(){return"css"}async _processFiles(t){this.discovered={themes:new Map,variables:{framework:new Set,consumer:new Set},classes:new Set,keyframes:new Set},this._addEssentialThemes();let{frameworkFiles:r,consumerFiles:s}=t;this.logger.debug(`Scanning ${r.length} framework + ${s.length} consumer CSS files`),this.logger.debug("\u{1F50D} FILES DISCOVERED:"),this.logger.debug("Framework files:",r),this.logger.debug("Consumer files:",s),r.length>0?(this.logger.debug(`Framework files found: ${r.length}`),this.logger.debug("Framework files:",r)):this.logger.debug("No framework files found"),s.length>0?(this.logger.debug(`Consumer files found: ${s.length}`),this.logger.debug("Consumer files:",s)):this.logger.debug("No consumer files found"),await this._processFrameworkFiles(r),await this._processConsumerFiles(s);let n=this._serializeThemes();return this.logger.debug(`Discovered ${n.length} themes:`,n.map(i=>i.name)),{themes:n,variables:{framework:Array.from(this.discovered.variables.framework).sort(),consumer:Array.from(this.discovered.variables.consumer).sort(),all:[...Array.from(this.discovered.variables.framework),...Array.from(this.discovered.variables.consumer)].sort()},classes:Array.from(this.discovered.classes).sort(),keyframes:Array.from(this.discovered.keyframes).sort()}}_getEmptyResult(){let t=this._serializeThemes();return{themes:t.length>0?t:this._getEssentialThemesFallback(),variables:{framework:[],consumer:[],all:[]},classes:[],keyframes:[],timestamp:Date.now()}}_getEssentialThemesFallback(){return wr.map(t=>({name:t.name,displayName:t.displayName,meta:{icon:t.icon,category:t.isDark?"dark":"light"},essential:!0,isDark:t.isDark,source:"built-in",variableCount:0}))}_getDiscoverySummary(){return""}async discoverThemes(t=!1){return await this.discover(t)}getThemes(){return this.cache?.themes||[]}getVariables(){return this.cache?.variables||{framework:[],consumer:[],all:[]}}getClasses(){return this.cache?.classes||[]}async _processFrameworkFiles(t){for(let r of t)try{let s=await this.pathResolver.read(r,{format:"text"}),n=this.pathResolver.normalizePath(r);this.cssExtractor.extractThemes(s,n,this.discovered),this.cssExtractor.extractClasses(s,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"framework"),this.cssExtractor.extractKeyframes(s,this.discovered),this.logger.debug(`\u2705 Processed framework: ${this.pathResolver.getRelativePath(n)}`)}catch(s){this.logger.debug(`Error scanning framework file ${r}: ${s.message}`)}}async _processConsumerFiles(t){for(let r of t)try{let s=await this.pathResolver.read(r,{format:"text"}),n=this.pathResolver.normalizePath(r);this.cssExtractor.extractThemes(s,n,this.discovered),this.cssExtractor.extractVariables(s,this.discovered,"consumer"),this.logger.debug(`\u2705 Processed consumer: ${this.pathResolver.getRelativePath(n)}`)}catch(s){this.logger.debug(`Error scanning consumer file ${r}: ${s.message}`)}}_addEssentialThemes(){wr.forEach(t=>{this.discovered.themes.set(t.name,{name:t.name,displayName:t.displayName,meta:{icon:t.icon,category:t.isDark?"dark":"light"},essential:!0,isDark:t.isDark,source:"built-in",variables:new Set})})}_serializeThemes(){return Array.from(this.discovered.themes.values()).map(t=>({name:t.name,displayName:t.displayName,meta:t.meta,source:t.source,essential:t.essential||!1,isDark:t.isDark||!1,variableCount:t.variables?.size||0}))}};var no={isEmpty:e=>!e.themes||e.themes.length===0,generateModule:(e,t,r="themes")=>{let{themes:s}=e;if(!s||s.length===0)return no.generateEmpty(e,t,void 0,r);let n=s.find(o=>o.essential&&o.name==="light")||s[0],i={totalThemes:s.length,defaultTheme:n?.name||"light",hasCustomThemes:s.some(o=>!o.essential),timestamp:new Date().toISOString()};return`// Virtual module: ${V.themes}
1076
1079
  // \u{1F680} STATIC INJECTION PATTERN - Zero Runtime Loading
1077
1080
  // Generated by @donotdev/config at ${new Date().toISOString()}
1078
1081
 
@@ -1100,7 +1103,7 @@ if (typeof globalThis !== 'undefined') {
1100
1103
  }
1101
1104
 
1102
1105
  // Populate themes configuration
1103
- globalThis._DNDEV_CONFIG_.${ne[r]} = {
1106
+ globalThis._DNDEV_CONFIG_.${le[r]} = {
1104
1107
  discovered: themeData,
1105
1108
  mapping: themeData.reduce((acc, theme) => {
1106
1109
  acc[theme.name] = theme;
@@ -1147,7 +1150,7 @@ export default {
1147
1150
  getAllThemes,
1148
1151
  getThemeNames
1149
1152
  };
1150
- `},generateEmpty:(e,t,r,s="themes")=>{let n=e.themes&&e.themes.length>0?e.themes:[{name:"light",displayName:"Light",meta:{icon:"Sun",category:"light"},essential:!0,isDark:!1,source:"built-in",variableCount:0}],i=n.find(a=>a.essential&&a.name==="light")||n[0],o={totalThemes:n.length,defaultTheme:i?.name||"light",hasCustomThemes:n.some(a=>!a.essential),timestamp:new Date().toISOString()};return`// ${W.themes} - Using framework essential themes (fallback)
1153
+ `},generateEmpty:(e,t,r,s="themes")=>{let n=e.themes&&e.themes.length>0?e.themes:[{name:"light",displayName:"Light",meta:{icon:"Sun",category:"light"},essential:!0,isDark:!1,source:"built-in",variableCount:0}],i=n.find(a=>a.essential&&a.name==="light")||n[0],o={totalThemes:n.length,defaultTheme:i?.name||"light",hasCustomThemes:n.some(a=>!a.essential),timestamp:new Date().toISOString()};return`// ${V.themes} - Using framework essential themes (fallback)
1151
1154
  // Generated by @donotdev/config at ${new Date().toISOString()}
1152
1155
 
1153
1156
  export const THEMES = ${JSON.stringify(n,null,2)};
@@ -1171,7 +1174,7 @@ if (typeof globalThis !== 'undefined') {
1171
1174
  };
1172
1175
  }
1173
1176
 
1174
- globalThis._DNDEV_CONFIG_.${ne[s]} = {
1177
+ globalThis._DNDEV_CONFIG_.${le[s]} = {
1175
1178
  discovered: themeData,
1176
1179
  mapping: themeData.reduce((acc, theme) => {
1177
1180
  acc[theme.name] = theme;
@@ -1233,7 +1236,7 @@ export default discoveredThemes;
1233
1236
  `;let s=r.find(n=>n.essential&&n.name==="light")||r[0];return`/**
1234
1237
  * Generated Theme Discovery Results
1235
1238
  * Generated at: ${new Date().toISOString()}
1236
- * Import from '${W.themes}'
1239
+ * Import from '${V.themes}'
1237
1240
  */
1238
1241
 
1239
1242
  export const discoveredThemes = ${JSON.stringify(r,null,2)};
@@ -1248,11 +1251,11 @@ export const themeManifest = {
1248
1251
  };
1249
1252
 
1250
1253
  export default discoveredThemes;
1251
- `},generateManifest:e=>({themes:e.themes?.length||0,timestamp:Date.now(),hasCustomThemes:e.themes?.some(t=>!t.essential)||!1}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.themes||[],n=s.filter(o=>!o.essential).length,i=s.length;r&&(i===0?r.warn(`${t} No themes discovered - using framework essential themes fallback`):r.info(`${t} Themes: ${i} discovered${n>0?` (${n} custom)`:""}`))}};function qi(e={}){let t=Date.now();return M("theme-plugin",e.debug,e.verbose).debug("\u{1F3A8} Creating theme discovery plugin..."),Se({pluginName:"dndev-theme",icon:"\u{1F3A8}",virtualModuleId:W.themes,DiscoveryClass:St,discoveryMethod:"discoverThemes",filePatterns:["**/*.css"],templates:Gi,defaultInspectionPath:Q.vite.themeInspection,manifestFileName:Q.manifests.theme,configKey:"themes",createDiscovery:(n,i)=>{let o=new We(n,{debug:i.debug,logger:M("css-extractor",i.debug,i.verbose)});return new St(o,n,i)}})(e)}function Wi(e={}){let t=M("vite-plugins",e.debug,e.verbose);try{let{mode:r,debug:s,verbose:n,isDev:i,server:o={},routes:a={},themes:l={},i18n:f={},assets:u={},seo:g={},pwa:p={},serverShim:m={},pluginFactory:S={}}=e,z=a.debug??s,q=l.debug??s,$=f.debug??s,C=u.debug??s,k=m.debug??s,D=[];D.push(Ui({...m,debug:k}));let N;try{N=G.getInstance()}catch(E){throw new Error(`Failed to initialize PathResolver: ${E.message||E}`)}return D.push({name:"dndev-file-watcher-fix",enforce:"pre",configResolved(E){if(s){t.debug("\u{1F4CB} Vite resolved config (configResolved):");let j={root:E.root,mode:E.mode,envDir:E.envDir,base:E.base,build:E.build?{outDir:E.build.outDir,minify:E.build.minify}:void 0,server:E.server?{port:E.server.port,host:E.server.host}:void 0,plugins:E.plugins?{count:E.plugins.length,names:E.plugins.map(fe=>fe?.name||"unnamed").filter(Boolean)}:void 0};t.debug(JSON.stringify(j,null,2))}N.setAppRoot(E.root);let B=N.getAppRoot();if(i&&E.server?.port){let j=E.server.https?"https":"http";process.env.VITE_APP_URL=`${j}://localhost:${E.server.port}`,(s||n)&&t.debug(`VITE_APP_URL set: ${process.env.VITE_APP_URL}`)}else i&&t.warn("VITE_APP_URL not set in dev mode. Server port not available.");try{let j=N.getRepoRoot();t.verbose(`Repo: ${j}`),t.verbose(`App: ${B}`)}catch(j){t.debug(`Could not log PathResolver values: ${j.message}`)}if(E.server){let j=I=>{let A=I.replace(/\\/g,"/"),te=B.replace(/\\/g,"/");return!A.startsWith(te)};E.server.watch||(E.server.watch={});let fe=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/.next/**","**/.turbo/**","**/.vite/**","**/functions/**","**/.generated/**"];E.server.watch={...E.server.watch,ignored:[...E.server.watch.ignored||[],...fe,j]},t.verbose(`Fixed file watcher to use app root: ${B}`)}}}),D.push(Fi({debug:s,verbose:n})),D.push(Ti({debug:s})),D.push(uf({fastRefresh:!0,jsxRuntime:"automatic"})),D.push(ff({ignoreConfigErrors:!0})),o.https!==!1&&D.push(cf()),D.push(Mi({...S,...a,debug:z})),D.push(qi({...S,...l,debug:q})),D.push(Di({...S,...f,debug:$})),D.push(ki({...S,...u,debug:C})),D.push(_i({...S,mode:r,debug:s,verbose:n})),D.push(Bi({...g,debug:s,isDev:i})),p.enabled&&D.push(Oi({...p,debug:s})),D.push(Ii({debug:s})),D}catch(r){throw M("vite-plugins",!1,!0).error(`Failed to create Vite plugins: ${r.message}`),r}}function hf(e){if(!e)return{};let t={};return Array.isArray(e)?e.forEach(({find:r,replacement:s})=>{typeof r=="string"&&(t[r]=s)}):typeof e=="object"&&Object.assign(t,e),t}function Hi(e={}){let{alias:t,...r}=e,{conditions:s,...n}=r;return{alias:{"@":"/src",...hf(t)},dedupe:["react","react-dom","react-router-dom"],preserveSymlinks:!1,conditions:["browser","module","import","vite-app",...s||[]],...n}}function Vi(e={}){let{include:t=[],exclude:r=[],esbuildOptions:s={},...n}=e,i=[...t,...Xe.optionalFeatures],o=[...new Set(i)],a=[...new Set(r)];return{include:o,exclude:a,esbuildOptions:s,...n}}function df(e={}){return e==null&&(e={}),async(t={})=>{t==null&&(t={});try{let r=process.env.CI==="true";process.env.DNDEV_BUILD_ID||(process.env.DNDEV_BUILD_ID=r?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9));let s=t.command,n=t.mode,{appConfig:i,...o}=e;if(!i)throw new Error(`appConfig is required. Import appConfig from src/config/app.ts and pass it to defineViteConfig({ appConfig, ... })
1252
- Make sure the import statement in vite.config.ts is: import { appConfig } from "./src/config/app";`);if(typeof i!="object"||i===null)throw new Error(`appConfig must be an object, but got ${typeof i}. Make sure you are exporting appConfig from src/config/app.ts correctly.`);let a=i?.features?{debug:i.features.debug}:void 0,l=i?.seo&&typeof i.seo!="boolean"?{...i.seo,siteName:i.seo.siteName||i.app?.name}:i?.app?.name?{siteName:i.app.name}:void 0,{features:f,seo:u,...g}=o,p=i?.app?{name:i.app.name,shortName:i.app.shortName,description:i.app.description}:void 0,{pwa:m={},...S}=g,z={...m,app:m.app||p},q={...a?{features:a}:{},...l?{seo:l}:{},...Object.keys(z).length>0?{pwa:z}:{},...S,mode:n},$;try{$=ss(q)}catch(we){throw new Error(`mergeOptions failed: ${we?.message||we||"Unknown error"}`)}let C;try{C=ns($)}catch(we){throw new Error(`normalizeOptions failed: ${we?.message||we||"Unknown error"}`)}if(!C)throw new Error("normalizeOptions returned undefined");let{mode:k,debug:D,verbose:N,isDev:E,isDebug:B,shouldAnalyze:j,serverOptions:fe,previewOptions:I,buildOverrides:A,resolveOptions:te,routeOptions:gt,themeOptions:de,i18nOptions:xe,assetOptions:F,featureOptions:L,seoOptions:O,pwaOptions:Y,serverShimOptions:He,chunkingOptions:re,pluginFactoryOptions:Le,base:De,defineOptions:tt,optimizeDepsOptions:Qt,pluginsOptions:Zt,cssOptions:pt,envDir:Rt,restOptions:er}=C,Ve=M("vite-config",D,N);Ve.debug(`Mode: ${k}, Dev: ${E}`);let b=process.env.DNDEV_BUILD_ID,P;s==="build"?P=`Building for ${k}`:s==="serve"?P=`Development server (${k})`:s==="preview"?P=`Preview server (serving ${k} build)`:P=`Running ${s} (${k})`,Ve.info(`
1253
- \u{1F3D7}\uFE0F DnDev Framework - ${P}${b?` [build:${b}]`:""}`),Ve.info(` Platform: Vite | Command: ${s} | Mode: ${k}
1254
- `);let X=Wi({mode:k,debug:D,verbose:N,isDev:E,routes:gt,themes:de,i18n:xe,assets:F,features:L,seo:O,pwa:Y,serverShim:He,chunkingOptions:re,pluginFactory:Le});if(!Array.isArray(X))throw new Error(`createVitePlugins returned ${typeof X}, expected array. Value: ${X}`);let Je=Zr({mode:k,chunkingOptions:re,debug:D,isDev:E,isDebug:B,shouldAnalyze:j}),ye=es(fe.port||3e3,fe,Ve),Ji=ts(I);return{...De&&{base:De},plugins:[...X,...Zt],appType:"spa",assetsInclude:["**/*.woff","**/*.woff2","**/*.ttf","**/*.otf","**/*.eot"],...k==="production"&&{build:Je},...s==="serve"&&{server:ye},...s==="preview"&&{preview:Ji},...Rt&&{envDir:Rt},customLogger:k==="production"&&!D?(()=>{let we={hasWarned:!1,_shouldSuppress(ge){return ge.includes("dist/")||ge.includes("kB")||ge.includes("\u2502")||ge.includes("gzip:")||ge.includes("\u2713 built in")||ge.match(/built in \d+\.\d+s/)},info(ge){we._shouldSuppress(ge)},warn(ge){we._shouldSuppress(ge)},error(ge){},warnOnce(ge){we.hasWarned||(we.hasWarned=!0)},clearScreen(){},hasErrorLogged(){return!1}};return we})():void 0,css:{postcss:os(pt),...pt},optimizeDeps:Vi(Qt),resolve:Hi(te),define:{...tt,"process.env.NODE_ENV":JSON.stringify(n),__DEV__:JSON.stringify(E),__PROD__:JSON.stringify(!E)},...er}}catch(r){let s=r||new Error("Unknown error occurred"),n=s?.message||s?.toString()||String(s)||"Unknown error",i=s?.stack||"",o=new Error(`Failed to create Vite config: ${n}${i?`
1255
- ${i}`:""}`);throw o.stack=i||o.stack,o}}}export{df as defineViteConfig};
1254
+ `},generateManifest:e=>({themes:e.themes?.length||0,timestamp:Date.now(),hasCustomThemes:e.themes?.some(t=>!t.essential)||!1}),logConfig:e=>{},logStats:(e,t,r)=>{let s=e.themes||[],n=s.filter(o=>!o.essential).length,i=s.length;r&&(i===0?r.warn(`${t} No themes discovered - using framework essential themes fallback`):r.info(`${t} Themes: ${i} discovered${n>0?` (${n} custom)`:""}`))}};function io(e={}){let t=Date.now();return B("theme-plugin",e.debug,e.verbose).debug("\u{1F3A8} Creating theme discovery plugin..."),Ne({pluginName:"dndev-theme",icon:"\u{1F3A8}",virtualModuleId:V.themes,DiscoveryClass:It,discoveryMethod:"discoverThemes",filePatterns:["**/*.css"],templates:no,defaultInspectionPath:te.vite.themeInspection,manifestFileName:te.manifests.theme,configKey:"themes",createDiscovery:(n,i)=>{let o=new Ke(n,{debug:i.debug,logger:B("css-extractor",i.debug,i.verbose)});return new It(o,n,i)}})(e)}me();function oo(e={}){let t=B("vite-plugins",e.debug,e.verbose);try{let{mode:r,debug:s,verbose:n,isDev:i,server:o={},routes:a={},themes:l={},i18n:u={},assets:f={},seo:d={},pwa:g={},serverShim:m={},pluginFactory:P={}}=e,U=a.debug??s,W=l.debug??s,N=u.debug??s,O=f.debug??s,C=m.debug??s,R=[];R.push(so({...m,debug:C}));let k;try{k=G.getInstance()}catch(E){throw new Error(`Failed to initialize PathResolver: ${E.message||E}`)}return R.push({name:"dndev-file-watcher-fix",enforce:"pre",configResolved(E){if(s){t.debug("\u{1F4CB} Vite resolved config (configResolved):");let M={root:E.root,mode:E.mode,envDir:E.envDir,base:E.base,build:E.build?{outDir:E.build.outDir,minify:E.build.minify}:void 0,server:E.server?{port:E.server.port,host:E.server.host}:void 0,plugins:E.plugins?{count:E.plugins.length,names:E.plugins.map(ve=>ve?.name||"unnamed").filter(Boolean)}:void 0};t.debug(JSON.stringify(M,null,2))}k.setAppRoot(E.root);let j=k.getAppRoot();if(i&&E.server?.port){let M=E.server.https?"https":"http";process.env.VITE_APP_URL=`${M}://localhost:${E.server.port}`,(s||n)&&t.debug(`VITE_APP_URL set: ${process.env.VITE_APP_URL}`)}else i&&t.warn("VITE_APP_URL not set in dev mode. Server port not available.");try{let M=k.getRepoRoot();t.verbose(`Repo: ${M}`),t.verbose(`App: ${j}`)}catch(M){t.debug(`Could not log PathResolver values: ${M.message}`)}if(E.server){let M=I=>{let A=I.replace(/\\/g,"/"),ie=j.replace(/\\/g,"/");return!A.startsWith(ie)};E.server.watch||(E.server.watch={});let ve=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/.next/**","**/.turbo/**","**/.vite/**","**/functions/**","**/.generated/**"];E.server.watch={...E.server.watch,ignored:[...E.server.watch.ignored||[],...ve,M]},t.verbose(`Fixed file watcher to use app root: ${j}`)}}}),R.push(Yi({debug:s,verbose:n})),R.push(Ji({debug:s})),R.push(Of({fastRefresh:!0,jsxRuntime:"automatic"})),R.push(Cf({ignoreConfigErrors:!0})),o.https!==!1&&R.push(Ff()),R.push(eo({...P,...a,debug:U})),R.push(io({...P,...l,debug:W})),R.push(Vi({...P,...u,debug:N})),R.push(Ui({...P,...f,debug:O})),R.push(qi({...P,mode:r,debug:s,verbose:n})),R.push(ro({...d,debug:s,isDev:i})),g.enabled&&R.push(Ki({...g,debug:s})),R.push(Hi({debug:s})),R}catch(r){throw B("vite-plugins",!1,!0).error(`Failed to create Vite plugins: ${r.message}`),r}}re();function jf(e){if(!e)return{};let t={};return Array.isArray(e)?e.forEach(({find:r,replacement:s})=>{typeof r=="string"&&(t[r]=s)}):typeof e=="object"&&Object.assign(t,e),t}function ao(e={}){let{alias:t,...r}=e,{conditions:s,...n}=r;return{alias:{"@":"/src",...jf(t)},dedupe:["react","react-dom","react-router-dom"],preserveSymlinks:!1,conditions:["browser","module","import","vite-app",...s||[]],...n}}function lo(e={}){let{include:t=[],exclude:r=[],esbuildOptions:s={},...n}=e,i=[...t,...tt.optionalFeatures],o=[...new Set(i)],a=[...new Set(r)];return{include:o,exclude:a,esbuildOptions:s,...n}}function th(e={}){return e==null&&(e={}),async(t={})=>{t==null&&(t={});try{let r=process.env.CI==="true";process.env.DNDEV_BUILD_ID||(process.env.DNDEV_BUILD_ID=r?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9));let s=t.command,n=t.mode,{appConfig:i,dndev:o,...a}=e;if(!i)throw new Error(`appConfig is required. Import appConfig from src/config/app.ts and pass it to defineViteConfig({ appConfig, ... })
1255
+ Make sure the import statement in vite.config.ts is: import { appConfig } from "./src/config/app";`);if(typeof i!="object"||i===null)throw new Error(`appConfig must be an object, but got ${typeof i}. Make sure you are exporting appConfig from src/config/app.ts correctly.`);let l=i?.features?{debug:i.features.debug}:void 0,u=i?.seo&&typeof i.seo!="boolean"?{...i.seo,siteName:i.seo.siteName||i.app?.name}:i?.app?.name?{siteName:i.app.name}:void 0,{features:f,seo:d,...g}=a,m=i?.app?{name:i.app.name,shortName:i.app.shortName,description:i.app.description}:void 0,{pwa:P={},...U}=g,W={...P,app:P.app||m},N={...l?{features:l}:{},...u?{seo:u}:{},...Object.keys(W).length>0?{pwa:W}:{},...U,mode:n},O;try{O=vs(N)}catch(de){throw new Error(`mergeOptions failed: ${de?.message||de||"Unknown error"}`)}let C;try{C=ys(O)}catch(de){throw new Error(`normalizeOptions failed: ${de?.message||de||"Unknown error"}`)}if(!C)throw new Error("normalizeOptions returned undefined");let{mode:R,debug:k,verbose:E,isDev:j,isDebug:M,shouldAnalyze:ve,serverOptions:I,previewOptions:A,buildOverrides:ie,resolveOptions:Et,routeOptions:ye,themeOptions:ke,i18nOptions:F,assetOptions:z,featureOptions:L,seoOptions:Z,pwaOptions:Ze,serverShimOptions:oe,chunkingOptions:Le,pluginFactoryOptions:qe,base:et,defineOptions:fr,optimizeDepsOptions:hr,pluginsOptions:xt,cssOptions:Ft,envDir:Ot,restOptions:Ct}=C,b=B("vite-config",k,E);b.debug(`Mode: ${R}, Dev: ${j}`);let S=process.env.DNDEV_BUILD_ID,Q;s==="build"?Q=`Building for ${R}`:s==="serve"?Q=`Development server (${R})`:s==="preview"?Q=`Preview server (serving ${R} build)`:Q=`Running ${s} (${R})`,b.info(`
1256
+ \u{1F3D7}\uFE0F DnDev Framework - ${Q}${S?` [build:${S}]`:""}`),b.info(` Platform: Vite | Command: ${s} | Mode: ${R}
1257
+ `);let Ae=oo({mode:R,debug:k,verbose:E,isDev:j,routes:ye,themes:ke,i18n:F,assets:z,features:L,seo:Z,pwa:Ze,serverShim:oe,chunkingOptions:Le,pluginFactory:qe});if(!Array.isArray(Ae))throw new Error(`createVitePlugins returned ${typeof Ae}, expected array. Value: ${Ae}`);let Re=ps({mode:R,chunkingOptions:Le,debug:k,isDev:j,isDebug:M,shouldAnalyze:ve}),vo=gs(I.port||3e3,I,b),yo=ms(A);if(o)try{let{createDndevPlugin:de}=await Promise.resolve().then(()=>(bo(),mo));xt.push(de(typeof o=="object"?o:{}))}catch{}return{...et&&{base:et},plugins:[...Ae,...xt],appType:"spa",assetsInclude:["**/*.woff","**/*.woff2","**/*.ttf","**/*.otf","**/*.eot"],...R==="production"&&{build:Re},...s==="serve"&&{server:vo},...s==="preview"&&{preview:yo},...Ot&&{envDir:Ot},customLogger:R==="production"&&!k?(()=>{let de={hasWarned:!1,_shouldSuppress(we){return we.includes("dist/")||we.includes("kB")||we.includes("\u2502")||we.includes("gzip:")||we.includes("\u2713 built in")||we.match(/built in \d+\.\d+s/)},info(we){de._shouldSuppress(we)},warn(we){de._shouldSuppress(we)},error(we){},warnOnce(we){de.hasWarned||(de.hasWarned=!0)},clearScreen(){},hasErrorLogged(){return!1}};return de})():void 0,css:{postcss:Es(Ft),...Ft},optimizeDeps:lo(hr),resolve:ao(Et),define:{...fr,"process.env.NODE_ENV":JSON.stringify(n),__DEV__:JSON.stringify(j),__PROD__:JSON.stringify(!j)},...Ct}}catch(r){let s=r||new Error("Unknown error occurred"),n=s?.message||s?.toString()||String(s)||"Unknown error",i=s?.stack||"",o=new Error(`Failed to create Vite config: ${n}${i?`
1258
+ ${i}`:""}`);throw o.stack=i||o.stack,o}}}export{th as defineViteConfig};
1256
1259
  /*! Bundled license information:
1257
1260
 
1258
1261
  sharp/lib/is.js: