@equinor/fusion-framework-cli 15.7.2-next.1 → 15.7.2-next.2

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/bin/build/bin.mjs CHANGED
@@ -1 +1 @@
1
- import{loadConfigFromFile as e,mergeConfig as t,build as r,loadEnv as n}from"vite";import i from"chalk";import o from"vite-tsconfig-paths";import{dirname as s,resolve as a,basename as c,extname as l,relative as u}from"node:path";import{readPackageUp as f}from"read-package-up";import d,{fileURLToPath as p}from"node:url";import h from"node:module";import m from"util";import{accessSync as g,constants as v,readFileSync as y,statSync as E,existsSync as b,mkdirSync as w,writeFileSync as I}from"node:fs";import{importConfig as L,FileNotFoundError as S}from"@equinor/fusion-imports";import C from"deepmerge";import{reactRouterPlugin as _}from"@equinor/fusion-framework-vite-plugin-react-router";import{rawImportsPlugin as D}from"@equinor/fusion-framework-vite-plugin-raw-imports";import P from"node:assert";import{execSync as N}from"node:child_process";import{coerce as O,SemVer as A,satisfies as $,valid as R}from"semver";import T,{z as x}from"zod";import k from"fs";import F from"path";import U from"zlib";import B from"crypto";import{stat as M,mkdir as G}from"node:fs/promises";import j from"ora";import{processServices as z,createDevServer as H}from"@equinor/fusion-framework-dev-server";import{enableAzureIdentityAuth as q}from"@equinor/fusion-framework-module-azure-identity";function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W,Z,K,Y;function X(){if(Z)return W;Z=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return W=e}function J(){if(Y)return K;Y=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return K={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}var Q,ee,te,re,ne,ie,oe,se,ae,ce,le,ue,fe,de={exports:{}};function pe(){return Q||(Q=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=J(),o=X(),s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],u=t.t={};let f=0;const d="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[d,n]],h=(e,t,r)=>{const n=(e=>{for(const[t,r]of p)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=f++;o(e,i,t),u[e]=i,c[i]=t,l[i]=n,s[i]=new RegExp(t,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};h("NUMERICIDENTIFIER","0|[1-9]\\d*"),h("NUMERICIDENTIFIERLOOSE","\\d+"),h("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),h("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASEIDENTIFIER",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h("BUILDIDENTIFIER",`${d}+`),h("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h("FULL",`^${c[u.FULLPLAIN]}$`),h("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h("LOOSE",`^${c[u.LOOSEPLAIN]}$`),h("GTLT","((?:<|>)?=?)"),h("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),h("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),h("COERCERTL",c[u.COERCE],!0),h("COERCERTLFULL",c[u.COERCEFULL],!0),h("LONETILDE","(?:~>?)"),h("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",h("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h("LONECARET","(?:\\^)"),h("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",h("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",h("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h("STAR","(<|>)?=?\\s*\\*"),h("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),h("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(de,de.exports)),de.exports}function he(){if(oe)return ie;oe=1;const e=X(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=J(),{safeRe:n,t:i}=pe(),o=function(){if(te)return ee;te=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return ee=r=>r?"object"!=typeof r?e:r:t}(),{compareIdentifiers:s}=function(){if(ne)return re;ne=1;const e=/^[0-9]+$/,t=(t,r)=>{if("number"==typeof t&&"number"==typeof r)return t===r?0:t<r?-1:1;const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:t<r?-1:1};return re={compareIdentifiers:t,rcompareIdentifiers:(e,r)=>t(r,e)}}();class a{constructor(s,c){if(c=o(c),s instanceof a){if(s.loose===!!c.loose&&s.includePrerelease===!!c.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",s,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const l=s.trim().match(c.loose?n[i.LOOSE]:n[i.FULL]);if(!l)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");l[4]?this.prerelease=l[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(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(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=t.prerelease[r];if(e("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}compareBuild(t){t instanceof a||(t=new a(t,this.options));let r=0;do{const n=this.build[r],i=t.build[r];if(e("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];if(!1===r&&(n=[t]),((e,t)=>{const r=t.split(".");if(r.length>e.length)return!1;for(let t=0;t<r.length;t++)if(0!==s(e[t],r[t]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=n)}else 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}}return ie=a}function me(){if(ae)return se;ae=1;const e=he();return se=(t,r,n=!1)=>{if(t instanceof e)return t;try{return new e(t,r)}catch(e){if(!n)return null;throw e}},se}var ge,ve,ye,Ee,be,we,Ie,Le,Se,Ce,_e=["0BSD","3D-Slicer-1.0","AAL","ADSL","AFL-1.1","AFL-1.2","AFL-2.0","AFL-2.1","AFL-3.0","AGPL-1.0-only","AGPL-1.0-or-later","AGPL-3.0-only","AGPL-3.0-or-later","AMD-newlib","AMDPLPA","AML","AML-glslang","AMPAS","ANTLR-PD","ANTLR-PD-fallback","APAFML","APL-1.0","APSL-1.0","APSL-1.1","APSL-1.2","APSL-2.0","ASWF-Digital-Assets-1.0","ASWF-Digital-Assets-1.1","Abstyles","AdaCore-doc","Adobe-2006","Adobe-Display-PostScript","Adobe-Glyph","Adobe-Utopia","Afmparse","Aladdin","Apache-1.0","Apache-1.1","Apache-2.0","App-s2p","Arphic-1999","Artistic-1.0","Artistic-1.0-Perl","Artistic-1.0-cl8","Artistic-2.0","Artistic-dist","Aspell-RU","BSD-1-Clause","BSD-2-Clause","BSD-2-Clause-Darwin","BSD-2-Clause-Patent","BSD-2-Clause-Views","BSD-2-Clause-first-lines","BSD-2-Clause-pkgconf-disclaimer","BSD-3-Clause","BSD-3-Clause-Attribution","BSD-3-Clause-Clear","BSD-3-Clause-HP","BSD-3-Clause-LBNL","BSD-3-Clause-Modification","BSD-3-Clause-No-Military-License","BSD-3-Clause-No-Nuclear-License","BSD-3-Clause-No-Nuclear-License-2014","BSD-3-Clause-No-Nuclear-Warranty","BSD-3-Clause-Open-MPI","BSD-3-Clause-Sun","BSD-3-Clause-acpica","BSD-3-Clause-flex","BSD-4-Clause","BSD-4-Clause-Shortened","BSD-4-Clause-UC","BSD-4.3RENO","BSD-4.3TAHOE","BSD-Advertising-Acknowledgement","BSD-Attribution-HPND-disclaimer","BSD-Inferno-Nettverk","BSD-Protection","BSD-Source-Code","BSD-Source-beginning-file","BSD-Systemics","BSD-Systemics-W3Works","BSL-1.0","BUSL-1.1","Baekmuk","Bahyph","Barr","Beerware","BitTorrent-1.0","BitTorrent-1.1","Bitstream-Charter","Bitstream-Vera","BlueOak-1.0.0","Boehm-GC","Boehm-GC-without-fee","Borceux","Brian-Gladman-2-Clause","Brian-Gladman-3-Clause","C-UDA-1.0","CAL-1.0","CAL-1.0-Combined-Work-Exception","CATOSL-1.1","CC-BY-1.0","CC-BY-2.0","CC-BY-2.5","CC-BY-2.5-AU","CC-BY-3.0","CC-BY-3.0-AT","CC-BY-3.0-AU","CC-BY-3.0-DE","CC-BY-3.0-IGO","CC-BY-3.0-NL","CC-BY-3.0-US","CC-BY-4.0","CC-BY-NC-1.0","CC-BY-NC-2.0","CC-BY-NC-2.5","CC-BY-NC-3.0","CC-BY-NC-3.0-DE","CC-BY-NC-4.0","CC-BY-NC-ND-1.0","CC-BY-NC-ND-2.0","CC-BY-NC-ND-2.5","CC-BY-NC-ND-3.0","CC-BY-NC-ND-3.0-DE","CC-BY-NC-ND-3.0-IGO","CC-BY-NC-ND-4.0","CC-BY-NC-SA-1.0","CC-BY-NC-SA-2.0","CC-BY-NC-SA-2.0-DE","CC-BY-NC-SA-2.0-FR","CC-BY-NC-SA-2.0-UK","CC-BY-NC-SA-2.5","CC-BY-NC-SA-3.0","CC-BY-NC-SA-3.0-DE","CC-BY-NC-SA-3.0-IGO","CC-BY-NC-SA-4.0","CC-BY-ND-1.0","CC-BY-ND-2.0","CC-BY-ND-2.5","CC-BY-ND-3.0","CC-BY-ND-3.0-DE","CC-BY-ND-4.0","CC-BY-SA-1.0","CC-BY-SA-2.0","CC-BY-SA-2.0-UK","CC-BY-SA-2.1-JP","CC-BY-SA-2.5","CC-BY-SA-3.0","CC-BY-SA-3.0-AT","CC-BY-SA-3.0-DE","CC-BY-SA-3.0-IGO","CC-BY-SA-4.0","CC-PDDC","CC-PDM-1.0","CC-SA-1.0","CC0-1.0","CDDL-1.0","CDDL-1.1","CDL-1.0","CDLA-Permissive-1.0","CDLA-Permissive-2.0","CDLA-Sharing-1.0","CECILL-1.0","CECILL-1.1","CECILL-2.0","CECILL-2.1","CECILL-B","CECILL-C","CERN-OHL-1.1","CERN-OHL-1.2","CERN-OHL-P-2.0","CERN-OHL-S-2.0","CERN-OHL-W-2.0","CFITSIO","CMU-Mach","CMU-Mach-nodoc","CNRI-Jython","CNRI-Python","CNRI-Python-GPL-Compatible","COIL-1.0","CPAL-1.0","CPL-1.0","CPOL-1.02","CUA-OPL-1.0","Caldera","Caldera-no-preamble","Catharon","ClArtistic","Clips","Community-Spec-1.0","Condor-1.1","Cornell-Lossless-JPEG","Cronyx","Crossword","CryptoSwift","CrystalStacker","Cube","D-FSL-1.0","DEC-3-Clause","DL-DE-BY-2.0","DL-DE-ZERO-2.0","DOC","DRL-1.0","DRL-1.1","DSDP","DocBook-DTD","DocBook-Schema","DocBook-Stylesheet","DocBook-XML","Dotseqn","ECL-1.0","ECL-2.0","EFL-1.0","EFL-2.0","EPICS","EPL-1.0","EPL-2.0","EUDatagrid","EUPL-1.0","EUPL-1.1","EUPL-1.2","Elastic-2.0","Entessa","ErlPL-1.1","Eurosym","FBM","FDK-AAC","FSFAP","FSFAP-no-warranty-disclaimer","FSFUL","FSFULLR","FSFULLRSD","FSFULLRWD","FSL-1.1-ALv2","FSL-1.1-MIT","FTL","Fair","Ferguson-Twofish","Frameworx-1.0","FreeBSD-DOC","FreeImage","Furuseth","GCR-docs","GD","GFDL-1.1-invariants-only","GFDL-1.1-invariants-or-later","GFDL-1.1-no-invariants-only","GFDL-1.1-no-invariants-or-later","GFDL-1.1-only","GFDL-1.1-or-later","GFDL-1.2-invariants-only","GFDL-1.2-invariants-or-later","GFDL-1.2-no-invariants-only","GFDL-1.2-no-invariants-or-later","GFDL-1.2-only","GFDL-1.2-or-later","GFDL-1.3-invariants-only","GFDL-1.3-invariants-or-later","GFDL-1.3-no-invariants-only","GFDL-1.3-no-invariants-or-later","GFDL-1.3-only","GFDL-1.3-or-later","GL2PS","GLWTPL","GPL-1.0-only","GPL-1.0-or-later","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0-only","GPL-3.0-or-later","Game-Programming-Gems","Giftware","Glide","Glulxe","Graphics-Gems","Gutmann","HDF5","HIDAPI","HP-1986","HP-1989","HPND","HPND-DEC","HPND-Fenneberg-Livingston","HPND-INRIA-IMAG","HPND-Intel","HPND-Kevlin-Henney","HPND-MIT-disclaimer","HPND-Markus-Kuhn","HPND-Netrek","HPND-Pbmplus","HPND-UC","HPND-UC-export-US","HPND-doc","HPND-doc-sell","HPND-export-US","HPND-export-US-acknowledgement","HPND-export-US-modify","HPND-export2-US","HPND-merchantability-variant","HPND-sell-MIT-disclaimer-xserver","HPND-sell-regexpr","HPND-sell-variant","HPND-sell-variant-MIT-disclaimer","HPND-sell-variant-MIT-disclaimer-rev","HTMLTIDY","HaskellReport","Hippocratic-2.1","IBM-pibs","ICU","IEC-Code-Components-EULA","IJG","IJG-short","IPA","IPL-1.0","ISC","ISC-Veillard","ImageMagick","Imlib2","Info-ZIP","Inner-Net-2.0","InnoSetup","Intel","Intel-ACPI","Interbase-1.0","JPL-image","JPNIC","JSON","Jam","JasPer-2.0","Kastrup","Kazlib","Knuth-CTAN","LAL-1.2","LAL-1.3","LGPL-2.0-only","LGPL-2.0-or-later","LGPL-2.1-only","LGPL-2.1-or-later","LGPL-3.0-only","LGPL-3.0-or-later","LGPLLR","LOOP","LPD-document","LPL-1.0","LPL-1.02","LPPL-1.0","LPPL-1.1","LPPL-1.2","LPPL-1.3a","LPPL-1.3c","LZMA-SDK-9.11-to-9.20","LZMA-SDK-9.22","Latex2e","Latex2e-translated-notice","Leptonica","LiLiQ-P-1.1","LiLiQ-R-1.1","LiLiQ-Rplus-1.1","Libpng","Linux-OpenIB","Linux-man-pages-1-para","Linux-man-pages-copyleft","Linux-man-pages-copyleft-2-para","Linux-man-pages-copyleft-var","Lucida-Bitmap-Fonts","MIPS","MIT","MIT-0","MIT-CMU","MIT-Click","MIT-Festival","MIT-Khronos-old","MIT-Modern-Variant","MIT-Wu","MIT-advertising","MIT-enna","MIT-feh","MIT-open-group","MIT-testregex","MITNFA","MMIXware","MPEG-SSG","MPL-1.0","MPL-1.1","MPL-2.0","MPL-2.0-no-copyleft-exception","MS-LPL","MS-PL","MS-RL","MTLL","Mackerras-3-Clause","Mackerras-3-Clause-acknowledgment","MakeIndex","Martin-Birgmeier","McPhee-slideshow","Minpack","MirOS","Motosoto","MulanPSL-1.0","MulanPSL-2.0","Multics","Mup","NAIST-2003","NASA-1.3","NBPL-1.0","NCBI-PD","NCGL-UK-2.0","NCL","NCSA","NGPL","NICTA-1.0","NIST-PD","NIST-PD-fallback","NIST-Software","NLOD-1.0","NLOD-2.0","NLPL","NOSL","NPL-1.0","NPL-1.1","NPOSL-3.0","NRL","NTIA-PD","NTP","NTP-0","Naumen","NetCDF","Newsletr","Nokia","Noweb","O-UDA-1.0","OAR","OCCT-PL","OCLC-2.0","ODC-By-1.0","ODbL-1.0","OFFIS","OFL-1.0","OFL-1.0-RFN","OFL-1.0-no-RFN","OFL-1.1","OFL-1.1-RFN","OFL-1.1-no-RFN","OGC-1.0","OGDL-Taiwan-1.0","OGL-Canada-2.0","OGL-UK-1.0","OGL-UK-2.0","OGL-UK-3.0","OGTSL","OLDAP-1.1","OLDAP-1.2","OLDAP-1.3","OLDAP-1.4","OLDAP-2.0","OLDAP-2.0.1","OLDAP-2.1","OLDAP-2.2","OLDAP-2.2.1","OLDAP-2.2.2","OLDAP-2.3","OLDAP-2.4","OLDAP-2.5","OLDAP-2.6","OLDAP-2.7","OLDAP-2.8","OLFL-1.3","OML","OPL-1.0","OPL-UK-3.0","OPUBL-1.0","OSET-PL-2.1","OSL-1.0","OSL-1.1","OSL-2.0","OSL-2.1","OSL-3.0","OpenPBS-2.3","OpenSSL","OpenSSL-standalone","OpenVision","PADL","PDDL-1.0","PHP-3.0","PHP-3.01","PPL","PSF-2.0","Parity-6.0.0","Parity-7.0.0","Pixar","Plexus","PolyForm-Noncommercial-1.0.0","PolyForm-Small-Business-1.0.0","PostgreSQL","Python-2.0","Python-2.0.1","QPL-1.0","QPL-1.0-INRIA-2004","Qhull","RHeCos-1.1","RPL-1.1","RPL-1.5","RPSL-1.0","RSA-MD","RSCPL","Rdisc","Ruby","Ruby-pty","SAX-PD","SAX-PD-2.0","SCEA","SGI-B-1.0","SGI-B-1.1","SGI-B-2.0","SGI-OpenGL","SGP4","SHL-0.5","SHL-0.51","SISSL","SISSL-1.2","SL","SMAIL-GPL","SMLNJ","SMPPL","SNIA","SOFA","SPL-1.0","SSH-OpenSSH","SSH-short","SSLeay-standalone","SSPL-1.0","SUL-1.0","SWL","Saxpath","SchemeReport","Sendmail","Sendmail-8.23","Sendmail-Open-Source-1.1","SimPL-2.0","Sleepycat","Soundex","Spencer-86","Spencer-94","Spencer-99","SugarCRM-1.1.3","Sun-PPP","Sun-PPP-2000","SunPro","Symlinks","TAPR-OHL-1.0","TCL","TCP-wrappers","TGPPL-1.0","TMate","TORQUE-1.1","TOSL","TPDL","TPL-1.0","TTWL","TTYP0","TU-Berlin-1.0","TU-Berlin-2.0","TermReadKey","ThirdEye","TrustedQSL","UCAR","UCL-1.0","UMich-Merit","UPL-1.0","URT-RLE","Ubuntu-font-1.0","Unicode-3.0","Unicode-DFS-2015","Unicode-DFS-2016","Unicode-TOU","UnixCrypt","Unlicense","Unlicense-libtelnet","Unlicense-libwhirlpool","VOSTROM","VSL-1.0","Vim","W3C","W3C-19980720","W3C-20150513","WTFPL","Watcom-1.0","Widget-Workshop","Wsuipa","X11","X11-distribute-modifications-variant","X11-swapped","XFree86-1.1","XSkat","Xdebug-1.03","Xerox","Xfig","Xnet","YPL-1.0","YPL-1.1","ZPL-1.1","ZPL-2.0","ZPL-2.1","Zed","Zeeff","Zend-2.0","Zimbra-1.3","Zimbra-1.4","Zlib","any-OSI","any-OSI-perl-modules","bcrypt-Solar-Designer","blessing","bzip2-1.0.6","check-cvs","checkmk","copyleft-next-0.3.0","copyleft-next-0.3.1","curl","cve-tou","diffmark","dtoa","dvipdfm","eGenix","etalab-2.0","fwlw","gSOAP-1.3b","generic-xts","gnuplot","gtkbook","hdparm","iMatix","jove","libpng-1.6.35","libpng-2.0","libselinux-1.0","libtiff","libutil-David-Nugent","lsof","magaz","mailprio","man2html","metamail","mpi-permissive","mpich2","mplus","ngrep","pkgconf","pnmstitch","psfrag","psutils","python-ldap","radvd","snprintf","softSurfer","ssh-keyscan","swrule","threeparttable","ulem","w3m","wwl","xinetd","xkeyboard-config-Zinoviev","xlock","xpp","xzoom","zlib-acknowledgement"],De=["AGPL-1.0","AGPL-3.0","BSD-2-Clause-FreeBSD","BSD-2-Clause-NetBSD","GFDL-1.1","GFDL-1.2","GFDL-1.3","GPL-1.0","GPL-2.0","GPL-2.0-with-GCC-exception","GPL-2.0-with-autoconf-exception","GPL-2.0-with-bison-exception","GPL-2.0-with-classpath-exception","GPL-2.0-with-font-exception","GPL-3.0","GPL-3.0-with-GCC-exception","GPL-3.0-with-autoconf-exception","LGPL-2.0","LGPL-2.1","LGPL-3.0","Net-SNMP","Nunit","StandardML-NJ","bzip2-1.0.5","eCos-2.0","wxWindows"],Pe=["389-exception","Asterisk-exception","Autoconf-exception-2.0","Autoconf-exception-3.0","Autoconf-exception-generic","Autoconf-exception-generic-3.0","Autoconf-exception-macro","Bison-exception-1.24","Bison-exception-2.2","Bootloader-exception","Classpath-exception-2.0","CLISP-exception-2.0","cryptsetup-OpenSSL-exception","DigiRule-FOSS-exception","eCos-exception-2.0","Fawkes-Runtime-exception","FLTK-exception","fmt-exception","Font-exception-2.0","freertos-exception-2.0","GCC-exception-2.0","GCC-exception-2.0-note","GCC-exception-3.1","Gmsh-exception","GNAT-exception","GNOME-examples-exception","GNU-compiler-exception","gnu-javamail-exception","GPL-3.0-interface-exception","GPL-3.0-linking-exception","GPL-3.0-linking-source-exception","GPL-CC-1.0","GStreamer-exception-2005","GStreamer-exception-2008","i2p-gpl-java-exception","KiCad-libraries-exception","LGPL-3.0-linking-exception","libpri-OpenH323-exception","Libtool-exception","Linux-syscall-note","LLGPL","LLVM-exception","LZMA-exception","mif-exception","OCaml-LGPL-linking-exception","OCCT-exception-1.0","OpenJDK-assembly-exception-1.0","openvpn-openssl-exception","PS-or-PDF-font-exception-20170817","QPL-1.0-INRIA-2004-exception","Qt-GPL-exception-1.0","Qt-LGPL-exception-1.1","Qwt-exception-1.0","SANE-exception","SHL-2.0","SHL-2.1","stunnel-exception","SWI-exception","Swift-exception","Texinfo-exception","u-boot-exception-2.0","UBDL-exception","Universal-FOSS-exception-1.0","vsftpd-openssl-exception","WxWindows-exception-3.1","x11vnc-openssl-exception"];function Ne(){if(ve)return ge;ve=1;var e=[].concat(_e).concat(De),t=Pe;return ge=function(r){var n=0;function i(){return n<r.length}function o(e){if(e instanceof RegExp){var t=r.slice(n).match(e);if(t)return n+=t[0].length,t[0]}else if(r.indexOf(e,n)===n)return n+=e.length,e}function s(){o(/[ ]*/)}function a(){return o(/[A-Za-z0-9-.]+/)}function c(){var e=a();if(!e)throw new Error("Expected idstring at offset "+n);return e}function l(){return function(){for(var e,t=["WITH","AND","OR","(",")",":","+"],i=0;i<t.length&&!(e=o(t[i]));i++);if("+"===e&&n>1&&" "===r[n-2])throw new Error("Space before `+`");return e&&{type:"OPERATOR",string:e}}()||function(){if(o("DocumentRef-"))return{type:"DOCUMENTREF",string:c()}}()||function(){if(o("LicenseRef-"))return{type:"LICENSEREF",string:c()}}()||(i=n,s=a(),-1!==e.indexOf(s)?{type:"LICENSE",string:s}:-1!==t.indexOf(s)?{type:"EXCEPTION",string:s}:void(n=i));var i,s}for(var u=[];i()&&(s(),i());){var f=l();if(!f)throw new Error("Unexpected `"+r[n]+"` at offset "+n);u.push(f)}return u}}function Oe(){return Ee?ye:(Ee=1,ye=function(e){var t=0;function r(){return t<e.length}function n(){return r()?e[t]:null}function i(){if(!r())throw new Error;t++}function o(e){var t=n();if(t&&"OPERATOR"===t.type&&e===t.string)return i(),t.string}function s(){var e=n();if(e&&"LICENSE"===e.type){i();var t={license:e.string};o("+")&&(t.plus=!0);var r=function(){if(o("WITH")){var e=n();if(e&&"EXCEPTION"===e.type)return i(),e.string;throw new Error("Expected exception after `WITH`")}}();return r&&(t.exception=r),t}}function a(e,t){return function r(){var n=t();if(n){if(!o(e))return n;var i=r();if(!i)throw new Error("Expected expression");return{left:n,conjunction:e.toLowerCase(),right:i}}}}var c=a("AND",function(){return function(){if(o("(")){var e=l();if(!o(")"))throw new Error("Expected `)`");return e}}()||function(){var e=t,r="",s=n();if("DOCUMENTREF"===s.type&&(i(),r+="DocumentRef-"+s.string+":",!o(":")))throw new Error("Expected `:` after `DocumentRef-...`");if("LICENSEREF"===(s=n()).type)return i(),{license:r+="LicenseRef-"+s.string};t=e}()||s()}),l=a("OR",c),u=l();if(!u||r())throw new Error("Syntax error");return u})}function Ae(){if(we)return be;we=1;var e=Ne(),t=Oe();return be=function(r){return t(e(r))}}function $e(){if(Ce)return Se;Ce=1;var e=Ae(),t=function(){if(Le)return Ie;Le=1;var e=Ae(),t=_e;function r(t){try{return e(t),!0}catch(e){return!1}}function n(e,t){var r=t[0].length-e[0].length;return 0!==r?r:e[0].toUpperCase().localeCompare(t[0].toUpperCase())}var i=[["APGL","AGPL"],["Gpl","GPL"],["GLP","GPL"],["APL","Apache"],["ISD","ISC"],["GLP","GPL"],["IST","ISC"],["Claude","Clause"],[" or later","+"],[" International",""],["GNU","GPL"],["GUN","GPL"],["+",""],["GNU GPL","GPL"],["GNU LGPL","LGPL"],["GNU/GPL","GPL"],["GNU GLP","GPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL"],["GNU Lesser General Public License","LGPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["GNU Lesser General Public License","LGPL-2.1"],["LESSER GENERAL PUBLIC LICENSE","LGPL"],["Lesser General Public License","LGPL"],["LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["Lesser General Public License","LGPL-2.1"],["GNU General Public License","GPL"],["Gnu public license","GPL"],["GNU Public License","GPL"],["GNU GENERAL PUBLIC LICENSE","GPL"],["MTI","MIT"],["Mozilla Public License","MPL"],["Universal Permissive License","UPL"],["WTH","WTF"],["WTFGPL","WTFPL"],["-License",""]].sort(n),o=[function(e){return e.toUpperCase()},function(e){return e.trim()},function(e){return e.replace(/\./g,"")},function(e){return e.replace(/\s+/g,"")},function(e){return e.replace(/\s+/g,"-")},function(e){return e.replace("v","-")},function(e){return e.replace(/,?\s*(\d)/,"-$1")},function(e){return e.replace(/,?\s*(\d)/,"-$1.0")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2.0")},function(e){return e[0].toUpperCase()+e.slice(1)},function(e){return e.replace("/","-")},function(e){return e.replace(/\s*V\s*(\d)/,"-$1").replace(/(\d)$/,"$1.0")},function(e){return-1!==e.indexOf("3.0")?e+"-or-later":e+"-only"},function(e){return e+"only"},function(e){return e.replace(/(\d)$/,"-$1.0")},function(e){return e.replace(/(-| )?(\d)$/,"-$2-Clause")},function(e){return e.replace(/(-| )clause(-| )(\d)/,"-$3-Clause")},function(e){return e.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i,"BSD-3-Clause")},function(e){return e.replace(/\bSimplified(-| )?BSD((-| )License)?/i,"BSD-2-Clause")},function(e){return e.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i,"BSD-2-Clause-$1BSD")},function(e){return e.replace(/\bClear(-| )?BSD((-| )License)?/i,"BSD-3-Clause-Clear")},function(e){return e.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i,"BSD-4-Clause")},function(e){return"CC-"+e},function(e){return"CC-"+e+"-4.0"},function(e){return e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")},function(e){return"CC-"+e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")+"-4.0"}],s=t.map(function(e){var t=/^(.*)-\d+\.\d+$/.exec(e);return t?[t[0],t[1]]:[e,null]}).reduce(function(e,t){var r=t[1];return e[r]=e[r]||[],e[r].push(t[0]),e},{}),a=Object.keys(s).map(function(e){return[e,s[e]]}).filter(function(e){return 1===e[1].length&&null!==e[0]&&"APL"!==e[0]}).map(function(e){return[e[0],e[1][0]]});s=void 0;var c=[["UNLI","Unlicense"],["WTF","WTFPL"],["2 CLAUSE","BSD-2-Clause"],["2-CLAUSE","BSD-2-Clause"],["3 CLAUSE","BSD-3-Clause"],["3-CLAUSE","BSD-3-Clause"],["AFFERO","AGPL-3.0-or-later"],["AGPL","AGPL-3.0-or-later"],["APACHE","Apache-2.0"],["ARTISTIC","Artistic-2.0"],["Affero","AGPL-3.0-or-later"],["BEER","Beerware"],["BOOST","BSL-1.0"],["BSD","BSD-2-Clause"],["CDDL","CDDL-1.1"],["ECLIPSE","EPL-1.0"],["FUCK","WTFPL"],["GNU","GPL-3.0-or-later"],["LGPL","LGPL-3.0-or-later"],["GPLV1","GPL-1.0-only"],["GPL-1","GPL-1.0-only"],["GPLV2","GPL-2.0-only"],["GPL-2","GPL-2.0-only"],["GPL","GPL-3.0-or-later"],["MIT +NO-FALSE-ATTRIBS","MITNFA"],["MIT","MIT"],["MPL","MPL-2.0"],["X11","X11"],["ZLIB","Zlib"]].concat(a).sort(n),l=function(e){for(var t=0;t<o.length;t++){var n=o[t](e).trim();if(n!==e&&r(n))return n}return null},u=function(e){for(var t=e.toUpperCase(),r=0;r<c.length;r++){var n=c[r];if(t.indexOf(n[0])>-1)return n[1]}return null},f=function(e,t){for(var r=0;r<i.length;r++){var n=i[r],o=n[0];if(e.indexOf(o)>-1){var s=t(e.replace(o,n[1]));if(null!==s)return s}}return null};return Ie=function(e,t){var n=void 0===(t=t||{}).upgrade||!!t.upgrade;function i(e){return n?function(e){return-1!==["GPL-1.0","LGPL-1.0","AGPL-1.0","GPL-2.0","LGPL-2.0","AGPL-2.0","LGPL-2.1"].indexOf(e)?e+"-only":-1!==["GPL-1.0+","GPL-2.0+","GPL-3.0+","LGPL-2.0+","LGPL-2.1+","LGPL-3.0+","AGPL-1.0+","AGPL-3.0+"].indexOf(e)?e.replace(/\+$/,"-or-later"):-1!==["GPL-3.0","LGPL-3.0","AGPL-3.0"].indexOf(e)?e+"-or-later":e}(e):e}if("string"!=typeof e||0===e.trim().length)throw Error("Invalid argument. Expected non-empty string.");if(r(e=e.trim()))return i(e);var o=e.replace(/\+$/,"").trim();if(r(o))return i(o);var s=l(e);return null!==s||null!==(s=f(e,function(e){return r(e)?e:l(e)}))||null!==(s=u(e))||null!==(s=f(e,u))?i(s):null}}(),r='license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>"',n=/^SEE LICEN[CS]E IN (.+)$/;function i(e,t){return t.slice(0,e.length)===e}function o(e){if(e.hasOwnProperty("license")){var t=e.license;return i("LicenseRef",t)||i("DocumentRef",t)}return o(e.left)||o(e.right)}return Se=function(i){var s;try{s=e(i)}catch(e){var a;if("UNLICENSED"===i||"UNLICENCED"===i)return{validForOldPackages:!0,validForNewPackages:!0,unlicensed:!0};if(a=n.exec(i))return{validForOldPackages:!0,validForNewPackages:!0,inFile:a[1]};var c={validForOldPackages:!1,validForNewPackages:!1,warnings:[r]};if(0!==i.trim().length){var l=t(i);l&&c.warnings.push('license is similar to the valid expression "'+l+'"')}return c}return o(s)?{validForNewPackages:!1,validForOldPackages:!1,spdx:!0,warnings:[r]}:{validForNewPackages:!0,validForOldPackages:!0,spdx:!0}}}var Re,Te,xe,ke,Fe,Ue,Be,Me,Ge,je,ze,He={};function qe(){if(Re)return He;Re=1;var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tracing=e.metrics=void 0;var t={hasSubscribers:!1};e.metrics=t,e.tracing=t}),r=e(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultPerf=void 0,e.defaultPerf="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date});Object.defineProperty(He,"__esModule",{value:!0}),He.LRUCache=void 0;var n=t(),i=r(),o=()=>n.metrics.hasSubscribers||n.tracing.hasSubscribers,s=new Set,a="object"==typeof process&&process?process:{},c=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),l=e=>c(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?u:null:null,u=class extends Array{constructor(e){super(e),this.fill(0)}},f=class e{heap;length;static#e=!1;static create(t){let r=l(t);if(!r)return[];e.#e=!0;let n=new e(t,r);return e.#e=!1,n}constructor(t,r){if(!e.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},d=class e{#e;#t;#r;#n;#i;#o;#s;#a;get perf(){return this.#a}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#c;#l;#u;#f;#d;#p;#h;#m;#g;#v;#y;#E;#b;#w;#I;#L;#S;#C;#_;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#w,autopurgeTimers:e.#I,sizes:e.#E,keyMap:e.#u,keyList:e.#f,valList:e.#d,next:e.#p,prev:e.#h,get head(){return e.#m},get tail(){return e.#g},free:e.#v,isBackgroundFetch:t=>e.#D(t),backgroundFetch:(t,r,n,i)=>e.#P(t,r,n,i),moveToTail:t=>e.#N(t),indexes:t=>e.#O(t),rindexes:t=>e.#A(t),isStale:t=>e.#$(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#l}get size(){return this.#c}get fetchMethod(){return this.#o}get memoMethod(){return this.#s}get dispose(){return this.#r}get onInsert(){return this.#n}get disposeAfter(){return this.#i}constructor(t){let{max:r=0,ttl:n,ttlResolution:o=1,ttlAutopurge:u,updateAgeOnGet:d,updateAgeOnHas:p,allowStale:h,dispose:m,onInsert:g,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:E,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:I,fetchMethod:L,memoMethod:S,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:_,allowStaleOnFetchRejection:D,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,backgroundFetchSize:O=1,perf:A}=t;if(this.backgroundFetchSize=O,void 0!==A&&"function"!=typeof A?.now)throw new TypeError("perf option must have a now() method if specified");if(this.#a=A??i.defaultPerf,0!==r&&!c(r))throw new TypeError("max option must be a nonnegative integer");let $=r?l(r):Array;if(!$)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=b,this.maxEntrySize=w||this.#t,this.sizeCalculation=I,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("memoMethod must be a function if defined");if(this.#s=S,void 0!==L&&"function"!=typeof L)throw new TypeError("fetchMethod must be a function if specified");if(this.#o=L,this.#S=!!L,this.#u=new Map,this.#f=Array.from({length:r}).fill(void 0),this.#d=Array.from({length:r}).fill(void 0),this.#p=new $(r),this.#h=new $(r),this.#m=0,this.#g=0,this.#v=f.create(r),this.#c=0,this.#l=0,"function"==typeof m&&(this.#r=m),"function"==typeof g&&(this.#n=g),"function"==typeof v?(this.#i=v,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#L=!!this.#r,this.#_=!!this.#n,this.#C=!!this.#i,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!D,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!N,0!==this.maxEntrySize){if(0!==this.#t&&!c(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!_,this.updateAgeOnGet=!!d,this.updateAgeOnHas=!!p,this.ttlResolution=c(o)||0===o?o:1,this.ttlAutopurge=!!u,this.ttl=n||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#T()}if(0===this.#e&&0===this.ttl&&0===this.#t)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t="LRU_CACHE_UNBOUNDED";(e=>!s.has(e))(t)&&(s.add(t),((e,t,r,n)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)})("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#T(){let e=new u(this.#e),t=new u(this.#e);this.#w=e,this.#b=t;let r=this.ttlAutopurge?Array.from({length:this.#e}):void 0;this.#I=r,this.#x=(r,i,o=this.#a.now())=>{t[r]=0!==i?o:0,e[r]=i,n(r,i)},this.#k=r=>{t[r]=0!==e[r]?this.#a.now():0,n(r,e[r])};let n=this.ttlAutopurge?(e,t)=>{if(r?.[e]&&(clearTimeout(r[e]),r[e]=void 0),t&&0!==t&&r){let i=setTimeout(()=>{this.#$(e)?(this.#F(this.#f[e],"expire"),r[e]=void 0):n(e,s(e))},t+1);i.unref&&i.unref(),r[e]=i}}:()=>{};this.#U=(r,n)=>{if(e[n]){let s=e[n],a=t[n];if(!s||!a)return;r.ttl=s,r.start=a,r.now=i||o();let c=r.now-a;r.remainingTTL=s-c}};let i=0,o=()=>{let e=this.#a.now();if(this.ttlResolution>0){i=e;let t=setTimeout(()=>i=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=e=>{let t=this.#u.get(e);return void 0===t?0:s(t)};let s=r=>{let n=e[r],s=t[r];return n&&s?n-((i||o())-s):1/0};this.#$=r=>{let n=t[r],s=e[r];return!!s&&!!n&&(i||o())-n>s}}#k=()=>{};#U=()=>{};#x=()=>{};#$=()=>!1;#R(){let e=new u(this.#e);this.#l=0,this.#E=e,this.#B=t=>{this.#l-=e[t],e[t]=0},this.#M=(e,t,r,n)=>{if(!c(r)){if(this.#D(t))return this.backgroundFetchSize;if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(t,e),!c(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#G=(t,r,n)=>{if(e[t]=r,this.#t){let r=this.#t-e[t];for(;this.#l>r;)this.#j(!0)}this.#l+=e[t],n&&(n.entrySize=r,n.totalCalculatedSize=this.#l)}}#B=e=>{};#G=(e,t,r)=>{};#M=(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#g;this.#z(t)&&((e||!this.#$(t))&&(yield t),t!==this.#m);)t=this.#h[t]}*#A({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#m;this.#z(t)&&((e||!this.#$(t))&&(yield t),t!==this.#g);)t=this.#p[t]}#z(e){return void 0!==e&&this.#u.get(this.#f[e])===e}*entries(){for(let e of this.#O())void 0!==this.#d[e]&&void 0!==this.#f[e]&&!this.#D(this.#d[e])&&(yield[this.#f[e],this.#d[e]])}*rentries(){for(let e of this.#A())void 0!==this.#d[e]&&void 0!==this.#f[e]&&!this.#D(this.#d[e])&&(yield[this.#f[e],this.#d[e]])}*keys(){for(let e of this.#O()){let t=this.#f[e];void 0!==t&&!this.#D(this.#d[e])&&(yield t)}}*rkeys(){for(let e of this.#A()){let t=this.#f[e];void 0!==t&&!this.#D(this.#d[e])&&(yield t)}}*values(){for(let e of this.#O())void 0!==this.#d[e]&&!this.#D(this.#d[e])&&(yield this.#d[e])}*rvalues(){for(let e of this.#A())void 0!==this.#d[e]&&!this.#D(this.#d[e])&&(yield this.#d[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#O()){let n=this.#d[r],i=this.#D(n)?n.__staleWhileFetching:n;if(void 0!==i&&e(i,this.#f[r],this))return this.#H(this.#f[r],t)}}forEach(e,t=this){for(let r of this.#O()){let n=this.#d[r],i=this.#D(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#f[r],this)}}rforEach(e,t=this){for(let r of this.#A()){let n=this.#d[r],i=this.#D(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#f[r],this)}}purgeStale(){let e=!1;for(let t of this.#A({allowStale:!0}))this.#$(t)&&(this.#F(this.#f[t],"expire"),e=!0);return e}info(e){let t=this.#u.get(e);if(void 0===t)return;let r=this.#d[t],n=this.#D(r)?r.__staleWhileFetching:r;if(void 0===n)return;let i={value:n};if(this.#w&&this.#b){let e=this.#w[t],r=this.#b[t];if(e&&r){let t=e-(this.#a.now()-r);i.ttl=t,i.start=Date.now()}}return this.#E&&(i.size=this.#E[t]),i}dump(){let e=[];for(let t of this.#O({allowStale:!0})){let r=this.#f[t],n=this.#d[t],i=this.#D(n)?n.__staleWhileFetching:n;if(void 0===i||void 0===r)continue;let o={value:i};if(this.#w&&this.#b){o.ttl=this.#w[t];let e=this.#a.now()-this.#b[t];o.start=Math.floor(Date.now()-e)}this.#E&&(o.size=this.#E[t]),e.unshift([r,o])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let e=Date.now()-r.start;r.start=this.#a.now()-e}this.#q(t,r.value,r)}}set(e,t,r={}){let{status:i=(n.metrics.hasSubscribers?{}:void 0)}=r;r.status=i,i&&(i.op="set",i.key=e,void 0!==t&&(i.value=t),i.cache=this);let o=this.#q(e,t,r);return i&&n.metrics.hasSubscribers&&n.metrics.publish(i),o}#q(e,t,r,n){let{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=r,l=this.#D(t);if(void 0===t)return c&&(c.set="deleted"),this.delete(e),this;let{noUpdateTTL:u=this.noUpdateTTL}=r;c&&!l&&(c.value=t);let f=this.#M(e,t,r.size||0,a,c);if(this.maxEntrySize&&f>this.maxEntrySize)return this.#F(e,"set"),c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this;let d=0===this.#c?void 0:this.#u.get(e);if(void 0===d)d=0===this.#c?this.#g:0!==this.#v.length?this.#v.pop():this.#c===this.#e?this.#j(!1):this.#c,this.#f[d]=e,this.#d[d]=t,this.#u.set(e,d),this.#p[this.#g]=d,this.#h[d]=this.#g,this.#g=d,this.#c++,this.#G(d,f,c),c&&(c.set="add"),u=!1,this.#_&&!l&&this.#n?.(t,e,"add");else{this.#N(d);let r=this.#d[d];if(t!==r){if(!s)if(this.#D(r)){r!==n&&r.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:i}=r;void 0!==i&&i!==t&&(this.#L&&this.#r?.(i,e,"set"),this.#C&&this.#y?.push([i,e,"set"]))}else this.#L&&this.#r?.(r,e,"set"),this.#C&&this.#y?.push([r,e,"set"]);if(this.#B(d),this.#G(d,f,c),this.#d[d]=t,!l){let n=r&&this.#D(r)?r.__staleWhileFetching:r,i=void 0===n?"add":t!==n?"replace":"update";c&&(c.set=i,void 0!==n&&(c.oldValue=n)),this.#_&&this.onInsert?.(t,e,i)}}else l||(c&&(c.set="update"),this.#_&&this.onInsert?.(t,e,"update"))}if(0!==i&&!this.#w&&this.#T(),this.#w&&(u||this.#x(d,i,o),c&&this.#U(c,d)),!s&&this.#C&&this.#y){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#c;){let e=this.#d[this.#m];if(this.#j(!0),this.#D(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#C&&this.#y){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}}}#j(e){let t=this.#m,r=this.#f[t],n=this.#d[t],i=this.#D(n);i&&n.__abortController.abort(new Error("evicted"));let o=i?n.__staleWhileFetching:n;return(this.#L||this.#C)&&void 0!==o&&(this.#L&&this.#r?.(o,r,"evict"),this.#C&&this.#y?.push([o,r,"evict"])),this.#B(t),this.#I?.[t]&&(clearTimeout(this.#I[t]),this.#I[t]=void 0),e&&(this.#f[t]=void 0,this.#d[t]=void 0,this.#v.push(t)),1===this.#c?(this.#m=this.#g=0,this.#v.length=0):this.#m=this.#p[t],this.#u.delete(r),this.#c--,t}has(e,t={}){let{status:r=(n.metrics.hasSubscribers?{}:void 0)}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let i=this.#V(e,t);return n.metrics.hasSubscribers&&n.metrics.publish(r),i}#V(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,i=this.#u.get(e);if(void 0!==i){let e=this.#d[i];if(this.#D(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#$(i))return r&&this.#k(i),n&&(n.has="hit",this.#U(n,i)),!0;n&&(n.has="stale",this.#U(n,i))}else n&&(n.has="miss");return!1}peek(e,t={}){let{status:r=(o()?{}:void 0)}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let i=this.#W(e,t);return n.metrics.hasSubscribers&&n.metrics.publish(r),i}#W(e,t){let{status:r,allowStale:n=this.allowStale}=t,i=this.#u.get(e);if(void 0===i||!n&&this.#$(i))return void(r&&(r.peek=void 0===i?"miss":"stale"));let o=this.#d[i],s=this.#D(o)?o.__staleWhileFetching:o;return r&&(void 0!==s?(r.peek="hit",r.value=s):r.peek="miss"),s}#P(e,t,r,n){let i=void 0===t?void 0:this.#d[t];if(this.#D(i))return i;let o=new AbortController,{signal:s}=r;s?.addEventListener("abort",()=>o.abort(s.reason),{signal:o.signal});let a={signal:o.signal,options:r,context:n},c=(n,i=!1)=>{let{aborted:s}=o.signal,c=r.ignoreFetchAbort&&void 0!==n,f=r.ignoreFetchAbort||!(!r.allowStaleOnFetchAbort||void 0===n);if(r.status&&(s&&!i?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,c&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),s&&!c&&!i)return l(o.signal.reason,f);let d=u,p=this.#d[t];return(p===u||void 0===p&&c&&i)&&(void 0===n?void 0!==d.__staleWhileFetching?this.#d[t]=d.__staleWhileFetching:this.#F(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.#q(e,n,a.options,d))),n},l=(n,i)=>{let{aborted:s}=o.signal,a=s&&r.allowStaleOnFetchAbort,c=a||r.allowStaleOnFetchRejection,l=c||r.noDeleteOnFetchRejection,f=u;if(this.#d[t]===u&&(!l||!i&&void 0===f.__staleWhileFetching?this.#F(e,"fetch"):a||(this.#d[t]=f.__staleWhileFetching)),c)return r.status&&void 0!==f.__staleWhileFetching&&(r.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw n};r.status&&(r.status.fetchDispatched=!0);let u=new Promise((t,n)=>{let s=this.#o?.(e,i,a);o.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))}),s&&s instanceof Promise?s.then(e=>t(void 0===e?void 0:e),n):void 0!==s&&t(s)}).then(c,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),l(e,!1))),f=Object.assign(u,{__abortController:o,__staleWhileFetching:i,__returned:void 0});return void 0===t?(this.#q(e,f,{...a.options,status:void 0}),t=this.#u.get(e)):this.#d[t]=f,f}#D(e){if(!this.#S)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let r=n.tracing.hasSubscribers,{status:i=(o()?{}:void 0)}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#Z(e,t);return i&&r&&(i.trace=!0,n.tracing.tracePromise(()=>s,i).catch(()=>{})),s}async#Z(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:h,forceRefresh:m=!1,status:g,signal:v}=t;if(g&&(g.op="fetch",g.key=e,m&&(g.forceRefresh=!0),g.cache=this),!this.#S)return g&&(g.fetch="get"),this.#H(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,status:g});let y={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:v},E=this.#u.get(e);if(void 0===E){g&&(g.fetch="miss");let t=this.#P(e,E,y,h);return t.__returned=t}{let t=this.#d[E];if(this.#D(t)){let e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#$(E);if(!m&&!i)return g&&(g.fetch="hit"),this.#N(E),n&&this.#k(E),g&&this.#U(g,E),t;let o=this.#P(e,E,y,h),s=void 0!==o.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",s&&i&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}forceFetch(e,t={}){let r=n.tracing.hasSubscribers,{status:i=(o()?{}:void 0)}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#K(e,t);return i&&r&&(i.trace=!0,n.tracing.tracePromise(()=>s,i).catch(()=>{})),s}async#K(e,t={}){let r=await this.#Z(e,t);if(void 0===r)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let{status:r=(n.metrics.hasSubscribers?{}:void 0)}=t;t.status=r,r&&(r.op="memo",r.key=e,t.context&&(r.context=t.context),r.cache=this);let i=this.#Y(e,t);return r&&(r.value=i),n.metrics.hasSubscribers&&n.metrics.publish(r),i}#Y(e,t={}){let r=this.#s;if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,status:i,forceRefresh:o,...s}=t;i&&o&&(i.forceRefresh=!0);let a=this.#H(e,s),c=o||void 0===a;if(i&&(i.memo=c?"miss":"hit",c||(i.value=a)),!c)return a;let l=r(e,a,{options:s,context:n});return i&&(i.value=l),this.#q(e,l,s),l}get(e,t={}){let{status:r=(n.metrics.hasSubscribers?{}:void 0)}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let i=this.#H(e,t);return r&&(void 0!==i&&(r.value=i),n.metrics.hasSubscribers&&n.metrics.publish(r)),i}#H(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=t,s=this.#u.get(e);if(void 0===s)return void(o&&(o.get="miss"));let a=this.#d[s],c=this.#D(a);return o&&this.#U(o,s),this.#$(s)?c?(o&&(o.get="stale-fetching"),r&&void 0!==a.__staleWhileFetching?(o&&(o.returnedStale=!0),a.__staleWhileFetching):void 0):(i||this.#F(e,"expire"),o&&(o.get="stale"),r?(o&&(o.returnedStale=!0),a):void 0):(o&&(o.get=c?"fetching":"hit"),this.#N(s),n&&this.#k(s),c?a.__staleWhileFetching:a)}#X(e,t){this.#h[t]=e,this.#p[e]=t}#N(e){e!==this.#g&&(e===this.#m?this.#m=this.#p[e]:this.#X(this.#h[e],this.#p[e]),this.#X(this.#g,e),this.#g=e)}delete(e){return this.#F(e,"delete")}#F(e,t){n.metrics.hasSubscribers&&n.metrics.publish({op:"delete",delete:t,key:e,cache:this});let r=!1;if(0!==this.#c){let n=this.#u.get(e);if(void 0!==n)if(this.#I?.[n]&&(clearTimeout(this.#I[n]),this.#I[n]=void 0),r=!0,1===this.#c)this.#J(t);else{this.#B(n);let r=this.#d[n];if(this.#D(r)?r.__abortController.abort(new Error("deleted")):(this.#L||this.#C)&&(this.#L&&this.#r?.(r,e,t),this.#C&&this.#y?.push([r,e,t])),this.#u.delete(e),this.#f[n]=void 0,this.#d[n]=void 0,n===this.#g)this.#g=this.#h[n];else if(n===this.#m)this.#m=this.#p[n];else{let e=this.#h[n];this.#p[e]=this.#p[n];let t=this.#p[n];this.#h[t]=this.#h[n]}this.#c--,this.#v.push(n)}}if(this.#C&&this.#y?.length){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}return r}clear(){return this.#J("delete")}#J(e){for(let t of this.#A({allowStale:!0})){let r=this.#d[t];if(this.#D(r))r.__abortController.abort(new Error("deleted"));else{let n=this.#f[t];this.#L&&this.#r?.(r,n,e),this.#C&&this.#y?.push([r,n,e])}}if(this.#u.clear(),this.#d.fill(void 0),this.#f.fill(void 0),this.#w&&this.#b){this.#w.fill(0),this.#b.fill(0);for(let e of this.#I??[])void 0!==e&&clearTimeout(e);this.#I?.fill(void 0)}if(this.#E&&this.#E.fill(0),this.#m=0,this.#g=0,this.#v.length=0,this.#l=0,this.#c=0,this.#C&&this.#y){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}}};return He.LRUCache=d,He}function Ve(){if(Fe)return ke;Fe=1;const e=(e,t,r)=>{const n=e.indexOf(r);return e.lastIndexOf(t,n>-1?n:1/0)},t=e=>{try{return new URL(e)}catch{}};return ke=(r,n)=>{const i=n?((e,t)=>{const r=e.indexOf(":"),n=e.slice(0,r+1);if(Object.prototype.hasOwnProperty.call(t,n))return e;if("://"===e.substr(r,3))return e;const i=e.indexOf("@");return i>-1?i>r?`git+ssh://${e}`:e:`${e.slice(0,r+1)}//${e.slice(r+1)}`})(r,n):r;return t(i)||t((t=>{const r=e(t,"@","#"),n=e(t,":","#");return n>r&&(t=t.slice(0,n)+"/"+t.slice(n+1)),-1===e(t,":","#")&&-1===t.indexOf("//")&&(t=`git+ssh://${t}`),t})(i))}}function We(){if(Be)return Ue;Be=1;const e=Ve();return Ue=(t,r,{gitHosts:n,protocols:i})=>{if(!t)return;const o=(e=>{const t=e.indexOf("#"),r=e.indexOf("/"),n=e.indexOf("/",r+1),i=e.indexOf(":"),o=/\s/.exec(e),s=e.indexOf("@"),a=!o||t>-1&&o.index>t,c=-1===s||t>-1&&s>t,l=-1===i||t>-1&&i>t,u=-1===n||t>-1&&n>t,f=r>0,d=t>-1?"/"!==e[t-1]:!e.endsWith("/"),p=!e.startsWith(".");return a&&f&&d&&p&&c&&l&&u})(t)?`github:${t}`:t,s=e(o,i);if(!s)return;const a=n.byShortcut[s.protocol],c=n.byDomain[s.hostname.startsWith("www.")?s.hostname.slice(4):s.hostname],l=a||c;if(!l)return;const u=n[a||c];let f=null;i[s.protocol]?.auth&&(s.username||s.password)&&(f=`${s.username}${s.password?":"+s.password:""}`);let d=null,p=null,h=null,m=null;try{if(a){let e=s.pathname.startsWith("/")?s.pathname.slice(1):s.pathname;const t=e.indexOf("@");t>-1&&(e=e.slice(t+1));const r=e.lastIndexOf("/");r>-1?(p=decodeURIComponent(e.slice(0,r)),p||(p=null),h=decodeURIComponent(e.slice(r+1))):h=decodeURIComponent(e),h.endsWith(".git")&&(h=h.slice(0,-4)),s.hash&&(d=decodeURIComponent(s.hash.slice(1))),m="shortcut"}else{if(!u.protocols.includes(s.protocol))return;const e=u.extract(s);if(!e)return;p=e.user&&decodeURIComponent(e.user),h=decodeURIComponent(e.project),d=decodeURIComponent(e.committish),m=i[s.protocol]?.name||s.protocol.slice(0,-1)}}catch(e){if(e instanceof URIError)return;throw e}return[l,p,f,h,d,m,r]}}function Ze(){if(Ge)return Me;Ge=1;const{LRUCache:e}=qe(),t=function(){if(xe)return Te;xe=1;const e=(...e)=>e.every(e=>e)?e.join(""):"",t=e=>e?encodeURIComponent(e):"",r=e=>e.toLowerCase().replace(/^\W+/g,"").replace(/(?<!\W)\W+$/,"").replace(/\//g,"").replace(/\W+/g,"-"),n={sshtemplate:({domain:t,user:r,project:n,committish:i})=>`git@${t}:${r}/${n}.git${e("#",i)}`,sshurltemplate:({domain:t,user:r,project:n,committish:i})=>`git+ssh://git@${t}/${r}/${n}.git${e("#",i)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s,path:a})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a)}`,browsetemplate:({domain:r,user:n,project:i,committish:o,treepath:s})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o))}`,browsetreetemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,browseblobtemplate:({domain:r,user:n,project:i,committish:o,blobpath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,docstemplate:({domain:r,user:n,project:i,treepath:o,committish:s})=>`https://${r}/${n}/${i}${e("/",o,"/",t(s))}#readme`,httpstemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git+https://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/raw/${t(i||"HEAD")}/${o}`,shortcuttemplate:({type:t,user:r,project:n,committish:i})=>`${t}:${r}/${n}${e("#",i)}`,pathtemplate:({user:t,project:r,committish:n})=>`${t}/${r}${e("#",n)}`,bugstemplate:({domain:e,user:t,project:r})=>`https://${e}/${t}/${r}/issues`,hashformat:r},i={};i.github={protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",blobpath:"blob",editpath:"edit",filetemplate:({auth:r,user:n,project:i,committish:o,path:s})=>`https://${e(r,"@")}raw.githubusercontent.com/${n}/${i}/${t(o||"HEAD")}/${s}`,gittemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://codeload.${e}/${r}/${n}/tar.gz/${t(i||"HEAD")}`,extract:e=>{let[,t,r,n,i]=e.pathname.split("/",5);if((!n||"tree"===n)&&(n||(i=e.hash.slice(1)),r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:i}}},i.bitbucket={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",blobpath:"src",editpath:"?mode=edit",edittemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,editpath:c})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a,c)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/get/${t(i||"HEAD")}.tar.gz`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["get"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}},i.gitlab={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",blobpath:"tree",editpath:"-/edit",tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/api/v4/projects/${t(r+"/"+n)}/repository/archive.tar.gz?sha=${t(i||"HEAD")}`,extract:e=>{const t=e.pathname.slice(1);if(t.includes("/-/")||t.includes("/archive.tar.gz"))return;const r=t.split("/");let n=r.pop();n.endsWith(".git")&&(n=n.slice(0,-4));const i=r.join("/");return i&&n?{user:i,project:n,committish:e.hash.slice(1)}:void 0}},i.gist={protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",editpath:"edit",sshtemplate:({domain:t,project:r,committish:n})=>`git@${t}:${r}.git${e("#",n)}`,sshurltemplate:({domain:t,project:r,committish:n})=>`git+ssh://git@${t}/${r}.git${e("#",n)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s})=>`https://${r}/${n}/${i}${e("/",t(o))}/${s}`,browsetemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,browsetreetemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,browseblobtemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,docstemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,httpstemplate:({domain:t,project:r,committish:n})=>`git+https://${t}/${r}.git${e("#",n)}`,filetemplate:({user:r,project:n,committish:i,path:o})=>`https://gist.githubusercontent.com/${r}/${n}/raw${e("/",t(i))}/${o}`,shortcuttemplate:({type:t,project:r,committish:n})=>`${t}:${r}${e("#",n)}`,pathtemplate:({project:t,committish:r})=>`${t}${e("#",r)}`,bugstemplate:({domain:e,project:t})=>`https://${e}/${t}`,gittemplate:({domain:t,project:r,committish:n})=>`git://${t}/${r}.git${e("#",n)}`,tarballtemplate:({project:e,committish:r})=>`https://codeload.github.com/gist/${e}/tar.gz/${t(r||"HEAD")}`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if("raw"!==n){if(!r){if(!t)return;r=t,t=null}return r.endsWith(".git")&&(r=r.slice(0,-4)),{user:t,project:r,committish:e.hash.slice(1)}}},hashformat:function(e){return e&&"file-"+r(e)}},i.sourcehut={protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",blobpath:"tree",filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/blob/${t(i)||"HEAD"}/${o}`,httpstemplate:({domain:t,user:r,project:n,committish:i})=>`https://${t}/${r}/${n}${e("#",i)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/archive/${t(i)||"HEAD"}.tar.gz`,bugstemplate:()=>null,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["archive"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}};for(const[e,t]of Object.entries(i))i[e]=Object.assign({},n,t);return Te=i}(),r=We(),n=Ve(),i=new e({max:1e3});class o{constructor(e,t,r,n,i,s,a={}){Object.assign(this,o.#Q[e],{type:e,user:t,auth:r,project:n,committish:i,default:s,opts:a})}static#Q={byShortcut:{},byDomain:{}};static#ee={"git+ssh:":{name:"sshurl"},"ssh:":{name:"sshurl"},"git+https:":{name:"https",auth:!0},"git:":{auth:!0},"http:":{auth:!0},"https:":{auth:!0},"git+http:":{auth:!0}};static addHost(e,t){o.#Q[e]=t,o.#Q.byDomain[t.domain]=e,o.#Q.byShortcut[`${e}:`]=e,o.#ee[`${e}:`]={name:e}}static fromUrl(e,t){if("string"!=typeof e)return;const n=e+JSON.stringify(t||{});if(!i.has(n)){const s=r(e,t,{gitHosts:o.#Q,protocols:o.#ee});i.set(n,s?new o(...s):void 0)}return i.get(n)}static fromManifest(e,t={}){if(!e||"object"!=typeof e)return;const r=e.repository,n=r&&("string"==typeof r?r:"object"==typeof r&&"string"==typeof r.url?r.url:null);if(!n)throw new Error("no repository");const i=n&&o.fromUrl(n.replace(/^git\+/,""),t)||null;if(i)return i;const s=function(e){try{const{protocol:t,hostname:r,pathname:n}=new URL(e);if(!r)return null;return`${/(?:git\+)http:$/.test(t)?"http:":"https:"}//${r}${n.replace(/\.git$/,"")}`}catch{return null}}(n);return o.fromUrl(s,t)||s}static parseUrl(e){return n(e)}#te(e,t){if("function"!=typeof e)return null;const r={...this,...this.opts,...t};r.path||(r.path=""),r.path.startsWith("/")&&(r.path=r.path.slice(1)),r.noCommittish&&(r.committish=null);const n=e(r);return r.noGitPlus&&n.startsWith("git+")?n.slice(4):n}hash(){return this.committish?`#${this.committish}`:""}ssh(e){return this.#te(this.sshtemplate,e)}sshurl(e){return this.#te(this.sshurltemplate,e)}browse(e,...t){return"string"!=typeof e?this.#te(this.browsetemplate,e):"string"!=typeof t[0]?this.#te(this.browsetreetemplate,{...t[0],path:e}):this.#te(this.browsetreetemplate,{...t[1],fragment:t[0],path:e})}browseFile(e,...t){return"string"!=typeof t[0]?this.#te(this.browseblobtemplate,{...t[0],path:e}):this.#te(this.browseblobtemplate,{...t[1],fragment:t[0],path:e})}docs(e){return this.#te(this.docstemplate,e)}bugs(e){return this.#te(this.bugstemplate,e)}https(e){return this.#te(this.httpstemplate,e)}git(e){return this.#te(this.gittemplate,e)}shortcut(e){return this.#te(this.shortcuttemplate,e)}path(e){return this.#te(this.pathtemplate,e)}tarball(e){return this.#te(this.tarballtemplate,{...e,noCommittish:!1})}file(e,t){return this.#te(this.filetemplate,{...t,path:e})}edit(e,t){return this.#te(this.edittemplate,{...t,path:e})}getDefaultRepresentation(){return this.default}toString(e){return this.default&&"function"==typeof this[this.default]?this[this.default](e):this.sshurl(e)}}for(const[e,r]of Object.entries(t))o.addHost(e,r);return Me=o}var Ke,Ye,Xe={topLevel:{dependancies:"dependencies",dependecies:"dependencies",depdenencies:"dependencies",devEependencies:"devDependencies",depends:"dependencies","dev-dependencies":"devDependencies",devDependences:"devDependencies",devDepenencies:"devDependencies",devdependencies:"devDependencies",repostitory:"repository",repo:"repository",prefereGlobal:"preferGlobal",hompage:"homepage",hampage:"homepage",autohr:"author",autor:"author",contributers:"contributors",publicationConfig:"publishConfig",script:"scripts"},bugs:{web:"url",name:"url"},script:{server:"start",tests:"test"}};function Je(){if(Ye)return Ke;Ye=1;var{URL:e}=d,t=function(){if(le)return ce;le=1;const e=me();return ce=(t,r)=>{const n=e(t,r);return n?n.version:null},ce}(),r=function(){if(fe)return ue;fe=1;const e=me();return ue=(t,r)=>{const n=e(t.trim().replace(/^[=v]+/,""),r);return n?n.version:null},ue}(),n=$e(),i=Ze(),{isBuiltin:o}=h,s=["dependencies","devDependencies","optionalDependencies"],a=ze?je:(ze=1,je=function(e){if(!e)return;if("ERROR: No README data found!"===e)return;e=e.trim().split("\n");let t=0;for(;e[t]&&e[t].trim().match(/^(#|$)/);)t++;const r=e.length;let n=t+1;for(;n<r&&e[n].trim();)n++;return e.slice(t,n).join(" ").trim()}),c=Xe,l=e=>e.includes("@")&&e.indexOf("@")<e.lastIndexOf(".");function u(e,t){return e.author&&(e.author=t(e.author)),["maintainers","contributors"].forEach(function(r){Array.isArray(e[r])&&(e[r]=e[r].map(t))}),e}function f(e){if("string"==typeof e)return e;var t=e.name||"",r=e.url||e.web,n=r?" ("+r+")":"",i=e.email||e.mail;return t+(i?" <"+i+">":"")+n}function p(e){if("string"!=typeof e)return e;var t=e.match(/^([^(<]+)/),r=e.match(/\(([^()]+)\)/),n=e.match(/<([^<>]+)>/),i={};return t&&t[0].trim()&&(i.name=t[0].trim()),n&&(i.email=n[1]),r&&(i.url=r[1]),i}return Ke={warn:function(){},fixRepositoryField:function(e){if(e.repositories&&(this.warn("repositories"),e.repository=e.repositories[0]),!e.repository)return this.warn("missingRepository");"string"==typeof e.repository&&(e.repository={type:"git",url:e.repository});var t=e.repository.url||"";if(t){var r=i.fromUrl(t);r&&(t=e.repository.url="shortcut"===r.getDefaultRepresentation()?r.https():r.toString())}t.match(/github.com\/[^/]+\/[^/]+\.git\.git$/)&&this.warn("brokenGitUrl",t)},fixTypos:function(e){Object.keys(c.topLevel).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t)&&this.warn("typo",t,c.topLevel[t])},this)},fixScriptsField:function(e){if(e.scripts)return"object"!=typeof e.scripts?(this.warn("nonObjectScripts"),void delete e.scripts):void Object.keys(e.scripts).forEach(function(t){"string"!=typeof e.scripts[t]?(this.warn("nonStringScript"),delete e.scripts[t]):c.script[t]&&!e.scripts[c.script[t]]&&this.warn("typo",t,c.script[t],"scripts")},this)},fixFilesField:function(e){var t=e.files;t&&!Array.isArray(t)?(this.warn("nonArrayFiles"),delete e.files):e.files&&(e.files=e.files.filter(function(e){return!(!e||"string"!=typeof e)||(this.warn("invalidFilename",e),!1)},this))},fixBinField:function(e){if(e.bin&&"string"==typeof e.bin){var t,r={};(t=e.name.match(/^@[^/]+[/](.*)$/))?r[t[1]]=e.bin:r[e.name]=e.bin,e.bin=r}},fixManField:function(e){e.man&&"string"==typeof e.man&&(e.man=[e.man])},fixBundleDependenciesField:function(e){var t="bundledDependencies",r="bundleDependencies";e[t]&&!e[r]&&(e[r]=e[t],delete e[t]),e[r]&&!Array.isArray(e[r])?(this.warn("nonArrayBundleDependencies"),delete e[r]):e[r]&&(e[r]=e[r].filter(function(t){return t&&"string"==typeof t?(e.dependencies||(e.dependencies={}),Object.prototype.hasOwnProperty.call(e.dependencies,t)||(this.warn("nonDependencyBundleDependency",t),e.dependencies[t]="*"),!0):(this.warn("nonStringBundleDependency",t),!1)},this))},fixDependencies:function(e){!function(e,t){s.forEach(function(r){e[r]&&(e[r]=function(e,t,r){if(!e)return{};"string"==typeof e&&(e=e.trim().split(/[\n\r\s\t ,]+/));if(!Array.isArray(e))return e;r("deprecatedArrayDependencies",t);var n={};return e.filter(function(e){return"string"==typeof e}).forEach(function(e){var t=(e=e.trim().split(/(:?[@\s><=])/)).shift(),r=e.join("");r=(r=r.trim()).replace(/^@/,""),n[t]=r}),n}(e[r],r,t))})}(e,this.warn),function(e){var t=e.optionalDependencies;if(!t)return;var r=e.dependencies||{};Object.keys(t).forEach(function(e){r[e]=t[e]}),e.dependencies=r}(e,this.warn),this.fixBundleDependenciesField(e),["dependencies","devDependencies"].forEach(function(t){if(t in e)return e[t]&&"object"==typeof e[t]?void Object.keys(e[t]).forEach(function(r){var n=e[t][r];"string"!=typeof n&&(this.warn("nonStringDependency",r,JSON.stringify(n)),delete e[t][r]);var o=i.fromUrl(e[t][r]);o&&(e[t][r]=o.toString())},this):(this.warn("nonObjectDependencies",t),void delete e[t])},this)},fixModulesField:function(e){e.modules&&(this.warn("deprecatedModules"),delete e.modules)},fixKeywordsField:function(e){"string"==typeof e.keywords&&(e.keywords=e.keywords.split(/,\s+/)),e.keywords&&!Array.isArray(e.keywords)?(delete e.keywords,this.warn("nonArrayKeywords")):e.keywords&&(e.keywords=e.keywords.filter(function(e){return!("string"!=typeof e||!e)||(this.warn("nonStringKeyword"),!1)},this))},fixVersionField:function(e,n){var i=!n;if(!e.version)return e.version="",!0;if(!t(e.version,i))throw new Error('Invalid version: "'+e.version+'"');return e.version=r(e.version,i),!0},fixPeople:function(e){u(e,f),u(e,p)},fixNameField:function(e,t){"boolean"==typeof t?t={strict:t}:void 0===t&&(t={});var r=t.strict;if(e.name||r){if("string"!=typeof e.name)throw new Error("name field must be a string.");r||(e.name=e.name.trim()),function(e,t,r){if("."===e.charAt(0)||!function(e){if("@"!==e.charAt(0))return!1;var t=e.slice(1).split("/");if(2!==t.length)return!1;return t[0]&&t[1]&&t[0]===encodeURIComponent(t[0])&&t[1]===encodeURIComponent(t[1])}(e)&&(n=e,n.match(/[/@\s+%:]/)||n!==encodeURIComponent(n))||t&&!r&&e!==e.toLowerCase()||"node_modules"===e.toLowerCase()||"favicon.ico"===e.toLowerCase())throw new Error("Invalid name: "+JSON.stringify(e));var n}(e.name,r,t.allowLegacyCase),o(e.name)&&this.warn("conflictingName",e.name)}else e.name=""},fixDescriptionField:function(e){e.description&&"string"!=typeof e.description&&(this.warn("nonStringDescription"),delete e.description),e.readme&&!e.description&&(e.description=a(e.readme)),void 0===e.description&&delete e.description,e.description||this.warn("missingDescription")},fixReadmeField:function(e){e.readme||(this.warn("missingReadme"),e.readme="ERROR: No README data found!")},fixBugsField:function(t){if(!t.bugs&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.bugs()&&(t.bugs={url:r.bugs()})}else if(t.bugs){if("string"==typeof t.bugs)l(t.bugs)?t.bugs={email:t.bugs}:e.canParse(t.bugs)?t.bugs={url:t.bugs}:this.warn("nonEmailUrlBugsString");else{!function(e,t){if(!e)return;Object.keys(e).forEach(function(r){c.bugs[r]&&(t("typo",r,c.bugs[r],"bugs"),e[c.bugs[r]]=e[r],delete e[r])})}(t.bugs,this.warn);var n=t.bugs;t.bugs={},n.url&&(e.canParse(n.url)?t.bugs.url=n.url:this.warn("nonUrlBugsUrlField")),n.email&&("string"==typeof n.email&&l(n.email)?t.bugs.email=n.email:this.warn("nonEmailBugsEmailField"))}t.bugs.email||t.bugs.url||(delete t.bugs,this.warn("emptyNormalizedBugs"))}},fixHomepageField:function(t){if(!t.homepage&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.docs()&&(t.homepage=r.docs())}if(t.homepage)return"string"!=typeof t.homepage?(this.warn("nonUrlHomepage"),delete t.homepage):void(e.canParse(t.homepage)||(t.homepage="http://"+t.homepage))},fixLicenseField:function(e){const t=e.license||e.licence;return t?"string"!=typeof t||t.length<1||""===t.trim()?this.warn("invalidLicense"):n(t).validForNewPackages?void 0:this.warn("invalidLicense"):this.warn("missingLicense")}},Ke}var Qe,et,tt,rt,nt={repositories:"'repositories' (plural) Not supported. Please pick one as the 'repository' field",missingRepository:"No repository field.",brokenGitUrl:"Probably broken git url: %s",nonObjectScripts:"scripts must be an object",nonStringScript:"script values must be string commands",nonArrayFiles:"Invalid 'files' member",invalidFilename:"Invalid filename in 'files' list: %s",nonArrayBundleDependencies:"Invalid 'bundleDependencies' list. Must be array of package names",nonStringBundleDependency:"Invalid bundleDependencies member: %s",nonDependencyBundleDependency:"Non-dependency in bundleDependencies: %s",nonObjectDependencies:"%s field must be an object",nonStringDependency:"Invalid dependency: %s %s",deprecatedArrayDependencies:"specifying %s as array is deprecated",deprecatedModules:"modules field is deprecated",nonArrayKeywords:"keywords should be an array of strings",nonStringKeyword:"keywords should be an array of strings",conflictingName:"%s is also the name of a node core module.",nonStringDescription:"'description' field should be a string",missingDescription:"No description",missingReadme:"No README data",missingLicense:"No license field.",nonEmailUrlBugsString:"Bug string field must be url, email, or {email,url}",nonUrlBugsUrlField:"bugs.url field must be a string url. Deleted.",nonEmailBugsEmailField:"bugs.email field must be a string email. Deleted.",emptyNormalizedBugs:"Normalized value of bugs field is an empty object. Deleted.",nonUrlHomepage:"homepage field must be a string url. Deleted.",invalidLicense:"license should be a valid SPDX license expression",typo:"%s should probably be %s."};function it(){if(et)return Qe;et=1;var e=m,t=nt;function r(r,n,i){return i&&(r=i+"['"+r+"']",n=i+"['"+n+"']"),e.format(t.typo,r,n)}return Qe=function(){var n=Array.prototype.slice.call(arguments,0),i=n.shift();if("typo"===i)return r.apply(null,n);var o=t[i]?t[i]:i+": '%s'";return n.unshift(o),e.format.apply(null,n)},Qe}var ot=function(){if(rt)return tt;rt=1,tt=n;var e=Je();n.fixer=e;var t=it(),r=["name","version","description","repository","modules","scripts","files","bin","man","bugs","keywords","readme","homepage","license"].map(function(e){return i(e)+"Field"});function n(n,o,s){!0===o&&(o=null,s=!0),s||(s=!1),o&&!n.private||(o=function(){}),n.scripts&&"node-gyp rebuild"===n.scripts.install&&!n.scripts.preinstall&&(n.gypfile=!0),e.warn=function(){o(t.apply(null,arguments))},r.forEach(function(t){e["fix"+i(t)](n,s)}),n._id=n.name+"@"+n.version}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}return r=r.concat(["dependencies","people","typos"]),tt}(),st=V(ot);const at=(e,t)=>{try{return g(e,v.F_OK),!0}catch(e){return!1}},ct=["index.ts","index.tsx","main.ts","main.tsx"],lt=(e,t,r)=>{const n=a(e??process.cwd(),"src"),i=ct,o=i.map(e=>a(n,e)).find(e=>at(e));if(!o)throw new Error(`Unable to resolve entry point, ensure ${i.join(", ")} exists in ${n}`);return o},ut=(e,t)=>C(e,t,{arrayMerge:(e,t)=>{const r=t[0]??e[0];return"object"==typeof r&&"match"in r&&"middleware"in r?((e,t,r)=>{const n=r.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),i={...t.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),...n};return Object.values(i)})("match",e,t):[...new Set([...e,...t])]}}),ft=async(r,n)=>{const{packageJson:i,root:a}=n,{config:u}=await e(r)??{},f=i.main??i.module??"./dist/bundle.js",d=lt(a);if("build"===r.command){if(s(f)===a)throw new Error("outDir cannot be root, please specify package.main or package.module in package.json");if("src"===s(f))throw new Error("outDir cannot be src, please specify package.main or package.module in package.json");if(s(f)===process.cwd())throw new Error("outDir cannot be the current working directory, please specify package.main or package.module in package.json")}return t({root:a,plugins:[o(),_({debug:!0}),D({extensions:[".md"]})],define:{"process.env.NODE_ENV":JSON.stringify(r.mode),"process.env.NODE_DEBUG":"production"!==r.mode,"process.env.FUSION_LOG_LEVEL":"production"===r.mode?1:3},build:{outDir:s(f),lib:{entry:d,fileName:c(f,l(f)),formats:["es"]},emptyOutDir:!0}},u??{})};function dt(e,t){P("object"==typeof e,new Error(t))}const pt=e=>{if(e.repository)return"string"==typeof e.repository?e.repository:e.repository.url},ht=()=>{try{return N("git remote get-url origin").toString().trim().replace("git@github.com:","https://github.com/").replace(/\.git$/,"")}catch(e){return}},mt=(e="HEAD")=>{try{return N(`git rev-parse ${e}`).toString().trim()}catch(e){return}},gt=()=>{try{return N("git branch --show-current").toString().trim()||void 0}catch{return}},vt="15.7.2-next.1",yt=e=>{if(e?.startsWith("refs/heads/"))return e.slice(11)||void 0},Et=()=>{const e={cliVersion:vt,source:"local",reason:"manual"};if("true"===process.env.GITHUB_ACTIONS){const t=(()=>{const e=process.env.GITHUB_EVENT_NAME||"unknown",t=process.env.GITHUB_ACTOR||"unknown",r=process.env.GITHUB_RUN_ID||"unknown",n=process.env.GITHUB_REPOSITORY||"unknown",i=process.env.GITHUB_WORKFLOW||"unknown",o=process.env.GITHUB_SERVER_URL||"https://github.com";let s="unknown";"unknown"!==n&&"unknown"!==r&&(s=`${o.replace(/\/$/,"")}/${n}/actions/runs/${r}`);const a={eventName:e,actor:t,runId:r,runUrl:s,workflow:i};if(process.env.GITHUB_EVENT_PATH)try{const e=y(process.env.GITHUB_EVENT_PATH,"utf8");Object.assign(a,JSON.parse(e))}catch{console.error("Failed to parse GitHub event payload")}return a})(),r={...e,source:"github",reason:t.eventName,workflow:t.workflow,runId:t.runId,runUrl:t.runUrl,commitId:t.head_commit?.id,repository:t.repository?.name,repository_homepage:t.repository?.homepage,repository_license:t.repository?.license?.name,repository_owner:t.repository?.owner?.login,repository_owner_avatar_url:t.repository?.owner?.avatar_url,actor:t.actor,sender_login:t.sender?.login,sender_avatar_url:t.sender?.avatar_url};return t.pull_request?{...r,branch:t.pull_request.head?.ref,commitId:t.pull_request.head?.sha,htmlUrl:t.pull_request.html_url}:t.release?{...r,tag:t.release.tag_name,htmlUrl:t.release.html_url}:{...r,branch:yt(t.ref??process.env.GITHUB_REF)}}if(process.env.SYSTEM_TEAMPROJECT){const t=(()=>{const e=process.env.BUILD_BUILDID||"unknown",t=process.env.BUILD_DEFINITIONNAME||"unknown",r=process.env.BUILD_REPOSITORY_NAME||"unknown",n=process.env.SYSTEM_TEAMPROJECT||"unknown",i=process.env.SYSTEM_COLLECTIONURI||"unknown",o=process.env.BUILD_REQUESTEDFOR||"unknown",s=process.env.BUILD_SOURCEBRANCH||"unknown",a=process.env.BUILD_SOURCEVERSION||"unknown",c=process.env.BUILD_REASON||"unknown";let l="unknown";return"unknown"!==i&&"unknown"!==n&&"unknown"!==e&&(l=`${i.replace(/\/$/,"")}${n}/_build/results?buildId=${e}`),{runId:e,pipelineName:t,repository:r,project:n,orgUrl:i,actor:o,branch:s,commitId:a,runUrl:l,reason:c}})();return{...e,source:"azure_devops",reason:t.reason,repository:t.repository,runId:t.runId,runUrl:t.runUrl,actor:t.actor,branch:t.branch,commitId:t.commitId,workflow:t.pipelineName}}return{...e,branch:gt()}},bt=["png","jpg","jpeg","gif","svg","ico","webp","mp4","webm","mp3","woff2","woff","eot","ttf","otf","pdf","md","txt"];const wt=(e,t,r)=>{dt(t,"expected packageJson"),P(t.name,"expected [name] in packageJson"),P(t.version,"expected [version] in packageJson");const n=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/app-bundle.js":lt(e.root))(e,t),i=t.name.replace(/^@|\w.*\//gm,""),o=r?.snapshot?function(e,t){const r=O(e)?.version;if(!r)throw new Error(`Invalid semantic version: "${e}". Expected format: major.minor.patch`);const n=Math.floor(Date.now()/1e3);return`${r}-${"string"==typeof t?`${t}.${n}`:`snapshot.${n}`}`}(t.version,r.snapshot):t.version,s="build"===e.command?void 0:`/bundles/apps/${i}@${o}`,a=pt(t)??ht(),c=bt.map(e=>`.${e}`);return{appKey:i,displayName:t.name,description:t.description||"",keywords:t.keywords,type:"standalone",build:{entryPoint:n,assetPath:s,githubRepo:a,version:o,timestamp:(new Date).toISOString(),commitSha:mt(),annotations:Et(),projectPage:t.homepage,allowedExtensions:c}}},It=(e,t)=>C(e,t),Lt=x.object({environment:x.record(x.string(),x.any()).describe("Key-value map of environment-specific variables for the application. Defaults to an empty object if not provided.").optional().default({}),endpoints:x.record(x.string(),x.object({url:x.string({message:"The endpoint URL. This field is required."}),scopes:x.array(x.string()).optional().default([]).describe("List of scopes required for accessing this endpoint. Defaults to an empty array.")})).describe("A mapping of endpoint names to their configuration objects. Each endpoint must specify a URL and may specify scopes.").optional()}).describe("The API application configuration schema, defining environment variables and endpoints for the application."),St=(e,t)=>i.blueBright(t?.relative?`./${u(t?.cwd??process.cwd(),e)}`:e),Ct=async(e,t,r)=>{const n=wt(e,t.packageJson,{snapshot:r?.snapshot});try{r?.log?.start("loading application package...");const{manifest:t,path:i}=await(async(e,t)=>{const r=t?.file??[`app.manifest.${e.environment}`,"app.manifest","app.manifest.config"],n=await L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};if("function"==typeof r.default){const t=await r.default(e,{base:n});return It(n,t??{})}return It(n,r.default??{})}}});return{manifest:n.config,path:n.path,extension:n.extension}})(e,{base:n,file:r?.manifestPath});if(!t.build)throw new Error(`Application manifest for ${t.appKey} does not contain build information, please check the manifest file.`);return"serve"===e.command&&(t.build.assetPath=`/bundles/apps/${t.appKey}/${t.build.version}`),r?.log?.succeed("generated manifest from",St(i,{relative:!0})),t}catch(e){if(e instanceof S){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${St(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(i.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?St(r?.manifestPath):""}`),e}};async function _t(e){e?.start("resolve project package");try{const t=await(async e=>{const t=await f({...e,normalize:!1});if(!t)throw new Error("failed to find package.json");const r={...t.packageJson};return st(r),{packageJson:{...r,version:t.packageJson.version},path:t.path,root:s(t.path)}})();return e?.succeed("ðŸ“Ķ",i.yellowBright([t.packageJson.name,t.packageJson.version].join("@"))),e?.info("🏠",i.blueBright(t.root)),t}catch(t){throw e?.fail("☠ïļ","failed to resolve project package"),t}}const Dt=async e=>{const{log:t}=e??{},r=await _t(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await Ct(n,r,{log:t,manifestPath:e?.manifest,snapshot:e?.snapshot});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},Pt=async e=>{const{log:t,snapshot:n}=e??{};t?.log(i.bold("Starting to build application"));const{manifest:o,pkg:s,env:a}=await Dt({log:t,manifest:e?.manifest,snapshot:n});t?.start("loading vite config...");const c=await ft(a,s);t?.succeed("vite config applied"),t?.debug("vite config:",c),t?.start("ðŸĪžðŸŧ","building application..."),t?.startNativeConsoleCapture(),await r(c),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:s,manifest:o,outDir:c.build.outDir}};var Nt,Ot,At={exports:{}};function $t(){return Ot?Nt:(Ot=1,Nt={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24})}var Rt,Tt,xt,kt,Ft,Ut,Bt,Mt,Gt={};function jt(){return Rt||(Rt=1,function(e){const t={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",MAX_OUTPUT_EXCEEDED:"Decompressed data exceeds the declared uncompressed size",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DUPLICATE_ENTRY:"Duplicate entry name {0}",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",ZIP64_VALUE_TOO_LARGE:"Zip64 value exceeds the maximum safe integer",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function r(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(e,r)=>t[r]||"")),new Error("ADM-ZIP: "+e)}}for(const n of Object.keys(t))e[n]=r(t[n])}(Gt)),Gt}function zt(){if(xt)return Tt;xt=1;const e=k,t=F,r=$t(),n=jt(),i="object"==typeof process&&"win32"===process.platform,o=e=>"object"==typeof e&&null!==e,s=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=3988292384^t>>>1:t>>>=1;return t>>>0});function a(r){this.sep=t.sep,this.fs=e,o(r)&&o(r.fs)&&"function"==typeof r.fs.statSync&&(this.fs=r.fs)}return Tt=a,a.prototype.makeDir=function(e){const t=this;!function(e){let r=e.split(t.sep)[0];e.split(t.sep).forEach(function(e){if(e&&":"!==e.substr(-1,1)){var i;r+=t.sep+e;try{i=t.fs.statSync(r)}catch(e){if(!e.message||!e.message.startsWith("ENOENT"))throw e;t.fs.mkdirSync(r)}if(i&&i.isFile())throw n.FILE_IN_THE_WAY(`"${r}"`)}})}(e)},a.prototype.writeFileTo=function(e,r,n,i){const o=this;if(o.fs.existsSync(e)){if(!n)return!1;if(o.fs.statSync(e).isDirectory())return!1}var s,a=t.dirname(e);o.fs.existsSync(a)||o.makeDir(a);try{s=o.fs.openSync(e,"w",438)}catch(t){o.fs.chmodSync(e,438),s=o.fs.openSync(e,"w",438)}if(s)try{o.fs.writeSync(s,r,0,r.length,0)}finally{o.fs.closeSync(s)}return o.fs.chmodSync(e,i||438),!0},a.prototype.writeFileToAsync=function(e,r,n,i,o){"function"==typeof i&&(o=i,i=void 0);const s=this;s.fs.exists(e,function(a){if(a&&!n)return o(!1);s.fs.stat(e,function(n,c){if(a&&c&&c.isDirectory())return o(!1);var l=t.dirname(e);s.fs.exists(l,function(t){if(!t)try{s.makeDir(l)}catch(e){return o(!1)}const n=function(t){s.fs.write(t,r,0,r.length,0,function(r){s.fs.close(t,function(){if(r)return o(!1);s.fs.chmod(e,i||438,function(){o(!0)})})})};s.fs.open(e,"w",438,function(t,r){t?s.fs.chmod(e,438,function(){s.fs.open(e,"w",438,function(e,t){if(e||!t)return o(!1);n(t)})}):r?n(r):o(!1)})})})})},a.prototype.assertPathSafe=function(e,r){const i=this;if("function"!=typeof i.fs.lstatSync)return;const o=t.resolve(e),s=t.resolve(r);if(s===o)return;const a=t.relative(o,s);if(!a||".."===a||a.startsWith(".."+t.sep)||t.isAbsolute(a))return;let c=o;for(const e of a.split(t.sep)){if(!e||"."===e)continue;let r;c=t.join(c,e);try{r=i.fs.lstatSync(c)}catch(e){break}if(r.isSymbolicLink())throw n.FILE_IN_THE_WAY(`"${c}"`)}},a.prototype.findFiles=function(e){const r=this,n="function"==typeof r.fs.lstatSync,i=r.fs.realpathSync(e);return function e(o,s,a,c){let l=[];return r.fs.readdirSync(o).forEach(function(u){const f=t.join(o,u);if(function(e){if(!n)return!1;if(!r.fs.lstatSync(e).isSymbolicLink())return!1;let o;try{o=r.fs.realpathSync(e)}catch(e){return!0}return!(o===i||o.startsWith(i+t.sep))}(f))return;const d=r.fs.statSync(f);if(l.push(t.normalize(f)+(d.isDirectory()?r.sep:"")),d.isDirectory()&&a){const t=r.fs.realpathSync(f);c.has(t)||(c.add(t),l=l.concat(e(f,s,a,c)))}}),l}(e,void 0,!0,new Set([i]))},a.prototype.findFilesAsync=function(e,r){const n=this,i=[];let o=!1;const s=function(e){o||(o=!0,r(e,e?void 0:i))},a="function"==typeof n.fs.lstat;let c=null;const l=function(e,r,o){n.fs.readdir(e,function(s,u){if(s)return o(s);let f=u.length;if(!f)return o();u.forEach(function(s){const u=t.join(e,s);!function(e,r){if(!a)return r(null,!1);n.fs.lstat(e,function(i,o){return i?r(i):o&&o.isSymbolicLink()?void n.fs.realpath(e,function(e,n){if(e)return r(null,!0);r(null,!(n===c||n.startsWith(c+t.sep)))}):r(null,!1)})}(u,function(e,s){if(e)return o(e);s?--f||o():n.fs.stat(u,function(e,s){if(e)return o(e);s?(i.push(t.normalize(u)+(s.isDirectory()?n.sep:"")),s.isDirectory()?n.fs.realpath(u,function(e,t){if(e)return o(e);r.has(t)?--f||o():(r.add(t),l(u,r,function(e){if(e)return o(e);--f||o()}))}):--f||o()):--f||o()})})})})};n.fs.realpath(e,function(t,r){if(t)return s(t);c=r,l(e,new Set([r]),s)})},a.prototype.getAttributes=function(){},a.prototype.setAttributes=function(){},a.crc32update=function(e,t){return s[255&(e^t)]^e>>>8},a.crc32=function(e){"string"==typeof e&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=a.crc32update(r,e[n++]);return~r>>>0},a.methodToString=function(e){switch(e){case r.STORED:return"STORED ("+e+")";case r.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}},a.canonical=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.join(".",r)},a.zipnamefix=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.posix.join(".",r)},a.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");for(let r=(e.length>>>0)-1;r>=0;r--)if(t(e[r],r,e))return e[r]},a.sanitize=function(e,r){e=t.resolve(t.normalize(e));for(var n=r.split("/"),i=0,o=n.length;i<o;i++){var s=t.normalize(t.join(e,n.slice(i,o).join(t.sep)));if(s===e||s.startsWith(e+t.sep))return s}return t.normalize(t.join(e,t.basename(r)))},a.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):"string"==typeof e?t(e):Buffer.alloc(0)},a.readBigUInt64LE=function(e,t){const r=e.readUInt32LE(t),i=4294967296*e.readUInt32LE(t+4)+r;if(i>Number.MAX_SAFE_INTEGER)throw n.ZIP64_VALUE_TOO_LARGE();return i},a.writeBigUInt64LE=function(e,t,r){const n=t>>>0,i=Math.floor(t/4294967296)>>>0;e.writeUInt32LE(n,r),e.writeUInt32LE(i,r+4)},a.fromDOS2Date=function(e){return new Date(1980+(e>>25&127),Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(31&e)<<1)},a.fromDate2DOS=function(e){let t=0,r=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),r=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|r},a.isWin=i,a.crcTable=s,Tt}function Ht(){return Mt||(Mt=1,At.exports=zt(),At.exports.Constants=$t(),At.exports.Errors=jt(),At.exports.FileAttr=function(){if(Ft)return kt;Ft=1;const e=F;return kt=function(t,{fs:r}){var n=t||"",i={directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0},o=null;return n&&r.existsSync(n)?(o=r.statSync(n),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=!!(73&o.mode),i.readonly=!(128&o.mode),i.hidden="."===e.basename(n)[0]):console.warn("Invalid path: "+n),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}(),At.exports.decoder=Bt?Ut:(Bt=1,Ut={efs:!0,encode:e=>Buffer.from(e,"utf8"),decode:e=>e.toString("utf8")})),At.exports}var qt,Vt,Wt,Zt,Kt,Yt={};function Xt(){if(Vt)return qt;Vt=1;var e=Ht(),t=e.Constants;return qt=function(){var r=20,n=10,i=0,o=0,s=0,a=0,c=0,l=0,u=0,f=0,d=0,p=0,h=0,m=0,g=0;r|=e.isWin?2560:768,i|=t.FLG_EFS;const v={extraLen:0},y=e=>Math.max(0,e)>>>0;return s=e.fromDate2DOS(new Date),{get made(){return r},set made(e){r=e},get version(){return n},set version(e){n=e},get flags(){return i},set flags(e){i=e},get flags_efs(){return(i&t.FLG_EFS)>0},set flags_efs(e){e?i|=t.FLG_EFS:i&=~t.FLG_EFS},get flags_desc(){return(i&t.FLG_DESC)>0},set flags_desc(e){e?i|=t.FLG_DESC:i&=~t.FLG_DESC},get method(){return o},set method(e){switch(e){case t.STORED:this.version=10;break;case t.DEFLATED:default:this.version=20}o=e},get time(){return e.fromDOS2Date(this.timeval)},set time(t){t=new Date(t),this.timeval=e.fromDate2DOS(t)},get timeval(){return s},set timeval(e){s=y(e)},get timeHighByte(){return e=s>>>8,255&Math.max(0,e);var e},get crc(){return a},set crc(e){a=y(e)},get compressedSize(){return c},set compressedSize(e){c=y(e)},get size(){return l},set size(e){l=y(e)},get fileNameLength(){return u},set fileNameLength(e){u=e},get extraLength(){return f},set extraLength(e){f=e},get extraLocalLength(){return v.extraLen},set extraLocalLength(e){v.extraLen=e},get commentLength(){return d},set commentLength(e){d=e},get diskNumStart(){return p},set diskNumStart(e){p=y(e)},get inAttr(){return h},set inAttr(e){h=y(e)},get attr(){return m},set attr(e){m=y(e)},get fileAttr(){return(m||0)>>16&511},get offset(){return g},set offset(e){g=y(e)},get encrypted(){return(i&t.FLG_ENC)===t.FLG_ENC},get centralHeaderSize(){return t.CENHDR+u+f+d},get realDataOffset(){return g+t.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(r){if(g<0||g+t.LOCHDR>r.length)throw e.Errors.INVALID_LOC();var n=r.slice(g,g+t.LOCHDR);if(n.readUInt32LE(0)!==t.LOCSIG)throw e.Errors.INVALID_LOC();v.version=n.readUInt16LE(t.LOCVER),v.flags=n.readUInt16LE(t.LOCFLG),v.flags_desc=(v.flags&t.FLG_DESC)>0,v.method=n.readUInt16LE(t.LOCHOW),v.time=n.readUInt32LE(t.LOCTIM),v.crc=n.readUInt32LE(t.LOCCRC),v.compressedSize=n.readUInt32LE(t.LOCSIZ),v.size=n.readUInt32LE(t.LOCLEN),v.fnameLen=n.readUInt16LE(t.LOCNAM),v.extraLen=n.readUInt16LE(t.LOCEXT);const i=g+t.LOCHDR+v.fnameLen,o=i+v.extraLen;return r.slice(i,o)},loadFromBinary:function(v){if(v.length!==t.CENHDR||v.readUInt32LE(0)!==t.CENSIG)throw e.Errors.INVALID_CEN();r=v.readUInt16LE(t.CENVEM),n=v.readUInt16LE(t.CENVER),i=v.readUInt16LE(t.CENFLG),o=v.readUInt16LE(t.CENHOW),s=v.readUInt32LE(t.CENTIM),a=v.readUInt32LE(t.CENCRC),c=v.readUInt32LE(t.CENSIZ),l=v.readUInt32LE(t.CENLEN),u=v.readUInt16LE(t.CENNAM),f=v.readUInt16LE(t.CENEXT),d=v.readUInt16LE(t.CENCOM),p=v.readUInt16LE(t.CENDSK),h=v.readUInt16LE(t.CENATT),m=v.readUInt32LE(t.CENATX),g=v.readUInt32LE(t.CENOFF)},localHeaderToBinary:function(){var e=Buffer.alloc(t.LOCHDR);return e.writeUInt32LE(t.LOCSIG,0),e.writeUInt16LE(n,t.LOCVER),e.writeUInt16LE(i&~t.FLG_DESC,t.LOCFLG),e.writeUInt16LE(o,t.LOCHOW),e.writeUInt32LE(s,t.LOCTIM),e.writeUInt32LE(a,t.LOCCRC),e.writeUInt32LE(c,t.LOCSIZ),e.writeUInt32LE(l,t.LOCLEN),e.writeUInt16LE(u,t.LOCNAM),e.writeUInt16LE(v.extraLen,t.LOCEXT),e},centralHeaderToBinary:function(){var e=Buffer.alloc(t.CENHDR+u+f+d);return e.writeUInt32LE(t.CENSIG,0),e.writeUInt16LE(r,t.CENVEM),e.writeUInt16LE(n,t.CENVER),e.writeUInt16LE(i&~t.FLG_DESC,t.CENFLG),e.writeUInt16LE(o,t.CENHOW),e.writeUInt32LE(s,t.CENTIM),e.writeUInt32LE(a,t.CENCRC),e.writeUInt32LE(c,t.CENSIZ),e.writeUInt32LE(l,t.CENLEN),e.writeUInt16LE(u,t.CENNAM),e.writeUInt16LE(f,t.CENEXT),e.writeUInt16LE(d,t.CENCOM),e.writeUInt16LE(p,t.CENDSK),e.writeUInt16LE(h,t.CENATT),e.writeUInt32LE(m,t.CENATX),e.writeUInt32LE(g,t.CENOFF),e},toJSON:function(){const s=function(e){return e+" bytes"};return{made:r,version:n,flags:i,method:e.methodToString(o),time:this.time,crc:"0x"+a.toString(16).toUpperCase(),compressedSize:s(c),size:s(l),fileNameLength:s(u),extraLength:s(f),commentLength:s(d),diskNumStart:p,inAttr:h,attr:m,offset:g,centralHeaderSize:s(t.CENHDR+u+f+d)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}function Jt(){return Kt||(Kt=1,Yt.EntryHeader=Xt(),Yt.MainHeader=function(){if(Zt)return Wt;Zt=1;var e=Ht(),t=e.Constants;return Wt=function(){var r=0,n=0,i=0,o=0,s=0;const a=()=>r>t.EF_ZIP64_OR_16||n>t.EF_ZIP64_OR_16||i>t.EF_ZIP64_OR_32||o>t.EF_ZIP64_OR_32;return{get diskEntries(){return r},set diskEntries(e){r=n=e},get totalEntries(){return n},set totalEntries(e){n=r=e},get size(){return i},set size(e){i=e},get offset(){return o},set offset(e){o=e},get commentLength(){return s},set commentLength(e){s=e},get mainHeaderSize(){return(a()?t.ZIP64HDR+t.END64HDR:0)+t.ENDHDR+s},loadFromBinary:function(a){if((a.length!==t.ENDHDR||a.readUInt32LE(0)!==t.ENDSIG)&&(a.length<t.ZIP64HDR||a.readUInt32LE(0)!==t.ZIP64SIG))throw e.Errors.INVALID_END();a.readUInt32LE(0)===t.ENDSIG?(r=a.readUInt16LE(t.ENDSUB),n=a.readUInt16LE(t.ENDTOT),i=a.readUInt32LE(t.ENDSIZ),o=a.readUInt32LE(t.ENDOFF),s=a.readUInt16LE(t.ENDCOM)):(r=e.readBigUInt64LE(a,t.ZIP64SUB),n=e.readBigUInt64LE(a,t.ZIP64TOT),i=e.readBigUInt64LE(a,t.ZIP64SIZB),o=e.readBigUInt64LE(a,t.ZIP64OFF),s=0)},toBinary:function(){var c;if(!a())return(c=Buffer.alloc(t.ENDHDR+s)).writeUInt32LE(t.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(r,t.ENDSUB),c.writeUInt16LE(n,t.ENDTOT),c.writeUInt32LE(i,t.ENDSIZ),c.writeUInt32LE(o,t.ENDOFF),c.writeUInt16LE(s,t.ENDCOM),c.fill(" ",t.ENDHDR),c;let l=0;(c=Buffer.alloc(this.mainHeaderSize)).writeUInt32LE(t.ZIP64SIG,l),e.writeBigUInt64LE(c,t.ZIP64HDR-t.ZIP64LEAD,l+t.ZIP64SIZE),c.writeUInt16LE(45,l+t.ZIP64VEM),c.writeUInt16LE(45,l+t.ZIP64VER),c.writeUInt32LE(0,l+t.ZIP64DSK),c.writeUInt32LE(0,l+t.ZIP64DSKDIR),e.writeBigUInt64LE(c,r,l+t.ZIP64SUB),e.writeBigUInt64LE(c,n,l+t.ZIP64TOT),e.writeBigUInt64LE(c,i,l+t.ZIP64SIZB),e.writeBigUInt64LE(c,o,l+t.ZIP64OFF);const u=o+i;return l+=t.ZIP64HDR,c.writeUInt32LE(t.END64SIG,l),c.writeUInt32LE(0,l+t.END64START),e.writeBigUInt64LE(c,u,l+t.END64OFF),c.writeUInt32LE(1,l+t.END64NUMDISKS),l+=t.END64HDR,c.writeUInt32LE(t.ENDSIG,l),c.writeUInt32LE(0,l+4),c.writeUInt16LE(Math.min(r,t.EF_ZIP64_OR_16),l+t.ENDSUB),c.writeUInt16LE(Math.min(n,t.EF_ZIP64_OR_16),l+t.ENDTOT),c.writeUInt32LE(Math.min(i,t.EF_ZIP64_OR_32),l+t.ENDSIZ),c.writeUInt32LE(Math.min(o,t.EF_ZIP64_OR_32),l+t.ENDOFF),c.writeUInt16LE(s,l+t.ENDCOM),c.fill(" ",l+t.ENDHDR),c},toJSON:function(){return{diskEntries:r,totalEntries:n,size:i+" bytes",offset:function(e,t){let r=e.toString(16).toUpperCase();for(;r.length<t;)r="0"+r;return"0x"+r}(o,4),commentLength:s}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}()),Yt}var Qt,er,tr,rr,nr,ir,or,sr,ar,cr,lr,ur,fr,dr={};function pr(){if(ir)return nr;ir=1;const{randomFillSync:e}=B,t=jt(),r=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=t>>>1^3988292384:t>>>=1;return t>>>0}),n=(e,t)=>Math.imul(e,t)>>>0,i=(e,t)=>r[255&(e^t)]^e>>>8,o=()=>"function"==typeof e?e(Buffer.alloc(12)):o.node();o.node=()=>{const e=Buffer.alloc(12),t=e.length;for(let r=0;r<t;r++)e[r]=256*Math.random()&255;return e};const s={genSalt:o};function a(e){const t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let e=0;e<t.length;e++)this.updateKeys(t[e])}return a.prototype.updateKeys=function(e){const t=this.keys;return t[0]=i(t[0],e),t[1]+=255&t[0],t[1]=n(t[1],134775813)+1,t[2]=i(t[2],t[1]>>>24),e},a.prototype.next=function(){const e=(2|this.keys[2])>>>0;return n(e,1^e)>>8&255},nr={decrypt:function(e,r,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);const i=function(e){const t=new a(e);return function(e){const r=Buffer.alloc(e.length);let n=0;for(let i of e)r[n++]=t.updateKeys(i^t.next());return r}}(n),o=i(e.slice(0,12)),s=8&~r.flags?r.crc>>>24:r.timeHighByte;if(o[11]!==s)throw t.WRONG_PASSWORD();return i(e.slice(12))},encrypt:function(e,t,r,n=!1){null==e&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));const i=function(e){const t=new a(e);return function(e,r,n=0){r||(r=Buffer.alloc(e.length));for(let i of e){const e=t.next();r[n++]=i^e,t.updateKeys(i)}return r}}(r),o=s.genSalt();o[11]=t.crc>>>24&255,n&&(o[10]=t.crc>>>16&255);const c=Buffer.alloc(e.length+12);return i(o,c),i(e,c,12)},_salter:function(e){Buffer.isBuffer(e)&&e.length>=12?s.genSalt=function(){return e.slice(0,12)}:s.genSalt="node"===e?o.node:o}}}function hr(){return or||(or=1,dr.Deflater=er?Qt:(er=1,Qt=function(e){var t=U,r={chunkSize:1024*(parseInt(e.length/1024)+1)};return{deflate:function(){return t.deflateRawSync(e,r)},deflateAsync:function(n){var i=t.createDeflateRaw(r),o=[],s=0;i.on("data",function(e){o.push(e),s+=e.length}),i.on("end",function(){var e=Buffer.alloc(s),t=0;e.fill(0);for(var r=0;r<o.length;r++){var i=o[r];i.copy(e,t),t+=i.length}n&&n(e)}),i.end(e)}}}),dr.Inflater=function(){if(rr)return tr;rr=1;const e=+(process?.versions?.node??"").split(".")[0]||0,t=jt();return tr=function(r,n){var i=U;const o=n>0?n:1,s=e>=15?{maxOutputLength:o}:{};return{inflate:function(){return i.inflateRawSync(r,s)},inflateAsync:function(e){var n=i.createInflateRaw(s),a=[],c=0,l=!1;const u=function(t){l||(l=!0,n.destroy(),e&&e(Buffer.alloc(0),t))};n.on("error",function(e){u(e)}),n.on("data",function(e){if(!l){if((c+=e.length)>o)return u(t.MAX_OUTPUT_EXCEEDED());a.push(e)}}),n.on("end",function(){if(!l){l=!0;var t=Buffer.alloc(c),r=0;t.fill(0);for(var n=0;n<a.length;n++){var i=a[n];i.copy(t,r),r+=i.length}e&&e(t)}}),n.end(r)}}}}(),dr.ZipCrypto=pr()),dr}function mr(){if(ar)return sr;ar=1;var e=Ht(),t=Jt(),r=e.Constants,n=hr();return sr=function(i,o){var s=new t.EntryHeader,a=Buffer.alloc(0),c=Buffer.alloc(0),l=!1,u=null,f=Buffer.alloc(0),d=Buffer.alloc(0),p=!0;const h=i,m="object"==typeof h.decoder?h.decoder:e.decoder;function g(){if(!(o&&o instanceof Uint8Array))return Buffer.alloc(0);d=s.loadLocalHeaderFromBinary(o);const t=s.realDataOffset,r=t+s.compressedSize;if(t<0||r<t||r>o.length)throw e.Errors.INVALID_LOC();return o.slice(t,r)}function v(t){const r=s.flags_desc||s.localHeader.flags_desc?s.crc:s.localHeader.crc;return e.crc32(t)===r}function y(t,r,i){if(void 0===r&&"string"==typeof t&&(i=t,t=void 0),l)return t&&r&&r(Buffer.alloc(0),e.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var o,c;try{if(0===(o=g()).length)return t&&r&&r(o),o;if(s.encrypted){if("string"!=typeof i&&!Buffer.isBuffer(i))throw e.Errors.INVALID_PASS_PARAM();o=n.ZipCrypto.decrypt(o,s,i)}}catch(e){if(t&&r)return r(Buffer.alloc(0),e),Buffer.alloc(0);throw e}switch(s.method){case e.Constants.STORED:if(c=Buffer.alloc(o.length),o.copy(c),v(c))return t&&r&&r(c),c;throw t&&r&&r(c,e.Errors.BAD_CRC()),e.Errors.BAD_CRC();case e.Constants.DEFLATED:var u=new n.Inflater(o,s.size);if(!t){if(!v(c=u.inflate()))throw e.Errors.BAD_CRC(`"${m.decode(a)}"`);return c}u.inflateAsync(function(t,n){r&&(n?r(Buffer.alloc(0),n):v(t)?r(t):r(t,e.Errors.BAD_CRC()))});break;default:throw t&&r&&r(Buffer.alloc(0),e.Errors.UNKNOWN_METHOD()),e.Errors.UNKNOWN_METHOD()}}function E(t,r){if((!u||!u.length)&&Buffer.isBuffer(o))return t&&r&&r(g()),g();if(u.length&&!l){var i;switch(s.method){case e.Constants.STORED:return s.compressedSize=s.size,i=Buffer.alloc(u.length),u.copy(i),t&&r&&r(i),i;default:case e.Constants.DEFLATED:var a=new n.Deflater(u);if(!t){var c=a.deflate();return s.compressedSize=c.length,c}a.deflateAsync(function(e){i=Buffer.alloc(e.length),s.compressedSize=e.length,e.copy(i),r&&r(i)}),a=null}}else{if(!t||!r)return Buffer.alloc(0);r(Buffer.alloc(0))}}function b(t,r){return e.readBigUInt64LE(t,r)}function w(e){var t,n,i,o;e.length>=r.EF_ZIP64_SCOMP&&(t=b(e,r.EF_ZIP64_SUNCOMP),s.size===r.EF_ZIP64_OR_32&&(s.size=t)),e.length>=r.EF_ZIP64_RHO&&(n=b(e,r.EF_ZIP64_SCOMP),s.compressedSize===r.EF_ZIP64_OR_32&&(s.compressedSize=n)),e.length>=r.EF_ZIP64_DSN&&(i=b(e,r.EF_ZIP64_RHO),s.offset===r.EF_ZIP64_OR_32&&(s.offset=i)),e.length>=r.EF_ZIP64_DSN+4&&(o=e.readUInt32LE(r.EF_ZIP64_DSN),s.diskNumStart===r.EF_ZIP64_OR_16&&(s.diskNumStart=o))}return p=!!m.hasOwnProperty("efs")&&m.efs,{get entryName(){return m.decode(a)},get rawEntryName(){return a},set entryName(t){var r=(a=e.toBuffer(t,m.encode))[a.length-1];l=47===r||92===r,s.fileNameLength=a.length},get efs(){return"function"==typeof p?p(this.entryName):p},get extra(){return f},set extra(t){f=t,s.extraLength=t.length,function(t){try{for(var n,i,o,s=0;s+4<t.length;)n=t.readUInt16LE(s),s+=2,i=t.readUInt16LE(s),s+=2,o=t.slice(s,s+i),s+=i,r.ID_ZIP64===n&&w(o)}catch(t){throw e.Errors.EXTRA_FIELD_PARSE_ERROR()}}(t)},get comment(){return m.decode(c)},set comment(t){if(c=e.toBuffer(t,m.encode),s.commentLength=c.length,c.length>65535)throw e.Errors.COMMENT_TOO_LONG()},get name(){const e=m.decode(a);return l?e.replace(/[/\\]$/,"").split("/").pop():e.split("/").pop()},get isDirectory(){return l},getCompressedData:function(){return E(!1,null)},getCompressedDataAsync:function(e){E(!0,e)},setData:function(t){u=e.toBuffer(t,e.decoder.encode),!l&&u.length?(s.size=u.length,s.method=e.Constants.DEFLATED,s.crc=e.crc32(t),s.changed=!0):s.method=e.Constants.STORED},getData:function(e){return s.changed?u:y(!1,null,e)},getDataAsync:function(e,t){s.changed?e(u):y(!0,e,t)},set attr(e){s.attr=e},get attr(){return s.attr},set header(e){s.loadFromBinary(e)},get header(){return s},packCentralHeader:function(){s.flags_efs=this.efs,s.extraLength=f.length;var t=s.centralHeaderToBinary(),r=e.Constants.CENHDR;return a.copy(t,r),r+=a.length,f.copy(t,r),r+=s.extraLength,c.copy(t,r),t},packLocalHeader:function(){let e=0;s.flags_efs=this.efs,s.extraLocalLength=d.length;const t=s.localHeaderToBinary(),r=Buffer.alloc(t.length+a.length+s.extraLocalLength);return t.copy(r,e),e+=t.length,a.copy(r,e),e+=a.length,d.copy(r,e),e+=d.length,r},toJSON:function(){const e=function(e){return"<"+(e&&e.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:s.toJSON(),compressedData:e(o),data:e(u)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}},sr}function gr(){if(lr)return cr;lr=1;const e=mr(),t=Jt(),r=Ht();return cr=function(n,i){var o=[],s=Object.create(null),a=Buffer.alloc(0),c=new t.MainHeader,l=!1;const u=new Set,f=i,{noSort:d,decoder:p}=f;function h(){if(l=!0,s=Object.create(null),c.diskEntries>(n.length-c.offset)/r.Constants.CENHDR)throw r.Errors.DISK_ENTRY_TOO_LARGE();o=new Array(c.diskEntries);for(var t=c.offset,i=0;i<o.length;i++){var a=t,d=new e(f,n);if(d.header=n.slice(a,a+=r.Constants.CENHDR),d.entryName=n.slice(a,a+=d.header.fileNameLength),d.header.extraLength&&(d.extra=n.slice(a,a+=d.header.extraLength)),d.header.commentLength&&(d.comment=n.slice(a,a+d.header.commentLength)),t+=d.header.centralHeaderSize,d.entryName in s)throw r.Errors.DUPLICATE_ENTRY(`"${d.entryName}"`);o[i]=d,s[d.entryName]=d}u.clear(),function(){const t=new Set;for(const e of Object.keys(s)){const r=e.split("/");if(r.pop(),r.length)for(let e=0;e<r.length;e++){const n=r.slice(0,e+1).join("/")+"/";t.add(n)}}for(const r of t)if(!(r in s)){const t=new e(f);t.entryName=r,t.attr=16,t.temporary=!0,o.push(t),s[t.entryName]=t,u.add(t)}}()}function m(){o.length>1&&!d&&(o=o.map(e=>({entry:e,key:e.entryName.toLowerCase()})).sort((e,t)=>e.key.localeCompare(t.key)).map(e=>e.entry))}return n?function(e){var t=n.length-r.Constants.ENDHDR,i=Math.max(0,t-65535),o=i,s=n.length,l=-1,u=0;"boolean"==typeof f.trailingSpace&&f.trailingSpace&&(i=0);for(;t>=o;t--)if(80===n[t])if(n.readUInt32LE(t)!==r.Constants.ENDSIG)if(n.readUInt32LE(t)!==r.Constants.END64SIG){if(n.readUInt32LE(t)===r.Constants.ZIP64SIG){l=t,s=t+r.readBigUInt64LE(n,t+r.Constants.ZIP64SIZE)+r.Constants.ZIP64LEAD;break}}else o=i;else l=t,u=t,s=t+r.Constants.ENDHDR,o=t-r.Constants.END64HDR;if(-1==l)throw r.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(l,s)),c.commentLength&&(a=n.slice(u+r.Constants.ENDHDR));e&&h()}(f.readEntries):l=!0,{get entries(){return l||h(),o.filter(e=>!u.has(e))},get comment(){return p.decode(a)},set comment(e){a=r.toBuffer(e,p.encode),c.commentLength=a.length},getEntryCount:function(){return l?o.length:c.diskEntries},forEach:function(e){this.entries.forEach(e)},getEntry:function(e){return l||h(),s[e]||null},setEntry:function(e){l||h(),o.push(e),s[e.entryName]=e,c.totalEntries=o.length},deleteFile:function(e,t=!0){l||h();const r=s[e];this.getEntryChildren(r,t).map(e=>e.entryName).forEach(this.deleteEntry)},deleteEntry:function(e){l||h();const t=s[e],r=o.indexOf(t);r>=0&&(o.splice(r,1),delete s[e],c.totalEntries=o.length)},getEntryChildren:function(e,t=!0){if(l||h(),"object"==typeof e){if(e.isDirectory&&t){const t=[],r=e.entryName;for(const e of o)e.entryName.startsWith(r)&&t.push(e);return t}return[e]}return[]},getChildCount:function(e){if(e&&e.isDirectory){const t=this.getEntryChildren(e);return t.includes(e)?t.length-1:t.length}return 0},compressToBuffer:function(){l||h(),m();const e=[],t=[];let r=0,i=0;c.size=0,c.offset=0;let o=0;for(const n of this.entries){const s=n.getCompressedData();n.header.offset=i;const a=n.packLocalHeader(),l=a.length+s.length;i+=l,e.push(a),e.push(s);const u=n.packCentralHeader();t.push(u),c.size+=u.length,r+=l+u.length,o++}r+=c.mainHeaderSize,c.offset=i,c.totalEntries=o,i=0;const s=Buffer.alloc(r);for(const t of e)t.copy(s,i),i+=t.length;for(const e of t)e.copy(s,i),i+=e.length;const u=c.toBinary();return a&&a.copy(u,u.length-a.length),u.copy(s,i),n=s,l=!1,s},toAsyncBuffer:function(e,t,r,i){try{l||h(),m();const t=[],o=[];let s=0,u=0,f=0;c.size=0,c.offset=0;const d=function(p){if(p.length>0){const e=p.shift(),n=e.entryName+e.extra.toString();r&&r(n),e.getCompressedDataAsync(function(r){i&&i(n),e.header.offset=u;const a=e.packLocalHeader(),l=a.length+r.length;u+=l,t.push(a),t.push(r);const h=e.packCentralHeader();o.push(h),c.size+=h.length,s+=l+h.length,f++,d(p)})}else{s+=c.mainHeaderSize,c.offset=u,c.totalEntries=f,u=0;const r=Buffer.alloc(s);t.forEach(function(e){e.copy(r,u),u+=e.length}),o.forEach(function(e){e.copy(r,u),u+=e.length});const i=c.toBinary();a&&a.copy(i,i.length-a.length),i.copy(r,u),n=r,l=!1,e(r)}};d(Array.from(this.entries))}catch(e){t(e)}}}},cr}var vr=function(){if(fr)return ur;fr=1;const e=Ht(),t=F,r=mr(),n=gr(),i=(...t)=>e.findLast(t,e=>"boolean"==typeof e),o=(...t)=>e.findLast(t,e=>"string"==typeof e),s={noSort:!1,readEntries:!1,method:e.Constants.NONE,fs:null};return ur=function(a,c){let l=null;const u=Object.assign(Object.create(null),s);a&&"object"==typeof a&&(a instanceof Uint8Array||(Object.assign(u,a),a=u.input?u.input:void 0,u.input&&delete u.input),Buffer.isBuffer(a)&&(l=a,u.method=e.Constants.BUFFER,a=void 0)),Object.assign(u,c);const f=new e(u),d=e=>{e.filter(e=>e.attr).sort((e,t)=>t.path.length-e.path.length).forEach(e=>f.fs.chmodSync(e.path,e.attr))};if("object"==typeof u.decoder&&"function"==typeof u.decoder.encode&&"function"==typeof u.decoder.decode||(u.decoder=e.decoder),a&&"string"==typeof a){if(!f.fs.existsSync(a))throw e.Errors.INVALID_FILENAME();u.method=e.Constants.FILE,u.filename=a,l=f.fs.readFileSync(a)}const p=new n(l,u),{canonical:h,sanitize:m,zipnamefix:g}=e;function v(e){var r;if(e&&p&&("string"==typeof e&&(r=p.getEntry(t.posix.normalize(e))),"object"==typeof e&&void 0!==e.entryName&&void 0!==e.header&&(r=p.getEntry(e.entryName)),r))return r;return null}function y(e){const{join:r,normalize:n,sep:i}=t.posix;return r(t.isAbsolute(e)?"/":".",n(i+e.split("\\").join(i)+i))}function E(e){return e instanceof RegExp?(t=e,function(e){return t.test(e)}):"function"!=typeof e?()=>!0:e;var t}const b=(e,r)=>{let n=r.slice(-1);return n=n===f.sep?f.sep:"",t.relative(e,r)+n};return{readFile:function(e,t){var r=v(e);return r&&r.getData(t)||null},childCount:function(e){const t=v(e);if(t)return p.getChildCount(t)},readFileAsync:function(e,t){var r=v(e);r?r.getDataAsync(t):t(null,"getEntry failed for:"+e)},readAsText:function(e,t){var r=v(e);if(r){var n=r.getData();if(n&&n.length)return n.toString(t||"utf8")}return""},readAsTextAsync:function(e,t,r){var n=v(e);n?n.getDataAsync(function(e,n){n?t(e,n):e&&e.length?t(e.toString(r||"utf8")):t("")}):t("")},deleteFile:function(e,t=!0){var r=v(e);r&&p.deleteFile(r.entryName,t)},deleteEntry:function(e){var t=v(e);t&&p.deleteEntry(t.entryName)},addZipComment:function(e){p.comment=e},getZipComment:function(){return p.comment||""},addZipEntryComment:function(e,t){var r=v(e);r&&(r.comment=t)},getZipEntryComment:function(e){var t=v(e);return t&&t.comment||""},updateFile:function(e,t){var r=v(e);r&&r.setData(t)},addLocalFile:function(r,n,i,o){if(!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{n=n?y(n):"";const e=t.win32.basename(t.win32.normalize(r));n+=i||e;const s=f.fs.statSync(r),a=s.isFile()?f.fs.readFileSync(r):Buffer.alloc(0);s.isDirectory()&&(n+=f.sep),this.addFile(n,a,o,s)}},addLocalFileAsync:function(e,r){e="object"==typeof e?e:{localPath:e};const n=t.resolve(e.localPath),{comment:i}=e;let{zipPath:o,zipName:s}=e;const a=this;f.fs.stat(n,function(e,c){if(e)return r(e,!1);o=o?y(o):"";const l=t.win32.basename(t.win32.normalize(n));if(o+=s||l,c.isFile())f.fs.readFile(n,function(e,t){return e?r(e,!1):(a.addFile(o,t,i,c),setImmediate(r,void 0,!0))});else if(c.isDirectory())return o+=f.sep,a.addFile(o,Buffer.alloc(0),i,c),setImmediate(r,void 0,!0)})},addLocalFolder:function(r,n,i){if(i=E(i),n=n?y(n):"",r=t.normalize(r),!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{const e=f.findFiles(r),o=this;if(e.length)for(const s of e){const e=t.join(n,b(r,s));i(e)&&o.addLocalFile(s,t.dirname(e))}}},addLocalFolderAsync:function(r,n,i,o){o=E(o),i=i?y(i):"",r=t.normalize(r);var s=this;f.fs.open(r,"r",function(t){if(t&&"ENOENT"===t.code)n(void 0,e.Errors.FILE_NOT_FOUND(r));else if(t)n(void 0,t);else{var a=f.findFiles(r),c=-1,l=function(){if((c+=1)<a.length){var e=a[c],t=b(r,e).split("\\").join("/");t=t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),o(t)?f.fs.stat(e,function(r,o){r&&n(void 0,r),o.isFile()?f.fs.readFile(e,function(e,r){e?n(void 0,e):(s.addFile(i+t,r,"",o),l())}):(s.addFile(i+t+"/",Buffer.alloc(0),"",o),l())}):process.nextTick(()=>{l()})}else n(!0,void 0)};l()}})},addLocalFolderAsync2:function(r,n){const i=this;r="object"==typeof r?r:{localPath:r};const o=t.resolve(r.localPath);let{zipPath:s,filter:a,namefix:c}=r;var l;a instanceof RegExp?(l=a,a=function(e){return l.test(e)}):"function"!=typeof a&&(a=function(){return!0}),s=s?y(s):"","latin1"===c&&(c=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),"function"!=typeof c&&(c=e=>e);const u=e=>t.join(s,c(b(o,e))),d=e=>t.win32.basename(t.win32.normalize(c(e)));f.fs.open(o,"r",function(r){r&&"ENOENT"===r.code?n(e.Errors.FILE_NOT_FOUND(o),!1):r?n(r,!1):f.findFilesAsync(o,function(e,r){return e?n(e,!1):(r=r.filter(e=>a(u(e)))).length?void setImmediate(r.reverse().reduce(function(e,r){return function(n,o){if(n||!1===o)return setImmediate(e,n,!1);i.addLocalFileAsync({localPath:r,zipPath:t.dirname(u(r)),zipName:d(r)},e)}},n)):n(void 0,!0)})})},addLocalFolderPromise:function(e,t){return new Promise((r,n)=>{this.addLocalFolderAsync2(Object.assign({localPath:e},t),(e,t)=>{if(e)return n(e);t&&r(this)})})},addFile:function(e,t,n,i){let o=v(e=g(e));const s=null!=o;s||(o=new r(u),o.entryName=e),o.comment=n||"";const a="object"==typeof i&&i instanceof f.fs.Stats;a&&(o.header.time=i.mtime);var c=o.isDirectory?16:0;let l=o.isDirectory?16384:32768;return l|=a?4095&i.mode:"number"==typeof i?4095&i:o.isDirectory?493:420,c=(c|l<<16)>>>0,o.attr=c,o.setData(t),s||p.setEntry(o),o},getEntries:function(e){return p.password=e,p?p.entries:[]},getEntry:function(e){return v(e)},getEntryCount:function(){return p.getEntryCount()},forEach:function(e){return p.forEach(e)},extractEntryTo:function(r,n,s,a,c,l){a=i(!1,a),c=i(!1,c),s=i(!0,s),l=o(c,l);var u=v(r);if(!u)throw e.Errors.NO_ENTRY();var d=h(u.entryName),g=m(n,l&&!u.isDirectory?h(l):s?d:t.basename(d));if(u.isDirectory)return p.getEntryChildren(u).forEach(function(t){if(t.isDirectory)return;var r=t.getData();if(!r)throw e.Errors.CANT_EXTRACT_FILE();var i=h(s?t.entryName:t.entryName.substring(u.entryName.length)),o=m(n,i);f.assertPathSafe(n,o);const l=c?t.header.fileAttr:void 0;f.writeFileTo(o,r,a,l)}),!0;var y=u.getData(p.password);if(!y)throw e.Errors.CANT_EXTRACT_FILE();if(f.assertPathSafe(n,g),f.fs.existsSync(g)&&!a)throw e.Errors.CANT_OVERRIDE();const E=c?r.header.fileAttr:void 0;return f.writeFileTo(g,y,a,E),!0},test:function(e){if(!p)return!1;for(var t of p.entries)try{if(t.isDirectory)continue;if(!t.getData(e))return!1}catch(e){return!1}return!0},extractAllTo:function(t,r,n,s){if(n=i(!1,n),s=o(n,s),r=i(!1,r),!p)throw e.Errors.NO_ZIP();const a=[];p.entries.forEach(function(i){var o=m(t,h(i.entryName));if(f.assertPathSafe(t,o),i.isDirectory)return f.makeDir(o),void(n&&a.push({path:o,attr:i.header.fileAttr}));var c=i.getData(s);if(!c)throw e.Errors.CANT_EXTRACT_FILE();const l=n?i.header.fileAttr:void 0;f.writeFileTo(o,c,r,l);try{f.fs.utimesSync(o,i.header.time,i.header.time)}catch(e){}}),d(a)},extractAllToAsync:function(r,n,o,s){if(s=((...t)=>e.findLast(t,e=>"function"==typeof e))(n,o,s),o=i(!1,o),n=i(!1,n),!s)return new Promise((e,t)=>{this.extractAllToAsync(r,n,o,function(r){r?t(r):e(this)})});if(!p)return void s(e.Errors.NO_ZIP());r=t.resolve(r);const a=e=>m(r,t.normalize(h(e.entryName))),c=(e,t)=>new Error(e+': "'+t+'"'),l=[],u=[];p.entries.forEach(e=>{e.isDirectory?l.push(e):u.push(e)});const g=[];for(const e of l){const t=a(e),n=o?e.header.fileAttr:void 0;try{f.assertPathSafe(r,t),f.makeDir(t)}catch(e){s(c("Unable to create folder",t));continue}n&&g.push({path:t,attr:n});try{f.fs.utimesSync(t,e.header.time,e.header.time)}catch(e){}}u.reverse().reduce(function(i,s){return function(a){if(a)i(a);else{const a=t.normalize(h(s.entryName)),l=m(r,a);try{f.assertPathSafe(r,l)}catch(e){return i(e)}s.getDataAsync(function(t,r){if(r)i(r);else if(t){const e=o?s.header.fileAttr:void 0;f.writeFileToAsync(l,t,n,e,function(e){if(!e)return i(c("Unable to write file",l));f.fs.utimes(l,s.header.time,s.header.time,function(){i()})})}else i(e.Errors.CANT_EXTRACT_FILE())})}}},e=>{if(!e)try{d(g)}catch(e){return s(c("Unable to set folder permissions",e.path||""))}s(e)})()},writeZip:function(e,t){if(1===arguments.length&&"function"==typeof e&&(t=e,e=""),!e&&u.filename&&(e=u.filename),e){var r=p.compressToBuffer();if(r){var n=f.writeFileTo(e,r,!0);"function"==typeof t&&t(n?null:new Error("failed"),"")}}},writeZipPromise:function(e,t){const{overwrite:r,perm:n}=Object.assign({overwrite:!0},t);return new Promise((t,i)=>{!e&&u.filename&&(e=u.filename),e||i("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(o=>{f.writeFileToAsync(e,o,r,n,e=>e?t(e):i("ADM-ZIP: Wasn't able to write zip file"))},i)})},toBufferPromise:function(){return new Promise((e,t)=>{p.toAsyncBuffer(e,t)})},toBuffer:function(e,t,r,n){return"function"==typeof e?(p.toAsyncBuffer(e,t,r,n),null):p.compressToBuffer()}}},ur}(),yr=V(vr);const Er=[["B","kB","MB","GB","TB","PB","EB","ZB","YB"],["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"]],br=e=>{if(e>=1e-6&&e<1e21)return String(e);const[t,r]=e.toExponential().split("e"),n=t.replace(".",""),i=Number(r)+1,o=i>0,s=o?n.padEnd(i,"0"):"0".repeat(1-i)+n,a=s.slice(0,o?i:1),c=s.slice(o?i:1).replace(/0+$/,"");return c?`${a}.${c}`:a},wr=e=>{if("number"==typeof e)return Math.log10(e);const t=e.toString(10);return t.length+Math.log10(`0.${t.slice(0,15)}`)},Ir=(e,t)=>{if(void 0!==t&&("number"!=typeof t||!Number.isInteger(t)||t<0||t>100))throw new TypeError(`Expected ${e} to be an integer between 0 and 100, got ${typeof t}: ${t}`)};function Lr(e,t){if("bigint"!=typeof e&&!Number.isFinite(e))throw new TypeError(`Expected a finite number, got ${typeof e}: ${e}`);(e=>{if(void 0!==e&&("number"!=typeof e||!Number.isSafeInteger(e)||e<0))throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof e}: ${e}`)})((t={bits:!1,binary:!1,space:!0,nonBreakingSpace:!1,...t}).fixedWidth);const r=(e=>{const{minimumFractionDigits:t,maximumFractionDigits:r}=e;if(void 0!==t||void 0!==r){if(Ir("minimumFractionDigits",t),Ir("maximumFractionDigits",r),t>r)throw new RangeError(`Expected minimumFractionDigits (${t}) to not be greater than maximumFractionDigits (${r})`);return{...void 0!==t&&{minimumFractionDigits:t},...void 0!==r&&{maximumFractionDigits:r},roundingMode:"trunc"}}})(t),n=Er[(t.bits?2:0)+(t.binary?1:0)],i=t.space?t.nonBreakingSpace?" ":" ":"";Object.is(e,-0)&&(e=0);const o=((e,t)=>e<0?"-":t?0===e||0n===e?" ":"+":"")(e,t.signed);e<0&&(e=-e);const s=t.binary?1024:1e3;let a=0;var c;e>=1&&(a=Math.min(Math.floor(t.binary?("number"==typeof(c=e)?Math.log(c):wr(c)*Math.log(10))/Math.log(s):wr(e)/3),n.length-1));const l=((e,t,r)=>{const n=t**r;if("number"==typeof e||e<=Number.MAX_SAFE_INTEGER)return Number(e)/n;const i=BigInt(t)**BigInt(r),o=e%i;return Number(e/i)+Number(o)/n})(e,s,a);let u;if(Number.isFinite(l)){if((e=l)<1&&a>0&&(e*=s,a-=1),!r){const t=Math.max(3,Math.floor(e).toString().length);(e=Number(e.toPrecision(t)))>=s&&a<n.length-1&&(e/=s,a+=1)}u=((e,t,r)=>{if("string"==typeof t||Array.isArray(t)||!0===t){const n=!0===t?void 0:t;if(void 0!==r)return e.toLocaleString(n,r);const i=br(e),o=i.indexOf("."),s=-1===o?0:i.length-o-1;return s>100?i:e.toLocaleString(n,{maximumFractionDigits:s})}return void 0===r?br(e):e.toLocaleString("en-US",{...r,useGrouping:!1})})(e,t.locale,r)}else u=((e,t,r,n)=>{const i=BigInt(t)**BigInt(r),o=e/i;if(void 0===n)return o.toString();const s=n.minimumFractionDigits??0,a=Math.max(n.maximumFractionDigits??3,s),c=(e%i*10n**BigInt(a)/i).toString().padStart(a,"0").replace(/0+$/,"").padEnd(s,"0");return c?`${o}.${c}`:o.toString()})(e,s,a,r);return(o+u+i+n[a]).padStart(t.fixedWidth??0)}const Sr=e=>"string"==typeof e?Sr(E(e).size):i.yellowBright(Lr(e));class Cr{#re;get ora(){return this.#re}set attachConsole(e){e?(console.log=this.info.bind(this),console.info=this.info.bind(this)):console=Pr}static Global(e){return _r=new Cr(e),_r}static Clone(e){const{prefixText:t}=e||_r;return new Cr({prefixText:t})}static get Current(){return _r}static set Current(e){_r=e}constructor(e){this.#re=j(e)}get prefixText(){return this.#re.prefixText}info(...e){this.#re.info(Dr(e))}succeed(...e){this.#re.succeed(Dr(e))}start(...e){this.#re.start(Dr(e))}fail(...e){this.#re.fail(Dr(e))}warn(...e){this.#re.warn(Dr(e))}clear(){this.#re.clear()}stop(){this.#re.stop()}stopAndPersist(...e){this.#re.stopAndPersist(...e)}}let _r=new Cr;const Dr=e=>e.length?e.join(" "):void 0,Pr=console;class Nr{spinner;debugMode;constructor(e,t){this.spinner=new Cr({prefixText:e}),this.debugMode=t?.debug??!1}start(...e){this.spinner.start(...e)}succeed(...e){this.spinner.succeed(...e)}fail(...e){this.spinner.fail(...e)}error(...e){console.log(...e)}warn(...e){this.spinner.warn(...e)}info(...e){this.spinner.info(...e)}log(...e){this.spinner.info(...e)}debug(...e){this.debugMode&&console.debug(...e)}startNativeConsoleCapture(){this.spinner.attachConsole=!0}stopNativeConsoleCapture(){this.spinner.attachConsole=!1}}const Or=e=>{const t=e.mock??e.mockDiscovery,r={spa:{templateEnv:(n=e.template,i=e.mock,{portal:{id:"@equinor/fusion-framework-dev-portal"},title:"Fusion Dev Portal",serviceDiscovery:{url:"/@fusion-services",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},msal:{clientId:"9b707e3a-3e90-41ed-a47e-652a1e3b53d0",tenantId:"3aa4a235-b6e2-48d5-9195-7fcf05b459b0",redirectUri:"/authentication/login-callback",requiresAuth:"true",...i?{mock:"true",mockServerUrl:i}:{}},serviceWorker:{resources:[{url:"/apps-proxy",rewrite:"/@fusion-api/apps",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/@fusion-api/apps",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/help-proxy",rewrite:"/@fusion-api/help",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/portal-proxy",rewrite:"/@fusion-api/portal-config",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/@fusion-api/portal-config",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]}]},...n})},api:{serviceDiscoveryUrl:t?new URL("/@fusion-mock/discovery",t).href:"https://discovery.fusion.equinor.com/service-registry/environments/ci/services/",headers:{"X-Fusion-Mock":String(Boolean(t))},processServices:(e,t)=>{const{data:r,routes:n}=z(e,t);return{data:r.concat({key:"portals",name:"Portal Service - MOCK",uri:"/@fusion-api/portals"}),routes:n}}}};var n,i;return e.app&&((e,t,r)=>{const{build:n,appKey:i}=t;if(!n)throw new Error("App manifest does not contain build information");e.api.routes??=[],e.api.routes.push({match:[`/apps/bundles/apps/${i}/${n.version}/*path`,`/apps/bundles/apps/${i}@${n.version}/*path`],middleware:async(e,t,r)=>{const n=e.params?.path;!1===Array.isArray(n)&&r(),t.writeHead(302,{"content-type":"application/javascript",location:`/${n.join("/")}`}),t.end()}}),e.api.routes.push({match:`/apps/persons/me/apps/${i}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify({id:"dev-server-generated-id",...t}))}}),e.api.routes.push({match:`/apps/apps/${i}/builds/${n.version}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(r,e.app.manifest,e.app.config),e.portal&&((e,t,r)=>{e.api.routes??=[];const n="portal-config";e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify(t))}}),r&&e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(r,e.portal.manifest,e.portal.config),r},Ar=e=>({portal:"object"==typeof e.spa?.templateEnv?e.spa.templateEnv.portal:void 0,msal:"object"==typeof e.spa?.templateEnv?e.spa.templateEnv.msal:void 0,proxy:"object"==typeof e.spa?.templateEnv?e.spa.templateEnv.serviceWorker?.resources:void 0,serviceDiscoveryUrl:e.api.serviceDiscoveryUrl,routes:e.api.routes});const $r=async(e,t,r)=>{const{overrides:i,log:o}=r??{},s=t.mock?void 0:function(e,t){const r=e.root??process.cwd(),i=n(e.mode,t?a(r,t):r,"FUSION_SPA_MSAL_MOCK");if("true"===i.FUSION_SPA_MSAL_MOCK)return i.FUSION_SPA_MSAL_MOCK_SERVER_URL||"http://localhost:4010"}(e,"string"==typeof i?.envDir?i.envDir:void 0);s&&o?.info(`FUSION_SPA_MSAL_MOCK is enabled, using mock service discovery at ${s}`);const c=Or({...t,mockDiscovery:t.mockDiscovery??s});o?.debug("\nBase dev server config:",Ar(c)),o?.debug("\nCreating dev server with overrides:",i);let l,u=c;try{const t=await(async(e,t,r)=>L("dev-server.config",{baseDir:e.root,extensions:r?.extensions,script:{resolve:async r=>{let n;if("function"==typeof r.default){const i={...t};n=await r.default(e,{base:i})}else n=r.default;return ut(t,n??{})}}}))(e,c);u=t.config;const{path:r}=t;o?.debug(`\nLoaded dev server config from ${r}`),o?.debug("\nLoaded dev server config:",Ar(u)),l=((e,t)=>({name:"fusion:dev-server-config-watcher",configureServer(r){r.watcher.add(e),r.watcher.on("change",n=>{n===e&&(t?.info(`\n${e} changed, restarting dev server...`),r.restart())}),t?.debug(`Watching dev-server.config.ts at: ${e}`)}}))(r,o)}catch(e){o?.warn("\nFailed to load dev server config:",e instanceof Error?e.message:String(e))}const f=t.mock??t.mockDiscovery??s;if(f&&new URL(u.api.serviceDiscoveryUrl).origin!==new URL(f).origin)throw new Error(`Mock mode is enabled (${f}), but service discovery points at ${u.api.serviceDiscoveryUrl}. Remove the api.serviceDiscoveryUrl override from dev-server.config, or run without mock auth.`);const d=l?{...i,plugins:[...i?.plugins??[],l]}:i;return H(u,d)},Rr="fusion-framework-cli",Tr={"X-Fusion-CLI-Name":Rr,"X-Fusion-CLI-Version":vt,"User-Agent":`${Rr}/${vt}`},xr=e=>{const t=new Headers(e.headers);for(const[e,r]of Object.entries(Tr))t.has(e)||t.set(e,r);return{...e,headers:t}},kr={AUTH_DOCS_URL:"https://github.com/equinor/fusion-framework/blob/main/packages/cli/docs/auth.md",APP_DOCS_URL:"https://github.com/equinor/fusion-framework/blob/main/packages/cli/docs/application.md"};function Fr(){if(process.env.FUSION_TOKEN)return[i.bold("ðŸ’Ą FUSION_TOKEN detected"),i.dim(" The CLI is using this token instead of your interactive login session."),i.dim(" If this is unintended, unset the variable and retry, or verify that the token has the correct scope/audience.")].join("\n")}const{AUTH_DOCS_URL:Ur,APP_DOCS_URL:Br}=kr;function Mr(e,t){switch(e){case 401:return function(e){const t=["",i.redBright(`ðŸšŦ Authentication failed: unable to ${e}`),""," No valid token was provided or the token has expired.",""],r=Fr();return r&&t.push(r,""),t.push(i.whiteBright(" Troubleshooting:"),"",` ${i.cyan("1.")} For CI/CD, verify that ${i.bold("FUSION_TOKEN")} is set and the token has not expired.`,` ${i.cyan("2.")} For local development, run ${i.greenBright.bold("ffc auth login")} to refresh your credentials.`,` ${i.cyan("3.")} Verify that ${i.bold("--scope")} targets the correct API audience for your environment.`,"",` ${i.dim("Auth docs:")} ${i.blueBright.underline(Ur)}`,` ${i.dim("Publish docs:")} ${i.blueBright.underline(Br)}`,""),t.join("\n")}(t);case 403:return function(e){const t=["",i.redBright(`ðŸšŦ Authorization failed: not permitted to ${e}`),"","⚠ïļ Your token is valid but does not have the required permissions for this operation.",""],r=Fr();return r&&t.push(r,""),t.push(i.whiteBright(" Troubleshooting:"),"",` ${i.cyan("1.")} Verify that your user or service principal has publish permissions for this application.`,` ${i.cyan("2.")} Check that the token's ${i.bold("scope / audience")} matches the target environment.`,` ${i.cyan("3.")} Confirm that the application is registered and your account has the correct role assignment.`,"",` ${i.dim("Auth docs:")} ${i.blueBright.underline(Ur)}`,` ${i.dim("Publish docs:")} ${i.blueBright.underline(Br)}`,""),t.join("\n")}(t);default:return}}const{AUTH_DOCS_URL:Gr,APP_DOCS_URL:jr}=kr;function zr(e,t){if(!(e instanceof Error))return;const r="SilentTokenAcquisitionError"===e.name,n=e,o=n.response?n.response.status:void 0,s=401===o||403===o;let a=!1,c=e.cause;for(let e=0;e<5&&c&&c instanceof Error;e++){if("SilentTokenAcquisitionError"===c.name){a=!0;break}c=c.cause}if(!r&&!s&&!a)return;if(s&&!r&&!a)return Mr(o,t);const l=function(e){let t=e;for(let e=0;e<5&&t;e++){if(!(t instanceof Error)){if("object"==typeof t&&"errorMessage"in t){const e=t.errorMessage;if("string"==typeof e){const t=e.match(/Description:\s*(.+?)(?:\s*Trace ID:|$)/);return t?.[1]?.trim()??e.split(" - ")[0]?.trim()}break}break}{const e=t;if("string"==typeof e.errorMessage){const t=e.errorMessage,r=t.match(/Description:\s*(.+?)(?:\s*Trace ID:|$)/);return r?.[1]?.trim()??t.split(" - ")[0]?.trim()}t=t.cause}}}(e),u=["",i.redBright(`🔑 Token acquisition failed: unable to ${t}`),"",i.yellow(`⚠ïļ ${l??"The CLI could not silently acquire an access token for this operation."}`),""],f=Fr();return f&&u.push(f,""),u.push(i.whiteBright(" Troubleshooting:"),"",` ${i.cyan("1.")} Run ${i.greenBright.bold("ffc auth login")} to refresh your local credentials.`,` ${i.cyan("2.")} For CI/CD, set a fresh ${i.bold("FUSION_TOKEN")} — cached refresh tokens may have expired.`,` ${i.cyan("3.")} Verify that ${i.bold("--scope")} targets the correct API audience for your environment.`,"",` ${i.dim("Auth docs:")} ${i.blueBright.underline(Gr)}`,` ${i.dim("Publish docs:")} ${i.blueBright.underline(jr)}`,""),u.join("\n")}const Hr=(e,t,r)=>{const n=s(String(e));b(n)||w(n,{recursive:!0}),I(e,t,r)},qr=["package.json","LICENSE.md","README.md","CHANGELOG.md"],Vr=async(e,t)=>{const{archive:r,log:n}=t??{},o=s(e.path),c=t?.buildDir??"dist",l=a(o,c);if(!(await M(l)).isDirectory())throw new Error(`Build directory ${c} does not exist`);n?.log(i.bold("Starting to pack bundle"));const u=new yr;if(u.addLocalFolder(l,c),t?.content)for(const[e,r]of Object.entries(t.content))u.addFile(e,Buffer.from(r)),n?.info("📄",St(e,{relative:!0}));n?.info("📂",St(l,{relative:!0}));for(const t of qr.concat(e.packageJson.files??[])){const e=a(o,t),r=s(e.replace(o,""));at(e)?(u.addLocalFile(e,r),n?.info("📄",St(e,{relative:!0}))):n?.warn(i.dim("📄",St(e,{relative:!0})))}return r&&(at(s(r))||await G(s(r),{recursive:!0}),n?.start("compressing content"),await u.writeZipPromise(r),n?.succeed("📚",St(r,{relative:!0}),Sr(r))),u},Wr=async e=>{const{log:t,manifest:r,snapshot:n}=e;process.env.NODE_ENV,process.cwd();const{pkg:i,manifest:o}=await Pt({log:t,manifest:r,snapshot:n});if(!o.build)throw new Error("Manifest build config not found");return{archive:await Vr(i,{log:t,archive:e?.archive,content:{"app-manifest.json":JSON.stringify(o.build,null,2),"metadata.json":JSON.stringify({appKey:o.appKey,name:o.appKey,version:o.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:o}},Zr=async(e,t)=>{const{log:r}=t;try{r?.start("create application configuration"),r?.info(`generating config with ${i.red.dim(e.command)} command in ${i.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`app.config.${e.environment}`,"app.config"];return L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{environment:{}};if("function"==typeof r.default){const t=await r.default(e,{base:n})??n;return Lt.parse(t??n)}return Lt.parse(r.default??n)}}})})(e,{file:t?.config});return r?.succeed("⚙ïļ generated config from ",St(n.path,{relative:!0})),n.config}catch(e){if(e instanceof S){if(!t.config)return r?.succeed(i.dim("⚙ïļ no local application config applied, using built-in")),{environment:{},endpoints:{}};r?.warn(`failed to load config file ${St(t.config)}, please check the path.`)}throw r?.fail("failed to resolve application config"),r?.debug(e),e}},Kr=async e=>{const{log:t}=e??{};let r;try{t?.start("resolve project package"),r=await _t(null),t?.succeed("ðŸ“Ķ",i.yellowBright([r.packageJson.name,r.packageJson.version].join("@"))),t?.info("🏠",i.blueBright(r.root))}catch{t?.info("Failed to resolve project package, using current directory as root")}const n=r?.root??process.cwd(),o={command:"build",mode:process.env.NODE_ENV??"production",root:n,...e?.env},s=await Zr(o,{log:t,config:e?.config});if(t?.debug("config:",s),e?.output){t?.start("writing config to file");try{await Hr(e.output,JSON.stringify(s,null,2)),t?.succeed("config written successfully",St(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:s,pkg:r}};class Yr extends Error{response;static Name="HttpResponseError";constructor(e,t,r){super(e,r),this.response=t}}class Xr extends Yr{static Name="HttpJsonResponseError";data;constructor(e,t,r){super(e,t,r),this.name=Xr.Name,this.data=r?.data}}class Jr extends Yr{static Name="ServerSentEventResponseError";constructor(e,t,r){super(e,t,r),this.name=Jr.Name}}class Qr extends Error{}const en=async e=>{const{log:t,config:r,appKey:n,buildVersion:i,framework:o}=e;try{const e=await o.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",St(e.uri))}),t?.start("Publishing application config");const s=await e.json(`/apps/${n}/builds/${i}/config`,{method:"PUT",body:r,headers:Tr});t?.debug("Response:",s),t?.succeed("Published application config")}catch(e){if(e instanceof Xr)switch(e.response.status){case 410:t?.fail("ðŸĪŽ",`App ${n} is deleted from apps-service. Please check the app key and try again.`);break;case 404:t?.fail("ðŸĪŽ",`App ${n} not found. Please check the app key and try again.`);break;case 403:case 401:{const r=Mr(e.response.status,`publish config for ${n}`);t?.fail("🔒","Authentication/authorization error publishing app config."),r&&t?.error(r),process.exit(1);break}default:t?.fail("ðŸĪŽ","Failed to publish application config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}const r=zr(e,`publish config for ${n}`);r&&(t?.fail("🔒",`Token acquisition failed publishing config for ${n}`),t?.error(r),process.exit(1)),t?.fail("ðŸĪŽ","Failed to publish app config:",e instanceof Error?e.message:String(e)),process.exit(1)}},tn=async e=>{const{log:r}=e??{},n="@equinor/fusion-framework-dev-portal",i=await _t(r),o={root:i.root,environment:"local",...e?.env,mode:"development",command:"serve"},a=await Ct(o,i,{log:r,manifestPath:e?.manifest}),c=await Zr(o,{log:r,config:e?.config});let l,u;const d=p(import.meta.resolve(n));at(d)?(l=d,u=await f({cwd:d}).then(e=>e?s(e?.path):void 0)):r?.info(`Portal ${n} is external, skipping entry point resolution`);const h=await ft(o,i),m=u?[i.root,u]:[i.root];r?.debug(`File system access allowed for: \n${m.join("\n")}\n`);const g=t(h,{server:{port:e?.port||3e3,host:e?.host||h.server?.host||"localhost",fs:{allow:m}}}),v={template:{portal:{id:n}},app:{manifest:a,config:c},mock:e?.mock};l&&(v.portal={manifest:{name:n,build:{templateEntry:l,assetPath:"/@fs"}},config:{}}),r?.debug("vite config:",g),r?.debug("dev server config:",v),r?.start("Starting app development server...");const y=await $r(o,v,{overrides:g,log:r});await y.listen(),r?.succeed("App development server started successfully");const E=y.config.server.https?"https":"http",b=y.config.server.host||"localhost",w=y.config.server.port||5173;return r?.info(`App development server is running at: ${E}://${b}:${w}/apps/${a.appKey}`),y},rn=async e=>{const{log:r,dir:n,port:i=4173,host:o="localhost"}=e??{};r?.log("Starting to serve application");const c="@equinor/fusion-framework-dev-portal",l=await _t(r);r?.start("Loading Vite config...");const u=await ft({root:l.root,command:"build",mode:"production"},l);r?.succeed("Vite config loaded");const d=n||(u.build?.outDir||"dist"),h=a(l.root,d),m={root:l.root,environment:"local",mode:"production",command:"serve",isPreview:!0},g=await Ct(m,l,{log:r,manifestPath:e?.manifest}),v=await Zr(m,{log:r,config:e?.config});if(r?.debug("Output directory:",h),!b(h))throw new Error(`Build directory does not exist: ${h}\nPlease build the application first using \`ffc app build\``);let y,E;const w=p(import.meta.resolve(c));at(w)?(y=w,E=await f({cwd:w}).then(e=>e?s(e?.path):void 0)):r?.info(`Portal ${c} is external, skipping entry point resolution`);const I=await ft(m,l),L=E?[l.root,E,h]:[l.root,h];r?.debug(`File system access allowed for: \n${L.join("\n")}\n`);const S=t(I,{server:{port:i,host:o||I.server?.host||"localhost",fs:{allow:L}}}),C={template:{portal:{id:c}},app:{manifest:g,config:v},mock:e?.mock};y&&(C.portal={manifest:{name:c,build:{templateEntry:y,assetPath:"/@fs"}},config:{}}),r?.debug("vite config:",S),r?.debug("dev server config:",C),r?.start("Starting preview server with dev-portal...");try{const e=await $r(m,C,{overrides:S,log:r});await e.listen(),r?.succeed("Preview server started successfully");const t=e.config.server?.https?"https":"http",n=e.config.server?.host||o,s=e.config.server?.port||i;return r?.info(`Preview server is running at: ${t}://${n}:${s}`),g.appKey&&r?.info(`App URL: ${t}://${n}:${s}/apps/${g.appKey}`),e}catch(e){throw r?.fail("Failed to start preview server"),e}};class nn extends A{satisfies(e){return $(this,e)}}const on=Symbol("fusion.telemetry-export-request");var sn=function(e,t){return sn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},sn(e,t)};function an(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}sn(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var cn=function(){return cn=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},cn.apply(this,arguments)};function ln(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})}function un(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function fn(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function dn(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function pn(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function hn(e){return this instanceof hn?(this.v=e,this):new hn(e)}function mn(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){o.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=i[e](t)).value instanceof hn?Promise.resolve(r.value.v).then(c,l):u(o[0][2],r)}catch(e){u(o[0][3],e)}var r}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function gn(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=fn(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}}function vn(e){return"function"==typeof e}function yn(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var En=yn(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function bn(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var wn=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=fn(o),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(vn(c))try{c()}catch(e){i=e instanceof En?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=fn(l),f=u.next();!f.done;f=u.next()){var d=f.value;try{Sn(d)}catch(e){i=null!=i?i:[],e instanceof En?i=pn(pn([],dn(i)),dn(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}}if(i)throw new En(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Sn(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&bn(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&bn(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),In=wn.EMPTY;function Ln(e){return e instanceof wn||e&&"closed"in e&&vn(e.remove)&&vn(e.add)&&vn(e.unsubscribe)}function Sn(e){vn(e)?e():e.unsubscribe()}var Cn={Promise:void 0},_n=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,pn([e,t],dn(r)))};function Dn(e){_n(function(){throw e})}function Pn(){}function Nn(e){e()}var On=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Ln(t)&&t.add(r)):r.destination=Tn,r}return an(t,e),t.create=function(e,t,r){return new $n(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(wn),An=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Rn(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Rn(e)}else Rn(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Rn(e)}},e}(),$n=function(e){function t(t,r,n){var i,o=e.call(this)||this;return i=vn(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,o.destination=new An(i),o}return an(t,e),t}(On);function Rn(e){Dn(e)}var Tn={closed:!0,next:Pn,error:function(e){throw e},complete:Pn},xn="function"==typeof Symbol&&Symbol.observable||"@@observable";function kn(e){return e}var Fn=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,i=this,o=(n=e)&&n instanceof On||function(e){return e&&vn(e.next)&&vn(e.error)&&vn(e.complete)}(n)&&Ln(n)?e:new $n(e,t,r);return Nn(function(){var e=i,t=e.operator,r=e.source;o.add(t?t.call(o,r):r?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Un(t))(function(t,n){var i=new $n({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});r.subscribe(i)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[xn]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?kn:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Un(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function Un(e){var t;return null!==(t=null!=e?e:Cn.Promise)&&void 0!==t?t:Promise}function Bn(e){return function(t){if(function(e){return vn(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function Mn(e,t,r,n,i){return new Gn(e,t,r,n,i)}var Gn=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return an(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(On),jn=yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),zn=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return an(t,e),t.prototype.lift=function(e){var t=new Hn(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new jn},t.prototype.next=function(e){var t=this;Nn(function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=fn(t.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(e)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}})},t.prototype.error=function(e){var t=this;Nn(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}})},t.prototype.complete=function(){var e=this;Nn(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?In:(this.currentObservers=null,o.push(e),new wn(function(){t.currentObservers=null,bn(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new Fn;return e.source=this,e},t.create=function(e,t){return new Hn(e,t)},t}(Fn),Hn=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return an(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:In},t}(zn),qn=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return an(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(zn),Vn={now:function(){return(Vn.delegate||Date).now()},delegate:void 0},Wn=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Vn);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return an(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),a=0,c=1;c<n.length&&n[c]<=s;c+=2)a=c;a&&n.splice(0,a+1)}},t}(zn),Zn=function(e){function t(t,r){return e.call(this)||this}return an(t,e),t.prototype.schedule=function(e,t){return this},t}(wn),Kn=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,pn([e,t],dn(r)))},Yn=function(e){return clearInterval(e)},Xn=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return an(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),Kn(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&Yn(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,bn(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Zn),Jn=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Vn.now,e}(),Qn=function(e){function t(t,r){void 0===r&&(r=Jn.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return an(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(Jn),ei=new Qn(Xn),ti=ei,ri=new Fn(function(e){return e.complete()});function ni(e){return e&&vn(e.schedule)}function ii(e){return e[e.length-1]}var oi=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function si(e){return vn(null==e?void 0:e.then)}function ai(e){return vn(e[xn])}function ci(e){return Symbol.asyncIterator&&vn(null==e?void 0:e[Symbol.asyncIterator])}function li(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var ui="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function fi(e){return vn(null==e?void 0:e[ui])}function di(e){return mn(this,arguments,function(){var t,r,n;return un(this,function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,hn(t.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,hn(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,hn(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function pi(e){return vn(null==e?void 0:e.getReader)}function hi(e){if(e instanceof Fn)return e;if(null!=e){if(ai(e))return i=e,new Fn(function(e){var t=i[xn]();if(vn(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(oi(e))return n=e,new Fn(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()});if(si(e))return r=e,new Fn(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Dn)});if(ci(e))return mi(e);if(fi(e))return t=e,new Fn(function(e){var r,n;try{for(var i=fn(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()});if(pi(e))return mi(di(e))}var t,r,n,i;throw li(e)}function mi(e){return new Fn(function(t){(function(e,t){var r,n,i,o;return ln(this,void 0,void 0,function(){var s,a;return un(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=gn(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(s=n.value,t.next(s),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function gi(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function vi(e,t){return void 0===t&&(t=0),Bn(function(r,n){r.subscribe(Mn(n,function(r){return gi(n,e,function(){return n.next(r)},t)},function(){return gi(n,e,function(){return n.complete()},t)},function(r){return gi(n,e,function(){return n.error(r)},t)}))})}function yi(e,t){return void 0===t&&(t=0),Bn(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function Ei(e,t){if(!e)throw new Error("Iterable cannot be null");return new Fn(function(r){gi(r,t,function(){var n=e[Symbol.asyncIterator]();gi(r,t,function(){n.next().then(function(e){e.done?r.complete():r.next(e.value)})},0,!0)})})}function bi(e,t){if(null!=e){if(ai(e))return function(e,t){return hi(e).pipe(yi(t),vi(t))}(e,t);if(oi(e))return function(e,t){return new Fn(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}(e,t);if(si(e))return function(e,t){return hi(e).pipe(yi(t),vi(t))}(e,t);if(ci(e))return Ei(e,t);if(fi(e))return function(e,t){return new Fn(function(r){var n;return gi(r,t,function(){n=e[ui](),gi(r,t,function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)},0,!0)}),function(){return vn(null==n?void 0:n.return)&&n.return()}})}(e,t);if(pi(e))return function(e,t){return Ei(di(e),t)}(e,t)}throw li(e)}function wi(e,t){return t?bi(e,t):hi(e)}function Ii(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ni(ii(e))?e.pop():void 0}(e);return wi(e,r)}var Li=yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Si(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o,s=!1;e.subscribe({next:function(e){o=e,s=!0},error:i,complete:function(){s?n(o):r?n(t.defaultValue):i(new Li)}})})}function Ci(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o=new $n({next:function(e){n(e),o.unsubscribe()},error:i,complete:function(){r?n(t.defaultValue):i(new Li)}});e.subscribe(o)})}function _i(e){return e instanceof Date&&!isNaN(e)}var Di=yn(function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function Pi(e){throw new Di(e)}function Ni(e,t){return Bn(function(r,n){var i=0;r.subscribe(Mn(n,function(r){n.next(e.call(t,r,i++))}))})}var Oi=Array.isArray;function Ai(e){return Ni(function(t){return function(e,t){return Oi(t)?e.apply(void 0,pn([],dn(t))):e(t)}(e,t)})}function $i(e,t,r,n,i,o,s,a){var c=[],l=0,u=0,f=!1,d=function(){!f||c.length||l||t.complete()},p=function(e){return l<n?h(e):c.push(e)},h=function(e){o&&t.next(e),l++;var a=!1;hi(r(e,u++)).subscribe(Mn(t,function(e){null==i||i(e),o?p(e):t.next(e)},function(){a=!0},void 0,function(){if(a)try{l--;for(var e=function(){var e=c.shift();s||h(e)};c.length&&l<n;)e();d()}catch(e){t.error(e)}}))};return e.subscribe(Mn(t,p,function(){f=!0,d()})),function(){null==a||a()}}function Ri(e,t,r){return void 0===r&&(r=1/0),vn(t)?Ri(function(r,n){return Ni(function(e,i){return t(r,e,n,i)})(hi(e(r,n)))},r):("number"==typeof t&&(r=t),Bn(function(t,n){return $i(t,n,e,r)}))}var Ti=["addListener","removeListener"],xi=["addEventListener","removeEventListener"],ki=["on","off"];function Fi(e,t,r,n){if(vn(r)&&(n=r,r=void 0),n)return Fi(e,t,r).pipe(Ai(n));var i=dn(function(e){return vn(e.addEventListener)&&vn(e.removeEventListener)}(e)?xi.map(function(n){return function(i){return e[n](t,i,r)}}):function(e){return vn(e.addListener)&&vn(e.removeListener)}(e)?Ti.map(Ui(e,t)):function(e){return vn(e.on)&&vn(e.off)}(e)?ki.map(Ui(e,t)):[],2),o=i[0],s=i[1];if(!o&&oi(e))return Ri(function(e){return Fi(e,t,r)})(hi(e));if(!o)throw new TypeError("Invalid event target");return new Fn(function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.next(1<t.length?t:t[0])};return o(t),function(){return s(t)}})}function Ui(e,t){return function(r){return function(n){return e[r](t,n)}}}function Bi(e,t,r){void 0===e&&(e=0),void 0===r&&(r=ti);var n=-1;return null!=t&&(ni(t)?r=t:n=t),new Fn(function(t){var i=_i(e)?+e-r.now():e;i<0&&(i=0);var o=0;return r.schedule(function(){t.closed||(t.next(o++),0<=n?this.schedule(void 0,n):t.complete())},i)})}function Mi(e,t){return Bn(function(r,n){var i=0;r.subscribe(Mn(n,function(r){return e.call(t,r,i++)&&n.next(r)}))})}function Gi(e){return Bn(function(t,r){var n,i=null,o=!1;i=t.subscribe(Mn(r,void 0,void 0,function(s){n=hi(e(s,Gi(e)(t))),i?(i.unsubscribe(),i=null,n.subscribe(r)):o=!0})),o&&(i.unsubscribe(),i=null,n.subscribe(r))})}function ji(e,t,r,n,i){return function(o,s){var a=r,c=t,l=0;o.subscribe(Mn(s,function(t){var r=l++;c=a?e(c,t,r):(a=!0,t),n&&s.next(c)},i&&function(){a&&s.next(c),s.complete()}))}}function zi(e,t){return Bn(ji(e,t,arguments.length>=2,!1,!0))}function Hi(e){return Bn(function(t,r){var n=!1;t.subscribe(Mn(r,function(e){n=!0,r.next(e)},function(){n||r.next(e),r.complete()}))})}function qi(e,t){return void 0===t&&(t=kn),e=null!=e?e:Vi,Bn(function(r,n){var i,o=!0;r.subscribe(Mn(n,function(r){var s=t(r);!o&&e(i,s)||(o=!1,i=s,n.next(r))}))})}function Vi(e,t){return e===t}function Wi(e){return void 0===e&&(e=Zi),Bn(function(t,r){var n=!1;t.subscribe(Mn(r,function(e){n=!0,r.next(e)},function(){return n?r.complete():r.error(e())}))})}function Zi(){return new Li}function Ki(e){return Bn(function(t,r){try{t.subscribe(r)}finally{r.add(e)}})}function Yi(e,t){var r=arguments.length>=2;return function(e){return e.pipe(kn,(n=1)<=0?function(){return ri}:Bn(function(e,t){var r=[];e.subscribe(Mn(t,function(e){r.push(e),n<r.length&&r.shift()},function(){var e,n;try{for(var i=fn(r),o=i.next();!o.done;o=i.next()){var s=o.value;t.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}t.complete()},void 0,function(){r=null}))}),r?Hi(t):Wi(function(){return new Li}));var n}}function Xi(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var i=new $n({next:function(){i.unsubscribe(),e()}});return hi(t.apply(void 0,pn([],dn(r)))).subscribe(i)}}else e()}function Ji(e,t){return Bn(function(r,n){var i=null,o=0,s=!1,a=function(){return s&&!i&&n.complete()};r.subscribe(Mn(n,function(r){null==i||i.unsubscribe();var s=0,c=o++;hi(e(r,c)).subscribe(i=Mn(n,function(e){return n.next(t?t(r,e,c,s++):e)},function(){i=null,a()}))},function(){s=!0,a()}))})}function Qi(e){return Bn(function(t,r){hi(e).subscribe(Mn(r,function(){return r.complete()},Pn)),!r.closed&&t.subscribe(r)})}function eo(e,t,r){var n=vn(e)||t||r?{next:e,error:t,complete:r}:e;return n?Bn(function(e,t){var r;null===(r=n.subscribe)||void 0===r||r.call(n);var i=!0;e.subscribe(Mn(t,function(e){var r;null===(r=n.next)||void 0===r||r.call(n,e),t.next(e)},function(){var e;i=!1,null===(e=n.complete)||void 0===e||e.call(n),t.complete()},function(e){var r;i=!1,null===(r=n.error)||void 0===r||r.call(n,e),t.error(e)},function(){var e,t;i&&(null===(e=n.unsubscribe)||void 0===e||e.call(n)),null===(t=n.finalize)||void 0===t||t.call(n)}))}):kn}function to(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r,n=vn(ii(r=e))?r.pop():void 0;return Bn(function(t,r){for(var i=e.length,o=new Array(i),s=e.map(function(){return!1}),a=!1,c=function(t){hi(e[t]).subscribe(Mn(r,function(e){o[t]=e,a||s[t]||(s[t]=!0,(a=s.every(kn))&&(s=null))},Pn))},l=0;l<i;l++)c(l);t.subscribe(Mn(r,function(e){if(a){var t=pn([e],dn(o));r.next(n?n.apply(void 0,pn([],dn(t))):t)}}))})}const ro=(e,t,r)=>{const n="string"==typeof t?t.split("."):t,i=n.shift();return i&&(e[i]??={},n.length?ro(e[i],n,r):Object.assign(e,{[i]:r})),e};class no{#ne={};createConfig(e,t){return wi(this._createConfig(e,t))}async createConfigAsync(e,t){return Si(this.createConfig(e,t))}_set(e,t){const r="function"==typeof t?t:async()=>t;this.#ne[e]=r}_get(e){return this.#ne[e]}_has(e){return e in this.#ne}_createConfig(e,t){return wi(this._buildConfig(e,t)).pipe(Ji(t=>this._processConfig(t,e)))}_buildConfig(e,t){return wi(Object.entries(this.#ne)).pipe(Ri(([t,r])=>wi(r(e)).pipe(Mi(e=>void 0!==e),Ni(e=>({target:t,value:e})),Gi(e=>(console.error(`Failed to execute config callback: ${r.name} for attribute: '${t}'`,e),ri)))),zi((e,{target:t,value:r})=>ro(e,t,r),t??{}))}_processConfig(e,t){return Ii(e)}}class io extends Error{constructor(){super("Module initialization timed out"),this.name="RequiredModuleTimeoutError"}}const oo="ModuleConfigurator",so={ModuleConfigAdded:`${oo}.module.configAdded`,PreparedConfigReplaced:`${oo}.module.preparedConfigReplaced`,OnConfiguredAdded:`${oo}.onConfigured.added`,OnInitializedAdded:`${oo}.onInitialized.added`,PluginAdded:`${oo}.plugin.added`,InitializeConfigLoaded:`${oo}.config.loaded`,InitializeInstanceInitialized:`${oo}.instance.initialized`,Initialize:`${oo}.initialize.complete`,HostInitializeStarted:`${oo}.host.initializeStarted`,HostInitialized:`${oo}.host.initialized`,HostInitializeError:`${oo}.host.initializeError`,ConfiguratorCreated:`${oo}.configurator.created`,ConfiguratorPrepared:`${oo}.configurator.prepared`,ConfiguratorPrepareError:`${oo}.configurator.prepareError`,ConfiguratorFailed:`${oo}.configurator.failed`,ModulePostConfigured:`${oo}.module.postConfigured`,ModulePostConfigureError:`${oo}.module.postConfigureError`,PostConfigureHooks:`${oo}.postConfigureHooks.started`,PostConfigureHooksComplete:`${oo}.postConfigureHooks.complete`,PostConfigureHooksError:`${oo}.postConfigureHooks.error`,ModuleInitializeError:`${oo}.module.initializeError`,ModuleInitializing:`${oo}.module.initializing`,ProviderNotBaseModuleProvider:`${oo}.provider.invalidBase`,ProviderVersionWarning:`${oo}.provider.versionMissing`,ModuleInitialized:`${oo}.module.initialized`,RequireInstanceModuleNotDefined:`${oo}.requireInstance.moduleNotDefined`,RequireInstanceModuleAlreadyInitialized:`${oo}.requireInstance.moduleAlreadyInitialized`,RequireInstanceAwaitingModule:`${oo}.requireInstance.awaitingModule`,RequireInstanceTimeout:`${oo}.requireInstance.timeout`,RequireInstanceModuleResolved:`${oo}.requireInstance.moduleResolved`,ModuleInitializeComplete:`${oo}.modules.initializeComplete`,InitializeComplete:`${oo}.initialize.instanceComplete`,ConfiguratorPostInitializeStart:`${oo}.postInitialize.started`,ModulePostInitializeStart:`${oo}.modulePostInitialize.started`,ModulePostInitializeComplete:`${oo}.modulePostInitialize.complete`,ModulePostInitializeError:`${oo}.modulePostInitialize.error`,PostInitializeComplete:`${oo}.postInitialize.complete`,PostInitializeCompleteNoHooks:`${oo}.postInitialize.noHooks`,PostInitializeHooks:`${oo}.postInitializeHooks.started`,PostInitializeHooksComplete:`${oo}.postInitializeHooks.complete`,PostInitializeHooksError:`${oo}.postInitializeHooks.error`,PluginsRegister:`${oo}.plugins.registering`,PluginRegistered:`${oo}.plugin.registered`,PluginRegisterError:`${oo}.plugin.registerError`,PluginsRegistered:`${oo}.plugins.registered`,Dispose:`${oo}.dispose.started`,PluginsDisposing:`${oo}.plugins.disposing`,PluginDisposed:`${oo}.plugin.disposed`,PluginDisposeError:`${oo}.plugin.disposeError`,ModulesDispose:`${oo}.modules.disposing`,ModuleDisposed:`${oo}.module.disposed`,ModuleDisposeError:`${oo}.module.disposeError`,ModulesDisposed:`${oo}.modules.disposed`};var ao;async function co(e,t){const r=await async function(e,t){const{modules:r,afterConfiguration:n,afterInit:i,registerEvent:o}=e;return Si(wi(r).pipe(Ri(async r=>{const n=performance.now();try{const i=e.configurators?.has(r)?e.configurators.get(r):await(r.configure?.(t)),s=Math.round(performance.now()-n);return o({level:ao.Debug,name:so.ConfiguratorCreated,message:`Configurator created for ${r.name} in ${s}ms`,properties:{moduleName:r.name,moduleVersion:r.version?.toString()||"unknown",configLoadTime:s},metric:s}),{[r.name]:i}}catch(e){throw o({level:ao.Error,name:so.ConfiguratorFailed,message:`Failed to create configurator for ${r.name}`,properties:{moduleName:r.name,moduleVersion:r.version?.toString()||"unknown"},metric:Math.round(performance.now()-n),error:e}),e}}),zi((e,t)=>Object.assign(e,t),{onAfterConfiguration(e){n.push(e)},onAfterInit(e){i.push(e)}})))}(e,t);return await Promise.all(e.configs.map(e=>Promise.resolve(e(r,t)))),await async function(e,t){const{modules:r,afterConfiguration:n,registerEvent:i}=e;if(await Promise.allSettled(r.filter(e=>!!e.postConfigure).map(async e=>{try{const r=performance.now();await(e.postConfigure?.(t)),i({level:ao.Debug,name:so.ModulePostConfigured,message:`Module ${e.name} post-configured successfully`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown",postConfigTime:Math.round(performance.now()-r)}})}catch(t){i({level:ao.Warning,name:so.ModulePostConfigureError,message:`Module ${e.name} post-configure failed`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t})}})),n.length)try{i({level:ao.Debug,name:so.PostConfigureHooks,message:`Post configure hooks [${n.length}] called`});const e=performance.now();await Promise.allSettled(n.map(e=>Promise.resolve(e(t))));const r=Math.round(performance.now()-e);i({level:ao.Debug,name:so.PostConfigureHooksComplete,message:"Post configure hooks complete",properties:{count:n.length,postConfigHooksTime:r},metric:r})}catch(e){i({level:ao.Warning,name:so.PostConfigureHooksError,message:"Post configure hook failed",error:e})}}(e,r),r}function lo(e,t){if(null!==e&&("object"==typeof e||"function"==typeof e)&&"then"in e&&"function"==typeof e.then)throw Promise.resolve(e).catch(()=>console.warn(`Asynchronous preparation failed for module "${t}"`)),new TypeError(`Preparation for module "${t}" must be synchronous`)}!function(e){e[e.Debug=0]="Debug",e[e.Information=1]="Information",e[e.Warning=2]="Warning",e[e.Error=3]="Error",e[e.Critical=4]="Critical"}(ao||(ao={}));class uo{static[Symbol.hasInstance](e){if(null!==e&&"object"==typeof e&&"version"in e&&"dispose"in e){const t=e,r=O(String(t.version)),n=t.dispose;return!!r&&"function"==typeof n}return!1}#ie;#oe;get version(){return this.#ie}constructor(e){const{version:t}=e;this.#ie=new nn(t),this.#oe=new wn}_addTeardown(e){return this.#oe.add(e),()=>this.#oe.remove(e)}dispose(){this.#oe.unsubscribe()}}function fo(e,t,r){return function(n,i=60){if(!e.includes(n)){const e=new Error(`Cannot require [${String(n)}] since module is not defined!`);throw e.name="ModuleNotDefinedError",r({level:ao.Error,name:so.RequireInstanceModuleNotDefined,message:e.message,properties:{moduleName:String(n),wait:i},error:e}),e}if(t.value[n])return r({level:ao.Debug,name:so.RequireInstanceModuleAlreadyInitialized,message:`Module [${String(n)}] is already initialized, skipping queue`,properties:{moduleName:String(n),wait:i}}),Promise.resolve(t.value[n]);const o=performance.now();return r({level:ao.Debug,name:so.RequireInstanceAwaitingModule,message:`Awaiting module [${String(n)}] initialization, timeout ${i}s`,properties:{moduleName:String(n),wait:i}}),Ci(t.pipe(Mi(e=>!!e[n]),Ni(e=>e[n]),function(e){var t=_i(e)?{first:e}:"number"==typeof e?{each:e}:e,r=t.first,n=t.each,i=t.with,o=void 0===i?Pi:i,s=t.scheduler,a=void 0===s?ei:s,c=t.meta,l=void 0===c?null:c;if(null==r&&null==n)throw new TypeError("No timeout provided.");return Bn(function(e,t){var i,s,c=null,u=0,f=function(e){s=gi(t,a,function(){try{i.unsubscribe(),hi(o({meta:l,lastValue:c,seen:u})).subscribe(t)}catch(e){t.error(e)}},e)};i=e.subscribe(Mn(t,function(e){null==s||s.unsubscribe(),u++,t.next(c=e),n>0&&f(n)},void 0,void 0,function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),c=null})),!u&&f(null!=r?"number"==typeof r?r:+r-a.now():n)})}({each:1e3*i,with:()=>{return t=vn(e=()=>{const e=new io;return r({level:ao.Error,name:so.RequireInstanceTimeout,message:`Module [${String(n)}] initialization timed out after ${i}s`,properties:{moduleName:String(n),wait:i},error:e}),e})?e:function(){return e},new Fn(function(e){return e.error(t())});var e,t}}),eo(()=>{const e=Math.round(performance.now()-o);r({level:ao.Debug,name:so.RequireInstanceModuleResolved,message:`Module [${String(n)}] required in ${e}ms`,properties:{moduleName:String(n),wait:i,requireTime:e},metric:e})})))}}async function po(e,t,r){const{modules:n,registerEvent:i,instances:o={},onLateProvider:s}=e;if(0===n.length)return Object.seal(o);const a=n.map(e=>e.name),c=new qn({}),l=e=>a.includes(e),u=fo(a,c,i),f=performance.now();let d=!1;const p=n.map(async e=>{const[n,a]=await async function(e,t){const{config:r,ref:n,requireInstance:i,hasModule:o,registerEvent:s}=t,a=e.name,c=performance.now();if(!e.initialize){const t=new Error(`Module ${e.name} does not have initialize method`);throw t.name="ModuleInitializeError",s({level:ao.Error,name:so.ModuleInitializeError,message:t.message,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t,metric:performance.now()-c}),t}let l;s({level:ao.Debug,name:so.ModuleInitializing,message:`Initializing module ${e.name}`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}});try{l=await e.initialize({ref:n,config:r[a],requireInstance:i,hasModule:o})}catch(t){throw s({level:ao.Error,name:so.ModuleInitializeError,message:"Module initialization failed",properties:{moduleName:e.name},metric:performance.now()-c,error:t}),t}l instanceof uo||s({level:ao.Warning,name:so.ProviderNotBaseModuleProvider,message:`Provider for module ${e.name} does not extend BaseModuleProvider`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}});const u=l;u.version||s({level:ao.Warning,name:so.ProviderVersionWarning,message:`Provider for module ${e.name} does not expose version`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}});const f=Math.round(performance.now()-c);return s({level:ao.Debug,name:so.ModuleInitialized,message:`Module ${e.name} initialized in ${f}ms`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown",providerName:typeof l,providerVersion:u.version?.toString()||"unknown",moduleInitTime:f},metric:f}),[a,l]}(e,{config:t,ref:r,requireInstance:u,hasModule:l,registerEvent:i});d?s?.(e,a):(o[n]=a,c.next({...o}))});try{await Promise.all(p)}catch(e){throw d=!0,c.error(e),e}c.complete();const h=Math.round(performance.now()-f);return i({level:ao.Debug,name:so.ModuleInitializeComplete,message:"All modules initialized",properties:{modules:Object.keys(o).join(", "),loadTime:h},metric:h}),i({level:ao.Debug,name:so.InitializeComplete,message:`Modules instance created in ${h}ms`,properties:{modules:Object.keys(o).join(", "),initTime:h},metric:h}),Object.seal(o),o}const ho=["default","diagnostics","events"];function mo(e){return"function"==typeof e?e.name||"anonymous":"dispose"}async function go(e){"function"!=typeof e?await e.dispose():await e()}async function vo(e,t,r){const{modules:n,registerEvent:i,event$:o,pluginTeardowns:s=[]}=e,a=performance.now();let c=!1;if(i({level:ao.Debug,name:so.Dispose,message:"Disposing modules instance",properties:{modules:Object.keys(t).join(", ")}}),s.length){i({level:ao.Debug,name:so.PluginsDisposing,message:`Disposing plugins [${s.length}]`,properties:{count:s.length}});for(const e of s.splice(0).reverse()){const t=mo(e);try{await go(e),i({level:ao.Debug,name:so.PluginDisposed,message:`Plugin ${t} disposed successfully`,properties:{name:t}})}catch(e){c=!0,i({level:ao.Warning,name:so.PluginDisposeError,message:`Plugin ${t} dispose failed`,properties:{name:t},error:e})}}}i({level:ao.Debug,name:so.ModulesDispose,message:"Disposing modules",properties:{count:n.length}});const l={default:[],diagnostics:[],events:[]};for(const e of n){const t=e.disposePhase??"default";ho.includes(t)?l[t].push(e):(c=!0,i({level:ao.Warning,name:so.ModulesDispose,message:`Unsupported disposal phase for module ${e.name}; disposing during the default phase`,properties:{moduleName:e.name},error:new TypeError("Unsupported module disposal phase")}),l.default.push(e))}for(const e of ho)await Promise.allSettled(l[e].filter(e=>!!e.dispose).map(async e=>{if(!e.dispose)return;const n=performance.now();try{await e.dispose({ref:r,modules:t,instance:t[e.name]}),i({level:ao.Debug,name:so.ModuleDisposed,metric:performance.now()-n,message:`Module ${e.name} disposed successfully`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}})}catch(t){c=!0,i({level:ao.Warning,name:so.ModuleDisposeError,metric:performance.now()-n,message:`Module ${e.name} dispose failed`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t})}})),"default"===e&&i({level:c?ao.Warning:ao.Information,name:so.ModulesDisposed,message:"Default module disposal complete; flushing lifecycle sinks",metric:performance.now()-a,properties:{count:n.length,failed:c}});o.complete()}class yo{static className="ModulesConfigurator";get version(){return"6.2.0-next.0"}#se=new Wn(100);#ae=new WeakMap;#ce=new Map;get event$(){return this.#se.asObservable()}_configs=[];_afterConfiguration=[];_afterInit=[];_plugins=[];_pluginTeardowns=[];#le=new WeakMap;_modules;constructor(e){this._modules=new Set(e?this._dedupeModulesByName(e):[])}_dedupeModulesByName(e){const t=new Map;for(const r of e)t.set(r.name,r);return Array.from(t.values())}_removeModuleCallbacks(e){this._configs=this._configs.filter(t=>t.moduleName!==e),this._afterConfiguration=this._afterConfiguration.filter(t=>t.moduleName!==e),this._afterInit=this._afterInit.filter(t=>t.moduleName!==e)}get modules(){return[...this._modules]}configure(...e){for(const t of e)this.addConfig(t)}addConfig(e){const{module:t,afterConfig:r,afterInit:n,configure:i}=e,o=function(e){const{registration:t,configurators:r,registerEvent:n}=e,{module:i,configurator:o,prepare:s}=t;if(void 0!==o||s)try{let e=o??r.get(i);if(void 0===e){if(!i.prepare)throw new TypeError(`Module "${i.name}" requires a prepare factory or an explicit configurator for preparation`);e=i.prepare(),lo(e,i.name)}return s&&lo(s(e),i.name),n({level:ao.Debug,name:so.ConfiguratorPrepared,message:`Configuration prepared for ${i.name}`,properties:{moduleName:i.name}}),{configurator:e}}catch(e){throw n({level:ao.Error,name:so.ConfiguratorPrepareError,message:`Configuration preparation failed for ${i.name}`,properties:{moduleName:i.name},error:e}),e}}({registration:e,configurators:this.#ce,registerEvent:e=>this._registerEvent(e)}),s=Array.from(this._modules).find(e=>e.name===t.name);if(s){if(s!==t){this.#ce.has(s)&&(console.warn(`Prepared configuration for module "${t.name}" was replaced`),this._registerEvent({level:ao.Warning,name:so.PreparedConfigReplaced,message:`Prepared configuration for module ${t.name} was replaced by a different descriptor`,properties:{moduleName:t.name}})),this._removeModuleCallbacks(t.name),this.#ce.delete(s);const e=Array.from(this._modules).map(e=>e.name===t.name?t:e);this._modules=new Set(e)}}else this._modules.add(t);if(o&&this.#ce.set(t,o.configurator),this._registerEvent({level:ao.Debug,name:so.ModuleConfigAdded,message:`Module configurator added for ${t.name}`,properties:{moduleName:t.name,moduleVersion:t.version?.toString()||"unknown",configure:!!i,afterConfig:!!r,afterInit:!!n}}),i){const e=(e,r)=>i(e[t.name],r);e.moduleName=t.name,this._configs.push(e)}if(r){const e=e=>r(e[t.name]);e.moduleName=t.name,this._afterConfiguration.push(e)}if(n){const e=e=>n(e[t.name]);e.moduleName=t.name,this._afterInit.push(e)}}onConfigured(e){this._afterConfiguration.push(e),this._registerEvent({level:ao.Debug,name:so.OnConfiguredAdded,message:"Added onConfigured callback",properties:{count:this._afterConfiguration.length,name:e.name||"anonymous"}})}onInitialized(e){this._afterInit.push(e),this._registerEvent({level:ao.Debug,name:so.OnInitializedAdded,message:"Added onInitialized callback",properties:{count:this._afterInit.length,name:e.name||"anonymous"}})}registerPlugin(e){this._plugins.push(e),this._registerEvent({level:ao.Debug,name:so.PluginAdded,message:"Added plugin callback",properties:{count:this._plugins.length,name:e.name||"anonymous"}})}async initialize(e){const t=performance.now(),r={},n=[];this._registerEvent({level:ao.Debug,name:so.HostInitializeStarted,message:"Starting host initialization"});try{const i=await this._initializeModules(r,n,e);return this._registerEvent({level:ao.Information,name:so.HostInitialized,message:"Host initialized",metric:performance.now()-t}),i}catch(i){this._registerEvent({level:ao.Error,name:so.HostInitializeError,message:"Host initialization failed",metric:performance.now()-t,error:i});try{const t=this.modules.filter(e=>Object.hasOwn(r,e.name));await vo({modules:t,registerEvent:this._registerEvent.bind(this),event$:this.#se,pluginTeardowns:n},r,e)}catch{console.warn("Module initialization rollback failed")}throw i}}async _initializeModules(e,t,r){const n=performance.now(),i=await this._configure(r),o=Math.round(performance.now()-n),s=this.modules.map(e=>e.name).join(", ");this._registerEvent({level:ao.Debug,name:so.InitializeConfigLoaded,message:`Modules configured in ${o}ms`,properties:{modules:s,count:this.modules.length,loadTime:o},metric:o});const a=performance.now(),c=await this._initialize(i,r,e),l=Math.round(performance.now()-a),u=this.modules.map(e=>e.name).join(", ");this._registerEvent({level:ao.Debug,name:so.InitializeInstanceInitialized,message:`Modules initialized in ${l}ms`,properties:{modules:u,count:this.modules.length,loadTime:l},metric:l});const f=o+l,d=this.modules.map(e=>e.name).join(", ");this._registerEvent({level:ao.Information,name:so.Initialize,message:`initialize in ${f}ms`,properties:{modules:d,configLoadTime:o,instanceLoadTime:l,totalLoadTime:f},metric:f}),await this._postInitialize(c,r);const p=Object.seal(Object.assign({},c,{dispose:()=>this.dispose(p)}));return this.#le.set(p,t),await this._registerPlugins(p,r,t),p}_registerEvent(e){const t=e.name.split("::");this.#se.next({...e,name:`${this.constructor.className}::${t[t.length-1]}`})}async _configure(e){return co({modules:this.modules,configurators:this.#ce,configs:this._configs,afterConfiguration:this._afterConfiguration,afterInit:this._afterInit,registerEvent:this._registerEvent.bind(this)},e)}async _initialize(e,t,r={}){return po({modules:this.modules,registerEvent:this._registerEvent.bind(this),instances:r,onLateProvider:(e,r)=>{yo.#ue(e,r,t)}},e,t)}static async#ue(e,t,r){try{await(e.dispose?.({ref:r,modules:{[e.name]:t},instance:t}))}catch{console.warn("Module initialization rollback failed")}}async _postInitialize(e,t){return async function(e,t,r){const{modules:n,afterInit:i,registerEvent:o}=e;o({level:ao.Debug,name:so.ConfiguratorPostInitializeStart,message:`Post-initializing all modules [${Object.keys(t).length}]`,properties:{modules:Object.keys(t).join(", ")}});const s=wi(n).pipe(Mi(e=>!!e.postInitialize),eo(e=>{o({level:ao.Debug,name:so.ModulePostInitializeStart,message:`Module ${e.name} is being post-initialized`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}})}),Ri(e=>{const n=performance.now();return wi(e.postInitialize({ref:r,modules:t,instance:t[e.name]})).pipe(eo(()=>{const t=Math.round(performance.now()-n);o({level:ao.Debug,name:so.ModulePostInitializeComplete,message:`Module ${e.name} has been post-initialized in ${t}ms`,metric:t,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown",postInitTime:t}})}),Hi(null),Gi(t=>(o({level:ao.Warning,name:so.ModulePostInitializeError,message:`Module ${e.name} post-initialize failed`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t}),ri)))}),Hi(null)),a=performance.now();await Si(s);const c=Math.round(performance.now()-a);if(o({level:ao.Debug,name:so.PostInitializeComplete,message:`Post-initialization of all modules completed in ${c}ms`,properties:{modules:Object.keys(t).join(", "),postInitTime:c},metric:c}),!i.length)return void o({level:ao.Debug,name:so.PostInitializeCompleteNoHooks,message:"Post-initialization complete",properties:{modules:Object.keys(t).join(", "),postInitCompleteTime:c}});try{const e=i.map(e=>e.name||"anonymous").join(", ");o({level:ao.Debug,name:so.PostInitializeHooks,message:`Executing post-initialize hooks [${i.length}]`,properties:{hooks:e}});const r=performance.now();await Promise.allSettled(i.map(e=>Promise.resolve(e(t))));const n=Math.round(performance.now()-r);o({level:ao.Debug,name:so.PostInitializeHooksComplete,message:`Post-initialize hooks completed in ${n}ms`,properties:{hooks:e,afterInitTime:n},metric:n})}catch(e){const t=i.map(e=>e.name||"anonymous").join(", ");o({level:ao.Warning,name:so.PostInitializeHooksError,message:"Post-initialize hooks failed",properties:{hooks:t},error:e})}const l=Math.round(performance.now()-a);o({level:ao.Debug,name:so.PostInitializeComplete,message:"Post-initialization complete",properties:{modules:Object.keys(t).join(", "),postInitCompleteTime:l}})}({modules:this.modules,afterInit:this._afterInit,registerEvent:this._registerEvent.bind(this)},e,t)}async _registerPlugins(e,t,r=this._pluginTeardowns){return async function(e,t,r){const{plugins:n,teardowns:i,registerEvent:o}=e;if(!n.length)return;o({level:ao.Debug,name:so.PluginsRegister,message:`Registering plugins [${n.length}]`,properties:{count:n.length}});const s=await Promise.all(n.map(async e=>{const n=performance.now(),i=e.name||"anonymous";try{const a=await e({modules:t,ref:r}),c=Math.round(performance.now()-n);return o({level:ao.Debug,name:so.PluginRegistered,message:`Plugin ${i} registered in ${c}ms`,properties:{name:i,pluginTime:c},metric:c}),"function"==typeof(s=a)||"object"==typeof s&&null!==s&&"dispose"in s&&"function"==typeof s.dispose?a:void 0}catch(e){return void o({level:ao.Warning,name:so.PluginRegisterError,message:`Plugin ${i} registration failed`,properties:{name:i},error:e})}var s}));for(const e of s)e&&i.push(e);o({level:ao.Debug,name:so.PluginsRegistered,message:"Plugin registration complete",properties:{count:n.length,teardowns:i.length}})}({plugins:this._plugins,teardowns:r,registerEvent:this._registerEvent.bind(this)},e,t)}dispose(e,t){let r=this.#ae.get(e);if(!r){const n=[...this.#le.get(e)?.splice(0)??[],...this._pluginTeardowns.splice(0)];r=vo({modules:this.modules,registerEvent:this._registerEvent.bind(this),event$:this.#se,pluginTeardowns:n},e,t),this.#ae.set(e,r)}return r}}class Eo{_operators;get operators(){return this._operators}constructor(e){this._operators=e&&"operators"in e?{...e.operators}:e??{}}add(e,t){if(Object.keys(this._operators).includes(e))throw Error(`Operator [${e}] already defined`);return this.set(e,t)}set(e,t){return this._operators[e]=t,this}remove(e){return delete this._operators[e],this}get(e){return this._operators[e]}process(e){return Object.values(this._operators).length?wi(Object.values(this._operators)).pipe((t=(e,t)=>Promise.resolve(t(e)).then(t=>t??e),r=e,n=1,Bn(function(e,i){var o=r;return $i(e,i,function(e,r){return t(o,e,r)},n,function(e){o=e},!1,void 0,function(){return o=null})})),Yi()):Ii(e);var t,r,n}}class bo extends Eo{setHeader(e,t){const r=((e,t)=>r=>{const n=new Headers(r.headers);return n.append(e,t),{...r,headers:n}})(e,t);return this.set(`header-${e}`,r)}}class wo extends Eo{}class Io{#fe;constructor(e){this.#fe=e?[...e.middleware]:[]}get middleware(){return this.#fe}use(e){return this.#fe.push(e),this}process(e,t,r){const n=this.#fe.reduceRight((e,t)=>(r,n)=>t(r,n,(t,r)=>function(e){return e instanceof Response?Promise.resolve(e):Ci(wi(e))}(e(t,r))),r),i=n(e,t);return i instanceof Response?Ii(i):wi(i)}}const Lo=x.object({attributionReporting:x.object({eventSourceEligible:x.boolean().optional(),triggerEligible:x.boolean().optional()}).optional(),body:x.union([x.string(),x.instanceof(Blob),x.instanceof(ArrayBuffer),x.instanceof(FormData),x.instanceof(URLSearchParams),x.instanceof(ReadableStream)]).optional(),browsingTopics:x.boolean().optional(),cache:x.enum(["default","no-store","reload","no-cache","force-cache","only-if-cached"]).optional(),credentials:x.enum(["omit","same-origin","include"]).optional(),headers:x.record(x.string(),x.string()).optional().or(x.instanceof(Headers)),integrity:x.string().optional(),keepalive:x.boolean().optional(),method:x.enum(["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD","CONNECT","TRACE"],{message:"Invalid request method. Expected one of: GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, CONNECT, TRACE. See RFC 2615 Section 9 for more information: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html"}).optional().optional(),mode:x.enum(["same-origin","cors","no-cors","navigate","websocket"]).optional(),priority:x.enum(["low","high","auto"]).optional(),redirect:x.enum(["follow","error","manual"]).optional(),referrer:x.string().optional(),referrerPolicy:x.enum(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]).optional(),signal:x.instanceof(AbortSignal).optional()}).extend({uri:x.string(),path:x.string().optional()}),So=e=>e=>{const{error:t,success:r,data:n}=x.string().optional().refine(e=>void 0===e||e===e?.toUpperCase(),{message:["Provided HTTP method must be in uppercase.","See RFC 7231 Section 4.1 for more information","https://www.rfc-editor.org/rfc/rfc7231#section-4.1"].join(" ")}).safeParse(e.method);if(e.method=r?n:e.method?.toUpperCase(),t)for(const e of t.issues)console.warn(e.message);return e},Co=e=>e=>{const{strict:t,parse:r}={},n=t?Lo:Lo.passthrough();try{const t=n.parse(e);return r?t:void 0}catch(e){if(r)throw e;console.error("Invalid request options",e.message)}},_o=e=>{try{return JSON.parse(e)}catch{return e}};function*Do(e,t){const r=e.split("\n\n"),n=t?.dataParser||_o;for(const e of r){if(!e.trim())continue;const t=e.split("\n").reduce((e,t)=>{if(!t)return e;const r=t.indexOf(":");if(-1===r)return e;const i=t.slice(0,r).trim(),o=t.slice(r+1).trim();return"data"===i?e.data=n(o):e[i]=o,e},{});Object.keys(t).length&&(yield t)}}const Po=e=>t=>{if(!t.ok)throw new Jr(`HTTP error! Status: ${t.status}`,t);if(!t.body)throw new Jr("Response body is not readable",t);if(!t.headers.get("Content-Type")?.includes("text/event-stream"))throw new Jr("Response is not a text/event-stream",t);const r=t.body.getReader();return wi(async function*(e,t){const r=!!t?.skipHeartbeats,n=t?.eventFilter?Array.isArray(t.eventFilter)?t.eventFilter:[t.eventFilter]:null,i=new TextDecoder;for(;;){const{done:o,value:s}=await e.read();if(o)break;const a=Do(i.decode(s,{stream:!0}),{dataParser:t?.dataParser});for(const e of a)if(e.retry)await new Promise(t=>setTimeout(t,Number.parseInt(e.retry??"300",10)));else{if(r){if(!e.event&&!e.data&&!e.id)continue;if(e.event&&["heartbeat","ping"].includes(e.event))continue}(!n||e.event&&n.includes(e.event))&&(yield e)}}}(r,{dataParser:e?.dataParser,skipHeartbeats:e?.skipHeartbeats,eventFilter:e?.eventFilter})).pipe(Qi(e?.abortSignal?Fi(e.abortSignal,"abort"):ri),Ki(async()=>{await r.cancel().catch(()=>{}),r.releaseLock()}))};class No{_clients={};get clients(){return{...this._clients}}defaultHttpClientCtor;defaultHttpRequestHandler=new bo({"capitalize-method":So(),"request-validation":Co()});defaultHttpMiddlewareHandler=new Io;constructor(e){this.defaultHttpClientCtor=e}hasClient(e){return Object.keys(this._clients).includes(e)}addMiddleware(e){return this.defaultHttpMiddlewareHandler.use(e),this}configureClient(e,t){const r="string"==typeof t?{baseUri:t}:t,n="function"==typeof r?{onCreate:r}:r;return this._clients[e]={...this._clients[e],...n},this}}const Oo=["http:","https:","ws:","wss:"];class Ao extends uo{config;get defaultHttpRequestHandler(){return this.config.defaultHttpRequestHandler}get defaultHttpMiddlewareHandler(){return this.config.defaultHttpMiddlewareHandler}constructor(e){super({version:"8.1.5-next.0",config:e}),this.config=e}hasClient(e){return Object.keys(this.config.clients).includes(e)}createClient(e){const t=this._resolveConfig(e),{baseUri:r,defaultScopes:n=[],onCreate:i,ctor:o=this.config.defaultHttpClientCtor,requestHandler:s=this.defaultHttpRequestHandler,responseHandler:a,middlewareHandler:c=this.defaultHttpMiddlewareHandler}=t,l=new o(r||"",{requestHandler:s,responseHandler:a,middlewareHandler:c});return Object.assign(l,{defaultScopes:n}),i?.(l),l}createCustomClient(e){return this.createClient(e)}_resolveConfig(e){if("string"==typeof e){const r=this.config.clients[e];if(!r&&(e=>{try{const t=new URL(e);return Oo.includes(t.protocol)}catch{return!1}})(e))return{baseUri:e};if(!r&&!(t=e).includes(" ")&&/^[a-z\d]([a-z\d-]*\.)+[a-z]{2,}/i.test(t))return console.warn(`[HttpClientProvider] "${e}" looks like a URL but is missing the http:// or https:// protocol. Treating it as "https://${e}". Pass a fully-qualified URL to silence this warning.`),{baseUri:`https://${e}`};if(!r)throw new Qr(`No registered http client for key [${e}]`);return r}var t;return e}}function $o(e,t){void 0===t&&(t={});var r=t.selector,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(t,["selector"]);return new Fn(function(t){var i=new AbortController,o=i.signal,s=!0,a=n.signal;if(a)if(a.aborted)i.abort();else{var c=function(){o.aborted||i.abort()};a.addEventListener("abort",c),t.add(function(){return a.removeEventListener("abort",c)})}var l=cn(cn({},n),{signal:o}),u=function(e){s=!1,t.error(e)};return fetch(e,l).then(function(e){r?hi(r(e)).subscribe(Mn(t,void 0,function(){s=!1,t.complete()},u)):(s=!1,t.next(e),t.complete())}).catch(u),function(){s&&i.abort()}})}const Ro=async e=>{if(204===e.status)return Promise.resolve();try{const t=await e.json();if(!e.ok)throw new Xr("network response was not OK",e,{data:t});return t}catch(t){if(t instanceof Xr)throw t;throw new Xr("failed to parse response",e,{cause:t})}},To=async e=>{if(!e.ok)throw new Error("network response was not OK");if(204===e.status)throw new Error("no content");const t=e.headers.get("content-disposition")?.split(";").find(e=>e.includes("filename="))?.replace("filename=","")?.trim();try{return{filename:t,blob:await e.blob()}}catch(e){throw Error("failed to parse response")}};class xo{uri;requestHandler;responseHandler;middlewareHandler;_request$=new zn;_response$=new zn;_abort$=new zn;get request$(){return this._request$.asObservable()}get response$(){return this._response$.asObservable()}constructor(e,t){this.uri=e,this.requestHandler=new bo(t?.requestHandler),this.responseHandler=new wo(t?.responseHandler),this.middlewareHandler=new Io(t?.middlewareHandler),this._init()}_init(){}fetch$(e,t){return this._fetch$(e,t)}fetch(e,t){return Ci(this.fetch$(e,t))}fetchAsync(e,t){return this.fetch(e,t)}json$(e,t){const r="object"==typeof t?.body?JSON.stringify(t?.body):t?.body,n=t?.selector??Ro,i=new Headers(t?.headers);return i.append("Accept","application/json"),i.append("Content-Type","application/json"),this.fetch$(e,{...t,body:r,selector:n,headers:i})}json(e,t){return Ci(this.json$(e,t))}blob$(e,t){const r=t?.selector??To,n={...t,selector:r};return this.fetch$(e,n)}blob(e,t){return Ci(this.blob$(e,t))}sse$(e,t,r){const n=new Headers(t?.headers);n.append("Accept","text/event-stream"),n.append("Content-Type","text/event-stream"),n.append("Cache-Control","no-cache"),n.append("Connection","keep-alive");const i=Po({...r,abortSignal:t?.signal});return this._fetch$(e,{selector:i,...t,headers:n})}jsonAsync(e,t){return this.json(e,t)}execute(e,t,r){return this[e](t,r)}abort(){this._abort$.next()}_fetch$(e,t){const{selector:r,...n}=t||{},i=new AbortController,o=this._abort$.pipe((s=1,s<=0?function(){return ri}:Bn(function(e,t){var r=0;e.subscribe(Mn(t,function(e){++r<=s&&(t.next(e),s<=r&&t.complete())}))}))).subscribe(()=>i.abort());var s;const a=n.signal,c=a?AbortSignal.any([a,i.signal]):i.signal;return Ii({...n,signal:c,path:e,uri:this._resolveUrl(e)}).pipe(Ji(e=>this._prepareRequest(e)),eo(e=>this._request$.next(e)),Ji(({uri:e,path:t,...r})=>this.middlewareHandler.process(e,r,(e,t)=>this._performFetch(e,t))),Ji(e=>this._prepareResponse(e)),eo(e=>this._response$.next(e)),Ji(e=>{if(r)try{return r(e)}catch(t){throw new Yr("failed to execute response selector",e,{cause:t})}return Ii(e)}),Qi(this._abort$),Ki(()=>o.unsubscribe()))}_performFetch(e,t){return $o(e,t)}_prepareRequest(e){return this.requestHandler.process(e)}_prepareResponse(e){return this.responseHandler.process(e)}_resolveUrl(e){const{origin:t,pathname:r}=new URL(this.uri,this.uri.startsWith("http")?void 0:window.location.origin),n=[r,e].join("/").replace(/\/{2,}/g,"/");return new URL(n,t).href}}class ko extends xo{defaultScopes=[];fetch$(e,t){const r={...t,scopes:this.defaultScopes.concat(t?.scopes||[])};return super._fetch$(e,r)}}const Fo={name:"http",configure:()=>new No(ko),initialize:async({config:e,hasModule:t,requireInstance:r})=>{const n=new Ao(e);if(t("auth")){const e=await r("auth");n.defaultHttpRequestHandler.set("MSAL",async t=>{const{scopes:r=[]}=t;if(r.length){const i={request:{scopes:r}},o=await e.acquireAccessToken(on in t?(n=i,{...n,[on]:!0}):i);if(o){const e=new Headers(t.headers);return e.set("Authorization",`Bearer ${o}`),{...t,headers:e}}}var n})}return n}},Uo=(...e)=>t=>t.pipe(function(e,t){return vn(t)?Ri(e,t,1):Ri(e,1)}(...e)),Bo=(...e)=>t=>t.pipe(Ri(...e)),Mo=(...e)=>t=>t.pipe(Ji(...e)),Go=e=>e.pipe(Ni(e=>e.value));var jo=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function zo(e){if(!function(e){return"string"==typeof e&&jo.test(e)}(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}const Ho=[];for(let e=0;e<256;++e)Ho.push((e+256).toString(16).slice(1));function qo(e,t=0){return(Ho[e[t+0]]+Ho[e[t+1]]+Ho[e[t+2]]+Ho[e[t+3]]+"-"+Ho[e[t+4]]+Ho[e[t+5]]+"-"+Ho[e[t+6]]+Ho[e[t+7]]+"-"+Ho[e[t+8]]+Ho[e[t+9]]+"-"+Ho[e[t+10]]+Ho[e[t+11]]+Ho[e[t+12]]+Ho[e[t+13]]+Ho[e[t+14]]+Ho[e[t+15]]).toLowerCase()}const Vo=new Uint8Array(16);function Wo(e,t,r,n,i,o){const s="string"==typeof r?function(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}(r):r,a="string"==typeof n?zo(n):n;if("string"==typeof n&&(n=zo(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+s.length);if(c.set(a),c.set(s,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){if(o??=0,o<0||o+16>i.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let e=0;e<16;++e)i[o+e]=c[e];return i}return qo(c)}function Zo(e,t,r){return crypto.randomUUID?crypto.randomUUID():function(e){e=e||{};const t=e.random??e.rng?.()??crypto.getRandomValues(Vo);if(t.length<16)throw new Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,qo(t)}(e)}function Ko(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Yo(e,t){return e<<t|e>>>32-t}function Xo(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,o=Math.ceil(i/16),s=new Array(o);for(let t=0;t<o;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];s[t]=r}s[o-1][14]=8*(e.length-1)/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<o;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=s[e][t];for(let e=16;e<80;++e)n[e]=Yo(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],o=r[1],a=r[2],c=r[3],l=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),s=Yo(i,5)+Ko(r,o,a,c)+l+t[r]+n[e]>>>0;l=c,c=a,a=Yo(o,30)>>>0,o=i,i=s}r[0]=r[0]+i>>>0,r[1]=r[1]+o>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+l>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function Jo(e,t,r,n){return Wo(80,Xo,e,t,r,n)}Jo.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Jo.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";class Qo extends Error{type;request;constructor(e,t){super(t.message,{cause:t.cause}),this.type=e,this.name="QueryClientError",this.request=t.request}}var es=Symbol.for("immer-nothing"),ts=Symbol.for("immer-draftable"),rs=Symbol.for("immer-state"),ns="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function is(e,...t){if("production"!==process.env.NODE_ENV){const r=ns[e],n=Ds(r)?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var os=Object,ss=os.getPrototypeOf,as="constructor",cs="prototype",ls="configurable",us="enumerable",fs="writable",ds="value",ps=e=>!!e&&!!e[rs];function hs(e){return!!e&&(vs(e)||Ls(e)||!!e[ts]||!!e[as]?.[ts]||Ss(e)||Cs(e))}var ms=os[cs][as].toString(),gs=new WeakMap;function vs(e){if(!e||!_s(e))return!1;const t=ss(e);if(null===t||t===os[cs])return!0;const r=os.hasOwnProperty.call(t,as)&&t[as];if(r===Object)return!0;if(!Ds(r))return!1;let n=gs.get(r);return void 0===n&&(n=Function.toString.call(r),gs.set(r,n)),n===ms}function ys(e,t,r=!0){if(0===Es(e)){(r?Reflect.ownKeys(e):os.keys(e)).forEach(r=>{t(r,e[r],e)})}else e.forEach((r,n)=>t(n,r,e))}function Es(e){const t=e[rs];return t?t.type_:Ls(e)?1:Ss(e)?2:Cs(e)?3:0}var bs=(e,t,r=Es(e))=>2===r?e.has(t):os[cs].hasOwnProperty.call(e,t),ws=(e,t,r=Es(e))=>2===r?e.get(t):e[t],Is=(e,t,r,n=Es(e))=>{2===n?e.set(t,r):3===n?e.add(r):e[t]=r};var Ls=Array.isArray,Ss=e=>e instanceof Map,Cs=e=>e instanceof Set,_s=e=>"object"==typeof e,Ds=e=>"function"==typeof e,Ps=e=>"boolean"==typeof e;var Ns=e=>e.copy_||e.base_,Os=e=>e.modified_?e.copy_:e.base_;function As(e,t){if(Ss(e))return new Map(e);if(Cs(e))return new Set(e);if(Ls(e))return Array[cs].slice.call(e);const r=vs(e);if(!0===t||"class_only"===t&&!r){const t=os.getOwnPropertyDescriptors(e);delete t[rs];let r=Reflect.ownKeys(t);for(let n=0;n<r.length;n++){const i=r[n],o=t[i];!1===o[fs]&&(o[fs]=!0,o[ls]=!0),(o.get||o.set)&&(t[i]={[ls]:!0,[fs]:!0,[us]:o[us],[ds]:e[i]})}return os.create(ss(e),t)}{const t=ss(e);if(null!==t&&r)return{...e};const n=os.create(t);return os.assign(n,e)}}function $s(e,t=!1){return Ts(e)||ps(e)||!hs(e)||(Es(e)>1&&os.defineProperties(e,{set:Rs,add:Rs,clear:Rs,delete:Rs}),os.freeze(e),t&&ys(e,(e,t)=>{$s(t,!0)},!1)),e}var Rs={[ds]:function(){is(2)}};function Ts(e){return null===e||!_s(e)||os.isFrozen(e)}var xs="MapSet",ks="Patches",Fs="ArrayMethods",Us={};function Bs(e){const t=Us[e];return t||is(0,e),t}var Ms,Gs=e=>!!Us[e],js=()=>Ms;function zs(e,t){t&&(e.patchPlugin_=Bs(ks),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Hs(e){qs(e),e.drafts_.forEach(Ws),e.drafts_=null}function qs(e){e===Ms&&(Ms=e.parent_)}var Vs=e=>Ms={drafts_:[],parent_:Ms,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Gs(xs)?Bs(xs):void 0,arrayMethodsPlugin_:Gs(Fs)?Bs(Fs):void 0};function Ws(e){const t=e[rs];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Zs(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(void 0!==e&&e!==r){r[rs].modified_&&(Hs(t),is(4)),hs(e)&&(e=Ks(t,e));const{patchPlugin_:n}=t;n&&n.generateReplacementPatches_(r[rs].base_,e,t)}else e=Ks(t,r);return function(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&$s(t,r)}(t,e,!0),Hs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==es?e:void 0}function Ks(e,t){if(Ts(t))return t;const r=t[rs];if(!r){return ta(t,e.handledSet_,e)}if(!Xs(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:t}=r;if(t)for(;t.length>0;){t.pop()(e)}ea(r,e)}return r.copy_}function Ys(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Xs=(e,t)=>e.scope_===t,Js=[];function Qs(e,t,r,n){const i=Ns(e),o=e.type_;if(void 0!==n){if(ws(i,n,o)===t)return void Is(i,n,r,o)}if(!e.draftLocations_){const t=e.draftLocations_=new Map;ys(i,(e,r)=>{if(ps(r)){const n=t.get(r)||[];n.push(e),t.set(r,n)}})}const s=e.draftLocations_.get(t)??Js;for(const e of s)Is(i,e,r,o)}function ea(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const n=r.getPath(e);n&&r.generatePatches_(e,n,t)}Ys(e)}}function ta(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ps(e)||t.has(e)||!hs(e)||Ts(e)||(t.add(e),ys(e,(n,i)=>{if(ps(i)){const t=i[rs];if(Xs(t,r)){const r=Os(t);Is(e,n,r,e.type_),Ys(t)}}else hs(i)&&ta(i,t,r)})),e}var ra={get(e,t){if(t===rs)return e;let r=e.scope_.arrayMethodsPlugin_;const n=1===e.type_&&"string"==typeof t;if(n&&r?.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const i=Ns(e);if(!bs(i,t,e.type_))return function(e,t,r){const n=oa(t,r);return n?ds in n?n[ds]:n.get?.call(e.draft_):void 0}(e,i,t);const o=i[t];if(e.finalized_||!hs(o))return o;if(n&&e.operationMethod&&r?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return o;if(o===ia(e.base_,t)||function(e,t,r){if(1!==e.type_||!e.allIndicesReassigned_||!hs(r)||r[rs])return!1;return e.baseRefs_.has(r)}(e,0,o)){aa(e);const r=1===e.type_?+t:t,n=ca(e.scope_,o,e,r);return e.copy_[r]=n}return o},has:(e,t)=>t in Ns(e),ownKeys:e=>Reflect.ownKeys(Ns(e)),set(e,t,r){const n=oa(Ns(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const n=ia(Ns(e),t),s=n?.[rs];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_.delete(t),!0;if(((i=r)===(o=n)?0!==i||1/i==1/o:i!=i&&o!=o)&&(void 0!==r||bs(e.base_,t,e.type_)))return!0;aa(e),sa(e)}var i,o;return e.copy_[t]===r&&(void 0!==r||bs(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),function(e,t,r){const{scope_:n}=e;if(ps(r)){const i=r[rs];Xs(i,n)&&i.callbacks_.push(function(){aa(e);const n=Os(i);Qs(e,r,n,t)})}else hs(r)&&e.callbacks_.push(function(){const i=Ns(e);3===e.type_?i.has(r)&&ta(r,n.handledSet_,n):ws(i,t,e.type_)===r&&n.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&ta(ws(e.copy_,t,e.type_),n.handledSet_,n)})}(e,t,r)),!0},deleteProperty:(e,t)=>(aa(e),void 0!==ia(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),sa(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const r=Ns(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{[fs]:!0,[ls]:1!==e.type_||"length"!==t,[us]:n[us],[ds]:r[t]}:n},defineProperty(){is(11)},getPrototypeOf:e=>ss(e.base_),setPrototypeOf(){is(12)}},na={};for(let e in ra){let t=ra[e];na[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function ia(e,t){const r=e[rs];return(r?Ns(r):e)[t]}function oa(e,t){if(!(t in e))return;let r=ss(e);for(;r;){const e=Object.getOwnPropertyDescriptor(r,t);if(e)return e;r=ss(r)}}function sa(e){e.modified_||(e.modified_=!0,e.parent_&&sa(e.parent_))}function aa(e){e.copy_||(e.assigned_=new Map,e.copy_=As(e.base_,e.scope_.immer_.useStrictShallowCopy_))}na.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&is(13),na.set.call(this,e,t,void 0)},na.set=function(e,t,r){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&is(14),ra.set.call(this,e[0],t,r,e[0])};function ca(e,t,r,n){const[i,o]=Ss(t)?Bs(xs).proxyMap_(t,r):Cs(t)?Bs(xs).proxySet_(t,r):function(e,t){const r=Ls(e),n={type_:r?1:0,scope_:t?t.scope_:js(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=n,o=ra;r&&(i=[n],o=na);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return n.draft_=a,n.revoke_=s,[a,n]}(t,r);return(r?.scope_??js()).drafts_.push(i),o.callbacks_=r?.callbacks_??[],o.key_=n,r&&void 0!==n?function(e,t,r){e.callbacks_.push(function(n){const i=t;if(!i||!Xs(i,n))return;n.mapSetPlugin_?.fixSetContents(i);const o=Os(i);Qs(e,i.draft_??i,o,r),ea(i,n)})}(r,o,n):o.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:t}=e;o.modified_&&t&&t.generatePatches_(o,[],e)}),i}function la(e){if(!hs(e)||Ts(e))return e;const t=e[rs];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=As(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=As(e,!0);const i=r;return Cs(r)&&(r=new Set),ys(i,(e,t)=>{Is(r,e,la(t))},n),t&&(t.finalized_=!1),r}globalThis.Iterator;var ua=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,r)=>{if(Ds(e)&&!Ds(t)){const r=t;t=e;const n=this;return function(e=r,...i){return n.produce(e,e=>t.call(this,e,...i))}}let n;if(Ds(t)||is(6),void 0===r||Ds(r)||is(7),hs(e)){const i=Vs(this),o=ca(i,e,void 0);let s=!0;try{n=t(o),s=!1}finally{s?Hs(i):qs(i)}return zs(i,r),Zs(n,i)}if(!e||!_s(e)){if(n=t(e),void 0===n&&(n=e),n===es&&(n=void 0),this.autoFreeze_&&$s(n,!0),r){const t=[],i=[];Bs(ks).generateReplacementPatches_(e,n,{patches_:t,inversePatches_:i}),r(t,i)}return n}is(1,e)},this.produceWithPatches=(e,t)=>{if(Ds(e))return(t,...r)=>this.produceWithPatches(t,t=>e(t,...r));let r,n;return[this.produce(e,t,(e,t)=>{r=e,n=t}),r,n]},Ps(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Ps(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Ps(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){hs(e)||is(8),ps(e)&&(e=function(e){ps(e)||is(10,e);return la(e)}(e));const t=Vs(this),r=ca(t,e,void 0);return r[rs].isManual_=!0,qs(t),r}finishDraft(e,t){const r=e&&e[rs];r&&r.isManual_||is(9);const{scope_:n}=r;return zs(n,t),Zs(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));const n=Bs(ks).applyPatches_;return ps(e)?n(e,t):this.produce(e,e=>n(e,t))}},fa=ua.produce;const da=(...e)=>Mi(t=>e.includes(t.type));class pa extends Fn{#de=new zn;#pe;get action$(){return this.#de.asObservable()}get value(){return this.#pe.value}get closed(){return this.#pe.closed||this.#de.closed}constructor(e,t){super(e=>this.#pe.subscribe(e));const r="getInitialState"in e?e.getInitialState():t;this.#pe=new qn(r),this.#de.pipe(function(e,t){return Bn(ji(e,t,arguments.length>=2,!0))}(e,r),qi()).subscribe(this.#pe),this.reset=()=>this.#pe.next(r)}reset;next(e){this.#de.next(e)}select(e,t){return this.#pe.pipe(Ni(e),qi(t))}addEffect(e,t){const r="function"==typeof e?this.action$:Array.isArray(e)?this.action$.pipe(da(...e)):this.action$.pipe(da(e)),n=t||e;return r.pipe(Ri(e=>wi(new Promise((t,r)=>{try{t(n(e,this.value))}catch(e){r(e)}})).pipe(Gi(e=>(console.warn("unhandled effect",e),ri)))),Mi(e=>!!e),vi(ei)).subscribe(this.#de)}addEpic(e){return this.addFlow(e)}addFlow(e){const t=e(this.action$,this);if(!t)throw new TypeError(`addEpic: one of the provided effects "${e.name||"<anonymous>"}" does not return a stream. Double check you're not missing a return statement!`);return t.pipe(Gi(e=>(console.trace("unhandled exception, epic closed!",e),ri)),vi(ei)).subscribe(this.#de)}unsubscribe(){this.#de.unsubscribe(),this.#pe.unsubscribe()}complete(){this.#de.complete(),this.#pe.complete()}asObservable(){return this.#pe.asObservable()}}const ha="::";function ma(e,t){function r(...r){if(t){const n=t(...r);if(!n)throw new Error("prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:r[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=t=>t.type===e,r}function ga(e,t,r,n){const i=ma([e,"request"].join(ha),t);return r&&Object.assign(i,{success:ma([e,"success"].join(ha),r)}),n&&Object.assign(i,{failure:ma([e,"failure"].join(ha),n)}),i}function va(e){return hs(e)?fa(e,()=>{}):e}function ya(e,t){const[r,n,i]=function(e){const t={},r=[];let n;const i={addCase(e,o){if("production"!==process.env.NODE_ENV){if(r.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(s in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[s]=o,i},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:e,reducer:t}),i},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addDefaultCase` can only be called once");return n=e,i}};return e(i),[t,r,n]}(t);let o;if("function"==typeof e)o=()=>va(e());else{const t=va(e);o=()=>t}function s(e,t){let s=[r[t.type],...n.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];const a=s.filter(e=>!!e).length>0;return i&&!a&&(s=[i]),s.reduce((e,r)=>{if(r){if(ps(e)){const n=r(e,t);return void 0===n?e:n}if(hs(e))return fa(e,e=>r(e,t));{const n=r(e,t);if(void 0===n){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}}return e},e??o())}return s.getInitialState=o,s}const Ea={request:ma("client/request",(e,t)=>({payload:{args:e,options:t},meta:{transaction:Zo(),created:Date.now()}})),execute:ga("client/execute",e=>({payload:e,meta:{transaction:e,created:Date.now()}}),e=>({payload:e,meta:{transaction:e.transaction,created:Date.now()}}),(e,t)=>({payload:{error:e},meta:{transaction:t,created:Date.now()}})),cancel:ma("client/cancel",(e,t)=>({payload:{transaction:e,reason:t},meta:{transaction:e,created:Date.now()}})),error:ma("client/error",(e,t)=>({payload:{transaction:e,error:t},meta:{transaction:e,created:Date.now()}}))},ba=e=>e.pipe(Mi(Ea.request.match),Ni(e=>Ea.execute(e.meta.transaction)));class wa extends Fn{#he=new qn("idle");get status(){return this.#he.value}get status$(){return this.#he.asObservable()}#me;#ge;get transaction(){return this.#ge}created=Date.now();get closed(){return"complete"===this.status||"error"===this.status||"canceled"===this.status}constructor(e,t,r){super(t=>{const{transaction:n}=this,i=e.action$.pipe(Mi(e=>e.meta.transaction===n));t.add(e.state$.pipe(Mi(e=>!!e[n]),Ni(e=>e[n])).subscribe(e=>{this.#he.next(e.status)})),t.add(i.pipe(Mi(Ea.execute.success.match),Ni(({payload:e})=>e)).subscribe(e=>{this.#he.next("complete"),t.next(e),t.complete()})),t.add(i.pipe(Mi(Ea.error.match),Ni(({payload:e})=>e)).subscribe(e=>{this.#he.next("error"),t.error(e.error)})),t.add(i.pipe(Mi(Ea.cancel.match)).subscribe(e=>{this.#he.next("canceled"),t.error(new Qo("abort",{message:e.payload.reason||`job: ${n} was canceled`,request:this.#me.getRequest(e.meta.transaction)}))})),r?.signal&&t.add(Fi(r?.signal,"abort").pipe(Ni(()=>Ea.cancel(n,`job: ${n} was aborted on signal from caller: ${r?.ref}`))).subscribe(t=>e.next(t))),t.add(()=>{this.complete()})}),this.#me=e;const n=Ea.request(t,{ref:r?.ref,retry:r?.retry});this.#ge=n.meta.transaction,this.#me.next(n)}complete(e){this.closed||this.cancel(e??`job: ${this.transaction} was completed`)}cancel(e){const t=this.transaction;this.#me.cancel(t,e??`job: ${t} was canceled`)}[Symbol.dispose](){this.complete()}}class Ia{type;transaction;data;constructor(e,t,r){this.type=e,this.transaction=t,this.data=r}}class La extends Fn{#pe;#ve;#ye;_registerEvent(e,t,r){this.#ye.next(new Ia(e,t,r))}get closed(){return this.#pe.closed}get state$(){return this.#pe.asObservable()}get action$(){return this.#pe.action$}get event$(){return this.#ye.asObservable()}get success$(){return this.action$.pipe(Mi(Ea.execute.success.match),Ni(({payload:e})=>e))}get error$(){return this.action$.pipe(da("client/error"),to(this.#pe),Ni(([e,t])=>{const{payload:r,meta:{transaction:n}}=e,i=t[n];return new Qo("error",{request:i,message:`job: ${n} failed`,cause:r})}))}constructor(e,t){super(e=>this.#pe.subscribe(e)),this.#pe=new pa(((e={})=>ya(e,e=>{e.addCase(Ea.request,(e,t)=>{e[t.meta.transaction]={...t.payload,...t.meta,execution:[],errors:[],status:"idle"}}),e.addCase(Ea.execute,(e,t)=>{const r=e[t.payload];r&&(r.execution.push(Date.now()),r.status="active")}),e.addCase(Ea.execute.success,(e,t)=>{delete e[t.payload.transaction]}),e.addCase(Ea.execute.failure,(e,t)=>{const r=e[t.meta.transaction];r&&(r.errors.push(t.payload.error),r.status="failed")}),e.addCase(Ea.error,(e,t)=>{delete e[t.meta.transaction]}),e.addCase(Ea.cancel,(e,t)=>{delete e[t.meta.transaction]})}))({})),this.#ve=new wn(()=>{this.#pe.complete(),this.#ye.complete()}),this.#ye=new zn,this.#ve.add(this.#pe.addFlow(ba)),this.#ve.add(this.#pe.addFlow((e=>(t,r)=>t.pipe(Mi(Ea.execute.match),to(r),Ri(([r,n])=>{const i=r.payload,o=n[i],s=new AbortController,a=t.pipe(Mi(Ea.cancel.match),Mi(e=>e.payload.transaction===i),eo(()=>{s.signal.aborted||s.abort()}));try{return wi(e(o.args,s.signal)).pipe(Ni(e=>Ea.execute.success({...o,status:"complete",completed:Date.now(),value:e})),Gi(e=>Ii(Ea.execute.failure(e,i))),Qi(a))}catch(e){return Ii(Ea.execute.failure(e,i))}})))(e)));const r=Object.assign({count:0,delay:0},t?.retry);this.#ve.add(this.#pe.addFlow((e=>(t,r)=>t.pipe(Mi(Ea.execute.failure.match),to(r),Ri(([t,n])=>{const{transaction:i}=t.meta,o=n[i];if(!o)return Ii(Ea.error(i,new Qo("error",{message:"request not found, cannot retry request, most likely removed while scheduled for retry!"})));const s=o.execution.length,a=Object.assign({},e,o.options?.retry),c=o.errors?.slice(-1)[0]??new Qo("error",{message:"no errors registered for request!",request:o});if(s>a.count){const e=0===a.count?c:new Qo("error",{message:"maximum retries executed!",cause:o.errors,request:o});return Ii(Ea.error(i,e))}return("function"==typeof a.delay?wi(a.delay(c)).pipe(Gi(e=>Ii(Ea.error(i,new Qo("error",{message:"retry delay callback failed!",cause:[...o.errors??[],e],request:o}))))):Bi(a.delay)).pipe(to(r),Mi(([e,t])=>!!t[i]),eo(([,e])=>{if(!e[i])throw new Qo("error",{message:"request not found, most likely removed while scheduled for retry",cause:o.errors,request:o})}),Ni(()=>Ea.execute(i)))})))(r))),this.#pe.addEffect(Ea.request.type,({payload:e,meta:{transaction:t}})=>{this._registerEvent("query_client_job_requested",t,e)}),this.#pe.addEffect(Ea.execute.type,({meta:{transaction:e}})=>{this._registerEvent("query_client_job_executing",e)}),this.#pe.addEffect(Ea.execute.success.type,({payload:e,meta:{transaction:t}})=>{this._registerEvent("query_client_job_completed",t,{payload:e})}),this.#pe.addEffect(Ea.execute.failure.type,({payload:e,meta:{transaction:t}})=>{const r=e.error instanceof Error?e.error:new Error(String(e.error));this._registerEvent("query_client_job_failed",t,{error:r})}),this.#pe.addEffect(Ea.cancel.type,({payload:{reason:e},meta:{transaction:t}})=>{this._registerEvent("query_client_job_canceled",t,{reason:e||"no reason provided"})}),this.#pe.addEffect(Ea.error.type,({payload:e,meta:{transaction:t}})=>{const r=e.error instanceof Error?e.error:new Error(String(e.error));this._registerEvent("query_client_job_error",t,{error:r})})}next(e){this.#pe.next(e)}query(e,t){const r=new wa(this,e,t),n=r.pipe(function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new zn}:t,n=e.resetOnError,i=void 0===n||n,o=e.resetOnComplete,s=void 0===o||o,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,o,a=0,l=!1,u=!1,f=function(){null==n||n.unsubscribe(),n=void 0},d=function(){f(),t=o=void 0,l=u=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return Bn(function(e,h){a++,u||l||f();var m=o=null!=o?o:r();h.add(function(){0!==--a||u||l||(n=Xi(p,c))}),m.subscribe(h),!t&&a>0&&(t=new $n({next:function(e){return m.next(e)},error:function(e){u=!0,f(),n=Xi(d,i,e),m.error(e)},complete:function(){l=!0,f(),n=Xi(d,s),m.complete()}}),hi(e).subscribe(t))})(e)}}({connector:()=>new Wn,resetOnRefCountZero:!1}));return Object.defineProperties(n,{transaction:{get:()=>r.transaction},created:{get:()=>r.created},status:{get:()=>r.status},closed:{get:()=>r.closed},cancel:{value:e=>r.cancel(e)},complete:{value:()=>r.complete()}}),n}async nextAsync(e,t){return Ci(this.query(e,t))}getRequest(e){return this.#pe.value[e]}getRequestByRef(e){return Object.values(this.#pe.value).find(t=>t.ref===e)}cancelTaskByRef(e,t){const r=this.getRequestByRef(e);r?.ref&&this.cancel(r.transaction,t)}cancel(e,t){if(e)this.#pe.value[e]&&(t??=`cancelation requested for job: ${e}`,this.#pe.next(Ea.cancel(e,t)));else for(const e of Object.keys(this.#pe.value))this.cancel(e,"all transactions requested canceled")}on(e,t){return this.#pe.addEffect(Ea[e].type,e=>{t(e,this)})}complete(){this.#ve.unsubscribe()}}const Sa={set:ma("cache/set",(e,t)=>({payload:{key:e,record:t}})),insert:ma("cache/insert",(e,t)=>({payload:{key:e,entry:t}})),remove:ma("cache/remove",e=>({payload:e})),invalidate:ma("cache/invalidate",(e,t)=>({payload:e,meta:{item:t}})),mutate:ma("cache/mutate",(e,t,r)=>({payload:{...t,key:e},meta:{item:r}})),trim:ma("cache/trim",e=>({payload:e}))},Ca=(e,t)=>(t.updated??0)-(e.updated??0);class _a{type;key;data;constructor(e,t,r){this.type=e,this.key=t,this.data=r}}class Da{#pe;#ye;get state(){return this.#pe.value}get state$(){return this.#pe.asObservable()}get action$(){return this.#pe.action$}_registerEvent(e,t){this.#ye.next(new _a(e,t?.key,t?.data))}get event$(){return this.#ye.asObservable()}constructor(e){const{trimming:t,initial:r}=e??{};this.#pe=new pa(function(e,t={}){return ya(t,t=>t.addCase(e.set,(e,t)=>{const{key:r,record:n}=t.payload;e[r]=n}).addCase(e.insert,(e,t)=>{const{key:r,entry:n}=t.payload,i=e[r];if(i)i.updated=Date.now(),i.updates??=0,i.updates++,i.value=n.value,i.transaction=n.transaction,i.mutated=void 0;else{const t=Date.now();e[r]={...n,created:t,updated:t}}}).addCase(e.remove,(e,t)=>{delete e[t.payload]}).addCase(e.invalidate,(e,t)=>{const r=t.payload?[t.payload]:Object.keys(e);for(const t of r){const r=e[t];r&&(r.updated=void 0)}}).addCase(e.mutate,(e,t)=>{const{key:r,value:n,updated:i}=t.payload,o=e[r];o&&(o.value=n,o.updated=i,o.mutated=Date.now(),o.updates??=0,o.updates++)}).addCase(e.trim,(e,t)=>{const{payload:r}=t,n=r.sort??Ca,i=Object.keys(e),o=Object.entries(e).filter(([e,t])=>!r.validate||r.validate(t)).sort((e,t)=>n(e[1],t[1])).slice(0,r.size??Number.MAX_SAFE_INTEGER).map(([e])=>e);if(i.length!==o.length)for(const t of i){const r=o.indexOf(t);-1!==r?o.splice(r,1):delete e[t]}}))}(Sa,r)),t&&this.#pe.addEffect("cache/set",()=>this.#pe.next(Sa.trim(t))),this.#ye=new zn}has(e){return e in this.#pe.value}setItem(e,t){const{args:r,transaction:n,value:i}=t;this.#pe.next(Sa.insert(e,{args:r,transaction:n,value:i})),this._registerEvent("query_cache_entry_inserted",{key:e,data:{value:i,args:r,transaction:n}})}getItem(e){return this.#pe.value[e]}removeItem(e){this.#pe.next(Sa.remove(e)),this._registerEvent("query_cache_entry_removed",{key:e})}invalidate(e){const t=e?this.#pe.value[e]:void 0;this.#pe.next(Sa.invalidate(e,t)),e&&this._registerEvent("query_cache_entry_invalidated",{key:e,data:{previousValue:t?.value}})}mutate(e,t){const r=e in this.#pe.value?this.#pe.value[e]:void 0;if(!r)throw new Error(`Cannot mutate cache item with key ${e}: item not found`);const n="function"==typeof t?t(r?.value):t;return this.#pe.next(Sa.mutate(e,n,r)),this._registerEvent("query_cache_entry_mutated",{key:e,data:{previousValue:r.value,newValue:n,mutation:n}}),()=>this.#pe.next(Sa.set(e,r))}trim(e){const t=new Set(Object.keys(this.#pe.value));this.#pe.next(Sa.trim(e));const r=new Set(Object.keys(this.#pe.value)),n=Array.from(t).filter(e=>!r.has(e));this._registerEvent("query_cache_trimmed",{data:{removedKeys:n,criteria:e}})}reset(){this.#pe.reset(),this._registerEvent("query_cache_reset")}complete(){this.#pe.complete(),this.#ye.complete()}}class Pa extends zn{key;args;options;#Ee=Date.now();get created(){return this.#Ee}#be=Zo();get uuid(){return this.#be}constructor(e,t,r){super(),this.key=e,this.args=t,this.options=r}processJob(e){return e.pipe(Ni(t=>{const{key:r,uuid:n,created:i}=this;return{key:r,uuid:n,created:i,status:"complete",transaction:e.transaction,complete:t.completed,value:t.value}}),Ki(()=>{e.complete()})).subscribe(this)}}class Na{type;key;data;constructor(e,t,r){this.type=e,this.key=t,this.data=r}}class Oa{static extractQueryValue=Go;#ve=new wn;#me;#we;#Ie=new zn;#Le={};#Se;#Ce;#_e=Zo();#se;get client(){return this.#me}_registerEvent(e,t,r){this.#se.next(new Na(e,t,r))}get cache(){return this.#we}get event$(){return this.#se.asObservable()}constructor(e){this.#se=new zn,this.#Se=t=>Jo(e.key(t),this.#_e),this.#Ce=e?.validate??((e=0)=>t=>(t.updated??0)+e>Date.now())(e?.expire),e.client instanceof La?this.#me=e.client:(this.#me=new La(e.client.fn,{...e.client.options}),this.#ve.add(()=>this.#me.complete())),this.#ve.add(this.#me.event$.subscribe({next:e=>this.#se.next(e)})),e.cache instanceof Da?this.#we=e.cache:(this.#we=new Da(e.cache||{}),this.#ve.add(()=>this.#we.complete())),this.#ve.add(this.#we.event$.subscribe({next:e=>this.#se.next(e)}));const t=((e="switch")=>"function"==typeof e?e:(()=>{switch(e){case"concat":return Uo;case"merge":return Bo;case"switch":return Mo;default:throw new Error(`Invalid queue operator: ${e}`)}})())(e.queueOperator);var r,n;this.#ve.add(()=>this.#Ie.complete()),this.#ve.add(this.#Ie.pipe(eo(e=>{this._registerEvent("query_queued",e)}),Mi(e=>!!(e in this.#Le)),t(e=>{const t=this.#Le[e],{args:r,options:n,uuid:i}=t;if(this._registerEvent("query_job_selected",e,{taskId:i,args:r,options:n}),!t?.observed)return this._registerEvent("query_job_skipped",e,{taskId:i,args:r,options:n}),delete this.#Le[e],ri;const o=this.#me.query(r,{...n,ref:t.uuid});return new Fn(s=>{const{transaction:a}=o;var c,l;this._registerEvent("query_job_started",e,{taskId:i,transaction:a,args:r,options:n}),s.add(()=>{this._registerEvent("query_job_closed",e,{taskId:i,transaction:a,args:r,options:n}),o.complete("task closed"),delete this.#Le[e]}),s.add((c=10,void 0===l&&(l=ei),Bi(c,c,l)).pipe(Mi(()=>!t.observed)).subscribe(()=>{o.cancel(`task: ${t.uuid} is not observed`),s.complete()})),s.add(t.processJob(o).add(()=>{this._registerEvent("query_job_completed",e,{taskId:i,transaction:a,args:r,options:n})})),o.pipe(Ni(e=>({result:e,task:t})),Gi(()=>ri)).subscribe(s)})}),(r=()=>!this.#me.closed,void 0===n&&(n=!1),Bn(function(e,t){var i=0;e.subscribe(Mn(t,function(e){var o=r(e,i++);(o||n)&&t.next(e),!o&&t.complete()}))}))).subscribe(e=>{const{value:t,transaction:r}=e.result,{args:n,key:i,uuid:o}=e.task;this._registerEvent("query_cache_added",i,{data:t,taskId:o,args:n,transaction:r}),this._registerEvent("query_completed",i,{data:t,hasValidCache:!0}),this.#we.setItem(i,{value:t,args:n,transaction:r})}))}query(e,t){return this._query(e,t)}queryAsync(e,t){const{skipResolve:r,...n}=t||{},i=r?Ci:Si;return new Promise((r,o)=>{t?.signal&&t.signal.addEventListener("abort",()=>o(new Error("Query aborted"))),i(this._query(e,n).pipe(Wi())).then(r,o)})}persistentQuery(e,t){const r=this.#Se(e),n=this._query(e,t);return new Fn(i=>{i.add(n.subscribe({next:i.next.bind(i),error:i.error.bind(i)}));const o=t?.cache?.validate||this.#Ce;i.add(this.cache.state$.pipe(Mi(e=>r in e),Ni(t=>({...t[r],key:r,status:"cache",hasValidCache:o(t[r],e)}))).subscribe(i))}).pipe(qi((e,t)=>e.transaction===t.transaction&&e.mutated===t.mutated))}generateCacheKey(e){return this.#Se(e)}mutate(e,t,r){const n=this.#Se(e);if(n in this.cache.state==!1){if(void 0===r?.allowCreation)throw new Error(`Cannot mutate cache item with key ${n}: item not found and option "allowCreation" is false`);if(!1===r.allowCreation)return()=>{};const{value:i}="function"==typeof t?t():t;this.cache.setItem(n,{args:e,transaction:Zo(),value:i})}return this.#we.mutate(n,t)}invalidate(e){this.#we.invalidate(e&&this.#Se(e))}complete(){this.#ve.unsubscribe(),this.#se?.complete()}onInvalidate(e){const t=this.#we.action$.pipe(da("cache/invalidate")).subscribe(t=>e({detail:{item:t.meta.item}}));return()=>t.unsubscribe()}onMutate(e){const t=this.#we.action$.pipe(da("cache/mutate")).subscribe(t=>e({detail:{changes:t.payload,current:t.meta.item}}));return()=>t.unsubscribe()}_query(e,t){const r=this.#Se(e),n=this._createTask(r,e,t);return this._registerEvent("query_created",r,{args:e,options:t}),n}_createTask(e,t,r){return new Fn(n=>{if(r?.signal){if(r?.signal.aborted)return this._registerEvent("query_aborted",e),n.complete();n.add(Fi(r?.signal,"abort").subscribe(()=>{this._registerEvent("query_aborted",e),n.complete()}))}const i=this.#we.getItem(e);if(i){this._registerEvent("query_cache_hit",e,{cacheEntry:i});const o=r?.cache?.suppressInvalid??!1,s=(r?.cache?.validate||this.#Ce)(i,t),a={...i,key:e,status:"cache",hasValidCache:s};if(n.next(a),s||o)return this._registerEvent("query_completed",e,{data:i.value,hasValidCache:s}),n.complete();this._registerEvent("query_cache_miss",e)}const o=e in this.#Le;o?this._registerEvent("query_connected",e,{isExistingTask:!0}):(this.#Le[e]=new Pa(e,t,r),this._registerEvent("query_job_created",e,{taskId:this.#Le[e].uuid,args:t,options:r}));const s=this.#Le[e];n.add(s.subscribe(n)),o||this.#Ie.next(e)})}}class Aa extends Error{retryAt;attempt;constructor(e){const t=Math.max(0,Math.ceil((e.retryAt-Date.now())/1e3));super(`Service discovery is unavailable after ${e.attempt} failed attempt(s); requests are paused for ${t}s`,{cause:e.cause}),this.name="ServiceDiscoveryUnavailableError",this.retryAt=e.retryAt,this.attempt=e.attempt}}const $a=T.object({key:T.string().describe("The key used to identify the service"),uri:T.string().describe("The URI of the service"),id:T.string().optional().describe("The ID of the service"),environment:T.string().optional().describe("The environment of the service"),name:T.string().optional().describe("The name of the service"),scopes:T.array(T.string()).optional().default([]).describe("Endpoint authentication scopes"),tags:T.array(T.string()).optional().describe("Tags for the service")}).describe("A service from the service discovery API").transform(e=>({...e,get defaultScopes(){return e.scopes??[]}})),Ra=T.array($a).describe("A list of services from the service discovery API");class Ta{#De;#Pe;#Ne;#Oe=new zn;diagnostic$=this.#Oe.asObservable();endpoint;http;constructor(e){this.http=e.http,this.endpoint=e.endpoint;const t=e.postProcess;this.#De=new Oa({client:{fn:()=>this.http.fetch$(this.endpoint??"",{selector:e=>((e,t)=>{const r=wi(Ro(e)).pipe(Ni(e=>Ra.default([]).parse(e)));return t?r.pipe(t):r})(e,t)})},key:()=>"services",expire:3e5})}async resolveServices(e){const t=performance.now();if(this.#Pe&&Date.now()<this.#Pe.retryAt)return this.#Ae(new Aa({cause:this.#Pe.error,retryAt:this.#Pe.retryAt,attempt:this.#Pe.attempt}),t,"cooldown");const r=Date.now();let n;try{const t=e?Ci:Si;n=await t(this.#De.query())}catch(e){return this.#$e(e,r),this.#Ae(e,t,"network")}return"complete"===n.status&&(this.#Pe=void 0,this.#Ne={services:n.value,receivedAt:Date.now()}),this.#Re({type:"resolve",outcome:"success",origin:"complete"===n.status?"network":"cache",duration:performance.now()-t}),n.value}#$e(e,t){if(this.#Pe&&this.#Pe.failedAt>=t)return;const r=(this.#Pe?.attempt??0)+1,n=Math.min(3e4,1e3*2**(r-1)),i=Math.round(n*(.8+.2*Math.random())),o=Date.now();this.#Pe={error:e,attempt:r,failedAt:o,retryAt:o+i},1===r&&console.warn("[service-discovery] request failed; pausing requests with backoff (max 30000ms)",e)}#Ae(e,t,r){const n=this.#Ne;if(n&&Date.now()-n.receivedAt<=864e5)return this.#Re({type:"resolve",outcome:"success",origin:"fallback",duration:performance.now()-t}),n.services;throw this.#Re({type:"resolve",outcome:"failure",origin:r,duration:performance.now()-t}),e}#Re(e){try{this.#Oe.next(e)}catch{}}async resolveService(e,t){const r=(await this.resolveServices(t)).find(t=>t.key===e);if(!r)throw this.#Re({type:"unknown-service"}),Error(`Failed to resolve service, invalid key [${e}]`);return r}}class xa extends no{async _createConfig(e,t){if(!e.hasModule("http"))throw new Error("http module is required");if(!this._has("discoveryClient")){(await e.requireInstance("http")).hasClient("service_discovery")&&this.configureServiceDiscoveryClientByClientKey("service_discovery")}return Si(wi(super._createConfig(e,t)))}_processConfig(e,t){if(!e.discoveryClient)throw new Error("discoveryClient is required, please configure it");return super._processConfig(e,t)}setServiceDiscoveryClient(e){this._set("discoveryClient","function"==typeof e?e:async()=>e)}configureServiceDiscoveryClient(e){this.setServiceDiscoveryClient(async t=>{const{httpClient:r,endpoint:n}=await Si(wi(e(t)))??{};if(r)return new Ta({http:r,endpoint:n,postProcess:Ni(e=>{const t="undefined"!=typeof globalThis?globalThis.sessionStorage:void 0;if(!t)return e;try{const r=JSON.parse(t.getItem("overriddenServiceDiscoveryUrls")||"{}");for(const[t,{url:n,scopes:i}]of Object.entries(r)){const r=e.find(e=>e.key===t);r&&(r.uri=n,r.scopes=i,r.overridden=!0)}}catch(e){console.error('Failed to JSON parse session overrides: "overriddenServiceDiscoveryUrls"',e)}return e})});throw Error("httpClient is required")})}configureServiceDiscoveryClientByClientKey(e,t){this.configureServiceDiscoveryClient(async({requireInstance:r})=>({httpClient:(await r("http")).createClient(e),endpoint:t}))}}const ka=x.string().regex(/^[a-z][a-z0-9-]*$/);var Fa,Ua,Ba;!function(e){e[e.Debug=0]="Debug",e[e.Information=1]="Information",e[e.Warning=2]="Warning",e[e.Error=3]="Error",e[e.Critical=4]="Critical"}(Fa||(Fa={})),function(e){e.Event="event",e.Exception="exception",e.Metric="metric",e.Custom="custom"}(Ua||(Ua={})),function(e){e.Framework="framework",e.Application="application"}(Ba||(Ba={}));const Ma=x.object({schemaVersion:x.literal(1),source:ka.optional(),hostId:x.string(),hostName:x.string().optional(),hostVersion:x.string().optional(),module:ka,operation:ka,outcome:x.enum(["success","failure","cancelled"]),occurredAt:x.number().finite().nonnegative(),unit:x.literal("ms"),traceId:x.string().optional(),spanId:x.string().optional(),traceFlags:x.number().int().min(0).max(255).optional()}).strict(),Ga=x.object({name:x.string().describe("The name of the telemetry item."),diagnostic:Ma.optional(),type:x.nativeEnum(Ua).describe("The type of telemetry. Defaults to Custom."),level:x.nativeEnum(Fa).optional().default(Fa.Information).describe("The severity level of the telemetry item. Defaults to Information."),properties:x.record(x.string(),x.unknown()).optional().describe("Optional additional properties for the telemetry item."),metadata:x.record(x.string(),x.unknown()).optional().describe("Optional metadata for the telemetry item."),scope:x.array(x.string()).optional().describe("Optional scope for the telemetry item.").transform(e=>[...new Set(e)])}),ja=Ga.extend({type:x.literal(Ua.Event)});function za(e){return e.source?[e.source,"operational"]:["operational"]}Ga.extend({type:x.literal(Ua.Exception),exception:x.instanceof(Error).describe("The exception object.")}),Ga.extend({type:x.literal(Ua.Metric),value:x.number().describe("The value of the metric.")}),ja.extend({type:x.literal(Ua.Custom)}).passthrough(),ga("telemetry/initialize",(e,t)=>({payload:e,meta:{operation:t}}),()=>({payload:void 0}),e=>({payload:e})),ga("telemetry/dispose",e=>({payload:void 0,meta:{operation:e}}),()=>({payload:void 0}),e=>({payload:e})),ma("telemetry/close"),ma("telemetry/enrichment/started",e=>({payload:{builtIn:e}})),ma("telemetry/enrichment/settled",e=>({payload:{builtIn:e}})),ma("telemetry/processing/started",e=>({payload:e})),ma("telemetry/processing/settled",e=>({payload:e})),ma("telemetry/failed",e=>({payload:e}));const Ha="1.9.1",qa=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const Va=function(e){const t=new Set([e]),r=new Set,n=e.match(qa);if(!n)return()=>!1;const i=+n[1],o=+n[2],s=+n[3];if(null!=n[4])return function(t){return t===e};function a(e){return r.add(e),!1}function c(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(r.has(e))return!1;const n=e.match(qa);if(!n)return a(e);const l=+n[1],u=+n[2],f=+n[3];return null!=n[4]||i!==l?a(e):0===i?o===u&&s<=f?c(e):a(e):o<=u?c(e):a(e)}}(Ha),Wa=Ha.split(".")[0],Za=Symbol.for(`opentelemetry.js.api.${Wa}`),Ka="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function Ya(e,t,r,n=!1){var i;const o=Ka[Za]=null!==(i=Ka[Za])&&void 0!==i?i:{version:Ha};if(!n&&o[e]){const t=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return r.error(t.stack||t.message),!1}if(o.version!==Ha){const t=new Error(`@opentelemetry/api: Registration of version v${o.version} for ${e} does not match previously registered API v${Ha}`);return r.error(t.stack||t.message),!1}return o[e]=t,r.debug(`@opentelemetry/api: Registered a global for ${e} v${Ha}.`),!0}function Xa(e){var t,r;const n=null===(t=Ka[Za])||void 0===t?void 0:t.version;if(n&&Va(n))return null===(r=Ka[Za])||void 0===r?void 0:r[e]}function Ja(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${Ha}.`);const r=Ka[Za];r&&delete r[e]}class Qa{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return ec("debug",this._namespace,e)}error(...e){return ec("error",this._namespace,e)}info(...e){return ec("info",this._namespace,e)}warn(...e){return ec("warn",this._namespace,e)}verbose(...e){return ec("verbose",this._namespace,e)}}function ec(e,t,r){const n=Xa("diag");if(n)return n[e](t,...r)}var tc;!function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"}(tc||(tc={}));class rc{static instance(){return this._instance||(this._instance=new rc),this._instance}constructor(){function e(e){return function(...t){const r=Xa("diag");if(r)return r[e](...t)}}const t=this;t.setLogger=(e,r={logLevel:tc.INFO})=>{var n,i,o;if(e===t){const e=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!==(n=e.stack)&&void 0!==n?n:e.message),!1}"number"==typeof r&&(r={logLevel:r});const s=Xa("diag"),a=function(e,t){function r(r,n){const i=t[r];return"function"==typeof i&&e>=n?i.bind(t):function(){}}return e<tc.NONE?e=tc.NONE:e>tc.ALL&&(e=tc.ALL),t=t||{},{error:r("error",tc.ERROR),warn:r("warn",tc.WARN),info:r("info",tc.INFO),debug:r("debug",tc.DEBUG),verbose:r("verbose",tc.VERBOSE)}}(null!==(i=r.logLevel)&&void 0!==i?i:tc.INFO,e);if(s&&!r.suppressOverrideMessage){const e=null!==(o=(new Error).stack)&&void 0!==o?o:"<failed to generate stacktrace>";s.warn(`Current logger will be overwritten from ${e}`),a.warn(`Current logger will overwrite one already registered from ${e}`)}return Ya("diag",a,t,!0)},t.disable=()=>{Ja("diag",t)},t.createComponentLogger=e=>new Qa(e),t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}}class nc{constructor(e){const t=this;t._currentContext=e?new Map(e):new Map,t.getValue=e=>t._currentContext.get(e),t.setValue=(e,r)=>{const n=new nc(t._currentContext);return n._currentContext.set(e,r),n},t.deleteValue=e=>{const r=new nc(t._currentContext);return r._currentContext.delete(e),r}}}const ic=new nc;const oc="context",sc=new class{active(){return ic}with(e,t,r,...n){return t.call(r,...n)}bind(e,t){return t}enable(){return this}disable(){return this}};class ac{constructor(){}static getInstance(){return this._instance||(this._instance=new ac),this._instance}setGlobalContextManager(e){return Ya(oc,e,rc.instance())}active(){return this._getContextManager().active()}with(e,t,r,...n){return this._getContextManager().with(e,t,r,...n)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Xa(oc)||sc}disable(){this._getContextManager().disable(),Ja(oc,rc.instance())}}var cc;!function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"}(cc||(cc={}));const lc="0000000000000000",uc="00000000000000000000000000000000",fc={traceId:uc,spanId:lc,traceFlags:cc.NONE};class dc{constructor(e=fc){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}}const pc=(hc="OpenTelemetry Context Key SPAN",Symbol.for(hc));var hc;function mc(e){return e.getValue(pc)||void 0}function gc(){return mc(ac.getInstance().active())}function vc(e,t){return e.setValue(pc,t)}function yc(e){return e.deleteValue(pc)}function Ec(e,t){return vc(e,new dc(t))}function bc(e){var t;return null===(t=mc(e))||void 0===t?void 0:t.spanContext()}const wc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Ic(e,t){if("string"!=typeof e||e.length!==t)return!1;let r=0;for(let t=0;t<e.length;t+=4)r+=(0|wc[e.charCodeAt(t)])+(0|wc[e.charCodeAt(t+1)])+(0|wc[e.charCodeAt(t+2)])+(0|wc[e.charCodeAt(t+3)]);return r===t}function Lc(e){return Ic(r=e.traceId,32)&&r!==uc&&(Ic(t=e.spanId,16)&&t!==lc);var t,r}function Sc(e){return new dc(e)}const Cc=ac.getInstance();class _c{startSpan(e,t,r=Cc.active()){if(Boolean(null==t?void 0:t.root))return new dc;const n=r&&bc(r);return null!==(i=n)&&"object"==typeof i&&"spanId"in i&&"string"==typeof i.spanId&&"traceId"in i&&"string"==typeof i.traceId&&"traceFlags"in i&&"number"==typeof i.traceFlags&&Lc(n)?new dc(n):new dc;var i}startActiveSpan(e,t,r,n){let i,o,s;if(arguments.length<2)return;2===arguments.length?s=t:3===arguments.length?(i=t,s=r):(i=t,o=r,s=n);const a=null!=o?o:Cc.active(),c=this.startSpan(e,i,a),l=vc(a,c);return Cc.with(l,s,void 0,c)}}const Dc=new _c;class Pc{constructor(e,t,r,n){this._provider=e,this.name=t,this.version=r,this.options=n}startSpan(e,t,r){return this._getTracer().startSpan(e,t,r)}startActiveSpan(e,t,r,n){const i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;const e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Dc}}const Nc=new class{getTracer(e,t,r){return new _c}};class Oc{getTracer(e,t,r){var n;return null!==(n=this.getDelegateTracer(e,t,r))&&void 0!==n?n:new Pc(this,e,t,r)}getDelegate(){var e;return null!==(e=this._delegate)&&void 0!==e?e:Nc}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,r){var n;return null===(n=this._delegate)||void 0===n?void 0:n.getTracer(e,t,r)}}const Ac=ac.getInstance(),$c="trace";class Rc{constructor(){this._proxyTracerProvider=new Oc,this.wrapSpanContext=Sc,this.isSpanContextValid=Lc,this.deleteSpan=yc,this.getSpan=mc,this.getActiveSpan=gc,this.getSpanContext=bc,this.setSpan=vc,this.setSpanContext=Ec}static getInstance(){return this._instance||(this._instance=new Rc),this._instance}setGlobalTracerProvider(e){const t=Ya($c,this._proxyTracerProvider,rc.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return Xa($c)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Ja($c,rc.instance()),this._proxyTracerProvider=new Oc}}const Tc=Rc.getInstance();function xc(e){const{source:t,module:r,operation:n,outcome:i}=e;if([t.source,r,n].some(e=>void 0!==e&&!ka.safeParse(e).success))throw new RangeError("Invalid operational telemetry identifier");const o=Tc.getSpanContext(Ac.active());return{...t,schemaVersion:1,module:r,operation:n,outcome:i,occurredAt:Date.now(),unit:"ms",...o?{traceId:o.traceId,spanId:o.spanId,traceFlags:o.traceFlags}:{}}}const kc={debug:Fa.Debug,information:Fa.Information,warning:Fa.Warning,error:Fa.Error,critical:Fa.Critical};function Fc(e){let t=!1;return r=>{try{const t=e();if(!t)return;if(!t.source)throw new Error("Operational telemetry requires host source identity");const n=t.source;if("notification"in r)return void t.trackEvent({name:`fusion.${r.module}.${r.operation}`,level:("string"==typeof r.level?kc[r.level]:r.level)??("failure"===r.outcome?Fa.Error:Fa.Information),scope:za(n),diagnostic:xc({...r,source:n}),...r.properties?{properties:{...r.properties}}:{}});for(const e of function(e){if(!Number.isFinite(e.duration)||e.duration<0)throw new RangeError("Invalid operational telemetry duration");const t=xc(e),r=`fusion.${e.module}.${e.operation}`,n={name:`${r}.duration`,type:Ua.Metric,level:Fa.Information,value:e.duration,scope:za(e.source),diagnostic:t,...e.properties?{properties:{...e.properties}}:{}};if("failure"!==e.outcome)return[n];const i=new Error(`${r} failed`);return i.name="OperationalError",i.stack=void 0,[n,{name:`${r}.failure`,type:Ua.Exception,level:Fa.Error,exception:Object.freeze(i),scope:n.scope,diagnostic:t,...e.properties?{properties:{...e.properties}}:{}}]}({...r,source:n}))t.track(e)}catch{t||(t=!0,console.warn("Operational telemetry delivery failed"))}}}const Uc={cancellations:new WeakSet,reasons:new WeakMap};function Bc(e){let t,r=e;for(let e=0;e<5&&r&&"object"==typeof r;e++){if(t??=Uc.reasons.get(r),Uc.cancellations.has(r))return{outcome:"cancelled",reason:t};r="cause"in r?r.cause:void 0}return{outcome:"failure",reason:t}}function Mc(e,t){return Uc.cancellations.add(e),t&&Uc.reasons.set(e,t),e}function Gc(e,t){return Uc.reasons.set(e,t),e}const jc=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,zc=/^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/;function Hc(e,t="key"){return"string"==typeof e&&("key"===t?jc:zc).test(e)?e:void 0}const qc=()=>{};class Vc{module;options;parent;classifyError=Bc;markCancellation=Mc;markReason=Gc;safeIdentity=Hc;#Te=new Set;#xe=new Set;#ke=[];#Fe;#Ue=!1;#Be=!1;#Me;constructor(e,t,r){this.module=e,this.options=t,this.parent=r,this.#Me=Fc(()=>this.#Ge())}get connected(){return this.active}get active(){return void 0!==this.#Ge()}get pending(){return this.#Te.size}connect=e=>{this.#Ue||(this.#Fe=e)};disconnect=()=>{this.close()};report=e=>{this.#Me({...e,module:this.module})};createScope(e){const t=new Vc(this.module,e,this);return this.#Ue&&t.close(),t}start(e,t){return this.reserve(e,t)??qc}reserve(e,t){if(!this.active)return;if(this.#Te.size>=256)return void this.#je("pending-operation capacity exceeded");const r=performance.now(),n=(i,o)=>{if(this.#Te.delete(n)){this.#ze();try{const n={...t,...this.options?.identity?.(),...o};this.report({operation:e,outcome:i,duration:Math.max(0,performance.now()-r),...Object.keys(n).length?{properties:n}:{}})}catch{this.#je("identity resolution failed")}}};return this.#Te.add(n),this.#He(),n}measure(e,t){return r=>{return n=()=>{const n=this.reserve(e,t);if(!n)return r;let i=!1;return r.pipe(eo({next:()=>{i=!0},error:e=>{const{outcome:t,reason:r}=Bc(e);n(t,r?{reason:r}:void 0)},complete:()=>n("success")}),Ki(()=>n(i?"success":"cancelled")))},new Fn(function(e){hi(n()).subscribe(e)});var n}}notify(e,t,r){this.report({operation:e,outcome:t,properties:r,notification:!0,level:"failure"===t?Fa.Warning:Fa.Information})}own(e){this.#qe()?this.#Ve(e):(this.#ke.push(e),this.#He())}cancelPending(e){for(const t of[...this.#Te])t("cancelled",e)}close(e){if(this.#Ue)return;for(const t of[...this.#xe])t.close(e);this.cancelPending(e),this.#Ue=!0,this.#Fe=void 0,this.parent&&(this.parent.#xe.delete(this),this.parent.#ze());const t=this.#ke;this.#ke=[];for(const e of t)this.#Ve(e)}#Ge(){if(!this.#Ue)return this.parent?this.parent.#Ge():this.#Fe}#qe(){return this.#Ue||!!this.parent&&this.parent.#qe()}#He(){this.parent&&(this.parent.#xe.add(this),this.parent.#He())}#ze(){this.#Te.size||this.#xe.size||this.#ke.length||this.parent&&(this.parent.#xe.delete(this),this.parent.#ze())}#Ve(e){try{"function"==typeof e?e():e.unsubscribe()}catch{this.#je("diagnostic teardown failed")}}#je(e){this.#Be||(this.#Be=!0,console.warn(`Operational telemetry for ${this.module}: ${e}`))}}class Wc extends uo{config;_http;constructor(e,t){super({version:"10.3.0-next.0",config:e}),this.config=e,this._http=t,this._addTeardown(()=>{this.#We?.unsubscribe(),this.#Ze.disconnect()})}#Ze=function(e,t){if(!ka.safeParse(e).success)throw new RangeError("Invalid operational telemetry module");return new Vc(e,t)}("service-discovery");#We;connectTelemetry(e){this.#Ze.connect(e);const t=this.client.diagnostic$;if(this.#We||!this.#Ze.connected||!t)return;const r=this.#Ze.report;this.#We=t.subscribe(e=>{if("unknown-service"===e.type)return void r({notification:!0,operation:"unknown-service",outcome:"failure",level:Fa.Warning});const{outcome:t,origin:n,duration:i}=e;r({operation:"resolve",outcome:t,duration:i}),"cache"===n?r({notification:!0,operation:"cache-hit",outcome:t,level:Fa.Information}):"network"!==n&&r({notification:!0,operation:n,outcome:t,level:Fa.Warning})})}get client(){return this.config.discoveryClient}resolveServices(){return this.config.discoveryClient.resolveServices()}async resolveService(e){return this.config.discoveryClient.resolveService(e)}async createClient(e,t){const r=await this.resolveService(e);if(!r)throw Error(`Could not load configuration of service [${e}]`);return this._http.createClient({...t,baseUri:r.uri,defaultScopes:r.scopes})}async configureClient(e,t){const{key:r,alias:n}="string"==typeof e?{key:e,alias:e}:e,{uri:i,scopes:o}=await this.resolveService(r);var s,a;t.addConfig((s=n,a={baseUri:i,defaultScopes:o},{module:Fo,configure:e=>{e.configureClient(s,a)}}))}}const Zc=new WeakMap,Kc={name:"serviceDiscovery",configure:()=>new xa,initialize:async e=>{const{requireInstance:t,ref:r}=e,n=await e.config.createConfigAsync(e,{...r?.serviceDiscovery?.config}),i=await t("http"),o=new Wc(n,i);return Zc.set(o,o),o},postInitialize:async({instance:e,modules:t,ref:r})=>{e.client!==r?.serviceDiscovery?.client&&e.connectTelemetry?.(t.telemetry)},dispose:({instance:e})=>{Zc.get(e)?.dispose(),Zc.delete(e)}},Yc=(e,t)=>{e.addConfig((e=>({module:Kc,configure:t=>e(t)}))(()=>Promise.resolve()))};var Xc,Jc,Qc,el={},tl=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}];function rl(){return Xc||(Xc=1,function(e){const t=tl,r=process.env;function n(e){return"string"==typeof e?!!r[e]:"env"in e?r[e.env]&&r[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!r[e]}):Object.keys(e).every(function(t){return r[t]===e[t]})}Object.defineProperty(e,"_vendors",{value:t.map(function(e){return e.constant})}),e.name=null,e.isPR=null,e.id=null,"false"!==r.CI&&t.forEach(function(t){const i=(Array.isArray(t.env)?t.env:[t.env]).every(function(e){return n(e)});e[t.constant]=i,i&&(e.name=t.name,e.isPR=function(e){switch(typeof e.pr){case"string":return!!r[e.pr];case"object":return"env"in e.pr?"any"in e.pr?e.pr.any.some(function(t){return r[e.pr.env]===t}):e.pr.env in r&&r[e.pr.env]!==e.pr.ne:"any"in e.pr?e.pr.any.some(function(e){return!!r[e]}):n(e.pr);default:return null}}(t),e.id=t.constant)}),e.isCI=!("false"===r.CI||!(r.BUILD_ID||r.BUILD_NUMBER||r.CI||r.CI_APP_ID||r.CI_BUILD_ID||r.CI_BUILD_NUMBER||r.CI_NAME||r.CONTINUOUS_INTEGRATION||r.RUN_ID||e.name))}(el)),el}var nl,il=V(Qc?Jc:(Qc=1,Jc=rl().isCI));!function(e){e.ContinuesIntegration="ci",e.QualityAssurance="fqa",e.Training="tr",e.Production="fprd",e.Development="dev"}(nl||(nl={}));const ol=["5a842df8-3238-415d-b168-9f16a6a6031b/.default"],sl=e=>{const t=new yo,r=e.env??nl.ContinuesIntegration;t.addConfig({module:Fo,configure:t=>{const n=r===nl.Development?nl.ContinuesIntegration:r,i=e.serviceDiscovery?.url??new URL(`/service-registry/environments/${n}/services`,"https://discovery.fusion.equinor.com").toString(),o=e.serviceDiscovery?.scope??ol;t.defaultHttpRequestHandler.set("fusion-cli-identification",xr),t.configureClient("service_discovery",{baseUri:i,defaultScopes:o})}}),Yc(t);const{auth:n}=e;return q(t,e=>{if("defaultCredential"in n&&n.defaultCredential)return void e.setDefaultCredential();if("token"in n&&n.token)return void e.setTokenOnly(n.token);const{clientId:t,tenantId:r}=n;if(!t||!r)throw new Error("clientId and tenantId are required for auth module");if("interactive"in n&&n.interactive){const{server:i}=n;if(!i.port)throw new Error("server.port is required for interactive mode");return void e.setInteractive({tenantId:r,clientId:t,redirectPort:i.port,onOpen:i.onOpen})}il?e.setDefaultCredential():e.setInteractive({tenantId:r,clientId:t,redirectPort:49741})}),t},al=async(e,t)=>{const r=sl(e);t&&t(r);return await r.initialize()},cl=e=>{const t=e.getEntry("metadata.json");if(!t)throw new Error("Metadata file not found in bundle");return new Promise((e,r)=>{t.getDataAsync((t,n)=>{if(n)return r(new Error("Failed to read metadata file",{cause:n}));try{return e(JSON.parse(String(t)))}catch(e){r(new Error("Failed to parse metadata file",{cause:e}))}})})},ll=async e=>{const{log:t,bundle:r}=e;let n;if(r)try{t?.info("🗜ïļ","Using artifact-based validation from bundle:",r);const e=new yr(r),i=await(async e=>{const t=await cl(e);if(!t.appKey||"string"!=typeof t.appKey||""===t.appKey.trim())throw new Error("App manifest is missing required appKey field");return t})(e);n=i.appKey,t?.info("ðŸ“Ķ",`Resolved app key "${n}" from bundle artifact`)}catch(e){return t?.fail("ðŸšŦ","Failed to resolve app information from bundle:",e instanceof Error?e.message:String(e)),!1}else{t?.info("📁","Using traditional validation from local project files");const e=await _t(t);n=(await Ct({command:"build",mode:"production"},e,{log:t})).appKey}t?.start("Initializing Fusion Framework...");const i=await al({env:e.environment,auth:"token"in e.auth?{token:e.auth.token}:e.auth});t?.succeed("Initialized Fusion Framework");try{const e=await i.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)}),t?.info("Checking if",n,"is registered in app store");const r=await e.fetch(`/apps/${n}`,{method:"HEAD",headers:Tr});if(r.ok)return t?.succeed("😃",`Application ${n} is registered in app store`),!0;if(404===r.status)return t?.fail("😞",`Application ${n} is not registered in app store`),!1;if(410===r.status)return t?.fail("😞",`Application ${n} is deleted from app store`),!1;const o=Mr(r.status,`check registration for ${n}`);throw o&&(t?.fail("🔒",`Authentication/authorization error checking ${n}`),t?.error(o),process.exit(1)),new Error(`Unexpected response status: ${r.status}`)}catch(e){const r=zr(e,`check registration for ${n}`);return r&&(t?.fail("🔒",`Token acquisition failed checking ${n}`),t?.error(r),process.exit(1)),t?.fail("🙅‍♂ïļ","Error checking application registration"),t?.error("Error checking application registration:",e instanceof Error?e.message:e),!1}},ul=x.object({error:x.object({code:x.string(),message:x.string(),resourceIdentifier:x.string().optional()})});const fl=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new yr(e.fileOrBundle):e.fileOrBundle,{appKey:o}=e.appKey?{appKey:e.appKey}:await cl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)});t?.info("ðŸ“Ķ",`Uploading application bundle for ${i.bold(o)}`);const s=(await n.getEntries()).map(e=>e.entryName);t?.debug("Bundle contents:",s);const a=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const s=await r.serviceDiscovery.createClient("apps");s.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const c=await s.fetch(`/bundles/apps/${o}`,{method:"POST",body:new Blob([a],{type:"application/zip"}),headers:{...Tr,"Content-Type":"application/zip"}});if(!c.ok){let r;try{const e=ul.safeParse(await c.json());if(e.success){r=e.data;const{error:n}=r;t?.debug("Error:",n),t?.warn(i.red(`ðŸĪŊ error: ${n.code}\n`),i.yellowBright(n.message),"\n")}else t?.debug("Unrecognized upload error response:",e.error)}catch(e){t?.debug("Failed to parse upload error response:",e)}if(!0===e.allowExistingVersion&&409===c.status&&"ConflictError"===r?.error.code&&"version"===r.error.resourceIdentifier){const e=n.getEntry("app-manifest.json");if(!e)throw new Error("Cannot recover existing version: app-manifest.json is missing");const t=x.object({version:x.string().refine(e=>null!==R(e))}).parse(JSON.parse(e.getData().toString())).version.toLowerCase();if("string"!=typeof o||!o.trim())throw new Error("Cannot recover existing version: application key is missing");if(r.error.message===`An app build with version ${t} already exists`)return{appKey:o,version:t,existingVersion:!0}}!function(e,t,r){const n=Mr(e.status,`upload bundle for ${t}`);let i;switch(n&&(r?.fail("🔒",`Authentication/authorization error uploading ${t}`),r?.error(n),process.exit(1)),e.status){case 409:i=`${e.status} - Version is already published, please generate a new release`;break;case 410:i=`${e.status} - ${t} is removed from Fusion app store`;break;case 404:i=`${e.status} - ${t} not found, please add your application in App Admin before publishing`;break;case 500:i=`${e.status} - Internal server error, please try again later or contact support`;break;default:i=`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`}r?.fail("🙅‍♂ïļ",i),process.exit(1)}(c,o,t)}t?.succeed("Successfully uploaded application bundle"),t?.debug("Response:",c);try{return{appKey:o,version:(await c.json()).version}}catch(e){t?.fail("🙅‍♂ïļ",`Failed to parse response from app service: ${e instanceof Error?e.message:e}`),process.exit(1)}}catch(e){const r=zr(e,`upload bundle for ${o}`);r&&(t?.fail("🔒",`Token acquisition failed uploading ${o}`),t?.error(r),process.exit(1)),t?.fail("🙅‍♂ïļ","Failed to upload application bundle"),t?.error(e instanceof Error?e.message:e),process.exit(1)}},dl=async e=>{const{tag:t,appKey:r,version:n,framework:o,log:s}=e;t&&"string"==typeof t&&0!==t.trim().length||(s?.fail("ðŸĪŠ","Tag must be a non-empty string."),process.exit(1)),/^[a-zA-Z0-9.-]+$/.test(t)||(s?.fail("ðŸĪŠ",'Invalid tag. Use "latest", "preview" or string [a-z, A-Z, 0-9, ".", "-"].'),process.exit(1)),r||(s?.fail("ðŸĪŠ","Application key is required."),process.exit(1)),n||(s?.fail("ðŸĪŠ","Version is required."),process.exit(1));try{const e=await o.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{s?.debug("Request:",e),s?.info("🌎","Executing request to:",St(e.uri))}),s?.start("Publishing application config");const a=await e.json(`/apps/${r}/tags/${t}`,{method:"PUT",body:{version:n},headers:Tr});return s?.debug("Response:",a),s?.succeed("Tagged application successfully",i.greenBright(`${r}@${n} - ${t}`)),a}catch(e){if(e instanceof Xr)switch(e.response.status){case 410:s?.fail("ðŸĪŽ",`App ${r} is deleted from apps-service. Please check the app key and try again.`);break;case 404:s?.fail("ðŸĪŽ",`App ${r} not found. Please check the app key and try again.`);break;case 403:case 401:{const t=Mr(e.response.status,`tag ${r}@${n}`);s?.fail("🔒","Authentication/authorization error tagging application."),t&&s?.error(t),process.exit(1);break}default:s?.fail("ðŸĪŽ","Failed to tag application",`Status code: ${e.response.status}`,`Error: ${e.message}`)}const t=zr(e,`tag ${r}@${n}`);t&&(s?.fail("🔒",`Token acquisition failed tagging ${r}@${n}`),s?.error(t),process.exit(1)),s?.fail("ðŸĪŽ","Failed to tag application:",e instanceof Error?e.message:String(e)),process.exit(1)}},pl=x.object({templateEntry:x.string({message:"templateEntry must be a string"}).describe("Main entry point for the portal"),schemaEntry:x.string({message:"schemaEntry must be a string"}).describe("Schema file for portal validation"),assetPath:x.string({message:"assetPath must be a string"}).optional().describe("Asset path for dev/preview builds"),githubRepo:x.string({message:"githubRepo must be a string"}).optional().describe("GitHub repo URL or local git remote"),version:x.string({message:"version must be a string"}).describe("Version from package.json"),timestamp:x.string({message:"timestamp must be a string"}).describe("Current build timestamp (ISO8601)"),commitSha:x.string({message:"commitSha must be a string"}).describe("Current git commit SHA"),annotations:x.record(x.string(),x.string().nullish()).optional().transform(e=>{if(!e)return;const t=Object.entries(e).filter(([,e])=>void 0!==e);return Object.fromEntries(t)}).describe("Optional build annotations"),projectPage:x.string({message:"projectPage must be a string"}).optional().describe("Optional project homepage"),allowedExtensions:x.array(x.string({message:"Each allowed extension must be a string"}),{message:"allowedExtensions must be an array of strings"}).describe("List of allowed asset extensions (with leading dot)"),schema:x.record(x.string(),x.unknown()).optional().describe("Optional schema for the portal"),config:x.record(x.string(),x.unknown()).optional().describe("Optional configuration for the portal")}),hl=x.object({name:x.string({message:"name must be a string"}).describe("Short app key (unscoped, derived from package name)"),displayName:x.string({message:"displayName must be a string"}).optional().describe("Full package name, may include scope"),description:x.string({message:"description must be a string"}).optional().describe("Description of the portal"),build:pl}),ml=(e,t)=>{dt(t,"expected packageJson"),P(t.name,"expected [name] in packageJson"),P(t.version,"expected [version] in packageJson");const r=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/bundle.js":lt(e.root))(e,t),n=t.name.replace(/^@|\w.*\//gm,""),i=t.version,o="build"===e.command?void 0:"/@fs",s=pt(t)??ht(),a=bt.map(e=>`.${e}`),c={name:n,displayName:t.name,description:t.description||"",build:{templateEntry:r,schemaEntry:"portal.schema.json",assetPath:o,githubRepo:s,version:i,timestamp:(new Date).toISOString(),commitSha:mt(),annotations:{...Et()},projectPage:t.homepage,allowedExtensions:a}},l=hl.safeParse(c);if(!l.success){const e=l.error.issues.map(e=>`- ${e.path.join(".")}: ${e.message}`).join("\n");throw new Error(["Invalid portal manifest generated from package.json:",e].join("\n"))}return l.data},gl=async(e,t,r)=>{const n=ml(e,t.packageJson);try{r?.log?.start("loading manifest...");const t=await(async(e,t)=>{const r=t?.file??[`portal.manifest.${e.environment}`,"portal.manifest"],n=await L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};let i;return i="function"==typeof r.default?await r.default(e,{base:n})??void 0:r.default,i?C(n,i):n}}}),i=n.config,o=hl.safeParse(i);if(!o.success){const e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");throw new Error(`Invalid portal manifest: ${e}`)}return{manifest:i,path:n.path,extension:n.extension}})(e,{base:n});return r?.log?.succeed("generated manifest from",St(t.path,{relative:!0})),t.manifest}catch(e){if(e instanceof S){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${St(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(i.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?St(r?.manifestPath):""}`),e}},vl=async(e,t)=>{const{log:r}=t;try{r?.start("create portal configuration"),r?.info(`generating config with ${i.red.dim(e.command)} command in ${i.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`portal.config.${e.environment}`,"portal.config"];return L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.schema??T.object({}).passthrough(),i=t?.base??{};if("function"==typeof r.default){const t=await r.default(i,e)??i;return n.parse(t)}return n.parse(r.default??i)}}})})(e,{file:t?.config});return r?.succeed("⚙ïļ generated config from ",St(n.path,{relative:!0})),n.config}catch(e){if(e instanceof S){if(!t.config)return r?.succeed(i.dim("⚙ïļ no local portal config applied, using built-in")),{};r?.warn(`failed to load config file ${St(t.config)}, please check the path.`)}throw r?.fail("failed to resolve portal config"),r?.debug(e),e}},yl=async e=>{const{log:r}=e??{},n=await _t(r),i={root:n.root,environment:"local",...e?.env,mode:"development",command:"serve"},o=await gl(i,n,{log:r,manifestPath:e?.manifest}),s=await vl(i,{log:r,config:e?.config}),a=t(await ft(i,n),{server:{port:e?.server?.port,fs:{allow:[n.root]}}}),c={template:{portal:{id:o.name}},portal:{manifest:o,config:s}};r?.debug("vite config:",a),r?.debug("dev server config:",c),r?.start("Starting app development server...");const l=await $r(i,c,{overrides:a,log:r});return await l.listen(),r?.succeed(`Started app development server on ${l.resolvedUrls?.local?.[0]}`),l},El=async e=>{const{log:r,dir:n,port:i=4173,host:o="localhost"}=e??{};r?.log("Starting to serve portal");const s=await _t(r);r?.start("Loading Vite config...");const c=await ft({root:s.root,command:"build",mode:"production"},s);r?.succeed("Vite config loaded");const l=n||(c.build?.outDir||"dist"),u=a(s.root,l),f={root:s.root,environment:"local",mode:"production",command:"serve",isPreview:!0},d=await gl(f,s,{log:r,manifestPath:e?.manifest}),p=await vl(f,{log:r,config:e?.config});if(r?.debug("Output directory:",u),!b(u))throw new Error(`Build directory does not exist: ${u}\nPlease build the portal first using \`ffc portal build\``);d.build.assetPath=void 0,d.build.templateEntry=`/${d.build.templateEntry}`;const h=await ft(f,s),m=t(h,{server:{port:i,host:o||h.server?.host||"localhost",fs:{allow:[s.root,u]}}}),g={template:{portal:{id:d.name}},portal:{manifest:d,config:p}};r?.debug("vite config:",m),r?.debug("dev server config:",g),r?.start("Starting preview server...");try{const e=await $r(f,g,{overrides:m,log:r});await e.listen(),r?.succeed("Preview server started successfully");const t=e.config.server?.https?"https":"http",n=e.config.server?.host||o,s=e.config.server?.port||i;return r?.info(`Preview server is running at: ${t}://${n}:${s}`),e}catch(e){throw r?.fail("Failed to start preview server"),e}},bl=async e=>{const{log:t}=e??{},r=await _t(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await gl(n,r,{log:t,manifestPath:e?.manifest});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},wl=async e=>{const{log:t}=e??{};t?.log(i.bold("Starting to build portal"));const{manifest:n,pkg:o,env:s}=await bl({log:t,manifest:e?.manifest});t?.start("loading vite config...");const a=await ft(s,o);t?.succeed("vite config applied"),t?.debug("vite config:",a),t?.start("ðŸĪžðŸŧ","building portal..."),t?.startNativeConsoleCapture(),await r(a),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:o,manifest:n,outDir:a.build.outDir}},Il=async e=>{const{log:t,manifest:r}=e,n={command:"build",mode:process.env.NODE_ENV??"production",environment:null,root:process.cwd()},{pkg:i,manifest:o}=await wl({log:t,manifest:r});if(!o.build)throw new Error("Manifest build config not found");const s=await(async(e,t)=>{const r=t?.file??[`portal.schema.${e.environment}`,"portal.schema"],n=await L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async t=>{const r="function"==typeof t.default?await Promise.resolve(t.default(e)):t.default;if(!r)throw new Error("Schema function did not return a valid schema");return r}}});return{schema:n.config,path:n.path,extension:n.extension}})(n,{file:e?.schema});t?.debug("Schema:",s);return{archive:await Vr(i,{log:t,archive:e?.archive,content:{"portal-template-manifest.json":JSON.stringify(o.build,null,2),"portal.schema.json":JSON.stringify(s.schema,null,2),"metadata.json":JSON.stringify({name:o.name,version:o.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:o,schema:s.schema}},Ll=async e=>{const{log:t}=e??{},r=await _t(t),n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env},i=await vl(n,{log:t,config:e?.config});if(t?.debug("config:",i),e?.output){t?.start("writing config to file");try{await Hr(e.output,JSON.stringify(i,null,2)),t?.succeed("config written successfully",St(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:i,pkg:r}},Sl=async e=>{const{log:t,portal:r}=e,{config:n}=await Ll({log:t,config:e.config,env:{environment:e.environment}});t?.start("Initializing Fusion Framework...");const o=await al({env:e.environment,auth:e.auth});t?.succeed("Initialized Fusion Framework");try{const s=await o.serviceDiscovery.createClient("portals");s.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",St(e.uri))}),t?.start("Publishing portal config"),t?.info("Using environment:",i.redBright(e.environment));const a=await s.json(`/portals/${r.name}@${r.version}/config`,{method:"PUT",body:n,headers:Tr});t?.debug("Response:",a),t?.succeed("Published portal config")}catch(e){if(e instanceof Xr)switch(e.response.status){case 410:t?.fail("ðŸĪŽ",`Portal ${r.name} is deleted from portals-service. Please check the portal key and try again.`);break;case 404:t?.fail("ðŸĪŽ",`Portal ${r.name} not found. Please check the portal key and try again.`);break;case 403:case 401:{const n=Mr(e.response.status,`publish config for portal ${r.name}`);t?.fail("🔒","Authentication/authorization error publishing portal config."),n&&t?.error(n),process.exit(1);break}default:t?.fail("ðŸĪŽ","Failed to publish portal config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}const n=zr(e,`publish config for portal ${r.name}`);n&&(t?.fail("🔒",`Token acquisition failed publishing config for ${r.name}`),t?.error(n),process.exit(1)),t?.fail("ðŸĪŽ","Failed to publish portal config:",e instanceof Error?e.message:String(e)),process.exit(1)}};const Cl=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new yr(e.fileOrBundle):e.fileOrBundle,{name:o}=e.name?{name:e.name}:await cl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)}),s=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const e=await r.serviceDiscovery.createClient("portal-config");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const n=await e.fetch(`/bundles/templates/${o}`,{method:"POST",body:new Blob([s],{type:"application/zip"}),headers:{...Tr,"Content-Type":"application/zip"}});if(!n.ok){try{const{error:e}=await n.json();t?.debug("Error:",e),e.message&&t?.warn(i.red(`ðŸĪŊ error: ${e.code}\n`),i.yellowBright(e.message),"\n")}catch(e){t?.debug("Error:",n.statusText)}!function(e,t,r){const n=Mr(e.status,`upload portal bundle for ${t}`);let i;switch(n&&(r?.fail("🔒",`Authentication/authorization error uploading ${t}`),r?.error(n),process.exit(1)),e.status){case 409:i=`${e.status} - Version is already published, please generate a new release`;break;case 410:i=`${e.status} - ${t} is removed from Fusion`;break;case 404:i=`${e.status} - ${t} not found`;break;case 500:i=`${e.status} - Internal server error, please try again later or contact support`;break;default:i=`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`}r?.fail("🙅‍♂ïļ",i),process.exit(1)}(n,o,t)}t?.succeed("Successfully uploaded portal bundle"),t?.debug("Response:",n)}catch(e){const r=zr(e,`upload portal bundle for ${o}`);r&&(t?.fail("🔒",`Token acquisition failed uploading ${o}`),t?.error(r),process.exit(1)),t?.fail("🙅‍♂ïļ","Failed to upload portal bundle"),t?.error(e instanceof Error?e.message:e),process.exit(1)}},_l=async e=>{const{tag:t,name:r,version:n,framework:o,log:s}=e;t&&"string"==typeof t&&0!==t.trim().length||(s?.fail("ðŸĪŠ","Tag must be a non-empty string."),process.exit(1)),/^[a-zA-Z0-9.-]+$/.test(t)||(s?.fail("ðŸĪŠ",'Invalid tag. Use "latest", "preview" or string [a-z, A-Z, 0-9, ".", "-"].'),process.exit(1)),r||(s?.fail("ðŸĪŠ","Portal name is required."),process.exit(1)),n||(s?.fail("ðŸĪŠ","Version is required."),process.exit(1)),s?.info("Tagging portal:",i.greenBright(`${r}@${t}`,n));try{const e=await o.serviceDiscovery.createClient("portal-config");e.request$.subscribe(e=>{s?.debug("Request:",e),s?.info("🌎","Executing request to:",St(e.uri))}),s?.start("Tagging portal template...");const i=await e.json(`/templates/${r}/tags/${t}`,{method:"PUT",body:{version:n},headers:Tr});s?.debug("Response:",i),s?.succeed("Tagged portal template successfully"),s?.info("🚀",JSON.stringify(i))}catch(e){if(e instanceof Xr){const{data:t,response:o}=e;switch(s?.debug("Error:",t),t&&s?.warn(i.red(`ðŸĪŊ error: ${t.code}\n`),i.yellowBright(t.message),"\n"),o?.status){case 410:s?.fail(`ðŸĪŽ - ${o?.status} -`,`${r} is deleted. Please check the name and try again.`);break;case 404:s?.fail(`ðŸĪŽ - ${o?.status} -`,`${r} not found. Please check the name and try again.`);break;case 403:case 401:{const e=Mr(o?.status??401,`tag portal ${r}@${n}`);s?.fail("🔒","Authentication/authorization error tagging portal."),e&&s?.error(e),process.exit(1);break}default:s?.fail(`ðŸĪŽ - ${o?.status} -`,"Failed to tag",`Error: ${e.message}`)}}const t=zr(e,`tag portal ${r}@${n}`);t&&(s?.fail("🔒",`Token acquisition failed tagging ${r}@${n}`),s?.error(t),process.exit(1)),s?.fail("ðŸĪŽ","Failed to tag portal:",e instanceof Error?e.message:String(e)),process.exit(1)}},Dl=e=>e&&!il?nl.Development:nl.ContinuesIntegration;export{Nr as ConsoleLogger,nl as FusionEnv,Pt as buildApplication,wl as buildPortal,Wr as bundleApp,Il as bundlePortal,ll as checkApp,sl as configureFramework,Tr as defaultHeaders,Kr as generateApplicationConfig,Ll as generatePortalConfig,al as initializeFramework,Dt as loadAppManifest,bl as loadPortalManifest,Vr as pack,en as publishAppConfig,Sl as publishPortalConfig,Dl as resolveDefaultEnv,rn as serveApplication,El as servePortal,tn as startAppDevServer,yl as startPortalDevServer,dl as tagApplication,_l as tagPortal,fl as uploadApplication,Cl as uploadPortalBundle};
1
+ import{loadConfigFromFile as e,mergeConfig as t,build as r,loadEnv as n}from"vite";import i from"chalk";import o from"vite-tsconfig-paths";import{dirname as s,resolve as a,basename as c,extname as l,relative as u}from"node:path";import{readPackageUp as f}from"read-package-up";import d,{fileURLToPath as p}from"node:url";import h from"node:module";import m from"util";import{accessSync as g,constants as v,readFileSync as y,statSync as E,existsSync as b,mkdirSync as w,writeFileSync as I}from"node:fs";import{importConfig as L,FileNotFoundError as S}from"@equinor/fusion-imports";import C from"deepmerge";import{reactRouterPlugin as _}from"@equinor/fusion-framework-vite-plugin-react-router";import{rawImportsPlugin as D}from"@equinor/fusion-framework-vite-plugin-raw-imports";import P from"node:assert";import{execSync as N}from"node:child_process";import{coerce as O,SemVer as A,satisfies as $,valid as R}from"semver";import T,{z as x}from"zod";import k from"fs";import F from"path";import U from"zlib";import B from"crypto";import{stat as M,mkdir as G}from"node:fs/promises";import j from"ora";import{processServices as z,createDevServer as H}from"@equinor/fusion-framework-dev-server";import{enableAzureIdentityAuth as q}from"@equinor/fusion-framework-module-azure-identity";function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W,Z,K,Y;function X(){if(Z)return W;Z=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return W=e}function J(){if(Y)return K;Y=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return K={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}var Q,ee,te,re,ne,ie,oe,se,ae,ce,le,ue,fe,de={exports:{}};function pe(){return Q||(Q=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=J(),o=X(),s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],u=t.t={};let f=0;const d="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[d,n]],h=(e,t,r)=>{const n=(e=>{for(const[t,r]of p)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=f++;o(e,i,t),u[e]=i,c[i]=t,l[i]=n,s[i]=new RegExp(t,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};h("NUMERICIDENTIFIER","0|[1-9]\\d*"),h("NUMERICIDENTIFIERLOOSE","\\d+"),h("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),h("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASEIDENTIFIER",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h("BUILDIDENTIFIER",`${d}+`),h("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h("FULL",`^${c[u.FULLPLAIN]}$`),h("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h("LOOSE",`^${c[u.LOOSEPLAIN]}$`),h("GTLT","((?:<|>)?=?)"),h("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),h("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),h("COERCERTL",c[u.COERCE],!0),h("COERCERTLFULL",c[u.COERCEFULL],!0),h("LONETILDE","(?:~>?)"),h("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",h("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h("LONECARET","(?:\\^)"),h("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",h("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",h("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h("STAR","(<|>)?=?\\s*\\*"),h("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),h("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(de,de.exports)),de.exports}function he(){if(oe)return ie;oe=1;const e=X(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=J(),{safeRe:n,t:i}=pe(),o=function(){if(te)return ee;te=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return ee=r=>r?"object"!=typeof r?e:r:t}(),{compareIdentifiers:s}=function(){if(ne)return re;ne=1;const e=/^[0-9]+$/,t=(t,r)=>{if("number"==typeof t&&"number"==typeof r)return t===r?0:t<r?-1:1;const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:t<r?-1:1};return re={compareIdentifiers:t,rcompareIdentifiers:(e,r)=>t(r,e)}}();class a{constructor(s,c){if(c=o(c),s instanceof a){if(s.loose===!!c.loose&&s.includePrerelease===!!c.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",s,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const l=s.trim().match(c.loose?n[i.LOOSE]:n[i.FULL]);if(!l)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");l[4]?this.prerelease=l[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(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(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=t.prerelease[r];if(e("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}compareBuild(t){t instanceof a||(t=new a(t,this.options));let r=0;do{const n=this.build[r],i=t.build[r];if(e("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];if(!1===r&&(n=[t]),((e,t)=>{const r=t.split(".");if(r.length>e.length)return!1;for(let t=0;t<r.length;t++)if(0!==s(e[t],r[t]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=n)}else 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}}return ie=a}function me(){if(ae)return se;ae=1;const e=he();return se=(t,r,n=!1)=>{if(t instanceof e)return t;try{return new e(t,r)}catch(e){if(!n)return null;throw e}},se}var ge,ve,ye,Ee,be,we,Ie,Le,Se,Ce,_e=["0BSD","3D-Slicer-1.0","AAL","ADSL","AFL-1.1","AFL-1.2","AFL-2.0","AFL-2.1","AFL-3.0","AGPL-1.0-only","AGPL-1.0-or-later","AGPL-3.0-only","AGPL-3.0-or-later","AMD-newlib","AMDPLPA","AML","AML-glslang","AMPAS","ANTLR-PD","ANTLR-PD-fallback","APAFML","APL-1.0","APSL-1.0","APSL-1.1","APSL-1.2","APSL-2.0","ASWF-Digital-Assets-1.0","ASWF-Digital-Assets-1.1","Abstyles","AdaCore-doc","Adobe-2006","Adobe-Display-PostScript","Adobe-Glyph","Adobe-Utopia","Afmparse","Aladdin","Apache-1.0","Apache-1.1","Apache-2.0","App-s2p","Arphic-1999","Artistic-1.0","Artistic-1.0-Perl","Artistic-1.0-cl8","Artistic-2.0","Artistic-dist","Aspell-RU","BSD-1-Clause","BSD-2-Clause","BSD-2-Clause-Darwin","BSD-2-Clause-Patent","BSD-2-Clause-Views","BSD-2-Clause-first-lines","BSD-2-Clause-pkgconf-disclaimer","BSD-3-Clause","BSD-3-Clause-Attribution","BSD-3-Clause-Clear","BSD-3-Clause-HP","BSD-3-Clause-LBNL","BSD-3-Clause-Modification","BSD-3-Clause-No-Military-License","BSD-3-Clause-No-Nuclear-License","BSD-3-Clause-No-Nuclear-License-2014","BSD-3-Clause-No-Nuclear-Warranty","BSD-3-Clause-Open-MPI","BSD-3-Clause-Sun","BSD-3-Clause-acpica","BSD-3-Clause-flex","BSD-4-Clause","BSD-4-Clause-Shortened","BSD-4-Clause-UC","BSD-4.3RENO","BSD-4.3TAHOE","BSD-Advertising-Acknowledgement","BSD-Attribution-HPND-disclaimer","BSD-Inferno-Nettverk","BSD-Protection","BSD-Source-Code","BSD-Source-beginning-file","BSD-Systemics","BSD-Systemics-W3Works","BSL-1.0","BUSL-1.1","Baekmuk","Bahyph","Barr","Beerware","BitTorrent-1.0","BitTorrent-1.1","Bitstream-Charter","Bitstream-Vera","BlueOak-1.0.0","Boehm-GC","Boehm-GC-without-fee","Borceux","Brian-Gladman-2-Clause","Brian-Gladman-3-Clause","C-UDA-1.0","CAL-1.0","CAL-1.0-Combined-Work-Exception","CATOSL-1.1","CC-BY-1.0","CC-BY-2.0","CC-BY-2.5","CC-BY-2.5-AU","CC-BY-3.0","CC-BY-3.0-AT","CC-BY-3.0-AU","CC-BY-3.0-DE","CC-BY-3.0-IGO","CC-BY-3.0-NL","CC-BY-3.0-US","CC-BY-4.0","CC-BY-NC-1.0","CC-BY-NC-2.0","CC-BY-NC-2.5","CC-BY-NC-3.0","CC-BY-NC-3.0-DE","CC-BY-NC-4.0","CC-BY-NC-ND-1.0","CC-BY-NC-ND-2.0","CC-BY-NC-ND-2.5","CC-BY-NC-ND-3.0","CC-BY-NC-ND-3.0-DE","CC-BY-NC-ND-3.0-IGO","CC-BY-NC-ND-4.0","CC-BY-NC-SA-1.0","CC-BY-NC-SA-2.0","CC-BY-NC-SA-2.0-DE","CC-BY-NC-SA-2.0-FR","CC-BY-NC-SA-2.0-UK","CC-BY-NC-SA-2.5","CC-BY-NC-SA-3.0","CC-BY-NC-SA-3.0-DE","CC-BY-NC-SA-3.0-IGO","CC-BY-NC-SA-4.0","CC-BY-ND-1.0","CC-BY-ND-2.0","CC-BY-ND-2.5","CC-BY-ND-3.0","CC-BY-ND-3.0-DE","CC-BY-ND-4.0","CC-BY-SA-1.0","CC-BY-SA-2.0","CC-BY-SA-2.0-UK","CC-BY-SA-2.1-JP","CC-BY-SA-2.5","CC-BY-SA-3.0","CC-BY-SA-3.0-AT","CC-BY-SA-3.0-DE","CC-BY-SA-3.0-IGO","CC-BY-SA-4.0","CC-PDDC","CC-PDM-1.0","CC-SA-1.0","CC0-1.0","CDDL-1.0","CDDL-1.1","CDL-1.0","CDLA-Permissive-1.0","CDLA-Permissive-2.0","CDLA-Sharing-1.0","CECILL-1.0","CECILL-1.1","CECILL-2.0","CECILL-2.1","CECILL-B","CECILL-C","CERN-OHL-1.1","CERN-OHL-1.2","CERN-OHL-P-2.0","CERN-OHL-S-2.0","CERN-OHL-W-2.0","CFITSIO","CMU-Mach","CMU-Mach-nodoc","CNRI-Jython","CNRI-Python","CNRI-Python-GPL-Compatible","COIL-1.0","CPAL-1.0","CPL-1.0","CPOL-1.02","CUA-OPL-1.0","Caldera","Caldera-no-preamble","Catharon","ClArtistic","Clips","Community-Spec-1.0","Condor-1.1","Cornell-Lossless-JPEG","Cronyx","Crossword","CryptoSwift","CrystalStacker","Cube","D-FSL-1.0","DEC-3-Clause","DL-DE-BY-2.0","DL-DE-ZERO-2.0","DOC","DRL-1.0","DRL-1.1","DSDP","DocBook-DTD","DocBook-Schema","DocBook-Stylesheet","DocBook-XML","Dotseqn","ECL-1.0","ECL-2.0","EFL-1.0","EFL-2.0","EPICS","EPL-1.0","EPL-2.0","EUDatagrid","EUPL-1.0","EUPL-1.1","EUPL-1.2","Elastic-2.0","Entessa","ErlPL-1.1","Eurosym","FBM","FDK-AAC","FSFAP","FSFAP-no-warranty-disclaimer","FSFUL","FSFULLR","FSFULLRSD","FSFULLRWD","FSL-1.1-ALv2","FSL-1.1-MIT","FTL","Fair","Ferguson-Twofish","Frameworx-1.0","FreeBSD-DOC","FreeImage","Furuseth","GCR-docs","GD","GFDL-1.1-invariants-only","GFDL-1.1-invariants-or-later","GFDL-1.1-no-invariants-only","GFDL-1.1-no-invariants-or-later","GFDL-1.1-only","GFDL-1.1-or-later","GFDL-1.2-invariants-only","GFDL-1.2-invariants-or-later","GFDL-1.2-no-invariants-only","GFDL-1.2-no-invariants-or-later","GFDL-1.2-only","GFDL-1.2-or-later","GFDL-1.3-invariants-only","GFDL-1.3-invariants-or-later","GFDL-1.3-no-invariants-only","GFDL-1.3-no-invariants-or-later","GFDL-1.3-only","GFDL-1.3-or-later","GL2PS","GLWTPL","GPL-1.0-only","GPL-1.0-or-later","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0-only","GPL-3.0-or-later","Game-Programming-Gems","Giftware","Glide","Glulxe","Graphics-Gems","Gutmann","HDF5","HIDAPI","HP-1986","HP-1989","HPND","HPND-DEC","HPND-Fenneberg-Livingston","HPND-INRIA-IMAG","HPND-Intel","HPND-Kevlin-Henney","HPND-MIT-disclaimer","HPND-Markus-Kuhn","HPND-Netrek","HPND-Pbmplus","HPND-UC","HPND-UC-export-US","HPND-doc","HPND-doc-sell","HPND-export-US","HPND-export-US-acknowledgement","HPND-export-US-modify","HPND-export2-US","HPND-merchantability-variant","HPND-sell-MIT-disclaimer-xserver","HPND-sell-regexpr","HPND-sell-variant","HPND-sell-variant-MIT-disclaimer","HPND-sell-variant-MIT-disclaimer-rev","HTMLTIDY","HaskellReport","Hippocratic-2.1","IBM-pibs","ICU","IEC-Code-Components-EULA","IJG","IJG-short","IPA","IPL-1.0","ISC","ISC-Veillard","ImageMagick","Imlib2","Info-ZIP","Inner-Net-2.0","InnoSetup","Intel","Intel-ACPI","Interbase-1.0","JPL-image","JPNIC","JSON","Jam","JasPer-2.0","Kastrup","Kazlib","Knuth-CTAN","LAL-1.2","LAL-1.3","LGPL-2.0-only","LGPL-2.0-or-later","LGPL-2.1-only","LGPL-2.1-or-later","LGPL-3.0-only","LGPL-3.0-or-later","LGPLLR","LOOP","LPD-document","LPL-1.0","LPL-1.02","LPPL-1.0","LPPL-1.1","LPPL-1.2","LPPL-1.3a","LPPL-1.3c","LZMA-SDK-9.11-to-9.20","LZMA-SDK-9.22","Latex2e","Latex2e-translated-notice","Leptonica","LiLiQ-P-1.1","LiLiQ-R-1.1","LiLiQ-Rplus-1.1","Libpng","Linux-OpenIB","Linux-man-pages-1-para","Linux-man-pages-copyleft","Linux-man-pages-copyleft-2-para","Linux-man-pages-copyleft-var","Lucida-Bitmap-Fonts","MIPS","MIT","MIT-0","MIT-CMU","MIT-Click","MIT-Festival","MIT-Khronos-old","MIT-Modern-Variant","MIT-Wu","MIT-advertising","MIT-enna","MIT-feh","MIT-open-group","MIT-testregex","MITNFA","MMIXware","MPEG-SSG","MPL-1.0","MPL-1.1","MPL-2.0","MPL-2.0-no-copyleft-exception","MS-LPL","MS-PL","MS-RL","MTLL","Mackerras-3-Clause","Mackerras-3-Clause-acknowledgment","MakeIndex","Martin-Birgmeier","McPhee-slideshow","Minpack","MirOS","Motosoto","MulanPSL-1.0","MulanPSL-2.0","Multics","Mup","NAIST-2003","NASA-1.3","NBPL-1.0","NCBI-PD","NCGL-UK-2.0","NCL","NCSA","NGPL","NICTA-1.0","NIST-PD","NIST-PD-fallback","NIST-Software","NLOD-1.0","NLOD-2.0","NLPL","NOSL","NPL-1.0","NPL-1.1","NPOSL-3.0","NRL","NTIA-PD","NTP","NTP-0","Naumen","NetCDF","Newsletr","Nokia","Noweb","O-UDA-1.0","OAR","OCCT-PL","OCLC-2.0","ODC-By-1.0","ODbL-1.0","OFFIS","OFL-1.0","OFL-1.0-RFN","OFL-1.0-no-RFN","OFL-1.1","OFL-1.1-RFN","OFL-1.1-no-RFN","OGC-1.0","OGDL-Taiwan-1.0","OGL-Canada-2.0","OGL-UK-1.0","OGL-UK-2.0","OGL-UK-3.0","OGTSL","OLDAP-1.1","OLDAP-1.2","OLDAP-1.3","OLDAP-1.4","OLDAP-2.0","OLDAP-2.0.1","OLDAP-2.1","OLDAP-2.2","OLDAP-2.2.1","OLDAP-2.2.2","OLDAP-2.3","OLDAP-2.4","OLDAP-2.5","OLDAP-2.6","OLDAP-2.7","OLDAP-2.8","OLFL-1.3","OML","OPL-1.0","OPL-UK-3.0","OPUBL-1.0","OSET-PL-2.1","OSL-1.0","OSL-1.1","OSL-2.0","OSL-2.1","OSL-3.0","OpenPBS-2.3","OpenSSL","OpenSSL-standalone","OpenVision","PADL","PDDL-1.0","PHP-3.0","PHP-3.01","PPL","PSF-2.0","Parity-6.0.0","Parity-7.0.0","Pixar","Plexus","PolyForm-Noncommercial-1.0.0","PolyForm-Small-Business-1.0.0","PostgreSQL","Python-2.0","Python-2.0.1","QPL-1.0","QPL-1.0-INRIA-2004","Qhull","RHeCos-1.1","RPL-1.1","RPL-1.5","RPSL-1.0","RSA-MD","RSCPL","Rdisc","Ruby","Ruby-pty","SAX-PD","SAX-PD-2.0","SCEA","SGI-B-1.0","SGI-B-1.1","SGI-B-2.0","SGI-OpenGL","SGP4","SHL-0.5","SHL-0.51","SISSL","SISSL-1.2","SL","SMAIL-GPL","SMLNJ","SMPPL","SNIA","SOFA","SPL-1.0","SSH-OpenSSH","SSH-short","SSLeay-standalone","SSPL-1.0","SUL-1.0","SWL","Saxpath","SchemeReport","Sendmail","Sendmail-8.23","Sendmail-Open-Source-1.1","SimPL-2.0","Sleepycat","Soundex","Spencer-86","Spencer-94","Spencer-99","SugarCRM-1.1.3","Sun-PPP","Sun-PPP-2000","SunPro","Symlinks","TAPR-OHL-1.0","TCL","TCP-wrappers","TGPPL-1.0","TMate","TORQUE-1.1","TOSL","TPDL","TPL-1.0","TTWL","TTYP0","TU-Berlin-1.0","TU-Berlin-2.0","TermReadKey","ThirdEye","TrustedQSL","UCAR","UCL-1.0","UMich-Merit","UPL-1.0","URT-RLE","Ubuntu-font-1.0","Unicode-3.0","Unicode-DFS-2015","Unicode-DFS-2016","Unicode-TOU","UnixCrypt","Unlicense","Unlicense-libtelnet","Unlicense-libwhirlpool","VOSTROM","VSL-1.0","Vim","W3C","W3C-19980720","W3C-20150513","WTFPL","Watcom-1.0","Widget-Workshop","Wsuipa","X11","X11-distribute-modifications-variant","X11-swapped","XFree86-1.1","XSkat","Xdebug-1.03","Xerox","Xfig","Xnet","YPL-1.0","YPL-1.1","ZPL-1.1","ZPL-2.0","ZPL-2.1","Zed","Zeeff","Zend-2.0","Zimbra-1.3","Zimbra-1.4","Zlib","any-OSI","any-OSI-perl-modules","bcrypt-Solar-Designer","blessing","bzip2-1.0.6","check-cvs","checkmk","copyleft-next-0.3.0","copyleft-next-0.3.1","curl","cve-tou","diffmark","dtoa","dvipdfm","eGenix","etalab-2.0","fwlw","gSOAP-1.3b","generic-xts","gnuplot","gtkbook","hdparm","iMatix","jove","libpng-1.6.35","libpng-2.0","libselinux-1.0","libtiff","libutil-David-Nugent","lsof","magaz","mailprio","man2html","metamail","mpi-permissive","mpich2","mplus","ngrep","pkgconf","pnmstitch","psfrag","psutils","python-ldap","radvd","snprintf","softSurfer","ssh-keyscan","swrule","threeparttable","ulem","w3m","wwl","xinetd","xkeyboard-config-Zinoviev","xlock","xpp","xzoom","zlib-acknowledgement"],De=["AGPL-1.0","AGPL-3.0","BSD-2-Clause-FreeBSD","BSD-2-Clause-NetBSD","GFDL-1.1","GFDL-1.2","GFDL-1.3","GPL-1.0","GPL-2.0","GPL-2.0-with-GCC-exception","GPL-2.0-with-autoconf-exception","GPL-2.0-with-bison-exception","GPL-2.0-with-classpath-exception","GPL-2.0-with-font-exception","GPL-3.0","GPL-3.0-with-GCC-exception","GPL-3.0-with-autoconf-exception","LGPL-2.0","LGPL-2.1","LGPL-3.0","Net-SNMP","Nunit","StandardML-NJ","bzip2-1.0.5","eCos-2.0","wxWindows"],Pe=["389-exception","Asterisk-exception","Autoconf-exception-2.0","Autoconf-exception-3.0","Autoconf-exception-generic","Autoconf-exception-generic-3.0","Autoconf-exception-macro","Bison-exception-1.24","Bison-exception-2.2","Bootloader-exception","Classpath-exception-2.0","CLISP-exception-2.0","cryptsetup-OpenSSL-exception","DigiRule-FOSS-exception","eCos-exception-2.0","Fawkes-Runtime-exception","FLTK-exception","fmt-exception","Font-exception-2.0","freertos-exception-2.0","GCC-exception-2.0","GCC-exception-2.0-note","GCC-exception-3.1","Gmsh-exception","GNAT-exception","GNOME-examples-exception","GNU-compiler-exception","gnu-javamail-exception","GPL-3.0-interface-exception","GPL-3.0-linking-exception","GPL-3.0-linking-source-exception","GPL-CC-1.0","GStreamer-exception-2005","GStreamer-exception-2008","i2p-gpl-java-exception","KiCad-libraries-exception","LGPL-3.0-linking-exception","libpri-OpenH323-exception","Libtool-exception","Linux-syscall-note","LLGPL","LLVM-exception","LZMA-exception","mif-exception","OCaml-LGPL-linking-exception","OCCT-exception-1.0","OpenJDK-assembly-exception-1.0","openvpn-openssl-exception","PS-or-PDF-font-exception-20170817","QPL-1.0-INRIA-2004-exception","Qt-GPL-exception-1.0","Qt-LGPL-exception-1.1","Qwt-exception-1.0","SANE-exception","SHL-2.0","SHL-2.1","stunnel-exception","SWI-exception","Swift-exception","Texinfo-exception","u-boot-exception-2.0","UBDL-exception","Universal-FOSS-exception-1.0","vsftpd-openssl-exception","WxWindows-exception-3.1","x11vnc-openssl-exception"];function Ne(){if(ve)return ge;ve=1;var e=[].concat(_e).concat(De),t=Pe;return ge=function(r){var n=0;function i(){return n<r.length}function o(e){if(e instanceof RegExp){var t=r.slice(n).match(e);if(t)return n+=t[0].length,t[0]}else if(r.indexOf(e,n)===n)return n+=e.length,e}function s(){o(/[ ]*/)}function a(){return o(/[A-Za-z0-9-.]+/)}function c(){var e=a();if(!e)throw new Error("Expected idstring at offset "+n);return e}function l(){return function(){for(var e,t=["WITH","AND","OR","(",")",":","+"],i=0;i<t.length&&!(e=o(t[i]));i++);if("+"===e&&n>1&&" "===r[n-2])throw new Error("Space before `+`");return e&&{type:"OPERATOR",string:e}}()||function(){if(o("DocumentRef-"))return{type:"DOCUMENTREF",string:c()}}()||function(){if(o("LicenseRef-"))return{type:"LICENSEREF",string:c()}}()||(i=n,s=a(),-1!==e.indexOf(s)?{type:"LICENSE",string:s}:-1!==t.indexOf(s)?{type:"EXCEPTION",string:s}:void(n=i));var i,s}for(var u=[];i()&&(s(),i());){var f=l();if(!f)throw new Error("Unexpected `"+r[n]+"` at offset "+n);u.push(f)}return u}}function Oe(){return Ee?ye:(Ee=1,ye=function(e){var t=0;function r(){return t<e.length}function n(){return r()?e[t]:null}function i(){if(!r())throw new Error;t++}function o(e){var t=n();if(t&&"OPERATOR"===t.type&&e===t.string)return i(),t.string}function s(){var e=n();if(e&&"LICENSE"===e.type){i();var t={license:e.string};o("+")&&(t.plus=!0);var r=function(){if(o("WITH")){var e=n();if(e&&"EXCEPTION"===e.type)return i(),e.string;throw new Error("Expected exception after `WITH`")}}();return r&&(t.exception=r),t}}function a(e,t){return function r(){var n=t();if(n){if(!o(e))return n;var i=r();if(!i)throw new Error("Expected expression");return{left:n,conjunction:e.toLowerCase(),right:i}}}}var c=a("AND",function(){return function(){if(o("(")){var e=l();if(!o(")"))throw new Error("Expected `)`");return e}}()||function(){var e=t,r="",s=n();if("DOCUMENTREF"===s.type&&(i(),r+="DocumentRef-"+s.string+":",!o(":")))throw new Error("Expected `:` after `DocumentRef-...`");if("LICENSEREF"===(s=n()).type)return i(),{license:r+="LicenseRef-"+s.string};t=e}()||s()}),l=a("OR",c),u=l();if(!u||r())throw new Error("Syntax error");return u})}function Ae(){if(we)return be;we=1;var e=Ne(),t=Oe();return be=function(r){return t(e(r))}}function $e(){if(Ce)return Se;Ce=1;var e=Ae(),t=function(){if(Le)return Ie;Le=1;var e=Ae(),t=_e;function r(t){try{return e(t),!0}catch(e){return!1}}function n(e,t){var r=t[0].length-e[0].length;return 0!==r?r:e[0].toUpperCase().localeCompare(t[0].toUpperCase())}var i=[["APGL","AGPL"],["Gpl","GPL"],["GLP","GPL"],["APL","Apache"],["ISD","ISC"],["GLP","GPL"],["IST","ISC"],["Claude","Clause"],[" or later","+"],[" International",""],["GNU","GPL"],["GUN","GPL"],["+",""],["GNU GPL","GPL"],["GNU LGPL","LGPL"],["GNU/GPL","GPL"],["GNU GLP","GPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL"],["GNU Lesser General Public License","LGPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["GNU Lesser General Public License","LGPL-2.1"],["LESSER GENERAL PUBLIC LICENSE","LGPL"],["Lesser General Public License","LGPL"],["LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["Lesser General Public License","LGPL-2.1"],["GNU General Public License","GPL"],["Gnu public license","GPL"],["GNU Public License","GPL"],["GNU GENERAL PUBLIC LICENSE","GPL"],["MTI","MIT"],["Mozilla Public License","MPL"],["Universal Permissive License","UPL"],["WTH","WTF"],["WTFGPL","WTFPL"],["-License",""]].sort(n),o=[function(e){return e.toUpperCase()},function(e){return e.trim()},function(e){return e.replace(/\./g,"")},function(e){return e.replace(/\s+/g,"")},function(e){return e.replace(/\s+/g,"-")},function(e){return e.replace("v","-")},function(e){return e.replace(/,?\s*(\d)/,"-$1")},function(e){return e.replace(/,?\s*(\d)/,"-$1.0")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2.0")},function(e){return e[0].toUpperCase()+e.slice(1)},function(e){return e.replace("/","-")},function(e){return e.replace(/\s*V\s*(\d)/,"-$1").replace(/(\d)$/,"$1.0")},function(e){return-1!==e.indexOf("3.0")?e+"-or-later":e+"-only"},function(e){return e+"only"},function(e){return e.replace(/(\d)$/,"-$1.0")},function(e){return e.replace(/(-| )?(\d)$/,"-$2-Clause")},function(e){return e.replace(/(-| )clause(-| )(\d)/,"-$3-Clause")},function(e){return e.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i,"BSD-3-Clause")},function(e){return e.replace(/\bSimplified(-| )?BSD((-| )License)?/i,"BSD-2-Clause")},function(e){return e.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i,"BSD-2-Clause-$1BSD")},function(e){return e.replace(/\bClear(-| )?BSD((-| )License)?/i,"BSD-3-Clause-Clear")},function(e){return e.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i,"BSD-4-Clause")},function(e){return"CC-"+e},function(e){return"CC-"+e+"-4.0"},function(e){return e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")},function(e){return"CC-"+e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")+"-4.0"}],s=t.map(function(e){var t=/^(.*)-\d+\.\d+$/.exec(e);return t?[t[0],t[1]]:[e,null]}).reduce(function(e,t){var r=t[1];return e[r]=e[r]||[],e[r].push(t[0]),e},{}),a=Object.keys(s).map(function(e){return[e,s[e]]}).filter(function(e){return 1===e[1].length&&null!==e[0]&&"APL"!==e[0]}).map(function(e){return[e[0],e[1][0]]});s=void 0;var c=[["UNLI","Unlicense"],["WTF","WTFPL"],["2 CLAUSE","BSD-2-Clause"],["2-CLAUSE","BSD-2-Clause"],["3 CLAUSE","BSD-3-Clause"],["3-CLAUSE","BSD-3-Clause"],["AFFERO","AGPL-3.0-or-later"],["AGPL","AGPL-3.0-or-later"],["APACHE","Apache-2.0"],["ARTISTIC","Artistic-2.0"],["Affero","AGPL-3.0-or-later"],["BEER","Beerware"],["BOOST","BSL-1.0"],["BSD","BSD-2-Clause"],["CDDL","CDDL-1.1"],["ECLIPSE","EPL-1.0"],["FUCK","WTFPL"],["GNU","GPL-3.0-or-later"],["LGPL","LGPL-3.0-or-later"],["GPLV1","GPL-1.0-only"],["GPL-1","GPL-1.0-only"],["GPLV2","GPL-2.0-only"],["GPL-2","GPL-2.0-only"],["GPL","GPL-3.0-or-later"],["MIT +NO-FALSE-ATTRIBS","MITNFA"],["MIT","MIT"],["MPL","MPL-2.0"],["X11","X11"],["ZLIB","Zlib"]].concat(a).sort(n),l=function(e){for(var t=0;t<o.length;t++){var n=o[t](e).trim();if(n!==e&&r(n))return n}return null},u=function(e){for(var t=e.toUpperCase(),r=0;r<c.length;r++){var n=c[r];if(t.indexOf(n[0])>-1)return n[1]}return null},f=function(e,t){for(var r=0;r<i.length;r++){var n=i[r],o=n[0];if(e.indexOf(o)>-1){var s=t(e.replace(o,n[1]));if(null!==s)return s}}return null};return Ie=function(e,t){var n=void 0===(t=t||{}).upgrade||!!t.upgrade;function i(e){return n?function(e){return-1!==["GPL-1.0","LGPL-1.0","AGPL-1.0","GPL-2.0","LGPL-2.0","AGPL-2.0","LGPL-2.1"].indexOf(e)?e+"-only":-1!==["GPL-1.0+","GPL-2.0+","GPL-3.0+","LGPL-2.0+","LGPL-2.1+","LGPL-3.0+","AGPL-1.0+","AGPL-3.0+"].indexOf(e)?e.replace(/\+$/,"-or-later"):-1!==["GPL-3.0","LGPL-3.0","AGPL-3.0"].indexOf(e)?e+"-or-later":e}(e):e}if("string"!=typeof e||0===e.trim().length)throw Error("Invalid argument. Expected non-empty string.");if(r(e=e.trim()))return i(e);var o=e.replace(/\+$/,"").trim();if(r(o))return i(o);var s=l(e);return null!==s||null!==(s=f(e,function(e){return r(e)?e:l(e)}))||null!==(s=u(e))||null!==(s=f(e,u))?i(s):null}}(),r='license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>"',n=/^SEE LICEN[CS]E IN (.+)$/;function i(e,t){return t.slice(0,e.length)===e}function o(e){if(e.hasOwnProperty("license")){var t=e.license;return i("LicenseRef",t)||i("DocumentRef",t)}return o(e.left)||o(e.right)}return Se=function(i){var s;try{s=e(i)}catch(e){var a;if("UNLICENSED"===i||"UNLICENCED"===i)return{validForOldPackages:!0,validForNewPackages:!0,unlicensed:!0};if(a=n.exec(i))return{validForOldPackages:!0,validForNewPackages:!0,inFile:a[1]};var c={validForOldPackages:!1,validForNewPackages:!1,warnings:[r]};if(0!==i.trim().length){var l=t(i);l&&c.warnings.push('license is similar to the valid expression "'+l+'"')}return c}return o(s)?{validForNewPackages:!1,validForOldPackages:!1,spdx:!0,warnings:[r]}:{validForNewPackages:!0,validForOldPackages:!0,spdx:!0}}}var Re,Te,xe,ke,Fe,Ue,Be,Me,Ge,je,ze,He={};function qe(){if(Re)return He;Re=1;var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tracing=e.metrics=void 0;var t={hasSubscribers:!1};e.metrics=t,e.tracing=t}),r=e(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultPerf=void 0,e.defaultPerf="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date});Object.defineProperty(He,"__esModule",{value:!0}),He.LRUCache=void 0;var n=t(),i=r(),o=()=>n.metrics.hasSubscribers||n.tracing.hasSubscribers,s=new Set,a="object"==typeof process&&process?process:{},c=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),l=e=>c(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?u:null:null,u=class extends Array{constructor(e){super(e),this.fill(0)}},f=class e{heap;length;static#e=!1;static create(t){let r=l(t);if(!r)return[];e.#e=!0;let n=new e(t,r);return e.#e=!1,n}constructor(t,r){if(!e.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},d=class e{#e;#t;#r;#n;#i;#o;#s;#a;get perf(){return this.#a}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#c;#l;#u;#f;#d;#p;#h;#m;#g;#v;#y;#E;#b;#w;#I;#L;#S;#C;#_;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#w,autopurgeTimers:e.#I,sizes:e.#E,keyMap:e.#u,keyList:e.#f,valList:e.#d,next:e.#p,prev:e.#h,get head(){return e.#m},get tail(){return e.#g},free:e.#v,isBackgroundFetch:t=>e.#D(t),backgroundFetch:(t,r,n,i)=>e.#P(t,r,n,i),moveToTail:t=>e.#N(t),indexes:t=>e.#O(t),rindexes:t=>e.#A(t),isStale:t=>e.#$(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#l}get size(){return this.#c}get fetchMethod(){return this.#o}get memoMethod(){return this.#s}get dispose(){return this.#r}get onInsert(){return this.#n}get disposeAfter(){return this.#i}constructor(t){let{max:r=0,ttl:n,ttlResolution:o=1,ttlAutopurge:u,updateAgeOnGet:d,updateAgeOnHas:p,allowStale:h,dispose:m,onInsert:g,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:E,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:I,fetchMethod:L,memoMethod:S,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:_,allowStaleOnFetchRejection:D,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,backgroundFetchSize:O=1,perf:A}=t;if(this.backgroundFetchSize=O,void 0!==A&&"function"!=typeof A?.now)throw new TypeError("perf option must have a now() method if specified");if(this.#a=A??i.defaultPerf,0!==r&&!c(r))throw new TypeError("max option must be a nonnegative integer");let $=r?l(r):Array;if(!$)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=b,this.maxEntrySize=w||this.#t,this.sizeCalculation=I,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("memoMethod must be a function if defined");if(this.#s=S,void 0!==L&&"function"!=typeof L)throw new TypeError("fetchMethod must be a function if specified");if(this.#o=L,this.#S=!!L,this.#u=new Map,this.#f=Array.from({length:r}).fill(void 0),this.#d=Array.from({length:r}).fill(void 0),this.#p=new $(r),this.#h=new $(r),this.#m=0,this.#g=0,this.#v=f.create(r),this.#c=0,this.#l=0,"function"==typeof m&&(this.#r=m),"function"==typeof g&&(this.#n=g),"function"==typeof v?(this.#i=v,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#L=!!this.#r,this.#_=!!this.#n,this.#C=!!this.#i,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!D,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!N,0!==this.maxEntrySize){if(0!==this.#t&&!c(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!_,this.updateAgeOnGet=!!d,this.updateAgeOnHas=!!p,this.ttlResolution=c(o)||0===o?o:1,this.ttlAutopurge=!!u,this.ttl=n||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#T()}if(0===this.#e&&0===this.ttl&&0===this.#t)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t="LRU_CACHE_UNBOUNDED";(e=>!s.has(e))(t)&&(s.add(t),((e,t,r,n)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)})("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#T(){let e=new u(this.#e),t=new u(this.#e);this.#w=e,this.#b=t;let r=this.ttlAutopurge?Array.from({length:this.#e}):void 0;this.#I=r,this.#x=(r,i,o=this.#a.now())=>{t[r]=0!==i?o:0,e[r]=i,n(r,i)},this.#k=r=>{t[r]=0!==e[r]?this.#a.now():0,n(r,e[r])};let n=this.ttlAutopurge?(e,t)=>{if(r?.[e]&&(clearTimeout(r[e]),r[e]=void 0),t&&0!==t&&r){let i=setTimeout(()=>{this.#$(e)?(this.#F(this.#f[e],"expire"),r[e]=void 0):n(e,s(e))},t+1);i.unref&&i.unref(),r[e]=i}}:()=>{};this.#U=(r,n)=>{if(e[n]){let s=e[n],a=t[n];if(!s||!a)return;r.ttl=s,r.start=a,r.now=i||o();let c=r.now-a;r.remainingTTL=s-c}};let i=0,o=()=>{let e=this.#a.now();if(this.ttlResolution>0){i=e;let t=setTimeout(()=>i=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=e=>{let t=this.#u.get(e);return void 0===t?0:s(t)};let s=r=>{let n=e[r],s=t[r];return n&&s?n-((i||o())-s):1/0};this.#$=r=>{let n=t[r],s=e[r];return!!s&&!!n&&(i||o())-n>s}}#k=()=>{};#U=()=>{};#x=()=>{};#$=()=>!1;#R(){let e=new u(this.#e);this.#l=0,this.#E=e,this.#B=t=>{this.#l-=e[t],e[t]=0},this.#M=(e,t,r,n)=>{if(!c(r)){if(this.#D(t))return this.backgroundFetchSize;if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(t,e),!c(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#G=(t,r,n)=>{if(e[t]=r,this.#t){let r=this.#t-e[t];for(;this.#l>r;)this.#j(!0)}this.#l+=e[t],n&&(n.entrySize=r,n.totalCalculatedSize=this.#l)}}#B=e=>{};#G=(e,t,r)=>{};#M=(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#g;this.#z(t)&&((e||!this.#$(t))&&(yield t),t!==this.#m);)t=this.#h[t]}*#A({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#m;this.#z(t)&&((e||!this.#$(t))&&(yield t),t!==this.#g);)t=this.#p[t]}#z(e){return void 0!==e&&this.#u.get(this.#f[e])===e}*entries(){for(let e of this.#O())void 0!==this.#d[e]&&void 0!==this.#f[e]&&!this.#D(this.#d[e])&&(yield[this.#f[e],this.#d[e]])}*rentries(){for(let e of this.#A())void 0!==this.#d[e]&&void 0!==this.#f[e]&&!this.#D(this.#d[e])&&(yield[this.#f[e],this.#d[e]])}*keys(){for(let e of this.#O()){let t=this.#f[e];void 0!==t&&!this.#D(this.#d[e])&&(yield t)}}*rkeys(){for(let e of this.#A()){let t=this.#f[e];void 0!==t&&!this.#D(this.#d[e])&&(yield t)}}*values(){for(let e of this.#O())void 0!==this.#d[e]&&!this.#D(this.#d[e])&&(yield this.#d[e])}*rvalues(){for(let e of this.#A())void 0!==this.#d[e]&&!this.#D(this.#d[e])&&(yield this.#d[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#O()){let n=this.#d[r],i=this.#D(n)?n.__staleWhileFetching:n;if(void 0!==i&&e(i,this.#f[r],this))return this.#H(this.#f[r],t)}}forEach(e,t=this){for(let r of this.#O()){let n=this.#d[r],i=this.#D(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#f[r],this)}}rforEach(e,t=this){for(let r of this.#A()){let n=this.#d[r],i=this.#D(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#f[r],this)}}purgeStale(){let e=!1;for(let t of this.#A({allowStale:!0}))this.#$(t)&&(this.#F(this.#f[t],"expire"),e=!0);return e}info(e){let t=this.#u.get(e);if(void 0===t)return;let r=this.#d[t],n=this.#D(r)?r.__staleWhileFetching:r;if(void 0===n)return;let i={value:n};if(this.#w&&this.#b){let e=this.#w[t],r=this.#b[t];if(e&&r){let t=e-(this.#a.now()-r);i.ttl=t,i.start=Date.now()}}return this.#E&&(i.size=this.#E[t]),i}dump(){let e=[];for(let t of this.#O({allowStale:!0})){let r=this.#f[t],n=this.#d[t],i=this.#D(n)?n.__staleWhileFetching:n;if(void 0===i||void 0===r)continue;let o={value:i};if(this.#w&&this.#b){o.ttl=this.#w[t];let e=this.#a.now()-this.#b[t];o.start=Math.floor(Date.now()-e)}this.#E&&(o.size=this.#E[t]),e.unshift([r,o])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let e=Date.now()-r.start;r.start=this.#a.now()-e}this.#q(t,r.value,r)}}set(e,t,r={}){let{status:i=(n.metrics.hasSubscribers?{}:void 0)}=r;r.status=i,i&&(i.op="set",i.key=e,void 0!==t&&(i.value=t),i.cache=this);let o=this.#q(e,t,r);return i&&n.metrics.hasSubscribers&&n.metrics.publish(i),o}#q(e,t,r,n){let{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=r,l=this.#D(t);if(void 0===t)return c&&(c.set="deleted"),this.delete(e),this;let{noUpdateTTL:u=this.noUpdateTTL}=r;c&&!l&&(c.value=t);let f=this.#M(e,t,r.size||0,a,c);if(this.maxEntrySize&&f>this.maxEntrySize)return this.#F(e,"set"),c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this;let d=0===this.#c?void 0:this.#u.get(e);if(void 0===d)d=0===this.#c?this.#g:0!==this.#v.length?this.#v.pop():this.#c===this.#e?this.#j(!1):this.#c,this.#f[d]=e,this.#d[d]=t,this.#u.set(e,d),this.#p[this.#g]=d,this.#h[d]=this.#g,this.#g=d,this.#c++,this.#G(d,f,c),c&&(c.set="add"),u=!1,this.#_&&!l&&this.#n?.(t,e,"add");else{this.#N(d);let r=this.#d[d];if(t!==r){if(!s)if(this.#D(r)){r!==n&&r.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:i}=r;void 0!==i&&i!==t&&(this.#L&&this.#r?.(i,e,"set"),this.#C&&this.#y?.push([i,e,"set"]))}else this.#L&&this.#r?.(r,e,"set"),this.#C&&this.#y?.push([r,e,"set"]);if(this.#B(d),this.#G(d,f,c),this.#d[d]=t,!l){let n=r&&this.#D(r)?r.__staleWhileFetching:r,i=void 0===n?"add":t!==n?"replace":"update";c&&(c.set=i,void 0!==n&&(c.oldValue=n)),this.#_&&this.onInsert?.(t,e,i)}}else l||(c&&(c.set="update"),this.#_&&this.onInsert?.(t,e,"update"))}if(0!==i&&!this.#w&&this.#T(),this.#w&&(u||this.#x(d,i,o),c&&this.#U(c,d)),!s&&this.#C&&this.#y){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#c;){let e=this.#d[this.#m];if(this.#j(!0),this.#D(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#C&&this.#y){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}}}#j(e){let t=this.#m,r=this.#f[t],n=this.#d[t],i=this.#D(n);i&&n.__abortController.abort(new Error("evicted"));let o=i?n.__staleWhileFetching:n;return(this.#L||this.#C)&&void 0!==o&&(this.#L&&this.#r?.(o,r,"evict"),this.#C&&this.#y?.push([o,r,"evict"])),this.#B(t),this.#I?.[t]&&(clearTimeout(this.#I[t]),this.#I[t]=void 0),e&&(this.#f[t]=void 0,this.#d[t]=void 0,this.#v.push(t)),1===this.#c?(this.#m=this.#g=0,this.#v.length=0):this.#m=this.#p[t],this.#u.delete(r),this.#c--,t}has(e,t={}){let{status:r=(n.metrics.hasSubscribers?{}:void 0)}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let i=this.#V(e,t);return n.metrics.hasSubscribers&&n.metrics.publish(r),i}#V(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,i=this.#u.get(e);if(void 0!==i){let e=this.#d[i];if(this.#D(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#$(i))return r&&this.#k(i),n&&(n.has="hit",this.#U(n,i)),!0;n&&(n.has="stale",this.#U(n,i))}else n&&(n.has="miss");return!1}peek(e,t={}){let{status:r=(o()?{}:void 0)}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let i=this.#W(e,t);return n.metrics.hasSubscribers&&n.metrics.publish(r),i}#W(e,t){let{status:r,allowStale:n=this.allowStale}=t,i=this.#u.get(e);if(void 0===i||!n&&this.#$(i))return void(r&&(r.peek=void 0===i?"miss":"stale"));let o=this.#d[i],s=this.#D(o)?o.__staleWhileFetching:o;return r&&(void 0!==s?(r.peek="hit",r.value=s):r.peek="miss"),s}#P(e,t,r,n){let i=void 0===t?void 0:this.#d[t];if(this.#D(i))return i;let o=new AbortController,{signal:s}=r;s?.addEventListener("abort",()=>o.abort(s.reason),{signal:o.signal});let a={signal:o.signal,options:r,context:n},c=(n,i=!1)=>{let{aborted:s}=o.signal,c=r.ignoreFetchAbort&&void 0!==n,f=r.ignoreFetchAbort||!(!r.allowStaleOnFetchAbort||void 0===n);if(r.status&&(s&&!i?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,c&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),s&&!c&&!i)return l(o.signal.reason,f);let d=u,p=this.#d[t];return(p===u||void 0===p&&c&&i)&&(void 0===n?void 0!==d.__staleWhileFetching?this.#d[t]=d.__staleWhileFetching:this.#F(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.#q(e,n,a.options,d))),n},l=(n,i)=>{let{aborted:s}=o.signal,a=s&&r.allowStaleOnFetchAbort,c=a||r.allowStaleOnFetchRejection,l=c||r.noDeleteOnFetchRejection,f=u;if(this.#d[t]===u&&(!l||!i&&void 0===f.__staleWhileFetching?this.#F(e,"fetch"):a||(this.#d[t]=f.__staleWhileFetching)),c)return r.status&&void 0!==f.__staleWhileFetching&&(r.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw n};r.status&&(r.status.fetchDispatched=!0);let u=new Promise((t,n)=>{let s=this.#o?.(e,i,a);o.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))}),s&&s instanceof Promise?s.then(e=>t(void 0===e?void 0:e),n):void 0!==s&&t(s)}).then(c,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),l(e,!1))),f=Object.assign(u,{__abortController:o,__staleWhileFetching:i,__returned:void 0});return void 0===t?(this.#q(e,f,{...a.options,status:void 0}),t=this.#u.get(e)):this.#d[t]=f,f}#D(e){if(!this.#S)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let r=n.tracing.hasSubscribers,{status:i=(o()?{}:void 0)}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#Z(e,t);return i&&r&&(i.trace=!0,n.tracing.tracePromise(()=>s,i).catch(()=>{})),s}async#Z(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:h,forceRefresh:m=!1,status:g,signal:v}=t;if(g&&(g.op="fetch",g.key=e,m&&(g.forceRefresh=!0),g.cache=this),!this.#S)return g&&(g.fetch="get"),this.#H(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,status:g});let y={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:v},E=this.#u.get(e);if(void 0===E){g&&(g.fetch="miss");let t=this.#P(e,E,y,h);return t.__returned=t}{let t=this.#d[E];if(this.#D(t)){let e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#$(E);if(!m&&!i)return g&&(g.fetch="hit"),this.#N(E),n&&this.#k(E),g&&this.#U(g,E),t;let o=this.#P(e,E,y,h),s=void 0!==o.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",s&&i&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}forceFetch(e,t={}){let r=n.tracing.hasSubscribers,{status:i=(o()?{}:void 0)}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#K(e,t);return i&&r&&(i.trace=!0,n.tracing.tracePromise(()=>s,i).catch(()=>{})),s}async#K(e,t={}){let r=await this.#Z(e,t);if(void 0===r)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let{status:r=(n.metrics.hasSubscribers?{}:void 0)}=t;t.status=r,r&&(r.op="memo",r.key=e,t.context&&(r.context=t.context),r.cache=this);let i=this.#Y(e,t);return r&&(r.value=i),n.metrics.hasSubscribers&&n.metrics.publish(r),i}#Y(e,t={}){let r=this.#s;if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,status:i,forceRefresh:o,...s}=t;i&&o&&(i.forceRefresh=!0);let a=this.#H(e,s),c=o||void 0===a;if(i&&(i.memo=c?"miss":"hit",c||(i.value=a)),!c)return a;let l=r(e,a,{options:s,context:n});return i&&(i.value=l),this.#q(e,l,s),l}get(e,t={}){let{status:r=(n.metrics.hasSubscribers?{}:void 0)}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let i=this.#H(e,t);return r&&(void 0!==i&&(r.value=i),n.metrics.hasSubscribers&&n.metrics.publish(r)),i}#H(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=t,s=this.#u.get(e);if(void 0===s)return void(o&&(o.get="miss"));let a=this.#d[s],c=this.#D(a);return o&&this.#U(o,s),this.#$(s)?c?(o&&(o.get="stale-fetching"),r&&void 0!==a.__staleWhileFetching?(o&&(o.returnedStale=!0),a.__staleWhileFetching):void 0):(i||this.#F(e,"expire"),o&&(o.get="stale"),r?(o&&(o.returnedStale=!0),a):void 0):(o&&(o.get=c?"fetching":"hit"),this.#N(s),n&&this.#k(s),c?a.__staleWhileFetching:a)}#X(e,t){this.#h[t]=e,this.#p[e]=t}#N(e){e!==this.#g&&(e===this.#m?this.#m=this.#p[e]:this.#X(this.#h[e],this.#p[e]),this.#X(this.#g,e),this.#g=e)}delete(e){return this.#F(e,"delete")}#F(e,t){n.metrics.hasSubscribers&&n.metrics.publish({op:"delete",delete:t,key:e,cache:this});let r=!1;if(0!==this.#c){let n=this.#u.get(e);if(void 0!==n)if(this.#I?.[n]&&(clearTimeout(this.#I[n]),this.#I[n]=void 0),r=!0,1===this.#c)this.#J(t);else{this.#B(n);let r=this.#d[n];if(this.#D(r)?r.__abortController.abort(new Error("deleted")):(this.#L||this.#C)&&(this.#L&&this.#r?.(r,e,t),this.#C&&this.#y?.push([r,e,t])),this.#u.delete(e),this.#f[n]=void 0,this.#d[n]=void 0,n===this.#g)this.#g=this.#h[n];else if(n===this.#m)this.#m=this.#p[n];else{let e=this.#h[n];this.#p[e]=this.#p[n];let t=this.#p[n];this.#h[t]=this.#h[n]}this.#c--,this.#v.push(n)}}if(this.#C&&this.#y?.length){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}return r}clear(){return this.#J("delete")}#J(e){for(let t of this.#A({allowStale:!0})){let r=this.#d[t];if(this.#D(r))r.__abortController.abort(new Error("deleted"));else{let n=this.#f[t];this.#L&&this.#r?.(r,n,e),this.#C&&this.#y?.push([r,n,e])}}if(this.#u.clear(),this.#d.fill(void 0),this.#f.fill(void 0),this.#w&&this.#b){this.#w.fill(0),this.#b.fill(0);for(let e of this.#I??[])void 0!==e&&clearTimeout(e);this.#I?.fill(void 0)}if(this.#E&&this.#E.fill(0),this.#m=0,this.#g=0,this.#v.length=0,this.#l=0,this.#c=0,this.#C&&this.#y){let e,t=this.#y;for(;e=t?.shift();)this.#i?.(...e)}}};return He.LRUCache=d,He}function Ve(){if(Fe)return ke;Fe=1;const e=(e,t,r)=>{const n=e.indexOf(r);return e.lastIndexOf(t,n>-1?n:1/0)},t=e=>{try{return new URL(e)}catch{}};return ke=(r,n)=>{const i=n?((e,t)=>{const r=e.indexOf(":"),n=e.slice(0,r+1);if(Object.prototype.hasOwnProperty.call(t,n))return e;if("://"===e.substr(r,3))return e;const i=e.indexOf("@");return i>-1?i>r?`git+ssh://${e}`:e:`${e.slice(0,r+1)}//${e.slice(r+1)}`})(r,n):r;return t(i)||t((t=>{const r=e(t,"@","#"),n=e(t,":","#");return n>r&&(t=t.slice(0,n)+"/"+t.slice(n+1)),-1===e(t,":","#")&&-1===t.indexOf("//")&&(t=`git+ssh://${t}`),t})(i))}}function We(){if(Be)return Ue;Be=1;const e=Ve();return Ue=(t,r,{gitHosts:n,protocols:i})=>{if(!t)return;const o=(e=>{const t=e.indexOf("#"),r=e.indexOf("/"),n=e.indexOf("/",r+1),i=e.indexOf(":"),o=/\s/.exec(e),s=e.indexOf("@"),a=!o||t>-1&&o.index>t,c=-1===s||t>-1&&s>t,l=-1===i||t>-1&&i>t,u=-1===n||t>-1&&n>t,f=r>0,d=t>-1?"/"!==e[t-1]:!e.endsWith("/"),p=!e.startsWith(".");return a&&f&&d&&p&&c&&l&&u})(t)?`github:${t}`:t,s=e(o,i);if(!s)return;const a=n.byShortcut[s.protocol],c=n.byDomain[s.hostname.startsWith("www.")?s.hostname.slice(4):s.hostname],l=a||c;if(!l)return;const u=n[a||c];let f=null;i[s.protocol]?.auth&&(s.username||s.password)&&(f=`${s.username}${s.password?":"+s.password:""}`);let d=null,p=null,h=null,m=null;try{if(a){let e=s.pathname.startsWith("/")?s.pathname.slice(1):s.pathname;const t=e.indexOf("@");t>-1&&(e=e.slice(t+1));const r=e.lastIndexOf("/");r>-1?(p=decodeURIComponent(e.slice(0,r)),p||(p=null),h=decodeURIComponent(e.slice(r+1))):h=decodeURIComponent(e),h.endsWith(".git")&&(h=h.slice(0,-4)),s.hash&&(d=decodeURIComponent(s.hash.slice(1))),m="shortcut"}else{if(!u.protocols.includes(s.protocol))return;const e=u.extract(s);if(!e)return;p=e.user&&decodeURIComponent(e.user),h=decodeURIComponent(e.project),d=decodeURIComponent(e.committish),m=i[s.protocol]?.name||s.protocol.slice(0,-1)}}catch(e){if(e instanceof URIError)return;throw e}return[l,p,f,h,d,m,r]}}function Ze(){if(Ge)return Me;Ge=1;const{LRUCache:e}=qe(),t=function(){if(xe)return Te;xe=1;const e=(...e)=>e.every(e=>e)?e.join(""):"",t=e=>e?encodeURIComponent(e):"",r=e=>e.toLowerCase().replace(/^\W+/g,"").replace(/(?<!\W)\W+$/,"").replace(/\//g,"").replace(/\W+/g,"-"),n={sshtemplate:({domain:t,user:r,project:n,committish:i})=>`git@${t}:${r}/${n}.git${e("#",i)}`,sshurltemplate:({domain:t,user:r,project:n,committish:i})=>`git+ssh://git@${t}/${r}/${n}.git${e("#",i)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s,path:a})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a)}`,browsetemplate:({domain:r,user:n,project:i,committish:o,treepath:s})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o))}`,browsetreetemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,browseblobtemplate:({domain:r,user:n,project:i,committish:o,blobpath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,docstemplate:({domain:r,user:n,project:i,treepath:o,committish:s})=>`https://${r}/${n}/${i}${e("/",o,"/",t(s))}#readme`,httpstemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git+https://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/raw/${t(i||"HEAD")}/${o}`,shortcuttemplate:({type:t,user:r,project:n,committish:i})=>`${t}:${r}/${n}${e("#",i)}`,pathtemplate:({user:t,project:r,committish:n})=>`${t}/${r}${e("#",n)}`,bugstemplate:({domain:e,user:t,project:r})=>`https://${e}/${t}/${r}/issues`,hashformat:r},i={};i.github={protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",blobpath:"blob",editpath:"edit",filetemplate:({auth:r,user:n,project:i,committish:o,path:s})=>`https://${e(r,"@")}raw.githubusercontent.com/${n}/${i}/${t(o||"HEAD")}/${s}`,gittemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://codeload.${e}/${r}/${n}/tar.gz/${t(i||"HEAD")}`,extract:e=>{let[,t,r,n,i]=e.pathname.split("/",5);if((!n||"tree"===n)&&(n||(i=e.hash.slice(1)),r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:i}}},i.bitbucket={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",blobpath:"src",editpath:"?mode=edit",edittemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,editpath:c})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a,c)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/get/${t(i||"HEAD")}.tar.gz`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["get"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}},i.gitlab={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",blobpath:"tree",editpath:"-/edit",tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/api/v4/projects/${t(r+"/"+n)}/repository/archive.tar.gz?sha=${t(i||"HEAD")}`,extract:e=>{const t=e.pathname.slice(1);if(t.includes("/-/")||t.includes("/archive.tar.gz"))return;const r=t.split("/");let n=r.pop();n.endsWith(".git")&&(n=n.slice(0,-4));const i=r.join("/");return i&&n?{user:i,project:n,committish:e.hash.slice(1)}:void 0}},i.gist={protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",editpath:"edit",sshtemplate:({domain:t,project:r,committish:n})=>`git@${t}:${r}.git${e("#",n)}`,sshurltemplate:({domain:t,project:r,committish:n})=>`git+ssh://git@${t}/${r}.git${e("#",n)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s})=>`https://${r}/${n}/${i}${e("/",t(o))}/${s}`,browsetemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,browsetreetemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,browseblobtemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,docstemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,httpstemplate:({domain:t,project:r,committish:n})=>`git+https://${t}/${r}.git${e("#",n)}`,filetemplate:({user:r,project:n,committish:i,path:o})=>`https://gist.githubusercontent.com/${r}/${n}/raw${e("/",t(i))}/${o}`,shortcuttemplate:({type:t,project:r,committish:n})=>`${t}:${r}${e("#",n)}`,pathtemplate:({project:t,committish:r})=>`${t}${e("#",r)}`,bugstemplate:({domain:e,project:t})=>`https://${e}/${t}`,gittemplate:({domain:t,project:r,committish:n})=>`git://${t}/${r}.git${e("#",n)}`,tarballtemplate:({project:e,committish:r})=>`https://codeload.github.com/gist/${e}/tar.gz/${t(r||"HEAD")}`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if("raw"!==n){if(!r){if(!t)return;r=t,t=null}return r.endsWith(".git")&&(r=r.slice(0,-4)),{user:t,project:r,committish:e.hash.slice(1)}}},hashformat:function(e){return e&&"file-"+r(e)}},i.sourcehut={protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",blobpath:"tree",filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/blob/${t(i)||"HEAD"}/${o}`,httpstemplate:({domain:t,user:r,project:n,committish:i})=>`https://${t}/${r}/${n}${e("#",i)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/archive/${t(i)||"HEAD"}.tar.gz`,bugstemplate:()=>null,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["archive"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}};for(const[e,t]of Object.entries(i))i[e]=Object.assign({},n,t);return Te=i}(),r=We(),n=Ve(),i=new e({max:1e3});class o{constructor(e,t,r,n,i,s,a={}){Object.assign(this,o.#Q[e],{type:e,user:t,auth:r,project:n,committish:i,default:s,opts:a})}static#Q={byShortcut:{},byDomain:{}};static#ee={"git+ssh:":{name:"sshurl"},"ssh:":{name:"sshurl"},"git+https:":{name:"https",auth:!0},"git:":{auth:!0},"http:":{auth:!0},"https:":{auth:!0},"git+http:":{auth:!0}};static addHost(e,t){o.#Q[e]=t,o.#Q.byDomain[t.domain]=e,o.#Q.byShortcut[`${e}:`]=e,o.#ee[`${e}:`]={name:e}}static fromUrl(e,t){if("string"!=typeof e)return;const n=e+JSON.stringify(t||{});if(!i.has(n)){const s=r(e,t,{gitHosts:o.#Q,protocols:o.#ee});i.set(n,s?new o(...s):void 0)}return i.get(n)}static fromManifest(e,t={}){if(!e||"object"!=typeof e)return;const r=e.repository,n=r&&("string"==typeof r?r:"object"==typeof r&&"string"==typeof r.url?r.url:null);if(!n)throw new Error("no repository");const i=n&&o.fromUrl(n.replace(/^git\+/,""),t)||null;if(i)return i;const s=function(e){try{const{protocol:t,hostname:r,pathname:n}=new URL(e);if(!r)return null;return`${/(?:git\+)http:$/.test(t)?"http:":"https:"}//${r}${n.replace(/\.git$/,"")}`}catch{return null}}(n);return o.fromUrl(s,t)||s}static parseUrl(e){return n(e)}#te(e,t){if("function"!=typeof e)return null;const r={...this,...this.opts,...t};r.path||(r.path=""),r.path.startsWith("/")&&(r.path=r.path.slice(1)),r.noCommittish&&(r.committish=null);const n=e(r);return r.noGitPlus&&n.startsWith("git+")?n.slice(4):n}hash(){return this.committish?`#${this.committish}`:""}ssh(e){return this.#te(this.sshtemplate,e)}sshurl(e){return this.#te(this.sshurltemplate,e)}browse(e,...t){return"string"!=typeof e?this.#te(this.browsetemplate,e):"string"!=typeof t[0]?this.#te(this.browsetreetemplate,{...t[0],path:e}):this.#te(this.browsetreetemplate,{...t[1],fragment:t[0],path:e})}browseFile(e,...t){return"string"!=typeof t[0]?this.#te(this.browseblobtemplate,{...t[0],path:e}):this.#te(this.browseblobtemplate,{...t[1],fragment:t[0],path:e})}docs(e){return this.#te(this.docstemplate,e)}bugs(e){return this.#te(this.bugstemplate,e)}https(e){return this.#te(this.httpstemplate,e)}git(e){return this.#te(this.gittemplate,e)}shortcut(e){return this.#te(this.shortcuttemplate,e)}path(e){return this.#te(this.pathtemplate,e)}tarball(e){return this.#te(this.tarballtemplate,{...e,noCommittish:!1})}file(e,t){return this.#te(this.filetemplate,{...t,path:e})}edit(e,t){return this.#te(this.edittemplate,{...t,path:e})}getDefaultRepresentation(){return this.default}toString(e){return this.default&&"function"==typeof this[this.default]?this[this.default](e):this.sshurl(e)}}for(const[e,r]of Object.entries(t))o.addHost(e,r);return Me=o}var Ke,Ye,Xe={topLevel:{dependancies:"dependencies",dependecies:"dependencies",depdenencies:"dependencies",devEependencies:"devDependencies",depends:"dependencies","dev-dependencies":"devDependencies",devDependences:"devDependencies",devDepenencies:"devDependencies",devdependencies:"devDependencies",repostitory:"repository",repo:"repository",prefereGlobal:"preferGlobal",hompage:"homepage",hampage:"homepage",autohr:"author",autor:"author",contributers:"contributors",publicationConfig:"publishConfig",script:"scripts"},bugs:{web:"url",name:"url"},script:{server:"start",tests:"test"}};function Je(){if(Ye)return Ke;Ye=1;var{URL:e}=d,t=function(){if(le)return ce;le=1;const e=me();return ce=(t,r)=>{const n=e(t,r);return n?n.version:null},ce}(),r=function(){if(fe)return ue;fe=1;const e=me();return ue=(t,r)=>{const n=e(t.trim().replace(/^[=v]+/,""),r);return n?n.version:null},ue}(),n=$e(),i=Ze(),{isBuiltin:o}=h,s=["dependencies","devDependencies","optionalDependencies"],a=ze?je:(ze=1,je=function(e){if(!e)return;if("ERROR: No README data found!"===e)return;e=e.trim().split("\n");let t=0;for(;e[t]&&e[t].trim().match(/^(#|$)/);)t++;const r=e.length;let n=t+1;for(;n<r&&e[n].trim();)n++;return e.slice(t,n).join(" ").trim()}),c=Xe,l=e=>e.includes("@")&&e.indexOf("@")<e.lastIndexOf(".");function u(e,t){return e.author&&(e.author=t(e.author)),["maintainers","contributors"].forEach(function(r){Array.isArray(e[r])&&(e[r]=e[r].map(t))}),e}function f(e){if("string"==typeof e)return e;var t=e.name||"",r=e.url||e.web,n=r?" ("+r+")":"",i=e.email||e.mail;return t+(i?" <"+i+">":"")+n}function p(e){if("string"!=typeof e)return e;var t=e.match(/^([^(<]+)/),r=e.match(/\(([^()]+)\)/),n=e.match(/<([^<>]+)>/),i={};return t&&t[0].trim()&&(i.name=t[0].trim()),n&&(i.email=n[1]),r&&(i.url=r[1]),i}return Ke={warn:function(){},fixRepositoryField:function(e){if(e.repositories&&(this.warn("repositories"),e.repository=e.repositories[0]),!e.repository)return this.warn("missingRepository");"string"==typeof e.repository&&(e.repository={type:"git",url:e.repository});var t=e.repository.url||"";if(t){var r=i.fromUrl(t);r&&(t=e.repository.url="shortcut"===r.getDefaultRepresentation()?r.https():r.toString())}t.match(/github.com\/[^/]+\/[^/]+\.git\.git$/)&&this.warn("brokenGitUrl",t)},fixTypos:function(e){Object.keys(c.topLevel).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t)&&this.warn("typo",t,c.topLevel[t])},this)},fixScriptsField:function(e){if(e.scripts)return"object"!=typeof e.scripts?(this.warn("nonObjectScripts"),void delete e.scripts):void Object.keys(e.scripts).forEach(function(t){"string"!=typeof e.scripts[t]?(this.warn("nonStringScript"),delete e.scripts[t]):c.script[t]&&!e.scripts[c.script[t]]&&this.warn("typo",t,c.script[t],"scripts")},this)},fixFilesField:function(e){var t=e.files;t&&!Array.isArray(t)?(this.warn("nonArrayFiles"),delete e.files):e.files&&(e.files=e.files.filter(function(e){return!(!e||"string"!=typeof e)||(this.warn("invalidFilename",e),!1)},this))},fixBinField:function(e){if(e.bin&&"string"==typeof e.bin){var t,r={};(t=e.name.match(/^@[^/]+[/](.*)$/))?r[t[1]]=e.bin:r[e.name]=e.bin,e.bin=r}},fixManField:function(e){e.man&&"string"==typeof e.man&&(e.man=[e.man])},fixBundleDependenciesField:function(e){var t="bundledDependencies",r="bundleDependencies";e[t]&&!e[r]&&(e[r]=e[t],delete e[t]),e[r]&&!Array.isArray(e[r])?(this.warn("nonArrayBundleDependencies"),delete e[r]):e[r]&&(e[r]=e[r].filter(function(t){return t&&"string"==typeof t?(e.dependencies||(e.dependencies={}),Object.prototype.hasOwnProperty.call(e.dependencies,t)||(this.warn("nonDependencyBundleDependency",t),e.dependencies[t]="*"),!0):(this.warn("nonStringBundleDependency",t),!1)},this))},fixDependencies:function(e){!function(e,t){s.forEach(function(r){e[r]&&(e[r]=function(e,t,r){if(!e)return{};"string"==typeof e&&(e=e.trim().split(/[\n\r\s\t ,]+/));if(!Array.isArray(e))return e;r("deprecatedArrayDependencies",t);var n={};return e.filter(function(e){return"string"==typeof e}).forEach(function(e){var t=(e=e.trim().split(/(:?[@\s><=])/)).shift(),r=e.join("");r=(r=r.trim()).replace(/^@/,""),n[t]=r}),n}(e[r],r,t))})}(e,this.warn),function(e){var t=e.optionalDependencies;if(!t)return;var r=e.dependencies||{};Object.keys(t).forEach(function(e){r[e]=t[e]}),e.dependencies=r}(e,this.warn),this.fixBundleDependenciesField(e),["dependencies","devDependencies"].forEach(function(t){if(t in e)return e[t]&&"object"==typeof e[t]?void Object.keys(e[t]).forEach(function(r){var n=e[t][r];"string"!=typeof n&&(this.warn("nonStringDependency",r,JSON.stringify(n)),delete e[t][r]);var o=i.fromUrl(e[t][r]);o&&(e[t][r]=o.toString())},this):(this.warn("nonObjectDependencies",t),void delete e[t])},this)},fixModulesField:function(e){e.modules&&(this.warn("deprecatedModules"),delete e.modules)},fixKeywordsField:function(e){"string"==typeof e.keywords&&(e.keywords=e.keywords.split(/,\s+/)),e.keywords&&!Array.isArray(e.keywords)?(delete e.keywords,this.warn("nonArrayKeywords")):e.keywords&&(e.keywords=e.keywords.filter(function(e){return!("string"!=typeof e||!e)||(this.warn("nonStringKeyword"),!1)},this))},fixVersionField:function(e,n){var i=!n;if(!e.version)return e.version="",!0;if(!t(e.version,i))throw new Error('Invalid version: "'+e.version+'"');return e.version=r(e.version,i),!0},fixPeople:function(e){u(e,f),u(e,p)},fixNameField:function(e,t){"boolean"==typeof t?t={strict:t}:void 0===t&&(t={});var r=t.strict;if(e.name||r){if("string"!=typeof e.name)throw new Error("name field must be a string.");r||(e.name=e.name.trim()),function(e,t,r){if("."===e.charAt(0)||!function(e){if("@"!==e.charAt(0))return!1;var t=e.slice(1).split("/");if(2!==t.length)return!1;return t[0]&&t[1]&&t[0]===encodeURIComponent(t[0])&&t[1]===encodeURIComponent(t[1])}(e)&&(n=e,n.match(/[/@\s+%:]/)||n!==encodeURIComponent(n))||t&&!r&&e!==e.toLowerCase()||"node_modules"===e.toLowerCase()||"favicon.ico"===e.toLowerCase())throw new Error("Invalid name: "+JSON.stringify(e));var n}(e.name,r,t.allowLegacyCase),o(e.name)&&this.warn("conflictingName",e.name)}else e.name=""},fixDescriptionField:function(e){e.description&&"string"!=typeof e.description&&(this.warn("nonStringDescription"),delete e.description),e.readme&&!e.description&&(e.description=a(e.readme)),void 0===e.description&&delete e.description,e.description||this.warn("missingDescription")},fixReadmeField:function(e){e.readme||(this.warn("missingReadme"),e.readme="ERROR: No README data found!")},fixBugsField:function(t){if(!t.bugs&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.bugs()&&(t.bugs={url:r.bugs()})}else if(t.bugs){if("string"==typeof t.bugs)l(t.bugs)?t.bugs={email:t.bugs}:e.canParse(t.bugs)?t.bugs={url:t.bugs}:this.warn("nonEmailUrlBugsString");else{!function(e,t){if(!e)return;Object.keys(e).forEach(function(r){c.bugs[r]&&(t("typo",r,c.bugs[r],"bugs"),e[c.bugs[r]]=e[r],delete e[r])})}(t.bugs,this.warn);var n=t.bugs;t.bugs={},n.url&&(e.canParse(n.url)?t.bugs.url=n.url:this.warn("nonUrlBugsUrlField")),n.email&&("string"==typeof n.email&&l(n.email)?t.bugs.email=n.email:this.warn("nonEmailBugsEmailField"))}t.bugs.email||t.bugs.url||(delete t.bugs,this.warn("emptyNormalizedBugs"))}},fixHomepageField:function(t){if(!t.homepage&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.docs()&&(t.homepage=r.docs())}if(t.homepage)return"string"!=typeof t.homepage?(this.warn("nonUrlHomepage"),delete t.homepage):void(e.canParse(t.homepage)||(t.homepage="http://"+t.homepage))},fixLicenseField:function(e){const t=e.license||e.licence;return t?"string"!=typeof t||t.length<1||""===t.trim()?this.warn("invalidLicense"):n(t).validForNewPackages?void 0:this.warn("invalidLicense"):this.warn("missingLicense")}},Ke}var Qe,et,tt,rt,nt={repositories:"'repositories' (plural) Not supported. Please pick one as the 'repository' field",missingRepository:"No repository field.",brokenGitUrl:"Probably broken git url: %s",nonObjectScripts:"scripts must be an object",nonStringScript:"script values must be string commands",nonArrayFiles:"Invalid 'files' member",invalidFilename:"Invalid filename in 'files' list: %s",nonArrayBundleDependencies:"Invalid 'bundleDependencies' list. Must be array of package names",nonStringBundleDependency:"Invalid bundleDependencies member: %s",nonDependencyBundleDependency:"Non-dependency in bundleDependencies: %s",nonObjectDependencies:"%s field must be an object",nonStringDependency:"Invalid dependency: %s %s",deprecatedArrayDependencies:"specifying %s as array is deprecated",deprecatedModules:"modules field is deprecated",nonArrayKeywords:"keywords should be an array of strings",nonStringKeyword:"keywords should be an array of strings",conflictingName:"%s is also the name of a node core module.",nonStringDescription:"'description' field should be a string",missingDescription:"No description",missingReadme:"No README data",missingLicense:"No license field.",nonEmailUrlBugsString:"Bug string field must be url, email, or {email,url}",nonUrlBugsUrlField:"bugs.url field must be a string url. Deleted.",nonEmailBugsEmailField:"bugs.email field must be a string email. Deleted.",emptyNormalizedBugs:"Normalized value of bugs field is an empty object. Deleted.",nonUrlHomepage:"homepage field must be a string url. Deleted.",invalidLicense:"license should be a valid SPDX license expression",typo:"%s should probably be %s."};function it(){if(et)return Qe;et=1;var e=m,t=nt;function r(r,n,i){return i&&(r=i+"['"+r+"']",n=i+"['"+n+"']"),e.format(t.typo,r,n)}return Qe=function(){var n=Array.prototype.slice.call(arguments,0),i=n.shift();if("typo"===i)return r.apply(null,n);var o=t[i]?t[i]:i+": '%s'";return n.unshift(o),e.format.apply(null,n)},Qe}var ot=function(){if(rt)return tt;rt=1,tt=n;var e=Je();n.fixer=e;var t=it(),r=["name","version","description","repository","modules","scripts","files","bin","man","bugs","keywords","readme","homepage","license"].map(function(e){return i(e)+"Field"});function n(n,o,s){!0===o&&(o=null,s=!0),s||(s=!1),o&&!n.private||(o=function(){}),n.scripts&&"node-gyp rebuild"===n.scripts.install&&!n.scripts.preinstall&&(n.gypfile=!0),e.warn=function(){o(t.apply(null,arguments))},r.forEach(function(t){e["fix"+i(t)](n,s)}),n._id=n.name+"@"+n.version}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}return r=r.concat(["dependencies","people","typos"]),tt}(),st=V(ot);const at=(e,t)=>{try{return g(e,v.F_OK),!0}catch(e){return!1}},ct=["index.ts","index.tsx","main.ts","main.tsx"],lt=(e,t,r)=>{const n=a(e??process.cwd(),"src"),i=ct,o=i.map(e=>a(n,e)).find(e=>at(e));if(!o)throw new Error(`Unable to resolve entry point, ensure ${i.join(", ")} exists in ${n}`);return o},ut=(e,t)=>C(e,t,{arrayMerge:(e,t)=>{const r=t[0]??e[0];return"object"==typeof r&&"match"in r&&"middleware"in r?((e,t,r)=>{const n=r.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),i={...t.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),...n};return Object.values(i)})("match",e,t):[...new Set([...e,...t])]}}),ft=async(r,n)=>{const{packageJson:i,root:a}=n,{config:u}=await e(r)??{},f=i.main??i.module??"./dist/bundle.js",d=lt(a);if("build"===r.command){if(s(f)===a)throw new Error("outDir cannot be root, please specify package.main or package.module in package.json");if("src"===s(f))throw new Error("outDir cannot be src, please specify package.main or package.module in package.json");if(s(f)===process.cwd())throw new Error("outDir cannot be the current working directory, please specify package.main or package.module in package.json")}return t({root:a,plugins:[o(),_({debug:!0}),D({extensions:[".md"]})],define:{"process.env.NODE_ENV":JSON.stringify(r.mode),"process.env.NODE_DEBUG":"production"!==r.mode,"process.env.FUSION_LOG_LEVEL":"production"===r.mode?1:3},build:{outDir:s(f),lib:{entry:d,fileName:c(f,l(f)),formats:["es"]},emptyOutDir:!0}},u??{})};function dt(e,t){P("object"==typeof e,new Error(t))}const pt=e=>{if(e.repository)return"string"==typeof e.repository?e.repository:e.repository.url},ht=()=>{try{return N("git remote get-url origin").toString().trim().replace("git@github.com:","https://github.com/").replace(/\.git$/,"")}catch(e){return}},mt=(e="HEAD")=>{try{return N(`git rev-parse ${e}`).toString().trim()}catch(e){return}},gt=()=>{try{return N("git branch --show-current").toString().trim()||void 0}catch{return}},vt="15.7.2-next.2",yt=e=>{if(e?.startsWith("refs/heads/"))return e.slice(11)||void 0},Et=()=>{const e={cliVersion:vt,source:"local",reason:"manual"};if("true"===process.env.GITHUB_ACTIONS){const t=(()=>{const e=process.env.GITHUB_EVENT_NAME||"unknown",t=process.env.GITHUB_ACTOR||"unknown",r=process.env.GITHUB_RUN_ID||"unknown",n=process.env.GITHUB_REPOSITORY||"unknown",i=process.env.GITHUB_WORKFLOW||"unknown",o=process.env.GITHUB_SERVER_URL||"https://github.com";let s="unknown";"unknown"!==n&&"unknown"!==r&&(s=`${o.replace(/\/$/,"")}/${n}/actions/runs/${r}`);const a={eventName:e,actor:t,runId:r,runUrl:s,workflow:i};if(process.env.GITHUB_EVENT_PATH)try{const e=y(process.env.GITHUB_EVENT_PATH,"utf8");Object.assign(a,JSON.parse(e))}catch{console.error("Failed to parse GitHub event payload")}return a})(),r={...e,source:"github",reason:t.eventName,workflow:t.workflow,runId:t.runId,runUrl:t.runUrl,commitId:t.head_commit?.id,repository:t.repository?.name,repository_homepage:t.repository?.homepage,repository_license:t.repository?.license?.name,repository_owner:t.repository?.owner?.login,repository_owner_avatar_url:t.repository?.owner?.avatar_url,actor:t.actor,sender_login:t.sender?.login,sender_avatar_url:t.sender?.avatar_url};return t.pull_request?{...r,branch:t.pull_request.head?.ref,commitId:t.pull_request.head?.sha,htmlUrl:t.pull_request.html_url}:t.release?{...r,tag:t.release.tag_name,htmlUrl:t.release.html_url}:{...r,branch:yt(t.ref??process.env.GITHUB_REF)}}if(process.env.SYSTEM_TEAMPROJECT){const t=(()=>{const e=process.env.BUILD_BUILDID||"unknown",t=process.env.BUILD_DEFINITIONNAME||"unknown",r=process.env.BUILD_REPOSITORY_NAME||"unknown",n=process.env.SYSTEM_TEAMPROJECT||"unknown",i=process.env.SYSTEM_COLLECTIONURI||"unknown",o=process.env.BUILD_REQUESTEDFOR||"unknown",s=process.env.BUILD_SOURCEBRANCH||"unknown",a=process.env.BUILD_SOURCEVERSION||"unknown",c=process.env.BUILD_REASON||"unknown";let l="unknown";return"unknown"!==i&&"unknown"!==n&&"unknown"!==e&&(l=`${i.replace(/\/$/,"")}${n}/_build/results?buildId=${e}`),{runId:e,pipelineName:t,repository:r,project:n,orgUrl:i,actor:o,branch:s,commitId:a,runUrl:l,reason:c}})();return{...e,source:"azure_devops",reason:t.reason,repository:t.repository,runId:t.runId,runUrl:t.runUrl,actor:t.actor,branch:t.branch,commitId:t.commitId,workflow:t.pipelineName}}return{...e,branch:gt()}},bt=["png","jpg","jpeg","gif","svg","ico","webp","mp4","webm","mp3","woff2","woff","eot","ttf","otf","pdf","md","txt"];const wt=(e,t,r)=>{dt(t,"expected packageJson"),P(t.name,"expected [name] in packageJson"),P(t.version,"expected [version] in packageJson");const n=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/app-bundle.js":lt(e.root))(e,t),i=t.name.replace(/^@|\w.*\//gm,""),o=r?.snapshot?function(e,t){const r=O(e)?.version;if(!r)throw new Error(`Invalid semantic version: "${e}". Expected format: major.minor.patch`);const n=Math.floor(Date.now()/1e3);return`${r}-${"string"==typeof t?`${t}.${n}`:`snapshot.${n}`}`}(t.version,r.snapshot):t.version,s="build"===e.command?void 0:`/bundles/apps/${i}@${o}`,a=pt(t)??ht(),c=bt.map(e=>`.${e}`);return{appKey:i,displayName:t.name,description:t.description||"",keywords:t.keywords,type:"standalone",build:{entryPoint:n,assetPath:s,githubRepo:a,version:o,timestamp:(new Date).toISOString(),commitSha:mt(),annotations:Et(),projectPage:t.homepage,allowedExtensions:c}}},It=(e,t)=>C(e,t),Lt=x.object({environment:x.record(x.string(),x.any()).describe("Key-value map of environment-specific variables for the application. Defaults to an empty object if not provided.").optional().default({}),endpoints:x.record(x.string(),x.object({url:x.string({message:"The endpoint URL. This field is required."}),scopes:x.array(x.string()).optional().default([]).describe("List of scopes required for accessing this endpoint. Defaults to an empty array.")})).describe("A mapping of endpoint names to their configuration objects. Each endpoint must specify a URL and may specify scopes.").optional()}).describe("The API application configuration schema, defining environment variables and endpoints for the application."),St=(e,t)=>i.blueBright(t?.relative?`./${u(t?.cwd??process.cwd(),e)}`:e),Ct=async(e,t,r)=>{const n=wt(e,t.packageJson,{snapshot:r?.snapshot});try{r?.log?.start("loading application package...");const{manifest:t,path:i}=await(async(e,t)=>{const r=t?.file??[`app.manifest.${e.environment}`,"app.manifest","app.manifest.config"],n=await L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};if("function"==typeof r.default){const t=await r.default(e,{base:n});return It(n,t??{})}return It(n,r.default??{})}}});return{manifest:n.config,path:n.path,extension:n.extension}})(e,{base:n,file:r?.manifestPath});if(!t.build)throw new Error(`Application manifest for ${t.appKey} does not contain build information, please check the manifest file.`);return"serve"===e.command&&(t.build.assetPath=`/bundles/apps/${t.appKey}/${t.build.version}`),r?.log?.succeed("generated manifest from",St(i,{relative:!0})),t}catch(e){if(e instanceof S){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${St(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(i.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?St(r?.manifestPath):""}`),e}};async function _t(e){e?.start("resolve project package");try{const t=await(async e=>{const t=await f({...e,normalize:!1});if(!t)throw new Error("failed to find package.json");const r={...t.packageJson};return st(r),{packageJson:{...r,version:t.packageJson.version},path:t.path,root:s(t.path)}})();return e?.succeed("ðŸ“Ķ",i.yellowBright([t.packageJson.name,t.packageJson.version].join("@"))),e?.info("🏠",i.blueBright(t.root)),t}catch(t){throw e?.fail("☠ïļ","failed to resolve project package"),t}}const Dt=async e=>{const{log:t}=e??{},r=await _t(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await Ct(n,r,{log:t,manifestPath:e?.manifest,snapshot:e?.snapshot});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},Pt=async e=>{const{log:t,snapshot:n}=e??{};t?.log(i.bold("Starting to build application"));const{manifest:o,pkg:s,env:a}=await Dt({log:t,manifest:e?.manifest,snapshot:n});t?.start("loading vite config...");const c=await ft(a,s);t?.succeed("vite config applied"),t?.debug("vite config:",c),t?.start("ðŸĪžðŸŧ","building application..."),t?.startNativeConsoleCapture(),await r(c),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:s,manifest:o,outDir:c.build.outDir}};var Nt,Ot,At={exports:{}};function $t(){return Ot?Nt:(Ot=1,Nt={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24})}var Rt,Tt,xt,kt,Ft,Ut,Bt,Mt,Gt={};function jt(){return Rt||(Rt=1,function(e){const t={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",MAX_OUTPUT_EXCEEDED:"Decompressed data exceeds the declared uncompressed size",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DUPLICATE_ENTRY:"Duplicate entry name {0}",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",ZIP64_VALUE_TOO_LARGE:"Zip64 value exceeds the maximum safe integer",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function r(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(e,r)=>t[r]||"")),new Error("ADM-ZIP: "+e)}}for(const n of Object.keys(t))e[n]=r(t[n])}(Gt)),Gt}function zt(){if(xt)return Tt;xt=1;const e=k,t=F,r=$t(),n=jt(),i="object"==typeof process&&"win32"===process.platform,o=e=>"object"==typeof e&&null!==e,s=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=3988292384^t>>>1:t>>>=1;return t>>>0});function a(r){this.sep=t.sep,this.fs=e,o(r)&&o(r.fs)&&"function"==typeof r.fs.statSync&&(this.fs=r.fs)}return Tt=a,a.prototype.makeDir=function(e){const t=this;!function(e){let r=e.split(t.sep)[0];e.split(t.sep).forEach(function(e){if(e&&":"!==e.substr(-1,1)){var i;r+=t.sep+e;try{i=t.fs.statSync(r)}catch(e){if(!e.message||!e.message.startsWith("ENOENT"))throw e;t.fs.mkdirSync(r)}if(i&&i.isFile())throw n.FILE_IN_THE_WAY(`"${r}"`)}})}(e)},a.prototype.writeFileTo=function(e,r,n,i){const o=this;if(o.fs.existsSync(e)){if(!n)return!1;if(o.fs.statSync(e).isDirectory())return!1}var s,a=t.dirname(e);o.fs.existsSync(a)||o.makeDir(a);try{s=o.fs.openSync(e,"w",438)}catch(t){o.fs.chmodSync(e,438),s=o.fs.openSync(e,"w",438)}if(s)try{o.fs.writeSync(s,r,0,r.length,0)}finally{o.fs.closeSync(s)}return o.fs.chmodSync(e,i||438),!0},a.prototype.writeFileToAsync=function(e,r,n,i,o){"function"==typeof i&&(o=i,i=void 0);const s=this;s.fs.exists(e,function(a){if(a&&!n)return o(!1);s.fs.stat(e,function(n,c){if(a&&c&&c.isDirectory())return o(!1);var l=t.dirname(e);s.fs.exists(l,function(t){if(!t)try{s.makeDir(l)}catch(e){return o(!1)}const n=function(t){s.fs.write(t,r,0,r.length,0,function(r){s.fs.close(t,function(){if(r)return o(!1);s.fs.chmod(e,i||438,function(){o(!0)})})})};s.fs.open(e,"w",438,function(t,r){t?s.fs.chmod(e,438,function(){s.fs.open(e,"w",438,function(e,t){if(e||!t)return o(!1);n(t)})}):r?n(r):o(!1)})})})})},a.prototype.assertPathSafe=function(e,r){const i=this;if("function"!=typeof i.fs.lstatSync)return;const o=t.resolve(e),s=t.resolve(r);if(s===o)return;const a=t.relative(o,s);if(!a||".."===a||a.startsWith(".."+t.sep)||t.isAbsolute(a))return;let c=o;for(const e of a.split(t.sep)){if(!e||"."===e)continue;let r;c=t.join(c,e);try{r=i.fs.lstatSync(c)}catch(e){break}if(r.isSymbolicLink())throw n.FILE_IN_THE_WAY(`"${c}"`)}},a.prototype.findFiles=function(e){const r=this,n="function"==typeof r.fs.lstatSync,i=r.fs.realpathSync(e);return function e(o,s,a,c){let l=[];return r.fs.readdirSync(o).forEach(function(u){const f=t.join(o,u);if(function(e){if(!n)return!1;if(!r.fs.lstatSync(e).isSymbolicLink())return!1;let o;try{o=r.fs.realpathSync(e)}catch(e){return!0}return!(o===i||o.startsWith(i+t.sep))}(f))return;const d=r.fs.statSync(f);if(l.push(t.normalize(f)+(d.isDirectory()?r.sep:"")),d.isDirectory()&&a){const t=r.fs.realpathSync(f);c.has(t)||(c.add(t),l=l.concat(e(f,s,a,c)))}}),l}(e,void 0,!0,new Set([i]))},a.prototype.findFilesAsync=function(e,r){const n=this,i=[];let o=!1;const s=function(e){o||(o=!0,r(e,e?void 0:i))},a="function"==typeof n.fs.lstat;let c=null;const l=function(e,r,o){n.fs.readdir(e,function(s,u){if(s)return o(s);let f=u.length;if(!f)return o();u.forEach(function(s){const u=t.join(e,s);!function(e,r){if(!a)return r(null,!1);n.fs.lstat(e,function(i,o){return i?r(i):o&&o.isSymbolicLink()?void n.fs.realpath(e,function(e,n){if(e)return r(null,!0);r(null,!(n===c||n.startsWith(c+t.sep)))}):r(null,!1)})}(u,function(e,s){if(e)return o(e);s?--f||o():n.fs.stat(u,function(e,s){if(e)return o(e);s?(i.push(t.normalize(u)+(s.isDirectory()?n.sep:"")),s.isDirectory()?n.fs.realpath(u,function(e,t){if(e)return o(e);r.has(t)?--f||o():(r.add(t),l(u,r,function(e){if(e)return o(e);--f||o()}))}):--f||o()):--f||o()})})})})};n.fs.realpath(e,function(t,r){if(t)return s(t);c=r,l(e,new Set([r]),s)})},a.prototype.getAttributes=function(){},a.prototype.setAttributes=function(){},a.crc32update=function(e,t){return s[255&(e^t)]^e>>>8},a.crc32=function(e){"string"==typeof e&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=a.crc32update(r,e[n++]);return~r>>>0},a.methodToString=function(e){switch(e){case r.STORED:return"STORED ("+e+")";case r.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}},a.canonical=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.join(".",r)},a.zipnamefix=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.posix.join(".",r)},a.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");for(let r=(e.length>>>0)-1;r>=0;r--)if(t(e[r],r,e))return e[r]},a.sanitize=function(e,r){e=t.resolve(t.normalize(e));for(var n=r.split("/"),i=0,o=n.length;i<o;i++){var s=t.normalize(t.join(e,n.slice(i,o).join(t.sep)));if(s===e||s.startsWith(e+t.sep))return s}return t.normalize(t.join(e,t.basename(r)))},a.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):"string"==typeof e?t(e):Buffer.alloc(0)},a.readBigUInt64LE=function(e,t){const r=e.readUInt32LE(t),i=4294967296*e.readUInt32LE(t+4)+r;if(i>Number.MAX_SAFE_INTEGER)throw n.ZIP64_VALUE_TOO_LARGE();return i},a.writeBigUInt64LE=function(e,t,r){const n=t>>>0,i=Math.floor(t/4294967296)>>>0;e.writeUInt32LE(n,r),e.writeUInt32LE(i,r+4)},a.fromDOS2Date=function(e){return new Date(1980+(e>>25&127),Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(31&e)<<1)},a.fromDate2DOS=function(e){let t=0,r=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),r=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|r},a.isWin=i,a.crcTable=s,Tt}function Ht(){return Mt||(Mt=1,At.exports=zt(),At.exports.Constants=$t(),At.exports.Errors=jt(),At.exports.FileAttr=function(){if(Ft)return kt;Ft=1;const e=F;return kt=function(t,{fs:r}){var n=t||"",i={directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0},o=null;return n&&r.existsSync(n)?(o=r.statSync(n),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=!!(73&o.mode),i.readonly=!(128&o.mode),i.hidden="."===e.basename(n)[0]):console.warn("Invalid path: "+n),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}(),At.exports.decoder=Bt?Ut:(Bt=1,Ut={efs:!0,encode:e=>Buffer.from(e,"utf8"),decode:e=>e.toString("utf8")})),At.exports}var qt,Vt,Wt,Zt,Kt,Yt={};function Xt(){if(Vt)return qt;Vt=1;var e=Ht(),t=e.Constants;return qt=function(){var r=20,n=10,i=0,o=0,s=0,a=0,c=0,l=0,u=0,f=0,d=0,p=0,h=0,m=0,g=0;r|=e.isWin?2560:768,i|=t.FLG_EFS;const v={extraLen:0},y=e=>Math.max(0,e)>>>0;return s=e.fromDate2DOS(new Date),{get made(){return r},set made(e){r=e},get version(){return n},set version(e){n=e},get flags(){return i},set flags(e){i=e},get flags_efs(){return(i&t.FLG_EFS)>0},set flags_efs(e){e?i|=t.FLG_EFS:i&=~t.FLG_EFS},get flags_desc(){return(i&t.FLG_DESC)>0},set flags_desc(e){e?i|=t.FLG_DESC:i&=~t.FLG_DESC},get method(){return o},set method(e){switch(e){case t.STORED:this.version=10;break;case t.DEFLATED:default:this.version=20}o=e},get time(){return e.fromDOS2Date(this.timeval)},set time(t){t=new Date(t),this.timeval=e.fromDate2DOS(t)},get timeval(){return s},set timeval(e){s=y(e)},get timeHighByte(){return e=s>>>8,255&Math.max(0,e);var e},get crc(){return a},set crc(e){a=y(e)},get compressedSize(){return c},set compressedSize(e){c=y(e)},get size(){return l},set size(e){l=y(e)},get fileNameLength(){return u},set fileNameLength(e){u=e},get extraLength(){return f},set extraLength(e){f=e},get extraLocalLength(){return v.extraLen},set extraLocalLength(e){v.extraLen=e},get commentLength(){return d},set commentLength(e){d=e},get diskNumStart(){return p},set diskNumStart(e){p=y(e)},get inAttr(){return h},set inAttr(e){h=y(e)},get attr(){return m},set attr(e){m=y(e)},get fileAttr(){return(m||0)>>16&511},get offset(){return g},set offset(e){g=y(e)},get encrypted(){return(i&t.FLG_ENC)===t.FLG_ENC},get centralHeaderSize(){return t.CENHDR+u+f+d},get realDataOffset(){return g+t.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(r){if(g<0||g+t.LOCHDR>r.length)throw e.Errors.INVALID_LOC();var n=r.slice(g,g+t.LOCHDR);if(n.readUInt32LE(0)!==t.LOCSIG)throw e.Errors.INVALID_LOC();v.version=n.readUInt16LE(t.LOCVER),v.flags=n.readUInt16LE(t.LOCFLG),v.flags_desc=(v.flags&t.FLG_DESC)>0,v.method=n.readUInt16LE(t.LOCHOW),v.time=n.readUInt32LE(t.LOCTIM),v.crc=n.readUInt32LE(t.LOCCRC),v.compressedSize=n.readUInt32LE(t.LOCSIZ),v.size=n.readUInt32LE(t.LOCLEN),v.fnameLen=n.readUInt16LE(t.LOCNAM),v.extraLen=n.readUInt16LE(t.LOCEXT);const i=g+t.LOCHDR+v.fnameLen,o=i+v.extraLen;return r.slice(i,o)},loadFromBinary:function(v){if(v.length!==t.CENHDR||v.readUInt32LE(0)!==t.CENSIG)throw e.Errors.INVALID_CEN();r=v.readUInt16LE(t.CENVEM),n=v.readUInt16LE(t.CENVER),i=v.readUInt16LE(t.CENFLG),o=v.readUInt16LE(t.CENHOW),s=v.readUInt32LE(t.CENTIM),a=v.readUInt32LE(t.CENCRC),c=v.readUInt32LE(t.CENSIZ),l=v.readUInt32LE(t.CENLEN),u=v.readUInt16LE(t.CENNAM),f=v.readUInt16LE(t.CENEXT),d=v.readUInt16LE(t.CENCOM),p=v.readUInt16LE(t.CENDSK),h=v.readUInt16LE(t.CENATT),m=v.readUInt32LE(t.CENATX),g=v.readUInt32LE(t.CENOFF)},localHeaderToBinary:function(){var e=Buffer.alloc(t.LOCHDR);return e.writeUInt32LE(t.LOCSIG,0),e.writeUInt16LE(n,t.LOCVER),e.writeUInt16LE(i&~t.FLG_DESC,t.LOCFLG),e.writeUInt16LE(o,t.LOCHOW),e.writeUInt32LE(s,t.LOCTIM),e.writeUInt32LE(a,t.LOCCRC),e.writeUInt32LE(c,t.LOCSIZ),e.writeUInt32LE(l,t.LOCLEN),e.writeUInt16LE(u,t.LOCNAM),e.writeUInt16LE(v.extraLen,t.LOCEXT),e},centralHeaderToBinary:function(){var e=Buffer.alloc(t.CENHDR+u+f+d);return e.writeUInt32LE(t.CENSIG,0),e.writeUInt16LE(r,t.CENVEM),e.writeUInt16LE(n,t.CENVER),e.writeUInt16LE(i&~t.FLG_DESC,t.CENFLG),e.writeUInt16LE(o,t.CENHOW),e.writeUInt32LE(s,t.CENTIM),e.writeUInt32LE(a,t.CENCRC),e.writeUInt32LE(c,t.CENSIZ),e.writeUInt32LE(l,t.CENLEN),e.writeUInt16LE(u,t.CENNAM),e.writeUInt16LE(f,t.CENEXT),e.writeUInt16LE(d,t.CENCOM),e.writeUInt16LE(p,t.CENDSK),e.writeUInt16LE(h,t.CENATT),e.writeUInt32LE(m,t.CENATX),e.writeUInt32LE(g,t.CENOFF),e},toJSON:function(){const s=function(e){return e+" bytes"};return{made:r,version:n,flags:i,method:e.methodToString(o),time:this.time,crc:"0x"+a.toString(16).toUpperCase(),compressedSize:s(c),size:s(l),fileNameLength:s(u),extraLength:s(f),commentLength:s(d),diskNumStart:p,inAttr:h,attr:m,offset:g,centralHeaderSize:s(t.CENHDR+u+f+d)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}function Jt(){return Kt||(Kt=1,Yt.EntryHeader=Xt(),Yt.MainHeader=function(){if(Zt)return Wt;Zt=1;var e=Ht(),t=e.Constants;return Wt=function(){var r=0,n=0,i=0,o=0,s=0;const a=()=>r>t.EF_ZIP64_OR_16||n>t.EF_ZIP64_OR_16||i>t.EF_ZIP64_OR_32||o>t.EF_ZIP64_OR_32;return{get diskEntries(){return r},set diskEntries(e){r=n=e},get totalEntries(){return n},set totalEntries(e){n=r=e},get size(){return i},set size(e){i=e},get offset(){return o},set offset(e){o=e},get commentLength(){return s},set commentLength(e){s=e},get mainHeaderSize(){return(a()?t.ZIP64HDR+t.END64HDR:0)+t.ENDHDR+s},loadFromBinary:function(a){if((a.length!==t.ENDHDR||a.readUInt32LE(0)!==t.ENDSIG)&&(a.length<t.ZIP64HDR||a.readUInt32LE(0)!==t.ZIP64SIG))throw e.Errors.INVALID_END();a.readUInt32LE(0)===t.ENDSIG?(r=a.readUInt16LE(t.ENDSUB),n=a.readUInt16LE(t.ENDTOT),i=a.readUInt32LE(t.ENDSIZ),o=a.readUInt32LE(t.ENDOFF),s=a.readUInt16LE(t.ENDCOM)):(r=e.readBigUInt64LE(a,t.ZIP64SUB),n=e.readBigUInt64LE(a,t.ZIP64TOT),i=e.readBigUInt64LE(a,t.ZIP64SIZB),o=e.readBigUInt64LE(a,t.ZIP64OFF),s=0)},toBinary:function(){var c;if(!a())return(c=Buffer.alloc(t.ENDHDR+s)).writeUInt32LE(t.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(r,t.ENDSUB),c.writeUInt16LE(n,t.ENDTOT),c.writeUInt32LE(i,t.ENDSIZ),c.writeUInt32LE(o,t.ENDOFF),c.writeUInt16LE(s,t.ENDCOM),c.fill(" ",t.ENDHDR),c;let l=0;(c=Buffer.alloc(this.mainHeaderSize)).writeUInt32LE(t.ZIP64SIG,l),e.writeBigUInt64LE(c,t.ZIP64HDR-t.ZIP64LEAD,l+t.ZIP64SIZE),c.writeUInt16LE(45,l+t.ZIP64VEM),c.writeUInt16LE(45,l+t.ZIP64VER),c.writeUInt32LE(0,l+t.ZIP64DSK),c.writeUInt32LE(0,l+t.ZIP64DSKDIR),e.writeBigUInt64LE(c,r,l+t.ZIP64SUB),e.writeBigUInt64LE(c,n,l+t.ZIP64TOT),e.writeBigUInt64LE(c,i,l+t.ZIP64SIZB),e.writeBigUInt64LE(c,o,l+t.ZIP64OFF);const u=o+i;return l+=t.ZIP64HDR,c.writeUInt32LE(t.END64SIG,l),c.writeUInt32LE(0,l+t.END64START),e.writeBigUInt64LE(c,u,l+t.END64OFF),c.writeUInt32LE(1,l+t.END64NUMDISKS),l+=t.END64HDR,c.writeUInt32LE(t.ENDSIG,l),c.writeUInt32LE(0,l+4),c.writeUInt16LE(Math.min(r,t.EF_ZIP64_OR_16),l+t.ENDSUB),c.writeUInt16LE(Math.min(n,t.EF_ZIP64_OR_16),l+t.ENDTOT),c.writeUInt32LE(Math.min(i,t.EF_ZIP64_OR_32),l+t.ENDSIZ),c.writeUInt32LE(Math.min(o,t.EF_ZIP64_OR_32),l+t.ENDOFF),c.writeUInt16LE(s,l+t.ENDCOM),c.fill(" ",l+t.ENDHDR),c},toJSON:function(){return{diskEntries:r,totalEntries:n,size:i+" bytes",offset:function(e,t){let r=e.toString(16).toUpperCase();for(;r.length<t;)r="0"+r;return"0x"+r}(o,4),commentLength:s}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}()),Yt}var Qt,er,tr,rr,nr,ir,or,sr,ar,cr,lr,ur,fr,dr={};function pr(){if(ir)return nr;ir=1;const{randomFillSync:e}=B,t=jt(),r=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=t>>>1^3988292384:t>>>=1;return t>>>0}),n=(e,t)=>Math.imul(e,t)>>>0,i=(e,t)=>r[255&(e^t)]^e>>>8,o=()=>"function"==typeof e?e(Buffer.alloc(12)):o.node();o.node=()=>{const e=Buffer.alloc(12),t=e.length;for(let r=0;r<t;r++)e[r]=256*Math.random()&255;return e};const s={genSalt:o};function a(e){const t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let e=0;e<t.length;e++)this.updateKeys(t[e])}return a.prototype.updateKeys=function(e){const t=this.keys;return t[0]=i(t[0],e),t[1]+=255&t[0],t[1]=n(t[1],134775813)+1,t[2]=i(t[2],t[1]>>>24),e},a.prototype.next=function(){const e=(2|this.keys[2])>>>0;return n(e,1^e)>>8&255},nr={decrypt:function(e,r,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);const i=function(e){const t=new a(e);return function(e){const r=Buffer.alloc(e.length);let n=0;for(let i of e)r[n++]=t.updateKeys(i^t.next());return r}}(n),o=i(e.slice(0,12)),s=8&~r.flags?r.crc>>>24:r.timeHighByte;if(o[11]!==s)throw t.WRONG_PASSWORD();return i(e.slice(12))},encrypt:function(e,t,r,n=!1){null==e&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));const i=function(e){const t=new a(e);return function(e,r,n=0){r||(r=Buffer.alloc(e.length));for(let i of e){const e=t.next();r[n++]=i^e,t.updateKeys(i)}return r}}(r),o=s.genSalt();o[11]=t.crc>>>24&255,n&&(o[10]=t.crc>>>16&255);const c=Buffer.alloc(e.length+12);return i(o,c),i(e,c,12)},_salter:function(e){Buffer.isBuffer(e)&&e.length>=12?s.genSalt=function(){return e.slice(0,12)}:s.genSalt="node"===e?o.node:o}}}function hr(){return or||(or=1,dr.Deflater=er?Qt:(er=1,Qt=function(e){var t=U,r={chunkSize:1024*(parseInt(e.length/1024)+1)};return{deflate:function(){return t.deflateRawSync(e,r)},deflateAsync:function(n){var i=t.createDeflateRaw(r),o=[],s=0;i.on("data",function(e){o.push(e),s+=e.length}),i.on("end",function(){var e=Buffer.alloc(s),t=0;e.fill(0);for(var r=0;r<o.length;r++){var i=o[r];i.copy(e,t),t+=i.length}n&&n(e)}),i.end(e)}}}),dr.Inflater=function(){if(rr)return tr;rr=1;const e=+(process?.versions?.node??"").split(".")[0]||0,t=jt();return tr=function(r,n){var i=U;const o=n>0?n:1,s=e>=15?{maxOutputLength:o}:{};return{inflate:function(){return i.inflateRawSync(r,s)},inflateAsync:function(e){var n=i.createInflateRaw(s),a=[],c=0,l=!1;const u=function(t){l||(l=!0,n.destroy(),e&&e(Buffer.alloc(0),t))};n.on("error",function(e){u(e)}),n.on("data",function(e){if(!l){if((c+=e.length)>o)return u(t.MAX_OUTPUT_EXCEEDED());a.push(e)}}),n.on("end",function(){if(!l){l=!0;var t=Buffer.alloc(c),r=0;t.fill(0);for(var n=0;n<a.length;n++){var i=a[n];i.copy(t,r),r+=i.length}e&&e(t)}}),n.end(r)}}}}(),dr.ZipCrypto=pr()),dr}function mr(){if(ar)return sr;ar=1;var e=Ht(),t=Jt(),r=e.Constants,n=hr();return sr=function(i,o){var s=new t.EntryHeader,a=Buffer.alloc(0),c=Buffer.alloc(0),l=!1,u=null,f=Buffer.alloc(0),d=Buffer.alloc(0),p=!0;const h=i,m="object"==typeof h.decoder?h.decoder:e.decoder;function g(){if(!(o&&o instanceof Uint8Array))return Buffer.alloc(0);d=s.loadLocalHeaderFromBinary(o);const t=s.realDataOffset,r=t+s.compressedSize;if(t<0||r<t||r>o.length)throw e.Errors.INVALID_LOC();return o.slice(t,r)}function v(t){const r=s.flags_desc||s.localHeader.flags_desc?s.crc:s.localHeader.crc;return e.crc32(t)===r}function y(t,r,i){if(void 0===r&&"string"==typeof t&&(i=t,t=void 0),l)return t&&r&&r(Buffer.alloc(0),e.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var o,c;try{if(0===(o=g()).length)return t&&r&&r(o),o;if(s.encrypted){if("string"!=typeof i&&!Buffer.isBuffer(i))throw e.Errors.INVALID_PASS_PARAM();o=n.ZipCrypto.decrypt(o,s,i)}}catch(e){if(t&&r)return r(Buffer.alloc(0),e),Buffer.alloc(0);throw e}switch(s.method){case e.Constants.STORED:if(c=Buffer.alloc(o.length),o.copy(c),v(c))return t&&r&&r(c),c;throw t&&r&&r(c,e.Errors.BAD_CRC()),e.Errors.BAD_CRC();case e.Constants.DEFLATED:var u=new n.Inflater(o,s.size);if(!t){if(!v(c=u.inflate()))throw e.Errors.BAD_CRC(`"${m.decode(a)}"`);return c}u.inflateAsync(function(t,n){r&&(n?r(Buffer.alloc(0),n):v(t)?r(t):r(t,e.Errors.BAD_CRC()))});break;default:throw t&&r&&r(Buffer.alloc(0),e.Errors.UNKNOWN_METHOD()),e.Errors.UNKNOWN_METHOD()}}function E(t,r){if((!u||!u.length)&&Buffer.isBuffer(o))return t&&r&&r(g()),g();if(u.length&&!l){var i;switch(s.method){case e.Constants.STORED:return s.compressedSize=s.size,i=Buffer.alloc(u.length),u.copy(i),t&&r&&r(i),i;default:case e.Constants.DEFLATED:var a=new n.Deflater(u);if(!t){var c=a.deflate();return s.compressedSize=c.length,c}a.deflateAsync(function(e){i=Buffer.alloc(e.length),s.compressedSize=e.length,e.copy(i),r&&r(i)}),a=null}}else{if(!t||!r)return Buffer.alloc(0);r(Buffer.alloc(0))}}function b(t,r){return e.readBigUInt64LE(t,r)}function w(e){var t,n,i,o;e.length>=r.EF_ZIP64_SCOMP&&(t=b(e,r.EF_ZIP64_SUNCOMP),s.size===r.EF_ZIP64_OR_32&&(s.size=t)),e.length>=r.EF_ZIP64_RHO&&(n=b(e,r.EF_ZIP64_SCOMP),s.compressedSize===r.EF_ZIP64_OR_32&&(s.compressedSize=n)),e.length>=r.EF_ZIP64_DSN&&(i=b(e,r.EF_ZIP64_RHO),s.offset===r.EF_ZIP64_OR_32&&(s.offset=i)),e.length>=r.EF_ZIP64_DSN+4&&(o=e.readUInt32LE(r.EF_ZIP64_DSN),s.diskNumStart===r.EF_ZIP64_OR_16&&(s.diskNumStart=o))}return p=!!m.hasOwnProperty("efs")&&m.efs,{get entryName(){return m.decode(a)},get rawEntryName(){return a},set entryName(t){var r=(a=e.toBuffer(t,m.encode))[a.length-1];l=47===r||92===r,s.fileNameLength=a.length},get efs(){return"function"==typeof p?p(this.entryName):p},get extra(){return f},set extra(t){f=t,s.extraLength=t.length,function(t){try{for(var n,i,o,s=0;s+4<t.length;)n=t.readUInt16LE(s),s+=2,i=t.readUInt16LE(s),s+=2,o=t.slice(s,s+i),s+=i,r.ID_ZIP64===n&&w(o)}catch(t){throw e.Errors.EXTRA_FIELD_PARSE_ERROR()}}(t)},get comment(){return m.decode(c)},set comment(t){if(c=e.toBuffer(t,m.encode),s.commentLength=c.length,c.length>65535)throw e.Errors.COMMENT_TOO_LONG()},get name(){const e=m.decode(a);return l?e.replace(/[/\\]$/,"").split("/").pop():e.split("/").pop()},get isDirectory(){return l},getCompressedData:function(){return E(!1,null)},getCompressedDataAsync:function(e){E(!0,e)},setData:function(t){u=e.toBuffer(t,e.decoder.encode),!l&&u.length?(s.size=u.length,s.method=e.Constants.DEFLATED,s.crc=e.crc32(t),s.changed=!0):s.method=e.Constants.STORED},getData:function(e){return s.changed?u:y(!1,null,e)},getDataAsync:function(e,t){s.changed?e(u):y(!0,e,t)},set attr(e){s.attr=e},get attr(){return s.attr},set header(e){s.loadFromBinary(e)},get header(){return s},packCentralHeader:function(){s.flags_efs=this.efs,s.extraLength=f.length;var t=s.centralHeaderToBinary(),r=e.Constants.CENHDR;return a.copy(t,r),r+=a.length,f.copy(t,r),r+=s.extraLength,c.copy(t,r),t},packLocalHeader:function(){let e=0;s.flags_efs=this.efs,s.extraLocalLength=d.length;const t=s.localHeaderToBinary(),r=Buffer.alloc(t.length+a.length+s.extraLocalLength);return t.copy(r,e),e+=t.length,a.copy(r,e),e+=a.length,d.copy(r,e),e+=d.length,r},toJSON:function(){const e=function(e){return"<"+(e&&e.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:s.toJSON(),compressedData:e(o),data:e(u)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}},sr}function gr(){if(lr)return cr;lr=1;const e=mr(),t=Jt(),r=Ht();return cr=function(n,i){var o=[],s=Object.create(null),a=Buffer.alloc(0),c=new t.MainHeader,l=!1;const u=new Set,f=i,{noSort:d,decoder:p}=f;function h(){if(l=!0,s=Object.create(null),c.diskEntries>(n.length-c.offset)/r.Constants.CENHDR)throw r.Errors.DISK_ENTRY_TOO_LARGE();o=new Array(c.diskEntries);for(var t=c.offset,i=0;i<o.length;i++){var a=t,d=new e(f,n);if(d.header=n.slice(a,a+=r.Constants.CENHDR),d.entryName=n.slice(a,a+=d.header.fileNameLength),d.header.extraLength&&(d.extra=n.slice(a,a+=d.header.extraLength)),d.header.commentLength&&(d.comment=n.slice(a,a+d.header.commentLength)),t+=d.header.centralHeaderSize,d.entryName in s)throw r.Errors.DUPLICATE_ENTRY(`"${d.entryName}"`);o[i]=d,s[d.entryName]=d}u.clear(),function(){const t=new Set;for(const e of Object.keys(s)){const r=e.split("/");if(r.pop(),r.length)for(let e=0;e<r.length;e++){const n=r.slice(0,e+1).join("/")+"/";t.add(n)}}for(const r of t)if(!(r in s)){const t=new e(f);t.entryName=r,t.attr=16,t.temporary=!0,o.push(t),s[t.entryName]=t,u.add(t)}}()}function m(){o.length>1&&!d&&(o=o.map(e=>({entry:e,key:e.entryName.toLowerCase()})).sort((e,t)=>e.key.localeCompare(t.key)).map(e=>e.entry))}return n?function(e){var t=n.length-r.Constants.ENDHDR,i=Math.max(0,t-65535),o=i,s=n.length,l=-1,u=0;"boolean"==typeof f.trailingSpace&&f.trailingSpace&&(i=0);for(;t>=o;t--)if(80===n[t])if(n.readUInt32LE(t)!==r.Constants.ENDSIG)if(n.readUInt32LE(t)!==r.Constants.END64SIG){if(n.readUInt32LE(t)===r.Constants.ZIP64SIG){l=t,s=t+r.readBigUInt64LE(n,t+r.Constants.ZIP64SIZE)+r.Constants.ZIP64LEAD;break}}else o=i;else l=t,u=t,s=t+r.Constants.ENDHDR,o=t-r.Constants.END64HDR;if(-1==l)throw r.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(l,s)),c.commentLength&&(a=n.slice(u+r.Constants.ENDHDR));e&&h()}(f.readEntries):l=!0,{get entries(){return l||h(),o.filter(e=>!u.has(e))},get comment(){return p.decode(a)},set comment(e){a=r.toBuffer(e,p.encode),c.commentLength=a.length},getEntryCount:function(){return l?o.length:c.diskEntries},forEach:function(e){this.entries.forEach(e)},getEntry:function(e){return l||h(),s[e]||null},setEntry:function(e){l||h(),o.push(e),s[e.entryName]=e,c.totalEntries=o.length},deleteFile:function(e,t=!0){l||h();const r=s[e];this.getEntryChildren(r,t).map(e=>e.entryName).forEach(this.deleteEntry)},deleteEntry:function(e){l||h();const t=s[e],r=o.indexOf(t);r>=0&&(o.splice(r,1),delete s[e],c.totalEntries=o.length)},getEntryChildren:function(e,t=!0){if(l||h(),"object"==typeof e){if(e.isDirectory&&t){const t=[],r=e.entryName;for(const e of o)e.entryName.startsWith(r)&&t.push(e);return t}return[e]}return[]},getChildCount:function(e){if(e&&e.isDirectory){const t=this.getEntryChildren(e);return t.includes(e)?t.length-1:t.length}return 0},compressToBuffer:function(){l||h(),m();const e=[],t=[];let r=0,i=0;c.size=0,c.offset=0;let o=0;for(const n of this.entries){const s=n.getCompressedData();n.header.offset=i;const a=n.packLocalHeader(),l=a.length+s.length;i+=l,e.push(a),e.push(s);const u=n.packCentralHeader();t.push(u),c.size+=u.length,r+=l+u.length,o++}r+=c.mainHeaderSize,c.offset=i,c.totalEntries=o,i=0;const s=Buffer.alloc(r);for(const t of e)t.copy(s,i),i+=t.length;for(const e of t)e.copy(s,i),i+=e.length;const u=c.toBinary();return a&&a.copy(u,u.length-a.length),u.copy(s,i),n=s,l=!1,s},toAsyncBuffer:function(e,t,r,i){try{l||h(),m();const t=[],o=[];let s=0,u=0,f=0;c.size=0,c.offset=0;const d=function(p){if(p.length>0){const e=p.shift(),n=e.entryName+e.extra.toString();r&&r(n),e.getCompressedDataAsync(function(r){i&&i(n),e.header.offset=u;const a=e.packLocalHeader(),l=a.length+r.length;u+=l,t.push(a),t.push(r);const h=e.packCentralHeader();o.push(h),c.size+=h.length,s+=l+h.length,f++,d(p)})}else{s+=c.mainHeaderSize,c.offset=u,c.totalEntries=f,u=0;const r=Buffer.alloc(s);t.forEach(function(e){e.copy(r,u),u+=e.length}),o.forEach(function(e){e.copy(r,u),u+=e.length});const i=c.toBinary();a&&a.copy(i,i.length-a.length),i.copy(r,u),n=r,l=!1,e(r)}};d(Array.from(this.entries))}catch(e){t(e)}}}},cr}var vr=function(){if(fr)return ur;fr=1;const e=Ht(),t=F,r=mr(),n=gr(),i=(...t)=>e.findLast(t,e=>"boolean"==typeof e),o=(...t)=>e.findLast(t,e=>"string"==typeof e),s={noSort:!1,readEntries:!1,method:e.Constants.NONE,fs:null};return ur=function(a,c){let l=null;const u=Object.assign(Object.create(null),s);a&&"object"==typeof a&&(a instanceof Uint8Array||(Object.assign(u,a),a=u.input?u.input:void 0,u.input&&delete u.input),Buffer.isBuffer(a)&&(l=a,u.method=e.Constants.BUFFER,a=void 0)),Object.assign(u,c);const f=new e(u),d=e=>{e.filter(e=>e.attr).sort((e,t)=>t.path.length-e.path.length).forEach(e=>f.fs.chmodSync(e.path,e.attr))};if("object"==typeof u.decoder&&"function"==typeof u.decoder.encode&&"function"==typeof u.decoder.decode||(u.decoder=e.decoder),a&&"string"==typeof a){if(!f.fs.existsSync(a))throw e.Errors.INVALID_FILENAME();u.method=e.Constants.FILE,u.filename=a,l=f.fs.readFileSync(a)}const p=new n(l,u),{canonical:h,sanitize:m,zipnamefix:g}=e;function v(e){var r;if(e&&p&&("string"==typeof e&&(r=p.getEntry(t.posix.normalize(e))),"object"==typeof e&&void 0!==e.entryName&&void 0!==e.header&&(r=p.getEntry(e.entryName)),r))return r;return null}function y(e){const{join:r,normalize:n,sep:i}=t.posix;return r(t.isAbsolute(e)?"/":".",n(i+e.split("\\").join(i)+i))}function E(e){return e instanceof RegExp?(t=e,function(e){return t.test(e)}):"function"!=typeof e?()=>!0:e;var t}const b=(e,r)=>{let n=r.slice(-1);return n=n===f.sep?f.sep:"",t.relative(e,r)+n};return{readFile:function(e,t){var r=v(e);return r&&r.getData(t)||null},childCount:function(e){const t=v(e);if(t)return p.getChildCount(t)},readFileAsync:function(e,t){var r=v(e);r?r.getDataAsync(t):t(null,"getEntry failed for:"+e)},readAsText:function(e,t){var r=v(e);if(r){var n=r.getData();if(n&&n.length)return n.toString(t||"utf8")}return""},readAsTextAsync:function(e,t,r){var n=v(e);n?n.getDataAsync(function(e,n){n?t(e,n):e&&e.length?t(e.toString(r||"utf8")):t("")}):t("")},deleteFile:function(e,t=!0){var r=v(e);r&&p.deleteFile(r.entryName,t)},deleteEntry:function(e){var t=v(e);t&&p.deleteEntry(t.entryName)},addZipComment:function(e){p.comment=e},getZipComment:function(){return p.comment||""},addZipEntryComment:function(e,t){var r=v(e);r&&(r.comment=t)},getZipEntryComment:function(e){var t=v(e);return t&&t.comment||""},updateFile:function(e,t){var r=v(e);r&&r.setData(t)},addLocalFile:function(r,n,i,o){if(!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{n=n?y(n):"";const e=t.win32.basename(t.win32.normalize(r));n+=i||e;const s=f.fs.statSync(r),a=s.isFile()?f.fs.readFileSync(r):Buffer.alloc(0);s.isDirectory()&&(n+=f.sep),this.addFile(n,a,o,s)}},addLocalFileAsync:function(e,r){e="object"==typeof e?e:{localPath:e};const n=t.resolve(e.localPath),{comment:i}=e;let{zipPath:o,zipName:s}=e;const a=this;f.fs.stat(n,function(e,c){if(e)return r(e,!1);o=o?y(o):"";const l=t.win32.basename(t.win32.normalize(n));if(o+=s||l,c.isFile())f.fs.readFile(n,function(e,t){return e?r(e,!1):(a.addFile(o,t,i,c),setImmediate(r,void 0,!0))});else if(c.isDirectory())return o+=f.sep,a.addFile(o,Buffer.alloc(0),i,c),setImmediate(r,void 0,!0)})},addLocalFolder:function(r,n,i){if(i=E(i),n=n?y(n):"",r=t.normalize(r),!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{const e=f.findFiles(r),o=this;if(e.length)for(const s of e){const e=t.join(n,b(r,s));i(e)&&o.addLocalFile(s,t.dirname(e))}}},addLocalFolderAsync:function(r,n,i,o){o=E(o),i=i?y(i):"",r=t.normalize(r);var s=this;f.fs.open(r,"r",function(t){if(t&&"ENOENT"===t.code)n(void 0,e.Errors.FILE_NOT_FOUND(r));else if(t)n(void 0,t);else{var a=f.findFiles(r),c=-1,l=function(){if((c+=1)<a.length){var e=a[c],t=b(r,e).split("\\").join("/");t=t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),o(t)?f.fs.stat(e,function(r,o){r&&n(void 0,r),o.isFile()?f.fs.readFile(e,function(e,r){e?n(void 0,e):(s.addFile(i+t,r,"",o),l())}):(s.addFile(i+t+"/",Buffer.alloc(0),"",o),l())}):process.nextTick(()=>{l()})}else n(!0,void 0)};l()}})},addLocalFolderAsync2:function(r,n){const i=this;r="object"==typeof r?r:{localPath:r};const o=t.resolve(r.localPath);let{zipPath:s,filter:a,namefix:c}=r;var l;a instanceof RegExp?(l=a,a=function(e){return l.test(e)}):"function"!=typeof a&&(a=function(){return!0}),s=s?y(s):"","latin1"===c&&(c=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),"function"!=typeof c&&(c=e=>e);const u=e=>t.join(s,c(b(o,e))),d=e=>t.win32.basename(t.win32.normalize(c(e)));f.fs.open(o,"r",function(r){r&&"ENOENT"===r.code?n(e.Errors.FILE_NOT_FOUND(o),!1):r?n(r,!1):f.findFilesAsync(o,function(e,r){return e?n(e,!1):(r=r.filter(e=>a(u(e)))).length?void setImmediate(r.reverse().reduce(function(e,r){return function(n,o){if(n||!1===o)return setImmediate(e,n,!1);i.addLocalFileAsync({localPath:r,zipPath:t.dirname(u(r)),zipName:d(r)},e)}},n)):n(void 0,!0)})})},addLocalFolderPromise:function(e,t){return new Promise((r,n)=>{this.addLocalFolderAsync2(Object.assign({localPath:e},t),(e,t)=>{if(e)return n(e);t&&r(this)})})},addFile:function(e,t,n,i){let o=v(e=g(e));const s=null!=o;s||(o=new r(u),o.entryName=e),o.comment=n||"";const a="object"==typeof i&&i instanceof f.fs.Stats;a&&(o.header.time=i.mtime);var c=o.isDirectory?16:0;let l=o.isDirectory?16384:32768;return l|=a?4095&i.mode:"number"==typeof i?4095&i:o.isDirectory?493:420,c=(c|l<<16)>>>0,o.attr=c,o.setData(t),s||p.setEntry(o),o},getEntries:function(e){return p.password=e,p?p.entries:[]},getEntry:function(e){return v(e)},getEntryCount:function(){return p.getEntryCount()},forEach:function(e){return p.forEach(e)},extractEntryTo:function(r,n,s,a,c,l){a=i(!1,a),c=i(!1,c),s=i(!0,s),l=o(c,l);var u=v(r);if(!u)throw e.Errors.NO_ENTRY();var d=h(u.entryName),g=m(n,l&&!u.isDirectory?h(l):s?d:t.basename(d));if(u.isDirectory)return p.getEntryChildren(u).forEach(function(t){if(t.isDirectory)return;var r=t.getData();if(!r)throw e.Errors.CANT_EXTRACT_FILE();var i=h(s?t.entryName:t.entryName.substring(u.entryName.length)),o=m(n,i);f.assertPathSafe(n,o);const l=c?t.header.fileAttr:void 0;f.writeFileTo(o,r,a,l)}),!0;var y=u.getData(p.password);if(!y)throw e.Errors.CANT_EXTRACT_FILE();if(f.assertPathSafe(n,g),f.fs.existsSync(g)&&!a)throw e.Errors.CANT_OVERRIDE();const E=c?r.header.fileAttr:void 0;return f.writeFileTo(g,y,a,E),!0},test:function(e){if(!p)return!1;for(var t of p.entries)try{if(t.isDirectory)continue;if(!t.getData(e))return!1}catch(e){return!1}return!0},extractAllTo:function(t,r,n,s){if(n=i(!1,n),s=o(n,s),r=i(!1,r),!p)throw e.Errors.NO_ZIP();const a=[];p.entries.forEach(function(i){var o=m(t,h(i.entryName));if(f.assertPathSafe(t,o),i.isDirectory)return f.makeDir(o),void(n&&a.push({path:o,attr:i.header.fileAttr}));var c=i.getData(s);if(!c)throw e.Errors.CANT_EXTRACT_FILE();const l=n?i.header.fileAttr:void 0;f.writeFileTo(o,c,r,l);try{f.fs.utimesSync(o,i.header.time,i.header.time)}catch(e){}}),d(a)},extractAllToAsync:function(r,n,o,s){if(s=((...t)=>e.findLast(t,e=>"function"==typeof e))(n,o,s),o=i(!1,o),n=i(!1,n),!s)return new Promise((e,t)=>{this.extractAllToAsync(r,n,o,function(r){r?t(r):e(this)})});if(!p)return void s(e.Errors.NO_ZIP());r=t.resolve(r);const a=e=>m(r,t.normalize(h(e.entryName))),c=(e,t)=>new Error(e+': "'+t+'"'),l=[],u=[];p.entries.forEach(e=>{e.isDirectory?l.push(e):u.push(e)});const g=[];for(const e of l){const t=a(e),n=o?e.header.fileAttr:void 0;try{f.assertPathSafe(r,t),f.makeDir(t)}catch(e){s(c("Unable to create folder",t));continue}n&&g.push({path:t,attr:n});try{f.fs.utimesSync(t,e.header.time,e.header.time)}catch(e){}}u.reverse().reduce(function(i,s){return function(a){if(a)i(a);else{const a=t.normalize(h(s.entryName)),l=m(r,a);try{f.assertPathSafe(r,l)}catch(e){return i(e)}s.getDataAsync(function(t,r){if(r)i(r);else if(t){const e=o?s.header.fileAttr:void 0;f.writeFileToAsync(l,t,n,e,function(e){if(!e)return i(c("Unable to write file",l));f.fs.utimes(l,s.header.time,s.header.time,function(){i()})})}else i(e.Errors.CANT_EXTRACT_FILE())})}}},e=>{if(!e)try{d(g)}catch(e){return s(c("Unable to set folder permissions",e.path||""))}s(e)})()},writeZip:function(e,t){if(1===arguments.length&&"function"==typeof e&&(t=e,e=""),!e&&u.filename&&(e=u.filename),e){var r=p.compressToBuffer();if(r){var n=f.writeFileTo(e,r,!0);"function"==typeof t&&t(n?null:new Error("failed"),"")}}},writeZipPromise:function(e,t){const{overwrite:r,perm:n}=Object.assign({overwrite:!0},t);return new Promise((t,i)=>{!e&&u.filename&&(e=u.filename),e||i("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(o=>{f.writeFileToAsync(e,o,r,n,e=>e?t(e):i("ADM-ZIP: Wasn't able to write zip file"))},i)})},toBufferPromise:function(){return new Promise((e,t)=>{p.toAsyncBuffer(e,t)})},toBuffer:function(e,t,r,n){return"function"==typeof e?(p.toAsyncBuffer(e,t,r,n),null):p.compressToBuffer()}}},ur}(),yr=V(vr);const Er=[["B","kB","MB","GB","TB","PB","EB","ZB","YB"],["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"]],br=e=>{if(e>=1e-6&&e<1e21)return String(e);const[t,r]=e.toExponential().split("e"),n=t.replace(".",""),i=Number(r)+1,o=i>0,s=o?n.padEnd(i,"0"):"0".repeat(1-i)+n,a=s.slice(0,o?i:1),c=s.slice(o?i:1).replace(/0+$/,"");return c?`${a}.${c}`:a},wr=e=>{if("number"==typeof e)return Math.log10(e);const t=e.toString(10);return t.length+Math.log10(`0.${t.slice(0,15)}`)},Ir=(e,t)=>{if(void 0!==t&&("number"!=typeof t||!Number.isInteger(t)||t<0||t>100))throw new TypeError(`Expected ${e} to be an integer between 0 and 100, got ${typeof t}: ${t}`)};function Lr(e,t){if("bigint"!=typeof e&&!Number.isFinite(e))throw new TypeError(`Expected a finite number, got ${typeof e}: ${e}`);(e=>{if(void 0!==e&&("number"!=typeof e||!Number.isSafeInteger(e)||e<0))throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof e}: ${e}`)})((t={bits:!1,binary:!1,space:!0,nonBreakingSpace:!1,...t}).fixedWidth);const r=(e=>{const{minimumFractionDigits:t,maximumFractionDigits:r}=e;if(void 0!==t||void 0!==r){if(Ir("minimumFractionDigits",t),Ir("maximumFractionDigits",r),t>r)throw new RangeError(`Expected minimumFractionDigits (${t}) to not be greater than maximumFractionDigits (${r})`);return{...void 0!==t&&{minimumFractionDigits:t},...void 0!==r&&{maximumFractionDigits:r},roundingMode:"trunc"}}})(t),n=Er[(t.bits?2:0)+(t.binary?1:0)],i=t.space?t.nonBreakingSpace?" ":" ":"";Object.is(e,-0)&&(e=0);const o=((e,t)=>e<0?"-":t?0===e||0n===e?" ":"+":"")(e,t.signed);e<0&&(e=-e);const s=t.binary?1024:1e3;let a=0;var c;e>=1&&(a=Math.min(Math.floor(t.binary?("number"==typeof(c=e)?Math.log(c):wr(c)*Math.log(10))/Math.log(s):wr(e)/3),n.length-1));const l=((e,t,r)=>{const n=t**r;if("number"==typeof e||e<=Number.MAX_SAFE_INTEGER)return Number(e)/n;const i=BigInt(t)**BigInt(r),o=e%i;return Number(e/i)+Number(o)/n})(e,s,a);let u;if(Number.isFinite(l)){if((e=l)<1&&a>0&&(e*=s,a-=1),!r){const t=Math.max(3,Math.floor(e).toString().length);(e=Number(e.toPrecision(t)))>=s&&a<n.length-1&&(e/=s,a+=1)}u=((e,t,r)=>{if("string"==typeof t||Array.isArray(t)||!0===t){const n=!0===t?void 0:t;if(void 0!==r)return e.toLocaleString(n,r);const i=br(e),o=i.indexOf("."),s=-1===o?0:i.length-o-1;return s>100?i:e.toLocaleString(n,{maximumFractionDigits:s})}return void 0===r?br(e):e.toLocaleString("en-US",{...r,useGrouping:!1})})(e,t.locale,r)}else u=((e,t,r,n)=>{const i=BigInt(t)**BigInt(r),o=e/i;if(void 0===n)return o.toString();const s=n.minimumFractionDigits??0,a=Math.max(n.maximumFractionDigits??3,s),c=(e%i*10n**BigInt(a)/i).toString().padStart(a,"0").replace(/0+$/,"").padEnd(s,"0");return c?`${o}.${c}`:o.toString()})(e,s,a,r);return(o+u+i+n[a]).padStart(t.fixedWidth??0)}const Sr=e=>"string"==typeof e?Sr(E(e).size):i.yellowBright(Lr(e));class Cr{#re;get ora(){return this.#re}set attachConsole(e){e?(console.log=this.info.bind(this),console.info=this.info.bind(this)):console=Pr}static Global(e){return _r=new Cr(e),_r}static Clone(e){const{prefixText:t}=e||_r;return new Cr({prefixText:t})}static get Current(){return _r}static set Current(e){_r=e}constructor(e){this.#re=j(e)}get prefixText(){return this.#re.prefixText}info(...e){this.#re.info(Dr(e))}succeed(...e){this.#re.succeed(Dr(e))}start(...e){this.#re.start(Dr(e))}fail(...e){this.#re.fail(Dr(e))}warn(...e){this.#re.warn(Dr(e))}clear(){this.#re.clear()}stop(){this.#re.stop()}stopAndPersist(...e){this.#re.stopAndPersist(...e)}}let _r=new Cr;const Dr=e=>e.length?e.join(" "):void 0,Pr=console;class Nr{spinner;debugMode;constructor(e,t){this.spinner=new Cr({prefixText:e}),this.debugMode=t?.debug??!1}start(...e){this.spinner.start(...e)}succeed(...e){this.spinner.succeed(...e)}fail(...e){this.spinner.fail(...e)}error(...e){console.log(...e)}warn(...e){this.spinner.warn(...e)}info(...e){this.spinner.info(...e)}log(...e){this.spinner.info(...e)}debug(...e){this.debugMode&&console.debug(...e)}startNativeConsoleCapture(){this.spinner.attachConsole=!0}stopNativeConsoleCapture(){this.spinner.attachConsole=!1}}const Or=e=>{const t=e.mock??e.mockDiscovery,r={spa:{templateEnv:(n=e.template,i=e.mock,{portal:{id:"@equinor/fusion-framework-dev-portal"},title:"Fusion Dev Portal",serviceDiscovery:{url:"/@fusion-services",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},msal:{clientId:"9b707e3a-3e90-41ed-a47e-652a1e3b53d0",tenantId:"3aa4a235-b6e2-48d5-9195-7fcf05b459b0",redirectUri:"/authentication/login-callback",requiresAuth:"true",...i?{mock:"true",mockServerUrl:i}:{}},serviceWorker:{resources:[{url:"/apps-proxy",rewrite:"/@fusion-api/apps",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/@fusion-api/apps",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/help-proxy",rewrite:"/@fusion-api/help",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/portal-proxy",rewrite:"/@fusion-api/portal-config",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/@fusion-api/portal-config",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]}]},...n})},api:{serviceDiscoveryUrl:t?new URL("/@fusion-mock/discovery",t).href:"https://discovery.fusion.equinor.com/service-registry/environments/ci/services/",headers:{"X-Fusion-Mock":String(Boolean(t))},processServices:(e,t)=>{const{data:r,routes:n}=z(e,t);return{data:r.concat({key:"portals",name:"Portal Service - MOCK",uri:"/@fusion-api/portals"}),routes:n}}}};var n,i;return e.app&&((e,t,r)=>{const{build:n,appKey:i}=t;if(!n)throw new Error("App manifest does not contain build information");e.api.routes??=[],e.api.routes.push({match:[`/apps/bundles/apps/${i}/${n.version}/*path`,`/apps/bundles/apps/${i}@${n.version}/*path`],middleware:async(e,t,r)=>{const n=e.params?.path;!1===Array.isArray(n)&&r(),t.writeHead(302,{"content-type":"application/javascript",location:`/${n.join("/")}`}),t.end()}}),e.api.routes.push({match:`/apps/persons/me/apps/${i}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify({id:"dev-server-generated-id",...t}))}}),e.api.routes.push({match:`/apps/apps/${i}/builds/${n.version}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(r,e.app.manifest,e.app.config),e.portal&&((e,t,r)=>{e.api.routes??=[];const n="portal-config";e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify(t))}}),r&&e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(r,e.portal.manifest,e.portal.config),r},Ar=e=>({portal:"object"==typeof e.spa?.templateEnv?e.spa.templateEnv.portal:void 0,msal:"object"==typeof e.spa?.templateEnv?e.spa.templateEnv.msal:void 0,proxy:"object"==typeof e.spa?.templateEnv?e.spa.templateEnv.serviceWorker?.resources:void 0,serviceDiscoveryUrl:e.api.serviceDiscoveryUrl,routes:e.api.routes});const $r=async(e,t,r)=>{const{overrides:i,log:o}=r??{},s=t.mock?void 0:function(e,t){const r=e.root??process.cwd(),i=n(e.mode,t?a(r,t):r,"FUSION_SPA_MSAL_MOCK");if("true"===i.FUSION_SPA_MSAL_MOCK)return i.FUSION_SPA_MSAL_MOCK_SERVER_URL||"http://localhost:4010"}(e,"string"==typeof i?.envDir?i.envDir:void 0);s&&o?.info(`FUSION_SPA_MSAL_MOCK is enabled, using mock service discovery at ${s}`);const c=Or({...t,mockDiscovery:t.mockDiscovery??s});o?.debug("\nBase dev server config:",Ar(c)),o?.debug("\nCreating dev server with overrides:",i);let l,u=c;try{const t=await(async(e,t,r)=>L("dev-server.config",{baseDir:e.root,extensions:r?.extensions,script:{resolve:async r=>{let n;if("function"==typeof r.default){const i={...t};n=await r.default(e,{base:i})}else n=r.default;return ut(t,n??{})}}}))(e,c);u=t.config;const{path:r}=t;o?.debug(`\nLoaded dev server config from ${r}`),o?.debug("\nLoaded dev server config:",Ar(u)),l=((e,t)=>({name:"fusion:dev-server-config-watcher",configureServer(r){r.watcher.add(e),r.watcher.on("change",n=>{n===e&&(t?.info(`\n${e} changed, restarting dev server...`),r.restart())}),t?.debug(`Watching dev-server.config.ts at: ${e}`)}}))(r,o)}catch(e){o?.warn("\nFailed to load dev server config:",e instanceof Error?e.message:String(e))}const f=t.mock??t.mockDiscovery??s;if(f&&new URL(u.api.serviceDiscoveryUrl).origin!==new URL(f).origin)throw new Error(`Mock mode is enabled (${f}), but service discovery points at ${u.api.serviceDiscoveryUrl}. Remove the api.serviceDiscoveryUrl override from dev-server.config, or run without mock auth.`);const d=l?{...i,plugins:[...i?.plugins??[],l]}:i;return H(u,d)},Rr="fusion-framework-cli",Tr={"X-Fusion-CLI-Name":Rr,"X-Fusion-CLI-Version":vt,"User-Agent":`${Rr}/${vt}`},xr=e=>{const t=new Headers(e.headers);for(const[e,r]of Object.entries(Tr))t.has(e)||t.set(e,r);return{...e,headers:t}},kr={AUTH_DOCS_URL:"https://github.com/equinor/fusion-framework/blob/main/packages/cli/docs/auth.md",APP_DOCS_URL:"https://github.com/equinor/fusion-framework/blob/main/packages/cli/docs/application.md"};function Fr(){if(process.env.FUSION_TOKEN)return[i.bold("ðŸ’Ą FUSION_TOKEN detected"),i.dim(" The CLI is using this token instead of your interactive login session."),i.dim(" If this is unintended, unset the variable and retry, or verify that the token has the correct scope/audience.")].join("\n")}const{AUTH_DOCS_URL:Ur,APP_DOCS_URL:Br}=kr;function Mr(e,t){switch(e){case 401:return function(e){const t=["",i.redBright(`ðŸšŦ Authentication failed: unable to ${e}`),""," No valid token was provided or the token has expired.",""],r=Fr();return r&&t.push(r,""),t.push(i.whiteBright(" Troubleshooting:"),"",` ${i.cyan("1.")} For CI/CD, verify that ${i.bold("FUSION_TOKEN")} is set and the token has not expired.`,` ${i.cyan("2.")} For local development, run ${i.greenBright.bold("ffc auth login")} to refresh your credentials.`,` ${i.cyan("3.")} Verify that ${i.bold("--scope")} targets the correct API audience for your environment.`,"",` ${i.dim("Auth docs:")} ${i.blueBright.underline(Ur)}`,` ${i.dim("Publish docs:")} ${i.blueBright.underline(Br)}`,""),t.join("\n")}(t);case 403:return function(e){const t=["",i.redBright(`ðŸšŦ Authorization failed: not permitted to ${e}`),"","⚠ïļ Your token is valid but does not have the required permissions for this operation.",""],r=Fr();return r&&t.push(r,""),t.push(i.whiteBright(" Troubleshooting:"),"",` ${i.cyan("1.")} Verify that your user or service principal has publish permissions for this application.`,` ${i.cyan("2.")} Check that the token's ${i.bold("scope / audience")} matches the target environment.`,` ${i.cyan("3.")} Confirm that the application is registered and your account has the correct role assignment.`,"",` ${i.dim("Auth docs:")} ${i.blueBright.underline(Ur)}`,` ${i.dim("Publish docs:")} ${i.blueBright.underline(Br)}`,""),t.join("\n")}(t);default:return}}const{AUTH_DOCS_URL:Gr,APP_DOCS_URL:jr}=kr;function zr(e,t){if(!(e instanceof Error))return;const r="SilentTokenAcquisitionError"===e.name,n=e,o=n.response?n.response.status:void 0,s=401===o||403===o;let a=!1,c=e.cause;for(let e=0;e<5&&c&&c instanceof Error;e++){if("SilentTokenAcquisitionError"===c.name){a=!0;break}c=c.cause}if(!r&&!s&&!a)return;if(s&&!r&&!a)return Mr(o,t);const l=function(e){let t=e;for(let e=0;e<5&&t;e++){if(!(t instanceof Error)){if("object"==typeof t&&"errorMessage"in t){const e=t.errorMessage;if("string"==typeof e){const t=e.match(/Description:\s*(.+?)(?:\s*Trace ID:|$)/);return t?.[1]?.trim()??e.split(" - ")[0]?.trim()}break}break}{const e=t;if("string"==typeof e.errorMessage){const t=e.errorMessage,r=t.match(/Description:\s*(.+?)(?:\s*Trace ID:|$)/);return r?.[1]?.trim()??t.split(" - ")[0]?.trim()}t=t.cause}}}(e),u=["",i.redBright(`🔑 Token acquisition failed: unable to ${t}`),"",i.yellow(`⚠ïļ ${l??"The CLI could not silently acquire an access token for this operation."}`),""],f=Fr();return f&&u.push(f,""),u.push(i.whiteBright(" Troubleshooting:"),"",` ${i.cyan("1.")} Run ${i.greenBright.bold("ffc auth login")} to refresh your local credentials.`,` ${i.cyan("2.")} For CI/CD, set a fresh ${i.bold("FUSION_TOKEN")} — cached refresh tokens may have expired.`,` ${i.cyan("3.")} Verify that ${i.bold("--scope")} targets the correct API audience for your environment.`,"",` ${i.dim("Auth docs:")} ${i.blueBright.underline(Gr)}`,` ${i.dim("Publish docs:")} ${i.blueBright.underline(jr)}`,""),u.join("\n")}const Hr=(e,t,r)=>{const n=s(String(e));b(n)||w(n,{recursive:!0}),I(e,t,r)},qr=["package.json","LICENSE.md","README.md","CHANGELOG.md"],Vr=async(e,t)=>{const{archive:r,log:n}=t??{},o=s(e.path),c=t?.buildDir??"dist",l=a(o,c);if(!(await M(l)).isDirectory())throw new Error(`Build directory ${c} does not exist`);n?.log(i.bold("Starting to pack bundle"));const u=new yr;if(u.addLocalFolder(l,c),t?.content)for(const[e,r]of Object.entries(t.content))u.addFile(e,Buffer.from(r)),n?.info("📄",St(e,{relative:!0}));n?.info("📂",St(l,{relative:!0}));for(const t of qr.concat(e.packageJson.files??[])){const e=a(o,t),r=s(e.replace(o,""));at(e)?(u.addLocalFile(e,r),n?.info("📄",St(e,{relative:!0}))):n?.warn(i.dim("📄",St(e,{relative:!0})))}return r&&(at(s(r))||await G(s(r),{recursive:!0}),n?.start("compressing content"),await u.writeZipPromise(r),n?.succeed("📚",St(r,{relative:!0}),Sr(r))),u},Wr=async e=>{const{log:t,manifest:r,snapshot:n}=e;process.env.NODE_ENV,process.cwd();const{pkg:i,manifest:o}=await Pt({log:t,manifest:r,snapshot:n});if(!o.build)throw new Error("Manifest build config not found");return{archive:await Vr(i,{log:t,archive:e?.archive,content:{"app-manifest.json":JSON.stringify(o.build,null,2),"metadata.json":JSON.stringify({appKey:o.appKey,name:o.appKey,version:o.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:o}},Zr=async(e,t)=>{const{log:r}=t;try{r?.start("create application configuration"),r?.info(`generating config with ${i.red.dim(e.command)} command in ${i.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`app.config.${e.environment}`,"app.config"];return L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{environment:{}};if("function"==typeof r.default){const t=await r.default(e,{base:n})??n;return Lt.parse(t??n)}return Lt.parse(r.default??n)}}})})(e,{file:t?.config});return r?.succeed("⚙ïļ generated config from ",St(n.path,{relative:!0})),n.config}catch(e){if(e instanceof S){if(!t.config)return r?.succeed(i.dim("⚙ïļ no local application config applied, using built-in")),{environment:{},endpoints:{}};r?.warn(`failed to load config file ${St(t.config)}, please check the path.`)}throw r?.fail("failed to resolve application config"),r?.debug(e),e}},Kr=async e=>{const{log:t}=e??{};let r;try{t?.start("resolve project package"),r=await _t(null),t?.succeed("ðŸ“Ķ",i.yellowBright([r.packageJson.name,r.packageJson.version].join("@"))),t?.info("🏠",i.blueBright(r.root))}catch{t?.info("Failed to resolve project package, using current directory as root")}const n=r?.root??process.cwd(),o={command:"build",mode:process.env.NODE_ENV??"production",root:n,...e?.env},s=await Zr(o,{log:t,config:e?.config});if(t?.debug("config:",s),e?.output){t?.start("writing config to file");try{await Hr(e.output,JSON.stringify(s,null,2)),t?.succeed("config written successfully",St(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:s,pkg:r}};class Yr extends Error{response;static Name="HttpResponseError";constructor(e,t,r){super(e,r),this.response=t}}class Xr extends Yr{static Name="HttpJsonResponseError";data;constructor(e,t,r){super(e,t,r),this.name=Xr.Name,this.data=r?.data}}class Jr extends Yr{static Name="ServerSentEventResponseError";constructor(e,t,r){super(e,t,r),this.name=Jr.Name}}class Qr extends Error{}const en=async e=>{const{log:t,config:r,appKey:n,buildVersion:i,framework:o}=e;try{const e=await o.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",St(e.uri))}),t?.start("Publishing application config");const s=await e.json(`/apps/${n}/builds/${i}/config`,{method:"PUT",body:r,headers:Tr});t?.debug("Response:",s),t?.succeed("Published application config")}catch(e){if(e instanceof Xr)switch(e.response.status){case 410:t?.fail("ðŸĪŽ",`App ${n} is deleted from apps-service. Please check the app key and try again.`);break;case 404:t?.fail("ðŸĪŽ",`App ${n} not found. Please check the app key and try again.`);break;case 403:case 401:{const r=Mr(e.response.status,`publish config for ${n}`);t?.fail("🔒","Authentication/authorization error publishing app config."),r&&t?.error(r),process.exit(1);break}default:t?.fail("ðŸĪŽ","Failed to publish application config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}const r=zr(e,`publish config for ${n}`);r&&(t?.fail("🔒",`Token acquisition failed publishing config for ${n}`),t?.error(r),process.exit(1)),t?.fail("ðŸĪŽ","Failed to publish app config:",e instanceof Error?e.message:String(e)),process.exit(1)}},tn=async e=>{const{log:r}=e??{},n="@equinor/fusion-framework-dev-portal",i=await _t(r),o={root:i.root,environment:"local",...e?.env,mode:"development",command:"serve"},a=await Ct(o,i,{log:r,manifestPath:e?.manifest}),c=await Zr(o,{log:r,config:e?.config});let l,u;const d=p(import.meta.resolve(n));at(d)?(l=d,u=await f({cwd:d}).then(e=>e?s(e?.path):void 0)):r?.info(`Portal ${n} is external, skipping entry point resolution`);const h=await ft(o,i),m=u?[i.root,u]:[i.root];r?.debug(`File system access allowed for: \n${m.join("\n")}\n`);const g=t(h,{server:{port:e?.port||3e3,host:e?.host||h.server?.host||"localhost",fs:{allow:m}}}),v={template:{portal:{id:n}},app:{manifest:a,config:c},mock:e?.mock};l&&(v.portal={manifest:{name:n,build:{templateEntry:l,assetPath:"/@fs"}},config:{}}),r?.debug("vite config:",g),r?.debug("dev server config:",v),r?.start("Starting app development server...");const y=await $r(o,v,{overrides:g,log:r});await y.listen(),r?.succeed("App development server started successfully");const E=y.config.server.https?"https":"http",b=y.config.server.host||"localhost",w=y.config.server.port||5173;return r?.info(`App development server is running at: ${E}://${b}:${w}/apps/${a.appKey}`),y},rn=async e=>{const{log:r,dir:n,port:i=4173,host:o="localhost"}=e??{};r?.log("Starting to serve application");const c="@equinor/fusion-framework-dev-portal",l=await _t(r);r?.start("Loading Vite config...");const u=await ft({root:l.root,command:"build",mode:"production"},l);r?.succeed("Vite config loaded");const d=n||(u.build?.outDir||"dist"),h=a(l.root,d),m={root:l.root,environment:"local",mode:"production",command:"serve",isPreview:!0},g=await Ct(m,l,{log:r,manifestPath:e?.manifest}),v=await Zr(m,{log:r,config:e?.config});if(r?.debug("Output directory:",h),!b(h))throw new Error(`Build directory does not exist: ${h}\nPlease build the application first using \`ffc app build\``);let y,E;const w=p(import.meta.resolve(c));at(w)?(y=w,E=await f({cwd:w}).then(e=>e?s(e?.path):void 0)):r?.info(`Portal ${c} is external, skipping entry point resolution`);const I=await ft(m,l),L=E?[l.root,E,h]:[l.root,h];r?.debug(`File system access allowed for: \n${L.join("\n")}\n`);const S=t(I,{server:{port:i,host:o||I.server?.host||"localhost",fs:{allow:L}}}),C={template:{portal:{id:c}},app:{manifest:g,config:v},mock:e?.mock};y&&(C.portal={manifest:{name:c,build:{templateEntry:y,assetPath:"/@fs"}},config:{}}),r?.debug("vite config:",S),r?.debug("dev server config:",C),r?.start("Starting preview server with dev-portal...");try{const e=await $r(m,C,{overrides:S,log:r});await e.listen(),r?.succeed("Preview server started successfully");const t=e.config.server?.https?"https":"http",n=e.config.server?.host||o,s=e.config.server?.port||i;return r?.info(`Preview server is running at: ${t}://${n}:${s}`),g.appKey&&r?.info(`App URL: ${t}://${n}:${s}/apps/${g.appKey}`),e}catch(e){throw r?.fail("Failed to start preview server"),e}};class nn extends A{satisfies(e){return $(this,e)}}const on=Symbol("fusion.telemetry-export-request");var sn=function(e,t){return sn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},sn(e,t)};function an(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}sn(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var cn=function(){return cn=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},cn.apply(this,arguments)};function ln(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})}function un(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function fn(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function dn(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function pn(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function hn(e){return this instanceof hn?(this.v=e,this):new hn(e)}function mn(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){o.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=i[e](t)).value instanceof hn?Promise.resolve(r.value.v).then(c,l):u(o[0][2],r)}catch(e){u(o[0][3],e)}var r}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function gn(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=fn(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}}function vn(e){return"function"==typeof e}function yn(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var En=yn(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function bn(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var wn=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=fn(o),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(vn(c))try{c()}catch(e){i=e instanceof En?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=fn(l),f=u.next();!f.done;f=u.next()){var d=f.value;try{Sn(d)}catch(e){i=null!=i?i:[],e instanceof En?i=pn(pn([],dn(i)),dn(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}}if(i)throw new En(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Sn(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&bn(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&bn(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),In=wn.EMPTY;function Ln(e){return e instanceof wn||e&&"closed"in e&&vn(e.remove)&&vn(e.add)&&vn(e.unsubscribe)}function Sn(e){vn(e)?e():e.unsubscribe()}var Cn={Promise:void 0},_n=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,pn([e,t],dn(r)))};function Dn(e){_n(function(){throw e})}function Pn(){}function Nn(e){e()}var On=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Ln(t)&&t.add(r)):r.destination=Tn,r}return an(t,e),t.create=function(e,t,r){return new $n(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(wn),An=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Rn(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Rn(e)}else Rn(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Rn(e)}},e}(),$n=function(e){function t(t,r,n){var i,o=e.call(this)||this;return i=vn(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,o.destination=new An(i),o}return an(t,e),t}(On);function Rn(e){Dn(e)}var Tn={closed:!0,next:Pn,error:function(e){throw e},complete:Pn},xn="function"==typeof Symbol&&Symbol.observable||"@@observable";function kn(e){return e}var Fn=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,i=this,o=(n=e)&&n instanceof On||function(e){return e&&vn(e.next)&&vn(e.error)&&vn(e.complete)}(n)&&Ln(n)?e:new $n(e,t,r);return Nn(function(){var e=i,t=e.operator,r=e.source;o.add(t?t.call(o,r):r?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Un(t))(function(t,n){var i=new $n({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});r.subscribe(i)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[xn]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?kn:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Un(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function Un(e){var t;return null!==(t=null!=e?e:Cn.Promise)&&void 0!==t?t:Promise}function Bn(e){return function(t){if(function(e){return vn(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function Mn(e,t,r,n,i){return new Gn(e,t,r,n,i)}var Gn=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return an(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(On),jn=yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),zn=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return an(t,e),t.prototype.lift=function(e){var t=new Hn(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new jn},t.prototype.next=function(e){var t=this;Nn(function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=fn(t.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(e)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}})},t.prototype.error=function(e){var t=this;Nn(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}})},t.prototype.complete=function(){var e=this;Nn(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?In:(this.currentObservers=null,o.push(e),new wn(function(){t.currentObservers=null,bn(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new Fn;return e.source=this,e},t.create=function(e,t){return new Hn(e,t)},t}(Fn),Hn=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return an(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:In},t}(zn),qn=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return an(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(zn),Vn={now:function(){return(Vn.delegate||Date).now()},delegate:void 0},Wn=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Vn);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return an(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),a=0,c=1;c<n.length&&n[c]<=s;c+=2)a=c;a&&n.splice(0,a+1)}},t}(zn),Zn=function(e){function t(t,r){return e.call(this)||this}return an(t,e),t.prototype.schedule=function(e,t){return this},t}(wn),Kn=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,pn([e,t],dn(r)))},Yn=function(e){return clearInterval(e)},Xn=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return an(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),Kn(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&Yn(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,bn(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Zn),Jn=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Vn.now,e}(),Qn=function(e){function t(t,r){void 0===r&&(r=Jn.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return an(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(Jn),ei=new Qn(Xn),ti=ei,ri=new Fn(function(e){return e.complete()});function ni(e){return e&&vn(e.schedule)}function ii(e){return e[e.length-1]}var oi=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function si(e){return vn(null==e?void 0:e.then)}function ai(e){return vn(e[xn])}function ci(e){return Symbol.asyncIterator&&vn(null==e?void 0:e[Symbol.asyncIterator])}function li(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var ui="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function fi(e){return vn(null==e?void 0:e[ui])}function di(e){return mn(this,arguments,function(){var t,r,n;return un(this,function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,hn(t.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,hn(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,hn(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function pi(e){return vn(null==e?void 0:e.getReader)}function hi(e){if(e instanceof Fn)return e;if(null!=e){if(ai(e))return i=e,new Fn(function(e){var t=i[xn]();if(vn(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(oi(e))return n=e,new Fn(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()});if(si(e))return r=e,new Fn(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Dn)});if(ci(e))return mi(e);if(fi(e))return t=e,new Fn(function(e){var r,n;try{for(var i=fn(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()});if(pi(e))return mi(di(e))}var t,r,n,i;throw li(e)}function mi(e){return new Fn(function(t){(function(e,t){var r,n,i,o;return ln(this,void 0,void 0,function(){var s,a;return un(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=gn(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(s=n.value,t.next(s),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function gi(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function vi(e,t){return void 0===t&&(t=0),Bn(function(r,n){r.subscribe(Mn(n,function(r){return gi(n,e,function(){return n.next(r)},t)},function(){return gi(n,e,function(){return n.complete()},t)},function(r){return gi(n,e,function(){return n.error(r)},t)}))})}function yi(e,t){return void 0===t&&(t=0),Bn(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function Ei(e,t){if(!e)throw new Error("Iterable cannot be null");return new Fn(function(r){gi(r,t,function(){var n=e[Symbol.asyncIterator]();gi(r,t,function(){n.next().then(function(e){e.done?r.complete():r.next(e.value)})},0,!0)})})}function bi(e,t){if(null!=e){if(ai(e))return function(e,t){return hi(e).pipe(yi(t),vi(t))}(e,t);if(oi(e))return function(e,t){return new Fn(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}(e,t);if(si(e))return function(e,t){return hi(e).pipe(yi(t),vi(t))}(e,t);if(ci(e))return Ei(e,t);if(fi(e))return function(e,t){return new Fn(function(r){var n;return gi(r,t,function(){n=e[ui](),gi(r,t,function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)},0,!0)}),function(){return vn(null==n?void 0:n.return)&&n.return()}})}(e,t);if(pi(e))return function(e,t){return Ei(di(e),t)}(e,t)}throw li(e)}function wi(e,t){return t?bi(e,t):hi(e)}function Ii(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ni(ii(e))?e.pop():void 0}(e);return wi(e,r)}var Li=yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Si(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o,s=!1;e.subscribe({next:function(e){o=e,s=!0},error:i,complete:function(){s?n(o):r?n(t.defaultValue):i(new Li)}})})}function Ci(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o=new $n({next:function(e){n(e),o.unsubscribe()},error:i,complete:function(){r?n(t.defaultValue):i(new Li)}});e.subscribe(o)})}function _i(e){return e instanceof Date&&!isNaN(e)}var Di=yn(function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function Pi(e){throw new Di(e)}function Ni(e,t){return Bn(function(r,n){var i=0;r.subscribe(Mn(n,function(r){n.next(e.call(t,r,i++))}))})}var Oi=Array.isArray;function Ai(e){return Ni(function(t){return function(e,t){return Oi(t)?e.apply(void 0,pn([],dn(t))):e(t)}(e,t)})}function $i(e,t,r,n,i,o,s,a){var c=[],l=0,u=0,f=!1,d=function(){!f||c.length||l||t.complete()},p=function(e){return l<n?h(e):c.push(e)},h=function(e){o&&t.next(e),l++;var a=!1;hi(r(e,u++)).subscribe(Mn(t,function(e){null==i||i(e),o?p(e):t.next(e)},function(){a=!0},void 0,function(){if(a)try{l--;for(var e=function(){var e=c.shift();s||h(e)};c.length&&l<n;)e();d()}catch(e){t.error(e)}}))};return e.subscribe(Mn(t,p,function(){f=!0,d()})),function(){null==a||a()}}function Ri(e,t,r){return void 0===r&&(r=1/0),vn(t)?Ri(function(r,n){return Ni(function(e,i){return t(r,e,n,i)})(hi(e(r,n)))},r):("number"==typeof t&&(r=t),Bn(function(t,n){return $i(t,n,e,r)}))}var Ti=["addListener","removeListener"],xi=["addEventListener","removeEventListener"],ki=["on","off"];function Fi(e,t,r,n){if(vn(r)&&(n=r,r=void 0),n)return Fi(e,t,r).pipe(Ai(n));var i=dn(function(e){return vn(e.addEventListener)&&vn(e.removeEventListener)}(e)?xi.map(function(n){return function(i){return e[n](t,i,r)}}):function(e){return vn(e.addListener)&&vn(e.removeListener)}(e)?Ti.map(Ui(e,t)):function(e){return vn(e.on)&&vn(e.off)}(e)?ki.map(Ui(e,t)):[],2),o=i[0],s=i[1];if(!o&&oi(e))return Ri(function(e){return Fi(e,t,r)})(hi(e));if(!o)throw new TypeError("Invalid event target");return new Fn(function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.next(1<t.length?t:t[0])};return o(t),function(){return s(t)}})}function Ui(e,t){return function(r){return function(n){return e[r](t,n)}}}function Bi(e,t,r){void 0===e&&(e=0),void 0===r&&(r=ti);var n=-1;return null!=t&&(ni(t)?r=t:n=t),new Fn(function(t){var i=_i(e)?+e-r.now():e;i<0&&(i=0);var o=0;return r.schedule(function(){t.closed||(t.next(o++),0<=n?this.schedule(void 0,n):t.complete())},i)})}function Mi(e,t){return Bn(function(r,n){var i=0;r.subscribe(Mn(n,function(r){return e.call(t,r,i++)&&n.next(r)}))})}function Gi(e){return Bn(function(t,r){var n,i=null,o=!1;i=t.subscribe(Mn(r,void 0,void 0,function(s){n=hi(e(s,Gi(e)(t))),i?(i.unsubscribe(),i=null,n.subscribe(r)):o=!0})),o&&(i.unsubscribe(),i=null,n.subscribe(r))})}function ji(e,t,r,n,i){return function(o,s){var a=r,c=t,l=0;o.subscribe(Mn(s,function(t){var r=l++;c=a?e(c,t,r):(a=!0,t),n&&s.next(c)},i&&function(){a&&s.next(c),s.complete()}))}}function zi(e,t){return Bn(ji(e,t,arguments.length>=2,!1,!0))}function Hi(e){return Bn(function(t,r){var n=!1;t.subscribe(Mn(r,function(e){n=!0,r.next(e)},function(){n||r.next(e),r.complete()}))})}function qi(e,t){return void 0===t&&(t=kn),e=null!=e?e:Vi,Bn(function(r,n){var i,o=!0;r.subscribe(Mn(n,function(r){var s=t(r);!o&&e(i,s)||(o=!1,i=s,n.next(r))}))})}function Vi(e,t){return e===t}function Wi(e){return void 0===e&&(e=Zi),Bn(function(t,r){var n=!1;t.subscribe(Mn(r,function(e){n=!0,r.next(e)},function(){return n?r.complete():r.error(e())}))})}function Zi(){return new Li}function Ki(e){return Bn(function(t,r){try{t.subscribe(r)}finally{r.add(e)}})}function Yi(e,t){var r=arguments.length>=2;return function(e){return e.pipe(kn,(n=1)<=0?function(){return ri}:Bn(function(e,t){var r=[];e.subscribe(Mn(t,function(e){r.push(e),n<r.length&&r.shift()},function(){var e,n;try{for(var i=fn(r),o=i.next();!o.done;o=i.next()){var s=o.value;t.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}t.complete()},void 0,function(){r=null}))}),r?Hi(t):Wi(function(){return new Li}));var n}}function Xi(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var i=new $n({next:function(){i.unsubscribe(),e()}});return hi(t.apply(void 0,pn([],dn(r)))).subscribe(i)}}else e()}function Ji(e,t){return Bn(function(r,n){var i=null,o=0,s=!1,a=function(){return s&&!i&&n.complete()};r.subscribe(Mn(n,function(r){null==i||i.unsubscribe();var s=0,c=o++;hi(e(r,c)).subscribe(i=Mn(n,function(e){return n.next(t?t(r,e,c,s++):e)},function(){i=null,a()}))},function(){s=!0,a()}))})}function Qi(e){return Bn(function(t,r){hi(e).subscribe(Mn(r,function(){return r.complete()},Pn)),!r.closed&&t.subscribe(r)})}function eo(e,t,r){var n=vn(e)||t||r?{next:e,error:t,complete:r}:e;return n?Bn(function(e,t){var r;null===(r=n.subscribe)||void 0===r||r.call(n);var i=!0;e.subscribe(Mn(t,function(e){var r;null===(r=n.next)||void 0===r||r.call(n,e),t.next(e)},function(){var e;i=!1,null===(e=n.complete)||void 0===e||e.call(n),t.complete()},function(e){var r;i=!1,null===(r=n.error)||void 0===r||r.call(n,e),t.error(e)},function(){var e,t;i&&(null===(e=n.unsubscribe)||void 0===e||e.call(n)),null===(t=n.finalize)||void 0===t||t.call(n)}))}):kn}function to(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r,n=vn(ii(r=e))?r.pop():void 0;return Bn(function(t,r){for(var i=e.length,o=new Array(i),s=e.map(function(){return!1}),a=!1,c=function(t){hi(e[t]).subscribe(Mn(r,function(e){o[t]=e,a||s[t]||(s[t]=!0,(a=s.every(kn))&&(s=null))},Pn))},l=0;l<i;l++)c(l);t.subscribe(Mn(r,function(e){if(a){var t=pn([e],dn(o));r.next(n?n.apply(void 0,pn([],dn(t))):t)}}))})}const ro=(e,t,r)=>{const n="string"==typeof t?t.split("."):t,i=n.shift();return i&&(e[i]??={},n.length?ro(e[i],n,r):Object.assign(e,{[i]:r})),e};class no{#ne={};createConfig(e,t){return wi(this._createConfig(e,t))}async createConfigAsync(e,t){return Si(this.createConfig(e,t))}_set(e,t){const r="function"==typeof t?t:async()=>t;this.#ne[e]=r}_get(e){return this.#ne[e]}_has(e){return e in this.#ne}_createConfig(e,t){return wi(this._buildConfig(e,t)).pipe(Ji(t=>this._processConfig(t,e)))}_buildConfig(e,t){return wi(Object.entries(this.#ne)).pipe(Ri(([t,r])=>wi(r(e)).pipe(Mi(e=>void 0!==e),Ni(e=>({target:t,value:e})),Gi(e=>(console.error(`Failed to execute config callback: ${r.name} for attribute: '${t}'`,e),ri)))),zi((e,{target:t,value:r})=>ro(e,t,r),t??{}))}_processConfig(e,t){return Ii(e)}}class io extends Error{constructor(){super("Module initialization timed out"),this.name="RequiredModuleTimeoutError"}}const oo="ModuleConfigurator",so={ModuleConfigAdded:`${oo}.module.configAdded`,PreparedConfigReplaced:`${oo}.module.preparedConfigReplaced`,OnConfiguredAdded:`${oo}.onConfigured.added`,OnInitializedAdded:`${oo}.onInitialized.added`,PluginAdded:`${oo}.plugin.added`,InitializeConfigLoaded:`${oo}.config.loaded`,InitializeInstanceInitialized:`${oo}.instance.initialized`,Initialize:`${oo}.initialize.complete`,HostInitializeStarted:`${oo}.host.initializeStarted`,HostInitialized:`${oo}.host.initialized`,HostInitializeError:`${oo}.host.initializeError`,ConfiguratorCreated:`${oo}.configurator.created`,ConfiguratorPrepared:`${oo}.configurator.prepared`,ConfiguratorPrepareError:`${oo}.configurator.prepareError`,ConfiguratorFailed:`${oo}.configurator.failed`,ModulePostConfigured:`${oo}.module.postConfigured`,ModulePostConfigureError:`${oo}.module.postConfigureError`,PostConfigureHooks:`${oo}.postConfigureHooks.started`,PostConfigureHooksComplete:`${oo}.postConfigureHooks.complete`,PostConfigureHooksError:`${oo}.postConfigureHooks.error`,ModuleInitializeError:`${oo}.module.initializeError`,ModuleInitializing:`${oo}.module.initializing`,ProviderNotBaseModuleProvider:`${oo}.provider.invalidBase`,ProviderVersionWarning:`${oo}.provider.versionMissing`,ModuleInitialized:`${oo}.module.initialized`,RequireInstanceModuleNotDefined:`${oo}.requireInstance.moduleNotDefined`,RequireInstanceModuleAlreadyInitialized:`${oo}.requireInstance.moduleAlreadyInitialized`,RequireInstanceAwaitingModule:`${oo}.requireInstance.awaitingModule`,RequireInstanceTimeout:`${oo}.requireInstance.timeout`,RequireInstanceModuleResolved:`${oo}.requireInstance.moduleResolved`,ModuleInitializeComplete:`${oo}.modules.initializeComplete`,InitializeComplete:`${oo}.initialize.instanceComplete`,ConfiguratorPostInitializeStart:`${oo}.postInitialize.started`,ModulePostInitializeStart:`${oo}.modulePostInitialize.started`,ModulePostInitializeComplete:`${oo}.modulePostInitialize.complete`,ModulePostInitializeError:`${oo}.modulePostInitialize.error`,PostInitializeComplete:`${oo}.postInitialize.complete`,PostInitializeCompleteNoHooks:`${oo}.postInitialize.noHooks`,PostInitializeHooks:`${oo}.postInitializeHooks.started`,PostInitializeHooksComplete:`${oo}.postInitializeHooks.complete`,PostInitializeHooksError:`${oo}.postInitializeHooks.error`,PluginsRegister:`${oo}.plugins.registering`,PluginRegistered:`${oo}.plugin.registered`,PluginRegisterError:`${oo}.plugin.registerError`,PluginsRegistered:`${oo}.plugins.registered`,Dispose:`${oo}.dispose.started`,PluginsDisposing:`${oo}.plugins.disposing`,PluginDisposed:`${oo}.plugin.disposed`,PluginDisposeError:`${oo}.plugin.disposeError`,ModulesDispose:`${oo}.modules.disposing`,ModuleDisposed:`${oo}.module.disposed`,ModuleDisposeError:`${oo}.module.disposeError`,ModulesDisposed:`${oo}.modules.disposed`};var ao;async function co(e,t){const r=await async function(e,t){const{modules:r,afterConfiguration:n,afterInit:i,registerEvent:o}=e;return Si(wi(r).pipe(Ri(async r=>{const n=performance.now();try{const i=e.configurators?.has(r)?e.configurators.get(r):await(r.configure?.(t)),s=Math.round(performance.now()-n);return o({level:ao.Debug,name:so.ConfiguratorCreated,message:`Configurator created for ${r.name} in ${s}ms`,properties:{moduleName:r.name,moduleVersion:r.version?.toString()||"unknown",configLoadTime:s},metric:s}),{[r.name]:i}}catch(e){throw o({level:ao.Error,name:so.ConfiguratorFailed,message:`Failed to create configurator for ${r.name}`,properties:{moduleName:r.name,moduleVersion:r.version?.toString()||"unknown"},metric:Math.round(performance.now()-n),error:e}),e}}),zi((e,t)=>Object.assign(e,t),{onAfterConfiguration(e){n.push(e)},onAfterInit(e){i.push(e)}})))}(e,t);return await Promise.all(e.configs.map(e=>Promise.resolve(e(r,t)))),await async function(e,t){const{modules:r,afterConfiguration:n,registerEvent:i}=e;if(await Promise.allSettled(r.filter(e=>!!e.postConfigure).map(async e=>{try{const r=performance.now();await(e.postConfigure?.(t)),i({level:ao.Debug,name:so.ModulePostConfigured,message:`Module ${e.name} post-configured successfully`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown",postConfigTime:Math.round(performance.now()-r)}})}catch(t){i({level:ao.Warning,name:so.ModulePostConfigureError,message:`Module ${e.name} post-configure failed`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t})}})),n.length)try{i({level:ao.Debug,name:so.PostConfigureHooks,message:`Post configure hooks [${n.length}] called`});const e=performance.now();await Promise.allSettled(n.map(e=>Promise.resolve(e(t))));const r=Math.round(performance.now()-e);i({level:ao.Debug,name:so.PostConfigureHooksComplete,message:"Post configure hooks complete",properties:{count:n.length,postConfigHooksTime:r},metric:r})}catch(e){i({level:ao.Warning,name:so.PostConfigureHooksError,message:"Post configure hook failed",error:e})}}(e,r),r}function lo(e,t){if(null!==e&&("object"==typeof e||"function"==typeof e)&&"then"in e&&"function"==typeof e.then)throw Promise.resolve(e).catch(()=>console.warn(`Asynchronous preparation failed for module "${t}"`)),new TypeError(`Preparation for module "${t}" must be synchronous`)}!function(e){e[e.Debug=0]="Debug",e[e.Information=1]="Information",e[e.Warning=2]="Warning",e[e.Error=3]="Error",e[e.Critical=4]="Critical"}(ao||(ao={}));class uo{static[Symbol.hasInstance](e){if(null!==e&&"object"==typeof e&&"version"in e&&"dispose"in e){const t=e,r=O(String(t.version)),n=t.dispose;return!!r&&"function"==typeof n}return!1}#ie;#oe;get version(){return this.#ie}constructor(e){const{version:t}=e;this.#ie=new nn(t),this.#oe=new wn}_addTeardown(e){return this.#oe.add(e),()=>this.#oe.remove(e)}dispose(){this.#oe.unsubscribe()}}function fo(e,t,r){return function(n,i=60){if(!e.includes(n)){const e=new Error(`Cannot require [${String(n)}] since module is not defined!`);throw e.name="ModuleNotDefinedError",r({level:ao.Error,name:so.RequireInstanceModuleNotDefined,message:e.message,properties:{moduleName:String(n),wait:i},error:e}),e}if(t.value[n])return r({level:ao.Debug,name:so.RequireInstanceModuleAlreadyInitialized,message:`Module [${String(n)}] is already initialized, skipping queue`,properties:{moduleName:String(n),wait:i}}),Promise.resolve(t.value[n]);const o=performance.now();return r({level:ao.Debug,name:so.RequireInstanceAwaitingModule,message:`Awaiting module [${String(n)}] initialization, timeout ${i}s`,properties:{moduleName:String(n),wait:i}}),Ci(t.pipe(Mi(e=>!!e[n]),Ni(e=>e[n]),function(e){var t=_i(e)?{first:e}:"number"==typeof e?{each:e}:e,r=t.first,n=t.each,i=t.with,o=void 0===i?Pi:i,s=t.scheduler,a=void 0===s?ei:s,c=t.meta,l=void 0===c?null:c;if(null==r&&null==n)throw new TypeError("No timeout provided.");return Bn(function(e,t){var i,s,c=null,u=0,f=function(e){s=gi(t,a,function(){try{i.unsubscribe(),hi(o({meta:l,lastValue:c,seen:u})).subscribe(t)}catch(e){t.error(e)}},e)};i=e.subscribe(Mn(t,function(e){null==s||s.unsubscribe(),u++,t.next(c=e),n>0&&f(n)},void 0,void 0,function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),c=null})),!u&&f(null!=r?"number"==typeof r?r:+r-a.now():n)})}({each:1e3*i,with:()=>{return t=vn(e=()=>{const e=new io;return r({level:ao.Error,name:so.RequireInstanceTimeout,message:`Module [${String(n)}] initialization timed out after ${i}s`,properties:{moduleName:String(n),wait:i},error:e}),e})?e:function(){return e},new Fn(function(e){return e.error(t())});var e,t}}),eo(()=>{const e=Math.round(performance.now()-o);r({level:ao.Debug,name:so.RequireInstanceModuleResolved,message:`Module [${String(n)}] required in ${e}ms`,properties:{moduleName:String(n),wait:i,requireTime:e},metric:e})})))}}async function po(e,t,r){const{modules:n,registerEvent:i,instances:o={},onLateProvider:s}=e;if(0===n.length)return Object.seal(o);const a=n.map(e=>e.name),c=new qn({}),l=e=>a.includes(e),u=fo(a,c,i),f=performance.now();let d=!1;const p=n.map(async e=>{const[n,a]=await async function(e,t){const{config:r,ref:n,requireInstance:i,hasModule:o,registerEvent:s}=t,a=e.name,c=performance.now();if(!e.initialize){const t=new Error(`Module ${e.name} does not have initialize method`);throw t.name="ModuleInitializeError",s({level:ao.Error,name:so.ModuleInitializeError,message:t.message,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t,metric:performance.now()-c}),t}let l;s({level:ao.Debug,name:so.ModuleInitializing,message:`Initializing module ${e.name}`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}});try{l=await e.initialize({ref:n,config:r[a],requireInstance:i,hasModule:o})}catch(t){throw s({level:ao.Error,name:so.ModuleInitializeError,message:"Module initialization failed",properties:{moduleName:e.name},metric:performance.now()-c,error:t}),t}l instanceof uo||s({level:ao.Warning,name:so.ProviderNotBaseModuleProvider,message:`Provider for module ${e.name} does not extend BaseModuleProvider`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}});const u=l;u.version||s({level:ao.Warning,name:so.ProviderVersionWarning,message:`Provider for module ${e.name} does not expose version`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}});const f=Math.round(performance.now()-c);return s({level:ao.Debug,name:so.ModuleInitialized,message:`Module ${e.name} initialized in ${f}ms`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown",providerName:typeof l,providerVersion:u.version?.toString()||"unknown",moduleInitTime:f},metric:f}),[a,l]}(e,{config:t,ref:r,requireInstance:u,hasModule:l,registerEvent:i});d?s?.(e,a):(o[n]=a,c.next({...o}))});try{await Promise.all(p)}catch(e){throw d=!0,c.error(e),e}c.complete();const h=Math.round(performance.now()-f);return i({level:ao.Debug,name:so.ModuleInitializeComplete,message:"All modules initialized",properties:{modules:Object.keys(o).join(", "),loadTime:h},metric:h}),i({level:ao.Debug,name:so.InitializeComplete,message:`Modules instance created in ${h}ms`,properties:{modules:Object.keys(o).join(", "),initTime:h},metric:h}),Object.seal(o),o}const ho=["default","diagnostics","events"];function mo(e){return"function"==typeof e?e.name||"anonymous":"dispose"}async function go(e){"function"!=typeof e?await e.dispose():await e()}async function vo(e,t,r){const{modules:n,registerEvent:i,event$:o,pluginTeardowns:s=[]}=e,a=performance.now();let c=!1;if(i({level:ao.Debug,name:so.Dispose,message:"Disposing modules instance",properties:{modules:Object.keys(t).join(", ")}}),s.length){i({level:ao.Debug,name:so.PluginsDisposing,message:`Disposing plugins [${s.length}]`,properties:{count:s.length}});for(const e of s.splice(0).reverse()){const t=mo(e);try{await go(e),i({level:ao.Debug,name:so.PluginDisposed,message:`Plugin ${t} disposed successfully`,properties:{name:t}})}catch(e){c=!0,i({level:ao.Warning,name:so.PluginDisposeError,message:`Plugin ${t} dispose failed`,properties:{name:t},error:e})}}}i({level:ao.Debug,name:so.ModulesDispose,message:"Disposing modules",properties:{count:n.length}});const l={default:[],diagnostics:[],events:[]};for(const e of n){const t=e.disposePhase??"default";ho.includes(t)?l[t].push(e):(c=!0,i({level:ao.Warning,name:so.ModulesDispose,message:`Unsupported disposal phase for module ${e.name}; disposing during the default phase`,properties:{moduleName:e.name},error:new TypeError("Unsupported module disposal phase")}),l.default.push(e))}for(const e of ho)await Promise.allSettled(l[e].filter(e=>!!e.dispose).map(async e=>{if(!e.dispose)return;const n=performance.now();try{await e.dispose({ref:r,modules:t,instance:t[e.name]}),i({level:ao.Debug,name:so.ModuleDisposed,metric:performance.now()-n,message:`Module ${e.name} disposed successfully`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}})}catch(t){c=!0,i({level:ao.Warning,name:so.ModuleDisposeError,metric:performance.now()-n,message:`Module ${e.name} dispose failed`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t})}})),"default"===e&&i({level:c?ao.Warning:ao.Information,name:so.ModulesDisposed,message:"Default module disposal complete; flushing lifecycle sinks",metric:performance.now()-a,properties:{count:n.length,failed:c}});o.complete()}class yo{static className="ModulesConfigurator";get version(){return"6.2.0-next.0"}#se=new Wn(100);#ae=new WeakMap;#ce=new Map;get event$(){return this.#se.asObservable()}_configs=[];_afterConfiguration=[];_afterInit=[];_plugins=[];_pluginTeardowns=[];#le=new WeakMap;_modules;constructor(e){this._modules=new Set(e?this._dedupeModulesByName(e):[])}_dedupeModulesByName(e){const t=new Map;for(const r of e)t.set(r.name,r);return Array.from(t.values())}_removeModuleCallbacks(e){this._configs=this._configs.filter(t=>t.moduleName!==e),this._afterConfiguration=this._afterConfiguration.filter(t=>t.moduleName!==e),this._afterInit=this._afterInit.filter(t=>t.moduleName!==e)}get modules(){return[...this._modules]}configure(...e){for(const t of e)this.addConfig(t)}addConfig(e){const{module:t,afterConfig:r,afterInit:n,configure:i}=e,o=function(e){const{registration:t,configurators:r,registerEvent:n}=e,{module:i,configurator:o,prepare:s}=t;if(void 0!==o||s)try{let e=o??r.get(i);if(void 0===e){if(!i.prepare)throw new TypeError(`Module "${i.name}" requires a prepare factory or an explicit configurator for preparation`);e=i.prepare(),lo(e,i.name)}return s&&lo(s(e),i.name),n({level:ao.Debug,name:so.ConfiguratorPrepared,message:`Configuration prepared for ${i.name}`,properties:{moduleName:i.name}}),{configurator:e}}catch(e){throw n({level:ao.Error,name:so.ConfiguratorPrepareError,message:`Configuration preparation failed for ${i.name}`,properties:{moduleName:i.name},error:e}),e}}({registration:e,configurators:this.#ce,registerEvent:e=>this._registerEvent(e)}),s=Array.from(this._modules).find(e=>e.name===t.name);if(s){if(s!==t){this.#ce.has(s)&&(console.warn(`Prepared configuration for module "${t.name}" was replaced`),this._registerEvent({level:ao.Warning,name:so.PreparedConfigReplaced,message:`Prepared configuration for module ${t.name} was replaced by a different descriptor`,properties:{moduleName:t.name}})),this._removeModuleCallbacks(t.name),this.#ce.delete(s);const e=Array.from(this._modules).map(e=>e.name===t.name?t:e);this._modules=new Set(e)}}else this._modules.add(t);if(o&&this.#ce.set(t,o.configurator),this._registerEvent({level:ao.Debug,name:so.ModuleConfigAdded,message:`Module configurator added for ${t.name}`,properties:{moduleName:t.name,moduleVersion:t.version?.toString()||"unknown",configure:!!i,afterConfig:!!r,afterInit:!!n}}),i){const e=(e,r)=>i(e[t.name],r);e.moduleName=t.name,this._configs.push(e)}if(r){const e=e=>r(e[t.name]);e.moduleName=t.name,this._afterConfiguration.push(e)}if(n){const e=e=>n(e[t.name]);e.moduleName=t.name,this._afterInit.push(e)}}onConfigured(e){this._afterConfiguration.push(e),this._registerEvent({level:ao.Debug,name:so.OnConfiguredAdded,message:"Added onConfigured callback",properties:{count:this._afterConfiguration.length,name:e.name||"anonymous"}})}onInitialized(e){this._afterInit.push(e),this._registerEvent({level:ao.Debug,name:so.OnInitializedAdded,message:"Added onInitialized callback",properties:{count:this._afterInit.length,name:e.name||"anonymous"}})}registerPlugin(e){this._plugins.push(e),this._registerEvent({level:ao.Debug,name:so.PluginAdded,message:"Added plugin callback",properties:{count:this._plugins.length,name:e.name||"anonymous"}})}async initialize(e){const t=performance.now(),r={},n=[];this._registerEvent({level:ao.Debug,name:so.HostInitializeStarted,message:"Starting host initialization"});try{const i=await this._initializeModules(r,n,e);return this._registerEvent({level:ao.Information,name:so.HostInitialized,message:"Host initialized",metric:performance.now()-t}),i}catch(i){this._registerEvent({level:ao.Error,name:so.HostInitializeError,message:"Host initialization failed",metric:performance.now()-t,error:i});try{const t=this.modules.filter(e=>Object.hasOwn(r,e.name));await vo({modules:t,registerEvent:this._registerEvent.bind(this),event$:this.#se,pluginTeardowns:n},r,e)}catch{console.warn("Module initialization rollback failed")}throw i}}async _initializeModules(e,t,r){const n=performance.now(),i=await this._configure(r),o=Math.round(performance.now()-n),s=this.modules.map(e=>e.name).join(", ");this._registerEvent({level:ao.Debug,name:so.InitializeConfigLoaded,message:`Modules configured in ${o}ms`,properties:{modules:s,count:this.modules.length,loadTime:o},metric:o});const a=performance.now(),c=await this._initialize(i,r,e),l=Math.round(performance.now()-a),u=this.modules.map(e=>e.name).join(", ");this._registerEvent({level:ao.Debug,name:so.InitializeInstanceInitialized,message:`Modules initialized in ${l}ms`,properties:{modules:u,count:this.modules.length,loadTime:l},metric:l});const f=o+l,d=this.modules.map(e=>e.name).join(", ");this._registerEvent({level:ao.Information,name:so.Initialize,message:`initialize in ${f}ms`,properties:{modules:d,configLoadTime:o,instanceLoadTime:l,totalLoadTime:f},metric:f}),await this._postInitialize(c,r);const p=Object.seal(Object.assign({},c,{dispose:()=>this.dispose(p)}));return this.#le.set(p,t),await this._registerPlugins(p,r,t),p}_registerEvent(e){const t=e.name.split("::");this.#se.next({...e,name:`${this.constructor.className}::${t[t.length-1]}`})}async _configure(e){return co({modules:this.modules,configurators:this.#ce,configs:this._configs,afterConfiguration:this._afterConfiguration,afterInit:this._afterInit,registerEvent:this._registerEvent.bind(this)},e)}async _initialize(e,t,r={}){return po({modules:this.modules,registerEvent:this._registerEvent.bind(this),instances:r,onLateProvider:(e,r)=>{yo.#ue(e,r,t)}},e,t)}static async#ue(e,t,r){try{await(e.dispose?.({ref:r,modules:{[e.name]:t},instance:t}))}catch{console.warn("Module initialization rollback failed")}}async _postInitialize(e,t){return async function(e,t,r){const{modules:n,afterInit:i,registerEvent:o}=e;o({level:ao.Debug,name:so.ConfiguratorPostInitializeStart,message:`Post-initializing all modules [${Object.keys(t).length}]`,properties:{modules:Object.keys(t).join(", ")}});const s=wi(n).pipe(Mi(e=>!!e.postInitialize),eo(e=>{o({level:ao.Debug,name:so.ModulePostInitializeStart,message:`Module ${e.name} is being post-initialized`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"}})}),Ri(e=>{const n=performance.now();return wi(e.postInitialize({ref:r,modules:t,instance:t[e.name]})).pipe(eo(()=>{const t=Math.round(performance.now()-n);o({level:ao.Debug,name:so.ModulePostInitializeComplete,message:`Module ${e.name} has been post-initialized in ${t}ms`,metric:t,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown",postInitTime:t}})}),Hi(null),Gi(t=>(o({level:ao.Warning,name:so.ModulePostInitializeError,message:`Module ${e.name} post-initialize failed`,properties:{moduleName:e.name,moduleVersion:e.version?.toString()||"unknown"},error:t}),ri)))}),Hi(null)),a=performance.now();await Si(s);const c=Math.round(performance.now()-a);if(o({level:ao.Debug,name:so.PostInitializeComplete,message:`Post-initialization of all modules completed in ${c}ms`,properties:{modules:Object.keys(t).join(", "),postInitTime:c},metric:c}),!i.length)return void o({level:ao.Debug,name:so.PostInitializeCompleteNoHooks,message:"Post-initialization complete",properties:{modules:Object.keys(t).join(", "),postInitCompleteTime:c}});try{const e=i.map(e=>e.name||"anonymous").join(", ");o({level:ao.Debug,name:so.PostInitializeHooks,message:`Executing post-initialize hooks [${i.length}]`,properties:{hooks:e}});const r=performance.now();await Promise.allSettled(i.map(e=>Promise.resolve(e(t))));const n=Math.round(performance.now()-r);o({level:ao.Debug,name:so.PostInitializeHooksComplete,message:`Post-initialize hooks completed in ${n}ms`,properties:{hooks:e,afterInitTime:n},metric:n})}catch(e){const t=i.map(e=>e.name||"anonymous").join(", ");o({level:ao.Warning,name:so.PostInitializeHooksError,message:"Post-initialize hooks failed",properties:{hooks:t},error:e})}const l=Math.round(performance.now()-a);o({level:ao.Debug,name:so.PostInitializeComplete,message:"Post-initialization complete",properties:{modules:Object.keys(t).join(", "),postInitCompleteTime:l}})}({modules:this.modules,afterInit:this._afterInit,registerEvent:this._registerEvent.bind(this)},e,t)}async _registerPlugins(e,t,r=this._pluginTeardowns){return async function(e,t,r){const{plugins:n,teardowns:i,registerEvent:o}=e;if(!n.length)return;o({level:ao.Debug,name:so.PluginsRegister,message:`Registering plugins [${n.length}]`,properties:{count:n.length}});const s=await Promise.all(n.map(async e=>{const n=performance.now(),i=e.name||"anonymous";try{const a=await e({modules:t,ref:r}),c=Math.round(performance.now()-n);return o({level:ao.Debug,name:so.PluginRegistered,message:`Plugin ${i} registered in ${c}ms`,properties:{name:i,pluginTime:c},metric:c}),"function"==typeof(s=a)||"object"==typeof s&&null!==s&&"dispose"in s&&"function"==typeof s.dispose?a:void 0}catch(e){return void o({level:ao.Warning,name:so.PluginRegisterError,message:`Plugin ${i} registration failed`,properties:{name:i},error:e})}var s}));for(const e of s)e&&i.push(e);o({level:ao.Debug,name:so.PluginsRegistered,message:"Plugin registration complete",properties:{count:n.length,teardowns:i.length}})}({plugins:this._plugins,teardowns:r,registerEvent:this._registerEvent.bind(this)},e,t)}dispose(e,t){let r=this.#ae.get(e);if(!r){const n=[...this.#le.get(e)?.splice(0)??[],...this._pluginTeardowns.splice(0)];r=vo({modules:this.modules,registerEvent:this._registerEvent.bind(this),event$:this.#se,pluginTeardowns:n},e,t),this.#ae.set(e,r)}return r}}class Eo{_operators;get operators(){return this._operators}constructor(e){this._operators=e&&"operators"in e?{...e.operators}:e??{}}add(e,t){if(Object.keys(this._operators).includes(e))throw Error(`Operator [${e}] already defined`);return this.set(e,t)}set(e,t){return this._operators[e]=t,this}remove(e){return delete this._operators[e],this}get(e){return this._operators[e]}process(e){return Object.values(this._operators).length?wi(Object.values(this._operators)).pipe((t=(e,t)=>Promise.resolve(t(e)).then(t=>t??e),r=e,n=1,Bn(function(e,i){var o=r;return $i(e,i,function(e,r){return t(o,e,r)},n,function(e){o=e},!1,void 0,function(){return o=null})})),Yi()):Ii(e);var t,r,n}}class bo extends Eo{setHeader(e,t){const r=((e,t)=>r=>{const n=new Headers(r.headers);return n.append(e,t),{...r,headers:n}})(e,t);return this.set(`header-${e}`,r)}}class wo extends Eo{}class Io{#fe;constructor(e){this.#fe=e?[...e.middleware]:[]}get middleware(){return this.#fe}use(e){return this.#fe.push(e),this}process(e,t,r){const n=this.#fe.reduceRight((e,t)=>(r,n)=>t(r,n,(t,r)=>function(e){return e instanceof Response?Promise.resolve(e):Ci(wi(e))}(e(t,r))),r),i=n(e,t);return i instanceof Response?Ii(i):wi(i)}}const Lo=x.object({attributionReporting:x.object({eventSourceEligible:x.boolean().optional(),triggerEligible:x.boolean().optional()}).optional(),body:x.union([x.string(),x.instanceof(Blob),x.instanceof(ArrayBuffer),x.instanceof(FormData),x.instanceof(URLSearchParams),x.instanceof(ReadableStream)]).optional(),browsingTopics:x.boolean().optional(),cache:x.enum(["default","no-store","reload","no-cache","force-cache","only-if-cached"]).optional(),credentials:x.enum(["omit","same-origin","include"]).optional(),headers:x.record(x.string(),x.string()).optional().or(x.instanceof(Headers)),integrity:x.string().optional(),keepalive:x.boolean().optional(),method:x.enum(["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD","CONNECT","TRACE"],{message:"Invalid request method. Expected one of: GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, CONNECT, TRACE. See RFC 2615 Section 9 for more information: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html"}).optional().optional(),mode:x.enum(["same-origin","cors","no-cors","navigate","websocket"]).optional(),priority:x.enum(["low","high","auto"]).optional(),redirect:x.enum(["follow","error","manual"]).optional(),referrer:x.string().optional(),referrerPolicy:x.enum(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]).optional(),signal:x.instanceof(AbortSignal).optional()}).extend({uri:x.string(),path:x.string().optional()}),So=e=>e=>{const{error:t,success:r,data:n}=x.string().optional().refine(e=>void 0===e||e===e?.toUpperCase(),{message:["Provided HTTP method must be in uppercase.","See RFC 7231 Section 4.1 for more information","https://www.rfc-editor.org/rfc/rfc7231#section-4.1"].join(" ")}).safeParse(e.method);if(e.method=r?n:e.method?.toUpperCase(),t)for(const e of t.issues)console.warn(e.message);return e},Co=e=>e=>{const{strict:t,parse:r}={},n=t?Lo:Lo.passthrough();try{const t=n.parse(e);return r?t:void 0}catch(e){if(r)throw e;console.error("Invalid request options",e.message)}},_o=e=>{try{return JSON.parse(e)}catch{return e}};function*Do(e,t){const r=e.split("\n\n"),n=t?.dataParser||_o;for(const e of r){if(!e.trim())continue;const t=e.split("\n").reduce((e,t)=>{if(!t)return e;const r=t.indexOf(":");if(-1===r)return e;const i=t.slice(0,r).trim(),o=t.slice(r+1).trim();return"data"===i?e.data=n(o):e[i]=o,e},{});Object.keys(t).length&&(yield t)}}const Po=e=>t=>{if(!t.ok)throw new Jr(`HTTP error! Status: ${t.status}`,t);if(!t.body)throw new Jr("Response body is not readable",t);if(!t.headers.get("Content-Type")?.includes("text/event-stream"))throw new Jr("Response is not a text/event-stream",t);const r=t.body.getReader();return wi(async function*(e,t){const r=!!t?.skipHeartbeats,n=t?.eventFilter?Array.isArray(t.eventFilter)?t.eventFilter:[t.eventFilter]:null,i=new TextDecoder;for(;;){const{done:o,value:s}=await e.read();if(o)break;const a=Do(i.decode(s,{stream:!0}),{dataParser:t?.dataParser});for(const e of a)if(e.retry)await new Promise(t=>setTimeout(t,Number.parseInt(e.retry??"300",10)));else{if(r){if(!e.event&&!e.data&&!e.id)continue;if(e.event&&["heartbeat","ping"].includes(e.event))continue}(!n||e.event&&n.includes(e.event))&&(yield e)}}}(r,{dataParser:e?.dataParser,skipHeartbeats:e?.skipHeartbeats,eventFilter:e?.eventFilter})).pipe(Qi(e?.abortSignal?Fi(e.abortSignal,"abort"):ri),Ki(async()=>{await r.cancel().catch(()=>{}),r.releaseLock()}))};class No{_clients={};get clients(){return{...this._clients}}defaultHttpClientCtor;defaultHttpRequestHandler=new bo({"capitalize-method":So(),"request-validation":Co()});defaultHttpMiddlewareHandler=new Io;constructor(e){this.defaultHttpClientCtor=e}hasClient(e){return Object.keys(this._clients).includes(e)}addMiddleware(e){return this.defaultHttpMiddlewareHandler.use(e),this}configureClient(e,t){const r="string"==typeof t?{baseUri:t}:t,n="function"==typeof r?{onCreate:r}:r;return this._clients[e]={...this._clients[e],...n},this}}const Oo=["http:","https:","ws:","wss:"];class Ao extends uo{config;get defaultHttpRequestHandler(){return this.config.defaultHttpRequestHandler}get defaultHttpMiddlewareHandler(){return this.config.defaultHttpMiddlewareHandler}constructor(e){super({version:"8.1.5-next.0",config:e}),this.config=e}hasClient(e){return Object.keys(this.config.clients).includes(e)}createClient(e){const t=this._resolveConfig(e),{baseUri:r,defaultScopes:n=[],onCreate:i,ctor:o=this.config.defaultHttpClientCtor,requestHandler:s=this.defaultHttpRequestHandler,responseHandler:a,middlewareHandler:c=this.defaultHttpMiddlewareHandler}=t,l=new o(r||"",{requestHandler:s,responseHandler:a,middlewareHandler:c});return Object.assign(l,{defaultScopes:n}),i?.(l),l}createCustomClient(e){return this.createClient(e)}_resolveConfig(e){if("string"==typeof e){const r=this.config.clients[e];if(!r&&(e=>{try{const t=new URL(e);return Oo.includes(t.protocol)}catch{return!1}})(e))return{baseUri:e};if(!r&&!(t=e).includes(" ")&&/^[a-z\d]([a-z\d-]*\.)+[a-z]{2,}/i.test(t))return console.warn(`[HttpClientProvider] "${e}" looks like a URL but is missing the http:// or https:// protocol. Treating it as "https://${e}". Pass a fully-qualified URL to silence this warning.`),{baseUri:`https://${e}`};if(!r)throw new Qr(`No registered http client for key [${e}]`);return r}var t;return e}}function $o(e,t){void 0===t&&(t={});var r=t.selector,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(t,["selector"]);return new Fn(function(t){var i=new AbortController,o=i.signal,s=!0,a=n.signal;if(a)if(a.aborted)i.abort();else{var c=function(){o.aborted||i.abort()};a.addEventListener("abort",c),t.add(function(){return a.removeEventListener("abort",c)})}var l=cn(cn({},n),{signal:o}),u=function(e){s=!1,t.error(e)};return fetch(e,l).then(function(e){r?hi(r(e)).subscribe(Mn(t,void 0,function(){s=!1,t.complete()},u)):(s=!1,t.next(e),t.complete())}).catch(u),function(){s&&i.abort()}})}const Ro=async e=>{if(204===e.status)return Promise.resolve();try{const t=await e.json();if(!e.ok)throw new Xr("network response was not OK",e,{data:t});return t}catch(t){if(t instanceof Xr)throw t;throw new Xr("failed to parse response",e,{cause:t})}},To=async e=>{if(!e.ok)throw new Error("network response was not OK");if(204===e.status)throw new Error("no content");const t=e.headers.get("content-disposition")?.split(";").find(e=>e.includes("filename="))?.replace("filename=","")?.trim();try{return{filename:t,blob:await e.blob()}}catch(e){throw Error("failed to parse response")}};class xo{uri;requestHandler;responseHandler;middlewareHandler;_request$=new zn;_response$=new zn;_abort$=new zn;get request$(){return this._request$.asObservable()}get response$(){return this._response$.asObservable()}constructor(e,t){this.uri=e,this.requestHandler=new bo(t?.requestHandler),this.responseHandler=new wo(t?.responseHandler),this.middlewareHandler=new Io(t?.middlewareHandler),this._init()}_init(){}fetch$(e,t){return this._fetch$(e,t)}fetch(e,t){return Ci(this.fetch$(e,t))}fetchAsync(e,t){return this.fetch(e,t)}json$(e,t){const r="object"==typeof t?.body?JSON.stringify(t?.body):t?.body,n=t?.selector??Ro,i=new Headers(t?.headers);return i.append("Accept","application/json"),i.append("Content-Type","application/json"),this.fetch$(e,{...t,body:r,selector:n,headers:i})}json(e,t){return Ci(this.json$(e,t))}blob$(e,t){const r=t?.selector??To,n={...t,selector:r};return this.fetch$(e,n)}blob(e,t){return Ci(this.blob$(e,t))}sse$(e,t,r){const n=new Headers(t?.headers);n.append("Accept","text/event-stream"),n.append("Content-Type","text/event-stream"),n.append("Cache-Control","no-cache"),n.append("Connection","keep-alive");const i=Po({...r,abortSignal:t?.signal});return this._fetch$(e,{selector:i,...t,headers:n})}jsonAsync(e,t){return this.json(e,t)}execute(e,t,r){return this[e](t,r)}abort(){this._abort$.next()}_fetch$(e,t){const{selector:r,...n}=t||{},i=new AbortController,o=this._abort$.pipe((s=1,s<=0?function(){return ri}:Bn(function(e,t){var r=0;e.subscribe(Mn(t,function(e){++r<=s&&(t.next(e),s<=r&&t.complete())}))}))).subscribe(()=>i.abort());var s;const a=n.signal,c=a?AbortSignal.any([a,i.signal]):i.signal;return Ii({...n,signal:c,path:e,uri:this._resolveUrl(e)}).pipe(Ji(e=>this._prepareRequest(e)),eo(e=>this._request$.next(e)),Ji(({uri:e,path:t,...r})=>this.middlewareHandler.process(e,r,(e,t)=>this._performFetch(e,t))),Ji(e=>this._prepareResponse(e)),eo(e=>this._response$.next(e)),Ji(e=>{if(r)try{return r(e)}catch(t){throw new Yr("failed to execute response selector",e,{cause:t})}return Ii(e)}),Qi(this._abort$),Ki(()=>o.unsubscribe()))}_performFetch(e,t){return $o(e,t)}_prepareRequest(e){return this.requestHandler.process(e)}_prepareResponse(e){return this.responseHandler.process(e)}_resolveUrl(e){const{origin:t,pathname:r}=new URL(this.uri,this.uri.startsWith("http")?void 0:window.location.origin),n=[r,e].join("/").replace(/\/{2,}/g,"/");return new URL(n,t).href}}class ko extends xo{defaultScopes=[];fetch$(e,t){const r={...t,scopes:this.defaultScopes.concat(t?.scopes||[])};return super._fetch$(e,r)}}const Fo={name:"http",configure:()=>new No(ko),initialize:async({config:e,hasModule:t,requireInstance:r})=>{const n=new Ao(e);if(t("auth")){const e=await r("auth");n.defaultHttpRequestHandler.set("MSAL",async t=>{const{scopes:r=[]}=t;if(r.length){const i={request:{scopes:r}},o=await e.acquireAccessToken(on in t?(n=i,{...n,[on]:!0}):i);if(o){const e=new Headers(t.headers);return e.set("Authorization",`Bearer ${o}`),{...t,headers:e}}}var n})}return n}},Uo=(...e)=>t=>t.pipe(function(e,t){return vn(t)?Ri(e,t,1):Ri(e,1)}(...e)),Bo=(...e)=>t=>t.pipe(Ri(...e)),Mo=(...e)=>t=>t.pipe(Ji(...e)),Go=e=>e.pipe(Ni(e=>e.value));var jo=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function zo(e){if(!function(e){return"string"==typeof e&&jo.test(e)}(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}const Ho=[];for(let e=0;e<256;++e)Ho.push((e+256).toString(16).slice(1));function qo(e,t=0){return(Ho[e[t+0]]+Ho[e[t+1]]+Ho[e[t+2]]+Ho[e[t+3]]+"-"+Ho[e[t+4]]+Ho[e[t+5]]+"-"+Ho[e[t+6]]+Ho[e[t+7]]+"-"+Ho[e[t+8]]+Ho[e[t+9]]+"-"+Ho[e[t+10]]+Ho[e[t+11]]+Ho[e[t+12]]+Ho[e[t+13]]+Ho[e[t+14]]+Ho[e[t+15]]).toLowerCase()}const Vo=new Uint8Array(16);function Wo(e,t,r,n,i,o){const s="string"==typeof r?function(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}(r):r,a="string"==typeof n?zo(n):n;if("string"==typeof n&&(n=zo(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+s.length);if(c.set(a),c.set(s,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){if(o??=0,o<0||o+16>i.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let e=0;e<16;++e)i[o+e]=c[e];return i}return qo(c)}function Zo(e,t,r){return crypto.randomUUID?crypto.randomUUID():function(e){e=e||{};const t=e.random??e.rng?.()??crypto.getRandomValues(Vo);if(t.length<16)throw new Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,qo(t)}(e)}function Ko(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Yo(e,t){return e<<t|e>>>32-t}function Xo(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,o=Math.ceil(i/16),s=new Array(o);for(let t=0;t<o;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];s[t]=r}s[o-1][14]=8*(e.length-1)/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<o;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=s[e][t];for(let e=16;e<80;++e)n[e]=Yo(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],o=r[1],a=r[2],c=r[3],l=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),s=Yo(i,5)+Ko(r,o,a,c)+l+t[r]+n[e]>>>0;l=c,c=a,a=Yo(o,30)>>>0,o=i,i=s}r[0]=r[0]+i>>>0,r[1]=r[1]+o>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+l>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function Jo(e,t,r,n){return Wo(80,Xo,e,t,r,n)}Jo.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Jo.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";class Qo extends Error{type;request;constructor(e,t){super(t.message,{cause:t.cause}),this.type=e,this.name="QueryClientError",this.request=t.request}}var es=Symbol.for("immer-nothing"),ts=Symbol.for("immer-draftable"),rs=Symbol.for("immer-state"),ns="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function is(e,...t){if("production"!==process.env.NODE_ENV){const r=ns[e],n=Ds(r)?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var os=Object,ss=os.getPrototypeOf,as="constructor",cs="prototype",ls="configurable",us="enumerable",fs="writable",ds="value",ps=e=>!!e&&!!e[rs];function hs(e){return!!e&&(vs(e)||Ls(e)||!!e[ts]||!!e[as]?.[ts]||Ss(e)||Cs(e))}var ms=os[cs][as].toString(),gs=new WeakMap;function vs(e){if(!e||!_s(e))return!1;const t=ss(e);if(null===t||t===os[cs])return!0;const r=os.hasOwnProperty.call(t,as)&&t[as];if(r===Object)return!0;if(!Ds(r))return!1;let n=gs.get(r);return void 0===n&&(n=Function.toString.call(r),gs.set(r,n)),n===ms}function ys(e,t,r=!0){if(0===Es(e)){(r?Reflect.ownKeys(e):os.keys(e)).forEach(r=>{t(r,e[r],e)})}else e.forEach((r,n)=>t(n,r,e))}function Es(e){const t=e[rs];return t?t.type_:Ls(e)?1:Ss(e)?2:Cs(e)?3:0}var bs=(e,t,r=Es(e))=>2===r?e.has(t):os[cs].hasOwnProperty.call(e,t),ws=(e,t,r=Es(e))=>2===r?e.get(t):e[t],Is=(e,t,r,n=Es(e))=>{2===n?e.set(t,r):3===n?e.add(r):e[t]=r};var Ls=Array.isArray,Ss=e=>e instanceof Map,Cs=e=>e instanceof Set,_s=e=>"object"==typeof e,Ds=e=>"function"==typeof e,Ps=e=>"boolean"==typeof e;var Ns=e=>e.copy_||e.base_,Os=e=>e.modified_?e.copy_:e.base_;function As(e,t){if(Ss(e))return new Map(e);if(Cs(e))return new Set(e);if(Ls(e))return Array[cs].slice.call(e);const r=vs(e);if(!0===t||"class_only"===t&&!r){const t=os.getOwnPropertyDescriptors(e);delete t[rs];let r=Reflect.ownKeys(t);for(let n=0;n<r.length;n++){const i=r[n],o=t[i];!1===o[fs]&&(o[fs]=!0,o[ls]=!0),(o.get||o.set)&&(t[i]={[ls]:!0,[fs]:!0,[us]:o[us],[ds]:e[i]})}return os.create(ss(e),t)}{const t=ss(e);if(null!==t&&r)return{...e};const n=os.create(t);return os.assign(n,e)}}function $s(e,t=!1){return Ts(e)||ps(e)||!hs(e)||(Es(e)>1&&os.defineProperties(e,{set:Rs,add:Rs,clear:Rs,delete:Rs}),os.freeze(e),t&&ys(e,(e,t)=>{$s(t,!0)},!1)),e}var Rs={[ds]:function(){is(2)}};function Ts(e){return null===e||!_s(e)||os.isFrozen(e)}var xs="MapSet",ks="Patches",Fs="ArrayMethods",Us={};function Bs(e){const t=Us[e];return t||is(0,e),t}var Ms,Gs=e=>!!Us[e],js=()=>Ms;function zs(e,t){t&&(e.patchPlugin_=Bs(ks),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Hs(e){qs(e),e.drafts_.forEach(Ws),e.drafts_=null}function qs(e){e===Ms&&(Ms=e.parent_)}var Vs=e=>Ms={drafts_:[],parent_:Ms,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Gs(xs)?Bs(xs):void 0,arrayMethodsPlugin_:Gs(Fs)?Bs(Fs):void 0};function Ws(e){const t=e[rs];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Zs(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(void 0!==e&&e!==r){r[rs].modified_&&(Hs(t),is(4)),hs(e)&&(e=Ks(t,e));const{patchPlugin_:n}=t;n&&n.generateReplacementPatches_(r[rs].base_,e,t)}else e=Ks(t,r);return function(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&$s(t,r)}(t,e,!0),Hs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==es?e:void 0}function Ks(e,t){if(Ts(t))return t;const r=t[rs];if(!r){return ta(t,e.handledSet_,e)}if(!Xs(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:t}=r;if(t)for(;t.length>0;){t.pop()(e)}ea(r,e)}return r.copy_}function Ys(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Xs=(e,t)=>e.scope_===t,Js=[];function Qs(e,t,r,n){const i=Ns(e),o=e.type_;if(void 0!==n){if(ws(i,n,o)===t)return void Is(i,n,r,o)}if(!e.draftLocations_){const t=e.draftLocations_=new Map;ys(i,(e,r)=>{if(ps(r)){const n=t.get(r)||[];n.push(e),t.set(r,n)}})}const s=e.draftLocations_.get(t)??Js;for(const e of s)Is(i,e,r,o)}function ea(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const n=r.getPath(e);n&&r.generatePatches_(e,n,t)}Ys(e)}}function ta(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ps(e)||t.has(e)||!hs(e)||Ts(e)||(t.add(e),ys(e,(n,i)=>{if(ps(i)){const t=i[rs];if(Xs(t,r)){const r=Os(t);Is(e,n,r,e.type_),Ys(t)}}else hs(i)&&ta(i,t,r)})),e}var ra={get(e,t){if(t===rs)return e;let r=e.scope_.arrayMethodsPlugin_;const n=1===e.type_&&"string"==typeof t;if(n&&r?.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const i=Ns(e);if(!bs(i,t,e.type_))return function(e,t,r){const n=oa(t,r);return n?ds in n?n[ds]:n.get?.call(e.draft_):void 0}(e,i,t);const o=i[t];if(e.finalized_||!hs(o))return o;if(n&&e.operationMethod&&r?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return o;if(o===ia(e.base_,t)||function(e,t,r){if(1!==e.type_||!e.allIndicesReassigned_||!hs(r)||r[rs])return!1;return e.baseRefs_.has(r)}(e,0,o)){aa(e);const r=1===e.type_?+t:t,n=ca(e.scope_,o,e,r);return e.copy_[r]=n}return o},has:(e,t)=>t in Ns(e),ownKeys:e=>Reflect.ownKeys(Ns(e)),set(e,t,r){const n=oa(Ns(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const n=ia(Ns(e),t),s=n?.[rs];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_.delete(t),!0;if(((i=r)===(o=n)?0!==i||1/i==1/o:i!=i&&o!=o)&&(void 0!==r||bs(e.base_,t,e.type_)))return!0;aa(e),sa(e)}var i,o;return e.copy_[t]===r&&(void 0!==r||bs(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),function(e,t,r){const{scope_:n}=e;if(ps(r)){const i=r[rs];Xs(i,n)&&i.callbacks_.push(function(){aa(e);const n=Os(i);Qs(e,r,n,t)})}else hs(r)&&e.callbacks_.push(function(){const i=Ns(e);3===e.type_?i.has(r)&&ta(r,n.handledSet_,n):ws(i,t,e.type_)===r&&n.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&ta(ws(e.copy_,t,e.type_),n.handledSet_,n)})}(e,t,r)),!0},deleteProperty:(e,t)=>(aa(e),void 0!==ia(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),sa(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const r=Ns(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{[fs]:!0,[ls]:1!==e.type_||"length"!==t,[us]:n[us],[ds]:r[t]}:n},defineProperty(){is(11)},getPrototypeOf:e=>ss(e.base_),setPrototypeOf(){is(12)}},na={};for(let e in ra){let t=ra[e];na[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function ia(e,t){const r=e[rs];return(r?Ns(r):e)[t]}function oa(e,t){if(!(t in e))return;let r=ss(e);for(;r;){const e=Object.getOwnPropertyDescriptor(r,t);if(e)return e;r=ss(r)}}function sa(e){e.modified_||(e.modified_=!0,e.parent_&&sa(e.parent_))}function aa(e){e.copy_||(e.assigned_=new Map,e.copy_=As(e.base_,e.scope_.immer_.useStrictShallowCopy_))}na.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&is(13),na.set.call(this,e,t,void 0)},na.set=function(e,t,r){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&is(14),ra.set.call(this,e[0],t,r,e[0])};function ca(e,t,r,n){const[i,o]=Ss(t)?Bs(xs).proxyMap_(t,r):Cs(t)?Bs(xs).proxySet_(t,r):function(e,t){const r=Ls(e),n={type_:r?1:0,scope_:t?t.scope_:js(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=n,o=ra;r&&(i=[n],o=na);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return n.draft_=a,n.revoke_=s,[a,n]}(t,r);return(r?.scope_??js()).drafts_.push(i),o.callbacks_=r?.callbacks_??[],o.key_=n,r&&void 0!==n?function(e,t,r){e.callbacks_.push(function(n){const i=t;if(!i||!Xs(i,n))return;n.mapSetPlugin_?.fixSetContents(i);const o=Os(i);Qs(e,i.draft_??i,o,r),ea(i,n)})}(r,o,n):o.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:t}=e;o.modified_&&t&&t.generatePatches_(o,[],e)}),i}function la(e){if(!hs(e)||Ts(e))return e;const t=e[rs];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=As(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=As(e,!0);const i=r;return Cs(r)&&(r=new Set),ys(i,(e,t)=>{Is(r,e,la(t))},n),t&&(t.finalized_=!1),r}globalThis.Iterator;var ua=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,r)=>{if(Ds(e)&&!Ds(t)){const r=t;t=e;const n=this;return function(e=r,...i){return n.produce(e,e=>t.call(this,e,...i))}}let n;if(Ds(t)||is(6),void 0===r||Ds(r)||is(7),hs(e)){const i=Vs(this),o=ca(i,e,void 0);let s=!0;try{n=t(o),s=!1}finally{s?Hs(i):qs(i)}return zs(i,r),Zs(n,i)}if(!e||!_s(e)){if(n=t(e),void 0===n&&(n=e),n===es&&(n=void 0),this.autoFreeze_&&$s(n,!0),r){const t=[],i=[];Bs(ks).generateReplacementPatches_(e,n,{patches_:t,inversePatches_:i}),r(t,i)}return n}is(1,e)},this.produceWithPatches=(e,t)=>{if(Ds(e))return(t,...r)=>this.produceWithPatches(t,t=>e(t,...r));let r,n;return[this.produce(e,t,(e,t)=>{r=e,n=t}),r,n]},Ps(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Ps(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Ps(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){hs(e)||is(8),ps(e)&&(e=function(e){ps(e)||is(10,e);return la(e)}(e));const t=Vs(this),r=ca(t,e,void 0);return r[rs].isManual_=!0,qs(t),r}finishDraft(e,t){const r=e&&e[rs];r&&r.isManual_||is(9);const{scope_:n}=r;return zs(n,t),Zs(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));const n=Bs(ks).applyPatches_;return ps(e)?n(e,t):this.produce(e,e=>n(e,t))}},fa=ua.produce;const da=(...e)=>Mi(t=>e.includes(t.type));class pa extends Fn{#de=new zn;#pe;get action$(){return this.#de.asObservable()}get value(){return this.#pe.value}get closed(){return this.#pe.closed||this.#de.closed}constructor(e,t){super(e=>this.#pe.subscribe(e));const r="getInitialState"in e?e.getInitialState():t;this.#pe=new qn(r),this.#de.pipe(function(e,t){return Bn(ji(e,t,arguments.length>=2,!0))}(e,r),qi()).subscribe(this.#pe),this.reset=()=>this.#pe.next(r)}reset;next(e){this.#de.next(e)}select(e,t){return this.#pe.pipe(Ni(e),qi(t))}addEffect(e,t){const r="function"==typeof e?this.action$:Array.isArray(e)?this.action$.pipe(da(...e)):this.action$.pipe(da(e)),n=t||e;return r.pipe(Ri(e=>wi(new Promise((t,r)=>{try{t(n(e,this.value))}catch(e){r(e)}})).pipe(Gi(e=>(console.warn("unhandled effect",e),ri)))),Mi(e=>!!e),vi(ei)).subscribe(this.#de)}addEpic(e){return this.addFlow(e)}addFlow(e){const t=e(this.action$,this);if(!t)throw new TypeError(`addEpic: one of the provided effects "${e.name||"<anonymous>"}" does not return a stream. Double check you're not missing a return statement!`);return t.pipe(Gi(e=>(console.trace("unhandled exception, epic closed!",e),ri)),vi(ei)).subscribe(this.#de)}unsubscribe(){this.#de.unsubscribe(),this.#pe.unsubscribe()}complete(){this.#de.complete(),this.#pe.complete()}asObservable(){return this.#pe.asObservable()}}const ha="::";function ma(e,t){function r(...r){if(t){const n=t(...r);if(!n)throw new Error("prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:r[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=t=>t.type===e,r}function ga(e,t,r,n){const i=ma([e,"request"].join(ha),t);return r&&Object.assign(i,{success:ma([e,"success"].join(ha),r)}),n&&Object.assign(i,{failure:ma([e,"failure"].join(ha),n)}),i}function va(e){return hs(e)?fa(e,()=>{}):e}function ya(e,t){const[r,n,i]=function(e){const t={},r=[];let n;const i={addCase(e,o){if("production"!==process.env.NODE_ENV){if(r.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(s in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[s]=o,i},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:e,reducer:t}),i},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addDefaultCase` can only be called once");return n=e,i}};return e(i),[t,r,n]}(t);let o;if("function"==typeof e)o=()=>va(e());else{const t=va(e);o=()=>t}function s(e,t){let s=[r[t.type],...n.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];const a=s.filter(e=>!!e).length>0;return i&&!a&&(s=[i]),s.reduce((e,r)=>{if(r){if(ps(e)){const n=r(e,t);return void 0===n?e:n}if(hs(e))return fa(e,e=>r(e,t));{const n=r(e,t);if(void 0===n){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}}return e},e??o())}return s.getInitialState=o,s}const Ea={request:ma("client/request",(e,t)=>({payload:{args:e,options:t},meta:{transaction:Zo(),created:Date.now()}})),execute:ga("client/execute",e=>({payload:e,meta:{transaction:e,created:Date.now()}}),e=>({payload:e,meta:{transaction:e.transaction,created:Date.now()}}),(e,t)=>({payload:{error:e},meta:{transaction:t,created:Date.now()}})),cancel:ma("client/cancel",(e,t)=>({payload:{transaction:e,reason:t},meta:{transaction:e,created:Date.now()}})),error:ma("client/error",(e,t)=>({payload:{transaction:e,error:t},meta:{transaction:e,created:Date.now()}}))},ba=e=>e.pipe(Mi(Ea.request.match),Ni(e=>Ea.execute(e.meta.transaction)));class wa extends Fn{#he=new qn("idle");get status(){return this.#he.value}get status$(){return this.#he.asObservable()}#me;#ge;get transaction(){return this.#ge}created=Date.now();get closed(){return"complete"===this.status||"error"===this.status||"canceled"===this.status}constructor(e,t,r){super(t=>{const{transaction:n}=this,i=e.action$.pipe(Mi(e=>e.meta.transaction===n));t.add(e.state$.pipe(Mi(e=>!!e[n]),Ni(e=>e[n])).subscribe(e=>{this.#he.next(e.status)})),t.add(i.pipe(Mi(Ea.execute.success.match),Ni(({payload:e})=>e)).subscribe(e=>{this.#he.next("complete"),t.next(e),t.complete()})),t.add(i.pipe(Mi(Ea.error.match),Ni(({payload:e})=>e)).subscribe(e=>{this.#he.next("error"),t.error(e.error)})),t.add(i.pipe(Mi(Ea.cancel.match)).subscribe(e=>{this.#he.next("canceled"),t.error(new Qo("abort",{message:e.payload.reason||`job: ${n} was canceled`,request:this.#me.getRequest(e.meta.transaction)}))})),r?.signal&&t.add(Fi(r?.signal,"abort").pipe(Ni(()=>Ea.cancel(n,`job: ${n} was aborted on signal from caller: ${r?.ref}`))).subscribe(t=>e.next(t))),t.add(()=>{this.complete()})}),this.#me=e;const n=Ea.request(t,{ref:r?.ref,retry:r?.retry});this.#ge=n.meta.transaction,this.#me.next(n)}complete(e){this.closed||this.cancel(e??`job: ${this.transaction} was completed`)}cancel(e){const t=this.transaction;this.#me.cancel(t,e??`job: ${t} was canceled`)}[Symbol.dispose](){this.complete()}}class Ia{type;transaction;data;constructor(e,t,r){this.type=e,this.transaction=t,this.data=r}}class La extends Fn{#pe;#ve;#ye;_registerEvent(e,t,r){this.#ye.next(new Ia(e,t,r))}get closed(){return this.#pe.closed}get state$(){return this.#pe.asObservable()}get action$(){return this.#pe.action$}get event$(){return this.#ye.asObservable()}get success$(){return this.action$.pipe(Mi(Ea.execute.success.match),Ni(({payload:e})=>e))}get error$(){return this.action$.pipe(da("client/error"),to(this.#pe),Ni(([e,t])=>{const{payload:r,meta:{transaction:n}}=e,i=t[n];return new Qo("error",{request:i,message:`job: ${n} failed`,cause:r})}))}constructor(e,t){super(e=>this.#pe.subscribe(e)),this.#pe=new pa(((e={})=>ya(e,e=>{e.addCase(Ea.request,(e,t)=>{e[t.meta.transaction]={...t.payload,...t.meta,execution:[],errors:[],status:"idle"}}),e.addCase(Ea.execute,(e,t)=>{const r=e[t.payload];r&&(r.execution.push(Date.now()),r.status="active")}),e.addCase(Ea.execute.success,(e,t)=>{delete e[t.payload.transaction]}),e.addCase(Ea.execute.failure,(e,t)=>{const r=e[t.meta.transaction];r&&(r.errors.push(t.payload.error),r.status="failed")}),e.addCase(Ea.error,(e,t)=>{delete e[t.meta.transaction]}),e.addCase(Ea.cancel,(e,t)=>{delete e[t.meta.transaction]})}))({})),this.#ve=new wn(()=>{this.#pe.complete(),this.#ye.complete()}),this.#ye=new zn,this.#ve.add(this.#pe.addFlow(ba)),this.#ve.add(this.#pe.addFlow((e=>(t,r)=>t.pipe(Mi(Ea.execute.match),to(r),Ri(([r,n])=>{const i=r.payload,o=n[i],s=new AbortController,a=t.pipe(Mi(Ea.cancel.match),Mi(e=>e.payload.transaction===i),eo(()=>{s.signal.aborted||s.abort()}));try{return wi(e(o.args,s.signal)).pipe(Ni(e=>Ea.execute.success({...o,status:"complete",completed:Date.now(),value:e})),Gi(e=>Ii(Ea.execute.failure(e,i))),Qi(a))}catch(e){return Ii(Ea.execute.failure(e,i))}})))(e)));const r=Object.assign({count:0,delay:0},t?.retry);this.#ve.add(this.#pe.addFlow((e=>(t,r)=>t.pipe(Mi(Ea.execute.failure.match),to(r),Ri(([t,n])=>{const{transaction:i}=t.meta,o=n[i];if(!o)return Ii(Ea.error(i,new Qo("error",{message:"request not found, cannot retry request, most likely removed while scheduled for retry!"})));const s=o.execution.length,a=Object.assign({},e,o.options?.retry),c=o.errors?.slice(-1)[0]??new Qo("error",{message:"no errors registered for request!",request:o});if(s>a.count){const e=0===a.count?c:new Qo("error",{message:"maximum retries executed!",cause:o.errors,request:o});return Ii(Ea.error(i,e))}return("function"==typeof a.delay?wi(a.delay(c)).pipe(Gi(e=>Ii(Ea.error(i,new Qo("error",{message:"retry delay callback failed!",cause:[...o.errors??[],e],request:o}))))):Bi(a.delay)).pipe(to(r),Mi(([e,t])=>!!t[i]),eo(([,e])=>{if(!e[i])throw new Qo("error",{message:"request not found, most likely removed while scheduled for retry",cause:o.errors,request:o})}),Ni(()=>Ea.execute(i)))})))(r))),this.#pe.addEffect(Ea.request.type,({payload:e,meta:{transaction:t}})=>{this._registerEvent("query_client_job_requested",t,e)}),this.#pe.addEffect(Ea.execute.type,({meta:{transaction:e}})=>{this._registerEvent("query_client_job_executing",e)}),this.#pe.addEffect(Ea.execute.success.type,({payload:e,meta:{transaction:t}})=>{this._registerEvent("query_client_job_completed",t,{payload:e})}),this.#pe.addEffect(Ea.execute.failure.type,({payload:e,meta:{transaction:t}})=>{const r=e.error instanceof Error?e.error:new Error(String(e.error));this._registerEvent("query_client_job_failed",t,{error:r})}),this.#pe.addEffect(Ea.cancel.type,({payload:{reason:e},meta:{transaction:t}})=>{this._registerEvent("query_client_job_canceled",t,{reason:e||"no reason provided"})}),this.#pe.addEffect(Ea.error.type,({payload:e,meta:{transaction:t}})=>{const r=e.error instanceof Error?e.error:new Error(String(e.error));this._registerEvent("query_client_job_error",t,{error:r})})}next(e){this.#pe.next(e)}query(e,t){const r=new wa(this,e,t),n=r.pipe(function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new zn}:t,n=e.resetOnError,i=void 0===n||n,o=e.resetOnComplete,s=void 0===o||o,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,o,a=0,l=!1,u=!1,f=function(){null==n||n.unsubscribe(),n=void 0},d=function(){f(),t=o=void 0,l=u=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return Bn(function(e,h){a++,u||l||f();var m=o=null!=o?o:r();h.add(function(){0!==--a||u||l||(n=Xi(p,c))}),m.subscribe(h),!t&&a>0&&(t=new $n({next:function(e){return m.next(e)},error:function(e){u=!0,f(),n=Xi(d,i,e),m.error(e)},complete:function(){l=!0,f(),n=Xi(d,s),m.complete()}}),hi(e).subscribe(t))})(e)}}({connector:()=>new Wn,resetOnRefCountZero:!1}));return Object.defineProperties(n,{transaction:{get:()=>r.transaction},created:{get:()=>r.created},status:{get:()=>r.status},closed:{get:()=>r.closed},cancel:{value:e=>r.cancel(e)},complete:{value:()=>r.complete()}}),n}async nextAsync(e,t){return Ci(this.query(e,t))}getRequest(e){return this.#pe.value[e]}getRequestByRef(e){return Object.values(this.#pe.value).find(t=>t.ref===e)}cancelTaskByRef(e,t){const r=this.getRequestByRef(e);r?.ref&&this.cancel(r.transaction,t)}cancel(e,t){if(e)this.#pe.value[e]&&(t??=`cancelation requested for job: ${e}`,this.#pe.next(Ea.cancel(e,t)));else for(const e of Object.keys(this.#pe.value))this.cancel(e,"all transactions requested canceled")}on(e,t){return this.#pe.addEffect(Ea[e].type,e=>{t(e,this)})}complete(){this.#ve.unsubscribe()}}const Sa={set:ma("cache/set",(e,t)=>({payload:{key:e,record:t}})),insert:ma("cache/insert",(e,t)=>({payload:{key:e,entry:t}})),remove:ma("cache/remove",e=>({payload:e})),invalidate:ma("cache/invalidate",(e,t)=>({payload:e,meta:{item:t}})),mutate:ma("cache/mutate",(e,t,r)=>({payload:{...t,key:e},meta:{item:r}})),trim:ma("cache/trim",e=>({payload:e}))},Ca=(e,t)=>(t.updated??0)-(e.updated??0);class _a{type;key;data;constructor(e,t,r){this.type=e,this.key=t,this.data=r}}class Da{#pe;#ye;get state(){return this.#pe.value}get state$(){return this.#pe.asObservable()}get action$(){return this.#pe.action$}_registerEvent(e,t){this.#ye.next(new _a(e,t?.key,t?.data))}get event$(){return this.#ye.asObservable()}constructor(e){const{trimming:t,initial:r}=e??{};this.#pe=new pa(function(e,t={}){return ya(t,t=>t.addCase(e.set,(e,t)=>{const{key:r,record:n}=t.payload;e[r]=n}).addCase(e.insert,(e,t)=>{const{key:r,entry:n}=t.payload,i=e[r];if(i)i.updated=Date.now(),i.updates??=0,i.updates++,i.value=n.value,i.transaction=n.transaction,i.mutated=void 0;else{const t=Date.now();e[r]={...n,created:t,updated:t}}}).addCase(e.remove,(e,t)=>{delete e[t.payload]}).addCase(e.invalidate,(e,t)=>{const r=t.payload?[t.payload]:Object.keys(e);for(const t of r){const r=e[t];r&&(r.updated=void 0)}}).addCase(e.mutate,(e,t)=>{const{key:r,value:n,updated:i}=t.payload,o=e[r];o&&(o.value=n,o.updated=i,o.mutated=Date.now(),o.updates??=0,o.updates++)}).addCase(e.trim,(e,t)=>{const{payload:r}=t,n=r.sort??Ca,i=Object.keys(e),o=Object.entries(e).filter(([e,t])=>!r.validate||r.validate(t)).sort((e,t)=>n(e[1],t[1])).slice(0,r.size??Number.MAX_SAFE_INTEGER).map(([e])=>e);if(i.length!==o.length)for(const t of i){const r=o.indexOf(t);-1!==r?o.splice(r,1):delete e[t]}}))}(Sa,r)),t&&this.#pe.addEffect("cache/set",()=>this.#pe.next(Sa.trim(t))),this.#ye=new zn}has(e){return e in this.#pe.value}setItem(e,t){const{args:r,transaction:n,value:i}=t;this.#pe.next(Sa.insert(e,{args:r,transaction:n,value:i})),this._registerEvent("query_cache_entry_inserted",{key:e,data:{value:i,args:r,transaction:n}})}getItem(e){return this.#pe.value[e]}removeItem(e){this.#pe.next(Sa.remove(e)),this._registerEvent("query_cache_entry_removed",{key:e})}invalidate(e){const t=e?this.#pe.value[e]:void 0;this.#pe.next(Sa.invalidate(e,t)),e&&this._registerEvent("query_cache_entry_invalidated",{key:e,data:{previousValue:t?.value}})}mutate(e,t){const r=e in this.#pe.value?this.#pe.value[e]:void 0;if(!r)throw new Error(`Cannot mutate cache item with key ${e}: item not found`);const n="function"==typeof t?t(r?.value):t;return this.#pe.next(Sa.mutate(e,n,r)),this._registerEvent("query_cache_entry_mutated",{key:e,data:{previousValue:r.value,newValue:n,mutation:n}}),()=>this.#pe.next(Sa.set(e,r))}trim(e){const t=new Set(Object.keys(this.#pe.value));this.#pe.next(Sa.trim(e));const r=new Set(Object.keys(this.#pe.value)),n=Array.from(t).filter(e=>!r.has(e));this._registerEvent("query_cache_trimmed",{data:{removedKeys:n,criteria:e}})}reset(){this.#pe.reset(),this._registerEvent("query_cache_reset")}complete(){this.#pe.complete(),this.#ye.complete()}}class Pa extends zn{key;args;options;#Ee=Date.now();get created(){return this.#Ee}#be=Zo();get uuid(){return this.#be}constructor(e,t,r){super(),this.key=e,this.args=t,this.options=r}processJob(e){return e.pipe(Ni(t=>{const{key:r,uuid:n,created:i}=this;return{key:r,uuid:n,created:i,status:"complete",transaction:e.transaction,complete:t.completed,value:t.value}}),Ki(()=>{e.complete()})).subscribe(this)}}class Na{type;key;data;constructor(e,t,r){this.type=e,this.key=t,this.data=r}}class Oa{static extractQueryValue=Go;#ve=new wn;#me;#we;#Ie=new zn;#Le={};#Se;#Ce;#_e=Zo();#se;get client(){return this.#me}_registerEvent(e,t,r){this.#se.next(new Na(e,t,r))}get cache(){return this.#we}get event$(){return this.#se.asObservable()}constructor(e){this.#se=new zn,this.#Se=t=>Jo(e.key(t),this.#_e),this.#Ce=e?.validate??((e=0)=>t=>(t.updated??0)+e>Date.now())(e?.expire),e.client instanceof La?this.#me=e.client:(this.#me=new La(e.client.fn,{...e.client.options}),this.#ve.add(()=>this.#me.complete())),this.#ve.add(this.#me.event$.subscribe({next:e=>this.#se.next(e)})),e.cache instanceof Da?this.#we=e.cache:(this.#we=new Da(e.cache||{}),this.#ve.add(()=>this.#we.complete())),this.#ve.add(this.#we.event$.subscribe({next:e=>this.#se.next(e)}));const t=((e="switch")=>"function"==typeof e?e:(()=>{switch(e){case"concat":return Uo;case"merge":return Bo;case"switch":return Mo;default:throw new Error(`Invalid queue operator: ${e}`)}})())(e.queueOperator);var r,n;this.#ve.add(()=>this.#Ie.complete()),this.#ve.add(this.#Ie.pipe(eo(e=>{this._registerEvent("query_queued",e)}),Mi(e=>!!(e in this.#Le)),t(e=>{const t=this.#Le[e],{args:r,options:n,uuid:i}=t;if(this._registerEvent("query_job_selected",e,{taskId:i,args:r,options:n}),!t?.observed)return this._registerEvent("query_job_skipped",e,{taskId:i,args:r,options:n}),delete this.#Le[e],ri;const o=this.#me.query(r,{...n,ref:t.uuid});return new Fn(s=>{const{transaction:a}=o;var c,l;this._registerEvent("query_job_started",e,{taskId:i,transaction:a,args:r,options:n}),s.add(()=>{this._registerEvent("query_job_closed",e,{taskId:i,transaction:a,args:r,options:n}),o.complete("task closed"),delete this.#Le[e]}),s.add((c=10,void 0===l&&(l=ei),Bi(c,c,l)).pipe(Mi(()=>!t.observed)).subscribe(()=>{o.cancel(`task: ${t.uuid} is not observed`),s.complete()})),s.add(t.processJob(o).add(()=>{this._registerEvent("query_job_completed",e,{taskId:i,transaction:a,args:r,options:n})})),o.pipe(Ni(e=>({result:e,task:t})),Gi(()=>ri)).subscribe(s)})}),(r=()=>!this.#me.closed,void 0===n&&(n=!1),Bn(function(e,t){var i=0;e.subscribe(Mn(t,function(e){var o=r(e,i++);(o||n)&&t.next(e),!o&&t.complete()}))}))).subscribe(e=>{const{value:t,transaction:r}=e.result,{args:n,key:i,uuid:o}=e.task;this._registerEvent("query_cache_added",i,{data:t,taskId:o,args:n,transaction:r}),this._registerEvent("query_completed",i,{data:t,hasValidCache:!0}),this.#we.setItem(i,{value:t,args:n,transaction:r})}))}query(e,t){return this._query(e,t)}queryAsync(e,t){const{skipResolve:r,...n}=t||{},i=r?Ci:Si;return new Promise((r,o)=>{t?.signal&&t.signal.addEventListener("abort",()=>o(new Error("Query aborted"))),i(this._query(e,n).pipe(Wi())).then(r,o)})}persistentQuery(e,t){const r=this.#Se(e),n=this._query(e,t);return new Fn(i=>{i.add(n.subscribe({next:i.next.bind(i),error:i.error.bind(i)}));const o=t?.cache?.validate||this.#Ce;i.add(this.cache.state$.pipe(Mi(e=>r in e),Ni(t=>({...t[r],key:r,status:"cache",hasValidCache:o(t[r],e)}))).subscribe(i))}).pipe(qi((e,t)=>e.transaction===t.transaction&&e.mutated===t.mutated))}generateCacheKey(e){return this.#Se(e)}mutate(e,t,r){const n=this.#Se(e);if(n in this.cache.state==!1){if(void 0===r?.allowCreation)throw new Error(`Cannot mutate cache item with key ${n}: item not found and option "allowCreation" is false`);if(!1===r.allowCreation)return()=>{};const{value:i}="function"==typeof t?t():t;this.cache.setItem(n,{args:e,transaction:Zo(),value:i})}return this.#we.mutate(n,t)}invalidate(e){this.#we.invalidate(e&&this.#Se(e))}complete(){this.#ve.unsubscribe(),this.#se?.complete()}onInvalidate(e){const t=this.#we.action$.pipe(da("cache/invalidate")).subscribe(t=>e({detail:{item:t.meta.item}}));return()=>t.unsubscribe()}onMutate(e){const t=this.#we.action$.pipe(da("cache/mutate")).subscribe(t=>e({detail:{changes:t.payload,current:t.meta.item}}));return()=>t.unsubscribe()}_query(e,t){const r=this.#Se(e),n=this._createTask(r,e,t);return this._registerEvent("query_created",r,{args:e,options:t}),n}_createTask(e,t,r){return new Fn(n=>{if(r?.signal){if(r?.signal.aborted)return this._registerEvent("query_aborted",e),n.complete();n.add(Fi(r?.signal,"abort").subscribe(()=>{this._registerEvent("query_aborted",e),n.complete()}))}const i=this.#we.getItem(e);if(i){this._registerEvent("query_cache_hit",e,{cacheEntry:i});const o=r?.cache?.suppressInvalid??!1,s=(r?.cache?.validate||this.#Ce)(i,t),a={...i,key:e,status:"cache",hasValidCache:s};if(n.next(a),s||o)return this._registerEvent("query_completed",e,{data:i.value,hasValidCache:s}),n.complete();this._registerEvent("query_cache_miss",e)}const o=e in this.#Le;o?this._registerEvent("query_connected",e,{isExistingTask:!0}):(this.#Le[e]=new Pa(e,t,r),this._registerEvent("query_job_created",e,{taskId:this.#Le[e].uuid,args:t,options:r}));const s=this.#Le[e];n.add(s.subscribe(n)),o||this.#Ie.next(e)})}}class Aa extends Error{retryAt;attempt;constructor(e){const t=Math.max(0,Math.ceil((e.retryAt-Date.now())/1e3));super(`Service discovery is unavailable after ${e.attempt} failed attempt(s); requests are paused for ${t}s`,{cause:e.cause}),this.name="ServiceDiscoveryUnavailableError",this.retryAt=e.retryAt,this.attempt=e.attempt}}const $a=T.object({key:T.string().describe("The key used to identify the service"),uri:T.string().describe("The URI of the service"),id:T.string().optional().describe("The ID of the service"),environment:T.string().optional().describe("The environment of the service"),name:T.string().optional().describe("The name of the service"),scopes:T.array(T.string()).optional().default([]).describe("Endpoint authentication scopes"),tags:T.array(T.string()).optional().describe("Tags for the service")}).describe("A service from the service discovery API").transform(e=>({...e,get defaultScopes(){return e.scopes??[]}})),Ra=T.array($a).describe("A list of services from the service discovery API");class Ta{#De;#Pe;#Ne;#Oe=new zn;diagnostic$=this.#Oe.asObservable();endpoint;http;constructor(e){this.http=e.http,this.endpoint=e.endpoint;const t=e.postProcess;this.#De=new Oa({client:{fn:()=>this.http.fetch$(this.endpoint??"",{selector:e=>((e,t)=>{const r=wi(Ro(e)).pipe(Ni(e=>Ra.default([]).parse(e)));return t?r.pipe(t):r})(e,t)})},key:()=>"services",expire:3e5})}async resolveServices(e){const t=performance.now();if(this.#Pe&&Date.now()<this.#Pe.retryAt)return this.#Ae(new Aa({cause:this.#Pe.error,retryAt:this.#Pe.retryAt,attempt:this.#Pe.attempt}),t,"cooldown");const r=Date.now();let n;try{const t=e?Ci:Si;n=await t(this.#De.query())}catch(e){return this.#$e(e,r),this.#Ae(e,t,"network")}return"complete"===n.status&&(this.#Pe=void 0,this.#Ne={services:n.value,receivedAt:Date.now()}),this.#Re({type:"resolve",outcome:"success",origin:"complete"===n.status?"network":"cache",duration:performance.now()-t}),n.value}#$e(e,t){if(this.#Pe&&this.#Pe.failedAt>=t)return;const r=(this.#Pe?.attempt??0)+1,n=Math.min(3e4,1e3*2**(r-1)),i=Math.round(n*(.8+.2*Math.random())),o=Date.now();this.#Pe={error:e,attempt:r,failedAt:o,retryAt:o+i},1===r&&console.warn("[service-discovery] request failed; pausing requests with backoff (max 30000ms)",e)}#Ae(e,t,r){const n=this.#Ne;if(n&&Date.now()-n.receivedAt<=864e5)return this.#Re({type:"resolve",outcome:"success",origin:"fallback",duration:performance.now()-t}),n.services;throw this.#Re({type:"resolve",outcome:"failure",origin:r,duration:performance.now()-t}),e}#Re(e){try{this.#Oe.next(e)}catch{}}async resolveService(e,t){const r=(await this.resolveServices(t)).find(t=>t.key===e);if(!r)throw this.#Re({type:"unknown-service"}),Error(`Failed to resolve service, invalid key [${e}]`);return r}}class xa extends no{async _createConfig(e,t){if(!e.hasModule("http"))throw new Error("http module is required");if(!this._has("discoveryClient")){(await e.requireInstance("http")).hasClient("service_discovery")&&this.configureServiceDiscoveryClientByClientKey("service_discovery")}return Si(wi(super._createConfig(e,t)))}_processConfig(e,t){if(!e.discoveryClient)throw new Error("discoveryClient is required, please configure it");return super._processConfig(e,t)}setServiceDiscoveryClient(e){this._set("discoveryClient","function"==typeof e?e:async()=>e)}configureServiceDiscoveryClient(e){this.setServiceDiscoveryClient(async t=>{const{httpClient:r,endpoint:n}=await Si(wi(e(t)))??{};if(r)return new Ta({http:r,endpoint:n,postProcess:Ni(e=>{const t="undefined"!=typeof globalThis?globalThis.sessionStorage:void 0;if(!t)return e;try{const r=JSON.parse(t.getItem("overriddenServiceDiscoveryUrls")||"{}");for(const[t,{url:n,scopes:i}]of Object.entries(r)){const r=e.find(e=>e.key===t);r&&(r.uri=n,r.scopes=i,r.overridden=!0)}}catch(e){console.error('Failed to JSON parse session overrides: "overriddenServiceDiscoveryUrls"',e)}return e})});throw Error("httpClient is required")})}configureServiceDiscoveryClientByClientKey(e,t){this.configureServiceDiscoveryClient(async({requireInstance:r})=>({httpClient:(await r("http")).createClient(e),endpoint:t}))}}const ka=x.string().regex(/^[a-z][a-z0-9-]*$/);var Fa,Ua,Ba;!function(e){e[e.Debug=0]="Debug",e[e.Information=1]="Information",e[e.Warning=2]="Warning",e[e.Error=3]="Error",e[e.Critical=4]="Critical"}(Fa||(Fa={})),function(e){e.Event="event",e.Exception="exception",e.Metric="metric",e.Custom="custom"}(Ua||(Ua={})),function(e){e.Framework="framework",e.Application="application"}(Ba||(Ba={}));const Ma=x.object({schemaVersion:x.literal(1),source:ka.optional(),hostId:x.string(),hostName:x.string().optional(),hostVersion:x.string().optional(),module:ka,operation:ka,outcome:x.enum(["success","failure","cancelled"]),occurredAt:x.number().finite().nonnegative(),unit:x.literal("ms"),traceId:x.string().optional(),spanId:x.string().optional(),traceFlags:x.number().int().min(0).max(255).optional()}).strict(),Ga=x.object({name:x.string().describe("The name of the telemetry item."),diagnostic:Ma.optional(),type:x.nativeEnum(Ua).describe("The type of telemetry. Defaults to Custom."),level:x.nativeEnum(Fa).optional().default(Fa.Information).describe("The severity level of the telemetry item. Defaults to Information."),properties:x.record(x.string(),x.unknown()).optional().describe("Optional additional properties for the telemetry item."),metadata:x.record(x.string(),x.unknown()).optional().describe("Optional metadata for the telemetry item."),scope:x.array(x.string()).optional().describe("Optional scope for the telemetry item.").transform(e=>[...new Set(e)])}),ja=Ga.extend({type:x.literal(Ua.Event)});function za(e){return e.source?[e.source,"operational"]:["operational"]}Ga.extend({type:x.literal(Ua.Exception),exception:x.instanceof(Error).describe("The exception object.")}),Ga.extend({type:x.literal(Ua.Metric),value:x.number().describe("The value of the metric.")}),ja.extend({type:x.literal(Ua.Custom)}).passthrough(),ga("telemetry/initialize",(e,t)=>({payload:e,meta:{operation:t}}),()=>({payload:void 0}),e=>({payload:e})),ga("telemetry/dispose",e=>({payload:void 0,meta:{operation:e}}),()=>({payload:void 0}),e=>({payload:e})),ma("telemetry/close"),ma("telemetry/enrichment/started",e=>({payload:{builtIn:e}})),ma("telemetry/enrichment/settled",e=>({payload:{builtIn:e}})),ma("telemetry/processing/started",e=>({payload:e})),ma("telemetry/processing/settled",e=>({payload:e})),ma("telemetry/failed",e=>({payload:e}));const Ha="1.9.1",qa=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const Va=function(e){const t=new Set([e]),r=new Set,n=e.match(qa);if(!n)return()=>!1;const i=+n[1],o=+n[2],s=+n[3];if(null!=n[4])return function(t){return t===e};function a(e){return r.add(e),!1}function c(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(r.has(e))return!1;const n=e.match(qa);if(!n)return a(e);const l=+n[1],u=+n[2],f=+n[3];return null!=n[4]||i!==l?a(e):0===i?o===u&&s<=f?c(e):a(e):o<=u?c(e):a(e)}}(Ha),Wa=Ha.split(".")[0],Za=Symbol.for(`opentelemetry.js.api.${Wa}`),Ka="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function Ya(e,t,r,n=!1){var i;const o=Ka[Za]=null!==(i=Ka[Za])&&void 0!==i?i:{version:Ha};if(!n&&o[e]){const t=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return r.error(t.stack||t.message),!1}if(o.version!==Ha){const t=new Error(`@opentelemetry/api: Registration of version v${o.version} for ${e} does not match previously registered API v${Ha}`);return r.error(t.stack||t.message),!1}return o[e]=t,r.debug(`@opentelemetry/api: Registered a global for ${e} v${Ha}.`),!0}function Xa(e){var t,r;const n=null===(t=Ka[Za])||void 0===t?void 0:t.version;if(n&&Va(n))return null===(r=Ka[Za])||void 0===r?void 0:r[e]}function Ja(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${Ha}.`);const r=Ka[Za];r&&delete r[e]}class Qa{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return ec("debug",this._namespace,e)}error(...e){return ec("error",this._namespace,e)}info(...e){return ec("info",this._namespace,e)}warn(...e){return ec("warn",this._namespace,e)}verbose(...e){return ec("verbose",this._namespace,e)}}function ec(e,t,r){const n=Xa("diag");if(n)return n[e](t,...r)}var tc;!function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"}(tc||(tc={}));class rc{static instance(){return this._instance||(this._instance=new rc),this._instance}constructor(){function e(e){return function(...t){const r=Xa("diag");if(r)return r[e](...t)}}const t=this;t.setLogger=(e,r={logLevel:tc.INFO})=>{var n,i,o;if(e===t){const e=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!==(n=e.stack)&&void 0!==n?n:e.message),!1}"number"==typeof r&&(r={logLevel:r});const s=Xa("diag"),a=function(e,t){function r(r,n){const i=t[r];return"function"==typeof i&&e>=n?i.bind(t):function(){}}return e<tc.NONE?e=tc.NONE:e>tc.ALL&&(e=tc.ALL),t=t||{},{error:r("error",tc.ERROR),warn:r("warn",tc.WARN),info:r("info",tc.INFO),debug:r("debug",tc.DEBUG),verbose:r("verbose",tc.VERBOSE)}}(null!==(i=r.logLevel)&&void 0!==i?i:tc.INFO,e);if(s&&!r.suppressOverrideMessage){const e=null!==(o=(new Error).stack)&&void 0!==o?o:"<failed to generate stacktrace>";s.warn(`Current logger will be overwritten from ${e}`),a.warn(`Current logger will overwrite one already registered from ${e}`)}return Ya("diag",a,t,!0)},t.disable=()=>{Ja("diag",t)},t.createComponentLogger=e=>new Qa(e),t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}}class nc{constructor(e){const t=this;t._currentContext=e?new Map(e):new Map,t.getValue=e=>t._currentContext.get(e),t.setValue=(e,r)=>{const n=new nc(t._currentContext);return n._currentContext.set(e,r),n},t.deleteValue=e=>{const r=new nc(t._currentContext);return r._currentContext.delete(e),r}}}const ic=new nc;const oc="context",sc=new class{active(){return ic}with(e,t,r,...n){return t.call(r,...n)}bind(e,t){return t}enable(){return this}disable(){return this}};class ac{constructor(){}static getInstance(){return this._instance||(this._instance=new ac),this._instance}setGlobalContextManager(e){return Ya(oc,e,rc.instance())}active(){return this._getContextManager().active()}with(e,t,r,...n){return this._getContextManager().with(e,t,r,...n)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Xa(oc)||sc}disable(){this._getContextManager().disable(),Ja(oc,rc.instance())}}var cc;!function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"}(cc||(cc={}));const lc="0000000000000000",uc="00000000000000000000000000000000",fc={traceId:uc,spanId:lc,traceFlags:cc.NONE};class dc{constructor(e=fc){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}}const pc=(hc="OpenTelemetry Context Key SPAN",Symbol.for(hc));var hc;function mc(e){return e.getValue(pc)||void 0}function gc(){return mc(ac.getInstance().active())}function vc(e,t){return e.setValue(pc,t)}function yc(e){return e.deleteValue(pc)}function Ec(e,t){return vc(e,new dc(t))}function bc(e){var t;return null===(t=mc(e))||void 0===t?void 0:t.spanContext()}const wc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Ic(e,t){if("string"!=typeof e||e.length!==t)return!1;let r=0;for(let t=0;t<e.length;t+=4)r+=(0|wc[e.charCodeAt(t)])+(0|wc[e.charCodeAt(t+1)])+(0|wc[e.charCodeAt(t+2)])+(0|wc[e.charCodeAt(t+3)]);return r===t}function Lc(e){return Ic(r=e.traceId,32)&&r!==uc&&(Ic(t=e.spanId,16)&&t!==lc);var t,r}function Sc(e){return new dc(e)}const Cc=ac.getInstance();class _c{startSpan(e,t,r=Cc.active()){if(Boolean(null==t?void 0:t.root))return new dc;const n=r&&bc(r);return null!==(i=n)&&"object"==typeof i&&"spanId"in i&&"string"==typeof i.spanId&&"traceId"in i&&"string"==typeof i.traceId&&"traceFlags"in i&&"number"==typeof i.traceFlags&&Lc(n)?new dc(n):new dc;var i}startActiveSpan(e,t,r,n){let i,o,s;if(arguments.length<2)return;2===arguments.length?s=t:3===arguments.length?(i=t,s=r):(i=t,o=r,s=n);const a=null!=o?o:Cc.active(),c=this.startSpan(e,i,a),l=vc(a,c);return Cc.with(l,s,void 0,c)}}const Dc=new _c;class Pc{constructor(e,t,r,n){this._provider=e,this.name=t,this.version=r,this.options=n}startSpan(e,t,r){return this._getTracer().startSpan(e,t,r)}startActiveSpan(e,t,r,n){const i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;const e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Dc}}const Nc=new class{getTracer(e,t,r){return new _c}};class Oc{getTracer(e,t,r){var n;return null!==(n=this.getDelegateTracer(e,t,r))&&void 0!==n?n:new Pc(this,e,t,r)}getDelegate(){var e;return null!==(e=this._delegate)&&void 0!==e?e:Nc}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,r){var n;return null===(n=this._delegate)||void 0===n?void 0:n.getTracer(e,t,r)}}const Ac=ac.getInstance(),$c="trace";class Rc{constructor(){this._proxyTracerProvider=new Oc,this.wrapSpanContext=Sc,this.isSpanContextValid=Lc,this.deleteSpan=yc,this.getSpan=mc,this.getActiveSpan=gc,this.getSpanContext=bc,this.setSpan=vc,this.setSpanContext=Ec}static getInstance(){return this._instance||(this._instance=new Rc),this._instance}setGlobalTracerProvider(e){const t=Ya($c,this._proxyTracerProvider,rc.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return Xa($c)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Ja($c,rc.instance()),this._proxyTracerProvider=new Oc}}const Tc=Rc.getInstance();function xc(e){const{source:t,module:r,operation:n,outcome:i}=e;if([t.source,r,n].some(e=>void 0!==e&&!ka.safeParse(e).success))throw new RangeError("Invalid operational telemetry identifier");const o=Tc.getSpanContext(Ac.active());return{...t,schemaVersion:1,module:r,operation:n,outcome:i,occurredAt:Date.now(),unit:"ms",...o?{traceId:o.traceId,spanId:o.spanId,traceFlags:o.traceFlags}:{}}}const kc={debug:Fa.Debug,information:Fa.Information,warning:Fa.Warning,error:Fa.Error,critical:Fa.Critical};function Fc(e){let t=!1;return r=>{try{const t=e();if(!t)return;if(!t.source)throw new Error("Operational telemetry requires host source identity");const n=t.source;if("notification"in r)return void t.trackEvent({name:`fusion.${r.module}.${r.operation}`,level:("string"==typeof r.level?kc[r.level]:r.level)??("failure"===r.outcome?Fa.Error:Fa.Information),scope:za(n),diagnostic:xc({...r,source:n}),...r.properties?{properties:{...r.properties}}:{}});for(const e of function(e){if(!Number.isFinite(e.duration)||e.duration<0)throw new RangeError("Invalid operational telemetry duration");const t=xc(e),r=`fusion.${e.module}.${e.operation}`,n={name:`${r}.duration`,type:Ua.Metric,level:Fa.Information,value:e.duration,scope:za(e.source),diagnostic:t,...e.properties?{properties:{...e.properties}}:{}};if("failure"!==e.outcome)return[n];const i=new Error(`${r} failed`);return i.name="OperationalError",i.stack=void 0,[n,{name:`${r}.failure`,type:Ua.Exception,level:Fa.Error,exception:Object.freeze(i),scope:n.scope,diagnostic:t,...e.properties?{properties:{...e.properties}}:{}}]}({...r,source:n}))t.track(e)}catch{t||(t=!0,console.warn("Operational telemetry delivery failed"))}}}const Uc={cancellations:new WeakSet,reasons:new WeakMap};function Bc(e){let t,r=e;for(let e=0;e<5&&r&&"object"==typeof r;e++){if(t??=Uc.reasons.get(r),Uc.cancellations.has(r))return{outcome:"cancelled",reason:t};r="cause"in r?r.cause:void 0}return{outcome:"failure",reason:t}}function Mc(e,t){return Uc.cancellations.add(e),t&&Uc.reasons.set(e,t),e}function Gc(e,t){return Uc.reasons.set(e,t),e}const jc=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,zc=/^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/;function Hc(e,t="key"){return"string"==typeof e&&("key"===t?jc:zc).test(e)?e:void 0}const qc=()=>{};class Vc{module;options;parent;classifyError=Bc;markCancellation=Mc;markReason=Gc;safeIdentity=Hc;#Te=new Set;#xe=new Set;#ke=[];#Fe;#Ue=!1;#Be=!1;#Me;constructor(e,t,r){this.module=e,this.options=t,this.parent=r,this.#Me=Fc(()=>this.#Ge())}get connected(){return this.active}get active(){return void 0!==this.#Ge()}get pending(){return this.#Te.size}connect=e=>{this.#Ue||(this.#Fe=e)};disconnect=()=>{this.close()};report=e=>{this.#Me({...e,module:this.module})};createScope(e){const t=new Vc(this.module,e,this);return this.#Ue&&t.close(),t}start(e,t){return this.reserve(e,t)??qc}reserve(e,t){if(!this.active)return;if(this.#Te.size>=256)return void this.#je("pending-operation capacity exceeded");const r=performance.now(),n=(i,o)=>{if(this.#Te.delete(n)){this.#ze();try{const n={...t,...this.options?.identity?.(),...o};this.report({operation:e,outcome:i,duration:Math.max(0,performance.now()-r),...Object.keys(n).length?{properties:n}:{}})}catch{this.#je("identity resolution failed")}}};return this.#Te.add(n),this.#He(),n}measure(e,t){return r=>{return n=()=>{const n=this.reserve(e,t);if(!n)return r;let i=!1;return r.pipe(eo({next:()=>{i=!0},error:e=>{const{outcome:t,reason:r}=Bc(e);n(t,r?{reason:r}:void 0)},complete:()=>n("success")}),Ki(()=>n(i?"success":"cancelled")))},new Fn(function(e){hi(n()).subscribe(e)});var n}}notify(e,t,r){this.report({operation:e,outcome:t,properties:r,notification:!0,level:"failure"===t?Fa.Warning:Fa.Information})}own(e){this.#qe()?this.#Ve(e):(this.#ke.push(e),this.#He())}cancelPending(e){for(const t of[...this.#Te])t("cancelled",e)}close(e){if(this.#Ue)return;for(const t of[...this.#xe])t.close(e);this.cancelPending(e),this.#Ue=!0,this.#Fe=void 0,this.parent&&(this.parent.#xe.delete(this),this.parent.#ze());const t=this.#ke;this.#ke=[];for(const e of t)this.#Ve(e)}#Ge(){if(!this.#Ue)return this.parent?this.parent.#Ge():this.#Fe}#qe(){return this.#Ue||!!this.parent&&this.parent.#qe()}#He(){this.parent&&(this.parent.#xe.add(this),this.parent.#He())}#ze(){this.#Te.size||this.#xe.size||this.#ke.length||this.parent&&(this.parent.#xe.delete(this),this.parent.#ze())}#Ve(e){try{"function"==typeof e?e():e.unsubscribe()}catch{this.#je("diagnostic teardown failed")}}#je(e){this.#Be||(this.#Be=!0,console.warn(`Operational telemetry for ${this.module}: ${e}`))}}class Wc extends uo{config;_http;constructor(e,t){super({version:"10.3.0-next.1",config:e}),this.config=e,this._http=t,this._addTeardown(()=>{this.#We?.unsubscribe(),this.#Ze.disconnect()})}#Ze=function(e,t){if(!ka.safeParse(e).success)throw new RangeError("Invalid operational telemetry module");return new Vc(e,t)}("service-discovery");#We;connectTelemetry(e){this.#Ze.connect(e);const t=this.client.diagnostic$;if(this.#We||!this.#Ze.connected||!t)return;const r=this.#Ze.report;this.#We=t.subscribe(e=>{if("unknown-service"===e.type)return void r({notification:!0,operation:"unknown-service",outcome:"failure",level:Fa.Warning});const{outcome:t,origin:n,duration:i}=e;"cache"!==n?(r({operation:"resolve",outcome:t,duration:i}),"network"!==n&&r({notification:!0,operation:n,outcome:t,level:Fa.Warning})):r({notification:!0,operation:"cache-hit",outcome:t,level:Fa.Debug})})}get client(){return this.config.discoveryClient}resolveServices(){return this.config.discoveryClient.resolveServices()}async resolveService(e){return this.config.discoveryClient.resolveService(e)}async createClient(e,t){const r=await this.resolveService(e);if(!r)throw Error(`Could not load configuration of service [${e}]`);return this._http.createClient({...t,baseUri:r.uri,defaultScopes:r.scopes})}async configureClient(e,t){const{key:r,alias:n}="string"==typeof e?{key:e,alias:e}:e,{uri:i,scopes:o}=await this.resolveService(r);var s,a;t.addConfig((s=n,a={baseUri:i,defaultScopes:o},{module:Fo,configure:e=>{e.configureClient(s,a)}}))}}const Zc=new WeakMap,Kc={name:"serviceDiscovery",configure:()=>new xa,initialize:async e=>{const{requireInstance:t,ref:r}=e,n=await e.config.createConfigAsync(e,{...r?.serviceDiscovery?.config}),i=await t("http"),o=new Wc(n,i);return Zc.set(o,o),o},postInitialize:async({instance:e,modules:t,ref:r})=>{e.client!==r?.serviceDiscovery?.client&&e.connectTelemetry?.(t.telemetry)},dispose:({instance:e})=>{Zc.get(e)?.dispose(),Zc.delete(e)}},Yc=(e,t)=>{e.addConfig((e=>({module:Kc,configure:t=>e(t)}))(()=>Promise.resolve()))};var Xc,Jc,Qc,el={},tl=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}];function rl(){return Xc||(Xc=1,function(e){const t=tl,r=process.env;function n(e){return"string"==typeof e?!!r[e]:"env"in e?r[e.env]&&r[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!r[e]}):Object.keys(e).every(function(t){return r[t]===e[t]})}Object.defineProperty(e,"_vendors",{value:t.map(function(e){return e.constant})}),e.name=null,e.isPR=null,e.id=null,"false"!==r.CI&&t.forEach(function(t){const i=(Array.isArray(t.env)?t.env:[t.env]).every(function(e){return n(e)});e[t.constant]=i,i&&(e.name=t.name,e.isPR=function(e){switch(typeof e.pr){case"string":return!!r[e.pr];case"object":return"env"in e.pr?"any"in e.pr?e.pr.any.some(function(t){return r[e.pr.env]===t}):e.pr.env in r&&r[e.pr.env]!==e.pr.ne:"any"in e.pr?e.pr.any.some(function(e){return!!r[e]}):n(e.pr);default:return null}}(t),e.id=t.constant)}),e.isCI=!("false"===r.CI||!(r.BUILD_ID||r.BUILD_NUMBER||r.CI||r.CI_APP_ID||r.CI_BUILD_ID||r.CI_BUILD_NUMBER||r.CI_NAME||r.CONTINUOUS_INTEGRATION||r.RUN_ID||e.name))}(el)),el}var nl,il=V(Qc?Jc:(Qc=1,Jc=rl().isCI));!function(e){e.ContinuesIntegration="ci",e.QualityAssurance="fqa",e.Training="tr",e.Production="fprd",e.Development="dev"}(nl||(nl={}));const ol=["5a842df8-3238-415d-b168-9f16a6a6031b/.default"],sl=e=>{const t=new yo,r=e.env??nl.ContinuesIntegration;t.addConfig({module:Fo,configure:t=>{const n=r===nl.Development?nl.ContinuesIntegration:r,i=e.serviceDiscovery?.url??new URL(`/service-registry/environments/${n}/services`,"https://discovery.fusion.equinor.com").toString(),o=e.serviceDiscovery?.scope??ol;t.defaultHttpRequestHandler.set("fusion-cli-identification",xr),t.configureClient("service_discovery",{baseUri:i,defaultScopes:o})}}),Yc(t);const{auth:n}=e;return q(t,e=>{if("defaultCredential"in n&&n.defaultCredential)return void e.setDefaultCredential();if("token"in n&&n.token)return void e.setTokenOnly(n.token);const{clientId:t,tenantId:r}=n;if(!t||!r)throw new Error("clientId and tenantId are required for auth module");if("interactive"in n&&n.interactive){const{server:i}=n;if(!i.port)throw new Error("server.port is required for interactive mode");return void e.setInteractive({tenantId:r,clientId:t,redirectPort:i.port,onOpen:i.onOpen})}il?e.setDefaultCredential():e.setInteractive({tenantId:r,clientId:t,redirectPort:49741})}),t},al=async(e,t)=>{const r=sl(e);t&&t(r);return await r.initialize()},cl=e=>{const t=e.getEntry("metadata.json");if(!t)throw new Error("Metadata file not found in bundle");return new Promise((e,r)=>{t.getDataAsync((t,n)=>{if(n)return r(new Error("Failed to read metadata file",{cause:n}));try{return e(JSON.parse(String(t)))}catch(e){r(new Error("Failed to parse metadata file",{cause:e}))}})})},ll=async e=>{const{log:t,bundle:r}=e;let n;if(r)try{t?.info("🗜ïļ","Using artifact-based validation from bundle:",r);const e=new yr(r),i=await(async e=>{const t=await cl(e);if(!t.appKey||"string"!=typeof t.appKey||""===t.appKey.trim())throw new Error("App manifest is missing required appKey field");return t})(e);n=i.appKey,t?.info("ðŸ“Ķ",`Resolved app key "${n}" from bundle artifact`)}catch(e){return t?.fail("ðŸšŦ","Failed to resolve app information from bundle:",e instanceof Error?e.message:String(e)),!1}else{t?.info("📁","Using traditional validation from local project files");const e=await _t(t);n=(await Ct({command:"build",mode:"production"},e,{log:t})).appKey}t?.start("Initializing Fusion Framework...");const i=await al({env:e.environment,auth:"token"in e.auth?{token:e.auth.token}:e.auth});t?.succeed("Initialized Fusion Framework");try{const e=await i.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)}),t?.info("Checking if",n,"is registered in app store");const r=await e.fetch(`/apps/${n}`,{method:"HEAD",headers:Tr});if(r.ok)return t?.succeed("😃",`Application ${n} is registered in app store`),!0;if(404===r.status)return t?.fail("😞",`Application ${n} is not registered in app store`),!1;if(410===r.status)return t?.fail("😞",`Application ${n} is deleted from app store`),!1;const o=Mr(r.status,`check registration for ${n}`);throw o&&(t?.fail("🔒",`Authentication/authorization error checking ${n}`),t?.error(o),process.exit(1)),new Error(`Unexpected response status: ${r.status}`)}catch(e){const r=zr(e,`check registration for ${n}`);return r&&(t?.fail("🔒",`Token acquisition failed checking ${n}`),t?.error(r),process.exit(1)),t?.fail("🙅‍♂ïļ","Error checking application registration"),t?.error("Error checking application registration:",e instanceof Error?e.message:e),!1}},ul=x.object({error:x.object({code:x.string(),message:x.string(),resourceIdentifier:x.string().optional()})});const fl=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new yr(e.fileOrBundle):e.fileOrBundle,{appKey:o}=e.appKey?{appKey:e.appKey}:await cl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)});t?.info("ðŸ“Ķ",`Uploading application bundle for ${i.bold(o)}`);const s=(await n.getEntries()).map(e=>e.entryName);t?.debug("Bundle contents:",s);const a=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const s=await r.serviceDiscovery.createClient("apps");s.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const c=await s.fetch(`/bundles/apps/${o}`,{method:"POST",body:new Blob([a],{type:"application/zip"}),headers:{...Tr,"Content-Type":"application/zip"}});if(!c.ok){let r;try{const e=ul.safeParse(await c.json());if(e.success){r=e.data;const{error:n}=r;t?.debug("Error:",n),t?.warn(i.red(`ðŸĪŊ error: ${n.code}\n`),i.yellowBright(n.message),"\n")}else t?.debug("Unrecognized upload error response:",e.error)}catch(e){t?.debug("Failed to parse upload error response:",e)}if(!0===e.allowExistingVersion&&409===c.status&&"ConflictError"===r?.error.code&&"version"===r.error.resourceIdentifier){const e=n.getEntry("app-manifest.json");if(!e)throw new Error("Cannot recover existing version: app-manifest.json is missing");const t=x.object({version:x.string().refine(e=>null!==R(e))}).parse(JSON.parse(e.getData().toString())).version.toLowerCase();if("string"!=typeof o||!o.trim())throw new Error("Cannot recover existing version: application key is missing");if(r.error.message===`An app build with version ${t} already exists`)return{appKey:o,version:t,existingVersion:!0}}!function(e,t,r){const n=Mr(e.status,`upload bundle for ${t}`);let i;switch(n&&(r?.fail("🔒",`Authentication/authorization error uploading ${t}`),r?.error(n),process.exit(1)),e.status){case 409:i=`${e.status} - Version is already published, please generate a new release`;break;case 410:i=`${e.status} - ${t} is removed from Fusion app store`;break;case 404:i=`${e.status} - ${t} not found, please add your application in App Admin before publishing`;break;case 500:i=`${e.status} - Internal server error, please try again later or contact support`;break;default:i=`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`}r?.fail("🙅‍♂ïļ",i),process.exit(1)}(c,o,t)}t?.succeed("Successfully uploaded application bundle"),t?.debug("Response:",c);try{return{appKey:o,version:(await c.json()).version}}catch(e){t?.fail("🙅‍♂ïļ",`Failed to parse response from app service: ${e instanceof Error?e.message:e}`),process.exit(1)}}catch(e){const r=zr(e,`upload bundle for ${o}`);r&&(t?.fail("🔒",`Token acquisition failed uploading ${o}`),t?.error(r),process.exit(1)),t?.fail("🙅‍♂ïļ","Failed to upload application bundle"),t?.error(e instanceof Error?e.message:e),process.exit(1)}},dl=async e=>{const{tag:t,appKey:r,version:n,framework:o,log:s}=e;t&&"string"==typeof t&&0!==t.trim().length||(s?.fail("ðŸĪŠ","Tag must be a non-empty string."),process.exit(1)),/^[a-zA-Z0-9.-]+$/.test(t)||(s?.fail("ðŸĪŠ",'Invalid tag. Use "latest", "preview" or string [a-z, A-Z, 0-9, ".", "-"].'),process.exit(1)),r||(s?.fail("ðŸĪŠ","Application key is required."),process.exit(1)),n||(s?.fail("ðŸĪŠ","Version is required."),process.exit(1));try{const e=await o.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{s?.debug("Request:",e),s?.info("🌎","Executing request to:",St(e.uri))}),s?.start("Publishing application config");const a=await e.json(`/apps/${r}/tags/${t}`,{method:"PUT",body:{version:n},headers:Tr});return s?.debug("Response:",a),s?.succeed("Tagged application successfully",i.greenBright(`${r}@${n} - ${t}`)),a}catch(e){if(e instanceof Xr)switch(e.response.status){case 410:s?.fail("ðŸĪŽ",`App ${r} is deleted from apps-service. Please check the app key and try again.`);break;case 404:s?.fail("ðŸĪŽ",`App ${r} not found. Please check the app key and try again.`);break;case 403:case 401:{const t=Mr(e.response.status,`tag ${r}@${n}`);s?.fail("🔒","Authentication/authorization error tagging application."),t&&s?.error(t),process.exit(1);break}default:s?.fail("ðŸĪŽ","Failed to tag application",`Status code: ${e.response.status}`,`Error: ${e.message}`)}const t=zr(e,`tag ${r}@${n}`);t&&(s?.fail("🔒",`Token acquisition failed tagging ${r}@${n}`),s?.error(t),process.exit(1)),s?.fail("ðŸĪŽ","Failed to tag application:",e instanceof Error?e.message:String(e)),process.exit(1)}},pl=x.object({templateEntry:x.string({message:"templateEntry must be a string"}).describe("Main entry point for the portal"),schemaEntry:x.string({message:"schemaEntry must be a string"}).describe("Schema file for portal validation"),assetPath:x.string({message:"assetPath must be a string"}).optional().describe("Asset path for dev/preview builds"),githubRepo:x.string({message:"githubRepo must be a string"}).optional().describe("GitHub repo URL or local git remote"),version:x.string({message:"version must be a string"}).describe("Version from package.json"),timestamp:x.string({message:"timestamp must be a string"}).describe("Current build timestamp (ISO8601)"),commitSha:x.string({message:"commitSha must be a string"}).describe("Current git commit SHA"),annotations:x.record(x.string(),x.string().nullish()).optional().transform(e=>{if(!e)return;const t=Object.entries(e).filter(([,e])=>void 0!==e);return Object.fromEntries(t)}).describe("Optional build annotations"),projectPage:x.string({message:"projectPage must be a string"}).optional().describe("Optional project homepage"),allowedExtensions:x.array(x.string({message:"Each allowed extension must be a string"}),{message:"allowedExtensions must be an array of strings"}).describe("List of allowed asset extensions (with leading dot)"),schema:x.record(x.string(),x.unknown()).optional().describe("Optional schema for the portal"),config:x.record(x.string(),x.unknown()).optional().describe("Optional configuration for the portal")}),hl=x.object({name:x.string({message:"name must be a string"}).describe("Short app key (unscoped, derived from package name)"),displayName:x.string({message:"displayName must be a string"}).optional().describe("Full package name, may include scope"),description:x.string({message:"description must be a string"}).optional().describe("Description of the portal"),build:pl}),ml=(e,t)=>{dt(t,"expected packageJson"),P(t.name,"expected [name] in packageJson"),P(t.version,"expected [version] in packageJson");const r=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/bundle.js":lt(e.root))(e,t),n=t.name.replace(/^@|\w.*\//gm,""),i=t.version,o="build"===e.command?void 0:"/@fs",s=pt(t)??ht(),a=bt.map(e=>`.${e}`),c={name:n,displayName:t.name,description:t.description||"",build:{templateEntry:r,schemaEntry:"portal.schema.json",assetPath:o,githubRepo:s,version:i,timestamp:(new Date).toISOString(),commitSha:mt(),annotations:{...Et()},projectPage:t.homepage,allowedExtensions:a}},l=hl.safeParse(c);if(!l.success){const e=l.error.issues.map(e=>`- ${e.path.join(".")}: ${e.message}`).join("\n");throw new Error(["Invalid portal manifest generated from package.json:",e].join("\n"))}return l.data},gl=async(e,t,r)=>{const n=ml(e,t.packageJson);try{r?.log?.start("loading manifest...");const t=await(async(e,t)=>{const r=t?.file??[`portal.manifest.${e.environment}`,"portal.manifest"],n=await L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};let i;return i="function"==typeof r.default?await r.default(e,{base:n})??void 0:r.default,i?C(n,i):n}}}),i=n.config,o=hl.safeParse(i);if(!o.success){const e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");throw new Error(`Invalid portal manifest: ${e}`)}return{manifest:i,path:n.path,extension:n.extension}})(e,{base:n});return r?.log?.succeed("generated manifest from",St(t.path,{relative:!0})),t.manifest}catch(e){if(e instanceof S){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${St(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(i.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?St(r?.manifestPath):""}`),e}},vl=async(e,t)=>{const{log:r}=t;try{r?.start("create portal configuration"),r?.info(`generating config with ${i.red.dim(e.command)} command in ${i.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`portal.config.${e.environment}`,"portal.config"];return L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.schema??T.object({}).passthrough(),i=t?.base??{};if("function"==typeof r.default){const t=await r.default(i,e)??i;return n.parse(t)}return n.parse(r.default??i)}}})})(e,{file:t?.config});return r?.succeed("⚙ïļ generated config from ",St(n.path,{relative:!0})),n.config}catch(e){if(e instanceof S){if(!t.config)return r?.succeed(i.dim("⚙ïļ no local portal config applied, using built-in")),{};r?.warn(`failed to load config file ${St(t.config)}, please check the path.`)}throw r?.fail("failed to resolve portal config"),r?.debug(e),e}},yl=async e=>{const{log:r}=e??{},n=await _t(r),i={root:n.root,environment:"local",...e?.env,mode:"development",command:"serve"},o=await gl(i,n,{log:r,manifestPath:e?.manifest}),s=await vl(i,{log:r,config:e?.config}),a=t(await ft(i,n),{server:{port:e?.server?.port,fs:{allow:[n.root]}}}),c={template:{portal:{id:o.name}},portal:{manifest:o,config:s}};r?.debug("vite config:",a),r?.debug("dev server config:",c),r?.start("Starting app development server...");const l=await $r(i,c,{overrides:a,log:r});return await l.listen(),r?.succeed(`Started app development server on ${l.resolvedUrls?.local?.[0]}`),l},El=async e=>{const{log:r,dir:n,port:i=4173,host:o="localhost"}=e??{};r?.log("Starting to serve portal");const s=await _t(r);r?.start("Loading Vite config...");const c=await ft({root:s.root,command:"build",mode:"production"},s);r?.succeed("Vite config loaded");const l=n||(c.build?.outDir||"dist"),u=a(s.root,l),f={root:s.root,environment:"local",mode:"production",command:"serve",isPreview:!0},d=await gl(f,s,{log:r,manifestPath:e?.manifest}),p=await vl(f,{log:r,config:e?.config});if(r?.debug("Output directory:",u),!b(u))throw new Error(`Build directory does not exist: ${u}\nPlease build the portal first using \`ffc portal build\``);d.build.assetPath=void 0,d.build.templateEntry=`/${d.build.templateEntry}`;const h=await ft(f,s),m=t(h,{server:{port:i,host:o||h.server?.host||"localhost",fs:{allow:[s.root,u]}}}),g={template:{portal:{id:d.name}},portal:{manifest:d,config:p}};r?.debug("vite config:",m),r?.debug("dev server config:",g),r?.start("Starting preview server...");try{const e=await $r(f,g,{overrides:m,log:r});await e.listen(),r?.succeed("Preview server started successfully");const t=e.config.server?.https?"https":"http",n=e.config.server?.host||o,s=e.config.server?.port||i;return r?.info(`Preview server is running at: ${t}://${n}:${s}`),e}catch(e){throw r?.fail("Failed to start preview server"),e}},bl=async e=>{const{log:t}=e??{},r=await _t(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await gl(n,r,{log:t,manifestPath:e?.manifest});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},wl=async e=>{const{log:t}=e??{};t?.log(i.bold("Starting to build portal"));const{manifest:n,pkg:o,env:s}=await bl({log:t,manifest:e?.manifest});t?.start("loading vite config...");const a=await ft(s,o);t?.succeed("vite config applied"),t?.debug("vite config:",a),t?.start("ðŸĪžðŸŧ","building portal..."),t?.startNativeConsoleCapture(),await r(a),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:o,manifest:n,outDir:a.build.outDir}},Il=async e=>{const{log:t,manifest:r}=e,n={command:"build",mode:process.env.NODE_ENV??"production",environment:null,root:process.cwd()},{pkg:i,manifest:o}=await wl({log:t,manifest:r});if(!o.build)throw new Error("Manifest build config not found");const s=await(async(e,t)=>{const r=t?.file??[`portal.schema.${e.environment}`,"portal.schema"],n=await L(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async t=>{const r="function"==typeof t.default?await Promise.resolve(t.default(e)):t.default;if(!r)throw new Error("Schema function did not return a valid schema");return r}}});return{schema:n.config,path:n.path,extension:n.extension}})(n,{file:e?.schema});t?.debug("Schema:",s);return{archive:await Vr(i,{log:t,archive:e?.archive,content:{"portal-template-manifest.json":JSON.stringify(o.build,null,2),"portal.schema.json":JSON.stringify(s.schema,null,2),"metadata.json":JSON.stringify({name:o.name,version:o.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:o,schema:s.schema}},Ll=async e=>{const{log:t}=e??{},r=await _t(t),n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env},i=await vl(n,{log:t,config:e?.config});if(t?.debug("config:",i),e?.output){t?.start("writing config to file");try{await Hr(e.output,JSON.stringify(i,null,2)),t?.succeed("config written successfully",St(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:i,pkg:r}},Sl=async e=>{const{log:t,portal:r}=e,{config:n}=await Ll({log:t,config:e.config,env:{environment:e.environment}});t?.start("Initializing Fusion Framework...");const o=await al({env:e.environment,auth:e.auth});t?.succeed("Initialized Fusion Framework");try{const s=await o.serviceDiscovery.createClient("portals");s.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",St(e.uri))}),t?.start("Publishing portal config"),t?.info("Using environment:",i.redBright(e.environment));const a=await s.json(`/portals/${r.name}@${r.version}/config`,{method:"PUT",body:n,headers:Tr});t?.debug("Response:",a),t?.succeed("Published portal config")}catch(e){if(e instanceof Xr)switch(e.response.status){case 410:t?.fail("ðŸĪŽ",`Portal ${r.name} is deleted from portals-service. Please check the portal key and try again.`);break;case 404:t?.fail("ðŸĪŽ",`Portal ${r.name} not found. Please check the portal key and try again.`);break;case 403:case 401:{const n=Mr(e.response.status,`publish config for portal ${r.name}`);t?.fail("🔒","Authentication/authorization error publishing portal config."),n&&t?.error(n),process.exit(1);break}default:t?.fail("ðŸĪŽ","Failed to publish portal config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}const n=zr(e,`publish config for portal ${r.name}`);n&&(t?.fail("🔒",`Token acquisition failed publishing config for ${r.name}`),t?.error(n),process.exit(1)),t?.fail("ðŸĪŽ","Failed to publish portal config:",e instanceof Error?e.message:String(e)),process.exit(1)}};const Cl=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new yr(e.fileOrBundle):e.fileOrBundle,{name:o}=e.name?{name:e.name}:await cl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)}),s=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const e=await r.serviceDiscovery.createClient("portal-config");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const n=await e.fetch(`/bundles/templates/${o}`,{method:"POST",body:new Blob([s],{type:"application/zip"}),headers:{...Tr,"Content-Type":"application/zip"}});if(!n.ok){try{const{error:e}=await n.json();t?.debug("Error:",e),e.message&&t?.warn(i.red(`ðŸĪŊ error: ${e.code}\n`),i.yellowBright(e.message),"\n")}catch(e){t?.debug("Error:",n.statusText)}!function(e,t,r){const n=Mr(e.status,`upload portal bundle for ${t}`);let i;switch(n&&(r?.fail("🔒",`Authentication/authorization error uploading ${t}`),r?.error(n),process.exit(1)),e.status){case 409:i=`${e.status} - Version is already published, please generate a new release`;break;case 410:i=`${e.status} - ${t} is removed from Fusion`;break;case 404:i=`${e.status} - ${t} not found`;break;case 500:i=`${e.status} - Internal server error, please try again later or contact support`;break;default:i=`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`}r?.fail("🙅‍♂ïļ",i),process.exit(1)}(n,o,t)}t?.succeed("Successfully uploaded portal bundle"),t?.debug("Response:",n)}catch(e){const r=zr(e,`upload portal bundle for ${o}`);r&&(t?.fail("🔒",`Token acquisition failed uploading ${o}`),t?.error(r),process.exit(1)),t?.fail("🙅‍♂ïļ","Failed to upload portal bundle"),t?.error(e instanceof Error?e.message:e),process.exit(1)}},_l=async e=>{const{tag:t,name:r,version:n,framework:o,log:s}=e;t&&"string"==typeof t&&0!==t.trim().length||(s?.fail("ðŸĪŠ","Tag must be a non-empty string."),process.exit(1)),/^[a-zA-Z0-9.-]+$/.test(t)||(s?.fail("ðŸĪŠ",'Invalid tag. Use "latest", "preview" or string [a-z, A-Z, 0-9, ".", "-"].'),process.exit(1)),r||(s?.fail("ðŸĪŠ","Portal name is required."),process.exit(1)),n||(s?.fail("ðŸĪŠ","Version is required."),process.exit(1)),s?.info("Tagging portal:",i.greenBright(`${r}@${t}`,n));try{const e=await o.serviceDiscovery.createClient("portal-config");e.request$.subscribe(e=>{s?.debug("Request:",e),s?.info("🌎","Executing request to:",St(e.uri))}),s?.start("Tagging portal template...");const i=await e.json(`/templates/${r}/tags/${t}`,{method:"PUT",body:{version:n},headers:Tr});s?.debug("Response:",i),s?.succeed("Tagged portal template successfully"),s?.info("🚀",JSON.stringify(i))}catch(e){if(e instanceof Xr){const{data:t,response:o}=e;switch(s?.debug("Error:",t),t&&s?.warn(i.red(`ðŸĪŊ error: ${t.code}\n`),i.yellowBright(t.message),"\n"),o?.status){case 410:s?.fail(`ðŸĪŽ - ${o?.status} -`,`${r} is deleted. Please check the name and try again.`);break;case 404:s?.fail(`ðŸĪŽ - ${o?.status} -`,`${r} not found. Please check the name and try again.`);break;case 403:case 401:{const e=Mr(o?.status??401,`tag portal ${r}@${n}`);s?.fail("🔒","Authentication/authorization error tagging portal."),e&&s?.error(e),process.exit(1);break}default:s?.fail(`ðŸĪŽ - ${o?.status} -`,"Failed to tag",`Error: ${e.message}`)}}const t=zr(e,`tag portal ${r}@${n}`);t&&(s?.fail("🔒",`Token acquisition failed tagging ${r}@${n}`),s?.error(t),process.exit(1)),s?.fail("ðŸĪŽ","Failed to tag portal:",e instanceof Error?e.message:String(e)),process.exit(1)}},Dl=e=>e&&!il?nl.Development:nl.ContinuesIntegration;export{Nr as ConsoleLogger,nl as FusionEnv,Pt as buildApplication,wl as buildPortal,Wr as bundleApp,Il as bundlePortal,ll as checkApp,sl as configureFramework,Tr as defaultHeaders,Kr as generateApplicationConfig,Ll as generatePortalConfig,al as initializeFramework,Dt as loadAppManifest,bl as loadPortalManifest,Vr as pack,en as publishAppConfig,Sl as publishPortalConfig,Dl as resolveDefaultEnv,rn as serveApplication,El as servePortal,tn as startAppDevServer,yl as startPortalDevServer,dl as tagApplication,_l as tagPortal,fl as uploadApplication,Cl as uploadPortalBundle};