@gjsify/example-node-express-webserver 0.54.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.gjs.js CHANGED
@@ -8,7 +8,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispos
8
8
  `+t)}profile(e){}profileEnd(e){}timeStamp(e){}},j=new Console,log=(...e)=>j.log(...e),info=(...e)=>j.info(...e),debug=(...e)=>j.debug(...e),warn=(...e)=>j.warn(...e),error=(...e)=>j.error(...e),dir=(e,t)=>j.dir(e,t),dirxml=(...e)=>j.dirxml(...e),table=(e,t)=>j.table(e,t),clear=()=>j.clear(),assert=(e,...t)=>j.assert(e,...t),trace=(...e)=>j.trace(...e),time=e=>j.time(e),timeEnd=e=>j.timeEnd(e),timeLog=(e,...t)=>j.timeLog(e,...t),count=e=>j.count(e),countReset=e=>j.countReset(e),group=(...e)=>j.group(...e),groupCollapsed=(...e)=>j.groupCollapsed(...e),groupEnd=()=>j.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),M,N=__esmMin(()=>{ae(),M={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),oe,se=__esmMin(()=>{oe=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function isWindowsPath(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function splitPathComponents(e){return isWindowsPath(e)?e.split(/[\\/]/):e.split(`/`)}function pathToFileUrlHref(e,t){let n=t?.windows??isWindowsPath(e),r=n?e.replace(/\\/g,`/`):e;if(n&&r.startsWith(`//`)){let e=r.indexOf(`/`,2);return`file://${e===-1?r.slice(2):r.slice(2,e)}${encodePathForFileUrl(e===-1?``:r.slice(e))}`}return`${r.startsWith(`/`)?`file://`:`file:///`}${encodePathForFileUrl(r)}`}function encodePathForFileUrl(e){let t=``;for(let n of e)t+=ce.test(n)?n:percentEncode$1(n);return t}function percentEncode$1(e){let t=``;for(let n of new TextEncoder().encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}var ce,le=__esmMin(()=>{ce=/^[A-Za-z0-9!$&'()*+,\-./:;=@_]$/,__name(percentEncode$1,`percentEncode`)});function mapSysname(e){let t=e.trim();switch(t){case`Linux`:return`linux`;case`Darwin`:return`darwin`;case`FreeBSD`:return`freebsd`;case`OpenBSD`:return`openbsd`;case`NetBSD`:return`netbsd`;case`SunOS`:return`sunos`;case`AIX`:return`aix`;case`Haiku`:return`haiku`;default:return/^CYGWIN/i.test(t)?`cygwin`:/^(MINGW|MSYS|Windows)/i.test(t)?`win32`:void 0}}function mapMachine(e){let t=e.trim().toLowerCase();switch(t){case`x86_64`:case`amd64`:return`x64`;case`aarch64`:case`arm64`:return`arm64`;case`i386`:case`i486`:case`i586`:case`i686`:return`ia32`;case`ppc64le`:case`ppc64`:return`ppc64`;case`s390x`:return`s390x`;case`riscv64`:return`riscv64`;case`loongarch64`:return`loong64`;case`mipsel`:return`mipsel`;case`mips`:return`mips`;default:return t.startsWith(`arm`)?`arm`:void 0}}var ue=__esmMin(()=>{});function classOf(e){return de.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 o=classOf(i);if(o===`Date`)return new Date(i.getTime());if(o===`RegExp`)return new RegExp(i.source,i.flags);if(o===`Boolean`||o===`Number`||o===`String`)return Object(i.valueOf());if(o===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,o=new(r&&fe[r]||fe[e.name]||Error)(e.message);return o.name=e.name,`cause`in e&&Object.defineProperty(o,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),o}if(o===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(o===`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(o===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(o===`DataView`){let e=i,r=n?.viewSnapshots.get(i),o=internalClone(e.buffer,t,n),s=r?r.byteOffset:e.byteOffset,c=r?r.byteLength:e.byteLength,l=new DataView(o,s,c);return t.set(i,l),l}if(pe.has(o)){let e=i,r=n?.viewSnapshots.get(i),o=internalClone(e.buffer,t,n),s=e.constructor,c=new s(o,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,c),c}if(o===`Map`){let e=new Map;t.set(i,e);for(let[r,o]of i)e.set(internalClone(r,t,n),internalClone(o,t,n));return e}if(o===`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`),o===`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(o===`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(`${o} 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 o=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),o.set(e,t.transfer())}return internalClone(e,new Map,{transferred:o,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 o=classOf(i);if(o===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(pe.has(o)){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(o===`Map`){for(let[e,o]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(o,t,n,r);return}if(o===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(o===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}var de,fe,pe,me=__esmMin(()=>{({toString:de}=Object.prototype),fe={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},pe=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name(structuredClone$1,`structuredClone`)});function hostGlib(){try{return globalThis.imports?.gi?.GLib}catch{return}}function readText(e,t){try{let[n,r]=e.file_get_contents(t);return!n||!r?null:new TextDecoder().decode(r)}catch{return null}}function shellOut(e,t){try{let[n,r]=e.spawn_command_line_sync(t);if(!n||!r)return null;let i=new TextDecoder().decode(r).trim();return i.length>0?i:null}catch{return null}}function hasProcfs(){let e=hostGlib();if(!e)return!1;try{return e.file_test(`/proc/self/status`,16)}catch{return!1}}function hostPid(){if(he!==null)return he>0?he:void 0;let e=hostGlib();if(!e)return;let t=0,n=hasProcfs()?readText(e,`/proc/self/stat`):null;if(n)t=parseInt(n,10);else{let n=shellOut(e,`sh -c 'echo $PPID'`);n&&(t=parseInt(n,10))}return he=Number.isInteger(t)&&t>0?t:0,he>0?he:void 0}function hostPpid(){let e=hostGlib();if(!e)return;let t=hasProcfs()?readText(e,`/proc/self/status`):null;if(t){let e=/PPid:\s+(\d+)/.exec(t);if(e){let t=parseInt(e[1],10);return Number.isInteger(t)?t:void 0}}let n=hostPid();if(n===void 0)return;let r=shellOut(e,`ps -o ppid= -p ${n}`);if(!r)return;let i=parseInt(r,10);return Number.isInteger(i)?i:void 0}function hostExecPath(){let e=hostGlib();if(e){if(hasProcfs())try{let t=e.file_read_link(`/proc/self/exe`);if(t)return t}catch{}try{let t=e.get_prgname();if(t){let n=e.find_program_in_path(t);if(n)return n}}catch{return}}}function readProcessMemory(){let e=hostGlib();if(!e)return null;let t=hasProcfs()?readText(e,`/proc/self/status`):null;if(t){let e=new Map;for(let n of t.split(`
9
9
  `)){let t=/^(\w+):\s+(\d+)(\s+kB)?/.exec(n);t&&e.set(t[1],parseInt(t[2],10)*(t[3]?1024:1))}if(e.size>0)return{virtual:e.get(`VmSize`)??0,resident:e.get(`VmRSS`)??0,data:e.get(`VmData`)??0,peak:e.get(`VmPeak`)??0}}let n=shellOut(e,`sh -c 'ps -o rss=,vsz= -p $PPID'`);if(!n)return null;let r=/^(\d+)\s+(\d+)$/.exec(n);return r?{virtual:parseInt(r[2],10)*1024,resident:parseInt(r[1],10)*1024,data:0,peak:0}:null}var he,ge=__esmMin(()=>{he=null});function glib(){let e=globalThis;if(typeof e.process?.versions?.gjs==`string`||e.process===void 0)return e.imports?.gi?.GLib}function arm(e){ye||(ye=!0,e.runAsync().catch(()=>{}))}function ensureMainLoop(){let e=glib();if(e)return ve?_e:(_e=new e.MainLoop(null,!1),ve=!0,e.main_depth()===0&&arm(_e),_e)}function quitMainLoop(){_e&&=(_e.quit(),ve=!1,ye=!1,null)}var _e,ve,ye,be=__esmMin(()=>{_e=null,ve=!1,ye=!1});function hostGi(){return globalThis.imports?.gi}function directoryOf(e){return/^(.*)[\\/][^\\/]*$/.exec(e)?.[1]}function colocateNativeLibrary(e,t=hostGi()){try{let n=t?.GIRepository?.Repository?.dup_default?.(),r=n?.get_typelib_path(e),i=r?directoryOf(r):void 0;return!n||!i?!1:(n.prepend_library_path(i),!0)}catch{return!1}}function probeNativeLibrary(e,t=hostGi()){try{let n=t?.GIRepository?.Repository?.dup_default?.(),r=n?.get_typelib_path(e);if(!t||!n||!r)return null;let i=firstSymbol(n,e);if(!i||(t.GModule?.module_error(),i.info.get_typelib().symbol(i.name)[0]))return null;let o=directoryOf(r)??`.`,s=r.includes(`\\`)&&!r.includes(`/`)?`\\`:`/`;for(let c of n.get_shared_libraries(e)??[]){let n=`${o}${s}${c}`,l=t.GLib?.file_test(n,t.GLib.FileTest.EXISTS)?n:c,u=loaderError(t,e,r,l,i.name);if(u!==void 0)return{namespace:e,library:l,reason:u,missingDependency:missingLibraryDependency(u,l)}}let c=(n.get_shared_libraries(e)??[]).join(`, `)||`(none named)`;return{namespace:e,library:c,reason:`symbol ${i.name} not found in ${c}, and the loader reported no error`}}catch{return null}}function firstSymbol(e,t){let n=e.get_n_infos(t),r=null;for(let i=0;i<n;i++){let n=e.get_info(t,i),o=n.get_type_init_function_name?.();if(o)return{info:n,name:o};let s=n.get_symbol?.();s&&!r&&(r={info:n,name:s})}return r}function loaderError(e,t,n,r,i){let{GIRepository:o,GLib:s,GModule:c}=e;if(!o?.Repository||!o.Typelib||!s||!c)return;let[,l]=s.file_get_contents(n),u=new TextEncoder().encode(`${r}\0`),d=new Uint8Array(l.length+u.length);d.set(l),d.set(u,l.length);let p=new DataView(d.buffer);p.setUint32(40,d.length,!0),p.setUint32(52,l.length,!0);let m=new o.Repository,h=firstSymbol(m,m.load_typelib(o.Typelib.new_from_bytes(new s.Bytes(d)),0));if(h&&(c.module_error(),!h.info.get_typelib().symbol(i)[0]))return c.module_error()??`${t}: ${r} could not be opened (the loader reported no error)`}function missingLibraryDependency(e,t){let n=/Library not loaded: (\S+)/.exec(e)?.[1]??/Error loading shared library ([^\s:]+): .*\(needed by /.exec(e)?.[1]??/(?:^|\s)([^\s:]+): cannot open shared object file/.exec(e)?.[1];if(!n)return;let r=n.replace(/^.*[\\/]/,``);if(!(t&&r===t.replace(/^.*[\\/]/,``)))return r}function openNativeLibrary(e,t=hostGi()){colocateNativeLibrary(e,t);let n=probeNativeLibrary(e,t);return n?new NativeLibraryLoadError(n):null}function loadOptionalNativeModule(e,t,n=hostGi()){if(!n)return{module:null,error:Error(`${e}: imports.gi is not available (not running on GJS)`)};try{let r=n[e];if(!r)return{module:null,error:Error(`${e}: typelib not found`)};let i=openNativeLibrary(e,n);if(i)return M.debug(i.message),{module:null,error:i};for(let e of t)r[e];return{module:r,error:null}}catch(e){return{module:null,error:e instanceof Error?e:Error(String(e))}}}var NativeLibraryLoadError,xe=__esmMin(()=>{N(),NativeLibraryLoadError=class extends Error{failure;constructor(e,t){let n=e.missingDependency?`It needs ${e.missingDependency}, which the loader could not find: not installed, or not on its search path.`:`The loader could not open it.`;super(`${e.namespace}: the native library ${e.library} could not be loaded. ${n}\nLoader: ${e.reason.trim()}\n`+(t??"`gjsify system-check` lists the system libraries the installed @gjsify packages need, with the install command for this host.")),this.name=`NativeLibraryLoadError`,this.failure=e}}});function drainOnce(e){let t=Math.min(64,Se.length);for(let n=0;n<t;n++){let t=Se.shift();try{t()}catch(t){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(t?.stack||t),null)}catch{}}}Se.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):Ce=!1}function tryGLibTimeout(e){let t=globalThis.imports?.gi?.GLib;return t?.timeout_add?(Se.push(e),Ce||(Ce=!0,t.timeout_add(t.PRIORITY_DEFAULT,0,()=>(drainOnce(t),!1))),!0):!1}var Se,Ce,nextTick,we=__esmMin(()=>{Se=[],Ce=!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)}}}),P=__esmMin(()=>{E(),D(),ee(),k(),te(),ne(),se(),le(),ue(),me(),ge(),be(),xe(),we()});T(),P(),registerGlobal(`Blob`,S),registerGlobal(`File`,w);const Te={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=Te[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]),o=i[5]===`%`,s=i[6]===void 0?1:parseComponent(i[6],1);return e>1&&(e/=360),(n||t>1)&&(t/=100),(o||r>1)&&(r/=100),hslToRGBA(e,t,r,Math.max(0,Math.min(1,s)))}return null}function parseHex(e){let t=e.slice(1),n,r,i,o=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,o=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,o=parseInt(t.slice(6,8),16)/255;else return null;return{r:n,g:r,b:i,a:o}}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,o,s;if(t===0)i=o=s=n;else{let r=n<.5?n*(1+t):n+t-n*t,c=2*n-r;i=hue2rgb(c,r,e+1/3),o=hue2rgb(c,r,e),s=hue2rgb(c,r,e-1/3)}return{r:i,g:o,b:s,a:r}}const Ee={r:0,g:0,b:0,a:1};var CanvasGradient=class{constructor(t,n,r,i,o,s,c){t===`radial`?this._pattern=new e.RadialGradient(n,r,s,i,o,c):this._pattern=new e.LinearGradient(n,r,i,o)}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,o){return{cp1x:e+2/3*(n-e),cp1y:t+2/3*(r-t),cp2x:i+2/3*(n-i),cp2y:o+2/3*(r-o)}}function computeArcTo(e,t,n,r,i,o,s){let c=e-n,l=t-r,u=i-n,d=o-r,p=Math.sqrt(c*c+l*l),m=Math.sqrt(u*u+d*d);if(p===0||m===0)return null;let h=c/p,g=l/p,_=u/m,v=d/m,y=h*v-g*_;if(Math.abs(y)<1e-10)return null;let b=h*_+g*v,x=Math.acos(Math.max(-1,Math.min(1,b)))/2,S=s/Math.tan(x),w=n+h*S,T=r+g*S,E=n+_*S,D=r+v*S,ee=s/Math.sin(x),O=(h+_)/2,k=(g+v)/2,te=Math.sqrt(O*O+k*k),A=n+O/te*ee,ne=r+k/te*ee;return{tx0:w,ty0:T,tx1:E,ty1:D,cx:A,cy:ne,startAngle:Math.atan2(T-ne,w-A),endAngle:Math.atan2(D-ne,E-A),counterclockwise:y>0}}function cairoArcTo(e,t,n,r,i,o,s,c){let l=computeArcTo(t,n,r,i,o,s,c);if(!l){e.lineTo(r,i);return}let{tx0:u,ty0:d,cx:p,cy:m,startAngle:h,endAngle:g,counterclockwise:_}=l;e.lineTo(u,d),_?e.arcNegative(p,m,c,h,g):e.arc(p,m,c,h,g)}function cairoEllipse(e,t,n,r,i,o,s,c,l){e.save(),e.translate(t,n),e.rotate(o),e.scale(r,i),l?e.arcNegative(0,0,1,s,c):e.arc(0,0,1,s,c),e.restore()}function cairoRoundRect(e,t,n,r,i,o){let s,c,l,u;typeof o==`number`?s=c=l=u=o:o.length===1?s=c=l=u=o[0]:o.length===2?(s=l=o[0],c=u=o[1]):o.length===3?(s=o[0],c=u=o[1],l=o[2]):(s=o[0],c=o[1],l=o[2],u=o[3]);let d=Math.min(r/2,i/2);s=Math.min(s,d),c=Math.min(c,d),l=Math.min(l,d),u=Math.min(u,d);let p=Math.PI/2;e.newSubPath(),e.arc(t+s,n+s,s,Math.PI,Math.PI+p),e.arc(t+r-c,n+c,c,-p,0),e.arc(t+r-l,n+i-l,l,0,p),e.arc(t+u,n+i-u,u,p,Math.PI),e.closePath()}const De={"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},Oe={butt:0,round:1,square:2},ke={miter:0,round:1,bevel:2};var Ae=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,o){this._ops.push({type:`bezierCurveTo`,cp1x:e,cp1y:t,cp2x:n,cp2y:r,x:i,y:o})}quadraticCurveTo(e,t,n,r){this._ops.push({type:`quadraticCurveTo`,cpx:e,cpy:t,x:n,y:r})}arc(e,t,n,r,i,o=!1){this._ops.push({type:`arc`,x:e,y:t,radius:n,startAngle:r,endAngle:i,ccw:o})}ellipse(e,t,n,r,i,o,s,c=!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:o,endAngle:s,ccw:c})}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:o,cp2x:s,cp2y:c}=quadraticToCubic(t,n,r.cpx,r.cpy,r.x,r.y);e.curveTo(i,o,s,c,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`}let je=null;function setCanvasPixelBridge(e){je=e}function getCanvasPixelBridge(){if(!je)throw TypeError(`@gjsify/canvas2d-core: no pixel bridge registered — pixel operations (getImageData / putImageData / drawImage / createPattern) need a platform backend. On GJS, import '@gjsify/canvas2d-core/gdk' (or use '@gjsify/dom-elements' / '@gjsify/canvas2d', which register it for you).`);return je}var Me=class CanvasPattern{constructor(t,n){let r=asCairoPattern(new e.SurfacePattern(t));if(!r)throw TypeError(`CanvasPattern: cairo SurfacePattern is missing setExtend at runtime — incompatible Cairo binding`);switch(this._pattern=r,n){case`repeat`:case``:case null:r.setExtend(e.Extend.REPEAT);break;case`repeat-x`:case`repeat-y`:r.setExtend(e.Extend.REPEAT);break;case`no-repeat`:r.setExtend(e.Extend.NONE);break}}static create(t,n){if(isPixbufImageSource(t)){let r=t._pixbuf,i=r.get_width(),o=r.get_height(),s=new e.ImageSurface(e.Format.ARGB32,i,o),c=new e.Context(s);return getCanvasPixelBridge().setSourceImage(c,r,0,0),c.paint(),c.$dispose(),new CanvasPattern(s,n)}if(isCanvasImageSource(t)){let r=t.getContext(`2d`);if(r&&typeof r._getSurface==`function`){let t=r._getSurface(),i=t.getWidth(),o=t.getHeight(),s=new e.ImageSurface(e.Format.ARGB32,i,o),c=new e.Context(s);return c.setSourceSurface(t,0,0),c.paint(),c.$dispose(),new CanvasPattern(s,n)}}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 Ne={translate(e,t){this._ensureSurface(),!(!Number.isFinite(e)||!Number.isFinite(t))&&this._ctx.translate(e,t)},rotate(e){this._ensureSurface(),Number.isFinite(e)&&this._ctx.rotate(e)},scale(e,t){if(this._ensureSurface(),!(!Number.isFinite(e)||!Number.isFinite(t))){if(e===0||t===0){this._state.transformIsSingular=!0;return}this._ctx.scale(e,t)}},transform(e,t,n,r,i,o){if(this._ensureSurface(),!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(o))return;if(e*r-t*n===0){this._state.transformIsSingular=!0;return}let s=i,c=o,l=Math.hypot(e,t),u=Math.hypot(n,r),d=Math.atan2(t,e);this._ctx.translate(s,c),d!==0&&this._ctx.rotate(d),(l!==1||u!==1)&&this._ctx.scale(l,u)},setTransform(e,t,n,r,i,o){if(this._ensureSurface(),this._state.transformIsSingular=!1,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,o)):this._ctx.identityMatrix()},getTransform(){if(this._state.transformIsSingular){let e=this._ctx.userToDevice(0,0);return makeMatrix(0,0,0,0,e[0]??0,e[1]??0)}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;return makeMatrix((t[0]??0)-r,(t[1]??0)-i,(n[0]??0)-r,(n[1]??0)-i,r,i)},resetTransform(){this._ensureSurface(),this._state.transformIsSingular=!1,this._ctx.identityMatrix()}};function makeMatrix(e,t,n,r,i,o){let s=globalThis.DOMMatrix;return typeof s==`function`?new s([e,t,n,r,i,o]):{a:e,b:t,c:n,d:r,e:i,f:o,m11:e,m12:t,m13:0,m14:0,m21:n,m22:r,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:i,m42:o,m43:0,m44:1,is2D:!0,isIdentity:e===1&&t===0&&n===0&&r===1&&i===0&&o===0}}function installTransformMethods(e){Object.assign(e,Ne)}const Pe={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,o){this._ensureSurface(),this._ctx.curveTo(e,t,n,r,i,o)},quadraticCurveTo(e,t,n,r){this._ensureSurface();let i,o;this._ctx.hasCurrentPoint()?[i,o]=this._ctx.getCurrentPoint():(i=e,o=t);let{cp1x:s,cp1y:c,cp2x:l,cp2y:u}=quadraticToCubic(i,o,e,t,n,r);this._ctx.curveTo(s,c,l,u,n,r)},arc(e,t,n,r,i,o=!1){if(this._ensureSurface(),Math.abs(i-r)>=2*Math.PI){this._ctx.arc(e,t,n,0,2*Math.PI);return}o?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 o,s;this._ctx.hasCurrentPoint()?[o,s]=this._ctx.getCurrentPoint():(o=e,s=t,this._ctx.moveTo(e,t)),cairoArcTo(this._ctx,o,s,e,t,n,r,i)},ellipse(e,t,n,r,i,o,s,c=!1){if(this._ensureSurface(),n<0||r<0)throw RangeError(`The radii provided are negative`);cairoEllipse(this._ctx,e,t,n,r,i,o,s,c)},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,Pe)}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 r=e.getContext(`2d`);if(r&&typeof r._getSurface==`function`){let e=r._getSurface();e.flush();let i=getCanvasPixelBridge().imageFromSurface(e,0,0,t,n);if(i)return{pixbuf:i,imgWidth:t,imgHeight:n}}}return null}const Fe={fill(t,n){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing(),this._applyFillStyle();let r;t instanceof Ae?(this._ctx.newPath(),t._replayOnCairo(this._ctx),r=n):r=t,this._ctx.setFillRule(r===`evenodd`?e.FillRule.EVEN_ODD:e.FillRule.WINDING),this._ctx.fillPreserve()},stroke(e){this._ensureSurface(),!this._state.transformIsSingular&&(this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle(),e instanceof Ae&&(this._ctx.newPath(),e._replayOnCairo(this._ctx)),this._ctx.strokePreserve())},fillRect(e,t,n,r){if(this._ensureSurface(),this._state.transformIsSingular)return;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){if(this._ensureSurface(),this._state.transformIsSingular)return;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(t,n,r,i){if(this._ensureSurface(),this._state.transformIsSingular)return;let o=this._ctx.copyPath();this._ctx.save(),this._ctx.setOperator(e.Operator.CLEAR),this._ctx.newPath(),this._ctx.rectangle(t,n,r,i),this._ctx.fill(),this._ctx.restore(),this._ctx.newPath(),this._ctx.appendPath(o)},clip(t,n){if(this._ensureSurface(),this._state.transformIsSingular)return;let r;t instanceof Ae?(this._ctx.newPath(),t._replayOnCairo(this._ctx),r=n):r=t,this._ctx.setFillRule(r===`evenodd`?e.FillRule.EVEN_ODD:e.FillRule.WINDING),this._ctx.clip()},isPointInPath(t,n,r,i){this._ensureSurface();let o,s,c;return t instanceof Ae?(this._ctx.newPath(),t._replayOnCairo(this._ctx),o=n,s=r,c=i):(o=t,s=n,c=r),this._ctx.setFillRule(c===`evenodd`?e.FillRule.EVEN_ODD:e.FillRule.WINDING),this._ctx.inFill(o,s)},isPointInStroke(e,t,n){return this._ensureSurface(),this._applyLineStyle(),e instanceof Ae?(this._ctx.newPath(),e._replayOnCairo(this._ctx),this._ctx.inStroke(t,n)):this._ctx.inStroke(e,t)},drawImage(t,n,r,i,o,s,c,l,u){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing();let d,p,m,h,g,_,v,y,b=getDrawImageSource(t);if(!b)return;let{pixbuf:x,imgWidth:S,imgHeight:w}=b;if(i===void 0?(d=0,p=0,m=S,h=w,g=n,_=r,v=S,y=w):s===void 0?(d=0,p=0,m=S,h=w,g=n,_=r,v=i,y=o):(d=n,p=r,m=i,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),getCanvasPixelBridge().setSourceImage(this._ctx,x,0,0);let T=asCairoPattern(this._ctx.getSource?.());if(T){let t;t=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?e.Filter.BEST:e.Filter.BILINEAR:e.Filter.NEAREST,T.setFilter(t)}this._state.globalAlpha<1?this._ctx.paintWithAlpha(this._state.globalAlpha):this._ctx.paint(),this._ctx.restore()}};function installDrawingMethods(e){Object.assign(e,Fe)}const Ie={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,r){this._ensureSurface(),this._surface.flush();let i=getCanvasPixelBridge().imageFromSurface(this._surface,e,t,n,r);if(!i)return new OurImageData(n,r);let o=i.get_pixels(),s=i.get_has_alpha(),c=i.get_rowstride(),l=i.get_n_channels(),u=new Uint8ClampedArray(n*r*4);for(let e=0;e<r;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,r)},putImageData(t,n,r,i,o,s,c){this._ensureSurface();let l=i??0,u=o??0,d=s??t.width,p=c??t.height,m=t.data,h=t.width,g=new Uint8Array(d*p*4);for(let e=0;e<p;e++)for(let t=0;t<d;t++){let n=((u+e)*h+(l+t))*4,r=(e*d+t)*4;g[r]=m[n],g[r+1]=m[n+1],g[r+2]=m[n+2],g[r+3]=m[n+3]}this._ctx.save(),this._ctx.setOperator(e.Operator.SOURCE),getCanvasPixelBridge().setSourcePixels(this._ctx,g,d,p,n+l,r+u),this._ctx.rectangle(n+l,r+u,d,p),this._ctx.fill(),this._ctx.restore()}};function installPixelMethods(e){Object.assign(e,Ie)}function parseFontToDescription(e){let n=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(!n)return t.font_description_from_string(e);let r=n[1]||``,i=n[3]||``,o=parseFloat(n[4])||10,s=(n[5]||`px`).toLowerCase(),c=(n[6]||`sans-serif`).replace(/['"]/g,``).trim();s===`pt`?o=o*96/72:s===`em`||s===`rem`?o*=16:s===`%`&&(o=o/100*16);let l=c;r===`italic`?l+=` Italic`:r===`oblique`&&(l+=` Oblique`),i===`bold`||i===`bolder`||parseInt(i)>=600?l+=` Bold`:(i===`lighter`||parseInt(i)>0&&parseInt(i)<=300)&&(l+=` Light`);let u=t.font_description_from_string(l);return u.set_absolute_size(o*t.SCALE),u}function createTextLayout(e,r){let i=n.create_layout(e._ctx);i.set_text(r,-1),i.get_context().set_base_dir(t.Direction.LTR),i.context_changed();let o=parseFontToDescription(e._state.font);return i.set_font_description(o),i}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,n){let r=n.get_font_description()||parseFontToDescription(e._state.font),i=n.get_context().get_metrics(r,null),o=i.get_ascent()/t.SCALE,s=i.get_descent()/t.SCALE,c=o+s;switch(e._state.textBaseline){case`top`:return 0;case`hanging`:return-(o*.2);case`middle`:return-(c/2);case`alphabetic`:return-o;case`ideographic`:return-(o+s*.5);case`bottom`:return-c;default:return-o}}const Le={fillText(t,r,i,o){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing();let s=createTextLayout(this,t),c=getTextAlignOffset(this,s),l=getTextBaselineOffset(this,s);if(this._hasShadow()){let t=parseColor(this._state.shadowColor);if(t){let[o,u]=this._deviceToUserDistance(this._state.shadowOffsetX,this._state.shadowOffsetY),d=this._state.shadowBlur,p;if(d>0){let[e]=this._deviceToUserDistance(d,0),[,n]=this._deviceToUserDistance(0,d);p=[[o,u,t.a],[o+e,u,t.a*.5],[o-e,u,t.a*.5],[o,u+n,t.a*.5],[o,u-n,t.a*.5]]}else p=[[o,u,t.a]];let m=this._state.imageSmoothingEnabled?e.Antialias.DEFAULT:e.Antialias.NONE;for(let[e,o,u]of p)this._ctx.save(),this._ctx.setAntialias(m),this._ctx.setSourceRGBA(t.r,t.g,t.b,u),this._ctx.moveTo(r+c+e,i+l+o),n.show_layout(this._ctx,s),this._ctx.restore()}}this._applyFillStyle(),this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?e.Antialias.DEFAULT:e.Antialias.NONE),this._ctx.moveTo(r+c,i+l),n.show_layout(this._ctx,s),this._ctx.restore()},strokeText(t,r,i,o){if(this._ensureSurface(),this._state.transformIsSingular)return;this._applyCompositing(),this._applyStrokeStyle(),this._applyLineStyle();let s=createTextLayout(this,t),c=getTextAlignOffset(this,s),l=getTextBaselineOffset(this,s);this._ctx.save(),this._ctx.setAntialias(this._state.imageSmoothingEnabled?e.Antialias.DEFAULT:e.Antialias.NONE),this._ctx.moveTo(r+c,i+l),n.layout_path(this._ctx,s),this._ctx.stroke(),this._ctx.restore()},measureText(e){this._ensureSurface();let n=createTextLayout(this,e),[r,i]=n.get_pixel_extents(),o=n.get_baseline()/t.SCALE,s=Math.max(0,o-r.y),c=Math.max(0,r.y+r.height-o),l=n.get_font_description()||parseFontToDescription(this._state.font),u=n.get_context().get_metrics(l,null),d=u.get_ascent()/t.SCALE,p=u.get_descent()/t.SCALE;return{width:i.width,actualBoundingBoxAscent:s,actualBoundingBoxDescent:c,actualBoundingBoxLeft:Math.max(0,-r.x),actualBoundingBoxRight:r.x+r.width,fontBoundingBoxAscent:d,fontBoundingBoxDescent:p,alphabeticBaseline:0,emHeightAscent:d,emHeightDescent:p,hangingBaseline:d*.8,ideographicBaseline:-p}}};function installTextMethods(e){Object.assign(e,Le)}const Re={createLinearGradient(e,t,n,r){return new CanvasGradient(`linear`,e,t,n,r)},createRadialGradient(e,t,n,r,i,o){return new CanvasGradient(`radial`,e,t,r,i,n,o)},createPattern(e,t){return Me.create(e,t)}};function installFactoryMethods(e){Object.assign(e,Re)}function installAllContextMethods(e){installTransformMethods(e),installPathMethods(e),installDrawingMethods(e),installPixelMethods(e),installTextMethods(e),installFactoryMethods(e)}function createDefaultState(){return{fillStyle:`#000000`,fillColor:{...Ee},strokeStyle:`#000000`,strokeColor:{...Ee},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`,transformIsSingular:!1}}function cloneState(e){return{...e,fillColor:{...e.fillColor},strokeColor:{...e.strokeColor},lineDash:[...e.lineDash]}}var CanvasRenderingContext2D=class{constructor(t,n){this._stateStack=[],this.canvas=t,this._surfaceWidth=t.width||300,this._surfaceHeight=t.height||150,this._surface=new e.ImageSurface(e.Format.ARGB32,this._surfaceWidth,this._surfaceHeight),this._ctx=new e.Context(this._surface),this._state=createDefaultState()}_ensureSurface(){let t=this.canvas.width||300,n=this.canvas.height||150;(t!==this._surfaceWidth||n!==this._surfaceHeight)&&(this._ctx.$dispose(),this._surface.finish(),this._surfaceWidth=t,this._surfaceHeight=n,this._surface=new e.ImageSurface(e.Format.ARGB32,t,n),this._ctx=new e.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 Me&&(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 Me&&(this._ctx.setSource(e._getCairoPattern()),this._applyPatternFilter())}_applyPatternFilter(){let t=asCairoPattern(this._ctx.getSource?.());if(!t)return;let n;n=this._state.imageSmoothingEnabled?this._state.imageSmoothingQuality===`high`?e.Filter.BEST:e.Filter.BILINEAR:e.Filter.NEAREST,t.setFilter(n)}_applyLineStyle(){this._ctx.setLineWidth(this._state.lineWidth),this._ctx.setLineCap(Oe[this._state.lineCap]),this._ctx.setLineJoin(ke[this._state.lineJoin]),this._ctx.setMiterLimit(this._state.miterLimit),this._ctx.setDash(this._state.lineDash,this._state.lineDashOffset)}_applyCompositing(){let e=De[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),o=(r[0]??0)-(n[0]??0),s=(r[1]??0)-(n[1]??0),c=(i[0]??0)-(n[0]??0),l=(i[1]??0)-(n[1]??0),u=o*l-s*c;return Math.abs(u)<1e-10?[e,t]:[(l*e-c*t)/u,(-s*e+o*t)/u]}_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){De[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]=i.file_open_tmp(`canvas-XXXXXX.png`);try{this._surface.writeToPNG(n);let[,e]=r.File.new_for_path(n).load_contents(null);return`data:image/png;base64,${i.base64_encode(e)}`}finally{i.unlink(n)}}_dispose(){this._ctx.$dispose(),this._surface.finish()}};installAllContextMethods(CanvasRenderingContext2D.prototype);var ze=Object.defineProperty;__name((e,t)=>{let n={};for(var r in e)ze(n,r,{get:e[r],enumerable:!0});return t||ze(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)({attributes:()=>R,childNodesList:()=>L,elementChildren:()=>Be,isConnected:()=>Ve,localName:()=>Ue,name:()=>Ke,namespaceURI:()=>We,nodeType:()=>F,ownerElement:()=>Je,parentNode:()=>I,prefix:()=>Ge,propertyEventListeners:()=>z,tagName:()=>He,value:()=>qe});const F=Symbol(`nodeType`),I=Symbol(`parentNode`),L=Symbol(`childNodesList`),Be=Symbol(`elementChildren`),Ve=Symbol(`isConnected`),He=Symbol(`tagName`),Ue=Symbol(`localName`),We=Symbol(`namespaceURI`),Ge=Symbol(`prefix`),R=Symbol(`attributes`),z=Symbol(`propertyEventListeners`),Ke=Symbol(`name`),qe=Symbol(`value`),Je=Symbol(`ownerElement`),B={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 Ye={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(Ye,this.name)?Ye[this.name]:0}};const V=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;N();const Xe=Symbol(`type`),Ze=Symbol(`bubbles`),Qe=Symbol(`cancelable`),$e=Symbol(`composed`),et=Symbol(`target`),tt=Symbol(`currentTarget`),nt=Symbol(`eventPhase`),rt=Symbol(`defaultPrevented`),it=Symbol(`isTrusted`),ot=Symbol(`timeStamp`),st=Symbol(`stop`),ct=Symbol(`immediateStop`),lt=Symbol(`dispatching`),ut=Symbol(`inPassiveListener`);var Event=class{[Xe];[Ze];[Qe];[$e];[et]=null;[tt]=null;[nt]=0;[rt]=!1;[it]=!1;[ot];[st]=!1;[ct]=!1;[lt]=!1;[ut]=!1;get type(){return this[Xe]}get bubbles(){return this[Ze]}get cancelable(){return this[Qe]}get composed(){return this[$e]}get target(){return this[et]}get currentTarget(){return this[tt]}get eventPhase(){return this[nt]}get defaultPrevented(){return this[rt]}get timeStamp(){return this[ot]}get cancelBubble(){return this[st]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[rt]}set returnValue(e){e||this.preventDefault()}get srcElement(){return this[et]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(e,t){this[Xe]=e,this[Ze]=t?.bubbles??!1,this[Qe]=t?.cancelable??!1,this[$e]=t?.composed??!1,this[ot]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[it],enumerable:!0,configurable:!1})}composedPath(){return this[tt]?[this[tt]]:[]}preventDefault(){this[Qe]&&!this[ut]&&(this[rt]=!0)}stopPropagation(){this[st]=!0}stopImmediatePropagation(){this[st]=!0,this[ct]=!0}},EventTarget=class{#e=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,o=typeof n==`object`?n?.passive??!1:!1,s=this.#e.get(e);s||(s=[],this.#e.set(e,s));for(let e of s)if(e.listener===t&&e.capture===r)return;let c={listener:t,capture:r,once:i,passive:o,removed:!1};s.push(c),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.#e.get(e);if(!i)return;let o=i.findIndex(e=>e.listener===t&&e.capture===r);o!==-1&&(i[o].removed=!0,i.splice(o,1),i.length===0&&this.#e.delete(e))}dispatchEvent(e){let t=e;if(t[lt])throw new V(`The event is already being dispatched.`,`InvalidStateError`);t[lt]=!0,t[et]=this,t[tt]=this,t[nt]=Event.AT_TARGET;try{let n=this.#e.get(e.type);if(n){let r=[...n];for(let n of r)if(!n.removed){if(t[ct]||t[st])break;n.once&&this.removeEventListener(e.type,n.listener,{capture:n.capture});try{n.passive&&(t[ut]=!0),typeof n.listener==`function`?n.listener.call(this,e):typeof n.listener.handleEvent==`function`&&n.listener.handleEvent.call(n.listener,e)}catch(e){reportListenerException(e)}finally{t[ut]=!1}}}}finally{t[nt]=Event.NONE,t[tt]=null,t[lt]=!1}return!e.defaultPrevented}};function reportListenerException(e){try{let t=globalThis;if(typeof t.reportError==`function`)t.reportError(e);else if(e instanceof Error){let t=`${e.name}: ${e.message}`;M.error(e.stack?`${t}\n${e.stack}`:t)}else M.error(String(e))}catch{}}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 dt,ft,pt,mt,ht;var gt=class Node extends EventTarget{constructor(...e){super(...e),this.ELEMENT_NODE=B.ELEMENT_NODE,this.ATTRIBUTE_NODE=B.ATTRIBUTE_NODE,this.TEXT_NODE=B.TEXT_NODE,this.CDATA_SECTION_NODE=B.CDATA_SECTION_NODE,this.PROCESSING_INSTRUCTION_NODE=B.PROCESSING_INSTRUCTION_NODE,this.COMMENT_NODE=B.COMMENT_NODE,this.DOCUMENT_NODE=B.DOCUMENT_NODE,this.DOCUMENT_TYPE_NODE=B.DOCUMENT_TYPE_NODE,this.DOCUMENT_FRAGMENT_NODE=B.DOCUMENT_FRAGMENT_NODE,this[dt]=B.ELEMENT_NODE,this[ft]=null,this[pt]=[],this[mt]=[],this[ht]=!1}static{this.ELEMENT_NODE=B.ELEMENT_NODE}static{this.ATTRIBUTE_NODE=B.ATTRIBUTE_NODE}static{this.TEXT_NODE=B.TEXT_NODE}static{this.CDATA_SECTION_NODE=B.CDATA_SECTION_NODE}static{this.PROCESSING_INSTRUCTION_NODE=B.PROCESSING_INSTRUCTION_NODE}static{this.COMMENT_NODE=B.COMMENT_NODE}static{this.DOCUMENT_NODE=B.DOCUMENT_NODE}static{this.DOCUMENT_TYPE_NODE=B.DOCUMENT_TYPE_NODE}static{this.DOCUMENT_FRAGMENT_NODE=B.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[F]}get nodeName(){return``}get parentNode(){return this[I]}get parentElement(){let e=this[I];return e&&e[F]===B.ELEMENT_NODE?e:null}get childNodes(){return new NodeList(this[L])}get firstChild(){return this[L][0]??null}get lastChild(){let e=this[L];return e[e.length-1]??null}get previousSibling(){let e=this[I];if(!e)return null;let t=e[L],n=t.indexOf(this);return n>0?t[n-1]:null}get nextSibling(){let e=this[I];if(!e)return null;let t=e[L],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[I];)e=e[I];let t=globalThis.document;return e===t?t:null}get isConnected(){return this[Ve]}hasChildNodes(){return this[L].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[I]}return!1}getRootNode(){let e=this;for(;e[I];)e=e[I];return e}appendChild(e){return e[I]&&e[I].removeChild(e),e[I]=this,this[L].push(e),e[F]===B.ELEMENT_NODE&&this[Be].push(e),e}removeChild(e){let t=this[L],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[I]=null,e[F]===B.ELEMENT_NODE){let t=this[Be].indexOf(e);t!==-1&&this[Be].splice(t,1)}return e}insertBefore(e,t){if(t===null)return this.appendChild(e);let n=this[L],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[I]&&e[I].removeChild(e),e[I]=this,n.splice(r,0,e),e[F]===B.ELEMENT_NODE){let t=this[Be],i=t.length;for(let o=r;o<n.length;o++)if(n[o][F]===B.ELEMENT_NODE&&n[o]!==e){i=t.indexOf(n[o]);break}t.splice(i,0,e)}return e}replaceChild(e,t){return this.insertBefore(e,t),this.removeChild(t),t}_createCloneTarget(){return new this.constructor}cloneNode(e=!1){let t=this._createCloneTarget();if(t[F]=this[F],e)for(let e of this[L])t.appendChild(e.cloneNode(!0));return t}dispatchEvent(e){let t=super.dispatchEvent(e);if(e.bubbles&&!e.cancelBubble){let t=this[I];for(;t&&(Object.getPrototypeOf(Node.prototype).dispatchEvent.call(t,e),!e.cancelBubble);)t=t[I]}return t}get[(dt=F,ft=I,pt=L,mt=Be,ht=Ve,Symbol.toStringTag)](){return`Node`}};const _t={isTag(e){return e[F]===B.ELEMENT_NODE},getName(e){return e[Ue]??``},getParent(e){return e.parentNode},getChildren(e){return e[L]},getSiblings(e){let t=e.parentNode;return t?t[L]:[e]},getAttributeValue(e,t){return e[F]===B.ELEMENT_NODE?e.getAttribute(t):null},getText(e){return e.textContent??``},caseSensitive:!1},vt={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[Ke]=e,this[qe]=t,this[Je]=i,this.namespaceURI=n,this.prefix=r;let o=e.indexOf(`:`);this.localName=o===-1?e:e.slice(o+1)}get name(){return this[Ke]}get value(){return this[qe]}set value(e){this[qe]=e}get ownerElement(){return this[Je]}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===vt.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)}};const yt=/^([+-]?\d*)n\s*(?:([+-])\s*(\d+))?$/,bt=/^[+-]?\d+$/;function parseNth(e){let t=e.trim().toLowerCase();if(t===`odd`)return{a:2,b:1};if(t===`even`)return{a:2,b:0};let n=yt.exec(t);if(n!==null){let e=n[1];return{a:e===``||e===`+`?1:e===`-`?-1:Number(e),b:n[3]===void 0?0:Number(n[2]+n[3])}}if(bt.test(t))return{a:0,b:Number(t)};throw SyntaxError(`'`+e+`' is not a valid An+B argument`)}function matchesNth(e,t){if(e.a===0)return t===e.b;let n=t-e.b;return e.a>0?n>=0&&n%e.a===0:n<=0&&n%e.a===0}const xt=new Set([` `,` `,`
10
10
  `,`\r`,`\f`]),St={"~":`element`,"|":`hyphen`,"^":`start`,$:`end`,"*":`any`,"!":`not`},Ct={"nth-child":`child`,"nth-last-child":`last-child`,"nth-of-type":`of-type`,"nth-last-of-type":`last-of-type`},wt={"any-link":`:is(a, area, link)[href]`,disabled:`:is(:is(button, input, select, textarea, optgroup, option, fieldset)[disabled], optgroup[disabled] > option, fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *))`,enabled:`:is(button, input, select, textarea, optgroup, option, fieldset):not(:disabled)`,checked:`:is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)`,required:`:is(input, select, textarea)[required]`,optional:`:is(input, select, textarea):not([required])`,selected:`option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)`},Tt=new Set([`before`,`after`,`first-line`,`first-letter`,`selection`,`placeholder`]),Et=new Set([`hover`,`active`,`focus`,`focus-visible`,`focus-within`,`visited`,`link`,`target`,`target-within`,`playing`,`paused`,`current`,`past`,`future`]);function isNameChar(e){if(e===``)return!1;let t=e.codePointAt(0);return e===`-`||e===`_`||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t>127}function isNameStart(e){return e===`\\`||e!==`-`&&isNameChar(e)&&!(e>=`0`&&e<=`9`)}function isHexDigit$1(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}__name(isHexDigit$1,`isHexDigit`);function isNthChar(e){return e>=`0`&&e<=`9`||e===`n`||e===`N`||e===`+`||e===`-`||xt.has(e)}var SelectorParser=class{input;pos=0;constructor(e){this.input=e}parseSelectorList(e){let t=[this.parseComplex(e)];for(;this.peek()===`,`;)this.pos++,t.push(this.parseComplex(e));return t}atEnd(){return this.pos>=this.input.length}fail(e){throw SyntaxError(`Failed to parse selector '`+this.input+`': `+e)}peek(e=0){return this.input[this.pos+e]??``}skipWhitespace(){let e=this.pos;for(;xt.has(this.peek());)this.pos++;return this.pos>e}expect(e){this.peek()!==e&&this.fail(`expected '`+e+`' at offset `+this.pos),this.pos++}parseComplex(e){this.skipWhitespace();let t=e?this.readLeadingCombinator():null,n=[this.parseCompound()],r=[];for(;;){let e=this.readCombinator();if(e===null)break;r.push(e),n.push(this.parseCompound())}return{compounds:n,combinators:r,leading:t}}readLeadingCombinator(){let e=this.peek();return e!==`>`&&e!==`+`&&e!==`~`?`descendant`:(this.pos++,this.skipWhitespace(),e===`>`?`child`:e===`+`?`adjacent`:`sibling`)}readCombinator(){let e=this.skipWhitespace(),t=this.peek();if(t===`>`||t===`+`||t===`~`)return this.pos++,this.skipWhitespace(),t===`>`?`child`:t===`+`?`adjacent`:`sibling`;if(t===`|`&&this.peek(1)===`|`&&this.fail(`the column combinator '||' needs a table layout`),t===``||t===`,`||t===`)`)return null;if(e)return`descendant`;this.fail(`unexpected '`+t+`' at offset `+this.pos)}parseCompound(){let e=[];for(;;){let t=this.peek();if(t===`*`)this.pos++,this.rejectNamespace(),e.push({kind:`universal`});else if(t===`#`)this.pos++,e.push({kind:`attribute`,name:`id`,action:`equals`,value:this.readName(),ignoreCase:!1});else if(t===`.`)this.pos++,e.push({kind:`attribute`,name:`class`,action:`element`,value:this.readName(),ignoreCase:!1});else if(t===`[`)e.push(this.parseAttribute());else if(t===`:`)for(let t of this.parsePseudo())e.push(t);else if(t===`|`)this.fail(`namespace selectors need a namespace map this parser is not given`);else if(isNameStart(t)){let t=this.readName();this.rejectNamespace(),e.push({kind:`type`,name:t})}else break}return e.length===0&&this.fail(`expected a selector at offset `+this.pos),e}rejectNamespace(){this.peek()===`|`&&this.peek(1)!==`=`&&this.fail(`namespace selectors need a namespace map this parser is not given`)}readName(){let e=``;for(;;){let t=this.peek();if(t===`\\`){e+=this.readEscape();continue}if(!isNameChar(t))break;e+=t,this.pos++}return e===``&&this.fail(`expected an identifier at offset `+this.pos),e}readEscape(){this.pos++;let e=``;for(;e.length<6&&isHexDigit$1(this.peek());)e+=this.peek(),this.pos++;if(e===``){let e=this.peek();return e===``&&this.fail(`a trailing backslash escapes nothing`),this.pos++,e}xt.has(this.peek())&&this.pos++;let t=Number.parseInt(e,16);return t===0||t>1114111||t>=55296&&t<=57343?`�`:String.fromCodePoint(t)}readString(e){this.pos++;let t=``;for(;;){let n=this.peek();if(n===``&&this.fail(`unterminated string`),n===e)return this.pos++,t;if(n===`\\`){t+=this.readEscape();continue}t+=n,this.pos++}}parseAttribute(){this.expect(`[`),this.skipWhitespace(),(this.peek()===`|`||this.peek()===`*`)&&this.fail(`namespace selectors need a namespace map this parser is not given`);let e=this.readName();if(this.rejectNamespace(),this.skipWhitespace(),this.peek()===`]`)return this.pos++,{kind:`attribute`,name:e,action:`exists`,value:``,ignoreCase:null};let t;this.peek()===`=`?(t=`equals`,this.pos++):this.peek(1)===`=`&&Object.hasOwn(St,this.peek())?(t=St[this.peek()],this.pos+=2):this.fail(`'`+this.peek()+`' is not an attribute operator`),this.skipWhitespace();let n=this.peek(),r=n===`"`||n===`'`?this.readString(n):this.readName();this.skipWhitespace();let i=null,o=this.peek().toLowerCase();return(o===`i`||o===`s`)&&(i=o===`i`,this.pos++,this.skipWhitespace()),this.expect(`]`),{kind:`attribute`,name:e,action:t,value:r,ignoreCase:i}}parsePseudo(){this.pos++,this.peek()===`:`&&(this.pos++,this.fail(`pseudo-element '::`+this.readName()+`' has no meaning without rendering`));let e=this.readName().toLowerCase();if(e===`not`||e===`is`||e===`where`||e===`matches`||e===`has`){this.expect(`(`);let t=this.parseSelectorList(e===`has`);return this.expect(`)`),[{kind:e===`not`?`not`:e===`has`?`has`:`is`,selectors:t}]}if(Object.hasOwn(Ct,e))return[this.parseNthPseudo(Ct[e])];if(e===`first-child`)return[positional(`child`,1)];if(e===`last-child`)return[positional(`last-child`,1)];if(e===`only-child`)return[positional(`child`,1),positional(`last-child`,1)];if(e===`first-of-type`)return[positional(`of-type`,1)];if(e===`last-of-type`)return[positional(`last-of-type`,1)];if(e===`only-of-type`)return[positional(`of-type`,1),positional(`last-of-type`,1)];if(e===`empty`)return[{kind:`empty`}];if(e===`root`)return[{kind:`root`}];if(e===`scope`)return[{kind:`scope`}];if(Object.hasOwn(wt,e))return[{kind:`is`,selectors:parseSelectorList(wt[e])}];Et.has(e)&&this.fail(`':`+e+`' is a user-state pseudo-class and needs a live document`),Tt.has(e)&&this.fail(`pseudo-element ':`+e+`' has no meaning without rendering`),this.fail(`unknown pseudo-class ':`+e+`'`)}parseNthPseudo(e){this.expect(`(`);let t=parseNth(this.readNthArgument()),n=null;return this.readKeyword(`of`)&&(n=this.parseSelectorList(!1)),this.expect(`)`),{kind:`nth`,axis:e,formula:t,of:n}}readNthArgument(){if(this.skipWhitespace(),this.readKeyword(`odd`))return`odd`;if(this.readKeyword(`even`))return`even`;let e=this.pos;for(;isNthChar(this.peek());)this.pos++;return this.input.slice(e,this.pos)}readKeyword(e){return this.input.slice(this.pos,this.pos+e.length).toLowerCase()!==e||isNameChar(this.peek(e.length))?!1:(this.pos+=e.length,this.skipWhitespace(),!0)}};function positional(e,t){return{kind:`nth`,axis:e,formula:{a:0,b:t},of:null}}function parseSelectorList(e){let t=new SelectorParser(e),n=t.parseSelectorList(!1);return t.atEnd()||t.fail(`unexpected trailing input`),n}const Dt=new Set(`accept.accept-charset.align.alink.axis.bgcolor.charset.checked.clear.codetype.color.compact.declare.defer.dir.direction.disabled.enctype.face.frame.hreflang.http-equiv.lang.language.link.media.method.multiple.nohref.noresize.noshade.nowrap.readonly.rel.rev.rules.scope.scrolling.selected.shape.target.text.type.valign.valuetype.vlink`.split(`.`)),Ot=/\s+/,kt={universal:0,attribute:1,type:2,nth:3,empty:3,root:3,scope:3,is:4,not:4,has:5};function cost(e){return e.kind===`attribute`?e.name===`id`&&e.action===`equals`?0:e.action===`exists`?2:1:kt[e.kind]}function compileAttribute(e,t){let n=t.caseSensitive?e.name:e.name.toLowerCase(),r=e.ignoreCase===null?!t.caseSensitive&&Dt.has(n):e.ignoreCase,i=r?e.value.toLowerCase():e.value,read=e=>{let i=t.getAttributeValue(e,n);return i===null||!r?i:i.toLowerCase()},noMatch=()=>!1;switch(e.action){case`exists`:return e=>t.getAttributeValue(e,n)!==null;case`equals`:return e=>read(e)===i;case`not`:return i===``?e=>(read(e)??``)!==``:e=>read(e)!==i;case`start`:return i===``?noMatch:e=>read(e)?.startsWith(i)===!0;case`end`:return i===``?noMatch:e=>read(e)?.endsWith(i)===!0;case`any`:return i===``?noMatch:e=>read(e)?.includes(i)===!0;case`hyphen`:return e=>{let t=read(e);return t!==null&&(t===i||t.startsWith(i+`-`))};default:return i===``||Ot.test(i)?noMatch:e=>read(e)?.split(Ot).includes(i)===!0}}function compileNth(e,t){let n=e.axis===`last-child`||e.axis===`last-of-type`,r=e.axis===`of-type`||e.axis===`last-of-type`,i=e.of===null?null:compileList(e.of,t);return(o,s)=>{let c=t.getSiblings(o),l=r?t.getName(o):``,u=n?-1:1,d=0;for(let p=n?c.length-1:0;p>=0&&p<c.length;p+=u){let n=c[p];if(t.isTag(n)&&!(r&&t.getName(n)!==l)&&!(i!==null&&!i(n,s))&&(d++,n===o))return matchesNth(e.formula,d)}return!1}}function collectDescendants(e,t,n){for(let r of t.getChildren(e))t.isTag(r)&&n.push(r),collectDescendants(r,t,n)}function followingSiblings(e,t){let n=t.getSiblings(e),r=n.indexOf(e);return r===-1?[]:n.slice(r+1).filter(e=>t.isTag(e))}function compileHas(e,t){let n=e.selectors.map(e=>compileComplex(e,t)),r=e.selectors.some(e=>e.leading===`adjacent`||e.leading===`sibling`),i=new Map;return(e,o)=>{let s=i.get(e);if(s!==void 0)return s;let c=[];if(collectDescendants(e,t,c),r)for(let n of followingSiblings(e,t))c.push(n);let l=o.scope;o.scope=e;let u=!1;for(let e of c)if(n.some(t=>t(e,o))){u=!0;break}return o.scope=l,i.set(e,u),u}}function compileSimple(e,t){switch(e.kind){case`universal`:return()=>!0;case`type`:{let n=t.caseSensitive?e.name:e.name.toLowerCase();return e=>t.getName(e)===n}case`attribute`:return compileAttribute(e,t);case`nth`:return compileNth(e,t);case`empty`:return e=>!t.getChildren(e).some(e=>t.isTag(e)||t.getText(e)!==``);case`root`:return e=>{let n=t.getParent(e);return n===null||!t.isTag(n)};case`scope`:return(e,t)=>e===t.scope;case`is`:return compileList(e.selectors,t);case`not`:{let n=compileList(e.selectors,t);return(e,t)=>!n(e,t)}default:return compileHas(e,t)}}function compileCompound(e,t){let n=e.slice().sort((e,t)=>cost(e)-cost(t)).map(e=>compileSimple(e,t));return n.length===1?n[0]:(e,t)=>{for(let r of n)if(!r(e,t))return!1;return!0}}function compileCombinator(e,t,n){switch(e){case`child`:return(e,r)=>{let i=n.getParent(e);return i!==null&&t(i,r)};case`descendant`:return(e,r)=>{let i=n.getParent(e);for(;i!==null;){if(t(i,r))return!0;i=n.getParent(i)}return!1};case`adjacent`:return(e,r)=>{let i=n.getSiblings(e);for(let o=i.indexOf(e)-1;o>=0;o--)if(n.isTag(i[o]))return t(i[o],r);return!1};default:return(e,r)=>{let i=n.getSiblings(e);for(let o=i.indexOf(e)-1;o>=0;o--)if(n.isTag(i[o])&&t(i[o],r))return!0;return!1}}}function compileComplex(e,t){let next=e.leading===null?()=>!0:compileCombinator(e.leading,(e,t)=>e===t.scope,t);for(let n=0;n<e.compounds.length;n++){n>0&&(next=compileCombinator(e.combinators[n-1],next,t));let r=compileCompound(e.compounds[n],t),i=next;next=(e,t)=>r(e,t)&&i(e,t)}return next}function compileList(e,t){let n=e.map(e=>compileComplex(e,t));return n.length===1?n[0]:(e,t)=>n.some(n=>n(e,t))}function compile(e,t){return compileList(parseSelectorList(e),t)}function walk(e,t,n){for(let r of t.getChildren(e))if(t.isTag(r)&&n(r)||walk(r,t,n))return!0;return!1}function selectAll(e,t,n){let r=compile(e,n),i={scope:t},o=[];return walk(t,n,e=>(r(e,i)&&o.push(e),!1)),o}function selectOne(e,t,n){let r=compile(e,n),i={scope:t},o=null;return walk(t,n,e=>r(e,i)?(o=e,!0):!1),o}function matchesSelector(e,t,n){return compile(e,n)(t,{scope:t})}function closestSelector(e,t,n){let r=compile(e,n),i={scope:t},o=t;for(;o!==null&&n.isTag(o);){if(r(o,i))return o;o=n.getParent(o)}return null}N();let At,jt,Mt,Nt,Pt,Ft;var Element=class extends gt{constructor(){super(),this[At]=``,this[jt]=``,this[Mt]=vt.html,this[Nt]=null,this[Pt]=new NamedNodeMap(this),this[Ft]=new Map,this._resizeSubscribers=null,this._allocatedClientWidth=0,this._allocatedClientHeight=0,this._pointerCaptures=new Set,this[F]=B.ELEMENT_NODE}get tagName(){return this[He]}get localName(){return this[Ue]}get namespaceURI(){return this[We]}get prefix(){return this[Ge]}get nodeName(){return this[He]}get attributes(){return this[R]}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[Be]}get childElementCount(){return this[Be].length}get firstElementChild(){return this[Be][0]??null}get lastElementChild(){let e=this[Be];return e[e.length-1]??null}get previousElementSibling(){let e=this[I];if(!e)return null;let t=e[Be],n=t.indexOf(this);return n>0?t[n-1]:null}get nextElementSibling(){let e=this[I];if(!e)return null;let t=e[Be],n=t.indexOf(this);return n!==-1&&n<t.length-1?t[n+1]:null}get textContent(){let e=``;for(let t of this[L])t.textContent!==null&&(e+=t.textContent);return e}set textContent(e){let t=this[L];for(;t.length>0;)this.removeChild(t[0])}getAttribute(e){let t=this[R].getNamedItem(e);return t?t.value:null}getAttributeNS(e,t){let n=this[R].getNamedItemNS(e,t);return n?n.value:null}setAttribute(e,t){this[R]._setNamedItem(e,String(t))}setAttributeNS(e,t,n){let r=e===``?null:e,i=t.split(`:`),o=i.length>1?i[0]:null;this[R]._setNamedItem(t,String(n),r,o)}removeAttribute(e){this[R]._removeNamedItem(e)}removeAttributeNS(e,t){let n=e===``?null:e;this[R]._removeNamedItemNS(n,t)}hasAttribute(e){return this[R].getNamedItem(e)!==null}hasAttributeNS(e,t){return this[R].getNamedItemNS(e,t)!==null}getAttributeNode(e){return this[R].getNamedItem(e)}setAttributeNode(e){return this[R].setNamedItem(e)}removeAttributeNode(e){let t=this[R].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[R].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[R].length>0}dispatchEvent(e){let t=super.dispatchEvent(e),n=this[z].get(`on`+e.type);return typeof n==`function`&&n.call(this,e),t}querySelector(e){return selectOne(e,this,_t)}querySelectorAll(e){return selectAll(e,this,_t)}matches(e){return matchesSelector(e,this,_t)}closest(e){return closestSelector(e,this,_t)}getElementsByTagName(e){let t=[],n=e.toUpperCase(),walk=r=>{for(let i of r[L])if(i[F]===B.ELEMENT_NODE){let r=i;(e===`*`||r[He]===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[L])if(r[F]===B.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[He]=this[He],t[Ue]=this[Ue],t[We]=this[We],t[Ge]=this[Ge];for(let e of this[R])t.setAttributeNS(e.namespaceURI,e.name,e.value);if(e)for(let e of this[L])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){M.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[(At=He,jt=Ue,Mt=We,Nt=Ge,Pt=R,Ft=z,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[z].get(`onclick`)??null}set onclick(e){this[z].set(`onclick`,e)}get ondblclick(){return this[z].get(`ondblclick`)??null}set ondblclick(e){this[z].set(`ondblclick`,e)}get onload(){return this[z].get(`onload`)??null}set onload(e){this[z].set(`onload`,e)}get onerror(){return this[z].get(`onerror`)??null}set onerror(e){this[z].set(`onerror`,e)}get onabort(){return this[z].get(`onabort`)??null}set onabort(e){this[z].set(`onabort`,e)}get onfocus(){return this[z].get(`onfocus`)??null}set onfocus(e){this[z].set(`onfocus`,e)}get onblur(){return this[z].get(`onblur`)??null}set onblur(e){this[z].set(`onblur`,e)}get onchange(){return this[z].get(`onchange`)??null}set onchange(e){this[z].set(`onchange`,e)}get oninput(){return this[z].get(`oninput`)??null}set oninput(e){this[z].set(`oninput`,e)}get onsubmit(){return this[z].get(`onsubmit`)??null}get onreset(){return this[z].get(`onreset`)??null}set onreset(e){this[z].set(`onreset`,e)}get onscroll(){return this[z].get(`onscroll`)??null}set onscroll(e){this[z].set(`onscroll`,e)}get onresize(){return this[z].get(`onresize`)??null}set onresize(e){this[z].set(`onresize`,e)}get onmousedown(){return this[z].get(`onmousedown`)??null}set onmousedown(e){this[z].set(`onmousedown`,e)}get onmouseup(){return this[z].get(`onmouseup`)??null}set onmouseup(e){this[z].set(`onmouseup`,e)}get onmousemove(){return this[z].get(`onmousemove`)??null}set onmousemove(e){this[z].set(`onmousemove`,e)}get onmouseover(){return this[z].get(`onmouseover`)??null}set onmouseover(e){this[z].set(`onmouseover`,e)}get onmouseout(){return this[z].get(`onmouseout`)??null}set onmouseout(e){this[z].set(`onmouseout`,e)}get onmouseenter(){return this[z].get(`onmouseenter`)??null}set onmouseenter(e){this[z].set(`onmouseenter`,e)}get onmouseleave(){return this[z].get(`onmouseleave`)??null}set onmouseleave(e){this[z].set(`onmouseleave`,e)}get oncontextmenu(){return this[z].get(`oncontextmenu`)??null}set oncontextmenu(e){this[z].set(`oncontextmenu`,e)}get onwheel(){return this[z].get(`onwheel`)??null}set onwheel(e){this[z].set(`onwheel`,e)}get onkeydown(){return this[z].get(`onkeydown`)??null}set onkeydown(e){this[z].set(`onkeydown`,e)}get onkeyup(){return this[z].get(`onkeyup`)??null}set onkeyup(e){this[z].set(`onkeyup`,e)}get ontouchstart(){return this[z].get(`ontouchstart`)??null}set ontouchstart(e){this[z].set(`ontouchstart`,e)}get ontouchend(){return this[z].get(`ontouchend`)??null}set ontouchend(e){this[z].set(`ontouchend`,e)}get ontouchmove(){return this[z].get(`ontouchmove`)??null}set ontouchmove(e){this[z].set(`ontouchmove`,e)}get onpointerdown(){return this[z].get(`onpointerdown`)??null}set onpointerdown(e){this[z].set(`onpointerdown`,e)}get onpointerup(){return this[z].get(`onpointerup`)??null}set onpointerup(e){this[z].set(`onpointerup`,e)}get onpointermove(){return this[z].get(`onpointermove`)??null}set onpointermove(e){this[z].set(`onpointermove`,e)}cloneNode(e=!1){return super.cloneNode(e)}get[Symbol.toStringTag](){return`HTMLElement`}},It=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,o]=r.split(`,`),s=i.split(`:`)[1].split(`;`)[0],c=atob(o),l=new Uint8Array(c.length);for(let e=0;e<c.length;e++)l[e]=c.charCodeAt(e);e(new Blob([l],{type:s}))}captureStream(e){return{}}},Lt=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){let t=this.a*e.a+this.c*e.b,n=this.b*e.a+this.d*e.b,r=this.a*e.c+this.c*e.d,i=this.b*e.c+this.d*e.d,o=this.a*e.e+this.c*e.f+this.e,s=this.b*e.e+this.d*e.f+this.f;return new DOMMatrix([t,n,r,i,o,s])}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 Rt=Lt;function defineGlobal(e,t){Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}function defineGlobalIfMissing$1(e,t){globalThis[e]===void 0&&defineGlobal(e,t)}__name(defineGlobalIfMissing$1,`defineGlobalIfMissing`),setCanvasPixelBridge({imageFromSurface(e,t,n,r,i){return o.pixbuf_get_from_surface(e,t,n,r,i)},setSourceImage(e,t,n,r){o.cairo_set_source_pixbuf(e,t,n,r)},setSourcePixels(e,t,n,r,i,c){let l=s.Pixbuf.new_from_bytes(t,s.Colorspace.RGB,!0,8,n,r,n*4);o.cairo_set_source_pixbuf(e,l,i,c)}}),defineGlobal(`HTMLCanvasElement`,It),defineGlobal(`CanvasRenderingContext2D`,CanvasRenderingContext2D),defineGlobal(`DOMMatrix`,Lt),defineGlobal(`DOMMatrixReadOnly`,Rt);const zt=Symbol.for(`gjsify_canvas2d_context`);It.registerContextFactory(`2d`,(e,t)=>{let n=e,r=n[zt];if(r)return r;let i=new CanvasRenderingContext2D(e,t);return n[zt]=i,i});function defineGlobalIfMissing(e,t){globalThis[e]===void 0&&Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0})}defineGlobalIfMissing(`ImageData`,OurImageData),defineGlobalIfMissing(`Path2D`,Ae);var CharacterData=class extends gt{constructor(e=``){super(),this[F]=B.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`}},Bt=class Comment extends CharacterData{constructor(e=``){super(e),this[F]=B.COMMENT_NODE}get nodeName(){return`#comment`}cloneNode(e=!1){return new Comment(this.data)}get[Symbol.toStringTag](){return`Comment`}},Vt=class Text extends CharacterData{constructor(e=``){super(e),this[F]=B.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`}},Ht=class DocumentFragment extends gt{constructor(){super(),this[F]=B.DOCUMENT_FRAGMENT_NODE}get nodeName(){return`#document-fragment`}get children(){return this[Be]}get childElementCount(){return this[Be].length}get firstElementChild(){return this[Be][0]??null}get lastElementChild(){let e=this[Be];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 Vt(e))}append(...e){for(let t of e)typeof t==`string`?this.appendChild(new Vt(t)):this.appendChild(t)}prepend(...e){let t=this.firstChild;for(let n of e)typeof n==`string`?this.insertBefore(new Vt(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`}};N();var HTMLImageElement=class extends HTMLElement$1{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[He]=`IMG`,this[Ue]=`img`,this[We]=vt.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 o=e.slice(5,n),c=e.slice(n+1),l=o.includes(`;base64`);try{let e;e=l?i.base64_decode(c):new TextEncoder().encode(decodeURIComponent(c));let n=i.Bytes.new(e),o=r.MemoryInputStream.new_from_bytes(n);this._pixbuf=s.Pixbuf.new_from_stream(o,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&M.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&M.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=i.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=i.path_get_dirname(c.programInvocationName);n=i.build_filenamev([t,e])}try{t&&M.log(`[img] load ${n}`),this._pixbuf=s.Pixbuf.new_from_file(n),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&M.log(`[img] ok ${n} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new Event(`load`))}catch(e){t&&M.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 Ut=1e9;function secondsToGstTime(e){return BigInt(Math.round(e*Ut))}function gstTimeToSeconds(e){return Number(e)/Ut}var HTMLVideoElement=class extends HTMLMediaElement{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[He]=`VIDEO`,this[Ue]=`video`,this[We]=vt.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 Wt=new class Document extends gt{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(),r=(()=>{switch(n){case`img`:return new HTMLImageElement;case`video`:return new HTMLVideoElement;case`canvas`:return new It;default:{let e=Document._elementFactories.get(n);return e?e():new HTMLElement$1}}})();return r[Ue]=n,r[He]=n.toUpperCase(),r[We]=e??vt.html,r}createElement(e){return this.createElementNS(`http://www.w3.org/1999/xhtml`,e)}createTextNode(e){return new Vt(e)}createComment(e){return new Bt(e)}createDocumentFragment(){return new Ht}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`}};function installWindowEventBus(e){if(e.__gjsify_globalEventTarget)return e.__gjsify_globalEventTarget;let t=new EventTarget,n=typeof e.addEventListener==`function`?e.addEventListener.bind(e):null,r=typeof e.removeEventListener==`function`?e.removeEventListener.bind(e):null;e.__gjsify_globalEventTarget=t;let define=(t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return define(`addEventListener`,(e,r,i)=>{t.addEventListener(e,r,i),n?.(e,r,i)}),define(`removeEventListener`,(e,n,i)=>{t.removeEventListener(e,n,i),r?.(e,n,i)}),define(`dispatchEvent`,e=>t.dispatchEvent(e)),t}installWindowEventBus(globalThis),N(),defineGlobal(`Text`,Vt),defineGlobal(`Comment`,Bt),defineGlobal(`DocumentFragment`,Ht),defineGlobal(`DOMTokenList`,DOMTokenList),defineGlobal(`document`,Wt),defineGlobalIfMissing$1(`self`,globalThis);var Window=class{static[Symbol.hasInstance](e){return e===globalThis}};defineGlobalIfMissing$1(`Window`,Window),defineGlobalIfMissing$1(`window`,globalThis),defineGlobalIfMissing$1(`focus`,()=>{}),defineGlobalIfMissing$1(`blur`,()=>{}),defineGlobalIfMissing$1(`devicePixelRatio`,1),defineGlobalIfMissing$1(`scrollX`,0),defineGlobalIfMissing$1(`scrollY`,0),defineGlobalIfMissing$1(`pageXOffset`,0),defineGlobalIfMissing$1(`pageYOffset`,0),defineGlobalIfMissing$1(`alert`,(...e)=>M.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0});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|Kt[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+=Gt[r>>18&63]+Gt[r>>12&63]+Gt[r>>6&63]+Gt[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=Gt[r>>18&63]+Gt[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=Gt[r>>18&63]+Gt[r>>12&63]+Gt[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,o=0;for(let e=0;e<t.length;e++)r=r<<6|Kt[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[o++]=r>>i&255);return n.subarray(0,o)}function base64Encode(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],o=r+1<n?e[r+1]:0,s=r+2<n?e[r+2]:0;t+=Gt[i>>2],t+=Gt[(i&3)<<4|o>>4],t+=r+1<n?Gt[(o&15)<<2|s>>6]:`=`,t+=r+2<n?Gt[s&63]:`=`}return t}var Gt,Kt,qt=__esmMin(()=>{Gt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Kt=new Uint8Array(256);for(let e=0;e<64;e++)Kt[Gt.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(!Jt.includes(t))throw TypeError(`Unknown encoding: ${e}`)}var Jt,Yt=__esmMin(()=>{Jt=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(e,t){switch(t){case`utf8`:return textEncoder().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 textEncoder().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 textDecoder().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 textDecoder().decode(i)}}function checkOffset(e,t,n){if(e+t>n)throw RangeError(`Attempt to access memory outside buffer bounds`)}var Xt,Zt,textEncoder,textDecoder,Qt=__esmMin(()=>{qt(),textEncoder=()=>Xt??=new TextEncoder,textDecoder=()=>Zt??=new TextDecoder}),$t,H,en,tn,nn,SlowBuffer,rn=__esmMin(()=>{Qt(),Yt(),$t=typeof SharedArrayBuffer<`u`,H=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,i=n===void 0?e.byteLength-r:n;return new Buffer(e,r,i)}if($t&&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,o=n===void 0?r.byteLength-i:n,s=r.viewBytes(i,o);return new Buffer(s.buffer,s.byteOffset,s.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||$t&&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 o=e[i],s=Math.min(o.length,t-r);s<=0||(n.set(o.subarray(0,s),r),r+=s)}return n}static poolSize=65536;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 o=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,s=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(o,s)}copy(e,t=0,n=0,r){let i=r??this.length,o=Math.min(i-n,e.length-t);return o<=0?0:(e.set(this.subarray(n,n+o),t),o)}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))),o=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,s=Math.min(i.length,o);return this.set(i.subarray(0,s),t),s}fill(e,t,n,r){let i=t??0,o=n??this.length;if(typeof e==`number`)super.fill(e&255,i,o);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,o);else if(t.length===1)super.fill(t[0],i,o);else for(let e=i;e<o;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,o);else for(let t=i;t<o;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}},en=2**31-1,tn=2**28-16,nn={MAX_LENGTH:en,MAX_STRING_LENGTH:tn},SlowBuffer=class extends H{constructor(e){super(e)}}}),an=__exportAll$5({Blob:()=>S,Buffer:()=>H,File:()=>w,INSPECT_MAX_BYTES:()=>50,SlowBuffer:()=>SlowBuffer,atob:()=>on,atobPolyfill:()=>atobPolyfill,base64Decode:()=>base64Decode,base64Encode:()=>base64Encode,btoa:()=>sn,btoaPolyfill:()=>btoaPolyfill,checkEncoding:()=>checkEncoding,constants:()=>nn,default:()=>cn,kMaxLength:()=>en,kStringMaxLength:()=>tn,normalizeEncoding:()=>normalizeEncoding}),on,sn,cn,U=__esmMin(()=>{qt(),T(),Yt(),rn(),on=globalThis.atob,sn=globalThis.btoa,cn={Buffer:H,SlowBuffer,Blob:S,File:w,atob:on,btoa:sn,kMaxLength:en,kStringMaxLength:tn,constants:nn,INSPECT_MAX_BYTES:50}});U(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:H,enumerable:!1,writable:!0,configurable:!0});var ln,un=__esmMin(()=>{ln=i}),W,G=__esmMin(()=>{un(),W=ln});G(),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 W.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=W.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}),P(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:oe,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}var dn=__esmMin(()=>{});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}function hrtime(e){let t=getMonotonicTime()-fn,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()-fn}var fn,pn=__esmMin(()=>{dn(),fn=getMonotonicTime()});function probeUname(){if(mn!==void 0)return mn;mn=null;try{let e=getGjsGlobal().imports?.gi?.GLib;if(!e)return mn;let t=e.spawn_sync,n=e.SpawnFlags?.SEARCH_PATH;if(!t||n===void 0)return mn;let[r,i]=t(null,[`uname`,`-sm`],null,n,null);if(!r||!i)return mn;let o=new TextDecoder().decode(i).trim().split(/\s+/);if(o.length<2)return mn;let s=mapSysname(o[0]),c=mapMachine(o[o.length-1]);if(!s||!c)return mn;mn={platform:s,arch:c}}catch{}return mn}var mn,hn=__esmMin(()=>{dn(),P()});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(){let e=runtimeProcess();return e&&typeof e.ppid==`number`?e.ppid:hostPpid()??0}function runtimeProcess(){let e=globalThis.process;return typeof e?.release?.name==`string`?e:void 0}function onGjs(){try{return getGjsGlobal().imports?.gi!==void 0}catch{return!1}}function detectPlatform(){let e=runtimeProcess();if(e)return e.platform;if(onGjs()){let e=probeUname();if(e)return e.platform}return`linux`}function detectArch(){let e=runtimeProcess();if(e)return e.arch;if(onGjs()){let e=probeUname();if(e)return e.arch}return`x64`}function getPid(){let e=runtimeProcess();return e&&typeof e.pid==`number`?e.pid:hostPid()??0}var gn=__esmMin(()=>{dn(),hn(),P()});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(){let e=globalThis.process;return!isGjsHost()&&typeof e?.execPath==`string`?e.execPath:hostExecPath()??`/usr/bin/gjs`}function isGjsHost(){try{return getGjsGlobal().imports?.gi!==void 0}catch{return!1}}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`)}var _n=__esmMin(()=>{dn(),P()});function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,o=n?.SOURCE_REMOVE,s=n?.PRIORITY_DEFAULT,c=n?.MainContext;if(r?.exit&&i&&typeof s==`number`&&typeof o==`boolean`&&typeof c?.default==`function`){i(s,()=>(r.exit(e),o));let t=c.default();for(;;)t.iteration(!0)}try{r?.exit&&r.exit(e)}catch{}let l=globalThis.process;throw l&&typeof l.exit==`function`&&l.exit(e),Error(`process.exit(${e})`)}var vn=__esmMin(()=>{dn()});function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function classifyKillFailure(e){if(/No such process/i.test(e))return`ESRCH`;if(/Operation not permitted/i.test(e))return`EPERM`}function killPid(e,t){let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=[`kill`,r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`,`--`,String(e)],o=n.environ_setenv(n.get_environ(),`LC_ALL`,`C`,!0),[,,s,c]=n.spawn_sync(null,i,o,4,null),l=!1;try{l=n.spawn_check_wait_status(c)}catch{l=!1}if(l)return!0;let u=s?new TextDecoder().decode(s).trim():``,d=classifyKillFailure(u),p=Error(d?`kill ${d}`:`kill failed${u?`: ${u}`:``}`);throw d&&(p.code=d,p.errno=d===`ESRCH`?-3:-1,p.syscall=`kill`),p}let r=globalThis.process;if(r&&typeof r.kill==`function`)return r.kill(e,t);throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){let e=readProcessMemory();if(e)return{rss:e.resident,heapTotal:e.resident,heapUsed:e.resident,external:0,arrayBuffers:0};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}}function readUmask(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[t,n]=e.file_get_contents(`/proc/self/status`);if(t){let e=/^Umask:\s*([0-7]+)/m.exec(new TextDecoder().decode(n));if(e)return parseInt(e[1],8)}}}catch{}return 18}var yn=__esmMin(()=>{dn(),P()});function resolveSignalAdd(){let e=getGjsGlobal().imports?.gi;if(!e)return null;for(let[t,n]of[[`GLibUnix`,`signal_add`],[`GLib`,`unix_signal_add`]])try{let r=e[t]?.[n];if(typeof r==`function`)return r}catch{}return null}function isDeliverableSignal(e){return typeof e==`string`&&e in bn}function armSignal(e,t){if(xn.has(e))return;let n=bn[e],r=resolveSignalAdd(),i=getGjsGlobal().imports?.gi?.GLib;if(n===void 0||r===null||!i)return;let o=i.PRIORITY_DEFAULT,s=r(o,n,()=>(t(e),!0));xn.set(e,s)}function disarmSignal(e){let t=xn.get(e);if(t===void 0)return;xn.delete(e);let n=getGjsGlobal().imports?.gi?.GLib;n&&typeof n.source_remove==`function`&&n.source_remove(t)}var bn,xn,Sn=__esmMin(()=>{dn(),bn={SIGHUP:1,SIGINT:2,SIGTERM:15},xn=new Map});function claimRawMode(e,t){Tn.set(e,t)}function releaseRawMode(e){Tn.delete(e)}function noteRawMode(e,t,n){let r=n(t);return t?r&&claimRawMode(e,()=>{n(!1)}):releaseRawMode(e),r}function restoreClaimedRawModes(){let e=[...Tn.entries()];Tn.clear();let t=0,n;for(let[,r]of e)try{r(),t+=1}catch(e){n??=e}if(n!==void 0)throw n;return t}var Cn,wn,Tn,En=__esmMin(()=>{Cn=Symbol.for(`@gjsify/terminal-native:raw-mode-claims`),wn=globalThis,Tn=wn[Cn]??=new Map});function callableModule(){if(!On)return null;try{return On.Terminal.is_tty(2),On}catch{return null}}function nativeIsTty(e){try{return callableModule()?.Terminal.is_tty(e)??null}catch{return null}}function nativeTerminalSize(e){try{let[t,n,r]=callableModule()?.Terminal.get_size(e)??[!1,0,0];return!t||r<=0?null:{rows:n,columns:r}}catch{return null}}function nativeSetRawMode(e,t){try{return callableModule()?.Terminal.set_raw_mode(e,t)??null}catch{return null}}var Dn,On,kn,An=__esmMin(()=>{En(),P(),Dn=loadOptionalNativeModule(`GjsifyTerminal`,[`Terminal`,`ResizeWatcher`]),On=Dn.module,kn=On});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$2(e){let t=Error(`The operation was aborted`);return t.name=`AbortError`,t.code=`ABORT_ERR`,e?.reason&&(t.cause=e.reason),t}var jn,Mn,Nn,Pn=__esmMin(()=>{N(),jn=Symbol(`kCapture`),Mn=Symbol.for(`nodejs.rejection`),Nn=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=Mn;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;[jn];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[jn]=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[jn]&&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[jn]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[Mn];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[jn];try{this[jn]=!1,this.emit(`error`,e)}finally{this[jn]=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 o=this.getMaxListeners();if(o>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>o&&!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`,M.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 o=n?.signal;if(o?.aborted){i(createAbortError$2(o));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{o&&o.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{o&&o.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$2(o))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),o&&o.addEventListener(`abort`,abortHandler,{once:!0});return}let s=e,eventHandler=(...e)=>{o&&o.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&s.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{s.removeListener(t,eventHandler),o&&o.removeEventListener(`abort`,abortHandler),i(e)},s.once(`error`,errorHandler)),s.once(t,eventHandler);let abortHandler=()=>{s.removeListener(t,eventHandler),errorHandler&&s.removeListener(`error`,errorHandler),i(createAbortError$2(o))};o&&o.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,t,n){let r=n?.signal;if(r?.aborted)throw createAbortError$2(r);let i=n?.highWaterMark??2**53-1,o=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(o,`lowWaterMark`);let s=[],c=[],l=null,u=!1,d=!1,eventHandler=(...t)=>{if(c.length>0){let{resolve:e}=c.shift();e({value:t,done:!1})}else s.push(t),s.length>=i&&!d&&(d=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(l=e,c.length>0){let{reject:t}=c.shift();t(e)}p.return()},abortHandler=()=>{errorHandler(createAbortError$2(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),u=!0;for(let{resolve:e}of c)e({value:void 0,done:!0});c.length=0,s.length=0},p={next(){if(s.length>0){let t=s.shift();return d&&s.length<o&&(d=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(l){let e=Promise.reject(l);return l=null,e}return u?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{c.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return u||(l=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return p}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)}}}},Nn.EventEmitter=Nn;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=Nn.prototype[e];typeof t==`function`&&Object.defineProperty(Nn.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(Nn.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(Nn.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Nn.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name(createAbortError$2,`createAbortError`)}),Fn=__exportAll$5({EventEmitter:()=>K,addAbortListener:()=>Gn,captureRejectionSymbol:()=>In,default:()=>K,defaultMaxListeners:()=>Rn,errorMonitor:()=>Ln,getEventListeners:()=>Un,getMaxListeners:()=>Bn,listenerCount:()=>Wn,"module.exports":()=>K,on:()=>Hn,once:()=>Vn,setMaxListeners:()=>zn}),K,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn=__esmMin(()=>{Pn(),P(),K=makeCallable(Nn),K.EventEmitter=K,In=K.captureRejectionSymbol,Ln=K.errorMonitor,Rn=K.defaultMaxListeners,zn=K.setMaxListeners,Bn=K.getMaxListeners,Vn=K.once,Hn=K.on,Un=K.getEventListeners,Wn=K.listenerCount,Gn=K.addAbortListener}),qn=__exportAll$5({StringDecoder:()=>Jn,default:()=>Yn});function normalizeAndValidateEncoding(e){return e&&checkEncoding(e),normalizeEncoding(e)}function utf8DecodeMaximalSubpart(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i];if(t<=127){r+=String.fromCharCode(t),i++;continue}if(t>=194&&t<=223){i+1<n&&e[i+1]>=128&&e[i+1]<=191?(r+=String.fromCharCode((t&31)<<6|e[i+1]&63),i+=2):(r+=`�`,i++);continue}if(t>=224&&t<=239){let o,s;if(t===224?(o=160,s=191):t===237?(o=128,s=159):(o=128,s=191),i+1>=n){r+=`�`,i++;continue}let c=e[i+1];if(c<o||c>s){r+=`�`,i++;continue}if(i+2>=n){r+=`�`,i+=2;continue}let l=e[i+2];if(l<128||l>191){r+=`�`,i+=2;continue}let u=(t&15)<<12|(c&63)<<6|l&63;r+=String.fromCharCode(u),i+=3;continue}if(t>=240&&t<=244){let o,s;if(t===240?(o=144,s=191):t===244?(o=128,s=143):(o=128,s=191),i+1>=n){r+=`�`,i++;continue}let c=e[i+1];if(c<o||c>s){r+=`�`,i++;continue}if(i+2>=n){r+=`�`,i+=2;continue}let l=e[i+2];if(l<128||l>191){r+=`�`,i+=2;continue}if(i+3>=n){r+=`�`,i+=3;continue}let u=e[i+3];if(u<128||u>191){r+=`�`,i+=3;continue}let d=(t&7)<<18|(c&63)<<12|(l&63)<<6|u&63;r+=String.fromCharCode(55296+(d-65536>>10),56320+(d-65536&1023)),i+=4;continue}r+=`�`,i++}return r}function utf8CharLength(e){return e&128?e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0:1}function isValidContinuation(e,t,n,r){if(n===1){if(t===3)return e===224?r>=160&&r<=191:e===237?r>=128&&r<=159:r>=128&&r<=191;if(t===4)return e===240?r>=144&&r<=191:e===244?r>=128&&r<=143:r>=128&&r<=191}return r>=128&&r<=191}function writeUtf8(e,t){let n=0,r=``;if(e._lastNeed>0){for(;n<t.length&&e._lastNeed>0;){let i=t[n],o=e._lastTotal-e._lastNeed;if(isValidContinuation(e._lastLeadByte,e._lastTotal,o,i))e._lastChar[o]=i,e._lastNeed--,n++;else{r+=`�`,e._lastNeed=0,e._lastTotal=0,e._lastLeadByte=0;break}}if(e._lastNeed===0&&e._lastTotal>0&&(r+=utf8DecodeMaximalSubpart(e._lastChar,0,e._lastTotal),e._lastTotal=0,e._lastLeadByte=0),e._lastNeed>0)return r}let i=t.length;for(let r=0;r<Math.min(4,t.length-n);r++){let o=t.length-1-r;if(o<n)break;let s=t[o];if((s&192)!=128){let n=utf8CharLength(s);if(n>0&&s>=128){let r=t.length-o;if(r<n){let c=!0;for(let e=1;e<r;e++)if(!isValidContinuation(s,n,e,t[o+e])){c=!1;break}if(c){i=o;for(let n=0;n<r;n++)e._lastChar[n]=t[o+n];e._lastNeed=n-r,e._lastTotal=n,e._lastLeadByte=s}}}break}}return i>n&&(r+=utf8DecodeMaximalSubpart(t,n,i)),r}function writeUtf16le(e,t){let n=``,r=0;if(e._lastNeed>0){let i=e._lastTotal-e._lastNeed,o=Math.min(e._lastNeed,t.length);for(let n=0;n<o;n++)e._lastChar[i+n]=t[n];if(e._lastNeed-=o,r=o,e._lastNeed>0)return``;let s=e._lastTotal,c=0;for(;c+1<s;){let i=e._lastChar[c]|e._lastChar[c+1]<<8;if(c+=2,i>=55296&&i<=56319){if(c+1<s){let t=e._lastChar[c]|e._lastChar[c+1]<<8;if(t>=56320&&t<=57343){n+=String.fromCharCode(i,t),c+=2;continue}}if(r+1<t.length){let e=t[r]|t[r+1]<<8;if(e>=56320&&e<=57343){n+=String.fromCharCode(i,e),r+=2;continue}}else if(r>=t.length)return e._lastChar[0]=e._lastChar[c-2],e._lastChar[1]=e._lastChar[c-1],e._lastNeed=2,e._lastTotal=4,n}n+=String.fromCharCode(i)}e._lastTotal=0}for(;r+1<t.length;){let i=t[r]|t[r+1]<<8;if(r+=2,i>=55296&&i<=56319)if(r+1<t.length){let e=t[r]|t[r+1]<<8;if(e>=56320&&e<=57343){n+=String.fromCharCode(i,e),r+=2;continue}}else if(r<t.length)return n+=String.fromCharCode(i),e._lastChar[0]=t[r],e._lastNeed=1,e._lastTotal=2,n;else return e._lastChar[0]=t[r-2],e._lastChar[1]=t[r-1],e._lastNeed=2,e._lastTotal=4,n;n+=String.fromCharCode(i)}return r<t.length&&(e._lastChar[0]=t[r],e._lastNeed=1,e._lastTotal=2),n}function writeBase64(e,t){let n=0;if(e._lastNeed>0){let r=Math.min(e._lastNeed,t.length);for(let n=0;n<r;n++)e._lastChar[e._lastTotal-e._lastNeed+n]=t[n],e._lastNeed--;if(n=r,e._lastNeed>0)return``}let r=t.length-n,i=r-r%3,o=``;e._lastTotal>0&&e._lastNeed===0&&(o+=base64Encode(e._lastChar.subarray(0,e._lastTotal)),e._lastTotal=0),i>0&&(o+=base64Encode(t.subarray(n,n+i)));let s=r-i;if(s>0){for(let r=0;r<s;r++)e._lastChar[r]=t[n+i+r];e._lastNeed=3-s,e._lastTotal=3}return o}function decodeAscii(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}function decodeLatin1(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function decodeHex(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}var Jn,Yn,Xn=__esmMin(()=>{U(),Jn=function StringDecoder(e){this.encoding=normalizeAndValidateEncoding(e),this._lastNeed=0,this._lastTotal=0,this._lastLeadByte=0,this.encoding===`utf8`||this.encoding===`utf16le`?this._lastChar=new Uint8Array(4):this.encoding===`base64`?this._lastChar=new Uint8Array(3):this._lastChar=new Uint8Array},Jn.prototype.write=function write(e){if(e.length===0)return``;switch(this.encoding){case`utf8`:return writeUtf8(this,e);case`utf16le`:return writeUtf16le(this,e);case`base64`:return writeBase64(this,e);case`ascii`:return decodeAscii(e);case`latin1`:return decodeLatin1(e);case`hex`:return decodeHex(e);default:return decodeAscii(e)}},Jn.prototype.end=function end(e){let t=``;if(e&&e.length>0&&(t=this.write(e)),this.encoding===`utf8`&&this._lastNeed>0)t+=`�`,this._lastNeed=0,this._lastTotal=0;else if(this.encoding===`utf16le`&&this._lastNeed>0){let e=this._lastTotal-this._lastNeed;for(let n=0;n+1<e;n+=2)t+=String.fromCharCode(this._lastChar[n]|this._lastChar[n+1]<<8);this._lastNeed=0,this._lastTotal=0}else if(this.encoding===`base64`&&this._lastNeed>0){let e=this._lastChar.subarray(0,this._lastTotal-this._lastNeed);t+=base64Encode(e),this._lastNeed=0,this._lastTotal=0}return t},Yn={StringDecoder:Jn}}),Zn,ProcessWriteStream,ProcessReadStream,Qn=__esmMin(()=>{N(),dn(),An(),Kn(),P(),Xn(),Zn=new TextEncoder,ProcessWriteStream=class extends K{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`?Zn.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?M.error(e):M.log(e),!0}get isTTY(){let e=nativeIsTty(this.fd);if(e!==null)return e;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){let e=nativeTerminalSize(this.fd);if(e)return e.columns;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(){let e=nativeTerminalSize(this.fd);if(e)return e.rows;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 K{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_mainLoopHeld=!1;_pendingRead=!1;_decoder=null;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return nativeIsTty(this.fd)??!1}setRawMode(e){return noteRawMode(this.fd,e,e=>nativeSetRawMode(this.fd,e)===!0)?(this.isRaw=e,this):(noteRawMode(this.fd,e,e=>this._setRawModeViaStty(e)),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return!1;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`-isig`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`,`isig`],o=new n.SubprocessLauncher({flags:r}).spawnv(i);return o.wait(null),o.get_successful()}catch{return!1}}setEncoding(e){return this._decoder=new Jn(e),this}_pushData(e){if(this._decoder){let t=this._decoder.write(e);t.length>0&&this.emit(`data`,t)}else this.emit(`data`,e)}on(e,t){let n=e===`data`&&this.listenerCount(`data`)===0;return super.on(e,t),n&&e===`data`&&this.resume(),this}addListener(e,t){return this.on(e,t)}once(e,t){return super.once(e,t),this}removeListener(e,t){return super.removeListener(e,t),e===`data`&&this.listenerCount(`data`)===0&&this.pause(),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=e===void 0||e===`data`?this.listenerCount(`data`)>0:!1;return super.removeAllListeners(e),t&&this.listenerCount(`data`)===0&&this.pause(),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._pushData(Buffer.from(n));else if(n!==null&&n.byteLength===0){if(this._reading=!1,this._decoder){let e=this._decoder.end();e.length>0&&this.emit(`data`,e)}this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}}});function defineLazy(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let r=n();return Object.defineProperty(e,t,{value:r,configurable:!0,enumerable:!0,writable:!1}),r}})}var $n,Process,er=__esmMin(()=>{N(),gn(),_n(),vn(),pn(),yn(),Sn(),Qn(),An(),Kn(),$n=Date.now(),Process=class extends K{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.on(`exit`,()=>{try{restoreClaimedRawModes()}catch(e){M.error(`@gjsify/process: raw mode could not be restored:`,e)}}),defineLazy(this,`platform`,detectPlatform),defineLazy(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,this.on(`newListener`,e=>{isDeliverableSignal(e)&&armSignal(e,e=>this.emit(e,e))}),this.on(`removeListener`,e=>{isDeliverableSignal(e)&&this.listenerCount(e)===0&&disarmSignal(e)})}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()-$n)/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){let t=readUmask();return e!==void 0&&!this._umaskWarned&&(this._umaskWarned=!0,this.emitWarning(`process.umask(0${e.toString(8)}) cannot change the file-creation mask under GJS — there is no umask(2) binding, so the mask is UNCHANGED. Pass an explicit \`mode\` to open/mkdir/writeFile instead; the kernel applies it atomically at creation.`,`UnsupportedWarning`)),t}_umaskWarned=!1;emitWarning(e,t){M.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}},Process.prototype.hrtime.bigint=function(){return hrtimeBigint()}}),q,tr=__esmMin(()=>{if(pn(),er(),An(),q=new Process,kn)try{let e=new kn.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{q.stdout.emit(`resize`),q.stderr.emit(`resize`)}),e.start()}catch{}q.platform,q.arch,q.env,q.argv,q.argv0,q.execPath,q.pid,q.ppid,q.version,q.versions,q.cwd.bind(q),q.chdir.bind(q),q.exit.bind(q),q.nextTick.bind(q),Object.assign(q.hrtime.bind(q),{bigint:hrtimeBigint}),q.uptime.bind(q),q.memoryUsage.bind(q),q.cpuUsage.bind(q),q.kill.bind(q),q.abort.bind(q),q.umask.bind(q),q.emitWarning.bind(q),q.execArgv,q.config,q.stdout,q.stderr,q.stdin});G(),tr();const nr=Symbol(`kInitialize`);function getNavigatorPlatform(e,t){return t===`darwin`?`MacIntel`:t===`win32`?`Win32`:t===`linux`?e===`ia32`?`Linux i686`:e===`x64`?`Linux x86_64`:`Linux ${e}`:t===`freebsd`?e===`ia32`?`FreeBSD i386`:e===`x64`?`FreeBSD amd64`:`FreeBSD ${e}`:t===`openbsd`?e===`ia32`?`OpenBSD i386`:e===`x64`?`OpenBSD amd64`:`OpenBSD ${e}`:t===`sunos`?e===`ia32`?`SunOS i86pc`:`SunOS ${e}`:t===`aix`?`AIX`:`${t[0].toUpperCase()}${t.slice(1)} ${e}`}function gjsUserAgent(){let e=q.versions.gjs;if(!e)return`GJS`;let[t,n]=e.split(`.`);return`GJS/${t}.${n}`}function illegalConstructor(){let e=TypeError(`Illegal constructor`);return e.code=`ERR_ILLEGAL_CONSTRUCTOR`,e}var Navigator=class{#e;#t;#n;#r;constructor(e){if(e!==nr)throw illegalConstructor()}get hardwareConcurrency(){return this.#e??=W.get_num_processors(),this.#e}get language(){return this.#r,new Intl.DateTimeFormat().resolvedOptions().locale||`en-US`}get languages(){return this.#r??=Object.freeze([this.language]),this.#r}get userAgent(){return this.#t??=gjsUserAgent(),this.#t}get platform(){return this.#n??=getNavigatorPlatform(q.arch,q.platform),this.#n}};for(let e of[`hardwareConcurrency`,`language`,`languages`,`userAgent`,`platform`])Object.defineProperty(Navigator.prototype,e,{enumerable:!0});const rr=new Navigator(nr);globalThis.navigator===void 0&&Object.defineProperty(globalThis,"navigator",{value:rr,enumerable:!0,writable:!0,configurable:!0}),globalThis.Navigator===void 0&&Object.defineProperty(globalThis,"Navigator",{value:Navigator,enumerable:!1,writable:!0,configurable:!0}),P(),tr(),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:q,enumerable:!1,writable:!0,configurable:!0}),P(),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 ir=getGLib()!==void 0;function reportTimerThrow(e,t){try{e.log_default_handler(`gjsify-timers`,e.LogLevelFlags.LEVEL_WARNING,`Uncaught exception in a timer callback: ${String(t)}\n${t?.stack??``}`,null)}catch{}}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(t){reportTimerThrow(e,t)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}unref(){return this._refed=!1,this}ref(){return this._refed=!0,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){this._id!==null&&(getGLib()?.Source.remove(this._id),this._id=null)}close(){return this._cancel(),this}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){e instanceof GjsifyTimeout||typeof e==`object`&&e&&`_cancel`in e?e._cancel():typeof e==`object`&&e&&typeof e.close==`function`?e.close():typeof e==`number`&&getGLib()?.Source.remove(e)}if(ir){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 ar,or,sr=__esmMin(()=>{ar=Object.defineProperty,or=__name((e,t)=>{let n={};for(var r in e)ar(n,r,{get:e[r],enumerable:!0});return t||ar(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=``,o=0,s=-1,c=0,l;for(let u=0;u<=e.length;++u){if(u<e.length)l=e.charCodeAt(u);else if(r(l))break;else l=47;if(r(l)){if(!(s===u-1||c===1))if(s!==u-1&&c===2){if(i.length<2||o!==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=``,o=0):(i=i.slice(0,e),o=i.length-1-i.lastIndexOf(n)),s=u,c=0;continue}else if(i.length===2||i.length===1){i=``,o=0,s=u,c=0;continue}}t&&(i.length>0?i+=`${n}..`:i=`..`,o=2)}else i.length>0?i+=n+e.slice(s+1,u):i=e.slice(s+1,u),o=u-s-1;s=u,c=0}else l===46&&c!==-1?++c:c=-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 cr=__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$2(...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$2(e),t=resolve$2(t),e===t))return``;let n=e.length,r=n-1,i=1,o=t.length-i,s=r<o?r:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(i+l)===47)return t.slice(i+l+1);if(l===0)return t.slice(i+l)}else r>s&&(e.charCodeAt(1+l)===47?c=l:l===0&&(c=0));break}let n=e.charCodeAt(1+l);if(n!==t.charCodeAt(i+l))break;n===47&&(c=l)}let u=``;for(l=1+c+1;l<=n;++l)(l===n||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(i+c):(i+=c,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 o=t.length-1,s=-1;for(let c=e.length-1;c>=0;--c){let l=e.charCodeAt(c);if(l===47){if(!i){n=c+1;break}}else s===-1&&(i=!1,s=c+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=c):(o=-1,r=s))}return n===r?r=s: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,o=0;for(let s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!i){n=s+1;break}continue}r===-1&&(i=!1,r=s+1),c===46?t===-1?t=s:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||r===-1||o===0||o===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function format$3(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$3(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,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=r;--l){let t=e.charCodeAt(l);if(t===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),t===46?i===-1?i=l:u!==1&&(u=1):i!==-1&&(u=-1)}return i===-1||s===-1||u===0||u===1&&i===s-1&&i===o+1?s!==-1&&(o===0&&n?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,s)):(t.name=e.slice(o,i),t.base=e.slice(o,s)),t.ext=e.slice(i,s)),o>0?t.dir=e.slice(0,o-1):n&&(t.dir=`/`),t}var lr,ur=__esmMin(()=>{sr(),cr(),lr=or({basename:()=>basename$1,delimiter:()=>`:`,dirname:()=>dirname$1,extname:()=>extname$1,format:()=>format$3,isAbsolute:()=>isAbsolute$1,join:()=>join$1,normalize:()=>normalize$1,parse:()=>parse$3,relative:()=>relative$1,resolve:()=>resolve$2,sep:()=>`/`,toNamespacedPath:()=>toNamespacedPath$1}),__name(resolve$2,`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$3,`format`),__name(parse$3,`parse`)});function cwd(){return typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():`/`}function resolve$1(...e){let t=``,n=``,r=!1;for(let i=e.length-1;i>=-1;i--){let o;if(i>=0){if(o=e[i],assertPath(o),o.length===0)continue}else t.length===0?o=cwd():(o=globalThis.process?.env?.[`=${t}`]||cwd(),o.slice(0,2).toLowerCase()!==t.toLowerCase()&&o.charCodeAt(2)===92&&(o=`${t}\\`));let s=o.length,c=0,l=``,u=!1,d=o.charCodeAt(0);if(s===1)isPathSeparator(d)&&(c=1,u=!0);else if(isPathSeparator(d))if(u=!0,isPathSeparator(o.charCodeAt(1))){let e=matchUncRoot(o);e&&(l=e.device,c=e.rootEnd)}else c=1;else isWindowsDeviceRoot(d)&&o.charCodeAt(1)===58&&(l=o.slice(0,2),c=2,s>2&&isPathSeparator(o.charCodeAt(2))&&(u=!0,c=3));if(l.length>0)if(t.length>0){if(l.toLowerCase()!==t.toLowerCase())continue}else t=l;if(r){if(t.length>0)break}else if(n=`${o.slice(c)}\\${n}`,r=u,u&&t.length>0)break}return n=normalizeString(n,!r,`\\`,isPathSeparator),r?`${t}\\${n}`:`${t}${n}`||`.`}function matchUncRoot(e){let t=e.length,n=2,r=n;for(;n<t&&!isPathSeparator(e.charCodeAt(n));)n++;if(n>=t||n===r)return;let i=e.slice(r,n);for(r=n;n<t&&isPathSeparator(e.charCodeAt(n));)n++;if(!(n>=t||n===r)){for(r=n;n<t&&!isPathSeparator(e.charCodeAt(n));)n++;return i===`.`||i===`?`?{device:`\\\\${i}`,rootEnd:4,shareOnly:!1}:{device:`\\\\${i}\\${e.slice(r,n)}`,rootEnd:n,shareOnly:n===t}}}function normalize(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=e.charCodeAt(0);if(t===1)return isPosixPathSeparator(n)?`\\`:e;let r=0,i,o=!1;if(isPathSeparator(n))if(o=!0,isPathSeparator(e.charCodeAt(1))){let t=matchUncRoot(e);if(t?.shareOnly)return`${t.device}\\`;if(t&&(i=t.device,r=t.rootEnd,i.length===3)){let t=e.slice(4,e.indexOf(`:`)+1);isWindowsReservedName(t,t.length-1)&&(i=`\\\\?\\${t}`,r=4+t.length)}}else r=1;else{let s=e.indexOf(`:`);s>0&&(isWindowsDeviceRoot(n)&&s===1?(i=e.slice(0,2),r=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(o=!0,r=3)):isWindowsReservedName(e,s)&&(i=e.slice(0,s+1),r=s+1))}let s=r<t?normalizeString(e.slice(r),!o,`\\`,isPathSeparator):``;if(s.length===0&&!o&&(s=`.`),s.length>0&&isPathSeparator(e.charCodeAt(t-1))&&(s+=`\\`),!o&&i===void 0&&e.includes(`:`)){if(s.length>=2&&isWindowsDeviceRoot(s.charCodeAt(0))&&s.charCodeAt(1)===58)return`.\\${s}`;let n=e.indexOf(`:`);do if(n===t-1||isPathSeparator(e.charCodeAt(n+1)))return`.\\${s}`;while((n=e.indexOf(`:`,n+1))!==-1)}return isWindowsReservedName(e,e.indexOf(`:`))?`.\\${i??``}${s}`:i===void 0?o?`\\${s}`:s:o?`${i}\\${s}`:`${i}${s}`}function isWindowsReservedName(e,t){return fr.has(e.slice(0,t).toUpperCase())}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 t.split(/\\+/).some(e=>{let t=e.indexOf(`:`);return t!==-1&&isWindowsReservedName(e,t)})?t.replace(/\//g,`\\`):normalize(t)}function relative(e,t){if(assertPath(e),assertPath(t),e===t)return``;let n=resolve$1(e),r=resolve$1(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 o=e.length;for(;o-1>i&&e.charCodeAt(o-1)===92;--o);let s=o-i,c=0;for(;c<t.length&&t.charCodeAt(c)===92;++c);let l=t.length;for(;l-1>c&&t.charCodeAt(l-1)===92;--l);let u=l-c,d=s<u?s:u,p=-1,m=0;for(;m<=d;++m){if(m===d){if(u>d){if(t.charCodeAt(c+m)===92)return r.slice(c+m+1);if(m===2)return r.slice(c+m)}s>d&&(e.charCodeAt(i+m)===92?p=m:m===2&&(p=3));break}let n=e.charCodeAt(i+m);if(n!==t.charCodeAt(c+m))break;n===92&&(p=m)}if(m!==d&&p===-1)return r;let h=``;for(p===-1&&(p=0),m=i+p+1;m<=o;++m)(m===o||e.charCodeAt(m)===92)&&(h.length===0?h+=`..`:h+=`\\..`);return h.length>0?h+r.slice(c+p,l):(c+=p,r.charCodeAt(c)===92&&++c,r.slice(c,l))}function toNamespacedPath(e){if(typeof e!=`string`||e.length===0)return e;let t=resolve$1(e);if(t.length<=2)return e;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 t}function dirname(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=-1,r=-1,i=!0,o=0,s=e.charCodeAt(0);if(t>1)if(isPathSeparator(s)){if(n=o=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=o=r+1)}}}}else isWindowsDeviceRoot(s)&&e.charCodeAt(1)===58&&(n=o=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(n=o=3));else if(isPathSeparator(s))return e;for(let n=t-1;n>=o;--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 o=t.length-1,s=-1;for(let c=e.length-1;c>=n;--c){let l=e.charCodeAt(c);if(isPathSeparator(l)){if(!i){n=c+1;break}}else s===-1&&(i=!1,s=c+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=c):(o=-1,r=s))}return n===r?r=s: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,o=!0,s=0;e.length>=2&&e.charCodeAt(1)===58&&isWindowsDeviceRoot(e.charCodeAt(0))&&(t=r=2);for(let c=e.length-1;c>=t;--c){let t=e.charCodeAt(c);if(isPathSeparator(t)){if(!o){r=c+1;break}continue}i===-1&&(o=!1,i=c+1),t===46?n===-1?n=c:s!==1&&(s=1):n!==-1&&(s=-1)}return n===-1||i===-1||s===0||s===1&&n===i-1&&n===r+1?``:e.slice(n,i)}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.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 o=-1,s=r,c=-1,l=!0,u=e.length-1,d=0;for(;u>=r;--u){if(i=e.charCodeAt(u),isPathSeparator(i)){if(!l){s=u+1;break}continue}c===-1&&(l=!1,c=u+1),i===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===s+1?c!==-1&&(t.base=t.name=e.slice(s,c)):(t.name=e.slice(s,o),t.base=e.slice(s,c),t.ext=e.slice(o,c)),s>0&&s!==r?t.dir=e.slice(0,s-1):t.dir=t.root,t}var dr,fr,pr=__esmMin(()=>{sr(),cr(),dr=or({basename:()=>basename,delimiter:()=>`;`,dirname:()=>dirname,extname:()=>extname,format:()=>format$2,isAbsolute:()=>isAbsolute,join:()=>join,normalize:()=>normalize,parse:()=>parse$2,relative:()=>relative,resolve:()=>resolve$1,sep:()=>`\\`,toNamespacedPath:()=>toNamespacedPath}),__name(resolve$1,`resolve`),fr=new Set([`CON`,`PRN`,`AUX`,`NUL`,...[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`¹`,`²`,`³`].flatMap(e=>[`COM${e}`,`LPT${e}`])]),__name(format$2,`format`),__name(parse$2,`parse`)});function selectFlavour(e){return e===`win32`?dr:lr}var mr=__esmMin(()=>{ur(),pr()}),hr=__exportAll$5({basename:()=>wr,default:()=>Ar,delimiter:()=>kr,dirname:()=>Cr,extname:()=>Tr,format:()=>Er,isAbsolute:()=>yr,join:()=>br,normalize:()=>vr,parse:()=>Dr,posix:()=>lr,relative:()=>xr,resolve:()=>_r,sep:()=>Or,toNamespacedPath:()=>Sr,win32:()=>dr}),gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr=__esmMin(()=>{ur(),pr(),mr(),P(),gr=selectFlavour(hostOs()),{resolve:_r,normalize:vr,isAbsolute:yr,join:br,relative:xr,toNamespacedPath:Sr,dirname:Cr,basename:wr,extname:Tr,format:Er,parse:Dr,sep:Or,delimiter:kr}=gr,Ar={resolve:gr.resolve,normalize:gr.normalize,isAbsolute:gr.isAbsolute,join:gr.join,relative:gr.relative,toNamespacedPath:gr.toNamespacedPath,dirname:gr.dirname,basename:gr.basename,extname:gr.extname,format:gr.format,parse:gr.parse,sep:gr.sep,delimiter:gr.delimiter,posix:lr,win32:dr}}),Mr=__exportAll$5({URL:()=>J,URLSearchParams:()=>Fr,default:()=>Br,domainToASCII:()=>domainToASCII,domainToUnicode:()=>domainToUnicode,fileURLToPath:()=>fileURLToPath,format:()=>format$1,parse:()=>parse$1,pathToFileURL:()=>pathToFileURL,resolve:()=>resolve});function platformOrShapeIsWindows(e){return hostOs()===void 0?isWindowsPath(e):isWin32()}function parseFormUrlencoded(e){let t=[];if(!e)return t;for(let n of e.split(`&`)){if(n===``)continue;let e=n.indexOf(`=`);e===-1?t.push([decodeComponent(n),``]):t.push([decodeComponent(n.slice(0,e)),decodeComponent(n.slice(e+1))])}return t}function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function percentEncodeUtf8(e){let t=``;for(let n of new TextEncoder().encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function encodeComponent(e){let t=``;for(let n of e)n===` `?t+=`+`:/^[A-Za-z0-9*\-._]$/.test(n)?t+=n:t+=percentEncodeUtf8(n);return t}function isSpecialScheme(e){return Ir.has(e)}function defaultPort(e){return Ir.get(e)??null}function percentEncode(e,t){let n=``;for(let r of e){let e=r.codePointAt(0);n+=e<=32||e>126||t.includes(r)?percentEncodeUtf8(r):r}return n}function encodeQuery(e,t){return percentEncode(e,t?`"#<>'`:`"#<>`)}function isSchemeChar(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`+`||e===`-`||e===`.`}function isAsciiDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isHexDigit(e){return e!==void 0&&/^[0-9A-Fa-f]$/.test(e)}function digitPrefix(e){let t=``;for(let n of e){if(!isAsciiDigit(n))break;t+=n}return t}function hasForbiddenDomainCodePoint(e){for(let t of e){let e=t.codePointAt(0);if(e<=31||e===127||t===`%`||zr.has(t))return!0}return!1}function parseIPv6(e){let t=[0,0,0,0,0,0,0,0],n=0,r=null,i=0,at=()=>e[i];if(at()===`:`){if(e[i+1]!==`:`)return;i+=2,n++,r=n}for(;i<e.length;){if(n===8)return;if(at()===`:`){if(r!==null)return;i++,n++,r=n;continue}let o=0,s=0;for(;s<4&&isHexDigit(at());)o=o*16+Number.parseInt(at(),16),i++,s++;if(at()===`.`){if(s===0||(i-=s,n>6))return;let r=0;for(;i<e.length;){let e=null;if(r>0)if(at()===`.`&&r<4)i++;else return;if(!isAsciiDigit(at()))return;for(;isAsciiDigit(at());){let t=Number(at());if(e===null)e=t;else if(e===0)return;else e=e*10+t;if(e>255)return;i++}t[n]=t[n]*256+e,r++,(r===2||r===4)&&n++}if(r!==4)return;break}if(at()===`:`){if(i++,i>=e.length)return}else if(i<e.length)return;t[n]=o,n++}if(r!==null){let e=n-r;for(n=7;n!==0&&e>0;){let i=t[r+e-1];t[r+e-1]=t[n],t[n]=i,n--,e--}}else if(n!==8)return;return serializeIPv6(t)}function serializeIPv6(e){let t=null,n=1,r=-1,i=0;for(let o=0;o<8;o++){if(e[o]!==0){r=-1,i=0;continue}r===-1&&(r=o),i++,i>n&&(n=i,t=r)}let o=``,s=!1;for(let n=0;n<8;n++)if(!(s&&e[n]===0)){if(s=!1,t===n){o+=n===0?`::`:`:`,s=!0;continue}o+=e[n].toString(16),n!==7&&(o+=`:`)}return o}function parseHost(e,t){if(e.startsWith(`[`)){if(!e.endsWith(`]`))return;let t=parseIPv6(e.slice(1,-1));return t===void 0?void 0:`[${t}]`}if(t){for(let t of e)if(zr.has(t))return;return percentEncode(e,``)}if(!hasForbiddenDomainCodePoint(e))return e.toLowerCase()}function parseHostSetterValue(e,t,n,r,i){let o=e.replace(Rr,``),s=isSpecialScheme(t);if(t===`file`){let e=o.length;for(let t=0;t<o.length;t++){let n=o[t];if(n===`/`||n===`\\`||n===`?`||n===`#`){e=t;break}}let t=o.slice(0,e);if(t===``)return{host:``};let n=parseHost(t,!1);return n===void 0?void 0:{host:n===`localhost`?``:n}}let c=!1,l=``;for(let e=0;e<o.length;e++){let n=o[e];if(n===`:`&&!c){if(l===``||i)return;let n=parseHost(l,!s);if(n===void 0)return;let r=digitPrefix(o.slice(e+1));if(r===``)return{host:n};let c=Number(r);return c>65535?{host:n}:{host:n,port:c===defaultPort(t)?null:c}}if(n===`/`||n===`?`||n===`#`||s&&n===`\\`)break;n===`[`?c=!0:n===`]`&&(c=!1),l+=n}if(l===``&&(s||n||r))return;let u=parseHost(l,!s);return u===void 0?void 0:{host:u}}function isDoubleDotSegment(e){let t=e.toLowerCase();return t===`..`||t===`.%2e`||t===`%2e.`||t===`%2e%2e`}function isSingleDotSegment(e){let t=e.toLowerCase();return t===`.`||t===`%2e`}function parsePathSetterValue(e,t,n){let r=e.replace(Rr,``);if(t&&(r=r.replace(/\\/g,`/`)),r===``)return t||n?`/`:``;let i=[],o=(r.startsWith(`/`)?r.slice(1):r).split(`/`);for(let e=0;e<o.length;e++){let t=o[e],n=e===o.length-1;isDoubleDotSegment(t)?(i.pop(),n&&i.push(``)):isSingleDotSegment(t)?n&&i.push(``):i.push(percentEncode(t,'"#<>?^`{}'))}return`/`+i.join(`/`)}function bracketIPv6Host(e){return e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function parse$1(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(),o=i.indexOf(`#`);o!==-1&&(r.hash=i.slice(o),i=i.slice(0,o));let s=i.indexOf(`?`);s!==-1&&(r.search=i.slice(s),r.query=t?Object.fromEntries(new Fr(i.slice(s+1))):i.slice(s+1),i=i.slice(0,s));let c=/^([a-z][a-z0-9.+-]*:)/i.exec(i);if(c&&(r.protocol=c[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$1(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$1(e){if(typeof e==`string`)return e;if(e instanceof J)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 Fr(t.query).toString();e&&(n+=`?`+e)}return t.hash&&(n+=t.hash),n}function resolve(e,t){return new J(t,new J(e,`resolve://`)).href.replace(/^resolve:\/\//,``)}function fileURLToPath(e,t){if(typeof e==`string`&&(e=new J(e)),!(e instanceof J))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`);let n=e.pathname,r=t?.windows??platformOrShapeIsWindows(n.slice(1));for(let e=0;e<n.length;e++){if(n[e]!==`%`)continue;let t=n.codePointAt(e+2)|32,i=n[e+1]===`2`&&t===102,o=n[e+1]===`5`&&t===99;if(r&&(i||o))throw TypeError(`File URL path must not include encoded \\ or / characters`);if(i)throw TypeError(`File URL path must not include encoded / characters`)}if(e.hostname!==``&&e.hostname!==`localhost`){if(!r)throw TypeError(`File URL host must be "localhost" or empty on ${hostOs()??`this platform`}`);return`\\\\${e.hostname}${decodeURIComponent(n).replace(/\//g,`\\`)}`}if(r){let e=decodeURIComponent(n);return/^\/[A-Za-z]:/.test(e)?e.slice(1).replace(/\//g,`\\`):e.replace(/\//g,`\\`)}return decodeURIComponent(n)}function pathToFileURL(e,t){let n=t?.windows??platformOrShapeIsWindows(e),r=n&&e.startsWith(`\\\\`)?e:(n?dr:lr).resolve(currentDir(),e);if(n&&r.startsWith(`\\\\`))return uncPathToFileURL(r);let i=e.charCodeAt(e.length-1);return(i===47||n&&i===92)&&r[r.length-1]!==Or&&(r+=`/`),new J(pathToFileUrlHref(r,{windows:n}))}function currentDir(){return typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():W.get_current_dir()}function uncPathToFileURL(e){let t=e.startsWith(`\\\\?\\UNC\\`)?8:2,n=e.indexOf(`\\`,t);if(n===-1)throw invalidPathValue(e,`Missing UNC resource path`);if(n===2)throw invalidPathValue(e,`Empty UNC servername`);let r=e.slice(t,n);return new J(`file://${r===`?`?``:r}${encodePathForFileUrl(e.slice(n).replace(/\\/g,`/`))}`)}function invalidPathValue(e,t){let n=TypeError(`The argument 'path' ${t}. Received '${e}'`);return n.code=`ERR_INVALID_ARG_VALUE`,n}function domainToASCII(e){try{return new J(`http://${e}`).hostname}catch{return``}}function domainToUnicode(e){try{return new J(`http://${e}`).hostname}catch{return``}}var Nr,Pr,Fr,Ir,Lr,Rr,zr,J,Br,Vr=__esmMin(()=>{G(),P(),jr(),Nr=W.UriFlags.HAS_PASSWORD|W.UriFlags.ENCODED|W.UriFlags.SCHEME_NORMALIZE,Pr=new WeakMap,Fr=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`)this._entries=parseFormUrlencoded(e.startsWith(`?`)?e.slice(1):e);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]);Pr.get(this)?.()}has(e,t){return t===void 0?this._entries.some(([t])=>t===e):this._entries.some(([n,r])=>n===e&&r===t)}delete(e,t){this._entries=t===void 0?this._entries.filter(([t])=>t!==e):this._entries.filter(([n,r])=>!(n===e&&r===t)),Pr.get(this)?.()}append(e,t){this._entries.push([e,t]),Pr.get(this)?.()}sort(){this._entries.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),Pr.get(this)?.()}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}},Ir=new Map([[`ftp`,21],[`file`,null],[`http`,80],[`https`,443],[`ws`,80],[`wss`,443]]),Lr='"#/:;<=>?@[\\]^`{|}',Rr=/[\t\n\r]/g,zr=new Set([`\0`,` `,`
11
- `,`\r`,` `,`#`,`/`,`:`,`<`,`>`,`?`,`@`,`[`,`\\`,`]`,`^`,`|`]),J=class URL{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;constructor(e,t){let n=e instanceof URL?e.href:String(e),r;try{if(t!==void 0){let e=t instanceof URL?t.href:String(t);r=W.Uri.parse(e,Nr).parse_relative(n,Nr)}else r=W.Uri.parse(n,Nr)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!r)throw TypeError(`Invalid URL: ${n}`);this.#e=r.get_scheme();let i=isSpecialScheme(this.#e);this.#t=r.get_user()??``,this.#n=r.get_password()??``;let o=r.get_host(),s=o===null?null:bracketIPv6Host(o.toLowerCase());this.#r=s===null?i?``:null:this.#e===`file`&&s===`localhost`?``:s;let c=r.get_port();this.#i=c===-1||c===defaultPort(this.#e)?null:c,this.#a=r.get_path()??``,i&&this.#a===``&&(this.#a=`/`),this.#o=this.#r===null&&!this.#a.startsWith(`/`),this.#r===null&&!this.#o&&this.#a.startsWith(`/.//`)&&(this.#a=this.#a.slice(2)),this.#s=r.get_fragment()??null,this.#l=r.get_query()??null,this.#c=new Fr,this.#c._entries=parseFormUrlencoded(this.#l??``),Pr.set(this.#c,()=>{let e=this.#c.toString();this.#l=e===``?null:e})}get protocol(){return this.#e+`:`}set protocol(e){let t=String(e).replace(Rr,``)+`:`;if(!/^[A-Za-z]/.test(t))return;let n=``;for(let e of t){if(e===`:`)break;if(!isSchemeChar(e))return;n+=e.toLowerCase()}isSpecialScheme(this.#e)===isSpecialScheme(n)&&(n===`file`&&(this.#t!==``||this.#n!==``||this.#i!==null)||this.#e===`file`&&(this.#r===null||this.#r===``)||(this.#e=n,this.#i!==null&&this.#i===defaultPort(n)&&(this.#i=null)))}get hostname(){return this.#r??``}set hostname(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!0);t!==void 0&&(this.#r=t.host)}get port(){return this.#i===null?``:String(this.#i)}set port(e){if(this.#u())return;let t=String(e);if(t===``){this.#i=null;return}let n=digitPrefix(t.replace(Rr,``));if(n===``)return;let r=Number(n);r>65535||(this.#i=r===defaultPort(this.#e)?null:r)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}set host(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!1);t!==void 0&&(this.#r=t.host,t.port!==void 0&&(this.#i=t.port))}get pathname(){return this.#a}set pathname(e){this.#o||(this.#a=parsePathSetterValue(String(e),isSpecialScheme(this.#e),this.#r===null))}get search(){return this.#l?`?`+this.#l:``}set search(e){let t=String(e);if(t===``){this.#l=null,this.#c._entries=[];return}let n=(t.startsWith(`?`)?t.slice(1):t).replace(Rr,``);this.#l=encodeQuery(n,isSpecialScheme(this.#e)),this.#c._entries=parseFormUrlencoded(n)}get hash(){return this.#s?`#`+this.#s:``}set hash(e){let t=String(e);if(t===``){this.#s=null;return}let n=(t.startsWith(`#`)?t.slice(1):t).replace(Rr,``);this.#s=percentEncode(n,'"<>`')}get origin(){return isSpecialScheme(this.#e)&&this.#e!==`file`?`${this.protocol}//${this.host}`:`null`}get username(){return this.#t}set username(e){this.#u()||(this.#t=percentEncode(String(e),Lr))}get password(){return this.#n}set password(e){this.#u()||(this.#n=percentEncode(String(e),Lr))}#u(){return this.#r===null||this.#r===``||this.#e===`file`}get href(){let e=this.#e+`:`;return this.#r===null?!this.#o&&this.#a.startsWith(`//`)&&(e+=`/.`):(e+=`//`,(this.#t!==``||this.#n!==``)&&(e+=this.#t,this.#n!==``&&(e+=`:`+this.#n),e+=`@`),e+=this.#r,this.#i!==null&&(e+=`:`+this.#i)),e+=this.#a,e+=this.#l===null?``:`?${this.#l}`,e+=this.#s===null?``:`#${this.#s}`,e}set href(e){let t=new URL(String(e));this.#e=t.#e,this.#t=t.#t,this.#n=t.#n,this.#r=t.#r,this.#i=t.#i,this.#a=t.#a,this.#o=t.#o,this.#l=t.#l,this.#s=t.#s,this.#c._entries=parseFormUrlencoded(this.#l??``)}get searchParams(){return this.#c}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);t&&(W.unlink(t),URL._objectURLPaths.delete(e))}},__name(parse$1,`parse`),__name(format$1,`format`),Br={URL:J,URLSearchParams:Fr,parse:parse$1,format:format$1,resolve,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});Vr(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:J,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:Fr,enumerable:!1,writable:!0,configurable:!0});let Hr;if(globalThis.performance)Hr=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();Hr={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,o=_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&&(o=e.startTime)}let s={name:e,entryType:`measure`,startTime:i,duration:o-i};return t.push(s),s},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 Ur=globalThis,Wr=Ur.PerformanceObserver||PerformanceObserverStub;Ur.PerformanceEntry,Ur.PerformanceObserverEntryList,Ur.PerformanceMark,Ur.PerformanceMeasure;const Gr=globalThis;globalThis.performance===void 0&&(Gr.performance=Hr),typeof Gr.PerformanceObserver!=`function`&&(Gr.PerformanceObserver=Wr);const Kr=Symbol(`abort`),qr=Symbol(`internal`);var Jr=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==qr)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 reason(){return this.#t}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.#t}[Kr](e){if(this.#e)return;this.#e=!0,this.#t=e??new V(`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(qr);return t[Kr](e),t}static timeout(e){let t=new AbortSignal(qr);return setTimeout(()=>{t[Kr](new V(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(qr);for(let n of e)if(n.aborted)return t[Kr](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Kr](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},Yr=class AbortController{signal;constructor(){this.signal=new Jr(qr)}get[Symbol.toStringTag](){return`AbortController`}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Kr](e)}};const Xr=globalThis;globalThis.AbortController===void 0&&(Xr.AbortController=Yr),globalThis.AbortSignal===void 0&&(Xr.AbortSignal=Jr);const Y=Symbol(`kState`),Zr=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[Y]!==void 0&&t[Zr]===e}function dequeueValue(e){let t=e[Y].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[Y].queueTotalSize=Math.max(0,e[Y].queueTotalSize-r),n}function resetQueue(e){e[Y].queue=[],e[Y].queueTotalSize=0}function peekQueueValue(e){return e[Y].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[Y].queue.push({value:t,size:n}),e[Y].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 Qr={__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 $r=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}},ei=Symbol(`kAbort`),ti=Symbol(`kCloseSentinel`),ni=Symbol(`kError`),ri=Symbol(`kSkipThrow`);var WritableStream=class{[Zr]=`WritableStream`;[Y];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[Y]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!ii(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return ii(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return ii(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(!ii(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[Zr]=`WritableStreamDefaultWriter`;[Y];constructor(e){if(!ii(e))throw TypeError(`Expected a WritableStream`);this[Y]={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 ai(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!ai(this))throw TypeError(`Invalid this`);if(this[Y].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return ai(this)?this[Y].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return ai(this)?this[Y].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!ai(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Y];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(!ai(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return ai(this)?this[Y].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{[Zr]=`WritableStreamDefaultController`;[Y];constructor(e){if(e!==ri)throw TypeError(`Illegal constructor`)}[ei](e){let t=this[Y].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[ni](){resetQueue(this)}get signal(){if(!oi(this))throw TypeError(`Invalid this`);return this[Y].abortController.signal}error(e){if(!oi(this))throw TypeError(`Invalid this`);this[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const ii=isBrandCheck(`WritableStream`),ai=isBrandCheck(`WritableStreamDefaultWriter`),oi=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[Y].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[Y].stream=t,t[Y].writer=e,t[Y].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[Y].backpressure?e[Y].ready=Promise.withResolvers():e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close=Promise.withResolvers();break;case`erroring`:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),setPromiseHandled(e[Y].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[Y];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[Y].abortController.abort(t),e[Y].pendingAbortRequest.abort.promise!==void 0)return e[Y].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let o=Promise.withResolvers();return e[Y].pendingAbortRequest={abort:o,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),o.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[Y];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Y].closeRequest=Promise.withResolvers();let{promise:o}=e[Y].closeRequest;return n!==void 0&&r&&t===`writable`&&n[Y].ready.resolve?.(),writableStreamDefaultControllerClose(i),o}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[Y];n!==void 0&&e[Y].backpressure!==t&&(t?n[Y].ready=Promise.withResolvers():n[Y].ready.resolve?.()),e[Y].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[Y];e[Y].state=`erroring`,e[Y].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[Y].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Y].closeRequest.promise!==void 0&&(e[Y].closeRequest.reject?.(e[Y].storedError),e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Y].close.promise),e[Y].close.reject?.(e[Y].storedError);let{writer:t}=e[Y];t!==void 0&&(setPromiseHandled(t[Y].close.promise),t[Y].close.reject?.(e[Y].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[Y].writeRequests.shift();e[Y].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[Y].inFlightCloseRequest=e[Y].closeRequest,e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Y].inFlightWriteRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[Y].inFlightWriteRequest.reject?.(t),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[Y].inFlightWriteRequest.resolve?.(),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[Y].inFlightCloseRequest.reject?.(t),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.reject?.(t),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[Y].inFlightCloseRequest.resolve?.(),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].state===`erroring`&&(e[Y].storedError=void 0,e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.resolve?.(),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Y].state=`closed`,e[Y].writer!==void 0&&e[Y].writer[Y].close.resolve?.(),e[Y].close.resolve?.()}function writableStreamFinishErroring(e){e[Y].state=`errored`,e[Y].controller[ni]();let t=e[Y].storedError;for(let n of e[Y].writeRequests)n.reject?.(t);if(e[Y].writeRequests=[],e[Y].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[Y].pendingAbortRequest;if(e[Y].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[Y].controller[ei](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[Y].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Y].closeRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[Y].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[Y],{controller:r}=n[Y],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[Y].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:o}=n[Y];if(o===`errored`)return Promise.reject(n[Y].storedError);if(writableStreamCloseQueuedOrInFlight(n)||o===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(o===`erroring`)return Promise.reject(n[Y].storedError);let s=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),s}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[Y],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[Y].writer=void 0,e[Y].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[Y];switch(t[Y].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[Y].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[Y].ready.reject?(e[Y].ready.reject(t),e[Y].ready.resolve=void 0,e[Y].ready.reject=void 0):e[Y].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[Y].close.reject?(e[Y].close.reject(t),e[Y].close.resolve=void 0,e[Y].close.reject=void 0):e[Y].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[Y],{state:n}=t[Y];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[Y].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Y].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[Y].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[Y];!writableStreamCloseQueuedOrInFlight(r)&&r[Y].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[Y];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[Y];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[Y].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[Y];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Y].highWaterMark-e[Y].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[Y];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Y].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,ti,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Y].writeAlgorithm=void 0,e[Y].closeAlgorithm=void 0,e[Y].abortAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[Y];if(!n||r[Y].inFlightWriteRequest.promise!==void 0)return;if(r[Y].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===ti?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(ri),o=t?.start,s=t?.write,c=t?.close,l=t?.abort;setupWritableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`sink.write`,s,t):nonOpWrite,c?createPromiseCallback(`sink.close`,c,t):nonOpCancel,l?createPromiseCallback(`sink.abort`,l,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,o,s,c){t[Y]={abortAlgorithm:o,closeAlgorithm:i,highWaterMark:s,queue:[],queueTotalSize:0,abortController:new $r,sizeAlgorithm:c,started:!1,stream:e,writeAlgorithm:r},e[Y].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let l=n();new Promise(e=>e(l)).then(()=>{t[Y].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[Y].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,o=()=>1){let s=Object.create(WritableStream.prototype);return s[Zr]=`WritableStream`,s[Y]=createWritableStreamState(),setupWritableStreamDefaultController(s,new WritableStreamDefaultController(ri),e,t,n,r,i,o),s}P();const si=Symbol(`kCancel`),ci=Symbol(`kClose`),li=Symbol(`kChunk`),ui=Symbol(`kError`),di=Symbol(`kPull`),fi=Symbol(`kRelease`),pi=Symbol(`kSkipThrow`);let mi,hi;function lazyReadableReleasedError(){return mi||(mi=TypeError(`Reader released`),mi)}function lazyReadableReleasingError(){return hi||(hi=TypeError(`Releasing reader`),hi)}function createAbortError$1(){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}__name(createAbortError$1,`createAbortError`);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`)}[Zr]=`ReadableStream`;[Y];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[Y]=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(!gi(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return gi(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!gi(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(!gi(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!gi(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!ii(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,o=t?.preventCancel,s=t?.preventClose,c=t?.signal;if(c!==void 0&&!(c instanceof Object&&`aborted`in c))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,!!s,!!i,!!o,c)),n}pipeTo(e,t={}){try{if(!gi(this))throw TypeError(`Invalid this`);if(!ii(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,o=t?.signal;if(o!==void 0&&!(o instanceof Object&&`aborted`in o))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,o)}catch(e){return Promise.reject(e)}}tee(){if(!gi(this))throw TypeError(`Invalid this`);let e=this[Y].controller;return yi(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!gi(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[Y].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,{[li](e){r.current=void 0,t({value:e,done:!1})},[ci](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[ui](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[Y].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}},Qr)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](){this[Y].resolve?.({value:void 0,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamDefaultReader=class{[Zr]=`ReadableStreamDefaultReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!vi(this))return Promise.reject(TypeError(`Invalid this`));if(this[Y].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Y].stream,t=e[Y].controller;if(e[Y].state===`readable`&&_i(t)&&t[Y].queue.length>0){e[Y].disturbed=!0;let n=dequeueValue(t);return t[Y].closeRequested&&!t[Y].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(!vi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return vi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return vi(this)?this[Y].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{[Zr]=`ReadableStreamDefaultController`;[Y];constructor(e){if(e!==pi)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)}[si](e){return readableStreamDefaultControllerCancelSteps(this,e)}[di](e){readableStreamDefaultControllerPullSteps(this,e)}[fi](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const gi=isBrandCheck(`ReadableStream`),_i=isBrandCheck(`ReadableStreamDefaultController`),vi=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Y].reader!==void 0}function readableStreamCancel(e,t){switch(e[Y].disturbed=!0,e[Y].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Y].storedError)}readableStreamClose(e);let n=e[Y].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[Y].readIntoRequests;n[Y].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][ci](void 0)}return e[Y].controller[si](t).then(()=>{})}function readableStreamClose(e){e[Y].state=`closed`,e[Y].closedPromise.resolve();let{reader:t}=e[Y];if(t!==void 0&&(t[Y].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[Y].readRequests.length;e++)t[Y].readRequests[e][ci]();t[Y].readRequests=[]}}function readableStreamError(e,t){e[Y].state=`errored`,e[Y].storedError=t,setPromiseHandled(e[Y].closedPromise.promise),e[Y].closedPromise.reject(t);let{reader:n}=e[Y];if(n!==void 0){if(setPromiseHandled(n[Y].close.promise),n[Y].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[Y].readRequests.length;e++)n[Y].readRequests[e][ui](t);n[Y].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[Y].readIntoRequests.length;e++)n[Y].readIntoRequests[e][ui](t);n[Y].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Y].reader[Y].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readRequests.shift();n?i[ci]():i[li](t)}function readableStreamAddReadRequest(e,t){e[Y].reader[Y].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[Y];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[Y].stream=t,t[Y].reader=e,t[Y].state){case`readable`:e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[Y],n=lazyReadableReleasedError();t[Y].state===`readable`?e[Y].close.reject?.(n):e[Y].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise),t[Y].controller[fi](),t[Y].reader=void 0,e[Y].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[Y].readRequests.length;++n)e[Y].readRequests[n][ui](t);e[Y].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[Y];switch(n[Y].disturbed=!0,n[Y].state){case`closed`:t[ci]();break;case`errored`:t[ui](n[Y].storedError);break;case`readable`:n[Y].controller[di](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[Y].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Y].closeRequested=!0,e[Y].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[Y];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[Y].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[Y];return!e[Y].closeRequested&&t[Y].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[Y];switch(t[Y].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[Y];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[Y];if(r.length){let i=dequeueValue(e);e[Y].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[li](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:s,stream:e},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(pi),o=t?.start,s=t?.pull,c=t?.cancel;setupReadableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`source.pull`,s,t):nonOpPull,c?createPromiseCallback(`source.cancel`,c,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let o=Object.create(ReadableStream$1.prototype);return o[Zr]=`ReadableStream`,o[Y]=createReadableStreamState(),setupReadableStreamDefaultController(o,new ReadableStreamDefaultController(pi),e,t,n,r,i),o}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[Y].controller):readableStreamDefaultControllerEnqueue(t[Y].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,o){let s,c;try{s=new ReadableStreamDefaultReader(e),c=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[Y].disturbed=!0;let l=!1,{promise:u,resolve:d,reject:p}=Promise.withResolvers(),m={currentWrite:Promise.resolve()},h;function finalize(e,t){writableStreamDefaultWriterRelease(c),readableStreamReaderGenericRelease(s),o!==void 0&&h&&(o.removeEventListener(`abort`,h),h=void 0),e?p(t):d()}async function waitForCurrentWrite(){let e=m.currentWrite;await e,e!==m.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(l)return;if(l=!0,t[Y].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(!l){if(l=!0,t[Y].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=o.reason&&o.reason.name===`AbortError`?createAbortError$1():o.reason;let s=[];r||s.push(()=>t[Y].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||s.push(()=>e[Y].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(s.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[Y].state===`errored`?n(e[Y].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[Y].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[li](e){oe(()=>{m.currentWrite=writableStreamDefaultWriterWrite(c,e),setPromiseHandled(m.currentWrite),g.resolve(!1)})}[ci](){g.resolve(!0)}[ui](e){g.reject(e)}}let g={resolve:null,reject:null};async function step(){if(l||t[Y].backpressure&&(await c[Y].ready.promise,l))return!0;let n=e[Y].controller;if(e[Y].state===`readable`&&_i(n)&&n[Y].queue.length>0){for(;n[Y].queue.length>0;){if(l)return!0;let r=dequeueValue(n);if(n[Y].closeRequested&&!n[Y].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),m.currentWrite=writableStreamDefaultWriterWrite(c,r),setPromiseHandled(m.currentWrite),t[Y].backpressure||t[Y].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[Y].state===`closed`}let{promise:r,resolve:i,reject:o}=Promise.withResolvers();return g={resolve:i,reject:o},readableStreamDefaultReaderRead(s,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(o!==void 0){if(o.aborted)return abortAlgorithm(),u;h=abortAlgorithm,o.addEventListener(`abort`,h,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,s[Y].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,c[Y].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,s[Y].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(c));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[Y].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return u}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,o=!1,s,c,l,u,d=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[li](e){oe(()=>{r=!1;let n=e,s=e;if(!o&&t)try{s=structuredClone(s)}catch{}i||readableStreamDefaultControllerEnqueue(l[Y].controller,n),o||readableStreamDefaultControllerEnqueue(u[Y].controller,s)})},[ci](){oe(()=>{r=!1,i||readableStreamDefaultControllerClose(l[Y].controller),o||readableStreamDefaultControllerClose(u[Y].controller),(!i||!o)&&d.resolve(void 0)})},[ui](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,s=t,o){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}function cancel2Algorithm(t){if(o=!0,c=t,i){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}return l=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),u=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[Y].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(l[Y].controller,e),readableStreamDefaultControllerError(u[Y].controller,e),(!i||!o)&&d.resolve(void 0)}),[l,u]}var BYOBReadIntoRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](e){this[Y].resolve?.({value:e,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamBYOBReader=class{[Zr]=`ReadableStreamBYOBReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!bi(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 o=e[Symbol.toStringTag];if(o!==void 0&&o!==`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[Y].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let s=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,s),s.promise}releaseLock(){if(!bi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return bi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return bi(this)?this[Y].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{[Zr]=`ReadableStreamBYOBRequest`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get view(){if(!xi(this))throw TypeError(`Invalid this`);return this[Y].view}respond(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Y].controller,e)}respondWithNewView(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[Zr]=`ReadableByteStreamController`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!yi(this))throw TypeError(`Invalid this`);if(this[Y].closeRequested)throw TypeError(`Close already requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!yi(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[Y].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!yi(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[si](e){return readableByteStreamControllerCancelSteps(this,e)}[di](e){readableByteStreamControllerPullSteps(this,e)}[fi](){if(this[Y].pendingPullIntos.length>0){let e=this[Y].pendingPullIntos[0];e.readerType=`none`,this[Y].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const yi=isBrandCheck(`ReadableByteStreamController`),bi=isBrandCheck(`ReadableStreamBYOBReader`),xi=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Y].reader[Y].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[Y].reader[Y].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readIntoRequests.shift();n?i[ci](t):i[li](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!yi(t[Y].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[Y].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[Y];i[Y].disturbed=!0,i[Y].state===`errored`?r[ui](i[Y].storedError):readableByteStreamControllerPullInto(i[Y].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[Y].readIntoRequests.length;n++)e[Y].readIntoRequests[n][ui](t);e[Y].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[Y].byobRequest;t!=null&&(t[Y].controller=void 0,t[Y].view=null,e[Y].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[Y].stream[Y].state;return t===`errored`?null:t===`closed`?0:e[Y].highWaterMark-e[Y].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[Y];if(t[Y].state!==`readable`||e[Y].closeRequested||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[Y].queueTotalSize===0&&e[Y].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[Y].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[Y].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[Y].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[Y].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[Y].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,o=!1,s=r-r%t.elementSize;s>=t.minimumFill&&(i=s-t.bytesFilled,o=!0);let c=e[Y].queue;for(;i>0;){let n=c[0],r=Math.min(i,n.byteLength),o=t.byteOffset+t.bytesFilled,s=new Uint8Array(t.buffer,o,r),l=new Uint8Array(n.buffer,n.byteOffset,r);s.set(l),n.byteLength===r?c.shift():(n.byteOffset+=r,n.byteLength-=r),e[Y].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return o}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[Y].queue.shift();e[Y].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[li](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[Y].stream[Y].reader;for(;t[Y].readRequests.length!==0;){if(e[Y].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[Y].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Y].pendingPullIntos.length!==0;){if(e[Y].queueTotalSize===0)return;let t=e[Y].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Y].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Y].byobRequest===null&&e[Y].pendingPullIntos.length!==0){let t=e[Y].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(pi);r[Y]={controller:e,view:n},e[Y].byobRequest=r}return e[Y].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[Y];if(e[Y].closeRequested||n[Y].state!==`readable`)return;let r=t.buffer,i=t.byteLength,o=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let s=transferArrayBuffer(r);if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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,s,o,i):(e[Y].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(s,o,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[Y];if(!(e[Y].closeRequested||t[Y].state!==`readable`)){if(e[Y].queueTotalSize>0){e[Y].closeRequested=!0;return}if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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[Y].stream,o=t[Symbol.toStringTag],s,c;if(o===void 0||o===`DataView`)s=DataView,c=1;else{let e=typedArrayConstructorByTag(o);if(!e){r[ui](TypeError(`Unsupported typed array: ${o}`));return}s=e,c=elementSizeByTag(o)}let l=t.buffer,u=t.byteLength,d=t.byteOffset,p=n*c,m;try{m=transferArrayBuffer(l)}catch(e){r[ui](e);return}let h={buffer:m,bufferByteLength:m.byteLength,byteOffset:d,byteLength:u,bytesFilled:0,minimumFill:p,elementSize:c,viewConstructor:s,readerType:`byob`};if(e[Y].pendingPullIntos.length!==0){e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r);return}if(i[Y].state===`closed`){let e=new s(h.buffer,h.byteOffset,0);r[ci](e);return}if(e[Y].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,h)){let t=readableByteStreamControllerConvertPullIntoDescriptor(h);readableByteStreamControllerHandleQueueDrain(e),r[li](t);return}if(e[Y].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[ui](t);return}}e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[Y].pendingPullIntos[0];if(e[Y].stream[Y].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[Y].pendingPullIntos[0],r=e[Y].stream[Y].state,i=t.byteLength,o=t.byteOffset,s=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!==o)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==s.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(s),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[Y].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].stream[Y].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[Y].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[Y].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[Y].stream;if(e[Y].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[Y].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[ui](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Y].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:s},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(pi),i=t?.start,o=t?.pull,s=t?.cancel,c=t?.autoAllocateChunkSize;if(c!==void 0&&(c===0||!Number.isInteger(c)||c<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,c)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,o,s,c=Promise.withResolvers(),l,u,d,p;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||d.close(),i||p.close();return}let t=e.value,o=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||d.enqueue(o),i||p.enqueue(new Uint8Array(o))},()=>{}),Promise.resolve())}return l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,o=t,i){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),u=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,s=t,r){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),d=l[Y].controller,p=u[Y].controller,t.closed.catch(e=>{d.error(e),p.error(e),(!r||!i)&&c.resolve()}),[l,u]}const Si=Symbol(`kSkipThrow`);var TransformStream=class{[Zr]=`TransformStream`;[Y];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,o=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let s=extractHighWaterMark(n?.highWaterMark,0),c=extractSizeAlgorithm(n?.size),l=extractHighWaterMark(t?.highWaterMark,1),u=extractSizeAlgorithm(t?.size),d=Promise.withResolvers();initializeTransformStream(this,d,l,u,s,c),setupTransformStreamDefaultControllerFromTransformer(this,e),o===void 0?d.resolve():d.resolve(o.call(e,this[Y].controller))}get readable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].readable}get writable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[Zr]=`TransformStreamDefaultController`;[Y];constructor(e){if(e!==Si)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!wi(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y],{readable:t}=e[Y],n=t[Y].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Ci=isBrandCheck(`TransformStream`),wi=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,o){let startAlgorithm=()=>t.promise,s=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[Y]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,o),writable:s,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[Y];readableStreamDefaultControllerError(n[Y].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[Y];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Y].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[Y].backpressureChange.promise!==void 0&&e[Y].backpressureChange.resolve?.(),e[Y].backpressureChange=Promise.withResolvers(),e[Y].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[Y]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[Y].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Si),r=t?.transform,i=t?.flush,o=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,o?createPromiseCallback(`transformer.cancel`,o,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Y].transformAlgorithm=void 0,e[Y].flushAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[Y],{readable:r}=n[Y],i=r[Y].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[Y].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[Y].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[Y].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[Y].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[Y].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[Y],{readable:n}=t[Y];readableStreamDefaultControllerClose(n[Y].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[Y];return e[Y].backpressure?e[Y].backpressureChange.promise.then(()=>{let{writable:r}=e[Y];if(r[Y].state===`erroring`)throw r[Y].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(readableStreamDefaultControllerError(r[Y].controller,t),o())},e=>{readableStreamDefaultControllerError(r[Y].controller,e),s(e)}),n[Y].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:r,resolve:i,reject:o}=Promise.withResolvers();n[Y].finishPromise=r;let s=n[Y].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{t[Y].state===`errored`?o(t[Y].storedError):(readableStreamDefaultControllerClose(t[Y].controller),i())},e=>{readableStreamDefaultControllerError(t[Y].controller,e),o(e)}),n[Y].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Y].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),o())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),s(t)}),n[Y].finishPromise}const Ti=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),Ei=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 Ti}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 Ei}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 Di=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),Di)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 o=incompleteUtf8Tail$1(i),s;if(o>0?(s=i.slice(0,i.length-o),e=i.slice(i.length-o)):(s=i,e=new Uint8Array),s.length>0){let e=this.#e.decode(s);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 Oi=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,ki=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Ai=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,ji=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Mi=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Ni=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Pi=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Fi,Ii=__esmMin(()=>{Fi=r}),X,Z=__esmMin(()=>{Ii(),X=Fi});function getGioFormat(e){switch(e){case`gzip`:return X.ZlibCompressorFormat.GZIP;case`deflate`:return X.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return X.ZlibCompressorFormat.RAW}}function concat$2(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function assertLevel(e){if(!(e>=-1&&e<=9))throw RangeError(`The value of "level" is out of range. It must be >= -1 and <= 9. Received ${e}`)}function compressWithGio(e,t,n=-1){assertLevel(n);let r=new X.ZlibCompressor({format:getGioFormat(t),level:Math.trunc(n)}),i=new X.ConverterOutputStream({base_stream:X.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new W.Bytes(e),null),i.close(null);let o=i.get_base_stream().steal_as_bytes();return new Uint8Array(o.get_data()??[])}function decompressStreamWithGio(e,t){let n=new X.ZlibDecompressor({format:getGioFormat(t)}),r=X.MemoryInputStream.new_from_bytes(new W.Bytes(e)),i=new X.ConverterInputStream({base_stream:r,converter:n}),o=[];for(;;){let e=i.read_bytes(Ri,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}return i.close(null),concat$2(o)}function findGzipMemberEnd(e){let t=new X.ZlibDecompressor({format:X.ZlibCompressorFormat.GZIP}),n=new Uint8Array(262144),r=0;for(;;){let i=e.subarray(r,r+Li);try{let[e,o,s]=t.convert(i,n,X.ConverterFlags.NONE);if(r+=o,e===X.ConverterResult.FINISHED||o===0&&s===0)return r}catch{return r}}}function gunzipWithGio(e){let t=[],n=0;for(;n<e.length&&!(e.length-n<2||e[n]!==31||e[n+1]!==139);){let r=e.subarray(n),i=findGzipMemberEnd(r);if(i<=0)break;t.push(decompressStreamWithGio(r.subarray(0,i),`gzip`)),n+=i}return t.length===0?decompressStreamWithGio(e,`gzip`):concat$2(t)}var Li,Ri,zi=__esmMin(()=>{Z(),G(),Li=256*1024,Ri=1024*1024,__name(concat$2,`concat`)}),Bi=__esmMin(()=>{P()}),Vi,Hi,Ui=__esmMin(()=>{Vi=Object.defineProperty,Hi=__name((e,t)=>{let n={};for(var r in e)Vi(n,r,{get:e[r],enumerable:!0});return t||Vi(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function _setPipeImpl(e){Wi=e}var Wi,Stream_,Gi=__esmMin(()=>{Kn(),Stream_=class extends K{constructor(e){super(e)}pipe(e,t){return Wi(this,e,t)}}});function finished$1(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 o=e,s=typeof e.write==`function`,c=typeof e.read==`function`,l=o.writableFinished===!0,u=o.readableEnded===!0;if(o.destroyed===!0){let e=o._err;oe(e?()=>done(e):s&&l||c&&u?()=>done():()=>done(Error(`premature close`)))}else(s&&!c&&l||!s&&c&&u||s&&c&&l&&u)&&oe(()=>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 Ki=__esmMin(()=>{Gi(),P(),__name(finished$1,`finished`)});function getDefaultHighWaterMark(e){return e?Ji:qi}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Ji=t:qi=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 qi,Ji,Yi=__esmMin(()=>{qi=16384,Ji=16});function createAbortError(){let e=Error(`The operation was aborted`);return e.name=`AbortError`,e.code=`ABORT_ERR`,e}async function streamAsyncDispose(e,t){let n;e.destroyed||(n=t?void 0:createAbortError(),e.destroy(n)),await new Promise((t,r)=>{finished$1(e,e=>{e&&e!==n?r(e):t()})})}var Xi,Zi=__esmMin(()=>{Ki(),Xi=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});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 Qi,$i,ea,ta=__esmMin(()=>{Gi(),Zi(),Yi(),P(),Qi=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;_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._destroy=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.listenerCount(`readable`)===0&&this.resume(),e===`readable`&&(this.readableFlowing=!1,this._buffer.length>0||this._readableState.ended?this._scheduleReadable():this._readableState.reading||nextTick(()=>{this.destroyed||this.read(0)})),this}removeListener(e,t){let n=super.removeListener(e,t);return e===`readable`&&nextTick(()=>this._updateReadableListening()),n}removeAllListeners(e){let t=e===void 0?super.removeAllListeners():super.removeAllListeners(e);return(e===`readable`||e===void 0)&&nextTick(()=>this._updateReadableListening()),t}_updateReadableListening(){this.listenerCount(`readable`)>0||(this.listenerCount(`data`)>0?this.resume():this.readableFlowing=null)}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){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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return 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,o=null;return e.on(`data`,e=>{if(i){let t=i;i=null,o=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,o=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,o){let t=o;i=null,o=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,o=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)}},Qi.prototype[Xi]=function(){return streamAsyncDispose(this,this.readableEnded)},$i=Object.getOwnPropertyDescriptor(Qi.prototype,`on`),ea=Object.getOwnPropertyDescriptor(Qi.prototype,`removeListener`),Object.defineProperty(Qi.prototype,"addListener",{...$i}),Object.defineProperty(Qi.prototype,"off",{...ea})});function writeAfterEndError(){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,e}var na=__esmMin(()=>{});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,ra=__esmMin(()=>{na(),Yi(),ta(),P(),Duplex_=class extends Qi{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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),o}_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.destroyed||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.destroyed||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,o=!1,ondrain=()=>{o=!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(),o||(o=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let s=!1,onend=()=>{s||(s=!0,i&&t.end())},onclose=()=>{if(!s&&(s=!0,i&&!(r instanceof Qi))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),o&&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 Qi&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var ia=__esmMin(()=>{Gi(),ta(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var aa,oa=__esmMin(()=>{na(),Gi(),Zi(),Yi(),P(),aa=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;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;_autoDestroy;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,this._autoDestroy=e?.autoDestroy!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroy=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){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`),this._autoDestroy?this.destroy():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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),o}_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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return this}},aa.prototype[Xi]=function(){return streamAsyncDispose(this,this.writableFinished)}}),sa,ca=__esmMin(()=>{ra(),P(),sa=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_,la=__esmMin(()=>{ca(),PassThrough_=class extends sa{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline$1(...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 o=r[0];for(let e=1;e<r.length;e++){let t=r[e];o.pipe(t),o.on(`error`,onError),o=t}let s=r[r.length-1];return s.on(`error`,onError),s.on(`finish`,()=>{n&&!i&&n(null)}),s}var ua=__esmMin(()=>{__name(pipeline$1,`pipeline`)});function pipeline(...e){return new Promise((t,n)=>{let cb=e=>{e?n(e):t()};pipeline$1(...e,cb)})}function finished(e,t){return new Promise((n,r)=>{t&&typeof t!=`function`?finished$1(e,t,e=>{e?r(e):n()}):finished$1(e,e=>{e?r(e):n()})})}var da,fa,pa=__esmMin(()=>{Ui(),Ki(),ua(),da=Hi({default:()=>fa,finished:()=>finished,pipeline:()=>pipeline}),fa={pipeline,finished}}),ma=__exportAll$5({Duplex:()=>va,PassThrough:()=>ba,Readable:()=>ga,Stream:()=>ha,Transform:()=>ya,Writable:()=>_a,addAbortSignal:()=>addAbortSignal,default:()=>xa,finished:()=>finished$1,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,"module.exports":()=>xa,pipeline:()=>pipeline$1,promises:()=>da,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),ha,ga,_a,va,ya,ba,xa,Sa=__esmMin(()=>{Bi(),Gi(),Ki(),Yi(),ta(),ra(),ia(),oa(),ca(),la(),ua(),pa(),ha=makeCallable(Stream_),ga=makeCallable(Qi),_a=makeCallable(aa),va=makeCallable(Duplex_),ya=makeCallable(sa),ba=makeCallable(PassThrough_),xa=Object.assign(ha,{Stream:ha,Readable:ga,Writable:_a,Duplex:va,Transform:ya,PassThrough:ba,pipeline:pipeline$1,finished:finished$1,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark,promises:da})});function toUint8Array$2(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function concat$1(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function createGzip(e){return new Gzip(e)}function createGunzip(e){return new Gunzip(e)}function createDeflate(e){return new Deflate(e)}function createInflate(e){return new Inflate(e)}function createDeflateRaw(e){return new DeflateRaw(e)}function createInflateRaw(e){return new InflateRaw(e)}function createUnzip(e){return new Unzip(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)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,Ca=__esmMin(()=>{zi(),Sa(),__name(toUint8Array$2,`toUint8Array`),__name(concat$1,`concat`),ZlibBase=class extends ya{_mode;_chunks=[];constructor(e,t){super(t),this._mode=e}_transform(e,t,n){this._chunks.push(toUint8Array$2(e)),n()}_flush(e){let t=concat$1(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(t))),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_run(e){let t=this._mode;switch(t.kind){case`compress`:return compressWithGio(e,t.format);case`decompress`:return decompressStreamWithGio(e,t.format);case`gunzip`:return gunzipWithGio(e);case`unzip`:return e.length>=2&&e[0]===31&&e[1]===139?gunzipWithGio(e):decompressStreamWithGio(e,`deflate`)}}},Gzip=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`gzip`},e)}},Gunzip=class extends ZlibBase{constructor(e){super({kind:`gunzip`},e)}},Deflate=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate`},e)}},Inflate=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate`},e)}},DeflateRaw=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate-raw`},e)}},InflateRaw=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate-raw`},e)}},Unzip=class extends ZlibBase{constructor(e){super({kind:`unzip`},e)}},BrotliCompress=class extends ya{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends ya{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends ya{constructor(){super();let e=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}},ZstdDecompress=class extends ya{constructor(){super();let e=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}}}),wa=__exportAll$5({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>Ea,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>Da,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function decompressWithGio(e,t){return t===`gzip`?gunzipWithGio(e):decompressStreamWithGio(e,t)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let o=r.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of r)s.set(e,c),c+=e.length;return s}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}function requestedLevel(e){let t=e?.level;if(!(t===void 0||t===-1))return assertLevel(t),t}async function compress(e,t,n){return n===void 0&&hasWebCompression()?compressWithWeb(e,t):compressWithGio(e,t,n)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return 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,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`gzip`,requestedLevel(i)).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,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate`,requestedLevel(i)).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,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate-raw`,requestedLevel(i)).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`,t?.level??-1)}function gunzipSync(e,t){return decompressWithGio(toUint8Array$1(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate`,t?.level??-1)}function inflateSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate-raw`,t?.level??-1)}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`),Ta)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),Ta)}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`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}var hasWebCompression,Ta,Ea,Da,Oa=__esmMin(()=>{zi(),Ca(),hasWebCompression=()=>globalThis.CompressionStream!==void 0,__name(toUint8Array$1,`toUint8Array`),Ta=new Uint8Array,Ea={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},Da={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:Ea}});const ka=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!ka.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const Aa=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let ja=!1,Ma,Na,Pa,Fa,Ia,La;async function loadZlib(){if(ja)return;let e=await Promise.resolve().then(()=>(Oa(),wa));Ma=e.gzipSync,Na=e.gunzipSync,Pa=e.deflateSync,Fa=e.inflateSync,Ia=e.deflateRawSync,La=e.inflateRawSync,ja=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Ma(e);case`deflate`:return e=>Pa(e);case`deflate-raw`:return e=>Ia(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Na(e);case`deflate`:return e=>Fa(e);case`deflate-raw`:return e=>La(e)}}function concatChunks(e){if(e.length===1)return e[0];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 n}let Ra,za;if(Aa)Ra=globalThis.CompressionStream,za=globalThis.DecompressionStream;else{let e=loadZlib();Ra=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getCompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}},za=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getDecompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}}}const Ba=globalThis;globalThis.CompressionStream===void 0&&(Ba.CompressionStream=Ra),globalThis.DecompressionStream===void 0&&(Ba.DecompressionStream=za);const Va=globalThis;globalThis.DOMException===void 0&&(Va.DOMException=V);const Ha=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(Ha.ByteLengthQueuingStrategy=ji),globalThis.CountQueuingStrategy===void 0&&(Ha.CountQueuingStrategy=Mi);const Ua=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`)||(Ua.ReadableStream=Oi),Ua.ReadableStreamBYOBReader===void 0&&(Ua.ReadableStreamBYOBReader=ReadableStreamBYOBReader),Ua.ReadableStreamBYOBRequest===void 0&&(Ua.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),Ua.ReadableByteStreamController===void 0&&(Ua.ReadableByteStreamController=ReadableByteStreamController),Ua.ReadableStreamDefaultController===void 0&&(Ua.ReadableStreamDefaultController=ReadableStreamDefaultController),Ua.ReadableStreamDefaultReader===void 0&&(Ua.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const Wa=globalThis;globalThis.TextEncoderStream===void 0&&(Wa.TextEncoderStream=Ni),globalThis.TextDecoderStream===void 0&&(Wa.TextDecoderStream=Pi);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=Ai}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=ki}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`}};const Ga=Uint8Array.of(166,166,166,166,166,166,166,166);function xorCounter(e,t){for(let n=0;n<8&&t>0;n++)e[7-n]^=t&255,t=Math.floor(t/256)}function aesKeyWrap(e,t){if(e.length<16||e.length%8!=0)throw new DOMException(`AES-KW: key data must be a multiple of 8 bytes and at least 16 bytes`,`OperationError`);let n=e.length/8,r=Ga.slice(),i=[];for(let t=0;t<n;t++)i.push(e.slice(t*8,t*8+8));let o=new Uint8Array(16);for(let e=0;e<=5;e++)for(let s=1;s<=n;s++){o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),xorCounter(r,n*e+s),i[s-1]=c.slice(8,16)}let s=new Uint8Array((n+1)*8);s.set(r,0);for(let e=0;e<n;e++)s.set(i[e],(e+1)*8);return s}function aesKeyUnwrap(e,t){if(e.length<24||e.length%8!=0)throw new DOMException(`AES-KW: wrapped key must be a multiple of 8 bytes and at least 24 bytes`,`OperationError`);let n=e.length/8-1,r=e.slice(0,8),i=[];for(let t=0;t<n;t++)i.push(e.slice((t+1)*8,(t+2)*8));let o=new Uint8Array(16);for(let e=5;e>=0;e--)for(let s=n;s>=1;s--){xorCounter(r,n*e+s),o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),i[s-1]=c.slice(8,16)}let s=!0;for(let e=0;e<8;e++)r[e]!==Ga[e]&&(s=!1);if(!s)throw new DOMException(`AES-KW: integrity check failed`,`OperationError`);let c=new Uint8Array(n*8);for(let e=0;e<n;e++)c.set(i[e],e*8);return c}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 Ka={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=Ka[e.toUpperCase()]||Ka[e];if(!t)throw new V(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const qa={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=qa[e];if(!t)throw new V(`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 V(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new V(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new V(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const Ja=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ya=new Uint8Array(128);for(let e=0;e<64;e++)Ya[Ja.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],o=r+1<n?e[r+1]:0,s=r+2<n?e[r+2]:0;t+=Ja[i>>2&63],t+=Ja[(i<<4|o>>4)&63],t+=r+1<n?Ja[(o<<2|s>>6)&63]:`=`,t+=r+2<n?Ja[s&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|Ya[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 checkAlgorithmMatch(e,t){if(e.algorithm.name.toUpperCase()!==t.toUpperCase())throw new V(`Key algorithm mismatch`,`InvalidAccessError`)}const Xa={Ed25519:{public:[`verify`],private:[`sign`]},X25519:{public:[],private:[`deriveKey`,`deriveBits`]}},Za={Ed25519:[48,42,48,5,6,3,43,101,112,3,33,0],X25519:[48,42,48,5,6,3,43,101,110,3,33,0]};function cfrgName(e){let t=e.toUpperCase();if(t===`ED25519`)return`Ed25519`;if(t===`X25519`)return`X25519`}function assertUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Unsupported key usage: ${n}`,`SyntaxError`)}function toArrayBuffer(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function keyObjectOf(e){return e._handle.keyObject}function cfrgGenerateKey(e,t,n,r){assertUsages(r,[...Xa[t].public,...Xa[t].private]);let i=r.filter(e=>Xa[t].private.includes(e));if(i.length===0)throw new V(`Usages cannot be empty when creating a key.`,`SyntaxError`);let o=r.filter(e=>Xa[t].public.includes(e)),{publicKey:s,privateKey:c}=e.generateKeyPairSync(t.toLowerCase());return{publicKey:new CryptoKey(`public`,!0,{name:t},o,{keyObject:s}),privateKey:new CryptoKey(`private`,n,{name:t},i,{keyObject:c})}}function validateJwk(e,t,n,r){if(typeof e!=`object`||!e)throw new V(`Invalid keyData`,`DataError`);if(e.kty!==`OKP`)throw new V(`Invalid JWK "kty" Parameter`,`DataError`);if(e.crv!==t)throw new V(`JWK "crv" Parameter and algorithm name mismatch`,`DataError`);if(t===`Ed25519`&&e.alg!==void 0&&e.alg!==`Ed25519`&&e.alg!==`EdDSA`)throw new V(`JWK "alg" does not match the requested algorithm`,`DataError`);let i=t===`X25519`?`enc`:`sig`;if(r.length>0&&e.use!==void 0&&e.use!==i)throw new V(`Invalid JWK "use" Parameter`,`DataError`);if(e.key_ops!==void 0){if(!Array.isArray(e.key_ops))throw new V(`Invalid JWK "key_ops" Parameter`,`DataError`);for(let t of r)if(!e.key_ops.includes(t))throw new V(`Key operations and usage mismatch`,`DataError`)}if(e.ext===!1&&n)throw new V(`JWK "ext" Parameter and extractable mismatch`,`DataError`);if(typeof e.x!=`string`||e.d!==void 0&&typeof e.d!=`string`)throw new V(`Invalid keyData`,`DataError`)}function cfrgImportKey(e,t,n,r,i,o){let s,c,importOrDataError=e=>{try{return e()}catch(e){throw new V(`Invalid keyData: ${e.message}`,`DataError`)}};switch(t){case`raw`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);if(t.length!==32)throw new V(`Invalid keyData`,`DataError`);let i=new Uint8Array(44);i.set(Za[r],0),i.set(t,12),s=importOrDataError(()=>e.createPublicKey({key:i,format:`der`,type:`spki`})),c=`public`;break}case`spki`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);s=importOrDataError(()=>e.createPublicKey({key:t,format:`der`,type:`spki`})),c=`public`;break}case`pkcs8`:{assertUsages(o,Xa[r].private);let t=toUint8Array(n);s=importOrDataError(()=>e.createPrivateKey({key:t,format:`der`,type:`pkcs8`})),c=`private`;break}case`jwk`:{let t=n;if(validateJwk(t,r,i,o),c=t.d===void 0?`public`:`private`,assertUsages(o,Xa[r][c]),c===`private`){if(s=importOrDataError(()=>e.createPrivateKey({key:t,format:`jwk`})),e.createPublicKey(s).export({format:`jwk`}).x!==t.x)throw new V(`Invalid JWK: "x" does not match "d"`,`DataError`)}else{if(base64urlDecode(t.x).length!==32)throw new V(`Invalid keyData`,`DataError`);s=importOrDataError(()=>e.createPublicKey({key:t,format:`jwk`}))}break}default:throw new V(`Unsupported format: ${t}`,`NotSupportedError`)}if(s.asymmetricKeyType!==r.toLowerCase())throw new V(`Invalid key type`,`DataError`);if(c===`private`&&o.length===0)throw new V(`Usages cannot be empty when importing a private key.`,`SyntaxError`);return new CryptoKey(c,i,{name:r},o,{keyObject:s})}function wrongKindForFormat(e,t){return new V(`Unable to export ${e.algorithm.name} ${e.type} key using ${t} format`,`InvalidAccessError`)}function cfrgExportKey(e,t){let n=keyObjectOf(t);switch(e){case`raw`:{if(t.type!==`public`)throw new V(`Unable to export ${t.algorithm.name} ${t.type} key using ${e} format`,`NotSupportedError`);let r=n.export({format:`jwk`}).x;return toArrayBuffer(base64urlDecode(r))}case`spki`:if(t.type!==`public`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`spki`}));case`pkcs8`:if(t.type!==`private`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`pkcs8`}));case`jwk`:{let e=n.export({format:`jwk`}),r={kty:`OKP`,crv:t.algorithm.name,x:e.x};return t.type===`private`&&(r.d=e.d),t.algorithm.name===`Ed25519`&&(r.alg=`Ed25519`),r.key_ops=[...t.usages],r.ext=t.extractable,r}default:throw new V(`Unsupported export format: ${e}`,`NotSupportedError`)}}function ed25519Sign$1(e,t,n){if(t.type!==`private`)throw new V(`Key must be a private key`,`InvalidAccessError`);return toArrayBuffer(e.sign(null,n,keyObjectOf(t)))}__name(ed25519Sign$1,`ed25519Sign`);function ed25519Verify$1(e,t,n,r){if(t.type!==`public`)throw new V(`Key must be a public key`,`InvalidAccessError`);return e.verify(null,r,keyObjectOf(t),n)}__name(ed25519Verify$1,`ed25519Verify`);function x25519DeriveBits(e,t,n,r){if(t.type!==`private`)throw new V(`baseKey must be a private key`,`InvalidAccessError`);if(!(n instanceof CryptoKey)||n.type!==`public`)throw new V(`algorithm.public must be a public key`,`InvalidAccessError`);if(n.algorithm.name!==t.algorithm.name)throw new V(`The public and private keys must be of the same type`,`InvalidAccessError`);let i;try{i=new Uint8Array(e.diffieHellman({privateKey:keyObjectOf(t),publicKey:keyObjectOf(n)}))}catch(e){throw new V(`Deriving bits failed: ${e.message}`,`OperationError`)}if(r==null)return toArrayBuffer(i);if(r>i.length*8)throw new V(`derived bit length is too small`,`OperationError`);let o=i.slice(0,Math.ceil(r/8));return r%8!=0&&(o[o.length-1]&=255<<8-r%8),toArrayBuffer(o)}var Qa,$a=__esmMin(()=>{Qa={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 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 eo=__esmMin(()=>{});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([to[n[1]]^ro[e/t-1],to[n[2]],to[n[3]],to[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([to[n[0]],to[n[1]],to[n[2]],to[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let o=[];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];o.push(t)}return o}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]=to[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],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,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<4;e++){let t=e*4,r=n[t],i=n[t+1],o=n[t+2],s=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^o^s,n[t+1]=r^gmul(2,i)^gmul(3,o)^s,n[t+2]=r^i^gmul(2,o)^gmul(3,s),n[t+3]=gmul(3,r)^i^o^gmul(2,s)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=to[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let o=n[2],s=n[6];n[2]=n[10],n[6]=n[14],n[10]=o,n[14]=s;let c=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=c;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],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,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]=no[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],o=n[t+2],s=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,o)^gmul(9,s),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,o)^gmul(13,s),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,o)^gmul(11,s),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,o)^gmul(14,s)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let o=n[10],s=n[14];n[10]=n[2],n[14]=n[6],n[2]=o,n[6]=s;let c=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=c;for(let e=0;e<16;e++)n[e]=no[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,o=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<o&&(r[e]^=t[n])}let s=gfMul(r,e);r.set(s)}let o=Math.ceil(n.length/16)||0;for(let t=0;t<o;t++){let i=t*16,o=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<o&&(r[e]^=n[t])}let s=gfMul(r,e);r.set(s)}let s=new Uint8Array(16),c=t.length*8,l=n.length*8,u=Math.floor(c/4294967296),d=c>>>0;s[0]=u>>>24&255,s[1]=u>>>16&255,s[2]=u>>>8&255,s[3]=u&255,s[4]=d>>>24&255,s[5]=d>>>16&255,s[6]=d>>>8&255,s[7]=d&255;let p=Math.floor(l/4294967296),m=l>>>0;s[8]=p>>>24&255,s[9]=p>>>16&255,s[10]=p>>>8&255,s[11]=p&255,s[12]=m>>>24&255,s[13]=m>>>16&255,s[14]=m>>>8&255,s[15]=m&255;for(let e=0;e<16;e++)r[e]^=s[e];let h=gfMul(r,e);return r.set(h),r}var to,no,ro,io=__esmMin(()=>{to=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]),no=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]),ro=[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`?H.from(e,t||`utf8`):H.from(e)}function encodeOutput(e,t){return t?H.from(e).toString(t):H.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 ao=__esmMin(()=>{U(),__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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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,oo=__esmMin(()=>{io(),ao(),U(),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 H.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 o=Math.floor(i.length/16)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._encryptBlock(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 encodeOutput(c,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];return this._gcmAuthTag=H.from(s),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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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=H.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 H.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 o=Math.floor(i.length/16);if(o===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let s=(this._autoPadding?o-1:o)*16,c=[];for(let e=0;e<s;e+=16){let t=i.slice(e,e+16);c.push(this._decryptBlock(t))}this._buffer=i.slice(s);let l=new Uint8Array(c.length*16);for(let e=0;e<c.length;e++)l.set(c[e],e*16);return this._encodeWithUtf8Handling(l,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];let c=this._gcmExpectedTag,l=Math.min(c.length,16),u=0;for(let e=0;e<l;e++)u|=s[e]^c[e];if(u!==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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];gcmIncrementCounter(this._counter)}return t}}});function pemToDer$1(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],o=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(o===-1)throw Error(`Invalid PEM: no END line found`);let s=t.slice(n+1,o).join(``),c=H.from(s,`base64`);return{type:i,der:new Uint8Array(c.buffer,c.byteOffset,c.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 o=e.slice(t,t+r),s=t+r,c={tag:n,data:o};return n===48&&(c.children=parseSequenceChildren(o)),{value:c,next:s}}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 okpCurveForOid(e){if(oidsEqual(e,lo))return`ed25519`;if(oidsEqual(e,co))return`x25519`}function oidForOkpCurve(e){return e===`ed25519`?lo:co}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 algorithmOid(e){let t=e?.children?.[0];if(!t||t.tag!==6)throw Error(`Invalid AlgorithmIdentifier`);if(okpCurveForOid(t.data)&&(e?.children?.length??0)!==1)throw Error(`Invalid AlgorithmIdentifier: parameters must be absent (RFC 8410)`);return t.data}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=algorithmOid(t[0]),r=t[1];if(r.tag!==3||r.data[0]!==0)throw Error(`Expected BIT STRING for public key data`);let i=r.data.slice(1),o=okpCurveForOid(n);if(o){if(i.length!==32)throw Error(`Invalid ${o} public key length: ${i.length}`);return{type:`okp-public`,curve:o,pub:i}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(parseDer(i))}}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=algorithmOid(t[1]),r=t[2];if(r.tag!==4)throw Error(`Expected OCTET STRING for private key data`);let i=okpCurveForOid(n);if(i){let e=parseDer(r.data);if(e.tag!==4||e.data.length!==32)throw Error(`Invalid ${i} private key`);return{type:`okp-private`,curve:i,priv:e.data}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(parseDer(r.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(so),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$2(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(so),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function encodeOkpSubjectPublicKeyInfo(e,t){return encodeSequence([encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeBitString(t)])}function encodeOkpPrivateKeyInfo(e,t){return encodeSequence([bigintToAsn1Integer(0n),encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeOctetString(encodeOctetString(t))])}function derToPem(e,t){let n=H.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(`
11
+ `,`\r`,` `,`#`,`/`,`:`,`<`,`>`,`?`,`@`,`[`,`\\`,`]`,`^`,`|`]),J=class URL{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;constructor(e,t){let n=e instanceof URL?e.href:String(e),r;try{if(t!==void 0){let e=t instanceof URL?t.href:String(t);r=W.Uri.parse(e,Nr).parse_relative(n,Nr)}else r=W.Uri.parse(n,Nr)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!r)throw TypeError(`Invalid URL: ${n}`);this.#e=r.get_scheme();let i=isSpecialScheme(this.#e);this.#t=r.get_user()??``,this.#n=r.get_password()??``;let o=r.get_host(),s=o===null?null:bracketIPv6Host(o.toLowerCase());this.#r=s===null?i?``:null:this.#e===`file`&&s===`localhost`?``:s;let c=r.get_port();this.#i=c===-1||c===defaultPort(this.#e)?null:c,this.#a=r.get_path()??``,i&&this.#a===``&&(this.#a=`/`),this.#o=this.#r===null&&!this.#a.startsWith(`/`),this.#r===null&&!this.#o&&this.#a.startsWith(`/.//`)&&(this.#a=this.#a.slice(2)),this.#s=r.get_fragment()??null,this.#l=r.get_query()??null,this.#c=new Fr,this.#c._entries=parseFormUrlencoded(this.#l??``),Pr.set(this.#c,()=>{let e=this.#c.toString();this.#l=e===``?null:e})}get protocol(){return this.#e+`:`}set protocol(e){let t=String(e).replace(Rr,``)+`:`;if(!/^[A-Za-z]/.test(t))return;let n=``;for(let e of t){if(e===`:`)break;if(!isSchemeChar(e))return;n+=e.toLowerCase()}isSpecialScheme(this.#e)===isSpecialScheme(n)&&(n===`file`&&(this.#t!==``||this.#n!==``||this.#i!==null)||this.#e===`file`&&(this.#r===null||this.#r===``)||(this.#e=n,this.#i!==null&&this.#i===defaultPort(n)&&(this.#i=null)))}get hostname(){return this.#r??``}set hostname(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!0);t!==void 0&&(this.#r=t.host)}get port(){return this.#i===null?``:String(this.#i)}set port(e){if(this.#u())return;let t=String(e);if(t===``){this.#i=null;return}let n=digitPrefix(t.replace(Rr,``));if(n===``)return;let r=Number(n);r>65535||(this.#i=r===defaultPort(this.#e)?null:r)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}set host(e){if(this.#o)return;let t=parseHostSetterValue(String(e),this.#e,this.#t!==``||this.#n!==``,this.#i!==null,!1);t!==void 0&&(this.#r=t.host,t.port!==void 0&&(this.#i=t.port))}get pathname(){return this.#a}set pathname(e){this.#o||(this.#a=parsePathSetterValue(String(e),isSpecialScheme(this.#e),this.#r===null))}get search(){return this.#l?`?`+this.#l:``}set search(e){let t=String(e);if(t===``){this.#l=null,this.#c._entries=[];return}let n=(t.startsWith(`?`)?t.slice(1):t).replace(Rr,``);this.#l=encodeQuery(n,isSpecialScheme(this.#e)),this.#c._entries=parseFormUrlencoded(n)}get hash(){return this.#s?`#`+this.#s:``}set hash(e){let t=String(e);if(t===``){this.#s=null;return}let n=(t.startsWith(`#`)?t.slice(1):t).replace(Rr,``);this.#s=percentEncode(n,'"<>`')}get origin(){return isSpecialScheme(this.#e)&&this.#e!==`file`?`${this.protocol}//${this.host}`:`null`}get username(){return this.#t}set username(e){this.#u()||(this.#t=percentEncode(String(e),Lr))}get password(){return this.#n}set password(e){this.#u()||(this.#n=percentEncode(String(e),Lr))}#u(){return this.#r===null||this.#r===``||this.#e===`file`}get href(){let e=this.#e+`:`;return this.#r===null?!this.#o&&this.#a.startsWith(`//`)&&(e+=`/.`):(e+=`//`,(this.#t!==``||this.#n!==``)&&(e+=this.#t,this.#n!==``&&(e+=`:`+this.#n),e+=`@`),e+=this.#r,this.#i!==null&&(e+=`:`+this.#i)),e+=this.#a,e+=this.#l===null?``:`?${this.#l}`,e+=this.#s===null?``:`#${this.#s}`,e}set href(e){let t=new URL(String(e));this.#e=t.#e,this.#t=t.#t,this.#n=t.#n,this.#r=t.#r,this.#i=t.#i,this.#a=t.#a,this.#o=t.#o,this.#l=t.#l,this.#s=t.#s,this.#c._entries=parseFormUrlencoded(this.#l??``)}get searchParams(){return this.#c}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);t&&(W.unlink(t),URL._objectURLPaths.delete(e))}},__name(parse$1,`parse`),__name(format$1,`format`),Br={URL:J,URLSearchParams:Fr,parse:parse$1,format:format$1,resolve,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});Vr(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:J,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:Fr,enumerable:!1,writable:!0,configurable:!0});let Hr;if(globalThis.performance)Hr=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();Hr={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,o=_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&&(o=e.startTime)}let s={name:e,entryType:`measure`,startTime:i,duration:o-i};return t.push(s),s},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 Ur=globalThis,Wr=Ur.PerformanceObserver||PerformanceObserverStub;Ur.PerformanceEntry,Ur.PerformanceObserverEntryList,Ur.PerformanceMark,Ur.PerformanceMeasure;const Gr=globalThis;globalThis.performance===void 0&&(Gr.performance=Hr),typeof Gr.PerformanceObserver!=`function`&&(Gr.PerformanceObserver=Wr);const Kr=Symbol(`abort`),qr=Symbol(`internal`);var Jr=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==qr)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 reason(){return this.#t}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.#t}[Kr](e){if(this.#e)return;this.#e=!0,this.#t=e??new V(`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(qr);return t[Kr](e),t}static timeout(e){let t=new AbortSignal(qr);return setTimeout(()=>{t[Kr](new V(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(qr);for(let n of e)if(n.aborted)return t[Kr](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[Kr](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},Yr=class AbortController{signal;constructor(){this.signal=new Jr(qr)}get[Symbol.toStringTag](){return`AbortController`}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Kr](e)}};const Xr=globalThis;globalThis.AbortController===void 0&&(Xr.AbortController=Yr),globalThis.AbortSignal===void 0&&(Xr.AbortSignal=Jr);const Y=Symbol(`kState`),Zr=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[Y]!==void 0&&t[Zr]===e}function dequeueValue(e){let t=e[Y].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[Y].queueTotalSize=Math.max(0,e[Y].queueTotalSize-r),n}function resetQueue(e){e[Y].queue=[],e[Y].queueTotalSize=0}function peekQueueValue(e){return e[Y].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[Y].queue.push({value:t,size:n}),e[Y].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 Qr={__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 $r=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}},ei=Symbol(`kAbort`),ti=Symbol(`kCloseSentinel`),ni=Symbol(`kError`),ri=Symbol(`kSkipThrow`);var WritableStream=class{[Zr]=`WritableStream`;[Y];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[Y]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!ii(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return ii(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return ii(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(!ii(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[Zr]=`WritableStreamDefaultWriter`;[Y];constructor(e){if(!ii(e))throw TypeError(`Expected a WritableStream`);this[Y]={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 ai(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!ai(this))throw TypeError(`Invalid this`);if(this[Y].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return ai(this)?this[Y].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return ai(this)?this[Y].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!ai(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[Y];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(!ai(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return ai(this)?this[Y].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{[Zr]=`WritableStreamDefaultController`;[Y];constructor(e){if(e!==ri)throw TypeError(`Illegal constructor`)}[ei](e){let t=this[Y].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[ni](){resetQueue(this)}get signal(){if(!oi(this))throw TypeError(`Invalid this`);return this[Y].abortController.signal}error(e){if(!oi(this))throw TypeError(`Invalid this`);this[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const ii=isBrandCheck(`WritableStream`),ai=isBrandCheck(`WritableStreamDefaultWriter`),oi=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[Y].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[Y].stream=t,t[Y].writer=e,t[Y].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[Y].backpressure?e[Y].ready=Promise.withResolvers():e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close=Promise.withResolvers();break;case`erroring`:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[Y].ready={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise),setPromiseHandled(e[Y].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[Y];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[Y].abortController.abort(t),e[Y].pendingAbortRequest.abort.promise!==void 0)return e[Y].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let o=Promise.withResolvers();return e[Y].pendingAbortRequest={abort:o,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),o.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[Y];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[Y].closeRequest=Promise.withResolvers();let{promise:o}=e[Y].closeRequest;return n!==void 0&&r&&t===`writable`&&n[Y].ready.resolve?.(),writableStreamDefaultControllerClose(i),o}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[Y];n!==void 0&&e[Y].backpressure!==t&&(t?n[Y].ready=Promise.withResolvers():n[Y].ready.resolve?.()),e[Y].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[Y];e[Y].state=`erroring`,e[Y].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[Y].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[Y].closeRequest.promise!==void 0&&(e[Y].closeRequest.reject?.(e[Y].storedError),e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[Y].close.promise),e[Y].close.reject?.(e[Y].storedError);let{writer:t}=e[Y];t!==void 0&&(setPromiseHandled(t[Y].close.promise),t[Y].close.reject?.(e[Y].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[Y].writeRequests.shift();e[Y].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[Y].inFlightCloseRequest=e[Y].closeRequest,e[Y].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[Y].inFlightWriteRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[Y].inFlightWriteRequest.reject?.(t),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[Y].inFlightWriteRequest.resolve?.(),e[Y].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[Y].inFlightCloseRequest.reject?.(t),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.reject?.(t),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[Y].inFlightCloseRequest.resolve?.(),e[Y].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[Y].state===`erroring`&&(e[Y].storedError=void 0,e[Y].pendingAbortRequest.abort.promise!==void 0&&(e[Y].pendingAbortRequest.abort.resolve?.(),e[Y].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[Y].state=`closed`,e[Y].writer!==void 0&&e[Y].writer[Y].close.resolve?.(),e[Y].close.resolve?.()}function writableStreamFinishErroring(e){e[Y].state=`errored`,e[Y].controller[ni]();let t=e[Y].storedError;for(let n of e[Y].writeRequests)n.reject?.(t);if(e[Y].writeRequests=[],e[Y].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[Y].pendingAbortRequest;if(e[Y].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[Y].controller[ei](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[Y].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[Y].closeRequest.promise!==void 0||e[Y].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[Y].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[Y],{controller:r}=n[Y],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[Y].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:o}=n[Y];if(o===`errored`)return Promise.reject(n[Y].storedError);if(writableStreamCloseQueuedOrInFlight(n)||o===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(o===`erroring`)return Promise.reject(n[Y].storedError);let s=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),s}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[Y],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[Y].writer=void 0,e[Y].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[Y];switch(t[Y].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[Y].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[Y].ready.reject?(e[Y].ready.reject(t),e[Y].ready.resolve=void 0,e[Y].ready.reject=void 0):e[Y].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[Y].close.reject?(e[Y].close.reject(t),e[Y].close.resolve=void 0,e[Y].close.reject=void 0):e[Y].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[Y],{state:n}=t[Y];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[Y].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[Y].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[Y].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[Y];!writableStreamCloseQueuedOrInFlight(r)&&r[Y].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[Y];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[Y];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[Y].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[Y];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[Y].highWaterMark-e[Y].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[Y];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[Y].stream[Y].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[Y].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,ti,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[Y].writeAlgorithm=void 0,e[Y].closeAlgorithm=void 0,e[Y].abortAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[Y];if(!n||r[Y].inFlightWriteRequest.promise!==void 0)return;if(r[Y].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===ti?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(ri),o=t?.start,s=t?.write,c=t?.close,l=t?.abort;setupWritableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`sink.write`,s,t):nonOpWrite,c?createPromiseCallback(`sink.close`,c,t):nonOpCancel,l?createPromiseCallback(`sink.abort`,l,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,o,s,c){t[Y]={abortAlgorithm:o,closeAlgorithm:i,highWaterMark:s,queue:[],queueTotalSize:0,abortController:new $r,sizeAlgorithm:c,started:!1,stream:e,writeAlgorithm:r},e[Y].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let l=n();new Promise(e=>e(l)).then(()=>{t[Y].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[Y].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,o=()=>1){let s=Object.create(WritableStream.prototype);return s[Zr]=`WritableStream`,s[Y]=createWritableStreamState(),setupWritableStreamDefaultController(s,new WritableStreamDefaultController(ri),e,t,n,r,i,o),s}P();const si=Symbol(`kCancel`),ci=Symbol(`kClose`),li=Symbol(`kChunk`),ui=Symbol(`kError`),di=Symbol(`kPull`),fi=Symbol(`kRelease`),pi=Symbol(`kSkipThrow`);let mi,hi;function lazyReadableReleasedError(){return mi||(mi=TypeError(`Reader released`),mi)}function lazyReadableReleasingError(){return hi||(hi=TypeError(`Releasing reader`),hi)}function createAbortError$1(){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}__name(createAbortError$1,`createAbortError`);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`)}[Zr]=`ReadableStream`;[Y];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[Y]=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(!gi(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return gi(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!gi(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(!gi(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!gi(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!ii(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,o=t?.preventCancel,s=t?.preventClose,c=t?.signal;if(c!==void 0&&!(c instanceof Object&&`aborted`in c))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,!!s,!!i,!!o,c)),n}pipeTo(e,t={}){try{if(!gi(this))throw TypeError(`Invalid this`);if(!ii(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,o=t?.signal;if(o!==void 0&&!(o instanceof Object&&`aborted`in o))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,o)}catch(e){return Promise.reject(e)}}tee(){if(!gi(this))throw TypeError(`Invalid this`);let e=this[Y].controller;return yi(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!gi(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[Y].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,{[li](e){r.current=void 0,t({value:e,done:!1})},[ci](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[ui](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[Y].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}},Qr)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](){this[Y].resolve?.({value:void 0,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamDefaultReader=class{[Zr]=`ReadableStreamDefaultReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!vi(this))return Promise.reject(TypeError(`Invalid this`));if(this[Y].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[Y].stream,t=e[Y].controller;if(e[Y].state===`readable`&&_i(t)&&t[Y].queue.length>0){e[Y].disturbed=!0;let n=dequeueValue(t);return t[Y].closeRequested&&!t[Y].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(!vi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return vi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return vi(this)?this[Y].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{[Zr]=`ReadableStreamDefaultController`;[Y];constructor(e){if(e!==pi)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)}[si](e){return readableStreamDefaultControllerCancelSteps(this,e)}[di](e){readableStreamDefaultControllerPullSteps(this,e)}[fi](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const gi=isBrandCheck(`ReadableStream`),_i=isBrandCheck(`ReadableStreamDefaultController`),vi=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[Y].reader!==void 0}function readableStreamCancel(e,t){switch(e[Y].disturbed=!0,e[Y].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[Y].storedError)}readableStreamClose(e);let n=e[Y].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[Y].readIntoRequests;n[Y].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][ci](void 0)}return e[Y].controller[si](t).then(()=>{})}function readableStreamClose(e){e[Y].state=`closed`,e[Y].closedPromise.resolve();let{reader:t}=e[Y];if(t!==void 0&&(t[Y].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[Y].readRequests.length;e++)t[Y].readRequests[e][ci]();t[Y].readRequests=[]}}function readableStreamError(e,t){e[Y].state=`errored`,e[Y].storedError=t,setPromiseHandled(e[Y].closedPromise.promise),e[Y].closedPromise.reject(t);let{reader:n}=e[Y];if(n!==void 0){if(setPromiseHandled(n[Y].close.promise),n[Y].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[Y].readRequests.length;e++)n[Y].readRequests[e][ui](t);n[Y].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[Y].readIntoRequests.length;e++)n[Y].readIntoRequests[e][ui](t);n[Y].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[Y].reader[Y].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readRequests.shift();n?i[ci]():i[li](t)}function readableStreamAddReadRequest(e,t){e[Y].reader[Y].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[Y];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[Y].stream=t,t[Y].reader=e,t[Y].state){case`readable`:e[Y].close=Promise.withResolvers();break;case`closed`:e[Y].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[Y].close={promise:Promise.reject(t[Y].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[Y],n=lazyReadableReleasedError();t[Y].state===`readable`?e[Y].close.reject?.(n):e[Y].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[Y].close.promise),t[Y].controller[fi](),t[Y].reader=void 0,e[Y].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[Y].readRequests.length;++n)e[Y].readRequests[n][ui](t);e[Y].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[Y];switch(n[Y].disturbed=!0,n[Y].state){case`closed`:t[ci]();break;case`errored`:t[ui](n[Y].storedError);break;case`readable`:n[Y].controller[di](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[Y].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[Y].closeRequested=!0,e[Y].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[Y];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[Y].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[Y];return!e[Y].closeRequested&&t[Y].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[Y];switch(t[Y].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[Y];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0,e[Y].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[Y];if(r.length){let i=dequeueValue(e);e[Y].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[li](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:s,stream:e},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(pi),o=t?.start,s=t?.pull,c=t?.cancel;setupReadableStreamDefaultController(e,i,o?o.bind(t,i):nonOpStart,s?createPromiseCallback(`source.pull`,s,t):nonOpPull,c?createPromiseCallback(`source.cancel`,c,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let o=Object.create(ReadableStream$1.prototype);return o[Zr]=`ReadableStream`,o[Y]=createReadableStreamState(),setupReadableStreamDefaultController(o,new ReadableStreamDefaultController(pi),e,t,n,r,i),o}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[Y].controller):readableStreamDefaultControllerEnqueue(t[Y].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,o){let s,c;try{s=new ReadableStreamDefaultReader(e),c=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[Y].disturbed=!0;let l=!1,{promise:u,resolve:d,reject:p}=Promise.withResolvers(),m={currentWrite:Promise.resolve()},h;function finalize(e,t){writableStreamDefaultWriterRelease(c),readableStreamReaderGenericRelease(s),o!==void 0&&h&&(o.removeEventListener(`abort`,h),h=void 0),e?p(t):d()}async function waitForCurrentWrite(){let e=m.currentWrite;await e,e!==m.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(l)return;if(l=!0,t[Y].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(!l){if(l=!0,t[Y].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=o.reason&&o.reason.name===`AbortError`?createAbortError$1():o.reason;let s=[];r||s.push(()=>t[Y].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||s.push(()=>e[Y].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(s.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[Y].state===`errored`?n(e[Y].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[Y].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[li](e){oe(()=>{m.currentWrite=writableStreamDefaultWriterWrite(c,e),setPromiseHandled(m.currentWrite),g.resolve(!1)})}[ci](){g.resolve(!0)}[ui](e){g.reject(e)}}let g={resolve:null,reject:null};async function step(){if(l||t[Y].backpressure&&(await c[Y].ready.promise,l))return!0;let n=e[Y].controller;if(e[Y].state===`readable`&&_i(n)&&n[Y].queue.length>0){for(;n[Y].queue.length>0;){if(l)return!0;let r=dequeueValue(n);if(n[Y].closeRequested&&!n[Y].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),m.currentWrite=writableStreamDefaultWriterWrite(c,r),setPromiseHandled(m.currentWrite),t[Y].backpressure||t[Y].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[Y].state===`closed`}let{promise:r,resolve:i,reject:o}=Promise.withResolvers();return g={resolve:i,reject:o},readableStreamDefaultReaderRead(s,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(o!==void 0){if(o.aborted)return abortAlgorithm(),u;h=abortAlgorithm,o.addEventListener(`abort`,h,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,s[Y].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,c[Y].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,s[Y].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(c));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[Y].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return u}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,o=!1,s,c,l,u,d=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[li](e){oe(()=>{r=!1;let n=e,s=e;if(!o&&t)try{s=structuredClone(s)}catch{}i||readableStreamDefaultControllerEnqueue(l[Y].controller,n),o||readableStreamDefaultControllerEnqueue(u[Y].controller,s)})},[ci](){oe(()=>{r=!1,i||readableStreamDefaultControllerClose(l[Y].controller),o||readableStreamDefaultControllerClose(u[Y].controller),(!i||!o)&&d.resolve(void 0)})},[ui](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,s=t,o){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}function cancel2Algorithm(t){if(o=!0,c=t,i){let t=[s,c];d.resolve(readableStreamCancel(e,t))}return d.promise}return l=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),u=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[Y].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(l[Y].controller,e),readableStreamDefaultControllerError(u[Y].controller,e),(!i||!o)&&d.resolve(void 0)}),[l,u]}var BYOBReadIntoRequest=class{[Y];constructor(){this[Y]=Promise.withResolvers()}[li](e){this[Y].resolve?.({value:e,done:!1})}[ci](e){this[Y].resolve?.({value:e,done:!0})}[ui](e){this[Y].reject?.(e)}get promise(){return this[Y].promise}},ReadableStreamBYOBReader=class{[Zr]=`ReadableStreamBYOBReader`;[Y];constructor(e){if(!gi(e))throw TypeError(`Expected a ReadableStream`);this[Y]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!bi(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 o=e[Symbol.toStringTag];if(o!==void 0&&o!==`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[Y].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let s=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,s),s.promise}releaseLock(){if(!bi(this))throw TypeError(`Invalid this`);this[Y].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return bi(this)?this[Y].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return bi(this)?this[Y].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{[Zr]=`ReadableStreamBYOBRequest`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get view(){if(!xi(this))throw TypeError(`Invalid this`);return this[Y].view}respond(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Y].controller,e)}respondWithNewView(e){if(!xi(this))throw TypeError(`Invalid this`);if(this[Y].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[Y].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[Zr]=`ReadableByteStreamController`;[Y];constructor(e){if(e!==pi)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!yi(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!yi(this))throw TypeError(`Invalid this`);if(this[Y].closeRequested)throw TypeError(`Close already requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!yi(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[Y].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Y].stream[Y].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!yi(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[si](e){return readableByteStreamControllerCancelSteps(this,e)}[di](e){readableByteStreamControllerPullSteps(this,e)}[fi](){if(this[Y].pendingPullIntos.length>0){let e=this[Y].pendingPullIntos[0];e.readerType=`none`,this[Y].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const yi=isBrandCheck(`ReadableByteStreamController`),bi=isBrandCheck(`ReadableStreamBYOBReader`),xi=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[Y];return t===void 0?!1:t[Y]!==void 0&&t[Zr]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[Y].reader[Y].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[Y].reader[Y].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[Y],i=r[Y].readIntoRequests.shift();n?i[ci](t):i[li](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!yi(t[Y].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[Y].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[Y];i[Y].disturbed=!0,i[Y].state===`errored`?r[ui](i[Y].storedError):readableByteStreamControllerPullInto(i[Y].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[Y].readIntoRequests.length;n++)e[Y].readIntoRequests[n][ui](t);e[Y].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[Y].pullAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[Y].byobRequest;t!=null&&(t[Y].controller=void 0,t[Y].view=null,e[Y].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[Y];n[Y].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[Y].stream[Y].state;return t===`errored`?null:t===`closed`?0:e[Y].highWaterMark-e[Y].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[Y];if(t[Y].state!==`readable`||e[Y].closeRequested||!e[Y].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[Y].pulling){e[Y].pullAgain=!0;return}e[Y].pulling=!0,e[Y].pullAlgorithm(e).then(()=>{e[Y].pulling=!1,e[Y].pullAgain&&(e[Y].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[Y].queueTotalSize===0&&e[Y].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[Y].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[Y].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[Y].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[Y].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[Y].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[Y].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,o=!1,s=r-r%t.elementSize;s>=t.minimumFill&&(i=s-t.bytesFilled,o=!0);let c=e[Y].queue;for(;i>0;){let n=c[0],r=Math.min(i,n.byteLength),o=t.byteOffset+t.bytesFilled,s=new Uint8Array(t.buffer,o,r),l=new Uint8Array(n.buffer,n.byteOffset,r);s.set(l),n.byteLength===r?c.shift():(n.byteOffset+=r,n.byteLength-=r),e[Y].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return o}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[Y].queue.shift();e[Y].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[li](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[Y].stream[Y].reader;for(;t[Y].readRequests.length!==0;){if(e[Y].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[Y].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[Y].pendingPullIntos.length!==0;){if(e[Y].queueTotalSize===0)return;let t=e[Y].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[Y].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[Y].byobRequest===null&&e[Y].pendingPullIntos.length!==0){let t=e[Y].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(pi);r[Y]={controller:e,view:n},e[Y].byobRequest=r}return e[Y].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[Y];if(e[Y].closeRequested||n[Y].state!==`readable`)return;let r=t.buffer,i=t.byteLength,o=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let s=transferArrayBuffer(r);if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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,s,o,i):(e[Y].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(s,o,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,o,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[Y];if(!(e[Y].closeRequested||t[Y].state!==`readable`)){if(e[Y].queueTotalSize>0){e[Y].closeRequested=!0;return}if(e[Y].pendingPullIntos.length!==0){let t=e[Y].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[Y].stream,o=t[Symbol.toStringTag],s,c;if(o===void 0||o===`DataView`)s=DataView,c=1;else{let e=typedArrayConstructorByTag(o);if(!e){r[ui](TypeError(`Unsupported typed array: ${o}`));return}s=e,c=elementSizeByTag(o)}let l=t.buffer,u=t.byteLength,d=t.byteOffset,p=n*c,m;try{m=transferArrayBuffer(l)}catch(e){r[ui](e);return}let h={buffer:m,bufferByteLength:m.byteLength,byteOffset:d,byteLength:u,bytesFilled:0,minimumFill:p,elementSize:c,viewConstructor:s,readerType:`byob`};if(e[Y].pendingPullIntos.length!==0){e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r);return}if(i[Y].state===`closed`){let e=new s(h.buffer,h.byteOffset,0);r[ci](e);return}if(e[Y].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,h)){let t=readableByteStreamControllerConvertPullIntoDescriptor(h);readableByteStreamControllerHandleQueueDrain(e),r[li](t);return}if(e[Y].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[ui](t);return}}e[Y].pendingPullIntos.push(h),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[Y].pendingPullIntos[0];if(e[Y].stream[Y].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[Y].pendingPullIntos[0],r=e[Y].stream[Y].state,i=t.byteLength,o=t.byteOffset,s=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!==o)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==s.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(s),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[Y].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[Y].stream[Y].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[Y].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[Y].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[Y].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[Y].stream;if(e[Y].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[Y].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[ui](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[Y].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,o,s){t[Y]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:o,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:s},e[Y].controller=t;let c=n();new Promise(e=>e(c)).then(()=>{t[Y].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(pi),i=t?.start,o=t?.pull,s=t?.cancel,c=t?.autoAllocateChunkSize;if(c!==void 0&&(c===0||!Number.isInteger(c)||c<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,c)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,o,s,c=Promise.withResolvers(),l,u,d,p;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||d.close(),i||p.close();return}let t=e.value,o=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||d.enqueue(o),i||p.enqueue(new Uint8Array(o))},()=>{}),Promise.resolve())}return l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,o=t,i){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),u=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,s=t,r){let t=readableStreamCancel(e,[o,s]);return c.resolve(),t}return c.promise}}),d=l[Y].controller,p=u[Y].controller,t.closed.catch(e=>{d.error(e),p.error(e),(!r||!i)&&c.resolve()}),[l,u]}const Si=Symbol(`kSkipThrow`);var TransformStream=class{[Zr]=`TransformStream`;[Y];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,o=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let s=extractHighWaterMark(n?.highWaterMark,0),c=extractSizeAlgorithm(n?.size),l=extractHighWaterMark(t?.highWaterMark,1),u=extractSizeAlgorithm(t?.size),d=Promise.withResolvers();initializeTransformStream(this,d,l,u,s,c),setupTransformStreamDefaultControllerFromTransformer(this,e),o===void 0?d.resolve():d.resolve(o.call(e,this[Y].controller))}get readable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].readable}get writable(){if(!Ci(this))throw TypeError(`Invalid this`);return this[Y].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[Zr]=`TransformStreamDefaultController`;[Y];constructor(e){if(e!==Si)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!wi(this))throw TypeError(`Invalid this`);let{stream:e}=this[Y],{readable:t}=e[Y],n=t[Y].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!wi(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const Ci=isBrandCheck(`TransformStream`),wi=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,o){let startAlgorithm=()=>t.promise,s=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[Y]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,o),writable:s,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[Y];readableStreamDefaultControllerError(n[Y].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[Y];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[Y].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[Y].backpressureChange.promise!==void 0&&e[Y].backpressureChange.resolve?.(),e[Y].backpressureChange=Promise.withResolvers(),e[Y].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[Y]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[Y].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Si),r=t?.transform,i=t?.flush,o=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,o?createPromiseCallback(`transformer.cancel`,o,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[Y].transformAlgorithm=void 0,e[Y].flushAlgorithm=void 0,e[Y].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[Y],{readable:r}=n[Y],i=r[Y].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[Y].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[Y].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[Y].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[Y].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[Y].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[Y],{readable:n}=t[Y];readableStreamDefaultControllerClose(n[Y].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[Y];return e[Y].backpressure?e[Y].backpressureChange.promise.then(()=>{let{writable:r}=e[Y];if(r[Y].state===`erroring`)throw r[Y].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(readableStreamDefaultControllerError(r[Y].controller,t),o())},e=>{readableStreamDefaultControllerError(r[Y].controller,e),s(e)}),n[Y].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:r,resolve:i,reject:o}=Promise.withResolvers();n[Y].finishPromise=r;let s=n[Y].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{t[Y].state===`errored`?o(t[Y].storedError):(readableStreamDefaultControllerClose(t[Y].controller),i())},e=>{readableStreamDefaultControllerError(t[Y].controller,e),o(e)}),n[Y].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[Y].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[Y];if(n[Y].finishPromise!==void 0)return n[Y].finishPromise;let{promise:i,resolve:o,reject:s}=Promise.withResolvers();n[Y].finishPromise=i;let c=n[Y].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),c.then(()=>{r[Y].state===`errored`?s(r[Y].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),o())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[Y].controller,t),transformStreamUnblockWrite(e),s(t)}),n[Y].finishPromise}const Ti=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),Ei=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 Ti}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 Ei}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 Di=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),Di)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 o=incompleteUtf8Tail$1(i),s;if(o>0?(s=i.slice(0,i.length-o),e=i.slice(i.length-o)):(s=i,e=new Uint8Array),s.length>0){let e=this.#e.decode(s);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 Oi=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,ki=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Ai=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,ji=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Mi=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Ni=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Pi=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Fi,Ii=__esmMin(()=>{Fi=r}),X,Z=__esmMin(()=>{Ii(),X=Fi});function getGioFormat(e){switch(e){case`gzip`:return X.ZlibCompressorFormat.GZIP;case`deflate`:return X.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return X.ZlibCompressorFormat.RAW}}function concat$2(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function assertLevel(e){if(!(e>=-1&&e<=9))throw RangeError(`The value of "level" is out of range. It must be >= -1 and <= 9. Received ${e}`)}function compressWithGio(e,t,n=-1){assertLevel(n);let r=new X.ZlibCompressor({format:getGioFormat(t),level:Math.trunc(n)}),i=new X.ConverterOutputStream({base_stream:X.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new W.Bytes(e),null),i.close(null);let o=i.get_base_stream().steal_as_bytes();return new Uint8Array(o.get_data()??[])}function decompressStreamWithGio(e,t){let n=new X.ZlibDecompressor({format:getGioFormat(t)}),r=X.MemoryInputStream.new_from_bytes(new W.Bytes(e)),i=new X.ConverterInputStream({base_stream:r,converter:n}),o=[];for(;;){let e=i.read_bytes(Ri,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}return i.close(null),concat$2(o)}function findGzipMemberEnd(e){let t=new X.ZlibDecompressor({format:X.ZlibCompressorFormat.GZIP}),n=new Uint8Array(262144),r=0;for(;;){let i=e.subarray(r,r+Li);try{let[e,o,s]=t.convert(i,n,X.ConverterFlags.NONE);if(r+=o,e===X.ConverterResult.FINISHED||o===0&&s===0)return r}catch{return r}}}function gunzipWithGio(e){let t=[],n=0;for(;n<e.length&&!(e.length-n<2||e[n]!==31||e[n+1]!==139);){let r=e.subarray(n),i=findGzipMemberEnd(r);if(i<=0)break;t.push(decompressStreamWithGio(r.subarray(0,i),`gzip`)),n+=i}return t.length===0?decompressStreamWithGio(e,`gzip`):concat$2(t)}var Li,Ri,zi=__esmMin(()=>{Z(),G(),Li=256*1024,Ri=1024*1024,__name(concat$2,`concat`)}),Bi=__esmMin(()=>{P()}),Vi,Hi,Ui=__esmMin(()=>{Vi=Object.defineProperty,Hi=__name((e,t)=>{let n={};for(var r in e)Vi(n,r,{get:e[r],enumerable:!0});return t||Vi(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function _setPipeImpl(e){Wi=e}var Wi,Stream_,Gi=__esmMin(()=>{Kn(),Stream_=class extends K{constructor(e){super(e)}pipe(e,t){return Wi(this,e,t)}}});function finished$1(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 o=e,s=typeof e.write==`function`,c=typeof e.read==`function`,l=o.writableFinished===!0,u=o.readableEnded===!0;if(o.destroyed===!0){let e=o._err;oe(e?()=>done(e):s&&l||c&&u?()=>done():()=>done(Error(`premature close`)))}else(s&&!c&&l||!s&&c&&u||s&&c&&l&&u)&&oe(()=>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 Ki=__esmMin(()=>{Gi(),P(),__name(finished$1,`finished`)});function getDefaultHighWaterMark(e){return e?Ji:qi}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Ji=t:qi=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 qi,Ji,Yi=__esmMin(()=>{qi=16384,Ji=16});function createAbortError(){let e=Error(`The operation was aborted`);return e.name=`AbortError`,e.code=`ABORT_ERR`,e}async function streamAsyncDispose(e,t){let n;e.destroyed||(n=t?void 0:createAbortError(),e.destroy(n)),await new Promise((t,r)=>{finished$1(e,e=>{e&&e!==n?r(e):t()})})}var Xi,Zi=__esmMin(()=>{Ki(),Xi=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});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 Qi,$i,ea,ta=__esmMin(()=>{Gi(),Zi(),Yi(),P(),Qi=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;_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._destroy=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.listenerCount(`readable`)===0&&this.resume(),e===`readable`&&(this.readableFlowing=!1,this._buffer.length>0||this._readableState.ended?this._scheduleReadable():this._readableState.reading||nextTick(()=>{this.destroyed||this.read(0)})),this}removeListener(e,t){let n=super.removeListener(e,t);return e===`readable`&&nextTick(()=>this._updateReadableListening()),n}removeAllListeners(e){let t=e===void 0?super.removeAllListeners():super.removeAllListeners(e);return(e===`readable`||e===void 0)&&nextTick(()=>this._updateReadableListening()),t}_updateReadableListening(){this.listenerCount(`readable`)>0||(this.listenerCount(`data`)>0?this.resume():this.readableFlowing=null)}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){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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return 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,o=null;return e.on(`data`,e=>{if(i){let t=i;i=null,o=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,o=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,o){let t=o;i=null,o=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,o=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)}},Qi.prototype[Xi]=function(){return streamAsyncDispose(this,this.readableEnded)},$i=Object.getOwnPropertyDescriptor(Qi.prototype,`on`),ea=Object.getOwnPropertyDescriptor(Qi.prototype,`removeListener`),Object.defineProperty(Qi.prototype,"addListener",{...$i}),Object.defineProperty(Qi.prototype,"off",{...ea})});function writeAfterEndError(){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,e}var na=__esmMin(()=>{});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,ra=__esmMin(()=>{na(),Yi(),ta(),P(),Duplex_=class extends Qi{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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),o}_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.destroyed||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.destroyed||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,o=!1,ondrain=()=>{o=!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(),o||(o=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let s=!1,onend=()=>{s||(s=!0,i&&t.end())},onclose=()=>{if(!s&&(s=!0,i&&!(r instanceof Qi))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),o&&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 Qi&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var ia=__esmMin(()=>{Gi(),ta(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var aa,oa=__esmMin(()=>{na(),Gi(),Zi(),Yi(),P(),aa=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;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;_autoDestroy;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,this._autoDestroy=e?.autoDestroy!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroy=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){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`),this._autoDestroy?this.destroy():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=writeAfterEndError();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 o=this.writableLength<this.writableHighWaterMark;return o||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),o}_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 t=!1,cb=e=>{t||(t=!0,e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`)))};try{this._destroy(e??null,cb)}catch(e){cb(e)}return this}},aa.prototype[Xi]=function(){return streamAsyncDispose(this,this.writableFinished)}}),sa,ca=__esmMin(()=>{ra(),P(),sa=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_,la=__esmMin(()=>{ca(),PassThrough_=class extends sa{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline$1(...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 o=r[0];for(let e=1;e<r.length;e++){let t=r[e];o.pipe(t),o.on(`error`,onError),o=t}let s=r[r.length-1];return s.on(`error`,onError),s.on(`finish`,()=>{n&&!i&&n(null)}),s}var ua=__esmMin(()=>{__name(pipeline$1,`pipeline`)});function pipeline(...e){return new Promise((t,n)=>{let cb=e=>{e?n(e):t()};pipeline$1(...e,cb)})}function finished(e,t){return new Promise((n,r)=>{t&&typeof t!=`function`?finished$1(e,t,e=>{e?r(e):n()}):finished$1(e,e=>{e?r(e):n()})})}var da,fa,pa=__esmMin(()=>{Ui(),Ki(),ua(),da=Hi({default:()=>fa,finished:()=>finished,pipeline:()=>pipeline}),fa={pipeline,finished}}),ma=__exportAll$5({Duplex:()=>va,PassThrough:()=>ba,Readable:()=>ga,Stream:()=>ha,Transform:()=>ya,Writable:()=>_a,addAbortSignal:()=>addAbortSignal,default:()=>xa,finished:()=>finished$1,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,"module.exports":()=>xa,pipeline:()=>pipeline$1,promises:()=>da,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),ha,ga,_a,va,ya,ba,xa,Sa=__esmMin(()=>{Bi(),Gi(),Ki(),Yi(),ta(),ra(),ia(),oa(),ca(),la(),ua(),pa(),ha=makeCallable(Stream_),ga=makeCallable(Qi),_a=makeCallable(aa),va=makeCallable(Duplex_),ya=makeCallable(sa),ba=makeCallable(PassThrough_),xa=Object.assign(ha,{Stream:ha,Readable:ga,Writable:_a,Duplex:va,Transform:ya,PassThrough:ba,pipeline:pipeline$1,finished:finished$1,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark,promises:da})});function toUint8Array$2(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function concat$1(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function createGzip(e){return new Gzip(e)}function createGunzip(e){return new Gunzip(e)}function createDeflate(e){return new Deflate(e)}function createInflate(e){return new Inflate(e)}function createDeflateRaw(e){return new DeflateRaw(e)}function createInflateRaw(e){return new InflateRaw(e)}function createUnzip(e){return new Unzip(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)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,Ca=__esmMin(()=>{zi(),Sa(),__name(toUint8Array$2,`toUint8Array`),__name(concat$1,`concat`),ZlibBase=class extends ya{_mode;_chunks=[];constructor(e,t){super(t),this._mode=e}_transform(e,t,n){this._chunks.push(toUint8Array$2(e)),n()}_flush(e){let t=concat$1(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(t))),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_run(e){let t=this._mode;switch(t.kind){case`compress`:return compressWithGio(e,t.format);case`decompress`:return decompressStreamWithGio(e,t.format);case`gunzip`:return gunzipWithGio(e);case`unzip`:return e.length>=2&&e[0]===31&&e[1]===139?gunzipWithGio(e):decompressStreamWithGio(e,`deflate`)}}},Gzip=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`gzip`},e)}},Gunzip=class extends ZlibBase{constructor(e){super({kind:`gunzip`},e)}},Deflate=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate`},e)}},Inflate=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate`},e)}},DeflateRaw=class extends ZlibBase{constructor(e){super({kind:`compress`,format:`deflate-raw`},e)}},InflateRaw=class extends ZlibBase{constructor(e){super({kind:`decompress`,format:`deflate-raw`},e)}},Unzip=class extends ZlibBase{constructor(e){super({kind:`unzip`},e)}},BrotliCompress=class extends ya{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends ya{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends ya{constructor(){super();let e=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}},ZstdDecompress=class extends ya{constructor(){super();let e=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw e.code=`ERR_UNSUPPORTED_OPERATION`,e}}}),wa=__exportAll$5({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>Ea,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>Da,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip,gunzipSync:()=>gunzipSync,gzip:()=>gzip,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function decompressWithGio(e,t){return t===`gzip`?gunzipWithGio(e):decompressStreamWithGio(e,t)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let o=r.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of r)s.set(e,c),c+=e.length;return s}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}function requestedLevel(e){let t=e?.level;if(!(t===void 0||t===-1))return assertLevel(t),t}async function compress(e,t,n){return n===void 0&&hasWebCompression()?compressWithWeb(e,t):compressWithGio(e,t,n)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return 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,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`gzip`,requestedLevel(i)).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,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate`,requestedLevel(i)).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,i=typeof t==`function`?void 0:t;compress(toUint8Array$1(e),`deflate-raw`,requestedLevel(i)).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`,t?.level??-1)}function gunzipSync(e,t){return decompressWithGio(toUint8Array$1(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate`,t?.level??-1)}function inflateSync(e,t){return decompressWithGio(toUint8Array$1(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array$1(e),`deflate-raw`,t?.level??-1)}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`),Ta)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),Ta)}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`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,Ta)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}var hasWebCompression,Ta,Ea,Da,Oa=__esmMin(()=>{zi(),Ca(),hasWebCompression=()=>globalThis.CompressionStream!==void 0,__name(toUint8Array$1,`toUint8Array`),Ta=new Uint8Array,Ea={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},Da={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:Ea}});const ka=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(e){if(!ka.has(e))throw TypeError(`Unsupported compression format: '${e}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return e}const Aa=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let ja=!1,Ma,Na,Pa,Fa,Ia,La;async function loadZlib(){if(ja)return;let e=await Promise.resolve().then(()=>(Oa(),wa));Ma=e.gzipSync,Na=e.gunzipSync,Pa=e.deflateSync,Fa=e.inflateSync,Ia=e.deflateRawSync,La=e.inflateRawSync,ja=!0}function getCompressFn(e){switch(e){case`gzip`:return e=>Ma(e);case`deflate`:return e=>Pa(e);case`deflate-raw`:return e=>Ia(e)}}function getDecompressFn(e){switch(e){case`gzip`:return e=>Na(e);case`deflate`:return e=>Fa(e);case`deflate-raw`:return e=>La(e)}}function concatChunks(e){if(e.length===1)return e[0];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 n}let Ra,za;if(Aa)Ra=globalThis.CompressionStream,za=globalThis.DecompressionStream;else{let e=loadZlib();Ra=class CompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getCompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}},za=class DecompressionStream{readable;writable;constructor(t){let n=validateFormat(t),r=[],i=new Ai({transform(e){r.push(e)},async flush(t){try{await e;let i=getDecompressFn(n)(concatChunks(r));i.length>0&&t.enqueue(i)}catch(e){t.error(e)}}});this.readable=i.readable,this.writable=i.writable}}}const Ba=globalThis;globalThis.CompressionStream===void 0&&(Ba.CompressionStream=Ra),globalThis.DecompressionStream===void 0&&(Ba.DecompressionStream=za);const Va=globalThis;globalThis.DOMException===void 0&&(Va.DOMException=V);const Ha=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(Ha.ByteLengthQueuingStrategy=ji),globalThis.CountQueuingStrategy===void 0&&(Ha.CountQueuingStrategy=Mi);const Ua=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`)||(Ua.ReadableStream=Oi),Ua.ReadableStreamBYOBReader===void 0&&(Ua.ReadableStreamBYOBReader=ReadableStreamBYOBReader),Ua.ReadableStreamBYOBRequest===void 0&&(Ua.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),Ua.ReadableByteStreamController===void 0&&(Ua.ReadableByteStreamController=ReadableByteStreamController),Ua.ReadableStreamDefaultController===void 0&&(Ua.ReadableStreamDefaultController=ReadableStreamDefaultController),Ua.ReadableStreamDefaultReader===void 0&&(Ua.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const Wa=globalThis;globalThis.TextEncoderStream===void 0&&(Wa.TextEncoderStream=Ni),globalThis.TextDecoderStream===void 0&&(Wa.TextDecoderStream=Pi);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=Ai}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=ki}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`}};const Ga=Uint8Array.of(166,166,166,166,166,166,166,166);function xorCounter(e,t){for(let n=0;n<8&&t>0;n++)e[7-n]^=t&255,t=Math.floor(t/256)}function aesKeyWrap(e,t){if(e.length<16||e.length%8!=0)throw new DOMException(`AES-KW: key data must be a multiple of 8 bytes and at least 16 bytes`,`OperationError`);let n=e.length/8,r=Ga.slice(),i=[];for(let t=0;t<n;t++)i.push(e.slice(t*8,t*8+8));let o=new Uint8Array(16);for(let e=0;e<=5;e++)for(let s=1;s<=n;s++){o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),xorCounter(r,n*e+s),i[s-1]=c.slice(8,16)}let s=new Uint8Array((n+1)*8);s.set(r,0);for(let e=0;e<n;e++)s.set(i[e],(e+1)*8);return s}function aesKeyUnwrap(e,t){if(e.length<24||e.length%8!=0)throw new DOMException(`AES-KW: wrapped key must be a multiple of 8 bytes and at least 24 bytes`,`OperationError`);let n=e.length/8-1,r=e.slice(0,8),i=[];for(let t=0;t<n;t++)i.push(e.slice((t+1)*8,(t+2)*8));let o=new Uint8Array(16);for(let e=5;e>=0;e--)for(let s=n;s>=1;s--){xorCounter(r,n*e+s),o.set(r,0),o.set(i[s-1],8);let c=t(o);r.set(c.subarray(0,8)),i[s-1]=c.slice(8,16)}let s=!0;for(let e=0;e<8;e++)r[e]!==Ga[e]&&(s=!1);if(!s)throw new DOMException(`AES-KW: integrity check failed`,`OperationError`);let c=new Uint8Array(n*8);for(let e=0;e<n;e++)c.set(i[e],e*8);return c}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 Ka={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=Ka[e.toUpperCase()]||Ka[e];if(!t)throw new V(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const qa={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=qa[e];if(!t)throw new V(`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 V(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new V(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new V(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const Ja=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ya=new Uint8Array(128);for(let e=0;e<64;e++)Ya[Ja.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],o=r+1<n?e[r+1]:0,s=r+2<n?e[r+2]:0;t+=Ja[i>>2&63],t+=Ja[(i<<4|o>>4)&63],t+=r+1<n?Ja[(o<<2|s>>6)&63]:`=`,t+=r+2<n?Ja[s&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|Ya[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 checkAlgorithmMatch(e,t){if(e.algorithm.name.toUpperCase()!==t.toUpperCase())throw new V(`Key algorithm mismatch`,`InvalidAccessError`)}const Xa={Ed25519:{public:[`verify`],private:[`sign`]},X25519:{public:[],private:[`deriveKey`,`deriveBits`]}},Za={Ed25519:[48,42,48,5,6,3,43,101,112,3,33,0],X25519:[48,42,48,5,6,3,43,101,110,3,33,0]};function cfrgName(e){let t=e.toUpperCase();if(t===`ED25519`)return`Ed25519`;if(t===`X25519`)return`X25519`}function assertUsages(e,t){for(let n of e)if(!t.includes(n))throw new V(`Unsupported key usage: ${n}`,`SyntaxError`)}function toArrayBuffer(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function keyObjectOf(e){return e._handle.keyObject}function cfrgGenerateKey(e,t,n,r){assertUsages(r,[...Xa[t].public,...Xa[t].private]);let i=r.filter(e=>Xa[t].private.includes(e));if(i.length===0)throw new V(`Usages cannot be empty when creating a key.`,`SyntaxError`);let o=r.filter(e=>Xa[t].public.includes(e)),{publicKey:s,privateKey:c}=e.generateKeyPairSync(t.toLowerCase());return{publicKey:new CryptoKey(`public`,!0,{name:t},o,{keyObject:s}),privateKey:new CryptoKey(`private`,n,{name:t},i,{keyObject:c})}}function validateJwk(e,t,n,r){if(typeof e!=`object`||!e)throw new V(`Invalid keyData`,`DataError`);if(e.kty!==`OKP`)throw new V(`Invalid JWK "kty" Parameter`,`DataError`);if(e.crv!==t)throw new V(`JWK "crv" Parameter and algorithm name mismatch`,`DataError`);if(t===`Ed25519`&&e.alg!==void 0&&e.alg!==`Ed25519`&&e.alg!==`EdDSA`)throw new V(`JWK "alg" does not match the requested algorithm`,`DataError`);let i=t===`X25519`?`enc`:`sig`;if(r.length>0&&e.use!==void 0&&e.use!==i)throw new V(`Invalid JWK "use" Parameter`,`DataError`);if(e.key_ops!==void 0){if(!Array.isArray(e.key_ops))throw new V(`Invalid JWK "key_ops" Parameter`,`DataError`);for(let t of r)if(!e.key_ops.includes(t))throw new V(`Key operations and usage mismatch`,`DataError`)}if(e.ext===!1&&n)throw new V(`JWK "ext" Parameter and extractable mismatch`,`DataError`);if(typeof e.x!=`string`||e.d!==void 0&&typeof e.d!=`string`)throw new V(`Invalid keyData`,`DataError`)}function cfrgImportKey(e,t,n,r,i,o){let s,c,importOrDataError=e=>{try{return e()}catch(e){throw new V(`Invalid keyData: ${e.message}`,`DataError`)}};switch(t){case`raw`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);if(t.length!==32)throw new V(`Invalid keyData`,`DataError`);let i=new Uint8Array(44);i.set(Za[r],0),i.set(t,12),s=importOrDataError(()=>e.createPublicKey({key:i,format:`der`,type:`spki`})),c=`public`;break}case`spki`:{assertUsages(o,Xa[r].public);let t=toUint8Array(n);s=importOrDataError(()=>e.createPublicKey({key:t,format:`der`,type:`spki`})),c=`public`;break}case`pkcs8`:{assertUsages(o,Xa[r].private);let t=toUint8Array(n);s=importOrDataError(()=>e.createPrivateKey({key:t,format:`der`,type:`pkcs8`})),c=`private`;break}case`jwk`:{let t=n;if(validateJwk(t,r,i,o),c=t.d===void 0?`public`:`private`,assertUsages(o,Xa[r][c]),c===`private`){if(s=importOrDataError(()=>e.createPrivateKey({key:t,format:`jwk`})),e.createPublicKey(s).export({format:`jwk`}).x!==t.x)throw new V(`Invalid JWK: "x" does not match "d"`,`DataError`)}else{if(base64urlDecode(t.x).length!==32)throw new V(`Invalid keyData`,`DataError`);s=importOrDataError(()=>e.createPublicKey({key:t,format:`jwk`}))}break}default:throw new V(`Unsupported format: ${t}`,`NotSupportedError`)}if(s.asymmetricKeyType!==r.toLowerCase())throw new V(`Invalid key type`,`DataError`);if(c===`private`&&o.length===0)throw new V(`Usages cannot be empty when importing a private key.`,`SyntaxError`);return new CryptoKey(c,i,{name:r},o,{keyObject:s})}function wrongKindForFormat(e,t){return new V(`Unable to export ${e.algorithm.name} ${e.type} key using ${t} format`,`InvalidAccessError`)}function cfrgExportKey(e,t){let n=keyObjectOf(t);switch(e){case`raw`:{if(t.type!==`public`)throw new V(`Unable to export ${t.algorithm.name} ${t.type} key using ${e} format`,`NotSupportedError`);let r=n.export({format:`jwk`}).x;return toArrayBuffer(base64urlDecode(r))}case`spki`:if(t.type!==`public`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`spki`}));case`pkcs8`:if(t.type!==`private`)throw wrongKindForFormat(t,e);return toArrayBuffer(n.export({format:`der`,type:`pkcs8`}));case`jwk`:{let e=n.export({format:`jwk`}),r={kty:`OKP`,crv:t.algorithm.name,x:e.x};return t.type===`private`&&(r.d=e.d),t.algorithm.name===`Ed25519`&&(r.alg=`Ed25519`),r.key_ops=[...t.usages],r.ext=t.extractable,r}default:throw new V(`Unsupported export format: ${e}`,`NotSupportedError`)}}function ed25519Sign$1(e,t,n){if(t.type!==`private`)throw new V(`Key must be a private key`,`InvalidAccessError`);return toArrayBuffer(e.sign(null,n,keyObjectOf(t)))}__name(ed25519Sign$1,`ed25519Sign`);function ed25519Verify$1(e,t,n,r){if(t.type!==`public`)throw new V(`Key must be a public key`,`InvalidAccessError`);return e.verify(null,r,keyObjectOf(t),n)}__name(ed25519Verify$1,`ed25519Verify`);function x25519DeriveBits(e,t,n,r){if(t.type!==`private`)throw new V(`baseKey must be a private key`,`InvalidAccessError`);if(!(n instanceof CryptoKey)||n.type!==`public`)throw new V(`algorithm.public must be a public key`,`InvalidAccessError`);if(n.algorithm.name!==t.algorithm.name)throw new V(`The public and private keys must be of the same type`,`InvalidAccessError`);let i;try{i=new Uint8Array(e.diffieHellman({privateKey:keyObjectOf(t),publicKey:keyObjectOf(n)}))}catch(e){throw new V(`Deriving bits failed: ${e.message}`,`OperationError`)}if(r==null)return toArrayBuffer(i);if(r>i.length*8)throw new V(`derived bit length is too small`,`OperationError`);let o=i.slice(0,Math.ceil(r/8));return r%8!=0&&(o[o.length-1]&=255<<8-r%8),toArrayBuffer(o)}var Qa,$a=__esmMin(()=>{Qa={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 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 eo=__esmMin(()=>{});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([to[n[1]]^ro[e/t-1],to[n[2]],to[n[3]],to[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([to[n[0]],to[n[1]],to[n[2]],to[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let o=[];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];o.push(t)}return o}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]=to[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],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,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<4;e++){let t=e*4,r=n[t],i=n[t+1],o=n[t+2],s=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^o^s,n[t+1]=r^gmul(2,i)^gmul(3,o)^s,n[t+2]=r^i^gmul(2,o)^gmul(3,s),n[t+3]=gmul(3,r)^i^o^gmul(2,s)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=to[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let o=n[2],s=n[6];n[2]=n[10],n[6]=n[14],n[10]=o,n[14]=s;let c=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=c;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],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,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]=no[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],o=n[t+2],s=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,o)^gmul(9,s),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,o)^gmul(13,s),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,o)^gmul(11,s),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,o)^gmul(14,s)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let o=n[10],s=n[14];n[10]=n[2],n[14]=n[6],n[2]=o,n[6]=s;let c=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=c;for(let e=0;e<16;e++)n[e]=no[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]=e[t]+1&255,e[t]===0);t--);}function gcmIncrementCounter(e){for(let t=15;t>=12&&(e[t]=e[t]+1&255,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,o=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<o&&(r[e]^=t[n])}let s=gfMul(r,e);r.set(s)}let o=Math.ceil(n.length/16)||0;for(let t=0;t<o;t++){let i=t*16,o=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<o&&(r[e]^=n[t])}let s=gfMul(r,e);r.set(s)}let s=new Uint8Array(16),c=t.length*8,l=n.length*8,u=Math.floor(c/4294967296),d=c>>>0;s[0]=u>>>24&255,s[1]=u>>>16&255,s[2]=u>>>8&255,s[3]=u&255,s[4]=d>>>24&255,s[5]=d>>>16&255,s[6]=d>>>8&255,s[7]=d&255;let p=Math.floor(l/4294967296),m=l>>>0;s[8]=p>>>24&255,s[9]=p>>>16&255,s[10]=p>>>8&255,s[11]=p&255,s[12]=m>>>24&255,s[13]=m>>>16&255,s[14]=m>>>8&255,s[15]=m&255;for(let e=0;e<16;e++)r[e]^=s[e];let h=gfMul(r,e);return r.set(h),r}var to,no,ro,io=__esmMin(()=>{to=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]),no=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]),ro=[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`?H.from(e,t||`utf8`):H.from(e)}function encodeOutput(e,t){return t?H.from(e).toString(t):H.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 ao=__esmMin(()=>{U(),__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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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`?H.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?H.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,oo=__esmMin(()=>{io(),ao(),U(),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 H.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 o=Math.floor(i.length/16)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._encryptBlock(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 encodeOutput(c,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];return this._gcmAuthTag=H.from(s),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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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=H.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 H.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 o=Math.floor(i.length/16);if(o===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let s=(this._autoPadding?o-1:o)*16,c=[];for(let e=0;e<s;e+=16){let t=i.slice(e,e+16);c.push(this._decryptBlock(t))}this._buffer=i.slice(s);let l=new Uint8Array(c.length*16);for(let e=0;e<c.length;e++)l.set(c[e],e*16);return this._encodeWithUtf8Handling(l,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),o=aesEncryptBlock(this._gcmJ0,this._roundKeys),s=new Uint8Array(16);for(let e=0;e<16;e++)s[e]=i[e]^o[e];let c=this._gcmExpectedTag,l=Math.min(c.length,16),u=0;for(let e=0;e<l;e++)u|=s[e]^c[e];if(u!==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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];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 o=0;o<i;o++)t[n+o]=e[n+o]^r[o];gcmIncrementCounter(this._counter)}return t}}});function pemToDer$1(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],o=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(o===-1)throw Error(`Invalid PEM: no END line found`);let s=t.slice(n+1,o).join(``),c=H.from(s,`base64`);return{type:i,der:new Uint8Array(c.buffer,c.byteOffset,c.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 o=e.slice(t,t+r),s=t+r,c={tag:n,data:o};return n===48&&(c.children=parseSequenceChildren(o)),{value:c,next:s}}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 okpCurveForOid(e){if(oidsEqual(e,lo))return`ed25519`;if(oidsEqual(e,co))return`x25519`}function oidForOkpCurve(e){return e===`ed25519`?lo:co}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 algorithmOid(e){let t=e?.children?.[0];if(!t||t.tag!==6)throw Error(`Invalid AlgorithmIdentifier`);if(okpCurveForOid(t.data)&&(e?.children?.length??0)!==1)throw Error(`Invalid AlgorithmIdentifier: parameters must be absent (RFC 8410)`);return t.data}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=algorithmOid(t[0]),r=t[1];if(r.tag!==3||r.data[0]!==0)throw Error(`Expected BIT STRING for public key data`);let i=r.data.slice(1),o=okpCurveForOid(n);if(o){if(i.length!==32)throw Error(`Invalid ${o} public key length: ${i.length}`);return{type:`okp-public`,curve:o,pub:i}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(parseDer(i))}}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=algorithmOid(t[1]),r=t[2];if(r.tag!==4)throw Error(`Expected OCTET STRING for private key data`);let i=okpCurveForOid(n);if(i){let e=parseDer(r.data);if(e.tag!==4||e.data.length!==32)throw Error(`Invalid ${i} private key`);return{type:`okp-private`,curve:i,priv:e.data}}if(!oidsEqual(n,so))throw Error(`Unsupported key algorithm`);return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(parseDer(r.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(so),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$2(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(so),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function encodeOkpSubjectPublicKeyInfo(e,t){return encodeSequence([encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeBitString(t)])}function encodeOkpPrivateKeyInfo(e,t){return encodeSequence([bigintToAsn1Integer(0n),encodeSequence([encodeOid(oidForOkpCurve(e))]),encodeOctetString(encodeOctetString(t))])}function derToPem(e,t){let n=H.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(`
12
12
  `)}function modInverse$2(e,t){let[n,r]=[e%t,t],[i,o]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,o]=[o,i-e*o]}return(i%t+t)%t}function parseX509(e){let{der:t}=pemToDer$1(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 o=0;n.children[0].tag===160&&o++;let s=integerToBigInt(n.children[o].data);o++,o++;let c=parseDN(n.children[o]);o++;let l=n.children[o],u=parseAsn1Time(l.children[0]),d=parseAsn1Time(l.children[1]);o++;let p=parseDN(n.children[o]);o++;let m=null,h=`unknown`;if(o<n.children.length){let e=n.children[o];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,so)&&(h=`rsa`,m=parseSubjectPublicKeyInfo(e).components)}}}catch{}o++}let g,_;for(let e=o;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){_=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];g=parseSAN(e.data)}}}}}let v=`unknown`;r.children&&r.children.length>=1&&(v=oidToName(r.children[0].data));let y=i.tag===3?i.data.slice(1):i.data;return{raw:e,tbsCertificate:n.data,serialNumber:s,issuer:c,subject:p,validFrom:u,validTo:d,publicKey:m,publicKeyAlgorithm:h,signatureAlgorithm:v,signature:y,subjectAltName:g,extensions:_}}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 fo[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=uo[r]||r,o=n.children[1].data,s=new TextDecoder().decode(o);t.push(`${i}=${s}`)}}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),o=parseInt(t.substring(8,10),10),s=parseInt(t.substring(10,12),10);return new Date(Date.UTC(e,n,r,i,o,s))}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),o=parseInt(t.substring(10,12),10),s=parseInt(t.substring(12,14),10);return new Date(Date.UTC(e,n,r,i,o,s))}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$1(e);switch(t){case`RSA PUBLIC KEY`:return parseDerKey(n,`pkcs1`,`public`);case`PUBLIC KEY`:return parseDerKey(n,`spki`);case`RSA PRIVATE KEY`:return parseDerKey(n,`pkcs1`,`private`);case`PRIVATE KEY`:return parseDerKey(n,`pkcs8`);default:throw Error(`Unsupported PEM type: ${t}`)}}function parseDerKey(e,t,n){let r=parseDer(e);if(r.tag!==48)throw Error(`Invalid key format: expected top-level SEQUENCE`);switch(t){case`spki`:return parseSubjectPublicKeyInfo(r);case`pkcs8`:return parsePrivateKeyInfo(r);case`pkcs1`:return n===`public`?{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(r)}:{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(r)}}}function rsaKeySize(e){let t=0,n=e;for(;n>0n;)t++,n>>=1n;return Math.ceil(t/8)}var so,co,lo,uo,fo,po=__esmMin(()=>{U(),__name(pemToDer$1,`pemToDer`),so=new Uint8Array([42,134,72,134,247,13,1,1,1]),co=new Uint8Array([43,101,110]),lo=new Uint8Array([43,101,112]),__name(modInverse$2,`modInverse`),uo={"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`},fo={"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 normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function hashSize(e){let t=normalizeAlgorithm(e),n=mo[t];if(n===void 0)throw Error(`Unknown hash algorithm: ${e}`);return n}function toBuffer$1(e,t){return typeof e==`string`?H.from(e,t||`utf8`):e instanceof DataView?H.from(e.buffer,e.byteOffset,e.byteLength):(e instanceof ArrayBuffer,H.from(e))}function codedError(e,t,n=Error){let r=new n(t);return r.code=e,r}var mo,ho,go,_o=__esmMin(()=>{U(),mo={md5:16,sha1:20,sha256:32,sha384:48,sha512:64},ho={md5:64,sha1:64,sha256:64,sha384:128,sha512:128},go=new Set([`md5`,`sha1`,`sha256`,`sha384`,`sha512`]),__name(toBuffer$1,`toBuffer`)});function fromBig(e,t=!1){return t?{h:Number(e&vo),l:Number(e>>yo&vo)}:{h:Number(e>>yo&vo)|0,l:Number(e&vo)|0}}function split(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){let{h:n,l:s}=fromBig(e[o],t);[r[o],i[o]]=[n,s]}return[r,i]}function setU64FromNum(e,t,n,r){let i=fromNumH(n),o=fromNumL(n);e.setUint32(t,r?o:i,r),e.setUint32(t+4,r?i:o,r)}function add(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var vo,yo,fromNumH,fromNumL,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,add3L,add3H,add4L,add4H,add5L,add5H,bo=__esmMin(()=>{vo=BigInt(2**32-1),yo=BigInt(32),fromNumH=e=>e/2**32|0,fromNumL=e=>e>>>0,shrSH=(e,t,n)=>e>>>n,shrSL=(e,t,n)=>e<<32-n|t>>>n,rotrSH=(e,t,n)=>e>>>n|t<<32-n,rotrSL=(e,t,n)=>e<<32-n|t>>>n,rotrBH=(e,t,n)=>e<<64-n|t>>>n-32,rotrBL=(e,t,n)=>e>>>n-32|t<<64-n,add3L=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5L=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),add5H=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0});function isBytes$1(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function anumber$1(e,t=``){if(typeof e!=`number`)throw TypeError(xo(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(xo(t)+`expected integer >= 0, got `+e);return e}function abytes$1(e,t,n=``){if(isBytes$1(e)&&(t===void 0||e.length===t))return e;t!==void 0&&anumber$1(t,`length`);let r=isBytes$1(e),i=t===void 0?``:` of length ${t}`,o=r?`length=${e.length}`:`type=${typeof e}`,s=xo(n)+`expected Uint8Array`+i+`, got `+o;throw r?RangeError(s):TypeError(s)}function aexists(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function aoutput(e,t){abytes$1(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function clean(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function createView(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function bytesToHex$1(e){if(abytes$1(e),Co)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=wo[e[n]];return t}function asciiToBase16(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function hexToBytes$1(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(Co)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=asciiToBase16(e.charCodeAt(i)),o=asciiToBase16(e.charCodeAt(i+1));if(n===void 0||o===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+o}return r}function concatBytes$1(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];abytes$1(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function checkOpts(e,t,n=`opts`){return aopts(e,`defaults`),t!==void 0&&aopts(t,n),Object.assign(Object.create(null),e,t)}function createHasher(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=checkOpts({},t,`info`);let hashC=(t,n)=>e(n).update(t).digest(),n=e(void 0);return hashC.outputLen=n.outputLen,hashC.blockLen=n.blockLen,hashC.canXOF=n.canXOF,hashC.create=t=>e(t),Object.assign(hashC,t),Object.freeze(hashC)}function randomBytes$2(e=32){anumber$1(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var xo,So,aopts,Co,wo,oidNist,To=__esmMin(()=>{__name(isBytes$1,`isBytes`),xo=__name(e=>e?`"${e}" `:``,`atitle`),__name(anumber$1,`anumber`),__name(abytes$1,`abytes`),So=__name((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},`aobject`),aopts=(e,t)=>{So(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)},Co=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,wo=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),__name(bytesToHex$1,`bytesToHex`),__name(hexToBytes$1,`hexToBytes`),__name(concatBytes$1,`concatBytes`),__name(randomBytes$2,`randomBytes`),oidNist=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})}),HashMD,Eo,Do=__esmMin(()=>{bo(),To(),HashMD=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){aexists(this),abytes$1(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,o=!1;for(let s=0;s<i;){let c=Math.min(r-this.pos,i-s);if(c===r){let t=createView(e);for(;r<=i-s;s+=r)this.process(t,s);o=!0;continue}n.set(s===0&&c===i?e:e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===r&&(this.process(t,0),this.pos=0,o=!0)}return this.length+=e.length,o&&this.roundClean(),this}digestInto(e){aexists(this),aoutput(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:o}=this;t[o++]=128,t.fill(0,o),this.padOffset>r-o&&(this.process(n,0),t.fill(0)),setU64FromNum(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let s=e===t?n:createView(e),c=this.outputLen,l=c/4,u=this.get();if(c%4||l>u.length)throw Error(`invalid outputLen`);for(let e=0;e<l;e++)s.setUint32(4*e,u[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:o}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=o,o&&e.buffer.set(t),e}clone(){return this._cloneInto()}},Eo=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),Oo,ko,Ao,jo,Mo,SHA2_64B,_SHA512,No,Po=__esmMin(()=>{Do(),bo(),To(),Oo=split(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),ko=Oo[0],Ao=Oo[1],jo=new Uint32Array(80),Mo=new Uint32Array(80),SHA2_64B=class extends HashMD{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(e,t){super(128,e,16,!1),this.Ah=t[0]|0,this.Al=t[1]|0,this.Bh=t[2]|0,this.Bl=t[3]|0,this.Ch=t[4]|0,this.Cl=t[5]|0,this.Dh=t[6]|0,this.Dl=t[7]|0,this.Eh=t[8]|0,this.El=t[9]|0,this.Fh=t[10]|0,this.Fl=t[11]|0,this.Gh=t[12]|0,this.Gl=t[13]|0,this.Hh=t[14]|0,this.Hl=t[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:c,Eh:l,El:u,Fh:d,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;return[e,t,n,r,i,o,s,c,l,u,d,p,m,h,g,_]}set(e,t,n,r,i,o,s,c,l,u,d,p,m,h,g,_){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=o|0,this.Dh=s|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=m|0,this.Gl=h|0,this.Hh=g|0,this.Hl=_|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)jo[n]=e.getUint32(t),Mo[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=jo[e-15]|0,n=Mo[e-15]|0,r=rotrSH(t,n,1)^rotrSH(t,n,8)^shrSH(t,n,7),i=rotrSL(t,n,1)^rotrSL(t,n,8)^shrSL(t,n,7),o=jo[e-2]|0,s=Mo[e-2]|0,c=rotrSH(o,s,19)^rotrBH(o,s,61)^shrSH(o,s,6),l=rotrSL(o,s,19)^rotrBL(o,s,61)^shrSL(o,s,6),u=add4L(i,l,Mo[e-7],Mo[e-16]),d=add4H(u,r,c,jo[e-7],jo[e-16]);jo[e]=d|0,Mo[e]=u|0}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:c,Dh:l,Dl:u,Eh:d,El:p,Fh:m,Fl:h,Gh:g,Gl:_,Hh:v,Hl:y}=this;for(let e=0;e<80;e++){let t=rotrSH(d,p,14)^rotrSH(d,p,18)^rotrBH(d,p,41),b=rotrSL(d,p,14)^rotrSL(d,p,18)^rotrBL(d,p,41),x=d&m^~d&g,S=p&h^~p&_,w=add5L(y,b,S,Ao[e],Mo[e]),T=add5H(w,v,t,x,ko[e],jo[e]),E=w|0,D=rotrSH(n,r,28)^rotrBH(n,r,34)^rotrBH(n,r,39),ee=rotrSL(n,r,28)^rotrBL(n,r,34)^rotrBL(n,r,39),O=n&i^n&s^i&s,k=r&o^r&c^o&c;v=g|0,y=_|0,g=m|0,_=h|0,m=d|0,h=p|0,{h:d,l:p}=add(l|0,u|0,T|0,E|0),l=s|0,u=c|0,s=i|0,c=o|0,i=n|0,o=r|0;let te=add3L(E,ee,k);n=add3H(te,T,D,O),r=te|0}({h:n,l:r}=add(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:o}=add(this.Bh|0,this.Bl|0,i|0,o|0),{h:s,l:c}=add(this.Ch|0,this.Cl|0,s|0,c|0),{h:l,l:u}=add(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:p}=add(this.Eh|0,this.El|0,d|0,p|0),{h:m,l:h}=add(this.Fh|0,this.Fl|0,m|0,h|0),{h:g,l:_}=add(this.Gh|0,this.Gl|0,g|0,_|0),{h:v,l:y}=add(this.Hh|0,this.Hl|0,v|0,y|0),this.set(n,r,i,o,s,c,l,u,d,p,m,h,g,_,v,y)}roundClean(){clean(jo,Mo)}destroy(){this.destroyed=!0,clean(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},_SHA512=class extends SHA2_64B{constructor(){super(64,Eo)}},No=createHasher(()=>new _SHA512,oidNist(3))});
13
13
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
14
14
  function aarray(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}function aobject(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function afunction(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function abool(e,t=``){if(typeof e!=`boolean`)throw TypeError(atitle(t)+`expected boolean, got type=`+typeof e);return e}function abignumber(e){if(typeof e==`bigint`){if(!isPosBig(e))throw RangeError(`positive bigint expected, got `+e)}else Fo(e);return e}function asafenumber(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function hexToNumber(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?zo:BigInt(`0x`+e)}function bytesToNumberBE(e){return hexToNumber(bytesToHex$1(e))}function bytesToNumberLE(e){return hexToNumber(bytesToHex$1(copyBytes(abytes$1(e)).reverse()))}function numberToBytesBE(e,t){if(anumber$1(t),t===0)throw Error(`zero output length is invalid`);e=abignumber(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return hexToBytes$1(r.padStart(n,`0`))}function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}function copyBytes(e){return Uint8Array.from(abytes(e))}function asciiToBytes(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function isPosBig(e){return typeof e==`bigint`&&zo<=e}function inRange(e,t,n){return isPosBig(e)&&isPosBig(t)&&isPosBig(n)&&t<=e&&e<n}function aInRange(e,t,n,r){if(!inRange(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function bitLen(e){if(e<zo)throw Error(`expected non-negative bigint, got `+e);return e===zo?0:e.toString(2).length}function validateObject(e,t={},n={},r=`object`){aobject(e,r),aobject(t,`fields`),aobject(n,`optFields`);function checkField(t,n,i){let o=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,s=e[t];if(!Object.hasOwn(e,t)&&(i?s!==void 0:n!==`function`))throw TypeError(`${o} is invalid: expected own property`);if(i&&s===void 0)return;let c=typeof s;if(c!==n||s===null)throw TypeError(`${o} is invalid: expected ${n}, got ${c}`)}let iter=(e,t)=>Object.entries(e).forEach(([e,n])=>checkField(e,n,t));iter(t,!1),iter(n,!0)}var abytes,Fo,Io,concatBytes,hexToBytes,Lo,Ro,zo,Bo,atitle,bitMask,Vo=__esmMin(()=>{To(),abytes=(e,t,n)=>abytes$1(e,t,n),Fo=anumber$1,Io=bytesToHex$1,concatBytes=(...e)=>concatBytes$1(...e),hexToBytes=e=>hexToBytes$1(e),Lo=isBytes$1,Ro=__name(e=>randomBytes$2(e),`randomBytes`),zo=BigInt(0),Bo=BigInt(1),atitle=e=>e?`"${e}" `:``,bitMask=e=>(asafenumber(e,`n`),(Bo<<BigInt(e))-Bo)});
@@ -448,4 +448,4 @@ ${t}
448
448
  ${renderContent(n.content)}
449
449
  </div>
450
450
  </article>
451
- </main>`))}),Qm.use(Jm.static(Xm)),Qm.listen(Zm,()=>{M.log(``),M.log(` Express.js blog running on ${Zc}`),M.log(``),M.log(` ➜ Local: http://localhost:${Zm}/`),M.log(` ➜ API: http://localhost:${Zm}/api/posts`),M.log(``),M.log(` Press Ctrl+C to stop`),M.log(``)});
451
+ </main>`))}),Qm.use(Jm.static(Xm)),Qm.listen(Zm,()=>{M.log(``),M.log(` Express.js blog running on ${Zc}`),M.log(``),M.log(` ➜ Local: http://localhost:${Zm}/`),M.log(` ➜ API: http://localhost:${Zm}/api/posts`),M.log(``),M.log(` Press Ctrl+C to stop`),M.log(``)});const $m=globalThis.process,eh=Number($m?.exitCode);Number.isInteger(eh)&&eh!==0&&$m.exit(eh);