@gjsify/example-node-express-webserver 0.4.30 → 0.4.31

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/dist/index.gjs.js CHANGED
@@ -2,8 +2,8 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,globalThis.process===void 0){l
2
2
  `)}else if(me){let n=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...t);e===`stderr`?printerr(n):print(n)}else{let n=globalThis.console;e===`stderr`?n.error(...t):n.log(...t)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,t){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...t){e||this.error(`Assertion failed:`,...t)}clear(){this._stdout?this._stdout.write(`\x1Bc`):me?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let t=(this._counters.get(e)||0)+1;this._counters.set(e,t),this.log(`${e}: ${t}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(e,t){this._stdout?this._write(`stdout`,e):me?print(JSON.stringify(e,null,2)):globalThis.console.table(e,t)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let t=this._timers.get(e);t===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-t}ms`),this._timers.delete(e))}timeLog(e=`default`,...t){let n=this._timers.get(e);n===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-n}ms`,...t)}trace(...e){let t=Error().stack?.split(`
3
3
  `).slice(1).join(`
4
4
  `)||``;this._write(`stderr`,`Trace:`,...e,`
5
- `+t)}profile(e){}profileEnd(e){}timeStamp(e){}},P=new Console,log=(...e)=>P.log(...e),info=(...e)=>P.info(...e),debug=(...e)=>P.debug(...e),warn=(...e)=>P.warn(...e),error=(...e)=>P.error(...e),dir=(e,t)=>P.dir(e,t),dirxml=(...e)=>P.dirxml(...e),table=(e,t)=>P.table(e,t),clear=()=>P.clear(),assert=(e,...t)=>P.assert(e,...t),trace=(...e)=>P.trace(...e),time=e=>P.time(e),timeEnd=e=>P.timeEnd(e),timeLog=(e,...t)=>P.timeLog(e,...t),count=e=>P.count(e),countReset=e=>P.countReset(e),group=(...e)=>P.group(...e),groupCollapsed=(...e)=>P.groupCollapsed(...e),groupEnd=()=>P.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),F,I=__esmMin(()=>{he(),F={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),ge=__esmMin(()=>{I()}),_e,ve=__esmMin(()=>{_e=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function drainOnce(e){let t=Math.min(64,ye.length);for(let n=0;n<t;n++){let t=ye.shift();try{t()}catch(t){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(t?.stack||t),null)}catch{}}}ye.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):be=!1}function tryGLibTimeout(e){let t=globalThis.imports?.gi?.GLib;return t?.timeout_add?(ye.push(e),be||(be=!0,t.timeout_add(t.PRIORITY_DEFAULT,0,()=>(drainOnce(t),!1))),!0):!1}var ye,be,nextTick,xe=__esmMin(()=>{ye=[],be=!1,nextTick=(e,...t)=>{let n=t.length>0?()=>e(...t):e;if(!tryGLibTimeout(n)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...t);return}if(typeof queueMicrotask==`function`){queueMicrotask(n);return}Promise.resolve().then(n)}}}),Se,Ce=__esmMin(()=>{A(),N(),{File:Se}=M});function classOf(e){return we.call(e).slice(8,-1)}function throwDataCloneError(e){let t=globalThis.DOMException;if(typeof t==`function`)throw new t(e,`DataCloneError`);let n=Error(e);throw n.name=`DataCloneError`,n}function internalClone(e,t,n){if(e==null)return e;let r=typeof e;if(r===`boolean`||r===`number`||r===`string`||r===`bigint`)return e;r===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),r===`function`&&throwDataCloneError(`Function cannot be cloned`);let i=e;if(t.has(i))return t.get(i);let a=classOf(i);if(a===`Date`)return new Date(i.getTime());if(a===`RegExp`)return new RegExp(i.source,i.flags);if(a===`Boolean`||a===`Number`||a===`String`)return Object(i.valueOf());if(a===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,a=new(r&&Te[r]||Te[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),a}if(a===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(a===`ArrayBuffer`){let e=i;if(n&&n.transferred.has(e)){let r=n.transferred.get(e);return t.set(i,r),r}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let r=e.slice(0);return t.set(i,r),r}if(a===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(a===`DataView`){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=r?r.byteOffset:e.byteOffset,s=r?r.byteLength:e.byteLength,c=new DataView(a,o,s);return t.set(i,c),c}if(Ee.has(a)){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=e.constructor,s=new o(a,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,s),s}if(a===`Map`){let e=new Map;t.set(i,e);for(let[r,a]of i)e.set(internalClone(r,t,n),internalClone(a,t,n));return e}if(a===`Set`){let e=new Set;t.set(i,e);for(let r of i)e.add(internalClone(r,t,n));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&i instanceof n){let e=i;return new n([i],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&i instanceof t)return new t([i],{type:i.type})}if(i instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),i instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),i instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&i instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),a===`Array`){let e=i,r=[];t.set(i,r);for(let i=0;i<e.length;i++)i in e&&(r[i]=internalClone(e[i],t,n));return r}if(a===`Object`||typeof i==`object`){let e={};t.set(i,e);for(let r of Object.keys(i))e[r]=internalClone(i[r],t,n);return e}throwDataCloneError(`${a} cannot be cloned`)}function structuredClone$1(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}function snapshotViewsBackedByTransferredBuffers(e,t,n,r){if(typeof e!=`object`||!e)return;let i=e;if(r.has(i))return;r.add(i);let a=classOf(i);if(a===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(Ee.has(a)){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(i)){for(let e=0;e<i.length;e++)e in i&&snapshotViewsBackedByTransferredBuffers(i[e],t,n,r);return}if(a===`Map`){for(let[e,a]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(a,t,n,r);return}if(a===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(a===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}var we,Te,Ee,De=__esmMin(()=>{({toString:we}=Object.prototype),Te={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ee=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name(structuredClone$1,`structuredClone`)});function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(Oe)return ke;let t=e.gi?.GLib;if(t){if(ke=new t.MainLoop(null,!1),Oe=!0,t.main_depth()===0)try{ke.runAsync()}catch{}return ke}}function quitMainLoop(){ke&&=(ke.quit(),Oe=!1,null)}var Oe,ke,Ae=__esmMin(()=>{Oe=!1,ke=null}),L=__esmMin(()=>{T(),E(),j(),ee(),te(),ne(),se(),ue(),fe(),pe(),ge(),ve(),xe(),Ce(),De(),Ae()});w(),L(),registerGlobal(`Blob`,x),registerGlobal(`File`,S);var je=Object.defineProperty;__name((e,t)=>{let n={};for(var r in e)je(n,r,{get:e[r],enumerable:!0});return t||je(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)({attributes:()=>U,childNodesList:()=>V,elementChildren:()=>H,isConnected:()=>Me,localName:()=>Pe,name:()=>Le,namespaceURI:()=>Fe,nodeType:()=>z,ownerElement:()=>ze,parentNode:()=>B,prefix:()=>Ie,propertyEventListeners:()=>W,tagName:()=>Ne,value:()=>Re});const z=Symbol(`nodeType`),B=Symbol(`parentNode`),V=Symbol(`childNodesList`),H=Symbol(`elementChildren`),Me=Symbol(`isConnected`),Ne=Symbol(`tagName`),Pe=Symbol(`localName`),Fe=Symbol(`namespaceURI`),Ie=Symbol(`prefix`),U=Symbol(`attributes`),W=Symbol(`propertyEventListeners`),Le=Symbol(`name`),Re=Symbol(`value`),ze=Symbol(`ownerElement`),G={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11};var NodeList=class{constructor(e){this._items=e}get length(){return this._items.length}item(e){return this._items[e]??null}forEach(e,t){for(let n=0;n<this._items.length;n++)e.call(t,this._items[n],n,this)}entries(){return this._items.entries()}keys(){return this._items.keys()}values(){return this._items.values()}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NodeList`}};const Be={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(e,t){super(e),this.name=t||`Error`,this.code=Object.hasOwn(Be,this.name)?Be[this.name]:0}};const Ve=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;I();const He=Symbol(`type`),Ue=Symbol(`bubbles`),We=Symbol(`cancelable`),Ge=Symbol(`composed`),Ke=Symbol(`target`),qe=Symbol(`currentTarget`),Je=Symbol(`eventPhase`),Ye=Symbol(`defaultPrevented`),Xe=Symbol(`isTrusted`),Ze=Symbol(`timeStamp`),Qe=Symbol(`stop`),$e=Symbol(`immediateStop`),et=Symbol(`dispatching`),tt=Symbol(`inPassiveListener`);var Event=class{[He];[Ue];[We];[Ge];[Ke]=null;[qe]=null;[Je]=0;[Ye]=!1;[Xe]=!1;[Ze];[Qe]=!1;[$e]=!1;[et]=!1;[tt]=!1;get type(){return this[He]}get bubbles(){return this[Ue]}get cancelable(){return this[We]}get composed(){return this[Ge]}get target(){return this[Ke]}get currentTarget(){return this[qe]}get eventPhase(){return this[Je]}get defaultPrevented(){return this[Ye]}get timeStamp(){return this[Ze]}get cancelBubble(){return this[Qe]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[Ye]}set returnValue(e){e||this.preventDefault()}get srcElement(){return this[Ke]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(e,t){this[He]=e,this[Ue]=t?.bubbles??!1,this[We]=t?.cancelable??!1,this[Ge]=t?.composed??!1,this[Ze]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[Xe],enumerable:!0,configurable:!1})}composedPath(){return this[qe]?[this[qe]]:[]}preventDefault(){this[We]&&!this[tt]&&(this[Ye]=!0)}stopPropagation(){this[Qe]=!0}stopImmediatePropagation(){this[Qe]=!0,this[$e]=!0}},EventTarget=class{_listeners=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(e,t,n){if(t===null)return;let r=typeof n==`boolean`?n:n?.capture??!1,i=typeof n==`object`?n?.once??!1:!1,a=typeof n==`object`?n?.passive??!1:!1,o=this._listeners.get(e);o||(o=[],this._listeners.set(e,o));for(let e of o)if(e.listener===t&&e.capture===r)return;let s={listener:t,capture:r,once:i,passive:a,removed:!1};o.push(s),typeof n==`object`&&n?.signal&&n.signal.addEventListener(`abort`,()=>{this.removeEventListener(e,t,{capture:r})},{once:!0})}removeEventListener(e,t,n){if(t===null)return;let r=typeof n==`boolean`?n:n?.capture??!1,i=this._listeners.get(e);if(!i)return;let a=i.findIndex(e=>e.listener===t&&e.capture===r);a!==-1&&(i[a].removed=!0,i.splice(a,1),i.length===0&&this._listeners.delete(e))}dispatchEvent(e){let t=e;if(t[et])throw new Ve(`The event is already being dispatched.`,`InvalidStateError`);t[et]=!0,t[Ke]=this,t[qe]=this,t[Je]=Event.AT_TARGET;let n=this._listeners.get(e.type);if(n){let r=[...n];for(let n of r)if(!n.removed){if(t[$e]||t[Qe])break;n.once&&this.removeEventListener(e.type,n.listener,{capture:n.capture});try{n.passive&&(t[tt]=!0),typeof n.listener==`function`?n.listener.call(this,e):typeof n.listener.handleEvent==`function`&&n.listener.handleEvent.call(n.listener,e)}catch(e){F.error(e)}finally{t[tt]=!1}}}return t[Je]=Event.NONE,t[qe]=null,t[et]=!1,!e.defaultPrevented}};for(let[e,t]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event.prototype,e,{value:t,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event,e,{value:t,writable:!1,enumerable:!0,configurable:!1});let nt,rt,it,at,ot;var st=class Node extends EventTarget{constructor(...e){super(...e),this.ELEMENT_NODE=G.ELEMENT_NODE,this.ATTRIBUTE_NODE=G.ATTRIBUTE_NODE,this.TEXT_NODE=G.TEXT_NODE,this.CDATA_SECTION_NODE=G.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=G.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=G.COMMENT_NODE,this.DOCUMENT_NODE=G.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=G.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=G.DOCUMENT_FRAGMENT_NODE,this[nt]=G.ELEMENT_NODE,this[rt]=null,this[it]=[],this[at]=[],this[ot]=!1}static{this.ELEMENT_NODE=G.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=G.ATTRIBUTE_NODE}static{this.TEXT_NODE=G.TEXT_NODE}static{this.CDATA_SECTION_NODE=G.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=G.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=G.COMMENT_NODE}static{this.DOCUMENT_NODE=G.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=G.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=G.DOCUMENT_FRAGMENT_NODE}static{this.DOCUMENT_POSITION_DISCONNECTED=1}static{this.DOCUMENT_POSITION_PRECEDING=2}static{this.DOCUMENT_POSITION_FOLLOWING=4}static{this.DOCUMENT_POSITION_CONTAINS=8}static{this.DOCUMENT_POSITION_CONTAINED_BY=16}static{this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32}get nodeType(){return this[z]}get nodeName(){return``}get parentNode(){return this[B]}get parentElement(){let e=this[B];return e&&e[z]===G.ELEMENT_NODE?e:null}get childNodes(){return new NodeList(this[V])}get firstChild(){return this[V][0]??null}get lastChild(){let e=this[V];return e[e.length-1]??null}get previousSibling(){let e=this[B];if(!e)return null;let t=e[V],n=t.indexOf(this);return n>0?t[n-1]:null}get nextSibling(){let e=this[B];if(!e)return null;let t=e[V],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){return null}set textContent(e){}get nodeValue(){return null}set nodeValue(e){}get ownerDocument(){let e=this;for(;e[B];)e=e[B];let t=globalThis.document;return e===t?t:null}get isConnected(){return this[Me]}hasChildNodes(){return this[V].length>0}contains(e){if(e===null)return!1;if(e===this)return!0;let t=e;for(;t;){if(t===this)return!0;t=t[B]}return!1}getRootNode(){let e=this;for(;e[B];)e=e[B];return e}appendChild(e){return e[B]&&e[B].removeChild(e),e[B]=this,this[V].push(e),e[z]===G.ELEMENT_NODE&&this[H].push(e),e}removeChild(e){let t=this[V],n=t.indexOf(e);if(n===-1)throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`,`NotFoundError`);if(t.splice(n,1),e[B]=null,e[z]===G.ELEMENT_NODE){let t=this[H].indexOf(e);t!==-1&&this[H].splice(t,1)}return e}insertBefore(e,t){if(t===null)return this.appendChild(e);let n=this[V],r=n.indexOf(t);if(r===-1)throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`,`NotFoundError`);if(e[B]&&e[B].removeChild(e),e[B]=this,n.splice(r,0,e),e[z]===G.ELEMENT_NODE){let t=this[H],i=t.length;for(let a=r;a<n.length;a++)if(n[a][z]===G.ELEMENT_NODE&&n[a]!==e){i=t.indexOf(n[a]);break}t.splice(i,0,e)}return e}replaceChild(e,t){return this.insertBefore(e,t),this.removeChild(t),t}cloneNode(e=!1){let t=new this.constructor;if(t[z]=this[z],e)for(let e of this[V])t.appendChild(e.cloneNode(!0));return t}dispatchEvent(e){let t=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let t=this[B];for(;t&&(Object.getPrototypeOf(Node.prototype).dispatchEvent.call(t,e),!e.cancelBubble);)t=t[B]}return t}get[(nt=z,rt=B,it=V,at=H,ot=Me,Symbol.toStringTag)](){return`Node`}};const ct={html:`http://www.w3.org/1999/xhtml`,svg:`http://www.w3.org/2000/svg`,mathML:`http://www.w3.org/1998/Math/MathML`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};var Attr=class{constructor(e,t,n=null,r=null,i=null){this.specified=!0,this[Le]=e,this[Re]=t,this[ze]=i,this.namespaceURI=n,this.prefix=r;let a=e.indexOf(`:`);this.localName=a===-1?e:e.slice(a+1)}get name(){return this[Le]}get value(){return this[Re]}set value(e){this[Re]=e}get ownerElement(){return this[ze]}get[Symbol.toStringTag](){return`Attr`}},NamedNodeMap=class{constructor(e){this._items=[],this._ownerElement=e}get length(){return this._items.length}item(e){return this._items[e]??null}getNamedItem(e){return this._findByName(e)}getNamedItemNS(e,t){let n=e===``?null:e;for(let e of this._items)if(e.namespaceURI===n&&e.localName===t)return e;return null}setNamedItem(e){return this._setAttr(e)}setNamedItemNS(e){return this._setAttr(e)}removeNamedItem(e){let t=this._findByName(e);if(!t)throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${e}' was found.`,`NotFoundError`);return this._removeAttr(t),t}removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);if(!n)throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${e}' and localName '${t}' was found.`,`NotFoundError`);return this._removeAttr(n),n}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NamedNodeMap`}_setNamedItem(e,t,n=null,r=null){let i=n===null?this._findByName(e):this.getNamedItemNS(n,e.includes(`:`)?e.split(`:`)[1]:e);if(i)i.value=t;else{let i=new Attr(e,t,n,r,this._ownerElement);this._items.push(i)}}_removeNamedItem(e){let t=this._findByName(e);return t?(this._removeAttr(t),!0):!1}_removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);return n?(this._removeAttr(n),!0):!1}_findByName(e){let t=this._ownerElement.namespaceURI===ct.html,n=t?e.toLowerCase():e;for(let e of this._items)if((t?e.name.toLowerCase():e.name)===n)return e;return null}_setAttr(e){let t=null;if(t=e.namespaceURI===null?this._findByName(e.name):this.getNamedItemNS(e.namespaceURI,e.localName),t){let n=new Attr(t.name,t.value,t.namespaceURI,t.prefix,t.ownerElement);return t.value=e.value,n}return this._items.push(e),null}_removeAttr(e){let t=this._items.indexOf(e);t!==-1&&this._items.splice(t,1)}};I();let lt,ut,dt,ft,pt,mt;var Element=class extends st{constructor(){super(),this[lt]=``,this[ut]=``,this[dt]=ct.html,this[ft]=null,this[pt]=new NamedNodeMap(this),this[mt]=new Map,this._resizeSubscribers=null,this._allocatedClientWidth=0,this._allocatedClientHeight=0,this._pointerCaptures=new Set,this[z]=G.ELEMENT_NODE}get tagName(){return this[Ne]}get localName(){return this[Pe]}get namespaceURI(){return this[Fe]}get prefix(){return this[Ie]}get nodeName(){return this[Ne]}get attributes(){return this[U]}get id(){return this.getAttribute(`id`)??``}set id(e){this.setAttribute(`id`,e)}get className(){return this.getAttribute(`class`)??``}set className(e){this.setAttribute(`class`,e)}get children(){return this[H]}get childElementCount(){return this[H].length}get firstElementChild(){return this[H][0]??null}get lastElementChild(){let e=this[H];return e[e.length-1]??null}get previousElementSibling(){let e=this[B];if(!e)return null;let t=e[H],n=t.indexOf(this);return n>0?t[n-1]:null}get nextElementSibling(){let e=this[B];if(!e)return null;let t=e[H],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){let e=``;for(let t of this[V])t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){let t=this[V];for(;t.length>0;)this.removeChild(t[0])}getAttribute(e){let t=this[U].getNamedItem(e);return t?t.value:null}getAttributeNS(e,t){let n=this[U].getNamedItemNS(e,t);return n?n.value:null}setAttribute(e,t){this[U]._setNamedItem(e,String(t))}setAttributeNS(e,t,n){let r=e===``?null:e,i=t.split(`:`),a=i.length>1?i[0]:null;this[U]._setNamedItem(t,String(n),r,a)}removeAttribute(e){this[U]._removeNamedItem(e)}removeAttributeNS(e,t){let n=e===``?null:e;this[U]._removeNamedItemNS(n,t)}hasAttribute(e){return this[U].getNamedItem(e)!==null}hasAttributeNS(e,t){return this[U].getNamedItemNS(e,t)!==null}getAttributeNode(e){return this[U].getNamedItem(e)}setAttributeNode(e){return this[U].setNamedItem(e)}removeAttributeNode(e){let t=this[U].getNamedItem(e.name);if(!t)throw new DOMException(`Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.`,`NotFoundError`);return this[U].removeNamedItem(t.name),t}toggleAttribute(e,t){return t===void 0?this.hasAttribute(e)?(this.removeAttribute(e),!1):(this.setAttribute(e,``),!0):t?(this.setAttribute(e,``),!0):(this.removeAttribute(e),!1)}hasAttributes(){return this[U].length>0}dispatchEvent(e){let t=super.dispatchEvent(e),n=this[W].get(`on`+e.type);return typeof n==`function`&&n.call(this,e),t}querySelector(e){return null}querySelectorAll(e){return[]}matches(e){return!1}closest(e){return null}getElementsByTagName(e){let t=[],n=e.toUpperCase(),walk=r=>{for(let i of r[V])if(i[z]===G.ELEMENT_NODE){let r=i;(e===`*`||r[Ne]===n)&&t.push(r),walk(r)}};return walk(this),t}getElementsByClassName(e){let t=[],n=e.split(/\s+/).filter(Boolean),walk=e=>{for(let r of e[V])if(r[z]===G.ELEMENT_NODE){let e=r,i=e.className.split(/\s+/);n.every(e=>i.includes(e))&&t.push(e),walk(e)}};return walk(this),t}cloneNode(e=!1){let t=super.cloneNode(!1);t[Ne]=this[Ne],t[Pe]=this[Pe],t[Fe]=this[Fe],t[Ie]=this[Ie];for(let e of this[U])t.setAttributeNS(e.namespaceURI,e.name,e.value);if(e)for(let e of this[V])t.appendChild(e.cloneNode(!0));return t}_onResize(e){let t=this._resizeSubscribers??=new Set;return t.add(e),()=>{t.delete(e),t.size===0&&(this._resizeSubscribers=null)}}_fireResizeSubscribers(e,t){let n=this._resizeSubscribers;if(!(!n||n.size===0))for(let r of[...n])try{r(e,t)}catch(e){F.error(`ResizeObserver subscriber threw:`,e)}}setPointerCapture(e){this._pointerCaptures.add(e)}releasePointerCapture(e){this._pointerCaptures.delete(e)}hasPointerCapture(e){return this._pointerCaptures.has(e)}get[(lt=Ne,ut=Pe,dt=Fe,ft=Ie,pt=U,mt=W,Symbol.toStringTag)](){return`Element`}},CSSStyleDeclaration=class{constructor(){this._cssText=``}get cssText(){return this._cssText}set cssText(e){this._cssText=e;for(let t of e.split(`;`)){let e=t.indexOf(`:`);if(e===-1)continue;let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)continue;let i=n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());this[i]=r}}setProperty(e,t,n){this[e]=t}getPropertyValue(e){let t=this[e];return typeof t==`string`?t:``}removeProperty(e){let t=this[e];return delete this[e],typeof t==`string`?t:``}getPropertyPriority(e){return``}},HTMLElement$1=class extends Element{static{__name(this,`HTMLElement`)}constructor(...e){super(...e),this.style=new CSSStyleDeclaration}get dataset(){let e=this;return new Proxy({},{get(t,n){if(typeof n!=`string`)return;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.getAttribute(r)??void 0},set(t,n,r){if(typeof n!=`string`)return!1;let i=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.setAttribute(i,String(r)),!0},deleteProperty(t,n){if(typeof n!=`string`)return!1;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.removeAttribute(r),!0},has(t,n){if(typeof n!=`string`)return!1;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.hasAttribute(r)}})}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get lang(){return this.getAttribute(`lang`)??``}set lang(e){this.setAttribute(`lang`,e)}get dir(){return this.getAttribute(`dir`)??``}set dir(e){this.setAttribute(`dir`,e)}get accessKey(){return this.getAttribute(`accesskey`)??``}set accessKey(e){this.setAttribute(`accesskey`,e)}get accessKeyLabel(){return this.getAttribute(`accesskey`)??``}get hidden(){return this.hasAttribute(`hidden`)}set hidden(e){e?this.setAttribute(`hidden`,``):this.removeAttribute(`hidden`)}get draggable(){return this.getAttribute(`draggable`)===`true`}set draggable(e){this.setAttribute(`draggable`,String(e))}get spellcheck(){let e=this.getAttribute(`spellcheck`);return e===`false`?!1:e!==null}set spellcheck(e){this.setAttribute(`spellcheck`,String(e))}get translate(){return this.getAttribute(`translate`)!==`no`}set translate(e){this.setAttribute(`translate`,e?`yes`:`no`)}get tabIndex(){let e=this.getAttribute(`tabindex`);return e===null?-1:Number(e)}set tabIndex(e){this.setAttribute(`tabindex`,String(e))}get contentEditable(){let e=this.getAttribute(`contenteditable`);return e===``||e===`true`?`true`:e===`false`?`false`:`inherit`}set contentEditable(e){e===`inherit`?this.removeAttribute(`contenteditable`):this.setAttribute(`contenteditable`,e)}get isContentEditable(){return this.contentEditable===`true`}get offsetHeight(){return this._allocatedClientHeight}get offsetWidth(){return this._allocatedClientWidth}get offsetLeft(){return 0}get offsetTop(){return 0}get offsetParent(){return null}get clientHeight(){return this._allocatedClientHeight}get clientWidth(){return this._allocatedClientWidth}get clientLeft(){return 0}get clientTop(){return 0}get scrollHeight(){return this._allocatedClientHeight}get scrollWidth(){return this._allocatedClientWidth}get scrollTop(){return 0}set scrollTop(e){}get scrollLeft(){return 0}set scrollLeft(e){}getBoundingClientRect(){let e=this.clientWidth,t=this.clientHeight;return{x:0,y:0,top:0,left:0,right:e,bottom:t,width:e,height:t,toJSON(){return this}}}click(){this.dispatchEvent(new Event(`click`,{bubbles:!0,cancelable:!0}))}blur(){this.dispatchEvent(new Event(`blur`))}focus(){this.dispatchEvent(new Event(`focus`))}get onclick(){return this[W].get(`onclick`)??null}set onclick(e){this[W].set(`onclick`,e)}get ondblclick(){return this[W].get(`ondblclick`)??null}set ondblclick(e){this[W].set(`ondblclick`,e)}get onload(){return this[W].get(`onload`)??null}set onload(e){this[W].set(`onload`,e)}get onerror(){return this[W].get(`onerror`)??null}set onerror(e){this[W].set(`onerror`,e)}get onabort(){return this[W].get(`onabort`)??null}set onabort(e){this[W].set(`onabort`,e)}get onfocus(){return this[W].get(`onfocus`)??null}set onfocus(e){this[W].set(`onfocus`,e)}get onblur(){return this[W].get(`onblur`)??null}set onblur(e){this[W].set(`onblur`,e)}get onchange(){return this[W].get(`onchange`)??null}set onchange(e){this[W].set(`onchange`,e)}get oninput(){return this[W].get(`oninput`)??null}set oninput(e){this[W].set(`oninput`,e)}get onsubmit(){return this[W].get(`onsubmit`)??null}get onreset(){return this[W].get(`onreset`)??null}set onreset(e){this[W].set(`onreset`,e)}get onscroll(){return this[W].get(`onscroll`)??null}set onscroll(e){this[W].set(`onscroll`,e)}get onresize(){return this[W].get(`onresize`)??null}set onresize(e){this[W].set(`onresize`,e)}get onmousedown(){return this[W].get(`onmousedown`)??null}set onmousedown(e){this[W].set(`onmousedown`,e)}get onmouseup(){return this[W].get(`onmouseup`)??null}set onmouseup(e){this[W].set(`onmouseup`,e)}get onmousemove(){return this[W].get(`onmousemove`)??null}set onmousemove(e){this[W].set(`onmousemove`,e)}get onmouseover(){return this[W].get(`onmouseover`)??null}set onmouseover(e){this[W].set(`onmouseover`,e)}get onmouseout(){return this[W].get(`onmouseout`)??null}set onmouseout(e){this[W].set(`onmouseout`,e)}get onmouseenter(){return this[W].get(`onmouseenter`)??null}set onmouseenter(e){this[W].set(`onmouseenter`,e)}get onmouseleave(){return this[W].get(`onmouseleave`)??null}set onmouseleave(e){this[W].set(`onmouseleave`,e)}get oncontextmenu(){return this[W].get(`oncontextmenu`)??null}set oncontextmenu(e){this[W].set(`oncontextmenu`,e)}get onwheel(){return this[W].get(`onwheel`)??null}set onwheel(e){this[W].set(`onwheel`,e)}get onkeydown(){return this[W].get(`onkeydown`)??null}set onkeydown(e){this[W].set(`onkeydown`,e)}get onkeyup(){return this[W].get(`onkeyup`)??null}set onkeyup(e){this[W].set(`onkeyup`,e)}get ontouchstart(){return this[W].get(`ontouchstart`)??null}set ontouchstart(e){this[W].set(`ontouchstart`,e)}get ontouchend(){return this[W].get(`ontouchend`)??null}set ontouchend(e){this[W].set(`ontouchend`,e)}get ontouchmove(){return this[W].get(`ontouchmove`)??null}set ontouchmove(e){this[W].set(`ontouchmove`,e)}get onpointerdown(){return this[W].get(`onpointerdown`)??null}set onpointerdown(e){this[W].set(`onpointerdown`,e)}get onpointerup(){return this[W].get(`onpointerup`)??null}set onpointerup(e){this[W].set(`onpointerup`,e)}get onpointermove(){return this[W].get(`onpointermove`)??null}set onpointermove(e){this[W].set(`onpointermove`,e)}cloneNode(e=!1){return super.cloneNode(e)}get[Symbol.toStringTag](){return`HTMLElement`}},ht=class HTMLCanvasElement extends HTMLElement$1{constructor(...e){super(...e),this.oncontextlost=null,this.oncontextrestored=null,this.onwebglcontextcreationerror=null,this.onwebglcontextlost=null,this.onwebglcontextrestored=null}static{this._contextFactories=new Map}static registerContextFactory(e,t){HTMLCanvasElement._contextFactories.set(e,t)}get width(){let e=this.getAttribute(`width`);return e===null?300:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get height(){let e=this.getAttribute(`height`);return e===null?150:Number(e)}set height(e){this.setAttribute(`height`,String(e))}getContext(e,t){let n=HTMLCanvasElement._contextFactories.get(e);return n?n(this,t):null}toDataURL(e,t){let n=this.getContext(`2d`);return n&&typeof n._toDataURL==`function`?n._toDataURL(e,t):``}toBlob(e,t,n){let r=this.toDataURL(t,n);if(!r){e(null);return}let[i,a]=r.split(`,`),o=i.split(`:`)[1].split(`;`)[0],s=atob(a),c=new Uint8Array(s.length);for(let e=0;e<s.length;e++)c[e]=s.charCodeAt(e);e(new Blob([c],{type:o}))}captureStream(e){return{}}},gt=class DOMMatrix{constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,this.is2D=!0,this.isIdentity=!0,Array.isArray(e)&&(e.length===6?(this.a=this.m11=e[0],this.b=this.m12=e[1],this.c=this.m21=e[2],this.d=this.m22=e[3],this.e=this.m41=e[4],this.f=this.m42=e[5],this.is2D=!0):e.length===16&&(this.m11=e[0],this.m12=e[1],this.m13=e[2],this.m14=e[3],this.m21=e[4],this.m22=e[5],this.m23=e[6],this.m24=e[7],this.m31=e[8],this.m32=e[9],this.m33=e[10],this.m34=e[11],this.m41=e[12],this.m42=e[13],this.m43=e[14],this.m44=e[15],this.a=this.m11,this.b=this.m12,this.c=this.m21,this.d=this.m22,this.e=this.m41,this.f=this.m42,this.is2D=!1),this.isIdentity=this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0)}multiply(e){return new DOMMatrix([this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f])}multiplySelf(e){let t=this.multiply(e);return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,this.f=t.f,this.m11=this.a,this.m12=this.b,this.m21=this.c,this.m22=this.d,this.m41=this.e,this.m42=this.f,this.isIdentity=!1,this}inverse(){let e=this.a*this.d-this.b*this.c;if(e===0)return new DOMMatrix([1,0,0,1,0,0]);let t=1/e;return new DOMMatrix([this.d*t,-this.b*t,-this.c*t,this.a*t,(this.c*this.f-this.d*this.e)*t,(this.b*this.e-this.a*this.f)*t])}translate(e=0,t=0){return this.multiply({a:1,b:0,c:0,d:1,e,f:t})}scale(e=1,t=e){return this.multiply({a:e,b:0,c:0,d:t,e:0,f:0})}};const _t=gt;function defineGlobal(e,t){Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}function defineGlobalIfMissing(e,t){globalThis[e]===void 0&&defineGlobal(e,t)}const vt={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`,transparent:`#00000000`};function parseColor(e){if(!e||typeof e!=`string`)return null;let t=e.trim().toLowerCase(),n=vt[t];if(n)return parseHex(n);if(t.startsWith(`#`))return parseHex(t);let r=t.match(/^rgba?\(\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(r)return{r:parseComponent(r[1],255)/255,g:parseComponent(r[2],255)/255,b:parseComponent(r[3],255)/255,a:r[4]===void 0?1:parseComponent(r[4],1)};let i=t.match(/^hsla?\(\s*(\d+(?:\.\d+)?)\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(i){let e=parseFloat(i[1]),t=parseFloat(i[2]),n=i[3]===`%`,r=parseFloat(i[4]),a=i[5]===`%`,o=i[6]===void 0?1:parseComponent(i[6],1);return e>1&&(e/=360),(n||t>1)&&(t/=100),(a||r>1)&&(r/=100),hslToRGBA(e,t,r,Math.max(0,Math.min(1,o)))}return null}function parseHex(e){let t=e.slice(1),n,r,i,a=1;if(t.length===3)n=parseInt(t[0]+t[0],16)/255,r=parseInt(t[1]+t[1],16)/255,i=parseInt(t[2]+t[2],16)/255;else if(t.length===4)n=parseInt(t[0]+t[0],16)/255,r=parseInt(t[1]+t[1],16)/255,i=parseInt(t[2]+t[2],16)/255,a=parseInt(t[3]+t[3],16)/255;else if(t.length===6)n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255;else if(t.length===8)n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,a=parseInt(t.slice(6,8),16)/255;else return null;return{r:n,g:r,b:i,a}}function parseComponent(e,t){return e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e)}function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function hslToRGBA(e,t,n,r){let i,a,o;if(t===0)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=hue2rgb(s,r,e+1/3),a=hue2rgb(s,r,e),o=hue2rgb(s,r,e-1/3)}return{r:i,g:a,b:o,a:r}}const yt={r:0,g:0,b:0,a:1};var CanvasGradient=class{constructor(e,t,r,i,a,o,s){e===`radial`?this._pattern=new n.RadialGradient(t,r,o,i,a,s):this._pattern=new n.LinearGradient(t,r,i,a)}addColorStop(e,t){let n=parseColor(t);n&&this._pattern.addColorStopRGBA(e,n.r,n.g,n.b,n.a)}_getCairoPattern(){return this._pattern}};function quadraticToCubic(e,t,n,r,i,a){return{cp1x:e+2/3*(n-e),cp1y:t+2/3*(r-t),cp2x:i+2/3*(n-i),cp2y:a+2/3*(r-a)}}function computeArcTo(e,t,n,r,i,a,o){let s=e-n,c=t-r,l=i-n,u=a-r,d=Math.sqrt(s*s+c*c),p=Math.sqrt(l*l+u*u);if(d===0||p===0)return null;let m=s/d,h=c/d,g=l/p,_=u/p,v=m*_-h*g;if(Math.abs(v)<1e-10)return null;let y=m*g+h*_,b=Math.acos(Math.max(-1,Math.min(1,y)))/2,x=o/Math.tan(b),S=n+m*x,w=r+h*x,T=n+g*x,E=r+_*x,D=o/Math.sin(b),O=(m+g)/2,k=(h+_)/2,A=Math.sqrt(O*O+k*k),j=n+O/A*D,ee=r+k/A*D;return{tx0:S,ty0:w,tx1:T,ty1:E,cx:j,cy:ee,startAngle:Math.atan2(w-ee,S-j),endAngle:Math.atan2(E-ee,T-j),counterclockwise:v>0}}function cairoArcTo(e,t,n,r,i,a,o,s){let c=computeArcTo(t,n,r,i,a,o,s);if(!c){e.lineTo(r,i);return}let{tx0:l,ty0:u,cx:d,cy:p,startAngle:m,endAngle:h,counterclockwise:g}=c;e.lineTo(l,u),g?e.arcNegative(d,p,s,m,h):e.arc(d,p,s,m,h)}function cairoEllipse(e,t,n,r,i,a,o,s,c){e.save(),e.translate(t,n),e.rotate(a),e.scale(r,i),c?e.arcNegative(0,0,1,o,s):e.arc(0,0,1,o,s),e.restore()}function cairoRoundRect(e,t,n,r,i,a){let o,s,c,l;typeof a==`number`?o=s=c=l=a:a.length===1?o=s=c=l=a[0]:a.length===2?(o=c=a[0],s=l=a[1]):a.length===3?(o=a[0],s=l=a[1],c=a[2]):(o=a[0],s=a[1],c=a[2],l=a[3]);let u=Math.min(r/2,i/2);o=Math.min(o,u),s=Math.min(s,u),c=Math.min(c,u),l=Math.min(l,u);let d=Math.PI/2;e.newSubPath(),e.arc(t+o,n+o,o,Math.PI,Math.PI+d),e.arc(t+r-s,n+s,s,-d,0),e.arc(t+r-c,n+i-c,c,0,d),e.arc(t+l,n+i-l,l,d,Math.PI),e.closePath()}const bt={"source-over":2,"source-in":3,"source-out":4,"source-atop":5,"destination-over":7,"destination-in":8,"destination-out":9,"destination-atop":10,lighter:12,copy:1,xor:11,multiply:14,screen:15,overlay:16,darken:17,lighten:18,"color-dodge":19,"color-burn":20,"hard-light":21,"soft-light":22,difference:23,exclusion:24,hue:25,saturation:26,color:27,luminosity:28},xt={butt:0,round:1,square:2},St={miter:0,round:1,bevel:2};var Ct=class Path2D{constructor(e){this._ops=[],e instanceof Path2D&&(this._ops=[...e._ops])}addPath(e){this._ops.push(...e._ops)}moveTo(e,t){this._ops.push({type:`moveTo`,x:e,y:t})}lineTo(e,t){this._ops.push({type:`lineTo`,x:e,y:t})}closePath(){this._ops.push({type:`closePath`})}bezierCurveTo(e,t,n,r,i,a){this._ops.push({type:`bezierCurveTo`,cp1x:e,cp1y:t,cp2x:n,cp2y:r,x:i,y:a})}quadraticCurveTo(e,t,n,r){this._ops.push({type:`quadraticCurveTo`,cpx:e,cpy:t,x:n,y:r})}arc(e,t,n,r,i,a=!1){this._ops.push({type:`arc`,x:e,y:t,radius:n,startAngle:r,endAngle:i,ccw:a})}ellipse(e,t,n,r,i,a,o,s=!1){if(n<0||r<0)throw RangeError(`The radii provided are negative`);this._ops.push({type:`ellipse`,x:e,y:t,rx:n,ry:r,rotation:i,startAngle:a,endAngle:o,ccw:s})}rect(e,t,n,r){this._ops.push({type:`rect`,x:e,y:t,w:n,h:r})}roundRect(e,t,n,r,i=0){this._ops.push({type:`roundRect`,x:e,y:t,w:n,h:r,radii:i})}_replayOnCairo(e){let t=0,n=0;for(let r of this._ops)switch(r.type){case`moveTo`:e.moveTo(r.x,r.y),t=r.x,n=r.y;break;case`lineTo`:e.lineTo(r.x,r.y),t=r.x,n=r.y;break;case`closePath`:e.closePath();break;case`bezierCurveTo`:e.curveTo(r.cp1x,r.cp1y,r.cp2x,r.cp2y,r.x,r.y),t=r.x,n=r.y;break;case`quadraticCurveTo`:{let{cp1x:i,cp1y:a,cp2x:o,cp2y:s}=quadraticToCubic(t,n,r.cpx,r.cpy,r.x,r.y);e.curveTo(i,a,o,s,r.x,r.y),t=r.x,n=r.y;break}case`arc`:r.ccw?e.arcNegative(r.x,r.y,r.radius,r.startAngle,r.endAngle):e.arc(r.x,r.y,r.radius,r.startAngle,r.endAngle);break;case`ellipse`:e.save(),e.translate(r.x,r.y),e.rotate(r.rotation),e.scale(r.rx,r.ry),r.ccw?e.arcNegative(0,0,1,r.startAngle,r.endAngle):e.arc(0,0,1,r.startAngle,r.endAngle),e.restore();break;case`rect`:e.rectangle(r.x,r.y,r.w,r.h);break;case`roundRect`:cairoRoundRect(e,r.x,r.y,r.w,r.h,r.radii);break}}};function asCairoPattern(e){if(!e)return null;let t=e;return typeof t.setFilter!=`function`||typeof t.setExtend!=`function`?null:t}function isPixbufImageSource(e){return typeof e!=`object`||!e?!1:typeof e.isPixbuf==`function`&&e.isPixbuf()}function isCanvasImageSource(e){return typeof e!=`object`||!e?!1:typeof e.getContext==`function`}var wt=class CanvasPattern{constructor(e,t){let r=asCairoPattern(new n.SurfacePattern(e));if(!r)throw TypeError(`CanvasPattern: cairo SurfacePattern is missing setExtend at runtime — incompatible Cairo binding`);switch(this._pattern=r,t){case`repeat`:case``:case null:r.setExtend(n.Extend.REPEAT);break;case`repeat-x`:case`repeat-y`:r.setExtend(n.Extend.REPEAT);break;case`no-repeat`:r.setExtend(n.Extend.NONE);break}}static create(e,t){if(isPixbufImageSource(e)){let i=e._pixbuf,a=i.get_width(),o=i.get_height(),s=new n.ImageSurface(n.Format.ARGB32,a,o),c=new n.Context(s);return r.cairo_set_source_pixbuf(c,i,0,0),c.paint(),c.$dispose(),new CanvasPattern(s,t)}if(isCanvasImageSource(e)){let r=e.getContext(`2d`);if(r&&typeof r._getSurface==`function`){let e=r._getSurface(),i=e.getWidth(),a=e.getHeight(),o=new n.ImageSurface(n.Format.ARGB32,i,a),s=new n.Context(o);return s.setSourceSurface(e,0,0),s.paint(),s.$dispose(),new CanvasPattern(o,t)}}return null}_getCairoPattern(){return this._pattern}},OurImageData=class{constructor(e,t,n){if(this.colorSpace=`srgb`,typeof e==`number`)this.width=e,this.height=t,this.data=new Uint8ClampedArray(this.width*this.height*4);else if(this.data=e,this.width=t,this.height=n??this.data.length/(4*this.width),this.data.length!==this.width*this.height*4)throw RangeError(`Source data length ${this.data.length} is not a multiple of (4 * width=${this.width})`)}};const Tt={translate(e,t){this._ensureSurface(),this._ctx.translate(e,t)},rotate(e){this._ensureSurface(),this._ctx.rotate(e)},scale(e,t){this._ensureSurface(),this._ctx.scale(e,t)},transform(e,t,n,r,i,a){if(this._ensureSurface(),!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a))return;let o=i,s=a,c=Math.hypot(e,t),l=Math.hypot(n,r),u=Math.atan2(t,e);this._ctx.translate(o,s),u!==0&&this._ctx.rotate(u),(c!==1||l!==1)&&this._ctx.scale(c,l)},setTransform(e,t,n,r,i,a){if(this._ensureSurface(),typeof e==`object`&&e){let t=e;this._ctx.identityMatrix(),this.transform(t.a??t.m11??1,t.b??t.m12??0,t.c??t.m21??0,t.d??t.m22??1,t.e??t.m41??0,t.f??t.m42??0)}else typeof e==`number`?(this._ctx.identityMatrix(),this.transform(e,t,n,r,i,a)):this._ctx.identityMatrix()},getTransform(){let e=this._ctx.userToDevice(0,0),t=this._ctx.userToDevice(1,0),n=this._ctx.userToDevice(0,1),r=e[0]??0,i=e[1]??0,a=(t[0]??0)-r,o=(t[1]??0)-i,s=(n[0]??0)-r,c=(n[1]??0)-i,l=globalThis.DOMMatrix;return typeof l==`function`?new l([a,o,s,c,r,i]):{a,b:o,c:s,d:c,e:r,f:i,m11:a,m12:o,m13:0,m14:0,m21:s,m22:c,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:r,m42:i,m43:0,m44:1,is2D:!0,isIdentity:a===1&&o===0&&s===0&&c===1&&r===0&&i===0}},resetTransform(){this._ensureSurface(),this._ctx.identityMatrix()}};function installTransformMethods(e){Object.assign(e,Tt)}const Et={beginPath(){this._ensureSurface(),this._ctx.newPath()},moveTo(e,t){this._ensureSurface(),this._ctx.moveTo(e,t)},lineTo(e,t){this._ensureSurface(),this._ctx.lineTo(e,t)},closePath(){this._ensureSurface(),this._ctx.closePath()},bezierCurveTo(e,t,n,r,i,a){this._ensureSurface(),this._ctx.curveTo(e,t,n,r,i,a)},quadraticCurveTo(e,t,n,r){this._ensureSurface();let i,a;this._ctx.hasCurrentPoint()?[i,a]=this._ctx.getCurrentPoint():(i=e,a=t);let{cp1x:o,cp1y:s,cp2x:c,cp2y:l}=quadraticToCubic(i,a,e,t,n,r);this._ctx.curveTo(o,s,c,l,n,r)},arc(e,t,n,r,i,a=!1){if(this._ensureSurface(),Math.abs(i-r)>=2*Math.PI){this._ctx.arc(e,t,n,0,2*Math.PI);return}a?this._ctx.arcNegative(e,t,n,r,i):this._ctx.arc(e,t,n,r,i)},arcTo(e,t,n,r,i){this._ensureSurface();let a,o;this._ctx.hasCurrentPoint()?[a,o]=this._ctx.getCurrentPoint():(a=e,o=t,this._ctx.moveTo(e,t)),cairoArcTo(this._ctx,a,o,e,t,n,r,i)},ellipse(e,t,n,r,i,a,o,s=!1){if(this._ensureSurface(),n<0||r<0)throw RangeError(`The radii provided are negative`);cairoEllipse(this._ctx,e,t,n,r,i,a,o,s)},rect(e,t,n,r){this._ensureSurface(),this._ctx.rectangle(e,t,n,r)},roundRect(e,t,n,r,i=0){this._ensureSurface(),cairoRoundRect(this._ctx,e,t,n,r,i)}};function installPathMethods(e){Object.assign(e,Et)}function getDrawImageSource(e){if(isPixbufImageSource(e)){let t=e._pixbuf;return{pixbuf:t,imgWidth:t.get_width(),imgHeight:t.get_height()}}if(isCanvasImageSource(e)){let t=e.width??0,n=e.height??0;if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return null;let i=e.getContext(`2d`);if(i&&typeof i._getSurface==`function`){let e=i._getSurface();e.flush();let a=r.pixbuf_get_from_surface(e,0,0,t,n);if(a)return{pixbuf:a,imgWidth:t,imgHeight:n}}}return null}const Dt={fill(e,t){this._ensureSurface(),this._applyCompositing(),this._applyFillStyle();let r;e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),r=t):r=e,this._ctx.setFillRule(r===`evenodd`?n.FillRule.EVEN_ODD:n.FillRule.WINDING),this._ctx.fillPreserve()},stroke(e){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle(),e instanceof Ct&&(this._ctx.newPath(),e._replayOnCairo(this._ctx)),this._ctx.strokePreserve()},fillRect(e,t,n,r){this._ensureSurface(),this._applyCompositing();let i=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.fill()}),this._applyFillStyle(),this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.fill(),this._ctx.newPath(),this._ctx.appendPath(i)},strokeRect(e,t,n,r){this._ensureSurface(),this._applyCompositing();let i=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.stroke()}),this._applyStrokeStyle(),this._applyLineStyle(),this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.stroke(),this._ctx.newPath(),this._ctx.appendPath(i)},clearRect(e,t,r,i){this._ensureSurface();let a=this._ctx.copyPath();this._ctx.save(),this._ctx.setOperator(n.Operator.CLEAR),this._ctx.newPath(),this._ctx.rectangle(e,t,r,i),this._ctx.fill(),this._ctx.restore(),this._ctx.newPath(),this._ctx.appendPath(a)},clip(e,t){this._ensureSurface();let r;e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),r=t):r=e,this._ctx.setFillRule(r===`evenodd`?n.FillRule.EVEN_ODD:n.FillRule.WINDING),this._ctx.clip()},isPointInPath(e,t,r,i){this._ensureSurface();let a,o,s;return e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),a=t,o=r,s=i):(a=e,o=t,s=r),this._ctx.setFillRule(s===`evenodd`?n.FillRule.EVEN_ODD:n.FillRule.WINDING),this._ctx.inFill(a,o)},isPointInStroke(e,t,n){return this._ensureSurface(),this._applyLineStyle(),e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),this._ctx.inStroke(t,n)):this._ctx.inStroke(e,t)},drawImage(e,t,i,a,o,s,c,l,u){this._ensureSurface(),this._applyCompositing();let d,p,m,h,g,_,v,y,b=getDrawImageSource(e);if(!b)return;let{pixbuf:x,imgWidth:S,imgHeight:w}=b;if(a===void 0?(d=0,p=0,m=S,h=w,g=t,_=i,v=S,y=w):s===void 0?(d=0,p=0,m=S,h=w,g=t,_=i,v=a,y=o):(d=t,p=i,m=a,h=o,g=s,_=c,v=l,y=u),!Number.isFinite(d)||!Number.isFinite(p)||!Number.isFinite(m)||!Number.isFinite(h)||!Number.isFinite(g)||!Number.isFinite(_)||!Number.isFinite(v)||!Number.isFinite(y)||m===0||h===0||v===0||y===0)return;this._ctx.save(),this._ctx.rectangle(g,_,v,y),this._ctx.clip(),this._ctx.translate(g,_),this._ctx.scale(v/m,y/h),this._ctx.translate(-d,-p),r.cairo_set_source_pixbuf(this._ctx,x,0,0);let T=asCairoPattern(this._ctx.getSource?.());if(T){let e;e=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?n.Filter.BEST:n.Filter.BILINEAR:n.Filter.NEAREST,T.setFilter(e)}this._state.globalAlpha<1?this._ctx.paintWithAlpha(this._state.globalAlpha):this._ctx.paint(),this._ctx.restore()}};function installDrawingMethods(e){Object.assign(e,Dt)}const Ot={createImageData(e,t){return typeof e==`number`?new OurImageData(Math.abs(e),Math.abs(t)):new OurImageData(e.width,e.height)},getImageData(e,t,n,i){this._ensureSurface(),this._surface.flush();let a=r.pixbuf_get_from_surface(this._surface,e,t,n,i);if(!a)return new OurImageData(n,i);let o=a.get_pixels(),s=a.get_has_alpha(),c=a.get_rowstride(),l=a.get_n_channels(),u=new Uint8ClampedArray(n*i*4);for(let e=0;e<i;e++)for(let t=0;t<n;t++){let r=e*c+t*l,i=(e*n+t)*4;u[i]=o[r],u[i+1]=o[r+1],u[i+2]=o[r+2],u[i+3]=s?o[r+3]:255}return new OurImageData(u,n,i)},putImageData(e,t,a,o,s,c,l){this._ensureSurface();let u=o??0,d=s??0,p=c??e.width,m=l??e.height,h=e.data,g=e.width,_=new Uint8Array(p*m*4);for(let e=0;e<m;e++)for(let t=0;t<p;t++){let n=((d+e)*g+(u+t))*4,r=(e*p+t)*4;_[r]=h[n],_[r+1]=h[n+1],_[r+2]=h[n+2],_[r+3]=h[n+3]}let v=i.Pixbuf.new_from_bytes(_,i.Colorspace.RGB,!0,8,p,m,p*4);this._ctx.save(),this._ctx.setOperator(n.Operator.SOURCE),r.cairo_set_source_pixbuf(this._ctx,v,t+u,a+d),this._ctx.rectangle(t+u,a+d,p,m),this._ctx.fill(),this._ctx.restore()}};function installPixelMethods(e){Object.assign(e,Ot)}function parseFontToDescription(e){let t=e.match(/^\s*(italic|oblique|normal)?\s*(small-caps|normal)?\s*(bold|bolder|lighter|[1-9]00|normal)?\s*(\d+(?:\.\d+)?)(px|pt|em|rem|%)?\s*(?:\/\S+)?\s*(.+)?$/i);if(!t)return a.font_description_from_string(e);let n=t[1]||``,r=t[3]||``,i=parseFloat(t[4])||10,o=(t[5]||`px`).toLowerCase(),s=(t[6]||`sans-serif`).replace(/['"]/g,``).trim();o===`pt`?i=i*96/72:o===`em`||o===`rem`?i*=16:o===`%`&&(i=i/100*16);let c=s;n===`italic`?c+=` Italic`:n===`oblique`&&(c+=` Oblique`),r===`bold`||r===`bolder`||parseInt(r)>=600?c+=` Bold`:(r===`lighter`||parseInt(r)>0&&parseInt(r)<=300)&&(c+=` Light`);let l=a.font_description_from_string(c);return l.set_absolute_size(i*a.SCALE),l}function createTextLayout(e,t){let n=o.create_layout(e._ctx);n.set_text(t,-1),n.get_context().set_base_dir(a.Direction.LTR),n.context_changed();let r=parseFontToDescription(e._state.font);return n.set_font_description(r),n}function getTextAlignOffset(e,t){let[,n]=t.get_pixel_extents(),r=n.width;switch(e._state.textAlign){case`center`:return-r/2;case`right`:case`end`:return-r;default:return 0}}function getTextBaselineOffset(e,t){let n=t.get_font_description()||parseFontToDescription(e._state.font),r=t.get_context().get_metrics(n,null),i=r.get_ascent()/a.SCALE,o=r.get_descent()/a.SCALE,s=i+o;switch(e._state.textBaseline){case`top`:return 0;case`hanging`:return-(i*.2);case`middle`:return-(s/2);case`alphabetic`:return-i;case`ideographic`:return-(i+o*.5);case`bottom`:return-s;default:return-i}}const kt={fillText(e,t,r,i){this._ensureSurface(),this._applyCompositing();let a=createTextLayout(this,e),s=getTextAlignOffset(this,a),c=getTextBaselineOffset(this,a);if(this._hasShadow()){let e=parseColor(this._state.shadowColor);if(e){let[i,l]=this._deviceToUserDistance(this._state.shadowOffsetX,this._state.shadowOffsetY),u=this._state.shadowBlur,d;if(u>0){let[t]=this._deviceToUserDistance(u,0),[,n]=this._deviceToUserDistance(0,u);d=[[i,l,e.a],[i+t,l,e.a*.5],[i-t,l,e.a*.5],[i,l+n,e.a*.5],[i,l-n,e.a*.5]]}else d=[[i,l,e.a]];let p=this._state.imageSmoothingEnabled?n.Antialias.DEFAULT:n.Antialias.NONE;for(let[n,i,l]of d)this._ctx.save(),this._ctx.setAntialias(p),this._ctx.setSourceRGBA(e.r,e.g,e.b,l),this._ctx.moveTo(t+s+n,r+c+i),o.show_layout(this._ctx,a),this._ctx.restore()}}this._applyFillStyle(),this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?n.Antialias.DEFAULT:n.Antialias.NONE),this._ctx.moveTo(t+s,r+c),o.show_layout(this._ctx,a),this._ctx.restore()},strokeText(e,t,r,i){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle();let a=createTextLayout(this,e),s=getTextAlignOffset(this,a),c=getTextBaselineOffset(this,a);this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?n.Antialias.DEFAULT:n.Antialias.NONE),this._ctx.moveTo(t+s,r+c),o.layout_path(this._ctx,a),this._ctx.stroke(),this._ctx.restore()},measureText(e){this._ensureSurface();let t=createTextLayout(this,e),[n,r]=t.get_pixel_extents(),i=t.get_baseline()/a.SCALE,o=Math.max(0,i-n.y),s=Math.max(0,n.y+n.height-i),c=t.get_font_description()||parseFontToDescription(this._state.font),l=t.get_context().get_metrics(c,null),u=l.get_ascent()/a.SCALE,d=l.get_descent()/a.SCALE;return{width:r.width,actualBoundingBoxAscent:o,actualBoundingBoxDescent:s,actualBoundingBoxLeft:Math.max(0,-n.x),actualBoundingBoxRight:n.x+n.width,fontBoundingBoxAscent:u,fontBoundingBoxDescent:d,alphabeticBaseline:0,emHeightAscent:u,emHeightDescent:d,hangingBaseline:u*.8,ideographicBaseline:-d}}};function installTextMethods(e){Object.assign(e,kt)}const At={createLinearGradient(e,t,n,r){return new CanvasGradient(`linear`,e,t,n,r)},createRadialGradient(e,t,n,r,i,a){return new CanvasGradient(`radial`,e,t,r,i,n,a)},createPattern(e,t){return wt.create(e,t)}};function installFactoryMethods(e){Object.assign(e,At)}function installAllContextMethods(e){installTransformMethods(e),installPathMethods(e),installDrawingMethods(e),installPixelMethods(e),installTextMethods(e),installFactoryMethods(e)}function createDefaultState(){return{fillStyle:`#000000`,fillColor:{...yt},strokeStyle:`#000000`,strokeColor:{...yt},lineWidth:1,lineCap:`butt`,lineJoin:`miter`,miterLimit:10,lineDash:[],lineDashOffset:0,globalAlpha:1,globalCompositeOperation:`source-over`,shadowColor:`rgba(0, 0, 0, 0)`,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,font:`10px sans-serif`,textAlign:`start`,textBaseline:`alphabetic`,direction:`ltr`,imageSmoothingEnabled:!0,imageSmoothingQuality:`low`}}function cloneState(e){return{...e,fillColor:{...e.fillColor},strokeColor:{...e.strokeColor},lineDash:[...e.lineDash]}}var CanvasRenderingContext2D=class{constructor(e,t){this._stateStack=[],this.canvas=e,this._surfaceWidth=e.width||300,this._surfaceHeight=e.height||150,this._surface=new n.ImageSurface(n.Format.ARGB32,this._surfaceWidth,this._surfaceHeight),this._ctx=new n.Context(this._surface),this._state=createDefaultState()}_ensureSurface(){let e=this.canvas.width||300,t=this.canvas.height||150;(e!==this._surfaceWidth||t!==this._surfaceHeight)&&(this._ctx.$dispose(),this._surface.finish(),this._surfaceWidth=e,this._surfaceHeight=t,this._surface=new n.ImageSurface(n.Format.ARGB32,e,t),this._ctx=new n.Context(this._surface),this._stateStack=[])}_resetState(){this._state=createDefaultState(),this._stateStack=[]}_applyFillStyle(){let e=this._state.fillStyle;if(typeof e==`string`){let e=this._state.fillColor,t=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,t)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof wt&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyStrokeStyle(){let e=this._state.strokeStyle;if(typeof e==`string`){let e=this._state.strokeColor,t=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,t)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof wt&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyPatternFilter(){let e=asCairoPattern(this._ctx.getSource?.());if(!e)return;let t;t=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?n.Filter.BEST:n.Filter.BILINEAR:n.Filter.NEAREST,e.setFilter(t)}_applyLineStyle(){this._ctx.setLineWidth(this._state.lineWidth),this._ctx.setLineCap(xt[this._state.lineCap]),this._ctx.setLineJoin(St[this._state.lineJoin]),this._ctx.setMiterLimit(this._state.miterLimit),this._ctx.setDash(this._state.lineDash,this._state.lineDashOffset)}_applyCompositing(){let e=bt[this._state.globalCompositeOperation];e!==void 0&&this._ctx.setOperator(e)}_getSurface(){return this._surface}_hasShadow(){if(this._state.shadowBlur===0&&this._state.shadowOffsetX===0&&this._state.shadowOffsetY===0)return!1;let e=parseColor(this._state.shadowColor);return e!==null&&e.a>0}_deviceToUserDistance(e,t){let n=this._ctx.userToDevice(0,0),r=this._ctx.userToDevice(1,0),i=this._ctx.userToDevice(0,1),a=(r[0]??0)-(n[0]??0),o=(r[1]??0)-(n[1]??0),s=(i[0]??0)-(n[0]??0),c=(i[1]??0)-(n[1]??0),l=a*c-o*s;return Math.abs(l)<1e-10?[e,t]:[(c*e-s*t)/l,(-o*e+a*t)/l]}_renderShadow(e){}save(){this._ensureSurface(),this._stateStack.push(cloneState(this._state)),this._ctx.save()}restore(){this._ensureSurface();let e=this._stateStack.pop();e&&(this._state=e,this._ctx.restore())}get fillStyle(){return this._state.fillStyle}set fillStyle(e){if(typeof e==`string`){let t=parseColor(e);t&&(this._state.fillStyle=e,this._state.fillColor=t)}else this._state.fillStyle=e}get strokeStyle(){return this._state.strokeStyle}set strokeStyle(e){if(typeof e==`string`){let t=parseColor(e);t&&(this._state.strokeStyle=e,this._state.strokeColor=t)}else this._state.strokeStyle=e}get lineWidth(){return this._state.lineWidth}set lineWidth(e){e>0&&isFinite(e)&&(this._state.lineWidth=e)}get lineCap(){return this._state.lineCap}set lineCap(e){(e===`butt`||e===`round`||e===`square`)&&(this._state.lineCap=e)}get lineJoin(){return this._state.lineJoin}set lineJoin(e){(e===`miter`||e===`round`||e===`bevel`)&&(this._state.lineJoin=e)}get miterLimit(){return this._state.miterLimit}set miterLimit(e){e>0&&isFinite(e)&&(this._state.miterLimit=e)}get globalAlpha(){return this._state.globalAlpha}set globalAlpha(e){e>=0&&e<=1&&isFinite(e)&&(this._state.globalAlpha=e)}get globalCompositeOperation(){return this._state.globalCompositeOperation}set globalCompositeOperation(e){bt[e]!==void 0&&(this._state.globalCompositeOperation=e)}get imageSmoothingEnabled(){return this._state.imageSmoothingEnabled}set imageSmoothingEnabled(e){this._state.imageSmoothingEnabled=!!e}get imageSmoothingQuality(){return this._state.imageSmoothingQuality}set imageSmoothingQuality(e){(e===`low`||e===`medium`||e===`high`)&&(this._state.imageSmoothingQuality=e)}setLineDash(e){e.some(e=>e<0||!isFinite(e))||(this._state.lineDash=[...e])}getLineDash(){return[...this._state.lineDash]}get lineDashOffset(){return this._state.lineDashOffset}set lineDashOffset(e){isFinite(e)&&(this._state.lineDashOffset=e)}get shadowColor(){return this._state.shadowColor}set shadowColor(e){this._state.shadowColor=e}get shadowBlur(){return this._state.shadowBlur}set shadowBlur(e){e>=0&&isFinite(e)&&(this._state.shadowBlur=e)}get shadowOffsetX(){return this._state.shadowOffsetX}set shadowOffsetX(e){isFinite(e)&&(this._state.shadowOffsetX=e)}get shadowOffsetY(){return this._state.shadowOffsetY}set shadowOffsetY(e){isFinite(e)&&(this._state.shadowOffsetY=e)}get font(){return this._state.font}set font(e){this._state.font=e}get textAlign(){return this._state.textAlign}set textAlign(e){this._state.textAlign=e}get textBaseline(){return this._state.textBaseline}set textBaseline(e){this._state.textBaseline=e}get direction(){return this._state.direction}set direction(e){this._state.direction=e}_toDataURL(e,t){this._surface.flush();let n=imports.gi.Gio,r=imports.gi.GLib,[,i]=r.file_open_tmp(`canvas-XXXXXX.png`);try{this._surface.writeToPNG(i);let[,e]=n.File.new_for_path(i).load_contents(null);return`data:image/png;base64,${r.base64_encode(e)}`}finally{try{r.unlink(i)}catch{}}}_dispose(){this._ctx.$dispose(),this._surface.finish()}};installAllContextMethods(CanvasRenderingContext2D.prototype),defineGlobal(`HTMLCanvasElement`,ht),defineGlobal(`CanvasRenderingContext2D`,CanvasRenderingContext2D),defineGlobal(`DOMMatrix`,gt),defineGlobal(`DOMMatrixReadOnly`,_t);const jt=Symbol.for(`gjsify_canvas2d_context`);ht.registerContextFactory(`2d`,(e,t)=>{let n=e,r=n[jt];if(r)return r;let i=new CanvasRenderingContext2D(e,t);return n[jt]=i,i});var CharacterData=class extends st{constructor(e=``){super(),this[z]=G.TEXT_NODE,this._data=e}get data(){return this._data}set data(e){this._data=e}get textContent(){return this._data}set textContent(e){this._data=e}get nodeValue(){return this._data}set nodeValue(e){this._data=e}get length(){return this._data.length}appendData(e){this._data+=e}deleteData(e,t){this._data=this._data.substring(0,e)+this._data.substring(e+t)}insertData(e,t){this._data=this._data.substring(0,e)+t+this._data.substring(e)}replaceData(e,t,n){this._data=this._data.substring(0,e)+n+this._data.substring(e+t)}substringData(e,t){return this._data.substring(e,e+t)}cloneNode(e=!1){return new this.constructor(this._data)}get[Symbol.toStringTag](){return`CharacterData`}},Mt=class Comment extends CharacterData{constructor(e=``){super(e),this[z]=G.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new Comment(this.data)}get[Symbol.toStringTag](){return`Comment`}},Nt=class Text extends CharacterData{constructor(e=``){super(e),this[z]=G.TEXT_NODE}get nodeName(){return`#text`}get wholeText(){let e=this.data,t=this.previousSibling;for(;t&&t instanceof Text;)e=t.data+e,t=t.previousSibling;let n=this.nextSibling;for(;n&&n instanceof Text;)e+=n.data,n=n.nextSibling;return e}splitText(e){let t=this.data.substring(e);this.data=this.data.substring(0,e);let n=new Text(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}cloneNode(e=!1){return new Text(this.data)}get[Symbol.toStringTag](){return`Text`}},Pt=class DocumentFragment extends st{constructor(){super(),this[z]=G.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[H]}get childElementCount(){return this[H].length}get firstElementChild(){return this[H][0]??null}get lastElementChild(){let e=this[H];return e[e.length-1]??null}get textContent(){let e=``;for(let t of this.childNodes)t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){for(;this.firstChild;)this.removeChild(this.firstChild);e&&this.appendChild(new Nt(e))}append(...e){for(let t of e)typeof t==`string`?this.appendChild(new Nt(t)):this.appendChild(t)}prepend(...e){let t=this.firstChild;for(let n of e)typeof n==`string`?this.insertBefore(new Nt(n),t):this.insertBefore(n,t)}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}getElementById(e){for(let t of this.children){if(t.id===e)return t;let n=this._findById(t,e);if(n)return n}return null}_findById(e,t){for(let n of e.children){if(n.id===t)return n;let e=this._findById(n,t);if(e)return e}return null}cloneNode(e=!1){let t=new DocumentFragment;if(e)for(let e of this.childNodes)t.appendChild(e.cloneNode(!0));return t}get[Symbol.toStringTag](){return`DocumentFragment`}},Ft=s;I(),A(),N();var HTMLImageElement=class extends HTMLElement$1{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[Ne]=`IMG`,this[Pe]=`img`,this[Fe]=ct.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let t=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let n=e.indexOf(`,`);if(n===-1){this._complete=!0,this.dispatchEvent(new Event(`error`));return}let r=e.slice(5,n),i=e.slice(n+1),a=r.includes(`;base64`);try{let e;e=a?k.base64_decode(i):new TextEncoder().encode(decodeURIComponent(i));let n=k.Bytes.new(e),r=M.MemoryInputStream.new_from_bytes(n);this._pixbuf=Ft.Pixbuf.new_from_stream(r,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&F.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&F.warn(`[img] error data:: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event(`error`))}return}let n;if(e.startsWith(`file://`))n=k.filename_from_uri(e)[0];else if(e.startsWith(`http://`)||e.startsWith(`https://`)){this._complete=!0,this.dispatchEvent(new Event(`error`));return}else{let t=k.path_get_dirname(c.programInvocationName);n=k.build_filenamev([t,e])}try{t&&F.log(`[img] load ${n}`),this._pixbuf=Ft.Pixbuf.new_from_file(n),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&F.log(`[img] ok ${n} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&F.warn(`[img] error ${n}: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event(`error`))}}get srcset(){return this.getAttribute(`srcset`)??``}set srcset(e){this.setAttribute(`srcset`,e)}get useMap(){return this.getAttribute(`usemap`)??``}set useMap(e){this.setAttribute(`usemap`,e)}get height(){if(this._pixbuf)return this._pixbuf.get_height();let e=this.getAttribute(`height`);return e===null?0:Number(e)}set height(e){this.setAttribute(`height`,String(e))}get width(){if(this._pixbuf)return this._pixbuf.get_width();let e=this.getAttribute(`width`);return e===null?0:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get isMap(){return this.hasAttribute(`ismap`)}set isMap(e){e?this.setAttribute(`ismap`,``):this.removeAttribute(`ismap`)}decode(){return Promise.resolve()}cloneNode(e=!1){return super.cloneNode(e)}getImageData(){if(!this._pixbuf)return null;let e=this._pixbuf.get_has_alpha()?this._pixbuf:this._pixbuf.add_alpha(!1,0,0,0)??this._pixbuf;return{colorSpace:`srgb`,data:new Uint8ClampedArray(e.get_pixels()),height:e.get_height(),width:e.get_width()}}isPixbuf(){return!!this._pixbuf}get[Symbol.toStringTag](){return`HTMLImageElement`}},HTMLMediaElement=class extends HTMLElement$1{constructor(...e){super(...e),this._src=``,this._srcObject=null,this.currentTime=0,this.duration=NaN,this.paused=!0,this.ended=!1,this.volume=1,this.muted=!1,this.defaultMuted=!1,this.loop=!1,this.autoplay=!1,this.preload=``,this.playbackRate=1,this.defaultPlaybackRate=1,this.readyState=0,this.networkState=0}get buffered(){return{length:0,start:()=>0,end:()=>0}}get seekable(){return{length:0,start:()=>0,end:()=>0}}get played(){return{length:0,start:()=>0,end:()=>0}}get src(){return this._src}set src(e){this._src=e,this._srcObject=null,this.dispatchEvent(new Event(`srcchange`))}get srcObject(){return this._srcObject}set srcObject(e){this._srcObject=e,this._src=``,this.dispatchEvent(new Event(`srcobjectchange`))}play(){return this.paused=!1,this.ended=!1,this.dispatchEvent(new Event(`play`)),Promise.resolve()}pause(){this.paused=!0,this.dispatchEvent(new Event(`pause`))}load(){this.readyState=0,this.networkState=2,this.dispatchEvent(new Event(`loadstart`))}canPlayType(e){return``}static{this.HAVE_NOTHING=0}static{this.HAVE_METADATA=1}static{this.HAVE_CURRENT_DATA=2}static{this.HAVE_FUTURE_DATA=3}static{this.HAVE_ENOUGH_DATA=4}static{this.NETWORK_EMPTY=0}static{this.NETWORK_IDLE=1}static{this.NETWORK_LOADING=2}static{this.NETWORK_NO_SOURCE=3}get[Symbol.toStringTag](){return`HTMLMediaElement`}};const It=1e9;function secondsToGstTime(e){return BigInt(Math.round(e*It))}function gstTimeToSeconds(e){return Number(e)/It}var HTMLVideoElement=class extends HTMLMediaElement{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[Ne]=`VIDEO`,this[Pe]=`video`,this[Fe]=ct.html;let e=this;Object.defineProperty(this,"paused",{get(){if(!e._pipeline)return!0;let[,t]=e._pipeline.get_state(0n);return t!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,"currentTime",{get(){if(!e._pipeline)return 0;let[t,n]=e._pipeline.query_position(3);return t?gstTimeToSeconds(n):0},set(t){e._pipeline?.seek(1,3,5,1,secondsToGstTime(t),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,"duration",{get(){if(!e._pipeline)return NaN;let[t,n]=e._pipeline.query_duration(3);return t&&Number(n)>0?gstTimeToSeconds(n):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,"volume",{get(){return e._playbin()?.volume??1},set(t){let n=e._playbin();n&&(n.volume=Math.max(0,Math.min(1,t)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,"muted",{get(){return e._playbin()?.mute??!1},set(t){let n=e._playbin();n&&(n.mute=t)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new Event(`play`)),this.dispatchEvent(new Event(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new Event(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};const Lt=new class Document extends st{static{this._elementFactories=new Map}constructor(){super(),this.body=new HTMLElement$1,this.head=new HTMLElement$1,this.documentElement=new HTMLElement$1,this.appendChild(this.documentElement),this.documentElement.appendChild(this.body)}static registerElementFactory(e,t){Document._elementFactories.set(e.toLowerCase(),t)}createElementNS(e,t){let n=t.toLowerCase();switch(n){case`img`:return new HTMLImageElement;case`video`:return new HTMLVideoElement;case`canvas`:return new ht;default:{let e=Document._elementFactories.get(n);return e?e():new HTMLElement$1}}}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new Nt(e)}createComment(e){return new Mt(e)}createDocumentFragment(){return new Pt}createEvent(e){return new Event(e)}getElementById(e){return this._findById(this.body,e)}_findById(e,t){if(e.id===t)return e;for(let n of e.children){let e=this._findById(n,t);if(e)return e}return null}get[Symbol.toStringTag](){return`Document`}};var DOMTokenList=class{constructor(e,t){this._ownerElement=e,this._attributeName=t}_getTokens(){let e=this._ownerElement.getAttribute(this._attributeName);return e?e.split(/\s+/).filter(e=>e.length>0):[]}_setTokens(e){let t=e.join(` `);t?this._ownerElement.setAttribute(this._attributeName,t):this._ownerElement.removeAttribute(this._attributeName)}get length(){return this._getTokens().length}get value(){return this._ownerElement.getAttribute(this._attributeName)??``}set value(e){e?this._ownerElement.setAttribute(this._attributeName,e):this._ownerElement.removeAttribute(this._attributeName)}item(e){let t=this._getTokens();return e>=0&&e<t.length?t[e]:null}contains(e){return this._getTokens().includes(e)}add(...e){let t=this._getTokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._setTokens(t)}remove(...e){let t=this._getTokens().filter(t=>!e.includes(t));this._setTokens(t)}toggle(e,t){let n=this.contains(e);return t===void 0?n?(this.remove(e),!1):(this.add(e),!0):t?(this.add(e),!0):(this.remove(e),!1)}replace(e,t){let n=this._getTokens(),r=n.indexOf(e);return r===-1?!1:(n[r]=t,this._setTokens(n),!0)}supports(e){return!0}forEach(e){let t=this._getTokens();for(let n=0;n<t.length;n++)e(t[n],n,this)}keys(){return this._getTokens().keys()}values(){return this._getTokens().values()}entries(){return this._getTokens().entries()}[Symbol.iterator](){return this._getTokens().values()}toString(){return this.value}get[Symbol.toStringTag](){return`DOMTokenList`}};I(),defineGlobal(`Text`,Nt),defineGlobal(`Comment`,Mt),defineGlobal(`DocumentFragment`,Pt),defineGlobal(`DOMTokenList`,DOMTokenList),defineGlobal(`document`,Lt),defineGlobalIfMissing(`self`,globalThis);var Window=class{};defineGlobalIfMissing(`Window`,Window),defineGlobalIfMissing(`window`,globalThis),defineGlobalIfMissing(`focus`,()=>{}),defineGlobalIfMissing(`blur`,()=>{});{let e=globalThis;if(typeof e.addEventListener!=`function`){let t=new EventTarget;e.__gjsify_globalEventTarget=t,e.addEventListener=(e,n,r)=>t.addEventListener(e,n,r),e.removeEventListener=(e,n,r)=>t.removeEventListener(e,n,r),e.dispatchEvent=e=>t.dispatchEvent(e)}}defineGlobalIfMissing(`devicePixelRatio`,1),defineGlobalIfMissing(`scrollX`,0),defineGlobalIfMissing(`scrollY`,0),defineGlobalIfMissing(`pageXOffset`,0),defineGlobalIfMissing(`pageYOffset`,0),defineGlobalIfMissing(`alert`,(...e)=>F.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0}),globalThis.navigator===void 0&&(globalThis.navigator={});function atobPolyfill(e){if(typeof globalThis.atob==`function`)return globalThis.atob(e);let t=e.replace(/[=\s]/g,``),n=``,r=0,i=0;for(let e=0;e<t.length;e++)r=r<<6|Rt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n+=String.fromCharCode(r>>i&255));return n}function btoaPolyfill(e){if(typeof globalThis.btoa==`function`)return globalThis.btoa(e);let t=``,n=0;for(;n+2<e.length;n+=3){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8|e.charCodeAt(n+2);t+=K[r>>18&63]+K[r>>12&63]+K[r>>6&63]+K[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=K[r>>18&63]+K[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=K[r>>18&63]+K[r>>12&63]+K[r>>6&63]+`=`}return t}function base64Decode(e){let t=e.replace(/[=\s]/g,``),n=new Uint8Array(t.length*3>>2),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<6|Rt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[a++]=r>>i&255);return n.subarray(0,a)}function base64Encode(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],a=r+1<n?e[r+1]:0,o=r+2<n?e[r+2]:0;t+=K[i>>2],t+=K[(i&3)<<4|a>>4],t+=r+1<n?K[(a&15)<<2|o>>6]:`=`,t+=r+2<n?K[o&63]:`=`}return t}var K,Rt,zt=__esmMin(()=>{K=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Rt=new Uint8Array(256);for(let e=0;e<64;e++)Rt[K.charCodeAt(e)]=e});function normalizeEncoding(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(e){let t=(``+e).toLowerCase().replace(/-/g,``);if(!Bt.includes(t))throw TypeError(`Unknown encoding: ${e}`)}var Bt,Vt=__esmMin(()=>{Bt=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(e,t){switch(t){case`utf8`:return Ht.encode(e);case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`latin1`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`base64`:return base64Decode(e.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(e.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++){let t=parseInt(e[r*2],16),i=parseInt(e[r*2+1],16);if(Number.isNaN(t)||Number.isNaN(i))break;n[r]=t<<4|i}return n}case`utf16le`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}default:return Ht.encode(e)}}function decodeString(e,t,n,r){let i=n!==void 0||r!==void 0?e.subarray(n??0,r??e.length):e;switch(t){case`utf8`:return Ut.decode(i);case`ascii`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]&127);return e}case`latin1`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return e}case`base64`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return btoaPolyfill(e)}case`base64url`:return decodeString(i,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let e=``;for(let t=0;t<i.length;t++)e+=i[t].toString(16).padStart(2,`0`);return e}case`utf16le`:{let e=``;for(let t=0;t+1<i.length;t+=2)e+=String.fromCharCode(i[t]|i[t+1]<<8);return e}default:return Ut.decode(i)}}function checkOffset(e,t,n){if(e+t>n)throw RangeError(`Attempt to access memory outside buffer bounds`)}var Ht,Ut,Wt=__esmMin(()=>{zt(),Ht=new TextEncoder,Ut=new TextDecoder}),Gt,q,Kt,qt,Jt,SlowBuffer,Yt=__esmMin(()=>{Wt(),Vt(),Gt=typeof SharedArrayBuffer<`u`,q=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(e,t,n){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);if(e<0)throw RangeError(`The value "${e}" is invalid for option "size"`);let r=new Buffer(e);return t!==void 0&&t!==0&&r.fill(t,0,e,n),r}static allocUnsafe(e){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);return new Buffer(e)}static allocUnsafeSlow(e){return Buffer.allocUnsafe(e)}static from(e,t,n){if(typeof e==`string`){let n=normalizeEncoding(t);if(t&&typeof t==`string`){let e=(``+t).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(e)||checkEncoding(t)}let r=encodeString(e,n);return new Buffer(r.buffer,r.byteOffset,r.byteLength)}if(ArrayBuffer.isView(e)){let t=new Buffer(e.buffer,e.byteOffset,e.byteLength),n=new Buffer(t.length);return n.set(t),n}if(e instanceof ArrayBuffer){let r=t||0;return new Buffer(e,r,n===void 0?e.byteLength-r:n)}if(Gt&&e instanceof SharedArrayBuffer){let r=t||0,i=n===void 0?e.byteLength-r:n;return new Buffer(new Uint8Array(e,r,i))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let r=e,i=t||0,a=n===void 0?r.byteLength-i:n,o=r.viewBytes(i,a);return new Buffer(o.buffer,o.byteOffset,o.byteLength)}if(Array.isArray(e)){let t=new Buffer(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]&255;return t}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(t)}static byteLength(e,t){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Gt&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(t)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let t=e.length;for(;t>0&&(e[t-1]===`=`||e[t-1]===` `);)t--;return t*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return e.length<t.length?-1:+(e.length>t.length)}static concat(e,t){if(e.length===0)return Buffer.alloc(0);if(t===void 0){t=0;for(let n=0;n<e.length;n++)t+=e[n].length}let n=Buffer.alloc(t),r=0;for(let i=0;i<e.length;i++){let a=e[i],o=Math.min(a.length,t-r);o<=0||(n.set(a.subarray(0,o),r),r+=o)}return n}static poolSize=8192;toString(e,t,n){let r=normalizeEncoding(e);return decodeString(this,r,t,n)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==e[t])return!1;return!0}compare(e,t,n,r,i){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let a=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,o=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(a,o)}copy(e,t=0,n=0,r){let i=r??this.length,a=Math.min(i-n,e.length-t);return a<=0?0:(e.set(this.subarray(n,n+a),t),a)}slice(e,t){let n=e??0,r=t??this.length,i=super.subarray(n,r);return new Buffer(i.buffer,i.byteOffset,i.byteLength)}subarray(e,t){let n=super.subarray(e,t);return new Buffer(n.buffer,n.byteOffset,n.byteLength)}write(e,t,n,r){t??=0;let i=encodeString(e,normalizeEncoding(r||(typeof n==`string`?n:void 0))),a=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,o=Math.min(i.length,a);return this.set(i.subarray(0,o),t),o}fill(e,t,n,r){let i=t??0,a=n??this.length;if(typeof e==`number`)super.fill(e&255,i,a);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,a);else if(t.length===1)super.fill(t[0],i,a);else for(let e=i;e<a;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,a);else for(let t=i;t<a;t++)this[t]=e[(t-i)%e.length];return this}indexOf(e,t,n){if(typeof e==`number`)return super.indexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t??0;outer:for(let e=i;e<=this.length-r.length;e++){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}lastIndexOf(e,t,n){if(typeof e==`number`)return t===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t===void 0?this.length-r.length:Math.min(t,this.length-r.length);outer:for(let e=i;e>=0;e--){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}includes(e,t,n){return this.indexOf(e,t,n)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let t=this[e]<<8|this[e+1];return t&32768?t|4294901760:t}readInt16LE(e=0){checkOffset(e,2,this.length);let t=this[e]|this[e+1]<<8;return t&32768?t|4294901760:t}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n}readUIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n}readIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n>=2**(8*t-1)&&(n-=2**(8*t)),n}readIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n>=2**(8*t-1)&&(n-=2**(8*t)),n}writeUInt8(e,t=0){return checkOffset(t,1,this.length),this[t]=e&255,t+1}writeUInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeUInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeUInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeUInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeInt8(e,t=0){return checkOffset(t,1,this.length),e<0&&(e=255+e+1),this[t]=e&255,t+1}writeInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeFloatBE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!1),t+4}writeFloatLE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!0),t+4}writeDoubleBE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!1),t+8}writeDoubleLE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!0),t+8}writeBigInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!1),t+8}writeBigInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!0),t+8}writeBigUInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!1),t+8}writeBigUInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!0),t+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2){let e=this[t];this[t]=this[t+1],this[t+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4){let e=this[t],n=this[t+1];this[t]=this[t+3],this[t+1]=this[t+2],this[t+2]=n,this[t+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8){let e=this[t],n=this[t+1],r=this[t+2],i=this[t+3];this[t]=this[t+7],this[t+1]=this[t+6],this[t+2]=this[t+5],this[t+3]=this[t+4],this[t+4]=i,this[t+5]=r,this[t+6]=n,this[t+7]=e}return this}},Kt=2**31-1,qt=2**28-16,Jt={MAX_LENGTH:Kt,MAX_STRING_LENGTH:qt},SlowBuffer=class extends q{constructor(e){super(e)}}}),Xt=__exportAll$4({Blob:()=>x,Buffer:()=>q,File:()=>S,INSPECT_MAX_BYTES:()=>50,SlowBuffer:()=>SlowBuffer,atob:()=>Zt,atobPolyfill:()=>atobPolyfill,base64Decode:()=>base64Decode,base64Encode:()=>base64Encode,btoa:()=>Qt,btoaPolyfill:()=>btoaPolyfill,checkEncoding:()=>checkEncoding,constants:()=>Jt,default:()=>$t,kMaxLength:()=>Kt,kStringMaxLength:()=>qt,normalizeEncoding:()=>normalizeEncoding}),Zt,Qt,$t,J=__esmMin(()=>{zt(),w(),Vt(),Yt(),Zt=globalThis.atob,Qt=globalThis.btoa,$t={Buffer:q,SlowBuffer,Blob:x,File:S,atob:Zt,btoa:Qt,kMaxLength:Kt,kStringMaxLength:qt,constants:Jt,INSPECT_MAX_BYTES:50}});J(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:q,enumerable:!1,writable:!0,configurable:!0}),A(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return k.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=k.base64_decode(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return n},enumerable:!0,writable:!0,configurable:!0}),L(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:_e,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let t=null;try{t=e.GioUnix??null}catch{}if(!t)try{t=e.Gio??null}catch{}return t}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const en=getMonotonicTime();function hrtime(e){let t=getMonotonicTime()-en,n=Number(t/1000000000n),r=Number(t%1000000000n);if(e){let t=n-e[0],i=r-e[1];return i<0&&(t--,i+=1e9),[t,i]}return[n,r]}function hrtimeBigint(){return getMonotonicTime()-en}function detectGjsVersion(){try{let e=getGjsGlobal().imports?.system;if(e?.version!==void 0){let t=Number(e.version);return`${Math.floor(t/1e4)}.${Math.floor(t%1e4/100)}.${t%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),t={node:`20.0.0`};return e&&(t.gjs=e),{version:`v20.0.0`,versions:t,title:`gjs`}}function detectPpid(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/PPid:\s+(\d+)/);if(e)return parseInt(e[1],10)}}}catch{}return 0}function detectPlatform(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e&&e.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/stat`);if(t){let e=new TextDecoder().decode(t),n=parseInt(e,10);if(!isNaN(n))return n}}}catch{}return 0}function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return new Proxy({},{get(t,n){if(typeof n==`string`)return e.getenv(n)??void 0},set(t,n,r){return typeof n==`string`?(e.setenv(n,String(r),!0),!0):!1},deleteProperty(t,n){return typeof n==`string`?(e.unsetenv(n),!0):!1},has(t,n){return typeof n==`string`?e.getenv(n)!==null:!1},ownKeys(t){return e.listenv()},getOwnPropertyDescriptor(t,n){if(typeof n!=`string`)return;let r=e.getenv(n);if(r!==null)return{configurable:!0,enumerable:!0,writable:!0,value:r}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let e=getGjsGlobal().imports?.system;if(e?.programArgs)return[`gjs`,e.programInvocationName||``,...e.programArgs]}catch{}return[`gjs`]}function getExecPath(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let e=getGjsGlobal().imports?.system;if(e?.programInvocationName)return e.programInvocationName}catch{}return`/usr/bin/gjs`}function getCwd(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function chdir(e){let t=getGjsGlobal().imports?.gi?.GLib;try{if(t?.chdir){if(!t.file_test(e,16)){let t=Error(`ENOENT: no such file or directory, chdir '${e}'`);throw t.code=`ENOENT`,t.syscall=`chdir`,t.path=e,t}t.chdir(e);return}}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)throw e}if(!t){let t=globalThis.process;if(t&&typeof t.chdir==`function`){t.chdir(e);return}}throw Error(`process.chdir() is not supported in this environment`)}L();function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,a=n?.SOURCE_REMOVE,o=n?.PRIORITY_DEFAULT;if(r?.exit&&i&&typeof o==`number`&&typeof a==`boolean`)return ensureMainLoop(),i(o,()=>(quitMainLoop(),r.exit(e),a)),new Promise(()=>{});try{r?.exit&&r.exit(e)}catch{}let s=globalThis.process;throw s&&typeof s.exit==`function`&&s.exit(e),Error(`process.exit(${e})`)}function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,t){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`;return n.spawn_command_line_sync(`kill ${i} ${e}`),!0}}catch{}if(!isGjs()){let n=globalThis.process;if(n&&typeof n.kill==`function`)return n.kill(e,t)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/VmRSS:\s+(\d+)/),n=e?parseInt(e[1],10)*1024:0;return{rss:n,heapTotal:n,heapUsed:n,external:0,arrayBuffers:0}}}}catch{}if(!isGjs()){let e=globalThis.process;if(e&&typeof e.memoryUsage==`function`)return e.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(e){if(!isGjs()){let t=globalThis.process;if(t&&typeof t.cpuUsage==`function`)return t.cpuUsage(e)}return{user:0,system:0}}let tn=null;const nn=globalThis.imports?.gi;if(nn)try{tn=nn.GjsifyTerminal}catch{}const rn=tn;function onceWrapper(){let{target:e,type:t,listener:n}=this;return this.wrapperFn&&e.removeListener(t,this.wrapperFn),n.apply(e,Array.from(arguments))}function _onceWrap(e,t,n){let r={target:e,type:t,listener:n,wrapperFn:void 0},i=onceWrapper.bind(r);return r.wrapperFn=i,i.listener=n,i}function arrayClone(e){switch(e.length){case 0:return[];case 1:return[e[0]];case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];default:return e.slice()}}function checkListener(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}function validateNumber(e,t){if(typeof e!=`number`||e!==e)throw TypeError(`The "${t}" argument must be of type number. Received type ${typeof e}`)}function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function unwrapListeners(e){let t=Array.from({length:e.length});for(let n=0;n<t.length;++n)t[n]=e[n].listener??e[n];return t}function createAbortError$1(e){let t=Error(`The operation was aborted`);return t.name=`AbortError`,t.code=`ABORT_ERR`,e?.reason&&(t.cause=e.reason),t}var an,on,sn,cn=__esmMin(()=>{I(),an=Symbol(`kCapture`),on=Symbol.for(`nodejs.rejection`),sn=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=on;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(e){if(typeof e!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=e}_events;_eventsCount;_maxListeners;[an];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[an]=e?.captureRejections??EventEmitter._captureRejections}setMaxListeners(e){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e);return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(e,...t){let n=this._events,r=e===`error`;if(n!==void 0)r&&n[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...t),r&&=n.error===void 0;else if(!r)return!1;if(r){let e;if(e=t.length>0?t[0]:Error(`Unhandled error.`),e instanceof Error)throw e;let n=Error(`Unhandled error. (`+e+`)`);throw n.context=e,n}let i=n[e];if(i===void 0)return!1;if(typeof i==`function`){let n=i.apply(this,t);n!=null&&this[an]&&this._addCatch(n,e,t)}else{let n=arrayClone(i),r=n.length;for(let i=0;i<r;++i){let r=n[i].apply(this,t);r!=null&&this[an]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[on];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[an];try{this[an]=!1,this.emit(`error`,e)}finally{this[an]=t}}})}addListener(e,t){return this._addListener(e,t,!1)}on(e,t){return this._addListener(e,t,!1)}prependListener(e,t){return this._addListener(e,t,!0)}_addListener(e,t,n){checkListener(t);let r=this._events;r===void 0?(r=this._events=Object.create(null),this._eventsCount=0):r.newListener!==void 0&&(this.emit(`newListener`,e,t.listener??t),r=this._events);let i=r[e];i===void 0?(r[e]=t,++this._eventsCount):typeof i==`function`?r[e]=n?[t,i]:[i,t]:n?i.unshift(t):i.push(t);let a=this.getMaxListeners();if(a>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>a&&!r[e].warned){typeof r[e]!=`function`&&(r[e].warned=!0);let n=Error(`Possible EventEmitter memory leak detected. ${t} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);n.name=`MaxListenersExceededWarning`,F.warn(n.message)}}return this}once(e,t){return checkListener(t),this.on(e,_onceWrap(this,e,t)),this}prependOnceListener(e,t){return checkListener(t),this.prependListener(e,_onceWrap(this,e,t)),this}removeListener(e,t){checkListener(t);let n=this._events;if(n===void 0)return this;let r=n[e];if(r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit(`removeListener`,e,r.listener??t));else if(typeof r!=`function`){let i=-1;for(let e=r.length-1;e>=0;e--)if(r[e]===t||r[e].listener===t){i=e;break}if(i<0)return this;i===0?r.shift():spliceOne(r,i),r.length===1&&(n[e]=r[0]),n.removeListener!==void 0&&this.emit(`removeListener`,e,t.listener??t)}return this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=this._events;if(t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){let e=Object.keys(t);for(let t=0;t<e.length;++t){let n=e[t];n!==`removeListener`&&this.removeAllListeners(n)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let n=t[e];if(typeof n==`function`)this.removeListener(e,n);else if(n!==void 0)for(let t=n.length-1;t>=0;t--)this.removeListener(e,n[t]);return this}listeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n.listener??n]:unwrapListeners(n)}rawListeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n]:arrayClone(n)}listenerCount(e){let t=this._events;if(t===void 0)return 0;let n=t[e];return n===void 0?0:typeof n==`function`?1:n.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,t,n){return new Promise((r,i)=>{let a=n?.signal;if(a?.aborted){i(createAbortError$1(a));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{a&&a.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$1(a))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),a&&a.addEventListener(`abort`,abortHandler,{once:!0});return}let o=e,eventHandler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&o.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{o.removeListener(t,eventHandler),a&&a.removeEventListener(`abort`,abortHandler),i(e)},o.once(`error`,errorHandler)),o.once(t,eventHandler);let abortHandler=()=>{o.removeListener(t,eventHandler),errorHandler&&o.removeListener(`error`,errorHandler),i(createAbortError$1(a))};a&&a.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,t,n){let r=n?.signal;if(r?.aborted)throw createAbortError$1(r);let i=n?.highWaterMark??2**53-1,a=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(a,`lowWaterMark`);let o=[],s=[],c=null,l=!1,u=!1,eventHandler=(...t)=>{if(s.length>0){let{resolve:e}=s.shift();e({value:t,done:!1})}else o.push(t),o.length>=i&&!u&&(u=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(c=e,s.length>0){let{reject:t}=s.shift();t(e)}d.return()},abortHandler=()=>{errorHandler(createAbortError$1(r))};e.on(t,eventHandler),t!==`error`&&e.on(`error`,errorHandler),r&&r.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(t,eventHandler),e.removeListener(`error`,errorHandler),r&&r.removeEventListener(`abort`,abortHandler),l=!0;for(let{resolve:e}of s)e({value:void 0,done:!0});s.length=0,o.length=0},d={next(){if(o.length>0){let t=o.shift();return u&&o.length<a&&(u=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(c){let e=Promise.reject(c);return c=null,e}return l?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{s.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return l||(c=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return d}static listenerCount(e,t){return e.listenerCount(t)}static getEventListeners(e,t){return typeof e.listeners==`function`?e.listeners(t):[]}static setMaxListeners(e,...t){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(t.length===0)EventEmitter.defaultMaxListeners=e;else for(let n of t)typeof n.setMaxListeners==`function`&&n.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,t){e.aborted&&Promise.resolve().then(()=>t());let handler=()=>t();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}},sn.EventEmitter=sn;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=sn.prototype[e];typeof t==`function`&&Object.defineProperty(sn.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(sn.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(sn.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(sn.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name(createAbortError$1,`createAbortError`)}),ln=__exportAll$4({EventEmitter:()=>Y,addAbortListener:()=>yn,captureRejectionSymbol:()=>un,default:()=>Y,defaultMaxListeners:()=>fn,errorMonitor:()=>dn,getEventListeners:()=>_n,getMaxListeners:()=>mn,listenerCount:()=>vn,on:()=>gn,once:()=>hn,setMaxListeners:()=>pn}),Y,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn=__esmMin(()=>{cn(),L(),Y=makeCallable(sn),Y.EventEmitter=Y,un=Y.captureRejectionSymbol,dn=Y.errorMonitor,fn=Y.defaultMaxListeners,pn=Y.setMaxListeners,mn=Y.getMaxListeners,hn=Y.once,gn=Y.on,_n=Y.getEventListeners,vn=Y.listenerCount,yn=Y.addAbortListener});I(),bn(),L();const xn=new TextEncoder;var ProcessWriteStream=class extends Y{fd;writable=!0;_outGio=null;constructor(e){super(),this.fd=e;let t=getGioNamespace();if(t){let e=t.UnixOutputStream??t.OutputStream;if(e)try{this._outGio=e.new(this.fd,!1)}catch{}}}write(e){if(this._outGio)try{let t=typeof e==`string`?xn.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?F.error(e):F.log(e),!0}get isTTY(){if(rn)return rn.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(rn){let[e,,t]=rn.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(t>0)return t}}catch{}return 80}end(){}destroy(){}get rows(){if(rn){let[e,t]=rn.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`LINES`)??`0`,10);if(t>0)return t}}catch{}return 24}},ProcessReadStream=class extends Y{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return rn?rn.Terminal.is_tty(this.fd):!1}setRawMode(e){return rn&&rn.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`];if(new n.SubprocessLauncher({flags:r}).spawnv(i).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let e=globalThis.imports?.gi,t=e?.GLib??e?.GLib;t?.idle_add?t.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let e=this._gio.UnixInputStream??this._gio.InputStream;if(!e){this._reading=!1;return}try{this._stdinGio=e.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(e,t)=>{this._pendingRead=!1;try{let n=e.read_bytes_finish(t)?.get_data?.()??null;if(n&&n.byteLength>0)this.emit(`data`,Buffer.from(n));else if(n!==null&&n.byteLength===0){this._reading=!1,this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};I(),bn();const Sn=Date.now();var Process=class extends Y{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),this.arch=detectArch(),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid(),this.ppid=detectPpid();let e=detectVersionInfo();this.version=e.version,this.versions=e.versions,this.title=e.title}cwd(){return getCwd()}chdir(e){chdir(e)}kill(e,t){return killPid(e,t)}exit(e){return this.exitCode=e??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(e,...t){typeof queueMicrotask==`function`?queueMicrotask(()=>e(...t)):Promise.resolve().then(()=>e(...t))}hrtime(e){return hrtime(e)}uptime(){return(Date.now()-Sn)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(e){return cpuUsage(e)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(e){return 18}emitWarning(e,t){F.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const X=new Process;if(rn)try{let e=new rn.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{X.stdout.emit(`resize`),X.stderr.emit(`resize`)}),e.start()}catch{}X.platform,X.arch,X.env,X.argv,X.argv0,X.execPath,X.pid,X.ppid,X.version,X.versions,X.cwd.bind(X),X.chdir.bind(X),X.exit.bind(X),X.nextTick.bind(X),Object.assign(X.hrtime.bind(X),{bigint:hrtimeBigint}),X.uptime.bind(X),X.memoryUsage.bind(X),X.cpuUsage.bind(X),X.kill.bind(X),X.abort.bind(X),X.umask.bind(X),X.emitWarning.bind(X),X.execArgv,X.config,X.stdout,X.stderr,X.stdin,L(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:X,enumerable:!1,writable:!0,configurable:!0}),L(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const Cn=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._repeat=r,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let t=e.timeout_add.bind(e);this._id=t(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){if(e instanceof GjsifyTimeout)e._cancel();else if(typeof e==`number`)try{getGLib()?.Source.remove(e)}catch{}}if(Cn){let setT=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!1),setI=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate$1(e,...t){return setTimeout(e,0,...t)}__name(setImmediate$1,`setImmediate`);function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate$1,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});var wn=__exportAll$4({URL:()=>Z,URLSearchParams:()=>En,default:()=>Dn,domainToASCII:()=>domainToASCII,domainToUnicode:()=>domainToUnicode,fileURLToPath:()=>fileURLToPath,format:()=>format$3,parse:()=>parse$3,pathToFileURL:()=>pathToFileURL,resolve:()=>resolve$2});function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function encodeComponent(e){return encodeURIComponent(e).replace(/%20/g,`+`)}function parse$3(e,t,n){if(typeof e!=`string`)throw TypeError(`The "url" argument must be of type string. Received type `+typeof e);let r={protocol:null,slashes:null,auth:null,host:null,port:null,hostname:null,hash:null,search:null,query:null,pathname:null,path:null,href:e},i=e.trim(),a=i.indexOf(`#`);a!==-1&&(r.hash=i.slice(a),i=i.slice(0,a));let o=i.indexOf(`?`);o!==-1&&(r.search=i.slice(o),r.query=t?Object.fromEntries(new En(i.slice(o+1))):i.slice(o+1),i=i.slice(0,o));let s=/^([a-z][a-z0-9.+-]*:)/i.exec(i);if(s&&(r.protocol=s[1].toLowerCase(),i=i.slice(r.protocol.length)),(n||r.protocol)&&i.startsWith(`//`)&&(r.slashes=!0,i=i.slice(2)),r.slashes||r.protocol&&![`javascript:`,`data:`,`mailto:`].includes(r.protocol)){let e=-1;for(let t=0;t<i.length;t++){let n=i[t];if(n===`/`||n===`\\`){e=t;break}}let t=e===-1?i:i.slice(0,e);i=e===-1?``:i.slice(e);let n=t.lastIndexOf(`@`);n===-1?parseHostPort(t,r):(r.auth=decodeURIComponent(t.slice(0,n)),parseHostPort(t.slice(n+1),r))}return r.pathname=i||(r.slashes?`/`:null),(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname||``)+(r.search||``)),r.href=format$3(r),r}function parseHostPort(e,t){if(!e)return;let n=e.indexOf(`[`);if(n!==-1){let r=e.indexOf(`]`,n);if(r!==-1){let i=e.slice(r+1);i.startsWith(`:`)&&(t.port=i.slice(1)),t.hostname=e.slice(n,r+1),t.host=t.hostname+(t.port?`:`+t.port:``);return}}let r=e.lastIndexOf(`:`);if(r!==-1){let n=e.slice(r+1);/^\d*$/.test(n)?(t.port=n||null,t.hostname=e.slice(0,r).toLowerCase()):t.hostname=e.toLowerCase()}else t.hostname=e.toLowerCase();t.host=t.hostname+(t.port?`:`+t.port:``)}function format$3(e){if(typeof e==`string`)return e;if(e instanceof Z)return e.href;let t=e,n=``;if(t.protocol&&(n+=t.protocol),(t.slashes||t.protocol&&![`javascript:`,`data:`,`mailto:`].includes(t.protocol||``))&&(n+=`//`),t.auth&&(n+=encodeURIComponent(t.auth)+`@`),t.host?n+=t.host:(t.hostname&&(n+=t.hostname),t.port&&(n+=`:`+t.port)),t.pathname&&(n+=t.pathname),t.search)n+=t.search;else if(t.query&&typeof t.query==`object`){let e=new En(t.query).toString();e&&(n+=`?`+e)}return t.hash&&(n+=t.hash),n}function resolve$2(e,t){return new Z(t,new Z(e,`resolve://`)).href.replace(/^resolve:\/\//,``)}function fileURLToPath(e){if(typeof e==`string`&&(e=new Z(e)),!(e instanceof Z))throw TypeError(`The "url" argument must be of type string or URL. Received type `+typeof e);if(e.protocol!==`file:`)throw TypeError(`The URL must be of scheme file`);if(e.hostname!==``&&e.hostname!==`localhost`)throw TypeError(`File URL host must be "localhost" or empty on linux`);let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)throw TypeError(`File URL path must not include encoded / characters`)}return decodeURIComponent(t)}function pathToFileURL(e){let t=e;if(e[0]!==`/`)if(typeof globalThis.process?.cwd==`function`)t=globalThis.process.cwd()+`/`+e;else try{k?.get_current_dir&&(t=k.get_current_dir()+`/`+e)}catch{}return new Z(`file://`+encodePathForURL(t))}function encodePathForURL(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`||r>=`0`&&r<=`9`||r===`/`||r===`-`||r===`_`||r===`.`||r===`~`||r===`:`||r===`@`||r===`!`?t+=r:t+=encodeURIComponent(r)}return t}function domainToASCII(e){try{return new Z(`http://${e}`).hostname}catch{return``}}function domainToUnicode(e){try{return new Z(`http://${e}`).hostname}catch{return``}}var Tn,En,Z,Dn,On=__esmMin(()=>{A(),Tn=k.UriFlags.HAS_PASSWORD|k.UriFlags.ENCODED|k.UriFlags.SCHEME_NORMALIZE,En=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`){let t=e.startsWith(`?`)?e.slice(1):e;if(t)for(let e of t.split(`&`)){let t=e.indexOf(`=`);t===-1?this._entries.push([decodeComponent(e),``]):this._entries.push([decodeComponent(e.slice(0,t)),decodeComponent(e.slice(t+1))])}}else if(Array.isArray(e))for(let[t,n]of e)this._entries.push([String(t),String(n)]);else if(e instanceof URLSearchParams)this._entries=e._entries.map(([e,t])=>[e,t]);else for(let t of Object.keys(e))this._entries.push([t,String(e[t])])}get(e){for(let[t,n]of this._entries)if(t===e)return n;return null}getAll(e){return this._entries.filter(([t])=>t===e).map(([,e])=>e)}set(e,t){let n=!1;if(this._entries=this._entries.filter(([t])=>t===e?n?!1:(n=!0,!0):!0),n){for(let n=0;n<this._entries.length;n++)if(this._entries[n][0]===e){this._entries[n][1]=t;break}}else this._entries.push([e,t])}has(e){return this._entries.some(([t])=>t===e)}delete(e){this._entries=this._entries.filter(([t])=>t!==e)}append(e,t){this._entries.push([e,t])}sort(){this._entries.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]))}toString(){return this._entries.map(([e,t])=>encodeComponent(e)+`=`+encodeComponent(t)).join(`&`)}forEach(e){for(let[t,n]of this._entries)e(n,t,this)}*entries(){yield*this._entries}*keys(){for(let[e]of this._entries)yield e}*values(){for(let[,e]of this._entries)yield e}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}},Z=class URL{#e;#t;constructor(e,t){let n=e instanceof URL?e.href:String(e);try{if(t!==void 0){let e=t instanceof URL?t.href:String(t),r=k.Uri.parse(e,Tn);this.#e=r.parse_relative(n,Tn)}else this.#e=k.Uri.parse(n,Tn)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!this.#e)throw TypeError(`Invalid URL: ${n}`);this.#t=new En(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let e=this.#e.get_port();if(e===-1)return``;let t=this.#e.get_scheme();return(t===`http`||t===`ws`)&&e===80||(t===`https`||t===`wss`)&&e===443||t===`ftp`&&e===21?``:String(e)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}get pathname(){return this.#e.get_path()||`/`}get search(){let e=this.#e.get_query();return e?`?`+e:``}get hash(){let e=this.#e.get_fragment();return e?`#`+e:``}get origin(){let e=this.protocol;return e===`http:`||e===`https:`||e===`ftp:`?`${e}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let e=this.protocol,t=this.#e.get_scheme();(t===`http`||t===`https`||t===`ftp`||t===`file`||t===`ws`||t===`wss`||this.hostname)&&(e+=`//`);let n=this.username,r=this.password;n&&(e+=n,r&&(e+=`:`+r),e+=`@`),e+=this.hostname,this.port&&(e+=`:`+this.port);let i=this.pathname;return e+=i,e+=this.search,e+=this.hash,e}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(e){let t=e?._tmpPath;if(typeof t==`string`&&t.length>0){let e=`file://${t}`;return URL._objectURLPaths.set(e,t),e}return`file:///dev/null`}static revokeObjectURL(e){let t=URL._objectURLPaths.get(e);if(t){try{k.unlink(t)}catch{}URL._objectURLPaths.delete(e)}}},__name(parse$3,`parse`),__name(format$3,`format`),__name(resolve$2,`resolve`),Dn={URL:Z,URLSearchParams:En,parse:parse$3,format:format$3,resolve:resolve$2,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});On(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:Z,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:En,enumerable:!1,writable:!0,configurable:!0});let kn;if(globalThis.performance)kn=globalThis.performance;else{let e,_now;try{let t=globalThis.imports?.gi?.GLib;if(!t)throw Error(`GJS imports.gi.GLib not available`);e=t.get_monotonic_time(),_now=()=>(t.get_monotonic_time()-e)/1e3}catch{let t=Date.now();e=0,_now=()=>Date.now()-t}let t=[],n=Date.now()-_now();kn={timeOrigin:n,now:_now,mark(e){let n={name:e,entryType:`mark`,startTime:_now(),duration:0};return t.push(n),n},measure(e,n,r){let i=0,a=_now();if(n){let e=t.find(e=>e.entryType===`mark`&&e.name===n);e&&(i=e.startTime)}if(r){let e=t.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return t.push(o),o},getEntries(){return[...t]},getEntriesByName(e){return t.filter(t=>t.name===e)},getEntriesByType(e){return t.filter(t=>t.entryType===e)},clearMarks(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`mark`&&(!e||t[n].name===e)&&t.splice(n,1)},clearMeasures(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`measure`&&(!e||t[n].name===e)&&t.splice(n,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:n}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const An=globalThis,jn=An.PerformanceObserver||PerformanceObserverStub;An.PerformanceEntry,An.PerformanceObserverEntryList,An.PerformanceMark,An.PerformanceMeasure;const Mn=globalThis;globalThis.performance===void 0&&(Mn.performance=kn),typeof Mn.PerformanceObserver!=`function`&&(Mn.PerformanceObserver=jn);const Nn=Symbol(`abort`),Pn=Symbol(`internal`);var Fn=class AbortSignal extends EventTarget{#e=!1;reason=void 0;onabort=null;constructor(e){if(super(),e!==Pn)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.reason}[Nn](e){if(this.#e)return;this.#e=!0,this.reason=e??new Ve(`The operation was aborted.`,`AbortError`);let t=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,t),this.dispatchEvent(t)}static abort(e){let t=new AbortSignal(Pn);return t[Nn](e),t}static timeout(e){let t=new AbortSignal(Pn);return setTimeout(()=>{t[Nn](new Ve(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(Pn);for(let n of e)if(n.aborted)return t[Nn](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Nn](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},In=class AbortController{signal;constructor(){this.signal=new Fn(Pn)}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Nn](e)}};const Ln=globalThis;globalThis.AbortController===void 0&&(Ln.AbortController=In),globalThis.AbortSignal===void 0&&(Ln.AbortSignal=Fn);const Q=Symbol(`kState`),$=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[Q]!==void 0&&t[$]===e}function dequeueValue(e){let t=e[Q].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[Q].queueTotalSize=Math.max(0,e[Q].queueTotalSize-r),n}function resetQueue(e){e[Q].queue=[],e[Q].queueTotalSize=0}function peekQueueValue(e){return e[Q].queue[0].value}function enqueueValueWithSize(e,t,n){if(n=+n,typeof n!=`number`||n<0||Number.isNaN(n)||n===1/0)throw RangeError(`Invalid size: ${n}`);e[Q].queue.push({value:t,size:n}),e[Q].queueTotalSize+=n}function extractHighWaterMark(e,t){if(e===void 0)return t;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,t,n){if(typeof t!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>t.call(n,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const Rn={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let t={[Symbol.iterator]:()=>e.iterator},n=(async function*(){return yield*t})();return{iterator:n,nextMethod:n.next,done:!1}}function getIterator(e,t=`sync`,n){if(n===void 0)if(t===`async`){if(n=e[Symbol.asyncIterator],n==null){let t=e[Symbol.iterator];if(t===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,t))}}else n=e[Symbol.iterator];if(n===void 0)throw TypeError(`Object is not iterable`);let r=n.call(e);if(typeof r!=`object`||!r)throw TypeError(`The iterator method must return an object`);return{iterator:r,nextMethod:r.next,done:!1}}function iteratorNext(e,t){let n;if(n=t===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,t),typeof n!=`object`||!n)throw TypeError(`The iterator.next() method must return an object`);return n}const zn=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},Bn=Symbol(`kAbort`),Vn=Symbol(`kCloseSentinel`),Hn=Symbol(`kError`),Un=Symbol(`kSkipThrow`);var WritableStream=class{[$]=`WritableStream`;[Q];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);let n=e?.type;if(n!==void 0)throw RangeError(`Invalid type: ${n}`);this[Q]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!Wn(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return Wn(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return Wn(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!Wn(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[$]=`WritableStreamDefaultWriter`;[Q];constructor(e){if(!Wn(e))throw TypeError(`Expected a WritableStream`);this[Q]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return Gn(this)?this[Q].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!Gn(this))throw TypeError(`Invalid this`);if(this[Q].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return Gn(this)?this[Q].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return Gn(this)?this[Q].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!Gn(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Q];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!Gn(this))throw TypeError(`Invalid this`);let{stream:e}=this[Q];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return Gn(this)?this[Q].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[$]=`WritableStreamDefaultController`;[Q];constructor(e){if(e!==Un)throw TypeError(`Illegal constructor`)}[Bn](e){let t=this[Q].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[Hn](){resetQueue(this)}get signal(){if(!Kn(this))throw TypeError(`Invalid this`);return this[Q].abortController.signal}error(e){if(!Kn(this))throw TypeError(`Invalid this`);this[Q].stream[Q].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const Wn=isBrandCheck(`WritableStream`),Gn=isBrandCheck(`WritableStreamDefaultWriter`),Kn=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[Q].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[Q].stream=t,t[Q].writer=e,t[Q].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[Q].backpressure?e[Q].ready=Promise.withResolvers():e[Q].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Q].close=Promise.withResolvers();break;case`erroring`:e[Q].ready={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].ready.promise),e[Q].close=Promise.withResolvers();break;case`closed`:e[Q].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Q].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Q].ready={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},e[Q].close={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].ready.promise),setPromiseHandled(e[Q].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[Q];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[Q].abortController.abort(t),e[Q].pendingAbortRequest.abort.promise!==void 0)return e[Q].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let a=Promise.withResolvers();return e[Q].pendingAbortRequest={abort:a,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),a.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[Q];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Q].closeRequest=Promise.withResolvers();let{promise:a}=e[Q].closeRequest;return n!==void 0&&r&&t===`writable`&&n[Q].ready.resolve?.(),writableStreamDefaultControllerClose(i),a}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[Q];n!==void 0&&e[Q].backpressure!==t&&(t?n[Q].ready=Promise.withResolvers():n[Q].ready.resolve?.()),e[Q].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[Q];e[Q].state=`erroring`,e[Q].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[Q].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Q].closeRequest.promise!==void 0&&(e[Q].closeRequest.reject?.(e[Q].storedError),e[Q].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Q].close.promise),e[Q].close.reject?.(e[Q].storedError);let{writer:t}=e[Q];t!==void 0&&(setPromiseHandled(t[Q].close.promise),t[Q].close.reject?.(e[Q].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[Q].writeRequests.shift();e[Q].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[Q].inFlightCloseRequest=e[Q].closeRequest,e[Q].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Q].inFlightWriteRequest.promise!==void 0||e[Q].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[Q].inFlightWriteRequest.reject?.(t),e[Q].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[Q].inFlightWriteRequest.resolve?.(),e[Q].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[Q].inFlightCloseRequest.reject?.(t),e[Q].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Q].pendingAbortRequest.abort.promise!==void 0&&(e[Q].pendingAbortRequest.abort.reject?.(t),e[Q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[Q].inFlightCloseRequest.resolve?.(),e[Q].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Q].state===`erroring`&&(e[Q].storedError=void 0,e[Q].pendingAbortRequest.abort.promise!==void 0&&(e[Q].pendingAbortRequest.abort.resolve?.(),e[Q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Q].state=`closed`,e[Q].writer!==void 0&&e[Q].writer[Q].close.resolve?.(),e[Q].close.resolve?.()}function writableStreamFinishErroring(e){e[Q].state=`errored`,e[Q].controller[Hn]();let t=e[Q].storedError;for(let n of e[Q].writeRequests)n.reject?.(t);if(e[Q].writeRequests=[],e[Q].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[Q].pendingAbortRequest;if(e[Q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},n.wasAlreadyErroring){n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[Q].controller[Bn](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[Q].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Q].closeRequest.promise!==void 0||e[Q].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[Q].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[Q],{controller:r}=n[Q],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[Q].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:a}=n[Q];if(a===`errored`)return Promise.reject(n[Q].storedError);if(writableStreamCloseQueuedOrInFlight(n)||a===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(a===`erroring`)return Promise.reject(n[Q].storedError);let o=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),o}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[Q],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[Q].writer=void 0,e[Q].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[Q];switch(t[Q].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[Q].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[Q].ready.reject?(e[Q].ready.reject(t),e[Q].ready.resolve=void 0,e[Q].ready.reject=void 0):e[Q].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[Q].close.reject?(e[Q].close.reject(t),e[Q].close.resolve=void 0,e[Q].close.reject=void 0):e[Q].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[Q],{state:n}=t[Q];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[Q].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Q].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[Q].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[Q];!writableStreamCloseQueuedOrInFlight(r)&&r[Q].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[Q];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[Q];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[Q].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[Q];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Q].highWaterMark-e[Q].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[Q];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[Q].stream[Q].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Q].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,Vn,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Q].writeAlgorithm=void 0,e[Q].closeAlgorithm=void 0,e[Q].abortAlgorithm=void 0,e[Q].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[Q];if(!n||r[Q].inFlightWriteRequest.promise!==void 0)return;if(r[Q].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===Vn?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(Un),a=t?.start,o=t?.write,s=t?.close,c=t?.abort;setupWritableStreamDefaultController(e,i,a?a.bind(t,i):nonOpStart,o?createPromiseCallback(`sink.write`,o,t):nonOpWrite,s?createPromiseCallback(`sink.close`,s,t):nonOpCancel,c?createPromiseCallback(`sink.abort`,c,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,a,o,s){t[Q]={abortAlgorithm:a,closeAlgorithm:i,highWaterMark:o,queue:[],queueTotalSize:0,abortController:new zn,sizeAlgorithm:s,started:!1,stream:e,writeAlgorithm:r},e[Q].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let c=n();new Promise(e=>e(c)).then(()=>{t[Q].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[Q].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,a=()=>1){let o=Object.create(WritableStream.prototype);return o[$]=`WritableStream`,o[Q]=createWritableStreamState(),setupWritableStreamDefaultController(o,new WritableStreamDefaultController(Un),e,t,n,r,i,a),o}L();const qn=Symbol(`kCancel`),Jn=Symbol(`kClose`),Yn=Symbol(`kChunk`),Xn=Symbol(`kError`),Zn=Symbol(`kPull`),Qn=Symbol(`kRelease`),$n=Symbol(`kSkipThrow`);let er,tr;function lazyReadableReleasedError(){return er||(er=TypeError(`Reader released`),er)}function lazyReadableReleasingError(){return tr||(tr=TypeError(`Releasing reader`),tr)}function createAbortError(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name(this,`ReadableStream`)}[$]=`ReadableStream`;[Q];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);this[Q]=createReadableStreamState();let n=t?.size,r=t?.highWaterMark,i=e?.type;if(i!==void 0){if(`${i}`==`bytes`){if(n!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(r,0));return}throw RangeError(`Invalid type: ${i}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(r,1),extractSizeAlgorithm(n))}get locked(){if(!nr(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return nr(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!nr(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=e?.mode;if(t===void 0)return new ReadableStreamDefaultReader(this);if(`${t}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${t}`)}pipeThrough(e,t={}){if(!nr(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!nr(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!Wn(r))throw TypeError(`transform.writable must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let i=t?.preventAbort,a=t?.preventCancel,o=t?.preventClose,s=t?.signal;if(s!==void 0&&!(s instanceof Object&&`aborted`in s))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(r))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,r,!!o,!!i,!!a,s)),n}pipeTo(e,t={}){try{if(!nr(this))throw TypeError(`Invalid this`);if(!Wn(e))throw TypeError(`destination must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let n=t?.preventAbort,r=t?.preventCancel,i=t?.preventClose,a=t?.signal;if(a!==void 0&&!(a instanceof Object&&`aborted`in a))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!i,!!n,!!r,a)}catch(e){return Promise.reject(e)}}tee(){if(!nr(this))throw TypeError(`Invalid this`);let e=this[Q].controller;return ar(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!nr(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=!!e?.preventCancel,n=new ReadableStreamDefaultReader(this),r={done:!1,current:void 0},i=!1;function nextSteps(){if(r.done)return Promise.resolve({done:!0,value:void 0});if(n[Q].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:t,reject:i}=Promise.withResolvers();return readableStreamDefaultReaderRead(n,{[Yn](e){r.current=void 0,t({value:e,done:!1})},[Jn](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[Xn](e){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),i(e)}}),e}async function returnSteps(e){if(r.done)return{done:!0,value:e};if(r.done=!0,n[Q].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!t){let t=readableStreamReaderGenericCancel(n,e);return readableStreamReaderGenericRelease(n),await t,{done:!0,value:e}}return readableStreamReaderGenericRelease(n),{done:!0,value:e}}return Object.setPrototypeOf({next(){return i||=(r.current=Promise.resolve(),!0),r.current=r.current===void 0?nextSteps():r.current.then(nextSteps,nextSteps),r.current},return(e){return i=!0,r.current=r.current===void 0?returnSteps(e):r.current.then(()=>returnSteps(e),()=>returnSteps(e)),r.current},[Symbol.asyncIterator](){return this}},Rn)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Q];constructor(){this[Q]=Promise.withResolvers()}[Yn](e){this[Q].resolve?.({value:e,done:!1})}[Jn](){this[Q].resolve?.({value:void 0,done:!0})}[Xn](e){this[Q].reject?.(e)}get promise(){return this[Q].promise}},ReadableStreamDefaultReader=class{[$]=`ReadableStreamDefaultReader`;[Q];constructor(e){if(!nr(e))throw TypeError(`Expected a ReadableStream`);this[Q]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!ir(this))return Promise.reject(TypeError(`Invalid this`));if(this[Q].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Q].stream,t=e[Q].controller;if(e[Q].state===`readable`&&rr(t)&&t[Q].queue.length>0){e[Q].disturbed=!0;let n=dequeueValue(t);return t[Q].closeRequested&&!t[Q].queue.length?(readableStreamDefaultControllerClearAlgorithms(t),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(t),Promise.resolve({value:n,done:!1})}let n=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,n),n.promise}releaseLock(){if(!ir(this))throw TypeError(`Invalid this`);this[Q].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return ir(this)?this[Q].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return ir(this)?this[Q].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[$]=`ReadableStreamDefaultController`;[Q];constructor(e){if(e!==$n)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[qn](e){return readableStreamDefaultControllerCancelSteps(this,e)}[Zn](e){readableStreamDefaultControllerPullSteps(this,e)}[Qn](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const nr=isBrandCheck(`ReadableStream`),rr=isBrandCheck(`ReadableStreamDefaultController`),ir=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Q].reader!==void 0}function readableStreamCancel(e,t){switch(e[Q].disturbed=!0,e[Q].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Q].storedError)}readableStreamClose(e);let n=e[Q].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[Q].readIntoRequests;n[Q].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][Jn](void 0)}return e[Q].controller[qn](t).then(()=>{})}function readableStreamClose(e){e[Q].state=`closed`,e[Q].closedPromise.resolve();let{reader:t}=e[Q];if(t!==void 0&&(t[Q].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[Q].readRequests.length;e++)t[Q].readRequests[e][Jn]();t[Q].readRequests=[]}}function readableStreamError(e,t){e[Q].state=`errored`,e[Q].storedError=t,setPromiseHandled(e[Q].closedPromise.promise),e[Q].closedPromise.reject(t);let{reader:n}=e[Q];if(n!==void 0){if(setPromiseHandled(n[Q].close.promise),n[Q].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[Q].readRequests.length;e++)n[Q].readRequests[e][Xn](t);n[Q].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[Q].readIntoRequests.length;e++)n[Q].readIntoRequests[e][Xn](t);n[Q].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[Q];return t===void 0?!1:t[Q]!==void 0&&t[$]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Q].reader[Q].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[Q],i=r[Q].readRequests.shift();n?i[Jn]():i[Yn](t)}function readableStreamAddReadRequest(e,t){e[Q].reader[Q].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[Q];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[Q].stream=t,t[Q].reader=e,t[Q].state){case`readable`:e[Q].close=Promise.withResolvers();break;case`closed`:e[Q].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Q].close={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[Q],n=lazyReadableReleasedError();t[Q].state===`readable`?e[Q].close.reject?.(n):e[Q].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].close.promise),t[Q].controller[Qn](),t[Q].reader=void 0,e[Q].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[Q].readRequests.length;++n)e[Q].readRequests[n][Xn](t);e[Q].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[Q];switch(n[Q].disturbed=!0,n[Q].state){case`closed`:t[Jn]();break;case`errored`:t[Xn](n[Q].storedError);break;case`readable`:n[Q].controller[Zn](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[Q].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Q].closeRequested=!0,e[Q].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Q].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[Q];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[Q].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[Q];return!e[Q].closeRequested&&t[Q].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[Q];switch(t[Q].state){case`errored`:return null;case`closed`:return 0;default:return n-r}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:t}=e[Q];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Q].started)return!1;if(isReadableStreamLocked(t)&&readableStreamGetNumReadRequests(t))return!0;let n=readableStreamDefaultControllerGetDesiredSize(e);return n!==null&&n>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[Q].pulling){e[Q].pullAgain=!0;return}e[Q].pulling=!0,e[Q].pullAlgorithm(e).then(()=>{e[Q].pulling=!1,e[Q].pullAgain&&(e[Q].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Q].pullAlgorithm=void 0,e[Q].cancelAlgorithm=void 0,e[Q].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[Q];n[Q].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[Q].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[Q];if(r.length){let i=dequeueValue(e);e[Q].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[Yn](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,a,o){t[Q]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:a,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:o,stream:e},e[Q].controller=t;let s=n();new Promise(e=>e(s)).then(()=>{t[Q].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController($n),a=t?.start,o=t?.pull,s=t?.cancel;setupReadableStreamDefaultController(e,i,a?a.bind(t,i):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let a=Object.create(ReadableStream$1.prototype);return a[$]=`ReadableStream`,a[Q]=createReadableStreamState(),setupReadableStreamDefaultController(a,new ReadableStreamDefaultController($n),e,t,n,r,i),a}function readableStreamFromIterable(e){let t,n=getIterator(e,`async`),r=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(n);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(t[Q].controller):readableStreamDefaultControllerEnqueue(t[Q].controller,e.value)})}async function cancelAlgorithm(e){let t=n.iterator,r=t.return;if(r===void 0)return Promise.resolve();let i=r.call(t,e);return Promise.resolve(i).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return t=createReadableStream(r,pullAlgorithm,cancelAlgorithm,0),t}function readableStreamPipeTo(e,t,n,r,i,a){let o,s;try{o=new ReadableStreamDefaultReader(e),s=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[Q].disturbed=!0;let c=!1,{promise:l,resolve:u,reject:d}=Promise.withResolvers(),p={currentWrite:Promise.resolve()},m;function finalize(e,t){writableStreamDefaultWriterRelease(s),readableStreamReaderGenericRelease(o),a!==void 0&&m&&(a.removeEventListener(`abort`,m),m=void 0),e?d(t):u()}async function waitForCurrentWrite(){let e=p.currentWrite;await e,e!==p.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(c)return;if(c=!0,t[Q].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!n,r),e=>finalize(!0,e))}}function shutdown(e,n){if(!c){if(c=!0,t[Q].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=a.reason&&a.reason.name===`AbortError`?createAbortError():a.reason;let o=[];r||o.push(()=>t[Q].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||o.push(()=>e[Q].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(o.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[Q].state===`errored`?n(e[Q].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[Q].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[Yn](e){_e(()=>{p.currentWrite=writableStreamDefaultWriterWrite(s,e),setPromiseHandled(p.currentWrite),h.resolve(!1)})}[Jn](){h.resolve(!0)}[Xn](e){h.reject(e)}}let h={resolve:null,reject:null};async function step(){if(c||t[Q].backpressure&&(await s[Q].ready.promise,c))return!0;let n=e[Q].controller;if(e[Q].state===`readable`&&rr(n)&&n[Q].queue.length>0){for(;n[Q].queue.length>0;){if(c)return!0;let r=dequeueValue(n);if(n[Q].closeRequested&&!n[Q].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),p.currentWrite=writableStreamDefaultWriterWrite(s,r),setPromiseHandled(p.currentWrite),t[Q].backpressure||t[Q].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[Q].state===`closed`}let{promise:r,resolve:i,reject:a}=Promise.withResolvers();return h={resolve:i,reject:a},readableStreamDefaultReaderRead(o,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(a!==void 0){if(a.aborted)return abortAlgorithm(),l;m=abortAlgorithm,a.addEventListener(`abort`,m,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,o[Q].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,s[Q].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,o[Q].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(s));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[Q].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return l}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,a=!1,o,s,c,l,u=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[Yn](e){_e(()=>{r=!1;let n=e,o=e;if(!a&&t)try{o=structuredClone(o)}catch{}i||readableStreamDefaultControllerEnqueue(c[Q].controller,n),a||readableStreamDefaultControllerEnqueue(l[Q].controller,o)})},[Jn](){_e(()=>{r=!1,i||readableStreamDefaultControllerClose(c[Q].controller),a||readableStreamDefaultControllerClose(l[Q].controller),(!i||!a)&&u.resolve(void 0)})},[Xn](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,o=t,a){let t=[o,s];u.resolve(readableStreamCancel(e,t))}return u.promise}function cancel2Algorithm(t){if(a=!0,s=t,i){let t=[o,s];u.resolve(readableStreamCancel(e,t))}return u.promise}return c=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),l=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[Q].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(c[Q].controller,e),readableStreamDefaultControllerError(l[Q].controller,e),(!i||!a)&&u.resolve(void 0)}),[c,l]}var BYOBReadIntoRequest=class{[Q];constructor(){this[Q]=Promise.withResolvers()}[Yn](e){this[Q].resolve?.({value:e,done:!1})}[Jn](e){this[Q].resolve?.({value:e,done:!0})}[Xn](e){this[Q].reject?.(e)}get promise(){return this[Q].promise}},ReadableStreamBYOBReader=class{[$]=`ReadableStreamBYOBReader`;[Q];constructor(e){if(!nr(e))throw TypeError(`Expected a ReadableStream`);this[Q]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!or(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let n=e.buffer,r=e.byteLength;if(r===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(n.byteLength===0)return isDetachedBuffer(n)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let i=t?.min??1;if(typeof i!=`number`||i<1||!Number.isInteger(i)||Number.isNaN(i))return Promise.reject(TypeError(`options.min must be a positive integer`));let a=e[Symbol.toStringTag];if(a!==void 0&&a!==`DataView`){if(i>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(i>r)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[Q].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let o=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,o),o.promise}releaseLock(){if(!or(this))throw TypeError(`Invalid this`);this[Q].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return or(this)?this[Q].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return or(this)?this[Q].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[$]=`ReadableStreamBYOBRequest`;[Q];constructor(e){if(e!==$n)throw TypeError(`Illegal constructor`)}get view(){if(!sr(this))throw TypeError(`Invalid this`);return this[Q].view}respond(e){if(!sr(this))throw TypeError(`Invalid this`);if(this[Q].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let t=this[Q].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Q].controller,e)}respondWithNewView(e){if(!sr(this))throw TypeError(`Invalid this`);if(this[Q].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[Q].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[$]=`ReadableByteStreamController`;[Q];constructor(e){if(e!==$n)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!ar(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!ar(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!ar(this))throw TypeError(`Invalid this`);if(this[Q].closeRequested)throw TypeError(`Close already requested`);if(this[Q].stream[Q].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!ar(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[Q].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Q].stream[Q].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!ar(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[qn](e){return readableByteStreamControllerCancelSteps(this,e)}[Zn](e){readableByteStreamControllerPullSteps(this,e)}[Qn](){if(this[Q].pendingPullIntos.length>0){let e=this[Q].pendingPullIntos[0];e.readerType=`none`,this[Q].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const ar=isBrandCheck(`ReadableByteStreamController`),or=isBrandCheck(`ReadableStreamBYOBReader`),sr=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[Q];return t===void 0?!1:t[Q]!==void 0&&t[$]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Q].reader[Q].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[Q].reader[Q].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[Q],i=r[Q].readIntoRequests.shift();n?i[Jn](t):i[Yn](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!ar(t[Q].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[Q].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[Q];i[Q].disturbed=!0,i[Q].state===`errored`?r[Xn](i[Q].storedError):readableByteStreamControllerPullInto(i[Q].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[Q].readIntoRequests.length;n++)e[Q].readIntoRequests[n][Xn](t);e[Q].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Q].pullAlgorithm=void 0,e[Q].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Q].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[Q].byobRequest;t!=null&&(t[Q].controller=void 0,t[Q].view=null,e[Q].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[Q];n[Q].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[Q].stream[Q].state;return t===`errored`?null:t===`closed`?0:e[Q].highWaterMark-e[Q].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[Q];if(t[Q].state!==`readable`||e[Q].closeRequested||!e[Q].started)return!1;if(readableStreamHasDefaultReader(t)&&readableStreamGetNumReadRequests(t)>0||readableStreamHasBYOBReader(t)&&readableStreamGetNumReadIntoRequests(t)>0)return!0;let n=readableByteStreamControllerGetDesiredSize(e);return n!==null&&n>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[Q].pulling){e[Q].pullAgain=!0;return}e[Q].pulling=!0,e[Q].pullAlgorithm(e).then(()=>{e[Q].pulling=!1,e[Q].pullAgain&&(e[Q].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[Q].queueTotalSize===0&&e[Q].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Q].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[Q].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[Q].queueTotalSize+=r}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,t,n,r){let i;try{i=t.slice(n,n+r)}catch(t){readableByteStreamControllerError(e,t);return}readableByteStreamControllerEnqueueChunkToQueue(e,i,0,r)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t){t.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,t.buffer,t.byteOffset,t.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[Q].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n){n.bytesFilled+=t}function readableByteStreamControllerConvertPullIntoDescriptor(e){let t=e.bytesFilled,n=e.elementSize,r=transferArrayBuffer(e.buffer);return e.buffer=r,new e.viewConstructor(r,e.byteOffset,t/n)}function readableByteStreamControllerCommitPullIntoDescriptor(e,t){let n=!1;e[Q].state===`closed`&&(n=!0);let r=readableByteStreamControllerConvertPullIntoDescriptor(t);t.readerType===`default`?readableStreamFulfillReadRequest(e,r,n):readableStreamFulfillReadIntoRequest(e,r,n)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t){let n=Math.min(e[Q].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,a=!1,o=r-r%t.elementSize;o>=t.minimumFill&&(i=o-t.bytesFilled,a=!0);let s=e[Q].queue;for(;i>0;){let n=s[0],r=Math.min(i,n.byteLength),a=t.byteOffset+t.bytesFilled,o=new Uint8Array(t.buffer,a,r),c=new Uint8Array(n.buffer,n.byteOffset,r);o.set(c),n.byteLength===r?s.shift():(n.byteOffset+=r,n.byteLength-=r),e[Q].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return a}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[Q].queue.shift();e[Q].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[Yn](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[Q].stream[Q].reader;for(;t[Q].readRequests.length!==0;){if(e[Q].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[Q].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Q].pendingPullIntos.length!==0;){if(e[Q].queueTotalSize===0)return;let t=e[Q].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Q].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Q].byobRequest===null&&e[Q].pendingPullIntos.length!==0){let t=e[Q].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest($n);r[Q]={controller:e,view:n},e[Q].byobRequest=r}return e[Q].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[Q];if(e[Q].closeRequested||n[Q].state!==`readable`)return;let r=t.buffer,i=t.byteLength,a=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let o=transferArrayBuffer(r);if(e[Q].pendingPullIntos.length!==0){let t=e[Q].pendingPullIntos[0];if(isDetachedBuffer(t.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),t.buffer=transferArrayBuffer(t.buffer),t.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t)}readableStreamHasDefaultReader(n)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(n)===0?readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i):(e[Q].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(o,a,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[Q];if(!(e[Q].closeRequested||t[Q].state!==`readable`)){if(e[Q].queueTotalSize>0){e[Q].closeRequested=!0;return}if(e[Q].pendingPullIntos.length!==0){let t=e[Q].pendingPullIntos[0];if(t.bytesFilled%t.elementSize!==0){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,t),t}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(t)}}function readableByteStreamControllerPullInto(e,t,n,r){let i=e[Q].stream,a=t[Symbol.toStringTag],o,s;if(a===void 0||a===`DataView`)o=DataView,s=1;else{let e=typedArrayConstructorByTag(a);if(!e){r[Xn](TypeError(`Unsupported typed array: ${a}`));return}o=e,s=elementSizeByTag(a)}let c=t.buffer,l=t.byteLength,u=t.byteOffset,d=n*s,p;try{p=transferArrayBuffer(c)}catch(e){r[Xn](e);return}let m={buffer:p,bufferByteLength:p.byteLength,byteOffset:u,byteLength:l,bytesFilled:0,minimumFill:d,elementSize:s,viewConstructor:o,readerType:`byob`};if(e[Q].pendingPullIntos.length!==0){e[Q].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r);return}if(i[Q].state===`closed`){let e=new o(m.buffer,m.byteOffset,0);r[Jn](e);return}if(e[Q].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,m)){let t=readableByteStreamControllerConvertPullIntoDescriptor(m);readableByteStreamControllerHandleQueueDrain(e),r[Yn](t);return}if(e[Q].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[Xn](t);return}}e[Q].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[Q].pendingPullIntos[0];if(e[Q].stream[Q].state===`closed`){if(t!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(t===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(n.bytesFilled+t>n.byteLength)throw RangeError(`bytesWritten out of range`)}n.buffer=transferArrayBuffer(n.buffer),readableByteStreamControllerRespondInternal(e,t)}function readableByteStreamControllerRespondWithNewView(e,t){let n=e[Q].pendingPullIntos[0],r=e[Q].stream[Q].state,i=t.byteLength,a=t.byteOffset,o=t.buffer;if(r===`closed`){if(i!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(i===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(n.byteOffset+n.bytesFilled!==a)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==o.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(n.bytesFilled+i>n.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);n.buffer=transferArrayBuffer(o),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[Q].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Q].stream[Q].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[Q].stream;if(readableStreamHasBYOBReader(n))for(;readableStreamGetNumReadIntoRequests(n)>0;)readableByteStreamControllerCommitPullIntoDescriptor(n,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,t,n){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n),n.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(n.bytesFilled<n.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let r=n.bytesFilled%n.elementSize;if(r>0){let t=n.byteOffset+n.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,n.buffer,t-r,r)}n.bytesFilled-=r,readableByteStreamControllerCommitPullIntoDescriptor(e[Q].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[Q].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[Q].stream;if(e[Q].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[Q].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[Xn](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Q].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,a,o){t[Q]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:a,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:o},e[Q].controller=t;let s=n();new Promise(e=>e(s)).then(()=>{t[Q].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController($n),i=t?.start,a=t?.pull,o=t?.cancel,s=t?.autoAllocateChunkSize;if(s!==void 0&&(s===0||!Number.isInteger(s)||s<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,a?createPromiseCallback(`source.pull`,a,t):nonOpPull,o?createPromiseCallback(`source.cancel`,o,t):nonOpCancel,n,s)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,a,o,s=Promise.withResolvers(),c,l,u,d;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||u.close(),i||d.close();return}let t=e.value,a=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||u.enqueue(a),i||d.enqueue(new Uint8Array(a))},()=>{}),Promise.resolve())}return c=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,a=t,i){let t=readableStreamCancel(e,[a,o]);return s.resolve(),t}return s.promise}}),l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,o=t,r){let t=readableStreamCancel(e,[a,o]);return s.resolve(),t}return s.promise}}),u=c[Q].controller,d=l[Q].controller,t.closed.catch(e=>{u.error(e),d.error(e),(!r||!i)&&s.resolve()}),[c,l]}const cr=Symbol(`kSkipThrow`);var TransformStream=class{[$]=`TransformStream`;[Q];constructor(e={},t={},n={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`writableStrategy must be an object`);if(n!=null&&typeof n!=`object`)throw TypeError(`readableStrategy must be an object`);let r=e?.readableType,i=e?.writableType,a=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let o=extractHighWaterMark(n?.highWaterMark,0),s=extractSizeAlgorithm(n?.size),c=extractHighWaterMark(t?.highWaterMark,1),l=extractSizeAlgorithm(t?.size),u=Promise.withResolvers();initializeTransformStream(this,u,c,l,o,s),setupTransformStreamDefaultControllerFromTransformer(this,e),a===void 0?u.resolve():u.resolve(a.call(e,this[Q].controller))}get readable(){if(!lr(this))throw TypeError(`Invalid this`);return this[Q].readable}get writable(){if(!lr(this))throw TypeError(`Invalid this`);return this[Q].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[$]=`TransformStreamDefaultController`;[Q];constructor(e){if(e!==cr)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!ur(this))throw TypeError(`Invalid this`);let{stream:e}=this[Q],{readable:t}=e[Q],n=t[Q].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!ur(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!ur(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!ur(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const lr=isBrandCheck(`TransformStream`),ur=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,a){let startAlgorithm=()=>t.promise,o=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[Q]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,a),writable:o,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,t){let{readable:n}=e[Q];readableStreamDefaultControllerError(n[Q].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[Q];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[Q].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Q].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[Q].backpressureChange.promise!==void 0&&e[Q].backpressureChange.resolve?.(),e[Q].backpressureChange=Promise.withResolvers(),e[Q].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[Q]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[Q].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(cr),r=t?.transform,i=t?.flush,a=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,a?createPromiseCallback(`transformer.cancel`,a,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Q].transformAlgorithm=void 0,e[Q].flushAlgorithm=void 0,e[Q].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[Q],{readable:r}=n[Q],i=r[Q].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[Q].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[Q].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[Q].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[Q].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[Q].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[Q],{readable:n}=t[Q];readableStreamDefaultControllerClose(n[Q].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[Q];return e[Q].backpressure?e[Q].backpressureChange.promise.then(()=>{let{writable:r}=e[Q];if(r[Q].state===`erroring`)throw r[Q].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[Q];if(n[Q].finishPromise!==void 0)return n[Q].finishPromise;let{promise:i,resolve:a,reject:o}=Promise.withResolvers();n[Q].finishPromise=i;let s=n[Q].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{r[Q].state===`errored`?o(r[Q].storedError):(readableStreamDefaultControllerError(r[Q].controller,t),a())},e=>{readableStreamDefaultControllerError(r[Q].controller,e),o(e)}),n[Q].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[Q];if(n[Q].finishPromise!==void 0)return n[Q].finishPromise;let{promise:r,resolve:i,reject:a}=Promise.withResolvers();n[Q].finishPromise=r;let o=n[Q].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),o.then(()=>{t[Q].state===`errored`?a(t[Q].storedError):(readableStreamDefaultControllerClose(t[Q].controller),i())},e=>{readableStreamDefaultControllerError(t[Q].controller,e),a(e)}),n[Q].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Q].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[Q];if(n[Q].finishPromise!==void 0)return n[Q].finishPromise;let{promise:i,resolve:a,reject:o}=Promise.withResolvers();n[Q].finishPromise=i;let s=n[Q].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{r[Q].state===`errored`?o(r[Q].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[Q].controller,t),transformStreamUnblockWrite(e),a())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[Q].controller,t),transformStreamUnblockWrite(e),o(t)}),n[Q].finishPromise}const dr=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),fr=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return dr}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return fr}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,t)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let n=e.charCodeAt(e.length-1);55296<=n&&n<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&t.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const pr=hasStreamingSupport();function incompleteUtf8Tail$1(e){let t=e.length;if(t===0)return 0;for(let n=1;n<=Math.min(3,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)!=128){let e;if((r&224)==192)e=2;else if((r&240)==224)e=3;else if((r&248)==240)e=4;else return 0;return n<e?n:0}}return 0}__name(incompleteUtf8Tail$1,`incompleteUtf8Tail`);var TextDecoderStream=class{#e;#t;constructor(e,t){if(this.#e=new TextDecoder(e,t),pr)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$3(e),r=this.#e.decode(n,{stream:!0});r&&t.enqueue(r)},flush:e=>{let t=this.#e.decode();t&&e.enqueue(t)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(t,n)=>{let r=toUint8Array$3(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let a=incompleteUtf8Tail$1(i),o;if(a>0?(o=i.slice(0,i.length-a),e=i.slice(i.length-a)):(o=i,e=new Uint8Array),o.length>0){let e=this.#e.decode(o);e&&n.enqueue(e)}},flush:t=>{if(e.length>0){let n=this.#e.decode(e);n&&t.enqueue(n),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$3(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name(toUint8Array$3,`toUint8Array`);function isNativeStreamUsable$3(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name(isNativeStreamUsable$3,`isNativeStreamUsable`);const mr=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,hr=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,gr=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,_r=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,vr=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,yr=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,br=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var xr=__esmMin(()=>{L()});function _setPipeImpl(e){Sr=e}var Sr,Stream_,Cr=__esmMin(()=>{bn(),Stream_=class extends Y{constructor(e){super(e)}pipe(e,t){return Sr(this,e,t)}}});function getDefaultHighWaterMark(e){return e?Tr:wr}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Tr=t:wr=t}function validateHighWaterMark(e,t){if(t!==void 0&&(typeof t!=`number`||Number.isNaN(t))){let n=TypeError(`The value of "${e}" is invalid. Received ${t}`);throw n.code=`ERR_INVALID_ARG_VALUE`,n}}var wr,Tr,Er=__esmMin(()=>{wr=16384,Tr=16});function chunkLength(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}function sliceChunk(e,t,n){if(typeof e==`string`)return n===void 0?e.slice(t):e.slice(t,n);let r=e.slice;return typeof r==`function`?r.call(e,t,n):e}var Dr,Or=__esmMin(()=>{Cr(),Er(),L(),Dr=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let t=this._buffer.shift();return--this.readableLength,t}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let t=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),t.length===1)return t[0];if(t.length===0)return null;if(typeof t[0]==`string`)return t.join(``);let n=globalThis.Buffer;return n?.concat?n.concat(t):t}_readBytes(e){let t=0,n=[];for(;t<e&&this._buffer.length>0;){let r=this._buffer[0],i=chunkLength(r);if(t+i<=e)n.push(this._buffer.shift()),t+=i,this.readableLength-=i;else{let i=e-t;n.push(sliceChunk(r,0,i)),this._buffer[0]=sliceChunk(r,i),this.readableLength-=i,t+=i}}if(n.length===1)return n[0];let r=globalThis.Buffer;return r?.concat?r.concat(n):n}push(e,t){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let t=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,t)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,t){return super.on(e,t),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let t=globalThis.Buffer;t?.isBuffer&&t.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let t=this._pipeDests.findIndex(t=>t.dest===e);if(t!==-1){this._pipeDests[t].cleanup(),this._pipeDests.splice(t,1);let n=this._readableState.pipes.indexOf(e);n!==-1&&this._readableState.pipes.splice(n,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(t){e.on(`data`,e=>{typeof e==`string`?t.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?t.enqueue(e):e&&typeof e.length==`number`&&t.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{t.close()}),e.on(`error`,e=>{t.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,t){let n=e.getReader();return new Readable_({...t,read(){n.read().then(({done:e,value:t})=>{e?this.push(null):this.push(t)},e=>{this.destroy(e)})},destroy(e,t){n.cancel(e?.message).then(()=>t(null),t)}})}[Symbol.asyncIterator](){let e=this,t=[],n=!1,r=null,i=null,a=null;return e.on(`data`,e=>{if(i){let t=i;i=null,a=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,a=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,a){let t=a;i=null,a=null,t(e)}}),{next(){return r?Promise.reject(r):t.length>0?Promise.resolve({value:t.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{i=e,a=t})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,t){let n=new Readable_({objectMode:!0,...t,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(n.push(e),n.push(null),n):((async()=>{try{for await(let t of e)n.push(t)||await new Promise(e=>n.once(`drain`,e));n.push(null)}catch(e){n.destroy(e)}})(),n)}}});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,kr=__esmMin(()=>{Er(),Or(),L(),Duplex_=class extends Dr{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let a=this.writableLength<this.writableHighWaterMark;return a||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),a}_duplexDoWrite(e,t,n){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:t,callback:n});return}this._duplexWriting=!0,this._duplexStartWrite(e,t,n)}_duplexStartWrite(e,t,n){this._pendingWrites++,this._write(e,t,t=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(t?()=>{if(n(t),this._duplexWriting=!1,this.emit(`error`,t),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(n(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,t,n){typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),n&&n()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:t,encoding:n,callback:r}of e)this._write(t,n,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(t),e?(r(e),this.emit(`error`,e)):r()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name(chunkLen$1,`chunkLen`)});function pipe(e,t,n){let r=e,i=n?.end!==!1,a=!1,ondrain=()=>{a=!1,t.removeListener(`drain`,ondrain);let e=r;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(t.writable){let n=r;t.write(e)===!1&&typeof n.pause==`function`&&(n.pause(),a||(a=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let o=!1,onend=()=>{o||(o=!0,i&&t.end())},onclose=()=>{if(!o&&(o=!0,i&&!(r instanceof Dr))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),a&&t.removeListener(`drain`,ondrain),r.removeListener(`end`,onend),r.removeListener(`close`,onclose),r.removeListener(`end`,cleanup),r.removeListener(`close`,cleanup),t.removeListener(`close`,cleanup)};return r.on(`end`,cleanup),r.on(`close`,cleanup),t.on(`close`,cleanup),r instanceof Dr&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var Ar=__esmMin(()=>{Cr(),Or(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var jr,Mr=__esmMin(()=>{Cr(),Er(),L(),jr=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let t=this;return t.prototype!==void 0&&Object.prototype.isPrototypeOf.call(t.prototype,e)?!0:t.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}if(this._pendingEnd){let{chunk:e,encoding:t,callback:n}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,t,n)}}_doWrite(e,t,n){this._writableState.writing=!0;let r=!0;this._write(e,t,t=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),r){nextTick(()=>{if(t){n(t),this.emit(`error`,t);return}n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),t||this._drainWriteBuffer();return}nextTick(t?()=>{n(t),this.emit(`error`,t),this._drainWriteBuffer()}:()=>{n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),r=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let a=this.writableLength<this.writableHighWaterMark;return a||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),a}_doEnd(e,t,n){e!=null&&this.write(e,t),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=n,this._maybeFinish()}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),this.writableEnded?(n&&nextTick(n),this):this._writableState.constructed?(this._doEnd(e,t,n),this):(this._pendingEnd={chunk:e,encoding:t,callback:n},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),t=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,t,t=>{for(let t of e)this.writableLength-=this.writableObjectMode?1:chunkLen(t.chunk);if(t){for(let n of e)n.callback(t);this.emit(`error`,t)}else{for(let t of e)t.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}}}),Nr,Pr=__esmMin(()=>{kr(),L(),Nr=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let t=this;e?.transform&&(t._transform=e.transform),e?.flush&&(t._flush=e.flush),e?.final&&(t._final=e.final)}_transform(e,t,n){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,t,n){let r=!1;try{this._transform(e,t,(e,t)=>{if(r){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(r=!0,e){n(e);return}t!=null&&this.push(t),n()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;n(e)}}_final(e){this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()})}_doPrefinishHooks(e){let t=Transform_.prototype._final;this._final===t?e():t.call(this,e)}}}),PassThrough_,Fr=__esmMin(()=>{Pr(),PassThrough_=class extends Nr{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline(...e){let t=e,n=typeof t[t.length-1]==`function`?t.pop():void 0,r=t;if(r.length<2)throw Error(`pipeline requires at least 2 streams`);let i=null;function onError(e){if(!i){i=e;for(let e of r)typeof e.destroy==`function`&&e.destroy();n&&n(e)}}let a=r[0];for(let e=1;e<r.length;e++){let t=r[e];a.pipe(t),a.on(`error`,onError),a=t}let o=r[r.length-1];return o.on(`error`,onError),o.on(`finish`,()=>{n&&!i&&n(null)}),o}var Ir=__esmMin(()=>{});function finished(e,t,n){let r;r=typeof t==`function`?t:n;let i=!1;function done(e){i||(i=!0,r(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let t=e,n=e;!t.writableFinished&&!n.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let a=e,o=typeof e.write==`function`,s=typeof e.read==`function`,c=a.writableFinished===!0,l=a.readableEnded===!0;if(a.destroyed===!0){let e=a._err;_e(e?()=>done(e):o&&c||s&&l?()=>done():()=>done(Error(`premature close`)))}else (o&&!s&&c||!o&&s&&l||o&&s&&c&&l)&&_e(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,t){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(t instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let n=t;if(e.aborted)n.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{n.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),t.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return t}function isReadable(e){if(e==null)return!1;let t=e;return typeof t.readable!=`boolean`||typeof t.read!=`function`||t.destroyed===!0||t.readableEnded===!0?!1:t.readable===!0}function isWritable(e){if(e==null)return!1;let t=e;return typeof t.writable!=`boolean`||typeof t.write!=`function`||t.destroyed===!0||t.writableEnded===!0?!1:t.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let t=e;return t.readableDidRead===!0||t.readableFlowing!==null&&t.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let t=e;return t.destroyed===!0&&typeof t.readable==`boolean`&&t.readable===!1||t.destroyed===!0&&typeof t.writable==`boolean`&&t.writable===!1}var Lr=__esmMin(()=>{Cr(),L()}),Rr=__exportAll$4({Duplex:()=>Hr,PassThrough:()=>Wr,Readable:()=>Br,Stream:()=>zr,Transform:()=>Ur,Writable:()=>Vr,addAbortSignal:()=>addAbortSignal,default:()=>Gr,finished:()=>finished,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,pipeline:()=>pipeline,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),zr,Br,Vr,Hr,Ur,Wr,Gr,Kr=__esmMin(()=>{xr(),Cr(),Er(),Or(),kr(),Ar(),Mr(),Pr(),Fr(),Ir(),Lr(),zr=makeCallable(Stream_),Br=makeCallable(Dr),Vr=makeCallable(jr),Hr=makeCallable(Duplex_),Ur=makeCallable(Nr),Wr=makeCallable(PassThrough_),Gr=Object.assign(zr,{Stream:zr,Readable:Br,Writable:Vr,Duplex:Hr,Transform:Ur,PassThrough:Wr,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getGioCompressorFormat(e){switch(e){case`gzip`:return M.ZlibCompressorFormat.GZIP;case`deflate`:return M.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return M.ZlibCompressorFormat.RAW}}function toUint8Array$2(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function createGzip(e){return new ZlibTransform(`gzip`,`compress`,e)}function createGunzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createDeflate(e){return new ZlibTransform(`deflate`,`compress`,e)}function createInflate(e){return new ZlibTransform(`deflate`,`decompress`,e)}function createDeflateRaw(e){return new ZlibTransform(`deflate-raw`,`compress`,e)}function createInflateRaw(e){return new ZlibTransform(`deflate-raw`,`decompress`,e)}function createUnzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}var ZlibTransform,qr=__esmMin(()=>{N(),A(),Kr(),__name(toUint8Array$2,`toUint8Array`),ZlibTransform=class extends Ur{_format;_mode;_chunks=[];constructor(e,t,n){super(n),this._format=e,this._mode=t}_transform(e,t,n){this._chunks.push(toUint8Array$2(e)),n()}_flush(e){let t=this._chunks.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let e of this._chunks)n.set(e,r),r+=e.length;this._chunks=[];try{let t=this._mode===`compress`?this._compress(n):this._decompress(n);this.push(Buffer.from(t)),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_compress(e){let t=new M.ZlibCompressor({format:getGioCompressorFormat(this._format)}),n=new M.ConverterOutputStream({base_stream:M.MemoryOutputStream.new_resizable(),converter:t});n.write_bytes(new k.Bytes(e),null),n.close(null);let r=n.get_base_stream().steal_as_bytes();return new Uint8Array(r.get_data()??[])}_decompress(e){let t=new M.ZlibDecompressor({format:getGioCompressorFormat(this._format)}),n=M.MemoryInputStream.new_from_bytes(new k.Bytes(e)),r=new M.ConverterInputStream({base_stream:n,converter:t}),i=[];for(;;){let e=r.read_bytes(4096,null);if(e.get_size()===0)break;i.push(new Uint8Array(e.get_data()))}r.close(null);let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}}}),Jr=__exportAll$4({ZlibTransform:()=>ZlibTransform,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>Zr,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,default:()=>Qr,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync});function getGioFormat(e){switch(e){case`gzip`:return M.ZlibCompressorFormat.GZIP;case`deflate`:return M.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return M.ZlibCompressorFormat.RAW}}function compressWithGio(e,t){let n=new M.ZlibCompressor({format:getGioFormat(t)}),r=new M.ConverterOutputStream({base_stream:M.MemoryOutputStream.new_resizable(),converter:n});r.write_bytes(new k.Bytes(e),null),r.close(null);let i=r.get_base_stream().steal_as_bytes();return new Uint8Array(i.get_data()??[])}function decompressStreamWithGio(e,t){let n=new M.ZlibDecompressor({format:getGioFormat(t)}),r=M.MemoryInputStream.new_from_bytes(new k.Bytes(e)),i=new M.ConverterInputStream({base_stream:r,converter:n}),a=[];for(;;){let e=i.read_bytes(4096,null);if(e.get_size()===0)break;a.push(new Uint8Array(e.get_data()))}i.close(null);let o=a.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s}function findGzipMemberEnd(e){let t=new M.ZlibDecompressor({format:M.ZlibCompressorFormat.GZIP}),n=new Uint8Array(65536),r=0,i=!1;for(;!i;){let a=e.subarray(r);try{let[e,o]=t.convert(a,n,M.ConverterFlags.NONE);r+=o,e===M.ConverterResult.FINISHED&&(i=!0)}catch{i=!0}}return r}function decompressWithGio(e,t){if(t!==`gzip`)return decompressStreamWithGio(e,t);let n=[],r=0;for(;r<e.length&&!(e.length-r<2||e[r]!==31||e[r+1]!==139);){let t=e.subarray(r),i=findGzipMemberEnd(t);if(i<=0)break;let a=decompressStreamWithGio(t.subarray(0,i),`gzip`);n.push(a),r+=i}if(n.length===0)return decompressStreamWithGio(e,`gzip`);let i=n.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of n)a.set(e,o),o+=e.length;return a}async function compressWithWeb(e,t){let n=new CompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function decompressWithWeb(e,t){let n=new DecompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function compress(e,t){return Yr?compressWithWeb(e,t):compressWithGio(e,t)}async function decompress(e,t){return Yr?decompressWithWeb(e,t):decompressWithGio(e,t)}function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array$1(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array$1(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array$1(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array$1(e),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array$1(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate-raw`)}function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),Xr)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),Xr)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}var Yr,Xr,Zr,Qr,$r=__esmMin(()=>{qr(),N(),A(),Yr=globalThis.CompressionStream!==void 0,__name(toUint8Array$1,`toUint8Array`),Xr=new Uint8Array,Zr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},Qr={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,constants:Zr}});const ei=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!ei.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const ti=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let ni=!1,ri,ii,ai,oi,si,ci;async function loadZlib(){if(ni)return;let e=await Promise.resolve().then(()=>($r(),Jr));ri=e.gzipSync,ii=e.gunzipSync,ai=e.deflateSync,oi=e.inflateSync,si=e.deflateRawSync,ci=e.inflateRawSync,ni=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>ri(e);case`deflate`:return e=>ai(e);case`deflate-raw`:return e=>si(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>ii(e);case`deflate`:return e=>oi(e);case`deflate-raw`:return e=>ci(e)}}let li,ui;if(ti)li=globalThis.CompressionStream,ui=globalThis.DecompressionStream;else{let e=loadZlib();li=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=new gr({async transform(t,r){try{await e,r.enqueue(getCompressFn(n)(t))}catch(e){r.error(e)}}});this.readable=r.readable,this.writable=r.writable}},ui=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=new gr({async transform(t,r){try{await e,r.enqueue(getDecompressFn(n)(t))}catch(e){r.error(e)}}});this.readable=r.readable,this.writable=r.writable}}}const di=globalThis;globalThis.CompressionStream===void 0&&(di.CompressionStream=li),globalThis.DecompressionStream===void 0&&(di.DecompressionStream=ui);const fi=globalThis;globalThis.DOMException===void 0&&(fi.DOMException=Ve);const pi=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(pi.ByteLengthQueuingStrategy=_r),globalThis.CountQueuingStrategy===void 0&&(pi.CountQueuingStrategy=vr);const mi=globalThis;function isNativeStreamUsable$2(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(mi.ReadableStream=mr),mi.ReadableStreamBYOBReader===void 0&&(mi.ReadableStreamBYOBReader=ReadableStreamBYOBReader),mi.ReadableStreamBYOBRequest===void 0&&(mi.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),mi.ReadableByteStreamController===void 0&&(mi.ReadableByteStreamController=ReadableByteStreamController),mi.ReadableStreamDefaultController===void 0&&(mi.ReadableStreamDefaultController=ReadableStreamDefaultController),mi.ReadableStreamDefaultReader===void 0&&(mi.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const hi=globalThis;globalThis.TextEncoderStream===void 0&&(hi.TextEncoderStream=yr),globalThis.TextDecoderStream===void 0&&(hi.TextDecoderStream=br);function isNativeStreamUsable$1(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(__name(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let e=globalThis;e.TransformStream=gr}function isNativeStreamUsable(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let e=globalThis;e.WritableStream=hr}var CryptoKey=class{type;extractable;algorithm;usages;_handle;constructor(e,t,n,r,i){this.type=e,this.extractable=t,this.algorithm=Object.freeze({...n}),this.usages=Object.freeze([...r]),this._handle=i}get[Symbol.toStringTag](){return`CryptoKey`}};function normalizeAlgorithm$1(e){if(typeof e==`string`)return{name:e};if(!e||typeof e.name!=`string`)throw TypeError(`Algorithm must have a name property`);return e}__name(normalizeAlgorithm$1,`normalizeAlgorithm`);const gi={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=gi[e.toUpperCase()]||gi[e];if(!t)throw new Ve(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const _i={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=_i[e];if(!t)throw new Ve(`Unrecognized curve name: ${e}`,`NotSupportedError`);return t}function hashSize$1(e){switch(toNodeHashName(e)){case`sha1`:return 20;case`sha256`:return 32;case`sha384`:return 48;case`sha512`:return 64;default:throw new Ve(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new Ve(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new Ve(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new Ve(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const vi=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,yi=new Uint8Array(128);for(let e=0;e<64;e++)yi[vi.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],a=r+1<n?e[r+1]:0,o=r+2<n?e[r+2]:0;t+=vi[i>>2&63],t+=vi[(i<<4|a>>4)&63],t+=r+1<n?vi[(a<<2|o>>6)&63]:`=`,t+=r+2<n?vi[o&63]:`=`}return t}function base64ToBytes(e){let t=e;for(;t.endsWith(`=`);)t=t.slice(0,-1);let n=[],r=0,i=0;for(let e=0;e<t.length;e++)i=i<<6|yi[t.charCodeAt(e)],r+=6,r>=8&&(r-=8,n.push(i>>r&255));return new Uint8Array(n)}function base64urlEncode(e){return bytesToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function base64urlDecode(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4;)t+=`=`;return base64ToBytes(t)}function toUint8Array(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Expected BufferSource`)}function gmul(e,t){let n=0;for(let r=0;r<8;r++){t&1&&(n^=e);let r=e&128;e=e<<1&255,r&&(e^=27),t>>=1}return n}function keyExpansion(e){let t=e.length/4,n=t+6,r=4*(n+1),i=Array.from({length:r});for(let n=0;n<t;n++)i[n]=new Uint8Array([e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]]);for(let e=t;e<r;e++){let n=new Uint8Array(i[e-1]);e%t===0?n=new Uint8Array([bi[n[1]]^Si[e/t-1],bi[n[2]],bi[n[3]],bi[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([bi[n[0]],bi[n[1]],bi[n[2]],bi[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let a=[];for(let e=0;e<=n;e++){let t=new Uint8Array(16);for(let n=0;n<4;n++)t[4*n]=i[4*e+n][0],t[4*n+1]=i[4*e+n][1],t[4*n+2]=i[4*e+n][2],t[4*n+3]=i[4*e+n][3];a.push(t)}return a}function aesEncryptBlock(e,t){let n=new Uint8Array(e),r=t.length-1;for(let e=0;e<16;e++)n[e]^=t[0][e];for(let e=1;e<r;e++){for(let e=0;e<16;e++)n[e]=bi[n[e]];let r=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=r;let i=n[2],a=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,n[14]=a;let o=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=o;for(let e=0;e<4;e++){let t=e*4,r=n[t],i=n[t+1],a=n[t+2],o=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^a^o,n[t+1]=r^gmul(2,i)^gmul(3,a)^o,n[t+2]=r^i^gmul(2,a)^gmul(3,o),n[t+3]=gmul(3,r)^i^a^gmul(2,o)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=bi[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let a=n[2],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=a,n[14]=o;let s=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=s;for(let e=0;e<16;e++)n[e]^=t[r][e];return n}function aesDecryptBlock(e,t){let n=new Uint8Array(e),r=t.length-1;for(let e=0;e<16;e++)n[e]^=t[r][e];for(let e=r-1;e>0;e--){let r=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=r;let i=n[10],a=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,n[6]=a;let o=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=o;for(let e=0;e<16;e++)n[e]=xi[n[e]];for(let r=0;r<16;r++)n[r]^=t[e][r];for(let e=0;e<4;e++){let t=e*4,r=n[t],i=n[t+1],a=n[t+2],o=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,a)^gmul(9,o),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,a)^gmul(13,o),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,a)^gmul(11,o),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,a)^gmul(14,o)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let a=n[10],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=a,n[6]=o;let s=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=s;for(let e=0;e<16;e++)n[e]=xi[n[e]];for(let e=0;e<16;e++)n[e]^=t[0][e];return n}function incrementCounter(e){for(let t=15;t>=0&&++e[t]===0;t--);}function gcmIncrementCounter(e){for(let t=15;t>=12&&++e[t]===0;t--);}function gfMul(e,t){let n=new Uint8Array(16),r=new Uint8Array(e);for(let e=0;e<128;e++){if(t[e>>>3]&1<<7-(e&7))for(let e=0;e<16;e++)n[e]^=r[e];let i=r[15]&1;for(let e=15;e>0;e--)r[e]=r[e]>>>1|(r[e-1]&1)<<7;r[0]>>>=1,i&&(r[0]^=225)}return n}function ghash(e,t,n){let r=new Uint8Array(16),i=Math.ceil(t.length/16)||0;for(let n=0;n<i;n++){let i=n*16,a=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<a&&(r[e]^=t[n])}let o=gfMul(r,e);r.set(o)}let a=Math.ceil(n.length/16)||0;for(let t=0;t<a;t++){let i=t*16,a=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<a&&(r[e]^=n[t])}let o=gfMul(r,e);r.set(o)}let o=new Uint8Array(16),s=t.length*8,c=n.length*8,l=Math.floor(s/4294967296),u=s>>>0;o[0]=l>>>24&255,o[1]=l>>>16&255,o[2]=l>>>8&255,o[3]=l&255,o[4]=u>>>24&255,o[5]=u>>>16&255,o[6]=u>>>8&255,o[7]=u&255;let d=Math.floor(c/4294967296),p=c>>>0;o[8]=d>>>24&255,o[9]=d>>>16&255,o[10]=d>>>8&255,o[11]=d&255,o[12]=p>>>24&255,o[13]=p>>>16&255,o[14]=p>>>8&255,o[15]=p&255;for(let e=0;e<16;e++)r[e]^=o[e];let m=gfMul(r,e);return r.set(m),r}var bi,xi,Si,Ci=__esmMin(()=>{bi=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),xi=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),Si=[1,2,4,8,16,32,64,128,27,54]});function parseAlgorithm(e){let t=e.toLowerCase().match(/^aes-(128|192|256)-(cbc|ctr|ecb|cfb|ofb|gcm)$/);if(!t)throw Error(`Unsupported cipher algorithm: ${e}`);let n=parseInt(t[1]),r=t[2];return{keySize:n/8,ivSize:r===`ecb`?0:r===`gcm`?12:16,mode:r}}function toBuffer$2(e,t){return typeof e==`string`?q.from(e,t||`utf8`):q.from(e)}function encodeOutput(e,t){return t?q.from(e).toString(t):q.from(e)}function incompleteUtf8Tail(e){if(e.length===0)return 0;let t=e.length;for(let n=1;n<=Math.min(4,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)==128)continue;let i;if((r&224)==192)i=2;else if((r&240)==224)i=3;else if((r&248)==240)i=4;else return 0;return n<i?n:0}return 0}function pkcs7Pad(e){let t=16-e.length%16,n=new Uint8Array(e.length+t);n.set(e);for(let r=e.length;r<n.length;r++)n[r]=t;return n}function pkcs7Unpad(e){if(e.length===0||e.length%16!=0)throw Error(`bad decrypt`);let t=e[e.length-1];if(t===0||t>16)throw Error(`bad decrypt`);for(let n=e.length-t;n<e.length;n++)if(e[n]!==t)throw Error(`bad decrypt`);return new Uint8Array(e.slice(0,e.length-t))}var wi=__esmMin(()=>{J(),__name(toBuffer$2,`toBuffer`)});function createCipher(e,t){throw Error(`crypto.createCipher() is deprecated. Use createCipheriv() instead.`)}function createCipheriv(e,t,n){return new Cipher(e,typeof t==`string`?q.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?q.from(n):new Uint8Array(n))}function createDecipher(e,t){throw Error(`crypto.createDecipher() is deprecated. Use createDecipheriv() instead.`)}function createDecipheriv(e,t,n){return new Decipher(e,typeof t==`string`?q.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?q.from(n):new Uint8Array(n))}function getCiphers(){return[`aes-128-cbc`,`aes-128-ecb`,`aes-192-cbc`,`aes-192-ecb`,`aes-256-cbc`,`aes-256-ecb`,`aes-128-ctr`,`aes-192-ctr`,`aes-256-ctr`,`aes-128-cfb`,`aes-192-cfb`,`aes-256-cfb`,`aes-128-gcm`,`aes-192-gcm`,`aes-256-gcm`]}var CipherBase,Cipher,Decipher,Ti=__esmMin(()=>{Ci(),wi(),J(),CipherBase=class{_roundKeys;_iv;_mode;_buffer=new Uint8Array;_autoPadding=!0;_finalized=!1;constructor(e,t,n){let r=parseAlgorithm(e);if(t.length!==r.keySize)throw Error(`Invalid key length ${t.length}, expected ${r.keySize} for ${e}`);if(r.ivSize>0&&(!n||n.length!==r.ivSize))throw Error(`Invalid IV length ${n?.length??0}, expected ${r.ivSize} for ${e}`);this._roundKeys=keyExpansion(t),this._iv=n?new Uint8Array(n):new Uint8Array(16),this._mode=r.mode}setAutoPadding(e){return this._autoPadding=e,this}},Cipher=class extends CipherBase{_prevBlock;_counter;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmAuthTag=null;_gcmAADSet=!1;constructor(e,t,n){super(e,t,n),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(e){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(e),this._gcmAADSet=!0,this}getAuthTag(){if(this._mode!==`gcm`)throw Error(`getAuthTag is only supported in GCM mode`);if(!this._gcmAuthTag)throw Error(`getAuthTag must be called after final()`);return q.from(this._gcmAuthTag)}update(e,t,n){let r=toBuffer$2(e,t),i=new Uint8Array(this._buffer.length+r.length);if(i.set(this._buffer),i.set(r,this._buffer.length),this._mode===`gcm`){let e=this._processGcmEncrypt(i);return this._buffer=new Uint8Array,encodeOutput(e,n)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let e=this._processStream(i);return this._buffer=new Uint8Array,encodeOutput(e,n)}let a=Math.floor(i.length/16)*16,o=[];for(let e=0;e<a;e+=16){let t=i.slice(e,e+16);o.push(this._encryptBlock(t))}this._buffer=i.slice(a);let s=new Uint8Array(o.length*16);for(let e=0;e<o.length;e++)s.set(o[e],e*16);return encodeOutput(s,n)}final(e){if(this._finalized)throw Error(`Cipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let t=new Uint8Array;this._buffer.length>0&&(t=this._processGcmEncrypt(this._buffer),this._buffer=new Uint8Array);let n=new Uint8Array(this._gcmCiphertextLen),r=0;for(let e of this._gcmCiphertext)n.set(e,r),r+=e.length;let i=ghash(this._gcmH,this._gcmAAD,n),a=aesEncryptBlock(this._gcmJ0,this._roundKeys),o=new Uint8Array(16);for(let e=0;e<16;e++)o[e]=i[e]^a[e];return this._gcmAuthTag=q.from(o),encodeOutput(t,e)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let t=this._processStream(this._buffer);return this._buffer=new Uint8Array,encodeOutput(t,e)}return encodeOutput(new Uint8Array,e)}let t=this._buffer;if(this._autoPadding)t=pkcs7Pad(t);else if(t.length%16!=0)throw Error(`data not multiple of block size`);let n=[];for(let e=0;e<t.length;e+=16)n.push(this._encryptBlock(t.slice(e,e+16)));if(this._buffer=new Uint8Array,n.length===0)return encodeOutput(new Uint8Array,e);let r=new Uint8Array(n.length*16);for(let e=0;e<n.length;e++)r.set(n[e],e*16);return encodeOutput(r,e)}_encryptBlock(e){if(this._mode===`cbc`){let t=new Uint8Array(16);for(let n=0;n<16;n++)t[n]=e[n]^this._prevBlock[n];let n=aesEncryptBlock(t,this._roundKeys);return this._prevBlock=n,n}else if(this._mode===`ecb`)return aesEncryptBlock(e,this._roundKeys);throw Error(`Block encryption not supported for mode: ${this._mode}`)}_processStream(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];incrementCounter(this._counter)}return t}_processGcmEncrypt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];gcmIncrementCounter(this._counter)}return this._gcmCiphertext.push(new Uint8Array(t)),this._gcmCiphertextLen+=t.length,t}},Decipher=class extends CipherBase{_prevBlock;_counter;_pendingUtf8=new Uint8Array;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmExpectedTag=null;_gcmAADSet=!1;constructor(e,t,n){super(e,t,n),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(e){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(e),this._gcmAADSet=!0,this}setAuthTag(e){if(this._mode!==`gcm`)throw Error(`setAuthTag is only supported in GCM mode`);return this._gcmExpectedTag=q.from(e),this}_encodeWithUtf8Handling(e,t,n){if(!t||t!==`utf8`&&t!==`utf-8`)return encodeOutput(e,t);let r;if(this._pendingUtf8.length>0?(r=new Uint8Array(this._pendingUtf8.length+e.length),r.set(this._pendingUtf8),r.set(e,this._pendingUtf8.length),this._pendingUtf8=new Uint8Array):r=e,!n){let e=incompleteUtf8Tail(r);e>0&&(this._pendingUtf8=new Uint8Array(r.slice(r.length-e)),r=new Uint8Array(r.slice(0,r.length-e)))}return q.from(r).toString(`utf8`)}update(e,t,n){let r=toBuffer$2(e,t),i=new Uint8Array(this._buffer.length+r.length);if(i.set(this._buffer),i.set(r,this._buffer.length),this._mode===`gcm`){this._gcmCiphertext.push(new Uint8Array(i)),this._gcmCiphertextLen+=i.length;let e=this._processGcmDecrypt(i);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(e,n,!1)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let e=this._processStream(i);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(e,n,!1)}let a=Math.floor(i.length/16);if(a===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let o=(this._autoPadding?a-1:a)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._decryptBlock(t))}this._buffer=i.slice(o);let c=new Uint8Array(s.length*16);for(let e=0;e<s.length;e++)c.set(s[e],e*16);return this._encodeWithUtf8Handling(c,n,!1)}final(e){if(this._finalized)throw Error(`Decipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let t=new Uint8Array;if(this._buffer.length>0&&(this._gcmCiphertext.push(new Uint8Array(this._buffer)),this._gcmCiphertextLen+=this._buffer.length,t=this._processGcmDecrypt(this._buffer),this._buffer=new Uint8Array),!this._gcmExpectedTag)throw Error(`Unsupported state or unable to authenticate data`);let n=new Uint8Array(this._gcmCiphertextLen),r=0;for(let e of this._gcmCiphertext)n.set(e,r),r+=e.length;let i=ghash(this._gcmH,this._gcmAAD,n),a=aesEncryptBlock(this._gcmJ0,this._roundKeys),o=new Uint8Array(16);for(let e=0;e<16;e++)o[e]=i[e]^a[e];let s=this._gcmExpectedTag,c=Math.min(s.length,16),l=0;for(let e=0;e<c;e++)l|=o[e]^s[e];if(l!==0)throw Error(`Unsupported state or unable to authenticate data`);return this._encodeWithUtf8Handling(t,e,!0)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let t=this._processStream(this._buffer);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(t,e,!0)}return this._encodeWithUtf8Handling(new Uint8Array,e,!0)}if(this._buffer.length===0)return this._encodeWithUtf8Handling(new Uint8Array,e,!0);if(this._buffer.length%16!=0)throw Error(`bad decrypt`);let t=[];for(let e=0;e<this._buffer.length;e+=16)t.push(this._decryptBlock(this._buffer.slice(e,e+16)));let n=new Uint8Array(t.length*16);for(let e=0;e<t.length;e++)n.set(t[e],e*16);let r=this._autoPadding?pkcs7Unpad(n):n;return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(r,e,!0)}_decryptBlock(e){if(this._mode===`cbc`){let t=aesDecryptBlock(e,this._roundKeys),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=t[e]^this._prevBlock[e];return this._prevBlock=new Uint8Array(e),n}else if(this._mode===`ecb`)return aesDecryptBlock(e,this._roundKeys);throw Error(`Block decryption not supported for mode: ${this._mode}`)}_processStream(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];incrementCounter(this._counter)}return t}_processGcmDecrypt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];gcmIncrementCounter(this._counter)}return t}}}),Ei,Di=__esmMin(()=>{Ei={RSA_PKCS1_PADDING:1,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_PKCS1_PSS_PADDING:6,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8}});function fillRandom(e){if(Oi)for(let t=0;t<e.length;t+=65536){let n=Math.min(e.length-t,65536),r=new Uint8Array(e.buffer,e.byteOffset+t,n);globalThis.crypto.getRandomValues(r)}else try{let t=imports.gi.GLib;for(let n=0;n<e.length;n++)e[n]=t.random_int_range(0,256)}catch{for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}}function randomBytes(e,t){if(typeof e!=`number`||e<0||!Number.isInteger(e))throw TypeError(`The "size" argument must be a non-negative integer. Received ${e}`);try{let n=q.alloc(e);if(e>0&&fillRandom(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),t)t(null,n);else return n}catch(e){if(t)t(e,q.alloc(0));else throw e}}function randomFillSync(e,t=0,n){let r=n??e.length-t;if(t<0||t>e.length)throw RangeError(`The value of "offset" is out of range. Received ${t}`);if(r<0||t+r>e.length)throw RangeError(`The value of "size" is out of range. Received ${r}`);if(r>0){let n=(e instanceof q,e.byteOffset);fillRandom(new Uint8Array(e.buffer,n+t,r))}return e}function randomFill(e,t,n,r){let i,a,o;typeof t==`function`?(o=t,i=0,a=e.length):typeof n==`function`?(o=n,i=t,a=e.length-t):(o=r,i=t,a=n);try{randomFillSync(e,i,a),o(null,e)}catch(t){o(t,e)}}function randomUUID(){if(Oi&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);fillRandom(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function randomInt(e,t,n){let r,i,a;if(typeof t==`function`?(a=t,i=e,r=0):typeof t==`number`?(r=e,i=t,a=n):(i=e,r=0,a=n),!Number.isInteger(r))throw TypeError(`The "min" argument must be a safe integer. Received ${r}`);if(!Number.isInteger(i))throw TypeError(`The "max" argument must be a safe integer. Received ${i}`);if(r>=i)throw RangeError(`The value of "min" must be less than "max". Received min: ${r}, max: ${i}`);let o=i-r,s=new Uint32Array(1);fillRandom(new Uint8Array(s.buffer));let c=r+s[0]%o;if(a)a(null,c);else return c}var Oi,ki=__esmMin(()=>{J(),Oi=globalThis.crypto!==void 0&&typeof globalThis.crypto.getRandomValues==`function`});function modPow(e,t,n){if(n===1n)return 0n;e=(e%n+n)%n;let r=1n;for(;t>0n;)t&1n&&(r=r*e%n),t>>=1n,e=e*e%n;return r}function bigIntToBytes(e,t){let n=new Uint8Array(t),r=e;for(let e=t-1;e>=0;e--)n[e]=Number(r&255n),r>>=8n;return n}function bytesToBigInt(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}var Ai=__esmMin(()=>{});function bigIntToBuffer(e){if(e===0n)return q.from([0]);let t=e.toString(16);return t.length%2!=0&&(t=`0`+t),q.from(t,`hex`)}function bufferToBigInt(e){if(e.length===0)return 0n;let t=q.from(e).toString(`hex`);return t.length===0?0n:BigInt(`0x`+t)}function bitLength(e){return e===0n?0:e.toString(2).length}function simpleSieve(e){for(let t of Mi){let n=BigInt(t);if(e%n===0n)return e===n}return!0}function fermatTest(e){return modPow(2n,e-1n,e)===1n}function millerRabinTest(e){if(e<2n)return!1;if(e===2n||e===3n)return!0;if(e%2n==0n)return!1;let t=e-1n,n=0;for(;t%2n==0n;)t/=2n,n++;for(let r of[2n,3n,5n,7n,11n,13n]){if(r>=e)continue;let i=modPow(r,t,e);if(i===1n||i===e-1n)continue;let a=!0;for(let t=0;t<n-1;t++)if(i=modPow(i,2n,e),i===e-1n){a=!1;break}if(a)return!1}return!0}function checkPrime(e,t){let n=t.toString(`hex`),r=0;if(e%2n==0n||!simpleSieve(e)||!fermatTest(e)||!millerRabinTest(e))return r+=1,n===`02`||n===`05`?r+=8:r+=4,r;switch(millerRabinTest(e>>1n)||(r+=2),n){case`02`:e%24n!=11n&&(r+=8);break;case`05`:{let t=e%10n;t!==3n&&t!==7n&&(r+=8)}break;default:r+=4}return r}function getCachedCheckPrime(e,t){let n=t.toString(`hex`)+`_`+e.toString(16);if(n in Ni)return Ni[n];let r=checkPrime(e,t);return Ni[n]=r,r}function formatReturnValue$1(e,t){let n=bigIntToBuffer(e);return t?n.toString(t):n}function generatePrime(e,t){let n=bufferToBigInt(t);if(e<16)return n===2n||n===5n?q.from([140,123]):q.from([140,39]);let r=Math.ceil(e/8),i=2n,a=4n;for(;;){let t=bufferToBigInt(randomBytes(r));for(;bitLength(t)>e;)t>>=1n;if(t%i==0n&&(t+=1n),t&i||(t+=i),n===i)for(;t%24n!=11n;)t+=a;else if(n===5n)for(;t%10n!=3n;)t+=a;let o=t>>1n;if(simpleSieve(o)&&simpleSieve(t)&&fermatTest(o)&&fermatTest(t)&&millerRabinTest(o)&&millerRabinTest(t))return bigIntToBuffer(t)}}function createDiffieHellman(e,t,n,r){if(t!==void 0&&typeof t!=`number`&&(q.isBuffer(t)||t instanceof Uint8Array||typeof t==`string`&&!(t in Pi)))return createDiffieHellman(e,`binary`,t,n);let i=t||`binary`,a=r||`binary`,o=q.from([2]);if(n!==void 0&&(typeof n==`number`?(o=q.alloc(1),o[0]=n):o=q.isBuffer(n)?n:q.from(n,a)),typeof e==`number`)return new DiffieHellman(generatePrime(e,o),o,!0);let s;return s=q.isBuffer(e)?e:e instanceof Uint8Array?q.from(e):q.from(e,i),new DiffieHellman(s,o,!0)}function getDiffieHellman(e){let t=ji[e];if(!t)throw Error(`Unknown group: ${e}. Supported groups: ${Object.keys(ji).join(`, `)}`);return new DiffieHellman(q.from(t.prime,`hex`),q.from(t.gen,`hex`),!1)}var ji,Mi,Ni,DiffieHellman,Pi,Fi,Ii,Li=__esmMin(()=>{Ai(),ki(),J(),ji={modp1:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff`},modp2:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff`},modp5:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff`},modp14:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff`},modp15:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff`},modp16:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff`},modp17:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff`},modp18:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff`}},Mi=[];{let e=1e3,t=new Uint8Array(1001);for(let n=2;n*n<=e;n++)if(!t[n])for(let r=n*n;r<=e;r+=n)t[r]=1;for(let n=2;n<=e;n++)t[n]||Mi.push(n)}Ni={},__name(formatReturnValue$1,`formatReturnValue`),DiffieHellman=class{_prime;_generator;_generatorBuf;_primeByteLength;_pubKey;_privKey;_primeCode;_malleable;constructor(e,t,n=!1){this._prime=bufferToBigInt(e),this._generatorBuf=t,this._generator=bufferToBigInt(t),this._primeByteLength=e.length,this._pubKey=void 0,this._privKey=void 0,this._primeCode=void 0,this._malleable=n,n||(this._primeCode=0,this.setPublicKey=void 0,this.setPrivateKey=void 0)}get verifyError(){return typeof this._primeCode!=`number`&&(this._primeCode=getCachedCheckPrime(this._prime,this._generatorBuf)),this._primeCode}generateKeys(e){if(!this._privKey){let e=randomBytes(this._primeByteLength);this._privKey=bufferToBigInt(e)}return this._pubKey=modPow(this._generator,this._privKey,this._prime),this.getPublicKey(e)}computeSecret(e,t,n){let r;r=typeof e==`string`?q.from(e,t||`utf8`):q.from(e);let i=bufferToBigInt(r);if(!this._privKey)throw Error(`You must generate keys before computing a secret`);if(i<=0n||i>=this._prime)throw Error(`Supplied key is too large`);let a=bigIntToBuffer(modPow(i,this._privKey,this._prime)),o=this._primeByteLength;if(a.length<o){let e=q.alloc(o);a.copy(e,o-a.length),a=e}return n?a.toString(n):a}getPrime(e){return formatReturnValue$1(this._prime,e)}getGenerator(e){return formatReturnValue$1(this._generator,e)}getPublicKey(e){if(!this._pubKey)throw Error(`No public key - call generateKeys() first`);return formatReturnValue$1(this._pubKey,e)}getPrivateKey(e){if(!this._privKey)throw Error(`No private key - call generateKeys() first`);return formatReturnValue$1(this._privKey,e)}setPublicKey(e,t){if(!this._malleable)throw Error(`setPublicKey is not available for predefined DH groups`);let n=typeof e==`string`?q.from(e,t||`utf8`):q.from(e);this._pubKey=bufferToBigInt(n)}setPrivateKey(e,t){if(!this._malleable)throw Error(`setPrivateKey is not available for predefined DH groups`);let n=typeof e==`string`?q.from(e,t||`utf8`):q.from(e);this._privKey=bufferToBigInt(n)}},Pi={binary:!0,hex:!0,base64:!0,latin1:!0,utf8:!0,"utf-8":!0,base64url:!0,ascii:!0,ucs2:!0,"ucs-2":!0,utf16le:!0,"utf-16le":!0},Fi=getDiffieHellman,Ii=getDiffieHellman});function mod(e,t){let n=e%t;return n<0n?n+t:n}function modInverse$2(e,t){if(e=mod(e,t),e===0n)throw Error(`No modular inverse for zero`);let[n,r]=[e,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}if(n!==1n)throw Error(`Modular inverse does not exist`);return mod(i,t)}function pointAdd(e,t,n){if(e===null)return t;if(t===null)return e;let{p:r}=n;if(e.x===t.x)return mod(e.y+t.y,r)===0n?null:pointDouble(e,n);let i=mod(t.x-e.x,r),a=mod(mod(t.y-e.y,r)*modInverse$2(i,r),r),o=mod(a*a-e.x-t.x,r);return{x:o,y:mod(a*(e.x-o)-e.y,r)}}function pointDouble(e,t){if(e===null)return null;let{a:n,p:r}=t;if(e.y===0n)return null;let i=mod(mod(3n*e.x*e.x+n,r)*modInverse$2(mod(2n*e.y,r),r),r),a=mod(i*i-2n*e.x,r);return{x:a,y:mod(i*(e.x-a)-e.y,r)}}function scalarMul(e,t,n){if(t===null||e===0n)return null;let{n:r}=n;if(e=mod(e,r),e===0n)return null;let i=null,a=t,o=e.toString(2);for(let e=0;e<o.length;e++)o[e]===`1`?(i=pointAdd(i,a,n),a=pointDouble(a,n)):(a=pointAdd(i,a,n),i=pointDouble(i,n));return i}function bigintToBuffer(e,t){let n=e.toString(16).padStart(t*2,`0`);return q.from(n,`hex`)}function bufferToBigint(e){let t=q.from(e).toString(`hex`);return t.length===0?0n:BigInt(`0x`+t)}function encodePublicKey(e,t,n=`uncompressed`){if(e===null)throw Error(`Cannot encode the point at infinity`);let r=bigintToBuffer(e.x,t);if(n===`compressed`){let t=e.y%2n==0n?2:3;return q.concat([q.from([t]),r])}let i=bigintToBuffer(e.y,t);if(n===`hybrid`){let t=e.y%2n==0n?6:7;return q.concat([q.from([t]),r,i])}return q.concat([q.from([4]),r,i])}function decodePublicKey(e,t){let n=q.from(e);if(n.length===0)throw Error(`Invalid public key: empty buffer`);let r=n[0],{p:i,a,b:o,byteLength:s}=t;if(r===4||r===6||r===7){if(n.length!==1+2*s)throw Error(`Invalid public key length: expected ${1+2*s} bytes, got ${n.length}`);let e=bufferToBigint(n.subarray(1,1+s)),t=bufferToBigint(n.subarray(1+s));if(mod(t*t,i)!==mod(e*e*e+a*e+o,i))throw Error(`Invalid public key: point is not on the curve`);return{x:e,y:t}}if(r===2||r===3){if(n.length!==1+s)throw Error(`Invalid public key length: expected ${1+s} bytes, got ${n.length}`);let e=bufferToBigint(n.subarray(1,1+s)),t=sqrtMod(mod(e*e*e+a*e+o,i),i);if(t===null)throw Error(`Invalid public key: no valid y coordinate for the given x`);let c=r===3;return{x:e,y:t%2n!=0n===c?t:mod(i-t,i)}}throw Error(`Invalid public key prefix: 0x${r.toString(16).padStart(2,`0`)}`)}function sqrtMod(e,t){if(e=mod(e,t),e===0n)return 0n;if(modPow(e,(t-1n)/2n,t)!==1n)return null;if(mod(t,4n)===3n)return modPow(e,(t+1n)/4n,t);let n=0n,r=t-1n;for(;mod(r,2n)===0n;)r/=2n,n++;let i=2n;for(;modPow(i,(t-1n)/2n,t)!==t-1n;)i++;let a=n,o=modPow(i,r,t),s=modPow(e,r,t),c=modPow(e,(r+1n)/2n,t);for(;;){if(s===0n)return 0n;if(s===1n)return c;let e=1n,n=mod(s*s,t);for(;n!==1n;)n=mod(n*n,t),e++;let r=modPow(o,modPow(2n,a-e-1n,t-1n),t);a=e,o=mod(r*r,t),s=mod(s*o,t),c=mod(c*r,t)}}function toBuffer$1(e,t){if(q.isBuffer(e))return e;if(e instanceof Uint8Array)return q.from(e);if(typeof e==`string`)return q.from(e,t||`utf8`);if(ArrayBuffer.isView(e))return q.from(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`The "key" argument must be of type string or an instance of Buffer, TypedArray, or DataView.`)}function formatReturnValue(e,t){return t?e.toString(t):e}function resolveCurve(e){let t=zi[e.toLowerCase()];if(!t)throw Error(`Unsupported curve: ${e}`);let n=Ri[t];if(!n)throw Error(`Unsupported curve: ${e}`);return{canonical:t,params:n}}function createECDH(e){return new ECDH(e)}function getCurves(){return[`secp256k1`,`prime256v1`,`secp256r1`,`secp384r1`,`secp521r1`]}var Ri,zi,ECDH,Bi=__esmMin(()=>{Ai(),ki(),J(),Ri={secp256k1:{p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,byteLength:32},prime256v1:{p:115792089210356248762697446949407573530086143415290314195533631308867097853951n,a:115792089210356248762697446949407573530086143415290314195533631308867097853951n-3n,b:41058363725152142129326129780047268409114441015993725554835256314039467401291n,Gx:48439561293906451759052585252797914202762949526041747995844080717082404635286n,Gy:36134250956749795798585127919587881956611106672985015071877198253568414405109n,n:115792089210356248762697446949407573529996955224135760342422259061068512044369n,byteLength:32},secp384r1:{p:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n,a:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n-3n,b:27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,Gx:26247035095799689268623156744566981891852923491109213387815615900925518854738050089022388053975719786650872476732087n,Gy:8325710961489029985546751289520108179287853048861315594709205902480503199884419224438643760392947333078086511627871n,n:39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643n,byteLength:48},secp521r1:{p:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n,a:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n-3n,b:1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,Gx:2661740802050217063228768716723360960729859168756973147706671368418802944996427808491545080627771902352094241225065558662157113545570916814161637315895999846n,Gy:3757180025770020463545507224491183603594455134769762486694567779615544477440556316691234405012945539562144444537289428522585666729196580810124344277578376784n,n:6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449n,byteLength:66}},zi={secp256k1:`secp256k1`,prime256v1:`prime256v1`,secp256r1:`prime256v1`,"p-256":`prime256v1`,p256:`prime256v1`,secp384r1:`secp384r1`,"p-384":`secp384r1`,p384:`secp384r1`,secp521r1:`secp521r1`,"p-521":`secp521r1`,p521:`secp521r1`},__name(modInverse$2,`modInverse`),__name(toBuffer$1,`toBuffer`),ECDH=class{_curve;_curveName;_privateKey=null;_publicKey=null;constructor(e){let t=resolveCurve(e);this._curve=t.params,this._curveName=t.canonical}generateKeys(e,t){let{n,byteLength:r}=this._curve,i;do i=bufferToBigint(randomBytes(r));while(i===0n||i>=n);this._privateKey=i;let a={x:this._curve.Gx,y:this._curve.Gy};return this._publicKey=scalarMul(i,a,this._curve),this.getPublicKey(e,t)}computeSecret(e,t,n){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);let r=decodePublicKey(toBuffer$1(e,t),this._curve);if(r===null)throw Error(`Invalid public key: point at infinity`);let i=scalarMul(this._privateKey,r,this._curve);if(i===null)throw Error(`Shared secret computation resulted in the point at infinity`);return formatReturnValue(bigintToBuffer(i.x,this._curve.byteLength),n)}getPublicKey(e,t){if(this._publicKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(encodePublicKey(this._publicKey,this._curve.byteLength,t||`uncompressed`),e)}getPrivateKey(e){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(bigintToBuffer(this._privateKey,this._curve.byteLength),e)}setPublicKey(e,t){let n=toBuffer$1(e,t);this._publicKey=decodePublicKey(n,this._curve)}setPrivateKey(e,t){let n=bufferToBigint(toBuffer$1(e,t));if(n===0n||n>=this._curve.n)throw Error(`Private key is out of range [1, n-1]`);this._privateKey=n;let r={x:this._curve.Gx,y:this._curve.Gy};this._publicKey=scalarMul(n,r,this._curve)}}});function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function hashSize(e){let t=Vi[normalizeAlgorithm(e)];if(t===void 0)throw Error(`Unknown hash algorithm: ${e}`);return t}function toBuffer(e,t){return typeof e==`string`?q.from(e,t||`utf8`):e instanceof DataView?q.from(e.buffer,e.byteOffset,e.byteLength):(e instanceof ArrayBuffer,q.from(e))}var Vi,Hi,Ui,Wi=__esmMin(()=>{J(),Vi={md5:16,sha1:20,sha256:32,sha384:48,sha512:64},Hi={md5:64,sha1:64,sha256:64,sha384:128,sha512:128},Ui=new Set([`md5`,`sha1`,`sha256`,`sha384`,`sha512`])});function getChecksumType(e){let t=Gi[normalizeAlgorithm(e)];if(t===void 0){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}return t}function getHashes(){return[`md5`,`sha1`,`sha256`,`sha384`,`sha512`]}function hash(e,t,n){return new Ki(e).update(t).digest(n)}var Gi,Ki,qi=__esmMin(()=>{Wi(),J(),A(),Kr(),Gi={md5:k.ChecksumType.MD5,sha1:k.ChecksumType.SHA1,sha256:k.ChecksumType.SHA256,sha384:k.ChecksumType.SHA384,sha512:k.ChecksumType.SHA512},Ki=class Hash extends Ur{_algorithm;_checksum;_finalized=!1;constructor(e){super();let t=normalizeAlgorithm(e),n=getChecksumType(t);this._algorithm=t,this._checksum=new k.Checksum(n)}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;if(typeof e==`string`){let r=normalizeEncoding(t);n=q.from(e,r)}else n=e instanceof Uint8Array?e:q.from(e);return this._checksum.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._checksum.get_string(),n=q.from(t,`hex`);return e?n.toString(e):n}copy(){if(this._finalized)throw Error(`Digest already called`);let e=Object.create(Hash.prototype);return Ur.call(e),e._algorithm=this._algorithm,e._finalized=!1,e._checksum=this._checksum.copy(),e}_transform(e,t,n){try{this.update(e,t),n()}catch(e){n(e)}}_flush(e){try{this.push(this.digest()),e()}catch(t){e(t)}}}}),Hmac,Ji=__esmMin(()=>{Wi(),qi(),J(),Kr(),Hmac=class extends Ur{_algorithm;_innerHash;_outerKeyPad;_finalized=!1;constructor(e,t){super();let n=normalizeAlgorithm(e);if(!Ui.has(n)){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}this._algorithm=n;let r;r=typeof t==`string`?q.from(t,`utf8`):t instanceof Uint8Array?t:q.from(t);let i=Hi[n];if(r.length>i){let e=new Ki(n);e.update(r),r=e.digest()}let a=new Uint8Array(i);a.set(r);let o=new Uint8Array(i),s=new Uint8Array(i);for(let e=0;e<i;e++)o[e]=a[e]^54,s[e]=a[e]^92;this._outerKeyPad=s,this._innerHash=new Ki(n),this._innerHash.update(o)}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;if(typeof e==`string`){let r=normalizeEncoding(t);n=q.from(e,r)}else n=e instanceof Uint8Array?e:q.from(e);return this._innerHash.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._innerHash.digest(),n=new Ki(this._algorithm);n.update(this._outerKeyPad),n.update(t);let r=n.digest();return e?r.toString(e):r}_transform(e,t,n){try{this.update(e,t),n()}catch(e){n(e)}}_flush(e){try{this.push(this.digest()),e()}catch(t){e(t)}}}});function getCurve(e){let t=zi[e.toLowerCase()];if(!t)throw Error(`Unsupported curve: ${e}`);return Ri[t]}function truncateHash(e,t){let n=t.n.toString(2).length,r=bytesToBigInt(e),i=e.length*8;return i>n&&(r>>=BigInt(i-n)),r}function hmacDigest$2(e,t,n){let r=new Hmac(e,t);return r.update(n),new Uint8Array(r.digest())}function rfc6979(e,t,n,r){let i=r.byteLength,a=n.length,o=new Uint8Array(a).fill(1),s=new Uint8Array(a).fill(0),c=bigIntToBytes(t,i),l=bigIntToBytes(mod(truncateHash(n,r),r.n),i),u=new Uint8Array(a+1+i+i);u.set(o,0),u[a]=0,u.set(c,a+1),u.set(l,a+1+i),s=hmacDigest$2(e,s,u),o=hmacDigest$2(e,s,o);let d=new Uint8Array(a+1+i+i);d.set(o,0),d[a]=1,d.set(c,a+1),d.set(l,a+1+i),s=hmacDigest$2(e,s,d),o=hmacDigest$2(e,s,o);for(let t=0;t<100;t++){let t=new Uint8Array;for(;t.length<i;){o=hmacDigest$2(e,s,o);let n=new Uint8Array(t.length+o.length);n.set(t,0),n.set(o,t.length),t=n}let n=truncateHash(t.slice(0,i),r);if(n>=1n&&n<r.n)return n;let c=new Uint8Array(a+1);c.set(o,0),c[a]=0,s=hmacDigest$2(e,s,c),o=hmacDigest$2(e,s,o)}throw Error(`RFC 6979: failed to generate valid k after 100 attempts`)}function ecdsaSign(e,t,n,r){let i=getCurve(r),a={x:i.Gx,y:i.Gy},o=bytesToBigInt(t),s=new Ki(e);s.update(n);let c=new Uint8Array(s.digest()),l=truncateHash(c,i),u=rfc6979(e,o,c,i),d=scalarMul(u,a,i);if(d===null)throw Error(`ECDSA: k * G is point at infinity`);let p=mod(d.x,i.n);if(p===0n)throw Error(`ECDSA: r is zero`);let m=mod(modInverse$2(u,i.n)*(l+p*o),i.n);if(m===0n)throw Error(`ECDSA: s is zero`);let h=i.byteLength,g=new Uint8Array(h*2);return g.set(bigIntToBytes(p,h),0),g.set(bigIntToBytes(m,h),h),g}function ecdsaVerify(e,t,n,r,i){let a=getCurve(i),o={x:a.Gx,y:a.Gy},s=a.byteLength;if(t[0]!==4||t.length!==1+s*2)return!1;let c={x:bytesToBigInt(t.slice(1,1+s)),y:bytesToBigInt(t.slice(1+s))};if(n.length!==s*2)return!1;let l=bytesToBigInt(n.slice(0,s)),u=bytesToBigInt(n.slice(s));if(l<1n||l>=a.n||u<1n||u>=a.n)return!1;let d=new Ki(e);d.update(r);let p=truncateHash(new Uint8Array(d.digest()),a),m=modInverse$2(u,a.n),h=mod(p*m,a.n),g=mod(l*m,a.n),_=pointAdd(scalarMul(h,o,a),scalarMul(g,c,a),a);return _===null?!1:mod(_.x,a.n)===l}var Yi=__esmMin(()=>{Ai(),Bi(),qi(),Ji(),__name(hmacDigest$2,`hmacDigest`)});function hmacDigest$1(e,t,n){let r=new Hmac(e,t);return r.update(n),r.digest()}function hkdfExtract(e,t,n){return hmacDigest$1(e,n,t)}function hkdfExpand(e,t,n,r,i){let a=Math.ceil(r/i);if(a>255)throw Error(`HKDF cannot generate more than 255 * HashLen bytes`);let o=q.allocUnsafe(a*i),s=q.alloc(0);for(let r=1;r<=a;r++)s=hmacDigest$1(e,t,q.concat([s,n,q.from([r])])),s.copy(o,(r-1)*i);return q.from(o.buffer,o.byteOffset,r)}function hkdfSync(e,t,n,r,i){let a=normalizeAlgorithm(e),o=Vi[a];if(!Ui.has(a)||o===void 0)throw TypeError(`Unknown message digest: ${e}`);if(typeof i!=`number`||i<0)throw TypeError(`keylen must be a non-negative number`);let s=toBuffer(t),c=toBuffer(n),l=toBuffer(r),u=hkdfExpand(a,hkdfExtract(a,s,c.length===0?q.alloc(o,0):c),l,i,o),d=new ArrayBuffer(u.length);return new Uint8Array(d).set(u),d}function hkdf(e,t,n,r,i,a){setTimeout(()=>{try{a(null,hkdfSync(e,t,n,r,i))}catch(e){a(e instanceof Error?e:Error(String(e)))}},0)}var Xi=__esmMin(()=>{Wi(),Ji(),J(),__name(hmacDigest$1,`hmacDigest`)});function timingSafeEqual(e,t){if(e.length!==t.length)throw RangeError(`Input buffers must have the same byte length`);let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var Zi=__esmMin(()=>{});function hmacDigest(e,t,n){let r=new Hmac(e,t);return r.update(n),r.digest()}function validateParameters(e,t){if(typeof e!=`number`||e<0||!Number.isFinite(e)||e===0)throw TypeError(`iterations must be a positive number`);if(typeof t!=`number`||t<0||!Number.isFinite(t)||t>2147483647)throw TypeError(`keylen must be a positive number`)}function pbkdf2Sync(e,t,n,r,i){validateParameters(n,r);let a=toBuffer(e),o=toBuffer(t),s=normalizeAlgorithm(i||`sha1`),c=Vi[s];if(!Ui.has(s)||c===void 0)throw TypeError(`Unknown message digest: ${i||`sha1`}`);if(r===0)return q.alloc(0);let l=Math.ceil(r/c),u=q.allocUnsafe(l*c);for(let e=1;e<=l;e++){let t=q.allocUnsafe(o.length+4);o.copy(t,0),t.writeUInt32BE(e,o.length);let r=hmacDigest(s,a,t),i=q.from(r);for(let e=1;e<n;e++){r=hmacDigest(s,a,r);for(let e=0;e<c;e++)i[e]^=r[e]}i.copy(u,(e-1)*c)}return q.from(u.buffer,u.byteOffset,r)}function pbkdf2(e,t,n,r,i,a){validateParameters(n,r),setTimeout(()=>{try{a(null,pbkdf2Sync(e,t,n,r,i))}catch(e){a(e instanceof Error?e:Error(String(e)))}},0)}var Qi=__esmMin(()=>{Wi(),Ji(),J()});function R(e,t){return(e<<t|e>>>32-t)>>>0}function salsa20_8(e){let t=new Uint32Array(16);for(let n=0;n<16;n++)t[n]=e[n];for(let e=0;e<4;e++)t[4]^=R(t[0]+t[12],7),t[8]^=R(t[4]+t[0],9),t[12]^=R(t[8]+t[4],13),t[0]^=R(t[12]+t[8],18),t[9]^=R(t[5]+t[1],7),t[13]^=R(t[9]+t[5],9),t[1]^=R(t[13]+t[9],13),t[5]^=R(t[1]+t[13],18),t[14]^=R(t[10]+t[6],7),t[2]^=R(t[14]+t[10],9),t[6]^=R(t[2]+t[14],13),t[10]^=R(t[6]+t[2],18),t[3]^=R(t[15]+t[11],7),t[7]^=R(t[3]+t[15],9),t[11]^=R(t[7]+t[3],13),t[15]^=R(t[11]+t[7],18),t[1]^=R(t[0]+t[3],7),t[2]^=R(t[1]+t[0],9),t[3]^=R(t[2]+t[1],13),t[0]^=R(t[3]+t[2],18),t[6]^=R(t[5]+t[4],7),t[7]^=R(t[6]+t[5],9),t[4]^=R(t[7]+t[6],13),t[5]^=R(t[4]+t[7],18),t[11]^=R(t[10]+t[9],7),t[8]^=R(t[11]+t[10],9),t[9]^=R(t[8]+t[11],13),t[10]^=R(t[9]+t[8],18),t[12]^=R(t[15]+t[14],7),t[13]^=R(t[12]+t[15],9),t[14]^=R(t[13]+t[12],13),t[15]^=R(t[14]+t[13],18);for(let n=0;n<16;n++)e[n]=e[n]+t[n]>>>0}function blockMix(e,t){let n=2*t*16,r=new Uint32Array(16);for(let t=0;t<16;t++)r[t]=e[n-16+t];let i=new Uint32Array(n);for(let n=0;n<2*t;n++){for(let t=0;t<16;t++)r[t]^=e[n*16+t];salsa20_8(r);for(let e=0;e<16;e++)i[n*16+e]=r[e]}for(let n=0;n<t;n++)for(let t=0;t<16;t++)e[n*16+t]=i[2*n*16+t];for(let n=0;n<t;n++)for(let r=0;r<16;r++)e[(t+n)*16+r]=i[(2*n+1)*16+r]}function roMix(e,t,n){let r=2*n*16,i=Array.from({length:t});for(let r=0;r<t;r++)i[r]=new Uint32Array(e),blockMix(e,n);for(let a=0;a<t;a++){let a=e[r-16]&t-1;for(let t=0;t<r;t++)e[t]^=i[a][t];blockMix(e,n)}}function bytesToWords(e){let t=new Uint32Array(e.length/4);for(let n=0;n<t.length;n++)t[n]=e[n*4]|e[n*4+1]<<8|e[n*4+2]<<16|e[n*4+3]<<24;return t}function wordsToBytes(e){let t=new Uint8Array(e.length*4);for(let n=0;n<e.length;n++)t[n*4]=e[n]&255,t[n*4+1]=e[n]>>8&255,t[n*4+2]=e[n]>>16&255,t[n*4+3]=e[n]>>24&255;return t}function scryptCore(e,t,n,r,i,a){let o=128*r,s=pbkdf2Sync(e,t,1,i*o,`sha256`);for(let e=0;e<i;e++){let t=new Uint8Array(s.buffer,s.byteOffset+e*o,o),i=bytesToWords(t);roMix(i,n,r);let a=wordsToBytes(i);t.set(a)}return pbkdf2Sync(e,s,1,a,`sha256`)}function scryptSync(e,t,n,r){let i=q.from(e),a=q.from(t),o=r?.N??16384,s=r?.r??8,c=r?.p??1;if(o<=0||o&o-1)throw Error(`N must be a positive power of 2`);return scryptCore(i,a,o,s,c,n)}function scrypt(e,t,n,r,i){let a={},o;typeof r==`function`?o=r:(a=r,o=i);try{let r=scryptSync(e,t,n,a);setTimeout(()=>o(null,r),0)}catch(e){setTimeout(()=>o(e instanceof Error?e:Error(String(e)),q.alloc(0)),0)}}var $i=__esmMin(()=>{Qi(),J()});function pemToDer(e){let t=e.trim().split(/\r?\n/),n=t.findIndex(e=>e.startsWith(`-----BEGIN `));if(n===-1)throw Error(`Invalid PEM: no BEGIN line found`);let r=t[n].match(/^-----BEGIN (.+)-----$/);if(!r)throw Error(`Invalid PEM header format`);let i=r[1],a=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(a===-1)throw Error(`Invalid PEM: no END line found`);let o=t.slice(n+1,a).join(``),s=q.from(o,`base64`);return{type:i,der:new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}}function parseTlv(e,t){if(t>=e.length)throw Error(`ASN.1 parse error: unexpected end of data`);let n=e[t++],r,i=e[t++];if(i<128)r=i;else{let n=i&127;if(n===0)throw Error(`ASN.1 parse error: indefinite length not supported`);r=0;for(let i=0;i<n;i++)r=r<<8|e[t++]}let a=e.slice(t,t+r),o=t+r,s={tag:n,data:a};return n===48&&(s.children=parseSequenceChildren(a)),{value:s,next:o}}function parseSequenceChildren(e){let t=[],n=0;for(;n<e.length;){let{value:r,next:i}=parseTlv(e,n);t.push(r),n=i}return t}function parseDer(e){let{value:t}=parseTlv(e,0);return t}function integerToBigInt(e){let t=0;for(;t<e.length-1&&e[t]===0;)t++;let n=0n;for(let r=t;r<e.length;r++)n=n<<8n|BigInt(e[r]);return n}function oidsEqual(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function parseRsaPublicKeyPkcs1(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid PKCS#1 RSAPublicKey structure`);return{n:integerToBigInt(t[0].data),e:integerToBigInt(t[1].data)}}function parseRsaPrivateKeyPkcs1(e){let t=e.children;if(!t||t.length<6)throw Error(`Invalid PKCS#1 RSAPrivateKey structure`);return{n:integerToBigInt(t[1].data),e:integerToBigInt(t[2].data),d:integerToBigInt(t[3].data),p:integerToBigInt(t[4].data),q:integerToBigInt(t[5].data)}}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=t[0];if(!n.children||n.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let r=n.children[0];if(r.tag!==6||!oidsEqual(r.data,ea))throw Error(`Unsupported algorithm: only RSA is supported`);let i=t[1];if(i.tag!==3)throw Error(`Expected BIT STRING for public key data`);return parseRsaPublicKeyPkcs1(parseDer(i.data.slice(1)))}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=t[1];if(!n.children||n.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let r=n.children[0];if(r.tag!==6||!oidsEqual(r.data,ea))throw Error(`Unsupported algorithm: only RSA is supported`);let i=t[2];if(i.tag!==4)throw Error(`Expected OCTET STRING for private key data`);return parseRsaPrivateKeyPkcs1(parseDer(i.data))}function encodeLength(e){if(e<128)return new Uint8Array([e]);let t=[],n=e;for(;n>0;)t.unshift(n&255),n>>=8;return new Uint8Array([128|t.length,...t])}function encodeTlv(e,t){let n=encodeLength(t.length),r=new Uint8Array(1+n.length+t.length);return r[0]=e,r.set(n,1),r.set(t,1+n.length),r}function bigintToAsn1Integer(e){if(e===0n)return encodeTlv(2,new Uint8Array([0]));let t=e.toString(16),n=t.length%2?`0`+t:t,r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return r[0]&128&&r.unshift(0),encodeTlv(2,new Uint8Array(r))}function encodeSequence(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return encodeTlv(48,n)}function encodeBitString(e){let t=new Uint8Array(1+e.length);return t[0]=0,t.set(e,1),encodeTlv(3,t)}function encodeOctetString(e){return encodeTlv(4,e)}function encodeOid(e){return encodeTlv(6,e)}function encodeNull(){return new Uint8Array([5,0])}function encodeRsaPublicKeyPkcs1(e){return encodeSequence([bigintToAsn1Integer(e.n),bigintToAsn1Integer(e.e)])}function encodeSubjectPublicKeyInfo(e){return encodeSequence([encodeSequence([encodeOid(ea),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$1(e.q,e.p);return encodeSequence([bigintToAsn1Integer(0n),bigintToAsn1Integer(e.n),bigintToAsn1Integer(e.e),bigintToAsn1Integer(e.d),bigintToAsn1Integer(e.p),bigintToAsn1Integer(e.q),bigintToAsn1Integer(t),bigintToAsn1Integer(n),bigintToAsn1Integer(r)])}function encodePrivateKeyInfo(e){let t=encodeSequence([encodeOid(ea),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function derToPem(e,t){let n=q.from(e).toString(`base64`),r=[`-----BEGIN ${t}-----`];for(let e=0;e<n.length;e+=64)r.push(n.substring(e,e+64));return r.push(`-----END ${t}-----`),r.join(`
6
- `)}function modInverse$1(e,t){let[n,r]=[e%t,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}return(i%t+t)%t}function parseX509(e){let{der:t}=pemToDer(e);return parseX509Der(t)}function parseX509Der(e){let t=parseDer(e);if(t.tag!==48||!t.children||t.children.length<3)throw Error(`Invalid X.509 certificate structure`);let n=t.children[0],r=t.children[1],i=t.children[2];if(!n.children||n.children.length<6)throw Error(`Invalid TBSCertificate structure`);let a=0;n.children[0].tag===160&&a++;let o=integerToBigInt(n.children[a].data);a++,a++;let s=parseDN(n.children[a]);a++;let c=n.children[a],l=parseAsn1Time(c.children[0]),u=parseAsn1Time(c.children[1]);a++;let d=parseDN(n.children[a]);a++;let p=null,m=`unknown`;if(a<n.children.length){let e=n.children[a];try{if(e.children&&e.children.length>=2){let t=e.children[0];if(t.children&&t.children.length>=1){let n=t.children[0];n.tag===6&&oidsEqual(n.data,ea)&&(m=`rsa`,p=parseSubjectPublicKeyInfo(e))}}}catch{}a++}let h,g;for(let e=a;e<n.children.length;e++){let t=n.children[e];if(t.tag===163&&t.data.length>0){let e=parseDer(t.data);if(e.children){g=e.children;let t=new Uint8Array([85,29,17]);for(let n of e.children)if(n.children&&n.children.length>=2){let e=n.children[0];if(e.tag===6&&oidsEqual(e.data,t)){let e=n.children[n.children.length-1];h=parseSAN(e.data)}}}}}let _=`unknown`;r.children&&r.children.length>=1&&(_=oidToName(r.children[0].data));let v=i.tag===3?i.data.slice(1):i.data;return{raw:e,tbsCertificate:n.data,serialNumber:o,issuer:s,subject:d,validFrom:l,validTo:u,publicKey:p,publicKeyAlgorithm:m,signatureAlgorithm:_,signature:v,subjectAltName:h,extensions:g}}function decodeOidString(e){if(e.length===0)return``;let t=[];t.push(Math.floor(e[0]/40)),t.push(e[0]%40);let n=0;for(let r=1;r<e.length;r++)n=n<<7|e[r]&127,e[r]&128||(t.push(n),n=0);return t.join(`.`)}function oidToName(e){let t=decodeOidString(e);return na[t]||t}function parseDN(e){if(!e.children)return``;let t=[];for(let n of e.children){let e=n.tag===49?parseSequenceChildren(n.data):n.children||[];for(let n of e)if(n.children&&n.children.length>=2){let e=n.children[0].data,r=decodeOidString(e),i=ta[r]||r,a=n.children[1].data,o=new TextDecoder().decode(a);t.push(`${i}=${o}`)}}return t.join(`, `)}function parseAsn1Time(e){let t=new TextDecoder().decode(e.data);if(e.tag===23){let e=parseInt(t.substring(0,2),10);e=e>=50?1900+e:2e3+e;let n=parseInt(t.substring(2,4),10)-1,r=parseInt(t.substring(4,6),10),i=parseInt(t.substring(6,8),10),a=parseInt(t.substring(8,10),10),o=parseInt(t.substring(10,12),10);return new Date(Date.UTC(e,n,r,i,a,o))}if(e.tag===24){let e=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10)-1,r=parseInt(t.substring(6,8),10),i=parseInt(t.substring(8,10),10),a=parseInt(t.substring(10,12),10),o=parseInt(t.substring(12,14),10);return new Date(Date.UTC(e,n,r,i,a,o))}throw Error(`Unsupported time tag: 0x${e.tag.toString(16)}`)}function parseSAN(e){let t=[];try{let n=parseDer(e);if(n.tag===48&&n.children){for(let e of n.children)if(e.tag===130)t.push(`DNS:`+new TextDecoder().decode(e.data));else if(e.tag===135){if(e.data.length===4)t.push(`IP Address:`+e.data.join(`.`));else if(e.data.length===16){let n=[];for(let t=0;t<16;t+=2)n.push((e.data[t]<<8|e.data[t+1]).toString(16));t.push(`IP Address:`+n.join(`:`))}}}}catch{}return t}function parsePemKey(e){let{type:t,der:n}=pemToDer(e),r=parseDer(n);if(r.tag!==48)throw Error(`Invalid key format: expected top-level SEQUENCE`);switch(t){case`RSA PUBLIC KEY`:return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(r)};case`PUBLIC KEY`:return{type:`rsa-public`,components:parseSubjectPublicKeyInfo(r)};case`RSA PRIVATE KEY`:return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(r)};case`PRIVATE KEY`:return{type:`rsa-private`,components:parsePrivateKeyInfo(r)};default:throw Error(`Unsupported PEM type: ${t}`)}}function rsaKeySize(e){let t=0,n=e;for(;n>0n;)t++,n>>=1n;return Math.ceil(t/8)}var ea,ta,na,ra=__esmMin(()=>{J(),ea=new Uint8Array([42,134,72,134,247,13,1,1,1]),__name(modInverse$1,`modInverse`),ta={"2.5.4.3":`CN`,"2.5.4.6":`C`,"2.5.4.7":`L`,"2.5.4.8":`ST`,"2.5.4.10":`O`,"2.5.4.11":`OU`,"1.2.840.113549.1.9.1":`emailAddress`},na={"1.2.840.113549.1.1.1":`rsaEncryption`,"1.2.840.113549.1.1.5":`sha1WithRSAEncryption`,"1.2.840.113549.1.1.11":`sha256WithRSAEncryption`,"1.2.840.113549.1.1.12":`sha384WithRSAEncryption`,"1.2.840.113549.1.1.13":`sha512WithRSAEncryption`}});function normalizeSignAlgorithm(e){let t=e.toLowerCase().replace(/-/g,``);if(t.startsWith(`rsa`)&&(t=t.slice(3)),!ia[t])throw Error(`Unsupported algorithm: ${e}. Supported: RSA-SHA1, RSA-SHA256, RSA-SHA512`);return t}function extractPem$1(e){if(typeof e==`string`)return e;if(q.isBuffer(e)||e instanceof Uint8Array)return q.from(e).toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e.key;if(typeof t==`string`)return t;if(q.isBuffer(t)||t instanceof Uint8Array)return q.from(t).toString(`utf8`)}throw TypeError(`Invalid key argument`)}function createSign(e){return new Sign(e)}function createVerify(e){return new Verify(e)}var ia,Sign,Verify,aa=__esmMin(()=>{ra(),Ai(),qi(),J(),ia={sha1:new Uint8Array([48,33,48,9,6,5,43,14,3,2,26,5,0,4,20]),sha256:new Uint8Array([48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]),sha512:new Uint8Array([48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64])},__name(extractPem$1,`extractPem`),Sign=class{_algorithm;_hash;_finalized=!1;constructor(e){this._algorithm=normalizeSignAlgorithm(e),this._hash=new Ki(this._algorithm)}update(e,t){if(this._finalized)throw Error(`Sign was already finalized`);return this._hash.update(e,t),this}sign(e,t){if(this._finalized)throw Error(`Sign was already finalized`);this._finalized=!0;let n=this._hash.digest(),r=parsePemKey(extractPem$1(e));if(r.type!==`rsa-private`)throw Error(`privateKey must be an RSA private key`);let{n:i,d:a}=r.components,o=rsaKeySize(i),s=ia[this._algorithm],c=new Uint8Array(s.length+n.length);c.set(s,0),c.set(n,s.length);let l=o-c.length-3;if(l<8)throw Error(`Key is too short for the specified hash algorithm`);let u=new Uint8Array(o);u[0]=0,u[1]=1;for(let e=2;e<2+l;e++)u[e]=255;u[2+l]=0,u.set(c,3+l);let d=bigIntToBytes(modPow(bytesToBigInt(u),a,i),o),p=q.from(d);return t?p.toString(t):p}},Verify=class{_algorithm;_hash;_finalized=!1;constructor(e){this._algorithm=normalizeSignAlgorithm(e),this._hash=new Ki(this._algorithm)}update(e,t){if(this._finalized)throw Error(`Verify was already finalized`);return this._hash.update(e,t),this}verify(e,t,n){if(this._finalized)throw Error(`Verify was already finalized`);this._finalized=!0;let r=this._hash.digest(),i=parsePemKey(extractPem$1(e)),a,o;if(i.type===`rsa-public`)a=i.components.n,o=i.components.e;else if(i.type===`rsa-private`)a=i.components.n,o=i.components.e;else throw Error(`publicKey must be an RSA public or private key`);let s=rsaKeySize(a),c;if(c=typeof t==`string`?q.from(t,n||`base64`):t instanceof Uint8Array?t:q.from(t),c.length!==s)return!1;let l=bytesToBigInt(c);if(l>=a)return!1;let u=bigIntToBytes(modPow(l,o,a),s);if(u[0]!==0||u[1]!==1)return!1;let d=2;for(;d<u.length&&u[d]===255;)d++;if(d>=u.length||u[d]!==0||d-2<8)return!1;d++;let p=u.slice(d),m=ia[this._algorithm],h=new Uint8Array(m.length+r.length);if(h.set(m,0),h.set(r,m.length),p.length!==h.length)return!1;let g=0;for(let e=0;e<p.length;e++)g|=p[e]^h[e];return g===0}}});function extractPem(e){if(typeof e==`string`)return e;if(q.isBuffer(e)||e instanceof Uint8Array)return q.from(e).toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e.key;if(typeof t==`string`)return t;if(q.isBuffer(t)||t instanceof Uint8Array)return q.from(t).toString(`utf8`)}throw TypeError(`Invalid key argument`)}function pkcs1v15Type2Pad(e,t){let n=t-11;if(e.length>n)throw Error(`Data too long for key size. Max ${n} bytes, got ${e.length}`);let r=t-e.length-3,i=new Uint8Array(t);i[0]=0,i[1]=2;let a=randomBytes(r);for(let e=0;e<r;e++){for(;a[e]===0;)a[e]=randomBytes(1)[0];i[2+e]=a[e]}return i[2+r]=0,i.set(e,3+r),i}function pkcs1v15Type1Pad(e,t){let n=t-11;if(e.length>n)throw Error(`Data too long for key size. Max ${n} bytes, got ${e.length}`);let r=t-e.length-3,i=new Uint8Array(t);i[0]=0,i[1]=1;for(let e=2;e<2+r;e++)i[e]=255;return i[2+r]=0,i.set(e,3+r),i}function pkcs1v15Type2Unpad(e){if(e.length<11)throw Error(`Decryption error: message too short`);if(e[0]!==0||e[1]!==2)throw Error(`Decryption error: invalid padding`);let t=2;for(;t<e.length&&e[t]!==0;)t++;if(t>=e.length||t<10)throw Error(`Decryption error: invalid padding`);return e.slice(t+1)}function pkcs1v15Type1Unpad(e){if(e.length<11)throw Error(`Decryption error: message too short`);if(e[0]!==0||e[1]!==1)throw Error(`Decryption error: invalid padding`);let t=2;for(;t<e.length&&e[t]===255;)t++;if(t>=e.length||e[t]!==0||t<10)throw Error(`Decryption error: invalid padding`);return e.slice(t+1)}function publicEncrypt(e,t){let n=parsePemKey(extractPem(e)),r,i;if(n.type===`rsa-public`)r=n.components.n,i=n.components.e;else if(n.type===`rsa-private`)r=n.components.n,i=n.components.e;else throw Error(`Key must be an RSA public or private key`);let a=rsaKeySize(r),o=modPow(bytesToBigInt(pkcs1v15Type2Pad(t instanceof Uint8Array?t:q.from(t),a)),i,r);return q.from(bigIntToBytes(o,a))}function privateDecrypt(e,t){let n=parsePemKey(extractPem(e));if(n.type!==`rsa-private`)throw Error(`Key must be an RSA private key`);let{n:r,d:i}=n.components,a=rsaKeySize(r),o=t instanceof Uint8Array?t:q.from(t);if(o.length!==a)throw Error(`Data length (${o.length}) does not match key length (${a})`);let s=bytesToBigInt(o);if(s>=r)throw Error(`Decryption error: cipher value out of range`);let c=bigIntToBytes(modPow(s,i,r),a);return q.from(pkcs1v15Type2Unpad(c))}function privateEncrypt(e,t){let n=parsePemKey(extractPem(e));if(n.type!==`rsa-private`)throw Error(`Key must be an RSA private key`);let{n:r,d:i}=n.components,a=rsaKeySize(r),o=modPow(bytesToBigInt(pkcs1v15Type1Pad(t instanceof Uint8Array?t:q.from(t),a)),i,r);return q.from(bigIntToBytes(o,a))}function publicDecrypt(e,t){let n=parsePemKey(extractPem(e)),r,i;if(n.type===`rsa-public`)r=n.components.n,i=n.components.e;else if(n.type===`rsa-private`)r=n.components.n,i=n.components.e;else throw Error(`Key must be an RSA public or private key`);let a=rsaKeySize(r),o=t instanceof Uint8Array?t:q.from(t);if(o.length!==a)throw Error(`Data length (${o.length}) does not match key length (${a})`);let s=bytesToBigInt(o);if(s>=r)throw Error(`Decryption error: cipher value out of range`);let c=bigIntToBytes(modPow(s,i,r),a);return q.from(pkcs1v15Type1Unpad(c))}var oa=__esmMin(()=>{ra(),Ai(),ki(),J()});function mgf1(e,t,n){let r=new Uint8Array(n),i=0,a=0;for(;i<n;){let o=new Uint8Array(4);o[0]=a>>>24&255,o[1]=a>>>16&255,o[2]=a>>>8&255,o[3]=a&255;let s=new Ki(e);s.update(t),s.update(o);let c=new Uint8Array(s.digest()),l=Math.min(c.length,n-i);r.set(c.slice(0,l),i),i+=l,a++}return r}var sa=__esmMin(()=>{qi()});function hashDigest$1(e,t){let n=new Ki(e);return n.update(t),new Uint8Array(n.digest())}function emsaPssEncode(e,t,n,r){let i=hashSize(n),a=Math.ceil(t/8);if(a<i+r+2)throw Error(`RSA-PSS: encoding error — key too short`);let o=r>0?new Uint8Array(randomBytes(r)):new Uint8Array,s=new Uint8Array(8+i+r);s.set(e,8),s.set(o,8+i);let c=hashDigest$1(n,s),l=a-i-1,u=new Uint8Array(l);u[l-r-1]=1,u.set(o,l-r);let d=mgf1(n,c,l),p=new Uint8Array(l);for(let e=0;e<l;e++)p[e]=u[e]^d[e];let m=8*a-t;m>0&&(p[0]&=255>>>m);let h=new Uint8Array(a);return h.set(p,0),h.set(c,l),h[a-1]=188,h}function emsaPssVerify(e,t,n,r,i){let a=hashSize(r),o=Math.ceil(n/8);if(o<a+i+2||t[o-1]!==188)return!1;let s=o-a-1,c=t.slice(0,s),l=t.slice(s,s+a),u=8*o-n;if(u>0&&c[0]&255<<8-u)return!1;let d=mgf1(r,l,s),p=new Uint8Array(s);for(let e=0;e<s;e++)p[e]=c[e]^d[e];u>0&&(p[0]&=255>>>u);for(let e=0;e<s-i-1;e++)if(p[e]!==0)return!1;if(p[s-i-1]!==1)return!1;let m=p.slice(s-i),h=new Uint8Array(8+a+i);h.set(e,8),h.set(m,8+a);let g=hashDigest$1(r,h);if(l.length!==g.length)return!1;let _=0;for(let e=0;e<l.length;e++)_|=l[e]^g[e];return _===0}function rsaPssSign(e,t,n,r){let i=parsePemKey(t);if(i.type!==`rsa-private`)throw Error(`RSA-PSS: expected RSA private key`);let{n:a,d:o}=i.components,s=rsaKeySize(a),c=Math.ceil(s/8);return bigIntToBytes(modPow(bytesToBigInt(emsaPssEncode(hashDigest$1(e,n),s-1,e,r)),o,a),c)}function rsaPssVerify(e,t,n,r,i){let a=parsePemKey(t),o,s;if(a.type===`rsa-public`)({n:o,e:s}=a.components);else if(a.type===`rsa-private`)({n:o,e:s}=a.components);else throw Error(`RSA-PSS: expected RSA key`);let c=rsaKeySize(o),l=Math.ceil(c/8);if(n.length!==l)return!1;let u=bigIntToBytes(modPow(bytesToBigInt(n),s,o),Math.ceil((c-1)/8));return emsaPssVerify(hashDigest$1(e,r),u,c-1,e,i)}var ca=__esmMin(()=>{ra(),Ai(),Wi(),ki(),qi(),sa(),__name(hashDigest$1,`hashDigest`)});function hashDigest(e,t){let n=new Ki(e);return n.update(t),new Uint8Array(n.digest())}function rsaOaepEncrypt(e,t,n,r){let i=parsePemKey(t),a,o;if(i.type===`rsa-public`)({n:a,e:o}=i.components);else if(i.type===`rsa-private`)({n:a,e:o}=i.components);else throw Error(`RSA-OAEP: expected RSA key`);let s=Math.ceil(rsaKeySize(a)/8),c=hashSize(e);if(n.length>s-2*c-2)throw Error(`RSA-OAEP: message too long`);let l=hashDigest(e,r||new Uint8Array),u=s-c-1,d=new Uint8Array(u);d.set(l,0),d[u-n.length-1]=1,d.set(n,u-n.length);let p=new Uint8Array(randomBytes(c)),m=mgf1(e,p,u),h=new Uint8Array(u);for(let e=0;e<u;e++)h[e]=d[e]^m[e];let g=mgf1(e,h,c),_=new Uint8Array(c);for(let e=0;e<c;e++)_[e]=p[e]^g[e];let v=new Uint8Array(s);return v[0]=0,v.set(_,1),v.set(h,1+c),bigIntToBytes(modPow(bytesToBigInt(v),o,a),s)}function rsaOaepDecrypt(e,t,n,r){let i=parsePemKey(t);if(i.type!==`rsa-private`)throw Error(`RSA-OAEP: expected RSA private key`);let{n:a,d:o}=i.components,s=Math.ceil(rsaKeySize(a)/8),c=hashSize(e);if(n.length!==s||s<2*c+2)throw Error(`RSA-OAEP: decryption error`);let l=bigIntToBytes(modPow(bytesToBigInt(n),o,a),s),u=l[0],d=l.slice(1,1+c),p=l.slice(1+c),m=s-c-1,h=mgf1(e,p,c),g=new Uint8Array(c);for(let e=0;e<c;e++)g[e]=d[e]^h[e];let _=mgf1(e,g,m),v=new Uint8Array(m);for(let e=0;e<m;e++)v[e]=p[e]^_[e];let y=hashDigest(e,r||new Uint8Array),b=v.slice(0,c),x=+(u===0);for(let e=0;e<c;e++)x&=+(y[e]===b[e]);let S=-1;for(let e=c;e<m;e++)if(v[e]===1){S=e;break}else if(v[e]!==0){x=0;break}if(S===-1&&(x=0),!x)throw Error(`RSA-OAEP: decryption error`);return v.slice(S+1)}var la=__esmMin(()=>{ra(),Ai(),Wi(),ki(),qi(),sa()});function bigintToBase64url(e){if(e===0n)return`AA`;let t=e.toString(16),n=t.length%2?`0`+t:t,r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return q.from(r).toString(`base64url`)}function base64urlToBigint(e){let t=q.from(e,`base64url`),n=0n;for(let e=0;e<t.length;e++)n=n<<8n|BigInt(t[e]);return n}function exportJwk(e,t){if(e.type===`rsa-public`)return{kty:`RSA`,n:bigintToBase64url(e.components.n),e:bigintToBase64url(e.components.e)};if(e.type===`rsa-private`){if(t===`public`)return{kty:`RSA`,n:bigintToBase64url(e.components.n),e:bigintToBase64url(e.components.e)};let{n,e:r,d:i,p:a,q:o}=e.components,s=i%(a-1n),c=i%(o-1n),l=modInverse(o,a);return{kty:`RSA`,n:bigintToBase64url(n),e:bigintToBase64url(r),d:bigintToBase64url(i),p:bigintToBase64url(a),q:bigintToBase64url(o),dp:bigintToBase64url(s),dq:bigintToBase64url(c),qi:bigintToBase64url(l)}}throw Error(`Unsupported key type for JWK export`)}function importJwkRsa(e){if(e.d){let t={n:base64urlToBigint(e.n),e:base64urlToBigint(e.e),d:base64urlToBigint(e.d),p:base64urlToBigint(e.p),q:base64urlToBigint(e.q)};return{parsed:{type:`rsa-private`,components:t},pem:derToPem(encodeRsaPrivateKeyPkcs1(t),`RSA PRIVATE KEY`)}}let t={n:base64urlToBigint(e.n),e:base64urlToBigint(e.e)};return{parsed:{type:`rsa-public`,components:t},pem:derToPem(encodeSubjectPublicKeyInfo(t),`PUBLIC KEY`)}}function generatePem(e,t,n){if(e.type===`rsa-public`)return n===`pkcs1`?derToPem(encodeRsaPublicKeyPkcs1(e.components),`RSA PUBLIC KEY`):derToPem(encodeSubjectPublicKeyInfo(e.components),`PUBLIC KEY`);if(e.type===`rsa-private`&&t===`public`){let t={n:e.components.n,e:e.components.e};return n===`pkcs1`?derToPem(encodeRsaPublicKeyPkcs1(t),`RSA PUBLIC KEY`):derToPem(encodeSubjectPublicKeyInfo(t),`PUBLIC KEY`)}if(e.type===`rsa-private`)return n===`pkcs8`?derToPem(encodePrivateKeyInfo(e.components),`PRIVATE KEY`):derToPem(encodeRsaPrivateKeyPkcs1(e.components),`RSA PRIVATE KEY`);throw Error(`Cannot generate PEM for this key type`)}function generateDer(e,t,n){if(e.type===`rsa-public`)return n===`pkcs1`?q.from(encodeRsaPublicKeyPkcs1(e.components)):q.from(encodeSubjectPublicKeyInfo(e.components));if(e.type===`rsa-private`&&t===`public`){let t={n:e.components.n,e:e.components.e};return n===`pkcs1`?q.from(encodeRsaPublicKeyPkcs1(t)):q.from(encodeSubjectPublicKeyInfo(t))}if(e.type===`rsa-private`)return n===`pkcs8`?q.from(encodePrivateKeyInfo(e.components)):q.from(encodeRsaPrivateKeyPkcs1(e.components));throw Error(`Cannot generate DER for this key type`)}function modInverse(e,t){let[n,r]=[e%t,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}return(i%t+t)%t}function createSecretKey(e,t){let n;return n=typeof e==`string`?q.from(e,t??`utf8`):new Uint8Array(e),new ua(`secret`,n)}function createPublicKey(e){if(e instanceof ua){if(e.type===`public`)return e;if(e.type===`private`){let t=e._handle;if(t.parsed.type===`rsa-private`){let e={n:t.parsed.components.n,e:t.parsed.components.e};return new ua(`public`,{parsed:{type:`rsa-public`,components:e},pem:derToPem(encodeSubjectPublicKeyInfo(e),`PUBLIC KEY`)})}}throw TypeError(`Cannot create public key from secret key`)}if(typeof e==`object`&&!q.isBuffer(e)&&`key`in e){let t=e;if(t.format===`jwk`){let e=t.key;if(e.kty===`RSA`){let{parsed:t,pem:n}=importJwkRsa({n:e.n,e:e.e});return new ua(`public`,{parsed:t,pem:n})}throw Error(`Unsupported JWK key type: ${e.kty}`)}}let t=normalizePem(e),n=parsePemKey(t);if(n.type===`rsa-private`){let e={n:n.components.n,e:n.components.e};return new ua(`public`,{parsed:{type:`rsa-public`,components:e},pem:derToPem(encodeSubjectPublicKeyInfo(e),`PUBLIC KEY`)})}return new ua(`public`,{parsed:n,pem:t})}function createPrivateKey(e){if(typeof e==`object`&&!q.isBuffer(e)&&`key`in e){let t=e;if(t.format===`jwk`){let e=t.key;if(e.kty===`RSA`&&e.d){let{parsed:t,pem:n}=importJwkRsa(e);return new ua(`private`,{parsed:t,pem:n})}throw Error(`JWK does not contain a private key`)}}let t=normalizePem(e),n=parsePemKey(t);if(n.type!==`rsa-private`)throw TypeError(`Key is not a private key`);return new ua(`private`,{parsed:n,pem:t})}function normalizePem(e){if(typeof e==`string`)return e;if(q.isBuffer(e))return e.toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e;if(typeof t.key==`string`)return t.key;if(q.isBuffer(t.key))return t.key.toString(t.encoding??`utf8`);if(t.key instanceof ua)return t.key.export({format:`pem`})}throw TypeError(`Invalid key input`)}var ua,da=__esmMin(()=>{ra(),J(),ua=class KeyObject{type;_handle;constructor(e,t){if(e!==`secret`&&e!==`public`&&e!==`private`)throw TypeError(`Invalid KeyObject type: ${e}`);this.type=e,this._handle=t}get symmetricKeySize(){if(this.type===`secret`)return this._handle.byteLength}get asymmetricKeyType(){if(this.type===`secret`)return;let e=this._handle;if(e.parsed.type===`rsa-public`||e.parsed.type===`rsa-private`)return`rsa`}get asymmetricKeySize(){if(this.type===`secret`)return;let e=this._handle;if(e.parsed.type===`rsa-public`||e.parsed.type===`rsa-private`)return rsaKeySize(e.parsed.components.n)/8}equals(e){if(!(e instanceof KeyObject)||this.type!==e.type)return!1;if(this.type===`secret`){let t=this._handle,n=e._handle;if(t.byteLength!==n.byteLength)return!1;for(let e=0;e<t.byteLength;e++)if(t[e]!==n[e])return!1;return!0}let t=this._handle,n=e._handle;return t.pem===n.pem}export(e){if(this.type===`secret`){let t=this._handle;return e?.format===`jwk`?{kty:`oct`,k:q.from(t).toString(`base64url`)}:q.from(t)}let t=this._handle,n=e?.format??`pem`,r=e?.type;if(n===`jwk`)return exportJwk(t.parsed,this.type);if(n===`pem`)return t.pem&&!t.pem.startsWith(`[`)?t.pem:generatePem(t.parsed,this.type,r);if(n===`der`){if(t.pem&&!t.pem.startsWith(`[`)){let e=t.pem.trim().split(/\r?\n/),n=e.findIndex(e=>e.startsWith(`-----BEGIN `)),r=e.findIndex((e,t)=>t>n&&e.startsWith(`-----END `)),i=e.slice(n+1,r).join(``);return q.from(i,`base64`)}return generateDer(t.parsed,this.type,r)}throw TypeError(`Unsupported export format: ${n}`)}get[Symbol.toStringTag](){return`KeyObject`}}});function formatFingerprint(e){let t=e.toString(`hex`).toUpperCase(),n=[];for(let e=0;e<t.length;e+=2)n.push(t.substring(e,e+2));return n.join(`:`)}function matchHostname(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return!0;if(n.startsWith(`*.`)){let e=n.substring(2),t=r.split(`.`);if(t.length>=2)return t.slice(1).join(`.`)===e}return!1}function parseDNToObject(e){let t={},n=e.split(`, `);for(let e of n){let n=e.indexOf(`=`);n>0&&(t[e.substring(0,n)]=e.substring(n+1))}return t}var X509Certificate,fa=__esmMin(()=>{ra(),da(),ha(),J(),X509Certificate=class{_components;_pem;constructor(e){if(typeof e==`string`)this._pem=e,this._components=parseX509(e);else{let t=q.isBuffer(e)?e:q.from(e),n=t.toString(`utf8`);n.includes(`-----BEGIN CERTIFICATE-----`)?(this._pem=n,this._components=parseX509(n)):(this._components=parseX509Der(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),this._pem=derToPem(this._components.raw,`CERTIFICATE`))}}get raw(){return q.from(this._components.raw)}get serialNumber(){return this._components.serialNumber.toString(16).toUpperCase()}get subject(){return this._components.subject}get issuer(){return this._components.issuer}get validFrom(){return this._components.validFrom.toUTCString()}get validTo(){return this._components.validTo.toUTCString()}get fingerprint(){return formatFingerprint(createHash(`sha1`).update(this._components.raw).digest())}get fingerprint256(){return formatFingerprint(createHash(`sha256`).update(this._components.raw).digest())}get fingerprint512(){return formatFingerprint(createHash(`sha512`).update(this._components.raw).digest())}get publicKey(){if(!this._components.publicKey)throw Error(`Certificate does not contain a supported public key type`);let e=derToPem(encodeSubjectPublicKeyInfo(this._components.publicKey),`PUBLIC KEY`);return new ua(`public`,{parsed:{type:`rsa-public`,components:this._components.publicKey},pem:e})}get subjectAltName(){if(!(!this._components.subjectAltName||this._components.subjectAltName.length===0))return this._components.subjectAltName.join(`, `)}get keyUsage(){}get infoAccess(){}get ca(){return!1}checkHost(e){let t=this._components.subject.match(/CN=([^,]+)/);if(t){let n=t[1].trim();if(matchHostname(n,e))return n}if(this._components.subjectAltName){for(let t of this._components.subjectAltName)if(t.startsWith(`DNS:`)){let n=t.substring(4);if(matchHostname(n,e))return n}}}checkEmail(e){let t=e.toLowerCase(),n=this._components.subject.match(/emailAddress=([^,]+)/);if(n&&n[1].toLowerCase()===t)return n[1]}checkIP(e){if(this._components.subjectAltName){for(let t of this._components.subjectAltName)if(t.startsWith(`IP Address:`)&&t.substring(11)===e)return e}}verify(e){return!0}checkIssued(e){return this.issuer===e.subject}toLegacyObject(){return{subject:parseDNToObject(this._components.subject),issuer:parseDNToObject(this._components.issuer),valid_from:this.validFrom,valid_to:this.validTo,serialNumber:this.serialNumber,fingerprint:this.fingerprint,fingerprint256:this.fingerprint256}}toString(){return this._pem}toJSON(){return this._pem}get[Symbol.toStringTag](){return`X509Certificate`}}}),pa=__exportAll$4({DiffieHellman:()=>DiffieHellman,DiffieHellmanGroup:()=>Ii,Hash:()=>Ki,Hmac:()=>Hmac,KeyObject:()=>ua,Sign:()=>Sign,Verify:()=>Verify,X509Certificate:()=>X509Certificate,constants:()=>Ei,createCipher:()=>createCipher,createCipheriv:()=>createCipheriv,createDecipher:()=>createDecipher,createDecipheriv:()=>createDecipheriv,createDiffieHellman:()=>createDiffieHellman,createDiffieHellmanGroup:()=>Fi,createECDH:()=>createECDH,createHash:()=>createHash,createHmac:()=>createHmac,createPrivateKey:()=>createPrivateKey,createPublicKey:()=>createPublicKey,createSecretKey:()=>createSecretKey,createSign:()=>createSign,createVerify:()=>createVerify,default:()=>ma,ecdsaSign:()=>ecdsaSign,ecdsaVerify:()=>ecdsaVerify,getCiphers:()=>getCiphers,getCurves:()=>getCurves,getDiffieHellman:()=>getDiffieHellman,getHashes:()=>getHashes,hash:()=>hash,hkdf:()=>hkdf,hkdfSync:()=>hkdfSync,mgf1:()=>mgf1,pbkdf2:()=>pbkdf2,pbkdf2Sync:()=>pbkdf2Sync,privateDecrypt:()=>privateDecrypt,privateEncrypt:()=>privateEncrypt,publicDecrypt:()=>publicDecrypt,publicEncrypt:()=>publicEncrypt,randomBytes:()=>randomBytes,randomFill:()=>randomFill,randomFillSync:()=>randomFillSync,randomInt:()=>randomInt,randomUUID:()=>randomUUID,rsaOaepDecrypt:()=>rsaOaepDecrypt,rsaOaepEncrypt:()=>rsaOaepEncrypt,rsaPssSign:()=>rsaPssSign,rsaPssVerify:()=>rsaPssVerify,scrypt:()=>scrypt,scryptSync:()=>scryptSync,timingSafeEqual:()=>timingSafeEqual});function createHash(e){return new Ki(e)}function createHmac(e,t){return new Hmac(e,t)}var ma,ha=__esmMin(()=>{Ti(),Di(),ki(),Li(),Bi(),qi(),Ji(),Yi(),Xi(),Zi(),Qi(),$i(),aa(),oa(),sa(),ca(),la(),da(),fa(),ma={Hash:Ki,getHashes,hash,Hmac,randomBytes,randomFill,randomFillSync,randomUUID,randomInt,timingSafeEqual,constants:Ei,pbkdf2,pbkdf2Sync,hkdf,hkdfSync,scrypt,scryptSync,createHash,createHmac,createCipher,createCipheriv,createDecipher,createDecipheriv,getCiphers,Sign,Verify,createSign,createVerify,createDiffieHellman,getDiffieHellman,DiffieHellman,DiffieHellmanGroup:Ii,createDiffieHellmanGroup:Fi,createECDH,getCurves,ecdsaSign,ecdsaVerify,publicEncrypt,privateDecrypt,privateEncrypt,publicDecrypt,rsaPssSign,rsaPssVerify,rsaOaepEncrypt,rsaOaepDecrypt,mgf1,KeyObject:ua,createSecretKey,createPublicKey,createPrivateKey,X509Certificate}});let ga=!1,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma;async function loadCrypto(){if(ga)return;let e=await Promise.resolve().then(()=>(ha(),pa));_a=e.createHash,va=e.createHmac,ya=e.createCipheriv,ba=e.createDecipheriv,xa=e.createSign,Sa=e.createVerify,Ca=e.pbkdf2Sync,wa=e.hkdfSync,Ta=e.createECDH,Ea=e.randomBytes,e.publicEncrypt,e.privateDecrypt,e.createPublicKey,e.createPrivateKey,Da=e.ecdsaSign,Oa=e.ecdsaVerify,ka=e.rsaPssSign,Aa=e.rsaPssVerify,ja=e.rsaOaepEncrypt,Ma=e.rsaOaepDecrypt,ga=!0}const Na=loadCrypto();var SubtleCrypto=class{async digest(e,t){await Na;let n=toNodeHashName(normalizeAlgorithm$1(e).name),r=toUint8Array(t),i=_a(n);i.update(r);let a=i.digest();return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}async generateKey(e,t,n){await Na;let r=normalizeAlgorithm$1(e);switch(r.name.toUpperCase()){case`AES-CBC`:case`AES-CTR`:case`AES-GCM`:{let i=e.length;if(![128,192,256].includes(i))throw new DOMException(`Invalid AES key length: ${i}`,`OperationError`);validateUsages(n,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]);let a=Ea(i/8);return new CryptoKey(`secret`,t,{name:r.name,length:i},n,new Uint8Array(a))}case`HMAC`:{let r=e,i=normalizeAlgorithm$1(r.hash),a=r.length||hashSize$1(i.name)*8;validateUsages(n,[`sign`,`verify`]);let o=Ea(Math.ceil(a/8));return new CryptoKey(`secret`,t,{name:`HMAC`,hash:{name:i.name},length:a},n,new Uint8Array(o))}case`ECDH`:{let r=e.namedCurve,i=toNodeCurveName(r);validateUsages(n,[`deriveKey`,`deriveBits`]);let a=Ta(i);a.generateKeys();let o=new Uint8Array(a.getPublicKey()),s=new Uint8Array(a.getPrivateKey());return{publicKey:new CryptoKey(`public`,!0,{name:`ECDH`,namedCurve:r},[],o),privateKey:new CryptoKey(`private`,t,{name:`ECDH`,namedCurve:r},n,{pub:o,priv:s})}}case`ECDSA`:{let r=e.namedCurve,i=toNodeCurveName(r);validateUsages(n,[`sign`,`verify`]);let a=Ta(i);a.generateKeys();let o=new Uint8Array(a.getPublicKey()),s=new Uint8Array(a.getPrivateKey());return{publicKey:new CryptoKey(`public`,!0,{name:`ECDSA`,namedCurve:r},[`verify`],o),privateKey:new CryptoKey(`private`,t,{name:`ECDSA`,namedCurve:r},[`sign`],{pub:o,priv:s})}}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async importKey(e,t,n,r,i){await Na;let a=normalizeAlgorithm$1(n),o=a.name.toUpperCase();switch(o){case`AES-CBC`:case`AES-CTR`:case`AES-GCM`:if(e===`raw`){let e=toUint8Array(t);if(![16,24,32].includes(e.length))throw new DOMException(`Invalid AES key length: ${e.length*8}`,`DataError`);return validateUsages(i,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:a.name,length:e.length*8},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);let n=base64urlDecode(e.k);if(![16,24,32].includes(n.length))throw new DOMException(`Invalid AES key length: ${n.length*8}`,`DataError`);return validateUsages(i,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:a.name,length:n.length*8},i,n)}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`HMAC`:{let a=normalizeAlgorithm$1(n.hash);if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`sign`,`verify`]),new CryptoKey(`secret`,r,{name:`HMAC`,hash:{name:a.name},length:e.length*8},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);let n=base64urlDecode(e.k);return validateUsages(i,[`sign`,`verify`]),new CryptoKey(`secret`,r,{name:`HMAC`,hash:{name:a.name},length:n.length*8},i,n)}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`)}case`PBKDF2`:if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`deriveKey`,`deriveBits`]),new CryptoKey(`secret`,!1,{name:`PBKDF2`},i,new Uint8Array(e))}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`HKDF`:if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`deriveKey`,`deriveBits`]),new CryptoKey(`secret`,!1,{name:`HKDF`},i,new Uint8Array(e))}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`ECDH`:case`ECDSA`:{let s=n.namedCurve;if(e===`raw`){let e=toUint8Array(t);return o===`ECDH`?i.length>0&&validateUsages(i,[`deriveKey`,`deriveBits`]):validateUsages(i,[`verify`]),new CryptoKey(`public`,r,{name:a.name,namedCurve:s},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`EC`)throw new DOMException(`JWK kty must be "EC"`,`DataError`);if(e.d){let t=base64urlDecode(e.d),n=base64urlDecode(e.x),c=base64urlDecode(e.y),l=new Uint8Array(1+n.length+c.length);return l[0]=4,l.set(n,1),l.set(c,1+n.length),validateUsages(i,o===`ECDH`?[`deriveKey`,`deriveBits`]:[`sign`]),new CryptoKey(`private`,r,{name:a.name,namedCurve:s},i,{pub:l,priv:t})}else{let t=base64urlDecode(e.x),n=base64urlDecode(e.y),c=new Uint8Array(1+t.length+n.length);return c[0]=4,c.set(t,1),c.set(n,1+t.length),o===`ECDH`?i.length>0&&validateUsages(i,[`deriveKey`,`deriveBits`]):validateUsages(i,[`verify`]),new CryptoKey(`public`,r,{name:a.name,namedCurve:s},i,c)}}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`)}default:throw new DOMException(`Unsupported algorithm: ${a.name}`,`NotSupportedError`)}}async exportKey(e,t){if(!t.extractable)throw new DOMException(`Key is not extractable`,`InvalidAccessError`);let n=t.algorithm.name.toUpperCase();if(e===`raw`){if(t.type===`secret`){let e=t._handle;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(t.type===`public`&&(n===`ECDH`||n===`ECDSA`)){let e=t._handle;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}throw new DOMException(`Cannot export in raw format`,`InvalidAccessError`)}if(e===`jwk`){if(t.type===`secret`){let e=t._handle,r={kty:`oct`,k:base64urlEncode(e),ext:t.extractable,key_ops:[...t.usages]};return n.startsWith(`AES-`)?r.alg=`A${t.algorithm.length}${n.replace(`AES-`,``)}`:n===`HMAC`&&(r.alg=`HS${t.algorithm.hash.name.replace(`SHA-`,``)}`),r}if((n===`ECDH`||n===`ECDSA`)&&(t.type===`public`||t.type===`private`)){let e=t.algorithm.namedCurve,n;n=t.type===`public`?t._handle:t._handle.pub;let r=(n.length-1)/2,i=n.slice(1,1+r),a=n.slice(1+r),o={kty:`EC`,crv:e,x:base64urlEncode(i),y:base64urlEncode(a),ext:t.extractable,key_ops:[...t.usages]};return t.type===`private`&&(o.d=base64urlEncode(t._handle.priv)),o}throw new DOMException(`JWK export not supported for ${n} ${t.type}`,`NotSupportedError`)}throw new DOMException(`Unsupported export format: ${e}`,`NotSupportedError`)}async encrypt(e,t,n){await Na,checkUsage(t,`encrypt`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`AES-CBC`:{let n=toUint8Array(e.iv),r=t._handle,i=r.length*8,o=ya(`aes-${i}-cbc`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-CTR`:{let n=toUint8Array(e.counter),r=t._handle,i=r.length*8,o=ya(`aes-${i}-ctr`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-GCM`:{let n=e,r=toUint8Array(n.iv),i=n.additionalData?toUint8Array(n.additionalData):void 0,o=t._handle,s=o.length*8,c=ya(`aes-${s}-gcm`,o,r);i&&c.setAAD(i);let l=c.update(a),u=c.final(),d=c.getAuthTag(),p=new Uint8Array(l.length+u.length+d.length);return p.set(new Uint8Array(l),0),p.set(new Uint8Array(u),l.length),p.set(new Uint8Array(d),l.length+u.length),p.buffer}case`RSA-OAEP`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e,s=o.label?toUint8Array(o.label):void 0,c=ja(r,i.pem,a,s);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async decrypt(e,t,n){await Na,checkUsage(t,`decrypt`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`AES-CBC`:{let n=toUint8Array(e.iv),r=t._handle,i=r.length*8,o=ba(`aes-${i}-cbc`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-CTR`:{let n=toUint8Array(e.counter),r=t._handle,i=r.length*8,o=ba(`aes-${i}-ctr`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-GCM`:{let n=e,r=toUint8Array(n.iv),i=(n.tagLength||128)/8,o=n.additionalData?toUint8Array(n.additionalData):void 0,s=t._handle,c=s.length*8,l=a.slice(0,a.length-i),u=a.slice(a.length-i),d=ba(`aes-${c}-gcm`,s,r);d.setAuthTag(u),o&&d.setAAD(o);let p=d.update(l),m=d.final(),h=new Uint8Array(p.length+m.length);return h.set(new Uint8Array(p),0),h.set(new Uint8Array(m),p.length),h.buffer}case`RSA-OAEP`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e,s=o.label?toUint8Array(o.label):void 0,c=Ma(r,i.pem,a,s);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async sign(e,t,n){await Na,checkUsage(t,`sign`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`HMAC`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=va(n,r);i.update(a);let o=i.digest();return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}case`RSASSA-PKCS1-V1_5`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=xa(n);i.update(a);let o=i.sign(r.pem);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}case`ECDSA`:{let n=e,r=toNodeHashName(typeof n.hash==`string`?n.hash:n.hash.name),i=t.algorithm.namedCurve,o=t._handle,s=Da(r,o.priv,a,i);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}case`RSA-PSS`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e.saltLength??hashSize$1(n),s=ka(r,i.pem,a,o);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async verify(e,t,n,r){await Na,checkUsage(t,`verify`);let i=normalizeAlgorithm$1(e),a=i.name.toUpperCase(),o=toUint8Array(r),s=toUint8Array(n);switch(a){case`HMAC`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=va(n,r);i.update(o);let a=new Uint8Array(i.digest());if(a.length!==s.length)return!1;let c=0;for(let e=0;e<a.length;e++)c|=a[e]^s[e];return c===0}case`RSASSA-PKCS1-V1_5`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=Sa(n);return i.update(o),i.verify(r.pem,s)}case`ECDSA`:{let n=e,r=toNodeHashName(typeof n.hash==`string`?n.hash:n.hash.name),i=t.algorithm.namedCurve,a=t._handle;return Oa(r,a,s,o,i)}case`RSA-PSS`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,a=e.saltLength??hashSize$1(n);return Aa(r,i.pem,s,o,a)}default:throw new DOMException(`Unsupported algorithm: ${i.name}`,`NotSupportedError`)}}async _deriveBitsInternal(e,t,n){await Na;let r=normalizeAlgorithm$1(e);switch(r.name.toUpperCase()){case`PBKDF2`:{let r=e,i=toNodeHashName(normalizeAlgorithm$1(r.hash).name),a=toUint8Array(r.salt),o=r.iterations,s=t._handle,c=Ca(s,a,o,n/8,i);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}case`HKDF`:{let r=e,i=toNodeHashName(normalizeAlgorithm$1(r.hash).name),a=toUint8Array(r.salt),o=toUint8Array(r.info),s=t._handle;return wa(i,s,a,o,n/8)}case`ECDH`:{let r=e.public,i=t.algorithm.namedCurve,a=toNodeCurveName(i),o=Ta(a),s=t._handle;o.setPrivateKey(s.priv);let c=r._handle instanceof Uint8Array?r._handle:r._handle.pub,l=o.computeSecret(c),u=new Uint8Array(l);return n?u.buffer.slice(0,n/8):u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async deriveBits(e,t,n){return checkUsage(t,`deriveBits`),this._deriveBitsInternal(e,t,n)}async deriveKey(e,t,n,r,i){checkUsage(t,`deriveKey`);let a=normalizeAlgorithm$1(n),o,s=a.name.toUpperCase();if(s===`AES-CBC`||s===`AES-CTR`||s===`AES-GCM`)o=n.length;else if(s===`HMAC`){let e=n,t=normalizeAlgorithm$1(e.hash);o=e.length||hashSize$1(t.name)*8}else throw new DOMException(`Unsupported derived key algorithm: ${a.name}`,`NotSupportedError`);let c=await this._deriveBitsInternal(e,t,o);return this.importKey(`raw`,c,n,r,i)}async wrapKey(e,t,n,r){throw new DOMException(`wrapKey not yet implemented`,`NotSupportedError`)}async unwrapKey(e,t,n,r,i,a,o){throw new DOMException(`unwrapKey not yet implemented`,`NotSupportedError`)}};const Pa=globalThis.crypto===void 0?null:globalThis.crypto;var CryptoPolyfill=class{subtle=new SubtleCrypto;getRandomValues(e){if(!(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigInt64Array||e instanceof BigUint64Array))throw new DOMException(`The provided value is not of type '(Int8Array or Int16Array or Int32Array or Uint8Array or Uint8ClampedArray or Uint16Array or Uint32Array or BigInt64Array or BigUint64Array)'`,`TypeMismatchError`);if(e.byteLength>65536)throw new DOMException(`The ArrayBufferView's byte length exceeds the number of bytes of entropy available via this API (65536)`,`QuotaExceededError`);let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Pa&&typeof Pa.getRandomValues==`function`)Pa.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return e}randomUUID(){if(Pa&&typeof Pa.randomUUID==`function`)return Pa.randomUUID();let e=new Uint8Array(16);this.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}};const Fa=Pa!==null&&Pa.subtle!==void 0&&typeof Pa.subtle.digest==`function`,Ia=Fa?Pa:new CryptoPolyfill;Fa?Pa.subtle:new SubtleCrypto;const La=globalThis;(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)&&(La.crypto=Ia);const Ra=typeof process<`u`&&typeof process.versions?.gjs==`string`,za=typeof process<`u`&&typeof process.versions?.node==`string`,Ba=Ra?`GJS`:za?`Node.js`:`Unknown`;Ra?process.versions.gjs:za&&process.versions.node;var Va,Ha,Ua=__esmMin(()=>{Va=Object.defineProperty,Ha=__name((e,t)=>{let n={};for(var r in e)Va(n,r,{get:e[r],enumerable:!0});return t||Va(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function assertPath(e){if(typeof e!=`string`)throw TypeError(`The "path" argument must be of type string. Received type `+typeof e)}function isPosixPathSeparator(e){return e===47}function isPathSeparator(e){return e===47||e===92}function isWindowsDeviceRoot(e){return e>=65&&e<=90||e>=97&&e<=122}function normalizeString(e,t,n,r){let i=``,a=0,o=-1,s=0,c;for(let l=0;l<=e.length;++l){if(l<e.length)c=e.charCodeAt(l);else if(r(c))break;else c=47;if(r(c)){if(!(o===l-1||s===1))if(o!==l-1&&s===2){if(i.length<2||a!==2||i.charCodeAt(i.length-1)!==46||i.charCodeAt(i.length-2)!==46){if(i.length>2){let e=i.lastIndexOf(n);e===-1?(i=``,a=0):(i=i.slice(0,e),a=i.length-1-i.lastIndexOf(n)),o=l,s=0;continue}else if(i.length===2||i.length===1){i=``,a=0,o=l,s=0;continue}}t&&(i.length>0?i+=`${n}..`:i=`..`,a=2)}else i.length>0?i+=n+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else c===46&&s!==-1?++s:s=-1}return i}function _format(e,t){if(typeof t!=`object`||!t)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof t);let n=t.dir||t.root,r=t.base||(t.name||``)+formatExt(t.ext);return n?n===t.root?n+r:n+e+r:r}function formatExt(e){return e?`${e[0]===`.`?``:`.`}${e}`:``}var Wa=__esmMin(()=>{});function posixCwd(){if(typeof globalThis.process?.cwd==`function`)return globalThis.process.cwd();try{let e=globalThis.imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function resolve$1(...e){let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i;if(r>=0){if(i=e[r],assertPath(i),i.length===0)continue}else i=posixCwd();t=`${i}/${t}`,n=i.charCodeAt(0)===47}return t=normalizeString(t,!n,`/`,isPosixPathSeparator),n?t.length>0?`/${t}`:`/`:t.length>0?t:`.`}function normalize$1(e){if(assertPath(e),e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=normalizeString(e,!t,`/`,isPosixPathSeparator);return r.length===0&&!t&&(r=`.`),r.length>0&&n&&(r+=`/`),t?`/${r}`:r}function isAbsolute$1(e){return assertPath(e),e.length>0&&e.charCodeAt(0)===47}function join$1(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];assertPath(r),r.length>0&&(t===void 0?t=r:t+=`/${r}`)}return t===void 0?`.`:normalize$1(t)}function relative$1(e,t){if(assertPath(e),assertPath(t),e===t||(e=resolve$1(e),t=resolve$1(t),e===t))return``;let n=e.length,r=n-1,i=1,a=t.length-i,o=r<a?r:a,s=-1,c=0;for(;c<=o;++c){if(c===o){if(a>o){if(t.charCodeAt(i+c)===47)return t.slice(i+c+1);if(c===0)return t.slice(i+c)}else r>o&&(e.charCodeAt(1+c)===47?s=c:c===0&&(s=0));break}let n=e.charCodeAt(1+c);if(n!==t.charCodeAt(i+c))break;n===47&&(s=c)}let l=``;for(c=1+s+1;c<=n;++c)(c===n||e.charCodeAt(c)===47)&&(l.length===0?l+=`..`:l+=`/..`);return l.length>0?l+t.slice(i+s):(i+=s,t.charCodeAt(i)===47&&++i,t.slice(i))}function toNamespacedPath$1(e){return e}function dirname$1(e){if(assertPath(e),e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function basename$1(e,t){t!==void 0&&assertPath(t),assertPath(e);let n=0,r=-1,i=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}else{for(let t=e.length-1;t>=0;--t)if(e.charCodeAt(t)===47){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}}function extname$1(e){assertPath(e);let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function format$2(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return _format(`/`,e)}function parse$2(e){assertPath(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0)===47,r;n?(t.root=`/`,r=1):r=0;let i=-1,a=0,o=-1,s=!0,c=e.length-1,l=0;for(;c>=r;--c){let t=e.charCodeAt(c);if(t===47){if(!s){a=c+1;break}continue}o===-1&&(s=!1,o=c+1),t===46?i===-1?i=c:l!==1&&(l=1):i!==-1&&(l=-1)}return i===-1||o===-1||l===0||l===1&&i===o-1&&i===a+1?o!==-1&&(a===0&&n?t.base=t.name=e.slice(1,o):t.base=t.name=e.slice(a,o)):(a===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,o)):(t.name=e.slice(a,i),t.base=e.slice(a,o)),t.ext=e.slice(i,o)),a>0?t.dir=e.slice(0,a-1):n&&(t.dir=`/`),t}var Ga,Ka=__esmMin(()=>{Ua(),Wa(),Ga=Ha({basename:()=>basename$1,delimiter:()=>`:`,dirname:()=>dirname$1,extname:()=>extname$1,format:()=>format$2,isAbsolute:()=>isAbsolute$1,join:()=>join$1,normalize:()=>normalize$1,parse:()=>parse$2,relative:()=>relative$1,resolve:()=>resolve$1,sep:()=>`/`,toNamespacedPath:()=>toNamespacedPath$1}),__name(resolve$1,`resolve`),__name(normalize$1,`normalize`),__name(isAbsolute$1,`isAbsolute`),__name(join$1,`join`),__name(relative$1,`relative`),__name(toNamespacedPath$1,`toNamespacedPath`),__name(dirname$1,`dirname`),__name(basename$1,`basename`),__name(extname$1,`extname`),__name(format$2,`format`),__name(parse$2,`parse`)});function resolve(...e){let t=``,n=``,r=!1;for(let i=e.length-1;i>=-1;i--){let a;if(i>=0){if(a=e[i],assertPath(a),a.length===0)continue}else a=(t.length,typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():`/`);let o=a.length,s=0,c=``,l=!1,u=a.charCodeAt(0);if(o>1)if(isPathSeparator(u))if(l=!0,isPathSeparator(a.charCodeAt(1))){let e=2,t=e;for(;e<o&&!isPathSeparator(a.charCodeAt(e));++e);if(e<o&&e!==t){let n=a.slice(t,e);for(t=e;e<o&&isPathSeparator(a.charCodeAt(e));++e);if(e<o&&e!==t){for(t=e;e<o&&!isPathSeparator(a.charCodeAt(e));++e);e===o?(c=`\\\\${n}\\${a.slice(t)}`,s=e):e!==t&&(c=`\\\\${n}\\${a.slice(t,e)}`,s=e)}}}else s=1;else isWindowsDeviceRoot(u)&&a.charCodeAt(1)===58&&(c=a.slice(0,2),s=2,o>2&&isPathSeparator(a.charCodeAt(2))&&(l=!0,s=3));else isPathSeparator(u)&&(s=1,l=!0);if(!(c.length>0&&t.length>0&&c.toLowerCase()!==t.toLowerCase())&&(t.length===0&&c.length>0&&(t=c),r||=(n=`${a.slice(s)}\\${n}`,l),t.length>0&&r))break}return n=normalizeString(n,!r,`\\`,isPathSeparator),t+(r?`\\`:``)+n||`.`}function normalize(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=0,r,i=!1,a=e.charCodeAt(0);if(t>1)if(isPathSeparator(a))if(i=!0,isPathSeparator(e.charCodeAt(1))){let i=2,a=i;for(;i<t&&!isPathSeparator(e.charCodeAt(i));++i);if(i<t&&i!==a){let o=e.slice(a,i);for(a=i;i<t&&isPathSeparator(e.charCodeAt(i));++i);if(i<t&&i!==a){for(a=i;i<t&&!isPathSeparator(e.charCodeAt(i));++i);if(i===t)return`\\\\${o}\\${e.slice(a)}\\`;i!==a&&(r=`\\\\${o}\\${e.slice(a,i)}`,n=i)}}}else n=1;else isWindowsDeviceRoot(a)&&e.charCodeAt(1)===58&&(r=e.slice(0,2),n=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(i=!0,n=3));else if(isPathSeparator(a))return`\\`;let o;return o=n<t?normalizeString(e.slice(n),!i,`\\`,isPathSeparator):``,o.length===0&&!i&&(o=`.`),o.length>0&&isPathSeparator(e.charCodeAt(t-1))&&(o+=`\\`),r===void 0?i?o.length>0?`\\${o}`:`\\`:o.length>0?o:``:i?o.length>0?`${r}\\${o}`:`${r}\\`:o.length>0?r+o:r}function isAbsolute(e){assertPath(e);let t=e.length;if(t===0)return!1;let n=e.charCodeAt(0);return!!(isPathSeparator(n)||isWindowsDeviceRoot(n)&&t>2&&e.charCodeAt(1)===58&&isPathSeparator(e.charCodeAt(2)))}function join(...e){if(e.length===0)return`.`;let t,n;for(let r=0;r<e.length;++r){let i=e[r];assertPath(i),i.length>0&&(t===void 0?t=n=i:t+=`\\${i}`)}if(t===void 0)return`.`;let r=!0,i=0;if(isPathSeparator(n.charCodeAt(0))){++i;let e=n.length;e>1&&isPathSeparator(n.charCodeAt(1))&&(++i,e>2&&(isPathSeparator(n.charCodeAt(2))?++i:r=!1))}if(r){for(;i<t.length&&isPathSeparator(t.charCodeAt(i));++i);i>=2&&(t=`\\${t.slice(i)}`)}return normalize(t)}function relative(e,t){if(assertPath(e),assertPath(t),e===t)return``;let n=resolve(e),r=resolve(t);if(n===r||(e=n.toLowerCase(),t=r.toLowerCase(),e===t))return``;let i=0;for(;i<e.length&&e.charCodeAt(i)===92;++i);let a=e.length;for(;a-1>i&&e.charCodeAt(a-1)===92;--a);let o=a-i,s=0;for(;s<t.length&&t.charCodeAt(s)===92;++s);let c=t.length;for(;c-1>s&&t.charCodeAt(c-1)===92;--c);let l=c-s,u=o<l?o:l,d=-1,p=0;for(;p<=u;++p){if(p===u){if(l>u){if(t.charCodeAt(s+p)===92)return r.slice(s+p+1);if(p===2)return r.slice(s+p)}o>u&&(e.charCodeAt(i+p)===92?d=p:p===2&&(d=3));break}let n=e.charCodeAt(i+p);if(n!==t.charCodeAt(s+p))break;n===92&&(d=p)}if(p!==u&&d===-1)return r;let m=``;for(d===-1&&(d=0),p=i+d+1;p<=a;++p)(p===a||e.charCodeAt(p)===92)&&(m.length===0?m+=`..`:m+=`\\..`);return m.length>0?m+r.slice(s+d,c):(s+=d,r.charCodeAt(s)===92&&++s,r.slice(s,c))}function toNamespacedPath(e){if(typeof e!=`string`)return e;if(e.length===0)return``;let t=resolve(e);if(t.length>=3){if(t.charCodeAt(0)===92){if(t.charCodeAt(1)===92){let e=t.charCodeAt(2);if(e!==63&&e!==46)return`\\\\?\\UNC\\${t.slice(2)}`}}else if(isWindowsDeviceRoot(t.charCodeAt(0))&&t.charCodeAt(1)===58&&t.charCodeAt(2)===92)return`\\\\?\\${t}`}return e}function dirname(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=-1,r=-1,i=!0,a=0,o=e.charCodeAt(0);if(t>1)if(isPathSeparator(o)){if(n=a=1,isPathSeparator(e.charCodeAt(1))){let r=2,i=r;for(;r<t&&!isPathSeparator(e.charCodeAt(r));++r);if(r<t&&r!==i){for(i=r;r<t&&isPathSeparator(e.charCodeAt(r));++r);if(r<t&&r!==i){for(i=r;r<t&&!isPathSeparator(e.charCodeAt(r));++r);if(r===t)return e;r!==i&&(n=a=r+1)}}}}else isWindowsDeviceRoot(o)&&e.charCodeAt(1)===58&&(n=a=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(n=a=3));else if(isPathSeparator(o))return e;for(let n=t-1;n>=a;--n)if(isPathSeparator(e.charCodeAt(n))){if(!i){r=n;break}}else i=!1;if(r===-1){if(n===-1)return`.`;r=n}return e.slice(0,r)}function basename(e,t){t!==void 0&&assertPath(t),assertPath(e);let n=0,r=-1,i=!0;if(e.length>=2&&isWindowsDeviceRoot(e.charCodeAt(0))&&e.charCodeAt(1)===58&&(n=2),t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=n;--s){let c=e.charCodeAt(s);if(isPathSeparator(c)){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}else{for(let t=e.length-1;t>=n;--t)if(isPathSeparator(e.charCodeAt(t))){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}}function extname(e){assertPath(e);let t=0,n=-1,r=0,i=-1,a=!0,o=0;e.length>=2&&e.charCodeAt(1)===58&&isWindowsDeviceRoot(e.charCodeAt(0))&&(t=r=2);for(let s=e.length-1;s>=t;--s){let t=e.charCodeAt(s);if(isPathSeparator(t)){if(!a){r=s+1;break}continue}i===-1&&(a=!1,i=s+1),t===46?n===-1?n=s:o!==1&&(o=1):n!==-1&&(o=-1)}return n===-1||i===-1||o===0||o===1&&n===i-1&&n===r+1?``:e.slice(n,i)}function format$1(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return _format(`\\`,e)}function parse$1(e){assertPath(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.length,r=0,i=e.charCodeAt(0);if(n>1)if(isPathSeparator(i)){if(r=1,isPathSeparator(e.charCodeAt(1))){let t=2,i=t;for(;t<n&&!isPathSeparator(e.charCodeAt(t));++t);if(t<n&&t!==i){for(i=t;t<n&&isPathSeparator(e.charCodeAt(t));++t);if(t<n&&t!==i){for(i=t;t<n&&!isPathSeparator(e.charCodeAt(t));++t);t===n?r=t:t!==i&&(r=t+1)}}}}else isWindowsDeviceRoot(i)&&e.charCodeAt(1)===58&&(r=2,n>2&&isPathSeparator(e.charCodeAt(2))&&(r=3));else if(isPathSeparator(i))return t.root=t.dir=e,t;r>0&&(t.root=e.slice(0,r));let a=-1,o=r,s=-1,c=!0,l=e.length-1,u=0;for(;l>=r;--l){if(i=e.charCodeAt(l),isPathSeparator(i)){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),i===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(t.base=t.name=e.slice(o,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s),t.ext=e.slice(a,s)),o>0&&o!==r?t.dir=e.slice(0,o-1):t.dir=t.root,t}var qa,Ja=__esmMin(()=>{Ua(),Wa(),qa=Ha({basename:()=>basename,delimiter:()=>`;`,dirname:()=>dirname,extname:()=>extname,format:()=>format$1,isAbsolute:()=>isAbsolute,join:()=>join,normalize:()=>normalize,parse:()=>parse$1,relative:()=>relative,resolve:()=>resolve,sep:()=>`\\`,toNamespacedPath:()=>toNamespacedPath}),__name(format$1,`format`),__name(parse$1,`parse`)}),Ya=__exportAll$4({basename:()=>ro,default:()=>lo,delimiter:()=>co,dirname:()=>no,extname:()=>io,format:()=>ao,isAbsolute:()=>Qa,join:()=>$a,normalize:()=>Za,parse:()=>oo,posix:()=>Ga,relative:()=>eo,resolve:()=>Xa,sep:()=>so,toNamespacedPath:()=>to,win32:()=>qa}),Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo=__esmMin(()=>{Ka(),Ja(),{resolve:Xa,normalize:Za,isAbsolute:Qa,join:$a,relative:eo,toNamespacedPath:to,dirname:no,basename:ro,extname:io,format:ao,parse:oo,sep:so,delimiter:co}=Ga,lo={resolve:resolve$1,normalize:normalize$1,isAbsolute:isAbsolute$1,join:join$1,relative:relative$1,toNamespacedPath:toNamespacedPath$1,dirname:dirname$1,basename:basename$1,extname:extname$1,format:format$2,parse:parse$2,sep:`/`,delimiter:`:`,posix:Ga,win32:qa}}),fo=__commonJSMin(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return parse(e);if(n===`number`&&isFinite(e))return t.long?fmtLong(e):fmtShort(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function parse(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function fmtShort(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function fmtLong(e){var t=Math.abs(e);return t>=a?plural(e,t,a,`day`):t>=i?plural(e,t,i,`hour`):t>=r?plural(e,t,r,`minute`):t>=n?plural(e,t,n,`second`):e+` ms`}function plural(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),po=__commonJSMin(((e,t)=>{I();function setup(e){createDebug.debug=createDebug,createDebug.default=createDebug,createDebug.coerce=coerce,createDebug.disable=disable,createDebug.enable=enable,createDebug.enabled=enabled,createDebug.humanize=fo(),createDebug.destroy=destroy,Object.keys(e).forEach(t=>{createDebug[t]=e[t]}),createDebug.names=[],createDebug.skips=[],createDebug.formatters={};function selectColor(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return createDebug.colors[Math.abs(t)%createDebug.colors.length]}createDebug.selectColor=selectColor;function createDebug(e){let t,n=null,r,i;function debug(...e){if(!debug.enabled)return;let n=debug,r=Number(new Date);n.diff=r-(t||r),n.prev=t,n.curr=r,t=r,e[0]=createDebug.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if(t===`%%`)return`%`;i++;let a=createDebug.formatters[r];if(typeof a==`function`){let r=e[i];t=a.call(n,r),e.splice(i,1),i--}return t}),createDebug.formatArgs.call(n,e),(n.log||createDebug.log).apply(n,e)}return debug.namespace=e,debug.useColors=createDebug.useColors(),debug.color=createDebug.selectColor(e),debug.extend=extend,debug.destroy=createDebug.destroy,Object.defineProperty(debug,"enabled",{enumerable:!0,configurable:!1,get:()=>n===null?(r!==createDebug.namespaces&&(r=createDebug.namespaces,i=createDebug.enabled(e)),i):n,set:e=>{n=e}}),typeof createDebug.init==`function`&&createDebug.init(debug),debug}function extend(e,t){let n=createDebug(this.namespace+(t===void 0?`:`:t)+e);return n.log=this.log,n}function enable(e){createDebug.save(e),createDebug.namespaces=e,createDebug.names=[],createDebug.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?createDebug.skips.push(e.slice(1)):createDebug.names.push(e)}function matchesTemplate(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function disable(){let e=[...createDebug.names,...createDebug.skips.map(e=>`-`+e)].join(`,`);return createDebug.enable(``),e}function enabled(e){for(let t of createDebug.skips)if(matchesTemplate(e,t))return!1;for(let t of createDebug.names)if(matchesTemplate(e,t))return!0;return!1}function coerce(e){return e instanceof Error?e.stack||e.message:e}function destroy(){F.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return createDebug.enable(createDebug.load()),createDebug}t.exports=setup})),mo=__commonJSMin(((e,t)=>{I(),e.formatArgs=formatArgs,e.save=save,e.load=load,e.useColors=useColors,e.storage=localstorage(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,F.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function useColors(){if(typeof globalThis<`u`&&globalThis.process&&(globalThis.process.type===`renderer`||globalThis.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof globalThis<`u`&&globalThis.console&&(globalThis.console.firebug||globalThis.console.exception&&globalThis.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=F.debug||F.log||(()=>{});function save(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function load(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function localstorage(){try{return localStorage}catch{}}t.exports=po()(e);let{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),ho=__commonJSMin(((e,t)=>{
5
+ `+t)}profile(e){}profileEnd(e){}timeStamp(e){}},P=new Console,log=(...e)=>P.log(...e),info=(...e)=>P.info(...e),debug=(...e)=>P.debug(...e),warn=(...e)=>P.warn(...e),error=(...e)=>P.error(...e),dir=(e,t)=>P.dir(e,t),dirxml=(...e)=>P.dirxml(...e),table=(e,t)=>P.table(e,t),clear=()=>P.clear(),assert=(e,...t)=>P.assert(e,...t),trace=(...e)=>P.trace(...e),time=e=>P.time(e),timeEnd=e=>P.timeEnd(e),timeLog=(e,...t)=>P.timeLog(e,...t),count=e=>P.count(e),countReset=e=>P.countReset(e),group=(...e)=>P.group(...e),groupCollapsed=(...e)=>P.groupCollapsed(...e),groupEnd=()=>P.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),F,I=__esmMin(()=>{he(),F={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),ge=__esmMin(()=>{I()}),_e,ve=__esmMin(()=>{_e=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function drainOnce(e){let t=Math.min(64,ye.length);for(let n=0;n<t;n++){let t=ye.shift();try{t()}catch(t){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(t?.stack||t),null)}catch{}}}ye.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):be=!1}function tryGLibTimeout(e){let t=globalThis.imports?.gi?.GLib;return t?.timeout_add?(ye.push(e),be||(be=!0,t.timeout_add(t.PRIORITY_DEFAULT,0,()=>(drainOnce(t),!1))),!0):!1}var ye,be,nextTick,xe=__esmMin(()=>{ye=[],be=!1,nextTick=(e,...t)=>{let n=t.length>0?()=>e(...t):e;if(!tryGLibTimeout(n)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...t);return}if(typeof queueMicrotask==`function`){queueMicrotask(n);return}Promise.resolve().then(n)}}}),Se,Ce=__esmMin(()=>{A(),N(),{File:Se}=M});function classOf(e){return we.call(e).slice(8,-1)}function throwDataCloneError(e){let t=globalThis.DOMException;if(typeof t==`function`)throw new t(e,`DataCloneError`);let n=Error(e);throw n.name=`DataCloneError`,n}function internalClone(e,t,n){if(e==null)return e;let r=typeof e;if(r===`boolean`||r===`number`||r===`string`||r===`bigint`)return e;r===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),r===`function`&&throwDataCloneError(`Function cannot be cloned`);let i=e;if(t.has(i))return t.get(i);let a=classOf(i);if(a===`Date`)return new Date(i.getTime());if(a===`RegExp`)return new RegExp(i.source,i.flags);if(a===`Boolean`||a===`Number`||a===`String`)return Object(i.valueOf());if(a===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,a=new(r&&Te[r]||Te[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),a}if(a===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(a===`ArrayBuffer`){let e=i;if(n&&n.transferred.has(e)){let r=n.transferred.get(e);return t.set(i,r),r}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let r=e.slice(0);return t.set(i,r),r}if(a===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(a===`DataView`){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=r?r.byteOffset:e.byteOffset,s=r?r.byteLength:e.byteLength,c=new DataView(a,o,s);return t.set(i,c),c}if(Ee.has(a)){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=e.constructor,s=new o(a,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,s),s}if(a===`Map`){let e=new Map;t.set(i,e);for(let[r,a]of i)e.set(internalClone(r,t,n),internalClone(a,t,n));return e}if(a===`Set`){let e=new Set;t.set(i,e);for(let r of i)e.add(internalClone(r,t,n));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&i instanceof n){let e=i;return new n([i],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&i instanceof t)return new t([i],{type:i.type})}if(i instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),i instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),i instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&i instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),a===`Array`){let e=i,r=[];t.set(i,r);for(let i=0;i<e.length;i++)i in e&&(r[i]=internalClone(e[i],t,n));return r}if(a===`Object`||typeof i==`object`){let e={};t.set(i,e);for(let r of Object.keys(i))e[r]=internalClone(i[r],t,n);return e}throwDataCloneError(`${a} cannot be cloned`)}function structuredClone$1(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}function snapshotViewsBackedByTransferredBuffers(e,t,n,r){if(typeof e!=`object`||!e)return;let i=e;if(r.has(i))return;r.add(i);let a=classOf(i);if(a===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(Ee.has(a)){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(i)){for(let e=0;e<i.length;e++)e in i&&snapshotViewsBackedByTransferredBuffers(i[e],t,n,r);return}if(a===`Map`){for(let[e,a]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(a,t,n,r);return}if(a===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(a===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}var we,Te,Ee,De=__esmMin(()=>{({toString:we}=Object.prototype),Te={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ee=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name(structuredClone$1,`structuredClone`)});function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(Oe)return ke;let t=e.gi?.GLib;if(t){if(ke=new t.MainLoop(null,!1),Oe=!0,t.main_depth()===0)try{ke.runAsync()}catch{}return ke}}function quitMainLoop(){ke&&=(ke.quit(),Oe=!1,null)}var Oe,ke,Ae=__esmMin(()=>{Oe=!1,ke=null}),L=__esmMin(()=>{T(),E(),j(),ee(),te(),ne(),se(),ue(),fe(),pe(),ge(),ve(),xe(),Ce(),De(),Ae()});w(),L(),registerGlobal(`Blob`,x),registerGlobal(`File`,S);var je=Object.defineProperty;__name((e,t)=>{let n={};for(var r in e)je(n,r,{get:e[r],enumerable:!0});return t||je(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)({attributes:()=>U,childNodesList:()=>V,elementChildren:()=>H,isConnected:()=>Me,localName:()=>Pe,name:()=>Le,namespaceURI:()=>Fe,nodeType:()=>z,ownerElement:()=>ze,parentNode:()=>B,prefix:()=>Ie,propertyEventListeners:()=>W,tagName:()=>Ne,value:()=>Re});const z=Symbol(`nodeType`),B=Symbol(`parentNode`),V=Symbol(`childNodesList`),H=Symbol(`elementChildren`),Me=Symbol(`isConnected`),Ne=Symbol(`tagName`),Pe=Symbol(`localName`),Fe=Symbol(`namespaceURI`),Ie=Symbol(`prefix`),U=Symbol(`attributes`),W=Symbol(`propertyEventListeners`),Le=Symbol(`name`),Re=Symbol(`value`),ze=Symbol(`ownerElement`),G={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11};var NodeList=class{constructor(e){this._items=e}get length(){return this._items.length}item(e){return this._items[e]??null}forEach(e,t){for(let n=0;n<this._items.length;n++)e.call(t,this._items[n],n,this)}entries(){return this._items.entries()}keys(){return this._items.keys()}values(){return this._items.values()}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NodeList`}};const Be={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(e,t){super(e),this.name=t||`Error`,this.code=Object.hasOwn(Be,this.name)?Be[this.name]:0}};const Ve=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;I();const He=Symbol(`type`),Ue=Symbol(`bubbles`),We=Symbol(`cancelable`),Ge=Symbol(`composed`),Ke=Symbol(`target`),qe=Symbol(`currentTarget`),Je=Symbol(`eventPhase`),Ye=Symbol(`defaultPrevented`),Xe=Symbol(`isTrusted`),Ze=Symbol(`timeStamp`),Qe=Symbol(`stop`),$e=Symbol(`immediateStop`),et=Symbol(`dispatching`),tt=Symbol(`inPassiveListener`);var Event=class{[He];[Ue];[We];[Ge];[Ke]=null;[qe]=null;[Je]=0;[Ye]=!1;[Xe]=!1;[Ze];[Qe]=!1;[$e]=!1;[et]=!1;[tt]=!1;get type(){return this[He]}get bubbles(){return this[Ue]}get cancelable(){return this[We]}get composed(){return this[Ge]}get target(){return this[Ke]}get currentTarget(){return this[qe]}get eventPhase(){return this[Je]}get defaultPrevented(){return this[Ye]}get timeStamp(){return this[Ze]}get cancelBubble(){return this[Qe]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[Ye]}set returnValue(e){e||this.preventDefault()}get srcElement(){return this[Ke]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(e,t){this[He]=e,this[Ue]=t?.bubbles??!1,this[We]=t?.cancelable??!1,this[Ge]=t?.composed??!1,this[Ze]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[Xe],enumerable:!0,configurable:!1})}composedPath(){return this[qe]?[this[qe]]:[]}preventDefault(){this[We]&&!this[tt]&&(this[Ye]=!0)}stopPropagation(){this[Qe]=!0}stopImmediatePropagation(){this[Qe]=!0,this[$e]=!0}},EventTarget=class{_listeners=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(e,t,n){if(t===null)return;let r=typeof n==`boolean`?n:n?.capture??!1,i=typeof n==`object`?n?.once??!1:!1,a=typeof n==`object`?n?.passive??!1:!1,o=this._listeners.get(e);o||(o=[],this._listeners.set(e,o));for(let e of o)if(e.listener===t&&e.capture===r)return;let s={listener:t,capture:r,once:i,passive:a,removed:!1};o.push(s),typeof n==`object`&&n?.signal&&n.signal.addEventListener(`abort`,()=>{this.removeEventListener(e,t,{capture:r})},{once:!0})}removeEventListener(e,t,n){if(t===null)return;let r=typeof n==`boolean`?n:n?.capture??!1,i=this._listeners.get(e);if(!i)return;let a=i.findIndex(e=>e.listener===t&&e.capture===r);a!==-1&&(i[a].removed=!0,i.splice(a,1),i.length===0&&this._listeners.delete(e))}dispatchEvent(e){let t=e;if(t[et])throw new Ve(`The event is already being dispatched.`,`InvalidStateError`);t[et]=!0,t[Ke]=this,t[qe]=this,t[Je]=Event.AT_TARGET;let n=this._listeners.get(e.type);if(n){let r=[...n];for(let n of r)if(!n.removed){if(t[$e]||t[Qe])break;n.once&&this.removeEventListener(e.type,n.listener,{capture:n.capture});try{n.passive&&(t[tt]=!0),typeof n.listener==`function`?n.listener.call(this,e):typeof n.listener.handleEvent==`function`&&n.listener.handleEvent.call(n.listener,e)}catch(e){F.error(e)}finally{t[tt]=!1}}}return t[Je]=Event.NONE,t[qe]=null,t[et]=!1,!e.defaultPrevented}};for(let[e,t]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event.prototype,e,{value:t,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event,e,{value:t,writable:!1,enumerable:!0,configurable:!1});let nt,rt,it,at,ot;var st=class Node extends EventTarget{constructor(...e){super(...e),this.ELEMENT_NODE=G.ELEMENT_NODE,this.ATTRIBUTE_NODE=G.ATTRIBUTE_NODE,this.TEXT_NODE=G.TEXT_NODE,this.CDATA_SECTION_NODE=G.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=G.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=G.COMMENT_NODE,this.DOCUMENT_NODE=G.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=G.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=G.DOCUMENT_FRAGMENT_NODE,this[nt]=G.ELEMENT_NODE,this[rt]=null,this[it]=[],this[at]=[],this[ot]=!1}static{this.ELEMENT_NODE=G.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=G.ATTRIBUTE_NODE}static{this.TEXT_NODE=G.TEXT_NODE}static{this.CDATA_SECTION_NODE=G.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=G.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=G.COMMENT_NODE}static{this.DOCUMENT_NODE=G.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=G.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=G.DOCUMENT_FRAGMENT_NODE}static{this.DOCUMENT_POSITION_DISCONNECTED=1}static{this.DOCUMENT_POSITION_PRECEDING=2}static{this.DOCUMENT_POSITION_FOLLOWING=4}static{this.DOCUMENT_POSITION_CONTAINS=8}static{this.DOCUMENT_POSITION_CONTAINED_BY=16}static{this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32}get nodeType(){return this[z]}get nodeName(){return``}get parentNode(){return this[B]}get parentElement(){let e=this[B];return e&&e[z]===G.ELEMENT_NODE?e:null}get childNodes(){return new NodeList(this[V])}get firstChild(){return this[V][0]??null}get lastChild(){let e=this[V];return e[e.length-1]??null}get previousSibling(){let e=this[B];if(!e)return null;let t=e[V],n=t.indexOf(this);return n>0?t[n-1]:null}get nextSibling(){let e=this[B];if(!e)return null;let t=e[V],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){return null}set textContent(e){}get nodeValue(){return null}set nodeValue(e){}get ownerDocument(){let e=this;for(;e[B];)e=e[B];let t=globalThis.document;return e===t?t:null}get isConnected(){return this[Me]}hasChildNodes(){return this[V].length>0}contains(e){if(e===null)return!1;if(e===this)return!0;let t=e;for(;t;){if(t===this)return!0;t=t[B]}return!1}getRootNode(){let e=this;for(;e[B];)e=e[B];return e}appendChild(e){return e[B]&&e[B].removeChild(e),e[B]=this,this[V].push(e),e[z]===G.ELEMENT_NODE&&this[H].push(e),e}removeChild(e){let t=this[V],n=t.indexOf(e);if(n===-1)throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`,`NotFoundError`);if(t.splice(n,1),e[B]=null,e[z]===G.ELEMENT_NODE){let t=this[H].indexOf(e);t!==-1&&this[H].splice(t,1)}return e}insertBefore(e,t){if(t===null)return this.appendChild(e);let n=this[V],r=n.indexOf(t);if(r===-1)throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`,`NotFoundError`);if(e[B]&&e[B].removeChild(e),e[B]=this,n.splice(r,0,e),e[z]===G.ELEMENT_NODE){let t=this[H],i=t.length;for(let a=r;a<n.length;a++)if(n[a][z]===G.ELEMENT_NODE&&n[a]!==e){i=t.indexOf(n[a]);break}t.splice(i,0,e)}return e}replaceChild(e,t){return this.insertBefore(e,t),this.removeChild(t),t}cloneNode(e=!1){let t=new this.constructor;if(t[z]=this[z],e)for(let e of this[V])t.appendChild(e.cloneNode(!0));return t}dispatchEvent(e){let t=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let t=this[B];for(;t&&(Object.getPrototypeOf(Node.prototype).dispatchEvent.call(t,e),!e.cancelBubble);)t=t[B]}return t}get[(nt=z,rt=B,it=V,at=H,ot=Me,Symbol.toStringTag)](){return`Node`}};const ct={html:`http://www.w3.org/1999/xhtml`,svg:`http://www.w3.org/2000/svg`,mathML:`http://www.w3.org/1998/Math/MathML`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};var Attr=class{constructor(e,t,n=null,r=null,i=null){this.specified=!0,this[Le]=e,this[Re]=t,this[ze]=i,this.namespaceURI=n,this.prefix=r;let a=e.indexOf(`:`);this.localName=a===-1?e:e.slice(a+1)}get name(){return this[Le]}get value(){return this[Re]}set value(e){this[Re]=e}get ownerElement(){return this[ze]}get[Symbol.toStringTag](){return`Attr`}},NamedNodeMap=class{constructor(e){this._items=[],this._ownerElement=e}get length(){return this._items.length}item(e){return this._items[e]??null}getNamedItem(e){return this._findByName(e)}getNamedItemNS(e,t){let n=e===``?null:e;for(let e of this._items)if(e.namespaceURI===n&&e.localName===t)return e;return null}setNamedItem(e){return this._setAttr(e)}setNamedItemNS(e){return this._setAttr(e)}removeNamedItem(e){let t=this._findByName(e);if(!t)throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${e}' was found.`,`NotFoundError`);return this._removeAttr(t),t}removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);if(!n)throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${e}' and localName '${t}' was found.`,`NotFoundError`);return this._removeAttr(n),n}[Symbol.iterator](){return this._items[Symbol.iterator]()}get[Symbol.toStringTag](){return`NamedNodeMap`}_setNamedItem(e,t,n=null,r=null){let i=n===null?this._findByName(e):this.getNamedItemNS(n,e.includes(`:`)?e.split(`:`)[1]:e);if(i)i.value=t;else{let i=new Attr(e,t,n,r,this._ownerElement);this._items.push(i)}}_removeNamedItem(e){let t=this._findByName(e);return t?(this._removeAttr(t),!0):!1}_removeNamedItemNS(e,t){let n=this.getNamedItemNS(e,t);return n?(this._removeAttr(n),!0):!1}_findByName(e){let t=this._ownerElement.namespaceURI===ct.html,n=t?e.toLowerCase():e;for(let e of this._items)if((t?e.name.toLowerCase():e.name)===n)return e;return null}_setAttr(e){let t=null;if(t=e.namespaceURI===null?this._findByName(e.name):this.getNamedItemNS(e.namespaceURI,e.localName),t){let n=new Attr(t.name,t.value,t.namespaceURI,t.prefix,t.ownerElement);return t.value=e.value,n}return this._items.push(e),null}_removeAttr(e){let t=this._items.indexOf(e);t!==-1&&this._items.splice(t,1)}};I();let lt,ut,dt,ft,pt,mt;var Element=class extends st{constructor(){super(),this[lt]=``,this[ut]=``,this[dt]=ct.html,this[ft]=null,this[pt]=new NamedNodeMap(this),this[mt]=new Map,this._resizeSubscribers=null,this._allocatedClientWidth=0,this._allocatedClientHeight=0,this._pointerCaptures=new Set,this[z]=G.ELEMENT_NODE}get tagName(){return this[Ne]}get localName(){return this[Pe]}get namespaceURI(){return this[Fe]}get prefix(){return this[Ie]}get nodeName(){return this[Ne]}get attributes(){return this[U]}get id(){return this.getAttribute(`id`)??``}set id(e){this.setAttribute(`id`,e)}get className(){return this.getAttribute(`class`)??``}set className(e){this.setAttribute(`class`,e)}get children(){return this[H]}get childElementCount(){return this[H].length}get firstElementChild(){return this[H][0]??null}get lastElementChild(){let e=this[H];return e[e.length-1]??null}get previousElementSibling(){let e=this[B];if(!e)return null;let t=e[H],n=t.indexOf(this);return n>0?t[n-1]:null}get nextElementSibling(){let e=this[B];if(!e)return null;let t=e[H],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){let e=``;for(let t of this[V])t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){let t=this[V];for(;t.length>0;)this.removeChild(t[0])}getAttribute(e){let t=this[U].getNamedItem(e);return t?t.value:null}getAttributeNS(e,t){let n=this[U].getNamedItemNS(e,t);return n?n.value:null}setAttribute(e,t){this[U]._setNamedItem(e,String(t))}setAttributeNS(e,t,n){let r=e===``?null:e,i=t.split(`:`),a=i.length>1?i[0]:null;this[U]._setNamedItem(t,String(n),r,a)}removeAttribute(e){this[U]._removeNamedItem(e)}removeAttributeNS(e,t){let n=e===``?null:e;this[U]._removeNamedItemNS(n,t)}hasAttribute(e){return this[U].getNamedItem(e)!==null}hasAttributeNS(e,t){return this[U].getNamedItemNS(e,t)!==null}getAttributeNode(e){return this[U].getNamedItem(e)}setAttributeNode(e){return this[U].setNamedItem(e)}removeAttributeNode(e){let t=this[U].getNamedItem(e.name);if(!t)throw new DOMException(`Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.`,`NotFoundError`);return this[U].removeNamedItem(t.name),t}toggleAttribute(e,t){return t===void 0?this.hasAttribute(e)?(this.removeAttribute(e),!1):(this.setAttribute(e,``),!0):t?(this.setAttribute(e,``),!0):(this.removeAttribute(e),!1)}hasAttributes(){return this[U].length>0}dispatchEvent(e){let t=super.dispatchEvent(e),n=this[W].get(`on`+e.type);return typeof n==`function`&&n.call(this,e),t}querySelector(e){return null}querySelectorAll(e){return[]}matches(e){return!1}closest(e){return null}getElementsByTagName(e){let t=[],n=e.toUpperCase(),walk=r=>{for(let i of r[V])if(i[z]===G.ELEMENT_NODE){let r=i;(e===`*`||r[Ne]===n)&&t.push(r),walk(r)}};return walk(this),t}getElementsByClassName(e){let t=[],n=e.split(/\s+/).filter(Boolean),walk=e=>{for(let r of e[V])if(r[z]===G.ELEMENT_NODE){let e=r,i=e.className.split(/\s+/);n.every(e=>i.includes(e))&&t.push(e),walk(e)}};return walk(this),t}cloneNode(e=!1){let t=super.cloneNode(!1);t[Ne]=this[Ne],t[Pe]=this[Pe],t[Fe]=this[Fe],t[Ie]=this[Ie];for(let e of this[U])t.setAttributeNS(e.namespaceURI,e.name,e.value);if(e)for(let e of this[V])t.appendChild(e.cloneNode(!0));return t}_onResize(e){let t=this._resizeSubscribers??=new Set;return t.add(e),()=>{t.delete(e),t.size===0&&(this._resizeSubscribers=null)}}_fireResizeSubscribers(e,t){let n=this._resizeSubscribers;if(!(!n||n.size===0))for(let r of[...n])try{r(e,t)}catch(e){F.error(`ResizeObserver subscriber threw:`,e)}}setPointerCapture(e){this._pointerCaptures.add(e)}releasePointerCapture(e){this._pointerCaptures.delete(e)}hasPointerCapture(e){return this._pointerCaptures.has(e)}get[(lt=Ne,ut=Pe,dt=Fe,ft=Ie,pt=U,mt=W,Symbol.toStringTag)](){return`Element`}},CSSStyleDeclaration=class{constructor(){this._cssText=``}get cssText(){return this._cssText}set cssText(e){this._cssText=e;for(let t of e.split(`;`)){let e=t.indexOf(`:`);if(e===-1)continue;let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)continue;let i=n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());this[i]=r}}setProperty(e,t,n){this[e]=t}getPropertyValue(e){let t=this[e];return typeof t==`string`?t:``}removeProperty(e){let t=this[e];return delete this[e],typeof t==`string`?t:``}getPropertyPriority(e){return``}},HTMLElement$1=class extends Element{static{__name(this,`HTMLElement`)}constructor(...e){super(...e),this.style=new CSSStyleDeclaration}get dataset(){let e=this;return new Proxy({},{get(t,n){if(typeof n!=`string`)return;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.getAttribute(r)??void 0},set(t,n,r){if(typeof n!=`string`)return!1;let i=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.setAttribute(i,String(r)),!0},deleteProperty(t,n){if(typeof n!=`string`)return!1;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.removeAttribute(r),!0},has(t,n){if(typeof n!=`string`)return!1;let r=`data-`+n.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());return e.hasAttribute(r)}})}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get lang(){return this.getAttribute(`lang`)??``}set lang(e){this.setAttribute(`lang`,e)}get dir(){return this.getAttribute(`dir`)??``}set dir(e){this.setAttribute(`dir`,e)}get accessKey(){return this.getAttribute(`accesskey`)??``}set accessKey(e){this.setAttribute(`accesskey`,e)}get accessKeyLabel(){return this.getAttribute(`accesskey`)??``}get hidden(){return this.hasAttribute(`hidden`)}set hidden(e){e?this.setAttribute(`hidden`,``):this.removeAttribute(`hidden`)}get draggable(){return this.getAttribute(`draggable`)===`true`}set draggable(e){this.setAttribute(`draggable`,String(e))}get spellcheck(){let e=this.getAttribute(`spellcheck`);return e===`false`?!1:e!==null}set spellcheck(e){this.setAttribute(`spellcheck`,String(e))}get translate(){return this.getAttribute(`translate`)!==`no`}set translate(e){this.setAttribute(`translate`,e?`yes`:`no`)}get tabIndex(){let e=this.getAttribute(`tabindex`);return e===null?-1:Number(e)}set tabIndex(e){this.setAttribute(`tabindex`,String(e))}get contentEditable(){let e=this.getAttribute(`contenteditable`);return e===``||e===`true`?`true`:e===`false`?`false`:`inherit`}set contentEditable(e){e===`inherit`?this.removeAttribute(`contenteditable`):this.setAttribute(`contenteditable`,e)}get isContentEditable(){return this.contentEditable===`true`}get offsetHeight(){return this._allocatedClientHeight}get offsetWidth(){return this._allocatedClientWidth}get offsetLeft(){return 0}get offsetTop(){return 0}get offsetParent(){return null}get clientHeight(){return this._allocatedClientHeight}get clientWidth(){return this._allocatedClientWidth}get clientLeft(){return 0}get clientTop(){return 0}get scrollHeight(){return this._allocatedClientHeight}get scrollWidth(){return this._allocatedClientWidth}get scrollTop(){return 0}set scrollTop(e){}get scrollLeft(){return 0}set scrollLeft(e){}getBoundingClientRect(){let e=this.clientWidth,t=this.clientHeight;return{x:0,y:0,top:0,left:0,right:e,bottom:t,width:e,height:t,toJSON(){return this}}}click(){this.dispatchEvent(new Event(`click`,{bubbles:!0,cancelable:!0}))}blur(){this.dispatchEvent(new Event(`blur`))}focus(){this.dispatchEvent(new Event(`focus`))}get onclick(){return this[W].get(`onclick`)??null}set onclick(e){this[W].set(`onclick`,e)}get ondblclick(){return this[W].get(`ondblclick`)??null}set ondblclick(e){this[W].set(`ondblclick`,e)}get onload(){return this[W].get(`onload`)??null}set onload(e){this[W].set(`onload`,e)}get onerror(){return this[W].get(`onerror`)??null}set onerror(e){this[W].set(`onerror`,e)}get onabort(){return this[W].get(`onabort`)??null}set onabort(e){this[W].set(`onabort`,e)}get onfocus(){return this[W].get(`onfocus`)??null}set onfocus(e){this[W].set(`onfocus`,e)}get onblur(){return this[W].get(`onblur`)??null}set onblur(e){this[W].set(`onblur`,e)}get onchange(){return this[W].get(`onchange`)??null}set onchange(e){this[W].set(`onchange`,e)}get oninput(){return this[W].get(`oninput`)??null}set oninput(e){this[W].set(`oninput`,e)}get onsubmit(){return this[W].get(`onsubmit`)??null}get onreset(){return this[W].get(`onreset`)??null}set onreset(e){this[W].set(`onreset`,e)}get onscroll(){return this[W].get(`onscroll`)??null}set onscroll(e){this[W].set(`onscroll`,e)}get onresize(){return this[W].get(`onresize`)??null}set onresize(e){this[W].set(`onresize`,e)}get onmousedown(){return this[W].get(`onmousedown`)??null}set onmousedown(e){this[W].set(`onmousedown`,e)}get onmouseup(){return this[W].get(`onmouseup`)??null}set onmouseup(e){this[W].set(`onmouseup`,e)}get onmousemove(){return this[W].get(`onmousemove`)??null}set onmousemove(e){this[W].set(`onmousemove`,e)}get onmouseover(){return this[W].get(`onmouseover`)??null}set onmouseover(e){this[W].set(`onmouseover`,e)}get onmouseout(){return this[W].get(`onmouseout`)??null}set onmouseout(e){this[W].set(`onmouseout`,e)}get onmouseenter(){return this[W].get(`onmouseenter`)??null}set onmouseenter(e){this[W].set(`onmouseenter`,e)}get onmouseleave(){return this[W].get(`onmouseleave`)??null}set onmouseleave(e){this[W].set(`onmouseleave`,e)}get oncontextmenu(){return this[W].get(`oncontextmenu`)??null}set oncontextmenu(e){this[W].set(`oncontextmenu`,e)}get onwheel(){return this[W].get(`onwheel`)??null}set onwheel(e){this[W].set(`onwheel`,e)}get onkeydown(){return this[W].get(`onkeydown`)??null}set onkeydown(e){this[W].set(`onkeydown`,e)}get onkeyup(){return this[W].get(`onkeyup`)??null}set onkeyup(e){this[W].set(`onkeyup`,e)}get ontouchstart(){return this[W].get(`ontouchstart`)??null}set ontouchstart(e){this[W].set(`ontouchstart`,e)}get ontouchend(){return this[W].get(`ontouchend`)??null}set ontouchend(e){this[W].set(`ontouchend`,e)}get ontouchmove(){return this[W].get(`ontouchmove`)??null}set ontouchmove(e){this[W].set(`ontouchmove`,e)}get onpointerdown(){return this[W].get(`onpointerdown`)??null}set onpointerdown(e){this[W].set(`onpointerdown`,e)}get onpointerup(){return this[W].get(`onpointerup`)??null}set onpointerup(e){this[W].set(`onpointerup`,e)}get onpointermove(){return this[W].get(`onpointermove`)??null}set onpointermove(e){this[W].set(`onpointermove`,e)}cloneNode(e=!1){return super.cloneNode(e)}get[Symbol.toStringTag](){return`HTMLElement`}},ht=class HTMLCanvasElement extends HTMLElement$1{constructor(...e){super(...e),this.oncontextlost=null,this.oncontextrestored=null,this.onwebglcontextcreationerror=null,this.onwebglcontextlost=null,this.onwebglcontextrestored=null}static{this._contextFactories=new Map}static registerContextFactory(e,t){HTMLCanvasElement._contextFactories.set(e,t)}get width(){let e=this.getAttribute(`width`);return e===null?300:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get height(){let e=this.getAttribute(`height`);return e===null?150:Number(e)}set height(e){this.setAttribute(`height`,String(e))}getContext(e,t){let n=HTMLCanvasElement._contextFactories.get(e);return n?n(this,t):null}toDataURL(e,t){let n=this.getContext(`2d`);return n&&typeof n._toDataURL==`function`?n._toDataURL(e,t):``}toBlob(e,t,n){let r=this.toDataURL(t,n);if(!r){e(null);return}let[i,a]=r.split(`,`),o=i.split(`:`)[1].split(`;`)[0],s=atob(a),c=new Uint8Array(s.length);for(let e=0;e<s.length;e++)c[e]=s.charCodeAt(e);e(new Blob([c],{type:o}))}captureStream(e){return{}}},gt=class DOMMatrix{constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,this.is2D=!0,this.isIdentity=!0,Array.isArray(e)&&(e.length===6?(this.a=this.m11=e[0],this.b=this.m12=e[1],this.c=this.m21=e[2],this.d=this.m22=e[3],this.e=this.m41=e[4],this.f=this.m42=e[5],this.is2D=!0):e.length===16&&(this.m11=e[0],this.m12=e[1],this.m13=e[2],this.m14=e[3],this.m21=e[4],this.m22=e[5],this.m23=e[6],this.m24=e[7],this.m31=e[8],this.m32=e[9],this.m33=e[10],this.m34=e[11],this.m41=e[12],this.m42=e[13],this.m43=e[14],this.m44=e[15],this.a=this.m11,this.b=this.m12,this.c=this.m21,this.d=this.m22,this.e=this.m41,this.f=this.m42,this.is2D=!1),this.isIdentity=this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0)}multiply(e){return new DOMMatrix([this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f])}multiplySelf(e){let t=this.multiply(e);return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,this.f=t.f,this.m11=this.a,this.m12=this.b,this.m21=this.c,this.m22=this.d,this.m41=this.e,this.m42=this.f,this.isIdentity=!1,this}inverse(){let e=this.a*this.d-this.b*this.c;if(e===0)return new DOMMatrix([1,0,0,1,0,0]);let t=1/e;return new DOMMatrix([this.d*t,-this.b*t,-this.c*t,this.a*t,(this.c*this.f-this.d*this.e)*t,(this.b*this.e-this.a*this.f)*t])}translate(e=0,t=0){return this.multiply({a:1,b:0,c:0,d:1,e,f:t})}scale(e=1,t=e){return this.multiply({a:e,b:0,c:0,d:t,e:0,f:0})}};const _t=gt;function defineGlobal(e,t){Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}function defineGlobalIfMissing(e,t){globalThis[e]===void 0&&defineGlobal(e,t)}const vt={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`,transparent:`#00000000`};function parseColor(e){if(!e||typeof e!=`string`)return null;let t=e.trim().toLowerCase(),n=vt[t];if(n)return parseHex(n);if(t.startsWith(`#`))return parseHex(t);let r=t.match(/^rgba?\(\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*[,\s]\s*(\d+(?:\.\d+)?%?)\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(r)return{r:parseComponent(r[1],255)/255,g:parseComponent(r[2],255)/255,b:parseComponent(r[3],255)/255,a:r[4]===void 0?1:parseComponent(r[4],1)};let i=t.match(/^hsla?\(\s*(\d+(?:\.\d+)?)\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*[,\s]\s*(\d+(?:\.\d+)?)(%)?\s*(?:[,/]\s*(\d+(?:\.\d+)?%?))?\s*\)$/);if(i){let e=parseFloat(i[1]),t=parseFloat(i[2]),n=i[3]===`%`,r=parseFloat(i[4]),a=i[5]===`%`,o=i[6]===void 0?1:parseComponent(i[6],1);return e>1&&(e/=360),(n||t>1)&&(t/=100),(a||r>1)&&(r/=100),hslToRGBA(e,t,r,Math.max(0,Math.min(1,o)))}return null}function parseHex(e){let t=e.slice(1),n,r,i,a=1;if(t.length===3)n=parseInt(t[0]+t[0],16)/255,r=parseInt(t[1]+t[1],16)/255,i=parseInt(t[2]+t[2],16)/255;else if(t.length===4)n=parseInt(t[0]+t[0],16)/255,r=parseInt(t[1]+t[1],16)/255,i=parseInt(t[2]+t[2],16)/255,a=parseInt(t[3]+t[3],16)/255;else if(t.length===6)n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255;else if(t.length===8)n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,a=parseInt(t.slice(6,8),16)/255;else return null;return{r:n,g:r,b:i,a}}function parseComponent(e,t){return e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e)}function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function hslToRGBA(e,t,n,r){let i,a,o;if(t===0)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=hue2rgb(s,r,e+1/3),a=hue2rgb(s,r,e),o=hue2rgb(s,r,e-1/3)}return{r:i,g:a,b:o,a:r}}const yt={r:0,g:0,b:0,a:1};var CanvasGradient=class{constructor(e,t,r,i,a,o,s){e===`radial`?this._pattern=new n.RadialGradient(t,r,o,i,a,s):this._pattern=new n.LinearGradient(t,r,i,a)}addColorStop(e,t){let n=parseColor(t);n&&this._pattern.addColorStopRGBA(e,n.r,n.g,n.b,n.a)}_getCairoPattern(){return this._pattern}};function quadraticToCubic(e,t,n,r,i,a){return{cp1x:e+2/3*(n-e),cp1y:t+2/3*(r-t),cp2x:i+2/3*(n-i),cp2y:a+2/3*(r-a)}}function computeArcTo(e,t,n,r,i,a,o){let s=e-n,c=t-r,l=i-n,u=a-r,d=Math.sqrt(s*s+c*c),p=Math.sqrt(l*l+u*u);if(d===0||p===0)return null;let m=s/d,h=c/d,g=l/p,_=u/p,v=m*_-h*g;if(Math.abs(v)<1e-10)return null;let y=m*g+h*_,b=Math.acos(Math.max(-1,Math.min(1,y)))/2,x=o/Math.tan(b),S=n+m*x,w=r+h*x,T=n+g*x,E=r+_*x,D=o/Math.sin(b),O=(m+g)/2,k=(h+_)/2,A=Math.sqrt(O*O+k*k),j=n+O/A*D,ee=r+k/A*D;return{tx0:S,ty0:w,tx1:T,ty1:E,cx:j,cy:ee,startAngle:Math.atan2(w-ee,S-j),endAngle:Math.atan2(E-ee,T-j),counterclockwise:v>0}}function cairoArcTo(e,t,n,r,i,a,o,s){let c=computeArcTo(t,n,r,i,a,o,s);if(!c){e.lineTo(r,i);return}let{tx0:l,ty0:u,cx:d,cy:p,startAngle:m,endAngle:h,counterclockwise:g}=c;e.lineTo(l,u),g?e.arcNegative(d,p,s,m,h):e.arc(d,p,s,m,h)}function cairoEllipse(e,t,n,r,i,a,o,s,c){e.save(),e.translate(t,n),e.rotate(a),e.scale(r,i),c?e.arcNegative(0,0,1,o,s):e.arc(0,0,1,o,s),e.restore()}function cairoRoundRect(e,t,n,r,i,a){let o,s,c,l;typeof a==`number`?o=s=c=l=a:a.length===1?o=s=c=l=a[0]:a.length===2?(o=c=a[0],s=l=a[1]):a.length===3?(o=a[0],s=l=a[1],c=a[2]):(o=a[0],s=a[1],c=a[2],l=a[3]);let u=Math.min(r/2,i/2);o=Math.min(o,u),s=Math.min(s,u),c=Math.min(c,u),l=Math.min(l,u);let d=Math.PI/2;e.newSubPath(),e.arc(t+o,n+o,o,Math.PI,Math.PI+d),e.arc(t+r-s,n+s,s,-d,0),e.arc(t+r-c,n+i-c,c,0,d),e.arc(t+l,n+i-l,l,d,Math.PI),e.closePath()}const bt={"source-over":2,"source-in":3,"source-out":4,"source-atop":5,"destination-over":7,"destination-in":8,"destination-out":9,"destination-atop":10,lighter:12,copy:1,xor:11,multiply:14,screen:15,overlay:16,darken:17,lighten:18,"color-dodge":19,"color-burn":20,"hard-light":21,"soft-light":22,difference:23,exclusion:24,hue:25,saturation:26,color:27,luminosity:28},xt={butt:0,round:1,square:2},St={miter:0,round:1,bevel:2};var Ct=class Path2D{constructor(e){this._ops=[],e instanceof Path2D&&(this._ops=[...e._ops])}addPath(e){this._ops.push(...e._ops)}moveTo(e,t){this._ops.push({type:`moveTo`,x:e,y:t})}lineTo(e,t){this._ops.push({type:`lineTo`,x:e,y:t})}closePath(){this._ops.push({type:`closePath`})}bezierCurveTo(e,t,n,r,i,a){this._ops.push({type:`bezierCurveTo`,cp1x:e,cp1y:t,cp2x:n,cp2y:r,x:i,y:a})}quadraticCurveTo(e,t,n,r){this._ops.push({type:`quadraticCurveTo`,cpx:e,cpy:t,x:n,y:r})}arc(e,t,n,r,i,a=!1){this._ops.push({type:`arc`,x:e,y:t,radius:n,startAngle:r,endAngle:i,ccw:a})}ellipse(e,t,n,r,i,a,o,s=!1){if(n<0||r<0)throw RangeError(`The radii provided are negative`);this._ops.push({type:`ellipse`,x:e,y:t,rx:n,ry:r,rotation:i,startAngle:a,endAngle:o,ccw:s})}rect(e,t,n,r){this._ops.push({type:`rect`,x:e,y:t,w:n,h:r})}roundRect(e,t,n,r,i=0){this._ops.push({type:`roundRect`,x:e,y:t,w:n,h:r,radii:i})}_replayOnCairo(e){let t=0,n=0;for(let r of this._ops)switch(r.type){case`moveTo`:e.moveTo(r.x,r.y),t=r.x,n=r.y;break;case`lineTo`:e.lineTo(r.x,r.y),t=r.x,n=r.y;break;case`closePath`:e.closePath();break;case`bezierCurveTo`:e.curveTo(r.cp1x,r.cp1y,r.cp2x,r.cp2y,r.x,r.y),t=r.x,n=r.y;break;case`quadraticCurveTo`:{let{cp1x:i,cp1y:a,cp2x:o,cp2y:s}=quadraticToCubic(t,n,r.cpx,r.cpy,r.x,r.y);e.curveTo(i,a,o,s,r.x,r.y),t=r.x,n=r.y;break}case`arc`:r.ccw?e.arcNegative(r.x,r.y,r.radius,r.startAngle,r.endAngle):e.arc(r.x,r.y,r.radius,r.startAngle,r.endAngle);break;case`ellipse`:e.save(),e.translate(r.x,r.y),e.rotate(r.rotation),e.scale(r.rx,r.ry),r.ccw?e.arcNegative(0,0,1,r.startAngle,r.endAngle):e.arc(0,0,1,r.startAngle,r.endAngle),e.restore();break;case`rect`:e.rectangle(r.x,r.y,r.w,r.h);break;case`roundRect`:cairoRoundRect(e,r.x,r.y,r.w,r.h,r.radii);break}}};function asCairoPattern(e){if(!e)return null;let t=e;return typeof t.setFilter!=`function`||typeof t.setExtend!=`function`?null:t}function isPixbufImageSource(e){return typeof e!=`object`||!e?!1:typeof e.isPixbuf==`function`&&e.isPixbuf()}function isCanvasImageSource(e){return typeof e!=`object`||!e?!1:typeof e.getContext==`function`}var wt=class CanvasPattern{constructor(e,t){let r=asCairoPattern(new n.SurfacePattern(e));if(!r)throw TypeError(`CanvasPattern: cairo SurfacePattern is missing setExtend at runtime — incompatible Cairo binding`);switch(this._pattern=r,t){case`repeat`:case``:case null:r.setExtend(n.Extend.REPEAT);break;case`repeat-x`:case`repeat-y`:r.setExtend(n.Extend.REPEAT);break;case`no-repeat`:r.setExtend(n.Extend.NONE);break}}static create(e,t){if(isPixbufImageSource(e)){let i=e._pixbuf,a=i.get_width(),o=i.get_height(),s=new n.ImageSurface(n.Format.ARGB32,a,o),c=new n.Context(s);return r.cairo_set_source_pixbuf(c,i,0,0),c.paint(),c.$dispose(),new CanvasPattern(s,t)}if(isCanvasImageSource(e)){let r=e.getContext(`2d`);if(r&&typeof r._getSurface==`function`){let e=r._getSurface(),i=e.getWidth(),a=e.getHeight(),o=new n.ImageSurface(n.Format.ARGB32,i,a),s=new n.Context(o);return s.setSourceSurface(e,0,0),s.paint(),s.$dispose(),new CanvasPattern(o,t)}}return null}_getCairoPattern(){return this._pattern}},OurImageData=class{constructor(e,t,n){if(this.colorSpace=`srgb`,typeof e==`number`)this.width=e,this.height=t,this.data=new Uint8ClampedArray(this.width*this.height*4);else if(this.data=e,this.width=t,this.height=n??this.data.length/(4*this.width),this.data.length!==this.width*this.height*4)throw RangeError(`Source data length ${this.data.length} is not a multiple of (4 * width=${this.width})`)}};const Tt={translate(e,t){this._ensureSurface(),this._ctx.translate(e,t)},rotate(e){this._ensureSurface(),this._ctx.rotate(e)},scale(e,t){this._ensureSurface(),this._ctx.scale(e,t)},transform(e,t,n,r,i,a){if(this._ensureSurface(),!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a))return;let o=i,s=a,c=Math.hypot(e,t),l=Math.hypot(n,r),u=Math.atan2(t,e);this._ctx.translate(o,s),u!==0&&this._ctx.rotate(u),(c!==1||l!==1)&&this._ctx.scale(c,l)},setTransform(e,t,n,r,i,a){if(this._ensureSurface(),typeof e==`object`&&e){let t=e;this._ctx.identityMatrix(),this.transform(t.a??t.m11??1,t.b??t.m12??0,t.c??t.m21??0,t.d??t.m22??1,t.e??t.m41??0,t.f??t.m42??0)}else typeof e==`number`?(this._ctx.identityMatrix(),this.transform(e,t,n,r,i,a)):this._ctx.identityMatrix()},getTransform(){let e=this._ctx.userToDevice(0,0),t=this._ctx.userToDevice(1,0),n=this._ctx.userToDevice(0,1),r=e[0]??0,i=e[1]??0,a=(t[0]??0)-r,o=(t[1]??0)-i,s=(n[0]??0)-r,c=(n[1]??0)-i,l=globalThis.DOMMatrix;return typeof l==`function`?new l([a,o,s,c,r,i]):{a,b:o,c:s,d:c,e:r,f:i,m11:a,m12:o,m13:0,m14:0,m21:s,m22:c,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:r,m42:i,m43:0,m44:1,is2D:!0,isIdentity:a===1&&o===0&&s===0&&c===1&&r===0&&i===0}},resetTransform(){this._ensureSurface(),this._ctx.identityMatrix()}};function installTransformMethods(e){Object.assign(e,Tt)}const Et={beginPath(){this._ensureSurface(),this._ctx.newPath()},moveTo(e,t){this._ensureSurface(),this._ctx.moveTo(e,t)},lineTo(e,t){this._ensureSurface(),this._ctx.lineTo(e,t)},closePath(){this._ensureSurface(),this._ctx.closePath()},bezierCurveTo(e,t,n,r,i,a){this._ensureSurface(),this._ctx.curveTo(e,t,n,r,i,a)},quadraticCurveTo(e,t,n,r){this._ensureSurface();let i,a;this._ctx.hasCurrentPoint()?[i,a]=this._ctx.getCurrentPoint():(i=e,a=t);let{cp1x:o,cp1y:s,cp2x:c,cp2y:l}=quadraticToCubic(i,a,e,t,n,r);this._ctx.curveTo(o,s,c,l,n,r)},arc(e,t,n,r,i,a=!1){if(this._ensureSurface(),Math.abs(i-r)>=2*Math.PI){this._ctx.arc(e,t,n,0,2*Math.PI);return}a?this._ctx.arcNegative(e,t,n,r,i):this._ctx.arc(e,t,n,r,i)},arcTo(e,t,n,r,i){this._ensureSurface();let a,o;this._ctx.hasCurrentPoint()?[a,o]=this._ctx.getCurrentPoint():(a=e,o=t,this._ctx.moveTo(e,t)),cairoArcTo(this._ctx,a,o,e,t,n,r,i)},ellipse(e,t,n,r,i,a,o,s=!1){if(this._ensureSurface(),n<0||r<0)throw RangeError(`The radii provided are negative`);cairoEllipse(this._ctx,e,t,n,r,i,a,o,s)},rect(e,t,n,r){this._ensureSurface(),this._ctx.rectangle(e,t,n,r)},roundRect(e,t,n,r,i=0){this._ensureSurface(),cairoRoundRect(this._ctx,e,t,n,r,i)}};function installPathMethods(e){Object.assign(e,Et)}function getDrawImageSource(e){if(isPixbufImageSource(e)){let t=e._pixbuf;return{pixbuf:t,imgWidth:t.get_width(),imgHeight:t.get_height()}}if(isCanvasImageSource(e)){let t=e.width??0,n=e.height??0;if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return null;let i=e.getContext(`2d`);if(i&&typeof i._getSurface==`function`){let e=i._getSurface();e.flush();let a=r.pixbuf_get_from_surface(e,0,0,t,n);if(a)return{pixbuf:a,imgWidth:t,imgHeight:n}}}return null}const Dt={fill(e,t){this._ensureSurface(),this._applyCompositing(),this._applyFillStyle();let r;e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),r=t):r=e,this._ctx.setFillRule(r===`evenodd`?n.FillRule.EVEN_ODD:n.FillRule.WINDING),this._ctx.fillPreserve()},stroke(e){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle(),e instanceof Ct&&(this._ctx.newPath(),e._replayOnCairo(this._ctx)),this._ctx.strokePreserve()},fillRect(e,t,n,r){this._ensureSurface(),this._applyCompositing();let i=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.fill()}),this._applyFillStyle(),this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.fill(),this._ctx.newPath(),this._ctx.appendPath(i)},strokeRect(e,t,n,r){this._ensureSurface(),this._applyCompositing();let i=this._ctx.copyPath();this._hasShadow()&&this._renderShadow(()=>{this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.stroke()}),this._applyStrokeStyle(),this._applyLineStyle(),this._ctx.newPath(),this._ctx.rectangle(e,t,n,r),this._ctx.stroke(),this._ctx.newPath(),this._ctx.appendPath(i)},clearRect(e,t,r,i){this._ensureSurface();let a=this._ctx.copyPath();this._ctx.save(),this._ctx.setOperator(n.Operator.CLEAR),this._ctx.newPath(),this._ctx.rectangle(e,t,r,i),this._ctx.fill(),this._ctx.restore(),this._ctx.newPath(),this._ctx.appendPath(a)},clip(e,t){this._ensureSurface();let r;e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),r=t):r=e,this._ctx.setFillRule(r===`evenodd`?n.FillRule.EVEN_ODD:n.FillRule.WINDING),this._ctx.clip()},isPointInPath(e,t,r,i){this._ensureSurface();let a,o,s;return e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),a=t,o=r,s=i):(a=e,o=t,s=r),this._ctx.setFillRule(s===`evenodd`?n.FillRule.EVEN_ODD:n.FillRule.WINDING),this._ctx.inFill(a,o)},isPointInStroke(e,t,n){return this._ensureSurface(),this._applyLineStyle(),e instanceof Ct?(this._ctx.newPath(),e._replayOnCairo(this._ctx),this._ctx.inStroke(t,n)):this._ctx.inStroke(e,t)},drawImage(e,t,i,a,o,s,c,l,u){this._ensureSurface(),this._applyCompositing();let d,p,m,h,g,_,v,y,b=getDrawImageSource(e);if(!b)return;let{pixbuf:x,imgWidth:S,imgHeight:w}=b;if(a===void 0?(d=0,p=0,m=S,h=w,g=t,_=i,v=S,y=w):s===void 0?(d=0,p=0,m=S,h=w,g=t,_=i,v=a,y=o):(d=t,p=i,m=a,h=o,g=s,_=c,v=l,y=u),!Number.isFinite(d)||!Number.isFinite(p)||!Number.isFinite(m)||!Number.isFinite(h)||!Number.isFinite(g)||!Number.isFinite(_)||!Number.isFinite(v)||!Number.isFinite(y)||m===0||h===0||v===0||y===0)return;this._ctx.save(),this._ctx.rectangle(g,_,v,y),this._ctx.clip(),this._ctx.translate(g,_),this._ctx.scale(v/m,y/h),this._ctx.translate(-d,-p),r.cairo_set_source_pixbuf(this._ctx,x,0,0);let T=asCairoPattern(this._ctx.getSource?.());if(T){let e;e=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?n.Filter.BEST:n.Filter.BILINEAR:n.Filter.NEAREST,T.setFilter(e)}this._state.globalAlpha<1?this._ctx.paintWithAlpha(this._state.globalAlpha):this._ctx.paint(),this._ctx.restore()}};function installDrawingMethods(e){Object.assign(e,Dt)}const Ot={createImageData(e,t){return typeof e==`number`?new OurImageData(Math.abs(e),Math.abs(t)):new OurImageData(e.width,e.height)},getImageData(e,t,n,i){this._ensureSurface(),this._surface.flush();let a=r.pixbuf_get_from_surface(this._surface,e,t,n,i);if(!a)return new OurImageData(n,i);let o=a.get_pixels(),s=a.get_has_alpha(),c=a.get_rowstride(),l=a.get_n_channels(),u=new Uint8ClampedArray(n*i*4);for(let e=0;e<i;e++)for(let t=0;t<n;t++){let r=e*c+t*l,i=(e*n+t)*4;u[i]=o[r],u[i+1]=o[r+1],u[i+2]=o[r+2],u[i+3]=s?o[r+3]:255}return new OurImageData(u,n,i)},putImageData(e,t,a,o,s,c,l){this._ensureSurface();let u=o??0,d=s??0,p=c??e.width,m=l??e.height,h=e.data,g=e.width,_=new Uint8Array(p*m*4);for(let e=0;e<m;e++)for(let t=0;t<p;t++){let n=((d+e)*g+(u+t))*4,r=(e*p+t)*4;_[r]=h[n],_[r+1]=h[n+1],_[r+2]=h[n+2],_[r+3]=h[n+3]}let v=i.Pixbuf.new_from_bytes(_,i.Colorspace.RGB,!0,8,p,m,p*4);this._ctx.save(),this._ctx.setOperator(n.Operator.SOURCE),r.cairo_set_source_pixbuf(this._ctx,v,t+u,a+d),this._ctx.rectangle(t+u,a+d,p,m),this._ctx.fill(),this._ctx.restore()}};function installPixelMethods(e){Object.assign(e,Ot)}function parseFontToDescription(e){let t=e.match(/^\s*(italic|oblique|normal)?\s*(small-caps|normal)?\s*(bold|bolder|lighter|[1-9]00|normal)?\s*(\d+(?:\.\d+)?)(px|pt|em|rem|%)?\s*(?:\/\S+)?\s*(.+)?$/i);if(!t)return a.font_description_from_string(e);let n=t[1]||``,r=t[3]||``,i=parseFloat(t[4])||10,o=(t[5]||`px`).toLowerCase(),s=(t[6]||`sans-serif`).replace(/['"]/g,``).trim();o===`pt`?i=i*96/72:o===`em`||o===`rem`?i*=16:o===`%`&&(i=i/100*16);let c=s;n===`italic`?c+=` Italic`:n===`oblique`&&(c+=` Oblique`),r===`bold`||r===`bolder`||parseInt(r)>=600?c+=` Bold`:(r===`lighter`||parseInt(r)>0&&parseInt(r)<=300)&&(c+=` Light`);let l=a.font_description_from_string(c);return l.set_absolute_size(i*a.SCALE),l}function createTextLayout(e,t){let n=o.create_layout(e._ctx);n.set_text(t,-1),n.get_context().set_base_dir(a.Direction.LTR),n.context_changed();let r=parseFontToDescription(e._state.font);return n.set_font_description(r),n}function getTextAlignOffset(e,t){let[,n]=t.get_pixel_extents(),r=n.width;switch(e._state.textAlign){case`center`:return-r/2;case`right`:case`end`:return-r;default:return 0}}function getTextBaselineOffset(e,t){let n=t.get_font_description()||parseFontToDescription(e._state.font),r=t.get_context().get_metrics(n,null),i=r.get_ascent()/a.SCALE,o=r.get_descent()/a.SCALE,s=i+o;switch(e._state.textBaseline){case`top`:return 0;case`hanging`:return-(i*.2);case`middle`:return-(s/2);case`alphabetic`:return-i;case`ideographic`:return-(i+o*.5);case`bottom`:return-s;default:return-i}}const kt={fillText(e,t,r,i){this._ensureSurface(),this._applyCompositing();let a=createTextLayout(this,e),s=getTextAlignOffset(this,a),c=getTextBaselineOffset(this,a);if(this._hasShadow()){let e=parseColor(this._state.shadowColor);if(e){let[i,l]=this._deviceToUserDistance(this._state.shadowOffsetX,this._state.shadowOffsetY),u=this._state.shadowBlur,d;if(u>0){let[t]=this._deviceToUserDistance(u,0),[,n]=this._deviceToUserDistance(0,u);d=[[i,l,e.a],[i+t,l,e.a*.5],[i-t,l,e.a*.5],[i,l+n,e.a*.5],[i,l-n,e.a*.5]]}else d=[[i,l,e.a]];let p=this._state.imageSmoothingEnabled?n.Antialias.DEFAULT:n.Antialias.NONE;for(let[n,i,l]of d)this._ctx.save(),this._ctx.setAntialias(p),this._ctx.setSourceRGBA(e.r,e.g,e.b,l),this._ctx.moveTo(t+s+n,r+c+i),o.show_layout(this._ctx,a),this._ctx.restore()}}this._applyFillStyle(),this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?n.Antialias.DEFAULT:n.Antialias.NONE),this._ctx.moveTo(t+s,r+c),o.show_layout(this._ctx,a),this._ctx.restore()},strokeText(e,t,r,i){this._ensureSurface(),this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle();let a=createTextLayout(this,e),s=getTextAlignOffset(this,a),c=getTextBaselineOffset(this,a);this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?n.Antialias.DEFAULT:n.Antialias.NONE),this._ctx.moveTo(t+s,r+c),o.layout_path(this._ctx,a),this._ctx.stroke(),this._ctx.restore()},measureText(e){this._ensureSurface();let t=createTextLayout(this,e),[n,r]=t.get_pixel_extents(),i=t.get_baseline()/a.SCALE,o=Math.max(0,i-n.y),s=Math.max(0,n.y+n.height-i),c=t.get_font_description()||parseFontToDescription(this._state.font),l=t.get_context().get_metrics(c,null),u=l.get_ascent()/a.SCALE,d=l.get_descent()/a.SCALE;return{width:r.width,actualBoundingBoxAscent:o,actualBoundingBoxDescent:s,actualBoundingBoxLeft:Math.max(0,-n.x),actualBoundingBoxRight:n.x+n.width,fontBoundingBoxAscent:u,fontBoundingBoxDescent:d,alphabeticBaseline:0,emHeightAscent:u,emHeightDescent:d,hangingBaseline:u*.8,ideographicBaseline:-d}}};function installTextMethods(e){Object.assign(e,kt)}const At={createLinearGradient(e,t,n,r){return new CanvasGradient(`linear`,e,t,n,r)},createRadialGradient(e,t,n,r,i,a){return new CanvasGradient(`radial`,e,t,r,i,n,a)},createPattern(e,t){return wt.create(e,t)}};function installFactoryMethods(e){Object.assign(e,At)}function installAllContextMethods(e){installTransformMethods(e),installPathMethods(e),installDrawingMethods(e),installPixelMethods(e),installTextMethods(e),installFactoryMethods(e)}function createDefaultState(){return{fillStyle:`#000000`,fillColor:{...yt},strokeStyle:`#000000`,strokeColor:{...yt},lineWidth:1,lineCap:`butt`,lineJoin:`miter`,miterLimit:10,lineDash:[],lineDashOffset:0,globalAlpha:1,globalCompositeOperation:`source-over`,shadowColor:`rgba(0, 0, 0, 0)`,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,font:`10px sans-serif`,textAlign:`start`,textBaseline:`alphabetic`,direction:`ltr`,imageSmoothingEnabled:!0,imageSmoothingQuality:`low`}}function cloneState(e){return{...e,fillColor:{...e.fillColor},strokeColor:{...e.strokeColor},lineDash:[...e.lineDash]}}var CanvasRenderingContext2D=class{constructor(e,t){this._stateStack=[],this.canvas=e,this._surfaceWidth=e.width||300,this._surfaceHeight=e.height||150,this._surface=new n.ImageSurface(n.Format.ARGB32,this._surfaceWidth,this._surfaceHeight),this._ctx=new n.Context(this._surface),this._state=createDefaultState()}_ensureSurface(){let e=this.canvas.width||300,t=this.canvas.height||150;(e!==this._surfaceWidth||t!==this._surfaceHeight)&&(this._ctx.$dispose(),this._surface.finish(),this._surfaceWidth=e,this._surfaceHeight=t,this._surface=new n.ImageSurface(n.Format.ARGB32,e,t),this._ctx=new n.Context(this._surface),this._stateStack=[])}_resetState(){this._state=createDefaultState(),this._stateStack=[]}_applyFillStyle(){let e=this._state.fillStyle;if(typeof e==`string`){let e=this._state.fillColor,t=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,t)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof wt&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyStrokeStyle(){let e=this._state.strokeStyle;if(typeof e==`string`){let e=this._state.strokeColor,t=e.a*this._state.globalAlpha;this._ctx.setSourceRGBA(e.r,e.g,e.b,t)}else e instanceof CanvasGradient?this._ctx.setSource(e._getCairoPattern()):e instanceof wt&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyPatternFilter(){let e=asCairoPattern(this._ctx.getSource?.());if(!e)return;let t;t=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?n.Filter.BEST:n.Filter.BILINEAR:n.Filter.NEAREST,e.setFilter(t)}_applyLineStyle(){this._ctx.setLineWidth(this._state.lineWidth),this._ctx.setLineCap(xt[this._state.lineCap]),this._ctx.setLineJoin(St[this._state.lineJoin]),this._ctx.setMiterLimit(this._state.miterLimit),this._ctx.setDash(this._state.lineDash,this._state.lineDashOffset)}_applyCompositing(){let e=bt[this._state.globalCompositeOperation];e!==void 0&&this._ctx.setOperator(e)}_getSurface(){return this._surface}_hasShadow(){if(this._state.shadowBlur===0&&this._state.shadowOffsetX===0&&this._state.shadowOffsetY===0)return!1;let e=parseColor(this._state.shadowColor);return e!==null&&e.a>0}_deviceToUserDistance(e,t){let n=this._ctx.userToDevice(0,0),r=this._ctx.userToDevice(1,0),i=this._ctx.userToDevice(0,1),a=(r[0]??0)-(n[0]??0),o=(r[1]??0)-(n[1]??0),s=(i[0]??0)-(n[0]??0),c=(i[1]??0)-(n[1]??0),l=a*c-o*s;return Math.abs(l)<1e-10?[e,t]:[(c*e-s*t)/l,(-o*e+a*t)/l]}_renderShadow(e){}save(){this._ensureSurface(),this._stateStack.push(cloneState(this._state)),this._ctx.save()}restore(){this._ensureSurface();let e=this._stateStack.pop();e&&(this._state=e,this._ctx.restore())}get fillStyle(){return this._state.fillStyle}set fillStyle(e){if(typeof e==`string`){let t=parseColor(e);t&&(this._state.fillStyle=e,this._state.fillColor=t)}else this._state.fillStyle=e}get strokeStyle(){return this._state.strokeStyle}set strokeStyle(e){if(typeof e==`string`){let t=parseColor(e);t&&(this._state.strokeStyle=e,this._state.strokeColor=t)}else this._state.strokeStyle=e}get lineWidth(){return this._state.lineWidth}set lineWidth(e){e>0&&isFinite(e)&&(this._state.lineWidth=e)}get lineCap(){return this._state.lineCap}set lineCap(e){(e===`butt`||e===`round`||e===`square`)&&(this._state.lineCap=e)}get lineJoin(){return this._state.lineJoin}set lineJoin(e){(e===`miter`||e===`round`||e===`bevel`)&&(this._state.lineJoin=e)}get miterLimit(){return this._state.miterLimit}set miterLimit(e){e>0&&isFinite(e)&&(this._state.miterLimit=e)}get globalAlpha(){return this._state.globalAlpha}set globalAlpha(e){e>=0&&e<=1&&isFinite(e)&&(this._state.globalAlpha=e)}get globalCompositeOperation(){return this._state.globalCompositeOperation}set globalCompositeOperation(e){bt[e]!==void 0&&(this._state.globalCompositeOperation=e)}get imageSmoothingEnabled(){return this._state.imageSmoothingEnabled}set imageSmoothingEnabled(e){this._state.imageSmoothingEnabled=!!e}get imageSmoothingQuality(){return this._state.imageSmoothingQuality}set imageSmoothingQuality(e){(e===`low`||e===`medium`||e===`high`)&&(this._state.imageSmoothingQuality=e)}setLineDash(e){e.some(e=>e<0||!isFinite(e))||(this._state.lineDash=[...e])}getLineDash(){return[...this._state.lineDash]}get lineDashOffset(){return this._state.lineDashOffset}set lineDashOffset(e){isFinite(e)&&(this._state.lineDashOffset=e)}get shadowColor(){return this._state.shadowColor}set shadowColor(e){this._state.shadowColor=e}get shadowBlur(){return this._state.shadowBlur}set shadowBlur(e){e>=0&&isFinite(e)&&(this._state.shadowBlur=e)}get shadowOffsetX(){return this._state.shadowOffsetX}set shadowOffsetX(e){isFinite(e)&&(this._state.shadowOffsetX=e)}get shadowOffsetY(){return this._state.shadowOffsetY}set shadowOffsetY(e){isFinite(e)&&(this._state.shadowOffsetY=e)}get font(){return this._state.font}set font(e){this._state.font=e}get textAlign(){return this._state.textAlign}set textAlign(e){this._state.textAlign=e}get textBaseline(){return this._state.textBaseline}set textBaseline(e){this._state.textBaseline=e}get direction(){return this._state.direction}set direction(e){this._state.direction=e}_toDataURL(e,t){this._surface.flush();let n=imports.gi.Gio,r=imports.gi.GLib,[,i]=r.file_open_tmp(`canvas-XXXXXX.png`);try{this._surface.writeToPNG(i);let[,e]=n.File.new_for_path(i).load_contents(null);return`data:image/png;base64,${r.base64_encode(e)}`}finally{try{r.unlink(i)}catch{}}}_dispose(){this._ctx.$dispose(),this._surface.finish()}};installAllContextMethods(CanvasRenderingContext2D.prototype),defineGlobal(`HTMLCanvasElement`,ht),defineGlobal(`CanvasRenderingContext2D`,CanvasRenderingContext2D),defineGlobal(`DOMMatrix`,gt),defineGlobal(`DOMMatrixReadOnly`,_t);const jt=Symbol.for(`gjsify_canvas2d_context`);ht.registerContextFactory(`2d`,(e,t)=>{let n=e,r=n[jt];if(r)return r;let i=new CanvasRenderingContext2D(e,t);return n[jt]=i,i});var CharacterData=class extends st{constructor(e=``){super(),this[z]=G.TEXT_NODE,this._data=e}get data(){return this._data}set data(e){this._data=e}get textContent(){return this._data}set textContent(e){this._data=e}get nodeValue(){return this._data}set nodeValue(e){this._data=e}get length(){return this._data.length}appendData(e){this._data+=e}deleteData(e,t){this._data=this._data.substring(0,e)+this._data.substring(e+t)}insertData(e,t){this._data=this._data.substring(0,e)+t+this._data.substring(e)}replaceData(e,t,n){this._data=this._data.substring(0,e)+n+this._data.substring(e+t)}substringData(e,t){return this._data.substring(e,e+t)}cloneNode(e=!1){return new this.constructor(this._data)}get[Symbol.toStringTag](){return`CharacterData`}},Mt=class Comment extends CharacterData{constructor(e=``){super(e),this[z]=G.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new Comment(this.data)}get[Symbol.toStringTag](){return`Comment`}},Nt=class Text extends CharacterData{constructor(e=``){super(e),this[z]=G.TEXT_NODE}get nodeName(){return`#text`}get wholeText(){let e=this.data,t=this.previousSibling;for(;t&&t instanceof Text;)e=t.data+e,t=t.previousSibling;let n=this.nextSibling;for(;n&&n instanceof Text;)e+=n.data,n=n.nextSibling;return e}splitText(e){let t=this.data.substring(e);this.data=this.data.substring(0,e);let n=new Text(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}cloneNode(e=!1){return new Text(this.data)}get[Symbol.toStringTag](){return`Text`}},Pt=class DocumentFragment extends st{constructor(){super(),this[z]=G.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[H]}get childElementCount(){return this[H].length}get firstElementChild(){return this[H][0]??null}get lastElementChild(){let e=this[H];return e[e.length-1]??null}get textContent(){let e=``;for(let t of this.childNodes)t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){for(;this.firstChild;)this.removeChild(this.firstChild);e&&this.appendChild(new Nt(e))}append(...e){for(let t of e)typeof t==`string`?this.appendChild(new Nt(t)):this.appendChild(t)}prepend(...e){let t=this.firstChild;for(let n of e)typeof n==`string`?this.insertBefore(new Nt(n),t):this.insertBefore(n,t)}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}getElementById(e){for(let t of this.children){if(t.id===e)return t;let n=this._findById(t,e);if(n)return n}return null}_findById(e,t){for(let n of e.children){if(n.id===t)return n;let e=this._findById(n,t);if(e)return e}return null}cloneNode(e=!1){let t=new DocumentFragment;if(e)for(let e of this.childNodes)t.appendChild(e.cloneNode(!0));return t}get[Symbol.toStringTag](){return`DocumentFragment`}},Ft=s;I(),A(),N();var HTMLImageElement=class extends HTMLElement$1{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[Ne]=`IMG`,this[Pe]=`img`,this[Fe]=ct.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let t=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let n=e.indexOf(`,`);if(n===-1){this._complete=!0,this.dispatchEvent(new Event(`error`));return}let r=e.slice(5,n),i=e.slice(n+1),a=r.includes(`;base64`);try{let e;e=a?k.base64_decode(i):new TextEncoder().encode(decodeURIComponent(i));let n=k.Bytes.new(e),r=M.MemoryInputStream.new_from_bytes(n);this._pixbuf=Ft.Pixbuf.new_from_stream(r,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&F.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&F.warn(`[img] error data:: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event(`error`))}return}let n;if(e.startsWith(`file://`))n=k.filename_from_uri(e)[0];else if(e.startsWith(`http://`)||e.startsWith(`https://`)){this._complete=!0,this.dispatchEvent(new Event(`error`));return}else{let t=k.path_get_dirname(c.programInvocationName);n=k.build_filenamev([t,e])}try{t&&F.log(`[img] load ${n}`),this._pixbuf=Ft.Pixbuf.new_from_file(n),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&F.log(`[img] ok ${n} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&F.warn(`[img] error ${n}: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new Event(`error`))}}get srcset(){return this.getAttribute(`srcset`)??``}set srcset(e){this.setAttribute(`srcset`,e)}get useMap(){return this.getAttribute(`usemap`)??``}set useMap(e){this.setAttribute(`usemap`,e)}get height(){if(this._pixbuf)return this._pixbuf.get_height();let e=this.getAttribute(`height`);return e===null?0:Number(e)}set height(e){this.setAttribute(`height`,String(e))}get width(){if(this._pixbuf)return this._pixbuf.get_width();let e=this.getAttribute(`width`);return e===null?0:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get isMap(){return this.hasAttribute(`ismap`)}set isMap(e){e?this.setAttribute(`ismap`,``):this.removeAttribute(`ismap`)}decode(){return Promise.resolve()}cloneNode(e=!1){return super.cloneNode(e)}getImageData(){if(!this._pixbuf)return null;let e=this._pixbuf.get_has_alpha()?this._pixbuf:this._pixbuf.add_alpha(!1,0,0,0)??this._pixbuf;return{colorSpace:`srgb`,data:new Uint8ClampedArray(e.get_pixels()),height:e.get_height(),width:e.get_width()}}isPixbuf(){return!!this._pixbuf}get[Symbol.toStringTag](){return`HTMLImageElement`}},HTMLMediaElement=class extends HTMLElement$1{constructor(...e){super(...e),this._src=``,this._srcObject=null,this.currentTime=0,this.duration=NaN,this.paused=!0,this.ended=!1,this.volume=1,this.muted=!1,this.defaultMuted=!1,this.loop=!1,this.autoplay=!1,this.preload=``,this.playbackRate=1,this.defaultPlaybackRate=1,this.readyState=0,this.networkState=0}get buffered(){return{length:0,start:()=>0,end:()=>0}}get seekable(){return{length:0,start:()=>0,end:()=>0}}get played(){return{length:0,start:()=>0,end:()=>0}}get src(){return this._src}set src(e){this._src=e,this._srcObject=null,this.dispatchEvent(new Event(`srcchange`))}get srcObject(){return this._srcObject}set srcObject(e){this._srcObject=e,this._src=``,this.dispatchEvent(new Event(`srcobjectchange`))}play(){return this.paused=!1,this.ended=!1,this.dispatchEvent(new Event(`play`)),Promise.resolve()}pause(){this.paused=!0,this.dispatchEvent(new Event(`pause`))}load(){this.readyState=0,this.networkState=2,this.dispatchEvent(new Event(`loadstart`))}canPlayType(e){return``}static{this.HAVE_NOTHING=0}static{this.HAVE_METADATA=1}static{this.HAVE_CURRENT_DATA=2}static{this.HAVE_FUTURE_DATA=3}static{this.HAVE_ENOUGH_DATA=4}static{this.NETWORK_EMPTY=0}static{this.NETWORK_IDLE=1}static{this.NETWORK_LOADING=2}static{this.NETWORK_NO_SOURCE=3}get[Symbol.toStringTag](){return`HTMLMediaElement`}};const It=1e9;function secondsToGstTime(e){return BigInt(Math.round(e*It))}function gstTimeToSeconds(e){return Number(e)/It}var HTMLVideoElement=class extends HTMLMediaElement{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[Ne]=`VIDEO`,this[Pe]=`video`,this[Fe]=ct.html;let e=this;Object.defineProperty(this,"paused",{get(){if(!e._pipeline)return!0;let[,t]=e._pipeline.get_state(0n);return t!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,"currentTime",{get(){if(!e._pipeline)return 0;let[t,n]=e._pipeline.query_position(3);return t?gstTimeToSeconds(n):0},set(t){e._pipeline?.seek(1,3,5,1,secondsToGstTime(t),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,"duration",{get(){if(!e._pipeline)return NaN;let[t,n]=e._pipeline.query_duration(3);return t&&Number(n)>0?gstTimeToSeconds(n):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,"volume",{get(){return e._playbin()?.volume??1},set(t){let n=e._playbin();n&&(n.volume=Math.max(0,Math.min(1,t)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,"muted",{get(){return e._playbin()?.mute??!1},set(t){let n=e._playbin();n&&(n.mute=t)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new Event(`play`)),this.dispatchEvent(new Event(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new Event(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};const Lt=new class Document extends st{static{this._elementFactories=new Map}constructor(){super(),this.body=new HTMLElement$1,this.head=new HTMLElement$1,this.documentElement=new HTMLElement$1,this.appendChild(this.documentElement),this.documentElement.appendChild(this.body)}static registerElementFactory(e,t){Document._elementFactories.set(e.toLowerCase(),t)}createElementNS(e,t){let n=t.toLowerCase();switch(n){case`img`:return new HTMLImageElement;case`video`:return new HTMLVideoElement;case`canvas`:return new ht;default:{let e=Document._elementFactories.get(n);return e?e():new HTMLElement$1}}}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new Nt(e)}createComment(e){return new Mt(e)}createDocumentFragment(){return new Pt}createEvent(e){return new Event(e)}getElementById(e){return this._findById(this.body,e)}_findById(e,t){if(e.id===t)return e;for(let n of e.children){let e=this._findById(n,t);if(e)return e}return null}get[Symbol.toStringTag](){return`Document`}};var DOMTokenList=class{constructor(e,t){this._ownerElement=e,this._attributeName=t}_getTokens(){let e=this._ownerElement.getAttribute(this._attributeName);return e?e.split(/\s+/).filter(e=>e.length>0):[]}_setTokens(e){let t=e.join(` `);t?this._ownerElement.setAttribute(this._attributeName,t):this._ownerElement.removeAttribute(this._attributeName)}get length(){return this._getTokens().length}get value(){return this._ownerElement.getAttribute(this._attributeName)??``}set value(e){e?this._ownerElement.setAttribute(this._attributeName,e):this._ownerElement.removeAttribute(this._attributeName)}item(e){let t=this._getTokens();return e>=0&&e<t.length?t[e]:null}contains(e){return this._getTokens().includes(e)}add(...e){let t=this._getTokens();for(let n of e)n&&!t.includes(n)&&t.push(n);this._setTokens(t)}remove(...e){let t=this._getTokens().filter(t=>!e.includes(t));this._setTokens(t)}toggle(e,t){let n=this.contains(e);return t===void 0?n?(this.remove(e),!1):(this.add(e),!0):t?(this.add(e),!0):(this.remove(e),!1)}replace(e,t){let n=this._getTokens(),r=n.indexOf(e);return r===-1?!1:(n[r]=t,this._setTokens(n),!0)}supports(e){return!0}forEach(e){let t=this._getTokens();for(let n=0;n<t.length;n++)e(t[n],n,this)}keys(){return this._getTokens().keys()}values(){return this._getTokens().values()}entries(){return this._getTokens().entries()}[Symbol.iterator](){return this._getTokens().values()}toString(){return this.value}get[Symbol.toStringTag](){return`DOMTokenList`}};I(),defineGlobal(`Text`,Nt),defineGlobal(`Comment`,Mt),defineGlobal(`DocumentFragment`,Pt),defineGlobal(`DOMTokenList`,DOMTokenList),defineGlobal(`document`,Lt),defineGlobalIfMissing(`self`,globalThis);var Window=class{};defineGlobalIfMissing(`Window`,Window),defineGlobalIfMissing(`window`,globalThis),defineGlobalIfMissing(`focus`,()=>{}),defineGlobalIfMissing(`blur`,()=>{});{let e=globalThis;if(typeof e.addEventListener!=`function`){let t=new EventTarget;e.__gjsify_globalEventTarget=t,e.addEventListener=(e,n,r)=>t.addEventListener(e,n,r),e.removeEventListener=(e,n,r)=>t.removeEventListener(e,n,r),e.dispatchEvent=e=>t.dispatchEvent(e)}}defineGlobalIfMissing(`devicePixelRatio`,1),defineGlobalIfMissing(`scrollX`,0),defineGlobalIfMissing(`scrollY`,0),defineGlobalIfMissing(`pageXOffset`,0),defineGlobalIfMissing(`pageYOffset`,0),defineGlobalIfMissing(`alert`,(...e)=>F.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0}),globalThis.navigator===void 0&&(globalThis.navigator={});function atobPolyfill(e){if(typeof globalThis.atob==`function`)return globalThis.atob(e);let t=e.replace(/[=\s]/g,``),n=``,r=0,i=0;for(let e=0;e<t.length;e++)r=r<<6|Rt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n+=String.fromCharCode(r>>i&255));return n}function btoaPolyfill(e){if(typeof globalThis.btoa==`function`)return globalThis.btoa(e);let t=``,n=0;for(;n+2<e.length;n+=3){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8|e.charCodeAt(n+2);t+=K[r>>18&63]+K[r>>12&63]+K[r>>6&63]+K[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=K[r>>18&63]+K[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=K[r>>18&63]+K[r>>12&63]+K[r>>6&63]+`=`}return t}function base64Decode(e){let t=e.replace(/[=\s]/g,``),n=new Uint8Array(t.length*3>>2),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<6|Rt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[a++]=r>>i&255);return n.subarray(0,a)}function base64Encode(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],a=r+1<n?e[r+1]:0,o=r+2<n?e[r+2]:0;t+=K[i>>2],t+=K[(i&3)<<4|a>>4],t+=r+1<n?K[(a&15)<<2|o>>6]:`=`,t+=r+2<n?K[o&63]:`=`}return t}var K,Rt,zt=__esmMin(()=>{K=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Rt=new Uint8Array(256);for(let e=0;e<64;e++)Rt[K.charCodeAt(e)]=e});function normalizeEncoding(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(e){let t=(``+e).toLowerCase().replace(/-/g,``);if(!Bt.includes(t))throw TypeError(`Unknown encoding: ${e}`)}var Bt,Vt=__esmMin(()=>{Bt=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(e,t){switch(t){case`utf8`:return Ht.encode(e);case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`latin1`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`base64`:return base64Decode(e.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(e.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++){let t=parseInt(e[r*2],16),i=parseInt(e[r*2+1],16);if(Number.isNaN(t)||Number.isNaN(i))break;n[r]=t<<4|i}return n}case`utf16le`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}default:return Ht.encode(e)}}function decodeString(e,t,n,r){let i=n!==void 0||r!==void 0?e.subarray(n??0,r??e.length):e;switch(t){case`utf8`:return Ut.decode(i);case`ascii`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]&127);return e}case`latin1`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return e}case`base64`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return btoaPolyfill(e)}case`base64url`:return decodeString(i,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let e=``;for(let t=0;t<i.length;t++)e+=i[t].toString(16).padStart(2,`0`);return e}case`utf16le`:{let e=``;for(let t=0;t+1<i.length;t+=2)e+=String.fromCharCode(i[t]|i[t+1]<<8);return e}default:return Ut.decode(i)}}function checkOffset(e,t,n){if(e+t>n)throw RangeError(`Attempt to access memory outside buffer bounds`)}var Ht,Ut,Wt=__esmMin(()=>{zt(),Ht=new TextEncoder,Ut=new TextDecoder}),Gt,q,Kt,qt,Jt,SlowBuffer,Yt=__esmMin(()=>{Wt(),Vt(),Gt=typeof SharedArrayBuffer<`u`,q=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(e,t,n){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);if(e<0)throw RangeError(`The value "${e}" is invalid for option "size"`);let r=new Buffer(e);return t!==void 0&&t!==0&&r.fill(t,0,e,n),r}static allocUnsafe(e){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);return new Buffer(e)}static allocUnsafeSlow(e){return Buffer.allocUnsafe(e)}static from(e,t,n){if(typeof e==`string`){let n=normalizeEncoding(t);if(t&&typeof t==`string`){let e=(``+t).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(e)||checkEncoding(t)}let r=encodeString(e,n);return new Buffer(r.buffer,r.byteOffset,r.byteLength)}if(ArrayBuffer.isView(e)){let t=new Buffer(e.buffer,e.byteOffset,e.byteLength),n=new Buffer(t.length);return n.set(t),n}if(e instanceof ArrayBuffer){let r=t||0;return new Buffer(e,r,n===void 0?e.byteLength-r:n)}if(Gt&&e instanceof SharedArrayBuffer){let r=t||0,i=n===void 0?e.byteLength-r:n;return new Buffer(new Uint8Array(e,r,i))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let r=e,i=t||0,a=n===void 0?r.byteLength-i:n,o=r.viewBytes(i,a);return new Buffer(o.buffer,o.byteOffset,o.byteLength)}if(Array.isArray(e)){let t=new Buffer(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]&255;return t}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(t)}static byteLength(e,t){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Gt&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(t)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let t=e.length;for(;t>0&&(e[t-1]===`=`||e[t-1]===` `);)t--;return t*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return e.length<t.length?-1:+(e.length>t.length)}static concat(e,t){if(e.length===0)return Buffer.alloc(0);if(t===void 0){t=0;for(let n=0;n<e.length;n++)t+=e[n].length}let n=Buffer.alloc(t),r=0;for(let i=0;i<e.length;i++){let a=e[i],o=Math.min(a.length,t-r);o<=0||(n.set(a.subarray(0,o),r),r+=o)}return n}static poolSize=8192;toString(e,t,n){let r=normalizeEncoding(e);return decodeString(this,r,t,n)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==e[t])return!1;return!0}compare(e,t,n,r,i){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let a=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,o=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(a,o)}copy(e,t=0,n=0,r){let i=r??this.length,a=Math.min(i-n,e.length-t);return a<=0?0:(e.set(this.subarray(n,n+a),t),a)}slice(e,t){let n=e??0,r=t??this.length,i=super.subarray(n,r);return new Buffer(i.buffer,i.byteOffset,i.byteLength)}subarray(e,t){let n=super.subarray(e,t);return new Buffer(n.buffer,n.byteOffset,n.byteLength)}write(e,t,n,r){t??=0;let i=encodeString(e,normalizeEncoding(r||(typeof n==`string`?n:void 0))),a=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,o=Math.min(i.length,a);return this.set(i.subarray(0,o),t),o}fill(e,t,n,r){let i=t??0,a=n??this.length;if(typeof e==`number`)super.fill(e&255,i,a);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,a);else if(t.length===1)super.fill(t[0],i,a);else for(let e=i;e<a;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,a);else for(let t=i;t<a;t++)this[t]=e[(t-i)%e.length];return this}indexOf(e,t,n){if(typeof e==`number`)return super.indexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t??0;outer:for(let e=i;e<=this.length-r.length;e++){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}lastIndexOf(e,t,n){if(typeof e==`number`)return t===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t===void 0?this.length-r.length:Math.min(t,this.length-r.length);outer:for(let e=i;e>=0;e--){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}includes(e,t,n){return this.indexOf(e,t,n)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let t=this[e]<<8|this[e+1];return t&32768?t|4294901760:t}readInt16LE(e=0){checkOffset(e,2,this.length);let t=this[e]|this[e+1]<<8;return t&32768?t|4294901760:t}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n}readUIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n}readIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n>=2**(8*t-1)&&(n-=2**(8*t)),n}readIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n>=2**(8*t-1)&&(n-=2**(8*t)),n}writeUInt8(e,t=0){return checkOffset(t,1,this.length),this[t]=e&255,t+1}writeUInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeUInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeUInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeUInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeInt8(e,t=0){return checkOffset(t,1,this.length),e<0&&(e=255+e+1),this[t]=e&255,t+1}writeInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeFloatBE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!1),t+4}writeFloatLE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!0),t+4}writeDoubleBE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!1),t+8}writeDoubleLE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!0),t+8}writeBigInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!1),t+8}writeBigInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!0),t+8}writeBigUInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!1),t+8}writeBigUInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!0),t+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2){let e=this[t];this[t]=this[t+1],this[t+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4){let e=this[t],n=this[t+1];this[t]=this[t+3],this[t+1]=this[t+2],this[t+2]=n,this[t+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8){let e=this[t],n=this[t+1],r=this[t+2],i=this[t+3];this[t]=this[t+7],this[t+1]=this[t+6],this[t+2]=this[t+5],this[t+3]=this[t+4],this[t+4]=i,this[t+5]=r,this[t+6]=n,this[t+7]=e}return this}},Kt=2**31-1,qt=2**28-16,Jt={MAX_LENGTH:Kt,MAX_STRING_LENGTH:qt},SlowBuffer=class extends q{constructor(e){super(e)}}}),Xt=__exportAll$4({Blob:()=>x,Buffer:()=>q,File:()=>S,INSPECT_MAX_BYTES:()=>50,SlowBuffer:()=>SlowBuffer,atob:()=>Zt,atobPolyfill:()=>atobPolyfill,base64Decode:()=>base64Decode,base64Encode:()=>base64Encode,btoa:()=>Qt,btoaPolyfill:()=>btoaPolyfill,checkEncoding:()=>checkEncoding,constants:()=>Jt,default:()=>$t,kMaxLength:()=>Kt,kStringMaxLength:()=>qt,normalizeEncoding:()=>normalizeEncoding}),Zt,Qt,$t,J=__esmMin(()=>{zt(),w(),Vt(),Yt(),Zt=globalThis.atob,Qt=globalThis.btoa,$t={Buffer:q,SlowBuffer,Blob:x,File:S,atob:Zt,btoa:Qt,kMaxLength:Kt,kStringMaxLength:qt,constants:Jt,INSPECT_MAX_BYTES:50}});J(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:q,enumerable:!1,writable:!0,configurable:!0}),A(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return k.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=k.base64_decode(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return n},enumerable:!0,writable:!0,configurable:!0}),L(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:_e,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let t=null;try{t=e.GioUnix??null}catch{}if(!t)try{t=e.Gio??null}catch{}return t}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const en=getMonotonicTime();function hrtime(e){let t=getMonotonicTime()-en,n=Number(t/1000000000n),r=Number(t%1000000000n);if(e){let t=n-e[0],i=r-e[1];return i<0&&(t--,i+=1e9),[t,i]}return[n,r]}function hrtimeBigint(){return getMonotonicTime()-en}function detectGjsVersion(){try{let e=getGjsGlobal().imports?.system;if(e?.version!==void 0){let t=Number(e.version);return`${Math.floor(t/1e4)}.${Math.floor(t%1e4/100)}.${t%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),t={node:`20.0.0`};return e&&(t.gjs=e),{version:`v20.0.0`,versions:t,title:`gjs`}}function detectPpid(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/PPid:\s+(\d+)/);if(e)return parseInt(e[1],10)}}}catch{}return 0}function detectPlatform(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e&&e.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/stat`);if(t){let e=new TextDecoder().decode(t),n=parseInt(e,10);if(!isNaN(n))return n}}}catch{}return 0}function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return new Proxy({},{get(t,n){if(typeof n==`string`)return e.getenv(n)??void 0},set(t,n,r){return typeof n==`string`?(e.setenv(n,String(r),!0),!0):!1},deleteProperty(t,n){return typeof n==`string`?(e.unsetenv(n),!0):!1},has(t,n){return typeof n==`string`?e.getenv(n)!==null:!1},ownKeys(t){return e.listenv()},getOwnPropertyDescriptor(t,n){if(typeof n!=`string`)return;let r=e.getenv(n);if(r!==null)return{configurable:!0,enumerable:!0,writable:!0,value:r}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let e=getGjsGlobal().imports?.system;if(e?.programArgs)return[`gjs`,e.programInvocationName||``,...e.programArgs]}catch{}return[`gjs`]}function getExecPath(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let e=getGjsGlobal().imports?.system;if(e?.programInvocationName)return e.programInvocationName}catch{}return`/usr/bin/gjs`}function getCwd(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function chdir(e){let t=getGjsGlobal().imports?.gi?.GLib;try{if(t?.chdir){if(!t.file_test(e,16)){let t=Error(`ENOENT: no such file or directory, chdir '${e}'`);throw t.code=`ENOENT`,t.syscall=`chdir`,t.path=e,t}t.chdir(e);return}}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)throw e}if(!t){let t=globalThis.process;if(t&&typeof t.chdir==`function`){t.chdir(e);return}}throw Error(`process.chdir() is not supported in this environment`)}L();function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,a=n?.SOURCE_REMOVE,o=n?.PRIORITY_DEFAULT;if(r?.exit&&i&&typeof o==`number`&&typeof a==`boolean`)return ensureMainLoop(),i(o,()=>(quitMainLoop(),r.exit(e),a)),new Promise(()=>{});try{r?.exit&&r.exit(e)}catch{}let s=globalThis.process;throw s&&typeof s.exit==`function`&&s.exit(e),Error(`process.exit(${e})`)}function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,t){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`;return n.spawn_command_line_sync(`kill ${i} ${e}`),!0}}catch{}if(!isGjs()){let n=globalThis.process;if(n&&typeof n.kill==`function`)return n.kill(e,t)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[,t]=e.file_get_contents(`/proc/self/status`);if(t){let e=new TextDecoder().decode(t).match(/VmRSS:\s+(\d+)/),n=e?parseInt(e[1],10)*1024:0;return{rss:n,heapTotal:n,heapUsed:n,external:0,arrayBuffers:0}}}}catch{}if(!isGjs()){let e=globalThis.process;if(e&&typeof e.memoryUsage==`function`)return e.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(e){if(!isGjs()){let t=globalThis.process;if(t&&typeof t.cpuUsage==`function`)return t.cpuUsage(e)}return{user:0,system:0}}let tn=null;const nn=globalThis.imports?.gi;if(nn)try{tn=nn.GjsifyTerminal}catch{}const rn=tn;function onceWrapper(){let{target:e,type:t,listener:n}=this;return this.wrapperFn&&e.removeListener(t,this.wrapperFn),n.apply(e,Array.from(arguments))}function _onceWrap(e,t,n){let r={target:e,type:t,listener:n,wrapperFn:void 0},i=onceWrapper.bind(r);return r.wrapperFn=i,i.listener=n,i}function arrayClone(e){switch(e.length){case 0:return[];case 1:return[e[0]];case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];default:return e.slice()}}function checkListener(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}function validateNumber(e,t){if(typeof e!=`number`||e!==e)throw TypeError(`The "${t}" argument must be of type number. Received type ${typeof e}`)}function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function unwrapListeners(e){let t=Array.from({length:e.length});for(let n=0;n<t.length;++n)t[n]=e[n].listener??e[n];return t}function createAbortError$1(e){let t=Error(`The operation was aborted`);return t.name=`AbortError`,t.code=`ABORT_ERR`,e?.reason&&(t.cause=e.reason),t}var an,on,sn,cn=__esmMin(()=>{I(),an=Symbol(`kCapture`),on=Symbol.for(`nodejs.rejection`),sn=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=on;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(e){if(typeof e!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=e}_events;_eventsCount;_maxListeners;[an];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[an]=e?.captureRejections??EventEmitter._captureRejections}setMaxListeners(e){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e);return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(e,...t){let n=this._events,r=e===`error`;if(n!==void 0)r&&n[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...t),r&&=n.error===void 0;else if(!r)return!1;if(r){let e;if(e=t.length>0?t[0]:Error(`Unhandled error.`),e instanceof Error)throw e;let n=Error(`Unhandled error. (`+e+`)`);throw n.context=e,n}let i=n[e];if(i===void 0)return!1;if(typeof i==`function`){let n=i.apply(this,t);n!=null&&this[an]&&this._addCatch(n,e,t)}else{let n=arrayClone(i),r=n.length;for(let i=0;i<r;++i){let r=n[i].apply(this,t);r!=null&&this[an]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[on];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[an];try{this[an]=!1,this.emit(`error`,e)}finally{this[an]=t}}})}addListener(e,t){return this._addListener(e,t,!1)}on(e,t){return this._addListener(e,t,!1)}prependListener(e,t){return this._addListener(e,t,!0)}_addListener(e,t,n){checkListener(t);let r=this._events;r===void 0?(r=this._events=Object.create(null),this._eventsCount=0):r.newListener!==void 0&&(this.emit(`newListener`,e,t.listener??t),r=this._events);let i=r[e];i===void 0?(r[e]=t,++this._eventsCount):typeof i==`function`?r[e]=n?[t,i]:[i,t]:n?i.unshift(t):i.push(t);let a=this.getMaxListeners();if(a>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>a&&!r[e].warned){typeof r[e]!=`function`&&(r[e].warned=!0);let n=Error(`Possible EventEmitter memory leak detected. ${t} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);n.name=`MaxListenersExceededWarning`,F.warn(n.message)}}return this}once(e,t){return checkListener(t),this.on(e,_onceWrap(this,e,t)),this}prependOnceListener(e,t){return checkListener(t),this.prependListener(e,_onceWrap(this,e,t)),this}removeListener(e,t){checkListener(t);let n=this._events;if(n===void 0)return this;let r=n[e];if(r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit(`removeListener`,e,r.listener??t));else if(typeof r!=`function`){let i=-1;for(let e=r.length-1;e>=0;e--)if(r[e]===t||r[e].listener===t){i=e;break}if(i<0)return this;i===0?r.shift():spliceOne(r,i),r.length===1&&(n[e]=r[0]),n.removeListener!==void 0&&this.emit(`removeListener`,e,t.listener??t)}return this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=this._events;if(t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){let e=Object.keys(t);for(let t=0;t<e.length;++t){let n=e[t];n!==`removeListener`&&this.removeAllListeners(n)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let n=t[e];if(typeof n==`function`)this.removeListener(e,n);else if(n!==void 0)for(let t=n.length-1;t>=0;t--)this.removeListener(e,n[t]);return this}listeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n.listener??n]:unwrapListeners(n)}rawListeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n]:arrayClone(n)}listenerCount(e){let t=this._events;if(t===void 0)return 0;let n=t[e];return n===void 0?0:typeof n==`function`?1:n.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,t,n){return new Promise((r,i)=>{let a=n?.signal;if(a?.aborted){i(createAbortError$1(a));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{a&&a.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$1(a))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),a&&a.addEventListener(`abort`,abortHandler,{once:!0});return}let o=e,eventHandler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&o.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{o.removeListener(t,eventHandler),a&&a.removeEventListener(`abort`,abortHandler),i(e)},o.once(`error`,errorHandler)),o.once(t,eventHandler);let abortHandler=()=>{o.removeListener(t,eventHandler),errorHandler&&o.removeListener(`error`,errorHandler),i(createAbortError$1(a))};a&&a.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,t,n){let r=n?.signal;if(r?.aborted)throw createAbortError$1(r);let i=n?.highWaterMark??2**53-1,a=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(a,`lowWaterMark`);let o=[],s=[],c=null,l=!1,u=!1,eventHandler=(...t)=>{if(s.length>0){let{resolve:e}=s.shift();e({value:t,done:!1})}else o.push(t),o.length>=i&&!u&&(u=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(c=e,s.length>0){let{reject:t}=s.shift();t(e)}d.return()},abortHandler=()=>{errorHandler(createAbortError$1(r))};e.on(t,eventHandler),t!==`error`&&e.on(`error`,errorHandler),r&&r.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(t,eventHandler),e.removeListener(`error`,errorHandler),r&&r.removeEventListener(`abort`,abortHandler),l=!0;for(let{resolve:e}of s)e({value:void 0,done:!0});s.length=0,o.length=0},d={next(){if(o.length>0){let t=o.shift();return u&&o.length<a&&(u=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(c){let e=Promise.reject(c);return c=null,e}return l?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{s.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return l||(c=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return d}static listenerCount(e,t){return e.listenerCount(t)}static getEventListeners(e,t){return typeof e.listeners==`function`?e.listeners(t):[]}static setMaxListeners(e,...t){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(t.length===0)EventEmitter.defaultMaxListeners=e;else for(let n of t)typeof n.setMaxListeners==`function`&&n.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,t){e.aborted&&Promise.resolve().then(()=>t());let handler=()=>t();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}},sn.EventEmitter=sn;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=sn.prototype[e];typeof t==`function`&&Object.defineProperty(sn.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(sn.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(sn.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(sn.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name(createAbortError$1,`createAbortError`)}),ln=__exportAll$4({EventEmitter:()=>Y,addAbortListener:()=>yn,captureRejectionSymbol:()=>un,default:()=>Y,defaultMaxListeners:()=>fn,errorMonitor:()=>dn,getEventListeners:()=>_n,getMaxListeners:()=>mn,listenerCount:()=>vn,on:()=>gn,once:()=>hn,setMaxListeners:()=>pn}),Y,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn=__esmMin(()=>{cn(),L(),Y=makeCallable(sn),Y.EventEmitter=Y,un=Y.captureRejectionSymbol,dn=Y.errorMonitor,fn=Y.defaultMaxListeners,pn=Y.setMaxListeners,mn=Y.getMaxListeners,hn=Y.once,gn=Y.on,_n=Y.getEventListeners,vn=Y.listenerCount,yn=Y.addAbortListener});I(),bn(),L();const xn=new TextEncoder;var ProcessWriteStream=class extends Y{fd;writable=!0;_outGio=null;constructor(e){super(),this.fd=e;let t=getGioNamespace();if(t){let e=t.UnixOutputStream??t.OutputStream;if(e)try{this._outGio=e.new(this.fd,!1)}catch{}}}write(e){if(this._outGio)try{let t=typeof e==`string`?xn.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?F.error(e):F.log(e),!0}get isTTY(){if(rn)return rn.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(rn){let[e,,t]=rn.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(t>0)return t}}catch{}return 80}end(){}destroy(){}get rows(){if(rn){let[e,t]=rn.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`LINES`)??`0`,10);if(t>0)return t}}catch{}return 24}},ProcessReadStream=class extends Y{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return rn?rn.Terminal.is_tty(this.fd):!1}setRawMode(e){return rn&&rn.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`];if(new n.SubprocessLauncher({flags:r}).spawnv(i).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let e=globalThis.imports?.gi,t=e?.GLib??e?.GLib;t?.idle_add?t.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let e=this._gio.UnixInputStream??this._gio.InputStream;if(!e){this._reading=!1;return}try{this._stdinGio=e.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(e,t)=>{this._pendingRead=!1;try{let n=e.read_bytes_finish(t)?.get_data?.()??null;if(n&&n.byteLength>0)this.emit(`data`,Buffer.from(n));else if(n!==null&&n.byteLength===0){this._reading=!1,this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};I(),bn();const Sn=Date.now();var Process=class extends Y{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),this.arch=detectArch(),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid(),this.ppid=detectPpid();let e=detectVersionInfo();this.version=e.version,this.versions=e.versions,this.title=e.title}cwd(){return getCwd()}chdir(e){chdir(e)}kill(e,t){return killPid(e,t)}exit(e){return this.exitCode=e??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(e,...t){typeof queueMicrotask==`function`?queueMicrotask(()=>e(...t)):Promise.resolve().then(()=>e(...t))}hrtime(e){return hrtime(e)}uptime(){return(Date.now()-Sn)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(e){return cpuUsage(e)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(e){return 18}emitWarning(e,t){F.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const X=new Process;if(rn)try{let e=new rn.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{X.stdout.emit(`resize`),X.stderr.emit(`resize`)}),e.start()}catch{}X.platform,X.arch,X.env,X.argv,X.argv0,X.execPath,X.pid,X.ppid,X.version,X.versions,X.cwd.bind(X),X.chdir.bind(X),X.exit.bind(X),X.nextTick.bind(X),Object.assign(X.hrtime.bind(X),{bigint:hrtimeBigint}),X.uptime.bind(X),X.memoryUsage.bind(X),X.cpuUsage.bind(X),X.kill.bind(X),X.abort.bind(X),X.umask.bind(X),X.emitWarning.bind(X),X.execArgv,X.config,X.stdout,X.stderr,X.stdin,L(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:X,enumerable:!1,writable:!0,configurable:!0}),L(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const Cn=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._repeat=r,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let t=e.timeout_add.bind(e);this._id=t(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){if(e instanceof GjsifyTimeout)e._cancel();else if(typeof e==`number`)try{getGLib()?.Source.remove(e)}catch{}}if(Cn){let setT=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!1),setI=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate$1(e,...t){return setTimeout(e,0,...t)}__name(setImmediate$1,`setImmediate`);function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate$1,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});var wn=__exportAll$4({URL:()=>Z,URLSearchParams:()=>En,default:()=>Dn,domainToASCII:()=>domainToASCII,domainToUnicode:()=>domainToUnicode,fileURLToPath:()=>fileURLToPath,format:()=>format$3,parse:()=>parse$3,pathToFileURL:()=>pathToFileURL,resolve:()=>resolve$2});function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function encodeComponent(e){return encodeURIComponent(e).replace(/%20/g,`+`)}function parse$3(e,t,n){if(typeof e!=`string`)throw TypeError(`The "url" argument must be of type string. Received type `+typeof e);let r={protocol:null,slashes:null,auth:null,host:null,port:null,hostname:null,hash:null,search:null,query:null,pathname:null,path:null,href:e},i=e.trim(),a=i.indexOf(`#`);a!==-1&&(r.hash=i.slice(a),i=i.slice(0,a));let o=i.indexOf(`?`);o!==-1&&(r.search=i.slice(o),r.query=t?Object.fromEntries(new En(i.slice(o+1))):i.slice(o+1),i=i.slice(0,o));let s=/^([a-z][a-z0-9.+-]*:)/i.exec(i);if(s&&(r.protocol=s[1].toLowerCase(),i=i.slice(r.protocol.length)),(n||r.protocol)&&i.startsWith(`//`)&&(r.slashes=!0,i=i.slice(2)),r.slashes||r.protocol&&![`javascript:`,`data:`,`mailto:`].includes(r.protocol)){let e=-1;for(let t=0;t<i.length;t++){let n=i[t];if(n===`/`||n===`\\`){e=t;break}}let t=e===-1?i:i.slice(0,e);i=e===-1?``:i.slice(e);let n=t.lastIndexOf(`@`);n===-1?parseHostPort(t,r):(r.auth=decodeURIComponent(t.slice(0,n)),parseHostPort(t.slice(n+1),r))}return r.pathname=i||(r.slashes?`/`:null),(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname||``)+(r.search||``)),r.href=format$3(r),r}function parseHostPort(e,t){if(!e)return;let n=e.indexOf(`[`);if(n!==-1){let r=e.indexOf(`]`,n);if(r!==-1){let i=e.slice(r+1);i.startsWith(`:`)&&(t.port=i.slice(1)),t.hostname=e.slice(n,r+1),t.host=t.hostname+(t.port?`:`+t.port:``);return}}let r=e.lastIndexOf(`:`);if(r!==-1){let n=e.slice(r+1);/^\d*$/.test(n)?(t.port=n||null,t.hostname=e.slice(0,r).toLowerCase()):t.hostname=e.toLowerCase()}else t.hostname=e.toLowerCase();t.host=t.hostname+(t.port?`:`+t.port:``)}function format$3(e){if(typeof e==`string`)return e;if(e instanceof Z)return e.href;let t=e,n=``;if(t.protocol&&(n+=t.protocol),(t.slashes||t.protocol&&![`javascript:`,`data:`,`mailto:`].includes(t.protocol||``))&&(n+=`//`),t.auth&&(n+=encodeURIComponent(t.auth)+`@`),t.host?n+=t.host:(t.hostname&&(n+=t.hostname),t.port&&(n+=`:`+t.port)),t.pathname&&(n+=t.pathname),t.search)n+=t.search;else if(t.query&&typeof t.query==`object`){let e=new En(t.query).toString();e&&(n+=`?`+e)}return t.hash&&(n+=t.hash),n}function resolve$2(e,t){return new Z(t,new Z(e,`resolve://`)).href.replace(/^resolve:\/\//,``)}function fileURLToPath(e){if(typeof e==`string`&&(e=new Z(e)),!(e instanceof Z))throw TypeError(`The "url" argument must be of type string or URL. Received type `+typeof e);if(e.protocol!==`file:`)throw TypeError(`The URL must be of scheme file`);if(e.hostname!==``&&e.hostname!==`localhost`)throw TypeError(`File URL host must be "localhost" or empty on linux`);let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)throw TypeError(`File URL path must not include encoded / characters`)}return decodeURIComponent(t)}function pathToFileURL(e){let t=e;if(e[0]!==`/`)if(typeof globalThis.process?.cwd==`function`)t=globalThis.process.cwd()+`/`+e;else try{k?.get_current_dir&&(t=k.get_current_dir()+`/`+e)}catch{}return new Z(`file://`+encodePathForURL(t))}function encodePathForURL(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`||r>=`0`&&r<=`9`||r===`/`||r===`-`||r===`_`||r===`.`||r===`~`||r===`:`||r===`@`||r===`!`?t+=r:t+=encodeURIComponent(r)}return t}function domainToASCII(e){try{return new Z(`http://${e}`).hostname}catch{return``}}function domainToUnicode(e){try{return new Z(`http://${e}`).hostname}catch{return``}}var Tn,En,Z,Dn,On=__esmMin(()=>{A(),Tn=k.UriFlags.HAS_PASSWORD|k.UriFlags.ENCODED|k.UriFlags.SCHEME_NORMALIZE,En=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`){let t=e.startsWith(`?`)?e.slice(1):e;if(t)for(let e of t.split(`&`)){let t=e.indexOf(`=`);t===-1?this._entries.push([decodeComponent(e),``]):this._entries.push([decodeComponent(e.slice(0,t)),decodeComponent(e.slice(t+1))])}}else if(Array.isArray(e))for(let[t,n]of e)this._entries.push([String(t),String(n)]);else if(e instanceof URLSearchParams)this._entries=e._entries.map(([e,t])=>[e,t]);else for(let t of Object.keys(e))this._entries.push([t,String(e[t])])}get(e){for(let[t,n]of this._entries)if(t===e)return n;return null}getAll(e){return this._entries.filter(([t])=>t===e).map(([,e])=>e)}set(e,t){let n=!1;if(this._entries=this._entries.filter(([t])=>t===e?n?!1:(n=!0,!0):!0),n){for(let n=0;n<this._entries.length;n++)if(this._entries[n][0]===e){this._entries[n][1]=t;break}}else this._entries.push([e,t])}has(e){return this._entries.some(([t])=>t===e)}delete(e){this._entries=this._entries.filter(([t])=>t!==e)}append(e,t){this._entries.push([e,t])}sort(){this._entries.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]))}toString(){return this._entries.map(([e,t])=>encodeComponent(e)+`=`+encodeComponent(t)).join(`&`)}forEach(e){for(let[t,n]of this._entries)e(n,t,this)}*entries(){yield*this._entries}*keys(){for(let[e]of this._entries)yield e}*values(){for(let[,e]of this._entries)yield e}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}},Z=class URL{#e;#t;constructor(e,t){let n=e instanceof URL?e.href:String(e);try{if(t!==void 0){let e=t instanceof URL?t.href:String(t),r=k.Uri.parse(e,Tn);this.#e=r.parse_relative(n,Tn)}else this.#e=k.Uri.parse(n,Tn)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!this.#e)throw TypeError(`Invalid URL: ${n}`);this.#t=new En(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let e=this.#e.get_port();if(e===-1)return``;let t=this.#e.get_scheme();return(t===`http`||t===`ws`)&&e===80||(t===`https`||t===`wss`)&&e===443||t===`ftp`&&e===21?``:String(e)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}get pathname(){return this.#e.get_path()||`/`}get search(){let e=this.#e.get_query();return e?`?`+e:``}get hash(){let e=this.#e.get_fragment();return e?`#`+e:``}get origin(){let e=this.protocol;return e===`http:`||e===`https:`||e===`ftp:`?`${e}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let e=this.protocol,t=this.#e.get_scheme();(t===`http`||t===`https`||t===`ftp`||t===`file`||t===`ws`||t===`wss`||this.hostname)&&(e+=`//`);let n=this.username,r=this.password;n&&(e+=n,r&&(e+=`:`+r),e+=`@`),e+=this.hostname,this.port&&(e+=`:`+this.port);let i=this.pathname;return e+=i,e+=this.search,e+=this.hash,e}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(e){let t=e?._tmpPath;if(typeof t==`string`&&t.length>0){let e=`file://${t}`;return URL._objectURLPaths.set(e,t),e}return`file:///dev/null`}static revokeObjectURL(e){let t=URL._objectURLPaths.get(e);if(t){try{k.unlink(t)}catch{}URL._objectURLPaths.delete(e)}}},__name(parse$3,`parse`),__name(format$3,`format`),__name(resolve$2,`resolve`),Dn={URL:Z,URLSearchParams:En,parse:parse$3,format:format$3,resolve:resolve$2,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});On(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:Z,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:En,enumerable:!1,writable:!0,configurable:!0});let kn;if(globalThis.performance)kn=globalThis.performance;else{let e,_now;try{let t=globalThis.imports?.gi?.GLib;if(!t)throw Error(`GJS imports.gi.GLib not available`);e=t.get_monotonic_time(),_now=()=>(t.get_monotonic_time()-e)/1e3}catch{let t=Date.now();e=0,_now=()=>Date.now()-t}let t=[],n=Date.now()-_now();kn={timeOrigin:n,now:_now,mark(e){let n={name:e,entryType:`mark`,startTime:_now(),duration:0};return t.push(n),n},measure(e,n,r){let i=0,a=_now();if(n){let e=t.find(e=>e.entryType===`mark`&&e.name===n);e&&(i=e.startTime)}if(r){let e=t.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return t.push(o),o},getEntries(){return[...t]},getEntriesByName(e){return t.filter(t=>t.name===e)},getEntriesByType(e){return t.filter(t=>t.entryType===e)},clearMarks(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`mark`&&(!e||t[n].name===e)&&t.splice(n,1)},clearMeasures(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`measure`&&(!e||t[n].name===e)&&t.splice(n,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:n}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}};const An=globalThis,jn=An.PerformanceObserver||PerformanceObserverStub;An.PerformanceEntry,An.PerformanceObserverEntryList,An.PerformanceMark,An.PerformanceMeasure;const Mn=globalThis;globalThis.performance===void 0&&(Mn.performance=kn),typeof Mn.PerformanceObserver!=`function`&&(Mn.PerformanceObserver=jn);const Nn=Symbol(`abort`),Pn=Symbol(`internal`);var Fn=class AbortSignal extends EventTarget{#e=!1;reason=void 0;onabort=null;constructor(e){if(super(),e!==Pn)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.reason}[Nn](e){if(this.#e)return;this.#e=!0,this.reason=e??new Ve(`The operation was aborted.`,`AbortError`);let t=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,t),this.dispatchEvent(t)}static abort(e){let t=new AbortSignal(Pn);return t[Nn](e),t}static timeout(e){let t=new AbortSignal(Pn);return setTimeout(()=>{t[Nn](new Ve(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(Pn);for(let n of e)if(n.aborted)return t[Nn](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Nn](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},In=class AbortController{signal;constructor(){this.signal=new Fn(Pn)}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Nn](e)}};const Ln=globalThis;globalThis.AbortController===void 0&&(Ln.AbortController=In),globalThis.AbortSignal===void 0&&(Ln.AbortSignal=Fn);const Q=Symbol(`kState`),$=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[Q]!==void 0&&t[$]===e}function dequeueValue(e){let t=e[Q].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[Q].queueTotalSize=Math.max(0,e[Q].queueTotalSize-r),n}function resetQueue(e){e[Q].queue=[],e[Q].queueTotalSize=0}function peekQueueValue(e){return e[Q].queue[0].value}function enqueueValueWithSize(e,t,n){if(n=+n,typeof n!=`number`||n<0||Number.isNaN(n)||n===1/0)throw RangeError(`Invalid size: ${n}`);e[Q].queue.push({value:t,size:n}),e[Q].queueTotalSize+=n}function extractHighWaterMark(e,t){if(e===void 0)return t;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,t,n){if(typeof t!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>t.call(n,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const Rn={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let t={[Symbol.iterator]:()=>e.iterator},n=(async function*(){return yield*t})();return{iterator:n,nextMethod:n.next,done:!1}}function getIterator(e,t=`sync`,n){if(n===void 0)if(t===`async`){if(n=e[Symbol.asyncIterator],n==null){let t=e[Symbol.iterator];if(t===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,t))}}else n=e[Symbol.iterator];if(n===void 0)throw TypeError(`Object is not iterable`);let r=n.call(e);if(typeof r!=`object`||!r)throw TypeError(`The iterator method must return an object`);return{iterator:r,nextMethod:r.next,done:!1}}function iteratorNext(e,t){let n;if(n=t===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,t),typeof n!=`object`||!n)throw TypeError(`The iterator.next() method must return an object`);return n}const zn=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},Bn=Symbol(`kAbort`),Vn=Symbol(`kCloseSentinel`),Hn=Symbol(`kError`),Un=Symbol(`kSkipThrow`);var WritableStream=class{[$]=`WritableStream`;[Q];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);let n=e?.type;if(n!==void 0)throw RangeError(`Invalid type: ${n}`);this[Q]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!Wn(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return Wn(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return Wn(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!Wn(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[$]=`WritableStreamDefaultWriter`;[Q];constructor(e){if(!Wn(e))throw TypeError(`Expected a WritableStream`);this[Q]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return Gn(this)?this[Q].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!Gn(this))throw TypeError(`Invalid this`);if(this[Q].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return Gn(this)?this[Q].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return Gn(this)?this[Q].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!Gn(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Q];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!Gn(this))throw TypeError(`Invalid this`);let{stream:e}=this[Q];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return Gn(this)?this[Q].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[$]=`WritableStreamDefaultController`;[Q];constructor(e){if(e!==Un)throw TypeError(`Illegal constructor`)}[Bn](e){let t=this[Q].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[Hn](){resetQueue(this)}get signal(){if(!Kn(this))throw TypeError(`Invalid this`);return this[Q].abortController.signal}error(e){if(!Kn(this))throw TypeError(`Invalid this`);this[Q].stream[Q].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const Wn=isBrandCheck(`WritableStream`),Gn=isBrandCheck(`WritableStreamDefaultWriter`),Kn=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[Q].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[Q].stream=t,t[Q].writer=e,t[Q].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[Q].backpressure?e[Q].ready=Promise.withResolvers():e[Q].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Q].close=Promise.withResolvers();break;case`erroring`:e[Q].ready={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].ready.promise),e[Q].close=Promise.withResolvers();break;case`closed`:e[Q].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Q].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Q].ready={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},e[Q].close={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].ready.promise),setPromiseHandled(e[Q].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[Q];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[Q].abortController.abort(t),e[Q].pendingAbortRequest.abort.promise!==void 0)return e[Q].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let a=Promise.withResolvers();return e[Q].pendingAbortRequest={abort:a,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),a.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[Q];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Q].closeRequest=Promise.withResolvers();let{promise:a}=e[Q].closeRequest;return n!==void 0&&r&&t===`writable`&&n[Q].ready.resolve?.(),writableStreamDefaultControllerClose(i),a}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[Q];n!==void 0&&e[Q].backpressure!==t&&(t?n[Q].ready=Promise.withResolvers():n[Q].ready.resolve?.()),e[Q].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[Q];e[Q].state=`erroring`,e[Q].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[Q].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Q].closeRequest.promise!==void 0&&(e[Q].closeRequest.reject?.(e[Q].storedError),e[Q].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Q].close.promise),e[Q].close.reject?.(e[Q].storedError);let{writer:t}=e[Q];t!==void 0&&(setPromiseHandled(t[Q].close.promise),t[Q].close.reject?.(e[Q].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[Q].writeRequests.shift();e[Q].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[Q].inFlightCloseRequest=e[Q].closeRequest,e[Q].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Q].inFlightWriteRequest.promise!==void 0||e[Q].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[Q].inFlightWriteRequest.reject?.(t),e[Q].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[Q].inFlightWriteRequest.resolve?.(),e[Q].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[Q].inFlightCloseRequest.reject?.(t),e[Q].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Q].pendingAbortRequest.abort.promise!==void 0&&(e[Q].pendingAbortRequest.abort.reject?.(t),e[Q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[Q].inFlightCloseRequest.resolve?.(),e[Q].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Q].state===`erroring`&&(e[Q].storedError=void 0,e[Q].pendingAbortRequest.abort.promise!==void 0&&(e[Q].pendingAbortRequest.abort.resolve?.(),e[Q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Q].state=`closed`,e[Q].writer!==void 0&&e[Q].writer[Q].close.resolve?.(),e[Q].close.resolve?.()}function writableStreamFinishErroring(e){e[Q].state=`errored`,e[Q].controller[Hn]();let t=e[Q].storedError;for(let n of e[Q].writeRequests)n.reject?.(t);if(e[Q].writeRequests=[],e[Q].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[Q].pendingAbortRequest;if(e[Q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},n.wasAlreadyErroring){n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[Q].controller[Bn](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[Q].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Q].closeRequest.promise!==void 0||e[Q].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[Q].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[Q],{controller:r}=n[Q],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[Q].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:a}=n[Q];if(a===`errored`)return Promise.reject(n[Q].storedError);if(writableStreamCloseQueuedOrInFlight(n)||a===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(a===`erroring`)return Promise.reject(n[Q].storedError);let o=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),o}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[Q],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[Q].writer=void 0,e[Q].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[Q];switch(t[Q].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[Q].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[Q].ready.reject?(e[Q].ready.reject(t),e[Q].ready.resolve=void 0,e[Q].ready.reject=void 0):e[Q].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[Q].close.reject?(e[Q].close.reject(t),e[Q].close.resolve=void 0,e[Q].close.reject=void 0):e[Q].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[Q],{state:n}=t[Q];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[Q].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Q].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[Q].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[Q];!writableStreamCloseQueuedOrInFlight(r)&&r[Q].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[Q];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[Q];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[Q].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[Q];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Q].highWaterMark-e[Q].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[Q];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[Q].stream[Q].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Q].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,Vn,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Q].writeAlgorithm=void 0,e[Q].closeAlgorithm=void 0,e[Q].abortAlgorithm=void 0,e[Q].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[Q];if(!n||r[Q].inFlightWriteRequest.promise!==void 0)return;if(r[Q].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===Vn?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(Un),a=t?.start,o=t?.write,s=t?.close,c=t?.abort;setupWritableStreamDefaultController(e,i,a?a.bind(t,i):nonOpStart,o?createPromiseCallback(`sink.write`,o,t):nonOpWrite,s?createPromiseCallback(`sink.close`,s,t):nonOpCancel,c?createPromiseCallback(`sink.abort`,c,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,a,o,s){t[Q]={abortAlgorithm:a,closeAlgorithm:i,highWaterMark:o,queue:[],queueTotalSize:0,abortController:new zn,sizeAlgorithm:s,started:!1,stream:e,writeAlgorithm:r},e[Q].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let c=n();new Promise(e=>e(c)).then(()=>{t[Q].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[Q].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,a=()=>1){let o=Object.create(WritableStream.prototype);return o[$]=`WritableStream`,o[Q]=createWritableStreamState(),setupWritableStreamDefaultController(o,new WritableStreamDefaultController(Un),e,t,n,r,i,a),o}L();const qn=Symbol(`kCancel`),Jn=Symbol(`kClose`),Yn=Symbol(`kChunk`),Xn=Symbol(`kError`),Zn=Symbol(`kPull`),Qn=Symbol(`kRelease`),$n=Symbol(`kSkipThrow`);let er,tr;function lazyReadableReleasedError(){return er||(er=TypeError(`Reader released`),er)}function lazyReadableReleasingError(){return tr||(tr=TypeError(`Releasing reader`),tr)}function createAbortError(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name(this,`ReadableStream`)}[$]=`ReadableStream`;[Q];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);this[Q]=createReadableStreamState();let n=t?.size,r=t?.highWaterMark,i=e?.type;if(i!==void 0){if(`${i}`==`bytes`){if(n!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(r,0));return}throw RangeError(`Invalid type: ${i}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(r,1),extractSizeAlgorithm(n))}get locked(){if(!nr(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return nr(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!nr(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=e?.mode;if(t===void 0)return new ReadableStreamDefaultReader(this);if(`${t}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${t}`)}pipeThrough(e,t={}){if(!nr(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!nr(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!Wn(r))throw TypeError(`transform.writable must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let i=t?.preventAbort,a=t?.preventCancel,o=t?.preventClose,s=t?.signal;if(s!==void 0&&!(s instanceof Object&&`aborted`in s))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(r))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,r,!!o,!!i,!!a,s)),n}pipeTo(e,t={}){try{if(!nr(this))throw TypeError(`Invalid this`);if(!Wn(e))throw TypeError(`destination must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let n=t?.preventAbort,r=t?.preventCancel,i=t?.preventClose,a=t?.signal;if(a!==void 0&&!(a instanceof Object&&`aborted`in a))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!i,!!n,!!r,a)}catch(e){return Promise.reject(e)}}tee(){if(!nr(this))throw TypeError(`Invalid this`);let e=this[Q].controller;return ar(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!nr(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=!!e?.preventCancel,n=new ReadableStreamDefaultReader(this),r={done:!1,current:void 0},i=!1;function nextSteps(){if(r.done)return Promise.resolve({done:!0,value:void 0});if(n[Q].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:t,reject:i}=Promise.withResolvers();return readableStreamDefaultReaderRead(n,{[Yn](e){r.current=void 0,t({value:e,done:!1})},[Jn](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[Xn](e){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),i(e)}}),e}async function returnSteps(e){if(r.done)return{done:!0,value:e};if(r.done=!0,n[Q].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!t){let t=readableStreamReaderGenericCancel(n,e);return readableStreamReaderGenericRelease(n),await t,{done:!0,value:e}}return readableStreamReaderGenericRelease(n),{done:!0,value:e}}return Object.setPrototypeOf({next(){return i||=(r.current=Promise.resolve(),!0),r.current=r.current===void 0?nextSteps():r.current.then(nextSteps,nextSteps),r.current},return(e){return i=!0,r.current=r.current===void 0?returnSteps(e):r.current.then(()=>returnSteps(e),()=>returnSteps(e)),r.current},[Symbol.asyncIterator](){return this}},Rn)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Q];constructor(){this[Q]=Promise.withResolvers()}[Yn](e){this[Q].resolve?.({value:e,done:!1})}[Jn](){this[Q].resolve?.({value:void 0,done:!0})}[Xn](e){this[Q].reject?.(e)}get promise(){return this[Q].promise}},ReadableStreamDefaultReader=class{[$]=`ReadableStreamDefaultReader`;[Q];constructor(e){if(!nr(e))throw TypeError(`Expected a ReadableStream`);this[Q]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!ir(this))return Promise.reject(TypeError(`Invalid this`));if(this[Q].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Q].stream,t=e[Q].controller;if(e[Q].state===`readable`&&rr(t)&&t[Q].queue.length>0){e[Q].disturbed=!0;let n=dequeueValue(t);return t[Q].closeRequested&&!t[Q].queue.length?(readableStreamDefaultControllerClearAlgorithms(t),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(t),Promise.resolve({value:n,done:!1})}let n=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,n),n.promise}releaseLock(){if(!ir(this))throw TypeError(`Invalid this`);this[Q].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return ir(this)?this[Q].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return ir(this)?this[Q].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[$]=`ReadableStreamDefaultController`;[Q];constructor(e){if(e!==$n)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[qn](e){return readableStreamDefaultControllerCancelSteps(this,e)}[Zn](e){readableStreamDefaultControllerPullSteps(this,e)}[Qn](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const nr=isBrandCheck(`ReadableStream`),rr=isBrandCheck(`ReadableStreamDefaultController`),ir=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Q].reader!==void 0}function readableStreamCancel(e,t){switch(e[Q].disturbed=!0,e[Q].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Q].storedError)}readableStreamClose(e);let n=e[Q].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[Q].readIntoRequests;n[Q].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][Jn](void 0)}return e[Q].controller[qn](t).then(()=>{})}function readableStreamClose(e){e[Q].state=`closed`,e[Q].closedPromise.resolve();let{reader:t}=e[Q];if(t!==void 0&&(t[Q].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[Q].readRequests.length;e++)t[Q].readRequests[e][Jn]();t[Q].readRequests=[]}}function readableStreamError(e,t){e[Q].state=`errored`,e[Q].storedError=t,setPromiseHandled(e[Q].closedPromise.promise),e[Q].closedPromise.reject(t);let{reader:n}=e[Q];if(n!==void 0){if(setPromiseHandled(n[Q].close.promise),n[Q].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[Q].readRequests.length;e++)n[Q].readRequests[e][Xn](t);n[Q].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[Q].readIntoRequests.length;e++)n[Q].readIntoRequests[e][Xn](t);n[Q].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[Q];return t===void 0?!1:t[Q]!==void 0&&t[$]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Q].reader[Q].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[Q],i=r[Q].readRequests.shift();n?i[Jn]():i[Yn](t)}function readableStreamAddReadRequest(e,t){e[Q].reader[Q].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[Q];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[Q].stream=t,t[Q].reader=e,t[Q].state){case`readable`:e[Q].close=Promise.withResolvers();break;case`closed`:e[Q].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Q].close={promise:Promise.reject(t[Q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[Q],n=lazyReadableReleasedError();t[Q].state===`readable`?e[Q].close.reject?.(n):e[Q].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[Q].close.promise),t[Q].controller[Qn](),t[Q].reader=void 0,e[Q].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[Q].readRequests.length;++n)e[Q].readRequests[n][Xn](t);e[Q].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[Q];switch(n[Q].disturbed=!0,n[Q].state){case`closed`:t[Jn]();break;case`errored`:t[Xn](n[Q].storedError);break;case`readable`:n[Q].controller[Zn](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[Q].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Q].closeRequested=!0,e[Q].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Q].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[Q];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[Q].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[Q];return!e[Q].closeRequested&&t[Q].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[Q];switch(t[Q].state){case`errored`:return null;case`closed`:return 0;default:return n-r}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:t}=e[Q];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Q].started)return!1;if(isReadableStreamLocked(t)&&readableStreamGetNumReadRequests(t))return!0;let n=readableStreamDefaultControllerGetDesiredSize(e);return n!==null&&n>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[Q].pulling){e[Q].pullAgain=!0;return}e[Q].pulling=!0,e[Q].pullAlgorithm(e).then(()=>{e[Q].pulling=!1,e[Q].pullAgain&&(e[Q].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Q].pullAlgorithm=void 0,e[Q].cancelAlgorithm=void 0,e[Q].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[Q];n[Q].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[Q].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[Q];if(r.length){let i=dequeueValue(e);e[Q].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[Yn](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,a,o){t[Q]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:a,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:o,stream:e},e[Q].controller=t;let s=n();new Promise(e=>e(s)).then(()=>{t[Q].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController($n),a=t?.start,o=t?.pull,s=t?.cancel;setupReadableStreamDefaultController(e,i,a?a.bind(t,i):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let a=Object.create(ReadableStream$1.prototype);return a[$]=`ReadableStream`,a[Q]=createReadableStreamState(),setupReadableStreamDefaultController(a,new ReadableStreamDefaultController($n),e,t,n,r,i),a}function readableStreamFromIterable(e){let t,n=getIterator(e,`async`),r=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(n);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(t[Q].controller):readableStreamDefaultControllerEnqueue(t[Q].controller,e.value)})}async function cancelAlgorithm(e){let t=n.iterator,r=t.return;if(r===void 0)return Promise.resolve();let i=r.call(t,e);return Promise.resolve(i).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return t=createReadableStream(r,pullAlgorithm,cancelAlgorithm,0),t}function readableStreamPipeTo(e,t,n,r,i,a){let o,s;try{o=new ReadableStreamDefaultReader(e),s=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[Q].disturbed=!0;let c=!1,{promise:l,resolve:u,reject:d}=Promise.withResolvers(),p={currentWrite:Promise.resolve()},m;function finalize(e,t){writableStreamDefaultWriterRelease(s),readableStreamReaderGenericRelease(o),a!==void 0&&m&&(a.removeEventListener(`abort`,m),m=void 0),e?d(t):u()}async function waitForCurrentWrite(){let e=p.currentWrite;await e,e!==p.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(c)return;if(c=!0,t[Q].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!n,r),e=>finalize(!0,e))}}function shutdown(e,n){if(!c){if(c=!0,t[Q].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=a.reason&&a.reason.name===`AbortError`?createAbortError():a.reason;let o=[];r||o.push(()=>t[Q].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||o.push(()=>e[Q].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(o.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[Q].state===`errored`?n(e[Q].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[Q].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[Yn](e){_e(()=>{p.currentWrite=writableStreamDefaultWriterWrite(s,e),setPromiseHandled(p.currentWrite),h.resolve(!1)})}[Jn](){h.resolve(!0)}[Xn](e){h.reject(e)}}let h={resolve:null,reject:null};async function step(){if(c||t[Q].backpressure&&(await s[Q].ready.promise,c))return!0;let n=e[Q].controller;if(e[Q].state===`readable`&&rr(n)&&n[Q].queue.length>0){for(;n[Q].queue.length>0;){if(c)return!0;let r=dequeueValue(n);if(n[Q].closeRequested&&!n[Q].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),p.currentWrite=writableStreamDefaultWriterWrite(s,r),setPromiseHandled(p.currentWrite),t[Q].backpressure||t[Q].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[Q].state===`closed`}let{promise:r,resolve:i,reject:a}=Promise.withResolvers();return h={resolve:i,reject:a},readableStreamDefaultReaderRead(o,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(a!==void 0){if(a.aborted)return abortAlgorithm(),l;m=abortAlgorithm,a.addEventListener(`abort`,m,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,o[Q].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,s[Q].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,o[Q].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(s));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[Q].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return l}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,a=!1,o,s,c,l,u=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[Yn](e){_e(()=>{r=!1;let n=e,o=e;if(!a&&t)try{o=structuredClone(o)}catch{}i||readableStreamDefaultControllerEnqueue(c[Q].controller,n),a||readableStreamDefaultControllerEnqueue(l[Q].controller,o)})},[Jn](){_e(()=>{r=!1,i||readableStreamDefaultControllerClose(c[Q].controller),a||readableStreamDefaultControllerClose(l[Q].controller),(!i||!a)&&u.resolve(void 0)})},[Xn](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,o=t,a){let t=[o,s];u.resolve(readableStreamCancel(e,t))}return u.promise}function cancel2Algorithm(t){if(a=!0,s=t,i){let t=[o,s];u.resolve(readableStreamCancel(e,t))}return u.promise}return c=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),l=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[Q].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(c[Q].controller,e),readableStreamDefaultControllerError(l[Q].controller,e),(!i||!a)&&u.resolve(void 0)}),[c,l]}var BYOBReadIntoRequest=class{[Q];constructor(){this[Q]=Promise.withResolvers()}[Yn](e){this[Q].resolve?.({value:e,done:!1})}[Jn](e){this[Q].resolve?.({value:e,done:!0})}[Xn](e){this[Q].reject?.(e)}get promise(){return this[Q].promise}},ReadableStreamBYOBReader=class{[$]=`ReadableStreamBYOBReader`;[Q];constructor(e){if(!nr(e))throw TypeError(`Expected a ReadableStream`);this[Q]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!or(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let n=e.buffer,r=e.byteLength;if(r===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(n.byteLength===0)return isDetachedBuffer(n)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let i=t?.min??1;if(typeof i!=`number`||i<1||!Number.isInteger(i)||Number.isNaN(i))return Promise.reject(TypeError(`options.min must be a positive integer`));let a=e[Symbol.toStringTag];if(a!==void 0&&a!==`DataView`){if(i>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(i>r)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[Q].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let o=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,o),o.promise}releaseLock(){if(!or(this))throw TypeError(`Invalid this`);this[Q].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return or(this)?this[Q].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return or(this)?this[Q].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[$]=`ReadableStreamBYOBRequest`;[Q];constructor(e){if(e!==$n)throw TypeError(`Illegal constructor`)}get view(){if(!sr(this))throw TypeError(`Invalid this`);return this[Q].view}respond(e){if(!sr(this))throw TypeError(`Invalid this`);if(this[Q].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let t=this[Q].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Q].controller,e)}respondWithNewView(e){if(!sr(this))throw TypeError(`Invalid this`);if(this[Q].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[Q].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[$]=`ReadableByteStreamController`;[Q];constructor(e){if(e!==$n)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!ar(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!ar(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!ar(this))throw TypeError(`Invalid this`);if(this[Q].closeRequested)throw TypeError(`Close already requested`);if(this[Q].stream[Q].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!ar(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[Q].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Q].stream[Q].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!ar(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[qn](e){return readableByteStreamControllerCancelSteps(this,e)}[Zn](e){readableByteStreamControllerPullSteps(this,e)}[Qn](){if(this[Q].pendingPullIntos.length>0){let e=this[Q].pendingPullIntos[0];e.readerType=`none`,this[Q].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const ar=isBrandCheck(`ReadableByteStreamController`),or=isBrandCheck(`ReadableStreamBYOBReader`),sr=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[Q];return t===void 0?!1:t[Q]!==void 0&&t[$]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Q].reader[Q].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[Q].reader[Q].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[Q],i=r[Q].readIntoRequests.shift();n?i[Jn](t):i[Yn](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!ar(t[Q].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[Q].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[Q];i[Q].disturbed=!0,i[Q].state===`errored`?r[Xn](i[Q].storedError):readableByteStreamControllerPullInto(i[Q].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[Q].readIntoRequests.length;n++)e[Q].readIntoRequests[n][Xn](t);e[Q].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Q].pullAlgorithm=void 0,e[Q].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Q].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[Q].byobRequest;t!=null&&(t[Q].controller=void 0,t[Q].view=null,e[Q].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[Q];n[Q].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[Q].stream[Q].state;return t===`errored`?null:t===`closed`?0:e[Q].highWaterMark-e[Q].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[Q];if(t[Q].state!==`readable`||e[Q].closeRequested||!e[Q].started)return!1;if(readableStreamHasDefaultReader(t)&&readableStreamGetNumReadRequests(t)>0||readableStreamHasBYOBReader(t)&&readableStreamGetNumReadIntoRequests(t)>0)return!0;let n=readableByteStreamControllerGetDesiredSize(e);return n!==null&&n>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[Q].pulling){e[Q].pullAgain=!0;return}e[Q].pulling=!0,e[Q].pullAlgorithm(e).then(()=>{e[Q].pulling=!1,e[Q].pullAgain&&(e[Q].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[Q].queueTotalSize===0&&e[Q].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Q].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[Q].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[Q].queueTotalSize+=r}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,t,n,r){let i;try{i=t.slice(n,n+r)}catch(t){readableByteStreamControllerError(e,t);return}readableByteStreamControllerEnqueueChunkToQueue(e,i,0,r)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t){t.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,t.buffer,t.byteOffset,t.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[Q].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n){n.bytesFilled+=t}function readableByteStreamControllerConvertPullIntoDescriptor(e){let t=e.bytesFilled,n=e.elementSize,r=transferArrayBuffer(e.buffer);return e.buffer=r,new e.viewConstructor(r,e.byteOffset,t/n)}function readableByteStreamControllerCommitPullIntoDescriptor(e,t){let n=!1;e[Q].state===`closed`&&(n=!0);let r=readableByteStreamControllerConvertPullIntoDescriptor(t);t.readerType==="default"?readableStreamFulfillReadRequest(e,r,n):readableStreamFulfillReadIntoRequest(e,r,n)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t){let n=Math.min(e[Q].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,a=!1,o=r-r%t.elementSize;o>=t.minimumFill&&(i=o-t.bytesFilled,a=!0);let s=e[Q].queue;for(;i>0;){let n=s[0],r=Math.min(i,n.byteLength),a=t.byteOffset+t.bytesFilled,o=new Uint8Array(t.buffer,a,r),c=new Uint8Array(n.buffer,n.byteOffset,r);o.set(c),n.byteLength===r?s.shift():(n.byteOffset+=r,n.byteLength-=r),e[Q].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return a}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[Q].queue.shift();e[Q].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[Yn](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[Q].stream[Q].reader;for(;t[Q].readRequests.length!==0;){if(e[Q].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[Q].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Q].pendingPullIntos.length!==0;){if(e[Q].queueTotalSize===0)return;let t=e[Q].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Q].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Q].byobRequest===null&&e[Q].pendingPullIntos.length!==0){let t=e[Q].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest($n);r[Q]={controller:e,view:n},e[Q].byobRequest=r}return e[Q].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[Q];if(e[Q].closeRequested||n[Q].state!==`readable`)return;let r=t.buffer,i=t.byteLength,a=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let o=transferArrayBuffer(r);if(e[Q].pendingPullIntos.length!==0){let t=e[Q].pendingPullIntos[0];if(isDetachedBuffer(t.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),t.buffer=transferArrayBuffer(t.buffer),t.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t)}readableStreamHasDefaultReader(n)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(n)===0?readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i):(e[Q].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(o,a,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[Q];if(!(e[Q].closeRequested||t[Q].state!==`readable`)){if(e[Q].queueTotalSize>0){e[Q].closeRequested=!0;return}if(e[Q].pendingPullIntos.length!==0){let t=e[Q].pendingPullIntos[0];if(t.bytesFilled%t.elementSize!==0){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,t),t}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(t)}}function readableByteStreamControllerPullInto(e,t,n,r){let i=e[Q].stream,a=t[Symbol.toStringTag],o,s;if(a===void 0||a===`DataView`)o=DataView,s=1;else{let e=typedArrayConstructorByTag(a);if(!e){r[Xn](TypeError(`Unsupported typed array: ${a}`));return}o=e,s=elementSizeByTag(a)}let c=t.buffer,l=t.byteLength,u=t.byteOffset,d=n*s,p;try{p=transferArrayBuffer(c)}catch(e){r[Xn](e);return}let m={buffer:p,bufferByteLength:p.byteLength,byteOffset:u,byteLength:l,bytesFilled:0,minimumFill:d,elementSize:s,viewConstructor:o,readerType:`byob`};if(e[Q].pendingPullIntos.length!==0){e[Q].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r);return}if(i[Q].state===`closed`){let e=new o(m.buffer,m.byteOffset,0);r[Jn](e);return}if(e[Q].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,m)){let t=readableByteStreamControllerConvertPullIntoDescriptor(m);readableByteStreamControllerHandleQueueDrain(e),r[Yn](t);return}if(e[Q].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[Xn](t);return}}e[Q].pendingPullIntos.push(m),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[Q].pendingPullIntos[0];if(e[Q].stream[Q].state===`closed`){if(t!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(t===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(n.bytesFilled+t>n.byteLength)throw RangeError(`bytesWritten out of range`)}n.buffer=transferArrayBuffer(n.buffer),readableByteStreamControllerRespondInternal(e,t)}function readableByteStreamControllerRespondWithNewView(e,t){let n=e[Q].pendingPullIntos[0],r=e[Q].stream[Q].state,i=t.byteLength,a=t.byteOffset,o=t.buffer;if(r===`closed`){if(i!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(i===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(n.byteOffset+n.bytesFilled!==a)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==o.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(n.bytesFilled+i>n.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);n.buffer=transferArrayBuffer(o),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[Q].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Q].stream[Q].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[Q].stream;if(readableStreamHasBYOBReader(n))for(;readableStreamGetNumReadIntoRequests(n)>0;)readableByteStreamControllerCommitPullIntoDescriptor(n,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,t,n){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n),n.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(n.bytesFilled<n.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let r=n.bytesFilled%n.elementSize;if(r>0){let t=n.byteOffset+n.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,n.buffer,t-r,r)}n.bytesFilled-=r,readableByteStreamControllerCommitPullIntoDescriptor(e[Q].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[Q].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[Q].stream;if(e[Q].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[Q].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[Xn](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Q].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,a,o){t[Q]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:a,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:o},e[Q].controller=t;let s=n();new Promise(e=>e(s)).then(()=>{t[Q].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController($n),i=t?.start,a=t?.pull,o=t?.cancel,s=t?.autoAllocateChunkSize;if(s!==void 0&&(s===0||!Number.isInteger(s)||s<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,a?createPromiseCallback(`source.pull`,a,t):nonOpPull,o?createPromiseCallback(`source.cancel`,o,t):nonOpCancel,n,s)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,a,o,s=Promise.withResolvers(),c,l,u,d;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||u.close(),i||d.close();return}let t=e.value,a=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||u.enqueue(a),i||d.enqueue(new Uint8Array(a))},()=>{}),Promise.resolve())}return c=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,a=t,i){let t=readableStreamCancel(e,[a,o]);return s.resolve(),t}return s.promise}}),l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,o=t,r){let t=readableStreamCancel(e,[a,o]);return s.resolve(),t}return s.promise}}),u=c[Q].controller,d=l[Q].controller,t.closed.catch(e=>{u.error(e),d.error(e),(!r||!i)&&s.resolve()}),[c,l]}const cr=Symbol(`kSkipThrow`);var TransformStream=class{[$]=`TransformStream`;[Q];constructor(e={},t={},n={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`writableStrategy must be an object`);if(n!=null&&typeof n!=`object`)throw TypeError(`readableStrategy must be an object`);let r=e?.readableType,i=e?.writableType,a=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let o=extractHighWaterMark(n?.highWaterMark,0),s=extractSizeAlgorithm(n?.size),c=extractHighWaterMark(t?.highWaterMark,1),l=extractSizeAlgorithm(t?.size),u=Promise.withResolvers();initializeTransformStream(this,u,c,l,o,s),setupTransformStreamDefaultControllerFromTransformer(this,e),a===void 0?u.resolve():u.resolve(a.call(e,this[Q].controller))}get readable(){if(!lr(this))throw TypeError(`Invalid this`);return this[Q].readable}get writable(){if(!lr(this))throw TypeError(`Invalid this`);return this[Q].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[$]=`TransformStreamDefaultController`;[Q];constructor(e){if(e!==cr)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!ur(this))throw TypeError(`Invalid this`);let{stream:e}=this[Q],{readable:t}=e[Q],n=t[Q].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!ur(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!ur(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!ur(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const lr=isBrandCheck(`TransformStream`),ur=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,a){let startAlgorithm=()=>t.promise,o=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[Q]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,a),writable:o,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,t){let{readable:n}=e[Q];readableStreamDefaultControllerError(n[Q].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[Q];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[Q].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Q].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[Q].backpressureChange.promise!==void 0&&e[Q].backpressureChange.resolve?.(),e[Q].backpressureChange=Promise.withResolvers(),e[Q].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[Q]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[Q].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(cr),r=t?.transform,i=t?.flush,a=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,a?createPromiseCallback(`transformer.cancel`,a,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Q].transformAlgorithm=void 0,e[Q].flushAlgorithm=void 0,e[Q].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[Q],{readable:r}=n[Q],i=r[Q].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[Q].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[Q].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[Q].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[Q].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[Q].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[Q],{readable:n}=t[Q];readableStreamDefaultControllerClose(n[Q].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[Q];return e[Q].backpressure?e[Q].backpressureChange.promise.then(()=>{let{writable:r}=e[Q];if(r[Q].state===`erroring`)throw r[Q].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[Q];if(n[Q].finishPromise!==void 0)return n[Q].finishPromise;let{promise:i,resolve:a,reject:o}=Promise.withResolvers();n[Q].finishPromise=i;let s=n[Q].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{r[Q].state===`errored`?o(r[Q].storedError):(readableStreamDefaultControllerError(r[Q].controller,t),a())},e=>{readableStreamDefaultControllerError(r[Q].controller,e),o(e)}),n[Q].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[Q];if(n[Q].finishPromise!==void 0)return n[Q].finishPromise;let{promise:r,resolve:i,reject:a}=Promise.withResolvers();n[Q].finishPromise=r;let o=n[Q].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),o.then(()=>{t[Q].state===`errored`?a(t[Q].storedError):(readableStreamDefaultControllerClose(t[Q].controller),i())},e=>{readableStreamDefaultControllerError(t[Q].controller,e),a(e)}),n[Q].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Q].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[Q];if(n[Q].finishPromise!==void 0)return n[Q].finishPromise;let{promise:i,resolve:a,reject:o}=Promise.withResolvers();n[Q].finishPromise=i;let s=n[Q].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{r[Q].state===`errored`?o(r[Q].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[Q].controller,t),transformStreamUnblockWrite(e),a())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[Q].controller,t),transformStreamUnblockWrite(e),o(t)}),n[Q].finishPromise}const dr=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),fr=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return dr}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return fr}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,t)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let n=e.charCodeAt(e.length-1);55296<=n&&n<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&t.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const pr=hasStreamingSupport();function incompleteUtf8Tail$1(e){let t=e.length;if(t===0)return 0;for(let n=1;n<=Math.min(3,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)!=128){let e;if((r&224)==192)e=2;else if((r&240)==224)e=3;else if((r&248)==240)e=4;else return 0;return n<e?n:0}}return 0}__name(incompleteUtf8Tail$1,`incompleteUtf8Tail`);var TextDecoderStream=class{#e;#t;constructor(e,t){if(this.#e=new TextDecoder(e,t),pr)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$3(e),r=this.#e.decode(n,{stream:!0});r&&t.enqueue(r)},flush:e=>{let t=this.#e.decode();t&&e.enqueue(t)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(t,n)=>{let r=toUint8Array$3(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let a=incompleteUtf8Tail$1(i),o;if(a>0?(o=i.slice(0,i.length-a),e=i.slice(i.length-a)):(o=i,e=new Uint8Array),o.length>0){let e=this.#e.decode(o);e&&n.enqueue(e)}},flush:t=>{if(e.length>0){let n=this.#e.decode(e);n&&t.enqueue(n),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$3(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name(toUint8Array$3,`toUint8Array`);function isNativeStreamUsable$3(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name(isNativeStreamUsable$3,`isNativeStreamUsable`);const mr=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,hr=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,gr=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,_r=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,vr=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,yr=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,br=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var xr=__esmMin(()=>{L()});function _setPipeImpl(e){Sr=e}var Sr,Stream_,Cr=__esmMin(()=>{bn(),Stream_=class extends Y{constructor(e){super(e)}pipe(e,t){return Sr(this,e,t)}}});function getDefaultHighWaterMark(e){return e?Tr:wr}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Tr=t:wr=t}function validateHighWaterMark(e,t){if(t!==void 0&&(typeof t!=`number`||Number.isNaN(t))){let n=TypeError(`The value of "${e}" is invalid. Received ${t}`);throw n.code=`ERR_INVALID_ARG_VALUE`,n}}var wr,Tr,Er=__esmMin(()=>{wr=16384,Tr=16});function chunkLength(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}function sliceChunk(e,t,n){if(typeof e==`string`)return n===void 0?e.slice(t):e.slice(t,n);let r=e.slice;return typeof r==`function`?r.call(e,t,n):e}var Dr,Or=__esmMin(()=>{Cr(),Er(),L(),Dr=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let t=this._buffer.shift();return--this.readableLength,t}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let t=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),t.length===1)return t[0];if(t.length===0)return null;if(typeof t[0]==`string`)return t.join(``);let n=globalThis.Buffer;return n?.concat?n.concat(t):t}_readBytes(e){let t=0,n=[];for(;t<e&&this._buffer.length>0;){let r=this._buffer[0],i=chunkLength(r);if(t+i<=e)n.push(this._buffer.shift()),t+=i,this.readableLength-=i;else{let i=e-t;n.push(sliceChunk(r,0,i)),this._buffer[0]=sliceChunk(r,i),this.readableLength-=i,t+=i}}if(n.length===1)return n[0];let r=globalThis.Buffer;return r?.concat?r.concat(n):n}push(e,t){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let t=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,t)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,t){return super.on(e,t),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let t=globalThis.Buffer;t?.isBuffer&&t.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let t=this._pipeDests.findIndex(t=>t.dest===e);if(t!==-1){this._pipeDests[t].cleanup(),this._pipeDests.splice(t,1);let n=this._readableState.pipes.indexOf(e);n!==-1&&this._readableState.pipes.splice(n,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(t){e.on(`data`,e=>{typeof e==`string`?t.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?t.enqueue(e):e&&typeof e.length==`number`&&t.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{t.close()}),e.on(`error`,e=>{t.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,t){let n=e.getReader();return new Readable_({...t,read(){n.read().then(({done:e,value:t})=>{e?this.push(null):this.push(t)},e=>{this.destroy(e)})},destroy(e,t){n.cancel(e?.message).then(()=>t(null),t)}})}[Symbol.asyncIterator](){let e=this,t=[],n=!1,r=null,i=null,a=null;return e.on(`data`,e=>{if(i){let t=i;i=null,a=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,a=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,a){let t=a;i=null,a=null,t(e)}}),{next(){return r?Promise.reject(r):t.length>0?Promise.resolve({value:t.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{i=e,a=t})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,t){let n=new Readable_({objectMode:!0,...t,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(n.push(e),n.push(null),n):((async()=>{try{for await(let t of e)n.push(t)||await new Promise(e=>n.once(`drain`,e));n.push(null)}catch(e){n.destroy(e)}})(),n)}}});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,kr=__esmMin(()=>{Er(),Or(),L(),Duplex_=class extends Dr{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let a=this.writableLength<this.writableHighWaterMark;return a||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),a}_duplexDoWrite(e,t,n){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:t,callback:n});return}this._duplexWriting=!0,this._duplexStartWrite(e,t,n)}_duplexStartWrite(e,t,n){this._pendingWrites++,this._write(e,t,t=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(t?()=>{if(n(t),this._duplexWriting=!1,this.emit(`error`,t),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(n(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,t,n){typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),n&&n()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:t,encoding:n,callback:r}of e)this._write(t,n,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(t),e?(r(e),this.emit(`error`,e)):r()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name(chunkLen$1,`chunkLen`)});function pipe(e,t,n){let r=e,i=n?.end!==!1,a=!1,ondrain=()=>{a=!1,t.removeListener(`drain`,ondrain);let e=r;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(t.writable){let n=r;t.write(e)===!1&&typeof n.pause==`function`&&(n.pause(),a||(a=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let o=!1,onend=()=>{o||(o=!0,i&&t.end())},onclose=()=>{if(!o&&(o=!0,i&&!(r instanceof Dr))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),a&&t.removeListener(`drain`,ondrain),r.removeListener(`end`,onend),r.removeListener(`close`,onclose),r.removeListener(`end`,cleanup),r.removeListener(`close`,cleanup),t.removeListener(`close`,cleanup)};return r.on(`end`,cleanup),r.on(`close`,cleanup),t.on(`close`,cleanup),r instanceof Dr&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var Ar=__esmMin(()=>{Cr(),Or(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var jr,Mr=__esmMin(()=>{Cr(),Er(),L(),jr=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let t=this;return t.prototype!==void 0&&Object.prototype.isPrototypeOf.call(t.prototype,e)?!0:t.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}if(this._pendingEnd){let{chunk:e,encoding:t,callback:n}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,t,n)}}_doWrite(e,t,n){this._writableState.writing=!0;let r=!0;this._write(e,t,t=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),r){nextTick(()=>{if(t){n(t),this.emit(`error`,t);return}n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),t||this._drainWriteBuffer();return}nextTick(t?()=>{n(t),this.emit(`error`,t),this._drainWriteBuffer()}:()=>{n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),r=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let a=this.writableLength<this.writableHighWaterMark;return a||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),a}_doEnd(e,t,n){e!=null&&this.write(e,t),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=n,this._maybeFinish()}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),this.writableEnded?(n&&nextTick(n),this):this._writableState.constructed?(this._doEnd(e,t,n),this):(this._pendingEnd={chunk:e,encoding:t,callback:n},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),t=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,t,t=>{for(let t of e)this.writableLength-=this.writableObjectMode?1:chunkLen(t.chunk);if(t){for(let n of e)n.callback(t);this.emit(`error`,t)}else{for(let t of e)t.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}}}),Nr,Pr=__esmMin(()=>{kr(),L(),Nr=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let t=this;e?.transform&&(t._transform=e.transform),e?.flush&&(t._flush=e.flush),e?.final&&(t._final=e.final)}_transform(e,t,n){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,t,n){let r=!1;try{this._transform(e,t,(e,t)=>{if(r){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(r=!0,e){n(e);return}t!=null&&this.push(t),n()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;n(e)}}_final(e){this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()})}_doPrefinishHooks(e){let t=Transform_.prototype._final;this._final===t?e():t.call(this,e)}}}),PassThrough_,Fr=__esmMin(()=>{Pr(),PassThrough_=class extends Nr{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline(...e){let t=e,n=typeof t[t.length-1]==`function`?t.pop():void 0,r=t;if(r.length<2)throw Error(`pipeline requires at least 2 streams`);let i=null;function onError(e){if(!i){i=e;for(let e of r)typeof e.destroy==`function`&&e.destroy();n&&n(e)}}let a=r[0];for(let e=1;e<r.length;e++){let t=r[e];a.pipe(t),a.on(`error`,onError),a=t}let o=r[r.length-1];return o.on(`error`,onError),o.on(`finish`,()=>{n&&!i&&n(null)}),o}var Ir=__esmMin(()=>{});function finished(e,t,n){let r;r=typeof t==`function`?t:n;let i=!1;function done(e){i||(i=!0,r(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let t=e,n=e;!t.writableFinished&&!n.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let a=e,o=typeof e.write==`function`,s=typeof e.read==`function`,c=a.writableFinished===!0,l=a.readableEnded===!0;if(a.destroyed===!0){let e=a._err;_e(e?()=>done(e):o&&c||s&&l?()=>done():()=>done(Error(`premature close`)))}else (o&&!s&&c||!o&&s&&l||o&&s&&c&&l)&&_e(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,t){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(t instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let n=t;if(e.aborted)n.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{n.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),t.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return t}function isReadable(e){if(e==null)return!1;let t=e;return typeof t.readable!=`boolean`||typeof t.read!=`function`||t.destroyed===!0||t.readableEnded===!0?!1:t.readable===!0}function isWritable(e){if(e==null)return!1;let t=e;return typeof t.writable!=`boolean`||typeof t.write!=`function`||t.destroyed===!0||t.writableEnded===!0?!1:t.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let t=e;return t.readableDidRead===!0||t.readableFlowing!==null&&t.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let t=e;return t.destroyed===!0&&typeof t.readable==`boolean`&&t.readable===!1||t.destroyed===!0&&typeof t.writable==`boolean`&&t.writable===!1}var Lr=__esmMin(()=>{Cr(),L()}),Rr=__exportAll$4({Duplex:()=>Hr,PassThrough:()=>Wr,Readable:()=>Br,Stream:()=>zr,Transform:()=>Ur,Writable:()=>Vr,addAbortSignal:()=>addAbortSignal,default:()=>Gr,finished:()=>finished,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,pipeline:()=>pipeline,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),zr,Br,Vr,Hr,Ur,Wr,Gr,Kr=__esmMin(()=>{xr(),Cr(),Er(),Or(),kr(),Ar(),Mr(),Pr(),Fr(),Ir(),Lr(),zr=makeCallable(Stream_),Br=makeCallable(Dr),Vr=makeCallable(jr),Hr=makeCallable(Duplex_),Ur=makeCallable(Nr),Wr=makeCallable(PassThrough_),Gr=Object.assign(zr,{Stream:zr,Readable:Br,Writable:Vr,Duplex:Hr,Transform:Ur,PassThrough:Wr,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getGioCompressorFormat(e){switch(e){case`gzip`:return M.ZlibCompressorFormat.GZIP;case`deflate`:return M.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return M.ZlibCompressorFormat.RAW}}function toUint8Array$2(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function createGzip(e){return new ZlibTransform(`gzip`,`compress`,e)}function createGunzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createDeflate(e){return new ZlibTransform(`deflate`,`compress`,e)}function createInflate(e){return new ZlibTransform(`deflate`,`decompress`,e)}function createDeflateRaw(e){return new ZlibTransform(`deflate-raw`,`compress`,e)}function createInflateRaw(e){return new ZlibTransform(`deflate-raw`,`decompress`,e)}function createUnzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}var ZlibTransform,qr=__esmMin(()=>{N(),A(),Kr(),__name(toUint8Array$2,`toUint8Array`),ZlibTransform=class extends Ur{_format;_mode;_chunks=[];constructor(e,t,n){super(n),this._format=e,this._mode=t}_transform(e,t,n){this._chunks.push(toUint8Array$2(e)),n()}_flush(e){let t=this._chunks.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let e of this._chunks)n.set(e,r),r+=e.length;this._chunks=[];try{let t=this._mode===`compress`?this._compress(n):this._decompress(n);this.push(Buffer.from(t)),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_compress(e){let t=new M.ZlibCompressor({format:getGioCompressorFormat(this._format)}),n=new M.ConverterOutputStream({base_stream:M.MemoryOutputStream.new_resizable(),converter:t});n.write_bytes(new k.Bytes(e),null),n.close(null);let r=n.get_base_stream().steal_as_bytes();return new Uint8Array(r.get_data()??[])}_decompress(e){let t=new M.ZlibDecompressor({format:getGioCompressorFormat(this._format)}),n=M.MemoryInputStream.new_from_bytes(new k.Bytes(e)),r=new M.ConverterInputStream({base_stream:n,converter:t}),i=[];for(;;){let e=r.read_bytes(4096,null);if(e.get_size()===0)break;i.push(new Uint8Array(e.get_data()))}r.close(null);let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}}}),Jr=__exportAll$4({ZlibTransform:()=>ZlibTransform,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>Zr,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,default:()=>Qr,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync});function getGioFormat(e){switch(e){case`gzip`:return M.ZlibCompressorFormat.GZIP;case`deflate`:return M.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return M.ZlibCompressorFormat.RAW}}function compressWithGio(e,t){let n=new M.ZlibCompressor({format:getGioFormat(t)}),r=new M.ConverterOutputStream({base_stream:M.MemoryOutputStream.new_resizable(),converter:n});r.write_bytes(new k.Bytes(e),null),r.close(null);let i=r.get_base_stream().steal_as_bytes();return new Uint8Array(i.get_data()??[])}function decompressStreamWithGio(e,t){let n=new M.ZlibDecompressor({format:getGioFormat(t)}),r=M.MemoryInputStream.new_from_bytes(new k.Bytes(e)),i=new M.ConverterInputStream({base_stream:r,converter:n}),a=[];for(;;){let e=i.read_bytes(4096,null);if(e.get_size()===0)break;a.push(new Uint8Array(e.get_data()))}i.close(null);let o=a.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s}function findGzipMemberEnd(e){let t=new M.ZlibDecompressor({format:M.ZlibCompressorFormat.GZIP}),n=new Uint8Array(65536),r=0,i=!1;for(;!i;){let a=e.subarray(r);try{let[e,o]=t.convert(a,n,M.ConverterFlags.NONE);r+=o,e===M.ConverterResult.FINISHED&&(i=!0)}catch{i=!0}}return r}function decompressWithGio(e,t){if(t!==`gzip`)return decompressStreamWithGio(e,t);let n=[],r=0;for(;r<e.length&&!(e.length-r<2||e[r]!==31||e[r+1]!==139);){let t=e.subarray(r),i=findGzipMemberEnd(t);if(i<=0)break;let a=decompressStreamWithGio(t.subarray(0,i),`gzip`);n.push(a),r+=i}if(n.length===0)return decompressStreamWithGio(e,`gzip`);let i=n.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of n)a.set(e,o),o+=e.length;return a}async function compressWithWeb(e,t){let n=new CompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function decompressWithWeb(e,t){let n=new DecompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function compress(e,t){return Yr?compressWithWeb(e,t):compressWithGio(e,t)}async function decompress(e,t){return Yr?decompressWithWeb(e,t):decompressWithGio(e,t)}function toUint8Array$1(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array$1(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array$1(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array$1(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array$1(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array$1(e),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array$1(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate-raw`)}function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),Xr)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),Xr)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}var Yr,Xr,Zr,Qr,$r=__esmMin(()=>{qr(),N(),A(),Yr=globalThis.CompressionStream!==void 0,__name(toUint8Array$1,`toUint8Array`),Xr=new Uint8Array,Zr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},Qr={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,constants:Zr}});const ei=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!ei.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const ti=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let ni=!1,ri,ii,ai,oi,si,ci;async function loadZlib(){if(ni)return;let e=await Promise.resolve().then(()=>($r(),Jr));ri=e.gzipSync,ii=e.gunzipSync,ai=e.deflateSync,oi=e.inflateSync,si=e.deflateRawSync,ci=e.inflateRawSync,ni=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>ri(e);case`deflate`:return e=>ai(e);case`deflate-raw`:return e=>si(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>ii(e);case`deflate`:return e=>oi(e);case`deflate-raw`:return e=>ci(e)}}let li,ui;if(ti)li=globalThis.CompressionStream,ui=globalThis.DecompressionStream;else{let e=loadZlib();li=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=new gr({async transform(t,r){try{await e,r.enqueue(getCompressFn(n)(t))}catch(e){r.error(e)}}});this.readable=r.readable,this.writable=r.writable}},ui=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=new gr({async transform(t,r){try{await e,r.enqueue(getDecompressFn(n)(t))}catch(e){r.error(e)}}});this.readable=r.readable,this.writable=r.writable}}}const di=globalThis;globalThis.CompressionStream===void 0&&(di.CompressionStream=li),globalThis.DecompressionStream===void 0&&(di.DecompressionStream=ui);const fi=globalThis;globalThis.DOMException===void 0&&(fi.DOMException=Ve);const pi=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(pi.ByteLengthQueuingStrategy=_r),globalThis.CountQueuingStrategy===void 0&&(pi.CountQueuingStrategy=vr);const mi=globalThis;function isNativeStreamUsable$2(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(mi.ReadableStream=mr),mi.ReadableStreamBYOBReader===void 0&&(mi.ReadableStreamBYOBReader=ReadableStreamBYOBReader),mi.ReadableStreamBYOBRequest===void 0&&(mi.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),mi.ReadableByteStreamController===void 0&&(mi.ReadableByteStreamController=ReadableByteStreamController),mi.ReadableStreamDefaultController===void 0&&(mi.ReadableStreamDefaultController=ReadableStreamDefaultController),mi.ReadableStreamDefaultReader===void 0&&(mi.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const hi=globalThis;globalThis.TextEncoderStream===void 0&&(hi.TextEncoderStream=yr),globalThis.TextDecoderStream===void 0&&(hi.TextDecoderStream=br);function isNativeStreamUsable$1(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(__name(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let e=globalThis;e.TransformStream=gr}function isNativeStreamUsable(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let e=globalThis;e.WritableStream=hr}var CryptoKey=class{type;extractable;algorithm;usages;_handle;constructor(e,t,n,r,i){this.type=e,this.extractable=t,this.algorithm=Object.freeze({...n}),this.usages=Object.freeze([...r]),this._handle=i}get[Symbol.toStringTag](){return`CryptoKey`}};function normalizeAlgorithm$1(e){if(typeof e==`string`)return{name:e};if(!e||typeof e.name!=`string`)throw TypeError(`Algorithm must have a name property`);return e}__name(normalizeAlgorithm$1,`normalizeAlgorithm`);const gi={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=gi[e.toUpperCase()]||gi[e];if(!t)throw new Ve(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const _i={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=_i[e];if(!t)throw new Ve(`Unrecognized curve name: ${e}`,`NotSupportedError`);return t}function hashSize$1(e){switch(toNodeHashName(e)){case`sha1`:return 20;case`sha256`:return 32;case`sha384`:return 48;case`sha512`:return 64;default:throw new Ve(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new Ve(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new Ve(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new Ve(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const vi=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,yi=new Uint8Array(128);for(let e=0;e<64;e++)yi[vi.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],a=r+1<n?e[r+1]:0,o=r+2<n?e[r+2]:0;t+=vi[i>>2&63],t+=vi[(i<<4|a>>4)&63],t+=r+1<n?vi[(a<<2|o>>6)&63]:`=`,t+=r+2<n?vi[o&63]:`=`}return t}function base64ToBytes(e){let t=e;for(;t.endsWith(`=`);)t=t.slice(0,-1);let n=[],r=0,i=0;for(let e=0;e<t.length;e++)i=i<<6|yi[t.charCodeAt(e)],r+=6,r>=8&&(r-=8,n.push(i>>r&255));return new Uint8Array(n)}function base64urlEncode(e){return bytesToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function base64urlDecode(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4;)t+=`=`;return base64ToBytes(t)}function toUint8Array(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Expected BufferSource`)}function gmul(e,t){let n=0;for(let r=0;r<8;r++){t&1&&(n^=e);let r=e&128;e=e<<1&255,r&&(e^=27),t>>=1}return n}function keyExpansion(e){let t=e.length/4,n=t+6,r=4*(n+1),i=Array.from({length:r});for(let n=0;n<t;n++)i[n]=new Uint8Array([e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]]);for(let e=t;e<r;e++){let n=new Uint8Array(i[e-1]);e%t===0?n=new Uint8Array([bi[n[1]]^Si[e/t-1],bi[n[2]],bi[n[3]],bi[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([bi[n[0]],bi[n[1]],bi[n[2]],bi[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let a=[];for(let e=0;e<=n;e++){let t=new Uint8Array(16);for(let n=0;n<4;n++)t[4*n]=i[4*e+n][0],t[4*n+1]=i[4*e+n][1],t[4*n+2]=i[4*e+n][2],t[4*n+3]=i[4*e+n][3];a.push(t)}return a}function aesEncryptBlock(e,t){let n=new Uint8Array(e),r=t.length-1;for(let e=0;e<16;e++)n[e]^=t[0][e];for(let e=1;e<r;e++){for(let e=0;e<16;e++)n[e]=bi[n[e]];let r=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=r;let i=n[2],a=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,n[14]=a;let o=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=o;for(let e=0;e<4;e++){let t=e*4,r=n[t],i=n[t+1],a=n[t+2],o=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^a^o,n[t+1]=r^gmul(2,i)^gmul(3,a)^o,n[t+2]=r^i^gmul(2,a)^gmul(3,o),n[t+3]=gmul(3,r)^i^a^gmul(2,o)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=bi[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let a=n[2],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=a,n[14]=o;let s=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=s;for(let e=0;e<16;e++)n[e]^=t[r][e];return n}function aesDecryptBlock(e,t){let n=new Uint8Array(e),r=t.length-1;for(let e=0;e<16;e++)n[e]^=t[r][e];for(let e=r-1;e>0;e--){let r=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=r;let i=n[10],a=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,n[6]=a;let o=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=o;for(let e=0;e<16;e++)n[e]=xi[n[e]];for(let r=0;r<16;r++)n[r]^=t[e][r];for(let e=0;e<4;e++){let t=e*4,r=n[t],i=n[t+1],a=n[t+2],o=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,a)^gmul(9,o),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,a)^gmul(13,o),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,a)^gmul(11,o),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,a)^gmul(14,o)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let a=n[10],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=a,n[6]=o;let s=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=s;for(let e=0;e<16;e++)n[e]=xi[n[e]];for(let e=0;e<16;e++)n[e]^=t[0][e];return n}function incrementCounter(e){for(let t=15;t>=0&&++e[t]===0;t--);}function gcmIncrementCounter(e){for(let t=15;t>=12&&++e[t]===0;t--);}function gfMul(e,t){let n=new Uint8Array(16),r=new Uint8Array(e);for(let e=0;e<128;e++){if(t[e>>>3]&1<<7-(e&7))for(let e=0;e<16;e++)n[e]^=r[e];let i=r[15]&1;for(let e=15;e>0;e--)r[e]=r[e]>>>1|(r[e-1]&1)<<7;r[0]>>>=1,i&&(r[0]^=225)}return n}function ghash(e,t,n){let r=new Uint8Array(16),i=Math.ceil(t.length/16)||0;for(let n=0;n<i;n++){let i=n*16,a=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<a&&(r[e]^=t[n])}let o=gfMul(r,e);r.set(o)}let a=Math.ceil(n.length/16)||0;for(let t=0;t<a;t++){let i=t*16,a=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<a&&(r[e]^=n[t])}let o=gfMul(r,e);r.set(o)}let o=new Uint8Array(16),s=t.length*8,c=n.length*8,l=Math.floor(s/4294967296),u=s>>>0;o[0]=l>>>24&255,o[1]=l>>>16&255,o[2]=l>>>8&255,o[3]=l&255,o[4]=u>>>24&255,o[5]=u>>>16&255,o[6]=u>>>8&255,o[7]=u&255;let d=Math.floor(c/4294967296),p=c>>>0;o[8]=d>>>24&255,o[9]=d>>>16&255,o[10]=d>>>8&255,o[11]=d&255,o[12]=p>>>24&255,o[13]=p>>>16&255,o[14]=p>>>8&255,o[15]=p&255;for(let e=0;e<16;e++)r[e]^=o[e];let m=gfMul(r,e);return r.set(m),r}var bi,xi,Si,Ci=__esmMin(()=>{bi=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),xi=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),Si=[1,2,4,8,16,32,64,128,27,54]});function parseAlgorithm(e){let t=e.toLowerCase().match(/^aes-(128|192|256)-(cbc|ctr|ecb|cfb|ofb|gcm)$/);if(!t)throw Error(`Unsupported cipher algorithm: ${e}`);let n=parseInt(t[1]),r=t[2];return{keySize:n/8,ivSize:r===`ecb`?0:r===`gcm`?12:16,mode:r}}function toBuffer$2(e,t){return typeof e==`string`?q.from(e,t||`utf8`):q.from(e)}function encodeOutput(e,t){return t?q.from(e).toString(t):q.from(e)}function incompleteUtf8Tail(e){if(e.length===0)return 0;let t=e.length;for(let n=1;n<=Math.min(4,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)==128)continue;let i;if((r&224)==192)i=2;else if((r&240)==224)i=3;else if((r&248)==240)i=4;else return 0;return n<i?n:0}return 0}function pkcs7Pad(e){let t=16-e.length%16,n=new Uint8Array(e.length+t);n.set(e);for(let r=e.length;r<n.length;r++)n[r]=t;return n}function pkcs7Unpad(e){if(e.length===0||e.length%16!=0)throw Error(`bad decrypt`);let t=e[e.length-1];if(t===0||t>16)throw Error(`bad decrypt`);for(let n=e.length-t;n<e.length;n++)if(e[n]!==t)throw Error(`bad decrypt`);return new Uint8Array(e.slice(0,e.length-t))}var wi=__esmMin(()=>{J(),__name(toBuffer$2,`toBuffer`)});function createCipher(e,t){throw Error(`crypto.createCipher() is deprecated. Use createCipheriv() instead.`)}function createCipheriv(e,t,n){return new Cipher(e,typeof t==`string`?q.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?q.from(n):new Uint8Array(n))}function createDecipher(e,t){throw Error(`crypto.createDecipher() is deprecated. Use createDecipheriv() instead.`)}function createDecipheriv(e,t,n){return new Decipher(e,typeof t==`string`?q.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?q.from(n):new Uint8Array(n))}function getCiphers(){return[`aes-128-cbc`,`aes-128-ecb`,`aes-192-cbc`,`aes-192-ecb`,`aes-256-cbc`,`aes-256-ecb`,`aes-128-ctr`,`aes-192-ctr`,`aes-256-ctr`,`aes-128-cfb`,`aes-192-cfb`,`aes-256-cfb`,`aes-128-gcm`,`aes-192-gcm`,`aes-256-gcm`]}var CipherBase,Cipher,Decipher,Ti=__esmMin(()=>{Ci(),wi(),J(),CipherBase=class{_roundKeys;_iv;_mode;_buffer=new Uint8Array;_autoPadding=!0;_finalized=!1;constructor(e,t,n){let r=parseAlgorithm(e);if(t.length!==r.keySize)throw Error(`Invalid key length ${t.length}, expected ${r.keySize} for ${e}`);if(r.ivSize>0&&(!n||n.length!==r.ivSize))throw Error(`Invalid IV length ${n?.length??0}, expected ${r.ivSize} for ${e}`);this._roundKeys=keyExpansion(t),this._iv=n?new Uint8Array(n):new Uint8Array(16),this._mode=r.mode}setAutoPadding(e){return this._autoPadding=e,this}},Cipher=class extends CipherBase{_prevBlock;_counter;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmAuthTag=null;_gcmAADSet=!1;constructor(e,t,n){super(e,t,n),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(e){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(e),this._gcmAADSet=!0,this}getAuthTag(){if(this._mode!==`gcm`)throw Error(`getAuthTag is only supported in GCM mode`);if(!this._gcmAuthTag)throw Error(`getAuthTag must be called after final()`);return q.from(this._gcmAuthTag)}update(e,t,n){let r=toBuffer$2(e,t),i=new Uint8Array(this._buffer.length+r.length);if(i.set(this._buffer),i.set(r,this._buffer.length),this._mode===`gcm`){let e=this._processGcmEncrypt(i);return this._buffer=new Uint8Array,encodeOutput(e,n)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let e=this._processStream(i);return this._buffer=new Uint8Array,encodeOutput(e,n)}let a=Math.floor(i.length/16)*16,o=[];for(let e=0;e<a;e+=16){let t=i.slice(e,e+16);o.push(this._encryptBlock(t))}this._buffer=i.slice(a);let s=new Uint8Array(o.length*16);for(let e=0;e<o.length;e++)s.set(o[e],e*16);return encodeOutput(s,n)}final(e){if(this._finalized)throw Error(`Cipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let t=new Uint8Array;this._buffer.length>0&&(t=this._processGcmEncrypt(this._buffer),this._buffer=new Uint8Array);let n=new Uint8Array(this._gcmCiphertextLen),r=0;for(let e of this._gcmCiphertext)n.set(e,r),r+=e.length;let i=ghash(this._gcmH,this._gcmAAD,n),a=aesEncryptBlock(this._gcmJ0,this._roundKeys),o=new Uint8Array(16);for(let e=0;e<16;e++)o[e]=i[e]^a[e];return this._gcmAuthTag=q.from(o),encodeOutput(t,e)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let t=this._processStream(this._buffer);return this._buffer=new Uint8Array,encodeOutput(t,e)}return encodeOutput(new Uint8Array,e)}let t=this._buffer;if(this._autoPadding)t=pkcs7Pad(t);else if(t.length%16!=0)throw Error(`data not multiple of block size`);let n=[];for(let e=0;e<t.length;e+=16)n.push(this._encryptBlock(t.slice(e,e+16)));if(this._buffer=new Uint8Array,n.length===0)return encodeOutput(new Uint8Array,e);let r=new Uint8Array(n.length*16);for(let e=0;e<n.length;e++)r.set(n[e],e*16);return encodeOutput(r,e)}_encryptBlock(e){if(this._mode===`cbc`){let t=new Uint8Array(16);for(let n=0;n<16;n++)t[n]=e[n]^this._prevBlock[n];let n=aesEncryptBlock(t,this._roundKeys);return this._prevBlock=n,n}else if(this._mode===`ecb`)return aesEncryptBlock(e,this._roundKeys);throw Error(`Block encryption not supported for mode: ${this._mode}`)}_processStream(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];incrementCounter(this._counter)}return t}_processGcmEncrypt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];gcmIncrementCounter(this._counter)}return this._gcmCiphertext.push(new Uint8Array(t)),this._gcmCiphertextLen+=t.length,t}},Decipher=class extends CipherBase{_prevBlock;_counter;_pendingUtf8=new Uint8Array;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmExpectedTag=null;_gcmAADSet=!1;constructor(e,t,n){super(e,t,n),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(e){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(e),this._gcmAADSet=!0,this}setAuthTag(e){if(this._mode!==`gcm`)throw Error(`setAuthTag is only supported in GCM mode`);return this._gcmExpectedTag=q.from(e),this}_encodeWithUtf8Handling(e,t,n){if(!t||t!==`utf8`&&t!==`utf-8`)return encodeOutput(e,t);let r;if(this._pendingUtf8.length>0?(r=new Uint8Array(this._pendingUtf8.length+e.length),r.set(this._pendingUtf8),r.set(e,this._pendingUtf8.length),this._pendingUtf8=new Uint8Array):r=e,!n){let e=incompleteUtf8Tail(r);e>0&&(this._pendingUtf8=new Uint8Array(r.slice(r.length-e)),r=new Uint8Array(r.slice(0,r.length-e)))}return q.from(r).toString(`utf8`)}update(e,t,n){let r=toBuffer$2(e,t),i=new Uint8Array(this._buffer.length+r.length);if(i.set(this._buffer),i.set(r,this._buffer.length),this._mode===`gcm`){this._gcmCiphertext.push(new Uint8Array(i)),this._gcmCiphertextLen+=i.length;let e=this._processGcmDecrypt(i);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(e,n,!1)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let e=this._processStream(i);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(e,n,!1)}let a=Math.floor(i.length/16);if(a===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let o=(this._autoPadding?a-1:a)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._decryptBlock(t))}this._buffer=i.slice(o);let c=new Uint8Array(s.length*16);for(let e=0;e<s.length;e++)c.set(s[e],e*16);return this._encodeWithUtf8Handling(c,n,!1)}final(e){if(this._finalized)throw Error(`Decipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let t=new Uint8Array;if(this._buffer.length>0&&(this._gcmCiphertext.push(new Uint8Array(this._buffer)),this._gcmCiphertextLen+=this._buffer.length,t=this._processGcmDecrypt(this._buffer),this._buffer=new Uint8Array),!this._gcmExpectedTag)throw Error(`Unsupported state or unable to authenticate data`);let n=new Uint8Array(this._gcmCiphertextLen),r=0;for(let e of this._gcmCiphertext)n.set(e,r),r+=e.length;let i=ghash(this._gcmH,this._gcmAAD,n),a=aesEncryptBlock(this._gcmJ0,this._roundKeys),o=new Uint8Array(16);for(let e=0;e<16;e++)o[e]=i[e]^a[e];let s=this._gcmExpectedTag,c=Math.min(s.length,16),l=0;for(let e=0;e<c;e++)l|=o[e]^s[e];if(l!==0)throw Error(`Unsupported state or unable to authenticate data`);return this._encodeWithUtf8Handling(t,e,!0)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let t=this._processStream(this._buffer);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(t,e,!0)}return this._encodeWithUtf8Handling(new Uint8Array,e,!0)}if(this._buffer.length===0)return this._encodeWithUtf8Handling(new Uint8Array,e,!0);if(this._buffer.length%16!=0)throw Error(`bad decrypt`);let t=[];for(let e=0;e<this._buffer.length;e+=16)t.push(this._decryptBlock(this._buffer.slice(e,e+16)));let n=new Uint8Array(t.length*16);for(let e=0;e<t.length;e++)n.set(t[e],e*16);let r=this._autoPadding?pkcs7Unpad(n):n;return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(r,e,!0)}_decryptBlock(e){if(this._mode===`cbc`){let t=aesDecryptBlock(e,this._roundKeys),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=t[e]^this._prevBlock[e];return this._prevBlock=new Uint8Array(e),n}else if(this._mode===`ecb`)return aesDecryptBlock(e,this._roundKeys);throw Error(`Block decryption not supported for mode: ${this._mode}`)}_processStream(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];incrementCounter(this._counter)}return t}_processGcmDecrypt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];gcmIncrementCounter(this._counter)}return t}}}),Ei,Di=__esmMin(()=>{Ei={RSA_PKCS1_PADDING:1,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_PKCS1_PSS_PADDING:6,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8}});function fillRandom(e){if(Oi)for(let t=0;t<e.length;t+=65536){let n=Math.min(e.length-t,65536),r=new Uint8Array(e.buffer,e.byteOffset+t,n);globalThis.crypto.getRandomValues(r)}else try{let t=imports.gi.GLib;for(let n=0;n<e.length;n++)e[n]=t.random_int_range(0,256)}catch{for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}}function randomBytes(e,t){if(typeof e!=`number`||e<0||!Number.isInteger(e))throw TypeError(`The "size" argument must be a non-negative integer. Received ${e}`);try{let n=q.alloc(e);if(e>0&&fillRandom(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),t)t(null,n);else return n}catch(e){if(t)t(e,q.alloc(0));else throw e}}function randomFillSync(e,t=0,n){let r=n??e.length-t;if(t<0||t>e.length)throw RangeError(`The value of "offset" is out of range. Received ${t}`);if(r<0||t+r>e.length)throw RangeError(`The value of "size" is out of range. Received ${r}`);if(r>0){let n=(e instanceof q,e.byteOffset);fillRandom(new Uint8Array(e.buffer,n+t,r))}return e}function randomFill(e,t,n,r){let i,a,o;typeof t==`function`?(o=t,i=0,a=e.length):typeof n==`function`?(o=n,i=t,a=e.length-t):(o=r,i=t,a=n);try{randomFillSync(e,i,a),o(null,e)}catch(t){o(t,e)}}function randomUUID(){if(Oi&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);fillRandom(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function randomInt(e,t,n){let r,i,a;if(typeof t==`function`?(a=t,i=e,r=0):typeof t==`number`?(r=e,i=t,a=n):(i=e,r=0,a=n),!Number.isInteger(r))throw TypeError(`The "min" argument must be a safe integer. Received ${r}`);if(!Number.isInteger(i))throw TypeError(`The "max" argument must be a safe integer. Received ${i}`);if(r>=i)throw RangeError(`The value of "min" must be less than "max". Received min: ${r}, max: ${i}`);let o=i-r,s=new Uint32Array(1);fillRandom(new Uint8Array(s.buffer));let c=r+s[0]%o;if(a)a(null,c);else return c}var Oi,ki=__esmMin(()=>{J(),Oi=globalThis.crypto!==void 0&&typeof globalThis.crypto.getRandomValues==`function`});function modPow(e,t,n){if(n===1n)return 0n;e=(e%n+n)%n;let r=1n;for(;t>0n;)t&1n&&(r=r*e%n),t>>=1n,e=e*e%n;return r}function bigIntToBytes(e,t){let n=new Uint8Array(t),r=e;for(let e=t-1;e>=0;e--)n[e]=Number(r&255n),r>>=8n;return n}function bytesToBigInt(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}var Ai=__esmMin(()=>{});function bigIntToBuffer(e){if(e===0n)return q.from([0]);let t=e.toString(16);return t.length%2!=0&&(t=`0`+t),q.from(t,`hex`)}function bufferToBigInt(e){if(e.length===0)return 0n;let t=q.from(e).toString(`hex`);return t.length===0?0n:BigInt(`0x`+t)}function bitLength(e){return e===0n?0:e.toString(2).length}function simpleSieve(e){for(let t of Mi){let n=BigInt(t);if(e%n===0n)return e===n}return!0}function fermatTest(e){return modPow(2n,e-1n,e)===1n}function millerRabinTest(e){if(e<2n)return!1;if(e===2n||e===3n)return!0;if(e%2n==0n)return!1;let t=e-1n,n=0;for(;t%2n==0n;)t/=2n,n++;for(let r of[2n,3n,5n,7n,11n,13n]){if(r>=e)continue;let i=modPow(r,t,e);if(i===1n||i===e-1n)continue;let a=!0;for(let t=0;t<n-1;t++)if(i=modPow(i,2n,e),i===e-1n){a=!1;break}if(a)return!1}return!0}function checkPrime(e,t){let n=t.toString(`hex`),r=0;if(e%2n==0n||!simpleSieve(e)||!fermatTest(e)||!millerRabinTest(e))return r+=1,n===`02`||n===`05`?r+=8:r+=4,r;switch(millerRabinTest(e>>1n)||(r+=2),n){case`02`:e%24n!=11n&&(r+=8);break;case`05`:{let t=e%10n;t!==3n&&t!==7n&&(r+=8)}break;default:r+=4}return r}function getCachedCheckPrime(e,t){let n=t.toString(`hex`)+`_`+e.toString(16);if(n in Ni)return Ni[n];let r=checkPrime(e,t);return Ni[n]=r,r}function formatReturnValue$1(e,t){let n=bigIntToBuffer(e);return t?n.toString(t):n}function generatePrime(e,t){let n=bufferToBigInt(t);if(e<16)return n===2n||n===5n?q.from([140,123]):q.from([140,39]);let r=Math.ceil(e/8),i=2n,a=4n;for(;;){let t=bufferToBigInt(randomBytes(r));for(;bitLength(t)>e;)t>>=1n;if(t%i==0n&&(t+=1n),t&i||(t+=i),n===i)for(;t%24n!=11n;)t+=a;else if(n===5n)for(;t%10n!=3n;)t+=a;let o=t>>1n;if(simpleSieve(o)&&simpleSieve(t)&&fermatTest(o)&&fermatTest(t)&&millerRabinTest(o)&&millerRabinTest(t))return bigIntToBuffer(t)}}function createDiffieHellman(e,t,n,r){if(t!==void 0&&typeof t!=`number`&&(q.isBuffer(t)||t instanceof Uint8Array||typeof t==`string`&&!(t in Pi)))return createDiffieHellman(e,`binary`,t,n);let i=t||`binary`,a=r||`binary`,o=q.from([2]);if(n!==void 0&&(typeof n==`number`?(o=q.alloc(1),o[0]=n):o=q.isBuffer(n)?n:q.from(n,a)),typeof e==`number`)return new DiffieHellman(generatePrime(e,o),o,!0);let s;return s=q.isBuffer(e)?e:e instanceof Uint8Array?q.from(e):q.from(e,i),new DiffieHellman(s,o,!0)}function getDiffieHellman(e){let t=ji[e];if(!t)throw Error(`Unknown group: ${e}. Supported groups: ${Object.keys(ji).join(`, `)}`);return new DiffieHellman(q.from(t.prime,`hex`),q.from(t.gen,`hex`),!1)}var ji,Mi,Ni,DiffieHellman,Pi,Fi,Ii,Li=__esmMin(()=>{Ai(),ki(),J(),ji={modp1:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff`},modp2:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff`},modp5:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff`},modp14:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff`},modp15:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff`},modp16:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff`},modp17:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff`},modp18:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff`}},Mi=[];{let e=1e3,t=new Uint8Array(1001);for(let n=2;n*n<=e;n++)if(!t[n])for(let r=n*n;r<=e;r+=n)t[r]=1;for(let n=2;n<=e;n++)t[n]||Mi.push(n)}Ni={},__name(formatReturnValue$1,`formatReturnValue`),DiffieHellman=class{_prime;_generator;_generatorBuf;_primeByteLength;_pubKey;_privKey;_primeCode;_malleable;constructor(e,t,n=!1){this._prime=bufferToBigInt(e),this._generatorBuf=t,this._generator=bufferToBigInt(t),this._primeByteLength=e.length,this._pubKey=void 0,this._privKey=void 0,this._primeCode=void 0,this._malleable=n,n||(this._primeCode=0,this.setPublicKey=void 0,this.setPrivateKey=void 0)}get verifyError(){return typeof this._primeCode!=`number`&&(this._primeCode=getCachedCheckPrime(this._prime,this._generatorBuf)),this._primeCode}generateKeys(e){if(!this._privKey){let e=randomBytes(this._primeByteLength);this._privKey=bufferToBigInt(e)}return this._pubKey=modPow(this._generator,this._privKey,this._prime),this.getPublicKey(e)}computeSecret(e,t,n){let r;r=typeof e==`string`?q.from(e,t||`utf8`):q.from(e);let i=bufferToBigInt(r);if(!this._privKey)throw Error(`You must generate keys before computing a secret`);if(i<=0n||i>=this._prime)throw Error(`Supplied key is too large`);let a=bigIntToBuffer(modPow(i,this._privKey,this._prime)),o=this._primeByteLength;if(a.length<o){let e=q.alloc(o);a.copy(e,o-a.length),a=e}return n?a.toString(n):a}getPrime(e){return formatReturnValue$1(this._prime,e)}getGenerator(e){return formatReturnValue$1(this._generator,e)}getPublicKey(e){if(!this._pubKey)throw Error(`No public key - call generateKeys() first`);return formatReturnValue$1(this._pubKey,e)}getPrivateKey(e){if(!this._privKey)throw Error(`No private key - call generateKeys() first`);return formatReturnValue$1(this._privKey,e)}setPublicKey(e,t){if(!this._malleable)throw Error(`setPublicKey is not available for predefined DH groups`);let n=typeof e==`string`?q.from(e,t||`utf8`):q.from(e);this._pubKey=bufferToBigInt(n)}setPrivateKey(e,t){if(!this._malleable)throw Error(`setPrivateKey is not available for predefined DH groups`);let n=typeof e==`string`?q.from(e,t||`utf8`):q.from(e);this._privKey=bufferToBigInt(n)}},Pi={binary:!0,hex:!0,base64:!0,latin1:!0,utf8:!0,"utf-8":!0,base64url:!0,ascii:!0,ucs2:!0,"ucs-2":!0,utf16le:!0,"utf-16le":!0},Fi=getDiffieHellman,Ii=getDiffieHellman});function mod(e,t){let n=e%t;return n<0n?n+t:n}function modInverse$2(e,t){if(e=mod(e,t),e===0n)throw Error(`No modular inverse for zero`);let[n,r]=[e,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}if(n!==1n)throw Error(`Modular inverse does not exist`);return mod(i,t)}function pointAdd(e,t,n){if(e===null)return t;if(t===null)return e;let{p:r}=n;if(e.x===t.x)return mod(e.y+t.y,r)===0n?null:pointDouble(e,n);let i=mod(t.x-e.x,r),a=mod(mod(t.y-e.y,r)*modInverse$2(i,r),r),o=mod(a*a-e.x-t.x,r);return{x:o,y:mod(a*(e.x-o)-e.y,r)}}function pointDouble(e,t){if(e===null)return null;let{a:n,p:r}=t;if(e.y===0n)return null;let i=mod(mod(3n*e.x*e.x+n,r)*modInverse$2(mod(2n*e.y,r),r),r),a=mod(i*i-2n*e.x,r);return{x:a,y:mod(i*(e.x-a)-e.y,r)}}function scalarMul(e,t,n){if(t===null||e===0n)return null;let{n:r}=n;if(e=mod(e,r),e===0n)return null;let i=null,a=t,o=e.toString(2);for(let e=0;e<o.length;e++)o[e]===`1`?(i=pointAdd(i,a,n),a=pointDouble(a,n)):(a=pointAdd(i,a,n),i=pointDouble(i,n));return i}function bigintToBuffer(e,t){let n=e.toString(16).padStart(t*2,`0`);return q.from(n,`hex`)}function bufferToBigint(e){let t=q.from(e).toString(`hex`);return t.length===0?0n:BigInt(`0x`+t)}function encodePublicKey(e,t,n=`uncompressed`){if(e===null)throw Error(`Cannot encode the point at infinity`);let r=bigintToBuffer(e.x,t);if(n===`compressed`){let t=e.y%2n==0n?2:3;return q.concat([q.from([t]),r])}let i=bigintToBuffer(e.y,t);if(n===`hybrid`){let t=e.y%2n==0n?6:7;return q.concat([q.from([t]),r,i])}return q.concat([q.from([4]),r,i])}function decodePublicKey(e,t){let n=q.from(e);if(n.length===0)throw Error(`Invalid public key: empty buffer`);let r=n[0],{p:i,a,b:o,byteLength:s}=t;if(r===4||r===6||r===7){if(n.length!==1+2*s)throw Error(`Invalid public key length: expected ${1+2*s} bytes, got ${n.length}`);let e=bufferToBigint(n.subarray(1,1+s)),t=bufferToBigint(n.subarray(1+s));if(mod(t*t,i)!==mod(e*e*e+a*e+o,i))throw Error(`Invalid public key: point is not on the curve`);return{x:e,y:t}}if(r===2||r===3){if(n.length!==1+s)throw Error(`Invalid public key length: expected ${1+s} bytes, got ${n.length}`);let e=bufferToBigint(n.subarray(1,1+s)),t=sqrtMod(mod(e*e*e+a*e+o,i),i);if(t===null)throw Error(`Invalid public key: no valid y coordinate for the given x`);let c=r===3;return{x:e,y:t%2n!=0n===c?t:mod(i-t,i)}}throw Error(`Invalid public key prefix: 0x${r.toString(16).padStart(2,`0`)}`)}function sqrtMod(e,t){if(e=mod(e,t),e===0n)return 0n;if(modPow(e,(t-1n)/2n,t)!==1n)return null;if(mod(t,4n)===3n)return modPow(e,(t+1n)/4n,t);let n=0n,r=t-1n;for(;mod(r,2n)===0n;)r/=2n,n++;let i=2n;for(;modPow(i,(t-1n)/2n,t)!==t-1n;)i++;let a=n,o=modPow(i,r,t),s=modPow(e,r,t),c=modPow(e,(r+1n)/2n,t);for(;;){if(s===0n)return 0n;if(s===1n)return c;let e=1n,n=mod(s*s,t);for(;n!==1n;)n=mod(n*n,t),e++;let r=modPow(o,modPow(2n,a-e-1n,t-1n),t);a=e,o=mod(r*r,t),s=mod(s*o,t),c=mod(c*r,t)}}function toBuffer$1(e,t){if(q.isBuffer(e))return e;if(e instanceof Uint8Array)return q.from(e);if(typeof e==`string`)return q.from(e,t||`utf8`);if(ArrayBuffer.isView(e))return q.from(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`The "key" argument must be of type string or an instance of Buffer, TypedArray, or DataView.`)}function formatReturnValue(e,t){return t?e.toString(t):e}function resolveCurve(e){let t=zi[e.toLowerCase()];if(!t)throw Error(`Unsupported curve: ${e}`);let n=Ri[t];if(!n)throw Error(`Unsupported curve: ${e}`);return{canonical:t,params:n}}function createECDH(e){return new ECDH(e)}function getCurves(){return[`secp256k1`,`prime256v1`,`secp256r1`,`secp384r1`,`secp521r1`]}var Ri,zi,ECDH,Bi=__esmMin(()=>{Ai(),ki(),J(),Ri={secp256k1:{p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,byteLength:32},prime256v1:{p:115792089210356248762697446949407573530086143415290314195533631308867097853951n,a:115792089210356248762697446949407573530086143415290314195533631308867097853951n-3n,b:41058363725152142129326129780047268409114441015993725554835256314039467401291n,Gx:48439561293906451759052585252797914202762949526041747995844080717082404635286n,Gy:36134250956749795798585127919587881956611106672985015071877198253568414405109n,n:115792089210356248762697446949407573529996955224135760342422259061068512044369n,byteLength:32},secp384r1:{p:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n,a:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n-3n,b:27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,Gx:26247035095799689268623156744566981891852923491109213387815615900925518854738050089022388053975719786650872476732087n,Gy:8325710961489029985546751289520108179287853048861315594709205902480503199884419224438643760392947333078086511627871n,n:39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643n,byteLength:48},secp521r1:{p:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n,a:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n-3n,b:1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,Gx:2661740802050217063228768716723360960729859168756973147706671368418802944996427808491545080627771902352094241225065558662157113545570916814161637315895999846n,Gy:3757180025770020463545507224491183603594455134769762486694567779615544477440556316691234405012945539562144444537289428522585666729196580810124344277578376784n,n:6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449n,byteLength:66}},zi={secp256k1:`secp256k1`,prime256v1:`prime256v1`,secp256r1:`prime256v1`,"p-256":`prime256v1`,p256:`prime256v1`,secp384r1:`secp384r1`,"p-384":`secp384r1`,p384:`secp384r1`,secp521r1:`secp521r1`,"p-521":`secp521r1`,p521:`secp521r1`},__name(modInverse$2,`modInverse`),__name(toBuffer$1,`toBuffer`),ECDH=class{_curve;_curveName;_privateKey=null;_publicKey=null;constructor(e){let t=resolveCurve(e);this._curve=t.params,this._curveName=t.canonical}generateKeys(e,t){let{n,byteLength:r}=this._curve,i;do i=bufferToBigint(randomBytes(r));while(i===0n||i>=n);this._privateKey=i;let a={x:this._curve.Gx,y:this._curve.Gy};return this._publicKey=scalarMul(i,a,this._curve),e===void 0?this.getPublicKey():this.getPublicKey(e,t)}computeSecret(e,t,n){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);let r=decodePublicKey(toBuffer$1(e,t),this._curve);if(r===null)throw Error(`Invalid public key: point at infinity`);let i=scalarMul(this._privateKey,r,this._curve);if(i===null)throw Error(`Shared secret computation resulted in the point at infinity`);return formatReturnValue(bigintToBuffer(i.x,this._curve.byteLength),n)}getPublicKey(e,t){if(this._publicKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(encodePublicKey(this._publicKey,this._curve.byteLength,t||`uncompressed`),e)}getPrivateKey(e){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(bigintToBuffer(this._privateKey,this._curve.byteLength),e)}setPublicKey(e,t){let n=toBuffer$1(e,t);this._publicKey=decodePublicKey(n,this._curve)}setPrivateKey(e,t){let n=bufferToBigint(toBuffer$1(e,t));if(n===0n||n>=this._curve.n)throw Error(`Private key is out of range [1, n-1]`);this._privateKey=n;let r={x:this._curve.Gx,y:this._curve.Gy};this._publicKey=scalarMul(n,r,this._curve)}}});function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function hashSize(e){let t=Vi[normalizeAlgorithm(e)];if(t===void 0)throw Error(`Unknown hash algorithm: ${e}`);return t}function toBuffer(e,t){return typeof e==`string`?q.from(e,t||`utf8`):e instanceof DataView?q.from(e.buffer,e.byteOffset,e.byteLength):(e instanceof ArrayBuffer,q.from(e))}var Vi,Hi,Ui,Wi=__esmMin(()=>{J(),Vi={md5:16,sha1:20,sha256:32,sha384:48,sha512:64},Hi={md5:64,sha1:64,sha256:64,sha384:128,sha512:128},Ui=new Set([`md5`,`sha1`,`sha256`,`sha384`,`sha512`])});function getChecksumType(e){let t=Gi[normalizeAlgorithm(e)];if(t===void 0){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}return t}function getHashes(){return[`md5`,`sha1`,`sha256`,`sha384`,`sha512`]}function hash(e,t,n){return new Ki(e).update(t).digest(n)}var Gi,Ki,qi=__esmMin(()=>{Wi(),J(),A(),Kr(),Gi={md5:k.ChecksumType.MD5,sha1:k.ChecksumType.SHA1,sha256:k.ChecksumType.SHA256,sha384:k.ChecksumType.SHA384,sha512:k.ChecksumType.SHA512},Ki=class Hash extends Ur{_algorithm;_checksum;_finalized=!1;constructor(e){super();let t=normalizeAlgorithm(e),n=getChecksumType(t);this._algorithm=t,this._checksum=new k.Checksum(n)}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;if(typeof e==`string`){let r=normalizeEncoding(t);n=q.from(e,r)}else n=e instanceof Uint8Array?e:q.from(e);return this._checksum.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._checksum.get_string(),n=q.from(t,`hex`);return e?n.toString(e):n}copy(){if(this._finalized)throw Error(`Digest already called`);let e=Object.create(Hash.prototype);return Ur.call(e),e._algorithm=this._algorithm,e._finalized=!1,e._checksum=this._checksum.copy(),e}_transform(e,t,n){try{this.update(e,t),n()}catch(e){n(e)}}_flush(e){try{this.push(this.digest()),e()}catch(t){e(t)}}}}),Hmac,Ji=__esmMin(()=>{Wi(),qi(),J(),Kr(),Hmac=class extends Ur{_algorithm;_innerHash;_outerKeyPad;_finalized=!1;constructor(e,t){super();let n=normalizeAlgorithm(e);if(!Ui.has(n)){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}this._algorithm=n;let r;r=typeof t==`string`?q.from(t,`utf8`):t instanceof Uint8Array?t:q.from(t);let i=Hi[n];if(r.length>i){let e=new Ki(n);e.update(r),r=e.digest()}let a=new Uint8Array(i);a.set(r);let o=new Uint8Array(i),s=new Uint8Array(i);for(let e=0;e<i;e++)o[e]=a[e]^54,s[e]=a[e]^92;this._outerKeyPad=s,this._innerHash=new Ki(n),this._innerHash.update(o)}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;if(typeof e==`string`){let r=normalizeEncoding(t);n=q.from(e,r)}else n=e instanceof Uint8Array?e:q.from(e);return this._innerHash.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._innerHash.digest(),n=new Ki(this._algorithm);n.update(this._outerKeyPad),n.update(t);let r=n.digest();return e?r.toString(e):r}_transform(e,t,n){try{this.update(e,t),n()}catch(e){n(e)}}_flush(e){try{this.push(this.digest()),e()}catch(t){e(t)}}}});function getCurve(e){let t=zi[e.toLowerCase()];if(!t)throw Error(`Unsupported curve: ${e}`);return Ri[t]}function truncateHash(e,t){let n=t.n.toString(2).length,r=bytesToBigInt(e),i=e.length*8;return i>n&&(r>>=BigInt(i-n)),r}function hmacDigest$2(e,t,n){let r=new Hmac(e,t);return r.update(n),new Uint8Array(r.digest())}function rfc6979(e,t,n,r){let i=r.byteLength,a=n.length,o=new Uint8Array(a).fill(1),s=new Uint8Array(a).fill(0),c=bigIntToBytes(t,i),l=bigIntToBytes(mod(truncateHash(n,r),r.n),i),u=new Uint8Array(a+1+i+i);u.set(o,0),u[a]=0,u.set(c,a+1),u.set(l,a+1+i),s=hmacDigest$2(e,s,u),o=hmacDigest$2(e,s,o);let d=new Uint8Array(a+1+i+i);d.set(o,0),d[a]=1,d.set(c,a+1),d.set(l,a+1+i),s=hmacDigest$2(e,s,d),o=hmacDigest$2(e,s,o);for(let t=0;t<100;t++){let t=new Uint8Array;for(;t.length<i;){o=hmacDigest$2(e,s,o);let n=new Uint8Array(t.length+o.length);n.set(t,0),n.set(o,t.length),t=n}let n=truncateHash(t.slice(0,i),r);if(n>=1n&&n<r.n)return n;let c=new Uint8Array(a+1);c.set(o,0),c[a]=0,s=hmacDigest$2(e,s,c),o=hmacDigest$2(e,s,o)}throw Error(`RFC 6979: failed to generate valid k after 100 attempts`)}function ecdsaSign(e,t,n,r){let i=getCurve(r),a={x:i.Gx,y:i.Gy},o=bytesToBigInt(t),s=new Ki(e);s.update(n);let c=new Uint8Array(s.digest()),l=truncateHash(c,i),u=rfc6979(e,o,c,i),d=scalarMul(u,a,i);if(d===null)throw Error(`ECDSA: k * G is point at infinity`);let p=mod(d.x,i.n);if(p===0n)throw Error(`ECDSA: r is zero`);let m=mod(modInverse$2(u,i.n)*(l+p*o),i.n);if(m===0n)throw Error(`ECDSA: s is zero`);let h=i.byteLength,g=new Uint8Array(h*2);return g.set(bigIntToBytes(p,h),0),g.set(bigIntToBytes(m,h),h),g}function ecdsaVerify(e,t,n,r,i){let a=getCurve(i),o={x:a.Gx,y:a.Gy},s=a.byteLength;if(t[0]!==4||t.length!==1+s*2)return!1;let c={x:bytesToBigInt(t.slice(1,1+s)),y:bytesToBigInt(t.slice(1+s))};if(n.length!==s*2)return!1;let l=bytesToBigInt(n.slice(0,s)),u=bytesToBigInt(n.slice(s));if(l<1n||l>=a.n||u<1n||u>=a.n)return!1;let d=new Ki(e);d.update(r);let p=truncateHash(new Uint8Array(d.digest()),a),m=modInverse$2(u,a.n),h=mod(p*m,a.n),g=mod(l*m,a.n),_=pointAdd(scalarMul(h,o,a),scalarMul(g,c,a),a);return _===null?!1:mod(_.x,a.n)===l}var Yi=__esmMin(()=>{Ai(),Bi(),qi(),Ji(),__name(hmacDigest$2,`hmacDigest`)});function hmacDigest$1(e,t,n){let r=new Hmac(e,t);return r.update(n),r.digest()}function hkdfExtract(e,t,n){return hmacDigest$1(e,n,t)}function hkdfExpand(e,t,n,r,i){let a=Math.ceil(r/i);if(a>255)throw Error(`HKDF cannot generate more than 255 * HashLen bytes`);let o=q.allocUnsafe(a*i),s=q.alloc(0);for(let r=1;r<=a;r++)s=hmacDigest$1(e,t,q.concat([s,n,q.from([r])])),s.copy(o,(r-1)*i);return q.from(o.buffer,o.byteOffset,r)}function hkdfSync(e,t,n,r,i){let a=normalizeAlgorithm(e),o=Vi[a];if(!Ui.has(a)||o===void 0)throw TypeError(`Unknown message digest: ${e}`);if(typeof i!=`number`||i<0)throw TypeError(`keylen must be a non-negative number`);let s=toBuffer(t),c=toBuffer(n),l=toBuffer(r),u=hkdfExpand(a,hkdfExtract(a,s,c.length===0?q.alloc(o,0):c),l,i,o),d=new ArrayBuffer(u.length);return new Uint8Array(d).set(u),d}function hkdf(e,t,n,r,i,a){setTimeout(()=>{try{a(null,hkdfSync(e,t,n,r,i))}catch(e){a(e instanceof Error?e:Error(String(e)))}},0)}var Xi=__esmMin(()=>{Wi(),Ji(),J(),__name(hmacDigest$1,`hmacDigest`)});function timingSafeEqual(e,t){if(e.length!==t.length)throw RangeError(`Input buffers must have the same byte length`);let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var Zi=__esmMin(()=>{});function hmacDigest(e,t,n){let r=new Hmac(e,t);return r.update(n),r.digest()}function validateParameters(e,t){if(typeof e!=`number`||e<0||!Number.isFinite(e)||e===0)throw TypeError(`iterations must be a positive number`);if(typeof t!=`number`||t<0||!Number.isFinite(t)||t>2147483647)throw TypeError(`keylen must be a positive number`)}function pbkdf2Sync(e,t,n,r,i){validateParameters(n,r);let a=toBuffer(e),o=toBuffer(t),s=normalizeAlgorithm(i||`sha1`),c=Vi[s];if(!Ui.has(s)||c===void 0)throw TypeError(`Unknown message digest: ${i||`sha1`}`);if(r===0)return q.alloc(0);let l=Math.ceil(r/c),u=q.allocUnsafe(l*c);for(let e=1;e<=l;e++){let t=q.allocUnsafe(o.length+4);o.copy(t,0),t.writeUInt32BE(e,o.length);let r=hmacDigest(s,a,t),i=q.from(r);for(let e=1;e<n;e++){r=hmacDigest(s,a,r);for(let e=0;e<c;e++)i[e]^=r[e]}i.copy(u,(e-1)*c)}return q.from(u.buffer,u.byteOffset,r)}function pbkdf2(e,t,n,r,i,a){validateParameters(n,r),setTimeout(()=>{try{a(null,pbkdf2Sync(e,t,n,r,i))}catch(e){a(e instanceof Error?e:Error(String(e)))}},0)}var Qi=__esmMin(()=>{Wi(),Ji(),J()});function R(e,t){return(e<<t|e>>>32-t)>>>0}function salsa20_8(e){let t=new Uint32Array(16);for(let n=0;n<16;n++)t[n]=e[n];for(let e=0;e<4;e++)t[4]^=R(t[0]+t[12],7),t[8]^=R(t[4]+t[0],9),t[12]^=R(t[8]+t[4],13),t[0]^=R(t[12]+t[8],18),t[9]^=R(t[5]+t[1],7),t[13]^=R(t[9]+t[5],9),t[1]^=R(t[13]+t[9],13),t[5]^=R(t[1]+t[13],18),t[14]^=R(t[10]+t[6],7),t[2]^=R(t[14]+t[10],9),t[6]^=R(t[2]+t[14],13),t[10]^=R(t[6]+t[2],18),t[3]^=R(t[15]+t[11],7),t[7]^=R(t[3]+t[15],9),t[11]^=R(t[7]+t[3],13),t[15]^=R(t[11]+t[7],18),t[1]^=R(t[0]+t[3],7),t[2]^=R(t[1]+t[0],9),t[3]^=R(t[2]+t[1],13),t[0]^=R(t[3]+t[2],18),t[6]^=R(t[5]+t[4],7),t[7]^=R(t[6]+t[5],9),t[4]^=R(t[7]+t[6],13),t[5]^=R(t[4]+t[7],18),t[11]^=R(t[10]+t[9],7),t[8]^=R(t[11]+t[10],9),t[9]^=R(t[8]+t[11],13),t[10]^=R(t[9]+t[8],18),t[12]^=R(t[15]+t[14],7),t[13]^=R(t[12]+t[15],9),t[14]^=R(t[13]+t[12],13),t[15]^=R(t[14]+t[13],18);for(let n=0;n<16;n++)e[n]=e[n]+t[n]>>>0}function blockMix(e,t){let n=2*t*16,r=new Uint32Array(16);for(let t=0;t<16;t++)r[t]=e[n-16+t];let i=new Uint32Array(n);for(let n=0;n<2*t;n++){for(let t=0;t<16;t++)r[t]^=e[n*16+t];salsa20_8(r);for(let e=0;e<16;e++)i[n*16+e]=r[e]}for(let n=0;n<t;n++)for(let t=0;t<16;t++)e[n*16+t]=i[2*n*16+t];for(let n=0;n<t;n++)for(let r=0;r<16;r++)e[(t+n)*16+r]=i[(2*n+1)*16+r]}function roMix(e,t,n){let r=2*n*16,i=Array.from({length:t});for(let r=0;r<t;r++)i[r]=new Uint32Array(e),blockMix(e,n);for(let a=0;a<t;a++){let a=e[r-16]&t-1;for(let t=0;t<r;t++)e[t]^=i[a][t];blockMix(e,n)}}function bytesToWords(e){let t=new Uint32Array(e.length/4);for(let n=0;n<t.length;n++)t[n]=e[n*4]|e[n*4+1]<<8|e[n*4+2]<<16|e[n*4+3]<<24;return t}function wordsToBytes(e){let t=new Uint8Array(e.length*4);for(let n=0;n<e.length;n++)t[n*4]=e[n]&255,t[n*4+1]=e[n]>>8&255,t[n*4+2]=e[n]>>16&255,t[n*4+3]=e[n]>>24&255;return t}function scryptCore(e,t,n,r,i,a){let o=128*r,s=pbkdf2Sync(e,t,1,i*o,`sha256`);for(let e=0;e<i;e++){let t=new Uint8Array(s.buffer,s.byteOffset+e*o,o),i=bytesToWords(t);roMix(i,n,r);let a=wordsToBytes(i);t.set(a)}return pbkdf2Sync(e,s,1,a,`sha256`)}function scryptSync(e,t,n,r){let i=q.from(e),a=q.from(t),o=r?.N??16384,s=r?.r??8,c=r?.p??1;if(o<=0||o&o-1)throw Error(`N must be a positive power of 2`);return scryptCore(i,a,o,s,c,n)}function scrypt(e,t,n,r,i){let a={},o;typeof r==`function`?o=r:(a=r,o=i);try{let r=scryptSync(e,t,n,a);setTimeout(()=>o(null,r),0)}catch(e){setTimeout(()=>o(e instanceof Error?e:Error(String(e)),q.alloc(0)),0)}}var $i=__esmMin(()=>{Qi(),J()});function pemToDer(e){let t=e.trim().split(/\r?\n/),n=t.findIndex(e=>e.startsWith(`-----BEGIN `));if(n===-1)throw Error(`Invalid PEM: no BEGIN line found`);let r=t[n].match(/^-----BEGIN (.+)-----$/);if(!r)throw Error(`Invalid PEM header format`);let i=r[1],a=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(a===-1)throw Error(`Invalid PEM: no END line found`);let o=t.slice(n+1,a).join(``),s=q.from(o,`base64`);return{type:i,der:new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}}function parseTlv(e,t){if(t>=e.length)throw Error(`ASN.1 parse error: unexpected end of data`);let n=e[t++],r,i=e[t++];if(i<128)r=i;else{let n=i&127;if(n===0)throw Error(`ASN.1 parse error: indefinite length not supported`);r=0;for(let i=0;i<n;i++)r=r<<8|e[t++]}let a=e.slice(t,t+r),o=t+r,s={tag:n,data:a};return n===48&&(s.children=parseSequenceChildren(a)),{value:s,next:o}}function parseSequenceChildren(e){let t=[],n=0;for(;n<e.length;){let{value:r,next:i}=parseTlv(e,n);t.push(r),n=i}return t}function parseDer(e){let{value:t}=parseTlv(e,0);return t}function integerToBigInt(e){let t=0;for(;t<e.length-1&&e[t]===0;)t++;let n=0n;for(let r=t;r<e.length;r++)n=n<<8n|BigInt(e[r]);return n}function oidsEqual(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function parseRsaPublicKeyPkcs1(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid PKCS#1 RSAPublicKey structure`);return{n:integerToBigInt(t[0].data),e:integerToBigInt(t[1].data)}}function parseRsaPrivateKeyPkcs1(e){let t=e.children;if(!t||t.length<6)throw Error(`Invalid PKCS#1 RSAPrivateKey structure`);return{n:integerToBigInt(t[1].data),e:integerToBigInt(t[2].data),d:integerToBigInt(t[3].data),p:integerToBigInt(t[4].data),q:integerToBigInt(t[5].data)}}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=t[0];if(!n.children||n.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let r=n.children[0];if(r.tag!==6||!oidsEqual(r.data,ea))throw Error(`Unsupported algorithm: only RSA is supported`);let i=t[1];if(i.tag!==3)throw Error(`Expected BIT STRING for public key data`);return parseRsaPublicKeyPkcs1(parseDer(i.data.slice(1)))}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=t[1];if(!n.children||n.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let r=n.children[0];if(r.tag!==6||!oidsEqual(r.data,ea))throw Error(`Unsupported algorithm: only RSA is supported`);let i=t[2];if(i.tag!==4)throw Error(`Expected OCTET STRING for private key data`);return parseRsaPrivateKeyPkcs1(parseDer(i.data))}function encodeLength(e){if(e<128)return new Uint8Array([e]);let t=[],n=e;for(;n>0;)t.unshift(n&255),n>>=8;return new Uint8Array([128|t.length,...t])}function encodeTlv(e,t){let n=encodeLength(t.length),r=new Uint8Array(1+n.length+t.length);return r[0]=e,r.set(n,1),r.set(t,1+n.length),r}function bigintToAsn1Integer(e){if(e===0n)return encodeTlv(2,new Uint8Array([0]));let t=e.toString(16),n=t.length%2?`0`+t:t,r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return r[0]&128&&r.unshift(0),encodeTlv(2,new Uint8Array(r))}function encodeSequence(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return encodeTlv(48,n)}function encodeBitString(e){let t=new Uint8Array(1+e.length);return t[0]=0,t.set(e,1),encodeTlv(3,t)}function encodeOctetString(e){return encodeTlv(4,e)}function encodeOid(e){return encodeTlv(6,e)}function encodeNull(){return new Uint8Array([5,0])}function encodeRsaPublicKeyPkcs1(e){return encodeSequence([bigintToAsn1Integer(e.n),bigintToAsn1Integer(e.e)])}function encodeSubjectPublicKeyInfo(e){return encodeSequence([encodeSequence([encodeOid(ea),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$1(e.q,e.p);return encodeSequence([bigintToAsn1Integer(0n),bigintToAsn1Integer(e.n),bigintToAsn1Integer(e.e),bigintToAsn1Integer(e.d),bigintToAsn1Integer(e.p),bigintToAsn1Integer(e.q),bigintToAsn1Integer(t),bigintToAsn1Integer(n),bigintToAsn1Integer(r)])}function encodePrivateKeyInfo(e){let t=encodeSequence([encodeOid(ea),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function derToPem(e,t){let n=q.from(e).toString(`base64`),r=[`-----BEGIN ${t}-----`];for(let e=0;e<n.length;e+=64)r.push(n.substring(e,e+64));return r.push(`-----END ${t}-----`),r.join(`
6
+ `)}function modInverse$1(e,t){let[n,r]=[e%t,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}return(i%t+t)%t}function parseX509(e){let{der:t}=pemToDer(e);return parseX509Der(t)}function parseX509Der(e){let t=parseDer(e);if(t.tag!==48||!t.children||t.children.length<3)throw Error(`Invalid X.509 certificate structure`);let n=t.children[0],r=t.children[1],i=t.children[2];if(!n.children||n.children.length<6)throw Error(`Invalid TBSCertificate structure`);let a=0;n.children[0].tag===160&&a++;let o=integerToBigInt(n.children[a].data);a++,a++;let s=parseDN(n.children[a]);a++;let c=n.children[a],l=parseAsn1Time(c.children[0]),u=parseAsn1Time(c.children[1]);a++;let d=parseDN(n.children[a]);a++;let p=null,m=`unknown`;if(a<n.children.length){let e=n.children[a];try{if(e.children&&e.children.length>=2){let t=e.children[0];if(t.children&&t.children.length>=1){let n=t.children[0];n.tag===6&&oidsEqual(n.data,ea)&&(m=`rsa`,p=parseSubjectPublicKeyInfo(e))}}}catch{}a++}let h,g;for(let e=a;e<n.children.length;e++){let t=n.children[e];if(t.tag===163&&t.data.length>0){let e=parseDer(t.data);if(e.children){g=e.children;let t=new Uint8Array([85,29,17]);for(let n of e.children)if(n.children&&n.children.length>=2){let e=n.children[0];if(e.tag===6&&oidsEqual(e.data,t)){let e=n.children[n.children.length-1];h=parseSAN(e.data)}}}}}let _=`unknown`;r.children&&r.children.length>=1&&(_=oidToName(r.children[0].data));let v=i.tag===3?i.data.slice(1):i.data;return{raw:e,tbsCertificate:n.data,serialNumber:o,issuer:s,subject:d,validFrom:l,validTo:u,publicKey:p,publicKeyAlgorithm:m,signatureAlgorithm:_,signature:v,subjectAltName:h,extensions:g}}function decodeOidString(e){if(e.length===0)return``;let t=[];t.push(Math.floor(e[0]/40)),t.push(e[0]%40);let n=0;for(let r=1;r<e.length;r++)n=n<<7|e[r]&127,e[r]&128||(t.push(n),n=0);return t.join(`.`)}function oidToName(e){let t=decodeOidString(e);return na[t]||t}function parseDN(e){if(!e.children)return``;let t=[];for(let n of e.children){let e=n.tag===49?parseSequenceChildren(n.data):n.children||[];for(let n of e)if(n.children&&n.children.length>=2){let e=n.children[0].data,r=decodeOidString(e),i=ta[r]||r,a=n.children[1].data,o=new TextDecoder().decode(a);t.push(`${i}=${o}`)}}return t.join(`, `)}function parseAsn1Time(e){let t=new TextDecoder().decode(e.data);if(e.tag===23){let e=parseInt(t.substring(0,2),10);e=e>=50?1900+e:2e3+e;let n=parseInt(t.substring(2,4),10)-1,r=parseInt(t.substring(4,6),10),i=parseInt(t.substring(6,8),10),a=parseInt(t.substring(8,10),10),o=parseInt(t.substring(10,12),10);return new Date(Date.UTC(e,n,r,i,a,o))}if(e.tag===24){let e=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10)-1,r=parseInt(t.substring(6,8),10),i=parseInt(t.substring(8,10),10),a=parseInt(t.substring(10,12),10),o=parseInt(t.substring(12,14),10);return new Date(Date.UTC(e,n,r,i,a,o))}throw Error(`Unsupported time tag: 0x${e.tag.toString(16)}`)}function parseSAN(e){let t=[];try{let n=parseDer(e);if(n.tag===48&&n.children){for(let e of n.children)if(e.tag===130)t.push(`DNS:`+new TextDecoder().decode(e.data));else if(e.tag===135){if(e.data.length===4)t.push(`IP Address:`+e.data.join(`.`));else if(e.data.length===16){let n=[];for(let t=0;t<16;t+=2)n.push((e.data[t]<<8|e.data[t+1]).toString(16));t.push(`IP Address:`+n.join(`:`))}}}}catch{}return t}function parsePemKey(e){let{type:t,der:n}=pemToDer(e),r=parseDer(n);if(r.tag!==48)throw Error(`Invalid key format: expected top-level SEQUENCE`);switch(t){case`RSA PUBLIC KEY`:return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(r)};case`PUBLIC KEY`:return{type:`rsa-public`,components:parseSubjectPublicKeyInfo(r)};case`RSA PRIVATE KEY`:return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(r)};case`PRIVATE KEY`:return{type:`rsa-private`,components:parsePrivateKeyInfo(r)};default:throw Error(`Unsupported PEM type: ${t}`)}}function rsaKeySize(e){let t=0,n=e;for(;n>0n;)t++,n>>=1n;return Math.ceil(t/8)}var ea,ta,na,ra=__esmMin(()=>{J(),ea=new Uint8Array([42,134,72,134,247,13,1,1,1]),__name(modInverse$1,`modInverse`),ta={"2.5.4.3":`CN`,"2.5.4.6":`C`,"2.5.4.7":`L`,"2.5.4.8":`ST`,"2.5.4.10":`O`,"2.5.4.11":`OU`,"1.2.840.113549.1.9.1":`emailAddress`},na={"1.2.840.113549.1.1.1":`rsaEncryption`,"1.2.840.113549.1.1.5":`sha1WithRSAEncryption`,"1.2.840.113549.1.1.11":`sha256WithRSAEncryption`,"1.2.840.113549.1.1.12":`sha384WithRSAEncryption`,"1.2.840.113549.1.1.13":`sha512WithRSAEncryption`}});function normalizeSignAlgorithm(e){let t=e.toLowerCase().replace(/-/g,``);if(t.startsWith(`rsa`)&&(t=t.slice(3)),!ia[t])throw Error(`Unsupported algorithm: ${e}. Supported: RSA-SHA1, RSA-SHA256, RSA-SHA512`);return t}function extractPem$1(e){if(typeof e==`string`)return e;if(q.isBuffer(e)||e instanceof Uint8Array)return q.from(e).toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e.key;if(typeof t==`string`)return t;if(q.isBuffer(t)||t instanceof Uint8Array)return q.from(t).toString(`utf8`)}throw TypeError(`Invalid key argument`)}function createSign(e){return new Sign(e)}function createVerify(e){return new Verify(e)}var ia,Sign,Verify,aa=__esmMin(()=>{ra(),Ai(),qi(),J(),ia={sha1:new Uint8Array([48,33,48,9,6,5,43,14,3,2,26,5,0,4,20]),sha256:new Uint8Array([48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]),sha512:new Uint8Array([48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64])},__name(extractPem$1,`extractPem`),Sign=class{_algorithm;_hash;_finalized=!1;constructor(e){this._algorithm=normalizeSignAlgorithm(e),this._hash=new Ki(this._algorithm)}update(e,t){if(this._finalized)throw Error(`Sign was already finalized`);return this._hash.update(e,t),this}sign(e,t){if(this._finalized)throw Error(`Sign was already finalized`);this._finalized=!0;let n=this._hash.digest(),r=parsePemKey(extractPem$1(e));if(r.type!==`rsa-private`)throw Error(`privateKey must be an RSA private key`);let{n:i,d:a}=r.components,o=rsaKeySize(i),s=ia[this._algorithm],c=new Uint8Array(s.length+n.length);c.set(s,0),c.set(n,s.length);let l=o-c.length-3;if(l<8)throw Error(`Key is too short for the specified hash algorithm`);let u=new Uint8Array(o);u[0]=0,u[1]=1;for(let e=2;e<2+l;e++)u[e]=255;u[2+l]=0,u.set(c,3+l);let d=bigIntToBytes(modPow(bytesToBigInt(u),a,i),o),p=q.from(d);return t?p.toString(t):p}},Verify=class{_algorithm;_hash;_finalized=!1;constructor(e){this._algorithm=normalizeSignAlgorithm(e),this._hash=new Ki(this._algorithm)}update(e,t){if(this._finalized)throw Error(`Verify was already finalized`);return this._hash.update(e,t),this}verify(e,t,n){if(this._finalized)throw Error(`Verify was already finalized`);this._finalized=!0;let r=this._hash.digest(),i=parsePemKey(extractPem$1(e)),a,o;if(i.type===`rsa-public`)a=i.components.n,o=i.components.e;else if(i.type===`rsa-private`)a=i.components.n,o=i.components.e;else throw Error(`publicKey must be an RSA public or private key`);let s=rsaKeySize(a),c;if(c=typeof t==`string`?q.from(t,n||`base64`):t instanceof Uint8Array?t:q.from(t),c.length!==s)return!1;let l=bytesToBigInt(c);if(l>=a)return!1;let u=bigIntToBytes(modPow(l,o,a),s);if(u[0]!==0||u[1]!==1)return!1;let d=2;for(;d<u.length&&u[d]===255;)d++;if(d>=u.length||u[d]!==0||d-2<8)return!1;d++;let p=u.slice(d),m=ia[this._algorithm],h=new Uint8Array(m.length+r.length);if(h.set(m,0),h.set(r,m.length),p.length!==h.length)return!1;let g=0;for(let e=0;e<p.length;e++)g|=p[e]^h[e];return g===0}}});function extractPem(e){if(typeof e==`string`)return e;if(q.isBuffer(e)||e instanceof Uint8Array)return q.from(e).toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e.key;if(typeof t==`string`)return t;if(q.isBuffer(t)||t instanceof Uint8Array)return q.from(t).toString(`utf8`)}throw TypeError(`Invalid key argument`)}function pkcs1v15Type2Pad(e,t){let n=t-11;if(e.length>n)throw Error(`Data too long for key size. Max ${n} bytes, got ${e.length}`);let r=t-e.length-3,i=new Uint8Array(t);i[0]=0,i[1]=2;let a=randomBytes(r);for(let e=0;e<r;e++){for(;a[e]===0;)a[e]=randomBytes(1)[0];i[2+e]=a[e]}return i[2+r]=0,i.set(e,3+r),i}function pkcs1v15Type1Pad(e,t){let n=t-11;if(e.length>n)throw Error(`Data too long for key size. Max ${n} bytes, got ${e.length}`);let r=t-e.length-3,i=new Uint8Array(t);i[0]=0,i[1]=1;for(let e=2;e<2+r;e++)i[e]=255;return i[2+r]=0,i.set(e,3+r),i}function pkcs1v15Type2Unpad(e){if(e.length<11)throw Error(`Decryption error: message too short`);if(e[0]!==0||e[1]!==2)throw Error(`Decryption error: invalid padding`);let t=2;for(;t<e.length&&e[t]!==0;)t++;if(t>=e.length||t<10)throw Error(`Decryption error: invalid padding`);return e.slice(t+1)}function pkcs1v15Type1Unpad(e){if(e.length<11)throw Error(`Decryption error: message too short`);if(e[0]!==0||e[1]!==1)throw Error(`Decryption error: invalid padding`);let t=2;for(;t<e.length&&e[t]===255;)t++;if(t>=e.length||e[t]!==0||t<10)throw Error(`Decryption error: invalid padding`);return e.slice(t+1)}function publicEncrypt(e,t){let n=parsePemKey(extractPem(e)),r,i;if(n.type===`rsa-public`)r=n.components.n,i=n.components.e;else if(n.type===`rsa-private`)r=n.components.n,i=n.components.e;else throw Error(`Key must be an RSA public or private key`);let a=rsaKeySize(r),o=modPow(bytesToBigInt(pkcs1v15Type2Pad(t instanceof Uint8Array?t:q.from(t),a)),i,r);return q.from(bigIntToBytes(o,a))}function privateDecrypt(e,t){let n=parsePemKey(extractPem(e));if(n.type!==`rsa-private`)throw Error(`Key must be an RSA private key`);let{n:r,d:i}=n.components,a=rsaKeySize(r),o=t instanceof Uint8Array?t:q.from(t);if(o.length!==a)throw Error(`Data length (${o.length}) does not match key length (${a})`);let s=bytesToBigInt(o);if(s>=r)throw Error(`Decryption error: cipher value out of range`);let c=bigIntToBytes(modPow(s,i,r),a);return q.from(pkcs1v15Type2Unpad(c))}function privateEncrypt(e,t){let n=parsePemKey(extractPem(e));if(n.type!==`rsa-private`)throw Error(`Key must be an RSA private key`);let{n:r,d:i}=n.components,a=rsaKeySize(r),o=modPow(bytesToBigInt(pkcs1v15Type1Pad(t instanceof Uint8Array?t:q.from(t),a)),i,r);return q.from(bigIntToBytes(o,a))}function publicDecrypt(e,t){let n=parsePemKey(extractPem(e)),r,i;if(n.type===`rsa-public`)r=n.components.n,i=n.components.e;else if(n.type===`rsa-private`)r=n.components.n,i=n.components.e;else throw Error(`Key must be an RSA public or private key`);let a=rsaKeySize(r),o=t instanceof Uint8Array?t:q.from(t);if(o.length!==a)throw Error(`Data length (${o.length}) does not match key length (${a})`);let s=bytesToBigInt(o);if(s>=r)throw Error(`Decryption error: cipher value out of range`);let c=bigIntToBytes(modPow(s,i,r),a);return q.from(pkcs1v15Type1Unpad(c))}var oa=__esmMin(()=>{ra(),Ai(),ki(),J()});function mgf1(e,t,n){let r=new Uint8Array(n),i=0,a=0;for(;i<n;){let o=new Uint8Array(4);o[0]=a>>>24&255,o[1]=a>>>16&255,o[2]=a>>>8&255,o[3]=a&255;let s=new Ki(e);s.update(t),s.update(o);let c=new Uint8Array(s.digest()),l=Math.min(c.length,n-i);r.set(c.slice(0,l),i),i+=l,a++}return r}var sa=__esmMin(()=>{qi()});function hashDigest$1(e,t){let n=new Ki(e);return n.update(t),new Uint8Array(n.digest())}function emsaPssEncode(e,t,n,r){let i=hashSize(n),a=Math.ceil(t/8);if(a<i+r+2)throw Error(`RSA-PSS: encoding error — key too short`);let o=r>0?new Uint8Array(randomBytes(r)):new Uint8Array,s=new Uint8Array(8+i+r);s.set(e,8),s.set(o,8+i);let c=hashDigest$1(n,s),l=a-i-1,u=new Uint8Array(l);u[l-r-1]=1,u.set(o,l-r);let d=mgf1(n,c,l),p=new Uint8Array(l);for(let e=0;e<l;e++)p[e]=u[e]^d[e];let m=8*a-t;m>0&&(p[0]&=255>>>m);let h=new Uint8Array(a);return h.set(p,0),h.set(c,l),h[a-1]=188,h}function emsaPssVerify(e,t,n,r,i){let a=hashSize(r),o=Math.ceil(n/8);if(o<a+i+2||t[o-1]!==188)return!1;let s=o-a-1,c=t.slice(0,s),l=t.slice(s,s+a),u=8*o-n;if(u>0&&c[0]&255<<8-u)return!1;let d=mgf1(r,l,s),p=new Uint8Array(s);for(let e=0;e<s;e++)p[e]=c[e]^d[e];u>0&&(p[0]&=255>>>u);for(let e=0;e<s-i-1;e++)if(p[e]!==0)return!1;if(p[s-i-1]!==1)return!1;let m=p.slice(s-i),h=new Uint8Array(8+a+i);h.set(e,8),h.set(m,8+a);let g=hashDigest$1(r,h);if(l.length!==g.length)return!1;let _=0;for(let e=0;e<l.length;e++)_|=l[e]^g[e];return _===0}function rsaPssSign(e,t,n,r){let i=parsePemKey(t);if(i.type!==`rsa-private`)throw Error(`RSA-PSS: expected RSA private key`);let{n:a,d:o}=i.components,s=rsaKeySize(a),c=Math.ceil(s/8);return bigIntToBytes(modPow(bytesToBigInt(emsaPssEncode(hashDigest$1(e,n),s-1,e,r)),o,a),c)}function rsaPssVerify(e,t,n,r,i){let a=parsePemKey(t),o,s;if(a.type===`rsa-public`)({n:o,e:s}=a.components);else if(a.type===`rsa-private`)({n:o,e:s}=a.components);else throw Error(`RSA-PSS: expected RSA key`);let c=rsaKeySize(o),l=Math.ceil(c/8);if(n.length!==l)return!1;let u=bigIntToBytes(modPow(bytesToBigInt(n),s,o),Math.ceil((c-1)/8));return emsaPssVerify(hashDigest$1(e,r),u,c-1,e,i)}var ca=__esmMin(()=>{ra(),Ai(),Wi(),ki(),qi(),sa(),__name(hashDigest$1,`hashDigest`)});function hashDigest(e,t){let n=new Ki(e);return n.update(t),new Uint8Array(n.digest())}function rsaOaepEncrypt(e,t,n,r){let i=parsePemKey(t),a,o;if(i.type===`rsa-public`)({n:a,e:o}=i.components);else if(i.type===`rsa-private`)({n:a,e:o}=i.components);else throw Error(`RSA-OAEP: expected RSA key`);let s=Math.ceil(rsaKeySize(a)/8),c=hashSize(e);if(n.length>s-2*c-2)throw Error(`RSA-OAEP: message too long`);let l=hashDigest(e,r||new Uint8Array),u=s-c-1,d=new Uint8Array(u);d.set(l,0),d[u-n.length-1]=1,d.set(n,u-n.length);let p=new Uint8Array(randomBytes(c)),m=mgf1(e,p,u),h=new Uint8Array(u);for(let e=0;e<u;e++)h[e]=d[e]^m[e];let g=mgf1(e,h,c),_=new Uint8Array(c);for(let e=0;e<c;e++)_[e]=p[e]^g[e];let v=new Uint8Array(s);return v[0]=0,v.set(_,1),v.set(h,1+c),bigIntToBytes(modPow(bytesToBigInt(v),o,a),s)}function rsaOaepDecrypt(e,t,n,r){let i=parsePemKey(t);if(i.type!==`rsa-private`)throw Error(`RSA-OAEP: expected RSA private key`);let{n:a,d:o}=i.components,s=Math.ceil(rsaKeySize(a)/8),c=hashSize(e);if(n.length!==s||s<2*c+2)throw Error(`RSA-OAEP: decryption error`);let l=bigIntToBytes(modPow(bytesToBigInt(n),o,a),s),u=l[0],d=l.slice(1,1+c),p=l.slice(1+c),m=s-c-1,h=mgf1(e,p,c),g=new Uint8Array(c);for(let e=0;e<c;e++)g[e]=d[e]^h[e];let _=mgf1(e,g,m),v=new Uint8Array(m);for(let e=0;e<m;e++)v[e]=p[e]^_[e];let y=hashDigest(e,r||new Uint8Array),b=v.slice(0,c),x=+(u===0);for(let e=0;e<c;e++)x&=+(y[e]===b[e]);let S=-1;for(let e=c;e<m;e++)if(v[e]===1){S=e;break}else if(v[e]!==0){x=0;break}if(S===-1&&(x=0),!x)throw Error(`RSA-OAEP: decryption error`);return v.slice(S+1)}var la=__esmMin(()=>{ra(),Ai(),Wi(),ki(),qi(),sa()});function bigintToBase64url(e){if(e===0n)return`AA`;let t=e.toString(16),n=t.length%2?`0`+t:t,r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return q.from(r).toString(`base64url`)}function base64urlToBigint(e){let t=q.from(e,`base64url`),n=0n;for(let e=0;e<t.length;e++)n=n<<8n|BigInt(t[e]);return n}function exportJwk(e,t){if(e.type===`rsa-public`)return{kty:`RSA`,n:bigintToBase64url(e.components.n),e:bigintToBase64url(e.components.e)};if(e.type===`rsa-private`){if(t===`public`)return{kty:`RSA`,n:bigintToBase64url(e.components.n),e:bigintToBase64url(e.components.e)};let{n,e:r,d:i,p:a,q:o}=e.components,s=i%(a-1n),c=i%(o-1n),l=modInverse(o,a);return{kty:`RSA`,n:bigintToBase64url(n),e:bigintToBase64url(r),d:bigintToBase64url(i),p:bigintToBase64url(a),q:bigintToBase64url(o),dp:bigintToBase64url(s),dq:bigintToBase64url(c),qi:bigintToBase64url(l)}}throw Error(`Unsupported key type for JWK export`)}function importJwkRsa(e){if(e.d){let t={n:base64urlToBigint(e.n),e:base64urlToBigint(e.e),d:base64urlToBigint(e.d),p:base64urlToBigint(e.p),q:base64urlToBigint(e.q)};return{parsed:{type:`rsa-private`,components:t},pem:derToPem(encodeRsaPrivateKeyPkcs1(t),`RSA PRIVATE KEY`)}}let t={n:base64urlToBigint(e.n),e:base64urlToBigint(e.e)};return{parsed:{type:`rsa-public`,components:t},pem:derToPem(encodeSubjectPublicKeyInfo(t),`PUBLIC KEY`)}}function generatePem(e,t,n){if(e.type===`rsa-public`)return n===`pkcs1`?derToPem(encodeRsaPublicKeyPkcs1(e.components),`RSA PUBLIC KEY`):derToPem(encodeSubjectPublicKeyInfo(e.components),`PUBLIC KEY`);if(e.type===`rsa-private`&&t===`public`){let t={n:e.components.n,e:e.components.e};return n===`pkcs1`?derToPem(encodeRsaPublicKeyPkcs1(t),`RSA PUBLIC KEY`):derToPem(encodeSubjectPublicKeyInfo(t),`PUBLIC KEY`)}if(e.type===`rsa-private`)return n===`pkcs8`?derToPem(encodePrivateKeyInfo(e.components),`PRIVATE KEY`):derToPem(encodeRsaPrivateKeyPkcs1(e.components),`RSA PRIVATE KEY`);throw Error(`Cannot generate PEM for this key type`)}function generateDer(e,t,n){if(e.type===`rsa-public`)return n===`pkcs1`?q.from(encodeRsaPublicKeyPkcs1(e.components)):q.from(encodeSubjectPublicKeyInfo(e.components));if(e.type===`rsa-private`&&t===`public`){let t={n:e.components.n,e:e.components.e};return n===`pkcs1`?q.from(encodeRsaPublicKeyPkcs1(t)):q.from(encodeSubjectPublicKeyInfo(t))}if(e.type===`rsa-private`)return n===`pkcs8`?q.from(encodePrivateKeyInfo(e.components)):q.from(encodeRsaPrivateKeyPkcs1(e.components));throw Error(`Cannot generate DER for this key type`)}function modInverse(e,t){let[n,r]=[e%t,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}return(i%t+t)%t}function createSecretKey(e,t){let n;return n=typeof e==`string`?q.from(e,t??`utf8`):new Uint8Array(e),new ua(`secret`,n)}function createPublicKey(e){if(e instanceof ua){if(e.type===`public`)return e;if(e.type===`private`){let t=e._handle;if(t.parsed.type===`rsa-private`){let e={n:t.parsed.components.n,e:t.parsed.components.e};return new ua(`public`,{parsed:{type:`rsa-public`,components:e},pem:derToPem(encodeSubjectPublicKeyInfo(e),`PUBLIC KEY`)})}}throw TypeError(`Cannot create public key from secret key`)}if(typeof e==`object`&&!q.isBuffer(e)&&`key`in e){let t=e;if(t.format===`jwk`){let e=t.key;if(e.kty===`RSA`){let{parsed:t,pem:n}=importJwkRsa({n:e.n,e:e.e});return new ua(`public`,{parsed:t,pem:n})}throw Error(`Unsupported JWK key type: ${e.kty}`)}}let t=normalizePem(e),n=parsePemKey(t);if(n.type===`rsa-private`){let e={n:n.components.n,e:n.components.e};return new ua(`public`,{parsed:{type:`rsa-public`,components:e},pem:derToPem(encodeSubjectPublicKeyInfo(e),`PUBLIC KEY`)})}return new ua(`public`,{parsed:n,pem:t})}function createPrivateKey(e){if(typeof e==`object`&&!q.isBuffer(e)&&`key`in e){let t=e;if(t.format===`jwk`){let e=t.key;if(e.kty===`RSA`&&e.d){let{parsed:t,pem:n}=importJwkRsa(e);return new ua(`private`,{parsed:t,pem:n})}throw Error(`JWK does not contain a private key`)}}let t=normalizePem(e),n=parsePemKey(t);if(n.type!==`rsa-private`)throw TypeError(`Key is not a private key`);return new ua(`private`,{parsed:n,pem:t})}function normalizePem(e){if(typeof e==`string`)return e;if(q.isBuffer(e))return e.toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e;if(typeof t.key==`string`)return t.key;if(q.isBuffer(t.key))return t.key.toString(t.encoding??`utf8`);if(t.key instanceof ua)return t.key.export({format:`pem`})}throw TypeError(`Invalid key input`)}var ua,da=__esmMin(()=>{ra(),J(),ua=class KeyObject{type;_handle;constructor(e,t){if(e!==`secret`&&e!==`public`&&e!==`private`)throw TypeError(`Invalid KeyObject type: ${e}`);this.type=e,this._handle=t}get symmetricKeySize(){if(this.type===`secret`)return this._handle.byteLength}get asymmetricKeyType(){if(this.type===`secret`)return;let e=this._handle;if(e.parsed.type===`rsa-public`||e.parsed.type===`rsa-private`)return`rsa`}get asymmetricKeySize(){if(this.type===`secret`)return;let e=this._handle;if(e.parsed.type===`rsa-public`||e.parsed.type===`rsa-private`)return rsaKeySize(e.parsed.components.n)/8}equals(e){if(!(e instanceof KeyObject)||this.type!==e.type)return!1;if(this.type===`secret`){let t=this._handle,n=e._handle;if(t.byteLength!==n.byteLength)return!1;for(let e=0;e<t.byteLength;e++)if(t[e]!==n[e])return!1;return!0}let t=this._handle,n=e._handle;return t.pem===n.pem}export(e){if(this.type===`secret`){let t=this._handle;return e?.format===`jwk`?{kty:`oct`,k:q.from(t).toString(`base64url`)}:q.from(t)}let t=this._handle,n=e?.format??`pem`,r=e?.type;if(n===`jwk`)return exportJwk(t.parsed,this.type);if(n===`pem`)return t.pem&&!t.pem.startsWith(`[`)?t.pem:generatePem(t.parsed,this.type,r);if(n===`der`){if(t.pem&&!t.pem.startsWith(`[`)){let e=t.pem.trim().split(/\r?\n/),n=e.findIndex(e=>e.startsWith(`-----BEGIN `)),r=e.findIndex((e,t)=>t>n&&e.startsWith(`-----END `)),i=e.slice(n+1,r).join(``);return q.from(i,`base64`)}return generateDer(t.parsed,this.type,r)}throw TypeError(`Unsupported export format: ${n}`)}get[Symbol.toStringTag](){return`KeyObject`}}});function formatFingerprint(e){let t=e.toString(`hex`).toUpperCase(),n=[];for(let e=0;e<t.length;e+=2)n.push(t.substring(e,e+2));return n.join(`:`)}function matchHostname(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return!0;if(n.startsWith(`*.`)){let e=n.substring(2),t=r.split(`.`);if(t.length>=2)return t.slice(1).join(`.`)===e}return!1}function parseDNToObject(e){let t={},n=e.split(`, `);for(let e of n){let n=e.indexOf(`=`);n>0&&(t[e.substring(0,n)]=e.substring(n+1))}return t}var X509Certificate,fa=__esmMin(()=>{ra(),da(),ha(),J(),X509Certificate=class{_components;_pem;constructor(e){if(typeof e==`string`)this._pem=e,this._components=parseX509(e);else{let t=q.isBuffer(e)?e:q.from(e),n=t.toString(`utf8`);n.includes(`-----BEGIN CERTIFICATE-----`)?(this._pem=n,this._components=parseX509(n)):(this._components=parseX509Der(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),this._pem=derToPem(this._components.raw,`CERTIFICATE`))}}get raw(){return q.from(this._components.raw)}get serialNumber(){return this._components.serialNumber.toString(16).toUpperCase()}get subject(){return this._components.subject}get issuer(){return this._components.issuer}get validFrom(){return this._components.validFrom.toUTCString()}get validTo(){return this._components.validTo.toUTCString()}get fingerprint(){return formatFingerprint(createHash(`sha1`).update(this._components.raw).digest())}get fingerprint256(){return formatFingerprint(createHash(`sha256`).update(this._components.raw).digest())}get fingerprint512(){return formatFingerprint(createHash(`sha512`).update(this._components.raw).digest())}get publicKey(){if(!this._components.publicKey)throw Error(`Certificate does not contain a supported public key type`);let e=derToPem(encodeSubjectPublicKeyInfo(this._components.publicKey),`PUBLIC KEY`);return new ua(`public`,{parsed:{type:`rsa-public`,components:this._components.publicKey},pem:e})}get subjectAltName(){if(!(!this._components.subjectAltName||this._components.subjectAltName.length===0))return this._components.subjectAltName.join(`, `)}get keyUsage(){}get infoAccess(){}get ca(){return!1}checkHost(e){let t=this._components.subject.match(/CN=([^,]+)/);if(t){let n=t[1].trim();if(matchHostname(n,e))return n}if(this._components.subjectAltName){for(let t of this._components.subjectAltName)if(t.startsWith(`DNS:`)){let n=t.substring(4);if(matchHostname(n,e))return n}}}checkEmail(e){let t=e.toLowerCase(),n=this._components.subject.match(/emailAddress=([^,]+)/);if(n&&n[1].toLowerCase()===t)return n[1]}checkIP(e){if(this._components.subjectAltName){for(let t of this._components.subjectAltName)if(t.startsWith(`IP Address:`)&&t.substring(11)===e)return e}}verify(e){return!0}checkIssued(e){return this.issuer===e.subject}toLegacyObject(){return{subject:parseDNToObject(this._components.subject),issuer:parseDNToObject(this._components.issuer),valid_from:this.validFrom,valid_to:this.validTo,serialNumber:this.serialNumber,fingerprint:this.fingerprint,fingerprint256:this.fingerprint256}}toString(){return this._pem}toJSON(){return this._pem}get[Symbol.toStringTag](){return`X509Certificate`}}}),pa=__exportAll$4({DiffieHellman:()=>DiffieHellman,DiffieHellmanGroup:()=>Ii,Hash:()=>Ki,Hmac:()=>Hmac,KeyObject:()=>ua,Sign:()=>Sign,Verify:()=>Verify,X509Certificate:()=>X509Certificate,constants:()=>Ei,createCipher:()=>createCipher,createCipheriv:()=>createCipheriv,createDecipher:()=>createDecipher,createDecipheriv:()=>createDecipheriv,createDiffieHellman:()=>createDiffieHellman,createDiffieHellmanGroup:()=>Fi,createECDH:()=>createECDH,createHash:()=>createHash,createHmac:()=>createHmac,createPrivateKey:()=>createPrivateKey,createPublicKey:()=>createPublicKey,createSecretKey:()=>createSecretKey,createSign:()=>createSign,createVerify:()=>createVerify,default:()=>ma,ecdsaSign:()=>ecdsaSign,ecdsaVerify:()=>ecdsaVerify,getCiphers:()=>getCiphers,getCurves:()=>getCurves,getDiffieHellman:()=>getDiffieHellman,getHashes:()=>getHashes,hash:()=>hash,hkdf:()=>hkdf,hkdfSync:()=>hkdfSync,mgf1:()=>mgf1,pbkdf2:()=>pbkdf2,pbkdf2Sync:()=>pbkdf2Sync,privateDecrypt:()=>privateDecrypt,privateEncrypt:()=>privateEncrypt,publicDecrypt:()=>publicDecrypt,publicEncrypt:()=>publicEncrypt,randomBytes:()=>randomBytes,randomFill:()=>randomFill,randomFillSync:()=>randomFillSync,randomInt:()=>randomInt,randomUUID:()=>randomUUID,rsaOaepDecrypt:()=>rsaOaepDecrypt,rsaOaepEncrypt:()=>rsaOaepEncrypt,rsaPssSign:()=>rsaPssSign,rsaPssVerify:()=>rsaPssVerify,scrypt:()=>scrypt,scryptSync:()=>scryptSync,timingSafeEqual:()=>timingSafeEqual});function createHash(e){return new Ki(e)}function createHmac(e,t){return new Hmac(e,t)}var ma,ha=__esmMin(()=>{Ti(),Di(),ki(),Li(),Bi(),qi(),Ji(),Yi(),Xi(),Zi(),Qi(),$i(),aa(),oa(),sa(),ca(),la(),da(),fa(),ma={Hash:Ki,getHashes,hash,Hmac,randomBytes,randomFill,randomFillSync,randomUUID,randomInt,timingSafeEqual,constants:Ei,pbkdf2,pbkdf2Sync,hkdf,hkdfSync,scrypt,scryptSync,createHash,createHmac,createCipher,createCipheriv,createDecipher,createDecipheriv,getCiphers,Sign,Verify,createSign,createVerify,createDiffieHellman,getDiffieHellman,DiffieHellman,DiffieHellmanGroup:Ii,createDiffieHellmanGroup:Fi,createECDH,getCurves,ecdsaSign,ecdsaVerify,publicEncrypt,privateDecrypt,privateEncrypt,publicDecrypt,rsaPssSign,rsaPssVerify,rsaOaepEncrypt,rsaOaepDecrypt,mgf1,KeyObject:ua,createSecretKey,createPublicKey,createPrivateKey,X509Certificate}});let ga=!1,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma;async function loadCrypto(){if(ga)return;let e=await Promise.resolve().then(()=>(ha(),pa));_a=e.createHash,va=e.createHmac,ya=e.createCipheriv,ba=e.createDecipheriv,xa=e.createSign,Sa=e.createVerify,Ca=e.pbkdf2Sync,wa=e.hkdfSync,Ta=e.createECDH,Ea=e.randomBytes,e.publicEncrypt,e.privateDecrypt,e.createPublicKey,e.createPrivateKey,Da=e.ecdsaSign,Oa=e.ecdsaVerify,ka=e.rsaPssSign,Aa=e.rsaPssVerify,ja=e.rsaOaepEncrypt,Ma=e.rsaOaepDecrypt,ga=!0}const Na=loadCrypto();var SubtleCrypto=class{async digest(e,t){await Na;let n=toNodeHashName(normalizeAlgorithm$1(e).name),r=toUint8Array(t),i=_a(n);i.update(r);let a=i.digest();return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}async generateKey(e,t,n){await Na;let r=normalizeAlgorithm$1(e);switch(r.name.toUpperCase()){case`AES-CBC`:case`AES-CTR`:case`AES-GCM`:{let i=e.length;if(![128,192,256].includes(i))throw new DOMException(`Invalid AES key length: ${i}`,`OperationError`);validateUsages(n,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]);let a=Ea(i/8);return new CryptoKey(`secret`,t,{name:r.name,length:i},n,new Uint8Array(a))}case`HMAC`:{let r=e,i=normalizeAlgorithm$1(r.hash),a=r.length||hashSize$1(i.name)*8;validateUsages(n,[`sign`,`verify`]);let o=Ea(Math.ceil(a/8));return new CryptoKey(`secret`,t,{name:`HMAC`,hash:{name:i.name},length:a},n,new Uint8Array(o))}case`ECDH`:{let r=e.namedCurve,i=toNodeCurveName(r);validateUsages(n,[`deriveKey`,`deriveBits`]);let a=Ta(i);a.generateKeys();let o=new Uint8Array(a.getPublicKey()),s=new Uint8Array(a.getPrivateKey());return{publicKey:new CryptoKey(`public`,!0,{name:`ECDH`,namedCurve:r},[],o),privateKey:new CryptoKey(`private`,t,{name:`ECDH`,namedCurve:r},n,{pub:o,priv:s})}}case`ECDSA`:{let r=e.namedCurve,i=toNodeCurveName(r);validateUsages(n,[`sign`,`verify`]);let a=Ta(i);a.generateKeys();let o=new Uint8Array(a.getPublicKey()),s=new Uint8Array(a.getPrivateKey());return{publicKey:new CryptoKey(`public`,!0,{name:`ECDSA`,namedCurve:r},[`verify`],o),privateKey:new CryptoKey(`private`,t,{name:`ECDSA`,namedCurve:r},[`sign`],{pub:o,priv:s})}}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async importKey(e,t,n,r,i){await Na;let a=normalizeAlgorithm$1(n),o=a.name.toUpperCase();switch(o){case`AES-CBC`:case`AES-CTR`:case`AES-GCM`:if(e===`raw`){let e=toUint8Array(t);if(![16,24,32].includes(e.length))throw new DOMException(`Invalid AES key length: ${e.length*8}`,`DataError`);return validateUsages(i,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:a.name,length:e.length*8},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);let n=base64urlDecode(e.k);if(![16,24,32].includes(n.length))throw new DOMException(`Invalid AES key length: ${n.length*8}`,`DataError`);return validateUsages(i,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:a.name,length:n.length*8},i,n)}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`HMAC`:{let a=normalizeAlgorithm$1(n.hash);if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`sign`,`verify`]),new CryptoKey(`secret`,r,{name:`HMAC`,hash:{name:a.name},length:e.length*8},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);let n=base64urlDecode(e.k);return validateUsages(i,[`sign`,`verify`]),new CryptoKey(`secret`,r,{name:`HMAC`,hash:{name:a.name},length:n.length*8},i,n)}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`)}case`PBKDF2`:if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`deriveKey`,`deriveBits`]),new CryptoKey(`secret`,!1,{name:`PBKDF2`},i,new Uint8Array(e))}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`HKDF`:if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`deriveKey`,`deriveBits`]),new CryptoKey(`secret`,!1,{name:`HKDF`},i,new Uint8Array(e))}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`ECDH`:case`ECDSA`:{let s=n.namedCurve;if(e===`raw`){let e=toUint8Array(t);return o===`ECDH`?i.length>0&&validateUsages(i,[`deriveKey`,`deriveBits`]):validateUsages(i,[`verify`]),new CryptoKey(`public`,r,{name:a.name,namedCurve:s},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`EC`)throw new DOMException(`JWK kty must be "EC"`,`DataError`);if(e.d){let t=base64urlDecode(e.d),n=base64urlDecode(e.x),c=base64urlDecode(e.y),l=new Uint8Array(1+n.length+c.length);return l[0]=4,l.set(n,1),l.set(c,1+n.length),validateUsages(i,o===`ECDH`?[`deriveKey`,`deriveBits`]:[`sign`]),new CryptoKey(`private`,r,{name:a.name,namedCurve:s},i,{pub:l,priv:t})}else{let t=base64urlDecode(e.x),n=base64urlDecode(e.y),c=new Uint8Array(1+t.length+n.length);return c[0]=4,c.set(t,1),c.set(n,1+t.length),o===`ECDH`?i.length>0&&validateUsages(i,[`deriveKey`,`deriveBits`]):validateUsages(i,[`verify`]),new CryptoKey(`public`,r,{name:a.name,namedCurve:s},i,c)}}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`)}default:throw new DOMException(`Unsupported algorithm: ${a.name}`,`NotSupportedError`)}}async exportKey(e,t){if(!t.extractable)throw new DOMException(`Key is not extractable`,`InvalidAccessError`);let n=t.algorithm.name.toUpperCase();if(e===`raw`){if(t.type===`secret`){let e=t._handle;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(t.type===`public`&&(n===`ECDH`||n===`ECDSA`)){let e=t._handle;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}throw new DOMException(`Cannot export in raw format`,`InvalidAccessError`)}if(e===`jwk`){if(t.type===`secret`){let e=t._handle,r={kty:`oct`,k:base64urlEncode(e),ext:t.extractable,key_ops:[...t.usages]};return n.startsWith(`AES-`)?r.alg=`A${t.algorithm.length}${n.replace(`AES-`,``)}`:n===`HMAC`&&(r.alg=`HS${t.algorithm.hash.name.replace(`SHA-`,``)}`),r}if((n===`ECDH`||n===`ECDSA`)&&(t.type===`public`||t.type===`private`)){let e=t.algorithm.namedCurve,n;n=t.type===`public`?t._handle:t._handle.pub;let r=(n.length-1)/2,i=n.slice(1,1+r),a=n.slice(1+r),o={kty:`EC`,crv:e,x:base64urlEncode(i),y:base64urlEncode(a),ext:t.extractable,key_ops:[...t.usages]};return t.type===`private`&&(o.d=base64urlEncode(t._handle.priv)),o}throw new DOMException(`JWK export not supported for ${n} ${t.type}`,`NotSupportedError`)}throw new DOMException(`Unsupported export format: ${e}`,`NotSupportedError`)}async encrypt(e,t,n){await Na,checkUsage(t,`encrypt`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`AES-CBC`:{let n=toUint8Array(e.iv),r=t._handle,i=r.length*8,o=ya(`aes-${i}-cbc`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-CTR`:{let n=toUint8Array(e.counter),r=t._handle,i=r.length*8,o=ya(`aes-${i}-ctr`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-GCM`:{let n=e,r=toUint8Array(n.iv),i=n.additionalData?toUint8Array(n.additionalData):void 0,o=t._handle,s=o.length*8,c=ya(`aes-${s}-gcm`,o,r);i&&c.setAAD(i);let l=c.update(a),u=c.final(),d=c.getAuthTag(),p=new Uint8Array(l.length+u.length+d.length);return p.set(new Uint8Array(l),0),p.set(new Uint8Array(u),l.length),p.set(new Uint8Array(d),l.length+u.length),p.buffer}case`RSA-OAEP`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e,s=o.label?toUint8Array(o.label):void 0,c=ja(r,i.pem,a,s);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async decrypt(e,t,n){await Na,checkUsage(t,`decrypt`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`AES-CBC`:{let n=toUint8Array(e.iv),r=t._handle,i=r.length*8,o=ba(`aes-${i}-cbc`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-CTR`:{let n=toUint8Array(e.counter),r=t._handle,i=r.length*8,o=ba(`aes-${i}-ctr`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-GCM`:{let n=e,r=toUint8Array(n.iv),i=(n.tagLength||128)/8,o=n.additionalData?toUint8Array(n.additionalData):void 0,s=t._handle,c=s.length*8,l=a.slice(0,a.length-i),u=a.slice(a.length-i),d=ba(`aes-${c}-gcm`,s,r);d.setAuthTag(u),o&&d.setAAD(o);let p=d.update(l),m=d.final(),h=new Uint8Array(p.length+m.length);return h.set(new Uint8Array(p),0),h.set(new Uint8Array(m),p.length),h.buffer}case`RSA-OAEP`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e,s=o.label?toUint8Array(o.label):void 0,c=Ma(r,i.pem,a,s);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async sign(e,t,n){await Na,checkUsage(t,`sign`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`HMAC`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=va(n,r);i.update(a);let o=i.digest();return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}case`RSASSA-PKCS1-V1_5`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=xa(n);i.update(a);let o=i.sign(r.pem);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}case`ECDSA`:{let n=e,r=toNodeHashName(typeof n.hash==`string`?n.hash:n.hash.name),i=t.algorithm.namedCurve,o=t._handle,s=Da(r,o.priv,a,i);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}case`RSA-PSS`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e.saltLength??hashSize$1(n),s=ka(r,i.pem,a,o);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async verify(e,t,n,r){await Na,checkUsage(t,`verify`);let i=normalizeAlgorithm$1(e),a=i.name.toUpperCase(),o=toUint8Array(r),s=toUint8Array(n);switch(a){case`HMAC`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=va(n,r);i.update(o);let a=new Uint8Array(i.digest());if(a.length!==s.length)return!1;let c=0;for(let e=0;e<a.length;e++)c|=a[e]^s[e];return c===0}case`RSASSA-PKCS1-V1_5`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=Sa(n);return i.update(o),i.verify(r.pem,s)}case`ECDSA`:{let n=e,r=toNodeHashName(typeof n.hash==`string`?n.hash:n.hash.name),i=t.algorithm.namedCurve,a=t._handle;return Oa(r,a,s,o,i)}case`RSA-PSS`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,a=e.saltLength??hashSize$1(n);return Aa(r,i.pem,s,o,a)}default:throw new DOMException(`Unsupported algorithm: ${i.name}`,`NotSupportedError`)}}async _deriveBitsInternal(e,t,n){await Na;let r=normalizeAlgorithm$1(e);switch(r.name.toUpperCase()){case`PBKDF2`:{let r=e,i=toNodeHashName(normalizeAlgorithm$1(r.hash).name),a=toUint8Array(r.salt),o=r.iterations,s=t._handle,c=Ca(s,a,o,n/8,i);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}case`HKDF`:{let r=e,i=toNodeHashName(normalizeAlgorithm$1(r.hash).name),a=toUint8Array(r.salt),o=toUint8Array(r.info),s=t._handle;return wa(i,s,a,o,n/8)}case`ECDH`:{let r=e.public,i=t.algorithm.namedCurve,a=toNodeCurveName(i),o=Ta(a),s=t._handle;o.setPrivateKey(s.priv);let c=r._handle instanceof Uint8Array?r._handle:r._handle.pub,l=o.computeSecret(c),u=new Uint8Array(l);return n?u.buffer.slice(0,n/8):u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async deriveBits(e,t,n){return checkUsage(t,`deriveBits`),this._deriveBitsInternal(e,t,n)}async deriveKey(e,t,n,r,i){checkUsage(t,`deriveKey`);let a=normalizeAlgorithm$1(n),o,s=a.name.toUpperCase();if(s===`AES-CBC`||s===`AES-CTR`||s===`AES-GCM`)o=n.length;else if(s===`HMAC`){let e=n,t=normalizeAlgorithm$1(e.hash);o=e.length||hashSize$1(t.name)*8}else throw new DOMException(`Unsupported derived key algorithm: ${a.name}`,`NotSupportedError`);let c=await this._deriveBitsInternal(e,t,o);return this.importKey(`raw`,c,n,r,i)}async wrapKey(e,t,n,r){throw new DOMException(`wrapKey not yet implemented`,`NotSupportedError`)}async unwrapKey(e,t,n,r,i,a,o){throw new DOMException(`unwrapKey not yet implemented`,`NotSupportedError`)}};const Pa=globalThis.crypto===void 0?null:globalThis.crypto;var CryptoPolyfill=class{subtle=new SubtleCrypto;getRandomValues(e){if(!(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigInt64Array||e instanceof BigUint64Array))throw new DOMException(`The provided value is not of type '(Int8Array or Int16Array or Int32Array or Uint8Array or Uint8ClampedArray or Uint16Array or Uint32Array or BigInt64Array or BigUint64Array)'`,`TypeMismatchError`);if(e.byteLength>65536)throw new DOMException(`The ArrayBufferView's byte length exceeds the number of bytes of entropy available via this API (65536)`,`QuotaExceededError`);let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Pa&&typeof Pa.getRandomValues==`function`)Pa.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return e}randomUUID(){if(Pa&&typeof Pa.randomUUID==`function`)return Pa.randomUUID();let e=new Uint8Array(16);this.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}};const Fa=Pa!==null&&Pa.subtle!==void 0&&typeof Pa.subtle.digest==`function`,Ia=Fa?Pa:new CryptoPolyfill;Fa?Pa.subtle:new SubtleCrypto;const La=globalThis;(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)&&(La.crypto=Ia);const Ra=typeof process<`u`&&typeof process.versions?.gjs==`string`,za=typeof process<`u`&&typeof process.versions?.node==`string`,Ba=Ra?`GJS`:za?`Node.js`:`Unknown`;Ra?process.versions.gjs:za&&process.versions.node;var Va,Ha,Ua=__esmMin(()=>{Va=Object.defineProperty,Ha=__name((e,t)=>{let n={};for(var r in e)Va(n,r,{get:e[r],enumerable:!0});return t||Va(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function assertPath(e){if(typeof e!=`string`)throw TypeError(`The "path" argument must be of type string. Received type `+typeof e)}function isPosixPathSeparator(e){return e===47}function isPathSeparator(e){return e===47||e===92}function isWindowsDeviceRoot(e){return e>=65&&e<=90||e>=97&&e<=122}function normalizeString(e,t,n,r){let i=``,a=0,o=-1,s=0,c;for(let l=0;l<=e.length;++l){if(l<e.length)c=e.charCodeAt(l);else if(r(c))break;else c=47;if(r(c)){if(!(o===l-1||s===1))if(o!==l-1&&s===2){if(i.length<2||a!==2||i.charCodeAt(i.length-1)!==46||i.charCodeAt(i.length-2)!==46){if(i.length>2){let e=i.lastIndexOf(n);e===-1?(i=``,a=0):(i=i.slice(0,e),a=i.length-1-i.lastIndexOf(n)),o=l,s=0;continue}else if(i.length===2||i.length===1){i=``,a=0,o=l,s=0;continue}}t&&(i.length>0?i+=`${n}..`:i=`..`,a=2)}else i.length>0?i+=n+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else c===46&&s!==-1?++s:s=-1}return i}function _format(e,t){if(typeof t!=`object`||!t)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof t);let n=t,r=n.dir||n.root,i=n.base||(n.name||``)+formatExt(n.ext);return r?r===n.root?r+i:r+e+i:i}function formatExt(e){return e?`${e[0]===`.`?``:`.`}${e}`:``}var Wa=__esmMin(()=>{});function posixCwd(){if(typeof globalThis.process?.cwd==`function`)return globalThis.process.cwd();try{let e=globalThis.imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function resolve$1(...e){let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i;if(r>=0){if(i=e[r],assertPath(i),i.length===0)continue}else i=posixCwd();t=`${i}/${t}`,n=i.charCodeAt(0)===47}return t=normalizeString(t,!n,`/`,isPosixPathSeparator),n?t.length>0?`/${t}`:`/`:t.length>0?t:`.`}function normalize$1(e){if(assertPath(e),e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=normalizeString(e,!t,`/`,isPosixPathSeparator);return r.length===0&&!t&&(r=`.`),r.length>0&&n&&(r+=`/`),t?`/${r}`:r}function isAbsolute$1(e){return assertPath(e),e.length>0&&e.charCodeAt(0)===47}function join$1(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];assertPath(r),r.length>0&&(t===void 0?t=r:t+=`/${r}`)}return t===void 0?`.`:normalize$1(t)}function relative$1(e,t){if(assertPath(e),assertPath(t),e===t||(e=resolve$1(e),t=resolve$1(t),e===t))return``;let n=e.length,r=n-1,i=1,a=t.length-i,o=r<a?r:a,s=-1,c=0;for(;c<=o;++c){if(c===o){if(a>o){if(t.charCodeAt(i+c)===47)return t.slice(i+c+1);if(c===0)return t.slice(i+c)}else r>o&&(e.charCodeAt(1+c)===47?s=c:c===0&&(s=0));break}let n=e.charCodeAt(1+c);if(n!==t.charCodeAt(i+c))break;n===47&&(s=c)}let l=``;for(c=1+s+1;c<=n;++c)(c===n||e.charCodeAt(c)===47)&&(l.length===0?l+=`..`:l+=`/..`);return l.length>0?l+t.slice(i+s):(i+=s,t.charCodeAt(i)===47&&++i,t.slice(i))}function toNamespacedPath$1(e){return e}function dirname$1(e){if(assertPath(e),e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function basename$1(e,t){t!==void 0&&assertPath(t),assertPath(e);let n=0,r=-1,i=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}else{for(let t=e.length-1;t>=0;--t)if(e.charCodeAt(t)===47){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}}function extname$1(e){assertPath(e);let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function format$2(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return _format(`/`,e)}function parse$2(e){assertPath(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0)===47,r;n?(t.root=`/`,r=1):r=0;let i=-1,a=0,o=-1,s=!0,c=e.length-1,l=0;for(;c>=r;--c){let t=e.charCodeAt(c);if(t===47){if(!s){a=c+1;break}continue}o===-1&&(s=!1,o=c+1),t===46?i===-1?i=c:l!==1&&(l=1):i!==-1&&(l=-1)}return i===-1||o===-1||l===0||l===1&&i===o-1&&i===a+1?o!==-1&&(a===0&&n?t.base=t.name=e.slice(1,o):t.base=t.name=e.slice(a,o)):(a===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,o)):(t.name=e.slice(a,i),t.base=e.slice(a,o)),t.ext=e.slice(i,o)),a>0?t.dir=e.slice(0,a-1):n&&(t.dir=`/`),t}var Ga,Ka=__esmMin(()=>{Ua(),Wa(),Ga=Ha({basename:()=>basename$1,delimiter:()=>`:`,dirname:()=>dirname$1,extname:()=>extname$1,format:()=>format$2,isAbsolute:()=>isAbsolute$1,join:()=>join$1,normalize:()=>normalize$1,parse:()=>parse$2,relative:()=>relative$1,resolve:()=>resolve$1,sep:()=>`/`,toNamespacedPath:()=>toNamespacedPath$1}),__name(resolve$1,`resolve`),__name(normalize$1,`normalize`),__name(isAbsolute$1,`isAbsolute`),__name(join$1,`join`),__name(relative$1,`relative`),__name(toNamespacedPath$1,`toNamespacedPath`),__name(dirname$1,`dirname`),__name(basename$1,`basename`),__name(extname$1,`extname`),__name(format$2,`format`),__name(parse$2,`parse`)});function resolve(...e){let t=``,n=``,r=!1;for(let i=e.length-1;i>=-1;i--){let a;if(i>=0){if(a=e[i],assertPath(a),a.length===0)continue}else a=(t.length,typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():`/`);let o=a.length,s=0,c=``,l=!1,u=a.charCodeAt(0);if(o>1)if(isPathSeparator(u))if(l=!0,isPathSeparator(a.charCodeAt(1))){let e=2,t=e;for(;e<o&&!isPathSeparator(a.charCodeAt(e));++e);if(e<o&&e!==t){let n=a.slice(t,e);for(t=e;e<o&&isPathSeparator(a.charCodeAt(e));++e);if(e<o&&e!==t){for(t=e;e<o&&!isPathSeparator(a.charCodeAt(e));++e);e===o?(c=`\\\\${n}\\${a.slice(t)}`,s=e):e!==t&&(c=`\\\\${n}\\${a.slice(t,e)}`,s=e)}}}else s=1;else isWindowsDeviceRoot(u)&&a.charCodeAt(1)===58&&(c=a.slice(0,2),s=2,o>2&&isPathSeparator(a.charCodeAt(2))&&(l=!0,s=3));else isPathSeparator(u)&&(s=1,l=!0);if(!(c.length>0&&t.length>0&&c.toLowerCase()!==t.toLowerCase())&&(t.length===0&&c.length>0&&(t=c),r||=(n=`${a.slice(s)}\\${n}`,l),t.length>0&&r))break}return n=normalizeString(n,!r,`\\`,isPathSeparator),t+(r?`\\`:``)+n||`.`}function normalize(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=0,r,i=!1,a=e.charCodeAt(0);if(t>1)if(isPathSeparator(a))if(i=!0,isPathSeparator(e.charCodeAt(1))){let i=2,a=i;for(;i<t&&!isPathSeparator(e.charCodeAt(i));++i);if(i<t&&i!==a){let o=e.slice(a,i);for(a=i;i<t&&isPathSeparator(e.charCodeAt(i));++i);if(i<t&&i!==a){for(a=i;i<t&&!isPathSeparator(e.charCodeAt(i));++i);if(i===t)return`\\\\${o}\\${e.slice(a)}\\`;i!==a&&(r=`\\\\${o}\\${e.slice(a,i)}`,n=i)}}}else n=1;else isWindowsDeviceRoot(a)&&e.charCodeAt(1)===58&&(r=e.slice(0,2),n=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(i=!0,n=3));else if(isPathSeparator(a))return`\\`;let o;return o=n<t?normalizeString(e.slice(n),!i,`\\`,isPathSeparator):``,o.length===0&&!i&&(o=`.`),o.length>0&&isPathSeparator(e.charCodeAt(t-1))&&(o+=`\\`),r===void 0?i?o.length>0?`\\${o}`:`\\`:o.length>0?o:``:i?o.length>0?`${r}\\${o}`:`${r}\\`:o.length>0?r+o:r}function isAbsolute(e){assertPath(e);let t=e.length;if(t===0)return!1;let n=e.charCodeAt(0);return!!(isPathSeparator(n)||isWindowsDeviceRoot(n)&&t>2&&e.charCodeAt(1)===58&&isPathSeparator(e.charCodeAt(2)))}function join(...e){if(e.length===0)return`.`;let t,n;for(let r=0;r<e.length;++r){let i=e[r];assertPath(i),i.length>0&&(t===void 0?t=n=i:t+=`\\${i}`)}if(t===void 0)return`.`;let r=!0,i=0;if(isPathSeparator(n.charCodeAt(0))){++i;let e=n.length;e>1&&isPathSeparator(n.charCodeAt(1))&&(++i,e>2&&(isPathSeparator(n.charCodeAt(2))?++i:r=!1))}if(r){for(;i<t.length&&isPathSeparator(t.charCodeAt(i));++i);i>=2&&(t=`\\${t.slice(i)}`)}return normalize(t)}function relative(e,t){if(assertPath(e),assertPath(t),e===t)return``;let n=resolve(e),r=resolve(t);if(n===r||(e=n.toLowerCase(),t=r.toLowerCase(),e===t))return``;let i=0;for(;i<e.length&&e.charCodeAt(i)===92;++i);let a=e.length;for(;a-1>i&&e.charCodeAt(a-1)===92;--a);let o=a-i,s=0;for(;s<t.length&&t.charCodeAt(s)===92;++s);let c=t.length;for(;c-1>s&&t.charCodeAt(c-1)===92;--c);let l=c-s,u=o<l?o:l,d=-1,p=0;for(;p<=u;++p){if(p===u){if(l>u){if(t.charCodeAt(s+p)===92)return r.slice(s+p+1);if(p===2)return r.slice(s+p)}o>u&&(e.charCodeAt(i+p)===92?d=p:p===2&&(d=3));break}let n=e.charCodeAt(i+p);if(n!==t.charCodeAt(s+p))break;n===92&&(d=p)}if(p!==u&&d===-1)return r;let m=``;for(d===-1&&(d=0),p=i+d+1;p<=a;++p)(p===a||e.charCodeAt(p)===92)&&(m.length===0?m+=`..`:m+=`\\..`);return m.length>0?m+r.slice(s+d,c):(s+=d,r.charCodeAt(s)===92&&++s,r.slice(s,c))}function toNamespacedPath(e){if(typeof e!=`string`)return e;if(e.length===0)return``;let t=resolve(e);if(t.length>=3){if(t.charCodeAt(0)===92){if(t.charCodeAt(1)===92){let e=t.charCodeAt(2);if(e!==63&&e!==46)return`\\\\?\\UNC\\${t.slice(2)}`}}else if(isWindowsDeviceRoot(t.charCodeAt(0))&&t.charCodeAt(1)===58&&t.charCodeAt(2)===92)return`\\\\?\\${t}`}return e}function dirname(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=-1,r=-1,i=!0,a=0,o=e.charCodeAt(0);if(t>1)if(isPathSeparator(o)){if(n=a=1,isPathSeparator(e.charCodeAt(1))){let r=2,i=r;for(;r<t&&!isPathSeparator(e.charCodeAt(r));++r);if(r<t&&r!==i){for(i=r;r<t&&isPathSeparator(e.charCodeAt(r));++r);if(r<t&&r!==i){for(i=r;r<t&&!isPathSeparator(e.charCodeAt(r));++r);if(r===t)return e;r!==i&&(n=a=r+1)}}}}else isWindowsDeviceRoot(o)&&e.charCodeAt(1)===58&&(n=a=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(n=a=3));else if(isPathSeparator(o))return e;for(let n=t-1;n>=a;--n)if(isPathSeparator(e.charCodeAt(n))){if(!i){r=n;break}}else i=!1;if(r===-1){if(n===-1)return`.`;r=n}return e.slice(0,r)}function basename(e,t){t!==void 0&&assertPath(t),assertPath(e);let n=0,r=-1,i=!0;if(e.length>=2&&isWindowsDeviceRoot(e.charCodeAt(0))&&e.charCodeAt(1)===58&&(n=2),t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=n;--s){let c=e.charCodeAt(s);if(isPathSeparator(c)){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}else{for(let t=e.length-1;t>=n;--t)if(isPathSeparator(e.charCodeAt(t))){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}}function extname(e){assertPath(e);let t=0,n=-1,r=0,i=-1,a=!0,o=0;e.length>=2&&e.charCodeAt(1)===58&&isWindowsDeviceRoot(e.charCodeAt(0))&&(t=r=2);for(let s=e.length-1;s>=t;--s){let t=e.charCodeAt(s);if(isPathSeparator(t)){if(!a){r=s+1;break}continue}i===-1&&(a=!1,i=s+1),t===46?n===-1?n=s:o!==1&&(o=1):n!==-1&&(o=-1)}return n===-1||i===-1||o===0||o===1&&n===i-1&&n===r+1?``:e.slice(n,i)}function format$1(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return _format(`\\`,e)}function parse$1(e){assertPath(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.length,r=0,i=e.charCodeAt(0);if(n>1)if(isPathSeparator(i)){if(r=1,isPathSeparator(e.charCodeAt(1))){let t=2,i=t;for(;t<n&&!isPathSeparator(e.charCodeAt(t));++t);if(t<n&&t!==i){for(i=t;t<n&&isPathSeparator(e.charCodeAt(t));++t);if(t<n&&t!==i){for(i=t;t<n&&!isPathSeparator(e.charCodeAt(t));++t);t===n?r=t:t!==i&&(r=t+1)}}}}else isWindowsDeviceRoot(i)&&e.charCodeAt(1)===58&&(r=2,n>2&&isPathSeparator(e.charCodeAt(2))&&(r=3));else if(isPathSeparator(i))return t.root=t.dir=e,t;r>0&&(t.root=e.slice(0,r));let a=-1,o=r,s=-1,c=!0,l=e.length-1,u=0;for(;l>=r;--l){if(i=e.charCodeAt(l),isPathSeparator(i)){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),i===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(t.base=t.name=e.slice(o,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s),t.ext=e.slice(a,s)),o>0&&o!==r?t.dir=e.slice(0,o-1):t.dir=t.root,t}var qa,Ja=__esmMin(()=>{Ua(),Wa(),qa=Ha({basename:()=>basename,delimiter:()=>`;`,dirname:()=>dirname,extname:()=>extname,format:()=>format$1,isAbsolute:()=>isAbsolute,join:()=>join,normalize:()=>normalize,parse:()=>parse$1,relative:()=>relative,resolve:()=>resolve,sep:()=>`\\`,toNamespacedPath:()=>toNamespacedPath}),__name(format$1,`format`),__name(parse$1,`parse`)}),Ya=__exportAll$4({basename:()=>ro,default:()=>lo,delimiter:()=>co,dirname:()=>no,extname:()=>io,format:()=>ao,isAbsolute:()=>Qa,join:()=>$a,normalize:()=>Za,parse:()=>oo,posix:()=>Ga,relative:()=>eo,resolve:()=>Xa,sep:()=>so,toNamespacedPath:()=>to,win32:()=>qa}),Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo=__esmMin(()=>{Ka(),Ja(),{resolve:Xa,normalize:Za,isAbsolute:Qa,join:$a,relative:eo,toNamespacedPath:to,dirname:no,basename:ro,extname:io,format:ao,parse:oo,sep:so,delimiter:co}=Ga,lo={resolve:resolve$1,normalize:normalize$1,isAbsolute:isAbsolute$1,join:join$1,relative:relative$1,toNamespacedPath:toNamespacedPath$1,dirname:dirname$1,basename:basename$1,extname:extname$1,format:format$2,parse:parse$2,sep:`/`,delimiter:`:`,posix:Ga,win32:qa}}),fo=__commonJSMin(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return parse(e);if(n===`number`&&isFinite(e))return t.long?fmtLong(e):fmtShort(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function parse(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function fmtShort(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function fmtLong(e){var t=Math.abs(e);return t>=a?plural(e,t,a,`day`):t>=i?plural(e,t,i,`hour`):t>=r?plural(e,t,r,`minute`):t>=n?plural(e,t,n,`second`):e+` ms`}function plural(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),po=__commonJSMin(((e,t)=>{I();function setup(e){createDebug.debug=createDebug,createDebug.default=createDebug,createDebug.coerce=coerce,createDebug.disable=disable,createDebug.enable=enable,createDebug.enabled=enabled,createDebug.humanize=fo(),createDebug.destroy=destroy,Object.keys(e).forEach(t=>{createDebug[t]=e[t]}),createDebug.names=[],createDebug.skips=[],createDebug.formatters={};function selectColor(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return createDebug.colors[Math.abs(t)%createDebug.colors.length]}createDebug.selectColor=selectColor;function createDebug(e){let t,n=null,r,i;function debug(...e){if(!debug.enabled)return;let n=debug,r=Number(new Date);n.diff=r-(t||r),n.prev=t,n.curr=r,t=r,e[0]=createDebug.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if(t===`%%`)return`%`;i++;let a=createDebug.formatters[r];if(typeof a==`function`){let r=e[i];t=a.call(n,r),e.splice(i,1),i--}return t}),createDebug.formatArgs.call(n,e),(n.log||createDebug.log).apply(n,e)}return debug.namespace=e,debug.useColors=createDebug.useColors(),debug.color=createDebug.selectColor(e),debug.extend=extend,debug.destroy=createDebug.destroy,Object.defineProperty(debug,"enabled",{enumerable:!0,configurable:!1,get:()=>n===null?(r!==createDebug.namespaces&&(r=createDebug.namespaces,i=createDebug.enabled(e)),i):n,set:e=>{n=e}}),typeof createDebug.init==`function`&&createDebug.init(debug),debug}function extend(e,t){let n=createDebug(this.namespace+(t===void 0?`:`:t)+e);return n.log=this.log,n}function enable(e){createDebug.save(e),createDebug.namespaces=e,createDebug.names=[],createDebug.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?createDebug.skips.push(e.slice(1)):createDebug.names.push(e)}function matchesTemplate(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function disable(){let e=[...createDebug.names,...createDebug.skips.map(e=>`-`+e)].join(`,`);return createDebug.enable(``),e}function enabled(e){for(let t of createDebug.skips)if(matchesTemplate(e,t))return!1;for(let t of createDebug.names)if(matchesTemplate(e,t))return!0;return!1}function coerce(e){return e instanceof Error?e.stack||e.message:e}function destroy(){F.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return createDebug.enable(createDebug.load()),createDebug}t.exports=setup})),mo=__commonJSMin(((e,t)=>{I(),e.formatArgs=formatArgs,e.save=save,e.load=load,e.useColors=useColors,e.storage=localstorage(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,F.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function useColors(){if(typeof globalThis<`u`&&globalThis.process&&(globalThis.process.type===`renderer`||globalThis.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof globalThis<`u`&&globalThis.console&&(globalThis.console.firebug||globalThis.console.exception&&globalThis.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=F.debug||F.log||(()=>{});function save(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function load(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function localstorage(){try{return localStorage}catch{}}t.exports=po()(e);let{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),ho=__commonJSMin(((e,t)=>{
7
7
  /*!
8
8
  * depd
9
9
  * Copyright(c) 2015 Douglas Christopher Wilson
@@ -188,8 +188,8 @@ var n=mo()(`finalhandler`),r=gl(),i=_l(),a=ss(),o=vl(),s=vo(),c=a.isFinished;fun
188
188
  `,`<br>`).replaceAll(` `,` &nbsp;`)+`</pre>
189
189
  </body>
190
190
  </html>
191
- `}t.exports=finalhandler;function finalhandler(e,t,i){var a=i||{},o=a.env||process.env.NODE_ENV||`development`,s=a.onerror;return function(i){var a,c,l;if(!i&&t.headersSent){n(`cannot 404 after headers sent`);return}if(i?(l=getErrorStatusCode(i),l===void 0?l=getResponseStatusCode(t):a=getErrorHeaders(i),c=getErrorMessage(i,l,o)):(l=404,c=`Cannot `+e.method+` `+r(getResourceName(e))),n(`default %s`,l),i&&s&&setImmediate(s,i,e,t),t.headersSent){n(`cannot %d after headers sent`,l),e.socket&&e.socket.destroy();return}send(e,t,l,a,c)}}function getErrorHeaders(e){if(!(!e.headers||typeof e.headers!=`object`))return{...e.headers}}function getErrorMessage(e,t,n){var r;return n!==`production`&&(r=e.stack,!r&&typeof e.toString==`function`&&(r=e.toString())),r||s.message[t]}function getErrorStatusCode(e){if(typeof e.status==`number`&&e.status>=400&&e.status<600)return e.status;if(typeof e.statusCode==`number`&&e.statusCode>=400&&e.statusCode<600)return e.statusCode}function getResourceName(e){try{return o.original(e).pathname}catch{return`resource`}}function getResponseStatusCode(e){var t=e.statusCode;return(typeof t!=`number`||t<400||t>599)&&(t=500),t}function send(e,t,n,r,i){function write(){var a=createHtmlDocument(i);t.statusCode=n,e.httpVersionMajor<2&&(t.statusMessage=s.message[n]),t.removeHeader(`Content-Encoding`),t.removeHeader(`Content-Language`),t.removeHeader(`Content-Range`);for(let[e,n]of Object.entries(r??{}))t.setHeader(e,n);if(t.setHeader(`Content-Security-Policy`,`default-src 'none'`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.setHeader(`Content-Type`,`text/html; charset=utf-8`),t.setHeader(`Content-Length`,Buffer.byteLength(a,`utf8`)),e.method===`HEAD`){t.end();return}t.end(a,`utf8`)}if(c(e)){write();return}e.unpipe(),a(e,write),e.resume()}})),bl,__exportAll,xl=__esmMin(()=>{bl=Object.defineProperty,__exportAll=(e,t)=>{let n={};for(var r in e)bl(n,r,{get:e[r],enumerable:!0});return t||bl(n,Symbol.toStringTag,{value:`Module`}),n}});function getEncodingFromOptions(e={encoding:null,flag:`r`},t=`utf8`){return e===null?t:typeof e==`string`?e:typeof e==`object`&&typeof e.encoding==`string`?e.encoding:t}function encodeUint8Array(e,t){return e===`buffer`?q.from(t):new TextDecoder(e).decode(t)}function decode(e,t){if(t){let n=new TextDecoder(t),r=new TextEncoder;return n.decode(r.encode(e))}else return e}var Sl=__esmMin(()=>{J()}),Dirent,Cl=__esmMin(()=>{N(),uo(),Dirent=class{name;parentPath;_isFile=!1;_isDirectory=!1;_isBlockDevice=!1;_isCharacterDevice=!1;_isSymbolicLink=!1;_isFIFO=!1;_isSocket=!1;_file;constructor(e,t,n){switch(t||=ro(e),this.name=t,this.parentPath=no(e),this._file=M.File.new_for_path(e),n??this._file.query_file_type(M.FileQueryInfoFlags.NONE,null)){case M.FileType.DIRECTORY:this._isDirectory=!0;break;case M.FileType.MOUNTABLE:break;case M.FileType.REGULAR:this._isFile=!0;break;case M.FileType.SYMBOLIC_LINK:case M.FileType.SHORTCUT:this._isSymbolicLink=!0;break;case M.FileType.SPECIAL:this._classifySpecialFile(e);break}}_classifySpecialFile(e){try{let t=M.File.new_for_path(e).query_info(`unix::mode`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_attribute_uint32(`unix::mode`);if(t===0)return;switch(t&61440){case 24576:this._isBlockDevice=!0;break;case 8192:this._isCharacterDevice=!0;break;case 49152:this._isSocket=!0;break;case 4096:this._isFIFO=!0;break}}catch{}}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isBlockDevice(){return this._isBlockDevice}isCharacterDevice(){return this._isCharacterDevice}isSymbolicLink(){return this._isSymbolicLink}isFIFO(){return this._isFIFO}isSocket(){return this._isSocket}}});function populateFromInfo(e){let t=e.get_attribute_uint64(`time::access`),n=e.get_attribute_uint32(`time::access-usec`)||0,r=e.get_attribute_uint64(`time::modified`),i=e.get_attribute_uint32(`time::modified-usec`)||0,a=e.get_attribute_uint64(`time::changed`),o=e.get_attribute_uint32(`time::changed-usec`)||0,s=e.get_attribute_uint64(`time::created`),c=e.get_attribute_uint32(`time::created-usec`)||0,l=t*1e3+n/1e3,u=r*1e3+i/1e3,d=a?a*1e3+o/1e3:u,p=s?s*1e3+c/1e3:d;return{dev:e.get_attribute_uint32(`unix::device`)||0,ino:Number(e.get_attribute_uint64(`unix::inode`)||0),mode:e.get_attribute_uint32(`unix::mode`)||0,nlink:e.get_attribute_uint32(`unix::nlink`)||0,uid:e.get_attribute_uint32(`unix::uid`)||0,gid:e.get_attribute_uint32(`unix::gid`)||0,rdev:e.get_attribute_uint32(`unix::rdev`)||0,size:Number(e.get_size()||0),blksize:e.get_attribute_uint32(`unix::block-size`)||4096,blocks:Number(e.get_attribute_uint64(`unix::blocks`)||0),atimeMs:l,mtimeMs:u,ctimeMs:d,birthtimeMs:p,atime:new Date(l),mtime:new Date(u),ctime:new Date(d),birthtime:new Date(p)}}var wl,Stats,BigIntStats,Tl=__esmMin(()=>{Cl(),N(),uo(),wl=`standard::*,time::*,unix::*`,Stats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof M.FileInfo?(r=e,i=t.toString(),n||=ro(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=ro(i),r=M.File.new_for_path(i).query_info(wl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type()),this._info=r;let a=populateFromInfo(r);this.dev=a.dev,this.ino=a.ino,this.mode=a.mode,this.nlink=a.nlink,this.uid=a.uid,this.gid=a.gid,this.rdev=a.rdev,this.size=a.size,this.blksize=a.blksize,this.blocks=a.blocks,this.atimeMs=a.atimeMs,this.mtimeMs=a.mtimeMs,this.ctimeMs=a.ctimeMs,this.birthtimeMs=a.birthtimeMs,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.birthtime=a.birthtime}},BigIntStats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atimeNs;mtimeNs;ctimeNs;birthtimeNs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof M.FileInfo?(r=e,i=t.toString(),n||=ro(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=ro(i),r=M.File.new_for_path(i).query_info(wl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type()),this._info=r;let a=populateFromInfo(r);this.dev=BigInt(a.dev),this.ino=BigInt(a.ino),this.mode=BigInt(a.mode),this.nlink=BigInt(a.nlink),this.uid=BigInt(a.uid),this.gid=BigInt(a.gid),this.rdev=BigInt(a.rdev),this.size=BigInt(a.size),this.blksize=BigInt(a.blksize),this.blocks=BigInt(a.blocks),this.atimeMs=BigInt(Math.trunc(a.atimeMs)),this.mtimeMs=BigInt(Math.trunc(a.mtimeMs)),this.ctimeMs=BigInt(Math.trunc(a.ctimeMs)),this.birthtimeMs=BigInt(Math.trunc(a.birthtimeMs)),this.atimeNs=this.atimeMs*1000000n,this.mtimeNs=this.mtimeMs*1000000n,this.ctimeNs=this.ctimeMs*1000000n,this.birthtimeNs=this.birthtimeMs*1000000n,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.birthtime=a.birthtime}}});function createReadStream(e,t){return new ReadStream(e,t)}var ReadStream,El=__esmMin(()=>{$l(),A(),N(),J(),Kr(),ReadStream=class extends Br{bytesRead=0;path;pending=!0;fd=null;_gioFile;_inputStream=null;_cancellable=new M.Cancellable;_start;_end;_pos;close(e){this._cancellable.cancel(),this._inputStream&&=(this._inputStream.close_async(k.PRIORITY_DEFAULT,null,()=>{}),null),this.destroy(),e&&e(null)}constructor(e,t){let n=normalizePath(e);super({highWaterMark:t?.highWaterMark??64*1024,encoding:t?.encoding,objectMode:!1}),this.path=n,this._gioFile=M.File.new_for_path(n),this._start=t?.start??0,this._end=t?.end??1/0,this._pos=this._start}_construct(e){this._gioFile.read_async(k.PRIORITY_DEFAULT,this._cancellable,(t,n)=>{if(this.destroyed){e();return}try{this._inputStream=this._gioFile.read_finish(n),this.pending=!1,this.emit(`open`,0),this.emit(`ready`),this._start>0&&this._inputStream.can_seek()&&this._inputStream.seek(this._start,k.SeekType.SET,null),e()}catch(t){this._cancellable.is_cancelled()||e(t)}})}_read(e){this._doRead(e)}_doRead(e){let t=e;if(this._end!==1/0){let n=this._end-this._pos+1;if(n<=0){this.push(null);return}t=Math.min(e,n)}let n=this._inputStream;n.read_bytes_async(t,k.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{try{let e=n.read_bytes_finish(t).get_data();if(!e||e.length===0){this.push(null);return}this.bytesRead+=e.length,this._pos+=e.length,this.push(q.from(e))}catch(e){this._cancellable.is_cancelled()||this.destroy(e)}})}_destroy(e,t){this._cancellable.cancel(),this._inputStream&&=(this._inputStream.close_async(k.PRIORITY_DEFAULT,null,()=>{}),null),t(e)}}});function createNodeError(e,t,n,r){return createNodeError$1(e,t,{path:n.toString(),dest:r?.toString()})}var Dl=__esmMin(()=>{L()});function makeEEXIST(e){let t=Error(`ERR_FS_CP_EEXIST: file already exists, copyfile '${e}'`);return t.code=`ERR_FS_CP_EEXIST`,t.syscall=`copyfile`,t.path=e,t}function makeEISDIR(e){let t=Error(`ERR_FS_EISDIR: illegal operation on a directory, copyfile '${e}'`);return t.code=`ERR_FS_EISDIR`,t.syscall=`copyfile`,t.path=e,t}function makeENOTDIR(e,t){let n=Error(`ENOTDIR: not a directory, copyfile '${e}' -> '${t}'`);return n.code=`ENOTDIR`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function makeSYMLINKLOOP(e,t){let n=Error(`ELOOP: too many levels of symbolic links, copyfile '${e}' -> '${t}'`);return n.code=`ELOOP`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function queryCopyFlags(e){let t=e.force??!0,n=M.FileCopyFlags.NONE;return t&&(n|=M.FileCopyFlags.OVERWRITE),e.preserveTimestamps&&(n|=M.FileCopyFlags.TARGET_DEFAULT_MODIFIED_TIME),e.dereference||(n|=M.FileCopyFlags.NOFOLLOW_SYMLINKS),n}function copyOneSyncFile(e,t,n,r,i){let a=i.force??!0;try{if(t.query_info(`standard::type`,M.FileQueryInfoFlags.NONE,null).get_file_type()===M.FileType.DIRECTORY)throw makeENOTDIR(n,r);if(!a){if(i.errorOnExist)throw makeEEXIST(r);return}}catch(e){if(typeof e.code==`string`)throw e}let o=queryCopyFlags(i);try{e.copy(t,o,null,null)}catch(e){throw createNodeError(e,`copyfile`,n,r)}}function cpOneDirSync(e,t,n,r,i){let a=n.endsWith(`/`)?``:`/`;if(r.startsWith(n+a)&&r!==n)throw makeSYMLINKLOOP(n,r);if(t.query_exists(null))try{if(t.query_info(`standard::type`,M.FileQueryInfoFlags.NONE,null).get_file_type()!==M.FileType.DIRECTORY)throw makeENOTDIR(r,n)}catch(e){if(typeof e.code==`string`)throw e}else try{t.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,r)}let o;try{o=e.enumerate_children(`standard::name,standard::type,standard::is-symlink`,i.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`scandir`,n)}let s=o.next_file(null);for(;s!==null;){let e=s.get_name(),t=$a(n,e),a=$a(r,e),c=i.filter;if(c&&!c(t,a)){s=o.next_file(null);continue}cpSyncInternal(t,a,i),s=o.next_file(null)}}function cpSyncInternal(e,t,n){let r=M.File.new_for_path(e),i=M.File.new_for_path(t),a;try{a=r.query_info(`standard::type,standard::is-symlink`,n.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`stat`,e)}if(a.get_file_type()===M.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(e);cpOneDirSync(r,i,e,t,n)}else copyOneSyncFile(r,i,e,t,n)}function cpSync(e,t,n){let r=normalizePath(e),i=normalizePath(t),a=n??{},o=M.File.new_for_path(r),s=a.filter;if(!(s&&!s(r,i))){try{if(o.query_info(`standard::type`,a.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_file_type()===M.FileType.DIRECTORY&&!a.recursive)throw makeEISDIR(r)}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`stat`,r)}cpSyncInternal(r,i,a)}}function cp(e,t,n,r){let i,a;typeof n==`function`?(a=n,i={}):(a=r,i=n);let o=i.filter;if(o){Promise.resolve(o(normalizePath(e),normalizePath(t))).then(n=>{if(!n){a(null);return}try{cpPromises(e,t,i).then(()=>a(null)).catch(a)}catch(e){a(e)}}).catch(a);return}Promise.resolve().then(()=>{try{cpSync(e,t,i),a(null)}catch(e){a(e)}})}async function cpPromisesDir(e,t,n){let r=e.endsWith(`/`)?``:`/`;if(t.startsWith(e+r)&&t!==e)throw makeSYMLINKLOOP(e,t);let i=M.File.new_for_path(t);if(!i.query_exists(null))try{i.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,t)}let a=M.File.new_for_path(e),o;try{o=a.enumerate_children(`standard::name,standard::type`,n.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`scandir`,e)}let s=o.next_file(null);for(;s!==null;){let r=s.get_name(),i=$a(e,r),a=$a(t,r),c=n.filter;if(c&&!await Promise.resolve(c(i,a))){s=o.next_file(null);continue}await cpPromises(i,a,n),s=o.next_file(null)}}async function cpPromises(e,t,n={}){let r=normalizePath(e),i=normalizePath(t),a=M.File.new_for_path(r),o;try{o=a.query_info(`standard::type`,n.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`stat`,r)}if(o.get_file_type()===M.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(r);await cpPromisesDir(r,i,n)}else copyOneSyncFile(a,M.File.new_for_path(i),r,i,n)}var Ol=__esmMin(()=>{$l(),Dl(),N(),uo()});function _openDir(e){let t=M.File.new_for_path(e),n;try{n=t.enumerate_children(kl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`opendir`,e)}return new Dir(e,n)}function opendirSync(e){return _openDir(normalizePath(e))}function opendir(e,t,n){let r;if(r=typeof t==`function`?t:n,typeof r!=`function`)throw TypeError(`The "callback" argument must be of type function`);Promise.resolve().then(()=>{try{let t=opendirSync(e);r(null,t)}catch(e){r(e,null)}})}async function opendirAsync(e,t){return new Promise((t,n)=>{let r=normalizePath(e),i=M.File.new_for_path(r);i.enumerate_children_async(kl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,k.PRIORITY_DEFAULT,null,(e,a)=>{try{t(new Dir(r,i.enumerate_children_finish(a)))}catch(e){n(createNodeError(e,`opendir`,r))}})})}var kl,Dir,Al=__esmMin(()=>{$l(),Cl(),Dl(),A(),N(),kl=`standard::name,standard::type,standard::is-symlink,standard::size,standard::symlink-target,unix::uid,unix::gid,unix::mode,time::modified,time::access,time::created`,Dir=class{path;_enumerator;_closed=!1;constructor(e,t){this.path=e,this._enumerator=t}_assertOpen(){if(this._closed){let e=Error(`Directory handle was closed`);throw e.code=`ERR_DIR_CLOSED`,e}}readSync(){this._assertOpen();try{let e=this._enumerator.next_file(null);if(e===null)return null;let t=e.get_name(),n=e.get_file_type();return new Dirent(this.path.endsWith(`/`)?this.path+t:this.path+`/`+t,t,n)}catch(e){throw createNodeError(e,`readdir`,this.path)}}read(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this._assertOpen();let t=this.readSync();Promise.resolve().then(()=>e(null,t))}catch(t){Promise.resolve().then(()=>e(t,null))}return}return new Promise((e,t)=>{try{this._assertOpen(),e(this.readSync())}catch(e){t(e)}})}closeSync(){this._assertOpen(),this._closed=!0;try{this._enumerator.close(null)}catch{}this._enumerator=null}close(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this.closeSync(),Promise.resolve().then(()=>e(null))}catch(t){Promise.resolve().then(()=>e(t))}return}return new Promise((e,t)=>{try{this.closeSync(),e()}catch(e){t(e)}})}async*[Symbol.asyncIterator](){try{for(;;){let e=await this.read();if(e===null)break;yield e}}finally{this._closed||await this.close()}}}});function segmentToRegexSrc(e){let t=/^([!*+?@])\((.+)\)$/.exec(e);if(t){let[,e,n]=t,r=n.split(`|`).map(e=>segmentToRegexSrc(e)),i=`(?:`+r.join(`|`)+`)`;switch(e){case`!`:return`(?!(?:`+r.join(`|`)+`))[^/]*`;case`*`:return i+`*`;case`+`:return i+`+`;case`?`:return i+`?`;case`@`:return i}}let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`*`){n+=`[^/]*`,r++;continue}if(t===`?`){n+=`[^/]`,r++;continue}if(t===`[`){let t=e.indexOf(`]`,r+1);if(t===-1){n+=`\\[`,r++;continue}n+=e.slice(r,t+1),r=t+1;continue}if(t===`{`){let t=e.indexOf(`}`,r+1);if(t===-1){n+=`\\{`,r++;continue}let i=e.slice(r+1,t).split(`,`).map(e=>segmentToRegexSrc(e.trim()));n+=`(?:`+i.join(`|`)+`)`,r=t+1;continue}`.+^$|()[]{}`.includes(t)?n+=`\\`+t:n+=t,r++}return n}function globToRegex(e){e=e.replace(/\/+/g,`/`).replace(/^\.\//,``);let t=e.split(`/`),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=e===t.length-1;r===`**`?i?n.length>0&&n[n.length-1]===`/`?(n.pop(),n.push(`(?:/.+)?`)):n.push(`(?:.+)?`):n.push(`(?:[^/]+/)*`):(n.push(segmentToRegexSrc(r)),i||n.push(`/`))}return RegExp(`^(?:`+n.join(``)+`)$`)}function buildExcludePredicate(e){if(!e)return null;if(typeof e==`function`)return e;let t=(Array.isArray(e)?e:[e]).map(e=>globToRegex(e));return e=>t.some(t=>t.test(e))}function matchAll(e,t,n){let r=globToRegex(e),i=buildExcludePredicate(n),a;try{a=readdirSync(t,{recursive:!0})}catch{return[]}let o=[`.`,...a],s=[];for(let e of o){let t=e.replace(/\\/g,`/`);r.test(t)&&(i&&i(t)||s.push(e))}return s}function globSync(e,t){let n=Array.isArray(e)?e:[e],r=t?.cwd?normalizePath(t.cwd):globalThis.process?.cwd?.()??`/`,i=t?.exclude,a=new Set,o=[];for(let e of n)for(let t of matchAll(e,r,i))a.has(t)||(a.add(t),o.push(t));return o}function glob(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(i=n,r=t||{}),Promise.resolve().then(()=>{try{let t=globSync(e,r);i(null,t)}catch(e){i(e,[])}})}async function*globAsync(e,t){let n=globSync(e,t);for(let e of n)yield e}var jl=__esmMin(()=>{$l(),Ql()});function buildStatFs(e){let t=Number(e.get_attribute_uint64(`filesystem::size`)??0),n=Number(e.get_attribute_uint64(`filesystem::free`)??0),r=Math.floor(t/Nl),i=Math.floor(n/Nl);return{type:0,bsize:Nl,blocks:r,bfree:i,bavail:i,files:0,ffree:0}}function buildBigIntStatFs(e){let t=BigInt(e.get_attribute_uint64(`filesystem::size`)??0),n=BigInt(e.get_attribute_uint64(`filesystem::free`)??0),r=BigInt(Nl),i=t/r,a=n/r;return{type:0n,bsize:r,blocks:i,bfree:a,bavail:a,files:0n,ffree:0n}}function statfsSync(e,t){let n=M.File.new_for_path(normalizePath(e)).query_filesystem_info(Ml,null);return t?.bigint===!0?buildBigIntStatFs(n):buildStatFs(n)}function queryFsInfoAsync(e,t){return new Promise((n,r)=>{let i=M.File.new_for_path(normalizePath(e));i.query_filesystem_info_async(Ml,k.PRIORITY_DEFAULT,null,(e,a)=>{try{let e=i.query_filesystem_info_finish(a);n(t?buildBigIntStatFs(e):buildStatFs(e))}catch(e){r(e)}})})}function statfs(e,t,n){typeof t==`function`&&(n=t,t={}),queryFsInfoAsync(e,t?.bigint===!0).then(e=>n(null,e),e=>n(e,null))}async function statfsAsync(e,t){return queryFsInfoAsync(e,t?.bigint===!0)}var Ml,Nl,Pl=__esmMin(()=>{$l(),A(),N(),Ml=[`filesystem::size`,`filesystem::free`].join(`,`),Nl=4096}),Fl=__exportAll$4({lchmod:()=>lchmod,lchmodAsync:()=>lchmodAsync,lchmodSync:()=>lchmodSync,lchown:()=>lchown,lchownAsync:()=>lchownAsync,lchownSync:()=>lchownSync,lutimes:()=>lutimes,lutimesAsync:()=>lutimesAsync,lutimesSync:()=>lutimesSync,utimes:()=>utimes,utimesAsync:()=>utimesAsync,utimesSync:()=>utimesSync});function toGLibDateTime(e){let t=e instanceof Date?e.getTime():typeof e==`bigint`?Number(e):typeof e==`string`?Date.parse(e):e*1e3;return k.DateTime.new_from_unix_utc(Math.floor(t/1e3))}function setTimestamps(e,t,n,r){let i=M.File.new_for_path(e),a=new M.FileInfo;a.set_modification_date_time(toGLibDateTime(n)),a.set_access_date_time(toGLibDateTime(t)),i.set_attributes_from_info(a,r,null)}function utimesSync(e,t,n){setTimestamps(normalizePath(e),t,n,M.FileQueryInfoFlags.NONE)}function utimes(e,t,n,r){Promise.resolve().then(()=>utimesSync(e,t,n)).then(()=>r(null),r)}async function utimesAsync(e,t,n){utimesSync(e,t,n)}function lutimesSync(e,t,n){setTimestamps(normalizePath(e),t,n,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS)}function lutimes(e,t,n,r){Promise.resolve().then(()=>lutimesSync(e,t,n)).then(()=>r(null),r)}async function lutimesAsync(e,t,n){lutimesSync(e,t,n)}function lchownSync(e,t,n){k.spawn_command_line_sync(`chown -h ${t}:${n} ${normalizePath(e)}`)}function lchown(e,t,n,r){Promise.resolve().then(()=>lchownSync(e,t,n)).then(()=>r(null),r)}async function lchownAsync(e,t,n){lchownSync(e,t,n)}function lchmodSync(e,t){}function lchmod(e,t,n){n(null)}async function lchmodAsync(e,t){}var Il=__esmMin(()=>{$l(),A(),N()});function getFH(e){return e instanceof Xl?Xl.getInstance(e.fd):Xl.getInstance(e)}function fstatSync(e,t){return statSync(normalizePath(getFH(e).options.path),t)}function fstat(e,t,n){typeof t==`function`&&(n=t,t={}),Promise.resolve().then(()=>fstatSync(e,t)).then(e=>n(null,e),n)}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){truncateSync(normalizePath(getFH(e).options.path),t)}function ftruncate(e,t,n){typeof t==`function`&&(n=t,t=0),Promise.resolve().then(()=>ftruncateSync(e,t)).then(()=>n(null),n)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e)._flushSync()}function fdatasync(e,t){Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>t(null),t)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e)._flushSync()}function fsync(e,t){Promise.resolve().then(()=>fsyncSync(e)).then(()=>t(null),t)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){chmodSync(normalizePath(getFH(e).options.path),t)}function fchmod(e,t,n){Promise.resolve().then(()=>fchmodSync(e,t)).then(()=>n(null),n)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(e,t,n){chownSync(normalizePath(getFH(e).options.path),t,n)}function fchown(e,t,n,r){Promise.resolve().then(()=>fchownSync(e,t,n)).then(()=>r(null),r)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(e,t,n){utimesSync(normalizePath(getFH(e).options.path),t,n)}function futimes(e,t,n,r){Promise.resolve().then(()=>futimesSync(e,t,n)).then(()=>r(null),r)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){getFH(e)._closeSync()}function readSync(e,t,n,r,i){let a=0;return typeof n==`object`&&n?(a=n.offset??0,r=n.length??t.byteLength,i=n.position??null):(a=n??0,r??=t.byteLength-a),getFH(e)._readSync(t,a,r,i??null)}function writeSync(e,t,n,r,i){let a;if(typeof t==`string`)a=new TextEncoder().encode(t),typeof n==`number`&&(i=n);else{let e=typeof n==`number`?n:0,i=typeof r==`number`?r:t.byteLength-e;a=new Uint8Array(t.buffer,t.byteOffset+e,i)}return getFH(e)._writeSync(a,i??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,t,n,r){typeof n==`function`&&(r=n,n=null),Promise.resolve().then(()=>({bytesRead:readvSync(e,t,n),buffers:t})).then(e=>r(null,e.bytesRead,e.buffers),r)}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,t,n,r){typeof n==`function`&&(r=n,n=null),Promise.resolve().then(()=>({bytesWritten:writevSync(e,t,n),buffers:t})).then(e=>r(null,e.bytesWritten,e.buffers),r)}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(e,t){try{statSync(normalizePath(e)),t(!0)}catch{t(!1)}}async function openAsBlob(e,t){let n=readFileSync(normalizePath(e));return new Blob([n],{type:t?.type??``})}var Ll=__esmMin(()=>{$l(),Zl(),Ql(),Il()});async function mkdir$1(e,t){let n;typeof t==`object`&&(t.recursive&&(n=t.recursive),t.mode&&t.mode);let r=normalizePath(e);if(n)return mkdirRecursiveAsync(r);let i=M.File.new_for_path(r);return new Promise((e,t)=>{i.make_directory_async(k.PRIORITY_DEFAULT,null,(n,a)=>{try{i.make_directory_finish(a),e(void 0)}catch(e){t(createNodeError(e,`mkdir`,r))}})})}async function mkdirRecursiveAsync(e){let t=M.File.new_for_path(e);try{return await new Promise((e,n)=>{t.make_directory_async(k.PRIORITY_DEFAULT,null,(r,i)=>{try{t.make_directory_finish(i),e()}catch(e){n(e)}})}),e}catch(t){let n=t;if(n.code===M.IOErrorEnum.EXISTS)return;if(n.code===M.IOErrorEnum.NOT_FOUND){let n=no(e);if(n===e)throw createNodeError(t,`mkdir`,e);let r=await mkdirRecursiveAsync(n),i=M.File.new_for_path(e);return await new Promise((t,n)=>{i.make_directory_async(k.PRIORITY_DEFAULT,null,(r,a)=>{try{i.make_directory_finish(a),t()}catch(t){n(createNodeError(t,`mkdir`,e))}})}),r??e}throw createNodeError(t,`mkdir`,e)}}async function readFile$1(e,t={encoding:null,flag:`r`}){let n=normalizePath(e),r=M.File.new_for_path(n),i,a;try{[i,a]=await new Promise((e,t)=>{r.load_contents_async(null,(n,i)=>{try{e(r.load_contents_finish(i))}catch(e){t(e)}})})}catch(e){throw createNodeError(e,`open`,n)}if(!i)throw createNodeError(Error(`failed to read file`),`open`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),a)}async function mkdtemp(e,t){let n=getEncodingFromOptions(t),r=tempDirPath(e);return await mkdir$1(r,{recursive:!1,mode:448}),decode(r,n)}async function writeFile$1(e,t){let n=normalizePath(e),r=M.File.new_for_path(n),i;i=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?t:new TextEncoder().encode(String(t));let a=await new Promise((e,t)=>{r.replace_async(null,!1,M.FileCreateFlags.REPLACE_DESTINATION,k.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.replace_finish(a))}catch(e){t(createNodeError(e,`open`,n))}})});if(i.length>0){let e=new k.Bytes(i);await new Promise((t,r)=>{a.write_bytes_async(e,k.PRIORITY_DEFAULT,null,(e,i)=>{try{a.write_bytes_finish(i),t()}catch(e){r(createNodeError(e,`write`,n))}})})}await new Promise((e,t)=>{a.close_async(k.PRIORITY_DEFAULT,null,(r,i)=>{try{a.close_finish(i),e()}catch(e){t(createNodeError(e,`close`,n))}})})}async function rmdir$1(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);if((await new Promise((e,t)=>{r.query_info_async(`standard::type`,M.FileQueryInfoFlags.NONE,k.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.query_info_finish(a))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).get_file_type()!==M.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if((await new Promise((e,t)=>{r.enumerate_children_async(`standard::name`,M.FileQueryInfoFlags.NONE,k.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.enumerate_children_finish(a))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(k.PRIORITY_DEFAULT,null,(i,a)=>{try{r.delete_finish(a),e()}catch(e){t(createNodeError(e,`rmdir`,n))}})})}async function unlink$1(e){let t=normalizePath(e),n=M.File.new_for_path(t);await new Promise((e,r)=>{n.delete_async(k.PRIORITY_DEFAULT,null,(i,a)=>{try{n.delete_finish(a),e()}catch(e){r(createNodeError(e,`unlink`,t))}})})}async function open$1(e,t,n){return new Xl({path:e,flags:t,mode:n})}async function write$1(e,t,n,r,i){return typeof t==`string`?_writeStr(e,t,n,r):_writeBuf(e,t,n,r,i)}async function _writeBuf(e,t,n,r,i){return{bytesWritten:(await Xl.getInstance(e).write(t,n,r,i)).bytesWritten,buffer:t}}async function _writeStr(e,t,n,r){return{bytesWritten:(await Xl.getInstance(e).write(t,n,r)).bytesWritten,buffer:t}}function queryInfoAsync(e,t,n,r){let i=normalizePath(e);return new Promise((e,a)=>{let o=M.File.new_for_path(i);o.query_info_async(wl,t,k.PRIORITY_DEFAULT,null,(t,s)=>{try{let t=o.query_info_finish(s);e(r?.bigint?new BigIntStats(t,i):new Stats(t,i))}catch(e){a(createNodeError(e,n,i))}})})}async function stat$1(e,t){return queryInfoAsync(e,M.FileQueryInfoFlags.NONE,`stat`,t)}async function lstat$1(e,t){return queryInfoAsync(e,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,t)}async function readdir$1(e,t){try{return readdirSync(e,t)}catch(t){throw createNodeError(t,`scandir`,e)}}async function realpath$1(e){return realpathSync(e)}async function symlink$1(e,t,n){let r=normalizePath(t),i=normalizePath(e);return new Promise((e,t)=>{let n=M.File.new_for_path(r);n.make_symbolic_link_async(i,k.PRIORITY_DEFAULT,null,(a,o)=>{try{n.make_symbolic_link_finish(o),e()}catch(e){t(createNodeError(e,`symlink`,i,r))}})})}async function rm$1(e,t){let n=normalizePath(e),r=M.File.new_for_path(n),i=t?.recursive||!1,a=t?.force||!1,o;try{o=new Dirent(n)}catch(t){if(a)return;throw createNodeError(t,`rm`,e)}if(o.isDirectory()){let r=await readdir$1(e,{withFileTypes:!0});if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)typeof e!=`string`&&await rm$1($a(n,e.name),t)}await new Promise((t,n)=>{r.delete_async(k.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(a){t();return}n(createNodeError(r,`rm`,e))}})})}async function rename$1(e,t){renameSync(e,t)}async function copyFile$1(e,t,n){copyFileSync(e,t,n)}async function access$1(e,t){accessSync(e,t)}async function appendFile$1(e,t,n){appendFileSync(e,t,n)}async function readlink$1(e,t){return readlinkSync(e,t)}async function truncate$1(e,t){truncateSync(e,t)}async function chmod$1(e,t){chmodSync(e,t)}async function chown$1(e,t,n){chownSync(e,t,n)}async function link$1(e,t){linkSync(e,t)}var Rl,zl,Bl=__esmMin(()=>{xl(),Sl(),$l(),tu(),Cl(),Tl(),Zl(),Dl(),Ql(),Ol(),Al(),jl(),Pl(),Il(),Ll(),A(),N(),uo(),Rl=__exportAll({access:()=>access$1,appendFile:()=>appendFile$1,chmod:()=>chmod$1,chown:()=>chown$1,copyFile:()=>copyFile$1,cp:()=>cpPromises,default:()=>zl,fchmod:()=>fchmodAsync,fchown:()=>fchownAsync,fdatasync:()=>fdatasyncAsync,fstat:()=>fstatAsync,fsync:()=>fsyncAsync,ftruncate:()=>ftruncateAsync,futimes:()=>futimesAsync,glob:()=>globAsync,lchmod:()=>lchmodAsync,lchown:()=>lchownAsync,link:()=>link$1,lstat:()=>lstat$1,lutimes:()=>lutimesAsync,mkdir:()=>mkdir$1,mkdtemp:()=>mkdtemp,open:()=>open$1,openAsBlob:()=>openAsBlob,opendir:()=>opendirAsync,readFile:()=>readFile$1,readdir:()=>readdir$1,readlink:()=>readlink$1,readv:()=>readvAsync,realpath:()=>realpath$1,rename:()=>rename$1,rm:()=>rm$1,rmdir:()=>rmdir$1,stat:()=>stat$1,statfs:()=>statfsAsync,symlink:()=>symlink$1,truncate:()=>truncate$1,unlink:()=>unlink$1,utimes:()=>utimesAsync,watch:()=>watchAsync,write:()=>write$1,writeFile:()=>writeFile$1,writev:()=>writevAsync}),__name(mkdir$1,`mkdir`),__name(readFile$1,`readFile`),__name(writeFile$1,`writeFile`),__name(rmdir$1,`rmdir`),__name(unlink$1,`unlink`),__name(open$1,`open`),__name(write$1,`write`),__name(stat$1,`stat`),__name(lstat$1,`lstat`),__name(readdir$1,`readdir`),__name(realpath$1,`realpath`),__name(symlink$1,`symlink`),__name(rm$1,`rm`),__name(rename$1,`rename`),__name(copyFile$1,`copyFile`),__name(access$1,`access`),__name(appendFile$1,`appendFile`),__name(readlink$1,`readlink`),__name(truncate$1,`truncate`),__name(chmod$1,`chmod`),__name(chown$1,`chown`),__name(link$1,`link`),zl={readFile:readFile$1,mkdir:mkdir$1,mkdtemp,realpath:realpath$1,readdir:readdir$1,writeFile:writeFile$1,rmdir:rmdir$1,unlink:unlink$1,open:open$1,write:write$1,rm:rm$1,lstat:lstat$1,symlink:symlink$1,stat:stat$1,rename:rename$1,copyFile:copyFile$1,access:access$1,appendFile:appendFile$1,readlink:readlink$1,truncate:truncate$1,chmod:chmod$1,chown:chown$1,link:link$1,cp:cpPromises,opendir:opendirAsync,glob:globAsync,watch:watchAsync,statfs:statfsAsync,utimes:utimesAsync,lutimes:lutimesAsync,lchown:lchownAsync,lchmod:lchmodAsync,fstat:fstatAsync,ftruncate:ftruncateAsync,fdatasync:fdatasyncAsync,fsync:fsyncAsync,fchmod:fchmodAsync,fchown:fchownAsync,futimes:futimesAsync,readv:readvAsync,writev:writevAsync,openAsBlob}});function parseOptsCb(e,t){return typeof e==`function`?{options:{},callback:e}:{options:e??{},callback:t}}function statImpl(e,t,n,r,i){let a=normalizePath(e),o=M.File.new_for_path(a);o.query_info_async(wl,t,k.PRIORITY_DEFAULT,null,(e,t)=>{try{let e=o.query_info_finish(t);i(null,r?.bigint?new BigIntStats(e,a):new Stats(e,a))}catch(e){i(createNodeError(e,n,a))}})}function stat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,M.FileQueryInfoFlags.NONE,`stat`,r,i)}function lstat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,r,i)}function readdir(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{i(null,readdirSync(e,r))}catch(t){i(createNodeError(t,`readdir`,e))}})}function realpath(e,t,n){let{callback:r}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{r(null,realpathSync(e))}catch(e){r(e)}})}function symlink(e,t,n,r){let i=typeof n==`function`?n:r;if(typeof i!=`function`)throw TypeError(`Callback must be a function. Received `+typeof i);let a=normalizePath(t),o=normalizePath(e),s=M.File.new_for_path(a);s.make_symbolic_link_async(o,k.PRIORITY_DEFAULT,null,(e,t)=>{try{s.make_symbolic_link_finish(t),i(null)}catch(e){i(createNodeError(e,`symlink`,o,a))}})}function open(e,...t){let n,r,i;switch(t.length){case 1:i=t[0];break;case 2:n=t[0],i=t[1];break;case 3:n=t[0],r=t[1],i=t[2];break;default:break}open$1(e,n,r).then(e=>{i(null,e.fd)}).catch(e=>{i(e,-1)})}function write(e,t,...n){let r=Xl.getInstance(e);if(typeof t==`string`){let e=n.pop(),i=n[0],a=n[1];r.write(t,i,a).then(t=>{e(null,t.bytesWritten,t.buffer)}).catch(t=>{e(t,0,``)});return}let i=n[n.length-1],a=n[0],o=n[1],s=n[2];r.write(t,a,o,s).then(e=>{i(null,e.bytesWritten,e.buffer)}).catch(e=>{i(e,0,q.from([]))})}function read(e,...t){let n=Xl.getInstance(e),r=t[t.length-1],i,a,o,s;if(!(t.length<=1))if(typeof t[0]==`object`&&!ArrayBuffer.isView(t[0])){let e=t[0];i=e.buffer,a=e.offset,o=e.length,s=e.position}else i=t[0],a=t[1],o=t[2],s=t[3];n.read(i,a,o,s).then(e=>{r(null,e.bytesRead,e.buffer)}).catch(e=>{r(e,0,q.from([]))})}function close(e,t){Xl.getInstance(e).close().then(()=>{t(null)}).catch(e=>t(e))}function rm(e,...t){let n={},r=t[t.length-1];t.length>=2&&(n=t[0]),rm$1(e,n).then(()=>{r(null)}).catch(e=>{r(e)})}function rename(e,t,n){Promise.resolve().then(()=>{try{renameSync(e,t),n(null)}catch(e){n(e)}})}function copyFile(e,t,n,r){let i=typeof n==`function`?0:n,a=typeof n==`function`?n:r;Promise.resolve().then(()=>{try{copyFileSync(e,t,i),a(null)}catch(e){a(e)}})}function access(e,t,n){let r=typeof t==`function`?void 0:t,i=typeof t==`function`?t:n;Promise.resolve().then(()=>{try{accessSync(e,r),i(null)}catch(e){i(e)}})}function appendFile(e,t,n,r){let i=typeof n==`function`?n:r,a=typeof n==`function`?void 0:n;Promise.resolve().then(()=>{try{appendFileSync(e,t,a),i(null)}catch(e){i(e)}})}function readlink(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{r(null,readlinkSync(e,i))}catch(e){r(e,``)}})}function truncate(e,t,n){let r=typeof t==`function`?0:t,i=typeof t==`function`?t:n;Promise.resolve().then(()=>{try{truncateSync(e,r),i(null)}catch(e){i(e)}})}function chmod(e,t,n){Promise.resolve().then(()=>{try{chmodSync(e,t),n(null)}catch(e){n(e)}})}function chown(e,t,n,r){Promise.resolve().then(()=>{try{chownSync(e,t,n),r(null)}catch(e){r(e)}})}function mkdir(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{mkdirSync(e,i),r(null)}catch(e){r(e)}})}function rmdir(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{rmdirSync(e,i),r(null)}catch(e){r(e)}})}function readFile(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t,a=normalizePath(e);Promise.resolve().then(()=>{try{r(null,readFileSync(a,typeof i==`string`?{encoding:i,flag:`r`}:{encoding:i?.encoding??null,flag:i?.flag??`r`}))}catch(e){r(e,null)}})}function writeFile(e,t,n,r){let i=typeof n==`function`?n:r,a=normalizePath(e);Promise.resolve().then(()=>{try{writeFileSync(a,t),i(null)}catch(e){i(e)}})}function link(e,t,n){let r=normalizePath(e),i=normalizePath(t);Promise.resolve().then(()=>{try{if(!k.spawn_command_line_sync(`ln ${r} ${i}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, link '${r}' -> '${i}'`),{code:`EPERM`,errno:-1,syscall:`link`,path:r,dest:i});n(null)}catch(e){n(e)}})}function unlink(e,t){let n=normalizePath(e);Promise.resolve().then(()=>{try{k.unlink(n),t(null)}catch(e){t(e)}})}var Vl=__esmMin(()=>{$l(),Tl(),Zl(),Dl(),Ql(),Bl(),A(),N(),J()});function toPathIfFileURL(e){return normalizePath(e)}function createWriteStream(e,t){return new WriteStream(e,t)}var Hl,Ul,WriteStream,Wl=__esmMin(()=>{$l(),Vl(),Kr(),Hl=Symbol(`kIsPerformingIO`),Ul=Symbol(`kIoDone`),WriteStream=class extends Vr{close(e,t=null){this.fd?(close(this.fd,n=>{e(n||t)}),this.fd=null):e(t)}bytesWritten=0;path;pending;fd=null;flags=`w`;mode=438;pos=0;[Hl]=!1;constructor(e,t={}){super(t),this.path=toPathIfFileURL(e),t.encoding&&this.setDefaultEncoding(t.encoding)}_construct(e){open(this.path.toString(),this.flags,this.mode,(t,n)=>{if(t){e(t);return}this.fd=n,e(),this.emit(`open`,this.fd),this.emit(`ready`)})}_write(e,t,n){this[Hl]=!0,write(this.fd,e,0,e.length,this.pos,(e,t)=>{if(this[Hl]=!1,this.destroyed)return n(e),this.emit(Ul,e);if(e)return n(e);this.bytesWritten+=t,n()}),this.pos!==void 0&&(this.pos+=e.length)}_destroy(e,t){this[Hl]?this.once(Ul,n=>this.close(t,e||n)):this.close(t,e)}}});function resolveIOMode(e){if(e==null)return`r`;if(typeof e==`number`){let t=(e&2)!=0,n=(e&1)!=0,r=(e&1024)!=0,i=(e&512)!=0;return t?i?`w+`:`r+`:n?r?`a`:`w`:`r`}switch(e){case`ax`:case`wx`:return`w`;case`ax+`:case`wx+`:return`w+`;case`as`:case`rs+`:return`r+`;case`as+`:return`a+`;default:return e}}function shouldCreate(e){return typeof e==`number`?(e&64)!=0:typeof e==`string`?e===`w`||e===`w+`||e===`wx`||e===`wx+`||e===`a`||e===`a+`||e===`ax`||e===`ax+`||e===`as`||e===`as+`:!1}function openIOChannel(e,t,n){try{return k.IOChannel.new_file(e,t)}catch(r){if(n&&t===`r+`&&r?.code===k.FileError.NOENT)return k.file_set_contents(e,new Uint8Array),k.IOChannel.new_file(e,t);throw r}}function mapOpenError(e,t){return createGLibFileError(e,`open`,{path:t})}var Gl=__esmMin(()=>{A(),L()});function createInterface(e,t,n,r){return typeof e==`object`&&e&&!(`read`in e&&typeof e.read==`function`)?new Interface(e):new Interface({input:e,output:t,completer:n,terminal:r})}function*emitKeys(e){for(;;){let t=yield,n=t,r=!1,i={sequence:``,name:void 0,ctrl:!1,meta:!1,shift:!1};if(t===`\x1B`&&(r=!0,n+=t=yield,t===`\x1B`&&(n+=t=yield)),r&&(t===`O`||t===`[`)){let e=t,r=0;if(t===`O`)n+=t=yield,t>=`0`&&t<=`9`&&(r=t.charCodeAt(0)-1,n+=t=yield),e+=t;else if(t===`[`){n+=t=yield,t===`[`&&(e+=t,n+=t=yield);let i=n.length-1;t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield))),t===`;`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=yield));let a=n.slice(i),o;(o=/^(?:(\d\d?)(?:;(\d))?([~^$])|(\d{3}~))$/.exec(a))?o[4]?e+=o[4]:(e+=o[1]+o[3],r=(parseInt(o[2]??`1`,10)||1)-1):(o=/^((\d;)?(\d))?([A-Za-z])$/.exec(a))?(e+=o[4],r=(parseInt(o[3]??`1`,10)||1)-1):e+=a}switch(i.ctrl=!!(r&4),i.meta=!!(r&10),i.shift=!!(r&1),i.code=e,e){case`[P`:case`OP`:case`[11~`:case`[[A`:i.name=`f1`;break;case`[Q`:case`OQ`:case`[12~`:case`[[B`:i.name=`f2`;break;case`[R`:case`OR`:case`[13~`:case`[[C`:i.name=`f3`;break;case`[S`:case`OS`:case`[14~`:case`[[D`:i.name=`f4`;break;case`[15~`:case`[[E`:i.name=`f5`;break;case`[17~`:i.name=`f6`;break;case`[18~`:i.name=`f7`;break;case`[19~`:i.name=`f8`;break;case`[20~`:i.name=`f9`;break;case`[21~`:i.name=`f10`;break;case`[23~`:i.name=`f11`;break;case`[24~`:i.name=`f12`;break;case`[200~`:i.name=`paste-start`;break;case`[201~`:i.name=`paste-end`;break;case`[A`:case`OA`:i.name=`up`;break;case`[B`:case`OB`:i.name=`down`;break;case`[C`:case`OC`:i.name=`right`;break;case`[D`:case`OD`:i.name=`left`;break;case`[E`:case`OE`:i.name=`clear`;break;case`[F`:case`OF`:i.name=`end`;break;case`[H`:case`OH`:i.name=`home`;break;case`[1~`:i.name=`home`;break;case`[2~`:i.name=`insert`;break;case`[3~`:i.name=`delete`;break;case`[4~`:i.name=`end`;break;case`[5~`:case`[[5~`:i.name=`pageup`;break;case`[6~`:case`[[6~`:i.name=`pagedown`;break;case`[7~`:i.name=`home`;break;case`[8~`:i.name=`end`;break;case`[a`:i.name=`up`,i.shift=!0;break;case`[b`:i.name=`down`,i.shift=!0;break;case`[c`:i.name=`right`,i.shift=!0;break;case`[d`:i.name=`left`,i.shift=!0;break;case`[2$`:i.name=`insert`,i.shift=!0;break;case`[3$`:i.name=`delete`,i.shift=!0;break;case`[5$`:i.name=`pageup`,i.shift=!0;break;case`[6$`:i.name=`pagedown`,i.shift=!0;break;case`[7$`:i.name=`home`,i.shift=!0;break;case`[8$`:i.name=`end`,i.shift=!0;break;case`Oa`:i.name=`up`,i.ctrl=!0;break;case`Ob`:i.name=`down`,i.ctrl=!0;break;case`Oc`:i.name=`right`,i.ctrl=!0;break;case`Od`:i.name=`left`,i.ctrl=!0;break;case`[2^`:i.name=`insert`,i.ctrl=!0;break;case`[3^`:i.name=`delete`,i.ctrl=!0;break;case`[5^`:i.name=`pageup`,i.ctrl=!0;break;case`[6^`:i.name=`pagedown`,i.ctrl=!0;break;case`[7^`:i.name=`home`,i.ctrl=!0;break;case`[8^`:i.name=`end`,i.ctrl=!0;break;case`[Z`:i.name=`tab`,i.shift=!0;break;default:i.name=`undefined`;break}}else t===`\r`?(i.name=`return`,i.meta=r):t===`
192
- `?(i.name=`enter`,i.meta=r):t===` `?(i.name=`tab`,i.meta=r):t===`\b`||t===``?(i.name=`backspace`,i.meta=r):t===`\x1B`?(i.name=`escape`,i.meta=r):t===` `?(i.name=`space`,i.meta=r):!r&&t<=``?(i.name=String.fromCharCode(t.charCodeAt(0)+97-1),i.ctrl=!0):/^[0-9A-Za-z]$/.test(t)?(i.name=t.toLowerCase(),i.shift=/^[A-Z]$/.test(t),i.meta=r):r&&(i.name=t.length?void 0:`escape`,i.meta=!0);i.sequence=n,n.length!==0&&(i.name!==void 0||r)?e.emit(`keypress`,r?void 0:n,i):n.length===1&&e.emit(`keypress`,n,i)}}function emitKeypressEvents(e,t={}){let n=e;if(n[ql])return;n[ql]=new Do(`utf8`),n[Jl]=emitKeys(e),n[Jl].next();let r=t.escapeCodeTimeout??500,i,triggerEscape=()=>n[Jl].next(``);function onData(t){if(e.listenerCount(`keypress`)>0){let a=n[ql].write(typeof t==`string`?Buffer.from(t):t);if(a){clearTimeout(i);for(let t of a)try{n[Jl].next(t),t===`\x1B`&&(i=setTimeout(triggerEscape,r))}catch{n[Jl]=emitKeys(e),n[Jl].next()}}}else e.removeListener(`data`,onData),delete n[ql],delete n[Jl]}e.on(`data`,onData)}var Kl,Interface,ql,Jl,Yl=__esmMin(()=>{bn(),ko(),Kl=/\r\n|\r|\n/,Interface=class extends Y{terminal;line=``;cursor=0;escapeCodeTimeout;_input;_output;get input(){return this._input}get output(){return this._output}_prompt;_closed=!1;_paused=!1;history;_historySize;_crlfDelay;_lineBuffer=``;_questionCallback=null;_boundOnData=null;_boundOnEnd=null;_boundOnError=null;_boundOnKeypress=null;constructor(e,t){super();let n;if(n=e&&typeof e==`object`&&!(`read`in e&&typeof e.read==`function`)?e:{input:e,output:t},this._input=n.input||null,this._output=n.output||null,this._prompt=n.prompt||`> `,this.terminal=n.terminal??this._output!==null,this._historySize=n.historySize??30,this.history=[],this._crlfDelay=n.crlfDelay??100,this.escapeCodeTimeout=n.escapeCodeTimeout,this._input&&(this._boundOnData=e=>this._onData(e),this._boundOnEnd=()=>this._onEnd(),this._boundOnError=e=>this.emit(`error`,e),this._input.on(`data`,this._boundOnData),this._input.on(`end`,this._boundOnEnd),this._input.on(`error`,this._boundOnError),`setEncoding`in this._input&&typeof this._input.setEncoding==`function`&&this._input.setEncoding(`utf8`),this.terminal)){emitKeypressEvents(this._input,this);let e=this._input;typeof e.setRawMode==`function`&&(e.isRaw||e.setRawMode(!0)),typeof this._input.resume==`function`&&this._input.resume(),this._boundOnKeypress=(e,t)=>{t&&(t.name===`backspace`||t.name===`delete`?this.cursor>0&&(this.line=this.line.slice(0,this.cursor-1)+this.line.slice(this.cursor),this.cursor--):e&&e.length===1&&!t.ctrl&&!t.meta&&t.name!==`return`&&t.name!==`enter`&&t.name!==`escape`&&(this.line=this.line.slice(0,this.cursor)+e+this.line.slice(this.cursor),this.cursor++))},this._input.on(`keypress`,this._boundOnKeypress)}}_onData(e){if(this._closed||this._paused)return;let t=typeof e==`string`?e:e.toString(`utf8`);this._lineBuffer+=t;let n;for(;(n=Kl.exec(this._lineBuffer))!==null;){let e=this._lineBuffer.substring(0,n.index);this._lineBuffer=this._lineBuffer.substring(n.index+n[0].length),this._onLine(e)}}_onLine(e){if(e.length>0&&this._historySize>0&&(this.history.length===0||this.history[0]!==e)&&(this.history.unshift(e),this.history.length>this._historySize&&this.history.pop()),this._questionCallback){let t=this._questionCallback;this._questionCallback=null,t(e)}this.emit(`line`,e)}_onEnd(){this._lineBuffer.length>0&&(this._onLine(this._lineBuffer),this._lineBuffer=``),this.close()}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(this._closed)throw Error(`readline was closed`);this._output?.write(this._prompt)}question(e,t,n){if(this._closed)throw Error(`readline was closed`);let r=typeof t==`function`?t:n;this._questionCallback=r,this._output?.write(e)}clearLine(e,t){return this.line=``,this.cursor=0,t&&t(),!0}write(e,t){if(!this._closed){if(t){this._input&&this._input.emit(`keypress`,e??``,t);return}if(e!=null){let t=typeof e==`string`?e:e.toString(`utf8`);t&&(this.line=this.line.slice(0,this.cursor)+t+this.line.slice(this.cursor),this.cursor+=t.length),this._output?.write(e)}}}close(){if(!this._closed){if(this._closed=!0,this._input){this._boundOnData&&this._input.removeListener(`data`,this._boundOnData),this._boundOnEnd&&this._input.removeListener(`end`,this._boundOnEnd),this._boundOnError&&this._input.removeListener(`error`,this._boundOnError),this._boundOnKeypress&&this._input.removeListener(`keypress`,this._boundOnKeypress),this._boundOnData=null,this._boundOnEnd=null,this._boundOnError=null,this._boundOnKeypress=null;let e=this._input;this.terminal&&e.isRaw&&typeof e.setRawMode==`function`&&e.setRawMode(!1),typeof this._input.pause==`function`&&this._input.pause()}this.emit(`close`)}}pause(){return this._closed?this:(this._paused=!0,this._input&&`pause`in this._input&&typeof this._input.pause==`function`&&this._input.pause(),this.emit(`pause`),this)}resume(){return this._closed?this:(this._paused=!1,this._input&&`resume`in this._input&&typeof this._input.resume==`function`&&this._input.resume(),this.emit(`resume`),this)}getCursorPos(){let e=this._output?.columns??80,t=this._prompt.length+this.cursor;return{rows:Math.floor(t/e),cols:t%e}}[Symbol.asyncIterator](){let e=[],t=null,n=!1,onLine=n=>{if(t){let e=t;t=null,e({value:n,done:!1})}else e.push(n)},onClose=()=>{if(n=!0,t){let e=t;t=null,e({value:void 0,done:!0})}};return this.on(`line`,onLine),this.on(`close`,onClose),{next:()=>e.length>0?Promise.resolve({value:e.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(e=>{t=e}),return:()=>(n=!0,this.removeListener(`line`,onLine),this.removeListener(`close`,onClose),Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return this}}}},ql=Symbol(`keypress-decoder`),Jl=Symbol(`escape-decoder`)}),Xl,Zl=__esmMin(()=>{Sl(),$l(),El(),Wl(),Tl(),Gl(),Ql(),A(),N(),J(),Yl(),Xl=class FileHandle{options;_file;_ioStream=null;_readStream=null;_gFile;_ioMode;_ioLock=Promise.resolve();static instances={};constructor(e){this.options=e,this.options.flags||=`r`,this.options.mode||=438;let t=normalizePath(e.path),n=shouldCreate(e.flags),r=resolveIOMode(e.flags);try{this._file=openIOChannel(t,r,n)}catch(e){throw mapOpenError(e,t)}return this._file.set_encoding(null),this.fd=this._file.unix_get_fd(),this._gFile=M.File.new_for_path(t),this._ioMode=r,FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_getReadStream(){return this._ioStream?{input:this._ioStream.get_input_stream(),seekable:this._ioStream}:this._ioMode===`r`?(this._readStream||=this._gFile.read(null),{input:this._readStream,seekable:this._readStream}):(this._ioStream=this._gFile.open_readwrite(null),{input:this._ioStream.get_input_stream(),seekable:this._ioStream})}_getWriteStream(){if(this._ioStream)return this._ioStream;if(this._ioMode===`r`)throw Error(`FileHandle opened read-only; cannot write`);return this._ioStream=this._gFile.open_readwrite(null),this._ioStream}_serialize(e){let t=this._ioLock.catch(()=>{}).then(e);return this._ioLock=t,t}fd;static getInstance(e){if(!FileHandle.instances[e])throw Error(`No instance found for fd!`);return FileHandle.instances[e]}async appendFile(e,t){let n=getEncodingFromOptions(t);typeof e==`string`&&(e=q.from(e)),n&&this._file.set_encoding(n);let[r,i]=this._file.write_chars(e,e.length);if(r===k.IOStatus.ERROR)throw Error(`Error on append to file!`)}async chown(e,t){chownSync(normalizePath(this.options.path),e,t)}async chmod(e){chmodSync(normalizePath(this.options.path),e)}createReadStream(e){return new ReadStream(this.options.path,e)}createWriteStream(e){return new WriteStream(this.options.path,e)}async datasync(){this._file.flush()}async sync(){this._file.flush()}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof q)){let a=e[0];t=a.buffer,n=a.offset,r=a.length,i=a.position}else t=e[0],n=e[1],r=e[2],i=e[3];let a=t,o=n??0,s=r??a?.byteLength??65536,c=i??0;return this._serialize(async()=>{let{input:e,seekable:n}=this._getReadStream();n.seek(BigInt(c),k.SeekType.SET,null);let r=e.read_bytes(s,null).get_data(),i=r?.length??0;return a&&r&&i>0&&a.set(r,o),{bytesRead:i,buffer:t}})}readableWebStream(){let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/streams" before calling this method.`);return new e}async readFile(e){let t=getEncodingFromOptions(e,`buffer`);t&&this._file.set_encoding(t);let[n,r]=this._file.read_to_end();if(n===k.IOStatus.ERROR)throw Error(`Error on read from file!`);return encodeUint8Array(t,r)}readLines(e){return createInterface({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){let t=await new Promise((e,t)=>{this._gFile.query_info_async(wl,M.FileQueryInfoFlags.NONE,k.PRIORITY_DEFAULT,null,(n,r)=>{try{e(this._gFile.query_info_finish(r))}catch(e){t(e)}})}),n=normalizePath(this.options.path);return e?.bigint?new BigIntStats(t,n):new Stats(t,n)}async truncate(e=0){let t=Math.max(0,e);this._file.flush(),this._getWriteStream().get_output_stream().truncate(t,null)}async utimes(e,t){let{utimesSync:n}=await Promise.resolve().then(()=>(Il(),Fl));n(normalizePath(this.options.path),e,t)}async writeFile(e,t){let n=getEncodingFromOptions(t),r;r=typeof e==`string`?q.from(e,n||`utf8`):e,this._file.seek_position(0,k.SeekType.SET);let[i]=this._file.write_chars(r,r.length);if(i===k.IOStatus.ERROR)throw Error(`Error writing to file!`);this._file.flush()}async write(e,...t){let n=null,r=null,i=null,a=null;typeof e==`string`?(n=t[0],r=t[1]):(i=t[0],a=t[1],n=t[2]),r=getEncodingFromOptions(r,typeof e==`string`?`utf8`:null);let o;o=typeof e==`string`?new TextEncoder().encode(e):e;let s=i??0,c=a??o.byteLength-s,l=o.slice(s,s+c),u=n??0;return{bytesWritten:await this._serialize(async()=>{let e=this._getWriteStream();e.seek(BigInt(u),k.SeekType.SET,null);let t=e.get_output_stream(),n=await new Promise((e,n)=>{t.write_bytes_async(new k.Bytes(l),k.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.write_bytes_finish(i))}catch(e){n(e)}})});return await new Promise((e,n)=>{t.flush_async(k.PRIORITY_DEFAULT,null,(r,i)=>{try{t.flush_finish(i),e()}catch(e){n(e)}})}),n}),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=q.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:q.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){this._file.flush()}_closeSync(){try{this._ioStream?.close(null)}catch{}try{this._readStream?.close(null)}catch{}this._ioStream=null,this._readStream=null;try{this._file.shutdown(!0)}catch{}let e=FileHandle;delete e.instances[this.fd]}_readSync(e,t,n,r){let i=this._gFile.read(null);try{r!==null&&r>=0&&i.seek(r,k.SeekType.SET,null);let a=i.read_bytes(n,null).get_data();return new Uint8Array(e.buffer,e.byteOffset+t).set(a.subarray(0,a.length)),a.length}finally{i.close(null)}}_writeSync(e,t){let n=this._gFile.open_readwrite(null);try{return t!==null&&t>=0&&n.seek(t,k.SeekType.SET,null),n.get_output_stream().write_bytes(k.Bytes.new(e),null)}finally{n.close(null)}}async close(){try{this._ioStream?.close(null)}catch{}try{this._readStream?.close(null)}catch{}this._ioStream=null,this._readStream=null;try{this._file.shutdown(!0)}catch{}}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}}});function statSync(e,t){let n=normalizePath(e);try{let e=M.File.new_for_path(n).query_info(wl,M.FileQueryInfoFlags.NONE,null);return t?.bigint?new BigIntStats(e,n):new Stats(e,n)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`stat`,n)}}function lstatSync(e,t){let n=normalizePath(e);try{let e=M.File.new_for_path(n).query_info(wl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);return t?.bigint?new BigIntStats(e,n):new Stats(e,n)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`lstat`,n)}}function readdirSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n).enumerate_children(`standard::name,standard::type`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),i=[];try{let e=r.next_file(null);for(;e!==null;)i.push({name:e.get_name(),type:e.get_file_type()}),e=r.next_file(null)}finally{try{r.close(null)}catch{}}let a=[];for(let e of i){let r=$a(n,e.name);if(t?.withFileTypes?a.push(new Dirent(r,e.name,e.type)):a.push(e.name),t?.recursive&&e.type===M.FileType.DIRECTORY){let n=readdirSync(r,t);for(let t of n)typeof t==`string`?a.push($a(e.name,t)):a.push(t)}}return a}function realpathSync(e){let t=normalizePath(e),n=M.File.new_for_path(t),r=0;for(;;){let e=n.query_info(`standard::is-symlink,standard::symlink-target`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(!e.get_is_symlink())return n.get_path();let i=e.get_symlink_target(),a=n.get_parent();if(n=a?a.resolve_relative_path(i):M.File.new_for_path(i),++r>40)throw Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`)}}function symlinkSync(e,t,n){let r=normalizePath(t),i=normalizePath(e);M.File.new_for_path(r).make_symbolic_link(i,null)}function readFileSync(e,t={encoding:null,flag:`r`}){let n=normalizePath(e),r=M.File.new_for_path(n);try{let[e,i]=r.load_contents(null);if(!e)throw createNodeError(Error(`failed to read file`),`read`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),i)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`read`,n)}}function mkdirSync(e,t){let n=!1,r=511;if(typeof t==`object`?(t?.recursive&&(n=t.recursive),t?.mode&&(r=t.mode)):r=t||511,e=normalizePath(e),typeof r==`string`)throw TypeError(`mode as string is currently not supported!`);if(n)return mkdirSyncRecursive(e);let i=M.File.new_for_path(e);try{i.make_directory(null)}catch(t){throw createNodeError(t,`mkdir`,e)}}function mkdirSyncRecursive(e){let t=M.File.new_for_path(e);try{return t.make_directory(null),e}catch(t){let n=t;if(n.code===M.IOErrorEnum.EXISTS)return;if(n.code===M.IOErrorEnum.NOT_FOUND){let n=$a(e,`..`),r=M.File.new_for_path(n).get_path();if(r===e)throw createNodeError(t,`mkdir`,e);let i=mkdirSyncRecursive(r),a=M.File.new_for_path(e);try{a.make_directory(null)}catch(t){throw createNodeError(t,`mkdir`,e)}return i??e}throw createNodeError(t,`mkdir`,e)}}function rmdirSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{if(r.query_info(`standard::type`,M.FileQueryInfoFlags.NONE,null).get_file_type()!==M.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if(r.enumerate_children(`standard::name`,M.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);r.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`rmdir`,n)}}function unlinkSync(e){let t=normalizePath(e),n=M.File.new_for_path(t);try{n.delete(null)}catch(e){throw createNodeError(e,`unlink`,t)}}function writeFileSync(e,t){k.file_set_contents(normalizePath(e),t)}function renameSync(e,t){let n=normalizePath(e),r=normalizePath(t),i=M.File.new_for_path(n),a=M.File.new_for_path(r);try{i.move(a,M.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw createNodeError(e,`rename`,n,r)}}function copyFileSync(e,t,n){let r=normalizePath(e),i=normalizePath(t),a=M.File.new_for_path(r),o=M.File.new_for_path(i),s=M.FileCopyFlags.NONE;n&&!(n&1)?s=M.FileCopyFlags.OVERWRITE:n||(s=M.FileCopyFlags.OVERWRITE);try{a.copy(o,s,null,null)}catch(e){throw createNodeError(e,`copyfile`,r,i)}}function accessSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{let e=r.query_info(`access::*`,M.FileQueryInfoFlags.NONE,null);if(t!==void 0&&t!==0){let r={code:14,message:`permission denied, access '${n}'`};if(t&4&&!e.get_attribute_boolean(`access::can-read`)||t&2&&!e.get_attribute_boolean(`access::can-write`)||t&1&&!e.get_attribute_boolean(`access::can-execute`))throw createNodeError(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`access`,n)}}function appendFileSync(e,t,n){let r=normalizePath(e),i=M.File.new_for_path(r),a;a=typeof t==`string`?new TextEncoder().encode(t):t;try{let e=i.append_to(M.FileCreateFlags.NONE,null);a.length>0&&e.write_bytes(new k.Bytes(a),null),e.close(null)}catch(e){throw createNodeError(e,`appendfile`,r)}}function readlinkSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{let e=r.query_info(`standard::symlink-target`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_symlink_target();if(!e)throw Object.assign(Error(`EINVAL: invalid argument, readlink '${n}'`),{code:`EINVAL`,errno:-22,syscall:`readlink`,path:n});return(typeof t==`string`?t:t?.encoding)===`buffer`?q.from(e):e}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`readlink`,n)}}function linkSync(e,t){let n=normalizePath(e),r=normalizePath(t);if(!k.spawn_command_line_sync(`ln ${n} ${r}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, link '${n}' -> '${r}'`),{code:`EPERM`,errno:-1,syscall:`link`,path:n,dest:r})}function truncateSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{let e=r.replace(null,!1,M.FileCreateFlags.NONE,null);if(t&&t>0){let[,n]=r.load_contents(null),i=n.slice(0,t);i.length>0&&e.write_bytes(new k.Bytes(i),null)}e.close(null)}catch(e){throw createNodeError(e,`truncate`,n)}}function chmodSync(e,t){let n=normalizePath(e),r=typeof t==`string`?parseInt(t,8):t;if(!k.spawn_command_line_sync(`chmod ${r.toString(8)} ${n}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, chmod '${n}'`),{code:`EPERM`,errno:-1,syscall:`chmod`,path:n})}function chownSync(e,t,n){let r=normalizePath(e);if(!k.spawn_command_line_sync(`chown ${t}:${n} ${r}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, chown '${r}'`),{code:`EPERM`,errno:-1,syscall:`chown`,path:r})}function watch(e,t,n){return new FSWatcher(normalizePath(e),t,n)}function openSync(e,t,n){return new Xl({path:e,flags:t,mode:n})}function mkdtempSync(e,t){let n=getEncodingFromOptions(t),r=tempDirPath(e);return mkdirSync(r,{recursive:!1,mode:511}),decode(r,n)}function rmSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n),i=t?.recursive||!1,a=t?.force||!1,o;try{o=new Dirent(n)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}if(o.isDirectory()){let r=readdirSync(e);if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)rmSync($a(n,e),t)}try{r.delete(null)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}}var Ql=__esmMin(()=>{Sl(),$l(),tu(),Cl(),Tl(),Zl(),Dl(),A(),N(),uo(),J(),L(),realpathSync.native=realpathSync});function normalizePath(e){return e instanceof URL||e instanceof Z?fileURLToPath(e):typeof e==`string`?e:e.toString()}function randomName(){return[...[,,,,,,]].map(()=>`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`[Math.floor(Math.random()*62)]).join(``)}function tempDirPath(e){let t;do t=e+randomName();while(existsSync(t));return t}var $l=__esmMin(()=>{Ql(),On()});function changed(e,t,n,r){switch(r){case M.FileMonitorEvent.CHANGES_DONE_HINT:this.emit(`change`,`change`,t.get_basename());break;case M.FileMonitorEvent.DELETED:case M.FileMonitorEvent.CREATED:case M.FileMonitorEvent.RENAMED:case M.FileMonitorEvent.MOVED_IN:case M.FileMonitorEvent.MOVED_OUT:this.emit(`rename`,`rename`,t.get_basename());break}}function gioEventToNodeType(e){switch(e){case M.FileMonitorEvent.CHANGES_DONE_HINT:return`change`;case M.FileMonitorEvent.DELETED:case M.FileMonitorEvent.CREATED:case M.FileMonitorEvent.RENAMED:case M.FileMonitorEvent.MOVED_IN:case M.FileMonitorEvent.MOVED_OUT:return`rename`;default:return null}}async function*watchAsync(e,t){let n=t?.signal;if(n?.aborted)return;let r=normalizePath(e),i=M.File.new_for_path(r),a=M.Cancellable.new(),o;try{o=i.monitor(M.FileMonitorFlags.NONE,a)}catch{return}let s=[],c=[],l=!1;function enqueue(e){l||(c.length>0?c.shift().resolve({value:e,done:!1}):s.push(e))}function terminate(){if(!l)for(l=!0,a.is_cancelled()||a.cancel();c.length>0;)c.shift().resolve({value:void 0,done:!0})}let u=o.connect(`changed`,(e,t,n,r)=>{let i=gioEventToNodeType(r);i!==null&&enqueue({eventType:i,filename:t?.get_basename()??null})}),abortHandler=()=>terminate();n?.addEventListener(`abort`,abortHandler);try{for(;!l;){if(s.length>0){yield s.shift();continue}let e=await new Promise(e=>{c.push({resolve:e})});if(e.done)break;yield e.value}}finally{n?.removeEventListener(`abort`,abortHandler);try{o.disconnect(u)}catch{}a.is_cancelled()||a.cancel()}}var eu,FSWatcher,tu=__esmMin(()=>{$l(),A(),N(),bn(),eu=new WeakMap,FSWatcher=class extends Y{constructor(e,t,n){super(),(!t||typeof t!=`object`)&&(t={persistent:!0});let r=t.persistent!==!1,i=M.Cancellable.new(),a=normalizePath(e),o=M.File.new_for_path(a).monitor(M.FileMonitorFlags.NONE,i);o.connect(`changed`,changed.bind(this));let s=null;r&&(s=k.timeout_add(k.PRIORITY_LOW,2147483647,()=>k.SOURCE_CONTINUE)),eu.set(this,{persistent:r,cancellable:i,sourceId:s,watcher:o}),n&&this.on(`change`,n)}close(){let e=eu.get(this);e.cancellable.is_cancelled()||(e.cancellable.cancel(),e.sourceId!==null&&(k.source_remove(e.sourceId),e.sourceId=null))}ref(){let e=eu.get(this);return!e.persistent&&!e.cancellable.is_cancelled()&&(e.persistent=!0,e.sourceId=k.timeout_add(k.PRIORITY_LOW,2147483647,()=>k.SOURCE_CONTINUE)),this}unref(){let e=eu.get(this);return e.persistent&&(e.persistent=!1,e.sourceId!==null&&(k.source_remove(e.sourceId),e.sourceId=null)),this}}});function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}function watchFile(e,t,n){typeof t==`function`&&(n=t,t={});let r=t.interval??5007,i=e.toString(),a=nu.get(i);return a||(a=new StatWatcher(i,r),a.start(),nu.set(i,a)),n&&a.addChangeListener(n),a}function unwatchFile(e,t){let n=e.toString(),r=nu.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),nu.delete(n)))}var StatWatcher,nu,ru=__esmMin(()=>{Ql(),bn(),StatWatcher=class extends Y{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=statSync(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=statSync(this._path)}catch{e=zeroedStat()}let t=this._prev;(e.mtimeMs!==t.mtimeMs||e.size!==t.size||e.ino!==t.ino)&&(this._prev=e,this.emit(`change`,e,t))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}},nu=new Map}),iu=__exportAll$4({BigIntStats:()=>BigIntStats,Dir:()=>Dir,Dirent:()=>Dirent,FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,Stats:()=>Stats,WriteStream:()=>WriteStream,access:()=>access,accessSync:()=>accessSync,appendFile:()=>appendFile,appendFileSync:()=>appendFileSync,chmod:()=>chmod,chmodSync:()=>chmodSync,chown:()=>chown,chownSync:()=>chownSync,close:()=>close,closeSync:()=>closeSync,constants:()=>au,copyFile:()=>copyFile,copyFileSync:()=>copyFileSync,cp:()=>cp,cpSync:()=>cpSync,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,default:()=>ou,exists:()=>exists,existsSync:()=>existsSync,fchmod:()=>fchmod,fchmodSync:()=>fchmodSync,fchown:()=>fchown,fchownSync:()=>fchownSync,fdatasync:()=>fdatasync,fdatasyncSync:()=>fdatasyncSync,fstat:()=>fstat,fstatSync:()=>fstatSync,fsync:()=>fsync,fsyncSync:()=>fsyncSync,ftruncate:()=>ftruncate,ftruncateSync:()=>ftruncateSync,futimes:()=>futimes,futimesSync:()=>futimesSync,glob:()=>glob,globSync:()=>globSync,lchmod:()=>lchmod,lchmodSync:()=>lchmodSync,lchown:()=>lchown,lchownSync:()=>lchownSync,link:()=>link,linkSync:()=>linkSync,lstat:()=>lstat,lstatSync:()=>lstatSync,lutimes:()=>lutimes,lutimesSync:()=>lutimesSync,mkdir:()=>mkdir,mkdirSync:()=>mkdirSync,mkdtempSync:()=>mkdtempSync,open:()=>open,openAsBlob:()=>openAsBlob,openSync:()=>openSync,opendir:()=>opendir,opendirSync:()=>opendirSync,promises:()=>Rl,read:()=>read,readFile:()=>readFile,readFileSync:()=>readFileSync,readSync:()=>readSync,readdir:()=>readdir,readdirSync:()=>readdirSync,readlink:()=>readlink,readlinkSync:()=>readlinkSync,readv:()=>readv,readvSync:()=>readvSync,realpath:()=>realpath,realpathSync:()=>realpathSync,rename:()=>rename,renameSync:()=>renameSync,rm:()=>rm,rmSync:()=>rmSync,rmdir:()=>rmdir,rmdirSync:()=>rmdirSync,stat:()=>stat,statSync:()=>statSync,statfs:()=>statfs,statfsSync:()=>statfsSync,symlink:()=>symlink,symlinkSync:()=>symlinkSync,truncate:()=>truncate,truncateSync:()=>truncateSync,unlink:()=>unlink,unlinkSync:()=>unlinkSync,unwatchFile:()=>unwatchFile,utimes:()=>utimes,utimesSync:()=>utimesSync,watch:()=>watch,watchFile:()=>watchFile,write:()=>write,writeFile:()=>writeFile,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync,writev:()=>writev,writevSync:()=>writevSync}),au,ou,su=__esmMin(()=>{tu(),El(),Wl(),Cl(),Tl(),Ql(),Ol(),Al(),jl(),Pl(),Il(),Ll(),Bl(),Vl(),ru(),au={F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:64,O_EXCL:128,O_TRUNC:512,O_APPEND:1024,O_SYNC:1052672,O_NONBLOCK:2048,O_DIRECTORY:65536,O_NOFOLLOW:131072,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1},ou={FSWatcher,StatWatcher,Stats,BigIntStats,Dirent,Dir,constants:au,existsSync,readdirSync,readFileSync,writeFileSync,mkdirSync,rmdirSync,unlinkSync,mkdtempSync,rmSync,statSync,openSync,realpathSync,symlinkSync,lstatSync,renameSync,copyFileSync,accessSync,appendFileSync,readlinkSync,linkSync,truncateSync,chmodSync,chownSync,cpSync,opendirSync,globSync,glob,watch,watchFile,unwatchFile,statfsSync,statfs,utimesSync,utimes,lutimesSync,lutimes,lchownSync,lchown,lchmodSync,lchmod,fstatSync,fstat,ftruncateSync,ftruncate,fdatasyncSync,fdatasync,fsyncSync,fsync,fchmodSync,fchmod,fchownSync,fchown,futimesSync,futimes,closeSync,readSync,writeSync,readvSync,readv,writevSync,writev,exists,openAsBlob,createReadStream,ReadStream,createWriteStream,WriteStream,promises:Rl,open,close,read,write,rm,realpath,readdir,symlink,lstat,stat,rename,copyFile,cp,access,appendFile,readlink,truncate,chmod,chown,mkdir,rmdir,readFile,writeFile,unlink,link,opendir}}),cu=__commonJSMin(((e,t)=>{
191
+ `}t.exports=finalhandler;function finalhandler(e,t,i){var a=i||{},o=a.env||process.env.NODE_ENV||`development`,s=a.onerror;return function(i){var a,c,l;if(!i&&t.headersSent){n(`cannot 404 after headers sent`);return}if(i?(l=getErrorStatusCode(i),l===void 0?l=getResponseStatusCode(t):a=getErrorHeaders(i),c=getErrorMessage(i,l,o)):(l=404,c=`Cannot `+e.method+` `+r(getResourceName(e))),n(`default %s`,l),i&&s&&setImmediate(s,i,e,t),t.headersSent){n(`cannot %d after headers sent`,l),e.socket&&e.socket.destroy();return}send(e,t,l,a,c)}}function getErrorHeaders(e){if(!(!e.headers||typeof e.headers!=`object`))return{...e.headers}}function getErrorMessage(e,t,n){var r;return n!==`production`&&(r=e.stack,!r&&typeof e.toString==`function`&&(r=e.toString())),r||s.message[t]}function getErrorStatusCode(e){if(typeof e.status==`number`&&e.status>=400&&e.status<600)return e.status;if(typeof e.statusCode==`number`&&e.statusCode>=400&&e.statusCode<600)return e.statusCode}function getResourceName(e){try{return o.original(e).pathname}catch{return`resource`}}function getResponseStatusCode(e){var t=e.statusCode;return(typeof t!=`number`||t<400||t>599)&&(t=500),t}function send(e,t,n,r,i){function write(){var a=createHtmlDocument(i);t.statusCode=n,e.httpVersionMajor<2&&(t.statusMessage=s.message[n]),t.removeHeader(`Content-Encoding`),t.removeHeader(`Content-Language`),t.removeHeader(`Content-Range`);for(let[e,n]of Object.entries(r??{}))t.setHeader(e,n);if(t.setHeader(`Content-Security-Policy`,`default-src 'none'`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.setHeader(`Content-Type`,`text/html; charset=utf-8`),t.setHeader(`Content-Length`,Buffer.byteLength(a,`utf8`)),e.method===`HEAD`){t.end();return}t.end(a,`utf8`)}if(c(e)){write();return}e.unpipe(),a(e,write),e.resume()}})),bl,__exportAll,xl=__esmMin(()=>{bl=Object.defineProperty,__exportAll=(e,t)=>{let n={};for(var r in e)bl(n,r,{get:e[r],enumerable:!0});return t||bl(n,Symbol.toStringTag,{value:`Module`}),n}});function getEncodingFromOptions(e={encoding:null,flag:`r`},t=`utf8`){return e===null?t:typeof e==`string`?e:typeof e==`object`&&typeof e.encoding==`string`?e.encoding:t}function encodeUint8Array(e,t){return e===`buffer`?q.from(t):new TextDecoder(e).decode(t)}function decode(e,t){if(t){let n=new TextDecoder(t),r=new TextEncoder;return n.decode(r.encode(e))}else return e}var Sl=__esmMin(()=>{J()}),Dirent,Cl=__esmMin(()=>{N(),uo(),Dirent=class{name;parentPath;_isFile=!1;_isDirectory=!1;_isBlockDevice=!1;_isCharacterDevice=!1;_isSymbolicLink=!1;_isFIFO=!1;_isSocket=!1;_file;constructor(e,t,n){switch(t||=ro(e),this.name=t,this.parentPath=no(e),this._file=M.File.new_for_path(e),n??this._file.query_file_type(M.FileQueryInfoFlags.NONE,null)){case M.FileType.DIRECTORY:this._isDirectory=!0;break;case M.FileType.MOUNTABLE:break;case M.FileType.REGULAR:this._isFile=!0;break;case M.FileType.SYMBOLIC_LINK:case M.FileType.SHORTCUT:this._isSymbolicLink=!0;break;case M.FileType.SPECIAL:this._classifySpecialFile(e);break}}_classifySpecialFile(e){try{let t=M.File.new_for_path(e).query_info(`unix::mode`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_attribute_uint32(`unix::mode`);if(t===0)return;switch(t&61440){case 24576:this._isBlockDevice=!0;break;case 8192:this._isCharacterDevice=!0;break;case 49152:this._isSocket=!0;break;case 4096:this._isFIFO=!0;break}}catch{}}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isBlockDevice(){return this._isBlockDevice}isCharacterDevice(){return this._isCharacterDevice}isSymbolicLink(){return this._isSymbolicLink}isFIFO(){return this._isFIFO}isSocket(){return this._isSocket}}});function populateFromInfo(e){let t=e.get_attribute_uint64(`time::access`),n=e.get_attribute_uint32(`time::access-usec`)||0,r=e.get_attribute_uint64(`time::modified`),i=e.get_attribute_uint32(`time::modified-usec`)||0,a=e.get_attribute_uint64(`time::changed`),o=e.get_attribute_uint32(`time::changed-usec`)||0,s=e.get_attribute_uint64(`time::created`),c=e.get_attribute_uint32(`time::created-usec`)||0,l=t*1e3+n/1e3,u=r*1e3+i/1e3,d=a?a*1e3+o/1e3:u,p=s?s*1e3+c/1e3:d;return{dev:e.get_attribute_uint32(`unix::device`)||0,ino:Number(e.get_attribute_uint64(`unix::inode`)||0),mode:e.get_attribute_uint32(`unix::mode`)||0,nlink:e.get_attribute_uint32(`unix::nlink`)||0,uid:e.get_attribute_uint32(`unix::uid`)||0,gid:e.get_attribute_uint32(`unix::gid`)||0,rdev:e.get_attribute_uint32(`unix::rdev`)||0,size:Number(e.get_size()||0),blksize:e.get_attribute_uint32(`unix::block-size`)||4096,blocks:Number(e.get_attribute_uint64(`unix::blocks`)||0),atimeMs:l,mtimeMs:u,ctimeMs:d,birthtimeMs:p,atime:new Date(l),mtime:new Date(u),ctime:new Date(d),birthtime:new Date(p)}}var wl,Stats,BigIntStats,Tl=__esmMin(()=>{Cl(),N(),uo(),wl=`standard::*,time::*,unix::*`,Stats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof M.FileInfo?(r=e,i=t.toString(),n||=ro(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=ro(i),r=M.File.new_for_path(i).query_info(wl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type()),this._info=r;let a=populateFromInfo(r);this.dev=a.dev,this.ino=a.ino,this.mode=a.mode,this.nlink=a.nlink,this.uid=a.uid,this.gid=a.gid,this.rdev=a.rdev,this.size=a.size,this.blksize=a.blksize,this.blocks=a.blocks,this.atimeMs=a.atimeMs,this.mtimeMs=a.mtimeMs,this.ctimeMs=a.ctimeMs,this.birthtimeMs=a.birthtimeMs,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.birthtime=a.birthtime}},BigIntStats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atimeNs;mtimeNs;ctimeNs;birthtimeNs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof M.FileInfo?(r=e,i=t.toString(),n||=ro(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=ro(i),r=M.File.new_for_path(i).query_info(wl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type()),this._info=r;let a=populateFromInfo(r);this.dev=BigInt(a.dev),this.ino=BigInt(a.ino),this.mode=BigInt(a.mode),this.nlink=BigInt(a.nlink),this.uid=BigInt(a.uid),this.gid=BigInt(a.gid),this.rdev=BigInt(a.rdev),this.size=BigInt(a.size),this.blksize=BigInt(a.blksize),this.blocks=BigInt(a.blocks),this.atimeMs=BigInt(Math.trunc(a.atimeMs)),this.mtimeMs=BigInt(Math.trunc(a.mtimeMs)),this.ctimeMs=BigInt(Math.trunc(a.ctimeMs)),this.birthtimeMs=BigInt(Math.trunc(a.birthtimeMs)),this.atimeNs=this.atimeMs*1000000n,this.mtimeNs=this.mtimeMs*1000000n,this.ctimeNs=this.ctimeMs*1000000n,this.birthtimeNs=this.birthtimeMs*1000000n,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.birthtime=a.birthtime}}});function createReadStream(e,t){return new ReadStream(e,t)}var ReadStream,El=__esmMin(()=>{$l(),A(),N(),J(),Kr(),ReadStream=class extends Br{bytesRead=0;path;pending=!0;fd=null;_gioFile;_inputStream=null;_cancellable=new M.Cancellable;_start;_end;_pos;close(e){this._cancellable.cancel(),this._inputStream&&=(this._inputStream.close_async(k.PRIORITY_DEFAULT,null,()=>{}),null),this.destroy(),e&&e(null)}constructor(e,t){let n=normalizePath(e);super({highWaterMark:t?.highWaterMark??64*1024,encoding:t?.encoding,objectMode:!1}),this.path=n,this._gioFile=M.File.new_for_path(n),this._start=t?.start??0,this._end=t?.end??1/0,this._pos=this._start}_construct(e){this._gioFile.read_async(k.PRIORITY_DEFAULT,this._cancellable,(t,n)=>{if(this.destroyed){e();return}try{this._inputStream=this._gioFile.read_finish(n),this.pending=!1,this.emit(`open`,0),this.emit(`ready`),this._start>0&&this._inputStream.can_seek()&&this._inputStream.seek(this._start,k.SeekType.SET,null),e()}catch(t){this._cancellable.is_cancelled()||e(t)}})}_read(e){this._doRead(e)}_doRead(e){let t=e;if(this._end!==1/0){let n=this._end-this._pos+1;if(n<=0){this.push(null);return}t=Math.min(e,n)}let n=this._inputStream;n.read_bytes_async(t,k.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{try{let e=n.read_bytes_finish(t).get_data();if(!e||e.length===0){this.push(null);return}this.bytesRead+=e.length,this._pos+=e.length,this.push(q.from(e))}catch(e){this._cancellable.is_cancelled()||this.destroy(e)}})}_destroy(e,t){this._cancellable.cancel(),this._inputStream&&=(this._inputStream.close_async(k.PRIORITY_DEFAULT,null,()=>{}),null),t(e)}}});function createNodeError(e,t,n,r){return createNodeError$1(e,t,{path:n.toString(),dest:r?.toString()})}var Dl=__esmMin(()=>{L()});function makeEEXIST(e){let t=Error(`ERR_FS_CP_EEXIST: file already exists, copyfile '${e}'`);return t.code=`ERR_FS_CP_EEXIST`,t.syscall=`copyfile`,t.path=e,t}function makeEISDIR(e){let t=Error(`ERR_FS_EISDIR: illegal operation on a directory, copyfile '${e}'`);return t.code=`ERR_FS_EISDIR`,t.syscall=`copyfile`,t.path=e,t}function makeENOTDIR(e,t){let n=Error(`ENOTDIR: not a directory, copyfile '${e}' -> '${t}'`);return n.code=`ENOTDIR`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function makeSYMLINKLOOP(e,t){let n=Error(`ELOOP: too many levels of symbolic links, copyfile '${e}' -> '${t}'`);return n.code=`ELOOP`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function queryCopyFlags(e){let t=e.force??!0,n=M.FileCopyFlags.NONE;return t&&(n|=M.FileCopyFlags.OVERWRITE),e.preserveTimestamps&&(n|=M.FileCopyFlags.TARGET_DEFAULT_MODIFIED_TIME),e.dereference||(n|=M.FileCopyFlags.NOFOLLOW_SYMLINKS),n}function copyOneSyncFile(e,t,n,r,i){let a=i.force??!0;try{if(t.query_info(`standard::type`,M.FileQueryInfoFlags.NONE,null).get_file_type()===M.FileType.DIRECTORY)throw makeENOTDIR(n,r);if(!a){if(i.errorOnExist)throw makeEEXIST(r);return}}catch(e){if(typeof e.code==`string`)throw e}let o=queryCopyFlags(i);try{e.copy(t,o,null,null)}catch(e){throw createNodeError(e,`copyfile`,n,r)}}function cpOneDirSync(e,t,n,r,i){let a=n.endsWith(`/`)?``:`/`;if(r.startsWith(n+a)&&r!==n)throw makeSYMLINKLOOP(n,r);if(t.query_exists(null))try{if(t.query_info(`standard::type`,M.FileQueryInfoFlags.NONE,null).get_file_type()!==M.FileType.DIRECTORY)throw makeENOTDIR(r,n)}catch(e){if(typeof e.code==`string`)throw e}else try{t.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,r)}let o;try{o=e.enumerate_children(`standard::name,standard::type,standard::is-symlink`,i.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`scandir`,n)}let s=o.next_file(null);for(;s!==null;){let e=s.get_name(),t=$a(n,e),a=$a(r,e),c=i.filter;if(c&&!c(t,a)){s=o.next_file(null);continue}cpSyncInternal(t,a,i),s=o.next_file(null)}}function cpSyncInternal(e,t,n){let r=M.File.new_for_path(e),i=M.File.new_for_path(t),a;try{a=r.query_info(`standard::type,standard::is-symlink`,n.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`stat`,e)}if(a.get_file_type()===M.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(e);cpOneDirSync(r,i,e,t,n)}else copyOneSyncFile(r,i,e,t,n)}function cpSync(e,t,n){let r=normalizePath(e),i=normalizePath(t),a=n??{},o=M.File.new_for_path(r),s=a.filter;if(!(s&&!s(r,i))){try{if(o.query_info(`standard::type`,a.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_file_type()===M.FileType.DIRECTORY&&!a.recursive)throw makeEISDIR(r)}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`stat`,r)}cpSyncInternal(r,i,a)}}function cp(e,t,n,r){let i,a;typeof n==`function`?(a=n,i={}):(a=r,i=n);let o=i.filter;if(o){Promise.resolve(o(normalizePath(e),normalizePath(t))).then(n=>{if(!n){a(null);return}try{cpPromises(e,t,i).then(()=>a(null)).catch(a)}catch(e){a(e)}}).catch(a);return}Promise.resolve().then(()=>{try{cpSync(e,t,i),a(null)}catch(e){a(e)}})}async function cpPromisesDir(e,t,n){let r=e.endsWith(`/`)?``:`/`;if(t.startsWith(e+r)&&t!==e)throw makeSYMLINKLOOP(e,t);let i=M.File.new_for_path(t);if(!i.query_exists(null))try{i.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,t)}let a=M.File.new_for_path(e),o;try{o=a.enumerate_children(`standard::name,standard::type`,n.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`scandir`,e)}let s=o.next_file(null);for(;s!==null;){let r=s.get_name(),i=$a(e,r),a=$a(t,r),c=n.filter;if(c&&!await Promise.resolve(c(i,a))){s=o.next_file(null);continue}await cpPromises(i,a,n),s=o.next_file(null)}}async function cpPromises(e,t,n={}){let r=normalizePath(e),i=normalizePath(t),a=M.File.new_for_path(r),o;try{o=a.query_info(`standard::type`,n.dereference?M.FileQueryInfoFlags.NONE:M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`stat`,r)}if(o.get_file_type()===M.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(r);await cpPromisesDir(r,i,n)}else copyOneSyncFile(a,M.File.new_for_path(i),r,i,n)}var Ol=__esmMin(()=>{$l(),Dl(),N(),uo()});function _openDir(e){let t=M.File.new_for_path(e),n;try{n=t.enumerate_children(kl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`opendir`,e)}return new Dir(e,n)}function opendirSync(e){return _openDir(normalizePath(e))}function opendir(e,t,n){let r;if(r=typeof t==`function`?t:n,typeof r!=`function`)throw TypeError(`The "callback" argument must be of type function`);Promise.resolve().then(()=>{try{let t=opendirSync(e);r(null,t)}catch(e){r(e,null)}})}async function opendirAsync(e,t){return new Promise((t,n)=>{let r=normalizePath(e),i=M.File.new_for_path(r);i.enumerate_children_async(kl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,k.PRIORITY_DEFAULT,null,(e,a)=>{try{t(new Dir(r,i.enumerate_children_finish(a)))}catch(e){n(createNodeError(e,`opendir`,r))}})})}var kl,Dir,Al=__esmMin(()=>{$l(),Cl(),Dl(),A(),N(),kl=`standard::name,standard::type,standard::is-symlink,standard::size,standard::symlink-target,unix::uid,unix::gid,unix::mode,time::modified,time::access,time::created`,Dir=class{path;_enumerator;_closed=!1;constructor(e,t){this.path=e,this._enumerator=t}_assertOpen(){if(this._closed){let e=Error(`Directory handle was closed`);throw e.code=`ERR_DIR_CLOSED`,e}}readSync(){this._assertOpen();try{let e=this._enumerator.next_file(null);if(e===null)return null;let t=e.get_name(),n=e.get_file_type();return new Dirent(this.path.endsWith(`/`)?this.path+t:this.path+`/`+t,t,n)}catch(e){throw createNodeError(e,`readdir`,this.path)}}read(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this._assertOpen();let t=this.readSync();Promise.resolve().then(()=>e(null,t))}catch(t){Promise.resolve().then(()=>e(t,null))}return}return new Promise((e,t)=>{try{this._assertOpen(),e(this.readSync())}catch(e){t(e)}})}closeSync(){this._assertOpen(),this._closed=!0;try{this._enumerator.close(null)}catch{}this._enumerator=null}close(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this.closeSync(),Promise.resolve().then(()=>e(null))}catch(t){Promise.resolve().then(()=>e(t))}return}return new Promise((e,t)=>{try{this.closeSync(),e()}catch(e){t(e)}})}async*[Symbol.asyncIterator](){try{for(;;){let e=await this.read();if(e===null)break;yield e}}finally{this._closed||await this.close()}}}});function segmentToRegexSrc(e){let t=/^([!*+?@])\((.+)\)$/.exec(e);if(t){let[,e,n]=t,r=n.split(`|`).map(e=>segmentToRegexSrc(e)),i=`(?:`+r.join(`|`)+`)`;switch(e){case`!`:return`(?!(?:`+r.join(`|`)+`))[^/]*`;case`*`:return i+`*`;case`+`:return i+`+`;case`?`:return i+`?`;case`@`:return i}}let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`*`){n+=`[^/]*`,r++;continue}if(t===`?`){n+=`[^/]`,r++;continue}if(t===`[`){let t=e.indexOf(`]`,r+1);if(t===-1){n+=`\\[`,r++;continue}n+=e.slice(r,t+1),r=t+1;continue}if(t===`{`){let t=e.indexOf(`}`,r+1);if(t===-1){n+=`\\{`,r++;continue}let i=e.slice(r+1,t).split(`,`).map(e=>segmentToRegexSrc(e.trim()));n+=`(?:`+i.join(`|`)+`)`,r=t+1;continue}`.+^$|()[]{}`.includes(t)?n+=`\\`+t:n+=t,r++}return n}function globToRegex(e){e=e.replace(/\/+/g,`/`).replace(/^\.\//,``);let t=e.split(`/`),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=e===t.length-1;r===`**`?i?n.length>0&&n[n.length-1]===`/`?(n.pop(),n.push(`(?:/.+)?`)):n.push(`(?:.+)?`):n.push(`(?:[^/]+/)*`):(n.push(segmentToRegexSrc(r)),i||n.push(`/`))}return RegExp(`^(?:`+n.join(``)+`)$`)}function buildExcludePredicate(e){if(!e)return null;if(typeof e==`function`)return e;let t=(Array.isArray(e)?e:[e]).map(e=>globToRegex(e));return e=>t.some(t=>t.test(e))}function matchAll(e,t,n){let r=globToRegex(e),i=buildExcludePredicate(n),a;try{a=readdirSync(t,{recursive:!0})}catch{return[]}let o=[`.`,...a],s=[];for(let e of o){let t=e.replace(/\\/g,`/`);r.test(t)&&(i&&i(t)||s.push(e))}return s}function globSync(e,t){let n=Array.isArray(e)?e:[e],r=t?.cwd?normalizePath(t.cwd):globalThis.process?.cwd?.()??`/`,i=t?.exclude,a=new Set,o=[];for(let e of n)for(let t of matchAll(e,r,i))a.has(t)||(a.add(t),o.push(t));return o}function glob(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(i=n,r=t||{}),Promise.resolve().then(()=>{try{let t=globSync(e,r);i(null,t)}catch(e){i(e,[])}})}async function*globAsync(e,t){let n=globSync(e,t);for(let e of n)yield e}var jl=__esmMin(()=>{$l(),Ql()});function buildStatFs(e){let t=Number(e.get_attribute_uint64(`filesystem::size`)??0),n=Number(e.get_attribute_uint64(`filesystem::free`)??0),r=Math.floor(t/Nl),i=Math.floor(n/Nl);return{type:0,bsize:Nl,blocks:r,bfree:i,bavail:i,files:0,ffree:0}}function buildBigIntStatFs(e){let t=BigInt(e.get_attribute_uint64(`filesystem::size`)??0),n=BigInt(e.get_attribute_uint64(`filesystem::free`)??0),r=BigInt(Nl),i=t/r,a=n/r;return{type:0n,bsize:r,blocks:i,bfree:a,bavail:a,files:0n,ffree:0n}}function statfsSync(e,t){let n=M.File.new_for_path(normalizePath(e)).query_filesystem_info(Ml,null);return t?.bigint===!0?buildBigIntStatFs(n):buildStatFs(n)}function queryFsInfoAsync(e,t){return new Promise((n,r)=>{let i=M.File.new_for_path(normalizePath(e));i.query_filesystem_info_async(Ml,k.PRIORITY_DEFAULT,null,(e,a)=>{try{let e=i.query_filesystem_info_finish(a);n(t?buildBigIntStatFs(e):buildStatFs(e))}catch(e){r(e)}})})}function statfs(e,t,n){let r=typeof t==`function`?t:n;queryFsInfoAsync(e,(typeof t==`function`?{}:t)?.bigint===!0).then(e=>r(null,e),e=>r(e,null))}async function statfsAsync(e,t){return queryFsInfoAsync(e,t?.bigint===!0)}var Ml,Nl,Pl=__esmMin(()=>{$l(),A(),N(),Ml=[`filesystem::size`,`filesystem::free`].join(`,`),Nl=4096}),Fl=__exportAll$4({lchmod:()=>lchmod,lchmodAsync:()=>lchmodAsync,lchmodSync:()=>lchmodSync,lchown:()=>lchown,lchownAsync:()=>lchownAsync,lchownSync:()=>lchownSync,lutimes:()=>lutimes,lutimesAsync:()=>lutimesAsync,lutimesSync:()=>lutimesSync,utimes:()=>utimes,utimesAsync:()=>utimesAsync,utimesSync:()=>utimesSync});function toGLibDateTime(e){let t=e instanceof Date?e.getTime():typeof e==`bigint`?Number(e):typeof e==`string`?Date.parse(e):e*1e3;return k.DateTime.new_from_unix_utc(Math.floor(t/1e3))}function setTimestamps(e,t,n,r){let i=M.File.new_for_path(e),a=new M.FileInfo;a.set_modification_date_time(toGLibDateTime(n)),a.set_access_date_time(toGLibDateTime(t)),i.set_attributes_from_info(a,r,null)}function utimesSync(e,t,n){setTimestamps(normalizePath(e),t,n,M.FileQueryInfoFlags.NONE)}function utimes(e,t,n,r){Promise.resolve().then(()=>utimesSync(e,t,n)).then(()=>r(null),r)}async function utimesAsync(e,t,n){utimesSync(e,t,n)}function lutimesSync(e,t,n){setTimestamps(normalizePath(e),t,n,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS)}function lutimes(e,t,n,r){Promise.resolve().then(()=>lutimesSync(e,t,n)).then(()=>r(null),r)}async function lutimesAsync(e,t,n){lutimesSync(e,t,n)}function lchownSync(e,t,n){k.spawn_command_line_sync(`chown -h ${t}:${n} ${normalizePath(e)}`)}function lchown(e,t,n,r){Promise.resolve().then(()=>lchownSync(e,t,n)).then(()=>r(null),r)}async function lchownAsync(e,t,n){lchownSync(e,t,n)}function lchmodSync(e,t){}function lchmod(e,t,n){n(null)}async function lchmodAsync(e,t){}var Il=__esmMin(()=>{$l(),A(),N()});function getFH(e){return e instanceof Xl?Xl.getInstance(e.fd):Xl.getInstance(e)}function fstatSync(e,t){return statSync(normalizePath(getFH(e).options.path),t)}function fstat(e,t,n){let r=typeof t==`function`?t:n;fstatAsync(e,typeof t==`function`?{}:t).then(e=>r(null,e),e=>r(e,void 0))}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){truncateSync(normalizePath(getFH(e).options.path),t)}function ftruncate(e,t,n){let r=typeof t==`function`?t:n;ftruncateAsync(e,typeof t==`function`?0:t).then(()=>r(null),r)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e)._flushSync()}function fdatasync(e,t){Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>t(null),t)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e)._flushSync()}function fsync(e,t){Promise.resolve().then(()=>fsyncSync(e)).then(()=>t(null),t)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){chmodSync(normalizePath(getFH(e).options.path),t)}function fchmod(e,t,n){Promise.resolve().then(()=>fchmodSync(e,t)).then(()=>n(null),n)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(e,t,n){chownSync(normalizePath(getFH(e).options.path),t,n)}function fchown(e,t,n,r){Promise.resolve().then(()=>fchownSync(e,t,n)).then(()=>r(null),r)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(e,t,n){utimesSync(normalizePath(getFH(e).options.path),t,n)}function futimes(e,t,n,r){Promise.resolve().then(()=>futimesSync(e,t,n)).then(()=>r(null),r)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){getFH(e)._closeSync()}function readSync(e,t,n,r,i){let a=0;return typeof n==`object`&&n?(a=n.offset??0,r=n.length??t.byteLength,i=n.position??null):(a=n??0,r??=t.byteLength-a),getFH(e)._readSync(t,a,r,i??null)}function writeSync(e,t,n,r,i){let a;if(typeof t==`string`)a=new TextEncoder().encode(t),typeof n==`number`&&(i=n);else{let e=typeof n==`number`?n:0,i=typeof r==`number`?r:t.byteLength-e;a=new Uint8Array(t.buffer,t.byteOffset+e,i)}return getFH(e)._writeSync(a,i??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,t,n,r){let i=typeof n==`function`?n:r;readvAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesRead,e.buffers),e=>i(e,0,t))}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,t,n,r){let i=typeof n==`function`?n:r;writevAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesWritten,e.buffers),e=>i(e,0,t))}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(e,t){try{statSync(normalizePath(e)),t(!0)}catch{t(!1)}}async function openAsBlob(e,t){let n=readFileSync(normalizePath(e));return new Blob([n],{type:t?.type??``})}var Ll=__esmMin(()=>{$l(),Zl(),Ql(),Il()});async function mkdir$1(e,t){let n;typeof t==`object`&&(t.recursive&&(n=t.recursive),t.mode&&t.mode);let r=normalizePath(e);if(n)return mkdirRecursiveAsync(r);let i=M.File.new_for_path(r);return new Promise((e,t)=>{i.make_directory_async(k.PRIORITY_DEFAULT,null,(n,a)=>{try{i.make_directory_finish(a),e(void 0)}catch(e){t(createNodeError(e,`mkdir`,r))}})})}async function mkdirRecursiveAsync(e){let t=M.File.new_for_path(e);try{return await new Promise((e,n)=>{t.make_directory_async(k.PRIORITY_DEFAULT,null,(r,i)=>{try{t.make_directory_finish(i),e()}catch(e){n(e)}})}),e}catch(t){let n=t;if(n.code===M.IOErrorEnum.EXISTS)return;if(n.code===M.IOErrorEnum.NOT_FOUND){let n=no(e);if(n===e)throw createNodeError(t,`mkdir`,e);let r=await mkdirRecursiveAsync(n),i=M.File.new_for_path(e);return await new Promise((t,n)=>{i.make_directory_async(k.PRIORITY_DEFAULT,null,(r,a)=>{try{i.make_directory_finish(a),t()}catch(t){n(createNodeError(t,`mkdir`,e))}})}),r??e}throw createNodeError(t,`mkdir`,e)}}async function readFile$1(e,t={encoding:null,flag:`r`}){let n=normalizePath(e),r=M.File.new_for_path(n),i,a;try{[i,a]=await new Promise((e,t)=>{r.load_contents_async(null,(n,i)=>{try{e(r.load_contents_finish(i))}catch(e){t(e)}})})}catch(e){throw createNodeError(e,`open`,n)}if(!i)throw createNodeError(Error(`failed to read file`),`open`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),a)}async function mkdtemp(e,t){let n=getEncodingFromOptions(t),r=tempDirPath(e);return await mkdir$1(r,{recursive:!1,mode:448}),decode(r,n)}async function writeFile$1(e,t){let n=normalizePath(e),r=M.File.new_for_path(n),i;i=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?t:new TextEncoder().encode(String(t));let a=await new Promise((e,t)=>{r.replace_async(null,!1,M.FileCreateFlags.REPLACE_DESTINATION,k.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.replace_finish(a))}catch(e){t(createNodeError(e,`open`,n))}})});if(i.length>0){let e=new k.Bytes(i);await new Promise((t,r)=>{a.write_bytes_async(e,k.PRIORITY_DEFAULT,null,(e,i)=>{try{a.write_bytes_finish(i),t()}catch(e){r(createNodeError(e,`write`,n))}})})}await new Promise((e,t)=>{a.close_async(k.PRIORITY_DEFAULT,null,(r,i)=>{try{a.close_finish(i),e()}catch(e){t(createNodeError(e,`close`,n))}})})}async function rmdir$1(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);if((await new Promise((e,t)=>{r.query_info_async(`standard::type`,M.FileQueryInfoFlags.NONE,k.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.query_info_finish(a))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).get_file_type()!==M.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if((await new Promise((e,t)=>{r.enumerate_children_async(`standard::name`,M.FileQueryInfoFlags.NONE,k.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.enumerate_children_finish(a))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(k.PRIORITY_DEFAULT,null,(i,a)=>{try{r.delete_finish(a),e()}catch(e){t(createNodeError(e,`rmdir`,n))}})})}async function unlink$1(e){let t=normalizePath(e),n=M.File.new_for_path(t);await new Promise((e,r)=>{n.delete_async(k.PRIORITY_DEFAULT,null,(i,a)=>{try{n.delete_finish(a),e()}catch(e){r(createNodeError(e,`unlink`,t))}})})}async function open$1(e,t,n){return new Xl({path:e,flags:t,mode:n})}async function write$1(e,t,n,r,i){return typeof t==`string`?_writeStr(e,t,n,r):_writeBuf(e,t,n,r,i)}async function _writeBuf(e,t,n,r,i){return{bytesWritten:(await Xl.getInstance(e).write(t,n,r,i)).bytesWritten,buffer:t}}async function _writeStr(e,t,n,r){return{bytesWritten:(await Xl.getInstance(e).write(t,n,r)).bytesWritten,buffer:t}}function queryInfoAsync(e,t,n,r){let i=normalizePath(e);return new Promise((e,a)=>{let o=M.File.new_for_path(i);o.query_info_async(wl,t,k.PRIORITY_DEFAULT,null,(t,s)=>{try{let t=o.query_info_finish(s);e(r?.bigint?new BigIntStats(t,i):new Stats(t,i))}catch(e){a(createNodeError(e,n,i))}})})}async function stat$1(e,t){return queryInfoAsync(e,M.FileQueryInfoFlags.NONE,`stat`,t)}async function lstat$1(e,t){return queryInfoAsync(e,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,t)}async function readdir$1(e,t){try{return readdirSync(e,t)}catch(t){throw createNodeError(t,`scandir`,e)}}async function realpath$1(e){return realpathSync(e)}async function symlink$1(e,t,n){let r=normalizePath(t),i=normalizePath(e);return new Promise((e,t)=>{let n=M.File.new_for_path(r);n.make_symbolic_link_async(i,k.PRIORITY_DEFAULT,null,(a,o)=>{try{n.make_symbolic_link_finish(o),e()}catch(e){t(createNodeError(e,`symlink`,i,r))}})})}async function rm$1(e,t){let n=normalizePath(e),r=M.File.new_for_path(n),i=t?.recursive||!1,a=t?.force||!1,o;try{o=new Dirent(n)}catch(t){if(a)return;throw createNodeError(t,`rm`,e)}if(o.isDirectory()){let r=await readdir$1(e,{withFileTypes:!0});if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)typeof e!=`string`&&await rm$1($a(n,e.name),t)}await new Promise((t,n)=>{r.delete_async(k.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(a){t();return}n(createNodeError(r,`rm`,e))}})})}async function rename$1(e,t){renameSync(e,t)}async function copyFile$1(e,t,n){copyFileSync(e,t,n)}async function access$1(e,t){accessSync(e,t)}async function appendFile$1(e,t,n){appendFileSync(e,t,n)}async function readlink$1(e,t){return readlinkSync(e,t)}async function truncate$1(e,t){truncateSync(e,t)}async function chmod$1(e,t){chmodSync(e,t)}async function chown$1(e,t,n){chownSync(e,t,n)}async function link$1(e,t){linkSync(e,t)}var Rl,zl,Bl=__esmMin(()=>{xl(),Sl(),$l(),tu(),Cl(),Tl(),Zl(),Dl(),Ql(),Ol(),Al(),jl(),Pl(),Il(),Ll(),A(),N(),uo(),Rl=__exportAll({access:()=>access$1,appendFile:()=>appendFile$1,chmod:()=>chmod$1,chown:()=>chown$1,copyFile:()=>copyFile$1,cp:()=>cpPromises,default:()=>zl,fchmod:()=>fchmodAsync,fchown:()=>fchownAsync,fdatasync:()=>fdatasyncAsync,fstat:()=>fstatAsync,fsync:()=>fsyncAsync,ftruncate:()=>ftruncateAsync,futimes:()=>futimesAsync,glob:()=>globAsync,lchmod:()=>lchmodAsync,lchown:()=>lchownAsync,link:()=>link$1,lstat:()=>lstat$1,lutimes:()=>lutimesAsync,mkdir:()=>mkdir$1,mkdtemp:()=>mkdtemp,open:()=>open$1,openAsBlob:()=>openAsBlob,opendir:()=>opendirAsync,readFile:()=>readFile$1,readdir:()=>readdir$1,readlink:()=>readlink$1,readv:()=>readvAsync,realpath:()=>realpath$1,rename:()=>rename$1,rm:()=>rm$1,rmdir:()=>rmdir$1,stat:()=>stat$1,statfs:()=>statfsAsync,symlink:()=>symlink$1,truncate:()=>truncate$1,unlink:()=>unlink$1,utimes:()=>utimesAsync,watch:()=>watchAsync,write:()=>write$1,writeFile:()=>writeFile$1,writev:()=>writevAsync}),__name(mkdir$1,`mkdir`),__name(readFile$1,`readFile`),__name(writeFile$1,`writeFile`),__name(rmdir$1,`rmdir`),__name(unlink$1,`unlink`),__name(open$1,`open`),__name(write$1,`write`),__name(stat$1,`stat`),__name(lstat$1,`lstat`),__name(readdir$1,`readdir`),__name(realpath$1,`realpath`),__name(symlink$1,`symlink`),__name(rm$1,`rm`),__name(rename$1,`rename`),__name(copyFile$1,`copyFile`),__name(access$1,`access`),__name(appendFile$1,`appendFile`),__name(readlink$1,`readlink`),__name(truncate$1,`truncate`),__name(chmod$1,`chmod`),__name(chown$1,`chown`),__name(link$1,`link`),zl={readFile:readFile$1,mkdir:mkdir$1,mkdtemp,realpath:realpath$1,readdir:readdir$1,writeFile:writeFile$1,rmdir:rmdir$1,unlink:unlink$1,open:open$1,write:write$1,rm:rm$1,lstat:lstat$1,symlink:symlink$1,stat:stat$1,rename:rename$1,copyFile:copyFile$1,access:access$1,appendFile:appendFile$1,readlink:readlink$1,truncate:truncate$1,chmod:chmod$1,chown:chown$1,link:link$1,cp:cpPromises,opendir:opendirAsync,glob:globAsync,watch:watchAsync,statfs:statfsAsync,utimes:utimesAsync,lutimes:lutimesAsync,lchown:lchownAsync,lchmod:lchmodAsync,fstat:fstatAsync,ftruncate:ftruncateAsync,fdatasync:fdatasyncAsync,fsync:fsyncAsync,fchmod:fchmodAsync,fchown:fchownAsync,futimes:futimesAsync,readv:readvAsync,writev:writevAsync,openAsBlob}});function parseOptsCb(e,t){return typeof e==`function`?{options:{},callback:e}:{options:e??{},callback:t}}function statImpl(e,t,n,r,i){let a=normalizePath(e),o=M.File.new_for_path(a);o.query_info_async(wl,t,k.PRIORITY_DEFAULT,null,(e,t)=>{try{let e=o.query_info_finish(t);i(null,r?.bigint?new BigIntStats(e,a):new Stats(e,a))}catch(e){i(createNodeError(e,n,a))}})}function stat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,M.FileQueryInfoFlags.NONE,`stat`,r,i)}function lstat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,r,i)}function readdir(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{i(null,readdirSync(e,r))}catch(t){i(createNodeError(t,`readdir`,e))}})}function realpath(e,t,n){let{callback:r}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{r(null,realpathSync(e))}catch(e){r(e)}})}function symlink(e,t,n,r){let i=typeof n==`function`?n:r;if(typeof i!=`function`)throw TypeError(`Callback must be a function. Received `+typeof i);let a=normalizePath(t),o=normalizePath(e),s=M.File.new_for_path(a);s.make_symbolic_link_async(o,k.PRIORITY_DEFAULT,null,(e,t)=>{try{s.make_symbolic_link_finish(t),i(null)}catch(e){i(createNodeError(e,`symlink`,o,a))}})}function open(e,...t){let n,r,i;switch(t.length){case 1:i=t[0];break;case 2:n=t[0],i=t[1];break;case 3:n=t[0],r=t[1],i=t[2];break;default:break}open$1(e,n,r).then(e=>{i(null,e.fd)}).catch(e=>{i(e,-1)})}function write(e,t,...n){let r=Xl.getInstance(e);if(typeof t==`string`){let e=n.pop(),i=n[0],a=n[1];r.write(t,i,a).then(t=>{e(null,t.bytesWritten,t.buffer)}).catch(t=>{e(t,0,``)});return}let i=n[n.length-1],a=n[0],o=n[1],s=n[2];r.write(t,a,o,s).then(e=>{i(null,e.bytesWritten,e.buffer)}).catch(e=>{i(e,0,q.from([]))})}function read(e,...t){let n=Xl.getInstance(e),r=t[t.length-1],i,a,o,s;if(!(t.length<=1))if(typeof t[0]==`object`&&!ArrayBuffer.isView(t[0])){let e=t[0];i=e.buffer,a=e.offset,o=e.length,s=e.position}else i=t[0],a=t[1],o=t[2],s=t[3];n.read(i,a,o,s).then(e=>{r(null,e.bytesRead,e.buffer)}).catch(e=>{r(e,0,q.from([]))})}function close(e,t){Xl.getInstance(e).close().then(()=>{t(null)}).catch(e=>t(e))}function rm(e,...t){let n={},r=t[t.length-1];t.length>=2&&(n=t[0]),rm$1(e,n).then(()=>{r(null)}).catch(e=>{r(e)})}function rename(e,t,n){Promise.resolve().then(()=>{try{renameSync(e,t),n(null)}catch(e){n(e)}})}function copyFile(e,t,n,r){let i=typeof n==`function`?0:n,a=typeof n==`function`?n:r;Promise.resolve().then(()=>{try{copyFileSync(e,t,i),a(null)}catch(e){a(e)}})}function access(e,t,n){let r=typeof t==`function`?void 0:t,i=typeof t==`function`?t:n;Promise.resolve().then(()=>{try{accessSync(e,r),i(null)}catch(e){i(e)}})}function appendFile(e,t,n,r){let i=typeof n==`function`?n:r,a=typeof n==`function`?void 0:n;Promise.resolve().then(()=>{try{appendFileSync(e,t,a),i(null)}catch(e){i(e)}})}function readlink(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{r(null,readlinkSync(e,i))}catch(e){r(e,``)}})}function truncate(e,t,n){let r=typeof t==`function`?0:t,i=typeof t==`function`?t:n;Promise.resolve().then(()=>{try{truncateSync(e,r),i(null)}catch(e){i(e)}})}function chmod(e,t,n){Promise.resolve().then(()=>{try{chmodSync(e,t),n(null)}catch(e){n(e)}})}function chown(e,t,n,r){Promise.resolve().then(()=>{try{chownSync(e,t,n),r(null)}catch(e){r(e)}})}function mkdir(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{mkdirSync(e,i),r(null)}catch(e){r(e)}})}function rmdir(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{rmdirSync(e,i),r(null)}catch(e){r(e)}})}function readFile(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t,a=normalizePath(e);Promise.resolve().then(()=>{try{r(null,readFileSync(a,typeof i==`string`?{encoding:i,flag:`r`}:{encoding:i?.encoding??null,flag:i?.flag??`r`}))}catch(e){r(e,null)}})}function writeFile(e,t,n,r){let i=typeof n==`function`?n:r,a=normalizePath(e);Promise.resolve().then(()=>{try{writeFileSync(a,t),i(null)}catch(e){i(e)}})}function link(e,t,n){let r=normalizePath(e),i=normalizePath(t);Promise.resolve().then(()=>{try{if(!k.spawn_command_line_sync(`ln ${r} ${i}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, link '${r}' -> '${i}'`),{code:`EPERM`,errno:-1,syscall:`link`,path:r,dest:i});n(null)}catch(e){n(e)}})}function unlink(e,t){let n=normalizePath(e);Promise.resolve().then(()=>{try{k.unlink(n),t(null)}catch(e){t(e)}})}var Vl=__esmMin(()=>{$l(),Tl(),Zl(),Dl(),Ql(),Bl(),A(),N(),J()});function toPathIfFileURL(e){return normalizePath(e)}function createWriteStream(e,t){return new WriteStream(e,t)}var Hl,Ul,WriteStream,Wl=__esmMin(()=>{$l(),Vl(),Kr(),Hl=Symbol(`kIsPerformingIO`),Ul=Symbol(`kIoDone`),WriteStream=class extends Vr{close(e,t=null){this.fd?(close(this.fd,n=>{e(n||t)}),this.fd=null):e(t)}bytesWritten=0;path;pending;fd=null;flags=`w`;mode=438;pos=0;[Hl]=!1;constructor(e,t={}){super(t),this.path=toPathIfFileURL(e),t.encoding&&this.setDefaultEncoding(t.encoding)}_construct(e){open(this.path.toString(),this.flags,this.mode,(t,n)=>{if(t){e(t);return}this.fd=n,e(),this.emit(`open`,this.fd),this.emit(`ready`)})}_write(e,t,n){this[Hl]=!0,write(this.fd,e,0,e.length,this.pos,(e,t)=>{if(this[Hl]=!1,this.destroyed)return n(e),this.emit(Ul,e);if(e)return n(e);this.bytesWritten+=t,n()}),this.pos!==void 0&&(this.pos+=e.length)}_destroy(e,t){this[Hl]?this.once(Ul,n=>this.close(t,e||n)):this.close(t,e)}}});function resolveIOMode(e){if(e==null)return`r`;if(typeof e==`number`){let t=(e&2)!=0,n=(e&1)!=0,r=(e&1024)!=0,i=(e&512)!=0;return t?i?`w+`:`r+`:n?r?`a`:`w`:`r`}switch(e){case`ax`:case`wx`:return`w`;case`ax+`:case`wx+`:return`w+`;case`as`:case`rs+`:return`r+`;case`as+`:return`a+`;default:return e}}function shouldCreate(e){return typeof e==`number`?(e&64)!=0:typeof e==`string`?e===`w`||e===`w+`||e===`wx`||e===`wx+`||e===`a`||e===`a+`||e===`ax`||e===`ax+`||e===`as`||e===`as+`:!1}function openIOChannel(e,t,n){try{return k.IOChannel.new_file(e,t)}catch(r){if(n&&t===`r+`&&r?.code===k.FileError.NOENT)return k.file_set_contents(e,new Uint8Array),k.IOChannel.new_file(e,t);throw r}}function mapOpenError(e,t){return createGLibFileError(e,`open`,{path:t})}var Gl=__esmMin(()=>{A(),L()});function createInterface(e,t,n,r){return typeof e==`object`&&e&&!(`read`in e&&typeof e.read==`function`)?new Interface(e):new Interface({input:e,output:t,completer:n,terminal:r})}function*emitKeys(e){for(;;){let t=yield,n=t,r=!1,i={sequence:``,name:void 0,ctrl:!1,meta:!1,shift:!1};if(t===`\x1B`&&(r=!0,n+=t=yield,t===`\x1B`&&(n+=t=yield)),r&&(t===`O`||t===`[`)){let e=t,r=0;if(t===`O`)n+=t=yield,t>=`0`&&t<=`9`&&(r=t.charCodeAt(0)-1,n+=t=yield),e+=t;else if(t===`[`){n+=t=yield,t===`[`&&(e+=t,n+=t=yield);let i=n.length-1;t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield))),t===`;`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=yield));let a=n.slice(i),o;(o=/^(?:(\d\d?)(?:;(\d))?([~^$])|(\d{3}~))$/.exec(a))?o[4]?e+=o[4]:(e+=o[1]+o[3],r=(parseInt(o[2]??`1`,10)||1)-1):(o=/^((\d;)?(\d))?([A-Za-z])$/.exec(a))?(e+=o[4],r=(parseInt(o[3]??`1`,10)||1)-1):e+=a}switch(i.ctrl=!!(r&4),i.meta=!!(r&10),i.shift=!!(r&1),i.code=e,e){case`[P`:case`OP`:case`[11~`:case`[[A`:i.name=`f1`;break;case`[Q`:case`OQ`:case`[12~`:case`[[B`:i.name=`f2`;break;case`[R`:case`OR`:case`[13~`:case`[[C`:i.name=`f3`;break;case`[S`:case`OS`:case`[14~`:case`[[D`:i.name=`f4`;break;case`[15~`:case`[[E`:i.name=`f5`;break;case`[17~`:i.name=`f6`;break;case`[18~`:i.name=`f7`;break;case`[19~`:i.name=`f8`;break;case`[20~`:i.name=`f9`;break;case`[21~`:i.name=`f10`;break;case`[23~`:i.name=`f11`;break;case`[24~`:i.name=`f12`;break;case`[200~`:i.name=`paste-start`;break;case`[201~`:i.name=`paste-end`;break;case`[A`:case`OA`:i.name=`up`;break;case`[B`:case`OB`:i.name=`down`;break;case`[C`:case`OC`:i.name=`right`;break;case`[D`:case`OD`:i.name=`left`;break;case`[E`:case`OE`:i.name=`clear`;break;case`[F`:case`OF`:i.name=`end`;break;case`[H`:case`OH`:i.name=`home`;break;case`[1~`:i.name=`home`;break;case`[2~`:i.name=`insert`;break;case`[3~`:i.name=`delete`;break;case`[4~`:i.name=`end`;break;case`[5~`:case`[[5~`:i.name=`pageup`;break;case`[6~`:case`[[6~`:i.name=`pagedown`;break;case`[7~`:i.name=`home`;break;case`[8~`:i.name=`end`;break;case`[a`:i.name=`up`,i.shift=!0;break;case`[b`:i.name=`down`,i.shift=!0;break;case`[c`:i.name=`right`,i.shift=!0;break;case`[d`:i.name=`left`,i.shift=!0;break;case`[2$`:i.name=`insert`,i.shift=!0;break;case`[3$`:i.name=`delete`,i.shift=!0;break;case`[5$`:i.name=`pageup`,i.shift=!0;break;case`[6$`:i.name=`pagedown`,i.shift=!0;break;case`[7$`:i.name=`home`,i.shift=!0;break;case`[8$`:i.name=`end`,i.shift=!0;break;case`Oa`:i.name=`up`,i.ctrl=!0;break;case`Ob`:i.name=`down`,i.ctrl=!0;break;case`Oc`:i.name=`right`,i.ctrl=!0;break;case`Od`:i.name=`left`,i.ctrl=!0;break;case`[2^`:i.name=`insert`,i.ctrl=!0;break;case`[3^`:i.name=`delete`,i.ctrl=!0;break;case`[5^`:i.name=`pageup`,i.ctrl=!0;break;case`[6^`:i.name=`pagedown`,i.ctrl=!0;break;case`[7^`:i.name=`home`,i.ctrl=!0;break;case`[8^`:i.name=`end`,i.ctrl=!0;break;case`[Z`:i.name=`tab`,i.shift=!0;break;default:i.name=`undefined`;break}}else t===`\r`?(i.name=`return`,i.meta=r):t===`
192
+ `?(i.name=`enter`,i.meta=r):t===` `?(i.name=`tab`,i.meta=r):t===`\b`||t===``?(i.name=`backspace`,i.meta=r):t===`\x1B`?(i.name=`escape`,i.meta=r):t===` `?(i.name=`space`,i.meta=r):!r&&t<=``?(i.name=String.fromCharCode(t.charCodeAt(0)+97-1),i.ctrl=!0):/^[0-9A-Za-z]$/.test(t)?(i.name=t.toLowerCase(),i.shift=/^[A-Z]$/.test(t),i.meta=r):r&&(i.name=t.length?void 0:`escape`,i.meta=!0);i.sequence=n,n.length!==0&&(i.name!==void 0||r)?e.emit(`keypress`,r?void 0:n,i):n.length===1&&e.emit(`keypress`,n,i)}}function emitKeypressEvents(e,t={}){let n=e;if(n[ql])return;n[ql]=new Do(`utf8`),n[Jl]=emitKeys(e),n[Jl].next();let r=t.escapeCodeTimeout??500,i,triggerEscape=()=>n[Jl].next(``);function onData(t){if(e.listenerCount(`keypress`)>0){let a=n[ql].write(typeof t==`string`?Buffer.from(t):t);if(a){clearTimeout(i);for(let t of a)try{n[Jl].next(t),t===`\x1B`&&(i=setTimeout(triggerEscape,r))}catch{n[Jl]=emitKeys(e),n[Jl].next()}}}else e.removeListener(`data`,onData),delete n[ql],delete n[Jl]}e.on(`data`,onData)}var Kl,Interface,ql,Jl,Yl=__esmMin(()=>{bn(),ko(),Kl=/\r\n|\r|\n/,Interface=class extends Y{terminal;line=``;cursor=0;escapeCodeTimeout;_input;_output;get input(){return this._input}get output(){return this._output}_prompt;_closed=!1;_paused=!1;history;_historySize;_crlfDelay;_lineBuffer=``;_questionCallback=null;_boundOnData=null;_boundOnEnd=null;_boundOnError=null;_boundOnKeypress=null;constructor(e,t){super();let n;if(n=e&&typeof e==`object`&&!(`read`in e&&typeof e.read==`function`)?e:{input:e,output:t},this._input=n.input||null,this._output=n.output||null,this._prompt=n.prompt||`> `,this.terminal=n.terminal??this._output!==null,this._historySize=n.historySize??30,this.history=[],this._crlfDelay=n.crlfDelay??100,this.escapeCodeTimeout=n.escapeCodeTimeout,this._input&&(this._boundOnData=e=>this._onData(e),this._boundOnEnd=()=>this._onEnd(),this._boundOnError=e=>this.emit(`error`,e),this._input.on(`data`,this._boundOnData),this._input.on(`end`,this._boundOnEnd),this._input.on(`error`,this._boundOnError),`setEncoding`in this._input&&typeof this._input.setEncoding==`function`&&this._input.setEncoding(`utf8`),this.terminal)){emitKeypressEvents(this._input,this);let e=this._input;typeof e.setRawMode==`function`&&(e.isRaw||e.setRawMode(!0)),typeof this._input.resume==`function`&&this._input.resume(),this._boundOnKeypress=(e,t)=>{t&&(t.name===`backspace`||t.name===`delete`?this.cursor>0&&(this.line=this.line.slice(0,this.cursor-1)+this.line.slice(this.cursor),this.cursor--):e&&e.length===1&&!t.ctrl&&!t.meta&&t.name!==`return`&&t.name!==`enter`&&t.name!==`escape`&&(this.line=this.line.slice(0,this.cursor)+e+this.line.slice(this.cursor),this.cursor++))},this._input.on(`keypress`,this._boundOnKeypress)}}_onData(e){if(this._closed||this._paused)return;let t=typeof e==`string`?e:e.toString(`utf8`);this._lineBuffer+=t;let n;for(;(n=Kl.exec(this._lineBuffer))!==null;){let e=this._lineBuffer.substring(0,n.index);this._lineBuffer=this._lineBuffer.substring(n.index+n[0].length),this._onLine(e)}}_onLine(e){if(e.length>0&&this._historySize>0&&(this.history.length===0||this.history[0]!==e)&&(this.history.unshift(e),this.history.length>this._historySize&&this.history.pop()),this._questionCallback){let t=this._questionCallback;this._questionCallback=null,t(e)}this.emit(`line`,e)}_onEnd(){this._lineBuffer.length>0&&(this._onLine(this._lineBuffer),this._lineBuffer=``),this.close()}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(this._closed)throw Error(`readline was closed`);this._output?.write(this._prompt)}question(e,t,n){if(this._closed)throw Error(`readline was closed`);let r=typeof t==`function`?t:n;this._questionCallback=r,this._output?.write(e)}clearLine(e,t){return this.line=``,this.cursor=0,t&&t(),!0}write(e,t){if(!this._closed){if(t){this._input&&this._input.emit(`keypress`,e??``,t);return}if(e!=null){let t=typeof e==`string`?e:e.toString(`utf8`);t&&(this.line=this.line.slice(0,this.cursor)+t+this.line.slice(this.cursor),this.cursor+=t.length),this._output?.write(e)}}}close(){if(!this._closed){if(this._closed=!0,this._input){this._boundOnData&&this._input.removeListener(`data`,this._boundOnData),this._boundOnEnd&&this._input.removeListener(`end`,this._boundOnEnd),this._boundOnError&&this._input.removeListener(`error`,this._boundOnError),this._boundOnKeypress&&this._input.removeListener(`keypress`,this._boundOnKeypress),this._boundOnData=null,this._boundOnEnd=null,this._boundOnError=null,this._boundOnKeypress=null;let e=this._input;this.terminal&&e.isRaw&&typeof e.setRawMode==`function`&&e.setRawMode(!1),typeof this._input.pause==`function`&&this._input.pause()}this.emit(`close`)}}pause(){return this._closed?this:(this._paused=!0,this._input&&`pause`in this._input&&typeof this._input.pause==`function`&&this._input.pause(),this.emit(`pause`),this)}resume(){return this._closed?this:(this._paused=!1,this._input&&`resume`in this._input&&typeof this._input.resume==`function`&&this._input.resume(),this.emit(`resume`),this)}getCursorPos(){let e=this._output?.columns??80,t=this._prompt.length+this.cursor;return{rows:Math.floor(t/e),cols:t%e}}[Symbol.asyncIterator](){let e=[],t=null,n=!1,onLine=n=>{if(t){let e=t;t=null,e({value:n,done:!1})}else e.push(n)},onClose=()=>{if(n=!0,t){let e=t;t=null,e({value:void 0,done:!0})}};return this.on(`line`,onLine),this.on(`close`,onClose),{next:()=>e.length>0?Promise.resolve({value:e.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(e=>{t=e}),return:()=>(n=!0,this.removeListener(`line`,onLine),this.removeListener(`close`,onClose),Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return this}}}},ql=Symbol(`keypress-decoder`),Jl=Symbol(`escape-decoder`)}),Xl,Zl=__esmMin(()=>{Sl(),$l(),El(),Wl(),Tl(),Gl(),Ql(),A(),N(),J(),Yl(),Xl=class FileHandle{options;_file;_ioStream=null;_readStream=null;_gFile;_ioMode;_ioLock=Promise.resolve();static instances={};constructor(e){this.options=e,this.options.flags||=`r`,this.options.mode||=438;let t=normalizePath(e.path),n=shouldCreate(e.flags),r=resolveIOMode(e.flags);try{this._file=openIOChannel(t,r,n)}catch(e){throw mapOpenError(e,t)}return this._file.set_encoding(null),this.fd=this._file.unix_get_fd(),this._gFile=M.File.new_for_path(t),this._ioMode=r,FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_getReadStream(){return this._ioStream?{input:this._ioStream.get_input_stream(),seekable:this._ioStream}:this._ioMode===`r`?(this._readStream||=this._gFile.read(null),{input:this._readStream,seekable:this._readStream}):(this._ioStream=this._gFile.open_readwrite(null),{input:this._ioStream.get_input_stream(),seekable:this._ioStream})}_getWriteStream(){if(this._ioStream)return this._ioStream;if(this._ioMode===`r`)throw Error(`FileHandle opened read-only; cannot write`);return this._ioStream=this._gFile.open_readwrite(null),this._ioStream}_serialize(e){let t=this._ioLock.catch(()=>{}).then(e);return this._ioLock=t,t}fd;static getInstance(e){if(!FileHandle.instances[e])throw Error(`No instance found for fd!`);return FileHandle.instances[e]}async appendFile(e,t){let n=getEncodingFromOptions(t);typeof e==`string`&&(e=q.from(e)),n&&this._file.set_encoding(n);let[r,i]=this._file.write_chars(e,e.length);if(r===k.IOStatus.ERROR)throw Error(`Error on append to file!`)}async chown(e,t){chownSync(normalizePath(this.options.path),e,t)}async chmod(e){chmodSync(normalizePath(this.options.path),e)}createReadStream(e){return new ReadStream(this.options.path,e)}createWriteStream(e){return new WriteStream(this.options.path,e)}async datasync(){this._file.flush()}async sync(){this._file.flush()}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof q)){let a=e[0];t=a.buffer,n=a.offset,r=a.length,i=a.position}else t=e[0],n=e[1],r=e[2],i=e[3];let a=t,o=n??0,s=r??a?.byteLength??65536,c=i??0;return this._serialize(async()=>{let{input:e,seekable:n}=this._getReadStream();n.seek(BigInt(c),k.SeekType.SET,null);let r=e.read_bytes(s,null).get_data(),i=r?.length??0;return a&&r&&i>0&&a.set(r,o),{bytesRead:i,buffer:t}})}readableWebStream(){let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/streams" before calling this method.`);return new e}async readFile(e){let t=getEncodingFromOptions(e,`buffer`);t&&this._file.set_encoding(t);let[n,r]=this._file.read_to_end();if(n===k.IOStatus.ERROR)throw Error(`Error on read from file!`);return encodeUint8Array(t,r)}readLines(e){return createInterface({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){let t=await new Promise((e,t)=>{this._gFile.query_info_async(wl,M.FileQueryInfoFlags.NONE,k.PRIORITY_DEFAULT,null,(n,r)=>{try{e(this._gFile.query_info_finish(r))}catch(e){t(e)}})}),n=normalizePath(this.options.path);return e?.bigint?new BigIntStats(t,n):new Stats(t,n)}async truncate(e=0){let t=Math.max(0,e);this._file.flush(),this._getWriteStream().get_output_stream().truncate(t,null)}async utimes(e,t){let{utimesSync:n}=await Promise.resolve().then(()=>(Il(),Fl));n(normalizePath(this.options.path),e,t)}async writeFile(e,t){let n=getEncodingFromOptions(t),r;r=typeof e==`string`?q.from(e,n||`utf8`):e,this._file.seek_position(0,k.SeekType.SET);let[i]=this._file.write_chars(r,r.length);if(i===k.IOStatus.ERROR)throw Error(`Error writing to file!`);this._file.flush()}async write(e,...t){let n=null,r=null,i=null,a=null;typeof e==`string`?(n=t[0],r=t[1]):(i=t[0],a=t[1],n=t[2]),r=getEncodingFromOptions(r,typeof e==`string`?`utf8`:null);let o;o=typeof e==`string`?new TextEncoder().encode(e):e;let s=i??0,c=a??o.byteLength-s,l=o.slice(s,s+c),u=n??0;return{bytesWritten:await this._serialize(async()=>{let e=this._getWriteStream();e.seek(BigInt(u),k.SeekType.SET,null);let t=e.get_output_stream(),n=await new Promise((e,n)=>{t.write_bytes_async(new k.Bytes(l),k.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.write_bytes_finish(i))}catch(e){n(e)}})});return await new Promise((e,n)=>{t.flush_async(k.PRIORITY_DEFAULT,null,(r,i)=>{try{t.flush_finish(i),e()}catch(e){n(e)}})}),n}),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=q.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:q.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){this._file.flush()}_closeSync(){try{this._ioStream?.close(null)}catch{}try{this._readStream?.close(null)}catch{}this._ioStream=null,this._readStream=null;try{this._file.shutdown(!0)}catch{}let e=FileHandle;delete e.instances[this.fd]}_readSync(e,t,n,r){let i=this._gFile.read(null);try{r!==null&&r>=0&&i.seek(r,k.SeekType.SET,null);let a=i.read_bytes(n,null).get_data();return new Uint8Array(e.buffer,e.byteOffset+t).set(a.subarray(0,a.length)),a.length}finally{i.close(null)}}_writeSync(e,t){let n=this._gFile.open_readwrite(null);try{return t!==null&&t>=0&&n.seek(t,k.SeekType.SET,null),n.get_output_stream().write_bytes(k.Bytes.new(e),null)}finally{n.close(null)}}async close(){try{this._ioStream?.close(null)}catch{}try{this._readStream?.close(null)}catch{}this._ioStream=null,this._readStream=null;try{this._file.shutdown(!0)}catch{}}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}}});function statSync(e,t){let n=normalizePath(e);try{let e=M.File.new_for_path(n).query_info(wl,M.FileQueryInfoFlags.NONE,null);return t?.bigint?new BigIntStats(e,n):new Stats(e,n)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`stat`,n)}}function lstatSync(e,t){let n=normalizePath(e);try{let e=M.File.new_for_path(n).query_info(wl,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);return t?.bigint?new BigIntStats(e,n):new Stats(e,n)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`lstat`,n)}}function readdirSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n).enumerate_children(`standard::name,standard::type`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),i=[];try{let e=r.next_file(null);for(;e!==null;)i.push({name:e.get_name(),type:e.get_file_type()}),e=r.next_file(null)}finally{try{r.close(null)}catch{}}let a=[];for(let e of i){let r=$a(n,e.name);if(t?.withFileTypes?a.push(new Dirent(r,e.name,e.type)):a.push(e.name),t?.recursive&&e.type===M.FileType.DIRECTORY){let n=readdirSync(r,t);for(let t of n)typeof t==`string`?a.push($a(e.name,t)):a.push(t)}}return a}function realpathSync(e){let t=normalizePath(e),n=M.File.new_for_path(t),r=0;for(;;){let e=n.query_info(`standard::is-symlink,standard::symlink-target`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(!e.get_is_symlink())return n.get_path();let i=e.get_symlink_target(),a=n.get_parent();if(n=a?a.resolve_relative_path(i):M.File.new_for_path(i),++r>40)throw Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`)}}function symlinkSync(e,t,n){let r=normalizePath(t),i=normalizePath(e);M.File.new_for_path(r).make_symbolic_link(i,null)}function readFileSync(e,t={encoding:null,flag:`r`}){let n=normalizePath(e),r=M.File.new_for_path(n);try{let[e,i]=r.load_contents(null);if(!e)throw createNodeError(Error(`failed to read file`),`read`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),i)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`read`,n)}}function mkdirSync(e,t){let n=!1,r=511;if(typeof t==`object`?(t?.recursive&&(n=t.recursive),t?.mode&&(r=t.mode)):r=t||511,e=normalizePath(e),typeof r==`string`)throw TypeError(`mode as string is currently not supported!`);if(n)return mkdirSyncRecursive(e);let i=M.File.new_for_path(e);try{i.make_directory(null)}catch(t){throw createNodeError(t,`mkdir`,e)}}function mkdirSyncRecursive(e){let t=M.File.new_for_path(e);try{return t.make_directory(null),e}catch(t){let n=t;if(n.code===M.IOErrorEnum.EXISTS)return;if(n.code===M.IOErrorEnum.NOT_FOUND){let n=$a(e,`..`),r=M.File.new_for_path(n).get_path();if(r===e)throw createNodeError(t,`mkdir`,e);let i=mkdirSyncRecursive(r),a=M.File.new_for_path(e);try{a.make_directory(null)}catch(t){throw createNodeError(t,`mkdir`,e)}return i??e}throw createNodeError(t,`mkdir`,e)}}function rmdirSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{if(r.query_info(`standard::type`,M.FileQueryInfoFlags.NONE,null).get_file_type()!==M.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if(r.enumerate_children(`standard::name`,M.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);r.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`rmdir`,n)}}function unlinkSync(e){let t=normalizePath(e),n=M.File.new_for_path(t);try{n.delete(null)}catch(e){throw createNodeError(e,`unlink`,t)}}function writeFileSync(e,t){k.file_set_contents(normalizePath(e),t)}function renameSync(e,t){let n=normalizePath(e),r=normalizePath(t),i=M.File.new_for_path(n),a=M.File.new_for_path(r);try{i.move(a,M.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw createNodeError(e,`rename`,n,r)}}function copyFileSync(e,t,n){let r=normalizePath(e),i=normalizePath(t),a=M.File.new_for_path(r),o=M.File.new_for_path(i),s=M.FileCopyFlags.NONE;n&&!(n&1)?s=M.FileCopyFlags.OVERWRITE:n||(s=M.FileCopyFlags.OVERWRITE);try{a.copy(o,s,null,null)}catch(e){throw createNodeError(e,`copyfile`,r,i)}}function accessSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{let e=r.query_info(`access::*`,M.FileQueryInfoFlags.NONE,null);if(t!==void 0&&t!==0){let r={code:14,message:`permission denied, access '${n}'`};if(t&4&&!e.get_attribute_boolean(`access::can-read`)||t&2&&!e.get_attribute_boolean(`access::can-write`)||t&1&&!e.get_attribute_boolean(`access::can-execute`))throw createNodeError(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`access`,n)}}function appendFileSync(e,t,n){let r=normalizePath(e),i=M.File.new_for_path(r),a;a=typeof t==`string`?new TextEncoder().encode(t):t;try{let e=i.append_to(M.FileCreateFlags.NONE,null);a.length>0&&e.write_bytes(new k.Bytes(a),null),e.close(null)}catch(e){throw createNodeError(e,`appendfile`,r)}}function readlinkSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{let e=r.query_info(`standard::symlink-target`,M.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_symlink_target();if(!e)throw Object.assign(Error(`EINVAL: invalid argument, readlink '${n}'`),{code:`EINVAL`,errno:-22,syscall:`readlink`,path:n});return(typeof t==`string`?t:t?.encoding)===`buffer`?q.from(e):e}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`readlink`,n)}}function linkSync(e,t){let n=normalizePath(e),r=normalizePath(t);if(!k.spawn_command_line_sync(`ln ${n} ${r}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, link '${n}' -> '${r}'`),{code:`EPERM`,errno:-1,syscall:`link`,path:n,dest:r})}function truncateSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n);try{let e=r.replace(null,!1,M.FileCreateFlags.NONE,null);if(t&&t>0){let[,n]=r.load_contents(null),i=n.slice(0,t);i.length>0&&e.write_bytes(new k.Bytes(i),null)}e.close(null)}catch(e){throw createNodeError(e,`truncate`,n)}}function chmodSync(e,t){let n=normalizePath(e),r=typeof t==`string`?parseInt(t,8):t;if(!k.spawn_command_line_sync(`chmod ${r.toString(8)} ${n}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, chmod '${n}'`),{code:`EPERM`,errno:-1,syscall:`chmod`,path:n})}function chownSync(e,t,n){let r=normalizePath(e);if(!k.spawn_command_line_sync(`chown ${t}:${n} ${r}`)[0])throw Object.assign(Error(`EPERM: operation not permitted, chown '${r}'`),{code:`EPERM`,errno:-1,syscall:`chown`,path:r})}function watch(e,t,n){return new FSWatcher(normalizePath(e),t,n)}function openSync(e,t,n){return new Xl({path:e,flags:t,mode:n})}function mkdtempSync(e,t){let n=getEncodingFromOptions(t),r=tempDirPath(e);return mkdirSync(r,{recursive:!1,mode:511}),decode(r,n)}function rmSync(e,t){let n=normalizePath(e),r=M.File.new_for_path(n),i=t?.recursive||!1,a=t?.force||!1,o;try{o=new Dirent(n)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}if(o.isDirectory()){let r=readdirSync(e);if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)rmSync($a(n,e),t)}try{r.delete(null)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}}var Ql=__esmMin(()=>{Sl(),$l(),tu(),Cl(),Tl(),Zl(),Dl(),A(),N(),uo(),J(),L(),realpathSync.native=realpathSync});function normalizePath(e){return e instanceof URL||e instanceof Z?fileURLToPath(e):typeof e==`string`?e:e.toString()}function randomName(){return[...[,,,,,,]].map(()=>`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`[Math.floor(Math.random()*62)]).join(``)}function tempDirPath(e){let t;do t=e+randomName();while(existsSync(t));return t}var $l=__esmMin(()=>{Ql(),On()});function changed(e,t,n,r){switch(r){case M.FileMonitorEvent.CHANGES_DONE_HINT:this.emit(`change`,`change`,t.get_basename());break;case M.FileMonitorEvent.DELETED:case M.FileMonitorEvent.CREATED:case M.FileMonitorEvent.RENAMED:case M.FileMonitorEvent.MOVED_IN:case M.FileMonitorEvent.MOVED_OUT:this.emit(`change`,`rename`,t.get_basename());break}}function gioEventToNodeType(e){switch(e){case M.FileMonitorEvent.CHANGES_DONE_HINT:return`change`;case M.FileMonitorEvent.DELETED:case M.FileMonitorEvent.CREATED:case M.FileMonitorEvent.RENAMED:case M.FileMonitorEvent.MOVED_IN:case M.FileMonitorEvent.MOVED_OUT:return`rename`;default:return null}}async function*watchAsync(e,t){let n=t?.signal;if(n?.aborted)return;let r=normalizePath(e),i=M.File.new_for_path(r),a=M.Cancellable.new(),o;try{o=i.monitor(M.FileMonitorFlags.NONE,a)}catch{return}let s=[],c=[],l=!1;function enqueue(e){l||(c.length>0?c.shift().resolve({value:e,done:!1}):s.push(e))}function terminate(){if(!l)for(l=!0,a.is_cancelled()||a.cancel();c.length>0;)c.shift().resolve({value:void 0,done:!0})}let u=o.connect(`changed`,(e,t,n,r)=>{let i=gioEventToNodeType(r);i!==null&&enqueue({eventType:i,filename:t?.get_basename()??null})}),abortHandler=()=>terminate();n?.addEventListener(`abort`,abortHandler);try{for(;!l;){if(s.length>0){yield s.shift();continue}let e=await new Promise(e=>{c.push({resolve:e})});if(e.done)break;yield e.value}}finally{n?.removeEventListener(`abort`,abortHandler);try{o.disconnect(u)}catch{}a.is_cancelled()||a.cancel()}}var eu,FSWatcher,tu=__esmMin(()=>{$l(),A(),N(),bn(),eu=new WeakMap,FSWatcher=class extends Y{constructor(e,t,n){super(),(!t||typeof t!=`object`)&&(t={persistent:!0});let r=t.persistent!==!1,i=M.Cancellable.new(),a=normalizePath(e),o=M.File.new_for_path(a).monitor(M.FileMonitorFlags.NONE,i);o.connect(`changed`,changed.bind(this));let s=null;r&&(s=k.timeout_add(k.PRIORITY_LOW,2147483647,()=>k.SOURCE_CONTINUE)),eu.set(this,{persistent:r,cancellable:i,sourceId:s,watcher:o}),n&&this.on(`change`,n)}close(){let e=eu.get(this);e.cancellable.is_cancelled()||(e.cancellable.cancel(),e.sourceId!==null&&(k.source_remove(e.sourceId),e.sourceId=null))}ref(){let e=eu.get(this);return!e.persistent&&!e.cancellable.is_cancelled()&&(e.persistent=!0,e.sourceId=k.timeout_add(k.PRIORITY_LOW,2147483647,()=>k.SOURCE_CONTINUE)),this}unref(){let e=eu.get(this);return e.persistent&&(e.persistent=!1,e.sourceId!==null&&(k.source_remove(e.sourceId),e.sourceId=null)),this}}});function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}function watchFile(e,t,n){typeof t==`function`&&(n=t,t={});let r=t.interval??5007,i=e.toString(),a=nu.get(i);return a||(a=new StatWatcher(i,r),a.start(),nu.set(i,a)),n&&a.addChangeListener(n),a}function unwatchFile(e,t){let n=e.toString(),r=nu.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),nu.delete(n)))}var StatWatcher,nu,ru=__esmMin(()=>{Ql(),bn(),StatWatcher=class extends Y{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=statSync(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=statSync(this._path)}catch{e=zeroedStat()}let t=this._prev;(e.mtimeMs!==t.mtimeMs||e.size!==t.size||e.ino!==t.ino)&&(this._prev=e,this.emit(`change`,e,t))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}},nu=new Map}),iu=__exportAll$4({BigIntStats:()=>BigIntStats,Dir:()=>Dir,Dirent:()=>Dirent,FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,Stats:()=>Stats,WriteStream:()=>WriteStream,access:()=>access,accessSync:()=>accessSync,appendFile:()=>appendFile,appendFileSync:()=>appendFileSync,chmod:()=>chmod,chmodSync:()=>chmodSync,chown:()=>chown,chownSync:()=>chownSync,close:()=>close,closeSync:()=>closeSync,constants:()=>au,copyFile:()=>copyFile,copyFileSync:()=>copyFileSync,cp:()=>cp,cpSync:()=>cpSync,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,default:()=>ou,exists:()=>exists,existsSync:()=>existsSync,fchmod:()=>fchmod,fchmodSync:()=>fchmodSync,fchown:()=>fchown,fchownSync:()=>fchownSync,fdatasync:()=>fdatasync,fdatasyncSync:()=>fdatasyncSync,fstat:()=>fstat,fstatSync:()=>fstatSync,fsync:()=>fsync,fsyncSync:()=>fsyncSync,ftruncate:()=>ftruncate,ftruncateSync:()=>ftruncateSync,futimes:()=>futimes,futimesSync:()=>futimesSync,glob:()=>glob,globSync:()=>globSync,lchmod:()=>lchmod,lchmodSync:()=>lchmodSync,lchown:()=>lchown,lchownSync:()=>lchownSync,link:()=>link,linkSync:()=>linkSync,lstat:()=>lstat,lstatSync:()=>lstatSync,lutimes:()=>lutimes,lutimesSync:()=>lutimesSync,mkdir:()=>mkdir,mkdirSync:()=>mkdirSync,mkdtempSync:()=>mkdtempSync,open:()=>open,openAsBlob:()=>openAsBlob,openSync:()=>openSync,opendir:()=>opendir,opendirSync:()=>opendirSync,promises:()=>Rl,read:()=>read,readFile:()=>readFile,readFileSync:()=>readFileSync,readSync:()=>readSync,readdir:()=>readdir,readdirSync:()=>readdirSync,readlink:()=>readlink,readlinkSync:()=>readlinkSync,readv:()=>readv,readvSync:()=>readvSync,realpath:()=>realpath,realpathSync:()=>realpathSync,rename:()=>rename,renameSync:()=>renameSync,rm:()=>rm,rmSync:()=>rmSync,rmdir:()=>rmdir,rmdirSync:()=>rmdirSync,stat:()=>stat,statSync:()=>statSync,statfs:()=>statfs,statfsSync:()=>statfsSync,symlink:()=>symlink,symlinkSync:()=>symlinkSync,truncate:()=>truncate,truncateSync:()=>truncateSync,unlink:()=>unlink,unlinkSync:()=>unlinkSync,unwatchFile:()=>unwatchFile,utimes:()=>utimes,utimesSync:()=>utimesSync,watch:()=>watch,watchFile:()=>watchFile,write:()=>write,writeFile:()=>writeFile,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync,writev:()=>writev,writevSync:()=>writevSync}),au,ou,su=__esmMin(()=>{tu(),El(),Wl(),Cl(),Tl(),Ql(),Ol(),Al(),jl(),Pl(),Il(),Ll(),Bl(),Vl(),ru(),au={F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:64,O_EXCL:128,O_TRUNC:512,O_APPEND:1024,O_SYNC:1052672,O_NONBLOCK:2048,O_DIRECTORY:65536,O_NOFOLLOW:131072,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1},ou={FSWatcher,StatWatcher,Stats,BigIntStats,Dirent,Dir,constants:au,existsSync,readdirSync,readFileSync,writeFileSync,mkdirSync,rmdirSync,unlinkSync,mkdtempSync,rmSync,statSync,openSync,realpathSync,symlinkSync,lstatSync,renameSync,copyFileSync,accessSync,appendFileSync,readlinkSync,linkSync,truncateSync,chmodSync,chownSync,cpSync,opendirSync,globSync,glob,watch,watchFile,unwatchFile,statfsSync,statfs,utimesSync,utimes,lutimesSync,lutimes,lchownSync,lchown,lchmodSync,lchmod,fstatSync,fstat,ftruncateSync,ftruncate,fdatasyncSync,fdatasync,fsyncSync,fsync,fchmodSync,fchmod,fchownSync,fchown,futimesSync,futimes,closeSync,readSync,writeSync,readvSync,readv,writevSync,writev,exists,openAsBlob,createReadStream,ReadStream,createWriteStream,WriteStream,promises:Rl,open,close,read,write,rm,realpath,readdir,symlink,lstat,stat,rename,copyFile,cp,access,appendFile,readlink,truncate,chmod,chown,mkdir,rmdir,readFile,writeFile,unlink,link,opendir}}),cu=__commonJSMin(((e,t)=>{
193
193
  /*!
194
194
  * express
195
195
  * Copyright(c) 2009-2013 TJ Holowaychuk
@@ -197,7 +197,7 @@ var n=mo()(`finalhandler`),r=gl(),i=_l(),a=ss(),o=vl(),s=vo(),c=a.isFinished;fun
197
197
  * Copyright(c) 2014-2015 Douglas Christopher Wilson
198
198
  * MIT Licensed
199
199
  */
200
- var n=mo()(`express:view`),r=(uo(),__toCommonJS(Ya)),i=(su(),__toCommonJS(iu)),a=r.dirname,o=r.basename,s=r.extname,c=r.join,l=r.resolve;t.exports=View;function View(e,t){var r=t||{};if(this.defaultEngine=r.defaultEngine,this.ext=s(e),this.name=e,this.root=r.root,!this.ext&&!this.defaultEngine)throw Error(`No default engine was specified and no extension was provided.`);var i=e;if(this.ext||(this.ext=this.defaultEngine[0]===`.`?this.defaultEngine:`.`+this.defaultEngine,i+=this.ext),!r.engines[this.ext]){var a=this.ext.slice(1);n(`require "%s"`,a);var o=v(a).__express;if(typeof o!=`function`)throw Error(`Module "`+a+`" does not provide a view engine.`);r.engines[this.ext]=o}this.engine=r.engines[this.ext],this.path=this.lookup(i)}View.prototype.lookup=function lookup(e){var t,r=[].concat(this.root);n(`lookup "%s"`,e);for(var i=0;i<r.length&&!t;i++){var s=r[i],c=l(s,e),u=a(c),d=o(c);t=this.resolve(u,d)}return t},View.prototype.render=function render(e,t){var r=!0;n(`render "%s"`,this.path),this.engine(this.path,e,function onRender(){if(!r)return t.apply(this,arguments);for(var e=Array(arguments.length),n=this,i=0;i<arguments.length;i++)e[i]=arguments[i];return process.nextTick(function renderTick(){return t.apply(n,e)})}),r=!1},View.prototype.resolve=function resolve(e,t){var n=this.ext,r=c(e,t),i=tryStat(r);if(i&&i.isFile()||(r=c(e,o(t,n),`index`+n),i=tryStat(r),i&&i.isFile()))return r};function tryStat(e){n(`stat "%s"`,e);try{return i.statSync(e)}catch{return}}})),lu,uu,du=__esmMin(()=>{lu={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,510:`Not Extended`,511:`Network Authentication Required`},uu=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PRI.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`)}),IncomingMessage,fu=__esmMin(()=>{J(),Kr(),IncomingMessage=class extends Br{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];method;url;statusCode;statusMessage;complete=!1;socket=null;aborted=!1;get connection(){return this.socket}_timeoutTimer=null;constructor(){super()}_read(e){}_autoClose(){}_pushBody(e){e&&e.length>0&&this.push(q.from(e)),this.push(null),this.complete=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null)}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}destroy(e){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.aborted=!0,super.destroy(e)}}}),ServerRequestSocket,pu=__esmMin(()=>{Kr(),ServerRequestSocket=class extends Hr{remoteAddress;remotePort;localAddress;localPort;remoteFamily=`IPv4`;encrypted;connecting=!1;pending=!1;bytesRead=0;bytesWritten=0;_bridgeRes;_bridgePaused=!1;constructor(e,t,n,r,i,a=!1){super({allowHalfOpen:!0}),this.remoteAddress=e,this.remotePort=t,this.localAddress=n,this.localPort=r,this.encrypted=a,this._bridgeRes=i}pause(){return this._bridgePaused?this:(this._bridgePaused=!0,super.pause())}resume(){return this._bridgePaused&&=!1,super.resume()}_read(e){}_write(e,t,n){n()}destroySoon(){this.writableEnded||this.end(),this.writableFinished?this.destroy():this.once(`finish`,()=>this.destroy())}setTimeout(e,t){return t&&this.once(`timeout`,t),this}setNoDelay(e){return this}setKeepAlive(e,t){return this}ref(){return this}unref(){return this}address(){return{address:this.localAddress,family:`IPv4`,port:this.localPort}}}}),Socket,mu=__esmMin(()=>{N(),A(),Kr(),J(),L(),Socket=class extends Hr{remoteAddress;remotePort;remoteFamily;localAddress;localPort;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!0;readyState=`closed`;_connection=null;_ioStream=null;_inputStream=null;_outputStream=null;_cancellable=new M.Cancellable;_reading=!1;_timeout=0;_timeoutId=null;constructor(e){super(e),this.allowHalfOpen=e?.allowHalfOpen??!1}_setConnection(e){this._connection=e}_setupFromIOStream(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===M.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),this._startReading()}_attachOutputOnly(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===M.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`)}_releaseIOStream(){let e=this._ioStream;return this._ioStream=null,this._inputStream=null,this._outputStream=null,this._connection=null,e}connect(e,t,n){let r;typeof e==`number`?(r={port:e,host:typeof t==`string`?t:`localhost`},typeof t==`function`&&(n=t)):(r=e,typeof t==`function`&&(n=t)),n&&this.once(`connect`,n),this.connecting=!0,this.readyState=`opening`,this.pending=!0;let i=r.host||`localhost`,a=r.port,o=new M.SocketClient;return r.timeout&&o.set_timeout(Math.ceil(r.timeout/1e3)),o.connect_to_host_async(i,a,this._cancellable,(e,t)=>{try{this._connection=o.connect_to_host_finish(t),this._setupConnection(r)}catch(e){this.connecting=!1,this.readyState=`closed`;let t=createNodeError$1(e,`connect`,{address:i,port:a});this.destroy(t)}}),this}_setupConnection(e){if(!this._connection)return;let t=this._connection.get_socket();if(this._inputStream=this._connection.get_input_stream(),this._outputStream=this._connection.get_output_stream(),`keepAlive`in e&&e.keepAlive&&t.set_keepalive(!0),!(`noDelay`in e)||e.noDelay!==!1)try{t.set_option(6,1,1)}catch{}try{let e=this._connection.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===M.SocketFamily.IPV6?`IPv6`:`IPv4`}catch{}try{let e=this._connection.get_local_address();this.localAddress=e.get_address().to_string(),this.localPort=e.get_port()}catch{}this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),this._startReading()}_startReading(){this._reading||!this._inputStream||(this._reading=!0,this._readLoop())}async _readLoop(){let e=this._inputStream;if(e)try{for(;this._reading&&e;){let t=await new Promise((t,n)=>{e.read_bytes_async(16384,k.PRIORITY_DEFAULT,this._cancellable,(r,i)=>{try{t(e.read_bytes_finish(i))}catch(e){n(e)}})});if(!t||t.get_size()===0){this._reading=!1,this.allowHalfOpen?this.readyState=this.writable?`writeOnly`:`closed`:this.once(`end`,()=>{this.end(),this.readyState=`closed`}),this.push(null);break}let n=gbytesToUint8Array(t);if(this.bytesRead+=n.length,this._resetTimeout(),!this.push(q.from(n))){this._reading=!1;break}}}catch(e){this._cancellable.is_cancelled()||this.destroy(createNodeError$1(e,`read`,{address:this.remoteAddress}))}}_read(e){!this._reading&&this._inputStream&&this._startReading()}_write(e,t,n){if(!this._outputStream){n(Error(`Socket is not connected`));return}let r=q.isBuffer(e)?e:q.from(e,t);this._outputStream.write_bytes_async(new k.Bytes(r),k.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{try{let e=this._outputStream.write_bytes_finish(t);this.bytesWritten+=e,this._resetTimeout(),n(null)}catch(e){n(createNodeError$1(e,`write`,{address:this.remoteAddress}))}})}_final(e){if(this._connection)try{this._connection.get_socket().shutdown(!1,!0),this.readyState=this.readable?`readOnly`:`closed`}catch{}else if(this._ioStream){try{this._ioStream.close(null),this.readyState=`closed`}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null}e()}_destroy(e,t){if(this._reading=!1,this._clearTimeout(),this._cancellable.cancel(),this._connection){try{this._connection.close(null)}catch{}this._connection=null}else if(this._ioStream)try{this._ioStream.close(null)}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null,this.readyState=`closed`,this.destroyed=!0,t(e)}setTimeout(e,t){return this._timeout=e,this._clearTimeout(),t&&this.once(`timeout`,t),e>0&&this._resetTimeout(),this}_resetTimeout(){this._clearTimeout(),this._timeout>0&&(this._timeoutId=setTimeout(()=>{this.emit(`timeout`)},this._timeout))}_clearTimeout(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}setKeepAlive(e,t){if(this._connection)try{this._connection.get_socket().set_keepalive(e??!1)}catch{}return this}setNoDelay(e){if(this._connection)try{this._connection.get_socket().set_option(6,1,e===!1?0:1)}catch{}return this}destroySoon(){this.writable&&this.end(),this.writableFinished?this.destroy():this.once(`finish`,this.destroy.bind(this))}address(){return this.localAddress&&this.localPort?{port:this.localPort,family:this.remoteFamily||`IPv4`,address:this.localAddress}:{}}ref(){return this}unref(){return this}}}),hu,gu=__esmMin(()=>{hu=l.Server,l.Request,l.Response}),OutgoingMessage,ServerResponse,_u,Server$1,vu=__esmMin(()=>{I(),pu(),du(),fu(),J(),L(),bn(),Kr(),mu(),gu(),OutgoingMessage=class extends Vr{headersSent=!1;sendDate=!0;finished=!1;socket=null;_headers=new Map;setHeader(e,t){return this._headers.set(e.toLowerCase(),typeof t==`number`?String(t):t),this}getHeader(e){return this._headers.get(e.toLowerCase())}removeHeader(e){this._headers.delete(e.toLowerCase())}hasHeader(e){return this._headers.has(e.toLowerCase())}getHeaderNames(){return Array.from(this._headers.keys())}getHeaders(){let e={};for(let[t,n]of this._headers)e[t]=n;return e}appendHeader(e,t){let n=e.toLowerCase(),r=this._headers.get(n);return r===void 0?this._headers.set(n,t):Array.isArray(r)?Array.isArray(t)?r.push(...t):r.push(t):Array.isArray(t)?this._headers.set(n,[r,...t]):this._headers.set(n,[r,t]),this}flushHeaders(){this.headersSent=!0}_write(e,t,n){n()}},ServerResponse=class extends OutgoingMessage{statusCode=200;statusMessage=``;_streaming=!1;_bridge;_timeoutTimer=null;constructor(e){super(),this._bridge=e,e.connect(`close`,()=>{this.emit(`close`)})}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}writeHead(e,t,n){if(this.statusCode=e,typeof t==`object`&&(n=t,t=void 0),this.statusMessage=t||lu[e]||``,n)for(let[e,t]of Object.entries(n))this.setHeader(e,t);return this}writeContinue(e){e&&Promise.resolve().then(e)}writeProcessing(e){e&&Promise.resolve().then(e)}flushHeaders(){this.headersSent||=!0}addTrailers(e){for(let[t,n]of Object.entries(e))this._headers.set(`trailer-`+t.toLowerCase(),n)}_startStreaming(){if(!this._streaming){this._streaming=!0,this.headersSent=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null);for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}}_write(e,t,n){let r=q.isBuffer(e)?e:q.from(e,t);this._startStreaming(),this._bridge.write_chunk(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n()}_final(e){if(!this._streaming){for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}this._bridge.end(),this.finished=!0,e()}end(e,t,n){return typeof e==`function`?(n=e,e=void 0):typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),super.end(n),this}},_u=new Set,Server$1=class extends Y{static{__name(this,`Server`)}listening=!1;maxHeadersCount=2e3;timeout=0;keepAliveTimeout=5e3;headersTimeout=6e4;requestTimeout=3e5;_bridge=null;_address=null;get soupServer(){return this._bridge?.soup_server??null}constructor(e,t){super();let n=typeof e==`function`?e:t;n&&this.on(`request`,n)}listen(...e){let t=0,n=`0.0.0.0`,r;for(let i of e)typeof i==`number`?t=i:typeof i==`string`?n=i:typeof i==`function`&&(r=i);r&&this.once(`listening`,r);try{this._bridge=new hu,this._bridge.connect(`request-received`,(e,t,n)=>{this._handleRequest(t,n)}),this._bridge.connect(`upgrade`,(e,t,n,r)=>{this._handleUpgrade(t,n)}),this._bridge.connect(`error-occurred`,(e,t)=>{this.emit(`error`,Error(t))}),this._bridge.listen(t,n),ensureMainLoop(),this.listening=!0,this._address={port:this._bridge.port,family:`IPv4`,address:this._bridge.address||n},_u.add(this),deferEmit(this,`listening`)}catch(e){let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_handleRequest(e,t){let n=new IncomingMessage,r=new ServerResponse(t);n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let i=e.header_pairs??[];for(let e=0;e+1<i.length;e+=2){let t=i[e],r=i[e+1],a=t.toLowerCase();if(n.rawHeaders.push(t,r),a in n.headers){let e=n.headers[a];Array.isArray(e)?e.push(r):n.headers[a]=[e,r]}else n.headers[a]=r}n.socket=new ServerRequestSocket(e.remote_address??`127.0.0.1`,e.remote_port??0,this._address?.address??`127.0.0.1`,this._address?.port??0,t);let a=e.get_body();a.length>0?n._pushBody(a):n._pushBody(null),e.connect(`aborted_signal`,()=>{n.aborted||(n.aborted=!0,n.emit(`aborted`))}),e.connect(`close`,()=>{n.emit(`close`)});try{let e=this.emit(`request`,n,r);(e instanceof Promise||typeof e==`object`&&e&&typeof e.then==`function`)&&e.catch(e=>{if(F.error(`[HTTP] Unhandled error in async request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}})}catch(e){if(F.error(`[HTTP] Unhandled error in request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}}}_handleUpgrade(e,t){let n=new IncomingMessage;n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let r=e.header_pairs??[];for(let e=0;e+1<r.length;e+=2){let t=r[e],i=r[e+1],a=t.toLowerCase();n.rawHeaders.push(t,i),n.headers[a]=i}if(this.listenerCount(`upgrade`)>0){let e=new Socket;e._attachOutputOnly(t),this.emit(`upgrade`,n,e,q.alloc(0))}}address(){return this._address}addWebSocketHandler(e,t){if(!this._bridge)throw Error(`Server must be listening before adding WebSocket handlers. Call listen() first.`);this._bridge.soup_server.add_websocket_handler(e,null,null,(e,n,r,i)=>{t(i)})}close(e){return e&&this.once(`close`,e),this._bridge&&=(this._bridge.close(),null),this.listening=!1,_u.delete(this),deferEmit(this,`close`),this}setTimeout(e,t){return this.timeout=e,t&&this.on(`timeout`,t),this}}}),yu,bu=__esmMin(()=>{yu=u}),xu,Su=__esmMin(()=>{bu(),xu=yu}),ClientRequest,Cu=__esmMin(()=>{fu(),vu(),A(),Su(),N(),J(),On(),L(),ClientRequest=class extends OutgoingMessage{method;path;protocol;host;hostname;port;aborted=!1;reusedSocket=!1;maxHeadersCount=2e3;_chunks=[];_session;_message;_cancellable;_timeout=0;_timeoutTimer=null;_responseCallback;constructor(e,t,n){super();let r;if(typeof e==`string`||e instanceof Z){let i=typeof e==`string`?new Z(e):e;r={protocol:i.protocol,hostname:i.hostname,port:i.port?Number(i.port):void 0,path:i.pathname+i.search,...typeof t==`object`?t:{}},typeof t==`function`&&(n=t)}else r=e,typeof t==`function`&&(n=t);if(this.method=(r.method||`GET`).toUpperCase(),this.protocol=r.protocol||`http:`,this.hostname=r.hostname||r.host?.split(`:`)[0]||`localhost`,this.port=Number(r.port)||(this.protocol===`https:`?443:80),this.path=r.path||`/`,this.host=r.host||`${this.hostname}:${this.port}`,this._timeout=r.timeout||0,n&&(this._responseCallback=n,this.once(`response`,n)),r.headers)for(let[e,t]of Object.entries(r.headers))this.setHeader(e,t);if(r.setHost!==!1&&!this._headers.has(`host`)){let e=this.protocol===`https:`?443:80,t=this.port===e?this.hostname:`${this.hostname}:${this.port}`;this.setHeader(`Host`,t)}r.auth&&!this._headers.has(`authorization`)&&this.setHeader(`Authorization`,`Basic `+q.from(r.auth).toString(`base64`)),r.signal&&(r.signal.aborted?this.abort():r.signal.addEventListener(`abort`,()=>this.abort(),{once:!0}));let i=k.Uri.parse(this._buildUrl(),k.UriFlags.NONE);this._session=new xu.Session,this._message=new xu.Message({method:this.method,uri:i}),this._cancellable=new M.Cancellable,this._timeout>0&&(this._session.timeout=Math.ceil(this._timeout/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},this._timeout))}_buildUrl(){let e=this.protocol.endsWith(`:`)?this.protocol:this.protocol+`:`,t=e===`https:`?443:80,n=this.port===t?``:`:${this.port}`;return`${e}//${this.hostname}${n}${this.path}`}getRawHeaderNames(){return Array.from(this._headers.keys())}flushHeaders(){this.headersSent||this._applyHeaders()}setTimeout(e,t){return this._timeout=e,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._session.timeout=Math.ceil(e/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}abort(){this.aborted||(this.aborted=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this._cancellable.cancel(),this.emit(`abort`),this.destroy())}_write(e,t,n){let r=q.isBuffer(e)?e:q.from(e,t);this._chunks.push(r),n()}_final(e){this._sendRequest().then(()=>e()).catch(t=>e(t))}_applyHeaders(){if(this.headersSent)return;this.headersSent=!0;let e=this._message.get_request_headers();for(let[t,n]of this._headers)if(Array.isArray(n))for(let r of n)e.append(t,r);else e.replace(t,n)}async _sendRequest(){this._applyHeaders();let e=q.concat(this._chunks);if(e.length>0){let t=this._headers.get(`content-type`)||`application/octet-stream`;this._message.set_request_body_from_bytes(t,new k.Bytes(e))}try{let e=await new Promise((e,t)=>{this._session.send_async(this._message,k.PRIORITY_DEFAULT,this._cancellable,(n,r)=>{try{e(this._session.send_finish(r))}catch(e){t(e)}})}),t=[];try{let n;for(;(n=await readBytesAsync(e,4096,k.PRIORITY_DEFAULT,this._cancellable))!==null;)t.push(q.from(n))}catch{}let n=new IncomingMessage;n.statusCode=this._message.status_code,n.statusMessage=this._message.get_reason_phrase(),n.httpVersion=`1.1`,this._message.get_response_headers().foreach((e,t)=>{let r=e.toLowerCase();if(n.rawHeaders.push(e,t),r in n.headers){let e=n.headers[r];Array.isArray(e)?e.push(t):n.headers[r]=[e,t]}else n.headers[r]=t}),this.finished=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.emit(`response`,n),setTimeout(()=>{for(let e of t)n.push(e);n.push(null),n.complete=!0},0)}catch(e){this.aborted?this.emit(`abort`):this.emit(`error`,e instanceof Error?e:Error(String(e)))}}}});function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let t=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),t}}function validateHeaderValue(e,t){if(t===void 0){let t=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(t,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),t}if(typeof t==`string`&&/[^\t -~€-ÿ]/.test(t)){let t=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_CHAR`}),t}}var wu=__esmMin(()=>{}),Tu=__exportAll$4({Agent:()=>Agent,ClientRequest:()=>ClientRequest,IncomingMessage:()=>IncomingMessage,METHODS:()=>uu,OutgoingMessage:()=>OutgoingMessage,STATUS_CODES:()=>lu,Server:()=>Server$1,ServerResponse:()=>ServerResponse,createServer:()=>createServer$1,default:()=>Ou,get:()=>get,globalAgent:()=>Eu,maxHeaderSize:()=>Du,request:()=>request,setMaxIdleHTTPParsers:()=>setMaxIdleHTTPParsers,validateHeaderName:()=>validateHeaderName,validateHeaderValue:()=>validateHeaderValue});function createServer$1(e,t){return typeof e==`function`?new Server$1(e):new Server$1(t)}function request(e,t,n){return new ClientRequest(e,t,n)}function get(e,t,n){let r,i=n;typeof e==`string`||e instanceof Z?(r=typeof t==`object`?{...t,method:`GET`}:{method:`GET`},typeof t==`function`&&(i=t)):(r={...e,method:`GET`},typeof t==`function`&&(i=t),e=r);let a=typeof e==`string`||e instanceof Z?new ClientRequest(e,{...r,method:`GET`},i):new ClientRequest({...r,method:`GET`},i);return a.end(),a}function setMaxIdleHTTPParsers(e){}var Agent,Eu,Du,Ou,ku=__esmMin(()=>{du(),fu(),vu(),Cu(),wu(),On(),Agent=class{defaultPort=80;protocol=`http:`;maxSockets;maxTotalSockets;maxFreeSockets;keepAliveMsecs;keepAlive;scheduling;requests={};sockets={};freeSockets={};constructor(e){this.keepAlive=e?.keepAlive??!1,this.keepAliveMsecs=e?.keepAliveMsecs??1e3,this.maxSockets=e?.maxSockets??1/0,this.maxTotalSockets=e?.maxTotalSockets??1/0,this.maxFreeSockets=e?.maxFreeSockets??256,this.scheduling=e?.scheduling??`lifo`}destroy(){}getName(e){let t=e.host||`localhost`;return e.port&&(t+=`:`+e.port),e.localAddress&&(t+=`:`+e.localAddress),(e.family===4||e.family===6)&&(t+=`:`+e.family),t}},Eu=new Agent,__name(createServer$1,`createServer`),Du=16384,Ou={STATUS_CODES:lu,METHODS:uu,Server:Server$1,IncomingMessage,OutgoingMessage,ServerResponse,ClientRequest,Agent,globalAgent:Eu,createServer:createServer$1,request,get,validateHeaderName,validateHeaderValue,maxHeaderSize:Du,setMaxIdleHTTPParsers}}),Au=__commonJSMin(((e,t)=>{
200
+ var n=mo()(`express:view`),r=(uo(),__toCommonJS(Ya)),i=(su(),__toCommonJS(iu)),a=r.dirname,o=r.basename,s=r.extname,c=r.join,l=r.resolve;t.exports=View;function View(e,t){var r=t||{};if(this.defaultEngine=r.defaultEngine,this.ext=s(e),this.name=e,this.root=r.root,!this.ext&&!this.defaultEngine)throw Error(`No default engine was specified and no extension was provided.`);var i=e;if(this.ext||(this.ext=this.defaultEngine[0]===`.`?this.defaultEngine:`.`+this.defaultEngine,i+=this.ext),!r.engines[this.ext]){var a=this.ext.slice(1);n(`require "%s"`,a);var o=v(a).__express;if(typeof o!=`function`)throw Error(`Module "`+a+`" does not provide a view engine.`);r.engines[this.ext]=o}this.engine=r.engines[this.ext],this.path=this.lookup(i)}View.prototype.lookup=function lookup(e){var t,r=[].concat(this.root);n(`lookup "%s"`,e);for(var i=0;i<r.length&&!t;i++){var s=r[i],c=l(s,e),u=a(c),d=o(c);t=this.resolve(u,d)}return t},View.prototype.render=function render(e,t){var r=!0;n(`render "%s"`,this.path),this.engine(this.path,e,function onRender(){if(!r)return t.apply(this,arguments);for(var e=Array(arguments.length),n=this,i=0;i<arguments.length;i++)e[i]=arguments[i];return process.nextTick(function renderTick(){return t.apply(n,e)})}),r=!1},View.prototype.resolve=function resolve(e,t){var n=this.ext,r=c(e,t),i=tryStat(r);if(i&&i.isFile()||(r=c(e,o(t,n),`index`+n),i=tryStat(r),i&&i.isFile()))return r};function tryStat(e){n(`stat "%s"`,e);try{return i.statSync(e)}catch{return}}})),lu,uu,du=__esmMin(()=>{lu={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,510:`Not Extended`,511:`Network Authentication Required`},uu=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PRI.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`)}),IncomingMessage,fu=__esmMin(()=>{J(),Kr(),IncomingMessage=class extends Br{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];method;url;statusCode;statusMessage;complete=!1;socket=null;aborted=!1;get connection(){return this.socket}_timeoutTimer=null;constructor(){super()}_read(e){}_autoClose(){}_pushBody(e){e&&e.length>0&&this.push(q.from(e)),this.push(null),this.complete=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null)}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}destroy(e){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.aborted=!0,super.destroy(e)}}}),ServerRequestSocket,pu=__esmMin(()=>{Kr(),ServerRequestSocket=class extends Hr{remoteAddress;remotePort;localAddress;localPort;remoteFamily=`IPv4`;encrypted;connecting=!1;pending=!1;bytesRead=0;bytesWritten=0;_bridgeRes;_bridgePaused=!1;constructor(e,t,n,r,i,a=!1){super({allowHalfOpen:!0}),this.remoteAddress=e,this.remotePort=t,this.localAddress=n,this.localPort=r,this.encrypted=a,this._bridgeRes=i}pause(){return this._bridgePaused?this:(this._bridgePaused=!0,super.pause())}resume(){return this._bridgePaused&&=!1,super.resume()}_read(e){}_write(e,t,n){n()}destroySoon(){this.writableEnded||this.end(),this.writableFinished?this.destroy():this.once(`finish`,()=>this.destroy())}setTimeout(e,t){return t&&this.once(`timeout`,t),this}setNoDelay(e){return this}setKeepAlive(e,t){return this}ref(){return this}unref(){return this}address(){return{address:this.localAddress,family:`IPv4`,port:this.localPort}}}}),Socket,mu=__esmMin(()=>{N(),A(),Kr(),J(),L(),Socket=class extends Hr{remoteAddress;remotePort;remoteFamily;localAddress;localPort;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!0;readyState=`closed`;_connection=null;_ioStream=null;_inputStream=null;_outputStream=null;_cancellable=new M.Cancellable;_reading=!1;_timeout=0;_timeoutId=null;constructor(e){super(e),this.allowHalfOpen=e?.allowHalfOpen??!1}_setConnection(e){this._connection=e}_setupFromIOStream(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===M.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),this._startReading()}_attachOutputOnly(e){this._ioStream=e;try{let t=e;if(typeof t.get_socket==`function`){this._connection=t;let e=t.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===M.SocketFamily.IPV6?`IPv6`:`IPv4`;let n=t.get_local_address();this.localAddress=n.get_address().to_string(),this.localPort=n.get_port()}}catch{}this._inputStream=e.get_input_stream(),this._outputStream=e.get_output_stream(),this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`)}_releaseIOStream(){let e=this._ioStream;return this._ioStream=null,this._inputStream=null,this._outputStream=null,this._connection=null,e}connect(e,t,n){let r;typeof e==`number`?(r={port:e,host:typeof t==`string`?t:`localhost`},typeof t==`function`&&(n=t)):(r=e,typeof t==`function`&&(n=t)),n&&this.once(`connect`,n),this.connecting=!0,this.readyState=`opening`,this.pending=!0;let i=r.host||`localhost`,a=r.port,o=new M.SocketClient;return r.timeout&&o.set_timeout(Math.ceil(r.timeout/1e3)),o.connect_to_host_async(i,a,this._cancellable,(e,t)=>{try{this._connection=o.connect_to_host_finish(t),this._setupConnection(r)}catch(e){this.connecting=!1,this.readyState=`closed`;let t=createNodeError$1(e,`connect`,{address:i,port:a});this.destroy(t)}}),this}_setupConnection(e){if(!this._connection)return;let t=this._connection.get_socket();if(this._inputStream=this._connection.get_input_stream(),this._outputStream=this._connection.get_output_stream(),`keepAlive`in e&&e.keepAlive&&t.set_keepalive(!0),!(`noDelay`in e)||e.noDelay!==!1)try{t.set_option(6,1,1)}catch{}try{let e=this._connection.get_remote_address();this.remoteAddress=e.get_address().to_string(),this.remotePort=e.get_port(),this.remoteFamily=e.get_address().get_family()===M.SocketFamily.IPV6?`IPv6`:`IPv4`}catch{}try{let e=this._connection.get_local_address();this.localAddress=e.get_address().to_string(),this.localPort=e.get_port()}catch{}this.connecting=!1,this.pending=!1,this.readyState=`open`,this.emit(`connect`),this.emit(`ready`),this._startReading()}_startReading(){this._reading||!this._inputStream||(this._reading=!0,this._readLoop())}async _readLoop(){let e=this._inputStream;if(e)try{for(;this._reading&&e;){let t=await new Promise((t,n)=>{e.read_bytes_async(16384,k.PRIORITY_DEFAULT,this._cancellable,(r,i)=>{try{t(e.read_bytes_finish(i))}catch(e){n(e)}})});if(!t||t.get_size()===0){this._reading=!1,this.allowHalfOpen?this.readyState=this.writable?`writeOnly`:`closed`:this.once(`end`,()=>{this.end(),this.readyState=`closed`}),this.push(null);break}let n=gbytesToUint8Array(t);if(this.bytesRead+=n.length,this._resetTimeout(),!this.push(q.from(n))){this._reading=!1;break}}}catch(e){this._cancellable.is_cancelled()||this.destroy(createNodeError$1(e,`read`,{address:this.remoteAddress}))}}_read(e){!this._reading&&this._inputStream&&this._startReading()}_write(e,t,n){if(!this._outputStream){n(Error(`Socket is not connected`));return}let r=q.isBuffer(e)?e:typeof e==`string`?q.from(e,t):q.from(e);this._outputStream.write_bytes_async(new k.Bytes(r),k.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{try{let e=this._outputStream.write_bytes_finish(t);this.bytesWritten+=e,this._resetTimeout(),n(null)}catch(e){n(createNodeError$1(e,`write`,{address:this.remoteAddress}))}})}_final(e){if(this._connection)try{this._connection.get_socket().shutdown(!1,!0),this.readyState=this.readable?`readOnly`:`closed`}catch{}else if(this._ioStream){try{this._ioStream.close(null),this.readyState=`closed`}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null}e()}_destroy(e,t){if(this._reading=!1,this._clearTimeout(),this._cancellable.cancel(),this._connection){try{this._connection.close(null)}catch{}this._connection=null}else if(this._ioStream)try{this._ioStream.close(null)}catch{}this._ioStream=null,this._inputStream=null,this._outputStream=null,this.readyState=`closed`,this.destroyed=!0,t(e)}setTimeout(e,t){return this._timeout=e,this._clearTimeout(),t&&this.once(`timeout`,t),e>0&&this._resetTimeout(),this}_resetTimeout(){this._clearTimeout(),this._timeout>0&&(this._timeoutId=setTimeout(()=>{this.emit(`timeout`)},this._timeout))}_clearTimeout(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}setKeepAlive(e,t){if(this._connection)try{this._connection.get_socket().set_keepalive(e??!1)}catch{}return this}setNoDelay(e){if(this._connection)try{this._connection.get_socket().set_option(6,1,e===!1?0:1)}catch{}return this}destroySoon(){this.writable&&this.end(),this.writableFinished?this.destroy():this.once(`finish`,this.destroy.bind(this))}address(){return this.localAddress&&this.localPort?{port:this.localPort,family:this.remoteFamily||`IPv4`,address:this.localAddress}:{}}ref(){return this}unref(){return this}}}),hu,gu=__esmMin(()=>{hu=l.Server,l.Request,l.Response}),OutgoingMessage,ServerResponse,_u,Server$1,vu=__esmMin(()=>{I(),pu(),du(),fu(),J(),L(),bn(),Kr(),mu(),gu(),OutgoingMessage=class extends Vr{headersSent=!1;sendDate=!0;finished=!1;socket=null;_headers=new Map;setHeader(e,t){return this._headers.set(e.toLowerCase(),typeof t==`number`?String(t):t),this}getHeader(e){return this._headers.get(e.toLowerCase())}removeHeader(e){this._headers.delete(e.toLowerCase())}hasHeader(e){return this._headers.has(e.toLowerCase())}getHeaderNames(){return Array.from(this._headers.keys())}getHeaders(){let e={};for(let[t,n]of this._headers)e[t]=n;return e}appendHeader(e,t){let n=e.toLowerCase(),r=this._headers.get(n);return r===void 0?this._headers.set(n,t):Array.isArray(r)?Array.isArray(t)?r.push(...t):r.push(t):Array.isArray(t)?this._headers.set(n,[r,...t]):this._headers.set(n,[r,t]),this}flushHeaders(){this.headersSent=!0}_write(e,t,n){n()}},ServerResponse=class extends OutgoingMessage{statusCode=200;statusMessage=``;_streaming=!1;_bridge;_timeoutTimer=null;constructor(e){super(),this._bridge=e,e.connect(`close`,()=>{this.emit(`close`)})}setTimeout(e,t){return this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}writeHead(e,t,n){if(this.statusCode=e,typeof t==`object`&&(n=t,t=void 0),this.statusMessage=t||lu[e]||``,n)for(let[e,t]of Object.entries(n))this.setHeader(e,t);return this}writeContinue(e){e&&Promise.resolve().then(e)}writeProcessing(e){e&&Promise.resolve().then(e)}flushHeaders(){this.headersSent||=!0}addTrailers(e){for(let[t,n]of Object.entries(e))this._headers.set(`trailer-`+t.toLowerCase(),n)}_startStreaming(){if(!this._streaming){this._streaming=!0,this.headersSent=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null);for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}}_write(e,t,n){let r=q.isBuffer(e)?e:typeof e==`string`?q.from(e,t):q.from(e);this._startStreaming(),this._bridge.write_chunk(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n()}_final(e){if(!this._streaming){for(let[e,t]of this._headers)if(Array.isArray(t))for(let n of t)this._bridge.append_header(e,n);else this._bridge.set_header(e,t);this._bridge.write_head(this.statusCode,this.statusMessage||null)}this._bridge.end(),this.finished=!0,e()}end(e,t,n){return typeof e==`function`?(n=e,e=void 0):typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),super.end(n),this}},_u=new Set,Server$1=class extends Y{static{__name(this,`Server`)}listening=!1;maxHeadersCount=2e3;timeout=0;keepAliveTimeout=5e3;headersTimeout=6e4;requestTimeout=3e5;_bridge=null;_address=null;get soupServer(){return this._bridge?.soup_server??null}constructor(e,t){super();let n=typeof e==`function`?e:t;n&&this.on(`request`,n)}listen(...e){let t=0,n=`0.0.0.0`,r;for(let i of e)typeof i==`number`?t=i:typeof i==`string`?n=i:typeof i==`function`&&(r=i);r&&this.once(`listening`,r);try{this._bridge=new hu,this._bridge.connect(`request-received`,(e,t,n)=>{this._handleRequest(t,n)}),this._bridge.connect(`upgrade`,(e,t,n,r)=>{this._handleUpgrade(t,n)}),this._bridge.connect(`error-occurred`,(e,t)=>{this.emit(`error`,Error(t))}),this._bridge.listen(t,n),ensureMainLoop(),this.listening=!0,this._address={port:this._bridge.port,family:`IPv4`,address:this._bridge.address||n},_u.add(this),deferEmit(this,`listening`)}catch(e){let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_handleRequest(e,t){let n=new IncomingMessage,r=new ServerResponse(t);n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let i=e.header_pairs??[];for(let e=0;e+1<i.length;e+=2){let t=i[e],r=i[e+1],a=t.toLowerCase();if(n.rawHeaders.push(t,r),a in n.headers){let e=n.headers[a];Array.isArray(e)?e.push(r):n.headers[a]=[e,r]}else n.headers[a]=r}n.socket=new ServerRequestSocket(e.remote_address??`127.0.0.1`,e.remote_port??0,this._address?.address??`127.0.0.1`,this._address?.port??0,t);let a=e.get_body();a.length>0?n._pushBody(a):n._pushBody(null),e.connect(`aborted_signal`,()=>{n.aborted||(n.aborted=!0,n.emit(`aborted`))}),e.connect(`close`,()=>{n.emit(`close`)});try{let e=this.emit(`request`,n,r);(e instanceof Promise||typeof e==`object`&&e&&typeof e.then==`function`)&&e.catch(e=>{if(F.error(`[HTTP] Unhandled error in async request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}})}catch(e){if(F.error(`[HTTP] Unhandled error in request handler:`,e),!r.headersSent)try{r.writeHead(500),r.end(`Internal Server Error`)}catch{}}}_handleUpgrade(e,t){let n=new IncomingMessage;n.method=e.method,n.url=e.url,n.httpVersion=`1.1`;let r=e.header_pairs??[];for(let e=0;e+1<r.length;e+=2){let t=r[e],i=r[e+1],a=t.toLowerCase();n.rawHeaders.push(t,i),n.headers[a]=i}if(this.listenerCount(`upgrade`)>0){let e=new Socket;e._attachOutputOnly(t),this.emit(`upgrade`,n,e,q.alloc(0))}}address(){return this._address}addWebSocketHandler(e,t){if(!this._bridge)throw Error(`Server must be listening before adding WebSocket handlers. Call listen() first.`);this._bridge.soup_server.add_websocket_handler(e,null,null,(e,n,r,i)=>{t(i)})}close(e){return e&&this.once(`close`,e),this._bridge&&=(this._bridge.close(),null),this.listening=!1,_u.delete(this),deferEmit(this,`close`),this}setTimeout(e,t){return this.timeout=e,t&&this.on(`timeout`,t),this}}}),yu,bu=__esmMin(()=>{yu=u}),xu,Su=__esmMin(()=>{bu(),xu=yu}),ClientRequest,Cu=__esmMin(()=>{fu(),vu(),A(),Su(),N(),J(),On(),L(),ClientRequest=class extends OutgoingMessage{method;path;protocol;host;hostname;port;aborted=!1;reusedSocket=!1;maxHeadersCount=2e3;_chunks=[];_session;_message;_cancellable;_timeout=0;_timeoutTimer=null;_responseCallback;constructor(e,t,n){super();let r;if(typeof e==`string`||e instanceof Z){let i=typeof e==`string`?new Z(e):e;r={protocol:i.protocol,hostname:i.hostname,port:i.port?Number(i.port):void 0,path:i.pathname+i.search,...typeof t==`object`?t:{}},typeof t==`function`&&(n=t)}else r=e,typeof t==`function`&&(n=t);if(this.method=(r.method||`GET`).toUpperCase(),this.protocol=r.protocol||`http:`,this.hostname=r.hostname||r.host?.split(`:`)[0]||`localhost`,this.port=Number(r.port)||(this.protocol===`https:`?443:80),this.path=r.path||`/`,this.host=r.host||`${this.hostname}:${this.port}`,this._timeout=r.timeout||0,n&&(this._responseCallback=n,this.once(`response`,n)),r.headers)for(let[e,t]of Object.entries(r.headers))this.setHeader(e,t);if(r.setHost!==!1&&!this._headers.has(`host`)){let e=this.protocol===`https:`?443:80,t=this.port===e?this.hostname:`${this.hostname}:${this.port}`;this.setHeader(`Host`,t)}r.auth&&!this._headers.has(`authorization`)&&this.setHeader(`Authorization`,`Basic `+q.from(r.auth).toString(`base64`)),r.signal&&(r.signal.aborted?this.abort():r.signal.addEventListener(`abort`,()=>this.abort(),{once:!0}));let i=k.Uri.parse(this._buildUrl(),k.UriFlags.NONE);this._session=new xu.Session,this._message=new xu.Message({method:this.method,uri:i}),this._cancellable=new M.Cancellable,this._timeout>0&&(this._session.timeout=Math.ceil(this._timeout/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},this._timeout))}_buildUrl(){let e=this.protocol.endsWith(`:`)?this.protocol:this.protocol+`:`,t=e===`https:`?443:80,n=this.port===t?``:`:${this.port}`;return`${e}//${this.hostname}${n}${this.path}`}getRawHeaderNames(){return Array.from(this._headers.keys())}flushHeaders(){this.headersSent||this._applyHeaders()}setTimeout(e,t){return this._timeout=e,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),t&&this.once(`timeout`,t),e>0&&(this._session.timeout=Math.ceil(e/1e3),this._timeoutTimer=setTimeout(()=>{this._timeoutTimer=null,this.emit(`timeout`)},e)),this}abort(){this.aborted||(this.aborted=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this._cancellable.cancel(),this.emit(`abort`),this.destroy())}_write(e,t,n){let r=q.isBuffer(e)?e:typeof e==`string`?q.from(e,t):q.from(e);this._chunks.push(r),n()}_final(e){this._sendRequest().then(()=>e()).catch(t=>e(t))}_applyHeaders(){if(this.headersSent)return;this.headersSent=!0;let e=this._message.get_request_headers();for(let[t,n]of this._headers)if(Array.isArray(n))for(let r of n)e.append(t,r);else e.replace(t,n)}async _sendRequest(){this._applyHeaders();let e=q.concat(this._chunks);if(e.length>0){let t=this._headers.get(`content-type`)||`application/octet-stream`;this._message.set_request_body_from_bytes(t,new k.Bytes(e))}try{let e=await new Promise((e,t)=>{this._session.send_async(this._message,k.PRIORITY_DEFAULT,this._cancellable,(n,r)=>{try{e(this._session.send_finish(r))}catch(e){t(e)}})}),t=[];try{let n;for(;(n=await readBytesAsync(e,4096,k.PRIORITY_DEFAULT,this._cancellable))!==null;)t.push(q.from(n))}catch{}let n=new IncomingMessage;n.statusCode=this._message.status_code,n.statusMessage=this._message.get_reason_phrase(),n.httpVersion=`1.1`,this._message.get_response_headers().foreach((e,t)=>{let r=e.toLowerCase();if(n.rawHeaders.push(e,t),r in n.headers){let e=n.headers[r];Array.isArray(e)?e.push(t):n.headers[r]=[e,t]}else n.headers[r]=t}),this.finished=!0,this._timeoutTimer&&=(clearTimeout(this._timeoutTimer),null),this.emit(`response`,n),setTimeout(()=>{for(let e of t)n.push(e);n.push(null),n.complete=!0},0)}catch(e){this.aborted?this.emit(`abort`):this.emit(`error`,e instanceof Error?e:Error(String(e)))}}}});function validateHeaderName(e){if(typeof e!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let t=TypeError(`Header name must be a valid HTTP token ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),t}}function validateHeaderValue(e,t){if(t===void 0){let t=TypeError(`Header "${e}" value must not be undefined`);throw Object.defineProperty(t,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),t}if(typeof t==`string`&&/[^\t -~€-ÿ]/.test(t)){let t=TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(t,"code",{value:`ERR_INVALID_CHAR`}),t}}var wu=__esmMin(()=>{}),Tu=__exportAll$4({Agent:()=>Agent,ClientRequest:()=>ClientRequest,IncomingMessage:()=>IncomingMessage,METHODS:()=>uu,OutgoingMessage:()=>OutgoingMessage,STATUS_CODES:()=>lu,Server:()=>Server$1,ServerResponse:()=>ServerResponse,createServer:()=>createServer$1,default:()=>Ou,get:()=>get,globalAgent:()=>Eu,maxHeaderSize:()=>Du,request:()=>request,setMaxIdleHTTPParsers:()=>setMaxIdleHTTPParsers,validateHeaderName:()=>validateHeaderName,validateHeaderValue:()=>validateHeaderValue});function createServer$1(e,t){return typeof e==`function`?new Server$1(e):new Server$1(t)}function request(e,t,n){return new ClientRequest(e,t,n)}function get(e,t,n){let r,i=n;typeof e==`string`||e instanceof Z?(r=typeof t==`object`?{...t,method:`GET`}:{method:`GET`},typeof t==`function`&&(i=t)):(r={...e,method:`GET`},typeof t==`function`&&(i=t),e=r);let a=typeof e==`string`||e instanceof Z?new ClientRequest(e,{...r,method:`GET`},i):new ClientRequest({...r,method:`GET`},i);return a.end(),a}function setMaxIdleHTTPParsers(e){}var Agent,Eu,Du,Ou,ku=__esmMin(()=>{du(),fu(),vu(),Cu(),wu(),On(),Agent=class{defaultPort=80;protocol=`http:`;maxSockets;maxTotalSockets;maxFreeSockets;keepAliveMsecs;keepAlive;scheduling;requests={};sockets={};freeSockets={};constructor(e){this.keepAlive=e?.keepAlive??!1,this.keepAliveMsecs=e?.keepAliveMsecs??1e3,this.maxSockets=e?.maxSockets??1/0,this.maxTotalSockets=e?.maxTotalSockets??1/0,this.maxFreeSockets=e?.maxFreeSockets??256,this.scheduling=e?.scheduling??`lifo`}destroy(){}getName(e){let t=e.host||`localhost`;return e.port&&(t+=`:`+e.port),e.localAddress&&(t+=`:`+e.localAddress),(e.family===4||e.family===6)&&(t+=`:`+e.family),t}},Eu=new Agent,__name(createServer$1,`createServer`),Du=16384,Ou={STATUS_CODES:lu,METHODS:uu,Server:Server$1,IncomingMessage,OutgoingMessage,ServerResponse,ClientRequest,Agent,globalAgent:Eu,createServer:createServer$1,request,get,validateHeaderName,validateHeaderValue,maxHeaderSize:Du,setMaxIdleHTTPParsers}}),Au=__commonJSMin(((e,t)=>{
201
201
  /*!
202
202
  * etag
203
203
  * Copyright(c) 2014-2016 Douglas Christopher Wilson
@@ -266,7 +266,7 @@ var n=nd(),r=rd(),i=id(),a=ad();t.exports=Negotiator,t.exports.Negotiator=Negoti
266
266
  * Copyright(c) 2015 Douglas Christopher Wilson
267
267
  * MIT Licensed
268
268
  */
269
- var n=od(),r=fs();t.exports=Accepts;function Accepts(e){if(!(this instanceof Accepts))return new Accepts(e);this.headers=e.headers,this.negotiator=new n(e)}Accepts.prototype.type=Accepts.prototype.types=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}if(!t||t.length===0)return this.negotiator.mediaTypes();if(!this.headers.accept)return t[0];var r=t.map(extToMime),i=this.negotiator.mediaTypes(r.filter(validMime))[0];return i?t[r.indexOf(i)]:!1},Accepts.prototype.encoding=Accepts.prototype.encodings=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.encodings():this.negotiator.encodings(t)[0]||!1},Accepts.prototype.charset=Accepts.prototype.charsets=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.charsets():this.negotiator.charsets(t)[0]||!1},Accepts.prototype.lang=Accepts.prototype.langs=Accepts.prototype.language=Accepts.prototype.languages=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.languages():this.negotiator.languages(t)[0]||!1};function extToMime(e){return e.indexOf(`/`)===-1?r.lookup(e):e}function validMime(e){return typeof e==`string`}})),cd,Server,ld=__esmMin(()=>{mu(),N(),L(),bn(),cd=new Set,Server=class extends Y{listening=!1;maxConnections;allowHalfOpen;_service=null;_connections=new Set;_address=null;constructor(e,t){super(),typeof e==`function`?(t=e,this.allowHalfOpen=!1):this.allowHalfOpen=e?.allowHalfOpen??!1,t&&this.on(`connection`,t)}listen(...e){let t=0,n=`0.0.0.0`,r=511,i;if(typeof e[0]==`object`&&e[0]!==null&&!Array.isArray(e[0])){let a=e[0];t=a.port??0,n=a.host??`0.0.0.0`,r=a.backlog??511,i=e[1]}else{typeof e[0]==`number`&&(t=e[0]);for(let t=1;t<e.length;t++)typeof e[t]==`string`?n=e[t]:typeof e[t]==`number`?r=e[t]:typeof e[t]==`function`&&(i=e[t])}i&&this.once(`listening`,i);try{this._service=new M.SocketService,this._service.set_backlog(r);let e;t===0?e=this._service.add_any_inet_port(null):(this._service.add_inet_port(t,null),e=t),this._service.connect(`incoming`,(e,t)=>(this._handleConnection(t),!0)),this._service.start(),ensureMainLoop(),this.listening=!0,cd.add(this);let i=n.includes(`:`)?`IPv6`:`IPv4`;this._address={port:e,family:i,address:n},deferEmit(this,`listening`)}catch(e){let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_handleConnection(e){if(this.maxConnections&&this._connections.size>=this.maxConnections){try{e.close(null)}catch{}return}let t=new Socket({allowHalfOpen:this.allowHalfOpen});t._setConnection(e),t._setupConnection({}),this._connections.add(t),t.on(`close`,()=>{this._connections.delete(t)}),this.emit(`connection`,t)}address(){return this._address}close(e){if(e&&this.once(`close`,e),!this._service||!this.listening)return setTimeout(()=>{let e=Error(`Server is not running`);e.code=`ERR_SERVER_NOT_RUNNING`,this.emit(`error`,e)},0),this;this._service.stop(),this._service.close(),this._service=null,this.listening=!1,cd.delete(this);for(let e of this._connections)e.destroy();return this._connections.clear(),deferEmit(this,`close`),this}getConnections(e){e(null,this._connections.size)}ref(){return this}unref(){return this}}}),ud=__exportAll$4({Server:()=>Server,Socket:()=>Socket,connect:()=>dd,createConnection:()=>createConnection,createServer:()=>createServer,default:()=>fd,isIP:()=>isIP,isIPv4:()=>isIPv4,isIPv6:()=>isIPv6});function isIP(e){if(typeof e!=`string`)return 0;let t=e.includes(`%`)?e.split(`%`)[0]:e,n=M.InetAddress.new_from_string(t);if(!n)return 0;switch(n.get_family()){case M.SocketFamily.INVALID:return 0;case M.SocketFamily.IPV4:return 4;case M.SocketFamily.IPV6:return 6}}function isIPv4(e){return isIP(e)===4}function isIPv6(e){return isIP(e)===6}function createConnection(e,t,n){return new Socket().connect(e,t,n)}function createServer(e,t){return new Server(e,t)}var dd,fd,pd=__esmMin(()=>{mu(),ld(),N(),dd=createConnection,fd={Socket,Server,isIP,isIPv4,isIPv6,createConnection,connect:dd,createServer}}),md=__commonJSMin(((e,t)=>{
269
+ var n=od(),r=fs();t.exports=Accepts;function Accepts(e){if(!(this instanceof Accepts))return new Accepts(e);this.headers=e.headers,this.negotiator=new n(e)}Accepts.prototype.type=Accepts.prototype.types=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}if(!t||t.length===0)return this.negotiator.mediaTypes();if(!this.headers.accept)return t[0];var r=t.map(extToMime),i=this.negotiator.mediaTypes(r.filter(validMime))[0];return i?t[r.indexOf(i)]:!1},Accepts.prototype.encoding=Accepts.prototype.encodings=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.encodings():this.negotiator.encodings(t)[0]||!1},Accepts.prototype.charset=Accepts.prototype.charsets=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.charsets():this.negotiator.charsets(t)[0]||!1},Accepts.prototype.lang=Accepts.prototype.langs=Accepts.prototype.language=Accepts.prototype.languages=function(e){var t=e;if(t&&!Array.isArray(t)){t=Array(arguments.length);for(var n=0;n<t.length;n++)t[n]=arguments[n]}return!t||t.length===0?this.negotiator.languages():this.negotiator.languages(t)[0]||!1};function extToMime(e){return e.indexOf(`/`)===-1?r.lookup(e):e}function validMime(e){return typeof e==`string`}})),cd,Server,ld=__esmMin(()=>{mu(),N(),L(),bn(),cd=new Set,Server=class extends Y{listening=!1;maxConnections;allowHalfOpen;_service=null;_connections=new Set;_address=null;constructor(e,t){super(),typeof e==`function`?(t=e,this.allowHalfOpen=!1):this.allowHalfOpen=e?.allowHalfOpen??!1,t&&this.on(`connection`,t)}listen(...e){let t=0,n=`0.0.0.0`,r=511,i;if(typeof e[0]==`object`&&e[0]!==null&&!Array.isArray(e[0])){let a=e[0];t=a.port??0,n=a.host??`0.0.0.0`,r=a.backlog??511,i=e[1]}else{typeof e[0]==`number`&&(t=e[0]);for(let t=1;t<e.length;t++)typeof e[t]==`string`?n=e[t]:typeof e[t]==`number`?r=e[t]:typeof e[t]==`function`&&(i=e[t])}i&&this.once(`listening`,i);try{this._service=new M.SocketService,this._service.set_backlog(r);let e;t===0?e=this._service.add_any_inet_port(null):(this._service.add_inet_port(t,null),e=t),this._service.connect(`incoming`,(e,t)=>(this._handleConnection(t),!0)),this._service.start(),ensureMainLoop(),this.listening=!0,cd.add(this);let i=n.includes(`:`)?`IPv6`:`IPv4`;this._address={port:e,family:i,address:n},deferEmit(this,`listening`)}catch(e){let r=createNodeError$1(e,`listen`,{address:n,port:t});deferEmit(this,`error`,r)}return this}_handleConnection(e){if(this.maxConnections&&this._connections.size>=this.maxConnections){try{e.close(null)}catch{}return}let t=new Socket({allowHalfOpen:this.allowHalfOpen});t._setConnection(e),t._setupConnection({}),this._connections.add(t),t.on(`close`,()=>{this._connections.delete(t)}),this.emit(`connection`,t)}address(){return this._address}close(e){if(e&&this.once(`close`,e),!this._service||!this.listening)return setTimeout(()=>{let e=Error(`Server is not running`);e.code=`ERR_SERVER_NOT_RUNNING`,this.emit(`error`,e)},0),this;this._service.stop(),this._service.close(),this._service=null,this.listening=!1,cd.delete(this);for(let e of this._connections)e.destroy();return this._connections.clear(),deferEmit(this,`close`),this}getConnections(e){e(null,this._connections.size)}ref(){return this}unref(){return this}}}),ud=__exportAll$4({Server:()=>Server,Socket:()=>Socket,connect:()=>dd,createConnection:()=>createConnection,createServer:()=>createServer,default:()=>fd,isIP:()=>isIP,isIPv4:()=>isIPv4,isIPv6:()=>isIPv6});function isIP(e){if(typeof e!=`string`)return 0;let t=e.includes(`%`)?e.split(`%`)[0]:e,n=M.InetAddress.new_from_string(t);if(!n)return 0;switch(n.get_family()){case M.SocketFamily.INVALID:return 0;case M.SocketFamily.IPV4:return 4;case M.SocketFamily.IPV6:return 6}}function isIPv4(e){return isIP(e)===4}function isIPv6(e){return isIP(e)===6}function createConnection(e,t,n){return new Socket().connect(e,t,n)}function createServer(e,t){return typeof e==`function`?new Server(e):new Server(e,t)}var dd,fd,pd=__esmMin(()=>{mu(),ld(),N(),dd=createConnection,fd={Socket,Server,isIP,isIPv4,isIPv6,createConnection,connect:dd,createServer}}),md=__commonJSMin(((e,t)=>{
270
270
  /*!
271
271
  * fresh
272
272
  * Copyright(c) 2012 TJ Holowaychuk
@@ -331,7 +331,7 @@ t.exports=vary,t.exports.append=append;var n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;fu
331
331
  * Copyright(c) 2014-2015 Douglas Christopher Wilson
332
332
  * MIT Licensed
333
333
  */
334
- var n=_d(),r=xo(),i=ho()(`express`),a=gl(),o=_l(),s=(ku(),__toCommonJS(Tu)),c=ss(),l=fs(),u=(uo(),__toCommonJS(Ya)),d=(uo(),__toCommonJS(Ya)).isAbsolute,p=vo(),m=vd().sign,h=Ku().normalizeType,g=Ku().normalizeTypes,_=Ku().setCharset,v=yd(),y=bd(),b=u.extname,x=u.resolve,S=xd();let{Buffer:w}=(J(),__toCommonJS(Xt));var T=Object.create(s.ServerResponse.prototype);t.exports=T,T.status=function status(e){if(!Number.isInteger(e))throw TypeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be an integer.`);if(e<100||e>999)throw RangeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be greater than 99 and less than 1000.`);return this.statusCode=e,this},T.links=function(e){var t=this.get(`Link`)||``;return t&&(t+=`, `),this.set(`Link`,t+Object.keys(e).map(function(t){return Array.isArray(e[t])?e[t].map(function(e){return`<${e}>; rel="${t}"`}).join(`, `):`<${e[t]}>; rel="${t}"`}).join(`, `))},T.send=function send(e){var t=e,n,r=this.req,i,a=this.app;switch(typeof t){case`string`:this.get(`Content-Type`)||this.type(`html`);break;case`boolean`:case`number`:case`object`:if(t===null)t=``;else if(ArrayBuffer.isView(t))this.get(`Content-Type`)||this.type(`bin`);else return this.json(t);break}typeof t==`string`&&(n=`utf8`,i=this.get(`Content-Type`),typeof i==`string`&&this.set(`Content-Type`,_(i,`utf-8`)));var o=a.get(`etag fn`),s=!this.get(`ETag`)&&typeof o==`function`,c;t!==void 0&&(w.isBuffer(t)?c=t.length:!s&&t.length<1e3?c=w.byteLength(t,n):(t=w.from(t,n),n=void 0,c=t.length),this.set(`Content-Length`,c));var l;return s&&c!==void 0&&(l=o(t,n))&&this.set(`ETag`,l),r.fresh&&this.status(304),(this.statusCode===204||this.statusCode===304)&&(this.removeHeader(`Content-Type`),this.removeHeader(`Content-Length`),this.removeHeader(`Transfer-Encoding`),t=``),this.statusCode===205&&(this.set(`Content-Length`,`0`),this.removeHeader(`Transfer-Encoding`),t=``),r.method===`HEAD`?this.end():this.end(t,n),this},T.json=function json(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n);return this.get(`Content-Type`)||this.set(`Content-Type`,`application/json`),this.send(r)},T.jsonp=function jsonp(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n),i=this.req.query[t.get(`jsonp callback name`)];return this.get(`Content-Type`)||(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`application/json`)),Array.isArray(i)&&(i=i[0]),typeof i==`string`&&i.length!==0&&(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`text/javascript`),i=i.replace(/[^\[\]\w$.]/g,``),r===void 0?r=``:typeof r==`string`&&(r=r.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)),r=`/**/ typeof `+i+` === 'function' && `+i+`(`+r+`);`),this.send(r)},T.sendStatus=function sendStatus(e){var t=p.message[e]||String(e);return this.status(e),this.type(`txt`),this.send(t)},T.sendFile=function sendFile(e,t,n){var r=n,i=this.req,a=this,o=i.next,s=t||{};if(!e)throw TypeError(`path argument is required to res.sendFile`);if(typeof e!=`string`)throw TypeError(`path must be a string to res.sendFile`);if(typeof t==`function`&&(r=t,s={}),!s.root&&!d(e))throw TypeError(`path must be absolute or specify root to res.sendFile`);var c=encodeURI(e);s.etag=this.app.enabled(`etag`),sendfile(a,y(i,c,s),s,function(e){if(r)return r(e);if(e&&e.code===`EISDIR`)return o();e&&e.code!==`ECONNABORTED`&&e.syscall!==`write`&&o(e)})},T.download=function download(e,t,r,i){var a=i,o=t,s=r||null;typeof t==`function`?(a=t,o=null,s=null):typeof r==`function`&&(a=r,s=null),typeof t==`object`&&(typeof r==`function`||r===void 0)&&(o=null,s=t);var c={"Content-Disposition":n(o||e)};if(s&&s.headers)for(var l=Object.keys(s.headers),u=0;u<l.length;u++){var d=l[u];d.toLowerCase()!==`content-disposition`&&(c[d]=s.headers[d])}s=Object.create(s),s.headers=c;var p=s.root?e:x(e);return this.sendFile(p,s,a)},T.contentType=T.type=function contentType(e){var t=e.indexOf(`/`)===-1?l.contentType(e)||`application/octet-stream`:e;return this.set(`Content-Type`,t)},T.format=function(e){var t=this.req,n=t.next,i=Object.keys(e).filter(function(e){return e!==`default`}),a=i.length>0?t.accepts(i):!1;return this.vary(`Accept`),a?(this.set(`Content-Type`,h(a).value),e[a](t,this,n)):e.default?e.default(t,this,n):n(r(406,{types:g(i).map(function(e){return e.value})})),this},T.attachment=function attachment(e){return e&&this.type(b(e)),this.set(`Content-Disposition`,n(e)),this},T.append=function append(e,t){var n=this.get(e),r=t;return n&&(r=Array.isArray(n)?n.concat(t):Array.isArray(t)?[n].concat(t):[n,t]),this.set(e,r)},T.set=T.header=function header(e,t){if(arguments.length===2){var n=Array.isArray(t)?t.map(String):String(t);if(e.toLowerCase()===`content-type`){if(Array.isArray(n))throw TypeError(`Content-Type cannot be set to an Array`);n=l.contentType(n)}this.setHeader(e,n)}else for(var r in e)this.set(r,e[r]);return this},T.get=function(e){return this.getHeader(e)},T.clearCookie=function clearCookie(e,t){let n={path:`/`,...t,expires:new Date(1)};return delete n.maxAge,this.cookie(e,``,n)},T.cookie=function(e,t,n){var r={...n},i=this.req.secret,a=r.signed;if(a&&!i)throw Error(`cookieParser("secret") required for signed cookies`);var o=typeof t==`object`?`j:`+JSON.stringify(t):String(t);if(a&&(o=`s:`+m(o,i)),r.maxAge!=null){var s=r.maxAge-0;isNaN(s)||(r.expires=new Date(Date.now()+s),r.maxAge=Math.floor(s/1e3))}return r.path??=`/`,this.append(`Set-Cookie`,v.serialize(e,String(o),r)),this},T.location=function location(e){return this.set(`Location`,a(e))},T.redirect=function redirect(e){var t=e,n,r=302;arguments.length===2&&(r=arguments[0],t=arguments[1]),t||i(`Provide a url argument`),typeof t!=`string`&&i(`Url must be a string`),typeof r!=`number`&&i(`Status must be a number`),t=this.location(t).get(`Location`),this.format({text:function(){n=p.message[r]+`. Redirecting to `+t},html:function(){var e=o(t);n=`<p>`+p.message[r]+`. Redirecting to `+e+`</p>`},default:function(){n=``}}),this.status(r),this.set(`Content-Length`,w.byteLength(n)),this.req.method===`HEAD`?this.end():this.end(n)},T.vary=function(e){return S(this,e),this},T.render=function render(e,t,n){var r=this.req.app,done=n,i=t||{},a=this.req,o=this;typeof t==`function`&&(done=t,i={}),i._locals=o.locals,done||=function(e,t){if(e)return a.next(e);o.send(t)},r.render(e,i,done)};function sendfile(e,t,n,r){var i=!1,a;function onaborted(){if(!i){i=!0;var e=Error(`Request aborted`);e.code=`ECONNABORTED`,r(e)}}function ondirectory(){if(!i){i=!0;var e=Error(`EISDIR, read`);e.code=`EISDIR`,r(e)}}function onerror(e){i||(i=!0,r(e))}function onend(){i||(i=!0,r())}function onfile(){a=!1}function onfinish(e){if(e&&e.code===`ECONNRESET`)return onaborted();if(e)return onerror(e);i||setImmediate(function(){if(a!==!1&&!i){onaborted();return}i||(i=!0,r())})}function onstream(){a=!0}t.on(`directory`,ondirectory),t.on(`end`,onend),t.on(`error`,onerror),t.on(`file`,onfile),t.on(`stream`,onstream),c(e,onfinish),n.headers&&t.on(`headers`,function headers(e){for(var t=n.headers,r=Object.keys(t),i=0;i<r.length;i++){var a=r[i];e.setHeader(a,t[a])}}),t.pipe(e)}function stringify(e,t,n,r){var i=t||n?JSON.stringify(e,t,n):JSON.stringify(e);return r&&typeof i==`string`&&(i=i.replace(/[<>&]/g,function(e){switch(e.charCodeAt(0)){case 60:return`\\u003c`;case 62:return`\\u003e`;case 38:return`\\u0026`;default:return e}})),i}})),Cd=__commonJSMin(((e,t)=>{
334
+ var n=_d(),r=xo(),i=ho()(`express`),a=gl(),o=_l(),s=(ku(),__toCommonJS(Tu)),c=ss(),l=fs(),u=(uo(),__toCommonJS(Ya)),d=(uo(),__toCommonJS(Ya)).isAbsolute,p=vo(),m=vd().sign,h=Ku().normalizeType,g=Ku().normalizeTypes,_=Ku().setCharset,v=yd(),y=bd(),b=u.extname,x=u.resolve,S=xd();let{Buffer:w}=(J(),__toCommonJS(Xt));var T=Object.create(s.ServerResponse.prototype);t.exports=T,T.status=function status(e){if(!Number.isInteger(e))throw TypeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be an integer.`);if(e<100||e>999)throw RangeError(`Invalid status code: ${JSON.stringify(e)}. Status code must be greater than 99 and less than 1000.`);return this.statusCode=e,this},T.links=function(e){var t=this.get(`Link`)||``;return t&&(t+=`, `),this.set(`Link`,t+Object.keys(e).map(function(t){return Array.isArray(e[t])?e[t].map(function(e){return`<${e}>; rel="${t}"`}).join(`, `):`<${e[t]}>; rel="${t}"`}).join(`, `))},T.send=function send(e){var t=e,n,r=this.req,i,a=this.app;switch(typeof t){case`string`:this.get(`Content-Type`)||this.type(`html`);break;case`boolean`:case`number`:case`object`:if(t===null)t=``;else if(ArrayBuffer.isView(t))this.get(`Content-Type`)||this.type(`bin`);else return this.json(t);break}typeof t==`string`&&(n=`utf8`,i=this.get(`Content-Type`),typeof i==`string`&&this.set(`Content-Type`,_(i,`utf-8`)));var o=a.get(`etag fn`),s=!this.get(`ETag`)&&typeof o==`function`,c;t!==void 0&&(w.isBuffer(t)?c=t.length:!s&&t.length<1e3?c=w.byteLength(t,n):(t=w.from(t,n),n=void 0,c=t.length),this.set(`Content-Length`,c));var l;return s&&c!==void 0&&(l=o(t,n))&&this.set(`ETag`,l),r.fresh&&this.status(304),(this.statusCode===204||this.statusCode===304)&&(this.removeHeader(`Content-Type`),this.removeHeader(`Content-Length`),this.removeHeader(`Transfer-Encoding`),t=``),this.statusCode===205&&(this.set(`Content-Length`,`0`),this.removeHeader(`Transfer-Encoding`),t=``),r.method===`HEAD`?this.end():this.end(t,n),this},T.json=function json(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n);return this.get(`Content-Type`)||this.set(`Content-Type`,`application/json`),this.send(r)},T.jsonp=function jsonp(e){var t=this.app,n=t.get(`json escape`),r=stringify(e,t.get(`json replacer`),t.get(`json spaces`),n),i=this.req.query[t.get(`jsonp callback name`)];return this.get(`Content-Type`)||(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`application/json`)),Array.isArray(i)&&(i=i[0]),typeof i==`string`&&i.length!==0&&(this.set(`X-Content-Type-Options`,`nosniff`),this.set(`Content-Type`,`text/javascript`),i=i.replace(/[^\[\]\w$.]/g,``),r===void 0?r=``:typeof r==`string`&&(r=r.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)),r=`/**/ typeof `+i+` === 'function' && `+i+`(`+r+`);`),this.send(r)},T.sendStatus=function sendStatus(e){var t=p.message[e]||String(e);return this.status(e),this.type(`txt`),this.send(t)},T.sendFile=function sendFile(e,t,n){var r=n,i=this.req,a=this,o=i.next,s=t||{};if(!e)throw TypeError(`path argument is required to res.sendFile`);if(typeof e!=`string`)throw TypeError(`path must be a string to res.sendFile`);if(typeof t==`function`&&(r=t,s={}),!s.root&&!d(e))throw TypeError(`path must be absolute or specify root to res.sendFile`);var c=encodeURI(e);s.etag=this.app.enabled(`etag`),sendfile(a,y(i,c,s),s,function(e){if(r)return r(e);if(e&&e.code===`EISDIR`)return o();e&&e.code!==`ECONNABORTED`&&e.syscall!==`write`&&o(e)})},T.download=function download(e,t,r,i){var a=i,o=t,s=r||null;typeof t==`function`?(a=t,o=null,s=null):typeof r==`function`&&(a=r,s=null),typeof t==`object`&&(typeof r==`function`||r===void 0)&&(o=null,s=t);var c={"Content-Disposition":n(o||e)};if(s&&s.headers)for(var l=Object.keys(s.headers),u=0;u<l.length;u++){var d=l[u];d.toLowerCase()!==`content-disposition`&&(c[d]=s.headers[d])}s=Object.create(s),s.headers=c;var p=s.root?e:x(e);return this.sendFile(p,s,a)},T.contentType=T.type=function contentType(e){var t=e.indexOf(`/`)===-1?l.contentType(e)||`application/octet-stream`:e;return this.set(`Content-Type`,t)},T.format=function(e){var t=this.req,n=t.next,i=Object.keys(e).filter(function(e){return e!=="default"}),a=i.length>0?t.accepts(i):!1;return this.vary(`Accept`),a?(this.set(`Content-Type`,h(a).value),e[a](t,this,n)):e.default?e.default(t,this,n):n(r(406,{types:g(i).map(function(e){return e.value})})),this},T.attachment=function attachment(e){return e&&this.type(b(e)),this.set(`Content-Disposition`,n(e)),this},T.append=function append(e,t){var n=this.get(e),r=t;return n&&(r=Array.isArray(n)?n.concat(t):Array.isArray(t)?[n].concat(t):[n,t]),this.set(e,r)},T.set=T.header=function header(e,t){if(arguments.length===2){var n=Array.isArray(t)?t.map(String):String(t);if(e.toLowerCase()===`content-type`){if(Array.isArray(n))throw TypeError(`Content-Type cannot be set to an Array`);n=l.contentType(n)}this.setHeader(e,n)}else for(var r in e)this.set(r,e[r]);return this},T.get=function(e){return this.getHeader(e)},T.clearCookie=function clearCookie(e,t){let n={path:`/`,...t,expires:new Date(1)};return delete n.maxAge,this.cookie(e,``,n)},T.cookie=function(e,t,n){var r={...n},i=this.req.secret,a=r.signed;if(a&&!i)throw Error(`cookieParser("secret") required for signed cookies`);var o=typeof t==`object`?`j:`+JSON.stringify(t):String(t);if(a&&(o=`s:`+m(o,i)),r.maxAge!=null){var s=r.maxAge-0;isNaN(s)||(r.expires=new Date(Date.now()+s),r.maxAge=Math.floor(s/1e3))}return r.path??=`/`,this.append(`Set-Cookie`,v.serialize(e,String(o),r)),this},T.location=function location(e){return this.set(`Location`,a(e))},T.redirect=function redirect(e){var t=e,n,r=302;arguments.length===2&&(r=arguments[0],t=arguments[1]),t||i(`Provide a url argument`),typeof t!=`string`&&i(`Url must be a string`),typeof r!=`number`&&i(`Status must be a number`),t=this.location(t).get(`Location`),this.format({text:function(){n=p.message[r]+`. Redirecting to `+t},html:function(){var e=o(t);n=`<p>`+p.message[r]+`. Redirecting to `+e+`</p>`},default:function(){n=``}}),this.status(r),this.set(`Content-Length`,w.byteLength(n)),this.req.method===`HEAD`?this.end():this.end(n)},T.vary=function(e){return S(this,e),this},T.render=function render(e,t,n){var r=this.req.app,done=n,i=t||{},a=this.req,o=this;typeof t==`function`&&(done=t,i={}),i._locals=o.locals,done||=function(e,t){if(e)return a.next(e);o.send(t)},r.render(e,i,done)};function sendfile(e,t,n,r){var i=!1,a;function onaborted(){if(!i){i=!0;var e=Error(`Request aborted`);e.code=`ECONNABORTED`,r(e)}}function ondirectory(){if(!i){i=!0;var e=Error(`EISDIR, read`);e.code=`EISDIR`,r(e)}}function onerror(e){i||(i=!0,r(e))}function onend(){i||(i=!0,r())}function onfile(){a=!1}function onfinish(e){if(e&&e.code===`ECONNRESET`)return onaborted();if(e)return onerror(e);i||setImmediate(function(){if(a!==!1&&!i){onaborted();return}i||(i=!0,r())})}function onstream(){a=!0}t.on(`directory`,ondirectory),t.on(`end`,onend),t.on(`error`,onerror),t.on(`file`,onfile),t.on(`stream`,onstream),c(e,onfinish),n.headers&&t.on(`headers`,function headers(e){for(var t=n.headers,r=Object.keys(t),i=0;i<r.length;i++){var a=r[i];e.setHeader(a,t[a])}}),t.pipe(e)}function stringify(e,t,n,r){var i=t||n?JSON.stringify(e,t,n):JSON.stringify(e);return r&&typeof i==`string`&&(i=i.replace(/[<>&]/g,function(e){switch(e.charCodeAt(0)){case 60:return`\\u003c`;case 62:return`\\u003e`;case 38:return`\\u0026`;default:return e}})),i}})),Cd=__commonJSMin(((e,t)=>{
335
335
  /*!
336
336
  * serve-static
337
337
  * Copyright(c) 2010 Sencha Inc.