@blockcerts/blockcerts-verifier 1.70.0 → 1.71.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.
Files changed (64) hide show
  1. package/__mocks__/@polymer/lit-element.ts +1 -1
  2. package/bundle-stats.html +13 -13
  3. package/dist/DataIntegrityProof-elCNKq16-DBDuaDNt.js +7 -0
  4. package/dist/EcdsaSd2023-B0XPAIp6-K61axvBA.js +30 -0
  5. package/dist/EcdsaSecp256k1Signature2019-BHgoxmKI-DT2qHZod.js +1 -0
  6. package/dist/Ed25519Signature2020-BQsESRnS-TKZI_1AX.js +34 -0
  7. package/dist/EddsaRdfc2022-DQKzWHK4-BILzDBp-.js +14 -0
  8. package/dist/HashlinkVerifier-BsVlaml5-B4Niv2-b.js +8 -0
  9. package/dist/{MerkleProof2017-DqA3Y12J-D6qS7nCf.js → MerkleProof2017-CYM8CJHB-FYpMvld0.js} +1 -1
  10. package/dist/{MerkleProof2017-MZJbBTpc-CeZmtqCh.js → MerkleProof2017-MZJbBTpc-Cwfnte6F.js} +6 -6
  11. package/dist/MerkleProof2019-BLrywo8h-Bo9rH2Eq.js +13 -0
  12. package/dist/checkCredentialSchemaConformity-CKNtOu_t-B9iaCRUE.js +1 -0
  13. package/dist/{checkRevocationStatusList2021-CPFaTtUR-XCu3zkCJ.js → checkRevocationStatusList2021-CMAVXAVE-BEBD8TO8.js} +1 -1
  14. package/dist/{controlVerificationMethod-qY02GU_H-B-4U8WJQ.js → controlVerificationMethod-B4TgLED0-BGpxLjMq.js} +1 -1
  15. package/dist/{did-key-common.esm-nDfdwcKN-BTWid9-w.js → did-key-common.esm-BIftA62j-hVrUMxjy.js} +3 -3
  16. package/dist/{did-key-ed25519.esm-DNra0jwE-CTwAEzy6.js → did-key-ed25519.esm-Drn3Y7PF-CqD0ifNk.js} +1 -1
  17. package/dist/did-key-secp256k1.esm-DH-f3o5q-C66E7IxB.js +1 -0
  18. package/dist/{downloadPDF-DQVfeIBI.js → downloadPDF-eGAsbwF0.js} +19 -19
  19. package/dist/ed25519-key-pair.esm-DPOFpdJ2-BrwuS0Ia.js +25 -0
  20. package/dist/elliptic-4aZS_cwf-BpaNaVm0.js +1 -0
  21. package/dist/elliptic-BYqApR8Y-CKp7atgR.js +1 -0
  22. package/dist/{ensureNotRevoked-gui-UMnE-DnVNmhNy.js → ensureNotRevoked-gui-UMnE-o08xNOvL.js} +1 -1
  23. package/dist/{ensureValidIssuingKey-Cz0isOdi-wu9SdYxL.js → ensureValidIssuingKey-BMVCi2T2-BdV46XBb.js} +1 -1
  24. package/dist/{index-Bi-O7G4n-Bgz40JYf.js → index-BgTFEYQ4-DMaz98iZ.js} +7 -7
  25. package/dist/index-CEj3k9G6.js +2 -0
  26. package/dist/index-DZLKRa_V-D_IQzjvG.js +5 -0
  27. package/dist/index-lyuTDW_o-nyi7dklX.js +1 -0
  28. package/dist/index.es-B7xY76Pb.js +56 -0
  29. package/dist/{jsonld-CQCA9cVk-CQeQQNYP.js → jsonld-B_Q2jvnp-BJ5uVeOU.js} +3 -3
  30. package/dist/{index-BM3knvQR-D4vxi3Vi.js → jsonld-signatures-BbILf-Q7-DTp6__ud.js} +16 -20
  31. package/dist/keyUtils-ExMI0fmg-NVOmd8LH.js +1 -0
  32. package/dist/main.js +128 -128
  33. package/dist/pako.esm-BGRKTPxS-UdHShO7y.js +2 -0
  34. package/dist/purify.es-CkKsfeyH.js +2 -0
  35. package/dist/{retrieveVerificationMethodPublicKey-6-rH9LB2-DvFOhdlW.js → retrieveVerificationMethodPublicKey-C5Gafl1E-Lv4waRy7.js} +1 -1
  36. package/dist/verifyIssuerProfile-DCJyz3ho-BwuCK9F3.js +1 -0
  37. package/dist/webcrypto.es-DpqeDikX-BnVhHKeM.js +40 -0
  38. package/dist/{x25519-CEFq6uo8-NSl6svWQ.js → x25519-Kp6t9B5a-Dh8L0KYb.js} +1 -1
  39. package/eslint.config.mjs +21 -0
  40. package/package.json +35 -46
  41. package/vitest.config.ts +11 -0
  42. package/web-test-runner.config.mjs +7 -0
  43. package/.eslintrc.js +0 -29
  44. package/dist/EcdsaSd2023-DcsELLJj-DreWzXlX.js +0 -36
  45. package/dist/EcdsaSecp256k1Signature2019-Cy1mIkjt-DJmj4ZAc.js +0 -1
  46. package/dist/Ed25519Signature2020-B-CFC9WC-DJkVVmwk.js +0 -52
  47. package/dist/HashlinkVerifier-hQgVXluZ-dg5WNZnc.js +0 -11
  48. package/dist/MerkleProof2019-B4HSvmJo-Cwc-hu-Y.js +0 -3
  49. package/dist/checkCredentialSchemaConformity-ChaCRIqw-7U54o8BA.js +0 -1
  50. package/dist/did-key-secp256k1.esm-Dv1NXpDw-_M-qRy-N.js +0 -1
  51. package/dist/elliptic-D-ZnlFdt-DQmYEk-8.js +0 -1
  52. package/dist/index-ButIU7pZ-Djl5IfSw.js +0 -1
  53. package/dist/index-C-APorIs.js +0 -2
  54. package/dist/index.es-BqQdvz5C.js +0 -56
  55. package/dist/pako.esm-DnD5dZGi-Bw1vqMku.js +0 -2
  56. package/dist/purify.es-DJj7iNgQ.js +0 -2
  57. package/dist/verifyIssuerProfile-DnjbDuXe-BVFzyjSL.js +0 -1
  58. package/dist/webcrypto.es-BxABHF-B-TCzLuarM.js +0 -40
  59. package/karma.conf.js +0 -27
  60. /package/dist/{Suite-B7Vy9AuU-D1ucdMDB.js → Suite-BmP2Qu19-D1ucdMDB.js} +0 -0
  61. /package/dist/{ensureNotRevoked-D9FFjDJd-DvMIgM4L.js → ensureNotRevoked-hGps0prO-DvMIgM4L.js} +0 -0
  62. /package/dist/{index-ZJb8DPW9-Dgus2xdV.js → index-BS134367-Dgus2xdV.js} +0 -0
  63. /package/dist/{index-0q2-1l6i-C0eXpZGn.js → index-CQYVZlSE-C0eXpZGn.js} +0 -0
  64. /package/dist/{sha256-BIUNvBZY-C1PUWFZm.js → sha256-u2xsd4MQ-C1PUWFZm.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{c as e,d as t,r as n,g as o,i as r,V as i,a,b as s,n as l,e as c,p as d}from"./index-C-APorIs.js";var u={},p=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,n,o,r,i,a=1,s={},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){l((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?((o=new MessageChannel).port1.onmessage=function(e){h(e.data)},t=function(e){o.port2.postMessage(e)}):d&&"onreadystatechange"in d.createElement("script")?(n=d.documentElement,t=function(e){var t=d.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.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 r={callback:e,args:n};return s[a]=r,t(a),a++},u.clearImmediate=p}function p(e){delete s[e]}function h(e){if(c)setTimeout(h,0,e);else{var t=s[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);
1
+ import{d as e,r as t,V as n,g as o,i as r,a as i,b as a,p as s,c as l,e as c,n as d}from"./index-CEj3k9G6.js";var u={},p=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,n,o,r,i,a=1,s={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?t=function(e){d((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?((o=new MessageChannel).port1.onmessage=function(e){h(e.data)},t=function(e){o.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(n=c.documentElement,t=function(e){var t=c.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.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 r={callback:e,args:n};return s[a]=r,t(a),a++},u.clearImmediate=p}function p(e){delete s[e]}function h(e){if(l)setTimeout(h,0,e);else{var t=s[e];if(t){l=!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),l=!1}}}}}("undefined"==typeof self?l:self);
2
2
  /*!
3
3
  * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
4
4
  */
@@ -13,7 +13,7 @@ const g="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",y="http://www.w3
13
13
  /*!
14
14
  * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
15
15
  */
16
- const E=p,O=f,D=v,C=j;var L=class{constructor({createMessageDigest:e=()=>new O("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:n=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new E("_: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 r=[...t.keys()].sort(),i=[];for(const e of r){const n=t.get(e);if(n.length>1){i.push(n);continue}const o=n[0];this.canonicalIssuer.getId(o)}for(const e of i){const t=[];for(const n of e){if(this.canonicalIssuer.hasId(n))continue;const e=new E("_:b");e.getId(n);const o=await this.hashNDegreeQuads(n,e);t.push(o)}t.sort(T);for(const e of t){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const a=[];for(const e of this.quads){const t=C.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));a.push(t)}return a.sort(),a.join("")}async hashFirstDegreeQuads(e){const t=[],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(C.serializeQuad(o))}t.sort();const r=this.createMessageDigest();for(const e of t)r.update(e);return n.hash=await r.digest(),n.hash}async hashRelatedBlankNode(e,t,n,o){let r;r=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):n.hasId(e)?n.getId(e):this.blankNodeInfo.get(e).hash;const i=this.createMessageDigest();return i.update(o),"g"!==o&&i.update(this.getRelatedPredicate(t)),i.update(r),i.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(),r=await this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let n,i="";const a=new D(r.get(e));let s=0;for(;a.hasNext();){const e=a.next();++s%3==0&&await this._yield();let o=t.clone(),r="";const l=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?r+=this.canonicalIssuer.getId(t):(o.hasId(t)||l.push(t),r+=o.getId(t)),0!==i.length&&r>i){c=!0;break}if(!c){for(const e of l){const t=await this.hashNDegreeQuads(e,o);if(r+=o.getId(e),r+=`<${t.hash}>`,o=t.issuer,0!==i.length&&r>i){c=!0;break}}c||(0===i.length||r<i)&&(i=r,n=o)}}o.update(i),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 r=0;for(const i of o)++r%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:i,component:i.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.graph,position:"g",id:e,issuer:t,hashToRelated:n})]);return n}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=await this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=await this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise((e=>setImmediate(e)))}};function T(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}
16
+ const O=p,E=f,D=v,C=j;var L=class{constructor({createMessageDigest:e=()=>new E("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:n=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new O("_: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 r=[...t.keys()].sort(),i=[];for(const e of r){const n=t.get(e);if(n.length>1){i.push(n);continue}const o=n[0];this.canonicalIssuer.getId(o)}for(const e of i){const t=[];for(const n of e){if(this.canonicalIssuer.hasId(n))continue;const e=new O("_:b");e.getId(n);const o=await this.hashNDegreeQuads(n,e);t.push(o)}t.sort(T);for(const e of t){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const a=[];for(const e of this.quads){const t=C.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));a.push(t)}return a.sort(),a.join("")}async hashFirstDegreeQuads(e){const t=[],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(C.serializeQuad(o))}t.sort();const r=this.createMessageDigest();for(const e of t)r.update(e);return n.hash=await r.digest(),n.hash}async hashRelatedBlankNode(e,t,n,o){let r;r=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):n.hasId(e)?n.getId(e):this.blankNodeInfo.get(e).hash;const i=this.createMessageDigest();return i.update(o),"g"!==o&&i.update(this.getRelatedPredicate(t)),i.update(r),i.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(),r=await this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let n,i="";const a=new D(r.get(e));let s=0;for(;a.hasNext();){const e=a.next();++s%3==0&&await this._yield();let o=t.clone(),r="";const l=[];let c=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?r+=this.canonicalIssuer.getId(t):(o.hasId(t)||l.push(t),r+=o.getId(t)),0!==i.length&&r>i){c=!0;break}if(!c){for(const e of l){const t=await this.hashNDegreeQuads(e,o);if(r+=o.getId(e),r+=`<${t.hash}>`,o=t.issuer,0!==i.length&&r>i){c=!0;break}}c||(0===i.length||r<i)&&(i=r,n=o)}}o.update(i),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 r=0;for(const i of o)++r%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:i,component:i.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:i,component:i.graph,position:"g",id:e,issuer:t,hashToRelated:n})]);return n}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=await this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=await this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise((e=>setImmediate(e)))}};function T(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}
17
17
  /*!
18
18
  * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
19
19
  */const R=f,A=L;var _=class extends A{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new R("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 r=0;for(const i of o){let o,a;if("BlankNode"===i.subject.termType&&i.subject.value!==e)a=i.subject.value,o="p";else{if("BlankNode"!==i.object.termType||i.object.value===e)continue;a=i.object.value,o="r"}++r%100==0&&await this._yield();const s=await this.hashRelatedBlankNode(a,i,t,o),l=n.get(s);l?l.push(a):n.set(s,[a])}return n}};
@@ -22,9 +22,9 @@ const E=p,O=f,D=v,C=j;var L=class{constructor({createMessageDigest:e=()=>new O("
22
22
  */const P=p,M=f,J=v,H=j;var B=class{constructor({createMessageDigest:e=()=>new M("sha256"),canonicalIdMap:t=new Map,maxDeepIterations:n=1/0}={}){this.name="URDNA2015",this.blankNodeInfo=new Map,this.canonicalIssuer=new P("_: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(),r=[];for(const e of o){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 P("_:b");e.getId(n);const o=this.hashNDegreeQuads(n,e);t.push(o)}t.sort(F);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=H.serializeQuadComponents(this._componentWithCanonicalId({component:e.subject}),e.predicate,this._componentWithCanonicalId({component:e.object}),this._componentWithCanonicalId({component:e.graph}));i.push(t)}return i.sort(),i.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(H.serializeQuad(o))}t.sort();const r=this.createMessageDigest();for(const e of t)r.update(e);return n.hash=r.digest(),n.hash}hashRelatedBlankNode(e,t,n,o){let r;r=this.canonicalIssuer.hasId(e)?this.canonicalIssuer.getId(e):n.hasId(e)?n.getId(e):this.blankNodeInfo.get(e).hash;const i=this.createMessageDigest();return i.update(o),"g"!==o&&i.update(this.getRelatedPredicate(t)),i.update(r),i.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(),r=this.createHashToRelated(e,t),i=[...r.keys()].sort();for(const e of i){o.update(e);let n,i="";const a=new J(r.get(e));for(;a.hasNext();){const e=a.next();let o=t.clone(),r="";const s=[];let l=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?r+=this.canonicalIssuer.getId(t):(o.hasId(t)||s.push(t),r+=o.getId(t)),0!==i.length&&r>i){l=!0;break}if(!l){for(const e of s){const t=this.hashNDegreeQuads(e,o);if(r+=o.getId(e),r+=`<${t.hash}>`,o=t.issuer,0!==i.length&&r>i){l=!0;break}}l||(0===i.length||r<i)&&(i=r,n=o)}}o.update(i),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 r of o)this._addRelatedBlankNodeHash({quad:r,component:r.subject,position:"s",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:r,component:r.object,position:"o",id:e,issuer:t,hashToRelated:n}),this._addRelatedBlankNodeHash({quad:r,component:r.graph,position:"g",id:e,issuer:t,hashToRelated:n});return n}_hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const n=this.hashFirstDegreeQuads(e),o=t.get(n);o?o.push(e):t.set(n,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const n=t.value,o=this.blankNodeInfo.get(n);o?o.quads.add(e):this.blankNodeInfo.set(n,{quads:new Set([e]),hash:null})}_addRelatedBlankNodeHash({quad:e,component:t,position:n,id:o,issuer:r,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=this.hashRelatedBlankNode(a,e,r,n),l=i.get(s);l?l.push(a):i.set(s,[a])}_componentWithCanonicalId({component:e}){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}};function F(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}
23
23
  /*!
24
24
  * Copyright (c) 2016-2021 Digital Bazaar, Inc. All rights reserved.
25
- */const U=f,q=B;var V=class extends q{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new U("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 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"}const a=this.hashRelatedBlankNode(i,r,t,o),s=n.get(a);s?s.push(i):n.set(a,[i])}return n}},$=o(Object.freeze({__proto__:null,default:{}}));!function(e){const t=L,n=_,o=B,r=V;let i;try{i=$}catch(e){}function a(t){return Array.isArray(t)?t:e.NQuads.legacyDatasetToQuads(t)}e.NQuads=j,e.IdentifierIssuer=p,e._rdfCanonizeNative=function(e){return e&&(i=e),i},e.canonize=async function(e,o){const r=a(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(r,o,((n,o)=>n?t(n):e(o)))))}if("URDNA2015"===o.algorithm)return new t(o).main(r);if("URGNA2012"===o.algorithm){if(o.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "URGNA2012".');return new n(o).main(r)}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=a(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 r(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)}}(u);var G=u;const z={};var K=z;z.isArray=Array.isArray,z.isBoolean=e=>"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e),z.isDouble=e=>z.isNumber(e)&&(-1!==String(e).indexOf(".")||Math.abs(e)>=1e21),z.isEmptyObject=e=>z.isObject(e)&&0===Object.keys(e).length,z.isNumber=e=>"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e),z.isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),z.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),z.isString=e=>"string"==typeof e||"[object String]"===Object.prototype.toString.call(e),z.isUndefined=e=>void 0===e;const Q=K,X={};var W=X;X.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},X.isSubjectReference=e=>Q.isObject(e)&&1===Object.keys(e).length&&"@id"in e,X.isValue=e=>Q.isObject(e)&&"@value"in e,X.isList=e=>Q.isObject(e)&&"@list"in e,X.isGraph=e=>Q.isObject(e)&&"@graph"in e&&1===Object.keys(e).filter((e=>"@id"!==e&&"@index"!==e)).length,X.isSimpleGraph=e=>X.isGraph(e)&&!("@id"in e),X.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 Y=W,ee=K,te=G.IdentifierIssuer,ne=Z,oe=/(?:<[^>]*?>|"[^"]*?"|[^,])+/g,re=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,ie=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g,ae={accept:"application/ld+json, application/json"},se={};var le=se;function ce(e,t){if(ee.isArray(t))for(let n=0;n<t.length;++n)t[n]=ce(e,t[n]);else if(Y.isList(t))t["@list"]=ce(e,t["@list"]);else if(ee.isObject(t)){Y.isBlankNode(t)&&(t["@id"]=e.getId(t["@id"]));const n=Object.keys(t).sort();for(let o=0;o<n.length;++o){const r=n[o];"@id"!==r&&(t[r]=ce(e,t[r]))}}return t}se.IdentifierIssuer=te,se.REGEX_BCP47=/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/,se.REGEX_KEYWORD=/^@[a-zA-Z]+$/,se.clone=function(e){if(e&&"object"==typeof e){let t;if(ee.isArray(e)){t=[];for(let n=0;n<e.length;++n)t[n]=se.clone(e[n])}else if(e instanceof Map){t=new Map;for(const[n,o]of e)t.set(n,se.clone(o))}else if(e instanceof Set){t=new Set;for(const n of e)t.add(se.clone(n))}else if(ee.isObject(e)){t={};for(const n in e)t[n]=se.clone(e[n])}else t=e.toString();return t}return e},se.asArray=function(e){return Array.isArray(e)?e:[e]},se.buildHeaders=(e={})=>{if(Object.keys(e).some((e=>"accept"===e.toLowerCase())))throw new RangeError('Accept header may not be specified; only "'+ae.accept+'" is supported.');return Object.assign({Accept:ae.accept},e)},se.parseLinkHeader=e=>{const t={},n=e.match(oe);for(let e=0;e<n.length;++e){let o=n[e].match(re);if(!o)continue;const r={target:o[1]},i=o[2];for(;o=ie.exec(i);)r[o[1]]=void 0===o[2]?o[3]:o[2];const a=r.rel||"";Array.isArray(t[a])?t[a].push(r):t.hasOwnProperty(a)?t[a]=[t[a],r]:t[a]=r}return t},se.validateTypeValue=(e,t)=>{if(!(ee.isString(e)||ee.isArray(e)&&e.every((e=>ee.isString(e))))){if(t&&ee.isObject(e))switch(Object.keys(e).length){case 0:return;case 1:if("@default"in e&&se.asArray(e["@default"]).every((e=>ee.isString(e))))return}throw new ne('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})}},se.hasProperty=(e,t)=>{if(e.hasOwnProperty(t)){const n=e[t];return!ee.isArray(n)||n.length>0}return!1},se.hasValue=(e,t,n)=>{if(se.hasProperty(e,t)){let o=e[t];const r=Y.isList(o);if(ee.isArray(o)||r){r&&(o=o["@list"]);for(let e=0;e<o.length;++e)if(se.compareValues(n,o[e]))return!0}else if(!ee.isArray(n))return se.compareValues(n,o)}return!1},se.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(ee.isArray(n)){0===n.length&&o.propertyIsArray&&!e.hasOwnProperty(t)&&(e[t]=[]),o.prependValue&&(n=n.concat(e[t]),e[t]=[]);for(let r=0;r<n.length;++r)se.addValue(e,t,n[r],o)}else if(e.hasOwnProperty(t)){const r=!o.allowDuplicate&&se.hasValue(e,t,n);ee.isArray(e[t])||r&&!o.propertyIsArray||(e[t]=[e[t]]),r||(o.prependValue?e[t].unshift(n):e[t].push(n))}else e[t]=o.propertyIsArray?[n]:n},se.getValues=(e,t)=>[].concat(e[t]||[]),se.removeProperty=(e,t)=>{delete e[t]},se.removeValue=(e,t,n,o)=>{"propertyIsArray"in(o=o||{})||(o.propertyIsArray=!1);const r=se.getValues(e,t).filter((e=>!se.compareValues(e,n)));0===r.length?se.removeProperty(e,t):1!==r.length||o.propertyIsArray?e[t]=r:e[t]=r[0]},se.relabelBlankNodes=(e,t)=>ce((t=t||{}).issuer||new te("_:b"),e),se.compareValues=(e,t)=>e===t||(!(!Y.isValue(e)||!Y.isValue(t)||e["@value"]!==t["@value"]||e["@type"]!==t["@type"]||e["@language"]!==t["@language"]||e["@index"]!==t["@index"])||!!(ee.isObject(e)&&"@id"in e&&ee.isObject(t)&&"@id"in t)&&e["@id"]===t["@id"]),se.compareShortestLeast=(e,t)=>e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1;const de="http://www.w3.org/1999/02/22-rdf-syntax-ns#",ue="http://www.w3.org/2001/XMLSchema#";var pe,he,fe,ve,ge={LINK_HEADER_REL:"http://www.w3.org/ns/json-ld#context",LINK_HEADER_CONTEXT:"http://www.w3.org/ns/json-ld#context",RDF:de,RDF_LIST:de+"List",RDF_FIRST:de+"first",RDF_REST:de+"rest",RDF_NIL:de+"nil",RDF_TYPE:de+"type",RDF_PLAIN_LITERAL:de+"PlainLiteral",RDF_XML_LITERAL:de+"XMLLiteral",RDF_JSON_LITERAL:de+"JSON",RDF_OBJECT:de+"object",RDF_LANGSTRING:de+"langString",XSD:ue,XSD_BOOLEAN:ue+"boolean",XSD_DOUBLE:ue+"double",XSD_INTEGER:ue+"integer",XSD_STRING:ue+"string"};function ye(){return he||(he=1,pe=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]}}}),pe}function me(){if(ve)return fe;ve=1;const e=K,t={};fe=t,t.parsers={simple:{keys:["href","scheme","authority","path","query","fragment"],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:["href","protocol","scheme","authority","auth","user","password","hostname","port","path","directory","file","query","fragment"],regex:/^(([a-zA-Z][a-zA-Z0-9+-.]*):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},t.parse=(e,n)=>{const o={},r=t.parsers[n||"full"],i=r.regex.exec(e);let a=r.keys.length;for(;a--;)o[r.keys[a]]=void 0===i[a]?null:i[a];return("https"===o.scheme&&"443"===o.port||"http"===o.scheme&&"80"===o.port)&&(o.href=o.href.replace(":"+o.port,""),o.authority=o.authority.replace(":"+o.port,""),o.port=null),o.normalizedPath=t.removeDotSegments(o.path),o},t.prependBase=(n,o)=>{if(null===n)return o;if(t.isAbsolute(o))return o;n&&!e.isString(n)||(n=t.parse(n||""));const r=t.parse(o),i={protocol:n.protocol||""};if(null!==r.authority)i.authority=r.authority,i.path=r.path,i.query=r.query;else if(i.authority=n.authority,""===r.path)i.path=n.path,null!==r.query?i.query=r.query:i.query=n.query;else{if(0===r.path.indexOf("/"))i.path=r.path;else{let e=n.path;e=e.substr(0,e.lastIndexOf("/")+1),(e.length>0||n.authority)&&"/"!==e.substr(-1)&&(e+="/"),e+=r.path,i.path=e}i.query=r.query}""!==r.path&&(i.path=t.removeDotSegments(i.path));let a=i.protocol;return null!==i.authority&&(a+="//"+i.authority),a+=i.path,null!==i.query&&(a+="?"+i.query),null!==r.fragment&&(a+="#"+r.fragment),""===a&&(a="./"),a},t.removeBase=(n,o)=>{if(null===n)return o;n&&!e.isString(n)||(n=t.parse(n||""));let r="";if(""!==n.href?r+=(n.protocol||"")+"//"+(n.authority||""):o.indexOf("//")&&(r+="//"),0!==o.indexOf(r))return o;const i=t.parse(o.substr(r.length)),a=n.normalizedPath.split("/"),s=i.normalizedPath.split("/"),l=i.fragment||i.query?0:1;for(;a.length>0&&s.length>l&&a[0]===s[0];)a.shift(),s.shift();let c="";if(a.length>0){a.pop();for(let e=0;e<a.length;++e)c+="../"}return c+=s.join("/"),null!==i.query&&(c+="?"+i.query),null!==i.fragment&&(c+="#"+i.fragment),""===c&&(c="./"),c},t.removeDotSegments=e=>{if(0===e.length)return"";const t=e.split("/"),n=[];for(;t.length>0;){const e=t.shift(),o=0===t.length;"."!==e?".."!==e?n.push(e):(n.pop(),o&&n.push("")):o&&n.push("")}return"/"===e[0]&&n.length>0&&""!==n[0]&&n.unshift(""),1===n.length&&""===n[0]?"/":n.join("/")};const n=/^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/;return t.isAbsolute=t=>e.isString(t)&&n.test(t),t.isRelative=t=>e.isString(t),fe}const{parseLinkHeader:xe,buildHeaders:be}=le,{LINK_HEADER_CONTEXT:we}=ge,Ie=Z,je=ye(),{prependBase:Se}=me(),ke=/(^|(\r\n))link:/i;const Ne=({secure:e,headers:t={},xhr:n}={headers:{}})=>{t=be(t);return(new je).wrapLoader((async function o(r){if(0!==r.indexOf("http:")&&0!==r.indexOf("https:"))throw new Ie('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:r});if(e&&0!==r.indexOf("https"))throw new Ie('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:r});let i;try{i=await function(e,t,n){e=e||XMLHttpRequest;const o=new e;return new Promise(((e,r)=>{o.onload=()=>e(o),o.onerror=e=>r(e),o.open("GET",t,!0);for(const e in n)o.setRequestHeader(e,n[e]);o.send()}))}(n,r,t)}catch(e){throw new Ie("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:e})}if(i.status>=400)throw new Ie("URL could not be dereferenced: "+i.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:r,httpStatusCode:i.status});let a={contextUrl:null,documentUrl:r,document:i.response},s=null;const l=i.getResponseHeader("Content-Type");let c;ke.test(i.getAllResponseHeaders())&&(c=i.getResponseHeader("Link"));if(c&&"application/ld+json"!==l){const e=xe(c),t=e[we];if(Array.isArray(t))throw new Ie("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r});t&&(a.contextUrl=t.target),s=e.alternate,s&&"application/ld+json"==s.type&&!(l||"").match(/^application\/(\w*\+)?json$/)&&(a=await o(Se(r,s.target)))}return a}))},Ee={};var Oe,De,Ce=Ee;Ee.setupDocumentLoaders=function(e){"undefined"!=typeof XMLHttpRequest&&(e.documentLoaders.xhr=Ne,e.useDocumentLoader("xhr"))},Ee.setupGlobals=function(e){void 0===globalThis.JsonLdProcessor&&Object.defineProperty(globalThis,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:e.JsonLdProcessor})};var Le=Te;function Te(e){var t=this;if(t instanceof Te||(t=new Te),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 Re(e,t,n){var o=t===e.head?new Pe(n,null,t,e):new Pe(n,t,t.next,e);return null===o.next&&(e.tail=o),null===o.prev&&(e.head=o),e.length++,o}function Ae(e,t){e.tail=new Pe(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function _e(e,t){e.head=new Pe(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function Pe(e,t,n,o){if(!(this instanceof Pe))return new Pe(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}Te.Node=Pe,Te.create=Te,Te.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},Te.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++}},Te.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++}},Te.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)Ae(this,arguments[e]);return this.length},Te.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)_e(this,arguments[e]);return this.length},Te.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}},Te.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}},Te.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},Te.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},Te.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},Te.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},Te.prototype.map=function(e,t){t=t||this;for(var n=new Te,o=this.head;null!==o;)n.push(e.call(t,o.value,this)),o=o.next;return n},Te.prototype.mapReverse=function(e,t){t=t||this;for(var n=new Te,o=this.tail;null!==o;)n.push(e.call(t,o.value,this)),o=o.prev;return n},Te.prototype.reduce=function(e,t){var n,o=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");o=this.head.next,n=this.head.value}for(var r=0;null!==o;r++)n=e(n,o.value,r),o=o.next;return n},Te.prototype.reduceReverse=function(e,t){var n,o=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");o=this.tail.prev,n=this.tail.value}for(var r=this.length-1;null!==o;r--)n=e(n,o.value,r),o=o.prev;return n},Te.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},Te.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},Te.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new Te;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,r=this.head;null!==r&&o<e;o++)r=r.next;for(;null!==r&&o<t;o++,r=r.next)n.push(r.value);return n},Te.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new Te;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,r=this.tail;null!==r&&o>t;o--)r=r.prev;for(;null!==r&&o>e;o--,r=r.prev)n.push(r.value);return n},Te.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var o=0,r=this.head;null!==r&&o<e;o++)r=r.next;var i=[];for(o=0;r&&o<t;o++)i.push(r.value),r=this.removeNode(r);null===r&&(r=this.tail),r!==this.head&&r!==this.tail&&(r=r.prev);for(o=0;o<n.length;o++)r=Re(this,r,n[o]);return i},Te.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{(De||(De=1,Oe=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),Oe)(Te)}catch(e){}const Me=Le,Je=Symbol("max"),He=Symbol("length"),Be=Symbol("lengthCalculator"),Fe=Symbol("allowStale"),Ue=Symbol("maxAge"),qe=Symbol("dispose"),Ve=Symbol("noDisposeOnSet"),$e=Symbol("lruList"),Ge=Symbol("cache"),ze=Symbol("updateAgeOnGet"),Ke=()=>1;const Qe=(e,t,n)=>{const o=e[Ge].get(t);if(o){const t=o.value;if(Xe(e,t)){if(Ze(e,o),!e[Fe])return}else n&&(e[ze]&&(o.value.now=Date.now()),e[$e].unshiftNode(o));return t.value}},Xe=(e,t)=>{if(!t||!t.maxAge&&!e[Ue])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[Ue]&&n>e[Ue]},We=e=>{if(e[He]>e[Je])for(let t=e[$e].tail;e[He]>e[Je]&&null!==t;){const n=t.prev;Ze(e,t),t=n}},Ze=(e,t)=>{if(t){const n=t.value;e[qe]&&e[qe](n.key,n.value),e[He]-=n.length,e[Ge].delete(n.key),e[$e].removeNode(t)}};class Ye{constructor(e,t,n,o,r){this.key=e,this.value=t,this.length=n,this.now=o,this.maxAge=r||0}}const et=(e,t,n,o)=>{let r=n.value;Xe(e,r)&&(Ze(e,n),e[Fe]||(r=void 0)),r&&t.call(o,r.value,r.key,e)};var tt=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[Je]=e.max||1/0;const t=e.length||Ke;if(this[Be]="function"!=typeof t?Ke:t,this[Fe]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[Ue]=e.maxAge||0,this[qe]=e.dispose,this[Ve]=e.noDisposeOnSet||!1,this[ze]=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[Je]=e||1/0,We(this)}get max(){return this[Je]}set allowStale(e){this[Fe]=!!e}get allowStale(){return this[Fe]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[Ue]=e,We(this)}get maxAge(){return this[Ue]}set lengthCalculator(e){"function"!=typeof e&&(e=Ke),e!==this[Be]&&(this[Be]=e,this[He]=0,this[$e].forEach((e=>{e.length=this[Be](e.value,e.key),this[He]+=e.length}))),We(this)}get lengthCalculator(){return this[Be]}get length(){return this[He]}get itemCount(){return this[$e].length}rforEach(e,t){t=t||this;for(let n=this[$e].tail;null!==n;){const o=n.prev;et(this,e,n,t),n=o}}forEach(e,t){t=t||this;for(let n=this[$e].head;null!==n;){const o=n.next;et(this,e,n,t),n=o}}keys(){return this[$e].toArray().map((e=>e.key))}values(){return this[$e].toArray().map((e=>e.value))}reset(){this[qe]&&this[$e]&&this[$e].length&&this[$e].forEach((e=>this[qe](e.key,e.value))),this[Ge]=new Map,this[$e]=new Me,this[He]=0}dump(){return this[$e].map((e=>!Xe(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[$e]}set(e,t,n){if((n=n||this[Ue])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const o=n?Date.now():0,r=this[Be](t,e);if(this[Ge].has(e)){if(r>this[Je])return Ze(this,this[Ge].get(e)),!1;const i=this[Ge].get(e).value;return this[qe]&&(this[Ve]||this[qe](e,i.value)),i.now=o,i.maxAge=n,i.value=t,this[He]+=r-i.length,i.length=r,this.get(e),We(this),!0}const i=new Ye(e,t,r,o,n);return i.length>this[Je]?(this[qe]&&this[qe](e,t),!1):(this[He]+=i.length,this[$e].unshift(i),this[Ge].set(e,this[$e].head),We(this),!0)}has(e){if(!this[Ge].has(e))return!1;const t=this[Ge].get(e).value;return!Xe(this,t)}get(e){return Qe(this,e,!0)}peek(e){return Qe(this,e,!1)}pop(){const e=this[$e].tail;return e?(Ze(this,e),e.value):null}del(e){Ze(this,this[Ge].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const o=e[n],r=o.e||0;if(0===r)this.set(o.k,o.v);else{const e=r-t;e>0&&this.set(o.k,o.v,e)}}}prune(){this[Ge].forEach(((e,t)=>Qe(this,t,!1)))}};const nt=tt;const{isArray:ot,isObject:rt,isString:it}=K,{asArray:at}=le,{prependBase:st}=me(),lt=Z,ct=class{constructor({document:e}){this.document=e,this.cache=new nt({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}};function dt(e){throw new lt("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function ut({context:e,base:t}){if(!e)return;const n=e["@context"];if(it(n))e["@context"]=st(t,n);else if(ot(n))for(let e=0;e<n.length;++e){const o=n[e];it(o)?n[e]=st(t,o):rt(o)&&ut({context:{"@context":o},base:t})}else if(rt(n))for(const e in n)ut({context:n[e],base:t})}var pt=G.NQuads;const ht=Z,{isArray:ft}=K,{asArray:vt}=le,gt={};var yt=gt;function mt({event:e,handlers:t}){let n=!0;for(let o=0;n&&o<t.length;++o){n=!1;const r=t[o];if(ft(r))n=mt({event:e,handlers:r});else if("function"==typeof r)r({event:e,next:()=>{n=!0}});else{if("object"!=typeof r)throw new ht("Invalid event handler.","jsonld.InvalidEventHandler",{event:e});e.code in r?r[e.code]({event:e,next:()=>{n=!0}}):n=!0}}return n}gt.defaultEventHandler=null,gt.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?gt.safeEventHandler:[],e.eventHandler?vt(e.eventHandler):[],gt.defaultEventHandler?gt.defaultEventHandler:[]);return 0===t.length?null:t},gt.handleEvent=({event:e,options:t})=>{mt({event:e,handlers:t.eventHandler})};const xt=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"]);gt.safeEventHandler=function({event:e,next:t}){if("warning"===e.level&&xt.has(e.code))throw new ht("Safe mode validation error.","jsonld.ValidationError",{event:e});t()},gt.logEventHandler=function({event:e,next:t}){console.log(`EVENT: ${e.message}`,{event:e}),t()},gt.logWarningEventHandler=function({event:e,next:t}){"warning"===e.level&&console.warn(`WARNING: ${e.message}`,{event:e}),t()},gt.unhandledEventHandler=function({event:e}){throw new ht("No handler for event.","jsonld.UnhandledEvent",{event:e})},gt.setDefaultEventHandler=function({eventHandler:e}={}){gt.defaultEventHandler=e?vt(e):null};const bt=le,wt=Z,{isArray:It,isObject:jt,isString:St,isUndefined:kt}=K,{isAbsolute:Nt,isRelative:Et,prependBase:Ot}=me(),{handleEvent:Dt}=yt,{REGEX_BCP47:Ct,REGEX_KEYWORD:Lt,asArray:Tt,compareShortestLeast:Rt}=le,At=new Map,_t={};var Pt=_t;function Mt(e,t,n,o,r,i){if(null===t||!St(t)||_t.isKeyword(t))return t;if(t.match(Lt))return null;if(o&&o.hasOwnProperty(t)&&!0!==r.get(t)&&_t.createTermDefinition({activeCtx:e,localCtx:o,term:t,defined:r,options:i}),(n=n||{}).vocab){const n=e.mappings.get(t);if(null===n)return null;if(jt(n)&&"@id"in n)return n["@id"]}const a=t.indexOf(":");if(a>0){const n=t.substr(0,a),s=t.substr(a+1);if("_"===n||0===s.indexOf("//"))return t;o&&o.hasOwnProperty(n)&&_t.createTermDefinition({activeCtx:e,localCtx:o,term:n,defined:r,options:i});const l=e.mappings.get(n);if(l&&l._prefix)return l["@id"]+s;if(Nt(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=Ot(i.base,e["@base"]),n=Ot(o,t)):(o=e["@base"],n=t):(o=i.base,n=Ot(i.base,t)),t=n}return t}function Jt(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(!Jt(e[n],t[n]))return!1;return!0}const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const n in e){let o=e[n],r=t[n];if("@container"===n&&Array.isArray(o)&&Array.isArray(r)&&(o=o.slice().sort(),r=r.slice().sort()),!Jt(o,r))return!1}return!0}_t.process=async({activeCtx:e,localCtx:t,options:n,propagate:o=!0,overrideProtected:r=!1,cycles:i=new Set})=>{jt(t)&&"@context"in t&&It(t["@context"])&&(t=t["@context"]);if(0===Tt(t).length)return e;const a=[],s=[({event:e,next:t})=>{a.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});jt(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(!r&&0!==Object.keys(e.protected).length)throw new wt("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});d=e=_t.getInitialContext(n).clone();continue}const c=o.getProcessed(e);if(c){if(l.eventHandler)for(const e of c.events)Dt({event:e,options:l});d=e=c.context;continue}if(jt(s)&&"@context"in s&&(s=s["@context"]),!jt(s))throw new wt("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 wt("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 wt("@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||Nt(e));else{if(!Et(e))throw new wt('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=Ot(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(!St(e))throw new wt('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(!Nt(e)&&_t.processingMode(d,1))throw new wt('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=Mt(d,e,{vocab:!0,base:!0},void 0,void 0,n);Nt(t)||n.eventHandler&&Dt({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(!St(e))throw new wt('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(Ct)||n.eventHandler&&Dt({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 wt("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 wt('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 wt("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if("boolean"!=typeof n)throw new wt("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 wt("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if(!St(o))throw new wt("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:t});const r=await n.contextResolver.resolve({activeCtx:e,context:o,documentLoader:n.documentLoader,base:n.base});if(1!==r.length)throw new wt("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:t});const i=r[0].getProcessed(e);if(i)s=i;else{const n=r[0].document;if("@import"in n)throw new wt("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]);r[0].setProcessed(e,s)}u.set("@import",!0)}u.set("@protected",s["@protected"]||!1);for(const e in s)if(_t.createTermDefinition({activeCtx:d,localCtx:s,term:e,defined:u,options:n,overrideProtected:r}),jt(s[e])&&"@context"in s[e]){const t=s[e]["@context"];let o=!0;if(St(t)){const e=Ot(n.base,t);i.has(e)?o=!1:i.add(e)}if(o)try{await _t.process({activeCtx:d.clone(),localCtx:s[e]["@context"],overrideProtected:!0,options:n,cycles:i})}catch(t){throw new wt("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:a})}return d},_t.createTermDefinition=({activeCtx:e,localCtx:t,term:n,defined:o,options:r,overrideProtected:i=!1})=>{if(o.has(n)){if(o.get(n))return;throw new wt("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:n})}let a;if(o.set(n,!1),t.hasOwnProperty(n)&&(a=t[n]),"@type"===n&&jt(a)&&"@set"===(a["@container"]||"@set")&&_t.processingMode(e,1.1)){const e=["@container","@id","@protected"],o=Object.keys(a);if(0===o.length||o.some((t=>!e.includes(t))))throw new wt("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n})}else{if(_t.isKeyword(n))throw new wt("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n});if(n.match(Lt))return void(r.eventHandler&&Dt({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:n}},options:r}));if(""===n)throw new wt("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((St(a)||null===a)&&(l=!0,a={"@id":a}),!jt(a))throw new wt("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"];_t.processingMode(e,1.1)&&d.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in a)if(!d.includes(e))throw new wt("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 a){if("@id"in a)throw new wt("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});if("@nest"in a)throw new wt("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});const i=a["@reverse"];if(!St(i))throw new wt("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(i.match(Lt))return r.eventHandler&&Dt({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:i}},options:r}),void(s?e.mappings.set(n,s):e.mappings.delete(n));const l=Mt(e,i,{vocab:!0,base:!1},t,o,r);if(!Nt(l))throw new wt("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 a){let i=a["@id"];if(i&&!St(i))throw new wt("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===i)c["@id"]=null;else{if(!_t.isKeyword(i)&&i.match(Lt))return r.eventHandler&&Dt({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:i}},options:r}),void(s?e.mappings.set(n,s):e.mappings.delete(n));if(i!==n){if(i=Mt(e,i,{vocab:!0,base:!1},t,o,r),!Nt(i)&&!_t.isKeyword(i))throw new wt("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(Mt(e,n,{vocab:!0,base:!1},t,new Map(o).set(n,!0),r)!==i)throw new wt("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t})}c["@id"]=i,c._prefix=l&&!c._termHasColon&&null!==i.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in c))if(c._termHasColon){const i=n.substr(0,u);if(t.hasOwnProperty(i)&&_t.createTermDefinition({activeCtx:e,localCtx:t,term:i,defined:o,options:r}),e.mappings.has(i)){const t=n.substr(u+1);c["@id"]=e.mappings.get(i)["@id"]+t}else c["@id"]=n}else if("@type"===n)c["@id"]=n;else{if(!("@vocab"in e))throw new wt("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===a["@protected"]||!0===o.get("@protected")&&!1!==a["@protected"])&&(e.protected[n]=!0,c.protected=!0),o.set(n,!0),"@type"in a){let n=a["@type"];if(!St(n))throw new wt("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(_t.processingMode(e,1))throw new wt(`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=Mt(e,n,{vocab:!0,base:!1},t,o,r),!Nt(n))throw new wt("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 wt("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 a){const n=St(a["@container"])?[a["@container"]]:a["@container"]||[],o=["@list","@set","@index","@language"];let r=!0;const i=n.includes("@set");if(_t.processingMode(e,1.1)){if(o.push("@graph","@id","@type"),n.includes("@list")){if(1!==n.length)throw new wt("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 wt("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 r&=n.length<=(i?2:1);if(n.includes("@type")&&(c["@type"]=c["@type"]||"@id",!["@id","@vocab"].includes(c["@type"])))throw new wt("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else r&=!It(a["@container"]),r&=n.length<=1;if(r&=n.every((e=>o.includes(e))),r&=!(i&&n.includes("@list")),!r)throw new wt("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 wt("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 a){if(!("@container"in a)||!c["@container"].includes("@index"))throw new wt(`Invalid JSON-LD syntax; @index without @index in @container: "${a["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});if(!St(a["@index"])||0===a["@index"].indexOf("@"))throw new wt(`Invalid JSON-LD syntax; @index must expand to an IRI: "${a["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});c["@index"]=a["@index"]}if("@context"in a&&(c["@context"]=a["@context"]),"@language"in a&&!("@type"in a)){let e=a["@language"];if(null!==e&&!St(e))throw new wt("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 a){if(n.match(/:|\//))throw new wt("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:t});if(_t.isKeyword(c["@id"]))throw new wt("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:t});if("boolean"!=typeof a["@prefix"])throw new wt("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:t});c._prefix=!0===a["@prefix"]}if("@direction"in a){const e=a["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new wt('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 a){const e=a["@nest"];if(!St(e)||"@nest"!==e&&0===e.indexOf("@"))throw new wt("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}
25
+ */const U=f,q=B;var V=class extends q{constructor(){super(),this.name="URGNA2012",this.createMessageDigest=()=>new U("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 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"}const a=this.hashRelatedBlankNode(i,r,t,o),s=n.get(a);s?s.push(i):n.set(a,[i])}return n}},$=c(Object.freeze({__proto__:null,default:{}}));!function(e){const t=L,n=_,o=B,r=V;let i;try{i=$}catch(e){}function a(t){return Array.isArray(t)?t:e.NQuads.legacyDatasetToQuads(t)}e.NQuads=j,e.IdentifierIssuer=p,e._rdfCanonizeNative=function(e){return e&&(i=e),i},e.canonize=async function(e,o){const r=a(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(r,o,((n,o)=>n?t(n):e(o)))))}if("URDNA2015"===o.algorithm)return new t(o).main(r);if("URGNA2012"===o.algorithm){if(o.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "URGNA2012".');return new n(o).main(r)}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=a(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 r(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)}}(u);var G=u;const z={};var K=z;z.isArray=Array.isArray,z.isBoolean=e=>"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e),z.isDouble=e=>z.isNumber(e)&&(-1!==String(e).indexOf(".")||Math.abs(e)>=1e21),z.isEmptyObject=e=>z.isObject(e)&&0===Object.keys(e).length,z.isNumber=e=>"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e),z.isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),z.isObject=e=>"[object Object]"===Object.prototype.toString.call(e),z.isString=e=>"string"==typeof e||"[object String]"===Object.prototype.toString.call(e),z.isUndefined=e=>void 0===e;const Q=K,W={};var X=W;W.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},W.isSubjectReference=e=>Q.isObject(e)&&1===Object.keys(e).length&&"@id"in e,W.isValue=e=>Q.isObject(e)&&"@value"in e,W.isList=e=>Q.isObject(e)&&"@list"in e,W.isGraph=e=>Q.isObject(e)&&"@graph"in e&&1===Object.keys(e).filter((e=>"@id"!==e&&"@index"!==e)).length,W.isSimpleGraph=e=>W.isGraph(e)&&!("@id"in e),W.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 Y=X,ee=K,te=G.IdentifierIssuer,ne=Z,oe=/(?:<[^>]*?>|"[^"]*?"|[^,])+/g,re=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,ie=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g,ae={accept:"application/ld+json, application/json"},se={};var le=se;function ce(e,t){if(ee.isArray(t))for(let n=0;n<t.length;++n)t[n]=ce(e,t[n]);else if(Y.isList(t))t["@list"]=ce(e,t["@list"]);else if(ee.isObject(t)){Y.isBlankNode(t)&&(t["@id"]=e.getId(t["@id"]));const n=Object.keys(t).sort();for(let o=0;o<n.length;++o){const r=n[o];"@id"!==r&&(t[r]=ce(e,t[r]))}}return t}se.IdentifierIssuer=te,se.REGEX_BCP47=/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/,se.REGEX_KEYWORD=/^@[a-zA-Z]+$/,se.clone=function(e){if(e&&"object"==typeof e){let t;if(ee.isArray(e)){t=[];for(let n=0;n<e.length;++n)t[n]=se.clone(e[n])}else if(e instanceof Map){t=new Map;for(const[n,o]of e)t.set(n,se.clone(o))}else if(e instanceof Set){t=new Set;for(const n of e)t.add(se.clone(n))}else if(ee.isObject(e)){t={};for(const n in e)t[n]=se.clone(e[n])}else t=e.toString();return t}return e},se.asArray=function(e){return Array.isArray(e)?e:[e]},se.buildHeaders=(e={})=>{if(Object.keys(e).some((e=>"accept"===e.toLowerCase())))throw new RangeError('Accept header may not be specified; only "'+ae.accept+'" is supported.');return Object.assign({Accept:ae.accept},e)},se.parseLinkHeader=e=>{const t={},n=e.match(oe);for(let e=0;e<n.length;++e){let o=n[e].match(re);if(!o)continue;const r={target:o[1]},i=o[2];for(;o=ie.exec(i);)r[o[1]]=void 0===o[2]?o[3]:o[2];const a=r.rel||"";Array.isArray(t[a])?t[a].push(r):t.hasOwnProperty(a)?t[a]=[t[a],r]:t[a]=r}return t},se.validateTypeValue=(e,t)=>{if(!(ee.isString(e)||ee.isArray(e)&&e.every((e=>ee.isString(e))))){if(t&&ee.isObject(e))switch(Object.keys(e).length){case 0:return;case 1:if("@default"in e&&se.asArray(e["@default"]).every((e=>ee.isString(e))))return}throw new ne('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})}},se.hasProperty=(e,t)=>{if(e.hasOwnProperty(t)){const n=e[t];return!ee.isArray(n)||n.length>0}return!1},se.hasValue=(e,t,n)=>{if(se.hasProperty(e,t)){let o=e[t];const r=Y.isList(o);if(ee.isArray(o)||r){r&&(o=o["@list"]);for(let e=0;e<o.length;++e)if(se.compareValues(n,o[e]))return!0}else if(!ee.isArray(n))return se.compareValues(n,o)}return!1},se.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(ee.isArray(n)){0===n.length&&o.propertyIsArray&&!e.hasOwnProperty(t)&&(e[t]=[]),o.prependValue&&(n=n.concat(e[t]),e[t]=[]);for(let r=0;r<n.length;++r)se.addValue(e,t,n[r],o)}else if(e.hasOwnProperty(t)){const r=!o.allowDuplicate&&se.hasValue(e,t,n);ee.isArray(e[t])||r&&!o.propertyIsArray||(e[t]=[e[t]]),r||(o.prependValue?e[t].unshift(n):e[t].push(n))}else e[t]=o.propertyIsArray?[n]:n},se.getValues=(e,t)=>[].concat(e[t]||[]),se.removeProperty=(e,t)=>{delete e[t]},se.removeValue=(e,t,n,o)=>{"propertyIsArray"in(o=o||{})||(o.propertyIsArray=!1);const r=se.getValues(e,t).filter((e=>!se.compareValues(e,n)));0===r.length?se.removeProperty(e,t):1!==r.length||o.propertyIsArray?e[t]=r:e[t]=r[0]},se.relabelBlankNodes=(e,t)=>ce((t=t||{}).issuer||new te("_:b"),e),se.compareValues=(e,t)=>e===t||(!(!Y.isValue(e)||!Y.isValue(t)||e["@value"]!==t["@value"]||e["@type"]!==t["@type"]||e["@language"]!==t["@language"]||e["@index"]!==t["@index"])||!!(ee.isObject(e)&&"@id"in e&&ee.isObject(t)&&"@id"in t)&&e["@id"]===t["@id"]),se.compareShortestLeast=(e,t)=>e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1;const de="http://www.w3.org/1999/02/22-rdf-syntax-ns#",ue="http://www.w3.org/2001/XMLSchema#";var pe,he,fe,ve,ge={LINK_HEADER_CONTEXT:"http://www.w3.org/ns/json-ld#context",RDF_LIST:de+"List",RDF_FIRST:de+"first",RDF_REST:de+"rest",RDF_NIL:de+"nil",RDF_TYPE:de+"type",RDF_JSON_LITERAL:de+"JSON",RDF_LANGSTRING:de+"langString",XSD_BOOLEAN:ue+"boolean",XSD_DOUBLE:ue+"double",XSD_INTEGER:ue+"integer",XSD_STRING:ue+"string"};function ye(){return he||(he=1,pe=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]}}}),pe}function me(){if(ve)return fe;ve=1;const e=K,t={};fe=t,t.parsers={simple:{keys:["href","scheme","authority","path","query","fragment"],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:["href","protocol","scheme","authority","auth","user","password","hostname","port","path","directory","file","query","fragment"],regex:/^(([a-zA-Z][a-zA-Z0-9+-.]*):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},t.parse=(e,n)=>{const o={},r=t.parsers[n||"full"],i=r.regex.exec(e);let a=r.keys.length;for(;a--;)o[r.keys[a]]=void 0===i[a]?null:i[a];return("https"===o.scheme&&"443"===o.port||"http"===o.scheme&&"80"===o.port)&&(o.href=o.href.replace(":"+o.port,""),o.authority=o.authority.replace(":"+o.port,""),o.port=null),o.normalizedPath=t.removeDotSegments(o.path),o},t.prependBase=(n,o)=>{if(null===n)return o;if(t.isAbsolute(o))return o;n&&!e.isString(n)||(n=t.parse(n||""));const r=t.parse(o),i={protocol:n.protocol||""};if(null!==r.authority)i.authority=r.authority,i.path=r.path,i.query=r.query;else if(i.authority=n.authority,""===r.path)i.path=n.path,null!==r.query?i.query=r.query:i.query=n.query;else{if(0===r.path.indexOf("/"))i.path=r.path;else{let e=n.path;e=e.substr(0,e.lastIndexOf("/")+1),(e.length>0||n.authority)&&"/"!==e.substr(-1)&&(e+="/"),e+=r.path,i.path=e}i.query=r.query}""!==r.path&&(i.path=t.removeDotSegments(i.path));let a=i.protocol;return null!==i.authority&&(a+="//"+i.authority),a+=i.path,null!==i.query&&(a+="?"+i.query),null!==r.fragment&&(a+="#"+r.fragment),""===a&&(a="./"),a},t.removeBase=(n,o)=>{if(null===n)return o;n&&!e.isString(n)||(n=t.parse(n||""));let r="";if(""!==n.href?r+=(n.protocol||"")+"//"+(n.authority||""):o.indexOf("//")&&(r+="//"),0!==o.indexOf(r))return o;const i=t.parse(o.substr(r.length)),a=n.normalizedPath.split("/"),s=i.normalizedPath.split("/"),l=i.fragment||i.query?0:1;for(;a.length>0&&s.length>l&&a[0]===s[0];)a.shift(),s.shift();let c="";if(a.length>0){a.pop();for(let e=0;e<a.length;++e)c+="../"}return c+=s.join("/"),null!==i.query&&(c+="?"+i.query),null!==i.fragment&&(c+="#"+i.fragment),""===c&&(c="./"),c},t.removeDotSegments=e=>{if(0===e.length)return"";const t=e.split("/"),n=[];for(;t.length>0;){const e=t.shift(),o=0===t.length;"."!==e?".."!==e?n.push(e):(n.pop(),o&&n.push("")):o&&n.push("")}return"/"===e[0]&&n.length>0&&""!==n[0]&&n.unshift(""),1===n.length&&""===n[0]?"/":n.join("/")};const n=/^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/;return t.isAbsolute=t=>e.isString(t)&&n.test(t),t.isRelative=t=>e.isString(t),fe}const{parseLinkHeader:xe,buildHeaders:be}=le,{LINK_HEADER_CONTEXT:we}=ge,Ie=Z,je=ye(),{prependBase:Se}=me(),ke=/(^|(\r\n))link:/i;const Ne=({secure:e,headers:t={},xhr:n}={headers:{}})=>{t=be(t);return(new je).wrapLoader((async function o(r){if(0!==r.indexOf("http:")&&0!==r.indexOf("https:"))throw new Ie('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:r});if(e&&0!==r.indexOf("https"))throw new Ie('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:r});let i;try{i=await function(e,t,n){e=e||XMLHttpRequest;const o=new e;return new Promise(((e,r)=>{o.onload=()=>e(o),o.onerror=e=>r(e),o.open("GET",t,!0);for(const e in n)o.setRequestHeader(e,n[e]);o.send()}))}(n,r,t)}catch(e){throw new Ie("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:e})}if(i.status>=400)throw new Ie("URL could not be dereferenced: "+i.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:r,httpStatusCode:i.status});let a={contextUrl:null,documentUrl:r,document:i.response},s=null;const l=i.getResponseHeader("Content-Type");let c;ke.test(i.getAllResponseHeaders())&&(c=i.getResponseHeader("Link"));if(c&&"application/ld+json"!==l){const e=xe(c),t=e[we];if(Array.isArray(t))throw new Ie("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r});t&&(a.contextUrl=t.target),s=e.alternate,s&&"application/ld+json"==s.type&&!(l||"").match(/^application\/(\w*\+)?json$/)&&(a=await o(Se(r,s.target)))}return a}))},Oe={};var Ee,De,Ce=Oe;Oe.setupDocumentLoaders=function(e){"undefined"!=typeof XMLHttpRequest&&(e.documentLoaders.xhr=Ne,e.useDocumentLoader("xhr"))},Oe.setupGlobals=function(e){void 0===globalThis.JsonLdProcessor&&Object.defineProperty(globalThis,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:e.JsonLdProcessor})};var Le=Te;function Te(e){var t=this;if(t instanceof Te||(t=new Te),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 Re(e,t,n){var o=t===e.head?new Pe(n,null,t,e):new Pe(n,t,t.next,e);return null===o.next&&(e.tail=o),null===o.prev&&(e.head=o),e.length++,o}function Ae(e,t){e.tail=new Pe(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function _e(e,t){e.head=new Pe(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function Pe(e,t,n,o){if(!(this instanceof Pe))return new Pe(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}Te.Node=Pe,Te.create=Te,Te.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},Te.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++}},Te.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++}},Te.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)Ae(this,arguments[e]);return this.length},Te.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)_e(this,arguments[e]);return this.length},Te.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}},Te.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}},Te.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},Te.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},Te.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},Te.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},Te.prototype.map=function(e,t){t=t||this;for(var n=new Te,o=this.head;null!==o;)n.push(e.call(t,o.value,this)),o=o.next;return n},Te.prototype.mapReverse=function(e,t){t=t||this;for(var n=new Te,o=this.tail;null!==o;)n.push(e.call(t,o.value,this)),o=o.prev;return n},Te.prototype.reduce=function(e,t){var n,o=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");o=this.head.next,n=this.head.value}for(var r=0;null!==o;r++)n=e(n,o.value,r),o=o.next;return n},Te.prototype.reduceReverse=function(e,t){var n,o=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");o=this.tail.prev,n=this.tail.value}for(var r=this.length-1;null!==o;r--)n=e(n,o.value,r),o=o.prev;return n},Te.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},Te.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},Te.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new Te;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,r=this.head;null!==r&&o<e;o++)r=r.next;for(;null!==r&&o<t;o++,r=r.next)n.push(r.value);return n},Te.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new Te;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,r=this.tail;null!==r&&o>t;o--)r=r.prev;for(;null!==r&&o>e;o--,r=r.prev)n.push(r.value);return n},Te.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var o=0,r=this.head;null!==r&&o<e;o++)r=r.next;var i=[];for(o=0;r&&o<t;o++)i.push(r.value),r=this.removeNode(r);null===r&&(r=this.tail),r!==this.head&&r!==this.tail&&(r=r.prev);for(o=0;o<n.length;o++)r=Re(this,r,n[o]);return i},Te.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{(De||(De=1,Ee=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),Ee)(Te)}catch(e){}const Me=Le,Je=Symbol("max"),He=Symbol("length"),Be=Symbol("lengthCalculator"),Fe=Symbol("allowStale"),Ue=Symbol("maxAge"),qe=Symbol("dispose"),Ve=Symbol("noDisposeOnSet"),$e=Symbol("lruList"),Ge=Symbol("cache"),ze=Symbol("updateAgeOnGet"),Ke=()=>1;const Qe=(e,t,n)=>{const o=e[Ge].get(t);if(o){const t=o.value;if(We(e,t)){if(Ze(e,o),!e[Fe])return}else n&&(e[ze]&&(o.value.now=Date.now()),e[$e].unshiftNode(o));return t.value}},We=(e,t)=>{if(!t||!t.maxAge&&!e[Ue])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[Ue]&&n>e[Ue]},Xe=e=>{if(e[He]>e[Je])for(let t=e[$e].tail;e[He]>e[Je]&&null!==t;){const n=t.prev;Ze(e,t),t=n}},Ze=(e,t)=>{if(t){const n=t.value;e[qe]&&e[qe](n.key,n.value),e[He]-=n.length,e[Ge].delete(n.key),e[$e].removeNode(t)}};class Ye{constructor(e,t,n,o,r){this.key=e,this.value=t,this.length=n,this.now=o,this.maxAge=r||0}}const et=(e,t,n,o)=>{let r=n.value;We(e,r)&&(Ze(e,n),e[Fe]||(r=void 0)),r&&t.call(o,r.value,r.key,e)};var tt=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[Je]=e.max||1/0;const t=e.length||Ke;if(this[Be]="function"!=typeof t?Ke:t,this[Fe]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[Ue]=e.maxAge||0,this[qe]=e.dispose,this[Ve]=e.noDisposeOnSet||!1,this[ze]=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[Je]=e||1/0,Xe(this)}get max(){return this[Je]}set allowStale(e){this[Fe]=!!e}get allowStale(){return this[Fe]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[Ue]=e,Xe(this)}get maxAge(){return this[Ue]}set lengthCalculator(e){"function"!=typeof e&&(e=Ke),e!==this[Be]&&(this[Be]=e,this[He]=0,this[$e].forEach((e=>{e.length=this[Be](e.value,e.key),this[He]+=e.length}))),Xe(this)}get lengthCalculator(){return this[Be]}get length(){return this[He]}get itemCount(){return this[$e].length}rforEach(e,t){t=t||this;for(let n=this[$e].tail;null!==n;){const o=n.prev;et(this,e,n,t),n=o}}forEach(e,t){t=t||this;for(let n=this[$e].head;null!==n;){const o=n.next;et(this,e,n,t),n=o}}keys(){return this[$e].toArray().map((e=>e.key))}values(){return this[$e].toArray().map((e=>e.value))}reset(){this[qe]&&this[$e]&&this[$e].length&&this[$e].forEach((e=>this[qe](e.key,e.value))),this[Ge]=new Map,this[$e]=new Me,this[He]=0}dump(){return this[$e].map((e=>!We(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[$e]}set(e,t,n){if((n=n||this[Ue])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const o=n?Date.now():0,r=this[Be](t,e);if(this[Ge].has(e)){if(r>this[Je])return Ze(this,this[Ge].get(e)),!1;const i=this[Ge].get(e).value;return this[qe]&&(this[Ve]||this[qe](e,i.value)),i.now=o,i.maxAge=n,i.value=t,this[He]+=r-i.length,i.length=r,this.get(e),Xe(this),!0}const i=new Ye(e,t,r,o,n);return i.length>this[Je]?(this[qe]&&this[qe](e,t),!1):(this[He]+=i.length,this[$e].unshift(i),this[Ge].set(e,this[$e].head),Xe(this),!0)}has(e){if(!this[Ge].has(e))return!1;const t=this[Ge].get(e).value;return!We(this,t)}get(e){return Qe(this,e,!0)}peek(e){return Qe(this,e,!1)}pop(){const e=this[$e].tail;return e?(Ze(this,e),e.value):null}del(e){Ze(this,this[Ge].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const o=e[n],r=o.e||0;if(0===r)this.set(o.k,o.v);else{const e=r-t;e>0&&this.set(o.k,o.v,e)}}}prune(){this[Ge].forEach(((e,t)=>Qe(this,t,!1)))}};const nt=tt;const{isArray:ot,isObject:rt,isString:it}=K,{asArray:at}=le,{prependBase:st}=me(),lt=Z,ct=class{constructor({document:e}){this.document=e,this.cache=new nt({max:10})}getProcessed(e){return this.cache.get(e)}setProcessed(e,t){this.cache.set(e,t)}};function dt(e){throw new lt("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:e})}function ut({context:e,base:t}){if(!e)return;const n=e["@context"];if(it(n))e["@context"]=st(t,n);else if(ot(n))for(let e=0;e<n.length;++e){const o=n[e];it(o)?n[e]=st(t,o):rt(o)&&ut({context:{"@context":o},base:t})}else if(rt(n))for(const e in n)ut({context:n[e],base:t})}var pt=G.NQuads;const ht=Z,{isArray:ft}=K,{asArray:vt}=le,gt={};var yt=gt;function mt({event:e,handlers:t}){let n=!0;for(let o=0;n&&o<t.length;++o){n=!1;const r=t[o];if(ft(r))n=mt({event:e,handlers:r});else if("function"==typeof r)r({event:e,next:()=>{n=!0}});else{if("object"!=typeof r)throw new ht("Invalid event handler.","jsonld.InvalidEventHandler",{event:e});e.code in r?r[e.code]({event:e,next:()=>{n=!0}}):n=!0}}return n}gt.defaultEventHandler=null,gt.setupEventHandler=({options:e={}})=>{const t=[].concat(e.safe?gt.safeEventHandler:[],e.eventHandler?vt(e.eventHandler):[],gt.defaultEventHandler?gt.defaultEventHandler:[]);return 0===t.length?null:t},gt.handleEvent=({event:e,options:t})=>{mt({event:e,handlers:t.eventHandler})};const xt=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"]);gt.safeEventHandler=function({event:e,next:t}){if("warning"===e.level&&xt.has(e.code))throw new ht("Safe mode validation error.","jsonld.ValidationError",{event:e});t()},gt.logEventHandler=function({event:e,next:t}){console.log(`EVENT: ${e.message}`,{event:e}),t()},gt.logWarningEventHandler=function({event:e,next:t}){"warning"===e.level&&console.warn(`WARNING: ${e.message}`,{event:e}),t()},gt.unhandledEventHandler=function({event:e}){throw new ht("No handler for event.","jsonld.UnhandledEvent",{event:e})},gt.setDefaultEventHandler=function({eventHandler:e}={}){gt.defaultEventHandler=e?vt(e):null};const bt=le,wt=Z,{isArray:It,isObject:jt,isString:St,isUndefined:kt}=K,{isAbsolute:Nt,isRelative:Ot,prependBase:Et}=me(),{handleEvent:Dt}=yt,{REGEX_BCP47:Ct,REGEX_KEYWORD:Lt,asArray:Tt,compareShortestLeast:Rt}=le,At=new Map,_t={};var Pt=_t;function Mt(e,t,n,o,r,i){if(null===t||!St(t)||_t.isKeyword(t))return t;if(t.match(Lt))return null;if(o&&o.hasOwnProperty(t)&&!0!==r.get(t)&&_t.createTermDefinition({activeCtx:e,localCtx:o,term:t,defined:r,options:i}),(n=n||{}).vocab){const n=e.mappings.get(t);if(null===n)return null;if(jt(n)&&"@id"in n)return n["@id"]}const a=t.indexOf(":");if(a>0){const n=t.substr(0,a),s=t.substr(a+1);if("_"===n||0===s.indexOf("//"))return t;o&&o.hasOwnProperty(n)&&_t.createTermDefinition({activeCtx:e,localCtx:o,term:n,defined:r,options:i});const l=e.mappings.get(n);if(l&&l._prefix)return l["@id"]+s;if(Nt(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=Et(i.base,e["@base"]),n=Et(o,t)):(o=e["@base"],n=t):(o=i.base,n=Et(i.base,t)),t=n}return t}function Jt(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(!Jt(e[n],t[n]))return!1;return!0}const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const n in e){let o=e[n],r=t[n];if("@container"===n&&Array.isArray(o)&&Array.isArray(r)&&(o=o.slice().sort(),r=r.slice().sort()),!Jt(o,r))return!1}return!0}_t.process=async({activeCtx:e,localCtx:t,options:n,propagate:o=!0,overrideProtected:r=!1,cycles:i=new Set})=>{jt(t)&&"@context"in t&&It(t["@context"])&&(t=t["@context"]);if(0===Tt(t).length)return e;const a=[],s=[({event:e,next:t})=>{a.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});jt(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(!r&&0!==Object.keys(e.protected).length)throw new wt("Tried to nullify a context with protected terms outside of a term definition.","jsonld.SyntaxError",{code:"invalid context nullification"});d=e=_t.getInitialContext(n).clone();continue}const c=o.getProcessed(e);if(c){if(l.eventHandler)for(const e of c.events)Dt({event:e,options:l});d=e=c.context;continue}if(jt(s)&&"@context"in s&&(s=s["@context"]),!jt(s))throw new wt("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 wt("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 wt("@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||Nt(e));else{if(!Ot(e))throw new wt('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=Et(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(!St(e))throw new wt('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(!Nt(e)&&_t.processingMode(d,1))throw new wt('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=Mt(d,e,{vocab:!0,base:!0},void 0,void 0,n);Nt(t)||n.eventHandler&&Dt({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(!St(e))throw new wt('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(Ct)||n.eventHandler&&Dt({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 wt("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 wt('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 wt("Invalid JSON-LD syntax; @propagate not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if("boolean"!=typeof n)throw new wt("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 wt("Invalid JSON-LD syntax; @import not compatible with "+e.processingMode,"jsonld.SyntaxError",{code:"invalid context entry",context:s});if(!St(o))throw new wt("Invalid JSON-LD syntax; @import must be a string.","jsonld.SyntaxError",{code:"invalid @import value",context:t});const r=await n.contextResolver.resolve({activeCtx:e,context:o,documentLoader:n.documentLoader,base:n.base});if(1!==r.length)throw new wt("Invalid JSON-LD syntax; @import must reference a single context.","jsonld.SyntaxError",{code:"invalid remote context",context:t});const i=r[0].getProcessed(e);if(i)s=i;else{const n=r[0].document;if("@import"in n)throw new wt("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]);r[0].setProcessed(e,s)}u.set("@import",!0)}u.set("@protected",s["@protected"]||!1);for(const e in s)if(_t.createTermDefinition({activeCtx:d,localCtx:s,term:e,defined:u,options:n,overrideProtected:r}),jt(s[e])&&"@context"in s[e]){const t=s[e]["@context"];let o=!0;if(St(t)){const e=Et(n.base,t);i.has(e)?o=!1:i.add(e)}if(o)try{await _t.process({activeCtx:d.clone(),localCtx:s[e]["@context"],overrideProtected:!0,options:n,cycles:i})}catch(t){throw new wt("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:a})}return d},_t.createTermDefinition=({activeCtx:e,localCtx:t,term:n,defined:o,options:r,overrideProtected:i=!1})=>{if(o.has(n)){if(o.get(n))return;throw new wt("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:n})}let a;if(o.set(n,!1),t.hasOwnProperty(n)&&(a=t[n]),"@type"===n&&jt(a)&&"@set"===(a["@container"]||"@set")&&_t.processingMode(e,1.1)){const e=["@container","@id","@protected"],o=Object.keys(a);if(0===o.length||o.some((t=>!e.includes(t))))throw new wt("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n})}else{if(_t.isKeyword(n))throw new wt("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n});if(n.match(Lt))return void(r.eventHandler&&Dt({event:{type:["JsonLdEvent"],code:"reserved term",level:"warning",message:'Terms beginning with "@" are reserved for future use and dropped.',details:{term:n}},options:r}));if(""===n)throw new wt("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((St(a)||null===a)&&(l=!0,a={"@id":a}),!jt(a))throw new wt("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"];_t.processingMode(e,1.1)&&d.push("@context","@direction","@index","@nest","@prefix","@protected");for(const e in a)if(!d.includes(e))throw new wt("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 a){if("@id"in a)throw new wt("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});if("@nest"in a)throw new wt("Invalid JSON-LD syntax; a @reverse term definition must not contain @nest.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});const i=a["@reverse"];if(!St(i))throw new wt("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(i.match(Lt))return r.eventHandler&&Dt({event:{type:["JsonLdEvent"],code:"reserved @reverse value",level:"warning",message:'@reverse values beginning with "@" are reserved for future use and dropped.',details:{reverse:i}},options:r}),void(s?e.mappings.set(n,s):e.mappings.delete(n));const l=Mt(e,i,{vocab:!0,base:!1},t,o,r);if(!Nt(l))throw new wt("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 a){let i=a["@id"];if(i&&!St(i))throw new wt("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===i)c["@id"]=null;else{if(!_t.isKeyword(i)&&i.match(Lt))return r.eventHandler&&Dt({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:'@id values beginning with "@" are reserved for future use and dropped.',details:{id:i}},options:r}),void(s?e.mappings.set(n,s):e.mappings.delete(n));if(i!==n){if(i=Mt(e,i,{vocab:!0,base:!1},t,o,r),!Nt(i)&&!_t.isKeyword(i))throw new wt("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(Mt(e,n,{vocab:!0,base:!1},t,new Map(o).set(n,!0),r)!==i)throw new wt("Invalid JSON-LD syntax; term in form of IRI must expand to definition.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t})}c["@id"]=i,c._prefix=l&&!c._termHasColon&&null!==i.match(/[:\/\?#\[\]@]$/)}}}if(!("@id"in c))if(c._termHasColon){const i=n.substr(0,u);if(t.hasOwnProperty(i)&&_t.createTermDefinition({activeCtx:e,localCtx:t,term:i,defined:o,options:r}),e.mappings.has(i)){const t=n.substr(u+1);c["@id"]=e.mappings.get(i)["@id"]+t}else c["@id"]=n}else if("@type"===n)c["@id"]=n;else{if(!("@vocab"in e))throw new wt("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===a["@protected"]||!0===o.get("@protected")&&!1!==a["@protected"])&&(e.protected[n]=!0,c.protected=!0),o.set(n,!0),"@type"in a){let n=a["@type"];if(!St(n))throw new wt("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(_t.processingMode(e,1))throw new wt(`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=Mt(e,n,{vocab:!0,base:!1},t,o,r),!Nt(n))throw new wt("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 wt("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 a){const n=St(a["@container"])?[a["@container"]]:a["@container"]||[],o=["@list","@set","@index","@language"];let r=!0;const i=n.includes("@set");if(_t.processingMode(e,1.1)){if(o.push("@graph","@id","@type"),n.includes("@list")){if(1!==n.length)throw new wt("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 wt("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 r&=n.length<=(i?2:1);if(n.includes("@type")&&(c["@type"]=c["@type"]||"@id",!["@id","@vocab"].includes(c["@type"])))throw new wt("Invalid JSON-LD syntax; container: @type requires @type to be @id or @vocab.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}else r&=!It(a["@container"]),r&=n.length<=1;if(r&=n.every((e=>o.includes(e))),r&=!(i&&n.includes("@list")),!r)throw new wt("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 wt("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 a){if(!("@container"in a)||!c["@container"].includes("@index"))throw new wt(`Invalid JSON-LD syntax; @index without @index in @container: "${a["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});if(!St(a["@index"])||0===a["@index"].indexOf("@"))throw new wt(`Invalid JSON-LD syntax; @index must expand to an IRI: "${a["@index"]}" on term "${n}".`,"jsonld.SyntaxError",{code:"invalid term definition",context:t});c["@index"]=a["@index"]}if("@context"in a&&(c["@context"]=a["@context"]),"@language"in a&&!("@type"in a)){let e=a["@language"];if(null!==e&&!St(e))throw new wt("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 a){if(n.match(/:|\//))throw new wt("Invalid JSON-LD syntax; @context @prefix used on a compact IRI term","jsonld.SyntaxError",{code:"invalid term definition",context:t});if(_t.isKeyword(c["@id"]))throw new wt("Invalid JSON-LD syntax; keywords may not be used as prefixes","jsonld.SyntaxError",{code:"invalid term definition",context:t});if("boolean"!=typeof a["@prefix"])throw new wt("Invalid JSON-LD syntax; @context value for @prefix must be boolean","jsonld.SyntaxError",{code:"invalid @prefix value",context:t});c._prefix=!0===a["@prefix"]}if("@direction"in a){const e=a["@direction"];if(null!==e&&"ltr"!==e&&"rtl"!==e)throw new wt('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 a){const e=a["@nest"];if(!St(e)||"@nest"!==e&&0===e.indexOf("@"))throw new wt("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
26
  // disallow aliasing @context and @preserve
27
- const p=c["@id"];if("@context"===p||"@preserve"===p)throw new wt("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t});if(s&&s.protected&&!i&&(e.protected[n]=!0,c.protected=!0,!Jt(s,c)))throw new wt("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:t,term:n})},_t.expandIri=(e,t,n,o)=>Mt(e,t,n,void 0,void 0,o),_t.getInitialContext=e=>{const t=JSON.stringify({processingMode:e.processingMode}),n=At.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={},a=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],l=e.mappings,c=[...l.keys()].sort(Rt);for(const e of c){const r=l.get(e);if(null===r)continue;let c=r["@container"]||"@none";if(c=[].concat(c).sort().join(""),null===r["@id"])continue;const d=Tt(r["@id"]);for(const l of d){let d=t[l];const u=_t.isKeyword(l);if(d)u||r._termHasColon||o[l].push(e);else if(t[l]=d={},!u&&!r._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],i(e,d["@any"],"@none"),r.reverse)i(e,d["@type"],"@reverse");else if("@none"===r["@type"])i(e,d["@any"],"@none"),i(e,d["@language"],"@none"),i(e,d["@type"],"@none");else if("@type"in r)i(e,d["@type"],r["@type"]);else if("@language"in r&&"@direction"in r){const t=r["@language"],n=r["@direction"];i(e,d["@language"],t&&n?`${t}_${n}`.toLowerCase():t?t.toLowerCase():n?`_${n}`:"@null")}else"@language"in r?i(e,d["@language"],(r["@language"]||"@null").toLowerCase()):"@direction"in r?r["@direction"]?i(e,d["@language"],`_${r["@direction"]}`):i(e,d["@language"],"@none"):s?(i(e,d["@language"],`_${s}`),i(e,d["@language"],"@none"),i(e,d["@type"],"@none")):(i(e,d["@language"],a),i(e,d["@language"],"@none"),i(e,d["@type"],"@none"))}}for(const e in n)r(n,e,1);return t},clone:function(){const e={};e.mappings=bt.clone(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,e.protected=bt.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===At.size&&At.clear(),At.set(t,o),o;function r(e,t,n){const o=e[t],i=e[t]={};let a,s;for(const e of o)a=e.iri,s=n>=a.length?"":a[n],s in i?i[s].push(e):i[s]=[e];for(const e in i)""!==e&&r(i,e,n+1)}function i(e,t,n){t.hasOwnProperty(n)||(t[n]=e)}},_t.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(kt(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},_t.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,_t.isKeyword=e=>{if(!St(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 Ht=Z,{isArray:Bt,isObject:Ft,isEmptyObject:Ut,isString:qt,isUndefined:Vt}=K,{isList:$t,isValue:Gt,isGraph:zt,isSubject:Kt}=W,{expandIri:Qt,getContextValue:Xt,isKeyword:Wt,process:Zt,processingMode:Yt}=Pt,{isAbsolute:en}=me(),{REGEX_BCP47:tn,REGEX_KEYWORD:nn,addValue:on,asArray:rn,getValues:an,validateTypeValue:sn}=le,{handleEvent:ln}=yt,cn={};var dn=cn;function un({value:e,count:t,options:n}){if(0===t||"@value"in e||"@list"in e||1===t&&"@id"in e){if(n.eventHandler){let o,r;0===t?(o="empty object",r="Dropping empty object."):"@value"in e?(o="object with only @value",r="Dropping object with only @value."):"@list"in e?(o="object with only @list",r="Dropping object with only @list."):1===t&&"@id"in e&&(o="object with only @id",r="Dropping object with only @id."),ln({event:{type:["JsonLdEvent"],code:o,level:"warning",message:r,details:{value:e}},options:n})}return null}return e}async function pn({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:o,expandedParent:r,options:i={},insideList:a,typeKey:s,typeScopedContext:l}){const c=Object.keys(o).sort(),d=[];let u;const p=o[s]&&"@json"===Qt(e,Bt(o[s])?o[s][0]:o[s],{vocab:!0},{...i,typeExpansion:!0});for(const a of c){let s,c=o[a];if("@context"===a)continue;const h=Qt(e,a,{vocab:!0},i);if(null===h||!en(h)&&!Wt(h)){i.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:a,expandedProperty:h}},options:i});continue}if(Wt(h)){if("@reverse"===n)throw new Ht("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 r&&"@included"!==h&&"@type"!==h)throw new Ht("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:h})}if("@id"===h){if(!qt(c)){if(!i.isFrame)throw new Ht('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:c});if(Ft(c)){if(!Ut(c))throw new Ht('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(!Bt(c))throw new Ht('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=>qt(e))))throw new Ht('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:c})}}on(r,"@id",rn(c).map((t=>{if(qt(t)){const n=Qt(e,t,{base:!0},i);return i.eventHandler&&(null===n?ln(null===t?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:t}},options:i}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:i}):en(n)||ln({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:t,expandedId:n}},options:i})),n}return t})),{propertyIsArray:i.isFrame});continue}if("@type"===h){Ft(c)&&(c=Object.fromEntries(Object.entries(c).map((([e,t])=>[Qt(l,e,{vocab:!0}),rn(t).map((e=>Qt(l,e,{base:!0,vocab:!0},{...i,typeExpansion:!0})))])))),sn(c,i.isFrame),on(r,"@type",rn(c).map((e=>{if(qt(e)){const t=Qt(l,e,{base:!0,vocab:!0},{...i,typeExpansion:!0});return"@json"===t||en(t)||i.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:i}),t}return e})),{propertyIsArray:!!i.isFrame});continue}if("@included"===h&&Yt(e,1.1)){const n=rn(await cn.expand({activeCtx:e,activeProperty:t,element:c,options:i}));if(!n.every((e=>Kt(e))))throw new Ht("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:c});on(r,"@included",n,{propertyIsArray:!0});continue}if("@graph"===h&&!Ft(c)&&!Bt(c))throw new Ht('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&&Yt(e,1.1)?r["@value"]=c:on(r,"@value",c,{propertyIsArray:i.isFrame});continue}if("@language"===h){if(null===c)continue;if(!qt(c)&&!i.isFrame)throw new Ht('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:c});c=rn(c).map((e=>qt(e)?e.toLowerCase():e));for(const e of c)qt(e)&&!e.match(tn)&&i.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:i});on(r,"@language",c,{propertyIsArray:i.isFrame});continue}if("@direction"===h){if(!qt(c)&&!i.isFrame)throw new Ht('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:c});c=rn(c);for(const e of c)if(qt(e)&&"ltr"!==e&&"rtl"!==e)throw new Ht('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:c});on(r,"@direction",c,{propertyIsArray:i.isFrame});continue}if("@index"===h){if(!qt(c))throw new Ht('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:c});on(r,"@index",c);continue}if("@reverse"===h){if(!Ft(c))throw new Ht('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:c});if(s=await cn.expand({activeCtx:e,activeProperty:"@reverse",element:c,options:i}),"@reverse"in s)for(const e in s["@reverse"])on(r,e,s["@reverse"][e],{propertyIsArray:!0});let t=r["@reverse"]||null;for(const e in s){if("@reverse"===e)continue;null===t&&(t=r["@reverse"]={}),on(t,e,[],{propertyIsArray:!0});const n=s[e];for(let o=0;o<n.length;++o){const r=n[o];if(Gt(r)||$t(r))throw new Ht('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:s});on(t,e,r,{propertyIsArray:!0})}}continue}if("@nest"===h){d.push(a);continue}let f=e;const v=Xt(e,a,"@context");Vt(v)||(f=await Zt({activeCtx:e,localCtx:v,propagate:!0,overrideProtected:!0,options:i}));const g=Xt(f,a,"@container")||[];if(g.includes("@language")&&Ft(c)){s=fn(f,c,Xt(f,a,"@direction"),i)}else if(g.includes("@index")&&Ft(c)){const t=g.includes("@graph"),n=Xt(f,a,"@index")||"@index",o="@index"!==n&&Qt(e,n,{vocab:!0},i);s=await vn({activeCtx:f,options:i,activeProperty:a,value:c,asGraph:t,indexKey:n,propertyIndex:o})}else if(g.includes("@id")&&Ft(c)){const e=g.includes("@graph");s=await vn({activeCtx:f,options:i,activeProperty:a,value:c,asGraph:e,indexKey:"@id"})}else if(g.includes("@type")&&Ft(c))s=await vn({activeCtx:f.revertToPreviousContext(),options:i,activeProperty:a,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 cn.expand({activeCtx:f,activeProperty:e,element:c,options:i,insideList:o})}else s="@json"===Xt(e,a,"@type")?{"@type":"@json","@value":c}:await cn.expand({activeCtx:f,activeProperty:a,element:c,options:i,insideList:!1})}if(null!==s||"@value"===h){if("@list"!==h&&!$t(s)&&g.includes("@list")&&(s={"@list":rn(s)}),g.includes("@graph")&&!g.some((e=>"@id"===e||"@index"===e))){if(s=rn(s),i.isFrame||(s=s.filter((e=>null!==un({value:e,count:Object.keys(e).length,options:i})))),0===s.length)continue;s=s.map((e=>({"@graph":rn(e)})))}if(f.mappings.has(a)&&f.mappings.get(a).reverse){const e=r["@reverse"]=r["@reverse"]||{};s=rn(s);for(let t=0;t<s.length;++t){const n=s[t];if(Gt(n)||$t(n))throw new Ht('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:s});on(e,h,n,{propertyIsArray:!0})}}else on(r,h,s,{propertyIsArray:!0})}}if("@value"in r)if("@json"===r["@type"]&&Yt(e,1.1));else if((Ft(u)||Bt(u))&&!i.isFrame)throw new Ht('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=Bt(o[c])?o[c]:[o[c]];for(const o of d){if(!Ft(o)||Object.keys(o).some((t=>"@value"===Qt(e,t,{vocab:!0},i))))throw new Ht("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:o});await pn({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:o,expandedParent:r,options:i,insideList:a,typeScopedContext:l,typeKey:s})}}}function hn({activeCtx:e,activeProperty:t,value:n,options:o}){if(null==n)return null;const r=Qt(e,t,{vocab:!0},o);if("@id"===r)return Qt(e,n,{base:!0},o);if("@type"===r)return Qt(e,n,{vocab:!0,base:!0},{...o,typeExpansion:!0});const i=Xt(e,t,"@type");if(("@id"===i||"@graph"===r)&&qt(n)){const r=Qt(e,n,{base:!0},o);return null===r&&n.match(nn)&&o.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}),{"@id":r}}if("@vocab"===i&&qt(n))return{"@id":Qt(e,n,{vocab:!0,base:!0},o)};if(Wt(r))return n;const a={};if(i&&!["@id","@vocab","@none"].includes(i))a["@type"]=i;else if(qt(n)){const n=Xt(e,t,"@language");null!==n&&(a["@language"]=n);const o=Xt(e,t,"@direction");null!==o&&(a["@direction"]=o)}return["boolean","number","string"].includes(typeof n)||(n=n.toString()),a["@value"]=n,a}function fn(e,t,n,o){const r=[],i=Object.keys(t).sort();for(const a of i){const i=Qt(e,a,{vocab:!0},o);let s=t[a];Bt(s)||(s=[s]);for(const e of s){if(null===e)continue;if(!qt(e))throw new Ht("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:t});const s={"@value":e};"@none"!==i&&(a.match(tn)||o.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:a}},options:o}),s["@language"]=a.toLowerCase()),n&&(s["@direction"]=n),r.push(s)}}return r}async function vn({activeCtx:e,options:t,activeProperty:n,value:o,asGraph:r,indexKey:i,propertyIndex:a}){const s=[],l=Object.keys(o).sort(),c="@type"===i;for(let d of l){if(c){const n=Xt(e,d,"@context");Vt(n)||(e=await Zt({activeCtx:e,localCtx:n,propagate:!1,options:t}))}let l,u=o[d];Bt(u)||(u=[u]),u=await cn.expand({activeCtx:e,activeProperty:n,element:u,options:t,insideList:!1,insideIndex:!0}),l=a?"@none"===d?"@none":hn({activeCtx:e,activeProperty:i,value:d,options:t}):Qt(e,d,{vocab:!0},t),"@id"===i?d=Qt(e,d,{base:!0},t):c&&(d=l);for(let e of u){if(r&&!zt(e)&&(e={"@graph":[e]}),"@type"===i)"@none"===l||(e["@type"]?e["@type"]=[d].concat(e["@type"]):e["@type"]=[d]);else{if(Gt(e)&&!["@language","@type","@index"].includes(i))throw new Ht(`Invalid JSON-LD syntax; Attempt to add illegal key to value object: "${i}".`,"jsonld.SyntaxError",{code:"invalid value object",value:e});a?"@none"!==l&&on(e,a,l,{propertyIsArray:!0,prependValue:!0}):"@none"===l||i in e||(e[i]=d)}s.push(e)}}return s}cn.expand=async({activeCtx:e,activeProperty:t=null,element:n,options:o={},insideList:r=!1,insideIndex:i=!1,typeScopedContext:a=null})=>{if(null==n)return null;if("@default"===t&&(o=Object.assign({},o,{isFrame:!1})),!Bt(n)&&!Ft(n))return r||null!==t&&"@graph"!==Qt(e,t,{vocab:!0},o)?hn({activeCtx:e,activeProperty:t,value:n,options:o}):(o.eventHandler&&ln({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(Bt(n)){let s=[];const l=Xt(e,t,"@container")||[];r=r||l.includes("@list");for(let l=0;l<n.length;++l){let c=await cn.expand({activeCtx:e,activeProperty:t,element:n[l],options:o,insideIndex:i,typeScopedContext:a});r&&Bt(c)&&(c={"@list":c}),null!==c&&(Bt(c)?s=s.concat(c):s.push(c))}return s}const s=Qt(e,t,{vocab:!0},o),l=Xt(e,t,"@context");a=a||(e.previousContext?e:null);let c=Object.keys(n).sort(),d=!i;if(d&&a&&c.length<=2&&!c.includes("@context"))for(const t of c){const n=Qt(a,t,{vocab:!0},o);if("@value"===n){d=!1,e=a;break}if("@id"===n&&1===c.length){d=!1;break}}d&&(e=e.revertToPreviousContext()),Vt(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})),a=e;let u=null;for(const t of c){if("@type"===Qt(e,t,{vocab:!0},o)){u=u||t;const r=n[t],i=Array.isArray(r)?r.length>1?r.slice().sort():r:[r];for(const t of i){const n=Xt(a,t,"@context");Vt(n)||(e=await Zt({activeCtx:e,localCtx:n,options:o,propagate:!1}))}}}let p={};await pn({activeCtx:e,activeProperty:t,expandedActiveProperty:s,element:n,expandedParent:p,options:o,insideList:r,typeKey:u,typeScopedContext:a}),c=Object.keys(p);let h=c.length;if("@value"in p){if("@type"in p&&("@language"in p||"@direction"in p))throw new Ht('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 Ht('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"]?[]:rn(p["@value"]),r=an(p,"@type");if(Yt(e,1.1)&&r.includes("@json")&&1===r.length);else if(0===n.length)o.eventHandler&&ln({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=>qt(e)||Ut(e)))&&"@language"in p)throw new Ht("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:p});if(!r.every((e=>en(e)&&!(qt(e)&&0===e.indexOf("_:"))||Ut(e))))throw new Ht('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&&!Bt(p["@type"]))p["@type"]=[p["@type"]];else if("@set"in p||"@list"in p){if(h>1&&(2!==h||!("@index"in p)))throw new Ht('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&&ln({event:{type:["JsonLdEvent"],code:"object with only @language",level:"warning",message:"Dropping object with only @language.",details:{value:p}},options:o}),p=null);return!Ft(p)||o.keepFreeFloatingNodes||r||null!==t&&"@graph"!==s&&!(Xt(e,t,"@container")||[]).includes("@graph")||(p=un({value:p,count:h,options:o})),p};const{isKeyword:gn}=Pt,yn=W,mn=K,xn=le,bn=Z,wn={};var In=wn;wn.createMergedNodeMap=(e,t)=>{const n=(t=t||{}).issuer||new xn.IdentifierIssuer("_:b"),o={"@default":{}};return wn.createNodeMap(e,o,"@default",n),wn.mergeNodeMaps(o)},wn.createNodeMap=(e,t,n,o,r,i)=>{if(mn.isArray(e)){for(const r of e)wn.createNodeMap(r,t,n,o,void 0,i);return}if(!mn.isObject(e))return void(i&&i.push(e));if(yn.isValue(e)){if("@type"in e){let t=e["@type"];0===t.indexOf("_:")&&(e["@type"]=t=o.getId(t))}return void(i&&i.push(e))}if(i&&yn.isList(e)){const a=[];return wn.createNodeMap(e["@list"],t,n,o,r,a),void i.push({"@list":a})}if("@type"in e){const t=e["@type"];for(const e of t)0===e.indexOf("_:")&&o.getId(e)}mn.isUndefined(r)&&(r=yn.isBlankNode(e)?o.getId(e["@id"]):e["@id"]),i&&i.push({"@id":r});const a=t[n],s=a[r]=a[r]||{};s["@id"]=r;const l=Object.keys(e).sort();for(let i of l){if("@id"===i)continue;if("@reverse"===i){const i={"@id":r},s=e["@reverse"];for(const e in s){const r=s[e];for(const s of r){let r=s["@id"];yn.isBlankNode(s)&&(r=o.getId(r)),wn.createNodeMap(s,t,n,o,r),xn.addValue(a[r],e,i,{propertyIsArray:!0,allowDuplicate:!1})}}continue}if("@graph"===i){r in t||(t[r]={}),wn.createNodeMap(e[i],t,r,o);continue}if("@included"===i){wn.createNodeMap(e[i],t,n,o);continue}if("@type"!==i&&gn(i)){if("@index"===i&&i in s&&(e[i]!==s[i]||e[i]["@id"]!==s[i]["@id"]))throw new bn("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:s});s[i]=e[i];continue}const l=e[i];if(0===i.indexOf("_:")&&(i=o.getId(i)),0!==l.length)for(let e of l)if("@type"===i&&(e=0===e.indexOf("_:")?o.getId(e):e),yn.isSubject(e)||yn.isSubjectReference(e)){if("@id"in e&&!e["@id"])continue;const r=yn.isBlankNode(e)?o.getId(e["@id"]):e["@id"];xn.addValue(s,i,{"@id":r},{propertyIsArray:!0,allowDuplicate:!1}),wn.createNodeMap(e,t,n,o,r)}else if(yn.isValue(e))xn.addValue(s,i,e,{propertyIsArray:!0,allowDuplicate:!1});else if(yn.isList(e)){const a=[];wn.createNodeMap(e["@list"],t,n,o,r,a),e={"@list":a},xn.addValue(s,i,e,{propertyIsArray:!0,allowDuplicate:!1})}else wn.createNodeMap(e,t,n,o,r),xn.addValue(s,i,e,{propertyIsArray:!0,allowDuplicate:!1});else xn.addValue(s,i,[],{propertyIsArray:!0})}},wn.mergeNodeMapGraphs=e=>{const t={};for(const n of Object.keys(e).sort())for(const o of Object.keys(e[n]).sort()){const r=e[n][o];o in t||(t[o]={"@id":o});const i=t[o];for(const e of Object.keys(r).sort())if(gn(e)&&"@type"!==e)i[e]=xn.clone(r[e]);else for(const t of r[e])xn.addValue(i,e,xn.clone(t),{propertyIsArray:!0,allowDuplicate:!1})}return t},wn.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 r=t[o];r?"@graph"in r||(r["@graph"]=[]):t[o]=r={"@id":o,"@graph":[]};const i=r["@graph"];for(const e of Object.keys(n).sort()){const t=n[e];yn.isSubjectReference(t)||i.push(t)}}return t};const{isSubjectReference:jn}=W,{createMergedNodeMap:Sn}=In,kn={};var Nn=kn;kn.flatten=e=>{const t=Sn(e),n=[],o=Object.keys(t).sort();for(let e=0;e<o.length;++e){const r=t[o[e]];jn(r)||n.push(r)}return n};const En=Z,On=W,Dn=K,{REGEX_BCP47:Cn,addValue:Ln}=le,{handleEvent:Tn}=yt,{RDF_LIST:Rn,RDF_FIRST:An,RDF_REST:_n,RDF_NIL:Pn,RDF_TYPE:Mn,RDF_JSON_LITERAL:Jn,XSD_BOOLEAN:Hn,XSD_DOUBLE:Bn,XSD_INTEGER:Fn,XSD_STRING:Un}=ge,qn={};var Vn=qn;function $n(e,t,n,o){if(e.termType.endsWith("Node"))return{"@id":e.value};const r={"@value":e.value};if(e.language)e.language.match(Cn)||o.eventHandler&&Tn({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e.language}},options:o}),r["@language"]=e.language;else{let i=e.datatype.value;if(i||(i=Un),i===Jn){i="@json";try{r["@value"]=JSON.parse(r["@value"])}catch(e){throw new En("JSON literal could not be parsed.","jsonld.InvalidJsonLiteral",{code:"invalid JSON literal",value:r["@value"],cause:e})}}if(t){if(i===Hn)"true"===r["@value"]?r["@value"]=!0:"false"===r["@value"]&&(r["@value"]=!1);else if(Dn.isNumeric(r["@value"]))if(i===Fn){const e=parseInt(r["@value"],10);e.toFixed(0)===r["@value"]&&(r["@value"]=e)}else i===Bn&&(r["@value"]=parseFloat(r["@value"]));[Hn,Fn,Bn,Un].includes(i)||(r["@type"]=i)}else if("i18n-datatype"===n&&i.startsWith("https://www.w3.org/ns/i18n#")){const[,e,t]=i.split(/[#_]/);e.length>0&&(r["@language"]=e,e.match(Cn)||o.eventHandler&&Tn({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:o})),r["@direction"]=t}else i!==Un&&(r["@type"]=i)}return r}qn.fromRDF=async(e,t)=>{const{useRdfType:n=!1,useNativeTypes:o=!1,rdfDirection:r=null}=t,i={},a={"@default":i},s={};if(r){if("compound-literal"===r)throw new En("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:r});if("i18n-datatype"!==r)throw new En("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:r})}for(const l of e){const e="DefaultGraph"===l.graph.termType?"@default":l.graph.value;e in a||(a[e]={}),"@default"===e||e in i||(i[e]={"@id":e});const c=a[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===Mn&&!n&&f){Ln(h,"@type",p.value,{propertyIsArray:!0});continue}const v=$n(p,o,r,t);if(Ln(h,u,v,{propertyIsArray:!0}),f)if(p.value===Pn){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 a){const t=a[e];if(!(Pn in t))continue;const n=t[Pn];if(n.usages){for(let e of n.usages){let n=e.node,o=e.property,r=e.value;const i=[],a=[];let l=Object.keys(n).length;for(;o===_n&&Dn.isObject(s[n["@id"]])&&Dn.isArray(n[An])&&1===n[An].length&&Dn.isArray(n[_n])&&1===n[_n].length&&(3===l||4===l&&Dn.isArray(n["@type"])&&1===n["@type"].length&&n["@type"][0]===Rn)&&(i.push(n[An][0]),a.push(n["@id"]),e=s[n["@id"]],n=e.node,o=e.property,r=e.value,l=Object.keys(n).length,On.isBlankNode(n)););delete r["@id"],r["@list"]=i.reverse();for(const e of a)delete t[e]}delete n.usages}}const l=[],c=Object.keys(i).sort();for(const e of c){const t=i[e];if(e in a){const n=t["@graph"]=[],o=a[e],r=Object.keys(o).sort();for(const e of r){const t=o[e];On.isSubjectReference(t)||n.push(t)}}On.isSubjectReference(t)||l.push(t)}return l};const{createNodeMap:Gn}=In,{isKeyword:zn}=Pt,Kn=W,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,r)=>{if(void 0===t[o]||"symbol"==typeof t[o])return n;return n+(0===n.length?"":",")+e(o)+":"+e(t[o])}),"")+"}"},Xn=Z,Wn=K,Zn=le,{handleEvent:Yn}=yt,{RDF_FIRST:eo,RDF_REST:to,RDF_NIL:no,RDF_TYPE:oo,RDF_JSON_LITERAL:ro,RDF_LANGSTRING:io,XSD_BOOLEAN:ao,XSD_DOUBLE:so,XSD_INTEGER:lo,XSD_STRING:co}=ge,{isAbsolute:uo}=me(),po={};var ho=po;function fo(e,t,n,o,r){const i=Object.keys(t).sort();for(const a of i){const i=t[a],s=Object.keys(i).sort();for(let t of s){const s=i[t];if("@type"===t)t=oo;else if(zn(t))continue;for(const i of s){const s={termType:a.startsWith("_:")?"BlankNode":"NamedNode",value:a};if(!uo(a)){r.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative subject reference",level:"warning",message:"Relative subject reference found.",details:{subject:a}},options:r});continue}const l={termType:t.startsWith("_:")?"BlankNode":"NamedNode",value:t};if(!uo(t)){r.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative predicate reference",level:"warning",message:"Relative predicate reference found.",details:{predicate:t}},options:r});continue}if("BlankNode"===l.termType&&!r.produceGeneralizedRdf){r.eventHandler&&Yn({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:r});continue}const c=vo(i,o,e,n,r.rdfDirection,r);c&&e.push({subject:s,predicate:l,object:c,graph:n})}}}}function vo(e,t,n,o,r,i){const a={};if(Kn.isValue(e)){a.termType="Literal",a.value=void 0,a.datatype={termType:"NamedNode"};let t=e["@value"];const n=e["@type"]||null;if("@json"===n)a.value=Qn(t),a.datatype.value=ro;else if(Wn.isBoolean(t))a.value=t.toString(),a.datatype.value=n||ao;else if(Wn.isDouble(t)||n===so)Wn.isDouble(t)||(t=parseFloat(t)),a.value=t.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),a.datatype.value=n||so;else if(Wn.isNumber(t))a.value=t.toFixed(0),a.datatype.value=n||lo;else if("@direction"in e&&"i18n-datatype"===r){const n=`https://www.w3.org/ns/i18n#${(e["@language"]||"").toLowerCase()}_${e["@direction"]}`;a.datatype.value=n,a.value=t}else{if("@direction"in e&&"compound-literal"===r)throw new Xn("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:r});if("@direction"in e&&r)throw new Xn("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:r});"@language"in e?("@direction"in e&&!r&&i.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:a.value}},options:i}),a.value=t,a.datatype.value=n||io,a.language=e["@language"]):("@direction"in e&&!r&&i.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:a.value}},options:i}),a.value=t,a.datatype.value=n||co)}}else if(Kn.isList(e)){const s=function(e,t,n,o,r,i){const a={termType:"NamedNode",value:eo},s={termType:"NamedNode",value:to},l={termType:"NamedNode",value:no},c=e.pop(),d=c?{termType:"BlankNode",value:t.getId()}:l;let u=d;for(const l of e){const e=vo(l,t,n,o,r,i),c={termType:"BlankNode",value:t.getId()};n.push({subject:u,predicate:a,object:e,graph:o}),n.push({subject:u,predicate:s,object:c,graph:o}),u=c}if(c){const e=vo(c,t,n,o,r,i);n.push({subject:u,predicate:a,object:e,graph:o}),n.push({subject:u,predicate:s,object:l,graph:o})}return d}(e["@list"],t,n,o,r,i);a.termType=s.termType,a.value=s.value}else{const t=Wn.isObject(e)?e["@id"]:e;a.termType=t.startsWith("_:")?"BlankNode":"NamedNode",a.value=t}return"NamedNode"!==a.termType||uo(a.value)?a:(i.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative object reference",level:"warning",message:"Relative object reference found.",details:{object:a.value}},options:i}),null)}po.toRDF=(e,t)=>{const n=new Zn.IdentifierIssuer("_:b"),o={"@default":{}};Gn(e,o,"@default",n);const r=[],i=Object.keys(o).sort();for(const e of i){let i;if("@default"===e)i={termType:"DefaultGraph",value:""};else{if(!uo(e)){t.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative graph reference",level:"warning",message:"Relative graph reference found.",details:{graph:e}},options:t});continue}i=e.startsWith("_:")?{termType:"BlankNode"}:{termType:"NamedNode"},i.value=e}fo(r,o[e],i,n,t)}return r};const{isKeyword:go}=Pt,yo=W,mo=K,xo=le,bo=me(),wo=Z,{createNodeMap:Io,mergeNodeMapGraphs:jo}=In,So={};var ko=So;function No(e){const t={};for(const n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function Eo(e,t,n){for(let o=n.length-1;o>=0;--o){const r=n[o];if(r.graph===t&&r.subject["@id"]===e["@id"])return!0}return!1}function Oo(e,t,n){const o="@"+n;let r=o in e?e[o][0]:t[n];if("embed"===n)if(!0===r)r="@once";else if(!1===r)r="@never";else if("@always"!==r&&"@never"!==r&&"@link"!==r&&"@first"!==r&&"@last"!==r&&"@once"!==r)throw new wo("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:e});return r}function Do(e){if(!mo.isArray(e)||1!==e.length||!mo.isObject(e[0]))throw new wo("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 xo.asArray(e[0]["@id"]))if(!mo.isObject(t)&&!bo.isAbsolute(t)||mo.isString(t)&&0===t.indexOf("_:"))throw new wo("Invalid JSON-LD syntax; invalid @id in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e});if("@type"in e[0])for(const t of xo.asArray(e[0]["@type"]))if(!mo.isObject(t)&&!bo.isAbsolute(t)&&"@json"!==t||mo.isString(t)&&0===t.indexOf("_:"))throw new wo("Invalid JSON-LD syntax; invalid @type in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e})}function Co(e,t,n,o){let r=!0,i=!1;for(const a in n){let s=!1;const l=xo.getValues(t,a),c=0===xo.getValues(n,a).length;if("@id"===a){if(mo.isEmptyObject(n["@id"][0]||{})?s=!0:n["@id"].length>=0&&(s=n["@id"].includes(l[0])),!o.requireAll)return s}else if("@type"===a){if(r=!1,c){if(l.length>0)return!1;s=!0}else if(1===n["@type"].length&&mo.isEmptyObject(n["@type"][0]))s=l.length>0;else for(const e of n["@type"])s=!(!mo.isObject(e)||!("@default"in e))||(s||l.some((t=>t===e)));if(!o.requireAll)return s}else{if(go(a))continue;{const t=xo.getValues(n,a)[0];let i=!1;if(t&&(Do([t]),i="@default"in t),r=!1,0===l.length&&i)continue;if(l.length>0&&c)return!1;if(void 0===t){if(l.length>0)return!1;s=!0}else if(yo.isList(t)){const n=t["@list"][0];if(yo.isList(l[0])){const t=l[0]["@list"];yo.isValue(n)?s=t.some((e=>_o(n,e))):(yo.isSubject(n)||yo.isSubjectReference(n))&&(s=t.some((t=>Ao(e,n,t,o))))}}else s=yo.isValue(t)?l.some((e=>_o(t,e))):yo.isSubjectReference(t)?l.some((n=>Ao(e,t,n,o))):!!mo.isObject(t)&&l.length>0}}if(!s&&o.requireAll)return!1;i=i||s}return r||i}function Lo(e,t){const n=e.uniqueEmbeds[e.graph],o=n[t],r=o.parent,i=o.property,a={"@id":t};if(mo.isArray(r)){for(let e=0;e<r.length;++e)if(xo.compareValues(r[e],a)){r[e]=a;break}}else{const e=mo.isArray(r[i]);xo.removeValue(r,i,a,{propertyIsArray:e}),xo.addValue(r,i,a,{propertyIsArray:e})}const s=e=>{const t=Object.keys(n);for(const o of t)o in n&&mo.isObject(n[o].parent)&&n[o].parent["@id"]===e&&(delete n[o],s(o))};s(t)}
27
+ const p=c["@id"];if("@context"===p||"@preserve"===p)throw new wt("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t});if(s&&s.protected&&!i&&(e.protected[n]=!0,c.protected=!0,!Jt(s,c)))throw new wt("Invalid JSON-LD syntax; tried to redefine a protected term.","jsonld.SyntaxError",{code:"protected term redefinition",context:t,term:n})},_t.expandIri=(e,t,n,o)=>Mt(e,t,n,void 0,void 0,o),_t.getInitialContext=e=>{const t=JSON.stringify({processingMode:e.processingMode}),n=At.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={},a=(e["@language"]||"@none").toLowerCase(),s=e["@direction"],l=e.mappings,c=[...l.keys()].sort(Rt);for(const e of c){const r=l.get(e);if(null===r)continue;let c=r["@container"]||"@none";if(c=[].concat(c).sort().join(""),null===r["@id"])continue;const d=Tt(r["@id"]);for(const l of d){let d=t[l];const u=_t.isKeyword(l);if(d)u||r._termHasColon||o[l].push(e);else if(t[l]=d={},!u&&!r._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],i(e,d["@any"],"@none"),r.reverse)i(e,d["@type"],"@reverse");else if("@none"===r["@type"])i(e,d["@any"],"@none"),i(e,d["@language"],"@none"),i(e,d["@type"],"@none");else if("@type"in r)i(e,d["@type"],r["@type"]);else if("@language"in r&&"@direction"in r){const t=r["@language"],n=r["@direction"];i(e,d["@language"],t&&n?`${t}_${n}`.toLowerCase():t?t.toLowerCase():n?`_${n}`:"@null")}else"@language"in r?i(e,d["@language"],(r["@language"]||"@null").toLowerCase()):"@direction"in r?r["@direction"]?i(e,d["@language"],`_${r["@direction"]}`):i(e,d["@language"],"@none"):s?(i(e,d["@language"],`_${s}`),i(e,d["@language"],"@none"),i(e,d["@type"],"@none")):(i(e,d["@language"],a),i(e,d["@language"],"@none"),i(e,d["@type"],"@none"))}}for(const e in n)r(n,e,1);return t},clone:function(){const e={};e.mappings=bt.clone(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,e.protected=bt.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===At.size&&At.clear(),At.set(t,o),o;function r(e,t,n){const o=e[t],i=e[t]={};let a,s;for(const e of o)a=e.iri,s=n>=a.length?"":a[n],s in i?i[s].push(e):i[s]=[e];for(const e in i)""!==e&&r(i,e,n+1)}function i(e,t,n){t.hasOwnProperty(n)||(t[n]=e)}},_t.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(kt(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},_t.processingMode=(e,t)=>t.toString()>="1.1"?!e.processingMode||e.processingMode>="json-ld-"+t.toString():"json-ld-1.0"===e.processingMode,_t.isKeyword=e=>{if(!St(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 Ht=Z,{isArray:Bt,isObject:Ft,isEmptyObject:Ut,isString:qt,isUndefined:Vt}=K,{isList:$t,isValue:Gt,isGraph:zt,isSubject:Kt}=X,{expandIri:Qt,getContextValue:Wt,isKeyword:Xt,process:Zt,processingMode:Yt}=Pt,{isAbsolute:en}=me(),{REGEX_BCP47:tn,REGEX_KEYWORD:nn,addValue:on,asArray:rn,getValues:an,validateTypeValue:sn}=le,{handleEvent:ln}=yt,cn={};var dn=cn;function un({value:e,count:t,options:n}){if(0===t||"@value"in e||"@list"in e||1===t&&"@id"in e){if(n.eventHandler){let o,r;0===t?(o="empty object",r="Dropping empty object."):"@value"in e?(o="object with only @value",r="Dropping object with only @value."):"@list"in e?(o="object with only @list",r="Dropping object with only @list."):1===t&&"@id"in e&&(o="object with only @id",r="Dropping object with only @id."),ln({event:{type:["JsonLdEvent"],code:o,level:"warning",message:r,details:{value:e}},options:n})}return null}return e}async function pn({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:o,expandedParent:r,options:i={},insideList:a,typeKey:s,typeScopedContext:l}){const c=Object.keys(o).sort(),d=[];let u;const p=o[s]&&"@json"===Qt(e,Bt(o[s])?o[s][0]:o[s],{vocab:!0},{...i,typeExpansion:!0});for(const a of c){let s,c=o[a];if("@context"===a)continue;const h=Qt(e,a,{vocab:!0},i);if(null===h||!en(h)&&!Xt(h)){i.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"invalid property",level:"warning",message:"Dropping property that did not expand into an absolute IRI or keyword.",details:{property:a,expandedProperty:h}},options:i});continue}if(Xt(h)){if("@reverse"===n)throw new Ht("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 r&&"@included"!==h&&"@type"!==h)throw new Ht("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:h})}if("@id"===h){if(!qt(c)){if(!i.isFrame)throw new Ht('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:c});if(Ft(c)){if(!Ut(c))throw new Ht('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(!Bt(c))throw new Ht('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=>qt(e))))throw new Ht('Invalid JSON-LD syntax; "@id" value an empty object or array of strings, if framing',"jsonld.SyntaxError",{code:"invalid @id value",value:c})}}on(r,"@id",rn(c).map((t=>{if(qt(t)){const n=Qt(e,t,{base:!0},i);return i.eventHandler&&(null===n?ln(null===t?{event:{type:["JsonLdEvent"],code:"null @id value",level:"warning",message:"Null @id found.",details:{id:t}},options:i}:{event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:i}):en(n)||ln({event:{type:["JsonLdEvent"],code:"relative @id reference",level:"warning",message:"Relative @id reference found.",details:{id:t,expandedId:n}},options:i})),n}return t})),{propertyIsArray:i.isFrame});continue}if("@type"===h){Ft(c)&&(c=Object.fromEntries(Object.entries(c).map((([e,t])=>[Qt(l,e,{vocab:!0}),rn(t).map((e=>Qt(l,e,{base:!0,vocab:!0},{...i,typeExpansion:!0})))])))),sn(c,i.isFrame),on(r,"@type",rn(c).map((e=>{if(qt(e)){const t=Qt(l,e,{base:!0,vocab:!0},{...i,typeExpansion:!0});return"@json"===t||en(t)||i.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"relative @type reference",level:"warning",message:"Relative @type reference found.",details:{type:e}},options:i}),t}return e})),{propertyIsArray:!!i.isFrame});continue}if("@included"===h&&Yt(e,1.1)){const n=rn(await cn.expand({activeCtx:e,activeProperty:t,element:c,options:i}));if(!n.every((e=>Kt(e))))throw new Ht("Invalid JSON-LD syntax; values of @included must expand to node objects.","jsonld.SyntaxError",{code:"invalid @included value",value:c});on(r,"@included",n,{propertyIsArray:!0});continue}if("@graph"===h&&!Ft(c)&&!Bt(c))throw new Ht('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&&Yt(e,1.1)?r["@value"]=c:on(r,"@value",c,{propertyIsArray:i.isFrame});continue}if("@language"===h){if(null===c)continue;if(!qt(c)&&!i.isFrame)throw new Ht('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:c});c=rn(c).map((e=>qt(e)?e.toLowerCase():e));for(const e of c)qt(e)&&!e.match(tn)&&i.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:i});on(r,"@language",c,{propertyIsArray:i.isFrame});continue}if("@direction"===h){if(!qt(c)&&!i.isFrame)throw new Ht('Invalid JSON-LD syntax; "@direction" value must be a string.',"jsonld.SyntaxError",{code:"invalid base direction",value:c});c=rn(c);for(const e of c)if(qt(e)&&"ltr"!==e&&"rtl"!==e)throw new Ht('Invalid JSON-LD syntax; "@direction" must be "ltr" or "rtl".',"jsonld.SyntaxError",{code:"invalid base direction",value:c});on(r,"@direction",c,{propertyIsArray:i.isFrame});continue}if("@index"===h){if(!qt(c))throw new Ht('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:c});on(r,"@index",c);continue}if("@reverse"===h){if(!Ft(c))throw new Ht('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:c});if(s=await cn.expand({activeCtx:e,activeProperty:"@reverse",element:c,options:i}),"@reverse"in s)for(const e in s["@reverse"])on(r,e,s["@reverse"][e],{propertyIsArray:!0});let t=r["@reverse"]||null;for(const e in s){if("@reverse"===e)continue;null===t&&(t=r["@reverse"]={}),on(t,e,[],{propertyIsArray:!0});const n=s[e];for(let o=0;o<n.length;++o){const r=n[o];if(Gt(r)||$t(r))throw new Ht('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:s});on(t,e,r,{propertyIsArray:!0})}}continue}if("@nest"===h){d.push(a);continue}let f=e;const v=Wt(e,a,"@context");Vt(v)||(f=await Zt({activeCtx:e,localCtx:v,propagate:!0,overrideProtected:!0,options:i}));const g=Wt(f,a,"@container")||[];if(g.includes("@language")&&Ft(c)){s=fn(f,c,Wt(f,a,"@direction"),i)}else if(g.includes("@index")&&Ft(c)){const t=g.includes("@graph"),n=Wt(f,a,"@index")||"@index",o="@index"!==n&&Qt(e,n,{vocab:!0},i);s=await vn({activeCtx:f,options:i,activeProperty:a,value:c,asGraph:t,indexKey:n,propertyIndex:o})}else if(g.includes("@id")&&Ft(c)){const e=g.includes("@graph");s=await vn({activeCtx:f,options:i,activeProperty:a,value:c,asGraph:e,indexKey:"@id"})}else if(g.includes("@type")&&Ft(c))s=await vn({activeCtx:f.revertToPreviousContext(),options:i,activeProperty:a,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 cn.expand({activeCtx:f,activeProperty:e,element:c,options:i,insideList:o})}else s="@json"===Wt(e,a,"@type")?{"@type":"@json","@value":c}:await cn.expand({activeCtx:f,activeProperty:a,element:c,options:i,insideList:!1})}if(null!==s||"@value"===h){if("@list"!==h&&!$t(s)&&g.includes("@list")&&(s={"@list":rn(s)}),g.includes("@graph")&&!g.some((e=>"@id"===e||"@index"===e))){if(s=rn(s),i.isFrame||(s=s.filter((e=>null!==un({value:e,count:Object.keys(e).length,options:i})))),0===s.length)continue;s=s.map((e=>({"@graph":rn(e)})))}if(f.mappings.has(a)&&f.mappings.get(a).reverse){const e=r["@reverse"]=r["@reverse"]||{};s=rn(s);for(let t=0;t<s.length;++t){const n=s[t];if(Gt(n)||$t(n))throw new Ht('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:s});on(e,h,n,{propertyIsArray:!0})}}else on(r,h,s,{propertyIsArray:!0})}}if("@value"in r)if("@json"===r["@type"]&&Yt(e,1.1));else if((Ft(u)||Bt(u))&&!i.isFrame)throw new Ht('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=Bt(o[c])?o[c]:[o[c]];for(const o of d){if(!Ft(o)||Object.keys(o).some((t=>"@value"===Qt(e,t,{vocab:!0},i))))throw new Ht("Invalid JSON-LD syntax; nested value must be a node object.","jsonld.SyntaxError",{code:"invalid @nest value",value:o});await pn({activeCtx:e,activeProperty:t,expandedActiveProperty:n,element:o,expandedParent:r,options:i,insideList:a,typeScopedContext:l,typeKey:s})}}}function hn({activeCtx:e,activeProperty:t,value:n,options:o}){if(null==n)return null;const r=Qt(e,t,{vocab:!0},o);if("@id"===r)return Qt(e,n,{base:!0},o);if("@type"===r)return Qt(e,n,{vocab:!0,base:!0},{...o,typeExpansion:!0});const i=Wt(e,t,"@type");if(("@id"===i||"@graph"===r)&&qt(n)){const r=Qt(e,n,{base:!0},o);return null===r&&n.match(nn)&&o.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"reserved @id value",level:"warning",message:"Reserved @id found.",details:{id:t}},options:o}),{"@id":r}}if("@vocab"===i&&qt(n))return{"@id":Qt(e,n,{vocab:!0,base:!0},o)};if(Xt(r))return n;const a={};if(i&&!["@id","@vocab","@none"].includes(i))a["@type"]=i;else if(qt(n)){const n=Wt(e,t,"@language");null!==n&&(a["@language"]=n);const o=Wt(e,t,"@direction");null!==o&&(a["@direction"]=o)}return["boolean","number","string"].includes(typeof n)||(n=n.toString()),a["@value"]=n,a}function fn(e,t,n,o){const r=[],i=Object.keys(t).sort();for(const a of i){const i=Qt(e,a,{vocab:!0},o);let s=t[a];Bt(s)||(s=[s]);for(const e of s){if(null===e)continue;if(!qt(e))throw new Ht("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:t});const s={"@value":e};"@none"!==i&&(a.match(tn)||o.eventHandler&&ln({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:a}},options:o}),s["@language"]=a.toLowerCase()),n&&(s["@direction"]=n),r.push(s)}}return r}async function vn({activeCtx:e,options:t,activeProperty:n,value:o,asGraph:r,indexKey:i,propertyIndex:a}){const s=[],l=Object.keys(o).sort(),c="@type"===i;for(let d of l){if(c){const n=Wt(e,d,"@context");Vt(n)||(e=await Zt({activeCtx:e,localCtx:n,propagate:!1,options:t}))}let l,u=o[d];Bt(u)||(u=[u]),u=await cn.expand({activeCtx:e,activeProperty:n,element:u,options:t,insideList:!1,insideIndex:!0}),l=a?"@none"===d?"@none":hn({activeCtx:e,activeProperty:i,value:d,options:t}):Qt(e,d,{vocab:!0},t),"@id"===i?d=Qt(e,d,{base:!0},t):c&&(d=l);for(let e of u){if(r&&!zt(e)&&(e={"@graph":[e]}),"@type"===i)"@none"===l||(e["@type"]?e["@type"]=[d].concat(e["@type"]):e["@type"]=[d]);else{if(Gt(e)&&!["@language","@type","@index"].includes(i))throw new Ht(`Invalid JSON-LD syntax; Attempt to add illegal key to value object: "${i}".`,"jsonld.SyntaxError",{code:"invalid value object",value:e});a?"@none"!==l&&on(e,a,l,{propertyIsArray:!0,prependValue:!0}):"@none"===l||i in e||(e[i]=d)}s.push(e)}}return s}cn.expand=async({activeCtx:e,activeProperty:t=null,element:n,options:o={},insideList:r=!1,insideIndex:i=!1,typeScopedContext:a=null})=>{if(null==n)return null;if("@default"===t&&(o=Object.assign({},o,{isFrame:!1})),!Bt(n)&&!Ft(n))return r||null!==t&&"@graph"!==Qt(e,t,{vocab:!0},o)?hn({activeCtx:e,activeProperty:t,value:n,options:o}):(o.eventHandler&&ln({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(Bt(n)){let s=[];const l=Wt(e,t,"@container")||[];r=r||l.includes("@list");for(let l=0;l<n.length;++l){let c=await cn.expand({activeCtx:e,activeProperty:t,element:n[l],options:o,insideIndex:i,typeScopedContext:a});r&&Bt(c)&&(c={"@list":c}),null!==c&&(Bt(c)?s=s.concat(c):s.push(c))}return s}const s=Qt(e,t,{vocab:!0},o),l=Wt(e,t,"@context");a=a||(e.previousContext?e:null);let c=Object.keys(n).sort(),d=!i;if(d&&a&&c.length<=2&&!c.includes("@context"))for(const t of c){const n=Qt(a,t,{vocab:!0},o);if("@value"===n){d=!1,e=a;break}if("@id"===n&&1===c.length){d=!1;break}}d&&(e=e.revertToPreviousContext()),Vt(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})),a=e;let u=null;for(const t of c){if("@type"===Qt(e,t,{vocab:!0},o)){u=u||t;const r=n[t],i=Array.isArray(r)?r.length>1?r.slice().sort():r:[r];for(const t of i){const n=Wt(a,t,"@context");Vt(n)||(e=await Zt({activeCtx:e,localCtx:n,options:o,propagate:!1}))}}}let p={};await pn({activeCtx:e,activeProperty:t,expandedActiveProperty:s,element:n,expandedParent:p,options:o,insideList:r,typeKey:u,typeScopedContext:a}),c=Object.keys(p);let h=c.length;if("@value"in p){if("@type"in p&&("@language"in p||"@direction"in p))throw new Ht('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 Ht('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"]?[]:rn(p["@value"]),r=an(p,"@type");if(Yt(e,1.1)&&r.includes("@json")&&1===r.length);else if(0===n.length)o.eventHandler&&ln({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=>qt(e)||Ut(e)))&&"@language"in p)throw new Ht("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:p});if(!r.every((e=>en(e)&&!(qt(e)&&0===e.indexOf("_:"))||Ut(e))))throw new Ht('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&&!Bt(p["@type"]))p["@type"]=[p["@type"]];else if("@set"in p||"@list"in p){if(h>1&&(2!==h||!("@index"in p)))throw new Ht('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&&ln({event:{type:["JsonLdEvent"],code:"object with only @language",level:"warning",message:"Dropping object with only @language.",details:{value:p}},options:o}),p=null);return!Ft(p)||o.keepFreeFloatingNodes||r||null!==t&&"@graph"!==s&&!(Wt(e,t,"@container")||[]).includes("@graph")||(p=un({value:p,count:h,options:o})),p};const{isKeyword:gn}=Pt,yn=X,mn=K,xn=le,bn=Z,wn={};var In=wn;wn.createMergedNodeMap=(e,t)=>{const n=(t=t||{}).issuer||new xn.IdentifierIssuer("_:b"),o={"@default":{}};return wn.createNodeMap(e,o,"@default",n),wn.mergeNodeMaps(o)},wn.createNodeMap=(e,t,n,o,r,i)=>{if(mn.isArray(e)){for(const r of e)wn.createNodeMap(r,t,n,o,void 0,i);return}if(!mn.isObject(e))return void(i&&i.push(e));if(yn.isValue(e)){if("@type"in e){let t=e["@type"];0===t.indexOf("_:")&&(e["@type"]=t=o.getId(t))}return void(i&&i.push(e))}if(i&&yn.isList(e)){const a=[];return wn.createNodeMap(e["@list"],t,n,o,r,a),void i.push({"@list":a})}if("@type"in e){const t=e["@type"];for(const e of t)0===e.indexOf("_:")&&o.getId(e)}mn.isUndefined(r)&&(r=yn.isBlankNode(e)?o.getId(e["@id"]):e["@id"]),i&&i.push({"@id":r});const a=t[n],s=a[r]=a[r]||{};s["@id"]=r;const l=Object.keys(e).sort();for(let i of l){if("@id"===i)continue;if("@reverse"===i){const i={"@id":r},s=e["@reverse"];for(const e in s){const r=s[e];for(const s of r){let r=s["@id"];yn.isBlankNode(s)&&(r=o.getId(r)),wn.createNodeMap(s,t,n,o,r),xn.addValue(a[r],e,i,{propertyIsArray:!0,allowDuplicate:!1})}}continue}if("@graph"===i){r in t||(t[r]={}),wn.createNodeMap(e[i],t,r,o);continue}if("@included"===i){wn.createNodeMap(e[i],t,n,o);continue}if("@type"!==i&&gn(i)){if("@index"===i&&i in s&&(e[i]!==s[i]||e[i]["@id"]!==s[i]["@id"]))throw new bn("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:s});s[i]=e[i];continue}const l=e[i];if(0===i.indexOf("_:")&&(i=o.getId(i)),0!==l.length)for(let e of l)if("@type"===i&&(e=0===e.indexOf("_:")?o.getId(e):e),yn.isSubject(e)||yn.isSubjectReference(e)){if("@id"in e&&!e["@id"])continue;const r=yn.isBlankNode(e)?o.getId(e["@id"]):e["@id"];xn.addValue(s,i,{"@id":r},{propertyIsArray:!0,allowDuplicate:!1}),wn.createNodeMap(e,t,n,o,r)}else if(yn.isValue(e))xn.addValue(s,i,e,{propertyIsArray:!0,allowDuplicate:!1});else if(yn.isList(e)){const a=[];wn.createNodeMap(e["@list"],t,n,o,r,a),e={"@list":a},xn.addValue(s,i,e,{propertyIsArray:!0,allowDuplicate:!1})}else wn.createNodeMap(e,t,n,o,r),xn.addValue(s,i,e,{propertyIsArray:!0,allowDuplicate:!1});else xn.addValue(s,i,[],{propertyIsArray:!0})}},wn.mergeNodeMapGraphs=e=>{const t={};for(const n of Object.keys(e).sort())for(const o of Object.keys(e[n]).sort()){const r=e[n][o];o in t||(t[o]={"@id":o});const i=t[o];for(const e of Object.keys(r).sort())if(gn(e)&&"@type"!==e)i[e]=xn.clone(r[e]);else for(const t of r[e])xn.addValue(i,e,xn.clone(t),{propertyIsArray:!0,allowDuplicate:!1})}return t},wn.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 r=t[o];r?"@graph"in r||(r["@graph"]=[]):t[o]=r={"@id":o,"@graph":[]};const i=r["@graph"];for(const e of Object.keys(n).sort()){const t=n[e];yn.isSubjectReference(t)||i.push(t)}}return t};const{isSubjectReference:jn}=X,{createMergedNodeMap:Sn}=In,kn={};var Nn=kn;kn.flatten=e=>{const t=Sn(e),n=[],o=Object.keys(t).sort();for(let e=0;e<o.length;++e){const r=t[o[e]];jn(r)||n.push(r)}return n};const On=Z,En=X,Dn=K,{REGEX_BCP47:Cn,addValue:Ln}=le,{handleEvent:Tn}=yt,{RDF_LIST:Rn,RDF_FIRST:An,RDF_REST:_n,RDF_NIL:Pn,RDF_TYPE:Mn,RDF_JSON_LITERAL:Jn,XSD_BOOLEAN:Hn,XSD_DOUBLE:Bn,XSD_INTEGER:Fn,XSD_STRING:Un}=ge,qn={};var Vn=qn;function $n(e,t,n,o){if(e.termType.endsWith("Node"))return{"@id":e.value};const r={"@value":e.value};if(e.language)e.language.match(Cn)||o.eventHandler&&Tn({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e.language}},options:o}),r["@language"]=e.language;else{let i=e.datatype.value;if(i||(i=Un),i===Jn){i="@json";try{r["@value"]=JSON.parse(r["@value"])}catch(e){throw new On("JSON literal could not be parsed.","jsonld.InvalidJsonLiteral",{code:"invalid JSON literal",value:r["@value"],cause:e})}}if(t){if(i===Hn)"true"===r["@value"]?r["@value"]=!0:"false"===r["@value"]&&(r["@value"]=!1);else if(Dn.isNumeric(r["@value"]))if(i===Fn){const e=parseInt(r["@value"],10);e.toFixed(0)===r["@value"]&&(r["@value"]=e)}else i===Bn&&(r["@value"]=parseFloat(r["@value"]));[Hn,Fn,Bn,Un].includes(i)||(r["@type"]=i)}else if("i18n-datatype"===n&&i.startsWith("https://www.w3.org/ns/i18n#")){const[,e,t]=i.split(/[#_]/);e.length>0&&(r["@language"]=e,e.match(Cn)||o.eventHandler&&Tn({event:{type:["JsonLdEvent"],code:"invalid @language value",level:"warning",message:"@language value must be valid BCP47.",details:{language:e}},options:o})),r["@direction"]=t}else i!==Un&&(r["@type"]=i)}return r}qn.fromRDF=async(e,t)=>{const{useRdfType:n=!1,useNativeTypes:o=!1,rdfDirection:r=null}=t,i={},a={"@default":i},s={};if(r){if("compound-literal"===r)throw new On("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:r});if("i18n-datatype"!==r)throw new On("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:r})}for(const l of e){const e="DefaultGraph"===l.graph.termType?"@default":l.graph.value;e in a||(a[e]={}),"@default"===e||e in i||(i[e]={"@id":e});const c=a[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===Mn&&!n&&f){Ln(h,"@type",p.value,{propertyIsArray:!0});continue}const v=$n(p,o,r,t);if(Ln(h,u,v,{propertyIsArray:!0}),f)if(p.value===Pn){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 a){const t=a[e];if(!(Pn in t))continue;const n=t[Pn];if(n.usages){for(let e of n.usages){let n=e.node,o=e.property,r=e.value;const i=[],a=[];let l=Object.keys(n).length;for(;o===_n&&Dn.isObject(s[n["@id"]])&&Dn.isArray(n[An])&&1===n[An].length&&Dn.isArray(n[_n])&&1===n[_n].length&&(3===l||4===l&&Dn.isArray(n["@type"])&&1===n["@type"].length&&n["@type"][0]===Rn)&&(i.push(n[An][0]),a.push(n["@id"]),e=s[n["@id"]],n=e.node,o=e.property,r=e.value,l=Object.keys(n).length,En.isBlankNode(n)););delete r["@id"],r["@list"]=i.reverse();for(const e of a)delete t[e]}delete n.usages}}const l=[],c=Object.keys(i).sort();for(const e of c){const t=i[e];if(e in a){const n=t["@graph"]=[],o=a[e],r=Object.keys(o).sort();for(const e of r){const t=o[e];En.isSubjectReference(t)||n.push(t)}}En.isSubjectReference(t)||l.push(t)}return l};const{createNodeMap:Gn}=In,{isKeyword:zn}=Pt,Kn=X,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,r)=>{if(void 0===t[o]||"symbol"==typeof t[o])return n;return n+(0===n.length?"":",")+e(o)+":"+e(t[o])}),"")+"}"},Wn=Z,Xn=K,Zn=le,{handleEvent:Yn}=yt,{RDF_FIRST:eo,RDF_REST:to,RDF_NIL:no,RDF_TYPE:oo,RDF_JSON_LITERAL:ro,RDF_LANGSTRING:io,XSD_BOOLEAN:ao,XSD_DOUBLE:so,XSD_INTEGER:lo,XSD_STRING:co}=ge,{isAbsolute:uo}=me(),po={};var ho=po;function fo(e,t,n,o,r){const i=Object.keys(t).sort();for(const a of i){const i=t[a],s=Object.keys(i).sort();for(let t of s){const s=i[t];if("@type"===t)t=oo;else if(zn(t))continue;for(const i of s){const s={termType:a.startsWith("_:")?"BlankNode":"NamedNode",value:a};if(!uo(a)){r.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative subject reference",level:"warning",message:"Relative subject reference found.",details:{subject:a}},options:r});continue}const l={termType:t.startsWith("_:")?"BlankNode":"NamedNode",value:t};if(!uo(t)){r.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative predicate reference",level:"warning",message:"Relative predicate reference found.",details:{predicate:t}},options:r});continue}if("BlankNode"===l.termType&&!r.produceGeneralizedRdf){r.eventHandler&&Yn({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:r});continue}const c=vo(i,o,e,n,r.rdfDirection,r);c&&e.push({subject:s,predicate:l,object:c,graph:n})}}}}function vo(e,t,n,o,r,i){const a={};if(Kn.isValue(e)){a.termType="Literal",a.value=void 0,a.datatype={termType:"NamedNode"};let t=e["@value"];const n=e["@type"]||null;if("@json"===n)a.value=Qn(t),a.datatype.value=ro;else if(Xn.isBoolean(t))a.value=t.toString(),a.datatype.value=n||ao;else if(Xn.isDouble(t)||n===so)Xn.isDouble(t)||(t=parseFloat(t)),a.value=t.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),a.datatype.value=n||so;else if(Xn.isNumber(t))a.value=t.toFixed(0),a.datatype.value=n||lo;else if("@direction"in e&&"i18n-datatype"===r){const n=`https://www.w3.org/ns/i18n#${(e["@language"]||"").toLowerCase()}_${e["@direction"]}`;a.datatype.value=n,a.value=t}else{if("@direction"in e&&"compound-literal"===r)throw new Wn("Unsupported rdfDirection value.","jsonld.InvalidRdfDirection",{value:r});if("@direction"in e&&r)throw new Wn("Unknown rdfDirection value.","jsonld.InvalidRdfDirection",{value:r});"@language"in e?("@direction"in e&&!r&&i.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:a.value}},options:i}),a.value=t,a.datatype.value=n||io,a.language=e["@language"]):("@direction"in e&&!r&&i.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"rdfDirection not set",level:"warning",message:"rdfDirection not set for @direction.",details:{object:a.value}},options:i}),a.value=t,a.datatype.value=n||co)}}else if(Kn.isList(e)){const s=function(e,t,n,o,r,i){const a={termType:"NamedNode",value:eo},s={termType:"NamedNode",value:to},l={termType:"NamedNode",value:no},c=e.pop(),d=c?{termType:"BlankNode",value:t.getId()}:l;let u=d;for(const l of e){const e=vo(l,t,n,o,r,i),c={termType:"BlankNode",value:t.getId()};n.push({subject:u,predicate:a,object:e,graph:o}),n.push({subject:u,predicate:s,object:c,graph:o}),u=c}if(c){const e=vo(c,t,n,o,r,i);n.push({subject:u,predicate:a,object:e,graph:o}),n.push({subject:u,predicate:s,object:l,graph:o})}return d}(e["@list"],t,n,o,r,i);a.termType=s.termType,a.value=s.value}else{const t=Xn.isObject(e)?e["@id"]:e;a.termType=t.startsWith("_:")?"BlankNode":"NamedNode",a.value=t}return"NamedNode"!==a.termType||uo(a.value)?a:(i.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative object reference",level:"warning",message:"Relative object reference found.",details:{object:a.value}},options:i}),null)}po.toRDF=(e,t)=>{const n=new Zn.IdentifierIssuer("_:b"),o={"@default":{}};Gn(e,o,"@default",n);const r=[],i=Object.keys(o).sort();for(const e of i){let i;if("@default"===e)i={termType:"DefaultGraph",value:""};else{if(!uo(e)){t.eventHandler&&Yn({event:{type:["JsonLdEvent"],code:"relative graph reference",level:"warning",message:"Relative graph reference found.",details:{graph:e}},options:t});continue}i=e.startsWith("_:")?{termType:"BlankNode"}:{termType:"NamedNode"},i.value=e}fo(r,o[e],i,n,t)}return r};const{isKeyword:go}=Pt,yo=X,mo=K,xo=le,bo=me(),wo=Z,{createNodeMap:Io,mergeNodeMapGraphs:jo}=In,So={};var ko=So;function No(e){const t={};for(const n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function Oo(e,t,n){for(let o=n.length-1;o>=0;--o){const r=n[o];if(r.graph===t&&r.subject["@id"]===e["@id"])return!0}return!1}function Eo(e,t,n){const o="@"+n;let r=o in e?e[o][0]:t[n];if("embed"===n)if(!0===r)r="@once";else if(!1===r)r="@never";else if("@always"!==r&&"@never"!==r&&"@link"!==r&&"@first"!==r&&"@last"!==r&&"@once"!==r)throw new wo("Invalid JSON-LD syntax; invalid value of @embed.","jsonld.SyntaxError",{code:"invalid @embed value",frame:e});return r}function Do(e){if(!mo.isArray(e)||1!==e.length||!mo.isObject(e[0]))throw new wo("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 xo.asArray(e[0]["@id"]))if(!mo.isObject(t)&&!bo.isAbsolute(t)||mo.isString(t)&&0===t.indexOf("_:"))throw new wo("Invalid JSON-LD syntax; invalid @id in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e});if("@type"in e[0])for(const t of xo.asArray(e[0]["@type"]))if(!mo.isObject(t)&&!bo.isAbsolute(t)&&"@json"!==t||mo.isString(t)&&0===t.indexOf("_:"))throw new wo("Invalid JSON-LD syntax; invalid @type in frame.","jsonld.SyntaxError",{code:"invalid frame",frame:e})}function Co(e,t,n,o){let r=!0,i=!1;for(const a in n){let s=!1;const l=xo.getValues(t,a),c=0===xo.getValues(n,a).length;if("@id"===a){if(mo.isEmptyObject(n["@id"][0]||{})?s=!0:n["@id"].length>=0&&(s=n["@id"].includes(l[0])),!o.requireAll)return s}else if("@type"===a){if(r=!1,c){if(l.length>0)return!1;s=!0}else if(1===n["@type"].length&&mo.isEmptyObject(n["@type"][0]))s=l.length>0;else for(const e of n["@type"])s=!(!mo.isObject(e)||!("@default"in e))||(s||l.some((t=>t===e)));if(!o.requireAll)return s}else{if(go(a))continue;{const t=xo.getValues(n,a)[0];let i=!1;if(t&&(Do([t]),i="@default"in t),r=!1,0===l.length&&i)continue;if(l.length>0&&c)return!1;if(void 0===t){if(l.length>0)return!1;s=!0}else if(yo.isList(t)){const n=t["@list"][0];if(yo.isList(l[0])){const t=l[0]["@list"];yo.isValue(n)?s=t.some((e=>_o(n,e))):(yo.isSubject(n)||yo.isSubjectReference(n))&&(s=t.some((t=>Ao(e,n,t,o))))}}else s=yo.isValue(t)?l.some((e=>_o(t,e))):yo.isSubjectReference(t)?l.some((n=>Ao(e,t,n,o))):!!mo.isObject(t)&&l.length>0}}if(!s&&o.requireAll)return!1;i=i||s}return r||i}function Lo(e,t){const n=e.uniqueEmbeds[e.graph],o=n[t],r=o.parent,i=o.property,a={"@id":t};if(mo.isArray(r)){for(let e=0;e<r.length;++e)if(xo.compareValues(r[e],a)){r[e]=a;break}}else{const e=mo.isArray(r[i]);xo.removeValue(r,i,a,{propertyIsArray:e}),xo.addValue(r,i,a,{propertyIsArray:e})}const s=e=>{const t=Object.keys(n);for(const o of t)o in n&&mo.isObject(n[o].parent)&&n[o].parent["@id"]===e&&(delete n[o],s(o))};s(t)}
28
28
  /**
29
29
  * Removes the @preserve keywords from expanded result of framing.
30
30
  *
@@ -36,7 +36,7 @@ const p=c["@id"];if("@context"===p||"@preserve"===p)throw new wt("Invalid JSON-L
36
36
  // remove @preserve
37
37
  if("@preserve"in e)return e["@preserve"][0];if(yo.isValue(e))return e;if(yo.isList(e))return e["@list"]=To(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]=To(e[n],t)}return e}function Ro(e,t,n){mo.isObject(e)?xo.addValue(e,t,n,{propertyIsArray:!0}):e.push(n)}function Ao(e,t,n,o){if(!("@id"in n))return!1;const r=e.subjects[n["@id"]];return r&&Co(e,r,t,o)}function _o(e,t){const n=t["@value"],o=t["@type"],r=t["@language"],i=e["@value"]?mo.isArray(e["@value"])?e["@value"]:[e["@value"]]:[],a=e["@type"]?mo.isArray(e["@type"])?e["@type"]:[e["@type"]]:[],s=e["@language"]?mo.isArray(e["@language"])?e["@language"]:[e["@language"]]:[];return 0===i.length&&0===a.length&&0===s.length||!(!i.includes(n)&&!mo.isEmptyObject(i[0]))&&(!!(!o&&0===a.length||a.includes(o)||o&&mo.isEmptyObject(a[0]))&&!!(!r&&0===s.length||s.includes(r)||r&&mo.isEmptyObject(s[0])))}So.frameMergedOrDefault=(e,t,n)=>{const o={options:n,embedded:!1,graph:"@default",graphMap:{"@default":{}},subjectStack:[],link:{},bnodeMap:{}},r=new xo.IdentifierIssuer("_:b");Io(e,o.graphMap,"@default",r),n.merged&&(o.graphMap["@merged"]=jo(o.graphMap),o.graph="@merged"),o.subjects=o.graphMap[o.graph];const i=[];return So.frame(o,Object.keys(o.subjects).sort(),t,i),n.pruneBlankNodeIdentifiers&&(n.bnodesToClear=Object.keys(o.bnodeMap).filter((e=>1===o.bnodeMap[e].length))),
38
38
  // remove @preserve from results
39
- n.link={},To(i,n)},So.frame=(e,t,n,o,r=null)=>{Do(n),n=n[0];const i=e.options,a={embed:Oo(n,i,"embed"),explicit:Oo(n,i,"explicit"),requireAll:Oo(n,i,"requireAll")};e.link.hasOwnProperty(e.graph)||(e.link[e.graph]={});const s=e.link[e.graph],l=function(e,t,n,o){const r={};for(const i of t){const t=e.graphMap[e.graph][i];Co(e,t,n,o)&&(r[i]=t)}return r}(e,t,n,a),c=Object.keys(l).sort();for(const d of c){const c=l[d];if(null===r?e.uniqueEmbeds={[e.graph]:{}}:e.uniqueEmbeds[e.graph]=e.uniqueEmbeds[e.graph]||{},"@link"===a.embed&&d in s){Ro(o,r,s[d]);continue}const u={"@id":d};if(0===d.indexOf("_:")&&xo.addValue(e.bnodeMap,d,u,{propertyIsArray:!0}),s[d]=u,("@first"===a.embed||"@last"===a.embed)&&e.is11)throw new wo("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"!==a.embed&&!Eo(c,e.graph,e.subjectStack))if(!e.embedded||"@first"!=a.embed&&"@once"!=a.embed||!e.uniqueEmbeds[e.graph].hasOwnProperty(d)){if("@last"===a.embed&&d in e.uniqueEmbeds[e.graph]&&Lo(e,d),e.uniqueEmbeds[e.graph][d]={parent:o,property:r},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),mo.isObject(o)||(o={})):(t="@merged"!==e.graph,o={}),t&&So.frame({...e,graph:d,embedded:!1},Object.keys(e.graphMap[d]).sort(),[o],u,"@graph")}"@included"in n&&So.frame({...e,embedded:!1},t,n["@included"],u,"@included");for(const t of Object.keys(c).sort())if(go(t)){if(u[t]=xo.clone(c[t]),"@type"===t)for(const t of c["@type"])0===t.indexOf("_:")&&xo.addValue(e.bnodeMap,t,u,{propertyIsArray:!0})}else if(!a.explicit||t in n)for(const o of c[t]){const r=t in n?n[t]:No(a);if(yo.isList(o)){const r=n[t]&&n[t][0]&&n[t][0]["@list"]?n[t][0]["@list"]:No(a),i={"@list":[]};Ro(u,t,i);const s=o["@list"];for(const t of s)yo.isSubjectReference(t)?So.frame({...e,embedded:!0},[t["@id"]],r,i,"@list"):Ro(i,"@list",xo.clone(t))}else yo.isSubjectReference(o)?So.frame({...e,embedded:!0},[o["@id"]],r,u,t):_o(r[0],o)&&Ro(u,t,xo.clone(o))}for(const e of Object.keys(n).sort()){if("@type"===e){if(!mo.isObject(n[e][0])||!("@default"in n[e][0]))continue}else if(go(e))continue;const t=n[e][0]||{};if(!Oo(t,i,"omitDefault")&&!(e in u)){let n="@null";"@default"in t&&(n=xo.clone(t["@default"])),mo.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)){xo.getValues(e.subjects[n],t).some((e=>e["@id"]===d))&&(u["@reverse"]=u["@reverse"]||{},xo.addValue(u["@reverse"],t,[],{propertyIsArray:!0}),So.frame({...e,embedded:!0},[n],o,u["@reverse"][t],r))}}Ro(o,r,u),e.subjectStack.pop()}else Ro(o,r,u);else Ro(o,r,u)}},So.cleanupNull=(e,t)=>{if(mo.isArray(e)){return e.map((e=>So.cleanupNull(e,t))).filter((e=>e))}if("@null"===e)return null;if(mo.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]=So.cleanupNull(e[n],t)}return e};const Po=Z,{isArray:Mo,isObject:Jo,isString:Ho,isUndefined:Bo}=K,{isList:Fo,isValue:Uo,isGraph:qo,isSimpleGraph:Vo,isSubjectReference:$o}=W,{expandIri:Go,getContextValue:zo,isKeyword:Ko,process:Qo,processingMode:Xo}=Pt,{removeBase:Wo,prependBase:Zo}=me(),{REGEX_KEYWORD:Yo,addValue:er,asArray:tr,compareShortestLeast:nr}=le,or={};var rr,ir,ar=or;function sr(e,t,n){if("@nest"!==Go(e,t,{vocab:!0},n))throw new Po("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}or.compact=async({activeCtx:e,activeProperty:t=null,element:n,options:o={}})=>{if(Mo(n)){let r=[];for(let i=0;i<n.length;++i){const a=await or.compact({activeCtx:e,activeProperty:t,element:n[i],options:o});null!==a&&r.push(a)}if(o.compactArrays&&1===r.length){0===(zo(e,t,"@container")||[]).length&&(r=r[0])}return r}const r=zo(e,t,"@context");if(Bo(r)||(e=await Qo({activeCtx:e,localCtx:r,propagate:!0,overrideProtected:!0,options:o})),Jo(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(Uo(n)||$o(n)){const r=or.compactValue({activeCtx:e,activeProperty:t,value:n,options:o});return o.link&&$o(n)&&(o.link.hasOwnProperty(n["@id"])||(o.link[n["@id"]]=[]),o.link[n["@id"]].push({expanded:n,compacted:r})),r}if(Fo(n)){if((zo(e,t,"@container")||[]).includes("@list"))return or.compact({activeCtx:e,activeProperty:t,element:n["@list"],options:o})}const r="@reverse"===t,i={},a=e;Uo(n)||$o(n)||(e=e.revertToPreviousContext());const s=zo(a,t,"@context");Bo(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:i}));let l=n["@type"]||[];l.length>1&&(l=Array.from(l).sort());const c=e;for(const t of l){const n=or.compactIri({activeCtx:c,iri:t,relativeTo:{vocab:!0}}),r=zo(a,n,"@context");Bo(r)||(e=await Qo({activeCtx:e,localCtx:r,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&&Ko(s)){const t=or.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});er(i,t,l)}else{if(!Mo(l))throw new Po("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===l.length){const t=or.compactIri({activeCtx:e,iri:s,value:l,relativeTo:{vocab:!0},reverse:r}),n=e.mappings.has(t)?e.mappings.get(t)["@nest"]:null;let a=i;n&&(sr(e,n,o),Jo(i[n])||(i[n]={}),a=i[n]),er(a,t,l,{propertyIsArray:!0})}for(const t of l){const n=or.compactIri({activeCtx:e,iri:s,value:t,relativeTo:{vocab:!0},reverse:r}),a=e.mappings.has(n)?e.mappings.get(n)["@nest"]:null;let l=i;a&&(sr(e,a,o),Jo(i[a])||(i[a]={}),l=i[a]);const c=zo(e,n,"@container")||[],d=qo(t),u=Fo(t);let p;u?p=t["@list"]:d&&(p=t["@graph"]);let h=await or.compact({activeCtx:e,activeProperty:n,element:u||d?p:t,options:o});if(u){if(Mo(h)||(h=[h]),c.includes("@list")){er(l,n,h,{valueIsArray:!0,allowDuplicate:!0});continue}h={[or.compactIri({activeCtx:e,iri:"@list",relativeTo:{vocab:!0}})]:h},"@index"in t&&(h[or.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"])}if(d)if(c.includes("@graph")&&(c.includes("@id")||c.includes("@index")&&Vo(t))){let r;l.hasOwnProperty(n)?r=l[n]:l[n]=r={};const i=(c.includes("@id")?t["@id"]:t["@index"])||or.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}});er(r,i,h,{propertyIsArray:!o.compactArrays||c.includes("@set")})}else c.includes("@graph")&&Vo(t)?(Mo(h)&&h.length>1&&(h={"@included":h}),er(l,n,h,{propertyIsArray:!o.compactArrays||c.includes("@set")})):(Mo(h)&&1===h.length&&o.compactArrays&&(h=h[0]),h={[or.compactIri({activeCtx:e,iri:"@graph",relativeTo:{vocab:!0}})]:h},"@id"in t&&(h[or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t["@id"]),"@index"in t&&(h[or.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"]),er(l,n,h,{propertyIsArray:!o.compactArrays||c.includes("@set")}));else if(c.includes("@language")||c.includes("@index")||c.includes("@id")||c.includes("@type")){let r,i;if(l.hasOwnProperty(n)?r=l[n]:l[n]=r={},c.includes("@language"))Uo(h)&&(h=h["@value"]),i=t["@language"];else if(c.includes("@index")){const o=zo(e,n,"@index")||"@index",r=or.compactIri({activeCtx:e,iri:o,relativeTo:{vocab:!0}});if("@index"===o)i=t["@index"],delete h[r];else{let e;if([i,...e]=tr(h[o]||[]),Ho(i))switch(e.length){case 0:delete h[o];break;case 1:h[o]=e[0];break;default:h[o]=e}else i=null}}else if(c.includes("@id")){const t=or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}});i=h[t],delete h[t]}else if(c.includes("@type")){const r=or.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}});let a;switch([i,...a]=tr(h[r]||[]),a.length){case 0:delete h[r];break;case 1:h[r]=a[0];break;default:h[r]=a}1===Object.keys(h).length&&"@id"in t&&(h=await or.compact({activeCtx:e,activeProperty:n,element:{"@id":t["@id"]},options:o}))}i||(i=or.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}})),er(r,i,h,{propertyIsArray:c.includes("@set")})}else{const e=!o.compactArrays||c.includes("@set")||c.includes("@list")||Mo(h)&&0===h.length||"@list"===s||"@graph"===s;er(l,n,h,{propertyIsArray:e})}}}else{if((zo(e,t,"@container")||[]).includes("@index"))continue;const n=or.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});er(i,n,l)}else{const n=await or.compact({activeCtx:e,activeProperty:t,element:l,options:o});Mo(n)&&0===n.length||er(i,s,n)}else{const t=await or.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 r=t[n],a=(zo(e,n,"@container")||[]).includes("@set")||!o.compactArrays;er(i,n,r,{propertyIsArray:a}),delete t[n]}if(Object.keys(t).length>0){const n=or.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});er(i,n,t)}}else{let t=tr(l).map((e=>or.compactIri({activeCtx:a,iri:e,relativeTo:{vocab:!0}})));1===t.length&&(t=t[0]);const n=or.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}}),o=(zo(e,n,"@container")||[]).includes("@set")&&Xo(e,1.1)||Mo(t)&&0===l.length;er(i,n,t,{propertyIsArray:o})}else{let t=tr(l).map((t=>or.compactIri({activeCtx:e,iri:t,relativeTo:{vocab:!1},base:o.base})));1===t.length&&(t=t[0]);i[or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t}}return i}return n},or.compactIri=({activeCtx:e,iri:t,value:n=null,relativeTo:o={vocab:!1},reverse:r=!1,base:i=null})=>{if(null===t)return t;e.isPropertyTermScoped&&e.previousContext&&(e=e.previousContext);const a=e.getInverse();if(Ko(t)&&t in a&&"@none"in a[t]&&"@type"in a[t]["@none"]&&"@none"in a[t]["@none"]["@type"])return a[t]["@none"]["@type"]["@none"];if(o.vocab&&t in a){const o=e["@language"]||"@none",i=[];Jo(n)&&"@index"in n&&!("@graph"in n)&&i.push("@index","@index@set"),Jo(n)&&"@preserve"in n&&(n=n["@preserve"][0]),qo(n)?("@index"in n&&i.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n&&i.push("@graph@id","@graph@id@set"),i.push("@graph","@graph@set","@set"),"@index"in n||i.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n||i.push("@graph@id","@graph@id@set")):Jo(n)&&!Uo(n)&&i.push("@id","@id@set","@type","@set@type");let a="@language",s="@null";if(r)a="@type",s="@reverse",i.push("@set");else if(Fo(n)){"@index"in n||i.push("@list");const e=n["@list"];if(0===e.length)a="@any",s="@none";else{let t=0===e.length?o:null,n=null;for(let o=0;o<e.length;++o){const r=e[o];let i="@none",a="@none";if(Uo(r))if("@direction"in r){i=`${(r["@language"]||"").toLowerCase()}_${r["@direction"]}`}else"@language"in r?i=r["@language"].toLowerCase():"@type"in r?a=r["@type"]:i="@null";else a="@id";if(null===t?t=i:i!==t&&Uo(r)&&(t="@none"),null===n?n=a:a!==n&&(n="@none"),"@none"===t&&"@none"===n)break}t=t||"@none",n=n||"@none","@none"!==n?(a="@type",s=n):s=t}}else{if(Uo(n))if("@language"in n&&!("@index"in n)){i.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&&(a="@type",s=n["@type"]);else a="@type",s="@id";i.push("@set")}i.push("@none"),Jo(n)&&!("@index"in n)&&i.push("@index","@index@set"),Uo(n)&&1===Object.keys(n).length&&i.push("@language","@language@set");const l=function(e,t,n,o,r,i){null===i&&(i="@null");const a=[];if(("@id"===i||"@reverse"===i)&&Jo(n)&&"@id"in n){"@reverse"===i&&a.push("@reverse");const t=or.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:!0}});e.mappings.has(t)&&e.mappings.get(t)&&e.mappings.get(t)["@id"]===n["@id"]?a.push.apply(a,["@vocab","@id"]):a.push.apply(a,["@id","@vocab"])}else{a.push(i);const e=a.find((e=>e.includes("_")));e&&a.push(e.replace(/^[^_]+_/,"_"))}a.push("@none");const s=e.inverse[t];for(const e of o){if(!(e in s))continue;const t=s[e][r];for(const e of a)if(e in t)return t[e]}return null}(e,t,n,i,a,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 r=l[o],i=r.terms;for(const o of i){const i=o+":"+t.substr(r.iri.length);e.mappings.get(o)._prefix&&(!e.mappings.has(i)||null===n&&e.mappings.get(i)["@id"]===t)&&(null===s||nr(i,s)<0)&&(s=i)}}if(null!==s)return s;for(const[n,o]of e.mappings)if(o&&o._prefix&&t.startsWith(n+":"))throw new Po(`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=Wo(Zo(i,e["@base"]),t);return Yo.test(n)?`./${n}`:n}return t}return Wo(i,t)}return t},or.compactValue=({activeCtx:e,activeProperty:t,value:n,options:o})=>{if(Uo(n)){const o=zo(e,t,"@type"),r=zo(e,t,"@language"),i=zo(e,t,"@direction"),a=zo(e,t,"@container")||[],s="@index"in n&&!a.includes("@index");if(!s&&"@none"!==o){if(n["@type"]===o)return n["@value"];if("@language"in n&&n["@language"]===r&&"@direction"in n&&n["@direction"]===i)return n["@value"];if("@language"in n&&n["@language"]===r)return n["@value"];if("@direction"in n&&n["@direction"]===i)return n["@value"]}const l=Object.keys(n).length,c=1===l||2===l&&"@index"in n&&!s,d="@language"in e,u=Ho(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[or.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=n["@index"]),"@type"in n?h[or.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=or.compactIri({activeCtx:e,iri:n["@type"],relativeTo:{vocab:!0}}):"@language"in n&&(h[or.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=n["@language"]),"@direction"in n&&(h[or.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=n["@direction"]),h[or.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=n["@value"],h}const r=Go(e,t,{vocab:!0},o),i=zo(e,t,"@type"),a=or.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:"@vocab"===i},base:o.base});return"@id"===i||"@vocab"===i||"@graph"===r?a:{[or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:a}};
39
+ n.link={},To(i,n)},So.frame=(e,t,n,o,r=null)=>{Do(n),n=n[0];const i=e.options,a={embed:Eo(n,i,"embed"),explicit:Eo(n,i,"explicit"),requireAll:Eo(n,i,"requireAll")};e.link.hasOwnProperty(e.graph)||(e.link[e.graph]={});const s=e.link[e.graph],l=function(e,t,n,o){const r={};for(const i of t){const t=e.graphMap[e.graph][i];Co(e,t,n,o)&&(r[i]=t)}return r}(e,t,n,a),c=Object.keys(l).sort();for(const d of c){const c=l[d];if(null===r?e.uniqueEmbeds={[e.graph]:{}}:e.uniqueEmbeds[e.graph]=e.uniqueEmbeds[e.graph]||{},"@link"===a.embed&&d in s){Ro(o,r,s[d]);continue}const u={"@id":d};if(0===d.indexOf("_:")&&xo.addValue(e.bnodeMap,d,u,{propertyIsArray:!0}),s[d]=u,("@first"===a.embed||"@last"===a.embed)&&e.is11)throw new wo("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"!==a.embed&&!Oo(c,e.graph,e.subjectStack))if(!e.embedded||"@first"!=a.embed&&"@once"!=a.embed||!e.uniqueEmbeds[e.graph].hasOwnProperty(d)){if("@last"===a.embed&&d in e.uniqueEmbeds[e.graph]&&Lo(e,d),e.uniqueEmbeds[e.graph][d]={parent:o,property:r},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),mo.isObject(o)||(o={})):(t="@merged"!==e.graph,o={}),t&&So.frame({...e,graph:d,embedded:!1},Object.keys(e.graphMap[d]).sort(),[o],u,"@graph")}"@included"in n&&So.frame({...e,embedded:!1},t,n["@included"],u,"@included");for(const t of Object.keys(c).sort())if(go(t)){if(u[t]=xo.clone(c[t]),"@type"===t)for(const t of c["@type"])0===t.indexOf("_:")&&xo.addValue(e.bnodeMap,t,u,{propertyIsArray:!0})}else if(!a.explicit||t in n)for(const o of c[t]){const r=t in n?n[t]:No(a);if(yo.isList(o)){const r=n[t]&&n[t][0]&&n[t][0]["@list"]?n[t][0]["@list"]:No(a),i={"@list":[]};Ro(u,t,i);const s=o["@list"];for(const t of s)yo.isSubjectReference(t)?So.frame({...e,embedded:!0},[t["@id"]],r,i,"@list"):Ro(i,"@list",xo.clone(t))}else yo.isSubjectReference(o)?So.frame({...e,embedded:!0},[o["@id"]],r,u,t):_o(r[0],o)&&Ro(u,t,xo.clone(o))}for(const e of Object.keys(n).sort()){if("@type"===e){if(!mo.isObject(n[e][0])||!("@default"in n[e][0]))continue}else if(go(e))continue;const t=n[e][0]||{};if(!Eo(t,i,"omitDefault")&&!(e in u)){let n="@null";"@default"in t&&(n=xo.clone(t["@default"])),mo.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)){xo.getValues(e.subjects[n],t).some((e=>e["@id"]===d))&&(u["@reverse"]=u["@reverse"]||{},xo.addValue(u["@reverse"],t,[],{propertyIsArray:!0}),So.frame({...e,embedded:!0},[n],o,u["@reverse"][t],r))}}Ro(o,r,u),e.subjectStack.pop()}else Ro(o,r,u);else Ro(o,r,u)}},So.cleanupNull=(e,t)=>{if(mo.isArray(e)){return e.map((e=>So.cleanupNull(e,t))).filter((e=>e))}if("@null"===e)return null;if(mo.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]=So.cleanupNull(e[n],t)}return e};const Po=Z,{isArray:Mo,isObject:Jo,isString:Ho,isUndefined:Bo}=K,{isList:Fo,isValue:Uo,isGraph:qo,isSimpleGraph:Vo,isSubjectReference:$o}=X,{expandIri:Go,getContextValue:zo,isKeyword:Ko,process:Qo,processingMode:Wo}=Pt,{removeBase:Xo,prependBase:Zo}=me(),{REGEX_KEYWORD:Yo,addValue:er,asArray:tr,compareShortestLeast:nr}=le,or={};var rr,ir,ar=or;function sr(e,t,n){if("@nest"!==Go(e,t,{vocab:!0},n))throw new Po("JSON-LD compact error; nested property must have an @nest value resolving to @nest.","jsonld.SyntaxError",{code:"invalid @nest value"})}or.compact=async({activeCtx:e,activeProperty:t=null,element:n,options:o={}})=>{if(Mo(n)){let r=[];for(let i=0;i<n.length;++i){const a=await or.compact({activeCtx:e,activeProperty:t,element:n[i],options:o});null!==a&&r.push(a)}if(o.compactArrays&&1===r.length){0===(zo(e,t,"@container")||[]).length&&(r=r[0])}return r}const r=zo(e,t,"@context");if(Bo(r)||(e=await Qo({activeCtx:e,localCtx:r,propagate:!0,overrideProtected:!0,options:o})),Jo(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(Uo(n)||$o(n)){const r=or.compactValue({activeCtx:e,activeProperty:t,value:n,options:o});return o.link&&$o(n)&&(o.link.hasOwnProperty(n["@id"])||(o.link[n["@id"]]=[]),o.link[n["@id"]].push({expanded:n,compacted:r})),r}if(Fo(n)){if((zo(e,t,"@container")||[]).includes("@list"))return or.compact({activeCtx:e,activeProperty:t,element:n["@list"],options:o})}const r="@reverse"===t,i={},a=e;Uo(n)||$o(n)||(e=e.revertToPreviousContext());const s=zo(a,t,"@context");Bo(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:i}));let l=n["@type"]||[];l.length>1&&(l=Array.from(l).sort());const c=e;for(const t of l){const n=or.compactIri({activeCtx:c,iri:t,relativeTo:{vocab:!0}}),r=zo(a,n,"@context");Bo(r)||(e=await Qo({activeCtx:e,localCtx:r,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&&Ko(s)){const t=or.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});er(i,t,l)}else{if(!Mo(l))throw new Po("JSON-LD expansion error; expanded value must be an array.","jsonld.SyntaxError");if(0===l.length){const t=or.compactIri({activeCtx:e,iri:s,value:l,relativeTo:{vocab:!0},reverse:r}),n=e.mappings.has(t)?e.mappings.get(t)["@nest"]:null;let a=i;n&&(sr(e,n,o),Jo(i[n])||(i[n]={}),a=i[n]),er(a,t,l,{propertyIsArray:!0})}for(const t of l){const n=or.compactIri({activeCtx:e,iri:s,value:t,relativeTo:{vocab:!0},reverse:r}),a=e.mappings.has(n)?e.mappings.get(n)["@nest"]:null;let l=i;a&&(sr(e,a,o),Jo(i[a])||(i[a]={}),l=i[a]);const c=zo(e,n,"@container")||[],d=qo(t),u=Fo(t);let p;u?p=t["@list"]:d&&(p=t["@graph"]);let h=await or.compact({activeCtx:e,activeProperty:n,element:u||d?p:t,options:o});if(u){if(Mo(h)||(h=[h]),c.includes("@list")){er(l,n,h,{valueIsArray:!0,allowDuplicate:!0});continue}h={[or.compactIri({activeCtx:e,iri:"@list",relativeTo:{vocab:!0}})]:h},"@index"in t&&(h[or.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"])}if(d)if(c.includes("@graph")&&(c.includes("@id")||c.includes("@index")&&Vo(t))){let r;l.hasOwnProperty(n)?r=l[n]:l[n]=r={};const i=(c.includes("@id")?t["@id"]:t["@index"])||or.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}});er(r,i,h,{propertyIsArray:!o.compactArrays||c.includes("@set")})}else c.includes("@graph")&&Vo(t)?(Mo(h)&&h.length>1&&(h={"@included":h}),er(l,n,h,{propertyIsArray:!o.compactArrays||c.includes("@set")})):(Mo(h)&&1===h.length&&o.compactArrays&&(h=h[0]),h={[or.compactIri({activeCtx:e,iri:"@graph",relativeTo:{vocab:!0}})]:h},"@id"in t&&(h[or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t["@id"]),"@index"in t&&(h[or.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=t["@index"]),er(l,n,h,{propertyIsArray:!o.compactArrays||c.includes("@set")}));else if(c.includes("@language")||c.includes("@index")||c.includes("@id")||c.includes("@type")){let r,i;if(l.hasOwnProperty(n)?r=l[n]:l[n]=r={},c.includes("@language"))Uo(h)&&(h=h["@value"]),i=t["@language"];else if(c.includes("@index")){const o=zo(e,n,"@index")||"@index",r=or.compactIri({activeCtx:e,iri:o,relativeTo:{vocab:!0}});if("@index"===o)i=t["@index"],delete h[r];else{let e;if([i,...e]=tr(h[o]||[]),Ho(i))switch(e.length){case 0:delete h[o];break;case 1:h[o]=e[0];break;default:h[o]=e}else i=null}}else if(c.includes("@id")){const t=or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}});i=h[t],delete h[t]}else if(c.includes("@type")){const r=or.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}});let a;switch([i,...a]=tr(h[r]||[]),a.length){case 0:delete h[r];break;case 1:h[r]=a[0];break;default:h[r]=a}1===Object.keys(h).length&&"@id"in t&&(h=await or.compact({activeCtx:e,activeProperty:n,element:{"@id":t["@id"]},options:o}))}i||(i=or.compactIri({activeCtx:e,iri:"@none",relativeTo:{vocab:!0}})),er(r,i,h,{propertyIsArray:c.includes("@set")})}else{const e=!o.compactArrays||c.includes("@set")||c.includes("@list")||Mo(h)&&0===h.length||"@list"===s||"@graph"===s;er(l,n,h,{propertyIsArray:e})}}}else{if((zo(e,t,"@container")||[]).includes("@index"))continue;const n=or.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});er(i,n,l)}else{const n=await or.compact({activeCtx:e,activeProperty:t,element:l,options:o});Mo(n)&&0===n.length||er(i,s,n)}else{const t=await or.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 r=t[n],a=(zo(e,n,"@container")||[]).includes("@set")||!o.compactArrays;er(i,n,r,{propertyIsArray:a}),delete t[n]}if(Object.keys(t).length>0){const n=or.compactIri({activeCtx:e,iri:s,relativeTo:{vocab:!0}});er(i,n,t)}}else{let t=tr(l).map((e=>or.compactIri({activeCtx:a,iri:e,relativeTo:{vocab:!0}})));1===t.length&&(t=t[0]);const n=or.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}}),o=(zo(e,n,"@container")||[]).includes("@set")&&Wo(e,1.1)||Mo(t)&&0===l.length;er(i,n,t,{propertyIsArray:o})}else{let t=tr(l).map((t=>or.compactIri({activeCtx:e,iri:t,relativeTo:{vocab:!1},base:o.base})));1===t.length&&(t=t[0]);i[or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]=t}}return i}return n},or.compactIri=({activeCtx:e,iri:t,value:n=null,relativeTo:o={vocab:!1},reverse:r=!1,base:i=null})=>{if(null===t)return t;e.isPropertyTermScoped&&e.previousContext&&(e=e.previousContext);const a=e.getInverse();if(Ko(t)&&t in a&&"@none"in a[t]&&"@type"in a[t]["@none"]&&"@none"in a[t]["@none"]["@type"])return a[t]["@none"]["@type"]["@none"];if(o.vocab&&t in a){const o=e["@language"]||"@none",i=[];Jo(n)&&"@index"in n&&!("@graph"in n)&&i.push("@index","@index@set"),Jo(n)&&"@preserve"in n&&(n=n["@preserve"][0]),qo(n)?("@index"in n&&i.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n&&i.push("@graph@id","@graph@id@set"),i.push("@graph","@graph@set","@set"),"@index"in n||i.push("@graph@index","@graph@index@set","@index","@index@set"),"@id"in n||i.push("@graph@id","@graph@id@set")):Jo(n)&&!Uo(n)&&i.push("@id","@id@set","@type","@set@type");let a="@language",s="@null";if(r)a="@type",s="@reverse",i.push("@set");else if(Fo(n)){"@index"in n||i.push("@list");const e=n["@list"];if(0===e.length)a="@any",s="@none";else{let t=0===e.length?o:null,n=null;for(let o=0;o<e.length;++o){const r=e[o];let i="@none",a="@none";if(Uo(r))if("@direction"in r){i=`${(r["@language"]||"").toLowerCase()}_${r["@direction"]}`}else"@language"in r?i=r["@language"].toLowerCase():"@type"in r?a=r["@type"]:i="@null";else a="@id";if(null===t?t=i:i!==t&&Uo(r)&&(t="@none"),null===n?n=a:a!==n&&(n="@none"),"@none"===t&&"@none"===n)break}t=t||"@none",n=n||"@none","@none"!==n?(a="@type",s=n):s=t}}else{if(Uo(n))if("@language"in n&&!("@index"in n)){i.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&&(a="@type",s=n["@type"]);else a="@type",s="@id";i.push("@set")}i.push("@none"),Jo(n)&&!("@index"in n)&&i.push("@index","@index@set"),Uo(n)&&1===Object.keys(n).length&&i.push("@language","@language@set");const l=function(e,t,n,o,r,i){null===i&&(i="@null");const a=[];if(("@id"===i||"@reverse"===i)&&Jo(n)&&"@id"in n){"@reverse"===i&&a.push("@reverse");const t=or.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:!0}});e.mappings.has(t)&&e.mappings.get(t)&&e.mappings.get(t)["@id"]===n["@id"]?a.push.apply(a,["@vocab","@id"]):a.push.apply(a,["@id","@vocab"])}else{a.push(i);const e=a.find((e=>e.includes("_")));e&&a.push(e.replace(/^[^_]+_/,"_"))}a.push("@none");const s=e.inverse[t];for(const e of o){if(!(e in s))continue;const t=s[e][r];for(const e of a)if(e in t)return t[e]}return null}(e,t,n,i,a,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 r=l[o],i=r.terms;for(const o of i){const i=o+":"+t.substr(r.iri.length);e.mappings.get(o)._prefix&&(!e.mappings.has(i)||null===n&&e.mappings.get(i)["@id"]===t)&&(null===s||nr(i,s)<0)&&(s=i)}}if(null!==s)return s;for(const[n,o]of e.mappings)if(o&&o._prefix&&t.startsWith(n+":"))throw new Po(`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=Xo(Zo(i,e["@base"]),t);return Yo.test(n)?`./${n}`:n}return t}return Xo(i,t)}return t},or.compactValue=({activeCtx:e,activeProperty:t,value:n,options:o})=>{if(Uo(n)){const o=zo(e,t,"@type"),r=zo(e,t,"@language"),i=zo(e,t,"@direction"),a=zo(e,t,"@container")||[],s="@index"in n&&!a.includes("@index");if(!s&&"@none"!==o){if(n["@type"]===o)return n["@value"];if("@language"in n&&n["@language"]===r&&"@direction"in n&&n["@direction"]===i)return n["@value"];if("@language"in n&&n["@language"]===r)return n["@value"];if("@direction"in n&&n["@direction"]===i)return n["@value"]}const l=Object.keys(n).length,c=1===l||2===l&&"@index"in n&&!s,d="@language"in e,u=Ho(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[or.compactIri({activeCtx:e,iri:"@index",relativeTo:{vocab:!0}})]=n["@index"]),"@type"in n?h[or.compactIri({activeCtx:e,iri:"@type",relativeTo:{vocab:!0}})]=or.compactIri({activeCtx:e,iri:n["@type"],relativeTo:{vocab:!0}}):"@language"in n&&(h[or.compactIri({activeCtx:e,iri:"@language",relativeTo:{vocab:!0}})]=n["@language"]),"@direction"in n&&(h[or.compactIri({activeCtx:e,iri:"@direction",relativeTo:{vocab:!0}})]=n["@direction"]),h[or.compactIri({activeCtx:e,iri:"@value",relativeTo:{vocab:!0}})]=n["@value"],h}const r=Go(e,t,{vocab:!0},o),i=zo(e,t,"@type"),a=or.compactIri({activeCtx:e,iri:n["@id"],relativeTo:{vocab:"@vocab"===i},base:o.base});return"@id"===i||"@vocab"===i||"@graph"===r?a:{[or.compactIri({activeCtx:e,iri:"@id",relativeTo:{vocab:!0}})]:a}};
40
40
  /**
41
41
  * A JavaScript implementation of the JSON-LD API.
42
42
  *
@@ -72,4 +72,4 @@ n.link={},To(i,n)},So.frame=(e,t,n,o,r=null)=>{Do(n),n=n[0];const i=e.options,a=
72
72
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
73
73
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74
74
  */
75
- const lr=G,cr=Ce,dr=le,ur=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:e,context:t,documentLoader:n,base:o,cycles:r=new Set}){t&&rt(t)&&t["@context"]&&(t=t["@context"]),t=at(t);const i=[];for(const a of t){if(it(a)){let t=this._get(a);t||(t=await this._resolveRemoteContext({activeCtx:e,url:a,documentLoader:n,base:o,cycles:r})),ot(t)?i.push(...t):i.push(t);continue}if(null===a){i.push(new ct({document:null}));continue}rt(a)||dt(t);const s=JSON.stringify(a);let l=this._get(s);l||(l=new ct({document:a}),this._cacheResolvedContext({key:s,resolved:l,tag:"static"})),i.push(l)}return i}_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:r}){t=st(o,t);const{context:i,remoteDoc:a}=await this._fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:r});ut({context:i,base:o=a.documentUrl||t});const s=await this.resolve({activeCtx:e,context:i,documentLoader:n,base:o,cycles:r});return this._cacheResolvedContext({key:t,resolved:s,tag:a.tag}),s}async _fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:o}){if(o.size>10)throw new lt("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 lt("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"recursive context inclusion":"context overflow",url:t});let r,i;o.add(t);try{i=await n(t),r=i.document||null,it(r)&&(r=JSON.parse(r))}catch(e){throw new lt("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(!rt(r))throw new lt("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 r="@context"in r?{"@context":r["@context"]}:{"@context":{}},i.contextUrl&&(ot(r["@context"])||(r["@context"]=[r["@context"]]),r["@context"].push(i.contextUrl)),{context:r,remoteDoc:i}}},pr=dr.IdentifierIssuer,hr=Z,fr=tt,vr=pt,{expand:gr}=dn,{flatten:yr}=Nn,{fromRDF:mr}=Vn,{toRDF:xr}=ho,{frameMergedOrDefault:br,cleanupNull:wr}=ko,{isArray:Ir,isObject:jr,isString:Sr}=K,{isSubjectReference:kr}=W,{expandIri:Nr,getInitialContext:Er,process:Or,processingMode:Dr}=Pt,{compact:Cr,compactIri:Lr}=ar,{createNodeMap:Tr,createMergedNodeMap:Rr,mergeNodeMaps:Ar}=In,{logEventHandler:_r,logWarningEventHandler:Pr,safeEventHandler:Mr,setDefaultEventHandler:Jr,setupEventHandler:Hr,strictEventHandler:Br,unhandledEventHandler:Fr}=yt,Ur=function(e){const t={},n=new fr({max:100});function o(t,{documentLoader:n=e.documentLoader,...o}){if(t&&"compactionMap"in t)throw new hr('"compactionMap" not supported.',"jsonld.OptionsError");if(t&&"expansionMap"in t)throw new hr('"expansionMap" not supported.',"jsonld.OptionsError");return Object.assign({},{documentLoader:n},o,t,{eventHandler:Hr({options:t})})}return e.compact=async function(t,r,i){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");if(null===r)throw new hr("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"});if(null===t)return null;let a;(i=o(i,{base:Sr(t)?t:"",compactArrays:!0,compactToRelative:!0,graph:!1,skipExpansion:!1,link:!1,issuer:new pr("_:b"),contextResolver:new ur({sharedCache:n})})).link&&(i.skipExpansion=!0),i.compactToRelative||delete i.base,a=i.skipExpansion?t:await e.expand(t,i);const s=await e.processContext(Er(i),r,i);let l=await Cr({activeCtx:s,element:a,options:i});i.compactArrays&&!i.graph&&Ir(l)?1===l.length?l=l[0]:0===l.length&&(l={}):i.graph&&jr(l)&&(l=[l]),jr(r)&&"@context"in r&&(r=r["@context"]),r=dr.clone(r),Ir(r)||(r=[r]);const c=r;r=[];for(let e=0;e<c.length;++e)(!jr(c[e])||Object.keys(c[e]).length>0)&&r.push(c[e]);const d=r.length>0;if(1===r.length&&(r=r[0]),Ir(l)){const e=Lr({activeCtx:s,iri:"@graph",relativeTo:{vocab:!0}}),t=l;l={},d&&(l["@context"]=r),l[e]=t}else if(jr(l)&&d){const e=l;l={"@context":r};for(const t in e)l[t]=e[t]}return l},e.expand=async function(t,r){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");const i={},a=[];if("expandContext"in(r=o(r,{keepFreeFloatingNodes:!1,contextResolver:new ur({sharedCache:n})}))){const e=dr.clone(r.expandContext);jr(e)&&"@context"in e?i.expandContext=e:i.expandContext={"@context":e},a.push(i.expandContext)}let s;if(Sr(t)){const n=await e.get(t,r);s=n.documentUrl,i.input=n.document,n.contextUrl&&(i.remoteContext={"@context":n.contextUrl},a.push(i.remoteContext))}else i.input=dr.clone(t);"base"in r||(r.base=s||"");let l=Er(r);for(const e of a)l=await Or({activeCtx:l,localCtx:e,options:r});let c=await gr({activeCtx:l,element:i.input,options:r});return jr(c)&&"@graph"in c&&1===Object.keys(c).length?c=c["@graph"]:null===c&&(c=[]),Ir(c)||(c=[c]),c},e.flatten=async function(t,r,i){if(arguments.length<1)return new TypeError("Could not flatten, too few arguments.");r="function"==typeof r?null:r||null,i=o(i,{base:Sr(t)?t:"",contextResolver:new ur({sharedCache:n})});const a=await e.expand(t,i),s=yr(a);if(null===r)return s;i.graph=!0,i.skipExpansion=!0;return await e.compact(s,r,i)},e.frame=async function(t,r,i){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");if(i=o(i,{base:Sr(t)?t:"",embed:"@once",explicit:!1,requireAll:!1,omitDefault:!1,bnodesToClear:[],contextResolver:new ur({sharedCache:n})}),Sr(r)){const t=await e.get(r,i);if(r=t.document,t.contextUrl){let e=r["@context"];e?Ir(e)?e.push(t.contextUrl):e=[e,t.contextUrl]:e=t.contextUrl,r["@context"]=e}}const a=r&&r["@context"]||{},s=await e.processContext(Er(i),a,i);i.hasOwnProperty("omitGraph")||(i.omitGraph=Dr(s,1.1)),i.hasOwnProperty("pruneBlankNodeIdentifiers")||(i.pruneBlankNodeIdentifiers=Dr(s,1.1));const l=await e.expand(t,i),c={...i};c.isFrame=!0,c.keepFreeFloatingNodes=!0;const d=await e.expand(r,c),u=Object.keys(r).map((e=>Nr(s,e,{vocab:!0})));c.merged=!u.includes("@graph"),c.is11=Dr(s,1.1);const p=br(l,d,c);c.graph=!i.omitGraph,c.skipExpansion=!0,c.link={},c.framing=!0;let h=await e.compact(p,a,c);return c.link={},h=wr(h,c),h},e.link=async function(t,n,o){const r={};return n&&(r["@context"]=n),r["@embed"]="@link",e.frame(t,r,o)},e.normalize=e.canonize=async function(t,r){if(arguments.length<1)throw new TypeError("Could not canonize, too few arguments.");if("inputFormat"in(r=o(r,{base:Sr(t)?t:null,algorithm:"URDNA2015",skipExpansion:!1,safe:!0,contextResolver:new ur({sharedCache:n})}))){if("application/n-quads"!==r.inputFormat&&"application/nquads"!==r.inputFormat)throw new hr("Unknown canonicalization input format.","jsonld.CanonizeError");const e=vr.parse(t);return lr.canonize(e,r)}const i={...r};delete i.format,i.produceGeneralizedRdf=!1;const a=await e.toRDF(t,i);return lr.canonize(a,r)},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:Sr(e)?"application/n-quads":void 0});const{format:r}=n;let{rdfParser:i}=n;if(r){if(i=i||t[r],!i)throw new hr("Unknown input format.","jsonld.UnknownFormat",{format:r})}else i=()=>e;const a=await i(e);return mr(a,n)},e.toRDF=async function(t,r){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");let i;i=(r=o(r,{base:Sr(t)?t:"",skipExpansion:!1,contextResolver:new ur({sharedCache:n})})).skipExpansion?t:await e.expand(t,r);const a=xr(i,r);if(r.format){if("application/n-quads"===r.format||"application/nquads"===r.format)return vr.serialize(a);throw new hr("Unknown output format.","jsonld.UnknownFormat",{format:r.format})}return a},e.createNodeMap=async function(t,r){if(arguments.length<1)throw new TypeError("Could not create node map, too few arguments.");r=o(r,{base:Sr(t)?t:"",contextResolver:new ur({sharedCache:n})});const i=await e.expand(t,r);return Rr(i,r)},e.merge=async function(t,r,i){if(arguments.length<1)throw new TypeError("Could not merge, too few arguments.");if(!Ir(t))throw new TypeError('Could not merge, "docs" must be an array.');r="function"==typeof r?null:r||null,i=o(i,{contextResolver:new ur({sharedCache:n})});const a=await Promise.all(t.map((t=>{const n={...i};return e.expand(t,n)})));let s=!0;"mergeNodes"in i&&(s=i.mergeNodes);const l=i.issuer||new pr("_:b"),c={"@default":{}};for(let e=0;e<a.length;++e){const t=dr.relabelBlankNodes(a[e],{issuer:new pr("_:b"+e+"-")}),n=s||0===e?c:{"@default":{}};if(Tr(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=Ar(c),u=[],p=Object.keys(d).sort();for(let e=0;e<p.length;++e){const t=d[p[e]];kr(t)||u.push(t)}if(null===r)return u;i.graph=!0,i.skipExpansion=!0;return await e.compact(u,r,i)},Object.defineProperty(e,"documentLoader",{get:()=>e._documentLoader,set:t=>e._documentLoader=t}),e.documentLoader=async e=>{throw new hr("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 r=await o(t);try{if(!r.document)throw new hr("No remote document found at the given URL.","jsonld.NullRemoteDocument");Sr(r.document)&&(r.document=JSON.parse(r.document))}catch(e){throw new hr("Could not retrieve a JSON-LD document from the URL.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:r})}return r},e.processContext=async function(e,t,r){return r=o(r,{base:"",contextResolver:new ur({sharedCache:n})}),null===t?Er(r):(t=dr.clone(t),jr(t)&&"@context"in t||(t={"@context":t}),Or({activeCtx:e,localCtx:t,options:r}))},e.getContextValue=Pt.getContextValue,e.documentLoaders={},e.useDocumentLoader=function(t){if(!(t in e.documentLoaders))throw new hr('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",vr.parse),e.registerRDFParser("application/nquads",vr.parse),e.url=me(),e.logEventHandler=_r,e.logWarningEventHandler=Pr,e.safeEventHandler=Mr,e.setDefaultEventHandler=Jr,e.strictEventHandler=Br,e.unhandledEventHandler=Fr,e.util=dr,Object.assign(e,dr),e.promises=e,e.RequestQueue=ye(),e.JsonLdProcessor=(ir||(ir=1,rr=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}),rr)(e),cr.setupGlobals(e),cr.setupDocumentLoaders(e),e},qr=function(){return Ur((function(){return qr()}))};Ur(qr);var Vr,$r=c(qr),Gr={exports:{}},zr={exports:{}};function Kr(){return Vr||(Vr=1,t=zr,function(e){var n={bytesToHex:function(e){return function(e){return e.map((function(e){return t=e.toString(16),n=2,t.length>n?t:Array(n-t.length+1).join("0")+t;var t,n})).join("")}(e)},hexToBytes:function(e){if(e.length%2==1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return 0===e.indexOf("0x")&&(e=e.slice(2)),e.match(/../g).map((function(e){return parseInt(e,16)}))}};t.exports?t.exports=n:e.convertHex=n}(e)),zr.exports;var t}var Qr,Xr,Wr={exports:{}};Xr=Gr,function(t){var n={};Xr.exports?(n.bytesToHex=Kr().bytesToHex,n.convertString=function(){return Qr||(Qr=1,t=Wr,function(e){var n={bytesToString:function(e){return e.map((function(e){return String.fromCharCode(e)})).join("")},stringToBytes:function(e){return e.split("").map((function(e){return e.charCodeAt(0)}))}};n.UTF8={bytesToString:function(e){return decodeURIComponent(escape(n.bytesToString(e)))},stringToBytes:function(e){return n.stringToBytes(unescape(encodeURIComponent(e)))}},t.exports?t.exports=n:e.convertString=n}(e)),Wr.exports;var t}(),Xr.exports=l):(n.bytesToHex=t.convertHex.bytesToHex,n.convertString=t.convertString,t.sha256=l);var o=[];!function(){function e(e){for(var t=Math.sqrt(e),n=2;n<=t;n++)if(!(e%n))return!1;return!0}function t(e){return 4294967296*(e-(0|e))|0}for(var n=2,r=0;r<64;)e(n)&&(o[r]=t(Math.pow(n,1/3)),r++),n++}();var r=function(e){for(var t=[],n=0,o=0;n<e.length;n++,o+=8)t[o>>>5]|=e[n]<<24-o%32;return t},i=function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},a=[],s=function(e,t,n){for(var r=e[0],i=e[1],s=e[2],l=e[3],c=e[4],d=e[5],u=e[6],p=e[7],h=0;h<64;h++){if(h<16)a[h]=0|t[n+h];else{var f=a[h-15],v=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=a[h-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;a[h]=v+a[h-7]+y+a[h-16]}var m=r&i^r&s^i&s,x=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=p+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&d^~c&u)+o[h]+a[h];p=u,u=d,d=c,c=l+b|0,l=s,s=i,i=r,r=b+(x+m)|0}e[0]=e[0]+r|0,e[1]=e[1]+i|0,e[2]=e[2]+s|0,e[3]=e[3]+l|0,e[4]=e[4]+c|0,e[5]=e[5]+d|0,e[6]=e[6]+u|0,e[7]=e[7]+p|0};function l(e,t){e.constructor===String&&(e=n.convertString.UTF8.stringToBytes(e));var o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],a=r(e),l=8*e.length;a[l>>5]|=128<<24-l%32,a[15+(l+64>>9<<4)]=l;for(var c=0;c<a.length;c+=16)s(o,a,c);var d=i(o);return t&&t.asBytes?d:t&&t.asString?n.convertString.bytesToString(d):n.bytesToHex(d)}l.x2=function(e,t){return l(l(e,{asBytes:!0}),t)}}(e);var Zr=c(Gr.exports);function Yr(e){e=e.trim();const t=[];for(let n=0;n<e.length;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}const ei="__IMAGE__SIGNATURE__";function ti(e){if(!Array.isArray(e["@context"])||Array.isArray(e["@context"])&&null==e["@context"][0]["image:signature"])return e;const t=JSON.parse(JSON.stringify(e));return t["@context"][0][ei]=e["@context"][0]["image:signature"],delete t["@context"][0]["image:signature"],t}async function ni(e){Array.isArray(e["@context"])&&!e["@context"].find((e=>r(e)&&"@vocab"in e))&&e["@context"].push({"@vocab":"http://fallback.org/"});const t=(n=e,null!=n.document?.assertion?.["image:signature"]&&(n.document.assertion[ei]=n.document.assertion["image:signature"],delete n.document.assertion["image:signature"]),n);var n;const o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in d?{contextUrl:null,document:ti(d[e]),documentUrl:e}:$r.documentLoader(e)},safe:!1};let s;try{s=await $r.normalize(t.document,o)}catch(e){throw console.error(e),new i("computeLocalHash",a("errors","failedJsonLdNormalization"))}const l=function(e){const t=e.split("\n"),n=/<http:\/\/fallback\.org\/(.*)>/,o=t.map((e=>n.exec(e))).filter((e=>null!=e));if(o.length>0){const e=o.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(s);if(l)throw new i("computeLocalHash",`${a("errors","foundUnmappedFields")}: ${l.join(", ")}`);return Zr(function(e){const t=[];for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t.push(o):o<2048?t.push(192|o>>6,128|63&o):o<55296||o>=57344?t.push(224|o>>12,128|o>>6&63,128|63&o):(n++,o=65536+((1023&o)<<10|1023&e.charCodeAt(n)),t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o))}return t}(s))}function oi(e,t,n){let o="";const r=function(e,t){let n=null;for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&o.toLowerCase()===t.toLowerCase()&&(n=o);return e[n]}(e,t),l=s(n);if(r?(r.created&&l<=r.created&&(o="invalidIssuingAddressCreationTime"),r.revoked&&l>=r.revoked&&(o="invalidIssuingAddressRevoked"),r.expires&&l>=r.expires&&(o="invalidIssuingAddressExpired")):o="invalidIssuingAddressUnknown",o)throw new i("checkAuthenticity",a("errors",o))}class ri{constructor(e){}}var ii;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(ii||(ii={}));class ai extends ri{verificationProcess=[ii.getTransactionId,ii.computeLocalHash,ii.fetchRemoteHash,ii.compareHashes,ii.checkMerkleRoot,ii.checkReceipt,ii.parseIssuerKeys,ii.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.explorerAPIs=e.explorerAPIs,this.issuer=e.issuer,this.proof=e.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature??this.documentToVerify.receipt,this.chain=t.certificates.getChain("",this.receipt),this.transactionId=t.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((n=>t.verifier.convertToVerificationSubsteps(e,n)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return t.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.txData.time.toString()}getProofType(){return Array.isArray(this.proof.type)?this.proof.type[0]:this.proof.type}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return t.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return t.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return t.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){const e=[this.type,"ChainpointSHA256v2"],t=this.getProofType();if(!e.includes(t))throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){t.chains.isMockChain(this.chain)&&(n(this.verificationProcess,ii.getTransactionId),n(this.verificationProcess,ii.fetchRemoteHash),n(this.verificationProcess,ii.parseIssuerKeys),n(this.verificationProcess,ii.checkMerkleRoot),n(this.verificationProcess,ii.checkAuthenticity))}async executeStep(e,t,n){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(ii.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new i("getTransactionId",a("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(ii.computeLocalHash,(async()=>await ni(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(ii.fetchRemoteHash,(async()=>await t.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(ii.compareHashes,(()=>function(e,t){if(e!==t)throw new i("compareHashes",a("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(ii.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new i("checkMerkleRoot",a("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(ii.checkReceipt,(()=>{!function(e){let t=e.targetHash;const n=e.merkleRoot;try{const n=e.proof??e.path;if(n)for(const e in n){const o=n[e];let r;if(void 0!==o.left)r=Yr(`${o.left}${t}`),t=Zr(r);else{if(void 0===o.right)throw new i("checkReceipt","Trigger catch error.");r=Yr(`${t}${o.right}`),t=Zr(r)}}}catch(e){throw new i("checkReceipt",a("errors","ensureValidReceipt"))}if(t!==n)throw new i("checkReceipt",a("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(ii.parseIssuerKeys,(()=>t.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(ii.checkAuthenticity,(()=>{oi(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{ai as default};
75
+ const lr=G,cr=Ce,dr=le,ur=class{constructor({sharedCache:e}){this.perOpCache=new Map,this.sharedCache=e}async resolve({activeCtx:e,context:t,documentLoader:n,base:o,cycles:r=new Set}){t&&rt(t)&&t["@context"]&&(t=t["@context"]),t=at(t);const i=[];for(const a of t){if(it(a)){let t=this._get(a);t||(t=await this._resolveRemoteContext({activeCtx:e,url:a,documentLoader:n,base:o,cycles:r})),ot(t)?i.push(...t):i.push(t);continue}if(null===a){i.push(new ct({document:null}));continue}rt(a)||dt(t);const s=JSON.stringify(a);let l=this._get(s);l||(l=new ct({document:a}),this._cacheResolvedContext({key:s,resolved:l,tag:"static"})),i.push(l)}return i}_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:r}){t=st(o,t);const{context:i,remoteDoc:a}=await this._fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:r});ut({context:i,base:o=a.documentUrl||t});const s=await this.resolve({activeCtx:e,context:i,documentLoader:n,base:o,cycles:r});return this._cacheResolvedContext({key:t,resolved:s,tag:a.tag}),s}async _fetchContext({activeCtx:e,url:t,documentLoader:n,cycles:o}){if(o.size>10)throw new lt("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 lt("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"json-ld-1.0"===e.processingMode?"recursive context inclusion":"context overflow",url:t});let r,i;o.add(t);try{i=await n(t),r=i.document||null,it(r)&&(r=JSON.parse(r))}catch(e){throw new lt("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(!rt(r))throw new lt("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 r="@context"in r?{"@context":r["@context"]}:{"@context":{}},i.contextUrl&&(ot(r["@context"])||(r["@context"]=[r["@context"]]),r["@context"].push(i.contextUrl)),{context:r,remoteDoc:i}}},pr=dr.IdentifierIssuer,hr=Z,fr=tt,vr=pt,{expand:gr}=dn,{flatten:yr}=Nn,{fromRDF:mr}=Vn,{toRDF:xr}=ho,{frameMergedOrDefault:br,cleanupNull:wr}=ko,{isArray:Ir,isObject:jr,isString:Sr}=K,{isSubjectReference:kr}=X,{expandIri:Nr,getInitialContext:Or,process:Er,processingMode:Dr}=Pt,{compact:Cr,compactIri:Lr}=ar,{createNodeMap:Tr,createMergedNodeMap:Rr,mergeNodeMaps:Ar}=In,{logEventHandler:_r,logWarningEventHandler:Pr,safeEventHandler:Mr,setDefaultEventHandler:Jr,setupEventHandler:Hr,strictEventHandler:Br,unhandledEventHandler:Fr}=yt,Ur=function(e){const t={},n=new fr({max:100});function o(t,{documentLoader:n=e.documentLoader,...o}){if(t&&"compactionMap"in t)throw new hr('"compactionMap" not supported.',"jsonld.OptionsError");if(t&&"expansionMap"in t)throw new hr('"expansionMap" not supported.',"jsonld.OptionsError");return Object.assign({},{documentLoader:n},o,t,{eventHandler:Hr({options:t})})}return e.compact=async function(t,r,i){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");if(null===r)throw new hr("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"});if(null===t)return null;let a;(i=o(i,{base:Sr(t)?t:"",compactArrays:!0,compactToRelative:!0,graph:!1,skipExpansion:!1,link:!1,issuer:new pr("_:b"),contextResolver:new ur({sharedCache:n})})).link&&(i.skipExpansion=!0),i.compactToRelative||delete i.base,a=i.skipExpansion?t:await e.expand(t,i);const s=await e.processContext(Or(i),r,i);let l=await Cr({activeCtx:s,element:a,options:i});i.compactArrays&&!i.graph&&Ir(l)?1===l.length?l=l[0]:0===l.length&&(l={}):i.graph&&jr(l)&&(l=[l]),jr(r)&&"@context"in r&&(r=r["@context"]),r=dr.clone(r),Ir(r)||(r=[r]);const c=r;r=[];for(let e=0;e<c.length;++e)(!jr(c[e])||Object.keys(c[e]).length>0)&&r.push(c[e]);const d=r.length>0;if(1===r.length&&(r=r[0]),Ir(l)){const e=Lr({activeCtx:s,iri:"@graph",relativeTo:{vocab:!0}}),t=l;l={},d&&(l["@context"]=r),l[e]=t}else if(jr(l)&&d){const e=l;l={"@context":r};for(const t in e)l[t]=e[t]}return l},e.expand=async function(t,r){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");const i={},a=[];if("expandContext"in(r=o(r,{keepFreeFloatingNodes:!1,contextResolver:new ur({sharedCache:n})}))){const e=dr.clone(r.expandContext);jr(e)&&"@context"in e?i.expandContext=e:i.expandContext={"@context":e},a.push(i.expandContext)}let s;if(Sr(t)){const n=await e.get(t,r);s=n.documentUrl,i.input=n.document,n.contextUrl&&(i.remoteContext={"@context":n.contextUrl},a.push(i.remoteContext))}else i.input=dr.clone(t);"base"in r||(r.base=s||"");let l=Or(r);for(const e of a)l=await Er({activeCtx:l,localCtx:e,options:r});let c=await gr({activeCtx:l,element:i.input,options:r});return jr(c)&&"@graph"in c&&1===Object.keys(c).length?c=c["@graph"]:null===c&&(c=[]),Ir(c)||(c=[c]),c},e.flatten=async function(t,r,i){if(arguments.length<1)return new TypeError("Could not flatten, too few arguments.");r="function"==typeof r?null:r||null,i=o(i,{base:Sr(t)?t:"",contextResolver:new ur({sharedCache:n})});const a=await e.expand(t,i),s=yr(a);if(null===r)return s;i.graph=!0,i.skipExpansion=!0;return await e.compact(s,r,i)},e.frame=async function(t,r,i){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");if(i=o(i,{base:Sr(t)?t:"",embed:"@once",explicit:!1,requireAll:!1,omitDefault:!1,bnodesToClear:[],contextResolver:new ur({sharedCache:n})}),Sr(r)){const t=await e.get(r,i);if(r=t.document,t.contextUrl){let e=r["@context"];e?Ir(e)?e.push(t.contextUrl):e=[e,t.contextUrl]:e=t.contextUrl,r["@context"]=e}}const a=r&&r["@context"]||{},s=await e.processContext(Or(i),a,i);i.hasOwnProperty("omitGraph")||(i.omitGraph=Dr(s,1.1)),i.hasOwnProperty("pruneBlankNodeIdentifiers")||(i.pruneBlankNodeIdentifiers=Dr(s,1.1));const l=await e.expand(t,i),c={...i};c.isFrame=!0,c.keepFreeFloatingNodes=!0;const d=await e.expand(r,c),u=Object.keys(r).map((e=>Nr(s,e,{vocab:!0})));c.merged=!u.includes("@graph"),c.is11=Dr(s,1.1);const p=br(l,d,c);c.graph=!i.omitGraph,c.skipExpansion=!0,c.link={},c.framing=!0;let h=await e.compact(p,a,c);return c.link={},h=wr(h,c),h},e.link=async function(t,n,o){const r={};return n&&(r["@context"]=n),r["@embed"]="@link",e.frame(t,r,o)},e.normalize=e.canonize=async function(t,r){if(arguments.length<1)throw new TypeError("Could not canonize, too few arguments.");if("inputFormat"in(r=o(r,{base:Sr(t)?t:null,algorithm:"URDNA2015",skipExpansion:!1,safe:!0,contextResolver:new ur({sharedCache:n})}))){if("application/n-quads"!==r.inputFormat&&"application/nquads"!==r.inputFormat)throw new hr("Unknown canonicalization input format.","jsonld.CanonizeError");const e=vr.parse(t);return lr.canonize(e,r)}const i={...r};delete i.format,i.produceGeneralizedRdf=!1;const a=await e.toRDF(t,i);return lr.canonize(a,r)},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:Sr(e)?"application/n-quads":void 0});const{format:r}=n;let{rdfParser:i}=n;if(r){if(i=i||t[r],!i)throw new hr("Unknown input format.","jsonld.UnknownFormat",{format:r})}else i=()=>e;const a=await i(e);return mr(a,n)},e.toRDF=async function(t,r){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");let i;i=(r=o(r,{base:Sr(t)?t:"",skipExpansion:!1,contextResolver:new ur({sharedCache:n})})).skipExpansion?t:await e.expand(t,r);const a=xr(i,r);if(r.format){if("application/n-quads"===r.format||"application/nquads"===r.format)return vr.serialize(a);throw new hr("Unknown output format.","jsonld.UnknownFormat",{format:r.format})}return a},e.createNodeMap=async function(t,r){if(arguments.length<1)throw new TypeError("Could not create node map, too few arguments.");r=o(r,{base:Sr(t)?t:"",contextResolver:new ur({sharedCache:n})});const i=await e.expand(t,r);return Rr(i,r)},e.merge=async function(t,r,i){if(arguments.length<1)throw new TypeError("Could not merge, too few arguments.");if(!Ir(t))throw new TypeError('Could not merge, "docs" must be an array.');r="function"==typeof r?null:r||null,i=o(i,{contextResolver:new ur({sharedCache:n})});const a=await Promise.all(t.map((t=>{const n={...i};return e.expand(t,n)})));let s=!0;"mergeNodes"in i&&(s=i.mergeNodes);const l=i.issuer||new pr("_:b"),c={"@default":{}};for(let e=0;e<a.length;++e){const t=dr.relabelBlankNodes(a[e],{issuer:new pr("_:b"+e+"-")}),n=s||0===e?c:{"@default":{}};if(Tr(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=Ar(c),u=[],p=Object.keys(d).sort();for(let e=0;e<p.length;++e){const t=d[p[e]];kr(t)||u.push(t)}if(null===r)return u;i.graph=!0,i.skipExpansion=!0;return await e.compact(u,r,i)},Object.defineProperty(e,"documentLoader",{get:()=>e._documentLoader,set:t=>e._documentLoader=t}),e.documentLoader=async e=>{throw new hr("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 r=await o(t);try{if(!r.document)throw new hr("No remote document found at the given URL.","jsonld.NullRemoteDocument");Sr(r.document)&&(r.document=JSON.parse(r.document))}catch(e){throw new hr("Could not retrieve a JSON-LD document from the URL.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:r})}return r},e.processContext=async function(e,t,r){return r=o(r,{base:"",contextResolver:new ur({sharedCache:n})}),null===t?Or(r):(t=dr.clone(t),jr(t)&&"@context"in t||(t={"@context":t}),Er({activeCtx:e,localCtx:t,options:r}))},e.getContextValue=Pt.getContextValue,e.documentLoaders={},e.useDocumentLoader=function(t){if(!(t in e.documentLoaders))throw new hr('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",vr.parse),e.registerRDFParser("application/nquads",vr.parse),e.url=me(),e.logEventHandler=_r,e.logWarningEventHandler=Pr,e.safeEventHandler=Mr,e.setDefaultEventHandler=Jr,e.strictEventHandler=Br,e.unhandledEventHandler=Fr,e.util=dr,Object.assign(e,dr),e.promises=e,e.RequestQueue=ye(),e.JsonLdProcessor=(ir||(ir=1,rr=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}),rr)(e),cr.setupGlobals(e),cr.setupDocumentLoaders(e),e},qr=function(){return Ur((function(){return qr()}))};Ur(qr);var Vr,$r=i(qr),Gr={exports:{}},zr={exports:{}};function Kr(){return Vr||(Vr=1,e=zr,function(t){var n={bytesToHex:function(e){return function(e){return e.map((function(e){return t=e.toString(16),n=2,t.length>n?t:Array(n-t.length+1).join("0")+t;var t,n})).join("")}(e)},hexToBytes:function(e){if(e.length%2==1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return 0===e.indexOf("0x")&&(e=e.slice(2)),e.match(/../g).map((function(e){return parseInt(e,16)}))}};e.exports?e.exports=n:t.convertHex=n}(l)),zr.exports;var e}var Qr,Wr,Xr={exports:{}};Wr=Gr,function(e){var t={};Wr.exports?(t.bytesToHex=Kr().bytesToHex,t.convertString=function(){return Qr||(Qr=1,e=Xr,function(t){var n={bytesToString:function(e){return e.map((function(e){return String.fromCharCode(e)})).join("")},stringToBytes:function(e){return e.split("").map((function(e){return e.charCodeAt(0)}))}};n.UTF8={bytesToString:function(e){return decodeURIComponent(escape(n.bytesToString(e)))},stringToBytes:function(e){return n.stringToBytes(unescape(encodeURIComponent(e)))}},e.exports?e.exports=n:t.convertString=n}(l)),Xr.exports;var e}(),Wr.exports=s):(t.bytesToHex=e.convertHex.bytesToHex,t.convertString=e.convertString,e.sha256=s);var n=[];!function(){function e(e){for(var t=Math.sqrt(e),n=2;n<=t;n++)if(!(e%n))return!1;return!0}function t(e){return 4294967296*(e-(0|e))|0}for(var o=2,r=0;r<64;)e(o)&&(n[r]=t(Math.pow(o,1/3)),r++),o++}();var o=function(e){for(var t=[],n=0,o=0;n<e.length;n++,o+=8)t[o>>>5]|=e[n]<<24-o%32;return t},r=function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},i=[],a=function(e,t,o){for(var r=e[0],a=e[1],s=e[2],l=e[3],c=e[4],d=e[5],u=e[6],p=e[7],h=0;h<64;h++){if(h<16)i[h]=0|t[o+h];else{var f=i[h-15],v=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=i[h-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;i[h]=v+i[h-7]+y+i[h-16]}var m=r&a^r&s^a&s,x=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=p+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&d^~c&u)+n[h]+i[h];p=u,u=d,d=c,c=l+b|0,l=s,s=a,a=r,r=b+(x+m)|0}e[0]=e[0]+r|0,e[1]=e[1]+a|0,e[2]=e[2]+s|0,e[3]=e[3]+l|0,e[4]=e[4]+c|0,e[5]=e[5]+d|0,e[6]=e[6]+u|0,e[7]=e[7]+p|0};function s(e,n){e.constructor===String&&(e=t.convertString.UTF8.stringToBytes(e));var i=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],s=o(e),l=8*e.length;s[l>>5]|=128<<24-l%32,s[15+(l+64>>9<<4)]=l;for(var c=0;c<s.length;c+=16)a(i,s,c);var d=r(i);return n&&n.asBytes?d:n&&n.asString?t.convertString.bytesToString(d):t.bytesToHex(d)}s.x2=function(e,t){return s(s(e,{asBytes:!0}),t)}}(l);var Zr=i(Gr.exports);function Yr(e){e=e.trim();const t=[];for(let n=0;n<e.length;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}const ei="__IMAGE__SIGNATURE__";function ti(e){if(!Array.isArray(e["@context"])||Array.isArray(e["@context"])&&null==e["@context"][0]["image:signature"])return e;const t=JSON.parse(JSON.stringify(e));return t["@context"][0][ei]=e["@context"][0]["image:signature"],delete t["@context"][0]["image:signature"],t}async function ni(e){Array.isArray(e["@context"])&&!e["@context"].find((e=>r(e)&&"@vocab"in e))&&e["@context"].push({"@vocab":"http://fallback.org/"});const t=(i=e,null!=i.document?.assertion?.["image:signature"]&&(i.document.assertion[ei]=i.document.assertion["image:signature"],delete i.document.assertion["image:signature"]),i);var i;const a={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in s?{contextUrl:null,document:ti(s[e]),documentUrl:e}:$r.documentLoader(e)},safe:!1};let l;try{l=await $r.normalize(t.document,a)}catch(e){throw console.error(e),new n("computeLocalHash",o("errors","failedJsonLdNormalization"))}const c=function(e){const t=e.split("\n"),n=/<http:\/\/fallback\.org\/(.*)>/,o=t.map((e=>n.exec(e))).filter((e=>null!=e));if(o.length>0){const e=o.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(l);if(c)throw new n("computeLocalHash",`${o("errors","foundUnmappedFields")}: ${c.join(", ")}`);return Zr(function(e){const t=[];for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t.push(o):o<2048?t.push(192|o>>6,128|63&o):o<55296||o>=57344?t.push(224|o>>12,128|o>>6&63,128|63&o):(n++,o=65536+((1023&o)<<10|1023&e.charCodeAt(n)),t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o))}return t}(l))}function oi(e,t,r){let i="";const s=function(e,t){let n=null;for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&o.toLowerCase()===t.toLowerCase()&&(n=o);return e[n]}(e,t),l=a(r);if(s?(s.created&&l<=s.created&&(i="invalidIssuingAddressCreationTime"),s.revoked&&l>=s.revoked&&(i="invalidIssuingAddressRevoked"),s.expires&&l>=s.expires&&(i="invalidIssuingAddressExpired")):i="invalidIssuingAddressUnknown",i)throw new n("checkAuthenticity",o("errors",i))}class ri{constructor(e){}}var ii;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(ii||(ii={}));class ai extends ri{verificationProcess=[ii.getTransactionId,ii.computeLocalHash,ii.fetchRemoteHash,ii.compareHashes,ii.checkMerkleRoot,ii.checkReceipt,ii.parseIssuerKeys,ii.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature??this.documentToVerify.receipt,this.chain=e.certificates.getChain("",this.receipt),this.transactionId=e.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((n=>e.verifier.convertToVerificationSubsteps(t,n)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return e.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.txData.time.toString()}getProofType(){return Array.isArray(this.proof.type)?this.proof.type[0]:this.proof.type}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){const e=[this.type,"ChainpointSHA256v2"],t=this.getProofType();if(!e.includes(t))throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(t(this.verificationProcess,ii.getTransactionId),t(this.verificationProcess,ii.fetchRemoteHash),t(this.verificationProcess,ii.parseIssuerKeys),t(this.verificationProcess,ii.checkMerkleRoot),t(this.verificationProcess,ii.checkAuthenticity))}async executeStep(e,t,n){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(ii.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new n("getTransactionId",o("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(ii.computeLocalHash,(async()=>await ni(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(ii.fetchRemoteHash,(async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(ii.compareHashes,(()=>function(e,t){if(e!==t)throw new n("compareHashes",o("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(ii.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new n("checkMerkleRoot",o("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(ii.checkReceipt,(()=>{!function(e){let t=e.targetHash;const r=e.merkleRoot;try{const o=e.proof??e.path;if(o)for(const e in o){const r=o[e];let i;if(void 0!==r.left)i=Yr(`${r.left}${t}`),t=Zr(i);else{if(void 0===r.right)throw new n("checkReceipt","Trigger catch error.");i=Yr(`${t}${r.right}`),t=Zr(i)}}}catch(e){throw new n("checkReceipt",o("errors","ensureValidReceipt"))}if(t!==r)throw new n("checkReceipt",o("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(ii.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(ii.checkAuthenticity,(()=>{oi(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{ai as default};