@donotdev/core 0.0.27 → 0.0.29
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/i18n/locales/eager/dndev_ar.json +29 -0
- package/i18n/locales/eager/dndev_da.json +29 -0
- package/i18n/locales/eager/dndev_de.json +29 -0
- package/i18n/locales/eager/dndev_en.json +179 -0
- package/i18n/locales/eager/dndev_es.json +29 -0
- package/i18n/locales/eager/dndev_fr.json +29 -0
- package/i18n/locales/eager/dndev_it.json +29 -0
- package/i18n/locales/eager/dndev_ja.json +29 -0
- package/i18n/locales/eager/dndev_ko.json +29 -0
- package/i18n/locales/eager/dndev_nl.json +29 -0
- package/i18n/locales/lazy/crud_ar.json +7 -1
- package/i18n/locales/lazy/crud_da.json +7 -1
- package/i18n/locales/lazy/crud_de.json +7 -1
- package/i18n/locales/lazy/crud_en.json +7 -1
- package/i18n/locales/lazy/crud_es.json +7 -1
- package/i18n/locales/lazy/crud_fr.json +7 -1
- package/i18n/locales/lazy/crud_it.json +7 -1
- package/i18n/locales/lazy/crud_ja.json +7 -1
- package/i18n/locales/lazy/crud_ko.json +7 -1
- package/i18n/locales/lazy/crud_nl.json +7 -1
- package/index.d.ts +5687 -5451
- package/index.js +40 -40
- package/next/index.d.ts +154 -154
- package/next/index.js +2 -2
- package/package.json +2 -2
- package/server.d.ts +6505 -6288
- package/server.js +1 -1
- package/vite/index.d.ts +154 -154
- package/vite/index.js +12 -12
package/next/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var ra=Object.create;var Lr=Object.defineProperty;var sa=Object.getOwnPropertyDescriptor;var ia=Object.getOwnPropertyNames;var na=Object.getPrototypeOf,aa=Object.prototype.hasOwnProperty;var I=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var oa=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ia(e))!aa.call(t,i)&&i!==r&&Lr(t,i,{get:()=>e[i],enumerable:!(s=sa(e,i))||s.enumerable});return t};var la=(t,e,r)=>(r=t!=null?ra(na(t)):{},oa(e||!t||!t.__esModule?Lr(r,"default",{value:t,enumerable:!0}):r,t));var ie=x((Uu,os)=>{var as=t=>typeof t<"u"&&t!==null,Pa=t=>typeof t=="object",xa=t=>Object.prototype.toString.call(t)==="[object Object]",Ra=t=>typeof t=="function",$a=t=>typeof t=="boolean",Sa=t=>t instanceof Buffer,ka=t=>{if(as(t))switch(t.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},Aa=t=>t instanceof ArrayBuffer,_a=t=>typeof t=="string"&&t.length>0,Na=t=>typeof t=="number"&&!Number.isNaN(t),Ia=t=>Number.isInteger(t),Fa=(t,e,r)=>t>=e&&t<=r,Ca=(t,e)=>e.includes(t),Da=(t,e,r)=>new Error(`Expected ${e} for ${t} but received ${r} of type ${typeof r}`),ja=(t,e)=>(e.message=t.message,e);os.exports={defined:as,object:Pa,plainObject:xa,fn:Ra,bool:$a,buffer:Sa,typedArray:ka,arrayBuffer:Aa,string:_a,number:Na,integer:Ia,inRange:Fa,inArray:Ca,invalidParameterError:Da,nativeError:ja}});var hs=x((qu,cs)=>{"use strict";var ls=()=>process.platform==="linux",yt=null,Ta=()=>{if(!yt)if(ls()&&process.report){let t=process.report.excludeNetwork;process.report.excludeNetwork=!0,yt=process.report.getReport(),process.report.excludeNetwork=t}else yt={};return yt};cs.exports={isLinux:ls,getReport:Ta}});var fs=x((Gu,us)=>{"use strict";var Ge=I("fs"),La="/usr/bin/ldd",Oa="/proc/self/exe",Et=2048,Ma=t=>{let e=Ge.openSync(t,"r"),r=Buffer.alloc(Et),s=Ge.readSync(e,r,0,Et,0);return Ge.close(e,()=>{}),r.subarray(0,s)},za=t=>new Promise((e,r)=>{Ge.open(t,"r",(s,i)=>{if(s)r(s);else{let n=Buffer.alloc(Et);Ge.read(i,n,0,Et,0,(a,o)=>{e(n.subarray(0,o)),Ge.close(i,()=>{})})}})});us.exports={LDD_PATH:La,SELF_PATH:Oa,readFileSync:Ma,readFile:za}});var gs=x((Hu,ds)=>{"use strict";var Ba=t=>{if(t.length<64||t.readUInt32BE(0)!==2135247942||t.readUInt8(4)!==2||t.readUInt8(5)!==1)return null;let e=t.readUInt32LE(32),r=t.readUInt16LE(54),s=t.readUInt16LE(56);for(let i=0;i<s;i++){let n=e+i*r;if(t.readUInt32LE(n)===3){let o=t.readUInt32LE(n+8),c=t.readUInt32LE(n+32);return t.subarray(o,o+c).toString().replace(/\0.*$/g,"")}}return null};ds.exports={interpreterPath:Ba}});var xt=x((Wu,Fs)=>{"use strict";var ms=I("child_process"),{isLinux:He,getReport:bs}=hs(),{LDD_PATH:Pt,SELF_PATH:vs,readFile:Zt,readFileSync:er}=fs(),{interpreterPath:ws}=gs(),ne,ae,oe,ys="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",$e="",Es=()=>$e||new Promise(t=>{ms.exec(ys,(e,r)=>{$e=e?" ":r,t($e)})}),Ps=()=>{if(!$e)try{$e=ms.execSync(ys,{encoding:"utf8"})}catch{$e=" "}return $e},ve="glibc",xs=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,je="musl",Ua=t=>t.includes("libc.musl-")||t.includes("ld-musl-"),Rs=()=>{let t=bs();return t.header&&t.header.glibcVersionRuntime?ve:Array.isArray(t.sharedObjects)&&t.sharedObjects.some(Ua)?je:null},$s=t=>{let[e,r]=t.split(/[\r\n]+/);return e&&e.includes(ve)?ve:r&&r.includes(je)?je:null},Ss=t=>{if(t){if(t.includes("/ld-musl-"))return je;if(t.includes("/ld-linux-"))return ve}return null},ks=t=>(t=t.toString(),t.includes("musl")?je:t.includes("GNU C Library")?ve:null),qa=async()=>{if(ae!==void 0)return ae;ae=null;try{let t=await Zt(Pt);ae=ks(t)}catch{}return ae},Ga=()=>{if(ae!==void 0)return ae;ae=null;try{let t=er(Pt);ae=ks(t)}catch{}return ae},Ha=async()=>{if(ne!==void 0)return ne;ne=null;try{let t=await Zt(vs),e=ws(t);ne=Ss(e)}catch{}return ne},Wa=()=>{if(ne!==void 0)return ne;ne=null;try{let t=er(vs),e=ws(t);ne=Ss(e)}catch{}return ne},As=async()=>{let t=null;if(He()&&(t=await Ha(),!t&&(t=await qa(),t||(t=Rs()),!t))){let e=await Es();t=$s(e)}return t},_s=()=>{let t=null;if(He()&&(t=Wa(),!t&&(t=Ga(),t||(t=Rs()),!t))){let e=Ps();t=$s(e)}return t},Va=async()=>He()&&await As()!==ve,Ja=()=>He()&&_s()!==ve,Xa=async()=>{if(oe!==void 0)return oe;oe=null;try{let e=(await Zt(Pt)).match(xs);e&&(oe=e[1])}catch{}return oe},Ya=()=>{if(oe!==void 0)return oe;oe=null;try{let e=er(Pt).match(xs);e&&(oe=e[1])}catch{}return oe},Ns=()=>{let t=bs();return t.header&&t.header.glibcVersionRuntime?t.header.glibcVersionRuntime:null},ps=t=>t.trim().split(/\s+/)[1],Is=t=>{let[e,r,s]=t.split(/[\r\n]+/);return e&&e.includes(ve)?ps(e):r&&s&&r.includes(je)?ps(s):null},Ka=async()=>{let t=null;if(He()&&(t=await Xa(),t||(t=Ns()),!t)){let e=await Es();t=Is(e)}return t},Qa=()=>{let t=null;if(He()&&(t=Ya(),t||(t=Ns()),!t)){let e=Ps();t=Is(e)}return t};Fs.exports={GLIBC:ve,MUSL:je,family:As,familySync:_s,isNonGlibcLinux:Va,isNonGlibcLinuxSync:Ja,version:Ka,versionSync:Qa}});var lt=x((Vu,Cs)=>{"use strict";var Za=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>{}:()=>{};Cs.exports=Za});var Rt=x((Ju,Ds)=>{"use strict";var eo="2.0.0",to=Number.MAX_SAFE_INTEGER||9007199254740991,ro=16,so=250,io=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Ds.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:ro,MAX_SAFE_BUILD_LENGTH:so,MAX_SAFE_INTEGER:to,RELEASE_TYPES:io,SEMVER_SPEC_VERSION:eo,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var ct=x((le,js)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:tr,MAX_SAFE_BUILD_LENGTH:no,MAX_LENGTH:ao}=Rt(),oo=lt();le=js.exports={};var lo=le.re=[],co=le.safeRe=[],v=le.src=[],ho=le.safeSrc=[],w=le.t={},uo=0,rr="[a-zA-Z0-9-]",fo=[["\\s",1],["\\d",ao],[rr,no]],go=t=>{for(let[e,r]of fo)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t},P=(t,e,r)=>{let s=go(e),i=uo++;oo(t,i,e),w[t]=i,v[i]=e,ho[i]=s,lo[i]=new RegExp(e,r?"g":void 0),co[i]=new RegExp(s,r?"g":void 0)};P("NUMERICIDENTIFIER","0|[1-9]\\d*");P("NUMERICIDENTIFIERLOOSE","\\d+");P("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${rr}*`);P("MAINVERSION",`(${v[w.NUMERICIDENTIFIER]})\\.(${v[w.NUMERICIDENTIFIER]})\\.(${v[w.NUMERICIDENTIFIER]})`);P("MAINVERSIONLOOSE",`(${v[w.NUMERICIDENTIFIERLOOSE]})\\.(${v[w.NUMERICIDENTIFIERLOOSE]})\\.(${v[w.NUMERICIDENTIFIERLOOSE]})`);P("PRERELEASEIDENTIFIER",`(?:${v[w.NONNUMERICIDENTIFIER]}|${v[w.NUMERICIDENTIFIER]})`);P("PRERELEASEIDENTIFIERLOOSE",`(?:${v[w.NONNUMERICIDENTIFIER]}|${v[w.NUMERICIDENTIFIERLOOSE]})`);P("PRERELEASE",`(?:-(${v[w.PRERELEASEIDENTIFIER]}(?:\\.${v[w.PRERELEASEIDENTIFIER]})*))`);P("PRERELEASELOOSE",`(?:-?(${v[w.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${v[w.PRERELEASEIDENTIFIERLOOSE]})*))`);P("BUILDIDENTIFIER",`${rr}+`);P("BUILD",`(?:\\+(${v[w.BUILDIDENTIFIER]}(?:\\.${v[w.BUILDIDENTIFIER]})*))`);P("FULLPLAIN",`v?${v[w.MAINVERSION]}${v[w.PRERELEASE]}?${v[w.BUILD]}?`);P("FULL",`^${v[w.FULLPLAIN]}$`);P("LOOSEPLAIN",`[v=\\s]*${v[w.MAINVERSIONLOOSE]}${v[w.PRERELEASELOOSE]}?${v[w.BUILD]}?`);P("LOOSE",`^${v[w.LOOSEPLAIN]}$`);P("GTLT","((?:<|>)?=?)");P("XRANGEIDENTIFIERLOOSE",`${v[w.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);P("XRANGEIDENTIFIER",`${v[w.NUMERICIDENTIFIER]}|x|X|\\*`);P("XRANGEPLAIN",`[v=\\s]*(${v[w.XRANGEIDENTIFIER]})(?:\\.(${v[w.XRANGEIDENTIFIER]})(?:\\.(${v[w.XRANGEIDENTIFIER]})(?:${v[w.PRERELEASE]})?${v[w.BUILD]}?)?)?`);P("XRANGEPLAINLOOSE",`[v=\\s]*(${v[w.XRANGEIDENTIFIERLOOSE]})(?:\\.(${v[w.XRANGEIDENTIFIERLOOSE]})(?:\\.(${v[w.XRANGEIDENTIFIERLOOSE]})(?:${v[w.PRERELEASELOOSE]})?${v[w.BUILD]}?)?)?`);P("XRANGE",`^${v[w.GTLT]}\\s*${v[w.XRANGEPLAIN]}$`);P("XRANGELOOSE",`^${v[w.GTLT]}\\s*${v[w.XRANGEPLAINLOOSE]}$`);P("COERCEPLAIN",`(^|[^\\d])(\\d{1,${tr}})(?:\\.(\\d{1,${tr}}))?(?:\\.(\\d{1,${tr}}))?`);P("COERCE",`${v[w.COERCEPLAIN]}(?:$|[^\\d])`);P("COERCEFULL",v[w.COERCEPLAIN]+`(?:${v[w.PRERELEASE]})?(?:${v[w.BUILD]})?(?:$|[^\\d])`);P("COERCERTL",v[w.COERCE],!0);P("COERCERTLFULL",v[w.COERCEFULL],!0);P("LONETILDE","(?:~>?)");P("TILDETRIM",`(\\s*)${v[w.LONETILDE]}\\s+`,!0);le.tildeTrimReplace="$1~";P("TILDE",`^${v[w.LONETILDE]}${v[w.XRANGEPLAIN]}$`);P("TILDELOOSE",`^${v[w.LONETILDE]}${v[w.XRANGEPLAINLOOSE]}$`);P("LONECARET","(?:\\^)");P("CARETTRIM",`(\\s*)${v[w.LONECARET]}\\s+`,!0);le.caretTrimReplace="$1^";P("CARET",`^${v[w.LONECARET]}${v[w.XRANGEPLAIN]}$`);P("CARETLOOSE",`^${v[w.LONECARET]}${v[w.XRANGEPLAINLOOSE]}$`);P("COMPARATORLOOSE",`^${v[w.GTLT]}\\s*(${v[w.LOOSEPLAIN]})$|^$`);P("COMPARATOR",`^${v[w.GTLT]}\\s*(${v[w.FULLPLAIN]})$|^$`);P("COMPARATORTRIM",`(\\s*)${v[w.GTLT]}\\s*(${v[w.LOOSEPLAIN]}|${v[w.XRANGEPLAIN]})`,!0);le.comparatorTrimReplace="$1$2$3";P("HYPHENRANGE",`^\\s*(${v[w.XRANGEPLAIN]})\\s+-\\s+(${v[w.XRANGEPLAIN]})\\s*$`);P("HYPHENRANGELOOSE",`^\\s*(${v[w.XRANGEPLAINLOOSE]})\\s+-\\s+(${v[w.XRANGEPLAINLOOSE]})\\s*$`);P("STAR","(<|>)?=?\\s*\\*");P("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");P("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var $t=x((Xu,Ts)=>{"use strict";var po=Object.freeze({loose:!0}),mo=Object.freeze({}),bo=t=>t?typeof t!="object"?po:t:mo;Ts.exports=bo});var zs=x((Yu,Ms)=>{"use strict";var Ls=/^[0-9]+$/,Os=(t,e)=>{if(typeof t=="number"&&typeof e=="number")return t===e?0:t<e?-1:1;let r=Ls.test(t),s=Ls.test(e);return r&&s&&(t=+t,e=+e),t===e?0:r&&!s?-1:s&&!r?1:t<e?-1:1},vo=(t,e)=>Os(e,t);Ms.exports={compareIdentifiers:Os,rcompareIdentifiers:vo}});var We=x((Ku,Us)=>{"use strict";var St=lt(),{MAX_LENGTH:Bs,MAX_SAFE_INTEGER:kt}=Rt(),{safeRe:At,t:_t}=ct(),wo=$t(),{compareIdentifiers:sr}=zs(),ir=class t{constructor(e,r){if(r=wo(r),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>Bs)throw new TypeError(`version is longer than ${Bs} characters`);St("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=e.trim().match(r.loose?At[_t.LOOSE]:At[_t.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>kt||this.major<0)throw new TypeError("Invalid major version");if(this.minor>kt||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>kt||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let n=+i;if(n>=0&&n<kt)return n}return i}):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(e){if(St("SemVer.compare",this.version,this.options,e),!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof t||(e=new t(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{let s=this.prerelease[r],i=e.prerelease[r];if(St("prerelease compare",r,s,i),s===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(s===void 0)return-1;if(s===i)continue;return sr(s,i)}while(++r)}compareBuild(e){e instanceof t||(e=new t(e,this.options));let r=0;do{let s=this.build[r],i=e.build[r];if(St("build compare",r,s,i),s===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(s===void 0)return-1;if(s===i)continue;return sr(s,i)}while(++r)}inc(e,r,s){if(e.startsWith("pre")){if(!r&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let i=`-${r}`.match(this.options.loose?At[_t.PRERELEASELOOSE]:At[_t.PRERELEASE]);if(!i||i[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(e){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 i=Number(s)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let n=this.prerelease.length;for(;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);if(n===-1){if(r===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let n=[r,i];s===!1&&(n=[r]),sr(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Us.exports=ir});var Hs=x((Qu,Gs)=>{"use strict";var qs=We(),yo=(t,e,r=!1)=>{if(t instanceof qs)return t;try{return new qs(t,e)}catch(s){if(!r)return null;throw s}};Gs.exports=yo});var Vs=x((Zu,Ws)=>{"use strict";var Eo=We(),Po=Hs(),{safeRe:Nt,t:It}=ct(),xo=(t,e)=>{if(t instanceof Eo)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(e.includePrerelease?Nt[It.COERCEFULL]:Nt[It.COERCE]);else{let c=e.includePrerelease?Nt[It.COERCERTLFULL]:Nt[It.COERCERTL],h;for(;(h=c.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||h.index+h[0].length!==r.index+r[0].length)&&(r=h),c.lastIndex=h.index+h[1].length+h[2].length;c.lastIndex=-1}if(r===null)return null;let s=r[2],i=r[3]||"0",n=r[4]||"0",a=e.includePrerelease&&r[5]?`-${r[5]}`:"",o=e.includePrerelease&&r[6]?`+${r[6]}`:"";return Po(`${s}.${i}.${n}${a}${o}`,e)};Ws.exports=xo});var Te=x((ef,Xs)=>{"use strict";var Js=We(),Ro=(t,e,r)=>new Js(t,r).compare(new Js(e,r));Xs.exports=Ro});var nr=x((tf,Ys)=>{"use strict";var $o=Te(),So=(t,e,r)=>$o(t,e,r)>=0;Ys.exports=So});var Qs=x((rf,Ks)=>{"use strict";var ar=class{constructor(){this.max=1e3,this.map=new Map}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&r!==void 0){if(this.map.size>=this.max){let i=this.map.keys().next().value;this.delete(i)}this.map.set(e,r)}return this}};Ks.exports=ar});var ei=x((sf,Zs)=>{"use strict";var ko=Te(),Ao=(t,e,r)=>ko(t,e,r)===0;Zs.exports=Ao});var ri=x((nf,ti)=>{"use strict";var _o=Te(),No=(t,e,r)=>_o(t,e,r)!==0;ti.exports=No});var ii=x((af,si)=>{"use strict";var Io=Te(),Fo=(t,e,r)=>Io(t,e,r)>0;si.exports=Fo});var ai=x((of,ni)=>{"use strict";var Co=Te(),Do=(t,e,r)=>Co(t,e,r)<0;ni.exports=Do});var li=x((lf,oi)=>{"use strict";var jo=Te(),To=(t,e,r)=>jo(t,e,r)<=0;oi.exports=To});var hi=x((cf,ci)=>{"use strict";var Lo=ei(),Oo=ri(),Mo=ii(),zo=nr(),Bo=ai(),Uo=li(),qo=(t,e,r,s)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return Lo(t,r,s);case"!=":return Oo(t,r,s);case">":return Mo(t,r,s);case">=":return zo(t,r,s);case"<":return Bo(t,r,s);case"<=":return Uo(t,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};ci.exports=qo});var bi=x((hf,mi)=>{"use strict";var ht=Symbol("SemVer ANY"),cr=class t{static get ANY(){return ht}constructor(e,r){if(r=ui(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),lr("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===ht?this.value="":this.value=this.operator+this.semver.version,lr("comp",this)}parse(e){let r=this.options.loose?fi[di.COMPARATORLOOSE]:fi[di.COMPARATOR],s=e.match(r);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new gi(s[2],this.options.loose):this.semver=ht}toString(){return this.value}test(e){if(lr("Comparator.test",e,this.options.loose),this.semver===ht||e===ht)return!0;if(typeof e=="string")try{e=new gi(e,this.options)}catch{return!1}return or(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new pi(e.value,r).test(this.value):e.operator===""?e.value===""?!0:new pi(this.value,r).test(e.semver):(r=ui(r),r.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||or(this.semver,"<",e.semver,r)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||or(this.semver,">",e.semver,r)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};mi.exports=cr;var ui=$t(),{safeRe:fi,t:di}=ct(),or=hi(),lr=lt(),gi=We(),pi=hr()});var hr=x((uf,Ei)=>{"use strict";var Go=/\s+/g,ur=class t{constructor(e,r){if(r=Wo(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof fr)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e.trim().replace(Go," "),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(i=>!wi(i[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let i of this.set)if(i.length===1&&Zo(i[0])){this.set=[i];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let r=this.set[e];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(e){let s=((this.options.includePrerelease&&Ko)|(this.options.loose&&Qo))+":"+e,i=vi.get(s);if(i)return i;let n=this.options.loose,a=n?M[O.HYPHENRANGELOOSE]:M[O.HYPHENRANGE];e=e.replace(a,cl(this.options.includePrerelease)),N("hyphen replace",e),e=e.replace(M[O.COMPARATORTRIM],Jo),N("comparator trim",e),e=e.replace(M[O.TILDETRIM],Xo),N("tilde trim",e),e=e.replace(M[O.CARETTRIM],Yo),N("caret trim",e);let o=e.split(" ").map(g=>el(g,this.options)).join(" ").split(/\s+/).map(g=>ll(g,this.options));n&&(o=o.filter(g=>(N("loose invalid filter",g,this.options),!!g.match(M[O.COMPARATORLOOSE])))),N("range list",o);let c=new Map,h=o.map(g=>new fr(g,this.options));for(let g of h){if(wi(g))return[g];c.set(g.value,g)}c.size>1&&c.has("")&&c.delete("");let f=[...c.values()];return vi.set(s,f),f}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(s=>yi(s,r)&&e.set.some(i=>yi(i,r)&&s.every(n=>i.every(a=>n.intersects(a,r)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new Vo(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(hl(this.set[r],e,this.options))return!0;return!1}};Ei.exports=ur;var Ho=Qs(),vi=new Ho,Wo=$t(),fr=bi(),N=lt(),Vo=We(),{safeRe:M,t:O,comparatorTrimReplace:Jo,tildeTrimReplace:Xo,caretTrimReplace:Yo}=ct(),{FLAG_INCLUDE_PRERELEASE:Ko,FLAG_LOOSE:Qo}=Rt(),wi=t=>t.value==="<0.0.0-0",Zo=t=>t.value==="",yi=(t,e)=>{let r=!0,s=t.slice(),i=s.pop();for(;r&&s.length;)r=s.every(n=>i.intersects(n,e)),i=s.pop();return r},el=(t,e)=>(t=t.replace(M[O.BUILD],""),N("comp",t,e),t=sl(t,e),N("caret",t),t=tl(t,e),N("tildes",t),t=nl(t,e),N("xrange",t),t=ol(t,e),N("stars",t),t),z=t=>!t||t.toLowerCase()==="x"||t==="*",tl=(t,e)=>t.trim().split(/\s+/).map(r=>rl(r,e)).join(" "),rl=(t,e)=>{let r=e.loose?M[O.TILDELOOSE]:M[O.TILDE];return t.replace(r,(s,i,n,a,o)=>{N("tilde",t,s,i,n,a,o);let c;return z(i)?c="":z(n)?c=`>=${i}.0.0 <${+i+1}.0.0-0`:z(a)?c=`>=${i}.${n}.0 <${i}.${+n+1}.0-0`:o?(N("replaceTilde pr",o),c=`>=${i}.${n}.${a}-${o} <${i}.${+n+1}.0-0`):c=`>=${i}.${n}.${a} <${i}.${+n+1}.0-0`,N("tilde return",c),c})},sl=(t,e)=>t.trim().split(/\s+/).map(r=>il(r,e)).join(" "),il=(t,e)=>{N("caret",t,e);let r=e.loose?M[O.CARETLOOSE]:M[O.CARET],s=e.includePrerelease?"-0":"";return t.replace(r,(i,n,a,o,c)=>{N("caret",t,i,n,a,o,c);let h;return z(n)?h="":z(a)?h=`>=${n}.0.0${s} <${+n+1}.0.0-0`:z(o)?n==="0"?h=`>=${n}.${a}.0${s} <${n}.${+a+1}.0-0`:h=`>=${n}.${a}.0${s} <${+n+1}.0.0-0`:c?(N("replaceCaret pr",c),n==="0"?a==="0"?h=`>=${n}.${a}.${o}-${c} <${n}.${a}.${+o+1}-0`:h=`>=${n}.${a}.${o}-${c} <${n}.${+a+1}.0-0`:h=`>=${n}.${a}.${o}-${c} <${+n+1}.0.0-0`):(N("no pr"),n==="0"?a==="0"?h=`>=${n}.${a}.${o}${s} <${n}.${a}.${+o+1}-0`:h=`>=${n}.${a}.${o}${s} <${n}.${+a+1}.0-0`:h=`>=${n}.${a}.${o} <${+n+1}.0.0-0`),N("caret return",h),h})},nl=(t,e)=>(N("replaceXRanges",t,e),t.split(/\s+/).map(r=>al(r,e)).join(" ")),al=(t,e)=>{t=t.trim();let r=e.loose?M[O.XRANGELOOSE]:M[O.XRANGE];return t.replace(r,(s,i,n,a,o,c)=>{N("xRange",t,s,i,n,a,o,c);let h=z(n),f=h||z(a),g=f||z(o),m=g;return i==="="&&m&&(i=""),c=e.includePrerelease?"-0":"",h?i===">"||i==="<"?s="<0.0.0-0":s="*":i&&m?(f&&(a=0),o=0,i===">"?(i=">=",f?(n=+n+1,a=0,o=0):(a=+a+1,o=0)):i==="<="&&(i="<",f?n=+n+1:a=+a+1),i==="<"&&(c="-0"),s=`${i+n}.${a}.${o}${c}`):f?s=`>=${n}.0.0${c} <${+n+1}.0.0-0`:g&&(s=`>=${n}.${a}.0${c} <${n}.${+a+1}.0-0`),N("xRange return",s),s})},ol=(t,e)=>(N("replaceStars",t,e),t.trim().replace(M[O.STAR],"")),ll=(t,e)=>(N("replaceGTE0",t,e),t.trim().replace(M[e.includePrerelease?O.GTE0PRE:O.GTE0],"")),cl=t=>(e,r,s,i,n,a,o,c,h,f,g,m)=>(z(s)?r="":z(i)?r=`>=${s}.0.0${t?"-0":""}`:z(n)?r=`>=${s}.${i}.0${t?"-0":""}`:a?r=`>=${r}`:r=`>=${r}${t?"-0":""}`,z(h)?c="":z(f)?c=`<${+h+1}.0.0-0`:z(g)?c=`<${h}.${+f+1}.0-0`:m?c=`<=${h}.${f}.${g}-${m}`:t?c=`<${h}.${f}.${+g+1}-0`:c=`<=${c}`,`${r} ${c}`.trim()),hl=(t,e,r)=>{for(let s=0;s<t.length;s++)if(!t[s].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let s=0;s<t.length;s++)if(N(t[s].semver),t[s].semver!==fr.ANY&&t[s].semver.prerelease.length>0){let i=t[s].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0}});var xi=x((ff,Pi)=>{"use strict";var ul=hr(),fl=(t,e,r)=>{try{e=new ul(e,r)}catch{return!1}return e.test(t)};Pi.exports=fl});var dr=x((df,dl)=>{dl.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=x((gf,Ci)=>{var{spawnSync:Ft}=I("node:child_process"),{createHash:gl}=I("node:crypto"),ki=Vs(),pl=nr(),ml=xi(),Ri=xt(),{config:bl,engines:$i,optionalDependencies:vl}=dr(),wl=process.env.npm_package_config_libvips||bl.libvips,Ai=ki(wl).version,yl=["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"],Ct={encoding:"utf8",shell:!0},El=t=>{t instanceof Error},_i=()=>Ri.isNonGlibcLinuxSync()?Ri.familySync():"",Pl=()=>`${process.platform}${_i()}-${process.arch}`,Ve=()=>{if(Ni())return"wasm32";let{npm_config_arch:t,npm_config_platform:e,npm_config_libc:r}=process.env,s=typeof r=="string"?r:_i();return`${e||process.platform}${s}-${t||process.arch}`},xl=()=>{try{return I(`@img/sharp-libvips-dev-${Ve()}/include`)}catch{try{return I("@img/sharp-libvips-dev/include")}catch{}}return""},Rl=()=>{try{return I("@img/sharp-libvips-dev/cplusplus")}catch{}return""},$l=()=>{try{return I(`@img/sharp-libvips-dev-${Ve()}/lib`)}catch{try{return I(`@img/sharp-libvips-${Ve()}/lib`)}catch{}}return""},Sl=()=>{if(process.release?.name==="node"&&process.versions&&!ml(process.versions.node,$i.node))return{found:process.versions.node,expected:$i.node}},Ni=()=>{let{CC:t}=process.env;return!!t?.endsWith("/emcc")},kl=()=>process.platform==="darwin"&&process.arch==="x64"?(Ft("sysctl sysctl.proc_translated",Ct).stdout||"").trim()==="sysctl.proc_translated: 1":!1,Si=t=>gl("sha512").update(t).digest("hex"),Al=()=>{try{let t=Si(`imgsharp-libvips-${Ve()}`),e=ki(vl[`@img/sharp-libvips-${Ve()}`],{includePrerelease:!0}).version;return Si(`${t}npm:${e}`).slice(0,10)}catch{}return""},_l=()=>Ft(`node-gyp rebuild --directory=src ${Ni()?"--nodedir=emscripten":""}`,{...Ct,stdio:"inherit"}).status,Ii=()=>process.platform!=="win32"?(Ft("pkg-config --modversion vips-cpp",{...Ct,env:{...process.env,PKG_CONFIG_PATH:Fi()}}).stdout||"").trim():"",Fi=()=>process.platform!=="win32"?[(Ft('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',Ct).stdout||"").trim(),process.env.PKG_CONFIG_PATH,"/usr/local/lib/pkgconfig","/usr/lib/pkgconfig","/usr/local/libdata/pkgconfig","/usr/libdata/pkgconfig"].filter(Boolean).join(":"):"",gr=(t,e,r)=>(r&&r(`Detected ${e}, skipping search for globally-installed libvips`),t),Nl=t=>{if(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)return gr(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",t);if(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)return gr(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",t);if(kl())return gr(!1,"Rosetta",t);let e=Ii();return!!e&&pl(e,Ai)};Ci.exports={minimumLibvipsVersion:Ai,prebuiltPlatforms:yl,buildPlatformArch:Ve,buildSharpLibvipsIncludeDir:xl,buildSharpLibvipsCPlusPlusDir:Rl,buildSharpLibvipsLibDir:$l,isUnsupportedNodeRuntime:Sl,runtimePlatformArch:Pl,log:El,yarnLocator:Al,spawnRebuild:_l,globalLibvipsVersion:Ii,pkgConfigPath:Fi,useGlobalLibvips:Nl}});var ft=x((mf,ji)=>{var{familySync:Il,versionSync:Fl}=xt(),{runtimePlatformArch:Cl,isUnsupportedNodeRuntime:Di,prebuiltPlatforms:Dl,minimumLibvipsVersion:jl}=pr(),Le=Cl(),Tl=[`../src/build/Release/sharp-${Le}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${Le}/sharp.node`,"@img/sharp-wasm32/sharp.node"],mr,Je,ut=[];for(mr of Tl)try{Je=I(mr);break}catch(t){ut.push(t)}if(Je&&mr.startsWith("@img/sharp-linux-x64")&&!Je._isUsingX64V2()){let t=new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");t.code="Unsupported CPU",ut.push(t),Je=null}if(Je)ji.exports=Je;else{let[t,e,r]=["linux","darwin","win32"].map(n=>Le.startsWith(n)),s=[`Could not load the "sharp" module using the ${Le} runtime`];ut.forEach(n=>{n.code!=="MODULE_NOT_FOUND"&&s.push(`${n.code}: ${n.message}`)});let i=ut.map(n=>n.message).join(" ");if(s.push("Possible solutions:"),Di()){let{found:n,expected:a}=Di();s.push("- Please upgrade Node.js:",` Found ${n}`,` Requires ${a}`)}else if(Dl.includes(Le)){let[n,a]=Le.split("-"),o=n.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=${n.replace("musl","")}${o} --cpu=${a} sharp`)}else s.push(`- Manually install libvips >= ${jl}`,"- Add experimental WebAssembly-based dependencies:"," npm install --cpu=wasm32 sharp"," npm install @img/sharp-wasm32");if(t&&/(symbol not found|CXXABI_)/i.test(i))try{let{config:n}=I(`@img/sharp-libvips-${Le}/package`),a=`${Il()} ${Fl()}`,o=`${n.musl?"musl":"glibc"} ${n.musl||n.glibc}`;s.push("- Update your OS:",` Found ${a}`,` Requires ${o}`)}catch{}throw t&&/\/snap\/core[0-9]{2}/.test(i)&&s.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node"),e&&/Incompatible library version/.test(i)&&s.push("- Update Homebrew:"," brew update && brew upgrade vips"),ut.some(n=>n.code==="ERR_DLOPEN_DISABLED")&&s.push("- Run Node.js without using the --no-addons flag"),r&&/The specified procedure could not be found/.test(i)&&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 Li=x((vf,Ti)=>{var Ll=I("node:util"),br=I("node:stream"),Ol=ie();ft();var Ml=Ll.debuglog("sharp"),zl=t=>{Oe.queue.emit("change",t)},Oe=function(t,e){if(arguments.length===1&&!Ol.defined(t))throw new Error("Invalid input");return this instanceof Oe?(br.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),Ml(r)},queueListener:zl},this.options.input=this._createInputDescriptor(t,e,{allowStream:!0}),this):new Oe(t,e)};Object.setPrototypeOf(Oe.prototype,br.Duplex.prototype);Object.setPrototypeOf(Oe,br.Duplex);function Bl(){let t=this.constructor.call(),{debuglog:e,queueListener:r,...s}=this.options;return t.options=structuredClone(s),t.options.debuglog=e,t.options.queueListener=r,this._isStreamInput()&&this.on("finish",()=>{this._flattenBufferIn(),t.options.input.buffer=this.options.input.buffer,t.emit("finish")}),t}Object.assign(Oe.prototype,{clone:Bl});Ti.exports=Oe});var zi=x((wf,Mi)=>{var u=ie(),Se=ft(),Ul={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 Oi(t){let e=ql.filter(r=>u.defined(t[r])).map(r=>[r,t[r]]);return e.length?Object.fromEntries(e):void 0}function Gl(t,e,r){let s={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(u.string(t))s.file=t;else if(u.buffer(t)){if(t.length===0)throw Error("Input Buffer is empty");s.buffer=t}else if(u.arrayBuffer(t)){if(t.byteLength===0)throw Error("Input bit Array is empty");s.buffer=Buffer.from(t,0,t.byteLength)}else if(u.typedArray(t)){if(t.length===0)throw Error("Input Bit Array is empty");s.buffer=Buffer.from(t.buffer,t.byteOffset,t.byteLength)}else if(u.plainObject(t)&&!u.defined(e))e=t,Oi(e)&&(s.buffer=[]);else if(!u.defined(t)&&!u.defined(e)&&u.object(r)&&r.allowStream)s.buffer=[];else if(Array.isArray(t))if(t.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=t.map(i=>this._createInputDescriptor(i));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 '${t}' of type ${typeof t}${u.defined(e)?` when also providing options of type ${typeof e}`:""}`);if(u.object(e)){if(u.defined(e.failOnError))if(u.bool(e.failOnError))s.failOn=e.failOnError?"warning":"none";else throw u.invalidParameterError("failOnError","boolean",e.failOnError);if(u.defined(e.failOn))if(u.string(e.failOn)&&u.inArray(e.failOn,["none","truncated","error","warning"]))s.failOn=e.failOn;else throw u.invalidParameterError("failOn","one of: none, truncated, error, warning",e.failOn);if(u.defined(e.autoOrient))if(u.bool(e.autoOrient))s.autoOrient=e.autoOrient;else throw u.invalidParameterError("autoOrient","boolean",e.autoOrient);if(u.defined(e.density))if(u.inRange(e.density,1,1e5))s.density=e.density;else throw u.invalidParameterError("density","number between 1 and 100000",e.density);if(u.defined(e.ignoreIcc))if(u.bool(e.ignoreIcc))s.ignoreIcc=e.ignoreIcc;else throw u.invalidParameterError("ignoreIcc","boolean",e.ignoreIcc);if(u.defined(e.limitInputPixels))if(u.bool(e.limitInputPixels))s.limitInputPixels=e.limitInputPixels?16383**2:0;else if(u.integer(e.limitInputPixels)&&u.inRange(e.limitInputPixels,0,Number.MAX_SAFE_INTEGER))s.limitInputPixels=e.limitInputPixels;else throw u.invalidParameterError("limitInputPixels","positive integer",e.limitInputPixels);if(u.defined(e.unlimited))if(u.bool(e.unlimited))s.unlimited=e.unlimited;else throw u.invalidParameterError("unlimited","boolean",e.unlimited);if(u.defined(e.sequentialRead))if(u.bool(e.sequentialRead))s.sequentialRead=e.sequentialRead;else throw u.invalidParameterError("sequentialRead","boolean",e.sequentialRead);if(u.defined(e.raw)){if(u.object(e.raw)&&u.integer(e.raw.width)&&e.raw.width>0&&u.integer(e.raw.height)&&e.raw.height>0&&u.integer(e.raw.channels)&&u.inRange(e.raw.channels,1,4))switch(s.rawWidth=e.raw.width,s.rawHeight=e.raw.height,s.rawChannels=e.raw.channels,t.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,u.defined(e.raw.premultiplied))if(u.bool(e.raw.premultiplied))s.rawPremultiplied=e.raw.premultiplied;else throw u.invalidParameterError("raw.premultiplied","boolean",e.raw.premultiplied);if(s.rawPageHeight=0,u.defined(e.raw.pageHeight))if(u.integer(e.raw.pageHeight)&&e.raw.pageHeight>0&&e.raw.pageHeight<=e.raw.height){if(e.raw.height%e.raw.pageHeight!==0)throw new Error(`Expected raw.height ${e.raw.height} to be a multiple of raw.pageHeight ${e.raw.pageHeight}`);s.rawPageHeight=e.raw.pageHeight}else throw u.invalidParameterError("raw.pageHeight","positive integer",e.raw.pageHeight)}if(u.defined(e.animated))if(u.bool(e.animated))s.pages=e.animated?-1:1;else throw u.invalidParameterError("animated","boolean",e.animated);if(u.defined(e.pages))if(u.integer(e.pages)&&u.inRange(e.pages,-1,1e5))s.pages=e.pages;else throw u.invalidParameterError("pages","integer between -1 and 100000",e.pages);if(u.defined(e.page))if(u.integer(e.page)&&u.inRange(e.page,0,1e5))s.page=e.page;else throw u.invalidParameterError("page","integer between 0 and 100000",e.page);if(u.object(e.openSlide)&&u.defined(e.openSlide.level))if(u.integer(e.openSlide.level)&&u.inRange(e.openSlide.level,0,256))s.openSlideLevel=e.openSlide.level;else throw u.invalidParameterError("openSlide.level","integer between 0 and 256",e.openSlide.level);else if(u.defined(e.level))if(u.integer(e.level)&&u.inRange(e.level,0,256))s.openSlideLevel=e.level;else throw u.invalidParameterError("level","integer between 0 and 256",e.level);if(u.object(e.tiff)&&u.defined(e.tiff.subifd))if(u.integer(e.tiff.subifd)&&u.inRange(e.tiff.subifd,-1,1e5))s.tiffSubifd=e.tiff.subifd;else throw u.invalidParameterError("tiff.subifd","integer between -1 and 100000",e.tiff.subifd);else if(u.defined(e.subifd))if(u.integer(e.subifd)&&u.inRange(e.subifd,-1,1e5))s.tiffSubifd=e.subifd;else throw u.invalidParameterError("subifd","integer between -1 and 100000",e.subifd);if(u.object(e.svg)){if(u.defined(e.svg.stylesheet))if(u.string(e.svg.stylesheet))s.svgStylesheet=e.svg.stylesheet;else throw u.invalidParameterError("svg.stylesheet","string",e.svg.stylesheet);if(u.defined(e.svg.highBitdepth))if(u.bool(e.svg.highBitdepth))s.svgHighBitdepth=e.svg.highBitdepth;else throw u.invalidParameterError("svg.highBitdepth","boolean",e.svg.highBitdepth)}if(u.object(e.pdf)&&u.defined(e.pdf.background)?s.pdfBackground=this._getBackgroundColourOption(e.pdf.background):u.defined(e.pdfBackground)&&(s.pdfBackground=this._getBackgroundColourOption(e.pdfBackground)),u.object(e.jp2)&&u.defined(e.jp2.oneshot))if(u.bool(e.jp2.oneshot))s.jp2Oneshot=e.jp2.oneshot;else throw u.invalidParameterError("jp2.oneshot","boolean",e.jp2.oneshot);if(u.defined(e.create))if(u.object(e.create)&&u.integer(e.create.width)&&e.create.width>0&&u.integer(e.create.height)&&e.create.height>0&&u.integer(e.create.channels)){if(s.createWidth=e.create.width,s.createHeight=e.create.height,s.createChannels=e.create.channels,s.createPageHeight=0,u.defined(e.create.pageHeight))if(u.integer(e.create.pageHeight)&&e.create.pageHeight>0&&e.create.pageHeight<=e.create.height){if(e.create.height%e.create.pageHeight!==0)throw new Error(`Expected create.height ${e.create.height} to be a multiple of create.pageHeight ${e.create.pageHeight}`);s.createPageHeight=e.create.pageHeight}else throw u.invalidParameterError("create.pageHeight","positive integer",e.create.pageHeight);if(u.defined(e.create.noise)){if(!u.object(e.create.noise))throw new Error("Expected noise to be an object");if(e.create.noise.type!=="gaussian")throw new Error("Only gaussian noise is supported at the moment");if(s.createNoiseType=e.create.noise.type,!u.inRange(e.create.channels,1,4))throw u.invalidParameterError("create.channels","number between 1 and 4",e.create.channels);if(s.createNoiseMean=128,u.defined(e.create.noise.mean))if(u.number(e.create.noise.mean)&&u.inRange(e.create.noise.mean,0,1e4))s.createNoiseMean=e.create.noise.mean;else throw u.invalidParameterError("create.noise.mean","number between 0 and 10000",e.create.noise.mean);if(s.createNoiseSigma=30,u.defined(e.create.noise.sigma))if(u.number(e.create.noise.sigma)&&u.inRange(e.create.noise.sigma,0,1e4))s.createNoiseSigma=e.create.noise.sigma;else throw u.invalidParameterError("create.noise.sigma","number between 0 and 10000",e.create.noise.sigma)}else if(u.defined(e.create.background)){if(!u.inRange(e.create.channels,3,4))throw u.invalidParameterError("create.channels","number between 3 and 4",e.create.channels);s.createBackground=this._getBackgroundColourOption(e.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(u.defined(e.text))if(u.object(e.text)&&u.string(e.text.text)){if(s.textValue=e.text.text,u.defined(e.text.height)&&u.defined(e.text.dpi))throw new Error("Expected only one of dpi or height");if(u.defined(e.text.font))if(u.string(e.text.font))s.textFont=e.text.font;else throw u.invalidParameterError("text.font","string",e.text.font);if(u.defined(e.text.fontfile))if(u.string(e.text.fontfile))s.textFontfile=e.text.fontfile;else throw u.invalidParameterError("text.fontfile","string",e.text.fontfile);if(u.defined(e.text.width))if(u.integer(e.text.width)&&e.text.width>0)s.textWidth=e.text.width;else throw u.invalidParameterError("text.width","positive integer",e.text.width);if(u.defined(e.text.height))if(u.integer(e.text.height)&&e.text.height>0)s.textHeight=e.text.height;else throw u.invalidParameterError("text.height","positive integer",e.text.height);if(u.defined(e.text.align))if(u.string(e.text.align)&&u.string(this.constructor.align[e.text.align]))s.textAlign=this.constructor.align[e.text.align];else throw u.invalidParameterError("text.align","valid alignment",e.text.align);if(u.defined(e.text.justify))if(u.bool(e.text.justify))s.textJustify=e.text.justify;else throw u.invalidParameterError("text.justify","boolean",e.text.justify);if(u.defined(e.text.dpi))if(u.integer(e.text.dpi)&&u.inRange(e.text.dpi,1,1e6))s.textDpi=e.text.dpi;else throw u.invalidParameterError("text.dpi","integer between 1 and 1000000",e.text.dpi);if(u.defined(e.text.rgba))if(u.bool(e.text.rgba))s.textRgba=e.text.rgba;else throw u.invalidParameterError("text.rgba","bool",e.text.rgba);if(u.defined(e.text.spacing))if(u.integer(e.text.spacing)&&u.inRange(e.text.spacing,-1e6,1e6))s.textSpacing=e.text.spacing;else throw u.invalidParameterError("text.spacing","integer between -1000000 and 1000000",e.text.spacing);if(u.defined(e.text.wrap))if(u.string(e.text.wrap)&&u.inArray(e.text.wrap,["word","char","word-char","none"]))s.textWrap=e.text.wrap;else throw u.invalidParameterError("text.wrap","one of: word, char, word-char, none",e.text.wrap);delete s.buffer}else throw new Error("Expected a valid string to create an image with text.");if(u.defined(e.join))if(u.defined(this.options.join)){if(u.defined(e.join.animated))if(u.bool(e.join.animated))s.joinAnimated=e.join.animated;else throw u.invalidParameterError("join.animated","boolean",e.join.animated);if(u.defined(e.join.across))if(u.integer(e.join.across)&&u.inRange(e.join.across,1,1e6))s.joinAcross=e.join.across;else throw u.invalidParameterError("join.across","integer between 1 and 100000",e.join.across);if(u.defined(e.join.shim))if(u.integer(e.join.shim)&&u.inRange(e.join.shim,0,1e6))s.joinShim=e.join.shim;else throw u.invalidParameterError("join.shim","integer between 0 and 100000",e.join.shim);if(u.defined(e.join.background)&&(s.joinBackground=this._getBackgroundColourOption(e.join.background)),u.defined(e.join.halign))if(u.string(e.join.halign)&&u.string(this.constructor.align[e.join.halign]))s.joinHalign=this.constructor.align[e.join.halign];else throw u.invalidParameterError("join.halign","valid alignment",e.join.halign);if(u.defined(e.join.valign))if(u.string(e.join.valign)&&u.string(this.constructor.align[e.join.valign]))s.joinValign=this.constructor.align[e.join.valign];else throw u.invalidParameterError("join.valign","valid alignment",e.join.valign)}else throw new Error("Expected input to be an array of images to join")}else if(u.defined(e))throw new Error(`Invalid input options ${e}`);return s}function Hl(t,e,r){Array.isArray(this.options.input.buffer)?u.buffer(t)?(this.options.input.buffer.length===0&&this.on("finish",()=>{this.streamInFinished=!0}),this.options.input.buffer.push(t),r()):r(new Error("Non-Buffer data on Writable Stream")):r(new Error("Unexpected data on Writable Stream"))}function Wl(){this._isStreamInput()&&(this.options.input.buffer=Buffer.concat(this.options.input.buffer))}function Vl(){return Array.isArray(this.options.input.buffer)}function Jl(t){let e=Error();return u.fn(t)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Se.metadata(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)})}):Se.metadata(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{let i=()=>{this._flattenBufferIn(),Se.metadata(this.options,(n,a)=>{n?s(u.nativeError(n,e)):r(a)})};this.writableFinished?i():this.once("finish",i)}):new Promise((r,s)=>{Se.metadata(this.options,(i,n)=>{i?s(u.nativeError(i,e)):r(n)})})}function Xl(t){let e=Error();return u.fn(t)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Se.stats(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)})}):Se.stats(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{this.on("finish",function(){this._flattenBufferIn(),Se.stats(this.options,(i,n)=>{i?s(u.nativeError(i,e)):r(n)})})}):new Promise((r,s)=>{Se.stats(this.options,(i,n)=>{i?s(u.nativeError(i,e)):r(n)})})}Mi.exports=t=>{Object.assign(t.prototype,{_inputOptionsFromObject:Oi,_createInputDescriptor:Gl,_write:Hl,_flattenBufferIn:Wl,_isStreamInput:Vl,metadata:Jl,stats:Xl}),t.align=Ul}});var Wi=x((yf,Hi)=>{var E=ie(),Ui={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},qi={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},Bi={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},Gi={entropy:16,attention:17},vr={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},Yl={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},Kl={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function wr(t){return t.angle%360!==0||t.rotationAngle!==0}function Dt(t){return t.width!==-1||t.height!==-1}function Ql(t,e,r){if(Dt(this.options)&&this.options.debuglog("ignoring previous resize options"),this.options.widthPost!==-1&&this.options.debuglog("operation order will be: extract, resize, extract"),E.defined(t))if(E.object(t)&&!E.defined(r))r=t;else if(E.integer(t)&&t>0)this.options.width=t;else throw E.invalidParameterError("width","positive integer",t);else this.options.width=-1;if(E.defined(e))if(E.integer(e)&&e>0)this.options.height=e;else throw E.invalidParameterError("height","positive integer",e);else this.options.height=-1;if(E.object(r)){if(E.defined(r.width))if(E.integer(r.width)&&r.width>0)this.options.width=r.width;else throw E.invalidParameterError("width","positive integer",r.width);if(E.defined(r.height))if(E.integer(r.height)&&r.height>0)this.options.height=r.height;else throw E.invalidParameterError("height","positive integer",r.height);if(E.defined(r.fit)){let s=Kl[r.fit];if(E.string(s))this.options.canvas=s;else throw E.invalidParameterError("fit","valid fit",r.fit)}if(E.defined(r.position)){let s=E.integer(r.position)?r.position:Gi[r.position]||qi[r.position]||Ui[r.position];if(E.integer(s)&&(E.inRange(s,0,8)||E.inRange(s,16,17)))this.options.position=s;else throw E.invalidParameterError("position","valid position/gravity/strategy",r.position)}if(this._setBackgroundColourOption("resizeBackground",r.background),E.defined(r.kernel))if(E.string(vr[r.kernel]))this.options.kernel=vr[r.kernel];else throw E.invalidParameterError("kernel","valid kernel name",r.kernel);E.defined(r.withoutEnlargement)&&this._setBooleanOption("withoutEnlargement",r.withoutEnlargement),E.defined(r.withoutReduction)&&this._setBooleanOption("withoutReduction",r.withoutReduction),E.defined(r.fastShrinkOnLoad)&&this._setBooleanOption("fastShrinkOnLoad",r.fastShrinkOnLoad)}return wr(this.options)&&Dt(this.options)&&(this.options.rotateBefore=!0),this}function Zl(t){if(E.integer(t)&&t>0)this.options.extendTop=t,this.options.extendBottom=t,this.options.extendLeft=t,this.options.extendRight=t;else if(E.object(t)){if(E.defined(t.top))if(E.integer(t.top)&&t.top>=0)this.options.extendTop=t.top;else throw E.invalidParameterError("top","positive integer",t.top);if(E.defined(t.bottom))if(E.integer(t.bottom)&&t.bottom>=0)this.options.extendBottom=t.bottom;else throw E.invalidParameterError("bottom","positive integer",t.bottom);if(E.defined(t.left))if(E.integer(t.left)&&t.left>=0)this.options.extendLeft=t.left;else throw E.invalidParameterError("left","positive integer",t.left);if(E.defined(t.right))if(E.integer(t.right)&&t.right>=0)this.options.extendRight=t.right;else throw E.invalidParameterError("right","positive integer",t.right);if(this._setBackgroundColourOption("extendBackground",t.background),E.defined(t.extendWith))if(E.string(Bi[t.extendWith]))this.options.extendWith=Bi[t.extendWith];else throw E.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",t.extendWith)}else throw E.invalidParameterError("extend","integer or object",t);return this}function ec(t){let e=Dt(this.options)||this.options.widthPre!==-1?"Post":"Pre";return this.options[`width${e}`]!==-1&&this.options.debuglog("ignoring previous extract options"),["left","top","width","height"].forEach(function(r){let s=t[r];if(E.integer(s)&&s>=0)this.options[r+(r==="left"||r==="top"?"Offset":"")+e]=s;else throw E.invalidParameterError(r,"integer",s)},this),wr(this.options)&&!Dt(this.options)&&(this.options.widthPre===-1||this.options.widthPost===-1)&&(this.options.rotateBefore=!0),this.options.input.autoOrient&&(this.options.orientBefore=!0),this}function tc(t){if(this.options.trimThreshold=10,E.defined(t))if(E.object(t)){if(E.defined(t.background)&&this._setBackgroundColourOption("trimBackground",t.background),E.defined(t.threshold))if(E.number(t.threshold)&&t.threshold>=0)this.options.trimThreshold=t.threshold;else throw E.invalidParameterError("threshold","positive number",t.threshold);E.defined(t.lineArt)&&this._setBooleanOption("trimLineArt",t.lineArt)}else throw E.invalidParameterError("trim","object",t);return wr(this.options)&&(this.options.rotateBefore=!0),this}Hi.exports=t=>{Object.assign(t.prototype,{resize:Ql,extend:Zl,extract:ec,trim:tc}),t.gravity=Ui,t.strategy=Gi,t.kernel=vr,t.fit=Yl,t.position=qi}});var Ji=x((Ef,Vi)=>{var _=ie(),yr={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 rc(t){if(!Array.isArray(t))throw _.invalidParameterError("images to composite","array",t);return this.options.composite=t.map(e=>{if(!_.object(e))throw _.invalidParameterError("image to composite","object",e);let r=this._inputOptionsFromObject(e),s={input:this._createInputDescriptor(e.input,r,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(_.defined(e.blend))if(_.string(yr[e.blend]))s.blend=yr[e.blend];else throw _.invalidParameterError("blend","valid blend name",e.blend);if(_.defined(e.tile))if(_.bool(e.tile))s.tile=e.tile;else throw _.invalidParameterError("tile","boolean",e.tile);if(_.defined(e.left))if(_.integer(e.left))s.left=e.left;else throw _.invalidParameterError("left","integer",e.left);if(_.defined(e.top))if(_.integer(e.top))s.top=e.top;else throw _.invalidParameterError("top","integer",e.top);if(_.defined(e.top)!==_.defined(e.left))throw new Error("Expected both left and top to be set");if(s.hasOffset=_.integer(e.top)&&_.integer(e.left),_.defined(e.gravity))if(_.integer(e.gravity)&&_.inRange(e.gravity,0,8))s.gravity=e.gravity;else if(_.string(e.gravity)&&_.integer(this.constructor.gravity[e.gravity]))s.gravity=this.constructor.gravity[e.gravity];else throw _.invalidParameterError("gravity","valid gravity",e.gravity);if(_.defined(e.premultiplied))if(_.bool(e.premultiplied))s.premultiplied=e.premultiplied;else throw _.invalidParameterError("premultiplied","boolean",e.premultiplied);return s}),this}Vi.exports=t=>{t.prototype.composite=rc,t.blend=yr}});var Zi=x((Pf,Qi)=>{var d=ie(),Xi={integer:"integer",float:"float",approximate:"approximate"};function sc(t,e){if(!d.defined(t))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(t)&&!(t%90))this.options.angle=t;else if(d.number(t))this.options.rotationAngle=t,d.object(e)&&e.background&&this._setBackgroundColourOption("rotationBackground",e.background);else throw d.invalidParameterError("angle","numeric",t);return this}function ic(){return this.options.input.autoOrient=!0,this}function nc(t){return this.options.flip=d.bool(t)?t:!0,this}function ac(t){return this.options.flop=d.bool(t)?t:!0,this}function oc(t,e){let r=[].concat(...t);if(r.length===4&&r.every(d.number))this.options.affineMatrix=r;else throw d.invalidParameterError("matrix","1x4 or 2x2 array",t);if(d.defined(e))if(d.object(e)){if(this._setBackgroundColourOption("affineBackground",e.background),d.defined(e.idx))if(d.number(e.idx))this.options.affineIdx=e.idx;else throw d.invalidParameterError("options.idx","number",e.idx);if(d.defined(e.idy))if(d.number(e.idy))this.options.affineIdy=e.idy;else throw d.invalidParameterError("options.idy","number",e.idy);if(d.defined(e.odx))if(d.number(e.odx))this.options.affineOdx=e.odx;else throw d.invalidParameterError("options.odx","number",e.odx);if(d.defined(e.ody))if(d.number(e.ody))this.options.affineOdy=e.ody;else throw d.invalidParameterError("options.ody","number",e.ody);if(d.defined(e.interpolator))if(d.inArray(e.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=e.interpolator;else throw d.invalidParameterError("options.interpolator","valid interpolator name",e.interpolator)}else throw d.invalidParameterError("options","object",e);return this}function lc(t,e,r){if(!d.defined(t))this.options.sharpenSigma=-1;else if(d.bool(t))this.options.sharpenSigma=t?-1:0;else if(d.number(t)&&d.inRange(t,.01,1e4)){if(this.options.sharpenSigma=t,d.defined(e))if(d.number(e)&&d.inRange(e,0,1e4))this.options.sharpenM1=e;else throw d.invalidParameterError("flat","number between 0 and 10000",e);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(t)){if(d.number(t.sigma)&&d.inRange(t.sigma,1e-6,10))this.options.sharpenSigma=t.sigma;else throw d.invalidParameterError("options.sigma","number between 0.000001 and 10",t.sigma);if(d.defined(t.m1))if(d.number(t.m1)&&d.inRange(t.m1,0,1e6))this.options.sharpenM1=t.m1;else throw d.invalidParameterError("options.m1","number between 0 and 1000000",t.m1);if(d.defined(t.m2))if(d.number(t.m2)&&d.inRange(t.m2,0,1e6))this.options.sharpenM2=t.m2;else throw d.invalidParameterError("options.m2","number between 0 and 1000000",t.m2);if(d.defined(t.x1))if(d.number(t.x1)&&d.inRange(t.x1,0,1e6))this.options.sharpenX1=t.x1;else throw d.invalidParameterError("options.x1","number between 0 and 1000000",t.x1);if(d.defined(t.y2))if(d.number(t.y2)&&d.inRange(t.y2,0,1e6))this.options.sharpenY2=t.y2;else throw d.invalidParameterError("options.y2","number between 0 and 1000000",t.y2);if(d.defined(t.y3))if(d.number(t.y3)&&d.inRange(t.y3,0,1e6))this.options.sharpenY3=t.y3;else throw d.invalidParameterError("options.y3","number between 0 and 1000000",t.y3)}else throw d.invalidParameterError("sigma","number between 0.01 and 10000",t);return this}function cc(t){if(!d.defined(t))this.options.medianSize=3;else if(d.integer(t)&&d.inRange(t,1,1e3))this.options.medianSize=t;else throw d.invalidParameterError("size","integer between 1 and 1000",t);return this}function hc(t){let e;if(d.number(t))e=t;else if(d.plainObject(t)){if(!d.number(t.sigma))throw d.invalidParameterError("options.sigma","number between 0.3 and 1000",e);if(e=t.sigma,"precision"in t)if(d.string(Xi[t.precision]))this.options.precision=Xi[t.precision];else throw d.invalidParameterError("precision","one of: integer, float, approximate",t.precision);if("minAmplitude"in t)if(d.number(t.minAmplitude)&&d.inRange(t.minAmplitude,.001,1))this.options.minAmpl=t.minAmplitude;else throw d.invalidParameterError("minAmplitude","number between 0.001 and 1",t.minAmplitude)}if(!d.defined(t))this.options.blurSigma=-1;else if(d.bool(t))this.options.blurSigma=t?-1:0;else if(d.number(e)&&d.inRange(e,.3,1e3))this.options.blurSigma=e;else throw d.invalidParameterError("sigma","number between 0.3 and 1000",e);return this}function Yi(t){if(!d.defined(t))this.options.dilateWidth=1;else if(d.integer(t)&&t>0)this.options.dilateWidth=t;else throw d.invalidParameterError("dilate","positive integer",Yi);return this}function Ki(t){if(!d.defined(t))this.options.erodeWidth=1;else if(d.integer(t)&&t>0)this.options.erodeWidth=t;else throw d.invalidParameterError("erode","positive integer",Ki);return this}function uc(t){return this.options.flatten=d.bool(t)?t:!0,d.object(t)&&this._setBackgroundColourOption("flattenBackground",t.background),this}function fc(){return this.options.unflatten=!0,this}function dc(t,e){if(!d.defined(t))this.options.gamma=2.2;else if(d.number(t)&&d.inRange(t,1,3))this.options.gamma=t;else throw d.invalidParameterError("gamma","number between 1.0 and 3.0",t);if(!d.defined(e))this.options.gammaOut=this.options.gamma;else if(d.number(e)&&d.inRange(e,1,3))this.options.gammaOut=e;else throw d.invalidParameterError("gammaOut","number between 1.0 and 3.0",e);return this}function gc(t){if(this.options.negate=d.bool(t)?t:!0,d.plainObject(t)&&"alpha"in t)if(d.bool(t.alpha))this.options.negateAlpha=t.alpha;else throw d.invalidParameterError("alpha","should be boolean value",t.alpha);return this}function pc(t){if(d.plainObject(t)){if(d.defined(t.lower))if(d.number(t.lower)&&d.inRange(t.lower,0,99))this.options.normaliseLower=t.lower;else throw d.invalidParameterError("lower","number between 0 and 99",t.lower);if(d.defined(t.upper))if(d.number(t.upper)&&d.inRange(t.upper,1,100))this.options.normaliseUpper=t.upper;else throw d.invalidParameterError("upper","number between 1 and 100",t.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 mc(t){return this.normalise(t)}function bc(t){if(d.plainObject(t)){if(d.integer(t.width)&&t.width>0)this.options.claheWidth=t.width;else throw d.invalidParameterError("width","integer greater than zero",t.width);if(d.integer(t.height)&&t.height>0)this.options.claheHeight=t.height;else throw d.invalidParameterError("height","integer greater than zero",t.height);if(d.defined(t.maxSlope))if(d.integer(t.maxSlope)&&d.inRange(t.maxSlope,0,100))this.options.claheMaxSlope=t.maxSlope;else throw d.invalidParameterError("maxSlope","integer between 0 and 100",t.maxSlope)}else throw d.invalidParameterError("options","plain object",t);return this}function vc(t){if(!d.object(t)||!Array.isArray(t.kernel)||!d.integer(t.width)||!d.integer(t.height)||!d.inRange(t.width,3,1001)||!d.inRange(t.height,3,1001)||t.height*t.width!==t.kernel.length)throw new Error("Invalid convolution kernel");return d.integer(t.scale)||(t.scale=t.kernel.reduce((e,r)=>e+r,0)),t.scale<1&&(t.scale=1),d.integer(t.offset)||(t.offset=0),this.options.convKernel=t,this}function wc(t,e){if(!d.defined(t))this.options.threshold=128;else if(d.bool(t))this.options.threshold=t?128:0;else if(d.integer(t)&&d.inRange(t,0,255))this.options.threshold=t;else throw d.invalidParameterError("threshold","integer between 0 and 255",t);return!d.object(e)||e.greyscale===!0||e.grayscale===!0?this.options.thresholdGrayscale=!0:this.options.thresholdGrayscale=!1,this}function yc(t,e,r){if(this.options.boolean=this._createInputDescriptor(t,r),d.string(e)&&d.inArray(e,["and","or","eor"]))this.options.booleanOp=e;else throw d.invalidParameterError("operator","one of: and, or, eor",e);return this}function Ec(t,e){if(!d.defined(t)&&d.number(e)?t=1:d.number(t)&&!d.defined(e)&&(e=0),!d.defined(t))this.options.linearA=[];else if(d.number(t))this.options.linearA=[t];else if(Array.isArray(t)&&t.length&&t.every(d.number))this.options.linearA=t;else throw d.invalidParameterError("a","number or array of numbers",t);if(!d.defined(e))this.options.linearB=[];else if(d.number(e))this.options.linearB=[e];else if(Array.isArray(e)&&e.length&&e.every(d.number))this.options.linearB=e;else throw d.invalidParameterError("b","number or array of numbers",e);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(t){if(!Array.isArray(t))throw d.invalidParameterError("inputMatrix","array",t);if(t.length!==3&&t.length!==4)throw d.invalidParameterError("inputMatrix","3x3 or 4x4 array",t.length);let e=t.flat().map(Number);if(e.length!==9&&e.length!==16)throw d.invalidParameterError("inputMatrix","cardinality of 9 or 16",e.length);return this.options.recombMatrix=e,this}function xc(t){if(!d.plainObject(t))throw d.invalidParameterError("options","plain object",t);if("brightness"in t)if(d.number(t.brightness)&&t.brightness>=0)this.options.brightness=t.brightness;else throw d.invalidParameterError("brightness","number above zero",t.brightness);if("saturation"in t)if(d.number(t.saturation)&&t.saturation>=0)this.options.saturation=t.saturation;else throw d.invalidParameterError("saturation","number above zero",t.saturation);if("hue"in t)if(d.integer(t.hue))this.options.hue=t.hue%360;else throw d.invalidParameterError("hue","number",t.hue);if("lightness"in t)if(d.number(t.lightness))this.options.lightness=t.lightness;else throw d.invalidParameterError("lightness","number",t.lightness);return this}Qi.exports=t=>{Object.assign(t.prototype,{autoOrient:ic,rotate:sc,flip:nc,flop:ac,affine:oc,sharpen:lc,erode:Ki,dilate:Yi,median:cc,blur:hc,flatten:uc,unflatten:fc,gamma:dc,negate:gc,normalise:pc,normalize:mc,clahe:bc,convolve:vc,threshold:wc,boolean:yc,linear:Ec,recomb:Pc,modulate:xc})}});var an=x((xf,nn)=>{var Rr=Object.defineProperty,Rc=Object.getOwnPropertyDescriptor,$c=Object.getOwnPropertyNames,Sc=Object.prototype.hasOwnProperty,kc=(t,e)=>{for(var r in e)Rr(t,r,{get:e[r],enumerable:!0})},Ac=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $c(e))!Sc.call(t,i)&&i!==r&&Rr(t,i,{get:()=>e[i],enumerable:!(s=Rc(e,i))||s.enumerable});return t},_c=t=>Ac(Rr({},"__esModule",{value:!0}),t),en={};kc(en,{default:()=>qc});nn.exports=_c(en);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]},tn=Object.create(null);for(let t in ce)Object.hasOwn(ce,t)&&(tn[ce[t]]=t);var H={to:{},get:{}};H.get=function(t){let e=t.slice(0,3).toLowerCase(),r,s;switch(e){case"hsl":{r=H.get.hsl(t),s="hsl";break}case"hwb":{r=H.get.hwb(t),s="hwb";break}default:{r=H.get.rgb(t),s="rgb";break}}return r?{model:s,value:r}:null};H.get.rgb=function(t){if(!t)return null;let e=/^#([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*)?\)$/,i=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,n=/^(\w+)$/,a=[0,0,0,1],o,c,h;if(o=t.match(r)){for(h=o[2],o=o[1],c=0;c<3;c++){let f=c*2;a[c]=Number.parseInt(o.slice(f,f+2),16)}h&&(a[3]=Number.parseInt(h,16)/255)}else if(o=t.match(e)){for(o=o[1],h=o[3],c=0;c<3;c++)a[c]=Number.parseInt(o[c]+o[c],16);h&&(a[3]=Number.parseInt(h+h,16)/255)}else if(o=t.match(s)){for(c=0;c<3;c++)a[c]=Number.parseInt(o[c+1],10);o[4]&&(a[3]=o[5]?Number.parseFloat(o[4])*.01:Number.parseFloat(o[4]))}else if(o=t.match(i)){for(c=0;c<3;c++)a[c]=Math.round(Number.parseFloat(o[c+1])*2.55);o[4]&&(a[3]=o[5]?Number.parseFloat(o[4])*.01:Number.parseFloat(o[4]))}else return(o=t.match(n))?o[1]==="transparent"?[0,0,0,0]:Object.hasOwn(ce,o[1])?(a=ce[o[1]],a[3]=1,a):null:null;for(c=0;c<3;c++)a[c]=ke(a[c],0,255);return a[3]=ke(a[3],0,1),a};H.get.hsl=function(t){if(!t)return null;let e=/^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=t.match(e);if(r){let s=Number.parseFloat(r[4]),i=(Number.parseFloat(r[1])%360+360)%360,n=ke(Number.parseFloat(r[2]),0,100),a=ke(Number.parseFloat(r[3]),0,100),o=ke(Number.isNaN(s)?1:s,0,1);return[i,n,a,o]}return null};H.get.hwb=function(t){if(!t)return null;let e=/^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=t.match(e);if(r){let s=Number.parseFloat(r[4]),i=(Number.parseFloat(r[1])%360+360)%360,n=ke(Number.parseFloat(r[2]),0,100),a=ke(Number.parseFloat(r[3]),0,100),o=ke(Number.isNaN(s)?1:s,0,1);return[i,n,a,o]}return null};H.to.hex=function(...t){return"#"+jt(t[0])+jt(t[1])+jt(t[2])+(t[3]<1?jt(Math.round(t[3]*255)):"")};H.to.rgb=function(...t){return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"};H.to.rgb.percent=function(...t){let e=Math.round(t[0]/255*100),r=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+r+"%, "+s+"%)":"rgba("+e+"%, "+r+"%, "+s+"%, "+t[3]+")"};H.to.hsl=function(...t){return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"};H.to.hwb=function(...t){let e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"};H.to.keyword=function(...t){return tn[t.slice(0,3)]};function ke(t,e,r){return Math.min(Math.max(e,t),r)}function jt(t){let e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}var Xe=H,rn={};for(let t of Object.keys(ce))rn[ce[t]]=t;var b={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"]}},Me=b,we=(6/29)**3;function Ke(t){let e=t>.0031308?1.055*t**.4166666666666667-.055:t*12.92;return Math.min(Math.max(0,e),1)}function Qe(t){return t>.04045?((t+.055)/1.055)**2.4:t/12.92}for(let t of Object.keys(b)){if(!("channels"in b[t]))throw new Error("missing channels property: "+t);if(!("labels"in b[t]))throw new Error("missing channel labels property: "+t);if(b[t].labels.length!==b[t].channels)throw new Error("channel and label counts mismatch: "+t);let{channels:e,labels:r}=b[t];delete b[t].channels,delete b[t].labels,Object.defineProperty(b[t],"channels",{value:e}),Object.defineProperty(b[t],"labels",{value:r})}b.rgb.hsl=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.min(e,r,s),n=Math.max(e,r,s),a=n-i,o,c;switch(n){case i:{o=0;break}case e:{o=(r-s)/a;break}case r:{o=2+(s-e)/a;break}case s:{o=4+(e-r)/a;break}}o=Math.min(o*60,360),o<0&&(o+=360);let h=(i+n)/2;return n===i?c=0:h<=.5?c=a/(n+i):c=a/(2-n-i),[o,c*100,h*100]};b.rgb.hsv=function(t){let e,r,s,i,n,a=t[0]/255,o=t[1]/255,c=t[2]/255,h=Math.max(a,o,c),f=h-Math.min(a,o,c),g=function(m){return(h-m)/6/f+1/2};if(f===0)i=0,n=0;else{switch(n=f/h,e=g(a),r=g(o),s=g(c),h){case a:{i=s-r;break}case o:{i=1/3+e-s;break}case c:{i=2/3+r-e;break}}i<0?i+=1:i>1&&(i-=1)}return[i*360,n*100,h*100]};b.rgb.hwb=function(t){let e=t[0],r=t[1],s=t[2],i=b.rgb.hsl(t)[0],n=1/255*Math.min(e,Math.min(r,s));return s=1-1/255*Math.max(e,Math.max(r,s)),[i,n*100,s*100]};b.rgb.oklab=function(t){let e=Qe(t[0]/255),r=Qe(t[1]/255),s=Qe(t[2]/255),i=Math.cbrt(.4122214708*e+.5363325363*r+.0514459929*s),n=Math.cbrt(.2119034982*e+.6806995451*r+.1073969566*s),a=Math.cbrt(.0883024619*e+.2817188376*r+.6299787005*s),o=.2104542553*i+.793617785*n-.0040720468*a,c=1.9779984951*i-2.428592205*n+.4505937099*a,h=.0259040371*i+.7827717662*n-.808675766*a;return[o*100,c*100,h*100]};b.rgb.cmyk=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.min(1-e,1-r,1-s),n=(1-e-i)/(1-i)||0,a=(1-r-i)/(1-i)||0,o=(1-s-i)/(1-i)||0;return[n*100,a*100,o*100,i*100]};function Nc(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}b.rgb.keyword=function(t){let e=rn[t];if(e)return e;let r=Number.POSITIVE_INFINITY,s;for(let i of Object.keys(ce)){let n=ce[i],a=Nc(t,n);a<r&&(r=a,s=i)}return s};b.keyword.rgb=function(t){return ce[t]};b.rgb.xyz=function(t){let e=Qe(t[0]/255),r=Qe(t[1]/255),s=Qe(t[2]/255),i=e*.4124564+r*.3575761+s*.1804375,n=e*.2126729+r*.7151522+s*.072175,a=e*.0193339+r*.119192+s*.9503041;return[i*100,n*100,a*100]};b.rgb.lab=function(t){let e=b.rgb.xyz(t),r=e[0],s=e[1],i=e[2];r/=95.047,s/=100,i/=108.883,r=r>we?r**(1/3):7.787*r+16/116,s=s>we?s**(1/3):7.787*s+16/116,i=i>we?i**(1/3):7.787*i+16/116;let n=116*s-16,a=500*(r-s),o=200*(s-i);return[n,a,o]};b.hsl.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,i,n;if(r===0)return n=s*255,[n,n,n];let a=s<.5?s*(1+r):s+r-s*r,o=2*s-a,c=[0,0,0];for(let h=0;h<3;h++)i=e+1/3*-(h-1),i<0&&i++,i>1&&i--,6*i<1?n=o+(a-o)*6*i:2*i<1?n=a:3*i<2?n=o+(a-o)*(2/3-i)*6:n=o,c[h]=n*255;return c};b.hsl.hsv=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,i=r,n=Math.max(s,.01);s*=2,r*=s<=1?s:2-s,i*=n<=1?n:2-n;let a=(s+r)/2,o=s===0?2*i/(n+i):2*r/(s+r);return[e,o*100,a*100]};b.hsv.rgb=function(t){let e=t[0]/60,r=t[1]/100,s=t[2]/100,i=Math.floor(e)%6,n=e-Math.floor(e),a=255*s*(1-r),o=255*s*(1-r*n),c=255*s*(1-r*(1-n));switch(s*=255,i){case 0:return[s,c,a];case 1:return[o,s,a];case 2:return[a,s,c];case 3:return[a,o,s];case 4:return[c,a,s];case 5:return[s,a,o]}};b.hsv.hsl=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,i=Math.max(s,.01),n,a;a=(2-r)*s;let o=(2-r)*i;return n=r*i,n/=o<=1?o:2-o,n=n||0,a/=2,[e,n*100,a*100]};b.hwb.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,i=r+s,n;i>1&&(r/=i,s/=i);let a=Math.floor(6*e),o=1-s;n=6*e-a,(a&1)!==0&&(n=1-n);let c=r+n*(o-r),h,f,g;switch(a){default:case 6:case 0:{h=o,f=c,g=r;break}case 1:{h=c,f=o,g=r;break}case 2:{h=r,f=o,g=c;break}case 3:{h=r,f=c,g=o;break}case 4:{h=c,f=r,g=o;break}case 5:{h=o,f=r,g=c;break}}return[h*255,f*255,g*255]};b.cmyk.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=t[3]/100,n=1-Math.min(1,e*(1-i)+i),a=1-Math.min(1,r*(1-i)+i),o=1-Math.min(1,s*(1-i)+i);return[n*255,a*255,o*255]};b.xyz.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i,n,a;return i=e*3.2404542+r*-1.5371385+s*-.4985314,n=e*-.969266+r*1.8760108+s*.041556,a=e*.0556434+r*-.2040259+s*1.0572252,i=Ke(i),n=Ke(n),a=Ke(a),[i*255,n*255,a*255]};b.xyz.lab=function(t){let e=t[0],r=t[1],s=t[2];e/=95.047,r/=100,s/=108.883,e=e>we?e**(1/3):7.787*e+16/116,r=r>we?r**(1/3):7.787*r+16/116,s=s>we?s**(1/3):7.787*s+16/116;let i=116*r-16,n=500*(e-r),a=200*(r-s);return[i,n,a]};b.xyz.oklab=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=Math.cbrt(.8189330101*e+.3618667424*r-.1288597137*s),n=Math.cbrt(.0329845436*e+.9293118715*r+.0361456387*s),a=Math.cbrt(.0482003018*e+.2643662691*r+.633851707*s),o=.2104542553*i+.793617785*n-.0040720468*a,c=1.9779984951*i-2.428592205*n+.4505937099*a,h=.0259040371*i+.7827717662*n-.808675766*a;return[o*100,c*100,h*100]};b.oklab.oklch=function(t){return b.lab.lch(t)};b.oklab.xyz=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=(.999999998*e+.396337792*r+.215803758*s)**3,n=(1.000000008*e-.105561342*r-.063854175*s)**3,a=(1.000000055*e-.089484182*r-1.291485538*s)**3,o=1.227013851*i-.55779998*n+.281256149*a,c=-.040580178*i+1.11225687*n-.071676679*a,h=-.076381285*i-.421481978*n+1.58616322*a;return[o*100,c*100,h*100]};b.oklab.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=(e+.3963377774*r+.2158037573*s)**3,n=(e-.1055613458*r-.0638541728*s)**3,a=(e-.0894841775*r-1.291485548*s)**3,o=Ke(4.0767416621*i-3.3077115913*n+.2309699292*a),c=Ke(-1.2684380046*i+2.6097574011*n-.3413193965*a),h=Ke(-.0041960863*i-.7034186147*n+1.707614701*a);return[o*255,c*255,h*255]};b.oklch.oklab=function(t){return b.lch.lab(t)};b.lab.xyz=function(t){let e=t[0],r=t[1],s=t[2],i,n,a;n=(e+16)/116,i=r/500+n,a=n-s/200;let o=n**3,c=i**3,h=a**3;return n=o>we?o:(n-16/116)/7.787,i=c>we?c:(i-16/116)/7.787,a=h>we?h:(a-16/116)/7.787,i*=95.047,n*=100,a*=108.883,[i,n,a]};b.lab.lch=function(t){let e=t[0],r=t[1],s=t[2],i;i=Math.atan2(s,r)*360/2/Math.PI,i<0&&(i+=360);let a=Math.sqrt(r*r+s*s);return[e,a,i]};b.lch.lab=function(t){let e=t[0],r=t[1],i=t[2]/360*2*Math.PI,n=r*Math.cos(i),a=r*Math.sin(i);return[e,n,a]};b.rgb.ansi16=function(t,e=null){let[r,s,i]=t,n=e===null?b.rgb.hsv(t)[2]:e;if(n=Math.round(n/50),n===0)return 30;let a=30+(Math.round(i/255)<<2|Math.round(s/255)<<1|Math.round(r/255));return n===2&&(a+=60),a};b.hsv.ansi16=function(t){return b.rgb.ansi16(b.hsv.rgb(t),t[2])};b.rgb.ansi256=function(t){let e=t[0],r=t[1],s=t[2];return e>>4===r>>4&&r>>4===s>>4?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(s/255*5)};b.ansi16.rgb=function(t){t=t[0];let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let r=(Math.trunc(t>50)+1)*.5,s=(e&1)*r*255,i=(e>>1&1)*r*255,n=(e>>2&1)*r*255;return[s,i,n]};b.ansi256.rgb=function(t){if(t=t[0],t>=232){let n=(t-232)*10+8;return[n,n,n]}t-=16;let e,r=Math.floor(t/36)/5*255,s=Math.floor((e=t%36)/6)/5*255,i=e%6/5*255;return[r,s,i]};b.rgb.hex=function(t){let r=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".slice(r.length)+r};b.hex.rgb=function(t){let e=t.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!e)return[0,0,0];let r=e[0];e[0].length===3&&(r=[...r].map(o=>o+o).join(""));let s=Number.parseInt(r,16),i=s>>16&255,n=s>>8&255,a=s&255;return[i,n,a]};b.rgb.hcg=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(e,r),s),n=Math.min(Math.min(e,r),s),a=i-n,o,c=a<1?n/(1-a):0;return a<=0?o=0:i===e?o=(r-s)/a%6:i===r?o=2+(s-e)/a:o=4+(e-r)/a,o/=6,o%=1,[o*360,a*100,c*100]};b.hsl.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=r<.5?2*e*r:2*e*(1-r),i=0;return s<1&&(i=(r-.5*s)/(1-s)),[t[0],s*100,i*100]};b.hsv.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=e*r,i=0;return s<1&&(i=(r-s)/(1-s)),[t[0],s*100,i*100]};b.hcg.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100;if(r===0)return[s*255,s*255,s*255];let i=[0,0,0],n=e%1*6,a=n%1,o=1-a,c=0;switch(Math.floor(n)){case 0:{i[0]=1,i[1]=a,i[2]=0;break}case 1:{i[0]=o,i[1]=1,i[2]=0;break}case 2:{i[0]=0,i[1]=1,i[2]=a;break}case 3:{i[0]=0,i[1]=o,i[2]=1;break}case 4:{i[0]=a,i[1]=0,i[2]=1;break}default:i[0]=1,i[1]=0,i[2]=o}return c=(1-r)*s,[(r*i[0]+c)*255,(r*i[1]+c)*255,(r*i[2]+c)*255]};b.hcg.hsv=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e),i=0;return s>0&&(i=e/s),[t[0],i*100,s*100]};b.hcg.hsl=function(t){let e=t[1]/100,s=t[2]/100*(1-e)+.5*e,i=0;return s>0&&s<.5?i=e/(2*s):s>=.5&&s<1&&(i=e/(2*(1-s))),[t[0],i*100,s*100]};b.hcg.hwb=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e);return[t[0],(s-e)*100,(1-s)*100]};b.hwb.hcg=function(t){let e=t[1]/100,s=1-t[2]/100,i=s-e,n=0;return i<1&&(n=(s-i)/(1-i)),[t[0],i*100,n*100]};b.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};b.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};b.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};b.gray.hsl=function(t){return[0,0,t[0]]};b.gray.hsv=b.gray.hsl;b.gray.hwb=function(t){return[0,100,t[0]]};b.gray.cmyk=function(t){return[0,0,0,t[0]]};b.gray.lab=function(t){return[t[0],0,0]};b.gray.hex=function(t){let e=Math.round(t[0]/100*255)&255,s=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".slice(s.length)+s};b.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};function Ic(){let t={},e=Object.keys(Me);for(let{length:r}=e,s=0;s<r;s++)t[e[s]]={distance:-1,parent:null};return t}function Fc(t){let e=Ic(),r=[t];for(e[t].distance=0;r.length>0;){let s=r.pop(),i=Object.keys(Me[s]);for(let{length:n}=i,a=0;a<n;a++){let o=i[a],c=e[o];c.distance===-1&&(c.distance=e[s].distance+1,c.parent=s,r.unshift(o))}}return e}function Cc(t,e){return function(r){return e(t(r))}}function Dc(t,e){let r=[e[t].parent,t],s=Me[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)r.unshift(e[i].parent),s=Cc(Me[e[i].parent][i],s),i=e[i].parent;return s.conversion=r,s}function jc(t){let e=Fc(t),r={},s=Object.keys(e);for(let{length:i}=s,n=0;n<i;n++){let a=s[n];e[a].parent!==null&&(r[a]=Dc(a,e))}return r}var Tc=jc,Ye={},Lc=Object.keys(Me);function Oc(t){let e=function(...r){let s=r[0];return s==null?s:(s.length>1&&(r=s),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Mc(t){let e=function(...r){let s=r[0];if(s==null)return s;s.length>1&&(r=s);let i=t(r);if(typeof i=="object")for(let{length:n}=i,a=0;a<n;a++)i[a]=Math.round(i[a]);return i};return"conversion"in t&&(e.conversion=t.conversion),e}for(let t of Lc){Ye[t]={},Object.defineProperty(Ye[t],"channels",{value:Me[t].channels}),Object.defineProperty(Ye[t],"labels",{value:Me[t].labels});let e=Tc(t),r=Object.keys(e);for(let s of r){let i=e[s];Ye[t][s]=Mc(i),Ye[t][s].raw=Oc(i)}}var V=Ye,sn=["keyword","gray","hex"],Er={};for(let t of Object.keys(V))Er[[...V[t].labels].sort().join("")]=t;var Pr={};function L(t,e){if(!(this instanceof L))return new L(t,e);if(e&&e in sn&&(e=null),e&&!(e in V))throw new Error("Unknown model: "+e);let r,s;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof L)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if(typeof t=="string"){let i=Xe.get(t);if(i===null)throw new Error("Unable to parse color from string: "+t);this.model=i.model,s=V[this.model].channels,this.color=i.value.slice(0,s),this.valpha=typeof i.value[s]=="number"?i.value[s]:1}else if(t.length>0){this.model=e||"rgb",s=V[this.model].channels;let i=Array.prototype.slice.call(t,0,s);this.color=xr(i,s),this.valpha=typeof t[s]=="number"?t[s]:1}else if(typeof t=="number")this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;let i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);let n=i.sort().join("");if(!(n in Er))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Er[n];let{labels:a}=V[this.model],o=[];for(r=0;r<a.length;r++)o.push(t[a[r]]);this.color=xr(o)}if(Pr[this.model])for(s=V[this.model].channels,r=0;r<s;r++){let i=Pr[this.model][r];i&&(this.color[r]=i(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}L.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let e=this.model in Xe.to?this:this.rgb();e=e.round(typeof t=="number"?t:1);let r=e.valpha===1?e.color:[...e.color,this.valpha];return Xe.to[e.model](...r)},percentString(t){let e=this.rgb().round(typeof t=="number"?t:1),r=e.valpha===1?e.color:[...e.color,this.valpha];return Xe.to.rgb.percent(...r)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let t={},{channels:e}=V[this.model],{labels:r}=V[this.model];for(let s=0;s<e;s++)t[r[s]]=this.color[s];return this.valpha!==1&&(t.alpha=this.valpha),t},unitArray(){let t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,this.valpha!==1&&t.push(this.valpha),t},unitObject(){let t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,this.valpha!==1&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new L([...this.color.map(Bc(t)),this.valpha],this.model)},alpha(t){return t!==void 0?new L([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:F("rgb",0,j(255)),green:F("rgb",1,j(255)),blue:F("rgb",2,j(255)),hue:F(["hsl","hsv","hsl","hwb","hcg"],0,t=>(t%360+360)%360),saturationl:F("hsl",1,j(100)),lightness:F("hsl",2,j(100)),saturationv:F("hsv",1,j(100)),value:F("hsv",2,j(100)),chroma:F("hcg",1,j(100)),gray:F("hcg",2,j(100)),white:F("hwb",1,j(100)),wblack:F("hwb",2,j(100)),cyan:F("cmyk",0,j(100)),magenta:F("cmyk",1,j(100)),yellow:F("cmyk",2,j(100)),black:F("cmyk",3,j(100)),x:F("xyz",0,j(95.047)),y:F("xyz",1,j(100)),z:F("xyz",2,j(108.833)),l:F("lab",0,j(100)),a:F("lab",1),b:F("lab",2),keyword(t){return t!==void 0?new L(t):V[this.model].keyword(this.color)},hex(t){return t!==void 0?new L(t):Xe.to.hex(...this.rgb().round().color)},hexa(t){if(t!==void 0)return new L(t);let e=this.rgb().round().color,r=Math.round(this.valpha*255).toString(16).toUpperCase();return r.length===1&&(r="0"+r),Xe.to.hex(...e)+r},rgbNumber(){let t=this.rgb().color;return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255},luminosity(){let t=this.rgb().color,e=[];for(let[r,s]of t.entries()){let i=s/255;e[r]=i<=.04045?i/12.92:((i+.055)/1.055)**2.4}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(t){let e=this.luminosity(),r=t.luminosity();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},level(t){let e=this.contrast(t);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){let t=this.rgb().color;return(t[0]*2126+t[1]*7152+t[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let t=this.rgb();for(let e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten(t){let e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken(t){let e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate(t){let e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate(t){let e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten(t){let e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken(t){let e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale(){let t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return L.rgb(e,e,e)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){let e=this.hsl(),r=e.color[0];return r=(r+t)%360,r=r<0?360+r:r,e.color[0]=r,e},mix(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);let r=t.rgb(),s=this.rgb(),i=e===void 0?.5:e,n=2*i-1,a=r.alpha()-s.alpha(),o=((n*a===-1?n:(n+a)/(1+n*a))+1)/2,c=1-o;return L.rgb(o*r.red()+c*s.red(),o*r.green()+c*s.green(),o*r.blue()+c*s.blue(),r.alpha()*i+s.alpha()*(1-i))}};for(let t of Object.keys(V)){if(sn.includes(t))continue;let{channels:e}=V[t];L.prototype[t]=function(...r){return this.model===t?new L(this):r.length>0?new L(r,t):new L([...Uc(V[this.model][t].raw(this.color)),this.valpha],t)},L[t]=function(...r){let s=r[0];return typeof s=="number"&&(s=xr(r,e)),new L(s,t)}}function zc(t,e){return Number(t.toFixed(e))}function Bc(t){return function(e){return zc(e,t)}}function F(t,e,r){t=Array.isArray(t)?t:[t];for(let s of t)(Pr[s]||=[])[e]=r;return t=t[0],function(s){let i;return s!==void 0?(r&&(s=r(s)),i=this[t](),i.color[e]=s,i):(i=this[t]().color[e],r&&(i=r(i)),i)}}function j(t){return function(e){return Math.max(0,Math.min(t,e))}}function Uc(t){return Array.isArray(t)?t:[t]}function xr(t,e){for(let r=0;r<e;r++)typeof t[r]!="number"&&(t[r]=0);return t}var qc=L});var ln=x((Rf,on)=>{on.exports=an().default});var fn=x(($f,un)=>{var Gc=ln(),ye=ie(),cn={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function Hc(t){return this._setBackgroundColourOption("tint",t),this}function Wc(t){return this.options.greyscale=ye.bool(t)?t:!0,this}function Vc(t){return this.greyscale(t)}function Jc(t){if(!ye.string(t))throw ye.invalidParameterError("colourspace","string",t);return this.options.colourspacePipeline=t,this}function Xc(t){return this.pipelineColourspace(t)}function Yc(t){if(!ye.string(t))throw ye.invalidParameterError("colourspace","string",t);return this.options.colourspace=t,this}function Kc(t){return this.toColourspace(t)}function hn(t){if(ye.object(t)||ye.string(t)&&t.length>=3&&t.length<=200){let e=Gc(t);return[e.red(),e.green(),e.blue(),Math.round(e.alpha()*255)]}else throw ye.invalidParameterError("background","object or string",t)}function Qc(t,e){ye.defined(e)&&(this.options[t]=hn(e))}un.exports=t=>{Object.assign(t.prototype,{tint:Hc,greyscale:Wc,grayscale:Vc,pipelineColourspace:Jc,pipelineColorspace:Xc,toColourspace:Yc,toColorspace:Kc,_getBackgroundColourOption:hn,_setBackgroundColourOption:Qc}),t.colourspace=cn,t.colorspace=cn}});var gn=x((Sf,dn)=>{var he=ie(),Zc={and:"and",or:"or",eor:"eor"};function eh(){return this.options.removeAlpha=!0,this}function th(t){if(he.defined(t))if(he.number(t)&&he.inRange(t,0,1))this.options.ensureAlpha=t;else throw he.invalidParameterError("alpha","number between 0 and 1",t);else this.options.ensureAlpha=1;return this}function rh(t){let e={red:0,green:1,blue:2,alpha:3};if(Object.keys(e).includes(t)&&(t=e[t]),he.integer(t)&&he.inRange(t,0,4))this.options.extractChannel=t;else throw he.invalidParameterError("channel","integer or one of: red, green, blue, alpha",t);return this}function sh(t,e){return Array.isArray(t)?t.forEach(function(r){this.options.joinChannelIn.push(this._createInputDescriptor(r,e))},this):this.options.joinChannelIn.push(this._createInputDescriptor(t,e)),this}function ih(t){if(he.string(t)&&he.inArray(t,["and","or","eor"]))this.options.bandBoolOp=t;else throw he.invalidParameterError("boolOp","one of: and, or, eor",t);return this}dn.exports=t=>{Object.assign(t.prototype,{removeAlpha:eh,ensureAlpha:th,extractChannel:rh,joinChannel:sh,bandbool:ih}),t.bool=Zc}});var wn=x((kf,vn)=>{var $r=I("node:path"),l=ie(),Ze=ft(),pn=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"]]),nh=/\.(jp[2x]|j2[kc])$/i,mn=()=>new Error("JP2 output requires libvips with support for OpenJPEG"),bn=t=>1<<31-Math.clz32(Math.ceil(Math.log2(t)));function ah(t,e){let r;if(l.string(t)?l.string(this.options.input.file)&&$r.resolve(this.options.input.file)===$r.resolve(t)?r=new Error("Cannot use same file for input and output"):nh.test($r.extname(t))&&!this.constructor.format.jp2k.output.file&&(r=mn()):r=new Error("Missing output file path"),r)if(l.fn(e))e(r);else return Promise.reject(r);else{this.options.fileOut=t;let s=Error();return this._pipeline(e,s)}return this}function oh(t,e){l.object(t)?this._setBooleanOption("resolveWithObject",t.resolveWithObject):this.options.resolveWithObject&&(this.options.resolveWithObject=!1),this.options.fileOut="";let r=Error();return this._pipeline(l.fn(t)?t:e,r)}function lh(){return this.options.keepMetadata|=1,this}function ch(t){if(l.object(t))for(let[e,r]of Object.entries(t))if(l.object(r))for(let[s,i]of Object.entries(r))if(l.string(i))this.options.withExif[`exif-${e.toLowerCase()}-${s}`]=i;else throw l.invalidParameterError(`${e}.${s}`,"string",i);else throw l.invalidParameterError(e,"object",r);else throw l.invalidParameterError("exif","object",t);return this.options.withExifMerge=!1,this.keepExif()}function hh(t){return this.withExif(t),this.options.withExifMerge=!0,this}function uh(){return this.options.keepMetadata|=8,this}function fh(t,e){if(l.string(t))this.options.withIccProfile=t;else throw l.invalidParameterError("icc","string",t);if(this.keepIccProfile(),l.object(e)&&l.defined(e.attach))if(l.bool(e.attach))e.attach||(this.options.keepMetadata&=-9);else throw l.invalidParameterError("attach","boolean",e.attach);return this}function dh(){return this.options.keepMetadata|=2,this}function gh(t){if(l.string(t)&&t.length>0)this.options.withXmp=t,this.options.keepMetadata|=2;else throw l.invalidParameterError("xmp","non-empty string",t);return this}function ph(){return this.options.keepMetadata=31,this}function mh(t){if(this.keepMetadata(),this.withIccProfile("srgb"),l.object(t)){if(l.defined(t.orientation))if(l.integer(t.orientation)&&l.inRange(t.orientation,1,8))this.options.withMetadataOrientation=t.orientation;else throw l.invalidParameterError("orientation","integer between 1 and 8",t.orientation);if(l.defined(t.density))if(l.number(t.density)&&t.density>0)this.options.withMetadataDensity=t.density;else throw l.invalidParameterError("density","positive number",t.density);l.defined(t.icc)&&this.withIccProfile(t.icc),l.defined(t.exif)&&this.withExifMerge(t.exif)}return this}function bh(t,e){let r=pn.get((l.object(t)&&l.string(t.id)?t.id:t).toLowerCase());if(!r)throw l.invalidParameterError("format",`one of: ${[...pn.keys()].join(", ")}`,t);return this[r](e)}function vh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.jpegQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.progressive)&&this._setBooleanOption("jpegProgressive",t.progressive),l.defined(t.chromaSubsampling))if(l.string(t.chromaSubsampling)&&l.inArray(t.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=t.chromaSubsampling;else throw l.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",t.chromaSubsampling);let e=l.bool(t.optimizeCoding)?t.optimizeCoding:t.optimiseCoding;if(l.defined(e)&&this._setBooleanOption("jpegOptimiseCoding",e),l.defined(t.mozjpeg))if(l.bool(t.mozjpeg))t.mozjpeg&&(this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3);else throw l.invalidParameterError("mozjpeg","boolean",t.mozjpeg);let r=l.bool(t.trellisQuantization)?t.trellisQuantization:t.trellisQuantisation;l.defined(r)&&this._setBooleanOption("jpegTrellisQuantisation",r),l.defined(t.overshootDeringing)&&this._setBooleanOption("jpegOvershootDeringing",t.overshootDeringing);let s=l.bool(t.optimizeScans)?t.optimizeScans:t.optimiseScans;l.defined(s)&&(this._setBooleanOption("jpegOptimiseScans",s),s&&(this.options.jpegProgressive=!0));let i=l.number(t.quantizationTable)?t.quantizationTable:t.quantisationTable;if(l.defined(i))if(l.integer(i)&&l.inRange(i,0,8))this.options.jpegQuantisationTable=i;else throw l.invalidParameterError("quantisationTable","integer between 0 and 8",i)}return this._updateFormatOut("jpeg",t)}function wh(t){if(l.object(t)){if(l.defined(t.progressive)&&this._setBooleanOption("pngProgressive",t.progressive),l.defined(t.compressionLevel))if(l.integer(t.compressionLevel)&&l.inRange(t.compressionLevel,0,9))this.options.pngCompressionLevel=t.compressionLevel;else throw l.invalidParameterError("compressionLevel","integer between 0 and 9",t.compressionLevel);l.defined(t.adaptiveFiltering)&&this._setBooleanOption("pngAdaptiveFiltering",t.adaptiveFiltering);let e=t.colours||t.colors;if(l.defined(e))if(l.integer(e)&&l.inRange(e,2,256))this.options.pngBitdepth=bn(e);else throw l.invalidParameterError("colours","integer between 2 and 256",e);if(l.defined(t.palette)?this._setBooleanOption("pngPalette",t.palette):[t.quality,t.effort,t.colours,t.colors,t.dither].some(l.defined)&&this._setBooleanOption("pngPalette",!0),this.options.pngPalette){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,0,100))this.options.pngQuality=t.quality;else throw l.invalidParameterError("quality","integer between 0 and 100",t.quality);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,1,10))this.options.pngEffort=t.effort;else throw l.invalidParameterError("effort","integer between 1 and 10",t.effort);if(l.defined(t.dither))if(l.number(t.dither)&&l.inRange(t.dither,0,1))this.options.pngDither=t.dither;else throw l.invalidParameterError("dither","number between 0.0 and 1.0",t.dither)}}return this._updateFormatOut("png",t)}function yh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.webpQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.alphaQuality))if(l.integer(t.alphaQuality)&&l.inRange(t.alphaQuality,0,100))this.options.webpAlphaQuality=t.alphaQuality;else throw l.invalidParameterError("alphaQuality","integer between 0 and 100",t.alphaQuality);if(l.defined(t.lossless)&&this._setBooleanOption("webpLossless",t.lossless),l.defined(t.nearLossless)&&this._setBooleanOption("webpNearLossless",t.nearLossless),l.defined(t.smartSubsample)&&this._setBooleanOption("webpSmartSubsample",t.smartSubsample),l.defined(t.smartDeblock)&&this._setBooleanOption("webpSmartDeblock",t.smartDeblock),l.defined(t.preset))if(l.string(t.preset)&&l.inArray(t.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=t.preset;else throw l.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",t.preset);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,0,6))this.options.webpEffort=t.effort;else throw l.invalidParameterError("effort","integer between 0 and 6",t.effort);l.defined(t.minSize)&&this._setBooleanOption("webpMinSize",t.minSize),l.defined(t.mixed)&&this._setBooleanOption("webpMixed",t.mixed)}return Sr(t,this.options),this._updateFormatOut("webp",t)}function Eh(t){if(l.object(t)){l.defined(t.reuse)&&this._setBooleanOption("gifReuse",t.reuse),l.defined(t.progressive)&&this._setBooleanOption("gifProgressive",t.progressive);let e=t.colours||t.colors;if(l.defined(e))if(l.integer(e)&&l.inRange(e,2,256))this.options.gifBitdepth=bn(e);else throw l.invalidParameterError("colours","integer between 2 and 256",e);if(l.defined(t.effort))if(l.number(t.effort)&&l.inRange(t.effort,1,10))this.options.gifEffort=t.effort;else throw l.invalidParameterError("effort","integer between 1 and 10",t.effort);if(l.defined(t.dither))if(l.number(t.dither)&&l.inRange(t.dither,0,1))this.options.gifDither=t.dither;else throw l.invalidParameterError("dither","number between 0.0 and 1.0",t.dither);if(l.defined(t.interFrameMaxError))if(l.number(t.interFrameMaxError)&&l.inRange(t.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=t.interFrameMaxError;else throw l.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",t.interFrameMaxError);if(l.defined(t.interPaletteMaxError))if(l.number(t.interPaletteMaxError)&&l.inRange(t.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=t.interPaletteMaxError;else throw l.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",t.interPaletteMaxError);if(l.defined(t.keepDuplicateFrames))if(l.bool(t.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",t.keepDuplicateFrames);else throw l.invalidParameterError("keepDuplicateFrames","boolean",t.keepDuplicateFrames)}return Sr(t,this.options),this._updateFormatOut("gif",t)}function Ph(t){if(!this.constructor.format.jp2k.output.buffer)throw mn();if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.jp2Quality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.lossless))if(l.bool(t.lossless))this.options.jp2Lossless=t.lossless;else throw l.invalidParameterError("lossless","boolean",t.lossless);if(l.defined(t.tileWidth))if(l.integer(t.tileWidth)&&l.inRange(t.tileWidth,1,32768))this.options.jp2TileWidth=t.tileWidth;else throw l.invalidParameterError("tileWidth","integer between 1 and 32768",t.tileWidth);if(l.defined(t.tileHeight))if(l.integer(t.tileHeight)&&l.inRange(t.tileHeight,1,32768))this.options.jp2TileHeight=t.tileHeight;else throw l.invalidParameterError("tileHeight","integer between 1 and 32768",t.tileHeight);if(l.defined(t.chromaSubsampling))if(l.string(t.chromaSubsampling)&&l.inArray(t.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=t.chromaSubsampling;else throw l.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",t.chromaSubsampling)}return this._updateFormatOut("jp2",t)}function Sr(t,e){if(l.object(t)&&l.defined(t.loop))if(l.integer(t.loop)&&l.inRange(t.loop,0,65535))e.loop=t.loop;else throw l.invalidParameterError("loop","integer between 0 and 65535",t.loop);if(l.object(t)&&l.defined(t.delay))if(l.integer(t.delay)&&l.inRange(t.delay,0,65535))e.delay=[t.delay];else if(Array.isArray(t.delay)&&t.delay.every(l.integer)&&t.delay.every(r=>l.inRange(r,0,65535)))e.delay=t.delay;else throw l.invalidParameterError("delay","integer or an array of integers between 0 and 65535",t.delay)}function xh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.tiffQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.bitdepth))if(l.integer(t.bitdepth)&&l.inArray(t.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=t.bitdepth;else throw l.invalidParameterError("bitdepth","1, 2, 4 or 8",t.bitdepth);if(l.defined(t.tile)&&this._setBooleanOption("tiffTile",t.tile),l.defined(t.tileWidth))if(l.integer(t.tileWidth)&&t.tileWidth>0)this.options.tiffTileWidth=t.tileWidth;else throw l.invalidParameterError("tileWidth","integer greater than zero",t.tileWidth);if(l.defined(t.tileHeight))if(l.integer(t.tileHeight)&&t.tileHeight>0)this.options.tiffTileHeight=t.tileHeight;else throw l.invalidParameterError("tileHeight","integer greater than zero",t.tileHeight);if(l.defined(t.miniswhite)&&this._setBooleanOption("tiffMiniswhite",t.miniswhite),l.defined(t.pyramid)&&this._setBooleanOption("tiffPyramid",t.pyramid),l.defined(t.xres))if(l.number(t.xres)&&t.xres>0)this.options.tiffXres=t.xres;else throw l.invalidParameterError("xres","number greater than zero",t.xres);if(l.defined(t.yres))if(l.number(t.yres)&&t.yres>0)this.options.tiffYres=t.yres;else throw l.invalidParameterError("yres","number greater than zero",t.yres);if(l.defined(t.compression))if(l.string(t.compression)&&l.inArray(t.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=t.compression;else throw l.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",t.compression);if(l.defined(t.bigtiff)&&this._setBooleanOption("tiffBigtiff",t.bigtiff),l.defined(t.predictor))if(l.string(t.predictor)&&l.inArray(t.predictor,["none","horizontal","float"]))this.options.tiffPredictor=t.predictor;else throw l.invalidParameterError("predictor","one of: none, horizontal, float",t.predictor);if(l.defined(t.resolutionUnit))if(l.string(t.resolutionUnit)&&l.inArray(t.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=t.resolutionUnit;else throw l.invalidParameterError("resolutionUnit","one of: inch, cm",t.resolutionUnit)}return this._updateFormatOut("tiff",t)}function Rh(t){return this.heif({...t,compression:"av1"})}function $h(t){if(l.object(t)){if(l.string(t.compression)&&l.inArray(t.compression,["av1","hevc"]))this.options.heifCompression=t.compression;else throw l.invalidParameterError("compression","one of: av1, hevc",t.compression);if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.heifQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.lossless))if(l.bool(t.lossless))this.options.heifLossless=t.lossless;else throw l.invalidParameterError("lossless","boolean",t.lossless);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,0,9))this.options.heifEffort=t.effort;else throw l.invalidParameterError("effort","integer between 0 and 9",t.effort);if(l.defined(t.chromaSubsampling))if(l.string(t.chromaSubsampling)&&l.inArray(t.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=t.chromaSubsampling;else throw l.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",t.chromaSubsampling);if(l.defined(t.bitdepth))if(l.integer(t.bitdepth)&&l.inArray(t.bitdepth,[8,10,12])){if(t.bitdepth!==8&&this.constructor.versions.heif)throw l.invalidParameterError("bitdepth when using prebuilt binaries",8,t.bitdepth);this.options.heifBitdepth=t.bitdepth}else throw l.invalidParameterError("bitdepth","8, 10 or 12",t.bitdepth)}else throw l.invalidParameterError("options","Object",t);return this._updateFormatOut("heif",t)}function Sh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.jxlDistance=t.quality>=30?.1+(100-t.quality)*.09:53/3e3*t.quality*t.quality-23/20*t.quality+25;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);else if(l.defined(t.distance))if(l.number(t.distance)&&l.inRange(t.distance,0,15))this.options.jxlDistance=t.distance;else throw l.invalidParameterError("distance","number between 0.0 and 15.0",t.distance);if(l.defined(t.decodingTier))if(l.integer(t.decodingTier)&&l.inRange(t.decodingTier,0,4))this.options.jxlDecodingTier=t.decodingTier;else throw l.invalidParameterError("decodingTier","integer between 0 and 4",t.decodingTier);if(l.defined(t.lossless))if(l.bool(t.lossless))this.options.jxlLossless=t.lossless;else throw l.invalidParameterError("lossless","boolean",t.lossless);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,1,9))this.options.jxlEffort=t.effort;else throw l.invalidParameterError("effort","integer between 1 and 9",t.effort)}return Sr(t,this.options),this._updateFormatOut("jxl",t)}function kh(t){if(l.object(t)&&l.defined(t.depth))if(l.string(t.depth)&&l.inArray(t.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=t.depth;else throw l.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",t.depth);return this._updateFormatOut("raw")}function Ah(t){if(l.object(t)){if(l.defined(t.size))if(l.integer(t.size)&&l.inRange(t.size,1,8192))this.options.tileSize=t.size;else throw l.invalidParameterError("size","integer between 1 and 8192",t.size);if(l.defined(t.overlap))if(l.integer(t.overlap)&&l.inRange(t.overlap,0,8192)){if(t.overlap>this.options.tileSize)throw l.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,t.overlap);this.options.tileOverlap=t.overlap}else throw l.invalidParameterError("overlap","integer between 0 and 8192",t.overlap);if(l.defined(t.container))if(l.string(t.container)&&l.inArray(t.container,["fs","zip"]))this.options.tileContainer=t.container;else throw l.invalidParameterError("container","one of: fs, zip",t.container);if(l.defined(t.layout))if(l.string(t.layout)&&l.inArray(t.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=t.layout;else throw l.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",t.layout);if(l.defined(t.angle))if(l.integer(t.angle)&&!(t.angle%90))this.options.tileAngle=t.angle;else throw l.invalidParameterError("angle","positive/negative multiple of 90",t.angle);if(this._setBackgroundColourOption("tileBackground",t.background),l.defined(t.depth))if(l.string(t.depth)&&l.inArray(t.depth,["onepixel","onetile","one"]))this.options.tileDepth=t.depth;else throw l.invalidParameterError("depth","one of: onepixel, onetile, one",t.depth);if(l.defined(t.skipBlanks))if(l.integer(t.skipBlanks)&&l.inRange(t.skipBlanks,-1,65535))this.options.tileSkipBlanks=t.skipBlanks;else throw l.invalidParameterError("skipBlanks","integer between -1 and 255/65535",t.skipBlanks);else l.defined(t.layout)&&t.layout==="google"&&(this.options.tileSkipBlanks=5);let e=l.bool(t.center)?t.center:t.centre;if(l.defined(e)&&this._setBooleanOption("tileCentre",e),l.defined(t.id))if(l.string(t.id))this.options.tileId=t.id;else throw l.invalidParameterError("id","string",t.id);if(l.defined(t.basename))if(l.string(t.basename))this.options.tileBasename=t.basename;else throw l.invalidParameterError("basename","string",t.basename)}if(l.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw l.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function _h(t){if(!l.plainObject(t))throw l.invalidParameterError("options","object",t);if(l.integer(t.seconds)&&l.inRange(t.seconds,0,3600))this.options.timeoutSeconds=t.seconds;else throw l.invalidParameterError("seconds","integer between 0 and 3600",t.seconds);return this}function Nh(t,e){return l.object(e)&&e.force===!1||(this.options.formatOut=t),this}function Ih(t,e){if(l.bool(e))this.options[t]=e;else throw l.invalidParameterError(t,"boolean",e)}function Fh(){if(!this.options.streamOut){this.options.streamOut=!0;let t=Error();this._pipeline(void 0,t)}}function Ch(t,e){return typeof t=="function"?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Ze.pipeline(this.options,(r,s,i)=>{r?t(l.nativeError(r,e)):t(null,s,i)})}):Ze.pipeline(this.options,(r,s,i)=>{r?t(l.nativeError(r,e)):t(null,s,i)}),this):this.options.streamOut?(this._isStreamInput()?(this.once("finish",()=>{this._flattenBufferIn(),Ze.pipeline(this.options,(r,s,i)=>{r?this.emit("error",l.nativeError(r,e)):(this.emit("info",i),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished&&this.emit("finish")):Ze.pipeline(this.options,(r,s,i)=>{r?this.emit("error",l.nativeError(r,e)):(this.emit("info",i),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))}),this):this._isStreamInput()?new Promise((r,s)=>{this.once("finish",()=>{this._flattenBufferIn(),Ze.pipeline(this.options,(i,n,a)=>{i?s(l.nativeError(i,e)):this.options.resolveWithObject?r({data:n,info:a}):r(n)})})}):new Promise((r,s)=>{Ze.pipeline(this.options,(i,n,a)=>{i?s(l.nativeError(i,e)):this.options.resolveWithObject?r({data:n,info:a}):r(n)})})}vn.exports=t=>{Object.assign(t.prototype,{toFile:ah,toBuffer:oh,keepExif:lh,withExif:ch,withExifMerge:hh,keepIccProfile:uh,withIccProfile:fh,keepXmp:dh,withXmp:gh,keepMetadata:ph,withMetadata:mh,toFormat:bh,jpeg:vh,jp2:Ph,png:wh,webp:yh,tiff:xh,avif:Rh,heif:$h,jxl:Sh,gif:Eh,raw:kh,tile:Ah,timeout:_h,_updateFormatOut:Nh,_setBooleanOption:Ih,_read:Fh,_pipeline:Ch})}});var xn=x((Af,Pn)=>{var Dh=I("node:events"),Tt=xt(),Z=ie(),{runtimePlatformArch:jh}=pr(),B=ft(),yn=jh(),kr=B.libvipsVersion(),Ae=B.format();Ae.heif.output.alias=["avif","heic"];Ae.jpeg.output.alias=["jpe","jpg"];Ae.tiff.output.alias=["tif"];Ae.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var Th={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},et={vips:kr.semver};if(!kr.isGlobal)if(kr.isWasm)try{et=I("@img/sharp-wasm32/versions")}catch{}else try{et=I(`@img/sharp-${yn}/versions`)}catch{try{et=I(`@img/sharp-libvips-${yn}/versions`)}catch{}}et.sharp=dr().version;et.heif&&Ae.heif&&(Ae.heif.input.fileSuffix=[".avif"],Ae.heif.output.alias=["avif"]);function En(t){return Z.bool(t)?t?B.cache(50,20,100):B.cache(0,0,0):Z.object(t)?B.cache(t.memory,t.files,t.items):B.cache()}En(!0);function Lh(t){return B.concurrency(Z.integer(t)?t:null)}Tt.familySync()===Tt.GLIBC&&!B._isUsingJemalloc()?B.concurrency(1):Tt.familySync()===Tt.MUSL&&B.concurrency()===1024&&B.concurrency(I("node:os").availableParallelism());var Oh=new Dh.EventEmitter;function Mh(){return B.counters()}function zh(t){return B.simd(Z.bool(t)?t:null)}function Bh(t){if(Z.object(t))if(Array.isArray(t.operation)&&t.operation.every(Z.string))B.block(t.operation,!0);else throw Z.invalidParameterError("operation","Array<string>",t.operation);else throw Z.invalidParameterError("options","object",t)}function Uh(t){if(Z.object(t))if(Array.isArray(t.operation)&&t.operation.every(Z.string))B.block(t.operation,!1);else throw Z.invalidParameterError("operation","Array<string>",t.operation);else throw Z.invalidParameterError("options","object",t)}Pn.exports=t=>{t.cache=En,t.concurrency=Lh,t.counters=Mh,t.simd=zh,t.format=Ae,t.interpolators=Th,t.versions=et,t.queue=Oh,t.block=Bh,t.unblock=Uh}});var $n=x((Nf,Rn)=>{var Ee=Li();zi()(Ee);Wi()(Ee);Ji()(Ee);Zi()(Ee);fn()(Ee);gn()(Ee);wn()(Ee);xn()(Ee);Rn.exports=Ee});var it={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},Mr={available:["auth","oauth","billing","crud"],packageNames:{auth:"@donotdev/auth",oauth:"@donotdev/oauth",billing:"@donotdev/billing",crud:"@donotdev/crud"},hooks:{auth:["useAuth"],oauth:["useOAuth","useOAuthPartner","useOAuthConnection"],billing:["useStripeBilling","useStripeCheckout"],crud:["useCrud","useCrudCollection"]}};var re={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},De={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"}},Vt={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},nt={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},mt={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"},K={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:[`${mt.SOURCE_EAGER}/*_*.json`],lazy:[`${mt.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/**"]},bt={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/adv-comps","@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"]},zr=["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"];var Jt={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)/}},at={Inter:"inter-latin","Space Grotesk":"space-grotesk-latin","Playfair Display":"playfair-display-latin",Roboto:"roboto-latin"},Xt=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],Or={base:{absolute:!0,onlyFiles:!0,ignore:K.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...K.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...K.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:K.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:K.globalIgnore}};function Br(t,e=null){let r=K[t];if(!r)throw new Error(`Unknown pattern type: ${t}`);return e&&r.framework?{...r,framework:r.framework.map(s=>`${e}/${s}`)}:r}function vt(t){return Or[t]||Or.base}import*as $ from"node:fs";import"node:fs";import{createRequire as ha}from"node:module";import{resolve as wt,join as me,dirname as xe,relative as Ur,normalize as ua,sep as qr,extname as fa}from"node:path";import{fileURLToPath as da}from"node:url";import ga from"fast-glob";var qe={getGlobOptionsFor:vt||void 0,SCAN_PATTERNS:K||void 0,getPatternsFor:Br||void 0,I18N_PATHS:mt||void 0},T={error:(t,e)=>{},warn:(t,e)=>{},info:t=>{}};function Gr(t,e){return t().catch(r=>{throw new Error(`${e}: ${r instanceof Error?r.message:String(r)}`)})}var Hr={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"},D=class t{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return t._instance||(t._instance=new t(e)),t._instance}static _reset(){t._instance=null}constructor(e={}){if(t._instance)return t._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.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,t._instance=this}normalizePath(e){if(!e)return"";try{return ua(e).split(qr).join("/")}catch{return String(e).split(qr).join("/")}}getRelativePath(e){let r=this.getAppRoot(),s=Ur(r,e);return this.normalizePath(s)}getBasename(e){if(!e)return"";let s=this.normalizePath(e).split("/");return s[s.length-1]||""}getDirname(e){return e?this.normalizePath(xe(e)):""}resolvePackage(e,r=null){try{let s=r||this.getAppRoot(),n=ha(me(s,"package.json")).resolve(e);return this.normalizePath(n)}catch{return null}}resolveFrameworkPackage(e,r=null){let s=this.resolvePackage(`${e}/package.json`,r);if(s)return this.getDirname(s);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let a=e.replace("@donotdev/",""),o=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(o))return o;if(["auth","billing","crud","oauth"].includes(a)){let c=this.resolveRepoPath(`packages/features/${a}`);if(this.pathExists(c))return c}if(a==="firebase"){let c=this.resolveRepoPath(`packages/providers/${a}`);if(this.pathExists(c))return c}}let i=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(i))return i;let n=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(n)?n:null}resolvePackageAsset(e,r=null){return this.resolvePackage(e,r)}resolveAppPath(e){let r=this.getAppRoot(),s=wt(r,e);return this.normalizePath(s)}resolveRepoPath(e){let r=this.getRepoRoot(),s=this.normalizePath(e),i=wt(r,s);return this.normalizePath(i)}resolvePath(e,r){let s=this.normalizePath(r),i=this.normalizePath(e),n=wt(s,i);return this.normalizePath(n)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let r=$.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:r.size,isFile:r.isFile(),isDirectory:r.isDirectory()}}catch{return null}}_detectFormat(e,r){return r&&r!=="auto"?r:fa(e).toLowerCase()===".json"?"json":"text"}async read(e,r={}){let{format:s="auto",encoding:i="utf8"}=r,n=this._detectFormat(e,s);try{if(n==="buffer")return await $.promises.readFile(e);let a=await $.promises.readFile(e,i),o=this.stripBom(a);return n==="json"?JSON.parse(o):o}catch(a){return this.options.debug&&T.warn(`Failed to read file: ${e}`,a),null}}readSync(e,r={}){let{format:s="auto",encoding:i="utf8"}=r,n=this._detectFormat(e,s);try{if(n==="buffer")return $.readFileSync(e);let a=$.readFileSync(e,i),o=this.stripBom(a);return n==="json"?JSON.parse(o):o}catch(a){return this.options.debug&&T.warn(`Failed to read file: ${e}`,a),null}}async write(e,r,s={}){let{format:i="auto",overwrite:n=!1,dryRun:a=!1,verbose:o=!1}=s,c=this.normalizePath(e),h=this.normalizePath(xe(c)),f=this.pathExists(c);if(f&&!n)return o&&T.info(`Skipping existing file: ${c}`),!1;if(a)return T.info(`[DRY RUN] Would write file: ${c}`),!0;try{await $.promises.mkdir(h,{recursive:!0})}catch(p){if(p?.code!=="EEXIST")throw p}let g=this._detectFormat(e,i),m;Buffer.isBuffer(r)?m=r:g==="json"&&typeof r=="object"?m=JSON.stringify(r,null,2):m=String(r);try{return await Gr(async()=>(Buffer.isBuffer(m)?await $.promises.writeFile(c,m):await $.promises.writeFile(c,m,"utf8"),o&&T.info(`${f?"Updated":"Created"} file: ${c}`),!0),`Failed to write file: ${c}`)}catch{return!1}}writeSync(e,r,s={}){let{format:i="auto",overwrite:n=!1,dryRun:a=!1,verbose:o=!1}=s,c=this.normalizePath(e),h=this.normalizePath(xe(c)),f=this.pathExists(c);if(f&&!n)return o&&T.info(`Skipping existing file: ${c}`),!1;if(a)return T.info(`[DRY RUN] Would write file: ${c}`),!0;try{$.mkdirSync(h,{recursive:!0})}catch(p){if(p?.code!=="EEXIST")throw p}let g=this._detectFormat(e,i),m;Buffer.isBuffer(r)?m=r:g==="json"&&typeof r=="object"?m=JSON.stringify(r,null,2):m=String(r);try{return Buffer.isBuffer(m)?$.writeFileSync(c,m):$.writeFileSync(c,m,"utf8"),o&&T.info(`${f?"Updated":"Created"} file: ${c}`),!0}catch(p){throw new Error(`Failed to write file: ${c}: ${p instanceof Error?p.message:String(p)}`)}}async copy(e,r,s={}){let{overwrite:i=!1,dryRun:n=!1,verbose:a=!1}=s,o=this.normalizePath(r),c=this.pathExists(o);if(c&&!i)return a&&T.info(`Skipping existing file: ${o}`),!1;if(n)return T.info(`[DRY RUN] Would copy file: ${o}`),!0;let h=this.normalizePath(xe(o));try{await $.promises.mkdir(h,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}try{return await Gr(async()=>(await $.promises.copyFile(e,o),a&&T.info(`${c?"Updated":"Created"} file: ${o}`),!0),`Failed to copy file from ${e} to ${o}`)}catch{return!1}}copySync(e,r,s={}){let{overwrite:i=!1,dryRun:n=!1,verbose:a=!1}=s,o=this.normalizePath(r),c=this.pathExists(o);if(c&&!i)return a&&T.info(`Skipping existing file: ${o}`),!1;if(n)return T.info(`[DRY RUN] Would copy file: ${o}`),!0;let h=this.normalizePath(xe(o));try{$.mkdirSync(h,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}try{return $.copyFileSync(e,o),a&&T.info(`${c?"Updated":"Created"} file: ${o}`),!0}catch{return!1}}pathExists(e,r=!1){try{return $.existsSync(e)}catch(s){return r||T.error(`Error checking path existence: ${e}`,s),!1}}mkdir(e){try{let r=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return $.existsSync(r)||$.mkdirSync(r,{recursive:!0}),!0}catch{return!1}}readdirSync(e,r){try{return $.readdirSync(e,r)}catch(s){return this.options.debug&&T.warn(`Failed to read directory: ${e}`,s),r&&typeof r=="object"&&"withFileTypes"in r&&r.withFileTypes?[]:[]}}statSync(e){try{return $.statSync(e)}catch(r){return this.options.debug&&T.warn(`Failed to stat file: ${e}`,r),null}}lstatSync(e){try{return $.lstatSync(e)}catch(r){return this.options.debug&&T.warn(`Failed to lstat file: ${e}`,r),null}}async ensureDir(e){try{await $.promises.mkdir(e,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}ensureDirSync(e){try{$.mkdirSync(e,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}async remove(e){await $.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){$.rmSync(e,{recursive:!0,force:!0})}async readdir(e,r){return $.promises.readdir(e,r)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=me(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let r=this.normalizePath(wt(e)),s=this.getAppRoot(),i=Ur(s,r),n=this.normalizePath(i);return!n.startsWith("../")&&!n.startsWith("/")}async findFiles(e,r,s={}){let i=this.normalizePath(me(e,r)),n=this.getAppRoot(),a=this.normalizePath(n),o=i.startsWith(a)?i.slice(a.length+1):i,c={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n,ignore:qe.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([o],{...c,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let r=qe.I18N_PATHS;if(!r)return null;let s=e.replace(r.SOURCE_ROOT+"/",""),i=this.resolveFrameworkPackage("@donotdev/core");if(!i)return null;let n=this.normalizePath(me(i,r.PUBLISHED_ROOT,s)),a=n.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),n}async _globWithNormalization(e,r){return(await ga(e,r)).map(i=>{let n=typeof i=="string"?i:i.path;return this.normalizePath(n)})}async resolveFiles(e,r="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(r==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...e.framework,...e.consumer];for(let f of s)if(typeof f!="string"||f.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let i=this.getAppRoot(),n=qe.getGlobOptionsFor?qe.getGlobOptionsFor(r):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(i),o=e.framework.map(f=>{let g=this.normalizePath(f);return g.startsWith(a)?g.slice(a.length+1):g}),c=e.consumer.map(f=>{let g=this.normalizePath(f);return g.startsWith(a)?g.slice(a.length+1):g}),h={...n,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:i};try{let f=o.length>0?await this._globWithNormalization(o,h):[],g=await this._globWithNormalization(c,h);return{frameworkFiles:f,consumerFiles:g}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!qe.getPatternsFor)return{framework:[],consumer:[],all:[]};let r=this.getAppRoot(),s=this.getRepoRoot();if(e==="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 i=qe.getPatternsFor(e),n=this.isMonorepo();if(e==="i18n"){let c=i,h={eager:c.eager.map(f=>f.startsWith("!")?"!"+this.resolveAppPath(f.slice(1)):this.resolveAppPath(f)),lazy:c.lazy.map(f=>f.startsWith("!")?"!"+this.resolveAppPath(f.slice(1)):this.resolveAppPath(f)),framework:{eager:n?(c.framework?.eager||[]).map(f=>this.resolveRepoPath(f)).filter(Boolean):await Promise.all((c.framework?.eager||[]).map(f=>this._resolveFrameworkI18nPattern(f))).then(f=>f.filter(Boolean)),lazy:n?(c.framework?.lazy||[]).map(f=>this.resolveRepoPath(f)).filter(Boolean):await Promise.all((c.framework?.lazy||[]).map(f=>this._resolveFrameworkI18nPattern(f))).then(f=>f.filter(Boolean))},all:[]};return h.all=[...h.eager,...h.lazy,...h.framework.eager,...h.framework.lazy],h}let a=i,o={framework:n?(a.framework||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):[],consumer:(a.consumer||[]).map(c=>this.resolveAppPath(c)),all:[]};return o.all=[...o.consumer,...o.framework],o}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let r=this.resolvePackage("@donotdev/core/empty");if(r)return r;let s=xe(da(import.meta.url));return this.normalizePath(me(s,"../empty.js"))}_findRepoRoot(e){let r=this.normalizePath(e),s=0,i=this.options.maxLevels;for(;s<i;){let n=this.normalizePath(me(r,Hr.TOOLING)),a=this.normalizePath(me(r,Hr.CORE));if(this.pathExists(n)&&this.pathExists(a))return r;let o=me(r,"apps");if(this.pathExists(o)&&this.statSync(o)?.isDirectory())return this.normalizePath(r);let c=this.normalizePath(me(r,"package.json"));if(this.pathExists(c)&&this.normalizePath(xe(r))===r)return r;let h=this.normalizePath(xe(r));if(h===r)break;r=h,s++}return this.normalizePath(e)}};function Wr({logger:t,debug:e=!1}={}){let r=D.getInstance(),s=!1,i=null;if(process.env.DNDEV_APP_ROOT?(i=r.normalizePath(process.env.DNDEV_APP_ROOT),r.pathExists(i)?(r.setAppRoot(i),s=!0,e&&t&&t.debug(`App root set from DNDEV_APP_ROOT: ${i}`)):t&&t.warn(`DNDEV_APP_ROOT path does not exist: ${i}`)):e&&t&&t.debug("DNDEV_APP_ROOT env var not set"),!s){if(r.getRepoRoot()){let a=r.resolveRepoPath("apps");if(r.pathExists(a))try{let o=process.cwd(),c=r.normalizePath(o);if(c.includes("/apps/")){let h=c.indexOf("/apps/"),g=c.substring(h+6).split("/")[0];if(g){let m=r.resolveRepoPath(`apps/${g}`),p=r.resolveRepoPath(`apps/${g}/next.config.js`);r.pathExists(p)&&(i=m,r.setAppRoot(i),s=!0,e&&t&&t.debug(`App root detected from process.cwd(): ${i}`))}}}catch{}}!s&&!i&&(i=process.cwd(),r.setAppRoot(i),s=!0,e&&t&&t.debug(`App root fallback to process.cwd(): ${i}`))}return{appRoot:i,appRootSet:s}}function Vr(){try{let t=D.getInstance(),e=t.resolveAppPath("package.json"),r=t.readSync(e,{format:"json"});if(!r)return[];let s={...r.dependencies,...r.devDependencies};return Object.keys(s).filter(n=>{let a=n.startsWith("@donotdev/"),o=n==="entities",c=s[n]&&typeof s[n]=="string"&&s[n].startsWith("workspace:");return a||o||c}).filter(n=>!bt.buildTimePackages.includes(n)).sort()}catch{return[]}}function be(t){return t&&typeof t=="object"&&!Array.isArray(t)}import Yt from"node:fs";import Xr from"node:path";var Jr=/--(?:font-family|font-headline)\s*:\s*(?:['"]([^'"]+)['"]|([^;]+?));/g,Re=class{constructor(e,r={}){if(!e)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=e,this.options={debug:!1,customPatterns:{},...r},this.logger=r.logger||{debug:(s,...i)=>{this.options.debug}},this.patterns={selectors:{...Jt.selectors,...this.options.customPatterns?.selectors},themes:{...Jt.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(e){if(!e||typeof e!="string")return this._debug(`Invalid CSS variable: ${e}`),null;let r=e.replace(/^--/,"");if(!r)return this._debug(`Empty CSS variable after removing --: ${e}`),null;let s=r.split("-").filter(a=>a.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${e}`),null;let i=s.map((a,o)=>{let c=a.replace(/[^a-zA-Z0-9]/g,"");return c?o===0?c.toLowerCase():c.charAt(0).toUpperCase()+c.slice(1).toLowerCase():null}).filter(Boolean).join("");return!i||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(i)?(this._debug(`Invalid JavaScript identifier generated from ${e}: ${i}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(i)?`${i}Var`:i}_stripComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(e,r,s){let i=[],n,a=this.pathResolver.normalizePath(r),o=this._stripComments(e),c=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(n=c.exec(o))!==null;){let[,h,f,g]=n;if(!h||!g)continue;let m=f.match(this.patterns.themes.themeIcon),p=f.match(this.patterns.themes.themeIsDark),R={name:h,displayName:g,isDark:p?p[1]==="1":!1,meta:{icon:m?.[1]},source:this.pathResolver.getBasename(r)};this._debug(`Discovered theme: ${h} (${g})`),i.push(R),s.themes.set(h,{name:h,displayName:g,isDark:R.isDark,file:a,variables:new Set,meta:R.meta})}return i.length>0&&this._debug(`Extracted ${i.length} themes from ${a}`),i}extractClasses(e,r){(e.match(this.patterns.selectors.class)||[]).forEach(i=>{let n=i.slice(1);n.startsWith("_")||r.classes.add(n)})}extractVariables(e,r,s){(e.match(this.patterns.selectors.variable)||[]).forEach(n=>{n.startsWith("--")&&n.length>2?s==="framework"?r.variables.framework.add(n):r.variables.consumer.add(n):this._debug(`Skipping invalid CSS variable: ${n}`)})}extractFontFamilies(e){if(!e||typeof e!="string")return[];let r=this._stripComments(e),s=new Set,i;for(Jr.lastIndex=0;(i=Jr.exec(r))!==null;){let n=i[1];n&&n.trim()&&s.add(n.trim())}return Array.from(s)}extractKeyframes(e,r){(e.match(this.patterns.selectors.keyframe)||[]).forEach(i=>{let n=i.replace("@keyframes","").trim();n&&r.keyframes.add(n)})}validateCSS(e){let r=[],s=e.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(n=>{r.push(`Possible malformed CSS variable: ${n}`)}),(e.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(n=>{if(!n.includes("--theme-label")&&n.includes("--")){let a=n.match(/\.([a-z][a-z0-9-]+)/)?.[1];a&&r.push(`Theme class "${a}" missing --theme-label`)}}),r}extractAll(e,r,s="consumer"){let i={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},n=this.extractThemes(e,r,i);this.extractClasses(e,i),this.extractVariables(e,i,s),this.extractKeyframes(e,i);let a=this.validateCSS(e);return{themes:n,classes:Array.from(i.classes),variables:{framework:Array.from(i.variables.framework),consumer:Array.from(i.variables.consumer),all:[...Array.from(i.variables.framework),...Array.from(i.variables.consumer)].sort()},keyframes:Array.from(i.keyframes),warnings:a}}getPatterns(){return{...this.patterns}}setPatterns(e){this.patterns={...this.patterns,...e,selectors:{...this.patterns.selectors,...e.selectors},themes:{...this.patterns.themes,...e.themes}}}_debug(e,r){this.logger.debug(e,r||"")}};var q;try{q=await import("@clack/prompts")}catch{q={log:{message:t=>{},info:t=>{},warn:t=>{},error:t=>{},success:t=>{},step:t=>{}}}}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 pa(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function se(t,e){return pa()?`${e}${t}${ee.reset}`:t}function W(t,e,r,s={}){let{logDir:i=".dndev-logs",fileLogging:n=!1}=s,a=D.getInstance(),o=null;if(n){let f=a.resolveAppPath(i);a.pathExists(f)||a.mkdir(f),o=a.resolveAppPath(`${i}/${t.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let g=`=== ${t} Log Started at ${new Date().toISOString()} ===
|
|
2
|
+
`))}});var Li=x((vf,Ti)=>{var Ll=I("node:util"),br=I("node:stream"),Ol=ie();ft();var Ml=Ll.debuglog("sharp"),zl=t=>{Oe.queue.emit("change",t)},Oe=function(t,e){if(arguments.length===1&&!Ol.defined(t))throw new Error("Invalid input");return this instanceof Oe?(br.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),Ml(r)},queueListener:zl},this.options.input=this._createInputDescriptor(t,e,{allowStream:!0}),this):new Oe(t,e)};Object.setPrototypeOf(Oe.prototype,br.Duplex.prototype);Object.setPrototypeOf(Oe,br.Duplex);function Bl(){let t=this.constructor.call(),{debuglog:e,queueListener:r,...s}=this.options;return t.options=structuredClone(s),t.options.debuglog=e,t.options.queueListener=r,this._isStreamInput()&&this.on("finish",()=>{this._flattenBufferIn(),t.options.input.buffer=this.options.input.buffer,t.emit("finish")}),t}Object.assign(Oe.prototype,{clone:Bl});Ti.exports=Oe});var zi=x((wf,Mi)=>{var u=ie(),Se=ft(),Ul={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 Oi(t){let e=ql.filter(r=>u.defined(t[r])).map(r=>[r,t[r]]);return e.length?Object.fromEntries(e):void 0}function Gl(t,e,r){let s={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(u.string(t))s.file=t;else if(u.buffer(t)){if(t.length===0)throw Error("Input Buffer is empty");s.buffer=t}else if(u.arrayBuffer(t)){if(t.byteLength===0)throw Error("Input bit Array is empty");s.buffer=Buffer.from(t,0,t.byteLength)}else if(u.typedArray(t)){if(t.length===0)throw Error("Input Bit Array is empty");s.buffer=Buffer.from(t.buffer,t.byteOffset,t.byteLength)}else if(u.plainObject(t)&&!u.defined(e))e=t,Oi(e)&&(s.buffer=[]);else if(!u.defined(t)&&!u.defined(e)&&u.object(r)&&r.allowStream)s.buffer=[];else if(Array.isArray(t))if(t.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=t.map(i=>this._createInputDescriptor(i));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 '${t}' of type ${typeof t}${u.defined(e)?` when also providing options of type ${typeof e}`:""}`);if(u.object(e)){if(u.defined(e.failOnError))if(u.bool(e.failOnError))s.failOn=e.failOnError?"warning":"none";else throw u.invalidParameterError("failOnError","boolean",e.failOnError);if(u.defined(e.failOn))if(u.string(e.failOn)&&u.inArray(e.failOn,["none","truncated","error","warning"]))s.failOn=e.failOn;else throw u.invalidParameterError("failOn","one of: none, truncated, error, warning",e.failOn);if(u.defined(e.autoOrient))if(u.bool(e.autoOrient))s.autoOrient=e.autoOrient;else throw u.invalidParameterError("autoOrient","boolean",e.autoOrient);if(u.defined(e.density))if(u.inRange(e.density,1,1e5))s.density=e.density;else throw u.invalidParameterError("density","number between 1 and 100000",e.density);if(u.defined(e.ignoreIcc))if(u.bool(e.ignoreIcc))s.ignoreIcc=e.ignoreIcc;else throw u.invalidParameterError("ignoreIcc","boolean",e.ignoreIcc);if(u.defined(e.limitInputPixels))if(u.bool(e.limitInputPixels))s.limitInputPixels=e.limitInputPixels?16383**2:0;else if(u.integer(e.limitInputPixels)&&u.inRange(e.limitInputPixels,0,Number.MAX_SAFE_INTEGER))s.limitInputPixels=e.limitInputPixels;else throw u.invalidParameterError("limitInputPixels","positive integer",e.limitInputPixels);if(u.defined(e.unlimited))if(u.bool(e.unlimited))s.unlimited=e.unlimited;else throw u.invalidParameterError("unlimited","boolean",e.unlimited);if(u.defined(e.sequentialRead))if(u.bool(e.sequentialRead))s.sequentialRead=e.sequentialRead;else throw u.invalidParameterError("sequentialRead","boolean",e.sequentialRead);if(u.defined(e.raw)){if(u.object(e.raw)&&u.integer(e.raw.width)&&e.raw.width>0&&u.integer(e.raw.height)&&e.raw.height>0&&u.integer(e.raw.channels)&&u.inRange(e.raw.channels,1,4))switch(s.rawWidth=e.raw.width,s.rawHeight=e.raw.height,s.rawChannels=e.raw.channels,t.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,u.defined(e.raw.premultiplied))if(u.bool(e.raw.premultiplied))s.rawPremultiplied=e.raw.premultiplied;else throw u.invalidParameterError("raw.premultiplied","boolean",e.raw.premultiplied);if(s.rawPageHeight=0,u.defined(e.raw.pageHeight))if(u.integer(e.raw.pageHeight)&&e.raw.pageHeight>0&&e.raw.pageHeight<=e.raw.height){if(e.raw.height%e.raw.pageHeight!==0)throw new Error(`Expected raw.height ${e.raw.height} to be a multiple of raw.pageHeight ${e.raw.pageHeight}`);s.rawPageHeight=e.raw.pageHeight}else throw u.invalidParameterError("raw.pageHeight","positive integer",e.raw.pageHeight)}if(u.defined(e.animated))if(u.bool(e.animated))s.pages=e.animated?-1:1;else throw u.invalidParameterError("animated","boolean",e.animated);if(u.defined(e.pages))if(u.integer(e.pages)&&u.inRange(e.pages,-1,1e5))s.pages=e.pages;else throw u.invalidParameterError("pages","integer between -1 and 100000",e.pages);if(u.defined(e.page))if(u.integer(e.page)&&u.inRange(e.page,0,1e5))s.page=e.page;else throw u.invalidParameterError("page","integer between 0 and 100000",e.page);if(u.object(e.openSlide)&&u.defined(e.openSlide.level))if(u.integer(e.openSlide.level)&&u.inRange(e.openSlide.level,0,256))s.openSlideLevel=e.openSlide.level;else throw u.invalidParameterError("openSlide.level","integer between 0 and 256",e.openSlide.level);else if(u.defined(e.level))if(u.integer(e.level)&&u.inRange(e.level,0,256))s.openSlideLevel=e.level;else throw u.invalidParameterError("level","integer between 0 and 256",e.level);if(u.object(e.tiff)&&u.defined(e.tiff.subifd))if(u.integer(e.tiff.subifd)&&u.inRange(e.tiff.subifd,-1,1e5))s.tiffSubifd=e.tiff.subifd;else throw u.invalidParameterError("tiff.subifd","integer between -1 and 100000",e.tiff.subifd);else if(u.defined(e.subifd))if(u.integer(e.subifd)&&u.inRange(e.subifd,-1,1e5))s.tiffSubifd=e.subifd;else throw u.invalidParameterError("subifd","integer between -1 and 100000",e.subifd);if(u.object(e.svg)){if(u.defined(e.svg.stylesheet))if(u.string(e.svg.stylesheet))s.svgStylesheet=e.svg.stylesheet;else throw u.invalidParameterError("svg.stylesheet","string",e.svg.stylesheet);if(u.defined(e.svg.highBitdepth))if(u.bool(e.svg.highBitdepth))s.svgHighBitdepth=e.svg.highBitdepth;else throw u.invalidParameterError("svg.highBitdepth","boolean",e.svg.highBitdepth)}if(u.object(e.pdf)&&u.defined(e.pdf.background)?s.pdfBackground=this._getBackgroundColourOption(e.pdf.background):u.defined(e.pdfBackground)&&(s.pdfBackground=this._getBackgroundColourOption(e.pdfBackground)),u.object(e.jp2)&&u.defined(e.jp2.oneshot))if(u.bool(e.jp2.oneshot))s.jp2Oneshot=e.jp2.oneshot;else throw u.invalidParameterError("jp2.oneshot","boolean",e.jp2.oneshot);if(u.defined(e.create))if(u.object(e.create)&&u.integer(e.create.width)&&e.create.width>0&&u.integer(e.create.height)&&e.create.height>0&&u.integer(e.create.channels)){if(s.createWidth=e.create.width,s.createHeight=e.create.height,s.createChannels=e.create.channels,s.createPageHeight=0,u.defined(e.create.pageHeight))if(u.integer(e.create.pageHeight)&&e.create.pageHeight>0&&e.create.pageHeight<=e.create.height){if(e.create.height%e.create.pageHeight!==0)throw new Error(`Expected create.height ${e.create.height} to be a multiple of create.pageHeight ${e.create.pageHeight}`);s.createPageHeight=e.create.pageHeight}else throw u.invalidParameterError("create.pageHeight","positive integer",e.create.pageHeight);if(u.defined(e.create.noise)){if(!u.object(e.create.noise))throw new Error("Expected noise to be an object");if(e.create.noise.type!=="gaussian")throw new Error("Only gaussian noise is supported at the moment");if(s.createNoiseType=e.create.noise.type,!u.inRange(e.create.channels,1,4))throw u.invalidParameterError("create.channels","number between 1 and 4",e.create.channels);if(s.createNoiseMean=128,u.defined(e.create.noise.mean))if(u.number(e.create.noise.mean)&&u.inRange(e.create.noise.mean,0,1e4))s.createNoiseMean=e.create.noise.mean;else throw u.invalidParameterError("create.noise.mean","number between 0 and 10000",e.create.noise.mean);if(s.createNoiseSigma=30,u.defined(e.create.noise.sigma))if(u.number(e.create.noise.sigma)&&u.inRange(e.create.noise.sigma,0,1e4))s.createNoiseSigma=e.create.noise.sigma;else throw u.invalidParameterError("create.noise.sigma","number between 0 and 10000",e.create.noise.sigma)}else if(u.defined(e.create.background)){if(!u.inRange(e.create.channels,3,4))throw u.invalidParameterError("create.channels","number between 3 and 4",e.create.channels);s.createBackground=this._getBackgroundColourOption(e.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(u.defined(e.text))if(u.object(e.text)&&u.string(e.text.text)){if(s.textValue=e.text.text,u.defined(e.text.height)&&u.defined(e.text.dpi))throw new Error("Expected only one of dpi or height");if(u.defined(e.text.font))if(u.string(e.text.font))s.textFont=e.text.font;else throw u.invalidParameterError("text.font","string",e.text.font);if(u.defined(e.text.fontfile))if(u.string(e.text.fontfile))s.textFontfile=e.text.fontfile;else throw u.invalidParameterError("text.fontfile","string",e.text.fontfile);if(u.defined(e.text.width))if(u.integer(e.text.width)&&e.text.width>0)s.textWidth=e.text.width;else throw u.invalidParameterError("text.width","positive integer",e.text.width);if(u.defined(e.text.height))if(u.integer(e.text.height)&&e.text.height>0)s.textHeight=e.text.height;else throw u.invalidParameterError("text.height","positive integer",e.text.height);if(u.defined(e.text.align))if(u.string(e.text.align)&&u.string(this.constructor.align[e.text.align]))s.textAlign=this.constructor.align[e.text.align];else throw u.invalidParameterError("text.align","valid alignment",e.text.align);if(u.defined(e.text.justify))if(u.bool(e.text.justify))s.textJustify=e.text.justify;else throw u.invalidParameterError("text.justify","boolean",e.text.justify);if(u.defined(e.text.dpi))if(u.integer(e.text.dpi)&&u.inRange(e.text.dpi,1,1e6))s.textDpi=e.text.dpi;else throw u.invalidParameterError("text.dpi","integer between 1 and 1000000",e.text.dpi);if(u.defined(e.text.rgba))if(u.bool(e.text.rgba))s.textRgba=e.text.rgba;else throw u.invalidParameterError("text.rgba","bool",e.text.rgba);if(u.defined(e.text.spacing))if(u.integer(e.text.spacing)&&u.inRange(e.text.spacing,-1e6,1e6))s.textSpacing=e.text.spacing;else throw u.invalidParameterError("text.spacing","integer between -1000000 and 1000000",e.text.spacing);if(u.defined(e.text.wrap))if(u.string(e.text.wrap)&&u.inArray(e.text.wrap,["word","char","word-char","none"]))s.textWrap=e.text.wrap;else throw u.invalidParameterError("text.wrap","one of: word, char, word-char, none",e.text.wrap);delete s.buffer}else throw new Error("Expected a valid string to create an image with text.");if(u.defined(e.join))if(u.defined(this.options.join)){if(u.defined(e.join.animated))if(u.bool(e.join.animated))s.joinAnimated=e.join.animated;else throw u.invalidParameterError("join.animated","boolean",e.join.animated);if(u.defined(e.join.across))if(u.integer(e.join.across)&&u.inRange(e.join.across,1,1e6))s.joinAcross=e.join.across;else throw u.invalidParameterError("join.across","integer between 1 and 100000",e.join.across);if(u.defined(e.join.shim))if(u.integer(e.join.shim)&&u.inRange(e.join.shim,0,1e6))s.joinShim=e.join.shim;else throw u.invalidParameterError("join.shim","integer between 0 and 100000",e.join.shim);if(u.defined(e.join.background)&&(s.joinBackground=this._getBackgroundColourOption(e.join.background)),u.defined(e.join.halign))if(u.string(e.join.halign)&&u.string(this.constructor.align[e.join.halign]))s.joinHalign=this.constructor.align[e.join.halign];else throw u.invalidParameterError("join.halign","valid alignment",e.join.halign);if(u.defined(e.join.valign))if(u.string(e.join.valign)&&u.string(this.constructor.align[e.join.valign]))s.joinValign=this.constructor.align[e.join.valign];else throw u.invalidParameterError("join.valign","valid alignment",e.join.valign)}else throw new Error("Expected input to be an array of images to join")}else if(u.defined(e))throw new Error(`Invalid input options ${e}`);return s}function Hl(t,e,r){Array.isArray(this.options.input.buffer)?u.buffer(t)?(this.options.input.buffer.length===0&&this.on("finish",()=>{this.streamInFinished=!0}),this.options.input.buffer.push(t),r()):r(new Error("Non-Buffer data on Writable Stream")):r(new Error("Unexpected data on Writable Stream"))}function Wl(){this._isStreamInput()&&(this.options.input.buffer=Buffer.concat(this.options.input.buffer))}function Vl(){return Array.isArray(this.options.input.buffer)}function Jl(t){let e=Error();return u.fn(t)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Se.metadata(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)})}):Se.metadata(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{let i=()=>{this._flattenBufferIn(),Se.metadata(this.options,(n,a)=>{n?s(u.nativeError(n,e)):r(a)})};this.writableFinished?i():this.once("finish",i)}):new Promise((r,s)=>{Se.metadata(this.options,(i,n)=>{i?s(u.nativeError(i,e)):r(n)})})}function Xl(t){let e=Error();return u.fn(t)?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Se.stats(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)})}):Se.stats(this.options,(r,s)=>{r?t(u.nativeError(r,e)):t(null,s)}),this):this._isStreamInput()?new Promise((r,s)=>{this.on("finish",function(){this._flattenBufferIn(),Se.stats(this.options,(i,n)=>{i?s(u.nativeError(i,e)):r(n)})})}):new Promise((r,s)=>{Se.stats(this.options,(i,n)=>{i?s(u.nativeError(i,e)):r(n)})})}Mi.exports=t=>{Object.assign(t.prototype,{_inputOptionsFromObject:Oi,_createInputDescriptor:Gl,_write:Hl,_flattenBufferIn:Wl,_isStreamInput:Vl,metadata:Jl,stats:Xl}),t.align=Ul}});var Wi=x((yf,Hi)=>{var E=ie(),Ui={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},qi={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},Bi={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},Gi={entropy:16,attention:17},vr={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},Yl={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},Kl={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function wr(t){return t.angle%360!==0||t.rotationAngle!==0}function Dt(t){return t.width!==-1||t.height!==-1}function Ql(t,e,r){if(Dt(this.options)&&this.options.debuglog("ignoring previous resize options"),this.options.widthPost!==-1&&this.options.debuglog("operation order will be: extract, resize, extract"),E.defined(t))if(E.object(t)&&!E.defined(r))r=t;else if(E.integer(t)&&t>0)this.options.width=t;else throw E.invalidParameterError("width","positive integer",t);else this.options.width=-1;if(E.defined(e))if(E.integer(e)&&e>0)this.options.height=e;else throw E.invalidParameterError("height","positive integer",e);else this.options.height=-1;if(E.object(r)){if(E.defined(r.width))if(E.integer(r.width)&&r.width>0)this.options.width=r.width;else throw E.invalidParameterError("width","positive integer",r.width);if(E.defined(r.height))if(E.integer(r.height)&&r.height>0)this.options.height=r.height;else throw E.invalidParameterError("height","positive integer",r.height);if(E.defined(r.fit)){let s=Kl[r.fit];if(E.string(s))this.options.canvas=s;else throw E.invalidParameterError("fit","valid fit",r.fit)}if(E.defined(r.position)){let s=E.integer(r.position)?r.position:Gi[r.position]||qi[r.position]||Ui[r.position];if(E.integer(s)&&(E.inRange(s,0,8)||E.inRange(s,16,17)))this.options.position=s;else throw E.invalidParameterError("position","valid position/gravity/strategy",r.position)}if(this._setBackgroundColourOption("resizeBackground",r.background),E.defined(r.kernel))if(E.string(vr[r.kernel]))this.options.kernel=vr[r.kernel];else throw E.invalidParameterError("kernel","valid kernel name",r.kernel);E.defined(r.withoutEnlargement)&&this._setBooleanOption("withoutEnlargement",r.withoutEnlargement),E.defined(r.withoutReduction)&&this._setBooleanOption("withoutReduction",r.withoutReduction),E.defined(r.fastShrinkOnLoad)&&this._setBooleanOption("fastShrinkOnLoad",r.fastShrinkOnLoad)}return wr(this.options)&&Dt(this.options)&&(this.options.rotateBefore=!0),this}function Zl(t){if(E.integer(t)&&t>0)this.options.extendTop=t,this.options.extendBottom=t,this.options.extendLeft=t,this.options.extendRight=t;else if(E.object(t)){if(E.defined(t.top))if(E.integer(t.top)&&t.top>=0)this.options.extendTop=t.top;else throw E.invalidParameterError("top","positive integer",t.top);if(E.defined(t.bottom))if(E.integer(t.bottom)&&t.bottom>=0)this.options.extendBottom=t.bottom;else throw E.invalidParameterError("bottom","positive integer",t.bottom);if(E.defined(t.left))if(E.integer(t.left)&&t.left>=0)this.options.extendLeft=t.left;else throw E.invalidParameterError("left","positive integer",t.left);if(E.defined(t.right))if(E.integer(t.right)&&t.right>=0)this.options.extendRight=t.right;else throw E.invalidParameterError("right","positive integer",t.right);if(this._setBackgroundColourOption("extendBackground",t.background),E.defined(t.extendWith))if(E.string(Bi[t.extendWith]))this.options.extendWith=Bi[t.extendWith];else throw E.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",t.extendWith)}else throw E.invalidParameterError("extend","integer or object",t);return this}function ec(t){let e=Dt(this.options)||this.options.widthPre!==-1?"Post":"Pre";return this.options[`width${e}`]!==-1&&this.options.debuglog("ignoring previous extract options"),["left","top","width","height"].forEach(function(r){let s=t[r];if(E.integer(s)&&s>=0)this.options[r+(r==="left"||r==="top"?"Offset":"")+e]=s;else throw E.invalidParameterError(r,"integer",s)},this),wr(this.options)&&!Dt(this.options)&&(this.options.widthPre===-1||this.options.widthPost===-1)&&(this.options.rotateBefore=!0),this.options.input.autoOrient&&(this.options.orientBefore=!0),this}function tc(t){if(this.options.trimThreshold=10,E.defined(t))if(E.object(t)){if(E.defined(t.background)&&this._setBackgroundColourOption("trimBackground",t.background),E.defined(t.threshold))if(E.number(t.threshold)&&t.threshold>=0)this.options.trimThreshold=t.threshold;else throw E.invalidParameterError("threshold","positive number",t.threshold);E.defined(t.lineArt)&&this._setBooleanOption("trimLineArt",t.lineArt)}else throw E.invalidParameterError("trim","object",t);return wr(this.options)&&(this.options.rotateBefore=!0),this}Hi.exports=t=>{Object.assign(t.prototype,{resize:Ql,extend:Zl,extract:ec,trim:tc}),t.gravity=Ui,t.strategy=Gi,t.kernel=vr,t.fit=Yl,t.position=qi}});var Ji=x((Ef,Vi)=>{var _=ie(),yr={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 rc(t){if(!Array.isArray(t))throw _.invalidParameterError("images to composite","array",t);return this.options.composite=t.map(e=>{if(!_.object(e))throw _.invalidParameterError("image to composite","object",e);let r=this._inputOptionsFromObject(e),s={input:this._createInputDescriptor(e.input,r,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(_.defined(e.blend))if(_.string(yr[e.blend]))s.blend=yr[e.blend];else throw _.invalidParameterError("blend","valid blend name",e.blend);if(_.defined(e.tile))if(_.bool(e.tile))s.tile=e.tile;else throw _.invalidParameterError("tile","boolean",e.tile);if(_.defined(e.left))if(_.integer(e.left))s.left=e.left;else throw _.invalidParameterError("left","integer",e.left);if(_.defined(e.top))if(_.integer(e.top))s.top=e.top;else throw _.invalidParameterError("top","integer",e.top);if(_.defined(e.top)!==_.defined(e.left))throw new Error("Expected both left and top to be set");if(s.hasOffset=_.integer(e.top)&&_.integer(e.left),_.defined(e.gravity))if(_.integer(e.gravity)&&_.inRange(e.gravity,0,8))s.gravity=e.gravity;else if(_.string(e.gravity)&&_.integer(this.constructor.gravity[e.gravity]))s.gravity=this.constructor.gravity[e.gravity];else throw _.invalidParameterError("gravity","valid gravity",e.gravity);if(_.defined(e.premultiplied))if(_.bool(e.premultiplied))s.premultiplied=e.premultiplied;else throw _.invalidParameterError("premultiplied","boolean",e.premultiplied);return s}),this}Vi.exports=t=>{t.prototype.composite=rc,t.blend=yr}});var Zi=x((Pf,Qi)=>{var d=ie(),Xi={integer:"integer",float:"float",approximate:"approximate"};function sc(t,e){if(!d.defined(t))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(t)&&!(t%90))this.options.angle=t;else if(d.number(t))this.options.rotationAngle=t,d.object(e)&&e.background&&this._setBackgroundColourOption("rotationBackground",e.background);else throw d.invalidParameterError("angle","numeric",t);return this}function ic(){return this.options.input.autoOrient=!0,this}function nc(t){return this.options.flip=d.bool(t)?t:!0,this}function ac(t){return this.options.flop=d.bool(t)?t:!0,this}function oc(t,e){let r=[].concat(...t);if(r.length===4&&r.every(d.number))this.options.affineMatrix=r;else throw d.invalidParameterError("matrix","1x4 or 2x2 array",t);if(d.defined(e))if(d.object(e)){if(this._setBackgroundColourOption("affineBackground",e.background),d.defined(e.idx))if(d.number(e.idx))this.options.affineIdx=e.idx;else throw d.invalidParameterError("options.idx","number",e.idx);if(d.defined(e.idy))if(d.number(e.idy))this.options.affineIdy=e.idy;else throw d.invalidParameterError("options.idy","number",e.idy);if(d.defined(e.odx))if(d.number(e.odx))this.options.affineOdx=e.odx;else throw d.invalidParameterError("options.odx","number",e.odx);if(d.defined(e.ody))if(d.number(e.ody))this.options.affineOdy=e.ody;else throw d.invalidParameterError("options.ody","number",e.ody);if(d.defined(e.interpolator))if(d.inArray(e.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=e.interpolator;else throw d.invalidParameterError("options.interpolator","valid interpolator name",e.interpolator)}else throw d.invalidParameterError("options","object",e);return this}function lc(t,e,r){if(!d.defined(t))this.options.sharpenSigma=-1;else if(d.bool(t))this.options.sharpenSigma=t?-1:0;else if(d.number(t)&&d.inRange(t,.01,1e4)){if(this.options.sharpenSigma=t,d.defined(e))if(d.number(e)&&d.inRange(e,0,1e4))this.options.sharpenM1=e;else throw d.invalidParameterError("flat","number between 0 and 10000",e);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(t)){if(d.number(t.sigma)&&d.inRange(t.sigma,1e-6,10))this.options.sharpenSigma=t.sigma;else throw d.invalidParameterError("options.sigma","number between 0.000001 and 10",t.sigma);if(d.defined(t.m1))if(d.number(t.m1)&&d.inRange(t.m1,0,1e6))this.options.sharpenM1=t.m1;else throw d.invalidParameterError("options.m1","number between 0 and 1000000",t.m1);if(d.defined(t.m2))if(d.number(t.m2)&&d.inRange(t.m2,0,1e6))this.options.sharpenM2=t.m2;else throw d.invalidParameterError("options.m2","number between 0 and 1000000",t.m2);if(d.defined(t.x1))if(d.number(t.x1)&&d.inRange(t.x1,0,1e6))this.options.sharpenX1=t.x1;else throw d.invalidParameterError("options.x1","number between 0 and 1000000",t.x1);if(d.defined(t.y2))if(d.number(t.y2)&&d.inRange(t.y2,0,1e6))this.options.sharpenY2=t.y2;else throw d.invalidParameterError("options.y2","number between 0 and 1000000",t.y2);if(d.defined(t.y3))if(d.number(t.y3)&&d.inRange(t.y3,0,1e6))this.options.sharpenY3=t.y3;else throw d.invalidParameterError("options.y3","number between 0 and 1000000",t.y3)}else throw d.invalidParameterError("sigma","number between 0.01 and 10000",t);return this}function cc(t){if(!d.defined(t))this.options.medianSize=3;else if(d.integer(t)&&d.inRange(t,1,1e3))this.options.medianSize=t;else throw d.invalidParameterError("size","integer between 1 and 1000",t);return this}function hc(t){let e;if(d.number(t))e=t;else if(d.plainObject(t)){if(!d.number(t.sigma))throw d.invalidParameterError("options.sigma","number between 0.3 and 1000",e);if(e=t.sigma,"precision"in t)if(d.string(Xi[t.precision]))this.options.precision=Xi[t.precision];else throw d.invalidParameterError("precision","one of: integer, float, approximate",t.precision);if("minAmplitude"in t)if(d.number(t.minAmplitude)&&d.inRange(t.minAmplitude,.001,1))this.options.minAmpl=t.minAmplitude;else throw d.invalidParameterError("minAmplitude","number between 0.001 and 1",t.minAmplitude)}if(!d.defined(t))this.options.blurSigma=-1;else if(d.bool(t))this.options.blurSigma=t?-1:0;else if(d.number(e)&&d.inRange(e,.3,1e3))this.options.blurSigma=e;else throw d.invalidParameterError("sigma","number between 0.3 and 1000",e);return this}function Yi(t){if(!d.defined(t))this.options.dilateWidth=1;else if(d.integer(t)&&t>0)this.options.dilateWidth=t;else throw d.invalidParameterError("dilate","positive integer",Yi);return this}function Ki(t){if(!d.defined(t))this.options.erodeWidth=1;else if(d.integer(t)&&t>0)this.options.erodeWidth=t;else throw d.invalidParameterError("erode","positive integer",Ki);return this}function uc(t){return this.options.flatten=d.bool(t)?t:!0,d.object(t)&&this._setBackgroundColourOption("flattenBackground",t.background),this}function fc(){return this.options.unflatten=!0,this}function dc(t,e){if(!d.defined(t))this.options.gamma=2.2;else if(d.number(t)&&d.inRange(t,1,3))this.options.gamma=t;else throw d.invalidParameterError("gamma","number between 1.0 and 3.0",t);if(!d.defined(e))this.options.gammaOut=this.options.gamma;else if(d.number(e)&&d.inRange(e,1,3))this.options.gammaOut=e;else throw d.invalidParameterError("gammaOut","number between 1.0 and 3.0",e);return this}function gc(t){if(this.options.negate=d.bool(t)?t:!0,d.plainObject(t)&&"alpha"in t)if(d.bool(t.alpha))this.options.negateAlpha=t.alpha;else throw d.invalidParameterError("alpha","should be boolean value",t.alpha);return this}function pc(t){if(d.plainObject(t)){if(d.defined(t.lower))if(d.number(t.lower)&&d.inRange(t.lower,0,99))this.options.normaliseLower=t.lower;else throw d.invalidParameterError("lower","number between 0 and 99",t.lower);if(d.defined(t.upper))if(d.number(t.upper)&&d.inRange(t.upper,1,100))this.options.normaliseUpper=t.upper;else throw d.invalidParameterError("upper","number between 1 and 100",t.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 mc(t){return this.normalise(t)}function bc(t){if(d.plainObject(t)){if(d.integer(t.width)&&t.width>0)this.options.claheWidth=t.width;else throw d.invalidParameterError("width","integer greater than zero",t.width);if(d.integer(t.height)&&t.height>0)this.options.claheHeight=t.height;else throw d.invalidParameterError("height","integer greater than zero",t.height);if(d.defined(t.maxSlope))if(d.integer(t.maxSlope)&&d.inRange(t.maxSlope,0,100))this.options.claheMaxSlope=t.maxSlope;else throw d.invalidParameterError("maxSlope","integer between 0 and 100",t.maxSlope)}else throw d.invalidParameterError("options","plain object",t);return this}function vc(t){if(!d.object(t)||!Array.isArray(t.kernel)||!d.integer(t.width)||!d.integer(t.height)||!d.inRange(t.width,3,1001)||!d.inRange(t.height,3,1001)||t.height*t.width!==t.kernel.length)throw new Error("Invalid convolution kernel");return d.integer(t.scale)||(t.scale=t.kernel.reduce((e,r)=>e+r,0)),t.scale<1&&(t.scale=1),d.integer(t.offset)||(t.offset=0),this.options.convKernel=t,this}function wc(t,e){if(!d.defined(t))this.options.threshold=128;else if(d.bool(t))this.options.threshold=t?128:0;else if(d.integer(t)&&d.inRange(t,0,255))this.options.threshold=t;else throw d.invalidParameterError("threshold","integer between 0 and 255",t);return!d.object(e)||e.greyscale===!0||e.grayscale===!0?this.options.thresholdGrayscale=!0:this.options.thresholdGrayscale=!1,this}function yc(t,e,r){if(this.options.boolean=this._createInputDescriptor(t,r),d.string(e)&&d.inArray(e,["and","or","eor"]))this.options.booleanOp=e;else throw d.invalidParameterError("operator","one of: and, or, eor",e);return this}function Ec(t,e){if(!d.defined(t)&&d.number(e)?t=1:d.number(t)&&!d.defined(e)&&(e=0),!d.defined(t))this.options.linearA=[];else if(d.number(t))this.options.linearA=[t];else if(Array.isArray(t)&&t.length&&t.every(d.number))this.options.linearA=t;else throw d.invalidParameterError("a","number or array of numbers",t);if(!d.defined(e))this.options.linearB=[];else if(d.number(e))this.options.linearB=[e];else if(Array.isArray(e)&&e.length&&e.every(d.number))this.options.linearB=e;else throw d.invalidParameterError("b","number or array of numbers",e);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(t){if(!Array.isArray(t))throw d.invalidParameterError("inputMatrix","array",t);if(t.length!==3&&t.length!==4)throw d.invalidParameterError("inputMatrix","3x3 or 4x4 array",t.length);let e=t.flat().map(Number);if(e.length!==9&&e.length!==16)throw d.invalidParameterError("inputMatrix","cardinality of 9 or 16",e.length);return this.options.recombMatrix=e,this}function xc(t){if(!d.plainObject(t))throw d.invalidParameterError("options","plain object",t);if("brightness"in t)if(d.number(t.brightness)&&t.brightness>=0)this.options.brightness=t.brightness;else throw d.invalidParameterError("brightness","number above zero",t.brightness);if("saturation"in t)if(d.number(t.saturation)&&t.saturation>=0)this.options.saturation=t.saturation;else throw d.invalidParameterError("saturation","number above zero",t.saturation);if("hue"in t)if(d.integer(t.hue))this.options.hue=t.hue%360;else throw d.invalidParameterError("hue","number",t.hue);if("lightness"in t)if(d.number(t.lightness))this.options.lightness=t.lightness;else throw d.invalidParameterError("lightness","number",t.lightness);return this}Qi.exports=t=>{Object.assign(t.prototype,{autoOrient:ic,rotate:sc,flip:nc,flop:ac,affine:oc,sharpen:lc,erode:Ki,dilate:Yi,median:cc,blur:hc,flatten:uc,unflatten:fc,gamma:dc,negate:gc,normalise:pc,normalize:mc,clahe:bc,convolve:vc,threshold:wc,boolean:yc,linear:Ec,recomb:Pc,modulate:xc})}});var an=x((xf,nn)=>{var Rr=Object.defineProperty,Rc=Object.getOwnPropertyDescriptor,$c=Object.getOwnPropertyNames,Sc=Object.prototype.hasOwnProperty,kc=(t,e)=>{for(var r in e)Rr(t,r,{get:e[r],enumerable:!0})},Ac=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $c(e))!Sc.call(t,i)&&i!==r&&Rr(t,i,{get:()=>e[i],enumerable:!(s=Rc(e,i))||s.enumerable});return t},_c=t=>Ac(Rr({},"__esModule",{value:!0}),t),en={};kc(en,{default:()=>qc});nn.exports=_c(en);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]},tn=Object.create(null);for(let t in ce)Object.hasOwn(ce,t)&&(tn[ce[t]]=t);var H={to:{},get:{}};H.get=function(t){let e=t.slice(0,3).toLowerCase(),r,s;switch(e){case"hsl":{r=H.get.hsl(t),s="hsl";break}case"hwb":{r=H.get.hwb(t),s="hwb";break}default:{r=H.get.rgb(t),s="rgb";break}}return r?{model:s,value:r}:null};H.get.rgb=function(t){if(!t)return null;let e=/^#([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*)?\)$/,i=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,n=/^(\w+)$/,a=[0,0,0,1],o,c,h;if(o=t.match(r)){for(h=o[2],o=o[1],c=0;c<3;c++){let f=c*2;a[c]=Number.parseInt(o.slice(f,f+2),16)}h&&(a[3]=Number.parseInt(h,16)/255)}else if(o=t.match(e)){for(o=o[1],h=o[3],c=0;c<3;c++)a[c]=Number.parseInt(o[c]+o[c],16);h&&(a[3]=Number.parseInt(h+h,16)/255)}else if(o=t.match(s)){for(c=0;c<3;c++)a[c]=Number.parseInt(o[c+1],10);o[4]&&(a[3]=o[5]?Number.parseFloat(o[4])*.01:Number.parseFloat(o[4]))}else if(o=t.match(i)){for(c=0;c<3;c++)a[c]=Math.round(Number.parseFloat(o[c+1])*2.55);o[4]&&(a[3]=o[5]?Number.parseFloat(o[4])*.01:Number.parseFloat(o[4]))}else return(o=t.match(n))?o[1]==="transparent"?[0,0,0,0]:Object.hasOwn(ce,o[1])?(a=ce[o[1]],a[3]=1,a):null:null;for(c=0;c<3;c++)a[c]=ke(a[c],0,255);return a[3]=ke(a[3],0,1),a};H.get.hsl=function(t){if(!t)return null;let e=/^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=t.match(e);if(r){let s=Number.parseFloat(r[4]),i=(Number.parseFloat(r[1])%360+360)%360,n=ke(Number.parseFloat(r[2]),0,100),a=ke(Number.parseFloat(r[3]),0,100),o=ke(Number.isNaN(s)?1:s,0,1);return[i,n,a,o]}return null};H.get.hwb=function(t){if(!t)return null;let e=/^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=t.match(e);if(r){let s=Number.parseFloat(r[4]),i=(Number.parseFloat(r[1])%360+360)%360,n=ke(Number.parseFloat(r[2]),0,100),a=ke(Number.parseFloat(r[3]),0,100),o=ke(Number.isNaN(s)?1:s,0,1);return[i,n,a,o]}return null};H.to.hex=function(...t){return"#"+jt(t[0])+jt(t[1])+jt(t[2])+(t[3]<1?jt(Math.round(t[3]*255)):"")};H.to.rgb=function(...t){return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"};H.to.rgb.percent=function(...t){let e=Math.round(t[0]/255*100),r=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+r+"%, "+s+"%)":"rgba("+e+"%, "+r+"%, "+s+"%, "+t[3]+")"};H.to.hsl=function(...t){return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"};H.to.hwb=function(...t){let e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"};H.to.keyword=function(...t){return tn[t.slice(0,3)]};function ke(t,e,r){return Math.min(Math.max(e,t),r)}function jt(t){let e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}var Xe=H,rn={};for(let t of Object.keys(ce))rn[ce[t]]=t;var b={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"]}},Me=b,we=(6/29)**3;function Ke(t){let e=t>.0031308?1.055*t**.4166666666666667-.055:t*12.92;return Math.min(Math.max(0,e),1)}function Qe(t){return t>.04045?((t+.055)/1.055)**2.4:t/12.92}for(let t of Object.keys(b)){if(!("channels"in b[t]))throw new Error("missing channels property: "+t);if(!("labels"in b[t]))throw new Error("missing channel labels property: "+t);if(b[t].labels.length!==b[t].channels)throw new Error("channel and label counts mismatch: "+t);let{channels:e,labels:r}=b[t];delete b[t].channels,delete b[t].labels,Object.defineProperty(b[t],"channels",{value:e}),Object.defineProperty(b[t],"labels",{value:r})}b.rgb.hsl=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.min(e,r,s),n=Math.max(e,r,s),a=n-i,o,c;switch(n){case i:{o=0;break}case e:{o=(r-s)/a;break}case r:{o=2+(s-e)/a;break}case s:{o=4+(e-r)/a;break}}o=Math.min(o*60,360),o<0&&(o+=360);let h=(i+n)/2;return n===i?c=0:h<=.5?c=a/(n+i):c=a/(2-n-i),[o,c*100,h*100]};b.rgb.hsv=function(t){let e,r,s,i,n,a=t[0]/255,o=t[1]/255,c=t[2]/255,h=Math.max(a,o,c),f=h-Math.min(a,o,c),g=function(m){return(h-m)/6/f+1/2};if(f===0)i=0,n=0;else{switch(n=f/h,e=g(a),r=g(o),s=g(c),h){case a:{i=s-r;break}case o:{i=1/3+e-s;break}case c:{i=2/3+r-e;break}}i<0?i+=1:i>1&&(i-=1)}return[i*360,n*100,h*100]};b.rgb.hwb=function(t){let e=t[0],r=t[1],s=t[2],i=b.rgb.hsl(t)[0],n=1/255*Math.min(e,Math.min(r,s));return s=1-1/255*Math.max(e,Math.max(r,s)),[i,n*100,s*100]};b.rgb.oklab=function(t){let e=Qe(t[0]/255),r=Qe(t[1]/255),s=Qe(t[2]/255),i=Math.cbrt(.4122214708*e+.5363325363*r+.0514459929*s),n=Math.cbrt(.2119034982*e+.6806995451*r+.1073969566*s),a=Math.cbrt(.0883024619*e+.2817188376*r+.6299787005*s),o=.2104542553*i+.793617785*n-.0040720468*a,c=1.9779984951*i-2.428592205*n+.4505937099*a,h=.0259040371*i+.7827717662*n-.808675766*a;return[o*100,c*100,h*100]};b.rgb.cmyk=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.min(1-e,1-r,1-s),n=(1-e-i)/(1-i)||0,a=(1-r-i)/(1-i)||0,o=(1-s-i)/(1-i)||0;return[n*100,a*100,o*100,i*100]};function Nc(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}b.rgb.keyword=function(t){let e=rn[t];if(e)return e;let r=Number.POSITIVE_INFINITY,s;for(let i of Object.keys(ce)){let n=ce[i],a=Nc(t,n);a<r&&(r=a,s=i)}return s};b.keyword.rgb=function(t){return ce[t]};b.rgb.xyz=function(t){let e=Qe(t[0]/255),r=Qe(t[1]/255),s=Qe(t[2]/255),i=e*.4124564+r*.3575761+s*.1804375,n=e*.2126729+r*.7151522+s*.072175,a=e*.0193339+r*.119192+s*.9503041;return[i*100,n*100,a*100]};b.rgb.lab=function(t){let e=b.rgb.xyz(t),r=e[0],s=e[1],i=e[2];r/=95.047,s/=100,i/=108.883,r=r>we?r**(1/3):7.787*r+16/116,s=s>we?s**(1/3):7.787*s+16/116,i=i>we?i**(1/3):7.787*i+16/116;let n=116*s-16,a=500*(r-s),o=200*(s-i);return[n,a,o]};b.hsl.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,i,n;if(r===0)return n=s*255,[n,n,n];let a=s<.5?s*(1+r):s+r-s*r,o=2*s-a,c=[0,0,0];for(let h=0;h<3;h++)i=e+1/3*-(h-1),i<0&&i++,i>1&&i--,6*i<1?n=o+(a-o)*6*i:2*i<1?n=a:3*i<2?n=o+(a-o)*(2/3-i)*6:n=o,c[h]=n*255;return c};b.hsl.hsv=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,i=r,n=Math.max(s,.01);s*=2,r*=s<=1?s:2-s,i*=n<=1?n:2-n;let a=(s+r)/2,o=s===0?2*i/(n+i):2*r/(s+r);return[e,o*100,a*100]};b.hsv.rgb=function(t){let e=t[0]/60,r=t[1]/100,s=t[2]/100,i=Math.floor(e)%6,n=e-Math.floor(e),a=255*s*(1-r),o=255*s*(1-r*n),c=255*s*(1-r*(1-n));switch(s*=255,i){case 0:return[s,c,a];case 1:return[o,s,a];case 2:return[a,s,c];case 3:return[a,o,s];case 4:return[c,a,s];case 5:return[s,a,o]}};b.hsv.hsl=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,i=Math.max(s,.01),n,a;a=(2-r)*s;let o=(2-r)*i;return n=r*i,n/=o<=1?o:2-o,n=n||0,a/=2,[e,n*100,a*100]};b.hwb.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,i=r+s,n;i>1&&(r/=i,s/=i);let a=Math.floor(6*e),o=1-s;n=6*e-a,(a&1)!==0&&(n=1-n);let c=r+n*(o-r),h,f,g;switch(a){default:case 6:case 0:{h=o,f=c,g=r;break}case 1:{h=c,f=o,g=r;break}case 2:{h=r,f=o,g=c;break}case 3:{h=r,f=c,g=o;break}case 4:{h=c,f=r,g=o;break}case 5:{h=o,f=r,g=c;break}}return[h*255,f*255,g*255]};b.cmyk.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=t[3]/100,n=1-Math.min(1,e*(1-i)+i),a=1-Math.min(1,r*(1-i)+i),o=1-Math.min(1,s*(1-i)+i);return[n*255,a*255,o*255]};b.xyz.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i,n,a;return i=e*3.2404542+r*-1.5371385+s*-.4985314,n=e*-.969266+r*1.8760108+s*.041556,a=e*.0556434+r*-.2040259+s*1.0572252,i=Ke(i),n=Ke(n),a=Ke(a),[i*255,n*255,a*255]};b.xyz.lab=function(t){let e=t[0],r=t[1],s=t[2];e/=95.047,r/=100,s/=108.883,e=e>we?e**(1/3):7.787*e+16/116,r=r>we?r**(1/3):7.787*r+16/116,s=s>we?s**(1/3):7.787*s+16/116;let i=116*r-16,n=500*(e-r),a=200*(r-s);return[i,n,a]};b.xyz.oklab=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=Math.cbrt(.8189330101*e+.3618667424*r-.1288597137*s),n=Math.cbrt(.0329845436*e+.9293118715*r+.0361456387*s),a=Math.cbrt(.0482003018*e+.2643662691*r+.633851707*s),o=.2104542553*i+.793617785*n-.0040720468*a,c=1.9779984951*i-2.428592205*n+.4505937099*a,h=.0259040371*i+.7827717662*n-.808675766*a;return[o*100,c*100,h*100]};b.oklab.oklch=function(t){return b.lab.lch(t)};b.oklab.xyz=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=(.999999998*e+.396337792*r+.215803758*s)**3,n=(1.000000008*e-.105561342*r-.063854175*s)**3,a=(1.000000055*e-.089484182*r-1.291485538*s)**3,o=1.227013851*i-.55779998*n+.281256149*a,c=-.040580178*i+1.11225687*n-.071676679*a,h=-.076381285*i-.421481978*n+1.58616322*a;return[o*100,c*100,h*100]};b.oklab.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,i=(e+.3963377774*r+.2158037573*s)**3,n=(e-.1055613458*r-.0638541728*s)**3,a=(e-.0894841775*r-1.291485548*s)**3,o=Ke(4.0767416621*i-3.3077115913*n+.2309699292*a),c=Ke(-1.2684380046*i+2.6097574011*n-.3413193965*a),h=Ke(-.0041960863*i-.7034186147*n+1.707614701*a);return[o*255,c*255,h*255]};b.oklch.oklab=function(t){return b.lch.lab(t)};b.lab.xyz=function(t){let e=t[0],r=t[1],s=t[2],i,n,a;n=(e+16)/116,i=r/500+n,a=n-s/200;let o=n**3,c=i**3,h=a**3;return n=o>we?o:(n-16/116)/7.787,i=c>we?c:(i-16/116)/7.787,a=h>we?h:(a-16/116)/7.787,i*=95.047,n*=100,a*=108.883,[i,n,a]};b.lab.lch=function(t){let e=t[0],r=t[1],s=t[2],i;i=Math.atan2(s,r)*360/2/Math.PI,i<0&&(i+=360);let a=Math.sqrt(r*r+s*s);return[e,a,i]};b.lch.lab=function(t){let e=t[0],r=t[1],i=t[2]/360*2*Math.PI,n=r*Math.cos(i),a=r*Math.sin(i);return[e,n,a]};b.rgb.ansi16=function(t,e=null){let[r,s,i]=t,n=e===null?b.rgb.hsv(t)[2]:e;if(n=Math.round(n/50),n===0)return 30;let a=30+(Math.round(i/255)<<2|Math.round(s/255)<<1|Math.round(r/255));return n===2&&(a+=60),a};b.hsv.ansi16=function(t){return b.rgb.ansi16(b.hsv.rgb(t),t[2])};b.rgb.ansi256=function(t){let e=t[0],r=t[1],s=t[2];return e>>4===r>>4&&r>>4===s>>4?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(s/255*5)};b.ansi16.rgb=function(t){t=t[0];let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let r=(Math.trunc(t>50)+1)*.5,s=(e&1)*r*255,i=(e>>1&1)*r*255,n=(e>>2&1)*r*255;return[s,i,n]};b.ansi256.rgb=function(t){if(t=t[0],t>=232){let n=(t-232)*10+8;return[n,n,n]}t-=16;let e,r=Math.floor(t/36)/5*255,s=Math.floor((e=t%36)/6)/5*255,i=e%6/5*255;return[r,s,i]};b.rgb.hex=function(t){let r=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".slice(r.length)+r};b.hex.rgb=function(t){let e=t.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!e)return[0,0,0];let r=e[0];e[0].length===3&&(r=[...r].map(o=>o+o).join(""));let s=Number.parseInt(r,16),i=s>>16&255,n=s>>8&255,a=s&255;return[i,n,a]};b.rgb.hcg=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(e,r),s),n=Math.min(Math.min(e,r),s),a=i-n,o,c=a<1?n/(1-a):0;return a<=0?o=0:i===e?o=(r-s)/a%6:i===r?o=2+(s-e)/a:o=4+(e-r)/a,o/=6,o%=1,[o*360,a*100,c*100]};b.hsl.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=r<.5?2*e*r:2*e*(1-r),i=0;return s<1&&(i=(r-.5*s)/(1-s)),[t[0],s*100,i*100]};b.hsv.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=e*r,i=0;return s<1&&(i=(r-s)/(1-s)),[t[0],s*100,i*100]};b.hcg.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100;if(r===0)return[s*255,s*255,s*255];let i=[0,0,0],n=e%1*6,a=n%1,o=1-a,c=0;switch(Math.floor(n)){case 0:{i[0]=1,i[1]=a,i[2]=0;break}case 1:{i[0]=o,i[1]=1,i[2]=0;break}case 2:{i[0]=0,i[1]=1,i[2]=a;break}case 3:{i[0]=0,i[1]=o,i[2]=1;break}case 4:{i[0]=a,i[1]=0,i[2]=1;break}default:i[0]=1,i[1]=0,i[2]=o}return c=(1-r)*s,[(r*i[0]+c)*255,(r*i[1]+c)*255,(r*i[2]+c)*255]};b.hcg.hsv=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e),i=0;return s>0&&(i=e/s),[t[0],i*100,s*100]};b.hcg.hsl=function(t){let e=t[1]/100,s=t[2]/100*(1-e)+.5*e,i=0;return s>0&&s<.5?i=e/(2*s):s>=.5&&s<1&&(i=e/(2*(1-s))),[t[0],i*100,s*100]};b.hcg.hwb=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e);return[t[0],(s-e)*100,(1-s)*100]};b.hwb.hcg=function(t){let e=t[1]/100,s=1-t[2]/100,i=s-e,n=0;return i<1&&(n=(s-i)/(1-i)),[t[0],i*100,n*100]};b.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};b.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};b.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};b.gray.hsl=function(t){return[0,0,t[0]]};b.gray.hsv=b.gray.hsl;b.gray.hwb=function(t){return[0,100,t[0]]};b.gray.cmyk=function(t){return[0,0,0,t[0]]};b.gray.lab=function(t){return[t[0],0,0]};b.gray.hex=function(t){let e=Math.round(t[0]/100*255)&255,s=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".slice(s.length)+s};b.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};function Ic(){let t={},e=Object.keys(Me);for(let{length:r}=e,s=0;s<r;s++)t[e[s]]={distance:-1,parent:null};return t}function Fc(t){let e=Ic(),r=[t];for(e[t].distance=0;r.length>0;){let s=r.pop(),i=Object.keys(Me[s]);for(let{length:n}=i,a=0;a<n;a++){let o=i[a],c=e[o];c.distance===-1&&(c.distance=e[s].distance+1,c.parent=s,r.unshift(o))}}return e}function Cc(t,e){return function(r){return e(t(r))}}function Dc(t,e){let r=[e[t].parent,t],s=Me[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)r.unshift(e[i].parent),s=Cc(Me[e[i].parent][i],s),i=e[i].parent;return s.conversion=r,s}function jc(t){let e=Fc(t),r={},s=Object.keys(e);for(let{length:i}=s,n=0;n<i;n++){let a=s[n];e[a].parent!==null&&(r[a]=Dc(a,e))}return r}var Tc=jc,Ye={},Lc=Object.keys(Me);function Oc(t){let e=function(...r){let s=r[0];return s==null?s:(s.length>1&&(r=s),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Mc(t){let e=function(...r){let s=r[0];if(s==null)return s;s.length>1&&(r=s);let i=t(r);if(typeof i=="object")for(let{length:n}=i,a=0;a<n;a++)i[a]=Math.round(i[a]);return i};return"conversion"in t&&(e.conversion=t.conversion),e}for(let t of Lc){Ye[t]={},Object.defineProperty(Ye[t],"channels",{value:Me[t].channels}),Object.defineProperty(Ye[t],"labels",{value:Me[t].labels});let e=Tc(t),r=Object.keys(e);for(let s of r){let i=e[s];Ye[t][s]=Mc(i),Ye[t][s].raw=Oc(i)}}var V=Ye,sn=["keyword","gray","hex"],Er={};for(let t of Object.keys(V))Er[[...V[t].labels].sort().join("")]=t;var Pr={};function L(t,e){if(!(this instanceof L))return new L(t,e);if(e&&e in sn&&(e=null),e&&!(e in V))throw new Error("Unknown model: "+e);let r,s;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof L)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if(typeof t=="string"){let i=Xe.get(t);if(i===null)throw new Error("Unable to parse color from string: "+t);this.model=i.model,s=V[this.model].channels,this.color=i.value.slice(0,s),this.valpha=typeof i.value[s]=="number"?i.value[s]:1}else if(t.length>0){this.model=e||"rgb",s=V[this.model].channels;let i=Array.prototype.slice.call(t,0,s);this.color=xr(i,s),this.valpha=typeof t[s]=="number"?t[s]:1}else if(typeof t=="number")this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;let i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);let n=i.sort().join("");if(!(n in Er))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Er[n];let{labels:a}=V[this.model],o=[];for(r=0;r<a.length;r++)o.push(t[a[r]]);this.color=xr(o)}if(Pr[this.model])for(s=V[this.model].channels,r=0;r<s;r++){let i=Pr[this.model][r];i&&(this.color[r]=i(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}L.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let e=this.model in Xe.to?this:this.rgb();e=e.round(typeof t=="number"?t:1);let r=e.valpha===1?e.color:[...e.color,this.valpha];return Xe.to[e.model](...r)},percentString(t){let e=this.rgb().round(typeof t=="number"?t:1),r=e.valpha===1?e.color:[...e.color,this.valpha];return Xe.to.rgb.percent(...r)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let t={},{channels:e}=V[this.model],{labels:r}=V[this.model];for(let s=0;s<e;s++)t[r[s]]=this.color[s];return this.valpha!==1&&(t.alpha=this.valpha),t},unitArray(){let t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,this.valpha!==1&&t.push(this.valpha),t},unitObject(){let t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,this.valpha!==1&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new L([...this.color.map(Bc(t)),this.valpha],this.model)},alpha(t){return t!==void 0?new L([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:F("rgb",0,j(255)),green:F("rgb",1,j(255)),blue:F("rgb",2,j(255)),hue:F(["hsl","hsv","hsl","hwb","hcg"],0,t=>(t%360+360)%360),saturationl:F("hsl",1,j(100)),lightness:F("hsl",2,j(100)),saturationv:F("hsv",1,j(100)),value:F("hsv",2,j(100)),chroma:F("hcg",1,j(100)),gray:F("hcg",2,j(100)),white:F("hwb",1,j(100)),wblack:F("hwb",2,j(100)),cyan:F("cmyk",0,j(100)),magenta:F("cmyk",1,j(100)),yellow:F("cmyk",2,j(100)),black:F("cmyk",3,j(100)),x:F("xyz",0,j(95.047)),y:F("xyz",1,j(100)),z:F("xyz",2,j(108.833)),l:F("lab",0,j(100)),a:F("lab",1),b:F("lab",2),keyword(t){return t!==void 0?new L(t):V[this.model].keyword(this.color)},hex(t){return t!==void 0?new L(t):Xe.to.hex(...this.rgb().round().color)},hexa(t){if(t!==void 0)return new L(t);let e=this.rgb().round().color,r=Math.round(this.valpha*255).toString(16).toUpperCase();return r.length===1&&(r="0"+r),Xe.to.hex(...e)+r},rgbNumber(){let t=this.rgb().color;return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255},luminosity(){let t=this.rgb().color,e=[];for(let[r,s]of t.entries()){let i=s/255;e[r]=i<=.04045?i/12.92:((i+.055)/1.055)**2.4}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(t){let e=this.luminosity(),r=t.luminosity();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},level(t){let e=this.contrast(t);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){let t=this.rgb().color;return(t[0]*2126+t[1]*7152+t[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let t=this.rgb();for(let e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten(t){let e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken(t){let e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate(t){let e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate(t){let e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten(t){let e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken(t){let e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale(){let t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return L.rgb(e,e,e)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){let e=this.hsl(),r=e.color[0];return r=(r+t)%360,r=r<0?360+r:r,e.color[0]=r,e},mix(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);let r=t.rgb(),s=this.rgb(),i=e===void 0?.5:e,n=2*i-1,a=r.alpha()-s.alpha(),o=((n*a===-1?n:(n+a)/(1+n*a))+1)/2,c=1-o;return L.rgb(o*r.red()+c*s.red(),o*r.green()+c*s.green(),o*r.blue()+c*s.blue(),r.alpha()*i+s.alpha()*(1-i))}};for(let t of Object.keys(V)){if(sn.includes(t))continue;let{channels:e}=V[t];L.prototype[t]=function(...r){return this.model===t?new L(this):r.length>0?new L(r,t):new L([...Uc(V[this.model][t].raw(this.color)),this.valpha],t)},L[t]=function(...r){let s=r[0];return typeof s=="number"&&(s=xr(r,e)),new L(s,t)}}function zc(t,e){return Number(t.toFixed(e))}function Bc(t){return function(e){return zc(e,t)}}function F(t,e,r){t=Array.isArray(t)?t:[t];for(let s of t)(Pr[s]||=[])[e]=r;return t=t[0],function(s){let i;return s!==void 0?(r&&(s=r(s)),i=this[t](),i.color[e]=s,i):(i=this[t]().color[e],r&&(i=r(i)),i)}}function j(t){return function(e){return Math.max(0,Math.min(t,e))}}function Uc(t){return Array.isArray(t)?t:[t]}function xr(t,e){for(let r=0;r<e;r++)typeof t[r]!="number"&&(t[r]=0);return t}var qc=L});var ln=x((Rf,on)=>{on.exports=an().default});var fn=x(($f,un)=>{var Gc=ln(),ye=ie(),cn={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function Hc(t){return this._setBackgroundColourOption("tint",t),this}function Wc(t){return this.options.greyscale=ye.bool(t)?t:!0,this}function Vc(t){return this.greyscale(t)}function Jc(t){if(!ye.string(t))throw ye.invalidParameterError("colourspace","string",t);return this.options.colourspacePipeline=t,this}function Xc(t){return this.pipelineColourspace(t)}function Yc(t){if(!ye.string(t))throw ye.invalidParameterError("colourspace","string",t);return this.options.colourspace=t,this}function Kc(t){return this.toColourspace(t)}function hn(t){if(ye.object(t)||ye.string(t)&&t.length>=3&&t.length<=200){let e=Gc(t);return[e.red(),e.green(),e.blue(),Math.round(e.alpha()*255)]}else throw ye.invalidParameterError("background","object or string",t)}function Qc(t,e){ye.defined(e)&&(this.options[t]=hn(e))}un.exports=t=>{Object.assign(t.prototype,{tint:Hc,greyscale:Wc,grayscale:Vc,pipelineColourspace:Jc,pipelineColorspace:Xc,toColourspace:Yc,toColorspace:Kc,_getBackgroundColourOption:hn,_setBackgroundColourOption:Qc}),t.colourspace=cn,t.colorspace=cn}});var gn=x((Sf,dn)=>{var he=ie(),Zc={and:"and",or:"or",eor:"eor"};function eh(){return this.options.removeAlpha=!0,this}function th(t){if(he.defined(t))if(he.number(t)&&he.inRange(t,0,1))this.options.ensureAlpha=t;else throw he.invalidParameterError("alpha","number between 0 and 1",t);else this.options.ensureAlpha=1;return this}function rh(t){let e={red:0,green:1,blue:2,alpha:3};if(Object.keys(e).includes(t)&&(t=e[t]),he.integer(t)&&he.inRange(t,0,4))this.options.extractChannel=t;else throw he.invalidParameterError("channel","integer or one of: red, green, blue, alpha",t);return this}function sh(t,e){return Array.isArray(t)?t.forEach(function(r){this.options.joinChannelIn.push(this._createInputDescriptor(r,e))},this):this.options.joinChannelIn.push(this._createInputDescriptor(t,e)),this}function ih(t){if(he.string(t)&&he.inArray(t,["and","or","eor"]))this.options.bandBoolOp=t;else throw he.invalidParameterError("boolOp","one of: and, or, eor",t);return this}dn.exports=t=>{Object.assign(t.prototype,{removeAlpha:eh,ensureAlpha:th,extractChannel:rh,joinChannel:sh,bandbool:ih}),t.bool=Zc}});var wn=x((kf,vn)=>{var $r=I("node:path"),l=ie(),Ze=ft(),pn=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"]]),nh=/\.(jp[2x]|j2[kc])$/i,mn=()=>new Error("JP2 output requires libvips with support for OpenJPEG"),bn=t=>1<<31-Math.clz32(Math.ceil(Math.log2(t)));function ah(t,e){let r;if(l.string(t)?l.string(this.options.input.file)&&$r.resolve(this.options.input.file)===$r.resolve(t)?r=new Error("Cannot use same file for input and output"):nh.test($r.extname(t))&&!this.constructor.format.jp2k.output.file&&(r=mn()):r=new Error("Missing output file path"),r)if(l.fn(e))e(r);else return Promise.reject(r);else{this.options.fileOut=t;let s=Error();return this._pipeline(e,s)}return this}function oh(t,e){l.object(t)?this._setBooleanOption("resolveWithObject",t.resolveWithObject):this.options.resolveWithObject&&(this.options.resolveWithObject=!1),this.options.fileOut="";let r=Error();return this._pipeline(l.fn(t)?t:e,r)}function lh(){return this.options.keepMetadata|=1,this}function ch(t){if(l.object(t))for(let[e,r]of Object.entries(t))if(l.object(r))for(let[s,i]of Object.entries(r))if(l.string(i))this.options.withExif[`exif-${e.toLowerCase()}-${s}`]=i;else throw l.invalidParameterError(`${e}.${s}`,"string",i);else throw l.invalidParameterError(e,"object",r);else throw l.invalidParameterError("exif","object",t);return this.options.withExifMerge=!1,this.keepExif()}function hh(t){return this.withExif(t),this.options.withExifMerge=!0,this}function uh(){return this.options.keepMetadata|=8,this}function fh(t,e){if(l.string(t))this.options.withIccProfile=t;else throw l.invalidParameterError("icc","string",t);if(this.keepIccProfile(),l.object(e)&&l.defined(e.attach))if(l.bool(e.attach))e.attach||(this.options.keepMetadata&=-9);else throw l.invalidParameterError("attach","boolean",e.attach);return this}function dh(){return this.options.keepMetadata|=2,this}function gh(t){if(l.string(t)&&t.length>0)this.options.withXmp=t,this.options.keepMetadata|=2;else throw l.invalidParameterError("xmp","non-empty string",t);return this}function ph(){return this.options.keepMetadata=31,this}function mh(t){if(this.keepMetadata(),this.withIccProfile("srgb"),l.object(t)){if(l.defined(t.orientation))if(l.integer(t.orientation)&&l.inRange(t.orientation,1,8))this.options.withMetadataOrientation=t.orientation;else throw l.invalidParameterError("orientation","integer between 1 and 8",t.orientation);if(l.defined(t.density))if(l.number(t.density)&&t.density>0)this.options.withMetadataDensity=t.density;else throw l.invalidParameterError("density","positive number",t.density);l.defined(t.icc)&&this.withIccProfile(t.icc),l.defined(t.exif)&&this.withExifMerge(t.exif)}return this}function bh(t,e){let r=pn.get((l.object(t)&&l.string(t.id)?t.id:t).toLowerCase());if(!r)throw l.invalidParameterError("format",`one of: ${[...pn.keys()].join(", ")}`,t);return this[r](e)}function vh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.jpegQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.progressive)&&this._setBooleanOption("jpegProgressive",t.progressive),l.defined(t.chromaSubsampling))if(l.string(t.chromaSubsampling)&&l.inArray(t.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=t.chromaSubsampling;else throw l.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",t.chromaSubsampling);let e=l.bool(t.optimizeCoding)?t.optimizeCoding:t.optimiseCoding;if(l.defined(e)&&this._setBooleanOption("jpegOptimiseCoding",e),l.defined(t.mozjpeg))if(l.bool(t.mozjpeg))t.mozjpeg&&(this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3);else throw l.invalidParameterError("mozjpeg","boolean",t.mozjpeg);let r=l.bool(t.trellisQuantization)?t.trellisQuantization:t.trellisQuantisation;l.defined(r)&&this._setBooleanOption("jpegTrellisQuantisation",r),l.defined(t.overshootDeringing)&&this._setBooleanOption("jpegOvershootDeringing",t.overshootDeringing);let s=l.bool(t.optimizeScans)?t.optimizeScans:t.optimiseScans;l.defined(s)&&(this._setBooleanOption("jpegOptimiseScans",s),s&&(this.options.jpegProgressive=!0));let i=l.number(t.quantizationTable)?t.quantizationTable:t.quantisationTable;if(l.defined(i))if(l.integer(i)&&l.inRange(i,0,8))this.options.jpegQuantisationTable=i;else throw l.invalidParameterError("quantisationTable","integer between 0 and 8",i)}return this._updateFormatOut("jpeg",t)}function wh(t){if(l.object(t)){if(l.defined(t.progressive)&&this._setBooleanOption("pngProgressive",t.progressive),l.defined(t.compressionLevel))if(l.integer(t.compressionLevel)&&l.inRange(t.compressionLevel,0,9))this.options.pngCompressionLevel=t.compressionLevel;else throw l.invalidParameterError("compressionLevel","integer between 0 and 9",t.compressionLevel);l.defined(t.adaptiveFiltering)&&this._setBooleanOption("pngAdaptiveFiltering",t.adaptiveFiltering);let e=t.colours||t.colors;if(l.defined(e))if(l.integer(e)&&l.inRange(e,2,256))this.options.pngBitdepth=bn(e);else throw l.invalidParameterError("colours","integer between 2 and 256",e);if(l.defined(t.palette)?this._setBooleanOption("pngPalette",t.palette):[t.quality,t.effort,t.colours,t.colors,t.dither].some(l.defined)&&this._setBooleanOption("pngPalette",!0),this.options.pngPalette){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,0,100))this.options.pngQuality=t.quality;else throw l.invalidParameterError("quality","integer between 0 and 100",t.quality);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,1,10))this.options.pngEffort=t.effort;else throw l.invalidParameterError("effort","integer between 1 and 10",t.effort);if(l.defined(t.dither))if(l.number(t.dither)&&l.inRange(t.dither,0,1))this.options.pngDither=t.dither;else throw l.invalidParameterError("dither","number between 0.0 and 1.0",t.dither)}}return this._updateFormatOut("png",t)}function yh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.webpQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.alphaQuality))if(l.integer(t.alphaQuality)&&l.inRange(t.alphaQuality,0,100))this.options.webpAlphaQuality=t.alphaQuality;else throw l.invalidParameterError("alphaQuality","integer between 0 and 100",t.alphaQuality);if(l.defined(t.lossless)&&this._setBooleanOption("webpLossless",t.lossless),l.defined(t.nearLossless)&&this._setBooleanOption("webpNearLossless",t.nearLossless),l.defined(t.smartSubsample)&&this._setBooleanOption("webpSmartSubsample",t.smartSubsample),l.defined(t.smartDeblock)&&this._setBooleanOption("webpSmartDeblock",t.smartDeblock),l.defined(t.preset))if(l.string(t.preset)&&l.inArray(t.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=t.preset;else throw l.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",t.preset);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,0,6))this.options.webpEffort=t.effort;else throw l.invalidParameterError("effort","integer between 0 and 6",t.effort);l.defined(t.minSize)&&this._setBooleanOption("webpMinSize",t.minSize),l.defined(t.mixed)&&this._setBooleanOption("webpMixed",t.mixed)}return Sr(t,this.options),this._updateFormatOut("webp",t)}function Eh(t){if(l.object(t)){l.defined(t.reuse)&&this._setBooleanOption("gifReuse",t.reuse),l.defined(t.progressive)&&this._setBooleanOption("gifProgressive",t.progressive);let e=t.colours||t.colors;if(l.defined(e))if(l.integer(e)&&l.inRange(e,2,256))this.options.gifBitdepth=bn(e);else throw l.invalidParameterError("colours","integer between 2 and 256",e);if(l.defined(t.effort))if(l.number(t.effort)&&l.inRange(t.effort,1,10))this.options.gifEffort=t.effort;else throw l.invalidParameterError("effort","integer between 1 and 10",t.effort);if(l.defined(t.dither))if(l.number(t.dither)&&l.inRange(t.dither,0,1))this.options.gifDither=t.dither;else throw l.invalidParameterError("dither","number between 0.0 and 1.0",t.dither);if(l.defined(t.interFrameMaxError))if(l.number(t.interFrameMaxError)&&l.inRange(t.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=t.interFrameMaxError;else throw l.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",t.interFrameMaxError);if(l.defined(t.interPaletteMaxError))if(l.number(t.interPaletteMaxError)&&l.inRange(t.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=t.interPaletteMaxError;else throw l.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",t.interPaletteMaxError);if(l.defined(t.keepDuplicateFrames))if(l.bool(t.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",t.keepDuplicateFrames);else throw l.invalidParameterError("keepDuplicateFrames","boolean",t.keepDuplicateFrames)}return Sr(t,this.options),this._updateFormatOut("gif",t)}function Ph(t){if(!this.constructor.format.jp2k.output.buffer)throw mn();if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.jp2Quality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.lossless))if(l.bool(t.lossless))this.options.jp2Lossless=t.lossless;else throw l.invalidParameterError("lossless","boolean",t.lossless);if(l.defined(t.tileWidth))if(l.integer(t.tileWidth)&&l.inRange(t.tileWidth,1,32768))this.options.jp2TileWidth=t.tileWidth;else throw l.invalidParameterError("tileWidth","integer between 1 and 32768",t.tileWidth);if(l.defined(t.tileHeight))if(l.integer(t.tileHeight)&&l.inRange(t.tileHeight,1,32768))this.options.jp2TileHeight=t.tileHeight;else throw l.invalidParameterError("tileHeight","integer between 1 and 32768",t.tileHeight);if(l.defined(t.chromaSubsampling))if(l.string(t.chromaSubsampling)&&l.inArray(t.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=t.chromaSubsampling;else throw l.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",t.chromaSubsampling)}return this._updateFormatOut("jp2",t)}function Sr(t,e){if(l.object(t)&&l.defined(t.loop))if(l.integer(t.loop)&&l.inRange(t.loop,0,65535))e.loop=t.loop;else throw l.invalidParameterError("loop","integer between 0 and 65535",t.loop);if(l.object(t)&&l.defined(t.delay))if(l.integer(t.delay)&&l.inRange(t.delay,0,65535))e.delay=[t.delay];else if(Array.isArray(t.delay)&&t.delay.every(l.integer)&&t.delay.every(r=>l.inRange(r,0,65535)))e.delay=t.delay;else throw l.invalidParameterError("delay","integer or an array of integers between 0 and 65535",t.delay)}function xh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.tiffQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.bitdepth))if(l.integer(t.bitdepth)&&l.inArray(t.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=t.bitdepth;else throw l.invalidParameterError("bitdepth","1, 2, 4 or 8",t.bitdepth);if(l.defined(t.tile)&&this._setBooleanOption("tiffTile",t.tile),l.defined(t.tileWidth))if(l.integer(t.tileWidth)&&t.tileWidth>0)this.options.tiffTileWidth=t.tileWidth;else throw l.invalidParameterError("tileWidth","integer greater than zero",t.tileWidth);if(l.defined(t.tileHeight))if(l.integer(t.tileHeight)&&t.tileHeight>0)this.options.tiffTileHeight=t.tileHeight;else throw l.invalidParameterError("tileHeight","integer greater than zero",t.tileHeight);if(l.defined(t.miniswhite)&&this._setBooleanOption("tiffMiniswhite",t.miniswhite),l.defined(t.pyramid)&&this._setBooleanOption("tiffPyramid",t.pyramid),l.defined(t.xres))if(l.number(t.xres)&&t.xres>0)this.options.tiffXres=t.xres;else throw l.invalidParameterError("xres","number greater than zero",t.xres);if(l.defined(t.yres))if(l.number(t.yres)&&t.yres>0)this.options.tiffYres=t.yres;else throw l.invalidParameterError("yres","number greater than zero",t.yres);if(l.defined(t.compression))if(l.string(t.compression)&&l.inArray(t.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=t.compression;else throw l.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",t.compression);if(l.defined(t.bigtiff)&&this._setBooleanOption("tiffBigtiff",t.bigtiff),l.defined(t.predictor))if(l.string(t.predictor)&&l.inArray(t.predictor,["none","horizontal","float"]))this.options.tiffPredictor=t.predictor;else throw l.invalidParameterError("predictor","one of: none, horizontal, float",t.predictor);if(l.defined(t.resolutionUnit))if(l.string(t.resolutionUnit)&&l.inArray(t.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=t.resolutionUnit;else throw l.invalidParameterError("resolutionUnit","one of: inch, cm",t.resolutionUnit)}return this._updateFormatOut("tiff",t)}function Rh(t){return this.heif({...t,compression:"av1"})}function $h(t){if(l.object(t)){if(l.string(t.compression)&&l.inArray(t.compression,["av1","hevc"]))this.options.heifCompression=t.compression;else throw l.invalidParameterError("compression","one of: av1, hevc",t.compression);if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.heifQuality=t.quality;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);if(l.defined(t.lossless))if(l.bool(t.lossless))this.options.heifLossless=t.lossless;else throw l.invalidParameterError("lossless","boolean",t.lossless);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,0,9))this.options.heifEffort=t.effort;else throw l.invalidParameterError("effort","integer between 0 and 9",t.effort);if(l.defined(t.chromaSubsampling))if(l.string(t.chromaSubsampling)&&l.inArray(t.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=t.chromaSubsampling;else throw l.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",t.chromaSubsampling);if(l.defined(t.bitdepth))if(l.integer(t.bitdepth)&&l.inArray(t.bitdepth,[8,10,12])){if(t.bitdepth!==8&&this.constructor.versions.heif)throw l.invalidParameterError("bitdepth when using prebuilt binaries",8,t.bitdepth);this.options.heifBitdepth=t.bitdepth}else throw l.invalidParameterError("bitdepth","8, 10 or 12",t.bitdepth)}else throw l.invalidParameterError("options","Object",t);return this._updateFormatOut("heif",t)}function Sh(t){if(l.object(t)){if(l.defined(t.quality))if(l.integer(t.quality)&&l.inRange(t.quality,1,100))this.options.jxlDistance=t.quality>=30?.1+(100-t.quality)*.09:53/3e3*t.quality*t.quality-23/20*t.quality+25;else throw l.invalidParameterError("quality","integer between 1 and 100",t.quality);else if(l.defined(t.distance))if(l.number(t.distance)&&l.inRange(t.distance,0,15))this.options.jxlDistance=t.distance;else throw l.invalidParameterError("distance","number between 0.0 and 15.0",t.distance);if(l.defined(t.decodingTier))if(l.integer(t.decodingTier)&&l.inRange(t.decodingTier,0,4))this.options.jxlDecodingTier=t.decodingTier;else throw l.invalidParameterError("decodingTier","integer between 0 and 4",t.decodingTier);if(l.defined(t.lossless))if(l.bool(t.lossless))this.options.jxlLossless=t.lossless;else throw l.invalidParameterError("lossless","boolean",t.lossless);if(l.defined(t.effort))if(l.integer(t.effort)&&l.inRange(t.effort,1,9))this.options.jxlEffort=t.effort;else throw l.invalidParameterError("effort","integer between 1 and 9",t.effort)}return Sr(t,this.options),this._updateFormatOut("jxl",t)}function kh(t){if(l.object(t)&&l.defined(t.depth))if(l.string(t.depth)&&l.inArray(t.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=t.depth;else throw l.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",t.depth);return this._updateFormatOut("raw")}function Ah(t){if(l.object(t)){if(l.defined(t.size))if(l.integer(t.size)&&l.inRange(t.size,1,8192))this.options.tileSize=t.size;else throw l.invalidParameterError("size","integer between 1 and 8192",t.size);if(l.defined(t.overlap))if(l.integer(t.overlap)&&l.inRange(t.overlap,0,8192)){if(t.overlap>this.options.tileSize)throw l.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,t.overlap);this.options.tileOverlap=t.overlap}else throw l.invalidParameterError("overlap","integer between 0 and 8192",t.overlap);if(l.defined(t.container))if(l.string(t.container)&&l.inArray(t.container,["fs","zip"]))this.options.tileContainer=t.container;else throw l.invalidParameterError("container","one of: fs, zip",t.container);if(l.defined(t.layout))if(l.string(t.layout)&&l.inArray(t.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=t.layout;else throw l.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",t.layout);if(l.defined(t.angle))if(l.integer(t.angle)&&!(t.angle%90))this.options.tileAngle=t.angle;else throw l.invalidParameterError("angle","positive/negative multiple of 90",t.angle);if(this._setBackgroundColourOption("tileBackground",t.background),l.defined(t.depth))if(l.string(t.depth)&&l.inArray(t.depth,["onepixel","onetile","one"]))this.options.tileDepth=t.depth;else throw l.invalidParameterError("depth","one of: onepixel, onetile, one",t.depth);if(l.defined(t.skipBlanks))if(l.integer(t.skipBlanks)&&l.inRange(t.skipBlanks,-1,65535))this.options.tileSkipBlanks=t.skipBlanks;else throw l.invalidParameterError("skipBlanks","integer between -1 and 255/65535",t.skipBlanks);else l.defined(t.layout)&&t.layout==="google"&&(this.options.tileSkipBlanks=5);let e=l.bool(t.center)?t.center:t.centre;if(l.defined(e)&&this._setBooleanOption("tileCentre",e),l.defined(t.id))if(l.string(t.id))this.options.tileId=t.id;else throw l.invalidParameterError("id","string",t.id);if(l.defined(t.basename))if(l.string(t.basename))this.options.tileBasename=t.basename;else throw l.invalidParameterError("basename","string",t.basename)}if(l.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw l.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function _h(t){if(!l.plainObject(t))throw l.invalidParameterError("options","object",t);if(l.integer(t.seconds)&&l.inRange(t.seconds,0,3600))this.options.timeoutSeconds=t.seconds;else throw l.invalidParameterError("seconds","integer between 0 and 3600",t.seconds);return this}function Nh(t,e){return l.object(e)&&e.force===!1||(this.options.formatOut=t),this}function Ih(t,e){if(l.bool(e))this.options[t]=e;else throw l.invalidParameterError(t,"boolean",e)}function Fh(){if(!this.options.streamOut){this.options.streamOut=!0;let t=Error();this._pipeline(void 0,t)}}function Ch(t,e){return typeof t=="function"?(this._isStreamInput()?this.on("finish",()=>{this._flattenBufferIn(),Ze.pipeline(this.options,(r,s,i)=>{r?t(l.nativeError(r,e)):t(null,s,i)})}):Ze.pipeline(this.options,(r,s,i)=>{r?t(l.nativeError(r,e)):t(null,s,i)}),this):this.options.streamOut?(this._isStreamInput()?(this.once("finish",()=>{this._flattenBufferIn(),Ze.pipeline(this.options,(r,s,i)=>{r?this.emit("error",l.nativeError(r,e)):(this.emit("info",i),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished&&this.emit("finish")):Ze.pipeline(this.options,(r,s,i)=>{r?this.emit("error",l.nativeError(r,e)):(this.emit("info",i),this.push(s)),this.push(null),this.on("end",()=>this.emit("close"))}),this):this._isStreamInput()?new Promise((r,s)=>{this.once("finish",()=>{this._flattenBufferIn(),Ze.pipeline(this.options,(i,n,a)=>{i?s(l.nativeError(i,e)):this.options.resolveWithObject?r({data:n,info:a}):r(n)})})}):new Promise((r,s)=>{Ze.pipeline(this.options,(i,n,a)=>{i?s(l.nativeError(i,e)):this.options.resolveWithObject?r({data:n,info:a}):r(n)})})}vn.exports=t=>{Object.assign(t.prototype,{toFile:ah,toBuffer:oh,keepExif:lh,withExif:ch,withExifMerge:hh,keepIccProfile:uh,withIccProfile:fh,keepXmp:dh,withXmp:gh,keepMetadata:ph,withMetadata:mh,toFormat:bh,jpeg:vh,jp2:Ph,png:wh,webp:yh,tiff:xh,avif:Rh,heif:$h,jxl:Sh,gif:Eh,raw:kh,tile:Ah,timeout:_h,_updateFormatOut:Nh,_setBooleanOption:Ih,_read:Fh,_pipeline:Ch})}});var xn=x((Af,Pn)=>{var Dh=I("node:events"),Tt=xt(),Z=ie(),{runtimePlatformArch:jh}=pr(),B=ft(),yn=jh(),kr=B.libvipsVersion(),Ae=B.format();Ae.heif.output.alias=["avif","heic"];Ae.jpeg.output.alias=["jpe","jpg"];Ae.tiff.output.alias=["tif"];Ae.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var Th={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},et={vips:kr.semver};if(!kr.isGlobal)if(kr.isWasm)try{et=I("@img/sharp-wasm32/versions")}catch{}else try{et=I(`@img/sharp-${yn}/versions`)}catch{try{et=I(`@img/sharp-libvips-${yn}/versions`)}catch{}}et.sharp=dr().version;et.heif&&Ae.heif&&(Ae.heif.input.fileSuffix=[".avif"],Ae.heif.output.alias=["avif"]);function En(t){return Z.bool(t)?t?B.cache(50,20,100):B.cache(0,0,0):Z.object(t)?B.cache(t.memory,t.files,t.items):B.cache()}En(!0);function Lh(t){return B.concurrency(Z.integer(t)?t:null)}Tt.familySync()===Tt.GLIBC&&!B._isUsingJemalloc()?B.concurrency(1):Tt.familySync()===Tt.MUSL&&B.concurrency()===1024&&B.concurrency(I("node:os").availableParallelism());var Oh=new Dh.EventEmitter;function Mh(){return B.counters()}function zh(t){return B.simd(Z.bool(t)?t:null)}function Bh(t){if(Z.object(t))if(Array.isArray(t.operation)&&t.operation.every(Z.string))B.block(t.operation,!0);else throw Z.invalidParameterError("operation","Array<string>",t.operation);else throw Z.invalidParameterError("options","object",t)}function Uh(t){if(Z.object(t))if(Array.isArray(t.operation)&&t.operation.every(Z.string))B.block(t.operation,!1);else throw Z.invalidParameterError("operation","Array<string>",t.operation);else throw Z.invalidParameterError("options","object",t)}Pn.exports=t=>{t.cache=En,t.concurrency=Lh,t.counters=Mh,t.simd=zh,t.format=Ae,t.interpolators=Th,t.versions=et,t.queue=Oh,t.block=Bh,t.unblock=Uh}});var $n=x((Nf,Rn)=>{var Ee=Li();zi()(Ee);Wi()(Ee);Ji()(Ee);Zi()(Ee);fn()(Ee);gn()(Ee);wn()(Ee);xn()(Ee);Rn.exports=Ee});var it={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},Mr={available:["auth","oauth","billing","crud"],packageNames:{auth:"@donotdev/auth",oauth:"@donotdev/oauth",billing:"@donotdev/billing",crud:"@donotdev/crud"},hooks:{auth:["useAuth"],oauth:["useOAuth","useOAuthPartner","useOAuthConnection"],billing:["useStripeBilling","useStripeCheckout"],crud:["useCrud","useCrudCollection"]}};var re={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},De={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"}},Vt={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},nt={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},mt={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"},K={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:[`${mt.SOURCE_EAGER}/*_*.json`],lazy:[`${mt.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/**"]},bt={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"]},zr=["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"];var Jt={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)/}},at={Inter:"inter-latin","Space Grotesk":"space-grotesk-latin","Playfair Display":"playfair-display-latin","Press Start 2P":"press-start-2p-latin",Roboto:"roboto-latin"},Xt=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],Or={base:{absolute:!0,onlyFiles:!0,ignore:K.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...K.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...K.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:K.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:K.globalIgnore}};function Br(t,e=null){let r=K[t];if(!r)throw new Error(`Unknown pattern type: ${t}`);return e&&r.framework?{...r,framework:r.framework.map(s=>`${e}/${s}`)}:r}function vt(t){return Or[t]||Or.base}import*as $ from"node:fs";import"node:fs";import{createRequire as ha}from"node:module";import{resolve as wt,join as me,dirname as xe,relative as Ur,normalize as ua,sep as qr,extname as fa}from"node:path";import{fileURLToPath as da}from"node:url";import ga from"fast-glob";var qe={getGlobOptionsFor:vt||void 0,SCAN_PATTERNS:K||void 0,getPatternsFor:Br||void 0,I18N_PATHS:mt||void 0},T={error:(t,e)=>{},warn:(t,e)=>{},info:t=>{}};function Gr(t,e){return t().catch(r=>{throw new Error(`${e}: ${r instanceof Error?r.message:String(r)}`)})}var Hr={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"},D=class t{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return t._instance||(t._instance=new t(e)),t._instance}static _reset(){t._instance=null}constructor(e={}){if(t._instance)return t._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.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,t._instance=this}normalizePath(e){if(!e)return"";try{return ua(e).split(qr).join("/")}catch{return String(e).split(qr).join("/")}}getRelativePath(e){let r=this.getAppRoot(),s=Ur(r,e);return this.normalizePath(s)}getBasename(e){if(!e)return"";let s=this.normalizePath(e).split("/");return s[s.length-1]||""}getDirname(e){return e?this.normalizePath(xe(e)):""}resolvePackage(e,r=null){try{let s=r||this.getAppRoot(),n=ha(me(s,"package.json")).resolve(e);return this.normalizePath(n)}catch{return null}}resolveFrameworkPackage(e,r=null){let s=this.resolvePackage(`${e}/package.json`,r);if(s)return this.getDirname(s);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let a=e.replace("@donotdev/",""),o=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(o))return o;if(["auth","billing","crud","oauth"].includes(a)){let c=this.resolveRepoPath(`packages/features/${a}`);if(this.pathExists(c))return c}if(a==="firebase"){let c=this.resolveRepoPath(`packages/providers/${a}`);if(this.pathExists(c))return c}}let i=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(i))return i;let n=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(n)?n:null}resolvePackageAsset(e,r=null){return this.resolvePackage(e,r)}resolveAppPath(e){let r=this.getAppRoot(),s=wt(r,e);return this.normalizePath(s)}resolveRepoPath(e){let r=this.getRepoRoot(),s=this.normalizePath(e),i=wt(r,s);return this.normalizePath(i)}resolvePath(e,r){let s=this.normalizePath(r),i=this.normalizePath(e),n=wt(s,i);return this.normalizePath(n)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let r=$.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:r.size,isFile:r.isFile(),isDirectory:r.isDirectory()}}catch{return null}}_detectFormat(e,r){return r&&r!=="auto"?r:fa(e).toLowerCase()===".json"?"json":"text"}async read(e,r={}){let{format:s="auto",encoding:i="utf8"}=r,n=this._detectFormat(e,s);try{if(n==="buffer")return await $.promises.readFile(e);let a=await $.promises.readFile(e,i),o=this.stripBom(a);return n==="json"?JSON.parse(o):o}catch(a){return this.options.debug&&T.warn(`Failed to read file: ${e}`,a),null}}readSync(e,r={}){let{format:s="auto",encoding:i="utf8"}=r,n=this._detectFormat(e,s);try{if(n==="buffer")return $.readFileSync(e);let a=$.readFileSync(e,i),o=this.stripBom(a);return n==="json"?JSON.parse(o):o}catch(a){return this.options.debug&&T.warn(`Failed to read file: ${e}`,a),null}}async write(e,r,s={}){let{format:i="auto",overwrite:n=!1,dryRun:a=!1,verbose:o=!1}=s,c=this.normalizePath(e),h=this.normalizePath(xe(c)),f=this.pathExists(c);if(f&&!n)return o&&T.info(`Skipping existing file: ${c}`),!1;if(a)return T.info(`[DRY RUN] Would write file: ${c}`),!0;try{await $.promises.mkdir(h,{recursive:!0})}catch(p){if(p?.code!=="EEXIST")throw p}let g=this._detectFormat(e,i),m;Buffer.isBuffer(r)?m=r:g==="json"&&typeof r=="object"?m=JSON.stringify(r,null,2):m=String(r);try{return await Gr(async()=>(Buffer.isBuffer(m)?await $.promises.writeFile(c,m):await $.promises.writeFile(c,m,"utf8"),o&&T.info(`${f?"Updated":"Created"} file: ${c}`),!0),`Failed to write file: ${c}`)}catch{return!1}}writeSync(e,r,s={}){let{format:i="auto",overwrite:n=!1,dryRun:a=!1,verbose:o=!1}=s,c=this.normalizePath(e),h=this.normalizePath(xe(c)),f=this.pathExists(c);if(f&&!n)return o&&T.info(`Skipping existing file: ${c}`),!1;if(a)return T.info(`[DRY RUN] Would write file: ${c}`),!0;try{$.mkdirSync(h,{recursive:!0})}catch(p){if(p?.code!=="EEXIST")throw p}let g=this._detectFormat(e,i),m;Buffer.isBuffer(r)?m=r:g==="json"&&typeof r=="object"?m=JSON.stringify(r,null,2):m=String(r);try{return Buffer.isBuffer(m)?$.writeFileSync(c,m):$.writeFileSync(c,m,"utf8"),o&&T.info(`${f?"Updated":"Created"} file: ${c}`),!0}catch(p){throw new Error(`Failed to write file: ${c}: ${p instanceof Error?p.message:String(p)}`)}}async copy(e,r,s={}){let{overwrite:i=!1,dryRun:n=!1,verbose:a=!1}=s,o=this.normalizePath(r),c=this.pathExists(o);if(c&&!i)return a&&T.info(`Skipping existing file: ${o}`),!1;if(n)return T.info(`[DRY RUN] Would copy file: ${o}`),!0;let h=this.normalizePath(xe(o));try{await $.promises.mkdir(h,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}try{return await Gr(async()=>(await $.promises.copyFile(e,o),a&&T.info(`${c?"Updated":"Created"} file: ${o}`),!0),`Failed to copy file from ${e} to ${o}`)}catch{return!1}}copySync(e,r,s={}){let{overwrite:i=!1,dryRun:n=!1,verbose:a=!1}=s,o=this.normalizePath(r),c=this.pathExists(o);if(c&&!i)return a&&T.info(`Skipping existing file: ${o}`),!1;if(n)return T.info(`[DRY RUN] Would copy file: ${o}`),!0;let h=this.normalizePath(xe(o));try{$.mkdirSync(h,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}try{return $.copyFileSync(e,o),a&&T.info(`${c?"Updated":"Created"} file: ${o}`),!0}catch{return!1}}pathExists(e,r=!1){try{return $.existsSync(e)}catch(s){return r||T.error(`Error checking path existence: ${e}`,s),!1}}mkdir(e){try{let r=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return $.existsSync(r)||$.mkdirSync(r,{recursive:!0}),!0}catch{return!1}}readdirSync(e,r){try{return $.readdirSync(e,r)}catch(s){return this.options.debug&&T.warn(`Failed to read directory: ${e}`,s),r&&typeof r=="object"&&"withFileTypes"in r&&r.withFileTypes?[]:[]}}statSync(e){try{return $.statSync(e)}catch(r){return this.options.debug&&T.warn(`Failed to stat file: ${e}`,r),null}}lstatSync(e){try{return $.lstatSync(e)}catch(r){return this.options.debug&&T.warn(`Failed to lstat file: ${e}`,r),null}}async ensureDir(e){try{await $.promises.mkdir(e,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}ensureDirSync(e){try{$.mkdirSync(e,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}async remove(e){await $.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){$.rmSync(e,{recursive:!0,force:!0})}async readdir(e,r){return $.promises.readdir(e,r)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=me(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let r=this.normalizePath(wt(e)),s=this.getAppRoot(),i=Ur(s,r),n=this.normalizePath(i);return!n.startsWith("../")&&!n.startsWith("/")}async findFiles(e,r,s={}){let i=this.normalizePath(me(e,r)),n=this.getAppRoot(),a=this.normalizePath(n),o=i.startsWith(a)?i.slice(a.length+1):i,c={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n,ignore:qe.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([o],{...c,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let r=qe.I18N_PATHS;if(!r)return null;let s=e.replace(r.SOURCE_ROOT+"/",""),i=this.resolveFrameworkPackage("@donotdev/core");if(!i)return null;let n=this.normalizePath(me(i,r.PUBLISHED_ROOT,s)),a=n.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),n}async _globWithNormalization(e,r){return(await ga(e,r)).map(i=>{let n=typeof i=="string"?i:i.path;return this.normalizePath(n)})}async resolveFiles(e,r="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(r==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...e.framework,...e.consumer];for(let f of s)if(typeof f!="string"||f.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let i=this.getAppRoot(),n=qe.getGlobOptionsFor?qe.getGlobOptionsFor(r):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(i),o=e.framework.map(f=>{let g=this.normalizePath(f);return g.startsWith(a)?g.slice(a.length+1):g}),c=e.consumer.map(f=>{let g=this.normalizePath(f);return g.startsWith(a)?g.slice(a.length+1):g}),h={...n,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:i};try{let f=o.length>0?await this._globWithNormalization(o,h):[],g=await this._globWithNormalization(c,h);return{frameworkFiles:f,consumerFiles:g}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!qe.getPatternsFor)return{framework:[],consumer:[],all:[]};let r=this.getAppRoot(),s=this.getRepoRoot();if(e==="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 i=qe.getPatternsFor(e),n=this.isMonorepo();if(e==="i18n"){let c=i,h={eager:c.eager.map(f=>f.startsWith("!")?"!"+this.resolveAppPath(f.slice(1)):this.resolveAppPath(f)),lazy:c.lazy.map(f=>f.startsWith("!")?"!"+this.resolveAppPath(f.slice(1)):this.resolveAppPath(f)),framework:{eager:n?(c.framework?.eager||[]).map(f=>this.resolveRepoPath(f)).filter(Boolean):await Promise.all((c.framework?.eager||[]).map(f=>this._resolveFrameworkI18nPattern(f))).then(f=>f.filter(Boolean)),lazy:n?(c.framework?.lazy||[]).map(f=>this.resolveRepoPath(f)).filter(Boolean):await Promise.all((c.framework?.lazy||[]).map(f=>this._resolveFrameworkI18nPattern(f))).then(f=>f.filter(Boolean))},all:[]};return h.all=[...h.eager,...h.lazy,...h.framework.eager,...h.framework.lazy],h}let a=i,o={framework:n?(a.framework||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):[],consumer:(a.consumer||[]).map(c=>this.resolveAppPath(c)),all:[]};return o.all=[...o.consumer,...o.framework],o}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let r=this.resolvePackage("@donotdev/core/empty");if(r)return r;let s=xe(da(import.meta.url));return this.normalizePath(me(s,"../empty.js"))}_findRepoRoot(e){let r=this.normalizePath(e),s=0,i=this.options.maxLevels;for(;s<i;){let n=this.normalizePath(me(r,Hr.TOOLING)),a=this.normalizePath(me(r,Hr.CORE));if(this.pathExists(n)&&this.pathExists(a))return r;let o=me(r,"apps");if(this.pathExists(o)&&this.statSync(o)?.isDirectory())return this.normalizePath(r);let c=this.normalizePath(me(r,"package.json"));if(this.pathExists(c)&&this.normalizePath(xe(r))===r)return r;let h=this.normalizePath(xe(r));if(h===r)break;r=h,s++}return this.normalizePath(e)}};function Wr({logger:t,debug:e=!1}={}){let r=D.getInstance(),s=!1,i=null;if(process.env.DNDEV_APP_ROOT?(i=r.normalizePath(process.env.DNDEV_APP_ROOT),r.pathExists(i)?(r.setAppRoot(i),s=!0,e&&t&&t.debug(`App root set from DNDEV_APP_ROOT: ${i}`)):t&&t.warn(`DNDEV_APP_ROOT path does not exist: ${i}`)):e&&t&&t.debug("DNDEV_APP_ROOT env var not set"),!s){if(r.getRepoRoot()){let a=r.resolveRepoPath("apps");if(r.pathExists(a))try{let o=process.cwd(),c=r.normalizePath(o);if(c.includes("/apps/")){let h=c.indexOf("/apps/"),g=c.substring(h+6).split("/")[0];if(g){let m=r.resolveRepoPath(`apps/${g}`),p=r.resolveRepoPath(`apps/${g}/next.config.js`);r.pathExists(p)&&(i=m,r.setAppRoot(i),s=!0,e&&t&&t.debug(`App root detected from process.cwd(): ${i}`))}}}catch{}}!s&&!i&&(i=process.cwd(),r.setAppRoot(i),s=!0,e&&t&&t.debug(`App root fallback to process.cwd(): ${i}`))}return{appRoot:i,appRootSet:s}}function Vr(){try{let t=D.getInstance(),e=t.resolveAppPath("package.json"),r=t.readSync(e,{format:"json"});if(!r)return[];let s={...r.dependencies,...r.devDependencies};return Object.keys(s).filter(n=>{let a=n.startsWith("@donotdev/"),o=n==="entities",c=s[n]&&typeof s[n]=="string"&&s[n].startsWith("workspace:");return a||o||c}).filter(n=>!bt.buildTimePackages.includes(n)).sort()}catch{return[]}}function be(t){return t&&typeof t=="object"&&!Array.isArray(t)}import Yt from"node:fs";import Xr from"node:path";var Jr=/--(?:font-family|font-headline)\s*:\s*(?:['"]([^'"]+)['"]|([^;]+?));/g,Re=class{constructor(e,r={}){if(!e)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=e,this.options={debug:!1,customPatterns:{},...r},this.logger=r.logger||{debug:(s,...i)=>{this.options.debug}},this.patterns={selectors:{...Jt.selectors,...this.options.customPatterns?.selectors},themes:{...Jt.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(e){if(!e||typeof e!="string")return this._debug(`Invalid CSS variable: ${e}`),null;let r=e.replace(/^--/,"");if(!r)return this._debug(`Empty CSS variable after removing --: ${e}`),null;let s=r.split("-").filter(a=>a.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${e}`),null;let i=s.map((a,o)=>{let c=a.replace(/[^a-zA-Z0-9]/g,"");return c?o===0?c.toLowerCase():c.charAt(0).toUpperCase()+c.slice(1).toLowerCase():null}).filter(Boolean).join("");return!i||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(i)?(this._debug(`Invalid JavaScript identifier generated from ${e}: ${i}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(i)?`${i}Var`:i}_stripComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(e,r,s){let i=[],n,a=this.pathResolver.normalizePath(r),o=this._stripComments(e),c=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(n=c.exec(o))!==null;){let[,h,f,g]=n;if(!h||!g)continue;let m=f.match(this.patterns.themes.themeIcon),p=f.match(this.patterns.themes.themeIsDark),R={name:h,displayName:g,isDark:p?p[1]==="1":!1,meta:{icon:m?.[1]},source:this.pathResolver.getBasename(r)};this._debug(`Discovered theme: ${h} (${g})`),i.push(R),s.themes.set(h,{name:h,displayName:g,isDark:R.isDark,file:a,variables:new Set,meta:R.meta})}return i.length>0&&this._debug(`Extracted ${i.length} themes from ${a}`),i}extractClasses(e,r){(e.match(this.patterns.selectors.class)||[]).forEach(i=>{let n=i.slice(1);n.startsWith("_")||r.classes.add(n)})}extractVariables(e,r,s){(e.match(this.patterns.selectors.variable)||[]).forEach(n=>{n.startsWith("--")&&n.length>2?s==="framework"?r.variables.framework.add(n):r.variables.consumer.add(n):this._debug(`Skipping invalid CSS variable: ${n}`)})}extractFontFamilies(e){if(!e||typeof e!="string")return[];let r=this._stripComments(e),s=new Set,i;for(Jr.lastIndex=0;(i=Jr.exec(r))!==null;){let n=i[1];n&&n.trim()&&s.add(n.trim())}return Array.from(s)}extractKeyframes(e,r){(e.match(this.patterns.selectors.keyframe)||[]).forEach(i=>{let n=i.replace("@keyframes","").trim();n&&r.keyframes.add(n)})}validateCSS(e){let r=[],s=e.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(n=>{r.push(`Possible malformed CSS variable: ${n}`)}),(e.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(n=>{if(!n.includes("--theme-label")&&n.includes("--")){let a=n.match(/\.([a-z][a-z0-9-]+)/)?.[1];a&&r.push(`Theme class "${a}" missing --theme-label`)}}),r}extractAll(e,r,s="consumer"){let i={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},n=this.extractThemes(e,r,i);this.extractClasses(e,i),this.extractVariables(e,i,s),this.extractKeyframes(e,i);let a=this.validateCSS(e);return{themes:n,classes:Array.from(i.classes),variables:{framework:Array.from(i.variables.framework),consumer:Array.from(i.variables.consumer),all:[...Array.from(i.variables.framework),...Array.from(i.variables.consumer)].sort()},keyframes:Array.from(i.keyframes),warnings:a}}getPatterns(){return{...this.patterns}}setPatterns(e){this.patterns={...this.patterns,...e,selectors:{...this.patterns.selectors,...e.selectors},themes:{...this.patterns.themes,...e.themes}}}_debug(e,r){this.logger.debug(e,r||"")}};var q;try{q=await import("@clack/prompts")}catch{q={log:{message:t=>{},info:t=>{},warn:t=>{},error:t=>{},success:t=>{},step:t=>{}}}}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 pa(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function se(t,e){return pa()?`${e}${t}${ee.reset}`:t}function W(t,e,r,s={}){let{logDir:i=".dndev-logs",fileLogging:n=!1}=s,a=D.getInstance(),o=null;if(n){let f=a.resolveAppPath(i);a.pathExists(f)||a.mkdir(f),o=a.resolveAppPath(`${i}/${t.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let g=`=== ${t} Log Started at ${new Date().toISOString()} ===
|
|
3
3
|
`;a.writeSync(o,g)}let c=(f,g,m)=>{if(o){let p=new Date().toISOString(),R=m.length>0?" "+m.map(J=>typeof J=="object"?JSON.stringify(J,null,2):String(J)).join(" "):"",C=`${p} [${f}] ${g}${R}
|
|
4
4
|
`;a.appendFile(o,C)}},h=(f,g)=>{if(g.length===0)return f;let m=g.map(p=>typeof p=="object"?JSON.stringify(p,null,2):String(p)).join(" ");return`${f} ${m}`};return{debug:(f,...g)=>{e&&(n?c("DEBUG",f,g):q.log.message(se(h(f,g),ee.gray)))},verbose:(f,...g)=>{r&&(n?c("VERBOSE",f,g):q.log.message(h(f,g)))},info:(f,...g)=>{n?c("INFO",f,g):q.log.info(se(h(f,g),ee.brightCyan))},warn:(f,...g)=>{e&&n?c("WARN",f,g):q.log.warn(se(h(f,g),ee.brightYellow))},error:(f,...g)=>{e&&n?c("ERROR",f,g):q.log.error(se(h(f,g),ee.brightRed))},success:(f,...g)=>{e&&n?c("SUCCESS",f,g):q.log.success(se(h(f,g),ee.brightGreen))},when:(f,g="debug")=>(m,...p)=>{if(f){let R=h(m,p);switch(g){case"verbose":r&&(q.log.message(R),c("VERBOSE",m,p));break;case"info":q.log.info(se(R,ee.brightCyan)),c("INFO",m,p);break;case"warn":q.log.warn(se(R,ee.brightYellow)),c("WARN",m,p);break;case"error":q.log.error(se(R,ee.brightRed)),c("ERROR",m,p);break;case"success":q.log.success(se(R,ee.brightGreen)),c("SUCCESS",m,p);break;default:e&&(q.log.message(se(R,ee.gray)),c("DEBUG",m,p))}}},getLogFilePath:()=>o}}var ma=3,Yr="dndev-font-preloads.json";async function ba(t,e){let r=W("font-preload-next",e,!1);try{let s=await t.resolvePatterns("css"),{consumerFiles:i}=await t.resolveFiles(s,"css");if(!i?.length)return[at.Inter];let n=new Re(t,{debug:e,logger:r}),a=new Set;for(let c of i)try{let h=await t.read(c,{format:"text"});h&&n.extractFontFamilies(h).forEach(f=>a.add(f))}catch{}if(a.size===0)return[at.Inter];let o=new Set;for(let c of a){let h=at[c];h&&o.add(h)}return Array.from(o)}catch{return[at.Inter]}}function Kr({pathResolver:t,debug:e=!1}){let r=W("font-preload-next",e,!1);return{apply(s){s.hooks.afterEmit.tapAsync("DndevFontPreloadManifest",async(i,n)=>{if(i.compiler.isChild()||i.compiler.name?.includes("server"))return n();try{let o=t.getAppRoot();if(!o)return n();let c=await ba(t,e),h=i.outputOptions.publicPath&&String(i.outputOptions.publicPath)!=="auto"?i.outputOptions.publicPath.replace(/\/$/,""):"",f=[];for(let[p]of Object.entries(i.assets)){if(!p.endsWith(".woff2")&&!p.endsWith(".woff"))continue;let R=p.toLowerCase();if(c.some(C=>R.includes(C))){let C=h?`${h}/${p}`:`/${p}`;if(f.push({href:C,type:"font/woff2"}),f.length>=ma)break}}let g=Xr.join(o,"public");if(!Yt.existsSync(g))try{Yt.mkdirSync(g,{recursive:!0})}catch(p){return r.debug(`Font preload: could not create public dir: ${p?.message}`),n()}let m=Xr.join(g,Yr);Yt.writeFileSync(m,JSON.stringify(f,null,0),"utf8"),r.debug(`Font preload: wrote ${f.length} entries to ${Yr}`)}catch(o){r.debug(`Font preload manifest: ${o?.message}`)}n()})}}}function Qr({originalWebpack:t,unusedFeaturePackages:e,usedFeaturePackages:r,logger:s,debug:i}){return(n,a)=>{let{dev:o,isServer:c,webpack:h}=a;o&&!c&&(n.infrastructureLogging={level:"error"},n.stats={...n.stats,logging:"error",loggingTrace:!1},n.ignoreWarnings=[...n.ignoreWarnings||[],/WebSocket connection to/,/WebSocket closed without opened/,/failed to connect to websocket/,/WebSocket error/]);let f=n.module?.rules?.find(g=>g.test?.test?.(".svg"));f&&(f.exclude=/\.svg$/i),n.module=n.module||{},n.module.rules=n.module.rules||[],n.module.rules.push({test:/\.svg$/i,type:"asset/resource",generator:{filename:"static/media/[name].[hash][ext]"}}),h?.IgnorePlugin&&n.plugins.push(new h.IgnorePlugin({resourceRegExp:/^(vite|@vitejs|vite-tsconfig-paths)$/}));try{let g=D.getInstance();n.plugins.push(Kr({pathResolver:g,debug:i}))}catch(g){s.debug(`Font preload webpack plugin skipped: ${g?.message}`)}if(e.length>0)if(s.info(`\u{1F6AB} Excluding unused features: ${e.join(", ")}`),s.info(`\u2705 Including features: ${r.join(", ")}`),n.externals=n.externals||[],Array.isArray(n.externals))n.externals.push(...e);else{let g=n.externals;n.externals=(m,p,R)=>e.includes(p)?R(null,"commonjs "+p):typeof g=="function"?g(m,p,R):R()}return t?t(n,a):n}}function Zr({originalRewrites:t,handlers:e,logger:r}){return async function(){try{let s=t?await t():[],n=e.filter(o=>o?.getAPIRewrites).map(o=>o.getAPIRewrites()).reduce((o,c)=>(c?.beforeFiles&&o.beforeFiles.push(...c.beforeFiles),c?.afterFiles&&o.afterFiles.push(...c.afterFiles),c?.fallback&&o.fallback.push(...c.fallback),o),{beforeFiles:[],afterFiles:[],fallback:[]}),a={beforeFiles:[...Array.isArray(s)?[]:s?.beforeFiles||[],...n.beforeFiles],afterFiles:[...Array.isArray(s)?s:s?.afterFiles||[],...n.afterFiles],fallback:[...Array.isArray(s)?[]:s?.fallback||[],...n.fallback]};return a.beforeFiles.length===0&&a.afterFiles.length===0&&a.fallback.length===0?null:a}catch(s){return r.error(`Next.js config failed to merge rewrites: ${s.message}`),r.error(`Stack: ${s.stack||"No stack trace available"}`),null}}}function es({routeResult:t,themeResult:e,i18nResult:r,assetResult:s,seoResult:i,pwaResult:n,serverShimResult:a,restNextConfig:o,discoveredPackages:c,webpackConfig:h,rewritesConfig:f,missingOptionalDeps:g,env:m,logger:p}){let R=o?.output==="export",J=o?.distDir||".next";return{transpilePackages:c,...o?.serverExternalPackages||o?.serverComponentsExternalPackages?{serverExternalPackages:(o?.serverExternalPackages||o?.serverComponentsExternalPackages||[]).filter(ue=>!ue.startsWith("@donotdev/"))}:{},...be(o)?o:(p.warn("restNextConfig is not a plain object:",o),{}),distDir:J,...process.env.NODE_ENV==="development"&&{devIndicators:{position:"bottom-right"},onDemandEntries:{maxInactiveAge:60*1e3,pagesBufferLength:5}},...be(t)?t:(p.error(`Route handler config invalid (got ${typeof t}):`,t),{}),...be(e)?e:(p.error(`Theme handler config invalid (got ${typeof e}):`,e),{}),...be(r)?r:(p.error(`I18n handler config invalid (got ${typeof r}):`,r),{}),...be(s)?s:(p.error(`Asset handler config invalid (got ${typeof s}):`,s),{}),...be(i)?i:(p.error(`SEO handler config invalid (got ${typeof i}):`,i),{}),...be(n)?n:(p.error(`PWA handler config invalid (got ${typeof n}):`,n),{}),...be(a)?a:(p.warn("serverShimConfig returned non-object:",a),{}),webpack:h,...R?{}:{rewrites:async()=>await f()||void 0},env:m,...process.env.NODE_ENV==="production"&&{logging:{fetches:{fullUrl:!1}}}}}var va=["public/route-manifest.json","public/theme-manifest.json","public/i18n-manifest.json","public/asset-manifest.json","public/seo-manifest.json","public/pwa-manifest.json"],wa="dndev-config-",ts=".dndev-build";function ya(t){if(!t)return!1;let e=D.getInstance(),r=e.resolveAppPath(ts),s=process.env.DNDEV_BUILD_ID;try{return(e.readSync(r,{format:"text"})||"").trim()===s}catch{return!1}}function Ea(t){if(!t)return;let e=D.getInstance(),r=e.resolveAppPath(ts),s=process.env.DNDEV_BUILD_ID;try{e.writeSync(r,s)}catch{}}function Kt(t,e){if(!t)return;let r=D.getInstance();for(let i of va){let n=r.resolveAppPath(i);if(r.pathExists(n))try{r.removeSync(n),e.debug(`Cleaned: ${i}`)}catch{}}let s=r.resolveAppPath("src/config");if(r.pathExists(s))try{let i=r.readdirSync(s);for(let n of i)if(n.startsWith(wa)&&n.endsWith(".js"))try{let a=r.resolvePath(n,s);r.removeSync(a),e.debug(`Cleaned: src/config/${n}`)}catch{}}catch{}}async function Qt({routeHandler:t,themeHandler:e,i18nHandler:r,assetHandler:s,seoHandler:i,pwaHandler:n},a){let o=t?.pathResolver;if(!o)throw new Error("PathResolver not available - handlers must be initialized with PathResolver");let c=o.getAppRoot(),h=o.getRepoRoot();if(!c||c===h){a.warn("\u26A0\uFE0F App root not properly set before discovery - waiting for appRoot resolution"),await new Promise(R=>setTimeout(R,0));let p=o.getAppRoot();if(!p||p===h)throw new Error("App root not set before discovery. Ensure resolveAppRoot() is called before runDiscoveries().")}if(ya(c)){a.debug("Discoveries already completed this build, skipping");return}let f=Date.now();if(t)try{a.info("\u{1F50D} Starting route discovery...");let R=(await t.generateFiles())?.routes?.length||0;a.info(`\u2705 Routes generated: ${R} routes found`),R===0&&a.error("\u274C NO ROUTES FOUND! Check that pages exist in src/pages/")}catch(p){throw a.error(`\u274C Route generation failed: ${p.message}`),p.stack&&a.error(`Stack: ${p.stack}`),p}else a.warn("\u26A0\uFE0F Route handler is disabled - no routes will be discovered");let g=[{name:"Theme",handler:e},{name:"I18n",handler:r},{name:"Asset",handler:s},{name:"SEO",handler:i},{name:"PWA",handler:n}];for(let{name:p,handler:R}of g)try{await R.generateFiles()}catch(C){a.debug(`${p} generation failed: ${C.message}`)}let m=Date.now()-f;a.verbose?.(`\u2705 All discoveries completed in ${m}ms - Next.js can now compile`),Ea(c)}async function rs(t,e,r){if(r)return!1;try{let s=await t.getDiscoveryData();return s?.copiedAssets?.length>0&&e.info(`\u{1F4E6} Copied ${s.copiedAssets.length} assets from framework`),!0}catch(s){return e.debug(`Asset discovery failed (non-critical): ${s.message}`),!1}}var ot={debug:!1,verbose:process.env.CI!=="true",features:{},generateManifest:!0,routes:{disabled:!1,debug:!1,routingMode:"app",generateMiddleware:!0},themes:{debug:!1},i18n:{debug:!1,fallbackLanguage:"en"},assets:{debug:!1},pwa:{debug:!1},seo:{disabled:!1,debug:!1,generateRobotsTxt:!0,generateSitemap:!0,crawlDelay:1},serverShim:{enabled:!0,debug:!1},discovery:{debug:!1,verbose:!1,cacheTimeout:6e4,fileLogging:!1,logDir:".dndev-logs"}};function ss(t,e){let r={...t};return e&&Object.keys(e).forEach(s=>{e[s]&&typeof e[s]=="object"&&!Array.isArray(e[s])?r[s]=ss(t[s]||{},e[s]):r[s]=e[s]}),r}function is(t={}){return ss(ot,t)}function ns(t){let{features:e={},routes:r={},themes:s={},i18n:i={},assets:n={},pwa:a={},seo:o={},serverShim:c={},discovery:h={},generateManifest:f,debug:g,verbose:m,...p}=t,R=process.env.NODE_ENV==="production"?"production":"development";return{generateManifest:f,debug:g,verbose:m,mode:R,isDev:R==="development",routeOptions:r,themeOptions:s,i18nOptions:i,assetOptions:n,featureOptions:e,pwaOptions:a,seoOptions:o,serverShimOptions:c,discoveryOptions:h,nextConfigOptions:p}}var G=class{constructor(e,r={}){this.options={...r,...this.getHandlerDefaults()},this.logger=W(`Next${this.getHandlerName()}Handler`,this.options.debug,this.options.verbose),this.pathResolver=D.getInstance(),this.configRoot=this.pathResolver.getAppRoot(),this.discovery=this.createDiscovery(e),this.initialize()}getHandlerDefaults(){return{}}logDiscoveryResults(e){}createDiscovery(e){let r={...ot.discovery,...this.options};return new e(this.pathResolver,r)}initialize(){}setAppRoot(e){this.configRoot=e,this.pathResolver.setAppRoot(e)}createNextConfig(){return(e={})=>(this.options.debug&&this.logger.debug(`${this.getHandlerName()} handler initialized`),{...e,webpack:(r,s)=>{let{dev:i,isServer:n,webpack:a}=s;return this.applyViteIgnorePlugin(r,a),this._generateFiles(),e.webpack?e.webpack(r,s):r},rewrites:async function(){try{let r=e.rewrites?await e.rewrites():[],s=this.getAPIRewrites();return this.mergeRewrites(r,s)}catch(r){return this.logger.error(`${this.getHandlerName()} handler failed to merge rewrites: ${r.message}`),this.logger.error(`Stack: ${r.stack||"No stack trace available"}`),[]}}.bind(this)})}async generateFiles(){try{let e=await this.getDiscoveryData();return this.options.verbose&&this.logDiscoveryResults(e),await this.generateConfigFile(e),this.options.generateManifest&&await this.generateManifest(e),await this.generateSpecificFiles(e),this.getHandlerName()==="Route"&&await this.generateNextEnvTypes(),this.logger.debug(`Generated ${this.getHandlerName()}: ${this.getGenerationSummary(e)}`),e}catch(e){throw this.logger.error(`${this.getHandlerName()} handler failed to generate files: ${e.message}`),this.logger.error(`Stack: ${e.stack||"No stack trace available"}`),e}}async generateConfigFile(e){let r=this.getHandlerName().toLowerCase(),s=De.next[`config${r.charAt(0).toUpperCase()}${r.slice(1)}`];if(!s)throw new Error(`No config path defined for ${r} handler. Add config${r.charAt(0).toUpperCase()}${r.slice(1)} to GENERATED_PATHS.next in constants.js`);let i=this.generateConfigContent(e);this.writeGeneratedFile(s,i,`DnDev ${r} config`)}generateConfigContent(e){let r=this.getHandlerName().toLowerCase(),s=re[r]||r;return`// Auto-generated DnDev config by @donotdev/config
|
|
5
5
|
// Generated at: ${new Date().toISOString()}
|
|
@@ -235,7 +235,7 @@ registerRoute(
|
|
|
235
235
|
}),
|
|
236
236
|
'POST'
|
|
237
237
|
);
|
|
238
|
-
`}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(e=".next"){let r=this.pathResolver.resolveAppPath(`${e}/static`),s=this.pathResolver.resolveAppPath(`${e}/static/chunks`),i=this.pathResolver.resolveAppPath(`${e}/static/css`),n=[];try{let a=[`${r}/**/*.{js,css,woff2,woff,ttf,eot}`,`${s}/**/*.{js,css}`,`${i}/**/*.css`];for(let o of a){let c=await this.pathResolver.findFiles(this.pathResolver.getAppRoot(),o.replace(this.pathResolver.getAppRoot(),""),{onlyFiles:!0});for(let h of c){let f=this.pathResolver.getRelativePath(h);if(f.startsWith(`${e}/static/`)){let g=`/_next/${f.replace(`${e}/static/`,"")}`;n.push({url:g,revision:null})}}}}catch(a){this.logger?.warn(`Failed to discover Next.js build assets: ${a.message}`)}return n}generatePrecacheManifest(e=[],r=null){let s=e;return r&&typeof r=="function"&&(s=r(s)),s}async discoverPWAAssets(e=!1){return await this.discover(e)}getPWAAssets(){return this.cache?.assets||[]}getPWAManifest(){return this.cache?.manifest||this._getDefaultManifest()}};var Ir=class extends G{constructor(e={}){super(Mt,e)}getHandlerDefaults(){return{enabled:!1,manifestPath:"public/manifest.json",serviceWorkerPath:"public/sw.js",workboxPath:"public/workbox-*.js",generateServiceWorker:!0,generateManifest:!0}}createDiscovery(e){let r=this.options.assetData||_r.data;return new e(this.pathResolver,{...this.options,assetData:r})}getHandlerName(){return"PWA"}async getDiscoveryData(){return await this.discovery.discoverPWAAssets()}getAPIRewrites(){return this.options.enabled?this.discovery.getPWARewrites():{beforeFiles:[],afterFiles:[],fallback:[]}}formatAPIResponse(e){return{assets:e.assets,manifest:e.manifest,totalAssets:e.assets.length,timestamp:e.timestamp}}createManifestContent(e){return{assets:e.assets.map(r=>({type:r.type,path:r.path,size:r.size})),manifest:e.manifest,totalAssets:e.assets.length,generatedAt:new Date().toISOString()}}getGenerationSummary(e){return`${e.assets.length} PWA assets for Next.js`}async generateSpecificFiles(e){if(!this.options.enabled){this.logger.debug("PWA disabled, skipping generation");return}this.options.generateManifest&&await this.generatePWAManifest(e),this.options.generateServiceWorker&&await this.generateServiceWorker(e),await this.generateAPIHandler(e)}async generatePWAManifest(e){let r=this.discovery.generateManifestContent(e);this.writeGeneratedFile(this.options.manifestPath,r,"PWA manifest")}async generateServiceWorker(e){let r=this.options.workbox||{},s=[];if(this.options.discoverBuildAssets!==!1){let n=await this.discovery.discoverNextBuildAssets(".next");s=this.discovery.generatePrecacheManifest(n,r.manifestTransform)}let i=this.discovery.generateServiceWorkerContent(e,{...r,precacheManifest:s});this.writeGeneratedFile(this.options.serviceWorkerPath,i,"service worker")}createNextConfig(){return this.options.enabled?(e={})=>(this.logger.debug("Initializing Next.js PWA handler"),{...e,async headers(){let r=e.headers?await e.headers():[],s=this.discovery.getPWAHeaders();return[...r,...s]},webpack:(r,s)=>{let{dev:i,isServer:n,webpack:a}=s;return this.applyViteIgnorePlugin(r,a),!i&&!n&&this._generateFiles(),e.webpack?e.webpack(r,s):r}}):()=>({})}async generatePWA(){return this.generateFiles()}createPWAAPIHandler(){return this.createAPIHandler()}};function An(t={}){return new Ir(t)}import{createRequire as Hh}from"node:module";function _n(t,e="unknown"){try{let r=/export\s+const\s+meta\s*[^=]*=\s*(\{[\s\S]*?\});/,s=t.match(r);if(!s)return null;let i=s[1];i=i.replace(/icon:\s*<(\w+)[\s\/][^>]*\/?>/g,(c,h)=>`icon: '${h}'`);let n=/(?:export\s+)?const\s+(\w+)\s*=\s*['"]([^'"]+)['"]/g;return[...t.matchAll(n)].forEach(c=>{let h=c[1],f=c[2];i=i.replace(new RegExp(`\\b${h}\\b`,"g"),`'${f}'`)}),Function(`return ${i}`)()}catch{return null}}var dt=null,Nn=null;function qh(t){let r=(t.split("/").pop()?.replace(/\.tsx?$/,"")||"Component").replace(/[^a-zA-Z0-9]/g,"");return r.charAt(0).toUpperCase()+r.slice(1)}var tt=class extends Q{constructor(e,r={}){super(e,{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(e){let r=this.pathResolver.getAppRoot(),s=process.env.DNDEV_BUILD_ID;if(dt&&Nn===s)return this.logger.debug("Using cached route discovery results"),this.routes=dt.routes,this.errors=dt.errors,this.source=dt.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.verbose||this.options.debug){let i=e?.consumerFiles?.length||0;if(this.logger.info(`\u{1F50D} Route discovery: Scanning ${i} files in ${r}`),this.options.debug){let n=await this._getPatterns();this.logger.debug(`Patterns: ${JSON.stringify(n)}`)}}return await this._performAutoDiscovery(e,r),(this.options.verbose||this.options.debug)&&(this.logger.info(`\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/")),dt={routes:this.routes,errors:this.errors,source:this.source},Nn=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(e=!1){return await this.discover(e)}getRoutes(){return this.cache?.routes||[]}async _performAutoDiscovery(e,r){let{consumerFiles:s}=e,i=await this._batchProcessFiles(s,h=>this._analyzePageFile(h,r)),n=await this._scanAdditionalPatterns(r),a=await this._batchProcessFiles(n,h=>this._analyzePageFile(h,r)),o=[...i,...a];this.logger.debug(`Auto-discovering from ${s.length} app + ${n.length} additional files`),this.routes=o.filter(h=>h.path==="home"||h.path==="/home"?(this.logger.debug(`Filtered reserved route: ${h.path} - Use root "/" instead (${h.file})`),!1):!0);let c=new Map;for(let h of this.routes){let f=h.path;if(c.has(f)){let g=c.get(f);throw new Error(`Route conflict: Multiple routes found for path '${f}'. Routes: ${g.file} and ${h.file}. Use PageMeta route override to specify unique paths. Example: export const meta: PageMeta = { route: '/custom-path' };`)}c.set(f,h)}this.logger.debug(`Auto-discovered ${this.routes.length} routes from ${s.length+n.length} files`)}async _scanAdditionalPatterns(e){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(e,r){let s=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!s)return null;let i=e.relativePath,n="/src/"+i.replace(/\\/g,"/");n=n.replace(/src\/src\//g,"src/").replace(/src\/src\//g,"src/");let a=this._extractMetaExport(s,e.absolutePath),o=qh(n),h=o===it.HOMEPAGE_COMPONENT?it.HOMEPAGE_PATH:this._resolveRoutePath(a,i,e.absolutePath),f=this._extractPageMeta(i,s),{entity:g,action:m,...p}=a||{};return{path:h,component:o,importPath:n,auth:a?.auth||!1,meta:{...f,...p,entity:f.entity,action:f.action},metaExport:a,file:i}}_extractMetaExport(e,r){try{let s=_n(e,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(e){let r=e.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(e,r,s){if(!e?.route)return this._generateRoutePath(r);if(typeof e.route=="string"){let i=e.route.trim();return i==="/"?"/":(i=i.replace(/\/+/g,"/"),i.startsWith("/")||(i="/"+i),i)}if(typeof e.route=="object"&&e.route!==null){let i=this._generateRoutePath(r),n=e.route.params;if(Array.isArray(n)&&n.length>0){let a=n.map(o=>`:${o}`).join("/");return`${i}/${a}`}return i}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(e,r){let s=e.split("/").pop()?.replace(".tsx","")||"",i=s.replace(/Page$/,"");i=i.replace(/([A-Z])/g," $1").trim(),i=i.charAt(0).toUpperCase()+i.slice(1);let n=e.split("/"),a=null,o=null;return n.length>1&&(a=n[n.length-2],s.includes("List")?o="list":s.includes("Form")||s.includes("Create")||s.includes("Edit")?o="form":(s.includes("Detail")||s.includes("View"))&&(o="detail")),{title:i,entity:a,action:o,file:e}}};function Gh(t,e,r="configuration-error",s={}){let i=`[${t}] ${e}`,n=new Error(i);return n.code=r,n.pluginName=t,n.context=s,n}function In(t,e,r,s={}){return Gh(t,`Required resource missing: ${e}. ${r}`,"missing-required-resource",Object.assign({resourceName:e},s))}import{readFileSync as od}from"node:fs";import{join as cd}from"node:path";function Fn(t){return t?.languages||t?.supportedLanguages||["en"]}function Cn(t){return t?.fallback||t?.fallbackLanguage||"en"}var Fr=class extends G{constructor(e={}){super(tt,e)}getHandlerDefaults(){return{routingMode:"app",generateMiddleware:!0,generateAppPages:!0,middlewarePath:De.next.middleware,manifestPath:De.next.routeManifest}}createDiscovery(e){return new e(this.pathResolver,this.options)}getHandlerName(){return"Route"}logDiscoveryResults(e){let r=e.routes||[],s=r.filter(n=>n.auth&&n.auth.required).length,i=r.length;this.logger.info(`\u{1F6E3}\uFE0F Routes: ${i} found${s>0?`, ${s} are authguarded`:""}`)}async getDiscoveryData(){return await this.discovery.discoverRoutes()}getAPIRewrites(){return{beforeFiles:[],afterFiles:[{source:"/api/routes",destination:"/api/routes/route"}],fallback:[]}}formatAPIResponse(e){return{routes:e.routes,source:e.source,totalRoutes:e.routes.length,timestamp:e.timestamp}}createManifestContent(e){return{routes:e.routes.map(r=>({path:r.path,auth:r.auth,meta:r.meta})),source:e.source,totalRoutes:e.routes.length,generatedAt:new Date().toISOString(),routingMode:this.options.routingMode}}getGenerationSummary(e){return`${e.routes.length} routes for Next.js ${this.options.routingMode} router`}generateConfigContent(e){let r=e.routes||[],s={totalRoutes:r.length,authRequired:r.filter(i=>i.auth&&i.auth.required).length,publicRoutes:r.filter(i=>!i.auth||i.auth===!1).length,source:e.source,generatedAt:new Date().toISOString()};return`// Auto-generated DnDev config by @donotdev/config
|
|
238
|
+
`}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(e=".next"){let r=this.pathResolver.resolveAppPath(`${e}/static`),s=this.pathResolver.resolveAppPath(`${e}/static/chunks`),i=this.pathResolver.resolveAppPath(`${e}/static/css`),n=[];try{let a=[`${r}/**/*.{js,css,woff2,woff,ttf,eot}`,`${s}/**/*.{js,css}`,`${i}/**/*.css`];for(let o of a){let c=await this.pathResolver.findFiles(this.pathResolver.getAppRoot(),o.replace(this.pathResolver.getAppRoot(),""),{onlyFiles:!0});for(let h of c){let f=this.pathResolver.getRelativePath(h);if(f.startsWith(`${e}/static/`)){let g=`/_next/${f.replace(`${e}/static/`,"")}`;n.push({url:g,revision:null})}}}}catch(a){this.logger?.warn(`Failed to discover Next.js build assets: ${a.message}`)}return n}generatePrecacheManifest(e=[],r=null){let s=e;return r&&typeof r=="function"&&(s=r(s)),s}async discoverPWAAssets(e=!1){return await this.discover(e)}getPWAAssets(){return this.cache?.assets||[]}getPWAManifest(){return this.cache?.manifest||this._getDefaultManifest()}};var Ir=class extends G{constructor(e={}){super(Mt,e)}getHandlerDefaults(){return{enabled:!1,manifestPath:"public/manifest.json",serviceWorkerPath:"public/sw.js",workboxPath:"public/workbox-*.js",generateServiceWorker:!0,generateManifest:!0}}createDiscovery(e){let r=this.options.assetData||_r.data;return new e(this.pathResolver,{...this.options,assetData:r})}getHandlerName(){return"PWA"}async getDiscoveryData(){return await this.discovery.discoverPWAAssets()}getAPIRewrites(){return this.options.enabled?this.discovery.getPWARewrites():{beforeFiles:[],afterFiles:[],fallback:[]}}formatAPIResponse(e){return{assets:e.assets,manifest:e.manifest,totalAssets:e.assets.length,timestamp:e.timestamp}}createManifestContent(e){return{assets:e.assets.map(r=>({type:r.type,path:r.path,size:r.size})),manifest:e.manifest,totalAssets:e.assets.length,generatedAt:new Date().toISOString()}}getGenerationSummary(e){return`${e.assets.length} PWA assets for Next.js`}async generateSpecificFiles(e){if(!this.options.enabled){this.logger.debug("PWA disabled, skipping generation");return}this.options.generateManifest&&await this.generatePWAManifest(e),this.options.generateServiceWorker&&await this.generateServiceWorker(e),await this.generateAPIHandler(e)}async generatePWAManifest(e){let r=this.discovery.generateManifestContent(e);this.writeGeneratedFile(this.options.manifestPath,r,"PWA manifest")}async generateServiceWorker(e){let r=this.options.workbox||{},s=[];if(this.options.discoverBuildAssets!==!1){let n=await this.discovery.discoverNextBuildAssets(".next");s=this.discovery.generatePrecacheManifest(n,r.manifestTransform)}let i=this.discovery.generateServiceWorkerContent(e,{...r,precacheManifest:s});this.writeGeneratedFile(this.options.serviceWorkerPath,i,"service worker")}createNextConfig(){return this.options.enabled?(e={})=>(this.logger.debug("Initializing Next.js PWA handler"),{...e,async headers(){let r=e.headers?await e.headers():[],s=this.discovery.getPWAHeaders();return[...r,...s]},webpack:(r,s)=>{let{dev:i,isServer:n,webpack:a}=s;return this.applyViteIgnorePlugin(r,a),!i&&!n&&this._generateFiles(),e.webpack?e.webpack(r,s):r}}):()=>({})}async generatePWA(){return this.generateFiles()}createPWAAPIHandler(){return this.createAPIHandler()}};function An(t={}){return new Ir(t)}import{createRequire as Hh}from"node:module";function _n(t,e="unknown"){try{let r=/export\s+const\s+meta\s*[^=]*=\s*(\{[\s\S]*?\});/,s=t.match(r);if(!s)return null;let i=s[1];i=i.replace(/icon:\s*<(\w+)[\s\/][^>]*\/?>/g,(c,h)=>`icon: '${h}'`);let n=/(?:export\s+)?const\s+(\w+)\s*=\s*['"]([^'"]+)['"]/g;return[...t.matchAll(n)].forEach(c=>{let h=c[1],f=c[2];i=i.replace(new RegExp(`\\b${h}\\b`,"g"),`'${f}'`)}),Function(`return ${i}`)()}catch{return null}}var dt=null,Nn=null;function qh(t){let r=(t.split("/").pop()?.replace(/\.tsx?$/,"")||"Component").replace(/[^a-zA-Z0-9]/g,"");return r.charAt(0).toUpperCase()+r.slice(1)}var tt=class extends Q{constructor(e,r={}){super(e,{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(e){let r=this.pathResolver.getAppRoot(),s=process.env.DNDEV_BUILD_ID;if(dt&&Nn===s)return this.logger.debug("Using cached route discovery results"),this.routes=dt.routes,this.errors=dt.errors,this.source=dt.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 i=e?.consumerFiles?.length||0;this.logger.debug(`\u{1F50D} Route discovery: Scanning ${i} files in ${r}`);let n=await this._getPatterns();this.logger.debug(`Patterns: ${JSON.stringify(n)}`)}return await this._performAutoDiscovery(e,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/"),dt={routes:this.routes,errors:this.errors,source:this.source},Nn=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(e=!1){return await this.discover(e)}getRoutes(){return this.cache?.routes||[]}async _performAutoDiscovery(e,r){let{consumerFiles:s}=e,i=await this._batchProcessFiles(s,h=>this._analyzePageFile(h,r)),n=await this._scanAdditionalPatterns(r),a=await this._batchProcessFiles(n,h=>this._analyzePageFile(h,r)),o=[...i,...a];this.logger.debug(`Auto-discovering from ${s.length} app + ${n.length} additional files`),this.routes=o.filter(h=>h.path==="home"||h.path==="/home"?(this.logger.debug(`Filtered reserved route: ${h.path} - Use root "/" instead (${h.file})`),!1):!0);let c=new Map;for(let h of this.routes){let f=h.path;if(c.has(f)){let g=c.get(f);throw new Error(`Route conflict: Multiple routes found for path '${f}'. Routes: ${g.file} and ${h.file}. Use PageMeta route override to specify unique paths. Example: export const meta: PageMeta = { route: '/custom-path' };`)}c.set(f,h)}this.logger.debug(`Auto-discovered ${this.routes.length} routes from ${s.length+n.length} files`)}async _scanAdditionalPatterns(e){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(e,r){let s=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!s)return null;let i=e.relativePath,n="/src/"+i.replace(/\\/g,"/");n=n.replace(/src\/src\//g,"src/").replace(/src\/src\//g,"src/");let a=this._extractMetaExport(s,e.absolutePath),o=qh(n),h=o===it.HOMEPAGE_COMPONENT?it.HOMEPAGE_PATH:this._resolveRoutePath(a,i,e.absolutePath),f=this._extractPageMeta(i,s),{entity:g,action:m,...p}=a||{};return{path:h,component:o,importPath:n,auth:a?.auth||!1,meta:{...f,...p,entity:f.entity,action:f.action},metaExport:a,file:i}}_extractMetaExport(e,r){try{let s=_n(e,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(e){let r=e.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(e,r,s){if(!e?.route)return this._generateRoutePath(r);if(typeof e.route=="string"){let i=e.route.trim();return i==="/"?"/":(i=i.replace(/\/+/g,"/"),i.startsWith("/")||(i="/"+i),i)}if(typeof e.route=="object"&&e.route!==null){let i=this._generateRoutePath(r),n=e.route.params;if(Array.isArray(n)&&n.length>0){let a=n.map(o=>`:${o}`).join("/");return`${i}/${a}`}return i}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(e,r){let s=e.split("/").pop()?.replace(".tsx","")||"",i=s.replace(/Page$/,"");i=i.replace(/([A-Z])/g," $1").trim(),i=i.charAt(0).toUpperCase()+i.slice(1);let n=e.split("/"),a=null,o=null;return n.length>1&&(a=n[n.length-2],s.includes("List")?o="list":s.includes("Form")||s.includes("Create")||s.includes("Edit")?o="form":(s.includes("Detail")||s.includes("View"))&&(o="detail")),{title:i,entity:a,action:o,file:e}}};function Gh(t,e,r="configuration-error",s={}){let i=`[${t}] ${e}`,n=new Error(i);return n.code=r,n.pluginName=t,n.context=s,n}function In(t,e,r,s={}){return Gh(t,`Required resource missing: ${e}. ${r}`,"missing-required-resource",Object.assign({resourceName:e},s))}import{readFileSync as od}from"node:fs";import{join as cd}from"node:path";function Fn(t){return t?.languages||t?.supportedLanguages||["en"]}function Cn(t){return t?.fallback||t?.fallbackLanguage||"en"}var Fr=class extends G{constructor(e={}){super(tt,e)}getHandlerDefaults(){return{routingMode:"app",generateMiddleware:!0,generateAppPages:!0,middlewarePath:De.next.middleware,manifestPath:De.next.routeManifest}}createDiscovery(e){return new e(this.pathResolver,this.options)}getHandlerName(){return"Route"}logDiscoveryResults(e){let r=e.routes||[],s=r.filter(n=>n.auth&&n.auth.required).length,i=r.length;this.logger.info(`\u{1F6E3}\uFE0F Routes: ${i} found${s>0?`, ${s} are authguarded`:""}`)}async getDiscoveryData(){return await this.discovery.discoverRoutes()}getAPIRewrites(){return{beforeFiles:[],afterFiles:[{source:"/api/routes",destination:"/api/routes/route"}],fallback:[]}}formatAPIResponse(e){return{routes:e.routes,source:e.source,totalRoutes:e.routes.length,timestamp:e.timestamp}}createManifestContent(e){return{routes:e.routes.map(r=>({path:r.path,auth:r.auth,meta:r.meta})),source:e.source,totalRoutes:e.routes.length,generatedAt:new Date().toISOString(),routingMode:this.options.routingMode}}getGenerationSummary(e){return`${e.routes.length} routes for Next.js ${this.options.routingMode} router`}generateConfigContent(e){let r=e.routes||[],s={totalRoutes:r.length,authRequired:r.filter(i=>i.auth&&i.auth.required).length,publicRoutes:r.filter(i=>!i.auth||i.auth===!1).length,source:e.source,generatedAt:new Date().toISOString()};return`// Auto-generated DnDev config by @donotdev/config
|
|
239
239
|
// Generated at: ${new Date().toISOString()}
|
|
240
240
|
// Populates _DNDEV_CONFIG_.routes with discovery results
|
|
241
241
|
|