@origintrail-official/dkg-node-ui 0.0.1-dev.1773506972.23bf9c0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +49 -0
  3. package/dist/api.d.ts +30 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +805 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/chat-assistant.d.ts +68 -0
  8. package/dist/chat-assistant.d.ts.map +1 -0
  9. package/dist/chat-assistant.js +663 -0
  10. package/dist/chat-assistant.js.map +1 -0
  11. package/dist/chat-memory.d.ts +171 -0
  12. package/dist/chat-memory.d.ts.map +1 -0
  13. package/dist/chat-memory.js +985 -0
  14. package/dist/chat-memory.js.map +1 -0
  15. package/dist/chat-persistence-queue.d.ts +67 -0
  16. package/dist/chat-persistence-queue.d.ts.map +1 -0
  17. package/dist/chat-persistence-queue.js +245 -0
  18. package/dist/chat-persistence-queue.js.map +1 -0
  19. package/dist/db.d.ts +402 -0
  20. package/dist/db.d.ts.map +1 -0
  21. package/dist/db.js +887 -0
  22. package/dist/db.js.map +1 -0
  23. package/dist/gelf-push-worker.d.ts +67 -0
  24. package/dist/gelf-push-worker.d.ts.map +1 -0
  25. package/dist/gelf-push-worker.js +147 -0
  26. package/dist/gelf-push-worker.js.map +1 -0
  27. package/dist/index.d.ts +20 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +12 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/llm/capability-resolver.d.ts +3 -0
  32. package/dist/llm/capability-resolver.d.ts.map +1 -0
  33. package/dist/llm/capability-resolver.js +21 -0
  34. package/dist/llm/capability-resolver.js.map +1 -0
  35. package/dist/llm/client.d.ts +23 -0
  36. package/dist/llm/client.d.ts.map +1 -0
  37. package/dist/llm/client.js +91 -0
  38. package/dist/llm/client.js.map +1 -0
  39. package/dist/llm/provider-adapter.d.ts +16 -0
  40. package/dist/llm/provider-adapter.d.ts.map +1 -0
  41. package/dist/llm/provider-adapter.js +199 -0
  42. package/dist/llm/provider-adapter.js.map +1 -0
  43. package/dist/llm/types.d.ts +64 -0
  44. package/dist/llm/types.d.ts.map +1 -0
  45. package/dist/llm/types.js +2 -0
  46. package/dist/llm/types.js.map +1 -0
  47. package/dist/metrics-collector.d.ts +36 -0
  48. package/dist/metrics-collector.d.ts.map +1 -0
  49. package/dist/metrics-collector.js +155 -0
  50. package/dist/metrics-collector.js.map +1 -0
  51. package/dist/operation-tracker.d.ts +43 -0
  52. package/dist/operation-tracker.d.ts.map +1 -0
  53. package/dist/operation-tracker.js +195 -0
  54. package/dist/operation-tracker.js.map +1 -0
  55. package/dist/structured-logger.d.ts +16 -0
  56. package/dist/structured-logger.d.ts.map +1 -0
  57. package/dist/structured-logger.js +41 -0
  58. package/dist/structured-logger.js.map +1 -0
  59. package/dist/telemetry.d.ts +35 -0
  60. package/dist/telemetry.d.ts.map +1 -0
  61. package/dist/telemetry.js +45 -0
  62. package/dist/telemetry.js.map +1 -0
  63. package/dist-ui/assets/3d-force-graph-nMUNmvtB.js +964 -0
  64. package/dist-ui/assets/AgentHub-XKCM9uYQ.js +65 -0
  65. package/dist-ui/assets/AppHost-DoLIi89g.js +1 -0
  66. package/dist-ui/assets/Apps-Cc8HfqfD.js +1 -0
  67. package/dist-ui/assets/Dashboard-D5q6MK78.js +2 -0
  68. package/dist-ui/assets/Explorer-B80RVksc.js +64 -0
  69. package/dist-ui/assets/N3Parser-Q_-1ZY5E.js +7 -0
  70. package/dist-ui/assets/Settings-CG7-7GM-.js +71 -0
  71. package/dist-ui/assets/hooks-BLTFNmyP.js +1 -0
  72. package/dist-ui/assets/index-8_35CUX2.js +192 -0
  73. package/dist-ui/assets/index-CKZq_ZB-.css +1 -0
  74. package/dist-ui/assets/index-DH-l6lM0.js +76 -0
  75. package/dist-ui/assets/jsonld-32FQRO67-DhbO8O6B.js +2 -0
  76. package/dist-ui/assets/jsonld-BFI4wECl.js +62 -0
  77. package/dist-ui/assets/ntriples-ZWBY2WET-nIpilpjf.js +1 -0
  78. package/dist-ui/assets/ordinal-DIohFSkg.js +1 -0
  79. package/dist-ui/assets/renderer-3d-2EVDZII7-DsxBsJvs.js +2 -0
  80. package/dist-ui/assets/three.module-uCjFke6H.js +4019 -0
  81. package/dist-ui/assets/turtle-JJPK7LJ5-zezDJZEp.js +1 -0
  82. package/dist-ui/favicon.png +0 -0
  83. package/dist-ui/index.html +14 -0
  84. package/package.json +58 -0
@@ -0,0 +1,7 @@
1
+ var ne={},z={},ge;function Ze(){if(ge)return z;ge=1,z.byteLength=s,z.toByteArray=B,z.fromByteArray=m;for(var d=[],r=[],h=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,_=a.length;c<_;++c)d[c]=a[c],r[a.charCodeAt(c)]=c;r[45]=62,r[95]=63;function l(y){var p=y.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var g=y.indexOf("=");g===-1&&(g=p);var F=g===p?0:4-g%4;return[g,F]}function s(y){var p=l(y),g=p[0],F=p[1];return(g+F)*3/4-F}function b(y,p,g){return(p+g)*3/4-g}function B(y){var p,g=l(y),F=g[0],j=g[1],S=new h(b(y,F,j)),U=0,$=j>0?F-4:F,T;for(T=0;T<$;T+=4)p=r[y.charCodeAt(T)]<<18|r[y.charCodeAt(T+1)]<<12|r[y.charCodeAt(T+2)]<<6|r[y.charCodeAt(T+3)],S[U++]=p>>16&255,S[U++]=p>>8&255,S[U++]=p&255;return j===2&&(p=r[y.charCodeAt(T)]<<2|r[y.charCodeAt(T+1)]>>4,S[U++]=p&255),j===1&&(p=r[y.charCodeAt(T)]<<10|r[y.charCodeAt(T+1)]<<4|r[y.charCodeAt(T+2)]>>2,S[U++]=p>>8&255,S[U++]=p&255),S}function E(y){return d[y>>18&63]+d[y>>12&63]+d[y>>6&63]+d[y&63]}function x(y,p,g){for(var F,j=[],S=p;S<g;S+=3)F=(y[S]<<16&16711680)+(y[S+1]<<8&65280)+(y[S+2]&255),j.push(E(F));return j.join("")}function m(y){for(var p,g=y.length,F=g%3,j=[],S=16383,U=0,$=g-F;U<$;U+=S)j.push(x(y,U,U+S>$?$:U+S));return F===1?(p=y[g-1],j.push(d[p>>2]+d[p<<4&63]+"==")):F===2&&(p=(y[g-2]<<8)+y[g-1],j.push(d[p>>10]+d[p>>4&63]+d[p<<2&63]+"=")),j.join("")}return z}var X={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var be;function We(){return be||(be=1,X.read=function(d,r,h,a,c){var _,l,s=c*8-a-1,b=(1<<s)-1,B=b>>1,E=-7,x=h?c-1:0,m=h?-1:1,y=d[r+x];for(x+=m,_=y&(1<<-E)-1,y>>=-E,E+=s;E>0;_=_*256+d[r+x],x+=m,E-=8);for(l=_&(1<<-E)-1,_>>=-E,E+=a;E>0;l=l*256+d[r+x],x+=m,E-=8);if(_===0)_=1-B;else{if(_===b)return l?NaN:(y?-1:1)*(1/0);l=l+Math.pow(2,a),_=_-B}return(y?-1:1)*l*Math.pow(2,_-a)},X.write=function(d,r,h,a,c,_){var l,s,b,B=_*8-c-1,E=(1<<B)-1,x=E>>1,m=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=a?0:_-1,p=a?1:-1,g=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,l=E):(l=Math.floor(Math.log(r)/Math.LN2),r*(b=Math.pow(2,-l))<1&&(l--,b*=2),l+x>=1?r+=m/b:r+=m*Math.pow(2,1-x),r*b>=2&&(l++,b/=2),l+x>=E?(s=0,l=E):l+x>=1?(s=(r*b-1)*Math.pow(2,c),l=l+x):(s=r*Math.pow(2,x-1)*Math.pow(2,c),l=0));c>=8;d[h+y]=s&255,y+=p,s/=256,c-=8);for(l=l<<c|s,B+=c;B>0;d[h+y]=l&255,y+=p,l/=256,B-=8);d[h+y-p]|=g*128}),X}/*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */var me;function Xe(){return me||(me=1,(function(d){const r=Ze(),h=We(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;d.Buffer=s,d.SlowBuffer=S,d.INSPECT_MAX_BYTES=50;const c=2147483647;d.kMaxLength=c,s.TYPED_ARRAY_SUPPORT=_(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function _(){try{const i=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(i,e),i.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function l(i){if(i>c)throw new RangeError('The value "'+i+'" is invalid for option "size"');const e=new Uint8Array(i);return Object.setPrototypeOf(e,s.prototype),e}function s(i,e,t){if(typeof i=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(i)}return b(i,e,t)}s.poolSize=8192;function b(i,e,t){if(typeof i=="string")return m(i,e);if(ArrayBuffer.isView(i))return p(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(k(i,ArrayBuffer)||i&&k(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(k(i,SharedArrayBuffer)||i&&k(i.buffer,SharedArrayBuffer)))return g(i,e,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const n=i.valueOf&&i.valueOf();if(n!=null&&n!==i)return s.from(n,e,t);const u=F(i);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return s.from(i[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}s.from=function(i,e,t){return b(i,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function B(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function E(i,e,t){return B(i),i<=0?l(i):e!==void 0?typeof t=="string"?l(i).fill(e,t):l(i).fill(e):l(i)}s.alloc=function(i,e,t){return E(i,e,t)};function x(i){return B(i),l(i<0?0:j(i)|0)}s.allocUnsafe=function(i){return x(i)},s.allocUnsafeSlow=function(i){return x(i)};function m(i,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const t=U(i,e)|0;let n=l(t);const u=n.write(i,e);return u!==t&&(n=n.slice(0,u)),n}function y(i){const e=i.length<0?0:j(i.length)|0,t=l(e);for(let n=0;n<e;n+=1)t[n]=i[n]&255;return t}function p(i){if(k(i,Uint8Array)){const e=new Uint8Array(i);return g(e.buffer,e.byteOffset,e.byteLength)}return y(i)}function g(i,e,t){if(e<0||i.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(i):t===void 0?n=new Uint8Array(i,e):n=new Uint8Array(i,e,t),Object.setPrototypeOf(n,s.prototype),n}function F(i){if(s.isBuffer(i)){const e=j(i.length)|0,t=l(e);return t.length===0||i.copy(t,0,0,e),t}if(i.length!==void 0)return typeof i.length!="number"||ie(i.length)?l(0):y(i);if(i.type==="Buffer"&&Array.isArray(i.data))return y(i.data)}function j(i){if(i>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return i|0}function S(i){return+i!=i&&(i=0),s.alloc(+i)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(k(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),k(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,u=t.length;for(let f=0,o=Math.min(n,u);f<o;++f)if(e[f]!==t[f]){n=e[f],u=t[f];break}return n<u?-1:u<n?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;const u=s.allocUnsafe(t);let f=0;for(n=0;n<e.length;++n){let o=e[n];if(k(o,Uint8Array))f+o.length>u.length?(s.isBuffer(o)||(o=s.from(o)),o.copy(u,f)):Uint8Array.prototype.set.call(u,o,f);else if(s.isBuffer(o))o.copy(u,f);else throw new TypeError('"list" argument must be an Array of Buffers');f+=o.length}return u};function U(i,e){if(s.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||k(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const t=i.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let u=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return re(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ye(i).length;default:if(u)return n?-1:re(i).length;e=(""+e).toLowerCase(),u=!0}}s.byteLength=U;function $(i,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return Oe(this,e,t);case"utf8":case"utf-8":return he(this,e,t);case"ascii":return Me(this,e,t);case"latin1":case"binary":return $e(this,e,t);case"base64":return ke(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function T(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}s.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;t<e;t+=2)T(this,t,t+1);return this},s.prototype.swap32=function(){const e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)T(this,t,t+3),T(this,t+1,t+2);return this},s.prototype.swap64=function(){const e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)T(this,t,t+7),T(this,t+1,t+6),T(this,t+2,t+5),T(this,t+3,t+4);return this},s.prototype.toString=function(){const e=this.length;return e===0?"":arguments.length===0?he(this,0,e):$.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="";const t=d.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,n,u,f){if(k(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),u===void 0&&(u=0),f===void 0&&(f=this.length),t<0||n>e.length||u<0||f>this.length)throw new RangeError("out of range index");if(u>=f&&t>=n)return 0;if(u>=f)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,u>>>=0,f>>>=0,this===e)return 0;let o=f-u,w=n-t;const A=Math.min(o,w),R=this.slice(u,f),N=e.slice(t,n);for(let I=0;I<A;++I)if(R[I]!==N[I]){o=R[I],w=N[I];break}return o<w?-1:w<o?1:0};function ue(i,e,t,n,u){if(i.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ie(t)&&(t=u?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(u)return-1;t=i.length-1}else if(t<0)if(u)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:ae(i,e,t,n,u);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(i,e,t):Uint8Array.prototype.lastIndexOf.call(i,e,t):ae(i,[e],t,n,u);throw new TypeError("val must be string, number or Buffer")}function ae(i,e,t,n,u){let f=1,o=i.length,w=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(i.length<2||e.length<2)return-1;f=2,o/=2,w/=2,t/=2}function A(N,I){return f===1?N[I]:N.readUInt16BE(I*f)}let R;if(u){let N=-1;for(R=t;R<o;R++)if(A(i,R)===A(e,N===-1?0:R-N)){if(N===-1&&(N=R),R-N+1===w)return N*f}else N!==-1&&(R-=R-N),N=-1}else for(t+w>o&&(t=o-w),R=t;R>=0;R--){let N=!0;for(let I=0;I<w;I++)if(A(i,R+I)!==A(e,I)){N=!1;break}if(N)return R}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},s.prototype.indexOf=function(e,t,n){return ue(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return ue(this,e,t,n,!1)};function je(i,e,t,n){t=Number(t)||0;const u=i.length-t;n?(n=Number(n),n>u&&(n=u)):n=u;const f=e.length;n>f/2&&(n=f/2);let o;for(o=0;o<n;++o){const w=parseInt(e.substr(o*2,2),16);if(ie(w))return o;i[t+o]=w}return o}function Pe(i,e,t,n){return W(re(e,i.length-t),i,t,n)}function Ue(i,e,t,n){return W(Qe(e),i,t,n)}function Ce(i,e,t,n){return W(ye(e),i,t,n)}function Le(i,e,t,n){return W(He(e,i.length-t),i,t,n)}s.prototype.write=function(e,t,n,u){if(t===void 0)u="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")u=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,u===void 0&&(u="utf8")):(u=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const f=this.length-t;if((n===void 0||n>f)&&(n=f),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");u||(u="utf8");let o=!1;for(;;)switch(u){case"hex":return je(this,e,t,n);case"utf8":case"utf-8":return Pe(this,e,t,n);case"ascii":case"latin1":case"binary":return Ue(this,e,t,n);case"base64":return Ce(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Le(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+u);u=(""+u).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ke(i,e,t){return e===0&&t===i.length?r.fromByteArray(i):r.fromByteArray(i.slice(e,t))}function he(i,e,t){t=Math.min(i.length,t);const n=[];let u=e;for(;u<t;){const f=i[u];let o=null,w=f>239?4:f>223?3:f>191?2:1;if(u+w<=t){let A,R,N,I;switch(w){case 1:f<128&&(o=f);break;case 2:A=i[u+1],(A&192)===128&&(I=(f&31)<<6|A&63,I>127&&(o=I));break;case 3:A=i[u+1],R=i[u+2],(A&192)===128&&(R&192)===128&&(I=(f&15)<<12|(A&63)<<6|R&63,I>2047&&(I<55296||I>57343)&&(o=I));break;case 4:A=i[u+1],R=i[u+2],N=i[u+3],(A&192)===128&&(R&192)===128&&(N&192)===128&&(I=(f&15)<<18|(A&63)<<12|(R&63)<<6|N&63,I>65535&&I<1114112&&(o=I))}}o===null?(o=65533,w=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),u+=w}return De(n)}const fe=4096;function De(i){const e=i.length;if(e<=fe)return String.fromCharCode.apply(String,i);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,i.slice(n,n+=fe));return t}function Me(i,e,t){let n="";t=Math.min(i.length,t);for(let u=e;u<t;++u)n+=String.fromCharCode(i[u]&127);return n}function $e(i,e,t){let n="";t=Math.min(i.length,t);for(let u=e;u<t;++u)n+=String.fromCharCode(i[u]);return n}function Oe(i,e,t){const n=i.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let u="";for(let f=e;f<t;++f)u+=Ve[i[f]];return u}function Ge(i,e,t){const n=i.slice(e,t);let u="";for(let f=0;f<n.length-1;f+=2)u+=String.fromCharCode(n[f]+n[f+1]*256);return u}s.prototype.slice=function(e,t){const n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);const u=this.subarray(e,t);return Object.setPrototypeOf(u,s.prototype),u};function P(i,e,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||P(e,t,this.length);let u=this[e],f=1,o=0;for(;++o<t&&(f*=256);)u+=this[e+o]*f;return u},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||P(e,t,this.length);let u=this[e+--t],f=1;for(;t>0&&(f*=256);)u+=this[e+--t]*f;return u},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||P(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||P(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||P(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||P(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=M(function(e){e=e>>>0,G(e,"offset");const t=this[e],n=this[e+7];(t===void 0||n===void 0)&&v(e,this.length-8);const u=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,f=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(u)+(BigInt(f)<<BigInt(32))}),s.prototype.readBigUInt64BE=M(function(e){e=e>>>0,G(e,"offset");const t=this[e],n=this[e+7];(t===void 0||n===void 0)&&v(e,this.length-8);const u=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],f=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(u)<<BigInt(32))+BigInt(f)}),s.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||P(e,t,this.length);let u=this[e],f=1,o=0;for(;++o<t&&(f*=256);)u+=this[e+o]*f;return f*=128,u>=f&&(u-=Math.pow(2,8*t)),u},s.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||P(e,t,this.length);let u=t,f=1,o=this[e+--u];for(;u>0&&(f*=256);)o+=this[e+--u]*f;return f*=128,o>=f&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e=e>>>0,t||P(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||P(e,2,this.length);const n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||P(e,2,this.length);const n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=M(function(e){e=e>>>0,G(e,"offset");const t=this[e],n=this[e+7];(t===void 0||n===void 0)&&v(e,this.length-8);const u=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(u)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=M(function(e){e=e>>>0,G(e,"offset");const t=this[e],n=this[e+7];(t===void 0||n===void 0)&&v(e,this.length-8);const u=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(u)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||P(e,4,this.length),h.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||P(e,4,this.length),h.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||P(e,8,this.length),h.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||P(e,8,this.length),h.read(this,e,!1,52,8)};function C(i,e,t,n,u,f){if(!s.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>u||e<f)throw new RangeError('"value" argument is out of bounds');if(t+n>i.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,u){if(e=+e,t=t>>>0,n=n>>>0,!u){const w=Math.pow(2,8*n)-1;C(this,e,t,n,w,0)}let f=1,o=0;for(this[t]=e&255;++o<n&&(f*=256);)this[t+o]=e/f&255;return t+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,u){if(e=+e,t=t>>>0,n=n>>>0,!u){const w=Math.pow(2,8*n)-1;C(this,e,t,n,w,0)}let f=n-1,o=1;for(this[t+f]=e&255;--f>=0&&(o*=256);)this[t+f]=e/o&255;return t+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function oe(i,e,t,n,u){xe(e,n,u,i,t,7);let f=Number(e&BigInt(4294967295));i[t++]=f,f=f>>8,i[t++]=f,f=f>>8,i[t++]=f,f=f>>8,i[t++]=f;let o=Number(e>>BigInt(32)&BigInt(4294967295));return i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o,t}function ce(i,e,t,n,u){xe(e,n,u,i,t,7);let f=Number(e&BigInt(4294967295));i[t+7]=f,f=f>>8,i[t+6]=f,f=f>>8,i[t+5]=f,f=f>>8,i[t+4]=f;let o=Number(e>>BigInt(32)&BigInt(4294967295));return i[t+3]=o,o=o>>8,i[t+2]=o,o=o>>8,i[t+1]=o,o=o>>8,i[t]=o,t+8}s.prototype.writeBigUInt64LE=M(function(e,t=0){return oe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=M(function(e,t=0){return ce(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,n,u){if(e=+e,t=t>>>0,!u){const A=Math.pow(2,8*n-1);C(this,e,t,n,A-1,-A)}let f=0,o=1,w=0;for(this[t]=e&255;++f<n&&(o*=256);)e<0&&w===0&&this[t+f-1]!==0&&(w=1),this[t+f]=(e/o>>0)-w&255;return t+n},s.prototype.writeIntBE=function(e,t,n,u){if(e=+e,t=t>>>0,!u){const A=Math.pow(2,8*n-1);C(this,e,t,n,A-1,-A)}let f=n-1,o=1,w=0;for(this[t+f]=e&255;--f>=0&&(o*=256);)e<0&&w===0&&this[t+f+1]!==0&&(w=1),this[t+f]=(e/o>>0)-w&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||C(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||C(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]=e&255,t+4},s.prototype.writeBigInt64LE=M(function(e,t=0){return oe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=M(function(e,t=0){return ce(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function le(i,e,t,n,u,f){if(t+n>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function de(i,e,t,n,u){return e=+e,t=t>>>0,u||le(i,e,t,4),h.write(i,e,t,n,23,4),t+4}s.prototype.writeFloatLE=function(e,t,n){return de(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return de(this,e,t,!1,n)};function pe(i,e,t,n,u){return e=+e,t=t>>>0,u||le(i,e,t,8),h.write(i,e,t,n,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,n){return pe(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return pe(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,u){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!u&&u!==0&&(u=this.length),t>=e.length&&(t=e.length),t||(t=0),u>0&&u<n&&(u=n),u===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("sourceEnd out of bounds");u>this.length&&(u=this.length),e.length-t<u-n&&(u=e.length-t+n);const f=u-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,u):Uint8Array.prototype.set.call(e,this.subarray(n,u),t),f},s.prototype.fill=function(e,t,n,u){if(typeof e=="string"){if(typeof t=="string"?(u=t,t=0,n=this.length):typeof n=="string"&&(u=n,n=this.length),u!==void 0&&typeof u!="string")throw new TypeError("encoding must be a string");if(typeof u=="string"&&!s.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(e.length===1){const o=e.charCodeAt(0);(u==="utf8"&&o<128||u==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let f;if(typeof e=="number")for(f=t;f<n;++f)this[f]=e;else{const o=s.isBuffer(e)?e:s.from(e,u),w=o.length;if(w===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(f=0;f<n-t;++f)this[f+t]=o[f%w]}return this};const O={};function te(i,e,t){O[i]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(u){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:u,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}te("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),te("ERR_INVALID_ARG_TYPE",function(i,e){return`The "${i}" argument must be of type number. Received type ${typeof e}`},TypeError),te("ERR_OUT_OF_RANGE",function(i,e,t){let n=`The value of "${i}" is out of range.`,u=t;return Number.isInteger(t)&&Math.abs(t)>2**32?u=_e(String(t)):typeof t=="bigint"&&(u=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(u=_e(u)),u+="n"),n+=` It must be ${e}. Received ${u}`,n},RangeError);function _e(i){let e="",t=i.length;const n=i[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${i.slice(t-3,t)}${e}`;return`${i.slice(0,t)}${e}`}function qe(i,e,t){G(e,"offset"),(i[e]===void 0||i[e+t]===void 0)&&v(e,i.length-(t+1))}function xe(i,e,t,n,u,f){if(i>t||i<e){const o=typeof e=="bigint"?"n":"";let w;throw e===0||e===BigInt(0)?w=`>= 0${o} and < 2${o} ** ${(f+1)*8}${o}`:w=`>= -(2${o} ** ${(f+1)*8-1}${o}) and < 2 ** ${(f+1)*8-1}${o}`,new O.ERR_OUT_OF_RANGE("value",w,i)}qe(n,u,f)}function G(i,e){if(typeof i!="number")throw new O.ERR_INVALID_ARG_TYPE(e,"number",i)}function v(i,e,t){throw Math.floor(i)!==i?(G(i,t),new O.ERR_OUT_OF_RANGE("offset","an integer",i)):e<0?new O.ERR_BUFFER_OUT_OF_BOUNDS:new O.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,i)}const ve=/[^+/0-9A-Za-z-_]/g;function ze(i){if(i=i.split("=")[0],i=i.trim().replace(ve,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function re(i,e){e=e||1/0;let t;const n=i.length;let u=null;const f=[];for(let o=0;o<n;++o){if(t=i.charCodeAt(o),t>55295&&t<57344){if(!u){if(t>56319){(e-=3)>-1&&f.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&f.push(239,191,189);continue}u=t;continue}if(t<56320){(e-=3)>-1&&f.push(239,191,189),u=t;continue}t=(u-55296<<10|t-56320)+65536}else u&&(e-=3)>-1&&f.push(239,191,189);if(u=null,t<128){if((e-=1)<0)break;f.push(t)}else if(t<2048){if((e-=2)<0)break;f.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;f.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;f.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return f}function Qe(i){const e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t)&255);return e}function He(i,e){let t,n,u;const f=[];for(let o=0;o<i.length&&!((e-=2)<0);++o)t=i.charCodeAt(o),n=t>>8,u=t%256,f.push(u),f.push(n);return f}function ye(i){return r.toByteArray(ze(i))}function W(i,e,t,n){let u;for(u=0;u<n&&!(u+t>=e.length||u>=i.length);++u)e[u+t]=i[u];return u}function k(i,e){return i instanceof e||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===e.name}function ie(i){return i!==i}const Ve=(function(){const i="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){const n=t*16;for(let u=0;u<16;++u)e[n+u]=i[t]+i[u]}return e})();function M(i){return typeof BigInt>"u"?Je:i}function Je(){throw new Error("BigInt not supported")}})(ne)),ne}var Ye=Xe();const Q="http://www.w3.org/1999/02/22-rdf-syntax-ns#",H="http://www.w3.org/2001/XMLSchema#",Y="http://www.w3.org/2000/10/swap/",L={xsd:{decimal:`${H}decimal`,boolean:`${H}boolean`,double:`${H}double`,integer:`${H}integer`,string:`${H}string`},rdf:{type:`${Q}type`,nil:`${Q}nil`,first:`${Q}first`,rest:`${Q}rest`,langString:`${Q}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Y}reify#forSome`,forAll:`${Y}reify#forAll`},log:{implies:`${Y}log#implies`,isImpliedBy:`${Y}log#isImpliedBy`}},{xsd:K}=L,Ke=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,we={"\\":"\\","'":"'",'"':'"',n:`
7
+ `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},et=/[\x00-\x20<>\\"\{\}\|\^\`]/,tt={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},rt=/$0^/;class it{constructor(r){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]*)?$/,r=r||{},this._isImpliedBy=r.isImpliedBy,this._lineMode=!!r.lineMode){this._n3Mode=!1;for(const h in this)!(h in tt)&&this[h]instanceof RegExp&&(this[h]=rt)}else this._n3Mode=r.n3!==!1;this.comments=!!r.comments,this._literalClosingPos=0}_tokenizeToEnd(r,h){let a=this._input,c=a.length;for(;;){let s,b;for(;s=this._newline.exec(a);)this.comments&&(b=this._comment.exec(s[0]))&&_("comment",b[1],"",this._line,s[0].length),a=a.substr(s[0].length,a.length),c=a.length,this._line++;if(!s&&(s=this._whitespace.exec(a))&&(a=a.substr(s[0].length,a.length)),this._endOfFile.test(a))return h&&(this.comments&&(b=this._comment.exec(a))&&_("comment",b[1],"",this._line,a.length),a=null,_("eof","","",this._line,0)),this._input=a;const B=this._line,E=a[0];let x="",m="",y="",p=null,g=0,F=!1;switch(E){case"^":if(a.length<3)break;if(a[1]==="^"){if(this._previousMarker="^^",a=a.substr(2),a[0]!=="<"){F=!0;break}}else{this._n3Mode&&(g=1,x="^");break}case"<":if(p=this._unescapedIri.exec(a))x="IRI",m=p[1];else if(p=this._iri.exec(a)){if(m=this._unescape(p[1]),m===null||et.test(m))return l(this);x="IRI"}else a.length>1&&a[1]==="<"?(x="<<",g=2):this._n3Mode&&a.length>1&&a[1]==="="&&(g=2,this._isImpliedBy?(x="abbreviation",m="<"):(x="inverse",m=">"));break;case">":a.length>1&&a[1]===">"&&(x=">>",g=2);break;case"_":((p=this._blank.exec(a))||h&&(p=this._blank.exec(`${a} `)))&&(x="blank",y="_",m=p[1]);break;case'"':if(p=this._simpleQuotedString.exec(a))m=p[1];else if({value:m,matchLength:g}=this._parseLiteral(a),m===null)return l(this);(p!==null||g!==0)&&(x="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(p=this._simpleApostropheString.exec(a))m=p[1];else if({value:m,matchLength:g}=this._parseLiteral(a),m===null)return l(this);(p!==null||g!==0)&&(x="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(p=this._variable.exec(a))&&(x="var",m=p[0]);break;case"@":this._previousMarker==="literal"&&(p=this._langcode.exec(a))?(x="langcode",m=p[1]):(p=this._keyword.exec(a))&&(x=p[0]);break;case".":if(a.length===1?h:a[1]<"0"||a[1]>"9"){x=".",g=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(a)||h&&(p=this._number.exec(`${a} `)))&&(x="literal",m=p[0],y=typeof p[1]=="string"?K.double:typeof p[2]=="string"?K.decimal:K.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(p=this._sparqlKeyword.exec(a))?x=p[0].toUpperCase():F=!0;break;case"f":case"t":(p=this._boolean.exec(a))?(x="literal",m=p[0],y=K.boolean):F=!0;break;case"a":(p=this._shortPredicates.exec(a))?(x="abbreviation",m="a"):F=!0;break;case"=":this._n3Mode&&a.length>1&&(x="abbreviation",a[1]!==">"?(g=1,m="="):(g=2,m=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(g=1,x=E);break;case"{":!this._lineMode&&a.length>=2&&(a[1]==="|"?(x="{|",g=2):(x=E,g=1));break;case"|":a.length>=2&&a[1]==="}"&&(x="|}",g=2);break;default:F=!0}if(F&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(p=this._prefix.exec(a))?(x="prefix",m=p[1]||""):((p=this._prefixed.exec(a))||h&&(p=this._prefixed.exec(`${a} `)))&&(x="prefixed",y=p[1]||"",m=this._unescape(p[2]))),this._previousMarker==="^^")switch(x){case"prefixed":x="type";break;case"IRI":x="typeIRI";break;default:x=""}if(!x)return h||!/^'''|^"""/.test(a)&&/\n|\r/.test(a)?l(this):this._input=a;const j=g||p[0].length,S=_(x,m,y,B,j);this.previousToken=S,this._previousMarker=x,a=a.substr(j,a.length)}function _(s,b,B,E,x){const m=a?c-a.length:c,y=m+x,p={type:s,value:b,prefix:B,line:E,start:m,end:y};return r(null,p),p}function l(s){r(s._syntaxError(/^\S*/.exec(a)[0]))}}_unescape(r){let h=!1;const a=r.replace(Ke,(c,_,l,s)=>{if(typeof _=="string")return String.fromCharCode(Number.parseInt(_,16));if(typeof l=="string"){let b=Number.parseInt(l,16);return b<=65535?String.fromCharCode(Number.parseInt(l,16)):String.fromCharCode(55296+((b-=65536)>>10),56320+(b&1023))}return s in we?we[s]:(h=!0,"")});return h?null:a}_parseLiteral(r){if(r.length>=3){const h=r.match(/^(?:"""|"|'''|'|)/)[0],a=h.length;let c=Math.max(this._literalClosingPos,a);for(;(c=r.indexOf(h,c))>0;){let _=0;for(;r[c-_-1]==="\\";)_++;if(_%2===0){const l=r.substring(a,c),s=l.split(/\r\n|\r|\n/).length-1,b=c+a;if(a===1&&s!==0||a===3&&this._lineMode)break;return this._line+=s,{value:this._unescape(l),matchLength:b}}c++}this._literalClosingPos=r.length-a+1}return{value:"",matchLength:0}}_syntaxError(r){this._input=null;const h=new Error(`Unexpected "${r}" on line ${this._line}.`);return h.context={token:void 0,line:this._line,previousToken:this.previousToken},h}_readStartingBom(r){return r.startsWith("\uFEFF")?r.substr(1):r}tokenize(r,h){if(this._line=1,typeof r=="string")if(this._input=this._readStartingBom(r),typeof h=="function")queueMicrotask(()=>this._tokenizeToEnd(h,!0));else{const a=[];let c;if(this._tokenizeToEnd((_,l)=>_?c=_:a.push(l),!0),c)throw c;return a}else this._pendingBuffer=null,typeof r.setEncoding=="function"&&r.setEncoding("utf8"),r.on("data",a=>{this._input!==null&&a.length!==0&&(this._pendingBuffer&&(a=Ye.Buffer.concat([this._pendingBuffer,a]),this._pendingBuffer=null),a[a.length-1]&128?this._pendingBuffer=a:(typeof this._input>"u"?this._input=this._readStartingBom(typeof a=="string"?a:a.toString()):this._input+=a,this._tokenizeToEnd(h,!1)))}),r.on("end",()=>{typeof this._input=="string"&&this._tokenizeToEnd(h,!0)}),r.on("error",h)}}const{rdf:nt,xsd:q}=L;let Z,st=0;const ut={namedNode:Fe,blankNode:Re,variable:Ne,literal:Ae,defaultGraph:ot,quad:se,triple:se,fromTerm:V,fromQuad:Se};class D{constructor(r){this.id=r}get value(){return this.id}equals(r){return r instanceof D?this.id===r.id:!!r&&this.termType===r.termType&&this.value===r.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class Be extends D{get termType(){return"NamedNode"}}class J extends D{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const r=this.id;let h=r.lastIndexOf('"')+1;return h<r.length&&r[h++]==="@"?r.substr(h).toLowerCase():""}get datatype(){return new Be(this.datatypeString)}get datatypeString(){const r=this.id,h=r.lastIndexOf('"')+1,a=h<r.length?r[h]:"";return a==="^"?r.substr(h+2):a!=="@"?q.string:nt.langString}equals(r){return r instanceof J?this.id===r.id:!!r&&!!r.datatype&&this.termType===r.termType&&this.value===r.value&&this.language===r.language&&this.datatype.value===r.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}}class at extends D{constructor(r){super(`_:${r}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class ht extends D{constructor(r){super(`?${r}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}class ft extends D{constructor(){return super(""),Z||this}get termType(){return"DefaultGraph"}equals(r){return this===r||!!r&&this.termType===r.termType}}Z=new ft;class Ie extends D{constructor(r,h,a,c){super(""),this._subject=r,this._predicate=h,this._object=a,this._graph=c||Z}get termType(){return"Quad"}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(r){return!!r&&this._subject.equals(r.subject)&&this._predicate.equals(r.predicate)&&this._object.equals(r.object)&&this._graph.equals(r.graph)}}function Fe(d){return new Be(d)}function Re(d){return new at(d||`n3-${st++}`)}function Ae(d,r){if(typeof r=="string")return new J(`"${d}"@${r.toLowerCase()}`);let h=r?r.value:"";return h===""&&(typeof d=="boolean"?h=q.boolean:typeof d=="number"&&(Number.isFinite(d)?h=Number.isInteger(d)?q.integer:q.double:(h=q.double,Number.isNaN(d)||(d=d>0?"INF":"-INF")))),h===""||h===q.string?new J(`"${d}"`):new J(`"${d}"^^${h}`)}function Ne(d){return new ht(d)}function ot(){return Z}function se(d,r,h,a){return new Ie(d,r,h,a)}function V(d){if(d instanceof D)return d;switch(d.termType){case"NamedNode":return Fe(d.value);case"BlankNode":return Re(d.value);case"Variable":return Ne(d.value);case"DefaultGraph":return Z;case"Literal":return Ae(d.value,d.language||d.datatype);case"Quad":return Se(d);default:throw new Error(`Unexpected termType: ${d.termType}`)}}function Se(d){if(d instanceof Ie)return d;if(d.termType!=="Quad")throw new Error(`Unexpected termType: ${d.termType}`);return se(V(d.subject),V(d.predicate),V(d.object),V(d.graph))}let Ee=0;class ct{constructor(r){this._contextStack=[],this._graph=null,r=r||{},this._setBase(r.baseIRI),r.factory&&Te(this,r.factory);const h=typeof r.format=="string"?r.format.match(/\w*$/)[0].toLowerCase():"",a=/turtle/.test(h),c=/trig/.test(h),_=/triple/.test(h),l=/quad/.test(h),s=this._n3Mode=/n3/.test(h),b=_||l;(this._supportsNamedGraphs=!(a||s))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(a||c||_||s),this._isImpliedBy=r.isImpliedBy,this._supportsRDFStar=h===""||/star|\*$/.test(h),b&&(this._resolveRelativeIRI=B=>null),this._blankNodePrefix=typeof r.blankNodePrefix!="string"?"":r.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=r.lexer||new it({lineMode:b,n3:s,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!r.explicitQuantifiers}static _resetBlankNodePrefix(){Ee=0}_setBase(r){if(!r)this._base="",this._basePath="";else{const h=r.indexOf("#");h>=0&&(r=r.substr(0,h)),this._base=r,this._basePath=r.indexOf("/")<0?r:r.replace(/[^\/?]*(?:\?.*)?$/,""),r=r.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=r[0],this._baseScheme=r[1]}}_saveContext(r,h,a,c,_){const l=this._n3Mode;this._contextStack.push({type:r,subject:a,predicate:c,object:_,graph:h,inverse:l?this._inversePredicate:!1,blankPrefix:l?this._prefixes._:"",quantified:l?this._quantified:null}),l&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(r,h){const a=this._contextStack.pop();if(!a||a.type!==r)return this._error(`Unexpected ${h.type}`,h);this._subject=a.subject,this._predicate=a.predicate,this._object=a.object,this._graph=a.graph,this._n3Mode&&(this._inversePredicate=a.inverse,this._prefixes._=a.blankPrefix,this._quantified=a.quantified)}_readInTopContext(r){switch(r.type){case"eof":return this._graph!==null?this._error("Unclosed graph",r):(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(r)}}_readEntity(r,h){let a;switch(r.type){case"IRI":case"typeIRI":const c=this._resolveIRI(r.value);if(c===null)return this._error("Invalid IRI",r);a=this._factory.namedNode(c);break;case"type":case"prefixed":const _=this._prefixes[r.prefix];if(_===void 0)return this._error(`Undefined prefix "${r.prefix}:"`,r);a=this._factory.namedNode(_+r.value);break;case"blank":a=this._factory.blankNode(this._prefixes[r.prefix]+r.value);break;case"var":a=this._factory.variable(r.value.substr(1));break;default:return this._error(`Expected entity but got ${r.type}`,r)}return!h&&this._n3Mode&&a.id in this._quantified&&(a=this._quantified[a.id]),a}_readSubject(r){switch(this._predicate=null,r.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",r);case"}":return this._readPunctuation(r);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',r);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',r);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",r);if(r.prefix.length===0)return this._literalValue=r.value,this._completeSubjectLiteral;this._subject=this._factory.literal(r.value,this._factory.namedNode(r.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",r);default:if((this._subject=this._readEntity(r))===void 0)return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(r){const h=r.type;switch(h){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[r.value];break;case".":case"]":case"}":return this._predicate===null?this._error(`Unexpected ${h}`,r):(this._subject=null,h==="]"?this._readBlankNodeTail(r):this._readPunctuation(r));case";":return this._predicate!==null?this._readPredicate:this._error("Expected predicate but got ;",r);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",r);default:if((this._predicate=this._readEntity(r))===void 0)return}return this._readObject}_readObject(r){switch(r.type){case"literal":if(r.prefix.length===0)return this._literalValue=r.value,this._readDataTypeOrLang;this._object=this._factory.literal(r.value,this._factory.namedNode(r.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",r);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",r);default:if((this._object=this._readEntity(r))===void 0)return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(r){return r.type==="{"?this._readGraph(r):this._readPredicate(r)}_readGraph(r){return r.type!=="{"?this._error(`Expected graph but got ${r.type}`,r):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(r){return r.type==="]"?(this._subject=null,this._readBlankNodeTail(r)):(this._predicate=null,this._readPredicate(r))}_readBlankNodeTail(r){if(r.type!=="]")return this._readBlankNodePunctuation(r);this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph);const h=this._predicate===null;return this._restoreContext("blank",r),this._object!==null?this._getContextEndReader():this._predicate!==null?this._readObject:h?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(r){switch(r.type){case".":case"}":return this._subject=null,this._readPunctuation(r);default:return this._readPredicate(r)}}_readListItem(r){let h=null,a=null,c=this._readListItem;const _=this._subject,l=this._contextStack,s=l[l.length-1];switch(r.type){case"[":this._saveContext("blank",this._graph,a=this._factory.blankNode(),this.RDF_FIRST,this._subject=h=this._factory.blankNode()),c=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,a=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",r),l.length!==0&&l[l.length-1].type==="list"&&this._emit(this._subject,this._predicate,this._object,this._graph),this._predicate===null){if(c=this._readPredicate,this._subject===this.RDF_NIL)return c}else if(c=this._getContextEndReader(),this._object===this.RDF_NIL)return c;a=this.RDF_NIL;break;case"literal":r.prefix.length===0?(this._literalValue=r.value,c=this._readListItemDataTypeOrLang):(h=this._factory.literal(r.value,this._factory.namedNode(r.prefix)),c=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",r);default:if((h=this._readEntity(r))===void 0)return}if(a===null&&(this._subject=a=this._factory.blankNode()),_===null?s.predicate===null?s.subject=a:s.object=a:this._emit(_,this.RDF_REST,a,this._graph),h!==null){if(this._n3Mode&&(r.type==="IRI"||r.type==="prefixed"))return this._saveContext("item",this._graph,a,this.RDF_FIRST,h),this._subject=h,this._predicate=null,this._getPathReader(this._readListItem);this._emit(a,this.RDF_FIRST,h,this._graph)}return c}_readDataTypeOrLang(r){return this._completeObjectLiteral(r,!1)}_readListItemDataTypeOrLang(r){return this._completeObjectLiteral(r,!0)}_completeLiteral(r){let h=this._factory.literal(this._literalValue);switch(r.type){case"type":case"typeIRI":const a=this._readEntity(r);if(a===void 0)return;h=this._factory.literal(this._literalValue,a),r=null;break;case"langcode":h=this._factory.literal(this._literalValue,r.value),r=null;break}return{token:r,literal:h}}_completeSubjectLiteral(r){return this._subject=this._completeLiteral(r).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(r,h){const a=this._completeLiteral(r);if(a)return this._object=a.literal,h&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),a.token===null?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(a.token))}_readFormulaTail(r){return r.type!=="}"?this._readPunctuation(r):(this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",r),this._object===null?this._readPredicate:this._getContextEndReader())}_readPunctuation(r){let h,a=this._graph;const c=this._subject,_=this._inversePredicate;switch(r.type){case"}":if(this._graph===null)return this._error("Unexpected graph closing",r);if(this._n3Mode)return this._readFormulaTail(r);this._graph=null;case".":this._subject=null,h=this._contextStack.length?this._readSubject:this._readInTopContext,_&&(this._inversePredicate=!1);break;case";":h=this._readPredicate;break;case",":h=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",r);const l=this._predicate,s=this._object;this._subject=this._factory.quad(c,l,s,this.DEFAULTGRAPH),h=this._readPredicate;break;case"|}":if(this._subject.termType!=="Quad")return this._error("Unexpected asserted triple closing",r);this._subject=null,h=this._readPunctuation;break;default:if(this._supportsQuads&&this._graph===null&&(a=this._readEntity(r))!==void 0){h=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,r)}if(c!==null){const l=this._predicate,s=this._object;_?this._emit(s,l,c,a):this._emit(c,l,s,a)}return h}_readBlankNodePunctuation(r){let h;switch(r.type){case";":h=this._readPredicate;break;case",":h=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,r)}return this._emit(this._subject,this._predicate,this._object,this._graph),h}_readQuadPunctuation(r){return r.type!=="."?this._error("Expected dot to follow quad",r):this._readInTopContext}_readPrefix(r){return r.type!=="prefix"?this._error("Expected prefix to follow @prefix",r):(this._prefix=r.value,this._readPrefixIRI)}_readPrefixIRI(r){if(r.type!=="IRI")return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,r);const h=this._readEntity(r);return this._prefixes[this._prefix]=h.value,this._prefixCallback(this._prefix,h),this._readDeclarationPunctuation}_readBaseIRI(r){const h=r.type==="IRI"&&this._resolveIRI(r.value);return h?(this._setBase(h),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",r)}_readNamedGraphLabel(r){switch(r.type){case"IRI":case"blank":case"prefixed":return this._readSubject(r),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",r)}}_readNamedGraphBlankLabel(r){return r.type!=="]"?this._error("Invalid graph label",r):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(r){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(r)):r.type!=="."?this._error("Expected declaration to end with a dot",r):this._readInTopContext}_readQuantifierList(r){let h;switch(r.type){case"IRI":case"prefixed":if((h=this._readEntity(r,!0))!==void 0)break;default:return this._error(`Unexpected ${r.type}`,r)}return this._explicitQuantifiers?(this._subject===null?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,h,this.QUANTIFIERS_GRAPH)):this._quantified[h.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(r){return r.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(r))}_getPathReader(r){return this._afterPath=r,this._readPath}_readPath(r){switch(r.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const h=this._contextStack,a=h.length&&h[h.length-1];if(a&&a.type==="item"){const c=this._subject;this._restoreContext("item",r),this._emit(this._subject,this.RDF_FIRST,c,this._graph)}return this._afterPath(r)}}_readForwardPath(r){let h,a;const c=this._factory.blankNode();if((a=this._readEntity(r))!==void 0)return this._predicate===null?(h=this._subject,this._subject=c):(h=this._object,this._object=c),this._emit(h,a,c,this._graph),this._readPath}_readBackwardPath(r){const h=this._factory.blankNode();let a,c;if((a=this._readEntity(r))!==void 0)return this._predicate===null?(c=this._subject,this._subject=h):(c=this._object,this._object=h),this._emit(h,a,c,this._graph),this._readPath}_readRDFStarTailOrGraph(r){return r.type!==">>"?this._supportsQuads&&this._graph===null&&(this._graph=this._readEntity(r))!==void 0?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,r):this._readRDFStarTail(r)}_readRDFStarTail(r){if(r.type!==">>")return this._error(`Expected >> but got ${r.type}`,r);const h=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",r),this._subject===null?(this._subject=h,this._readPredicate):(this._object=h,this._getContextEndReader())}_getContextEndReader(){const r=this._contextStack;if(!r.length)return this._readPunctuation;switch(r[r.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(r,h,a,c){this._callback(null,this._factory.quad(r,h,a,c||this.DEFAULTGRAPH))}_error(r,h){const a=new Error(`${r} on line ${h.line}.`);a.context={token:h,line:h.line,previousToken:this._lexer.previousToken},this._callback(a),this._callback=ee}_resolveIRI(r){return/^[a-z][a-z0-9+.-]*:/i.test(r)?r:this._resolveRelativeIRI(r)}_resolveRelativeIRI(r){if(!r.length)return this._base;switch(r[0]){case"#":return this._base+r;case"?":return this._base.replace(/(?:\?.*)?$/,r);case"/":return(r[1]==="/"?this._baseScheme:this._baseRoot)+this._removeDotSegments(r);default:return/^[^/:]*:/.test(r)?null:this._removeDotSegments(this._basePath+r)}}_removeDotSegments(r){if(!/(^|\/)\.\.?($|[/#?])/.test(r))return r;const h=r.length;let a="",c=-1,_=-1,l=0,s="/";for(;c<h;){switch(s){case":":if(_<0&&r[++c]==="/"&&r[++c]==="/")for(;(_=c+1)<h&&r[_]!=="/";)c=_;break;case"?":case"#":c=h;break;case"/":if(r[c+1]===".")switch(s=r[++c+1],s){case"/":a+=r.substring(l,c-1),l=c+1;break;case void 0:case"?":case"#":return a+r.substring(l,c)+r.substr(c+1);case".":if(s=r[++c+1],s===void 0||s==="/"||s==="?"||s==="#"){if(a+=r.substring(l,c-2),(l=a.lastIndexOf("/"))>=_&&(a=a.substr(0,l)),s!=="/")return`${a}/${r.substr(c+1)}`;l=c+1}}}s=r[++c]}return a+r.substring(l)}parse(r,h,a){let c,_,l;if(h&&(h.onQuad||h.onPrefix||h.onComment)?(c=h.onQuad,_=h.onPrefix,l=h.onComment):(c=h,_=a),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${Ee++}_`,this._prefixCallback=_||ee,this._inversePredicate=!1,this._quantified=Object.create(null),!c){const b=[];let B;if(this._callback=(E,x)=>{E?B=E:x&&b.push(x)},this._lexer.tokenize(r).every(E=>this._readCallback=this._readCallback(E)),B)throw B;return b}let s=(b,B)=>{b!==null?(this._callback(b),this._callback=ee):this._readCallback&&(this._readCallback=this._readCallback(B))};l&&(this._lexer.comments=!0,s=(b,B)=>{b!==null?(this._callback(b),this._callback=ee):this._readCallback&&(B.type==="comment"?l(B.value):this._readCallback=this._readCallback(B))}),this._callback=c,this._lexer.tokenize(r,s)}}function ee(){}function Te(d,r){d._factory=r,d.DEFAULTGRAPH=r.defaultGraph(),d.RDF_FIRST=r.namedNode(L.rdf.first),d.RDF_REST=r.namedNode(L.rdf.rest),d.RDF_NIL=r.namedNode(L.rdf.nil),d.N3_FORALL=r.namedNode(L.r.forAll),d.N3_FORSOME=r.namedNode(L.r.forSome),d.ABBREVIATIONS={a:r.namedNode(L.rdf.type),"=":r.namedNode(L.owl.sameAs),">":r.namedNode(L.log.implies),"<":r.namedNode(L.log.isImpliedBy)},d.QUANTIFIERS_GRAPH=r.namedNode("urn:n3:quantifiers")}Te(ct.prototype,ut);export{ct as N};