@blockcerts/blockcerts-verifier 1.62.2 → 1.64.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/dist/{EcdsaSd2023-jnIXPui8-Ecil79Z6.js → EcdsaSd2023-C-1LsSqc-ObXBX61N.js} +8 -8
- package/dist/EcdsaSecp256k1Signature2019-9eEnZ1FG-BmfqA6PL.js +1 -0
- package/dist/Ed25519Signature2020-BMcgU5hX-x_NYJtpB.js +52 -0
- package/dist/HashlinkVerifier-BtvQtMxp-dg5WNZnc.js +11 -0
- package/dist/{MerkleProof2017-Cy_nkz4C-gnoFFWMW.js → MerkleProof2017-CYhvkyFU-Dl5-uCC8.js} +1 -1
- package/dist/MerkleProof2019-DvKX1MAC-ZkVAsaEc.js +3 -0
- package/dist/checkCredentialSchemaConformity-BKqGaA0B-BD_kUjvp.js +1 -0
- package/dist/{controlVerificationMethod-BxseSDWK-Ghg2o_Hj.js → controlVerificationMethod-CxlzFjkZ-PQqX7CMl.js} +1 -1
- package/dist/did-key-common.esm-BFTxB53c-CbGeVC_r.js +9 -0
- package/dist/did-key-ed25519.esm-De8G8Ym_-DucypQMo.js +1 -0
- package/dist/did-key-secp256k1.esm-Bq_BYfMd-CQBo4Q3q.js +1 -0
- package/dist/elliptic-ChFQ9Ngs-BRLTdj5Y.js +1 -0
- package/dist/{ensureValidIssuingKey-C7MTkDyV-frafTbMl.js → ensureValidIssuingKey-CVj5gBFJ-wu9SdYxL.js} +1 -1
- package/dist/index-CXMZ9dwW-lR6I8M8V.js +1 -0
- package/dist/index-CZmdZxVn-C0eXpZGn.js +1 -0
- package/dist/index-DJ38G5vv-CIHAiYCe.js +22 -0
- package/dist/index-SE5hL_nS--rUcmgx9.js +60 -0
- package/dist/jsonld-DSQP4wXm-C61cS9xX.js +33 -0
- package/dist/main.js +122 -119
- package/dist/{retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js → retrieveVerificationMethodPublicKey-8w3WQciA-sHmGZCdE.js} +1 -1
- package/dist/sha256-4DF0Q3E2-C1PUWFZm.js +1 -0
- package/dist/webcrypto.es-SQMaF2SJ-B87Lqr9a.js +40 -0
- package/dist/x25519-KjRyLrTf-NSl6svWQ.js +1 -0
- package/package.json +2 -2
- package/dist/EcdsaSecp256k1Signature2019-CBV4BwnM-C2qGlq2W.js +0 -4
- package/dist/Ed25519Signature2020-MQoWd113-PNuci9U2.js +0 -52
- package/dist/HashlinkVerifier-DykIKn5i-CYewU55u.js +0 -11
- package/dist/MerkleProof2019-DpwH-snR-ClzVR6uC.js +0 -3
- package/dist/checkCredentialSchemaConformity-DOGmtCq0-CnEpCN-s.js +0 -1
- package/dist/did-key-common.esm-C42sQiXe-DN5hgDGM.js +0 -9
- package/dist/did-key-ed25519.esm-CO7qImeZ-BR5JRBUU.js +0 -1
- package/dist/did-key-secp256k1.esm-BblZ1xRe-4Ak_uTKC.js +0 -1
- package/dist/elliptic-6eMlPaPZ-CGOSt2J1.js +0 -1
- package/dist/index-BZds3Ljo-CHN5LgUq.js +0 -1
- package/dist/index-Dzjg2qbR-DK7tzt5T.js +0 -22
- package/dist/index-VOqA2-xz-CKqwdkuf.js +0 -70
- package/dist/index-WN144sZ6-DKm58evR.js +0 -3
- package/dist/jsonld-BpvX3DRL-qZrjsUmJ.js +0 -75
- package/dist/sha256-D_qJpPFT-BYFBxJ7m.js +0 -1
- package/dist/webcrypto.es-DQnPRx8R-BJSH271h.js +0 -41
- package/dist/x25519-Dm-l65ld-DcUk09rC.js +0 -1
- /package/dist/{checkRevocationStatusList2021-CNtaPjVp-XCu3zkCJ.js → checkRevocationStatusList2021-BUqNLYXm-XCu3zkCJ.js} +0 -0
- /package/dist/{ensureNotRevoked-D9_PlMpD-DvMIgM4L.js → ensureNotRevoked-JuH4UdyO-DvMIgM4L.js} +0 -0
- /package/dist/{index-CWugL4dz-Dgus2xdV.js → index-BcM1LBSs-Dgus2xdV.js} +0 -0
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import{a as e,u as t,t as n,g as o}from"./main.js";var a={},r=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()]}};!function(e){if(!e.setImmediate){var t,o,a,r,i,s=1,l={},c=!1,d=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?t=function(e){n((function(){h(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((a=new MessageChannel).port1.onmessage=function(e){h(e.data)},t=function(e){a.port2.postMessage(e)}):d&&"onreadystatechange"in d.createElement("script")?(o=d.documentElement,t=function(e){var t=d.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):t=function(e){setTimeout(h,0,e)}:(r="setImmediate$"+Math.random()+"$",i=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(r)&&h(+t.data.slice(r.length))},e.addEventListener?e.addEventListener("message",i,!1):e.attachEvent("onmessage",i),t=function(t){e.postMessage(r+t,"*")}),u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var n=new Array(arguments.length-1),o=0;o<n.length;o++)n[o]=arguments[o+1];var a={callback:e,args:n};return l[s]=a,t(s),s++},u.clearImmediate=p}function p(e){delete l[e]}function h(e){if(c)setTimeout(h,0,e);else{var t=l[e];if(t){c=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(void 0,n)}}(t)}finally{p(e),c=!1}}}}}("undefined"==typeof self?e:self);
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
4
|
-
*/
|
|
5
|
-
const i=self.crypto||self.msCrypto;var s=class{constructor(e){if(!i||!i.subtle)throw new Error("crypto.subtle not found.");if("sha256"===e)this.algorithm={name:"SHA-256"};else{if("sha1"!==e)throw new Error(`Unsupported algorithm "${e}".`);this.algorithm={name:"SHA-1"}}this._content=""}update(e){this._content+=e}async digest(){const e=(new TextEncoder).encode(this._content),t=new Uint8Array(await i.subtle.digest(this.algorithm,e));let n="";for(let e=0;e<t.length;++e)n+=t[e].toString(16).padStart(2,"0");return n}},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,a=0;const r=e.length;for(let n=0;n<r;++n){const i=e[n],s=t.get(i);(null===o||i>o)&&(s&&n>0&&i>e[n-1]||!s&&n<r-1&&i>e[n+1])&&(o=i,a=n)}if(null===o)this.done=!0;else{const n=t.get(o)?a-1:a+1;e[a]=e[n],e[n]=o;for(const n of e)n>o&&t.set(n,!t.get(n))}return n}};
|
|
6
|
-
/*!
|
|
7
|
-
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
8
|
-
*/
|
|
9
|
-
/*!
|
|
10
|
-
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
11
|
-
*/
|
|
12
|
-
const c="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",d="http://www.w3.org/2001/XMLSchema#string",u="NamedNode",p="BlankNode",h="Literal",f="DefaultGraph",v={};(()=>{const e="(?:<([^:]+:[^>]*)>)",t="A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�_",n=t+"0-9-·̀-ͯ‿-⁀",o="(_:(?:["+t+"0-9])(?:(?:["+n+".])*(?:["+n+"]))?)",a="[ \\t]+",r="[ \\t]*",i="(?:"+e+"|"+o+")"+a,s=e+a,l="(?:"+e+"|"+o+"|"+('(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:'+("(?:\\^\\^"+e+")")+"|(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)))?)")+")"+r,c="(?:\\.|(?:(?:"+e+"|"+o+")"+r+"\\.))";v.eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,v.empty=new RegExp("^"+r+"$"),v.quad=new RegExp("^"+r+i+s+l+c+r+"$")})();var g=class e{static parse(e){const t=[],n={},o=e.split(v.eoln);let a=0;for(const e of o){if(a++,v.empty.test(e))continue;const o=e.match(v.quad);if(null===o)throw new Error("N-Quads parse error on line "+a+".");const r={subject:null,predicate:null,object:null,graph:null};if(void 0!==o[1]?r.subject={termType:u,value:o[1]}:r.subject={termType:p,value:o[2]},r.predicate={termType:u,value:o[3]},void 0!==o[4]?r.object={termType:u,value:o[4]}:void 0!==o[5]?r.object={termType:p,value:o[5]}:(r.object={termType:h,value:void 0,datatype:{termType:u}},void 0!==o[7]?r.object.datatype.value=o[7]:void 0!==o[8]?(r.object.datatype.value=c,r.object.language=o[8]):r.object.datatype.value=d,r.object.value=o[6].replace(x,(function(e,t,n,o){if(t)switch(t){case"t":return"\t";case"b":return"\b";case"n":return"\n";case"r":return"\r";case"f":return"\f";case'"':return'"';case"'":return"'";case"\\":return"\\"}if(n)return String.fromCharCode(parseInt(n,16));if(o)throw new Error("Unsupported U escape")}))),void 0!==o[9]?r.graph={termType:u,value:o[9]}:void 0!==o[10]?r.graph={termType:p,value:o[10]}:r.graph={termType:f,value:""},r.graph.value in n){let e=!0;const o=n[r.graph.value];for(const t of o)if(y(t,r)){e=!1;break}e&&(o.push(r),t.push(r))}else n[r.graph.value]=[r],t.push(r)}return t}static serialize(t){Array.isArray(t)||(t=e.legacyDatasetToQuads(t));const n=[];for(const o of t)n.push(e.serializeQuad(o));return n.sort().join("")}static serializeQuadComponents(e,t,n,o){let a="";return e.termType===u?a+=`<${e.value}>`:a+=`${e.value}`,a+=` <${t.value}> `,n.termType===u?a+=`<${n.value}>`:n.termType===p?a+=n.value:(a+=`"${function(e){return e.replace(m,(function(e){switch(e){case'"':return'\\"';case"\\":return"\\\\";case"\n":return"\\n";case"\r":return"\\r"}}))}(n.value)}"`,n.datatype.value===c?n.language&&(a+=`@${n.language}`):n.datatype.value!==d&&(a+=`^^<${n.datatype.value}>`)),o.termType===u?a+=` <${o.value}>`:o.termType===p&&(a+=` ${o.value}`),a+=" .\n",a}static serializeQuad(t){return e.serializeQuadComponents(t.subject,t.predicate,t.object,t.graph)}static legacyDatasetToQuads(e){const t=[],n={"blank node":p,IRI:u,literal:h};for(const o in e){e[o].forEach((e=>{const a={};for(const t in e){const o=e[t],r={termType:n[o.type],value:o.value};r.termType===h&&(r.datatype={termType:u},"datatype"in o&&(r.datatype.value=o.datatype),"language"in o?("datatype"in o||(r.datatype.value=c),r.language=o.language):"datatype"in o||(r.datatype.value=d)),a[t]=r}a.graph="@default"===o?{termType:f,value:""}:{termType:o.startsWith("_:")?p:u,value:o},t.push(a)}))}return t}};function y(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!==h||e.object.datatype.termType===t.object.datatype.termType&&e.object.language===t.object.language&&e.object.datatype.value===t.object.datatype.value))}const m=/["\\\n\r]/g;const x=/(?:\\([tbnrf"'\\]))|(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;
|
|
13
|
-
/*!
|
|
14
|
-
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
15
|
-
*/
|
|
16
|
-
const b=r,w=s,j=l,I=g;var N=class{constructor({createMessageDigest:e=()=>new w("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:n=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new b("_:c14n",t),this.createMessageDigest=e,this.maxDeepIterations=n,this.quads=null,this.deepIterations=null}async main(e){this.deepIterations=new Map,this.quads=e;for(const t of e)this._addBlankNodeQuadInfo({quad:t,component:t.subject}),this._addBlankNodeQuadInfo({quad:t,component:t.object}),this._addBlankNodeQuadInfo({quad:t,component:t.graph});const t=new Map,n=[...this.blankNodeInfo.keys()];let o=0;for(const e of n)++o%100==0&&await this._yield(),await this._hashAndTrackBlankNode({id:e,hashToBlankNodes:t});const a=[...t.keys()].sort(),r=[];for(const e of a){const n=t.get(e);if(n.length>1){r.push(n);continue}const o=n[0];this.canonicalIssuer.getId(o)}for(const e of r){const t=[];for(const n of e){if(this.canonicalIssuer.hasId(n))continue;const e=new b("_:b");e.getId(n);const o=await this.hashNDegreeQuads(n,e);t.push(o)}t.sort(S);for(const e of t){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const i=[];for(const e of this.quads){const t=I.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));i.push(t)}return i.sort(),i.join("")}async hashFirstDegreeQuads(e){const t=[],n=this.blankNodeInfo.get(e),o=n.quads;for(const n of o){const o={subject:null,predicate:n.predicate,object:null,graph:null};o.subject=this.modifyFirstDegreeComponent(e,n.subject,"subject"),o.object=this.modifyFirstDegreeComponent(e,n.object,"object"),o.graph=this.modifyFirstDegreeComponent(e,n.graph,"graph"),t.push(I.serializeQuad(o))}t.sort();const a=this.createMessageDigest();for(const e of t)a.update(e);return n.hash=await a.digest(),n.hash}async hashRelatedBlankNode(e,t,n,o){let a;a=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):n.hasId(e)?n.getId(e):this.blankNodeInfo.get(e).hash;const r=this.createMessageDigest();return r.update(o),"g"!==o&&r.update(this.getRelatedPredicate(t)),r.update(a),r.digest()}async hashNDegreeQuads(e,t){const n=this.deepIterations.get(e)||0;if(n>this.maxDeepIterations)throw new Error(`Maximum deep iterations (${this.maxDeepIterations}) exceeded.`);this.deepIterations.set(e,n+1);const o=this.createMessageDigest(),a=await this.createHashToRelated(e,t),r=[...a.keys()].sort();for(const e of r){o.update(e);let n,r="";const i=new j(a.get(e));let s=0;for(;i.hasNext();){const e=i.next();++s%3==0&&await this._yield();let o=t.clone(),a="";const l=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?a+=this.canonicalIssuer.getId(t):(o.hasId(t)||l.push(t),a+=o.getId(t)),0!==r.length&&a>r){c=!0;break}if(!c){for(const e of l){const t=await this.hashNDegreeQuads(e,o);if(a+=o.getId(e),a+=`<${t.hash}>`,o=t.issuer,0!==r.length&&a>r){c=!0;break}}c||(0===r.length||a<r)&&(r=a,n=o)}}o.update(r),t=n}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 a=0;for(const r of o)++a%100==0&&await this._yield(),await Promise.all([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}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:a,hashToRelated:r}){if("BlankNode"!==t.termType||t.value===o)return;const i=t.value,s=await this.hashRelatedBlankNode(i,e,a,n),l=r.get(s);l?l.push(i):r.set(s,[i])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise((e=>setImmediate(e)))}};function S(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}
|
|
17
|
-
/*!
|
|
18
|
-
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
19
|
-
*/const O=s,E=N;var D=class extends E{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new O("sha1")}modifyFirstDegreeComponent(e,t,n){return"BlankNode"!==t.termType?t:"graph"===n?{termType:"BlankNode",value:"_:g"}:{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 a=0;for(const r of o){let o,i;if("BlankNode"===r.subject.termType&&r.subject.value!==e)i=r.subject.value,o="p";else{if("BlankNode"!==r.object.termType||r.object.value===e)continue;i=r.object.value,o="r"}++a%100==0&&await this._yield();const s=await this.hashRelatedBlankNode(i,r,t,o),l=n.get(s);l?l.push(i):n.set(s,[i])}return n}};
|
|
20
|
-
/*!
|
|
21
|
-
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
22
|
-
*/const k=r,C=s,L=l,R=g;var T=class{constructor({createMessageDigest:e=()=>new C("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:n=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new k("_:c14n",t),this.createMessageDigest=e,this.maxDeepIterations=n,this.quads=null,this.deepIterations=null}main(e){this.deepIterations=new Map,this.quads=e;for(const t of e)this._addBlankNodeQuadInfo({quad:t,component:t.subject}),this._addBlankNodeQuadInfo({quad:t,component:t.object}),this._addBlankNodeQuadInfo({quad:t,component:t.graph});const t=new Map,n=[...this.blankNodeInfo.keys()];for(const e of n)this._hashAndTrackBlankNode({id:e,hashToBlankNodes:t});const o=[...t.keys()].sort(),a=[];for(const e of o){const n=t.get(e);if(n.length>1){a.push(n);continue}const o=n[0];this.canonicalIssuer.getId(o)}for(const e of a){const t=[];for(const n of e){if(this.canonicalIssuer.hasId(n))continue;const e=new k("_:b");e.getId(n);const o=this.hashNDegreeQuads(n,e);t.push(o)}t.sort(A);for(const e of t){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const r=[];for(const e of this.quads){const t=R.serializeQuadComponents(this._componentWithCanonicalId({component:e.subject}),e.predicate,this._componentWithCanonicalId({component:e.object}),this._componentWithCanonicalId({component:e.graph}));r.push(t)}return r.sort(),r.join("")}hashFirstDegreeQuads(e){const t=[],n=this.blankNodeInfo.get(e),o=n.quads;for(const n of o){const o={subject:null,predicate:n.predicate,object:null,graph:null};o.subject=this.modifyFirstDegreeComponent(e,n.subject,"subject"),o.object=this.modifyFirstDegreeComponent(e,n.object,"object"),o.graph=this.modifyFirstDegreeComponent(e,n.graph,"graph"),t.push(R.serializeQuad(o))}t.sort();const a=this.createMessageDigest();for(const e of t)a.update(e);return n.hash=a.digest(),n.hash}hashRelatedBlankNode(e,t,n,o){let a;a=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):n.hasId(e)?n.getId(e):this.blankNodeInfo.get(e).hash;const r=this.createMessageDigest();return r.update(o),"g"!==o&&r.update(this.getRelatedPredicate(t)),r.update(a),r.digest()}hashNDegreeQuads(e,t){const n=this.deepIterations.get(e)||0;if(n>this.maxDeepIterations)throw new Error(`Maximum deep iterations (${this.maxDeepIterations}) exceeded.`);this.deepIterations.set(e,n+1);const o=this.createMessageDigest(),a=this.createHashToRelated(e,t),r=[...a.keys()].sort();for(const e of r){o.update(e);let n,r="";const i=new L(a.get(e));for(;i.hasNext();){const e=i.next();let o=t.clone(),a="";const s=[];let l=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?a+=this.canonicalIssuer.getId(t):(o.hasId(t)||s.push(t),a+=o.getId(t)),0!==r.length&&a>r){l=!0;break}if(!l){for(const e of s){const t=this.hashNDegreeQuads(e,o);if(a+=o.getId(e),a+=`<${t.hash}>`,o=t.issuer,0!==r.length&&a>r){l=!0;break}}l||(0===r.length||a<r)&&(r=a,n=o)}}o.update(r),t=n}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 a of o)this._addRelatedBlankNodeHash({quad:a,component:a.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:a,component:a.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:a,component:a.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:a,hashToRelated:r}){if("BlankNode"!==t.termType||t.value===o)return;const i=t.value,s=this.hashRelatedBlankNode(i,e,a,n),l=r.get(s);l?l.push(i):r.set(s,[i])}_componentWithCanonicalId({component:e}){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}};function A(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}
|
|
23
|
-
/*!
|
|
24
|
-
* Copyright (c) 2016-2021 Digital Bazaar, Inc. All rights reserved.
|
|
25
|
-
*/const _=s,M=T;var J=class extends M{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new _("sha1")}modifyFirstDegreeComponent(e,t,n){return"BlankNode"!==t.termType?t:"graph"===n?{termType:"BlankNode",value:"_:g"}:{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 a of o){let o,r;if("BlankNode"===a.subject.termType&&a.subject.value!==e)r=a.subject.value,o="p";else{if("BlankNode"!==a.object.termType||a.object.value===e)continue;r=a.object.value,o="r"}const i=this.hashRelatedBlankNode(r,a,t,o),s=n.get(i);s?s.push(r):n.set(i,[r])}return n}},P=t(Object.freeze({__proto__:null,default:{}}));!function(e){const t=N,n=D,o=T,a=J;let i;try{i=P}catch(e){}function s(t){return Array.isArray(t)?t:e.NQuads.legacyDatasetToQuads(t)}e.NQuads=g,e.IdentifierIssuer=r,e._rdfCanonizeNative=function(e){return e&&(i=e),i},e.canonize=async function(e,o){const a=s(e);if(o.useNative){if(!i)throw new Error("rdf-canonize-native not available");if(o.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return new Promise(((e,t)=>i.canonize(a,o,((n,o)=>n?t(n):e(o)))))}if("URDNA2015"===o.algorithm)return new t(o).main(a);if("URGNA2012"===o.algorithm){if(o.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "URGNA2012".');return new n(o).main(a)}if(!("algorithm"in o))throw new Error("No RDF Dataset Canonicalization algorithm specified.");throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+o.algorithm)},e._canonizeSync=function(e,t){const n=s(e);if(t.useNative){if(!i)throw new Error("rdf-canonize-native not available");if(t.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return i.canonizeSync(n,t)}if("URDNA2015"===t.algorithm)return new o(t).main(n);if("URGNA2012"===t.algorithm){if(t.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "URGNA2012".');return new a(t).main(n)}if(!("algorithm"in t))throw new Error("No RDF Dataset Canonicalization algorithm specified.");throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+t.algorithm)}}(a);var B=a;const H={};var F=H;H.isArray=Array.isArray,H.isBoolean=e=>"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e),H.isDouble=e=>H.isNumber(e)&&(-1!==String(e).indexOf(".")||Math.abs(e)>=1e21),H.isEmptyObject=e=>H.isObject(e)&&0===Object.keys(e).length,H.isNumber=e=>"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e),H.isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),H.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),H.isString=e=>"string"==typeof e||"[object String]"===Object.prototype.toString.call(e),H.isUndefined=e=>void 0===e;const q=F,U={};var V=U;U.isSubject=e=>{if(q.isObject(e)&&!("@value"in e||"@set"in e||"@list"in e)){return Object.keys(e).length>1||!("@id"in e)}return!1},U.isSubjectReference=e=>q.isObject(e)&&1===Object.keys(e).length&&"@id"in e,U.isValue=e=>q.isObject(e)&&"@value"in e,U.isList=e=>q.isObject(e)&&"@list"in e,U.isGraph=e=>q.isObject(e)&&"@graph"in e&&1===Object.keys(e).filter((e=>"@id"!==e&&"@index"!==e)).length,U.isSimpleGraph=e=>U.isGraph(e)&&!("@id"in e),U.isBlankNode=e=>{if(q.isObject(e)){if("@id"in e){const t=e["@id"];return!q.isString(t)||0===t.indexOf("_:")}return 0===Object.keys(e).length||!("@value"in e||"@set"in e||"@list"in e)}return!1};var z=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}};const G=V,$=F,Q=B.IdentifierIssuer,X=z,W=/(?:<[^>]*?>|"[^"]*?"|[^,])+/g,K=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,Z=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g,Y={accept:"application/ld+json, application/json"},ee={};var te=ee;function ne(e,t){if($.isArray(t))for(let n=0;n<t.length;++n)t[n]=ne(e,t[n]);else if(G.isList(t))t["@list"]=ne(e,t["@list"]);else if($.isObject(t)){G.isBlankNode(t)&&(t["@id"]=e.getId(t["@id"]));const n=Object.keys(t).sort();for(let o=0;o<n.length;++o){const a=n[o];"@id"!==a&&(t[a]=ne(e,t[a]))}}return t}ee.IdentifierIssuer=Q,ee.REGEX_BCP47=/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/,ee.REGEX_KEYWORD=/^@[a-zA-Z]+$/,ee.clone=function(e){if(e&&"object"==typeof e){let t;if($.isArray(e)){t=[];for(let n=0;n<e.length;++n)t[n]=ee.clone(e[n])}else if(e instanceof Map){t=new Map;for(const[n,o]of e)t.set(n,ee.clone(o))}else if(e instanceof Set){t=new Set;for(const n of e)t.add(ee.clone(n))}else if($.isObject(e)){t={};for(const n in e)t[n]=ee.clone(e[n])}else t=e.toString();return t}return e},ee.asArray=function(e){return Array.isArray(e)?e:[e]},ee.buildHeaders=(e={})=>{if(Object.keys(e).some((e=>"accept"===e.toLowerCase())))throw new RangeError('Accept header may not be specified; only "'+Y.accept+'" is supported.');return Object.assign({Accept:Y.accept},e)},ee.parseLinkHeader=e=>{const t={},n=e.match(W);for(let e=0;e<n.length;++e){let o=n[e].match(K);if(!o)continue;const a={target:o[1]},r=o[2];for(;o=Z.exec(r);)a[o[1]]=void 0===o[2]?o[3]:o[2];const i=a.rel||"";Array.isArray(t[i])?t[i].push(a):t.hasOwnProperty(i)?t[i]=[t[i],a]:t[i]=a}return t},ee.validateTypeValue=(e,t)=>{if(!($.isString(e)||$.isArray(e)&&e.every((e=>$.isString(e))))){if(t&&$.isObject(e))switch(Object.keys(e).length){case 0:return;case 1:if("@default"in e&&ee.asArray(e["@default"]).every((e=>$.isString(e))))return}throw new X('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})}},ee.hasProperty=(e,t)=>{if(e.hasOwnProperty(t)){const n=e[t];return!$.isArray(n)||n.length>0}return!1},ee.hasValue=(e,t,n)=>{if(ee.hasProperty(e,t)){let o=e[t];const a=G.isList(o);if($.isArray(o)||a){a&&(o=o["@list"]);for(let e=0;e<o.length;++e)if(ee.compareValues(n,o[e]))return!0}else if(!$.isArray(n))return ee.compareValues(n,o)}return!1},ee.addValue=(e,t,n,o)=>{if("propertyIsArray"in(o=o||{})||(o.propertyIsArray=!1),"valueIsArray"in o||(o.valueIsArray=!1),"allowDuplicate"in o||(o.allowDuplicate=!0),"prependValue"in o||(o.prependValue=!1),o.valueIsArray)e[t]=n;else if($.isArray(n)){0===n.length&&o.propertyIsArray&&!e.hasOwnProperty(t)&&(e[t]=[]),o.prependValue&&(n=n.concat(e[t]),e[t]=[]);for(let a=0;a<n.length;++a)ee.addValue(e,t,n[a],o)}else if(e.hasOwnProperty(t)){const a=!o.allowDuplicate&&ee.hasValue(e,t,n);$.isArray(e[t])||a&&!o.propertyIsArray||(e[t]=[e[t]]),a||(o.prependValue?e[t].unshift(n):e[t].push(n))}else e[t]=o.propertyIsArray?[n]:n},ee.getValues=(e,t)=>[].concat(e[t]||[]),ee.removeProperty=(e,t)=>{delete e[t]},ee.removeValue=(e,t,n,o)=>{"propertyIsArray"in(o=o||{})||(o.propertyIsArray=!1);const a=ee.getValues(e,t).filter((e=>!ee.compareValues(e,n)));0===a.length?ee.removeProperty(e,t):1!==a.length||o.propertyIsArray?e[t]=a:e[t]=a[0]},ee.relabelBlankNodes=(e,t)=>ne((t=t||{}).issuer||new Q("_:b"),e),ee.compareValues=(e,t)=>e===t||(!(!G.isValue(e)||!G.isValue(t)||e["@value"]!==t["@value"]||e["@type"]!==t["@type"]||e["@language"]!==t["@language"]||e["@index"]!==t["@index"])||!!($.isObject(e)&&"@id"in e&&$.isObject(t)&&"@id"in t)&&e["@id"]===t["@id"]),ee.compareShortestLeast=(e,t)=>e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1;const oe="http://www.w3.org/1999/02/22-rdf-syntax-ns#",ae="http://www.w3.org/2001/XMLSchema#";var re,ie,se,le,ce={LINK_HEADER_REL:"http://www.w3.org/ns/json-ld#context",LINK_HEADER_CONTEXT:"http://www.w3.org/ns/json-ld#context",RDF:oe,RDF_LIST:oe+"List",RDF_FIRST:oe+"first",RDF_REST:oe+"rest",RDF_NIL:oe+"nil",RDF_TYPE:oe+"type",RDF_PLAIN_LITERAL:oe+"PlainLiteral",RDF_XML_LITERAL:oe+"XMLLiteral",RDF_JSON_LITERAL:oe+"JSON",RDF_OBJECT:oe+"object",RDF_LANGSTRING:oe+"langString",XSD:ae,XSD_BOOLEAN:ae+"boolean",XSD_DOUBLE:ae+"double",XSD_INTEGER:ae+"integer",XSD_STRING:ae+"string"};function de(){return ie||(ie=1,re=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]}}}),re}function ue(){if(le)return se;le=1;const e=F,t={};se=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={},a=t.parsers[n||"full"],r=a.regex.exec(e);let i=a.keys.length;for(;i--;)o[a.keys[i]]=void 0===r[i]?null:r[i];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 a=t.parse(o),r={protocol:n.protocol||""};if(null!==a.authority)r.authority=a.authority,r.path=a.path,r.query=a.query;else if(r.authority=n.authority,""===a.path)r.path=n.path,null!==a.query?r.query=a.query:r.query=n.query;else{if(0===a.path.indexOf("/"))r.path=a.path;else{let e=n.path;e=e.substr(0,e.lastIndexOf("/")+1),(e.length>0||n.authority)&&"/"!==e.substr(-1)&&(e+="/"),e+=a.path,r.path=e}r.query=a.query}""!==a.path&&(r.path=t.removeDotSegments(r.path));let i=r.protocol;return null!==r.authority&&(i+="//"+r.authority),i+=r.path,null!==r.query&&(i+="?"+r.query),null!==a.fragment&&(i+="#"+a.fragment),""===i&&(i="./"),i},t.removeBase=(n,o)=>{if(null===n)return o;n&&!e.isString(n)||(n=t.parse(n||""));let a="";if(""!==n.href?a+=(n.protocol||"")+"//"+(n.authority||""):o.indexOf("//")&&(a+="//"),0!==o.indexOf(a))return o;const r=t.parse(o.substr(a.length)),i=n.normalizedPath.split("/"),s=r.normalizedPath.split("/"),l=r.fragment||r.query?0:1;for(;i.length>0&&s.length>l&&i[0]===s[0];)i.shift(),s.shift();let c="";if(i.length>0){i.pop();for(let e=0;e<i.length;++e)c+="../"}return c+=s.join("/"),null!==r.query&&(c+="?"+r.query),null!==r.fragment&&(c+="#"+r.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),se}const{parseLinkHeader:pe,buildHeaders:he}=te,{LINK_HEADER_CONTEXT:fe}=ce,ve=z,ge=de(),{prependBase:ye}=ue(),me=/(^|(\r\n))link:/i;const xe=({secure:e,headers:t={},xhr:n}={headers:{}})=>{t=he(t);return(new ge).wrapLoader((async function o(a){if(0!==a.indexOf("http:")&&0!==a.indexOf("https:"))throw new ve('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:a});if(e&&0!==a.indexOf("https"))throw new ve('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:a});let r;try{r=await function(e,t,n){e=e||XMLHttpRequest;const o=new e;return new Promise(((e,a)=>{o.onload=()=>e(o),o.onerror=e=>a(e),o.open("GET",t,!0);for(const e in n)o.setRequestHeader(e,n[e]);o.send()}))}(n,a,t)}catch(e){throw new ve("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:a,cause:e})}if(r.status>=400)throw new ve("URL could not be dereferenced: "+r.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:a,httpStatusCode:r.status});let i={contextUrl:null,documentUrl:a,document:r.response},s=null;const l=r.getResponseHeader("Content-Type");let c;me.test(r.getAllResponseHeaders())&&(c=r.getResponseHeader("Link"));if(c&&"application/ld+json"!==l){const e=pe(c),t=e[fe];if(Array.isArray(t))throw new ve("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:a});t&&(i.contextUrl=t.target),s=e.alternate,s&&"application/ld+json"==s.type&&!(l||"").match(/^application\/(\w*\+)?json$/)&&(i=await o(ye(a,s.target)))}return i}))},be={};var we,je,Ie=be;be.setupDocumentLoaders=function(e){"undefined"!=typeof XMLHttpRequest&&(e.documentLoaders.xhr=xe,e.useDocumentLoader("xhr"))},be.setupGlobals=function(e){void 0===globalThis.JsonLdProcessor&&Object.defineProperty(globalThis,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:e.JsonLdProcessor})};var Ne=Se;function Se(e){var t=this;if(t instanceof Se||(t=new Se),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var n=0,o=arguments.length;n<o;n++)t.push(arguments[n]);return t}function Oe(e,t,n){var o=t===e.head?new ke(n,null,t,e):new ke(n,t,t.next,e);return null===o.next&&(e.tail=o),null===o.prev&&(e.head=o),e.length++,o}function Ee(e,t){e.tail=new ke(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function De(e,t){e.head=new ke(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function ke(e,t,n,o){if(!(this instanceof ke))return new ke(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}Se.Node=ke,Se.create=Se,Se.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},Se.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++}},Se.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++}},Se.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)Ee(this,arguments[e]);return this.length},Se.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)De(this,arguments[e]);return this.length},Se.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}},Se.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}},Se.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},Se.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},Se.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},Se.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},Se.prototype.map=function(e,t){t=t||this;for(var n=new Se,o=this.head;null!==o;)n.push(e.call(t,o.value,this)),o=o.next;return n},Se.prototype.mapReverse=function(e,t){t=t||this;for(var n=new Se,o=this.tail;null!==o;)n.push(e.call(t,o.value,this)),o=o.prev;return n},Se.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 a=0;null!==o;a++)n=e(n,o.value,a),o=o.next;return n},Se.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 a=this.length-1;null!==o;a--)n=e(n,o.value,a),o=o.prev;return n},Se.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},Se.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},Se.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new Se;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,a=this.head;null!==a&&o<e;o++)a=a.next;for(;null!==a&&o<t;o++,a=a.next)n.push(a.value);return n},Se.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new Se;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,a=this.tail;null!==a&&o>t;o--)a=a.prev;for(;null!==a&&o>e;o--,a=a.prev)n.push(a.value);return n},Se.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var o=0,a=this.head;null!==a&&o<e;o++)a=a.next;var r=[];for(o=0;a&&o<t;o++)r.push(a.value),a=this.removeNode(a);null===a&&(a=this.tail),a!==this.head&&a!==this.tail&&(a=a.prev);for(o=0;o<n.length;o++)a=Oe(this,a,n[o]);return r},Se.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{(je||(je=1,we=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),we)(Se)}catch(e){}const Ce=Ne,Le=Symbol("max"),Re=Symbol("length"),Te=Symbol("lengthCalculator"),Ae=Symbol("allowStale"),_e=Symbol("maxAge"),Me=Symbol("dispose"),Je=Symbol("noDisposeOnSet"),Pe=Symbol("lruList"),Be=Symbol("cache"),He=Symbol("updateAgeOnGet"),Fe=()=>1;const qe=(e,t,n)=>{const o=e[Be].get(t);if(o){const t=o.value;if(Ue(e,t)){if(ze(e,o),!e[Ae])return}else n&&(e[He]&&(o.value.now=Date.now()),e[Pe].unshiftNode(o));return t.value}},Ue=(e,t)=>{if(!t||!t.maxAge&&!e[_e])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[_e]&&n>e[_e]},Ve=e=>{if(e[Re]>e[Le])for(let t=e[Pe].tail;e[Re]>e[Le]&&null!==t;){const n=t.prev;ze(e,t),t=n}},ze=(e,t)=>{if(t){const n=t.value;e[Me]&&e[Me](n.key,n.value),e[Re]-=n.length,e[Be].delete(n.key),e[Pe].removeNode(t)}};class Ge{constructor(e,t,n,o,a){this.key=e,this.value=t,this.length=n,this.now=o,this.maxAge=a||0}}const $e=(e,t,n,o)=>{let a=n.value;Ue(e,a)&&(ze(e,n),e[Ae]||(a=void 0)),a&&t.call(o,a.value,a.key,e)};var Qe=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[Le]=e.max||1/0;const t=e.length||Fe;if(this[Te]="function"!=typeof t?Fe:t,this[Ae]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[_e]=e.maxAge||0,this[Me]=e.dispose,this[Je]=e.noDisposeOnSet||!1,this[He]=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[Le]=e||1/0,Ve(this)}get max(){return this[Le]}set allowStale(e){this[Ae]=!!e}get allowStale(){return this[Ae]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[_e]=e,Ve(this)}get maxAge(){return this[_e]}set lengthCalculator(e){"function"!=typeof e&&(e=Fe),e!==this[Te]&&(this[Te]=e,this[Re]=0,this[Pe].forEach((e=>{e.length=this[Te](e.value,e.key),this[Re]+=e.length}))),Ve(this)}get lengthCalculator(){return this[Te]}get length(){return this[Re]}get itemCount(){return this[Pe].length}rforEach(e,t){t=t||this;for(let n=this[Pe].tail;null!==n;){const o=n.prev;$e(this,e,n,t),n=o}}forEach(e,t){t=t||this;for(let n=this[Pe].head;null!==n;){const o=n.next;$e(this,e,n,t),n=o}}keys(){return this[Pe].toArray().map((e=>e.key))}values(){return this[Pe].toArray().map((e=>e.value))}reset(){this[Me]&&this[Pe]&&this[Pe].length&&this[Pe].forEach((e=>this[Me](e.key,e.value))),this[Be]=new Map,this[Pe]=new Ce,this[Re]=0}dump(){return this[Pe].map((e=>!Ue(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[Pe]}set(e,t,n){if((n=n||this[_e])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const o=n?Date.now():0,a=this[Te](t,e);if(this[Be].has(e)){if(a>this[Le])return ze(this,this[Be].get(e)),!1;const r=this[Be].get(e).value;return this[Me]&&(this[Je]||this[Me](e,r.value)),r.now=o,r.maxAge=n,r.value=t,this[Re]+=a-r.length,r.length=a,this.get(e),Ve(this),!0}const r=new Ge(e,t,a,o,n);return r.length>this[Le]?(this[Me]&&this[Me](e,t),!1):(this[Re]+=r.length,this[Pe].unshift(r),this[Be].set(e,this[Pe].head),Ve(this),!0)}has(e){if(!this[Be].has(e))return!1;const t=this[Be].get(e).value;return!Ue(this,t)}get(e){return qe(this,e,!0)}peek(e){return qe(this,e,!1)}pop(){const e=this[Pe].tail;return e?(ze(this,e),e.value):null}del(e){ze(this,this[Be].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const o=e[n],a=o.e||0;if(0===a)this.set(o.k,o.v);else{const e=a-t;e>0&&this.set(o.k,o.v,e)}}}prune(){this[Be].forEach(((e,t)=>qe(this,t,!1)))}};const Xe=Qe;const{isArray:We,isObject:Ke,isString:Ze}=F,{asArray:Ye}=te,{prependBase:et}=ue(),tt=z,nt=class{constructor({document:e}){this.document=e,this.cache=new Xe({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}};function ot(e){throw new tt("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function at({context:e,base:t}){if(!e)return;const n=e["@context"];if(Ze(n))e["@context"]=et(t,n);else if(We(n))for(let e=0;e<n.length;++e){const o=n[e];Ze(o)?n[e]=et(t,o):Ke(o)&&at({context:{"@context":o},base:t})}else if(Ke(n))for(const e in n)at({context:n[e],base:t})}var rt=B.NQuads;const it=z,{isArray:st}=F,{asArray:lt}=te,ct={};var dt=ct;function ut({event:e,handlers:t}){let n=!0;for(let o=0;n&&o<t.length;++o){n=!1;const a=t[o];if(st(a))n=ut({event:e,handlers:a});else if("function"==typeof a)a({event:e,next:()=>{n=!0}});else{if("object"!=typeof a)throw new it("Invalid event handler.","jsonld.InvalidEventHandler",{event:e});e.code in a?a[e.code]({event:e,next:()=>{n=!0}}):n=!0}}return n}ct.defaultEventHandler=null,ct.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?ct.safeEventHandler:[],e.eventHandler?lt(e.eventHandler):[],ct.defaultEventHandler?ct.defaultEventHandler:[]);return 0===t.length?null:t},ct.handleEvent=({event:e,options:t})=>{ut({event:e,handlers:t.eventHandler})};const pt=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"]);ct.safeEventHandler=function({event:e,next:t}){if("warning"===e.level&&pt.has(e.code))throw new it("Safe mode validation error.","jsonld.ValidationError",{event:e});t()},ct.logEventHandler=function({event:e,next:t}){console.log(`EVENT: ${e.message}`,{event:e}),t()},ct.logWarningEventHandler=function({event:e,next:t}){"warning"===e.level&&console.warn(`WARNING: ${e.message}`,{event:e}),t()},ct.unhandledEventHandler=function({event:e}){throw new it("No handler for event.","jsonld.UnhandledEvent",{event:e})},ct.setDefaultEventHandler=function({eventHandler:e}={}){ct.defaultEventHandler=e?lt(e):null};const ht=te,ft=z,{isArray:vt,isObject:gt,isString:yt,isUndefined:mt}=F,{isAbsolute:xt,isRelative:bt,prependBase:wt}=ue(),{handleEvent:jt}=dt,{REGEX_BCP47:It,REGEX_KEYWORD:Nt,asArray:St,compareShortestLeast:Ot}=te,Et=new Map,Dt={};var kt=Dt;function Ct(e,t,n,o,a,r){if(null===t||!yt(t)||Dt.isKeyword(t))return t;if(t.match(Nt))return null;if(o&&o.hasOwnProperty(t)&&!0!==a.get(t)&&Dt.createTermDefinition({activeCtx:e,localCtx:o,term:t,defined:a,options:r}),(n=n||{}).vocab){const n=e.mappings.get(t);if(null===n)return null;if(gt(n)&&"@id"in n)return n["@id"]}const i=t.indexOf(":");if(i>0){const n=t.substr(0,i),s=t.substr(i+1);if("_"===n||0===s.indexOf("//"))return t;o&&o.hasOwnProperty(n)&&Dt.createTermDefinition({activeCtx:e,localCtx:o,term:n,defined:a,options:r});const l=e.mappings.get(n);if(l&&l._prefix)return l["@id"]+s;if(xt(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=wt(r.base,e["@base"]),n=wt(o,t)):(o=e["@base"],n=t):(o=r.base,n=wt(r.base,t)),t=n}return t}function Lt(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(!Lt(e[n],t[n]))return!1;return!0}const o=Object.keys(e),a=Object.keys(t);if(o.length!==a.length)return!1;for(const n in e){let o=e[n],a=t[n];if("@container"===n&&Array.isArray(o)&&Array.isArray(a)&&(o=o.slice().sort(),a=a.slice().sort()),!Lt(o,a))return!1}return!0}Dt.process=async({activeCtx:e,localCtx:t,options:n,propagate:o=!0,overrideProtected:a=!1,cycles:r=new Set})=>{gt(t)&&"@context"in t&&vt(t["@context"])&&(t=t["@context"]);if(0===St(t).length)return e;const i=[],s=[({event:e,next:t})=>{i.push(e),t()}];n.eventHandler&&s.push(n.eventHandler);const l=n;n={...n,eventHandler:s};const c=await n.contextResolver.resolve({activeCtx:e,context:t,documentLoader:n.documentLoader,base:n.base});gt(c[0].document)&&"boolean"==typeof c[0].document["@propagate"]&&(o=c[0].document["@propagate"]);let d=e;o||d.previousContext||(d=d.clone(),d.previousContext=e);for(const o of c){let{document:s}=o;if(e=d,null===s){if(!a&&0!==Object.keys(e.protected).length)throw new ft("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});d=e=Dt.getInitialContext(n).clone();continue}const c=o.getProcessed(e);if(c){if(l.eventHandler)for(const e of c.events)jt({event:e,options:l});d=e=c.context;continue}if(gt(s)&&"@context"in s&&(s=s["@context"]),!gt(s))throw new ft("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:s});d=d.clone();const u=new Map;if("@version"in s){if(1.1!==s["@version"])throw new ft("Unsupported JSON-LD version: "+s["@version"],"jsonld.UnsupportedVersion",{code:"invalid @version value",context:s});if(e.processingMode&&"json-ld-1.0"===e.processingMode)throw new ft("@version: "+s["@version"]+" not compatible with "+e.processingMode,"jsonld.ProcessingModeConflict",{code:"processing mode conflict",context:s});d.processingMode="json-ld-1.1",d["@version"]=s["@version"],u.set("@version",!0)}if(d.processingMode=d.processingMode||e.processingMode,"@base"in s){let e=s["@base"];if(null===e||xt(e));else{if(!bt(e))throw new ft('Invalid JSON-LD syntax; the value of "@base" in a @context must be an absolute IRI, a relative IRI, or null.',"jsonld.SyntaxError",{code:"invalid base IRI",context:s});e=wt(d["@base"],e)}d["@base"]=e,u.set("@base",!0)}if("@vocab"in s){const e=s["@vocab"];if(null===e)delete d["@vocab"];else{if(!yt(e))throw new ft('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:s});if(!xt(e)&&Dt.processingMode(d,1))throw new ft('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:s});{const t=Ct(d,e,{vocab:!0,base:!0},void 0,void 0,n);xt(t)||n.eventHandler&&jt({event:{type:["JsonLdEvent"],code:"relative @vocab reference",level:"warning",message:"Relative @vocab reference found.",details:{vocab:t}},options:n}),d["@vocab"]=t}}u.set("@vocab",!0)}if("@language"in s){const e=s["@language"];if(null===e)delete d["@language"];else{if(!yt(e))throw new ft('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:s});e.match(It)||n.eventHandler&&jt({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:n}),d["@language"]=e.toLowerCase()}u.set("@language",!0)}if("@direction"in s){const t=s["@direction"];if("json-ld-1.0"===e.processingMode)throw new ft("Invalid JSON-LD syntax; @direction not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context member",context:s});if(null===t)delete d["@direction"];else{if("ltr"!==t&&"rtl"!==t)throw new ft('Invalid JSON-LD syntax; the value of "@direction" in a @context must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:s});d["@direction"]=t}u.set("@direction",!0)}if("@propagate"in s){const n=s["@propagate"];if("json-ld-1.0"===e.processingMode)throw new ft("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if("boolean"!=typeof n)throw new ft("Invalid JSON-LD syntax; @propagate value must be a boolean.","jsonld.SyntaxError",{code:"invalid @propagate value",context:t});u.set("@propagate",!0)}if("@import"in s){const o=s["@import"];if("json-ld-1.0"===e.processingMode)throw new ft("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if(!yt(o))throw new ft("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:t});const a=await n.contextResolver.resolve({activeCtx:e,context:o,documentLoader:n.documentLoader,base:n.base});if(1!==a.length)throw new ft("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:t});const r=a[0].getProcessed(e);if(r)s=r;else{const n=a[0].document;if("@import"in n)throw new ft("Invalid JSON-LD syntax: imported context must not include @import.","jsonld.SyntaxError",{code:"invalid context entry",context:t});for(const e in n)s.hasOwnProperty(e)||(s[e]=n[e]);a[0].setProcessed(e,s)}u.set("@import",!0)}u.set("@protected",s["@protected"]||!1);for(const e in s)if(Dt.createTermDefinition({activeCtx:d,localCtx:s,term:e,defined:u,options:n,overrideProtected:a}),gt(s[e])&&"@context"in s[e]){const t=s[e]["@context"];let o=!0;if(yt(t)){const e=wt(n.base,t);r.has(e)?o=!1:r.add(e)}if(o)try{await Dt.process({activeCtx:d.clone(),localCtx:s[e]["@context"],overrideProtected:!0,options:n,cycles:r})}catch(t){throw new ft("Invalid JSON-LD syntax; invalid scoped context.","jsonld.SyntaxError",{code:"invalid scoped context",context:s[e]["@context"],term:e})}}o.setProcessed(e,{context:d,events:i})}return d},Dt.createTermDefinition=({activeCtx:e,localCtx:t,term:n,defined:o,options:a,overrideProtected:r=!1})=>{if(o.has(n)){if(o.get(n))return;throw new ft("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:n})}let i;if(o.set(n,!1),t.hasOwnProperty(n)&&(i=t[n]),"@type"===n&>(i)&&"@set"===(i["@container"]||"@set")&&Dt.processingMode(e,1.1)){const e=["@container","@id","@protected"],o=Object.keys(i);if(0===o.length||o.some((t=>!e.includes(t))))throw new ft("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n})}else{if(Dt.isKeyword(n))throw new ft("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n});if(n.match(Nt))return void(a.eventHandler&&jt({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:n}},options:a}));if(""===n)throw new ft("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:t})}const s=e.mappings.get(n);e.mappings.has(n)&&e.mappings.delete(n);let l=!1;if((yt(i)||null===i)&&(l=!0,i={"@id":i}),!gt(i))throw new ft("Invalid JSON-LD syntax; @context term values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:t});const c={};e.mappings.set(n,c),c.reverse=!1;const d=["@container","@id","@language","@reverse","@type"];Dt.processingMode(e,1.1)&&d.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in i)if(!d.includes(e))throw new ft("Invalid JSON-LD syntax; a term definition must not contain "+e,"jsonld.SyntaxError",{code:"invalid term definition",context:t});const u=n.indexOf(":");if(c._termHasColon=u>0,"@reverse"in i){if("@id"in i)throw new ft("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});if("@nest"in i)throw new ft("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});const r=i["@reverse"];if(!yt(r))throw new ft("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(r.match(Nt))return a.eventHandler&&jt({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:r}},options:a}),void(s?e.mappings.set(n,s):e.mappings.delete(n));const l=Ct(e,r,{vocab:!0,base:!1},t,o,a);if(!xt(l))throw new ft("Invalid JSON-LD syntax; a @context @reverse value must be an absolute IRI or a blank node identifier.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});c["@id"]=l,c.reverse=!0}else if("@id"in i){let r=i["@id"];if(r&&!yt(r))throw new ft("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(null===r)c["@id"]=null;else{if(!Dt.isKeyword(r)&&r.match(Nt))return a.eventHandler&&jt({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:r}},options:a}),void(s?e.mappings.set(n,s):e.mappings.delete(n));if(r!==n){if(r=Ct(e,r,{vocab:!0,base:!1},t,o,a),!xt(r)&&!Dt.isKeyword(r))throw new ft("Invalid JSON-LD syntax; a @context @id value must be an absolute IRI, a blank node identifier, or a keyword.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(n.match(/(?::[^:])|\//)){if(Ct(e,n,{vocab:!0,base:!1},t,new Map(o).set(n,!0),a)!==r)throw new ft("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t})}c["@id"]=r,c._prefix=l&&!c._termHasColon&&null!==r.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in c))if(c._termHasColon){const r=n.substr(0,u);if(t.hasOwnProperty(r)&&Dt.createTermDefinition({activeCtx:e,localCtx:t,term:r,defined:o,options:a}),e.mappings.has(r)){const t=n.substr(u+1);c["@id"]=e.mappings.get(r)["@id"]+t}else c["@id"]=n}else if("@type"===n)c["@id"]=n;else{if(!("@vocab"in e))throw new ft("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t,term:n});c["@id"]=e["@vocab"]+n}if((!0===i["@protected"]||!0===o.get("@protected")&&!1!==i["@protected"])&&(e.protected[n]=!0,c.protected=!0),o.set(n,!0),"@type"in i){let n=i["@type"];if(!yt(n))throw new ft("Invalid JSON-LD syntax; an @context @type value must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if("@json"===n||"@none"===n){if(Dt.processingMode(e,1))throw new ft(`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:t})}else if("@id"!==n&&"@vocab"!==n){if(n=Ct(e,n,{vocab:!0,base:!1},t,o,a),!xt(n))throw new ft("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if(0===n.indexOf("_:"))throw new ft("Invalid JSON-LD syntax; an @context @type value must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}c["@type"]=n}if("@container"in i){const n=yt(i["@container"])?[i["@container"]]:i["@container"]||[],o=["@list","@set","@index","@language"];let a=!0;const r=n.includes("@set");if(Dt.processingMode(e,1.1)){if(o.push("@graph","@id","@type"),n.includes("@list")){if(1!==n.length)throw new ft("Invalid JSON-LD syntax; @context @container with @list must have no other values","jsonld.SyntaxError",{code:"invalid container mapping",context:t})}else if(n.includes("@graph")){if(n.some((e=>"@graph"!==e&&"@id"!==e&&"@index"!==e&&"@set"!==e)))throw new ft("Invalid JSON-LD syntax; @context @container with @graph must have no other values other than @id, @index, and @set","jsonld.SyntaxError",{code:"invalid container mapping",context:t})}else a&=n.length<=(r?2:1);if(n.includes("@type")&&(c["@type"]=c["@type"]||"@id",!["@id","@vocab"].includes(c["@type"])))throw new ft("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else a&=!vt(i["@container"]),a&=n.length<=1;if(a&=n.every((e=>o.includes(e))),a&=!(r&&n.includes("@list")),!a)throw new ft("Invalid JSON-LD syntax; @context @container value must be one of the following: "+o.join(", "),"jsonld.SyntaxError",{code:"invalid container mapping",context:t});if(c.reverse&&!n.every((e=>["@index","@set"].includes(e))))throw new ft("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});c["@container"]=n}if("@index"in i){if(!("@container"in i)||!c["@container"].includes("@index"))throw new ft(`Invalid JSON-LD syntax; @index without @index in @container: "${i["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});if(!yt(i["@index"])||0===i["@index"].indexOf("@"))throw new ft(`Invalid JSON-LD syntax; @index must expand to an IRI: "${i["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});c["@index"]=i["@index"]}if("@context"in i&&(c["@context"]=i["@context"]),"@language"in i&&!("@type"in i)){let e=i["@language"];if(null!==e&&!yt(e))throw new ft("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:t});null!==e&&(e=e.toLowerCase()),c["@language"]=e}if("@prefix"in i){if(n.match(/:|\//))throw new ft("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:t});if(Dt.isKeyword(c["@id"]))throw new ft("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:t});if("boolean"!=typeof i["@prefix"])throw new ft("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:t});c._prefix=!0===i["@prefix"]}if("@direction"in i){const e=i["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new ft('Invalid JSON-LD syntax; @direction value must be null, "ltr", or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",context:t});c["@direction"]=e}if("@nest"in i){const e=i["@nest"];if(!yt(e)||"@nest"!==e&&0===e.indexOf("@"))throw new ft("Invalid JSON-LD syntax; @context @nest value must be a string which is not a keyword other than @nest.","jsonld.SyntaxError",{code:"invalid @nest value",context:t});c["@nest"]=e}
|
|
26
|
-
// disallow aliasing @context and @preserve
|
|
27
|
-
const p=c["@id"];if("@context"===p||"@preserve"===p)throw new ft("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t});if(s&&s.protected&&!r&&(e.protected[n]=!0,c.protected=!0,!Lt(s,c)))throw new ft("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:t,term:n})},Dt.expandIri=(e,t,n,o)=>Ct(e,t,n,void 0,void 0,o),Dt.getInitialContext=e=>{const t=JSON.stringify({processingMode:e.processingMode}),n=Et.get(t);if(n)return n;const o={processingMode:e.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={},i=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],l=e.mappings,c=[...l.keys()].sort(Ot);for(const e of c){const a=l.get(e);if(null===a)continue;let c=a["@container"]||"@none";if(c=[].concat(c).sort().join(""),null===a["@id"])continue;const d=St(a["@id"]);for(const l of d){let d=t[l];const u=Dt.isKeyword(l);if(d)u||a._termHasColon||o[l].push(e);else if(t[l]=d={},!u&&!a._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],r(e,d["@any"],"@none"),a.reverse)r(e,d["@type"],"@reverse");else if("@none"===a["@type"])r(e,d["@any"],"@none"),r(e,d["@language"],"@none"),r(e,d["@type"],"@none");else if("@type"in a)r(e,d["@type"],a["@type"]);else if("@language"in a&&"@direction"in a){const t=a["@language"],n=a["@direction"];r(e,d["@language"],t&&n?`${t}_${n}`.toLowerCase():t?t.toLowerCase():n?`_${n}`:"@null")}else"@language"in a?r(e,d["@language"],(a["@language"]||"@null").toLowerCase()):"@direction"in a?a["@direction"]?r(e,d["@language"],`_${a["@direction"]}`):r(e,d["@language"],"@none"):s?(r(e,d["@language"],`_${s}`),r(e,d["@language"],"@none"),r(e,d["@type"],"@none")):(r(e,d["@language"],i),r(e,d["@language"],"@none"),r(e,d["@type"],"@none"))}}for(const e in n)a(n,e,1);return t},clone:function(){const e={};e.mappings=ht.clone(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,e.protected=ht.clone(this.protected),this.previousContext&&(e.previousContext=this.previousContext.clone());e.revertToPreviousContext=this.revertToPreviousContext,"@base"in this&&(e["@base"]=this["@base"]);"@language"in this&&(e["@language"]=this["@language"]);"@vocab"in this&&(e["@vocab"]=this["@vocab"]);return e},revertToPreviousContext:function(){if(!this.previousContext)return this;return this.previousContext.clone()},protected:{}};return 1e4===Et.size&&Et.clear(),Et.set(t,o),o;function a(e,t,n){const o=e[t],r=e[t]={};let i,s;for(const e of o)i=e.iri,s=n>=i.length?"":i[n],s in r?r[s].push(e):r[s]=[e];for(const e in r)""!==e&&a(r,e,n+1)}function r(e,t,n){t.hasOwnProperty(n)||(t[n]=e)}},Dt.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(mt(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},Dt.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,Dt.isKeyword=e=>{if(!yt(e)||"@"!==e[0])return!1;switch(e){case"@base":case"@container":case"@context":case"@default":case"@direction":case"@embed":case"@explicit":case"@graph":case"@id":case"@included":case"@index":case"@json":case"@language":case"@list":case"@nest":case"@none":case"@omitDefault":case"@prefix":case"@preserve":case"@protected":case"@requireAll":case"@reverse":case"@set":case"@type":case"@value":case"@version":case"@vocab":return!0}return!1};const Rt=z,{isArray:Tt,isObject:At,isEmptyObject:_t,isString:Mt,isUndefined:Jt}=F,{isList:Pt,isValue:Bt,isGraph:Ht,isSubject:Ft}=V,{expandIri:qt,getContextValue:Ut,isKeyword:Vt,process:zt,processingMode:Gt}=kt,{isAbsolute:$t}=ue(),{REGEX_BCP47:Qt,REGEX_KEYWORD:Xt,addValue:Wt,asArray:Kt,getValues:Zt,validateTypeValue:Yt}=te,{handleEvent:en}=dt,tn={};var nn=tn;function on({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,a;0===t?(o="empty object",a="Dropping empty object."):"@value"in e?(o="object with only @value",a="Dropping object with only @value."):"@list"in e?(o="object with only @list",a="Dropping object with only @list."):1===t&&"@id"in e&&(o="object with only @id",a="Dropping object with only @id."),en({event:{type:["JsonLdEvent"],code:o,level:"warning",message:a,details:{value:e}},options:n})}return null}return e}async function an({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:o,expandedParent:a,options:r={},insideList:i,typeKey:s,typeScopedContext:l}){const c=Object.keys(o).sort(),d=[];let u;const p=o[s]&&"@json"===qt(e,Tt(o[s])?o[s][0]:o[s],{vocab:!0},{...r,typeExpansion:!0});for(const i of c){let s,c=o[i];if("@context"===i)continue;const h=qt(e,i,{vocab:!0},r);if(null===h||!$t(h)&&!Vt(h)){r.eventHandler&&en({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:i,expandedProperty:h}},options:r});continue}if(Vt(h)){if("@reverse"===n)throw new Rt("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:c});if(h in a&&"@included"!==h&&"@type"!==h)throw new Rt("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:h})}if("@id"===h){if(!Mt(c)){if(!r.isFrame)throw new Rt('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:c});if(At(c)){if(!_t(c))throw new Rt('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:c})}else{if(!Tt(c))throw new Rt('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:c});if(!c.every((e=>Mt(e))))throw new Rt('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:c})}}Wt(a,"@id",Kt(c).map((t=>{if(Mt(t)){const n=qt(e,t,{base:!0},r);return r.eventHandler&&(null===n?en(null===t?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:t}},options:r}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:r}):$t(n)||en({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:t,expandedId:n}},options:r})),n}return t})),{propertyIsArray:r.isFrame});continue}if("@type"===h){At(c)&&(c=Object.fromEntries(Object.entries(c).map((([e,t])=>[qt(l,e,{vocab:!0}),Kt(t).map((e=>qt(l,e,{base:!0,vocab:!0},{...r,typeExpansion:!0})))])))),Yt(c,r.isFrame),Wt(a,"@type",Kt(c).map((e=>{if(Mt(e)){const t=qt(l,e,{base:!0,vocab:!0},{...r,typeExpansion:!0});return"@json"===t||$t(t)||r.eventHandler&&en({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:r}),t}return e})),{propertyIsArray:!!r.isFrame});continue}if("@included"===h&&Gt(e,1.1)){const n=Kt(await tn.expand({activeCtx:e,activeProperty:t,element:c,options:r}));if(!n.every((e=>Ft(e))))throw new Rt("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:c});Wt(a,"@included",n,{propertyIsArray:!0});continue}if("@graph"===h&&!At(c)&&!Tt(c))throw new Rt('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:c});if("@value"===h){u=c,p&&Gt(e,1.1)?a["@value"]=c:Wt(a,"@value",c,{propertyIsArray:r.isFrame});continue}if("@language"===h){if(null===c)continue;if(!Mt(c)&&!r.isFrame)throw new Rt('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:c});c=Kt(c).map((e=>Mt(e)?e.toLowerCase():e));for(const e of c)Mt(e)&&!e.match(Qt)&&r.eventHandler&&en({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:r});Wt(a,"@language",c,{propertyIsArray:r.isFrame});continue}if("@direction"===h){if(!Mt(c)&&!r.isFrame)throw new Rt('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:c});c=Kt(c);for(const e of c)if(Mt(e)&&"ltr"!==e&&"rtl"!==e)throw new Rt('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:c});Wt(a,"@direction",c,{propertyIsArray:r.isFrame});continue}if("@index"===h){if(!Mt(c))throw new Rt('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:c});Wt(a,"@index",c);continue}if("@reverse"===h){if(!At(c))throw new Rt('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:c});if(s=await tn.expand({activeCtx:e,activeProperty:"@reverse",element:c,options:r}),"@reverse"in s)for(const e in s["@reverse"])Wt(a,e,s["@reverse"][e],{propertyIsArray:!0});let t=a["@reverse"]||null;for(const e in s){if("@reverse"===e)continue;null===t&&(t=a["@reverse"]={}),Wt(t,e,[],{propertyIsArray:!0});const n=s[e];for(let o=0;o<n.length;++o){const a=n[o];if(Bt(a)||Pt(a))throw new Rt('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:s});Wt(t,e,a,{propertyIsArray:!0})}}continue}if("@nest"===h){d.push(i);continue}let f=e;const v=Ut(e,i,"@context");Jt(v)||(f=await zt({activeCtx:e,localCtx:v,propagate:!0,overrideProtected:!0,options:r}));const g=Ut(e,i,"@container")||[];if(g.includes("@language")&&At(c)){s=sn(f,c,Ut(f,i,"@direction"),r)}else if(g.includes("@index")&&At(c)){const t=g.includes("@graph"),n=Ut(f,i,"@index")||"@index",o="@index"!==n&&qt(e,n,{vocab:!0},r);s=await ln({activeCtx:f,options:r,activeProperty:i,value:c,asGraph:t,indexKey:n,propertyIndex:o})}else if(g.includes("@id")&&At(c)){const e=g.includes("@graph");s=await ln({activeCtx:f,options:r,activeProperty:i,value:c,asGraph:e,indexKey:"@id"})}else if(g.includes("@type")&&At(c))s=await ln({activeCtx:f.revertToPreviousContext(),options:r,activeProperty:i,value:c,asGraph:!1,indexKey:"@type"});else{const o="@list"===h;if(o||"@set"===h){let e=t;o&&"@graph"===n&&(e=null),s=await tn.expand({activeCtx:f,activeProperty:e,element:c,options:r,insideList:o})}else s="@json"===Ut(e,i,"@type")?{"@type":"@json","@value":c}:await tn.expand({activeCtx:f,activeProperty:i,element:c,options:r,insideList:!1})}if(null!==s||"@value"===h){if("@list"!==h&&!Pt(s)&&g.includes("@list")&&(s={"@list":Kt(s)}),g.includes("@graph")&&!g.some((e=>"@id"===e||"@index"===e))){if(s=Kt(s),r.isFrame||(s=s.filter((e=>null!==on({value:e,count:Object.keys(e).length,options:r})))),0===s.length)continue;s=s.map((e=>({"@graph":Kt(e)})))}if(f.mappings.has(i)&&f.mappings.get(i).reverse){const e=a["@reverse"]=a["@reverse"]||{};s=Kt(s);for(let t=0;t<s.length;++t){const n=s[t];if(Bt(n)||Pt(n))throw new Rt('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:s});Wt(e,h,n,{propertyIsArray:!0})}}else Wt(a,h,s,{propertyIsArray:!0})}}if("@value"in a)if("@json"===a["@type"]&&Gt(e,1.1));else if((At(u)||Tt(u))&&!r.isFrame)throw new Rt('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:u});for(const c of d){const d=Tt(o[c])?o[c]:[o[c]];for(const o of d){if(!At(o)||Object.keys(o).some((t=>"@value"===qt(e,t,{vocab:!0},r))))throw new Rt("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:o});await an({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:o,expandedParent:a,options:r,insideList:i,typeScopedContext:l,typeKey:s})}}}function rn({activeCtx:e,activeProperty:t,value:n,options:o}){if(null==n)return null;const a=qt(e,t,{vocab:!0},o);if("@id"===a)return qt(e,n,{base:!0},o);if("@type"===a)return qt(e,n,{vocab:!0,base:!0},{...o,typeExpansion:!0});const r=Ut(e,t,"@type");if(("@id"===r||"@graph"===a)&&Mt(n)){const a=qt(e,n,{base:!0},o);return null===a&&n.match(Xt)&&o.eventHandler&&en({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}),{"@id":a}}if("@vocab"===r&&Mt(n))return{"@id":qt(e,n,{vocab:!0,base:!0},o)};if(Vt(a))return n;const i={};if(r&&!["@id","@vocab","@none"].includes(r))i["@type"]=r;else if(Mt(n)){const n=Ut(e,t,"@language");null!==n&&(i["@language"]=n);const o=Ut(e,t,"@direction");null!==o&&(i["@direction"]=o)}return["boolean","number","string"].includes(typeof n)||(n=n.toString()),i["@value"]=n,i}function sn(e,t,n,o){const a=[],r=Object.keys(t).sort();for(const i of r){const r=qt(e,i,{vocab:!0},o);let s=t[i];Tt(s)||(s=[s]);for(const e of s){if(null===e)continue;if(!Mt(e))throw new Rt("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:t});const s={"@value":e};"@none"!==r&&(i.match(Qt)||o.eventHandler&&en({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:i}},options:o}),s["@language"]=i.toLowerCase()),n&&(s["@direction"]=n),a.push(s)}}return a}async function ln({activeCtx:e,options:t,activeProperty:n,value:o,asGraph:a,indexKey:r,propertyIndex:i}){const s=[],l=Object.keys(o).sort(),c="@type"===r;for(let d of l){if(c){const n=Ut(e,d,"@context");Jt(n)||(e=await zt({activeCtx:e,localCtx:n,propagate:!1,options:t}))}let l,u=o[d];Tt(u)||(u=[u]),u=await tn.expand({activeCtx:e,activeProperty:n,element:u,options:t,insideList:!1,insideIndex:!0}),l=i?"@none"===d?"@none":rn({activeCtx:e,activeProperty:r,value:d,options:t}):qt(e,d,{vocab:!0},t),"@id"===r?d=qt(e,d,{base:!0},t):c&&(d=l);for(let e of u){if(a&&!Ht(e)&&(e={"@graph":[e]}),"@type"===r)"@none"===l||(e["@type"]?e["@type"]=[d].concat(e["@type"]):e["@type"]=[d]);else{if(Bt(e)&&!["@language","@type","@index"].includes(r))throw new Rt(`Invalid JSON-LD syntax; Attempt to add illegal key to value object: "${r}".`,"jsonld.SyntaxError",{code:"invalid value object",value:e});i?"@none"!==l&&Wt(e,i,l,{propertyIsArray:!0,prependValue:!0}):"@none"===l||r in e||(e[r]=d)}s.push(e)}}return s}tn.expand=async({activeCtx:e,activeProperty:t=null,element:n,options:o={},insideList:a=!1,insideIndex:r=!1,typeScopedContext:i=null})=>{if(null==n)return null;if("@default"===t&&(o=Object.assign({},o,{isFrame:!1})),!Tt(n)&&!At(n))return a||null!==t&&"@graph"!==qt(e,t,{vocab:!0},o)?rn({activeCtx:e,activeProperty:t,value:n,options:o}):(o.eventHandler&&en({event:{type:["JsonLdEvent"],code:"free-floating scalar",level:"warning",message:"Dropping free-floating scalar not in a list.",details:{value:n}},options:o}),null);if(Tt(n)){let s=[];const l=Ut(e,t,"@container")||[];a=a||l.includes("@list");for(let l=0;l<n.length;++l){let c=await tn.expand({activeCtx:e,activeProperty:t,element:n[l],options:o,insideIndex:r,typeScopedContext:i});a&&Tt(c)&&(c={"@list":c}),null!==c&&(Tt(c)?s=s.concat(c):s.push(c))}return s}const s=qt(e,t,{vocab:!0},o),l=Ut(e,t,"@context");i=i||(e.previousContext?e:null);let c=Object.keys(n).sort(),d=!r;if(d&&i&&c.length<=2&&!c.includes("@context"))for(const t of c){const n=qt(i,t,{vocab:!0},o);if("@value"===n){d=!1,e=i;break}if("@id"===n&&1===c.length){d=!1;break}}d&&(e=e.revertToPreviousContext()),Jt(l)||(e=await zt({activeCtx:e,localCtx:l,propagate:!0,overrideProtected:!0,options:o})),"@context"in n&&(e=await zt({activeCtx:e,localCtx:n["@context"],options:o})),i=e;let u=null;for(const t of c){if("@type"===qt(e,t,{vocab:!0},o)){u=u||t;const a=n[t],r=Array.isArray(a)?a.length>1?a.slice().sort():a:[a];for(const t of r){const n=Ut(i,t,"@context");Jt(n)||(e=await zt({activeCtx:e,localCtx:n,options:o,propagate:!1}))}}}let p={};await an({activeCtx:e,activeProperty:t,expandedActiveProperty:s,element:n,expandedParent:p,options:o,insideList:a,typeKey:u,typeScopedContext:i}),c=Object.keys(p);let h=c.length;if("@value"in p){if("@type"in p&&("@language"in p||"@direction"in p))throw new Rt('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and either "@language" or "@direction".',"jsonld.SyntaxError",{code:"invalid value object",element:p});let t=h-1;if("@type"in p&&(t-=1),"@index"in p&&(t-=1),"@language"in p&&(t-=1),"@direction"in p&&(t-=1),0!==t)throw new Rt('Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and either "@type" or either or both "@language" or "@direction".',"jsonld.SyntaxError",{code:"invalid value object",element:p});const n=null===p["@value"]?[]:Kt(p["@value"]),a=Zt(p,"@type");if(Gt(e,1.1)&&a.includes("@json")&&1===a.length);else if(0===n.length)o.eventHandler&&en({event:{type:["JsonLdEvent"],code:"null @value value",level:"warning",message:"Dropping null @value value.",details:{value:p}},options:o}),p=null;else{if(!n.every((e=>Mt(e)||_t(e)))&&"@language"in p)throw new Rt("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:p});if(!a.every((e=>$t(e)&&!(Mt(e)&&0===e.indexOf("_:"))||_t(e))))throw new Rt('Invalid JSON-LD syntax; an element containing "@value" and "@type" must have an absolute IRI for the value of "@type".',"jsonld.SyntaxError",{code:"invalid typed value",element:p})}}else if("@type"in p&&!Tt(p["@type"]))p["@type"]=[p["@type"]];else if("@set"in p||"@list"in p){if(h>1&&(2!==h||!("@index"in p)))throw new Rt('Invalid JSON-LD syntax; if an element has the property "@set" or "@list", then it can have at most one other property that is "@index".',"jsonld.SyntaxError",{code:"invalid set or list object",element:p});"@set"in p&&(p=p["@set"],c=Object.keys(p),h=c.length)}else 1===h&&"@language"in p&&(o.eventHandler&&en({event:{type:["JsonLdEvent"],code:"object with only @language",level:"warning",message:"Dropping object with only @language.",details:{value:p}},options:o}),p=null);return!At(p)||o.keepFreeFloatingNodes||a||null!==t&&"@graph"!==s&&!(Ut(e,t,"@container")||[]).includes("@graph")||(p=on({value:p,count:h,options:o})),p};const{isKeyword:cn}=kt,dn=V,un=F,pn=te,hn=z,fn={};var vn=fn;fn.createMergedNodeMap=(e,t)=>{const n=(t=t||{}).issuer||new pn.IdentifierIssuer("_:b"),o={"@default":{}};return fn.createNodeMap(e,o,"@default",n),fn.mergeNodeMaps(o)},fn.createNodeMap=(e,t,n,o,a,r)=>{if(un.isArray(e)){for(const a of e)fn.createNodeMap(a,t,n,o,void 0,r);return}if(!un.isObject(e))return void(r&&r.push(e));if(dn.isValue(e)){if("@type"in e){let t=e["@type"];0===t.indexOf("_:")&&(e["@type"]=t=o.getId(t))}return void(r&&r.push(e))}if(r&&dn.isList(e)){const i=[];return fn.createNodeMap(e["@list"],t,n,o,a,i),void r.push({"@list":i})}if("@type"in e){const t=e["@type"];for(const e of t)0===e.indexOf("_:")&&o.getId(e)}un.isUndefined(a)&&(a=dn.isBlankNode(e)?o.getId(e["@id"]):e["@id"]),r&&r.push({"@id":a});const i=t[n],s=i[a]=i[a]||{};s["@id"]=a;const l=Object.keys(e).sort();for(let r of l){if("@id"===r)continue;if("@reverse"===r){const r={"@id":a},s=e["@reverse"];for(const e in s){const a=s[e];for(const s of a){let a=s["@id"];dn.isBlankNode(s)&&(a=o.getId(a)),fn.createNodeMap(s,t,n,o,a),pn.addValue(i[a],e,r,{propertyIsArray:!0,allowDuplicate:!1})}}continue}if("@graph"===r){a in t||(t[a]={}),fn.createNodeMap(e[r],t,a,o);continue}if("@included"===r){fn.createNodeMap(e[r],t,n,o);continue}if("@type"!==r&&cn(r)){if("@index"===r&&r in s&&(e[r]!==s[r]||e[r]["@id"]!==s[r]["@id"]))throw new hn("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:s});s[r]=e[r];continue}const l=e[r];if(0===r.indexOf("_:")&&(r=o.getId(r)),0!==l.length)for(let e of l)if("@type"===r&&(e=0===e.indexOf("_:")?o.getId(e):e),dn.isSubject(e)||dn.isSubjectReference(e)){if("@id"in e&&!e["@id"])continue;const a=dn.isBlankNode(e)?o.getId(e["@id"]):e["@id"];pn.addValue(s,r,{"@id":a},{propertyIsArray:!0,allowDuplicate:!1}),fn.createNodeMap(e,t,n,o,a)}else if(dn.isValue(e))pn.addValue(s,r,e,{propertyIsArray:!0,allowDuplicate:!1});else if(dn.isList(e)){const i=[];fn.createNodeMap(e["@list"],t,n,o,a,i),e={"@list":i},pn.addValue(s,r,e,{propertyIsArray:!0,allowDuplicate:!1})}else fn.createNodeMap(e,t,n,o,a),pn.addValue(s,r,e,{propertyIsArray:!0,allowDuplicate:!1});else pn.addValue(s,r,[],{propertyIsArray:!0})}},fn.mergeNodeMapGraphs=e=>{const t={};for(const n of Object.keys(e).sort())for(const o of Object.keys(e[n]).sort()){const a=e[n][o];o in t||(t[o]={"@id":o});const r=t[o];for(const e of Object.keys(a).sort())if(cn(e)&&"@type"!==e)r[e]=pn.clone(a[e]);else for(const t of a[e])pn.addValue(r,e,pn.clone(t),{propertyIsArray:!0,allowDuplicate:!1})}return t},fn.mergeNodeMaps=e=>{const t=e["@default"],n=Object.keys(e).sort();for(const o of n){if("@default"===o)continue;const n=e[o];let a=t[o];a?"@graph"in a||(a["@graph"]=[]):t[o]=a={"@id":o,"@graph":[]};const r=a["@graph"];for(const e of Object.keys(n).sort()){const t=n[e];dn.isSubjectReference(t)||r.push(t)}}return t};const{isSubjectReference:gn}=V,{createMergedNodeMap:yn}=vn,mn={};var xn=mn;mn.flatten=e=>{const t=yn(e),n=[],o=Object.keys(t).sort();for(let e=0;e<o.length;++e){const a=t[o[e]];gn(a)||n.push(a)}return n};const bn=z,wn=V,jn=F,{REGEX_BCP47:In,addValue:Nn}=te,{handleEvent:Sn}=dt,{RDF_LIST:On,RDF_FIRST:En,RDF_REST:Dn,RDF_NIL:kn,RDF_TYPE:Cn,RDF_JSON_LITERAL:Ln,XSD_BOOLEAN:Rn,XSD_DOUBLE:Tn,XSD_INTEGER:An,XSD_STRING:_n}=ce,Mn={};var Jn=Mn;function Pn(e,t,n,o){if(e.termType.endsWith("Node"))return{"@id":e.value};const a={"@value":e.value};if(e.language)e.language.match(In)||o.eventHandler&&Sn({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e.language}},options:o}),a["@language"]=e.language;else{let r=e.datatype.value;if(r||(r=_n),r===Ln){r="@json";try{a["@value"]=JSON.parse(a["@value"])}catch(e){throw new bn("JSON literal could not be parsed.","jsonld.InvalidJsonLiteral",{code:"invalid JSON literal",value:a["@value"],cause:e})}}if(t){if(r===Rn)"true"===a["@value"]?a["@value"]=!0:"false"===a["@value"]&&(a["@value"]=!1);else if(jn.isNumeric(a["@value"]))if(r===An){const e=parseInt(a["@value"],10);e.toFixed(0)===a["@value"]&&(a["@value"]=e)}else r===Tn&&(a["@value"]=parseFloat(a["@value"]));[Rn,An,Tn,_n].includes(r)||(a["@type"]=r)}else if("i18n-datatype"===n&&r.startsWith("https://www.w3.org/ns/i18n#")){const[,e,t]=r.split(/[#_]/);e.length>0&&(a["@language"]=e,e.match(In)||o.eventHandler&&Sn({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:o})),a["@direction"]=t}else r!==_n&&(a["@type"]=r)}return a}Mn.fromRDF=async(e,t)=>{const{useRdfType:n=!1,useNativeTypes:o=!1,rdfDirection:a=null}=t,r={},i={"@default":r},s={};if(a){if("compound-literal"===a)throw new bn("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:a});if("i18n-datatype"!==a)throw new bn("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:a})}for(const l of e){const e="DefaultGraph"===l.graph.termType?"@default":l.graph.value;e in i||(i[e]={}),"@default"===e||e in r||(r[e]={"@id":e});const c=i[e],d=l.subject.value,u=l.predicate.value,p=l.object;d in c||(c[d]={"@id":d});const h=c[d],f=p.termType.endsWith("Node");if(f&&!(p.value in c)&&(c[p.value]={"@id":p.value}),u===Cn&&!n&&f){Nn(h,"@type",p.value,{propertyIsArray:!0});continue}const v=Pn(p,o,a,t);if(Nn(h,u,v,{propertyIsArray:!0}),f)if(p.value===kn){const e=c[p.value];"usages"in e||(e.usages=[]),e.usages.push({node:h,property:u,value:v})}else p.value in s?s[p.value]=!1:s[p.value]={node:h,property:u,value:v}}for(const e in i){const t=i[e];if(!(kn in t))continue;const n=t[kn];if(n.usages){for(let e of n.usages){let n=e.node,o=e.property,a=e.value;const r=[],i=[];let l=Object.keys(n).length;for(;o===Dn&&jn.isObject(s[n["@id"]])&&jn.isArray(n[En])&&1===n[En].length&&jn.isArray(n[Dn])&&1===n[Dn].length&&(3===l||4===l&&jn.isArray(n["@type"])&&1===n["@type"].length&&n["@type"][0]===On)&&(r.push(n[En][0]),i.push(n["@id"]),e=s[n["@id"]],n=e.node,o=e.property,a=e.value,l=Object.keys(n).length,wn.isBlankNode(n)););delete a["@id"],a["@list"]=r.reverse();for(const e of i)delete t[e]}delete n.usages}}const l=[],c=Object.keys(r).sort();for(const e of c){const t=r[e];if(e in i){const n=t["@graph"]=[],o=i[e],a=Object.keys(o).sort();for(const e of a){const t=o[e];wn.isSubjectReference(t)||n.push(t)}}wn.isSubjectReference(t)||l.push(t)}return l};const{createNodeMap:Bn}=vn,{isKeyword:Hn}=kt,Fn=V,qn=function e(t){return null===t||"object"!=typeof t||null!=t.toJSON?JSON.stringify(t):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,a)=>{if(void 0===t[o]||"symbol"==typeof t[o])return n;return n+(0===n.length?"":",")+e(o)+":"+e(t[o])}),"")+"}"},Un=z,Vn=F,zn=te,{handleEvent:Gn}=dt,{RDF_FIRST:$n,RDF_REST:Qn,RDF_NIL:Xn,RDF_TYPE:Wn,RDF_JSON_LITERAL:Kn,RDF_LANGSTRING:Zn,XSD_BOOLEAN:Yn,XSD_DOUBLE:eo,XSD_INTEGER:to,XSD_STRING:no}=ce,{isAbsolute:oo}=ue(),ao={};var ro=ao;function io(e,t,n,o,a){const r=Object.keys(t).sort();for(const i of r){const r=t[i],s=Object.keys(r).sort();for(let t of s){const s=r[t];if("@type"===t)t=Wn;else if(Hn(t))continue;for(const r of s){const s={termType:i.startsWith("_:")?"BlankNode":"NamedNode",value:i};if(!oo(i)){a.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"relative subject reference",level:"warning",message:"Relative subject reference found.",details:{subject:i}},options:a});continue}const l={termType:t.startsWith("_:")?"BlankNode":"NamedNode",value:t};if(!oo(t)){a.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"relative predicate reference",level:"warning",message:"Relative predicate reference found.",details:{predicate:t}},options:a});continue}if("BlankNode"===l.termType&&!a.produceGeneralizedRdf){a.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"blank node predicate",level:"warning",message:"Dropping blank node predicate.",details:{property:o.getOldIds().find((e=>o.getId(e)===t))}},options:a});continue}const c=so(r,o,e,n,a.rdfDirection,a);c&&e.push({subject:s,predicate:l,object:c,graph:n})}}}}function so(e,t,n,o,a,r){const i={};if(Fn.isValue(e)){i.termType="Literal",i.value=void 0,i.datatype={termType:"NamedNode"};let t=e["@value"];const n=e["@type"]||null;if("@json"===n)i.value=qn(t),i.datatype.value=Kn;else if(Vn.isBoolean(t))i.value=t.toString(),i.datatype.value=n||Yn;else if(Vn.isDouble(t)||n===eo)Vn.isDouble(t)||(t=parseFloat(t)),i.value=t.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),i.datatype.value=n||eo;else if(Vn.isNumber(t))i.value=t.toFixed(0),i.datatype.value=n||to;else if("@direction"in e&&"i18n-datatype"===a){const n=`https://www.w3.org/ns/i18n#${(e["@language"]||"").toLowerCase()}_${e["@direction"]}`;i.datatype.value=n,i.value=t}else{if("@direction"in e&&"compound-literal"===a)throw new Un("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:a});if("@direction"in e&&a)throw new Un("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:a});"@language"in e?("@direction"in e&&!a&&r.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:i.value}},options:r}),i.value=t,i.datatype.value=n||Zn,i.language=e["@language"]):("@direction"in e&&!a&&r.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:i.value}},options:r}),i.value=t,i.datatype.value=n||no)}}else if(Fn.isList(e)){const s=function(e,t,n,o,a,r){const i={termType:"NamedNode",value:$n},s={termType:"NamedNode",value:Qn},l={termType:"NamedNode",value:Xn},c=e.pop(),d=c?{termType:"BlankNode",value:t.getId()}:l;let u=d;for(const l of e){const e=so(l,t,n,o,a,r),c={termType:"BlankNode",value:t.getId()};n.push({subject:u,predicate:i,object:e,graph:o}),n.push({subject:u,predicate:s,object:c,graph:o}),u=c}if(c){const e=so(c,t,n,o,a,r);n.push({subject:u,predicate:i,object:e,graph:o}),n.push({subject:u,predicate:s,object:l,graph:o})}return d}(e["@list"],t,n,o,a,r);i.termType=s.termType,i.value=s.value}else{const t=Vn.isObject(e)?e["@id"]:e;i.termType=t.startsWith("_:")?"BlankNode":"NamedNode",i.value=t}return"NamedNode"!==i.termType||oo(i.value)?i:(r.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"relative object reference",level:"warning",message:"Relative object reference found.",details:{object:i.value}},options:r}),null)}ao.toRDF=(e,t)=>{const n=new zn.IdentifierIssuer("_:b"),o={"@default":{}};Bn(e,o,"@default",n);const a=[],r=Object.keys(o).sort();for(const e of r){let r;if("@default"===e)r={termType:"DefaultGraph",value:""};else{if(!oo(e)){t.eventHandler&&Gn({event:{type:["JsonLdEvent"],code:"relative graph reference",level:"warning",message:"Relative graph reference found.",details:{graph:e}},options:t});continue}r=e.startsWith("_:")?{termType:"BlankNode"}:{termType:"NamedNode"},r.value=e}io(a,o[e],r,n,t)}return a};const{isKeyword:lo}=kt,co=V,uo=F,po=te,ho=ue(),fo=z,{createNodeMap:vo,mergeNodeMapGraphs:go}=vn,yo={};var mo=yo;function xo(e){const t={};for(const n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function bo(e,t,n){for(let o=n.length-1;o>=0;--o){const a=n[o];if(a.graph===t&&a.subject["@id"]===e["@id"])return!0}return!1}function wo(e,t,n){const o="@"+n;let a=o in e?e[o][0]:t[n];if("embed"===n)if(!0===a)a="@once";else if(!1===a)a="@never";else if("@always"!==a&&"@never"!==a&&"@link"!==a&&"@first"!==a&&"@last"!==a&&"@once"!==a)throw new fo("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:e});return a}function jo(e){if(!uo.isArray(e)||1!==e.length||!uo.isObject(e[0]))throw new fo("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 po.asArray(e[0]["@id"]))if(!uo.isObject(t)&&!ho.isAbsolute(t)||uo.isString(t)&&0===t.indexOf("_:"))throw new fo("Invalid JSON-LD syntax; invalid @id in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e});if("@type"in e[0])for(const t of po.asArray(e[0]["@type"]))if(!uo.isObject(t)&&!ho.isAbsolute(t)&&"@json"!==t||uo.isString(t)&&0===t.indexOf("_:"))throw new fo("Invalid JSON-LD syntax; invalid @type in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e})}function Io(e,t,n,o){let a=!0,r=!1;for(const i in n){let s=!1;const l=po.getValues(t,i),c=0===po.getValues(n,i).length;if("@id"===i){if(uo.isEmptyObject(n["@id"][0]||{})?s=!0:n["@id"].length>=0&&(s=n["@id"].includes(l[0])),!o.requireAll)return s}else if("@type"===i){if(a=!1,c){if(l.length>0)return!1;s=!0}else if(1===n["@type"].length&&uo.isEmptyObject(n["@type"][0]))s=l.length>0;else for(const e of n["@type"])s=!(!uo.isObject(e)||!("@default"in e))||(s||l.some((t=>t===e)));if(!o.requireAll)return s}else{if(lo(i))continue;{const t=po.getValues(n,i)[0];let r=!1;if(t&&(jo([t]),r="@default"in t),a=!1,0===l.length&&r)continue;if(l.length>0&&c)return!1;if(void 0===t){if(l.length>0)return!1;s=!0}else if(co.isList(t)){const n=t["@list"][0];if(co.isList(l[0])){const t=l[0]["@list"];co.isValue(n)?s=t.some((e=>Do(n,e))):(co.isSubject(n)||co.isSubjectReference(n))&&(s=t.some((t=>Eo(e,n,t,o))))}}else s=co.isValue(t)?l.some((e=>Do(t,e))):co.isSubjectReference(t)?l.some((n=>Eo(e,t,n,o))):!!uo.isObject(t)&&l.length>0}}if(!s&&o.requireAll)return!1;r=r||s}return a||r}function No(e,t){const n=e.uniqueEmbeds[e.graph],o=n[t],a=o.parent,r=o.property,i={"@id":t};if(uo.isArray(a)){for(let e=0;e<a.length;++e)if(po.compareValues(a[e],i)){a[e]=i;break}}else{const e=uo.isArray(a[r]);po.removeValue(a,r,i,{propertyIsArray:e}),po.addValue(a,r,i,{propertyIsArray:e})}const s=e=>{const t=Object.keys(n);for(const o of t)o in n&&uo.isObject(n[o].parent)&&n[o].parent["@id"]===e&&(delete n[o],s(o))};s(t)}
|
|
28
|
-
/**
|
|
29
|
-
* Removes the @preserve keywords from expanded result of framing.
|
|
30
|
-
*
|
|
31
|
-
* @param input the framed, framed output.
|
|
32
|
-
* @param options the framing options used.
|
|
33
|
-
*
|
|
34
|
-
* @return the resulting output.
|
|
35
|
-
*/function So(e,t){if(uo.isArray(e))return e.map((e=>So(e,t)));if(uo.isObject(e)){
|
|
36
|
-
// remove @preserve
|
|
37
|
-
if("@preserve"in e)return e["@preserve"][0];if(co.isValue(e))return e;if(co.isList(e))return e["@list"]=So(e["@list"],t),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)"@id"===n&&t.bnodesToClear.includes(e[n])?delete e["@id"]:e[n]=So(e[n],t)}return e}function Oo(e,t,n){uo.isObject(e)?po.addValue(e,t,n,{propertyIsArray:!0}):e.push(n)}function Eo(e,t,n,o){if(!("@id"in n))return!1;const a=e.subjects[n["@id"]];return a&&Io(e,a,t,o)}function Do(e,t){const n=t["@value"],o=t["@type"],a=t["@language"],r=e["@value"]?uo.isArray(e["@value"])?e["@value"]:[e["@value"]]:[],i=e["@type"]?uo.isArray(e["@type"])?e["@type"]:[e["@type"]]:[],s=e["@language"]?uo.isArray(e["@language"])?e["@language"]:[e["@language"]]:[];return 0===r.length&&0===i.length&&0===s.length||!(!r.includes(n)&&!uo.isEmptyObject(r[0]))&&(!!(!o&&0===i.length||i.includes(o)||o&&uo.isEmptyObject(i[0]))&&!!(!a&&0===s.length||s.includes(a)||a&&uo.isEmptyObject(s[0])))}yo.frameMergedOrDefault=(e,t,n)=>{const o={options:n,embedded:!1,graph:"@default",graphMap:{"@default":{}},subjectStack:[],link:{},bnodeMap:{}},a=new po.IdentifierIssuer("_:b");vo(e,o.graphMap,"@default",a),n.merged&&(o.graphMap["@merged"]=go(o.graphMap),o.graph="@merged"),o.subjects=o.graphMap[o.graph];const r=[];return yo.frame(o,Object.keys(o.subjects).sort(),t,r),n.pruneBlankNodeIdentifiers&&(n.bnodesToClear=Object.keys(o.bnodeMap).filter((e=>1===o.bnodeMap[e].length))),
|
|
38
|
-
// remove @preserve from results
|
|
39
|
-
n.link={},So(r,n)},yo.frame=(e,t,n,o,a=null)=>{jo(n),n=n[0];const r=e.options,i={embed:wo(n,r,"embed"),explicit:wo(n,r,"explicit"),requireAll:wo(n,r,"requireAll")};e.link.hasOwnProperty(e.graph)||(e.link[e.graph]={});const s=e.link[e.graph],l=function(e,t,n,o){const a={};for(const r of t){const t=e.graphMap[e.graph][r];Io(e,t,n,o)&&(a[r]=t)}return a}(e,t,n,i),c=Object.keys(l).sort();for(const d of c){const c=l[d];if(null===a?e.uniqueEmbeds={[e.graph]:{}}:e.uniqueEmbeds[e.graph]=e.uniqueEmbeds[e.graph]||{},"@link"===i.embed&&d in s){Oo(o,a,s[d]);continue}const u={"@id":d};if(0===d.indexOf("_:")&&po.addValue(e.bnodeMap,d,u,{propertyIsArray:!0}),s[d]=u,("@first"===i.embed||"@last"===i.embed)&&e.is11)throw new fo("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:n});if(e.embedded||!e.uniqueEmbeds[e.graph].hasOwnProperty(d))if(!e.embedded||"@never"!==i.embed&&!bo(c,e.graph,e.subjectStack))if(!e.embedded||"@first"!=i.embed&&"@once"!=i.embed||!e.uniqueEmbeds[e.graph].hasOwnProperty(d)){if("@last"===i.embed&&d in e.uniqueEmbeds[e.graph]&&No(e,d),e.uniqueEmbeds[e.graph][d]={parent:o,property:a},e.subjectStack.push({subject:c,graph:e.graph}),d in e.graphMap){let t=!1,o=null;"@graph"in n?(o=n["@graph"][0],t=!("@merged"===d||"@default"===d),uo.isObject(o)||(o={})):(t="@merged"!==e.graph,o={}),t&&yo.frame({...e,graph:d,embedded:!1},Object.keys(e.graphMap[d]).sort(),[o],u,"@graph")}"@included"in n&&yo.frame({...e,embedded:!1},t,n["@included"],u,"@included");for(const t of Object.keys(c).sort())if(lo(t)){if(u[t]=po.clone(c[t]),"@type"===t)for(const t of c["@type"])0===t.indexOf("_:")&&po.addValue(e.bnodeMap,t,u,{propertyIsArray:!0})}else if(!i.explicit||t in n)for(const o of c[t]){const a=t in n?n[t]:xo(i);if(co.isList(o)){const a=n[t]&&n[t][0]&&n[t][0]["@list"]?n[t][0]["@list"]:xo(i),r={"@list":[]};Oo(u,t,r);const s=o["@list"];for(const t of s)co.isSubjectReference(t)?yo.frame({...e,embedded:!0},[t["@id"]],a,r,"@list"):Oo(r,"@list",po.clone(t))}else co.isSubjectReference(o)?yo.frame({...e,embedded:!0},[o["@id"]],a,u,t):Do(a[0],o)&&Oo(u,t,po.clone(o))}for(const e of Object.keys(n).sort()){if("@type"===e){if(!uo.isObject(n[e][0])||!("@default"in n[e][0]))continue}else if(lo(e))continue;const t=n[e][0]||{};if(!wo(t,r,"omitDefault")&&!(e in u)){let n="@null";"@default"in t&&(n=po.clone(t["@default"])),uo.isArray(n)||(n=[n]),u[e]=[{"@preserve":n}]}}for(const t of Object.keys(n["@reverse"]||{}).sort()){const o=n["@reverse"][t];for(const n of Object.keys(e.subjects)){po.getValues(e.subjects[n],t).some((e=>e["@id"]===d))&&(u["@reverse"]=u["@reverse"]||{},po.addValue(u["@reverse"],t,[],{propertyIsArray:!0}),yo.frame({...e,embedded:!0},[n],o,u["@reverse"][t],a))}}Oo(o,a,u),e.subjectStack.pop()}else Oo(o,a,u);else Oo(o,a,u)}},yo.cleanupNull=(e,t)=>{if(uo.isArray(e)){return e.map((e=>yo.cleanupNull(e,t))).filter((e=>e))}if("@null"===e)return null;if(uo.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]=yo.cleanupNull(e[n],t)}return e};const ko=z,{isArray:Co,isObject:Lo,isString:Ro,isUndefined:To}=F,{isList:Ao,isValue:_o,isGraph:Mo,isSimpleGraph:Jo,isSubjectReference:Po}=V,{expandIri:Bo,getContextValue:Ho,isKeyword:Fo,process:qo,processingMode:Uo}=kt,{removeBase:Vo,prependBase:zo}=ue(),{REGEX_KEYWORD:Go,addValue:$o,asArray:Qo,compareShortestLeast:Xo}=te,Wo={};var Ko,Zo,Yo=Wo;function ea(e,t,n){if("@nest"!==Bo(e,t,{vocab:!0},n))throw new ko("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}Wo.compact=async({activeCtx:e,activeProperty:t=null,element:n,options:o={}})=>{if(Co(n)){let a=[];for(let r=0;r<n.length;++r){const i=await Wo.compact({activeCtx:e,activeProperty:t,element:n[r],options:o});null!==i&&a.push(i)}if(o.compactArrays&&1===a.length){0===(Ho(e,t,"@container")||[]).length&&(a=a[0])}return a}const a=Ho(e,t,"@context");if(To(a)||(e=await qo({activeCtx:e,localCtx:a,propagate:!0,overrideProtected:!0,options:o})),Lo(n)){if(o.link&&"@id"in n&&o.link.hasOwnProperty(n["@id"])){const e=o.link[n["@id"]];for(let t=0;t<e.length;++t)if(e[t].expanded===n)return e[t].compacted}if(_o(n)||Po(n)){const a=Wo.compactValue({activeCtx:e,activeProperty:t,value:n,options:o});return o.link&&Po(n)&&(o.link.hasOwnProperty(n["@id"])||(o.link[n["@id"]]=[]),o.link[n["@id"]].push({expanded:n,compacted:a})),a}if(Ao(n)){if((Ho(e,t,"@container")||[]).includes("@list"))return Wo.compact({activeCtx:e,activeProperty:t,element:n["@list"],options:o})}const a="@reverse"===t,r={},i=e;_o(n)||Po(n)||(e=e.revertToPreviousContext());const s=Ho(i,t,"@context");To(s)||(e=await qo({activeCtx:e,localCtx:s,propagate:!0,overrideProtected:!0,options:o})),o.link&&"@id"in n&&(o.link.hasOwnProperty(n["@id"])||(o.link[n["@id"]]=[]),o.link[n["@id"]].push({expanded:n,compacted:r}));let l=n["@type"]||[];l.length>1&&(l=Array.from(l).sort());const c=e;for(const t of l){const n=Wo.compactIri({activeCtx:c,iri:t,relativeTo:{vocab:!0}}),a=Ho(i,n,"@context");To(a)||(e=await qo({activeCtx:e,localCtx:a,options:o,propagate:!1}))}const d=Object.keys(n).sort();for(const s of d){const l=n[s];if("@id"!==s)if("@type"!==s)if("@reverse"!==s)if("@preserve"!==s)if("@index"!==s)if("@graph"!==s&&"@list"!==s&&"@included"!==s&&Fo(s)){const t=Wo.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});$o(r,t,l)}else{if(!Co(l))throw new ko("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===l.length){const t=Wo.compactIri({activeCtx:e,iri:s,value:l,relativeTo:{vocab:!0},reverse:a}),n=e.mappings.has(t)?e.mappings.get(t)["@nest"]:null;let i=r;n&&(ea(e,n,o),Lo(r[n])||(r[n]={}),i=r[n]),$o(i,t,l,{propertyIsArray:!0})}for(const t of l){const n=Wo.compactIri({activeCtx:e,iri:s,value:t,relativeTo:{vocab:!0},reverse:a}),i=e.mappings.has(n)?e.mappings.get(n)["@nest"]:null;let l=r;i&&(ea(e,i,o),Lo(r[i])||(r[i]={}),l=r[i]);const c=Ho(e,n,"@container")||[],d=Mo(t),u=Ao(t);let p;u?p=t["@list"]:d&&(p=t["@graph"]);let h=await Wo.compact({activeCtx:e,activeProperty:n,element:u||d?p:t,options:o});if(u){if(Co(h)||(h=[h]),c.includes("@list")){$o(l,n,h,{valueIsArray:!0,allowDuplicate:!0});continue}h={[Wo.compactIri({activeCtx:e,iri:"@list",relativeTo:{vocab:!0}})]:h},"@index"in t&&(h[Wo.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"])}if(d)if(c.includes("@graph")&&(c.includes("@id")||c.includes("@index")&&Jo(t))){let a;l.hasOwnProperty(n)?a=l[n]:l[n]=a={};const r=(c.includes("@id")?t["@id"]:t["@index"])||Wo.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}});$o(a,r,h,{propertyIsArray:!o.compactArrays||c.includes("@set")})}else c.includes("@graph")&&Jo(t)?(Co(h)&&h.length>1&&(h={"@included":h}),$o(l,n,h,{propertyIsArray:!o.compactArrays||c.includes("@set")})):(Co(h)&&1===h.length&&o.compactArrays&&(h=h[0]),h={[Wo.compactIri({activeCtx:e,iri:"@graph",relativeTo:{vocab:!0}})]:h},"@id"in t&&(h[Wo.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t["@id"]),"@index"in t&&(h[Wo.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"]),$o(l,n,h,{propertyIsArray:!o.compactArrays||c.includes("@set")}));else if(c.includes("@language")||c.includes("@index")||c.includes("@id")||c.includes("@type")){let a,r;if(l.hasOwnProperty(n)?a=l[n]:l[n]=a={},c.includes("@language"))_o(h)&&(h=h["@value"]),r=t["@language"];else if(c.includes("@index")){const o=Ho(e,n,"@index")||"@index",a=Wo.compactIri({activeCtx:e,iri:o,relativeTo:{vocab:!0}});if("@index"===o)r=t["@index"],delete h[a];else{let e;if([r,...e]=Qo(h[o]||[]),Ro(r))switch(e.length){case 0:delete h[o];break;case 1:h[o]=e[0];break;default:h[o]=e}else r=null}}else if(c.includes("@id")){const t=Wo.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}});r=h[t],delete h[t]}else if(c.includes("@type")){const a=Wo.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}});let i;switch([r,...i]=Qo(h[a]||[]),i.length){case 0:delete h[a];break;case 1:h[a]=i[0];break;default:h[a]=i}1===Object.keys(h).length&&"@id"in t&&(h=await Wo.compact({activeCtx:e,activeProperty:n,element:{"@id":t["@id"]},options:o}))}r||(r=Wo.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}})),$o(a,r,h,{propertyIsArray:c.includes("@set")})}else{const e=!o.compactArrays||c.includes("@set")||c.includes("@list")||Co(h)&&0===h.length||"@list"===s||"@graph"===s;$o(l,n,h,{propertyIsArray:e})}}}else{if((Ho(e,t,"@container")||[]).includes("@index"))continue;const n=Wo.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});$o(r,n,l)}else{const n=await Wo.compact({activeCtx:e,activeProperty:t,element:l,options:o});Co(n)&&0===n.length||$o(r,s,n)}else{const t=await Wo.compact({activeCtx:e,activeProperty:"@reverse",element:l,options:o});for(const n in t)if(e.mappings.has(n)&&e.mappings.get(n).reverse){const a=t[n],i=(Ho(e,n,"@container")||[]).includes("@set")||!o.compactArrays;$o(r,n,a,{propertyIsArray:i}),delete t[n]}if(Object.keys(t).length>0){const n=Wo.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});$o(r,n,t)}}else{let t=Qo(l).map((e=>Wo.compactIri({activeCtx:i,iri:e,relativeTo:{vocab:!0}})));1===t.length&&(t=t[0]);const n=Wo.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}}),o=(Ho(e,n,"@container")||[]).includes("@set")&&Uo(e,1.1)||Co(t)&&0===l.length;$o(r,n,t,{propertyIsArray:o})}else{let t=Qo(l).map((t=>Wo.compactIri({activeCtx:e,iri:t,relativeTo:{vocab:!1},base:o.base})));1===t.length&&(t=t[0]);r[Wo.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t}}return r}return n},Wo.compactIri=({activeCtx:e,iri:t,value:n=null,relativeTo:o={vocab:!1},reverse:a=!1,base:r=null})=>{if(null===t)return t;e.isPropertyTermScoped&&e.previousContext&&(e=e.previousContext);const i=e.getInverse();if(Fo(t)&&t in i&&"@none"in i[t]&&"@type"in i[t]["@none"]&&"@none"in i[t]["@none"]["@type"])return i[t]["@none"]["@type"]["@none"];if(o.vocab&&t in i){const o=e["@language"]||"@none",r=[];Lo(n)&&"@index"in n&&!("@graph"in n)&&r.push("@index","@index@set"),Lo(n)&&"@preserve"in n&&(n=n["@preserve"][0]),Mo(n)?("@index"in n&&r.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n&&r.push("@graph@id","@graph@id@set"),r.push("@graph","@graph@set","@set"),"@index"in n||r.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n||r.push("@graph@id","@graph@id@set")):Lo(n)&&!_o(n)&&r.push("@id","@id@set","@type","@set@type");let i="@language",s="@null";if(a)i="@type",s="@reverse",r.push("@set");else if(Ao(n)){"@index"in n||r.push("@list");const e=n["@list"];if(0===e.length)i="@any",s="@none";else{let t=0===e.length?o:null,n=null;for(let o=0;o<e.length;++o){const a=e[o];let r="@none",i="@none";if(_o(a))if("@direction"in a){r=`${(a["@language"]||"").toLowerCase()}_${a["@direction"]}`}else"@language"in a?r=a["@language"].toLowerCase():"@type"in a?i=a["@type"]:r="@null";else i="@id";if(null===t?t=r:r!==t&&_o(a)&&(t="@none"),null===n?n=i:i!==n&&(n="@none"),"@none"===t&&"@none"===n)break}t=t||"@none",n=n||"@none","@none"!==n?(i="@type",s=n):s=t}}else{if(_o(n))if("@language"in n&&!("@index"in n)){r.push("@language","@language@set"),s=n["@language"];const e=n["@direction"];e&&(s=`${s}_${e}`)}else"@direction"in n&&!("@index"in n)?s=`_${n["@direction"]}`:"@type"in n&&(i="@type",s=n["@type"]);else i="@type",s="@id";r.push("@set")}r.push("@none"),Lo(n)&&!("@index"in n)&&r.push("@index","@index@set"),_o(n)&&1===Object.keys(n).length&&r.push("@language","@language@set");const l=function(e,t,n,o,a,r){null===r&&(r="@null");const i=[];if(("@id"===r||"@reverse"===r)&&Lo(n)&&"@id"in n){"@reverse"===r&&i.push("@reverse");const t=Wo.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:!0}});e.mappings.has(t)&&e.mappings.get(t)&&e.mappings.get(t)["@id"]===n["@id"]?i.push.apply(i,["@vocab","@id"]):i.push.apply(i,["@id","@vocab"])}else{i.push(r);const e=i.find((e=>e.includes("_")));e&&i.push(e.replace(/^[^_]+_/,"_"))}i.push("@none");const s=e.inverse[t];for(const e of o){if(!(e in s))continue;const t=s[e][a];for(const e of i)if(e in t)return t[e]}return null}(e,t,n,r,i,s);if(null!==l)return l}if(o.vocab&&"@vocab"in e){const n=e["@vocab"];if(0===t.indexOf(n)&&t!==n){const o=t.substr(n.length);if(!e.mappings.has(o))return o}}let s=null;const l=[];let c=e.fastCurieMap;const d=t.length-1;for(let e=0;e<d&&t[e]in c;++e)c=c[t[e]],""in c&&l.push(c[""][0]);for(let o=l.length-1;o>=0;--o){const a=l[o],r=a.terms;for(const o of r){const r=o+":"+t.substr(a.iri.length);e.mappings.get(o)._prefix&&(!e.mappings.has(r)||null===n&&e.mappings.get(r)["@id"]===t)&&(null===s||Xo(r,s)<0)&&(s=r)}}if(null!==s)return s;for(const[n,o]of e.mappings)if(o&&o._prefix&&t.startsWith(n+":"))throw new ko(`Absolute IRI "${t}" confused with prefix "${n}".`,"jsonld.SyntaxError",{code:"IRI confused with prefix",context:e});if(!o.vocab){if("@base"in e){if(e["@base"]){const n=Vo(zo(r,e["@base"]),t);return Go.test(n)?`./${n}`:n}return t}return Vo(r,t)}return t},Wo.compactValue=({activeCtx:e,activeProperty:t,value:n,options:o})=>{if(_o(n)){const o=Ho(e,t,"@type"),a=Ho(e,t,"@language"),r=Ho(e,t,"@direction"),i=Ho(e,t,"@container")||[],s="@index"in n&&!i.includes("@index");if(!s&&"@none"!==o){if(n["@type"]===o)return n["@value"];if("@language"in n&&n["@language"]===a&&"@direction"in n&&n["@direction"]===r)return n["@value"];if("@language"in n&&n["@language"]===a)return n["@value"];if("@direction"in n&&n["@direction"]===r)return n["@value"]}const l=Object.keys(n).length,c=1===l||2===l&&"@index"in n&&!s,d="@language"in e,u=Ro(n["@value"]),p=e.mappings.has(t)&&null===e.mappings.get(t)["@language"];if(c&&"@none"!==o&&(!d||!u||p))return n["@value"];const h={};return s&&(h[Wo.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=n["@index"]),"@type"in n?h[Wo.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=Wo.compactIri({activeCtx:e,iri:n["@type"],relativeTo:{vocab:!0}}):"@language"in n&&(h[Wo.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=n["@language"]),"@direction"in n&&(h[Wo.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=n["@direction"]),h[Wo.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=n["@value"],h}const a=Bo(e,t,{vocab:!0},o),r=Ho(e,t,"@type"),i=Wo.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:"@vocab"===r},base:o.base});return"@id"===r||"@vocab"===r||"@graph"===a?i:{[Wo.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:i}};
|
|
40
|
-
/**
|
|
41
|
-
* A JavaScript implementation of the JSON-LD API.
|
|
42
|
-
*
|
|
43
|
-
* @author Dave Longley
|
|
44
|
-
*
|
|
45
|
-
* @license BSD 3-Clause License
|
|
46
|
-
* Copyright (c) 2011-2022 Digital Bazaar, Inc.
|
|
47
|
-
* All rights reserved.
|
|
48
|
-
*
|
|
49
|
-
* Redistribution and use in source and binary forms, with or without
|
|
50
|
-
* modification, are permitted provided that the following conditions are met:
|
|
51
|
-
*
|
|
52
|
-
* Redistributions of source code must retain the above copyright notice,
|
|
53
|
-
* this list of conditions and the following disclaimer.
|
|
54
|
-
*
|
|
55
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
56
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
57
|
-
* documentation and/or other materials provided with the distribution.
|
|
58
|
-
*
|
|
59
|
-
* Neither the name of the Digital Bazaar, Inc. nor the names of its
|
|
60
|
-
* contributors may be used to endorse or promote products derived from
|
|
61
|
-
* this software without specific prior written permission.
|
|
62
|
-
*
|
|
63
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
64
|
-
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
65
|
-
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
66
|
-
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
67
|
-
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
68
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
69
|
-
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
70
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
71
|
-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
72
|
-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
73
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
|
-
*/
|
|
75
|
-
const ta=B,na=Ie,oa=te,aa=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:e,context:t,documentLoader:n,base:o,cycles:a=new Set}){t&&Ke(t)&&t["@context"]&&(t=t["@context"]),t=Ye(t);const r=[];for(const i of t){if(Ze(i)){let t=this._get(i);t||(t=await this._resolveRemoteContext({activeCtx:e,url:i,documentLoader:n,base:o,cycles:a})),We(t)?r.push(...t):r.push(t);continue}if(null===i){r.push(new nt({document:null}));continue}Ke(i)||ot(t);const s=JSON.stringify(i);let l=this._get(s);l||(l=new nt({document:i}),this._cacheResolvedContext({key:s,resolved:l,tag:"static"})),r.push(l)}return r}_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:a}){t=et(o,t);const{context:r,remoteDoc:i}=await this._fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:a});at({context:r,base:o=i.documentUrl||t});const s=await this.resolve({activeCtx:e,context:r,documentLoader:n,base:o,cycles:a});return this._cacheResolvedContext({key:t,resolved:s,tag:i.tag}),s}async _fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:o}){if(o.size>10)throw new tt("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"loading remote context failed":"context overflow",max:10});if(o.has(t))throw new tt("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"recursive context inclusion":"context overflow",url:t});let a,r;o.add(t);try{r=await n(t),a=r.document||null,Ze(a)&&(a=JSON.parse(a))}catch(e){throw new tt("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.","jsonld.InvalidUrl",{code:"loading remote context failed",url:t,cause:e})}if(!Ke(a))throw new tt("Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.","jsonld.InvalidUrl",{code:"invalid remote context",url:t});return a="@context"in a?{"@context":a["@context"]}:{"@context":{}},r.contextUrl&&(We(a["@context"])||(a["@context"]=[a["@context"]]),a["@context"].push(r.contextUrl)),{context:a,remoteDoc:r}}},ra=oa.IdentifierIssuer,ia=z,sa=Qe,la=rt,{expand:ca}=nn,{flatten:da}=xn,{fromRDF:ua}=Jn,{toRDF:pa}=ro,{frameMergedOrDefault:ha,cleanupNull:fa}=mo,{isArray:va,isObject:ga,isString:ya}=F,{isSubjectReference:ma}=V,{expandIri:xa,getInitialContext:ba,process:wa,processingMode:ja}=kt,{compact:Ia,compactIri:Na}=Yo,{createNodeMap:Sa,createMergedNodeMap:Oa,mergeNodeMaps:Ea}=vn,{logEventHandler:Da,logWarningEventHandler:ka,safeEventHandler:Ca,setDefaultEventHandler:La,setupEventHandler:Ra,strictEventHandler:Ta,unhandledEventHandler:Aa}=dt,_a=function(e){const t={},n=new sa({max:100});function o(t,{documentLoader:n=e.documentLoader,...o}){if(t&&"compactionMap"in t)throw new ia('"compactionMap" not supported.',"jsonld.OptionsError");if(t&&"expansionMap"in t)throw new ia('"expansionMap" not supported.',"jsonld.OptionsError");return Object.assign({},{documentLoader:n},o,t,{eventHandler:Ra({options:t})})}return e.compact=async function(t,a,r){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");if(null===a)throw new ia("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"});if(null===t)return null;let i;(r=o(r,{base:ya(t)?t:"",compactArrays:!0,compactToRelative:!0,graph:!1,skipExpansion:!1,link:!1,issuer:new ra("_:b"),contextResolver:new aa({sharedCache:n})})).link&&(r.skipExpansion=!0),r.compactToRelative||delete r.base,i=r.skipExpansion?t:await e.expand(t,r);const s=await e.processContext(ba(r),a,r);let l=await Ia({activeCtx:s,element:i,options:r});r.compactArrays&&!r.graph&&va(l)?1===l.length?l=l[0]:0===l.length&&(l={}):r.graph&&ga(l)&&(l=[l]),ga(a)&&"@context"in a&&(a=a["@context"]),a=oa.clone(a),va(a)||(a=[a]);const c=a;a=[];for(let e=0;e<c.length;++e)(!ga(c[e])||Object.keys(c[e]).length>0)&&a.push(c[e]);const d=a.length>0;if(1===a.length&&(a=a[0]),va(l)){const e=Na({activeCtx:s,iri:"@graph",relativeTo:{vocab:!0}}),t=l;l={},d&&(l["@context"]=a),l[e]=t}else if(ga(l)&&d){const e=l;l={"@context":a};for(const t in e)l[t]=e[t]}return l},e.expand=async function(t,a){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");const r={},i=[];if("expandContext"in(a=o(a,{keepFreeFloatingNodes:!1,contextResolver:new aa({sharedCache:n})}))){const e=oa.clone(a.expandContext);ga(e)&&"@context"in e?r.expandContext=e:r.expandContext={"@context":e},i.push(r.expandContext)}let s;if(ya(t)){const n=await e.get(t,a);s=n.documentUrl,r.input=n.document,n.contextUrl&&(r.remoteContext={"@context":n.contextUrl},i.push(r.remoteContext))}else r.input=oa.clone(t);"base"in a||(a.base=s||"");let l=ba(a);for(const e of i)l=await wa({activeCtx:l,localCtx:e,options:a});let c=await ca({activeCtx:l,element:r.input,options:a});return ga(c)&&"@graph"in c&&1===Object.keys(c).length?c=c["@graph"]:null===c&&(c=[]),va(c)||(c=[c]),c},e.flatten=async function(t,a,r){if(arguments.length<1)return new TypeError("Could not flatten, too few arguments.");a="function"==typeof a?null:a||null,r=o(r,{base:ya(t)?t:"",contextResolver:new aa({sharedCache:n})});const i=await e.expand(t,r),s=da(i);if(null===a)return s;r.graph=!0,r.skipExpansion=!0;return await e.compact(s,a,r)},e.frame=async function(t,a,r){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");if(r=o(r,{base:ya(t)?t:"",embed:"@once",explicit:!1,requireAll:!1,omitDefault:!1,bnodesToClear:[],contextResolver:new aa({sharedCache:n})}),ya(a)){const t=await e.get(a,r);if(a=t.document,t.contextUrl){let e=a["@context"];e?va(e)?e.push(t.contextUrl):e=[e,t.contextUrl]:e=t.contextUrl,a["@context"]=e}}const i=a&&a["@context"]||{},s=await e.processContext(ba(r),i,r);r.hasOwnProperty("omitGraph")||(r.omitGraph=ja(s,1.1)),r.hasOwnProperty("pruneBlankNodeIdentifiers")||(r.pruneBlankNodeIdentifiers=ja(s,1.1));const l=await e.expand(t,r),c={...r};c.isFrame=!0,c.keepFreeFloatingNodes=!0;const d=await e.expand(a,c),u=Object.keys(a).map((e=>xa(s,e,{vocab:!0})));c.merged=!u.includes("@graph"),c.is11=ja(s,1.1);const p=ha(l,d,c);c.graph=!r.omitGraph,c.skipExpansion=!0,c.link={},c.framing=!0;let h=await e.compact(p,i,c);return c.link={},h=fa(h,c),h},e.link=async function(t,n,o){const a={};return n&&(a["@context"]=n),a["@embed"]="@link",e.frame(t,a,o)},e.normalize=e.canonize=async function(t,a){if(arguments.length<1)throw new TypeError("Could not canonize, too few arguments.");if("inputFormat"in(a=o(a,{base:ya(t)?t:null,algorithm:"URDNA2015",skipExpansion:!1,safe:!0,contextResolver:new aa({sharedCache:n})}))){if("application/n-quads"!==a.inputFormat&&"application/nquads"!==a.inputFormat)throw new ia("Unknown canonicalization input format.","jsonld.CanonizeError");const e=la.parse(t);return ta.canonize(e,a)}const r={...a};delete r.format,r.produceGeneralizedRdf=!1;const i=await e.toRDF(t,r);return ta.canonize(i,a)},e.fromRDF=async function(e,n){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");n=o(n,{format:ya(e)?"application/n-quads":void 0});const{format:a}=n;let{rdfParser:r}=n;if(a){if(r=r||t[a],!r)throw new ia("Unknown input format.","jsonld.UnknownFormat",{format:a})}else r=()=>e;const i=await r(e);return ua(i,n)},e.toRDF=async function(t,a){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");let r;r=(a=o(a,{base:ya(t)?t:"",skipExpansion:!1,contextResolver:new aa({sharedCache:n})})).skipExpansion?t:await e.expand(t,a);const i=pa(r,a);if(a.format){if("application/n-quads"===a.format||"application/nquads"===a.format)return la.serialize(i);throw new ia("Unknown output format.","jsonld.UnknownFormat",{format:a.format})}return i},e.createNodeMap=async function(t,a){if(arguments.length<1)throw new TypeError("Could not create node map, too few arguments.");a=o(a,{base:ya(t)?t:"",contextResolver:new aa({sharedCache:n})});const r=await e.expand(t,a);return Oa(r,a)},e.merge=async function(t,a,r){if(arguments.length<1)throw new TypeError("Could not merge, too few arguments.");if(!va(t))throw new TypeError('Could not merge, "docs" must be an array.');a="function"==typeof a?null:a||null,r=o(r,{contextResolver:new aa({sharedCache:n})});const i=await Promise.all(t.map((t=>{const n={...r};return e.expand(t,n)})));let s=!0;"mergeNodes"in r&&(s=r.mergeNodes);const l=r.issuer||new ra("_:b"),c={"@default":{}};for(let e=0;e<i.length;++e){const t=oa.relabelBlankNodes(i[e],{issuer:new ra("_:b"+e+"-")}),n=s||0===e?c:{"@default":{}};if(Sa(t,n,"@default",l),n!==c)for(const e in n){const t=n[e];if(!(e in c)){c[e]=t;continue}const o=c[e];for(const e in t)e in o||(o[e]=t[e])}}const d=Ea(c),u=[],p=Object.keys(d).sort();for(let e=0;e<p.length;++e){const t=d[p[e]];ma(t)||u.push(t)}if(null===a)return u;r.graph=!0,r.skipExpansion=!0;return await e.compact(u,a,r)},Object.defineProperty(e,"documentLoader",{get:()=>e._documentLoader,set:t=>e._documentLoader=t}),e.documentLoader=async e=>{throw new ia("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",url:e})},e.get=async function(t,n){let o;o="function"==typeof n.documentLoader?n.documentLoader:e.documentLoader;const a=await o(t);try{if(!a.document)throw new ia("No remote document found at the given URL.","jsonld.NullRemoteDocument");ya(a.document)&&(a.document=JSON.parse(a.document))}catch(e){throw new ia("Could not retrieve a JSON-LD document from the URL.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:a})}return a},e.processContext=async function(e,t,a){return a=o(a,{base:"",contextResolver:new aa({sharedCache:n})}),null===t?ba(a):(t=oa.clone(t),ga(t)&&"@context"in t||(t={"@context":t}),wa({activeCtx:e,localCtx:t,options:a}))},e.getContextValue=kt.getContextValue,e.documentLoaders={},e.useDocumentLoader=function(t){if(!(t in e.documentLoaders))throw new ia('Unknown document loader type: "'+t+'"',"jsonld.UnknownDocumentLoader",{type:t});e.documentLoader=e.documentLoaders[t].apply(e,Array.prototype.slice.call(arguments,1))},e.registerRDFParser=function(e,n){t[e]=n},e.unregisterRDFParser=function(e){delete t[e]},e.registerRDFParser("application/n-quads",la.parse),e.registerRDFParser("application/nquads",la.parse),e.url=ue(),e.logEventHandler=Da,e.logWarningEventHandler=ka,e.safeEventHandler=Ca,e.setDefaultEventHandler=La,e.strictEventHandler=Ta,e.unhandledEventHandler=Aa,e.util=oa,Object.assign(e,oa),e.promises=e,e.RequestQueue=de(),e.JsonLdProcessor=(Zo||(Zo=1,Ko=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}),Ko)(e),na.setupGlobals(e),na.setupDocumentLoaders(e),e},Ma=function(){return _a((function(){return Ma()}))};_a(Ma);var Ja=Ma,Pa=o(Ja);export{Ja as a,Pa as j};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as t,g as r}from"./main.js";var n,e={exports:{}},o={exports:{}};function i(){return n||(n=1,r=o,function(t){var n={bytesToHex:function(t){return function(t){return t.map((function(t){return r=t.toString(16),n=2,r.length>n?r:Array(n-r.length+1).join("0")+r;var r,n})).join("")}(t)},hexToBytes:function(t){if(t.length%2==1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return 0===t.indexOf("0x")&&(t=t.slice(2)),t.match(/../g).map((function(t){return parseInt(t,16)}))}};r.exports?r.exports=n:t.convertHex=n}(t)),o.exports;var r}var s,a,u={exports:{}};a=e,function(r){var n={};a.exports?(n.bytesToHex=i().bytesToHex,n.convertString=function(){return s||(s=1,r=u,function(t){var n={bytesToString:function(t){return t.map((function(t){return String.fromCharCode(t)})).join("")},stringToBytes:function(t){return t.split("").map((function(t){return t.charCodeAt(0)}))}};n.UTF8={bytesToString:function(t){return decodeURIComponent(escape(n.bytesToString(t)))},stringToBytes:function(t){return n.stringToBytes(unescape(encodeURIComponent(t)))}},r.exports?r.exports=n:t.convertString=n}(t)),u.exports;var r}(),a.exports=g):(n.bytesToHex=r.convertHex.bytesToHex,n.convertString=r.convertString,r.sha256=g);var e=[];!function(){function t(t){for(var r=Math.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,o=0;o<64;)t(n)&&(e[o]=r(Math.pow(n,1/3)),o++),n++}();var o=function(t){for(var r=[],n=0,e=0;n<t.length;n++,e+=8)r[e>>>5]|=t[n]<<24-e%32;return r},c=function(t){for(var r=[],n=0;n<32*t.length;n+=8)r.push(t[n>>>5]>>>24-n%32&255);return r},f=[],v=function(t,r,n){for(var o=t[0],i=t[1],s=t[2],a=t[3],u=t[4],c=t[5],v=t[6],g=t[7],p=0;p<64;p++){if(p<16)f[p]=0|r[n+p];else{var x=f[p-15],h=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,y=f[p-2],T=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;f[p]=h+f[p-7]+T+f[p-16]}var S=o&i^o&s^i&s,m=(o<<30|o>>>2)^(o<<19|o>>>13)^(o<<10|o>>>22),b=g+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&v)+e[p]+f[p];g=v,v=c,c=u,u=a+b|0,a=s,s=i,i=o,o=b+(m+S)|0}t[0]=t[0]+o|0,t[1]=t[1]+i|0,t[2]=t[2]+s|0,t[3]=t[3]+a|0,t[4]=t[4]+u|0,t[5]=t[5]+c|0,t[6]=t[6]+v|0,t[7]=t[7]+g|0};function g(t,r){t.constructor===String&&(t=n.convertString.UTF8.stringToBytes(t));var e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],i=o(t),s=8*t.length;i[s>>5]|=128<<24-s%32,i[15+(s+64>>9<<4)]=s;for(var a=0;a<i.length;a+=16)v(e,i,a);var u=c(e);return r&&r.asBytes?u:r&&r.asString?n.convertString.bytesToString(u):n.bytesToHex(u)}g.x2=function(t,r){return g(g(t,{asBytes:!0}),r)}}(t);var c=r(e.exports);export{c as s};
|