prez-lib 4.1.2 → 4.1.3

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/prez-lib.js CHANGED
@@ -7442,7 +7442,7 @@ class gr {
7442
7442
  }
7443
7443
  getMaxReached() {
7444
7444
  const e = this.store.getObjects(null, ce.count, null);
7445
- return e.length > 0 ? e[0].value.includes(">") : !1;
7445
+ return e.length > 0 ? !e[0].value.includes(">") : !1;
7446
7446
  }
7447
7447
  /**
7448
7448
  * Returns a list of item objects
@@ -7455,6 +7455,10 @@ class gr {
7455
7455
  e.push(this.toPrezFocusNode(n));
7456
7456
  }), e;
7457
7457
  }
7458
+ getSkosCollections(e) {
7459
+ const r = this.getSubjects("http://www.w3.org/2004/02/skos/core#inScheme", e.value);
7460
+ return this.getSubjects("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/2004/02/skos/core#Collection").filter((a) => r.find((l) => l.value === a.value)).map((a) => this.toPrezTerm(a)).sort((a, l) => a.label && l.label ? a.label.value.localeCompare(l.label.value) : a.label ? -1 : l.label ? 1 : a.value.localeCompare(l.value));
7461
+ }
7458
7462
  /**
7459
7463
  * Returns an item object
7460
7464
  *
@@ -7466,14 +7470,11 @@ class gr {
7466
7470
  const e = this.getByPrezId();
7467
7471
  if (e.length == 0) throw new Error("Unable to find item");
7468
7472
  const r = this.toPrezFocusNode(e[0]);
7469
- if ((n = r.rdfTypes) != null && n.map((i) => i.value).includes(he.skosConcept)) {
7470
- const i = this.getConcepts(e[0]);
7473
+ if ((n = r.rdfTypes) != null && n.map((i) => i.value).includes(he.skosConceptScheme)) {
7474
+ const i = this.getSkosCollections(e[0]);
7471
7475
  return {
7472
7476
  ...r,
7473
- topConcepts: {
7474
- narrowers: i,
7475
- hasChildren: i.length > 0
7476
- }
7477
+ collections: i
7477
7478
  };
7478
7479
  }
7479
7480
  return r;
@@ -26,4 +26,4 @@
26
26
  `),this._subject=null),this._write=this._blockedWrite;let r=e&&((n,i)=>{r=null,e(n,i)});if(this._endStream)try{return this._outputStream.end(r)}catch{}r&&r()}}function Vn(t){let e=wo[t];return e===void 0&&(t.length===1?(e=t.charCodeAt(0).toString(16),e="\\u0000".substr(0,6-e.length)+e):(e=((t.charCodeAt(0)-55296)*1024+t.charCodeAt(1)+9216).toString(16),e="\\U00000000".substr(0,10-e.length)+e)),e}var Kn={exports:{}},$r={exports:{}},oe={AggregateError:class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
27
27
  `;super(r),this.name="AggregateError",this.errors=e}},ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,e){return t.includes(e)},ArrayPrototypeIndexOf(t,e){return t.indexOf(e)},ArrayPrototypeJoin(t,e){return t.join(e)},ArrayPrototypeMap(t,e){return t.map(e)},ArrayPrototypePop(t,e){return t.pop(e)},ArrayPrototypePush(t,e){return t.push(e)},ArrayPrototypeSlice(t,e,r){return t.slice(e,r)},Error,FunctionPrototypeCall(t,e,...r){return t.call(e,...r)},FunctionPrototypeSymbolHasInstance(t,e){return Function.prototype[Symbol.hasInstance].call(t,e)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,e){return Object.defineProperties(t,e)},ObjectDefineProperty(t,e,r){return Object.defineProperty(t,e,r)},ObjectGetOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(t,e)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,e){return Object.setPrototypeOf(t,e)},Promise,PromisePrototypeCatch(t,e){return t.catch(e)},PromisePrototypeThen(t,e,r){return t.then(e,r)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,e){return t.test(e)},SafeSet:Set,String,StringPrototypeSlice(t,e,r){return t.slice(e,r)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Boolean,Uint8Array},Yn={exports:{}},Xn={format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){const i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}}};const{format:mo,inspect:rr}=Xn,{AggregateError:xo}=oe,Eo=globalThis.AggregateError||xo,So=Symbol("kIsNodeError"),Io=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Ro=/^([A-Z][a-z0-9]*)+$/,Ao="__node_internal_",nr={};function at(t,e){if(!t)throw new nr.ERR_INTERNAL_ASSERTION(e)}function Zn(t){let e="",r=t.length;const n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function To(t,e,r){if(typeof e=="function")return at(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);const n=(e.match(/%[dfijoOs]/g)||[]).length;return at(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:mo(e,...r)}function ye(t,e,r){r||(r=Error);class n extends r{constructor(...a){super(To(t,e,a))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[So]=!0,nr[t]=n}function Jn(t){const e=Ao+t.name;return Object.defineProperty(t,"name",{value:e}),t}function vo(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;const r=new Eo([e,t],e.message);return r.code=e.code,r}return t||e}let No=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new nr.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};ye("ERR_ASSERTION","%s",Error),ye("ERR_INVALID_ARG_TYPE",(t,e,r)=>{at(typeof t=="string","'name' must be a string"),Array.isArray(e)||(e=[e]);let n="The ";t.endsWith(" argument")?n+=`${t} `:n+=`"${t}" ${t.includes(".")?"property":"argument"} `,n+="must be ";const i=[],a=[],l=[];for(const p of e)at(typeof p=="string","All expected entries have to be of type string"),Io.includes(p)?i.push(p.toLowerCase()):Ro.test(p)?a.push(p):(at(p!=="object",'The value "object" should be written as "Object"'),l.push(p));if(a.length>0){const p=i.indexOf("object");p!==-1&&(i.splice(i,p,1),a.push("Object"))}if(i.length>0){switch(i.length){case 1:n+=`of type ${i[0]}`;break;case 2:n+=`one of type ${i[0]} or ${i[1]}`;break;default:{const p=i.pop();n+=`one of type ${i.join(", ")}, or ${p}`}}(a.length>0||l.length>0)&&(n+=" or ")}if(a.length>0){switch(a.length){case 1:n+=`an instance of ${a[0]}`;break;case 2:n+=`an instance of ${a[0]} or ${a[1]}`;break;default:{const p=a.pop();n+=`an instance of ${a.join(", ")}, or ${p}`}}l.length>0&&(n+=" or ")}switch(l.length){case 0:break;case 1:l[0].toLowerCase()!==l[0]&&(n+="an "),n+=`${l[0]}`;break;case 2:n+=`one of ${l[0]} or ${l[1]}`;break;default:{const p=l.pop();n+=`one of ${l.join(", ")}, or ${p}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var u;if((u=r.constructor)!==null&&u!==void 0&&u.name)n+=`. Received an instance of ${r.constructor.name}`;else{const p=rr(r,{depth:-1});n+=`. Received ${p}`}}else{let p=rr(r,{colors:!1});p.length>25&&(p=`${p.slice(0,25)}...`),n+=`. Received type ${typeof r} (${p})`}return n},TypeError),ye("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=rr(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError),ye("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;const i=r!=null&&(n=r.constructor)!==null&&n!==void 0&&n.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${t} to be returned from the "${e}" function but got ${i}.`},TypeError),ye("ERR_MISSING_ARGS",(...t)=>{at(t.length>0,"At least one arg needs to be specified");let e;const r=t.length;switch(t=(Array.isArray(t)?t:[t]).map(n=>`"${n}"`).join(" or "),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{const n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError),ye("ERR_OUT_OF_RANGE",(t,e,r)=>{at(e,'Missing "range" argument');let n;if(Number.isInteger(r)&&Math.abs(r)>2**32)n=Zn(String(r));else if(typeof r=="bigint"){n=String(r);const i=BigInt(2)**BigInt(32);(r>i||r<-i)&&(n=Zn(n)),n+="n"}else n=rr(r);return`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError),ye("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),ye("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),ye("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),ye("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),ye("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),ye("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),ye("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),ye("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),ye("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),ye("ERR_STREAM_WRITE_AFTER_END","write after end",Error),ye("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);var xe={AbortError:No,aggregateTwoErrors:Jn(vo),hideStackFrames:Jn,codes:nr},Ct={exports:{}},ei;function Ot(){if(ei)return Ct.exports;ei=1;const{AbortController:t,AbortSignal:e}=typeof self<"u"?self:typeof window<"u"?window:void 0;return Ct.exports=t,Ct.exports.AbortSignal=e,Ct.exports.default=t,Ct.exports}var Br={exports:{}},St=typeof Reflect=="object"?Reflect:null,ti=St&&typeof St.apply=="function"?St.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ir;St&&typeof St.ownKeys=="function"?ir=St.ownKeys:Object.getOwnPropertySymbols?ir=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ir=function(e){return Object.getOwnPropertyNames(e)};function Po(t){console&&console.warn&&console.warn(t)}var ri=Number.isNaN||function(e){return e!==e};function X(){X.init.call(this)}Br.exports=X,Br.exports.once=Bo,X.EventEmitter=X,X.prototype._events=void 0,X.prototype._eventsCount=0,X.prototype._maxListeners=void 0;var ni=10;function sr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(X,"defaultMaxListeners",{enumerable:!0,get:function(){return ni},set:function(t){if(typeof t!="number"||t<0||ri(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ni=t}}),X.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},X.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ri(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ii(t){return t._maxListeners===void 0?X.defaultMaxListeners:t._maxListeners}X.prototype.getMaxListeners=function(){return ii(this)},X.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var l;if(r.length>0&&(l=r[0]),l instanceof Error)throw l;var u=new Error("Unhandled error."+(l?" ("+l.message+")":""));throw u.context=l,u}var p=a[e];if(p===void 0)return!1;if(typeof p=="function")ti(p,this,r);else for(var _=p.length,y=ui(p,_),n=0;n<_;++n)ti(y[n],this,r);return!0};function si(t,e,r,n){var i,a,l;if(sr(r),a=t._events,a===void 0?(a=t._events=Object.create(null),t._eventsCount=0):(a.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),l=a[e]),l===void 0)l=a[e]=r,++t._eventsCount;else if(typeof l=="function"?l=a[e]=n?[r,l]:[l,r]:n?l.unshift(r):l.push(r),i=ii(t),i>0&&l.length>i&&!l.warned){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=l.length,Po(u)}return t}X.prototype.addListener=function(e,r){return si(this,e,r,!1)},X.prototype.on=X.prototype.addListener,X.prototype.prependListener=function(e,r){return si(this,e,r,!0)};function jo(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function oi(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=jo.bind(n);return i.listener=r,n.wrapFn=i,i}X.prototype.once=function(e,r){return sr(r),this.on(e,oi(this,e,r)),this},X.prototype.prependOnceListener=function(e,r){return sr(r),this.prependListener(e,oi(this,e,r)),this},X.prototype.removeListener=function(e,r){var n,i,a,l,u;if(sr(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,l=n.length-1;l>=0;l--)if(n[l]===r||n[l].listener===r){u=n[l].listener,a=l;break}if(a<0)return this;a===0?n.shift():Lo(n,a),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this},X.prototype.off=X.prototype.removeListener,X.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var a=Object.keys(n),l;for(i=0;i<a.length;++i)l=a[i],l!=="removeListener"&&this.removeAllListeners(l);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function ai(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?$o(i):ui(i,i.length)}X.prototype.listeners=function(e){return ai(this,e,!0)},X.prototype.rawListeners=function(e){return ai(this,e,!1)},X.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):li.call(t,e)},X.prototype.listenerCount=li;function li(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}X.prototype.eventNames=function(){return this._eventsCount>0?ir(this._events):[]};function ui(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Lo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function $o(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Bo(t,e){return new Promise(function(r,n){function i(l){t.removeListener(e,a),n(l)}function a(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}fi(t,e,a,{once:!0}),e!=="error"&&Fo(t,i,{once:!0})})}function Fo(t,e,r){typeof t.on=="function"&&fi(t,"error",e,r)}function fi(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(a){n.once&&t.removeEventListener(e,i),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var or=Br.exports;(function(t){const e=Fe,{format:r,inspect:n}=Xn,{codes:{ERR_INVALID_ARG_TYPE:i}}=xe,{kResistStopPropagation:a,AggregateError:l,SymbolDispose:u}=oe,p=globalThis.AbortSignal||Ot().AbortSignal,_=globalThis.AbortController||Ot().AbortController,y=Object.getPrototypeOf(async function(){}).constructor,x=globalThis.Blob||e.Blob,I=typeof x<"u"?function(A){return A instanceof x}:function(A){return!1},S=(w,A)=>{if(w!==void 0&&(w===null||typeof w!="object"||!("aborted"in w)))throw new i(A,"AbortSignal",w)},R=(w,A)=>{if(typeof w!="function")throw new i(A,"Function",w)};t.exports={AggregateError:l,kEmptyObject:Object.freeze({}),once(w){let A=!1;return function(...$){A||(A=!0,w.apply(this,$))}},createDeferredPromise:function(){let w,A;return{promise:new Promise((B,T)=>{w=B,A=T}),resolve:w,reject:A}},promisify(w){return new Promise((A,$)=>{w((B,...T)=>B?$(B):A(...T))})},debuglog(){return function(){}},format:r,inspect:n,types:{isAsyncFunction(w){return w instanceof y},isArrayBufferView(w){return ArrayBuffer.isView(w)}},isBlob:I,deprecate(w,A){return w},addAbortListener:or.addAbortListener||function(A,$){if(A===void 0)throw new i("signal","AbortSignal",A);S(A,"signal"),R($,"listener");let B;return A.aborted?queueMicrotask(()=>$()):(A.addEventListener("abort",$,{__proto__:null,once:!0,[a]:!0}),B=()=>{A.removeEventListener("abort",$)}),{__proto__:null,[u](){var T;(T=B)===null||T===void 0||T()}}},AbortSignalAny:p.any||function(A){if(A.length===1)return A[0];const $=new _,B=()=>$.abort();return A.forEach(T=>{S(T,"signals"),T.addEventListener("abort",B,{once:!0})}),$.signal.addEventListener("abort",()=>{A.forEach(T=>T.removeEventListener("abort",B))},{once:!0}),$.signal}},t.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(Yn);var Se=Yn.exports,Fr={};const{ArrayIsArray:ci,ArrayPrototypeIncludes:ko,ArrayPrototypeJoin:Co,ArrayPrototypeMap:Oo,NumberIsInteger:kr,NumberMAX_SAFE_INTEGER:Mo,NumberMIN_SAFE_INTEGER:Do,ObjectPrototypeHasOwnProperty:Uo,String:Wo}=oe,{hideStackFrames:Ne,codes:{ERR_INVALID_ARG_TYPE:Pe,ERR_INVALID_ARG_VALUE:di,ERR_OUT_OF_RANGE:It}}=xe,{normalizeEncoding:Xu}=Se,{isAsyncFunction:Go,isArrayBufferView:zo}=Se.types,qo=Ne((t,e,r=Do,n=Mo)=>{if(typeof t!="number")throw new Pe(e,"number",t);if(!kr(t))throw new It(e,"an integer",t);if(t<r||t>n)throw new It(e,`>= ${r} && <= ${n}`,t)});Ne((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Pe(e,"number",t);if(!kr(t))throw new It(e,"an integer",t);if(t<r||t>n)throw new It(e,`>= ${r} && <= ${n}`,t)}),Ne((t,e,r=!1)=>{if(typeof t!="number")throw new Pe(e,"number",t);if(!kr(t))throw new It(e,"an integer",t);const n=r?1:0,i=4294967295;if(t<n||t>i)throw new It(e,`>= ${n} && <= ${i}`,t)}),Ne((t,e,r)=>{if(!ko(r,t)){const i="must be one of: "+Co(Oo(r,a=>typeof a=="string"?`'${a}'`:Wo(a)),", ");throw new di(e,t,i)}});function Ho(t,e){if(typeof t!="boolean")throw new Pe(e,"boolean",t)}function Cr(t,e,r){return t==null||!Uo(t,e)?r:t[e]}const Qo=Ne((t,e,r=null)=>{const n=Cr(r,"allowArray",!1),i=Cr(r,"allowFunction",!1);if(!Cr(r,"nullable",!1)&&t===null||!n&&ci(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Pe(e,"Object",t)});Ne((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Pe(e,"a dictionary",t)}),Ne((t,e,r=0)=>{if(!ci(t))throw new Pe(e,"Array",t);if(t.length<r){const n=`must be longer than ${r}`;throw new di(e,t,n)}}),Ne((t,e="buffer")=>{if(!zo(t))throw new Pe(e,["Buffer","TypedArray","DataView"],t)});const Vo=Ne((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Pe(e,"AbortSignal",t)}),Ko=Ne((t,e)=>{if(typeof t!="function")throw new Pe(e,"Function",t)});Ne((t,e)=>{if(typeof t!="function"||Go(t))throw new Pe(e,"Function",t)}),Ne((t,e)=>{if(t!==void 0)throw new Pe(e,"undefined",t)});var Mt={validateBoolean:Ho,validateFunction:Ko,validateInteger:qo,validateObject:Qo,validateAbortSignal:Vo},Or={exports:{}},hi={exports:{}},he=hi.exports={},Ce,Oe;function Mr(){throw new Error("setTimeout has not been defined")}function Dr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ce=setTimeout:Ce=Mr}catch{Ce=Mr}try{typeof clearTimeout=="function"?Oe=clearTimeout:Oe=Dr}catch{Oe=Dr}})();function pi(t){if(Ce===setTimeout)return setTimeout(t,0);if((Ce===Mr||!Ce)&&setTimeout)return Ce=setTimeout,setTimeout(t,0);try{return Ce(t,0)}catch{try{return Ce.call(null,t,0)}catch{return Ce.call(this,t,0)}}}function Yo(t){if(Oe===clearTimeout)return clearTimeout(t);if((Oe===Dr||!Oe)&&clearTimeout)return Oe=clearTimeout,clearTimeout(t);try{return Oe(t)}catch{try{return Oe.call(null,t)}catch{return Oe.call(this,t)}}}var ze=[],Rt=!1,lt,ar=-1;function Xo(){!Rt||!lt||(Rt=!1,lt.length?ze=lt.concat(ze):ar=-1,ze.length&&_i())}function _i(){if(!Rt){var t=pi(Xo);Rt=!0;for(var e=ze.length;e;){for(lt=ze,ze=[];++ar<e;)lt&&lt[ar].run();ar=-1,e=ze.length}lt=null,Rt=!1,Yo(t)}}he.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ze.push(new bi(t,e)),ze.length===1&&!Rt&&pi(_i)};function bi(t,e){this.fun=t,this.array=e}bi.prototype.run=function(){this.fun.apply(null,this.array)},he.title="browser",he.browser=!0,he.env={},he.argv=[],he.version="",he.versions={};function qe(){}he.on=qe,he.addListener=qe,he.once=qe,he.off=qe,he.removeListener=qe,he.removeAllListeners=qe,he.emit=qe,he.prependListener=qe,he.prependOnceListener=qe,he.listeners=function(t){return[]},he.binding=function(t){throw new Error("process.binding is not supported")},he.cwd=function(){return"/"},he.chdir=function(t){throw new Error("process.chdir is not supported")},he.umask=function(){return 0};var ut=hi.exports;const{SymbolAsyncIterator:yi,SymbolIterator:gi,SymbolFor:ft}=oe,wi=ft("nodejs.stream.destroyed"),Zo=ft("nodejs.stream.errored"),mi=ft("nodejs.stream.readable"),xi=ft("nodejs.stream.writable"),Jo=ft("nodejs.stream.disturbed"),ea=ft("nodejs.webstream.isClosedPromise"),ta=ft("nodejs.webstream.controllerErrorFunction");function Ur(t,e=!1){var r;return!!(t&&typeof t.pipe=="function"&&typeof t.on=="function"&&(!e||typeof t.pause=="function"&&typeof t.resume=="function")&&(!t._writableState||((r=t._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!t._writableState||t._readableState))}function lr(t){var e;return!!(t&&typeof t.write=="function"&&typeof t.on=="function"&&(!t._readableState||((e=t._writableState)===null||e===void 0?void 0:e.writable)!==!1))}function ra(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Me(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function Ei(t){return!!(t&&!Me(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Si(t){return!!(t&&!Me(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Ii(t){return!!(t&&!Me(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function na(t){return Ei(t)||Si(t)||Ii(t)}function ia(t,e){return t==null?!1:e===!0?typeof t[yi]=="function":e===!1?typeof t[gi]=="function":typeof t[yi]=="function"||typeof t[gi]=="function"}function ur(t){if(!Me(t))return null;const e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[wi]||n!=null&&n.destroyed)}function sa(t){if(!lr(t))return null;if(t.writableEnded===!0)return!0;const e=t._writableState;return e!=null&&e.errored?!1:typeof(e==null?void 0:e.ended)!="boolean"?null:e.ended}function oa(t,e){if(!lr(t))return null;if(t.writableFinished===!0)return!0;const r=t._writableState;return r!=null&&r.errored?!1:typeof(r==null?void 0:r.finished)!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function Ri(t,e){if(!Ur(t))return null;const r=t._readableState;return r!=null&&r.errored?!1:typeof(r==null?void 0:r.endEmitted)!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function Ai(t){return t&&t[mi]!=null?t[mi]:typeof(t==null?void 0:t.readable)!="boolean"?null:ur(t)?!1:Ur(t)&&t.readable&&!Ri(t)}function Ti(t){return t&&t[xi]!=null?t[xi]:typeof(t==null?void 0:t.writable)!="boolean"?null:ur(t)?!1:lr(t)&&t.writable&&!sa(t)}function aa(t,e){return Me(t)?ur(t)?!0:!((e==null?void 0:e.readable)!==!1&&Ai(t)||(e==null?void 0:e.writable)!==!1&&Ti(t)):null}function la(t){var e,r;return Me(t)?t.writableErrored?t.writableErrored:(e=(r=t._writableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function ua(t){var e,r;return Me(t)?t.readableErrored?t.readableErrored:(e=(r=t._readableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function fa(t){if(!Me(t))return null;if(typeof t.closed=="boolean")return t.closed;const e=t._writableState,r=t._readableState;return typeof(e==null?void 0:e.closed)=="boolean"||typeof(r==null?void 0:r.closed)=="boolean"?(e==null?void 0:e.closed)||(r==null?void 0:r.closed):typeof t._closed=="boolean"&&vi(t)?t._closed:null}function vi(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function ca(t){return typeof t._sent100=="boolean"&&vi(t)}function da(t){var e;return typeof t._consuming=="boolean"&&typeof t._dumped=="boolean"&&((e=t.req)===null||e===void 0?void 0:e.upgradeOrConnect)===void 0}function ha(t){if(!Me(t))return null;const e=t._writableState,r=t._readableState,n=e||r;return!n&&ca(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function pa(t){var e;return!!(t&&((e=t[Jo])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function _a(t){var e,r,n,i,a,l,u,p,_,y;return!!(t&&((e=(r=(n=(i=(a=(l=t[Zo])!==null&&l!==void 0?l:t.readableErrored)!==null&&a!==void 0?a:t.writableErrored)!==null&&i!==void 0?i:(u=t._readableState)===null||u===void 0?void 0:u.errorEmitted)!==null&&n!==void 0?n:(p=t._writableState)===null||p===void 0?void 0:p.errorEmitted)!==null&&r!==void 0?r:(_=t._readableState)===null||_===void 0?void 0:_.errored)!==null&&e!==void 0?e:!((y=t._writableState)===null||y===void 0)&&y.errored))}var He={isDestroyed:ur,kIsDestroyed:wi,isDisturbed:pa,isErrored:_a,isReadable:Ai,kIsClosedPromise:ea,kControllerErrorFunction:ta,isClosed:fa,isDuplexNodeStream:ra,isFinished:aa,isIterable:ia,isReadableNodeStream:Ur,isReadableStream:Ei,isReadableFinished:Ri,isReadableErrored:ua,isNodeStream:Me,isWebStream:na,isWritable:Ti,isWritableNodeStream:lr,isWritableStream:Si,isWritableFinished:oa,isWritableErrored:la,isServerRequest:da,willEmitClose:ha,isTransformStream:Ii};const Ze=ut,{AbortError:Ni,codes:ba}=xe,{ERR_INVALID_ARG_TYPE:ya,ERR_STREAM_PREMATURE_CLOSE:Pi}=ba,{kEmptyObject:Wr,once:Gr}=Se,{validateAbortSignal:ga,validateFunction:wa,validateObject:ma,validateBoolean:xa}=Mt,{Promise:Ea,PromisePrototypeThen:Sa,SymbolDispose:ji}=oe,{isClosed:Ia,isReadable:Li,isReadableNodeStream:zr,isReadableStream:Ra,isReadableFinished:$i,isReadableErrored:Bi,isWritable:Fi,isWritableNodeStream:ki,isWritableStream:Aa,isWritableFinished:Ci,isWritableErrored:Oi,isNodeStream:Ta,willEmitClose:va,kIsClosedPromise:Na}=He;let At;function Pa(t){return t.setHeader&&typeof t.abort=="function"}const qr=()=>{};function Mi(t,e,r){var n,i;if(arguments.length===2?(r=e,e=Wr):e==null?e=Wr:ma(e,"options"),wa(r,"callback"),ga(e.signal,"options.signal"),r=Gr(r),Ra(t)||Aa(t))return ja(t,e,r);if(!Ta(t))throw new ya("stream",["ReadableStream","WritableStream","Stream"],t);const a=(n=e.readable)!==null&&n!==void 0?n:zr(t),l=(i=e.writable)!==null&&i!==void 0?i:ki(t),u=t._writableState,p=t._readableState,_=()=>{t.writable||I()};let y=va(t)&&zr(t)===a&&ki(t)===l,x=Ci(t,!1);const I=()=>{x=!0,t.destroyed&&(y=!1),!(y&&(!t.readable||a))&&(!a||S)&&r.call(t)};let S=$i(t,!1);const R=()=>{S=!0,t.destroyed&&(y=!1),!(y&&(!t.writable||l))&&(!l||x)&&r.call(t)},w=U=>{r.call(t,U)};let A=Ia(t);const $=()=>{A=!0;const U=Oi(t)||Bi(t);if(U&&typeof U!="boolean")return r.call(t,U);if(a&&!S&&zr(t,!0)&&!$i(t,!1))return r.call(t,new Pi);if(l&&!x&&!Ci(t,!1))return r.call(t,new Pi);r.call(t)},B=()=>{A=!0;const U=Oi(t)||Bi(t);if(U&&typeof U!="boolean")return r.call(t,U);r.call(t)},T=()=>{t.req.on("finish",I)};Pa(t)?(t.on("complete",I),y||t.on("abort",$),t.req?T():t.on("request",T)):l&&!u&&(t.on("end",_),t.on("close",_)),!y&&typeof t.aborted=="boolean"&&t.on("aborted",$),t.on("end",R),t.on("finish",I),e.error!==!1&&t.on("error",w),t.on("close",$),A?Ze.nextTick($):u!=null&&u.errorEmitted||p!=null&&p.errorEmitted?y||Ze.nextTick(B):(!a&&(!y||Li(t))&&(x||Fi(t)===!1)||!l&&(!y||Fi(t))&&(S||Li(t)===!1)||p&&t.req&&t.aborted)&&Ze.nextTick(B);const q=()=>{r=qr,t.removeListener("aborted",$),t.removeListener("complete",I),t.removeListener("abort",$),t.removeListener("request",T),t.req&&t.req.removeListener("finish",I),t.removeListener("end",_),t.removeListener("close",_),t.removeListener("finish",I),t.removeListener("end",R),t.removeListener("error",w),t.removeListener("close",$)};if(e.signal&&!A){const U=()=>{const ae=r;q(),ae.call(t,new Ni(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Ze.nextTick(U);else{At=At||Se.addAbortListener;const ae=At(e.signal,U),Ee=r;r=Gr((...ee)=>{ae[ji](),Ee.apply(t,ee)})}}return q}function ja(t,e,r){let n=!1,i=qr;if(e.signal)if(i=()=>{n=!0,r.call(t,new Ni(void 0,{cause:e.signal.reason}))},e.signal.aborted)Ze.nextTick(i);else{At=At||Se.addAbortListener;const l=At(e.signal,i),u=r;r=Gr((...p)=>{l[ji](),u.apply(t,p)})}const a=(...l)=>{n||Ze.nextTick(()=>r.apply(t,l))};return Sa(t[Na].promise,a,a),qr}function La(t,e){var r;let n=!1;return e===null&&(e=Wr),(r=e)!==null&&r!==void 0&&r.cleanup&&(xa(e.cleanup,"cleanup"),n=e.cleanup),new Ea((i,a)=>{const l=Mi(t,e,u=>{n&&l(),u?a(u):i()})})}Or.exports=Mi,Or.exports.finished=La;var Je=Or.exports;const De=ut,{aggregateTwoErrors:$a,codes:{ERR_MULTIPLE_CALLBACK:Ba},AbortError:Fa}=xe,{Symbol:Di}=oe,{kIsDestroyed:ka,isDestroyed:Ca,isFinished:Oa,isServerRequest:Ma}=He,Ui=Di("kDestroy"),Hr=Di("kConstruct");function Wi(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function Da(t,e){const r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(Wi(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Gi(this,t,e):this.once(Ui,function(a){Gi(this,$a(a,t),e)}),this)}function Gi(t,e,r){let n=!1;function i(a){if(n)return;n=!0;const l=t._readableState,u=t._writableState;Wi(a,u,l),u&&(u.closed=!0),l&&(l.closed=!0),typeof r=="function"&&r(a),a?De.nextTick(Ua,t,a):De.nextTick(zi,t)}try{t._destroy(e||null,i)}catch(a){i(a)}}function Ua(t,e){Qr(t,e),zi(t)}function zi(t){const e=t._readableState,r=t._writableState;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r!=null&&r.emitClose||e!=null&&e.emitClose)&&t.emit("close")}function Qr(t,e){const r=t._readableState,n=t._writableState;n!=null&&n.errorEmitted||r!=null&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit("error",e))}function Wa(){const t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=t.readable===!1,t.endEmitted=t.readable===!1),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=e.writable===!1,e.ending=e.writable===!1,e.finished=e.writable===!1)}function Vr(t,e,r){const n=t._readableState,i=t._writableState;if(i!=null&&i.destroyed||n!=null&&n.destroyed)return this;n!=null&&n.autoDestroy||i!=null&&i.autoDestroy?t.destroy(e):e&&(e.stack,i&&!i.errored&&(i.errored=e),n&&!n.errored&&(n.errored=e),r?De.nextTick(Qr,t,e):Qr(t,e))}function Ga(t,e){if(typeof t._construct!="function")return;const r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(Hr,e),!(t.listenerCount(Hr)>1)&&De.nextTick(za,t)}function za(t){let e=!1;function r(n){if(e){Vr(t,n??new Ba);return}e=!0;const i=t._readableState,a=t._writableState,l=a||i;i&&(i.constructed=!0),a&&(a.constructed=!0),l.destroyed?t.emit(Ui,n):n?Vr(t,n,!0):De.nextTick(qa,t)}try{t._construct(n=>{De.nextTick(r,n)})}catch(n){De.nextTick(r,n)}}function qa(t){t.emit(Hr)}function qi(t){return(t==null?void 0:t.setHeader)&&typeof t.abort=="function"}function Hi(t){t.emit("close")}function Ha(t,e){t.emit("error",e),De.nextTick(Hi,t)}function Qa(t,e){!t||Ca(t)||(!e&&!Oa(t)&&(e=new Fa),Ma(t)?(t.socket=null,t.destroy(e)):qi(t)?t.abort():qi(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?De.nextTick(Ha,t,e):De.nextTick(Hi,t),t.destroyed||(t[ka]=!0))}var Tt={construct:Ga,destroyer:Qa,destroy:Da,undestroy:Wa,errorOrDestroy:Vr};const{ArrayIsArray:Va,ObjectSetPrototypeOf:Qi}=oe,{EventEmitter:fr}=or;function cr(t){fr.call(this,t)}Qi(cr.prototype,fr.prototype),Qi(cr,fr),cr.prototype.pipe=function(t,e){const r=this;function n(y){t.writable&&t.write(y)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",l),r.on("close",u));let a=!1;function l(){a||(a=!0,t.end())}function u(){a||(a=!0,typeof t.destroy=="function"&&t.destroy())}function p(y){_(),fr.listenerCount(this,"error")===0&&this.emit("error",y)}Kr(r,"error",p),Kr(t,"error",p);function _(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",l),r.removeListener("close",u),r.removeListener("error",p),t.removeListener("error",p),r.removeListener("end",_),r.removeListener("close",_),t.removeListener("close",_)}return r.on("end",_),r.on("close",_),t.on("close",_),t.emit("pipe",r),t};function Kr(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Va(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}var Yr={Stream:cr,prependListener:Kr},Vi={exports:{}};(function(t){const{SymbolDispose:e}=oe,{AbortError:r,codes:n}=xe,{isNodeStream:i,isWebStream:a,kControllerErrorFunction:l}=He,u=Je,{ERR_INVALID_ARG_TYPE:p}=n;let _;const y=(x,I)=>{if(typeof x!="object"||!("aborted"in x))throw new p(I,"AbortSignal",x)};t.exports.addAbortSignal=function(I,S){if(y(I,"signal"),!i(S)&&!a(S))throw new p("stream",["ReadableStream","WritableStream","Stream"],S);return t.exports.addAbortSignalNoValidate(I,S)},t.exports.addAbortSignalNoValidate=function(x,I){if(typeof x!="object"||!("aborted"in x))return I;const S=i(I)?()=>{I.destroy(new r(void 0,{cause:x.reason}))}:()=>{I[l](new r(void 0,{cause:x.reason}))};if(x.aborted)S();else{_=_||Se.addAbortListener;const R=_(x,S);u(I,R[e])}return I}})(Vi);var dr=Vi.exports;const{StringPrototypeSlice:Ki,SymbolIterator:Ka,TypedArrayPrototypeSet:hr,Uint8Array:Ya}=oe,{Buffer:Xr}=Fe,{inspect:Xa}=Se;var Za=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){const r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;const e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let r=this.head,n=""+r.data;for(;(r=r.next)!==null;)n+=e+r.data;return n}concat(e){if(this.length===0)return Xr.alloc(0);const r=Xr.allocUnsafe(e>>>0);let n=this.head,i=0;for(;n;)hr(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){const n=this.head.data;if(e<n.length){const i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[Ka](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{const a=n.data;if(e>a.length)r+=a,e-=a.length;else{e===a.length?(r+=a,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Ki(a,0,e),this.head=n,n.data=Ki(a,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){const r=Xr.allocUnsafe(e),n=e;let i=this.head,a=0;do{const l=i.data;if(e>l.length)hr(r,l,n-e),e-=l.length;else{e===l.length?(hr(r,l,n-e),++a,i.next?this.head=i.next:this.head=this.tail=null):(hr(r,new Ya(l.buffer,l.byteOffset,e),n-e),this.head=i,i.data=l.slice(e));break}++a}while((i=i.next)!==null);return this.length-=a,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Xa(this,{...r,depth:0,customInspect:!1})}};const{MathFloor:Ja,NumberIsInteger:el}=oe,{validateInteger:tl}=Mt,{ERR_INVALID_ARG_VALUE:rl}=xe.codes;let Yi=16*1024,Xi=16;function nl(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Zi(t){return t?Xi:Yi}function il(t,e){tl(e,"value",0),t?Xi=e:Yi=e}function sl(t,e,r,n){const i=nl(e,n,r);if(i!=null){if(!el(i)||i<0){const a=n?`options.${r}`:"options.highWaterMark";throw new rl(a,i)}return Ja(i)}return Zi(t.objectMode)}var pr={getHighWaterMark:sl,getDefaultHighWaterMark:Zi,setDefaultHighWaterMark:il},Ji={},Zr={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(t,e){var r=Fe,n=r.Buffer;function i(l,u){for(var p in l)u[p]=l[p]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=a);function a(l,u,p){return n(l,u,p)}a.prototype=Object.create(n.prototype),i(n,a),a.from=function(l,u,p){if(typeof l=="number")throw new TypeError("Argument must not be a number");return n(l,u,p)},a.alloc=function(l,u,p){if(typeof l!="number")throw new TypeError("Argument must be a number");var _=n(l);return u!==void 0?typeof p=="string"?_.fill(u,p):_.fill(u):_.fill(0),_},a.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return n(l)},a.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}})(Zr,Zr.exports);var ol=Zr.exports,Jr=ol.Buffer,es=Jr.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function al(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function ll(t){var e=al(t);if(typeof e!="string"&&(Jr.isEncoding===es||!es(t)))throw new Error("Unknown encoding: "+t);return e||t}Ji.StringDecoder=Dt;function Dt(t){this.encoding=ll(t);var e;switch(this.encoding){case"utf16le":this.text=pl,this.end=_l,e=4;break;case"utf8":this.fillLast=cl,e=4;break;case"base64":this.text=bl,this.end=yl,e=3;break;default:this.write=gl,this.end=wl;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Jr.allocUnsafe(e)}Dt.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},Dt.prototype.end=hl,Dt.prototype.text=dl,Dt.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function en(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function ul(t,e,r){var n=e.length-1;if(n<r)return 0;var i=en(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=en(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=en(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function fl(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"�"}}function cl(t){var e=this.lastTotal-this.lastNeed,r=fl(this,t);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function dl(t,e){var r=ul(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function hl(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function pl(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function _l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function bl(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function yl(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function gl(t){return t.toString(this.encoding)}function wl(t){return t&&t.length?this.write(t):""}const ts=ut,{PromisePrototypeThen:ml,SymbolAsyncIterator:rs,SymbolIterator:ns}=oe,{Buffer:xl}=Fe,{ERR_INVALID_ARG_TYPE:El,ERR_STREAM_NULL_VALUES:Sl}=xe.codes;function Il(t,e,r){let n;if(typeof e=="string"||e instanceof xl)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[rs])i=!0,n=e[rs]();else if(e&&e[ns])i=!1,n=e[ns]();else throw new El("iterable",["Iterable"],e);const a=new t({objectMode:!0,highWaterMark:1,...r});let l=!1;a._read=function(){l||(l=!0,p())},a._destroy=function(_,y){ml(u(_),()=>ts.nextTick(y,_),x=>ts.nextTick(y,x||_))};async function u(_){const y=_!=null,x=typeof n.throw=="function";if(y&&x){const{value:I,done:S}=await n.throw(_);if(await I,S)return}if(typeof n.return=="function"){const{value:I}=await n.return();await I}}async function p(){for(;;){try{const{value:_,done:y}=i?await n.next():n.next();if(y)a.push(null);else{const x=_&&typeof _.then=="function"?await _:_;if(x===null)throw l=!1,new Sl;if(a.push(x))continue;l=!1}}catch(_){a.destroy(_)}break}}return a}var is=Il,tn,ss;function _r(){if(ss)return tn;ss=1;const t=ut,{ArrayPrototypeIndexOf:e,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:a,ObjectKeys:l,ObjectSetPrototypeOf:u,Promise:p,SafeSet:_,SymbolAsyncDispose:y,SymbolAsyncIterator:x,Symbol:I}=oe;tn=O,O.ReadableState=Re;const{EventEmitter:S}=or,{Stream:R,prependListener:w}=Yr,{Buffer:A}=Fe,{addAbortSignal:$}=dr,B=Je;let T=Se.debuglog("stream",c=>{T=c});const q=Za,U=Tt,{getHighWaterMark:ae,getDefaultHighWaterMark:Ee}=pr,{aggregateTwoErrors:ee,codes:{ERR_INVALID_ARG_TYPE:le,ERR_METHOD_NOT_IMPLEMENTED:ge,ERR_OUT_OF_RANGE:we,ERR_STREAM_PUSH_AFTER_EOF:Q,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:P},AbortError:K}=xe,{validateObject:G}=Mt,H=I("kPaused"),{StringDecoder:ue}=Ji,fe=is;u(O.prototype,R.prototype),u(O,R);const re=()=>{},{errorOrDestroy:ce}=U,D=1,ne=2,M=4,_e=8,Te=16,tt=32,Ke=64,je=128,Ye=256,Pt=512,_t=1024,rt=2048,g=4096,m=8192,N=16384,C=32768,F=65536,Z=1<<17,te=1<<18;function Y(c){return{enumerable:!1,get(){return(this.state&c)!==0},set(h){h?this.state|=c:this.state&=~c}}}a(Re.prototype,{objectMode:Y(D),ended:Y(ne),endEmitted:Y(M),reading:Y(_e),constructed:Y(Te),sync:Y(tt),needReadable:Y(Ke),emittedReadable:Y(je),readableListening:Y(Ye),resumeScheduled:Y(Pt),errorEmitted:Y(_t),emitClose:Y(rt),autoDestroy:Y(g),destroyed:Y(m),closed:Y(N),closeEmitted:Y(C),multiAwaitDrain:Y(F),readingMore:Y(Z),dataEmitted:Y(te)});function Re(c,h,j){typeof j!="boolean"&&(j=h instanceof Qe()),this.state=rt|g|Te|tt,c&&c.objectMode&&(this.state|=D),j&&c&&c.readableObjectMode&&(this.state|=D),this.highWaterMark=c?ae(this,c,"readableHighWaterMark",j):Ee(!1),this.buffer=new q,this.length=0,this.pipes=[],this.flowing=null,this[H]=null,c&&c.emitClose===!1&&(this.state&=-2049),c&&c.autoDestroy===!1&&(this.state&=-4097),this.errored=null,this.defaultEncoding=c&&c.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,c&&c.encoding&&(this.decoder=new ue(c.encoding),this.encoding=c.encoding)}function O(c){if(!(this instanceof O))return new O(c);const h=this instanceof Qe();this._readableState=new Re(c,this,h),c&&(typeof c.read=="function"&&(this._read=c.read),typeof c.destroy=="function"&&(this._destroy=c.destroy),typeof c.construct=="function"&&(this._construct=c.construct),c.signal&&!h&&$(c.signal,this)),R.call(this,c),U.construct(this,()=>{this._readableState.needReadable&&b(this,this._readableState)})}O.prototype.destroy=U.destroy,O.prototype._undestroy=U.undestroy,O.prototype._destroy=function(c,h){h(c)},O.prototype[S.captureRejectionSymbol]=function(c){this.destroy(c)},O.prototype[y]=function(){let c;return this.destroyed||(c=this.readableEnded?null:new K,this.destroy(c)),new p((h,j)=>B(this,L=>L&&L!==c?j(L):h(null)))},O.prototype.push=function(c,h){return Le(this,c,h,!1)},O.prototype.unshift=function(c,h){return Le(this,c,h,!0)};function Le(c,h,j,L){T("readableAddChunk",h);const k=c._readableState;let me;if((k.state&D)===0&&(typeof h=="string"?(j=j||k.defaultEncoding,k.encoding!==j&&(L&&k.encoding?h=A.from(h,j).toString(k.encoding):(h=A.from(h,j),j=""))):h instanceof A?j="":R._isUint8Array(h)?(h=R._uint8ArrayToBuffer(h),j=""):h!=null&&(me=new le("chunk",["string","Buffer","Uint8Array"],h))),me)ce(c,me);else if(h===null)k.state&=-9,s(c,k);else if((k.state&D)!==0||h&&h.length>0)if(L)if((k.state&M)!==0)ce(c,new P);else{if(k.destroyed||k.errored)return!1;Kt(c,k,h,!0)}else if(k.ended)ce(c,new Q);else{if(k.destroyed||k.errored)return!1;k.state&=-9,k.decoder&&!j?(h=k.decoder.write(h),k.objectMode||h.length!==0?Kt(c,k,h,!1):b(c,k)):Kt(c,k,h,!1)}else L||(k.state&=-9,b(c,k));return!k.ended&&(k.length<k.highWaterMark||k.length===0)}function Kt(c,h,j,L){h.flowing&&h.length===0&&!h.sync&&c.listenerCount("data")>0?((h.state&F)!==0?h.awaitDrainWriters.clear():h.awaitDrainWriters=null,h.dataEmitted=!0,c.emit("data",j)):(h.length+=h.objectMode?1:j.length,L?h.buffer.unshift(j):h.buffer.push(j),(h.state&Ke)!==0&&o(c)),b(c,h)}O.prototype.isPaused=function(){const c=this._readableState;return c[H]===!0||c.flowing===!1},O.prototype.setEncoding=function(c){const h=new ue(c);this._readableState.decoder=h,this._readableState.encoding=this._readableState.decoder.encoding;const j=this._readableState.buffer;let L="";for(const k of j)L+=h.write(k);return j.clear(),L!==""&&j.push(L),this._readableState.length=L.length,this};const Ge=1073741824;function Rn(c){if(c>Ge)throw new we("size","<= 1GiB",c);return c--,c|=c>>>1,c|=c>>>2,c|=c>>>4,c|=c>>>8,c|=c>>>16,c++,c}function f(c,h){return c<=0||h.length===0&&h.ended?0:(h.state&D)!==0?1:n(c)?h.flowing&&h.length?h.buffer.first().length:h.length:c<=h.length?c:h.ended?h.length:0}O.prototype.read=function(c){T("read",c),c===void 0?c=NaN:r(c)||(c=i(c,10));const h=this._readableState,j=c;if(c>h.highWaterMark&&(h.highWaterMark=Rn(c)),c!==0&&(h.state&=-129),c===0&&h.needReadable&&((h.highWaterMark!==0?h.length>=h.highWaterMark:h.length>0)||h.ended))return T("read: emitReadable",h.length,h.ended),h.length===0&&h.ended?An(this):o(this),null;if(c=f(c,h),c===0&&h.ended)return h.length===0&&An(this),null;let L=(h.state&Ke)!==0;if(T("need readable",L),(h.length===0||h.length-c<h.highWaterMark)&&(L=!0,T("length less than watermark",L)),h.ended||h.reading||h.destroyed||h.errored||!h.constructed)L=!1,T("reading, ended or constructing",L);else if(L){T("do read"),h.state|=_e|tt,h.length===0&&(h.state|=Ke);try{this._read(h.highWaterMark)}catch(me){ce(this,me)}h.state&=-33,h.reading||(c=f(j,h))}let k;return c>0?k=Gs(c,h):k=null,k===null?(h.needReadable=h.length<=h.highWaterMark,c=0):(h.length-=c,h.multiAwaitDrain?h.awaitDrainWriters.clear():h.awaitDrainWriters=null),h.length===0&&(h.ended||(h.needReadable=!0),j!==c&&h.ended&&An(this)),k!==null&&!h.errorEmitted&&!h.closeEmitted&&(h.dataEmitted=!0,this.emit("data",k)),k};function s(c,h){if(T("onEofChunk"),!h.ended){if(h.decoder){const j=h.decoder.end();j&&j.length&&(h.buffer.push(j),h.length+=h.objectMode?1:j.length)}h.ended=!0,h.sync?o(c):(h.needReadable=!1,h.emittedReadable=!0,d(c))}}function o(c){const h=c._readableState;T("emitReadable",h.needReadable,h.emittedReadable),h.needReadable=!1,h.emittedReadable||(T("emitReadable",h.flowing),h.emittedReadable=!0,t.nextTick(d,c))}function d(c){const h=c._readableState;T("emitReadable_",h.destroyed,h.length,h.ended),!h.destroyed&&!h.errored&&(h.length||h.ended)&&(c.emit("readable"),h.emittedReadable=!1),h.needReadable=!h.flowing&&!h.ended&&h.length<=h.highWaterMark,V(c)}function b(c,h){!h.readingMore&&h.constructed&&(h.readingMore=!0,t.nextTick(E,c,h))}function E(c,h){for(;!h.reading&&!h.ended&&(h.length<h.highWaterMark||h.flowing&&h.length===0);){const j=h.length;if(T("maybeReadMore read 0"),c.read(0),j===h.length)break}h.readingMore=!1}O.prototype._read=function(c){throw new ge("_read()")},O.prototype.pipe=function(c,h){const j=this,L=this._readableState;L.pipes.length===1&&(L.multiAwaitDrain||(L.multiAwaitDrain=!0,L.awaitDrainWriters=new _(L.awaitDrainWriters?[L.awaitDrainWriters]:[]))),L.pipes.push(c),T("pipe count=%d opts=%j",L.pipes.length,h);const me=(!h||h.end!==!1)&&c!==t.stdout&&c!==t.stderr?qs:Yt;L.endEmitted?t.nextTick(me):j.once("end",me),c.on("unpipe",$e);function $e(yt,Xe){T("onunpipe"),yt===j&&Xe&&Xe.hasUnpiped===!1&&(Xe.hasUnpiped=!0,Qu())}function qs(){T("onend"),c.end()}let bt,Hs=!1;function Qu(){T("cleanup"),c.removeListener("close",Nn),c.removeListener("finish",Pn),bt&&c.removeListener("drain",bt),c.removeListener("error",vn),c.removeListener("unpipe",$e),j.removeListener("end",qs),j.removeListener("end",Yt),j.removeListener("data",Vs),Hs=!0,bt&&L.awaitDrainWriters&&(!c._writableState||c._writableState.needDrain)&&bt()}function Qs(){Hs||(L.pipes.length===1&&L.pipes[0]===c?(T("false write response, pause",0),L.awaitDrainWriters=c,L.multiAwaitDrain=!1):L.pipes.length>1&&L.pipes.includes(c)&&(T("false write response, pause",L.awaitDrainWriters.size),L.awaitDrainWriters.add(c)),j.pause()),bt||(bt=v(j,c),c.on("drain",bt))}j.on("data",Vs);function Vs(yt){T("ondata");const Xe=c.write(yt);T("dest.write",Xe),Xe===!1&&Qs()}function vn(yt){if(T("onerror",yt),Yt(),c.removeListener("error",vn),c.listenerCount("error")===0){const Xe=c._writableState||c._readableState;Xe&&!Xe.errorEmitted?ce(c,yt):c.emit("error",yt)}}w(c,"error",vn);function Nn(){c.removeListener("finish",Pn),Yt()}c.once("close",Nn);function Pn(){T("onfinish"),c.removeListener("close",Nn),Yt()}c.once("finish",Pn);function Yt(){T("unpipe"),j.unpipe(c)}return c.emit("pipe",j),c.writableNeedDrain===!0?Qs():L.flowing||(T("pipe resume"),j.resume()),c};function v(c,h){return function(){const L=c._readableState;L.awaitDrainWriters===h?(T("pipeOnDrain",1),L.awaitDrainWriters=null):L.multiAwaitDrain&&(T("pipeOnDrain",L.awaitDrainWriters.size),L.awaitDrainWriters.delete(h)),(!L.awaitDrainWriters||L.awaitDrainWriters.size===0)&&c.listenerCount("data")&&c.resume()}}O.prototype.unpipe=function(c){const h=this._readableState,j={hasUnpiped:!1};if(h.pipes.length===0)return this;if(!c){const k=h.pipes;h.pipes=[],this.pause();for(let me=0;me<k.length;me++)k[me].emit("unpipe",this,{hasUnpiped:!1});return this}const L=e(h.pipes,c);return L===-1?this:(h.pipes.splice(L,1),h.pipes.length===0&&this.pause(),c.emit("unpipe",this,j),this)},O.prototype.on=function(c,h){const j=R.prototype.on.call(this,c,h),L=this._readableState;return c==="data"?(L.readableListening=this.listenerCount("readable")>0,L.flowing!==!1&&this.resume()):c==="readable"&&!L.endEmitted&&!L.readableListening&&(L.readableListening=L.needReadable=!0,L.flowing=!1,L.emittedReadable=!1,T("on readable",L.length,L.reading),L.length?o(this):L.reading||t.nextTick(ie,this)),j},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(c,h){const j=R.prototype.removeListener.call(this,c,h);return c==="readable"&&t.nextTick(W,this),j},O.prototype.off=O.prototype.removeListener,O.prototype.removeAllListeners=function(c){const h=R.prototype.removeAllListeners.apply(this,arguments);return(c==="readable"||c===void 0)&&t.nextTick(W,this),h};function W(c){const h=c._readableState;h.readableListening=c.listenerCount("readable")>0,h.resumeScheduled&&h[H]===!1?h.flowing=!0:c.listenerCount("data")>0?c.resume():h.readableListening||(h.flowing=null)}function ie(c){T("readable nexttick read 0"),c.read(0)}O.prototype.resume=function(){const c=this._readableState;return c.flowing||(T("resume"),c.flowing=!c.readableListening,J(this,c)),c[H]=!1,this};function J(c,h){h.resumeScheduled||(h.resumeScheduled=!0,t.nextTick(se,c,h))}function se(c,h){T("resume",h.reading),h.reading||c.read(0),h.resumeScheduled=!1,c.emit("resume"),V(c),h.flowing&&!h.reading&&c.read(0)}O.prototype.pause=function(){return T("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(T("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[H]=!0,this};function V(c){const h=c._readableState;for(T("flow",h.flowing);h.flowing&&c.read()!==null;);}O.prototype.wrap=function(c){let h=!1;c.on("data",L=>{!this.push(L)&&c.pause&&(h=!0,c.pause())}),c.on("end",()=>{this.push(null)}),c.on("error",L=>{ce(this,L)}),c.on("close",()=>{this.destroy()}),c.on("destroy",()=>{this.destroy()}),this._read=()=>{h&&c.resume&&(h=!1,c.resume())};const j=l(c);for(let L=1;L<j.length;L++){const k=j[L];this[k]===void 0&&typeof c[k]=="function"&&(this[k]=c[k].bind(c))}return this},O.prototype[x]=function(){return Ws(this)},O.prototype.iterator=function(c){return c!==void 0&&G(c,"options"),Ws(this,c)};function Ws(c,h){typeof c.read!="function"&&(c=O.wrap(c,{objectMode:!0}));const j=zu(c,h);return j.stream=c,j}async function*zu(c,h){let j=re;function L($e){this===c?(j(),j=re):j=$e}c.on("readable",L);let k;const me=B(c,{writable:!1},$e=>{k=$e?ee(k,$e):null,j(),j=re});try{for(;;){const $e=c.destroyed?null:c.read();if($e!==null)yield $e;else{if(k)throw k;if(k===null)return;await new p(L)}}}catch($e){throw k=ee(k,$e),k}finally{(k||(h==null?void 0:h.destroyOnReturn)!==!1)&&(k===void 0||c._readableState.autoDestroy)?U.destroyer(c,null):(c.off("readable",L),me())}}a(O.prototype,{readable:{__proto__:null,get(){const c=this._readableState;return!!c&&c.readable!==!1&&!c.destroyed&&!c.errorEmitted&&!c.endEmitted},set(c){this._readableState&&(this._readableState.readable=!!c)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(c){this._readableState&&(this._readableState.flowing=c)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(c){this._readableState&&(this._readableState.destroyed=c)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),a(Re.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[H]!==!1},set(c){this[H]=!!c}}}),O._fromList=Gs;function Gs(c,h){if(h.length===0)return null;let j;return h.objectMode?j=h.buffer.shift():!c||c>=h.length?(h.decoder?j=h.buffer.join(""):h.buffer.length===1?j=h.buffer.first():j=h.buffer.concat(h.length),h.buffer.clear()):j=h.buffer.consume(c,h.decoder),j}function An(c){const h=c._readableState;T("endReadable",h.endEmitted),h.endEmitted||(h.ended=!0,t.nextTick(qu,h,c))}function qu(c,h){if(T("endReadableNT",c.endEmitted,c.length),!c.errored&&!c.closeEmitted&&!c.endEmitted&&c.length===0){if(c.endEmitted=!0,h.emit("end"),h.writable&&h.allowHalfOpen===!1)t.nextTick(Hu,h);else if(c.autoDestroy){const j=h._writableState;(!j||j.autoDestroy&&(j.finished||j.writable===!1))&&h.destroy()}}}function Hu(c){c.writable&&!c.writableEnded&&!c.destroyed&&c.end()}O.from=function(c,h){return fe(O,c,h)};let Tn;function zs(){return Tn===void 0&&(Tn={}),Tn}return O.fromWeb=function(c,h){return zs().newStreamReadableFromReadableStream(c,h)},O.toWeb=function(c,h){return zs().newReadableStreamFromStreamReadable(c,h)},O.wrap=function(c,h){var j,L;return new O({objectMode:(j=(L=c.readableObjectMode)!==null&&L!==void 0?L:c.objectMode)!==null&&j!==void 0?j:!0,...h,destroy(k,me){U.destroyer(c,k),me(k)}}).wrap(c)},tn}var rn,os;function nn(){if(os)return rn;os=1;const t=ut,{ArrayPrototypeSlice:e,Error:r,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:i,ObjectDefineProperties:a,ObjectSetPrototypeOf:l,StringPrototypeToLowerCase:u,Symbol:p,SymbolHasInstance:_}=oe;rn=G,G.WritableState=P;const{EventEmitter:y}=or,x=Yr.Stream,{Buffer:I}=Fe,S=Tt,{addAbortSignal:R}=dr,{getHighWaterMark:w,getDefaultHighWaterMark:A}=pr,{ERR_INVALID_ARG_TYPE:$,ERR_METHOD_NOT_IMPLEMENTED:B,ERR_MULTIPLE_CALLBACK:T,ERR_STREAM_CANNOT_PIPE:q,ERR_STREAM_DESTROYED:U,ERR_STREAM_ALREADY_FINISHED:ae,ERR_STREAM_NULL_VALUES:Ee,ERR_STREAM_WRITE_AFTER_END:ee,ERR_UNKNOWN_ENCODING:le}=xe.codes,{errorOrDestroy:ge}=S;l(G.prototype,x.prototype),l(G,x);function we(){}const Q=p("kOnFinished");function P(g,m,N){typeof N!="boolean"&&(N=m instanceof Qe()),this.objectMode=!!(g&&g.objectMode),N&&(this.objectMode=this.objectMode||!!(g&&g.writableObjectMode)),this.highWaterMark=g?w(this,g,"writableHighWaterMark",N):A(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const C=!!(g&&g.decodeStrings===!1);this.decodeStrings=!C,this.defaultEncoding=g&&g.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=ce.bind(void 0,m),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,K(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!g||g.emitClose!==!1,this.autoDestroy=!g||g.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Q]=[]}function K(g){g.buffered=[],g.bufferedIndex=0,g.allBuffers=!0,g.allNoop=!0}P.prototype.getBuffer=function(){return e(this.buffered,this.bufferedIndex)},i(P.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function G(g){const m=this instanceof Qe();if(!m&&!n(G,this))return new G(g);this._writableState=new P(g,this,m),g&&(typeof g.write=="function"&&(this._write=g.write),typeof g.writev=="function"&&(this._writev=g.writev),typeof g.destroy=="function"&&(this._destroy=g.destroy),typeof g.final=="function"&&(this._final=g.final),typeof g.construct=="function"&&(this._construct=g.construct),g.signal&&R(g.signal,this)),x.call(this,g),S.construct(this,()=>{const N=this._writableState;N.writing||_e(this,N),je(this,N)})}i(G,_,{__proto__:null,value:function(g){return n(this,g)?!0:this!==G?!1:g&&g._writableState instanceof P}}),G.prototype.pipe=function(){ge(this,new q)};function H(g,m,N,C){const F=g._writableState;if(typeof N=="function")C=N,N=F.defaultEncoding;else{if(!N)N=F.defaultEncoding;else if(N!=="buffer"&&!I.isEncoding(N))throw new le(N);typeof C!="function"&&(C=we)}if(m===null)throw new Ee;if(!F.objectMode)if(typeof m=="string")F.decodeStrings!==!1&&(m=I.from(m,N),N="buffer");else if(m instanceof I)N="buffer";else if(x._isUint8Array(m))m=x._uint8ArrayToBuffer(m),N="buffer";else throw new $("chunk",["string","Buffer","Uint8Array"],m);let Z;return F.ending?Z=new ee:F.destroyed&&(Z=new U("write")),Z?(t.nextTick(C,Z),ge(g,Z,!0),Z):(F.pendingcb++,ue(g,F,m,N,C))}G.prototype.write=function(g,m,N){return H(this,g,m,N)===!0},G.prototype.cork=function(){this._writableState.corked++},G.prototype.uncork=function(){const g=this._writableState;g.corked&&(g.corked--,g.writing||_e(this,g))},G.prototype.setDefaultEncoding=function(m){if(typeof m=="string"&&(m=u(m)),!I.isEncoding(m))throw new le(m);return this._writableState.defaultEncoding=m,this};function ue(g,m,N,C,F){const Z=m.objectMode?1:N.length;m.length+=Z;const te=m.length<m.highWaterMark;return te||(m.needDrain=!0),m.writing||m.corked||m.errored||!m.constructed?(m.buffered.push({chunk:N,encoding:C,callback:F}),m.allBuffers&&C!=="buffer"&&(m.allBuffers=!1),m.allNoop&&F!==we&&(m.allNoop=!1)):(m.writelen=Z,m.writecb=F,m.writing=!0,m.sync=!0,g._write(N,C,m.onwrite),m.sync=!1),te&&!m.errored&&!m.destroyed}function fe(g,m,N,C,F,Z,te){m.writelen=C,m.writecb=te,m.writing=!0,m.sync=!0,m.destroyed?m.onwrite(new U("write")):N?g._writev(F,m.onwrite):g._write(F,Z,m.onwrite),m.sync=!1}function re(g,m,N,C){--m.pendingcb,C(N),M(m),ge(g,N)}function ce(g,m){const N=g._writableState,C=N.sync,F=N.writecb;if(typeof F!="function"){ge(g,new T);return}N.writing=!1,N.writecb=null,N.length-=N.writelen,N.writelen=0,m?(m.stack,N.errored||(N.errored=m),g._readableState&&!g._readableState.errored&&(g._readableState.errored=m),C?t.nextTick(re,g,N,m,F):re(g,N,m,F)):(N.buffered.length>N.bufferedIndex&&_e(g,N),C?N.afterWriteTickInfo!==null&&N.afterWriteTickInfo.cb===F?N.afterWriteTickInfo.count++:(N.afterWriteTickInfo={count:1,cb:F,stream:g,state:N},t.nextTick(D,N.afterWriteTickInfo)):ne(g,N,1,F))}function D({stream:g,state:m,count:N,cb:C}){return m.afterWriteTickInfo=null,ne(g,m,N,C)}function ne(g,m,N,C){for(!m.ending&&!g.destroyed&&m.length===0&&m.needDrain&&(m.needDrain=!1,g.emit("drain"));N-- >0;)m.pendingcb--,C();m.destroyed&&M(m),je(g,m)}function M(g){if(g.writing)return;for(let F=g.bufferedIndex;F<g.buffered.length;++F){var m;const{chunk:Z,callback:te}=g.buffered[F],Y=g.objectMode?1:Z.length;g.length-=Y,te((m=g.errored)!==null&&m!==void 0?m:new U("write"))}const N=g[Q].splice(0);for(let F=0;F<N.length;F++){var C;N[F]((C=g.errored)!==null&&C!==void 0?C:new U("end"))}K(g)}function _e(g,m){if(m.corked||m.bufferProcessing||m.destroyed||!m.constructed)return;const{buffered:N,bufferedIndex:C,objectMode:F}=m,Z=N.length-C;if(!Z)return;let te=C;if(m.bufferProcessing=!0,Z>1&&g._writev){m.pendingcb-=Z-1;const Y=m.allNoop?we:O=>{for(let Le=te;Le<N.length;++Le)N[Le].callback(O)},Re=m.allNoop&&te===0?N:e(N,te);Re.allBuffers=m.allBuffers,fe(g,m,!0,m.length,Re,"",Y),K(m)}else{do{const{chunk:Y,encoding:Re,callback:O}=N[te];N[te++]=null;const Le=F?1:Y.length;fe(g,m,!1,Le,Y,Re,O)}while(te<N.length&&!m.writing);te===N.length?K(m):te>256?(N.splice(0,te),m.bufferedIndex=0):m.bufferedIndex=te}m.bufferProcessing=!1}G.prototype._write=function(g,m,N){if(this._writev)this._writev([{chunk:g,encoding:m}],N);else throw new B("_write()")},G.prototype._writev=null,G.prototype.end=function(g,m,N){const C=this._writableState;typeof g=="function"?(N=g,g=null,m=null):typeof m=="function"&&(N=m,m=null);let F;if(g!=null){const Z=H(this,g,m);Z instanceof r&&(F=Z)}return C.corked&&(C.corked=1,this.uncork()),F||(!C.errored&&!C.ending?(C.ending=!0,je(this,C,!0),C.ended=!0):C.finished?F=new ae("end"):C.destroyed&&(F=new U("end"))),typeof N=="function"&&(F||C.finished?t.nextTick(N,F):C[Q].push(N)),this};function Te(g){return g.ending&&!g.destroyed&&g.constructed&&g.length===0&&!g.errored&&g.buffered.length===0&&!g.finished&&!g.writing&&!g.errorEmitted&&!g.closeEmitted}function tt(g,m){let N=!1;function C(F){if(N){ge(g,F??T());return}if(N=!0,m.pendingcb--,F){const Z=m[Q].splice(0);for(let te=0;te<Z.length;te++)Z[te](F);ge(g,F,m.sync)}else Te(m)&&(m.prefinished=!0,g.emit("prefinish"),m.pendingcb++,t.nextTick(Ye,g,m))}m.sync=!0,m.pendingcb++;try{g._final(C)}catch(F){C(F)}m.sync=!1}function Ke(g,m){!m.prefinished&&!m.finalCalled&&(typeof g._final=="function"&&!m.destroyed?(m.finalCalled=!0,tt(g,m)):(m.prefinished=!0,g.emit("prefinish")))}function je(g,m,N){Te(m)&&(Ke(g,m),m.pendingcb===0&&(N?(m.pendingcb++,t.nextTick((C,F)=>{Te(F)?Ye(C,F):F.pendingcb--},g,m)):Te(m)&&(m.pendingcb++,Ye(g,m))))}function Ye(g,m){m.pendingcb--,m.finished=!0;const N=m[Q].splice(0);for(let C=0;C<N.length;C++)N[C]();if(g.emit("finish"),m.autoDestroy){const C=g._readableState;(!C||C.autoDestroy&&(C.endEmitted||C.readable===!1))&&g.destroy()}}a(G.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(g){this._writableState&&(this._writableState.destroyed=g)}},writable:{__proto__:null,get(){const g=this._writableState;return!!g&&g.writable!==!1&&!g.destroyed&&!g.errored&&!g.ending&&!g.ended},set(g){this._writableState&&(this._writableState.writable=!!g)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){const g=this._writableState;return g?!g.destroyed&&!g.ending&&g.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});const Pt=S.destroy;G.prototype.destroy=function(g,m){const N=this._writableState;return!N.destroyed&&(N.bufferedIndex<N.buffered.length||N[Q].length)&&t.nextTick(M,N),Pt.call(this,g,m),this},G.prototype._undestroy=S.undestroy,G.prototype._destroy=function(g,m){m(g)},G.prototype[y.captureRejectionSymbol]=function(g){this.destroy(g)};let _t;function rt(){return _t===void 0&&(_t={}),_t}return G.fromWeb=function(g,m){return rt().newStreamWritableFromWritableStream(g,m)},G.toWeb=function(g){return rt().newWritableStreamFromStreamWritable(g)},rn}var sn,as;function Rl(){if(as)return sn;as=1;const t=ut,e=Fe,{isReadable:r,isWritable:n,isIterable:i,isNodeStream:a,isReadableNodeStream:l,isWritableNodeStream:u,isDuplexNodeStream:p,isReadableStream:_,isWritableStream:y}=He,x=Je,{AbortError:I,codes:{ERR_INVALID_ARG_TYPE:S,ERR_INVALID_RETURN_VALUE:R}}=xe,{destroyer:w}=Tt,A=Qe(),$=_r(),B=nn(),{createDeferredPromise:T}=Se,q=is,U=globalThis.Blob||e.Blob,ae=typeof U<"u"?function(P){return P instanceof U}:function(P){return!1},Ee=globalThis.AbortController||Ot().AbortController,{FunctionPrototypeCall:ee}=oe;class le extends A{constructor(P){super(P),(P==null?void 0:P.readable)===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),(P==null?void 0:P.writable)===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}sn=function Q(P,K){if(p(P))return P;if(l(P))return we({readable:P});if(u(P))return we({writable:P});if(a(P))return we({writable:!1,readable:!1});if(_(P))return we({readable:$.fromWeb(P)});if(y(P))return we({writable:B.fromWeb(P)});if(typeof P=="function"){const{value:H,write:ue,final:fe,destroy:re}=ge(P);if(i(H))return q(le,H,{objectMode:!0,write:ue,final:fe,destroy:re});const ce=H==null?void 0:H.then;if(typeof ce=="function"){let D;const ne=ee(ce,H,M=>{if(M!=null)throw new R("nully","body",M)},M=>{w(D,M)});return D=new le({objectMode:!0,readable:!1,write:ue,final(M){fe(async()=>{try{await ne,t.nextTick(M,null)}catch(_e){t.nextTick(M,_e)}})},destroy:re})}throw new R("Iterable, AsyncIterable or AsyncFunction",K,H)}if(ae(P))return Q(P.arrayBuffer());if(i(P))return q(le,P,{objectMode:!0,writable:!1});if(_(P==null?void 0:P.readable)&&y(P==null?void 0:P.writable))return le.fromWeb(P);if(typeof(P==null?void 0:P.writable)=="object"||typeof(P==null?void 0:P.readable)=="object"){const H=P!=null&&P.readable?l(P==null?void 0:P.readable)?P==null?void 0:P.readable:Q(P.readable):void 0,ue=P!=null&&P.writable?u(P==null?void 0:P.writable)?P==null?void 0:P.writable:Q(P.writable):void 0;return we({readable:H,writable:ue})}const G=P==null?void 0:P.then;if(typeof G=="function"){let H;return ee(G,P,ue=>{ue!=null&&H.push(ue),H.push(null)},ue=>{w(H,ue)}),H=new le({objectMode:!0,writable:!1,read(){}})}throw new S(K,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],P)};function ge(Q){let{promise:P,resolve:K}=T();const G=new Ee,H=G.signal;return{value:Q(async function*(){for(;;){const fe=P;P=null;const{chunk:re,done:ce,cb:D}=await fe;if(t.nextTick(D),ce)return;if(H.aborted)throw new I(void 0,{cause:H.reason});({promise:P,resolve:K}=T()),yield re}}(),{signal:H}),write(fe,re,ce){const D=K;K=null,D({chunk:fe,done:!1,cb:ce})},final(fe){const re=K;K=null,re({done:!0,cb:fe})},destroy(fe,re){G.abort(),re(fe)}}}function we(Q){const P=Q.readable&&typeof Q.readable.read!="function"?$.wrap(Q.readable):Q.readable,K=Q.writable;let G=!!r(P),H=!!n(K),ue,fe,re,ce,D;function ne(M){const _e=ce;ce=null,_e?_e(M):M&&D.destroy(M)}return D=new le({readableObjectMode:!!(P!=null&&P.readableObjectMode),writableObjectMode:!!(K!=null&&K.writableObjectMode),readable:G,writable:H}),H&&(x(K,M=>{H=!1,M&&w(P,M),ne(M)}),D._write=function(M,_e,Te){K.write(M,_e)?Te():ue=Te},D._final=function(M){K.end(),fe=M},K.on("drain",function(){if(ue){const M=ue;ue=null,M()}}),K.on("finish",function(){if(fe){const M=fe;fe=null,M()}})),G&&(x(P,M=>{G=!1,M&&w(P,M),ne(M)}),P.on("readable",function(){if(re){const M=re;re=null,M()}}),P.on("end",function(){D.push(null)}),D._read=function(){for(;;){const M=P.read();if(M===null){re=D._read;return}if(!D.push(M))return}}),D._destroy=function(M,_e){!M&&ce!==null&&(M=new I),re=null,ue=null,fe=null,ce===null?_e(M):(ce=_e,w(K,M),w(P,M))},D}return sn}var on,ls;function Qe(){if(ls)return on;ls=1;const{ObjectDefineProperties:t,ObjectGetOwnPropertyDescriptor:e,ObjectKeys:r,ObjectSetPrototypeOf:n}=oe;on=l;const i=_r(),a=nn();n(l.prototype,i.prototype),n(l,i);{const y=r(a.prototype);for(let x=0;x<y.length;x++){const I=y[x];l.prototype[I]||(l.prototype[I]=a.prototype[I])}}function l(y){if(!(this instanceof l))return new l(y);i.call(this,y),a.call(this,y),y?(this.allowHalfOpen=y.allowHalfOpen!==!1,y.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),y.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}t(l.prototype,{writable:{__proto__:null,...e(a.prototype,"writable")},writableHighWaterMark:{__proto__:null,...e(a.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...e(a.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...e(a.prototype,"writableBuffer")},writableLength:{__proto__:null,...e(a.prototype,"writableLength")},writableFinished:{__proto__:null,...e(a.prototype,"writableFinished")},writableCorked:{__proto__:null,...e(a.prototype,"writableCorked")},writableEnded:{__proto__:null,...e(a.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...e(a.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(y){this._readableState&&this._writableState&&(this._readableState.destroyed=y,this._writableState.destroyed=y)}}});let u;function p(){return u===void 0&&(u={}),u}l.fromWeb=function(y,x){return p().newStreamDuplexFromReadableWritablePair(y,x)},l.toWeb=function(y){return p().newReadableWritablePairFromDuplex(y)};let _;return l.from=function(y){return _||(_=Rl()),_(y,"body")},on}const{ObjectSetPrototypeOf:us,Symbol:Al}=oe;var fs=Ve;const{ERR_METHOD_NOT_IMPLEMENTED:Tl}=xe.codes,an=Qe(),{getHighWaterMark:vl}=pr;us(Ve.prototype,an.prototype),us(Ve,an);const Ut=Al("kCallback");function Ve(t){if(!(this instanceof Ve))return new Ve(t);const e=t?vl(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),an.call(this,t),this._readableState.sync=!1,this[Ut]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",Nl)}function ln(t){typeof this._flush=="function"&&!this.destroyed?this._flush((e,r)=>{if(e){t?t(e):this.destroy(e);return}r!=null&&this.push(r),this.push(null),t&&t()}):(this.push(null),t&&t())}function Nl(){this._final!==ln&&ln.call(this)}Ve.prototype._final=ln,Ve.prototype._transform=function(t,e,r){throw new Tl("_transform()")},Ve.prototype._write=function(t,e,r){const n=this._readableState,i=this._writableState,a=n.length;this._transform(t,e,(l,u)=>{if(l){r(l);return}u!=null&&this.push(u),i.ended||a===n.length||n.length<n.highWaterMark?r():this[Ut]=r})},Ve.prototype._read=function(){if(this[Ut]){const t=this[Ut];this[Ut]=null,t()}};const{ObjectSetPrototypeOf:cs}=oe;var ds=vt;const un=fs;cs(vt.prototype,un.prototype),cs(vt,un);function vt(t){if(!(this instanceof vt))return new vt(t);un.call(this,t)}vt.prototype._transform=function(t,e,r){r(null,t)};const Wt=ut,{ArrayIsArray:Pl,Promise:jl,SymbolAsyncIterator:Ll,SymbolDispose:$l}=oe,br=Je,{once:Bl}=Se,Fl=Tt,hs=Qe(),{aggregateTwoErrors:kl,codes:{ERR_INVALID_ARG_TYPE:fn,ERR_INVALID_RETURN_VALUE:cn,ERR_MISSING_ARGS:Cl,ERR_STREAM_DESTROYED:Ol,ERR_STREAM_PREMATURE_CLOSE:Ml},AbortError:Dl}=xe,{validateFunction:Ul,validateAbortSignal:Wl}=Mt,{isIterable:ct,isReadable:dn,isReadableNodeStream:yr,isNodeStream:ps,isTransformStream:Nt,isWebStream:Gl,isReadableStream:hn,isReadableFinished:zl}=He,ql=globalThis.AbortController||Ot().AbortController;let pn,_n,bn;function _s(t,e,r){let n=!1;t.on("close",()=>{n=!0});const i=br(t,{readable:e,writable:r},a=>{n=!a});return{destroy:a=>{n||(n=!0,Fl.destroyer(t,a||new Ol("pipe")))},cleanup:i}}function Hl(t){return Ul(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function yn(t){if(ct(t))return t;if(yr(t))return Ql(t);throw new fn("val",["Readable","Iterable","AsyncIterable"],t)}async function*Ql(t){_n||(_n=_r()),yield*_n.prototype[Ll].call(t)}async function gr(t,e,r,{end:n}){let i,a=null;const l=_=>{if(_&&(i=_),a){const y=a;a=null,y()}},u=()=>new jl((_,y)=>{i?y(i):a=()=>{i?y(i):_()}});e.on("drain",l);const p=br(e,{readable:!1},l);try{e.writableNeedDrain&&await u();for await(const _ of t)e.write(_)||await u();n&&(e.end(),await u()),r()}catch(_){r(i!==_?kl(i,_):_)}finally{p(),e.off("drain",l)}}async function gn(t,e,r,{end:n}){Nt(e)&&(e=e.writable);const i=e.getWriter();try{for await(const a of t)await i.ready,i.write(a).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(a){try{await i.abort(a),r(a)}catch(l){r(l)}}}function Vl(...t){return bs(t,Bl(Hl(t)))}function bs(t,e,r){if(t.length===1&&Pl(t[0])&&(t=t[0]),t.length<2)throw new Cl("streams");const n=new ql,i=n.signal,a=r==null?void 0:r.signal,l=[];Wl(a,"options.signal");function u(){R(new Dl)}bn=bn||Se.addAbortListener;let p;a&&(p=bn(a,u));let _,y;const x=[];let I=0;function S(B){R(B,--I===0)}function R(B,T){var q;if(B&&(!_||_.code==="ERR_STREAM_PREMATURE_CLOSE")&&(_=B),!(!_&&!T)){for(;x.length;)x.shift()(_);(q=p)===null||q===void 0||q[$l](),n.abort(),T&&(_||l.forEach(U=>U()),Wt.nextTick(e,_,y))}}let w;for(let B=0;B<t.length;B++){const T=t[B],q=B<t.length-1,U=B>0,ae=q||(r==null?void 0:r.end)!==!1,Ee=B===t.length-1;if(ps(T)){let ee=function(le){le&&le.name!=="AbortError"&&le.code!=="ERR_STREAM_PREMATURE_CLOSE"&&S(le)};if(ae){const{destroy:le,cleanup:ge}=_s(T,q,U);x.push(le),dn(T)&&Ee&&l.push(ge)}T.on("error",ee),dn(T)&&Ee&&l.push(()=>{T.removeListener("error",ee)})}if(B===0)if(typeof T=="function"){if(w=T({signal:i}),!ct(w))throw new cn("Iterable, AsyncIterable or Stream","source",w)}else ct(T)||yr(T)||Nt(T)?w=T:w=hs.from(T);else if(typeof T=="function"){if(Nt(w)){var A;w=yn((A=w)===null||A===void 0?void 0:A.readable)}else w=yn(w);if(w=T(w,{signal:i}),q){if(!ct(w,!0))throw new cn("AsyncIterable",`transform[${B-1}]`,w)}else{var $;pn||(pn=ds);const ee=new pn({objectMode:!0}),le=($=w)===null||$===void 0?void 0:$.then;if(typeof le=="function")I++,le.call(w,Q=>{y=Q,Q!=null&&ee.write(Q),ae&&ee.end(),Wt.nextTick(S)},Q=>{ee.destroy(Q),Wt.nextTick(S,Q)});else if(ct(w,!0))I++,gr(w,ee,S,{end:ae});else if(hn(w)||Nt(w)){const Q=w.readable||w;I++,gr(Q,ee,S,{end:ae})}else throw new cn("AsyncIterable or Promise","destination",w);w=ee;const{destroy:ge,cleanup:we}=_s(w,!1,!0);x.push(ge),Ee&&l.push(we)}}else if(ps(T)){if(yr(w)){I+=2;const ee=Kl(w,T,S,{end:ae});dn(T)&&Ee&&l.push(ee)}else if(Nt(w)||hn(w)){const ee=w.readable||w;I++,gr(ee,T,S,{end:ae})}else if(ct(w))I++,gr(w,T,S,{end:ae});else throw new fn("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],w);w=T}else if(Gl(T)){if(yr(w))I++,gn(yn(w),T,S,{end:ae});else if(hn(w)||ct(w))I++,gn(w,T,S,{end:ae});else if(Nt(w))I++,gn(w.readable,T,S,{end:ae});else throw new fn("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],w);w=T}else w=hs.from(T)}return(i!=null&&i.aborted||a!=null&&a.aborted)&&Wt.nextTick(u),w}function Kl(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new Ml)}),t.pipe(e,{end:!1}),n){let a=function(){i=!0,e.end()};zl(t)?Wt.nextTick(a):t.once("end",a)}else r();return br(t,{readable:!0,writable:!1},a=>{const l=t._readableState;a&&a.code==="ERR_STREAM_PREMATURE_CLOSE"&&l&&l.ended&&!l.errored&&!l.errorEmitted?t.once("end",r).once("error",r):r(a)}),br(e,{readable:!1,writable:!0},r)}var wn={pipelineImpl:bs,pipeline:Vl};const{pipeline:Yl}=wn,wr=Qe(),{destroyer:Xl}=Tt,{isNodeStream:mr,isReadable:ys,isWritable:gs,isWebStream:mn,isTransformStream:dt,isWritableStream:ws,isReadableStream:ms}=He,{AbortError:Zl,codes:{ERR_INVALID_ARG_VALUE:xs,ERR_MISSING_ARGS:Jl}}=xe,eu=Je;var Es=function(...e){if(e.length===0)throw new Jl("streams");if(e.length===1)return wr.from(e[0]);const r=[...e];if(typeof e[0]=="function"&&(e[0]=wr.from(e[0])),typeof e[e.length-1]=="function"){const S=e.length-1;e[S]=wr.from(e[S])}for(let S=0;S<e.length;++S)if(!(!mr(e[S])&&!mn(e[S]))){if(S<e.length-1&&!(ys(e[S])||ms(e[S])||dt(e[S])))throw new xs(`streams[${S}]`,r[S],"must be readable");if(S>0&&!(gs(e[S])||ws(e[S])||dt(e[S])))throw new xs(`streams[${S}]`,r[S],"must be writable")}let n,i,a,l,u;function p(S){const R=l;l=null,R?R(S):S?u.destroy(S):!I&&!x&&u.destroy()}const _=e[0],y=Yl(e,p),x=!!(gs(_)||ws(_)||dt(_)),I=!!(ys(y)||ms(y)||dt(y));if(u=new wr({writableObjectMode:!!(_!=null&&_.writableObjectMode),readableObjectMode:!!(y!=null&&y.readableObjectMode),writable:x,readable:I}),x){if(mr(_))u._write=function(R,w,A){_.write(R,w)?A():n=A},u._final=function(R){_.end(),i=R},_.on("drain",function(){if(n){const R=n;n=null,R()}});else if(mn(_)){const w=(dt(_)?_.writable:_).getWriter();u._write=async function(A,$,B){try{await w.ready,w.write(A).catch(()=>{}),B()}catch(T){B(T)}},u._final=async function(A){try{await w.ready,w.close().catch(()=>{}),i=A}catch($){A($)}}}const S=dt(y)?y.readable:y;eu(S,()=>{if(i){const R=i;i=null,R()}})}if(I){if(mr(y))y.on("readable",function(){if(a){const S=a;a=null,S()}}),y.on("end",function(){u.push(null)}),u._read=function(){for(;;){const S=y.read();if(S===null){a=u._read;return}if(!u.push(S))return}};else if(mn(y)){const R=(dt(y)?y.readable:y).getReader();u._read=async function(){for(;;)try{const{value:w,done:A}=await R.read();if(!u.push(w))return;if(A){u.push(null);return}}catch{return}}}}return u._destroy=function(S,R){!S&&l!==null&&(S=new Zl),a=null,n=null,i=null,l===null?R(S):(l=R,mr(y)&&Xl(y,S))},u};const tu=globalThis.AbortController||Ot().AbortController,{codes:{ERR_INVALID_ARG_VALUE:ru,ERR_INVALID_ARG_TYPE:Gt,ERR_MISSING_ARGS:nu,ERR_OUT_OF_RANGE:iu},AbortError:Ue}=xe,{validateAbortSignal:ht,validateInteger:Ss,validateObject:pt}=Mt,su=oe.Symbol("kWeak"),ou=oe.Symbol("kResistStopPropagation"),{finished:au}=Je,lu=Es,{addAbortSignalNoValidate:uu}=dr,{isWritable:fu,isNodeStream:cu}=He,{deprecate:du}=Se,{ArrayPrototypePush:hu,Boolean:pu,MathFloor:Is,Number:_u,NumberIsNaN:bu,Promise:Rs,PromiseReject:As,PromiseResolve:yu,PromisePrototypeThen:Ts,Symbol:vs}=oe,xr=vs("kEmpty"),Ns=vs("kEof");function gu(t,e){if(e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal"),cu(t)&&!fu(t))throw new ru("stream",t,"must be writable");const r=lu(this,t);return e!=null&&e.signal&&uu(e.signal,r),r}function Er(t,e){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal");let r=1;(e==null?void 0:e.concurrency)!=null&&(r=Is(e.concurrency));let n=r-1;return(e==null?void 0:e.highWaterMark)!=null&&(n=Is(e.highWaterMark)),Ss(r,"options.concurrency",1),Ss(n,"options.highWaterMark",0),n+=r,(async function*(){const a=Se.AbortSignalAny([e==null?void 0:e.signal].filter(pu)),l=this,u=[],p={signal:a};let _,y,x=!1,I=0;function S(){x=!0,R()}function R(){I-=1,w()}function w(){y&&!x&&I<r&&u.length<n&&(y(),y=null)}async function A(){try{for await(let $ of l){if(x)return;if(a.aborted)throw new Ue;try{if($=t($,p),$===xr)continue;$=yu($)}catch(B){$=As(B)}I+=1,Ts($,R,S),u.push($),_&&(_(),_=null),!x&&(u.length>=n||I>=r)&&await new Rs(B=>{y=B})}u.push(Ns)}catch($){const B=As($);Ts(B,R,S),u.push(B)}finally{x=!0,_&&(_(),_=null)}}A();try{for(;;){for(;u.length>0;){const $=await u[0];if($===Ns)return;if(a.aborted)throw new Ue;$!==xr&&(yield $),u.shift(),w()}await new Rs($=>{_=$})}}finally{x=!0,y&&(y(),y=null)}}).call(this)}function wu(t=void 0){return t!=null&&pt(t,"options"),(t==null?void 0:t.signal)!=null&&ht(t.signal,"options.signal"),(async function*(){let r=0;for await(const i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Ue({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Ps(t,e=void 0){for await(const r of xn.call(this,t,e))return!0;return!1}async function mu(t,e=void 0){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);return!await Ps.call(this,async(...r)=>!await t(...r),e)}async function xu(t,e){for await(const r of xn.call(this,t,e))return r}async function Eu(t,e){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),xr}for await(const n of Er.call(this,r,e));}function xn(t,e){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:xr}return Er.call(this,r,e)}class Su extends nu{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function Iu(t,e,r){var n;if(typeof t!="function")throw new Gt("reducer",["Function","AsyncFunction"],t);r!=null&&pt(r,"options"),(r==null?void 0:r.signal)!=null&&ht(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){const _=new Ue(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await au(this.destroy(_)),_}const a=new tu,l=a.signal;if(r!=null&&r.signal){const _={once:!0,[su]:this,[ou]:!0};r.signal.addEventListener("abort",()=>a.abort(),_)}let u=!1;try{for await(const _ of this){var p;if(u=!0,r!=null&&(p=r.signal)!==null&&p!==void 0&&p.aborted)throw new Ue;i?e=await t(e,_,{signal:l}):(e=_,i=!0)}if(!u&&!i)throw new Su}finally{a.abort()}return e}async function Ru(t){t!=null&&pt(t,"options"),(t==null?void 0:t.signal)!=null&&ht(t.signal,"options.signal");const e=[];for await(const n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new Ue(void 0,{cause:t.signal.reason});hu(e,n)}return e}function Au(t,e){const r=Er.call(this,t,e);return(async function*(){for await(const i of r)yield*i}).call(this)}function js(t){if(t=_u(t),bu(t))return 0;if(t<0)throw new iu("number",">= 0",t);return t}function Tu(t,e=void 0){return e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal"),t=js(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ue;for await(const a of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ue;t--<=0&&(yield a)}}).call(this)}function vu(t,e=void 0){return e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal"),t=js(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ue;for await(const a of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ue;if(t-- >0&&(yield a),t<=0)return}}).call(this)}Fr.streamReturningOperators={asIndexedPairs:du(wu,"readable.asIndexedPairs will be removed in a future version."),drop:Tu,filter:xn,flatMap:Au,map:Er,take:vu,compose:gu},Fr.promiseReturningOperators={every:mu,forEach:Eu,reduce:Iu,toArray:Ru,some:Ps,find:xu};var En,Ls;function $s(){if(Ls)return En;Ls=1;const{ArrayPrototypePop:t,Promise:e}=oe,{isIterable:r,isNodeStream:n,isWebStream:i}=He,{pipelineImpl:a}=wn,{finished:l}=Je;Fs();function u(...p){return new e((_,y)=>{let x,I;const S=p[p.length-1];if(S&&typeof S=="object"&&!n(S)&&!r(S)&&!i(S)){const R=t(p);x=R.signal,I=R.end}a(p,(R,w)=>{R?y(R):_(w)},{signal:x,end:I})})}return En={finished:l,pipeline:u},En}var Bs;function Fs(){if(Bs)return $r.exports;Bs=1;const{Buffer:t}=Fe,{ObjectDefineProperty:e,ObjectKeys:r,ReflectApply:n}=oe,{promisify:{custom:i}}=Se,{streamReturningOperators:a,promiseReturningOperators:l}=Fr,{codes:{ERR_ILLEGAL_CONSTRUCTOR:u}}=xe,p=Es,{setDefaultHighWaterMark:_,getDefaultHighWaterMark:y}=pr,{pipeline:x}=wn,{destroyer:I}=Tt,S=Je,R=$s(),w=He,A=$r.exports=Yr.Stream;A.isDestroyed=w.isDestroyed,A.isDisturbed=w.isDisturbed,A.isErrored=w.isErrored,A.isReadable=w.isReadable,A.isWritable=w.isWritable,A.Readable=_r();for(const B of r(a)){let q=function(...U){if(new.target)throw u();return A.Readable.from(n(T,this,U))};const T=a[B];e(q,"name",{__proto__:null,value:T.name}),e(q,"length",{__proto__:null,value:T.length}),e(A.Readable.prototype,B,{__proto__:null,value:q,enumerable:!1,configurable:!0,writable:!0})}for(const B of r(l)){let q=function(...U){if(new.target)throw u();return n(T,this,U)};const T=l[B];e(q,"name",{__proto__:null,value:T.name}),e(q,"length",{__proto__:null,value:T.length}),e(A.Readable.prototype,B,{__proto__:null,value:q,enumerable:!1,configurable:!0,writable:!0})}A.Writable=nn(),A.Duplex=Qe(),A.Transform=fs,A.PassThrough=ds,A.pipeline=x;const{addAbortSignal:$}=dr;return A.addAbortSignal=$,A.finished=S,A.destroy=I,A.compose=p,A.setDefaultHighWaterMark=_,A.getDefaultHighWaterMark=y,e(A,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return R}}),e(x,i,{__proto__:null,enumerable:!0,get(){return R.pipeline}}),e(S,i,{__proto__:null,enumerable:!0,get(){return R.finished}}),A.Stream=A,A._isUint8Array=function(T){return T instanceof Uint8Array},A._uint8ArrayToBuffer=function(T){return t.from(T.buffer,T.byteOffset,T.byteLength)},$r.exports}(function(t){const e=Fs(),r=$s(),n=e.Readable.destroy;t.exports=e.Readable,t.exports._uint8ArrayToBuffer=e._uint8ArrayToBuffer,t.exports._isUint8Array=e._isUint8Array,t.exports.isDisturbed=e.isDisturbed,t.exports.isErrored=e.isErrored,t.exports.isReadable=e.isReadable,t.exports.Readable=e.Readable,t.exports.Writable=e.Writable,t.exports.Duplex=e.Duplex,t.exports.Transform=e.Transform,t.exports.PassThrough=e.PassThrough,t.exports.addAbortSignal=e.addAbortSignal,t.exports.finished=e.finished,t.exports.destroy=e.destroy,t.exports.destroy=n,t.exports.pipeline=e.pipeline,t.exports.compose=e.compose,Object.defineProperty(e,"promises",{configurable:!0,enumerable:!0,get(){return r}}),t.exports.Stream=e.Stream,t.exports.default=t.exports})(Kn);var ks=Kn.exports;const Sn=Symbol("iter");function zt(t,e,r=4){if(r===0)return Object.assign(t,e);for(const n in e)t[n]=zt(t[n]||Object.create(null),e[n],r-1);return t}function Cs(t,e,r=4){let n=!1;for(const i in t)if(i in e){const a=r===0?null:Cs(t[i],e[i],r-1);if(a!==!1)n=n||Object.create(null),n[i]=a;else if(r===3)return!1}return n}function Os(t,e,r=4){let n=!1;for(const i in t)if(!(i in e))n=n||Object.create(null),n[i]=r===0?null:zt({},t[i],r-1);else if(r!==0){const a=Os(t[i],e[i],r-1);if(a!==!1)n=n||Object.create(null),n[i]=a;else if(r===3)return!1}return n}class Nu{constructor(e={}){this._id=1,this._ids=Object.create(null),this._ids[""]=1,this._entities=Object.create(null),this._entities[1]="",this._blankNodeIndex=0,this._factory=e.factory||ot}_termFromId(e){if(e[0]==="."){const r=this._entities,n=e.split(".");return this._factory.quad(this._termFromId(r[n[1]]),this._termFromId(r[n[2]]),this._termFromId(r[n[3]]),n[4]&&this._termFromId(r[n[4]]))}return $t(e,this._factory)}_termToNumericId(e){if(e.termType==="Quad"){const r=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),i=this._termToNumericId(e.object);let a;return r&&n&&i&&(Pr(e.graph)||(a=this._termToNumericId(e.graph)))&&this._ids[a?`.${r}.${n}.${i}.${a}`:`.${r}.${n}.${i}`]}return this._ids[xt(e)]}_termToNewNumericId(e){const r=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${Pr(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:xt(e);return this._ids[r]||(this._ids[this._entities[++this._id]=r]=this._id)}createBlankNode(e){let r,n;if(e)for(r=e=`_:${e}`,n=1;this._ids[r];)r=e+n++;else do r=`_:b${this._blankNodeIndex++}`;while(this._ids[r]);return this._ids[r]=++this._id,this._entities[this._id]=r,this._factory.blankNode(r.substr(2))}}class Ie{constructor(e,r){this._size=0,this._graphs=Object.create(null),!r&&e&&!e[0]&&typeof e.match!="function"&&(r=e,e=null),r=r||{},this._factory=r.factory||ot,this._entityIndex=r.entityIndex||new Nu({factory:this._factory}),this._entities=this._entityIndex._entities,this._termFromId=this._entityIndex._termFromId.bind(this._entityIndex),this._termToNumericId=this._entityIndex._termToNumericId.bind(this._entityIndex),this._termToNewNumericId=this._entityIndex._termToNewNumericId.bind(this._entityIndex),e&&this.addAll(e)}get size(){let e=this._size;if(e!==null)return e;e=0;const r=this._graphs;let n,i;for(const a in r)for(const l in n=r[a].subjects)for(const u in i=n[l])e+=Object.keys(i[u]).length;return this._size=e}_addToIndex(e,r,n,i){const a=e[r]||(e[r]={}),l=a[n]||(a[n]={}),u=i in l;return u||(l[i]=null),!u}_removeFromIndex(e,r,n,i){const a=e[r],l=a[n];delete l[i];for(const u in l)return;delete a[n];for(const u in a)return;delete e[r]}*_findInIndex(e,r,n,i,a,l,u,p){let _,y,x;const I=this._entities,S=this._termFromId(I[p]),R={subject:null,predicate:null,object:null};r&&((_=e,e={})[r]=_[r]);for(const w in e)if(y=e[w]){R[a]=this._termFromId(I[w]),n&&((_=y,y={})[n]=_[n]);for(const A in y)if(x=y[A]){R[l]=this._termFromId(I[A]);const $=i?i in x?[i]:[]:Object.keys(x);for(let B=0;B<$.length;B++)R[u]=this._termFromId(I[$[B]]),yield this._factory.quad(R.subject,R.predicate,R.object,S)}}}_loop(e,r){for(const n in e)r(n)}_loopByKey0(e,r,n){let i,a;if(i=e[r])for(a in i)n(a)}_loopByKey1(e,r,n){let i,a;for(i in e)a=e[i],a[r]&&n(i)}_loopBy2Keys(e,r,n,i){let a,l,u;if((a=e[r])&&(l=a[n]))for(u in l)i(u)}_countInIndex(e,r,n,i){let a=0,l,u,p;r&&((l=e,e={})[r]=l[r]);for(const _ in e)if(u=e[_]){n&&((l=u,u={})[n]=l[n]);for(const y in u)(p=u[y])&&(i?i in p&&a++:a+=Object.keys(p).length)}return a}_getGraphs(e){return e=e===""?1:e&&(this._termToNumericId(e)||-1),typeof e!="number"?this._graphs:{[e]:this._graphs[e]}}_uniqueEntities(e){const r=Object.create(null);return n=>{n in r||(r[n]=!0,e(this._termFromId(this._entities[n],this._factory)))}}add(e){return this.addQuad(e),this}addQuad(e,r,n,i){r||(i=e.graph,n=e.object,r=e.predicate,e=e.subject),i=i?this._termToNewNumericId(i):1;let a=this._graphs[i];return a||(a=this._graphs[i]={subjects:{},predicates:{},objects:{}},Object.freeze(a)),e=this._termToNewNumericId(e),r=this._termToNewNumericId(r),n=this._termToNewNumericId(n),this._addToIndex(a.subjects,e,r,n)?(this._addToIndex(a.predicates,r,n,e),this._addToIndex(a.objects,n,e,r),this._size=null,!0):!1}addQuads(e){for(let r=0;r<e.length;r++)this.addQuad(e[r])}delete(e){return this.removeQuad(e),this}has(e,r,n,i){return e&&e.subject&&({subject:e,predicate:r,object:n,graph:i}=e),!this.readQuads(e,r,n,i).next().done}import(e){return e.on("data",r=>{this.addQuad(r)}),e}removeQuad(e,r,n,i){r||({subject:e,predicate:r,object:n,graph:i}=e),i=i?this._termToNumericId(i):1;const a=this._graphs;let l,u,p;if(!(e=e&&this._termToNumericId(e))||!(r=r&&this._termToNumericId(r))||!(n=n&&this._termToNumericId(n))||!(l=a[i])||!(u=l.subjects[e])||!(p=u[r])||!(n in p))return!1;this._removeFromIndex(l.subjects,e,r,n),this._removeFromIndex(l.predicates,r,n,e),this._removeFromIndex(l.objects,n,e,r),this._size!==null&&this._size--;for(e in l.subjects)return!0;return delete a[i],!0}removeQuads(e){for(let r=0;r<e.length;r++)this.removeQuad(e[r])}remove(e){return e.on("data",r=>{this.removeQuad(r)}),e}removeMatches(e,r,n,i){const a=new ks.Readable({objectMode:!0}),l=this.readQuads(e,r,n,i);return a._read=u=>{for(;--u>=0;){const{done:p,value:_}=l.next();if(p){a.push(null);return}a.push(_)}},this.remove(a)}deleteGraph(e){return this.removeMatches(null,null,null,e)}getQuads(e,r,n,i){return[...this.readQuads(e,r,n,i)]}*readQuads(e,r,n,i){const a=this._getGraphs(i);let l,u,p,_;if(!(e&&!(u=this._termToNumericId(e))||r&&!(p=this._termToNumericId(r))||n&&!(_=this._termToNumericId(n))))for(const y in a)(l=a[y])&&(u?_?yield*this._findInIndex(l.objects,_,u,p,"object","subject","predicate",y):yield*this._findInIndex(l.subjects,u,p,null,"subject","predicate","object",y):p?yield*this._findInIndex(l.predicates,p,_,null,"predicate","object","subject",y):_?yield*this._findInIndex(l.objects,_,null,null,"object","subject","predicate",y):yield*this._findInIndex(l.subjects,null,null,null,"subject","predicate","object",y))}match(e,r,n,i){return new et(this,e,r,n,i,{entityIndex:this._entityIndex})}countQuads(e,r,n,i){const a=this._getGraphs(i);let l=0,u,p,_,y;if(e&&!(p=this._termToNumericId(e))||r&&!(_=this._termToNumericId(r))||n&&!(y=this._termToNumericId(n)))return 0;for(const x in a)(u=a[x])&&(e?n?l+=this._countInIndex(u.objects,y,p,_):l+=this._countInIndex(u.subjects,p,_,y):r?l+=this._countInIndex(u.predicates,_,y,p):l+=this._countInIndex(u.objects,y,p,_));return l}forEach(e,r,n,i,a){this.some(l=>(e(l,this),!1),r,n,i,a)}every(e,r,n,i,a){return!this.some(l=>!e(l,this),r,n,i,a)}some(e,r,n,i,a){for(const l of this.readQuads(r,n,i,a))if(e(l,this))return!0;return!1}getSubjects(e,r,n){const i=[];return this.forSubjects(a=>{i.push(a)},e,r,n),i}forSubjects(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.predicates,u,p,e):this._loopByKey1(l.subjects,u,e):p?this._loopByKey0(l.objects,p,e):this._loop(l.subjects,e))}getPredicates(e,r,n){const i=[];return this.forPredicates(a=>{i.push(a)},e,r,n),i}forPredicates(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.objects,p,u,e):this._loopByKey0(l.subjects,u,e):p?this._loopByKey1(l.predicates,p,e):this._loop(l.predicates,e))}getObjects(e,r,n){const i=[];return this.forObjects(a=>{i.push(a)},e,r,n),i}forObjects(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.subjects,u,p,e):this._loopByKey1(l.objects,u,e):p?this._loopByKey0(l.predicates,p,e):this._loop(l.objects,e))}getGraphs(e,r,n){const i=[];return this.forGraphs(a=>{i.push(a)},e,r,n),i}forGraphs(e,r,n,i){for(const a in this._graphs)this.some(l=>(e(l.graph),!0),r,n,i,this._termFromId(this._entities[a]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:r=!1}={}){const n={},i=r?()=>!0:(u,p)=>{throw new Error(`${u.value} ${p}`)},a=this.getQuads(null,be.rdf.rest,be.rdf.nil,null),l=e?[...a]:[];return a.forEach(u=>{const p=[];let _=!1,y,x;const I=u.graph;let S=u.subject;for(;S&&!_;){const R=this.getQuads(null,null,S,null),w=this.getQuads(S,null,null,null);let A,$=null,B=null,T=null;for(let q=0;q<w.length&&!_;q++)A=w[q],A.graph.equals(I)?y?_=i(S,"has non-list arcs out"):A.predicate.value===be.rdf.first?$?_=i(S,"has multiple rdf:first arcs"):l.push($=A):A.predicate.value===be.rdf.rest?B?_=i(S,"has multiple rdf:rest arcs"):l.push(B=A):R.length?_=i(S,"can't be subject and object"):(y=A,x="subject"):_=i(S,"not confined to single graph");for(let q=0;q<R.length&&!_;++q)A=R[q],y?_=i(S,"can't have coreferences"):A.predicate.value===be.rdf.rest?T?_=i(S,"has incoming rdf:rest arcs"):T=A:(y=A,x="object");$?p.unshift($.object):_=i(S,"has no list head"),S=T&&T.subject}_?e=!1:y&&(n[y[x].value]=p)}),e&&this.removeQuads(l),n}addAll(e){if(e instanceof et&&(e=e.filtered),Array.isArray(e))this.addQuads(e);else if(e instanceof Ie&&e._entityIndex===this._entityIndex)e._size!==0&&(this._graphs=zt(this._graphs,e._graphs),this._size=null);else for(const r of e)this.add(r);return this}contains(e){if(e instanceof et&&(e=e.filtered),e===this)return!0;if(!(e instanceof Ie)||this._entityIndex!==e._entityIndex)return e.every(_=>this.has(_));const r=this._graphs,n=e._graphs;let i,a,l,u,p;for(const _ in n){if(!(i=r[_]))return!1;i=i.subjects;for(const y in a=n[_].subjects){if(!(l=i[y]))return!1;for(const x in u=a[y]){if(!(p=l[x]))return!1;for(const I in u[x])if(!(I in p))return!1}}}return!0}deleteMatches(e,r,n,i){for(const a of this.match(e,r,n,i))this.removeQuad(a);return this}difference(e){if(e&&e instanceof et&&(e=e.filtered),e===this)return new Ie({entityIndex:this._entityIndex});if(e instanceof Ie&&e._entityIndex===this._entityIndex){const r=new Ie({entityIndex:this._entityIndex}),n=Os(this._graphs,e._graphs);return n&&(r._graphs=n,r._size=null),r}return this.filter(r=>!e.has(r))}equals(e){return e instanceof et&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){const r=new Ie({entityIndex:this._entityIndex});for(const n of this)e(n,this)&&r.add(n);return r}intersection(e){if(e instanceof et&&(e=e.filtered),e===this){const r=new Ie({entityIndex:this._entityIndex});return r._graphs=zt(Object.create(null),this._graphs),r._size=this._size,r}else if(e instanceof Ie&&this._entityIndex===e._entityIndex){const r=new Ie({entityIndex:this._entityIndex}),n=Cs(e._graphs,this._graphs);return n&&(r._graphs=n,r._size=null),r}return this.filter(r=>e.has(r))}map(e){const r=new Ie({entityIndex:this._entityIndex});for(const n of this)r.add(e(n,this));return r}reduce(e,r){const n=this.readQuads();let i=r===void 0?n.next().value:r;for(const a of n)i=e(i,a,this);return i}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return new Qn().quadsToString(this)}union(e){const r=new Ie({entityIndex:this._entityIndex});return r._graphs=zt(Object.create(null),this._graphs),r._size=this._size,r.addAll(e),r}*[Symbol.iterator](){yield*this.readQuads()}}function We(t,e,r=0){const n=e[r];if(n&&!(n in t))return!1;let i=!1;for(const a in n?{[n]:t[n]}:t){const l=r===2?null:We(t[a],e,r+1);l!==!1&&(i=i||Object.create(null),i[a]=l)}return i}class et extends ks.Readable{constructor(e,r,n,i,a,l){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:r,predicate:n,object:i,graph:a,options:l})}get filtered(){if(!this._filtered){const{n3Store:e,graph:r,object:n,predicate:i,subject:a}=this,l=this._filtered=new Ie({factory:e._factory,entityIndex:this.options.entityIndex});let u,p,_;if(a&&!(u=l._termToNumericId(a))||i&&!(p=l._termToNumericId(i))||n&&!(_=l._termToNumericId(n)))return l;const y=e._getGraphs(r);for(const x in y){let I,S,R,w;(w=y[x])&&(!u&&p?(S=We(w.predicates,[p,_,u]))&&(I=We(w.subjects,[u,p,_]),R=We(w.objects,[_,u,p])):_?(R=We(w.objects,[_,u,p]))&&(I=We(w.subjects,[u,p,_]),S=We(w.predicates,[p,_,u])):(I=We(w.subjects,[u,p,_]))&&(S=We(w.predicates,[p,_,u]),R=We(w.objects,[_,u,p])),I&&(l._graphs[x]={subjects:I,predicates:S,objects:R}))}l._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[Sn]&&(this[Sn]=this[Symbol.iterator]());const r=this[Sn];for(;--e>=0;){const{done:n,value:i}=r.next();if(n){this.push(null);return}this.push(i)}}addAll(e){return this.filtered.addAll(e)}contains(e){return this.filtered.contains(e)}deleteMatches(e,r,n,i){return this.filtered.deleteMatches(e,r,n,i)}difference(e){return this.filtered.difference(e)}equals(e){return this.filtered.equals(e)}every(e,r,n,i,a){return this.filtered.every(e,r,n,i,a)}filter(e){return this.filtered.filter(e)}forEach(e,r,n,i,a){return this.filtered.forEach(e,r,n,i,a)}import(e){return this.filtered.import(e)}intersection(e){return this.filtered.intersection(e)}map(e){return this.filtered.map(e)}some(e,r,n,i,a){return this.filtered.some(e,r,n,i,a)}toCanonical(){return this.filtered.toCanonical()}toStream(){return this._filtered?this._filtered.toStream():this.n3Store.match(this.subject,this.predicate,this.object,this.graph)}union(e){return this._filtered?this._filtered.union(e):this.n3Store.match(this.subject,this.predicate,this.object,this.graph).addAll(e)}toArray(){return this._filtered?this._filtered.toArray():this.n3Store.getQuads(this.subject,this.predicate,this.object,this.graph)}reduce(e,r){return this.filtered.reduce(e,r)}toString(){return new Qn().quadsToString(this)}add(e){return this.filtered.add(e)}delete(e){return this.filtered.delete(e)}has(e){return this.filtered.has(e)}match(e,r,n,i){return new et(this.filtered,e,r,n,i,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}}const Sr={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#"},de={namespace:"https://prez.dev/",label:"https://prez.dev/label",description:"https://prez.dev/description",provenance:"https://prez.dev/provenance",focusNode:"https://prez.dev/FocusNode",link:"https://prez.dev/link",members:"https://prez.dev/members",identifier:"https://prez.dev/identifier",count:"https://prez.dev/count",searchResult:"https://prez.dev/SearchResult",searchResultWeight:"https://prez.dev/searchResultWeight",searchResultPredicate:"https://prez.dev/searchResultPredicate",searchResultURI:"https://prez.dev/searchResultURI",searchResultMatch:"https://prez.dev/searchResultMatch",hasChildren:"https://prez.dev/hasChildren",facetCount:"https://prez.dev/facetCount",facetName:"https://prez.dev/facetName",facetValue:"https://prez.dev/facetValue",profile:"https://prez.dev/profile"},pe={skosConceptScheme:"http://www.w3.org/2004/02/skos/core#ConceptScheme",skosConcept:"http://www.w3.org/2004/02/skos/core#Concept",a:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",rdfLangString:"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",xmlString:"http://www.w3.org/2001/XMLSchema#string",w3Html:"http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",w3Markdown:"https://www.w3.org/ns/iana/media-types/text/markdown",w3token:"http://www.w3.org/2001/XMLSchema#token",shaclAllPredicates:"http://example.com/shacl-extension#allPredicateValues",shaclPathAlias:"http://example.com/shacl-extension#pathAlias",shaclProperty:"http://www.w3.org/ns/shacl#property",shaclPath:"http://www.w3.org/ns/shacl#path",shaclUnion:"http://www.w3.org/ns/shacl#union",dctermsIdentifier:"http://purl.org/dc/terms/identifier"},Pu={label:["https://prez.dev/label"],description:["https://prez.dev/description"],provenance:["https://prez.dev/provenance"]};function Ms(t,e=Sr){if(t==="a")return e.rdf+"type";{const[r,n]=t.split(":");return r?[r]+n:t}}function Ds(t,e=Sr){let r="";return Object.entries(e).forEach(([n,i])=>{t.startsWith(i)&&(r=n+":"+t.split(i)[1])}),r}const Us=t=>{const e=new URL(t);return`${e.protocol}//${e.hostname}`},ju=t=>new URL(t).pathname,Lu=(t,e)=>{var n,i;const r=(i=(n=e.identifiers)==null?void 0:n.find(a=>a.value))==null?void 0:i.value;return r?t+`/concept-hierarchy/${r}/narrowers`:""},$u=(t,e)=>{var l;const r=e?Us(e):"",n=(l=t.identifiers)==null?void 0:l.find(u=>u.value),i=n?n.value:"";return i?r+`/concept-hierarchy/${i}/top-concepts`:""},Ir=t=>t.flatMap(e=>{var r;if(e["@id"])return e["@id"];if(e["@list"]&&e["@list"].length>0){const n=e["@list"][0];return(n==null?void 0:n["@id"])===pe.shaclUnion?Ir(((r=e["@list"][1])==null?void 0:r["@list"])||[]).filter(Boolean):Ir(e["@list"]).flat()}return[]}).filter(e=>!!e),Bu=t=>t.reduce((e,r)=>{if(pe.shaclProperty in r)for(const n of r[pe.shaclProperty]){const i=t.find(a=>a["@id"]===n["@id"]);i&&pe.shaclPath in i&&(e[r["@id"]]=Ir(i[pe.shaclPath]).filter(a=>a!==pe.shaclAllPredicates))}return e},{});function qt(t){if(Array.isArray(t))return t.reduce((e,r)=>{const n=qt(r);return typeof n=="object"&&!Array.isArray(n)&&Object.assign(e,n),e},{});if(typeof t=="object"&&t!==null){if(t.hasOwnProperty("value"))return t.value;if(t.hasOwnProperty("node")&&t.hasOwnProperty("list")){const e={};return e[t.node.value]=t.list.length>0?qt(t.list):"",e}else{const e={};for(const r in t)e[r]=qt(t[r]);return e}}return t}function In(t,e=""){let r="";const n=Object.entries(t),i=n.length;return n.forEach(([a,l],u)=>{const p=a.replace(/https?:\/\/(www\.)?/,""),[_,y]=p.split("#"),x=_.split("/"),I=x[x.length-1],S=y?`(${x[0]})/${I}#${y}`:`(${x[0]})/${I}`,R=u===i-1;r+=`${e}${R?"└── ":"├── "}${S}
28
28
  `,typeof l=="object"&&l!==null&&(r+=In(l,e+(R?" ":"│ ")))}),r}function Fu(t){return t?In(qt(t)):""}const{namedNode:Ht}=ot;class Qt{constructor(){nt(this,"store");nt(this,"parser");nt(this,"prefixes");nt(this,"basePath");nt(this,"baseUrl");nt(this,"linkedLists");nt(this,"lists");this.store=new Ie,this.baseUrl="",this.basePath="",this.parser=new Un,this.prefixes=Sr,this.linkedLists={},this.lists={}}load(e){e=`PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
29
- `+e;const r=this.parser.parse(e,null,(n,i)=>{this.prefixes[n]=i.value});this.store.addQuads(r),this.linkedLists=this.store.extractLists(),this.buildLists()}buildLists(){this.lists={};const e=this.linkedLists;this.store.getQuads(null,pe.shaclPath,null,null).forEach(r=>{const n=r.object;if(n.termType==="BlankNode"){const i=this.store.getQuads(n,pe.shaclUnion,null,null);if(i.length>0){const a=i[0].object;if(a.termType==="BlankNode"&&a.value in e){const l=e[a.value],u=n.value;this.lists[u]=this.buildSubList(l)}else console.warn(`[buildLists] Found sh:union for ${n.value}, but its object ${a.value} is not a valid list head in linkedLists.`)}}})}buildSubList(e){var n;const r=[];for(const i of e)if(i.termType=="BlankNode"){const a=i.value;if(a in this.linkedLists){const l=this.buildSubList(this.linkedLists[a]);if(l.length>1){const u=r.find(p=>p.node.value==l[0].node.value);u?(u.list??(u.list=[])).push(...l.slice(1)):r.push({node:l[0].node,list:l.slice(1)})}else r.push(...l)}else{const l=(n=this.store.getObjects(i,pe.shaclPathAlias,null))==null?void 0:n[0];if(l){const u=this.toPrezTerm(l);r.push({node:u,list:[]})}}}else if(i.termType=="NamedNode"&&i.value!=pe.shaclUnion){const a=this.toPrezTerm(i);r.push({node:a,list:[]})}return r}setBaseUrl(e){this.baseUrl=e,this.basePath=new URL(e).pathname}toIri(e){return Ms(e,this.prefixes)}fromIri(e){return Ds(e,this.prefixes)}getObjectLiteral(e,r){return this.getObjects(e,r).map(n=>this.toPrezTerm(n))[0]||void 0}getProperties(e,r){const n={};return this.store.forEach(i=>{var a;r!=null&&r.excludePrefix&&i.predicate.value.startsWith(r.excludePrefix)||r!=null&&r.includePrefix&&!i.predicate.value.startsWith(r.includePrefix)||(n[a=i.predicate.value]??(n[a]={predicate:this.toPrezTerm(i.predicate),objects:[]}),n[i.predicate.value].objects.push(this.toPrezTerm(i.object)))},e,null,null,null),e.termType,n}getParents(e){e.startsWith(this.basePath)&&(e=e.substring(this.basePath.length));const r=e.split("/"),n=[];let i="";for(const a of r){if(a=="")continue;i+="/"+a;const l={url:i,segment:a};if(a.includes(":")){const u=a.split(":"),p=this.prefixes[u[0]];if(p){const _=this.getObjects(p+u[1],de.label);_.length>0&&(l.label=Rr(_[0].value))}}n.push(l)}return n}toPrezTerm(e){switch(e.termType){case"NamedNode":const r=it(e.value);r.label=this.getObjectLiteral(e.value,de.label),r.description=this.getObjectLiteral(e.value,de.description),r.provenance=this.getObjectLiteral(e.value,de.provenance);const n=this.getObjects(e.value,de.identifier);n.length>0&&(r.identifiers=n.map(_=>this.toPrezTerm(_)));const i=this.getObjects(e.value,de.link);i.length>0&&(r.links=i.map(_=>({value:_.value,parents:this.getParents(_.value)})));const a=this.getObjects(e.value,de.members);a.length>0&&(r.members={value:a[0].value,parents:this.getParents(a[0].value)});const l=this.getObjects(e.value,pe.a);return l.length>0&&(r.rdfTypes=l.map(_=>this.toPrezTerm(_))),r;case"Literal":const u=Rr(e.value);return e.datatype&&(u.datatype=this.toPrezTerm(e.datatype)),e.language&&(u.language=e.language),u;case"BlankNode":const p=Ar(e.value);return p.properties=this.getProperties(e),e.value in this.lists&&(p.list=this.lists[e.value]),p;default:throw"Invalid n3 Term object"}}toPrezFocusNode(e){var n,i,a,l,u;const r=this.toPrezTerm(e);return r.properties=this.getProperties(e,{excludePrefix:de.namespace}),r.systemProperties=this.getProperties(e,{includePrefix:de.namespace}),(n=r.rdfTypes)!=null&&n.map(p=>p.value).includes(pe.skosConcept)&&(r.hasChildren=((u=(l=(a=(i=r.systemProperties)==null?void 0:i[de.hasChildren])==null?void 0:a.objects)==null?void 0:l[0])==null?void 0:u.value)=="true"),r}getSubjects(e,r){return this.store.getSubjects(e,r,null)}getObjects(e,r){if(typeof r=="string")return this.store.getObjects(Ht(e),Ht(r),null);{const n=[];return r.forEach(i=>{n.push(...this.store.getObjects(Ht(e),Ht(i),null))}),n}}getMembers(e){this.getObjects(e,this.toIri("prez:members")).forEach(n=>({value:n.value,parents:[]}))}getConcepts(e){const r=this.getSubjects(this.toIri("skos:inScheme"),e.value);function n(_){return r.map(y=>y.value).includes(_.value)}const i=this.getObjects(e.value,this.toIri("skos:hasTopConcept")),a=this.getObjects(e.value,this.toIri("skos:topConceptOf")),l={},u=[...i,...a].filter(_=>n(_));r.forEach(_=>{l[_.value]=[]}),r.forEach(_=>{this.getObjects(_.value,this.toIri("skos:broader")).forEach(I=>{n(I)&&l[I.value].push(_)}),this.getObjects(_.value,this.toIri("skos:narrower")).forEach(I=>{n(I)&&l[_.value].push(I)})});const p=[];return u.forEach(_=>{p.push(this.createHierarchy(_,l))}),p}createHierarchy(e,r){const n=r[e.value].map(i=>this.createHierarchy(i,r));return{...this.toPrezTerm(e),hasChildren:n.length>0,narrowers:n}}getByPrezId(e){const r=[];return this.store.forEach(n=>{r.push(n)},null,null,Ht("https://prez.dev/FocusNode"),null),e?r.find(n=>n.object.value===e).subject:r.map(n=>n.subject)}getCount(){const e=this.store.getObjects(null,de.count,null);return e.length>0?Number(e[0].value.replace(">","")):0}getMaxReached(){const e=this.store.getObjects(null,de.count,null);return e.length>0?e[0].value.includes(">"):!1}getList(){const e=[];return this.getByPrezId().forEach(n=>{e.push(this.toPrezFocusNode(n))}),e}getItem(){var n;const e=this.getByPrezId();if(e.length==0)throw new Error("Unable to find item");const r=this.toPrezFocusNode(e[0]);if((n=r.rdfTypes)!=null&&n.map(i=>i.value).includes(pe.skosConcept)){const i=this.getConcepts(e[0]);return{...r,topConcepts:{narrowers:i,hasChildren:i.length>0}}}return r}getSubItems(e){const r=this.store.getQuads(null,e,null,null),n=[];return r.forEach(i=>{const a=this.toPrezFocusNode(i.object);a&&n.push(a)}),n}search(){return this.getSubjects(pe.a,de.searchResult).map(n=>({hash:n.value.split("urn:hash:").slice(-1)[0],weight:Number(this.getObjects(n.value,de.searchResultWeight)[0].value),predicate:this.toPrezTerm(this.getObjects(n.value,de.searchResultPredicate)[0]),match:this.toPrezTerm(this.getObjects(n.value,de.searchResultMatch)[0]),resource:this.toPrezFocusNode(this.getObjects(n.value,de.searchResultURI)[0])}))}getFacets(){const e=[];return this.store.getQuads(null,de.facetName,null,null).forEach(r=>{var n,i,a,l,u,p,_,y,x;if(r.subject.termType=="BlankNode"){const I=Ar(r.subject.value);I.properties=this.getProperties(r.subject);const S=Number((a=(i=(n=I.properties)==null?void 0:n[de.facetCount])==null?void 0:i.objects)==null?void 0:a[0].value)||0,R=(p=(u=(l=I.properties)==null?void 0:l[de.facetName])==null?void 0:u.objects)==null?void 0:p[0],w=(x=(y=(_=I.properties)==null?void 0:_[de.facetValue])==null?void 0:y.objects)==null?void 0:x[0],A=R,$=e.find(B=>B.facetName.value==(A==null?void 0:A.value));if(S>0&&A!==void 0&&w!==void 0){const B=this.toPrezTerm(w);if(B.termType==="Literal"||B.termType==="NamedNode"){const T={term:B,count:S};$?$.facetValues.push(T):e.push({facetName:A,facetValues:[T]})}}}}),e}}class ku extends Error{constructor(e){super(e),this.name="NetworkError"}}function Cu(t){let e={};const r=t.split(",").map(i=>{const[,a,l]=i.trim().match(/<(.+)>; (.+)/),u={uri:a};return l.split("; ").forEach(p=>{const[,_,y]=p.match(/(.+)=[\"<](.+)[\">]/);u[_]=y}),u});r.filter(i=>i.rel==="type").forEach(i=>{e[i.anchor]={default:!1,current:!1,token:i.token,mediatypes:[],title:i.title,description:"",uri:i.anchor}});const n=r.find(i=>i.rel==="self");return n.format in e&&(e[n.format].current=!0),r.filter(i=>i.rel==="alternate"&&i.format).forEach(i=>{e[i.format].mediatypes.map(a=>a.mediatype).includes(i.type)||e[i.format].mediatypes.push({title:"",mediatype:i.type,default:!1})}),Object.values(e)}async function Vt(t){const e=await fetch(t,{method:"GET",headers:{Accept:"text/anot+turtle"}});if(!e.ok)throw new ku(`Network error - status code ${e.status}: ${e.statusText}`);const r=e.headers.get("link")||e.headers.get("Link"),n=r?Cu(r):[];return{data:await e.text(),profiles:n}}async function Ou(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Vt(r),l=new Qt;return l.setBaseUrl(t),l.load(i),{type:"list",data:l.getList(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n),facets:l.getFacets()}}async function Mu(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Vt(r),l=new Qt;return l.setBaseUrl(t),l.load(i),{type:"item",data:l.getItem(),profiles:a,parents:l.getParents(n),store:l,facets:l.getFacets()}}async function Du(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Vt(r),l=new Qt;return l.setBaseUrl(t),l.load(i),{type:"search",data:l.search(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n),facets:l.getFacets()}}async function Uu(t){var l,u,p,_,y,x;const e=t+"/profiles?page=1&limit=999&_mediatype=application/anot%2Bturtle",{data:r}=await Vt(e),n=new Qt;n.setBaseUrl(t),n.load(r);const i=n.getList(),a={};for(const I of i){let S=[];if(I.properties&&((u=(l=I.properties)==null?void 0:l[pe.shaclProperty])!=null&&u.objects)){const R=I.properties[pe.shaclProperty].objects;for(const w of R){const A=w;if(A.properties&&A.properties[pe.shaclPath])for(const $ of A.properties[pe.shaclPath].objects){const B=$.list;B&&(S=B)}}}(x=(y=(_=(p=I.properties)==null?void 0:p[pe.dctermsIdentifier])==null?void 0:_.objects)==null?void 0:y.filter(R=>{var w;return(R==null?void 0:R.termType)=="Literal"&&((w=R==null?void 0:R.datatype)==null?void 0:w.value)==pe.w3token}))==null||x.map(R=>R.value).forEach(R=>{a[R]=S,a[I.value]=S;const w=n.fromIri(I.value);w!=I.value&&(a[w]=S)})}return a}function Wu(t,e){const r={},n=Object.keys(t),i=[...(e||[]).filter(a=>n.includes(a.node.value)).map(a=>a.node.value),...n.filter(a=>!(e||[]).find(l=>l.node.value==a))].filter(a=>a in(t||{})).map(a=>t[a]);for(const a of i)e.find(l=>l.node.value==a.predicate.value&&l.list&&l.list.length>0),r[a.predicate.value]=t[a.predicate.value];return r}function Gu(t,e){t.data.properties=Wu(t.data.properties||{},e)}z.ANNOTATION_PREDICATES=Pu,z.DEFAULT_PREFIXES=Sr,z.PREZ_PREDICATES=de,z.RDFStore=Qt,z.SYSTEM_PREDICATES=pe,z.apiGet=Vt,z.applyProfileToItem=Gu,z.bnode=Ar,z.buildProfiles=Bu,z.defaultFromIri=Ds,z.defaultToIri=Ms,z.dumpNodeArray=Fu,z.getBaseUrl=Us,z.getItem=Mu,z.getList=Ou,z.getNarrowersUrl=Lu,z.getProfiles=Uu,z.getTopConceptsUrl=$u,z.getUrlPath=ju,z.isTypePrezTerm=Ae,z.literal=Rr,z.node=it,z.nodeArrayToTree=In,z.processShaclPath=Ir,z.search=Du,z.simplifyNodeArray=qt,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
29
+ `+e;const r=this.parser.parse(e,null,(n,i)=>{this.prefixes[n]=i.value});this.store.addQuads(r),this.linkedLists=this.store.extractLists(),this.buildLists()}buildLists(){this.lists={};const e=this.linkedLists;this.store.getQuads(null,pe.shaclPath,null,null).forEach(r=>{const n=r.object;if(n.termType==="BlankNode"){const i=this.store.getQuads(n,pe.shaclUnion,null,null);if(i.length>0){const a=i[0].object;if(a.termType==="BlankNode"&&a.value in e){const l=e[a.value],u=n.value;this.lists[u]=this.buildSubList(l)}else console.warn(`[buildLists] Found sh:union for ${n.value}, but its object ${a.value} is not a valid list head in linkedLists.`)}}})}buildSubList(e){var n;const r=[];for(const i of e)if(i.termType=="BlankNode"){const a=i.value;if(a in this.linkedLists){const l=this.buildSubList(this.linkedLists[a]);if(l.length>1){const u=r.find(p=>p.node.value==l[0].node.value);u?(u.list??(u.list=[])).push(...l.slice(1)):r.push({node:l[0].node,list:l.slice(1)})}else r.push(...l)}else{const l=(n=this.store.getObjects(i,pe.shaclPathAlias,null))==null?void 0:n[0];if(l){const u=this.toPrezTerm(l);r.push({node:u,list:[]})}}}else if(i.termType=="NamedNode"&&i.value!=pe.shaclUnion){const a=this.toPrezTerm(i);r.push({node:a,list:[]})}return r}setBaseUrl(e){this.baseUrl=e,this.basePath=new URL(e).pathname}toIri(e){return Ms(e,this.prefixes)}fromIri(e){return Ds(e,this.prefixes)}getObjectLiteral(e,r){return this.getObjects(e,r).map(n=>this.toPrezTerm(n))[0]||void 0}getProperties(e,r){const n={};return this.store.forEach(i=>{var a;r!=null&&r.excludePrefix&&i.predicate.value.startsWith(r.excludePrefix)||r!=null&&r.includePrefix&&!i.predicate.value.startsWith(r.includePrefix)||(n[a=i.predicate.value]??(n[a]={predicate:this.toPrezTerm(i.predicate),objects:[]}),n[i.predicate.value].objects.push(this.toPrezTerm(i.object)))},e,null,null,null),e.termType,n}getParents(e){e.startsWith(this.basePath)&&(e=e.substring(this.basePath.length));const r=e.split("/"),n=[];let i="";for(const a of r){if(a=="")continue;i+="/"+a;const l={url:i,segment:a};if(a.includes(":")){const u=a.split(":"),p=this.prefixes[u[0]];if(p){const _=this.getObjects(p+u[1],de.label);_.length>0&&(l.label=Rr(_[0].value))}}n.push(l)}return n}toPrezTerm(e){switch(e.termType){case"NamedNode":const r=it(e.value);r.label=this.getObjectLiteral(e.value,de.label),r.description=this.getObjectLiteral(e.value,de.description),r.provenance=this.getObjectLiteral(e.value,de.provenance);const n=this.getObjects(e.value,de.identifier);n.length>0&&(r.identifiers=n.map(_=>this.toPrezTerm(_)));const i=this.getObjects(e.value,de.link);i.length>0&&(r.links=i.map(_=>({value:_.value,parents:this.getParents(_.value)})));const a=this.getObjects(e.value,de.members);a.length>0&&(r.members={value:a[0].value,parents:this.getParents(a[0].value)});const l=this.getObjects(e.value,pe.a);return l.length>0&&(r.rdfTypes=l.map(_=>this.toPrezTerm(_))),r;case"Literal":const u=Rr(e.value);return e.datatype&&(u.datatype=this.toPrezTerm(e.datatype)),e.language&&(u.language=e.language),u;case"BlankNode":const p=Ar(e.value);return p.properties=this.getProperties(e),e.value in this.lists&&(p.list=this.lists[e.value]),p;default:throw"Invalid n3 Term object"}}toPrezFocusNode(e){var n,i,a,l,u;const r=this.toPrezTerm(e);return r.properties=this.getProperties(e,{excludePrefix:de.namespace}),r.systemProperties=this.getProperties(e,{includePrefix:de.namespace}),(n=r.rdfTypes)!=null&&n.map(p=>p.value).includes(pe.skosConcept)&&(r.hasChildren=((u=(l=(a=(i=r.systemProperties)==null?void 0:i[de.hasChildren])==null?void 0:a.objects)==null?void 0:l[0])==null?void 0:u.value)=="true"),r}getSubjects(e,r){return this.store.getSubjects(e,r,null)}getObjects(e,r){if(typeof r=="string")return this.store.getObjects(Ht(e),Ht(r),null);{const n=[];return r.forEach(i=>{n.push(...this.store.getObjects(Ht(e),Ht(i),null))}),n}}getMembers(e){this.getObjects(e,this.toIri("prez:members")).forEach(n=>({value:n.value,parents:[]}))}getConcepts(e){const r=this.getSubjects(this.toIri("skos:inScheme"),e.value);function n(_){return r.map(y=>y.value).includes(_.value)}const i=this.getObjects(e.value,this.toIri("skos:hasTopConcept")),a=this.getObjects(e.value,this.toIri("skos:topConceptOf")),l={},u=[...i,...a].filter(_=>n(_));r.forEach(_=>{l[_.value]=[]}),r.forEach(_=>{this.getObjects(_.value,this.toIri("skos:broader")).forEach(I=>{n(I)&&l[I.value].push(_)}),this.getObjects(_.value,this.toIri("skos:narrower")).forEach(I=>{n(I)&&l[_.value].push(I)})});const p=[];return u.forEach(_=>{p.push(this.createHierarchy(_,l))}),p}createHierarchy(e,r){const n=r[e.value].map(i=>this.createHierarchy(i,r));return{...this.toPrezTerm(e),hasChildren:n.length>0,narrowers:n}}getByPrezId(e){const r=[];return this.store.forEach(n=>{r.push(n)},null,null,Ht("https://prez.dev/FocusNode"),null),e?r.find(n=>n.object.value===e).subject:r.map(n=>n.subject)}getCount(){const e=this.store.getObjects(null,de.count,null);return e.length>0?Number(e[0].value.replace(">","")):0}getMaxReached(){const e=this.store.getObjects(null,de.count,null);return e.length>0?!e[0].value.includes(">"):!1}getList(){const e=[];return this.getByPrezId().forEach(n=>{e.push(this.toPrezFocusNode(n))}),e}getSkosCollections(e){const r=this.getSubjects("http://www.w3.org/2004/02/skos/core#inScheme",e.value);return this.getSubjects("http://www.w3.org/1999/02/22-rdf-syntax-ns#type","http://www.w3.org/2004/02/skos/core#Collection").filter(a=>r.find(l=>l.value===a.value)).map(a=>this.toPrezTerm(a)).sort((a,l)=>a.label&&l.label?a.label.value.localeCompare(l.label.value):a.label?-1:l.label?1:a.value.localeCompare(l.value))}getItem(){var n;const e=this.getByPrezId();if(e.length==0)throw new Error("Unable to find item");const r=this.toPrezFocusNode(e[0]);if((n=r.rdfTypes)!=null&&n.map(i=>i.value).includes(pe.skosConceptScheme)){const i=this.getSkosCollections(e[0]);return{...r,collections:i}}return r}getSubItems(e){const r=this.store.getQuads(null,e,null,null),n=[];return r.forEach(i=>{const a=this.toPrezFocusNode(i.object);a&&n.push(a)}),n}search(){return this.getSubjects(pe.a,de.searchResult).map(n=>({hash:n.value.split("urn:hash:").slice(-1)[0],weight:Number(this.getObjects(n.value,de.searchResultWeight)[0].value),predicate:this.toPrezTerm(this.getObjects(n.value,de.searchResultPredicate)[0]),match:this.toPrezTerm(this.getObjects(n.value,de.searchResultMatch)[0]),resource:this.toPrezFocusNode(this.getObjects(n.value,de.searchResultURI)[0])}))}getFacets(){const e=[];return this.store.getQuads(null,de.facetName,null,null).forEach(r=>{var n,i,a,l,u,p,_,y,x;if(r.subject.termType=="BlankNode"){const I=Ar(r.subject.value);I.properties=this.getProperties(r.subject);const S=Number((a=(i=(n=I.properties)==null?void 0:n[de.facetCount])==null?void 0:i.objects)==null?void 0:a[0].value)||0,R=(p=(u=(l=I.properties)==null?void 0:l[de.facetName])==null?void 0:u.objects)==null?void 0:p[0],w=(x=(y=(_=I.properties)==null?void 0:_[de.facetValue])==null?void 0:y.objects)==null?void 0:x[0],A=R,$=e.find(B=>B.facetName.value==(A==null?void 0:A.value));if(S>0&&A!==void 0&&w!==void 0){const B=this.toPrezTerm(w);if(B.termType==="Literal"||B.termType==="NamedNode"){const T={term:B,count:S};$?$.facetValues.push(T):e.push({facetName:A,facetValues:[T]})}}}}),e}}class ku extends Error{constructor(e){super(e),this.name="NetworkError"}}function Cu(t){let e={};const r=t.split(",").map(i=>{const[,a,l]=i.trim().match(/<(.+)>; (.+)/),u={uri:a};return l.split("; ").forEach(p=>{const[,_,y]=p.match(/(.+)=[\"<](.+)[\">]/);u[_]=y}),u});r.filter(i=>i.rel==="type").forEach(i=>{e[i.anchor]={default:!1,current:!1,token:i.token,mediatypes:[],title:i.title,description:"",uri:i.anchor}});const n=r.find(i=>i.rel==="self");return n.format in e&&(e[n.format].current=!0),r.filter(i=>i.rel==="alternate"&&i.format).forEach(i=>{e[i.format].mediatypes.map(a=>a.mediatype).includes(i.type)||e[i.format].mediatypes.push({title:"",mediatype:i.type,default:!1})}),Object.values(e)}async function Vt(t){const e=await fetch(t,{method:"GET",headers:{Accept:"text/anot+turtle"}});if(!e.ok)throw new ku(`Network error - status code ${e.status}: ${e.statusText}`);const r=e.headers.get("link")||e.headers.get("Link"),n=r?Cu(r):[];return{data:await e.text(),profiles:n}}async function Ou(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Vt(r),l=new Qt;return l.setBaseUrl(t),l.load(i),{type:"list",data:l.getList(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n),facets:l.getFacets()}}async function Mu(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Vt(r),l=new Qt;return l.setBaseUrl(t),l.load(i),{type:"item",data:l.getItem(),profiles:a,parents:l.getParents(n),store:l,facets:l.getFacets()}}async function Du(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Vt(r),l=new Qt;return l.setBaseUrl(t),l.load(i),{type:"search",data:l.search(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n),facets:l.getFacets()}}async function Uu(t){var l,u,p,_,y,x;const e=t+"/profiles?page=1&limit=999&_mediatype=application/anot%2Bturtle",{data:r}=await Vt(e),n=new Qt;n.setBaseUrl(t),n.load(r);const i=n.getList(),a={};for(const I of i){let S=[];if(I.properties&&((u=(l=I.properties)==null?void 0:l[pe.shaclProperty])!=null&&u.objects)){const R=I.properties[pe.shaclProperty].objects;for(const w of R){const A=w;if(A.properties&&A.properties[pe.shaclPath])for(const $ of A.properties[pe.shaclPath].objects){const B=$.list;B&&(S=B)}}}(x=(y=(_=(p=I.properties)==null?void 0:p[pe.dctermsIdentifier])==null?void 0:_.objects)==null?void 0:y.filter(R=>{var w;return(R==null?void 0:R.termType)=="Literal"&&((w=R==null?void 0:R.datatype)==null?void 0:w.value)==pe.w3token}))==null||x.map(R=>R.value).forEach(R=>{a[R]=S,a[I.value]=S;const w=n.fromIri(I.value);w!=I.value&&(a[w]=S)})}return a}function Wu(t,e){const r={},n=Object.keys(t),i=[...(e||[]).filter(a=>n.includes(a.node.value)).map(a=>a.node.value),...n.filter(a=>!(e||[]).find(l=>l.node.value==a))].filter(a=>a in(t||{})).map(a=>t[a]);for(const a of i)e.find(l=>l.node.value==a.predicate.value&&l.list&&l.list.length>0),r[a.predicate.value]=t[a.predicate.value];return r}function Gu(t,e){t.data.properties=Wu(t.data.properties||{},e)}z.ANNOTATION_PREDICATES=Pu,z.DEFAULT_PREFIXES=Sr,z.PREZ_PREDICATES=de,z.RDFStore=Qt,z.SYSTEM_PREDICATES=pe,z.apiGet=Vt,z.applyProfileToItem=Gu,z.bnode=Ar,z.buildProfiles=Bu,z.defaultFromIri=Ds,z.defaultToIri=Ms,z.dumpNodeArray=Fu,z.getBaseUrl=Us,z.getItem=Mu,z.getList=Ou,z.getNarrowersUrl=Lu,z.getProfiles=Uu,z.getTopConceptsUrl=$u,z.getUrlPath=ju,z.isTypePrezTerm=Ae,z.literal=Rr,z.node=it,z.nodeArrayToTree=In,z.processShaclPath=Ir,z.search=Du,z.simplifyNodeArray=qt,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
package/dist/store.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Store, Quad_Object, Quad_Subject, Term } from 'n3';
2
- import { PrezProperties, PrezSearchResult, PrezFocusNode, PrezLink, PrezConceptNode, PrezLinkParent, PrezFacet } from './types';
2
+ import { PrezNode, PrezProperties, PrezSearchResult, PrezFocusNode, PrezLink, PrezConceptNode, PrezLinkParent, PrezFacet } from './types';
3
3
  /**
4
4
  * An in-memory N3.js store containing convenience functions
5
5
  */
@@ -103,6 +103,7 @@ export declare class RDFStore {
103
103
  * @returns a list of item objects
104
104
  */
105
105
  getList(): PrezFocusNode[];
106
+ getSkosCollections(vocab: Quad_Object): PrezNode[];
106
107
  /**
107
108
  * Returns an item object
108
109
  *
package/dist/types.d.ts CHANGED
@@ -87,7 +87,7 @@ export interface PrezConceptSchemeNode extends PrezFocusNode {
87
87
  /**
88
88
  * the top level concepts found under this concept scheme
89
89
  */
90
- topConcepts: PrezConceptNode;
90
+ collections: PrezNode[];
91
91
  }
92
92
  /**
93
93
  * A recursive list of child concept schemes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prez-lib",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "A JS library for processing RDF data for use with Prez UI",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",