@blockcerts/blockcerts-verifier 1.73.0 → 1.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +1 -1
- package/coverage/lcov.info +104 -104
- package/dist/{DataIntegrityProof-D8TnXEkl-CGiIg0kn.js → DataIntegrityProof-DRK-bLb_-CItV0ZXY.js} +2 -2
- package/dist/EcdsaSd2023-CdilbQE4-BlaeM9K_.js +26 -0
- package/dist/EcdsaSecp256k1Signature2019-rfxWS2XE-C73WHAtH.js +1 -0
- package/dist/{Ed25519Signature2020-D2tdrIA4-PSi5TCQH.js → Ed25519Signature2020-CDbX0d2Z-Dc1L-exZ.js} +8 -8
- package/dist/{EddsaRdfc2022-CpZAUc7W-BJP0532C.js → EddsaRdfc2022-Do0HFpDb-BcV_n8Fk.js} +4 -4
- package/dist/{HashlinkVerifier-BcdAFe02-DMjUYzMR.js → HashlinkVerifier-Cdnza1Dw-A9htzw7A.js} +1 -1
- package/dist/MerkleProof2017-5uQFQKSe-dtmePIpg.js +1 -0
- package/dist/MerkleProof2019-DraC60XD-B9XV8wNx.js +5 -0
- package/dist/checkBitStringStatusList-CKk6xxUL-D99R7EXK.js +1 -0
- package/dist/checkCredentialSchemaConformity-U2NlIuJZ-swOY09NS.js +1 -0
- package/dist/controlVerificationMethod-Blm4pE1t-BYBRLxNP.js +1 -0
- package/dist/{downloadPDF-BU6CfP-N.js → downloadPDF-C-y2U2YC.js} +2 -2
- package/dist/{ensureNotRevoked-BWp1jPEo-DSQMtjrj.js → ensureNotRevoked-DrQAPfcJ-BheL-ZKZ.js} +1 -1
- package/dist/ensureValidIssuingKey-D7OT4D35--HN0afRq.js +1 -0
- package/dist/index-BNsIYV4r-BnYxKy2f.js +14 -0
- package/dist/{index-OtXtCWrq-CyttRwCk.js → index-C4ZZHHRx-BOdwDnYa.js} +1 -1
- package/dist/index-CVS5Gn9h-DNgvq6Wk.js +7 -0
- package/dist/index-D2bS6rRi-D_ppNIsb.js +66 -0
- package/dist/{index-CB7VaVsF-G_Mj6xql.js → index-Dr7MpiEc-D5LHgMik.js} +12 -12
- package/dist/{index.es-C2GPR7m7.js → index.es-BmC2s_4v.js} +1 -1
- package/dist/jsonld-DOUjwF6J-dtl20tiV.js +33 -0
- package/dist/jsonld-signatures-BJXipuab-CB799Kkm.js +56 -0
- package/dist/main.js +122 -122
- package/dist/retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js +1 -0
- package/dist/{verifyIssuerProfile-zkczSLpC-CTHpISfH.js → verifyIssuerProfile-BG-odQrl-0JjZhiiC.js} +1 -1
- package/package.json +2 -2
- package/dist/EcdsaSd2023-D2eJBmaY-mHNjbn8h.js +0 -26
- package/dist/EcdsaSecp256k1Signature2019-BRdQnZ0o-D_QN8KrS.js +0 -1
- package/dist/MerkleProof2017-DW_9FhLr-C0dPtifx.js +0 -1
- package/dist/MerkleProof2019-DJbo7uW--CHlhsnHk.js +0 -5
- package/dist/checkBitStringStatusList-BUPuVWy_-CYedocxJ.js +0 -13
- package/dist/checkCredentialSchemaConformity-CJdGwNcY-CaSak-bD.js +0 -1
- package/dist/controlVerificationMethod-C71lJp3H-n-AbzkO8.js +0 -1
- package/dist/ensureValidIssuingKey-BYAR3LEF-76kiqVKA.js +0 -1
- package/dist/index-Jn9Q6fuB-uChPhl1c.js +0 -56
- package/dist/jsonld-DqC1oHcn-ruRlORc0.js +0 -88
- package/dist/retrieveVerificationMethodPublicKey-Dai7em0K-BqIH8qzD.js +0 -1
- /package/dist/{index-BCu3PGuw-Dh4-8Ruv.js → index-uKBVup0_-Dh4-8Ruv.js} +0 -0
- /package/dist/{index-KzSDgEl9-Dgus2xdV.js → index-yOIIz7AL-Dgus2xdV.js} +0 -0
- /package/dist/{webcrypto.es-9hytEjC6-gGk5JRJH.js → webcrypto.es-FKUHCUj--gGk5JRJH.js} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import{h as e}from"./main.js";var t,n,o={};function r(){return n?t:(n=1,t=class e{constructor(e,t=new Map,n=0){this.prefix=e,this._existing=t,this.counter=n}clone(){const{prefix:t,_existing:n,counter:o}=this;return new e(t,new Map(n),o)}getId(e){const t=e&&this._existing.get(e);if(t)return t;const n=this.prefix+this.counter;return this.counter++,e&&this._existing.set(e,n),n}hasId(e){return this._existing.has(e)}getOldIds(){return[...this._existing.keys()]}})}var i,a,s,l,c,d,u,p,f,h,v,g,y,m,x,b,w,I,j,S,D,N,O,E,C,k,L,A,R,T,_,J,P,M,F,H,B,q,U,$,V,z,G,Q,W,X,K,Z,Y,ee,te,ne,oe,re,ie,ae,se,le,ce,de,ue,pe,fe,he,ve,ge,ye,me,xe={};
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
|
|
4
|
+
*/function be(){if(i)return xe;i=1,xe.setImmediate=setImmediate,xe.crypto=globalThis.crypto;const e=[];for(let t=0;t<=255;++t)e.push(t.toString(16).padStart(2,"0"));return xe.bufferToHex=function(t){let n="";const o=new Uint8Array(t);for(let t=0;t<o.length;++t)n+=e[o[t]];return n},xe}
|
|
5
|
+
/*!
|
|
6
|
+
* Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
|
|
7
|
+
*/function we(){if(s)return a;s=1;const{bufferToHex:e,crypto:t}=be(),n=new Map([["sha256","SHA-256"],["SHA256","SHA-256"],["SHA-256","SHA-256"],["sha384","SHA-384"],["SHA384","SHA-384"],["SHA-384","SHA-384"],["sha512","SHA-512"],["SHA512","SHA-512"],["SHA-512","SHA-512"]]);return a=class{constructor(e){if(!t||!t.subtle)throw new Error("crypto.subtle not found.");if(!n.has(e))throw new Error(`Unsupported algorithm "${e}".`);this.algorithm=n.get(e),this._content=""}update(e){this._content+=e}async digest(){const n=(new TextEncoder).encode(this._content),o=await t.subtle.digest(this.algorithm,n);return e(o)}}}
|
|
8
|
+
/*!
|
|
9
|
+
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
10
|
+
*/function Ie(){return c?l:(c=1,l=class{constructor(e){this.current=e.sort(),this.done=!1,this.dir=new Map;for(let t=0;t<e.length;++t)this.dir.set(e[t],!0)}hasNext(){return!this.done}next(){const{current:e,dir:t}=this,n=e.slice();let o=null,r=0;const i=e.length;for(let n=0;n<i;++n){const a=e[n],s=t.get(a);(null===o||a>o)&&(s&&n>0&&a>e[n-1]||!s&&n<i-1&&a>e[n+1])&&(o=a,r=n)}if(null===o)this.done=!0;else{const n=t.get(o)?r-1:r+1;e[r]=e[n],e[n]=o;for(const n of e)n>o&&t.set(n,!t.get(n))}return n}})}
|
|
11
|
+
/*!
|
|
12
|
+
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
13
|
+
*/function je(){if(u)return d;u=1;const e="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",t="http://www.w3.org/2001/XMLSchema#string",n="NamedNode",o="BlankNode",r="Literal",i={};function a(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!==r||e.object.datatype.termType===t.object.datatype.termType&&e.object.language===t.object.language&&e.object.datatype.value===t.object.datatype.value))}(()=>{const e="A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�_",t=e+"0-9-·̀-ͯ‿-⁀",n="_:((?:["+e+"0-9])(?:(?:["+t+".])*(?:["+t+"]))?)",o='(?:<((?:[^\0- <>"{}|^`\\\\]|\\\\u[0-9A-Fa-f]{4}|\\\\U[0-9A-Fa-f]{8})*)>)',r="[ \\t]+",a="[ \\t]*",s="(?:"+o+"|"+n+")"+r,l=o+r,c="(?:"+o+"|"+n+"|"+('(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:'+("(?:\\^\\^"+o+")")+"|(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)))?)")+")"+a,d="(?:\\.|(?:(?:"+o+"|"+n+")"+a+"\\.))";i.eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,i.empty=new RegExp("^"+a+"$"),i.quad=new RegExp("^"+a+s+l+c+d+a+"$")})(),d=class c{static parse(s){const l=[],c={},d=s.split(i.eoln);let u=0;for(const s of d){if(u++,i.empty.test(s))continue;const d=s.match(i.quad);if(null===d)throw new Error("N-Quads parse error on line "+u+".");const f={subject:null,predicate:null,object:null,graph:null};if(void 0!==d[1]?f.subject={termType:n,value:y(d[1])}:f.subject={termType:o,value:d[2]},f.predicate={termType:n,value:y(d[3])},void 0!==d[4]?f.object={termType:n,value:y(d[4])}:void 0!==d[5]?f.object={termType:o,value:d[5]}:(f.object={termType:r,value:void 0,datatype:{termType:n}},void 0!==d[7]?f.object.datatype.value=y(d[7]):void 0!==d[8]?(f.object.datatype.value=e,f.object.language=d[8]):f.object.datatype.value=t,f.object.value=p(d[6])),void 0!==d[9]?f.graph={termType:n,value:y(d[9])}:void 0!==d[10]?f.graph={termType:o,value:d[10]}:f.graph={termType:"DefaultGraph",value:""},f.graph.value in c){let e=!0;const t=c[f.graph.value];for(const n of t)if(a(n,f)){e=!1;break}e&&(t.push(f),l.push(f))}else c[f.graph.value]=[f],l.push(f)}return l}static serialize(e){const t=[];for(const n of e)t.push(c.serializeQuad(n));return t.sort().join("")}static serializeQuadComponents(r,i,a,c){let d="";return r.termType===n?d+=`<${v(r.value)}>`:d+=`_:${r.value}`,i.termType===n?d+=` <${v(i.value)}> `:d+=` _:${i.value} `,a.termType===n?d+=`<${v(a.value)}>`:a.termType===o?d+=`_:${a.value}`:(d+=`"${function(e){if(!s.test(e))return e;return e.replace(s,function(e){return l[e.codePointAt(0)]})}(a.value)}"`,a.datatype.value===e?a.language&&(d+=`@${a.language}`):a.datatype.value!==t&&(d+=`^^<${v(a.datatype.value)}>`)),c.termType===n?d+=` <${v(c.value)}>`:c.termType===o&&(d+=` _:${c.value}`),d+=" .\n",d}static serializeQuad(e){return c.serializeQuadComponents(e.subject,e.predicate,e.object,e.graph)}};const s=/[\u0000-\u001F\u007F"\\]/g,l=[];for(let e=0;e<=127;++e)s.test(String.fromCharCode(e))&&(l[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),s.lastIndex=0);l["\b".codePointAt(0)]="\\b",l["\t".codePointAt(0)]="\\t",l["\n".codePointAt(0)]="\\n",l["\f".codePointAt(0)]="\\f",l["\r".codePointAt(0)]="\\r",l['"'.codePointAt(0)]='\\"',l["\\".codePointAt(0)]="\\\\";const c=/(?:\\([btnfr"'\\]))|(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function p(e){return c.test(e)?e.replace(c,function(e,t,n,o){if(t)switch(t){case"b":return"\b";case"t":return"\t";case"n":return"\n";case"f":return"\f";case"r":return"\r";case'"':return'"';case"'":return"'";case"\\":return"\\"}return n?String.fromCharCode(parseInt(n,16)):o?String.fromCodePoint(parseInt(o,16)):void 0}):e}const f=/[\u0000-\u0020<>"{}|^`\\]/g,h=[];for(let e=0;e<=127;++e)f.test(String.fromCharCode(e))&&(h[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),f.lastIndex=0);function v(e){return f.test(e)?e.replace(f,function(e){return h[e.codePointAt(0)]}):e}const g=/(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function y(e){return g.test(e)?e.replace(g,function(e,t,n){return t?String.fromCharCode(parseInt(t,16)):n?String.fromCodePoint(parseInt(n,16)):void 0}):e}return d}
|
|
14
|
+
/*!
|
|
15
|
+
* Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
|
|
16
|
+
*/function Se(){return g||(g=1,function(e){const t=function(){if(f)return p;f=1;const e=r(),t=we(),n=Ie(),o=je(),{setImmediate:i}=be();function a(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return p=class{constructor({createMessageDigest:n=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:r=new Map,maxWorkFactor:i=1,maxDeepIterations:a=-1,signal:s=null}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",r),this.createMessageDigest=n||(()=>new t(o)),this.maxWorkFactor=i,this.maxDeepIterations=a,this.remainingDeepIterations=0,this.signal=s,this.quads=null}async main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const n=new Map,r=[...this.blankNodeInfo.keys()];let i=0;for(const e of r)++i%100==0&&await this._yield(),await this._hashAndTrackBlankNode({id:e,hashToBlankNodes:n});const s=[...n.keys()].sort(),l=[];for(const e of s){const t=n.get(e);if(t.length>1){l.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=l.reduce((e,t)=>e+t.length,0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of l){const n=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const r=await this.hashNDegreeQuads(o,t);n.push(r)}n.sort(a);for(const e of n){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const c=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));c.push(t)}return c.sort(),c.join("")}async hashFirstDegreeQuads(e){const t=[],n=this.blankNodeInfo.get(e),r=n.quads;for(const n of r)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,n.subject,"subject"),n.predicate,this.modifyFirstDegreeComponent(e,n.object,"object"),this.modifyFirstDegreeComponent(e,n.graph,"graph")));t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return n.hash=await i.digest(),n.hash}async hashRelatedBlankNode(e,t,n,o){const r=this.createMessageDigest();let i;return r.update(o),"g"!==o&&r.update(this.getRelatedPredicate(t)),i=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):n.hasId(e)?"_:"+n.getId(e):this.blankNodeInfo.get(e).hash,r.update(i),r.digest()}async hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),r=await this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let i,a="";const s=new n(r.get(e));let l=0;for(;s.hasNext();){const e=s.next();if(++l%3==0){if(this.signal&&this.signal.aborted)throw new Error(`Abort signal received: "${this.signal.reason}".`);await this._yield()}let n=t.clone(),o="";const r=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(n.hasId(t)||r.push(t),o+="_:"+n.getId(t)),0!==a.length&&o>a){c=!0;break}if(!c){for(const e of r){const t=await this.hashNDegreeQuads(e,n);if(o+="_:"+n.getId(e),o+=`<${t.hash}>`,n=t.issuer,0!==a.length&&o>a){c=!0;break}}c||(0===a.length||o<a)&&(a=o,i=n)}}o.update(a),t=i}return{hash:await o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}async createHashToRelated(e,t){const n=new Map,o=this.blankNodeInfo.get(e).quads;let r=0;for(const i of o)++r%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:i,component:i.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.graph,position:"g",id:e,issuer:t,hashToRelated:n})]);return n}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=await this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=await this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.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=>i(e))}}}
|
|
17
|
+
/*!
|
|
18
|
+
* Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
|
|
19
|
+
*/(),n=function(){if(v)return h;v=1;const e=r(),t=we(),n=Ie(),o=je();function i(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return h=class{constructor({createMessageDigest:n=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:r=new Map,maxWorkFactor:i=1,maxDeepIterations:a=-1,timeout:s=0}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",r),this.createMessageDigest=n||(()=>new t(o)),this.maxWorkFactor=i,this.maxDeepIterations=a,this.remainingDeepIterations=0,this.timeout=s,s>0&&(this.startTime=Date.now()),this.quads=null}main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const n=new Map,r=[...this.blankNodeInfo.keys()];for(const e of r)this._hashAndTrackBlankNode({id:e,hashToBlankNodes:n});const a=[...n.keys()].sort(),s=[];for(const e of a){const t=n.get(e);if(t.length>1){s.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=s.reduce((e,t)=>e+t.length,0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of s){const n=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const r=this.hashNDegreeQuads(o,t);n.push(r)}n.sort(i);for(const e of n){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const l=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));l.push(t)}return l.sort(),l.join("")}hashFirstDegreeQuads(e){const t=[],n=this.blankNodeInfo.get(e),r=n.quads;for(const n of r)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,n.subject,"subject"),n.predicate,this.modifyFirstDegreeComponent(e,n.object,"object"),this.modifyFirstDegreeComponent(e,n.graph,"graph")));t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return n.hash=i.digest(),n.hash}hashRelatedBlankNode(e,t,n,o){const r=this.createMessageDigest();let i;return r.update(o),"g"!==o&&r.update(this.getRelatedPredicate(t)),i=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):n.hasId(e)?"_:"+n.getId(e):this.blankNodeInfo.get(e).hash,r.update(i),r.digest()}hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),r=this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let i,a="";const s=new n(r.get(e));let l=0;for(;s.hasNext();){const e=s.next();if(++l%3==0&&this.timeout>0&&Date.now()-this.startTime>this.timeout)throw new Error("Canonize timeout.");let n=t.clone(),o="";const r=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(n.hasId(t)||r.push(t),o+="_:"+n.getId(t)),0!==a.length&&o>a){c=!0;break}if(!c){for(const e of r){const t=this.hashNDegreeQuads(e,n);if(o+="_:"+n.getId(e),o+=`<${t.hash}>`,n=t.issuer,0!==a.length&&o>a){c=!0;break}}c||(0===a.length||o<a)&&(a=o,i=n)}}o.update(a),t=i}return{hash:o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}createHashToRelated(e,t){const n=new Map,o=this.blankNodeInfo.get(e).quads;for(const r of o)this._addRelatedBlankNodeHash({quad:r,component:r.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:r,component:r.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:r,component:r.graph,position:"g",id:e,issuer:t,hashToRelated:n});return n}_hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}_addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}}}();function o(t,n){if(n.inputFormat){if("application/n-quads"===n.inputFormat){if("string"!=typeof t)throw new Error("N-Quads input must be a string.");return e.NQuads.parse(t)}throw new Error(`Unknown canonicalization input format: "${n.inputFormat}".`)}return t}function i(e){if(e.format&&"application/n-quads"!==e.format)throw new Error(`Unknown canonicalization output format: "${e.format}".`)}function a(){globalThis.RDF_CANONIZE_TRACE_URDNA2015&&console.trace("[rdf-canonize] URDNA2015 is deprecated, use RDFC-1.0")}e.NQuads=je(),e.IdentifierIssuer=r(),e.canonize=async function(e,n={}){const r=o(e,n);if(i(n),!("algorithm"in n))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===n.algorithm)return new t(n).main(r);if("URDNA2015"===n.algorithm&&!n.rejectURDNA2015)return a(),new t(n).main(r);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+n.algorithm)},e._canonizeSync=function(e,t={}){const r=o(e,t);if(i(t),!("algorithm"in t))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===t.algorithm)return new n(t).main(r);if("URDNA2015"===t.algorithm&&!t.rejectURDNA2015)return a(),new n(t).main(r);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+t.algorithm)}}(o)),o}function De(){return m?y:(m=1,y=Se())}function Ne(){if(b)return x;b=1;const e={};return x=e,e.isArray=Array.isArray,e.isBoolean=e=>"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e),e.isDouble=t=>e.isNumber(t)&&(-1!==String(t).indexOf(".")||Math.abs(t)>=1e21),e.isEmptyObject=t=>e.isObject(t)&&0===Object.keys(t).length,e.isNumber=e=>"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e),e.isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),e.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),e.isString=e=>"string"==typeof e||"[object String]"===Object.prototype.toString.call(e),e.isUndefined=e=>void 0===e,x}function Oe(){if(I)return w;I=1;const e=Ne(),t={};return w=t,t.isSubject=t=>{if(e.isObject(t)&&!("@value"in t||"@set"in t||"@list"in t)){return Object.keys(t).length>1||!("@id"in t)}return!1},t.isSubjectReference=t=>e.isObject(t)&&1===Object.keys(t).length&&"@id"in t,t.isValue=t=>e.isObject(t)&&"@value"in t,t.isList=t=>e.isObject(t)&&"@list"in t,t.isGraph=t=>e.isObject(t)&&"@graph"in t&&1===Object.keys(t).filter(e=>"@id"!==e&&"@index"!==e).length,t.isSimpleGraph=e=>t.isGraph(e)&&!("@id"in e),t.isBlankNode=t=>{if(e.isObject(t)){if("@id"in t){const n=t["@id"];return!e.isString(n)||0===n.indexOf("_:")}return 0===Object.keys(t).length||!("@value"in t||"@set"in t||"@list"in t)}return!1},w}function Ee(){return S?j:(S=1,j=class extends Error{constructor(e="An unspecified JSON-LD error occurred.",t="jsonld.Error",n={}){super(e),this.name=t,this.message=e,this.details=n}})}function Ce(){if(N)return D;N=1;const e=Oe(),t=Ne(),n=De().IdentifierIssuer,o=Ee(),r=/(?:<[^>]*?>|"[^"]*?"|[^,])+/g,i=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,a=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g,s={accept:"application/ld+json, application/json"},l={};function c(n,o){if(t.isArray(o))for(let e=0;e<o.length;++e)o[e]=c(n,o[e]);else if(e.isList(o))o["@list"]=c(n,o["@list"]);else if(t.isObject(o)){e.isBlankNode(o)&&(o["@id"]=n.getId(o["@id"]));const t=Object.keys(o).sort();for(let e=0;e<t.length;++e){const r=t[e];"@id"!==r&&(o[r]=c(n,o[r]))}}return o}return D=l,l.IdentifierIssuer=n,l.REGEX_BCP47=/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/,l.REGEX_KEYWORD=/^@[a-zA-Z]+$/,l.clone=function(e){if(e&&"object"==typeof e){let n;if(t.isArray(e)){n=[];for(let t=0;t<e.length;++t)n[t]=l.clone(e[t])}else if(e instanceof Map){n=new Map;for(const[t,o]of e)n.set(t,l.clone(o))}else if(e instanceof Set){n=new Set;for(const t of e)n.add(l.clone(t))}else if(t.isObject(e)){n={};for(const t in e)n[t]=l.clone(e[t])}else n=e.toString();return n}return e},l.asArray=function(e){return Array.isArray(e)?e:[e]},l.buildHeaders=(e={})=>{if(Object.keys(e).some(e=>"accept"===e.toLowerCase()))throw new RangeError('Accept header may not be specified; only "'+s.accept+'" is supported.');return Object.assign({Accept:s.accept},e)},l.parseLinkHeader=e=>{const t={},n=e.match(r);for(let e=0;e<n.length;++e){let o=n[e].match(i);if(!o)continue;const r={target:o[1]},s=o[2];for(;o=a.exec(s);)r[o[1]]=void 0===o[2]?o[3]:o[2];const l=r.rel||"";Array.isArray(t[l])?t[l].push(r):t.hasOwnProperty(l)?t[l]=[t[l],r]:t[l]=r}return t},l.validateTypeValue=(e,n)=>{if(!(t.isString(e)||t.isArray(e)&&e.every(e=>t.isString(e)))){if(n&&t.isObject(e))switch(Object.keys(e).length){case 0:return;case 1:if("@default"in e&&l.asArray(e["@default"]).every(e=>t.isString(e)))return}throw new o('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})}},l.hasProperty=(e,n)=>{if(e.hasOwnProperty(n)){const o=e[n];return!t.isArray(o)||o.length>0}return!1},l.hasValue=(n,o,r)=>{if(l.hasProperty(n,o)){let i=n[o];const a=e.isList(i);if(t.isArray(i)||a){a&&(i=i["@list"]);for(let e=0;e<i.length;++e)if(l.compareValues(r,i[e]))return!0}else if(!t.isArray(r))return l.compareValues(r,i)}return!1},l.addValue=(e,n,o,r)=>{if("propertyIsArray"in(r=r||{})||(r.propertyIsArray=!1),"valueIsArray"in r||(r.valueIsArray=!1),"allowDuplicate"in r||(r.allowDuplicate=!0),"prependValue"in r||(r.prependValue=!1),r.valueIsArray)e[n]=o;else if(t.isArray(o)){0===o.length&&r.propertyIsArray&&!e.hasOwnProperty(n)&&(e[n]=[]),r.prependValue&&(o=o.concat(e[n]),e[n]=[]);for(let t=0;t<o.length;++t)l.addValue(e,n,o[t],r)}else if(e.hasOwnProperty(n)){const i=!r.allowDuplicate&&l.hasValue(e,n,o);t.isArray(e[n])||i&&!r.propertyIsArray||(e[n]=[e[n]]),i||(r.prependValue?e[n].unshift(o):e[n].push(o))}else e[n]=r.propertyIsArray?[o]:o},l.getValues=(e,t)=>[].concat(e[t]||[]),l.removeProperty=(e,t)=>{delete e[t]},l.removeValue=(e,t,n,o)=>{"propertyIsArray"in(o=o||{})||(o.propertyIsArray=!1);const r=l.getValues(e,t).filter(e=>!l.compareValues(e,n));0===r.length?l.removeProperty(e,t):1!==r.length||o.propertyIsArray?e[t]=r:e[t]=r[0]},l.relabelBlankNodes=(e,t)=>c((t=t||{}).issuer||new n("_:b"),e),l.compareValues=(n,o)=>n===o||(!(!e.isValue(n)||!e.isValue(o)||n["@value"]!==o["@value"]||n["@type"]!==o["@type"]||n["@language"]!==o["@language"]||n["@index"]!==o["@index"])||!!(t.isObject(n)&&"@id"in n&&t.isObject(o)&&"@id"in o)&&n["@id"]===o["@id"]),l.compareShortestLeast=(e,t)=>e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1,D}function ke(){if(E)return O;E=1;const e="http://www.w3.org/1999/02/22-rdf-syntax-ns#",t="http://www.w3.org/2001/XMLSchema#";return O={LINK_HEADER_REL:"http://www.w3.org/ns/json-ld#context",LINK_HEADER_CONTEXT:"http://www.w3.org/ns/json-ld#context",RDF:e,RDF_LIST:e+"List",RDF_FIRST:e+"first",RDF_REST:e+"rest",RDF_NIL:e+"nil",RDF_TYPE:e+"type",RDF_PLAIN_LITERAL:e+"PlainLiteral",RDF_XML_LITERAL:e+"XMLLiteral",RDF_JSON_LITERAL:e+"JSON",RDF_OBJECT:e+"object",RDF_LANGSTRING:e+"langString",XSD:t,XSD_BOOLEAN:t+"boolean",XSD_DOUBLE:t+"double",XSD_INTEGER:t+"integer",XSD_STRING:t+"string"}}function Le(){return k||(k=1,C=class{constructor(){this._requests={}}wrapLoader(e){const t=this;return t._loader=e,function(){return t.add.apply(t,arguments)}}async add(e){let t=this._requests[e];if(t)return Promise.resolve(t);t=this._requests[e]=this._loader(e);try{return await t}finally{delete this._requests[e]}}}),C}function Ae(){if(A)return L;A=1;const e=Ne(),t={};L=t,t.parsers={simple:{keys:["href","scheme","authority","path","query","fragment"],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:["href","protocol","scheme","authority","auth","user","password","hostname","port","path","directory","file","query","fragment"],regex:/^(([a-zA-Z][a-zA-Z0-9+-.]*):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},t.parse=(e,n)=>{const o={},r=t.parsers[n||"full"],i=r.regex.exec(e);let a=r.keys.length;for(;a--;)o[r.keys[a]]=void 0===i[a]?null:i[a];return("https"===o.scheme&&"443"===o.port||"http"===o.scheme&&"80"===o.port)&&(o.href=o.href.replace(":"+o.port,""),o.authority=o.authority.replace(":"+o.port,""),o.port=null),o.normalizedPath=t.removeDotSegments(o.path),o},t.prependBase=(n,o)=>{if(null===n)return o;if(t.isAbsolute(o))return o;n&&!e.isString(n)||(n=t.parse(n||""));const r=t.parse(o),i={protocol:n.protocol||""};if(null!==r.authority)i.authority=r.authority,i.path=r.path,i.query=r.query;else if(i.authority=n.authority,""===r.path)i.path=n.path,null!==r.query?i.query=r.query:i.query=n.query;else{if(0===r.path.indexOf("/"))i.path=r.path;else{let e=n.path;e=e.substr(0,e.lastIndexOf("/")+1),(e.length>0||n.authority)&&"/"!==e.substr(-1)&&(e+="/"),e+=r.path,i.path=e}i.query=r.query}""!==r.path&&(i.path=t.removeDotSegments(i.path));let a=i.protocol;return null!==i.authority&&(a+="//"+i.authority),a+=i.path,null!==i.query&&(a+="?"+i.query),null!==r.fragment&&(a+="#"+r.fragment),""===a&&(a="./"),a},t.removeBase=(n,o)=>{if(null===n)return o;n&&!e.isString(n)||(n=t.parse(n||""));let r="";if(""!==n.href?r+=(n.protocol||"")+"//"+(n.authority||""):o.indexOf("//")&&(r+="//"),0!==o.indexOf(r))return o;const i=t.parse(o.substr(r.length)),a=n.normalizedPath.split("/"),s=i.normalizedPath.split("/"),l=i.fragment||i.query?0:1;for(;a.length>0&&s.length>l&&a[0]===s[0];)a.shift(),s.shift();let c="";if(a.length>0){a.pop();for(let e=0;e<a.length;++e)c+="../"}return c+=s.join("/"),null!==i.query&&(c+="?"+i.query),null!==i.fragment&&(c+="#"+i.fragment),""===c&&(c="./"),c},t.removeDotSegments=e=>{if(0===e.length)return"";const t=e.split("/"),n=[];for(;t.length>0;){const e=t.shift(),o=0===t.length;"."!==e?".."!==e?n.push(e):(n.pop(),o&&n.push("")):o&&n.push("")}return"/"===e[0]&&n.length>0&&""!==n[0]&&n.unshift(""),1===n.length&&""===n[0]?"/":n.join("/")};const n=/^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/;return t.isAbsolute=t=>e.isString(t)&&n.test(t),t.isRelative=t=>e.isString(t),L}function Re(){if(T)return R;T=1;const{parseLinkHeader:e,buildHeaders:t}=Ce(),{LINK_HEADER_CONTEXT:n}=ke(),o=Ee(),r=Le(),{prependBase:i}=Ae(),a=/(^|(\r\n))link:/i;return R=({secure:s,headers:l={},xhr:c}={headers:{}})=>{l=t(l);return(new r).wrapLoader(async function t(r){if(0!==r.indexOf("http:")&&0!==r.indexOf("https:"))throw new o('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:r});if(s&&0!==r.indexOf("https"))throw new o('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:r});let d;try{d=await function(e,t,n){e=e||XMLHttpRequest;const o=new e;return new Promise((e,r)=>{o.onload=()=>e(o),o.onerror=e=>r(e),o.open("GET",t,!0);for(const e in n)o.setRequestHeader(e,n[e]);o.send()})}(c,r,l)}catch(e){throw new o("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:e})}if(d.status>=400)throw new o("URL could not be dereferenced: "+d.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:r,httpStatusCode:d.status});let u={contextUrl:null,documentUrl:r,document:d.response},p=null;const f=d.getResponseHeader("Content-Type");let h;a.test(d.getAllResponseHeaders())&&(h=d.getResponseHeader("Link"));if(h&&"application/ld+json"!==f){const a=e(h),s=a[n];if(Array.isArray(s))throw new o("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r});s&&(u.contextUrl=s.target),p=a.alternate,p&&"application/ld+json"==p.type&&!(f||"").match(/^application\/(\w*\+)?json$/)&&(u=await t(i(r,p.target)))}return u})},R}function Te(){if(H)return F;function e(t){var n=this;if(n instanceof e||(n=new e),n.tail=null,n.head=null,n.length=0,t&&"function"==typeof t.forEach)t.forEach(function(e){n.push(e)});else if(arguments.length>0)for(var o=0,r=arguments.length;o<r;o++)n.push(arguments[o]);return n}function t(e,t,n){var o=t===e.head?new r(n,null,t,e):new r(n,t,t.next,e);return null===o.next&&(e.tail=o),null===o.prev&&(e.head=o),e.length++,o}function n(e,t){e.tail=new r(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function o(e,t){e.head=new r(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function r(e,t,n,o){if(!(this instanceof r))return new r(e,t,n,o);this.list=o,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}H=1,F=e,e.Node=r,e.create=e,e.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},e.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},e.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},e.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)n(this,arguments[e]);return this.length},e.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},e.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},e.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},e.prototype.forEach=function(e,t){t=t||this;for(var n=this.head,o=0;null!==n;o++)e.call(t,n.value,o,this),n=n.next},e.prototype.forEachReverse=function(e,t){t=t||this;for(var n=this.tail,o=this.length-1;null!==n;o--)e.call(t,n.value,o,this),n=n.prev},e.prototype.get=function(e){for(var t=0,n=this.head;null!==n&&t<e;t++)n=n.next;if(t===e&&null!==n)return n.value},e.prototype.getReverse=function(e){for(var t=0,n=this.tail;null!==n&&t<e;t++)n=n.prev;if(t===e&&null!==n)return n.value},e.prototype.map=function(t,n){n=n||this;for(var o=new e,r=this.head;null!==r;)o.push(t.call(n,r.value,this)),r=r.next;return o},e.prototype.mapReverse=function(t,n){n=n||this;for(var o=new e,r=this.tail;null!==r;)o.push(t.call(n,r.value,this)),r=r.prev;return o},e.prototype.reduce=function(e,t){var n,o=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");o=this.head.next,n=this.head.value}for(var r=0;null!==o;r++)n=e(n,o.value,r),o=o.next;return n},e.prototype.reduceReverse=function(e,t){var n,o=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");o=this.tail.prev,n=this.tail.value}for(var r=this.length-1;null!==o;r--)n=e(n,o.value,r),o=o.prev;return n},e.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},e.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},e.prototype.slice=function(t,n){(n=n||this.length)<0&&(n+=this.length),(t=t||0)<0&&(t+=this.length);var o=new e;if(n<t||n<0)return o;t<0&&(t=0),n>this.length&&(n=this.length);for(var r=0,i=this.head;null!==i&&r<t;r++)i=i.next;for(;null!==i&&r<n;r++,i=i.next)o.push(i.value);return o},e.prototype.sliceReverse=function(t,n){(n=n||this.length)<0&&(n+=this.length),(t=t||0)<0&&(t+=this.length);var o=new e;if(n<t||n<0)return o;t<0&&(t=0),n>this.length&&(n=this.length);for(var r=this.length,i=this.tail;null!==i&&r>n;r--)i=i.prev;for(;null!==i&&r>t;r--,i=i.prev)o.push(i.value);return o},e.prototype.splice=function(e,n,...o){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,i=this.head;null!==i&&r<e;r++)i=i.next;var a=[];for(r=0;i&&r<n;r++)a.push(i.value),i=this.removeNode(i);null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev);for(r=0;r<o.length;r++)i=t(this,i,o[r]);return a},e.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var o=n.prev;n.prev=n.next,n.next=o}return this.head=t,this.tail=e,this};try{(M?P:(M=1,P=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}))(e)}catch(e){}return F}function _e(){if(q)return B;q=1;const e=Te(),t=Symbol("max"),n=Symbol("length"),o=Symbol("lengthCalculator"),r=Symbol("allowStale"),i=Symbol("maxAge"),a=Symbol("dispose"),s=Symbol("noDisposeOnSet"),l=Symbol("lruList"),c=Symbol("cache"),d=Symbol("updateAgeOnGet"),u=()=>1;const p=(e,t,n)=>{const o=e[c].get(t);if(o){const t=o.value;if(f(e,t)){if(v(e,o),!e[r])return}else n&&(e[d]&&(o.value.now=Date.now()),e[l].unshiftNode(o));return t.value}},f=(e,t)=>{if(!t||!t.maxAge&&!e[i])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[i]&&n>e[i]},h=e=>{if(e[n]>e[t])for(let o=e[l].tail;e[n]>e[t]&&null!==o;){const t=o.prev;v(e,o),o=t}},v=(e,t)=>{if(t){const o=t.value;e[a]&&e[a](o.key,o.value),e[n]-=o.length,e[c].delete(o.key),e[l].removeNode(t)}};class g{constructor(e,t,n,o,r){this.key=e,this.value=t,this.length=n,this.now=o,this.maxAge=r||0}}const y=(e,t,n,o)=>{let i=n.value;f(e,i)&&(v(e,n),e[r]||(i=void 0)),i&&t.call(o,i.value,i.key,e)};return B=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[t]=e.max||1/0;const n=e.length||u;if(this[o]="function"!=typeof n?u:n,this[r]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[i]=e.maxAge||0,this[a]=e.dispose,this[s]=e.noDisposeOnSet||!1,this[d]=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[t]=e||1/0,h(this)}get max(){return this[t]}set allowStale(e){this[r]=!!e}get allowStale(){return this[r]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[i]=e,h(this)}get maxAge(){return this[i]}set lengthCalculator(e){"function"!=typeof e&&(e=u),e!==this[o]&&(this[o]=e,this[n]=0,this[l].forEach(e=>{e.length=this[o](e.value,e.key),this[n]+=e.length})),h(this)}get lengthCalculator(){return this[o]}get length(){return this[n]}get itemCount(){return this[l].length}rforEach(e,t){t=t||this;for(let n=this[l].tail;null!==n;){const o=n.prev;y(this,e,n,t),n=o}}forEach(e,t){t=t||this;for(let n=this[l].head;null!==n;){const o=n.next;y(this,e,n,t),n=o}}keys(){return this[l].toArray().map(e=>e.key)}values(){return this[l].toArray().map(e=>e.value)}reset(){this[a]&&this[l]&&this[l].length&&this[l].forEach(e=>this[a](e.key,e.value)),this[c]=new Map,this[l]=new e,this[n]=0}dump(){return this[l].map(e=>!f(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[l]}set(e,r,d){if((d=d||this[i])&&"number"!=typeof d)throw new TypeError("maxAge must be a number");const u=d?Date.now():0,p=this[o](r,e);if(this[c].has(e)){if(p>this[t])return v(this,this[c].get(e)),!1;const o=this[c].get(e).value;return this[a]&&(this[s]||this[a](e,o.value)),o.now=u,o.maxAge=d,o.value=r,this[n]+=p-o.length,o.length=p,this.get(e),h(this),!0}const f=new g(e,r,p,u,d);return f.length>this[t]?(this[a]&&this[a](e,r),!1):(this[n]+=f.length,this[l].unshift(f),this[c].set(e,this[l].head),h(this),!0)}has(e){if(!this[c].has(e))return!1;const t=this[c].get(e).value;return!f(this,t)}get(e){return p(this,e,!0)}peek(e){return p(this,e,!1)}pop(){const e=this[l].tail;return e?(v(this,e),e.value):null}del(e){v(this,this[c].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const o=e[n],r=o.e||0;if(0===r)this.set(o.k,o.v);else{const e=r-t;e>0&&this.set(o.k,o.v,e)}}}prune(){this[c].forEach((e,t)=>p(this,t,!1))}}}function Je(){if(z)return V;z=1;const{isArray:e,isObject:t,isString:n}=Ne(),{asArray:o}=Ce(),{prependBase:r}=Ae(),i=Ee(),a=function(){if($)return U;$=1;const e=_e();return U=class{constructor({document:t}){this.document=t,this.cache=new e({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}}}();function s(e){throw new i("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function l({context:o,base:i}){if(!o)return;const a=o["@context"];if(n(a))o["@context"]=r(i,a);else if(e(a))for(let e=0;e<a.length;++e){const o=a[e];n(o)?a[e]=r(i,o):t(o)&&l({context:{"@context":o},base:i})}else if(t(a))for(const e in a)l({context:a[e],base:i})}return V=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:r,context:i,documentLoader:l,base:c,cycles:d=new Set}){i&&t(i)&&i["@context"]&&(i=i["@context"]),i=o(i);const u=[];for(const o of i){if(n(o)){let t=this._get(o);t||(t=await this._resolveRemoteContext({activeCtx:r,url:o,documentLoader:l,base:c,cycles:d})),e(t)?u.push(...t):u.push(t);continue}if(null===o){u.push(new a({document:null}));continue}t(o)||s(i);const p=JSON.stringify(o);let f=this._get(p);f||(f=new a({document:o}),this._cacheResolvedContext({key:p,resolved:f,tag:"static"})),u.push(f)}return u}_get(e){let t=this.perOpCache.get(e);if(!t){const n=this.sharedCache.get(e);n&&(t=n.get("static"),t&&this.perOpCache.set(e,t))}return t}_cacheResolvedContext({key:e,resolved:t,tag:n}){if(this.perOpCache.set(e,t),void 0!==n){let o=this.sharedCache.get(e);o||(o=new Map,this.sharedCache.set(e,o)),o.set(n,t)}return t}async _resolveRemoteContext({activeCtx:e,url:t,documentLoader:n,base:o,cycles:i}){t=r(o,t);const{context:a,remoteDoc:s}=await this._fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:i});l({context:a,base:o=s.documentUrl||t});const c=await this.resolve({activeCtx:e,context:a,documentLoader:n,base:o,cycles:i});return this._cacheResolvedContext({key:t,resolved:c,tag:s.tag}),c}async _fetchContext({activeCtx:o,url:r,documentLoader:a,cycles:s}){if(s.size>10)throw new i("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"json-ld-1.0"===o.processingMode?"loading remote context failed":"context overflow",max:10});if(s.has(r))throw new i("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===o.processingMode?"recursive context inclusion":"context overflow",url:r});let l,c;s.add(r);try{c=await a(r),l=c.document||null,n(l)&&(l=JSON.parse(l))}catch(e){throw new i(`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: "${r}".`,"jsonld.InvalidUrl",{code:"loading remote context failed",url:r,cause:e})}if(!t(l))throw new i(`Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object. URL: "${r}".`,"jsonld.InvalidUrl",{code:"invalid remote context",url:r});return l="@context"in l?{"@context":l["@context"]}:{"@context":{}},c.contextUrl&&(e(l["@context"])||(l["@context"]=[l["@context"]]),l["@context"].push(c.contextUrl)),{context:l,remoteDoc:c}}},V}function Pe(){return Q?G:(Q=1,G=De().NQuads)}function Me(){if(X)return W;X=1;const e=Ee(),{isArray:t}=Ne(),{asArray:n}=Ce(),o={};function r({event:n,handlers:o}){let i=!0;for(let a=0;i&&a<o.length;++a){i=!1;const s=o[a];if(t(s))i=r({event:n,handlers:s});else if("function"==typeof s)s({event:n,next:()=>{i=!0}});else{if("object"!=typeof s)throw new e("Invalid event handler.","jsonld.InvalidEventHandler",{event:n});n.code in s?s[n.code]({event:n,next:()=>{i=!0}}):i=!0}}return i}W=o,o.defaultEventHandler=null,o.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?o.safeEventHandler:[],e.eventHandler?n(e.eventHandler):[],o.defaultEventHandler?o.defaultEventHandler:[]);return 0===t.length?null:t},o.handleEvent=({event:e,options:t})=>{r({event:e,handlers:t.eventHandler})};const i=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"]);return o.safeEventHandler=function({event:t,next:n}){if("warning"===t.level&&i.has(t.code))throw new e("Safe mode validation error.","jsonld.ValidationError",{event:t});n()},o.logEventHandler=function({event:e,next:t}){console.log(`EVENT: ${e.message}`,{event:e}),t()},o.logWarningEventHandler=function({event:e,next:t}){"warning"===e.level&&console.warn(`WARNING: ${e.message}`,{event:e}),t()},o.unhandledEventHandler=function({event:t}){throw new e("No handler for event.","jsonld.UnhandledEvent",{event:t})},o.setDefaultEventHandler=function({eventHandler:e}={}){o.defaultEventHandler=e?n(e):null},W}function Fe(){if(Z)return K;Z=1;const e=Ce(),t=Ee(),{isArray:n,isObject:o,isString:r,isUndefined:i}=Ne(),{isAbsolute:a,isRelative:s,prependBase:l}=Ae(),{handleEvent:c}=Me(),{REGEX_BCP47:d,REGEX_KEYWORD:u,asArray:p,compareShortestLeast:f}=Ce(),h=new Map,v={};function g(e,t,n,i,s,c){if(null===t||!r(t)||v.isKeyword(t))return t;if(t.match(u))return null;if(i&&i.hasOwnProperty(t)&&!0!==s.get(t)&&v.createTermDefinition({activeCtx:e,localCtx:i,term:t,defined:s,options:c}),(n=n||{}).vocab){const n=e.mappings.get(t);if(null===n)return null;if(o(n)&&"@id"in n)return n["@id"]}const d=t.indexOf(":");if(d>0){const n=t.substr(0,d),o=t.substr(d+1);if("_"===n||0===o.indexOf("//"))return t;i&&i.hasOwnProperty(n)&&v.createTermDefinition({activeCtx:e,localCtx:i,term:n,defined:s,options:c});const r=e.mappings.get(n);if(r&&r._prefix)return r["@id"]+o;if(a(t))return t}if(n.vocab&&"@vocab"in e){t=e["@vocab"]+t}else if(n.base){let n,o;"@base"in e?e["@base"]?(o=l(c.base,e["@base"]),n=l(o,t)):(o=e["@base"],n=t):(o=c.base,n=l(c.base,t)),t=n}return t}function y(e,t){if(!e||"object"!=typeof e||!t||"object"!=typeof t)return e===t;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!y(e[n],t[n]))return!1;return!0}const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const n in e){let o=e[n],r=t[n];if("@container"===n&&Array.isArray(o)&&Array.isArray(r)&&(o=o.slice().sort(),r=r.slice().sort()),!y(o,r))return!1}return!0}return K=v,v.process=async({activeCtx:e,localCtx:i,options:u,propagate:f=!0,overrideProtected:h=!1,cycles:y=new Set})=>{o(i)&&"@context"in i&&n(i["@context"])&&(i=i["@context"]);if(0===p(i).length)return e;const m=[],x=[({event:e,next:t})=>{m.push(e),t()}];u.eventHandler&&x.push(u.eventHandler);const b=u;u={...u,eventHandler:x};const w=await u.contextResolver.resolve({activeCtx:e,context:i,documentLoader:u.documentLoader,base:u.base});o(w[0].document)&&"boolean"==typeof w[0].document["@propagate"]&&(f=w[0].document["@propagate"]);let I=e;f||I.previousContext||(I=I.clone(),I.previousContext=e);for(const n of w){let{document:p}=n;if(e=I,null===p){if(!h&&0!==Object.keys(e.protected).length)throw new t("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});I=e=v.getInitialContext(u).clone();continue}const f=n.getProcessed(e);if(f){if(b.eventHandler)for(const e of f.events)c({event:e,options:b});I=e=f.context;continue}if(o(p)&&"@context"in p&&(p=p["@context"]),!o(p))throw new t("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:p});I=I.clone();const x=new Map;if("@version"in p){if(1.1!==p["@version"])throw new t("Unsupported JSON-LD version: "+p["@version"],"jsonld.UnsupportedVersion",{code:"invalid @version value",context:p});if(e.processingMode&&"json-ld-1.0"===e.processingMode)throw new t("@version: "+p["@version"]+" not compatible with "+e.processingMode,"jsonld.ProcessingModeConflict",{code:"processing mode conflict",context:p});I.processingMode="json-ld-1.1",I["@version"]=p["@version"],x.set("@version",!0)}if(I.processingMode=I.processingMode||e.processingMode,"@base"in p){let e=p["@base"];if(null===e||a(e));else{if(!s(e))throw new t('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:p});e=l(I["@base"],e)}I["@base"]=e,x.set("@base",!0)}if("@vocab"in p){const e=p["@vocab"];if(null===e)delete I["@vocab"];else{if(!r(e))throw new t('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:p});if(!a(e)&&v.processingMode(I,1))throw new t('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:p});{const t=g(I,e,{vocab:!0,base:!0},void 0,void 0,u);a(t)||u.eventHandler&&c({event:{type:["JsonLdEvent"],code:"relative @vocab reference",level:"warning",message:"Relative @vocab reference found.",details:{vocab:t}},options:u}),I["@vocab"]=t}}x.set("@vocab",!0)}if("@language"in p){const e=p["@language"];if(null===e)delete I["@language"];else{if(!r(e))throw new t('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:p});e.match(d)||u.eventHandler&&c({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:u}),I["@language"]=e.toLowerCase()}x.set("@language",!0)}if("@direction"in p){const n=p["@direction"];if("json-ld-1.0"===e.processingMode)throw new t("Invalid JSON-LD syntax; @direction not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context member",context:p});if(null===n)delete I["@direction"];else{if("ltr"!==n&&"rtl"!==n)throw new t('Invalid JSON-LD syntax; the value of "@direction" in a @context must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:p});I["@direction"]=n}x.set("@direction",!0)}if("@propagate"in p){const n=p["@propagate"];if("json-ld-1.0"===e.processingMode)throw new t("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:p});if("boolean"!=typeof n)throw new t("Invalid JSON-LD syntax; @propagate value must be a boolean.","jsonld.SyntaxError",{code:"invalid @propagate value",context:i});x.set("@propagate",!0)}if("@import"in p){const n=p["@import"];if("json-ld-1.0"===e.processingMode)throw new t("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:p});if(!r(n))throw new t("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:i});const o=await u.contextResolver.resolve({activeCtx:e,context:n,documentLoader:u.documentLoader,base:u.base});if(1!==o.length)throw new t("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:i});const a=o[0].getProcessed(e);if(a)p=a;else{const n=o[0].document;if("@import"in n)throw new t("Invalid JSON-LD syntax: imported context must not include @import.","jsonld.SyntaxError",{code:"invalid context entry",context:i});for(const e in n)p.hasOwnProperty(e)||(p[e]=n[e]);o[0].setProcessed(e,p)}x.set("@import",!0)}x.set("@protected",p["@protected"]||!1);for(const e in p)if(v.createTermDefinition({activeCtx:I,localCtx:p,term:e,defined:x,options:u,overrideProtected:h}),o(p[e])&&"@context"in p[e]){const n=p[e]["@context"];let o=!0;if(r(n)){const e=l(u.base,n);y.has(e)?o=!1:y.add(e)}if(o)try{await v.process({activeCtx:I.clone(),localCtx:p[e]["@context"],overrideProtected:!0,options:u,cycles:y})}catch(n){throw new t("Invalid JSON-LD syntax; invalid scoped context.","jsonld.SyntaxError",{code:"invalid scoped context",context:p[e]["@context"],term:e})}}n.setProcessed(e,{context:I,events:m})}return I},v.createTermDefinition=({activeCtx:e,localCtx:i,term:s,defined:l,options:d,overrideProtected:p=!1})=>{if(l.has(s)){if(l.get(s))return;throw new t("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:i,term:s})}let f;if(l.set(s,!1),i.hasOwnProperty(s)&&(f=i[s]),"@type"===s&&o(f)&&"@set"===(f["@container"]||"@set")&&v.processingMode(e,1.1)){const e=["@container","@id","@protected"],n=Object.keys(f);if(0===n.length||n.some(t=>!e.includes(t)))throw new t("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:i,term:s})}else{if(v.isKeyword(s))throw new t("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:i,term:s});if(s.match(u))return void(d.eventHandler&&c({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:s}},options:d}));if(""===s)throw new t("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:i})}const h=e.mappings.get(s);e.mappings.has(s)&&e.mappings.delete(s);let m=!1;if((r(f)||null===f)&&(m=!0,f={"@id":f}),!o(f))throw new t("Invalid JSON-LD syntax; @context term values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:i});const x={};e.mappings.set(s,x),x.reverse=!1;const b=["@container","@id","@language","@reverse","@type"];v.processingMode(e,1.1)&&b.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in f)if(!b.includes(e))throw new t("Invalid JSON-LD syntax; a term definition must not contain "+e,"jsonld.SyntaxError",{code:"invalid term definition",context:i});const w=s.indexOf(":");if(x._termHasColon=w>0,"@reverse"in f){if("@id"in f)throw new t("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:i});if("@nest"in f)throw new t("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:i});const n=f["@reverse"];if(!r(n))throw new t("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i});if(n.match(u))return d.eventHandler&&c({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:n}},options:d}),void(h?e.mappings.set(s,h):e.mappings.delete(s));const o=g(e,n,{vocab:!0,base:!1},i,l,d);if(!a(o))throw new t("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:i});x["@id"]=o,x.reverse=!0}else if("@id"in f){let n=f["@id"];if(n&&!r(n))throw new t("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i});if(null===n)x["@id"]=null;else{if(!v.isKeyword(n)&&n.match(u))return d.eventHandler&&c({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:n}},options:d}),void(h?e.mappings.set(s,h):e.mappings.delete(s));if(n!==s){if(n=g(e,n,{vocab:!0,base:!1},i,l,d),!a(n)&&!v.isKeyword(n))throw new t("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:i});if(s.match(/(?::[^:])|\//)){if(g(e,s,{vocab:!0,base:!1},i,new Map(l).set(s,!0),d)!==n)throw new t("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i})}x["@id"]=n,x._prefix=m&&!x._termHasColon&&null!==n.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in x))if(x._termHasColon){const t=s.substr(0,w);if(i.hasOwnProperty(t)&&v.createTermDefinition({activeCtx:e,localCtx:i,term:t,defined:l,options:d}),e.mappings.has(t)){const n=s.substr(w+1);x["@id"]=e.mappings.get(t)["@id"]+n}else x["@id"]=s}else if("@type"===s)x["@id"]=s;else{if(!("@vocab"in e))throw new t("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:i,term:s});x["@id"]=e["@vocab"]+s}if((!0===f["@protected"]||!0===l.get("@protected")&&!1!==f["@protected"])&&(e.protected[s]=!0,x.protected=!0),l.set(s,!0),"@type"in f){let n=f["@type"];if(!r(n))throw new t("Invalid JSON-LD syntax; an @context @type value must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:i});if("@json"===n||"@none"===n){if(v.processingMode(e,1))throw new t(`Invalid JSON-LD syntax; an @context @type value must not be "${n}" in JSON-LD 1.0 mode.`,"jsonld.SyntaxError",{code:"invalid type mapping",context:i})}else if("@id"!==n&&"@vocab"!==n){if(n=g(e,n,{vocab:!0,base:!1},i,l,d),!a(n))throw new t("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:i});if(0===n.indexOf("_:"))throw new t("Invalid JSON-LD syntax; an @context @type value must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:i})}x["@type"]=n}if("@container"in f){const o=r(f["@container"])?[f["@container"]]:f["@container"]||[],a=["@list","@set","@index","@language"];let s=!0;const l=o.includes("@set");if(v.processingMode(e,1.1)){if(a.push("@graph","@id","@type"),o.includes("@list")){if(1!==o.length)throw new t("Invalid JSON-LD syntax; @context @container with @list must have no other values","jsonld.SyntaxError",{code:"invalid container mapping",context:i})}else if(o.includes("@graph")){if(o.some(e=>"@graph"!==e&&"@id"!==e&&"@index"!==e&&"@set"!==e))throw new t("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:i})}else s&=o.length<=(l?2:1);if(o.includes("@type")&&(x["@type"]=x["@type"]||"@id",!["@id","@vocab"].includes(x["@type"])))throw new t("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:i})}else s&=!n(f["@container"]),s&=o.length<=1;if(s&=o.every(e=>a.includes(e)),s&=!(l&&o.includes("@list")),!s)throw new t("Invalid JSON-LD syntax; @context @container value must be one of the following: "+a.join(", "),"jsonld.SyntaxError",{code:"invalid container mapping",context:i});if(x.reverse&&!o.every(e=>["@index","@set"].includes(e)))throw new t("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:i});x["@container"]=o}if("@index"in f){if(!("@container"in f)||!x["@container"].includes("@index"))throw new t(`Invalid JSON-LD syntax; @index without @index in @container: "${f["@index"]}" on term "${s}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:i});if(!r(f["@index"])||0===f["@index"].indexOf("@"))throw new t(`Invalid JSON-LD syntax; @index must expand to an IRI: "${f["@index"]}" on term "${s}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:i});x["@index"]=f["@index"]}if("@context"in f&&(x["@context"]=f["@context"]),"@language"in f&&!("@type"in f)){let e=f["@language"];if(null!==e&&!r(e))throw new t("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:i});null!==e&&(e=e.toLowerCase()),x["@language"]=e}if("@prefix"in f){if(s.match(/:|\//))throw new t("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:i});if(v.isKeyword(x["@id"]))throw new t("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:i});if("boolean"!=typeof f["@prefix"])throw new t("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:i});x._prefix=!0===f["@prefix"]}if("@direction"in f){const e=f["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new t('Invalid JSON-LD syntax; @direction value must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:i});x["@direction"]=e}if("@nest"in f){const e=f["@nest"];if(!r(e)||"@nest"!==e&&0===e.indexOf("@"))throw new t("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:i});x["@nest"]=e}
|
|
20
|
+
// disallow aliasing @context and @preserve
|
|
21
|
+
const I=x["@id"];if("@context"===I||"@preserve"===I)throw new t("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:i});if(h&&h.protected&&!p&&(e.protected[s]=!0,x.protected=!0,!y(h,x)))throw new t("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:i,term:s})},v.expandIri=(e,t,n,o)=>g(e,t,n,void 0,void 0,o),v.getInitialContext=t=>{const n=JSON.stringify({processingMode:t.processingMode}),o=h.get(n);if(o)return o;const r={processingMode:t.processingMode,mappings:new Map,inverse:null,getInverse:function(){const e=this;if(e.inverse)return e.inverse;const t=e.inverse={},n=e.fastCurieMap={},o={},r=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],l=e.mappings,c=[...l.keys()].sort(f);for(const e of c){const i=l.get(e);if(null===i)continue;let c=i["@container"]||"@none";if(c=[].concat(c).sort().join(""),null===i["@id"])continue;const d=p(i["@id"]);for(const l of d){let d=t[l];const u=v.isKeyword(l);if(d)u||i._termHasColon||o[l].push(e);else if(t[l]=d={},!u&&!i._termHasColon){o[l]=[e];const t={iri:l,terms:o[l]};l[0]in n?n[l[0]].push(t):n[l[0]]=[t]}if(d[c]||(d[c]={"@language":{},"@type":{},"@any":{}}),d=d[c],a(e,d["@any"],"@none"),i.reverse)a(e,d["@type"],"@reverse");else if("@none"===i["@type"])a(e,d["@any"],"@none"),a(e,d["@language"],"@none"),a(e,d["@type"],"@none");else if("@type"in i)a(e,d["@type"],i["@type"]);else if("@language"in i&&"@direction"in i){const t=i["@language"],n=i["@direction"];a(e,d["@language"],t&&n?`${t}_${n}`.toLowerCase():t?t.toLowerCase():n?`_${n}`:"@null")}else"@language"in i?a(e,d["@language"],(i["@language"]||"@null").toLowerCase()):"@direction"in i?i["@direction"]?a(e,d["@language"],`_${i["@direction"]}`):a(e,d["@language"],"@none"):s?(a(e,d["@language"],`_${s}`),a(e,d["@language"],"@none"),a(e,d["@type"],"@none")):(a(e,d["@language"],r),a(e,d["@language"],"@none"),a(e,d["@type"],"@none"))}}for(const e in n)i(n,e,1);return t},clone:function(){const t={};t.mappings=e.clone(this.mappings),t.clone=this.clone,t.inverse=null,t.getInverse=this.getInverse,t.protected=e.clone(this.protected),this.previousContext&&(t.previousContext=this.previousContext.clone());t.revertToPreviousContext=this.revertToPreviousContext,"@base"in this&&(t["@base"]=this["@base"]);"@language"in this&&(t["@language"]=this["@language"]);"@vocab"in this&&(t["@vocab"]=this["@vocab"]);return t},revertToPreviousContext:function(){if(!this.previousContext)return this;return this.previousContext.clone()},protected:{}};return 1e4===h.size&&h.clear(),h.set(n,r),r;function i(e,t,n){const o=e[t],r=e[t]={};let a,s;for(const e of o)a=e.iri,s=n>=a.length?"":a[n],s in r?r[s].push(e):r[s]=[e];for(const e in r)""!==e&&i(r,e,n+1)}function a(e,t,n){t.hasOwnProperty(n)||(t[n]=e)}},v.getContextValue=(e,t,n)=>{if(null===t){if("@context"===n)return;return null}if(e.mappings.has(t)){const o=e.mappings.get(t);if(i(n))return o;if(o.hasOwnProperty(n))return o[n]}return"@language"===n&&n in e||"@direction"===n&&n in e?e[n]:"@context"!==n?null:void 0},v.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,v.isKeyword=e=>{if(!r(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},K}function He(){if(ee)return Y;ee=1;const e=Ee(),{isArray:t,isObject:n,isEmptyObject:o,isString:r,isUndefined:i}=Ne(),{isList:a,isValue:s,isGraph:l,isSubject:c}=Oe(),{expandIri:d,getContextValue:u,isKeyword:p,process:f,processingMode:h}=Fe(),{isAbsolute:v}=Ae(),{REGEX_BCP47:g,REGEX_KEYWORD:y,addValue:m,asArray:x,getValues:b,validateTypeValue:w}=Ce(),{handleEvent:I}=Me(),j={};function S({value:e,count:t,options:n}){if(0===t||"@value"in e||"@list"in e||1===t&&"@id"in e){if(n.eventHandler){let o,r;0===t?(o="empty object",r="Dropping empty object."):"@value"in e?(o="object with only @value",r="Dropping object with only @value."):"@list"in e?(o="object with only @list",r="Dropping object with only @list."):1===t&&"@id"in e&&(o="object with only @id",r="Dropping object with only @id."),I({event:{type:["JsonLdEvent"],code:o,level:"warning",message:r,details:{value:e}},options:n})}return null}return e}async function D({activeCtx:l,activeProperty:y,expandedActiveProperty:b,element:N,expandedParent:C,options:k={},insideList:L,typeKey:A,typeScopedContext:R}){const T=Object.keys(N).sort(),_=[];let J;const P=N[A]&&"@json"===d(l,t(N[A])?N[A][0]:N[A],{vocab:!0},{...k,typeExpansion:!0});for(const D of T){let L,A=N[D];if("@context"===D)continue;const T=d(l,D,{vocab:!0},k);if(null===T||!v(T)&&!p(T)){k.eventHandler&&I({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:D,expandedProperty:T}},options:k});continue}if(p(T)){if("@reverse"===b)throw new e("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:A});if(T in C&&"@included"!==T&&"@type"!==T)throw new e("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:T})}if("@id"===T){if(!r(A)){if(!k.isFrame)throw new e('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:A});if(n(A)){if(!o(A))throw new e('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A})}else{if(!t(A))throw new e('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A});if(!A.every(e=>r(e)))throw new e('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:A})}}m(C,"@id",x(A).map(e=>{if(r(e)){const t=d(l,e,{base:!0},k);return k.eventHandler&&(null===t?I(null===e?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:e}},options:k}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:e}},options:k}):v(t)||I({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:e,expandedId:t}},options:k})),t}return e}),{propertyIsArray:k.isFrame});continue}if("@type"===T){n(A)&&(A=Object.fromEntries(Object.entries(A).map(([e,t])=>[d(R,e,{vocab:!0}),x(t).map(e=>d(R,e,{base:!0,vocab:!0},{...k,typeExpansion:!0}))]))),w(A,k.isFrame),m(C,"@type",x(A).map(e=>{if(r(e)){const t=d(R,e,{base:!0,vocab:!0},{...k,typeExpansion:!0});return"@json"===t||v(t)||k.eventHandler&&I({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:k}),t}return e}),{propertyIsArray:!!k.isFrame});continue}if("@included"===T&&h(l,1.1)){const t=x(await j.expand({activeCtx:l,activeProperty:y,element:A,options:k}));if(!t.every(e=>c(e)))throw new e("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:A});m(C,"@included",t,{propertyIsArray:!0});continue}if("@graph"===T&&!n(A)&&!t(A))throw new e('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:A});if("@value"===T){J=A,P&&h(l,1.1)?C["@value"]=A:m(C,"@value",A,{propertyIsArray:k.isFrame});continue}if("@language"===T){if(null===A)continue;if(!r(A)&&!k.isFrame)throw new e('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:A});A=x(A).map(e=>r(e)?e.toLowerCase():e);for(const e of A)r(e)&&!e.match(g)&&k.eventHandler&&I({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:k});m(C,"@language",A,{propertyIsArray:k.isFrame});continue}if("@direction"===T){if(!r(A)&&!k.isFrame)throw new e('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:A});A=x(A);for(const t of A)if(r(t)&&"ltr"!==t&&"rtl"!==t)throw new e('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:A});m(C,"@direction",A,{propertyIsArray:k.isFrame});continue}if("@index"===T){if(!r(A))throw new e('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:A});m(C,"@index",A);continue}if("@reverse"===T){if(!n(A))throw new e('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:A});if(L=await j.expand({activeCtx:l,activeProperty:"@reverse",element:A,options:k}),"@reverse"in L)for(const e in L["@reverse"])m(C,e,L["@reverse"][e],{propertyIsArray:!0});let t=C["@reverse"]||null;for(const n in L){if("@reverse"===n)continue;null===t&&(t=C["@reverse"]={}),m(t,n,[],{propertyIsArray:!0});const o=L[n];for(let r=0;r<o.length;++r){const i=o[r];if(s(i)||a(i))throw new e('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:L});m(t,n,i,{propertyIsArray:!0})}}continue}if("@nest"===T){_.push(D);continue}let M=l;const F=u(l,D,"@context");i(F)||(M=await f({activeCtx:l,localCtx:F,propagate:!0,overrideProtected:!0,options:k}));const H=u(l,D,"@container")||[];if(H.includes("@language")&&n(A)){L=O(M,A,u(M,D,"@direction"),k)}else if(H.includes("@index")&&n(A)){const e=H.includes("@graph"),t=u(M,D,"@index")||"@index",n="@index"!==t&&d(l,t,{vocab:!0},k);L=await E({activeCtx:M,options:k,activeProperty:D,value:A,asGraph:e,indexKey:t,propertyIndex:n})}else if(H.includes("@id")&&n(A)){const e=H.includes("@graph");L=await E({activeCtx:M,options:k,activeProperty:D,value:A,asGraph:e,indexKey:"@id"})}else if(H.includes("@type")&&n(A))L=await E({activeCtx:M.revertToPreviousContext(),options:k,activeProperty:D,value:A,asGraph:!1,indexKey:"@type"});else{const e="@list"===T;if(e||"@set"===T){let t=y;e&&"@graph"===b&&(t=null),L=await j.expand({activeCtx:M,activeProperty:t,element:A,options:k,insideList:e})}else L="@json"===u(l,D,"@type")?{"@type":"@json","@value":A}:await j.expand({activeCtx:M,activeProperty:D,element:A,options:k,insideList:!1})}if(null!==L||"@value"===T){if("@list"!==T&&!a(L)&&H.includes("@list")&&(L={"@list":x(L)}),H.includes("@graph")&&!H.some(e=>"@id"===e||"@index"===e)){if(L=x(L),k.isFrame||(L=L.filter(e=>null!==S({value:e,count:Object.keys(e).length,options:k}))),0===L.length)continue;L=L.map(e=>({"@graph":x(e)}))}if(M.mappings.has(D)&&M.mappings.get(D).reverse){const t=C["@reverse"]=C["@reverse"]||{};L=x(L);for(let n=0;n<L.length;++n){const o=L[n];if(s(o)||a(o))throw new e('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:L});m(t,T,o,{propertyIsArray:!0})}continue}m(C,T,L,{propertyIsArray:!0})}}if("@value"in C)if("@json"===C["@type"]&&h(l,1.1));else if((n(J)||t(J))&&!k.isFrame)throw new e('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:J});for(const o of _){const r=t(N[o])?N[o]:[N[o]];for(const t of r){if(!n(t)||Object.keys(t).some(e=>"@value"===d(l,e,{vocab:!0},k)))throw new e("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:t});await D({activeCtx:l,activeProperty:y,expandedActiveProperty:b,element:t,expandedParent:C,options:k,insideList:L,typeScopedContext:R,typeKey:A})}}}function N({activeCtx:e,activeProperty:t,value:n,options:o}){if(null==n)return null;const i=d(e,t,{vocab:!0},o);if("@id"===i)return d(e,n,{base:!0},o);if("@type"===i)return d(e,n,{vocab:!0,base:!0},{...o,typeExpansion:!0});const a=u(e,t,"@type");if(("@id"===a||"@graph"===i)&&r(n)){const r=d(e,n,{base:!0},o);return null===r&&n.match(y)&&o.eventHandler&&I({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}),{"@id":r}}if("@vocab"===a&&r(n))return{"@id":d(e,n,{vocab:!0,base:!0},o)};if(p(i))return n;const s={};if(a&&!["@id","@vocab","@none"].includes(a))s["@type"]=a;else if(r(n)){const n=u(e,t,"@language");null!==n&&(s["@language"]=n);const o=u(e,t,"@direction");null!==o&&(s["@direction"]=o)}return["boolean","number","string"].includes(typeof n)||(n=n.toString()),s["@value"]=n,s}function O(n,o,i,a){const s=[],l=Object.keys(o).sort();for(const c of l){const l=d(n,c,{vocab:!0},a);let u=o[c];t(u)||(u=[u]);for(const t of u){if(null===t)continue;if(!r(t))throw new e("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:o});const n={"@value":t};"@none"!==l&&(c.match(g)||a.eventHandler&&I({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:c}},options:a}),n["@language"]=c.toLowerCase()),i&&(n["@direction"]=i),s.push(n)}}return s}async function E({activeCtx:n,options:o,activeProperty:r,value:a,asGraph:c,indexKey:p,propertyIndex:h}){const v=[],g=Object.keys(a).sort(),y="@type"===p;for(let x of g){if(y){const e=u(n,x,"@context");i(e)||(n=await f({activeCtx:n,localCtx:e,propagate:!1,options:o}))}let g,b=a[x];t(b)||(b=[b]),b=await j.expand({activeCtx:n,activeProperty:r,element:b,options:o,insideList:!1,insideIndex:!0}),g=h?"@none"===x?"@none":N({activeCtx:n,activeProperty:p,value:x,options:o}):d(n,x,{vocab:!0},o),"@id"===p?x=d(n,x,{base:!0},o):y&&(x=g);for(let t of b){if(c&&!l(t)&&(t={"@graph":[t]}),"@type"===p)"@none"===g||(t["@type"]?t["@type"]=[x].concat(t["@type"]):t["@type"]=[x]);else{if(s(t)&&!["@language","@type","@index"].includes(p))throw new e(`Invalid JSON-LD syntax; Attempt to add illegal key to value object: "${p}".`,"jsonld.SyntaxError",{code:"invalid value object",value:t});h?"@none"!==g&&m(t,h,g,{propertyIsArray:!0,prependValue:!0}):"@none"===g||p in t||(t[p]=x)}v.push(t)}}return v}return Y=j,j.expand=async({activeCtx:a,activeProperty:s=null,element:l,options:c={},insideList:p=!1,insideIndex:g=!1,typeScopedContext:y=null})=>{if(null==l)return null;if("@default"===s&&(c=Object.assign({},c,{isFrame:!1})),!t(l)&&!n(l))return p||null!==s&&"@graph"!==d(a,s,{vocab:!0},c)?N({activeCtx:a,activeProperty:s,value:l,options:c}):(c.eventHandler&&I({event:{type:["JsonLdEvent"],code:"free-floating scalar",level:"warning",message:"Dropping free-floating scalar not in a list.",details:{value:l}},options:c}),null);if(t(l)){let e=[];const n=u(a,s,"@container")||[];p=p||n.includes("@list");for(let n=0;n<l.length;++n){let o=await j.expand({activeCtx:a,activeProperty:s,element:l[n],options:c,insideIndex:g,typeScopedContext:y});p&&t(o)&&(o={"@list":o}),null!==o&&(t(o)?e=e.concat(o):e.push(o))}return e}const m=d(a,s,{vocab:!0},c),w=u(a,s,"@context");y=y||(a.previousContext?a:null);let O=Object.keys(l).sort(),E=!g;if(E&&y&&O.length<=2&&!O.includes("@context"))for(const e of O){const t=d(y,e,{vocab:!0},c);if("@value"===t){E=!1,a=y;break}if("@id"===t&&1===O.length){E=!1;break}}E&&(a=a.revertToPreviousContext()),i(w)||(a=await f({activeCtx:a,localCtx:w,propagate:!0,overrideProtected:!0,options:c})),"@context"in l&&(a=await f({activeCtx:a,localCtx:l["@context"],options:c})),y=a;let C=null;for(const e of O){if("@type"===d(a,e,{vocab:!0},c)){C=C||e;const t=l[e],n=Array.isArray(t)?t.length>1?t.slice().sort():t:[t];for(const e of n){const t=u(y,e,"@context");i(t)||(a=await f({activeCtx:a,localCtx:t,options:c,propagate:!1}))}}}let k={};await D({activeCtx:a,activeProperty:s,expandedActiveProperty:m,element:l,expandedParent:k,options:c,insideList:p,typeKey:C,typeScopedContext:y}),O=Object.keys(k);let L=O.length;if("@value"in k){if("@type"in k&&("@language"in k||"@direction"in k))throw new e('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:k});let t=L-1;if("@type"in k&&(t-=1),"@index"in k&&(t-=1),"@language"in k&&(t-=1),"@direction"in k&&(t-=1),0!==t)throw new e('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:k});const n=null===k["@value"]?[]:x(k["@value"]),i=b(k,"@type");if(h(a,1.1)&&i.includes("@json")&&1===i.length);else if(0===n.length)c.eventHandler&&I({event:{type:["JsonLdEvent"],code:"null @value value",level:"warning",message:"Dropping null @value value.",details:{value:k}},options:c}),k=null;else{if(!n.every(e=>r(e)||o(e))&&"@language"in k)throw new e("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:k});if(!i.every(e=>v(e)&&!(r(e)&&0===e.indexOf("_:"))||o(e)))throw new e('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:k})}}else if("@type"in k&&!t(k["@type"]))k["@type"]=[k["@type"]];else if("@set"in k||"@list"in k){if(L>1&&(2!==L||!("@index"in k)))throw new e('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:k});"@set"in k&&(k=k["@set"],O=Object.keys(k),L=O.length)}else 1===L&&"@language"in k&&(c.eventHandler&&I({event:{type:["JsonLdEvent"],code:"object with only @language",level:"warning",message:"Dropping object with only @language.",details:{value:k}},options:c}),k=null);return!n(k)||c.keepFreeFloatingNodes||p||null!==s&&"@graph"!==m&&!(u(a,s,"@container")||[]).includes("@graph")||(k=S({value:k,count:L,options:c})),k},Y}function Be(){if(ne)return te;ne=1;const{isKeyword:e}=Fe(),t=Oe(),n=Ne(),o=Ce(),r=Ee(),i={};return te=i,i.createMergedNodeMap=(e,t)=>{const n=(t=t||{}).issuer||new o.IdentifierIssuer("_:b"),r={"@default":{}};return i.createNodeMap(e,r,"@default",n),i.mergeNodeMaps(r)},i.createNodeMap=(a,s,l,c,d,u)=>{if(n.isArray(a)){for(const e of a)i.createNodeMap(e,s,l,c,void 0,u);return}if(!n.isObject(a))return void(u&&u.push(a));if(t.isValue(a)){if("@type"in a){let e=a["@type"];0===e.indexOf("_:")&&(a["@type"]=e=c.getId(e))}return void(u&&u.push(a))}if(u&&t.isList(a)){const e=[];return i.createNodeMap(a["@list"],s,l,c,d,e),void u.push({"@list":e})}if("@type"in a){const e=a["@type"];for(const t of e)0===t.indexOf("_:")&&c.getId(t)}n.isUndefined(d)&&(d=t.isBlankNode(a)?c.getId(a["@id"]):a["@id"]),u&&u.push({"@id":d});const p=s[l],f=p[d]=p[d]||{};f["@id"]=d;const h=Object.keys(a).sort();for(let n of h){if("@id"===n)continue;if("@reverse"===n){const e={"@id":d},n=a["@reverse"];for(const r in n){const a=n[r];for(const n of a){let a=n["@id"];t.isBlankNode(n)&&(a=c.getId(a)),i.createNodeMap(n,s,l,c,a),o.addValue(p[a],r,e,{propertyIsArray:!0,allowDuplicate:!1})}}continue}if("@graph"===n){d in s||(s[d]={}),i.createNodeMap(a[n],s,d,c);continue}if("@included"===n){i.createNodeMap(a[n],s,l,c);continue}if("@type"!==n&&e(n)){if("@index"===n&&n in f&&(a[n]!==f[n]||a[n]["@id"]!==f[n]["@id"]))throw new r("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:f});f[n]=a[n];continue}const u=a[n];if(0===n.indexOf("_:")&&(n=c.getId(n)),0!==u.length)for(let e of u)if("@type"===n&&(e=0===e.indexOf("_:")?c.getId(e):e),t.isSubject(e)||t.isSubjectReference(e)){if("@id"in e&&!e["@id"])continue;const r=t.isBlankNode(e)?c.getId(e["@id"]):e["@id"];o.addValue(f,n,{"@id":r},{propertyIsArray:!0,allowDuplicate:!1}),i.createNodeMap(e,s,l,c,r)}else if(t.isValue(e))o.addValue(f,n,e,{propertyIsArray:!0,allowDuplicate:!1});else if(t.isList(e)){const t=[];i.createNodeMap(e["@list"],s,l,c,d,t),e={"@list":t},o.addValue(f,n,e,{propertyIsArray:!0,allowDuplicate:!1})}else i.createNodeMap(e,s,l,c,d),o.addValue(f,n,e,{propertyIsArray:!0,allowDuplicate:!1});else o.addValue(f,n,[],{propertyIsArray:!0})}},i.mergeNodeMapGraphs=t=>{const n={};for(const r of Object.keys(t).sort())for(const i of Object.keys(t[r]).sort()){const a=t[r][i];i in n||(n[i]={"@id":i});const s=n[i];for(const t of Object.keys(a).sort())if(e(t)&&"@type"!==t)s[t]=o.clone(a[t]);else for(const e of a[t])o.addValue(s,t,o.clone(e),{propertyIsArray:!0,allowDuplicate:!1})}return n},i.mergeNodeMaps=e=>{const n=e["@default"],o=Object.keys(e).sort();for(const r of o){if("@default"===r)continue;const o=e[r];let i=n[r];i?"@graph"in i||(i["@graph"]=[]):n[r]=i={"@id":r,"@graph":[]};const a=i["@graph"];for(const e of Object.keys(o).sort()){const n=o[e];t.isSubjectReference(n)||a.push(n)}}return n},te}function qe(){if(de)return ce;de=1;const{createNodeMap:e}=Be(),{isKeyword:t}=Fe(),n=Oe(),o=le?se:(le=1,se=function e(t){if("number"==typeof t&&isNaN(t))throw new Error("NaN is not allowed");if("number"==typeof t&&!isFinite(t))throw new Error("Infinity is not allowed");return null===t||"object"!=typeof t?JSON.stringify(t):t.toJSON instanceof Function?e(t.toJSON()):Array.isArray(t)?`[${t.reduce((t,n,o)=>`${t}${0===o?"":","}${e(void 0===n||"symbol"==typeof n?null:n)}`,"")}]`:`{${Object.keys(t).sort().reduce((n,o)=>void 0===t[o]||"symbol"==typeof t[o]?n:`${n}${0===n.length?"":","}${e(o)}:${e(t[o])}`,"")}}`}),r=Ee(),i=Ne(),a=Ce(),{handleEvent:s}=Me(),{RDF_FIRST:l,RDF_REST:c,RDF_NIL:d,RDF_TYPE:u,RDF_JSON_LITERAL:p,RDF_LANGSTRING:f,XSD_BOOLEAN:h,XSD_DOUBLE:v,XSD_INTEGER:g,XSD_STRING:y}=ke(),{isAbsolute:m}=Ae(),x={};function b(e,n,o,r,i){const a=Object.keys(n).sort();for(const l of a){const a=n[l],c=Object.keys(a).sort();for(let n of c){const c=a[n];if("@type"===n)n=u;else if(t(n))continue;for(const t of c){const a=I(l);if(!m(l)){i.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative subject reference",level:"warning",message:"Relative subject reference found.",details:{subject:l}},options:i});continue}const c=I(n);if(!m(n)){i.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative predicate reference",level:"warning",message:"Relative predicate reference found.",details:{predicate:n}},options:i});continue}if("BlankNode"===c.termType&&!i.produceGeneralizedRdf){i.eventHandler&&s({event:{type:["JsonLdEvent"],code:"blank node predicate",level:"warning",message:"Dropping blank node predicate.",details:{property:r.getOldIds().find(e=>r.getId(e)===n)}},options:i});continue}const d=w(t,r,e,o,i.rdfDirection,i);d&&e.push({subject:a,predicate:c,object:d,graph:o})}}}}function w(e,t,a,u,x,b){let j;if(n.isValue(e)){j={termType:"Literal",value:void 0,datatype:{termType:"NamedNode"}};let t=e["@value"];const n=e["@type"]||null;if("@json"===n)j.value=o(t),j.datatype.value=p;else if(i.isBoolean(t))j.value=t.toString(),j.datatype.value=n||h;else if(i.isDouble(t)||n===v)i.isDouble(t)||(t=parseFloat(t)),j.value=t.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),j.datatype.value=n||v;else if(i.isNumber(t))j.value=t.toFixed(0),j.datatype.value=n||g;else if("@direction"in e&&"i18n-datatype"===x){const n=`https://www.w3.org/ns/i18n#${(e["@language"]||"").toLowerCase()}_${e["@direction"]}`;j.datatype.value=n,j.value=t}else{if("@direction"in e&&"compound-literal"===x)throw new r("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:x});if("@direction"in e&&x)throw new r("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:x});"@language"in e?("@direction"in e&&!x&&b.eventHandler&&s({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:j.value}},options:b}),j.value=t,j.datatype.value=n||f,j.language=e["@language"]):("@direction"in e&&!x&&b.eventHandler&&s({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:j.value}},options:b}),j.value=t,j.datatype.value=n||y)}}else if(n.isList(e)){const n=function(e,t,n,o,r,i){const a={termType:"NamedNode",value:l},s={termType:"NamedNode",value:c},u={termType:"NamedNode",value:d},p=e.pop(),f=p?{termType:"BlankNode",value:t.getId().slice(2)}:u;let h=f;for(const l of e){const e=w(l,t,n,o,r,i),c={termType:"BlankNode",value:t.getId().slice(2)};n.push({subject:h,predicate:a,object:e,graph:o}),n.push({subject:h,predicate:s,object:c,graph:o}),h=c}if(p){const e=w(p,t,n,o,r,i);n.push({subject:h,predicate:a,object:e,graph:o}),n.push({subject:h,predicate:s,object:u,graph:o})}return f}(e["@list"],t,a,u,x,b);j={termType:n.termType,value:n.value}}else{j=I(i.isObject(e)?e["@id"]:e)}return"NamedNode"!==j.termType||m(j.value)?j:(b.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative object reference",level:"warning",message:"Relative object reference found.",details:{object:j.value}},options:b}),null)}function I(e){return e.startsWith("_:")?{termType:"BlankNode",value:e.slice(2)}:{termType:"NamedNode",value:e}}return ce=x,x.toRDF=(t,n)=>{const o=new a.IdentifierIssuer("_:b"),r={"@default":{}};e(t,r,"@default",o);const i=[],l=Object.keys(r).sort();for(const e of l){let t;if("@default"===e)t={termType:"DefaultGraph",value:""};else{if(!m(e)){n.eventHandler&&s({event:{type:["JsonLdEvent"],code:"relative graph reference",level:"warning",message:"Relative graph reference found.",details:{graph:e}},options:n});continue}t=I(e)}b(i,r[e],t,o,n)}return i},ce}function Ue(){if(pe)return ue;pe=1;const{isKeyword:e}=Fe(),t=Oe(),n=Ne(),o=Ce(),r=Ae(),i=Ee(),{createNodeMap:a,mergeNodeMapGraphs:s}=Be(),l={};function c(e){const t={};for(const n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function d(e,t,n){for(let o=n.length-1;o>=0;--o){const r=n[o];if(r.graph===t&&r.subject["@id"]===e["@id"])return!0}return!1}function u(e,t,n){const o="@"+n;let r=o in e?e[o][0]:t[n];if("embed"===n)if(!0===r)r="@once";else if(!1===r)r="@never";else if("@always"!==r&&"@never"!==r&&"@link"!==r&&"@first"!==r&&"@last"!==r&&"@once"!==r)throw new i("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:e});return r}function p(e){if(!n.isArray(e)||1!==e.length||!n.isObject(e[0]))throw new i("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 o.asArray(e[0]["@id"]))if(!n.isObject(t)&&!r.isAbsolute(t)||n.isString(t)&&0===t.indexOf("_:"))throw new i("Invalid JSON-LD syntax; invalid @id in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e});if("@type"in e[0])for(const t of o.asArray(e[0]["@type"]))if(!n.isObject(t)&&!r.isAbsolute(t)&&"@json"!==t||n.isString(t)&&0===t.indexOf("_:"))throw new i("Invalid JSON-LD syntax; invalid @type in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e})}function f(r,i,a,s){let l=!0,c=!1;for(const d in a){let u=!1;const f=o.getValues(i,d),h=0===o.getValues(a,d).length;if("@id"===d){if(n.isEmptyObject(a["@id"][0]||{})?u=!0:a["@id"].length>=0&&(u=a["@id"].includes(f[0])),!s.requireAll)return u}else if("@type"===d){if(l=!1,h){if(f.length>0)return!1;u=!0}else if(1===a["@type"].length&&n.isEmptyObject(a["@type"][0]))u=f.length>0;else for(const e of a["@type"])u=!(!n.isObject(e)||!("@default"in e))||(u||f.some(t=>t===e));if(!s.requireAll)return u}else{if(e(d))continue;{const e=o.getValues(a,d)[0];let i=!1;if(e&&(p([e]),i="@default"in e),l=!1,0===f.length&&i)continue;if(f.length>0&&h)return!1;if(void 0===e){if(f.length>0)return!1;u=!0}else if(t.isList(e)){const n=e["@list"][0];if(t.isList(f[0])){const e=f[0]["@list"];t.isValue(n)?u=e.some(e=>m(n,e)):(t.isSubject(n)||t.isSubjectReference(n))&&(u=e.some(e=>y(r,n,e,s)))}}else u=t.isValue(e)?f.some(t=>m(e,t)):t.isSubjectReference(e)?f.some(t=>y(r,e,t,s)):!!n.isObject(e)&&f.length>0}}if(!u&&s.requireAll)return!1;c=c||u}return l||c}function h(e,t){const r=e.uniqueEmbeds[e.graph],i=r[t],a=i.parent,s=i.property,l={"@id":t};if(n.isArray(a)){for(let e=0;e<a.length;++e)if(o.compareValues(a[e],l)){a[e]=l;break}}else{const e=n.isArray(a[s]);o.removeValue(a,s,l,{propertyIsArray:e}),o.addValue(a,s,l,{propertyIsArray:e})}const c=e=>{const t=Object.keys(r);for(const o of t)o in r&&n.isObject(r[o].parent)&&r[o].parent["@id"]===e&&(delete r[o],c(o))};c(t)}
|
|
22
|
+
/**
|
|
23
|
+
* Removes the @preserve keywords from expanded result of framing.
|
|
24
|
+
*
|
|
25
|
+
* @param input the framed, framed output.
|
|
26
|
+
* @param options the framing options used.
|
|
27
|
+
*
|
|
28
|
+
* @return the resulting output.
|
|
29
|
+
*/function v(e,o){if(n.isArray(e))return e.map(e=>v(e,o));if(n.isObject(e)){
|
|
30
|
+
// remove @preserve
|
|
31
|
+
if("@preserve"in e)return e["@preserve"][0];if(t.isValue(e))return e;if(t.isList(e))return e["@list"]=v(e["@list"],o),e;if("@id"in e){const t=e["@id"];if(o.link.hasOwnProperty(t)){const n=o.link[t].indexOf(e);if(-1!==n)return o.link[t][n];o.link[t].push(e)}else o.link[t]=[e]}for(const t in e)"@id"===t&&o.bnodesToClear.includes(e[t])?delete e["@id"]:e[t]=v(e[t],o)}return e}function g(e,t,r){n.isObject(e)?o.addValue(e,t,r,{propertyIsArray:!0}):e.push(r)}function y(e,t,n,o){if(!("@id"in n))return!1;const r=e.subjects[n["@id"]];return r&&f(e,r,t,o)}function m(e,t){const o=t["@value"],r=t["@type"],i=t["@language"],a=e["@value"]?n.isArray(e["@value"])?e["@value"]:[e["@value"]]:[],s=e["@type"]?n.isArray(e["@type"])?e["@type"]:[e["@type"]]:[],l=e["@language"]?n.isArray(e["@language"])?e["@language"]:[e["@language"]]:[];return 0===a.length&&0===s.length&&0===l.length||!(!a.includes(o)&&!n.isEmptyObject(a[0]))&&(!!(!r&&0===s.length||s.includes(r)||r&&n.isEmptyObject(s[0]))&&!!(!i&&0===l.length||l.includes(i)||i&&n.isEmptyObject(l[0])))}return ue=l,l.frameMergedOrDefault=(e,t,n)=>{const r={options:n,embedded:!1,graph:"@default",graphMap:{"@default":{}},subjectStack:[],link:{},bnodeMap:{}},i=new o.IdentifierIssuer("_:b");a(e,r.graphMap,"@default",i),n.merged&&(r.graphMap["@merged"]=s(r.graphMap),r.graph="@merged"),r.subjects=r.graphMap[r.graph];const c=[];return l.frame(r,Object.keys(r.subjects).sort(),t,c),n.pruneBlankNodeIdentifiers&&(n.bnodesToClear=Object.keys(r.bnodeMap).filter(e=>1===r.bnodeMap[e].length)),
|
|
32
|
+
// remove @preserve from results
|
|
33
|
+
n.link={},v(c,n)},l.frame=(r,a,s,v,y=null)=>{p(s),s=s[0];const x=r.options,b={embed:u(s,x,"embed"),explicit:u(s,x,"explicit"),requireAll:u(s,x,"requireAll")};r.link.hasOwnProperty(r.graph)||(r.link[r.graph]={});const w=r.link[r.graph],I=function(e,t,n,o){const r={};for(const i of t){const t=e.graphMap[e.graph][i];f(e,t,n,o)&&(r[i]=t)}return r}(r,a,s,b),j=Object.keys(I).sort();for(const p of j){const f=I[p];if(null===y?r.uniqueEmbeds={[r.graph]:{}}:r.uniqueEmbeds[r.graph]=r.uniqueEmbeds[r.graph]||{},"@link"===b.embed&&p in w){g(v,y,w[p]);continue}const j={"@id":p};if(0===p.indexOf("_:")&&o.addValue(r.bnodeMap,p,j,{propertyIsArray:!0}),w[p]=j,("@first"===b.embed||"@last"===b.embed)&&r.is11)throw new i("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:s});if(r.embedded||!r.uniqueEmbeds[r.graph].hasOwnProperty(p))if(!r.embedded||"@never"!==b.embed&&!d(f,r.graph,r.subjectStack))if(!r.embedded||"@first"!=b.embed&&"@once"!=b.embed||!r.uniqueEmbeds[r.graph].hasOwnProperty(p)){if("@last"===b.embed&&p in r.uniqueEmbeds[r.graph]&&h(r,p),r.uniqueEmbeds[r.graph][p]={parent:v,property:y},r.subjectStack.push({subject:f,graph:r.graph}),p in r.graphMap){let e=!1,t=null;"@graph"in s?(t=s["@graph"][0],e=!("@merged"===p||"@default"===p),n.isObject(t)||(t={})):(e="@merged"!==r.graph,t={}),e&&l.frame({...r,graph:p,embedded:!1},Object.keys(r.graphMap[p]).sort(),[t],j,"@graph")}"@included"in s&&l.frame({...r,embedded:!1},a,s["@included"],j,"@included");for(const n of Object.keys(f).sort())if(e(n)){if(j[n]=o.clone(f[n]),"@type"===n)for(const e of f["@type"])0===e.indexOf("_:")&&o.addValue(r.bnodeMap,e,j,{propertyIsArray:!0})}else if(!b.explicit||n in s)for(const e of f[n]){const i=n in s?s[n]:c(b);if(t.isList(e)){const i=s[n]&&s[n][0]&&s[n][0]["@list"]?s[n][0]["@list"]:c(b),a={"@list":[]};g(j,n,a);const d=e["@list"];for(const e of d)t.isSubjectReference(e)?l.frame({...r,embedded:!0},[e["@id"]],i,a,"@list"):g(a,"@list",o.clone(e))}else t.isSubjectReference(e)?l.frame({...r,embedded:!0},[e["@id"]],i,j,n):m(i[0],e)&&g(j,n,o.clone(e))}for(const t of Object.keys(s).sort()){if("@type"===t){if(!n.isObject(s[t][0])||!("@default"in s[t][0]))continue}else if(e(t))continue;const r=s[t][0]||{};if(!u(r,x,"omitDefault")&&!(t in j)){let e="@null";"@default"in r&&(e=o.clone(r["@default"])),n.isArray(e)||(e=[e]),j[t]=[{"@preserve":e}]}}for(const e of Object.keys(s["@reverse"]||{}).sort()){const t=s["@reverse"][e];for(const n of Object.keys(r.subjects)){o.getValues(r.subjects[n],e).some(e=>e["@id"]===p)&&(j["@reverse"]=j["@reverse"]||{},o.addValue(j["@reverse"],e,[],{propertyIsArray:!0}),l.frame({...r,embedded:!0},[n],t,j["@reverse"][e],y))}}g(v,y,j),r.subjectStack.pop()}else g(v,y,j);else g(v,y,j)}},l.cleanupNull=(e,t)=>{if(n.isArray(e)){return e.map(e=>l.cleanupNull(e,t)).filter(e=>e)}if("@null"===e)return null;if(n.isObject(e)){if("@id"in e){const n=e["@id"];if(t.link.hasOwnProperty(n)){const o=t.link[n].indexOf(e);if(-1!==o)return t.link[n][o];t.link[n].push(e)}else t.link[n]=[e]}for(const n in e)e[n]=l.cleanupNull(e[n],t)}return e},ue}function $e(){if(he)return fe;he=1;const e=Ee(),{isArray:t,isObject:n,isString:o,isUndefined:r}=Ne(),{isList:i,isValue:a,isGraph:s,isSimpleGraph:l,isSubjectReference:c}=Oe(),{expandIri:d,getContextValue:u,isKeyword:p,process:f,processingMode:h}=Fe(),{removeBase:v,prependBase:g}=Ae(),{REGEX_KEYWORD:y,addValue:m,asArray:x,compareShortestLeast:b}=Ce(),w={};function I(t,n,o){if("@nest"!==d(t,n,{vocab:!0},o))throw new e("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}return fe=w,w.compact=async({activeCtx:d,activeProperty:v=null,element:g,options:y={}})=>{if(t(g)){let e=[];for(let t=0;t<g.length;++t){const n=await w.compact({activeCtx:d,activeProperty:v,element:g[t],options:y});null!==n&&e.push(n)}if(y.compactArrays&&1===e.length){0===(u(d,v,"@container")||[]).length&&(e=e[0])}return e}const b=u(d,v,"@context");if(r(b)||(d=await f({activeCtx:d,localCtx:b,propagate:!0,overrideProtected:!0,options:y})),n(g)){if(y.link&&"@id"in g&&y.link.hasOwnProperty(g["@id"])){const e=y.link[g["@id"]];for(let t=0;t<e.length;++t)if(e[t].expanded===g)return e[t].compacted}if(a(g)||c(g)){const e=w.compactValue({activeCtx:d,activeProperty:v,value:g,options:y});return y.link&&c(g)&&(y.link.hasOwnProperty(g["@id"])||(y.link[g["@id"]]=[]),y.link[g["@id"]].push({expanded:g,compacted:e})),e}if(i(g)){if((u(d,v,"@container")||[]).includes("@list"))return w.compact({activeCtx:d,activeProperty:v,element:g["@list"],options:y})}const b="@reverse"===v,j={},S=d;a(g)||c(g)||(d=d.revertToPreviousContext());const D=u(S,v,"@context");r(D)||(d=await f({activeCtx:d,localCtx:D,propagate:!0,overrideProtected:!0,options:y})),y.link&&"@id"in g&&(y.link.hasOwnProperty(g["@id"])||(y.link[g["@id"]]=[]),y.link[g["@id"]].push({expanded:g,compacted:j}));let N=g["@type"]||[];N.length>1&&(N=Array.from(N).sort());const O=d;for(const e of N){const t=w.compactIri({activeCtx:O,iri:e,relativeTo:{vocab:!0}}),n=u(S,t,"@context");r(n)||(d=await f({activeCtx:d,localCtx:n,options:y,propagate:!1}))}const E=Object.keys(g).sort();for(const r of E){const c=g[r];if("@id"===r){let e=x(c).map(e=>w.compactIri({activeCtx:d,iri:e,relativeTo:{vocab:!1},base:y.base}));1===e.length&&(e=e[0]);j[w.compactIri({activeCtx:d,iri:"@id",relativeTo:{vocab:!0}})]=e;continue}if("@type"===r){let e=x(c).map(e=>w.compactIri({activeCtx:S,iri:e,relativeTo:{vocab:!0}}));1===e.length&&(e=e[0]);const n=w.compactIri({activeCtx:d,iri:"@type",relativeTo:{vocab:!0}}),o=(u(d,n,"@container")||[]).includes("@set")&&h(d,1.1)||t(e)&&0===c.length;m(j,n,e,{propertyIsArray:o});continue}if("@reverse"===r){const e=await w.compact({activeCtx:d,activeProperty:"@reverse",element:c,options:y});for(const t in e)if(d.mappings.has(t)&&d.mappings.get(t).reverse){const n=e[t],o=(u(d,t,"@container")||[]).includes("@set")||!y.compactArrays;m(j,t,n,{propertyIsArray:o}),delete e[t]}if(Object.keys(e).length>0){const t=w.compactIri({activeCtx:d,iri:r,relativeTo:{vocab:!0}});m(j,t,e)}continue}if("@preserve"===r){const e=await w.compact({activeCtx:d,activeProperty:v,element:c,options:y});t(e)&&0===e.length||m(j,r,e);continue}if("@index"===r){if((u(d,v,"@container")||[]).includes("@index"))continue;const e=w.compactIri({activeCtx:d,iri:r,relativeTo:{vocab:!0}});m(j,e,c);continue}if("@graph"!==r&&"@list"!==r&&"@included"!==r&&p(r)){const e=w.compactIri({activeCtx:d,iri:r,relativeTo:{vocab:!0}});m(j,e,c);continue}if(!t(c))throw new e("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===c.length){const e=w.compactIri({activeCtx:d,iri:r,value:c,relativeTo:{vocab:!0},reverse:b}),t=d.mappings.has(e)?d.mappings.get(e)["@nest"]:null;let o=j;t&&(I(d,t,y),n(j[t])||(j[t]={}),o=j[t]),m(o,e,c,{propertyIsArray:!0})}for(const e of c){const c=w.compactIri({activeCtx:d,iri:r,value:e,relativeTo:{vocab:!0},reverse:b}),p=d.mappings.has(c)?d.mappings.get(c)["@nest"]:null;let f=j;p&&(I(d,p,y),n(j[p])||(j[p]={}),f=j[p]);const h=u(d,c,"@container")||[],v=s(e),g=i(e);let S;g?S=e["@list"]:v&&(S=e["@graph"]);let D=await w.compact({activeCtx:d,activeProperty:c,element:g||v?S:e,options:y});if(g){if(t(D)||(D=[D]),h.includes("@list")){m(f,c,D,{valueIsArray:!0,allowDuplicate:!0});continue}D={[w.compactIri({activeCtx:d,iri:"@list",relativeTo:{vocab:!0}})]:D},"@index"in e&&(D[w.compactIri({activeCtx:d,iri:"@index",relativeTo:{vocab:!0}})]=e["@index"])}if(v)if(h.includes("@graph")&&(h.includes("@id")||h.includes("@index")&&l(e))){let t;f.hasOwnProperty(c)?t=f[c]:f[c]=t={};const n=(h.includes("@id")?e["@id"]:e["@index"])||w.compactIri({activeCtx:d,iri:"@none",relativeTo:{vocab:!0}});m(t,n,D,{propertyIsArray:!y.compactArrays||h.includes("@set")})}else h.includes("@graph")&&l(e)?(t(D)&&D.length>1&&(D={"@included":D}),m(f,c,D,{propertyIsArray:!y.compactArrays||h.includes("@set")})):(t(D)&&1===D.length&&y.compactArrays&&(D=D[0]),D={[w.compactIri({activeCtx:d,iri:"@graph",relativeTo:{vocab:!0}})]:D},"@id"in e&&(D[w.compactIri({activeCtx:d,iri:"@id",relativeTo:{vocab:!0}})]=e["@id"]),"@index"in e&&(D[w.compactIri({activeCtx:d,iri:"@index",relativeTo:{vocab:!0}})]=e["@index"]),m(f,c,D,{propertyIsArray:!y.compactArrays||h.includes("@set")}));else if(h.includes("@language")||h.includes("@index")||h.includes("@id")||h.includes("@type")){let t,n;if(f.hasOwnProperty(c)?t=f[c]:f[c]=t={},h.includes("@language"))a(D)&&(D=D["@value"]),n=e["@language"];else if(h.includes("@index")){const t=u(d,c,"@index")||"@index",r=w.compactIri({activeCtx:d,iri:t,relativeTo:{vocab:!0}});if("@index"===t)n=e["@index"],delete D[r];else{let e;if([n,...e]=x(D[t]||[]),o(n))switch(e.length){case 0:delete D[t];break;case 1:D[t]=e[0];break;default:D[t]=e}else n=null}}else if(h.includes("@id")){const e=w.compactIri({activeCtx:d,iri:"@id",relativeTo:{vocab:!0}});n=D[e],delete D[e]}else if(h.includes("@type")){const t=w.compactIri({activeCtx:d,iri:"@type",relativeTo:{vocab:!0}});let o;switch([n,...o]=x(D[t]||[]),o.length){case 0:delete D[t];break;case 1:D[t]=o[0];break;default:D[t]=o}1===Object.keys(D).length&&"@id"in e&&(D=await w.compact({activeCtx:d,activeProperty:c,element:{"@id":e["@id"]},options:y}))}n||(n=w.compactIri({activeCtx:d,iri:"@none",relativeTo:{vocab:!0}})),m(t,n,D,{propertyIsArray:h.includes("@set")})}else{const e=!y.compactArrays||h.includes("@set")||h.includes("@list")||t(D)&&0===D.length||"@list"===r||"@graph"===r;m(f,c,D,{propertyIsArray:e})}}}return j}return g},w.compactIri=({activeCtx:t,iri:o,value:r=null,relativeTo:l={vocab:!1},reverse:c=!1,base:d=null})=>{if(null===o)return o;t.isPropertyTermScoped&&t.previousContext&&(t=t.previousContext);const u=t.getInverse();if(p(o)&&o in u&&"@none"in u[o]&&"@type"in u[o]["@none"]&&"@none"in u[o]["@none"]["@type"])return u[o]["@none"]["@type"]["@none"];if(l.vocab&&o in u){const e=t["@language"]||"@none",l=[];n(r)&&"@index"in r&&!("@graph"in r)&&l.push("@index","@index@set"),n(r)&&"@preserve"in r&&(r=r["@preserve"][0]),s(r)?("@index"in r&&l.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in r&&l.push("@graph@id","@graph@id@set"),l.push("@graph","@graph@set","@set"),"@index"in r||l.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in r||l.push("@graph@id","@graph@id@set")):n(r)&&!a(r)&&l.push("@id","@id@set","@type","@set@type");let d="@language",u="@null";if(c)d="@type",u="@reverse",l.push("@set");else if(i(r)){"@index"in r||l.push("@list");const t=r["@list"];if(0===t.length)d="@any",u="@none";else{let n=0===t.length?e:null,o=null;for(let e=0;e<t.length;++e){const r=t[e];let i="@none",s="@none";if(a(r))if("@direction"in r){i=`${(r["@language"]||"").toLowerCase()}_${r["@direction"]}`}else"@language"in r?i=r["@language"].toLowerCase():"@type"in r?s=r["@type"]:i="@null";else s="@id";if(null===n?n=i:i!==n&&a(r)&&(n="@none"),null===o?o=s:s!==o&&(o="@none"),"@none"===n&&"@none"===o)break}n=n||"@none",o=o||"@none","@none"!==o?(d="@type",u=o):u=n}}else{if(a(r))if("@language"in r&&!("@index"in r)){l.push("@language","@language@set"),u=r["@language"];const e=r["@direction"];e&&(u=`${u}_${e}`)}else"@direction"in r&&!("@index"in r)?u=`_${r["@direction"]}`:"@type"in r&&(d="@type",u=r["@type"]);else d="@type",u="@id";l.push("@set")}l.push("@none"),n(r)&&!("@index"in r)&&l.push("@index","@index@set"),a(r)&&1===Object.keys(r).length&&l.push("@language","@language@set");const p=function(e,t,o,r,i,a){null===a&&(a="@null");const s=[];if(("@id"===a||"@reverse"===a)&&n(o)&&"@id"in o){"@reverse"===a&&s.push("@reverse");const t=w.compactIri({activeCtx:e,iri:o["@id"],relativeTo:{vocab:!0}});e.mappings.has(t)&&e.mappings.get(t)&&e.mappings.get(t)["@id"]===o["@id"]?s.push.apply(s,["@vocab","@id"]):s.push.apply(s,["@id","@vocab"])}else{s.push(a);const e=s.find(e=>e.includes("_"));e&&s.push(e.replace(/^[^_]+_/,"_"))}s.push("@none");const l=e.inverse[t];for(const e of r){if(!(e in l))continue;const t=l[e][i];for(const e of s)if(e in t)return t[e]}return null}(t,o,r,l,d,u);if(null!==p)return p}if(l.vocab&&"@vocab"in t){const e=t["@vocab"];if(0===o.indexOf(e)&&o!==e){const n=o.substr(e.length);if(!t.mappings.has(n))return n}}let f=null;const h=[];let m=t.fastCurieMap;const x=o.length-1;for(let e=0;e<x&&o[e]in m;++e)m=m[o[e]],""in m&&h.push(m[""][0]);for(let e=h.length-1;e>=0;--e){const n=h[e],i=n.terms;for(const e of i){const i=e+":"+o.substr(n.iri.length);t.mappings.get(e)._prefix&&(!t.mappings.has(i)||null===r&&t.mappings.get(i)["@id"]===o)&&(null===f||b(i,f)<0)&&(f=i)}}if(null!==f)return f;for(const[n,r]of t.mappings)if(r&&r._prefix&&o.startsWith(n+":"))throw new e(`Absolute IRI "${o}" confused with prefix "${n}".`,"jsonld.SyntaxError",{code:"IRI confused with prefix",context:t});if(!l.vocab){if("@base"in t){if(t["@base"]){const e=v(g(d,t["@base"]),o);return y.test(e)?`./${e}`:e}return o}return v(d,o)}return o},w.compactValue=({activeCtx:e,activeProperty:t,value:n,options:r})=>{if(a(n)){const r=u(e,t,"@type"),i=u(e,t,"@language"),a=u(e,t,"@direction"),s=u(e,t,"@container")||[],l="@index"in n&&!s.includes("@index");if(!l&&"@none"!==r){if(n["@type"]===r)return n["@value"];if("@language"in n&&n["@language"]===i&&"@direction"in n&&n["@direction"]===a)return n["@value"];if("@language"in n&&n["@language"]===i)return n["@value"];if("@direction"in n&&n["@direction"]===a)return n["@value"]}const c=Object.keys(n).length,d=1===c||2===c&&"@index"in n&&!l,p="@language"in e,f=o(n["@value"]),h=e.mappings.has(t)&&null===e.mappings.get(t)["@language"];if(d&&"@none"!==r&&(!p||!f||h))return n["@value"];const v={};return l&&(v[w.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=n["@index"]),"@type"in n?v[w.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=w.compactIri({activeCtx:e,iri:n["@type"],relativeTo:{vocab:!0}}):"@language"in n&&(v[w.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=n["@language"]),"@direction"in n&&(v[w.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=n["@direction"]),v[w.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=n["@value"],v}const i=d(e,t,{vocab:!0},r),s=u(e,t,"@type"),l=w.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:"@vocab"===s},base:r.base});return"@id"===s||"@vocab"===s||"@graph"===i?l:{[w.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:l}},fe}function Ve(){if(me)return ye;me=1;const e=De(),t=function(){if(J)return _;J=1;const e=Re(),t={};return _=t,t.setupDocumentLoaders=function(t){"undefined"!=typeof XMLHttpRequest&&(t.documentLoaders.xhr=e,t.useDocumentLoader("xhr"))},t.setupGlobals=function(e){void 0===globalThis.JsonLdProcessor&&Object.defineProperty(globalThis,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:e.JsonLdProcessor})},_}(),n=Ce(),o=Je(),r=n.IdentifierIssuer,i=Ee(),a=_e(),s=Pe(),{expand:l}=He(),{flatten:c}=function(){if(re)return oe;re=1;const{isSubjectReference:e}=Oe(),{createMergedNodeMap:t}=Be(),n={};return oe=n,n.flatten=n=>{const o=t(n),r=[],i=Object.keys(o).sort();for(let t=0;t<i.length;++t){const n=o[i[t]];e(n)||r.push(n)}return r},oe}(),{fromRDF:d}=function(){if(ae)return ie;ae=1;const e=Ee(),t=Oe(),n=Ne(),{REGEX_BCP47:o,addValue:r}=Ce(),{handleEvent:i}=Me(),{RDF_LIST:a,RDF_FIRST:s,RDF_REST:l,RDF_NIL:c,RDF_TYPE:d,RDF_JSON_LITERAL:u,XSD_BOOLEAN:p,XSD_DOUBLE:f,XSD_INTEGER:h,XSD_STRING:v}=ke(),g={};function y(t,r,a,s){const l=m(t);if(l)return{"@id":l};const c={"@value":t.value};if(t.language)t.language.match(o)||s.eventHandler&&i({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:t.language}},options:s}),c["@language"]=t.language;else{let l=t.datatype.value;if(l||(l=v),l===u){l="@json";try{c["@value"]=JSON.parse(c["@value"])}catch(t){throw new e("JSON literal could not be parsed.","jsonld.InvalidJsonLiteral",{code:"invalid JSON literal",value:c["@value"],cause:t})}}if(r)if(l===p)"true"===c["@value"]||"1"===c["@value"]?c["@value"]=!0:"false"===c["@value"]||"0"===c["@value"]?c["@value"]=!1:c["@type"]=l;else if(l===h)if(n.isNumeric(c["@value"])){const e=parseInt(c["@value"],10);e.toFixed(0)===c["@value"]&&(c["@value"]=e)}else c["@type"]=l;else l===f&&n.isNumeric(c["@value"])?c["@value"]=parseFloat(c["@value"]):c["@type"]=l;else if("i18n-datatype"===a&&l.startsWith("https://www.w3.org/ns/i18n#")){const[,e,t]=l.split(/[#_]/);e.length>0&&(c["@language"]=e,e.match(o)||s.eventHandler&&i({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:s})),c["@direction"]=t}else l!==v&&(c["@type"]=l)}return c}function m(e){return"NamedNode"===e.termType?e.value:"BlankNode"===e.termType?"_:"+e.value:null}return ie=g,g.fromRDF=async(o,i)=>{const{useRdfType:u=!1,useNativeTypes:p=!1,rdfDirection:f=null}=i,h={},v={"@default":h},g={};if(f){if("compound-literal"===f)throw new e("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:f});if("i18n-datatype"!==f)throw new e("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:f})}for(const e of o){const t="DefaultGraph"===e.graph.termType?"@default":e.graph.value;t in v||(v[t]={}),"@default"===t||t in h||(h[t]={"@id":t});const n=v[t],o=m(e.subject),a=e.predicate.value,s=e.object;o in n||(n[o]={"@id":o});const l=n[o],x=m(s),b=!!x;if(b&&!(x in n)&&(n[x]={"@id":x}),a===d&&!u&&b){r(l,"@type",x,{propertyIsArray:!0});continue}const w=y(s,p,f,i);if(r(l,a,w,{propertyIsArray:!0}),b)if(x===c){const e=n[x];"usages"in e||(e.usages=[]),e.usages.push({node:l,property:a,value:w})}else g[x]=!(x in g)&&{node:l,property:a,value:w}}for(const e in v){const o=v[e];if(!(c in o))continue;const r=o[c];if(r.usages){for(let e of r.usages){let r=e.node,i=e.property,c=e.value;const d=[],u=[];let p=Object.keys(r).length;for(;i===l&&n.isObject(g[r["@id"]])&&n.isArray(r[s])&&1===r[s].length&&n.isArray(r[l])&&1===r[l].length&&(3===p||4===p&&n.isArray(r["@type"])&&1===r["@type"].length&&r["@type"][0]===a)&&(d.push(r[s][0]),u.push(r["@id"]),e=g[r["@id"]],r=e.node,i=e.property,c=e.value,p=Object.keys(r).length,t.isBlankNode(r)););delete c["@id"],c["@list"]=d.reverse();for(const e of u)delete o[e]}delete r.usages}}const x=[],b=Object.keys(h).sort();for(const e of b){const n=h[e];if(e in v){const o=n["@graph"]=[],r=v[e],i=Object.keys(r).sort();for(const e of i){const n=r[e];t.isSubjectReference(n)||o.push(n)}}t.isSubjectReference(n)||x.push(n)}return x},ie}(),{toRDF:u}=qe(),{frameMergedOrDefault:p,cleanupNull:f}=Ue(),{isArray:h,isObject:v,isString:g}=Ne(),{isSubjectReference:y}=Oe(),{expandIri:m,getInitialContext:x,process:b,processingMode:w}=Fe(),{compact:I,compactIri:j}=$e(),{createNodeMap:S,createMergedNodeMap:D,mergeNodeMaps:N}=Be(),{logEventHandler:O,logWarningEventHandler:E,safeEventHandler:C,setDefaultEventHandler:k,setupEventHandler:L,strictEventHandler:A,unhandledEventHandler:R}=Me(),T=function(T){const _={},J=new a({max:100});function P(e,{documentLoader:t=T.documentLoader,...n}){if(e&&"compactionMap"in e)throw new i('"compactionMap" not supported.',"jsonld.OptionsError");if(e&&"expansionMap"in e)throw new i('"expansionMap" not supported.',"jsonld.OptionsError");return Object.assign({},{documentLoader:t},n,e,{eventHandler:L({options:e})})}return T.compact=async function(e,t,a){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");if(null===t)throw new i("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"});if(null===e)return null;let s;(a=P(a,{base:g(e)?e:"",compactArrays:!0,compactToRelative:!0,graph:!1,skipExpansion:!1,link:!1,issuer:new r("_:b"),contextResolver:new o({sharedCache:J})})).link&&(a.skipExpansion=!0),a.compactToRelative||delete a.base,s=a.skipExpansion?e:await T.expand(e,a);const l=await T.processContext(x(a),t,a);let c=await I({activeCtx:l,element:s,options:a});a.compactArrays&&!a.graph&&h(c)?1===c.length?c=c[0]:0===c.length&&(c={}):a.graph&&v(c)&&(c=[c]),v(t)&&"@context"in t&&(t=t["@context"]),t=n.clone(t),h(t)||(t=[t]);const d=t;t=[];for(let e=0;e<d.length;++e)(!v(d[e])||Object.keys(d[e]).length>0)&&t.push(d[e]);const u=t.length>0;if(1===t.length&&(t=t[0]),h(c)){const e=j({activeCtx:l,iri:"@graph",relativeTo:{vocab:!0}}),n=c;c={},u&&(c["@context"]=t),c[e]=n}else if(v(c)&&u){const e=c;c={"@context":t};for(const t in e)c[t]=e[t]}return c},T.expand=async function(e,t){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");const r={},i=[];if("expandContext"in(t=P(t,{keepFreeFloatingNodes:!1,contextResolver:new o({sharedCache:J})}))){const e=n.clone(t.expandContext);v(e)&&"@context"in e?r.expandContext=e:r.expandContext={"@context":e},i.push(r.expandContext)}let a;if(g(e)){const n=await T.get(e,t);a=n.documentUrl,r.input=n.document,n.contextUrl&&(r.remoteContext={"@context":n.contextUrl},i.push(r.remoteContext))}else r.input=n.clone(e);"base"in t||(t.base=a||"");let s=x(t);for(const e of i)s=await b({activeCtx:s,localCtx:e,options:t});let c=await l({activeCtx:s,element:r.input,options:t});return v(c)&&"@graph"in c&&1===Object.keys(c).length?c=c["@graph"]:null===c&&(c=[]),h(c)||(c=[c]),c},T.flatten=async function(e,t,n){if(arguments.length<1)return new TypeError("Could not flatten, too few arguments.");t="function"==typeof t?null:t||null,n=P(n,{base:g(e)?e:"",contextResolver:new o({sharedCache:J})});const r=await T.expand(e,n),i=c(r);if(null===t)return i;n.graph=!0,n.skipExpansion=!0;return await T.compact(i,t,n)},T.frame=async function(e,t,n){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");if(n=P(n,{base:g(e)?e:"",embed:"@once",explicit:!1,requireAll:!1,omitDefault:!1,bnodesToClear:[],contextResolver:new o({sharedCache:J})}),g(t)){const e=await T.get(t,n);if(t=e.document,e.contextUrl){let n=t["@context"];n?h(n)?n.push(e.contextUrl):n=[n,e.contextUrl]:n=e.contextUrl,t["@context"]=n}}const r=t&&t["@context"]||{},i=await T.processContext(x(n),r,n);n.hasOwnProperty("omitGraph")||(n.omitGraph=w(i,1.1)),n.hasOwnProperty("pruneBlankNodeIdentifiers")||(n.pruneBlankNodeIdentifiers=w(i,1.1));const a=await T.expand(e,n),s={...n};s.isFrame=!0,s.keepFreeFloatingNodes=!0;const l=await T.expand(t,s),c=Object.keys(t).map(e=>m(i,e,{vocab:!0}));s.merged=!c.includes("@graph"),s.is11=w(i,1.1);const d=p(a,l,s);s.graph=!n.omitGraph,s.skipExpansion=!0,s.link={},s.framing=!0;let u=await T.compact(d,r,s);return s.link={},u=f(u,s),u},T.link=async function(e,t,n){const o={};return t&&(o["@context"]=t),o["@embed"]="@link",T.frame(e,o,n)},T.normalize=T.canonize=async function(t,n){if(arguments.length<1)throw new TypeError("Could not canonize, too few arguments.");n=P(n,{skipExpansion:!1,safe:!0,contextResolver:new o({sharedCache:J})});const r=Object.assign({},{algorithm:"RDFC-1.0"},n.canonizeOptions||null);if("inputFormat"in n){if("application/n-quads"!==n.inputFormat)throw new i("Unknown canonicalization input format.","jsonld.CanonizeError");const o=s.parse(t);return e.canonize(o,r)}const a={...n};delete a.format,delete a.canonizeOptions,a.produceGeneralizedRdf=!1;const l=await T.toRDF(t,a);return e.canonize(l,r)},T.fromRDF=async function(e,t){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");t=P(t,{format:g(e)?"application/n-quads":void 0});const{format:n}=t;let{rdfParser:o}=t;if(n){if(o=o||_[n],!o)throw new i("Unknown input format.","jsonld.UnknownFormat",{format:n})}else o=()=>e;const r=await o(e);return d(r,t)},T.toRDF=async function(e,t){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");let n;n=(t=P(t,{skipExpansion:!1,contextResolver:new o({sharedCache:J})})).skipExpansion?e:await T.expand(e,t);const r=u(n,t);if(t.format){if("application/n-quads"===t.format)return s.serialize(r);throw new i("Unknown output format.","jsonld.UnknownFormat",{format:t.format})}return r},T.createNodeMap=async function(e,t){if(arguments.length<1)throw new TypeError("Could not create node map, too few arguments.");t=P(t,{base:g(e)?e:"",contextResolver:new o({sharedCache:J})});const n=await T.expand(e,t);return D(n,t)},T.merge=async function(e,t,i){if(arguments.length<1)throw new TypeError("Could not merge, too few arguments.");if(!h(e))throw new TypeError('Could not merge, "docs" must be an array.');t="function"==typeof t?null:t||null,i=P(i,{contextResolver:new o({sharedCache:J})});const a=await Promise.all(e.map(e=>{const t={...i};return T.expand(e,t)}));let s=!0;"mergeNodes"in i&&(s=i.mergeNodes);const l=i.issuer||new r("_:b"),c={"@default":{}};for(let e=0;e<a.length;++e){const t=n.relabelBlankNodes(a[e],{issuer:new r("_:b"+e+"-")}),o=s||0===e?c:{"@default":{}};if(S(t,o,"@default",l),o!==c)for(const e in o){const t=o[e];if(!(e in c)){c[e]=t;continue}const n=c[e];for(const e in t)e in n||(n[e]=t[e])}}const d=N(c),u=[],p=Object.keys(d).sort();for(let e=0;e<p.length;++e){const t=d[p[e]];y(t)||u.push(t)}if(null===t)return u;i.graph=!0,i.skipExpansion=!0;return await T.compact(u,t,i)},Object.defineProperty(T,"documentLoader",{get:()=>T._documentLoader,set:e=>T._documentLoader=e}),T.documentLoader=async e=>{throw new i("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",url:e})},T.get=async function(e,t){let n;n="function"==typeof t.documentLoader?t.documentLoader:T.documentLoader;const o=await n(e);try{if(!o.document)throw new i("No remote document found at the given URL.","jsonld.NullRemoteDocument");g(o.document)&&(o.document=JSON.parse(o.document))}catch(e){throw new i("Could not retrieve a JSON-LD document from the URL.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:o})}return o},T.processContext=async function(e,t,r){return r=P(r,{base:"",contextResolver:new o({sharedCache:J})}),null===t?x(r):(t=n.clone(t),v(t)&&"@context"in t||(t={"@context":t}),b({activeCtx:e,localCtx:t,options:r}))},T.getContextValue=Fe().getContextValue,T.documentLoaders={},T.useDocumentLoader=function(e){if(!(e in T.documentLoaders))throw new i('Unknown document loader type: "'+e+'"',"jsonld.UnknownDocumentLoader",{type:e});T.documentLoader=T.documentLoaders[e].apply(T,Array.prototype.slice.call(arguments,1))},T.registerRDFParser=function(e,t){_[e]=t},T.unregisterRDFParser=function(e){delete _[e]},T.registerRDFParser("application/n-quads",s.parse),T.url=Ae(),T.logEventHandler=O,T.logWarningEventHandler=E,T.safeEventHandler=C,T.setDefaultEventHandler=k,T.strictEventHandler=A,T.unhandledEventHandler=R,T.util=n,Object.assign(T,n),T.promises=T,T.RequestQueue=Le(),T.JsonLdProcessor=(ge||(ge=1,ve=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,n){return arguments.length<2?Promise.reject(new TypeError("Could not compact, too few arguments.")):e.compact(t,n)},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}),ve)(T),t.setupGlobals(T),t.setupDocumentLoaders(T),T},P=function(){return T(function(){return P()})};return T(P),ye=P}var ze=e(Ve());export{Ve as a,ze as j,De as r};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import{h as e,K as t,B as r}from"./main.js";import{a as o,r as n}from"./jsonld-DOUjwF6J-dtl20tiV.js";var i,a,s,c,p,d,u,f,l,h,y,m,w,g,v,T,E,x,b,S,L,_,C,M,O,R,U,D,K,N,P,A,V,I,j,k,X=(function(e,t){!function(e,t){for(var r in t)e[r]=t[r]}(t,function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
const o=r(1),n=r(2),i=r(3),{CONTEXT_URL:a,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c}=i,p=new Map;p.set(s,o),p.set(c,n),e.exports={constants:i,contexts:p,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c,CONTEXT_URL:a,CONTEXT:n}},function(e,t,r){
|
|
6
|
+
/*!
|
|
7
|
+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
8
|
+
*/
|
|
9
|
+
e.exports={"@context":{id:"@id",type:"@type",dc:"http://purl.org/dc/terms/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",EcdsaKoblitzSignature2016:"sec:EcdsaKoblitzSignature2016",Ed25519Signature2018:"sec:Ed25519Signature2018",EncryptedMessage:"sec:EncryptedMessage",GraphSignature2012:"sec:GraphSignature2012",LinkedDataSignature2015:"sec:LinkedDataSignature2015",LinkedDataSignature2016:"sec:LinkedDataSignature2016",CryptographicKey:"sec:Key",authenticationTag:"sec:authenticationTag",canonicalizationAlgorithm:"sec:canonicalizationAlgorithm",cipherAlgorithm:"sec:cipherAlgorithm",cipherData:"sec:cipherData",cipherKey:"sec:cipherKey",created:{"@id":"dc:created","@type":"xsd:dateTime"},creator:{"@id":"dc:creator","@type":"@id"},digestAlgorithm:"sec:digestAlgorithm",digestValue:"sec:digestValue",domain:"sec:domain",encryptionKey:"sec:encryptionKey",expiration:{"@id":"sec:expiration","@type":"xsd:dateTime"},expires:{"@id":"sec:expiration","@type":"xsd:dateTime"},initializationVector:"sec:initializationVector",iterationCount:"sec:iterationCount",nonce:"sec:nonce",normalizationAlgorithm:"sec:normalizationAlgorithm",owner:{"@id":"sec:owner","@type":"@id"},password:"sec:password",privateKey:{"@id":"sec:privateKey","@type":"@id"},privateKeyPem:"sec:privateKeyPem",publicKey:{"@id":"sec:publicKey","@type":"@id"},publicKeyBase58:"sec:publicKeyBase58",publicKeyPem:"sec:publicKeyPem",publicKeyWif:"sec:publicKeyWif",publicKeyService:{"@id":"sec:publicKeyService","@type":"@id"},revoked:{"@id":"sec:revoked","@type":"xsd:dateTime"},salt:"sec:salt",signature:"sec:signature",signatureAlgorithm:"sec:signingAlgorithm",signatureValue:"sec:signatureValue"}}},function(e,t,r){
|
|
10
|
+
/*!
|
|
11
|
+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
12
|
+
*/
|
|
13
|
+
e.exports={"@context":[{"@version":1.1},"https://w3id.org/security/v1",{AesKeyWrappingKey2019:"sec:AesKeyWrappingKey2019",DeleteKeyOperation:"sec:DeleteKeyOperation",DeriveSecretOperation:"sec:DeriveSecretOperation",EcdsaSecp256k1Signature2019:"sec:EcdsaSecp256k1Signature2019",EcdsaSecp256r1Signature2019:"sec:EcdsaSecp256r1Signature2019",EcdsaSecp256k1VerificationKey2019:"sec:EcdsaSecp256k1VerificationKey2019",EcdsaSecp256r1VerificationKey2019:"sec:EcdsaSecp256r1VerificationKey2019",Ed25519Signature2018:"sec:Ed25519Signature2018",Ed25519VerificationKey2018:"sec:Ed25519VerificationKey2018",EquihashProof2018:"sec:EquihashProof2018",ExportKeyOperation:"sec:ExportKeyOperation",GenerateKeyOperation:"sec:GenerateKeyOperation",KmsOperation:"sec:KmsOperation",RevokeKeyOperation:"sec:RevokeKeyOperation",RsaSignature2018:"sec:RsaSignature2018",RsaVerificationKey2018:"sec:RsaVerificationKey2018",Sha256HmacKey2019:"sec:Sha256HmacKey2019",SignOperation:"sec:SignOperation",UnwrapKeyOperation:"sec:UnwrapKeyOperation",VerifyOperation:"sec:VerifyOperation",WrapKeyOperation:"sec:WrapKeyOperation",X25519KeyAgreementKey2019:"sec:X25519KeyAgreementKey2019",allowedAction:"sec:allowedAction",assertionMethod:{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"},capability:{"@id":"sec:capability","@type":"@id"},capabilityAction:"sec:capabilityAction",capabilityChain:{"@id":"sec:capabilityChain","@type":"@id","@container":"@list"},capabilityDelegation:{"@id":"sec:capabilityDelegationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"sec:capabilityInvocationMethod","@type":"@id","@container":"@set"},caveat:{"@id":"sec:caveat","@type":"@id","@container":"@set"},challenge:"sec:challenge",ciphertext:"sec:ciphertext",controller:{"@id":"sec:controller","@type":"@id"},delegator:{"@id":"sec:delegator","@type":"@id"},equihashParameterK:{"@id":"sec:equihashParameterK","@type":"xsd:integer"},equihashParameterN:{"@id":"sec:equihashParameterN","@type":"xsd:integer"},invocationTarget:{"@id":"sec:invocationTarget","@type":"@id"},invoker:{"@id":"sec:invoker","@type":"@id"},jws:"sec:jws",keyAgreement:{"@id":"sec:keyAgreementMethod","@type":"@id","@container":"@set"},kmsModule:{"@id":"sec:kmsModule"},parentCapability:{"@id":"sec:parentCapability","@type":"@id"},plaintext:"sec:plaintext",proof:{"@id":"sec:proof","@type":"@id","@container":"@graph"},proofPurpose:{"@id":"sec:proofPurpose","@type":"@vocab"},proofValue:"sec:proofValue",referenceId:"sec:referenceId",unwrappedKey:"sec:unwrappedKey",verificationMethod:{"@id":"sec:verificationMethod","@type":"@id"},verifyData:"sec:verifyData",wrappedKey:"sec:wrappedKey"}]}},function(e,t,r){
|
|
14
|
+
/*!
|
|
15
|
+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
16
|
+
*/
|
|
17
|
+
e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTEXT_V2_URL:"https://w3id.org/security/v2",CONTEXT_URL:"https://w3id.org/security/v2"}}]))}(i={exports:{}},i.exports),i.exports),z=(a=X)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,Y=X.contexts,q=X.constants,$=X.CONTEXT,F=X.CONTEXT_URL,J=X.SECURITY_CONTEXT_V1_URL,B=X.SECURITY_CONTEXT_V2_URL,G=t(Object.freeze({__proto__:null,CONTEXT:$,CONTEXT_URL:F,SECURITY_CONTEXT_V1_URL:J,SECURITY_CONTEXT_V2_URL:B,constants:q,contexts:Y,default:z}));function W(){if(c)return s;c=1;const{constants:e}=G;return s={SECURITY_CONTEXT_URL:e.SECURITY_CONTEXT_V2_URL,SECURITY_CONTEXT_V1_URL:e.SECURITY_CONTEXT_V1_URL,SECURITY_CONTEXT_V2_URL:e.SECURITY_CONTEXT_V2_URL,SECURITY_PROOF_URL:"https://w3id.org/security#proof",SECURITY_SIGNATURE_URL:"https://w3id.org/security#signature"}}
|
|
18
|
+
/*!
|
|
19
|
+
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
20
|
+
*/function H(){if(d)return p;d=1;const e=W(),{contexts:t}=G;return p=new Map([[e.SECURITY_CONTEXT_V1_URL,t.get(e.SECURITY_CONTEXT_V1_URL)],[e.SECURITY_CONTEXT_V2_URL,t.get(e.SECURITY_CONTEXT_V2_URL)]])}
|
|
21
|
+
/*!
|
|
22
|
+
* Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
|
|
23
|
+
*/function Q(){if(f)return u;f=1;const e=H(),t={};return u=t,t.extendContextLoader=t=>async r=>{const o=e.get(r);return void 0!==o?{contextUrl:null,documentUrl:r,document:o,tag:"static"}:t(r)},t.strictDocumentLoader=t.extendContextLoader(e=>{throw new Error(`${e} not found.`)}),u}function Z(){if(h)return l;h=1;class e extends Error{constructor(t){super(e._prepareSuperMessage(t)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,e)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch{return String(e)}}}const t=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],o=Symbol(".toJSON called"),n=({from:e,seen:i,to_:a,forceEnumerable:s,maxDepth:c,depth:p})=>{const d=a||(Array.isArray(e)?[]:{});if(i.push(e),p>=c)return d;if("function"==typeof e.toJSON&&!0!==e[o])return(e=>{e[o]=!0;const t=e.toJSON();return delete e[o],t})(e);for(const[t,o]of Object.entries(e))"function"==typeof r&&r.isBuffer(o)?d[t]="[object Buffer]":"function"!=typeof o&&(o&&"object"==typeof o?i.includes(e[t])?d[t]="[Circular]":(p++,d[t]=n({from:e[t],seen:i.slice(),forceEnumerable:s,maxDepth:c,depth:p})):d[t]=o);for(const{property:r,enumerable:o}of t)"string"==typeof e[r]&&Object.defineProperty(d,r,{value:e[r],enumerable:!!s||o,configurable:!0,writable:!0});return d};return l={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?n({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(t,r={})=>{const{maxDepth:o=Number.POSITIVE_INFINITY}=r;if(t instanceof Error)return t;if("object"==typeof t&&null!==t&&!Array.isArray(t)){const e=new Error;return n({from:t,seen:[],to_:e,maxDepth:o,depth:0}),e}return new e(t)}}}
|
|
24
|
+
/*!
|
|
25
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
26
|
+
*/function ee(){if(m)return y;m=1;const e=W(),t=o(),{extendContextLoader:r,strictDocumentLoader:n}=Q(),{serializeError:i}=Z();function a({document:r}){let o;o=t.getValues(r,"proof");const n=r["@context"]||e.SECURITY_CONTEXT_URL;return o=o.map(e=>{const{cryptosuite:t}=e;return t?.includes?.("-jcs-")?e:{"@context":n,...e}}),o}function s(e){Object.defineProperty(e,"toJSON",{value:function(){return i(this)},configurable:!0,writable:!0})}return y=class{async add(e,{suite:o,purpose:i,documentLoader:s}={}){if(!o)throw new TypeError('"options.suite" is required.');if(!i)throw new TypeError('"options.purpose" is required.');s=s?r(s):n;const c={...e};delete c.proof;const p=a({document:e}),d=await o.createProof({document:c,purpose:i,proofSet:p,documentLoader:s});return t.addValue(e,"proof",d),e}async derive(e,{suite:t,purpose:o,documentLoader:i}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!o)throw new TypeError('"options.purpose" is required.');i=i?r(i):n;const s={...e};delete s.proof;const c=a({document:e});return await t.derive({document:s,purpose:o,proofSet:c,documentLoader:i})}async verify(e,{suite:t,purpose:o,documentLoader:i}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!o)throw new TypeError('"options.purpose" is required.');const c=Array.isArray(t)?t:[t];if(0===c.length)throw new TypeError("At least one suite is required.");i=i?r(i):n;try{const t=a({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const r=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const i=Array.isArray(o)?o:[o],a=new Map,c=new Map,p=new Map;if(await Promise.all(i.map(o=>async function({purposeToProofs:e,proofToSuite:t,purpose:r,proofSet:o,suites:n,suiteMatchQueue:i,document:a,documentLoader:s}){for(const c of o){if(!await r.match(c,{document:a,documentLoader:s}))continue;let o=!1;for(const e of n){let r=i.get(e);r||i.set(e,r=new Map);let n=r.get(c);if(n||(n=e.matchProof({proof:c,document:a,documentLoader:s}),r.set(c,n)),await n){o=!0,t.set(c,e);break}}if(o){const t=e.get(r);t?t.push(c):e.set(r,[c])}}}({purposeToProofs:a,proofToSuite:c,purpose:o,proofSet:r,suites:t,suiteMatchQueue:p,document:e,documentLoader:n}))),a.size<i.length)return[];const d=new Map;return await Promise.all([...c.entries()].map(async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:p,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=p),i={proof:t,verified:c,verificationMethod:a,error:d}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&s(i.error),d.set(t,i)})),await Promise.all([...a.entries()].map(async([t,r])=>{for(const o of r){const r=d.get(o);if(!r.verified)continue;const{verificationMethod:i}=r,a=c.get(o);let p;try{p=await t.validate(o,{document:e,suite:a,verificationMethod:i,documentLoader:n})}catch(e){p={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(p):r.purposeResult=[r.purposeResult,p]:r.purposeResult=p,p.valid||(s(p.error),r.error||(r.verified=!1,r.error=p.error))}})),[...d.values()]}({document:e,suites:c,proofSet:t,purpose:o,documentLoader:i});if(0===r.length){const e=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).");throw e.name="NotFoundError",e}const n=r.some(e=>e.verified);if(!n){const e=[].concat(...r.filter(e=>e.error).map(e=>e.error)),t={verified:n,results:r};return e.length>0&&(t.error=e),t}return{verified:n,results:r}}catch(e){return s(e),{verified:!1,error:e}}}},y}
|
|
27
|
+
/*!
|
|
28
|
+
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
|
|
29
|
+
*/function te(){return T?v:(T=1,v=class{constructor({type:e}={}){if("string"!=typeof e)throw new TypeError('A LinkedDataProof must have a "type".');this.type=e}async createProof({}){throw new Error('"createProof" must be implemented in a derived class.')}async derive({}){throw new Error('"deriveProof" must be implemented in a derived class.')}async verifyProof({}){throw new Error('"verifyProof" must be implemented in a derived class.')}async matchProof({proof:e}){return e.type===this.type}})}function re(){if(x)return E;x=1;const e={};return E=e,e.w3cDate=e=>{null==e?e=new Date:"number"!=typeof e&&"string"!=typeof e||(e=new Date(e));const t=e.toISOString();return t.substr(0,t.length-5)+"Z"},e.concat=(e,t)=>{const r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},E}function oe(){if(_)return L;_=1;const e=W(),t=o(),r=n(),i=re(),{sha256digest:a}=function(){if(S)return b;S=1;const e=self&&(self.crypto||self.msCrypto);return b={async sha256digest({string:t}){const r=(new TextEncoder).encode(t);return new Uint8Array(await e.subtle.digest("SHA-256",r))}}}
|
|
30
|
+
/*!
|
|
31
|
+
* Copyright (c) 2017-2024 Digital Bazaar, Inc. All rights reserved.
|
|
32
|
+
*/(),s=te();return L=class extends s{constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:i,verifier:a,useNativeCanonize:s,canonizeOptions:c,contextUrl:p}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=p,this.proof=t;const d=function({key:e,signer:t,verifier:r}){const o={};if(e){if(o.key=e,o.verificationMethod=e.id,"function"==typeof e.signer&&(o.signer=e.signer()),"function"==typeof e.verifier&&(o.verifier=e.verifier()),!o.signer&&!o.verifier)throw new TypeError('The "key" parameter must contain a "signer" or "verifier" method.')}else o.verificationMethod=t&&t.id||r&&r.id,o.signer=t,o.verifier=r;if(o.signer&&"function"!=typeof o.signer.sign)throw new TypeError("A signer API has not been specified.");if(o.verifier&&"function"!=typeof o.verifier.verify)throw new TypeError("A verifier API has not been specified.");return o}({key:n,signer:i,verifier:a});if(this.verificationMethod=d.verificationMethod,this.key=d.key,this.signer=d.signer,this.verifier=d.verifier,this.canonizeOptions=c,o&&(this.date=new Date(o),isNaN(this.date)))throw TypeError(`"date" "${o}" is not a valid date.`);this.useNativeCanonize=s,this._hashCache=null}async createProof({document:e,purpose:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');let a;a=this.proof?{...this.proof}:{},a.type=this.type;let s=this.date;void 0===a.created&&void 0===s&&(s=new Date),s&&"string"!=typeof s&&(s=i.w3cDate(s)),s&&(a.created=s),a.verificationMethod=this.verificationMethod,a=await this.updateProof({document:e,proof:a,proofSet:r,purpose:t,documentLoader:o}),a=await t.update(a,{document:e,suite:this,documentLoader:o});const c=await this.createVerifyData({document:e,proof:a,proofSet:r,documentLoader:o});return a=await this.sign({verifyData:c,document:e,proof:a,documentLoader:o}),a}async updateProof({proof:e,expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e}async verifyProof({proof:e,document:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');try{const i=await this.createVerifyData({document:t,proof:e,proofSet:r,documentLoader:o,expansionMap:n}),a=await this.getVerificationMethod({proof:e,document:t,documentLoader:o,expansionMap:n});if(!await this.verifySignature({verifyData:i,verificationMethod:a,document:t,proof:e,documentLoader:o,expansionMap:n}))throw new Error("Invalid signature.");return{verified:!0,verificationMethod:a}}catch(e){return{verified:!1,error:e}}}async canonize(e,{documentLoader:o,expansionMap:n,skipExpansion:i}){if(n)throw new Error('"expansionMap" not supported.');return async function(e,o){const n={rdfDirection:"i18n-datatype",...o,produceGeneralizedRdf:!1};delete n.format;const i=await t.toRDF(e,n);return r.canonize(i,o)}(e,{algorithm:"RDFC-1.0",base:null,format:"application/n-quads",documentLoader:o,safe:!0,skipExpansion:i,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(t,{document:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');return delete(t={"@context":r["@context"]||e.SECURITY_CONTEXT_URL,...t}).jws,delete t.signatureValue,delete t.proofValue,this.canonize(t,{documentLoader:o,expansionMap:n,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');let n;const{_hashCache:s}=this;s&&s.document===e?n=s.hash:this._hashCache={document:e,hash:n=this.canonize(e,{documentLoader:r,expansionMap:o}).then(e=>a({string:e}))};const[c,p]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:r,expansionMap:o}).then(e=>a({string:e})),n]);return i.concat(c,p)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:r,documentLoader:o}){let{verificationMethod:n}=r;if("object"==typeof n&&(n=n.id),!n)throw new Error('No "verificationMethod" found in proof.');const i=await t.frame(n,{"@context":e.SECURITY_CONTEXT_URL,"@embed":"@always",id:n},{documentLoader:o,compactToRelative:!1,safe:!0});if(!i)throw new Error(`Verification method ${n} not found.`);if(void 0!==i.revoked)throw new Error("The verification method has been revoked.");return i}async sign(){throw new Error("Must be implemented by a derived class.")}async verifySignature(){throw new Error("Must be implemented by a derived class.")}ensureSuiteContext({document:e,addSuiteContext:t}){const{contextUrl:r}=this;if(function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}({document:e,contextUrl:r}))return;if(!t)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=e["@context"]||[];e["@context"]=Array.isArray(o)?[...o,r]:[o,r]}},L}
|
|
33
|
+
/*!
|
|
34
|
+
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
35
|
+
*/function ne(){return R?O:(R=1,O=class{constructor({term:e,date:t,maxTimestampDelta:r=1/0}={}){if(void 0===e)throw new Error('"term" is required.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxTimestampDelta" must be a number.');if(this.term=e,void 0!==t&&(this.date=new Date(t),isNaN(this.date)))throw TypeError(`"date" "${t}" is not a valid date.`);this.maxTimestampDelta=r}async validate(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');try{if(this.maxTimestampDelta!==1/0){const t=(this.date||new Date).getTime(),r=1e3*this.maxTimestampDelta,o=new Date(e.created).getTime();if(!(o>=t-r&&o<=t+r))throw new Error("The proof's created timestamp is out of range.")}return{valid:!0}}catch(e){return{valid:!1,error:e}}}async update(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose=this.term,e}async match(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose===this.term}})}
|
|
36
|
+
/*!
|
|
37
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
38
|
+
*/function ie(){if(D)return U;D=1;const e=W(),t=o(),r=ne(),n="https://www.w3.org/ns/did/v1",i=["assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","verificationMethod"];return U=class extends r{constructor({term:e,controller:t,date:r,maxTimestampDelta:o=1/0}={}){if(super({term:e,date:r,maxTimestampDelta:o}),void 0!==t){if("object"!=typeof t)throw new TypeError('"controller" must be an object.');this.controller=t}this._termDefinedByDIDContext=i.includes(e)}async validate(r,{verificationMethod:o,documentLoader:i,expansionMap:a}){try{const s=await super.validate(r,{verificationMethod:o,documentLoader:i,expansionMap:a});if(!s.valid)throw s.error;const{id:c}=o;if("string"!=typeof c)throw new Error(`Verification method ID "${o.id}" must be a string.`);const{term:p,_termDefinedByDIDContext:d}=this;if(this.controller)s.controller=this.controller;else{const{controller:r}=o;let a;if(r)if("object"==typeof r)a=r.id;else{if("string"!=typeof r)throw new TypeError('"controller" must be a string representing a URL.');a=r}let{document:u}=await i(a);!(d&&u["@context"]===n||Array.isArray(u["@context"])&&u["@context"][0]===n)&&(u=await t.frame(u,{"@context":e.SECURITY_CONTEXT_URL,id:a,[p]:{"@embed":"@never",id:c}},{documentLoader:i,compactToRelative:!1,safe:!0})),s.controller=u}const u=t.getValues(s.controller,p);if(s.valid=u.some(e=>e===c||"object"==typeof e&&e.id===c),!s.valid)throw new Error(`Verification method "${o.id}" not authorized by controller for proof purpose "${this.term}".`);return s}catch(e){return{valid:!1,error:e}}}},U}
|
|
39
|
+
/*!
|
|
40
|
+
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
41
|
+
*/function ae(){if(N)return K;N=1;const e=ie();return K=class extends e{constructor({term:e="assertionMethod",controller:t,date:r,maxTimestampDelta:o=1/0}={}){super({term:e,controller:t,date:r,maxTimestampDelta:o})}}}
|
|
42
|
+
/*!
|
|
43
|
+
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
44
|
+
*/function se(){if(A)return P;A=1;const e=ie();return P=class extends e{constructor({term:e="authentication",controller:t,challenge:r,date:o,domain:n,maxTimestampDelta:i=1/0}={}){if(super({term:e,controller:t,date:o,maxTimestampDelta:i}),"string"!=typeof r)throw new TypeError('"challenge" must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('"domain" must be a string.');this.challenge=r,this.domain=n}async validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o}){try{if(e.challenge!==this.challenge)throw new Error(`The challenge is not as expected; challenge="${e.challenge}", expected="${this.challenge}"`);if(void 0!==this.domain){const{domain:t}=e;if(!(t===this.domain||Array.isArray(t)&&t.includes(this.domain)))throw new Error(`The domain is not as expected; domain=${JSON.stringify(t)}, expected=${JSON.stringify(this.domain)}`)}return super.validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o})}catch(e){return{valid:!1,error:e}}}async update(e,{document:t,suite:r,documentLoader:o,expansionMap:n}){return(e=await super.update(e,{document:t,suite:r,documentLoader:o,expansionMap:n})).challenge=this.challenge,void 0!==this.domain&&(e.domain=this.domain),e}},P}
|
|
45
|
+
/*!
|
|
46
|
+
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
47
|
+
*/var ce=function(){if(k)return j;k=1;const e={};j=e;const t=W();Object.assign(e,t);const r=ee(),o=function(){if(g)return w;g=1;class e extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}}return w=e}
|
|
48
|
+
/*!
|
|
49
|
+
* Copyright (c) 2018-2023 Digital Bazaar, Inc. All rights reserved.
|
|
50
|
+
*/();return e.derive=async function(e,{suite:t,purpose:o,documentLoader:n,addSuiteContext:i=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:i});try{return await(new r).derive(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "derive".`);throw r.cause=e,r}throw e}},e.sign=async function(e,{suite:t,purpose:o,documentLoader:n,expansionMap:i,addSuiteContext:a=!0}={}){if(i)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:a});try{return await(new r).add(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".`);throw r.cause=e,r}throw e}},e.verify=async function(e,{suite:t,purpose:n,documentLoader:i,expansionMap:a}={}){if(a)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const s=await(new r).verify(e,{suite:t,purpose:n,documentLoader:i}),{error:c}=s;if(c)if(i||"jsonld.InvalidUrl"!==c.name)s.error=new o(c);else{const{details:{url:e}}=c,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);s.error=new o(t)}return s},e.suites=function(){if(M)return C;M=1;const e={};return C=e,e.suites={LinkedDataProof:te(),LinkedDataSignature:oe()},C}
|
|
51
|
+
/*!
|
|
52
|
+
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
53
|
+
*/().suites,e.purposes=function(){if(I)return V;I=1;const e={};return V=e,e.purposes={AssertionProofPurpose:ae(),AuthenticationProofPurpose:se(),ControllerProofPurpose:ie(),ProofPurpose:ne()},V}
|
|
54
|
+
/*!
|
|
55
|
+
* Copyright (c) 2010-2023 Digital Bazaar, Inc. All rights reserved.
|
|
56
|
+
*/().purposes,Object.assign(e,Q()),j}(),pe=e(ce);export{pe as j};
|