@hyperjump/json-schema-core
Advanced tools
Comparing version 0.23.2 to 0.23.3
@@ -645,4 +645,67 @@ define(['exports'], (function (exports) { 'use strict'; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1 }; | ||
const CHAR_BACKWARD_SLASH = 47; | ||
const pathRelative$1 = (from, to) => { | ||
if (from === to) { | ||
return ""; | ||
} | ||
let toStart = 1; | ||
const fromLen = from.length - 1; | ||
const toLen = to.length - toStart; | ||
// Compare paths to find the longest common path from root | ||
const length = fromLen < toLen ? fromLen : toLen; | ||
let lastCommonSep = -1; | ||
let i = 0; | ||
for (; i < length; i++) { | ||
const fromCode = from.charCodeAt(i + 1); | ||
if (fromCode !== to.charCodeAt(toStart + i)) { | ||
break; | ||
} else if (fromCode === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} | ||
} | ||
if (toLen > length) { | ||
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) { | ||
return to.slice(toStart + i + 1); | ||
} | ||
if (i === 0) { | ||
return to.slice(toStart + i); | ||
} | ||
} | ||
if (fromLen > length) { | ||
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} else if (length === 0) { | ||
lastCommonSep = 0; | ||
} | ||
} | ||
let out = ""; | ||
// Generate the relative path based on the path difference between `to` and `from` | ||
for (i = lastCommonSep + 2; i <= from.length; ++i) { | ||
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) { | ||
out += out.length === 0 ? ".." : "/.."; | ||
} | ||
} | ||
toStart += lastCommonSep; | ||
// Lastly, append the rest of the destination (`to`) path that comes after | ||
// the common path parts | ||
if (out.length > 0) { | ||
return `${out}${to.slice(toStart, to.length)}`; | ||
} | ||
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) { | ||
++toStart; | ||
} | ||
return to.slice(toStart, to.length); | ||
}; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 }; | ||
const nil$2 = ""; | ||
@@ -1152,3 +1215,3 @@ | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl } = common; | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl, pathRelative } = common; | ||
@@ -1383,6 +1446,69 @@ | ||
const toSchemaDefaultOptions = { | ||
parentId: "", | ||
parentDialect: "", | ||
includeEmbedded: true | ||
}; | ||
const toSchema = (schemaDoc, options = {}) => { | ||
const fullOptions = { ...toSchemaDefaultOptions, ...options }; | ||
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => { | ||
if (!reference.isReference(value)) { | ||
return value; | ||
} | ||
const refValue = reference.value(value); | ||
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion; | ||
const embeddedToken = getConfig(embeddedDialect, "embeddedToken"); | ||
if (!fullOptions.includeEmbedded && embeddedToken in refValue) { | ||
return; | ||
} else { | ||
return reference.value(value); | ||
} | ||
})); | ||
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken"); | ||
Object.entries(schemaDoc.dynamicAnchors) | ||
.forEach(([anchor, uri]) => { | ||
const pointer = splitUrl$1(uri)[1]; | ||
lib$2.assign(pointer, schema, { | ||
[dynamicAnchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken"); | ||
Object.entries(schemaDoc.anchors) | ||
.filter(([anchor]) => anchor !== "") | ||
.forEach(([anchor, pointer]) => { | ||
lib$2.assign(pointer, schema, { | ||
[anchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken"); | ||
const id = relativeUri(fullOptions.parentId, schemaDoc.id); | ||
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion; | ||
return { | ||
...(id && { [baseToken]: id }), | ||
...(dialect && { $schema: dialect }), | ||
...schema | ||
}; | ||
}; | ||
const relativeUri = (from, to) => { | ||
if (to.startsWith("file://")) { | ||
const pathToSchema = from.slice(7, from.lastIndexOf("/")); | ||
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7)); | ||
} else { | ||
return to; | ||
} | ||
}; | ||
var schema = { | ||
setConfig, getConfig, | ||
add: add$1, get, markValidated, | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length, | ||
toSchema | ||
}; | ||
@@ -1404,2 +1530,3 @@ schema.setConfig; | ||
schema.length; | ||
schema.toSchema; | ||
@@ -1406,0 +1533,0 @@ class InvalidSchemaError extends Error { |
@@ -1,2 +0,2 @@ | ||
define(["exports"],(function(e){"use strict";var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(c.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var p={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),P=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[P]:e,[S]:t}),isReference:e=>e&&void 0!==e[P],href:e=>e[P],value:e=>e[S]};const{jsonTypeOf:A}=p,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>x.isReference(e.value)?x.value(e.value):e.value,k=t(((e,t)=>A(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),U=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:U,reduce:C,every:z,some:K,length:e=>T(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function Z(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function M(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!F.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Z(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!F.test(n))throw new TypeError("invalid media type");var o=new M(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},J=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:J,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([J,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae}=p,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");ne(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,fe(e,n,r),x.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=ae(me(t),e),[n,o]=oe(r);if(!(e=>e in le||e in ue)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>x.isReference(e.value)?ye(x.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>x.isReference(e.value)?x.value(e.value):e.value,ge=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:we(t)[e],validated:r.validated});return ve(n)},Oe=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await ge(n,t),n))),te.all],t)));var Ee={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:me,value:we,getAnchorPointer:be,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:ge,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await ge(t,e)])),te.all],e),map:Oe,length:e=>we(e).length};Ee.setConfig,Ee.getConfig,Ee.add,Ee.get,Ee.markValidated,Ee.uri,Ee.value,Ee.getAnchorPointer,Ee.typeOf,Ee.has,Ee.step,Ee.keys,Ee.entries,Ee.map,Ee.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=je;const{splitUrl:Se}=p,Pe="FLAG",xe="BASIC",Ae="DETAILED",Ie="VERBOSE";let Te=Ae,ke=!0;const Ve=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Re=t((({ast:e,schemaUri:t},r,n=Pe)=>{if(![Pe,xe,Ae,Ie].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ue(n,a));return Ne(t,r,e,{}),o.unsubscribe(i),a[0]})),Ue=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Ie||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},ze=e=>Ce[e],Ke=e=>e in Ce,Le={},qe={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Ee.get(e.schemaVersion);(Ee.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(ke&&!e.validated){if(Ee.markValidated(e.id),!(e.schemaVersion in qe)){const t=await Ee.get(e.schemaVersion),r=await Ve(t);qe[t.id]=Re(r)}const t=L.cons(e.schema,e.id),r=qe[e.schemaVersion](t,Te);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),ze(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Ee.typeOf(e,"string")?De(await Ee.get(Ee.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=Se(e)[0];return ze(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Fe={validate:async(e,t,r)=>{const n=await Ve(e),o=(e,t)=>Re(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ve,interpret:Re,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:xe,DETAILED:Ae,VERBOSE:Ie,add:(e,t="",r="")=>{const n=Ee.add(e,t,r);delete qe[n]},getKeyword:ze,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>Ee.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=Ee.uri(e);if(!(r in t)){t[r]=!1;const n=Ee.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Ee.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Ee.uri(e),"boolean"==typeof n?n:await te.pipeline([Ee.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Fe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ee.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Fe.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Fe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Fe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},We={metaData:Ze,validate:Me},Je={Core:Fe,Schema:Ee,Instance:L,Reference:x,Keywords:We,InvalidSchemaError:$e},Ge=Je.Core,He=Je.Schema,Qe=Je.Instance,Xe=Je.Reference,Ye=Je.Keywords,et=Je.InvalidSchemaError;e.Core=Ge,e.Instance=Qe,e.InvalidSchemaError=et,e.Keywords=Ye,e.Reference=Xe,e.Schema=He,e.default=Je,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
define(["exports"],(function(e){"use strict";var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function d(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(c.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var d={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},pathRelative:(e,t)=>{if(e===t)return"";let r=1;const n=e.length-1,o=t.length-r,a=n<o?n:o;let i=-1,s=0;for(;s<a;s++){const n=e.charCodeAt(s+1);if(n!==t.charCodeAt(r+s))break;47===n&&(i=s)}if(o>a){if(47===t.charCodeAt(r+s))return t.slice(r+s+1);if(0===s)return t.slice(r+s)}n>a&&(47===e.charCodeAt(s+1)?i=s:0===a&&(i=0));let c="";for(s=i+2;s<=e.length;++s)s!==e.length&&47!==e.charCodeAt(s)||(c+=0===c.length?"..":"/..");return r+=i,c.length>0?`${c}${t.slice(r,t.length)}`:(47===t.charCodeAt(r)&&++r,t.slice(r,t.length))}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,v(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,v(o,n))}else{t[O(t,e[0])]=r}},m=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:m(e,o,v(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,v(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},v=t(((e,t)=>t+"/"+g(e))),g=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:v,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),v(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>m(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),A=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[A]:e,[S]:t}),isReference:e=>e&&void 0!==e[A],href:e=>e[A],value:e=>e[S]};const{jsonTypeOf:P}=d,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>x.isReference(e.value)?x.value(e.value):e.value,k=t(((e,t)=>P(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function J(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var Z={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!F.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+J(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!F.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:M,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([M,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae,pathRelative:ie}=d,se={},ce={},le=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},ue={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(fe[i]=c);const u={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ne(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):(ce[c]=n,d={[n]:!0});const h={"":""};return ue[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:d,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,de(e,n,r),x.cons(e[s],e)}const l=le(r,"anchorToken"),u=le(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=le(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const d=le(r,"jrefToken");if("string"==typeof e[d])return x.cons(e[d],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},he=e=>ue[fe[e]]||ue[e],ye=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=ye)=>{const r=ae(ge(t),e),[n,o]=oe(r);if(!(e=>e in ue||e in fe)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=Z.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),n)}const a=he(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return be(s)},be=e=>x.isReference(e.value)?me(x.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>x.isReference(e.value)?x.value(e.value):e.value,Oe=(e,t)=>{const r=he(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:we(t)[e],validated:r.validated});return be(n)},Ee=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await Oe(n,t),n))),te.all],t))),je={parentId:"",parentDialect:"",includeEmbedded:!0},$e=(e,t)=>{if(t.startsWith("file://")){const r=e.slice(7,e.lastIndexOf("/"));return""===e?"":ie(r,t.slice(7))}return t};var Se={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:le,add:de,get:me,markValidated:e=>{ue[e].validated=!0},uri:ge,value:we,getAnchorPointer:ve,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:Oe,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await Oe(t,e)])),te.all],e),map:Ee,length:e=>we(e).length,toSchema:(e,t={})=>{const r={...je,...t},n=JSON.parse(JSON.stringify(e.schema,((t,n)=>{if(!x.isReference(n))return n;const o=x.value(n),a=o.$schema||e.schemaVersion,i=le(a,"embeddedToken");return!r.includeEmbedded&&i in o?void 0:x.value(n)}))),o=le(e.schemaVersion,"dynamicAnchorToken");Object.entries(e.dynamicAnchors).forEach((([e,t])=>{const r=oe(t)[1];$.assign(r,n,{[o]:e,...$.get(r,n)})}));const a=le(e.schemaVersion,"anchorToken");Object.entries(e.anchors).filter((([e])=>""!==e)).forEach((([e,t])=>{$.assign(t,n,{[a]:e,...$.get(t,n)})}));const i=le(e.schemaVersion,"baseToken"),s=$e(r.parentId,e.id),c=r.parentDialect===e.schemaVersion?"":e.schemaVersion;return{...s&&{[i]:s},...c&&{$schema:c},...n}}};Se.setConfig,Se.getConfig,Se.add,Se.get,Se.markValidated,Se.uri,Se.value,Se.getAnchorPointer,Se.typeOf,Se.has,Se.step,Se.keys,Se.entries,Se.map,Se.length,Se.toSchema;class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Ae;const{splitUrl:Pe}=d,Ie="FLAG",Te="BASIC",ke="DETAILED",Ve="VERBOSE";let Re=ke,Ce=!0;const Ue=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},ze=t((({ast:e,schemaUri:t},r,n=Ie)=>{if(![Ie,Te,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ke(n,a));return Je(t,r,e,{}),o.unsubscribe(i),a[0]})),Ke=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Ie&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Le={},qe=e=>Le[e],_e=e=>e in Le,De={},Ne={},Be=async(e,t)=>{if(e=await Fe(e),!_e(`${e.schemaVersion}#validate`)){const t=await Se.get(e.schemaVersion);(Se.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Le[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ce&&!e.validated){if(Se.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await Se.get(e.schemaVersion),r=await Ue(t);Ne[t.id]=ze(r)}const t=L.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Re);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),qe(`${e.schemaVersion}#validate`).compile(e,t)},Fe=async e=>Se.typeOf(e,"string")?Fe(await Se.get(Se.value(e),e)):e,Je=(e,t,r,n)=>{const o=We(e,r),a=Pe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},We=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await Ue(e),o=(e,t)=>ze(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ue,interpret:ze,setMetaOutputFormat:e=>{Re=e},setShouldMetaValidate:e=>{Ce=e},FLAG:Ie,BASIC:Te,DETAILED:ke,VERBOSE:Ve,add:(e,t="",r="")=>{const n=Se.add(e,t,r);delete Ne[n]},getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Be,interpretSchema:Je,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=We(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=We(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>Se.value(e),interpret:()=>!0};var Ge={compile:async(e,t)=>{const r=Se.uri(e);if(!(r in t)){t[r]=!1;const n=Se.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Se.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Se.uri(e),"boolean"==typeof n?n:await te.pipeline([Se.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Ze.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,Se.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},He={metaData:Me,validate:Ge},Qe={Core:Ze,Schema:Se,Instance:L,Reference:x,Keywords:He,InvalidSchemaError:xe},Xe=Qe.Core,Ye=Qe.Schema,et=Qe.Instance,tt=Qe.Reference,rt=Qe.Keywords,nt=Qe.InvalidSchemaError;e.Core=Xe,e.Instance=et,e.InvalidSchemaError=nt,e.Keywords=rt,e.Reference=tt,e.Schema=Ye,e.default=Qe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -647,4 +647,67 @@ 'use strict'; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1 }; | ||
const CHAR_BACKWARD_SLASH = 47; | ||
const pathRelative$1 = (from, to) => { | ||
if (from === to) { | ||
return ""; | ||
} | ||
let toStart = 1; | ||
const fromLen = from.length - 1; | ||
const toLen = to.length - toStart; | ||
// Compare paths to find the longest common path from root | ||
const length = fromLen < toLen ? fromLen : toLen; | ||
let lastCommonSep = -1; | ||
let i = 0; | ||
for (; i < length; i++) { | ||
const fromCode = from.charCodeAt(i + 1); | ||
if (fromCode !== to.charCodeAt(toStart + i)) { | ||
break; | ||
} else if (fromCode === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} | ||
} | ||
if (toLen > length) { | ||
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) { | ||
return to.slice(toStart + i + 1); | ||
} | ||
if (i === 0) { | ||
return to.slice(toStart + i); | ||
} | ||
} | ||
if (fromLen > length) { | ||
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} else if (length === 0) { | ||
lastCommonSep = 0; | ||
} | ||
} | ||
let out = ""; | ||
// Generate the relative path based on the path difference between `to` and `from` | ||
for (i = lastCommonSep + 2; i <= from.length; ++i) { | ||
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) { | ||
out += out.length === 0 ? ".." : "/.."; | ||
} | ||
} | ||
toStart += lastCommonSep; | ||
// Lastly, append the rest of the destination (`to`) path that comes after | ||
// the common path parts | ||
if (out.length > 0) { | ||
return `${out}${to.slice(toStart, to.length)}`; | ||
} | ||
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) { | ||
++toStart; | ||
} | ||
return to.slice(toStart, to.length); | ||
}; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 }; | ||
const nil$2 = ""; | ||
@@ -1154,3 +1217,3 @@ | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl } = common; | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl, pathRelative } = common; | ||
@@ -1385,6 +1448,69 @@ | ||
const toSchemaDefaultOptions = { | ||
parentId: "", | ||
parentDialect: "", | ||
includeEmbedded: true | ||
}; | ||
const toSchema = (schemaDoc, options = {}) => { | ||
const fullOptions = { ...toSchemaDefaultOptions, ...options }; | ||
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => { | ||
if (!reference.isReference(value)) { | ||
return value; | ||
} | ||
const refValue = reference.value(value); | ||
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion; | ||
const embeddedToken = getConfig(embeddedDialect, "embeddedToken"); | ||
if (!fullOptions.includeEmbedded && embeddedToken in refValue) { | ||
return; | ||
} else { | ||
return reference.value(value); | ||
} | ||
})); | ||
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken"); | ||
Object.entries(schemaDoc.dynamicAnchors) | ||
.forEach(([anchor, uri]) => { | ||
const pointer = splitUrl$1(uri)[1]; | ||
lib$2.assign(pointer, schema, { | ||
[dynamicAnchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken"); | ||
Object.entries(schemaDoc.anchors) | ||
.filter(([anchor]) => anchor !== "") | ||
.forEach(([anchor, pointer]) => { | ||
lib$2.assign(pointer, schema, { | ||
[anchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken"); | ||
const id = relativeUri(fullOptions.parentId, schemaDoc.id); | ||
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion; | ||
return { | ||
...(id && { [baseToken]: id }), | ||
...(dialect && { $schema: dialect }), | ||
...schema | ||
}; | ||
}; | ||
const relativeUri = (from, to) => { | ||
if (to.startsWith("file://")) { | ||
const pathToSchema = from.slice(7, from.lastIndexOf("/")); | ||
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7)); | ||
} else { | ||
return to; | ||
} | ||
}; | ||
var schema = { | ||
setConfig, getConfig, | ||
add: add$1, get, markValidated, | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length, | ||
toSchema | ||
}; | ||
@@ -1406,2 +1532,3 @@ schema.setConfig; | ||
schema.length; | ||
schema.toSchema; | ||
@@ -1408,0 +1535,0 @@ class InvalidSchemaError extends Error { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports);n.PubSub;var o=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(s.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=p(t),a=e(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=p(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:P}=f,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>x.isReference(e.value)?x.value(e.value):e.value,T=e(((e,t)=>P(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:I(t)[e]}),V=e(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=e(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=e(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),C=e(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=e(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:A,cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:T,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:V,filter:R,reduce:U,every:C,some:z,length:e=>I(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function Z(e){this.parameters=Object.create(null),this.type=e}var M={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new Z(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},W=async e=>Object.entries(await e),J=e((async(e,t)=>(await t).map(e))),G=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=e((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=e((async(e,t)=>{const r=await J(e,t);return(await Promise.all(r)).some((e=>e))})),X=e((async(e,t)=>{const r=await J(e,t);return(await Promise.all(r)).every((e=>e))})),Y=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:W,map:J,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([W,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const h={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),x.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,j.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),he=async(e,t=de)=>{const r=oe(be(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>x.isReference(e.value)?he(x.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},be=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>x.isReference(e.value)?x.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},ge=e(((e,t)=>ee.pipeline([me,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:he,markValidated:e=>{ce[e].validated=!0},uri:be,value:me,getAnchorPointer:ve,typeOf:(e,t)=>re(me(e),t),has:(e,t)=>e in me(t),step:we,keys:e=>Object.keys(me(e)),entries:e=>ee.pipeline([me,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:ge,length:e=>me(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class Ee extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Ee;const{splitUrl:$e}=f,Se="FLAG",xe="BASIC",Pe="DETAILED",Ae="VERBOSE";let Ie=Pe,Te=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await qe(e,t)}},Ve=e((({ast:e,schemaUri:t},r,o=Se)=>{if(![Se,xe,Pe,Ae].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",Re(o,a));return De(t,r,e,{}),n.unsubscribe(i),a[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Ae||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},Ce=e=>Ue[e],ze=e=>e in Ue,Ke={},Le={},qe=async(e,t)=>{if(e=await _e(e),!ze(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Te&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in Le)){const t=await Oe.get(e.schemaVersion),r=await ke(t);Le[t.id]=Ve(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Ie);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ce(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>Oe.typeOf(e,"string")?_e(await Oe.get(Oe.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=$e(e)[0];return Ce(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Ve(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Ve,setMetaOutputFormat:e=>{Ie=e},setShouldMetaValidate:e=>{Te=e},FLAG:Se,BASIC:xe,DETAILED:Pe,VERBOSE:Ae,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete Le[n]},getKeyword:Ce,hasKeyword:ze,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:qe,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Be.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={metaData:Fe,validate:Ze},We={Core:Be,Schema:Oe,Instance:K,Reference:x,Keywords:Me,InvalidSchemaError:je},Je=We.Core,Ge=We.Schema,He=We.Instance,Qe=We.Reference,Xe=We.Keywords,Ye=We.InvalidSchemaError;exports.Core=Je,exports.Instance=He,exports.InvalidSchemaError=Ye,exports.Keywords=Xe,exports.Reference=Qe,exports.Schema=Ge,exports.default=We; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports);n.PubSub;var o=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(s.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},pathRelative:(e,t)=>{if(e===t)return"";let r=1;const n=e.length-1,o=t.length-r,a=n<o?n:o;let i=-1,s=0;for(;s<a;s++){const n=e.charCodeAt(s+1);if(n!==t.charCodeAt(r+s))break;47===n&&(i=s)}if(o>a){if(47===t.charCodeAt(r+s))return t.slice(r+s+1);if(0===s)return t.slice(r+s)}n>a&&(47===e.charCodeAt(s+1)?i=s:0===a&&(i=0));let c="";for(s=i+2;s<=e.length;++s)s!==e.length&&47!==e.charCodeAt(s)||(c+=0===c.length?"..":"/..");return r+=i,c.length>0?`${c}${t.slice(r,t.length)}`:(47===t.charCodeAt(r)&&++r,t.slice(r,t.length))}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[w(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[w(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return O(t,e[0],r)}},m=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);m(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+v(e))),v=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),w=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[w(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=p(t),a=e(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=p(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>m(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:A}=f,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>x.isReference(e.value)?x.value(e.value):e.value,T=e(((e,t)=>A(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:I(t)[e]}),V=e(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=e(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=e(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),U=e(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=e(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:P,cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:T,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:V,filter:R,reduce:C,every:U,some:z,length:e=>I(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new J(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Z=async e=>Object.entries(await e),M=e((async(e,t)=>(await t).map(e))),G=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=e((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),X=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).every((e=>e))})),Y=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:Z,map:M,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([Z,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe,pathRelative:ae}=f,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");re(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,fe(e,n,r),x.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,j.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=oe(ve(t),e),[n,o]=ne(r);if(!(e=>e in le||e in ue)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return me(s)},me=e=>x.isReference(e.value)?ye(x.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ve=e=>`${e.id}#${encodeURI(e.pointer)}`,ge=e=>x.isReference(e.value)?x.value(e.value):e.value,we=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:ge(t)[e],validated:r.validated});return me(n)},Oe=e(((e,t)=>ee.pipeline([ge,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t))),Ee={parentId:"",parentDialect:"",includeEmbedded:!0},je=(e,t)=>{if(t.startsWith("file://")){const r=e.slice(7,e.lastIndexOf("/"));return""===e?"":ae(r,t.slice(7))}return t};var $e={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:ve,value:ge,getAnchorPointer:be,typeOf:(e,t)=>re(ge(e),t),has:(e,t)=>e in ge(t),step:we,keys:e=>Object.keys(ge(e)),entries:e=>ee.pipeline([ge,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:Oe,length:e=>ge(e).length,toSchema:(e,t={})=>{const r={...Ee,...t},n=JSON.parse(JSON.stringify(e.schema,((t,n)=>{if(!x.isReference(n))return n;const o=x.value(n),a=o.$schema||e.schemaVersion,i=ce(a,"embeddedToken");return!r.includeEmbedded&&i in o?void 0:x.value(n)}))),o=ce(e.schemaVersion,"dynamicAnchorToken");Object.entries(e.dynamicAnchors).forEach((([e,t])=>{const r=ne(t)[1];j.assign(r,n,{[o]:e,...j.get(r,n)})}));const a=ce(e.schemaVersion,"anchorToken");Object.entries(e.anchors).filter((([e])=>""!==e)).forEach((([e,t])=>{j.assign(t,n,{[a]:e,...j.get(t,n)})}));const i=ce(e.schemaVersion,"baseToken"),s=je(r.parentId,e.id),c=r.parentDialect===e.schemaVersion?"":e.schemaVersion;return{...s&&{[i]:s},...c&&{$schema:c},...n}}};$e.setConfig,$e.getConfig,$e.add,$e.get,$e.markValidated,$e.uri,$e.value,$e.getAnchorPointer,$e.typeOf,$e.has,$e.step,$e.keys,$e.entries,$e.map,$e.length,$e.toSchema;class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Se;const{splitUrl:Ae}=f,Pe="FLAG",Ie="BASIC",Te="DETAILED",ke="VERBOSE";let Ve=Te,Re=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ue=e((({ast:e,schemaUri:t},r,o=Pe)=>{if(![Pe,Ie,Te,ke].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",ze(o,a));return Fe(t,r,e,{}),n.unsubscribe(i),a[0]})),ze=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ke={},Le=e=>Ke[e],qe=e=>e in Ke,_e={},De={},Ne=async(e,t)=>{if(e=await Be(e),!qe(`${e.schemaVersion}#validate`)){const t=await $e.get(e.schemaVersion);($e.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Ke[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Re&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in De)){const t=await $e.get(e.schemaVersion),r=await Ce(t);De[t.id]=Ue(r)}const t=K.cons(e.schema,e.id),r=De[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Le(`${e.schemaVersion}#validate`).compile(e,t)},Be=async e=>$e.typeOf(e,"string")?Be(await $e.get($e.value(e),e)):e,Fe=(e,t,r,n)=>{const o=Je(e,r),a=Ae(e)[0];return Le(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Je=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var We={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t)=>Ue(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ue,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Re=e},FLAG:Pe,BASIC:Ie,DETAILED:Te,VERBOSE:ke,add:(e,t="",r="")=>{const n=$e.add(e,t,r);delete De[n]},getKeyword:Le,hasKeyword:qe,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Ne,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Je(e,r);return Le(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Je(e,r);return Le(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>$e.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${$e.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,$e.uri(e),"boolean"==typeof n?n:await ee.pipeline([$e.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>We.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=We.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&We.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&We.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={metaData:Ze,validate:Me},He={Core:We,Schema:$e,Instance:K,Reference:x,Keywords:Ge,InvalidSchemaError:xe},Qe=He.Core,Xe=He.Schema,Ye=He.Instance,et=He.Reference,tt=He.Keywords,rt=He.InvalidSchemaError;exports.Core=Qe,exports.Instance=Ye,exports.InvalidSchemaError=rt,exports.Keywords=tt,exports.Reference=et,exports.Schema=Xe,exports.default=He; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -643,4 +643,67 @@ var justCurryIt = curry; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1 }; | ||
const CHAR_BACKWARD_SLASH = 47; | ||
const pathRelative$1 = (from, to) => { | ||
if (from === to) { | ||
return ""; | ||
} | ||
let toStart = 1; | ||
const fromLen = from.length - 1; | ||
const toLen = to.length - toStart; | ||
// Compare paths to find the longest common path from root | ||
const length = fromLen < toLen ? fromLen : toLen; | ||
let lastCommonSep = -1; | ||
let i = 0; | ||
for (; i < length; i++) { | ||
const fromCode = from.charCodeAt(i + 1); | ||
if (fromCode !== to.charCodeAt(toStart + i)) { | ||
break; | ||
} else if (fromCode === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} | ||
} | ||
if (toLen > length) { | ||
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) { | ||
return to.slice(toStart + i + 1); | ||
} | ||
if (i === 0) { | ||
return to.slice(toStart + i); | ||
} | ||
} | ||
if (fromLen > length) { | ||
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} else if (length === 0) { | ||
lastCommonSep = 0; | ||
} | ||
} | ||
let out = ""; | ||
// Generate the relative path based on the path difference between `to` and `from` | ||
for (i = lastCommonSep + 2; i <= from.length; ++i) { | ||
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) { | ||
out += out.length === 0 ? ".." : "/.."; | ||
} | ||
} | ||
toStart += lastCommonSep; | ||
// Lastly, append the rest of the destination (`to`) path that comes after | ||
// the common path parts | ||
if (out.length > 0) { | ||
return `${out}${to.slice(toStart, to.length)}`; | ||
} | ||
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) { | ||
++toStart; | ||
} | ||
return to.slice(toStart, to.length); | ||
}; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 }; | ||
const nil$2 = ""; | ||
@@ -1150,3 +1213,3 @@ | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl } = common; | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl, pathRelative } = common; | ||
@@ -1381,6 +1444,69 @@ | ||
const toSchemaDefaultOptions = { | ||
parentId: "", | ||
parentDialect: "", | ||
includeEmbedded: true | ||
}; | ||
const toSchema = (schemaDoc, options = {}) => { | ||
const fullOptions = { ...toSchemaDefaultOptions, ...options }; | ||
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => { | ||
if (!reference.isReference(value)) { | ||
return value; | ||
} | ||
const refValue = reference.value(value); | ||
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion; | ||
const embeddedToken = getConfig(embeddedDialect, "embeddedToken"); | ||
if (!fullOptions.includeEmbedded && embeddedToken in refValue) { | ||
return; | ||
} else { | ||
return reference.value(value); | ||
} | ||
})); | ||
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken"); | ||
Object.entries(schemaDoc.dynamicAnchors) | ||
.forEach(([anchor, uri]) => { | ||
const pointer = splitUrl$1(uri)[1]; | ||
lib$2.assign(pointer, schema, { | ||
[dynamicAnchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken"); | ||
Object.entries(schemaDoc.anchors) | ||
.filter(([anchor]) => anchor !== "") | ||
.forEach(([anchor, pointer]) => { | ||
lib$2.assign(pointer, schema, { | ||
[anchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken"); | ||
const id = relativeUri(fullOptions.parentId, schemaDoc.id); | ||
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion; | ||
return { | ||
...(id && { [baseToken]: id }), | ||
...(dialect && { $schema: dialect }), | ||
...schema | ||
}; | ||
}; | ||
const relativeUri = (from, to) => { | ||
if (to.startsWith("file://")) { | ||
const pathToSchema = from.slice(7, from.lastIndexOf("/")); | ||
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7)); | ||
} else { | ||
return to; | ||
} | ||
}; | ||
var schema = { | ||
setConfig, getConfig, | ||
add: add$1, get, markValidated, | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length, | ||
toSchema | ||
}; | ||
@@ -1402,2 +1528,3 @@ schema.setConfig; | ||
schema.length; | ||
schema.toSchema; | ||
@@ -1404,0 +1531,0 @@ class InvalidSchemaError extends Error { |
@@ -1,2 +0,2 @@ | ||
var e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports);n.PubSub;var o=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(s.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=p(t),a=e(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=p(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:A}=f,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),I=e=>x.isReference(e.value)?x.value(e.value):e.value,T=e(((e,t)=>A(I(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:I(t)[e]}),V=e(((e,t)=>I(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=e(((e,t)=>I(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=e(((e,t,r)=>I(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),C=e(((e,t)=>I(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=e(((e,t)=>I(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:P,cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:I,has:(e,t)=>e in I(t),typeOf:T,step:k,entries:e=>Object.keys(I(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(I(e)),map:V,filter:R,reduce:U,every:C,some:z,length:e=>I(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function Z(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new Z(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},J=async e=>Object.entries(await e),M=e((async(e,t)=>(await t).map(e))),G=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=e((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),X=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).every((e=>e))})),Y=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:J,map:M,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([J,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const h={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),x.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,j.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),he=async(e,t=de)=>{const r=oe(be(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>x.isReference(e.value)?he(x.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},be=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>x.isReference(e.value)?x.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},ge=e(((e,t)=>ee.pipeline([me,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:he,markValidated:e=>{ce[e].validated=!0},uri:be,value:me,getAnchorPointer:ve,typeOf:(e,t)=>re(me(e),t),has:(e,t)=>e in me(t),step:we,keys:e=>Object.keys(me(e)),entries:e=>ee.pipeline([me,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:ge,length:e=>me(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class Ee extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Ee;const{splitUrl:$e}=f,Se="FLAG",xe="BASIC",Ae="DETAILED",Pe="VERBOSE";let Ie=Ae,Te=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await qe(e,t)}},Ve=e((({ast:e,schemaUri:t},r,o=Se)=>{if(![Se,xe,Ae,Pe].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",Re(o,a));return De(t,r,e,{}),n.unsubscribe(i),a[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Pe||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},Ce=e=>Ue[e],ze=e=>e in Ue,Ke={},Le={},qe=async(e,t)=>{if(e=await _e(e),!ze(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Te&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in Le)){const t=await Oe.get(e.schemaVersion),r=await ke(t);Le[t.id]=Ve(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Ie);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ce(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>Oe.typeOf(e,"string")?_e(await Oe.get(Oe.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=$e(e)[0];return Ce(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Ve(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Ve,setMetaOutputFormat:e=>{Ie=e},setShouldMetaValidate:e=>{Te=e},FLAG:Se,BASIC:xe,DETAILED:Ae,VERBOSE:Pe,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete Le[n]},getKeyword:Ce,hasKeyword:ze,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:qe,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ce(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Be.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},We={metaData:Fe,validate:Ze},Je={Core:Be,Schema:Oe,Instance:K,Reference:x,Keywords:We,InvalidSchemaError:je},Me=Je.Core,Ge=Je.Schema,He=Je.Instance,Qe=Je.Reference,Xe=Je.Keywords,Ye=Je.InvalidSchemaError;export{Me as Core,He as Instance,Ye as InvalidSchemaError,Xe as Keywords,Qe as Reference,Ge as Schema,Je as default}; | ||
var e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function d(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports);n.PubSub;var o=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(s.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},pathRelative:(e,t)=>{if(e===t)return"";let r=1;const n=e.length-1,o=t.length-r,a=n<o?n:o;let i=-1,s=0;for(;s<a;s++){const n=e.charCodeAt(s+1);if(n!==t.charCodeAt(r+s))break;47===n&&(i=s)}if(o>a){if(47===t.charCodeAt(r+s))return t.slice(r+s+1);if(0===s)return t.slice(r+s)}n>a&&(47===e.charCodeAt(s+1)?i=s:0===a&&(i=0));let c="";for(s=i+2;s<=e.length;++s)s!==e.length&&47!==e.charCodeAt(s)||(c+=0===c.length?"..":"/..");return r+=i,c.length>0?`${c}${t.slice(r,t.length)}`:(47===t.charCodeAt(r)&&++r,t.slice(r,t.length))}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[w(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[w(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return O(t,e[0],r)}},m=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);m(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+v(e))),v=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),w=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[w(e,t)]},E=e=>null===e||"object"!=typeof e;var $={nil:"",append:b,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=d(t),a=e(((e,t)=>p(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=d(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>m(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const j=Symbol("$__value"),S=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[S]:e,[j]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[j]};const{jsonTypeOf:x}=f,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>A.isReference(e.value)?A.value(e.value):e.value,T=e(((e,t)=>x(P(e),t))),k=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:P(t)[e]}),V=e(((e,t)=>P(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=e(((e,t)=>P(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=e(((e,t,r)=>P(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),U=e(((e,t)=>P(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=e(((e,t)=>P(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,has:(e,t)=>e in P(t),typeOf:T,step:k,entries:e=>Object.keys(P(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(P(e)),map:V,filter:R,reduce:C,every:U,some:z,length:e=>P(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,_=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new J(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(_,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Z=async e=>Object.entries(await e),M=e((async(e,t)=>(await t).map(e))),G=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=e((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),X=e((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).every((e=>e))})),Y=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:Z,map:M,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([Z,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe,pathRelative:ae}=f,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let d;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const p=ce(n,"vocabularyToken");re(e[p],"object")?(se[c]=n,d=e[p],delete e[p]):(se[c]=n,d={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:de(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:d,validated:!1},c},de=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,fe(e,n,r),A.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const d=ce(r,"jrefToken");if("string"==typeof e[d])return A.cons(e[d],e);for(const i in e)e[i]=de(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>de(e,t,r,$.append(i,n),o,a))):e},pe=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=oe(ve(t),e),[n,o]=ne(r);if(!(e=>e in le||e in ue)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=pe(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return me(s)},me=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ve=e=>`${e.id}#${encodeURI(e.pointer)}`,ge=e=>A.isReference(e.value)?A.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:ge(t)[e],validated:r.validated});return me(n)},Oe=e(((e,t)=>ee.pipeline([ge,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t))),Ee={parentId:"",parentDialect:"",includeEmbedded:!0},$e=(e,t)=>{if(t.startsWith("file://")){const r=e.slice(7,e.lastIndexOf("/"));return""===e?"":ae(r,t.slice(7))}return t};var je={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:ve,value:ge,getAnchorPointer:be,typeOf:(e,t)=>re(ge(e),t),has:(e,t)=>e in ge(t),step:we,keys:e=>Object.keys(ge(e)),entries:e=>ee.pipeline([ge,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:Oe,length:e=>ge(e).length,toSchema:(e,t={})=>{const r={...Ee,...t},n=JSON.parse(JSON.stringify(e.schema,((t,n)=>{if(!A.isReference(n))return n;const o=A.value(n),a=o.$schema||e.schemaVersion,i=ce(a,"embeddedToken");return!r.includeEmbedded&&i in o?void 0:A.value(n)}))),o=ce(e.schemaVersion,"dynamicAnchorToken");Object.entries(e.dynamicAnchors).forEach((([e,t])=>{const r=ne(t)[1];$.assign(r,n,{[o]:e,...$.get(r,n)})}));const a=ce(e.schemaVersion,"anchorToken");Object.entries(e.anchors).filter((([e])=>""!==e)).forEach((([e,t])=>{$.assign(t,n,{[a]:e,...$.get(t,n)})}));const i=ce(e.schemaVersion,"baseToken"),s=$e(r.parentId,e.id),c=r.parentDialect===e.schemaVersion?"":e.schemaVersion;return{...s&&{[i]:s},...c&&{$schema:c},...n}}};je.setConfig,je.getConfig,je.add,je.get,je.markValidated,je.uri,je.value,je.getAnchorPointer,je.typeOf,je.has,je.step,je.keys,je.entries,je.map,je.length,je.toSchema;class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=Se;const{splitUrl:xe}=f,Ie="FLAG",Pe="BASIC",Te="DETAILED",ke="VERBOSE";let Ve=Te,Re=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ue=e((({ast:e,schemaUri:t},r,o=Ie)=>{if(![Ie,Pe,Te,ke].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",ze(o,a));return Fe(t,r,e,{}),n.unsubscribe(i),a[0]})),ze=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Pe&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Ie&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ke={},Le=e=>Ke[e],qe=e=>e in Ke,De={},_e={},Ne=async(e,t)=>{if(e=await Be(e),!qe(`${e.schemaVersion}#validate`)){const t=await je.get(e.schemaVersion);(je.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Ke[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Re&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in _e)){const t=await je.get(e.schemaVersion),r=await Ce(t);_e[t.id]=Ue(r)}const t=K.cons(e.schema,e.id),r=_e[e.schemaVersion](t,Ve);if(!r.valid)throw new Ae(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Le(`${e.schemaVersion}#validate`).compile(e,t)},Be=async e=>je.typeOf(e,"string")?Be(await je.get(je.value(e),e)):e,Fe=(e,t,r,n)=>{const o=Je(e,r),a=xe(e)[0];return Le(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Je=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var We={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t)=>Ue(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ue,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Re=e},FLAG:Ie,BASIC:Pe,DETAILED:Te,VERBOSE:ke,add:(e,t="",r="")=>{const n=je.add(e,t,r);delete _e[n]},getKeyword:Le,hasKeyword:qe,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Ne,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Je(e,r);return Le(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Je(e,r);return Le(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>je.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${je.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,je.uri(e),"boolean"==typeof n?n:await ee.pipeline([je.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>We.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=We.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&We.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&We.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={metaData:Ze,validate:Me},He={Core:We,Schema:je,Instance:K,Reference:A,Keywords:Ge,InvalidSchemaError:Ae},Qe=He.Core,Xe=He.Schema,Ye=He.Instance,et=He.Reference,tt=He.Keywords,rt=He.InvalidSchemaError;export{Qe as Core,Ye as Instance,rt as InvalidSchemaError,tt as Keywords,et as Reference,Xe as Schema,He as default}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -646,4 +646,67 @@ var JSC = (function (exports) { | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1 }; | ||
const CHAR_BACKWARD_SLASH = 47; | ||
const pathRelative$1 = (from, to) => { | ||
if (from === to) { | ||
return ""; | ||
} | ||
let toStart = 1; | ||
const fromLen = from.length - 1; | ||
const toLen = to.length - toStart; | ||
// Compare paths to find the longest common path from root | ||
const length = fromLen < toLen ? fromLen : toLen; | ||
let lastCommonSep = -1; | ||
let i = 0; | ||
for (; i < length; i++) { | ||
const fromCode = from.charCodeAt(i + 1); | ||
if (fromCode !== to.charCodeAt(toStart + i)) { | ||
break; | ||
} else if (fromCode === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} | ||
} | ||
if (toLen > length) { | ||
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) { | ||
return to.slice(toStart + i + 1); | ||
} | ||
if (i === 0) { | ||
return to.slice(toStart + i); | ||
} | ||
} | ||
if (fromLen > length) { | ||
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} else if (length === 0) { | ||
lastCommonSep = 0; | ||
} | ||
} | ||
let out = ""; | ||
// Generate the relative path based on the path difference between `to` and `from` | ||
for (i = lastCommonSep + 2; i <= from.length; ++i) { | ||
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) { | ||
out += out.length === 0 ? ".." : "/.."; | ||
} | ||
} | ||
toStart += lastCommonSep; | ||
// Lastly, append the rest of the destination (`to`) path that comes after | ||
// the common path parts | ||
if (out.length > 0) { | ||
return `${out}${to.slice(toStart, to.length)}`; | ||
} | ||
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) { | ||
++toStart; | ||
} | ||
return to.slice(toStart, to.length); | ||
}; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 }; | ||
const nil$2 = ""; | ||
@@ -1153,3 +1216,3 @@ | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl } = common; | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl, pathRelative } = common; | ||
@@ -1384,6 +1447,69 @@ | ||
const toSchemaDefaultOptions = { | ||
parentId: "", | ||
parentDialect: "", | ||
includeEmbedded: true | ||
}; | ||
const toSchema = (schemaDoc, options = {}) => { | ||
const fullOptions = { ...toSchemaDefaultOptions, ...options }; | ||
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => { | ||
if (!reference.isReference(value)) { | ||
return value; | ||
} | ||
const refValue = reference.value(value); | ||
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion; | ||
const embeddedToken = getConfig(embeddedDialect, "embeddedToken"); | ||
if (!fullOptions.includeEmbedded && embeddedToken in refValue) { | ||
return; | ||
} else { | ||
return reference.value(value); | ||
} | ||
})); | ||
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken"); | ||
Object.entries(schemaDoc.dynamicAnchors) | ||
.forEach(([anchor, uri]) => { | ||
const pointer = splitUrl$1(uri)[1]; | ||
lib$2.assign(pointer, schema, { | ||
[dynamicAnchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken"); | ||
Object.entries(schemaDoc.anchors) | ||
.filter(([anchor]) => anchor !== "") | ||
.forEach(([anchor, pointer]) => { | ||
lib$2.assign(pointer, schema, { | ||
[anchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken"); | ||
const id = relativeUri(fullOptions.parentId, schemaDoc.id); | ||
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion; | ||
return { | ||
...(id && { [baseToken]: id }), | ||
...(dialect && { $schema: dialect }), | ||
...schema | ||
}; | ||
}; | ||
const relativeUri = (from, to) => { | ||
if (to.startsWith("file://")) { | ||
const pathToSchema = from.slice(7, from.lastIndexOf("/")); | ||
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7)); | ||
} else { | ||
return to; | ||
} | ||
}; | ||
var schema = { | ||
setConfig, getConfig, | ||
add: add$1, get, markValidated, | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length, | ||
toSchema | ||
}; | ||
@@ -1405,2 +1531,3 @@ schema.setConfig; | ||
schema.length; | ||
schema.toSchema; | ||
@@ -1407,0 +1534,0 @@ class InvalidSchemaError extends Error { |
@@ -1,2 +0,2 @@ | ||
var JSC=function(e){"use strict";var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(c.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var p={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),P=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[P]:e,[S]:t}),isReference:e=>e&&void 0!==e[P],href:e=>e[P],value:e=>e[S]};const{jsonTypeOf:x}=p,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>A.isReference(e.value)?A.value(e.value):e.value,k=t(((e,t)=>x(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function Z(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var M={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!F.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Z(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!F.test(n))throw new TypeError("invalid media type");var o=new J(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},W=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:W,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([W,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae}=p,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");ne(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,fe(e,n,r),A.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return A.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=ae(me(t),e),[n,o]=oe(r);if(!(e=>e in le||e in ue)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=M.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>A.isReference(e.value)?A.value(e.value):e.value,ge=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:we(t)[e],validated:r.validated});return ve(n)},Oe=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await ge(n,t),n))),te.all],t)));var Ee={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:me,value:we,getAnchorPointer:be,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:ge,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await ge(t,e)])),te.all],e),map:Oe,length:e=>we(e).length};Ee.setConfig,Ee.getConfig,Ee.add,Ee.get,Ee.markValidated,Ee.uri,Ee.value,Ee.getAnchorPointer,Ee.typeOf,Ee.has,Ee.step,Ee.keys,Ee.entries,Ee.map,Ee.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=je;const{splitUrl:Se}=p,Pe="FLAG",Ae="BASIC",xe="DETAILED",Ie="VERBOSE";let Te=xe,ke=!0;const Ve=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Re=t((({ast:e,schemaUri:t},r,n=Pe)=>{if(![Pe,Ae,xe,Ie].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ce(n,a));return Ne(t,r,e,{}),o.unsubscribe(i),a[0]})),Ce=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ae&&(o.push(...t.errors),delete t.errors),(e===Ie||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},ze=e=>Ue[e],Ke=e=>e in Ue,Le={},qe={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Ee.get(e.schemaVersion);(Ee.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(ke&&!e.validated){if(Ee.markValidated(e.id),!(e.schemaVersion in qe)){const t=await Ee.get(e.schemaVersion),r=await Ve(t);qe[t.id]=Re(r)}const t=L.cons(e.schema,e.id),r=qe[e.schemaVersion](t,Te);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),ze(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Ee.typeOf(e,"string")?De(await Ee.get(Ee.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=Se(e)[0];return ze(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Fe={validate:async(e,t,r)=>{const n=await Ve(e),o=(e,t)=>Re(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ve,interpret:Re,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{ke=e},FLAG:Pe,BASIC:Ae,DETAILED:xe,VERBOSE:Ie,add:(e,t="",r="")=>{const n=Ee.add(e,t,r);delete qe[n]},getKeyword:ze,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>Ee.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=Ee.uri(e);if(!(r in t)){t[r]=!1;const n=Ee.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Ee.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Ee.uri(e),"boolean"==typeof n?n:await te.pipeline([Ee.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Fe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ee.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Fe.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Fe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Fe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={metaData:Ze,validate:Je},We={Core:Fe,Schema:Ee,Instance:L,Reference:A,Keywords:Me,InvalidSchemaError:$e},Ge=We.Core,He=We.Schema,Qe=We.Instance,Xe=We.Reference,Ye=We.Keywords,et=We.InvalidSchemaError;return e.Core=Ge,e.Instance=Qe,e.InvalidSchemaError=et,e.Keywords=Ye,e.Reference=Xe,e.Schema=He,e.default=We,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var JSC=function(e){"use strict";var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function d(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(c.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var d={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},pathRelative:(e,t)=>{if(e===t)return"";let r=1;const n=e.length-1,o=t.length-r,a=n<o?n:o;let i=-1,s=0;for(;s<a;s++){const n=e.charCodeAt(s+1);if(n!==t.charCodeAt(r+s))break;47===n&&(i=s)}if(o>a){if(47===t.charCodeAt(r+s))return t.slice(r+s+1);if(0===s)return t.slice(r+s)}n>a&&(47===e.charCodeAt(s+1)?i=s:0===a&&(i=0));let c="";for(s=i+2;s<=e.length;++s)s!==e.length&&47!==e.charCodeAt(s)||(c+=0===c.length?"..":"/..");return r+=i,c.length>0?`${c}${t.slice(r,t.length)}`:(47===t.charCodeAt(r)&&++r,t.slice(r,t.length))}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,b(o,n))}else{t[O(t,e[0])]=r}},m=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:m(e,o,b(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return E(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},b=t(((e,t)=>t+"/"+g(e))),g=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>m(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),A=Symbol("$__href");var P={cons:(e,t)=>Object.freeze({[A]:e,[S]:t}),isReference:e=>e&&void 0!==e[A],href:e=>e[A],value:e=>e[S]};const{jsonTypeOf:x}=d,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>P.isReference(e.value)?P.value(e.value):e.value,k=t(((e,t)=>x(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,J=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var Z={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:M,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([M,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae,pathRelative:ie}=d,se={},ce={},le=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},ue={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(fe[i]=c);const u={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ne(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):(ce[c]=n,d={[n]:!0});const h={"":""};return ue[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:d,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,de(e,n,r),P.cons(e[s],e)}const l=le(r,"anchorToken"),u=le(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=le(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const d=le(r,"jrefToken");if("string"==typeof e[d])return P.cons(e[d],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},he=e=>ue[fe[e]]||ue[e],ye=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=ye)=>{const r=ae(ge(t),e),[n,o]=oe(r);if(!(e=>e in ue||e in fe)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=Z.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),n)}const a=he(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>P.isReference(e.value)?me(P.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>P.isReference(e.value)?P.value(e.value):e.value,Oe=(e,t)=>{const r=he(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:we(t)[e],validated:r.validated});return ve(n)},Ee=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await Oe(n,t),n))),te.all],t))),je={parentId:"",parentDialect:"",includeEmbedded:!0},$e=(e,t)=>{if(t.startsWith("file://")){const r=e.slice(7,e.lastIndexOf("/"));return""===e?"":ie(r,t.slice(7))}return t};var Se={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:le,add:de,get:me,markValidated:e=>{ue[e].validated=!0},uri:ge,value:we,getAnchorPointer:be,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:Oe,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await Oe(t,e)])),te.all],e),map:Ee,length:e=>we(e).length,toSchema:(e,t={})=>{const r={...je,...t},n=JSON.parse(JSON.stringify(e.schema,((t,n)=>{if(!P.isReference(n))return n;const o=P.value(n),a=o.$schema||e.schemaVersion,i=le(a,"embeddedToken");return!r.includeEmbedded&&i in o?void 0:P.value(n)}))),o=le(e.schemaVersion,"dynamicAnchorToken");Object.entries(e.dynamicAnchors).forEach((([e,t])=>{const r=oe(t)[1];$.assign(r,n,{[o]:e,...$.get(r,n)})}));const a=le(e.schemaVersion,"anchorToken");Object.entries(e.anchors).filter((([e])=>""!==e)).forEach((([e,t])=>{$.assign(t,n,{[a]:e,...$.get(t,n)})}));const i=le(e.schemaVersion,"baseToken"),s=$e(r.parentId,e.id),c=r.parentDialect===e.schemaVersion?"":e.schemaVersion;return{...s&&{[i]:s},...c&&{$schema:c},...n}}};Se.setConfig,Se.getConfig,Se.add,Se.get,Se.markValidated,Se.uri,Se.value,Se.getAnchorPointer,Se.typeOf,Se.has,Se.step,Se.keys,Se.entries,Se.map,Se.length,Se.toSchema;class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Ae;const{splitUrl:xe}=d,Ie="FLAG",Te="BASIC",ke="DETAILED",Ve="VERBOSE";let Re=ke,Ce=!0;const Ue=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Je(e,t)}},ze=t((({ast:e,schemaUri:t},r,n=Ie)=>{if(![Ie,Te,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ke(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Ke=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Ie&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Le={},qe=e=>Le[e],_e=e=>e in Le,De={},Ne={},Je=async(e,t)=>{if(e=await Be(e),!_e(`${e.schemaVersion}#validate`)){const t=await Se.get(e.schemaVersion);(Se.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Le[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ce&&!e.validated){if(Se.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await Se.get(e.schemaVersion),r=await Ue(t);Ne[t.id]=ze(r)}const t=L.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Re);if(!r.valid)throw new Pe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),qe(`${e.schemaVersion}#validate`).compile(e,t)},Be=async e=>Se.typeOf(e,"string")?Be(await Se.get(Se.value(e),e)):e,Fe=(e,t,r,n)=>{const o=We(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},We=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await Ue(e),o=(e,t)=>ze(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ue,interpret:ze,setMetaOutputFormat:e=>{Re=e},setShouldMetaValidate:e=>{Ce=e},FLAG:Ie,BASIC:Te,DETAILED:ke,VERBOSE:Ve,add:(e,t="",r="")=>{const n=Se.add(e,t,r);delete Ne[n]},getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Je,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=We(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=We(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>Se.value(e),interpret:()=>!0};var Ge={compile:async(e,t)=>{const r=Se.uri(e);if(!(r in t)){t[r]=!1;const n=Se.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Se.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Se.uri(e),"boolean"==typeof n?n:await te.pipeline([Se.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Ze.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,Se.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},He={metaData:Me,validate:Ge},Qe={Core:Ze,Schema:Se,Instance:L,Reference:P,Keywords:He,InvalidSchemaError:Pe},Xe=Qe.Core,Ye=Qe.Schema,et=Qe.Instance,tt=Qe.Reference,rt=Qe.Keywords,nt=Qe.InvalidSchemaError;return e.Core=Xe,e.Instance=et,e.InvalidSchemaError=nt,e.Keywords=rt,e.Reference=tt,e.Schema=Ye,e.default=Qe,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -1,2 +0,2 @@ | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(c.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var p={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||j(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+g(e))),g=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(j(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},j=e=>null===e||"object"!=typeof e;var $={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};$.nil,$.append,$.get,$.set,$.assign,$.unset,$.remove;const S=Symbol("$__value"),x=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[x]:e,[S]:t}),isReference:e=>e&&void 0!==e[x],href:e=>e[x],value:e=>e[S]};const{jsonTypeOf:P}=p,I=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>A.isReference(e.value)?A.value(e.value):e.value,k=t(((e,t)=>P(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:$.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:I,cons:(e,t="")=>Object.freeze({...I,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,D=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,B=/([\\"])/g,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function Z(e){var t=String(e);if(D.test(t))return t;if(t.length>0&&!_.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(B,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!F.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!D.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Z(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!F.test(n))throw new TypeError("invalid media type");var o=new J(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:M,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([M,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae}=p,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=ce(n,"vocabularyToken");ne(e[d],"object")?(se[c]=n,p=e[d],delete e[d]):(se[c]=n,p={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:pe(e,c,n,$.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,fe(e,n,r),A.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=ce(r,"jrefToken");if("string"==typeof e[p])return A.cons(e[p],e);for(const i in e)e[i]=pe(e[i],t,r,$.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,$.append(i,n),o,a))):e},de=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:$.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=ae(me(t),e),[n,o]=oe(r);if(!(e=>e in le||e in ue)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=de(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:$.get(i,a.schema)});return ve(s)},ve=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},me=e=>`${e.id}#${encodeURI(e.pointer)}`,ge=e=>A.isReference(e.value)?A.value(e.value):e.value,we=(e,t)=>{const r=de(t.id),n=Object.freeze({...t,pointer:$.append(e,t.pointer),value:ge(t)[e],validated:r.validated});return ve(n)},Oe=t(((e,t)=>te.pipeline([ge,te.map((async(r,n)=>e(await we(n,t),n))),te.all],t)));var Ee={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:me,value:ge,getAnchorPointer:be,typeOf:(e,t)=>ne(ge(e),t),has:(e,t)=>e in ge(t),step:we,keys:e=>Object.keys(ge(e)),entries:e=>te.pipeline([ge,Object.keys,te.map((async t=>[t,await we(t,e)])),te.all],e),map:Oe,length:e=>ge(e).length};Ee.setConfig,Ee.getConfig,Ee.add,Ee.get,Ee.markValidated,Ee.uri,Ee.value,Ee.getAnchorPointer,Ee.typeOf,Ee.has,Ee.step,Ee.keys,Ee.entries,Ee.map,Ee.length;class je extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=je;const{splitUrl:Se}=p,xe="FLAG",Ae="BASIC",Pe="DETAILED",Ie="VERBOSE";let Te=Pe,ke=!0;const Ve=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await _e(e,t)}},Re=t((({ast:e,schemaUri:t},r,n=xe)=>{if(![xe,Ae,Pe,Ie].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ce(n,a));return Ne(t,r,e,{}),o.unsubscribe(i),a[0]})),Ce=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ae&&(o.push(...t.errors),delete t.errors),(e===Ie||e!==xe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ue={},ze=e=>Ue[e],Ke=e=>e in Ue,Le={},qe={},_e=async(e,t)=>{if(e=await De(e),!Ke(`${e.schemaVersion}#validate`)){const t=await Ee.get(e.schemaVersion);(Ee.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in Le)Object.entries(Le[e]).forEach((([e,r])=>{((e,t)=>{Ue[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(ke&&!e.validated){if(Ee.markValidated(e.id),!(e.schemaVersion in qe)){const t=await Ee.get(e.schemaVersion),r=await Ve(t);qe[t.id]=Re(r)}const t=L.cons(e.schema,e.id),r=qe[e.schemaVersion](t,Te);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),ze(`${e.schemaVersion}#validate`).compile(e,t)},De=async e=>Ee.typeOf(e,"string")?De(await Ee.get(Ee.value(e),e)):e,Ne=(e,t,r,n)=>{const o=Be(e,r),a=Se(e)[0];return ze(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Be=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Fe={validate:async(e,t,r)=>{const n=await Ve(e),o=(e,t)=>Re(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ve,interpret:Re,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{ke=e},FLAG:xe,BASIC:Ae,DETAILED:Pe,VERBOSE:Ie,add:(e,t="",r="")=>{const n=Ee.add(e,t,r);delete qe[n]},getKeyword:ze,hasKeyword:Ke,defineVocabulary:(e,t)=>{Le[e]=t},compileSchema:_e,interpretSchema:Ne,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Be(e,r);return ze(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>Ee.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=Ee.uri(e);if(!(r in t)){t[r]=!1;const n=Ee.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Ee.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Ee.uri(e),"boolean"==typeof n?n:await te.pipeline([Ee.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Fe.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Fe.getKeyword(r).compile(n,t,e);return[r,Ee.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Fe.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Fe.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Fe.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},We={metaData:Ze,validate:Je},Me=e("default",{Core:Fe,Schema:Ee,Instance:L,Reference:A,Keywords:We,InvalidSchemaError:$e});e("Core",Me.Core),e("Schema",Me.Schema),e("Instance",Me.Instance),e("Reference",Me.Reference),e("Keywords",Me.Keywords),e("InvalidSchemaError",Me.InvalidSchemaError)}}})); | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function d(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports);o.PubSub;var a=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(c.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}};function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const l={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},f=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var d={jsonTypeOf:(e,t)=>l[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=a(e,t),n=u(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},pathRelative:(e,t)=>{if(e===t)return"";let r=1;const n=e.length-1,o=t.length-r,a=n<o?n:o;let i=-1,s=0;for(;s<a;s++){const n=e.charCodeAt(s+1);if(n!==t.charCodeAt(r+s))break;47===n&&(i=s)}if(o>a){if(47===t.charCodeAt(r+s))return t.slice(r+s+1);if(0===s)return t.slice(r+s)}n>a&&(47===e.charCodeAt(s+1)?i=s:0===a&&(i=0));let c="";for(s=i+2;s<=e.length;++s)s!==e.length&&47!==e.charCodeAt(s)||(c+=0===c.length?"..":"/..");return r+=i,c.length>0?`${c}${t.slice(r,t.length)}`:(47===t.charCodeAt(r)&&++r,t.slice(r,t.length))}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,v(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||$(t)){const o=e.shift();y(e,E(t,o,n),r,v(o,n))}else{t[O(t,e[0])]=r}},m=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:m(e,o,v(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,v(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},v=t(((e,t)=>t+"/"+g(e))),g=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if($(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},$=e=>null===e||"object"!=typeof e;var j={nil:"",append:v,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),v(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>m(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const S=Symbol("$__value"),A=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[A]:e,[S]:t}),isReference:e=>e&&void 0!==e[A],href:e=>e[A],value:e=>e[S]};const{jsonTypeOf:I}=d,P=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>x.isReference(e.value)?x.value(e.value):e.value,k=t(((e,t)=>I(T(e),t))),V=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:T(t)[e]}),R=t(((e,t)=>T(t).map(((r,n,o,a)=>e(V(n,t),n,o,a))))),C=t(((e,t)=>T(t).map(((e,r,n,o)=>V(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),U=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,V(o,r),o)),t))),z=t(((e,t)=>T(t).every(((r,n,o,a)=>e(V(n,t),n,o,a))))),K=t(((e,t)=>T(t).some(((r,n,o,a)=>e(V(n,t),n,o,a)))));var L={nil:P,cons:(e,t="")=>Object.freeze({...P,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:k,step:V,entries:e=>Object.keys(T(e)).map((t=>[t,V(t,e)])),keys:e=>Object.keys(T(e)),map:R,filter:C,reduce:U,every:z,some:K,length:e=>T(e).length},q=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,D=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N=/\\([\u000b\u0020-\u00ff])/g,J=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!D.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var Z={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var a,i,s;for(q.lastIndex=r;i=q.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(N,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),G=t((async(e,t)=>(await t).map(e))),H=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Q=t((async(e,t,r={})=>H((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),X=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).some((e=>e))})),Y=t((async(e,t)=>{const r=await G(e,t);return(await Promise.all(r)).every((e=>e))})),ee=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),te={entries:M,map:G,filter:Q,reduce:H,some:X,every:Y,pipeline:ee,all:e=>Promise.all(e),allValues:e=>ee([M,H((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};te.entries,te.map,te.filter,te.reduce,te.some,te.every,te.pipeline,te.all,te.allValues;var re=fetch;const{jsonTypeOf:ne,splitUrl:oe,safeResolveUrl:ae,pathRelative:ie}=d,se={},ce={},le=(e,t)=>{const r=e in ce?ce[e]:e;if(r in se)return se[r][t]},ue={},fe={},de=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=oe(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=oe(t)[0];if(!i&&!oe(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ae(i,e[o]||""),[c,l]=oe(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(fe[i]=c);const u={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ne(e[p],"object")?(ce[c]=n,d=e[p],delete e[p]):(ce[c]=n,d={[n]:!0});const h={"":""};return ue[c]={id:c,schemaVersion:n,schema:pe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:d,validated:!1},c},pe=(e,t,r,n,o,a)=>{if(ne(e,"object")){const i="string"==typeof e.$schema?oe(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ae(t,e[s]);return e[s]=n,de(e,n,r),x.cons(e[s],e)}const l=le(r,"anchorToken"),u=le(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=le(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const d=le(r,"jrefToken");if("string"==typeof e[d])return x.cons(e[d],e);for(const i in e)e[i]=pe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>pe(e,t,r,j.append(i,n),o,a))):e},he=e=>ue[fe[e]]||ue[e],ye=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=ye)=>{const r=ae(ge(t),e),[n,o]=oe(r);if(!(e=>e in ue||e in fe)(n)){const e=await re(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=Z.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}de(await e.json(),n)}const a=he(n),i="/"!==o[0]?ve(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return be(s)},be=e=>x.isReference(e.value)?me(x.href(e.value),e):e,ve=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,we=e=>x.isReference(e.value)?x.value(e.value):e.value,Oe=(e,t)=>{const r=he(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:we(t)[e],validated:r.validated});return be(n)},Ee=t(((e,t)=>te.pipeline([we,te.map((async(r,n)=>e(await Oe(n,t),n))),te.all],t))),$e={parentId:"",parentDialect:"",includeEmbedded:!0},je=(e,t)=>{if(t.startsWith("file://")){const r=e.slice(7,e.lastIndexOf("/"));return""===e?"":ie(r,t.slice(7))}return t};var Se={setConfig:(e,t,r)=>{se[e]||(se[e]={}),se[e][t]=r},getConfig:le,add:de,get:me,markValidated:e=>{ue[e].validated=!0},uri:ge,value:we,getAnchorPointer:ve,typeOf:(e,t)=>ne(we(e),t),has:(e,t)=>e in we(t),step:Oe,keys:e=>Object.keys(we(e)),entries:e=>te.pipeline([we,Object.keys,te.map((async t=>[t,await Oe(t,e)])),te.all],e),map:Ee,length:e=>we(e).length,toSchema:(e,t={})=>{const r={...$e,...t},n=JSON.parse(JSON.stringify(e.schema,((t,n)=>{if(!x.isReference(n))return n;const o=x.value(n),a=o.$schema||e.schemaVersion,i=le(a,"embeddedToken");return!r.includeEmbedded&&i in o?void 0:x.value(n)}))),o=le(e.schemaVersion,"dynamicAnchorToken");Object.entries(e.dynamicAnchors).forEach((([e,t])=>{const r=oe(t)[1];j.assign(r,n,{[o]:e,...j.get(r,n)})}));const a=le(e.schemaVersion,"anchorToken");Object.entries(e.anchors).filter((([e])=>""!==e)).forEach((([e,t])=>{j.assign(t,n,{[a]:e,...j.get(t,n)})}));const i=le(e.schemaVersion,"baseToken"),s=je(r.parentId,e.id),c=r.parentDialect===e.schemaVersion?"":e.schemaVersion;return{...s&&{[i]:s},...c&&{$schema:c},...n}}};Se.setConfig,Se.getConfig,Se.add,Se.get,Se.markValidated,Se.uri,Se.value,Se.getAnchorPointer,Se.typeOf,Se.has,Se.step,Se.keys,Se.entries,Se.map,Se.length,Se.toSchema;class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=Ae;const{splitUrl:Ie}=d,Pe="FLAG",Te="BASIC",ke="DETAILED",Ve="VERBOSE";let Re=ke,Ce=!0;const Ue=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Je(e,t)}},ze=t((({ast:e,schemaUri:t},r,n=Pe)=>{if(![Pe,Te,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);const a=[],i=o.subscribe("result",Ke(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Ke=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Le={},qe=e=>Le[e],De=e=>e in Le,_e={},Ne={},Je=async(e,t)=>{if(e=await Be(e),!De(`${e.schemaVersion}#validate`)){const t=await Se.get(e.schemaVersion);(Se.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Le[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ce&&!e.validated){if(Se.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await Se.get(e.schemaVersion),r=await Ue(t);Ne[t.id]=ze(r)}const t=L.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Re);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),qe(`${e.schemaVersion}#validate`).compile(e,t)},Be=async e=>Se.typeOf(e,"string")?Be(await Se.get(Se.value(e),e)):e,Fe=(e,t,r,n)=>{const o=We(e,r),a=Ie(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},We=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await Ue(e),o=(e,t)=>ze(n,L.cons(e),t);return void 0===t?o:o(t,r)},compile:Ue,interpret:ze,setMetaOutputFormat:e=>{Re=e},setShouldMetaValidate:e=>{Ce=e},FLAG:Pe,BASIC:Te,DETAILED:ke,VERBOSE:Ve,add:(e,t="",r="")=>{const n=Se.add(e,t,r);delete Ne[n]},getKeyword:qe,hasKeyword:De,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Je,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=We(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=We(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>Se.value(e),interpret:()=>!0};var Ge={compile:async(e,t)=>{const r=Se.uri(e);if(!(r in t)){t[r]=!1;const n=Se.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Se.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Se.uri(e),"boolean"==typeof n?n:await te.pipeline([Se.entries,te.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),te.filter((([t])=>Ze.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),te.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,Se.uri(n),o]})),te.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:L.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:L.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},He={metaData:Me,validate:Ge},Qe=e("default",{Core:Ze,Schema:Se,Instance:L,Reference:x,Keywords:He,InvalidSchemaError:xe});e("Core",Qe.Core),e("Schema",Qe.Schema),e("Instance",Qe.Instance),e("Reference",Qe.Reference),e("Keywords",Qe.Keywords),e("InvalidSchemaError",Qe.InvalidSchemaError)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
@@ -649,4 +649,67 @@ (function (global, factory) { | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1 }; | ||
const CHAR_BACKWARD_SLASH = 47; | ||
const pathRelative$1 = (from, to) => { | ||
if (from === to) { | ||
return ""; | ||
} | ||
let toStart = 1; | ||
const fromLen = from.length - 1; | ||
const toLen = to.length - toStart; | ||
// Compare paths to find the longest common path from root | ||
const length = fromLen < toLen ? fromLen : toLen; | ||
let lastCommonSep = -1; | ||
let i = 0; | ||
for (; i < length; i++) { | ||
const fromCode = from.charCodeAt(i + 1); | ||
if (fromCode !== to.charCodeAt(toStart + i)) { | ||
break; | ||
} else if (fromCode === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} | ||
} | ||
if (toLen > length) { | ||
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) { | ||
return to.slice(toStart + i + 1); | ||
} | ||
if (i === 0) { | ||
return to.slice(toStart + i); | ||
} | ||
} | ||
if (fromLen > length) { | ||
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} else if (length === 0) { | ||
lastCommonSep = 0; | ||
} | ||
} | ||
let out = ""; | ||
// Generate the relative path based on the path difference between `to` and `from` | ||
for (i = lastCommonSep + 2; i <= from.length; ++i) { | ||
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) { | ||
out += out.length === 0 ? ".." : "/.."; | ||
} | ||
} | ||
toStart += lastCommonSep; | ||
// Lastly, append the rest of the destination (`to`) path that comes after | ||
// the common path parts | ||
if (out.length > 0) { | ||
return `${out}${to.slice(toStart, to.length)}`; | ||
} | ||
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) { | ||
++toStart; | ||
} | ||
return to.slice(toStart, to.length); | ||
}; | ||
var common = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$2, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 }; | ||
const nil$2 = ""; | ||
@@ -1156,3 +1219,3 @@ | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl } = common; | ||
const { jsonTypeOf, splitUrl: splitUrl$1, safeResolveUrl, pathRelative } = common; | ||
@@ -1387,6 +1450,69 @@ | ||
const toSchemaDefaultOptions = { | ||
parentId: "", | ||
parentDialect: "", | ||
includeEmbedded: true | ||
}; | ||
const toSchema = (schemaDoc, options = {}) => { | ||
const fullOptions = { ...toSchemaDefaultOptions, ...options }; | ||
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => { | ||
if (!reference.isReference(value)) { | ||
return value; | ||
} | ||
const refValue = reference.value(value); | ||
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion; | ||
const embeddedToken = getConfig(embeddedDialect, "embeddedToken"); | ||
if (!fullOptions.includeEmbedded && embeddedToken in refValue) { | ||
return; | ||
} else { | ||
return reference.value(value); | ||
} | ||
})); | ||
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken"); | ||
Object.entries(schemaDoc.dynamicAnchors) | ||
.forEach(([anchor, uri]) => { | ||
const pointer = splitUrl$1(uri)[1]; | ||
lib$2.assign(pointer, schema, { | ||
[dynamicAnchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken"); | ||
Object.entries(schemaDoc.anchors) | ||
.filter(([anchor]) => anchor !== "") | ||
.forEach(([anchor, pointer]) => { | ||
lib$2.assign(pointer, schema, { | ||
[anchorToken]: anchor, | ||
...lib$2.get(pointer, schema) | ||
}); | ||
}); | ||
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken"); | ||
const id = relativeUri(fullOptions.parentId, schemaDoc.id); | ||
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion; | ||
return { | ||
...(id && { [baseToken]: id }), | ||
...(dialect && { $schema: dialect }), | ||
...schema | ||
}; | ||
}; | ||
const relativeUri = (from, to) => { | ||
if (to.startsWith("file://")) { | ||
const pathToSchema = from.slice(7, from.lastIndexOf("/")); | ||
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7)); | ||
} else { | ||
return to; | ||
} | ||
}; | ||
var schema = { | ||
setConfig, getConfig, | ||
add: add$1, get, markValidated, | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length, | ||
toSchema | ||
}; | ||
@@ -1408,2 +1534,3 @@ schema.setConfig; | ||
schema.length; | ||
schema.toSchema; | ||
@@ -1410,0 +1537,0 @@ class InvalidSchemaError extends Error { |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSC={})}(this,(function(e){"use strict";var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function p(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return p(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return p(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}));n.PubSub;var o=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(s.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},d=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:d(e,O(t,o,n),r,v(o,n))}}if(Array.isArray(t)){const n=[...t];return n[w(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,v(o,n))}else{t[w(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,v(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return O(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);b(e,o,v(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},v=t(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),w=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[w(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:v,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),v(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>d(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=p(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var x={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:P}=f,A=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),T=e=>x.isReference(e.value)?x.value(e.value):e.value,I=t(((e,t)=>P(T(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:T(t)[e]}),V=t(((e,t)=>T(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=t(((e,t)=>T(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=t(((e,t,r)=>T(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),U=t(((e,t)=>T(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=t(((e,t)=>T(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:A,cons:(e,t="")=>Object.freeze({...A,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:T,has:(e,t)=>e in T(t),typeOf:I,step:k,entries:e=>Object.keys(T(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(T(e)),map:V,filter:R,reduce:C,every:U,some:z,length:e=>T(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function F(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function Z(e){this.parameters=Object.create(null),this.type=e}var J={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!B.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+F(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!B.test(n))throw new TypeError("invalid media type");var o=new Z(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},M=async e=>Object.entries(await e),W=t((async(e,t)=>(await t).map(e))),G=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=t((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=t((async(e,t)=>{const r=await W(e,t);return(await Promise.all(r)).some((e=>e))})),X=t((async(e,t)=>{const r=await W(e,t);return(await Promise.all(r)).every((e=>e))})),Y=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:M,map:W,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([M,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe}=f,ae={},ie={},se=(e,t)=>{const r=e in ie?ie[e]:e;if(r in ae)return ae[r][t]},ce={},le={},ue=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=se(n,"baseToken"),a=se(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(le[i]=c);const u={},f=se(n,"recursiveAnchorToken");let p;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const d=se(n,"vocabularyToken");re(e[d],"object")?(ie[c]=n,p=e[d],delete e[d]):(ie[c]=n,p={[n]:!0});const h={"":""};return ce[c]={id:c,schemaVersion:n,schema:fe(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:p,validated:!1},c},fe=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=se(i,"embeddedToken"),c=se(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,ue(e,n,r),x.cons(e[s],e)}const l=se(r,"anchorToken"),u=se(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=se(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const p=se(r,"jrefToken");if("string"==typeof e[p])return x.cons(e[p],e);for(const i in e)e[i]=fe(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>fe(e,t,r,j.append(i,n),o,a))):e},pe=e=>ce[le[e]]||ce[e],de=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),he=async(e,t=de)=>{const r=oe(ve(t),e),[n,o]=ne(r);if(!(e=>e in ce||e in le)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=J.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}ue(await e.json(),n)}const a=pe(n),i="/"!==o[0]?be(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return ye(s)},ye=e=>x.isReference(e.value)?he(x.href(e.value),e):e,be=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ve=e=>`${e.id}#${encodeURI(e.pointer)}`,me=e=>x.isReference(e.value)?x.value(e.value):e.value,ge=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:me(t)[e],validated:r.validated});return ye(n)},we=t(((e,t)=>ee.pipeline([me,ee.map((async(r,n)=>e(await ge(n,t),n))),ee.all],t)));var Oe={setConfig:(e,t,r)=>{ae[e]||(ae[e]={}),ae[e][t]=r},getConfig:se,add:ue,get:he,markValidated:e=>{ce[e].validated=!0},uri:ve,value:me,getAnchorPointer:be,typeOf:(e,t)=>re(me(e),t),has:(e,t)=>e in me(t),step:ge,keys:e=>Object.keys(me(e)),entries:e=>ee.pipeline([me,Object.keys,ee.map((async t=>[t,await ge(t,e)])),ee.all],e),map:we,length:e=>me(e).length};Oe.setConfig,Oe.getConfig,Oe.add,Oe.get,Oe.markValidated,Oe.uri,Oe.value,Oe.getAnchorPointer,Oe.typeOf,Oe.has,Oe.step,Oe.keys,Oe.entries,Oe.map,Oe.length;class Ee extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var je=Ee;const{splitUrl:$e}=f,Se="FLAG",xe="BASIC",Pe="DETAILED",Ae="VERBOSE";let Te=Pe,Ie=!0;const ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await qe(e,t)}},Ve=t((({ast:e,schemaUri:t},r,o=Se)=>{if(![Se,xe,Pe,Ae].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",Re(o,a));return De(t,r,e,{}),n.unsubscribe(i),a[0]})),Re=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===xe&&(o.push(...t.errors),delete t.errors),(e===Ae||e!==Se&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Ue=e=>Ce[e],ze=e=>e in Ce,Ke={},Le={},qe=async(e,t)=>{if(e=await _e(e),!ze(`${e.schemaVersion}#validate`)){const t=await Oe.get(e.schemaVersion);(Oe.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in Ke)Object.entries(Ke[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Ie&&!e.validated){if(Oe.markValidated(e.id),!(e.schemaVersion in Le)){const t=await Oe.get(e.schemaVersion),r=await ke(t);Le[t.id]=Ve(r)}const t=K.cons(e.schema,e.id),r=Le[e.schemaVersion](t,Te);if(!r.valid)throw new je(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Ue(`${e.schemaVersion}#validate`).compile(e,t)},_e=async e=>Oe.typeOf(e,"string")?_e(await Oe.get(Oe.value(e),e)):e,De=(e,t,r,n)=>{const o=Ne(e,r),a=$e(e)[0];return Ue(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ne=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var Be={validate:async(e,t,r)=>{const n=await ke(e),o=(e,t)=>Ve(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:ke,interpret:Ve,setMetaOutputFormat:e=>{Te=e},setShouldMetaValidate:e=>{Ie=e},FLAG:Se,BASIC:xe,DETAILED:Pe,VERBOSE:Ae,add:(e,t="",r="")=>{const n=Oe.add(e,t,r);delete Le[n]},getKeyword:Ue,hasKeyword:ze,defineVocabulary:(e,t)=>{Ke[e]=t},compileSchema:qe,interpretSchema:De,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ne(e,r);return Ue(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ne(e,r);return Ue(a).collectEvaluatedItems(e,t,r,n,o)}};var Fe={compile:e=>Oe.value(e),interpret:()=>!0};var Ze={compile:async(e,t)=>{const r=Oe.uri(e);if(!(r in t)){t[r]=!1;const n=Oe.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${Oe.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,Oe.uri(e),"boolean"==typeof n?n:await ee.pipeline([Oe.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>Be.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await Be.getKeyword(r).compile(n,t,e);return[r,Oe.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Be.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Be.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Be.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Je={metaData:Fe,validate:Ze},Me={Core:Be,Schema:Oe,Instance:K,Reference:x,Keywords:Je,InvalidSchemaError:je},We=Me.Core,Ge=Me.Schema,He=Me.Instance,Qe=Me.Reference,Xe=Me.Keywords,Ye=Me.InvalidSchemaError;e.Core=We,e.Instance=He,e.InvalidSchemaError=Ye,e.Keywords=Xe,e.Reference=Qe,e.Schema=Ge,e.default=Me,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSC={})}(this,(function(e){"use strict";var t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],l=o?s:i;if(Object.prototype.hasOwnProperty.call(t,r))for(a in c)Object.prototype.hasOwnProperty.call(c,a)&&l(c[a],e,n)}function l(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function u(e){var r=String(e);return Boolean(Object.prototype.hasOwnProperty.call(t,r)&&o(t[r]))}function f(e){for(var t=String(e),r=u(t)||u(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=u(t);return r}function d(e,t,r,n){var o=l(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,Object.prototype.hasOwnProperty.call(t,e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeAll=function(t){return e.subscribe(n,t)},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n,o=0;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)){for(n in t[r])o++;break}return o},e.getSubscriptions=function(e){var r,n=[];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,a,i=function(e){var r;for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(Object.prototype.hasOwnProperty.call(t,r)||i(r)),c=!s&&"string"==typeof r,l="function"==typeof r,u=!1;if(!s){for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(o=t[n],c&&o[r]){delete o[r],u=r;break}if(l)for(a in o)Object.prototype.hasOwnProperty.call(o,a)&&o[a]===r&&(delete o[a],u=!0)}return u}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}));n.PubSub;var o=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(s.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}};function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach(((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))})),"/"+r.join("/")}const s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]},u=e=>{const t=RegExp(/^(.+):\/\//).exec(e);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=o(e,t),n=l(e)[0];if(n&&"file"===u(r)&&"file"!==u(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},pathRelative:(e,t)=>{if(e===t)return"";let r=1;const n=e.length-1,o=t.length-r,a=n<o?n:o;let i=-1,s=0;for(;s<a;s++){const n=e.charCodeAt(s+1);if(n!==t.charCodeAt(r+s))break;47===n&&(i=s)}if(o>a){if(47===t.charCodeAt(r+s))return t.slice(r+s+1);if(0===s)return t.slice(r+s)}n>a&&(47===e.charCodeAt(s+1)?i=s:0===a&&(i=0));let c="";for(s=i+2;s<=e.length;++s)s!==e.length&&47!==e.charCodeAt(s)||(c+=0===c.length?"..":"/..");return r+=i,c.length>0?`${c}${t.slice(r,t.length)}`:(47===t.charCodeAt(r)&&++r,t.slice(r,t.length))}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,O(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[w(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,m(o,n))}else{t[w(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,m(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return O(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},m=t(((e,t)=>t+"/"+v(e))),v=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),w=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[w(e,t)]},E=e=>null===e||"object"!=typeof e;var j={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),a=t(((e,t)=>p(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=d(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},remove:(e,t)=>{const r=d(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};j.nil,j.append,j.get,j.set,j.assign,j.unset,j.remove;const $=Symbol("$__value"),S=Symbol("$__href");var A={cons:(e,t)=>Object.freeze({[S]:e,[$]:t}),isReference:e=>e&&void 0!==e[S],href:e=>e[S],value:e=>e[$]};const{jsonTypeOf:x}=f,T=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),P=e=>A.isReference(e.value)?A.value(e.value):e.value,I=t(((e,t)=>x(P(e),t))),k=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:P(t)[e]}),V=t(((e,t)=>P(t).map(((r,n,o,a)=>e(k(n,t),n,o,a))))),R=t(((e,t)=>P(t).map(((e,r,n,o)=>k(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=t(((e,t,r)=>P(r).reduce(((t,n,o)=>e(t,k(o,r),o)),t))),U=t(((e,t)=>P(t).every(((r,n,o,a)=>e(k(n,t),n,o,a))))),z=t(((e,t)=>P(t).some(((r,n,o,a)=>e(k(n,t),n,o,a)))));var K={nil:T,cons:(e,t="")=>Object.freeze({...T,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:P,has:(e,t)=>e in P(t),typeOf:I,step:k,entries:e=>Object.keys(P(e)).map((t=>[t,k(t,e)])),keys:e=>Object.keys(P(e)),map:V,filter:R,reduce:C,every:U,some:z,length:e=>P(e).length},L=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,q=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,D=/\\([\u000b\u0020-\u00ff])/g,N=/([\\"])/g,J=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function B(e){var t=String(e);if(_.test(t))return t;if(t.length>0&&!q.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(N,"\\$1")+'"'}function F(e){this.parameters=Object.create(null),this.type=e}var W={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!J.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!_.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+B(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!J.test(n))throw new TypeError("invalid media type");var o=new F(n.toLowerCase());if(-1!==r){var a,i,s;for(L.lastIndex=r;i=L.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(D,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Z=async e=>Object.entries(await e),M=t((async(e,t)=>(await t).map(e))),G=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),H=t((async(e,t,r={})=>G((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),Q=t((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).some((e=>e))})),X=t((async(e,t)=>{const r=await M(e,t);return(await Promise.all(r)).every((e=>e))})),Y=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ee={entries:Z,map:M,filter:H,reduce:G,some:Q,every:X,pipeline:Y,all:e=>Promise.all(e),allValues:e=>Y([Z,G((async(e,[t,r])=>(e[t]=await r,e)),{})],e)};ee.entries,ee.map,ee.filter,ee.reduce,ee.some,ee.every,ee.pipeline,ee.all,ee.allValues;var te=fetch;const{jsonTypeOf:re,splitUrl:ne,safeResolveUrl:oe,pathRelative:ae}=f,ie={},se={},ce=(e,t)=>{const r=e in se?se[e]:e;if(r in ie)return ie[r][t]},le={},ue={},fe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ne(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ce(n,"baseToken"),a=ce(n,"anchorToken"),i=ne(t)[0];if(!i&&!ne(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=oe(i,e[o]||""),[c,l]=ne(s);delete e[o],l&&o===a&&(e[a]=a!==o?encodeURI(l):`#${encodeURI(l)}`),i&&(ue[i]=c);const u={},f=ce(n,"recursiveAnchorToken");let d;!0===e[f]&&(u[""]=`${c}#`,e[a]="",delete e[f]);const p=ce(n,"vocabularyToken");re(e[p],"object")?(se[c]=n,d=e[p],delete e[p]):(se[c]=n,d={[n]:!0});const h={"":""};return le[c]={id:c,schemaVersion:n,schema:de(e,c,n,j.nil,h,u),anchors:h,dynamicAnchors:u,vocabulary:d,validated:!1},c},de=(e,t,r,n,o,a)=>{if(re(e,"object")){const i="string"==typeof e.$schema?ne(e.$schema)[0]:r,s=ce(i,"embeddedToken"),c=ce(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=oe(t,e[s]);return e[s]=n,fe(e,n,r),A.cons(e[s],e)}const l=ce(r,"anchorToken"),u=ce(r,"dynamicAnchorToken");"string"==typeof e[u]&&(a[e[u]]=`${t}#${encodeURI(n)}`,o[e[u]]=n,delete e[u]);const f=ce(r,"embeddedToken");if("string"==typeof e[l]){const t=l!==f?e[l]:e[l].slice(1);o[t]=n,delete e[l]}const d=ce(r,"jrefToken");if("string"==typeof e[d])return A.cons(e[d],e);for(const i in e)e[i]=de(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>de(e,t,r,j.append(i,n),o,a))):e},pe=e=>le[ue[e]]||le[e],he=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),ye=async(e,t=he)=>{const r=oe(ve(t),e),[n,o]=ne(r);if(!(e=>e in le||e in ue)(n)){const e=await te(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${n}`);if(e.headers.has("content-type")){const t=W.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}fe(await e.json(),n)}const a=pe(n),i="/"!==o[0]?me(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return be(s)},be=e=>A.isReference(e.value)?ye(A.href(e.value),e):e,me=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ve=e=>`${e.id}#${encodeURI(e.pointer)}`,ge=e=>A.isReference(e.value)?A.value(e.value):e.value,we=(e,t)=>{const r=pe(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:ge(t)[e],validated:r.validated});return be(n)},Oe=t(((e,t)=>ee.pipeline([ge,ee.map((async(r,n)=>e(await we(n,t),n))),ee.all],t))),Ee={parentId:"",parentDialect:"",includeEmbedded:!0},je=(e,t)=>{if(t.startsWith("file://")){const r=e.slice(7,e.lastIndexOf("/"));return""===e?"":ae(r,t.slice(7))}return t};var $e={setConfig:(e,t,r)=>{ie[e]||(ie[e]={}),ie[e][t]=r},getConfig:ce,add:fe,get:ye,markValidated:e=>{le[e].validated=!0},uri:ve,value:ge,getAnchorPointer:me,typeOf:(e,t)=>re(ge(e),t),has:(e,t)=>e in ge(t),step:we,keys:e=>Object.keys(ge(e)),entries:e=>ee.pipeline([ge,Object.keys,ee.map((async t=>[t,await we(t,e)])),ee.all],e),map:Oe,length:e=>ge(e).length,toSchema:(e,t={})=>{const r={...Ee,...t},n=JSON.parse(JSON.stringify(e.schema,((t,n)=>{if(!A.isReference(n))return n;const o=A.value(n),a=o.$schema||e.schemaVersion,i=ce(a,"embeddedToken");return!r.includeEmbedded&&i in o?void 0:A.value(n)}))),o=ce(e.schemaVersion,"dynamicAnchorToken");Object.entries(e.dynamicAnchors).forEach((([e,t])=>{const r=ne(t)[1];j.assign(r,n,{[o]:e,...j.get(r,n)})}));const a=ce(e.schemaVersion,"anchorToken");Object.entries(e.anchors).filter((([e])=>""!==e)).forEach((([e,t])=>{j.assign(t,n,{[a]:e,...j.get(t,n)})}));const i=ce(e.schemaVersion,"baseToken"),s=je(r.parentId,e.id),c=r.parentDialect===e.schemaVersion?"":e.schemaVersion;return{...s&&{[i]:s},...c&&{$schema:c},...n}}};$e.setConfig,$e.getConfig,$e.add,$e.get,$e.markValidated,$e.uri,$e.value,$e.getAnchorPointer,$e.typeOf,$e.has,$e.step,$e.keys,$e.entries,$e.map,$e.length,$e.toSchema;class Se extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=Se;const{splitUrl:xe}=f,Te="FLAG",Pe="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Re=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ue=t((({ast:e,schemaUri:t},r,o=Te)=>{if(![Te,Pe,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);const a=[],i=n.subscribe("result",ze(o,a));return Be(t,r,e,{}),n.unsubscribe(i),a[0]})),ze=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Pe&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ke={},Le=e=>Ke[e],qe=e=>e in Ke,_e={},De={},Ne=async(e,t)=>{if(e=await Je(e),!qe(`${e.schemaVersion}#validate`)){const t=await $e.get(e.schemaVersion);($e.getConfig(t.id,"mandatoryVocabularies")||[]).forEach((e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)})),Object.entries(t.vocabulary).forEach((([e,r])=>{if(e in _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Ke[e]={collectEvaluatedItems:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&new Set,collectEvaluatedProperties:(e,r,n,o,a)=>t.interpret(e,r,n,o,a)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error(`Missing required vocabulary: ${e}`)}))}if(Re&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in De)){const t=await $e.get(e.schemaVersion),r=await Ce(t);De[t.id]=Ue(r)}const t=K.cons(e.schema,e.id),r=De[e.schemaVersion](t,Ve);if(!r.valid)throw new Ae(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),Le(`${e.schemaVersion}#validate`).compile(e,t)},Je=async e=>$e.typeOf(e,"string")?Je(await $e.get($e.value(e),e)):e,Be=(e,t,r,n)=>{const o=Fe(e,r),a=xe(e)[0];return Le(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error(`No schema found at ${e}`);return t[e][0]};var We={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t)=>Ue(n,K.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ue,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Re=e},FLAG:Te,BASIC:Pe,DETAILED:Ie,VERBOSE:ke,add:(e,t="",r="")=>{const n=$e.add(e,t,r);delete De[n]},getKeyword:Le,hasKeyword:qe,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Fe(e,r);return Le(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Fe(e,r);return Le(a).collectEvaluatedItems(e,t,r,n,o)}};var Ze={compile:e=>$e.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);if(!["object","boolean"].includes(typeof n))throw Error(`No schema found at '${$e.uri(e)}'`);t[r]=[`${e.schemaVersion}#validate`,$e.uri(e),"boolean"==typeof n?n:await ee.pipeline([$e.entries,ee.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ee.filter((([t])=>We.hasKeyword(t)&&t!==`${e.schemaVersion}#validate`)),ee.map((async([r,n])=>{const o=await We.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),ee.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=We.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:K.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:K.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&We.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&We.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={metaData:Ze,validate:Me},He={Core:We,Schema:$e,Instance:K,Reference:A,Keywords:Ge,InvalidSchemaError:Ae},Qe=He.Core,Xe=He.Schema,Ye=He.Instance,et=He.Reference,tt=He.Keywords,rt=He.InvalidSchemaError;e.Core=Qe,e.Instance=Ye,e.InvalidSchemaError=rt,e.Keywords=tt,e.Reference=et,e.Schema=Xe,e.default=He,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
export type JsonType = "null" | "boolean" | "object" | "array" | "number" | "integer" | "string"; | ||
export const pathRelative: (from: string, to: string) => string; |
@@ -39,2 +39,65 @@ const resolveUrl = require("url-resolve-browser"); | ||
module.exports = { jsonTypeOf, splitUrl, safeResolveUrl }; | ||
const CHAR_BACKWARD_SLASH = 47; | ||
const pathRelative = (from, to) => { | ||
if (from === to) { | ||
return ""; | ||
} | ||
let toStart = 1; | ||
const fromLen = from.length - 1; | ||
const toLen = to.length - toStart; | ||
// Compare paths to find the longest common path from root | ||
const length = fromLen < toLen ? fromLen : toLen; | ||
let lastCommonSep = -1; | ||
let i = 0; | ||
for (; i < length; i++) { | ||
const fromCode = from.charCodeAt(i + 1); | ||
if (fromCode !== to.charCodeAt(toStart + i)) { | ||
break; | ||
} else if (fromCode === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} | ||
} | ||
if (toLen > length) { | ||
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) { | ||
return to.slice(toStart + i + 1); | ||
} | ||
if (i === 0) { | ||
return to.slice(toStart + i); | ||
} | ||
} | ||
if (fromLen > length) { | ||
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) { | ||
lastCommonSep = i; | ||
} else if (length === 0) { | ||
lastCommonSep = 0; | ||
} | ||
} | ||
let out = ""; | ||
// Generate the relative path based on the path difference between `to` and `from` | ||
for (i = lastCommonSep + 2; i <= from.length; ++i) { | ||
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) { | ||
out += out.length === 0 ? ".." : "/.."; | ||
} | ||
} | ||
toStart += lastCommonSep; | ||
// Lastly, append the rest of the destination (`to`) path that comes after | ||
// the common path parts | ||
if (out.length > 0) { | ||
return `${out}${to.slice(toStart, to.length)}`; | ||
} | ||
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) { | ||
++toStart; | ||
} | ||
return to.slice(toStart, to.length); | ||
}; | ||
module.exports = { jsonTypeOf, splitUrl, safeResolveUrl, pathRelative }; |
@@ -5,3 +5,3 @@ const contentTypeParser = require("content-type"); | ||
const JsonPointer = require("@hyperjump/json-pointer"); | ||
const { jsonTypeOf, splitUrl, safeResolveUrl } = require("./common"); | ||
const { jsonTypeOf, splitUrl, safeResolveUrl, pathRelative } = require("./common"); | ||
const fetch = require("./fetch"); | ||
@@ -236,6 +236,69 @@ const Reference = require("./reference"); | ||
const toSchemaDefaultOptions = { | ||
parentId: "", | ||
parentDialect: "", | ||
includeEmbedded: true | ||
}; | ||
const toSchema = (schemaDoc, options = {}) => { | ||
const fullOptions = { ...toSchemaDefaultOptions, ...options }; | ||
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => { | ||
if (!Reference.isReference(value)) { | ||
return value; | ||
} | ||
const refValue = Reference.value(value); | ||
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion; | ||
const embeddedToken = getConfig(embeddedDialect, "embeddedToken"); | ||
if (!fullOptions.includeEmbedded && embeddedToken in refValue) { | ||
return; | ||
} else { | ||
return Reference.value(value); | ||
} | ||
})); | ||
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken"); | ||
Object.entries(schemaDoc.dynamicAnchors) | ||
.forEach(([anchor, uri]) => { | ||
const pointer = splitUrl(uri)[1]; | ||
JsonPointer.assign(pointer, schema, { | ||
[dynamicAnchorToken]: anchor, | ||
...JsonPointer.get(pointer, schema) | ||
}); | ||
}); | ||
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken"); | ||
Object.entries(schemaDoc.anchors) | ||
.filter(([anchor]) => anchor !== "") | ||
.forEach(([anchor, pointer]) => { | ||
JsonPointer.assign(pointer, schema, { | ||
[anchorToken]: anchor, | ||
...JsonPointer.get(pointer, schema) | ||
}); | ||
}); | ||
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken"); | ||
const id = relativeUri(fullOptions.parentId, schemaDoc.id); | ||
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion; | ||
return { | ||
...(id && { [baseToken]: id }), | ||
...(dialect && { $schema: dialect }), | ||
...schema | ||
}; | ||
}; | ||
const relativeUri = (from, to) => { | ||
if (to.startsWith("file://")) { | ||
const pathToSchema = from.slice(7, from.lastIndexOf("/")); | ||
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7)); | ||
} else { | ||
return to; | ||
} | ||
}; | ||
module.exports = { | ||
setConfig, getConfig, | ||
add, get, markValidated, | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length | ||
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length, | ||
toSchema | ||
}; |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.23.2", | ||
"version": "0.23.3", | ||
"description": "A framework for building JSON Schema tools", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -88,3 +88,14 @@ # Hyperjump - JSON Schema Core | ||
Similar to `Array.prototype.length`. | ||
* **Schema.toSchema**: (doc: SDoc, options: ToSchemaOptions) => object | ||
Get a raw schema from a Schema Document. | ||
* **ToSchemaOptions**: object | ||
* parentId: string (default: "") -- `file://` URIs will be generated | ||
relative to this path. | ||
* parentDialect: string (default: "") -- If the dialect of the schema | ||
* matches this value, the `$schema` keyword will be omitted. | ||
* includeEmbedded: boolean (default: true) -- If false, embedded schemas | ||
will be unbundled from the schema. | ||
### Schema Identification | ||
@@ -91,0 +102,0 @@ JSC requires that all schemas are identified by at least one URI. There are two |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1794836
10781
754