p;)b--,d|=(255&l.dt(y++))<>=u[C+1],p-=u[C+1],0!=(16&h)){for(h&=15,S=u[C+2]+(d&o[h]),d>>=h,p-=h;15>p;)b--,d|=(255&l.dt(y++))<
>=u[C+1],p-=u[C+1],0!=(16&h)){for(h&=15;h>p;)b--,d|=(255&l.dt(y++))<
>=h,p-=h,k-=S,z>m){_=m-z;do{_+=f.end}while(0>_);if(h=f.end-_,S>h){if(S-=h,m-_>0&&h>m-_)do{f.yt[m++]=f.yt[_++]}while(0!=--h);else f.yt.set(f.yt.subarray(_,_+h),m),m+=h,_+=h,h=0;_=0}}else _=m-z,m-_>0&&2>m-_?(f.yt[m++]=f.yt[_++],f.yt[m++]=f.yt[_++],S-=2):(f.yt.set(f.yt.subarray(_,_+2),m),m+=2,_+=2,S-=2);if(m-_>0&&S>m-_)do{f.yt[m++]=f.yt[_++]}while(0!=--S);else f.yt.set(f.yt.subarray(_,_+S),m),m+=S,_+=S,S=0;break}if(0!=(64&h))return l.Qe="invalid distance code",S=l.qe-b,S=S>p>>3?p>>3:S,b+=S,y-=S,p-=S<<3,f.wt=d,f.ht=p,l.qe=b,l.Ye+=y-l.ct,l.ct=y,f.write=m,t;a+=u[C+2],a+=d&o[h],C=3*(w+a),h=u[C]}break}if(0!=(64&h))return 0!=(32&h)?(S=l.qe-b,S=S>p>>3?p>>3:S,b+=S,y-=S,p-=S<<3,f.wt=d,f.ht=p,l.qe=b,l.Ye+=y-l.ct,l.ct=y,f.write=m,1):(l.Qe="invalid literal/length code",S=l.qe-b,S=S>p>>3?p>>3:S,b+=S,y-=S,p-=S<<3,f.wt=d,f.ht=p,l.qe=b,l.Ye+=y-l.ct,l.ct=y,f.write=m,t);if(a+=u[C+2],a+=d&o[h],C=3*(w+a),0===(h=u[C])){d>>=u[C+1],p-=u[C+1],f.yt[m++]=u[C+2],k--;break}}else d>>=u[C+1],p-=u[C+1],f.yt[m++]=u[C+2],k--}while(k>=258&&b>=10);return S=l.qe-b,S=S>p>>3?p>>3:S,b+=S,y-=S,p-=S<<3,f.wt=d,f.ht=p,l.qe=b,l.Ye+=y-l.ct,l.ct=y,f.write=m,0}n.init=(e,t,n,o,f,l)=>{r=0,d=e,p=t,i=n,y=o,c=f,b=l,s=null},n.bt=(n,k,g)=>{let v,S,z,_,C,I,x,A=0,V=0,B=0;for(B=k.ct,_=k.qe,A=n.wt,V=n.ht,C=n.write,I=C=258&&_>=10&&(n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,g=m(d,p,i,y,c,b,n,k),B=k.ct,_=k.qe,A=n.wt,V=n.ht,C=n.write,I=CV;){if(0===_)return n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,n.kt(k,g);g=0,_--,A|=(255&k.dt(B++))<>>=s[S+1],V-=s[S+1],z=s[S],0===z){u=s[S+2],r=6;break}if(0!=(16&z)){w=15&z,f=s[S+2],r=2;break}if(0==(64&z)){a=z,l=S/3+s[S+2];break}if(0!=(32&z)){r=7;break}return r=9,k.Qe="invalid literal/length code",g=t,n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,n.kt(k,g);case 2:for(v=w;v>V;){if(0===_)return n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,n.kt(k,g);g=0,_--,A|=(255&k.dt(B++))<>=v,V-=v,a=p,s=c,l=b,r=3;case 3:for(v=a;v>V;){if(0===_)return n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,n.kt(k,g);g=0,_--,A|=(255&k.dt(B++))<>=s[S+1],V-=s[S+1],z=s[S],0!=(16&z)){w=15&z,h=s[S+2],r=4;break}if(0==(64&z)){a=z,l=S/3+s[S+2];break}return r=9,k.Qe="invalid distance code",g=t,n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,n.kt(k,g);case 4:for(v=w;v>V;){if(0===_)return n.wt=A,n.ht=V,k.qe=_,k.Ye+=B-k.ct,k.ct=B,n.write=C,n.kt(k,g);g=0,_--,A|=(255&k.dt(B++))<>=v,V-=v,r=5;case 5:for(x=C-h;0>x;)x+=n.end;for(;0!==f;){if(0===I&&(C==n.end&&0!==n.read&&(C=0,I=C7&&(V-=8,_++,B--),n.write=C,g=n.kt(k,g),C=n.write,I=C{}}d.vt=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=f,r[0]=l,0);const y=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function b(n,r){const f=this;let l,a=0,u=0,w=0,h=0;const b=[0],m=[0],k=new p;let g=0,v=new c(4320);const S=new d;f.ht=0,f.wt=0,f.yt=new s(r),f.end=r,f.read=0,f.write=0,f.reset=(e,t)=>{t&&(t[0]=0),6==a&&k.gt(e),a=0,f.ht=0,f.wt=0,f.read=f.write=0},f.reset(n,null),f.kt=(e,t)=>{let n,r,s;return r=e.ft,s=f.read,n=(s>f.write?f.end:f.write)-s,n>e.ot&&(n=e.ot),0!==n&&t==i&&(t=0),e.ot-=n,e.Ze+=n,e.st.set(f.yt.subarray(s,s+n),r),r+=n,s+=n,s==f.end&&(s=0,f.write==f.end&&(f.write=0),n=f.write-s,n>e.ot&&(n=e.ot),0!==n&&t==i&&(t=0),e.ot-=n,e.Ze+=n,e.st.set(f.yt.subarray(s,s+n),r),r+=n,s+=n),e.ft=r,f.read=s,t},f.bt=(n,r)=>{let s,i,c,p,z,_,C,I;for(p=n.ct,z=n.qe,i=f.wt,c=f.ht,_=f.write,C=_c;){if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);r=0,z--,i|=(255&n.dt(p++))<>>1){case 0:i>>>=3,c-=3,s=7&c,i>>>=s,c-=s,a=1;break;case 1:x=[],A=[],V=[[]],B=[[]],d.vt(x,A,V,B),k.init(x[0],A[0],V[0],0,B[0],0),i>>>=3,c-=3,a=6;break;case 2:i>>>=3,c-=3,a=3;break;case 3:return i>>>=3,c-=3,a=9,n.Qe="invalid block type",r=t,f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r)}break;case 1:for(;32>c;){if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);r=0,z--,i|=(255&n.dt(p++))<>>16&65535)!=(65535&i))return a=9,n.Qe="invalid stored block lengths",r=t,f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);u=65535&i,i=c=0,a=0!==u?2:0!==g?7:0;break;case 2:if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);if(0===C&&(_==f.end&&0!==f.read&&(_=0,C=_z&&(s=z),s>C&&(s=C),f.yt.set(n.Ge(p,s),_),p+=s,z-=s,_+=s,C-=s,0!=(u-=s))break;a=0!==g?7:0;break;case 3:for(;14>c;){if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);r=0,z--,i|=(255&n.dt(p++))<29||(s>>5&31)>29)return a=9,n.Qe="too many length or distance symbols",r=t,f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);if(s=258+(31&s)+(s>>5&31),!l||l.lengthI;I++)l[I]=0;i>>>=14,c-=14,h=0,a=4;case 4:for(;4+(w>>>10)>h;){for(;3>c;){if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);r=0,z--,i|=(255&n.dt(p++))<>>=3,c-=3}for(;19>h;)l[y[h++]]=0;if(b[0]=7,s=S.lt(l,b,m,v,n),0!=s)return(r=s)==t&&(l=null,a=9),f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);h=0,a=5;case 5:for(;s=w,258+(31&s)+(s>>5&31)>h;){let e,u;for(s=b[0];s>c;){if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);r=0,z--,i|=(255&n.dt(p++))<u)i>>>=s,c-=s,l[h++]=u;else{for(I=18==u?7:u-14,e=18==u?11:3;s+I>c;){if(0===z)return f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);r=0,z--,i|=(255&n.dt(p++))<>>=s,c-=s,e+=i&o[I],i>>>=I,c-=I,I=h,s=w,I+e>258+(31&s)+(s>>5&31)||16==u&&1>I)return l=null,a=9,n.Qe="invalid bit length repeat",r=t,f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);u=16==u?l[I-1]:0;do{l[I++]=u}while(0!=--e);h=I}}if(m[0]=-1,D=[],E=[],M=[],T=[],D[0]=9,E[0]=6,s=w,s=S.ut(257+(31&s),1+(s>>5&31),l,D,E,M,T,v,n),0!=s)return s==t&&(l=null,a=9),r=s,f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,f.kt(n,r);k.init(D[0],E[0],v,M[0],v,T[0]),a=6;case 6:if(f.wt=i,f.ht=c,n.qe=z,n.Ye+=p-n.ct,n.ct=p,f.write=_,1!=(r=k.bt(f,n,r)))return f.kt(n,r);if(r=0,k.gt(n),p=n.ct,z=n.qe,i=f.wt,c=f.ht,_=f.write,C=_{f.reset(e,null),f.yt=null,v=null},f.St=(e,t,n)=>{f.yt.set(e.subarray(t,t+n),0),f.read=f.write=n},f.zt=()=>1==a?1:0}const m=13,k=[0,0,255,255];function g(){const n=this;function r(t){return t&&t._t?(t.Ye=t.Ze=0,t.Qe=null,t._t.mode=7,t._t.Ct.reset(t,null),0):e}n.mode=0,n.method=0,n.It=[0],n.xt=0,n.marker=0,n.At=0,n.Vt=e=>(n.Ct&&n.Ct.gt(e),n.Ct=null,0),n.Bt=(t,s)=>(t.Qe=null,n.Ct=null,8>s||s>15?(n.Vt(t),e):(n.At=s,t._t.Ct=new b(t,1<{let s,o;if(!n||!n._t||!n.it)return e;const c=n._t;for(r=4==r?i:0,s=i;;)switch(c.mode){case 0:if(0===n.qe)return s;if(s=r,n.qe--,n.Ye++,8!=(15&(c.method=n.dt(n.ct++)))){c.mode=m,n.Qe="unknown compression method",c.marker=5;break}if(8+(c.method>>4)>c.At){c.mode=m,n.Qe="invalid win size",c.marker=5;break}c.mode=1;case 1:if(0===n.qe)return s;if(s=r,n.qe--,n.Ye++,o=255&n.dt(n.ct++),((c.method<<8)+o)%31!=0){c.mode=m,n.Qe="incorrect header check",c.marker=5;break}if(0==(32&o)){c.mode=7;break}c.mode=2;case 2:if(0===n.qe)return s;s=r,n.qe--,n.Ye++,c.xt=(255&n.dt(n.ct++))<<24&4278190080,c.mode=3;case 3:if(0===n.qe)return s;s=r,n.qe--,n.Ye++,c.xt+=(255&n.dt(n.ct++))<<16&16711680,c.mode=4;case 4:if(0===n.qe)return s;s=r,n.qe--,n.Ye++,c.xt+=(255&n.dt(n.ct++))<<8&65280,c.mode=5;case 5:return 0===n.qe?s:(s=r,n.qe--,n.Ye++,c.xt+=255&n.dt(n.ct++),c.mode=6,2);case 6:return c.mode=m,n.Qe="need dictionary",c.marker=0,e;case 7:if(s=c.Ct.bt(n,s),s==t){c.mode=m,c.marker=0;break}if(0==s&&(s=r),1!=s)return s;s=r,c.Ct.reset(n,c.It),c.mode=12;case 12:return n.qe=0,1;case m:return t;default:return e}},n.Et=(t,n,r)=>{let s=0,i=r;if(!t||!t._t||6!=t._t.mode)return e;const o=t._t;return i<1<{let s,o,c,f,l;if(!n||!n._t)return e;const a=n._t;if(a.mode!=m&&(a.mode=m,a.marker=0),0===(s=n.qe))return i;for(o=n.ct,c=a.marker;0!==s&&4>c;)n.dt(o)==k[c]?c++:c=0!==n.dt(o)?0:4-c,o++,s--;return n.Ye+=o-n.ct,n.ct=o,n.qe=s,a.marker=c,4!=c?t:(f=n.Ye,l=n.Ze,r(n),n.Ye=f,n.Ze=l,a.mode=7,0)},n.Tt=t=>t&&t._t&&t._t.Ct?t._t.Ct.zt():e}function v(){}return v.prototype={Bt(e){const t=this;return t._t=new g,e||(e=15),t._t.Bt(t,e)},Dt(t){const n=this;return n._t?n._t.Dt(n,t):e},Vt(){const t=this;if(!t._t)return e;const n=t._t.Vt(t);return t._t=null,n},Mt(){const t=this;return t._t?t._t.Mt(t):e},Et(t,n){const r=this;return r._t?r._t.Et(r,t,n):e},dt(e){return this.it[e]},Ge(e,t){return this.it.subarray(e,e+t)}},function(e){const t=new v,o=e&&e.chunkSize?n.floor(2*e.chunkSize):131072,c=new s(o);let f=!1;t.Bt(),t.st=c,this.append=(e,n)=>{const l=[];let a,u,w=0,h=0,d=0;if(0!==e.length){t.ct=0,t.it=e,t.qe=e.length;do{if(t.ft=0,t.ot=o,0!==t.qe||f||(t.ct=0,f=!0),a=t.Dt(0),f&&a===i){if(0!==t.qe)throw new r("inflating: bad input")}else if(0!==a&&1!==a)throw new r("inflating: "+t.Qe);if((f||1===a)&&t.qe===e.length)throw new r("inflating: bad input");t.ft&&(t.ft===o?l.push(new s(c)):l.push(c.slice(0,t.ft))),d+=t.ft,n&&t.ct>0&&t.ct!=w&&(n(t.ct),w=t.ct)}while(t.qe>0||0===t.ot);return l.length>1?(u=new s(d),l.forEach((e=>{u.set(e,h),h+=e.length}))):u=l[0]||new s,u}},this.flush=()=>{t.Vt()}}})();self.initCodec=()=>{self.Deflate=Se,self.Inflate=ze};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}});}};
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ function getMimeType() {
+ return "application/octet-stream";
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ var streamCodecShim = (library, options = {}, registerDataHandler) => {
+ return {
+ Deflate: createCodecClass(library.Deflate, options.deflate, registerDataHandler),
+ Inflate: createCodecClass(library.Inflate, options.inflate, registerDataHandler)
+ };
+ };
+
+ function createCodecClass(constructor, constructorOptions, registerDataHandler) {
+ return class {
+
+ constructor(options) {
+ const codecAdapter = this;
+ const onData = data => {
+ if (codecAdapter.pendingData) {
+ const { pendingData } = codecAdapter;
+ codecAdapter.pendingData = new Uint8Array(pendingData.length + data.length);
+ pendingData.set(pendingData, 0);
+ pendingData.set(data, pendingData.length);
+ } else {
+ codecAdapter.pendingData = new Uint8Array(data);
+ }
+ };
+ if (Object.hasOwn(options, "level") && options.level === undefined) {
+ delete options.level;
+ }
+ codecAdapter.codec = new constructor(Object.assign({}, constructorOptions, options));
+ registerDataHandler(codecAdapter.codec, onData);
+ }
+ append(data) {
+ this.codec.push(data);
+ return getResponse(this);
+ }
+ flush() {
+ this.codec.push(new Uint8Array(), true);
+ return getResponse(this);
+ }
+ };
+
+ function getResponse(codec) {
+ if (codec.pendingData) {
+ const output = codec.pendingData;
+ codec.pendingData = null;
+ return output;
+ } else {
+ return new Uint8Array();
+ }
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const table = [];
+ for (let i = 0; i < 256; i++) {
+ let t = i;
+ for (let j = 0; j < 8; j++) {
+ if (t & 1) {
+ t = (t >>> 1) ^ 0xEDB88320;
+ } else {
+ t = t >>> 1;
+ }
+ }
+ table[i] = t;
+ }
+
+ class Crc32 {
+
+ constructor(crc) {
+ this.crc = crc || -1;
+ }
+
+ append(data) {
+ let crc = this.crc | 0;
+ for (let offset = 0, length = data.length | 0; offset < length; offset++) {
+ crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF];
+ }
+ this.crc = crc;
+ }
+
+ get() {
+ return ~this.crc;
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ class Crc32Stream extends TransformStream {
+
+ constructor() {
+ super({
+ start() {
+ this.crc32 = new Crc32();
+ },
+ transform(chunk) {
+ this.crc32.append(chunk);
+ },
+ flush(controller) {
+ const value = new Uint8Array(4);
+ const dataView = new DataView(value.buffer);
+ dataView.setUint32(0, this.crc32.get());
+ controller.enqueue(value);
+ }
+ });
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ function encodeText(value) {
+ if (typeof TextEncoder == "undefined") {
+ value = unescape(encodeURIComponent(value));
+ const result = new Uint8Array(value.length);
+ for (let i = 0; i < result.length; i++) {
+ result[i] = value.charCodeAt(i);
+ }
+ return result;
+ } else {
+ return new TextEncoder().encode(value);
+ }
+ }
+
+ // Derived from https://github.com/xqdoo00o/jszip/blob/master/lib/sjcl.js and https://github.com/bitwiseshiftleft/sjcl
+
+ /*// deno-lint-ignore-file no-this-alias *
+
+ /*
+ * SJCL is open. You can use, modify and redistribute it under a BSD
+ * license or under the GNU GPL, version 2.0.
+ */
+
+ /** @fileOverview Javascript cryptography implementation.
+ *
+ * Crush to remove comments, shorten variable names and
+ * generally reduce transmission size.
+ *
+ * @author Emily Stark
+ * @author Mike Hamburg
+ * @author Dan Boneh
+ */
+
+ /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
+
+ /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
+ *
+ * @author Emily Stark
+ * @author Mike Hamburg
+ * @author Dan Boneh
+ */
+
+ /**
+ * Arrays of bits, encoded as arrays of Numbers.
+ * @namespace
+ * @description
+ *
+ * These objects are the currency accepted by SJCL's crypto functions.
+ *
+ *
+ *
+ * Most of our crypto primitives operate on arrays of 4-byte words internally,
+ * but many of them can take arguments that are not a multiple of 4 bytes.
+ * This library encodes arrays of bits (whose size need not be a multiple of 8
+ * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
+ * array of words, 32 bits at a time. Since the words are double-precision
+ * floating point numbers, they fit some extra data. We use this (in a private,
+ * possibly-changing manner) to encode the number of bits actually present
+ * in the last word of the array.
+ *
+ *
+ *
+ * Because bitwise ops clear this out-of-band data, these arrays can be passed
+ * to ciphers like AES which want arrays of words.
+ *
+ */
+ const bitArray = {
+ /**
+ * Concatenate two bit arrays.
+ * @param {bitArray} a1 The first array.
+ * @param {bitArray} a2 The second array.
+ * @return {bitArray} The concatenation of a1 and a2.
+ */
+ concat(a1, a2) {
+ if (a1.length === 0 || a2.length === 0) {
+ return a1.concat(a2);
+ }
+
+ const last = a1[a1.length - 1], shift = bitArray.getPartial(last);
+ if (shift === 32) {
+ return a1.concat(a2);
+ } else {
+ return bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1));
+ }
+ },
+
+ /**
+ * Find the length of an array of bits.
+ * @param {bitArray} a The array.
+ * @return {Number} The length of a, in bits.
+ */
+ bitLength(a) {
+ const l = a.length;
+ if (l === 0) {
+ return 0;
+ }
+ const x = a[l - 1];
+ return (l - 1) * 32 + bitArray.getPartial(x);
+ },
+
+ /**
+ * Truncate an array.
+ * @param {bitArray} a The array.
+ * @param {Number} len The length to truncate to, in bits.
+ * @return {bitArray} A new array, truncated to len bits.
+ */
+ clamp(a, len) {
+ if (a.length * 32 < len) {
+ return a;
+ }
+ a = a.slice(0, Math.ceil(len / 32));
+ const l = a.length;
+ len = len & 31;
+ if (l > 0 && len) {
+ a[l - 1] = bitArray.partial(len, a[l - 1] & 0x80000000 >> (len - 1), 1);
+ }
+ return a;
+ },
+
+ /**
+ * Make a partial word for a bit array.
+ * @param {Number} len The number of bits in the word.
+ * @param {Number} x The bits.
+ * @param {Number} [_end=0] Pass 1 if x has already been shifted to the high side.
+ * @return {Number} The partial word.
+ */
+ partial(len, x, _end) {
+ if (len === 32) {
+ return x;
+ }
+ return (_end ? x | 0 : x << (32 - len)) + len * 0x10000000000;
+ },
+
+ /**
+ * Get the number of bits used by a partial word.
+ * @param {Number} x The partial word.
+ * @return {Number} The number of bits used by the partial word.
+ */
+ getPartial(x) {
+ return Math.round(x / 0x10000000000) || 32;
+ },
+
+ /** Shift an array right.
+ * @param {bitArray} a The array to shift.
+ * @param {Number} shift The number of bits to shift.
+ * @param {Number} [carry=0] A byte to carry in
+ * @param {bitArray} [out=[]] An array to prepend to the output.
+ * @private
+ */
+ _shiftRight(a, shift, carry, out) {
+ if (out === undefined) {
+ out = [];
+ }
+
+ for (; shift >= 32; shift -= 32) {
+ out.push(carry);
+ carry = 0;
+ }
+ if (shift === 0) {
+ return out.concat(a);
+ }
+
+ for (let i = 0; i < a.length; i++) {
+ out.push(carry | a[i] >>> shift);
+ carry = a[i] << (32 - shift);
+ }
+ const last2 = a.length ? a[a.length - 1] : 0;
+ const shift2 = bitArray.getPartial(last2);
+ out.push(bitArray.partial(shift + shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(), 1));
+ return out;
+ }
+ };
+
+ /** @fileOverview Bit array codec implementations.
+ *
+ * @author Emily Stark
+ * @author Mike Hamburg
+ * @author Dan Boneh
+ */
+
+ /**
+ * Arrays of bytes
+ * @namespace
+ */
+ const codec = {
+ bytes: {
+ /** Convert from a bitArray to an array of bytes. */
+ fromBits(arr) {
+ const bl = bitArray.bitLength(arr);
+ const byteLength = bl / 8;
+ const out = new Uint8Array(byteLength);
+ let tmp;
+ for (let i = 0; i < byteLength; i++) {
+ if ((i & 3) === 0) {
+ tmp = arr[i / 4];
+ }
+ out[i] = tmp >>> 24;
+ tmp <<= 8;
+ }
+ return out;
+ },
+ /** Convert from an array of bytes to a bitArray. */
+ toBits(bytes) {
+ const out = [];
+ let i;
+ let tmp = 0;
+ for (i = 0; i < bytes.length; i++) {
+ tmp = tmp << 8 | bytes[i];
+ if ((i & 3) === 3) {
+ out.push(tmp);
+ tmp = 0;
+ }
+ }
+ if (i & 3) {
+ out.push(bitArray.partial(8 * (i & 3), tmp));
+ }
+ return out;
+ }
+ }
+ };
+
+ const hash = {};
+
+ /**
+ * Context for a SHA-1 operation in progress.
+ * @constructor
+ */
+ hash.sha1 = function (hash) {
+ if (hash) {
+ this._h = hash._h.slice(0);
+ this._buffer = hash._buffer.slice(0);
+ this._length = hash._length;
+ } else {
+ this.reset();
+ }
+ };
+
+ hash.sha1.prototype = {
+ /**
+ * The hash's block size, in bits.
+ * @constant
+ */
+ blockSize: 512,
+
+ /**
+ * Reset the hash state.
+ * @return this
+ */
+ reset() {
+ const sha1 = this;
+ sha1._h = this._init.slice(0);
+ sha1._buffer = [];
+ sha1._length = 0;
+ return sha1;
+ },
+
+ /**
+ * Input several words to the hash.
+ * @param {bitArray|String} data the data to hash.
+ * @return this
+ */
+ update(data) {
+ const sha1 = this;
+ if (typeof data === "string") {
+ data = codec.utf8String.toBits(data);
+ }
+ const b = sha1._buffer = bitArray.concat(sha1._buffer, data);
+ const ol = sha1._length;
+ const nl = sha1._length = ol + bitArray.bitLength(data);
+ if (nl > 9007199254740991) {
+ throw new Error("Cannot hash more than 2^53 - 1 bits");
+ }
+ const c = new Uint32Array(b);
+ let j = 0;
+ for (let i = sha1.blockSize + ol - ((sha1.blockSize + ol) & (sha1.blockSize - 1)); i <= nl;
+ i += sha1.blockSize) {
+ sha1._block(c.subarray(16 * j, 16 * (j + 1)));
+ j += 1;
+ }
+ b.splice(0, 16 * j);
+ return sha1;
+ },
+
+ /**
+ * Complete hashing and output the hash value.
+ * @return {bitArray} The hash value, an array of 5 big-endian words. TODO
+ */
+ finalize() {
+ const sha1 = this;
+ let b = sha1._buffer;
+ const h = sha1._h;
+
+ // Round out and push the buffer
+ b = bitArray.concat(b, [bitArray.partial(1, 1)]);
+ // Round out the buffer to a multiple of 16 words, less the 2 length words.
+ for (let i = b.length + 2; i & 15; i++) {
+ b.push(0);
+ }
+
+ // append the length
+ b.push(Math.floor(sha1._length / 0x100000000));
+ b.push(sha1._length | 0);
+
+ while (b.length) {
+ sha1._block(b.splice(0, 16));
+ }
+
+ sha1.reset();
+ return h;
+ },
+
+ /**
+ * The SHA-1 initialization vector.
+ * @private
+ */
+ _init: [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0],
+
+ /**
+ * The SHA-1 hash key.
+ * @private
+ */
+ _key: [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6],
+
+ /**
+ * The SHA-1 logical functions f(0), f(1), ..., f(79).
+ * @private
+ */
+ _f(t, b, c, d) {
+ if (t <= 19) {
+ return (b & c) | (~b & d);
+ } else if (t <= 39) {
+ return b ^ c ^ d;
+ } else if (t <= 59) {
+ return (b & c) | (b & d) | (c & d);
+ } else if (t <= 79) {
+ return b ^ c ^ d;
+ }
+ },
+
+ /**
+ * Circular left-shift operator.
+ * @private
+ */
+ _S(n, x) {
+ return (x << n) | (x >>> 32 - n);
+ },
+
+ /**
+ * Perform one cycle of SHA-1.
+ * @param {Uint32Array|bitArray} words one block of words.
+ * @private
+ */
+ _block(words) {
+ const sha1 = this;
+ const h = sha1._h;
+ // When words is passed to _block, it has 16 elements. SHA1 _block
+ // function extends words with new elements (at the end there are 80 elements).
+ // The problem is that if we use Uint32Array instead of Array,
+ // the length of Uint32Array cannot be changed. Thus, we replace words with a
+ // normal Array here.
+ const w = Array(80); // do not use Uint32Array here as the instantiation is slower
+ for (let j = 0; j < 16; j++) {
+ w[j] = words[j];
+ }
+
+ let a = h[0];
+ let b = h[1];
+ let c = h[2];
+ let d = h[3];
+ let e = h[4];
+
+ for (let t = 0; t <= 79; t++) {
+ if (t >= 16) {
+ w[t] = sha1._S(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]);
+ }
+ const tmp = (sha1._S(5, a) + sha1._f(t, b, c, d) + e + w[t] +
+ sha1._key[Math.floor(t / 20)]) | 0;
+ e = d;
+ d = c;
+ c = sha1._S(30, b);
+ b = a;
+ a = tmp;
+ }
+
+ h[0] = (h[0] + a) | 0;
+ h[1] = (h[1] + b) | 0;
+ h[2] = (h[2] + c) | 0;
+ h[3] = (h[3] + d) | 0;
+ h[4] = (h[4] + e) | 0;
+ }
+ };
+
+ /** @fileOverview Low-level AES implementation.
+ *
+ * This file contains a low-level implementation of AES, optimized for
+ * size and for efficiency on several browsers. It is based on
+ * OpenSSL's aes_core.c, a public-domain implementation by Vincent
+ * Rijmen, Antoon Bosselaers and Paulo Barreto.
+ *
+ * An older version of this implementation is available in the public
+ * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
+ * Stanford University 2008-2010 and BSD-licensed for liability
+ * reasons.
+ *
+ * @author Emily Stark
+ * @author Mike Hamburg
+ * @author Dan Boneh
+ */
+
+ const cipher = {};
+
+ /**
+ * Schedule out an AES key for both encryption and decryption. This
+ * is a low-level class. Use a cipher mode to do bulk encryption.
+ *
+ * @constructor
+ * @param {Array} key The key as an array of 4, 6 or 8 words.
+ */
+ cipher.aes = class {
+ constructor(key) {
+ /**
+ * The expanded S-box and inverse S-box tables. These will be computed
+ * on the client so that we don't have to send them down the wire.
+ *
+ * There are two tables, _tables[0] is for encryption and
+ * _tables[1] is for decryption.
+ *
+ * The first 4 sub-tables are the expanded S-box with MixColumns. The
+ * last (_tables[01][4]) is the S-box itself.
+ *
+ * @private
+ */
+ const aes = this;
+ aes._tables = [[[], [], [], [], []], [[], [], [], [], []]];
+
+ if (!aes._tables[0][0][0]) {
+ aes._precompute();
+ }
+
+ const sbox = aes._tables[0][4];
+ const decTable = aes._tables[1];
+ const keyLen = key.length;
+
+ let i, encKey, decKey, rcon = 1;
+
+ if (keyLen !== 4 && keyLen !== 6 && keyLen !== 8) {
+ throw new Error("invalid aes key size");
+ }
+
+ aes._key = [encKey = key.slice(0), decKey = []];
+
+ // schedule encryption keys
+ for (i = keyLen; i < 4 * keyLen + 28; i++) {
+ let tmp = encKey[i - 1];
+
+ // apply sbox
+ if (i % keyLen === 0 || (keyLen === 8 && i % keyLen === 4)) {
+ tmp = sbox[tmp >>> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16 ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255];
+
+ // shift rows and add rcon
+ if (i % keyLen === 0) {
+ tmp = tmp << 8 ^ tmp >>> 24 ^ rcon << 24;
+ rcon = rcon << 1 ^ (rcon >> 7) * 283;
+ }
+ }
+
+ encKey[i] = encKey[i - keyLen] ^ tmp;
+ }
+
+ // schedule decryption keys
+ for (let j = 0; i; j++, i--) {
+ const tmp = encKey[j & 3 ? i : i - 4];
+ if (i <= 4 || j < 4) {
+ decKey[j] = tmp;
+ } else {
+ decKey[j] = decTable[0][sbox[tmp >>> 24]] ^
+ decTable[1][sbox[tmp >> 16 & 255]] ^
+ decTable[2][sbox[tmp >> 8 & 255]] ^
+ decTable[3][sbox[tmp & 255]];
+ }
+ }
+ }
+ // public
+ /* Something like this might appear here eventually
+ name: "AES",
+ blockSize: 4,
+ keySizes: [4,6,8],
+ */
+
+ /**
+ * Encrypt an array of 4 big-endian words.
+ * @param {Array} data The plaintext.
+ * @return {Array} The ciphertext.
+ */
+ encrypt(data) {
+ return this._crypt(data, 0);
+ }
+
+ /**
+ * Decrypt an array of 4 big-endian words.
+ * @param {Array} data The ciphertext.
+ * @return {Array} The plaintext.
+ */
+ decrypt(data) {
+ return this._crypt(data, 1);
+ }
+
+ /**
+ * Expand the S-box tables.
+ *
+ * @private
+ */
+ _precompute() {
+ const encTable = this._tables[0];
+ const decTable = this._tables[1];
+ const sbox = encTable[4];
+ const sboxInv = decTable[4];
+ const d = [];
+ const th = [];
+ let xInv, x2, x4, x8;
+
+ // Compute double and third tables
+ for (let i = 0; i < 256; i++) {
+ th[(d[i] = i << 1 ^ (i >> 7) * 283) ^ i] = i;
+ }
+
+ for (let x = xInv = 0; !sbox[x]; x ^= x2 || 1, xInv = th[xInv] || 1) {
+ // Compute sbox
+ let s = xInv ^ xInv << 1 ^ xInv << 2 ^ xInv << 3 ^ xInv << 4;
+ s = s >> 8 ^ s & 255 ^ 99;
+ sbox[x] = s;
+ sboxInv[s] = x;
+
+ // Compute MixColumns
+ x8 = d[x4 = d[x2 = d[x]]];
+ let tDec = x8 * 0x1010101 ^ x4 * 0x10001 ^ x2 * 0x101 ^ x * 0x1010100;
+ let tEnc = d[s] * 0x101 ^ s * 0x1010100;
+
+ for (let i = 0; i < 4; i++) {
+ encTable[i][x] = tEnc = tEnc << 24 ^ tEnc >>> 8;
+ decTable[i][s] = tDec = tDec << 24 ^ tDec >>> 8;
+ }
+ }
+
+ // Compactify. Considerable speedup on Firefox.
+ for (let i = 0; i < 5; i++) {
+ encTable[i] = encTable[i].slice(0);
+ decTable[i] = decTable[i].slice(0);
+ }
+ }
+
+ /**
+ * Encryption and decryption core.
+ * @param {Array} input Four words to be encrypted or decrypted.
+ * @param dir The direction, 0 for encrypt and 1 for decrypt.
+ * @return {Array} The four encrypted or decrypted words.
+ * @private
+ */
+ _crypt(input, dir) {
+ if (input.length !== 4) {
+ throw new Error("invalid aes block size");
+ }
+
+ const key = this._key[dir];
+
+ const nInnerRounds = key.length / 4 - 2;
+ const out = [0, 0, 0, 0];
+ const table = this._tables[dir];
+
+ // load up the tables
+ const t0 = table[0];
+ const t1 = table[1];
+ const t2 = table[2];
+ const t3 = table[3];
+ const sbox = table[4];
+
+ // state variables a,b,c,d are loaded with pre-whitened data
+ let a = input[0] ^ key[0];
+ let b = input[dir ? 3 : 1] ^ key[1];
+ let c = input[2] ^ key[2];
+ let d = input[dir ? 1 : 3] ^ key[3];
+ let kIndex = 4;
+ let a2, b2, c2;
+
+ // Inner rounds. Cribbed from OpenSSL.
+ for (let i = 0; i < nInnerRounds; i++) {
+ a2 = t0[a >>> 24] ^ t1[b >> 16 & 255] ^ t2[c >> 8 & 255] ^ t3[d & 255] ^ key[kIndex];
+ b2 = t0[b >>> 24] ^ t1[c >> 16 & 255] ^ t2[d >> 8 & 255] ^ t3[a & 255] ^ key[kIndex + 1];
+ c2 = t0[c >>> 24] ^ t1[d >> 16 & 255] ^ t2[a >> 8 & 255] ^ t3[b & 255] ^ key[kIndex + 2];
+ d = t0[d >>> 24] ^ t1[a >> 16 & 255] ^ t2[b >> 8 & 255] ^ t3[c & 255] ^ key[kIndex + 3];
+ kIndex += 4;
+ a = a2; b = b2; c = c2;
+ }
+
+ // Last round.
+ for (let i = 0; i < 4; i++) {
+ out[dir ? 3 & -i : i] =
+ sbox[a >>> 24] << 24 ^
+ sbox[b >> 16 & 255] << 16 ^
+ sbox[c >> 8 & 255] << 8 ^
+ sbox[d & 255] ^
+ key[kIndex++];
+ a2 = a; a = b; b = c; c = d; d = a2;
+ }
+
+ return out;
+ }
+ };
+
+ /**
+ * Random values
+ * @namespace
+ */
+ const random = {
+ /**
+ * Generate random words with pure js, cryptographically not as strong & safe as native implementation.
+ * @param {TypedArray} typedArray The array to fill.
+ * @return {TypedArray} The random values.
+ */
+ getRandomValues(typedArray) {
+ const words = new Uint32Array(typedArray.buffer);
+ const r = (m_w) => {
+ let m_z = 0x3ade68b1;
+ const mask = 0xffffffff;
+ return function () {
+ m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
+ m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
+ const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5;
+ return result * (Math.random() > .5 ? 1 : -1);
+ };
+ };
+ for (let i = 0, rcache; i < typedArray.length; i += 4) {
+ const _r = r((rcache || Math.random()) * 0x100000000);
+ rcache = _r() * 0x3ade67b7;
+ words[i / 4] = (_r() * 0x100000000) | 0;
+ }
+ return typedArray;
+ }
+ };
+
+ /** @fileOverview CTR mode implementation.
+ *
+ * Special thanks to Roy Nicholson for pointing out a bug in our
+ * implementation.
+ *
+ * @author Emily Stark
+ * @author Mike Hamburg
+ * @author Dan Boneh
+ */
+
+ /** Brian Gladman's CTR Mode.
+ * @constructor
+ * @param {Object} _prf The aes instance to generate key.
+ * @param {bitArray} _iv The iv for ctr mode, it must be 128 bits.
+ */
+
+ const mode = {};
+
+ /**
+ * Brian Gladman's CTR Mode.
+ * @namespace
+ */
+ mode.ctrGladman = class {
+ constructor(prf, iv) {
+ this._prf = prf;
+ this._initIv = iv;
+ this._iv = iv;
+ }
+
+ reset() {
+ this._iv = this._initIv;
+ }
+
+ /** Input some data to calculate.
+ * @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
+ */
+ update(data) {
+ return this.calculate(this._prf, data, this._iv);
+ }
+
+ incWord(word) {
+ if (((word >> 24) & 0xff) === 0xff) { //overflow
+ let b1 = (word >> 16) & 0xff;
+ let b2 = (word >> 8) & 0xff;
+ let b3 = word & 0xff;
+
+ if (b1 === 0xff) { // overflow b1
+ b1 = 0;
+ if (b2 === 0xff) {
+ b2 = 0;
+ if (b3 === 0xff) {
+ b3 = 0;
+ } else {
+ ++b3;
+ }
+ } else {
+ ++b2;
+ }
+ } else {
+ ++b1;
+ }
+
+ word = 0;
+ word += (b1 << 16);
+ word += (b2 << 8);
+ word += b3;
+ } else {
+ word += (0x01 << 24);
+ }
+ return word;
+ }
+
+ incCounter(counter) {
+ if ((counter[0] = this.incWord(counter[0])) === 0) {
+ // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
+ counter[1] = this.incWord(counter[1]);
+ }
+ }
+
+ calculate(prf, data, iv) {
+ let l;
+ if (!(l = data.length)) {
+ return [];
+ }
+ const bl = bitArray.bitLength(data);
+ for (let i = 0; i < l; i += 4) {
+ this.incCounter(iv);
+ const e = prf.encrypt(iv);
+ data[i] ^= e[0];
+ data[i + 1] ^= e[1];
+ data[i + 2] ^= e[2];
+ data[i + 3] ^= e[3];
+ }
+ return bitArray.clamp(data, bl);
+ }
+ };
+
+ const misc = {
+ importKey(password) {
+ return new misc.hmacSha1(codec.bytes.toBits(password));
+ },
+ pbkdf2(prf, salt, count, length) {
+ count = count || 10000;
+ if (length < 0 || count < 0) {
+ throw new Error("invalid params to pbkdf2");
+ }
+ const byteLength = ((length >> 5) + 1) << 2;
+ let u, ui, i, j, k;
+ const arrayBuffer = new ArrayBuffer(byteLength);
+ const out = new DataView(arrayBuffer);
+ let outLength = 0;
+ const b = bitArray;
+ salt = codec.bytes.toBits(salt);
+ for (k = 1; outLength < (byteLength || 1); k++) {
+ u = ui = prf.encrypt(b.concat(salt, [k]));
+ for (i = 1; i < count; i++) {
+ ui = prf.encrypt(ui);
+ for (j = 0; j < ui.length; j++) {
+ u[j] ^= ui[j];
+ }
+ }
+ for (i = 0; outLength < (byteLength || 1) && i < u.length; i++) {
+ out.setInt32(outLength, u[i]);
+ outLength += 4;
+ }
+ }
+ return arrayBuffer.slice(0, length / 8);
+ }
+ };
+
+ /** @fileOverview HMAC implementation.
+ *
+ * @author Emily Stark
+ * @author Mike Hamburg
+ * @author Dan Boneh
+ */
+
+ /** HMAC with the specified hash function.
+ * @constructor
+ * @param {bitArray} key the key for HMAC.
+ * @param {Object} [Hash=hash.sha1] The hash function to use.
+ */
+ misc.hmacSha1 = class {
+
+ constructor(key) {
+ const hmac = this;
+ const Hash = hmac._hash = hash.sha1;
+ const exKey = [[], []];
+ const bs = Hash.prototype.blockSize / 32;
+ hmac._baseHash = [new Hash(), new Hash()];
+
+ if (key.length > bs) {
+ key = Hash.hash(key);
+ }
+
+ for (let i = 0; i < bs; i++) {
+ exKey[0][i] = key[i] ^ 0x36363636;
+ exKey[1][i] = key[i] ^ 0x5C5C5C5C;
+ }
+
+ hmac._baseHash[0].update(exKey[0]);
+ hmac._baseHash[1].update(exKey[1]);
+ hmac._resultHash = new Hash(hmac._baseHash[0]);
+ }
+ reset() {
+ const hmac = this;
+ hmac._resultHash = new hmac._hash(hmac._baseHash[0]);
+ hmac._updated = false;
+ }
+
+ update(data) {
+ const hmac = this;
+ hmac._updated = true;
+ hmac._resultHash.update(data);
+ }
+
+ digest() {
+ const hmac = this;
+ const w = hmac._resultHash.finalize();
+ const result = new (hmac._hash)(hmac._baseHash[1]).update(w).finalize();
+
+ hmac.reset();
+
+ return result;
+ }
+
+ encrypt(data) {
+ if (!this._updated) {
+ this.update(data);
+ return this.digest(data);
+ } else {
+ throw new Error("encrypt on already updated hmac called!");
+ }
+ }
+ };
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ /* global crypto */
+
+ const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != "undefined" && typeof crypto.getRandomValues == "function";
+
+ const ERR_INVALID_PASSWORD = "Invalid password";
+
+ function getRandomValues(array) {
+ if (GET_RANDOM_VALUES_SUPPORTED) {
+ return crypto.getRandomValues(array);
+ } else {
+ return random.getRandomValues(array);
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const BLOCK_LENGTH = 16;
+ const RAW_FORMAT = "raw";
+ const PBKDF2_ALGORITHM = { name: "PBKDF2" };
+ const HASH_ALGORITHM = { name: "HMAC" };
+ const HASH_FUNCTION = "SHA-1";
+ const BASE_KEY_ALGORITHM = Object.assign({ hash: HASH_ALGORITHM }, PBKDF2_ALGORITHM);
+ const DERIVED_BITS_ALGORITHM = Object.assign({ iterations: 1000, hash: { name: HASH_FUNCTION } }, PBKDF2_ALGORITHM);
+ const DERIVED_BITS_USAGE = ["deriveBits"];
+ const SALT_LENGTH = [8, 12, 16];
+ const KEY_LENGTH = [16, 24, 32];
+ const SIGNATURE_LENGTH = 10;
+ const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
+ const UNDEFINED_TYPE$1 = "undefined";
+ const FUNCTION_TYPE = "function";
+ const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE$1;
+ const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof crypto.subtle != UNDEFINED_TYPE$1;
+ const IMPORT_KEY_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof crypto.subtle.importKey == FUNCTION_TYPE;
+ const DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof crypto.subtle.deriveBits == FUNCTION_TYPE;
+ const codecBytes = codec.bytes;
+ const Aes = cipher.aes;
+ const CtrGladman = mode.ctrGladman;
+ const HmacSha1 = misc.hmacSha1;
+
+ class AESDecryptionStream extends TransformStream {
+
+ constructor(password, signed, strength) {
+ let stream;
+ super({
+ start() {
+ Object.assign(this, {
+ ready: new Promise(resolve => this.resolveReady = resolve),
+ password,
+ signed,
+ strength: strength - 1,
+ pending: new Uint8Array()
+ });
+ },
+ async transform(chunk, controller) {
+ const aesCrypto = this;
+ if (aesCrypto.password) {
+ const password = aesCrypto.password;
+ aesCrypto.password = null;
+ const preamble = subarray(chunk, 0, SALT_LENGTH[aesCrypto.strength] + 2);
+ await createDecryptionKeys(aesCrypto, preamble, password);
+ aesCrypto.ctr = new CtrGladman(new Aes(aesCrypto.keys.key), Array.from(COUNTER_DEFAULT_VALUE));
+ aesCrypto.hmac = new HmacSha1(aesCrypto.keys.authentication);
+ chunk = subarray(chunk, SALT_LENGTH[aesCrypto.strength] + 2);
+ aesCrypto.resolveReady();
+ } else {
+ await aesCrypto.ready;
+ }
+ const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
+ controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
+ },
+ async flush(controller) {
+ const aesCrypto = this;
+ await aesCrypto.ready;
+ const pending = aesCrypto.pending;
+ const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
+ const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
+ let decryptedChunkArray = new Uint8Array();
+ if (chunkToDecrypt.length) {
+ const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
+ aesCrypto.hmac.update(encryptedChunk);
+ const decryptedChunk = aesCrypto.ctr.update(encryptedChunk);
+ decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
+ }
+ stream.valid = true;
+ if (aesCrypto.signed) {
+ const signature = subarray(fromBits(codecBytes, aesCrypto.hmac.digest()), 0, SIGNATURE_LENGTH);
+ for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
+ if (signature[indexSignature] != originalSignature[indexSignature]) {
+ stream.valid = false;
+ }
+ }
+ }
+ controller.enqueue(decryptedChunkArray);
+ }
+ });
+ stream = this;
+ }
+ }
+
+ class AESEncryptionStream extends TransformStream {
+
+ constructor(password, strength) {
+ let stream;
+ super({
+ start() {
+ Object.assign(this, {
+ ready: new Promise(resolve => this.resolveReady = resolve),
+ password,
+ strength: strength - 1,
+ pending: new Uint8Array()
+ });
+ },
+ async transform(chunk, controller) {
+ const aesCrypto = this;
+ let preamble = new Uint8Array();
+ if (aesCrypto.password) {
+ const password = aesCrypto.password;
+ aesCrypto.password = null;
+ preamble = await createEncryptionKeys(aesCrypto, password);
+ aesCrypto.ctr = new CtrGladman(new Aes(aesCrypto.keys.key), Array.from(COUNTER_DEFAULT_VALUE));
+ aesCrypto.hmac = new HmacSha1(aesCrypto.keys.authentication);
+ aesCrypto.resolveReady();
+ } else {
+ await aesCrypto.ready;
+ }
+ const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
+ output.set(preamble, 0);
+ controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0));
+ },
+ async flush(controller) {
+ const aesCrypto = this;
+ await aesCrypto.ready;
+ let encryptedChunkArray = new Uint8Array();
+ if (aesCrypto.pending.length) {
+ const encryptedChunk = aesCrypto.ctr.update(toBits(codecBytes, aesCrypto.pending));
+ aesCrypto.hmac.update(encryptedChunk);
+ encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
+ }
+ stream.signature = fromBits(codecBytes, aesCrypto.hmac.digest()).slice(0, SIGNATURE_LENGTH);
+ controller.enqueue(concat(encryptedChunkArray, stream.signature));
+ }
+ });
+ stream = this;
+ }
+ }
+
+ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
+ const inputLength = input.length - paddingEnd;
+ if (aesCrypto.pending.length) {
+ input = concat(aesCrypto.pending, input);
+ output = expand(output, inputLength - (inputLength % BLOCK_LENGTH));
+ }
+ let offset;
+ for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
+ const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
+ if (verifySignature) {
+ aesCrypto.hmac.update(inputChunk);
+ }
+ const outputChunk = aesCrypto.ctr.update(inputChunk);
+ if (!verifySignature) {
+ aesCrypto.hmac.update(outputChunk);
+ }
+ output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
+ }
+ aesCrypto.pending = subarray(input, offset);
+ return output;
+ }
+
+ async function createDecryptionKeys(decrypt, preambleArray, password) {
+ await createKeys$1(decrypt, password, subarray(preambleArray, 0, SALT_LENGTH[decrypt.strength]));
+ const passwordVerification = subarray(preambleArray, SALT_LENGTH[decrypt.strength]);
+ const passwordVerificationKey = decrypt.keys.passwordVerification;
+ if (passwordVerificationKey[0] != passwordVerification[0] || passwordVerificationKey[1] != passwordVerification[1]) {
+ throw new Error(ERR_INVALID_PASSWORD);
+ }
+ }
+
+ async function createEncryptionKeys(encrypt, password) {
+ const salt = getRandomValues(new Uint8Array(SALT_LENGTH[encrypt.strength]));
+ await createKeys$1(encrypt, password, salt);
+ return concat(salt, encrypt.keys.passwordVerification);
+ }
+
+ async function createKeys$1(target, password, salt) {
+ const encodedPassword = encodeText(password);
+ const basekey = await importKey(RAW_FORMAT, encodedPassword, BASE_KEY_ALGORITHM, false, DERIVED_BITS_USAGE);
+ const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM), basekey, 8 * ((KEY_LENGTH[target.strength] * 2) + 2));
+ const compositeKey = new Uint8Array(derivedBits);
+ target.keys = {
+ key: toBits(codecBytes, subarray(compositeKey, 0, KEY_LENGTH[target.strength])),
+ authentication: toBits(codecBytes, subarray(compositeKey, KEY_LENGTH[target.strength], KEY_LENGTH[target.strength] * 2)),
+ passwordVerification: subarray(compositeKey, KEY_LENGTH[target.strength] * 2)
+ };
+ }
+
+ function importKey(format, password, algorithm, extractable, keyUsages) {
+ if (IMPORT_KEY_SUPPORTED) {
+ return crypto.subtle.importKey(format, password, algorithm, extractable, keyUsages);
+ } else {
+ return misc.importKey(password);
+ }
+ }
+
+ async function deriveBits(algorithm, baseKey, length) {
+ if (DERIVE_BITS_SUPPORTED) {
+ return await crypto.subtle.deriveBits(algorithm, baseKey, length);
+ } else {
+ return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
+ }
+ }
+
+ function concat(leftArray, rightArray) {
+ let array = leftArray;
+ if (leftArray.length + rightArray.length) {
+ array = new Uint8Array(leftArray.length + rightArray.length);
+ array.set(leftArray, 0);
+ array.set(rightArray, leftArray.length);
+ }
+ return array;
+ }
+
+ function expand(inputArray, length) {
+ if (length && length > inputArray.length) {
+ const array = inputArray;
+ inputArray = new Uint8Array(length);
+ inputArray.set(array, 0);
+ }
+ return inputArray;
+ }
+
+ function subarray(array, begin, end) {
+ return array.subarray(begin, end);
+ }
+
+ function fromBits(codecBytes, chunk) {
+ return codecBytes.fromBits(chunk);
+ }
+ function toBits(codecBytes, chunk) {
+ return codecBytes.toBits(chunk);
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const HEADER_LENGTH = 12;
+
+ class ZipCryptoDecryptionStream extends TransformStream {
+
+ constructor(password, passwordVerification) {
+ let stream;
+ super({
+ start() {
+ Object.assign(this, {
+ password,
+ passwordVerification
+ });
+ createKeys(this, password);
+ },
+ transform(chunk, controller) {
+ const zipCrypto = this;
+ if (zipCrypto.password) {
+ const decryptedHeader = decrypt(zipCrypto, chunk.subarray(0, HEADER_LENGTH));
+ zipCrypto.password = null;
+ if (decryptedHeader[HEADER_LENGTH - 1] != zipCrypto.passwordVerification) {
+ throw new Error(ERR_INVALID_PASSWORD);
+ }
+ chunk = chunk.subarray(HEADER_LENGTH);
+ }
+ controller.enqueue(decrypt(zipCrypto, chunk));
+ },
+ flush() {
+ stream.valid = true;
+ }
+ });
+ stream = this;
+ }
+ }
+
+ class ZipCryptoEncryptionStream extends TransformStream {
+
+ constructor(password, passwordVerification) {
+ super({
+ start() {
+ Object.assign(this, {
+ password,
+ passwordVerification
+ });
+ createKeys(this, password);
+ },
+ transform(chunk, controller) {
+ const zipCrypto = this;
+ let output;
+ let offset;
+ if (zipCrypto.password) {
+ zipCrypto.password = null;
+ const header = getRandomValues(new Uint8Array(HEADER_LENGTH));
+ header[HEADER_LENGTH - 1] = zipCrypto.passwordVerification;
+ output = new Uint8Array(chunk.length + header.length);
+ output.set(encrypt(zipCrypto, header), 0);
+ offset = HEADER_LENGTH;
+ } else {
+ output = new Uint8Array(chunk.length);
+ offset = 0;
+ }
+ output.set(encrypt(zipCrypto, chunk), offset);
+ controller.enqueue(output);
+ },
+ flush() {
+ }
+ });
+ }
+ }
+
+ function decrypt(target, input) {
+ const output = new Uint8Array(input.length);
+ for (let index = 0; index < input.length; index++) {
+ output[index] = getByte(target) ^ input[index];
+ updateKeys(target, output[index]);
+ }
+ return output;
+ }
+
+ function encrypt(target, input) {
+ const output = new Uint8Array(input.length);
+ for (let index = 0; index < input.length; index++) {
+ output[index] = getByte(target) ^ input[index];
+ updateKeys(target, input[index]);
+ }
+ return output;
+ }
+
+ function createKeys(target, password) {
+ target.keys = [0x12345678, 0x23456789, 0x34567890];
+ target.crcKey0 = new Crc32(target.keys[0]);
+ target.crcKey2 = new Crc32(target.keys[2]);
+ for (let index = 0; index < password.length; index++) {
+ updateKeys(target, password.charCodeAt(index));
+ }
+ }
+
+ function updateKeys(target, byte) {
+ target.crcKey0.append([byte]);
+ target.keys[0] = ~target.crcKey0.get();
+ target.keys[1] = getInt32(target.keys[1] + getInt8(target.keys[0]));
+ target.keys[1] = getInt32(Math.imul(target.keys[1], 134775813) + 1);
+ target.crcKey2.append([target.keys[1] >>> 24]);
+ target.keys[2] = ~target.crcKey2.get();
+ }
+
+ function getByte(target) {
+ const temp = target.keys[2] | 2;
+ return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
+ }
+
+ function getInt8(number) {
+ return number & 0xFF;
+ }
+
+ function getInt32(number) {
+ return number & 0xFFFFFFFF;
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ /*
+ * This program is based on JZlib 1.0.2 ymnk, JCraft,Inc.
+ * JZlib is based on zlib-1.1.3, so all credit should go authors
+ * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
+ * and contributors of zlib.
+ */
+
+ /* global TransformStream */
+
+ class CodecStream extends TransformStream {
+
+ constructor(Codec, options) {
+ let codec;
+ super({
+ start() {
+ codec = new Codec(options);
+ },
+ transform(chunk, controller) {
+ chunk = codec.append(chunk);
+ controller.enqueue(chunk);
+ },
+ flush(controller) {
+ const chunk = codec.flush();
+ if (chunk) {
+ controller.enqueue(chunk);
+ }
+ }
+ });
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const ERR_INVALID_SIGNATURE = "Invalid signature";
+ const COMPRESSION_FORMAT = "deflate-raw";
+ const UNDEFINED_TYPE = "undefined";
+ const COMPRESSION_STREAM_API_SUPPORTED = typeof CompressionStream == UNDEFINED_TYPE;
+ const DECOMPRESSION_STREAM_API_SUPPORTED = typeof DecompressionStream == UNDEFINED_TYPE;
+ let INFLATE_RAW_SUPPORTED = true;
+ let DEFLATE_RAW_SUPPORTED = true;
+
+ class DeflateStream extends TransformStream {
+
+ constructor(codecConstructor, options, { chunkSize }, ...strategies) {
+ super({}, ...strategies);
+ const { compressed, encrypted, useCompressionStream, password, passwordVerification, encryptionStrength, zipCrypto, signed, level } = options;
+ const stream = this;
+ let crc32Stream, encryptionStream;
+ let readable = filterEmptyChunks(super.readable);
+ if ((!encrypted || zipCrypto) && signed) {
+ [readable, crc32Stream] = readable.tee();
+ crc32Stream = crc32Stream.pipeThrough(new Crc32Stream());
+ }
+ if (compressed) {
+ if ((useCompressionStream !== undefined && !useCompressionStream) || (COMPRESSION_STREAM_API_SUPPORTED && !DEFLATE_RAW_SUPPORTED)) {
+ readable = pipeCodecStream(codecConstructor, readable, { chunkSize, level });
+ } else {
+ try {
+ readable = readable.pipeThrough(new CompressionStream(COMPRESSION_FORMAT));
+ } catch (_error) {
+ DEFLATE_RAW_SUPPORTED = false;
+ readable = pipeCodecStream(codecConstructor, readable, { chunkSize, level });
+ }
+ }
+ }
+ if (encrypted) {
+ if (zipCrypto) {
+ readable = readable.pipeThrough(new ZipCryptoEncryptionStream(password, passwordVerification));
+ } else {
+ encryptionStream = new AESEncryptionStream(password, encryptionStrength);
+ readable = readable.pipeThrough(encryptionStream);
+ }
+ }
+ setReadable(stream, readable, async () => {
+ let signature;
+ if (encrypted && !zipCrypto) {
+ signature = encryptionStream.signature;
+ }
+ if ((!encrypted || zipCrypto) && signed) {
+ signature = await crc32Stream.getReader().read();
+ signature = new DataView(signature.value.buffer).getUint32(0);
+ }
+ stream.signature = signature;
+ });
+ }
+ }
+
+ class InflateStream extends TransformStream {
+
+ constructor(codecConstructor, options, { chunkSize }, ...strategies) {
+ super({}, ...strategies);
+ const { zipCrypto, encrypted, password, passwordVerification, signed, encryptionStrength, compressed, useCompressionStream } = options;
+ const stream = this;
+ let crc32Stream, decryptionStream;
+ let readable = filterEmptyChunks(super.readable);
+ if (encrypted) {
+ if (zipCrypto) {
+ readable = readable.pipeThrough(new ZipCryptoDecryptionStream(password, passwordVerification));
+ } else {
+ decryptionStream = new AESDecryptionStream(password, signed, encryptionStrength);
+ readable = readable.pipeThrough(decryptionStream);
+ }
+ }
+ if (compressed) {
+ if ((useCompressionStream !== undefined && !useCompressionStream) || (DECOMPRESSION_STREAM_API_SUPPORTED && !INFLATE_RAW_SUPPORTED)) {
+ readable = pipeCodecStream(codecConstructor, readable, { chunkSize });
+ } else {
+ try {
+ readable = readable.pipeThrough(new DecompressionStream(COMPRESSION_FORMAT));
+ } catch (_error) {
+ INFLATE_RAW_SUPPORTED = false;
+ readable = pipeCodecStream(codecConstructor, readable, { chunkSize });
+ }
+ }
+ }
+ if ((!encrypted || zipCrypto) && signed) {
+ [readable, crc32Stream] = readable.tee();
+ crc32Stream = crc32Stream.pipeThrough(new Crc32Stream());
+ }
+ setReadable(stream, readable, async () => {
+ if (encrypted && !zipCrypto) {
+ if (!decryptionStream.valid) {
+ throw new Error(ERR_INVALID_SIGNATURE);
+ }
+ }
+ if ((!encrypted || zipCrypto) && signed) {
+ const signature = await crc32Stream.getReader().read();
+ const dataViewSignature = new DataView(signature.value.buffer);
+ if (options.signature != dataViewSignature.getUint32(0, false)) {
+ throw new Error(ERR_INVALID_SIGNATURE);
+ }
+ }
+ });
+ }
+ }
+
+ function pipeCodecStream(codecConstructor, readable, options) {
+ return readable.pipeThrough(new CodecStream(codecConstructor, options));
+ }
+
+ function filterEmptyChunks(readable) {
+ return readable.pipeThrough(new TransformStream({
+ transform(chunk, controller) {
+ if (chunk && chunk.length) {
+ controller.enqueue(chunk);
+ }
+ }
+ }));
+ }
+
+ function setReadable(stream, readable, flush) {
+ stream.size = 0;
+ readable = readable.pipeThrough(new TransformStream({
+ transform(chunk, controller) {
+ if (chunk && chunk.length) {
+ stream.size += chunk.length;
+ controller.enqueue(chunk);
+ }
+ }, flush
+ }));
+ Object.defineProperty(stream, "readable", {
+ get() {
+ return readable;
+ }
+ });
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const CODEC_DEFLATE = "deflate";
+ const CODEC_INFLATE = "inflate";
+ const MESSAGE_EVENT_TYPE = "message";
+ const MESSAGE_START = "start";
+ const MESSAGE_PULL = "pull";
+ const MESSAGE_DATA = "data";
+ const MESSAGE_CLOSE = "close";
+
+ class Codec {
+
+ constructor(codecConstructor, readable, writable, options, config) {
+ const { codecType } = options;
+ if (codecType.startsWith(CODEC_DEFLATE)) {
+ this.run = () => run(DeflateStream);
+ } else if (codecType.startsWith(CODEC_INFLATE)) {
+ this.run = () => run(InflateStream);
+ }
+
+ async function run(StreamConstructor) {
+ const stream = new StreamConstructor(codecConstructor, options, config);
+ await readable.pipeThrough(stream).pipeTo(writable, { preventClose: true, preventAbort: true });
+ const { size, signature } = stream;
+ return { size, signature };
+ }
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ let workersSupported;
+ let classicWorkersSupported = true;
+
+ class CodecWorker {
+
+ constructor(workerData, stream, workerOptions, onTaskFinished) {
+ const { readable, writable } = stream;
+ const { options, config, streamOptions, webWorker, scripts, codecConstructor } = workerOptions;
+ Object.assign(workerData, {
+ busy: true,
+ codecConstructor,
+ readable,
+ writable,
+ options: Object.assign({}, options),
+ scripts,
+ terminate() {
+ if (workerData.worker && !workerData.busy) {
+ workerData.worker.terminate();
+ workerData.interface = null;
+ }
+ },
+ onTaskFinished() {
+ workerData.busy = false;
+ onTaskFinished(workerData);
+ }
+ });
+ const { signal, onstart, onprogress, size, onend } = streamOptions;
+ let chunkOffset = 0;
+ const transformer = {};
+ if (onstart) {
+ transformer.start = () => callHandler(onstart, size());
+ }
+ transformer.transform = async (chunk, controller) => {
+ chunkOffset += chunk.length;
+ if (onprogress) {
+ await callHandler(onprogress, chunkOffset, size());
+ }
+ controller.enqueue(chunk);
+ };
+ transformer.flush = () => {
+ readable.size = () => chunkOffset;
+ if (onend) {
+ callHandler(onend, chunkOffset);
+ }
+ };
+ workerData.readable = readable.pipeThrough(new TransformStream(transformer, { highWaterMark: 1, size: () => config.chunkSize }), { signal });
+ if (workersSupported === undefined) {
+ workersSupported = typeof Worker != "undefined";
+ }
+ return webWorker && workersSupported ? createWebWorkerInterface(workerData, config) : createWorkerInterface(workerData, config);
+ }
+ }
+
+ async function callHandler(handler, ...parameters) {
+ try {
+ await handler(...parameters);
+ } catch (_error) {
+ // ignored
+ }
+ }
+
+ function createWorkerInterface(workerData, config) {
+ const interfaceCodec = new Codec(workerData.codecConstructor, workerData.readable, workerData.writable, workerData.options, config);
+ const { onTaskFinished } = workerData;
+ const codec = {
+ async run() {
+ try {
+ return await interfaceCodec.run();
+ } finally {
+ onTaskFinished();
+ }
+ }
+ };
+ return codec;
+ }
+
+ function createWebWorkerInterface(workerData, { baseURL, chunkSize }) {
+ const workerOptions = { type: "module" };
+ const { readable, writable } = workerData;
+ Object.assign(workerData, {
+ reader: readable.getReader(),
+ writer: writable.getWriter(),
+ result: new Promise((resolve, reject) => {
+ workerData.resolveResult = resolve;
+ workerData.rejectResult = reject;
+ })
+ });
+ if (!workerData.interface) {
+ if (!classicWorkersSupported) {
+ workerData.worker = getWorker(workerOptions);
+ } else {
+ try {
+ workerData.worker = getWorker({});
+ } catch (_error) {
+ classicWorkersSupported = false;
+ workerData.worker = getWorker(workerOptions);
+ }
+ }
+ workerData.worker.addEventListener(MESSAGE_EVENT_TYPE, onMessage, false);
+ workerData.interface = {
+ run() {
+ const { options } = workerData;
+ const scripts = workerData.scripts.slice(1);
+ sendMessage({ type: MESSAGE_START, scripts, options, config: { chunkSize } });
+ return workerData.result;
+ }
+ };
+ }
+ return workerData.interface;
+
+ function getWorker(options) {
+ let url, scriptUrl;
+ url = workerData.scripts[0];
+ if (typeof url == "function") {
+ url = url();
+ }
+ try {
+ scriptUrl = new URL(url, baseURL);
+ } catch (_error) {
+ scriptUrl = url;
+ }
+ return new Worker(scriptUrl, options);
+ }
+
+ function sendMessage(message) {
+ const { worker, writer, onTaskFinished } = workerData;
+ try {
+ let { data } = message;
+ if (data) {
+ try {
+ const { buffer, length } = data;
+ if (length != buffer.byteLength) {
+ data = new Uint8Array(data);
+ }
+ message.data = data.buffer;
+ worker.postMessage(message, [message.data]);
+ } catch (_error) {
+ worker.postMessage(message);
+ }
+ } else {
+ worker.postMessage(message);
+ }
+ } catch (error) {
+ writer.releaseLock();
+ onTaskFinished();
+ throw error;
+ }
+ }
+
+ async function onMessage(event) {
+ const message = event.data;
+ const { reader, writer, resolveResult, rejectResult, onTaskFinished } = workerData;
+ const { type, data, messageId, result } = message;
+ const reponseError = message.error;
+ try {
+ if (reponseError) {
+ const { message, stack } = reponseError;
+ const error = new Error(message);
+ error.stack = stack;
+ close(error);
+ } else {
+ if (type == MESSAGE_PULL) {
+ const { value, done } = await reader.read();
+ sendMessage({ type: MESSAGE_DATA, data: value, done, messageId });
+ }
+ if (type == MESSAGE_DATA) {
+ await writer.ready;
+ await writer.write(new Uint8Array(data));
+ }
+ if (type == MESSAGE_CLOSE) {
+ close(null, result);
+ }
+ }
+ } catch (error) {
+ close(error);
+ }
+
+ function close(error, result) {
+ if (error) {
+ rejectResult(error);
+ } else {
+ resolveResult(result);
+ }
+ writer.releaseLock();
+ onTaskFinished();
+ }
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ let pool = [];
+ const pendingRequests = [];
+
+ let indexWorker = 0;
+
+ async function runWorker(stream, workerOptions) {
+ const { options, config } = workerOptions;
+ const streamCopy = !options.compressed && !options.signed && !options.encrypted;
+ const { useWebWorkers, useCompressionStream, codecType } = options;
+ const { workerScripts } = config;
+ workerOptions.webWorker = !streamCopy && (useWebWorkers || (useWebWorkers === undefined && config.useWebWorkers));
+ workerOptions.scripts = workerOptions.webWorker && workerScripts ? workerScripts[codecType] : [];
+ options.useCompressionStream = useCompressionStream === undefined ? config.useCompressionStream : useCompressionStream;
+ let worker;
+ if (pool.length < config.maxWorkers) {
+ const workerData = { indexWorker };
+ indexWorker++;
+ pool.push(workerData);
+ worker = new CodecWorker(workerData, stream, workerOptions, onTaskFinished);
+ } else {
+ const workerData = pool.find(workerData => !workerData.busy);
+ if (workerData) {
+ clearTerminateTimeout(workerData);
+ worker = new CodecWorker(workerData, stream, workerOptions, onTaskFinished);
+ } else {
+ worker = await new Promise(resolve => pendingRequests.push({ resolve, stream, workerOptions }));
+ }
+ }
+ return worker.run();
+
+ function onTaskFinished(workerData) {
+ if (pendingRequests.length) {
+ const [{ resolve, stream, workerOptions }] = pendingRequests.splice(0, 1);
+ resolve(new CodecWorker(workerData, stream, workerOptions, onTaskFinished));
+ } else if (workerData.worker) {
+ const { terminateWorkerTimeout } = config;
+ clearTerminateTimeout(workerData);
+ if (Number.isFinite(terminateWorkerTimeout) && terminateWorkerTimeout >= 0) {
+ workerData.terminateTimeout = setTimeout(() => {
+ pool = pool.filter(data => data != workerData);
+ workerData.terminate();
+ }, terminateWorkerTimeout);
+ }
+ } else {
+ pool = pool.filter(data => data != workerData);
+ }
+ }
+ }
+
+ function clearTerminateTimeout(workerData) {
+ const { terminateTimeout } = workerData;
+ if (terminateTimeout) {
+ clearTimeout(terminateTimeout);
+ workerData.terminateTimeout = null;
+ }
+ }
+
+ function terminateWorkers() {
+ pool.forEach(workerData => {
+ clearTerminateTimeout(workerData);
+ workerData.terminate();
+ });
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ /* global Blob, atob, btoa, XMLHttpRequest, URL, fetch, ReadableStream, WritableStream, FileReader, TransformStream, Response */
+
+ const ERR_HTTP_STATUS = "HTTP error ";
+ const ERR_HTTP_RANGE = "HTTP Range not supported";
+
+ const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
+ const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
+ const HTTP_HEADER_CONTENT_RANGE = "Content-Range";
+ const HTTP_HEADER_ACCEPT_RANGES = "Accept-Ranges";
+ const HTTP_HEADER_RANGE = "Range";
+ const HTTP_METHOD_HEAD = "HEAD";
+ const HTTP_METHOD_GET = "GET";
+ const HTTP_RANGE_UNIT = "bytes";
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
+
+ class Stream {
+
+ constructor() {
+ this.size = 0;
+ }
+
+ init() {
+ this.initialized = true;
+ }
+ }
+
+ class Reader extends Stream {
+
+ get readable() {
+ const reader = this;
+ const { chunkSize = DEFAULT_CHUNK_SIZE } = reader;
+ const readable = new ReadableStream({
+ start() {
+ this.chunkOffset = 0;
+ },
+ async pull(controller) {
+ const { offset = 0, size } = readable;
+ const { chunkOffset } = this;
+ controller.enqueue(await reader.readUint8Array(offset + chunkOffset, Math.min(chunkSize, size() - chunkOffset)));
+ if (chunkOffset + chunkSize > size()) {
+ controller.close();
+ } else {
+ this.chunkOffset += chunkSize;
+ }
+ }
+ });
+ return readable;
+ }
+ }
+
+ class WriterStream extends Stream {
+
+ constructor() {
+ super();
+ const writer = this;
+ const writable = new WritableStream({
+ write(chunk) {
+ return writer.writeUint8Array(chunk);
+ }
+ });
+ Object.defineProperty(this, "writable", {
+ get() {
+ return writable;
+ }
+ });
+ }
+ }
+
+ class Writer extends WriterStream {
+
+ writeUint8Array(array) {
+ this.size += array.length;
+ }
+ }
+
+ class TextReader extends Reader {
+
+ constructor(text) {
+ super();
+ this.blobReader = new BlobReader(new Blob([text], { type: CONTENT_TYPE_TEXT_PLAIN }));
+ }
+
+ init() {
+ const reader = this;
+ super.init();
+ reader.blobReader.init();
+ reader.size = reader.blobReader.size;
+ }
+
+ readUint8Array(offset, length) {
+ return this.blobReader.readUint8Array(offset, length);
+ }
+ }
+
+ class TextWriter extends Writer {
+
+ constructor(encoding) {
+ super();
+ this.encoding = encoding;
+ this.blob = new Blob([], { type: CONTENT_TYPE_TEXT_PLAIN });
+ }
+
+ writeUint8Array(array) {
+ super.writeUint8Array(array);
+ this.blob = new Blob([this.blob, array.buffer], { type: CONTENT_TYPE_TEXT_PLAIN });
+ }
+
+ getData() {
+ const writer = this;
+ if (writer.blob.text && (writer.encoding === undefined || (writer.encoding && writer.encoding.toLowerCase() == "utf-8"))) {
+ return writer.blob.text();
+ } else {
+ const reader = new FileReader();
+ return new Promise((resolve, reject) => {
+ reader.onload = event => resolve(event.target.result);
+ reader.onerror = () => reject(reader.error);
+ reader.readAsText(writer.blob, writer.encoding);
+ });
+ }
+ }
+ }
+
+ class Data64URIReader extends Reader {
+
+ constructor(dataURI) {
+ super();
+ const reader = this;
+ reader.dataURI = dataURI;
+ let dataEnd = dataURI.length;
+ while (dataURI.charAt(dataEnd - 1) == "=") {
+ dataEnd--;
+ }
+ reader.dataStart = dataURI.indexOf(",") + 1;
+ reader.size = Math.floor((dataEnd - reader.dataStart) * 0.75);
+ }
+
+ readUint8Array(offset, length) {
+ const dataArray = new Uint8Array(length);
+ const start = Math.floor(offset / 3) * 4;
+ const dataStart = this.dataStart;
+ const bytes = atob(this.dataURI.substring(start + dataStart, Math.ceil((offset + length) / 3) * 4 + dataStart));
+ const delta = offset - Math.floor(start / 4) * 3;
+ for (let indexByte = delta; indexByte < delta + length; indexByte++) {
+ dataArray[indexByte - delta] = bytes.charCodeAt(indexByte);
+ }
+ return dataArray;
+ }
+ }
+
+ class Data64URIWriter extends Writer {
+
+ constructor(contentType) {
+ super();
+ this.data = "data:" + (contentType || "") + ";base64,";
+ this.pending = [];
+ }
+
+ writeUint8Array(array) {
+ super.writeUint8Array(array);
+ const writer = this;
+ let indexArray = 0;
+ let dataString = writer.pending;
+ const delta = writer.pending.length;
+ writer.pending = "";
+ for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
+ dataString += String.fromCharCode(array[indexArray]);
+ }
+ for (; indexArray < array.length; indexArray++) {
+ writer.pending += String.fromCharCode(array[indexArray]);
+ }
+ if (dataString.length > 2) {
+ writer.data += btoa(dataString);
+ } else {
+ writer.pending = dataString;
+ }
+ }
+
+ getData() {
+ return this.data + btoa(this.pending);
+ }
+ }
+
+ class BlobReader extends Reader {
+
+ constructor(blob) {
+ super();
+ this.blob = blob;
+ this.size = blob.size;
+ }
+
+ async readUint8Array(offset, length) {
+ const reader = this;
+ return new Uint8Array(await reader.blob.slice(offset, offset + length).arrayBuffer());
+ }
+ }
+
+ class BlobWriter extends Stream {
+
+ constructor(contentType) {
+ super();
+ const writer = this;
+ writer.contentType = contentType;
+ writer.transformStream = new TransformStream({
+ transform(chunk, controller) {
+ writer.size += chunk.length;
+ controller.enqueue(chunk);
+ }
+ });
+ Object.defineProperty(this, "writable", {
+ get() {
+ return writer.transformStream.writable;
+ }
+ });
+ }
+
+ init() {
+ super.init();
+ const writer = this;
+ const {
+ transformStream,
+ contentType
+ } = writer;
+ writer.blob = new Response(transformStream.readable).blob({ type: contentType });
+ }
+
+ getData() {
+ return this.blob;
+ }
+ }
+
+ class FetchReader extends Reader {
+
+ constructor(url, options) {
+ super();
+ const reader = this;
+ reader.url = url;
+ reader.preventHeadRequest = options.preventHeadRequest;
+ reader.useRangeHeader = options.useRangeHeader;
+ reader.forceRangeRequests = options.forceRangeRequests;
+ reader.options = options = Object.assign({}, options);
+ delete options.preventHeadRequest;
+ delete options.useRangeHeader;
+ delete options.forceRangeRequests;
+ delete options.useXHR;
+ }
+
+ async init() {
+ super.init();
+ await initHttpReader(this, sendFetchRequest, getFetchRequestData);
+ }
+
+ readUint8Array(index, length) {
+ return readUint8ArrayHttpReader(this, index, length, sendFetchRequest, getFetchRequestData);
+ }
+ }
+
+ class XHRReader extends Reader {
+
+ constructor(url, options) {
+ super();
+ const reader = this;
+ reader.url = url;
+ reader.preventHeadRequest = options.preventHeadRequest;
+ reader.useRangeHeader = options.useRangeHeader;
+ reader.forceRangeRequests = options.forceRangeRequests;
+ reader.options = options;
+ }
+
+ async init() {
+ super.init();
+ await initHttpReader(this, sendXMLHttpRequest, getXMLHttpRequestData);
+ }
+
+ readUint8Array(index, length) {
+ return readUint8ArrayHttpReader(this, index, length, sendXMLHttpRequest, getXMLHttpRequestData);
+ }
+ }
+
+ async function initHttpReader(httpReader, sendRequest, getRequestData) {
+ if (isHttpFamily(httpReader.url) && (httpReader.useRangeHeader || httpReader.forceRangeRequests)) {
+ const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader));
+ if (!httpReader.forceRangeRequests && response.headers.get(HTTP_HEADER_ACCEPT_RANGES) != HTTP_RANGE_UNIT) {
+ throw new Error(ERR_HTTP_RANGE);
+ } else {
+ let contentSize;
+ const contentRangeHeader = response.headers.get(HTTP_HEADER_CONTENT_RANGE);
+ if (contentRangeHeader) {
+ const splitHeader = contentRangeHeader.trim().split(/\s*\/\s*/);
+ if (splitHeader.length) {
+ const headerValue = splitHeader[1];
+ if (headerValue && headerValue != "*") {
+ contentSize = Number(headerValue);
+ }
+ }
+ }
+ if (contentSize === undefined) {
+ await getContentLength(httpReader, sendRequest, getRequestData);
+ } else {
+ httpReader.size = contentSize;
+ }
+ }
+ } else {
+ await getContentLength(httpReader, sendRequest, getRequestData);
+ }
+ }
+
+ async function readUint8ArrayHttpReader(httpReader, index, length, sendRequest, getRequestData) {
+ if (httpReader.useRangeHeader || httpReader.forceRangeRequests) {
+ const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
+ if (response.status != 206) {
+ throw new Error(ERR_HTTP_RANGE);
+ }
+ return new Uint8Array(await response.arrayBuffer());
+ } else {
+ if (!httpReader.data) {
+ await getRequestData(httpReader, httpReader.options);
+ }
+ return new Uint8Array(httpReader.data.subarray(index, index + length));
+ }
+ }
+
+ function getRangeHeaders(httpReader, index = 0, length = 1) {
+ return Object.assign({}, getHeaders(httpReader), { [HTTP_HEADER_RANGE]: HTTP_RANGE_UNIT + "=" + index + "-" + (index + length - 1) });
+ }
+
+ function getHeaders(httpReader) {
+ const headers = httpReader.options.headers;
+ if (headers) {
+ if (Symbol.iterator in headers) {
+ return Object.fromEntries(headers);
+ } else {
+ return headers;
+ }
+ }
+ }
+
+ async function getFetchRequestData(httpReader) {
+ await getRequestData(httpReader, sendFetchRequest);
+ }
+
+ async function getXMLHttpRequestData(httpReader) {
+ await getRequestData(httpReader, sendXMLHttpRequest);
+ }
+
+ async function getRequestData(httpReader, sendRequest) {
+ const response = await sendRequest(HTTP_METHOD_GET, httpReader, getHeaders(httpReader));
+ httpReader.data = new Uint8Array(await response.arrayBuffer());
+ if (!httpReader.size) {
+ httpReader.size = httpReader.data.length;
+ }
+ }
+
+ async function getContentLength(httpReader, sendRequest, getRequestData) {
+ if (httpReader.preventHeadRequest) {
+ await getRequestData(httpReader, httpReader.options);
+ } else {
+ const response = await sendRequest(HTTP_METHOD_HEAD, httpReader, getHeaders(httpReader));
+ const contentLength = response.headers.get(HTTP_HEADER_CONTENT_LENGTH);
+ if (contentLength) {
+ httpReader.size = Number(contentLength);
+ } else {
+ await getRequestData(httpReader, httpReader.options);
+ }
+ }
+ }
+
+ async function sendFetchRequest(method, { options, url }, headers) {
+ const response = await fetch(url, Object.assign({}, options, { method, headers }));
+ if (response.status < 400) {
+ return response;
+ } else {
+ throw response.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (response.statusText || response.status));
+ }
+ }
+
+ function sendXMLHttpRequest(method, { url }, headers) {
+ return new Promise((resolve, reject) => {
+ const request = new XMLHttpRequest();
+ request.addEventListener("load", () => {
+ if (request.status < 400) {
+ const headers = [];
+ request.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(header => {
+ const splitHeader = header.trim().split(/\s*:\s*/);
+ splitHeader[0] = splitHeader[0].trim().replace(/^[a-z]|-[a-z]/g, value => value.toUpperCase());
+ headers.push(splitHeader);
+ });
+ resolve({
+ status: request.status,
+ arrayBuffer: () => request.response,
+ headers: new Map(headers)
+ });
+ } else {
+ reject(request.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (request.statusText || request.status)));
+ }
+ }, false);
+ request.addEventListener("error", event => reject(event.detail.error), false);
+ request.open(method, url);
+ if (headers) {
+ for (const entry of Object.entries(headers)) {
+ request.setRequestHeader(entry[0], entry[1]);
+ }
+ }
+ request.responseType = "arraybuffer";
+ request.send();
+ });
+ }
+
+ class HttpReader extends Reader {
+
+ constructor(url, options = {}) {
+ super();
+ const reader = this;
+ reader.url = url;
+ reader.reader = options.useXHR ? new XHRReader(url, options) : new FetchReader(url, options);
+ }
+
+ set size(value) {
+ // ignored
+ }
+
+ get size() {
+ return this.reader.size;
+ }
+
+ async init() {
+ super.init();
+ await this.reader.init();
+ }
+
+ readUint8Array(index, length) {
+ return this.reader.readUint8Array(index, length);
+ }
+ }
+
+ class HttpRangeReader extends HttpReader {
+
+ constructor(url, options = {}) {
+ options.useRangeHeader = true;
+ super(url, options);
+ }
+ }
+
+
+ class Uint8ArrayReader extends Reader {
+
+ constructor(array) {
+ super();
+ this.array = array;
+ this.size = array.length;
+ }
+
+ readUint8Array(index, length) {
+ return this.array.slice(index, index + length);
+ }
+ }
+
+ class Uint8ArrayWriter extends Writer {
+
+ init(initSize = 0) {
+ super.init();
+ this.array = new Uint8Array(initSize);
+ }
+
+ writeUint8Array(array) {
+ const writer = this;
+ if (writer.size + array.length > writer.array.length) {
+ const previousArray = writer.array;
+ writer.array = new Uint8Array(previousArray.length + array.length);
+ writer.array.set(previousArray);
+ }
+ writer.array.set(array, writer.size);
+ super.writeUint8Array(array);
+ }
+
+ getData() {
+ return this.array;
+ }
+ }
+
+ function isHttpFamily(url) {
+ const { baseURL } = getConfiguration();
+ const { protocol } = new URL(url, baseURL);
+ return protocol == "http:" || protocol == "https:";
+ }
+
+ async function initStream(stream, initSize) {
+ if (stream.init && !stream.initialized) {
+ await stream.init(initSize);
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const MAX_32_BITS = 0xffffffff;
+ const MAX_16_BITS = 0xffff;
+ const COMPRESSION_METHOD_DEFLATE = 0x08;
+ const COMPRESSION_METHOD_STORE = 0x00;
+ const COMPRESSION_METHOD_AES = 0x63;
+
+ const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
+ const DATA_DESCRIPTOR_RECORD_SIGNATURE = 0x08074b50;
+ const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50;
+ const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50;
+ const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50;
+ const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50;
+ const END_OF_CENTRAL_DIR_LENGTH = 22;
+ const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20;
+ const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56;
+ const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LENGTH;
+
+ const ZIP64_TOTAL_NUMBER_OF_DISKS = 1;
+
+ const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
+ const EXTRAFIELD_TYPE_AES = 0x9901;
+ const EXTRAFIELD_TYPE_NTFS = 0x000a;
+ const EXTRAFIELD_TYPE_NTFS_TAG1 = 0x0001;
+ const EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP = 0x5455;
+ const EXTRAFIELD_TYPE_UNICODE_PATH = 0x7075;
+ const EXTRAFIELD_TYPE_UNICODE_COMMENT = 0x6375;
+
+ const BITFLAG_ENCRYPTED = 0x01;
+ const BITFLAG_LEVEL = 0x06;
+ const BITFLAG_DATA_DESCRIPTOR = 0x0008;
+ const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
+ const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
+
+ const VERSION_DEFLATE = 0x14;
+ const VERSION_ZIP64 = 0x2D;
+ const VERSION_AES = 0x33;
+
+ const DIRECTORY_SIGNATURE = "/";
+
+ const MAX_DATE = new Date(2107, 11, 31);
+ const MIN_DATE = new Date(1980, 0, 1);
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ /* global TextDecoder */
+
+ const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
+ const VALID_CP437 = CP437.length == 256;
+
+ var decodeCP437 = (stringValue) => {
+ if (VALID_CP437) {
+ let result = "";
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
+ result += CP437[stringValue[indexCharacter]];
+ }
+ return result;
+ } else {
+ return new TextDecoder().decode(stringValue);
+ }
+ };
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ function decodeText(value, encoding) {
+ if (encoding && encoding.trim().toLowerCase() == "cp437") {
+ return decodeCP437(value);
+ } else {
+ return new TextDecoder(encoding).decode(value);
+ }
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const PROPERTY_NAMES = [
+ "filename", "rawFilename", "directory", "encrypted", "compressedSize", "uncompressedSize",
+ "lastModDate", "rawLastModDate", "comment", "rawComment", "signature", "extraField",
+ "rawExtraField", "bitFlag", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment",
+ "extraFieldAES", "filenameUTF8", "commentUTF8", "offset", "zip64", "compressionMethod",
+ "extraFieldNTFS", "lastAccessDate", "creationDate", "extraFieldExtendedTimestamp",
+ "version", "versionMadeBy", "msDosCompatible", "internalFileAttribute", "externalFileAttribute"];
+
+ class Entry {
+
+ constructor(data) {
+ PROPERTY_NAMES.forEach(name => this[name] = data[name]);
+ }
+
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const ERR_BAD_FORMAT = "File format is not recognized";
+ const ERR_EOCDR_NOT_FOUND = "End of central directory not found";
+ const ERR_EOCDR_ZIP64_NOT_FOUND = "End of Zip64 central directory not found";
+ const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = "End of Zip64 central directory locator not found";
+ const ERR_CENTRAL_DIRECTORY_NOT_FOUND = "Central directory header not found";
+ const ERR_LOCAL_FILE_HEADER_NOT_FOUND = "Local file header not found";
+ const ERR_EXTRAFIELD_ZIP64_NOT_FOUND = "Zip64 extra field not found";
+ const ERR_ENCRYPTED = "File contains encrypted entry";
+ const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
+ const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
+ const CHARSET_UTF8 = "utf-8";
+ const CHARSET_CP437 = "cp437";
+ const ZIP64_PROPERTIES = ["uncompressedSize", "compressedSize", "offset"];
+
+ class ZipReader {
+
+ constructor(reader, options = {}) {
+ Object.assign(this, {
+ reader,
+ options,
+ config: getConfiguration()
+ });
+ }
+
+ async* getEntriesGenerator(options = {}) {
+ const zipReader = this;
+ let { reader } = zipReader;
+ const { config } = zipReader;
+ await initStream(reader);
+ if (reader.size === undefined || !reader.readUint8Array) {
+ const blob = await new Response(reader.readable).blob();
+ reader = new BlobReader(blob);
+ }
+ if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
+ throw new Error(ERR_BAD_FORMAT);
+ }
+ reader.chunkSize = getChunkSize(config);
+ const endOfDirectoryInfo = await seekSignature(reader, END_OF_CENTRAL_DIR_SIGNATURE, reader.size, END_OF_CENTRAL_DIR_LENGTH, MAX_16_BITS * 16);
+ if (!endOfDirectoryInfo) {
+ throw new Error(ERR_EOCDR_NOT_FOUND);
+ }
+ const endOfDirectoryView = getDataView$1(endOfDirectoryInfo);
+ let directoryDataLength = getUint32(endOfDirectoryView, 12);
+ let directoryDataOffset = getUint32(endOfDirectoryView, 16);
+ const commentOffset = endOfDirectoryInfo.offset;
+ const commentLength = getUint16(endOfDirectoryView, 20);
+ const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
+ let filesLength = getUint16(endOfDirectoryView, 8);
+ let prependedDataLength = 0;
+ let startOffset = 0;
+ if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS) {
+ const endOfDirectoryLocatorArray = await readUint8Array(reader, endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH);
+ const endOfDirectoryLocatorView = getDataView$1(endOfDirectoryLocatorArray);
+ if (getUint32(endOfDirectoryLocatorView, 0) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
+ throw new Error(ERR_EOCDR_ZIP64_NOT_FOUND);
+ }
+ directoryDataOffset = getBigUint64(endOfDirectoryLocatorView, 8);
+ let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
+ let endOfDirectoryView = getDataView$1(endOfDirectoryArray);
+ const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
+ if (getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE && directoryDataOffset != expectedDirectoryDataOffset) {
+ const originalDirectoryDataOffset = directoryDataOffset;
+ directoryDataOffset = expectedDirectoryDataOffset;
+ prependedDataLength = directoryDataOffset - originalDirectoryDataOffset;
+ endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
+ endOfDirectoryView = getDataView$1(endOfDirectoryArray);
+ }
+ if (getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
+ throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
+ }
+ filesLength = getBigUint64(endOfDirectoryView, 32);
+ directoryDataLength = getBigUint64(endOfDirectoryView, 40);
+ directoryDataOffset -= directoryDataLength;
+ }
+ if (directoryDataOffset < 0 || directoryDataOffset >= reader.size) {
+ throw new Error(ERR_BAD_FORMAT);
+ }
+ let offset = 0;
+ let directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
+ let directoryView = getDataView$1(directoryArray);
+ if (directoryDataLength) {
+ const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - directoryDataLength;
+ if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE && directoryDataOffset != expectedDirectoryDataOffset) {
+ const originalDirectoryDataOffset = directoryDataOffset;
+ directoryDataOffset = expectedDirectoryDataOffset;
+ prependedDataLength = directoryDataOffset - originalDirectoryDataOffset;
+ directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
+ directoryView = getDataView$1(directoryArray);
+ }
+ }
+ if (directoryDataOffset < 0 || directoryDataOffset >= reader.size) {
+ throw new Error(ERR_BAD_FORMAT);
+ }
+ const filenameEncoding = getOptionValue$1(zipReader, options, "filenameEncoding");
+ const commentEncoding = getOptionValue$1(zipReader, options, "commentEncoding");
+ for (let indexFile = 0; indexFile < filesLength; indexFile++) {
+ const fileEntry = new ZipEntry(reader, config, zipReader.options);
+ if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
+ throw new Error(ERR_CENTRAL_DIRECTORY_NOT_FOUND);
+ }
+ readCommonHeader(fileEntry, directoryView, offset + 6);
+ const languageEncodingFlag = Boolean(fileEntry.bitFlag.languageEncodingFlag);
+ const filenameOffset = offset + 46;
+ const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
+ const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
+ const versionMadeBy = getUint16(directoryView, offset + 4);
+ const msDosCompatible = (versionMadeBy & 0) == 0;
+ Object.assign(fileEntry, {
+ versionMadeBy,
+ msDosCompatible,
+ compressedSize: 0,
+ uncompressedSize: 0,
+ commentLength: getUint16(directoryView, offset + 32),
+ directory: msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK),
+ offset: getUint32(directoryView, offset + 42) + prependedDataLength,
+ internalFileAttribute: getUint16(directoryView, offset + 36),
+ externalFileAttribute: getUint32(directoryView, offset + 38),
+ rawFilename: directoryArray.subarray(filenameOffset, extraFieldOffset),
+ filenameUTF8: languageEncodingFlag,
+ commentUTF8: languageEncodingFlag,
+ rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
+ });
+ startOffset = Math.max(fileEntry.offset, startOffset);
+ const endOffset = commentOffset + fileEntry.commentLength;
+ fileEntry.rawComment = directoryArray.subarray(commentOffset, endOffset);
+ const [filename, comment] = await Promise.all([
+ decodeText(fileEntry.rawFilename, fileEntry.filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437),
+ decodeText(fileEntry.rawComment, fileEntry.commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437)
+ ]);
+ fileEntry.filename = filename;
+ fileEntry.comment = comment;
+ if (!fileEntry.directory && fileEntry.filename.endsWith(DIRECTORY_SIGNATURE)) {
+ fileEntry.directory = true;
+ }
+ await readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
+ const entry = new Entry(fileEntry);
+ entry.getData = (writer, options) => fileEntry.getData(writer, entry, options);
+ offset = endOffset;
+ if (options.onprogress) {
+ try {
+ await options.onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
+ } catch (_error) {
+ // ignored
+ }
+ }
+ yield entry;
+ }
+ const extractPrependedData = getOptionValue$1(zipReader, options, "extractPrependedData");
+ const extractAppendedData = getOptionValue$1(zipReader, options, "extractAppendedData");
+ if (extractPrependedData) {
+ zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : new Uint8Array();
+ }
+ zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : new Uint8Array();
+ if (extractAppendedData) {
+ zipReader.appendedData = appendedDataOffset < reader.size ? await readUint8Array(reader, appendedDataOffset, reader.size - appendedDataOffset) : new Uint8Array();
+ }
+ return true;
+ }
+
+ async getEntries(options = {}) {
+ const entries = [];
+ for await (const entry of this.getEntriesGenerator(options)) {
+ entries.push(entry);
+ }
+ return entries;
+ }
+
+ async close() {
+ }
+ }
+
+ class ZipEntry {
+
+ constructor(reader, config, options) {
+ Object.assign(this, {
+ reader,
+ config,
+ options
+ });
+ }
+
+ async getData(writer, fileEntry, options = {}) {
+ const zipEntry = this;
+ const {
+ reader,
+ offset,
+ extraFieldAES,
+ compressionMethod,
+ config,
+ bitFlag,
+ signature,
+ rawLastModDate,
+ uncompressedSize,
+ compressedSize
+ } = zipEntry;
+ const localDirectory = zipEntry.localDirectory = {};
+ let dataArray = await readUint8Array(reader, offset, 30);
+ const dataView = getDataView$1(dataArray);
+ let password = getOptionValue$1(zipEntry, options, "password");
+ password = password && password.length && password;
+ if (extraFieldAES) {
+ if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
+ throw new Error(ERR_UNSUPPORTED_COMPRESSION);
+ }
+ }
+ if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) {
+ console.log(compressionMethod);
+ throw new Error(ERR_UNSUPPORTED_COMPRESSION);
+ }
+ if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
+ throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
+ }
+ readCommonHeader(localDirectory, dataView, 4);
+ dataArray = await readUint8Array(reader, offset, 30 + localDirectory.filenameLength + localDirectory.extraFieldLength);
+ localDirectory.rawExtraField = dataArray.subarray(30 + localDirectory.filenameLength);
+ await readCommonFooter(zipEntry, localDirectory, dataView, 4);
+ fileEntry.lastAccessDate = localDirectory.lastAccessDate;
+ fileEntry.creationDate = localDirectory.creationDate;
+ const encrypted = zipEntry.encrypted && localDirectory.encrypted;
+ const zipCrypto = encrypted && !extraFieldAES;
+ if (encrypted) {
+ if (!zipCrypto && extraFieldAES.strength === undefined) {
+ throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
+ } else if (!password) {
+ throw new Error(ERR_ENCRYPTED);
+ }
+ }
+ const dataOffset = offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength;
+ const size = () => compressedSize;
+ const readable = reader.readable;
+ readable.offset = dataOffset;
+ readable.size = size;
+ const { writable } = writer;
+ const signal = getOptionValue$1(zipEntry, options, "signal");
+ await initStream(writer, uncompressedSize);
+ const { onstart, onprogress, onend } = options;
+ const workerOptions = {
+ options: {
+ codecType: CODEC_INFLATE,
+ password,
+ zipCrypto,
+ encryptionStrength: extraFieldAES && extraFieldAES.strength,
+ signed: getOptionValue$1(zipEntry, options, "checkSignature"),
+ passwordVerification: zipCrypto && (bitFlag.dataDescriptor ? ((rawLastModDate >>> 8) & 0xFF) : ((signature >>> 24) & 0xFF)),
+ signature,
+ compressed: compressionMethod != 0,
+ encrypted,
+ useWebWorkers: getOptionValue$1(zipEntry, options, "useWebWorkers"),
+ useCompressionStream: getOptionValue$1(zipEntry, options, "useCompressionStream")
+ },
+ config,
+ streamOptions: { signal, size, onstart, onprogress, onend },
+ codecConstructor: config.Inflate
+ };
+ await runWorker({ readable, writable }, workerOptions);
+ const preventClose = getOptionValue$1(zipEntry, options, "preventClose");
+ if (!preventClose) {
+ await writable.getWriter().close();
+ }
+ return writer.getData ? writer.getData() : writable;
+ }
+ }
+
+ function readCommonHeader(directory, dataView, offset) {
+ const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
+ const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
+ const rawLastModDate = getUint32(dataView, offset + 6);
+ Object.assign(directory, {
+ encrypted,
+ version: getUint16(dataView, offset),
+ bitFlag: {
+ level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
+ dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
+ languageEncodingFlag: (rawBitFlag & BITFLAG_LANG_ENCODING_FLAG) == BITFLAG_LANG_ENCODING_FLAG
+ },
+ rawLastModDate,
+ lastModDate: getDate(rawLastModDate),
+ filenameLength: getUint16(dataView, offset + 22),
+ extraFieldLength: getUint16(dataView, offset + 24)
+ });
+ }
+
+ async function readCommonFooter(fileEntry, directory, dataView, offset) {
+ const { rawExtraField } = directory;
+ const extraField = directory.extraField = new Map();
+ const rawExtraFieldView = getDataView$1(new Uint8Array(rawExtraField));
+ let offsetExtraField = 0;
+ try {
+ while (offsetExtraField < rawExtraField.length) {
+ const type = getUint16(rawExtraFieldView, offsetExtraField);
+ const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
+ extraField.set(type, {
+ type,
+ data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
+ });
+ offsetExtraField += 4 + size;
+ }
+ } catch (_error) {
+ // ignored
+ }
+ const compressionMethod = getUint16(dataView, offset + 4);
+ directory.signature = getUint32(dataView, offset + 10);
+ directory.uncompressedSize = getUint32(dataView, offset + 18);
+ directory.compressedSize = getUint32(dataView, offset + 14);
+ const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
+ if (extraFieldZip64) {
+ readExtraFieldZip64(extraFieldZip64, directory);
+ directory.extraFieldZip64 = extraFieldZip64;
+ }
+ const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
+ if (extraFieldUnicodePath) {
+ await readExtraFieldUnicode(extraFieldUnicodePath, "filename", "rawFilename", directory, fileEntry);
+ directory.extraFieldUnicodePath = extraFieldUnicodePath;
+ }
+ const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
+ if (extraFieldUnicodeComment) {
+ await readExtraFieldUnicode(extraFieldUnicodeComment, "comment", "rawComment", directory, fileEntry);
+ directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
+ }
+ const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
+ if (extraFieldAES) {
+ readExtraFieldAES(extraFieldAES, directory, compressionMethod);
+ directory.extraFieldAES = extraFieldAES;
+ } else {
+ directory.compressionMethod = compressionMethod;
+ }
+ const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
+ if (extraFieldNTFS) {
+ readExtraFieldNTFS(extraFieldNTFS, directory);
+ directory.extraFieldNTFS = extraFieldNTFS;
+ }
+ const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
+ if (extraFieldExtendedTimestamp) {
+ readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory);
+ directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
+ }
+ }
+
+ function readExtraFieldZip64(extraFieldZip64, directory) {
+ directory.zip64 = true;
+ const extraFieldView = getDataView$1(extraFieldZip64.data);
+ extraFieldZip64.values = [];
+ for (let indexValue = 0; indexValue < Math.floor(extraFieldZip64.data.length / 8); indexValue++) {
+ extraFieldZip64.values.push(getBigUint64(extraFieldView, 0 + indexValue * 8));
+ }
+ const missingProperties = ZIP64_PROPERTIES.filter(propertyName => directory[propertyName] == MAX_32_BITS);
+ for (let indexMissingProperty = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) {
+ extraFieldZip64[missingProperties[indexMissingProperty]] = extraFieldZip64.values[indexMissingProperty];
+ }
+ ZIP64_PROPERTIES.forEach(propertyName => {
+ if (directory[propertyName] == MAX_32_BITS) {
+ if (extraFieldZip64[propertyName] !== undefined) {
+ directory[propertyName] = extraFieldZip64[propertyName];
+ } else {
+ throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
+ }
+ }
+ });
+ }
+
+ async function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
+ const extraFieldView = getDataView$1(extraFieldUnicode.data);
+ extraFieldUnicode.version = getUint8(extraFieldView, 0);
+ extraFieldUnicode.signature = getUint32(extraFieldView, 1);
+ const crc32 = new Crc32();
+ crc32.append(fileEntry[rawPropertyName]);
+ const dataViewSignature = getDataView$1(new Uint8Array(4));
+ dataViewSignature.setUint32(0, crc32.get(), true);
+ extraFieldUnicode[propertyName] = await decodeText(extraFieldUnicode.data.subarray(5));
+ extraFieldUnicode.valid = !fileEntry.bitFlag.languageEncodingFlag && extraFieldUnicode.signature == getUint32(dataViewSignature, 0);
+ if (extraFieldUnicode.valid) {
+ directory[propertyName] = extraFieldUnicode[propertyName];
+ directory[propertyName + "UTF8"] = true;
+ }
+ }
+
+ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
+ const extraFieldView = getDataView$1(extraFieldAES.data);
+ extraFieldAES.vendorVersion = getUint8(extraFieldView, 0);
+ extraFieldAES.vendorId = getUint8(extraFieldView, 2);
+ const strength = getUint8(extraFieldView, 4);
+ extraFieldAES.strength = strength;
+ extraFieldAES.originalCompressionMethod = compressionMethod;
+ directory.compressionMethod = extraFieldAES.compressionMethod = getUint16(extraFieldView, 5);
+ }
+
+ function readExtraFieldNTFS(extraFieldNTFS, directory) {
+ const extraFieldView = getDataView$1(extraFieldNTFS.data);
+ let offsetExtraField = 4;
+ let tag1Data;
+ try {
+ while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
+ const tagValue = getUint16(extraFieldView, offsetExtraField);
+ const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
+ if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
+ tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
+ }
+ offsetExtraField += 4 + attributeSize;
+ }
+ } catch (_error) {
+ // ignored
+ }
+ try {
+ if (tag1Data && tag1Data.length == 24) {
+ const tag1View = getDataView$1(tag1Data);
+ const rawLastModDate = tag1View.getBigUint64(0, true);
+ const rawLastAccessDate = tag1View.getBigUint64(8, true);
+ const rawCreationDate = tag1View.getBigUint64(16, true);
+ Object.assign(extraFieldNTFS, {
+ rawLastModDate,
+ rawLastAccessDate,
+ rawCreationDate
+ });
+ const lastModDate = getDateNTFS(rawLastModDate);
+ const lastAccessDate = getDateNTFS(rawLastAccessDate);
+ const creationDate = getDateNTFS(rawCreationDate);
+ const extraFieldData = { lastModDate, lastAccessDate, creationDate };
+ Object.assign(extraFieldNTFS, extraFieldData);
+ Object.assign(directory, extraFieldData);
+ }
+ } catch (_error) {
+ // ignored
+ }
+ }
+
+ function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory) {
+ const extraFieldView = getDataView$1(extraFieldExtendedTimestamp.data);
+ const flags = getUint8(extraFieldView, 0);
+ const timeProperties = [];
+ const timeRawProperties = [];
+ if ((flags & 0x1) == 0x1) {
+ timeProperties.push("lastModDate");
+ timeRawProperties.push("rawLastModDate");
+ }
+ if ((flags & 0x2) == 0x2) {
+ timeProperties.push("lastAccessDate");
+ timeRawProperties.push("rawLastAccessDate");
+ }
+ if ((flags & 0x4) == 0x4) {
+ timeProperties.push("creationDate");
+ timeRawProperties.push("rawCreationDate");
+ }
+ let offset = 1;
+ timeProperties.forEach((propertyName, indexProperty) => {
+ if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
+ const time = getUint32(extraFieldView, offset);
+ directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date(time * 1000);
+ const rawPropertyName = timeRawProperties[indexProperty];
+ extraFieldExtendedTimestamp[rawPropertyName] = time;
+ }
+ offset += 4;
+ });
+ }
+
+ async function seekSignature(reader, signature, startOffset, minimumBytes, maximumLength) {
+ const signatureArray = new Uint8Array(4);
+ const signatureView = getDataView$1(signatureArray);
+ setUint32$1(signatureView, 0, signature);
+ const maximumBytes = minimumBytes + maximumLength;
+ return (await seek(minimumBytes)) || await seek(Math.min(maximumBytes, startOffset));
+
+ async function seek(length) {
+ const offset = startOffset - length;
+ const bytes = await readUint8Array(reader, offset, length);
+ for (let indexByte = bytes.length - minimumBytes; indexByte >= 0; indexByte--) {
+ if (bytes[indexByte] == signatureArray[0] && bytes[indexByte + 1] == signatureArray[1] &&
+ bytes[indexByte + 2] == signatureArray[2] && bytes[indexByte + 3] == signatureArray[3]) {
+ return {
+ offset: offset + indexByte,
+ buffer: bytes.slice(indexByte, indexByte + minimumBytes).buffer
+ };
+ }
+ }
+ }
+ }
+
+ function getOptionValue$1(zipReader, options, name) {
+ return options[name] === undefined ? zipReader.options[name] : options[name];
+ }
+
+ function getDate(timeRaw) {
+ const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
+ try {
+ return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
+ } catch (_error) {
+ // ignored
+ }
+ }
+
+ function getDateNTFS(timeRaw) {
+ return new Date((Number((timeRaw / BigInt(10000)) - BigInt(11644473600000))));
+ }
+
+ function getUint8(view, offset) {
+ return view.getUint8(offset);
+ }
+
+ function getUint16(view, offset) {
+ return view.getUint16(offset, true);
+ }
+
+ function getUint32(view, offset) {
+ return view.getUint32(offset, true);
+ }
+
+ function getBigUint64(view, offset) {
+ return Number(view.getBigUint64(offset, true));
+ }
+
+ function setUint32$1(view, offset, value) {
+ view.setUint32(offset, value, true);
+ }
+
+ function getDataView$1(array) {
+ return new DataView(array.buffer);
+ }
+
+ function readUint8Array(reader, offset, size) {
+ return reader.readUint8Array(offset, size);
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ const ERR_DUPLICATED_NAME = "File already exists";
+ const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
+ const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
+ const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
+ const ERR_INVALID_VERSION = "Version exceeds 65535";
+ const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
+ const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
+ const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
+ const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (make sure 'keepOrder' is set to 'true')";
+
+ const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
+ const EXTRAFIELD_LENGTH_ZIP64 = 24;
+
+ let workers = 0;
+ const pendingEntries = [];
+
+ class ZipWriter {
+
+ constructor(writer, options = {}) {
+ Object.assign(this, {
+ writer,
+ options,
+ config: getConfiguration(),
+ files: new Map(),
+ filenames: new Set(),
+ offset: writer.size || 0,
+ pendingCompressedSize: 0,
+ pendingAddFileCalls: new Set()
+ });
+ }
+
+ async add(name = "", reader, options = {}) {
+ const zipWriter = this;
+ const {
+ pendingAddFileCalls,
+ config
+ } = zipWriter;
+ if (workers < config.maxWorkers) {
+ workers++;
+ } else {
+ await new Promise(resolve => pendingEntries.push(resolve));
+ }
+ let promiseAddFile;
+ try {
+ name = name.trim();
+ if (zipWriter.filenames.has(name)) {
+ throw new Error(ERR_DUPLICATED_NAME);
+ }
+ zipWriter.filenames.add(name);
+ promiseAddFile = addFile(zipWriter, name, reader, options);
+ pendingAddFileCalls.add(promiseAddFile);
+ return await promiseAddFile;
+ } catch (error) {
+ zipWriter.filenames.delete(name);
+ throw error;
+ } finally {
+ pendingAddFileCalls.delete(promiseAddFile);
+ const pendingEntry = pendingEntries.shift();
+ if (pendingEntry) {
+ pendingEntry();
+ } else {
+ workers--;
+ }
+ }
+ }
+
+ async close(comment = new Uint8Array(), options = {}) {
+ const { pendingAddFileCalls, writer } = this;
+ const { writable } = writer;
+ while (pendingAddFileCalls.size) {
+ await Promise.all(Array.from(pendingAddFileCalls));
+ }
+ await closeFile(this, comment, options);
+ if (!writer.preventClose && !options.preventClose) {
+ await writable.getWriter().close();
+ }
+ return writer.getData ? writer.getData() : writable;
+ }
+ }
+
+ async function addFile(zipWriter, name, reader, options) {
+ name = name.trim();
+ if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
+ name += DIRECTORY_SIGNATURE;
+ } else {
+ options.directory = name.endsWith(DIRECTORY_SIGNATURE);
+ }
+ const rawFilename = encodeText(name);
+ if (rawFilename.length > MAX_16_BITS) {
+ throw new Error(ERR_INVALID_ENTRY_NAME);
+ }
+ const comment = options.comment || "";
+ const rawComment = encodeText(comment);
+ if (rawComment.length > MAX_16_BITS) {
+ throw new Error(ERR_INVALID_ENTRY_COMMENT);
+ }
+ const version = zipWriter.options.version || options.version || 0;
+ if (version > MAX_16_BITS) {
+ throw new Error(ERR_INVALID_VERSION);
+ }
+ const versionMadeBy = zipWriter.options.versionMadeBy || options.versionMadeBy || 20;
+ if (versionMadeBy > MAX_16_BITS) {
+ throw new Error(ERR_INVALID_VERSION);
+ }
+ const lastModDate = getOptionValue(zipWriter, options, "lastModDate") || new Date();
+ const lastAccessDate = getOptionValue(zipWriter, options, "lastAccessDate");
+ const creationDate = getOptionValue(zipWriter, options, "creationDate");
+ const password = getOptionValue(zipWriter, options, "password");
+ const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength") || 3;
+ const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
+ if (password !== undefined && encryptionStrength !== undefined && (encryptionStrength < 1 || encryptionStrength > 3)) {
+ throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
+ }
+ let rawExtraField = new Uint8Array();
+ const { extraField } = options;
+ if (extraField) {
+ let extraFieldSize = 0;
+ let offset = 0;
+ extraField.forEach(data => extraFieldSize += 4 + data.length);
+ rawExtraField = new Uint8Array(extraFieldSize);
+ extraField.forEach((data, type) => {
+ if (type > MAX_16_BITS) {
+ throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
+ }
+ if (data.length > MAX_16_BITS) {
+ throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
+ }
+ arraySet(rawExtraField, new Uint16Array([type]), offset);
+ arraySet(rawExtraField, new Uint16Array([data.length]), offset + 2);
+ arraySet(rawExtraField, data, offset + 4);
+ offset += 4 + data.length;
+ });
+ }
+ let extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp");
+ if (extendedTimestamp === undefined) {
+ extendedTimestamp = true;
+ }
+ let maximumCompressedSize = 0;
+ let keepOrder = getOptionValue(zipWriter, options, "keepOrder");
+ if (keepOrder === undefined) {
+ keepOrder = true;
+ }
+ let uncompressedSize = 0;
+ let msDosCompatible = getOptionValue(zipWriter, options, "msDosCompatible");
+ if (msDosCompatible === undefined) {
+ msDosCompatible = true;
+ }
+ const internalFileAttribute = getOptionValue(zipWriter, options, "internalFileAttribute") || 0;
+ const externalFileAttribute = getOptionValue(zipWriter, options, "externalFileAttribute") || 0;
+ if (reader) {
+ await initStream(reader);
+ if (reader.size === undefined) {
+ options.dataDescriptor = true;
+ } else {
+ uncompressedSize = reader.size;
+ }
+ maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
+ }
+ let zip64 = options.zip64 || zipWriter.options.zip64 || false;
+ if (zipWriter.offset + zipWriter.pendingCompressedSize >= MAX_32_BITS ||
+ uncompressedSize >= MAX_32_BITS ||
+ maximumCompressedSize >= MAX_32_BITS) {
+ if (options.zip64 === false || zipWriter.options.zip64 === false || !keepOrder) {
+ throw new Error(ERR_UNSUPPORTED_FORMAT);
+ } else {
+ zip64 = true;
+ }
+ }
+ zipWriter.pendingCompressedSize += maximumCompressedSize;
+ await Promise.resolve();
+ const level = getOptionValue(zipWriter, options, "level");
+ const useWebWorkers = getOptionValue(zipWriter, options, "useWebWorkers");
+ const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
+ let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor");
+ let dataDescriptorSignature = getOptionValue(zipWriter, options, "dataDescriptorSignature");
+ const signal = getOptionValue(zipWriter, options, "signal");
+ const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
+ if (dataDescriptor === undefined) {
+ dataDescriptor = true;
+ }
+ if (dataDescriptor && dataDescriptorSignature === undefined) {
+ dataDescriptorSignature = false;
+ }
+ const fileEntry = await getFileEntry(zipWriter, name, reader, Object.assign({}, options, {
+ rawFilename,
+ rawComment,
+ version,
+ versionMadeBy,
+ lastModDate,
+ lastAccessDate,
+ creationDate,
+ rawExtraField,
+ zip64,
+ password,
+ level,
+ useWebWorkers,
+ encryptionStrength,
+ extendedTimestamp,
+ zipCrypto,
+ bufferedWrite,
+ keepOrder,
+ dataDescriptor,
+ dataDescriptorSignature,
+ signal,
+ msDosCompatible,
+ internalFileAttribute,
+ externalFileAttribute,
+ useCompressionStream
+ }));
+ if (maximumCompressedSize) {
+ zipWriter.pendingCompressedSize -= maximumCompressedSize;
+ }
+ Object.assign(fileEntry, { name, comment, extraField });
+ return new Entry(fileEntry);
+ }
+
+ async function getFileEntry(zipWriter, name, reader, options) {
+ const {
+ files,
+ writer
+ } = zipWriter;
+ const {
+ keepOrder,
+ dataDescriptor,
+ zipCrypto,
+ signal
+ } = options;
+ const previousFileEntry = Array.from(files.values()).pop();
+ let fileEntry = {};
+ let bufferedWrite;
+ let releaseLockWriter;
+ let releaseLockCurrentFileEntry;
+ let writingBufferedData;
+ let fileWriter;
+ let fileWriterSize;
+ files.set(name, fileEntry);
+ try {
+ let lockPreviousFileEntry;
+ if (keepOrder) {
+ lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
+ requestLockCurrentFileEntry();
+ }
+ if (options.bufferedWrite || zipWriter.lockWriter || !dataDescriptor) {
+ fileWriter = new BlobWriter();
+ bufferedWrite = true;
+ await initStream(writer);
+ } else {
+ fileWriter = writer;
+ zipWriter.lockWriter = Promise.resolve();
+ }
+ await initStream(fileWriter);
+ fileWriterSize = fileWriter.size;
+ fileEntry = await createFileEntry(reader, fileEntry, fileWriter.writable, zipWriter.config, options);
+ files.set(name, fileEntry);
+ fileEntry.filename = name;
+ if (bufferedWrite) {
+ await fileWriter.writable.getWriter().close();
+ let blob = await fileWriter.getData();
+ await lockPreviousFileEntry;
+ await requestLockWriter();
+ writingBufferedData = true;
+ const { writable } = writer;
+ if (!dataDescriptor) {
+ const headerLength = 26;
+ const arrayBuffer = await sliceAsArrayBuffer(blob, 0, headerLength);
+ const arrayBufferView = new DataView(arrayBuffer);
+ if (!fileEntry.encrypted || zipCrypto) {
+ setUint32(arrayBufferView, 14, fileEntry.signature);
+ }
+ if (fileEntry.zip64) {
+ setUint32(arrayBufferView, 18, MAX_32_BITS);
+ setUint32(arrayBufferView, 22, MAX_32_BITS);
+ } else {
+ setUint32(arrayBufferView, 18, fileEntry.compressedSize);
+ setUint32(arrayBufferView, 22, fileEntry.uncompressedSize);
+ }
+ await writeData(writable, new Uint8Array(arrayBuffer));
+ blob = blob.slice(headerLength);
+ }
+ await blob.stream().pipeTo(writable, { preventClose: true, signal });
+ writingBufferedData = false;
+ }
+ fileEntry.offset = zipWriter.offset;
+ if (fileEntry.zip64) {
+ const rawExtraFieldZip64View = getDataView(fileEntry.rawExtraFieldZip64);
+ setBigUint64(rawExtraFieldZip64View, 20, BigInt(fileEntry.offset));
+ } else if (fileEntry.offset >= MAX_32_BITS) {
+ throw new Error(ERR_UNSUPPORTED_FORMAT);
+ }
+ zipWriter.offset += fileEntry.length;
+ return fileEntry;
+ } catch (error) {
+ if ((bufferedWrite && writingBufferedData) || (!bufferedWrite && fileEntry.writingData)) {
+ zipWriter.hasCorruptedEntries = true;
+ if (error) {
+ error.corruptedEntry = true;
+ }
+ zipWriter.offset += fileWriter.size - fileWriterSize;
+ }
+ files.delete(name);
+ throw error;
+ } finally {
+ if (releaseLockCurrentFileEntry) {
+ releaseLockCurrentFileEntry();
+ }
+ if (releaseLockWriter) {
+ releaseLockWriter();
+ }
+ }
+
+ function requestLockCurrentFileEntry() {
+ fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
+ }
+
+ async function requestLockWriter() {
+ const { lockWriter } = zipWriter;
+ if (lockWriter) {
+ await lockWriter.then(() => delete zipWriter.lockWriter);
+ return requestLockWriter();
+ } else {
+ zipWriter.lockWriter = new Promise(resolve => releaseLockWriter = resolve);
+ }
+ }
+ }
+
+ async function createFileEntry(reader, pendingFileEntry, writable, config, options) {
+ const {
+ rawFilename,
+ lastAccessDate,
+ creationDate,
+ password,
+ level,
+ zip64,
+ zipCrypto,
+ dataDescriptor,
+ dataDescriptorSignature,
+ directory,
+ version,
+ versionMadeBy,
+ rawComment,
+ rawExtraField,
+ useWebWorkers,
+ onstart,
+ onprogress,
+ onend,
+ signal,
+ encryptionStrength,
+ extendedTimestamp,
+ msDosCompatible,
+ internalFileAttribute,
+ externalFileAttribute,
+ useCompressionStream
+ } = options;
+ const encrypted = Boolean(password && password.length);
+ const compressed = level !== 0 && !directory;
+ let rawExtraFieldAES;
+ if (encrypted && !zipCrypto) {
+ rawExtraFieldAES = new Uint8Array(EXTRAFIELD_DATA_AES.length + 2);
+ const extraFieldAESView = getDataView(rawExtraFieldAES);
+ setUint16(extraFieldAESView, 0, EXTRAFIELD_TYPE_AES);
+ arraySet(rawExtraFieldAES, EXTRAFIELD_DATA_AES, 2);
+ setUint8(extraFieldAESView, 8, encryptionStrength);
+ } else {
+ rawExtraFieldAES = new Uint8Array();
+ }
+ let rawExtraFieldNTFS;
+ let rawExtraFieldExtendedTimestamp;
+ if (extendedTimestamp) {
+ rawExtraFieldExtendedTimestamp = new Uint8Array(9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0));
+ const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
+ setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
+ setUint16(extraFieldExtendedTimestampView, 2, rawExtraFieldExtendedTimestamp.length - 4);
+ const extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
+ setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
+ setUint32(extraFieldExtendedTimestampView, 5, Math.floor(options.lastModDate.getTime() / 1000));
+ if (lastAccessDate) {
+ setUint32(extraFieldExtendedTimestampView, 9, Math.floor(lastAccessDate.getTime() / 1000));
+ }
+ if (creationDate) {
+ setUint32(extraFieldExtendedTimestampView, 13, Math.floor(creationDate.getTime() / 1000));
+ }
+ try {
+ rawExtraFieldNTFS = new Uint8Array(36);
+ const extraFieldNTFSView = getDataView(rawExtraFieldNTFS);
+ const lastModTimeNTFS = getTimeNTFS(options.lastModDate);
+ setUint16(extraFieldNTFSView, 0, EXTRAFIELD_TYPE_NTFS);
+ setUint16(extraFieldNTFSView, 2, 32);
+ setUint16(extraFieldNTFSView, 8, EXTRAFIELD_TYPE_NTFS_TAG1);
+ setUint16(extraFieldNTFSView, 10, 24);
+ setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
+ setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
+ setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
+ } catch (_error) {
+ rawExtraFieldNTFS = new Uint8Array();
+ }
+ } else {
+ rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
+ }
+ const fileEntry = {
+ lock: pendingFileEntry.lock,
+ version: version || VERSION_DEFLATE,
+ versionMadeBy,
+ zip64,
+ directory: Boolean(directory),
+ filenameUTF8: true,
+ rawFilename,
+ commentUTF8: true,
+ rawComment,
+ rawExtraFieldZip64: zip64 ? new Uint8Array(EXTRAFIELD_LENGTH_ZIP64 + 4) : new Uint8Array(),
+ rawExtraFieldExtendedTimestamp,
+ rawExtraFieldNTFS,
+ rawExtraFieldAES,
+ rawExtraField,
+ extendedTimestamp,
+ msDosCompatible,
+ internalFileAttribute,
+ externalFileAttribute
+ };
+ let uncompressedSize = fileEntry.uncompressedSize = 0;
+ let bitFlag = BITFLAG_LANG_ENCODING_FLAG;
+ if (dataDescriptor) {
+ bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
+ }
+ let compressionMethod = COMPRESSION_METHOD_STORE;
+ if (compressed) {
+ compressionMethod = COMPRESSION_METHOD_DEFLATE;
+ }
+ if (zip64) {
+ fileEntry.version = fileEntry.version > VERSION_ZIP64 ? fileEntry.version : VERSION_ZIP64;
+ }
+ if (encrypted) {
+ bitFlag = bitFlag | BITFLAG_ENCRYPTED;
+ if (!zipCrypto) {
+ fileEntry.version = fileEntry.version > VERSION_AES ? fileEntry.version : VERSION_AES;
+ compressionMethod = COMPRESSION_METHOD_AES;
+ if (compressed) {
+ fileEntry.rawExtraFieldAES[9] = COMPRESSION_METHOD_DEFLATE;
+ }
+ }
+ }
+ fileEntry.compressionMethod = compressionMethod;
+ const headerArray = fileEntry.headerArray = new Uint8Array(26);
+ const headerView = getDataView(headerArray);
+ setUint16(headerView, 0, fileEntry.version);
+ setUint16(headerView, 2, bitFlag);
+ setUint16(headerView, 4, compressionMethod);
+ const dateArray = new Uint32Array(1);
+ const dateView = getDataView(dateArray);
+ let lastModDate;
+ if (options.lastModDate < MIN_DATE) {
+ lastModDate = MIN_DATE;
+ } else if (options.lastModDate > MAX_DATE) {
+ lastModDate = MAX_DATE;
+ } else {
+ lastModDate = options.lastModDate;
+ }
+ setUint16(dateView, 0, (((lastModDate.getHours() << 6) | lastModDate.getMinutes()) << 5) | lastModDate.getSeconds() / 2);
+ setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
+ const rawLastModDate = dateArray[0];
+ setUint32(headerView, 6, rawLastModDate);
+ setUint16(headerView, 22, rawFilename.length);
+ const extraFieldLength = rawExtraFieldAES.length + rawExtraFieldExtendedTimestamp.length + rawExtraFieldNTFS.length + rawExtraField.length;
+ setUint16(headerView, 24, extraFieldLength);
+ const localHeaderArray = new Uint8Array(30 + rawFilename.length + extraFieldLength);
+ const localHeaderView = getDataView(localHeaderArray);
+ setUint32(localHeaderView, 0, LOCAL_FILE_HEADER_SIGNATURE);
+ arraySet(localHeaderArray, headerArray, 4);
+ arraySet(localHeaderArray, rawFilename, 30);
+ arraySet(localHeaderArray, rawExtraFieldAES, 30 + rawFilename.length);
+ arraySet(localHeaderArray, rawExtraFieldExtendedTimestamp, 30 + rawFilename.length + rawExtraFieldAES.length);
+ arraySet(localHeaderArray, rawExtraFieldNTFS, 30 + rawFilename.length + rawExtraFieldAES.length + rawExtraFieldExtendedTimestamp.length);
+ arraySet(localHeaderArray, rawExtraField, 30 + rawFilename.length + rawExtraFieldAES.length + rawExtraFieldExtendedTimestamp.length + rawExtraFieldNTFS.length);
+ let result;
+ let compressedSize = 0;
+ fileEntry.writingData = pendingFileEntry.writingData = true;
+ if (reader) {
+ reader.chunkSize = getChunkSize(config);
+ await writeData(writable, localHeaderArray);
+ const size = () => reader.size;
+ const readable = reader.readable;
+ readable.size = size;
+ const workerOptions = {
+ options: {
+ codecType: CODEC_DEFLATE,
+ level,
+ password,
+ encryptionStrength,
+ zipCrypto: encrypted && zipCrypto,
+ passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
+ signed: true,
+ compressed,
+ encrypted,
+ useWebWorkers,
+ useCompressionStream
+ },
+ config,
+ streamOptions: { signal, size, onstart, onprogress, onend },
+ codecConstructor: config.Deflate
+ };
+ result = await runWorker({ readable, writable }, workerOptions);
+ uncompressedSize = fileEntry.uncompressedSize = reader.size = readable.size();
+ compressedSize = result.size;
+ } else {
+ await writeData(writable, localHeaderArray);
+ }
+ let dataDescriptorArray = new Uint8Array();
+ let dataDescriptorView, dataDescriptorOffset = 0;
+ if (dataDescriptor) {
+ dataDescriptorArray = new Uint8Array(zip64 ? (dataDescriptorSignature ? 24 : 20) : (dataDescriptorSignature ? 16 : 12));
+ dataDescriptorView = getDataView(dataDescriptorArray);
+ if (dataDescriptorSignature) {
+ dataDescriptorOffset = 4;
+ setUint32(dataDescriptorView, 0, DATA_DESCRIPTOR_RECORD_SIGNATURE);
+ }
+ }
+ if (reader) {
+ const { signature } = result;
+ if ((!encrypted || zipCrypto) && signature !== undefined) {
+ setUint32(headerView, 10, signature);
+ fileEntry.signature = signature;
+ if (dataDescriptor) {
+ setUint32(dataDescriptorView, dataDescriptorOffset, signature);
+ }
+ }
+ if (zip64) {
+ const rawExtraFieldZip64View = getDataView(fileEntry.rawExtraFieldZip64);
+ setUint16(rawExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
+ setUint16(rawExtraFieldZip64View, 2, EXTRAFIELD_LENGTH_ZIP64);
+ setUint32(headerView, 14, MAX_32_BITS);
+ setBigUint64(rawExtraFieldZip64View, 12, BigInt(compressedSize));
+ setUint32(headerView, 18, MAX_32_BITS);
+ setBigUint64(rawExtraFieldZip64View, 4, BigInt(uncompressedSize));
+ if (dataDescriptor) {
+ setBigUint64(dataDescriptorView, dataDescriptorOffset + 4, BigInt(compressedSize));
+ setBigUint64(dataDescriptorView, dataDescriptorOffset + 12, BigInt(uncompressedSize));
+ }
+ } else {
+ setUint32(headerView, 14, compressedSize);
+ setUint32(headerView, 18, uncompressedSize);
+ if (dataDescriptor) {
+ setUint32(dataDescriptorView, dataDescriptorOffset + 4, compressedSize);
+ setUint32(dataDescriptorView, dataDescriptorOffset + 8, uncompressedSize);
+ }
+ }
+ }
+ if (dataDescriptor) {
+ await writeData(writable, dataDescriptorArray);
+ }
+ const length = localHeaderArray.length + compressedSize + dataDescriptorArray.length;
+ Object.assign(fileEntry, {
+ compressedSize,
+ lastModDate,
+ rawLastModDate,
+ creationDate,
+ lastAccessDate,
+ encrypted,
+ length,
+ writingData: false
+ });
+ return fileEntry;
+ }
+
+ async function closeFile(zipWriter, comment, options) {
+ const { files } = zipWriter;
+ let offset = 0;
+ let directoryDataLength = 0;
+ let directoryOffset = zipWriter.offset;
+ let filesLength = files.size;
+ for (const [, fileEntry] of files) {
+ directoryDataLength += 46 +
+ fileEntry.rawFilename.length +
+ fileEntry.rawComment.length +
+ fileEntry.rawExtraFieldZip64.length +
+ fileEntry.rawExtraFieldAES.length +
+ fileEntry.rawExtraFieldExtendedTimestamp.length +
+ fileEntry.rawExtraFieldNTFS.length +
+ fileEntry.rawExtraField.length;
+ }
+ let zip64 = options.zip64 || zipWriter.options.zip64 || false;
+ if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS) {
+ if (options.zip64 === false || zipWriter.options.zip64 === false) {
+ throw new Error(ERR_UNSUPPORTED_FORMAT);
+ } else {
+ zip64 = true;
+ }
+ }
+ const directoryArray = new Uint8Array(directoryDataLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH));
+ const directoryView = getDataView(directoryArray);
+ for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
+ const {
+ rawFilename,
+ rawExtraFieldZip64,
+ rawExtraFieldAES,
+ rawExtraField,
+ rawComment,
+ versionMadeBy,
+ headerArray,
+ directory,
+ zip64,
+ msDosCompatible,
+ internalFileAttribute,
+ externalFileAttribute
+ } = fileEntry;
+ let rawExtraFieldExtendedTimestamp;
+ let rawExtraFieldNTFS;
+ if (fileEntry.extendedTimestamp) {
+ rawExtraFieldNTFS = fileEntry.rawExtraFieldNTFS;
+ rawExtraFieldExtendedTimestamp = new Uint8Array(9);
+ const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
+ setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
+ setUint16(extraFieldExtendedTimestampView, 2, rawExtraFieldExtendedTimestamp.length - 4);
+ setUint8(extraFieldExtendedTimestampView, 4, 0x1);
+ setUint32(extraFieldExtendedTimestampView, 5, Math.floor(fileEntry.lastModDate.getTime() / 1000));
+ } else {
+ rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
+ }
+ const extraFieldLength = rawExtraFieldZip64.length + rawExtraFieldAES.length + rawExtraFieldExtendedTimestamp.length + rawExtraFieldNTFS.length + rawExtraField.length;
+ setUint32(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE);
+ setUint16(directoryView, offset + 4, versionMadeBy);
+ arraySet(directoryArray, headerArray, offset + 6);
+ setUint16(directoryView, offset + 30, extraFieldLength);
+ setUint16(directoryView, offset + 32, rawComment.length);
+ setUint16(directoryView, offset + 36, internalFileAttribute);
+ if (externalFileAttribute) {
+ setUint32(directoryView, offset + 38, externalFileAttribute);
+ } else if (directory && msDosCompatible) {
+ setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
+ }
+ if (zip64) {
+ setUint32(directoryView, offset + 42, MAX_32_BITS);
+ } else {
+ setUint32(directoryView, offset + 42, fileEntry.offset);
+ }
+ arraySet(directoryArray, rawFilename, offset + 46);
+ arraySet(directoryArray, rawExtraFieldZip64, offset + 46 + rawFilename.length);
+ arraySet(directoryArray, rawExtraFieldAES, offset + 46 + rawFilename.length + rawExtraFieldZip64.length);
+ arraySet(directoryArray, rawExtraFieldExtendedTimestamp, offset + 46 + rawFilename.length + rawExtraFieldZip64.length + rawExtraFieldAES.length);
+ arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + rawFilename.length + rawExtraFieldZip64.length + rawExtraFieldAES.length + rawExtraFieldExtendedTimestamp.length);
+ arraySet(directoryArray, rawExtraField, offset + 46 + rawFilename.length + rawExtraFieldZip64.length + rawExtraFieldAES.length + rawExtraFieldExtendedTimestamp.length + rawExtraFieldNTFS.length);
+ arraySet(directoryArray, rawComment, offset + 46 + rawFilename.length + extraFieldLength);
+ offset += 46 + rawFilename.length + extraFieldLength + rawComment.length;
+ if (options.onprogress) {
+ try {
+ await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
+ } catch (_error) {
+ // ignored
+ }
+ }
+ }
+ if (zip64) {
+ setUint32(directoryView, offset, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
+ setBigUint64(directoryView, offset + 4, BigInt(44));
+ setUint16(directoryView, offset + 12, 45);
+ setUint16(directoryView, offset + 14, 45);
+ setBigUint64(directoryView, offset + 24, BigInt(filesLength));
+ setBigUint64(directoryView, offset + 32, BigInt(filesLength));
+ setBigUint64(directoryView, offset + 40, BigInt(directoryDataLength));
+ setBigUint64(directoryView, offset + 48, BigInt(directoryOffset));
+ setUint32(directoryView, offset + 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
+ setBigUint64(directoryView, offset + 64, BigInt(directoryOffset) + BigInt(directoryDataLength));
+ setUint32(directoryView, offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS);
+ filesLength = MAX_16_BITS;
+ directoryOffset = MAX_32_BITS;
+ directoryDataLength = MAX_32_BITS;
+ offset += 76;
+ }
+ setUint32(directoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE);
+ setUint16(directoryView, offset + 8, filesLength);
+ setUint16(directoryView, offset + 10, filesLength);
+ setUint32(directoryView, offset + 12, directoryDataLength);
+ setUint32(directoryView, offset + 16, directoryOffset);
+ if (comment && comment.length) {
+ if (comment.length <= MAX_16_BITS) {
+ setUint16(directoryView, offset + 20, comment.length);
+ } else {
+ throw new Error(ERR_INVALID_COMMENT);
+ }
+ }
+ const { writable } = zipWriter.writer;
+ await initStream(zipWriter.writer);
+ await writeData(writable, directoryArray);
+ if (comment && comment.length) {
+ await writeData(writable, comment);
+ }
+ }
+
+ function sliceAsArrayBuffer(blob, start, end) {
+ if (start || end) {
+ return blob.slice(start, end).arrayBuffer();
+ } else {
+ return blob.arrayBuffer();
+ }
+ }
+
+ async function writeData(writable, array) {
+ const streamWriter = writable.getWriter();
+ await streamWriter.ready;
+ await streamWriter.write(array);
+ streamWriter.releaseLock();
+ }
+
+ function getTimeNTFS(date) {
+ if (date) {
+ return ((BigInt(date.getTime()) + BigInt(11644473600000)) * BigInt(10000));
+ }
+ }
+
+ function getOptionValue(zipWriter, options, name) {
+ return options[name] === undefined ? zipWriter.options[name] : options[name];
+ }
+
+ function getMaximumCompressedSize(uncompressedSize) {
+ return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
+ }
+
+ function setUint8(view, offset, value) {
+ view.setUint8(offset, value);
+ }
+
+ function setUint16(view, offset, value) {
+ view.setUint16(offset, value, true);
+ }
+
+ function setUint32(view, offset, value) {
+ view.setUint32(offset, value, true);
+ }
+
+ function setBigUint64(view, offset, value) {
+ view.setBigUint64(offset, value, true);
+ }
+
+ function arraySet(array, typedArray, offset) {
+ array.set(typedArray, offset);
+ }
+
+ function getDataView(array) {
+ return new DataView(array.buffer);
+ }
+
+ /*
+ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+ INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ let baseURL;
+ try {
+ baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('zip.js', document.baseURI).href));
+ } catch (error) {
+ // ignored
+ }
+ configure({ baseURL });
+ e(configure);
+
+ exports.BlobReader = BlobReader;
+ exports.BlobWriter = BlobWriter;
+ exports.Data64URIReader = Data64URIReader;
+ exports.Data64URIWriter = Data64URIWriter;
+ exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
+ exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
+ exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
+ exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
+ exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
+ exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
+ exports.ERR_EOCDR_ZIP64_NOT_FOUND = ERR_EOCDR_ZIP64_NOT_FOUND;
+ exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
+ exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
+ exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
+ exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
+ exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
+ exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
+ exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
+ exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
+ exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
+ exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
+ exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
+ exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
+ exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
+ exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
+ exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
+ exports.HttpRangeReader = HttpRangeReader;
+ exports.HttpReader = HttpReader;
+ exports.Reader = Reader;
+ exports.TextReader = TextReader;
+ exports.TextWriter = TextWriter;
+ exports.Uint8ArrayReader = Uint8ArrayReader;
+ exports.Uint8ArrayWriter = Uint8ArrayWriter;
+ exports.Writer = Writer;
+ exports.ZipReader = ZipReader;
+ exports.ZipWriter = ZipWriter;
+ exports.configure = configure;
+ exports.getMimeType = getMimeType;
+ exports.initShimAsyncCodec = streamCodecShim;
+ exports.initStream = initStream;
+ exports.terminateWorkers = terminateWorkers;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/previewers/betatest/lib/cdi-viewer.bundle.min.js b/previewers/betatest/lib/cdi-viewer.bundle.min.js
new file mode 100644
index 00000000..7ecb568b
--- /dev/null
+++ b/previewers/betatest/lib/cdi-viewer.bundle.min.js
@@ -0,0 +1,97 @@
+var CDIViewer=function(e,t){"use strict";function r(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})}),Object.freeze(e)}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}for(var a={},s={byteLength:function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},toByteArray:function(e){var t,r,n=f(e),i=n[0],o=n[1],a=new l(function(e,t,r){return 3*(t+r)/4-r}(0,i,o)),s=0,c=o>0?i-4:i;for(r=0;r>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===o&&(t=u[e.charCodeAt(r)]<<2|u[e.charCodeAt(r+1)]>>4,a[s++]=255&t);1===o&&(t=u[e.charCodeAt(r)]<<10|u[e.charCodeAt(r+1)]<<4|u[e.charCodeAt(r+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},fromByteArray:function(e){for(var t,r=e.length,n=r%3,i=[],o=16383,a=0,s=r-n;as?s:a+o));1===n?(t=e[r-1],i.push(c[t>>2]+c[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],i.push(c[t>>10]+c[t>>4&63]+c[t<<2&63]+"="));return i.join("")}},c=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0;p<64;++p)c[p]=d[p],u[d.charCodeAt(p)]=p;function f(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function h(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function y(e,t,r){for(var n,i=[],o=t;o */
+read:function(e,t,r,n,i){var o,a,s=8*i-n-1,c=(1<>1,l=-7,d=r?i-1:0,p=r?-1:1,f=e[t+d];for(d+=p,o=f&(1<<-l)-1,f>>=-l,l+=s;l>0;o=256*o+e[t+d],d+=p,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+e[t+d],d+=p,l-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),o-=u}return(f?-1:1)*a*Math.pow(2,o-n)},write:function(e,t,r,n,i,o){var a,s,c,u=8*o-i-1,l=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,h=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+d>=1?p/c:p*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=l?(s=0,a=l):a+d>=1?(s=(t*c-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&s,f+=h,s/=256,i-=8);for(a=a<0;e[r+f]=255&a,f+=h,a/=256,u-=8);e[r+f-h]|=128*y}};
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+!function(e){const t=s,r=g,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},e.INSPECT_MAX_BYTES=50;const i=2147483647;function o(e){if(e>i)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return c(e,t,r)}function c(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|h(e,t);let n=o(r);const i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(W(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return a.from(n,t,r);const i=function(e){if(a.isBuffer(e)){const t=0|f(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||K(e.length)?o(0):d(e);if("Buffer"===e.type&&Array.isArray(e.data))return d(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return u(e),o(e<0?0:0|f(e))}function d(e){const t=e.length<0?0:0|f(e.length),r=o(t);for(let n=0;n=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function h(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return X(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(i)return n?-1:X(e).length;t=(""+t).toLowerCase(),i=!0}}function y(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return F(this,t,r);case"utf8":case"utf-8":return j(this,t,r);case"ascii":return E(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return x(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),K(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){let o,a=1,s=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){let n=-1;for(o=r;os&&(r=s-c),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=t.length;let a;for(n>o/2&&(n=o/2),a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function x(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function j(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+a<=r){let r,n,s,c;switch(a){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(o=c));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[i+1],n=e[i+2],s=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&s,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(e){const t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn.length?(a.isBuffer(t)||(t=a.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!a.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},a.byteLength=h,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tr&&(t+=" ... "),""},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(e,t,r,n,i){if(W(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const c=Math.min(o,s),u=this.slice(n,i),l=e.slice(t,r);for(let e=0;e>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":case"latin1":case"binary":return T(this,e,t,r);case"base64":return O(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function E(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;in)&&(r=n);let i="";for(let n=t;nr)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function R(e,t,r,n,i){Q(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,r}function M(e,t,r,n,i){Q(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a>>=8,e[r+2]=a,a>>=8,e[r+1]=a,a>>=8,e[r]=a,r+8}function L(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(e,t,n,i,o){return t=+t,n>>>=0,o||L(e,0,n,4),r.write(e,t,n,i,23,4),n+4}function k(e,t,n,i,o){return t=+t,n>>>=0,o||L(e,0,n,8),r.write(e,t,n,i,52,8),n+8}a.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||N(e,t,this.length);let n=this[e],i=1,o=0;for(;++o>>=0,t>>>=0,r||N(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=Z(function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<>>=0,t>>>=0,r||N(e,t,this.length);let n=this[e],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||N(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||N(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=Z(function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||N(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){P(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,!n){P(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeBigUInt64LE=Z(function(e,t=0){return R(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Z(function(e,t=0){return M(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}let i=0,o=1,a=0;for(this[t]=255&e;++i>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/o|0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeBigInt64LE=Z(function(e,t=0){return R(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Z(function(e,t=0){return M(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeFloatLE=function(e,t,r){return C(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return C(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return k(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return k(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function Q(e,t,r,n,i,o){if(e>r||e= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new B.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,r){z(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||G(t,e.length-(r+1))}(n,i,o)}function z(e,t){if("number"!=typeof e)throw new B.ERR_INVALID_ARG_TYPE(t,"number",e)}function G(e,t,r){if(Math.floor(e)!==e)throw z(e,r),new B.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new B.ERR_BUFFER_OUT_OF_BOUNDS;throw new B.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}U("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),U("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=q(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=q(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);const V=/[^+/0-9A-Za-z-_]/g;function X(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let a=0;a55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function J(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function W(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}const Y=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function Z(e){return"undefined"==typeof BigInt?ee:e}function ee(){throw new Error("BigInt not supported")}}(a);const m="http://www.w3.org/1999/02/22-rdf-syntax-ns#",b="http://www.w3.org/2001/XMLSchema#",v="http://www.w3.org/2000/10/swap/";var _={xsd:{decimal:`${b}decimal`,boolean:`${b}boolean`,double:`${b}double`,integer:`${b}integer`,string:`${b}string`},rdf:{type:`${m}type`,nil:`${m}nil`,first:`${m}first`,rest:`${m}rest`,langString:`${m}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${v}reify#forSome`,forAll:`${v}reify#forAll`},log:{implies:`${v}log#implies`,isImpliedBy:`${v}log#isImpliedBy`}};const{xsd:w}=_,T=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,O={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},S=/[\x00-\x20<>\\"\{\}\|\^\`]/,x={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},j=/$0^/;class A{constructor(e){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,e=e||{},this._isImpliedBy=e.isImpliedBy,this._lineMode=!!e.lineMode){this._n3Mode=!1;for(const e in this)!(e in x)&&this[e]instanceof RegExp&&(this[e]=j)}else this._n3Mode=!1!==e.n3;this.comments=!!e.comments,this._literalClosingPos=0}_tokenizeToEnd(e,t){let r=this._input,n=r.length;for(;;){let e,a;for(;e=this._newline.exec(r);)this.comments&&(a=this._comment.exec(e[0]))&&i("comment",a[1],"",this._line,e[0].length),r=r.substr(e[0].length,r.length),n=r.length,this._line++;if(!e&&(e=this._whitespace.exec(r))&&(r=r.substr(e[0].length,r.length)),this._endOfFile.test(r))return t&&(this.comments&&(a=this._comment.exec(r))&&i("comment",a[1],"",this._line,r.length),r=null,i("eof","","",this._line,0)),this._input=r;const s=this._line,c=r[0];let u="",l="",d="",p=null,f=0,h=!1;switch(c){case"^":if(r.length<3)break;if("^"!==r[1]){this._n3Mode&&(f=1,u="^");break}if(this._previousMarker="^^",r=r.substr(2),"<"!==r[0]){h=!0;break}case"<":if(p=this._unescapedIri.exec(r))u="IRI",l=p[1];else if(p=this._iri.exec(r)){if(l=this._unescape(p[1]),null===l||S.test(l))return o(this);u="IRI"}else r.length>1&&"<"===r[1]?(u="<<",f=2):this._n3Mode&&r.length>1&&"="===r[1]&&(f=2,this._isImpliedBy?(u="abbreviation",l="<"):(u="inverse",l=">"));break;case">":r.length>1&&">"===r[1]&&(u=">>",f=2);break;case"_":((p=this._blank.exec(r))||t&&(p=this._blank.exec(`${r} `)))&&(u="blank",d="_",l=p[1]);break;case'"':if(p=this._simpleQuotedString.exec(r))l=p[1];else if(({value:l,matchLength:f}=this._parseLiteral(r)),null===l)return o(this);null===p&&0===f||(u="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(p=this._simpleApostropheString.exec(r))l=p[1];else if(({value:l,matchLength:f}=this._parseLiteral(r)),null===l)return o(this);null===p&&0===f||(u="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(p=this._variable.exec(r))&&(u="var",l=p[0]);break;case"@":"literal"===this._previousMarker&&(p=this._langcode.exec(r))?(u="langcode",l=p[1]):(p=this._keyword.exec(r))&&(u=p[0]);break;case".":if(1===r.length?t:r[1]<"0"||r[1]>"9"){u=".",f=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(p=this._number.exec(r)||t&&(p=this._number.exec(`${r} `)))&&(u="literal",l=p[0],d="string"==typeof p[1]?w.double:"string"==typeof p[2]?w.decimal:w.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(p=this._sparqlKeyword.exec(r))?u=p[0].toUpperCase():h=!0;break;case"f":case"t":(p=this._boolean.exec(r))?(u="literal",l=p[0],d=w.boolean):h=!0;break;case"a":(p=this._shortPredicates.exec(r))?(u="abbreviation",l="a"):h=!0;break;case"=":this._n3Mode&&r.length>1&&(u="abbreviation",">"!==r[1]?(f=1,l="="):(f=2,l=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(f=1,u=c);break;case"{":!this._lineMode&&r.length>=2&&("|"===r[1]?(u="{|",f=2):(u=c,f=1));break;case"|":r.length>=2&&"}"===r[1]&&(u="|}",f=2);break;default:h=!0}if(h&&("@prefix"!==this._previousMarker&&"PREFIX"!==this._previousMarker||!(p=this._prefix.exec(r))?((p=this._prefixed.exec(r))||t&&(p=this._prefixed.exec(`${r} `)))&&(u="prefixed",d=p[1]||"",l=this._unescape(p[2])):(u="prefix",l=p[1]||"")),"^^"===this._previousMarker)switch(u){case"prefixed":u="type";break;case"IRI":u="typeIRI";break;default:u=""}if(!u)return t||!/^'''|^"""/.test(r)&&/\n|\r/.test(r)?o(this):this._input=r;const y=f||p[0].length,g=i(u,l,d,s,y);this.previousToken=g,this._previousMarker=u,r=r.substr(y,r.length)}function i(t,i,o,a,s){const c=r?n-r.length:n,u={type:t,value:i,prefix:o,line:a,start:c,end:c+s};return e(null,u),u}function o(t){e(t._syntaxError(/^\S*/.exec(r)[0]))}}_unescape(e){let t=!1;const r=e.replace(T,(e,r,n,i)=>{if("string"==typeof r)return String.fromCharCode(Number.parseInt(r,16));if("string"==typeof n){let e=Number.parseInt(n,16);return e<=65535?String.fromCharCode(Number.parseInt(n,16)):String.fromCharCode(55296+((e-=65536)>>10),56320+(1023&e))}return i in O?O[i]:(t=!0,"")});return t?null:r}_parseLiteral(e){if(e.length>=3){const t=e.match(/^(?:"""|"|'''|'|)/)[0],r=t.length;let n=Math.max(this._literalClosingPos,r);for(;(n=e.indexOf(t,n))>0;){let t=0;for(;"\\"===e[n-t-1];)t++;if(t%2==0){const t=e.substring(r,n),i=t.split(/\r\n|\r|\n/).length-1,o=n+r;if(1===r&&0!==i||3===r&&this._lineMode)break;return this._line+=i,{value:this._unescape(t),matchLength:o}}n++}this._literalClosingPos=e.length-r+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;const t=new Error(`Unexpected "${e}" on line ${this._line}.`);return t.context={token:void 0,line:this._line,previousToken:this.previousToken},t}_readStartingBom(e){return e.startsWith("\ufeff")?e.substr(1):e}tokenize(e,t){if(this._line=1,"string"==typeof e){if(this._input=this._readStartingBom(e),"function"!=typeof t){const e=[];let t;if(this._tokenizeToEnd((r,n)=>r?t=r:e.push(n),!0),t)throw t;return e}queueMicrotask(()=>this._tokenizeToEnd(t,!0))}else this._pendingBuffer=null,"function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",e=>{null!==this._input&&0!==e.length&&(this._pendingBuffer&&(e=a.Buffer.concat([this._pendingBuffer,e]),this._pendingBuffer=null),128&e[e.length-1]?this._pendingBuffer=e:(void 0===this._input?this._input=this._readStartingBom("string"==typeof e?e:e.toString()):this._input+=e,this._tokenizeToEnd(t,!1)))}),e.on("end",()=>{"string"==typeof this._input&&this._tokenizeToEnd(t,!0)}),e.on("error",t)}}const{rdf:E,xsd:I}=_;let F,D=0;const N={namedNode:Q,blankNode:z,variable:V,literal:G,defaultGraph:function(){return F},quad:X,triple:X,fromTerm:H,fromQuad:J};let P=class e{constructor(e){this.id=e}get value(){return this.id}equals(t){return t instanceof e?this.id===t.id:!!t&&this.termType===t.termType&&this.value===t.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}},R=class extends P{get termType(){return"NamedNode"}},M=class e extends P{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const e=this.id;let t=e.lastIndexOf('"')+1;return t0?"INF":"-INF")))),""===r||r===I.string?new M(`"${e}"`):new M(`"${e}"^^${r}`)}function V(e){return new C(e)}function X(e,t,r,n){return new q(e,t,r,n)}function H(e){if(e instanceof P)return e;switch(e.termType){case"NamedNode":return Q(e.value);case"BlankNode":return z(e.value);case"Variable":return V(e.value);case"DefaultGraph":return F;case"Literal":return G(e.value,e.language||e.datatype);case"Quad":return J(e);default:throw new Error(`Unexpected termType: ${e.termType}`)}}function J(e){if(e instanceof q)return e;if("Quad"!==e.termType)throw new Error(`Unexpected termType: ${e.termType}`);return X(H(e.subject),H(e.predicate),H(e.object),H(e.graph))}let W=0;class K{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&Z(this,e.factory);const t="string"==typeof e.format?e.format.match(/\w*$/)[0].toLowerCase():"",r=/turtle/.test(t),n=/trig/.test(t),i=/triple/.test(t),o=/quad/.test(t),a=this._n3Mode=/n3/.test(t),s=i||o;(this._supportsNamedGraphs=!(r||a))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||n||i||a),this._isImpliedBy=e.isImpliedBy,this._supportsRDFStar=""===t||/star|\*$/.test(t),s&&(this._resolveRelativeIRI=e=>null),this._blankNodePrefix="string"!=typeof e.blankNodePrefix?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new A({lineMode:s,n3:a,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){W=0}_setBase(e){if(e){const t=e.indexOf("#");t>=0&&(e=e.substr(0,t)),this._base=e,this._basePath=e.indexOf("/")<0?e:e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=e[0],this._baseScheme=e[1]}else this._base="",this._basePath=""}_saveContext(e,t,r,n,i){const o=this._n3Mode;this._contextStack.push({type:e,subject:r,predicate:n,object:i,graph:t,inverse:!!o&&this._inversePredicate,blankPrefix:o?this._prefixes._:"",quantified:o?this._quantified:null}),o&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,t){const r=this._contextStack.pop();if(!r||r.type!==e)return this._error(`Unexpected ${t.type}`,t);this._subject=r.subject,this._predicate=r.predicate,this._object=r.object,this._graph=r.graph,this._n3Mode&&(this._inversePredicate=r.inverse,this._prefixes._=r.blankPrefix,this._quantified=r.quantified)}_readInTopContext(e){switch(e.type){case"eof":return null!==this._graph?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(e)}}_readEntity(e,t){let r;switch(e.type){case"IRI":case"typeIRI":const t=this._resolveIRI(e.value);if(null===t)return this._error("Invalid IRI",e);r=this._factory.namedNode(t);break;case"type":case"prefixed":const n=this._prefixes[e.prefix];if(void 0===n)return this._error(`Undefined prefix "${e.prefix}:"`,e);r=this._factory.namedNode(n+e.value);break;case"blank":r=this._factory.blankNode(this._prefixes[e.prefix]+e.value);break;case"var":r=this._factory.variable(e.value.substr(1));break;default:return this._error(`Expected entity but got ${e.type}`,e)}return!t&&this._n3Mode&&r.id in this._quantified&&(r=this._quantified[r.id]),r}_readSubject(e){switch(this._predicate=null,e.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",e);case"}":return this._readPunctuation(e);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',e);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',e);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",e);if(0===e.prefix.length)return this._literalValue=e.value,this._completeSubjectLiteral;this._subject=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if(void 0===(this._subject=this._readEntity(e)))return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(e){const t=e.type;switch(t){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[e.value];break;case".":case"]":case"}":return null===this._predicate?this._error(`Unexpected ${t}`,e):(this._subject=null,"]"===t?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return null!==this._predicate?this._readPredicate:this._error("Expected predicate but got ;",e);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",e);default:if(void 0===(this._predicate=this._readEntity(e)))return}return this._readObject}_readObject(e){switch(e.type){case"literal":if(0===e.prefix.length)return this._literalValue=e.value,this._readDataTypeOrLang;this._object=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if(void 0===(this._object=this._readEntity(e)))return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(e){return"{"===e.type?this._readGraph(e):this._readPredicate(e)}_readGraph(e){return"{"!==e.type?this._error(`Expected graph but got ${e.type}`,e):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(e){return"]"===e.type?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))}_readBlankNodeTail(e){if("]"!==e.type)return this._readBlankNodePunctuation(e);null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph);const t=null===this._predicate;return this._restoreContext("blank",e),null!==this._object?this._getContextEndReader():null!==this._predicate?this._readObject:t?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(e){switch(e.type){case".":case"}":return this._subject=null,this._readPunctuation(e);default:return this._readPredicate(e)}}_readListItem(e){let t=null,r=null,n=this._readListItem;const i=this._subject,o=this._contextStack,a=o[o.length-1];switch(e.type){case"[":this._saveContext("blank",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this._subject=t=this._factory.blankNode()),n=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",e),0!==o.length&&"list"===o[o.length-1].type&&this._emit(this._subject,this._predicate,this._object,this._graph),null===this._predicate){if(n=this._readPredicate,this._subject===this.RDF_NIL)return n}else if(n=this._getContextEndReader(),this._object===this.RDF_NIL)return n;r=this.RDF_NIL;break;case"literal":0===e.prefix.length?(this._literalValue=e.value,n=this._readListItemDataTypeOrLang):(t=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),n=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);default:if(void 0===(t=this._readEntity(e)))return}if(null===r&&(this._subject=r=this._factory.blankNode()),null===i?null===a.predicate?a.subject=r:a.object=r:this._emit(i,this.RDF_REST,r,this._graph),null!==t){if(this._n3Mode&&("IRI"===e.type||"prefixed"===e.type))return this._saveContext("item",this._graph,r,this.RDF_FIRST,t),this._subject=t,this._predicate=null,this._getPathReader(this._readListItem);this._emit(r,this.RDF_FIRST,t,this._graph)}return n}_readDataTypeOrLang(e){return this._completeObjectLiteral(e,!1)}_readListItemDataTypeOrLang(e){return this._completeObjectLiteral(e,!0)}_completeLiteral(e){let t=this._factory.literal(this._literalValue);switch(e.type){case"type":case"typeIRI":const r=this._readEntity(e);if(void 0===r)return;t=this._factory.literal(this._literalValue,r),e=null;break;case"langcode":t=this._factory.literal(this._literalValue,e.value),e=null}return{token:e,literal:t}}_completeSubjectLiteral(e){return this._subject=this._completeLiteral(e).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(e,t){const r=this._completeLiteral(e);if(r)return this._object=r.literal,t&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),null===r.token?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(r.token))}_readFormulaTail(e){return"}"!==e.type?this._readPunctuation(e):(null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",e),null===this._object?this._readPredicate:this._getContextEndReader())}_readPunctuation(e){let t,r=this._graph;const n=this._subject,i=this._inversePredicate;switch(e.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",e);if(this._n3Mode)return this._readFormulaTail(e);this._graph=null;case".":this._subject=null,t=this._contextStack.length?this._readSubject:this._readInTopContext,i&&(this._inversePredicate=!1);break;case";":t=this._readPredicate;break;case",":t=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",e);const o=this._predicate,a=this._object;this._subject=this._factory.quad(n,o,a,this.DEFAULTGRAPH),t=this._readPredicate;break;case"|}":if("Quad"!==this._subject.termType)return this._error("Unexpected asserted triple closing",e);this._subject=null,t=this._readPunctuation;break;default:if(this._supportsQuads&&null===this._graph&&void 0!==(r=this._readEntity(e))){t=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}if(null!==n){const e=this._predicate,t=this._object;i?this._emit(t,e,n,r):this._emit(n,e,t,r)}return t}_readBlankNodePunctuation(e){let t;switch(e.type){case";":t=this._readPredicate;break;case",":t=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}return this._emit(this._subject,this._predicate,this._object,this._graph),t}_readQuadPunctuation(e){return"."!==e.type?this._error("Expected dot to follow quad",e):this._readInTopContext}_readPrefix(e){return"prefix"!==e.type?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)}_readPrefixIRI(e){if("IRI"!==e.type)return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,e);const t=this._readEntity(e);return this._prefixes[this._prefix]=t.value,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation}_readBaseIRI(e){const t="IRI"===e.type&&this._resolveIRI(e.value);return t?(this._setBase(t),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",e)}_readNamedGraphLabel(e){switch(e.type){case"IRI":case"blank":case"prefixed":return this._readSubject(e),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",e)}}_readNamedGraphBlankLabel(e){return"]"!==e.type?this._error("Invalid graph label",e):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(e){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(e)):"."!==e.type?this._error("Expected declaration to end with a dot",e):this._readInTopContext}_readQuantifierList(e){let t;switch(e.type){case"IRI":case"prefixed":if(void 0!==(t=this._readEntity(e,!0)))break;default:return this._error(`Unexpected ${e.type}`,e)}return this._explicitQuantifiers?(null===this._subject?this._emit(this._graph||this.DEFAULTGRAPH,this._predicate,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH):this._emit(this._subject,this.RDF_REST,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH),this._emit(this._subject,this.RDF_FIRST,t,this.QUANTIFIERS_GRAPH)):this._quantified[t.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(e){return","===e.type?this._readQuantifierList:(this._explicitQuantifiers&&(this._emit(this._subject,this.RDF_REST,this.RDF_NIL,this.QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(e))}_getPathReader(e){return this._afterPath=e,this._readPath}_readPath(e){switch(e.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const t=this._contextStack,r=t.length&&t[t.length-1];if(r&&"item"===r.type){const t=this._subject;this._restoreContext("item",e),this._emit(this._subject,this.RDF_FIRST,t,this._graph)}return this._afterPath(e)}}_readForwardPath(e){let t,r;const n=this._factory.blankNode();if(void 0!==(r=this._readEntity(e)))return null===this._predicate?(t=this._subject,this._subject=n):(t=this._object,this._object=n),this._emit(t,r,n,this._graph),this._readPath}_readBackwardPath(e){const t=this._factory.blankNode();let r,n;if(void 0!==(r=this._readEntity(e)))return null===this._predicate?(n=this._subject,this._subject=t):(n=this._object,this._object=t),this._emit(t,r,n,this._graph),this._readPath}_readRDFStarTailOrGraph(e){return">>"!==e.type?this._supportsQuads&&null===this._graph&&void 0!==(this._graph=this._readEntity(e))?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,e):this._readRDFStarTail(e)}_readRDFStarTail(e){if(">>"!==e.type)return this._error(`Expected >> but got ${e.type}`,e);const t=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",e),null===this._subject?(this._subject=t,this._readPredicate):(this._object=t,this._getContextEndReader())}_getContextEndReader(){const e=this._contextStack;if(!e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(e,t,r,n){this._callback(null,this._factory.quad(e,t,r,n||this.DEFAULTGRAPH))}_error(e,t){const r=new Error(`${e} on line ${t.line}.`);r.context={token:t,line:t.line,previousToken:this._lexer.previousToken},this._callback(r),this._callback=Y}_resolveIRI(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)?e:this._resolveRelativeIRI(e)}_resolveRelativeIRI(e){if(!e.length)return this._base;switch(e[0]){case"#":return this._base+e;case"?":return this._base.replace(/(?:\?.*)?$/,e);case"/":return("/"===e[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(e);default:return/^[^/:]*:/.test(e)?null:this._removeDotSegments(this._basePath+e)}}_removeDotSegments(e){if(!/(^|\/)\.\.?($|[/#?])/.test(e))return e;const t=e.length;let r="",n=-1,i=-1,o=0,a="/";for(;n=i&&(r=r.substr(0,o)),"/"!==a)return`${r}/${e.substr(n+1)}`;o=n+1}}}a=e[++n]}return r+e.substring(o)}parse(e,t,r){let n,i,o;if(t&&(t.onQuad||t.onPrefix||t.onComment)?(n=t.onQuad,i=t.onPrefix,o=t.onComment):(n=t,i=r),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${W++}_`,this._prefixCallback=i||Y,this._inversePredicate=!1,this._quantified=Object.create(null),!n){const t=[];let r;if(this._callback=(e,n)=>{e?r=e:n&&t.push(n)},this._lexer.tokenize(e).every(e=>this._readCallback=this._readCallback(e)),r)throw r;return t}let a=(e,t)=>{null!==e?(this._callback(e),this._callback=Y):this._readCallback&&(this._readCallback=this._readCallback(t))};o&&(this._lexer.comments=!0,a=(e,t)=>{null!==e?(this._callback(e),this._callback=Y):this._readCallback&&("comment"===t.type?o(t.value):this._readCallback=this._readCallback(t))}),this._callback=n,this._lexer.tokenize(e,a)}}function Y(){}function Z(e,t){e._factory=t,e.DEFAULTGRAPH=t.defaultGraph(),e.RDF_FIRST=t.namedNode(_.rdf.first),e.RDF_REST=t.namedNode(_.rdf.rest),e.RDF_NIL=t.namedNode(_.rdf.nil),e.N3_FORALL=t.namedNode(_.r.forAll),e.N3_FORSOME=t.namedNode(_.r.forSome),e.ABBREVIATIONS={a:t.namedNode(_.rdf.type),"=":t.namedNode(_.owl.sameAs),">":t.namedNode(_.log.implies),"<":t.namedNode(_.log.isImpliedBy)},e.QUANTIFIERS_GRAPH=t.namedNode("urn:n3:quantifiers")}function ee(e){return!!e&&"DefaultGraph"===e.termType}function te(e,t){const r=Object.create(null);for(const t in e)n(t,e[t]);function n(e,n){if("string"==typeof n){const i=Object.create(null);r[e]=e=>i[e]||(i[e]=t.namedNode(n+e))}else if(!(e in r))throw new Error(`Unknown prefix: ${e}`);return r[e]}return t=t||N,n}Z(K.prototype,N);var re=Object.freeze({__proto__:null,inDefaultGraph:function(e){return ee(e.graph)},isBlankNode:function(e){return!!e&&"BlankNode"===e.termType},isDefaultGraph:ee,isLiteral:function(e){return!!e&&"Literal"===e.termType},isNamedNode:function(e){return!!e&&"NamedNode"===e.termType},isQuad:function(e){return!!e&&"Quad"===e.termType},isVariable:function(e){return!!e&&"Variable"===e.termType},prefix:function(e,t){return te({"":e.value||e},t)("")},prefixes:te});function ne(e){return e.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}const ie=/^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i,oe=/^(?:(?:[^/?#]{3,}|\.?[^/?#.]\.?)(?:\/[^/?#]{3,}|\.?[^/?#.]\.?)*\/?)?(?:[?#]|$)/;class ae{constructor(e){this.base=e,this._baseLength=0,this._baseMatcher=null,this._pathReplacements=new Array(e.length+1)}static supports(e){return!ie.test(e)}_getBaseMatcher(){if(this._baseMatcher)return this._baseMatcher;if(!ae.supports(this.base))return this._baseMatcher=/.^/;const e=/^[^:]*:\/*/.exec(this.base)[0],t=["^",ne(e)],r=[],n=[],i=/[^/?#]*([/?#])/y;let o,a=0,s=0,c=i.lastIndex=e.length;for(;!a&&!s&&(o=i.exec(this.base));)"#"===o[1]?s=i.lastIndex-1:(t.push(ne(o[0]),"(?:"),r.push(")?"),"?"!==o[1]?n.push(c=i.lastIndex):(a=c=i.lastIndex,s=this.base.indexOf("#",a),this._pathReplacements[a]="?"));for(let e=0;e0?s:this.base.length,t.push(ne(this.base.substring(c,this._baseLength)),a?"(?:#|$)":"(?:[?#]|$)"),this._baseMatcher=new RegExp([...t,...r].join(""))}toRelative(e){const t=this._getBaseMatcher().exec(e);if(!t)return e;const r=t[0].length;if(r===this._baseLength&&r===e.length)return"";const n=this._pathReplacements[r];if(n){const t=e.substring(r);return"?"===n||oe.test(t)?"./"===n&&/^[^?#]/.test(t)?t:n+t:e}return e.substring(r-1)}}const se=N.defaultGraph(),{rdf:ce,xsd:ue}=_,le=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,de=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,pe={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};class fe extends P{equals(e){return e===this}}class he{constructor(e,t){if(this._prefixRegex=/$0^/,e&&"function"!=typeof e.write&&(t=e,e=null),t=t||{},this._lists=t.lists,e)this._outputStream=e,this._endStream=void 0===t.end||!!t.end;else{let e="";this._outputStream={write(t,r,n){e+=t,n&&n()},end:t=>{t&&t(null,e)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(t.format)?(this._lineMode=!0,this._writeQuad=this._writeQuadLine):(this._lineMode=!1,this._graph=se,this._prefixIRIs=Object.create(null),t.prefixes&&this.addPrefixes(t.prefixes),t.baseIRI&&(this._baseIri=new ae(t.baseIRI)))}get _inDefaultGraph(){return se.equals(this._graph)}_write(e,t){this._outputStream.write(e,"utf8",t)}_writeQuad(e,t,r,n,i){try{n.equals(this._graph)||(this._write((null===this._subject?"":this._inDefaultGraph?".\n":"\n}\n")+(se.equals(n)?"":`${this._encodeIriOrBlank(n)} {\n`)),this._graph=n,this._subject=null),e.equals(this._subject)?t.equals(this._predicate)?this._write(`, ${this._encodeObject(r)}`,i):this._write(`;\n ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(r)}`,i):this._write(`${(null===this._subject?"":".\n")+this._encodeSubject(this._subject=e)} ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(r)}`,i)}catch(e){i&&i(e)}}_writeQuadLine(e,t,r,n,i){delete this._prefixMatch,this._write(this.quadToString(e,t,r,n),i)}quadToString(e,t,r,n){return`${this._encodeSubject(e)} ${this._encodeIriOrBlank(t)} ${this._encodeObject(r)}${n&&n.value?` ${this._encodeIriOrBlank(n)} .\n`:" .\n"}`}quadsToString(e){let t="";for(const r of e)t+=this.quadToString(r.subject,r.predicate,r.object,r.graph);return t}_encodeSubject(e){return"Quad"===e.termType?this._encodeQuad(e):this._encodeIriOrBlank(e)}_encodeIriOrBlank(e){if("NamedNode"!==e.termType)return this._lists&&e.value in this._lists&&(e=this.list(this._lists[e.value])),"id"in e?e.id:`_:${e.value}`;let t=e.value;this._baseIri&&(t=this._baseIri.toRelative(t)),le.test(t)&&(t=t.replace(de,ye));const r=this._prefixRegex.exec(t);return r?r[1]?this._prefixIRIs[r[1]]+r[2]:t:`<${t}>`}_encodeLiteral(e){let t=e.value;if(le.test(t)&&(t=t.replace(de,ye)),e.language)return`"${t}"@${e.language}`;if(this._lineMode){if(e.datatype.value===ue.string)return`"${t}"`}else switch(e.datatype.value){case ue.string:return`"${t}"`;case ue.boolean:if("true"===t||"false"===t)return t;break;case ue.integer:if(/^[+-]?\d+$/.test(t))return t;break;case ue.decimal:if(/^[+-]?\d*\.\d+$/.test(t))return t;break;case ue.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(t))return t}return`"${t}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){return e.value===ce.type?"a":this._encodeIriOrBlank(e)}_encodeObject(e){switch(e.termType){case"Quad":return this._encodeQuad(e);case"Literal":return this._encodeLiteral(e);default:return this._encodeIriOrBlank(e)}}_encodeQuad({subject:e,predicate:t,object:r,graph:n}){return`<<${this._encodeSubject(e)} ${this._encodePredicate(t)} ${this._encodeObject(r)}${ee(n)?"":` ${this._encodeIriOrBlank(n)}`}>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,t,r,n,i){void 0===r?this._writeQuad(e.subject,e.predicate,e.object,e.graph,t):"function"==typeof n?this._writeQuad(e,t,r,se,n):this._writeQuad(e,t,r,n||se,i)}addQuads(e){for(let t=0;t.\n`)}if(r){let e="",t="";for(const r in this._prefixIRIs)e+=e?`|${r}`:r,t+=(t?"|":"")+this._prefixIRIs[r];e=ne(e),this._prefixRegex=new RegExp(`^(?:${t})[^/]*$|^(${e})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`)}this._write(r?"\n":"",t)}blank(e,t){let r,n,i=e;switch(void 0===e?i=[]:e.termType?i=[{predicate:e,object:t}]:"length"in e||(i=[e]),n=i.length){case 0:return new fe("[]");case 1:if(r=i[0],!(r.object instanceof fe))return new fe(`[ ${this._encodePredicate(r.predicate)} ${this._encodeObject(r.object)} ]`);default:let t="[";for(let o=0;o{t=null,e(r,n)});if(this._endStream)try{return this._outputStream.end(t)}catch(e){}t&&t()}}function ye(e){let t=pe[e];return void 0===t&&(1===e.length?(t=e.charCodeAt(0).toString(16),t="\\u0000".substr(0,6-t.length)+t):(t=(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)+9216).toString(16),t="\\U00000000".substr(0,10-t.length)+t)),t}var ge={exports:{}},me={exports:{}};let be=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError("Expected input to be an Array, got "+typeof e);let t="";for(let r=0;rArray.isArray(e),ArrayPrototypeIncludes:(e,t)=>e.includes(t),ArrayPrototypeIndexOf:(e,t)=>e.indexOf(t),ArrayPrototypeJoin:(e,t)=>e.join(t),ArrayPrototypeMap:(e,t)=>e.map(t),ArrayPrototypePop:(e,t)=>e.pop(t),ArrayPrototypePush:(e,t)=>e.push(t),ArrayPrototypeSlice:(e,t,r)=>e.slice(t,r),Error:Error,FunctionPrototypeCall:(e,t,...r)=>e.call(t,...r),FunctionPrototypeSymbolHasInstance:(e,t)=>Function.prototype[Symbol.hasInstance].call(e,t),MathFloor:Math.floor,Number: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:(e,t)=>Object.defineProperties(e,t),ObjectDefineProperty:(e,t,r)=>Object.defineProperty(e,t,r),ObjectGetOwnPropertyDescriptor:(e,t)=>Object.getOwnPropertyDescriptor(e,t),ObjectKeys:e=>Object.keys(e),ObjectSetPrototypeOf:(e,t)=>Object.setPrototypeOf(e,t),Promise:Promise,PromisePrototypeCatch:(e,t)=>e.catch(t),PromisePrototypeThen:(e,t,r)=>e.then(t,r),PromiseReject:e=>Promise.reject(e),PromiseResolve:e=>Promise.resolve(e),ReflectApply:Reflect.apply,RegExpPrototypeTest:(e,t)=>e.test(t),SafeSet:Set,String:String,StringPrototypeSlice:(e,t,r)=>e.slice(t,r),StringPrototypeToLowerCase:e=>e.toLowerCase(),StringPrototypeToUpperCase:e=>e.toUpperCase(),StringPrototypeTrim:e=>e.trim(),Symbol: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:(e,t,r)=>e.set(t,r),Boolean:Boolean,Uint8Array:Uint8Array},_e={exports:{}},we={format:(e,...t)=>e.replace(/%([sdifj])/g,function(...[e,r]){const n=t.shift();if("f"===r)return n.toFixed(6);if("j"===r)return JSON.stringify(n);if("s"===r&&"object"==typeof n){return`${n.constructor!==Object?n.constructor.name:""} {}`.trim()}return n.toString()}),inspect(e){switch(typeof e){case"string":if(e.includes("'")){if(!e.includes('"'))return`"${e}"`;if(!e.includes("`")&&!e.includes("${"))return`\`${e}\``}return`'${e}'`;case"number":return isNaN(e)?"NaN":Object.is(e,-0)?String(e):e;case"bigint":return`${String(e)}n`;case"boolean":case"undefined":return String(e);case"object":return"{}"}}};const{format:Te,inspect:Oe}=we,{AggregateError:Se}=ve,xe=globalThis.AggregateError||Se,je=Symbol("kIsNodeError"),Ae=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Ee=/^([A-Z][a-z0-9]*)+$/,Ie={};function Fe(e,t){if(!e)throw new Ie.ERR_INTERNAL_ASSERTION(t)}function De(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function Ne(e,t,r){r||(r=Error);class n extends r{constructor(...r){super(function(e,t,r){if("function"==typeof t)return Fe(t.length<=r.length,`Code: ${e}; The provided arguments length (${r.length}) does not match the required ones (${t.length}).`),t(...r);const n=(t.match(/%[dfijoOs]/g)||[]).length;return Fe(n===r.length,`Code: ${e}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),0===r.length?t:Te(t,...r)}(e,t,r))}toString(){return`${this.name} [${e}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${e}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=e,n.prototype[je]=!0,Ie[e]=n}function Pe(e){const t="__node_internal_"+e.name;return Object.defineProperty(e,"name",{value:t}),e}let Re=class extends Error{constructor(e="The operation was aborted",t=void 0){if(void 0!==t&&"object"!=typeof t)throw new Ie.ERR_INVALID_ARG_TYPE("options","Object",t);super(e,t),this.code="ABORT_ERR",this.name="AbortError"}};Ne("ERR_ASSERTION","%s",Error),Ne("ERR_INVALID_ARG_TYPE",(e,t,r)=>{Fe("string"==typeof e,"'name' must be a string"),Array.isArray(t)||(t=[t]);let n="The ";e.endsWith(" argument")?n+=`${e} `:n+=`"${e}" ${e.includes(".")?"property":"argument"} `,n+="must be ";const i=[],o=[],a=[];for(const e of t)Fe("string"==typeof e,"All expected entries have to be of type string"),Ae.includes(e)?i.push(e.toLowerCase()):Ee.test(e)?o.push(e):(Fe("object"!==e,'The value "object" should be written as "Object"'),a.push(e));if(o.length>0){const e=i.indexOf("object");-1!==e&&(i.splice(i,e,1),o.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 e=i.pop();n+=`one of type ${i.join(", ")}, or ${e}`}}(o.length>0||a.length>0)&&(n+=" or ")}if(o.length>0){switch(o.length){case 1:n+=`an instance of ${o[0]}`;break;case 2:n+=`an instance of ${o[0]} or ${o[1]}`;break;default:{const e=o.pop();n+=`an instance of ${o.join(", ")}, or ${e}`}}a.length>0&&(n+=" or ")}switch(a.length){case 0:break;case 1:a[0].toLowerCase()!==a[0]&&(n+="an "),n+=`${a[0]}`;break;case 2:n+=`one of ${a[0]} or ${a[1]}`;break;default:{const e=a.pop();n+=`one of ${a.join(", ")}, or ${e}`}}if(null==r)n+=`. Received ${r}`;else if("function"==typeof r&&r.name)n+=`. Received function ${r.name}`;else if("object"==typeof r){var s;if(null!==(s=r.constructor)&&void 0!==s&&s.name)n+=`. Received an instance of ${r.constructor.name}`;else{n+=`. Received ${Oe(r,{depth:-1})}`}}else{let e=Oe(r,{colors:!1});e.length>25&&(e=`${e.slice(0,25)}...`),n+=`. Received type ${typeof r} (${e})`}return n},TypeError),Ne("ERR_INVALID_ARG_VALUE",(e,t,r="is invalid")=>{let n=Oe(t);n.length>128&&(n=n.slice(0,128)+"...");return`The ${e.includes(".")?"property":"argument"} '${e}' ${r}. Received ${n}`},TypeError),Ne("ERR_INVALID_RETURN_VALUE",(e,t,r)=>{var n;return`Expected ${e} to be returned from the "${t}" function but got ${null!=r&&null!==(n=r.constructor)&&void 0!==n&&n.name?`instance of ${r.constructor.name}`:"type "+typeof r}.`},TypeError),Ne("ERR_MISSING_ARGS",(...e)=>{let t;Fe(e.length>0,"At least one arg needs to be specified");const r=e.length;switch(e=(Array.isArray(e)?e:[e]).map(e=>`"${e}"`).join(" or "),r){case 1:t+=`The ${e[0]} argument`;break;case 2:t+=`The ${e[0]} and ${e[1]} arguments`;break;default:{const r=e.pop();t+=`The ${e.join(", ")}, and ${r} arguments`}}return`${t} must be specified`},TypeError),Ne("ERR_OUT_OF_RANGE",(e,t,r)=>{let n;if(Fe(t,'Missing "range" argument'),Number.isInteger(r)&&Math.abs(r)>2**32)n=De(String(r));else if("bigint"==typeof r){n=String(r);const e=BigInt(2)**BigInt(32);(r>e||r<-e)&&(n=De(n)),n+="n"}else n=Oe(r);return`The value of "${e}" is out of range. It must be ${t}. Received ${n}`},RangeError),Ne("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),Ne("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),Ne("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),Ne("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),Ne("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),Ne("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Ne("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),Ne("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),Ne("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),Ne("ERR_STREAM_WRITE_AFTER_END","write after end",Error),Ne("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);var Me,Le={AbortError:Re,aggregateTwoErrors:Pe(function(e,t){if(e&&t&&e!==t){if(Array.isArray(t.errors))return t.errors.push(e),t;const r=new xe([t,e],t.message);return r.code=t.code,r}return e||t}),hideStackFrames:Pe,codes:Ie},Ce={exports:{}};function ke(){if(Me)return Ce.exports;Me=1;const{AbortController:e,AbortSignal:t}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;return Ce.exports=e,Ce.exports.AbortSignal=t,Ce.exports.default=e,Ce.exports}var Be,Ue={exports:{}},$e="object"==typeof Reflect?Reflect:null,qe=$e&&"function"==typeof $e.apply?$e.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};Be=$e&&"function"==typeof $e.ownKeys?$e.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Qe=Number.isNaN||function(e){return e!=e};function ze(){ze.init.call(this)}Ue.exports=ze,Ue.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}et(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&et(e,"error",t,r)}(e,i,{once:!0})})},ze.EventEmitter=ze,ze.prototype._events=void 0,ze.prototype._eventsCount=0,ze.prototype._maxListeners=void 0;var Ge=10;function Ve(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Xe(e){return void 0===e._maxListeners?ze.defaultMaxListeners:e._maxListeners}function He(e,t,r,n){var i,o,a,s;if(Ve(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=Xe(e))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function Je(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function We(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Je.bind(n);return i.listener=r,n.wrapFn=i,i}function Ke(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)qe(s,this,t);else{var c=s.length,u=Ze(s,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},ze.prototype.listeners=function(e){return Ke(this,e,!0)},ze.prototype.rawListeners=function(e){return Ke(this,e,!1)},ze.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ye.call(e,t)},ze.prototype.listenerCount=Ye,ze.prototype.eventNames=function(){return this._eventsCount>0?Be(this._events):[]};var tt=Ue.exports;!function(e){const t=a,{format:r,inspect:n}=we,{codes:{ERR_INVALID_ARG_TYPE:i}}=Le,{kResistStopPropagation:o,AggregateError:s,SymbolDispose:c}=ve,u=globalThis.AbortSignal||ke().AbortSignal,l=globalThis.AbortController||ke().AbortController,d=Object.getPrototypeOf(async function(){}).constructor,p=globalThis.Blob||t.Blob,f=void 0!==p?function(e){return e instanceof p}:function(e){return!1},h=(e,t)=>{if(void 0!==e&&(null===e||"object"!=typeof e||!("aborted"in e)))throw new i(t,"AbortSignal",e)};e.exports={AggregateError:s,kEmptyObject:Object.freeze({}),once(e){let t=!1;return function(...r){t||(t=!0,e.apply(this,r))}},createDeferredPromise:function(){let e,t;return{promise:new Promise((r,n)=>{e=r,t=n}),resolve:e,reject:t}},promisify:e=>new Promise((t,r)=>{e((e,...n)=>e?r(e):t(...n))}),debuglog:()=>function(){},format:r,inspect:n,types:{isAsyncFunction:e=>e instanceof d,isArrayBufferView:e=>ArrayBuffer.isView(e)},isBlob:f,deprecate:(e,t)=>e,addAbortListener:tt.addAbortListener||function(e,t){if(void 0===e)throw new i("signal","AbortSignal",e);let r;return h(e,"signal"),((e,t)=>{if("function"!=typeof e)throw new i(t,"Function",e)})(t,"listener"),e.aborted?queueMicrotask(()=>t()):(e.addEventListener("abort",t,{__proto__:null,once:!0,[o]:!0}),r=()=>{e.removeEventListener("abort",t)}),{__proto__:null,[c](){var e;null===(e=r)||void 0===e||e()}}},AbortSignalAny:u.any||function(e){if(1===e.length)return e[0];const t=new l,r=()=>t.abort();return e.forEach(e=>{h(e,"signals"),e.addEventListener("abort",r,{once:!0})}),t.signal.addEventListener("abort",()=>{e.forEach(e=>e.removeEventListener("abort",r))},{once:!0}),t.signal}},e.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}(_e);var rt=_e.exports,nt={};const{ArrayIsArray:it,ArrayPrototypeIncludes:ot,ArrayPrototypeJoin:at,ArrayPrototypeMap:st,NumberIsInteger:ct,NumberIsNaN:ut,NumberMAX_SAFE_INTEGER:lt,NumberMIN_SAFE_INTEGER:dt,NumberParseInt:pt,ObjectPrototypeHasOwnProperty:ft,RegExpPrototypeExec:ht,String:yt,StringPrototypeToUpperCase:gt,StringPrototypeTrim:mt}=ve,{hideStackFrames:bt,codes:{ERR_SOCKET_BAD_PORT:vt,ERR_INVALID_ARG_TYPE:_t,ERR_INVALID_ARG_VALUE:wt,ERR_OUT_OF_RANGE:Tt,ERR_UNKNOWN_SIGNAL:Ot}}=Le,{normalizeEncoding:St}=rt,{isAsyncFunction:xt,isArrayBufferView:jt}=rt.types,At=bt((e,t,r=dt,n=lt)=>{if("number"!=typeof e)throw new _t(t,"number",e);if(!ct(e))throw new Tt(t,"an integer",e);if(en)throw new Tt(t,`>= ${r} && <= ${n}`,e)});function Et(e,t,r){return null!=e&&ft(e,t)?e[t]:r}bt((e,t,r=-2147483648,n=2147483647)=>{if("number"!=typeof e)throw new _t(t,"number",e);if(!ct(e))throw new Tt(t,"an integer",e);if(en)throw new Tt(t,`>= ${r} && <= ${n}`,e)}),bt((e,t,r=!1)=>{if("number"!=typeof e)throw new _t(t,"number",e);if(!ct(e))throw new Tt(t,"an integer",e);const n=r?1:0,i=4294967295;if(ei)throw new Tt(t,`>= ${n} && <= ${i}`,e)}),bt((e,t,r)=>{if(!ot(r,e)){const n=at(st(r,e=>"string"==typeof e?`'${e}'`:yt(e)),", ");throw new wt(t,e,"must be one of: "+n)}});const It=bt((e,t,r=null)=>{const n=Et(r,"allowArray",!1),i=Et(r,"allowFunction",!1);if(!Et(r,"nullable",!1)&&null===e||!n&&it(e)||"object"!=typeof e&&(!i||"function"!=typeof e))throw new _t(t,"Object",e)});bt((e,t)=>{if(null!=e&&"object"!=typeof e&&"function"!=typeof e)throw new _t(t,"a dictionary",e)}),bt((e,t,r=0)=>{if(!it(e))throw new _t(t,"Array",e);if(e.length{if(!jt(e))throw new _t(t,["Buffer","TypedArray","DataView"],e)});const Ft=bt((e,t)=>{if(void 0!==e&&(null===e||"object"!=typeof e||!("aborted"in e)))throw new _t(t,"AbortSignal",e)}),Dt=bt((e,t)=>{if("function"!=typeof e)throw new _t(t,"Function",e)});bt((e,t)=>{if("function"!=typeof e||xt(e))throw new _t(t,"Function",e)}),bt((e,t)=>{if(void 0!==e)throw new _t(t,"undefined",e)});var Nt,Pt,Rt={validateBoolean:function(e,t){if("boolean"!=typeof e)throw new _t(t,"boolean",e)},validateFunction:Dt,validateInteger:At,validateObject:It,validateAbortSignal:Ft},Mt={exports:{}},Lt={exports:{}},Ct=Lt.exports={};function kt(){throw new Error("setTimeout has not been defined")}function Bt(){throw new Error("clearTimeout has not been defined")}function Ut(e){if(Nt===setTimeout)return setTimeout(e,0);if((Nt===kt||!Nt)&&setTimeout)return Nt=setTimeout,setTimeout(e,0);try{return Nt(e,0)}catch(t){try{return Nt.call(null,e,0)}catch(t){return Nt.call(this,e,0)}}}!function(){try{Nt="function"==typeof setTimeout?setTimeout:kt}catch(e){Nt=kt}try{Pt="function"==typeof clearTimeout?clearTimeout:Bt}catch(e){Pt=Bt}}();var $t,qt=[],Qt=!1,zt=-1;function Gt(){Qt&&$t&&(Qt=!1,$t.length?qt=$t.concat(qt):zt=-1,qt.length&&Vt())}function Vt(){if(!Qt){var e=Ut(Gt);Qt=!0;for(var t=qt.length;t;){for($t=qt,qt=[];++zt1)for(var r=1;r{};function Hr(e,t,r){var n,i;if(2===arguments.length?(r=t,t=Or):null==t?t=Or:Ar(t,"options"),jr(r,"callback"),xr(t.signal,"options.signal"),r=Sr(r),Mr(e)||Ur(e))return function(e,t,r){let n=!1,i=Xr;if(t.signal)if(i=()=>{n=!0,r.call(e,new vr(void 0,{cause:t.signal.reason}))},t.signal.aborted)br.nextTick(i);else{Vr=Vr||rt.addAbortListener;const n=Vr(t.signal,i),o=r;r=Sr((...t)=>{n[Dr](),o.apply(e,t)})}const o=(...t)=>{n||br.nextTick(()=>r.apply(e,t))};return Fr(e[Gr].promise,o,o),Xr}(e,t,r);if(!Qr(e))throw new wr("stream",["ReadableStream","WritableStream","Stream"],e);const o=null!==(n=t.readable)&&void 0!==n?n:Rr(e),a=null!==(i=t.writable)&&void 0!==i?i:Br(e),s=e._writableState,c=e._readableState,u=()=>{e.writable||p()};let l=zr(e)&&Rr(e)===o&&Br(e)===a,d=$r(e,!1);const p=()=>{d=!0,e.destroyed&&(l=!1),(!l||e.readable&&!o)&&(o&&!f||r.call(e))};let f=Lr(e,!1);const h=()=>{f=!0,e.destroyed&&(l=!1),(!l||e.writable&&!a)&&(a&&!d||r.call(e))},y=t=>{r.call(e,t)};let g=Nr(e);const m=()=>{g=!0;const t=qr(e)||Cr(e);return t&&"boolean"!=typeof t?r.call(e,t):o&&!f&&Rr(e,!0)&&!Lr(e,!1)?r.call(e,new Tr):!a||d||$r(e,!1)?void r.call(e):r.call(e,new Tr)},b=()=>{g=!0;const t=qr(e)||Cr(e);if(t&&"boolean"!=typeof t)return r.call(e,t);r.call(e)},v=()=>{e.req.on("finish",p)};!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?a&&!s&&(e.on("end",u),e.on("close",u)):(e.on("complete",p),l||e.on("abort",m),e.req?v():e.on("request",v)),l||"boolean"!=typeof e.aborted||e.on("aborted",m),e.on("end",h),e.on("finish",p),!1!==t.error&&e.on("error",y),e.on("close",m),g?br.nextTick(m):null!=s&&s.errorEmitted||null!=c&&c.errorEmitted?l||br.nextTick(b):(o||l&&!Pr(e)||!d&&!1!==kr(e))&&(a||l&&!kr(e)||!f&&!1!==Pr(e))?c&&e.req&&e.aborted&&br.nextTick(b):br.nextTick(b);const _=()=>{r=Xr,e.removeListener("aborted",m),e.removeListener("complete",p),e.removeListener("abort",m),e.removeListener("request",v),e.req&&e.req.removeListener("finish",p),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",p),e.removeListener("end",h),e.removeListener("error",y),e.removeListener("close",m)};if(t.signal&&!g){const n=()=>{const n=r;_(),n.call(e,new vr(void 0,{cause:t.signal.reason}))};if(t.signal.aborted)br.nextTick(n);else{Vr=Vr||rt.addAbortListener;const i=Vr(t.signal,n),o=r;r=Sr((...t)=>{i[Dr](),o.apply(e,t)})}}return _}Mt.exports=Hr,Mt.exports.finished=function(e,t){var r;let n=!1;return null===t&&(t=Or),null!==(r=t)&&void 0!==r&&r.cleanup&&(Er(t.cleanup,"cleanup"),n=t.cleanup),new Ir((r,i)=>{const o=Hr(e,t,e=>{n&&o(),e?i(e):r()})})};var Jr=Mt.exports;const Wr=Jt,{aggregateTwoErrors:Kr,codes:{ERR_MULTIPLE_CALLBACK:Yr},AbortError:Zr}=Le,{Symbol:en}=ve,{kIsDestroyed:tn,isDestroyed:rn,isFinished:nn,isServerRequest:on}=mr,an=en("kDestroy"),sn=en("kConstruct");function cn(e,t,r){e&&(e.stack,t&&!t.errored&&(t.errored=e),r&&!r.errored&&(r.errored=e))}function un(e,t,r){let n=!1;function i(t){if(n)return;n=!0;const i=e._readableState,o=e._writableState;cn(t,o,i),o&&(o.closed=!0),i&&(i.closed=!0),"function"==typeof r&&r(t),t?Wr.nextTick(ln,e,t):Wr.nextTick(dn,e)}try{e._destroy(t||null,i)}catch(t){i(t)}}function ln(e,t){pn(e,t),dn(e)}function dn(e){const t=e._readableState,r=e._writableState;r&&(r.closeEmitted=!0),t&&(t.closeEmitted=!0),(null!=r&&r.emitClose||null!=t&&t.emitClose)&&e.emit("close")}function pn(e,t){const r=e._readableState,n=e._writableState;null!=n&&n.errorEmitted||null!=r&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),e.emit("error",t))}function fn(e,t,r){const n=e._readableState,i=e._writableState;if(null!=i&&i.destroyed||null!=n&&n.destroyed)return this;null!=n&&n.autoDestroy||null!=i&&i.autoDestroy?e.destroy(t):t&&(t.stack,i&&!i.errored&&(i.errored=t),n&&!n.errored&&(n.errored=t),r?Wr.nextTick(pn,e,t):pn(e,t))}function hn(e){let t=!1;function r(r){if(t)return void fn(e,null!=r?r:new Yr);t=!0;const n=e._readableState,i=e._writableState,o=i||n;n&&(n.constructed=!0),i&&(i.constructed=!0),o.destroyed?e.emit(an,r):r?fn(e,r,!0):Wr.nextTick(yn,e)}try{e._construct(e=>{Wr.nextTick(r,e)})}catch(e){Wr.nextTick(r,e)}}function yn(e){e.emit(sn)}function gn(e){return(null==e?void 0:e.setHeader)&&"function"==typeof e.abort}function mn(e){e.emit("close")}function bn(e,t){e.emit("error",t),Wr.nextTick(mn,e)}var vn={construct:function(e,t){if("function"!=typeof e._construct)return;const r=e._readableState,n=e._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),e.once(sn,t),e.listenerCount(sn)>1||Wr.nextTick(hn,e)},destroyer:function(e,t){e&&!rn(e)&&(t||nn(e)||(t=new Zr),on(e)?(e.socket=null,e.destroy(t)):gn(e)?e.abort():gn(e.req)?e.req.abort():"function"==typeof e.destroy?e.destroy(t):"function"==typeof e.close?e.close():t?Wr.nextTick(bn,e,t):Wr.nextTick(mn,e),e.destroyed||(e[tn]=!0))},destroy:function(e,t){const r=this._readableState,n=this._writableState,i=n||r;return null!=n&&n.destroyed||null!=r&&r.destroyed?("function"==typeof t&&t(),this):(cn(e,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?un(this,e,t):this.once(an,function(r){un(this,Kr(r,e),t)}),this)},undestroy:function(){const e=this._readableState,t=this._writableState;e&&(e.constructed=!0,e.closed=!1,e.closeEmitted=!1,e.destroyed=!1,e.errored=null,e.errorEmitted=!1,e.reading=!1,e.ended=!1===e.readable,e.endEmitted=!1===e.readable),t&&(t.constructed=!0,t.destroyed=!1,t.closed=!1,t.closeEmitted=!1,t.errored=null,t.errorEmitted=!1,t.finalCalled=!1,t.prefinished=!1,t.ended=!1===t.writable,t.ending=!1===t.writable,t.finished=!1===t.writable)},errorOrDestroy:fn};const{ArrayIsArray:_n,ObjectSetPrototypeOf:wn}=ve,{EventEmitter:Tn}=tt;function On(e){Tn.call(this,e)}function Sn(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?_n(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}wn(On.prototype,Tn.prototype),wn(On,Tn),On.prototype.pipe=function(e,t){const r=this;function n(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function i(){r.readable&&r.resume&&r.resume()}r.on("data",n),e.on("drain",i),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",s));let o=!1;function a(){o||(o=!0,e.end())}function s(){o||(o=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){u(),0===Tn.listenerCount(this,"error")&&this.emit("error",e)}function u(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",a),r.removeListener("close",s),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",u),r.removeListener("close",u),e.removeListener("close",u)}return Sn(r,"error",c),Sn(e,"error",c),r.on("end",u),r.on("close",u),e.on("close",u),e.emit("pipe",r),e};var xn={Stream:On,prependListener:Sn},jn={exports:{}};!function(e){const{SymbolDispose:t}=ve,{AbortError:r,codes:n}=Le,{isNodeStream:i,isWebStream:o,kControllerErrorFunction:a}=mr,s=Jr,{ERR_INVALID_ARG_TYPE:c}=n;let u;e.exports.addAbortSignal=function(t,r){if(((e,t)=>{if("object"!=typeof e||!("aborted"in e))throw new c(t,"AbortSignal",e)})(t,"signal"),!i(r)&&!o(r))throw new c("stream",["ReadableStream","WritableStream","Stream"],r);return e.exports.addAbortSignalNoValidate(t,r)},e.exports.addAbortSignalNoValidate=function(e,n){if("object"!=typeof e||!("aborted"in e))return n;const o=i(n)?()=>{n.destroy(new r(void 0,{cause:e.reason}))}:()=>{n[a](new r(void 0,{cause:e.reason}))};if(e.aborted)o();else{u=u||rt.addAbortListener;const r=u(e,o);s(n,r[t])}return n}}(jn);var An=jn.exports;const{StringPrototypeSlice:En,SymbolIterator:In,TypedArrayPrototypeSet:Fn,Uint8Array:Dn}=ve,{Buffer:Nn}=a,{inspect:Pn}=rt;var Rn=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}unshift(e){const t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}shift(){if(0===this.length)return;const e=this.head.data;return 1===this.length?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(0===this.length)return"";let t=this.head,r=""+t.data;for(;null!==(t=t.next);)r+=e+t.data;return r}concat(e){if(0===this.length)return Nn.alloc(0);const t=Nn.allocUnsafe(e>>>0);let r=this.head,n=0;for(;r;)Fn(t,r.data,n),n+=r.data.length,r=r.next;return t}consume(e,t){const r=this.head.data;if(ei.length)){e===i.length?(t+=i,++n,r.next?this.head=r.next:this.head=this.tail=null):(t+=En(i,0,e),this.head=r,r.data=En(i,e));break}t+=i,e-=i.length,++n}while(null!==(r=r.next));return this.length-=n,t}_getBuffer(e){const t=Nn.allocUnsafe(e),r=e;let n=this.head,i=0;do{const o=n.data;if(!(e>o.length)){e===o.length?(Fn(t,o,r-e),++i,n.next?this.head=n.next:this.head=this.tail=null):(Fn(t,new Dn(o.buffer,o.byteOffset,e),r-e),this.head=n,n.data=o.slice(e));break}Fn(t,o,r-e),e-=o.length,++i}while(null!==(n=n.next));return this.length-=i,t}[Symbol.for("nodejs.util.inspect.custom")](e,t){return Pn(this,{...t,depth:0,customInspect:!1})}};const{MathFloor:Mn,NumberIsInteger:Ln}=ve,{validateInteger:Cn}=Rt,{ERR_INVALID_ARG_VALUE:kn}=Le.codes;let Bn=16384,Un=16;function $n(e){return e?Un:Bn}var qn={getHighWaterMark:function(e,t,r,n){const i=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,n,r);if(null!=i){if(!Ln(i)||i<0){throw new kn(n?`options.${r}`:"options.highWaterMark",i)}return Mn(i)}return $n(e.objectMode)},getDefaultHighWaterMark:$n,setDefaultHighWaterMark:function(e,t){Cn(t,"value",0),e?Un=t:Bn=t}},Qn={},zn={exports:{}};
+/*! safe-buffer. MIT License. Feross Aboukhadijeh */
+!function(e,t){var r=a,n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(zn,zn.exports);var Gn=zn.exports.Buffer,Vn=Gn.isEncoding||function(e){switch((e=""+e)&&e.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 Xn(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){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 e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(Gn.isEncoding===Vn||!Vn(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=Wn,this.end=Kn,t=4;break;case"utf8":this.fillLast=Jn,t=4;break;case"base64":this.text=Yn,this.end=Zn,t=3;break;default:return this.write=ei,void(this.end=ti)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Gn.allocUnsafe(t)}function Hn(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function Jn(e){var t=this.lastTotal-this.lastNeed,r=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function Wn(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function Kn(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function Yn(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Zn(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function ei(e){return e.toString(this.encoding)}function ti(e){return e&&e.length?this.write(e):""}Qn.StringDecoder=Xn,Xn.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},Xn.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};const ri=Jt,{PromisePrototypeThen:ni,SymbolAsyncIterator:ii,SymbolIterator:oi}=ve,{Buffer:ai}=a,{ERR_INVALID_ARG_TYPE:si,ERR_STREAM_NULL_VALUES:ci}=Le.codes;var ui,li,di,pi,fi,hi,yi,gi,mi=function(e,t,r){let n,i;if("string"==typeof t||t instanceof ai)return new e({objectMode:!0,...r,read(){this.push(t),this.push(null)}});if(t&&t[ii])i=!0,n=t[ii]();else{if(!t||!t[oi])throw new si("iterable",["Iterable"],t);i=!1,n=t[oi]()}const o=new e({objectMode:!0,highWaterMark:1,...r});let a=!1;return o._read=function(){a||(a=!0,async function(){for(;;){try{const{value:e,done:t}=i?await n.next():n.next();if(t)o.push(null);else{const t=e&&"function"==typeof e.then?await e:e;if(null===t)throw a=!1,new ci;if(o.push(t))continue;a=!1}}catch(e){o.destroy(e)}break}}())},o._destroy=function(e,t){ni(async function(e){const t=null!=e,r="function"==typeof n.throw;if(t&&r){const{value:t,done:r}=await n.throw(e);if(await t,r)return}if("function"==typeof n.return){const{value:e}=await n.return();await e}}(e),()=>ri.nextTick(t,e),r=>ri.nextTick(t,r||e))},o};function bi(){if(li)return ui;li=1;const e=Jt,{ArrayPrototypeIndexOf:t,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:o,ObjectKeys:s,ObjectSetPrototypeOf:c,Promise:u,SafeSet:l,SymbolAsyncDispose:d,SymbolAsyncIterator:p,Symbol:f}=ve;ui=V,V.ReadableState=G;const{EventEmitter:h}=tt,{Stream:y,prependListener:g}=xn,{Buffer:m}=a,{addAbortSignal:b}=An,v=Jr;let _=rt.debuglog("stream",e=>{_=e});const w=Rn,T=vn,{getHighWaterMark:O,getDefaultHighWaterMark:S}=qn,{aggregateTwoErrors:x,codes:{ERR_INVALID_ARG_TYPE:j,ERR_METHOD_NOT_IMPLEMENTED:A,ERR_OUT_OF_RANGE:E,ERR_STREAM_PUSH_AFTER_EOF:I,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:F},AbortError:D}=Le,{validateObject:N}=Rt,P=f("kPaused"),{StringDecoder:R}=Qn,M=mi;c(V.prototype,y.prototype),c(V,y);const L=()=>{},{errorOrDestroy:C}=T,k=1,B=16,U=32,q=2048,Q=4096;function z(e){return{enumerable:!1,get(){return 0!==(this.state&e)},set(t){t?this.state|=e:this.state&=~e}}}function G(e,t,r){"boolean"!=typeof r&&(r=t instanceof wi()),this.state=q|Q|B|U,e&&e.objectMode&&(this.state|=k),r&&e&&e.readableObjectMode&&(this.state|=k),this.highWaterMark=e?O(this,e,"readableHighWaterMark",r):S(!1),this.buffer=new w,this.length=0,this.pipes=[],this.flowing=null,this[P]=null,e&&!1===e.emitClose&&(this.state&=~q),e&&!1===e.autoDestroy&&(this.state&=~Q),this.errored=null,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,e&&e.encoding&&(this.decoder=new R(e.encoding),this.encoding=e.encoding)}function V(e){if(!(this instanceof V))return new V(e);const t=this instanceof wi();this._readableState=new G(e,this,t),e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.construct&&(this._construct=e.construct),e.signal&&!t&&b(e.signal,this)),y.call(this,e),T.construct(this,()=>{this._readableState.needReadable&&Y(this,this._readableState)})}function X(e,t,r,n){_("readableAddChunk",t);const i=e._readableState;let o;if(0===(i.state&k)&&("string"==typeof t?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?t=m.from(t,r).toString(i.encoding):(t=m.from(t,r),r=""))):t instanceof m?r="":y._isUint8Array(t)?(t=y._uint8ArrayToBuffer(t),r=""):null!=t&&(o=new j("chunk",["string","Buffer","Uint8Array"],t))),o)C(e,o);else if(null===t)i.state&=-9,function(e,t){if(_("onEofChunk"),t.ended)return;if(t.decoder){const e=t.decoder.end();e&&e.length&&(t.buffer.push(e),t.length+=t.objectMode?1:e.length)}t.ended=!0,t.sync?W(e):(t.needReadable=!1,t.emittedReadable=!0,K(e))}(e,i);else if(0!==(i.state&k)||t&&t.length>0)if(n)if(4&i.state)C(e,new F);else{if(i.destroyed||i.errored)return!1;H(e,i,t,!0)}else if(i.ended)C(e,new I);else{if(i.destroyed||i.errored)return!1;i.state&=-9,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?H(e,i,t,!1):Y(e,i)):H(e,i,t,!1)}else n||(i.state&=-9,Y(e,i));return!i.ended&&(i.length0?(65536&t.state?t.awaitDrainWriters.clear():t.awaitDrainWriters=null,t.dataEmitted=!0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),64&t.state&&W(e)),Y(e,t)}o(G.prototype,{objectMode:z(k),ended:z(2),endEmitted:z(4),reading:z(8),constructed:z(B),sync:z(U),needReadable:z(64),emittedReadable:z(128),readableListening:z(256),resumeScheduled:z(512),errorEmitted:z(1024),emitClose:z(q),autoDestroy:z(Q),destroyed:z(8192),closed:z(16384),closeEmitted:z(32768),multiAwaitDrain:z(65536),readingMore:z(1<<17),dataEmitted:z(1<<18)}),V.prototype.destroy=T.destroy,V.prototype._undestroy=T.undestroy,V.prototype._destroy=function(e,t){t(e)},V.prototype[h.captureRejectionSymbol]=function(e){this.destroy(e)},V.prototype[d]=function(){let e;return this.destroyed||(e=this.readableEnded?null:new D,this.destroy(e)),new u((t,r)=>v(this,n=>n&&n!==e?r(n):t(null)))},V.prototype.push=function(e,t){return X(this,e,t,!1)},V.prototype.unshift=function(e,t){return X(this,e,t,!0)},V.prototype.isPaused=function(){const e=this._readableState;return!0===e[P]||!1===e.flowing},V.prototype.setEncoding=function(e){const t=new R(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;const r=this._readableState.buffer;let n="";for(const e of r)n+=t.write(e);return r.clear(),""!==n&&r.push(n),this._readableState.length=n.length,this};function J(e,t){return e<=0||0===t.length&&t.ended?0:0!==(t.state&k)?1:n(e)?t.flowing&&t.length?t.buffer.first().length:t.length:e<=t.length?e:t.ended?t.length:0}function W(t){const r=t._readableState;_("emitReadable",r.needReadable,r.emittedReadable),r.needReadable=!1,r.emittedReadable||(_("emitReadable",r.flowing),r.emittedReadable=!0,e.nextTick(K,t))}function K(e){const t=e._readableState;_("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||t.errored||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,ne(e)}function Y(t,r){!r.readingMore&&r.constructed&&(r.readingMore=!0,e.nextTick(Z,t,r))}function Z(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!1===t[P]?t.flowing=!0:e.listenerCount("data")>0?e.resume():t.readableListening||(t.flowing=null)}function te(e){_("readable nexttick read 0"),e.read(0)}function re(e,t){_("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),ne(e),t.flowing&&!t.reading&&e.read(0)}function ne(e){const t=e._readableState;for(_("flow",t.flowing);t.flowing&&null!==e.read(););}function ie(e,t){"function"!=typeof e.read&&(e=V.wrap(e,{objectMode:!0}));const r=async function*(e,t){let r,n=L;function i(t){this===e?(n(),n=L):n=t}e.on("readable",i);const o=v(e,{writable:!1},e=>{r=e?x(r,e):null,n(),n=L});try{for(;;){const t=e.destroyed?null:e.read();if(null!==t)yield t;else{if(r)throw r;if(null===r)return;await new u(i)}}}catch(e){throw r=x(r,e),r}finally{!r&&!1===(null==t?void 0:t.destroyOnReturn)||void 0!==r&&!e._readableState.autoDestroy?(e.off("readable",i),o()):T.destroyer(e,null)}}(e,t);return r.stream=e,r}function oe(e,t){if(0===t.length)return null;let r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function ae(t){const r=t._readableState;_("endReadable",r.endEmitted),r.endEmitted||(r.ended=!0,e.nextTick(se,r,t))}function se(t,r){if(_("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&0===t.length)if(t.endEmitted=!0,r.emit("end"),r.writable&&!1===r.allowHalfOpen)e.nextTick(ce,r);else if(t.autoDestroy){const e=r._writableState;(!e||e.autoDestroy&&(e.finished||!1===e.writable))&&r.destroy()}}function ce(e){e.writable&&!e.writableEnded&&!e.destroyed&&e.end()}let ue;function le(){return void 0===ue&&(ue={}),ue}return V.prototype.read=function(e){_("read",e),void 0===e?e=NaN:r(e)||(e=i(e,10));const t=this._readableState,n=e;if(e>t.highWaterMark&&(t.highWaterMark=function(e){if(e>1073741824)throw new E("size","<= 1GiB",e);return e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,++e}(e)),0!==e&&(t.state&=-129),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return _("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?ae(this):W(this),null;if(0===(e=J(e,t))&&t.ended)return 0===t.length&&ae(this),null;let o,a=!!(64&t.state);if(_("need readable",a),(0===t.length||t.length-e0?oe(e,t):null,null===o?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.multiAwaitDrain?t.awaitDrainWriters.clear():t.awaitDrainWriters=null),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&ae(this)),null===o||t.errorEmitted||t.closeEmitted||(t.dataEmitted=!0,this.emit("data",o)),o},V.prototype._read=function(e){throw new A("_read()")},V.prototype.pipe=function(t,r){const n=this,i=this._readableState;1===i.pipes.length&&(i.multiAwaitDrain||(i.multiAwaitDrain=!0,i.awaitDrainWriters=new l(i.awaitDrainWriters?[i.awaitDrainWriters]:[]))),i.pipes.push(t),_("pipe count=%d opts=%j",i.pipes.length,r);const o=(!r||!1!==r.end)&&t!==e.stdout&&t!==e.stderr?s:m;function a(e,r){_("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,function(){_("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),c&&t.removeListener("drain",c);t.removeListener("error",f),t.removeListener("unpipe",a),n.removeListener("end",s),n.removeListener("end",m),n.removeListener("data",p),u=!0,c&&i.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&c()}())}function s(){_("onend"),t.end()}let c;i.endEmitted?e.nextTick(o):n.once("end",o),t.on("unpipe",a);let u=!1;function d(){u||(1===i.pipes.length&&i.pipes[0]===t?(_("false write response, pause",0),i.awaitDrainWriters=t,i.multiAwaitDrain=!1):i.pipes.length>1&&i.pipes.includes(t)&&(_("false write response, pause",i.awaitDrainWriters.size),i.awaitDrainWriters.add(t)),n.pause()),c||(c=function(e,t){return function(){const r=e._readableState;r.awaitDrainWriters===t?(_("pipeOnDrain",1),r.awaitDrainWriters=null):r.multiAwaitDrain&&(_("pipeOnDrain",r.awaitDrainWriters.size),r.awaitDrainWriters.delete(t)),r.awaitDrainWriters&&0!==r.awaitDrainWriters.size||!e.listenerCount("data")||e.resume()}}(n,t),t.on("drain",c))}function p(e){_("ondata");const r=t.write(e);_("dest.write",r),!1===r&&d()}function f(e){if(_("onerror",e),m(),t.removeListener("error",f),0===t.listenerCount("error")){const r=t._writableState||t._readableState;r&&!r.errorEmitted?C(t,e):t.emit("error",e)}}function h(){t.removeListener("finish",y),m()}function y(){_("onfinish"),t.removeListener("close",h),m()}function m(){_("unpipe"),n.unpipe(t)}return n.on("data",p),g(t,"error",f),t.once("close",h),t.once("finish",y),t.emit("pipe",n),!0===t.writableNeedDrain?d():i.flowing||(_("pipe resume"),n.resume()),t},V.prototype.unpipe=function(e){const r=this._readableState;if(0===r.pipes.length)return this;if(!e){const e=r.pipes;r.pipes=[],this.pause();for(let t=0;t0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,_("on readable",i.length,i.reading),i.length?W(this):i.reading||e.nextTick(te,this))),n},V.prototype.addListener=V.prototype.on,V.prototype.removeListener=function(t,r){const n=y.prototype.removeListener.call(this,t,r);return"readable"===t&&e.nextTick(ee,this),n},V.prototype.off=V.prototype.removeListener,V.prototype.removeAllListeners=function(t){const r=y.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(ee,this),r},V.prototype.resume=function(){const t=this._readableState;return t.flowing||(_("resume"),t.flowing=!t.readableListening,function(t,r){r.resumeScheduled||(r.resumeScheduled=!0,e.nextTick(re,t,r))}(this,t)),t[P]=!1,this},V.prototype.pause=function(){return _("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(_("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[P]=!0,this},V.prototype.wrap=function(e){let t=!1;e.on("data",r=>{!this.push(r)&&e.pause&&(t=!0,e.pause())}),e.on("end",()=>{this.push(null)}),e.on("error",e=>{C(this,e)}),e.on("close",()=>{this.destroy()}),e.on("destroy",()=>{this.destroy()}),this._read=()=>{t&&e.resume&&(t=!1,e.resume())};const r=s(e);for(let t=1;t{const e=this._writableState;e.writing||U(this,e),z(this,e)})}function P(t,r,n,i){const o=t._writableState;if("function"==typeof n)i=n,n=o.defaultEncoding;else{if(n){if("buffer"!==n&&!f.isEncoding(n))throw new j(n)}else n=o.defaultEncoding;"function"!=typeof i&&(i=E)}if(null===r)throw new S;if(!o.objectMode)if("string"==typeof r)!1!==o.decodeStrings&&(r=f.from(r,n),n="buffer");else if(r instanceof f)n="buffer";else{if(!p._isUint8Array(r))throw new b("chunk",["string","Buffer","Uint8Array"],r);r=p._uint8ArrayToBuffer(r),n="buffer"}let a;return o.ending?a=new x:o.destroyed&&(a=new T("write")),a?(e.nextTick(i,a),A(t,a,!0),a):(o.pendingcb++,function(e,t,r,n,i){const o=t.objectMode?1:r.length;t.length+=o;const a=t.lengthn.bufferedIndex&&U(t,n),i?null!==n.afterWriteTickInfo&&n.afterWriteTickInfo.cb===o?n.afterWriteTickInfo.count++:(n.afterWriteTickInfo={count:1,cb:o,stream:t,state:n},e.nextTick(C,n.afterWriteTickInfo)):k(t,n,1,o))):A(t,new _)}function C({stream:e,state:t,count:r,cb:n}){return t.afterWriteTickInfo=null,k(e,t,r,n)}function k(e,t,r,n){for(!t.ending&&!e.destroyed&&0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"));r-- >0;)t.pendingcb--,n();t.destroyed&&B(t),z(e,t)}function B(e){if(e.writing)return;for(let r=e.bufferedIndex;r1&&e._writev){r.pendingcb-=a-1;const i=r.allNoop?E:e=>{for(let t=s;t256?(n.splice(0,s),r.bufferedIndex=0):r.bufferedIndex=s}r.bufferProcessing=!1}function q(e){return e.ending&&!e.destroyed&&e.constructed&&0===e.length&&!e.errored&&0===e.buffered.length&&!e.finished&&!e.writing&&!e.errorEmitted&&!e.closeEmitted}function Q(t,r){r.prefinished||r.finalCalled||("function"!=typeof t._final||r.destroyed?(r.prefinished=!0,t.emit("prefinish")):(r.finalCalled=!0,function(t,r){let n=!1;function i(i){if(n)A(t,null!=i?i:_());else if(n=!0,r.pendingcb--,i){const e=r[I].splice(0);for(let t=0;t{q(t)?G(e,t):t.pendingcb--},t,r)):q(r)&&(r.pendingcb++,G(t,r))))}function G(e,t){t.pendingcb--,t.finished=!0;const r=t[I].splice(0);for(let e=0;e{d=!1,e&&g(t,e),h(e)}),u._write=function(e,t,r){i.write(e,t)?r():o=r},u._final=function(e){i.end(),a=e},i.on("drain",function(){if(o){const e=o;o=null,e()}}),i.on("finish",function(){if(a){const e=a;a=null,e()}})),l&&(p(t,e=>{l=!1,e&&g(t,e),h(e)}),t.on("readable",function(){if(s){const e=s;s=null,e()}}),t.on("end",function(){u.push(null)}),u._read=function(){for(;;){const e=t.read();if(null===e)return void(s=u._read);if(!u.push(e))return}}),u._destroy=function(e,r){e||null===c||(e=new f),s=null,o=null,a=null,null===c?r(e):(c=r,g(i,e),g(t,e))},u}return fi=function t(r,n){if(u(r))return r;if(s(r))return A({readable:r});if(c(r))return A({writable:r});if(o(r))return A({writable:!1,readable:!1});if(l(r))return A({readable:b.fromWeb(r)});if(d(r))return A({writable:v.fromWeb(r)});if("function"==typeof r){const{value:t,write:o,final:a,destroy:s}=function(t){let{promise:r,resolve:n}=_();const i=new S,o=i.signal,a=t(async function*(){for(;;){const t=r;r=null;const{chunk:i,done:a,cb:s}=await t;if(e.nextTick(s),a)return;if(o.aborted)throw new f(void 0,{cause:o.reason});({promise:r,resolve:n}=_()),yield i}}(),{signal:o});return{value:a,write(e,t,r){const i=n;n=null,i({chunk:e,done:!1,cb:r})},final(e){const t=n;n=null,t({done:!0,cb:e})},destroy(e,t){i.abort(),t(e)}}}(r);if(i(t))return w(j,t,{objectMode:!0,write:o,final:a,destroy:s});const c=null==t?void 0:t.then;if("function"==typeof c){let r;const n=x(c,t,e=>{if(null!=e)throw new y("nully","body",e)},e=>{g(r,e)});return r=new j({objectMode:!0,readable:!1,write:o,final(t){a(async()=>{try{await n,e.nextTick(t,null)}catch(r){e.nextTick(t,r)}})},destroy:s})}throw new y("Iterable, AsyncIterable or AsyncFunction",n,t)}if(O(r))return t(r.arrayBuffer());if(i(r))return w(j,r,{objectMode:!0,writable:!1});if(l(null==r?void 0:r.readable)&&d(null==r?void 0:r.writable))return j.fromWeb(r);if("object"==typeof(null==r?void 0:r.writable)||"object"==typeof(null==r?void 0:r.readable)){return A({readable:null!=r&&r.readable?s(null==r?void 0:r.readable)?null==r?void 0:r.readable:t(r.readable):void 0,writable:null!=r&&r.writable?c(null==r?void 0:r.writable)?null==r?void 0:r.writable:t(r.writable):void 0})}const a=null==r?void 0:r.then;if("function"==typeof a){let e;return x(a,r,t=>{null!=t&&e.push(t),e.push(null)},t=>{g(e,t)}),e=new j({objectMode:!0,writable:!1,read(){}})}throw new h(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],r)},fi}function wi(){if(gi)return yi;gi=1;const{ObjectDefineProperties:e,ObjectGetOwnPropertyDescriptor:t,ObjectKeys:r,ObjectSetPrototypeOf:n}=ve;yi=a;const i=bi(),o=vi();n(a.prototype,i.prototype),n(a,i);{const e=r(o.prototype);for(let t=0;t{t?e?e(t):this.destroy(t):(null!=r&&this.push(r),this.push(null),e&&e())})}function Di(){this._final!==Fi&&Fi.call(this)}Ii.prototype._final=Fi,Ii.prototype._transform=function(e,t,r){throw new xi("_transform()")},Ii.prototype._write=function(e,t,r){const n=this._readableState,i=this._writableState,o=n.length;this._transform(e,t,(e,t)=>{e?r(e):(null!=t&&this.push(t),i.ended||o===n.length||n.length{n=!0});return{destroy:t=>{n||(n=!0,Qi.destroyer(e,t||new Ji("pipe")))},cleanup:$i(e,{readable:t,writable:r},e=>{n=!e})}}function ho(e){if(eo(e))return e;if(ro(e))return async function*(e){lo||(lo=bi());yield*lo.prototype[Bi].call(e)}(e);throw new Vi("val",["Readable","Iterable","AsyncIterable"],e)}async function yo(e,t,r,{end:n}){let i,o=null;const a=e=>{if(e&&(i=e),o){const e=o;o=null,e()}},s=()=>new ki((e,t)=>{i?t(i):o=()=>{i?t(i):e()}});t.on("drain",a);const c=$i(t,{readable:!1},a);try{t.writableNeedDrain&&await s();for await(const r of e)t.write(r)||await s();n&&(t.end(),await s()),r()}catch(e){r(i!==e?Gi(i,e):e)}finally{c(),t.off("drain",a)}}async function go(e,t,r,{end:n}){io(t)&&(t=t.writable);const i=t.getWriter();try{for await(const t of e)await i.ready,i.write(t).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(e){try{await i.abort(e),r(e)}catch(e){r(e)}}}function mo(e,t,r){if(1===e.length&&Ci(e[0])&&(e=e[0]),e.length<2)throw new Hi("streams");const n=new co,i=n.signal,o=null==r?void 0:r.signal,a=[];function s(){y(new Ki)}let c,u,l;Zi(o,"options.signal"),po=po||rt.addAbortListener,o&&(c=po(o,s));const d=[];let p,f=0;function h(e){y(e,0===--f)}function y(e,r){var i;if(!e||u&&"ERR_STREAM_PREMATURE_CLOSE"!==u.code||(u=e),u||r){for(;d.length;)d.shift()(u);null===(i=c)||void 0===i||i[Ui](),n.abort(),r&&(u||a.forEach(e=>e()),Li.nextTick(t,u,l))}}for(let b=0;b0,T=_||!1!==(null==r?void 0:r.end),O=b===e.length-1;if(no(v)){if(T){const{destroy:x,cleanup:j}=fo(v,_,w);d.push(x),to(v)&&O&&a.push(j)}function S(e){e&&"AbortError"!==e.name&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code&&h(e)}v.on("error",S),to(v)&&O&&a.push(()=>{v.removeListener("error",S)})}if(0===b)if("function"==typeof v){if(p=v({signal:i}),!eo(p))throw new Xi("Iterable, AsyncIterable or Stream","source",p)}else p=eo(v)||ro(v)||io(v)?v:zi.from(v);else if("function"==typeof v){var g;if(io(p))p=ho(null===(g=p)||void 0===g?void 0:g.readable);else p=ho(p);if(p=v(p,{signal:i}),_){if(!eo(p,!0))throw new Xi("AsyncIterable",`transform[${b-1}]`,p)}else{var m;uo||(uo=Pi);const A=new uo({objectMode:!0}),E=null===(m=p)||void 0===m?void 0:m.then;if("function"==typeof E)f++,E.call(p,e=>{l=e,null!=e&&A.write(e),T&&A.end(),Li.nextTick(h)},e=>{A.destroy(e),Li.nextTick(h,e)});else if(eo(p,!0))f++,yo(p,A,h,{end:T});else{if(!ao(p)&&!io(p))throw new Xi("AsyncIterable or Promise","destination",p);{const D=p.readable||p;f++,yo(D,A,h,{end:T})}}p=A;const{destroy:I,cleanup:F}=fo(p,!1,!0);d.push(I),O&&a.push(F)}}else if(no(v)){if(ro(p)){f+=2;const N=bo(p,v,h,{end:T});to(v)&&O&&a.push(N)}else if(io(p)||ao(p)){const P=p.readable||p;f++,yo(P,v,h,{end:T})}else{if(!eo(p))throw new Vi("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],p);f++,yo(p,v,h,{end:T})}p=v}else if(oo(v)){if(ro(p))f++,go(ho(p),v,h,{end:T});else if(ao(p)||eo(p))f++,go(p,v,h,{end:T});else{if(!io(p))throw new Vi("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],p);f++,go(p.readable,v,h,{end:T})}p=v}else p=zi.from(v)}return(null!=i&&i.aborted||null!=o&&o.aborted)&&Li.nextTick(s),p}function bo(e,t,r,{end:n}){let i=!1;if(t.on("close",()=>{i||r(new Wi)}),e.pipe(t,{end:!1}),n){function o(){i=!0,t.end()}so(e)?Li.nextTick(o):e.once("end",o)}else r();return $i(e,{readable:!0,writable:!1},t=>{const n=e._readableState;t&&"ERR_STREAM_PREMATURE_CLOSE"===t.code&&n&&n.ended&&!n.errored&&!n.errorEmitted?e.once("end",r).once("error",r):r(t)}),$i(t,{readable:!1,writable:!0},r)}var vo={pipelineImpl:mo,pipeline:function(...e){return mo(e,qi(function(e){return Yi(e[e.length-1],"streams[stream.length - 1]"),e.pop()}(e)))}};const{pipeline:_o}=vo,wo=wi(),{destroyer:To}=vn,{isNodeStream:Oo,isReadable:So,isWritable:xo,isWebStream:jo,isTransformStream:Ao,isWritableStream:Eo,isReadableStream:Io}=mr,{AbortError:Fo,codes:{ERR_INVALID_ARG_VALUE:Do,ERR_MISSING_ARGS:No}}=Le,Po=Jr;var Ro=function(...e){if(0===e.length)throw new No("streams");if(1===e.length)return wo.from(e[0]);const t=[...e];if("function"==typeof e[0]&&(e[0]=wo.from(e[0])),"function"==typeof e[e.length-1]){const t=e.length-1;e[t]=wo.from(e[t])}for(let r=0;r0&&!(xo(e[r])||Eo(e[r])||Ao(e[r])))throw new Do(`streams[${r}]`,t[r],"must be writable")}let r,n,i,o,a;const s=e[0],c=_o(e,function(e){const t=o;o=null,t?t(e):e?a.destroy(e):l||u||a.destroy()}),u=!!(xo(s)||Eo(s)||Ao(s)),l=!!(So(c)||Io(c)||Ao(c));if(a=new wo({writableObjectMode:!(null==s||!s.writableObjectMode),readableObjectMode:!(null==c||!c.readableObjectMode),writable:u,readable:l}),u){if(Oo(s))a._write=function(e,t,n){s.write(e,t)?n():r=n},a._final=function(e){s.end(),n=e},s.on("drain",function(){if(r){const e=r;r=null,e()}});else if(jo(s)){const e=(Ao(s)?s.writable:s).getWriter();a._write=async function(t,r,n){try{await e.ready,e.write(t).catch(()=>{}),n()}catch(e){n(e)}},a._final=async function(t){try{await e.ready,e.close().catch(()=>{}),n=t}catch(e){t(e)}}}const e=Ao(c)?c.readable:c;Po(e,()=>{if(n){const e=n;n=null,e()}})}if(l)if(Oo(c))c.on("readable",function(){if(i){const e=i;i=null,e()}}),c.on("end",function(){a.push(null)}),a._read=function(){for(;;){const e=c.read();if(null===e)return void(i=a._read);if(!a.push(e))return}};else if(jo(c)){const e=(Ao(c)?c.readable:c).getReader();a._read=async function(){for(;;)try{const{value:t,done:r}=await e.read();if(!a.push(t))return;if(r)return void a.push(null)}catch{return}}}return a._destroy=function(e,t){e||null===o||(e=new Fo),i=null,r=null,n=null,null===o?t(e):(o=t,Oo(c)&&To(c,e))},a};const Mo=globalThis.AbortController||ke().AbortController,{codes:{ERR_INVALID_ARG_VALUE:Lo,ERR_INVALID_ARG_TYPE:Co,ERR_MISSING_ARGS:ko,ERR_OUT_OF_RANGE:Bo},AbortError:Uo}=Le,{validateAbortSignal:$o,validateInteger:qo,validateObject:Qo}=Rt,zo=ve.Symbol("kWeak"),Go=ve.Symbol("kResistStopPropagation"),{finished:Vo}=Jr,Xo=Ro,{addAbortSignalNoValidate:Ho}=An,{isWritable:Jo,isNodeStream:Wo}=mr,{deprecate:Ko}=rt,{ArrayPrototypePush:Yo,Boolean:Zo,MathFloor:ea,Number:ta,NumberIsNaN:ra,Promise:na,PromiseReject:ia,PromiseResolve:oa,PromisePrototypeThen:aa,Symbol:sa}=ve,ca=sa("kEmpty"),ua=sa("kEof");function la(e,t){if("function"!=typeof e)throw new Co("fn",["Function","AsyncFunction"],e);null!=t&&Qo(t,"options"),null!=(null==t?void 0:t.signal)&&$o(t.signal,"options.signal");let r=1;null!=(null==t?void 0:t.concurrency)&&(r=ea(t.concurrency));let n=r-1;return null!=(null==t?void 0:t.highWaterMark)&&(n=ea(t.highWaterMark)),qo(r,"options.concurrency",1),qo(n,"options.highWaterMark",0),n+=r,async function*(){const i=rt.AbortSignalAny([null==t?void 0:t.signal].filter(Zo)),o=this,a=[],s={signal:i};let c,u,l=!1,d=0;function p(){l=!0,f()}function f(){d-=1,h()}function h(){u&&!l&&d=n||d>=r)&&await new na(e=>{u=e})}a.push(ua)}catch(e){const t=ia(e);aa(t,f,p),a.push(t)}finally{l=!0,c&&(c(),c=null)}}();try{for(;;){for(;a.length>0;){const e=await a[0];if(e===ua)return;if(i.aborted)throw new Uo;e!==ca&&(yield e),a.shift(),h()}await new na(e=>{c=e})}}finally{l=!0,u&&(u(),u=null)}}.call(this)}async function da(e,t=void 0){for await(const r of pa.call(this,e,t))return!0;return!1}function pa(e,t){if("function"!=typeof e)throw new Co("fn",["Function","AsyncFunction"],e);return la.call(this,async function(t,r){return await e(t,r)?t:ca},t)}class fa extends ko{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}function ha(e){if(e=ta(e),ra(e))return 0;if(e<0)throw new Bo("number",">= 0",e);return e}var ya,ga,ma;function ba(){if(ga)return ya;ga=1;const{ArrayPrototypePop:e,Promise:t}=ve,{isIterable:r,isNodeStream:n,isWebStream:i}=mr,{pipelineImpl:o}=vo,{finished:a}=Jr;return va(),ya={finished:a,pipeline:function(...a){return new t((t,s)=>{let c,u;const l=a[a.length-1];if(l&&"object"==typeof l&&!n(l)&&!r(l)&&!i(l)){const t=e(a);c=t.signal,u=t.end}o(a,(e,r)=>{e?s(e):t(r)},{signal:c,end:u})})}}}function va(){if(ma)return me.exports;ma=1;const{Buffer:e}=a,{ObjectDefineProperty:t,ObjectKeys:r,ReflectApply:n}=ve,{promisify:{custom:i}}=rt,{streamReturningOperators:o,promiseReturningOperators:s}=nt,{codes:{ERR_ILLEGAL_CONSTRUCTOR:c}}=Le,u=Ro,{setDefaultHighWaterMark:l,getDefaultHighWaterMark:d}=qn,{pipeline:p}=vo,{destroyer:f}=vn,h=Jr,y=ba(),g=mr,m=me.exports=xn.Stream;m.isDestroyed=g.isDestroyed,m.isDisturbed=g.isDisturbed,m.isErrored=g.isErrored,m.isReadable=g.isReadable,m.isWritable=g.isWritable,m.Readable=bi();for(const v of r(o)){const _=o[v];function w(...e){if(new.target)throw c();return m.Readable.from(n(_,this,e))}t(w,"name",{__proto__:null,value:_.name}),t(w,"length",{__proto__:null,value:_.length}),t(m.Readable.prototype,v,{__proto__:null,value:w,enumerable:!1,configurable:!0,writable:!0})}for(const T of r(s)){const O=s[T];function S(...e){if(new.target)throw c();return n(O,this,e)}t(S,"name",{__proto__:null,value:O.name}),t(S,"length",{__proto__:null,value:O.length}),t(m.Readable.prototype,T,{__proto__:null,value:S,enumerable:!1,configurable:!0,writable:!0})}m.Writable=vi(),m.Duplex=wi(),m.Transform=Si,m.PassThrough=Pi,m.pipeline=p;const{addAbortSignal:b}=An;return m.addAbortSignal=b,m.finished=h,m.destroy=f,m.compose=u,m.setDefaultHighWaterMark=l,m.getDefaultHighWaterMark=d,t(m,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:()=>y}),t(p,i,{__proto__:null,enumerable:!0,get:()=>y.pipeline}),t(h,i,{__proto__:null,enumerable:!0,get:()=>y.finished}),m.Stream=m,m._isUint8Array=function(e){return e instanceof Uint8Array},m._uint8ArrayToBuffer=function(t){return e.from(t.buffer,t.byteOffset,t.byteLength)},me.exports}nt.streamReturningOperators={asIndexedPairs:Ko(function(e=void 0){return null!=e&&Qo(e,"options"),null!=(null==e?void 0:e.signal)&&$o(e.signal,"options.signal"),async function*(){let t=0;for await(const n of this){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new Uo({cause:e.signal.reason});yield[t++,n]}}.call(this)},"readable.asIndexedPairs will be removed in a future version."),drop:function(e,t=void 0){return null!=t&&Qo(t,"options"),null!=(null==t?void 0:t.signal)&&$o(t.signal,"options.signal"),e=ha(e),async function*(){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new Uo;for await(const r of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new Uo;e--<=0&&(yield r)}}.call(this)},filter:pa,flatMap:function(e,t){const r=la.call(this,e,t);return async function*(){for await(const e of r)yield*e}.call(this)},map:la,take:function(e,t=void 0){return null!=t&&Qo(t,"options"),null!=(null==t?void 0:t.signal)&&$o(t.signal,"options.signal"),e=ha(e),async function*(){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new Uo;for await(const r of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new Uo;if(e-- >0&&(yield r),e<=0)return}}.call(this)},compose:function(e,t){if(null!=t&&Qo(t,"options"),null!=(null==t?void 0:t.signal)&&$o(t.signal,"options.signal"),Wo(e)&&!Jo(e))throw new Lo("stream",e,"must be writable");const r=Xo(this,e);return null!=t&&t.signal&&Ho(t.signal,r),r}},nt.promiseReturningOperators={every:async function(e,t=void 0){if("function"!=typeof e)throw new Co("fn",["Function","AsyncFunction"],e);return!await da.call(this,async(...t)=>!await e(...t),t)},forEach:async function(e,t){if("function"!=typeof e)throw new Co("fn",["Function","AsyncFunction"],e);for await(const r of la.call(this,async function(t,r){return await e(t,r),ca},t));},reduce:async function(e,t,r){var n;if("function"!=typeof e)throw new Co("reducer",["Function","AsyncFunction"],e);null!=r&&Qo(r,"options"),null!=(null==r?void 0:r.signal)&&$o(r.signal,"options.signal");let i=arguments.length>1;if(null!=r&&null!==(n=r.signal)&&void 0!==n&&n.aborted){const e=new Uo(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await Vo(this.destroy(e)),e}const o=new Mo,a=o.signal;if(null!=r&&r.signal){const e={once:!0,[zo]:this,[Go]:!0};r.signal.addEventListener("abort",()=>o.abort(),e)}let s=!1;try{for await(const n of this){var c;if(s=!0,null!=r&&null!==(c=r.signal)&&void 0!==c&&c.aborted)throw new Uo;i?t=await e(t,n,{signal:a}):(t=n,i=!0)}if(!s&&!i)throw new fa}finally{o.abort()}return t},toArray:async function(e){null!=e&&Qo(e,"options"),null!=(null==e?void 0:e.signal)&&$o(e.signal,"options.signal");const t=[];for await(const n of this){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new Uo(void 0,{cause:e.signal.reason});Yo(t,n)}return t},some:da,find:async function(e,t){for await(const r of pa.call(this,e,t))return r}},function(e){const t=va(),r=ba(),n=t.Readable.destroy;e.exports=t.Readable,e.exports._uint8ArrayToBuffer=t._uint8ArrayToBuffer,e.exports._isUint8Array=t._isUint8Array,e.exports.isDisturbed=t.isDisturbed,e.exports.isErrored=t.isErrored,e.exports.isReadable=t.isReadable,e.exports.Readable=t.Readable,e.exports.Writable=t.Writable,e.exports.Duplex=t.Duplex,e.exports.Transform=t.Transform,e.exports.PassThrough=t.PassThrough,e.exports.addAbortSignal=t.addAbortSignal,e.exports.finished=t.finished,e.exports.destroy=t.destroy,e.exports.destroy=n,e.exports.pipeline=t.pipeline,e.exports.compose=t.compose,Object.defineProperty(t,"promises",{configurable:!0,enumerable:!0,get:()=>r}),e.exports.Stream=t.Stream,e.exports.default=e.exports}(ge);var _a=ge.exports;const wa=Symbol("iter");function Ta(e,t,r=4){if(0===r)return Object.assign(e,t);for(const n in t)e[n]=Ta(e[n]||Object.create(null),t[n],r-1);return e}function Oa(e,t,r=4){let n=!1;for(const i in e)if(i in t){const o=0===r?null:Oa(e[i],t[i],r-1);if(!1!==o)n=n||Object.create(null),n[i]=o;else if(3===r)return!1}return n}function Sa(e,t,r=4){let n=!1;for(const i in e)if(i in t){if(0!==r){const o=Sa(e[i],t[i],r-1);if(!1!==o)n=n||Object.create(null),n[i]=o;else if(3===r)return!1}}else n=n||Object.create(null),n[i]=0===r?null:Ta({},e[i],r-1);return n}class xa{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||N}_termFromId(e){if("."===e[0]){const t=this._entities,r=e.split(".");return this._factory.quad(this._termFromId(t[r[1]]),this._termFromId(t[r[2]]),this._termFromId(t[r[3]]),r[4]&&this._termFromId(t[r[4]]))}return B(e,this._factory)}_termToNumericId(e){if("Quad"===e.termType){const t=this._termToNumericId(e.subject),r=this._termToNumericId(e.predicate),n=this._termToNumericId(e.object);let i;return t&&r&&n&&(ee(e.graph)||(i=this._termToNumericId(e.graph)))&&this._ids[i?`.${t}.${r}.${n}.${i}`:`.${t}.${r}.${n}`]}return this._ids[U(e)]}_termToNewNumericId(e){const t=e&&"Quad"===e.termType?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${ee(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:U(e);return this._ids[t]||(this._ids[this._entities[++this._id]=t]=this._id)}createBlankNode(e){let t,r;if(e)for(t=e=`_:${e}`,r=1;this._ids[t];)t=e+r++;else do{t="_:b"+this._blankNodeIndex++}while(this._ids[t]);return this._ids[t]=++this._id,this._entities[this._id]=t,this._factory.blankNode(t.substr(2))}}class ja{constructor(e,t){this._size=0,this._graphs=Object.create(null),t||!e||e[0]||"function"==typeof e.match||(t=e,e=null),t=t||{},this._factory=t.factory||N,this._entityIndex=t.entityIndex||new xa({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(null!==e)return e;e=0;const t=this._graphs;let r,n;for(const i in t)for(const o in r=t[i].subjects)for(const t in n=r[o])e+=Object.keys(n[t]).length;return this._size=e}_addToIndex(e,t,r,n){const i=e[t]||(e[t]={}),o=i[r]||(i[r]={}),a=n in o;return a||(o[n]=null),!a}_removeFromIndex(e,t,r,n){const i=e[t],o=i[r];delete o[n];for(const e in o)return;delete i[r];for(const e in i)return;delete e[t]}*_findInIndex(e,t,r,n,i,o,a,s){let c,u,l;const d=this._entities,p=this._termFromId(d[s]),f={subject:null,predicate:null,object:null};t&&((c=e,e={})[t]=c[t]);for(const t in e)if(u=e[t]){f[i]=this._termFromId(d[t]),r&&((c=u,u={})[r]=c[r]);for(const e in u)if(l=u[e]){f[o]=this._termFromId(d[e]);const t=n?n in l?[n]:[]:Object.keys(l);for(let e=0;e{r in t||(t[r]=!0,e(this._termFromId(this._entities[r],this._factory)))}}add(e){return this.addQuad(e),this}addQuad(e,t,r,n){t||(n=e.graph,r=e.object,t=e.predicate,e=e.subject),n=n?this._termToNewNumericId(n):1;let i=this._graphs[n];return i||(i=this._graphs[n]={subjects:{},predicates:{},objects:{}},Object.freeze(i)),e=this._termToNewNumericId(e),t=this._termToNewNumericId(t),r=this._termToNewNumericId(r),!!this._addToIndex(i.subjects,e,t,r)&&(this._addToIndex(i.predicates,t,r,e),this._addToIndex(i.objects,r,e,t),this._size=null,!0)}addQuads(e){for(let t=0;t{this.addQuad(e)}),e}removeQuad(e,t,r,n){t||({subject:e,predicate:t,object:r,graph:n}=e),n=n?this._termToNumericId(n):1;const i=this._graphs;let o,a,s;if(!((e=e&&this._termToNumericId(e))&&(t=t&&this._termToNumericId(t))&&(r=r&&this._termToNumericId(r))&&(o=i[n])&&(a=o.subjects[e])&&(s=a[t])&&r in s))return!1;for(e in this._removeFromIndex(o.subjects,e,t,r),this._removeFromIndex(o.predicates,t,r,e),this._removeFromIndex(o.objects,r,e,t),null!==this._size&&this._size--,o.subjects)return!0;return delete i[n],!0}removeQuads(e){for(let t=0;t{this.removeQuad(e)}),e}removeMatches(e,t,r,n){const i=new _a.Readable({objectMode:!0}),o=this.readQuads(e,t,r,n);return i._read=e=>{for(;--e>=0;){const{done:e,value:t}=o.next();if(e)return void i.push(null);i.push(t)}},this.remove(i)}deleteGraph(e){return this.removeMatches(null,null,null,e)}getQuads(e,t,r,n){return[...this.readQuads(e,t,r,n)]}*readQuads(e,t,r,n){const i=this._getGraphs(n);let o,a,s,c;if(!(e&&!(a=this._termToNumericId(e))||t&&!(s=this._termToNumericId(t))||r&&!(c=this._termToNumericId(r))))for(const e in i)(o=i[e])&&(a?c?yield*this._findInIndex(o.objects,c,a,s,"object","subject","predicate",e):yield*this._findInIndex(o.subjects,a,s,null,"subject","predicate","object",e):s?yield*this._findInIndex(o.predicates,s,c,null,"predicate","object","subject",e):c?yield*this._findInIndex(o.objects,c,null,null,"object","subject","predicate",e):yield*this._findInIndex(o.subjects,null,null,null,"subject","predicate","object",e))}match(e,t,r,n){return new Ea(this,e,t,r,n,{entityIndex:this._entityIndex})}countQuads(e,t,r,n){const i=this._getGraphs(n);let o,a,s,c,u=0;if(e&&!(a=this._termToNumericId(e))||t&&!(s=this._termToNumericId(t))||r&&!(c=this._termToNumericId(r)))return 0;for(const n in i)(o=i[n])&&(u+=e?r?this._countInIndex(o.objects,c,a,s):this._countInIndex(o.subjects,a,s,c):t?this._countInIndex(o.predicates,s,c,a):this._countInIndex(o.objects,c,a,s));return u}forEach(e,t,r,n,i){this.some(t=>(e(t,this),!1),t,r,n,i)}every(e,t,r,n,i){return!this.some(t=>!e(t,this),t,r,n,i)}some(e,t,r,n,i){for(const o of this.readQuads(t,r,n,i))if(e(o,this))return!0;return!1}getSubjects(e,t,r){const n=[];return this.forSubjects(e=>{n.push(e)},e,t,r),n}forSubjects(e,t,r,n){const i=this._getGraphs(n);let o,a,s;if(e=this._uniqueEntities(e),!(t&&!(a=this._termToNumericId(t))||r&&!(s=this._termToNumericId(r))))for(n in i)(o=i[n])&&(a?s?this._loopBy2Keys(o.predicates,a,s,e):this._loopByKey1(o.subjects,a,e):s?this._loopByKey0(o.objects,s,e):this._loop(o.subjects,e))}getPredicates(e,t,r){const n=[];return this.forPredicates(e=>{n.push(e)},e,t,r),n}forPredicates(e,t,r,n){const i=this._getGraphs(n);let o,a,s;if(e=this._uniqueEntities(e),!(t&&!(a=this._termToNumericId(t))||r&&!(s=this._termToNumericId(r))))for(n in i)(o=i[n])&&(a?s?this._loopBy2Keys(o.objects,s,a,e):this._loopByKey0(o.subjects,a,e):s?this._loopByKey1(o.predicates,s,e):this._loop(o.predicates,e))}getObjects(e,t,r){const n=[];return this.forObjects(e=>{n.push(e)},e,t,r),n}forObjects(e,t,r,n){const i=this._getGraphs(n);let o,a,s;if(e=this._uniqueEntities(e),!(t&&!(a=this._termToNumericId(t))||r&&!(s=this._termToNumericId(r))))for(n in i)(o=i[n])&&(a?s?this._loopBy2Keys(o.subjects,a,s,e):this._loopByKey1(o.objects,a,e):s?this._loopByKey0(o.predicates,s,e):this._loop(o.objects,e))}getGraphs(e,t,r){const n=[];return this.forGraphs(e=>{n.push(e)},e,t,r),n}forGraphs(e,t,r,n){for(const i in this._graphs)this.some(t=>(e(t.graph),!0),t,r,n,this._termFromId(this._entities[i]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:t=!1}={}){const r={},n=t?()=>!0:(e,t)=>{throw new Error(`${e.value} ${t}`)},i=this.getQuads(null,_.rdf.rest,_.rdf.nil,null),o=e?[...i]:[];return i.forEach(t=>{const i=[];let a,s,c=!1;const u=t.graph;let l=t.subject;for(;l&&!c;){const e=this.getQuads(null,null,l,null),t=this.getQuads(l,null,null,null);let r,d=null,p=null,f=null;for(let i=0;ithis.has(e));const t=this._graphs,r=e._graphs;let n,i,o,a,s;for(const e in r){if(!(n=t[e]))return!1;n=n.subjects;for(const t in i=r[e].subjects){if(!(o=n[t]))return!1;for(const e in a=i[t]){if(!(s=o[e]))return!1;for(const t in a[e])if(!(t in s))return!1}}}return!0}deleteMatches(e,t,r,n){for(const i of this.match(e,t,r,n))this.removeQuad(i);return this}difference(e){if(e&&e instanceof Ea&&(e=e.filtered),e===this)return new ja({entityIndex:this._entityIndex});if(e instanceof ja&&e._entityIndex===this._entityIndex){const t=new ja({entityIndex:this._entityIndex}),r=Sa(this._graphs,e._graphs);return r&&(t._graphs=r,t._size=null),t}return this.filter(t=>!e.has(t))}equals(e){return e instanceof Ea&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){const t=new ja({entityIndex:this._entityIndex});for(const r of this)e(r,this)&&t.add(r);return t}intersection(e){if(e instanceof Ea&&(e=e.filtered),e===this){const e=new ja({entityIndex:this._entityIndex});return e._graphs=Ta(Object.create(null),this._graphs),e._size=this._size,e}if(e instanceof ja&&this._entityIndex===e._entityIndex){const t=new ja({entityIndex:this._entityIndex}),r=Oa(e._graphs,this._graphs);return r&&(t._graphs=r,t._size=null),t}return this.filter(t=>e.has(t))}map(e){const t=new ja({entityIndex:this._entityIndex});for(const r of this)t.add(e(r,this));return t}reduce(e,t){const r=this.readQuads();let n=void 0===t?r.next().value:t;for(const t of r)n=e(n,t,this);return n}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return(new he).quadsToString(this)}union(e){const t=new ja({entityIndex:this._entityIndex});return t._graphs=Ta(Object.create(null),this._graphs),t._size=this._size,t.addAll(e),t}*[Symbol.iterator](){yield*this.readQuads()}}function Aa(e,t,r=0){const n=t[r];if(n&&!(n in e))return!1;let i=!1;for(const o in n?{[n]:e[n]}:e){const n=2===r?null:Aa(e[o],t,r+1);!1!==n&&(i=i||Object.create(null),i[o]=n)}return i}class Ea extends _a.Readable{constructor(e,t,r,n,i,o){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:t,predicate:r,object:n,graph:i,options:o})}get filtered(){if(!this._filtered){const{n3Store:e,graph:t,object:r,predicate:n,subject:i}=this,o=this._filtered=new ja({factory:e._factory,entityIndex:this.options.entityIndex});let a,s,c;if(i&&!(a=o._termToNumericId(i))||n&&!(s=o._termToNumericId(n))||r&&!(c=o._termToNumericId(r)))return o;const u=e._getGraphs(t);for(const e in u){let t,r,n,i;(i=u[e])&&(!a&&s?(r=Aa(i.predicates,[s,c,a]))&&(t=Aa(i.subjects,[a,s,c]),n=Aa(i.objects,[c,a,s])):c?(n=Aa(i.objects,[c,a,s]))&&(t=Aa(i.subjects,[a,s,c]),r=Aa(i.predicates,[s,c,a])):(t=Aa(i.subjects,[a,s,c]))&&(r=Aa(i.predicates,[s,c,a]),n=Aa(i.objects,[c,a,s])),t&&(o._graphs[e]={subjects:t,predicates:r,objects:n}))}o._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[wa]&&(this[wa]=this[Symbol.iterator]());const t=this[wa];for(;--e>=0;){const{done:e,value:r}=t.next();if(e)return void this.push(null);this.push(r)}}addAll(e){return this.filtered.addAll(e)}contains(e){return this.filtered.contains(e)}deleteMatches(e,t,r,n){return this.filtered.deleteMatches(e,t,r,n)}difference(e){return this.filtered.difference(e)}equals(e){return this.filtered.equals(e)}every(e,t,r,n,i){return this.filtered.every(e,t,r,n,i)}filter(e){return this.filtered.filter(e)}forEach(e,t,r,n,i){return this.filtered.forEach(e,t,r,n,i)}import(e){return this.filtered.import(e)}intersection(e){return this.filtered.intersection(e)}map(e){return this.filtered.map(e)}some(e,t,r,n,i){return this.filtered.some(e,t,r,n,i)}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,t){return this.filtered.reduce(e,t)}toString(){return(new he).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,t,r,n){return new Ea(this.filtered,e,t,r,n,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}}class Ia{dataset(e){return new ja(e)}}function Fa(e){const t=[];for(const{subject:r,object:n}of e.match(null,N.namedNode("http://www.w3.org/2000/10/swap/log#implies"),null,N.defaultGraph())){const i=[...e.match(null,null,null,r)],o=[...e.match(null,null,null,n)];t.push({premise:i,conclusion:o})}return t}class Da{constructor(e){this._store=e}_add(e,t,r,n,i){this._store._addToIndex(n.subjects,e,t,r)&&(this._store._addToIndex(n.predicates,t,r,e),this._store._addToIndex(n.objects,r,e,t),i())}_evaluatePremise(e,t,r,n=0){let i,o,a,s,c;const[u,l,d]=e.premise[n].value,p=t[e.premise[n].content],f=!(a=u.value);for(a in f?p:{[a]:p[a]})if(s=p[a]){for(a in f&&(u.value=Number(a)),i=!(a=l.value),i?s:{[a]:s[a]})if(c=s[a]){for(a in i&&(l.value=Number(a)),o=!(a=d.value),o?c:{[a]:c[a]})o&&(d.value=Number(a)),n===e.premise.length-1?e.conclusion.forEach(e=>{this._add(e.subject.value,e.predicate.value,e.object.value,t,()=>{r(e)})}):this._evaluatePremise(e,t,r,n+1);o&&(d.value=null)}i&&(l.value=null)}f&&(u.value=null)}_evaluateRules(e,t,r){for(let n=0;n{r.push([e.subject.value,e.predicate.value,e.object.value,t])})}const i=e=>{e.forEach(e=>{this._add(e.subject.value,e.predicate.value,e.object.value,t,()=>{n(e)})})};let o;for(this._evaluateRules(e,t,n);void 0!==(o=r.pop());){const[e,r,a,s]=o,c=s.basePremise.subject.value;c||(s.basePremise.subject.value=e);const u=s.basePremise.predicate.value;u||(s.basePremise.predicate.value=r);const l=s.basePremise.object.value;l||(s.basePremise.object.value=a),0===s.premise.length?i(s.conclusion):this._evaluatePremise(s,t,n),c||(s.basePremise.subject.value=null),u||(s.basePremise.predicate.value=null),l||(s.basePremise.object.value=null)}}_createRule({premise:e,conclusion:t}){const r={},n=e=>"Variable"===e.termType?r[e.value]=r[e.value]||{}:{value:this._store._termToNewNumericId(e)},i=e=>({subject:n(e.subject),predicate:n(e.predicate),object:n(e.object)});return{premise:e.map(e=>i(e)),conclusion:t.map(e=>i(e)),variables:Object.values(r)}}reason(e){Array.isArray(e)||(e=Fa(e)),e=e.map(e=>this._createRule(e));for(const t of e)for(const r of e)for(let e=0;e{e.value=null})}}for(const t of e){const e=new Set;t.premise=t.premise.map(t=>Na(t,e))}const t=this._store._getGraphs();for(const r in t)this._reasonGraphNaive(e,t[r]);this._store._size=null}}function Na({subject:e,predicate:t,object:r},n){const i=e.value||n.has(e)||(n.add(e),!1),o=t.value||n.has(t)||(n.add(t),!1),a=r.value||n.has(r)||(n.add(r),!1);return!i&&o?{content:"predicates",value:[t,r,e]}:a?{content:"objects",value:[r,e,t]}:{content:"subjects",value:[e,t,r]}}function Pa(e,t){return null===e.value&&(e.value=t.value),e.value===t.value}class Ra extends _a.Transform{constructor(e){super({decodeStrings:!0}),this._readableState.objectMode=!0;const t=new K(e);let r,n;const i={onQuad:(e,t)=>{e&&this.emit("error",e)||t&&this.push(t)},onPrefix:(e,t)=>{this.emit("prefix",e,t)}};e&&e.comments&&(i.onComment=e=>{this.emit("comment",e)}),t.parse({on:(e,t)=>{switch(e){case"data":r=t;break;case"end":n=t}}},i),this._transform=(e,t,n)=>{r(e),n()},this._flush=e=>{n(),e()}}import(e){return e.on("data",e=>{this.write(e)}),e.on("end",()=>{this.end()}),e.on("error",e=>{this.emit("error",e)}),this}}class Ma extends _a.Transform{constructor(e){super({encoding:"utf8",writableObjectMode:!0});const t=this._writer=new he({write:(e,t,r)=>{this.push(e),r&&r()},end:e=>{this.push(null),e&&e()}},e);this._transform=(e,r,n)=>{t.addQuad(e,n)},this._flush=e=>{t.end(e)}}import(e){return e.on("data",e=>{this.write(e)}),e.on("end",()=>{this.end()}),e.on("error",e=>{this.emit("error",e)}),e.on("prefix",(e,t)=>{this._writer.addPrefix(e,t)}),this}}var La={Lexer:A,Parser:K,Writer:he,Store:ja,StoreFactory:Ia,EntityIndex:xa,StreamParser:Ra,StreamWriter:Ma,Util:re,Reasoner:Da,BaseIRI:ae,DataFactory:N,Term:P,NamedNode:R,Literal:M,BlankNode:L,Variable:C,DefaultGraph:k,Quad:q,Triple:q,termFromId:B,termToId:U},Ca=Object.freeze({__proto__:null,BaseIRI:ae,BlankNode:L,DataFactory:N,DefaultGraph:k,EntityIndex:xa,Lexer:A,Literal:M,NamedNode:R,Parser:K,Quad:q,Reasoner:Da,Store:ja,StoreFactory:Ia,StreamParser:Ra,StreamWriter:Ma,Term:P,Triple:q,Util:re,Variable:C,Writer:he,default:La,getRulesFromDataset:Fa,termFromId:B,termToId:U}),ka={},Ba=class e{constructor(e,t=new Map,r=0){this.prefix=e,this._existing=t,this.counter=r}clone(){const{prefix:t,_existing:r,counter:n}=this;return new e(t,new Map(r),n)}getId(e){const t=e&&this._existing.get(e);if(t)return t;const r=this.prefix+this.counter;return this.counter++,e&&this._existing.set(e,r),r}hasId(e){return this._existing.has(e)}getOldIds(){return[...this._existing.keys()]}};!function(e){if(!e.setImmediate){var t,r,n,i,o,a=1,s={},c=!1,u=e.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(e);l=l&&l.setTimeout?l:e,"[object process]"==={}.toString.call(e.process)?t=function(e){process.nextTick(function(){p(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((n=new MessageChannel).port1.onmessage=function(e){p(e.data)},t=function(e){n.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(r=u.documentElement,t=function(e){var t=u.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):t=function(e){setTimeout(p,0,e)}:(i="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(i)&&p(+t.data.slice(i.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),t=function(t){e.postMessage(i+t,"*")}),l.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var r=new Array(arguments.length-1),n=0;nn)&&(s&&r>0&&a>e[r-1]||!s&&re[r+1])&&(n=a,i=r)}if(null===n)this.done=!0;else{const r=t.get(n)?i-1:i+1;e[i]=e[r],e[r]=n;for(const r of e)r>n&&t.set(r,!t.get(r))}return r}};
+/*!
+ * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
+ */
+/*!
+ * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
+ */
+const Qa="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",za="http://www.w3.org/2001/XMLSchema#string",Ga="NamedNode",Va="BlankNode",Xa="Literal",Ha="DefaultGraph",Ja={};(()=>{const e="(?:<([^:]+:[^>]*)>)",t="A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�_",r=t+"0-9-·̀-ͯ‿-⁀",n="(_:(?:["+t+"0-9])(?:(?:["+r+".])*(?:["+r+"]))?)",i="[ \\t]+",o="[ \\t]*",a="(?:"+e+"|"+n+")"+i,s=e+i,c="(?:"+e+"|"+n+"|"+('(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:'+("(?:\\^\\^"+e+")")+"|(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)))?)")+")"+o,u="(?:\\.|(?:(?:"+e+"|"+n+")"+o+"\\.))";Ja.eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,Ja.empty=new RegExp("^"+o+"$"),Ja.quad=new RegExp("^"+o+a+s+c+u+o+"$")})();var Wa=class e{static parse(e){const t=[],r={},n=e.split(Ja.eoln);let i=0;for(const e of n){if(i++,Ja.empty.test(e))continue;const n=e.match(Ja.quad);if(null===n)throw new Error("N-Quads parse error on line "+i+".");const o={subject:null,predicate:null,object:null,graph:null};if(void 0!==n[1]?o.subject={termType:Ga,value:n[1]}:o.subject={termType:Va,value:n[2]},o.predicate={termType:Ga,value:n[3]},void 0!==n[4]?o.object={termType:Ga,value:n[4]}:void 0!==n[5]?o.object={termType:Va,value:n[5]}:(o.object={termType:Xa,value:void 0,datatype:{termType:Ga}},void 0!==n[7]?o.object.datatype.value=n[7]:void 0!==n[8]?(o.object.datatype.value=Qa,o.object.language=n[8]):o.object.datatype.value=za,o.object.value=es(n[6])),void 0!==n[9]?o.graph={termType:Ga,value:n[9]}:void 0!==n[10]?o.graph={termType:Va,value:n[10]}:o.graph={termType:Ha,value:""},o.graph.value in r){let e=!0;const n=r[o.graph.value];for(const t of n)if(Ka(t,o)){e=!1;break}e&&(n.push(o),t.push(o))}else r[o.graph.value]=[o],t.push(o)}return t}static serialize(t){Array.isArray(t)||(t=e.legacyDatasetToQuads(t));const r=[];for(const n of t)r.push(e.serializeQuad(n));return r.sort().join("")}static serializeQuadComponents(e,t,r,n){let i="";return e.termType===Ga?i+=`<${e.value}>`:i+=`${e.value}`,i+=` <${t.value}> `,r.termType===Ga?i+=`<${r.value}>`:r.termType===Va?i+=r.value:(i+=`"${function(e){return e.replace(Ya,function(e){switch(e){case'"':return'\\"';case"\\":return"\\\\";case"\n":return"\\n";case"\r":return"\\r"}})}(r.value)}"`,r.datatype.value===Qa?r.language&&(i+=`@${r.language}`):r.datatype.value!==za&&(i+=`^^<${r.datatype.value}>`)),n.termType===Ga?i+=` <${n.value}>`:n.termType===Va&&(i+=` ${n.value}`),i+=" .\n",i}static serializeQuad(t){return e.serializeQuadComponents(t.subject,t.predicate,t.object,t.graph)}static legacyDatasetToQuads(e){const t=[],r={"blank node":Va,IRI:Ga,literal:Xa};for(const n in e){e[n].forEach(e=>{const i={};for(const t in e){const n=e[t],o={termType:r[n.type],value:n.value};o.termType===Xa&&(o.datatype={termType:Ga},"datatype"in n&&(o.datatype.value=n.datatype),"language"in n?("datatype"in n||(o.datatype.value=Qa),o.language=n.language):"datatype"in n||(o.datatype.value=za)),i[t]=o}i.graph="@default"===n?{termType:Ha,value:""}:{termType:n.startsWith("_:")?Va:Ga,value:n},t.push(i)})}return t}};function Ka(e,t){return e.subject.termType===t.subject.termType&&e.object.termType===t.object.termType&&(e.subject.value===t.subject.value&&e.predicate.value===t.predicate.value&&e.object.value===t.object.value&&(e.object.termType!==Xa||e.object.datatype.termType===t.object.datatype.termType&&e.object.language===t.object.language&&e.object.datatype.value===t.object.datatype.value))}const Ya=/["\\\n\r]/g;const Za=/(?:\\([tbnrf"'\\]))|(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function es(e){return e.replace(Za,function(e,t,r,n){if(t)switch(t){case"t":return"\t";case"b":return"\b";case"n":return"\n";case"r":return"\r";case"f":return"\f";case'"':return'"';case"'":return"'";case"\\":return"\\"}if(r)return String.fromCharCode(parseInt(r,16));if(n)throw new Error("Unsupported U escape")})}
+/*!
+ * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
+ */const ts=Ba,rs=$a,ns=qa,is=Wa;var os=class{constructor({createMessageDigest:e=()=>new rs("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:r=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new ts("_:c14n",t),this.createMessageDigest=e,this.maxDeepIterations=r,this.quads=null,this.deepIterations=null}async main(e){this.deepIterations=new Map,this.quads=e;for(const t of e)this._addBlankNodeQuadInfo({quad:t,component:t.subject}),this._addBlankNodeQuadInfo({quad:t,component:t.object}),this._addBlankNodeQuadInfo({quad:t,component:t.graph});const t=new Map,r=[...this.blankNodeInfo.keys()];let n=0;for(const e of r)++n%100==0&&await this._yield(),await this._hashAndTrackBlankNode({id:e,hashToBlankNodes:t});const i=[...t.keys()].sort(),o=[];for(const e of i){const r=t.get(e);if(r.length>1){o.push(r);continue}const n=r[0];this.canonicalIssuer.getId(n)}for(const e of o){const t=[];for(const r of e){if(this.canonicalIssuer.hasId(r))continue;const e=new ts("_:b");e.getId(r);const n=await this.hashNDegreeQuads(r,e);t.push(n)}t.sort(as);for(const e of t){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const a=[];for(const e of this.quads){const t=is.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));a.push(t)}return a.sort(),a.join("")}async hashFirstDegreeQuads(e){const t=[],r=this.blankNodeInfo.get(e),n=r.quads;for(const r of n){const n={subject:null,predicate:r.predicate,object:null,graph:null};n.subject=this.modifyFirstDegreeComponent(e,r.subject,"subject"),n.object=this.modifyFirstDegreeComponent(e,r.object,"object"),n.graph=this.modifyFirstDegreeComponent(e,r.graph,"graph"),t.push(is.serializeQuad(n))}t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return r.hash=await i.digest(),r.hash}async hashRelatedBlankNode(e,t,r,n){let i;i=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):r.hasId(e)?r.getId(e):this.blankNodeInfo.get(e).hash;const o=this.createMessageDigest();return o.update(n),"g"!==n&&o.update(this.getRelatedPredicate(t)),o.update(i),o.digest()}async hashNDegreeQuads(e,t){const r=this.deepIterations.get(e)||0;if(r>this.maxDeepIterations)throw new Error(`Maximum deep iterations (${this.maxDeepIterations}) exceeded.`);this.deepIterations.set(e,r+1);const n=this.createMessageDigest(),i=await this.createHashToRelated(e,t),o=[...i.keys()].sort();for(const e of o){n.update(e);let r,o="";const a=new ns(i.get(e));let s=0;for(;a.hasNext();){const e=a.next();++s%3==0&&await this._yield();let n=t.clone(),i="";const c=[];let u=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?i+=this.canonicalIssuer.getId(t):(n.hasId(t)||c.push(t),i+=n.getId(t)),0!==o.length&&i>o){u=!0;break}if(!u){for(const e of c){const t=await this.hashNDegreeQuads(e,n);if(i+=n.getId(e),i+=`<${t.hash}>`,n=t.issuer,0!==o.length&&i>o){u=!0;break}}u||(0===o.length||i`}async createHashToRelated(e,t){const r=new Map,n=this.blankNodeInfo.get(e).quads;let i=0;for(const o of n)++i%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:o,component:o.subject,position:"s",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:o,component:o.object,position:"o",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:o,component:o.graph,position:"g",id:e,issuer:t,hashToRelated:r})]);return r}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const r=await this.hashFirstDegreeQuads(e),n=t.get(r);n?n.push(e):t.set(r,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const r=t.value,n=this.blankNodeInfo.get(r);n?n.quads.add(e):this.blankNodeInfo.set(r,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:r,id:n,issuer:i,hashToRelated:o}){if("BlankNode"!==t.termType||t.value===n)return;const a=t.value,s=await this.hashRelatedBlankNode(a,e,i,r),c=o.get(s);c?c.push(a):o.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise(e=>setImmediate(e))}};function as(e,t){return e.hasht.hash?1:0}
+/*!
+ * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
+ */const ss=$a,cs=os;var us=class extends cs{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new ss("sha1")}modifyFirstDegreeComponent(e,t,r){return"BlankNode"!==t.termType?t:"graph"===r?{termType:"BlankNode",value:"_:g"}:{termType:"BlankNode",value:t.value===e?"_:a":"_:z"}}getRelatedPredicate(e){return e.predicate.value}async createHashToRelated(e,t){const r=new Map,n=this.blankNodeInfo.get(e).quads;let i=0;for(const o of n){let n,a;if("BlankNode"===o.subject.termType&&o.subject.value!==e)a=o.subject.value,n="p";else{if("BlankNode"!==o.object.termType||o.object.value===e)continue;a=o.object.value,n="r"}++i%100==0&&await this._yield();const s=await this.hashRelatedBlankNode(a,o,t,n),c=r.get(s);c?c.push(a):r.set(s,[a])}return r}};
+/*!
+ * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
+ */const ls=Ba,ds=$a,ps=qa,fs=Wa;var hs=class{constructor({createMessageDigest:e=()=>new ds("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:r=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new ls("_:c14n",t),this.createMessageDigest=e,this.maxDeepIterations=r,this.quads=null,this.deepIterations=null}main(e){this.deepIterations=new Map,this.quads=e;for(const t of e)this._addBlankNodeQuadInfo({quad:t,component:t.subject}),this._addBlankNodeQuadInfo({quad:t,component:t.object}),this._addBlankNodeQuadInfo({quad:t,component:t.graph});const t=new Map,r=[...this.blankNodeInfo.keys()];for(const e of r)this._hashAndTrackBlankNode({id:e,hashToBlankNodes:t});const n=[...t.keys()].sort(),i=[];for(const e of n){const r=t.get(e);if(r.length>1){i.push(r);continue}const n=r[0];this.canonicalIssuer.getId(n)}for(const e of i){const t=[];for(const r of e){if(this.canonicalIssuer.hasId(r))continue;const e=new ls("_:b");e.getId(r);const n=this.hashNDegreeQuads(r,e);t.push(n)}t.sort(ys);for(const e of t){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const o=[];for(const e of this.quads){const t=fs.serializeQuadComponents(this._componentWithCanonicalId({component:e.subject}),e.predicate,this._componentWithCanonicalId({component:e.object}),this._componentWithCanonicalId({component:e.graph}));o.push(t)}return o.sort(),o.join("")}hashFirstDegreeQuads(e){const t=[],r=this.blankNodeInfo.get(e),n=r.quads;for(const r of n){const n={subject:null,predicate:r.predicate,object:null,graph:null};n.subject=this.modifyFirstDegreeComponent(e,r.subject,"subject"),n.object=this.modifyFirstDegreeComponent(e,r.object,"object"),n.graph=this.modifyFirstDegreeComponent(e,r.graph,"graph"),t.push(fs.serializeQuad(n))}t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return r.hash=i.digest(),r.hash}hashRelatedBlankNode(e,t,r,n){let i;i=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):r.hasId(e)?r.getId(e):this.blankNodeInfo.get(e).hash;const o=this.createMessageDigest();return o.update(n),"g"!==n&&o.update(this.getRelatedPredicate(t)),o.update(i),o.digest()}hashNDegreeQuads(e,t){const r=this.deepIterations.get(e)||0;if(r>this.maxDeepIterations)throw new Error(`Maximum deep iterations (${this.maxDeepIterations}) exceeded.`);this.deepIterations.set(e,r+1);const n=this.createMessageDigest(),i=this.createHashToRelated(e,t),o=[...i.keys()].sort();for(const e of o){n.update(e);let r,o="";const a=new ps(i.get(e));for(;a.hasNext();){const e=a.next();let n=t.clone(),i="";const s=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?i+=this.canonicalIssuer.getId(t):(n.hasId(t)||s.push(t),i+=n.getId(t)),0!==o.length&&i>o){c=!0;break}if(!c){for(const e of s){const t=this.hashNDegreeQuads(e,n);if(i+=n.getId(e),i+=`<${t.hash}>`,n=t.issuer,0!==o.length&&i>o){c=!0;break}}c||(0===o.length||i`}createHashToRelated(e,t){const r=new Map,n=this.blankNodeInfo.get(e).quads;for(const i of n)this._addRelatedBlankNodeHash({quad:i,component:i.subject,position:"s",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:i,component:i.object,position:"o",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:i,component:i.graph,position:"g",id:e,issuer:t,hashToRelated:r});return r}_hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const r=this.hashFirstDegreeQuads(e),n=t.get(r);n?n.push(e):t.set(r,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const r=t.value,n=this.blankNodeInfo.get(r);n?n.quads.add(e):this.blankNodeInfo.set(r,{quads:new Set([e]),hash:null})}_addRelatedBlankNodeHash({quad:e,component:t,position:r,id:n,issuer:i,hashToRelated:o}){if("BlankNode"!==t.termType||t.value===n)return;const a=t.value,s=this.hashRelatedBlankNode(a,e,i,r),c=o.get(s);c?c.push(a):o.set(s,[a])}_componentWithCanonicalId({component:e}){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}};function ys(e,t){return e.hasht.hash?1:0}
+/*!
+ * Copyright (c) 2016-2021 Digital Bazaar, Inc. All rights reserved.
+ */const gs=$a,ms=hs;var bs=class extends ms{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new gs("sha1")}modifyFirstDegreeComponent(e,t,r){return"BlankNode"!==t.termType?t:"graph"===r?{termType:"BlankNode",value:"_:g"}:{termType:"BlankNode",value:t.value===e?"_:a":"_:z"}}getRelatedPredicate(e){return e.predicate.value}createHashToRelated(e,t){const r=new Map,n=this.blankNodeInfo.get(e).quads;for(const i of n){let n,o;if("BlankNode"===i.subject.termType&&i.subject.value!==e)o=i.subject.value,n="p";else{if("BlankNode"!==i.object.termType||i.object.value===e)continue;o=i.object.value,n="r"}const a=this.hashRelatedBlankNode(o,i,t,n),s=r.get(a);s?s.push(o):r.set(a,[o])}return r}},vs=o(Object.freeze({__proto__:null,default:{}}));!function(e){const t=os,r=us,n=hs,i=bs;let o;try{o=vs}catch(e){}function a(t){return Array.isArray(t)?t:e.NQuads.legacyDatasetToQuads(t)}e.NQuads=Wa,e.IdentifierIssuer=Ba,e._rdfCanonizeNative=function(e){return e&&(o=e),o},e.canonize=async function(e,n){const i=a(e);if(n.useNative){if(!o)throw new Error("rdf-canonize-native not available");if(n.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return new Promise((e,t)=>o.canonize(i,n,(r,n)=>r?t(r):e(n)))}if("URDNA2015"===n.algorithm)return new t(n).main(i);if("URGNA2012"===n.algorithm){if(n.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "URGNA2012".');return new r(n).main(i)}if(!("algorithm"in n))throw new Error("No RDF Dataset Canonicalization algorithm specified.");throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+n.algorithm)},e._canonizeSync=function(e,t){const r=a(e);if(t.useNative){if(!o)throw new Error("rdf-canonize-native not available");if(t.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return o.canonizeSync(r,t)}if("URDNA2015"===t.algorithm)return new n(t).main(r);if("URGNA2012"===t.algorithm){if(t.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "URGNA2012".');return new i(t).main(r)}if(!("algorithm"in t))throw new Error("No RDF Dataset Canonicalization algorithm specified.");throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+t.algorithm)}}(ka);var _s=ka;const ws={};var Ts=ws;ws.isArray=Array.isArray,ws.isBoolean=e=>"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e),ws.isDouble=e=>ws.isNumber(e)&&(-1!==String(e).indexOf(".")||Math.abs(e)>=1e21),ws.isEmptyObject=e=>ws.isObject(e)&&0===Object.keys(e).length,ws.isNumber=e=>"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e),ws.isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),ws.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),ws.isString=e=>"string"==typeof e||"[object String]"===Object.prototype.toString.call(e),ws.isUndefined=e=>void 0===e;const Os=Ts,Ss={};var xs=Ss;Ss.isSubject=e=>{if(Os.isObject(e)&&!("@value"in e||"@set"in e||"@list"in e)){return Object.keys(e).length>1||!("@id"in e)}return!1},Ss.isSubjectReference=e=>Os.isObject(e)&&1===Object.keys(e).length&&"@id"in e,Ss.isValue=e=>Os.isObject(e)&&"@value"in e,Ss.isList=e=>Os.isObject(e)&&"@list"in e,Ss.isGraph=e=>Os.isObject(e)&&"@graph"in e&&1===Object.keys(e).filter(e=>"@id"!==e&&"@index"!==e).length,Ss.isSimpleGraph=e=>Ss.isGraph(e)&&!("@id"in e),Ss.isBlankNode=e=>{if(Os.isObject(e)){if("@id"in e){const t=e["@id"];return!Os.isString(t)||0===t.indexOf("_:")}return 0===Object.keys(e).length||!("@value"in e||"@set"in e||"@list"in e)}return!1};var js=class extends Error{constructor(e="An unspecified JSON-LD error occurred.",t="jsonld.Error",r={}){super(e),this.name=t,this.message=e,this.details=r}};const As=xs,Es=Ts,Is=_s.IdentifierIssuer,Fs=js,Ds=/(?:<[^>]*?>|"[^"]*?"|[^,])+/g,Ns=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,Ps=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g,Rs={accept:"application/ld+json, application/json"},Ms={};var Ls=Ms;function Cs(e,t){if(Es.isArray(t))for(let r=0;r{if(Object.keys(e).some(e=>"accept"===e.toLowerCase()))throw new RangeError('Accept header may not be specified; only "'+Rs.accept+'" is supported.');return Object.assign({Accept:Rs.accept},e)},Ms.parseLinkHeader=e=>{const t={},r=e.match(Ds);for(let e=0;e{if(!(Es.isString(e)||Es.isArray(e)&&e.every(e=>Es.isString(e)))){if(t&&Es.isObject(e))switch(Object.keys(e).length){case 0:return;case 1:if("@default"in e&&Ms.asArray(e["@default"]).every(e=>Es.isString(e)))return}throw new Fs('Invalid JSON-LD syntax; "@type" value must a string, an array of strings, an empty object, or a default object.',"jsonld.SyntaxError",{code:"invalid type value",value:e})}},Ms.hasProperty=(e,t)=>{if(e.hasOwnProperty(t)){const r=e[t];return!Es.isArray(r)||r.length>0}return!1},Ms.hasValue=(e,t,r)=>{if(Ms.hasProperty(e,t)){let n=e[t];const i=As.isList(n);if(Es.isArray(n)||i){i&&(n=n["@list"]);for(let e=0;e{if("propertyIsArray"in(n=n||{})||(n.propertyIsArray=!1),"valueIsArray"in n||(n.valueIsArray=!1),"allowDuplicate"in n||(n.allowDuplicate=!0),"prependValue"in n||(n.prependValue=!1),n.valueIsArray)e[t]=r;else if(Es.isArray(r)){0===r.length&&n.propertyIsArray&&!e.hasOwnProperty(t)&&(e[t]=[]),n.prependValue&&(r=r.concat(e[t]),e[t]=[]);for(let i=0;i[].concat(e[t]||[]),Ms.removeProperty=(e,t)=>{delete e[t]},Ms.removeValue=(e,t,r,n)=>{"propertyIsArray"in(n=n||{})||(n.propertyIsArray=!1);const i=Ms.getValues(e,t).filter(e=>!Ms.compareValues(e,r));0===i.length?Ms.removeProperty(e,t):1!==i.length||n.propertyIsArray?e[t]=i:e[t]=i[0]},Ms.relabelBlankNodes=(e,t)=>Cs((t=t||{}).issuer||new Is("_:b"),e),Ms.compareValues=(e,t)=>e===t||(!(!As.isValue(e)||!As.isValue(t)||e["@value"]!==t["@value"]||e["@type"]!==t["@type"]||e["@language"]!==t["@language"]||e["@index"]!==t["@index"])||!!(Es.isObject(e)&&"@id"in e&&Es.isObject(t)&&"@id"in t)&&e["@id"]===t["@id"]),Ms.compareShortestLeast=(e,t)=>e.length{const n={},i=t.parsers[r||"full"],o=i.regex.exec(e);let a=i.keys.length;for(;a--;)n[i.keys[a]]=void 0===o[a]?null:o[a];return("https"===n.scheme&&"443"===n.port||"http"===n.scheme&&"80"===n.port)&&(n.href=n.href.replace(":"+n.port,""),n.authority=n.authority.replace(":"+n.port,""),n.port=null),n.normalizedPath=t.removeDotSegments(n.path),n},t.prependBase=(r,n)=>{if(null===r)return n;if(t.isAbsolute(n))return n;r&&!e.isString(r)||(r=t.parse(r||""));const i=t.parse(n),o={protocol:r.protocol||""};if(null!==i.authority)o.authority=i.authority,o.path=i.path,o.query=i.query;else if(o.authority=r.authority,""===i.path)o.path=r.path,null!==i.query?o.query=i.query:o.query=r.query;else{if(0===i.path.indexOf("/"))o.path=i.path;else{let e=r.path;e=e.substr(0,e.lastIndexOf("/")+1),(e.length>0||r.authority)&&"/"!==e.substr(-1)&&(e+="/"),e+=i.path,o.path=e}o.query=i.query}""!==i.path&&(o.path=t.removeDotSegments(o.path));let a=o.protocol;return null!==o.authority&&(a+="//"+o.authority),a+=o.path,null!==o.query&&(a+="?"+o.query),null!==i.fragment&&(a+="#"+i.fragment),""===a&&(a="./"),a},t.removeBase=(r,n)=>{if(null===r)return n;r&&!e.isString(r)||(r=t.parse(r||""));let i="";if(""!==r.href?i+=(r.protocol||"")+"//"+(r.authority||""):n.indexOf("//")&&(i+="//"),0!==n.indexOf(i))return n;const o=t.parse(n.substr(i.length)),a=r.normalizedPath.split("/"),s=o.normalizedPath.split("/"),c=o.fragment||o.query?0:1;for(;a.length>0&&s.length>c&&a[0]===s[0];)a.shift(),s.shift();let u="";if(a.length>0){a.pop();for(let e=0;e{if(0===e.length)return"";const t=e.split("/"),r=[];for(;t.length>0;){const e=t.shift(),n=0===t.length;"."!==e?".."!==e?r.push(e):(r.pop(),n&&r.push("")):n&&r.push("")}return"/"===e[0]&&r.length>0&&""!==r[0]&&r.unshift(""),1===r.length&&""===r[0]?"/":r.join("/")};const r=/^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/;return t.isAbsolute=t=>e.isString(t)&&r.test(t),t.isRelative=t=>e.isString(t),qs}const{parseLinkHeader:Xs,buildHeaders:Hs}=Ls,{LINK_HEADER_CONTEXT:Js}=zs,Ws=js,Ks=Gs(),{prependBase:Ys}=Vs(),Zs=/(^|(\r\n))link:/i;const ec=({secure:e,headers:t={},xhr:r}={headers:{}})=>{t=Hs(t);return(new Ks).wrapLoader(async function n(i){if(0!==i.indexOf("http:")&&0!==i.indexOf("https:"))throw new Ws('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:i});if(e&&0!==i.indexOf("https"))throw new Ws('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:i});let o;try{o=await function(e,t,r){e=e||XMLHttpRequest;const n=new e;return new Promise((e,i)=>{n.onload=()=>e(n),n.onerror=e=>i(e),n.open("GET",t,!0);for(const e in r)n.setRequestHeader(e,r[e]);n.send()})}(r,i,t)}catch(e){throw new Ws("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:i,cause:e})}if(o.status>=400)throw new Ws("URL could not be dereferenced: "+o.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:i,httpStatusCode:o.status});let a={contextUrl:null,documentUrl:i,document:o.response},s=null;const c=o.getResponseHeader("Content-Type");let u;Zs.test(o.getAllResponseHeaders())&&(u=o.getResponseHeader("Link"));if(u&&"application/ld+json"!==c){const e=Xs(u),t=e[Js];if(Array.isArray(t))throw new Ws("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:i});t&&(a.contextUrl=t.target),s=e.alternate,s&&"application/ld+json"==s.type&&!(c||"").match(/^application\/(\w*\+)?json$/)&&(a=await n(Ys(i,s.target)))}return a})},tc={};var rc,nc,ic=tc;tc.setupDocumentLoaders=function(e){"undefined"!=typeof XMLHttpRequest&&(e.documentLoaders.xhr=ec,e.useDocumentLoader("xhr"))},tc.setupGlobals=function(e){void 0===globalThis.JsonLdProcessor&&Object.defineProperty(globalThis,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:e.JsonLdProcessor})};var oc=ac;function ac(e){var t=this;if(t instanceof ac||(t=new ac),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach(function(e){t.push(e)});else if(arguments.length>0)for(var r=0,n=arguments.length;r1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=e(r,n.value,i),n=n.next;return r},ac.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=e(r,n.value,i),n=n.prev;return r},ac.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},ac.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},ac.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new ac;if(tthis.length&&(t=this.length);for(var n=0,i=this.head;null!==i&&nthis.length&&(t=this.length);for(var n=this.length,i=this.tail;null!==i&&n>t;n--)i=i.prev;for(;null!==i&&n>e;n--,i=i.prev)r.push(i.value);return r},ac.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,i=this.head;null!==i&&n1;const Oc=(e,t,r)=>{const n=e[_c].get(t);if(n){const t=n.value;if(Sc(e,t)){if(jc(e,n),!e[yc])return}else r&&(e[wc]&&(n.value.now=Date.now()),e[vc].unshiftNode(n));return t.value}},Sc=(e,t)=>{if(!t||!t.maxAge&&!e[gc])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[gc]&&r>e[gc]},xc=e=>{if(e[fc]>e[pc])for(let t=e[vc].tail;e[fc]>e[pc]&&null!==t;){const r=t.prev;jc(e,t),t=r}},jc=(e,t)=>{if(t){const r=t.value;e[mc]&&e[mc](r.key,r.value),e[fc]-=r.length,e[_c].delete(r.key),e[vc].removeNode(t)}};class Ac{constructor(e,t,r,n,i){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=i||0}}const Ec=(e,t,r,n)=>{let i=r.value;Sc(e,i)&&(jc(e,r),e[yc]||(i=void 0)),i&&t.call(n,i.value,i.key,e)};var Ic=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[pc]=e.max||1/0;const t=e.length||Tc;if(this[hc]="function"!=typeof t?Tc:t,this[yc]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[gc]=e.maxAge||0,this[mc]=e.dispose,this[bc]=e.noDisposeOnSet||!1,this[wc]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[pc]=e||1/0,xc(this)}get max(){return this[pc]}set allowStale(e){this[yc]=!!e}get allowStale(){return this[yc]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[gc]=e,xc(this)}get maxAge(){return this[gc]}set lengthCalculator(e){"function"!=typeof e&&(e=Tc),e!==this[hc]&&(this[hc]=e,this[fc]=0,this[vc].forEach(e=>{e.length=this[hc](e.value,e.key),this[fc]+=e.length})),xc(this)}get lengthCalculator(){return this[hc]}get length(){return this[fc]}get itemCount(){return this[vc].length}rforEach(e,t){t=t||this;for(let r=this[vc].tail;null!==r;){const n=r.prev;Ec(this,e,r,t),r=n}}forEach(e,t){t=t||this;for(let r=this[vc].head;null!==r;){const n=r.next;Ec(this,e,r,t),r=n}}keys(){return this[vc].toArray().map(e=>e.key)}values(){return this[vc].toArray().map(e=>e.value)}reset(){this[mc]&&this[vc]&&this[vc].length&&this[vc].forEach(e=>this[mc](e.key,e.value)),this[_c]=new Map,this[vc]=new dc,this[fc]=0}dump(){return this[vc].map(e=>!Sc(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[vc]}set(e,t,r){if((r=r||this[gc])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,i=this[hc](t,e);if(this[_c].has(e)){if(i>this[pc])return jc(this,this[_c].get(e)),!1;const o=this[_c].get(e).value;return this[mc]&&(this[bc]||this[mc](e,o.value)),o.now=n,o.maxAge=r,o.value=t,this[fc]+=i-o.length,o.length=i,this.get(e),xc(this),!0}const o=new Ac(e,t,i,n,r);return o.length>this[pc]?(this[mc]&&this[mc](e,t),!1):(this[fc]+=o.length,this[vc].unshift(o),this[_c].set(e,this[vc].head),xc(this),!0)}has(e){if(!this[_c].has(e))return!1;const t=this[_c].get(e).value;return!Sc(this,t)}get(e){return Oc(this,e,!0)}peek(e){return Oc(this,e,!1)}pop(){const e=this[vc].tail;return e?(jc(this,e),e.value):null}del(e){jc(this,this[_c].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const n=e[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{const e=i-t;e>0&&this.set(n.k,n.v,e)}}}prune(){this[_c].forEach((e,t)=>Oc(this,t,!1))}};const Fc=Ic;const{isArray:Dc,isObject:Nc,isString:Pc}=Ts,{asArray:Rc}=Ls,{prependBase:Mc}=Vs(),Lc=js,Cc=class{constructor({document:e}){this.document=e,this.cache=new Fc({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}};function kc(e){throw new Lc("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function Bc({context:e,base:t}){if(!e)return;const r=e["@context"];if(Pc(r))e["@context"]=Mc(t,r);else if(Dc(r))for(let e=0;e{r=!0}});else{if("object"!=typeof i)throw new $c("Invalid event handler.","jsonld.InvalidEventHandler",{event:e});e.code in i?i[e.code]({event:e,next:()=>{r=!0}}):r=!0}}return r}zc.defaultEventHandler=null,zc.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?zc.safeEventHandler:[],e.eventHandler?Qc(e.eventHandler):[],zc.defaultEventHandler?zc.defaultEventHandler:[]);return 0===t.length?null:t},zc.handleEvent=({event:e,options:t})=>{Vc({event:e,handlers:t.eventHandler})};const Xc=new Set(["empty object","free-floating scalar","invalid @language value","invalid property","null @id value","null @value value","object with only @id","object with only @language","object with only @list","object with only @value","relative @id reference","relative @type reference","relative @vocab reference","reserved @id value","reserved @reverse value","reserved term","blank node predicate","relative graph reference","relative object reference","relative predicate reference","relative subject reference","rdfDirection not set"]);zc.safeEventHandler=function({event:e,next:t}){if("warning"===e.level&&Xc.has(e.code))throw new $c("Safe mode validation error.","jsonld.ValidationError",{event:e});t()},zc.logEventHandler=function({event:e,next:t}){console.log(`EVENT: ${e.message}`,{event:e}),t()},zc.logWarningEventHandler=function({event:e,next:t}){"warning"===e.level&&console.warn(`WARNING: ${e.message}`,{event:e}),t()},zc.unhandledEventHandler=function({event:e}){throw new $c("No handler for event.","jsonld.UnhandledEvent",{event:e})},zc.setDefaultEventHandler=function({eventHandler:e}={}){zc.defaultEventHandler=e?Qc(e):null};const Hc=Ls,Jc=js,{isArray:Wc,isObject:Kc,isString:Yc,isUndefined:Zc}=Ts,{isAbsolute:eu,isRelative:tu,prependBase:ru}=Vs(),{handleEvent:nu}=Gc,{REGEX_BCP47:iu,REGEX_KEYWORD:ou,asArray:au,compareShortestLeast:su}=Ls,cu=new Map,uu={};var lu=uu;function du(e,t,r,n,i,o){if(null===t||!Yc(t)||uu.isKeyword(t))return t;if(t.match(ou))return null;if(n&&n.hasOwnProperty(t)&&!0!==i.get(t)&&uu.createTermDefinition({activeCtx:e,localCtx:n,term:t,defined:i,options:o}),(r=r||{}).vocab){const r=e.mappings.get(t);if(null===r)return null;if(Kc(r)&&"@id"in r)return r["@id"]}const a=t.indexOf(":");if(a>0){const r=t.substr(0,a),s=t.substr(a+1);if("_"===r||0===s.indexOf("//"))return t;n&&n.hasOwnProperty(r)&&uu.createTermDefinition({activeCtx:e,localCtx:n,term:r,defined:i,options:o});const c=e.mappings.get(r);if(c&&c._prefix)return c["@id"]+s;if(eu(t))return t}if(r.vocab&&"@vocab"in e){t=e["@vocab"]+t}else if(r.base){let r,n;"@base"in e?e["@base"]?(n=ru(o.base,e["@base"]),r=ru(n,t)):(n=e["@base"],r=t):(n=o.base,r=ru(o.base,t)),t=r}return t}function pu(e,t){if(!e||"object"!=typeof e||!t||"object"!=typeof t)return e===t;const r=Array.isArray(e);if(r!==Array.isArray(t))return!1;if(r){if(e.length!==t.length)return!1;for(let r=0;r{Kc(t)&&"@context"in t&&Wc(t["@context"])&&(t=t["@context"]);if(0===au(t).length)return e;const a=[],s=[({event:e,next:t})=>{a.push(e),t()}];r.eventHandler&&s.push(r.eventHandler);const c=r;r={...r,eventHandler:s};const u=await r.contextResolver.resolve({activeCtx:e,context:t,documentLoader:r.documentLoader,base:r.base});Kc(u[0].document)&&"boolean"==typeof u[0].document["@propagate"]&&(n=u[0].document["@propagate"]);let l=e;n||l.previousContext||(l=l.clone(),l.previousContext=e);for(const n of u){let{document:s}=n;if(e=l,null===s){if(!i&&0!==Object.keys(e.protected).length)throw new Jc("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});l=e=uu.getInitialContext(r).clone();continue}const u=n.getProcessed(e);if(u){if(c.eventHandler)for(const e of u.events)nu({event:e,options:c});l=e=u.context;continue}if(Kc(s)&&"@context"in s&&(s=s["@context"]),!Kc(s))throw new Jc("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:s});l=l.clone();const d=new Map;if("@version"in s){if(1.1!==s["@version"])throw new Jc("Unsupported JSON-LD version: "+s["@version"],"jsonld.UnsupportedVersion",{code:"invalid @version value",context:s});if(e.processingMode&&"json-ld-1.0"===e.processingMode)throw new Jc("@version: "+s["@version"]+" not compatible with "+e.processingMode,"jsonld.ProcessingModeConflict",{code:"processing mode conflict",context:s});l.processingMode="json-ld-1.1",l["@version"]=s["@version"],d.set("@version",!0)}if(l.processingMode=l.processingMode||e.processingMode,"@base"in s){let e=s["@base"];if(null===e||eu(e));else{if(!tu(e))throw new Jc('Invalid JSON-LD syntax; the value of "@base" in a @context must be an absolute IRI, a relative IRI, or null.',"jsonld.SyntaxError",{code:"invalid base IRI",context:s});e=ru(l["@base"],e)}l["@base"]=e,d.set("@base",!0)}if("@vocab"in s){const e=s["@vocab"];if(null===e)delete l["@vocab"];else{if(!Yc(e))throw new Jc('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:s});if(!eu(e)&&uu.processingMode(l,1))throw new Jc('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:s});{const t=du(l,e,{vocab:!0,base:!0},void 0,void 0,r);eu(t)||r.eventHandler&&nu({event:{type:["JsonLdEvent"],code:"relative @vocab reference",level:"warning",message:"Relative @vocab reference found.",details:{vocab:t}},options:r}),l["@vocab"]=t}}d.set("@vocab",!0)}if("@language"in s){const e=s["@language"];if(null===e)delete l["@language"];else{if(!Yc(e))throw new Jc('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:s});e.match(iu)||r.eventHandler&&nu({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:r}),l["@language"]=e.toLowerCase()}d.set("@language",!0)}if("@direction"in s){const t=s["@direction"];if("json-ld-1.0"===e.processingMode)throw new Jc("Invalid JSON-LD syntax; @direction not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context member",context:s});if(null===t)delete l["@direction"];else{if("ltr"!==t&&"rtl"!==t)throw new Jc('Invalid JSON-LD syntax; the value of "@direction" in a @context must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:s});l["@direction"]=t}d.set("@direction",!0)}if("@propagate"in s){const r=s["@propagate"];if("json-ld-1.0"===e.processingMode)throw new Jc("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if("boolean"!=typeof r)throw new Jc("Invalid JSON-LD syntax; @propagate value must be a boolean.","jsonld.SyntaxError",{code:"invalid @propagate value",context:t});d.set("@propagate",!0)}if("@import"in s){const n=s["@import"];if("json-ld-1.0"===e.processingMode)throw new Jc("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if(!Yc(n))throw new Jc("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:t});const i=await r.contextResolver.resolve({activeCtx:e,context:n,documentLoader:r.documentLoader,base:r.base});if(1!==i.length)throw new Jc("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:t});const o=i[0].getProcessed(e);if(o)s=o;else{const r=i[0].document;if("@import"in r)throw new Jc("Invalid JSON-LD syntax: imported context must not include @import.","jsonld.SyntaxError",{code:"invalid context entry",context:t});for(const e in r)s.hasOwnProperty(e)||(s[e]=r[e]);i[0].setProcessed(e,s)}d.set("@import",!0)}d.set("@protected",s["@protected"]||!1);for(const e in s)if(uu.createTermDefinition({activeCtx:l,localCtx:s,term:e,defined:d,options:r,overrideProtected:i}),Kc(s[e])&&"@context"in s[e]){const t=s[e]["@context"];let n=!0;if(Yc(t)){const e=ru(r.base,t);o.has(e)?n=!1:o.add(e)}if(n)try{await uu.process({activeCtx:l.clone(),localCtx:s[e]["@context"],overrideProtected:!0,options:r,cycles:o})}catch(t){throw new Jc("Invalid JSON-LD syntax; invalid scoped context.","jsonld.SyntaxError",{code:"invalid scoped context",context:s[e]["@context"],term:e})}}n.setProcessed(e,{context:l,events:a})}return l},uu.createTermDefinition=({activeCtx:e,localCtx:t,term:r,defined:n,options:i,overrideProtected:o=!1})=>{if(n.has(r)){if(n.get(r))return;throw new Jc("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:r})}let a;if(n.set(r,!1),t.hasOwnProperty(r)&&(a=t[r]),"@type"===r&&Kc(a)&&"@set"===(a["@container"]||"@set")&&uu.processingMode(e,1.1)){const e=["@container","@id","@protected"],n=Object.keys(a);if(0===n.length||n.some(t=>!e.includes(t)))throw new Jc("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:r})}else{if(uu.isKeyword(r))throw new Jc("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:r});if(r.match(ou))return void(i.eventHandler&&nu({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:r}},options:i}));if(""===r)throw new Jc("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:t})}const s=e.mappings.get(r);e.mappings.has(r)&&e.mappings.delete(r);let c=!1;if((Yc(a)||null===a)&&(c=!0,a={"@id":a}),!Kc(a))throw new Jc("Invalid JSON-LD syntax; @context term values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:t});const u={};e.mappings.set(r,u),u.reverse=!1;const l=["@container","@id","@language","@reverse","@type"];uu.processingMode(e,1.1)&&l.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in a)if(!l.includes(e))throw new Jc("Invalid JSON-LD syntax; a term definition must not contain "+e,"jsonld.SyntaxError",{code:"invalid term definition",context:t});const d=r.indexOf(":");if(u._termHasColon=d>0,"@reverse"in a){if("@id"in a)throw new Jc("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});if("@nest"in a)throw new Jc("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});const o=a["@reverse"];if(!Yc(o))throw new Jc("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(o.match(ou))return i.eventHandler&&nu({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:o}},options:i}),void(s?e.mappings.set(r,s):e.mappings.delete(r));const c=du(e,o,{vocab:!0,base:!1},t,n,i);if(!eu(c))throw new Jc("Invalid JSON-LD syntax; a @context @reverse value must be an absolute IRI or a blank node identifier.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});u["@id"]=c,u.reverse=!0}else if("@id"in a){let o=a["@id"];if(o&&!Yc(o))throw new Jc("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(null===o)u["@id"]=null;else{if(!uu.isKeyword(o)&&o.match(ou))return i.eventHandler&&nu({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:o}},options:i}),void(s?e.mappings.set(r,s):e.mappings.delete(r));if(o!==r){if(o=du(e,o,{vocab:!0,base:!1},t,n,i),!eu(o)&&!uu.isKeyword(o))throw new Jc("Invalid JSON-LD syntax; a @context @id value must be an absolute IRI, a blank node identifier, or a keyword.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(r.match(/(?::[^:])|\//)){if(du(e,r,{vocab:!0,base:!1},t,new Map(n).set(r,!0),i)!==o)throw new Jc("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t})}u["@id"]=o,u._prefix=c&&!u._termHasColon&&null!==o.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in u))if(u._termHasColon){const o=r.substr(0,d);if(t.hasOwnProperty(o)&&uu.createTermDefinition({activeCtx:e,localCtx:t,term:o,defined:n,options:i}),e.mappings.has(o)){const t=r.substr(d+1);u["@id"]=e.mappings.get(o)["@id"]+t}else u["@id"]=r}else if("@type"===r)u["@id"]=r;else{if(!("@vocab"in e))throw new Jc("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t,term:r});u["@id"]=e["@vocab"]+r}if((!0===a["@protected"]||!0===n.get("@protected")&&!1!==a["@protected"])&&(e.protected[r]=!0,u.protected=!0),n.set(r,!0),"@type"in a){let r=a["@type"];if(!Yc(r))throw new Jc("Invalid JSON-LD syntax; an @context @type value must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if("@json"===r||"@none"===r){if(uu.processingMode(e,1))throw new Jc(`Invalid JSON-LD syntax; an @context @type value must not be "${r}" in JSON-LD 1.0 mode.`,"jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else if("@id"!==r&&"@vocab"!==r){if(r=du(e,r,{vocab:!0,base:!1},t,n,i),!eu(r))throw new Jc("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if(0===r.indexOf("_:"))throw new Jc("Invalid JSON-LD syntax; an @context @type value must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}u["@type"]=r}if("@container"in a){const r=Yc(a["@container"])?[a["@container"]]:a["@container"]||[],n=["@list","@set","@index","@language"];let i=!0;const o=r.includes("@set");if(uu.processingMode(e,1.1)){if(n.push("@graph","@id","@type"),r.includes("@list")){if(1!==r.length)throw new Jc("Invalid JSON-LD syntax; @context @container with @list must have no other values","jsonld.SyntaxError",{code:"invalid container mapping",context:t})}else if(r.includes("@graph")){if(r.some(e=>"@graph"!==e&&"@id"!==e&&"@index"!==e&&"@set"!==e))throw new Jc("Invalid JSON-LD syntax; @context @container with @graph must have no other values other than @id, @index, and @set","jsonld.SyntaxError",{code:"invalid container mapping",context:t})}else i&=r.length<=(o?2:1);if(r.includes("@type")&&(u["@type"]=u["@type"]||"@id",!["@id","@vocab"].includes(u["@type"])))throw new Jc("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else i&=!Wc(a["@container"]),i&=r.length<=1;if(i&=r.every(e=>n.includes(e)),i&=!(o&&r.includes("@list")),!i)throw new Jc("Invalid JSON-LD syntax; @context @container value must be one of the following: "+n.join(", "),"jsonld.SyntaxError",{code:"invalid container mapping",context:t});if(u.reverse&&!r.every(e=>["@index","@set"].includes(e)))throw new Jc("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});u["@container"]=r}if("@index"in a){if(!("@container"in a)||!u["@container"].includes("@index"))throw new Jc(`Invalid JSON-LD syntax; @index without @index in @container: "${a["@index"]}" on term "${r}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});if(!Yc(a["@index"])||0===a["@index"].indexOf("@"))throw new Jc(`Invalid JSON-LD syntax; @index must expand to an IRI: "${a["@index"]}" on term "${r}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});u["@index"]=a["@index"]}if("@context"in a&&(u["@context"]=a["@context"]),"@language"in a&&!("@type"in a)){let e=a["@language"];if(null!==e&&!Yc(e))throw new Jc("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:t});null!==e&&(e=e.toLowerCase()),u["@language"]=e}if("@prefix"in a){if(r.match(/:|\//))throw new Jc("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:t});if(uu.isKeyword(u["@id"]))throw new Jc("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:t});if("boolean"!=typeof a["@prefix"])throw new Jc("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:t});u._prefix=!0===a["@prefix"]}if("@direction"in a){const e=a["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new Jc('Invalid JSON-LD syntax; @direction value must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:t});u["@direction"]=e}if("@nest"in a){const e=a["@nest"];if(!Yc(e)||"@nest"!==e&&0===e.indexOf("@"))throw new Jc("Invalid JSON-LD syntax; @context @nest value must be a string which is not a keyword other than @nest.","jsonld.SyntaxError",{code:"invalid @nest value",context:t});u["@nest"]=e}
+// disallow aliasing @context and @preserve
+const p=u["@id"];if("@context"===p||"@preserve"===p)throw new Jc("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t});if(s&&s.protected&&!o&&(e.protected[r]=!0,u.protected=!0,!pu(s,u)))throw new Jc("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:t,term:r})},uu.expandIri=(e,t,r,n)=>du(e,t,r,void 0,void 0,n),uu.getInitialContext=e=>{const t=JSON.stringify({processingMode:e.processingMode}),r=cu.get(t);if(r)return r;const n={processingMode:e.processingMode,mappings:new Map,inverse:null,getInverse:function(){const e=this;if(e.inverse)return e.inverse;const t=e.inverse={},r=e.fastCurieMap={},n={},a=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],c=e.mappings,u=[...c.keys()].sort(su);for(const e of u){const i=c.get(e);if(null===i)continue;let u=i["@container"]||"@none";if(u=[].concat(u).sort().join(""),null===i["@id"])continue;const l=au(i["@id"]);for(const c of l){let l=t[c];const d=uu.isKeyword(c);if(l)d||i._termHasColon||n[c].push(e);else if(t[c]=l={},!d&&!i._termHasColon){n[c]=[e];const t={iri:c,terms:n[c]};c[0]in r?r[c[0]].push(t):r[c[0]]=[t]}if(l[u]||(l[u]={"@language":{},"@type":{},"@any":{}}),l=l[u],o(e,l["@any"],"@none"),i.reverse)o(e,l["@type"],"@reverse");else if("@none"===i["@type"])o(e,l["@any"],"@none"),o(e,l["@language"],"@none"),o(e,l["@type"],"@none");else if("@type"in i)o(e,l["@type"],i["@type"]);else if("@language"in i&&"@direction"in i){const t=i["@language"],r=i["@direction"];o(e,l["@language"],t&&r?`${t}_${r}`.toLowerCase():t?t.toLowerCase():r?`_${r}`:"@null")}else"@language"in i?o(e,l["@language"],(i["@language"]||"@null").toLowerCase()):"@direction"in i?i["@direction"]?o(e,l["@language"],`_${i["@direction"]}`):o(e,l["@language"],"@none"):s?(o(e,l["@language"],`_${s}`),o(e,l["@language"],"@none"),o(e,l["@type"],"@none")):(o(e,l["@language"],a),o(e,l["@language"],"@none"),o(e,l["@type"],"@none"))}}for(const e in r)i(r,e,1);return t},clone:function(){const e={};e.mappings=Hc.clone(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,e.protected=Hc.clone(this.protected),this.previousContext&&(e.previousContext=this.previousContext.clone());e.revertToPreviousContext=this.revertToPreviousContext,"@base"in this&&(e["@base"]=this["@base"]);"@language"in this&&(e["@language"]=this["@language"]);"@vocab"in this&&(e["@vocab"]=this["@vocab"]);return e},revertToPreviousContext:function(){if(!this.previousContext)return this;return this.previousContext.clone()},protected:{}};return 1e4===cu.size&&cu.clear(),cu.set(t,n),n;function i(e,t,r){const n=e[t],o=e[t]={};let a,s;for(const e of n)a=e.iri,s=r>=a.length?"":a[r],s in o?o[s].push(e):o[s]=[e];for(const e in o)""!==e&&i(o,e,r+1)}function o(e,t,r){t.hasOwnProperty(r)||(t[r]=e)}},uu.getContextValue=(e,t,r)=>{if(null===t){if("@context"===r)return;return null}if(e.mappings.has(t)){const n=e.mappings.get(t);if(Zc(r))return n;if(n.hasOwnProperty(r))return n[r]}return"@language"===r&&r in e||"@direction"===r&&r in e?e[r]:"@context"!==r?null:void 0},uu.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,uu.isKeyword=e=>{if(!Yc(e)||"@"!==e[0])return!1;switch(e){case"@base":case"@container":case"@context":case"@default":case"@direction":case"@embed":case"@explicit":case"@graph":case"@id":case"@included":case"@index":case"@json":case"@language":case"@list":case"@nest":case"@none":case"@omitDefault":case"@prefix":case"@preserve":case"@protected":case"@requireAll":case"@reverse":case"@set":case"@type":case"@value":case"@version":case"@vocab":return!0}return!1};const fu=js,{isArray:hu,isObject:yu,isEmptyObject:gu,isString:mu,isUndefined:bu}=Ts,{isList:vu,isValue:_u,isGraph:wu,isSubject:Tu}=xs,{expandIri:Ou,getContextValue:Su,isKeyword:xu,process:ju,processingMode:Au}=lu,{isAbsolute:Eu}=Vs(),{REGEX_BCP47:Iu,REGEX_KEYWORD:Fu,addValue:Du,asArray:Nu,getValues:Pu,validateTypeValue:Ru}=Ls,{handleEvent:Mu}=Gc,Lu={};var Cu=Lu;function ku({value:e,count:t,options:r}){if(0===t||"@value"in e||"@list"in e||1===t&&"@id"in e){if(r.eventHandler){let n,i;0===t?(n="empty object",i="Dropping empty object."):"@value"in e?(n="object with only @value",i="Dropping object with only @value."):"@list"in e?(n="object with only @list",i="Dropping object with only @list."):1===t&&"@id"in e&&(n="object with only @id",i="Dropping object with only @id."),Mu({event:{type:["JsonLdEvent"],code:n,level:"warning",message:i,details:{value:e}},options:r})}return null}return e}async function Bu({activeCtx:e,activeProperty:t,expandedActiveProperty:r,element:n,expandedParent:i,options:o={},insideList:a,typeKey:s,typeScopedContext:c}){const u=Object.keys(n).sort(),l=[];let d;const p=n[s]&&"@json"===Ou(e,hu(n[s])?n[s][0]:n[s],{vocab:!0},{...o,typeExpansion:!0});for(const a of u){let s,u=n[a];if("@context"===a)continue;const f=Ou(e,a,{vocab:!0},o);if(null===f||!Eu(f)&&!xu(f)){o.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:a,expandedProperty:f}},options:o});continue}if(xu(f)){if("@reverse"===r)throw new fu("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:u});if(f in i&&"@included"!==f&&"@type"!==f)throw new fu("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:f})}if("@id"===f){if(!mu(u)){if(!o.isFrame)throw new fu('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:u});if(yu(u)){if(!gu(u))throw new fu('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:u})}else{if(!hu(u))throw new fu('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:u});if(!u.every(e=>mu(e)))throw new fu('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:u})}}Du(i,"@id",Nu(u).map(t=>{if(mu(t)){const r=Ou(e,t,{base:!0},o);return o.eventHandler&&(null===r?Mu(null===t?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:t}},options:o}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}):Eu(r)||Mu({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:t,expandedId:r}},options:o})),r}return t}),{propertyIsArray:o.isFrame});continue}if("@type"===f){yu(u)&&(u=Object.fromEntries(Object.entries(u).map(([e,t])=>[Ou(c,e,{vocab:!0}),Nu(t).map(e=>Ou(c,e,{base:!0,vocab:!0},{...o,typeExpansion:!0}))]))),Ru(u,o.isFrame),Du(i,"@type",Nu(u).map(e=>{if(mu(e)){const t=Ou(c,e,{base:!0,vocab:!0},{...o,typeExpansion:!0});return"@json"===t||Eu(t)||o.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:o}),t}return e}),{propertyIsArray:!!o.isFrame});continue}if("@included"===f&&Au(e,1.1)){const r=Nu(await Lu.expand({activeCtx:e,activeProperty:t,element:u,options:o}));if(!r.every(e=>Tu(e)))throw new fu("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:u});Du(i,"@included",r,{propertyIsArray:!0});continue}if("@graph"===f&&!yu(u)&&!hu(u))throw new fu('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:u});if("@value"===f){d=u,p&&Au(e,1.1)?i["@value"]=u:Du(i,"@value",u,{propertyIsArray:o.isFrame});continue}if("@language"===f){if(null===u)continue;if(!mu(u)&&!o.isFrame)throw new fu('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:u});u=Nu(u).map(e=>mu(e)?e.toLowerCase():e);for(const e of u)mu(e)&&!e.match(Iu)&&o.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:o});Du(i,"@language",u,{propertyIsArray:o.isFrame});continue}if("@direction"===f){if(!mu(u)&&!o.isFrame)throw new fu('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:u});u=Nu(u);for(const e of u)if(mu(e)&&"ltr"!==e&&"rtl"!==e)throw new fu('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:u});Du(i,"@direction",u,{propertyIsArray:o.isFrame});continue}if("@index"===f){if(!mu(u))throw new fu('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:u});Du(i,"@index",u);continue}if("@reverse"===f){if(!yu(u))throw new fu('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:u});if(s=await Lu.expand({activeCtx:e,activeProperty:"@reverse",element:u,options:o}),"@reverse"in s)for(const e in s["@reverse"])Du(i,e,s["@reverse"][e],{propertyIsArray:!0});let t=i["@reverse"]||null;for(const e in s){if("@reverse"===e)continue;null===t&&(t=i["@reverse"]={}),Du(t,e,[],{propertyIsArray:!0});const r=s[e];for(let n=0;n"@id"===e||"@index"===e)){if(s=Nu(s),o.isFrame||(s=s.filter(e=>null!==ku({value:e,count:Object.keys(e).length,options:o}))),0===s.length)continue;s=s.map(e=>({"@graph":Nu(e)}))}if(h.mappings.has(a)&&h.mappings.get(a).reverse){const e=i["@reverse"]=i["@reverse"]||{};s=Nu(s);for(let t=0;t"@value"===Ou(e,t,{vocab:!0},o)))throw new fu("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:n});await Bu({activeCtx:e,activeProperty:t,expandedActiveProperty:r,element:n,expandedParent:i,options:o,insideList:a,typeScopedContext:c,typeKey:s})}}}function Uu({activeCtx:e,activeProperty:t,value:r,options:n}){if(null==r)return null;const i=Ou(e,t,{vocab:!0},n);if("@id"===i)return Ou(e,r,{base:!0},n);if("@type"===i)return Ou(e,r,{vocab:!0,base:!0},{...n,typeExpansion:!0});const o=Su(e,t,"@type");if(("@id"===o||"@graph"===i)&&mu(r)){const i=Ou(e,r,{base:!0},n);return null===i&&r.match(Fu)&&n.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:n}),{"@id":i}}if("@vocab"===o&&mu(r))return{"@id":Ou(e,r,{vocab:!0,base:!0},n)};if(xu(i))return r;const a={};if(o&&!["@id","@vocab","@none"].includes(o))a["@type"]=o;else if(mu(r)){const r=Su(e,t,"@language");null!==r&&(a["@language"]=r);const n=Su(e,t,"@direction");null!==n&&(a["@direction"]=n)}return["boolean","number","string"].includes(typeof r)||(r=r.toString()),a["@value"]=r,a}function $u(e,t,r,n){const i=[],o=Object.keys(t).sort();for(const a of o){const o=Ou(e,a,{vocab:!0},n);let s=t[a];hu(s)||(s=[s]);for(const e of s){if(null===e)continue;if(!mu(e))throw new fu("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:t});const s={"@value":e};"@none"!==o&&(a.match(Iu)||n.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:a}},options:n}),s["@language"]=a.toLowerCase()),r&&(s["@direction"]=r),i.push(s)}}return i}async function qu({activeCtx:e,options:t,activeProperty:r,value:n,asGraph:i,indexKey:o,propertyIndex:a}){const s=[],c=Object.keys(n).sort(),u="@type"===o;for(let l of c){if(u){const r=Su(e,l,"@context");bu(r)||(e=await ju({activeCtx:e,localCtx:r,propagate:!1,options:t}))}let c,d=n[l];hu(d)||(d=[d]),d=await Lu.expand({activeCtx:e,activeProperty:r,element:d,options:t,insideList:!1,insideIndex:!0}),c=a?"@none"===l?"@none":Uu({activeCtx:e,activeProperty:o,value:l,options:t}):Ou(e,l,{vocab:!0},t),"@id"===o?l=Ou(e,l,{base:!0},t):u&&(l=c);for(let e of d){if(i&&!wu(e)&&(e={"@graph":[e]}),"@type"===o)"@none"===c||(e["@type"]?e["@type"]=[l].concat(e["@type"]):e["@type"]=[l]);else{if(_u(e)&&!["@language","@type","@index"].includes(o))throw new fu(`Invalid JSON-LD syntax; Attempt to add illegal key to value object: "${o}".`,"jsonld.SyntaxError",{code:"invalid value object",value:e});a?"@none"!==c&&Du(e,a,c,{propertyIsArray:!0,prependValue:!0}):"@none"===c||o in e||(e[o]=l)}s.push(e)}}return s}Lu.expand=async({activeCtx:e,activeProperty:t=null,element:r,options:n={},insideList:i=!1,insideIndex:o=!1,typeScopedContext:a=null})=>{if(null==r)return null;if("@default"===t&&(n=Object.assign({},n,{isFrame:!1})),!hu(r)&&!yu(r))return i||null!==t&&"@graph"!==Ou(e,t,{vocab:!0},n)?Uu({activeCtx:e,activeProperty:t,value:r,options:n}):(n.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"free-floating scalar",level:"warning",message:"Dropping free-floating scalar not in a list.",details:{value:r}},options:n}),null);if(hu(r)){let s=[];const c=Su(e,t,"@container")||[];i=i||c.includes("@list");for(let c=0;c1?i.slice().sort():i:[i];for(const t of o){const r=Su(a,t,"@context");bu(r)||(e=await ju({activeCtx:e,localCtx:r,options:n,propagate:!1}))}}}let p={};await Bu({activeCtx:e,activeProperty:t,expandedActiveProperty:s,element:r,expandedParent:p,options:n,insideList:i,typeKey:d,typeScopedContext:a}),u=Object.keys(p);let f=u.length;if("@value"in p){if("@type"in p&&("@language"in p||"@direction"in p))throw new fu('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and either "@language" or "@direction".',"jsonld.SyntaxError",{code:"invalid value object",element:p});let t=f-1;if("@type"in p&&(t-=1),"@index"in p&&(t-=1),"@language"in p&&(t-=1),"@direction"in p&&(t-=1),0!==t)throw new fu('Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and either "@type" or either or both "@language" or "@direction".',"jsonld.SyntaxError",{code:"invalid value object",element:p});const r=null===p["@value"]?[]:Nu(p["@value"]),i=Pu(p,"@type");if(Au(e,1.1)&&i.includes("@json")&&1===i.length);else if(0===r.length)n.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"null @value value",level:"warning",message:"Dropping null @value value.",details:{value:p}},options:n}),p=null;else{if(!r.every(e=>mu(e)||gu(e))&&"@language"in p)throw new fu("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:p});if(!i.every(e=>Eu(e)&&!(mu(e)&&0===e.indexOf("_:"))||gu(e)))throw new fu('Invalid JSON-LD syntax; an element containing "@value" and "@type" must have an absolute IRI for the value of "@type".',"jsonld.SyntaxError",{code:"invalid typed value",element:p})}}else if("@type"in p&&!hu(p["@type"]))p["@type"]=[p["@type"]];else if("@set"in p||"@list"in p){if(f>1&&(2!==f||!("@index"in p)))throw new fu('Invalid JSON-LD syntax; if an element has the property "@set" or "@list", then it can have at most one other property that is "@index".',"jsonld.SyntaxError",{code:"invalid set or list object",element:p});"@set"in p&&(p=p["@set"],u=Object.keys(p),f=u.length)}else 1===f&&"@language"in p&&(n.eventHandler&&Mu({event:{type:["JsonLdEvent"],code:"object with only @language",level:"warning",message:"Dropping object with only @language.",details:{value:p}},options:n}),p=null);return!yu(p)||n.keepFreeFloatingNodes||i||null!==t&&"@graph"!==s&&!(Su(e,t,"@container")||[]).includes("@graph")||(p=ku({value:p,count:f,options:n})),p};const{isKeyword:Qu}=lu,zu=xs,Gu=Ts,Vu=Ls,Xu=js,Hu={};var Ju=Hu;Hu.createMergedNodeMap=(e,t)=>{const r=(t=t||{}).issuer||new Vu.IdentifierIssuer("_:b"),n={"@default":{}};return Hu.createNodeMap(e,n,"@default",r),Hu.mergeNodeMaps(n)},Hu.createNodeMap=(e,t,r,n,i,o)=>{if(Gu.isArray(e)){for(const i of e)Hu.createNodeMap(i,t,r,n,void 0,o);return}if(!Gu.isObject(e))return void(o&&o.push(e));if(zu.isValue(e)){if("@type"in e){let t=e["@type"];0===t.indexOf("_:")&&(e["@type"]=t=n.getId(t))}return void(o&&o.push(e))}if(o&&zu.isList(e)){const a=[];return Hu.createNodeMap(e["@list"],t,r,n,i,a),void o.push({"@list":a})}if("@type"in e){const t=e["@type"];for(const e of t)0===e.indexOf("_:")&&n.getId(e)}Gu.isUndefined(i)&&(i=zu.isBlankNode(e)?n.getId(e["@id"]):e["@id"]),o&&o.push({"@id":i});const a=t[r],s=a[i]=a[i]||{};s["@id"]=i;const c=Object.keys(e).sort();for(let o of c){if("@id"===o)continue;if("@reverse"===o){const o={"@id":i},s=e["@reverse"];for(const e in s){const i=s[e];for(const s of i){let i=s["@id"];zu.isBlankNode(s)&&(i=n.getId(i)),Hu.createNodeMap(s,t,r,n,i),Vu.addValue(a[i],e,o,{propertyIsArray:!0,allowDuplicate:!1})}}continue}if("@graph"===o){i in t||(t[i]={}),Hu.createNodeMap(e[o],t,i,n);continue}if("@included"===o){Hu.createNodeMap(e[o],t,r,n);continue}if("@type"!==o&&Qu(o)){if("@index"===o&&o in s&&(e[o]!==s[o]||e[o]["@id"]!==s[o]["@id"]))throw new Xu("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:s});s[o]=e[o];continue}const c=e[o];if(0===o.indexOf("_:")&&(o=n.getId(o)),0!==c.length)for(let e of c)if("@type"===o&&(e=0===e.indexOf("_:")?n.getId(e):e),zu.isSubject(e)||zu.isSubjectReference(e)){if("@id"in e&&!e["@id"])continue;const i=zu.isBlankNode(e)?n.getId(e["@id"]):e["@id"];Vu.addValue(s,o,{"@id":i},{propertyIsArray:!0,allowDuplicate:!1}),Hu.createNodeMap(e,t,r,n,i)}else if(zu.isValue(e))Vu.addValue(s,o,e,{propertyIsArray:!0,allowDuplicate:!1});else if(zu.isList(e)){const a=[];Hu.createNodeMap(e["@list"],t,r,n,i,a),e={"@list":a},Vu.addValue(s,o,e,{propertyIsArray:!0,allowDuplicate:!1})}else Hu.createNodeMap(e,t,r,n,i),Vu.addValue(s,o,e,{propertyIsArray:!0,allowDuplicate:!1});else Vu.addValue(s,o,[],{propertyIsArray:!0})}},Hu.mergeNodeMapGraphs=e=>{const t={};for(const r of Object.keys(e).sort())for(const n of Object.keys(e[r]).sort()){const i=e[r][n];n in t||(t[n]={"@id":n});const o=t[n];for(const e of Object.keys(i).sort())if(Qu(e)&&"@type"!==e)o[e]=Vu.clone(i[e]);else for(const t of i[e])Vu.addValue(o,e,Vu.clone(t),{propertyIsArray:!0,allowDuplicate:!1})}return t},Hu.mergeNodeMaps=e=>{const t=e["@default"],r=Object.keys(e).sort();for(const n of r){if("@default"===n)continue;const r=e[n];let i=t[n];i?"@graph"in i||(i["@graph"]=[]):t[n]=i={"@id":n,"@graph":[]};const o=i["@graph"];for(const e of Object.keys(r).sort()){const t=r[e];zu.isSubjectReference(t)||o.push(t)}}return t};const{isSubjectReference:Wu}=xs,{createMergedNodeMap:Ku}=Ju,Yu={};var Zu=Yu;Yu.flatten=e=>{const t=Ku(e),r=[],n=Object.keys(t).sort();for(let e=0;e0&&(i["@language"]=e,e.match(nl)||n.eventHandler&&ol({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:n})),i["@direction"]=t}else o!==yl&&(i["@type"]=o)}return i}gl.fromRDF=async(e,t)=>{const{useRdfType:r=!1,useNativeTypes:n=!1,rdfDirection:i=null}=t,o={},a={"@default":o},s={};if(i){if("compound-literal"===i)throw new el("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:i});if("i18n-datatype"!==i)throw new el("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:i})}for(const c of e){const e="DefaultGraph"===c.graph.termType?"@default":c.graph.value;e in a||(a[e]={}),"@default"===e||e in o||(o[e]={"@id":e});const u=a[e],l=c.subject.value,d=c.predicate.value,p=c.object;l in u||(u[l]={"@id":l});const f=u[l],h=p.termType.endsWith("Node");if(h&&!(p.value in u)&&(u[p.value]={"@id":p.value}),d===ll&&!r&&h){il(f,"@type",p.value,{propertyIsArray:!0});continue}const y=bl(p,n,i,t);if(il(f,d,y,{propertyIsArray:!0}),h)if(p.value===ul){const e=u[p.value];"usages"in e||(e.usages=[]),e.usages.push({node:f,property:d,value:y})}else p.value in s?s[p.value]=!1:s[p.value]={node:f,property:d,value:y}}for(const e in a){const t=a[e];if(!(ul in t))continue;const r=t[ul];if(r.usages){for(let e of r.usages){let r=e.node,n=e.property,i=e.value;const o=[],a=[];let c=Object.keys(r).length;for(;n===cl&&rl.isObject(s[r["@id"]])&&rl.isArray(r[sl])&&1===r[sl].length&&rl.isArray(r[cl])&&1===r[cl].length&&(3===c||4===c&&rl.isArray(r["@type"])&&1===r["@type"].length&&r["@type"][0]===al)&&(o.push(r[sl][0]),a.push(r["@id"]),e=s[r["@id"]],r=e.node,n=e.property,i=e.value,c=Object.keys(r).length,tl.isBlankNode(r)););delete i["@id"],i["@list"]=o.reverse();for(const e of a)delete t[e]}delete r.usages}}const c=[],u=Object.keys(o).sort();for(const e of u){const t=o[e];if(e in a){const r=t["@graph"]=[],n=a[e],i=Object.keys(n).sort();for(const e of i){const t=n[e];tl.isSubjectReference(t)||r.push(t)}}tl.isSubjectReference(t)||c.push(t)}return c};const{createNodeMap:vl}=Ju,{isKeyword:_l}=lu,wl=xs,Tl=function e(t){return null===t||"object"!=typeof t||null!=t.toJSON?JSON.stringify(t):Array.isArray(t)?"["+t.reduce((t,r,n)=>t+(0===n?"":",")+e(void 0===r||"symbol"==typeof r?null:r),"")+"]":"{"+Object.keys(t).sort().reduce((r,n,i)=>{if(void 0===t[n]||"symbol"==typeof t[n])return r;return r+(0===r.length?"":",")+e(n)+":"+e(t[n])},"")+"}"},Ol=js,Sl=Ts,xl=Ls,{handleEvent:jl}=Gc,{RDF_FIRST:Al,RDF_REST:El,RDF_NIL:Il,RDF_TYPE:Fl,RDF_JSON_LITERAL:Dl,RDF_LANGSTRING:Nl,XSD_BOOLEAN:Pl,XSD_DOUBLE:Rl,XSD_INTEGER:Ml,XSD_STRING:Ll}=zs,{isAbsolute:Cl}=Vs(),kl={};var Bl=kl;function Ul(e,t,r,n,i){const o=Object.keys(t).sort();for(const a of o){const o=t[a],s=Object.keys(o).sort();for(let t of s){const s=o[t];if("@type"===t)t=Fl;else if(_l(t))continue;for(const o of s){const s={termType:a.startsWith("_:")?"BlankNode":"NamedNode",value:a};if(!Cl(a)){i.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"relative subject reference",level:"warning",message:"Relative subject reference found.",details:{subject:a}},options:i});continue}const c={termType:t.startsWith("_:")?"BlankNode":"NamedNode",value:t};if(!Cl(t)){i.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"relative predicate reference",level:"warning",message:"Relative predicate reference found.",details:{predicate:t}},options:i});continue}if("BlankNode"===c.termType&&!i.produceGeneralizedRdf){i.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"blank node predicate",level:"warning",message:"Dropping blank node predicate.",details:{property:n.getOldIds().find(e=>n.getId(e)===t)}},options:i});continue}const u=$l(o,n,e,r,i.rdfDirection,i);u&&e.push({subject:s,predicate:c,object:u,graph:r})}}}}function $l(e,t,r,n,i,o){const a={};if(wl.isValue(e)){a.termType="Literal",a.value=void 0,a.datatype={termType:"NamedNode"};let t=e["@value"];const r=e["@type"]||null;if("@json"===r)a.value=Tl(t),a.datatype.value=Dl;else if(Sl.isBoolean(t))a.value=t.toString(),a.datatype.value=r||Pl;else if(Sl.isDouble(t)||r===Rl)Sl.isDouble(t)||(t=parseFloat(t)),a.value=t.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),a.datatype.value=r||Rl;else if(Sl.isNumber(t))a.value=t.toFixed(0),a.datatype.value=r||Ml;else if("@direction"in e&&"i18n-datatype"===i){const r=`https://www.w3.org/ns/i18n#${(e["@language"]||"").toLowerCase()}_${e["@direction"]}`;a.datatype.value=r,a.value=t}else{if("@direction"in e&&"compound-literal"===i)throw new Ol("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:i});if("@direction"in e&&i)throw new Ol("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:i});"@language"in e?("@direction"in e&&!i&&o.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:a.value}},options:o}),a.value=t,a.datatype.value=r||Nl,a.language=e["@language"]):("@direction"in e&&!i&&o.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:a.value}},options:o}),a.value=t,a.datatype.value=r||Ll)}}else if(wl.isList(e)){const s=function(e,t,r,n,i,o){const a={termType:"NamedNode",value:Al},s={termType:"NamedNode",value:El},c={termType:"NamedNode",value:Il},u=e.pop(),l=u?{termType:"BlankNode",value:t.getId()}:c;let d=l;for(const c of e){const e=$l(c,t,r,n,i,o),u={termType:"BlankNode",value:t.getId()};r.push({subject:d,predicate:a,object:e,graph:n}),r.push({subject:d,predicate:s,object:u,graph:n}),d=u}if(u){const e=$l(u,t,r,n,i,o);r.push({subject:d,predicate:a,object:e,graph:n}),r.push({subject:d,predicate:s,object:c,graph:n})}return l}(e["@list"],t,r,n,i,o);a.termType=s.termType,a.value=s.value}else{const t=Sl.isObject(e)?e["@id"]:e;a.termType=t.startsWith("_:")?"BlankNode":"NamedNode",a.value=t}return"NamedNode"!==a.termType||Cl(a.value)?a:(o.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"relative object reference",level:"warning",message:"Relative object reference found.",details:{object:a.value}},options:o}),null)}kl.toRDF=(e,t)=>{const r=new xl.IdentifierIssuer("_:b"),n={"@default":{}};vl(e,n,"@default",r);const i=[],o=Object.keys(n).sort();for(const e of o){let o;if("@default"===e)o={termType:"DefaultGraph",value:""};else{if(!Cl(e)){t.eventHandler&&jl({event:{type:["JsonLdEvent"],code:"relative graph reference",level:"warning",message:"Relative graph reference found.",details:{graph:e}},options:t});continue}o=e.startsWith("_:")?{termType:"BlankNode"}:{termType:"NamedNode"},o.value=e}Ul(i,n[e],o,r,t)}return i};const{isKeyword:ql}=lu,Ql=xs,zl=Ts,Gl=Ls,Vl=Vs(),Xl=js,{createNodeMap:Hl,mergeNodeMapGraphs:Jl}=Ju,Wl={};var Kl=Wl;function Yl(e){const t={};for(const r in e)void 0!==e[r]&&(t["@"+r]=[e[r]]);return[t]}function Zl(e,t,r){for(let n=r.length-1;n>=0;--n){const i=r[n];if(i.graph===t&&i.subject["@id"]===e["@id"])return!0}return!1}function ed(e,t,r){const n="@"+r;let i=n in e?e[n][0]:t[r];if("embed"===r)if(!0===i)i="@once";else if(!1===i)i="@never";else if("@always"!==i&&"@never"!==i&&"@link"!==i&&"@first"!==i&&"@last"!==i&&"@once"!==i)throw new Xl("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:e});return i}function td(e){if(!zl.isArray(e)||1!==e.length||!zl.isObject(e[0]))throw new Xl("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e});if("@id"in e[0])for(const t of Gl.asArray(e[0]["@id"]))if(!zl.isObject(t)&&!Vl.isAbsolute(t)||zl.isString(t)&&0===t.indexOf("_:"))throw new Xl("Invalid JSON-LD syntax; invalid @id in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e});if("@type"in e[0])for(const t of Gl.asArray(e[0]["@type"]))if(!zl.isObject(t)&&!Vl.isAbsolute(t)&&"@json"!==t||zl.isString(t)&&0===t.indexOf("_:"))throw new Xl("Invalid JSON-LD syntax; invalid @type in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e})}function rd(e,t,r,n){let i=!0,o=!1;for(const a in r){let s=!1;const c=Gl.getValues(t,a),u=0===Gl.getValues(r,a).length;if("@id"===a){if(zl.isEmptyObject(r["@id"][0]||{})?s=!0:r["@id"].length>=0&&(s=r["@id"].includes(c[0])),!n.requireAll)return s}else if("@type"===a){if(i=!1,u){if(c.length>0)return!1;s=!0}else if(1===r["@type"].length&&zl.isEmptyObject(r["@type"][0]))s=c.length>0;else for(const e of r["@type"])s=!(!zl.isObject(e)||!("@default"in e))||(s||c.some(t=>t===e));if(!n.requireAll)return s}else{if(ql(a))continue;{const t=Gl.getValues(r,a)[0];let o=!1;if(t&&(td([t]),o="@default"in t),i=!1,0===c.length&&o)continue;if(c.length>0&&u)return!1;if(void 0===t){if(c.length>0)return!1;s=!0}else if(Ql.isList(t)){const r=t["@list"][0];if(Ql.isList(c[0])){const t=c[0]["@list"];Ql.isValue(r)?s=t.some(e=>sd(r,e)):(Ql.isSubject(r)||Ql.isSubjectReference(r))&&(s=t.some(t=>ad(e,r,t,n)))}}else s=Ql.isValue(t)?c.some(e=>sd(t,e)):Ql.isSubjectReference(t)?c.some(r=>ad(e,t,r,n)):!!zl.isObject(t)&&c.length>0}}if(!s&&n.requireAll)return!1;o=o||s}return i||o}function nd(e,t){const r=e.uniqueEmbeds[e.graph],n=r[t],i=n.parent,o=n.property,a={"@id":t};if(zl.isArray(i)){for(let e=0;e{const t=Object.keys(r);for(const n of t)n in r&&zl.isObject(r[n].parent)&&r[n].parent["@id"]===e&&(delete r[n],s(n))};s(t)}
+/**
+ * Removes the @preserve keywords from expanded result of framing.
+ *
+ * @param input the framed, framed output.
+ * @param options the framing options used.
+ *
+ * @return the resulting output.
+ */function id(e,t){if(zl.isArray(e))return e.map(e=>id(e,t));if(zl.isObject(e)){
+// remove @preserve
+if("@preserve"in e)return e["@preserve"][0];if(Ql.isValue(e))return e;if(Ql.isList(e))return e["@list"]=id(e["@list"],t),e;if("@id"in e){const r=e["@id"];if(t.link.hasOwnProperty(r)){const n=t.link[r].indexOf(e);if(-1!==n)return t.link[r][n];t.link[r].push(e)}else t.link[r]=[e]}for(const r in e)"@id"===r&&t.bnodesToClear.includes(e[r])?delete e["@id"]:e[r]=id(e[r],t)}return e}function od(e,t,r){zl.isObject(e)?Gl.addValue(e,t,r,{propertyIsArray:!0}):e.push(r)}function ad(e,t,r,n){if(!("@id"in r))return!1;const i=e.subjects[r["@id"]];return i&&rd(e,i,t,n)}function sd(e,t){const r=t["@value"],n=t["@type"],i=t["@language"],o=e["@value"]?zl.isArray(e["@value"])?e["@value"]:[e["@value"]]:[],a=e["@type"]?zl.isArray(e["@type"])?e["@type"]:[e["@type"]]:[],s=e["@language"]?zl.isArray(e["@language"])?e["@language"]:[e["@language"]]:[];return 0===o.length&&0===a.length&&0===s.length||!(!o.includes(r)&&!zl.isEmptyObject(o[0]))&&(!!(!n&&0===a.length||a.includes(n)||n&&zl.isEmptyObject(a[0]))&&!!(!i&&0===s.length||s.includes(i)||i&&zl.isEmptyObject(s[0])))}Wl.frameMergedOrDefault=(e,t,r)=>{const n={options:r,embedded:!1,graph:"@default",graphMap:{"@default":{}},subjectStack:[],link:{},bnodeMap:{}},i=new Gl.IdentifierIssuer("_:b");Hl(e,n.graphMap,"@default",i),r.merged&&(n.graphMap["@merged"]=Jl(n.graphMap),n.graph="@merged"),n.subjects=n.graphMap[n.graph];const o=[];return Wl.frame(n,Object.keys(n.subjects).sort(),t,o),r.pruneBlankNodeIdentifiers&&(r.bnodesToClear=Object.keys(n.bnodeMap).filter(e=>1===n.bnodeMap[e].length)),
+// remove @preserve from results
+r.link={},id(o,r)},Wl.frame=(e,t,r,n,i=null)=>{td(r),r=r[0];const o=e.options,a={embed:ed(r,o,"embed"),explicit:ed(r,o,"explicit"),requireAll:ed(r,o,"requireAll")};e.link.hasOwnProperty(e.graph)||(e.link[e.graph]={});const s=e.link[e.graph],c=function(e,t,r,n){const i={};for(const o of t){const t=e.graphMap[e.graph][o];rd(e,t,r,n)&&(i[o]=t)}return i}(e,t,r,a),u=Object.keys(c).sort();for(const l of u){const u=c[l];if(null===i?e.uniqueEmbeds={[e.graph]:{}}:e.uniqueEmbeds[e.graph]=e.uniqueEmbeds[e.graph]||{},"@link"===a.embed&&l in s){od(n,i,s[l]);continue}const d={"@id":l};if(0===l.indexOf("_:")&&Gl.addValue(e.bnodeMap,l,d,{propertyIsArray:!0}),s[l]=d,("@first"===a.embed||"@last"===a.embed)&&e.is11)throw new Xl("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:r});if(e.embedded||!e.uniqueEmbeds[e.graph].hasOwnProperty(l))if(!e.embedded||"@never"!==a.embed&&!Zl(u,e.graph,e.subjectStack))if(!e.embedded||"@first"!=a.embed&&"@once"!=a.embed||!e.uniqueEmbeds[e.graph].hasOwnProperty(l)){if("@last"===a.embed&&l in e.uniqueEmbeds[e.graph]&&nd(e,l),e.uniqueEmbeds[e.graph][l]={parent:n,property:i},e.subjectStack.push({subject:u,graph:e.graph}),l in e.graphMap){let t=!1,n=null;"@graph"in r?(n=r["@graph"][0],t=!("@merged"===l||"@default"===l),zl.isObject(n)||(n={})):(t="@merged"!==e.graph,n={}),t&&Wl.frame({...e,graph:l,embedded:!1},Object.keys(e.graphMap[l]).sort(),[n],d,"@graph")}"@included"in r&&Wl.frame({...e,embedded:!1},t,r["@included"],d,"@included");for(const t of Object.keys(u).sort())if(ql(t)){if(d[t]=Gl.clone(u[t]),"@type"===t)for(const t of u["@type"])0===t.indexOf("_:")&&Gl.addValue(e.bnodeMap,t,d,{propertyIsArray:!0})}else if(!a.explicit||t in r)for(const n of u[t]){const i=t in r?r[t]:Yl(a);if(Ql.isList(n)){const i=r[t]&&r[t][0]&&r[t][0]["@list"]?r[t][0]["@list"]:Yl(a),o={"@list":[]};od(d,t,o);const s=n["@list"];for(const t of s)Ql.isSubjectReference(t)?Wl.frame({...e,embedded:!0},[t["@id"]],i,o,"@list"):od(o,"@list",Gl.clone(t))}else Ql.isSubjectReference(n)?Wl.frame({...e,embedded:!0},[n["@id"]],i,d,t):sd(i[0],n)&&od(d,t,Gl.clone(n))}for(const e of Object.keys(r).sort()){if("@type"===e){if(!zl.isObject(r[e][0])||!("@default"in r[e][0]))continue}else if(ql(e))continue;const t=r[e][0]||{};if(!ed(t,o,"omitDefault")&&!(e in d)){let r="@null";"@default"in t&&(r=Gl.clone(t["@default"])),zl.isArray(r)||(r=[r]),d[e]=[{"@preserve":r}]}}for(const t of Object.keys(r["@reverse"]||{}).sort()){const n=r["@reverse"][t];for(const r of Object.keys(e.subjects)){Gl.getValues(e.subjects[r],t).some(e=>e["@id"]===l)&&(d["@reverse"]=d["@reverse"]||{},Gl.addValue(d["@reverse"],t,[],{propertyIsArray:!0}),Wl.frame({...e,embedded:!0},[r],n,d["@reverse"][t],i))}}od(n,i,d),e.subjectStack.pop()}else od(n,i,d);else od(n,i,d)}},Wl.cleanupNull=(e,t)=>{if(zl.isArray(e)){return e.map(e=>Wl.cleanupNull(e,t)).filter(e=>e)}if("@null"===e)return null;if(zl.isObject(e)){if("@id"in e){const r=e["@id"];if(t.link.hasOwnProperty(r)){const n=t.link[r].indexOf(e);if(-1!==n)return t.link[r][n];t.link[r].push(e)}else t.link[r]=[e]}for(const r in e)e[r]=Wl.cleanupNull(e[r],t)}return e};const cd=js,{isArray:ud,isObject:ld,isString:dd,isUndefined:pd}=Ts,{isList:fd,isValue:hd,isGraph:yd,isSimpleGraph:gd,isSubjectReference:md}=xs,{expandIri:bd,getContextValue:vd,isKeyword:_d,process:wd,processingMode:Td}=lu,{removeBase:Od,prependBase:Sd}=Vs(),{REGEX_KEYWORD:xd,addValue:jd,asArray:Ad,compareShortestLeast:Ed}=Ls,Id={};var Fd,Dd,Nd=Id;function Pd(e,t,r){if("@nest"!==bd(e,t,{vocab:!0},r))throw new cd("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}Id.compact=async({activeCtx:e,activeProperty:t=null,element:r,options:n={}})=>{if(ud(r)){let i=[];for(let o=0;o1&&(c=Array.from(c).sort());const u=e;for(const t of c){const r=Id.compactIri({activeCtx:u,iri:t,relativeTo:{vocab:!0}}),i=vd(a,r,"@context");pd(i)||(e=await wd({activeCtx:e,localCtx:i,options:n,propagate:!1}))}const l=Object.keys(r).sort();for(const s of l){const c=r[s];if("@id"===s){let t=Ad(c).map(t=>Id.compactIri({activeCtx:e,iri:t,relativeTo:{vocab:!1},base:n.base}));1===t.length&&(t=t[0]);o[Id.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t;continue}if("@type"===s){let t=Ad(c).map(e=>Id.compactIri({activeCtx:a,iri:e,relativeTo:{vocab:!0}}));1===t.length&&(t=t[0]);const r=Id.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}}),n=(vd(e,r,"@container")||[]).includes("@set")&&Td(e,1.1)||ud(t)&&0===c.length;jd(o,r,t,{propertyIsArray:n});continue}if("@reverse"===s){const t=await Id.compact({activeCtx:e,activeProperty:"@reverse",element:c,options:n});for(const r in t)if(e.mappings.has(r)&&e.mappings.get(r).reverse){const i=t[r],a=(vd(e,r,"@container")||[]).includes("@set")||!n.compactArrays;jd(o,r,i,{propertyIsArray:a}),delete t[r]}if(Object.keys(t).length>0){const r=Id.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});jd(o,r,t)}continue}if("@preserve"===s){const r=await Id.compact({activeCtx:e,activeProperty:t,element:c,options:n});ud(r)&&0===r.length||jd(o,s,r);continue}if("@index"===s){if((vd(e,t,"@container")||[]).includes("@index"))continue;const r=Id.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});jd(o,r,c);continue}if("@graph"!==s&&"@list"!==s&&"@included"!==s&&_d(s)){const t=Id.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});jd(o,t,c);continue}if(!ud(c))throw new cd("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===c.length){const t=Id.compactIri({activeCtx:e,iri:s,value:c,relativeTo:{vocab:!0},reverse:i}),r=e.mappings.has(t)?e.mappings.get(t)["@nest"]:null;let a=o;r&&(Pd(e,r,n),ld(o[r])||(o[r]={}),a=o[r]),jd(a,t,c,{propertyIsArray:!0})}for(const t of c){const r=Id.compactIri({activeCtx:e,iri:s,value:t,relativeTo:{vocab:!0},reverse:i}),a=e.mappings.has(r)?e.mappings.get(r)["@nest"]:null;let c=o;a&&(Pd(e,a,n),ld(o[a])||(o[a]={}),c=o[a]);const u=vd(e,r,"@container")||[],l=yd(t),d=fd(t);let p;d?p=t["@list"]:l&&(p=t["@graph"]);let f=await Id.compact({activeCtx:e,activeProperty:r,element:d||l?p:t,options:n});if(d){if(ud(f)||(f=[f]),u.includes("@list")){jd(c,r,f,{valueIsArray:!0,allowDuplicate:!0});continue}f={[Id.compactIri({activeCtx:e,iri:"@list",relativeTo:{vocab:!0}})]:f},"@index"in t&&(f[Id.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"])}if(l)if(u.includes("@graph")&&(u.includes("@id")||u.includes("@index")&&gd(t))){let i;c.hasOwnProperty(r)?i=c[r]:c[r]=i={};const o=(u.includes("@id")?t["@id"]:t["@index"])||Id.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}});jd(i,o,f,{propertyIsArray:!n.compactArrays||u.includes("@set")})}else u.includes("@graph")&&gd(t)?(ud(f)&&f.length>1&&(f={"@included":f}),jd(c,r,f,{propertyIsArray:!n.compactArrays||u.includes("@set")})):(ud(f)&&1===f.length&&n.compactArrays&&(f=f[0]),f={[Id.compactIri({activeCtx:e,iri:"@graph",relativeTo:{vocab:!0}})]:f},"@id"in t&&(f[Id.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t["@id"]),"@index"in t&&(f[Id.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"]),jd(c,r,f,{propertyIsArray:!n.compactArrays||u.includes("@set")}));else if(u.includes("@language")||u.includes("@index")||u.includes("@id")||u.includes("@type")){let i,o;if(c.hasOwnProperty(r)?i=c[r]:c[r]=i={},u.includes("@language"))hd(f)&&(f=f["@value"]),o=t["@language"];else if(u.includes("@index")){const n=vd(e,r,"@index")||"@index",i=Id.compactIri({activeCtx:e,iri:n,relativeTo:{vocab:!0}});if("@index"===n)o=t["@index"],delete f[i];else{let e;if([o,...e]=Ad(f[n]||[]),dd(o))switch(e.length){case 0:delete f[n];break;case 1:f[n]=e[0];break;default:f[n]=e}else o=null}}else if(u.includes("@id")){const t=Id.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}});o=f[t],delete f[t]}else if(u.includes("@type")){const i=Id.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}});let a;switch([o,...a]=Ad(f[i]||[]),a.length){case 0:delete f[i];break;case 1:f[i]=a[0];break;default:f[i]=a}1===Object.keys(f).length&&"@id"in t&&(f=await Id.compact({activeCtx:e,activeProperty:r,element:{"@id":t["@id"]},options:n}))}o||(o=Id.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}})),jd(i,o,f,{propertyIsArray:u.includes("@set")})}else{const e=!n.compactArrays||u.includes("@set")||u.includes("@list")||ud(f)&&0===f.length||"@list"===s||"@graph"===s;jd(c,r,f,{propertyIsArray:e})}}}return o}return r},Id.compactIri=({activeCtx:e,iri:t,value:r=null,relativeTo:n={vocab:!1},reverse:i=!1,base:o=null})=>{if(null===t)return t;e.isPropertyTermScoped&&e.previousContext&&(e=e.previousContext);const a=e.getInverse();if(_d(t)&&t in a&&"@none"in a[t]&&"@type"in a[t]["@none"]&&"@none"in a[t]["@none"]["@type"])return a[t]["@none"]["@type"]["@none"];if(n.vocab&&t in a){const n=e["@language"]||"@none",o=[];ld(r)&&"@index"in r&&!("@graph"in r)&&o.push("@index","@index@set"),ld(r)&&"@preserve"in r&&(r=r["@preserve"][0]),yd(r)?("@index"in r&&o.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in r&&o.push("@graph@id","@graph@id@set"),o.push("@graph","@graph@set","@set"),"@index"in r||o.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in r||o.push("@graph@id","@graph@id@set")):ld(r)&&!hd(r)&&o.push("@id","@id@set","@type","@set@type");let a="@language",s="@null";if(i)a="@type",s="@reverse",o.push("@set");else if(fd(r)){"@index"in r||o.push("@list");const e=r["@list"];if(0===e.length)a="@any",s="@none";else{let t=0===e.length?n:null,r=null;for(let n=0;ne.includes("_"));e&&a.push(e.replace(/^[^_]+_/,"_"))}a.push("@none");const s=e.inverse[t];for(const e of n){if(!(e in s))continue;const t=s[e][i];for(const e of a)if(e in t)return t[e]}return null}(e,t,r,o,a,s);if(null!==c)return c}if(n.vocab&&"@vocab"in e){const r=e["@vocab"];if(0===t.indexOf(r)&&t!==r){const n=t.substr(r.length);if(!e.mappings.has(n))return n}}let s=null;const c=[];let u=e.fastCurieMap;const l=t.length-1;for(let e=0;e=0;--n){const i=c[n],o=i.terms;for(const n of o){const o=n+":"+t.substr(i.iri.length);e.mappings.get(n)._prefix&&(!e.mappings.has(o)||null===r&&e.mappings.get(o)["@id"]===t)&&(null===s||Ed(o,s)<0)&&(s=o)}}if(null!==s)return s;for(const[r,n]of e.mappings)if(n&&n._prefix&&t.startsWith(r+":"))throw new cd(`Absolute IRI "${t}" confused with prefix "${r}".`,"jsonld.SyntaxError",{code:"IRI confused with prefix",context:e});if(!n.vocab){if("@base"in e){if(e["@base"]){const r=Od(Sd(o,e["@base"]),t);return xd.test(r)?`./${r}`:r}return t}return Od(o,t)}return t},Id.compactValue=({activeCtx:e,activeProperty:t,value:r,options:n})=>{if(hd(r)){const n=vd(e,t,"@type"),i=vd(e,t,"@language"),o=vd(e,t,"@direction"),a=vd(e,t,"@container")||[],s="@index"in r&&!a.includes("@index");if(!s&&"@none"!==n){if(r["@type"]===n)return r["@value"];if("@language"in r&&r["@language"]===i&&"@direction"in r&&r["@direction"]===o)return r["@value"];if("@language"in r&&r["@language"]===i)return r["@value"];if("@direction"in r&&r["@direction"]===o)return r["@value"]}const c=Object.keys(r).length,u=1===c||2===c&&"@index"in r&&!s,l="@language"in e,d=dd(r["@value"]),p=e.mappings.has(t)&&null===e.mappings.get(t)["@language"];if(u&&"@none"!==n&&(!l||!d||p))return r["@value"];const f={};return s&&(f[Id.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=r["@index"]),"@type"in r?f[Id.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=Id.compactIri({activeCtx:e,iri:r["@type"],relativeTo:{vocab:!0}}):"@language"in r&&(f[Id.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=r["@language"]),"@direction"in r&&(f[Id.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=r["@direction"]),f[Id.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=r["@value"],f}const i=bd(e,t,{vocab:!0},n),o=vd(e,t,"@type"),a=Id.compactIri({activeCtx:e,iri:r["@id"],relativeTo:{vocab:"@vocab"===o},base:n.base});return"@id"===o||"@vocab"===o||"@graph"===i?a:{[Id.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:a}};
+/**
+ * A JavaScript implementation of the JSON-LD API.
+ *
+ * @author Dave Longley
+ *
+ * @license BSD 3-Clause License
+ * Copyright (c) 2011-2022 Digital Bazaar, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the Digital Bazaar, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+const Rd=_s,Md=ic,Ld=Ls,Cd=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:e,context:t,documentLoader:r,base:n,cycles:i=new Set}){t&&Nc(t)&&t["@context"]&&(t=t["@context"]),t=Rc(t);const o=[];for(const a of t){if(Pc(a)){let t=this._get(a);t||(t=await this._resolveRemoteContext({activeCtx:e,url:a,documentLoader:r,base:n,cycles:i})),Dc(t)?o.push(...t):o.push(t);continue}if(null===a){o.push(new Cc({document:null}));continue}Nc(a)||kc(t);const s=JSON.stringify(a);let c=this._get(s);c||(c=new Cc({document:a}),this._cacheResolvedContext({key:s,resolved:c,tag:"static"})),o.push(c)}return o}_get(e){let t=this.perOpCache.get(e);if(!t){const r=this.sharedCache.get(e);r&&(t=r.get("static"),t&&this.perOpCache.set(e,t))}return t}_cacheResolvedContext({key:e,resolved:t,tag:r}){if(this.perOpCache.set(e,t),void 0!==r){let n=this.sharedCache.get(e);n||(n=new Map,this.sharedCache.set(e,n)),n.set(r,t)}return t}async _resolveRemoteContext({activeCtx:e,url:t,documentLoader:r,base:n,cycles:i}){t=Mc(n,t);const{context:o,remoteDoc:a}=await this._fetchContext({activeCtx:e,url:t,documentLoader:r,cycles:i});Bc({context:o,base:n=a.documentUrl||t});const s=await this.resolve({activeCtx:e,context:o,documentLoader:r,base:n,cycles:i});return this._cacheResolvedContext({key:t,resolved:s,tag:a.tag}),s}async _fetchContext({activeCtx:e,url:t,documentLoader:r,cycles:n}){if(n.size>10)throw new Lc("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"loading remote context failed":"context overflow",max:10});if(n.has(t))throw new Lc("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"recursive context inclusion":"context overflow",url:t});let i,o;n.add(t);try{o=await r(t),i=o.document||null,Pc(i)&&(i=JSON.parse(i))}catch(e){throw new Lc(`Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context. URL: "${t}".`,"jsonld.InvalidUrl",{code:"loading remote context failed",url:t,cause:e})}if(!Nc(i))throw new Lc(`Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object. URL: "${t}".`,"jsonld.InvalidUrl",{code:"invalid remote context",url:t});return i="@context"in i?{"@context":i["@context"]}:{"@context":{}},o.contextUrl&&(Dc(i["@context"])||(i["@context"]=[i["@context"]]),i["@context"].push(o.contextUrl)),{context:i,remoteDoc:o}}},kd=Ld.IdentifierIssuer,Bd=js,Ud=Ic,$d=Uc,{expand:qd}=Cu,{flatten:Qd}=Zu,{fromRDF:zd}=ml,{toRDF:Gd}=Bl,{frameMergedOrDefault:Vd,cleanupNull:Xd}=Kl,{isArray:Hd,isObject:Jd,isString:Wd}=Ts,{isSubjectReference:Kd}=xs,{expandIri:Yd,getInitialContext:Zd,process:ep,processingMode:tp}=lu,{compact:rp,compactIri:np}=Nd,{createNodeMap:ip,createMergedNodeMap:op,mergeNodeMaps:ap}=Ju,{logEventHandler:sp,logWarningEventHandler:cp,safeEventHandler:up,setDefaultEventHandler:lp,setupEventHandler:dp,strictEventHandler:pp,unhandledEventHandler:fp}=Gc,hp=function(e){const t={},r=new Ud({max:100});function n(t,{documentLoader:r=e.documentLoader,...n}){if(t&&"compactionMap"in t)throw new Bd('"compactionMap" not supported.',"jsonld.OptionsError");if(t&&"expansionMap"in t)throw new Bd('"expansionMap" not supported.',"jsonld.OptionsError");return Object.assign({},{documentLoader:r},n,t,{eventHandler:dp({options:t})})}return e.compact=async function(t,i,o){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");if(null===i)throw new Bd("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"});if(null===t)return null;let a;(o=n(o,{base:Wd(t)?t:"",compactArrays:!0,compactToRelative:!0,graph:!1,skipExpansion:!1,link:!1,issuer:new kd("_:b"),contextResolver:new Cd({sharedCache:r})})).link&&(o.skipExpansion=!0),o.compactToRelative||delete o.base,a=o.skipExpansion?t:await e.expand(t,o);const s=await e.processContext(Zd(o),i,o);let c=await rp({activeCtx:s,element:a,options:o});o.compactArrays&&!o.graph&&Hd(c)?1===c.length?c=c[0]:0===c.length&&(c={}):o.graph&&Jd(c)&&(c=[c]),Jd(i)&&"@context"in i&&(i=i["@context"]),i=Ld.clone(i),Hd(i)||(i=[i]);const u=i;i=[];for(let e=0;e0)&&i.push(u[e]);const l=i.length>0;if(1===i.length&&(i=i[0]),Hd(c)){const e=np({activeCtx:s,iri:"@graph",relativeTo:{vocab:!0}}),t=c;c={},l&&(c["@context"]=i),c[e]=t}else if(Jd(c)&&l){const e=c;c={"@context":i};for(const t in e)c[t]=e[t]}return c},e.expand=async function(t,i){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");const o={},a=[];if("expandContext"in(i=n(i,{keepFreeFloatingNodes:!1,contextResolver:new Cd({sharedCache:r})}))){const e=Ld.clone(i.expandContext);Jd(e)&&"@context"in e?o.expandContext=e:o.expandContext={"@context":e},a.push(o.expandContext)}let s;if(Wd(t)){const r=await e.get(t,i);s=r.documentUrl,o.input=r.document,r.contextUrl&&(o.remoteContext={"@context":r.contextUrl},a.push(o.remoteContext))}else o.input=Ld.clone(t);"base"in i||(i.base=s||"");let c=Zd(i);for(const e of a)c=await ep({activeCtx:c,localCtx:e,options:i});let u=await qd({activeCtx:c,element:o.input,options:i});return Jd(u)&&"@graph"in u&&1===Object.keys(u).length?u=u["@graph"]:null===u&&(u=[]),Hd(u)||(u=[u]),u},e.flatten=async function(t,i,o){if(arguments.length<1)return new TypeError("Could not flatten, too few arguments.");i="function"==typeof i?null:i||null,o=n(o,{base:Wd(t)?t:"",contextResolver:new Cd({sharedCache:r})});const a=await e.expand(t,o),s=Qd(a);if(null===i)return s;o.graph=!0,o.skipExpansion=!0;return await e.compact(s,i,o)},e.frame=async function(t,i,o){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");if(o=n(o,{base:Wd(t)?t:"",embed:"@once",explicit:!1,requireAll:!1,omitDefault:!1,bnodesToClear:[],contextResolver:new Cd({sharedCache:r})}),Wd(i)){const t=await e.get(i,o);if(i=t.document,t.contextUrl){let e=i["@context"];e?Hd(e)?e.push(t.contextUrl):e=[e,t.contextUrl]:e=t.contextUrl,i["@context"]=e}}const a=i&&i["@context"]||{},s=await e.processContext(Zd(o),a,o);o.hasOwnProperty("omitGraph")||(o.omitGraph=tp(s,1.1)),o.hasOwnProperty("pruneBlankNodeIdentifiers")||(o.pruneBlankNodeIdentifiers=tp(s,1.1));const c=await e.expand(t,o),u={...o};u.isFrame=!0,u.keepFreeFloatingNodes=!0;const l=await e.expand(i,u),d=Object.keys(i).map(e=>Yd(s,e,{vocab:!0}));u.merged=!d.includes("@graph"),u.is11=tp(s,1.1);const p=Vd(c,l,u);u.graph=!o.omitGraph,u.skipExpansion=!0,u.link={},u.framing=!0;let f=await e.compact(p,a,u);return u.link={},f=Xd(f,u),f},e.link=async function(t,r,n){const i={};return r&&(i["@context"]=r),i["@embed"]="@link",e.frame(t,i,n)},e.normalize=e.canonize=async function(t,i){if(arguments.length<1)throw new TypeError("Could not canonize, too few arguments.");if("inputFormat"in(i=n(i,{base:Wd(t)?t:null,algorithm:"URDNA2015",skipExpansion:!1,safe:!0,contextResolver:new Cd({sharedCache:r})}))){if("application/n-quads"!==i.inputFormat&&"application/nquads"!==i.inputFormat)throw new Bd("Unknown canonicalization input format.","jsonld.CanonizeError");const e=$d.parse(t);return Rd.canonize(e,i)}const o={...i};delete o.format,o.produceGeneralizedRdf=!1;const a=await e.toRDF(t,o);return Rd.canonize(a,i)},e.fromRDF=async function(e,r){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");r=n(r,{format:Wd(e)?"application/n-quads":void 0});const{format:i}=r;let{rdfParser:o}=r;if(i){if(o=o||t[i],!o)throw new Bd("Unknown input format.","jsonld.UnknownFormat",{format:i})}else o=()=>e;const a=await o(e);return zd(a,r)},e.toRDF=async function(t,i){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");let o;o=(i=n(i,{base:Wd(t)?t:"",skipExpansion:!1,contextResolver:new Cd({sharedCache:r})})).skipExpansion?t:await e.expand(t,i);const a=Gd(o,i);if(i.format){if("application/n-quads"===i.format||"application/nquads"===i.format)return $d.serialize(a);throw new Bd("Unknown output format.","jsonld.UnknownFormat",{format:i.format})}return a},e.createNodeMap=async function(t,i){if(arguments.length<1)throw new TypeError("Could not create node map, too few arguments.");i=n(i,{base:Wd(t)?t:"",contextResolver:new Cd({sharedCache:r})});const o=await e.expand(t,i);return op(o,i)},e.merge=async function(t,i,o){if(arguments.length<1)throw new TypeError("Could not merge, too few arguments.");if(!Hd(t))throw new TypeError('Could not merge, "docs" must be an array.');i="function"==typeof i?null:i||null,o=n(o,{contextResolver:new Cd({sharedCache:r})});const a=await Promise.all(t.map(t=>{const r={...o};return e.expand(t,r)}));let s=!0;"mergeNodes"in o&&(s=o.mergeNodes);const c=o.issuer||new kd("_:b"),u={"@default":{}};for(let e=0;ee._documentLoader,set:t=>e._documentLoader=t}),e.documentLoader=async e=>{throw new Bd("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",url:e})},e.get=async function(t,r){let n;n="function"==typeof r.documentLoader?r.documentLoader:e.documentLoader;const i=await n(t);try{if(!i.document)throw new Bd("No remote document found at the given URL.","jsonld.NullRemoteDocument");Wd(i.document)&&(i.document=JSON.parse(i.document))}catch(e){throw new Bd("Could not retrieve a JSON-LD document from the URL.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:i})}return i},e.processContext=async function(e,t,i){return i=n(i,{base:"",contextResolver:new Cd({sharedCache:r})}),null===t?Zd(i):(t=Ld.clone(t),Jd(t)&&"@context"in t||(t={"@context":t}),ep({activeCtx:e,localCtx:t,options:i}))},e.getContextValue=lu.getContextValue,e.documentLoaders={},e.useDocumentLoader=function(t){if(!(t in e.documentLoaders))throw new Bd('Unknown document loader type: "'+t+'"',"jsonld.UnknownDocumentLoader",{type:t});e.documentLoader=e.documentLoaders[t].apply(e,Array.prototype.slice.call(arguments,1))},e.registerRDFParser=function(e,r){t[e]=r},e.unregisterRDFParser=function(e){delete t[e]},e.registerRDFParser("application/n-quads",$d.parse),e.registerRDFParser("application/nquads",$d.parse),e.url=Vs(),e.logEventHandler=sp,e.logWarningEventHandler=cp,e.safeEventHandler=up,e.setDefaultEventHandler=lp,e.strictEventHandler=pp,e.unhandledEventHandler=fp,e.util=Ld,Object.assign(e,Ld),e.promises=e,e.RequestQueue=Gs(),e.JsonLdProcessor=(Dd||(Dd=1,Fd=e=>{class t{toString(){return"[object JsonLdProcessor]"}}return Object.defineProperty(t,"prototype",{writable:!1,enumerable:!1}),Object.defineProperty(t.prototype,"constructor",{writable:!0,enumerable:!1,configurable:!0,value:t}),t.compact=function(t,r){return arguments.length<2?Promise.reject(new TypeError("Could not compact, too few arguments.")):e.compact(t,r)},t.expand=function(t){return arguments.length<1?Promise.reject(new TypeError("Could not expand, too few arguments.")):e.expand(t)},t.flatten=function(t){return arguments.length<1?Promise.reject(new TypeError("Could not flatten, too few arguments.")):e.flatten(t)},t}),Fd)(e),Md.setupGlobals(e),Md.setupDocumentLoaders(e),e},yp=function(){return hp(function(){return yp()})};hp(yp);var gp=yp,mp=r({__proto__:null,default:i(gp)},[gp]);const bp={ERROR:0,WARN:1,INFO:2,DEBUG:3},vp="true"===new URLSearchParams(window.location.search).get("debug")?bp.DEBUG:bp.WARN;function _p(e,...t){if(e<=vp)switch(e){case bp.ERROR:console.error(...t);break;case bp.WARN:console.warn(...t);break;case bp.INFO:console.info(...t);break;case bp.DEBUG:console.log(...t)}}function wp(...e){_p(bp.ERROR,...e)}function Tp(...e){_p(bp.WARN,...e)}function Op(...e){_p(bp.INFO,...e)}function Sp(...e){_p(bp.DEBUG,...e)}const xp={jsonData:null,shaclShapes:null,shaclShapesStore:null,isEditMode:!1,originalData:null,validationReport:null,fileId:null,siteUrl:null,originalFileName:"cdi-metadata.jsonld",isEmbeddedMode:!1,expandedJsonLd:null,currentShapeSource:null,hadOriginalGraph:!0,defaultTypeNamespace:null},jp=new Set;function Ap(e){jp.add(e),"undefined"!=typeof window&&window.updateSaveButtonVisibility&&window.updateSaveButtonVisibility()}function Ep(){jp.clear(),"undefined"!=typeof window&&window.updateSaveButtonVisibility&&window.updateSaveButtonVisibility()}function Ip(){return xp.jsonData}function Fp(e){xp.jsonData=e}function Dp(e){xp.shaclShapes=e}function Np(){return xp.shaclShapesStore}function Pp(e){xp.shaclShapesStore=e}function Rp(){return xp.isEditMode}function Mp(e){xp.originalData=e}function Lp(){return xp.fileId}function Cp(e){xp.fileId=e}function kp(){return xp.siteUrl}function Bp(e){xp.siteUrl=e}function Up(){return xp.originalFileName}function $p(e){xp.originalFileName=e}function qp(){return xp.expandedJsonLd}function Qp(e){xp.expandedJsonLd=e}function zp(e){xp.currentShapeSource=e}function Gp(e){xp.hadOriginalGraph=e}function Vp(){return xp.defaultTypeNamespace}function Xp(e){xp.defaultTypeNamespace=e}const Hp={"ddi-cdi-official":"https://ddi-cdi.github.io/m2t-ng/DDI-CDI_1-0/encoding/shacl/ddi-cdi.shacl.ttl","cdif-core":"shapes/cdif-core.ttl","cdif-core-shacl":"shapes/cdif-core.ttl","dcat-ap":"https://semiceu.github.io/DCAT-AP/releases/3.0.0/html/shacl/shapes.ttl",datacube:"https://raw.githubusercontent.com/w3c/shacl/master/shapes/datacube.shapes.ttl",skos:"https://raw.githubusercontent.com/skohub-io/skohub-shapes/main/skos.shacl.ttl","local-fallback":"shapes/ddi-cdi-official.ttl"};"undefined"!=typeof window&&(window.LOG_LEVEL=bp,window.log=_p,window.SHAPE_URLS=Hp,window.state=xp);let Jp=class{constructor(e){this.value=e}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value}};Jp.prototype.termType="BlankNode";let Wp=class{equals(e){return!!e&&e.termType===this.termType}};function Kp(e,t){if(!t)return null;if("BlankNode"===t.termType)return e.blankNode(t.value);if("DefaultGraph"===t.termType)return e.defaultGraph();if("Literal"===t.termType)return e.literal(t.value,t.language||e.namedNode(t.datatype.value));if("NamedNode"===t.termType)return e.namedNode(t.value);if("Quad"===t.termType){const r=e.fromTerm(t.subject),n=e.fromTerm(t.predicate),i=e.fromTerm(t.object),o=e.fromTerm(t.graph);return e.quad(r,n,i,o)}if("Variable"===t.termType)return e.variable(t.value);throw new Error(`unknown termType ${t.termType}`)}Wp.prototype.termType="DefaultGraph",Wp.prototype.value="";let Yp=class{constructor(e,t,r,n=""){this.value=e,this.language=t,this.datatype=r,this.direction=n}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value&&e.language===this.language&&e.datatype.equals(this.datatype)&&(e.direction||"")===this.direction}};Yp.prototype.termType="Literal";let Zp=class{constructor(e){this.value=e}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value}};Zp.prototype.termType="NamedNode";let ef=class{constructor(e,t,r,n){this.subject=e,this.predicate=t,this.object=r,this.graph=n}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&e.subject.equals(this.subject)&&e.predicate.equals(this.predicate)&&e.object.equals(this.object)&&e.graph.equals(this.graph)}};ef.prototype.termType="Quad",ef.prototype.value="";let tf=class{constructor(e){this.value=e}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value}};tf.prototype.termType="Variable";const rf=new Zp("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"),nf=new Zp("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),of=new Zp("http://www.w3.org/2001/XMLSchema#string");let af=class{constructor(){this.init()}init(){this._data={blankNodeCounter:0,defaultGraph:new Wp}}namedNode(e){return new Zp(e)}blankNode(e){return e=e||"b"+ ++this._data.blankNodeCounter,new Jp(e)}literal(e,t){return"string"==typeof t?new Yp(e,t,nf):"string"==typeof t?.language?new Yp(e,t.language,t.direction?rf:nf,t.direction):new Yp(e,"",t||of)}variable(e){return new tf(e)}defaultGraph(){return this._data.defaultGraph}quad(e,t,r,n=this.defaultGraph()){return new ef(e,t,r,n)}fromTerm(e){return Kp(this,e)}fromQuad(e){return Kp(this,e)}};af.exports=["blankNode","defaultGraph","fromQuad","fromTerm","literal","namedNode","quad","variable"];const sf=new af;function cf(e){return"string"==typeof e||e instanceof String}function uf(e){if("string"==typeof e)return e;if(!e)return"";if(void 0!==e.id&&"Quad"!==e.termType)return e.id;let t,r,n,i;switch(e.termType){case"NamedNode":return e.value;case"BlankNode":return`_:${e.value}`;case"Variable":return`?${e.value}`;case"DefaultGraph":return"";case"Literal":return e.language?`"${e.value}"@${e.language}`:`"${e.value}"${e.datatype&&"http://www.w3.org/2001/XMLSchema#string"!==e.datatype.value?`^^${e.datatype.value}`:""}`;case"Quad":return t=df(uf(e.subject)),r=df(uf(e.predicate)),n=df(uf(e.object)),i="DefaultGraph"===e.graph.termType?"":` ${uf(e.graph)}`,`<<${t} ${r} ${n}${i}>>`;default:throw new Error(`Unexpected termType: ${e.termType}`)}}const lf=/^"(.*".*)(?="[^"]*$)/;function df(e){return e.replace(lf,(e,t)=>`"${t.replace(/"/g,'""')}`)}class pf{constructor(e){if(this._size=0,this._graphs=Object.create(null),this._id=0,this._ids=Object.create(null),this._ids["><"]=0,this._entities=Object.create(null),this._quads=new Map,e)for(const t of e)this.add(t)}get size(){let e=this._size;if(null!==e)return e;e=0;const t=this._graphs;let r,n;for(const i in t)for(const o in r=t[i].subjects)for(const t in n=r[o])e+=Object.keys(n[t]).length;return this._size=e,this._size}add(e){let t=uf(e.subject),r=uf(e.predicate),n=uf(e.object);const i=uf(e.graph);let o=this._graphs[i];o||(o=this._graphs[i]={subjects:{},predicates:{},objects:{}},Object.freeze(o));const a=this._ids,s=this._entities;return t=a[t]||(a[s[++this._id]=t]=this._id),r=a[r]||(a[s[++this._id]=r]=this._id),n=a[n]||(a[s[++this._id]=n]=this._id),this._addToIndex(o.subjects,t,r,n),this._addToIndex(o.predicates,r,n,t),this._addToIndex(o.objects,n,t,r),this._setQuad(t,r,n,i,e),this._size=null,this}delete(e){let t=uf(e.subject),r=uf(e.predicate),n=uf(e.object);const i=uf(e.graph),o=this._ids,a=this._graphs;let s,c,u;if(!((t=o[t])&&(r=o[r])&&(n=o[n])&&(s=a[i])&&(c=s.subjects[t])&&(u=c[r])&&n in u))return this;for(t in this._removeFromIndex(s.subjects,t,r,n),this._removeFromIndex(s.predicates,r,n,t),this._removeFromIndex(s.objects,n,t,r),null!==this._size&&this._size--,this._deleteQuad(t,r,n,i),s.subjects)return this;return delete a[i],this}has(e){const t=uf(e.subject),r=uf(e.predicate),n=uf(e.object),i=uf(e.graph),o=this._graphs[i];if(!o)return!1;const a=this._ids;let s,c,u;return!(cf(t)&&!(s=a[t])||cf(r)&&!(c=a[r])||cf(n)&&!(u=a[n]))&&1===this._countInIndex(o.objects,u,s,c)}match(e,t,r,n){return this._createDataset(this._match(e,t,r,n))}[Symbol.iterator](){return this._match()[Symbol.iterator]()}_addToIndex(e,t,r,n){const i=e[t]||(e[t]={}),o=i[r]||(i[r]={}),a=n in o;return a||(o[n]=null),!a}_removeFromIndex(e,t,r,n){const i=e[t],o=i[r];delete o[n];for(const e in o)return;delete i[r];for(const e in i)return;delete e[t]}_findInIndex(e,t,r,n,i,o,a,s,c,u){let l,d,p;t&&((l=e,e={})[t]=l[t]);for(const t in e)if(d=e[t],d){r&&((l=d,d={})[r]=l[r]);for(const e in d)if(p=d[e],p){const r=n?n in p?[n]:[]:Object.keys(p);for(let n=0;n"}const gf=/["\\\\\n\r]/,mf=/["\\\\\n\r]/g,bf={'"':'\\"',"\\":"\\\\","\n":"\\n","\r":"\\r"};function vf(e){return bf[e]}function _f(e){const t=(r=e.value,gf.test(r)?r.replace(mf,vf):r);var r;return"http://www.w3.org/2001/XMLSchema#string"===e.datatype.value?'"'+t+'"':"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"===e.datatype.value?'"'+t+'"@'+e.language:'"'+t+'"^^'+yf(e.datatype)}function wf(e){if(!e)return null;if("BlankNode"===e.termType)return function(e){return"_:"+e.value}(e);if("DefaultGraph"===e.termType)return"";if("Literal"===e.termType)return _f(e);if("NamedNode"===e.termType)return yf(e);if("Quad"===e.termType||e.subject&&e.predicate&&e.object&&e.graph)return function(e,t){const r=t(e.subject),n=t(e.predicate),i=t(e.object),o=t(e.graph);return`${r} ${n} ${i} ${o?o+" ":""}.`}(e,wf);if("Variable"===e.termType)return function(e){return"?"+e.value}(e);if(e[Symbol.iterator])return function(e,t){return[...e].map(e=>t(e)).join("\n")+"\n"}(e,wf);throw new Error(`unknown termType ${e.termType}`)}class Tf{constructor(e){if(this.index=new Map,e)for(const[t,r]of e)this.set(t,r)}get size(){return this.index.size}clear(){this.index.clear()}delete(e){return this.index.delete(wf(e))}*entries(){for(const[,{term:e,value:t}]of this.index)yield[e,t]}forEach(e,t){for(const r of this.entries())e.call(t,r[1],r[0],this)}get(e){const t=this.index.get(wf(e));return t&&t.value}has(e){return this.index.has(wf(e))}*keys(){for(const[,{term:e}]of this.index)yield e}set(e,t){const r=wf(e);return this.index.set(r,{term:e,value:t}),this}*values(){for(const[,{value:e}]of this.index)yield e}[Symbol.iterator](){return this.entries()[Symbol.iterator]()}}class Of{constructor({dataset:e,end:t,quad:r,start:n}){this.dataset=e,this.end=t,this.quad=r,this.start=n}get term(){return this.quad[this.end]}get graph(){return this.quad.graph}get startTerm(){return this.quad[this.start]}}function Sf(e){try{return wf(e)}catch(e){return null}}class xf{constructor(e){if(this.index=new Map,e)for(const t of e)this.add(t)}get size(){return this.index.size}add(e){const t=wf(e);return this.index.has(t)||this.index.set(t,e),this}clear(){this.index.clear()}delete(e){return!!e&&this.index.delete(Sf(e))}entries(){return this.values().entries()}forEach(e,t){return this.values().forEach(e,t)}has(e){return!!e&&this.index.has(Sf(e))}values(){return new Set(this.index.values())}keys(){return this.values()}[Symbol.iterator](){return this.index.values()}}const jf={apply:(e,t,r)=>e(r[0]),get:(e,t)=>e(t)};function Af(e,{factory:t=sf}={}){const r=(r="")=>t.namedNode(`${e}${r.raw||r}`);return"undefined"==typeof Proxy?r:new Proxy(r,jf)}Af("http://www.w3.org/2001/XMLSchema#");const Ef=Af("http://www.w3.org/1999/02/22-rdf-syntax-ns#");Af("http://www.w3.org/2000/01/rdf-schema#");class If{static add({ptr:e,start:t,end:r,subjects:n=[null],predicates:i=[null],objects:o=[null],graphs:a,callback:s}={}){if(!e.factory)throw new Error("add operation requires a factory");let c=()=>{};s&&(c=n=>{s(new Of({dataset:e.dataset,start:t,end:r,quad:n}))});for(const r of n)for(const n of i)for(const i of o)for(const o of a){const a={subject:r,predicate:n,object:i,graph:o};a[t]=e.term;const s=e.factory.quad(a.subject,a.predicate,a.object,a.graph);e.dataset.add(s),c(s)}return e}static addList({ptr:e,predicates:t,items:r,graphs:n}){if(e.isAny())throw new Error("can't attach a list to an any ptr");for(const i of t)for(const t of n){const n=r.map(()=>e.factory.blankNode());e.dataset.add(e.factory.quad(e.term,i,n[0]||Ef.nil,t));for(let i=0;i!u.has(e.term))),e=c,l=[...l,...c],u=new xf(l.map(e=>e.term))}while(c.length>0);return l}static traverseOne({ptr:e,start:t,end:r,subjects:n,predicates:i,objects:o,graphs:a,callback:s=(e,t)=>t.extend(e)}={}){const c=[];for(const u of n)for(const n of i)for(const i of o)for(const o of a){const a={subject:u,predicate:n,object:i,graph:o};a[t]=e.term;for(const n of e.dataset.match(a.subject,a.predicate,a.object,a.graph))c.push(s(new Of({dataset:e.dataset,end:r,quad:n,start:t}),e))}return c}}function Ff(e,t){return t?r=>t(e.extend(r)):()=>{}}class Df{constructor({dataset:e,edges:t=[],factory:r,graph:n,term:i}){if(!e&&0===t.length)throw new Error("dataset or edges is required");if(0===t.length&&void 0===i)throw new Error("edges or term must be given");if(t.length>0&&i)throw new Error("edges or term must be given");this.dataset=e||t[t.length-1].dataset,this.edges=t,this.factory=r,this._graph=n,0===t.length&&(this._term=i)}get edge(){return this.edges[this.edges.length-1]}get graph(){return"object"==typeof this._graph?this._graph:this.edge&&this.edge.graph}get length(){return void 0!==this._term?1:this.edges.length+1}get startTerm(){return this._term||this.edges[0].startTerm}get term(){return void 0!==this._term?this._term:this.edge.term}get value(){const e=this.term;return null===e?void 0:e.value}addIn(e,t,r){return If.add({ptr:this,start:"object",end:"subject",subjects:t,predicates:e,graphs:[this.graph||this.factory.defaultGraph()],callback:Ff(this,r)})}addList(e,t){return If.addList({ptr:this,predicates:e,graphs:[this.graph||this.factory.defaultGraph()],items:t})}addOut(e,t,r){return If.add({ptr:this,start:"subject",end:"object",predicates:e,objects:t,graphs:[this.graph||this.factory.defaultGraph()],callback:Ff(this,r)})}deleteIn(e,t){return If.delete({ptr:this,start:"object",subjects:t,predicates:e})}deleteList(e){return If.deleteList({ptr:this,predicates:e})}deleteOut(e,t){return If.delete({ptr:this,start:"subject",predicates:e,objects:t})}execute({operation:e,quantifier:t,start:r,end:n,subjects:i,predicates:o,objects:a,graphs:s,items:c,callback:u}){return If.execute({ptr:this,operation:e,quantifier:t,start:r,end:n,subjects:i,predicates:o,objects:a,graphs:s,items:c,callback:u})}extend(e){return new this.constructor({dataset:this.dataset,edges:[...this.edges,e],factory:this.factory,graph:this._graph})}hasIn(e,t){return If.traverse({ptr:this,start:"object",end:"object",subjects:t,predicates:e,graphs:[this.graph]})}hasOut(e,t){return If.traverse({ptr:this,start:"subject",end:"subject",predicates:e,objects:t,graphs:[this.graph]})}in(e,t){return If.traverse({ptr:this,start:"object",end:"subject",subjects:t,predicates:e,graphs:[this.graph]})}isAny(){return!this.term}isList(){return If.isList({ptr:this})}list(){return If.list({ptr:this})}*nodes(){for(let e=0;ee?yield{dataset:this.edges[e].dataset,term:this.edges[e].startTerm}:this.edges.length===e&&(yield{dataset:this.edges[e-1].dataset,term:this.edges[e-1].term})}out(e,t){return If.traverse({ptr:this,predicates:e,objects:t,graphs:[this.graph]})}*quads(){for(const{quad:e}of this.edges)yield e}trim(){return new this.constructor({dataset:this.dataset,factory:this.factory,graph:this.graph,term:this.term})}}function Nf(e,t){return e?e.equals(t):e===t}function Pf(e,t){return t?r=>t(new e.constructor({factory:e.factory,ptrs:[r]})):()=>{}}class Rf{constructor({dataset:e,factory:t,ptrs:r,terms:n,graphs:i}){if(this.factory=t,r)this.ptrs=[...r];else{this.ptrs=[];for(const r of n||[null])for(const n of i||[null])this.ptrs.push(new Df({dataset:e,factory:t,graph:n,term:r}))}}get dataset(){const e=new Set(this.datasets);return 1!==e.size?null:e[Symbol.iterator]().next().value}get datasets(){return this.ptrs.map(e=>e.dataset)}get term(){const e=new xf(this.terms);if(1===e.size)return e[Symbol.iterator]().next().value}get terms(){return this.ptrs.map(e=>e.term)}get value(){const e=this.term;return null==e?void 0:e.value}get values(){return this.ptrs.map(e=>e.value)}addIn(e,t,r){const n=Pf(this,r);for(const r of this.ptrs)r.addIn(e,t,n);return this}addList(e,t){if(this.isAny())throw new Error("can't attach a list to an any ptr");for(const r of this.ptrs)r.addList(e,t);return this}addOut(e,t,r){const n=Pf(this,r);for(const r of this.ptrs)r.addOut(e,t,n);return this}clone(e){return new this.constructor({factory:this.factory,ptrs:this.ptrs,...e})}deleteIn(e,t){for(const r of this.ptrs)r.deleteIn(e,t);return this}deleteList(e){for(const t of this.ptrs)t.deleteList(e);return this}deleteOut(e,t){for(const r of this.ptrs)r.deleteOut(e,t);return this}distinct(){const e=this.ptrs.reduce((e,t)=>(e.some(e=>{return n=t,(r=e).dataset===n.dataset&&!!Nf(r.graph,n.graph)&&!!Nf(r.term,n.term);var r,n})||e.push(t.trim()),e),[]);return this.clone({ptrs:e})}execute(e){return this.clone({ptrs:this.ptrs.flatMap(t=>t.execute(e))})}executeAll(e){let t=this;for(const r of e)t=t.execute(r);return t}filter(e){return this.clone({ptrs:[...this].filter(e).map(e=>e.ptrs[0])})}hasIn(e,t){return this.clone({ptrs:this.ptrs.flatMap(r=>r.hasIn(e,t))})}hasOut(e,t){return this.clone({ptrs:this.ptrs.flatMap(r=>r.hasOut(e,t))})}in(e,t){return this.clone({ptrs:this.ptrs.flatMap(r=>r.in(e,t))})}isAny(){return this.ptrs.length>0&&this.ptrs.some(e=>e.isAny())}isList(){return 1===this.ptrs.length&&this.ptrs[0].isList()}list(){if(!this.isList())return;const e=this.ptrs[0].list(),t=this;return function*(){for(const r of e)yield t.clone({ptrs:[r]})}()}map(e){return[...this].map(e)}node(e){const t=this.dataset,r=[...e].map(e=>new Df({dataset:t,factory:this.factory,term:e}));return this.clone({ptrs:r})}out(e,t){return this.clone({ptrs:this.ptrs.flatMap(r=>r.out(e,t))})}*quads(){for(const{edges:e}of this.ptrs)for(const{quad:t}of e)yield t}trim(){return this.clone({ptrs:this.ptrs.map(e=>e.trim())})}*[Symbol.iterator](){for(const e of this.ptrs)yield this.clone({ptrs:[e]})}}const Mf=Af("http://www.w3.org/2002/07/owl#"),Lf=Af("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),Cf=Af("http://www.w3.org/2000/01/rdf-schema#"),kf=Af("http://www.w3.org/ns/shacl#"),Bf=Af("https://schemas.link/shacl-next#"),Uf=Af("http://www.w3.org/2001/XMLSchema#");function $f(e){return e?`{${e.map(e=>function(e){return e?`{${[...e.quads()].map(e=>wf(e)).join(" ")}}`:"{}"}(e)).join(" ")}}`:"{}"}var qf=/\s/;var Qf=function(e){for(var t=e.length;t--&&qf.test(e.charAt(t)););return t},zf=Qf,Gf=/^\s+/;var Vf=function(e){return e?e.slice(0,zf(e)+1).replace(Gf,""):e};var Xf=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Hf="object"==typeof n&&n&&n.Object===Object&&n,Jf="object"==typeof self&&self&&self.Object===Object&&self,Wf=(Hf||Jf||Function("return this")()).Symbol,Kf=Wf,Yf=Object.prototype,Zf=Yf.hasOwnProperty,eh=Yf.toString,th=Kf?Kf.toStringTag:void 0;var rh=function(e){var t=Zf.call(e,th),r=e[th];try{e[th]=void 0;var n=!0}catch(e){}var i=eh.call(e);return n&&(t?e[th]=r:delete e[th]),i},nh=Object.prototype.toString;var ih=rh,oh=function(e){return nh.call(e)},ah=Wf?Wf.toStringTag:void 0;var sh=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ah&&ah in Object(e)?ih(e):oh(e)},ch=function(e){return null!=e&&"object"==typeof e};var uh=Vf,lh=Xf,dh=function(e){return"symbol"==typeof e||ch(e)&&"[object Symbol]"==sh(e)},ph=/^[-+]0x[0-9a-f]+$/i,fh=/^0b[01]+$/i,hh=/^0o[0-7]+$/i,yh=parseInt;var gh=function(e){if("number"==typeof e)return e;if(dh(e))return NaN;if(lh(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=lh(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=uh(e);var r=fh.test(e);return r||hh.test(e)?yh(e.slice(2),r?2:8):ph.test(e)?NaN:+e},mh=1/0;var bh=function(e){return e?(e=gh(e))===mh||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};var vh=function(e){var t=bh(e),r=t%1;return t==t?r?t-r:t:0};var _h=function(e,t){var r;if("function"!=typeof t)throw new TypeError("Expected a function");return e=vh(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=void 0),r}},wh=_h;var Th=i(function(e){return wh(2,e)});let Oh=class{constructor({details:e,factory:t,options:r,results:n=[]}={}){this.details=e,this.factory=t,this.options=r,this.results=n,this._conforms=Th(()=>!this.results.some(e=>e.severity.equals(kf.Info)||e.severity.equals(kf.Violation)||e.severity.equals(kf.Warning))),this._ptr=Th(()=>this.build())}get conforms(){return this._conforms()}get dataset(){return this.ptr.dataset}get ptr(){return this._ptr()}get term(){return this.ptr.term}build(){const e=new Rf({dataset:this.factory.dataset(),factory:this.factory,terms:[this.factory.blankNode()]});e.addOut([Lf.type],[kf.ValidationReport]).addOut([kf.conforms],[this.factory.literal(this.conforms.toString(),Uf.boolean)]);for(const t of this.results)e.addOut([kf.result],[this.factory.blankNode()],e=>{t.build(e,this.options)});return e}coverage(){return this.results.flatMap(e=>e.coverage())}};let Sh=class{constructor({args:e={},constraintComponent:t,factory:r,focusNode:n,message:i=[],path:o,results:a=[],severity:s,shape:c,source:u=[],value:l,valuePaths:d=[]}={}){this.args=e,this.constraintComponent=t,this.factory=r,this.focusNode=n,this.path=o||c.path,this.results=a,this.severity=s,this.shape=c,this.source=u,this.value=l,this.valuePaths=d,this._message=Th(()=>(this.shape.message.length>0&&(i=this.shape.message),0===i.length&&(i=this.shape.ptr.node([this.constraintComponent]).out([kf.message]).terms),i.map(t=>r.literal(function(e,t){return Object.entries(t).reduce((e,[t,r])=>(r&&r.termType&&(r=wf(r)),e.replace(`{$${t}}`,r).replace(`{?${t}}`,r)),e)}(t.value,e),t.language||null))))}get message(){return this._message()}build(e,{details:t}={}){e.addOut([Lf.type],[kf.ValidationResult]).addOut([kf.focusNode],this.focusNode.terms).addOut([kf.resultSeverity],[this.severity]).addOut([kf.sourceConstraint],this.source).addOut([kf.sourceConstraintComponent],[this.constraintComponent]).addOut([kf.sourceShape],this.shape.ptr.terms),this.message&&e.addOut([kf.resultMessage],this.message);const r=t=>"one"===t.quantifier?t.predicates.length>1?e.node([this.factory.blankNode()]).addList([kf.alternativePath],t.predicates):"object"===t.start?e.node([this.factory.blankNode()]).addOut([kf.inversePath],[t.predicates[0]]):e.node([t.predicates[0]]):"oneOrMore"===t.quantifier?e.node([this.factory.blankNode()]).addOut([kf.oneOrMorePath],[t.predicates[0]]):"zeroOrMore"===t.quantifier?e.node([this.factory.blankNode()]).addOut([kf.zeroOrMorePath],[t.predicates[0]]):"zeroOrOne"===t.quantifier?e.node([this.factory.blankNode()]).addOut([kf.zeroOrOnePath],[t.predicates[0]]):void 0;if(this.path&&(1===this.path.length?e.addOut([kf.resultPath],r(this.path[0]).terms):e.addList([kf.resultPath],this.path.map(e=>r(e).term))),void 0!==this.value&&e.addOut([kf.value],this.value.terms),t)for(const r of this.results)e.addOut([kf.detail],[this.factory.blankNode()],e=>{r.build(e,{details:t})})}coverage(){return[...this.valuePaths.flatMap(e=>[...e.quads()]),...this.results.flatMap(e=>e.coverage())]}},xh=class e{constructor({factory:e,focusNode:t,options:r={debug:!1,details:!1},processed:n=new Set,report:i=new Oh({factory:e,options:r}),results:o=new Map,shape:a,value:s,valueOrNode:c,valuePaths:u,values:l}={}){this.factory=e,this.focusNode=t,this.options=r,this.processed=n,this.report=i,this.results=o,this.shape=a,this.value=s,this.valuePaths=u,this.valueOrNode=c,this.values=l}create({child:t,focusNode:r=this.focusNode,shape:n=this.shape,value:i=this.value,valueOrNode:o=this.valueOrNode,valuePaths:a=this.valuePaths,values:s=this.values}={}){return new e({factory:this.factory,focusNode:r,options:this.options,processed:this.processed,report:t?new Oh({factory:this.factory,options:this.options}):this.report,results:this.results,shape:n,value:i,valueOrNode:o,valuePaths:a,values:s})}id({shape:e=this.shape}={}){return`${wf(e.ptr.term)} - ${wf(this.focusNode.term)} - ${$f(this.valuePaths)}`}result(e){const t=new Sh({factory:this.factory,focusNode:this.focusNode,shape:this.shape,value:this.value,valuePaths:this.valuePaths,...e}),r=this.id();this.results.has(r)?this.results.get(r).add(t):this.results.set(r,new Set([t])),this.report.results.push(t)}debug(e,t){this.options.debug&&this.result({severity:Bf.Debug,constraintComponent:e,...t})}trace(e,t){this.options.trace&&this.result({severity:Bf.Trace,constraintComponent:e,...t})}test(e,t,r){e?this.debug(t,r):this.violation(t,r)}violation(e,t){this.result({constraintComponent:e,severity:this.shape.severity||kf.Violation,...t})}};function jh(){return{generic:e=>{e.trace(Bf.TraversalConstraintComponent,{args:{},message:[e.factory.literal("Traversal")],value:e.valueOrNode})}}}class Ah{constructor(e){this.validations=new Tf(e)}compile(e){const t=e.validator.options.coverage;if(e.deactivated)return[];let r=!1;const n=new Set;for(const t of e.ptr.execute({start:"subject",end:"predicate"})){const e=this.validations.get(t.term);e&&(n.add(e),t.term.equals(kf.property)&&(r=!0))}return t&&e.isPropertyShape&&!r&&n.add(jh),[...n].map(t=>t(e)).filter(Boolean)}}var Eh={},Ih={},Fh={};Object.defineProperty(Fh,"__esModule",{value:!0}),Fh.BlankNode=void 0;Fh.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}};var Dh={},Nh={};Object.defineProperty(Nh,"__esModule",{value:!0}),Nh.DefaultGraph=void 0;let Ph=class{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}};Nh.DefaultGraph=Ph,Ph.INSTANCE=new Ph;var Rh={},Mh={};Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.NamedNode=void 0;Mh.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}},Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.Literal=void 0;const Lh=Mh;let Ch=class e{constructor(t,r){this.termType="Literal",this.value=t,"string"==typeof r?(this.language=r,this.datatype=e.RDF_LANGUAGE_STRING,this.direction=""):r?"termType"in r?(this.language="",this.datatype=r,this.direction=""):(this.language=r.language,this.datatype=r.direction?e.RDF_DIRECTIONAL_LANGUAGE_STRING:e.RDF_LANGUAGE_STRING,this.direction=r.direction||""):(this.language="",this.datatype=e.XSD_STRING,this.direction="")}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&(e.direction===this.direction||!e.direction&&""===this.direction)&&this.datatype.equals(e.datatype)}};Rh.Literal=Ch,Ch.RDF_LANGUAGE_STRING=new Lh.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),Ch.RDF_DIRECTIONAL_LANGUAGE_STRING=new Lh.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"),Ch.XSD_STRING=new Lh.NamedNode("http://www.w3.org/2001/XMLSchema#string");var kh={};Object.defineProperty(kh,"__esModule",{value:!0}),kh.Quad=void 0;kh.Quad=class{constructor(e,t,r,n){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=n}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}};var Bh={};Object.defineProperty(Bh,"__esModule",{value:!0}),Bh.Variable=void 0;Bh.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}},Object.defineProperty(Dh,"__esModule",{value:!0}),Dh.DataFactory=void 0;const Uh=Fh,$h=Nh,qh=Rh,Qh=Mh,zh=kh,Gh=Bh;let Vh=0;var Xh,Hh,Jh;Dh.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${Vh++}_`}namedNode(e){return new Qh.NamedNode(e)}blankNode(e){return new Uh.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new qh.Literal(e,t)}variable(e){return new Gh.Variable(e)}defaultGraph(){return $h.DefaultGraph.INSTANCE}quad(e,t,r,n){return new zh.Quad(e,t,r,n||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(qh.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}},Xh=Ih,Hh=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Jh=n&&n.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||Hh(t,e,r)},Object.defineProperty(Xh,"__esModule",{value:!0}),Jh(Fh,Xh),Jh(Dh,Xh),Jh(Nh,Xh),Jh(Rh,Xh),Jh(Mh,Xh),Jh(kh,Xh),Jh(Bh,Xh);var Wh={},Kh={},Yh={};Object.defineProperty(Yh,"__esModule",{value:!0}),Yh.Translator=void 0;Yh.Translator=class{constructor(){this.supportedRdfDatatypes=[],this.fromRdfHandlers={},this.toRdfHandlers={}}static incorrectRdfDataType(e){throw new Error(`Invalid RDF ${e.datatype.value} value: '${e.value}'`)}registerHandler(e,t,r){for(const r of t)this.supportedRdfDatatypes.push(r),this.fromRdfHandlers[r.value]=e;for(const t of r){let r=this.toRdfHandlers[t];r||(this.toRdfHandlers[t]=r=[]),r.push(e)}}fromRdf(e,t){const r=this.fromRdfHandlers[e.datatype.value];return r?r.fromRdf(e,t):e.value}toRdf(e,t){const r=this.toRdfHandlers[typeof e];if(r)for(const n of r){const r=n.toRdf(e,t);if(r)return r}throw new Error(`Invalid JavaScript value: '${e}'`)}getSupportedRdfDatatypes(){return this.supportedRdfDatatypes}getSupportedJavaScriptPrimitives(){return Object.keys(this.toRdfHandlers)}},Object.defineProperty(Kh,"__esModule",{value:!0}),Kh.TypeHandlerBoolean=void 0;const Zh=Yh;class ey{fromRdf(e,t){switch(e.value){case"true":case"1":return!0;case"false":case"0":return!1}return t&&Zh.Translator.incorrectRdfDataType(e),!1}toRdf(e,{datatype:t,dataFactory:r}){return r.literal(e?"true":"false",t||r.namedNode(ey.TYPE))}}Kh.TypeHandlerBoolean=ey,ey.TYPE="http://www.w3.org/2001/XMLSchema#boolean";var ty={};Object.defineProperty(ty,"__esModule",{value:!0}),ty.TypeHandlerDate=void 0;const ry=Yh;class ny{fromRdf(e,t){switch(t&&!e.value.match(ny.VALIDATORS[e.datatype.value.substr(33,e.datatype.value.length)])&&ry.Translator.incorrectRdfDataType(e),e.datatype.value){case"http://www.w3.org/2001/XMLSchema#gDay":return new Date(0,0,parseInt(e.value,10));case"http://www.w3.org/2001/XMLSchema#gMonthDay":const t=e.value.split("-");return new Date(0,parseInt(t[0],10)-1,parseInt(t[1],10));case"http://www.w3.org/2001/XMLSchema#gYear":return new Date(e.value+"-01-01");case"http://www.w3.org/2001/XMLSchema#gYearMonth":return new Date(e.value+"-01");default:return new Date(e.value)}}toRdf(e,{datatype:t,dataFactory:r}){if(t=t||r.namedNode(ny.TYPES[0]),!(e instanceof Date))return null;const n=e;let i;switch(t.value){case"http://www.w3.org/2001/XMLSchema#gDay":i=String(n.getUTCDate());break;case"http://www.w3.org/2001/XMLSchema#gMonthDay":i=n.getUTCMonth()+1+"-"+n.getUTCDate();break;case"http://www.w3.org/2001/XMLSchema#gYear":i=String(n.getUTCFullYear());break;case"http://www.w3.org/2001/XMLSchema#gYearMonth":i=n.getUTCFullYear()+"-"+(n.getUTCMonth()+1);break;case"http://www.w3.org/2001/XMLSchema#date":i=n.toISOString().replace(/T.*$/,"");break;default:i=n.toISOString()}return r.literal(i,t)}}ty.TypeHandlerDate=ny,ny.TYPES=["http://www.w3.org/2001/XMLSchema#dateTime","http://www.w3.org/2001/XMLSchema#date","http://www.w3.org/2001/XMLSchema#gDay","http://www.w3.org/2001/XMLSchema#gMonthDay","http://www.w3.org/2001/XMLSchema#gYear","http://www.w3.org/2001/XMLSchema#gYearMonth"],ny.VALIDATORS={date:/^[0-9]+-[0-9][0-9]-[0-9][0-9]Z?$/,dateTime:/^[0-9]+-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9](\.[0-9][0-9][0-9])?((Z?)|([\+-][0-9][0-9]:[0-9][0-9]))$/,gDay:/^[0-9]+$/,gMonthDay:/^[0-9]+-[0-9][0-9]$/,gYear:/^[0-9]+$/,gYearMonth:/^[0-9]+-[0-9][0-9]$/};var iy={};Object.defineProperty(iy,"__esModule",{value:!0}),iy.TypeHandlerNumberDouble=void 0;const oy=Yh;class ay{fromRdf(e,t){const r=parseFloat(e.value);return t&&isNaN(r)&&oy.Translator.incorrectRdfDataType(e),r}toRdf(e,{datatype:t,dataFactory:r}){return t=t||r.namedNode(ay.TYPES[0]),isNaN(e)?r.literal("NaN",t):isFinite(e)?e%1==0?null:r.literal(e.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),t):r.literal(e>0?"INF":"-INF",t)}}iy.TypeHandlerNumberDouble=ay,ay.TYPES=["http://www.w3.org/2001/XMLSchema#double","http://www.w3.org/2001/XMLSchema#decimal","http://www.w3.org/2001/XMLSchema#float"];var sy={};Object.defineProperty(sy,"__esModule",{value:!0}),sy.TypeHandlerNumberInteger=void 0;const cy=Yh;class uy{fromRdf(e,t){const r=parseInt(e.value,10);return t&&(isNaN(r)||e.value.indexOf(".")>=0)&&cy.Translator.incorrectRdfDataType(e),r}toRdf(e,{datatype:t,dataFactory:r}){return r.literal(String(e),t||(e<=uy.MAX_INT&&e>=uy.MIN_INT?r.namedNode(uy.TYPES[0]):r.namedNode(uy.TYPES[1])))}}sy.TypeHandlerNumberInteger=uy,uy.TYPES=["http://www.w3.org/2001/XMLSchema#integer","http://www.w3.org/2001/XMLSchema#long","http://www.w3.org/2001/XMLSchema#int","http://www.w3.org/2001/XMLSchema#byte","http://www.w3.org/2001/XMLSchema#short","http://www.w3.org/2001/XMLSchema#negativeInteger","http://www.w3.org/2001/XMLSchema#nonNegativeInteger","http://www.w3.org/2001/XMLSchema#nonPositiveInteger","http://www.w3.org/2001/XMLSchema#positiveInteger","http://www.w3.org/2001/XMLSchema#unsignedByte","http://www.w3.org/2001/XMLSchema#unsignedInt","http://www.w3.org/2001/XMLSchema#unsignedLong","http://www.w3.org/2001/XMLSchema#unsignedShort"],uy.MAX_INT=2147483647,uy.MIN_INT=-2147483648;var ly={};Object.defineProperty(ly,"__esModule",{value:!0}),ly.TypeHandlerString=void 0;class dy{fromRdf(e){return e.value}toRdf(e,{datatype:t,dataFactory:r}){return r.literal(e,t)}}ly.TypeHandlerString=dy,dy.TYPES=["http://www.w3.org/2001/XMLSchema#string","http://www.w3.org/2001/XMLSchema#normalizedString","http://www.w3.org/2001/XMLSchema#anyURI","http://www.w3.org/2001/XMLSchema#base64Binary","http://www.w3.org/2001/XMLSchema#language","http://www.w3.org/2001/XMLSchema#Name","http://www.w3.org/2001/XMLSchema#NCName","http://www.w3.org/2001/XMLSchema#NMTOKEN","http://www.w3.org/2001/XMLSchema#token","http://www.w3.org/2001/XMLSchema#hexBinary","http://www.w3.org/1999/02/22-rdf-syntax-ns#langString","http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString","http://www.w3.org/2001/XMLSchema#time","http://www.w3.org/2001/XMLSchema#duration"],function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Kh,e),r(ty,e),r(iy,e),r(sy,e),r(ly,e)}(Wh);var py={};function fy(e){if("BlankNode"!==e.term.termType)return{quantifier:"one",start:"subject",end:"object",predicates:[e.term]};const t=e.out([kf.alternativePath]);if(1===t.ptrs.length&&t.ptrs[0].isList())return{quantifier:"one",start:"subject",end:"object",predicates:[...t.list()].map(e=>e.term)};const r=e.out([kf.inversePath]);if(r.term)return{quantifier:"one",start:"object",end:"subject",predicates:[r.term]};const n=e.out([kf.oneOrMorePath]);if(n.term)return{quantifier:"oneOrMore",start:"subject",end:"object",predicates:[n.term]};const i=e.out([kf.zeroOrMorePath]);if(i.term)return{quantifier:"zeroOrMore",start:"subject",end:"object",predicates:[i.term]};const o=e.out([kf.zeroOrOnePath]);return o.term?{quantifier:"zeroOrOne",start:"subject",end:"object",predicates:[o.term]}:void 0}function hy(e){return 0===e.terms.length?null:e.ptrs[0].isList()?[...e.list()].map(e=>fy(e)):[fy(e)]}Object.defineProperty(py,"__esModule",{value:!0}),function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.fromRdf=u,e.toRdf=function(e,t){t&&"namedNode"in t&&(t={dataFactory:t});(t=t||{})&&!t.dataFactory&&(t.dataFactory=s);return c.toRdf(e,t)},e.getTermRaw=function(e,t){if("Literal"===e.termType)return u(e,t);return e.value},e.getSupportedRdfDatatypes=function(){return c.getSupportedRdfDatatypes()},e.getSupportedJavaScriptPrimitives=function(){return c.getSupportedJavaScriptPrimitives()};const i=Ih,o=Wh,a=Yh;r(Wh,e),r(py,e),r(Yh,e);const s=new i.DataFactory,c=new a.Translator;function u(e,t){return c.fromRdf(e,t)}c.registerHandler(new o.TypeHandlerString,o.TypeHandlerString.TYPES.map(e=>s.namedNode(e)),["string"]),c.registerHandler(new o.TypeHandlerBoolean,[o.TypeHandlerBoolean.TYPE].map(e=>s.namedNode(e)),["boolean"]),c.registerHandler(new o.TypeHandlerNumberDouble,o.TypeHandlerNumberDouble.TYPES.map(e=>s.namedNode(e)),["number"]),c.registerHandler(new o.TypeHandlerNumberInteger,o.TypeHandlerNumberInteger.TYPES.map(e=>s.namedNode(e)),["number"]),c.registerHandler(new o.TypeHandlerDate,o.TypeHandlerDate.TYPES.map(e=>s.namedNode(e)),["object"])}(Eh);class yy{constructor(e){this.shape=e,this._compiled=Th(()=>this.shape.validator.registry.compile(e))}get compiled(){return this._compiled()}async validate(e){return 0===e.focusNode.dataset.size||(this.shape.isPropertyShape?await this.validateProperty(e):await this.validateNode(e)),e}async validateNode(e){const t=e.create({shape:this.shape,valueOrNode:e.value||e.focusNode});for(const e of this.compiled)e.node&&await e.node(t),e.generic&&await e.generic(t)}async validateProperty(e){let t;t=this.shape.isSparqlShape?e.focusNode:e.focusNode.executeAll(this.shape.path);const r=t.node(new xf(t.terms)),n=[...t].reduce((e,r)=>{const n=r.term,i=t.node([n]);return e.has(n)||e.set(n,{value:i,valuePaths:[]}),e.get(n).valuePaths.push(r),e},new Tf).values(),i=e.create({shape:this.shape,values:r});for(const e of this.compiled)e.property&&await e.property(i);for(const{value:t,valuePaths:r}of n){const n=e.create({shape:this.shape,value:t,valueOrNode:t,valuePaths:r});for(const e of this.compiled)e.generic&&await e.generic(n)}}}function gy(e){const t=new xf,r=new Rf({dataset:e.dataset,terms:e.terms}).execute({quantifier:"zeroOrMore",start:"object",end:"subject",predicates:[Cf.subClassOf]});for(const e of r.ptrs)for(const{term:r}of e.nodes())t.add(r);return t}var my={},by={},vy={},_y={},wy={},Ty={},Oy={},Sy={},xy="@@__IMMUTABLE_INDEXED__@@";function jy(e){return Boolean(e&&e[xy])}var Ay="@@__IMMUTABLE_KEYED__@@";function Ey(e){return Boolean(e&&e[Ay])}function Iy(e){return Ey(e)||jy(e)}var Fy="@@__IMMUTABLE_ITERABLE__@@";function Dy(e){return Boolean(e&&e[Fy])}var Ny=function(e){return Dy(e)?e:yg(e)},Py=function(e){function t(e){return Ey(e)?e:gg(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ny),Ry=function(e){function t(e){return jy(e)?e:mg(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ny),My=function(e){function t(e){return Dy(e)&&!Iy(e)?e:bg(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ny);Ny.Keyed=Py,Ny.Indexed=Ry,Ny.Set=My;var Ly="function"==typeof Symbol&&Symbol.iterator,Cy="@@iterator",ky=Ly||Cy,By=function(e){this.next=e};function Uy(e,t,r,n){var i=0===e?t:1===e?r:[t,r];return n?n.value=i:n={value:i,done:!1},n}function $y(){return{value:void 0,done:!0}}function qy(e){return!!Array.isArray(e)||!!Gy(e)}function Qy(e){return!(!e||"function"!=typeof e.next)}function zy(e){var t=Gy(e);return t&&t.call(e)}function Gy(e){var t=e&&(Ly&&e[Ly]||e[Cy]);if("function"==typeof t)return t}By.prototype.toString=function(){return"[Iterator]"},By.KEYS=0,By.VALUES=1,By.ENTRIES=2,By.prototype.inspect=By.prototype.toSource=function(){return this.toString()},By.prototype[ky]=function(){return this};var Vy="delete",Xy=32,Hy=31,Jy={};function Wy(e){e&&(e.value=!0)}function Ky(){}function Yy(e){return void 0===e.size&&(e.size=e.__iterate(eg)),e.size}function Zy(e,t){if("number"!=typeof t){var r=t>>>0;if(""+r!==t||4294967295===r)return NaN;t=r}return t<0?Yy(e)+t:t}function eg(){return!0}function tg(e,t,r){return(0===e&&!og(e)||void 0!==r&&e<=-r)&&(void 0===t||void 0!==r&&t>=r)}function rg(e,t){return ig(e,t,0)}function ng(e,t){return ig(e,t,t)}function ig(e,t,r){return void 0===e?r:og(e)?t===1/0?t:0|Math.max(0,t+e):void 0===t||t===e?e:0|Math.min(t,e)}function og(e){return e<0||0===e&&1/e==-1/0}var ag="@@__IMMUTABLE_RECORD__@@";function sg(e){return Boolean(e&&e[ag])}function cg(e){return Dy(e)||sg(e)}var ug="@@__IMMUTABLE_ORDERED__@@";function lg(e){return Boolean(e&&e[ug])}var dg="@@__IMMUTABLE_SEQ__@@";function pg(e){return Boolean(e&&e[dg])}var fg=Object.prototype.hasOwnProperty;function hg(e){return!(!Array.isArray(e)&&"string"!=typeof e)||e&&"object"==typeof e&&Number.isInteger(e.length)&&e.length>=0&&(0===e.length?1===Object.keys(e).length:e.hasOwnProperty(e.length-1))}var yg=function(e){function t(e){return null==e?Og():cg(e)?e.toSeq():function(e){var t=jg(e);if(t)return(n=Gy(r=e))&&n===r.entries?t.fromEntrySeq():function(e){var t=Gy(e);return t&&t===e.keys}(e)?t.toSetSeq():t;var r,n;if("object"==typeof e)return new _g(e);throw new TypeError("Expected Array or collection object of values, or keyed object: "+e)}(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq {","}")},t.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},t.prototype.__iterate=function(e,t){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[t?n-++i:i++];if(!1===e(o[1],o[0],this))break}return i}return this.__iterateUncached(e,t)},t.prototype.__iterator=function(e,t){var r=this._cache;if(r){var n=r.length,i=0;return new By(function(){if(i===n)return{value:void 0,done:!0};var o=r[t?n-++i:i++];return Uy(e,o[0],o[1])})}return this.__iteratorUncached(e,t)},t}(Ny),gg=function(e){function t(e){return null==e?Og().toKeyedSeq():Dy(e)?Ey(e)?e.toSeq():e.fromEntrySeq():sg(e)?e.toSeq():Sg(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toKeyedSeq=function(){return this},t}(yg),mg=function(e){function t(e){return null==e?Og():Dy(e)?Ey(e)?e.entrySeq():e.toIndexedSeq():sg(e)?e.toSeq().entrySeq():xg(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t}(yg),bg=function(e){function t(e){return(Dy(e)&&!Iy(e)?e:mg(e)).toSetSeq()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t}(yg);yg.isSeq=pg,yg.Keyed=gg,yg.Set=bg,yg.Indexed=mg,yg.prototype[dg]=!0;var vg=function(e){function t(e){this._array=e,this.size=e.length}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(e,t){return this.has(e)?this._array[Zy(this,e)]:t},t.prototype.__iterate=function(e,t){for(var r=this._array,n=r.length,i=0;i!==n;){var o=t?n-++i:i++;if(!1===e(r[o],o,this))break}return i},t.prototype.__iterator=function(e,t){var r=this._array,n=r.length,i=0;return new By(function(){if(i===n)return{value:void 0,done:!0};var o=t?n-++i:i++;return Uy(e,o,r[o])})},t}(mg),_g=function(e){function t(e){var t=Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]);this._object=e,this._keys=t,this.size=t.length}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(e,t){return void 0===t||this.has(e)?this._object[e]:t},t.prototype.has=function(e){return fg.call(this._object,e)},t.prototype.__iterate=function(e,t){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var a=n[t?i-++o:o++];if(!1===e(r[a],a,this))break}return o},t.prototype.__iterator=function(e,t){var r=this._object,n=this._keys,i=n.length,o=0;return new By(function(){if(o===i)return{value:void 0,done:!0};var a=n[t?i-++o:o++];return Uy(e,a,r[a])})},t}(gg);_g.prototype[ug]=!0;var wg,Tg=function(e){function t(e){this._collection=e,this.size=e.length||e.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);var r=zy(this._collection),n=0;if(Qy(r))for(var i;!(i=r.next()).done&&!1!==e(i.value,n++,this););return n},t.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=zy(this._collection);if(!Qy(r))return new By($y);var n=0;return new By(function(){var t=r.next();return t.done?t:Uy(e,n++,t.value)})},t}(mg);function Og(){return wg||(wg=new vg([]))}function Sg(e){var t=jg(e);if(t)return t.fromEntrySeq();if("object"==typeof e)return new _g(e);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+e)}function xg(e){var t=jg(e);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+e)}function jg(e){return hg(e)?new vg(e):qy(e)?new Tg(e):void 0}function Ag(){return this.__ensureOwner()}function Eg(){return this.__ownerID?this:this.__ensureOwner(new Ky)}var Ig="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(e,t){var r=65535&(e|=0),n=65535&(t|=0);return r*n+((e>>>16)*n+r*(t>>>16)<<16>>>0)|0};function Fg(e){return e>>>1&1073741824|3221225471&e}var Dg=Object.prototype.valueOf;function Ng(e){if(null==e)return Pg(e);if("function"==typeof e.hashCode)return Fg(e.hashCode(e));var t,r=(t=e).valueOf!==Dg&&"function"==typeof t.valueOf?t.valueOf(t):t;if(null==r)return Pg(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(e){if(e!=e||e===1/0)return 0;var t=0|e;t!==e&&(t^=4294967295*e);for(;e>4294967295;)t^=e/=4294967295;return Fg(t)}(r);case"string":return r.length>Qg?function(e){var t=Vg[e];void 0===t&&(t=Rg(e),Gg===zg&&(Gg=0,Vg={}),Gg++,Vg[e]=t);return t}(r):Rg(r);case"object":case"function":return function(e){var t;if(Bg&&void 0!==(t=kg.get(e)))return t;if(t=e[qg],void 0!==t)return t;if(!Lg){if(void 0!==(t=e.propertyIsEnumerable&&e.propertyIsEnumerable[qg]))return t;if(void 0!==(t=function(e){if(e&&e.nodeType>0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}(e)))return t}if(t=Cg(),Bg)kg.set(e,t);else{if(void 0!==Mg&&!1===Mg(e))throw new Error("Non-extensible objects are not allowed as keys.");if(Lg)Object.defineProperty(e,qg,{enumerable:!1,configurable:!1,writable:!1,value:t});else if(void 0!==e.propertyIsEnumerable&&e.propertyIsEnumerable===e.constructor.prototype.propertyIsEnumerable)e.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},e.propertyIsEnumerable[qg]=t;else{if(void 0===e.nodeType)throw new Error("Unable to set a non-enumerable property on object.");e[qg]=t}}return t}(r);case"symbol":return function(e){var t=Ug[e];if(void 0!==t)return t;return t=Cg(),Ug[e]=t,t}(r);default:if("function"==typeof r.toString)return Rg(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function Pg(e){return null===e?1108378658:1108378659}function Rg(e){for(var t=0,r=0;r=0&&(c.get=function(t,r){return(t=Zy(this,t))>=0&&to)return{value:void 0,done:!0};var e=i.next();return n||1===t||e.done?e:Uy(t,c-1,0===t?void 0:e.value[1],e)})},c}function rm(e,t,r,n){var i=pm(e);return i.__iterateUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,c=0;return e.__iterate(function(e,o,u){if(!s||!(s=t.call(r,e,o,u)))return c++,i(e,n?o:c-1,a)}),c},i.__iteratorUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterator(i,o);var s=e.__iterator(2,o),c=!0,u=0;return new By(function(){var e,o,l;do{if((e=s.next()).done)return n||1===i?e:Uy(i,u++,0===i?void 0:e.value[1],e);var d=e.value;o=d[0],l=d[1],c&&(c=t.call(r,l,o,a))}while(c);return 2===i?e:Uy(i,o,l,e)})},i}Hg.prototype.cacheResult=Xg.prototype.cacheResult=Jg.prototype.cacheResult=Wg.prototype.cacheResult=fm;var nm=function(e){function t(e){this._wrappedIterables=e.flatMap(function(e){return e._wrappedIterables?e._wrappedIterables:[e]}),this.size=this._wrappedIterables.reduce(function(e,t){if(void 0!==e){var r=t.size;if(void 0!==r)return e+r}},0),this[Ay]=this._wrappedIterables[0][Ay],this[xy]=this._wrappedIterables[0][xy],this[ug]=this._wrappedIterables[0][ug]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(e,t){if(0!==this._wrappedIterables.length){if(t)return this.cacheResult().__iterate(e,t);for(var r=0,n=Ey(this),i=n?2:1,o=this._wrappedIterables[r].__iterator(i,t),a=!0,s=0;a;){for(var c=o.next();c.done;){if(++r===this._wrappedIterables.length)return s;c=(o=this._wrappedIterables[r].__iterator(i,t)).next()}a=!1!==(n?e(c.value[1],c.value[0],this):e(c.value,s,this)),s++}return s}},t.prototype.__iteratorUncached=function(e,t){var r=this;if(0===this._wrappedIterables.length)return new By($y);if(t)return this.cacheResult().__iterator(e,t);var n=0,i=this._wrappedIterables[n].__iterator(e,t);return new By(function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(e,t)).next()}return o})},t}(yg);function im(e,t,r){var n=pm(e);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var a=0,s=!1;return function e(c,u){c.__iterate(function(o,c){return(!t||u0}function cm(e,t,r,n){var i=pm(e),o=new vg(r).map(function(e){return e.size});return i.size=n?o.max():o.min(),i.__iterate=function(e,t){for(var r,n=this.__iterator(1,t),i=0;!(r=n.next()).done&&!1!==e(r.value,i++,this););return i},i.__iteratorUncached=function(e,i){var o=r.map(function(e){return e=Ny(e),zy(i?e.reverse():e)}),a=0,s=!1;return new By(function(){var r;return s||(r=o.map(function(e){return e.next()}),s=n?r.every(function(e){return e.done}):r.some(function(e){return e.done})),s?{value:void 0,done:!0}:Uy(e,a++,t.apply(null,r.map(function(e){return e.value})))})},i}function um(e,t){return e===t?e:pg(e)?t:e.constructor(t)}function lm(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function dm(e){return Ey(e)?Py:jy(e)?Ry:My}function pm(e){return Object.create((Ey(e)?gg:jy(e)?mg:bg).prototype)}function fm(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):yg.prototype.cacheResult.call(this)}function hm(e,t){return void 0===e&&void 0===t?0:void 0===e?1:void 0===t?-1:e>t?1:e0;)t[r]=arguments[r+1];if("function"!=typeof e)throw new TypeError("Invalid merger function: "+e);return _m(this,t,e)}function _m(e,t,r){for(var n=[],i=0;i0;)t[r]=arguments[r+1];return jm(this,t,e)}function Fm(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return gb(this,e,eb(),function(e){return jm(e,t)})}function Dm(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return gb(this,e,eb(),function(e){return Am(e,t)})}function Nm(e,t,r){return gb(e,t,Jy,function(){return r})}function Pm(e,t){return Nm(this,e,t)}function Rm(e,t,r){return 1===arguments.length?e(this):mm(this,e,t,r)}function Mm(e,t,r){return gb(this,e,t,r)}function Lm(){return this.__altered}function Cm(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}var km="@@__IMMUTABLE_MAP__@@";function Bm(e){return Boolean(e&&e[km])}function Um(e,t){if(!e)throw new Error(t)}function $m(e){Um(e!==1/0,"Cannot perform this action with an infinite size.")}var qm=function(e){function t(t){return null==t?eb():Bm(t)&&!lg(t)?t:eb().withMutations(function(r){var n=e(t);$m(n.size),n.forEach(function(e,t){return r.set(t,e)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(e,t){return this._root?this._root.get(0,void 0,e,t):t},t.prototype.set=function(e,t){return tb(this,e,t)},t.prototype.remove=function(e){return tb(this,e,Jy)},t.prototype.deleteAll=function(e){var t=Ny(e);return 0===t.size?this:this.withMutations(function(e){t.forEach(function(t){return e.remove(t)})})},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):eb()},t.prototype.sort=function(e){return Lb(om(this,e))},t.prototype.sortBy=function(e,t){return Lb(om(this,t,e))},t.prototype.map=function(e,t){var r=this;return this.withMutations(function(n){n.forEach(function(i,o){n.set(o,e.call(t,i,o,r))})})},t.prototype.__iterator=function(e,t){return new Wm(this,e,t)},t.prototype.__iterate=function(e,t){var r=this,n=0;return this._root&&this._root.iterate(function(t){return n++,e(t[1],t[0],r)},t),n},t.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?Zm(this.size,this._root,e,this.__hash):0===this.size?eb():(this.__ownerID=e,this.__altered=!1,this)},t}(Py);qm.isMap=Bm;var Qm=qm.prototype;Qm[km]=!0,Qm[Vy]=Qm.remove,Qm.removeAll=Qm.deleteAll,Qm.setIn=Pm,Qm.removeIn=Qm.deleteIn=vb,Qm.update=Rm,Qm.updateIn=Mm,Qm.merge=Qm.concat=bm,Qm.mergeWith=vm,Qm.mergeDeep=Em,Qm.mergeDeepWith=Im,Qm.mergeIn=Dm,Qm.mergeDeepIn=Fm,Qm.withMutations=Cm,Qm.wasAltered=Lm,Qm.asImmutable=Ag,Qm["@@transducer/init"]=Qm.asMutable=Eg,Qm["@@transducer/step"]=function(e,t){return e.set(t[0],t[1])},Qm["@@transducer/result"]=function(e){return e.asImmutable()};var zm=function(e,t){this.ownerID=e,this.entries=t};zm.prototype.get=function(e,t,r,n){for(var i=this.entries,o=0,a=i.length;o=sb)return function(e,t,r,n){e||(e=new Ky);for(var i=new Hm(e,Ng(r),[r,n]),o=0;o>>e)&Hy),o=this.bitmap;return 0===(o&i)?n:this.nodes[ob(o&i-1)].get(e+5,t,r,n)},Gm.prototype.update=function(e,t,r,n,i,o,a){void 0===r&&(r=Ng(n));var s=(0===t?r:r>>>t)&Hy,c=1<=cb)return function(e,t,r,n,i){for(var o=0,a=new Array(Xy),s=0;0!==r;s++,r>>>=1)a[s]=1&r?t[o++]:void 0;return a[n]=i,new Vm(e,o+1,a)}(e,p,u,s,h);if(l&&!h&&2===p.length&&nb(p[1^d]))return p[1^d];if(l&&h&&1===p.length&&nb(h))return h;var y=e&&e===this.ownerID,g=l?h?u:u^c:u|c,m=l?h?ab(p,d,h,y):function(e,t,r){var n=e.length-1;if(r&&t===n)return e.pop(),e;for(var i=new Array(n),o=0,a=0;a>>e)&Hy,o=this.nodes[i];return o?o.get(e+5,t,r,n):n},Vm.prototype.update=function(e,t,r,n,i,o,a){void 0===r&&(r=Ng(n));var s=(0===t?r:r>>>t)&Hy,c=i===Jy,u=this.nodes,l=u[s];if(c&&!l)return this;var d=rb(l,e,t+5,r,n,i,o,a);if(d===l)return this;var p=this.count;if(l){if(!d&&--p>>r)&Hy,s=(0===r?n:n>>>r)&Hy,c=a===s?[ib(e,t,r+5,n,i)]:(o=new Hm(t,n,i),a>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)}function ab(e,t,r,n){var i=n?e:Sm(e);return i[t]=r,i}var sb=8,cb=16,ub=8;function lb(e){if(hg(e)&&"string"!=typeof e)return e;if(lg(e))return e.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+e)}function db(e){try{return"string"==typeof e?JSON.stringify(e):String(e)}catch(t){return JSON.stringify(e)}}function pb(e,t){return cg(e)?e.has(t):Om(e)&&fg.call(e,t)}function fb(e,t,r){return cg(e)?e.get(t,r):pb(e,t)?"function"==typeof e.get?e.get(t):e[t]:r}function hb(e,t){if(!Om(e))throw new TypeError("Cannot update non-data-structure value: "+e);if(cg(e)){if(!e.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+e);return e.remove(t)}if(!fg.call(e,t))return e;var r=xm(e);return Array.isArray(r)?r.splice(t,1):delete r[t],r}function yb(e,t,r){if(!Om(e))throw new TypeError("Cannot update non-data-structure value: "+e);if(cg(e)){if(!e.set)throw new TypeError("Cannot update immutable value without .set() method: "+e);return e.set(t,r)}if(fg.call(e,t)&&r===e[t])return e;var n=xm(e);return n[t]=r,n}function gb(e,t,r,n){n||(n=r,r=void 0);var i=mb(cg(e),e,lb(t),0,r,n);return i===Jy?r:i}function mb(e,t,r,n,i,o){var a=t===Jy;if(n===r.length){var s=a?i:t,c=o(s);return c===s?t:c}if(!a&&!Om(t))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(r).slice(0,n).map(db)+"]: "+t);var u=r[n],l=a?Jy:fb(t,u,Jy),d=mb(l===Jy?e:cg(l),l,r,n+1,i,o);return d===l?t:d===Jy?hb(t,u):yb(a?e?eb():{}:t,u,d)}function bb(e,t){return gb(e,t,function(){return Jy})}function vb(e){return bb(this,e)}var _b="@@__IMMUTABLE_LIST__@@";function wb(e){return Boolean(e&&e[_b])}var Tb=function(e){function t(t){var r=Eb();if(null==t)return r;if(wb(t))return t;var n=e(t),i=n.size;return 0===i?r:($m(i),i>0&&i=0&&e=e.size||t<0)return e.withMutations(function(e){t<0?Nb(e,t).set(0,r):Nb(e,0,t+1).set(t,r)});t+=e._origin;var n=e._tail,i=e._root,o={value:!1};t>=Pb(e._capacity)?n=Ib(n,e.__ownerID,0,t,r,o):i=Ib(i,e.__ownerID,e._level,t,r,o);if(!o.value)return e;if(e.__ownerID)return e._root=i,e._tail=n,e.__hash=void 0,e.__altered=!0,e;return Ab(e._origin,e._capacity,e._level,i,n)}(this,e,t)},t.prototype.remove=function(e){return this.has(e)?0===e?this.shift():e===this.size-1?this.pop():this.splice(e,1):this},t.prototype.insert=function(e,t){return this.splice(e,0,t)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=5,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):Eb()},t.prototype.push=function(){var e=arguments,t=this.size;return this.withMutations(function(r){Nb(r,0,t+e.length);for(var n=0;n>>t&Hy;if(n>=this.array.length)return new Sb([],e);var i,o=0===n;if(t>0){var a=this.array[n];if((i=a&&a.removeBefore(e,t-5,r))===a&&o)return this}if(o&&!i)return this;var s=Fb(this,e);if(!o)for(var c=0;c>>t&Hy;if(i>=this.array.length)return this;if(t>0){var o=this.array[i];if((n=o&&o.removeAfter(e,t-5,r))===o&&i===this.array.length-1)return this}var a=Fb(this,e);return a.array.splice(i+1),n&&(a.array[i]=n),a};var xb={};function jb(e,t){var r=e._origin,n=e._capacity,i=Pb(n),o=e._tail;return a(e._root,e._level,0);function a(e,s,c){return 0===s?function(e,a){var s=a===i?o&&o.array:e&&e.array,c=a>r?0:r-a,u=n-a;u>Xy&&(u=Xy);return function(){if(c===u)return xb;var e=t?--u:c++;return s&&s[e]}}(e,c):function(e,i,o){var s,c=e&&e.array,u=o>r?0:r-o>>i,l=1+(n-o>>i);l>Xy&&(l=Xy);return function(){for(;;){if(s){var e=s();if(e!==xb)return e;s=null}if(u===l)return xb;var r=t?--l:u++;s=a(c&&c[r],i-5,o+(r<>>r&Hy,c=e&&s0){var u=e&&e.array[s],l=Ib(u,t,r-5,n,i,o);return l===u?e:((a=Fb(e,t)).array[s]=l,a)}return c&&e.array[s]===i?e:(o&&Wy(o),a=Fb(e,t),void 0===i&&s===a.array.length-1?a.array.pop():a.array[s]=i,a)}function Fb(e,t){return t&&e&&t===e.ownerID?e:new Sb(e?e.array.slice():[],t)}function Db(e,t){if(t>=Pb(e._capacity))return e._tail;if(t<1<0;)r=r.array[t>>>n&Hy],n-=5;return r}}function Nb(e,t,r){void 0!==t&&(t|=0),void 0!==r&&(r|=0);var n=e.__ownerID||new Ky,i=e._origin,o=e._capacity,a=i+t,s=void 0===r?o:r<0?o+r:i+r;if(a===i&&s===o)return e;if(a>=s)return e.clear();for(var c=e._level,u=e._root,l=0;a+l<0;)u=new Sb(u&&u.array.length?[void 0,u]:[],n),l+=1<<(c+=5);l&&(a+=l,i+=l,s+=l,o+=l);for(var d=Pb(o),p=Pb(s);p>=1<d?new Sb([],n):f;if(f&&p>d&&a5;g-=5){var m=d>>>g&Hy;y=y.array[m]=Fb(y.array[m],n)}y.array[d>>>5&Hy]=f}if(s=p)a-=p,s-=p,c=5,u=null,h=h&&h.removeBefore(n,0,a);else if(a>i||p>>c&Hy;if(b!==p>>>c&Hy)break;b&&(l+=(1<i&&(u=u.removeBefore(n,c,a-l)),u&&p>>5<<5}function Rb(e){return Bm(e)&&lg(e)}var Mb,Lb=function(e){function t(e){return null==e?kb():Rb(e)?e:kb().withMutations(function(t){var r=Py(e);$m(r.size),r.forEach(function(e,r){return t.set(r,e)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("OrderedMap {","}")},t.prototype.get=function(e,t){var r=this._map.get(e);return void 0!==r?this._list.get(r)[1]:t},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):kb()},t.prototype.set=function(e,t){return Bb(this,e,t)},t.prototype.remove=function(e){return Bb(this,e,Jy)},t.prototype.__iterate=function(e,t){var r=this;return this._list.__iterate(function(t){return t&&e(t[1],t[0],r)},t)},t.prototype.__iterator=function(e,t){return this._list.fromEntrySeq().__iterator(e,t)},t.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._map.__ensureOwner(e),r=this._list.__ensureOwner(e);return e?Cb(t,r,e,this.__hash):0===this.size?kb():(this.__ownerID=e,this.__altered=!1,this._map=t,this._list=r,this)},t}(qm);function Cb(e,t,r,n){var i=Object.create(Lb.prototype);return i.size=e?e.size:0,i._map=e,i._list=t,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function kb(){return Mb||(Mb=Cb(eb(),Eb()))}function Bb(e,t,r){var n,i,o=e._map,a=e._list,s=o.get(t),c=void 0!==s;if(r===Jy){if(!c)return e;a.size>=Xy&&a.size>=2*o.size?(n=(i=a.filter(function(e,t){return void 0!==e&&s!==t})).toKeyedSeq().map(function(e){return e[0]}).flip().toMap(),e.__ownerID&&(n.__ownerID=i.__ownerID=e.__ownerID)):(n=o.remove(t),i=s===a.size-1?a.pop():a.set(s,void 0))}else if(c){if(r===a.get(s)[1])return e;n=o,i=a.set(s,[t,r])}else n=o.set(t,a.size),i=a.set(a.size,[t,r]);return e.__ownerID?(e.size=n.size,e._map=n,e._list=i,e.__hash=void 0,e.__altered=!0,e):Cb(n,i)}Lb.isOrderedMap=Rb,Lb.prototype[ug]=!0,Lb.prototype[Vy]=Lb.prototype.remove;var Ub="@@__IMMUTABLE_STACK__@@";function $b(e){return Boolean(e&&e[Ub])}var qb=function(e){function t(e){return null==e?Vb():$b(e)?e:Vb().pushAll(e)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(e,t){var r=this._head;for(e=Zy(this,e);r&&e--;)r=r.next;return r?r.value:t},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var e=arguments;if(0===arguments.length)return this;for(var t=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:e[n],next:r};return this.__ownerID?(this.size=t,this._head=r,this.__hash=void 0,this.__altered=!0,this):Gb(t,r)},t.prototype.pushAll=function(t){if(0===(t=e(t)).size)return this;if(0===this.size&&$b(t))return t;$m(t.size);var r=this.size,n=this._head;return t.__iterate(function(e){r++,n={value:e,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Gb(r,n)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Vb()},t.prototype.slice=function(t,r){if(tg(t,r,this.size))return this;var n=rg(t,this.size);if(ng(r,this.size)!==this.size)return e.prototype.slice.call(this,t,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Gb(i,o)},t.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?Gb(this.size,this._head,e,this.__hash):0===this.size?Vb():(this.__ownerID=e,this.__altered=!1,this)},t.prototype.__iterate=function(e,t){var r=this;if(t)return new vg(this.toArray()).__iterate(function(t,n){return e(t,n,r)},t);for(var n=0,i=this._head;i&&!1!==e(i.value,n++,this);)i=i.next;return n},t.prototype.__iterator=function(e,t){if(t)return new vg(this.toArray()).__iterator(e,t);var r=0,n=this._head;return new By(function(){if(n){var t=n.value;return n=n.next,Uy(e,r++,t)}return{value:void 0,done:!0}})},t}(Ry);qb.isStack=$b;var Qb,zb=qb.prototype;function Gb(e,t,r,n){var i=Object.create(zb);return i.size=e,i._head=t,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Vb(){return Qb||(Qb=Gb(0))}function Xb(e,t,r,n,i,o){return $m(e.size),e.__iterate(function(e,o,a){i?(i=!1,r=e):r=t.call(n,r,e,o,a)},o),r}function Hb(e,t){return t}function Jb(e,t){return[t,e]}function Wb(e){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return!e.apply(this,t)}}function Kb(e){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return-e.apply(this,t)}}function Yb(e,t){return et?-1:0}function Zb(e,t){if(e===t)return!0;if(!Dy(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||Ey(e)!==Ey(t)||jy(e)!==jy(t)||lg(e)!==lg(t))return!1;if(0===e.size&&0===t.size)return!0;var r=!Iy(e);if(lg(e)){var n=e.entries();return t.every(function(e,t){var i=n.next().value;return i&&gm(i[1],e)&&(r||gm(i[0],t))})&&n.next().done}var i=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{i=!0;var o=e;e=t,t=o}var a=!0,s=t.__iterate(function(t,n){if(r?!e.has(t):i?!gm(t,e.get(n,Jy)):!gm(e.get(n,Jy),t))return a=!1,!1});return a&&e.size===s}zb[Ub]=!0,zb.shift=zb.pop,zb.unshift=zb.push,zb.unshiftAll=zb.pushAll,zb.withMutations=Cm,zb.wasAltered=Lm,zb.asImmutable=Ag,zb["@@transducer/init"]=zb.asMutable=Eg,zb["@@transducer/step"]=function(e,t){return e.unshift(t)},zb["@@transducer/result"]=function(e){return e.asImmutable()};var ev,tv=function(e){function t(e,r,n){if(void 0===n&&(n=1),!(this instanceof t))return new t(e,r,n);if(Um(0!==n,"Cannot step a Range by 0"),Um(void 0!==e,"You must define a start value when using Range"),Um(void 0!==r,"You must define an end value when using Range"),n=Math.abs(n),r=0&&t=0&&r>>-15,461845907),t=Ig(t<<13|t>>>-13,5),t=(t+3864292196|0)^e,t=Ig(t^t>>>16,2246822507),t=Ig(t^t>>>13,3266489909),t=Fg(t^t>>>16),t}(e.size,n)}function gv(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}function mv(e,t){var r=function(r){e.prototype[r]=t[r]};return Object.keys(t).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(r),e}av[rv]=!0,av[Vy]=av.remove,av.merge=av.concat=av.union,av.withMutations=Cm,av.asImmutable=Ag,av["@@transducer/init"]=av.asMutable=Eg,av["@@transducer/step"]=function(e,t){return e.add(t)},av["@@transducer/result"]=function(e){return e.asImmutable()},av.__empty=uv,av.__make=cv,Ny.Iterator=By,mv(Ny,{toArray:function(){$m(this.size);var e=new Array(this.size||0),t=Ey(this),r=0;return this.__iterate(function(n,i){e[r++]=t?[i,n]:n}),e},toIndexedSeq:function(){return new Hg(this)},toJS:function(){return hv(this)},toKeyedSeq:function(){return new Xg(this,!0)},toMap:function(){return qm(this.toKeyedSeq())},toObject:fv,toOrderedMap:function(){return Lb(this.toKeyedSeq())},toOrderedSet:function(){return Sv(Ey(this)?this.valueSeq():this)},toSet:function(){return iv(Ey(this)?this.valueSeq():this)},toSetSeq:function(){return new Jg(this)},toSeq:function(){return jy(this)?this.toIndexedSeq():Ey(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return qb(Ey(this)?this.valueSeq():this)},toList:function(){return Tb(Ey(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(e,t){return 0===this.size?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return um(this,function(e,t){var r=Ey(e),n=[e].concat(t).map(function(e){return Dy(e)?r&&(e=Py(e)):e=r?Sg(e):xg(Array.isArray(e)?e:[e]),e}).filter(function(e){return 0!==e.size});if(0===n.length)return e;if(1===n.length){var i=n[0];if(i===e||r&&Ey(i)||jy(e)&&jy(i))return i}return new nm(n)}(this,e))},includes:function(e){return this.some(function(t){return gm(t,e)})},entries:function(){return this.__iterator(2)},every:function(e,t){$m(this.size);var r=!0;return this.__iterate(function(n,i,o){if(!e.call(t,n,i,o))return r=!1,!1}),r},filter:function(e,t){return um(this,em(this,e,t,!0))},partition:function(e,t){return function(e,t,r){var n=Ey(e),i=[[],[]];e.__iterate(function(o,a){i[t.call(r,o,a,e)?1:0].push(n?[a,o]:o)});var o=dm(e);return i.map(function(t){return um(e,o(t))})}(this,e,t)},find:function(e,t,r){var n=this.findEntry(e,t);return n?n[1]:r},forEach:function(e,t){return $m(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){$m(this.size),e=void 0!==e?""+e:",";var t="",r=!0;return this.__iterate(function(n){r?r=!1:t+=e,t+=null!=n?n.toString():""}),t},keys:function(){return this.__iterator(0)},map:function(e,t){return um(this,Yg(this,e,t))},reduce:function(e,t,r){return Xb(this,e,t,r,arguments.length<2,!1)},reduceRight:function(e,t,r){return Xb(this,e,t,r,arguments.length<2,!0)},reverse:function(){return um(this,Zg(this,!0))},slice:function(e,t){return um(this,tm(this,e,t,!0))},some:function(e,t){$m(this.size);var r=!1;return this.__iterate(function(n,i,o){if(e.call(t,n,i,o))return r=!0,!1}),r},sort:function(e){return um(this,om(this,e))},values:function(){return this.__iterator(1)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some(function(){return!0})},count:function(e,t){return Yy(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return function(e,t,r){var n=qm().asMutable();return e.__iterate(function(i,o){n.update(t.call(r,i,o,e),0,function(e){return e+1})}),n.asImmutable()}(this,e,t)},equals:function(e){return Zb(this,e)},entrySeq:function(){var e=this;if(e._cache)return new vg(e._cache);var t=e.toSeq().map(Jb).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(Wb(e),t)},findEntry:function(e,t,r){var n=r;return this.__iterate(function(r,i,o){if(e.call(t,r,i,o))return n=[i,r],!1}),n},findKey:function(e,t){var r=this.findEntry(e,t);return r&&r[0]},findLast:function(e,t,r){return this.toKeyedSeq().reverse().find(e,t,r)},findLastEntry:function(e,t,r){return this.toKeyedSeq().reverse().findEntry(e,t,r)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(e){return this.find(eg,null,e)},flatMap:function(e,t){return um(this,function(e,t,r){var n=dm(e);return e.toSeq().map(function(i,o){return n(t.call(r,i,o,e))}).flatten(!0)}(this,e,t))},flatten:function(e){return um(this,im(this,e,!0))},fromEntrySeq:function(){return new Wg(this)},get:function(e,t){return this.find(function(t,r){return gm(r,e)},void 0,t)},getIn:dv,groupBy:function(e,t){return function(e,t,r){var n=Ey(e),i=(lg(e)?Lb():qm()).asMutable();e.__iterate(function(o,a){i.update(t.call(r,o,a,e),function(e){return(e=e||[]).push(n?[a,o]:o),e})});var o=dm(e);return i.map(function(t){return um(e,o(t))}).asImmutable()}(this,e,t)},has:function(e){return this.get(e,Jy)!==Jy},hasIn:function(e){return pv(this,e)},isSubset:function(e){return e="function"==typeof e.includes?e:Ny(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return(e="function"==typeof e.isSubset?e:Ny(e)).isSubset(this)},keyOf:function(e){return this.findKey(function(t){return gm(t,e)})},keySeq:function(){return this.toSeq().map(Hb).toIndexedSeq()},last:function(e){return this.toSeq().reverse().first(e)},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return am(this,e)},maxBy:function(e,t){return am(this,t,e)},min:function(e){return am(this,e?Kb(e):Yb)},minBy:function(e,t){return am(this,t?Kb(t):Yb,e)},rest:function(){return this.slice(1)},skip:function(e){return 0===e?this:this.slice(Math.max(0,e))},skipLast:function(e){return 0===e?this:this.slice(0,-Math.max(0,e))},skipWhile:function(e,t){return um(this,rm(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(Wb(e),t)},sortBy:function(e,t){return um(this,om(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return this.slice(-Math.max(0,e))},takeWhile:function(e,t){return um(this,function(e,t,r){var n=pm(e);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var a=0;return e.__iterate(function(e,i,s){return t.call(r,e,i,s)&&++a&&n(e,i,o)}),a},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var a=e.__iterator(2,i),s=!0;return new By(function(){if(!s)return{value:void 0,done:!0};var e=a.next();if(e.done)return e;var i=e.value,c=i[0],u=i[1];return t.call(r,u,c,o)?2===n?e:Uy(n,c,u,e):(s=!1,{value:void 0,done:!0})})},n}(this,e,t))},takeUntil:function(e,t){return this.takeWhile(Wb(e),t)},update:function(e){return e(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=yv(this))}});var bv=Ny.prototype;bv[Fy]=!0,bv[ky]=bv.values,bv.toJSON=bv.toArray,bv.__toStringMapper=db,bv.inspect=bv.toSource=function(){return this.toString()},bv.chain=bv.flatMap,bv.contains=bv.includes,mv(Py,{flip:function(){return um(this,Kg(this))},mapEntries:function(e,t){var r=this,n=0;return um(this,this.toSeq().map(function(i,o){return e.call(t,[o,i],n++,r)}).fromEntrySeq())},mapKeys:function(e,t){var r=this;return um(this,this.toSeq().flip().map(function(n,i){return e.call(t,n,i,r)}).flip())}});var vv=Py.prototype;vv[Ay]=!0,vv[ky]=bv.entries,vv.toJSON=fv,vv.__toStringMapper=function(e,t){return db(t)+": "+db(e)},mv(Ry,{toKeyedSeq:function(){return new Xg(this,!1)},filter:function(e,t){return um(this,em(this,e,t,!1))},findIndex:function(e,t){var r=this.findEntry(e,t);return r?r[0]:-1},indexOf:function(e){var t=this.keyOf(e);return void 0===t?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return void 0===t?-1:t},reverse:function(){return um(this,Zg(this,!1))},slice:function(e,t){return um(this,tm(this,e,t,!1))},splice:function(e,t){var r=arguments.length;if(t=Math.max(t||0,0),0===r||2===r&&!t)return this;e=rg(e,e<0?this.count():this.size);var n=this.slice(0,e);return um(this,1===r?n:n.concat(Sm(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var r=this.findLastEntry(e,t);return r?r[0]:-1},first:function(e){return this.get(0,e)},flatten:function(e){return um(this,im(this,e,!1))},get:function(e,t){return(e=Zy(this,e))<0||this.size===1/0||void 0!==this.size&&e>this.size?t:this.find(function(t,r){return r===e},void 0,t)},has:function(e){return(e=Zy(this,e))>=0&&(void 0!==this.size?this.size===1/0||e2?[]:void 0,{"":e})},get:fb,getIn:lv,has:pb,hasIn:pv,hash:Ng,is:gm,isAssociative:Iy,isCollection:Dy,isImmutable:cg,isIndexed:jy,isKeyed:Ey,isList:wb,isMap:Bm,isOrdered:lg,isOrderedMap:Rb,isOrderedSet:Ov,isPlainObject:Tm,isRecord:sg,isSeq:pg,isSet:nv,isStack:$b,isValueObject:ym,merge:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return Am(e,t)},mergeDeep:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return jm(e,t)},mergeDeepWith:function(e,t){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return jm(t,r,e)},mergeWith:function(e,t){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Am(t,r,e)},remove:hb,removeIn:bb,set:yb,setIn:Nm,update:mm,updateIn:gb,version:"5.1.4"}),$v=o(Uv);Object.defineProperty(Sy,"__esModule",{value:!0}),Sy.ActionContextKey=Sy.ActionContext=void 0;const qv=$v;class Qv{constructor(e={}){this.map=(0,qv.Map)(e)}setDefault(e,t){return this.has(e)?this:this.set(e,t)}set(e,t){return this.setRaw(e.name,t)}setRaw(e,t){return new Qv(this.map.set(e,t))}delete(e){return new Qv(this.map.delete(e.name))}get(e){return this.getRaw(e.name)}getRaw(e){return this.map.get(e)}getSafe(e){if(!this.has(e))throw new Error(`Context entry ${e.name} is required but not available`);return this.get(e)}has(e){return this.hasRaw(e.name)}hasRaw(e){return this.map.has(e)}merge(...e){let t=this;for(const r of e)for(const e of r.keys())t=t.set(e,r.get(e));return t}keys(){return[...this.map.keys()].map(e=>new zv(e))}toJS(){return this.map.toJS()}toString(){return`ActionContext(${JSON.stringify(this.map.toJS())})`}[Symbol.for("nodejs.util.inspect.custom")](){return`ActionContext(${JSON.stringify(this.map.toJS(),null," ")})`}static ensureActionContext(e){return e instanceof Qv?e:new Qv((0,qv.Map)(e??{}))}}Sy.ActionContext=Qv;class zv{constructor(e){this.name=e}}Sy.ActionContextKey=zv;var Gv={};Object.defineProperty(Gv,"__esModule",{value:!0}),Gv.Bus=void 0;Gv.Bus=class{constructor(e){this.actors=[],this.observers=[],this.dependencyLinks=new Map,Object.assign(this,e),this.failMessage=`All actors over bus ${this.name} failed to handle an action`}subscribe(e){this.actors.push(e),this.reorderForDependencies()}subscribeObserver(e){this.observers.push(e)}unsubscribe(e){const t=this.actors.indexOf(e);return t>=0&&(this.actors.splice(t,1),!0)}unsubscribeObserver(e){const t=this.observers.indexOf(e);return t>=0&&(this.observers.splice(t,1),!0)}publish(e){return this.actors.map(t=>({actor:t,reply:t.test(e)}))}onRun(e,t,r){for(const n of this.observers)n.onRun(e,t,r)}addDependencies(e,t){for(const r of t){let t=this.dependencyLinks.get(r);t||(t=[],this.dependencyLinks.set(r,t)),t.push(e)}this.reorderForDependencies()}reorderForDependencies(){if(this.dependencyLinks.size>0){const e=[];for(const t of this.dependencyLinks.keys()){const r=this.actors.indexOf(t);r>=0&&(this.actors.splice(r,1),e.push(t))}for(;e.length>0;){let t=-1;for(let r=0;r=0&&t.splice(r,1),0===t.length&&delete this.actorsIndex[n]}r=r||super.unsubscribe(e)}return r}publish(e){const t=this.getActionIdentifier(e);if(t){return[...this.actorsIndex[t]||[],...this.actorsIndex._undefined_||[]].map(t=>({actor:t,reply:t.test(e)}))}return super.publish(e)}getActorIdentifiers(e){const t=this.actorIdentifierFields.reduce((e,t)=>e[t],e);if(t)return Array.isArray(t)?t:[t]}getActionIdentifier(e){return this.actionIdentifierFields.reduce((e,t)=>e[t],e)}}Vv.BusIndexed=Hv;var Jv={};Object.defineProperty(Jv,"__esModule",{value:!0}),Jv.CONTEXT_KEY_LOGGER=void 0;const Wv=Sy;Jv.CONTEXT_KEY_LOGGER=new Wv.ActionContextKey("@comunica/core:log");var Kv={};Object.defineProperty(Kv,"__esModule",{value:!0}),Kv.ActionObserver=void 0;Kv.ActionObserver=class{constructor(e){Object.assign(this,e)}};var Yv={};Object.defineProperty(Yv,"__esModule",{value:!0}),Yv.Actor=void 0;const Zv=Jv;class e_{constructor(e){this.beforeActors=[],Object.assign(this,e),this.bus.subscribe(this),this.beforeActors.length>0&&this.bus.addDependencies(this,this.beforeActors),e.busFailMessage&&(this.bus.failMessage=e.busFailMessage)}static getContextLogger(e){return e.get(Zv.CONTEXT_KEY_LOGGER)}runObservable(e,t){const r=this.run(e,t);return this.bus.onRun(this,e,r),r}getDefaultLogData(e,t){const r=t?t():{};return r.actor=this.name,r}logTrace(e,t,r){const n=e_.getContextLogger(e);n&&n.trace(t,this.getDefaultLogData(e,r))}logDebug(e,t,r){const n=e_.getContextLogger(e);n&&n.debug(t,this.getDefaultLogData(e,r))}logInfo(e,t,r){const n=e_.getContextLogger(e);n&&n.info(t,this.getDefaultLogData(e,r))}logWarn(e,t,r){const n=e_.getContextLogger(e);n&&n.warn(t,this.getDefaultLogData(e,r))}logError(e,t,r){const n=e_.getContextLogger(e);n&&n.error(t,this.getDefaultLogData(e,r))}logFatal(e,t,r){const n=e_.getContextLogger(e);n&&n.fatal(t,this.getDefaultLogData(e,r))}}Yv.Actor=e_;var t_={};Object.defineProperty(t_,"__esModule",{value:!0}),t_.Mediator=void 0;class r_{constructor(e){Object.assign(this,e)}publish(e){const t=this.bus.publish(e);if(0===t.length)throw new Error(`No actors are able to reply to a message in the bus ${this.bus.name}`);return t}async mediateActor(e){return await this.mediateWith(e,this.publish(e))}async mediateTestable(e){return(await this.mediateActor(e)).mapAsync((t,r)=>t.runObservable(e,r))}async mediate(e){return(await this.mediateTestable(e)).getOrThrow()}constructFailureMessage(e,t){const r="\n ";return`${this.bus.failMessage.replaceAll(/\$\{(.*?)\}/gu,(t,r)=>r_.getObjectValue({action:e},r.split("."))||t)}\n Error messages of failing actors:${r}${t.join(r)}`}static getObjectValue(e,t){return 0===t.length?e:e?r_.getObjectValue(e[t[0]],t.slice(1)):void 0}}t_.Mediator=r_;var n_={};Object.defineProperty(n_,"__esModule",{value:!0}),n_.TestResultFailed=n_.TestResultPassed=n_.failTest=n_.passTestVoidWithSideData=n_.passTestWithSideData=n_.passTestVoid=n_.passTest=void 0,n_.passTest=function(e){return new i_(e,void 0)},n_.passTestVoid=function(){return new i_(!0,void 0)},n_.passTestWithSideData=function(e,t){return new i_(e,t)},n_.passTestVoidWithSideData=function(e){return new i_(!0,e)},n_.failTest=function(e){return new o_(e)};class i_{constructor(e,t){this.value=e,this.sideData=t}isPassed(){return!0}isFailed(){return!1}get(){return this.value}getOrThrow(){return this.value}getSideData(){return this.sideData}getFailMessage(){}map(e){return new i_(e(this.value,this.sideData),this.sideData)}async mapAsync(e){return new i_(await e(this.value,this.sideData),this.sideData)}}n_.TestResultPassed=i_;class o_{constructor(e){this.failMessage=e}isPassed(){return!1}isFailed(){return!0}get(){}getOrThrow(){throw new Error(this.getFailMessage())}getSideData(){throw new Error(this.getFailMessage())}getFailMessage(){return this.failMessage}map(){return this}async mapAsync(){return this}}n_.TestResultFailed=o_,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Sy,e),r(Gv,e),r(Vv,e),r(Jv,e),r(Kv,e),r(Yv,e),r(t_,e),r(n_,e)}(Oy),Object.defineProperty(Ty,"__esModule",{value:!0}),Ty.ActorInit=void 0;const a_=Oy;class s_ extends a_.Actor{constructor(e){super(e)}}Ty.ActorInit=s_,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Ty,e)}(wy),Object.defineProperty(_y,"__esModule",{value:!0}),_y.ActorInitQueryBase=void 0;const c_=wy,u_=Oy;_y.ActorInitQueryBase=class extends c_.ActorInit{async test(e){return(0,u_.passTestVoid)()}async run(e){throw new Error("ActorInitSparql#run is not supported in the browser.")}};var l_={};Object.defineProperty(l_,"__esModule",{value:!0}),l_.ActorInitQuery=void 0;const d_=_y;"undefined"==typeof process&&(globalThis.process=Jt);class p_ extends d_.ActorInitQueryBase{}l_.ActorInitQuery=p_;var f_,h_={},y_={},g_={};function m_(){if(f_)return g_;f_=1,Object.defineProperty(g_,"__esModule",{value:!0}),g_.KeysStatistics=g_.KeysRdfJoin=g_.KeysMergeBindingsContext=g_.KeysRdfUpdateQuads=g_.KeysQuerySourceIdentify=g_.KeysRdfParseHtmlScript=g_.KeysRdfParseJsonLd=g_.KeysQueryOperation=g_.KeysExpressionEvaluator=g_.KeysInitQuery=g_.KeysHttpProxy=g_.KeysHttpMemento=g_.KeysHttpWayback=g_.KeysHttp=g_.KeysCore=void 0;const e=Oy;return g_.KeysCore={log:e.CONTEXT_KEY_LOGGER},g_.KeysHttp={includeCredentials:new e.ActionContextKey("@comunica/bus-http:include-credentials"),auth:new e.ActionContextKey("@comunica/bus-http:auth"),fetch:new e.ActionContextKey("@comunica/bus-http:fetch"),httpTimeout:new e.ActionContextKey("@comunica/bus-http:http-timeout"),httpBodyTimeout:new e.ActionContextKey("@comunica/bus-http:http-body-timeout"),httpRetryCount:new e.ActionContextKey("@comunica/bus-http:http-retry-count"),httpRetryDelayFallback:new e.ActionContextKey("@comunica/bus-http:http-retry-delay-fallback"),httpRetryDelayLimit:new e.ActionContextKey("@comunica/bus-http:http-retry-delay-limit"),httpRetryStatusCodes:new e.ActionContextKey("@comunica/bus-http:http-retry-status-codes")},g_.KeysHttpWayback={recoverBrokenLinks:new e.ActionContextKey("@comunica/bus-http:recover-broken-links")},g_.KeysHttpMemento={datetime:new e.ActionContextKey("@comunica/actor-http-memento:datetime")},g_.KeysHttpProxy={httpProxyHandler:new e.ActionContextKey("@comunica/actor-http-proxy:httpProxyHandler")},g_.KeysInitQuery={querySourcesUnidentified:new e.ActionContextKey("@comunica/actor-init-query:querySourcesUnidentified"),initialBindings:new e.ActionContextKey("@comunica/actor-init-query:initialBindings"),queryFormat:new e.ActionContextKey("@comunica/actor-init-query:queryFormat"),graphqlSingularizeVariables:new e.ActionContextKey("@comunica/actor-init-query:singularizeVariables"),lenient:new e.ActionContextKey("@comunica/actor-init-query:lenient"),queryString:new e.ActionContextKey("@comunica/actor-init-query:queryString"),query:new e.ActionContextKey("@comunica/actor-init-query:query"),baseIRI:new e.ActionContextKey("@comunica/actor-init-query:baseIRI"),fileBaseIRI:new e.ActionContextKey("@comunica/actor-init-query:fileBaseIRI"),functionArgumentsCache:new e.ActionContextKey("@comunica/actor-init-query:functionArgumentsCache"),queryTimestamp:new e.ActionContextKey("@comunica/actor-init-query:queryTimestamp"),queryTimestampHighResolution:new e.ActionContextKey("@comunica/actor-init-query:queryTimestampHighResolution"),extensionFunctionCreator:new e.ActionContextKey("@comunica/actor-init-query:extensionFunctionCreator"),extensionFunctions:new e.ActionContextKey("@comunica/actor-init-query:extensionFunctions"),extensionFunctionsAlwaysPushdown:new e.ActionContextKey("@comunica/actor-init-query:extensionFunctionsAlwaysPushdown"),cliArgsHandlers:new e.ActionContextKey("@comunica/actor-init-query:cliArgsHandlers"),explain:new e.ActionContextKey("@comunica/actor-init-query:explain"),physicalQueryPlanLogger:new e.ActionContextKey("@comunica/actor-init-query:physicalQueryPlanLogger"),physicalQueryPlanNode:new e.ActionContextKey("@comunica/actor-init-query:physicalQueryPlanNode"),jsonLdContext:new e.ActionContextKey("@context"),invalidateCache:new e.ActionContextKey("@comunica/actor-init-query:invalidateCache"),dataFactory:new e.ActionContextKey("@comunica/actor-init-query:dataFactory"),distinctConstruct:new e.ActionContextKey("@comunica/actor-init-query:distinctConstruct")},g_.KeysExpressionEvaluator={extensionFunctionCreator:new e.ActionContextKey("@comunica/utils-expression-evaluator:extensionFunctionCreator"),superTypeProvider:new e.ActionContextKey("@comunica/utils-expression-evaluator:superTypeProvider"),defaultTimeZone:new e.ActionContextKey("@comunica/utils-expression-evaluator:defaultTimeZone"),actionContext:new e.ActionContextKey("@comunica/utils-expression-evaluator:actionContext")},g_.KeysQueryOperation={operation:new e.ActionContextKey("@comunica/bus-query-operation:operation"),joinLeftMetadata:new e.ActionContextKey("@comunica/bus-query-operation:joinLeftMetadata"),joinRightMetadatas:new e.ActionContextKey("@comunica/bus-query-operation:joinRightMetadatas"),joinBindings:new e.ActionContextKey("@comunica/bus-query-operation:joinBindings"),readOnly:new e.ActionContextKey("@comunica/bus-query-operation:readOnly"),isPathArbitraryLengthDistinctKey:new e.ActionContextKey("@comunica/bus-query-operation:isPathArbitraryLengthDistinct"),limitIndicator:new e.ActionContextKey("@comunica/bus-query-operation:limitIndicator"),unionDefaultGraph:new e.ActionContextKey("@comunica/bus-query-operation:unionDefaultGraph"),querySources:new e.ActionContextKey("@comunica/bus-query-operation:querySources")},g_.KeysRdfParseJsonLd={documentLoader:new e.ActionContextKey("@comunica/actor-rdf-parse-jsonld:documentLoader"),strictValues:new e.ActionContextKey("@comunica/actor-rdf-parse-jsonld:strictValues"),parserOptions:new e.ActionContextKey("@comunica/actor-rdf-parse-jsonld:parserOptions")},g_.KeysRdfParseHtmlScript={processingHtmlScript:new e.ActionContextKey("@comunica/actor-rdf-parse-html-script:processingHtmlScript"),extractAllScripts:new e.ActionContextKey("extractAllScripts")},g_.KeysQuerySourceIdentify={sourceIds:new e.ActionContextKey("@comunica/bus-query-source-identify:sourceIds"),hypermediaSourcesAggregatedStores:new e.ActionContextKey("@comunica/bus-query-source-identify:hypermediaSourcesAggregatedStores"),traverse:new e.ActionContextKey("@comunica/bus-query-source-identify:traverse")},g_.KeysRdfUpdateQuads={destination:new e.ActionContextKey("@comunica/bus-rdf-update-quads:destination")},g_.KeysMergeBindingsContext={sourcesBinding:new e.ActionContextKey("@comunica/bus-merge-bindings-context:sourcesBinding")},g_.KeysRdfJoin={lastPhysicalJoin:new e.ActionContextKey("@comunica/bus-rdf-join:lastPhysicalJoin")},g_.KeysStatistics={discoveredLinks:new e.ActionContextKey("@comunica/statistic:discoveredLinks"),dereferencedLinks:new e.ActionContextKey("@comunica/statistic:dereferencedLinks"),intermediateResults:new e.ActionContextKey("@comunica/statistic:intermediateResults")},g_}!function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(m_(),e)}(y_),Object.defineProperty(h_,"__esModule",{value:!0}),h_.QueryEngineBase=void 0;const b_=y_,v_=Oy;class __{constructor(e){this.actorInitQuery=e}async queryBindings(e,t){return this.queryOfType(e,t,"bindings")}async queryQuads(e,t){return this.queryOfType(e,t,"quads")}async queryBoolean(e,t){return this.queryOfType(e,t,"boolean")}async queryVoid(e,t){return this.queryOfType(e,t,"void")}async queryOfType(e,t,r){const n=await this.query(e,t);if(n.resultType===r)return await n.execute();throw new Error(`Query result type '${r}' was expected, while '${n.resultType}' was found.`)}async query(e,t){const r=await this.queryOrExplain(e,t);if("explain"in r)throw new Error("Tried to explain a query when in query-only mode");return r}async explain(e,t,r){t.explain=r;return await this.queryOrExplain(e,t)}async queryOrExplain(e,t){const r=v_.ActionContext.ensureActionContext(t);r.get(b_.KeysInitQuery.invalidateCache)&&await this.invalidateHttpCache();const{result:n}=await this.actorInitQuery.mediatorQueryProcess.mediate({query:e,context:r});return"explain"in n?n:__.internalToFinalResult(n)}async getResultMediaTypes(e){return e=v_.ActionContext.ensureActionContext(e),(await this.actorInitQuery.mediatorQueryResultSerializeMediaTypeCombiner.mediate({context:e,mediaTypes:!0})).mediaTypes}async getResultMediaTypeFormats(e){return e=v_.ActionContext.ensureActionContext(e),(await this.actorInitQuery.mediatorQueryResultSerializeMediaTypeFormatCombiner.mediate({context:e,mediaTypeFormats:!0})).mediaTypeFormats}async resultToString(e,t,r){if(r=v_.ActionContext.ensureActionContext(r),!t)switch(e.resultType){case"bindings":t="application/json";break;case"quads":t="application/trig";break;default:t="simple"}const n={...await __.finalToInternalResult(e),context:r};return(await this.actorInitQuery.mediatorQueryResultSerialize.mediate({context:r,handle:n,handleMediaType:t})).handle}invalidateHttpCache(e,t){return t=v_.ActionContext.ensureActionContext(t),this.actorInitQuery.mediatorHttpInvalidate.mediate({url:e,context:t})}static internalToFinalResult(e){switch(e.type){case"bindings":return{resultType:"bindings",execute:async()=>e.bindingsStream,metadata:async()=>{const t=await e.metadata();return t.variables=t.variables.map(e=>e.variable),t},context:e.context};case"quads":return{resultType:"quads",execute:async()=>e.quadStream,metadata:async()=>await e.metadata(),context:e.context};case"boolean":return{resultType:"boolean",execute:async()=>e.execute(),context:e.context};case"void":return{resultType:"void",execute:async()=>e.execute(),context:e.context}}}static async finalToInternalResult(e){switch(e.resultType){case"bindings":return{type:"bindings",bindingsStream:await e.execute(),metadata:async()=>{const t=await e.metadata();return t.variables=t.variables.map(e=>({variable:e,canBeUndef:!1})),t}};case"quads":return{type:"quads",quadStream:await e.execute(),metadata:async()=>await e.metadata()};case"boolean":return{type:"boolean",execute:()=>e.execute()};case"void":return{type:"void",execute:()=>e.execute()}}}}h_.QueryEngineBase=__,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.QueryEngineBase=void 0,r(_y,e),r(l_,e);var i=h_;Object.defineProperty(e,"QueryEngineBase",{enumerable:!0,get:function(){return i.QueryEngineBase}})}(vy);var w_,T_={},O_={},S_={},x_={};var j_,A_={};var E_,I_={};var F_,D_={};var N_,P_={};var R_,M_={};var L_,C_={};var k_,B_={};var U_,$_={};var q_,Q_={};var z_,G_={};var V_,X_={};var H_,J_={};var W_,K_={};var Y_,Z_={};var ew,tw={};var rw,nw={};var iw,ow={};var aw,sw={};var cw,uw={};var lw,dw,pw,fw,hw={};function yw(){return dw||(dw=1,function(e){var t,r=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=n&&n.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),i((w_||(w_=1,Object.defineProperty(x_,"__esModule",{value:!0})),x_),e),i((j_||(j_=1,Object.defineProperty(A_,"__esModule",{value:!0})),A_),e),i((E_||(E_=1,Object.defineProperty(I_,"__esModule",{value:!0})),I_),e),i((F_||(F_=1,Object.defineProperty(D_,"__esModule",{value:!0})),D_),e),i((N_||(N_=1,Object.defineProperty(P_,"__esModule",{value:!0})),P_),e),i((R_||(R_=1,Object.defineProperty(M_,"__esModule",{value:!0})),M_),e),i((L_||(L_=1,Object.defineProperty(C_,"__esModule",{value:!0})),C_),e),i((k_||(k_=1,Object.defineProperty(B_,"__esModule",{value:!0})),B_),e),i((U_||(U_=1,Object.defineProperty($_,"__esModule",{value:!0})),$_),e),i((q_||(q_=1,Object.defineProperty(Q_,"__esModule",{value:!0})),Q_),e),i((z_||(z_=1,Object.defineProperty(G_,"__esModule",{value:!0})),G_),e),i((V_||(V_=1,Object.defineProperty(X_,"__esModule",{value:!0})),X_),e),i((H_||(H_=1,Object.defineProperty(J_,"__esModule",{value:!0})),J_),e),i((W_||(W_=1,Object.defineProperty(K_,"__esModule",{value:!0})),K_),e),i((Y_||(Y_=1,Object.defineProperty(Z_,"__esModule",{value:!0})),Z_),e),i((ew||(ew=1,Object.defineProperty(tw,"__esModule",{value:!0})),tw),e),i((rw||(rw=1,Object.defineProperty(nw,"__esModule",{value:!0})),nw),e),i((iw||(iw=1,Object.defineProperty(ow,"__esModule",{value:!0})),ow),e),i((aw||(aw=1,Object.defineProperty(sw,"__esModule",{value:!0})),sw),e),i(function(){if(cw)return uw;cw=1,Object.defineProperty(uw,"__esModule",{value:!0}),uw.Logger=void 0;let e=class e{static getLevelOrdinal(t){return e.LEVELS[t]}};return uw.Logger=e,e.LEVELS={trace:0,debug:1,info:2,warn:3,error:4,fatal:5},uw}(),e),i((lw||(lw=1,Object.defineProperty(hw,"__esModule",{value:!0}),hw.ExpressionType=void 0,function(e){e.Aggregate="aggregate",e.Existence="existence",e.Operator="operator",e.Term="term",e.Variable="variable"}(t||(hw.ExpressionType=t={}))),hw),e)}(S_)),S_}function gw(){return fw||(fw=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(pw)return O_;pw=1,Object.defineProperty(O_,"__esModule",{value:!0}),O_.LoggerVoid=void 0;const e=yw();let t=class extends e.Logger{debug(){}error(){}fatal(){}info(){}trace(){}warn(){}};return O_.LoggerVoid=t,O_}(),e)}(T_)),T_}var mw,bw={},vw={};function _w(){if(mw)return vw;mw=1,Object.defineProperty(vw,"__esModule",{value:!0}),vw.MediatorFunctionFactory=vw.ActorFunctionFactory=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};vw.ActorFunctionFactory=t;class r extends e.Mediator{}return vw.MediatorFunctionFactory=r,vw}var ww,Tw={};var Ow,Sw={};var xw={},jw={},Aw={},Ew={},Iw={},Fw={},Dw={};Object.defineProperty(Dw,"__esModule",{value:!0}),Dw.BlankNode=void 0;Dw.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}};var Nw={},Pw={};Object.defineProperty(Pw,"__esModule",{value:!0}),Pw.DefaultGraph=void 0;let Rw=class{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}};Pw.DefaultGraph=Rw,Rw.INSTANCE=new Rw;var Mw={},Lw={};Object.defineProperty(Lw,"__esModule",{value:!0}),Lw.NamedNode=void 0;Lw.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}},Object.defineProperty(Mw,"__esModule",{value:!0}),Mw.Literal=void 0;const Cw=Lw;let kw=class e{constructor(t,r){this.termType="Literal",this.value=t,"string"==typeof r?(this.language=r,this.datatype=e.RDF_LANGUAGE_STRING):r?(this.language="",this.datatype=r):(this.language="",this.datatype=e.XSD_STRING)}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&this.datatype.equals(e.datatype)}};Mw.Literal=kw,kw.RDF_LANGUAGE_STRING=new Cw.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),kw.XSD_STRING=new Cw.NamedNode("http://www.w3.org/2001/XMLSchema#string");var Bw={};Object.defineProperty(Bw,"__esModule",{value:!0}),Bw.Quad=void 0;Bw.Quad=class{constructor(e,t,r,n){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=n}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}};var Uw={};Object.defineProperty(Uw,"__esModule",{value:!0}),Uw.Variable=void 0;Uw.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}},Object.defineProperty(Nw,"__esModule",{value:!0}),Nw.DataFactory=void 0;const $w=Dw,qw=Pw,Qw=Mw,zw=Lw,Gw=Bw,Vw=Uw;let Xw=0;Nw.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${Xw++}_`}namedNode(e){return new zw.NamedNode(e)}blankNode(e){return new $w.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new Qw.Literal(e,t)}variable(e){return new Vw.Variable(e)}defaultGraph(){return qw.DefaultGraph.INSTANCE}quad(e,t,r,n){return new Gw.Quad(e,t,r,n||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(Qw.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}},function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Dw,e),r(Nw,e),r(Pw,e),r(Mw,e),r(Lw,e),r(Bw,e),r(Uw,e)}(Fw),Object.defineProperty(Iw,"__esModule",{value:!0}),Iw.stringQuadToQuad=Iw.quadToStringQuad=Iw.stringToTerm=Iw.getLiteralLanguage=Iw.getLiteralType=Iw.getLiteralValue=Iw.termToString=void 0;const Hw=new Fw.DataFactory;function Jw(e){if(e)switch(e.termType){case"NamedNode":case"DefaultGraph":return e.value;case"BlankNode":return"_:"+e.value;case"Literal":const t=e;return'"'+t.value+'"'+(t.datatype&&"http://www.w3.org/2001/XMLSchema#string"!==t.datatype.value&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"!==t.datatype.value?"^^"+t.datatype.value:"")+(t.language?"@"+t.language:"");case"Quad":return`<<${Jw(e.subject)} ${Jw(e.predicate)} ${Jw(e.object)}${"DefaultGraph"===e.graph.termType?"":" "+Jw(e.graph)}>>`;case"Variable":return"?"+e.value}}function Ww(e){const t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]}function Kw(e){const t=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]||(t[2]?"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString":"http://www.w3.org/2001/XMLSchema#string")}function Yw(e){const t=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]?t[1].toLowerCase():""}function Zw(e,t){if(t=t||Hw,!e||!e.length)return t.defaultGraph();switch(e[0]){case"_":return t.blankNode(e.substr(2));case"?":if(!t.variable)throw new Error("Missing 'variable()' method on the given DataFactory");return t.variable(e.substr(1));case'"':const r=Yw(e),n=t.namedNode(Kw(e));return t.literal(Ww(e),r||n);default:if("<"===e[0]&&e.length>4&&"<"===e[1]&&">"===e[e.length-1]&&">"===e[e.length-2]){const r=e.slice(2,-2).trim();let n=[],i=0,o=0,a=!1;for(let t=0;t"===s){if(0===i)throw new Error("Found closing tag without opening tag in "+e);i--}if('"'===s){let e=!1,n=t;for(;n-- >0&&"\\"===r[n];)e=!e;e||(a=!a)}if(" "===s&&!a&&0===i){for(n.push(r.slice(o,t));" "===r[t+1];)t+=1;o=t+1}}if(0!==i)throw new Error("Found opening tag without closing tag in "+e);if(n.push(r.slice(o,r.length)),3!==n.length&&4!==n.length)throw new Error("Nested quad syntax error "+e);return n=n.map(e=>e.startsWith("<")&&!e.includes(" ")?e.slice(1,-1):e),t.quad(Zw(n[0]),Zw(n[1]),Zw(n[2]),n[3]?Zw(n[3]):void 0)}return t.namedNode(e)}}Iw.termToString=Jw,Iw.getLiteralValue=Ww,Iw.getLiteralType=Kw,Iw.getLiteralLanguage=Yw,Iw.stringToTerm=Zw,Iw.quadToStringQuad=function(e){return{subject:Jw(e.subject),predicate:Jw(e.predicate),object:Jw(e.object),graph:Jw(e.graph)}},Iw.stringQuadToQuad=function(e,t){return(t=t||Hw).quad(Zw(e.subject,t),Zw(e.predicate,t),Zw(e.object,t),Zw(e.graph,t))},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.termToString=e.stringToTerm=e.stringQuadToQuad=e.quadToStringQuad=e.getLiteralValue=e.getLiteralType=e.getLiteralLanguage=void 0;const t=Iw;Object.defineProperty(e,"getLiteralLanguage",{enumerable:!0,get:function(){return t.getLiteralLanguage}}),Object.defineProperty(e,"getLiteralType",{enumerable:!0,get:function(){return t.getLiteralType}}),Object.defineProperty(e,"getLiteralValue",{enumerable:!0,get:function(){return t.getLiteralValue}}),Object.defineProperty(e,"quadToStringQuad",{enumerable:!0,get:function(){return t.quadToStringQuad}}),Object.defineProperty(e,"stringQuadToQuad",{enumerable:!0,get:function(){return t.stringQuadToQuad}}),Object.defineProperty(e,"stringToTerm",{enumerable:!0,get:function(){return t.stringToTerm}}),Object.defineProperty(e,"termToString",{enumerable:!0,get:function(){return t.termToString}})}(Ew);var eT,tT,rT={},nT={};var iT,oT={},aT={},sT={},cT={};function uT(){if(iT)return cT;iT=1,Object.defineProperty(cT,"__esModule",{value:!0}),cT.BlankNode=void 0;return cT.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}},cT}var lT,dT={},pT={};function fT(){if(lT)return pT;lT=1,Object.defineProperty(pT,"__esModule",{value:!0}),pT.DefaultGraph=void 0;class e{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}}return pT.DefaultGraph=e,e.INSTANCE=new e,pT}var hT,yT,gT={},mT={};function bT(){if(hT)return mT;hT=1,Object.defineProperty(mT,"__esModule",{value:!0}),mT.NamedNode=void 0;return mT.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}},mT}function vT(){if(yT)return gT;yT=1,Object.defineProperty(gT,"__esModule",{value:!0}),gT.Literal=void 0;const e=bT();class t{constructor(e,r){this.termType="Literal",this.value=e,"string"==typeof r?(this.language=r,this.datatype=t.RDF_LANGUAGE_STRING,this.direction=""):r?"termType"in r?(this.language="",this.datatype=r,this.direction=""):(this.language=r.language,this.datatype=r.direction?t.RDF_DIRECTIONAL_LANGUAGE_STRING:t.RDF_LANGUAGE_STRING,this.direction=r.direction||""):(this.language="",this.datatype=t.XSD_STRING,this.direction="")}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&(e.direction===this.direction||!e.direction&&""===this.direction)&&this.datatype.equals(e.datatype)}}return gT.Literal=t,t.RDF_LANGUAGE_STRING=new e.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),t.RDF_DIRECTIONAL_LANGUAGE_STRING=new e.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"),t.XSD_STRING=new e.NamedNode("http://www.w3.org/2001/XMLSchema#string"),gT}var _T,wT={};function TT(){if(_T)return wT;_T=1,Object.defineProperty(wT,"__esModule",{value:!0}),wT.Quad=void 0;return wT.Quad=class{constructor(e,t,r,n){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=n}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}},wT}var OT,ST,xT,jT,AT,ET={};function IT(){if(OT)return ET;OT=1,Object.defineProperty(ET,"__esModule",{value:!0}),ET.Variable=void 0;return ET.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}},ET}function FT(){return xT||(xT=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(uT(),e),r(function(){if(ST)return dT;ST=1,Object.defineProperty(dT,"__esModule",{value:!0}),dT.DataFactory=void 0;const e=uT(),t=fT(),r=vT(),n=bT(),i=TT(),o=IT();let a=0;return dT.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${a++}_`}namedNode(e){return new n.NamedNode(e)}blankNode(t){return new e.BlankNode(t||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new r.Literal(e,t)}variable(e){return new o.Variable(e)}defaultGraph(){return t.DefaultGraph.INSTANCE}quad(e,t,r,n){return new i.Quad(e,t,r,n||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(r.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}},dT}(),e),r(fT(),e),r(vT(),e),r(bT(),e),r(TT(),e),r(IT(),e)}(sT)),sT}function DT(){return AT||(AT=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.termToString=e.stringToTerm=e.stringQuadToQuad=e.quadToStringQuad=e.getLiteralValue=e.getLiteralType=e.getLiteralDirection=e.getLiteralLanguage=void 0;const t=function(){if(jT)return aT;jT=1,Object.defineProperty(aT,"__esModule",{value:!0}),aT.termToString=t,aT.getLiteralValue=r,aT.getLiteralType=n,aT.getLiteralLanguage=i,aT.getLiteralDirection=o,aT.stringToTerm=a,aT.quadToStringQuad=function(e){return{subject:t(e.subject),predicate:t(e.predicate),object:t(e.object),graph:t(e.graph)}},aT.stringQuadToQuad=function(t,r){return(r=r||e).quad(a(t.subject,r),a(t.predicate,r),a(t.object,r),a(t.graph,r))};const e=new(FT().DataFactory);function t(e){if(e)switch(e.termType){case"NamedNode":case"DefaultGraph":return e.value;case"BlankNode":return"_:"+e.value;case"Literal":const r=e;return'"'+r.value+'"'+(r.datatype&&"http://www.w3.org/2001/XMLSchema#string"!==r.datatype.value&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"!==r.datatype.value&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"!==r.datatype.value?"^^"+r.datatype.value:"")+(r.language?"@"+r.language:"")+(r.direction?"--"+r.direction:"");case"Quad":return`<<${t(e.subject)} ${t(e.predicate)} ${t(e.object)}${"DefaultGraph"===e.graph.termType?"":" "+t(e.graph)}>>`;case"Variable":return"?"+e.value}}function r(e){const t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]}function n(e){const t=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]||(t[2]?"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString":"http://www.w3.org/2001/XMLSchema#string")}function i(e){const t=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");if(t[1]){let e=t[1].toLowerCase();const r=e.indexOf("--");return r>=0&&(e=e.slice(0,r)),e}return""}function o(e){const t=e.indexOf("--",e.lastIndexOf('"'));if(t>=0){const r=e.slice(t+2,e.length);if("ltr"===r||"rtl"===r)return r;throw new Error(e+" is not a literal with a valid direction")}return""}function a(t,s){if(s=s||e,!t||!t.length)return s.defaultGraph();switch(t[0]){case"_":return s.blankNode(t.substr(2));case"?":if(!s.variable)throw new Error("Missing 'variable()' method on the given DataFactory");return s.variable(t.substr(1));case'"':const e=i(t),c=o(t),u=s.namedNode(n(t));return s.literal(r(t),e?{language:e,direction:c}:u);default:if("<"===t[0]&&t.length>4&&"<"===t[1]&&">"===t[t.length-1]&&">"===t[t.length-2]){const e=t.slice(2,-2).trim();let r=[],n=0,i=0,o=!1;for(let a=0;a"===s){if(0===n)throw new Error("Found closing tag without opening tag in "+t);n--}if('"'===s){let t=!1,r=a;for(;r-- >0&&"\\"===e[r];)t=!t;t||(o=!o)}if(" "===s&&!o&&0===n){for(r.push(e.slice(i,a));" "===e[a+1];)a+=1;i=a+1}}if(0!==n)throw new Error("Found opening tag without closing tag in "+t);if(r.push(e.slice(i,e.length)),3!==r.length&&4!==r.length)throw new Error("Nested quad syntax error "+t);return r=r.map(e=>e.startsWith("<")&&!e.includes(" ")?e.slice(1,-1):e),s.quad(a(r[0]),a(r[1]),a(r[2]),r[3]?a(r[3]):void 0)}return s.namedNode(t)}}return aT}();Object.defineProperty(e,"getLiteralLanguage",{enumerable:!0,get:function(){return t.getLiteralLanguage}}),Object.defineProperty(e,"getLiteralDirection",{enumerable:!0,get:function(){return t.getLiteralDirection}}),Object.defineProperty(e,"getLiteralType",{enumerable:!0,get:function(){return t.getLiteralType}}),Object.defineProperty(e,"getLiteralValue",{enumerable:!0,get:function(){return t.getLiteralValue}}),Object.defineProperty(e,"quadToStringQuad",{enumerable:!0,get:function(){return t.quadToStringQuad}}),Object.defineProperty(e,"stringQuadToQuad",{enumerable:!0,get:function(){return t.stringQuadToQuad}}),Object.defineProperty(e,"stringToTerm",{enumerable:!0,get:function(){return t.stringToTerm}}),Object.defineProperty(e,"termToString",{enumerable:!0,get:function(){return t.termToString}})}(oT)),oT}var NT,PT={};function RT(){return NT||(NT=1,function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.expressionTypes=e.types=void 0,function(e){e.ALT="alt",e.ASK="ask",e.BGP="bgp",e.CONSTRUCT="construct",e.DESCRIBE="describe",e.DISTINCT="distinct",e.EXPRESSION="expression",e.EXTEND="extend",e.FILTER="filter",e.FROM="from",e.GRAPH="graph",e.GROUP="group",e.INV="inv",e.JOIN="join",e.LEFT_JOIN="leftjoin",e.LINK="link",e.MINUS="minus",e.NOP="nop",e.NPS="nps",e.ONE_OR_MORE_PATH="OneOrMorePath",e.ORDER_BY="orderby",e.PATH="path",e.PATTERN="pattern",e.PROJECT="project",e.REDUCED="reduced",e.SEQ="seq",e.SERVICE="service",e.SLICE="slice",e.UNION="union",e.VALUES="values",e.ZERO_OR_MORE_PATH="ZeroOrMorePath",e.ZERO_OR_ONE_PATH="ZeroOrOnePath",e.COMPOSITE_UPDATE="compositeupdate",e.DELETE_INSERT="deleteinsert",e.LOAD="load",e.CLEAR="clear",e.CREATE="create",e.DROP="drop",e.ADD="add",e.MOVE="move",e.COPY="copy"}(e.types||(e.types={})),(t=e.expressionTypes||(e.expressionTypes={})).AGGREGATE="aggregate",t.EXISTENCE="existence",t.NAMED="named",t.OPERATOR="operator",t.TERM="term",t.WILDCARD="wildcard"}(PT)),PT}var MT,LT,CT,kT,BT,UT,$T,qT,QT={},zT={};function GT(){if(MT)return zT;MT=1;let e=class{constructor(){return t||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(e.prototype,"value",{enumerable:!0,value:"*"}),Object.defineProperty(e.prototype,"termType",{enumerable:!0,value:"Wildcard"});var t=new e;return zT.Wildcard=e,zT}function VT(){if(CT)return LT;CT=1;var e=function(){var e=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r},t=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],r=[2,247],n=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],o=[1,18],a=[1,27],s=[13,16,45,197,224,229,308],c=[28,29,53],u=[28,53],l=[1,42],d=[1,45],p=[1,41],f=[1,44],h=[123,126],y=[1,67],g=[39,45,87],m=[13,16,45,197,224,308],b=[1,87],v=[2,281],_=[1,86],w=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],T=[6,28,29,53,63,70,73,81,83,85],O=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],S=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],x=[6,13,16,28,29,31,39,45,47,48,53,63,70,73,81,82,83,85,87,89,109,112,121,123,126,128,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,337,338,340,341,342,343,344,345,346],j=[13,16,308],A=[112,132,327,334],E=[13,16,112,132,308],I=[1,111],F=[1,117],D=[112,132,327,328,334],N=[13,16,112,132,308,328],P=[28,29,45,53,87],R=[1,138],M=[1,151],L=[1,128],C=[1,127],k=[1,129],B=[1,140],U=[1,141],q=[1,142],Q=[1,143],z=[1,144],G=[1,145],V=[1,147],X=[1,148],H=[2,457],J=[1,158],W=[1,159],K=[1,160],Y=[1,152],Z=[1,153],ee=[1,156],te=[1,171],re=[1,172],ne=[1,173],ie=[1,174],oe=[1,175],ae=[1,176],se=[1,167],ce=[1,168],ue=[1,169],le=[1,170],de=[1,157],pe=[1,166],fe=[1,161],he=[1,162],ye=[1,163],ge=[1,164],me=[1,165],be=[6,13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],ve=[1,195],_e=[6,31,73,81,83,85],we=[2,285],Te=[1,199],Oe=[1,201],Se=[6,31,70,73,81,83,85],xe=[2,283],je=[1,207],Ae=[1,218],Ee=[1,223],Ie=[1,219],Fe=[1,225],De=[1,226],Ne=[1,224],Pe=[6,63,70,73,81,83,85],Re=[1,236],Me=[2,334],Le=[1,243],Ce=[1,241],ke=[6,193],Be=[2,349],Ue=[2,339],$e=[28,128],qe=[47,48,193,272],Qe=[47,48,193,242,272],ze=[47,48,193,242,246,272],Ge=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Ve=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],Xe=[1,271],He=[1,270],Je=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],We=[1,281],Ke=[1,280],Ye=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],Ze=[45,89],et=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],tt=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],rt=[31,89],nt=[48,87],it=[6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338],ot=[6,13,16,39,45,48,82,87,89,231,263,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338,340],at=[1,313],st=[6,85],ct=[6,31,81,83,85],ut=[2,361],lt=[2,353],dt=[1,343],pt=[31,112,335],ft=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],ht=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335],yt=[6,109,193],gt=[31,112],mt=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],bt=[1,390],vt=[1,391],_t=[13,16,87,197,308,314],wt=[13,16,39,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Tt=[1,417],Ot=[1,418],St=[13,16,48,197,229,308],xt=[6,31,85],jt=[6,13,16,31,45,73,81,83,85,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],At=[6,13,16,29,31,45,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,231,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,346,347,348,349,350,351],Et=[29,31,85,112,159,160,161,163,164],It=[1,443],Ft=[1,444],Dt=[1,449],Nt=[31,112,193,232,318,335],Pt=[13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Rt=[13,16,31,45,48,82,87,89,112,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Mt=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Lt=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Ct=[31,45],kt=[1,507],Bt=[1,508],Ut=[6,13,16,29,31,39,45,47,48,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,336,338,341,342,343,344,345,346,347,348,349,350,351],$t=[29,31,85,112,159,160,161,163,164,335],qt=[6,13,16,31,45,70,73,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Qt=[13,16,31,45,48,82,87,89,112,193,197,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],zt=[2,352],Gt=[13,16,197,308,314],Vt=[1,565],Xt=[6,13,16,31,45,76,78,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Ht=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Jt=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],Wt=[13,16,87,308],Kt=[2,364],Yt=[29,31,85,112,159,160,161,163,164,193,232,318,335],Zt=[31,112,193,232,272,318,335],er=[2,359],tr=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],rr=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],nr=[13,16,31,45,82,87,89,112,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],ir=[2,347],or={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Query:7,Qry:8,Query_option0:9,Prologue_repetition0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectClauseWildcard:17,Qry_repetition0:18,WhereClause:19,SolutionModifierNoGroup:20,SelectClauseVars:21,Qry_repetition1:22,SolutionModifier:23,CONSTRUCT:24,ConstructTemplate:25,Qry_repetition2:26,Qry_repetition3:27,WHERE:28,"{":29,Qry_option0:30,"}":31,DESCRIBE:32,Qry_group0:33,Qry_repetition4:34,Qry_option1:35,ASK:36,Qry_repetition5:37,SelectClauseBase:38,"*":39,SelectClauseVars_repetition_plus0:40,SELECT:41,SelectClauseBase_option0:42,SelectClauseItem:43,Var:44,"(":45,Expression:46,AS:47,")":48,SubSelect:49,SubSelect_option0:50,SubSelect_option1:51,DatasetClause:52,FROM:53,DatasetClause_option0:54,iri:55,WhereClause_option0:56,GroupGraphPattern:57,SolutionModifier_option0:58,SolutionModifierNoGroup_option0:59,SolutionModifierNoGroup_option1:60,SolutionModifierNoGroup_option2:61,GroupClause:62,GROUP:63,BY:64,GroupClause_repetition_plus0:65,GroupCondition:66,BuiltInCall:67,FunctionCall:68,HavingClause:69,HAVING:70,HavingClause_repetition_plus0:71,OrderClause:72,ORDER:73,OrderClause_repetition_plus0:74,OrderCondition:75,ASC:76,BrackettedExpression:77,DESC:78,Constraint:79,LimitOffsetClauses:80,LIMIT:81,INTEGER:82,OFFSET:83,ValuesClause:84,VALUES:85,InlineData:86,VAR:87,InlineData_repetition0:88,NIL:89,InlineData_repetition1:90,InlineData_repetition_plus2:91,InlineData_repetition3:92,DataBlock:93,DataBlockValueList:94,DataBlockValueList_repetition_plus0:95,Update:96,Update_repetition0:97,Update1:98,Update_option0:99,LOAD:100,Update1_option0:101,Update1_option1:102,Update1_group0:103,Update1_option2:104,GraphRefAll:105,Update1_group1:106,Update1_option3:107,GraphOrDefault:108,TO:109,CREATE:110,Update1_option4:111,GRAPH:112,INSERTDATA:113,QuadPattern:114,DELETEDATA:115,DELETEWHERE:116,Update1_option5:117,InsertDeleteClause:118,Update1_repetition0:119,IntoGraphClause:120,INTO:121,GraphRef:122,DELETE:123,InsertDeleteClause_option0:124,InsertClause:125,INSERT:126,UsingClause:127,USING:128,UsingClause_option0:129,WithClause:130,WITH:131,DEFAULT:132,GraphOrDefault_option0:133,GraphRefAll_group0:134,Quads:135,Quads_option0:136,Quads_repetition0:137,QuadsNotTriples:138,VarOrIri:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GroupOrUnionGraphPattern:158,OPTIONAL:159,MINUS:160,SERVICE:161,GraphPatternNotTriples_option0:162,FILTER:163,BIND:164,InlineDataOneVar:165,InlineDataFull:166,InlineDataOneVar_repetition0:167,InlineDataFull_repetition0:168,InlineDataFull_repetition_plus1:169,InlineDataFull_repetition2:170,DataBlockValue:171,Literal:172,QuotedTriple:173,UNDEF:174,GroupOrUnionGraphPattern_repetition0:175,ArgList:176,ArgList_option0:177,ArgList_repetition0:178,ExpressionList:179,ExpressionList_repetition0:180,ConstructTemplate_option0:181,ConstructTriples:182,ConstructTriples_repetition0:183,ConstructTriples_option0:184,VarOrTermOrQuotedTP:185,PropertyListNotEmpty:186,TriplesNode:187,PropertyList:188,PropertyList_option0:189,VerbObjectList:190,PropertyListNotEmpty_repetition0:191,SemiOptionalVerbObjectList:192,";":193,SemiOptionalVerbObjectList_option0:194,Verb:195,ObjectList:196,a:197,ObjectList_repetition0:198,Object:199,GraphNode:200,Object_option0:201,PropertyListPathNotEmpty:202,TriplesNodePath:203,TriplesSameSubjectPath_option0:204,O:205,PropertyListPathNotEmpty_repetition0:206,PropertyListPathNotEmptyTail:207,O_group0:208,ObjectListPath:209,ObjectListPath_repetition0:210,ObjectPath:211,GraphNodePath:212,ObjectPath_option0:213,Path:214,Path_repetition0:215,PathSequence:216,PathSequence_repetition0:217,PathEltOrInverse:218,PathElt:219,PathPrimary:220,PathElt_option0:221,PathEltOrInverse_option0:222,IriOrA:223,"!":224,PathNegatedPropertySet:225,PathOneInPropertySet:226,PathNegatedPropertySet_repetition0:227,PathNegatedPropertySet_option0:228,"^":229,TriplesNode_repetition_plus0:230,"[":231,"]":232,TriplesNodePath_repetition_plus0:233,VarOrTermOrQuotedTPExpr:234,VarOrTerm:235,GraphTerm:236,BlankNode:237,ConditionalOrExpression:238,ConditionalAndExpression:239,ConditionalOrExpression_repetition0:240,ConditionalOrExpressionTail:241,"||":242,RelationalExpression:243,ConditionalAndExpression_repetition0:244,ConditionalAndExpressionTail:245,"&&":246,NumericExpression:247,RelationalExpression_group0:248,RelationalExpression_option0:249,IN:250,MultiplicativeExpression:251,NumericExpression_repetition0:252,AdditiveExpressionTail:253,AdditiveExpressionTail_group0:254,NumericLiteralPositive:255,AdditiveExpressionTail_repetition0:256,NumericLiteralNegative:257,AdditiveExpressionTail_repetition1:258,UnaryExpression:259,MultiplicativeExpression_repetition0:260,MultiplicativeExpressionTail:261,MultiplicativeExpressionTail_group0:262,"+":263,PrimaryExpression:264,"-":265,ExprQuotedTP:266,Aggregate:267,FUNC_ARITY0:268,FUNC_ARITY1:269,FUNC_ARITY1_SPARQL_STAR:270,FUNC_ARITY2:271,",":272,FUNC_ARITY3:273,FUNC_ARITY3_SPARQL_STAR:274,BuiltInCall_group0:275,BOUND:276,BNODE:277,BuiltInCall_option0:278,EXISTS:279,COUNT:280,Aggregate_option0:281,Aggregate_group0:282,FUNC_AGGREGATE:283,Aggregate_option1:284,GROUP_CONCAT:285,Aggregate_option2:286,Aggregate_option3:287,GroupConcatSeparator:288,SEPARATOR:289,"=":290,String:291,LANGTAG:292,"^^":293,DECIMAL:294,DOUBLE:295,BOOLEAN:296,INTEGER_POSITIVE:297,DECIMAL_POSITIVE:298,DOUBLE_POSITIVE:299,INTEGER_NEGATIVE:300,DECIMAL_NEGATIVE:301,DOUBLE_NEGATIVE:302,STRING_LITERAL1:303,STRING_LITERAL2:304,STRING_LITERAL_LONG1:305,STRING_LITERAL_LONG2:306,PrefixedName:307,PNAME_LN:308,BLANK_NODE_LABEL:309,ANON:310,QuotedTP:311,"<<":312,qtSubjectOrObject:313,">>":314,DataValueTerm:315,AnnotationPattern:316,"{|":317,"|}":318,AnnotationPatternPath:319,ExprVarOrTerm:320,QueryOrUpdate_group0_option0:321,Prologue_repetition0_group0:322,Qry_group0_repetition_plus0:323,SelectClauseBase_option0_group0:324,DISTINCT:325,REDUCED:326,NAMED:327,SILENT:328,CLEAR:329,DROP:330,ADD:331,MOVE:332,COPY:333,ALL:334,".":335,UNION:336,"|":337,"/":338,PathElt_option0_group0:339,"?":340,"!=":341,"<":342,">":343,"<=":344,">=":345,NOT:346,CONCAT:347,COALESCE:348,SUBSTR:349,REGEX:350,REPLACE:351,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"CONSTRUCT",28:"WHERE",29:"{",31:"}",32:"DESCRIBE",36:"ASK",39:"*",41:"SELECT",45:"(",47:"AS",48:")",53:"FROM",63:"GROUP",64:"BY",70:"HAVING",73:"ORDER",76:"ASC",78:"DESC",81:"LIMIT",82:"INTEGER",83:"OFFSET",85:"VALUES",87:"VAR",89:"NIL",100:"LOAD",109:"TO",110:"CREATE",112:"GRAPH",113:"INSERTDATA",115:"DELETEDATA",116:"DELETEWHERE",121:"INTO",123:"DELETE",126:"INSERT",128:"USING",131:"WITH",132:"DEFAULT",159:"OPTIONAL",160:"MINUS",161:"SERVICE",163:"FILTER",164:"BIND",174:"UNDEF",193:";",197:"a",224:"!",229:"^",231:"[",232:"]",242:"||",246:"&&",250:"IN",263:"+",265:"-",268:"FUNC_ARITY0",269:"FUNC_ARITY1",270:"FUNC_ARITY1_SPARQL_STAR",271:"FUNC_ARITY2",272:",",273:"FUNC_ARITY3",274:"FUNC_ARITY3_SPARQL_STAR",276:"BOUND",277:"BNODE",279:"EXISTS",280:"COUNT",283:"FUNC_AGGREGATE",285:"GROUP_CONCAT",289:"SEPARATOR",290:"=",292:"LANGTAG",293:"^^",294:"DECIMAL",295:"DOUBLE",296:"BOOLEAN",297:"INTEGER_POSITIVE",298:"DECIMAL_POSITIVE",299:"DOUBLE_POSITIVE",300:"INTEGER_NEGATIVE",301:"DECIMAL_NEGATIVE",302:"DOUBLE_NEGATIVE",303:"STRING_LITERAL1",304:"STRING_LITERAL2",305:"STRING_LITERAL_LONG1",306:"STRING_LITERAL_LONG2",308:"PNAME_LN",309:"BLANK_NODE_LABEL",310:"ANON",312:"<<",314:">>",317:"{|",318:"|}",325:"DISTINCT",326:"REDUCED",327:"NAMED",328:"SILENT",329:"CLEAR",330:"DROP",331:"ADD",332:"MOVE",333:"COPY",334:"ALL",335:".",336:"UNION",337:"|",338:"/",340:"?",341:"!=",342:"<",343:">",344:"<=",345:">=",346:"NOT",347:"CONCAT",348:"COALESCE",349:"SUBSTR",350:"REGEX",351:"REPLACE"},productions_:[0,[3,3],[7,2],[4,1],[11,2],[14,3],[8,4],[8,4],[8,5],[8,7],[8,5],[8,4],[17,2],[21,2],[38,2],[43,1],[43,5],[49,4],[49,4],[52,3],[19,2],[23,2],[20,3],[62,3],[66,1],[66,1],[66,3],[66,5],[66,1],[69,2],[72,3],[75,2],[75,2],[75,1],[75,1],[80,2],[80,2],[80,4],[80,4],[84,2],[86,4],[86,4],[86,6],[86,2],[94,3],[96,3],[98,4],[98,3],[98,5],[98,4],[98,2],[98,2],[98,2],[98,5],[120,2],[118,3],[118,1],[125,2],[127,3],[130,2],[108,1],[108,2],[122,2],[105,1],[105,1],[114,3],[135,2],[138,7],[143,3],[57,3],[57,3],[147,2],[150,3],[154,3],[151,1],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[93,1],[93,1],[165,4],[166,4],[166,6],[171,1],[171,1],[171,1],[171,1],[158,2],[79,1],[79,1],[79,1],[68,2],[176,1],[176,5],[179,1],[179,4],[25,3],[182,3],[145,2],[145,2],[188,1],[186,2],[192,2],[190,2],[195,1],[195,1],[196,2],[199,2],[156,2],[156,2],[202,2],[207,1],[207,2],[205,2],[209,2],[211,2],[214,2],[216,2],[219,2],[218,2],[220,1],[220,2],[220,3],[225,1],[225,1],[225,4],[226,1],[226,2],[187,3],[187,3],[203,3],[203,3],[200,1],[200,1],[212,1],[212,1],[234,1],[235,1],[235,1],[139,1],[139,1],[44,1],[236,1],[236,1],[236,1],[236,1],[46,1],[238,2],[241,2],[239,2],[245,2],[243,1],[243,3],[243,4],[247,2],[253,2],[253,2],[253,2],[251,2],[261,2],[259,2],[259,2],[259,2],[259,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[77,3],[67,1],[67,2],[67,4],[67,4],[67,6],[67,8],[67,8],[67,2],[67,4],[67,2],[67,4],[67,3],[267,5],[267,5],[267,6],[288,4],[172,1],[172,2],[172,3],[172,1],[172,1],[172,1],[172,1],[172,1],[172,1],[255,1],[255,1],[255,1],[257,1],[257,1],[257,1],[291,1],[291,1],[291,1],[291,1],[55,1],[55,1],[307,1],[307,1],[237,1],[237,1],[311,5],[173,5],[313,1],[313,1],[313,1],[313,1],[313,1],[315,1],[315,1],[315,1],[185,1],[185,1],[185,1],[316,3],[319,3],[266,5],[320,1],[320,1],[320,1],[223,1],[223,1],[321,0],[321,1],[5,1],[5,1],[5,1],[9,0],[9,1],[322,1],[322,1],[10,0],[10,2],[18,0],[18,2],[22,0],[22,2],[26,0],[26,2],[27,0],[27,2],[30,0],[30,1],[323,1],[323,2],[33,1],[33,1],[34,0],[34,2],[35,0],[35,1],[37,0],[37,2],[40,1],[40,2],[324,1],[324,1],[42,0],[42,1],[50,0],[50,1],[51,0],[51,1],[54,0],[54,1],[56,0],[56,1],[58,0],[58,1],[59,0],[59,1],[60,0],[60,1],[61,0],[61,1],[65,1],[65,2],[71,1],[71,2],[74,1],[74,2],[88,0],[88,2],[90,0],[90,2],[91,1],[91,2],[92,0],[92,2],[95,1],[95,2],[97,0],[97,4],[99,0],[99,2],[101,0],[101,1],[102,0],[102,1],[103,1],[103,1],[104,0],[104,1],[106,1],[106,1],[106,1],[107,0],[107,1],[111,0],[111,1],[117,0],[117,1],[119,0],[119,2],[124,0],[124,1],[129,0],[129,1],[133,0],[133,1],[134,1],[134,1],[134,1],[136,0],[136,1],[137,0],[137,2],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[162,0],[162,1],[167,0],[167,2],[168,0],[168,2],[169,1],[169,2],[170,0],[170,2],[175,0],[175,3],[177,0],[177,1],[178,0],[178,3],[180,0],[180,3],[181,0],[181,1],[183,0],[183,3],[184,0],[184,1],[189,0],[189,1],[191,0],[191,2],[194,0],[194,1],[198,0],[198,3],[201,0],[201,1],[204,0],[204,1],[206,0],[206,2],[208,1],[208,1],[210,0],[210,3],[213,0],[213,1],[215,0],[215,3],[217,0],[217,3],[339,1],[339,1],[339,1],[221,0],[221,1],[222,0],[222,1],[227,0],[227,3],[228,0],[228,1],[230,1],[230,2],[233,1],[233,2],[240,0],[240,2],[244,0],[244,2],[248,1],[248,1],[248,1],[248,1],[248,1],[248,1],[249,0],[249,1],[252,0],[252,2],[254,1],[254,1],[256,0],[256,2],[258,0],[258,2],[260,0],[260,2],[262,1],[262,1],[275,1],[275,1],[275,1],[275,1],[275,1],[278,0],[278,1],[281,0],[281,1],[282,1],[282,1],[284,0],[284,1],[286,0],[286,1],[287,0],[287,1]],performAction:function(e,t,r,n,i,o,a){var s,c,u,l,d=o.length-1;switch(i){case 1:if(o[d-1]=o[d-1]||{},nn.base&&(o[d-1].base=nn.base),nn.base="",o[d-1].prefixes=nn.prefixes,nn.prefixes=null,nn.pathOnly){if("path"===o[d-1].type||"termType"in o[d-1])return o[d-1];throw new Error("Received full SPARQL query in path only mode")}if("path"===o[d-1].type||"termType"in o[d-1])throw new Error("Received only path in full SPARQL mode");if("update"===o[d-1].type){const e={};for(const t of o[d-1].updates)if("insert"===t.updateType){const r={};for(const e of t.insert)if("bgp"===e.type||"graph"===e.type)for(const t of e.triples)"BlankNode"===t.subject.termType&&(r[t.subject.value]=!0),"BlankNode"===t.predicate.termType&&(r[t.predicate.value]=!0),"BlankNode"===t.object.termType&&(r[t.object.value]=!0);for(const t of Object.keys(r)){if(e[t])throw new Error("Detected reuse blank node across different INSERT DATA clauses");e[t]=!0}}}return o[d-1];case 2:this.$={...o[d-1],...o[d],type:"query"};break;case 4:nn.base=xr(o[d]);break;case 5:nn.prefixes||(nn.prefixes={}),o[d-1]=o[d-1].substr(0,o[d-1].length-1),o[d]=xr(o[d]),nn.prefixes[o[d-1]]=o[d];break;case 6:this.$={...o[d-3],...Dr(o[d-2]),...o[d-1],...o[d]};break;case 7:if(!nn.skipValidation){if(Hr(o[d-3].variables.map(e=>Vr(e.expression))).some(e=>"count"===e.aggregation&&!(e.expression instanceof ar))||o[d].group)for(const e of o[d-3].variables)if("Variable"===e.termType){if(!o[d].group||!o[d].group.map(e=>Gr(e)).includes(Gr(e)))throw Error("Projection of ungrouped variable (?"+Gr(e)+")")}else if(0===Vr(e.expression).length){const t=Xr(e.expression);for(const e of t)if(!o[d].group||!o[d].group.map||!o[d].group.map(e=>Gr(e)).includes(Gr(e)))throw Error("Use of ungrouped variable in projection of operation (?"+Gr(e)+")")}}const e=o[d-1].where.filter(e=>"query"===e.type);if(e.length>0){const t=o[d-3].variables.filter(e=>e.variable&&e.variable.value).map(e=>e.variable.value),r=Hr(e.map(e=>e.variables)).map(e=>e.value||e.variable.value);for(const e of t)if(r.indexOf(e)>=0)throw Error("Target id of 'AS' (?"+e+") already used in subquery")}this.$=Or(o[d-3],Dr(o[d-2]),o[d-1],o[d]);break;case 8:this.$=Or({queryType:"CONSTRUCT",template:o[d-3]},Dr(o[d-2]),o[d-1],o[d]);break;case 9:this.$=Or({queryType:"CONSTRUCT",template:o[d-2]=o[d-2]?o[d-2].triples:[]},Dr(o[d-5]),{where:[{type:"bgp",triples:Tr([],o[d-2])}]},o[d]);break;case 10:this.$=Or({queryType:"DESCRIBE",variables:"*"===o[d-3]?[new ar]:o[d-3]},Dr(o[d-2]),o[d-1],o[d]);break;case 11:this.$=Or({queryType:"ASK"},Dr(o[d-2]),o[d-1],o[d]);break;case 12:this.$=Or(o[d-1],{variables:[new ar]});break;case 13:const t=function(e){const t=e.slice().sort(),r=[];for(let e=0;ee.value||e.variable.value));if(t.length>0)throw Error("Two or more of the resulting columns have the same name (?"+t[0]+")");this.$=Or(o[d-1],{variables:o[d]});break;case 14:this.$=Or({queryType:"SELECT"},o[d]&&(o[d-1]=_r(o[d]),o[d]={},o[d][o[d-1]]=!0,o[d]));break;case 16:case 27:this.$=Er(o[d-3],{variable:o[d-1]});break;case 17:case 18:this.$=Or(o[d-3],o[d-2],o[d-1],o[d],{type:"query"});break;case 19:case 58:this.$={iri:o[d],named:!!o[d-1]};break;case 20:this.$={where:o[d].patterns};break;case 21:this.$=Or(o[d-1],o[d]);break;case 22:this.$=Or(o[d-2],o[d-1],o[d]);break;case 23:this.$={group:o[d]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Er(o[d]);break;case 26:this.$=Er(o[d-1]);break;case 29:this.$={having:o[d]};break;case 30:this.$={order:o[d]};break;case 32:this.$=Er(o[d],{descending:!0});break;case 35:this.$={limit:Nr(o[d])};break;case 36:this.$={offset:Nr(o[d])};break;case 37:this.$={limit:Nr(o[d-2]),offset:Nr(o[d])};break;case 38:this.$={limit:Nr(o[d]),offset:Nr(o[d-2])};break;case 39:case 43:this.$={type:"values",values:o[d]};break;case 40:case 84:this.$=o[d-1].map(e=>({[o[d-3]]:e}));break;case 41:case 85:this.$=o[d-1].map(()=>({}));break;case 42:case 86:var p=o[d-4].length;o[d-4]=o[d-4].map(jr),this.$=o[d-1].map(function(e){if(e.length!==p)throw Error("Inconsistent VALUES length");for(var t={},r=0;r"bind"===e.type)){const t=o[d-1].indexOf(e),r=new Set;for(const e of o[d-1].slice(0,t))"group"!==e.type&&"bgp"!==e.type||Wr(e).forEach(e=>r.add(e));if(r.has(e.variable.value))throw Error("Variable used to bind is already bound (?"+e.variable.value+")")}this.$={type:"group",patterns:o[d-1]};break;case 71:this.$=o[d-1]?Sr([o[d-1]],o[d]):Sr(o[d]);break;case 72:this.$=o[d]?[o[d-2],o[d]]:o[d-2];break;case 75:this.$=Or(o[d],{type:"optional"});break;case 76:this.$=Or(o[d],{type:"minus"});break;case 77:this.$=Or(o[d],{type:"graph",name:o[d-1]});break;case 78:this.$=Or(o[d],{type:"service",name:o[d-1],silent:!!o[d-2]});break;case 79:this.$={type:"filter",expression:o[d]};break;case 80:this.$={type:"bind",variable:o[d-1],expression:o[d-3]};break;case 89:this.$=Kr(o[d]);break;case 90:this.$=void 0;break;case 91:this.$=o[d-1].length?{type:"union",patterns:Sr(o[d-1].map(Pr),[Pr(o[d])])}:o[d];break;case 95:this.$={...o[d],function:o[d-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:wr(o[d-2],o[d-1]),distinct:!!o[d-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=wr(o[d-2],o[d-1]);break;case 101:this.$=Sr(o[d-2],[o[d-1]]);break;case 102:case 112:this.$=Zr(o[d].map(e=>Or(Lr(o[d-1]),e)));break;case 103:this.$=Zr(Tr(o[d].map(e=>Or(Lr(o[d-1].entity),e)),o[d-1].triples));break;case 105:this.$=Sr([o[d-1]],o[d]);break;case 106:this.$=Sr(o[d]);break;case 107:this.$=zr(o[d-1],o[d]);break;case 109:case 237:this.$=nn.factory.namedNode(cr);break;case 110:case 118:this.$=wr(o[d-1],o[d]);break;case 111:this.$=o[d]?{annotation:o[d],object:o[d-1]}:o[d-1];break;case 113:this.$=o[d]?Zr(Tr(o[d].map(e=>Or(Lr(o[d-1].entity),e)),o[d-1].triples)):o[d-1].triples;break;case 114:this.$=zr(...o[d-1],o[d]);break;case 116:this.$=zr(...o[d]);break;case 117:case 159:case 163:this.$=[o[d-1],o[d]];break;case 119:this.$=o[d]?{object:o[d-1],annotation:o[d]}:o[d-1];break;case 120:this.$=o[d-1].length?Ir("|",wr(o[d-1],o[d])):o[d];break;case 121:this.$=o[d-1].length?Ir("/",wr(o[d-1],o[d])):o[d];break;case 122:this.$=o[d]?Ir(o[d],[o[d-1]]):o[d-1];break;case 123:this.$=o[d-1]?Ir(o[d-1],[o[d]]):o[d];break;case 125:case 131:this.$=Ir(o[d-1],[o[d]]);break;case 129:this.$=Ir("|",wr(o[d-2],o[d-1]));break;case 132:case 134:this.$=function(e){var t=Cr(),r=t,n=[],i=[];e.forEach(function(e){n.push(e.entity),Tr(i,e.triples)});for(var o=0,a=0,s=n.length,c=Array(2*s);o2&&T.push("'"+this.terminals_[v]+"'");x=l.showPosition?"Parse error on line "+(s+1)+":\n"+l.showPosition()+"\nExpecting "+T.join(", ")+", got '"+(this.terminals_[y]||y)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==y?"end of input":"'"+(this.terminals_[y]||y)+"'"),this.parseError(x,{text:l.match,token:this.terminals_[y]||y,line:l.yylineno,loc:f,expected:T})}if(m[0]instanceof Array&&m.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+y);switch(m[0]){case 1:r.push(y),n.push(l.yytext),i.push(l.yylloc),r.push(m[1]),y=null,c=l.yyleng,a=l.yytext,s=l.yylineno,f=l.yylloc;break;case 2:if(_=this.productions_[m[1]][1],S.$=n[n.length-_],S._$={first_line:i[i.length-(_||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(_||1)].first_column,last_column:i[i.length-1].last_column},h&&(S._$.range=[i[i.length-(_||1)].range[0],i[i.length-1].range[1]]),void 0!==(b=this.performAction.apply(S,[a,c,s,d.yy,m[1],n,i].concat(u))))return b;_&&(r=r.slice(0,-1*_*2),n=n.slice(0,-1*_),i=i.slice(0,-1*_)),r.push(this.productions_[m[1]][0]),n.push(S.$),i.push(S._$),w=o[r[r.length-2]][r[r.length-1]],r.push(w);break;case 3:return!0}}return!0}},ar=GT().Wildcard,sr="http://www.w3.org/1999/02/22-rdf-syntax-ns#",cr=sr+"type",ur=sr+"first",lr=sr+"rest",dr=sr+"nil",pr="http://www.w3.org/2001/XMLSchema#",fr=pr+"integer",hr=pr+"decimal",yr=pr+"double",gr=pr+"boolean",mr="",br="",vr="";function _r(e){return e.toLowerCase()}function wr(e,t){return e.push(t),e}function Tr(e,t){return e.push.apply(e,t),e}function Or(e){e||(e={});for(var t,r=1,n=arguments.length;r>10),56320+(1023&i))}var o=Ur[n];if(!o)throw new Error;return o})}catch(e){return""}if($r.exec(e))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+e);return e}function zr(e,t,r){var n=[],i=[];return t.forEach(function(t){let r=null;t.annotation&&(r=t.annotation,t=t.object),n.push(Lr(null,e,t.entity,r)),Tr(i,t.triples)}),Sr(n,r||[],i)}function Gr(e){return e.variable?e.variable.value:e.value||e.expression.value}function Vr(e){if(!e)return[];if("aggregate"===e.type)return[e];if("operation"===e.type){const t=[];for(const r of e.args)t.push(...Vr(r));return t}return[]}function Xr(e){const t=new Set,r=function(e){e&&("Variable"===e.termType?t.add(e):"operation"===e.type&&e.args.forEach(r))};return r(e),t}function Hr(e,t=1,r=[]){for(const n of e)t>0&&n instanceof Array?Hr(n,t-1,r):r.push(n);return r}function Jr(e){return"Variable"===e.termType}function Wr(e){if(e.triples){const t=[];for(const r of e.triples)Jr(r.subject)&&t.push(r.subject.value),Jr(r.predicate)&&t.push(r.predicate.value),Jr(r.object)&&t.push(r.object.value);return t}if(e.patterns){const t=[];for(const r of e.patterns)t.push(...Wr(r));return t}return[]}function Kr(e){if(!nn.sparqlStar)throw new Error("SPARQL-star support is not enabled");return e}function Yr(e,t,r){for(const n of t){const t=Lr("subject"in n?n.subject:e,n.predicate,n.object);r.push(t),n.annotations&&Yr(Mr(e,n.predicate,n.object),n.annotations,r)}}function Zr(e){if(nn.sparqlStar){const t=[];return e.forEach(e=>{const r=Lr(e.subject,e.predicate,e.object);t.push(r),e.annotations&&Yr(Mr(e.subject,e.predicate,e.object),e.annotations,t)}),t}return e}function en(e){for(const t of e){if("graph"===t.type&&"Variable"===t.name.termType)throw new Error("Detected illegal variable in GRAPH");if("bgp"===t.type||"graph"===t.type)for(const e of t.triples)if("Variable"===e.subject.termType||"Variable"===e.predicate.termType||"Variable"===e.object.termType)throw new Error("Detected illegal variable in BGP")}return e}function tn(e){for(const t of e)if("bgp"===t.type)for(const e of t.triples)if("BlankNode"===e.subject.termType||"BlankNode"===e.predicate.termType||"BlankNode"===e.object.termType)throw new Error("Detected illegal blank node in BGP");return e}var rn=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;ot[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(t.yytext)}},rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return e}();function nn(){this.yy={}}return or.lexer=rn,nn.prototype=or,or.Parser=nn,new nn}();return LT=e}function XT(){if($T)return UT;$T=1;const{Parser:e}=VT(),{Generator:t}=function(){if(BT)return kT;function e(e){this._options=e=e||{};var t=e.prefixes||{};this._prefixByIri={};var r=[];for(var n in t){var i=t[n];o(i)&&(this._prefixByIri[i]=n,r.push(i))}var a=r.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+a+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=e.sparqlStar,this._indent=o(e.indent)?e.indent:" ",this._newline=o(e.newline)?e.newline:"\n",this._explicitDatatype=Boolean(e.explicitDatatype)}BT=1,e.prototype.toQuery=function(e){var t="";return e.queryType&&(t+=e.queryType.toUpperCase()+" "),e.reduced&&(t+="REDUCED "),e.distinct&&(t+="DISTINCT "),e.variables?t+=c(e.variables,void 0,function(e){return/^[?$]/.test(e)?e:a(e)?this.toEntity(e):"("+this.toExpression(e.expression)+" AS "+i(e.variable)+")"},this)+" ":e.template&&(t+=this.group(e.template,!0)+this._newline),e.from&&(t+=this.graphs("FROM ",e.from.default)+this.graphs("FROM NAMED ",e.from.named)),e.where&&(t+="WHERE "+this.group(e.where,!0)+this._newline),e.updates&&(t+=c(e.updates,";"+this._newline,this.toUpdate,this)),e.group&&(t+="GROUP BY "+c(e.group,void 0,function(e){var t=a(e.expression)?this.toEntity(e.expression):"("+this.toExpression(e.expression)+")";return e.variable?"("+t+" AS "+i(e.variable)+")":t},this)+this._newline),e.having&&(t+="HAVING ("+c(e.having,void 0,this.toExpression,this)+")"+this._newline),e.order&&(t+="ORDER BY "+c(e.order,void 0,function(e){var t="("+this.toExpression(e.expression)+")";return e.descending?"DESC "+t:t},this)+this._newline),e.offset&&(t+="OFFSET "+e.offset+this._newline),e.limit&&(t+="LIMIT "+e.limit+this._newline),e.values&&(t+=this.values(e)),(t=this.baseAndPrefixes(e)+t).trim()},e.prototype.baseAndPrefixes=function(e){var t=e.base?"BASE <"+e.base+">"+this._newline:"",r="";for(var n in e.prefixes)(this._options.allPrefixes||this._usedPrefixes[n])&&(r+="PREFIX "+n+": <"+e.prefixes[n]+">"+this._newline);return t+r},e.prototype.toPattern=function(e){var t=e.type||e instanceof Array&&"array"||(e.subject&&e.predicate&&e.object?"triple":"");if(!(t in this))throw new Error("Unknown entry type: "+t);return this[t](e)},e.prototype.triple=function(e){return this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+"."},e.prototype.array=function(e){return c(e,this._newline,this.toPattern,this)},e.prototype.bgp=function(e){return this.encodeTriples(e.triples)},e.prototype.encodeTriples=function(e){if(!e.length)return"";for(var t=[],r=void 0,n=void 0,i=0;i":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(a(i[0])?this.toEntity(i[0]):"("+this.toExpression(i[0])+")")+" "+n+" "+(a(i[1])?this.toEntity(i[1]):"("+this.toExpression(i[1])+")");case"!":return"!("+this.toExpression(i[0])+")";case"uplus":return"+("+this.toExpression(i[0])+")";case"uminus":return"-("+this.toExpression(i[0])+")";case"notin":n="NOT IN";case"in":return this.toExpression(i[0])+" "+n+"("+(o(i[1])?i[1]:c(i[1],", ",this.toExpression,this))+")";case"notexists":n="NOT EXISTS";case"exists":return n+" "+this.group(i[0],!0);default:return n+"("+c(i,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+e.type)}},e.prototype.toEntity=function(e){if(a(e))switch(e.termType){case"Wildcard":return"*";case"Variable":return i(e);case"BlankNode":return"_:"+e.value;case"Literal":var n=e.value||"",o=e.language||"",s=e.datatype;if(e='"'+n.replace(t,r)+'"',o)e+="@"+o;else if(s){if(!this._explicitDatatype)switch(s.value){case"http://www.w3.org/2001/XMLSchema#string":return e;case"http://www.w3.org/2001/XMLSchema#integer":if(/^\d+$/.test(n))return n+" "}e+="^^"+this.encodeIRI(s.value)}return e;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return e.graph&&"DefaultGraph"!==e.graph.termType?"<< GRAPH "+this.toEntity(e.graph)+" { "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" } >>":"<< "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" >>";default:return this.encodeIRI(e.value)}else{var c=e.items.map(this.toEntity,this),u=e.pathType;switch(u){case"^":case"!":return u+c[0];case"*":case"+":case"?":return"("+c[0]+u+")";default:return"("+c.join(u)+")"}}};var t=/["\\\t\n\r\b\f]/g,r=function(e){return n[e]},n={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function i(e){return"?"+e.value}function o(e){return"string"==typeof e}function a(e){return"string"==typeof e.termType}function s(e,t){if(!e||!a(e))return!1;if(!t||!a(t))return!1;if(e.termType!==t.termType)return!1;switch(e.termType){case"Literal":return e.value===t.value&&e.language===t.language&&s(e.datatype,t.datatype);case"Quad":return s(e.subject,t.subject)&&s(e.predicate,t.predicate)&&s(e.object,t.object)&&s(e.graph,t.graph);default:return e.value===t.value}}function c(e,t,r,n){return e.map(r,n).join(o(t)?t:" ")}return e.prototype.encodeIRI=function(e){var t=this._prefixRegex.exec(e);if(t){var r=this._prefixByIri[t[1]];return this._usedPrefixes[r]=!0,r+":"+t[2]}return"<"+e+">"},e.prototype.toUpdate=function(e){switch(e.type||e.updateType){case"load":return"LOAD"+(e.source?" "+this.toEntity(e.source):"")+(e.destination?" INTO GRAPH "+this.toEntity(e.destination):"");case"insert":return"INSERT DATA "+this.group(e.insert,!0);case"delete":return"DELETE DATA "+this.group(e.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(e.delete,!0);case"insertdelete":return(e.graph?"WITH "+this.toEntity(e.graph)+this._newline:"")+(e.delete.length?"DELETE "+this.group(e.delete,!0)+this._newline:"")+(e.insert.length?"INSERT "+this.group(e.insert,!0)+this._newline:"")+(e.using?this.graphs("USING ",e.using.default):"")+(e.using?this.graphs("USING NAMED ",e.using.named):"")+"WHERE "+this.group(e.where,!0);case"add":case"copy":case"move":return e.type.toUpperCase()+" "+(e.silent?"SILENT ":"")+(e.source.default?"DEFAULT":this.toEntity(e.source.name))+" TO "+this.toEntity(e.destination.name);case"create":case"clear":case"drop":return e.type.toUpperCase()+(e.silent?" SILENT ":" ")+(e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.all?"ALL":"GRAPH "+this.toEntity(e.graph.name));default:throw new Error("Unknown update query type: "+e.type)}},e.prototype.indent=function(e){return e.replace(/^/gm,this._indent)},kT={Generator:function(t={}){return{stringify:function(r){var n=Object.create(t);return n.prefixes=r.prefixes,new e(n).toQuery(r)},createGenerator:function(){return new e(t)}}}}}(),{Wildcard:r}=GT(),{DataFactory:n}=Fw;return UT={Parser:function({prefixes:t,baseIRI:r,factory:i,pathOnly:o,sparqlStar:a,skipValidation:s,skipUngroupedVariableCheck:c}={}){const u={};for(const e in t??{})u[e]=t[e];const l=new e;return l.parse=function(){return e.base=r||"",e.prefixes=Object.create(u),e.factory=i||new n,e.sparqlStar=Boolean(a),e.pathOnly=Boolean(o),e.skipValidation=Boolean(s)||Boolean(c),e.prototype.parse.apply(l,arguments)},l._resetBlanks=e._resetBlanks,l},Generator:t,Wildcard:r},UT}function HT(){if(qT)return QT;qT=1;var e=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),t=n&&n.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=n&&n.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(n,r,i);return t(n,r),n};Object.defineProperty(QT,"__esModule",{value:!0});const i=r(RT()),o=FT(),a=DT(),s=XT();return QT.default=class{constructor(e){this.dataFactory=e||new o.DataFactory,this.stringType=this.createTerm("http://www.w3.org/2001/XMLSchema#string")}createAlt(e,t=!0){return this.flattenMulti({type:i.types.ALT,input:e},t)}createAsk(e){return{type:i.types.ASK,input:e}}createBoundAggregate(e,t,r,n,i){const o=this.createAggregateExpression(t,r,n,i);return o.variable=e,o}createBgp(e){return{type:i.types.BGP,patterns:e}}createConstruct(e,t){return{type:i.types.CONSTRUCT,input:e,template:t}}createDescribe(e,t){return{type:i.types.DESCRIBE,input:e,terms:t}}createDistinct(e){return{type:i.types.DISTINCT,input:e}}createExtend(e,t,r){return{type:i.types.EXTEND,input:e,variable:t,expression:r}}createFrom(e,t,r){return{type:i.types.FROM,input:e,default:t,named:r}}createFilter(e,t){return{type:i.types.FILTER,input:e,expression:t}}createGraph(e,t){return{type:i.types.GRAPH,input:e,name:t}}createGroup(e,t,r){return{type:i.types.GROUP,input:e,variables:t,aggregates:r}}createInv(e){return{type:i.types.INV,path:e}}createJoin(e,t=!0){return this.flattenMulti({type:i.types.JOIN,input:e},t)}createLeftJoin(e,t,r){return r?{type:i.types.LEFT_JOIN,input:[e,t],expression:r}:{type:i.types.LEFT_JOIN,input:[e,t]}}createLink(e){return{type:i.types.LINK,iri:e}}createMinus(e,t){return{type:i.types.MINUS,input:[e,t]}}createNop(){return{type:i.types.NOP}}createNps(e){return{type:i.types.NPS,iris:e}}createOneOrMorePath(e){return{type:i.types.ONE_OR_MORE_PATH,path:e}}createOrderBy(e,t){return{type:i.types.ORDER_BY,input:e,expressions:t}}createPath(e,t,r,n){return n?{type:i.types.PATH,subject:e,predicate:t,object:r,graph:n}:{type:i.types.PATH,subject:e,predicate:t,object:r,graph:this.dataFactory.defaultGraph()}}createPattern(e,t,r,n){const o=this.dataFactory.quad(e,t,r,n);return o.type=i.types.PATTERN,o}createProject(e,t){return{type:i.types.PROJECT,input:e,variables:t}}createReduced(e){return{type:i.types.REDUCED,input:e}}createSeq(e,t=!0){return this.flattenMulti({type:i.types.SEQ,input:e},t)}createService(e,t,r){return{type:i.types.SERVICE,input:e,name:t,silent:Boolean(r)}}createSlice(e,t,r){return t=t||0,void 0!==r?{type:i.types.SLICE,input:e,start:t,length:r}:{type:i.types.SLICE,input:e,start:t}}createUnion(e,t=!0){return this.flattenMulti({type:i.types.UNION,input:e},t)}createValues(e,t){return{type:i.types.VALUES,variables:e,bindings:t}}createZeroOrMorePath(e){return{type:i.types.ZERO_OR_MORE_PATH,path:e}}createZeroOrOnePath(e){return{type:i.types.ZERO_OR_ONE_PATH,path:e}}createAggregateExpression(e,t,r,n){return n?{type:i.types.EXPRESSION,expressionType:i.expressionTypes.AGGREGATE,aggregator:e,expression:t,separator:n,distinct:r}:{type:i.types.EXPRESSION,expressionType:i.expressionTypes.AGGREGATE,aggregator:e,expression:t,distinct:r}}createExistenceExpression(e,t){return{type:i.types.EXPRESSION,expressionType:i.expressionTypes.EXISTENCE,not:e,input:t}}createNamedExpression(e,t){return{type:i.types.EXPRESSION,expressionType:i.expressionTypes.NAMED,name:e,args:t}}createOperatorExpression(e,t){return{type:i.types.EXPRESSION,expressionType:i.expressionTypes.OPERATOR,operator:e,args:t}}createTermExpression(e){return{type:i.types.EXPRESSION,expressionType:i.expressionTypes.TERM,term:e}}createWildcardExpression(){return{type:i.types.EXPRESSION,expressionType:i.expressionTypes.WILDCARD,wildcard:new s.Wildcard}}createTerm(e){return"$"===e[0]&&(e=e.replace("$","?")),(0,a.stringToTerm)(e,this.dataFactory)}createCompositeUpdate(e){return{type:i.types.COMPOSITE_UPDATE,updates:e}}createDeleteInsert(e,t,r){const n={type:i.types.DELETE_INSERT};return e&&(n.delete=e),t&&(n.insert=t),r&&(n.where=r),n}createLoad(e,t,r){const n={type:i.types.LOAD,source:e};return t&&(n.destination=t),this.addSilent(n,Boolean(r))}createClear(e,t){return this.addSilent({type:i.types.CLEAR,source:e},Boolean(t))}createCreate(e,t){return this.addSilent({type:i.types.CREATE,source:e},Boolean(t))}createDrop(e,t){return this.addSilent({type:i.types.DROP,source:e},Boolean(t))}createAdd(e,t,r){return this.addSilent({type:i.types.ADD,source:e,destination:t},Boolean(r))}createMove(e,t,r){return this.addSilent({type:i.types.MOVE,source:e,destination:t},Boolean(r))}createCopy(e,t,r){return this.addSilent({type:i.types.COPY,source:e,destination:t},Boolean(r))}addSilent(e,t){return t&&(e.silent=t),e}flattenMulti(e,t){if(!t)return e;const r=e.type,n=e.input;let i=[];for(const e of n)e.type===r?i.push(...e.input):i.push(e);return e.input=i,e}},QT}var JT,WT={},KT={},YT={};var ZT,eO,tO,rO,nO={};function iO(){return eO||(eO=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(JT)return YT;JT=1,Object.defineProperty(YT,"__esModule",{value:!0}),YT.TRIPLE_TERM_NAMES=YT.QUAD_TERM_NAMES=void 0,YT.getTerms=t,YT.getTermsNested=function e(r,n){const i=[];for(const o of t(r,n))"Quad"===o.termType?e(o,n).forEach(e=>i.push(e)):i.push(o);return i},YT.getNamedTerms=function(e){return[{key:"subject",value:e.subject},{key:"predicate",value:e.predicate},{key:"object",value:e.object},{key:"graph",value:e.graph}]},YT.collectNamedTerms=function(t,r,n){const i={};return t.forEach(e=>i[e.key]=e.value),r&&(i.subject=i.subject||r("subject"),i.predicate=i.predicate||r("predicate"),i.object=i.object||r("object"),i.graph=i.graph||r("graph")),(n||e).quad(i.subject,i.predicate,i.object,i.graph)},YT.forEachTerms=function(e,t){t(e.subject,"subject"),t(e.predicate,"predicate"),t(e.object,"object"),t(e.graph,"graph")},YT.forEachTermsNested=function e(t,r,n=[]){"Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]),"Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]),"Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]),"Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"])},YT.filterTerms=function(e,t){const r=[];return t(e.subject,"subject")&&r.push(e.subject),t(e.predicate,"predicate")&&r.push(e.predicate),t(e.object,"object")&&r.push(e.object),t(e.graph,"graph")&&r.push(e.graph),r},YT.filterTermsNested=function e(t,r,n=[]){let i=[];return"Quad"===t.subject.termType?i=[...i,...e(t.subject,r,[...n,"subject"])]:r(t.subject,[...n,"subject"])&&i.push(t.subject),"Quad"===t.predicate.termType?i=[...i,...e(t.predicate,r,[...n,"predicate"])]:r(t.predicate,[...n,"predicate"])&&i.push(t.predicate),"Quad"===t.object.termType?i=[...i,...e(t.object,r,[...n,"object"])]:r(t.object,[...n,"object"])&&i.push(t.object),"Quad"===t.graph.termType?i=[...i,...e(t.graph,r,[...n,"graph"])]:r(t.graph,[...n,"graph"])&&i.push(t.graph),i},YT.filterQuadTermNames=function(e,t){const r=[];return t(e.subject,"subject")&&r.push("subject"),t(e.predicate,"predicate")&&r.push("predicate"),t(e.object,"object")&&r.push("object"),t(e.graph,"graph")&&r.push("graph"),r},YT.filterQuadTermNamesNested=function e(t,r,n=[]){let i=[];const o=[...n,"subject"];"Quad"===t.subject.termType?i=[...i,...e(t.subject,r,o)]:r(t.subject,o)&&i.push(o);const a=[...n,"predicate"];"Quad"===t.predicate.termType?i=[...i,...e(t.predicate,r,a)]:r(t.predicate,a)&&i.push(a);const s=[...n,"object"];"Quad"===t.object.termType?i=[...i,...e(t.object,r,s)]:r(t.object,s)&&i.push(s);const c=[...n,"graph"];return"Quad"===t.graph.termType?i=[...i,...e(t.graph,r,c)]:r(t.graph,c)&&i.push(c),i},YT.mapTerms=function(t,r,n){return(n||e).quad(r(t.subject,"subject"),r(t.predicate,"predicate"),r(t.object,"object"),r(t.graph,"graph"))},YT.mapTermsNested=function t(r,n,i,o=[]){return(i||e).quad("Quad"===r.subject.termType?t(r.subject,n,i,[...o,"subject"]):n(r.subject,[...o,"subject"]),"Quad"===r.predicate.termType?t(r.predicate,n,i,[...o,"predicate"]):n(r.predicate,[...o,"predicate"]),"Quad"===r.object.termType?t(r.object,n,i,[...o,"object"]):n(r.object,[...o,"object"]),"Quad"===r.graph.termType?t(r.graph,n,i,[...o,"graph"]):n(r.graph,[...o,"graph"]))},YT.reduceTerms=function(e,t,r){let n=r;return n=t(n,e.subject,"subject"),n=t(n,e.predicate,"predicate"),n=t(n,e.object,"object"),t(n,e.graph,"graph")},YT.reduceTermsNested=function e(t,r,n,i=[]){let o=n;return o="Quad"===t.subject.termType?e(t.subject,r,o,[...i,"subject"]):r(o,t.subject,[...i,"subject"]),o="Quad"===t.predicate.termType?e(t.predicate,r,o,[...i,"predicate"]):r(o,t.predicate,[...i,"predicate"]),o="Quad"===t.object.termType?e(t.object,r,o,[...i,"object"]):r(o,t.object,[...i,"object"]),o="Quad"===t.graph.termType?e(t.graph,r,o,[...i,"graph"]):r(o,t.graph,[...i,"graph"]),o},YT.everyTerms=r,YT.everyTermsNested=function e(t,r,n=[]){return("Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]))&&("Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]))&&("Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]))&&("Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"]))},YT.someTerms=function(e,t){return t(e.subject,"subject")||t(e.predicate,"predicate")||t(e.object,"object")||t(e.graph,"graph")},YT.someTermsNested=function e(t,r,n=[]){return("Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]))||("Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]))||("Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]))||("Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"]))},YT.getValueNestedPath=function e(t,r){if(0===r.length)return t;if("Quad"===t.termType)return e(t[r[0]],r.slice(1));throw new Error(`Tried to get ${r[0]} from term of type ${t.termType}`)},YT.matchTerm=n,YT.matchPattern=i,YT.matchPatternComplete=o,YT.matchPatternMappings=function(e,t,n={}){const i={};return function e(t,o){return r(t,(t,r)=>{var a,s;const c=o[r];switch(t.termType){case"Variable":return n.skipVarMapping&&"Variable"===c.termType||(null!==(s=null===(a=i[t.value])||void 0===a?void 0:a.equals(c))&&void 0!==s?s:(i[t.value]=c,!0));case"Quad":return"Quad"===c.termType&&e(t,c);default:return t.equals(c)}})}(t,e)&&(!n.returnMappings||i)};const e=new(FT().DataFactory);function t(e,t){return t&&"DefaultGraph"===e.graph.termType?[e.subject,e.predicate,e.object]:[e.subject,e.predicate,e.object,e.graph]}function r(e,t){return t(e.subject,"subject")&&t(e.predicate,"predicate")&&t(e.object,"object")&&t(e.graph,"graph")}function n(e,t){return!t||"Variable"===t.termType||"Quad"===t.termType&&"Quad"===e.termType&&o(e,t)||t.equals(e)}function i(e,t,r,i,o){return n(e.subject,t)&&n(e.predicate,r)&&n(e.object,i)&&n(e.graph,o)}function o(e,t){return i(e,t.subject,t.predicate,t.object,t.graph)}return YT.QUAD_TERM_NAMES=["subject","predicate","object","graph"],YT.TRIPLE_TERM_NAMES=["subject","predicate","object"],YT}(),e),r(function(){if(ZT)return nO;ZT=1,Object.defineProperty(nO,"__esModule",{value:!0}),nO.TERM_TYPES=void 0,nO.uniqTerms=function(t){const r={};return t.filter(t=>{const n=(0,e.termToString)(t);return!(n in r)&&(r[n]=!0)})},nO.getTermsOfType=t,nO.getNamedNodes=function(e){return t(e,"NamedNode")},nO.getBlankNodes=function(e){return t(e,"BlankNode")},nO.getLiterals=function(e){return t(e,"Literal")},nO.getVariables=function(e){return t(e,"Variable")},nO.getDefaultGraphs=function(e){return t(e,"DefaultGraph")},nO.getQuads=function(e){return t(e,"Quad")};const e=DT();function t(e,t){return e.filter(e=>e.termType===t)}return nO.TERM_TYPES=["NamedNode","BlankNode","Literal","Variable","DefaultGraph","Quad"],nO}(),e)}(KT)),KT}function oO(){if(tO)return WT;tO=1;var e=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(WT,"__esModule",{value:!0});const t=RT(),r=e(HT()),i=iO();class o{static flatten(e){return Array.prototype.concat(...e).filter(e=>e)}static objectify(e){if(e.termType){if("Quad"===e.termType)return{type:"pattern",termType:"Quad",subject:o.objectify(e.subject),predicate:o.objectify(e.predicate),object:o.objectify(e.object),graph:o.objectify(e.graph)};{let t={termType:e.termType,value:e.value};return e.language&&(t.language=e.language),e.datatype&&(t.datatype=o.objectify(e.datatype)),t}}if(Array.isArray(e))return e.map(e=>o.objectify(e));if(e===Object(e)){let t={};for(let r of Object.keys(e))t[r]=o.objectify(e[r]);return t}return e}static inScopeVariables(e){const r=[];function n(e){r.find(t=>e.value===t.value)||r.push(e)}function i(e){"Variable"===e.subject.termType&&n(e.subject),"Variable"===e.predicate.termType&&n(e.predicate),"Variable"===e.object.termType&&n(e.object),"Variable"===e.graph.termType&&n(e.graph),"Quad"===e.subject.termType&&i(e.subject),"Quad"===e.predicate.termType&&i(e.predicate),"Quad"===e.object.termType&&i(e.object),"Quad"===e.graph.termType&&i(e.graph)}return o.recurseOperation(e,{[t.types.EXPRESSION]:e=>(e.expressionType===t.expressionTypes.AGGREGATE&&e.variable&&n(e.variable),!0),[t.types.EXTEND]:e=>(n(e.variable),!0),[t.types.GRAPH]:e=>("Variable"===e.name.termType&&n(e.name),!0),[t.types.GROUP]:e=>(e.variables.forEach(n),!0),[t.types.PATH]:e=>("Variable"===e.subject.termType&&n(e.subject),"Variable"===e.object.termType&&n(e.object),"Variable"===e.graph.termType&&n(e.graph),"Quad"===e.subject.termType&&i(e.subject),"Quad"===e.object.termType&&i(e.object),"Quad"===e.graph.termType&&i(e.graph),!0),[t.types.PATTERN]:e=>(i(e),!0),[t.types.PROJECT]:e=>(e.variables.forEach(n),!1),[t.types.SERVICE]:e=>("Variable"===e.name.termType&&n(e.name),!0),[t.types.VALUES]:e=>(e.variables.forEach(n),!0)}),r}static recurseOperation(e,r){let n=e,i=!0;const a=r[e.type];if(a&&(i=a(e)),!i)return;let s=e=>o.recurseOperation(e,r);switch(n.type){case t.types.ALT:n.input.map(s);break;case t.types.ASK:s(n.input);break;case t.types.BGP:n.patterns.forEach(s);break;case t.types.CONSTRUCT:s(n.input),n.template.map(s);break;case t.types.DESCRIBE:case t.types.DISTINCT:s(n.input);break;case t.types.EXPRESSION:n.expressionType===t.expressionTypes.EXISTENCE&&s(n.input);break;case t.types.EXTEND:case t.types.FILTER:s(n.input),s(n.expression);break;case t.types.FROM:case t.types.GRAPH:s(n.input);break;case t.types.GROUP:s(n.input),n.aggregates.forEach(s);break;case t.types.INV:s(n.path);break;case t.types.JOIN:n.input.map(s);break;case t.types.LEFT_JOIN:n.input.map(s),n.expression&&s(n.expression);break;case t.types.LINK:break;case t.types.MINUS:n.input.map(s);break;case t.types.NOP:case t.types.NPS:break;case t.types.ONE_OR_MORE_PATH:s(n.path);break;case t.types.ORDER_BY:s(n.input),n.expressions.forEach(s);break;case t.types.PATH:s(n.predicate);break;case t.types.PATTERN:break;case t.types.PROJECT:case t.types.REDUCED:s(n.input);break;case t.types.SEQ:n.input.map(s);break;case t.types.SERVICE:case t.types.SLICE:s(n.input);break;case t.types.UNION:n.input.map(s);break;case t.types.VALUES:break;case t.types.ZERO_OR_MORE_PATH:case t.types.ZERO_OR_ONE_PATH:s(n.path);break;case t.types.COMPOSITE_UPDATE:n.updates.forEach(e=>s(e));break;case t.types.DELETE_INSERT:n.delete&&n.delete.forEach(e=>s(e)),n.insert&&n.insert.forEach(e=>s(e)),n.where&&s(n.where);break;case t.types.LOAD:case t.types.CLEAR:case t.types.CREATE:case t.types.DROP:case t.types.ADD:case t.types.MOVE:case t.types.COPY:break;default:throw new Error(`Unknown Operation type ${n.type}`)}}static mapOperation(e,n,i){let a=e,s=!0,c=!0;i=i||new r.default;const u=n[e.type];if(u){const t=u(e,i);a=t.result,s=t.recurse,c=!1!==t.copyMetadata}let l;if(c&&(a.metadata||e.metadata)&&(l={...a.metadata,...e.metadata}),!s)return l&&(a.metadata=l),a;let d=e=>o.mapOperation(e,n,i);switch(a.type){case t.types.ALT:a=i.createAlt(a.input.map(d));break;case t.types.ASK:a=i.createAsk(d(a.input));break;case t.types.BGP:a=i.createBgp(a.patterns.map(d));break;case t.types.CONSTRUCT:a=i.createConstruct(d(a.input),a.template.map(d));break;case t.types.DESCRIBE:a=i.createDescribe(d(a.input),a.terms);break;case t.types.DISTINCT:a=i.createDistinct(d(a.input));break;case t.types.EXPRESSION:a=o.mapExpression(a,n,i);break;case t.types.EXTEND:a=i.createExtend(d(a.input),a.variable,d(a.expression));break;case t.types.FILTER:a=i.createFilter(d(a.input),d(a.expression));break;case t.types.FROM:a=i.createFrom(d(a.input),[...a.default],[...a.named]);break;case t.types.GRAPH:a=i.createGraph(d(a.input),a.name);break;case t.types.GROUP:a=i.createGroup(d(a.input),[].concat(a.variables),a.aggregates.map(d));break;case t.types.INV:a=i.createInv(d(a.path));break;case t.types.JOIN:a=i.createJoin(a.input.map(d));break;case t.types.LEFT_JOIN:a=i.createLeftJoin(d(a.input[0]),d(a.input[1]),a.expression?d(a.expression):void 0);break;case t.types.LINK:a=i.createLink(a.iri);break;case t.types.MINUS:a=i.createMinus(d(a.input[0]),d(a.input[1]));break;case t.types.NOP:a=i.createNop();break;case t.types.NPS:a=i.createNps([].concat(a.iris));break;case t.types.ONE_OR_MORE_PATH:a=i.createOneOrMorePath(d(a.path));break;case t.types.ORDER_BY:a=i.createOrderBy(d(a.input),a.expressions.map(d));break;case t.types.PATH:a=i.createPath(a.subject,d(a.predicate),a.object,a.graph);break;case t.types.PATTERN:a=i.createPattern(a.subject,a.predicate,a.object,a.graph);break;case t.types.PROJECT:a=i.createProject(d(a.input),[...a.variables]);break;case t.types.REDUCED:a=i.createReduced(d(a.input));break;case t.types.SEQ:a=i.createSeq(a.input.map(d));break;case t.types.SERVICE:a=i.createService(d(a.input),a.name,a.silent);break;case t.types.SLICE:a=i.createSlice(d(a.input),a.start,a.length);break;case t.types.UNION:a=i.createUnion(a.input.map(d));break;case t.types.VALUES:a=i.createValues([].concat(a.variables),a.bindings.map(e=>Object.assign({},e)));break;case t.types.ZERO_OR_MORE_PATH:a=i.createZeroOrMorePath(d(a.path));break;case t.types.ZERO_OR_ONE_PATH:a=i.createZeroOrOnePath(d(a.path));break;case t.types.COMPOSITE_UPDATE:a=i.createCompositeUpdate(a.updates.map(d));break;case t.types.DELETE_INSERT:a=i.createDeleteInsert(a.delete?a.delete.map(d):void 0,a.insert?a.insert.map(d):void 0,a.where?d(a.where):void 0);break;case t.types.LOAD:a=i.createLoad(a.source,a.destination,a.silent);break;case t.types.CLEAR:a=i.createClear(a.source,a.silent);break;case t.types.CREATE:a=i.createCreate(a.source,a.silent);break;case t.types.DROP:a=i.createDrop(a.source,a.silent);break;case t.types.ADD:a=i.createAdd(a.source,a.destination);break;case t.types.MOVE:a=i.createMove(a.source,a.destination);break;case t.types.COPY:a=i.createCopy(a.source,a.destination);break;default:throw new Error(`Unknown Operation type ${a.type}`)}return l&&(a.metadata=l),a}static mapExpression(e,n,i){let a=e,s=!0;i=i||new r.default;const c=n[e.expressionType];if(c&&({result:a,recurse:s}=c(e,i)),!s)return a;let u=e=>o.mapOperation(e,n,i);switch(e.expressionType){case t.expressionTypes.AGGREGATE:return e.variable?i.createBoundAggregate(e.variable,e.aggregator,u(e.expression),e.distinct,e.separator):i.createAggregateExpression(e.aggregator,u(e.expression),e.distinct,e.separator);case t.expressionTypes.EXISTENCE:return i.createExistenceExpression(e.not,u(e.input));case t.expressionTypes.NAMED:return i.createNamedExpression(e.name,e.args.map(u));case t.expressionTypes.OPERATOR:return i.createOperatorExpression(e.operator,e.args.map(u));case t.expressionTypes.TERM:return i.createTermExpression(e.term);case t.expressionTypes.WILDCARD:return i.createWildcardExpression();default:throw new Error(`Unknown Expression type ${e.expressionType}`)}}static cloneOperation(e){return o.mapOperation(e,{})}static cloneExpression(e){return o.mapExpression(e,{})}static createUniqueVariable(e,t,r){let n=0,i=e;for(;t[i];)i=`${e}${n++}`;return r.variable(i)}static isSimpleTerm(e){return void 0!==e.termType&&"Quad"!==e.termType&&"Wildcard"!==e.termType}static isQuad(e){return"Quad"===e.termType}static hasQuadVariables(e){return(0,i.someTermsNested)(e,e=>"Variable"===e.termType)}static isWildcard(e){return"Wildcard"===e.termType}}return WT.default=o,WT}function aO(){if(rO)return nT;rO=1;var e=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),t=n&&n.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=n&&n.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(n,r,i);return t(n,r),n},i=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(nT,"__esModule",{value:!0});const o=(tT||(tT=1,eT=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(i=n;0!==i--;)if(!e(t[i],r[i]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(i of t.entries())if(!r.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],r.get(i[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(i of t.entries())if(!r.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if((n=t.length)!=r.length)return!1;for(i=n;0!==i--;)if(t[i]!==r[i])return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(o=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(i=n;0!==i--;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;0!==i--;){var a=o[i];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}),eT),a=DT(),s=r(RT()),c=i(HT()),u=i(oO()),l=XT().Parser,d=s.types;let p,f=new Set,h=0,y=!1;function g(e,t,r){if(f=new Set,h=0,y=Boolean(t),!e.type)return p.createNop();if("query"!==e.type&&"update"!==e.type)throw new Error("Translate only works on complete query or update objects.");let n;if(v(e),"query"===e.type){n=w({type:"group",patterns:e.where||[]}),n=function(e,t){const r=e,n=[],i={};if(r.variables=r.variables&&r.variables.map(e=>P(e,i)),r.having=r.having&&r.having.map(e=>P(e,i)),r.order=r.order&&r.order.map(e=>P(e,i)),r.group||Object.keys(i).length>0){const e=Object.keys(i).map(e=>function(e,t){if("aggregate"!==e.type||!e.aggregation)throw new Error(`Unexpected input: ${JSON.stringify(e)}`);const r=T(e);return r.variable=t,r}(i[e],p.createTerm(e))),n=[];if(r.group)for(const e of r.group)if(u.default.isSimpleTerm(e.expression))n.push(e.expression);else{const r="variable"in e?e.variable:j();t=p.createExtend(t,r,T(e.expression)),n.push(r)}t=p.createGroup(t,n,e)}if(r.having)for(let e of r.having)t=p.createFilter(t,T(e));e.values&&(t=p.createJoin([t,N(e)]));let o=[];if("SELECT"===e.queryType||"DESCRIBE"===e.queryType)if(e.variables.some(e=>e&&u.default.isWildcard(e)))o=Object.values(_(e)).sort((e,t)=>e.value.localeCompare(t.value));else for(let t of e.variables)b(t)||!("variable"in t)?o.push(t):t.variable&&(o.push(t.variable),n.push(t));for(let e of n)t=p.createExtend(t,e.variable,T(e.expression));r.order&&(t=p.createOrderBy(t,r.order.map(e=>{let t=T(e.expression);return e.descending&&(t=p.createOperatorExpression("desc",[t])),t})));"SELECT"===e.queryType&&(t=p.createProject(t,o));r.distinct&&(t=p.createDistinct(t));r.reduced&&(t=p.createReduced(t));"CONSTRUCT"===e.queryType?t=p.createConstruct(t,(e.template||[]).map(A)):"ASK"===e.queryType?t=p.createAsk(t):"DESCRIBE"===e.queryType&&(t=p.createDescribe(t,o));(r.offset||r.limit)&&(t=p.createSlice(t,r.offset||0,r.limit));r.from&&(t=p.createFrom(t,r.from.default,r.from.named));return t}(e,n)}else"update"===e.type&&(n=1===(i=e).updates.length?R(i.updates[0]):p.createCompositeUpdate(i.updates.map(R)));var i;return r&&(n=L(n)),n}function m(e){return Boolean(null==e?void 0:e.termType)}function b(e){return"Variable"===(null==e?void 0:e.termType)}function v(e){if(m(e))b(e)&&f.add(`?${e.value}`);else if(Array.isArray(e))for(const t of e)v(t);else if(e&&"object"==typeof e)for(let t of Object.keys(e))t.startsWith("?")?f.add(t):t.startsWith("$")&&f.add(`?${t.slice(1)}`),v(e[t])}function _(e){let t={};if((r=e).subject&&r.predicate&&r.object){const r=[_(e.subject),_(e.predicate),_(e.object),e.graph?_(e.graph):{}];Object.assign(t,...r)}else if(m(e))b(e)&&(t[e.value]=e);else if("bgp"===e.type){const r=e.triples;Object.assign(t,...r.map(_))}else if("path"===e.type)Object.assign(t,...e.items.map(_));else if("group"===e.type||"union"===e.type||"optional"===e.type)Object.assign(t,...e.patterns.map(_));else if("service"===e.type||"graph"===e.type)Object.assign(t,_(e.name)),Object.assign(t,...e.patterns.map(_));else if("bind"===e.type)Object.assign(t,_(e.variable));else if("values"===e.type){if(e.values.length>0){const r=Object.keys(e.values[0]).map(e=>p.createTerm(e));Object.assign(t,...r.map(_))}}else if("query"===e.type&&("SELECT"===e.queryType||"DESCRIBE"===e.queryType)){e.where&&e.variables.some(u.default.isWildcard)&&Object.assign(t,...e.where.map(_));for(const r of e.variables)b(r)?Object.assign(t,_(r)):r.variable&&Object.assign(t,_(r.variable));if("SELECT"===e.queryType){if(e.group)for(const r of e.group)r.variable&&Object.assign(t,_(r.variable));if(e.values){const r={type:"values",values:e.values};Object.assign(t,_(r))}}}var r;return t}function w(e){if("bgp"===e.type)return function(e){let t=[],r=[];for(let n of e.triples)if("pathType"in n.predicate){let e=O(n);for(let n of e)n.type===d.PATH?(t.length>0&&r.push(p.createBgp(t)),t=[],r.push(n)):t.push(n)}else t.push(A(n));t.length>0&&r.push(p.createBgp(t));return 1===r.length?r[0]:p.createJoin(r)}(e);if("union"===e.type)return p.createUnion(e.patterns.map(e=>("group"!==e.type&&(e={type:"group",patterns:[e]}),w(e))));if("graph"===e.type){let t=w({type:"group",patterns:e.patterns});return t=y?I(t,e.name):p.createGraph(t,e.name),t}if("values"===e.type)return N(e);if("query"===e.type)return g(e,y,!1);if("group"===e.type){let t=[],r=[];for(let n of e.patterns)("filter"===n.type?t:r).push(n);let n=r.reduce(F,p.createBgp([])),i=t.map(e=>T(e.expression));return i.length>0&&(n=p.createFilter(n,i.reduce((e,t)=>p.createOperatorExpression("&&",[e,t])))),n}throw new Error(`Unexpected type: ${e.type}`)}function T(e){if(u.default.isSimpleTerm(e))return p.createTermExpression(e);if(u.default.isQuad(e))return u.default.hasQuadVariables(e)?p.createOperatorExpression("triple",[T(e.subject),T(e.predicate),T(e.object)]):p.createTermExpression(e);if(u.default.isWildcard(e))return p.createWildcardExpression();if("aggregation"in e)return p.createAggregateExpression(e.aggregation,T(e.expression),Boolean(e.distinct),e.separator);if("function"in e)return p.createNamedExpression(e.function,e.args.map(T));if("operator"in e)return"exists"===e.operator||"notexists"===e.operator?p.createExistenceExpression("notexists"===e.operator,w(e.args[0])):("in"!==e.operator&&"notin"!==e.operator||(e.args=[e.args[0]].concat(e.args[1])),p.createOperatorExpression(e.operator,e.args.map(T)));throw new Error(`Unknown expression: ${JSON.stringify(e)}`)}function O(e){return x(e.subject,S(e.predicate),e.object)}function S(e){if(u.default.isSimpleTerm(e)){if("NamedNode"===e.termType)return p.createLink(e);throw new Error(`Path predicate should be a NamedNode, got ${JSON.stringify(e)}`)}if("^"===e.pathType)return p.createInv(S(e.items[0]));if("!"===e.pathType){let t,r=[],n=[];t="pathType"in e.items[0]&&"|"===e.items[0].pathType?e.items[0].items:e.items;for(let e of t)if(u.default.isSimpleTerm(e))r.push(e);else{if("^"!==e.pathType)throw new Error(`Unexpected item: ${JSON.stringify(e)}`);n.push(e.items[0])}let i=p.createNps(r),o=p.createInv(p.createNps(n));return 0===n.length?i:0===r.length?o:p.createAlt([i,o])}if("/"===e.pathType)return p.createSeq(e.items.map(S));if("|"===e.pathType)return p.createAlt(e.items.map(S));if("*"===e.pathType)return p.createZeroOrMorePath(S(e.items[0]));if("+"===e.pathType)return p.createOneOrMorePath(S(e.items[0]));if("?"===e.pathType)return p.createZeroOrOnePath(S(e.items[0]));throw new Error(`Unable to translate path expression ${JSON.stringify(e)}`)}function x(e,t,r){if(t.type===d.LINK)return[p.createPattern(e,t.iri,r)];if(t.type===d.INV)return x(r,t.path,e);if(t.type===d.SEQ){let n=e;return u.default.flatten(t.input.map((e,i)=>{const o=i===t.input.length-1?r:j(),a=x(n,e,o);return"Variable"===o.termType&&(n=o),a}))}return[p.createPath(e,t,r)]}function j(){let e="?var"+h++;return f.has(e)?j():(f.add(e),p.createTerm(e))}function A(e){if("pathType"in e.predicate)throw new Error("Trying to translate property path to quad.");return p.createPattern(e.subject,e.predicate,e.object,e.graph)}nT.default=function(e,t){let r;if(t=t||{},p=new c.default(t.dataFactory),"string"==typeof e){let n=new l(t);n._resetBlanks(),r=n.parse(e)}else r=e;return g(r,t.quads,t.blankToVariable)};let E=Object.values(d);function I(e,t,r){if(e.type===d.GRAPH){if(r)throw new Error("Recursing through nested GRAPH statements with a replacement is impossible.");e=I(e.input,e.name)}else if(e.type===d.SERVICE);else if(e.type===d.BGP)e.patterns=e.patterns.map(e=>(r&&(e.subject.equals(t)&&(e.subject=r),e.predicate.equals(t)&&(e.predicate=r),e.object.equals(t)&&(e.object=r)),"DefaultGraph"===e.graph.termType&&(e.graph=t),e));else if(e.type===d.PATH)r&&(e.subject.equals(t)&&(e.subject=r),e.object.equals(t)&&(e.object=r)),"DefaultGraph"===e.graph.termType&&(e.graph=t);else if(e.type!==d.PROJECT||r)if(e.type!==d.EXTEND||r)if(e.type===d.MINUS&&"Variable"===t.termType)e.metadata={graphVariableFromParentScope:t},e.input=[I(e.input[0],t,r),I(e.input[1],t,r)];else for(let n of Object.keys(e))Array.isArray(e[n])?e[n]=e[n].map(e=>I(e,t,r)):E.indexOf(e[n].type)>=0?e[n]=I(e[n],t,r):r&&b(e[n])&&e[n].equals(t)&&(e[n]=r);else e.variable.equals(t)&&(r=j()),e.input=I(e.input,t,r);else e.variables.some(e=>e.equals(t))||(r=j()),e.input=I(e.input,t,r);return e}function F(e,t){if("optional"===t.type){const r=w({type:"group",patterns:t.patterns});e=r.type===d.FILTER?p.createLeftJoin(e,r.input,r.expression):p.createLeftJoin(e,r)}else if("minus"===t.type){const r=w({type:"group",patterns:t.patterns});e=p.createMinus(e,r)}else if("bind"===t.type)e=p.createExtend(e,t.variable,T(t.expression));else if("service"===t.type){const r={type:"group",patterns:t.patterns};e=D(e,p.createService(w(r),t.name,t.silent))}else{e=D(e,w(t))}return e}function D(e,t){return e.type===d.BGP&&t.type===d.BGP?e=p.createBgp([...e.patterns,...t.patterns]):e.type===d.BGP&&0===e.patterns.length?e=t:t.type===d.BGP&&0===t.patterns.length||(e=p.createJoin([e,t])),e}function N(e){let t=(0===e.values.length?[]:Object.keys(e.values[0])).map(p.createTerm.bind(p)),r=e.values.map(e=>{let t=Object.keys(e);t=t.filter(t=>void 0!==e[t]);let r={};for(let n of t)r[n]=e[n];return r});return p.createValues(t,r)}function P(e,t){if("type"in e&&"aggregate"===e.type){let r,n=!1;for(let i of Object.keys(t))if(o(t[i],e)){r=p.createTerm(i),n=!0;break}return n||(r=j(),t[(0,a.termToString)(r)]=e),r}return"expression"in e&&e.expression?{...e,expression:P(e.expression,t)}:"args"in e&&e.args?{...e,args:e.args.map(e=>P(e,t))}:e}function R(e){if("type"in e){if("load"===e.type)return function(e){return p.createLoad(e.source,e.destination,e.silent)}(e);if("clear"===e.type||"create"===e.type||"drop"===e.type)return function(e){let t;t=u.default.isSimpleTerm(e.graph)?e.graph:e.graph.all?"ALL":e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.name;switch(e.type){case"clear":return p.createClear(t,e.silent);case"create":return p.createCreate(t,e.silent);case"drop":return p.createDrop(t,e.silent)}}(e);if("add"===e.type||"copy"===e.type||"move"===e.type)return function(e){const t=e.source.default?"DEFAULT":e.source.name,r=e.destination.default?"DEFAULT":e.destination.name;switch(e.type){case"copy":return p.createCopy(t,r,e.silent);case"move":return p.createMove(t,r,e.silent);case"add":return p.createAdd(t,r,e.silent)}}(e)}else if("insertdelete"===e.updateType||"deletewhere"===e.updateType||"delete"===e.updateType||"insert"===e.updateType)return function(e){if(!y)throw new Error("INSERT/DELETE operations are only supported with quads option enabled");let t,r=[],n=[];e.delete&&(r=u.default.flatten(e.delete.map(t=>M(t,e.graph))));e.insert&&(n=u.default.flatten(e.insert.map(t=>M(t,e.graph))));if(e.where&&e.where.length>0){t=w({type:"group",patterns:e.where});const r=e.using;r?t=p.createFrom(t,r.default,r.named):e.graph&&(t=I(t,e.graph))}else"deletewhere"===e.updateType&&r.length>0&&(t=p.createBgp(r));return p.createDeleteInsert(r.length>0?r:void 0,n.length>0?n:void 0,t)}(e);throw new Error(`Unknown update type ${JSON.stringify(e)}`)}function M(e,t){let r=t;"graph"===e.type&&(r=e.name);let n=e.triples;return r&&(n=n.map(e=>Object.assign(e,{graph:r}))),n.map(A)}function L(e){const t={},r=Array.from(f).reduce((e,t)=>(e[t]=!0,e),{});return u.default.mapOperation(e,{[s.types.DELETE_INSERT]:e=>({result:p.createDeleteInsert(e.delete,e.insert,e.where&&L(e.where)),recurse:!1}),[s.types.PATH]:(e,t)=>({result:t.createPath(n(e.subject),e.predicate,n(e.object),n(e.graph)),recurse:!1}),[s.types.PATTERN]:(e,t)=>({result:t.createPattern(n(e.subject),n(e.predicate),n(e.object),n(e.graph)),recurse:!1}),[s.types.CONSTRUCT]:e=>({result:p.createConstruct(L(e.input),e.template),recurse:!1})});function n(e){if("BlankNode"===e.termType){let n=t[e.value];return n||(n=u.default.createUniqueVariable(e.value,r,p.dataFactory),r[n.value]=!0,t[e.value]=n),n}return"Quad"===e.termType?p.dataFactory.quad(n(e.subject),n(e.predicate),n(e.object),n(e.graph)):e}}return nT}var sO,cO={},uO={},lO={},dO={},pO={},fO={},hO={};function yO(){if(sO)return hO;sO=1,Object.defineProperty(hO,"__esModule",{value:!0}),hO.BlankNode=void 0;return hO.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}},hO}var gO,mO={},bO={};function vO(){if(gO)return bO;gO=1,Object.defineProperty(bO,"__esModule",{value:!0}),bO.DefaultGraph=void 0;class e{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}}return bO.DefaultGraph=e,e.INSTANCE=new e,bO}var _O,wO,TO={},OO={};function SO(){if(_O)return OO;_O=1,Object.defineProperty(OO,"__esModule",{value:!0}),OO.NamedNode=void 0;return OO.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}},OO}function xO(){if(wO)return TO;wO=1,Object.defineProperty(TO,"__esModule",{value:!0}),TO.Literal=void 0;const e=SO();class t{constructor(e,r){this.termType="Literal",this.value=e,"string"==typeof r?(this.language=r,this.datatype=t.RDF_LANGUAGE_STRING,this.direction=""):r?"termType"in r?(this.language="",this.datatype=r,this.direction=""):(this.language=r.language,this.datatype=r.direction?t.RDF_DIRECTIONAL_LANGUAGE_STRING:t.RDF_LANGUAGE_STRING,this.direction=r.direction||""):(this.language="",this.datatype=t.XSD_STRING,this.direction="")}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&(e.direction===this.direction||!e.direction&&""===this.direction)&&this.datatype.equals(e.datatype)}}return TO.Literal=t,t.RDF_LANGUAGE_STRING=new e.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),t.RDF_DIRECTIONAL_LANGUAGE_STRING=new e.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"),t.XSD_STRING=new e.NamedNode("http://www.w3.org/2001/XMLSchema#string"),TO}var jO,AO={};function EO(){if(jO)return AO;jO=1,Object.defineProperty(AO,"__esModule",{value:!0}),AO.Quad=void 0;return AO.Quad=class{constructor(e,t,r,n){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=n}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}},AO}var IO,FO,DO,NO,PO,RO={};function MO(){if(IO)return RO;IO=1,Object.defineProperty(RO,"__esModule",{value:!0}),RO.Variable=void 0;return RO.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}},RO}function LO(){return DO||(DO=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(yO(),e),r(function(){if(FO)return mO;FO=1,Object.defineProperty(mO,"__esModule",{value:!0}),mO.DataFactory=void 0;const e=yO(),t=vO(),r=xO(),n=SO(),i=EO(),o=MO();let a=0;return mO.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${a++}_`}namedNode(e){return new n.NamedNode(e)}blankNode(t){return new e.BlankNode(t||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new r.Literal(e,t)}variable(e){return new o.Variable(e)}defaultGraph(){return t.DefaultGraph.INSTANCE}quad(e,t,r,n){return new i.Quad(e,t,r,n||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(r.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}},mO}(),e),r(vO(),e),r(xO(),e),r(SO(),e),r(EO(),e),r(MO(),e)}(fO)),fO}function CO(){return PO||(PO=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.termToString=e.stringToTerm=e.stringQuadToQuad=e.quadToStringQuad=e.getLiteralValue=e.getLiteralType=e.getLiteralDirection=e.getLiteralLanguage=void 0;const t=function(){if(NO)return pO;NO=1,Object.defineProperty(pO,"__esModule",{value:!0}),pO.termToString=t,pO.getLiteralValue=r,pO.getLiteralType=n,pO.getLiteralLanguage=i,pO.getLiteralDirection=o,pO.stringToTerm=a,pO.quadToStringQuad=function(e){return{subject:t(e.subject),predicate:t(e.predicate),object:t(e.object),graph:t(e.graph)}},pO.stringQuadToQuad=function(t,r){return(r=r||e).quad(a(t.subject,r),a(t.predicate,r),a(t.object,r),a(t.graph,r))};const e=new(LO().DataFactory);function t(e){if(e)switch(e.termType){case"NamedNode":case"DefaultGraph":return e.value;case"BlankNode":return"_:"+e.value;case"Literal":const r=e;return'"'+r.value+'"'+(r.datatype&&"http://www.w3.org/2001/XMLSchema#string"!==r.datatype.value&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"!==r.datatype.value&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"!==r.datatype.value?"^^"+r.datatype.value:"")+(r.language?"@"+r.language:"")+(r.direction?"--"+r.direction:"");case"Quad":return`<<${t(e.subject)} ${t(e.predicate)} ${t(e.object)}${"DefaultGraph"===e.graph.termType?"":" "+t(e.graph)}>>`;case"Variable":return"?"+e.value}}function r(e){const t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]}function n(e){const t=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]||(t[2]?"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString":"http://www.w3.org/2001/XMLSchema#string")}function i(e){const t=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");if(t[1]){let e=t[1].toLowerCase();const r=e.indexOf("--");return r>=0&&(e=e.slice(0,r)),e}return""}function o(e){const t=e.indexOf("--",e.lastIndexOf('"'));if(t>=0){const r=e.slice(t+2,e.length);if("ltr"===r||"rtl"===r)return r;throw new Error(e+" is not a literal with a valid direction")}return""}function a(t,s){if(s=s||e,!t||!t.length)return s.defaultGraph();switch(t[0]){case"_":return s.blankNode(t.substr(2));case"?":if(!s.variable)throw new Error("Missing 'variable()' method on the given DataFactory");return s.variable(t.substr(1));case'"':const e=i(t),c=o(t),u=s.namedNode(n(t));return s.literal(r(t),e?{language:e,direction:c}:u);default:if("<"===t[0]&&t.length>4&&"<"===t[1]&&">"===t[t.length-1]&&">"===t[t.length-2]){const e=t.slice(2,-2).trim();let r=[],n=0,i=0,o=!1;for(let a=0;a"===s){if(0===n)throw new Error("Found closing tag without opening tag in "+t);n--}if('"'===s){let t=!1,r=a;for(;r-- >0&&"\\"===e[r];)t=!t;t||(o=!o)}if(" "===s&&!o&&0===n){for(r.push(e.slice(i,a));" "===e[a+1];)a+=1;i=a+1}}if(0!==n)throw new Error("Found opening tag without closing tag in "+t);if(r.push(e.slice(i,e.length)),3!==r.length&&4!==r.length)throw new Error("Nested quad syntax error "+t);return r=r.map(e=>e.startsWith("<")&&!e.includes(" ")?e.slice(1,-1):e),s.quad(a(r[0]),a(r[1]),a(r[2]),r[3]?a(r[3]):void 0)}return s.namedNode(t)}}return pO}();Object.defineProperty(e,"getLiteralLanguage",{enumerable:!0,get:function(){return t.getLiteralLanguage}}),Object.defineProperty(e,"getLiteralDirection",{enumerable:!0,get:function(){return t.getLiteralDirection}}),Object.defineProperty(e,"getLiteralType",{enumerable:!0,get:function(){return t.getLiteralType}}),Object.defineProperty(e,"getLiteralValue",{enumerable:!0,get:function(){return t.getLiteralValue}}),Object.defineProperty(e,"quadToStringQuad",{enumerable:!0,get:function(){return t.quadToStringQuad}}),Object.defineProperty(e,"stringQuadToQuad",{enumerable:!0,get:function(){return t.stringQuadToQuad}}),Object.defineProperty(e,"stringToTerm",{enumerable:!0,get:function(){return t.stringToTerm}}),Object.defineProperty(e,"termToString",{enumerable:!0,get:function(){return t.termToString}})}(dO)),dO}var kO,BO={},UO={};var $O,qO,QO={};function zO(){return qO||(qO=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(kO)return UO;kO=1,Object.defineProperty(UO,"__esModule",{value:!0}),UO.TRIPLE_TERM_NAMES=UO.QUAD_TERM_NAMES=void 0,UO.getTerms=t,UO.getTermsNested=function e(r,n){const i=[];for(const o of t(r,n))"Quad"===o.termType?e(o,n).forEach(e=>i.push(e)):i.push(o);return i},UO.getNamedTerms=function(e){return[{key:"subject",value:e.subject},{key:"predicate",value:e.predicate},{key:"object",value:e.object},{key:"graph",value:e.graph}]},UO.collectNamedTerms=function(t,r,n){const i={};return t.forEach(e=>i[e.key]=e.value),r&&(i.subject=i.subject||r("subject"),i.predicate=i.predicate||r("predicate"),i.object=i.object||r("object"),i.graph=i.graph||r("graph")),(n||e).quad(i.subject,i.predicate,i.object,i.graph)},UO.forEachTerms=function(e,t){t(e.subject,"subject"),t(e.predicate,"predicate"),t(e.object,"object"),t(e.graph,"graph")},UO.forEachTermsNested=function e(t,r,n=[]){"Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]),"Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]),"Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]),"Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"])},UO.filterTerms=function(e,t){const r=[];return t(e.subject,"subject")&&r.push(e.subject),t(e.predicate,"predicate")&&r.push(e.predicate),t(e.object,"object")&&r.push(e.object),t(e.graph,"graph")&&r.push(e.graph),r},UO.filterTermsNested=function e(t,r,n=[]){let i=[];return"Quad"===t.subject.termType?i=[...i,...e(t.subject,r,[...n,"subject"])]:r(t.subject,[...n,"subject"])&&i.push(t.subject),"Quad"===t.predicate.termType?i=[...i,...e(t.predicate,r,[...n,"predicate"])]:r(t.predicate,[...n,"predicate"])&&i.push(t.predicate),"Quad"===t.object.termType?i=[...i,...e(t.object,r,[...n,"object"])]:r(t.object,[...n,"object"])&&i.push(t.object),"Quad"===t.graph.termType?i=[...i,...e(t.graph,r,[...n,"graph"])]:r(t.graph,[...n,"graph"])&&i.push(t.graph),i},UO.filterQuadTermNames=function(e,t){const r=[];return t(e.subject,"subject")&&r.push("subject"),t(e.predicate,"predicate")&&r.push("predicate"),t(e.object,"object")&&r.push("object"),t(e.graph,"graph")&&r.push("graph"),r},UO.filterQuadTermNamesNested=function e(t,r,n=[]){let i=[];const o=[...n,"subject"];"Quad"===t.subject.termType?i=[...i,...e(t.subject,r,o)]:r(t.subject,o)&&i.push(o);const a=[...n,"predicate"];"Quad"===t.predicate.termType?i=[...i,...e(t.predicate,r,a)]:r(t.predicate,a)&&i.push(a);const s=[...n,"object"];"Quad"===t.object.termType?i=[...i,...e(t.object,r,s)]:r(t.object,s)&&i.push(s);const c=[...n,"graph"];return"Quad"===t.graph.termType?i=[...i,...e(t.graph,r,c)]:r(t.graph,c)&&i.push(c),i},UO.mapTerms=function(t,r,n){return(n||e).quad(r(t.subject,"subject"),r(t.predicate,"predicate"),r(t.object,"object"),r(t.graph,"graph"))},UO.mapTermsNested=function t(r,n,i,o=[]){return(i||e).quad("Quad"===r.subject.termType?t(r.subject,n,i,[...o,"subject"]):n(r.subject,[...o,"subject"]),"Quad"===r.predicate.termType?t(r.predicate,n,i,[...o,"predicate"]):n(r.predicate,[...o,"predicate"]),"Quad"===r.object.termType?t(r.object,n,i,[...o,"object"]):n(r.object,[...o,"object"]),"Quad"===r.graph.termType?t(r.graph,n,i,[...o,"graph"]):n(r.graph,[...o,"graph"]))},UO.reduceTerms=function(e,t,r){let n=r;return n=t(n,e.subject,"subject"),n=t(n,e.predicate,"predicate"),n=t(n,e.object,"object"),t(n,e.graph,"graph")},UO.reduceTermsNested=function e(t,r,n,i=[]){let o=n;return o="Quad"===t.subject.termType?e(t.subject,r,o,[...i,"subject"]):r(o,t.subject,[...i,"subject"]),o="Quad"===t.predicate.termType?e(t.predicate,r,o,[...i,"predicate"]):r(o,t.predicate,[...i,"predicate"]),o="Quad"===t.object.termType?e(t.object,r,o,[...i,"object"]):r(o,t.object,[...i,"object"]),o="Quad"===t.graph.termType?e(t.graph,r,o,[...i,"graph"]):r(o,t.graph,[...i,"graph"]),o},UO.everyTerms=r,UO.everyTermsNested=function e(t,r,n=[]){return("Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]))&&("Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]))&&("Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]))&&("Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"]))},UO.someTerms=function(e,t){return t(e.subject,"subject")||t(e.predicate,"predicate")||t(e.object,"object")||t(e.graph,"graph")},UO.someTermsNested=function e(t,r,n=[]){return("Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]))||("Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]))||("Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]))||("Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"]))},UO.getValueNestedPath=function e(t,r){if(0===r.length)return t;if("Quad"===t.termType)return e(t[r[0]],r.slice(1));throw new Error(`Tried to get ${r[0]} from term of type ${t.termType}`)},UO.matchTerm=n,UO.matchPattern=i,UO.matchPatternComplete=o,UO.matchPatternMappings=function(e,t,n={}){const i={};return function e(t,o){return r(t,(t,r)=>{var a,s;const c=o[r];switch(t.termType){case"Variable":return n.skipVarMapping&&"Variable"===c.termType||(null!==(s=null===(a=i[t.value])||void 0===a?void 0:a.equals(c))&&void 0!==s?s:(i[t.value]=c,!0));case"Quad":return"Quad"===c.termType&&e(t,c);default:return t.equals(c)}})}(t,e)&&(!n.returnMappings||i)};const e=new(LO().DataFactory);function t(e,t){return t&&"DefaultGraph"===e.graph.termType?[e.subject,e.predicate,e.object]:[e.subject,e.predicate,e.object,e.graph]}function r(e,t){return t(e.subject,"subject")&&t(e.predicate,"predicate")&&t(e.object,"object")&&t(e.graph,"graph")}function n(e,t){return!t||"Variable"===t.termType||"Quad"===t.termType&&"Quad"===e.termType&&o(e,t)||t.equals(e)}function i(e,t,r,i,o){return n(e.subject,t)&&n(e.predicate,r)&&n(e.object,i)&&n(e.graph,o)}function o(e,t){return i(e,t.subject,t.predicate,t.object,t.graph)}return UO.QUAD_TERM_NAMES=["subject","predicate","object","graph"],UO.TRIPLE_TERM_NAMES=["subject","predicate","object"],UO}(),e),r(function(){if($O)return QO;$O=1,Object.defineProperty(QO,"__esModule",{value:!0}),QO.TERM_TYPES=void 0,QO.uniqTerms=function(t){const r={};return t.filter(t=>{const n=(0,e.termToString)(t);return!(n in r)&&(r[n]=!0)})},QO.getTermsOfType=t,QO.getNamedNodes=function(e){return t(e,"NamedNode")},QO.getBlankNodes=function(e){return t(e,"BlankNode")},QO.getLiterals=function(e){return t(e,"Literal")},QO.getVariables=function(e){return t(e,"Variable")},QO.getDefaultGraphs=function(e){return t(e,"DefaultGraph")},QO.getQuads=function(e){return t(e,"Quad")};const e=CO();function t(e,t){return e.filter(e=>e.termType===t)}return QO.TERM_TYPES=["NamedNode","BlankNode","Literal","Variable","DefaultGraph","Quad"],QO}(),e)}(BO)),BO}var GO,VO,XO,HO,JO,WO={exports:{}};
+/**
+ * @preserve
+ * JS Implementation of incremental MurmurHash3 (r150) (as of May 10, 2013)
+ *
+ * @author Jens Taylor
+ * @see http://github.com/homebrewing/brauhaus-diff
+ * @author Gary Court
+ * @see http://github.com/garycourt/murmurhash-js
+ * @author Austin Appleby
+ * @see http://sites.google.com/site/murmurhash/
+ */function KO(){return GO||(GO=1,e=WO,function(){var t;function r(e,n){var i=this instanceof r?this:t;if(i.reset(n),"string"==typeof e&&e.length>0&&i.hash(e),i!==this)return i}r.prototype.hash=function(e){var t,r,n,i,o;switch(o=e.length,this.len+=o,r=this.k1,n=0,this.rem){case 0:r^=o>n?65535&e.charCodeAt(n++):0;case 1:r^=o>n?(65535&e.charCodeAt(n++))<<8:0;case 2:r^=o>n?(65535&e.charCodeAt(n++))<<16:0;case 3:r^=o>n?(255&e.charCodeAt(n))<<24:0,r^=o>n?(65280&e.charCodeAt(n++))>>8:0}if(this.rem=o+this.rem&3,(o-=this.rem)>0){for(t=this.h1;t=5*(t=(t^=r=13715*(r=(r=11601*r+3432906752*(65535&r)&4294967295)<<15|r>>>17)+461832192*(65535&r)&4294967295)<<13|t>>>19)+3864292196&4294967295,!(n>=o);)r=65535&e.charCodeAt(n++)^(65535&e.charCodeAt(n++))<<8^(65535&e.charCodeAt(n++))<<16,r^=(255&(i=e.charCodeAt(n++)))<<24^(65280&i)>>8;switch(r=0,this.rem){case 3:r^=(65535&e.charCodeAt(n+2))<<16;case 2:r^=(65535&e.charCodeAt(n+1))<<8;case 1:r^=65535&e.charCodeAt(n)}this.h1=t}return this.k1=r,this},r.prototype.result=function(){var e,t;return e=this.k1,t=this.h1,e>0&&(t^=e=13715*(e=(e=11601*e+3432906752*(65535&e)&4294967295)<<15|e>>>17)+461832192*(65535&e)&4294967295),t^=this.len,t=51819*(t^=t>>>16)+2246770688*(65535&t)&4294967295,t=44597*(t^=t>>>13)+3266445312*(65535&t)&4294967295,(t^=t>>>16)>>>0},r.prototype.reset=function(e){return this.h1="number"==typeof e?e:0,this.rem=this.k1=this.len=0,this},t=new r,e.exports=r}()),WO.exports;var e}function YO(){return XO||(XO=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(VO)return lO;VO=1,Object.defineProperty(lO,"__esModule",{value:!0}),lO.isomorphic=function(e,t){return!!n(e,t)},lO.getBijection=n,lO.getBijectionInner=i,lO.hashValues=a,lO.hasValue=s,lO.getQuadsWithBlankNodes=c,lO.getQuadsWithoutBlankNodes=u,lO.indexGraph=l,lO.deindexGraph=d,lO.uniqGraph=p,lO.getGraphBlankNodes=f,lO.hashTerms=h,lO.hashTerm=y,lO.hashNumber=g,lO.quadToSignature=m,lO.termToSignature=b,lO.isTermGrounded=v;const e=CO(),t=zO(),r=KO();function n(e,t){const r=l(u(e)),n=l(u(t));if(Object.keys(r).length!==Object.keys(n).length)return null;for(const e in r)if(r[e]!==n[e])return null;return i(p(c(e)),p(c(t)),f(e),f(t))}function i(t,r,n,c,u,l){u||(u={}),l||(l={});const[d,p]=h(t,n,u),[f,y]=h(r,c,l);if(Object.keys(d).length!==Object.keys(f).length)return null;for(const e in d)if(!s(f,d[e]))return null;let m={};for(const t of n){const r=(0,e.termToString)(t),n=p[r];for(const e in y)if(y[e]===n){m[r]=e,delete y[e];break}}if(!o(Object.keys(m).sort(),n.map(e.termToString).sort())||!o(a(m).sort(),c.map(e.termToString).sort())){m=null;for(const o of n){const a=(0,e.termToString)(o);if(!d[a])for(const o of c){const s=(0,e.termToString)(o);if(!f[s]&&p[a]===y[s]){const e=g(a);m=i(t,r,n,c,Object.assign(Object.assign({},d),{[a]:e}),Object.assign(Object.assign({},f),{[s]:e}))}}}}return m}function o(e,t){if(e.length!==t.length)return!1;for(let r=e.length;r--;)if(e[r]!==t[r])return!1;return!0}function a(e){const t=[];for(const r in e)t.push(e[r]);return t}function s(e,t){for(const r in e)if(e[r]===t)return!0;return!1}function c(e){return e.filter(e=>(0,t.someTerms)(e,e=>"BlankNode"===e.termType||"Quad"===e.termType&&(0,t.getTermsNested)(e).some(e=>"BlankNode"===e.termType)))}function u(e){return e.filter(e=>(0,t.everyTerms)(e,e=>"BlankNode"!==e.termType&&!("Quad"===e.termType&&(0,t.getTermsNested)(e).some(e=>"BlankNode"===e.termType))))}function l(t){const r={};for(const n of t)r[JSON.stringify((0,e.quadToStringQuad)(n))]=!0;return r}function d(t){return Object.keys(t).map(t=>(0,e.stringQuadToQuad)(JSON.parse(t)))}function p(e){return d(l(e))}function f(e){return(0,t.uniqTerms)(e.map(e=>(0,t.getBlankNodes)((0,t.getTermsNested)(e))).reduce((e,t)=>e.concat(t),[]))}function h(t,r,n){const i=Object.assign({},n),o={};let a=!0;for(;a;){const n=Object.keys(i).length;for(const n of r){const r=(0,e.termToString)(n);if(!i[r]){const[e,a]=y(n,t,i);e&&(i[r]=a),o[r]=a}}const s=new Map;for(const e in o){const t=o[e];void 0===s.get(t)?s.set(t,e):s.set(t,!1)}for(const[e,t]of s.entries())t&&(i[t]=e);a=n!==Object.keys(i).length}return[i,o]}function y(e,r,n){const i=[];let o=!0;for(const a of r){const r=(0,t.getTermsNested)(a);if(r.some(t=>t.equals(e))){i.push(m(a,n,e));for(const t of r)v(t,n)||t.equals(e)||(o=!1)}}return[o,g(i.sort().join(""))]}function g(e){return r().hash(e).result()}function m(e,r,n){return(0,t.getTerms)(e).map(e=>b(e,r,n)).join("|")}function b(t,r,n){var i;return t.equals(n)?"@self":"BlankNode"===t.termType?(null===(i=r[(0,e.termToString)(t)])||void 0===i?void 0:i.toString())||"@blank":"Quad"===t.termType?`<${m(t,r,n)}>`:(0,e.termToString)(t)}function v(r,n){return"BlankNode"!==r.termType&&!("Quad"===r.termType&&(0,t.getTermsNested)(r).some(e=>!v(e,n)))||!!n[(0,e.termToString)(r)]}return lO}(),e)}(uO)),uO}function ZO(){if(HO)return cO;HO=1;var e=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),t=n&&n.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=n&&n.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(n,r,i);return t(n,r),n},i=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(cO,"__esModule",{value:!0}),cO.toSparqlJs=cO.toSparql=void 0;const o=YO(),a=DT(),s=XT(),c=r(RT()),u=i(HT()),l=i(oO()),d=c.types,p=c.expressionTypes;let f;const h=new u.default;function y(e){g();let t=m(e=function(e){return F(e,[])}(e));return"group"===t.type?t.patterns[0]:t}function g(){f={project:!1,extend:[],group:[],aggregates:[],order:[]}}function m(e){switch(e.type!==d.EXTEND&&e.type!==d.ORDER_BY&&e.type!==d.GRAPH&&(f.project=!1),e.type){case d.EXPRESSION:return b(e);case d.ASK:return x(e,d.ASK);case d.BGP:return function(e){let t=e.patterns.map(O);return 0===t.length?null:{type:"bgp",triples:t}}(e);case d.CONSTRUCT:return function(e){return{type:"query",prefixes:{},queryType:"CONSTRUCT",template:e.template.map(O),where:l.default.flatten([m(e.input)])}}(e);case d.DESCRIBE:return x(e,d.DESCRIBE);case d.DISTINCT:return function(e){let t=m(e.input);return t.patterns[0].distinct=!0,t}(e);case d.EXTEND:return function(e){if(f.project)return f.extend.push(e),m(e.input);return l.default.flatten([m(e.input),{type:"bind",variable:e.variable,expression:b(e.expression)}])}(e);case d.FROM:return function(e){const t=m(e.input);let r=t;"group"===t.type&&(r=t.patterns[0]);return r.from={default:e.default,named:e.named},t}(e);case d.FILTER:return function(e){return{type:"group",patterns:l.default.flatten([m(e.input),{type:"filter",expression:b(e.expression)}])}}(e);case d.GRAPH:return function(e){return{type:"graph",patterns:l.default.flatten([m(e.input)]),name:e.name}}(e);case d.GROUP:return function(e){const t=m(e.input),r=e.aggregates.map(T);return f.aggregates.push(...r),f.group.push(...e.variables),t}(e);case d.JOIN:return function(e){const t=l.default.flatten(e.input.map(m));return t.reduce((e,t)=>("bgp"!==t.type||0==e.length||"bgp"!==e[e.length-1].type?e.push(t):e[e.length-1].triples.push(...t.triples),e),[])}(e);case d.LEFT_JOIN:return function(e){const t={type:"optional",patterns:[m(e.input[1])]};e.expression&&t.patterns.push({type:"filter",expression:b(e.expression)});return t.patterns=l.default.flatten(t.patterns),l.default.flatten([m(e.input[0]),t])}(e);case d.MINUS:return function(e){let t=m(e.input[1]);"group"===t.type&&(t=t.patterns);Array.isArray(t)||(t=[t]);return l.default.flatten([m(e.input[0]),{type:"minus",patterns:t}])}(e);case d.NOP:return{};case d.ORDER_BY:return function(e){return f.order.push(...e.expressions),m(e.input)}(e);case d.PATH:return function(e){return{type:"bgp",triples:[{subject:e.subject,predicate:v(e.predicate),object:e.object}]}}(e);case d.PATTERN:return O(e);case d.PROJECT:return x(e,d.PROJECT);case d.REDUCED:return function(e){let t=m(e.input);return t.patterns[0].reduced=!0,t}(e);case d.SERVICE:return function(e){let t=m(e.input);"group"===t.type&&(t=t.patterns);Array.isArray(t)||(t=[t]);return{type:"service",name:e.name,silent:e.silent,patterns:t}}(e);case d.SLICE:return function(e){let t=m(e.input),r=t;t.type&&"group"===t.type&&(r=t.patterns[0]);0!==e.start&&(r.offset=e.start);void 0!==e.length&&(r.limit=e.length);return t}(e);case d.UNION:return function(e){return{type:"union",patterns:e.input.map(m).map(w)}}(e);case d.VALUES:return function(e){return{type:"values",values:e.bindings.map(t=>{let r={};for(let n of e.variables){let e=`?${n.value}`;t[e]?r[e]=t[e]:r[e]=void 0}return r})}}(e);case d.COMPOSITE_UPDATE:return function(e){const t=e.updates.map(e=>m(e).updates[0]);return{prefixes:{},type:"update",updates:t}}(e);case d.DELETE_INSERT:return function(e){var t;let r,n=e.where;if(n&&n.type===d.FROM){let e=n;n=e.input,r={default:e.default,named:e.named}}const i=[{updateType:"insertdelete",delete:I(e.delete||[]),insert:I(e.insert||[])}];r&&(i[0].using=r);if(!n||n.type===d.BGP&&0===n.patterns.length)i[0].where=[];else{const e=[];let r=m(F(n,e));if("group"===r.type?i[0].where=r.patterns:i[0].where=[r],e.length>0){if(1!==e.length)throw new Error("This is unexpected and might indicate an error in graph handling for updates.");""!==(null===(t=e[0])||void 0===t?void 0:t.value)&&(i[0].where=[{type:"graph",patterns:i[0].where,name:e[0]}])}}e.delete||e.where?e.insert||e.where?!e.insert&&e.where&&"bgp"===e.where.type&&(0,o.isomorphic)(e.delete,e.where.patterns)&&(delete i[0].where,i[0].updateType="deletewhere"):(delete i[0].insert,delete i[0].where,e.delete.some(e=>"Variable"===e.subject.termType||"Variable"===e.predicate.termType||"Variable"===e.object.termType)?i[0].updateType="deletewhere":i[0].updateType="delete"):(i[0].updateType="insert",delete i[0].delete,delete i[0].where);return{prefixes:{},type:"update",updates:i}}(e);case d.LOAD:return function(e){const t=[{type:"load",silent:Boolean(e.silent),source:e.source}];e.destination&&(t[0].destination=e.destination);return{prefixes:{},type:"update",updates:t}}(e);case d.CLEAR:return function(e){return A(e,"clear")}(e);case d.CREATE:return function(e){return A(e,"create")}(e);case d.DROP:return function(e){return A(e,"drop")}(e);case d.ADD:return function(e){return E(e,"add")}(e);case d.MOVE:return function(e){return E(e,"move")}(e);case d.COPY:return function(e){return E(e,"copy")}(e)}throw new Error(`Unknown Operation type ${e.type}`)}function b(e){switch(e.expressionType){case p.AGGREGATE:return function(e){const t={expression:b(e.expression),type:"aggregate",aggregation:e.aggregator,distinct:e.distinct};e.separator&&(t.separator=e.separator);return t}(e);case p.EXISTENCE:return function(e){return{type:"operation",operator:e.not?"notexists":"exists",args:[{type:"group",patterns:l.default.flatten([m(e.input)])}]}}(e);case p.NAMED:return function(e){return{type:"functionCall",function:e.name,args:e.args.map(b)}}(e);case p.OPERATOR:return function(e){if("desc"===e.operator){const t={expression:b(e.args[0]),descending:!0};return t}const t={type:"operation",operator:e.operator,args:e.args.map(b)};"in"!==t.operator&&"notin"!==t.operator||(t.args=[t.args[0]].concat([t.args.slice(1)]));return t}(e);case p.TERM:return function(e){return e.term}(e);case p.WILDCARD:return function(e){return e.wildcard}(e)}throw new Error(`Unknown Expression Operation type ${e.expressionType}`)}function v(e){switch(e.type){case d.ALT:return function(e){const t=e.input.map(v);if(t.every(e=>"pathType"in e&&"!"===e.pathType))return{type:"path",pathType:"!",items:[{type:"path",pathType:"|",items:l.default.flatten(t.map(e=>e.items))}]};return{type:"path",pathType:"|",items:t}}(e);case d.INV:return function(e){if(e.path.type===d.NPS){const t=e.path.iris.map(e=>({type:"path",pathType:"^",items:[e]}));return t.length<=1?{type:"path",pathType:"!",items:t}:{type:"path",pathType:"!",items:[{type:"path",pathType:"|",items:t}]}}return{type:"path",pathType:"^",items:[v(e.path)]}}(e);case d.LINK:return function(e){return e.iri}(e);case d.NPS:return function(e){return e.iris.length<=1?{type:"path",pathType:"!",items:e.iris}:{type:"path",pathType:"!",items:[{type:"path",pathType:"|",items:e.iris}]}}(e);case d.ONE_OR_MORE_PATH:return function(e){return{type:"path",pathType:"+",items:[v(e.path)]}}(e);case d.SEQ:return function(e){return{type:"path",pathType:"/",items:e.input.map(v)}}(e);case d.ZERO_OR_MORE_PATH:return function(e){return{type:"path",pathType:"*",items:[v(e.path)]}}(e);case d.ZERO_OR_ONE_PATH:return function(e){return{type:"path",pathType:"?",items:[v(e.path)]}}(e)}throw new Error(`Unknown Path type ${e.type}`)}function _(e){return(0,a.termToString)(e)}function w(e){return Array.isArray(e)?1===e.length?e[0]:{type:"group",patterns:e}:e}function T(e){return e}function O(e){return{subject:e.subject,predicate:e.predicate,object:e.object}}function S(e,t){let r=l.default.isSimpleTerm(e)?_(e):e;if("string"==typeof r){if(t[r])return t[r]}else if(Array.isArray(e))e=e.map(e=>S(e,t));else for(let r of Object.keys(e))e[r]=S(e[r],t);return e}function x(e,t){const r={type:"query",prefixes:{}},n=r;let i;t===d.PROJECT?(r.queryType="SELECT",i=e.variables):t===d.ASK?r.queryType="ASK":t===d.DESCRIBE&&(r.queryType="DESCRIBE",i=e.terms);const o=f.extend,c=f.group,u=f.aggregates,p=f.order;g(),f.project=!0;let h=l.default.flatten([m(e.input)]);1===h.length&&"group"===h[0].type&&(h=h[0].patterns),r.where=h;let y={};for(let e of f.aggregates)y[_(e.variable)]=b(e);let v={};for(let e=f.extend.length-1;e>=0;--e){let t=f.extend[e];v[_(t.variable)]=S(b(t.expression),y)}f.group.length>0&&(n.group=f.group.map(e=>{let t=_(e);if(v[t]){let r=v[t];return delete v[t],{variable:e,expression:r}}return{expression:e}})),f.order.length>0&&(n.order=f.order.map(m).map(e=>e.descending?e:{expression:e})),i&&(n.variables=i.map(e=>{let t=_(e);if(v[t]){let r=v[t];return delete v[t],{variable:e,expression:r}}return e}),0===n.variables.length&&(n.variables=[new s.Wildcard]));const w=Object.entries(v);if(w.length>0){n.where=n.where||[];for(const[e,t]of w)n.where.push({type:"bind",variable:(0,a.stringToTerm)(e),expression:t})}if(r.where.length>0&&"filter"===r.where[r.where.length-1].type){const e=r.where[r.where.length-1];j(e,Object.keys(y))&&(n.having=l.default.flatten([S(e.expression,y)]),r.where.splice(-1))}return f.extend=o,f.group=c,f.aggregates=u,f.order=p,{type:"group",patterns:[n]}}function j(e,t){return l.default.isSimpleTerm(e)?t.indexOf(_(e))>=0:Array.isArray(e)?e.some(e=>j(e,t)):e===Object(e)?Object.keys(e).some(r=>j(e[r],t)):t.indexOf(e)>=0}function A(e,t){const r=[{type:t,silent:Boolean(e.silent)}];return"DEFAULT"===e.source?r[0].graph={default:!0}:"NAMED"===e.source?r[0].graph={named:!0}:"ALL"===e.source?r[0].graph={all:!0}:r[0].graph={type:"graph",name:e.source},{prefixes:{},type:"update",updates:r}}function E(e,t){const r=[{type:t,silent:Boolean(e.silent)}];return r[0].source="DEFAULT"===e.source?{type:"graph",default:!0}:{type:"graph",name:e.source},r[0].destination="DEFAULT"===e.destination?{type:"graph",default:!0}:{type:"graph",name:e.destination},{prefixes:{},type:"update",updates:r}}function I(e){if(!e)return[];const t={};return e.forEach(e=>{const r=e.graph.value;t[r]||(t[r]=[]),t[r].push(e)}),Object.keys(t).map(e=>""===e?{type:"bgp",triples:t[e].map(O)}:{type:"graph",triples:t[e].map(O),name:t[e][0].graph})}function F(e,t){if(Array.isArray(e))return e.map(e=>F(e,t));if(!e.type)return e;if(e.type===d.DELETE_INSERT)return e;if((e.type===d.PATTERN||e.type===d.PATH)&&e.graph)return t.push(e.graph),""!==e.graph.name?e.type===d.PATTERN?h.createPattern(e.subject,e.predicate,e.object):h.createPath(e.subject,e.predicate,e.object):e;const r={},n={},i={};for(let t of Object.keys(e)){const o=[];if(r[t]=F(e[t],o),o.length>0){n[t]=o;for(const e of o)i[e.value]=e}}const o=Object.keys(i);if(o.length>0)if(1!==o.length||[d.PROJECT,d.SERVICE].includes(e.type)){if(e.type===d.BGP)return function(e,t){var r;const n={};for(let i=0;i""===n[e][0].value?t:h.createGraph(t,n[e][r])):""!==n[e][0].value&&(r[e]=h.createGraph(t,n[e][0]))}}else t.push(i[o[0]]);return r}return cO.toSparql=function(e,t={}){return new s.Generator(t).stringify(y(e))},cO.toSparqlJs=y,cO}function eS(){return JO||(JO=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&t(n,e,i);return r(n,e),n},o=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Util=e.toSparqlJs=e.toSparql=e.Factory=e.Algebra=e.translate=void 0;const a=o(aO());e.translate=a.default;const s=i(RT());e.Algebra=s;const c=o(HT());e.Factory=c.default;const u=ZO();Object.defineProperty(e,"toSparql",{enumerable:!0,get:function(){return u.toSparql}}),Object.defineProperty(e,"toSparqlJs",{enumerable:!0,get:function(){return u.toSparqlJs}});const l=o(oO());e.Util=l.default}(rT)),rT}var tS,rS={},nS={};var iS,oS={};var aS,sS={},cS={};function uS(){if(aS)return cS;aS=1,Object.defineProperty(cS,"__esModule",{value:!0}),cS.SparqlOperator=cS.TypeURL=cS.typedLiteral=cS.TypeAlias=void 0;const e=Fw;var t;!function(e){e.SPARQL_NUMERIC="SPARQL_NUMERIC",e.SPARQL_STRINGLY="SPARQL_STRINGLY"}(t||(cS.TypeAlias=t={}));const r=new e.DataFactory;var n,i;return cS.typedLiteral=function(e,t){return r.literal(e,r.namedNode(t))},function(e){e.XSD_ANY_URI="http://www.w3.org/2001/XMLSchema#anyURI",e.XSD_STRING="http://www.w3.org/2001/XMLSchema#string",e.RDF_LANG_STRING="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",e.XSD_BOOLEAN="http://www.w3.org/2001/XMLSchema#boolean",e.XSD_DATE_TIME="http://www.w3.org/2001/XMLSchema#dateTime",e.XSD_DATE_TIME_STAMP="http://www.w3.org/2001/XMLSchema#dateTimeStamp",e.XSD_DATE="http://www.w3.org/2001/XMLSchema#date",e.XSD_G_MONTH="http://www.w3.org/2001/XMLSchema#gMonth",e.XSD_G_MONTHDAY="http://www.w3.org/2001/XMLSchema#gMonthDay",e.XSD_G_YEAR="http://www.w3.org/2001/XMLSchema#gYear",e.XSD_G_YEAR_MONTH="http://www.w3.org/2001/XMLSchema#gYearMonth",e.XSD_TIME="http://www.w3.org/2001/XMLSchema#time",e.XSD_G_DAY="http://www.w3.org/2001/XMLSchema#gDay",e.XSD_DECIMAL="http://www.w3.org/2001/XMLSchema#decimal",e.XSD_FLOAT="http://www.w3.org/2001/XMLSchema#float",e.XSD_DOUBLE="http://www.w3.org/2001/XMLSchema#double",e.XSD_INTEGER="http://www.w3.org/2001/XMLSchema#integer",e.XSD_NON_POSITIVE_INTEGER="http://www.w3.org/2001/XMLSchema#nonPositiveInteger",e.XSD_NEGATIVE_INTEGER="http://www.w3.org/2001/XMLSchema#negativeInteger",e.XSD_LONG="http://www.w3.org/2001/XMLSchema#long",e.XSD_INT="http://www.w3.org/2001/XMLSchema#int",e.XSD_SHORT="http://www.w3.org/2001/XMLSchema#short",e.XSD_BYTE="http://www.w3.org/2001/XMLSchema#byte",e.XSD_NON_NEGATIVE_INTEGER="http://www.w3.org/2001/XMLSchema#nonNegativeInteger",e.XSD_POSITIVE_INTEGER="http://www.w3.org/2001/XMLSchema#positiveInteger",e.XSD_UNSIGNED_LONG="http://www.w3.org/2001/XMLSchema#unsignedLong",e.XSD_UNSIGNED_INT="http://www.w3.org/2001/XMLSchema#unsignedInt",e.XSD_UNSIGNED_SHORT="http://www.w3.org/2001/XMLSchema#unsignedShort",e.XSD_UNSIGNED_BYTE="http://www.w3.org/2001/XMLSchema#unsignedByte",e.XSD_NORMALIZED_STRING="http://www.w3.org/2001/XMLSchema#normalizedString",e.XSD_TOKEN="http://www.w3.org/2001/XMLSchema#token",e.XSD_LANGUAGE="http://www.w3.org/2001/XMLSchema#language",e.XSD_NM_TOKEN="http://www.w3.org/2001/XMLSchema#NMTOKEN",e.XSD_NAME="http://www.w3.org/2001/XMLSchema#name",e.XSD_NC_NAME="http://www.w3.org/2001/XMLSchema#NCName",e.XSD_ENTITY="http://www.w3.org/2001/XMLSchema#ENTITY",e.XSD_ID="http://www.w3.org/2001/XMLSchema#ID",e.XSD_ID_REF="http://www.w3.org/2001/XMLSchema#IDREF",e.XSD_DURATION="http://www.w3.org/2001/XMLSchema#duration",e.XSD_YEAR_MONTH_DURATION="http://www.w3.org/2001/XMLSchema#yearMonthDuration",e.XSD_DAY_TIME_DURATION="http://www.w3.org/2001/XMLSchema#dayTimeDuration",e.XSD_UNTYPED_ATOMIC="http://www.w3.org/2001/XMLSchema#untypedAtomic"}(n||(cS.TypeURL=n={})),function(e){e.NOT="!",e.UMINUS="uminus",e.UPLUS="uplus",e.LOGICAL_OR="||",e.LOGICAL_AND="&&",e.EQUAL="=",e.NOT_EQUAL="!=",e.LT="<",e.GT=">",e.LTE="<=",e.GTE=">=",e.SAME_TERM="sameterm",e.IN="in",e.NOT_IN="notin",e.MULTIPLICATION="*",e.DIVISION="/",e.ADDITION="+",e.SUBTRACTION="-",e.IS_IRI="isiri",e.IS_URI="isuri",e.IS_BLANK="isblank",e.IS_LITERAL="isliteral",e.IS_NUMERIC="isnumeric",e.STR="str",e.LANG="lang",e.DATATYPE="datatype",e.IRI="iri",e.URI="uri",e.BNODE="bnode",e.STRDT="strdt",e.STRLANG="strlang",e.UUID="uuid",e.STRUUID="struuid",e.STRLEN="strlen",e.SUBSTR="substr",e.UCASE="ucase",e.LCASE="lcase",e.STRSTARTS="strstarts",e.STRENDS="strends",e.CONTAINS="contains",e.STRBEFORE="strbefore",e.STRAFTER="strafter",e.ENCODE_FOR_URI="encode_for_uri",e.CONCAT="concat",e.LANG_MATCHES="langmatches",e.REGEX="regex",e.REPLACE="replace",e.ABS="abs",e.ROUND="round",e.CEIL="ceil",e.FLOOR="floor",e.RAND="rand",e.NOW="now",e.YEAR="year",e.MONTH="month",e.DAY="day",e.HOURS="hours",e.MINUTES="minutes",e.SECONDS="seconds",e.TIMEZONE="timezone",e.TZ="tz",e.MD5="md5",e.SHA1="sha1",e.SHA256="sha256",e.SHA384="sha384",e.SHA512="sha512",e.TRIPLE="triple",e.SUBJECT="subject",e.PREDICATE="predicate",e.OBJECT="object",e.IS_TRIPLE="istriple",e.BOUND="bound",e.IF="if",e.COALESCE="coalesce"}(i||(cS.SparqlOperator=i={})),cS}var lS,dS={};function pS(){if(lS)return dS;lS=1,Object.defineProperty(dS,"__esModule",{value:!0}),dS.NoAggregator=dS.ExtensionFunctionError=dS.InvalidExpression=dS.InvalidArity=dS.UnexpectedError=dS.ParseError=dS.EmptyAggregateError=dS.IncompatibleLanguageOperation=dS.InvalidTimezoneCall=dS.CastError=dS.InvalidArgumentTypes=dS.InError=dS.CoalesceError=dS.RDFEqualTypeError=dS.EBVCoercionError=dS.UnboundVariableError=dS.InvalidLexicalForm=dS.isExpressionError=dS.ExpressionError=void 0;class e extends Error{}dS.ExpressionError=e,dS.isExpressionError=function(t){return t instanceof e};dS.InvalidLexicalForm=class extends e{constructor(e){super(`Invalid lexical form '${a(e)}'`),this.arg=e}};dS.UnboundVariableError=class extends e{constructor(e,t){super(`Unbound variable '${a(e)}'`),this.variable=e,this.bindings=t}};dS.EBVCoercionError=class extends e{constructor(e){super(`Cannot coerce term to EBV '${a(e)}'`),this.arg=e}};dS.RDFEqualTypeError=class extends e{constructor(e){super("Equality test for literals with unsupported datatypes"),this.args=e}};dS.CoalesceError=class extends e{constructor(e){super("All COALESCE arguments threw errors"),this.errors=e}};dS.InError=class extends e{constructor(e){super(`Some argument to IN errorred and none where equal. ${e.map(e=>`(${e.toString()}) `).join("and ")}`),this.errors=e}};dS.InvalidArgumentTypes=class extends e{constructor(e,t){super(`Argument types not valid for operator: '${a(t)}' with '${a(e)}`),this.args=e,this.op=t}};dS.CastError=class extends e{constructor(e,t){super(`Invalid cast: '${a(e)}' to '${a(t)}'`),this.arg=e}};dS.InvalidTimezoneCall=class extends e{constructor(e){super(`TIMEZONE call on ${e} which has no timezone`),this.dateString=e}};dS.IncompatibleLanguageOperation=class extends e{constructor(e,t){super(`Operation on incompatible language literals '${a(e)}' and '${a(t)}'`),this.arg1=e,this.arg2=t}};dS.EmptyAggregateError=class extends e{constructor(){super("Empty aggregate expression")}};dS.ParseError=class extends e{constructor(e,t){super(`Failed to parse "${e}" as ${t}.`)}};class t extends Error{constructor(e,t){super(`Programmer Error '${e}'`),this.payload=t}}dS.UnexpectedError=t;class r extends Error{constructor(e,t){super(`The number of args does not match the arity of the operator '${a(t)}'.`),this.args=e,this.op=t}}dS.InvalidArity=r;class n extends Error{constructor(e){super(`Invalid SPARQL Expression '${a(e)}'`)}}dS.InvalidExpression=n;class i extends Error{constructor(e,t){t instanceof Error?super(`Error thrown in ${e}: ${t.message}${t.stack?`\n${t.stack}`:""}`):super(`Error thrown in ${e}`)}}dS.ExtensionFunctionError=i;class o extends Error{constructor(e){super(`Aggregate expression ${a(e)} found, but no aggregate hook provided.`)}}function a(e){return JSON.stringify(e)}return dS.NoAggregator=o,dS}var fS,hS={};var yS,gS,mS,bS,vS={},_S={},wS={};function TS(){if(yS)return wS;yS=1,Object.defineProperty(wS,"__esModule",{value:!0}),wS.OverloadTree=void 0;const e=PS(),t=SS();return wS.OverloadTree=class r{constructor(e,t){this.identifier=e,this.implementation=void 0,this.generalOverloads=Object.create(null),this.literalOverLoads=[],this.depth=t??0,this.promotionCount=void 0}getSubtree(e){const r=(0,t.asGeneralType)(e);if(r)return this.generalOverloads[r];for(const[t,r]of this.literalOverLoads)if(e===t)return r}getImplementationExact(e){let t=this;for(const r of e)if(t=t.getSubtree(r),!t)return;return t.implementation}search(t,r,n){let i=n[this.identifier],o=0;for(;o({node:e,index:1})));a.length>0;){const{index:e,node:i}=a.pop();if(e===t.length&&i.implementation)return this.addToCache(n,t,i.implementation),i.implementation;a.push(...i.getSubTreeWithArg(t[e],r).map(t=>({node:t,index:e+1})))}}addToCache(t,r,n){function i(e,t){return t in e||(e[t]={}),e[t]}let o=i(t,this.identifier);for(const t of r){const r=(0,e.isLiteralTermExpression)(t),n=r?r.dataType:t.termType;o.cache=o.cache??{},o=i(o.cache,n)}o.func=n}addOverload(e,t){this._addOverload([...e],t,0)}_addOverload(e,n,i){const[o,...a]=e;if(!o)return void((void 0===this.promotionCount||i<=this.promotionCount)&&(this.promotionCount=i,this.implementation=n));let s=this.getSubtree(o);if(!s){const e=new r(this.identifier,this.depth+1),n=(0,t.asGeneralType)(o);n&&(this.generalOverloads[n]=e);const i=(0,t.asOverrideType)(o);i&&this.literalOverLoads.push([i,e]),s=e}if(s._addOverload(a,n,i),t.typePromotion[o])for(const e of t.typePromotion[o])this.addPromotedOverload(e.typeToPromote,n,e.conversionFunction,a,i)}addPromotedOverload(e,t,n,i,o){let a=this.getSubtree(e);if(!a){const t=new r(this.identifier,this.depth+1);this.literalOverLoads.push([e,t]),a=t}a._addOverload(i,e=>r=>t(e)([...r.slice(0,this.depth),n(r[this.depth]),...r.slice(this.depth+1,r.length)]),o+1)}getSubTreeWithArg(r,n){const i=[],o=(0,e.isLiteralTermExpression)(r);if(this.generalOverloads.term&&i.push(this.generalOverloads.term),this.generalOverloads[r.termType]&&i.push(this.generalOverloads[r.termType]),o){const e=(0,t.asKnownLiteralType)(o.dataType);let r;r=e?t.superTypeDictTable[e]:(0,t.getSuperTypes)(o.dataType,n);const a=this.literalOverLoads.filter(([e,t])=>e in r).map(([e,t])=>[r[e],t]);a.sort(([e,t],[r,n])=>e-r),i.push(...a.map(([e,t])=>t))}return i}},wS}function OS(){if(gS)return _S;gS=1,Object.defineProperty(_S,"__esModule",{value:!0}),_S.expressionToVar=_S.dateTime=_S.langString=_S.string=_S.double=_S.float=_S.decimal=_S.integer=_S.bool=_S.Builder=_S.declare=void 0;const e=y_,t=PS(),r=PS(),n=uS(),i=uS(),o=pS(),a=TS();_S.declare=function(e){return new s(e)};class s{constructor(e){this.overloadTree=new a.OverloadTree(e),this.collected=!1}collect(){if(this.collected)throw new Error("Builders can only be collected once!");return this.collected=!0,this.overloadTree}static wrapInvalidLexicalProtected(t){return n=>i=>{for(const[t,a]of i.entries())if(a instanceof r.NonLexicalLiteral)throw new o.InvalidLexicalForm(i[t].toRDF(n.context.getSafe(e.KeysInitQuery.dataFactory)));return t(n)(i)}}set(e,t,r=!0){return this.overloadTree.addOverload(e,r?s.wrapInvalidLexicalProtected(t):t),this}copy({from:e,to:t}){const r=this.overloadTree.getImplementationExact(e);if(!r)throw new o.UnexpectedError("Tried to copy implementation, but types not found",{from:e,to:t});return this.set(t,r)}onUnary(e,t,r=!0){return this.set([e],e=>([r])=>t(e)(r),r)}onUnaryTyped(e,t,r=!0){return this.set([e],e=>([r])=>t(e)(r.typedValue),r)}onBinary(e,t,r=!0){return this.set(e,e=>([r,n])=>t(e)(r,n),r)}onBinaryTyped(e,t,r=!0){return this.set(e,e=>([r,n])=>t(e)(r.typedValue,n.typedValue),r)}onTernaryTyped(e,t,r=!0){return this.set(e,e=>([r,n,i])=>t(e)(r.typedValue,n.typedValue,i.typedValue),r)}onTernary(e,t,r=!0){return this.set(e,e=>([r,n,i])=>t(e)(r,n,i),r)}onQuaternaryTyped(e,t,r=!0){return this.set(e,e=>([r,n,i,o])=>t(e)(r.typedValue,n.typedValue,i.typedValue,o.typedValue),r)}onTerm1(e,t=!1){return this.set(["term"],t=>([r])=>e(t)(r),t)}onTerm3(e){return this.set(["term","term","term"],t=>([r,n,i])=>e(t)(r,n,i))}onQuad1(e){return this.set(["quad"],t=>([r])=>e(t)(r))}onLiteral1(e,t=!0){return this.set(["literal"],t=>([r])=>e(t)(r),t)}onBoolean1(e,t=!0){return this.set([n.TypeURL.XSD_BOOLEAN],t=>([r])=>e(t)(r),t)}onBoolean1Typed(e,t=!0){return this.set([n.TypeURL.XSD_BOOLEAN],t=>([r])=>e(t)(r.typedValue),t)}onString1(e,t=!0){return this.set([n.TypeURL.XSD_STRING],t=>([r])=>e(t)(r),t)}onString1Typed(e,t=!0){return this.set([n.TypeURL.XSD_STRING],t=>([r])=>e(t)(r.typedValue),t)}onLangString1(e,t=!0){return this.set([n.TypeURL.RDF_LANG_STRING],t=>([r])=>e(t)(r),t)}onStringly1(e,t=!0){return this.set([n.TypeAlias.SPARQL_STRINGLY],t=>([r])=>e(t)(r),t)}onStringly1Typed(e,t=!0){return this.set([n.TypeAlias.SPARQL_STRINGLY],t=>([r])=>e(t)(r.typedValue),t)}onNumeric1(e,t=!0){return this.set([n.TypeAlias.SPARQL_NUMERIC],t=>([r])=>e(t)(r),t)}onDateTime1(e,t=!0){return this.set([n.TypeURL.XSD_DATE_TIME],t=>([r])=>e(t)(r),t)}numericConverter(e,t=!0){const r=t=>r=>e(t)(r.typedValue);return this.onUnary(i.TypeURL.XSD_INTEGER,e=>t=>u(r(e)(t)),t).onUnary(i.TypeURL.XSD_DECIMAL,e=>t=>l(r(e)(t)),t).onUnary(i.TypeURL.XSD_FLOAT,e=>t=>d(r(e)(t)),t).onUnary(i.TypeURL.XSD_DOUBLE,e=>t=>p(r(e)(t)),t)}arithmetic(e,t=!0){const r=t=>(r,n)=>e(t)(r.typedValue,n.typedValue);return this.onBinary([i.TypeURL.XSD_INTEGER,i.TypeURL.XSD_INTEGER],e=>(t,n)=>u(r(e)(t,n)),t).onBinary([i.TypeURL.XSD_DECIMAL,i.TypeURL.XSD_DECIMAL],e=>(t,n)=>l(r(e)(t,n)),t).onBinary([i.TypeURL.XSD_FLOAT,i.TypeURL.XSD_FLOAT],e=>(t,n)=>d(r(e)(t,n)),t).onBinary([i.TypeURL.XSD_DOUBLE,i.TypeURL.XSD_DOUBLE],e=>(t,n)=>p(r(e)(t,n)),t)}numberTest(e){return this.numeric(t=>([r,n])=>c(e(t)(r.typedValue,n.typedValue)))}stringTest(e,t=!0){return this.set([n.TypeURL.XSD_STRING,n.TypeURL.XSD_STRING],t=>([r,n])=>c(e(t)(r.typedValue,n.typedValue)),t)}booleanTest(e,t=!0){return this.set([n.TypeURL.XSD_BOOLEAN,n.TypeURL.XSD_BOOLEAN],t=>([r,n])=>c(e(t)(r.typedValue,n.typedValue)),t)}dateTimeTest(e,t=!0){return this.set([n.TypeURL.XSD_DATE_TIME,n.TypeURL.XSD_DATE_TIME],t=>([r,n])=>c(e(t)(r.typedValue,n.typedValue)),t)}numeric(e){return this.set([n.TypeAlias.SPARQL_NUMERIC,n.TypeAlias.SPARQL_NUMERIC],e)}}function c(e){return new t.BooleanLiteral(e)}function u(e){return new t.IntegerLiteral(e)}function l(e){return new t.DecimalLiteral(e)}function d(e){return new t.FloatLiteral(e)}function p(e){return new t.DoubleLiteral(e)}return _S.Builder=s,_S.bool=c,_S.integer=u,_S.decimal=l,_S.float=d,_S.double=p,_S.string=function(e){return new t.StringLiteral(e)},_S.langString=function(e,r){return new t.LangStringLiteral(e,r)},_S.dateTime=function(e,r){return new t.DateTimeLiteral(e,r)},_S.expressionToVar=function(e,t){return e.variable(t.name.slice(1))},_S}function SS(){return mS||(mS=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.typePromotion=e.isSubTypeOf=e.getSuperTypeDict=e.isInternalSubType=e.asGeneralType=e.asOverrideType=e.asKnownLiteralType=e.asTypeAlias=e.typeAliasCheck=e.extensionTableInit=e.getSuperTypes=e.superTypeDictTable=e.extensionTableInput=void 0;const t=PS(),r=OS(),n=uS();function i(t,r){const n=r.cache.get(t);if(n)return n;const o=r.discoverer(t);if("term"===o){const e=Object.create(null);return e.__depth=0,e[t]=0,r.cache.set(t,e),e}let a;const c=s(o);return a=c?{...e.superTypeDictTable[c]}:{...i(o,r)},a.__depth++,a[t]=a.__depth,r.cache.set(t,a),a}function o(){for(const[t,r]of Object.entries(e.extensionTableInput)){const n=t;e.superTypeDictTable[n]||a(n,r,e.superTypeDictTable)}}function a(t,r,n){if("term"===r||void 0===r){const e=Object.create(null);return e.__depth=0,e[t]=0,void(n[t]=e)}n[r]||a(r,e.extensionTableInput[r],n),n[t]={...n[r],[t]:n[r].__depth+1,__depth:n[r].__depth+1}}function s(t){if(t in e.superTypeDictTable)return t}function c(t,r){const n=s(t);return n?e.superTypeDictTable[n]:i(t,r)}e.extensionTableInput={[n.TypeURL.XSD_DATE_TIME_STAMP]:n.TypeURL.XSD_DATE_TIME,[n.TypeURL.XSD_DAY_TIME_DURATION]:n.TypeURL.XSD_DURATION,[n.TypeURL.XSD_YEAR_MONTH_DURATION]:n.TypeURL.XSD_DURATION,[n.TypeURL.RDF_LANG_STRING]:n.TypeAlias.SPARQL_STRINGLY,[n.TypeURL.XSD_STRING]:n.TypeAlias.SPARQL_STRINGLY,[n.TypeURL.XSD_NORMALIZED_STRING]:n.TypeURL.XSD_STRING,[n.TypeURL.XSD_TOKEN]:n.TypeURL.XSD_NORMALIZED_STRING,[n.TypeURL.XSD_LANGUAGE]:n.TypeURL.XSD_TOKEN,[n.TypeURL.XSD_NM_TOKEN]:n.TypeURL.XSD_TOKEN,[n.TypeURL.XSD_NAME]:n.TypeURL.XSD_TOKEN,[n.TypeURL.XSD_NC_NAME]:n.TypeURL.XSD_NAME,[n.TypeURL.XSD_ENTITY]:n.TypeURL.XSD_NC_NAME,[n.TypeURL.XSD_ID]:n.TypeURL.XSD_NC_NAME,[n.TypeURL.XSD_ID_REF]:n.TypeURL.XSD_NC_NAME,[n.TypeURL.XSD_UNTYPED_ATOMIC]:n.TypeURL.XSD_STRING,[n.TypeURL.XSD_DOUBLE]:n.TypeAlias.SPARQL_NUMERIC,[n.TypeURL.XSD_FLOAT]:n.TypeAlias.SPARQL_NUMERIC,[n.TypeURL.XSD_DECIMAL]:n.TypeAlias.SPARQL_NUMERIC,[n.TypeURL.XSD_INTEGER]:n.TypeURL.XSD_DECIMAL,[n.TypeURL.XSD_NON_POSITIVE_INTEGER]:n.TypeURL.XSD_INTEGER,[n.TypeURL.XSD_NEGATIVE_INTEGER]:n.TypeURL.XSD_NON_POSITIVE_INTEGER,[n.TypeURL.XSD_LONG]:n.TypeURL.XSD_INTEGER,[n.TypeURL.XSD_INT]:n.TypeURL.XSD_LONG,[n.TypeURL.XSD_SHORT]:n.TypeURL.XSD_INT,[n.TypeURL.XSD_BYTE]:n.TypeURL.XSD_SHORT,[n.TypeURL.XSD_NON_NEGATIVE_INTEGER]:n.TypeURL.XSD_INTEGER,[n.TypeURL.XSD_POSITIVE_INTEGER]:n.TypeURL.XSD_NON_NEGATIVE_INTEGER,[n.TypeURL.XSD_UNSIGNED_LONG]:n.TypeURL.XSD_NON_NEGATIVE_INTEGER,[n.TypeURL.XSD_UNSIGNED_INT]:n.TypeURL.XSD_UNSIGNED_LONG,[n.TypeURL.XSD_UNSIGNED_SHORT]:n.TypeURL.XSD_UNSIGNED_INT,[n.TypeURL.XSD_UNSIGNED_BYTE]:n.TypeURL.XSD_UNSIGNED_SHORT,[n.TypeURL.XSD_DATE_TIME]:"term",[n.TypeURL.XSD_BOOLEAN]:"term",[n.TypeURL.XSD_DATE]:"term",[n.TypeURL.XSD_G_MONTH]:"term",[n.TypeURL.XSD_G_MONTHDAY]:"term",[n.TypeURL.XSD_G_YEAR]:"term",[n.TypeURL.XSD_G_YEAR_MONTH]:"term",[n.TypeURL.XSD_TIME]:"term",[n.TypeURL.XSD_G_DAY]:"term",[n.TypeURL.XSD_DURATION]:"term",[n.TypeAlias.SPARQL_NUMERIC]:"term",[n.TypeAlias.SPARQL_STRINGLY]:"term",[n.TypeURL.XSD_ANY_URI]:"term"},e.superTypeDictTable=Object.create(null),e.getSuperTypes=i,e.extensionTableInit=o,o(),e.typeAliasCheck=Object.create(null),function(){for(const t of Object.values(n.TypeAlias))e.typeAliasCheck[t]=!0}(),e.asTypeAlias=function(t){if(t in e.typeAliasCheck)return t},e.asKnownLiteralType=s,e.asOverrideType=function(e){if(s(e)??"term"===e)return e},e.asGeneralType=function(e){if("term"===e||(0,t.asTermType)(e))return e},e.isInternalSubType=function(t,r){return"term"!==t&&e.superTypeDictTable[t]&&void 0!==e.superTypeDictTable[t][r]},e.getSuperTypeDict=c,e.isSubTypeOf=function(e,t,r){return"term"!==e&&void 0!==c(e,r)[t]},e.typePromotion={[n.TypeURL.XSD_STRING]:[{typeToPromote:n.TypeURL.XSD_ANY_URI,conversionFunction:e=>(0,r.string)(e.str())}],[n.TypeURL.XSD_DOUBLE]:[{typeToPromote:n.TypeURL.XSD_FLOAT,conversionFunction:e=>(0,r.double)(e.typedValue)},{typeToPromote:n.TypeURL.XSD_DECIMAL,conversionFunction:e=>(0,r.double)(e.typedValue)}],[n.TypeURL.XSD_FLOAT]:[{typeToPromote:n.TypeURL.XSD_DECIMAL,conversionFunction:e=>(0,r.float)(e.typedValue)}]}}(vS)),vS}function xS(){if(bS)return sS;bS=1,Object.defineProperty(sS,"__esModule",{value:!0}),sS.isNonLexicalLiteral=sS.NonLexicalLiteral=sS.YearMonthDurationLiteral=sS.DayTimeDurationLiteral=sS.DurationLiteral=sS.DateLiteral=sS.TimeLiteral=sS.DateTimeLiteral=sS.StringLiteral=sS.LangStringLiteral=sS.BooleanLiteral=sS.DoubleLiteral=sS.FloatLiteral=sS.DecimalLiteral=sS.IntegerLiteral=sS.NumericLiteral=sS.Literal=sS.isLiteralTermExpression=sS.DefaultGraph=sS.Quad=sS.BlankNode=sS.NamedNode=sS.Term=void 0;const e=yw(),t=uS(),r=uS(),n=pS(),i=function(){if(fS)return hS;function e(e,t=2){return e.toLocaleString(void 0,{minimumIntegerDigits:t,useGrouping:!1})}function t(t){return void 0===t.zoneHours||void 0===t.zoneMinutes?"":0===t.zoneHours&&0===t.zoneMinutes?"Z":`${t.zoneHours>=0?`+${e(t.zoneHours)}`:e(t.zoneHours)}:${e(Math.abs(t.zoneMinutes))}`}function r(r){return`${e(r.year,4)}-${e(r.month)}-${e(r.day)}${t(r)}`}function n(r){return`${e(r.hours)}:${e(r.minutes)}:${e(r.seconds)}${t(r)}`}return fS=1,Object.defineProperty(hS,"__esModule",{value:!0}),hS.serializeDuration=hS.serializeTime=hS.serializeDate=hS.serializeDateTime=void 0,hS.serializeDateTime=function(e){return`${r({year:e.year,month:e.month,day:e.day})}T${n(e)}`},hS.serializeDate=r,hS.serializeTime=n,hS.serializeDuration=function(e,t="PT0S"){if(!Object.values(e).some(e=>0!==(e||0)))return t;const r=`${Object.values(e).some(e=>(e||0)<0)?"-":""}P${e.year?`${Math.abs(e.year)}Y`:""}${e.month?`${Math.abs(e.month)}M`:""}${e.day?`${Math.abs(e.day)}D`:""}`;return e.hours||e.minutes||e.seconds?`${r}T${e.hours?`${Math.abs(e.hours)}H`:""}${e.minutes?`${Math.abs(e.minutes)}M`:""}${e.seconds?`${Math.abs(e.seconds)}S`:""}`:r},hS}(),o=SS();let a=class{constructor(){this.expressionType=e.ExpressionType.Term}str(){throw new n.InvalidArgumentTypes([this],t.SparqlOperator.STR)}coerceEBV(){throw new n.EBVCoercionError(this)}};sS.Term=a;sS.NamedNode=class extends a{constructor(e){super(),this.value=e,this.termType="namedNode"}toRDF(e){return e.namedNode(this.value)}str(){return this.value}};sS.BlankNode=class extends a{constructor(e){super(),this.termType="blankNode",this.value=e}toRDF(e){return"string"==typeof this.value?e.blankNode(this.value):this.value}};sS.Quad=class extends a{constructor(e,t,r,n){super(),this.subject=e,this.predicate=t,this.object=r,this.graph=n,this.termType="quad"}toRDF(e){return e.quad(this.subject.toRDF(e),this.predicate.toRDF(e),this.object.toRDF(e),this.graph.toRDF(e))}str(){return`Quad: [${this.subject.str()}, ${this.predicate.str()}, ${this.object.str()}, ${this.graph.str()}]`}};sS.DefaultGraph=class extends a{constructor(){super(),this.termType="defaultGraph"}toRDF(e){return e.defaultGraph()}str(){return"DefaultGraph"}},sS.isLiteralTermExpression=function(e){if("literal"===e.termType)return e};class s extends a{constructor(e,t,r,n){super(),this.typedValue=e,this.dataType=t,this.strValue=r,this.language=n,this.termType="literal"}toRDF(e){return e.literal(this.strValue??this.str(),this.language??e.namedNode(this.dataType))}str(){return this.strValue??this.typedValue.toString()}}sS.Literal=s;class c extends s{constructor(e,t,r,n){super(e,t,r,n),this.typedValue=e,this.strValue=r,this.language=n}coerceEBV(){return Boolean(this.typedValue)}toRDF(e){const t=super.toRDF(e);return Number.isFinite(this.typedValue)||(t.value=t.value.replace("Infinity","INF")),t}str(){return this.strValue??this.specificFormatter(this.typedValue)}}sS.NumericLiteral=c;sS.IntegerLiteral=class extends c{constructor(e,t,n,i){super(e,t??r.TypeURL.XSD_INTEGER,n,i),this.typedValue=e,this.strValue=n,this.language=i}specificFormatter(e){return e.toFixed(0)}};sS.DecimalLiteral=class extends c{constructor(e,t,n,i){super(e,t??r.TypeURL.XSD_DECIMAL,n,i),this.typedValue=e,this.strValue=n,this.language=i}specificFormatter(e){return e.toString()}};sS.FloatLiteral=class extends c{constructor(e,t,n,i){super(e,t??r.TypeURL.XSD_FLOAT,n,i),this.typedValue=e,this.strValue=n,this.language=i}specificFormatter(e){return e.toString()}};sS.DoubleLiteral=class extends c{constructor(e,t,n,i){super(e,t??r.TypeURL.XSD_DOUBLE,n,i),this.typedValue=e,this.strValue=n,this.language=i}specificFormatter(e){if(!Number.isFinite(e))return e>0?"INF":e<0?"-INF":"NaN";const t=e.toExponential(),[r,n]=t.split("e"),i=n.replace(/\+/u,"");return`${r.includes(".")?r:`${r}.0`}E${i}`}};sS.BooleanLiteral=class extends s{constructor(e,t,n){super(e,n??r.TypeURL.XSD_BOOLEAN,t),this.typedValue=e,this.strValue=t}coerceEBV(){return this.typedValue}};sS.LangStringLiteral=class extends s{constructor(e,t,n){super(e,n??r.TypeURL.RDF_LANG_STRING,e,t),this.typedValue=e,this.language=t}coerceEBV(){return this.str().length>0}};sS.StringLiteral=class extends s{constructor(e,t){super(e,t??r.TypeURL.XSD_STRING,e),this.typedValue=e}coerceEBV(){return this.str().length>0}};sS.DateTimeLiteral=class extends s{constructor(e,t,n){super(e,n??r.TypeURL.XSD_DATE_TIME,t),this.typedValue=e,this.strValue=t}str(){return(0,i.serializeDateTime)(this.typedValue)}};sS.TimeLiteral=class extends s{constructor(e,t,n){super(e,n??r.TypeURL.XSD_TIME,t),this.typedValue=e,this.strValue=t}str(){return(0,i.serializeTime)(this.typedValue)}};sS.DateLiteral=class extends s{constructor(e,t,n){super(e,n??r.TypeURL.XSD_DATE,t),this.typedValue=e,this.strValue=t}str(){return(0,i.serializeDate)(this.typedValue)}};class u extends s{constructor(e,t,n){super(e,n??r.TypeURL.XSD_DURATION,t),this.typedValue=e,this.strValue=t}str(){return(0,i.serializeDuration)(this.typedValue)}}sS.DurationLiteral=u;sS.DayTimeDurationLiteral=class extends u{constructor(e,t,n){super(e,t,n??r.TypeURL.XSD_DAY_TIME_DURATION),this.typedValue=e,this.strValue=t}};sS.YearMonthDurationLiteral=class extends s{constructor(e,t,n){super(e,n??r.TypeURL.XSD_YEAR_MONTH_DURATION,t),this.typedValue=e,this.strValue=t}str(){return(0,i.serializeDuration)(this.typedValue,"P0M")}};class l extends s{constructor(e,t,r,n,i){super({toString:()=>"undefined"},t,n,i),this.openWorldType=r}coerceEBV(){if((0,o.isSubTypeOf)(this.dataType,r.TypeURL.XSD_BOOLEAN,this.openWorldType)||(0,o.isSubTypeOf)(this.dataType,r.TypeAlias.SPARQL_NUMERIC,this.openWorldType))return!1;throw new n.EBVCoercionError(this)}toRDF(e){return e.literal(this.str(),this.language??e.namedNode(this.dataType))}str(){return this.strValue??""}}return sS.NonLexicalLiteral=l,sS.isNonLexicalLiteral=function(e){if(e instanceof l)return e},sS}var jS,AS={};var ES,IS={};var FS,DS,NS={};function PS(){return DS||(DS=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r((tS||(tS=1,Object.defineProperty(nS,"__esModule",{value:!0}),nS.asTermType=void 0,nS.asTermType=function(e){if("namedNode"===e||"literal"===e||"blankNode"===e||"quad"===e)return e}),nS),e),r(function(){if(iS)return oS;iS=1,Object.defineProperty(oS,"__esModule",{value:!0}),oS.Variable=void 0;const e=yw();return oS.Variable=class{constructor(t){this.expressionType=e.ExpressionType.Variable,this.name=t}},oS}(),e),r(xS(),e),r(function(){if(jS)return AS;jS=1,Object.defineProperty(AS,"__esModule",{value:!0}),AS.Operator=void 0;const e=yw();return AS.Operator=class{constructor(t,r,n){this.name=t,this.args=r,this.apply=n,this.expressionType=e.ExpressionType.Operator}},AS}(),e),r(function(){if(ES)return IS;ES=1,Object.defineProperty(IS,"__esModule",{value:!0}),IS.Aggregate=void 0;const e=yw();return IS.Aggregate=class{constructor(t,r){this.name=t,this.expression=r,this.expressionType=e.ExpressionType.Aggregate}},IS}(),e),r(function(){if(FS)return NS;FS=1,Object.defineProperty(NS,"__esModule",{value:!0}),NS.Existence=void 0;const e=yw();return NS.Existence=class{constructor(t){this.expression=t,this.expressionType=e.ExpressionType.Existence}},NS}(),e)}(rS)),rS}var RS,MS={},LS={};function CS(){if(RS)return LS;function e(e){return{day:e.day??0,hours:e.hours??0,minutes:e.minutes??0,seconds:e.seconds??0}}function t(e){return{year:e.year??0,month:e.month??0}}function r(r){return{...e(r),...t(r)}}function n(e){return{...e,day:e.day??1,hours:e.hours??0,month:e.month??1,year:e.year??0,seconds:e.seconds??0,minutes:e.minutes??0}}function i(e){const t=new Date(e.year,e.month-1,e.day,e.hours,e.minutes,Math.trunc(e.seconds),e.seconds%1*1e3);if(e.year>=0&&e.year<100){const e=1900;t.setFullYear(t.getFullYear()-e)}return t}return RS=1,Object.defineProperty(LS,"__esModule",{value:!0}),LS.extractTimeZone=LS.extractRawTimeZone=LS.dayTimeDurationsToSeconds=LS.yearMonthDurationsToMonths=LS.trimToDayTimeDuration=LS.trimToYearMonthDuration=LS.toUTCDate=LS.toJSDate=LS.negateDuration=LS.toDateTimeRepresentation=LS.defaultedDateTimeRepresentation=LS.simplifyDurationRepresentation=LS.defaultedDurationRepresentation=LS.defaultedYearMonthDurationRepresentation=LS.defaultedDayTimeDurationRepresentation=void 0,LS.defaultedDayTimeDurationRepresentation=e,LS.defaultedYearMonthDurationRepresentation=t,LS.defaultedDurationRepresentation=r,LS.simplifyDurationRepresentation=function(e){const t=r(e),n={},i=t.year+Math.trunc(t.month/12);i&&(n.year=i,t.month%=12),t.month&&(n.month=t.month);const o=t.day+Math.trunc(t.hours/24)+Math.trunc(t.minutes/1440)+Math.trunc(t.seconds/86400);o&&(n.day=o,t.hours%=24,t.minutes%=1440,t.seconds%=86400);const a=t.hours+Math.trunc(t.minutes/60)+Math.trunc(t.seconds/3600);a&&(n.hours=a,t.minutes%=60,t.seconds%=3600);const s=t.minutes+Math.trunc(t.seconds/60);return s&&(n.minutes=s,t.seconds%=60),t.seconds&&(n.seconds=t.seconds),n},LS.defaultedDateTimeRepresentation=n,LS.toDateTimeRepresentation=function({date:e,timeZone:t}){return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds(),zoneHours:t.zoneHours,zoneMinutes:t.zoneMinutes}},LS.negateDuration=function(e){return{year:void 0===e.year?void 0:-1*e.year,month:void 0===e.month?void 0:-1*e.month,day:void 0===e.day?void 0:-1*e.day,hours:void 0===e.hours?void 0:-1*e.hours,minutes:void 0===e.minutes?void 0:-1*e.minutes,seconds:void 0===e.seconds?void 0:-1*e.seconds}},LS.toJSDate=i,LS.toUTCDate=function(e,t){const r=i(n(e)),o=r.getTimezoneOffset(),a=e.zoneHours??t.zoneHours,s=e.zoneMinutes??t.zoneMinutes;return new Date(r.getTime()-60*(o+60*a+s)*1e3)},LS.trimToYearMonthDuration=function(e){return{year:e.year,month:e.month}},LS.trimToDayTimeDuration=function(e){return{day:e.day,hours:e.hours,minutes:e.minutes,seconds:e.seconds}},LS.yearMonthDurationsToMonths=function(e){return 12*e.year+e.month},LS.dayTimeDurationsToSeconds=function(e){return 60*(60*(24*e.day+e.hours)+e.minutes)+e.seconds},LS.extractRawTimeZone=function(e){return/(Z|([+-]\d\d:\d\d))?$/u.exec(e)[0]},LS.extractTimeZone=function(e){return{zoneHours:e.getTimezoneOffset()/60,zoneMinutes:e.getTimezoneOffset()%60}},LS}var kS,BS,US,$S={};function qS(){if(kS)return $S;kS=1,Object.defineProperty($S,"__esModule",{value:!0}),$S.elapsedDuration=$S.addDurationToDateTime=$S.maximumDayInMonthFor=void 0;const e=CS();function t(e,t,r=0){const n=e-r,i=t-r,o=Math.floor(n/i);return{intDiv:o,remainder:e-o*i}}function r(e,r){const{intDiv:n,remainder:i}=t(r,13,1),o=e+n;return[1,3,5,7,8,10,12].includes(i)?31:[4,6,9,11].includes(i)?30:2===i&&(0===t(o,400).remainder||0!==t(o,100).remainder&&0===t(o,4).remainder)?29:28}return $S.maximumDayInMonthFor=r,$S.addDurationToDateTime=function(e,n){const i={...e};let o=t(e.month+n.month,13,1);for(i.month=o.remainder,i.year=e.year+n.year+o.intDiv,o=t(e.seconds+n.seconds,60),i.seconds=o.remainder,o=t(e.minutes+n.minutes+o.intDiv,60),i.minutes=o.remainder,o=t(e.hours+n.hours+o.intDiv,24),i.hours=o.remainder,i.day=e.day+n.day+o.intDiv;;){let e;if(i.day<1)i.day+=r(i.year,i.month-1),e=-1;else{if(!(i.day>r(i.year,i.month)))break;i.day-=r(i.year,i.month),e=1}o=t(i.month+e,13,1),i.month=o.remainder,i.year+=o.intDiv}return i},$S.elapsedDuration=function(t,r,n){const i=(0,e.toUTCDate)(t,n),o=(0,e.toUTCDate)(r,n),a=i.getTime()-o.getTime();return{day:Math.floor(a/864e5),hours:Math.floor(a%864e5/36e5),minutes:Math.floor(a%36e5/6e4),seconds:a%6e4}},$S}function QS(){if(BS)return MS;BS=1,Object.defineProperty(MS,"__esModule",{value:!0}),MS.parseDayTimeDuration=MS.parseYearMonthDuration=MS.parseDuration=MS.parseTime=MS.parseDate=MS.parseDateTime=MS.parseXSDDecimal=MS.parseXSDFloat=void 0;const e=CS(),t=pS(),r=qS();function n(e){if(""===e)return{zoneHours:void 0,zoneMinutes:void 0};if("Z"===e)return{zoneHours:0,zoneMinutes:0};const t=e.replaceAll(/^([+|-])(\d\d):(\d\d)$/gu,"$11!$2!$3").split("!").map(Number);return{zoneHours:t[0]*t[1],zoneMinutes:t[0]*t[2]}}function i(e){const i=e.replaceAll(/^(-)?([123456789]*\d{4})-(\d\d)-(\d\d)(Z|([+-]\d\d:\d\d))?$/gu,"$11!$2!$3!$4!$5");if(i===e)throw new t.ParseError(e,"date");const o=i.split("!"),a=o.slice(0,-1).map(Number),s={year:a[0]*a[1],month:a[2],day:a[3],...n(o[4])};if(!(s.month>=1&&s.month<=12&&s.day>=1&&s.day<=(0,r.maximumDayInMonthFor)(s.year,s.month)))throw new t.ParseError(e,"date");return s}function o(e){const r=e.replaceAll(/^(\d\d):(\d\d):(\d\d(\.\d+)?)(Z|([+-]\d\d:\d\d))?$/gu,"$1!$2!$3!$5");if(r===e)throw new t.ParseError(e,"time");const i=r.split("!"),o=i.slice(0,-1).map(Number),a={hours:o[0],minutes:o[1],seconds:o[2],...n(i[3])};if(a.seconds>=60||a.minutes>=60||a.hours>24||24===a.hours&&(0!==a.minutes||0!==a.seconds))throw new t.ParseError(e,"time");return a}function a(r){const[n,i]=r.split("T"),o=n.replaceAll(/^(-)?P(\d+Y)?(\d+M)?(\d+D)?$/gu,"$11S!$2!$3!$4");if(o===n)throw new t.ParseError(r,"duration");const a=o.split("!");if(void 0!==i){const e=i.replaceAll(/^(\d+H)?(\d+M)?(\d+(\.\d+)?S)?$/gu,"$1!$2!$3");if(""===i||i===e)throw new t.ParseError(r,"duration");a.push(...e.split("!"))}const s=a.map(e=>e.slice(0,-1));if(!s.slice(1).some(Boolean))throw new t.ParseError(r,"duration");const c=Number(s[0]);return(0,e.simplifyDurationRepresentation)({year:s[1]?c*Number(s[1]):void 0,month:s[2]?c*Number(s[2]):void 0,day:s[3]?c*Number(s[3]):void 0,hours:s[4]?c*Number(s[4]):void 0,minutes:s[5]?c*Number(s[5]):void 0,seconds:s[6]?c*Number(s[6]):void 0})}return MS.parseXSDFloat=function(e){const t=Number(e);return Number.isNaN(t)?"NaN"===e?Number.NaN:"INF"===e||"+INF"===e?Number.POSITIVE_INFINITY:"-INF"===e?Number.NEGATIVE_INFINITY:void 0:t},MS.parseXSDDecimal=function(e){const t=Number(e);return Number.isNaN(t)?void 0:t},MS.parseDateTime=function(e){const[r,n]=e.split("T");if(void 0===n)throw new t.ParseError(e,"dateTime");return{...i(r),...o(n)}},MS.parseDate=i,MS.parseTime=function(e){const t=o(e);return t.hours%=24,t},MS.parseDuration=a,MS.parseYearMonthDuration=function(e){const r=a(e);if(["hours","minutes","seconds","day"].some(e=>Boolean(r[e])))throw new t.ParseError(e,"yearMonthDuration");return r},MS.parseDayTimeDuration=function(e){const r=a(e);if(["year","month"].some(e=>Boolean(r[e])))throw new t.ParseError(e,"dayTimeDuration");return r},MS}var zS={};const GS="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,VS=new Set,XS="object"==typeof process&&process?process:{},HS=(e,t,r,n)=>{"function"==typeof XS.emitWarning?XS.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)};let JS=globalThis.AbortController,WS=globalThis.AbortSignal;if(void 0===JS){WS=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},JS=class{constructor(){t()}signal=new WS;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==XS.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,HS("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}const KS=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),YS=e=>KS(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?ZS:null:null;let ZS=class extends Array{constructor(e){super(e),this.fill(0)}},ex=class e{heap;length;static#e=!1;static create(t){const r=YS(t);if(!r)return[];e.#e=!0;const n=new e(t,r);return e.#e=!1,n}constructor(t,r){if(!e.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},tx=class e{#t;#r;#n;#i;#o;#a;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#c;#u;#l;#d;#p;#f;#h;#y;#g;#m;#b;#v;#_;#w;#T;#O;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#_,sizes:e.#b,keyMap:e.#u,keyList:e.#l,valList:e.#d,next:e.#p,prev:e.#f,get head(){return e.#h},get tail(){return e.#y},free:e.#g,isBackgroundFetch:t=>e.#S(t),backgroundFetch:(t,r,n,i)=>e.#x(t,r,n,i),moveToTail:t=>e.#j(t),indexes:t=>e.#A(t),rindexes:t=>e.#E(t),isStale:t=>e.#I(t)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#c}get size(){return this.#s}get fetchMethod(){return this.#o}get memoMethod(){return this.#a}get dispose(){return this.#n}get disposeAfter(){return this.#i}constructor(t){const{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:s,allowStale:c,dispose:u,disposeAfter:l,noDisposeOnSet:d,noUpdateTTL:p,maxSize:f=0,maxEntrySize:h=0,sizeCalculation:y,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:b,noDeleteOnStaleGet:v,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:w,ignoreFetchAbort:T}=t;if(0!==r&&!KS(r))throw new TypeError("max option must be a nonnegative integer");const O=r?YS(r):Array;if(!O)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=f,this.maxEntrySize=h||this.#r,this.sizeCalculation=y,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#a=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#o=g,this.#T=!!g,this.#u=new Map,this.#l=new Array(r).fill(void 0),this.#d=new Array(r).fill(void 0),this.#p=new O(r),this.#f=new O(r),this.#h=0,this.#y=0,this.#g=ex.create(r),this.#s=0,this.#c=0,"function"==typeof u&&(this.#n=u),"function"==typeof l?(this.#i=l,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#w=!!this.#n,this.#O=!!this.#i,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!b,this.allowStaleOnFetchRejection=!!_,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!T,0!==this.maxEntrySize){if(0!==this.#r&&!KS(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!KS(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#F()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!v,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!s,this.ttlResolution=KS(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!KS(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}if(0===this.#t&&0===this.ttl&&0===this.#r)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){const t="LRU_CACHE_UNBOUNDED";if((e=>!VS.has(e))(t)){VS.add(t);HS("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,e)}}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#D(){const e=new ZS(this.#t),t=new ZS(this.#t);this.#_=e,this.#v=t,this.#N=(r,n,i=GS.now())=>{if(t[r]=0!==n?i:0,e[r]=n,0!==n&&this.ttlAutopurge){const e=setTimeout(()=>{this.#I(r)&&this.#P(this.#l[r],"expire")},n+1);e.unref&&e.unref()}},this.#R=r=>{t[r]=0!==e[r]?GS.now():0},this.#M=(i,o)=>{if(e[o]){const a=e[o],s=t[o];if(!a||!s)return;i.ttl=a,i.start=s,i.now=r||n();const c=i.now-s;i.remainingTTL=a-c}};let r=0;const n=()=>{const e=GS.now();if(this.ttlResolution>0){r=e;const t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{const o=this.#u.get(i);if(void 0===o)return 0;const a=e[o],s=t[o];if(!a||!s)return 1/0;return a-((r||n())-s)},this.#I=i=>{const o=t[i],a=e[i];return!!a&&!!o&&(r||n())-o>a}}#R=()=>{};#M=()=>{};#N=()=>{};#I=()=>!1;#F(){const e=new ZS(this.#t);this.#c=0,this.#b=e,this.#L=t=>{this.#c-=e[t],e[t]=0},this.#C=(e,t,r,n)=>{if(this.#S(t))return 0;if(!KS(r)){if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(t,e),!KS(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#k=(t,r,n)=>{if(e[t]=r,this.#r){const r=this.#r-e[t];for(;this.#c>r;)this.#B(!0)}this.#c+=e[t],n&&(n.entrySize=r,n.totalCalculatedSize=this.#c)}}#L=e=>{};#k=(e,t,r)=>{};#C=(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:e=this.allowStale}={}){if(this.#s)for(let t=this.#y;this.#U(t)&&(!e&&this.#I(t)||(yield t),t!==this.#h);)t=this.#f[t]}*#E({allowStale:e=this.allowStale}={}){if(this.#s)for(let t=this.#h;this.#U(t)&&(!e&&this.#I(t)||(yield t),t!==this.#y);)t=this.#p[t]}#U(e){return void 0!==e&&this.#u.get(this.#l[e])===e}*entries(){for(const e of this.#A())void 0===this.#d[e]||void 0===this.#l[e]||this.#S(this.#d[e])||(yield[this.#l[e],this.#d[e]])}*rentries(){for(const e of this.#E())void 0===this.#d[e]||void 0===this.#l[e]||this.#S(this.#d[e])||(yield[this.#l[e],this.#d[e]])}*keys(){for(const e of this.#A()){const t=this.#l[e];void 0===t||this.#S(this.#d[e])||(yield t)}}*rkeys(){for(const e of this.#E()){const t=this.#l[e];void 0===t||this.#S(this.#d[e])||(yield t)}}*values(){for(const e of this.#A()){void 0===this.#d[e]||this.#S(this.#d[e])||(yield this.#d[e])}}*rvalues(){for(const e of this.#E()){void 0===this.#d[e]||this.#S(this.#d[e])||(yield this.#d[e])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const r of this.#A()){const n=this.#d[r],i=this.#S(n)?n.__staleWhileFetching:n;if(void 0!==i&&e(i,this.#l[r],this))return this.get(this.#l[r],t)}}forEach(e,t=this){for(const r of this.#A()){const n=this.#d[r],i=this.#S(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#l[r],this)}}rforEach(e,t=this){for(const r of this.#E()){const n=this.#d[r],i=this.#S(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#l[r],this)}}purgeStale(){let e=!1;for(const t of this.#E({allowStale:!0}))this.#I(t)&&(this.#P(this.#l[t],"expire"),e=!0);return e}info(e){const t=this.#u.get(e);if(void 0===t)return;const r=this.#d[t],n=this.#S(r)?r.__staleWhileFetching:r;if(void 0===n)return;const i={value:n};if(this.#_&&this.#v){const e=this.#_[t],r=this.#v[t];if(e&&r){const t=e-(GS.now()-r);i.ttl=t,i.start=Date.now()}}return this.#b&&(i.size=this.#b[t]),i}dump(){const e=[];for(const t of this.#A({allowStale:!0})){const r=this.#l[t],n=this.#d[t],i=this.#S(n)?n.__staleWhileFetching:n;if(void 0===i||void 0===r)continue;const o={value:i};if(this.#_&&this.#v){o.ttl=this.#_[t];const e=GS.now()-this.#v[t];o.start=Math.floor(Date.now()-e)}this.#b&&(o.size=this.#b[t]),e.unshift([r,o])}return e}load(e){this.clear();for(const[t,r]of e){if(r.start){const e=Date.now()-r.start;r.start=GS.now()-e}this.set(t,r.value,r)}}set(e,t,r={}){if(void 0===t)return this.delete(e),this;const{ttl:n=this.ttl,start:i,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:s}=r;let{noUpdateTTL:c=this.noUpdateTTL}=r;const u=this.#C(e,t,r.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return s&&(s.set="miss",s.maxEntrySizeExceeded=!0),this.#P(e,"set"),this;let l=0===this.#s?void 0:this.#u.get(e);if(void 0===l)l=0===this.#s?this.#y:0!==this.#g.length?this.#g.pop():this.#s===this.#t?this.#B(!1):this.#s,this.#l[l]=e,this.#d[l]=t,this.#u.set(e,l),this.#p[this.#y]=l,this.#f[l]=this.#y,this.#y=l,this.#s++,this.#k(l,u,s),s&&(s.set="add"),c=!1;else{this.#j(l);const r=this.#d[l];if(t!==r){if(this.#T&&this.#S(r)){r.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=r;void 0===t||o||(this.#w&&this.#n?.(t,e,"set"),this.#O&&this.#m?.push([t,e,"set"]))}else o||(this.#w&&this.#n?.(r,e,"set"),this.#O&&this.#m?.push([r,e,"set"]));if(this.#L(l),this.#k(l,u,s),this.#d[l]=t,s){s.set="replace";const e=r&&this.#S(r)?r.__staleWhileFetching:r;void 0!==e&&(s.oldValue=e)}}else s&&(s.set="update")}if(0===n||this.#_||this.#D(),this.#_&&(c||this.#N(l,n,i),s&&this.#M(s,l)),!o&&this.#O&&this.#m){const e=this.#m;let t;for(;t=e?.shift();)this.#i?.(...t)}return this}pop(){try{for(;this.#s;){const e=this.#d[this.#h];if(this.#B(!0),this.#S(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#O&&this.#m){const e=this.#m;let t;for(;t=e?.shift();)this.#i?.(...t)}}}#B(e){const t=this.#h,r=this.#l[t],n=this.#d[t];return this.#T&&this.#S(n)?n.__abortController.abort(new Error("evicted")):(this.#w||this.#O)&&(this.#w&&this.#n?.(n,r,"evict"),this.#O&&this.#m?.push([n,r,"evict"])),this.#L(t),e&&(this.#l[t]=void 0,this.#d[t]=void 0,this.#g.push(t)),1===this.#s?(this.#h=this.#y=0,this.#g.length=0):this.#h=this.#p[t],this.#u.delete(r),this.#s--,t}has(e,t={}){const{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,i=this.#u.get(e);if(void 0!==i){const e=this.#d[i];if(this.#S(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#I(i))return r&&this.#R(i),n&&(n.has="hit",this.#M(n,i)),!0;n&&(n.has="stale",this.#M(n,i))}else n&&(n.has="miss");return!1}peek(e,t={}){const{allowStale:r=this.allowStale}=t,n=this.#u.get(e);if(void 0===n||!r&&this.#I(n))return;const i=this.#d[n];return this.#S(i)?i.__staleWhileFetching:i}#x(e,t,r,n){const i=void 0===t?void 0:this.#d[t];if(this.#S(i))return i;const o=new JS,{signal:a}=r;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});const s={signal:o.signal,options:r,context:n},c=(n,i=!1)=>{const{aborted:a}=o.signal,c=r.ignoreFetchAbort&&void 0!==n;if(r.status&&(a&&!i?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,c&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),a&&!c&&!i)return u(o.signal.reason);const d=l;return this.#d[t]===l&&(void 0===n?d.__staleWhileFetching?this.#d[t]=d.__staleWhileFetching:this.#P(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,n,s.options))),n},u=n=>{const{aborted:i}=o.signal,a=i&&r.allowStaleOnFetchAbort,s=a||r.allowStaleOnFetchRejection,c=s||r.noDeleteOnFetchRejection,u=l;if(this.#d[t]===l){!c||void 0===u.__staleWhileFetching?this.#P(e,"fetch"):a||(this.#d[t]=u.__staleWhileFetching)}if(s)return r.status&&void 0!==u.__staleWhileFetching&&(r.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw n};r.status&&(r.status.fetchDispatched=!0);const l=new Promise((t,n)=>{const a=this.#o?.(e,i,s);a&&a instanceof Promise&&a.then(e=>t(void 0===e?void 0:e),n),o.signal.addEventListener("abort",()=>{r.ignoreFetchAbort&&!r.allowStaleOnFetchAbort||(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))})}).then(c,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),u(e))),d=Object.assign(l,{__abortController:o,__staleWhileFetching:i,__returned:void 0});return void 0===t?(this.set(e,d,{...s.options,status:void 0}),t=this.#u.get(e)):this.#d[t]=d,d}#S(e){if(!this.#T)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof JS}async fetch(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:h,forceRefresh:y=!1,status:g,signal:m}=t;if(!this.#T)return g&&(g.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,status:g});const b={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:a,size:s,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:f,ignoreFetchAbort:p,status:g,signal:m};let v=this.#u.get(e);if(void 0===v){g&&(g.fetch="miss");const t=this.#x(e,v,b,h);return t.__returned=t}{const t=this.#d[v];if(this.#S(t)){const e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const i=this.#I(v);if(!y&&!i)return g&&(g.fetch="hit"),this.#j(v),n&&this.#R(v),g&&this.#M(g,v),t;const o=this.#x(e,v,b,h),a=void 0!==o.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",a&&i&&(g.returnedStale=!0)),a?o.__staleWhileFetching:o.__returned=o}}async forceFetch(e,t={}){const r=await this.fetch(e,t);if(void 0===r)throw new Error("fetch() returned undefined");return r}memo(e,t={}){const r=this.#a;if(!r)throw new Error("no memoMethod provided to constructor");const{context:n,forceRefresh:i,...o}=t,a=this.get(e,o);if(!i&&void 0!==a)return a;const s=r(e,a,{options:o,context:n});return this.set(e,s,o),s}get(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=t,a=this.#u.get(e);if(void 0!==a){const t=this.#d[a],s=this.#S(t);return o&&this.#M(o,a),this.#I(a)?(o&&(o.get="stale"),s?(o&&r&&void 0!==t.__staleWhileFetching&&(o.returnedStale=!0),r?t.__staleWhileFetching:void 0):(i||this.#P(e,"expire"),o&&r&&(o.returnedStale=!0),r?t:void 0)):(o&&(o.get="hit"),s?t.__staleWhileFetching:(this.#j(a),n&&this.#R(a),t))}o&&(o.get="miss")}#$(e,t){this.#f[t]=e,this.#p[e]=t}#j(e){e!==this.#y&&(e===this.#h?this.#h=this.#p[e]:this.#$(this.#f[e],this.#p[e]),this.#$(this.#y,e),this.#y=e)}delete(e){return this.#P(e,"delete")}#P(e,t){let r=!1;if(0!==this.#s){const n=this.#u.get(e);if(void 0!==n)if(r=!0,1===this.#s)this.#q(t);else{this.#L(n);const r=this.#d[n];if(this.#S(r)?r.__abortController.abort(new Error("deleted")):(this.#w||this.#O)&&(this.#w&&this.#n?.(r,e,t),this.#O&&this.#m?.push([r,e,t])),this.#u.delete(e),this.#l[n]=void 0,this.#d[n]=void 0,n===this.#y)this.#y=this.#f[n];else if(n===this.#h)this.#h=this.#p[n];else{const e=this.#f[n];this.#p[e]=this.#p[n];const t=this.#p[n];this.#f[t]=this.#f[n]}this.#s--,this.#g.push(n)}}if(this.#O&&this.#m?.length){const e=this.#m;let t;for(;t=e?.shift();)this.#i?.(...t)}return r}clear(){return this.#q("delete")}#q(e){for(const t of this.#E({allowStale:!0})){const r=this.#d[t];if(this.#S(r))r.__abortController.abort(new Error("deleted"));else{const n=this.#l[t];this.#w&&this.#n?.(r,n,e),this.#O&&this.#m?.push([r,n,e])}}if(this.#u.clear(),this.#d.fill(void 0),this.#l.fill(void 0),this.#_&&this.#v&&(this.#_.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#h=0,this.#y=0,this.#g.length=0,this.#c=0,this.#s=0,this.#O&&this.#m){const e=this.#m;let t;for(;t=e?.shift();)this.#i?.(...t)}}};var rx,nx,ix,ox,ax=o(Object.freeze({__proto__:null,LRUCache:tx}));function sx(){return nx||(nx=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LangStringLiteral=e.TimeLiteral=e.DurationLiteral=e.DateLiteral=e.DayTimeDurationLiteral=e.DateTimeLiteral=e.yearMonthDurationsToMonths=e.toUTCDate=e.toDateTimeRepresentation=e.negateDuration=e.extractRawTimeZone=e.defaultedYearMonthDurationRepresentation=e.defaultedDurationRepresentation=e.defaultedDayTimeDurationRepresentation=e.defaultedDateTimeRepresentation=e.dayTimeDurationsToSeconds=e.isSubTypeOf=e.SparqlOperator=e.TypeAlias=e.TypeURL=e.typedLiteral=e.InvalidArity=e.InvalidLexicalForm=e.ExtensionFunctionError=e.CastError=e.UnboundVariableError=e.NoAggregator=e.InError=e.CoalesceError=e.InvalidArgumentTypes=e.InvalidTimezoneCall=e.IncompatibleLanguageOperation=e.RDFEqualTypeError=e.EmptyAggregateError=e.isExpressionError=e.ExpressionError=e.Builder=e.expressionToVar=e.float=e.decimal=e.langString=e.dateTime=e.integer=e.double=e.string=e.bool=e.declare=e.prepareEvaluatorActionContext=e.OverloadTree=e.TermTransformer=void 0,e.trimToDayTimeDuration=e.trimToYearMonthDuration=e.parseDate=e.parseXSDFloat=e.parseXSDDecimal=e.parseYearMonthDuration=e.parseTime=e.parseDuration=e.parseDayTimeDuration=e.parseDateTime=e.elapsedDuration=e.addDurationToDateTime=e.isNonLexicalLiteral=e.StringLiteral=e.NonLexicalLiteral=e.FloatLiteral=e.IntegerLiteral=e.Literal=e.Existence=e.Aggregate=e.DoubleLiteral=e.DefaultGraph=e.DecimalLiteral=e.BlankNode=e.BooleanLiteral=e.NumericLiteral=e.Variable=e.NamedNode=e.Operator=e.Quad=e.YearMonthDurationLiteral=e.Term=void 0;var t=function(){if(US)return Aw;US=1,Object.defineProperty(Aw,"__esModule",{value:!0}),Aw.TermTransformer=void 0;const e=Ew,t=eS(),r=PS(),n=uS(),i=pS(),o=pS(),a=QS(),s=QS(),c=SS();return Aw.TermTransformer=class{constructor(e){this.superTypeProvider=e}transformRDFTermUnsafe(e){return this.transformTerm({term:e,type:t.Algebra.types.EXPRESSION,expressionType:t.Algebra.expressionTypes.TERM})}transformTerm(t){if(!t.term)throw new i.InvalidExpression(t);switch(t.term.termType){case"Variable":return new r.Variable(e.termToString(t.term));case"Literal":return this.transformLiteral(t.term);case"NamedNode":return new r.NamedNode(t.term.value);case"BlankNode":return new r.BlankNode(t.term.value);case"Quad":return new r.Quad(this.transformRDFTermUnsafe(t.term.subject),this.transformRDFTermUnsafe(t.term.predicate),this.transformRDFTermUnsafe(t.term.object),this.transformRDFTermUnsafe(t.term.graph));case"DefaultGraph":return new r.DefaultGraph}}transformLiteral(e){if(!e.datatype||[null,void 0,""].includes(e.datatype.value))return e.language?new r.LangStringLiteral(e.value,e.language):new r.StringLiteral(e.value);const t=e.datatype.value,i=(0,c.getSuperTypeDict)(t,this.superTypeProvider);try{if(n.TypeURL.XSD_STRING in i)return new r.StringLiteral(e.value,t);if(n.TypeURL.RDF_LANG_STRING in i)return new r.LangStringLiteral(e.value,e.language);if(n.TypeURL.XSD_YEAR_MONTH_DURATION in i)return new r.YearMonthDurationLiteral((0,a.parseYearMonthDuration)(e.value),e.value,t);if(n.TypeURL.XSD_DAY_TIME_DURATION in i)return new r.DayTimeDurationLiteral((0,a.parseDayTimeDuration)(e.value),e.value,t);if(n.TypeURL.XSD_DURATION in i)return new r.DurationLiteral((0,a.parseDuration)(e.value),e.value,t);if(n.TypeURL.XSD_DATE_TIME in i){const n=new Date(e.value);return Number.isNaN(n.getTime())?new r.NonLexicalLiteral(void 0,t,this.superTypeProvider,e.value):new r.DateTimeLiteral((0,a.parseDateTime)(e.value),e.value,t)}if(n.TypeURL.XSD_DATE in i)return new r.DateLiteral((0,a.parseDate)(e.value),e.value,t);if(n.TypeURL.XSD_TIME in i)return new r.TimeLiteral((0,a.parseTime)(e.value),e.value,t);if(n.TypeURL.XSD_BOOLEAN in i)return"true"!==e.value&&"false"!==e.value&&"1"!==e.value&&"0"!==e.value?new r.NonLexicalLiteral(void 0,t,this.superTypeProvider,e.value):new r.BooleanLiteral("true"===e.value||"1"===e.value,e.value);if(n.TypeURL.XSD_DECIMAL in i){const o=s.parseXSDDecimal(e.value);return void 0===o?new r.NonLexicalLiteral(void 0,t,this.superTypeProvider,e.value):n.TypeURL.XSD_INTEGER in i?new r.IntegerLiteral(o,t,e.value):new r.DecimalLiteral(o,t,e.value)}const o=n.TypeURL.XSD_FLOAT in i,c=n.TypeURL.XSD_DOUBLE in i;if(o||c){const n=s.parseXSDFloat(e.value);return void 0===n?new r.NonLexicalLiteral(void 0,t,this.superTypeProvider,e.value):o?new r.FloatLiteral(n,t,e.value):new r.DoubleLiteral(n,t,e.value)}return new r.Literal(e.value,t,e.value)}catch(n){if((0,o.isExpressionError)(n))return new r.NonLexicalLiteral(void 0,t,this.superTypeProvider,e.value);throw n}}},Aw}();Object.defineProperty(e,"TermTransformer",{enumerable:!0,get:function(){return t.TermTransformer}});var r=TS();Object.defineProperty(e,"OverloadTree",{enumerable:!0,get:function(){return r.OverloadTree}});var n=function(){if(rx)return zS;rx=1,Object.defineProperty(zS,"__esModule",{value:!0}),zS.prepareEvaluatorActionContext=void 0;const e=y_,t=ax,r=CS();return zS.prepareEvaluatorActionContext=function(n){let i=n;if(i.has(e.KeysInitQuery.extensionFunctionCreator)&&i.has(e.KeysInitQuery.extensionFunctions))throw new Error("Illegal simultaneous usage of extensionFunctionCreator and extensionFunctions in context");if(i.has(e.KeysInitQuery.extensionFunctionCreator))i=i.set(e.KeysExpressionEvaluator.extensionFunctionCreator,i.get(e.KeysInitQuery.extensionFunctionCreator));else if(i.has(e.KeysInitQuery.extensionFunctions)){const t=i.getSafe(e.KeysInitQuery.extensionFunctions);i=i.set(e.KeysExpressionEvaluator.extensionFunctionCreator,async e=>t[e.value])}else i=i.setDefault(e.KeysExpressionEvaluator.extensionFunctionCreator,async()=>{});return i=i.setDefault(e.KeysExpressionEvaluator.defaultTimeZone,(0,r.extractTimeZone)(i.getSafe(e.KeysInitQuery.queryTimestamp))),i=i.setDefault(e.KeysExpressionEvaluator.superTypeProvider,{cache:new t.LRUCache({max:1e3}),discoverer:()=>"term"}),i},zS}();Object.defineProperty(e,"prepareEvaluatorActionContext",{enumerable:!0,get:function(){return n.prepareEvaluatorActionContext}});var i=OS();Object.defineProperty(e,"declare",{enumerable:!0,get:function(){return i.declare}}),Object.defineProperty(e,"bool",{enumerable:!0,get:function(){return i.bool}}),Object.defineProperty(e,"string",{enumerable:!0,get:function(){return i.string}}),Object.defineProperty(e,"double",{enumerable:!0,get:function(){return i.double}}),Object.defineProperty(e,"integer",{enumerable:!0,get:function(){return i.integer}}),Object.defineProperty(e,"dateTime",{enumerable:!0,get:function(){return i.dateTime}}),Object.defineProperty(e,"langString",{enumerable:!0,get:function(){return i.langString}}),Object.defineProperty(e,"decimal",{enumerable:!0,get:function(){return i.decimal}}),Object.defineProperty(e,"float",{enumerable:!0,get:function(){return i.float}}),Object.defineProperty(e,"expressionToVar",{enumerable:!0,get:function(){return i.expressionToVar}}),Object.defineProperty(e,"Builder",{enumerable:!0,get:function(){return i.Builder}});var o=pS();Object.defineProperty(e,"ExpressionError",{enumerable:!0,get:function(){return o.ExpressionError}}),Object.defineProperty(e,"isExpressionError",{enumerable:!0,get:function(){return o.isExpressionError}}),Object.defineProperty(e,"EmptyAggregateError",{enumerable:!0,get:function(){return o.EmptyAggregateError}}),Object.defineProperty(e,"RDFEqualTypeError",{enumerable:!0,get:function(){return o.RDFEqualTypeError}}),Object.defineProperty(e,"IncompatibleLanguageOperation",{enumerable:!0,get:function(){return o.IncompatibleLanguageOperation}}),Object.defineProperty(e,"InvalidTimezoneCall",{enumerable:!0,get:function(){return o.InvalidTimezoneCall}}),Object.defineProperty(e,"InvalidArgumentTypes",{enumerable:!0,get:function(){return o.InvalidArgumentTypes}}),Object.defineProperty(e,"CoalesceError",{enumerable:!0,get:function(){return o.CoalesceError}}),Object.defineProperty(e,"InError",{enumerable:!0,get:function(){return o.InError}}),Object.defineProperty(e,"NoAggregator",{enumerable:!0,get:function(){return o.NoAggregator}}),Object.defineProperty(e,"UnboundVariableError",{enumerable:!0,get:function(){return o.UnboundVariableError}}),Object.defineProperty(e,"CastError",{enumerable:!0,get:function(){return o.CastError}}),Object.defineProperty(e,"ExtensionFunctionError",{enumerable:!0,get:function(){return o.ExtensionFunctionError}}),Object.defineProperty(e,"InvalidLexicalForm",{enumerable:!0,get:function(){return o.InvalidLexicalForm}}),Object.defineProperty(e,"InvalidArity",{enumerable:!0,get:function(){return o.InvalidArity}});var a=uS();Object.defineProperty(e,"typedLiteral",{enumerable:!0,get:function(){return a.typedLiteral}}),Object.defineProperty(e,"TypeURL",{enumerable:!0,get:function(){return a.TypeURL}}),Object.defineProperty(e,"TypeAlias",{enumerable:!0,get:function(){return a.TypeAlias}}),Object.defineProperty(e,"SparqlOperator",{enumerable:!0,get:function(){return a.SparqlOperator}});var s=SS();Object.defineProperty(e,"isSubTypeOf",{enumerable:!0,get:function(){return s.isSubTypeOf}});var c=CS();Object.defineProperty(e,"dayTimeDurationsToSeconds",{enumerable:!0,get:function(){return c.dayTimeDurationsToSeconds}}),Object.defineProperty(e,"defaultedDateTimeRepresentation",{enumerable:!0,get:function(){return c.defaultedDateTimeRepresentation}}),Object.defineProperty(e,"defaultedDayTimeDurationRepresentation",{enumerable:!0,get:function(){return c.defaultedDayTimeDurationRepresentation}}),Object.defineProperty(e,"defaultedDurationRepresentation",{enumerable:!0,get:function(){return c.defaultedDurationRepresentation}}),Object.defineProperty(e,"defaultedYearMonthDurationRepresentation",{enumerable:!0,get:function(){return c.defaultedYearMonthDurationRepresentation}}),Object.defineProperty(e,"extractRawTimeZone",{enumerable:!0,get:function(){return c.extractRawTimeZone}}),Object.defineProperty(e,"negateDuration",{enumerable:!0,get:function(){return c.negateDuration}}),Object.defineProperty(e,"toDateTimeRepresentation",{enumerable:!0,get:function(){return c.toDateTimeRepresentation}}),Object.defineProperty(e,"toUTCDate",{enumerable:!0,get:function(){return c.toUTCDate}}),Object.defineProperty(e,"yearMonthDurationsToMonths",{enumerable:!0,get:function(){return c.yearMonthDurationsToMonths}});var u=PS();Object.defineProperty(e,"DateTimeLiteral",{enumerable:!0,get:function(){return u.DateTimeLiteral}}),Object.defineProperty(e,"DayTimeDurationLiteral",{enumerable:!0,get:function(){return u.DayTimeDurationLiteral}}),Object.defineProperty(e,"DateLiteral",{enumerable:!0,get:function(){return u.DateLiteral}}),Object.defineProperty(e,"DurationLiteral",{enumerable:!0,get:function(){return u.DurationLiteral}}),Object.defineProperty(e,"TimeLiteral",{enumerable:!0,get:function(){return u.TimeLiteral}}),Object.defineProperty(e,"LangStringLiteral",{enumerable:!0,get:function(){return u.LangStringLiteral}}),Object.defineProperty(e,"Term",{enumerable:!0,get:function(){return u.Term}}),Object.defineProperty(e,"YearMonthDurationLiteral",{enumerable:!0,get:function(){return u.YearMonthDurationLiteral}}),Object.defineProperty(e,"Quad",{enumerable:!0,get:function(){return u.Quad}}),Object.defineProperty(e,"Operator",{enumerable:!0,get:function(){return u.Operator}}),Object.defineProperty(e,"NamedNode",{enumerable:!0,get:function(){return u.NamedNode}}),Object.defineProperty(e,"Variable",{enumerable:!0,get:function(){return u.Variable}}),Object.defineProperty(e,"NumericLiteral",{enumerable:!0,get:function(){return u.NumericLiteral}}),Object.defineProperty(e,"BooleanLiteral",{enumerable:!0,get:function(){return u.BooleanLiteral}}),Object.defineProperty(e,"BlankNode",{enumerable:!0,get:function(){return u.BlankNode}}),Object.defineProperty(e,"DecimalLiteral",{enumerable:!0,get:function(){return u.DecimalLiteral}}),Object.defineProperty(e,"DefaultGraph",{enumerable:!0,get:function(){return u.DefaultGraph}}),Object.defineProperty(e,"DoubleLiteral",{enumerable:!0,get:function(){return u.DoubleLiteral}}),Object.defineProperty(e,"Aggregate",{enumerable:!0,get:function(){return u.Aggregate}}),Object.defineProperty(e,"Existence",{enumerable:!0,get:function(){return u.Existence}}),Object.defineProperty(e,"Literal",{enumerable:!0,get:function(){return u.Literal}}),Object.defineProperty(e,"IntegerLiteral",{enumerable:!0,get:function(){return u.IntegerLiteral}}),Object.defineProperty(e,"FloatLiteral",{enumerable:!0,get:function(){return u.FloatLiteral}}),Object.defineProperty(e,"NonLexicalLiteral",{enumerable:!0,get:function(){return u.NonLexicalLiteral}}),Object.defineProperty(e,"StringLiteral",{enumerable:!0,get:function(){return u.StringLiteral}}),Object.defineProperty(e,"isNonLexicalLiteral",{enumerable:!0,get:function(){return u.isNonLexicalLiteral}});var l=qS();Object.defineProperty(e,"addDurationToDateTime",{enumerable:!0,get:function(){return l.addDurationToDateTime}}),Object.defineProperty(e,"elapsedDuration",{enumerable:!0,get:function(){return l.elapsedDuration}});var d=QS();Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return d.parseDateTime}}),Object.defineProperty(e,"parseDayTimeDuration",{enumerable:!0,get:function(){return d.parseDayTimeDuration}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return d.parseDuration}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return d.parseTime}}),Object.defineProperty(e,"parseYearMonthDuration",{enumerable:!0,get:function(){return d.parseYearMonthDuration}}),Object.defineProperty(e,"parseXSDDecimal",{enumerable:!0,get:function(){return d.parseXSDDecimal}}),Object.defineProperty(e,"parseXSDFloat",{enumerable:!0,get:function(){return d.parseXSDFloat}}),Object.defineProperty(e,"parseDate",{enumerable:!0,get:function(){return d.parseDate}});var p=CS();Object.defineProperty(e,"trimToYearMonthDuration",{enumerable:!0,get:function(){return p.trimToYearMonthDuration}}),Object.defineProperty(e,"trimToDayTimeDuration",{enumerable:!0,get:function(){return p.trimToDayTimeDuration}})}(jw)),jw}function cx(){if(ix)return xw;ix=1,Object.defineProperty(xw,"__esModule",{value:!0}),xw.TermFunctionBase=xw.ExpressionFunctionBase=void 0;const e=y_,t=sx();class r{constructor({arity:e,operator:t,apply:r}){this.arity=e,this.operator=t,this.apply=r}checkArity(e){return Array.isArray(this.arity)?this.arity.includes(e.length):this.arity===Number.POSITIVE_INFINITY||e.length===this.arity}}xw.ExpressionFunctionBase=r;return xw.TermFunctionBase=class extends r{constructor({arity:e,operator:t,overloads:r}){super({arity:e,operator:t,apply:async({args:e,exprEval:t,mapping:r})=>this.applyOnTerms(await Promise.all(e.map(e=>t.evaluatorExpressionEvaluation(e,r))),t)}),this.supportsTermExpressions=!0,this.overloads=r}applyOnTerms(t,r){return(this.overloads.search(t,r.context.getSafe(e.KeysExpressionEvaluator.superTypeProvider),r.context.getSafe(e.KeysInitQuery.functionArgumentsCache))??this.handleInvalidTypes(t))(r)(t)}handleInvalidTypes(e){throw new t.InvalidArgumentTypes(e,this.operator)}},xw}function ux(){return ox||(ox=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(_w(),e),r(function(){if(ww)return Tw;ww=1,Object.defineProperty(Tw,"__esModule",{value:!0}),Tw.ActorFunctionFactoryDedicated=void 0;const e=Oy,t=_w();let r=class extends t.ActorFunctionFactory{constructor(e){super(e)}async test(t){return!this.functionNames.includes(t.functionName)||!this.termFunction&&t.requireTermExpression?(0,e.failTest)(`Actor ${this.name} can not provide implementation for "${t.functionName}", only for ${this.termFunction?"":"non-termExpression "}${this.functionNames.join(" and ")}.`):(0,e.passTestVoid)()}};return Tw.ActorFunctionFactoryDedicated=r,Tw}(),e),r(function(){if(Ow)return Sw;Ow=1,Object.defineProperty(Sw,"__esModule",{value:!0}),Sw.BusFunctionFactory=void 0;const e=Oy;let t=class extends e.BusIndexed{constructor(e){super({...e,actorIdentifierFields:["functionNames"],actionIdentifierFields:["functionName"]})}};return Sw.BusFunctionFactory=t,Sw}(),e),r(cx(),e)}(bw)),bw}var lx,dx={},px={};function fx(){if(lx)return px;lx=1,Object.defineProperty(px,"__esModule",{value:!0}),px.ActorQueryOperation=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return px.ActorQueryOperation=t,px}var hx,yx={},gx={},mx={};var bx,vx,_x,wx={};function Tx(){return vx||(vx=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r((hx||(hx=1,Object.defineProperty(mx,"__esModule",{value:!0}),mx.MetadataValidationState=void 0,mx.MetadataValidationState=class{constructor(){this.invalidateListeners=[],this.valid=!0}addInvalidateListener(e){this.invalidateListeners.push(e)}invalidate(){if(this.valid){this.valid=!1;for(const e of this.invalidateListeners)e()}}}),mx),e),r(function(){if(bx)return wx;function e(e){for(const t of["cardinality"])if(!(t in e))throw new Error(`Invalid metadata: missing ${t} in ${JSON.stringify(e)}`);return e}function t(e){for(const t of["cardinality","variables"])if(!(t in e))throw new Error(`Invalid metadata: missing ${t} in ${JSON.stringify(e)}`);return e}function r(e){let t;return()=>(t||(t=e(),t.then(e=>e.state.addInvalidateListener(()=>{t=void 0})).catch(()=>{})),t)}return bx=1,Object.defineProperty(wx,"__esModule",{value:!0}),wx.cachifyMetadata=wx.validateMetadataBindings=wx.validateMetadataQuads=wx.getMetadataBindings=wx.getMetadataQuads=void 0,wx.getMetadataQuads=function(t){return r(()=>new Promise((e,r)=>{t.getProperty("metadata",t=>e(t)),t.on("error",r)}).then(t=>e(t)))},wx.getMetadataBindings=function(e){return r(()=>new Promise((t,r)=>{e.getProperty("metadata",e=>t(e)),e.on("error",r)}).then(e=>t(e)))},wx.validateMetadataQuads=e,wx.validateMetadataBindings=t,wx.cachifyMetadata=r,wx}(),e)}(gx)),gx}function Ox(){if(_x)return yx;_x=1,Object.defineProperty(yx,"__esModule",{value:!0}),yx.ActorQueryOperationTyped=void 0;const e=y_,t=Oy,r=Tx(),n=fx();let i=class extends n.ActorQueryOperation{constructor(e,t){if(super({...e,operationName:t}),!this.operationName)throw new Error('A valid "operationName" argument must be provided.')}async test(e){if(!e.operation)return(0,t.failTest)("Missing field 'operation' in a query operation action.");if(e.operation.type!==this.operationName)return(0,t.failTest)(`Actor ${this.name} only supports ${this.operationName} operations, but got ${e.operation.type}`);const r=e.operation;return this.testOperation(r,e.context)}async run(t,n){const i=t.context.get(e.KeysInitQuery.physicalQueryPlanLogger);i&&(i.logOperation(t.operation.type,void 0,t.operation,t.context.get(e.KeysInitQuery.physicalQueryPlanNode),this.name,{}),t.context=t.context.set(e.KeysInitQuery.physicalQueryPlanNode,t.operation));const o=t.operation,a=t.context.set(e.KeysQueryOperation.operation,o),s=await this.runOperation(o,a,n);return"metadata"in s&&(s.metadata=(0,r.cachifyMetadata)(s.metadata)),s}};return yx.ActorQueryOperationTyped=i,yx}var Sx,xx={};var jx,Ax,Ex={};function Ix(){return Ax||(Ax=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(fx(),e),r(Ox(),e),r(function(){if(Sx)return xx;Sx=1,Object.defineProperty(xx,"__esModule",{value:!0}),xx.ActorQueryOperationTypedMediated=void 0;const e=Ox();let t=class extends e.ActorQueryOperationTyped{constructor(e,t){super(e,t)}};return xx.ActorQueryOperationTypedMediated=t,xx}(),e),r(function(){if(jx)return Ex;jx=1,Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.BusQueryOperation=void 0;const e=Oy;let t=class extends e.BusIndexed{constructor(e){super({...e,actorIdentifierFields:["operationName"],actionIdentifierFields:["operation","type"]})}};return Ex.BusQueryOperation=t,Ex}(),e)}(dx)),dx}var Fx,Dx,Nx,Px,Rx={},Mx={},Lx={},Cx={};function kx(){return Dx||(Dx=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Fx)return Cx;Fx=1,Object.defineProperty(Cx,"__esModule",{value:!0}),Cx.ActorContextPreprocess=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return Cx.ActorContextPreprocess=t,Cx}(),e)}(Lx)),Lx}function Bx(){return Px||(Px=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Nx)return Mx;Nx=1,Object.defineProperty(Mx,"__esModule",{value:!0}),Mx.ActorContextPreprocessConvertShortcuts=void 0;const e=kx(),t=Oy;let r=class r extends e.ActorContextPreprocess{constructor(e){super(e)}async test(e){return(0,t.passTestVoid)()}async run(e){return{context:r.expandShortcuts(e.context,this.contextKeyShortcuts)}}static expandShortcuts(e,r){for(const n of e.keys())r[n.name]&&(e=e.set(new t.ActionContextKey(r[n.name]),e.get(n)).delete(n));return e}};return Mx.ActorContextPreprocessConvertShortcuts=r,Mx}(),e)}(Rx)),Rx}var Ux,$x,qx={},Qx={};function zx(){return $x||($x=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Ux)return Qx;Ux=1,Object.defineProperty(Qx,"__esModule",{value:!0}),Qx.ActorContextPreprocessSetDefaults=void 0;const e=kx(),t=y_,r=Oy,n=Fw;let i=class extends e.ActorContextPreprocess{constructor(e){super(e),this.defaultFunctionArgumentsCache={}}async test(e){return(0,r.passTestVoid)()}async run(e){let r=e.context;if(e.initialize){r=r.setDefault(t.KeysInitQuery.queryTimestamp,new Date).setDefault(t.KeysInitQuery.queryTimestampHighResolution,performance.now()).setDefault(t.KeysQuerySourceIdentify.sourceIds,new Map).setDefault(t.KeysCore.log,this.logger).setDefault(t.KeysInitQuery.functionArgumentsCache,this.defaultFunctionArgumentsCache).setDefault(t.KeysQuerySourceIdentify.hypermediaSourcesAggregatedStores,new Map).setDefault(t.KeysInitQuery.dataFactory,new n.DataFactory);let e={language:"sparql",version:"1.1"};r.has(t.KeysInitQuery.queryFormat)?(e=r.get(t.KeysInitQuery.queryFormat),"graphql"===e.language&&(r=r.setDefault(t.KeysInitQuery.graphqlSingularizeVariables,{}))):r=r.set(t.KeysInitQuery.queryFormat,e),r.has(t.KeysInitQuery.extensionFunctionsAlwaysPushdown)||r.has(t.KeysInitQuery.extensionFunctions)||(r=r.set(t.KeysInitQuery.extensionFunctionsAlwaysPushdown,!0))}return{context:r}}};return Qx.ActorContextPreprocessSetDefaults=i,Qx}(),e)}(qx)),qx}var Gx,Vx,Xx={},Hx={};function Jx(){return Vx||(Vx=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Gx)return Hx;Gx=1,Object.defineProperty(Hx,"__esModule",{value:!0}),Hx.ActorContextPreprocessSourceToDestination=void 0;const e=kx(),t=y_,r=Oy;let n=class extends e.ActorContextPreprocess{constructor(e){super(e)}async test(e){return(0,r.passTestVoid)()}async run(e){if(e.context.get(t.KeysInitQuery.querySourcesUnidentified)&&!e.context.get(t.KeysRdfUpdateQuads.destination)){const r=e.context.get(t.KeysInitQuery.querySourcesUnidentified);if(1===r.length)return{context:e.context.set(t.KeysRdfUpdateQuads.destination,r[0])}}return e}};return Hx.ActorContextPreprocessSourceToDestination=n,Hx}(),e)}(Xx)),Xx}var Wx,Kx={},Yx={},Zx={},ej={},tj={};var rj={};let nj=1;const ij=new Map;let oj,aj=!1,sj=(e,...t)=>(ij.set(nj,[e,t]),oj(nj),nj++),cj=e=>{ij.delete(e)};function uj(e){if(aj)setTimeout(uj,0,e);else{const t=ij.get(e);if(t){aj=!0;try{t[0](...t[1])}finally{cj(e),aj=!1}}}}const lj="undefined"==typeof self?"undefined"==typeof global?window:global:self;lj.setImmediate?(sj=lj.setImmediate,cj=lj.clearImmediate):lj.importScripts?function(){const e=new MessageChannel;e.port1.onmessage=e=>{uj(e.data)},oj=t=>{e.port2.postMessage(t)}}():function(){const e=`setImmediate$${Math.random()}$`;window.addEventListener("message",t=>{"string"==typeof t.data&&t.data.startsWith(e)&&uj(+t.data.slice(e.length))}),oj=t=>{window.postMessage(e+t,"*")}}();var dj,pj,fj=o(Object.freeze({__proto__:null,get clearImmediate(){return cj},get setImmediate(){return sj}}));function hj(){return pj||(pj=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isIterator=e.isIterable=e.isSourceExpression=e.isPromise=e.isEventEmitter=e.isFunction=e.range=e.union=e.fromIterable=e.fromIterator=e.fromArray=e.single=e.empty=e.wrap=e.WrappingIterator=e.ClonedIterator=e.UnionIterator=e.MultiTransformIterator=e.SimpleTransformIterator=e.TransformIterator=e.BufferedIterator=e.MappingIterator=e.DESTINATION=e.identity=e.IntegerIterator=e.ArrayIterator=e.SingletonIterator=e.EmptyIterator=e.AsyncIterator=e.DESTROYED=e.ENDED=e.CLOSED=e.CLOSING=e.OPEN=e.INIT=e.setTaskScheduler=e.getTaskScheduler=e.scheduleTask=e.LinkedList=void 0;const t=tt,r=(Wx||(Wx=1,Object.defineProperty(tj,"__esModule",{value:!0}),tj.LinkedList=void 0,tj.LinkedList=class{constructor(){this._length=0,this._head=null,this._tail=null}get length(){return this._length}get first(){var e;return null===(e=this._head)||void 0===e?void 0:e.value}get last(){var e;return null===(e=this._tail)||void 0===e?void 0:e.value}get empty(){return null===this._head}push(e){const t={value:e,next:null};null===this._tail?this._head=this._tail=t:this._tail.next=this._tail=t,this._length++}shift(){if(null===this._head)return;const{value:e,next:t}=this._head;return this._head=t,null===t&&(this._tail=null),this._length--,e}clear(){this._length=0,this._head=this._tail=null}}),tj);Object.defineProperty(e,"LinkedList",{enumerable:!0,get:function(){return r.LinkedList}});const n=function(){if(dj)return rj;dj=1,Object.defineProperty(rj,"__esModule",{value:!0}),rj.createTaskScheduler=void 0;const e=fj,t=Promise.resolve(void 0);return rj.createTaskScheduler=function(r=e.setImmediate){const n="function"==typeof queueMicrotask?queueMicrotask:e=>t.then(e);let i=0,o=null;return e=>{null!==o?o.push(e):++i<100?n(e):(o=[e],r(()=>{for(const e of o)n(e);o=null,i=0}))}},rj}();let i=n.createTaskScheduler();e.scheduleTask=function(e){i(e)},e.getTaskScheduler=function(){return i},e.setTaskScheduler=function(e){i=e},e.INIT=1,e.OPEN=2,e.CLOSING=4,e.CLOSED=8,e.ENDED=16,e.DESTROYED=32;class o extends t.EventEmitter{constructor(t=e.OPEN){super(),this._readable=!1,this._state=t,this.on("newListener",a)}_changeState(t,r=!1){const n=t>this._state&&this._statethis.emit("end")):this.emit("end"))),n}read(){return null}forEach(e,t){this.on("data",N(e,t))}close(){this._changeState(e.CLOSED)&&this._endAsync()}destroy(e){this.done||this._destroy(e,t=>{(e=e||t)&&this.emit("error",e),this._end(!0)})}_destroy(e,t){t()}_end(t=!1){this._changeState(t?e.DESTROYED:e.ENDED)&&(this._readable=!1,this.removeAllListeners("readable"),this.removeAllListeners("data"),this.removeAllListeners("end"))}_endAsync(){i(()=>this._end())}get readable(){return this._readable}set readable(e){e=Boolean(e)&&!this.done,this._readable!==e&&(this._readable=e,e&&i(()=>this.emit("readable")))}get closed(){return this._state>=e.CLOSING}get ended(){return this._state===e.ENDED}get destroyed(){return this._state===e.DESTROYED}get done(){return this._state>=e.ENDED}toString(){const e=this._toStringDetails();return`[${this.constructor.name}${e?` ${e}`:""}]`}_toStringDetails(){return""}toArray(e){const t=[],r="number"==typeof(null==e?void 0:e.limit)?e.limit:1/0;return this.ended||r<=0?Promise.resolve(t):new Promise((e,n)=>{const i=()=>e(t),o=a=>{t.push(a),t.length>=r&&(this.removeListener("error",n),this.removeListener("data",o),this.removeListener("end",i),e(t))};this.on("error",n),this.on("data",o),this.on("end",i)})}getProperty(e,t){const r=this._properties;if(!t)return r&&r[e];if(r&&e in r)i(()=>t(r[e]));else{let r;(r=this._propertyCallbacks)||(this._propertyCallbacks=r=Object.create(null)),e in r?r[e].push(t):r[e]=[t]}}setProperty(e,t){(this._properties||(this._properties=Object.create(null)))[e]=t;const r=this._propertyCallbacks||{},n=r[e];if(n){for(e in delete r[e],i(()=>{for(const e of n)e(t)}),r)return;delete this._propertyCallbacks}}getProperties(){const e=this._properties,t={};for(const r in e)t[r]=e[r];return t}setProperties(e){for(const t in e)this.setProperty(t,e[t])}copyProperties(e,t){for(const r of t)e.getProperty(r,e=>this.setProperty(r,e))}transform(e){return new O(this,e)}map(e,t){return new h(this,N(e,t))}filter(e,t){return this.map(function(r){return e.call(t||this,r)?r:null})}uniq(e=f){const t=new Set;return this.filter(function(r){const n=e.call(this,r);return!t.has(n)&&(t.add(n),!0)})}prepend(e){return this.transform({prepend:e})}append(e){return this.transform({append:e})}surround(e,t){return this.transform({prepend:e,append:t})}skip(e){return this.map(t=>e-- >0?null:t)}take(e){return this.transform({limit:e})}range(e,t){return this.transform({offset:e,limit:Math.max(t-e+1,0)})}clone(){return new j(this)}[Symbol.asyncIterator](){const e=this;let t=null,r=null,n=null;function i(){if(null!==t)if(null!==n)o(n);else if(e.done)t({done:!0,value:void 0}),t=r=null,a();else{const n=e.read();null!==n&&(t({done:!1,value:n}),t=r=null)}}function o(e){null!==r?(r(e),t=r=n=null,a()):null===n&&(n=e)}function a(){e.removeListener("readable",i),e.removeListener("end",i),e.removeListener("error",o)}return e.addListener("readable",i),e.addListener("end",i),e.addListener("error",o),{next:()=>new Promise((e,n)=>{t=e,r=n,i()})}}}function a(e){"data"===e&&(this.removeListener("newListener",a),c(this,"readable",s),this.readable&&i(()=>s.call(this)))}function s(){let e;for(;0!==this.listenerCount("data")&&null!==(e=this.read());)this.emit("data",e);0!==this.listenerCount("data")||this.done||(this.removeListener("readable",s),c(this,"newListener",a))}function c(e,t,r){e.listeners(t).includes(r)||e.on(t,r)}e.AsyncIterator=o;class u extends o{constructor(){super(),this._changeState(e.ENDED,!0)}}e.EmptyIterator=u;class l extends o{constructor(e){super(),this._item=e,null===e?this.close():this.readable=!0}read(){const e=this._item;return this._item=null,this.close(),e}_toStringDetails(){return null===this._item?"":`(${this._item})`}}e.SingletonIterator=l;class d extends o{constructor(e=[],{autoStart:t=!0,preserve:r=!0}={}){super();const n=r||!Array.isArray(e)?[...e]:e;this._index=0,this._sourceStarted=!1!==t,this._truncateThreshold=r?-1:64,this._sourceStarted&&0===n.length?this.close():this._buffer=n,this.readable=!0}read(){this._sourceStarted||(this._sourceStarted=!0);let e=null;return this._buffer&&(this._index=t&&this.close(),Promise.resolve(i)}}e.ArrayIterator=d;class p extends o{constructor({start:e=0,step:t=1,end:r}={}){super(),Number.isFinite(e)&&(e=Math.trunc(e)),this._next=e,Number.isFinite(t)&&(t=Math.trunc(t)),this._step=t;const n=t>=0,i=n?1/0:-1/0;Number.isFinite(r)?r=Math.trunc(r):r!==-i&&(r=i),this._last=r,!Number.isFinite(e)||(n?e>r:e=0?n>r:nthis._init(n)),this._sourceStarted=!1!==n}get maxBufferSize(){return this._maxBufferSize}set maxBufferSize(t){t!==1/0&&(t=Number.isFinite(t)?Math.max(Math.trunc(t),1):4),this._maxBufferSize!==t&&(this._maxBufferSize=t,this._state===e.OPEN&&this._fillBuffer())}_init(t){let r=!1;this._reading=!0,this._begin(()=>{if(r)throw new Error("done callback called multiple times");r=!0,this._reading=!1,this._changeState(e.OPEN),t?this._fillBufferAsync():this.readable=!0})}_begin(e){e()}read(){if(this.done)return null;this._sourceStarted||(this._sourceStarted=!0);const e=this._buffer;let t;return e.empty?(t=null,this.readable=!1):t=e.shift(),!this._reading&&e.length0&&(this._pushedCount=0,this._reading=!0,this._read(e,()=>{if(!e)throw new Error("done callback called multiple times");e=0,this._reading=!1,this.closed?this._completeClose():this._pushedCount&&(this.readable=!0,this._buffer.length{this._reading=!1,this._fillBuffer()}))}close(){this._reading?this._changeState(e.CLOSING):this._completeClose()}_completeClose(){this._changeState(e.CLOSED)&&(this._reading=!0,this._flush(()=>{if(!this._reading)throw new Error("done callback called multiple times");this._reading=!1,this._buffer.empty&&this._endAsync()}))}_destroy(e,t){this._buffer.clear(),t()}_flush(e){e()}_toStringDetails(){const e=this._buffer;return`{${e.empty?"":`next: ${e.first}, `}buffer: ${e.length}}`}}e.BufferedIterator=g;class m extends g{constructor(e,t=e||{}){super(t),this._boundPush=e=>this._push(e),L(e)||(e=t.source),R(e)?this.source=e:e&&(this._createSource=M(e)?()=>e:e,this._sourceStarted&&this._loadSourceAsync()),this._optional=Boolean(t.optional),this._destroySource=!1!==t.destroySource}get source(){return P(this._createSource)&&this._loadSourceAsync(),this._source}set source(t){const r=this._source=this._validateSource(t);r[e.DESTINATION]=this,this.done?this._destroySource&&r.destroy():r.done?this.close():(r.on("end",w),r.on("readable",T),r.on("error",v))}_loadSourceAsync(){P(this._createSource)&&(Promise.resolve(this._createSource()).then(e=>{delete this._createSource,this.source=e,this._fillBuffer()},e=>this.emit("error",e)),this._createSource=null)}_validateSource(e,t=!1){if(this._source||void 0!==this._createSource)throw new Error("The source cannot be changed after it has been set");return y(e,t)}_read(e,t){const r=()=>{this._pushedCountthis._readAndTransform(r,t)):t()};this._readAndTransform(r,t)}_readAndTransform(e,t){let r;const n=this.source;!n||n.done||null===(r=n.read())?t():this._optional?this._optionalTransform(r,e):this._transform(r,e,this._boundPush)}_optionalTransform(e,t){const r=this._pushedCount;this._transform(e,()=>{r===this._pushedCount&&this._push(e),t()},this._boundPush)}_transform(e,t,r){r(e),t()}_closeWhenDone(){this.close()}_end(t){const r=this._source;r&&(r.removeListener("end",w),r.removeListener("error",v),r.removeListener("readable",T),delete r[e.DESTINATION],this._destroySource&&r.destroy()),super._end(t)}}function b(){this[e.DESTINATION].readable=!0}function v(t){this[e.DESTINATION].emit("error",t)}function _(){this[e.DESTINATION].close()}function w(){this[e.DESTINATION]._closeWhenDone()}function T(){!1!==this[e.DESTINATION]._sourceStarted&&this[e.DESTINATION]._fillBuffer()}e.TransformIterator=m;class O extends m{constructor(e,t){if(super(e,t),this._offset=0,this._limit=1/0,this._filter=e=>!0,t=t||(L(e)?null:e)){const e=P(t)?t:t.transform,{limit:r,offset:n,filter:i,map:o,prepend:a,append:s}=t;n===1/0||r===-1/0?this._limit=0:(Number.isFinite(n)&&(this._offset=Math.max(Math.trunc(n),0)),Number.isFinite(r)&&(this._limit=Math.max(Math.trunc(r),0)),P(i)&&(this._filter=i),P(o)&&(this._map=o),this._transform=P(e)?e:null),a&&(this._prepender=R(a)?a:D(a)),s&&(this._appender=R(s)?s:D(s))}}_read(e,t){const r=()=>this._readAndTransformSimple(e,n,t);function n(){i(r)}this._readAndTransformSimple(e,n,t)}_readAndTransformSimple(e,t,r){let n;const{source:i}=this;if(i&&!i.done){for(0===this._limit&&this.close();!this.closed&&this._pushedCountthis._push(e);!e||e.done?t():(e.on("data",r),e.on("end",function n(){e.removeListener("data",r),e.removeListener("end",n),t()}))}}e.SimpleTransformIterator=O;e.MultiTransformIterator=class extends m{constructor(e,t){if(super(e,t),this._transformerQueue=[],t){const e=P(t)?t:t.multiTransform;e&&(this._createTransformer=e)}}_read(t,r){const n=this._transformerQueue,i=this._optional;let o,a;for(;(o=n[0])&&o.transformer.done;){i&&null!==o.item&&(t--,this._push(o.item)),n.shift();const{transformer:e}=o;e.removeListener("end",T),e.removeListener("readable",T),e.removeListener("error",v)}const{source:s}=this;for(;s&&!s.done&&n.length0&&null!==(a=e.read());)this._push(a),i&&(o.item=null)}else s&&s.done&&this.close();r()}_createTransformer(e){return new l(e)}_closeWhenDone(){this._transformerQueue.length||this.close()}_end(e){if(super._end(e),this._destroySource)for(const e of this._transformerQueue)e.transformer.destroy()}};class S extends g{constructor(e,t={}){super(t),this._sources=[],this._currentSource=-1;const r=!1!==t.autoStart;if(R(e))e.on("error",e=>this.emit("error",e)),this._pending={loading:!1,sources:e},r&&this._loadSources();else if(Array.isArray(e)&&e.length>0)for(const t of e)this._addSource(t);else r&&this.close();this._destroySources=!1!==t.destroySources}_loadSources(){const e=this._pending.sources;this._pending.loading=!0,e.done?(delete this._pending,this.close()):(e.on("data",e=>{this._addSource(e),this._fillBufferAsync()}),e.on("end",()=>{delete this._pending,this._fillBuffer()}))}_addSource(t){M(t)&&(t=I(t)),t.done||(this._sources.push(t),t[e.DESTINATION]=this,t.on("error",v),t.on("readable",T),t.on("end",x))}_removeEmptySources(){this._sources=this._sources.filter((e,t)=>(e.done&&t<=this._currentSource&&this._currentSource--,!e.done)),this._fillBuffer()}_read(e,t){var r;!1===(null===(r=this._pending)||void 0===r?void 0:r.loading)&&this._loadSources();let n,i=0;for(;i!==(i=e);)for(let t=0;t0;t++){this._currentSource=(this._currentSource+1)%this._sources.length;null!==(n=this._sources[this._currentSource].read())&&(e--,this._push(n))}this._pending||0!==this._sources.length||this.close(),t()}_end(e=!1){if(super._end(e),this._destroySources){for(const e of this._sources)e.destroy();this._pending&&(this._pending.sources.destroy(),delete this._pending)}}}function x(){this[e.DESTINATION]._removeEmptySources()}e.UnionIterator=S;class j extends m{constructor(e){super(e,{autoStart:!1}),this._readPosition=0,this._reading=!1,e&&(this.readable=!0)}_init(){}close(){o.prototype.close.call(this)}get source(){return super.source}set source(t){const r=this._source=this._validateSource(t),n=r&&r[e.DESTINATION]||(r[e.DESTINATION]=new A(r));this.done?this._destroySource&&r.destroy():n.endsAt(0)?this.close():(n.register(this),!1!==r._sourceStarted&&null===n.readAt(0)||(this.readable=!0));const i=this._propertyCallbacks;for(const e in i){const t=i[e];for(const r of t)this._getSourceProperty(e,r)}}_validateSource(t,r=!1){const n=t&&t[e.DESTINATION];return super._validateSource(t,!n||n instanceof A)}getProperty(e,t){const{source:r}=this,n=this._properties,i=n&&e in n;if(!t)return i?n&&n[e]:r&&r.getProperty(e);super.getProperty(e,t),r&&!i&&this._getSourceProperty(e,t)}_getSourceProperty(e,t){this.source.getProperty(e,r=>{this._properties&&e in this._properties||t(r)})}getProperties(){const e=this.source?this.source.getProperties():{},t=this._properties;for(const r in t)e[r]=t[r];return e}_toStringDetails(){return`{source: ${this.source?this.source.toString():"none"}}`}read(){this._sourceStarted||(this._sourceStarted=!0);const t=this.source;let r=null;if(!this.done&&t){const n=t[e.DESTINATION];null!==(r=n.readAt(this._readPosition))?this._readPosition++:this.readable=!1,n.endsAt(this._readPosition)&&this.close()}return r}_end(t){const r=this.source,n=null==r?void 0:r[e.DESTINATION];n&&n.unregister(this),g.prototype._end.call(this,t)}}e.ClonedIterator=j;class A{constructor(e){if(this._history=[],this._trackers=new Set,this._source=e,!e.done){const t=()=>{for(const e of this._trackers)e.readable=!0},r=e=>{for(const t of this._trackers)t.emit("error",e)},n=()=>{for(const e of this._trackers)!1!==e._sourceStarted&&e._readPosition===this._history.length&&e.close();this._trackers.clear(),e.removeListener("end",n),e.removeListener("error",r),e.removeListener("readable",t)};e.on("end",n),e.on("error",r),e.on("readable",t)}}register(e){this._source.done||this._trackers.add(e)}unregister(e){this._trackers.delete(e)}readAt(e){let t=null;return e{this._source=null,this.source=e}).catch(e=>this.emit("error",e))):e&&(this.source=e)}set source(r){let n=r;if(null!==this._source)throw new Error("The source cannot be changed after it has been set");if(C(n)&&(n=n[Symbol.iterator]()),k(n)){let e=n;n=new t.EventEmitter,n.read=()=>{if(null!==e){let t;for(;!(t=e.next()).done;)if(null!==t.value)return t.value;e=null,this.close()}return null}}else n=y(n);this.done?this._destroySource&&P(n.destroy)&&n.destroy():(n[e.DESTINATION]=this,n.on("end",_),n.on("error",v),n.on("readable",b),this._source=n,this.readable=!1!==n.readable)}read(){if(null!==this._source&&!1!==this._source.readable){const e=this._source.read();if(null!==e)return e;this.readable=!1}return null}_end(t=!1){null!==this._source&&(this._source.removeListener("end",_),this._source.removeListener("error",v),this._source.removeListener("readable",b),delete this._source[e.DESTINATION],this._destroySource&&P(this._source.destroy)&&this._source.destroy(),this._source=null),super._end(t)}}function I(e,t){if(t&&("autoStart"in t||"optional"in t||"source"in t||"maxBufferSize"in t))return e&&!R(e)&&(e=new E(e)),new m(e,t);if(!e)return F();if(M(e))return new E(e,t);if(e instanceof o)return e;if(Array.isArray(e))return D(e);if(C(e)||k(e)||R(e))return new E(e,t);throw new TypeError(`Invalid source: ${e}`)}function F(){return new u}function D(e){return new d(e)}function N(e,t){return t?e.bind(t):e}function P(e){return"function"==typeof e}function R(e){return P(null==e?void 0:e.on)}function M(e){return P(null==e?void 0:e.then)}function L(e){return e&&(R(e)||M(e)||P(e))}function C(e){return e&&Symbol.iterator in e}function k(e){return P(null==e?void 0:e.next)}e.WrappingIterator=E,e.wrap=I,e.empty=F,e.single=function(e){return new l(e)},e.fromArray=D,e.fromIterator=function(e){return new E(e)},e.fromIterable=function(e){return new E(e)},e.union=function(e){return new S(e)},e.range=function(e,t,r){return new p({start:e,end:t,step:r})},e.isFunction=P,e.isEventEmitter=R,e.isPromise=M,e.isSourceExpression=L,e.isIterable=C,e.isIterator=k}(ej)),ej}var yj,gj={},mj={},bj={};var vj,_j,wj={};function Tj(){return _j||(_j=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r((yj||(yj=1,Object.defineProperty(bj,"__esModule",{value:!0}),bj.BlankNodeScoped=void 0,bj.BlankNodeScoped=class{constructor(e,t){this.termType="BlankNode",this.value=e,this.skolemized=t}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}}),bj),e),r((vj||(vj=1,Object.defineProperty(wj,"__esModule",{value:!0}),wj.BlankNodeBindingsScoped=void 0,wj.BlankNodeBindingsScoped=class{constructor(e){this.termType="BlankNode",this.singleBindingsScope=!0,this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}}),wj),e)}(mj)),mj}var Oj,Sj={},xj={};function jj(){if(Oj)return xj;Oj=1,Object.defineProperty(xj,"__esModule",{value:!0}),xj.matchPatternMappings=xj.matchPatternComplete=xj.matchPattern=xj.matchTerm=xj.getValueNestedPath=xj.someTermsNested=xj.someTerms=xj.everyTermsNested=xj.everyTerms=xj.reduceTermsNested=xj.reduceTerms=xj.mapTermsNested=xj.mapTerms=xj.filterQuadTermNamesNested=xj.filterQuadTermNames=xj.filterTermsNested=xj.filterTerms=xj.forEachTermsNested=xj.forEachTerms=xj.collectNamedTerms=xj.getNamedTerms=xj.getTermsNested=xj.getTerms=xj.TRIPLE_TERM_NAMES=xj.QUAD_TERM_NAMES=void 0;const e=new Fw.DataFactory;function t(e,t){return t&&"DefaultGraph"===e.graph.termType?[e.subject,e.predicate,e.object]:[e.subject,e.predicate,e.object,e.graph]}function r(e,t){return t(e.subject,"subject")&&t(e.predicate,"predicate")&&t(e.object,"object")&&t(e.graph,"graph")}function n(e,t){return!t||"Variable"===t.termType||"Quad"===t.termType&&"Quad"===e.termType&&o(e,t)||t.equals(e)}function i(e,t,r,i,o){return n(e.subject,t)&&n(e.predicate,r)&&n(e.object,i)&&n(e.graph,o)}function o(e,t){return i(e,t.subject,t.predicate,t.object,t.graph)}return xj.QUAD_TERM_NAMES=["subject","predicate","object","graph"],xj.TRIPLE_TERM_NAMES=["subject","predicate","object"],xj.getTerms=t,xj.getTermsNested=function e(r,n){const i=[];for(const o of t(r,n))"Quad"===o.termType?e(o,n).forEach(e=>i.push(e)):i.push(o);return i},xj.getNamedTerms=function(e){return[{key:"subject",value:e.subject},{key:"predicate",value:e.predicate},{key:"object",value:e.object},{key:"graph",value:e.graph}]},xj.collectNamedTerms=function(t,r,n){const i={};return t.forEach(e=>i[e.key]=e.value),r&&(i.subject=i.subject||r("subject"),i.predicate=i.predicate||r("predicate"),i.object=i.object||r("object"),i.graph=i.graph||r("graph")),(n||e).quad(i.subject,i.predicate,i.object,i.graph)},xj.forEachTerms=function(e,t){t(e.subject,"subject"),t(e.predicate,"predicate"),t(e.object,"object"),t(e.graph,"graph")},xj.forEachTermsNested=function e(t,r,n=[]){"Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]),"Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]),"Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]),"Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"])},xj.filterTerms=function(e,t){const r=[];return t(e.subject,"subject")&&r.push(e.subject),t(e.predicate,"predicate")&&r.push(e.predicate),t(e.object,"object")&&r.push(e.object),t(e.graph,"graph")&&r.push(e.graph),r},xj.filterTermsNested=function e(t,r,n=[]){let i=[];return"Quad"===t.subject.termType?i=[...i,...e(t.subject,r,[...n,"subject"])]:r(t.subject,[...n,"subject"])&&i.push(t.subject),"Quad"===t.predicate.termType?i=[...i,...e(t.predicate,r,[...n,"predicate"])]:r(t.predicate,[...n,"predicate"])&&i.push(t.predicate),"Quad"===t.object.termType?i=[...i,...e(t.object,r,[...n,"object"])]:r(t.object,[...n,"object"])&&i.push(t.object),"Quad"===t.graph.termType?i=[...i,...e(t.graph,r,[...n,"graph"])]:r(t.graph,[...n,"graph"])&&i.push(t.graph),i},xj.filterQuadTermNames=function(e,t){const r=[];return t(e.subject,"subject")&&r.push("subject"),t(e.predicate,"predicate")&&r.push("predicate"),t(e.object,"object")&&r.push("object"),t(e.graph,"graph")&&r.push("graph"),r},xj.filterQuadTermNamesNested=function e(t,r,n=[]){let i=[];const o=[...n,"subject"];"Quad"===t.subject.termType?i=[...i,...e(t.subject,r,o)]:r(t.subject,o)&&i.push(o);const a=[...n,"predicate"];"Quad"===t.predicate.termType?i=[...i,...e(t.predicate,r,a)]:r(t.predicate,a)&&i.push(a);const s=[...n,"object"];"Quad"===t.object.termType?i=[...i,...e(t.object,r,s)]:r(t.object,s)&&i.push(s);const c=[...n,"graph"];return"Quad"===t.graph.termType?i=[...i,...e(t.graph,r,c)]:r(t.graph,c)&&i.push(c),i},xj.mapTerms=function(t,r,n){return(n||e).quad(r(t.subject,"subject"),r(t.predicate,"predicate"),r(t.object,"object"),r(t.graph,"graph"))},xj.mapTermsNested=function t(r,n,i,o=[]){return(i||e).quad("Quad"===r.subject.termType?t(r.subject,n,i,[...o,"subject"]):n(r.subject,[...o,"subject"]),"Quad"===r.predicate.termType?t(r.predicate,n,i,[...o,"predicate"]):n(r.predicate,[...o,"predicate"]),"Quad"===r.object.termType?t(r.object,n,i,[...o,"object"]):n(r.object,[...o,"object"]),"Quad"===r.graph.termType?t(r.graph,n,i,[...o,"graph"]):n(r.graph,[...o,"graph"]))},xj.reduceTerms=function(e,t,r){let n=r;return n=t(n,e.subject,"subject"),n=t(n,e.predicate,"predicate"),n=t(n,e.object,"object"),t(n,e.graph,"graph")},xj.reduceTermsNested=function e(t,r,n,i=[]){let o=n;return o="Quad"===t.subject.termType?e(t.subject,r,o,[...i,"subject"]):r(o,t.subject,[...i,"subject"]),o="Quad"===t.predicate.termType?e(t.predicate,r,o,[...i,"predicate"]):r(o,t.predicate,[...i,"predicate"]),o="Quad"===t.object.termType?e(t.object,r,o,[...i,"object"]):r(o,t.object,[...i,"object"]),o="Quad"===t.graph.termType?e(t.graph,r,o,[...i,"graph"]):r(o,t.graph,[...i,"graph"]),o},xj.everyTerms=r,xj.everyTermsNested=function e(t,r,n=[]){return("Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]))&&("Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]))&&("Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]))&&("Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"]))},xj.someTerms=function(e,t){return t(e.subject,"subject")||t(e.predicate,"predicate")||t(e.object,"object")||t(e.graph,"graph")},xj.someTermsNested=function e(t,r,n=[]){return("Quad"===t.subject.termType?e(t.subject,r,[...n,"subject"]):r(t.subject,[...n,"subject"]))||("Quad"===t.predicate.termType?e(t.predicate,r,[...n,"predicate"]):r(t.predicate,[...n,"predicate"]))||("Quad"===t.object.termType?e(t.object,r,[...n,"object"]):r(t.object,[...n,"object"]))||("Quad"===t.graph.termType?e(t.graph,r,[...n,"graph"]):r(t.graph,[...n,"graph"]))},xj.getValueNestedPath=function e(t,r){if(0===r.length)return t;if("Quad"===t.termType)return e(t[r[0]],r.slice(1));throw new Error(`Tried to get ${r[0]} from term of type ${t.termType}`)},xj.matchTerm=n,xj.matchPattern=i,xj.matchPatternComplete=o,xj.matchPatternMappings=function(e,t,n={}){const i={};return function e(t,o){return r(t,(t,r)=>{var a,s;const c=o[r];switch(t.termType){case"Variable":return n.skipVarMapping&&"Variable"===c.termType||(null!==(s=null===(a=i[t.value])||void 0===a?void 0:a.equals(c))&&void 0!==s?s:(i[t.value]=c,!0));case"Quad":return"Quad"===c.termType&&e(t,c);default:return t.equals(c)}})}(t,e)&&(!n.returnMappings||i)},xj}var Aj,Ej,Ij,Fj,Dj,Nj,Pj={};function Rj(){return Ej||(Ej=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(jj(),e),r(function(){if(Aj)return Pj;Aj=1,Object.defineProperty(Pj,"__esModule",{value:!0}),Pj.getQuads=Pj.getDefaultGraphs=Pj.getVariables=Pj.getLiterals=Pj.getBlankNodes=Pj.getNamedNodes=Pj.getTermsOfType=Pj.uniqTerms=Pj.TERM_TYPES=void 0;const e=Ew;function t(e,t){return e.filter(e=>e.termType===t)}return Pj.TERM_TYPES=["NamedNode","BlankNode","Literal","Variable","DefaultGraph","Quad"],Pj.uniqTerms=function(t){const r={};return t.filter(t=>{const n=(0,e.termToString)(t);return!(n in r)&&(r[n]=!0)})},Pj.getTermsOfType=t,Pj.getNamedNodes=function(e){return t(e,"NamedNode")},Pj.getBlankNodes=function(e){return t(e,"BlankNode")},Pj.getLiterals=function(e){return t(e,"Literal")},Pj.getVariables=function(e){return t(e,"Variable")},Pj.getDefaultGraphs=function(e){return t(e,"DefaultGraph")},Pj.getQuads=function(e){return t(e,"Quad")},Pj}(),e)}(Sj)),Sj}function Mj(){return Ij||(Ij=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.deskolemizeOperation=e.deskolemizeQuad=e.deskolemizeTermNestedThrowing=e.deskolemizeTerm=e.skolemizeBindingsStream=e.skolemizeQuadStream=e.skolemizeBindings=e.skolemizeQuad=e.skolemizeTerm=e.getSourceId=e.SKOLEM_PREFIX=void 0;const t=Tj(),r=Rj(),n=eS();function i(r,n,i){return"BlankNode"===n.termType?new t.BlankNodeScoped(`bc_${i}_${n.value}`,r.namedNode(`${e.SKOLEM_PREFIX}${i}:${n.value}`)):n}function o(e,t,n){return(0,r.mapTermsNested)(t,t=>i(e,t,n))}function a(e,t,r){return t.map(t=>"Quad"===t.termType?o(e,t,r):i(e,t,r))}function s(t,r,n){if("BlankNode"===r.termType&&"skolemized"in r&&(r=r.skolemized),"NamedNode"===r.termType&&r.value.startsWith(e.SKOLEM_PREFIX)){const i=r.value.indexOf(":",e.SKOLEM_PREFIX.length);if(r.value.slice(e.SKOLEM_PREFIX.length,i)===n){const e=r.value.slice(i+1,r.value.length);return t.blankNode(e)}return null}return r}function c(e,t,n){if("Quad"===t.termType)return(0,r.mapTermsNested)(t,t=>{const r=s(e,t,n);if(!r)throw new Error("Skolemized term is not in scope for this source");return r});const i=s(e,t,n);if(null===i)throw new Error("Skolemized term is not in scope for this source");return i}e.SKOLEM_PREFIX="urn:comunica_skolem:source_",e.getSourceId=function(e,t){let r=e.get(t.referenceValue);return void 0===r&&(r=`${e.size}`,e.set(t.referenceValue,r)),r},e.skolemizeTerm=i,e.skolemizeQuad=o,e.skolemizeBindings=a,e.skolemizeQuadStream=function(e,t,r){const n=t.map(t=>o(e,t,r));return function e(){t.getProperty("metadata",t=>{n.setProperty("metadata",t),t.state.addInvalidateListener(e)})}(),n},e.skolemizeBindingsStream=function(e,t,r){const n=t.map(t=>a(e,t,r));return function e(){t.getProperty("metadata",t=>{n.setProperty("metadata",t),t.state.addInvalidateListener(e)})}(),n},e.deskolemizeTerm=s,e.deskolemizeTermNestedThrowing=c,e.deskolemizeQuad=function(e,t,n){return(0,r.mapTermsNested)(t,t=>s(e,t,n)??t)},e.deskolemizeOperation=function(e,t,r){const i=new n.Factory;try{return n.Util.mapOperation(t,{[n.Algebra.types.PATTERN]:(t,n)=>({result:Object.assign(n.createPattern(c(e,t.subject,r),c(e,t.predicate,r),c(e,t.object,r),c(e,t.graph,r)),{metadata:t.metadata}),recurse:!1}),[n.Algebra.types.PATH]:(t,n)=>({result:Object.assign(n.createPath(c(e,t.subject,r),t.predicate,c(e,t.object,r),c(e,t.graph,r)),{metadata:t.metadata}),recurse:!1})},i)}catch{}}}(gj)),gj}function Lj(){if(Fj)return Zx;Fj=1,Object.defineProperty(Zx,"__esModule",{value:!0}),Zx.QuerySourceSkolemized=void 0;const e=y_,t=Tx(),r=hj(),n=Mj();return Zx.QuerySourceSkolemized=class{constructor(e,t){this.innerSource=e,this.sourceId=t}async getSelectorShape(e){return this.innerSource.getSelectorShape(e)}queryBindings(i,o,a){const s=o.getSafe(e.KeysInitQuery.dataFactory),c=(0,n.deskolemizeOperation)(s,i,this.sourceId);if(!c){const e=new r.ArrayIterator([],{autoStart:!1});return e.setProperty("metadata",{state:new t.MetadataValidationState,cardinality:{type:"exact",value:0},variables:[]}),e}return(0,n.skolemizeBindingsStream)(s,this.innerSource.queryBindings(c,o,a),this.sourceId)}queryBoolean(e,t){return this.innerSource.queryBoolean(e,t)}queryQuads(i,o){const a=o.getSafe(e.KeysInitQuery.dataFactory),s=(0,n.deskolemizeOperation)(a,i,this.sourceId);if(!s){const e=new r.ArrayIterator([],{autoStart:!1});return e.setProperty("metadata",{state:new t.MetadataValidationState,cardinality:{type:"exact",value:0}}),e}return(0,n.skolemizeQuadStream)(a,this.innerSource.queryQuads(s,o),this.sourceId)}queryVoid(e,t){return this.innerSource.queryVoid(e,t)}get referenceValue(){return this.innerSource.referenceValue}toString(){return`${this.innerSource.toString()}(SkolemID:${this.sourceId})`}},Zx}function Cj(){return Nj||(Nj=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Dj)return Yx;Dj=1,Object.defineProperty(Yx,"__esModule",{value:!0}),Yx.ActorContextPreprocessQuerySourceSkolemize=void 0;const e=kx(),t=y_,r=Oy,n=Lj(),i=Mj();let o=class extends e.ActorContextPreprocess{constructor(e){super(e)}async test(e){return(0,r.passTestVoid)()}async run(e){let r=e.context;if(r.has(t.KeysQueryOperation.querySources)){r.has(t.KeysQuerySourceIdentify.sourceIds)||(r=r.set(t.KeysQuerySourceIdentify.sourceIds,new Map));const e=r.getSafe(t.KeysQuerySourceIdentify.sourceIds);let o=r.getSafe(t.KeysQueryOperation.querySources);o=o.map(t=>({source:new n.QuerySourceSkolemized(t.source,(0,i.getSourceId)(e,t.source)),context:t.context})),r=r.set(t.KeysQueryOperation.querySources,o)}return{context:r}}};return Yx.ActorContextPreprocessQuerySourceSkolemize=o,Yx}(),e),r(Lj(),e),r(Mj(),e)}(Kx)),Kx}var kj,Bj,Uj={},$j={};function qj(){return Bj||(Bj=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(kj)return $j;kj=1,Object.defineProperty($j,"__esModule",{value:!0}),$j.MediatorCombinePipeline=void 0;const e=Oy;let t=class extends e.Mediator{constructor(e){super(e)}async mediate(e){let t;try{t=this.publish(e)}catch{return e}if(this.filterFailures){const e=[];for(const r of t)(await r.reply).isPassed()&&e.push(r);t=e}const r=[];if(t=await Promise.all(t.map(async({actor:t,reply:n},i)=>{try{const e=await n,o=e.getOrThrow();return r[i]=e.getSideData(),{actor:t,reply:o}}catch(t){throw new Error(this.constructFailureMessage(e,[t.message]))}})),this.order){const e=e=>{const t=this.field?e[this.field]:e;if("number"!=typeof t)throw new TypeError("Cannot order elements that are not numbers.");return t};t=t.sort((t,r)=>("increasing"===this.order?1:-1)*(e(t.reply)-e(r.reply)))}let n=e,i=0;for(const{actor:e}of t)n={...n,...await e.runObservable(n,r[i++])};return n}mediateWith(){throw new Error("Method not supported.")}};return $j.MediatorCombinePipeline=t,$j}(),e)}(Uj)),Uj}var Qj,zj,Gj,Vj,Xj={},Hj={},Jj={},Wj={};function Kj(){return zj||(zj=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Qj)return Wj;Qj=1,Object.defineProperty(Wj,"__esModule",{value:!0}),Wj.ActorHashBindings=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return Wj.ActorHashBindings=t,Wj}(),e)}(Jj)),Jj}function Yj(){return Vj||(Vj=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Gj)return Hj;Gj=1,Object.defineProperty(Hj,"__esModule",{value:!0}),Hj.ActorHashBindingsMurmur=void 0;const e=Kj(),t=Oy,r=KO();let n=class extends e.ActorHashBindings{async test(e){return(0,t.passTestVoid)()}async run(e){return{hashFunction:(e,t)=>{let n=r();for(const r of t)n=n.hash(e.get(r)?.value??"UNDEF");return n.result()}}}};return Hj.ActorHashBindingsMurmur=n,Hj}(),e)}(Xj)),Xj}var Zj,eA,tA={},rA={};function nA(){return eA||(eA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(Zj)return rA;Zj=1,Object.defineProperty(rA,"__esModule",{value:!0}),rA.MediatorRace=void 0;const e=Oy;let t=class extends e.Mediator{constructor(e){super(e)}mediateWith(t,r){return new Promise((n,i)=>{const o=[];for(const a of r)a.reply.then(i=>{i.isPassed()?n((0,e.passTestWithSideData)(a.actor,i.getSideData())):(o.push(i.getFailMessage()),o.length===r.length&&n((0,e.failTest)(this.constructFailureMessage(t,o))))}).catch(e=>{i(e)})})}};return rA.MediatorRace=t,rA}(),e)}(tA)),tA}var iA,oA,aA,sA,cA={},uA={},lA={},dA={};function pA(){return oA||(oA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(iA)return dA;iA=1,Object.defineProperty(dA,"__esModule",{value:!0}),dA.ActorHashQuads=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return dA.ActorHashQuads=t,dA}(),e)}(lA)),lA}function fA(){return sA||(sA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(aA)return uA;aA=1,Object.defineProperty(uA,"__esModule",{value:!0}),uA.ActorHashQuadsMurmur=void 0;const e=pA(),t=Oy,r=KO();let n=class extends e.ActorHashQuads{async test(e){return(0,t.passTestVoid)()}async run(e){return{hashFunction:e=>{const t=r(e.subject.value);return t.hash(e.predicate.value),t.hash(e.object.value),t.hash(e.graph.value),t.result()}}}};return uA.ActorHashQuadsMurmur=n,uA}(),e)}(cA)),cA}var hA,yA,gA,mA,bA={},vA={},_A={},wA={};function TA(){return yA||(yA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(hA)return wA;hA=1,Object.defineProperty(wA,"__esModule",{value:!0}),wA.ActorOptimizeQueryOperation=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return wA.ActorOptimizeQueryOperation=t,wA}(),e)}(_A)),_A}function OA(){return mA||(mA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(gA)return vA;gA=1,Object.defineProperty(vA,"__esModule",{value:!0}),vA.ActorOptimizeQueryOperationRewriteCopy=void 0;const e=TA(),t=y_,r=Oy,n=eS();let i=class extends e.ActorOptimizeQueryOperation{constructor(e){super(e)}async test(e){return(0,r.passTestVoid)()}async run(e){const r=e.context.getSafe(t.KeysInitQuery.dataFactory),i=new n.Factory(r),o=n.Util.mapOperation(e.operation,{[n.Algebra.types.COPY](e,t){let r;return r="string"==typeof e.destination&&"string"==typeof e.source&&e.destination===e.source||"string"!=typeof e.destination&&"string"!=typeof e.source&&e.destination.equals(e.source)?t.createCompositeUpdate([]):t.createCompositeUpdate([t.createDrop(e.destination,!0),t.createAdd(e.source,e.destination,e.silent)]),{result:r,recurse:!1}}},i);return{operation:o,context:e.context}}};return vA.ActorOptimizeQueryOperationRewriteCopy=i,vA}(),e)}(bA)),bA}var SA,xA,jA={},AA={};function EA(){return xA||(xA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(SA)return AA;SA=1,Object.defineProperty(AA,"__esModule",{value:!0}),AA.ActorOptimizeQueryOperationRewriteMove=void 0;const e=TA(),t=y_,r=Oy,n=eS();let i=class extends e.ActorOptimizeQueryOperation{constructor(e){super(e)}async test(e){return(0,r.passTestVoid)()}async run(e){const r=e.context.getSafe(t.KeysInitQuery.dataFactory),i=new n.Factory(r),o=n.Util.mapOperation(e.operation,{[n.Algebra.types.MOVE](e,t){let r;if("string"==typeof e.destination&&"string"==typeof e.source&&e.destination===e.source||"string"!=typeof e.destination&&"string"!=typeof e.source&&e.destination.equals(e.source))r=t.createCompositeUpdate([]);else{const n=[t.createDrop(e.destination,!0),t.createAdd(e.source,e.destination,e.silent),t.createDrop(e.source)];r=t.createCompositeUpdate(n)}return{result:r,recurse:!1}}},i);return{operation:o,context:e.context}}};return AA.ActorOptimizeQueryOperationRewriteMove=i,AA}(),e)}(jA)),jA}var IA,FA,DA={},NA={};function PA(){return FA||(FA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(IA)return NA;IA=1,Object.defineProperty(NA,"__esModule",{value:!0}),NA.ActorOptimizeQueryOperationRewriteAdd=void 0;const e=TA(),t=y_,r=Oy,n=Fw,i=eS(),o=new n.DataFactory;let a=class extends e.ActorOptimizeQueryOperation{constructor(e){super(e)}async test(e){return(0,r.passTestVoid)()}async run(e){const r=e.context.getSafe(t.KeysInitQuery.dataFactory),n=new i.Factory(r),a=i.Util.mapOperation(e.operation,{[i.Algebra.types.ADD](e,t){const r="DEFAULT"===e.destination?o.defaultGraph():e.destination,n="DEFAULT"===e.source?o.defaultGraph():e.source;return{result:t.createDeleteInsert(void 0,[t.createPattern(o.variable("s"),o.variable("p"),o.variable("o"),r)],t.createPattern(o.variable("s"),o.variable("p"),o.variable("o"),n)),recurse:!1}}},n);return{operation:a,context:e.context}}};return NA.ActorOptimizeQueryOperationRewriteAdd=a,NA}(),e)}(DA)),DA}var RA,MA={},LA={},CA={},kA={};var BA,UA={};var $A,qA={};var QA,zA={};var GA,VA,XA,HA,JA={};function WA(){return VA||(VA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(RA)return kA;RA=1,Object.defineProperty(kA,"__esModule",{value:!0}),kA.estimateNpsCardinality=kA.estimateJoinCardinality=kA.estimateUnionCardinality=kA.estimateSliceCardinality=kA.estimateMinusCardinality=kA.estimateCardinality=void 0;const e=Fw,t=eS(),r=new e.DataFactory,n=new t.Factory(r);function i(e,l){const d=l.getCardinality(e);if(d)return d;switch(e.type){case t.Algebra.types.ASK:return{type:"exact",value:1,dataset:l.uri};case t.Algebra.types.LOAD:case t.Algebra.types.DELETE_INSERT:case t.Algebra.types.ADD:case t.Algebra.types.COMPOSITE_UPDATE:case t.Algebra.types.CLEAR:case t.Algebra.types.NOP:case t.Algebra.types.DROP:case t.Algebra.types.CREATE:case t.Algebra.types.MOVE:case t.Algebra.types.COPY:return{type:"exact",value:0,dataset:l.uri};case t.Algebra.types.PROJECT:case t.Algebra.types.FILTER:case t.Algebra.types.ORDER_BY:case t.Algebra.types.GROUP:case t.Algebra.types.CONSTRUCT:case t.Algebra.types.DISTINCT:case t.Algebra.types.REDUCED:case t.Algebra.types.EXTEND:case t.Algebra.types.FROM:case t.Algebra.types.GRAPH:return i(e.input,l);case t.Algebra.types.ZERO_OR_ONE_PATH:case t.Algebra.types.ZERO_OR_MORE_PATH:case t.Algebra.types.ONE_OR_MORE_PATH:case t.Algebra.types.INV:return i(e.path,l);case t.Algebra.types.PATH:return i(e.predicate,l);case t.Algebra.types.NPS:return u(e,l);case t.Algebra.types.LINK:return i(n.createPattern(r.variable("s"),e.iri,r.variable("o")),l);case t.Algebra.types.UNION:case t.Algebra.types.SEQ:case t.Algebra.types.ALT:return s(e.input,l);case t.Algebra.types.BGP:return c(e.patterns,l);case t.Algebra.types.JOIN:case t.Algebra.types.LEFT_JOIN:return c(e.input,l);case t.Algebra.types.SLICE:return a(e,l);case t.Algebra.types.MINUS:return o(e,l);case t.Algebra.types.VALUES:return{type:"exact",value:e.bindings.length,dataset:l.uri};case t.Algebra.types.SERVICE:case t.Algebra.types.DESCRIBE:case t.Algebra.types.EXPRESSION:case t.Algebra.types.PATTERN:return{type:"estimate",value:Number.POSITIVE_INFINITY,dataset:l.uri}}}function o(e,t){const r=i(e.input[0],t),n=i(e.input[1],t);return{type:"estimate",value:Math.max(r.value-n.value,0),dataset:t.uri}}function a(e,t){const r=i(e.input,t);return r.value>0&&(r.value=Math.max(r.value-e.start,0),void 0!==e.length&&(r.value=Math.min(r.value,e.length))),r}function s(e,t){const r={type:"exact",value:0,dataset:t.uri};for(const n of e){const e=i(n,t);"estimate"===e.type&&"exact"===r.type&&(r.type=e.type),r.value+=e.value}return r}function c(e,r){const n=[];for(const r of e){const e=t.Util.inScopeVariables(r).map(e=>e.value),i=n.find(t=>e.some(e=>t.vars.has(e)));if(i){i.ops.push(r);for(const t of e)i.vars.add(t)}else n.push({ops:[r],vars:new Set(e)})}return{type:"estimate",value:n.map(e=>Math.min(...e.ops.map(e=>i(e,r).value))).reduce((e,t)=>e*t,1),dataset:r.uri}}function u(e,t){const o=i(n.createSeq([...e.iris].reverse().map(e=>n.createLink(e))),t),a=i(n.createPattern(r.variable("s"),r.variable("p"),r.variable("o")),t);return{type:"estimate",value:Math.max(0,a.value-o.value),dataset:t.uri}}return kA.estimateCardinality=i,kA.estimateMinusCardinality=o,kA.estimateSliceCardinality=a,kA.estimateUnionCardinality=s,kA.estimateJoinCardinality=c,kA.estimateNpsCardinality=u,kA}(),e),r(function(){if(BA)return UA;BA=1,Object.defineProperty(UA,"__esModule",{value:!0}),UA.getExpressionVariables=void 0;const e=Rj(),t=eS();return UA.getExpressionVariables=function r(n){switch(n.expressionType){case t.Algebra.expressionTypes.AGGREGATE:case t.Algebra.expressionTypes.WILDCARD:throw new Error(`Getting expression variables is not supported for ${n.expressionType}`);case t.Algebra.expressionTypes.EXISTENCE:return t.Util.inScopeVariables(n.input);case t.Algebra.expressionTypes.NAMED:return[];case t.Algebra.expressionTypes.OPERATOR:return(0,e.uniqTerms)(n.args.flatMap(e=>r(e)));case t.Algebra.expressionTypes.TERM:return"Variable"===n.term.termType?[n.term]:[]}},UA}(),e),r(function(){if($A)return qA;$A=1,Object.defineProperty(qA,"__esModule",{value:!0}),qA.doesShapeAcceptOperation=void 0;const e=eS();function t(e,t,n){return r(e,e,t,n)}function r(a,s,c,u){if("conjunction"===s.type)return s.children.every(e=>r(a,e,c,u));if("disjunction"===s.type)return s.children.some(e=>r(a,e,c,u));if("negation"===s.type)return!r(s.child,s.child,c,u);if("arity"===s.type)return r(a,s.child,c,u);if((u?.joinBindings&&!s.joinBindings)??(u?.filterBindings&&!s.filterBindings))return!1;const l=s.operation;switch(l.operationType){case"type":return!(!(l.type!==e.Algebra.types.EXPRESSION||!o(c)||"extensionFunctions"in l&&l.extensionFunctions?.includes(c.name.value))||!n(a,s.children,c,u)&&!i(a,c,u)||l.type!==c.type);case"pattern":return!(!n(a,s.children,c,u)&&!i(a,c,u))&&l.pattern.type===c.type;case"wildcard":{if(u?.wildcardAcceptAllExtensionFunctions)return!0;if(o(c))return!1;let r=!1;return e.Util.recurseOperation(c,{[e.Algebra.types.EXPRESSION]:e=>!(o(e)&&!t(a,e,u)&&(r=!0,1))}),!r}}}function n(e,t,n,i){if(o(n)||o(n.expression))return!1;if(t){const o=n.input?Array.isArray(n.input)?n.input:[n.input]:n.patterns??[];for(const[n,a]of t.entries())if(!o[n]||!r(e,a,o[n],i))return!1;return!0}return!1}function i(e,t,n){return!(t.input&&!(Array.isArray(t.input)?t.input:[t.input]).every(t=>r(e,e,t,n)))&&!(t.expression&&o(t.expression)&&!r(e,e,t.expression,n)||t.patterns&&!t.patterns.every(t=>r(e,e,t,n)))}function o(t){return t&&t.type===e.Algebra.types.EXPRESSION&&t.expressionType===e.Algebra.expressionTypes.NAMED&&(r=t.name.value,!/^https?:\/\/www\.w3\.org\//u.test(r));var r}return qA.doesShapeAcceptOperation=t,qA}(),e),r(function(){if(QA)return zA;QA=1,Object.defineProperty(zA,"__esModule",{value:!0}),zA.removeOperationSource=zA.assignOperationSource=zA.getOperationSource=zA.testReadOnly=zA.validateQueryOutput=zA.getSafeVoid=zA.getSafeBoolean=zA.getSafeQuads=zA.getSafeBindings=void 0;const e=y_,t=Oy;function r(e,t){if(e.type!==t)throw new Error(`Invalid query output type: Expected '${t}' but got '${e.type}'`)}return zA.getSafeBindings=function(e){return r(e,"bindings"),e},zA.getSafeQuads=function(e){return r(e,"quads"),e},zA.getSafeBoolean=function(e){return r(e,"boolean"),e},zA.getSafeVoid=function(e){return r(e,"void"),e},zA.validateQueryOutput=r,zA.testReadOnly=function(r){return r.get(e.KeysQueryOperation.readOnly)?(0,t.failTest)("Attempted a write operation in read-only mode"):(0,t.passTestVoid)()},zA.getOperationSource=function(e){return e.metadata?.scopedSource},zA.assignOperationSource=function(e,t){return(e={...e}).metadata=e.metadata?{...e.metadata}:{},e.metadata.scopedSource=t,e},zA.removeOperationSource=function(e){delete e.metadata?.scopedSource,e.metadata&&0===Object.keys(e.metadata).length&&delete e.metadata},zA}(),e),r(function(){if(GA)return JA;GA=1,Object.defineProperty(JA,"__esModule",{value:!0}),JA.materializeOperation=JA.materializeTerm=void 0;const e=Ew,t=Rj(),r=eS();function n(e,r){if("Variable"===e.termType){const t=r.get(e);if(t)return t}return"Quad"===e.termType&&(0,t.someTermsNested)(e,e=>"Variable"===e.termType)?(0,t.mapTermsNested)(e,e=>n(e,r)):e}function i(t,r,n){const i=[];for(const[o,a]of r)if(!n||n.some(e=>e.equals(o))){const r={[(0,e.termToString)(o)]:a};i.push(t.createValues([o],[r]))}return i}return JA.materializeTerm=n,JA.materializeOperation=function t(o,a,s,c,u={}){return u={strictTargetVariables:"strictTargetVariables"in u&&u.strictTargetVariables,bindFilter:!("bindFilter"in u)||u.bindFilter,originalBindings:"originalBindings"in u?u.originalBindings:a},r.Util.mapOperation(o,{path:(e,t)=>({recurse:!1,result:Object.assign(t.createPath(n(e.subject,a),e.predicate,n(e.object,a),n(e.graph,a)),{metadata:e.metadata})}),pattern:(e,t)=>({recurse:!1,result:Object.assign(t.createPattern(n(e.subject,a),n(e.predicate,a),n(e.object,a),n(e.graph,a)),{metadata:e.metadata})}),join:(e,r)=>({recurse:!1,result:r.createJoin(e.input.map(e=>t(e,a,s,c,u)),e.input.every(e=>!e.metadata))}),extend(r){if(a.has(r.variable)){if(u.strictTargetVariables)throw new Error(`Tried to bind variable ${(0,e.termToString)(r.variable)} in a BIND operator.`);return{recurse:!0,result:t(r.input,a,s,c,u)}}return{recurse:!0,result:r}},group(t,r){if(u.strictTargetVariables){for(const r of t.variables)if(a.has(r))throw new Error(`Tried to bind variable ${(0,e.termToString)(r)} in a GROUP BY operator.`);return{recurse:!0,result:t}}const n=t.variables.filter(e=>!a.has(e));return{recurse:!0,result:r.createGroup(t.input,n,t.aggregates)}},filter(e,r){const n=u.originalBindings;if("operator"!==e.expression.expressionType||0===n.size)return{recurse:!1,result:e};const o=i(r,n),l=t(e.expression,a,s,c,u),d=r.createJoin([...o,t(e.input,a,s,c,u)]);return{recurse:!1,result:r.createFilter(d,l)}},project(e,r){const n=i(r,u.originalBindings,e.variables);let o=t(e.input,a,s,c,u);return n.length>0&&(o=r.createJoin([...n,o])),{recurse:!1,result:r.createProject(o,e.variables)}},values(t,r){if(!u.strictTargetVariables){const n=t.variables.filter(e=>!a.has(e)),i=t.bindings.map(t=>{const r={...t};let n=!0;return a.forEach((t,i)=>{const o=(0,e.termToString)(i);o in r&&(t.equals(r[o])||(n=!1),delete r[o])}),n?r:void 0}).filter(Boolean);return{recurse:!0,result:r.createValues(n,i)}}for(const r of t.variables)if(a.has(r))throw new Error(`Tried to bind variable ${(0,e.termToString)(r)} in a VALUES operator.`);return{recurse:!1,result:t}},expression(t,r){if(!u.bindFilter)return{recurse:!1,result:t};if("term"===t.expressionType)return{recurse:!1,result:r.createTermExpression(n(t.term,a))};if("operator"===t.expressionType)return"bound"===t.operator&&1===t.args.length&&"term"===t.args[0].expressionType&&[...a.keys()].some(e=>t.args[0].term.equals(e))?{recurse:!1,result:r.createTermExpression(r.dataFactory.literal("true",r.dataFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean")))}:{recurse:!0,result:t};if("aggregate"===t.expressionType&&"variable"in t&&a.has(t.variable)){if(u.strictTargetVariables)throw new Error(`Tried to bind ${(0,e.termToString)(t.variable)} in a ${t.aggregator} aggregate.`);return{recurse:!0,result:t}}return{recurse:!0,result:t}}},s)},JA}(),e)}(CA)),CA}function KA(){return HA||(HA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(XA)return LA;XA=1,Object.defineProperty(LA,"__esModule",{value:!0}),LA.ActorOptimizeQueryOperationGroupSources=void 0;const e=TA(),t=y_,r=Oy,n=WA(),i=eS();let o=class extends e.ActorOptimizeQueryOperation{constructor(e){super(e)}async test(e){return(0,n.getOperationSource)(e.operation)?(0,r.failTest)(`Actor ${this.name} does not work with top-level operation sources.`):(0,r.passTestVoid)()}async run(e){return{operation:await this.groupOperation(e.operation,e.context),context:e.context}}async groupOperation(e,r){const o=r.getSafe(t.KeysInitQuery.dataFactory),a=new i.Factory(o);if((0,n.getOperationSource)(e)??!("input"in e))return e;if(!Array.isArray(e.input)){const t=await this.groupOperation(e.input,r);if(t.metadata?.scopedSource){const i=(0,n.getOperationSource)(t);e=await this.moveSourceAnnotationUpwardsIfPossible(e,[t],i,r)}return{...e,input:t}}const s=await Promise.all(e.input.map(e=>this.groupOperation(e,r))),c=this.clusterOperationsWithEqualSources(s);if(1===c.length){const t=c[0],i=(0,n.getOperationSource)(c[0][0]);return{...await this.moveSourceAnnotationUpwardsIfPossible(e,t,i,r),input:t}}if(c.length===s.length)return{...e,input:s};let u;switch(e.type){case i.Algebra.types.JOIN:u=a.createJoin.bind(a);break;case i.Algebra.types.UNION:u=a.createUnion.bind(a);break;case i.Algebra.types.ALT:u=a.createAlt.bind(a);break;case i.Algebra.types.SEQ:u=a.createSeq.bind(a);break;default:throw new Error(`Unsupported operation '${e.type}' detected while grouping sources`)}return await this.groupOperationMulti(c,u,r)}async groupOperationMulti(e,t,r){let i=!0;const o=await Promise.all(e.map(async e=>{const o=(0,n.getOperationSource)(e[0]),a=await this.moveSourceAnnotationUpwardsIfPossible(t(e,!0),e,o,r);return(0,n.getOperationSource)(a)&&(i=!1),a}));return t(o,i)}clusterOperationsWithEqualSources(e){const t=new Map,r=[];for(const i of e){const e=(0,n.getOperationSource)(i);e?(t.has(e)||t.set(e,[]),t.get(e).push(i)):r.push(i)}const i=[];r.length>0&&i.push(r);for(const[e,r]of t.entries())i.push(r.map(t=>(0,n.assignOperationSource)(t,e)));return i}async moveSourceAnnotationUpwardsIfPossible(e,t,r,i){if(r&&this.isPossibleToMoveSourceAnnotationUpwards(e,await r.source.getSelectorShape(i),i)){this.logDebug(i,`Hoist ${t.length} source-specific operations into a single ${e.type} operation for ${r.source.toString()}`),e=(0,n.assignOperationSource)(e,r);for(const e of t)(0,n.removeOperationSource)(e)}return e}isPossibleToMoveSourceAnnotationUpwards(e,r,o){const a=o.get(t.KeysInitQuery.extensionFunctionsAlwaysPushdown);if((0,n.doesShapeAcceptOperation)(r,e,{wildcardAcceptAllExtensionFunctions:a})){const s=o.get(t.KeysInitQuery.extensionFunctions),c=e.expression;return!s||c?.expressionType!==i.Algebra.expressionTypes.NAMED||!(c?.name.value in s)||(0,n.doesShapeAcceptOperation)(r,c,{wildcardAcceptAllExtensionFunctions:a})}return!1}};return LA.ActorOptimizeQueryOperationGroupSources=o,LA}(),e)}(MA)),MA}var YA,ZA,eE={},tE={};function rE(){return ZA||(ZA=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(YA)return tE;YA=1,Object.defineProperty(tE,"__esModule",{value:!0}),tE.ActorOptimizeQueryOperationConstructDistinct=void 0;const e=TA(),t=m_(),r=Oy,n=eS();let i=class extends e.ActorOptimizeQueryOperation{constructor(e){super(e)}async test(e){return e.context.has(t.KeysInitQuery.distinctConstruct)?(0,r.passTestVoid)():(0,r.failTest)(`${this.name} was not enabled by the query.`)}async run(e){const r=n.Util.mapOperation(e.operation,{construct:(e,t)=>({recurse:!1,result:t.createDistinct(t.createConstruct(e.input,e.template))})});return{operation:r,context:e.context.delete(t.KeysInitQuery.distinctConstruct)}}};return tE.ActorOptimizeQueryOperationConstructDistinct=i,tE}(),e)}(eE)),eE}var nE,iE,oE,aE,sE={},cE={},uE={},lE={};function dE(){return iE||(iE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(nE)return lE;nE=1,Object.defineProperty(lE,"__esModule",{value:!0}),lE.ActorRdfJoinEntriesSort=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return lE.ActorRdfJoinEntriesSort=t,lE}(),e)}(uE)),uE}function pE(){return aE||(aE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(oE)return cE;oE=1,Object.defineProperty(cE,"__esModule",{value:!0}),cE.ActorRdfJoinEntriesSortCardinality=void 0;const e=dE(),t=Oy;let r=class extends e.ActorRdfJoinEntriesSort{constructor(e){super(e)}async test(e){return(0,t.passTest)({accuracy:0===e.entries.length?1:e.entries.reduce((e,t)=>e+(Number.isFinite(t.metadata.cardinality.value)?1:0),0)/e.entries.length})}async run(e){return{entries:[...e.entries].sort((e,t)=>e.metadata.cardinality.value-t.metadata.cardinality.value)}}};return cE.ActorRdfJoinEntriesSortCardinality=r,cE}(),e)}(sE)),sE}var fE,hE,yE={},gE={};function mE(){return hE||(hE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(fE)return gE;fE=1,Object.defineProperty(gE,"__esModule",{value:!0}),gE.MediatorNumber=void 0;const e=Oy;let t=class extends e.Mediator{constructor(e){super(e),this.indexPicker=this.createIndexPicker()}createIndexPicker(){switch(this.type){case"min":return e=>e.reduce((e,t,r)=>{const n=this.getOrDefault(t[this.field],Number.POSITIVE_INFINITY);return null!==n&&(Number.isNaN(e[0])||e[0]>n)?[n,r]:e},[Number.NaN,-1])[1];case"max":return e=>e.reduce((e,t,r)=>{const n=this.getOrDefault(t[this.field],Number.NEGATIVE_INFINITY);return null!==n&&(Number.isNaN(e[0])||e[0]e));const i=[];if(this.ignoreFailures){const t={};t[this.field]=null,n=n.map(r=>r.isFailed()?(i.push(r.getFailMessage()),(0,e.passTestWithSideData)(t,void 0)):r)}const o=[],a=n.map((e,t)=>{const r=e.getOrThrow();return o[t]=e.getSideData(),r}),s=this.indexPicker(a);return s<0?(0,e.failTest)(this.constructFailureMessage(t,i)):(0,e.passTestWithSideData)(r[s].actor,o[s])}};return gE.MediatorNumber=t,gE}(),e)}(yE)),yE}var bE,vE,_E,wE,TE={},OE={},SE={},xE={};function jE(){return vE||(vE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(bE)return xE;bE=1,Object.defineProperty(xE,"__esModule",{value:!0}),xE.ActorRdfJoinSelectivity=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return xE.ActorRdfJoinSelectivity=t,xE}(),e)}(SE)),SE}function AE(){return wE||(wE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(_E)return OE;_E=1,Object.defineProperty(OE,"__esModule",{value:!0}),OE.JoinTypes=OE.ActorRdfJoinSelectivityVariableCounting=void 0;const e=jE(),t=Oy,r=eS();let n=class n extends e.ActorRdfJoinSelectivity{constructor(e){super(e)}async test(e){return(0,t.passTest)({accuracy:.5})}static getPatternCost(e){let t=1;return"Variable"===e.subject.termType&&(t+=4),"Variable"!==e.predicate.termType&&e.type!==r.Algebra.types.PATH||(t+=1),"Variable"===e.object.termType&&(t+=2),"Variable"===e.graph.termType&&(t+=1),t/9}static getJoinTypes(e,t){const r=[];return"Variable"===e.subject.termType?(e.subject.equals(t.subject)&&r.push(i.unboundSS),"pattern"===t.type&&e.subject.equals(t.predicate)&&r.push(i.unboundSP),e.subject.equals(t.object)&&r.push(i.unboundSO),e.subject.equals(t.graph)&&r.push(i.unboundSG)):(e.subject.equals(t.subject)&&r.push(i.boundSS),"pattern"===t.type&&e.subject.equals(t.predicate)&&r.push(i.boundSP),e.subject.equals(t.object)&&r.push(i.boundSO),e.subject.equals(t.graph)&&r.push(i.boundSG)),"pattern"===e.type&&("Variable"===e.predicate.termType?(e.predicate.equals(t.subject)&&r.push(i.unboundPS),"pattern"===t.type&&e.predicate.equals(t.predicate)&&r.push(i.unboundPP),e.predicate.equals(t.object)&&r.push(i.unboundPO),e.predicate.equals(t.graph)&&r.push(i.unboundPG)):(e.predicate.equals(t.subject)&&r.push(i.boundPS),"pattern"===t.type&&e.predicate.equals(t.predicate)&&r.push(i.boundPP),e.predicate.equals(t.object)&&r.push(i.boundPO),e.predicate.equals(t.graph)&&r.push(i.boundPG))),"Variable"===e.object.termType?(e.object.equals(t.subject)&&r.push(i.unboundOS),"pattern"===t.type&&e.object.equals(t.predicate)&&r.push(i.unboundOP),e.object.equals(t.object)&&r.push(i.unboundOO),e.object.equals(t.graph)&&r.push(i.unboundOG)):(e.object.equals(t.subject)&&r.push(i.boundOS),"pattern"===t.type&&e.object.equals(t.predicate)&&r.push(i.boundOP),e.object.equals(t.object)&&r.push(i.boundOO),e.object.equals(t.graph)&&r.push(i.boundOG)),"Variable"===e.graph.termType?(e.graph.equals(t.subject)&&r.push(i.unboundGS),"pattern"===t.type&&e.graph.equals(t.predicate)&&r.push(i.unboundGP),e.graph.equals(t.object)&&r.push(i.unboundGO),e.graph.equals(t.graph)&&r.push(i.unboundGG)):(e.graph.equals(t.subject)&&r.push(i.boundGS),"pattern"===t.type&&e.graph.equals(t.predicate)&&r.push(i.boundGP),e.graph.equals(t.object)&&r.push(i.boundGO),e.graph.equals(t.graph)&&r.push(i.boundGG)),r}static getOperationsPairwiseJoinCost(e,t){let r=n.MAX_PAIRWISE_COST;for(const o of n.getJoinTypes(e,t))switch(o){case i.boundSS:r-=4;break;case i.boundSP:r-=6;break;case i.boundSO:r-=2;break;case i.boundSG:case i.boundPS:r-=6;break;case i.boundPP:return 1;case i.boundPO:case i.boundPG:r-=6;break;case i.boundOS:r-=2;break;case i.boundOP:r-=6;break;case i.boundOO:r-=2;break;case i.boundOG:case i.boundGS:case i.boundGP:case i.boundGO:case i.boundGG:r-=6;break;case i.unboundSS:r-=2;break;case i.unboundSP:r-=3;break;case i.unboundSO:r-=1;break;case i.unboundSG:case i.unboundPS:case i.unboundPP:case i.unboundPO:case i.unboundPG:r-=3;break;case i.unboundOS:r-=1;break;case i.unboundOP:r-=3;break;case i.unboundOO:r-=1;break;case i.unboundOG:case i.unboundGS:case i.unboundGP:case i.unboundGO:case i.unboundGG:r-=3}return r/n.MAX_PAIRWISE_COST}static getOperationsJoinCost(e){const t=[];for(const n of e)r.Util.recurseOperation(n,{[r.Algebra.types.PATTERN]:e=>(t.push(e),!1),[r.Algebra.types.PATH]:e=>(t.push(e),!1)});let i=0,o=0;for(const e of t)for(const r of t)e!==r&&(i+=n.getOperationsPairwiseJoinCost(e,r),o++);return 0===o?1:i/o*t.reduce((e,t)=>e*n.getPatternCost(t),1)}async run(e){return e.entries.length<=1?{selectivity:1}:{selectivity:n.getOperationsJoinCost(e.entries.map(e=>e.operation))}}};var i;return OE.ActorRdfJoinSelectivityVariableCounting=n,n.MAX_PAIRWISE_COST=82,function(e){e[e.boundSS=0]="boundSS",e[e.boundSP=1]="boundSP",e[e.boundSO=2]="boundSO",e[e.boundSG=3]="boundSG",e[e.boundPS=4]="boundPS",e[e.boundPP=5]="boundPP",e[e.boundPO=6]="boundPO",e[e.boundPG=7]="boundPG",e[e.boundOS=8]="boundOS",e[e.boundOP=9]="boundOP",e[e.boundOO=10]="boundOO",e[e.boundOG=11]="boundOG",e[e.boundGS=12]="boundGS",e[e.boundGP=13]="boundGP",e[e.boundGO=14]="boundGO",e[e.boundGG=15]="boundGG",e[e.unboundSS=16]="unboundSS",e[e.unboundSP=17]="unboundSP",e[e.unboundSO=18]="unboundSO",e[e.unboundSG=19]="unboundSG",e[e.unboundPS=20]="unboundPS",e[e.unboundPP=21]="unboundPP",e[e.unboundPO=22]="unboundPO",e[e.unboundPG=23]="unboundPG",e[e.unboundOS=24]="unboundOS",e[e.unboundOP=25]="unboundOP",e[e.unboundOO=26]="unboundOO",e[e.unboundOG=27]="unboundOG",e[e.unboundGS=28]="unboundGS",e[e.unboundGP=29]="unboundGP",e[e.unboundGO=30]="unboundGO",e[e.unboundGG=31]="unboundGG"}(i||(OE.JoinTypes=i={})),OE}(),e)}(TE)),TE}var EE,IE,FE,DE,NE={},PE={},RE={},ME={};function LE(){return IE||(IE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(EE)return ME;EE=1,Object.defineProperty(ME,"__esModule",{value:!0}),ME.ActorRdfMetadataAccumulate=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return ME.ActorRdfMetadataAccumulate=t,ME}(),e)}(RE)),RE}function CE(){return DE||(DE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(FE)return PE;FE=1,Object.defineProperty(PE,"__esModule",{value:!0}),PE.ActorRdfMetadataAccumulateCardinality=void 0;const e=LE(),t=Oy;let r=class extends e.ActorRdfMetadataAccumulate{constructor(e){super(e)}async test(e){return(0,t.passTestVoid)()}async run(e){if("initialize"===e.mode)return{metadata:{cardinality:{type:"exact",value:0}}};const t={...e.accumulatedMetadata.cardinality};if(t.dataset){if(e.accumulatedMetadata.defaultGraph===t.dataset&&t.dataset!==e.appendingMetadata.cardinality.dataset)return{metadata:{cardinality:e.appendingMetadata.cardinality}};if(!e.appendingMetadata.cardinality.dataset)return{metadata:{cardinality:t}};if(t.dataset!==e.appendingMetadata.cardinality.dataset&&e.appendingMetadata.subsetOf===t.dataset)return{metadata:{cardinality:e.appendingMetadata.cardinality}};if(t.dataset===e.appendingMetadata.cardinality.dataset)return{metadata:{cardinality:t}};delete t.dataset}return e.appendingMetadata.cardinality&&Number.isFinite(e.appendingMetadata.cardinality.value)?("estimate"===e.appendingMetadata.cardinality.type&&(t.type="estimate"),t.value+=e.appendingMetadata.cardinality.value):(t.type="estimate",t.value=Number.POSITIVE_INFINITY),{metadata:{cardinality:t}}}};return PE.ActorRdfMetadataAccumulateCardinality=r,PE}(),e)}(NE)),NE}var kE,BE,UE={},$E={};function qE(){return BE||(BE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(kE)return $E;kE=1,Object.defineProperty($E,"__esModule",{value:!0}),$E.ActorRdfMetadataAccumulatePageSize=void 0;const e=LE(),t=Oy;let r=class extends e.ActorRdfMetadataAccumulate{constructor(e){super(e)}async test(e){return(0,t.passTestVoid)()}async run(e){return"initialize"===e.mode?{metadata:{}}:{metadata:{..."pageSize"in e.accumulatedMetadata||"pageSize"in e.appendingMetadata?{pageSize:(e.accumulatedMetadata.pageSize??0)+(e.appendingMetadata.pageSize??0)}:{}}}}};return $E.ActorRdfMetadataAccumulatePageSize=r,$E}(),e)}(UE)),UE}var QE,zE,GE={},VE={};function XE(){return zE||(zE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(QE)return VE;QE=1,Object.defineProperty(VE,"__esModule",{value:!0}),VE.ActorRdfMetadataAccumulateRequestTime=void 0;const e=LE(),t=Oy;let r=class extends e.ActorRdfMetadataAccumulate{constructor(e){super(e)}async test(e){return(0,t.passTestVoid)()}async run(e){return"initialize"===e.mode?{metadata:{}}:{metadata:{..."requestTime"in e.accumulatedMetadata||"requestTime"in e.appendingMetadata?{requestTime:(e.accumulatedMetadata.requestTime??0)+(e.appendingMetadata.requestTime??0)}:{}}}}};return VE.ActorRdfMetadataAccumulateRequestTime=r,VE}(),e)}(GE)),GE}var HE,JE,WE={},KE={};function YE(){return JE||(JE=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(HE)return KE;HE=1,Object.defineProperty(KE,"__esModule",{value:!0}),KE.MediatorCombineUnion=void 0;const e=Oy;let t=class extends e.Mediator{constructor(e){super(e),this.combiner=this.createCombiner()}async mediate(e){let t;try{t=this.publish(e)}catch{t=[]}if(this.filterFailures){const e=[];for(const r of t)(await r.reply).isPassed()&&e.push(r);t=e}const r=[];await Promise.all(t.map(async({reply:e},t)=>{const n=await e,i=n.getOrThrow();return r[t]=n.getSideData(),i}));const n=await Promise.all(t.map((t,n)=>t.actor.runObservable(e,r[n])));return this.combiner(n)}mediateWith(){throw new Error("Method not supported.")}createCombiner(){return e=>{const t={};return t[this.field]={},[{}].concat(e.map(e=>e[this.field])).forEach(e=>{t[this.field]={...e,...t[this.field]}}),t}}};return KE.MediatorCombineUnion=t,KE}(),e)}(WE)),WE}var ZE,eI={},tI={},rI={},nI={};function iI(){if(ZE)return nI;ZE=1,Object.defineProperty(nI,"__esModule",{value:!0}),nI.ActorRdfUpdateQuads=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return nI.ActorRdfUpdateQuads=t,nI}var oI,aI={};var sI,cI={};var uI,lI,dI={};function pI(){return lI||(lI=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(iI(),e),r(function(){if(oI)return aI;oI=1,Object.defineProperty(aI,"__esModule",{value:!0}),aI.ActorRdfUpdateQuadsDestination=aI.deskolemize=aI.deskolemizeStream=void 0;const e=Cj(),t=y_,r=Oy,n=iI();function i(t,r,n){return r?.map(r=>(0,e.deskolemizeQuad)(t,r,n))}function o(e){const r=e.context.getSafe(t.KeysInitQuery.dataFactory),n=e.context.get(t.KeysRdfUpdateQuads.destination),o=e.context.get(t.KeysQuerySourceIdentify.sourceIds)?.get(n);return o?{...e,quadStreamInsert:i(r,e.quadStreamInsert,o),quadStreamDelete:i(r,e.quadStreamDelete,o)}:e}aI.deskolemizeStream=i,aI.deskolemize=o;let a=class extends n.ActorRdfUpdateQuads{async test(e){return(0,r.passTestVoid)()}async run(e){const t=await this.getDestination(e.context);return await this.getOutput(t,o(e))}async getOutput(e,t){return{execute:async()=>{await e.update({insert:t.quadStreamInsert,delete:t.quadStreamDelete}),await(t.deleteGraphs?e.deleteGraphs(t.deleteGraphs.graphs,t.deleteGraphs.requireExistence,t.deleteGraphs.dropGraphs):Promise.resolve()),await(t.createGraphs?e.createGraphs(t.createGraphs.graphs,t.createGraphs.requireNonExistence):Promise.resolve())}}}};return aI.ActorRdfUpdateQuadsDestination=a,aI}(),e),r((sI||(sI=1,Object.defineProperty(cI,"__esModule",{value:!0})),cI),e),r(function(){if(uI)return dI;uI=1,Object.defineProperty(dI,"__esModule",{value:!0}),dI.getContextDestinationUrl=dI.getContextDestination=dI.getDataDestinationContext=dI.getDataDestinationValue=dI.getDataDestinationType=dI.isDataDestinationRawType=void 0;const e=y_;function t(e){return"string"==typeof e||"remove"in e}function r(e){return t(e)?e:e.value}return dI.isDataDestinationRawType=t,dI.getDataDestinationType=function(e){return"string"==typeof e?"":"remove"in e?"rdfjsStore":e.type},dI.getDataDestinationValue=r,dI.getDataDestinationContext=function(e,t){return"string"==typeof e||"remove"in e||!e.context?t:t.merge(e.context)},dI.getContextDestination=function(t){return t.get(e.KeysRdfUpdateQuads.destination)},dI.getContextDestinationUrl=function(e){if(e){let t=r(e);if("string"==typeof t){const e=t.indexOf("#");return e>=0&&(t=t.slice(0,e)),t}}},dI}(),e)}(rI)),rI}var fI,hI,yI,gI,mI={},bI={};function vI(){if(hI)return mI;hI=1,Object.defineProperty(mI,"__esModule",{value:!0}),mI.RdfJsQuadDestination=void 0;const e=(fI||(fI=1,Object.defineProperty(bI,"__esModule",{value:!0}),bI.promisifyEventEmitter=void 0,bI.promisifyEventEmitter=function(e,t){return new Promise((r,n)=>{e.on("end",()=>r(t)),e.on("error",n)})}),bI),t=Ew;return mI.RdfJsQuadDestination=class{constructor(e,t){this.dataFactory=e,this.store=t}async update(t){t.delete&&await(0,e.promisifyEventEmitter)(this.store.remove(t.delete)),t.insert&&await(0,e.promisifyEventEmitter)(this.store.import(t.insert))}async deleteGraphs(r,n,i){switch(r){case"ALL":await(0,e.promisifyEventEmitter)(this.store.deleteGraph(this.dataFactory.defaultGraph()));case"NAMED":const n=this.store.match(),i={};n.on("data",e=>{"DefaultGraph"!==e.graph.termType&&(i[(0,t.termToString)(e.graph)]=!0)}),await(0,e.promisifyEventEmitter)(n),await Promise.all(Object.keys(i).map(r=>(0,e.promisifyEventEmitter)(this.store.deleteGraph((0,t.stringToTerm)(r,this.dataFactory)))));break;default:for(const t of Array.isArray(r)?r:[r])await(0,e.promisifyEventEmitter)(this.store.deleteGraph(t))}}async createGraphs(e,t){if(t)for(const t of e){const e=this.store.match(void 0,void 0,void 0,t);await new Promise((r,n)=>{e.once("data",()=>{n(new Error(`Unable to create graph ${t.value} as it already exists`))}),e.on("end",r),e.on("error",n)})}}},mI}function _I(){return gI||(gI=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(yI)return tI;yI=1,Object.defineProperty(tI,"__esModule",{value:!0}),tI.ActorRdfUpdateQuadsRdfJsStore=void 0;const e=pI(),t=y_,r=Oy,n=vI();let i=class extends e.ActorRdfUpdateQuadsDestination{constructor(e){super(e)}async test(t){const n=(0,e.getContextDestination)(t.context);return!n||"string"==typeof n||!("remove"in n)&&"value"in n&&!n.value?.remove?(0,r.failTest)(`${this.name} received an invalid rdfjsStore.`):(0,r.passTestVoid)()}async getDestination(r){const i=(0,e.getContextDestination)(r);return new n.RdfJsQuadDestination(r.getSafe(t.KeysInitQuery.dataFactory),"remove"in i?i:i.value)}};return tI.ActorRdfUpdateQuadsRdfJsStore=i,tI}(),e)}(eI)),eI}var wI,TI,OI,SI,xI={},jI={},AI={},EI={};function II(){return TI||(TI=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(wI)return EI;wI=1,Object.defineProperty(EI,"__esModule",{value:!0}),EI.ActorQueryParse=void 0;const e=Oy;let t=class extends e.Actor{constructor(e){super(e)}};return EI.ActorQueryParse=t,EI}(),e)}(AI)),AI}function FI(){return SI||(SI=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(OI)return jI;OI=1,Object.defineProperty(jI,"__esModule",{value:!0}),jI.ActorQueryParseSparql=void 0;const e=II(),t=y_,r=Oy,n=eS(),i=XT();let o=class extends e.ActorQueryParse{constructor(e){super(e),this.prefixes=Object.freeze(this.prefixes)}async test(e){return e.queryFormat&&"sparql"!==e.queryFormat.language?(0,r.failTest)("This actor can only parse SPARQL queries"):(0,r.passTestVoid)()}async run(e){const r=e.context.getSafe(t.KeysInitQuery.dataFactory),o=new i.Parser({prefixes:this.prefixes,baseIRI:e.baseIRI,sparqlStar:!0,factory:r}).parse(e.query);return{baseIRI:"query"===o.type?o.base:void 0,operation:(0,n.translate)(o,{quads:!0,prefixes:this.prefixes,blankToVariable:!0,baseIRI:e.baseIRI,dataFactory:r})}}};return jI.ActorQueryParseSparql=o,jI}(),e)}(xI)),xI}var DI,NI,PI,RI={},MI={},LI={};function CI(){if(NI)return MI;NI=1,Object.defineProperty(MI,"__esModule",{value:!0}),MI.ActorFunctionFactoryExpressionBnode=void 0;const e=ux(),t=sx(),r=function(){if(DI)return LI;DI=1,Object.defineProperty(LI,"__esModule",{value:!0}),LI.ExpressionFunctionBnode=void 0;const e=ux(),t=y_,r=Tj(),n=sx();let i=class i extends e.ExpressionFunctionBase{constructor(){super({arity:Number.POSITIVE_INFINITY,operator:n.SparqlOperator.BNODE,apply:async e=>{const{args:o,mapping:a,exprEval:s}=e,c=1===o.length?await s.evaluatorExpressionEvaluation(o[0],a):void 0;let u;if(c){const e=i.bnodeTree.search([c],s.context.getSafe(t.KeysExpressionEvaluator.superTypeProvider),s.context.getSafe(t.KeysInitQuery.functionArgumentsCache));if(!e)throw new n.InvalidArgumentTypes(o,n.SparqlOperator.BNODE);u=e(s)([c]).str()}const l=new r.BlankNodeBindingsScoped(u??"BNODE_"+i.bnodeCounter++);return new n.BlankNode(l)}})}checkArity(e){return 0===e.length||1===e.length}};return LI.ExpressionFunctionBnode=i,i.bnodeTree=(0,n.declare)(n.SparqlOperator.BNODE).onString1(()=>e=>e).collect(),i.bnodeCounter=0,LI}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.BNODE],termFunction:!1})}async run(e){return new r.ExpressionFunctionBnode}};return MI.ActorFunctionFactoryExpressionBnode=n,MI}var kI,BI,UI,$I={},qI={},QI={};function zI(){if(BI)return qI;BI=1,Object.defineProperty(qI,"__esModule",{value:!0}),qI.ActorFunctionFactoryExpressionCoalesce=void 0;const e=ux(),t=sx(),r=function(){if(kI)return QI;kI=1,Object.defineProperty(QI,"__esModule",{value:!0}),QI.ExpressionFunctionCoalesce=void 0;const e=ux(),t=sx();let r=class extends e.ExpressionFunctionBase{constructor(){super({arity:Number.POSITIVE_INFINITY,operator:t.SparqlOperator.COALESCE,apply:async({args:e,mapping:r,exprEval:n})=>{const i=[];for(const t of e)try{return await n.evaluatorExpressionEvaluation(t,r)}catch(e){i.push(e)}throw new t.CoalesceError(i)}})}};return QI.ExpressionFunctionCoalesce=r,QI}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.COALESCE],termFunction:!1})}async run(e){return new r.ExpressionFunctionCoalesce}};return qI.ActorFunctionFactoryExpressionCoalesce=n,qI}var GI,VI,XI,HI={},JI={},WI={};function KI(){if(VI)return JI;VI=1,Object.defineProperty(JI,"__esModule",{value:!0}),JI.ActorFunctionFactoryExpressionBound=void 0;const e=ux(),t=sx(),r=function(){if(GI)return WI;GI=1,Object.defineProperty(WI,"__esModule",{value:!0}),WI.ExpressionFunctionBound=void 0;const e=ux(),t=y_,r=yw(),n=sx();let i=class extends e.ExpressionFunctionBase{constructor(){super({arity:1,operator:n.SparqlOperator.BOUND,apply:async({args:e,mapping:i,exprEval:o})=>{const a=e[0];if(a.expressionType!==r.ExpressionType.Variable)throw new n.InvalidArgumentTypes(e,n.SparqlOperator.BOUND);const s=i.has((0,n.expressionToVar)(o.context.getSafe(t.KeysInitQuery.dataFactory),a));return(0,n.bool)(s)}})}};return WI.ExpressionFunctionBound=i,WI}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.BOUND],termFunction:!1})}async run(e){return new r.ExpressionFunctionBound}};return JI.ActorFunctionFactoryExpressionBound=n,JI}var YI,ZI,eF,tF={},rF={},nF={};function iF(){if(ZI)return rF;ZI=1,Object.defineProperty(rF,"__esModule",{value:!0}),rF.ActorFunctionFactoryExpressionExtensions=void 0;const e=ux(),t=y_,r=Oy,n=Fw,i=function(){if(YI)return nF;YI=1,Object.defineProperty(nF,"__esModule",{value:!0}),nF.NamedExtension=void 0;const e=cx(),t=y_,r=sx();let n=class extends e.ExpressionFunctionBase{constructor({operator:e,functionDefinition:n}){super({arity:Number.POSITIVE_INFINITY,operator:e,apply:async({args:e,exprEval:i,mapping:o})=>{const a=await Promise.all(e.map(e=>i.evaluatorExpressionEvaluation(e,o)));try{return new r.TermTransformer(i.context.getSafe(t.KeysExpressionEvaluator.superTypeProvider)).transformRDFTermUnsafe(await n(a.map(e=>e.toRDF(i.context.getSafe(t.KeysInitQuery.dataFactory)))))}catch(e){throw new r.ExtensionFunctionError(this.operator,e)}}})}};return nF.NamedExtension=n,nF}();let o=class extends e.ActorFunctionFactory{constructor(e){super(e)}async test({context:e,functionName:i}){const o=e.getSafe(t.KeysExpressionEvaluator.extensionFunctionCreator);return await o((new n.DataFactory).namedNode(i))?(0,r.passTestVoid)():(0,r.failTest)(`Actor ${this.name} can only provide non-termExpression implementations for functions that are provided through config entries like: ${t.KeysInitQuery.extensionFunctionCreator.name} or ${t.KeysInitQuery.extensionFunctions.name}`)}async run({context:e,functionName:r}){const o=e.getSafe(t.KeysExpressionEvaluator.extensionFunctionCreator),a=await o((new n.DataFactory).namedNode(r));return new i.NamedExtension({operator:r,functionDefinition:a})}};return rF.ActorFunctionFactoryExpressionExtensions=o,rF}var oF,aF,sF,cF={},uF={},lF={};function dF(){if(aF)return uF;aF=1,Object.defineProperty(uF,"__esModule",{value:!0}),uF.ActorFunctionFactoryExpressionConcat=void 0;const e=ux(),t=sx(),r=function(){if(oF)return lF;oF=1,Object.defineProperty(lF,"__esModule",{value:!0}),lF.ExpressionFunctionConcat=void 0;const e=ux(),t=y_,r=sx();let n=class n extends e.ExpressionFunctionBase{constructor(){super({arity:Number.POSITIVE_INFINITY,operator:r.SparqlOperator.CONCAT,apply:async e=>{const{args:i,mapping:o,exprEval:a}=e,s=i.map(async e=>a.evaluatorExpressionEvaluation(e,o)).map(async e=>{const o=n.concatTree.search([await e],a.context.getSafe(t.KeysExpressionEvaluator.superTypeProvider),a.context.getSafe(t.KeysInitQuery.functionArgumentsCache));if(!o)throw new r.InvalidArgumentTypes(i,r.SparqlOperator.CONCAT);return o(a)([await e])}),c=await Promise.all(s),u=c.map(e=>e.typedValue).join(""),l=n.langAllEqual(c)?c[0].language:void 0;return l?(0,r.langString)(u,l):(0,r.string)(u)}})}static langAllEqual(e){return e.length>0&&e.every(t=>t.language===e[0].language)}};return lF.ExpressionFunctionConcat=n,n.concatTree=(0,r.declare)(r.SparqlOperator.CONCAT).onStringly1(()=>e=>e).collect(),lF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.CONCAT],termFunction:!1})}async run(e){return new r.ExpressionFunctionConcat}};return uF.ActorFunctionFactoryExpressionConcat=n,uF}var pF,fF,hF,yF={},gF={},mF={};function bF(){if(fF)return gF;fF=1,Object.defineProperty(gF,"__esModule",{value:!0}),gF.ActorFunctionFactoryExpressionIf=void 0;const e=ux(),t=sx(),r=function(){if(pF)return mF;pF=1,Object.defineProperty(mF,"__esModule",{value:!0}),mF.ExpressionFunctionIf=void 0;const e=ux(),t=sx();let r=class extends e.ExpressionFunctionBase{constructor(){super({arity:3,operator:t.SparqlOperator.IF,apply:async({args:e,mapping:t,exprEval:r})=>(await r.evaluatorExpressionEvaluation(e[0],t)).coerceEBV()?r.evaluatorExpressionEvaluation(e[1],t):r.evaluatorExpressionEvaluation(e[2],t)})}};return mF.ExpressionFunctionIf=r,mF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IF],termFunction:!1})}async run(e){return new r.ExpressionFunctionIf}};return gF.ActorFunctionFactoryExpressionIf=n,gF}var vF,_F,wF,TF={},OF={},SF={};function xF(){if(_F)return OF;_F=1,Object.defineProperty(OF,"__esModule",{value:!0}),OF.ActorFunctionFactoryExpressionLogicalAnd=void 0;const e=ux(),t=sx(),r=function(){if(vF)return SF;vF=1,Object.defineProperty(SF,"__esModule",{value:!0}),SF.ExpressionFunctionLogicalAnd=void 0;const e=ux(),t=sx();let r=class extends e.ExpressionFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.LOGICAL_AND,apply:async({args:e,mapping:r,exprEval:n})=>{const[i,o]=e;try{if(!(await n.evaluatorExpressionEvaluation(i,r)).coerceEBV())return(0,t.bool)(!1);const e=(await n.evaluatorExpressionEvaluation(o,r)).coerceEBV();return(0,t.bool)(e)}catch(e){if((await n.evaluatorExpressionEvaluation(o,r)).coerceEBV())throw e;return(0,t.bool)(!1)}}})}};return SF.ExpressionFunctionLogicalAnd=r,SF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.LOGICAL_AND],termFunction:!1})}async run(e){return new r.ExpressionFunctionLogicalAnd}};return OF.ActorFunctionFactoryExpressionLogicalAnd=n,OF}var jF,AF,EF,IF={},FF={},DF={};function NF(){if(AF)return FF;AF=1,Object.defineProperty(FF,"__esModule",{value:!0}),FF.ActorFunctionFactoryExpressionLogicalOr=void 0;const e=ux(),t=sx(),r=function(){if(jF)return DF;jF=1,Object.defineProperty(DF,"__esModule",{value:!0}),DF.ExpressionFunctionLogicalOr=void 0;const e=ux(),t=sx();let r=class extends e.ExpressionFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.LOGICAL_OR,apply:async({args:e,mapping:r,exprEval:n})=>{const[i,o]=e;try{if((await n.evaluatorExpressionEvaluation(i,r)).coerceEBV())return(0,t.bool)(!0);const e=(await n.evaluatorExpressionEvaluation(o,r)).coerceEBV();return(0,t.bool)(e)}catch(e){if(!(await n.evaluatorExpressionEvaluation(o,r)).coerceEBV())throw e;return(0,t.bool)(!0)}}})}};return DF.ExpressionFunctionLogicalOr=r,DF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.LOGICAL_OR],termFunction:!1})}async run(e){return new r.ExpressionFunctionLogicalOr}};return FF.ActorFunctionFactoryExpressionLogicalOr=n,FF}var PF,RF,MF,LF={},CF={},kF={};function BF(){if(RF)return CF;RF=1,Object.defineProperty(CF,"__esModule",{value:!0}),CF.ActorFunctionFactoryExpressionSameTerm=void 0;const e=ux(),t=sx(),r=function(){if(PF)return kF;PF=1,Object.defineProperty(kF,"__esModule",{value:!0}),kF.ExpressionFunctionSameTerm=void 0;const e=ux(),t=y_,r=sx();let n=class extends e.ExpressionFunctionBase{constructor(){super({arity:2,operator:r.SparqlOperator.SAME_TERM,apply:async({args:e,mapping:n,exprEval:i})=>{const o=i.context.getSafe(t.KeysInitQuery.dataFactory),[a,s]=e.map(e=>i.evaluatorExpressionEvaluation(e,n)),[c,u]=await Promise.all([a,s]);return(0,r.bool)(c.toRDF(o).equals(u.toRDF(o)))}})}};return kF.ExpressionFunctionSameTerm=n,kF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.SAME_TERM],termFunction:!1})}async run(e){return new r.ExpressionFunctionSameTerm}};return CF.ActorFunctionFactoryExpressionSameTerm=n,CF}var UF,$F,qF,QF={},zF={},GF={};function VF(){if($F)return zF;$F=1,Object.defineProperty(zF,"__esModule",{value:!0}),zF.ActorFunctionFactoryTermAbs=void 0;const e=ux(),t=sx(),r=function(){if(UF)return GF;UF=1,Object.defineProperty(GF,"__esModule",{value:!0}),GF.TermFunctionAbs=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.ABS,overloads:(0,t.declare)(t.SparqlOperator.ABS).numericConverter(()=>e=>Math.abs(e)).collect()})}};return GF.TermFunctionAbs=r,GF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.ABS],termFunction:!0})}async run(e){return new r.TermFunctionAbs}};return zF.ActorFunctionFactoryTermAbs=n,zF}var XF={},HF={},JF={},WF=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,KF=Math.ceil,YF=Math.floor,ZF="[BigNumber Error] ",eD=ZF+"Number primitive has more than 15 significant digits: ",tD=1e14,rD=14,nD=9007199254740991,iD=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],oD=1e7,aD=1e9;function sD(e){var t=0|e;return e>0||e===t?t:t-1}function cD(e){for(var t,r,n=1,i=e.length,o=e[0]+"";nu^r?1:-1;for(s=(c=i.length)<(u=o.length)?c:u,a=0;ao[a]^r?1:-1;return c==u?0:c>u^r?1:-1}function lD(e,t,r,n){if(er||e!==YF(e))throw Error(ZF+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function dD(e){var t=e.c.length-1;return sD(e.e/rD)==t&&e.c[t]%2!=0}function pD(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function fD(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else tv?p.c=p.e=null:e.e=10;c/=10,s++);return void(s>v?p.c=p.e=null:(p.e=s,p.c=[e]))}d=String(e)}else{if(!WF.test(d=String(e)))return i(p,d,u);p.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(s=d.indexOf("."))>-1&&(d=d.replace(".","")),(c=d.search(/e/i))>0?(s<0&&(s=c),s+=+d.slice(c+1),d=d.substring(0,c)):s<0&&(s=d.length)}else{if(lD(t,2,S.length,"Base"),10==t&&x)return F(p=new j(e),h+p.e+1,y);if(d=String(e),u="number"==typeof e){if(0*e!=0)return i(p,d,u,t);if(p.s=1/e<0?(d=d.slice(1),-1):1,j.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(eD+e)}else p.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(r=S.slice(0,t),s=c=0,l=d.length;cs){s=l;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,c=-1,s=0;continue}return i(p,String(e),u,t)}u=!1,(s=(d=n(d,t,10,p.s)).indexOf("."))>-1?d=d.replace(".",""):s=d.length}for(c=0;48===d.charCodeAt(c);c++);for(l=d.length;48===d.charCodeAt(--l););if(d=d.slice(c,++l)){if(l-=c,u&&j.DEBUG&&l>15&&(e>nD||e!==YF(e)))throw Error(eD+p.s*e);if((s=s-c-1)>v)p.c=p.e=null;else if(s=m)?pD(c,a):fD(c,a,"0");else if(o=(e=F(new j(e),t,r)).e,s=(c=cD(e.c)).length,1==n||2==n&&(t<=o||o<=g)){for(;sa),c=fD(c,o,"0"),o+1>s){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=o-s)>0)for(o+1==s&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function E(e,t){for(var r,n,i=1,o=new j(e[0]);i=10;i/=10,n++);return(r=n+r*rD-1)>v?e.c=e.e=null:r=10;s/=10,i++);if((o=t-i)<0)o+=rD,a=t,c=d[u=0],l=YF(c/p[i-a-1]%10);else if((u=KF((o+1)/rD))>=d.length){if(!n)break e;for(;d.length<=u;d.push(0));c=l=0,i=1,a=(o%=rD)-rD+1}else{for(c=s=d[u],i=1;s>=10;s/=10,i++);l=(a=(o%=rD)-rD+i)<0?0:YF(c/p[i-a-1]%10)}if(n=n||t<0||null!=d[u+1]||(a<0?c:c%p[i-a-1]),n=r<4?(l||n)&&(0==r||r==(e.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(o>0?a>0?c/p[i-a]:0:d[u-1])%10&1||r==(e.s<0?8:7)),t<1||!d[0])return d.length=0,n?(t-=e.e+1,d[0]=p[(rD-t%rD)%rD],e.e=-t||0):d[0]=e.e=0,e;if(0==o?(d.length=u,s=1,u--):(d.length=u+1,s=p[rD-o],d[u]=a>0?YF(c/p[i-a]%p[a])*s:0),n)for(;;){if(0==u){for(o=1,a=d[0];a>=10;a/=10,o++);for(a=d[0]+=s,s=1;a>=10;a/=10,s++);o!=s&&(e.e++,d[0]==tD&&(d[0]=1));break}if(d[u]+=s,d[u]!=tD)break;d[u--]=0,s=1}for(o=d.length;0===d[--o];d.pop());}e.e>v?e.c=e.e=null:e.e=m?pD(t,r):fD(t,r,"0"),e.s<0?"-"+t:t)}return j.clone=e,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(ZF+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(lD(r=e[t],0,aD,t),h=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(lD(r=e[t],0,8,t),y=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(lD(r[0],-aD,0,t),lD(r[1],0,aD,t),g=r[0],m=r[1]):(lD(r,-aD,aD,t),g=-(m=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)lD(r[0],-aD,-1,t),lD(r[1],1,aD,t),b=r[0],v=r[1];else{if(lD(r,-aD,aD,t),!r)throw Error(ZF+t+" cannot be zero: "+r);b=-(v=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(ZF+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw _=!r,Error(ZF+"crypto unavailable");_=r}else _=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(lD(r=e[t],0,9,t),w=r),e.hasOwnProperty(t="POW_PRECISION")&&(lD(r=e[t],0,aD,t),T=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(ZF+t+" not an object: "+r);O=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(ZF+t+" invalid: "+r);x="0123456789"==r.slice(0,10),S=r}}return{DECIMAL_PLACES:h,ROUNDING_MODE:y,EXPONENTIAL_AT:[g,m],RANGE:[b,v],CRYPTO:_,MODULO_MODE:w,POW_PRECISION:T,FORMAT:O,ALPHABET:S}},j.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!j.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-aD&&i<=aD&&i===YF(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%rD)<1&&(t+=rD),String(n[0]).length==t){for(t=0;t=tD||r!==YF(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(ZF+"Invalid BigNumber: "+e)},j.maximum=j.max=function(){return E(arguments,-1)},j.minimum=j.min=function(){return E(arguments,1)},j.random=(o=9007199254740992,a=Math.random()*o&2097151?function(){return YF(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,o,s=0,c=[],u=new j(f);if(null==e?e=h:lD(e,0,aD),i=KF(e/rD),_)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));s>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[s]=r[0],t[s+1]=r[1]):(c.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw _=!1,Error(ZF+"crypto unavailable");for(t=crypto.randomBytes(i*=7);s=9e15?crypto.randomBytes(7).copy(t,s):(c.push(o%1e14),s+=7);s=i/7}if(!_)for(;s=10;o/=10,s++);sr-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/r|0,a[i]%=r)}return a.reverse()}return function(n,i,o,a,s){var c,u,l,d,p,f,g,m,b=n.indexOf("."),v=h,_=y;for(b>=0&&(d=T,T=0,n=n.replace(".",""),f=(m=new j(i)).pow(n.length-b),T=d,m.c=t(fD(cD(f.c),f.e,"0"),10,o,e),m.e=m.c.length),l=d=(g=t(n,i,o,s?(c=S,e):(c=e,S))).length;0==g[--d];g.pop());if(!g[0])return c.charAt(0);if(b<0?--l:(f.c=g,f.e=l,f.s=a,g=(f=r(f,m,v,_,o)).c,p=f.r,l=f.e),b=g[u=l+v+1],d=o/2,p=p||u<0||null!=g[u+1],p=_<4?(null!=b||p)&&(0==_||_==(f.s<0?3:2)):b>d||b==d&&(4==_||p||6==_&&1&g[u-1]||_==(f.s<0?8:7)),u<1||!g[0])n=p?fD(c.charAt(1),-v,c.charAt(0)):c.charAt(0);else{if(g.length=u,p)for(--o;++g[--u]>o;)g[u]=0,u||(++l,g=[1].concat(g));for(d=g.length;!g[--d];);for(b=0,n="";b<=d;n+=c.charAt(g[b++]));n=fD(n,l,c.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,i,o,a,s=0,c=e.length,u=t%oD,l=t/oD|0;for(e=e.slice();c--;)s=((i=u*(o=e[c]%oD)+(n=l*o+(a=e[c]/oD|0)*u)%oD*oD+s)/r|0)+(n/oD|0)+l*a,e[c]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,o,a,s){var c,u,l,d,p,f,h,y,g,m,b,v,_,w,T,O,S,x=n.s==i.s?1:-1,A=n.c,E=i.c;if(!(A&&A[0]&&E&&E[0]))return new j(n.s&&i.s&&(A?!E||A[0]!=E[0]:E)?A&&0==A[0]||!E?0*x:x/0:NaN);for(g=(y=new j(x)).c=[],x=o+(u=n.e-i.e)+1,s||(s=tD,u=sD(n.e/rD)-sD(i.e/rD),x=x/rD|0),l=0;E[l]==(A[l]||0);l++);if(E[l]>(A[l]||0)&&u--,x<0)g.push(1),d=!0;else{for(w=A.length,O=E.length,l=0,x+=2,(p=YF(s/(E[0]+1)))>1&&(E=e(E,p,s),A=e(A,p,s),O=E.length,w=A.length),_=O,b=(m=A.slice(0,O)).length;b=s/2&&T++;do{if(p=0,(c=t(E,m,O,b))<0){if(v=m[0],O!=b&&(v=v*s+(m[1]||0)),(p=YF(v/T))>1)for(p>=s&&(p=s-1),h=(f=e(E,p,s)).length,b=m.length;1==t(f,m,h,b);)p--,r(f,O=10;x/=10,l++);F(y,o+(y.e=l+u*rD-1)+1,a,d)}else y.e=u,y.r=+d;return y}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,u=/^\.([^.]+)$/,l=/^-?(Infinity|NaN)$/,d=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(d,"");if(l.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(s,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(c,"$1").replace(u,"0.$1")),t!=o))return new j(o,i);if(j.DEBUG)throw Error(ZF+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},p.absoluteValue=p.abs=function(){var e=new j(this);return e.s<0&&(e.s=1),e},p.comparedTo=function(e,t){return uD(this,new j(e,t))},p.decimalPlaces=p.dp=function(e,t){var r,n,i,o=this;if(null!=e)return lD(e,0,aD),null==t?t=y:lD(t,0,8),F(new j(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-sD(this.e/rD))*rD,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},p.dividedBy=p.div=function(e,t){return r(this,new j(e,t),h,y)},p.dividedToIntegerBy=p.idiv=function(e,t){return r(this,new j(e,t),0,1)},p.exponentiatedBy=p.pow=function(e,t){var r,n,i,o,a,s,c,u,l=this;if((e=new j(e)).c&&!e.isInteger())throw Error(ZF+"Exponent not an integer: "+D(e));if(null!=t&&(t=new j(t)),a=e.e>14,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!e.c||!e.c[0])return u=new j(Math.pow(+D(l),a?e.s*(2-dD(e)):+D(e))),t?u.mod(t):u;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new j(NaN);(n=!s&&l.isInteger()&&t.isInteger())&&(l=l.mod(t))}else{if(e.e>9&&(l.e>0||l.e<-1||(0==l.e?l.c[0]>1||a&&l.c[1]>=24e7:l.c[0]<8e13||a&&l.c[0]<=9999975e7)))return o=l.s<0&&dD(e)?-0:0,l.e>-1&&(o=1/o),new j(s?1/o:o);T&&(o=KF(T/rD+2))}for(a?(r=new j(.5),s&&(e.s=1),c=dD(e)):c=(i=Math.abs(+D(e)))%2,u=new j(f);;){if(c){if(!(u=u.times(l)).c)break;o?u.c.length>o&&(u.c.length=o):n&&(u=u.mod(t))}if(i){if(0===(i=YF(i/2)))break;c=i%2}else if(F(e=e.times(r),e.e+1,1),e.e>14)c=dD(e);else{if(0===(i=+D(e)))break;c=i%2}l=l.times(l),o?l.c&&l.c.length>o&&(l.c.length=o):n&&(l=l.mod(t))}return n?u:(s&&(u=f.div(u)),t?u.mod(t):o?F(u,T,y,undefined):u)},p.integerValue=function(e){var t=new j(this);return null==e?e=y:lD(e,0,8),F(t,t.e+1,e)},p.isEqualTo=p.eq=function(e,t){return 0===uD(this,new j(e,t))},p.isFinite=function(){return!!this.c},p.isGreaterThan=p.gt=function(e,t){return uD(this,new j(e,t))>0},p.isGreaterThanOrEqualTo=p.gte=function(e,t){return 1===(t=uD(this,new j(e,t)))||0===t},p.isInteger=function(){return!!this.c&&sD(this.e/rD)>this.c.length-2},p.isLessThan=p.lt=function(e,t){return uD(this,new j(e,t))<0},p.isLessThanOrEqualTo=p.lte=function(e,t){return-1===(t=uD(this,new j(e,t)))||0===t},p.isNaN=function(){return!this.s},p.isNegative=function(){return this.s<0},p.isPositive=function(){return this.s>0},p.isZero=function(){return!!this.c&&0==this.c[0]},p.minus=function(e,t){var r,n,i,o,a=this,s=a.s;if(t=(e=new j(e,t)).s,!s||!t)return new j(NaN);if(s!=t)return e.s=-t,a.plus(e);var c=a.e/rD,u=e.e/rD,l=a.c,d=e.c;if(!c||!u){if(!l||!d)return l?(e.s=-t,e):new j(d?a:NaN);if(!l[0]||!d[0])return d[0]?(e.s=-t,e):new j(l[0]?a:3==y?-0:0)}if(c=sD(c),u=sD(u),l=l.slice(),s=c-u){for((o=s<0)?(s=-s,i=l):(u=c,i=d),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=l.length)<(t=d.length))?s:t,s=t=0;t0)for(;t--;l[r++]=0);for(t=tD-1;n>s;){if(l[--n]=0;){for(r=0,p=v[i]%g,f=v[i]/g|0,o=i+(a=c);o>i;)r=((u=p*(u=b[--a]%g)+(s=f*u+(l=b[a]/g|0)*p)%g*g+h[o]+r)/y|0)+(s/g|0)+f*l,h[o--]=u%y;h[o]=r}return r?++n:h.splice(0,1),I(e,h,n)},p.negated=function(){var e=new j(this);return e.s=-e.s||null,e},p.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new j(e,t)).s,!i||!t)return new j(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/rD,a=e.e/rD,s=n.c,c=e.c;if(!o||!a){if(!s||!c)return new j(i/0);if(!s[0]||!c[0])return c[0]?e:new j(s[0]?n:0*i)}if(o=sD(o),a=sD(a),s=s.slice(),i=o-a){for(i>0?(a=o,r=c):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(t=c.length)<0&&(r=c,c=s,s=r,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/tD|0,s[t]=tD===s[t]?0:s[t]%tD;return i&&(s=[i].concat(s),++a),I(e,s,a)},p.precision=p.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return lD(e,1,aD),null==t?t=y:lD(t,0,8),F(new j(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*rD+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},p.shiftedBy=function(e){return lD(e,-9007199254740991,nD),this.times("1e"+e)},p.squareRoot=p.sqrt=function(){var e,t,n,i,o,a=this,s=a.c,c=a.s,u=a.e,l=h+4,d=new j("0.5");if(1!==c||!s||!s[0])return new j(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(c=Math.sqrt(+D(a)))||c==1/0?(((t=cD(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=sD((u+1)/2)-(u<0||u%2),n=new j(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new j(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(o=n,n=d.times(o.plus(r(a,o,l,1))),cD(o.c).slice(0,c)===(t=cD(n.c)).slice(0,c)){if(n.e0&&h>0){for(o=h%s||s,l=f.substr(0,o);o0&&(l+=u+f.slice(o)),p&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},p.toFraction=function(e){var t,n,i,o,a,s,c,u,l,d,p,h,g=this,m=g.c;if(null!=e&&(!(c=new j(e)).isInteger()&&(c.c||1!==c.s)||c.lt(f)))throw Error(ZF+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+D(c));if(!m)return new j(g);for(t=new j(f),l=n=new j(f),i=u=new j(f),h=cD(m),a=t.e=h.length-g.e-1,t.c[0]=iD[(s=a%rD)<0?rD+s:s],e=!e||c.comparedTo(t)>0?a>0?t:l:c,s=v,v=1/0,c=new j(h),u.c[0]=0;d=r(c,t,0,1),1!=(o=n.plus(d.times(i))).comparedTo(e);)n=i,i=o,l=u.plus(d.times(o=l)),u=o,t=c.minus(d.times(o=t)),c=o;return o=r(e.minus(n),i,0,1),u=u.plus(o.times(l)),n=n.plus(o.times(i)),u.s=l.s=g.s,p=r(l,i,a*=2,y).minus(g).abs().comparedTo(r(u,n,a,y).minus(g).abs())<1?[l,i]:[u,n],v=s,p},p.toNumber=function(){return+D(this)},p.toPrecision=function(e,t){return null!=e&&lD(e,1,aD),A(this,e,t,2)},p.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=g||o>=m?pD(cD(r.c),o):fD(cD(r.c),o,"0"):10===e&&x?t=fD(cD((r=F(new j(r),h+o+1,y)).c),r.e,"0"):(lD(e,2,S.length,"Base"),t=n(fD(cD(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},p.valueOf=p.toJSON=function(){return D(this)},p._isBigNumber=!0,p[Symbol.toStringTag]="BigNumber",p[Symbol.for("nodejs.util.inspect.custom")]=p.valueOf,null!=t&&j.set(t),j}(),bD=o(Object.freeze({__proto__:null,BigNumber:mD,default:mD}));function vD(){if(yD)return HF;yD=1,Object.defineProperty(HF,"__esModule",{value:!0}),HF.ActorFunctionFactoryTermAddition=void 0;const e=ux(),t=sx(),r=function(){if(hD)return JF;hD=1,Object.defineProperty(JF,"__esModule",{value:!0}),JF.TermFunctionAddition=void 0;const e=ux(),t=sx(),r=bD;let n=class extends e.TermFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.ADDITION,overloads:(0,t.declare)(t.SparqlOperator.ADDITION).arithmetic(()=>(e,t)=>new r.BigNumber(e).plus(t).toNumber()).set([t.TypeURL.XSD_DATE_TIME,t.TypeURL.XSD_DAY_TIME_DURATION],()=>([e,r])=>new t.DateTimeLiteral((0,t.addDurationToDateTime)(e.typedValue,(0,t.defaultedDurationRepresentation)(r.typedValue)))).copy({from:[t.TypeURL.XSD_DATE_TIME,t.TypeURL.XSD_DAY_TIME_DURATION],to:[t.TypeURL.XSD_DATE_TIME,t.TypeURL.XSD_YEAR_MONTH_DURATION]}).set([t.TypeURL.XSD_DATE,t.TypeURL.XSD_DAY_TIME_DURATION],()=>([e,r])=>new t.DateLiteral((0,t.addDurationToDateTime)((0,t.defaultedDateTimeRepresentation)(e.typedValue),(0,t.defaultedDurationRepresentation)(r.typedValue)))).copy({from:[t.TypeURL.XSD_DATE,t.TypeURL.XSD_DAY_TIME_DURATION],to:[t.TypeURL.XSD_DATE,t.TypeURL.XSD_YEAR_MONTH_DURATION]}).set([t.TypeURL.XSD_TIME,t.TypeURL.XSD_DAY_TIME_DURATION],()=>([e,r])=>new t.TimeLiteral((0,t.addDurationToDateTime)((0,t.defaultedDateTimeRepresentation)(e.typedValue),(0,t.defaultedDurationRepresentation)(r.typedValue)))).copy({from:[t.TypeURL.XSD_TIME,t.TypeURL.XSD_DAY_TIME_DURATION],to:[t.TypeURL.XSD_TIME,t.TypeURL.XSD_YEAR_MONTH_DURATION]}).collect()})}};return JF.TermFunctionAddition=n,JF}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.ADDITION],termFunction:!0})}async run(e){return new r.TermFunctionAddition}};return HF.ActorFunctionFactoryTermAddition=n,HF}var _D,wD,TD,OD={},SD={},xD={};function jD(){if(wD)return SD;wD=1,Object.defineProperty(SD,"__esModule",{value:!0}),SD.ActorFunctionFactoryTermCeil=void 0;const e=ux(),t=sx(),r=function(){if(_D)return xD;_D=1,Object.defineProperty(xD,"__esModule",{value:!0}),xD.TermFunctionCeil=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.CEIL,overloads:(0,t.declare)(t.SparqlOperator.CEIL).numericConverter(()=>e=>Math.ceil(e)).collect()})}};return xD.TermFunctionCeil=r,xD}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.CEIL],termFunction:!0})}async run(e){return new r.TermFunctionCeil}};return SD.ActorFunctionFactoryTermCeil=n,SD}var AD,ED,ID,FD={},DD={},ND={};function PD(){if(ED)return DD;ED=1,Object.defineProperty(DD,"__esModule",{value:!0}),DD.ActorFunctionFactoryTermContains=void 0;const e=ux(),t=sx(),r=function(){if(AD)return ND;AD=1,Object.defineProperty(ND,"__esModule",{value:!0}),ND.TermFunctionContains=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.CONTAINS,overloads:(0,t.declare)(t.SparqlOperator.CONTAINS).onBinaryTyped([t.TypeAlias.SPARQL_STRINGLY,t.TypeURL.XSD_STRING],()=>(e,r)=>(0,t.bool)(e.includes(r))).onBinary([t.TypeURL.RDF_LANG_STRING,t.TypeURL.RDF_LANG_STRING],()=>(e,r)=>{if(e.language!==r.language)throw new t.IncompatibleLanguageOperation(e,r);return(0,t.bool)(e.typedValue.includes(r.typedValue))}).collect()})}};return ND.TermFunctionContains=r,ND}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.CONTAINS],termFunction:!0})}async run(e){return new r.TermFunctionContains}};return DD.ActorFunctionFactoryTermContains=n,DD}var RD,MD,LD,CD={},kD={},BD={};function UD(){if(MD)return kD;MD=1,Object.defineProperty(kD,"__esModule",{value:!0}),kD.ActorFunctionFactoryTermDatatype=void 0;const e=ux(),t=sx(),r=function(){if(RD)return BD;RD=1,Object.defineProperty(BD,"__esModule",{value:!0}),BD.TermFunctionDatatype=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.DATATYPE,overloads:(0,t.declare)(t.SparqlOperator.DATATYPE).onLiteral1(()=>e=>new t.NamedNode(e.dataType)).collect()})}};return BD.TermFunctionDatatype=r,BD}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.DATATYPE],termFunction:!0})}async run(e){return new r.TermFunctionDatatype}};return kD.ActorFunctionFactoryTermDatatype=n,kD}var $D,qD,QD,zD={},GD={},VD={};function XD(){if(qD)return GD;qD=1,Object.defineProperty(GD,"__esModule",{value:!0}),GD.ActorFunctionFactoryTermDay=void 0;const e=ux(),t=sx(),r=function(){if($D)return VD;$D=1,Object.defineProperty(VD,"__esModule",{value:!0}),VD.TermFunctionDay=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.DAY,overloads:(0,t.declare)(t.SparqlOperator.DAY).onDateTime1(()=>e=>(0,t.integer)(e.typedValue.day)).set([t.TypeURL.XSD_DATE],()=>([e])=>(0,t.integer)(e.typedValue.day)).collect()})}};return VD.TermFunctionDay=r,VD}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.DAY],termFunction:!0})}async run(e){return new r.TermFunctionDay}};return GD.ActorFunctionFactoryTermDay=n,GD}var HD,JD,WD,KD={},YD={},ZD={};function eN(){if(JD)return YD;JD=1,Object.defineProperty(YD,"__esModule",{value:!0}),YD.ActorFunctionFactoryTermEncodeForUri=void 0;const e=ux(),t=sx(),r=function(){if(HD)return ZD;HD=1,Object.defineProperty(ZD,"__esModule",{value:!0}),ZD.TermFunctionEncodeForUri=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.ENCODE_FOR_URI,overloads:(0,t.declare)(t.SparqlOperator.ENCODE_FOR_URI).onStringly1Typed(()=>e=>(0,t.string)(encodeURI(e))).collect()})}};return ZD.TermFunctionEncodeForUri=r,ZD}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.ENCODE_FOR_URI],termFunction:!0})}async run(e){return new r.TermFunctionEncodeForUri}};return YD.ActorFunctionFactoryTermEncodeForUri=n,YD}var tN,rN,nN,iN={},oN={},aN={};function sN(){if(rN)return oN;rN=1,Object.defineProperty(oN,"__esModule",{value:!0}),oN.ActorFunctionFactoryTermDivision=void 0;const e=ux(),t=sx(),r=function(){if(tN)return aN;tN=1,Object.defineProperty(aN,"__esModule",{value:!0}),aN.TermFunctionDivision=void 0;const e=ux(),t=sx(),r=bD;let n=class extends e.TermFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.DIVISION,overloads:(0,t.declare)(t.SparqlOperator.DIVISION).arithmetic(()=>(e,t)=>new r.BigNumber(e).div(t).toNumber()).onBinaryTyped([t.TypeURL.XSD_INTEGER,t.TypeURL.XSD_INTEGER],()=>(e,n)=>{if(0===n)throw new t.ExpressionError("Integer division by 0");return(0,t.decimal)(new r.BigNumber(e).div(n).toNumber())}).collect()})}};return aN.TermFunctionDivision=n,aN}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.DIVISION],termFunction:!0})}async run(e){return new r.TermFunctionDivision}};return oN.ActorFunctionFactoryTermDivision=n,oN}var cN,uN,lN,dN={},pN={},fN={};function hN(){if(uN)return pN;uN=1,Object.defineProperty(pN,"__esModule",{value:!0}),pN.ActorFunctionFactoryTermEquality=void 0;const e=ux(),t=sx(),r=function(){if(cN)return fN;cN=1,Object.defineProperty(fN,"__esModule",{value:!0}),fN.TermFunctionEquality=void 0;const e=ux(),t=y_,r=sx();let n=class extends e.TermFunctionBase{constructor(){super({arity:2,operator:r.SparqlOperator.EQUAL,overloads:(0,r.declare)(r.SparqlOperator.EQUAL).numberTest(()=>(e,t)=>e===t).stringTest(()=>(e,t)=>0===e.localeCompare(t)).set([r.TypeURL.RDF_LANG_STRING,r.TypeURL.RDF_LANG_STRING],()=>([e,t])=>(0,r.bool)(e.str()===t.str()&&e.language===t.language)).set([r.TypeAlias.SPARQL_STRINGLY,r.TypeAlias.SPARQL_STRINGLY],()=>()=>(0,r.bool)(!1)).booleanTest(()=>(e,t)=>e===t).dateTimeTest(e=>(n,i)=>(0,r.toUTCDate)(n,e.context.getSafe(t.KeysExpressionEvaluator.defaultTimeZone)).getTime()===(0,r.toUTCDate)(i,e.context.getSafe(t.KeysExpressionEvaluator.defaultTimeZone)).getTime()).copy({from:[r.TypeURL.XSD_DATE_TIME,r.TypeURL.XSD_DATE_TIME],to:[r.TypeURL.XSD_DATE,r.TypeURL.XSD_DATE]}).set(["quad","quad"],e=>([t,n])=>(0,r.bool)(this.applyOnTerms([t.subject,n.subject],e).coerceEBV()&&this.applyOnTerms([t.predicate,n.predicate],e).coerceEBV()&&this.applyOnTerms([t.object,n.object],e).coerceEBV()&&this.applyOnTerms([t.graph,n.graph],e).coerceEBV()),!1).set(["term","term"],e=>([n,i])=>{const o=n.toRDF(e.context.getSafe(t.KeysInitQuery.dataFactory)),a=i.toRDF(e.context.getSafe(t.KeysInitQuery.dataFactory)),s=o.equals(a);if(!s&&"Literal"===o.termType&&"Literal"===a.termType)throw new r.RDFEqualTypeError([n,i]);return(0,r.bool)(s)},!1).set([r.TypeURL.XSD_DURATION,r.TypeURL.XSD_DURATION],()=>([e,t])=>(0,r.bool)((0,r.yearMonthDurationsToMonths)((0,r.defaultedYearMonthDurationRepresentation)(e.typedValue))===(0,r.yearMonthDurationsToMonths)((0,r.defaultedYearMonthDurationRepresentation)(t.typedValue))&&(0,r.dayTimeDurationsToSeconds)((0,r.defaultedDayTimeDurationRepresentation)(e.typedValue))===(0,r.dayTimeDurationsToSeconds)((0,r.defaultedDayTimeDurationRepresentation)(t.typedValue)))).set([r.TypeURL.XSD_TIME,r.TypeURL.XSD_TIME],e=>([n,i])=>(0,r.bool)((0,r.toUTCDate)((0,r.defaultedDateTimeRepresentation)(n.typedValue),e.context.getSafe(t.KeysExpressionEvaluator.defaultTimeZone)).getTime()===(0,r.toUTCDate)((0,r.defaultedDateTimeRepresentation)(i.typedValue),e.context.getSafe(t.KeysExpressionEvaluator.defaultTimeZone)).getTime())).collect()})}};return fN.TermFunctionEquality=n,fN}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.EQUAL],termFunction:!0})}async run(e){return new r.TermFunctionEquality}};return pN.ActorFunctionFactoryTermEquality=n,pN}var yN,gN,mN,bN={},vN={},_N={};function wN(){if(gN)return vN;gN=1,Object.defineProperty(vN,"__esModule",{value:!0}),vN.ActorFunctionFactoryTermFloor=void 0;const e=ux(),t=sx(),r=function(){if(yN)return _N;yN=1,Object.defineProperty(_N,"__esModule",{value:!0}),_N.TermFunctionFloor=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.FLOOR,overloads:(0,t.declare)(t.SparqlOperator.FLOOR).numericConverter(()=>e=>Math.floor(e)).collect()})}};return _N.TermFunctionFloor=r,_N}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.FLOOR],termFunction:!0})}async run(e){return new r.TermFunctionFloor}};return vN.ActorFunctionFactoryTermFloor=n,vN}var TN,ON,SN,xN={},jN={},AN={};function EN(){if(ON)return jN;ON=1,Object.defineProperty(jN,"__esModule",{value:!0}),jN.ActorFunctionFactoryTermHours=void 0;const e=ux(),t=sx(),r=function(){if(TN)return AN;TN=1,Object.defineProperty(AN,"__esModule",{value:!0}),AN.TermFunctionHours=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.HOURS,overloads:(0,t.declare)(t.SparqlOperator.HOURS).onDateTime1(()=>e=>(0,t.integer)(e.typedValue.hours)).set([t.TypeURL.XSD_TIME],()=>([e])=>(0,t.integer)(e.typedValue.hours)).collect()})}};return AN.TermFunctionHours=r,AN}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.HOURS],termFunction:!0})}async run(e){return new r.TermFunctionHours}};return jN.ActorFunctionFactoryTermHours=n,jN}var IN,FN,DN,NN={},PN={},RN={};function MN(){if(FN)return PN;FN=1,Object.defineProperty(PN,"__esModule",{value:!0}),PN.ActorFunctionFactoryTermIsIri=void 0;const e=ux(),t=sx(),r=function(){if(IN)return RN;IN=1,Object.defineProperty(RN,"__esModule",{value:!0}),RN.TermFunctionIsIri=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.IS_IRI,overloads:(0,t.declare)(t.SparqlOperator.IS_IRI).onTerm1(()=>e=>(0,t.bool)("namedNode"===e.termType)).collect()})}};return RN.TermFunctionIsIri=r,RN}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IS_IRI,t.SparqlOperator.IS_URI],termFunction:!0})}async run(e){return new r.TermFunctionIsIri}};return PN.ActorFunctionFactoryTermIsIri=n,PN}var LN,CN,kN,BN={},UN={},$N={};function qN(){if(CN)return UN;CN=1,Object.defineProperty(UN,"__esModule",{value:!0}),UN.ActorFunctionFactoryTermIsBlank=void 0;const e=ux(),t=sx(),r=function(){if(LN)return $N;LN=1,Object.defineProperty($N,"__esModule",{value:!0}),$N.TermFunctionIsBlank=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.IS_BLANK,overloads:(0,t.declare)(t.SparqlOperator.IS_BLANK).onTerm1(()=>e=>(0,t.bool)("blankNode"===e.termType)).collect()})}};return $N.TermFunctionIsBlank=r,$N}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IS_BLANK],termFunction:!0})}async run(e){return new r.TermFunctionIsBlank}};return UN.ActorFunctionFactoryTermIsBlank=n,UN}var QN,zN,GN,VN={},XN={},HN={};function JN(){if(zN)return XN;zN=1,Object.defineProperty(XN,"__esModule",{value:!0}),XN.ActorFunctionFactoryTermIsLiteral=void 0;const e=ux(),t=sx(),r=function(){if(QN)return HN;QN=1,Object.defineProperty(HN,"__esModule",{value:!0}),HN.TermFunctionIsLiteral=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.IS_LITERAL,overloads:(0,t.declare)(t.SparqlOperator.IS_LITERAL).onTerm1(()=>e=>(0,t.bool)("literal"===e.termType)).collect()})}};return HN.TermFunctionIsLiteral=r,HN}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IS_LITERAL],termFunction:!0})}async run(e){return new r.TermFunctionIsLiteral}};return XN.ActorFunctionFactoryTermIsLiteral=n,XN}var WN,KN,YN,ZN,eP,tP={},rP={},nP={},iP={},oP={};function aP(){return KN||(KN=1,function(e){var t=n&&n.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=n&&n.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(function(){if(WN)return oP;function e(e){const t=[];let n=0;for(;ne.join("")).join("/")}function t(t,r){let n=r+1;r>=0?"/"===t[r+1]&&"/"===t[r+2]&&(n=r+3):"/"===t[0]&&"/"===t[1]&&(n=2);const i=t.indexOf("/",n);return i<0?t:t.substr(0,i)+e(t.substr(i))}function r(e){return!e||"#"===e||"?"===e||"/"===e}return WN=1,Object.defineProperty(oP,"__esModule",{value:!0}),oP.removeDotSegmentsOfPath=oP.removeDotSegments=oP.resolve=void 0,oP.resolve=function(r,n){const i=(n=n||"").indexOf("#");if(i>0&&(n=n.substr(0,i)),!r.length){if(n.indexOf(":")<0)throw new Error(`Found invalid baseIRI '${n}' for value '${r}'`);return n}if(r.startsWith("?")){const e=n.indexOf("?");return e>0&&(n=n.substr(0,e)),n+r}if(r.startsWith("#"))return n+r;if(!n.length){const e=r.indexOf(":");if(e<0)throw new Error(`Found invalid relative IRI '${r}' for a missing baseIRI`);return t(r,e)}const o=r.indexOf(":");if(o>=0)return t(r,o);const a=n.indexOf(":");if(a<0)throw new Error(`Found invalid baseIRI '${n}' for value '${r}'`);const s=n.substr(0,a+1);if(0===r.indexOf("//"))return s+t(r,o);let c;if(n.indexOf("//",a)===a+1){if(c=n.indexOf("/",a+3),c<0)return n.length>a+3?n+"/"+t(r,o):s+t(r,o)}else if(c=n.indexOf("/",a+1),c<0)return s+t(r,o);if(0===r.indexOf("/"))return n.substr(0,c)+e(r);let u=n.substr(c);const l=u.lastIndexOf("/");return l>=0&&li=>{const o=i[0],a=(0,n.resolve)(o.str(),e.context.get(t.KeysInitQuery.baseIRI)??"");return new r.NamedNode(a)}).onString1(e=>i=>{const o=(0,n.resolve)(i.str(),e.context.get(t.KeysInitQuery.baseIRI)??"");return new r.NamedNode(o)}).collect()})}};return nP.TermFunctionIri=i,nP}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IRI,t.SparqlOperator.URI],termFunction:!0})}async run(e){return new r.TermFunctionIri}};return rP.ActorFunctionFactoryTermIri=n,rP}var cP,uP,lP,dP={},pP={},fP={};function hP(){if(uP)return pP;uP=1,Object.defineProperty(pP,"__esModule",{value:!0}),pP.ActorFunctionFactoryTermIsNumeric=void 0;const e=ux(),t=sx(),r=function(){if(cP)return fP;cP=1,Object.defineProperty(fP,"__esModule",{value:!0}),fP.TermFunctionIsNumeric=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.IS_NUMERIC,overloads:(0,t.declare)(t.SparqlOperator.IS_NUMERIC).onNumeric1(()=>()=>(0,t.bool)(!0)).onTerm1(()=>()=>(0,t.bool)(!1)).collect()})}};return fP.TermFunctionIsNumeric=r,fP}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IS_NUMERIC],termFunction:!0})}async run(e){return new r.TermFunctionIsNumeric}};return pP.ActorFunctionFactoryTermIsNumeric=n,pP}var yP,gP,mP,bP={},vP={},_P={};function wP(){if(gP)return vP;gP=1,Object.defineProperty(vP,"__esModule",{value:!0}),vP.ActorFunctionFactoryTermLang=void 0;const e=ux(),t=sx(),r=function(){if(yP)return _P;yP=1,Object.defineProperty(_P,"__esModule",{value:!0}),_P.TermFunctionLang=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.LANG,overloads:(0,t.declare)(t.SparqlOperator.LANG).onLiteral1(()=>e=>(0,t.string)(e.language??"")).collect()})}};return _P.TermFunctionLang=r,_P}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.LANG],termFunction:!0})}async run(e){return new r.TermFunctionLang}};return vP.ActorFunctionFactoryTermLang=n,vP}var TP,OP,SP,xP={},jP={},AP={};function EP(){if(OP)return jP;OP=1,Object.defineProperty(jP,"__esModule",{value:!0}),jP.ActorFunctionFactoryTermIsTriple=void 0;const e=ux(),t=sx(),r=function(){if(TP)return AP;TP=1,Object.defineProperty(AP,"__esModule",{value:!0}),AP.TermFunctionIsTriple=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.IS_TRIPLE,overloads:(0,t.declare)(t.SparqlOperator.IS_TRIPLE).onTerm1(()=>e=>(0,t.bool)("quad"===e.termType)).collect()})}};return AP.TermFunctionIsTriple=r,AP}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.IS_TRIPLE],termFunction:!0})}async run(e){return new r.TermFunctionIsTriple}};return jP.ActorFunctionFactoryTermIsTriple=n,jP}var IP,FP,DP,NP={},PP={},RP={};function MP(){if(FP)return PP;FP=1,Object.defineProperty(PP,"__esModule",{value:!0}),PP.ActorFunctionFactoryTermLangmatches=void 0;const e=ux(),t=sx(),r=function(){if(IP)return RP;IP=1,Object.defineProperty(RP,"__esModule",{value:!0}),RP.TermFunctionLangmatches=void 0;const e=ux(),t=sx();let r=class r extends e.TermFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.LANG_MATCHES,overloads:(0,t.declare)(t.SparqlOperator.LANG_MATCHES).onBinaryTyped([t.TypeURL.XSD_STRING,t.TypeURL.XSD_STRING],()=>(e,n)=>(0,t.bool)(r.langMatches(e,n))).collect()})}static langMatches(e,t){const n=e.split("-"),i=t.split("-");if(!r.matchLangTag(i[0],n[0])&&!r.isWildCard(n[0]))return!1;let o=1,a=1;for(;ae=>(0,t.integer)(e.typedValue.minutes)).set([t.TypeURL.XSD_TIME],()=>([e])=>(0,t.integer)(e.typedValue.minutes)).collect()})}};return $P.TermFunctionMinutes=r,$P}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.MINUTES],termFunction:!0})}async run(e){return new r.TermFunctionMinutes}};return UP.ActorFunctionFactoryTermMinutes=n,UP}var QP,zP,GP,VP={},XP={},HP={};function JP(){if(zP)return XP;zP=1,Object.defineProperty(XP,"__esModule",{value:!0}),XP.ActorFunctionFactoryTermLcase=void 0;const e=ux(),t=sx(),r=function(){if(QP)return HP;QP=1,Object.defineProperty(HP,"__esModule",{value:!0}),HP.TermFunctionLcase=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.LCASE,overloads:(0,t.declare)(t.SparqlOperator.LCASE).onString1Typed(()=>e=>(0,t.string)(e.toLowerCase())).onLangString1(()=>e=>(0,t.langString)(e.typedValue.toLowerCase(),e.language)).collect()})}};return HP.TermFunctionLcase=r,HP}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.LCASE],termFunction:!0})}async run(e){return new r.TermFunctionLcase}};return XP.ActorFunctionFactoryTermLcase=n,XP}var WP,KP,YP,ZP,eR={},tR={},rR={},nR={exports:{}};function iR(){return WP||(WP=1,nR.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function r(e,t){var r=e[0],n=e[1],i=e[2],o=e[3];n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&i|~n&o)+t[0]-680876936|0)<<7|r>>>25)+n|0)&n|~r&i)+t[1]-389564586|0)<<12|o>>>20)+r|0)&r|~o&n)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&r)+t[3]-1044525330|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&i|~n&o)+t[4]-176418897|0)<<7|r>>>25)+n|0)&n|~r&i)+t[5]+1200080426|0)<<12|o>>>20)+r|0)&r|~o&n)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&r)+t[7]-45705983|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&i|~n&o)+t[8]+1770035416|0)<<7|r>>>25)+n|0)&n|~r&i)+t[9]-1958414417|0)<<12|o>>>20)+r|0)&r|~o&n)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&r)+t[11]-1990404162|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&i|~n&o)+t[12]+1804603682|0)<<7|r>>>25)+n|0)&n|~r&i)+t[13]-40341101|0)<<12|o>>>20)+r|0)&r|~o&n)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&r)+t[15]+1236535329|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&o|i&~o)+t[1]-165796510|0)<<5|r>>>27)+n|0)&i|n&~i)+t[6]-1069501632|0)<<9|o>>>23)+r|0)&n|r&~n)+t[11]+643717713|0)<<14|i>>>18)+o|0)&r|o&~r)+t[0]-373897302|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&o|i&~o)+t[5]-701558691|0)<<5|r>>>27)+n|0)&i|n&~i)+t[10]+38016083|0)<<9|o>>>23)+r|0)&n|r&~n)+t[15]-660478335|0)<<14|i>>>18)+o|0)&r|o&~r)+t[4]-405537848|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&o|i&~o)+t[9]+568446438|0)<<5|r>>>27)+n|0)&i|n&~i)+t[14]-1019803690|0)<<9|o>>>23)+r|0)&n|r&~n)+t[3]-187363961|0)<<14|i>>>18)+o|0)&r|o&~r)+t[8]+1163531501|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n&o|i&~o)+t[13]-1444681467|0)<<5|r>>>27)+n|0)&i|n&~i)+t[2]-51403784|0)<<9|o>>>23)+r|0)&n|r&~n)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&r|o&~r)+t[12]-1926607734|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n^i^o)+t[5]-378558|0)<<4|r>>>28)+n|0)^n^i)+t[8]-2022574463|0)<<11|o>>>21)+r|0)^r^n)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^r)+t[14]-35309556|0)<<23|n>>>9)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n^i^o)+t[1]-1530992060|0)<<4|r>>>28)+n|0)^n^i)+t[4]+1272893353|0)<<11|o>>>21)+r|0)^r^n)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^r)+t[10]-1094730640|0)<<23|n>>>9)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n^i^o)+t[13]+681279174|0)<<4|r>>>28)+n|0)^n^i)+t[0]-358537222|0)<<11|o>>>21)+r|0)^r^n)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^r)+t[6]+76029189|0)<<23|n>>>9)+i|0,n=((n+=((i=((i+=((o=((o+=((r=((r+=(n^i^o)+t[9]-640364487|0)<<4|r>>>28)+n|0)^n^i)+t[12]-421815835|0)<<11|o>>>21)+r|0)^r^n)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^r)+t[2]-995338651|0)<<23|n>>>9)+i|0,n=((n+=((o=((o+=(n^((r=((r+=(i^(n|~o))+t[0]-198630844|0)<<6|r>>>26)+n|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+r|0)^((i=((i+=(r^(o|~n))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~r))+t[5]-57434055|0)<<21|n>>>11)+i|0,n=((n+=((o=((o+=(n^((r=((r+=(i^(n|~o))+t[12]+1700485571|0)<<6|r>>>26)+n|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+r|0)^((i=((i+=(r^(o|~n))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~r))+t[1]-2054922799|0)<<21|n>>>11)+i|0,n=((n+=((o=((o+=(n^((r=((r+=(i^(n|~o))+t[8]+1873313359|0)<<6|r>>>26)+n|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+r|0)^((i=((i+=(r^(o|~n))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~r))+t[13]+1309151649|0)<<21|n>>>11)+i|0,n=((n+=((o=((o+=(n^((r=((r+=(i^(n|~o))+t[4]-145523070|0)<<6|r>>>26)+n|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+r|0)^((i=((i+=(r^(o|~n))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~r))+t[9]-343485551|0)<<21|n>>>11)+i|0,e[0]=r+e[0]|0,e[1]=n+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function n(e){var t,r=[];for(t=0;t<64;t+=4)r[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return r}function i(e){var t,r=[];for(t=0;t<64;t+=4)r[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return r}function o(e){var t,i,o,a,s,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)r(l,n(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(r(l,o),t=0;t<16;t+=1)o[t]=0;return a=(a=8*u).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),c=parseInt(a[1],16)||0,o[14]=s,o[15]=c,r(l,o),l}function a(e){var t,n,o,a,s,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)r(l,i(e.subarray(t-64,t)));for(n=(e=t-64>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(r(l,o),t=0;t<16;t+=1)o[t]=0;return a=(a=8*u).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),c=parseInt(a[1],16)||0,o[14]=s,o[15]=c,r(l,o),l}function s(e){var r,n="";for(r=0;r<4;r+=1)n+=t[e>>8*r+4&15]+t[e>>8*r&15];return n}function c(e){var t;for(t=0;tl?new ArrayBuffer(0):(i=l-u,o=new ArrayBuffer(i),a=new Uint8Array(o),s=new Uint8Array(this,u,i),a.set(s),o)}}(),h.prototype.append=function(e){return this.appendBinary(u(e)),this},h.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)r(this._hash,n(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},h.prototype.end=function(e){var t,r,n=this._buff,i=n.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t>2]|=n.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),r=c(this._hash),e&&(r=f(r)),this.reset(),r},h.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},h.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},h.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},h.prototype._finish=function(e,t){var n,i,o,a=t;if(e[a>>2]|=128<<(a%4<<3),a>55)for(r(this._hash,e),a=0;a<16;a+=1)e[a]=0;n=(n=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(n[2],16),o=parseInt(n[1],16)||0,e[14]=i,e[15]=o,r(this._hash,e)},h.hash=function(e,t){return h.hashBinary(u(e),t)},h.hashBinary=function(e,t){var r=c(o(e));return t?f(r):r},h.ArrayBuffer=function(){this.reset()},h.ArrayBuffer.prototype.append=function(e){var t,n=p(this._buff.buffer,e),o=n.length;for(this._length+=e.byteLength,t=64;t<=o;t+=64)r(this._hash,i(n.subarray(t-64,t)));return this._buff=t-64>2]|=n[t]<<(t%4<<3);return this._finish(o,i),r=c(this._hash),e&&(r=f(r)),this.reset(),r},h.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.ArrayBuffer.prototype.getState=function(){var e=h.prototype.getState.call(this);return e.buff=d(e.buff),e},h.ArrayBuffer.prototype.setState=function(e){return e.buff=l(e.buff,!0),h.prototype.setState.call(this,e)},h.ArrayBuffer.prototype.destroy=h.prototype.destroy,h.ArrayBuffer.prototype._finish=h.prototype._finish,h.ArrayBuffer.hash=function(e,t){var r=c(a(new Uint8Array(e)));return t?f(r):r},h}()),nR.exports}function oR(){if(YP)return tR;YP=1,Object.defineProperty(tR,"__esModule",{value:!0}),tR.ActorFunctionFactoryTermMd5=void 0;const e=ux(),t=sx(),r=function(){if(KP)return rR;KP=1,Object.defineProperty(rR,"__esModule",{value:!0}),rR.TermFunctionMd5=void 0;const e=ux(),t=sx(),r=iR();let n=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.MD5,overloads:(0,t.declare)(t.SparqlOperator.MD5).onString1Typed(()=>e=>(0,t.string)((0,r.hash)(e))).collect()})}};return rR.TermFunctionMd5=n,rR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.MD5],termFunction:!0})}async run(e){return new r.TermFunctionMd5}};return tR.ActorFunctionFactoryTermMd5=n,tR}var aR,sR,cR,uR={},lR={},dR={};function pR(){if(sR)return lR;sR=1,Object.defineProperty(lR,"__esModule",{value:!0}),lR.ActorFunctionFactoryTermMonth=void 0;const e=ux(),t=sx(),r=function(){if(aR)return dR;aR=1,Object.defineProperty(dR,"__esModule",{value:!0}),dR.TermFunctionMonth=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.MONTH,overloads:(0,t.declare)(t.SparqlOperator.MONTH).onDateTime1(()=>e=>(0,t.integer)(e.typedValue.month)).set([t.TypeURL.XSD_DATE],()=>([e])=>(0,t.integer)(e.typedValue.month)).collect()})}};return dR.TermFunctionMonth=r,dR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.MONTH],termFunction:!0})}async run(e){return new r.TermFunctionMonth}};return lR.ActorFunctionFactoryTermMonth=n,lR}var fR,hR,yR,gR={},mR={},bR={};function vR(){if(hR)return mR;hR=1,Object.defineProperty(mR,"__esModule",{value:!0}),mR.ActorFunctionFactoryTermNot=void 0;const e=ux(),t=sx(),r=function(){if(fR)return bR;fR=1,Object.defineProperty(bR,"__esModule",{value:!0}),bR.TermFunctionNot=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.NOT,overloads:(0,t.declare)(t.SparqlOperator.NOT).onTerm1(()=>e=>(0,t.bool)(!e.coerceEBV())).collect()})}};return bR.TermFunctionNot=r,bR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.NOT],termFunction:!0})}async run(e){return new r.TermFunctionNot}};return mR.ActorFunctionFactoryTermNot=n,mR}var _R,wR,TR,OR={},SR={},xR={};function jR(){if(wR)return SR;wR=1,Object.defineProperty(SR,"__esModule",{value:!0}),SR.ActorFunctionFactoryTermMultiplication=void 0;const e=ux(),t=sx(),r=function(){if(_R)return xR;_R=1,Object.defineProperty(xR,"__esModule",{value:!0}),xR.TermFunctionMultiplication=void 0;const e=ux(),t=sx(),r=bD;let n=class extends e.TermFunctionBase{constructor(){super({arity:2,operator:t.SparqlOperator.MULTIPLICATION,overloads:(0,t.declare)(t.SparqlOperator.MULTIPLICATION).arithmetic(()=>(e,t)=>new r.BigNumber(e).times(t).toNumber()).collect()})}};return xR.TermFunctionMultiplication=n,xR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.MULTIPLICATION],termFunction:!0})}async run(e){return new r.TermFunctionMultiplication}};return SR.ActorFunctionFactoryTermMultiplication=n,SR}var AR,ER,IR,FR={},DR={},NR={};function PR(){if(ER)return DR;ER=1,Object.defineProperty(DR,"__esModule",{value:!0}),DR.ActorFunctionFactoryTermNow=void 0;const e=ux(),t=sx(),r=function(){if(AR)return NR;AR=1,Object.defineProperty(NR,"__esModule",{value:!0}),NR.TermFunctionNow=void 0;const e=ux(),t=y_,r=sx();let n=class extends e.TermFunctionBase{constructor(){super({arity:0,operator:r.SparqlOperator.NOW,overloads:(0,r.declare)(r.SparqlOperator.NOW).set([],e=>()=>new r.DateTimeLiteral((0,r.toDateTimeRepresentation)({date:e.context.getSafe(t.KeysInitQuery.queryTimestamp),timeZone:e.context.getSafe(t.KeysExpressionEvaluator.defaultTimeZone)}))).collect()})}};return NR.TermFunctionNow=n,NR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.NOW],termFunction:!0})}async run(e){return new r.TermFunctionNow}};return DR.ActorFunctionFactoryTermNow=n,DR}var RR,MR,LR,CR={},kR={},BR={};function UR(){if(MR)return kR;MR=1,Object.defineProperty(kR,"__esModule",{value:!0}),kR.ActorFunctionFactoryTermObject=void 0;const e=ux(),t=sx(),r=function(){if(RR)return BR;RR=1,Object.defineProperty(BR,"__esModule",{value:!0}),BR.TermFunctionObject=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.OBJECT,overloads:(0,t.declare)(t.SparqlOperator.OBJECT).onQuad1(()=>e=>e.object).collect()})}};return BR.TermFunctionObject=r,BR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.OBJECT],termFunction:!0})}async run(e){return new r.TermFunctionObject}};return kR.ActorFunctionFactoryTermObject=n,kR}var $R,qR,QR,zR={},GR={},VR={};function XR(){if(qR)return GR;qR=1,Object.defineProperty(GR,"__esModule",{value:!0}),GR.ActorFunctionFactoryTermPredicate=void 0;const e=ux(),t=sx(),r=function(){if($R)return VR;$R=1,Object.defineProperty(VR,"__esModule",{value:!0}),VR.TermFunctionPredicate=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.PREDICATE,overloads:(0,t.declare)(t.SparqlOperator.PREDICATE).onQuad1(()=>e=>e.predicate).collect()})}};return VR.TermFunctionPredicate=r,VR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.PREDICATE],termFunction:!0})}async run(e){return new r.TermFunctionPredicate}};return GR.ActorFunctionFactoryTermPredicate=n,GR}var HR,JR,WR,KR={},YR={},ZR={};function eM(){if(JR)return YR;JR=1,Object.defineProperty(YR,"__esModule",{value:!0}),YR.ActorFunctionFactoryTermRand=void 0;const e=ux(),t=sx(),r=function(){if(HR)return ZR;HR=1,Object.defineProperty(ZR,"__esModule",{value:!0}),ZR.TermFunctionRand=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:0,operator:t.SparqlOperator.RAND,overloads:(0,t.declare)(t.SparqlOperator.RAND).set([],()=>()=>(0,t.double)(Math.random())).collect()})}};return ZR.TermFunctionRand=r,ZR}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.RAND],termFunction:!0})}async run(e){return new r.TermFunctionRand}};return YR.ActorFunctionFactoryTermRand=n,YR}var tM,rM,nM,iM,oM,aM,sM={},cM={},uM={},lM={},dM={},pM={};function fM(){if(tM)return pM;tM=1,Object.defineProperty(pM,"__esModule",{value:!0}),pM.TermFunctionRegex=void 0;const e=ux(),t=sx();let r=class r extends e.TermFunctionBase{constructor(){super({arity:[2,3],operator:t.SparqlOperator.REGEX,overloads:(0,t.declare)(t.SparqlOperator.REGEX).onBinaryTyped([t.TypeAlias.SPARQL_STRINGLY,t.TypeURL.XSD_STRING],r.regex2).onTernaryTyped([t.TypeAlias.SPARQL_STRINGLY,t.TypeURL.XSD_STRING,t.TypeURL.XSD_STRING],r.regex3).collect()})}static regex2(){return(e,n)=>(0,t.bool)(r.matches(e,n))}static regex3(){return(e,n,i)=>(0,t.bool)(r.matches(e,n,i))}static matches(e,t,n=""){(n=r.cleanFlags(n)).includes("x")&&(t=r.flagX(t)),n.includes("q")&&(t=r.flagQ(t));return new RegExp(t,n.replaceAll(/[qx]/gu,"")).test(e)}static cleanFlags(e){if(!/^[imsxq]*$/u.test(e))throw new Error("Invalid flags");const t=[...e].find((e,t,r)=>r.indexOf(e)!==t);if(t)throw new Error(`Duplicate flag: ${t}`);return e?.includes("q")&&(e=e.replaceAll(/[msx]/gu,"")),`${e}u`}static flagX(e){if(!e)return e;let t=e[0];for(;["\t","\n","\r"," "].includes(t);)t=(e=e.slice(1))[0];let r="["===t;for(let n=1;n(e,t,i)=>(0,r.string)(n.replace(e,t,i))).set([r.TypeURL.RDF_LANG_STRING,r.TypeURL.XSD_STRING,r.TypeURL.XSD_STRING],()=>([e,t,i])=>{const o=n.replace(e.typedValue,t.typedValue,i.typedValue);return(0,r.langString)(o,e.language)}).onQuaternaryTyped([r.TypeURL.XSD_STRING,r.TypeURL.XSD_STRING,r.TypeURL.XSD_STRING,r.TypeURL.XSD_STRING],()=>(e,t,i,o)=>(0,r.string)(n.replace(e,t,i,o))).set([r.TypeURL.RDF_LANG_STRING,r.TypeURL.XSD_STRING,r.TypeURL.XSD_STRING,r.TypeURL.XSD_STRING],()=>([e,t,i,o])=>{const a=n.replace(e.typedValue,t.typedValue,i.typedValue,o.typedValue);return(0,r.langString)(a,e.language)}).collect()})}static replace(t,r,n,i=""){return(i=e.TermFunctionRegex.cleanFlags(i)).includes("x")&&(r=e.TermFunctionRegex.flagX(r)),i.includes("q")?r=e.TermFunctionRegex.flagQ(r):n=n.replaceAll("$0",()=>"$&"),i=`${i.replaceAll(/[qx]/gu,"")}g`,t.replaceAll(new RegExp(r,i),n)}};return uM.TermFunctionReplace=n,uM}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.REPLACE],termFunction:!0})}async run(e){return new r.TermFunctionReplace}};return cM.ActorFunctionFactoryTermReplace=n,cM}var gM,mM,bM,vM={},_M={},wM={};function TM(){if(mM)return _M;mM=1,Object.defineProperty(_M,"__esModule",{value:!0}),_M.ActorFunctionFactoryTermRound=void 0;const e=ux(),t=sx(),r=function(){if(gM)return wM;gM=1,Object.defineProperty(wM,"__esModule",{value:!0}),wM.TermFunctionRound=void 0;const e=ux(),t=sx();let r=class extends e.TermFunctionBase{constructor(){super({arity:1,operator:t.SparqlOperator.ROUND,overloads:(0,t.declare)(t.SparqlOperator.ROUND).numericConverter(()=>e=>Math.round(e)).collect()})}};return wM.TermFunctionRound=r,wM}();let n=class extends e.ActorFunctionFactoryDedicated{constructor(e){super({...e,functionNames:[t.SparqlOperator.ROUND],termFunction:!0})}async run(e){return new r.TermFunctionRound}};return _M.ActorFunctionFactoryTermRound=n,_M}var OM,SM,xM={},jM={},AM={},EM={},IM={};function FM(){if(SM)return OM;function e(e,t){if(!e)throw new Error(t||"Assertion failed")}return SM=1,OM=e,e.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)},OM}var DM,NM,PM={exports:{}};function RM(){if(NM)return IM;NM=1;var e=FM(),t=(DM||(DM=1,"function"==typeof Object.create?PM.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:PM.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),PM.exports);function r(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function n(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function i(e){return 1===e.length?"0"+e:e}function o(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}return IM.inherits=t,IM.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),o=0;o>6|192,n[i++]=63&a|128):r(e,o)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++o)),n[i++]=a>>18|240,n[i++]=a>>12&63|128,n[i++]=a>>6&63|128,n[i++]=63&a|128):(n[i++]=a>>12|224,n[i++]=a>>6&63|128,n[i++]=63&a|128)}else for(o=0;o>>0}return a},IM.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},IM.rotr32=function(e,t){return e>>>t|e<<32-t},IM.rotl32=function(e,t){return e<>>32-t},IM.sum32=function(e,t){return e+t>>>0},IM.sum32_3=function(e,t,r){return e+t+r>>>0},IM.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},IM.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},IM.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},IM.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},IM.sum64_lo=function(e,t,r,n){return t+n>>>0},IM.sum64_4_hi=function(e,t,r,n,i,o,a,s){var c=0,u=t;return c+=(u=u+n>>>0)>>0)>>0)>>0},IM.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},IM.sum64_5_hi=function(e,t,r,n,i,o,a,s,c,u){var l=0,d=t;return l+=(d=d+n>>>0)>>0)>>0)>>0)>>0},IM.sum64_5_lo=function(e,t,r,n,i,o,a,s,c,u){return t+n+o+s+u>>>0},IM.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},IM.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},IM.shr64_hi=function(e,t,r){return e>>>r},IM.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},IM}var MM,LM={};function CM(){if(MM)return LM;MM=1;var e=RM(),t=FM();function r(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}return LM.BlockHash=r,r.prototype.update=function(t,r){if(t=e.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=e.join32(t,0,t.length-n,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},KM.g1_256=function(t){return e(t,17)^e(t,19)^t>>>10},KM}function ZM(){if(qM)return $M;qM=1;var e=RM(),t=CM(),r=YM(),n=FM(),i=e.sum32,o=e.sum32_4,a=e.sum32_5,s=r.ch32,c=r.maj32,u=r.s0_256,l=r.s1_256,d=r.g0_256,p=r.g1_256,f=t.BlockHash,h=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function y(){if(!(this instanceof y))return new y;f.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=h,this.W=new Array(64)}return e.inherits(y,f),$M=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(e,t){for(var r=this.W,f=0;f<16;f++)r[f]=e[t+f];for(;f