z-schema 9.0.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +123 -191
  2. package/cjs/index.d.ts +33 -9
  3. package/cjs/index.js +4799 -3984
  4. package/dist/errors.js +5 -0
  5. package/dist/format-validators.js +65 -0
  6. package/dist/json-schema-versions.js +5 -0
  7. package/dist/json-schema.js +11 -4
  8. package/dist/json-validation.js +151 -10
  9. package/dist/report.js +2 -3
  10. package/dist/schema-cache.js +23 -2
  11. package/dist/schema-compiler.js +25 -10
  12. package/dist/schema-validator.js +66 -45
  13. package/dist/schemas/draft-06-hyper-schema.json +132 -0
  14. package/dist/schemas/draft-06-links.json +43 -0
  15. package/dist/schemas/draft-06-schema.json +155 -0
  16. package/dist/types/errors.d.ts +4 -0
  17. package/dist/types/index.d.ts +2 -1
  18. package/dist/types/json-schema-versions.d.ts +23 -0
  19. package/dist/types/json-schema.d.ts +5 -9
  20. package/dist/types/json-validation.d.ts +3 -3
  21. package/dist/types/report.d.ts +3 -3
  22. package/dist/types/schema-cache.d.ts +1 -1
  23. package/dist/types/schema-compiler.d.ts +1 -1
  24. package/dist/types/schema-validator.d.ts +1 -1
  25. package/dist/types/utils/what-is.d.ts +1 -0
  26. package/dist/types/z-schema-base.d.ts +1 -1
  27. package/dist/types/z-schema-options.d.ts +1 -1
  28. package/dist/types/z-schema-reader.d.ts +1 -1
  29. package/dist/types/z-schema-versions.d.ts +1 -0
  30. package/dist/types/z-schema.d.ts +10 -1
  31. package/dist/utils/schema-regex.js +4 -3
  32. package/dist/utils/what-is.js +4 -1
  33. package/dist/z-schema-base.js +4 -5
  34. package/dist/z-schema-options.js +3 -1
  35. package/dist/z-schema-versions.js +27 -0
  36. package/dist/z-schema.js +21 -7
  37. package/package.json +2 -2
  38. package/src/errors.ts +6 -0
  39. package/src/format-validators.ts +65 -0
  40. package/src/index.ts +2 -1
  41. package/src/json-schema-versions.ts +34 -0
  42. package/src/json-schema.ts +22 -16
  43. package/src/json-validation.ts +183 -13
  44. package/src/report.ts +5 -6
  45. package/src/schema-cache.ts +25 -3
  46. package/src/schema-compiler.ts +25 -11
  47. package/src/schema-validator.ts +128 -62
  48. package/src/schemas/draft-06-hyper-schema.json +133 -0
  49. package/src/schemas/draft-06-links.json +43 -0
  50. package/src/schemas/draft-06-schema.json +155 -0
  51. package/src/utils/schema-regex.ts +5 -3
  52. package/src/utils/what-is.ts +5 -1
  53. package/src/z-schema-base.ts +5 -6
  54. package/src/z-schema-options.ts +3 -2
  55. package/src/z-schema-reader.ts +1 -1
  56. package/src/z-schema-versions.ts +38 -0
  57. package/src/z-schema.ts +27 -11
  58. package/umd/ZSchema.js +5100 -4285
  59. package/umd/ZSchema.min.js +1 -1
@@ -1 +1 @@
1
- !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).ZSchema={})}(this,function(e){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,i={exports:{}},o={exports:{}};function n(){return r||(r=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(null==e)throw new TypeError("Expected a string but received a ".concat(e));if("String"!==e.constructor.name)throw new TypeError("Expected a string but received a ".concat(e.constructor.name))},e.exports=t.default,e.exports.default=t.default}(o,o.exports)),o.exports}var s,a={exports:{}};function l(){return s||(s=1,function(e,t){function r(e){return"[object RegExp]"===Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){for(var i=0;i<t.length;i++){var o=t[i];if(e===o||r(o)&&o.test(e))return!0}return!1},e.exports=t.default,e.exports.default=t.default}(a,a.exports)),a.exports}var c,d={exports:{}};function f(){return c||(c=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r,n;(0,i.default)(e),"object"===o(t)?(r=t.min||0,n=t.max):(r=arguments[1],n=arguments[2]);var s=encodeURI(e).split(/%..|./).length-1;return s>=r&&(void 0===n||s<=n)};var r,i=(r=n())&&r.__esModule?r:{default:r};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}e.exports=t.default,e.exports.default=t.default}(d,d.exports)),d.exports}var p,u,h={exports:{}},m={exports:{}};function E(){return p||(p=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e},e.exports=t.default,e.exports.default=t.default}(m,m.exports)),m.exports}function y(){return u||(u=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){(0,r.default)(e),(t=(0,i.default)(t,s)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));!0===t.allow_wildcard&&0===e.indexOf("*.")&&(e=e.substring(2));var o=e.split("."),n=o[o.length-1];if(t.require_tld){if(o.length<2)return!1;if(!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(n))return!1;if(/\s/.test(n))return!1}if(!t.allow_numeric_tld&&/^\d+$/.test(n))return!1;return o.every(function(e){return!(e.length>63&&!t.ignore_max_length)&&(!!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(e)&&(!/[\uff01-\uff5e]/.test(e)&&(!/^-|-$/.test(e)&&!(!t.allow_underscores&&/_/.test(e)))))})};var r=o(n()),i=o(E());function o(e){return e&&e.__esModule?e:{default:e}}var s={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};e.exports=t.default,e.exports.default=t.default}(h,h.exports)),h.exports}var _,g,v={exports:{}};function O(){return _||(_=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,i.default)(t);var n=("object"===o(r)?r.version:arguments[1])||"";if(!n)return e(t,{version:4})||e(t,{version:6});if("4"===n.toString())return l.test(t);if("6"===n.toString())return d.test(t);return!1};var r,i=(r=n())&&r.__esModule?r:{default:r};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var s="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",a="(".concat(s,"[.]){3}").concat(s),l=new RegExp("^".concat(a,"$")),c="(?:[0-9a-fA-F]{1,4})",d=new RegExp("^("+"(?:".concat(c,":){7}(?:").concat(c,"|:)|")+"(?:".concat(c,":){6}(?:").concat(a,"|:").concat(c,"|:)|")+"(?:".concat(c,":){5}(?::").concat(a,"|(:").concat(c,"){1,2}|:)|")+"(?:".concat(c,":){4}(?:(:").concat(c,"){0,1}:").concat(a,"|(:").concat(c,"){1,3}|:)|")+"(?:".concat(c,":){3}(?:(:").concat(c,"){0,2}:").concat(a,"|(:").concat(c,"){1,4}|:)|")+"(?:".concat(c,":){2}(?:(:").concat(c,"){0,3}:").concat(a,"|(:").concat(c,"){1,5}|:)|")+"(?:".concat(c,":){1}(?:(:").concat(c,"){0,4}:").concat(a,"|(:").concat(c,"){1,6}|:)|")+"(?::((?::".concat(c,"){0,5}:").concat(a,"|(?::").concat(c,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");e.exports=t.default,e.exports.default=t.default}(v,v.exports)),v.exports}function A(){return g||(g=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if((0,r.default)(e),(t=(0,c.default)(t,p)).require_display_name||t.allow_display_name){var n=e.match(u);if(n){var l=n[1];if(e=e.replace(l,"").replace(/(^<|>$)/g,""),l.endsWith(" ")&&(l=l.slice(0,-1)),!function(e){var t=e.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;if(/[\.";<>]/.test(t)){if(t===e)return!1;if(!(t.split('"').length===t.split('\\"').length))return!1}return!0}(l))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&e.length>A)return!1;var d=e.split("@"),f=d.pop(),E=f.toLowerCase();if(t.host_blacklist.length>0&&(0,i.default)(E,t.host_blacklist))return!1;if(t.host_whitelist.length>0&&!(0,i.default)(E,t.host_whitelist))return!1;var y=d.join("@");if(t.domain_specific_validation&&("gmail.com"===E||"googlemail.com"===E)){var O=(y=y.toLowerCase()).split("+")[0];if(!(0,o.default)(O.replace(/\./g,""),{min:6,max:30}))return!1;for(var T=O.split("."),x=0;x<T.length;x++)if(!m.test(T[x]))return!1}if(!(!1!==t.ignore_max_length||(0,o.default)(y,{max:64})&&(0,o.default)(f,{max:254})))return!1;if(!(0,s.default)(f,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,a.default)(f)){if(!f.startsWith("[")||!f.endsWith("]"))return!1;var I=f.slice(1,-1);if(0===I.length||!(0,a.default)(I))return!1}}if(t.blacklisted_chars&&-1!==y.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g")))return!1;if('"'===y[0]&&'"'===y[y.length-1])return y=y.slice(1,y.length-1),t.allow_utf8_local_part?v.test(y):_.test(y);for(var R=t.allow_utf8_local_part?g:h,P=y.split("."),b=0;b<P.length;b++)if(!R.test(P[b]))return!1;return!0};var r=d(n()),i=d(l()),o=d(f()),s=d(y()),a=d(O()),c=d(E());function d(e){return e&&e.__esModule?e:{default:e}}var p={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},u=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,h=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,m=/^[a-z\d]+$/,_=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,g=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,v=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,A=254;e.exports=t.default,e.exports.default=t.default}(i,i.exports)),i.exports}var T,x,I=t(A()),R=t(O()),P={exports:{}},b={exports:{}};function S(){return T||(T=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=function(e,t){return-1!==e.indexOf(t)},e.exports=t.default,e.exports.default=t.default}(b,b.exports)),b.exports}function D(){return x||(x=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if((0,r.default)(e),!e||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;if((t=(0,c.default)(t,p)).validate_length&&e.length>t.max_allowed_length)return!1;if(!t.allow_fragments&&(0,o.default)(e,"#"))return!1;if(!t.allow_query_components&&((0,o.default)(e,"?")||(0,o.default)(e,"&")))return!1;var n,l,d,h,m,E,y,_;y=e.split("#"),e=y.shift(),y=e.split("?");var g=(e=y.shift()).match(/^([a-z][a-z0-9+\-.]*):/i),v=!1,O=function(r){return v=!0,n=r.toLowerCase(),(!t.require_valid_protocol||-1!==t.protocols.indexOf(n))&&e.substring(g[0].length)};if(g){var A=g[1],T=e.substring(g[0].length);if("//"===T.slice(0,2)){if(!1===(e=O(A)))return!1}else{var x=T.indexOf("/"),I=-1===x?T:T.substring(0,x),R=I.indexOf("@");if(-1!==R){var P=I.substring(0,R),b=/^[a-zA-Z0-9\-_.%:]*$/.test(P),S=/%[0-9a-fA-F]{2}/.test(P);if(b&&!S){if(t.require_protocol)return!1}else if(!1===(e=O(A)))return!1}else{if(/^[0-9]/.test(T)){if(t.require_protocol)return!1}else if(!1===(e=O(A)))return!1}}}else if(t.require_protocol)return!1;if("//"===e.slice(0,2)){if(!v&&!t.allow_protocol_relative_urls)return!1;e=e.slice(2)}if(""===e)return!1;if(y=e.split("/"),""===(e=y.shift())&&!t.require_host)return!0;if((y=e.split("@")).length>1){if(t.disallow_auth)return!1;if(""===y[0])return!1;if((l=y.shift()).indexOf(":")>=0&&l.split(":").length>2)return!1;var D=l.split(":"),M=(Y=2,function(e){if(Array.isArray(e))return e}(w=D)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,o,n,s,a=[],l=!0,c=!1;try{if(n=(r=r.call(e)).next,0===t);else for(;!(l=(i=n.call(r)).done)&&(a.push(i.value),a.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}(w,Y)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(w,Y)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),N=M[0],C=M[1];if(""===N&&""===C)return!1}var w,Y;h=y.join("@"),E=null,_=null;var $=h.match(u);$?(d="",_=$[1],E=$[2]||null):(d=(y=h.split(":")).shift(),y.length&&(E=y.join(":")));if(null!==E&&E.length>0){if(m=parseInt(E,10),!/^[0-9]+$/.test(E)||m<=0||m>65535)return!1}else if(t.require_port)return!1;if(t.host_whitelist)return(0,i.default)(d,t.host_whitelist);if(""===d&&!t.require_host)return!0;if(!((0,a.default)(d)||(0,s.default)(d,t)||_&&(0,a.default)(_,6)))return!1;if(d=d||_,t.host_blacklist&&(0,i.default)(d,t.host_blacklist))return!1;return!0};var r=d(n()),i=d(l()),o=d(S()),s=d(y()),a=d(O()),c=d(E());function d(e){return e&&e.__esModule?e:{default:e}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}var p={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0,max_allowed_length:2084},u=/^\[([^\]]+)\](?::([0-9]+))?$/;e.exports=t.default,e.exports.default=t.default}(P,P.exports)),P.exports}var M=t(D());const N=e=>"object"==typeof e?null===e?"null":Array.isArray(e)?"array":"object":"number"==typeof e?Number.isFinite(e)?e%1==0?"integer":"number":Number.isNaN(e)?"not-a-number":"unknown-number":typeof e;function C(e){return"object"===N(e)}const w=(e,t,r)=>{const i=(r=r||{}).caseInsensitiveComparison||!1;if(e===t)return!0;if(!0===i&&"string"==typeof e&&"string"==typeof t&&e.toUpperCase()===t.toUpperCase())return!0;let o,n;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(n=e.length,o=0;o<n;o++)if(!w(e[o],t[o],{caseInsensitiveComparison:i}))return!1;return!0}if(C(e)&&C(t)){const r=$(e),s=$(t);if(!w(r,s,{caseInsensitiveComparison:i}))return!1;for(n=r.length,o=0;o<n;o++)if(!w(e[r[o]],t[r[o]],{caseInsensitiveComparison:i}))return!1;return!0}return!1},Y=e=>decodeURIComponent(e).replace(/~[0-1]/g,e=>"~1"===e?"/":"~"),$=e=>Object.keys(e).sort(),U=(e,t)=>("string"==typeof t&&(t=t.split(".")),t.reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)),F=e=>{if("string"!=typeof e)return!0;const t=/^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/.test(e);if(t){if(e.length>255)return!1;const t=e.split(".");for(let e=0;e<t.length;e++)if(t[e].length>63)return!1}return t},L=e=>"string"!=typeof e||M.default(e),j={date:e=>{if("string"!=typeof e)return!0;const t=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(e);return null!==t&&!(t[2]<"01"||t[2]>"12"||t[3]<"01"||t[3]>"31")},"date-time":e=>{if("string"!=typeof e)return!0;const t=e.toLowerCase().split("t");if(2!==t.length)return!1;const r=t[0],i=t[1],o=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(r);if(null===o)return!1;const n=parseInt(o[1],10),s=parseInt(o[2],10),a=parseInt(o[3],10);if(s<1||s>12||a<1||a>31)return!1;const l=new Date(n,s-1,a);if(l.getFullYear()!==n||l.getMonth()!==s-1||l.getDate()!==a)return!1;const c=/^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$/.exec(i);if(null===c)return!1;const d=parseInt(c[1],10),f=parseInt(c[2],10),p=parseInt(c[3],10);if(d>23||f>59||p>60)return!1;let u=d;if("z"!==c[5]){const e=c[5],t=/^([+-])([0-9]{2}):([0-9]{2})$/.exec(e);if(null===t)return!1;const r=t[1],i=parseInt(t[2],10),o=parseInt(t[3],10);if(i>23||o>59)return!1;u="+"===r?d-i:d+i,u=(u%24+24)%24}return 60!==p||23===u&&59===f},email:e=>"string"!=typeof e||I.default(e,{require_tld:!0}),hostname:F,"host-name":F,ipv4:e=>"string"!=typeof e||R.default(e,4),ipv6:e=>"string"!=typeof e||!e.includes("%")&&R.default(e,6),regex:e=>{if("string"!=typeof e)return!1;try{return RegExp(e),!0}catch(e){return!1}},uri:function(e){if("string"!=typeof e)return!0;if(/[^\x00-\x7F]/.test(e))return!1;const t=e.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):\/\/([^/]*)/);if(t){const e=t[2],r=e.indexOf("@");if(r>0){const t=e.substring(0,r);if(t.includes("[")||t.includes("]"))return!1}}return/^[a-zA-Z][a-zA-Z0-9+.-]*:[^"\\<>^{}^`| ]*$/.test(e)},"strict-uri":L},k={};function K(e){const t={...j,...k,...e};return $(t).filter(e=>null!=t[e])}const W={"draft-04":"http://json-schema.org/draft-04/schema#"},q=(e,t)=>{if("object"!=typeof e||null===e)return;if(!t)return e;if(e.id&&(e.id===t||"#"===e.id[0]&&e.id.substring(1)===t))return e;let r,i;if(Array.isArray(e))for(r=e.length;r--;)if(i=q(e[r],t),i)return i;if(C(e)){const o=Object.keys(e);for(r=o.length;r--;){const n=o[r];if(0!==n.indexOf("__$")&&(i=q(e[n],t),i))return i}}},X={INVALID_TYPE:"Expected type {0} but found type {1}",INVALID_FORMAT:"Object didn't pass validation for format {0}: {1}",ENUM_MISMATCH:"No enum match for: {0}",ENUM_CASE_MISMATCH:"Enum does not match case for: {0}",ANY_OF_MISSING:"Data does not match any schemas from 'anyOf'",ONE_OF_MISSING:"Data does not match any schemas from 'oneOf'",ONE_OF_MULTIPLE:"Data is valid against more than one schema from 'oneOf'",NOT_PASSED:"Data matches schema from 'not'",ARRAY_LENGTH_SHORT:"Array is too short ({0}), minimum {1}",ARRAY_LENGTH_LONG:"Array is too long ({0}), maximum {1}",ARRAY_UNIQUE:"Array items are not unique (indexes {0} and {1})",ARRAY_ADDITIONAL_ITEMS:"Additional items not allowed",MULTIPLE_OF:"Value {0} is not a multiple of {1}",MINIMUM:"Value {0} is less than minimum {1}",MINIMUM_EXCLUSIVE:"Value {0} is equal or less than exclusive minimum {1}",MAXIMUM:"Value {0} is greater than maximum {1}",MAXIMUM_EXCLUSIVE:"Value {0} is equal or greater than exclusive maximum {1}",OBJECT_PROPERTIES_MINIMUM:"Too few properties defined ({0}), minimum {1}",OBJECT_PROPERTIES_MAXIMUM:"Too many properties defined ({0}), maximum {1}",OBJECT_MISSING_REQUIRED_PROPERTY:"Missing required property: {0}",OBJECT_ADDITIONAL_PROPERTIES:"Additional properties not allowed: {0}",OBJECT_DEPENDENCY_KEY:"Dependency failed - key must exist: {0} (due to key: {1})",MIN_LENGTH:"String is too short ({0} chars), minimum {1}",MAX_LENGTH:"String is too long ({0} chars), maximum {1}",PATTERN:"String does not match pattern {0}: {1}",KEYWORD_TYPE_EXPECTED:"Keyword '{0}' is expected to be of type '{1}'",KEYWORD_UNDEFINED_STRICT:"Keyword '{0}' must be defined in strict mode",KEYWORD_UNEXPECTED:"Keyword '{0}' is not expected to appear in the schema",KEYWORD_MUST_BE:"Keyword '{0}' must be {1}",KEYWORD_DEPENDENCY:"Keyword '{0}' requires keyword '{1}'",KEYWORD_PATTERN:"Keyword '{0}' is not a valid RegExp pattern: {1}",KEYWORD_VALUE_TYPE:"Each element of keyword '{0}' array must be a '{1}'",UNKNOWN_FORMAT:"There is no validation function for format '{0}'",CUSTOM_MODE_FORCE_PROPERTIES:"{0} must define at least one property if present",REF_UNRESOLVED:"Reference has not been resolved during compilation: {0}",UNRESOLVABLE_REFERENCE:"Reference could not be resolved: {0}",SCHEMA_NOT_REACHABLE:"Validator was not able to read schema with uri: {0}",SCHEMA_TYPE_EXPECTED:"Schema is expected to be of type 'object'",SCHEMA_NOT_AN_OBJECT:"Schema is not an object: {0}",ASYNC_TIMEOUT:"{0} asynchronous task(s) have timed out after {1} ms",PARENT_SCHEMA_VALIDATION_FAILED:"Schema failed to validate against its parent schema, see inner errors for details.",REMOTE_NOT_VALID:"Remote reference didn't compile successfully: {0}"};class B extends Error{name;details;constructor(e,t){super(e),this.name="z-schema validation error",this.details=t}}function V({message:e,details:t}){return new B(e||"",t)}const H=Symbol.for("z-schema/json"),J=Symbol.for("z-schema/schema"),z=e=>{const t=e.indexOf("#");return-1===t?e:e.slice(0,t)},G=e=>/^(https?|file):\/\//.test(e);class Z{asyncTasks=[];commonErrorMessage;errors=[];json;path=[];schemaPath=[];rootSchema;parentReport;options;reportOptions;validateOptions={};constructor(e,t,r){this.parentReport=e instanceof Z?e:void 0,this.options=e instanceof Z?e.options:e||{},e instanceof Z?(this.reportOptions=t||{},this.validateOptions=r||e.validateOptions):(this.reportOptions={},this.validateOptions=t||{})}isValid(){if(this.asyncTasks.length>0)throw new Error("Async tasks pending, can't answer isValid");return 0===this.errors.length}addAsyncTask(e,t,r){this.asyncTasks.push([e,t,r])}getAncestor(e){if(this.parentReport)return this.parentReport.getSchemaId()===e?this.parentReport:this.parentReport.getAncestor(e)}processAsyncTasks(e,t){const r=e||2e3;let i=this.asyncTasks.length,o=i,n=!1;const s=()=>{setTimeout(()=>{const e=0===this.errors.length,r=e?void 0:V({details:this.errors});t(r,e)},0)},a=e=>t=>{n||(e(t),0===--i&&s())};if(0===i||this.errors.length>0&&this.options.breakOnFirstError)s();else{for(;o--;){const[e,t,r]=this.asyncTasks[o];e(...t,a(r))}setTimeout(()=>{i>0&&(n=!0,this.addError("ASYNC_TIMEOUT",[i,r]),t(V({details:this.errors}),!1))},r)}}getPath(e){let t=[];return this.parentReport&&(t=t.concat(this.parentReport.path)),t=t.concat(this.path),!0!==e?"#/"+t.map(function(e){return e=e.toString(),G(e)?"uri("+e+")":e.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/"):t}getSchemaPath(){let e=[];return this.parentReport&&(e=e.concat(this.parentReport.schemaPath)),e=e.concat(this.schemaPath),e}getSchemaId(){if(!this.rootSchema)return;let e=[];for(this.parentReport&&(e=e.concat(this.parentReport.path)),e=e.concat(this.path);e.length>0;){const t=U(this.rootSchema,e);if(t&&t.id)return t.id;e.pop()}return this.rootSchema.id}hasError(e,t){let r=this.errors.length;for(;r--;)if(this.errors[r].code===e){let e=!0,i=this.errors[r].params.length;for(;i--;)this.errors[r].params[i]!==t[i]&&(e=!1);if(e)return e}return!1}addError(e,t,r,i,o){if(!e)throw new Error("No errorCode passed into addError()");this.addCustomError(e,X[e],t,r,i,o)}getJson(){return this.json?this.json:this.parentReport?this.parentReport.getJson():void 0}addCustomError(e,t,r,i,o,n){if("number"==typeof this.reportOptions.maxErrors&&this.errors.length>=this.reportOptions.maxErrors)return;if(!t)throw new Error("No errorMessage known for code "+e);let s=(r=r||[]).length;for(;s--;){const e=N(r[s]),i="object"===e||"null"===e?JSON.stringify(r[s]):r[s];t=t.replace("{"+s+"}",i.toString())}const a={code:e,params:r,message:t,path:this.getPath(this.options.reportPathAsArray),schemaPath:this.getSchemaPath(),schemaId:this.getSchemaId(),keyword:n};if(a[J]=o,a[H]=this.getJson(),o&&"string"==typeof o?a.description=o:o&&"object"==typeof o&&(o.title&&(a.title=o.title),o.description&&(a.description=o.description)),null!=i){for(Array.isArray(i)||(i=[i]),a.inner=[],s=i.length;s--;){const e=i[s];let t=e.errors.length;for(;t--;)a.inner.push(e.errors[t])}0===a.inner.length&&(a.inner=void 0)}Array.isArray(this.validateOptions.excludeErrors)&&this.validateOptions.excludeErrors.includes(e)||this.errors.push(a)}}function Q(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ee(e,t,r,i){Q(e,r)&&Object.defineProperty(t,r,{value:i?i(e[r]):e[r],enumerable:!0,writable:!0,configurable:!0})}const te=e=>{if(null==e||"object"!=typeof e)return e;let t,r;if(Array.isArray(e))for(t=[],r=e.length;r--;)t[r]=e[r];else{t={};const r=Object.keys(e).sort();for(const i of r)ee(e,t,i)}return t},re=e=>{let t=0;const r=new Map,i=[],o=e=>{if("object"!=typeof e||null===e)return e;let n,s;const a=r.get(e);if(void 0!==a)return i[a];if(r.set(e,t++),Array.isArray(e))for(n=[],i.push(n),s=e.length;s--;)n[s]=o(e[s]);else{n={},i.push(n);const t=Object.keys(e).sort();for(const r of t)ee(e,n,r,o)}return n};return o(e)};class ie{validator;static global_cache={};cache={};constructor(e){this.validator=e}static cacheSchemaByUri(e,t){const r=z(e);r&&(this.global_cache[r]=t)}cacheSchemaByUri(e,t){const r=z(e);r&&(this.cache[r]=t)}removeFromCacheByUri(e){const t=z(e);t&&delete this.cache[t]}checkCacheForUri(e){const t=z(e);return!!t&&null!=this.cache[t]}getSchema(e,t){return Array.isArray(t)?t.map(t=>this.getSchema(e,t)):"string"==typeof t?this.getSchemaByUri(e,t):re(t)}fromCache(e){let t=this.cache[e];if(t)return this.cache[e];return t=ie.global_cache[e],t?(r=t,r.id??=e,re(r)):void 0;var r}getSchemaByUri(e,t,r){const i=z(t),o=(e=>{const t=e.indexOf("#");return-1===t?void 0:e.slice(t+1)})(t);let n=i?this.fromCache(i):r;if(n&&i){if(n!==r){let r;e.path.push(i);const o=n.id?e.getAncestor(n.id):void 0;if(o)r=o;else{r=new Z(e);const t=!n.id||!G(n.id);if(this.validator.sc.compileSchema(r,n,{noCache:t})){const e=this.validator.options;try{this.validator.options=n.__$validationOptions||this.validator.options,this.validator.sv.validateSchema(r,n)}finally{this.validator.options=e}}}const s=r.isValid();if(s||e.addError("REMOTE_NOT_VALID",[t],r),e.path.pop(),!s)return}}if(n&&o){const e=o.split("/");for(let t=0,r=e.length;n&&t<r;t++){const r=Y(e[t]);n=0===t?q(n,r):n[r]}}return n}}const oe=(e,t)=>{let r,i;const o=e.length;for(r=0;r<o;r++)for(i=r+1;i<o;i++)if(w(e[r],e[i]))return t&&t.push(r,i),!1;return!0};function ne(e){if(/\\[pP]{/.test(e))try{return{ok:!0,value:new RegExp(e,"u")}}catch(t){return{ok:!1,error:{pattern:e,message:t&&t.message?t.message:"Invalid regular expression"}}}else try{return{ok:!0,value:new RegExp(e)}}catch(t){return{ok:!1,error:{pattern:e,message:t&&t.message?t.message:"Invalid regular expression"}}}}function se(e){const t=[];let r=0;const i=e.length;let o,n;for(;r<i;)o=e.charCodeAt(r++),o>=55296&&o<=56319&&r<i?(n=e.charCodeAt(r++),56320==(64512&n)?t.push(((1023&o)<<10)+(1023&n)+65536):(t.push(o),r--)):t.push(o);return t}const ae=function(e,t){return e&&Array.isArray(e.includeErrors)&&e.includeErrors.length>0&&!t.some(function(t){return e.includeErrors.includes(t)})},le={id:()=>{},$ref:()=>{},$schema:()=>{},title:()=>{},description:()=>{},default:()=>{},multipleOf:function(e,t,r){if(ae(this.validateOptions,["MULTIPLE_OF"]))return;if("number"!=typeof r)return;const i=r/t.multipleOf;(!Number.isFinite(i)||Math.abs(i-Math.round(i))>=1e-10)&&e.addError("MULTIPLE_OF",[r,t.multipleOf],void 0,t,"multipleOf")},maximum:function(e,t,r){ae(this.validateOptions,["MAXIMUM","MAXIMUM_EXCLUSIVE"])||"number"==typeof r&&(!0!==t.exclusiveMaximum?r>t.maximum&&e.addError("MAXIMUM",[r,t.maximum],void 0,t,"maximum"):r>=t.maximum&&e.addError("MAXIMUM_EXCLUSIVE",[r,t.maximum],void 0,t,"maximum"))},exclusiveMaximum:function(){},minimum:function(e,t,r){ae(this.validateOptions,["MINIMUM","MINIMUM_EXCLUSIVE"])||"number"==typeof r&&(!0!==t.exclusiveMinimum?r<t.minimum&&e.addError("MINIMUM",[r,t.minimum],void 0,t,"minimum"):r<=t.minimum&&e.addError("MINIMUM_EXCLUSIVE",[r,t.minimum],void 0,t,"minimum"))},exclusiveMinimum:function(){},maxLength:function(e,t,r){ae(this.validateOptions,["MAX_LENGTH"])||"string"==typeof r&&se(r).length>t.maxLength&&e.addError("MAX_LENGTH",[r.length,t.maxLength],void 0,t,"maxLength")},minLength:function(e,t,r){ae(this.validateOptions,["MIN_LENGTH"])||"string"==typeof r&&se(r).length<t.minLength&&e.addError("MIN_LENGTH",[r.length,t.minLength],void 0,t,"minLength")},pattern:function(e,t,r){if(ae(this.validateOptions,["PATTERN"]))return;if("string"!=typeof r)return;const i=ne(t.pattern);i.ok?i.value.test(r)||e.addError("PATTERN",[t.pattern,r],void 0,t,"pattern"):e.addError("PATTERN",[t.pattern,r,i.error.message],void 0,t,"pattern")},additionalItems:function(e,t,r){ae(this.validateOptions,["ARRAY_ADDITIONAL_ITEMS"])||Array.isArray(r)&&!1===t.additionalItems&&Array.isArray(t.items)&&r.length>t.items.length&&e.addError("ARRAY_ADDITIONAL_ITEMS",void 0,void 0,t,"additionalItems")},items:function(){},maxItems:function(e,t,r){ae(this.validateOptions,["ARRAY_LENGTH_LONG"])||Array.isArray(r)&&r.length>t.maxItems&&e.addError("ARRAY_LENGTH_LONG",[r.length,t.maxItems],void 0,t,"maxItems")},minItems:function(e,t,r){ae(this.validateOptions,["ARRAY_LENGTH_SHORT"])||Array.isArray(r)&&r.length<t.minItems&&e.addError("ARRAY_LENGTH_SHORT",[r.length,t.minItems],void 0,t,"minItems")},uniqueItems:function(e,t,r){if(!ae(this.validateOptions,["ARRAY_UNIQUE"])&&Array.isArray(r)&&!0===t.uniqueItems){const i=[];!1===oe(r,i)&&e.addError("ARRAY_UNIQUE",i,void 0,t,"uniqueItems")}},maxProperties:function(e,t,r){if(ae(this.validateOptions,["OBJECT_PROPERTIES_MAXIMUM"]))return;if(!C(r))return;const i=Object.keys(r).length;i>t.maxProperties&&e.addError("OBJECT_PROPERTIES_MAXIMUM",[i,t.maxProperties],void 0,t,"maxProperties")},minProperties:function(e,t,r){if(ae(this.validateOptions,["OBJECT_PROPERTIES_MINIMUM"]))return;if(!C(r))return;const i=Object.keys(r).length;i<t.minProperties&&e.addError("OBJECT_PROPERTIES_MINIMUM",[i,t.minProperties],void 0,t,"minProperties")},required:function(e,t,r){if(ae(this.validateOptions,["OBJECT_MISSING_REQUIRED_PROPERTY"]))return;if(!C(r))return;let i=t.required.length;for(;i--;){const o=t.required[i];Q(r,o)||e.addError("OBJECT_MISSING_REQUIRED_PROPERTY",[o],void 0,t,"required")}},additionalProperties:function(e,t,r){if(void 0===t.properties&&void 0===t.patternProperties)return le.properties.call(this,e,t,r)},patternProperties:function(e,t,r){if(void 0===t.properties)return le.properties.call(this,e,t,r)},properties:function(e,t,r){if(ae(this.validateOptions,["OBJECT_ADDITIONAL_PROPERTIES"]))return;if(!C(r))return;const i=void 0!==t.properties?t.properties:{},o=void 0!==t.patternProperties?t.patternProperties:{};if(!1===t.additionalProperties){let n=Object.keys(r);const s=Object.keys(i),a=Object.keys(o);n=((e,t)=>{const r=[];let i=e.length;for(;i--;)-1===t.indexOf(e[i])&&r.push(e[i]);return r})(n,s);let l=a.length;for(;l--;){const e=RegExp(a[l]);let t=n.length;for(;t--;)!0===e.test(n[t])&&n.splice(t,1)}if(n.length>0){if(Array.isArray(this.options.assumeAdditional)){let e=this.options.assumeAdditional.length;if(e)for(;e--;){const t=n.indexOf(this.options.assumeAdditional[e]);-1!==t&&n.splice(t,1)}}let r=n.length;if(r)for(;r--;)e.addError("OBJECT_ADDITIONAL_PROPERTIES",[n[r]],void 0,t,"properties")}}},dependencies:function(e,t,r){if(ae(this.validateOptions,["OBJECT_DEPENDENCY_KEY"]))return;if(!C(r))return;const i=Object.keys(t.dependencies);let o=i.length;for(;o--;){const n=i[o];if(Q(r,n)){const i=t.dependencies[n];if(Array.isArray(i)){let o=i.length;for(;o--;){const s=i[o];Q(r,s)||e.addError("OBJECT_DEPENDENCY_KEY",[s,n],void 0,t,"dependencies")}}else fe.call(this,e,i,r)}}},enum:function(e,t,r){if(ae(this.validateOptions,["ENUM_CASE_MISMATCH","ENUM_MISMATCH"]))return;let i=!1,o=!1,n=t.enum.length;for(;n--;){if(w(r,t.enum[n])){i=!0;break}w(r,t.enum[n],{caseInsensitiveComparison:!0})&&(o=!0)}if(!1===i){const i=o&&this.options.enumCaseInsensitiveComparison?"ENUM_CASE_MISMATCH":"ENUM_MISMATCH";e.addError(i,[JSON.stringify(r)],void 0,t,"enum")}},type:function(e,t,r){if(ae(this.validateOptions,["INVALID_TYPE"]))return;const i=N(r);"string"==typeof t.type?i===t.type||"integer"===i&&"number"===t.type||e.addError("INVALID_TYPE",[t.type,i],void 0,t,"type"):-1!==t.type.indexOf(i)||"integer"===i&&-1!==t.type.indexOf("number")||e.addError("INVALID_TYPE",[JSON.stringify(t.type),i],void 0,t,"type")},allOf:function(e,t,r){let i=t.allOf.length;for(;i--;){const o=fe.call(this,e,t.allOf[i],r);if(this.options.breakOnFirstError&&!1===o)break}},anyOf:function(e,t,r){const i=[];let o=t.anyOf.length;for(;o--;){const n=new Z(e);i.push(n),fe.call(this,n,t.anyOf[o],r)}const n=e.asyncTasks.length;for(const t of i)e.asyncTasks.push(...t.asyncTasks);if(e.asyncTasks.length>n){const r=te(e.path);e.addAsyncTask(e=>{setTimeout(()=>e(null),0)},[],()=>{const o=e.path;e.path=r;let n=!1;for(const e of i)if(0===e.errors.length){n=!0;break}!1===n&&e.addError("ANY_OF_MISSING",void 0,i,t,"anyOf"),e.path=o})}else{let r=!1;for(const e of i)if(0===e.errors.length){r=!0;break}!1===r&&e.addError("ANY_OF_MISSING",void 0,i,t,"anyOf")}},oneOf:function(e,t,r){const i=[];let o=t.oneOf.length;for(;o--;){const n=new Z(e);i.push(n),fe.call(this,n,t.oneOf[o],r)}const n=e.asyncTasks.length;for(const t of i)e.asyncTasks.push(...t.asyncTasks);if(e.asyncTasks.length>n){const r=te(e.path);e.addAsyncTask(e=>{setTimeout(()=>e(null),0)},[],()=>{const o=e.path;e.path=r;let n=0;for(const e of i)0===e.errors.length&&n++;0===n?e.addError("ONE_OF_MISSING",void 0,i,t,"oneOf"):n>1&&e.addError("ONE_OF_MULTIPLE",void 0,void 0,t,"oneOf"),e.path=o})}else{let r=0;for(const e of i)0===e.errors.length&&r++;0===r?e.addError("ONE_OF_MISSING",void 0,i,t,"oneOf"):r>1&&e.addError("ONE_OF_MULTIPLE",void 0,void 0,t,"oneOf")}},not:function(e,t,r){const i=new Z(e);!0===fe.call(this,i,t.not,r)&&e.addError("NOT_PASSED",void 0,void 0,t,"not")},definitions:function(){},format:function(e,t,r){var i;const o=(i=this.options,{...j,...i?.strictUris?{uri:L}:{},...k,...i?.customFormats||{}})[t.format];if("function"==typeof o){if(ae(this.validateOptions,["INVALID_FORMAT"]))return;if(e.hasError("INVALID_TYPE",[t.type,N(r)]))return;if(2===o.length){const i=te(e.path);e.addAsyncTask(o,[r],function(o){if(!0!==o){const o=e.path;e.path=i,e.addError("INVALID_FORMAT",[t.format,JSON.stringify(r)],void 0,t,"format"),e.path=o}})}else{const i=o.call(this,r);if(i instanceof Promise){const o=te(e.path),n=this.options.asyncTimeout||2e3;e.addAsyncTask(async e=>{try{const t=new Promise((e,t)=>{setTimeout(()=>t(new Error("Async timeout")),n)});e(await Promise.race([i,t]))}catch(t){if("Async timeout"===t.message)return;e(!1)}},[],function(i){if(!0!==i){const i=e.path;e.path=o,e.addError("INVALID_FORMAT",[t.format,JSON.stringify(r)],void 0,t,"format"),e.path=i}})}else!0!==i&&e.addError("INVALID_FORMAT",[t.format,JSON.stringify(r)],void 0,t,"format")}}else!0!==this.options.ignoreUnknownFormats&&e.addError("UNKNOWN_FORMAT",[t.format],void 0,t,"format")}},ce=function(e,t,r){let i=r.length;if(Array.isArray(t.items))for(;i--;)i<t.items.length?(e.path.push(i),fe.call(this,e,t.items[i],r[i]),e.path.pop()):"object"==typeof t.additionalItems&&(e.path.push(i),fe.call(this,e,t.additionalItems,r[i]),e.path.pop());else if("object"==typeof t.items)for(;i--;)e.path.push(i),e.schemaPath.push("items"),fe.call(this,e,t.items,r[i]),e.schemaPath.pop(),e.path.pop()},de=function(e,t,r){let i=t.additionalProperties;!0!==i&&void 0!==i||(i={});const o=t.properties?Object.keys(t.properties):[],n=t.patternProperties?Object.keys(t.patternProperties):[],s=Object.keys(r);let a=s.length;for(;a--;){const l=s[a],c=r[l],d=[];-1!==o.indexOf(l)&&d.push(t.properties[l]);let f=n.length;for(;f--;){const e=n[f];!0===RegExp(e).test(l)&&d.push(t.patternProperties[e])}for(0===d.length&&!1!==i&&d.push(i),f=d.length;f--;)e.path.push(l),-1!==o.indexOf(l)?(e.schemaPath.push("properties"),e.schemaPath.push(l)):e.schemaPath.push("additionalProperties"),fe.call(this,e,d[f],c),e.path.pop(),e.schemaPath.pop(),-1!==o.indexOf(l)&&e.schemaPath.pop()}};function fe(e,t,r){e.commonErrorMessage="JSON_OBJECT_VALIDATION_FAILED";const i=N(t);if("object"!==i)return e.addError("SCHEMA_NOT_AN_OBJECT",[i],void 0,t),!1;let o=Object.keys(t);if(0===o.length)return!0;let n=!1;if(e.rootSchema||(e.rootSchema=t,n=!0),void 0!==t.$ref){let r=99;for(;t.$ref&&r>0;){if(!t.__$refResolved){e.addError("REF_UNRESOLVED",[t.$ref],void 0,t);break}if(t.__$refResolved===t)break;t=t.__$refResolved,o=Object.keys(t),r--}if(0===r)throw new Error("Circular dependency by $ref references!");e.schemaPath=[]}if(t.type&&(o.splice(o.indexOf("type"),1),e.schemaPath.push("type"),le.type.call(this,e,t,r),e.schemaPath.pop(),e.errors.length&&this.options.breakOnFirstError))return!1;let s=o.length;for(;s--&&!(le[o[s]]&&(le[o[s]].call(this,e,t,r),e.errors.length&&this.options.breakOnFirstError)););return 0!==e.errors.length&&!1!==this.options.breakOnFirstError||(Array.isArray(r)?ce.call(this,e,t,r):C(r)&&de.call(this,e,t,r)),"function"==typeof this.options.customValidator&&this.options.customValidator.call(this,e,t,r),n&&(e.rootSchema=void 0),0===e.errors.length}let pe;function ue(){return pe}const he=["enum"],me=(e,t,r,i)=>{if(t=t||[],r=r||[],i=i||[],"object"!=typeof e||null===e)return t;const o="string"==typeof e.$ref&&void 0===e.__$refResolved;let n=!1;const s=0===r.length;if("string"==typeof e.id&&(s||!o)){const t=r.length>0?r[r.length-1]:void 0;r.push(ye(t,e.id)),n=!0}let a;if(o&&t.push({ref:Ee(r[r.length-1],e.$ref),key:"$ref",obj:e,path:i.slice(0)}),"string"==typeof e.$schema&&void 0===e.__$schemaResolved&&t.push({ref:Ee(r[r.length-1],e.$schema),key:"$schema",obj:e,path:i.slice(0)}),Array.isArray(e))for(a=e.length;a--;)i.push(a),me(e[a],t,r,i),i.pop();else{const o=Object.keys(e);for(a=o.length;a--;)0===o[a].indexOf("__$")||he.includes(o[a])||(i.push(o[a]),me(e[o[a]],t,r,i),i.pop())}return n&&r.pop(),t},Ee=(e,t)=>{if(G(t))return t;const r=e??"";if("#"===t[0]){const e=r.indexOf("#");return(-1===e?r:r.slice(0,e))+t}if(!r)return t;const i=r.indexOf("#"),o=-1===i?r:r.slice(0,i);if(G(o))try{return new URL(t,o).toString()}catch{}let n=o;return n.endsWith("/")||(n=n.replace(/[^/]*$/,"")),n+t},ye=(e,t)=>{if(G(t))return t;const r=e??"";if("#"!==t[0]&&!t.includes("/")&&!t.includes(".")&&!t.includes("#")){const e=r.indexOf("#");return(-1===e?r:r.slice(0,e))+"#"+t}return Ee(e,t)};class _e{validator;constructor(e){this.validator=e}collectAndCacheIds(e){const t=(e=>{const t=[];return function e(r,i){if("object"!=typeof r||null==r)return;let o=!1;if(r.id&&"string"==typeof r.id){let e=G(r.id)?"absolute":"relative";0===i.length&&(e="root");const n={id:r.id,type:e,obj:r};"absolute"===e||"root"===e&&G(r.id)?n.absoluteUri=r.id:"relative"===e&&(n.absoluteParent=i.filter(e=>"absolute"===e.type||"root"===e.type&&e.absoluteUri).slice(-1)[0],n.absoluteParent&&(n.absoluteUri=n.absoluteParent.id.split("/").slice(0,-1).concat(n.id).join("/"))),t.push(n),i.push(n),o=!0}if(Array.isArray(r))for(const t of r)e(t,i);else for(const t of Object.keys(r))0!==t.indexOf("__$")&&e(r[t],i);o&&i.pop()}(e,[]),t})(e);for(const e of t)e.absoluteUri?this.validator.scache.cacheSchemaByUri(e.absoluteUri,e.obj):"root"===e.type&&this.validator.scache.cacheSchemaByUri(e.id,e.obj)}compileSchema(e,t,r){if(e.commonErrorMessage="SCHEMA_COMPILATION_FAILED","string"==typeof t){const r=this.validator.scache.getSchemaByUri(e,t);if(!r)return e.addError("SCHEMA_NOT_REACHABLE",[t]),!1;t=r}if(Array.isArray(t))return r?.noCache||t.forEach(e=>this.collectAndCacheIds(e)),this.compileArrayOfSchemas(e,t);if(r?.noCache||this.collectAndCacheIds(t),t.__$compiled&&t.id&&!1===this.validator.scache.checkCacheForUri(t.id)&&(t.__$compiled=void 0),t.__$compiled)return!0;t.$schema||"none"===this.validator.options.version||(t.$schema=this.validator.getDefaultSchemaId()),t.id&&"string"==typeof t.id&&!r?.noCache&&this.validator.scache.cacheSchemaByUri(t.id,t);let i=!1;e.rootSchema||(e.rootSchema=t,i=!0);const o=e.isValid();delete t.__$missingReferences;const n=me(t);let s=n.length;for(;s--;){const r=n[s];let i=this.validator.scache.getSchemaByUri(e,r.ref,t);if(!i){const o=ue();if(o){const n=z(r.ref),s=o(n);if(s){s.id=n;const o=new Z(e);this.compileSchema(o,s)?i=this.validator.scache.getSchemaByUri(e,r.ref,t):e.errors=e.errors.concat(o.errors)}}}if(!i){const i=e.hasError("REMOTE_NOT_VALID",[r.ref]),n=G(r.ref);let s=!1;const a=!0===this.validator.options.ignoreUnresolvableReferences;n&&(s=this.validator.scache.checkCacheForUri(r.ref)),i||a&&n||s||(e.path.push(...r.path),e.addError("UNRESOLVABLE_REFERENCE",[r.ref]),e.path=e.path.slice(0,-r.path.length),o&&(t.__$missingReferences=t.__$missingReferences||[],t.__$missingReferences.push(r)))}r.obj[`__${r.key}Resolved`]=i}const a=e.isValid();return a&&(t.__$compiled=!0),i&&(e.rootSchema=void 0),a}compileArrayOfSchemas(e,t){let r,i=0;do{let o=e.errors.length;for(;o--;)"UNRESOLVABLE_REFERENCE"===e.errors[o].code&&e.errors.splice(o,1);for(r=i,i=this.compileArrayOfSchemasLoop(e,t),o=t.length;o--;){const e=t[o];if(e.__$missingReferences){let r=e.__$missingReferences.length;for(;r--;){const i=e.__$missingReferences[r],o=t.find(e=>e.id===i.ref);o&&(i.obj[`__${i.key}Resolved`]=o,e.__$missingReferences.splice(r,1))}0===e.__$missingReferences.length&&delete e.__$missingReferences}}}while(i!==t.length&&i!==r);return e.isValid()}compileArrayOfSchemasLoop(e,t){let r=t.length,i=0;for(;r--;){const o=new Z(e);this.compileSchema(o,t[r])&&i++,e.errors=e.errors.concat(o.errors)}return i}}const ge={$ref:function(e,t){"string"!=typeof t.$ref&&e.addError("KEYWORD_TYPE_EXPECTED",["$ref","string"],void 0,t,"$ref")},$schema:function(e,t){"string"!=typeof t.$schema&&e.addError("KEYWORD_TYPE_EXPECTED",["$schema","string"],void 0,t,"$schema")},multipleOf:function(e,t){"number"!=typeof t.multipleOf?e.addError("KEYWORD_TYPE_EXPECTED",["multipleOf","number"],void 0,t,"multipleOf"):t.multipleOf<=0&&e.addError("KEYWORD_MUST_BE",["multipleOf","strictly greater than 0"],void 0,t,"multipleOf")},maximum:function(e,t){"number"!=typeof t.maximum&&e.addError("KEYWORD_TYPE_EXPECTED",["maximum","number"],void 0,t,"maximum")},exclusiveMaximum:function(e,t){"boolean"!=typeof t.exclusiveMaximum?e.addError("KEYWORD_TYPE_EXPECTED",["exclusiveMaximum","boolean"],void 0,t,"exclusiveMaximum"):void 0===t.maximum&&e.addError("KEYWORD_DEPENDENCY",["exclusiveMaximum","maximum"],void 0,t,"exclusiveMaximum")},minimum:function(e,t){"number"!=typeof t.minimum&&e.addError("KEYWORD_TYPE_EXPECTED",["minimum","number"],void 0,t,"minimum")},exclusiveMinimum:function(e,t){"boolean"!=typeof t.exclusiveMinimum?e.addError("KEYWORD_TYPE_EXPECTED",["exclusiveMinimum","boolean"],void 0,t,"exclusiveMinimum"):void 0===t.minimum&&e.addError("KEYWORD_DEPENDENCY",["exclusiveMinimum","minimum"],void 0,t,"exclusiveMinimum")},maxLength:function(e,t){"integer"!==N(t.maxLength)?e.addError("KEYWORD_TYPE_EXPECTED",["maxLength","integer"],void 0,t,"maxLength"):t.maxLength<0&&e.addError("KEYWORD_MUST_BE",["maxLength","greater than, or equal to 0"],void 0,t,"maxLength")},minLength:function(e,t){"integer"!==N(t.minLength)?e.addError("KEYWORD_TYPE_EXPECTED",["minLength","integer"],void 0,t,"minLength"):t.minLength<0&&e.addError("KEYWORD_MUST_BE",["minLength","greater than, or equal to 0"],void 0,t,"minLength")},pattern:function(e,t){if("string"!=typeof t.pattern)e.addError("KEYWORD_TYPE_EXPECTED",["pattern","string"],void 0,t,"pattern");else{const r=ne(t.pattern);r.ok||e.addError("KEYWORD_PATTERN",["pattern",t.pattern,r.error.message],void 0,t,"pattern")}},additionalItems:function(e,t){const r=N(t.additionalItems);"boolean"!==r&&"object"!==r?e.addError("KEYWORD_TYPE_EXPECTED",["additionalItems",["boolean","object"]],void 0,t,"additionalItems"):C(t.additionalItems)&&(e.path.push("additionalItems"),this.validateSchema(e,t.additionalItems),e.path.pop())},items:function(e,t){if("object"===N(t.items))e.path.push("items"),this.validateSchema(e,t.items),e.path.pop();else if(Array.isArray(t.items)){let r=t.items.length;for(;r--;)e.path.push("items"),e.path.push(r),this.validateSchema(e,t.items[r]),e.path.pop(),e.path.pop()}else e.addError("KEYWORD_TYPE_EXPECTED",["items",["array","object"]],void 0,t,"items");!0===this.options.forceAdditional&&void 0===t.additionalItems&&Array.isArray(t.items)&&e.addError("KEYWORD_UNDEFINED_STRICT",["additionalItems"],void 0,t,"additionalItems"),this.options.assumeAdditional&&void 0===t.additionalItems&&Array.isArray(t.items)&&(t.additionalItems=!1)},maxItems:function(e,t){"number"!=typeof t.maxItems?e.addError("KEYWORD_TYPE_EXPECTED",["maxItems","integer"],void 0,t,"maxItems"):t.maxItems<0&&e.addError("KEYWORD_MUST_BE",["maxItems","greater than, or equal to 0"],void 0,t,"maxItems")},minItems:function(e,t){"integer"!==N(t.minItems)?e.addError("KEYWORD_TYPE_EXPECTED",["minItems","integer"],void 0,t,"minItems"):t.minItems<0&&e.addError("KEYWORD_MUST_BE",["minItems","greater than, or equal to 0"],void 0,t,"minItems")},uniqueItems:function(e,t){"boolean"!=typeof t.uniqueItems&&e.addError("KEYWORD_TYPE_EXPECTED",["uniqueItems","boolean"],void 0,t,"uniqueItems")},maxProperties:function(e,t){"integer"!==N(t.maxProperties)?e.addError("KEYWORD_TYPE_EXPECTED",["maxProperties","integer"],void 0,t,"maxProperties"):t.maxProperties<0&&e.addError("KEYWORD_MUST_BE",["maxProperties","greater than, or equal to 0"],void 0,t,"maxProperties")},minProperties:function(e,t){"integer"!==N(t.minProperties)?e.addError("KEYWORD_TYPE_EXPECTED",["minProperties","integer"],void 0,t,"minProperties"):t.minProperties<0&&e.addError("KEYWORD_MUST_BE",["minProperties","greater than, or equal to 0"],void 0,t,"minProperties")},required:function(e,t){if("array"!==N(t.required))e.addError("KEYWORD_TYPE_EXPECTED",["required","array"],void 0,t,"required");else if(0===t.required.length)e.addError("KEYWORD_MUST_BE",["required","an array with at least one element"],void 0,t,"required");else{let r=t.required.length;for(;r--;)"string"!=typeof t.required[r]&&e.addError("KEYWORD_VALUE_TYPE",["required","string"],void 0,t,"required");!1===oe(t.required)&&e.addError("KEYWORD_MUST_BE",["required","an array with unique items"],void 0,t,"required")}},additionalProperties:function(e,t){const r=N(t.additionalProperties);"boolean"!==r&&"object"!==r?e.addError("KEYWORD_TYPE_EXPECTED",["additionalProperties",["boolean","object"]],void 0,t,"additionalProperties"):C(t.additionalProperties)&&(e.path.push("additionalProperties"),this.validateSchema(e,t.additionalProperties),e.path.pop())},properties:function(e,t){if("object"!==N(t.properties))return void e.addError("KEYWORD_TYPE_EXPECTED",["properties","object"],void 0,t,"properties");const r=Object.keys(t.properties);let i=r.length;for(;i--;){const o=r[i],n=t.properties[o];e.path.push("properties"),e.path.push(o),this.validateSchema(e,n),e.path.pop(),e.path.pop()}!0===this.options.forceAdditional&&void 0===t.additionalProperties&&e.addError("KEYWORD_UNDEFINED_STRICT",["additionalProperties"],void 0,t,"additionalProperties"),this.options.assumeAdditional&&void 0===t.additionalProperties&&(t.additionalProperties=!1),!0===this.options.forceProperties&&0===r.length&&e.addError("CUSTOM_MODE_FORCE_PROPERTIES",["properties"],void 0,t,"properties")},patternProperties:function(e,t){if("object"!==N(t.patternProperties))return void e.addError("KEYWORD_TYPE_EXPECTED",["patternProperties","object"],void 0,t,"patternProperties");const r=Object.keys(t.patternProperties);let i=r.length;for(;i--;){const o=r[i],n=t.patternProperties[o],s=ne(o);s.ok||e.addError("KEYWORD_PATTERN",["patternProperties",o,s.error.message],void 0,t,"patternProperties"),e.path.push("patternProperties"),e.path.push(o),this.validateSchema(e,n),e.path.pop(),e.path.pop()}!0===this.options.forceProperties&&0===r.length&&e.addError("CUSTOM_MODE_FORCE_PROPERTIES",["patternProperties"],void 0,t,"patternProperties")},dependencies:function(e,t){if("object"!==N(t.dependencies))e.addError("KEYWORD_TYPE_EXPECTED",["dependencies","object"],void 0,t,"dependencies");else{const r=Object.keys(t.dependencies);let i=r.length;for(;i--;){const o=r[i],n=t.dependencies[o],s=N(n);if("object"===s)e.path.push("dependencies"),e.path.push(o),this.validateSchema(e,n),e.path.pop(),e.path.pop();else if("array"===s){let r=n.length;for(0===r&&e.addError("KEYWORD_MUST_BE",["dependencies","not empty array"],void 0,t,"dependencies");r--;)"string"!=typeof n[r]&&e.addError("KEYWORD_VALUE_TYPE",["dependencies","string"],void 0,t,"dependencies");!1===oe(n)&&e.addError("KEYWORD_MUST_BE",["dependencies","an array with unique items"],void 0,t,"dependencies")}else e.addError("KEYWORD_VALUE_TYPE",["dependencies","object or array"],void 0,t,"dependencies")}}},enum:function(e,t){!1===Array.isArray(t.enum)?e.addError("KEYWORD_TYPE_EXPECTED",["enum","array"],void 0,t,"enum"):0===t.enum.length?e.addError("KEYWORD_MUST_BE",["enum","an array with at least one element"],void 0,t,"enum"):!1===oe(t.enum)&&e.addError("KEYWORD_MUST_BE",["enum","an array with unique elements"],void 0,t,"enum")},type:function(e,t){const r=["array","boolean","integer","number","null","object","string"],i=r.join(","),o=Array.isArray(t.type);if(Array.isArray(t.type)){let o=t.type.length;for(;o--;)-1===r.indexOf(t.type[o])&&e.addError("KEYWORD_TYPE_EXPECTED",["type",i],void 0,t,"type");!1===oe(t.type)&&e.addError("KEYWORD_MUST_BE",["type","an object with unique properties"],void 0,t,"type")}else"string"==typeof t.type?-1===r.indexOf(t.type)&&e.addError("KEYWORD_TYPE_EXPECTED",["type",i],void 0,t,"type"):e.addError("KEYWORD_TYPE_EXPECTED",["type",["string","array"]],void 0,t,"type");!0===this.options.noEmptyStrings&&("string"===t.type||o&&-1!==t.type.indexOf("string"))&&void 0===t.minLength&&void 0===t.enum&&void 0===t.format&&(t.minLength=1),!0===this.options.noEmptyArrays&&("array"===t.type||o&&-1!==t.type.indexOf("array"))&&void 0===t.minItems&&(t.minItems=1),!0===this.options.forceProperties&&("object"===t.type||o&&-1!==t.type.indexOf("object"))&&void 0===t.properties&&void 0===t.patternProperties&&e.addError("KEYWORD_UNDEFINED_STRICT",["properties"],void 0,t,"properties"),!0===this.options.forceItems&&("array"===t.type||o&&-1!==t.type.indexOf("array"))&&void 0===t.items&&e.addError("KEYWORD_UNDEFINED_STRICT",["items"],void 0,t,"items"),!0===this.options.forceMinItems&&("array"===t.type||o&&-1!==t.type.indexOf("array"))&&void 0===t.minItems&&e.addError("KEYWORD_UNDEFINED_STRICT",["minItems"],void 0,t,"minItems"),!0===this.options.forceMaxItems&&("array"===t.type||o&&-1!==t.type.indexOf("array"))&&void 0===t.maxItems&&e.addError("KEYWORD_UNDEFINED_STRICT",["maxItems"],void 0,t,"maxItems"),!0===this.options.forceMinLength&&("string"===t.type||o&&-1!==t.type.indexOf("string"))&&void 0===t.minLength&&void 0===t.format&&void 0===t.enum&&void 0===t.pattern&&e.addError("KEYWORD_UNDEFINED_STRICT",["minLength"],void 0,t,"minLength"),!0===this.options.forceMaxLength&&("string"===t.type||o&&-1!==t.type.indexOf("string"))&&void 0===t.maxLength&&void 0===t.format&&void 0===t.enum&&void 0===t.pattern&&e.addError("KEYWORD_UNDEFINED_STRICT",["maxLength"],void 0,t,"maxLength")},allOf:function(e,t){if(!1===Array.isArray(t.allOf))e.addError("KEYWORD_TYPE_EXPECTED",["allOf","array"],void 0,t,"allOf");else if(0===t.allOf.length)e.addError("KEYWORD_MUST_BE",["allOf","an array with at least one element"],void 0,t,"allOf");else{let r=t.allOf.length;for(;r--;)e.path.push("allOf"),e.path.push(r),this.validateSchema(e,t.allOf[r]),e.path.pop(),e.path.pop()}},anyOf:function(e,t){if(!1===Array.isArray(t.anyOf))e.addError("KEYWORD_TYPE_EXPECTED",["anyOf","array"],void 0,t,"anyOf");else if(0===t.anyOf.length)e.addError("KEYWORD_MUST_BE",["anyOf","an array with at least one element"],void 0,t,"anyOf");else{let r=t.anyOf.length;for(;r--;)e.path.push("anyOf"),e.path.push(r),this.validateSchema(e,t.anyOf[r]),e.path.pop(),e.path.pop()}},oneOf:function(e,t){if(!1===Array.isArray(t.oneOf))e.addError("KEYWORD_TYPE_EXPECTED",["oneOf","array"],void 0,t,"oneOf");else if(0===t.oneOf.length)e.addError("KEYWORD_MUST_BE",["oneOf","an array with at least one element"],void 0,t,"oneOf");else{let r=t.oneOf.length;for(;r--;)e.path.push("oneOf"),e.path.push(r),this.validateSchema(e,t.oneOf[r]),e.path.pop(),e.path.pop()}},not:function(e,t){"object"!==N(t.not)?e.addError("KEYWORD_TYPE_EXPECTED",["not","object"],void 0,t,"not"):(e.path.push("not"),this.validateSchema(e,t.not),e.path.pop())},definitions:function(e,t){if("object"!==N(t.definitions))e.addError("KEYWORD_TYPE_EXPECTED",["definitions","object"],void 0,t,"definitions");else{const r=Object.keys(t.definitions);let i=r.length;for(;i--;){const o=r[i],n=t.definitions[o];e.path.push("definitions"),e.path.push(o),this.validateSchema(e,n),e.path.pop(),e.path.pop()}}},format:function(e,t){var r;"string"!=typeof t.format?e.addError("KEYWORD_TYPE_EXPECTED",["format","string"],void 0,t,"format"):(r=t.format,K(this.options.customFormats).includes(r)||!0===this.options.ignoreUnknownFormats||e.addError("UNKNOWN_FORMAT",[t.format],void 0,t,"format"))},id:function(e,t){"string"!=typeof t.id&&e.addError("KEYWORD_TYPE_EXPECTED",["id","string"],void 0,t,"id")},title:function(e,t){"string"!=typeof t.title&&e.addError("KEYWORD_TYPE_EXPECTED",["title","string"],void 0,t,"title")},description:function(e,t){"string"!=typeof t.description&&e.addError("KEYWORD_TYPE_EXPECTED",["description","string"],void 0,t,"description")},default:function(){}};class ve{validator;constructor(e){this.validator=e}get options(){return this.validator.options}validateArrayOfSchemas(e,t){let r=t.length;for(;r--;)this.validateSchema(e,t[r]);return e.isValid()}validateSchema(e,t){if(e.commonErrorMessage="SCHEMA_VALIDATION_FAILED",Array.isArray(t))return this.validateArrayOfSchemas(e,t);if(t.__$validated)return!0;const r=t.$schema&&t.id!==t.$schema;if(r)if(t.__$schemaResolved&&t.__$schemaResolved!==t){const r=new Z(e);!1===fe.call(this.validator,r,t.__$schemaResolved,t)&&e.addError("PARENT_SCHEMA_VALIDATION_FAILED",void 0,r,t,"$schema")}else!0!==this.validator.options.ignoreUnresolvableReferences&&e.addError("REF_UNRESOLVED",[t.$schema],void 0,t,"$schema");if(!0===this.validator.options.noTypeless){if(void 0!==t.type){let e=[];Array.isArray(t.anyOf)&&(e=e.concat(t.anyOf)),Array.isArray(t.oneOf)&&(e=e.concat(t.oneOf)),Array.isArray(t.allOf)&&(e=e.concat(t.allOf)),e.forEach(function(e){e.type||(e.type=t.type)})}void 0===t.enum&&void 0===t.type&&void 0===t.anyOf&&void 0===t.oneOf&&void 0===t.not&&void 0===t.$ref&&e.addError("KEYWORD_UNDEFINED_STRICT",["type"],void 0,t,"type")}const i=Object.keys(t);let o=i.length;for(;o--;){const n=i[o];0!==n.indexOf("__")&&(Object.prototype.hasOwnProperty.call(ge,n)?ge[n].call(this,e,t):r||!0===this.validator.options.noExtraKeywords&&e.addError("KEYWORD_UNEXPECTED",[n],void 0,t,void 0))}if(!0===this.validator.options.pedanticCheck){if(t.enum){const r=te(t);for(delete r.enum,delete r.default,e.path.push("enum"),o=t.enum.length;o--;)e.path.push(o),fe.call(this.validator,e,r,t.enum[o]),e.path.pop();e.path.pop()}t.default&&(e.path.push("default"),fe.call(this.validator,e,t,t.default),e.path.pop())}const n=e.isValid();return n&&(t.__$validated=!0),n}}const Oe={version:"draft-04",asyncTimeout:2e3,forceAdditional:!1,assumeAdditional:!1,enumCaseInsensitiveComparison:!1,forceItems:!1,forceMinItems:!1,forceMaxItems:!1,forceMinLength:!1,forceMaxLength:!1,forceProperties:!1,ignoreUnresolvableReferences:!1,noExtraKeywords:!1,noTypeless:!1,noEmptyStrings:!1,noEmptyArrays:!1,strictUris:!1,strictMode:!1,reportPathAsArray:!1,breakOnFirstError:!1,pedanticCheck:!1,ignoreUnknownFormats:!1,customValidator:null},Ae=e=>{let t;if("object"==typeof e){let r,i=Object.keys(e),o=i.length;for(;o--;)if(r=i[o],void 0===Oe[r])throw new Error("Unexpected option passed to constructor: "+r);for(i=Object.keys(Oe),o=i.length;o--;)r=i[o],void 0===e[r]&&(e[r]=te(Oe[r]));t=e}else t=te(Oe);return!0===t.strictMode&&(t.forceAdditional=!0,t.forceItems=!0,t.forceMaxLength=!0,t.forceProperties=!0,t.noExtraKeywords=!0,t.noTypeless=!0,t.noEmptyStrings=!0,t.noEmptyArrays=!0),t};class Te{scache;sc;sv;validateOptions={};options;constructor(e){if(!e?.__called_from_factory__)throw new Error("do not use new ZSchema(), use ZSchema.create() instead");delete e.__called_from_factory__,this.scache=new ie(this),this.sc=new _e(this),this.sv=new ve(this),this.options=Ae(e)}getDefaultSchemaId(){return this.options.version&&"none"!==this.options.version?W[this.options.version]:W[Oe.version]}_validate(e,t,r,i){"function"==typeof r&&(i=r,r={}),r||(r={}),this.validateOptions=r;const o=N(t);if("string"!==o&&"object"!==o){const e=new Error("Invalid .validate call - schema must be a string or object but "+o+" was passed!");if(i)return void setTimeout(function(){i(e,!1)},0);throw e}let n=!1;const s=new Z(this.options,r);let a;if(s.json=e,"string"==typeof t){const e=t;if(a=this.scache.getSchema(s,e),!a){const t=new Error("Schema with id '"+e+"' wasn't found in the validator cache!");if(i)return void setTimeout(function(){i(t,!1)},0);throw t}}else a=this.scache.getSchema(s,t);let l=!1;n||(l=this.sc.compileSchema(s,a)),l||(n=!0);let c=!1;if(n||(c=this.sv.validateSchema(s,a)),c||(n=!0),r.schemaPath&&(s.rootSchema=a,a=U(a,r.schemaPath),!a)){const e=new Error("Schema path '"+r.schemaPath+"' wasn't found in the schema!");if(i)return void setTimeout(function(){i(e,!1)},0);throw e}if(n||fe.call(this,s,a,e),!i){if(s.asyncTasks.length>0)throw new Error("This validation has async tasks and cannot be done in sync mode, please provide callback argument.");if(!s.isValid())throw V({message:s.commonErrorMessage,details:s.errors});return!0}s.processAsyncTasks(this.options.asyncTimeout,i)}_validateSchema(e){if(Array.isArray(e)&&0===e.length)throw new Error(".compileSchema was called with an empty array");const t=new Z(this.options);if(Array.isArray(e)){const r=this.scache.getSchema(t,e);this.sc.compileSchema(t,r)&&this.sv.validateSchema(t,r)}else{const r=this.scache.getSchema(t,e);this.sc.compileSchema(t,r)&&this.sv.validateSchema(t,r)}if(!t.isValid())throw V({message:t.commonErrorMessage,details:t.errors});return!0}registerFormat(e,t){this.options.customFormats||(this.options.customFormats={}),this.options.customFormats[e]=t}unregisterFormat(e){this.options.customFormats||(this.options.customFormats={}),this.options.customFormats[e]=null}getRegisteredFormats(){return $(this.options.customFormats||{}).filter(e=>null!=this.options.customFormats?.[e])}getSupportedFormats(){return K(this.options.customFormats)}setRemoteReference(e,t,r){let i;i="string"==typeof t?JSON.parse(t):re(t),i.id||(i.id=e),r&&(i.__$validationOptions=Ae(r)),this.scache.cacheSchemaByUri(e,i)}getMissingReferences(e){if(!e)return[];const t=e.details||[],r=[];return function e(t){for(const i of t)"UNRESOLVABLE_REFERENCE"!==i.code&&"SCHEMA_NOT_REACHABLE"!==i.code||r.push(i.params[0]),i.inner&&e(i.inner)}(t),r}getMissingRemoteReferences(e){const t=this.getMissingReferences(e),r=[];let i=t.length;for(;i--;){const e=z(t[i]);e&&-1===r.indexOf(e)&&r.push(e)}return r}getResolvedSchema(e){const t=new Z(this.options),r=this.scache.getSchemaByUri(t,e);if(!r)return;const i=re(r),o=[],n=function(e){let t;const r=N(e);if(("object"===r||"array"===r)&&!e.___$visited){if(e.___$visited=!0,o.push(e),e.$ref&&e.__$refResolved){const r=e.__$refResolved,i=e;for(t in delete e.$ref,delete e.__$refResolved,r)ee(r,i,t)}for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&(0===t.indexOf("__$")?delete e[t]:n(e[t]))}};return n(i),o.forEach(function(e){delete e.___$visited}),i}}var xe={$schema:"http://json-schema.org/draft-04/hyper-schema#",id:"http://json-schema.org/draft-04/hyper-schema#",title:"JSON Hyper-Schema",allOf:[{$ref:"http://json-schema.org/draft-04/schema#"}],properties:{additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}]},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}]},dependencies:{additionalProperties:{anyOf:[{$ref:"#"},{type:"array"}]}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}]},definitions:{additionalProperties:{$ref:"#"}},patternProperties:{additionalProperties:{$ref:"#"}},properties:{additionalProperties:{$ref:"#"}},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"},links:{type:"array",items:{$ref:"#/definitions/linkDescription"}},fragmentResolution:{type:"string"},media:{type:"object",properties:{type:{description:"A media type, as described in RFC 2046",type:"string"},binaryEncoding:{description:"A content encoding scheme, as described in RFC 2045",type:"string"}}},pathStart:{description:"Instances' URIs must start with this value for this schema to apply to them",type:"string",format:"uri"}},definitions:{schemaArray:{type:"array",items:{$ref:"#"}},linkDescription:{title:"Link Description Object",type:"object",required:["href","rel"],properties:{href:{description:"a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",type:"string"},rel:{description:"relation to the target resource of the link",type:"string"},title:{description:"a title for the link",type:"string"},targetSchema:{description:"JSON Schema describing the link target",$ref:"#"},mediaType:{description:"media type (as defined by RFC 2046) describing the link target",type:"string"},method:{description:'method for requesting the target of the link (e.g. for HTTP this might be "GET" or "DELETE")',type:"string"},encType:{description:"The media type in which to submit data along with the request",type:"string",default:"application/json"},schema:{description:"Schema describing the data to submit along with the request",$ref:"#"}}},readOnly:{description:"If true, indicates that the value of this property is controlled by the server.",type:"boolean",default:!1}},links:[{rel:"self",href:"{+id}"},{rel:"full",href:"{+($ref)}"}]},Ie={id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string"},$schema:{type:"string"},title:{type:"string"},description:{type:"string"},default:{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean",default:!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean",default:!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},enum:{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},default:{}};class Re extends Te{static registerFormat(e,t){return function(e,t){k[e]=t}(e,t)}static unregisterFormat(e){return function(e){delete k[e]}(e)}static getRegisteredFormats(){return $(k)}static getDefaultOptions(){return re(Oe)}static setRemoteReference(e,t,r){let i;i="string"==typeof t?JSON.parse(t):re(t),i.id||(i.id=e),r&&(i.__$validationOptions=Ae(r)),ie.cacheSchemaByUri(e,i)}static getSchemaReader(){return ue()}static setSchemaReader(e){return function(e){pe=e}(e)}static schemaSymbol=J;static jsonSymbol=H;static create(e={}){const t=e.async,r=e.safe;return delete e.async,delete e.safe,e.__called_from_factory__=!0,t&&r?new Se(e):t?new be(e):r?new Pe(e):new Re(e)}validate(e,t,r={}){return this._validate(e,t,r)}validateSafe(e,t,r){try{return this._validate(e,t,r??{}),{valid:!0}}catch(e){return{valid:!1,err:e}}}validateAsync(e,t,r){return new Promise((i,o)=>{try{this._validate(e,t,r||{},(e,t)=>e||!0!==t?o(e):i(t))}catch(e){o(e)}})}validateAsyncSafe(e,t,r){return new Promise(i=>{try{this._validate(e,t,r||{},(e,t)=>{i({valid:t,err:e})})}catch(e){i({valid:!1,err:e})}})}validateSchema(e){return this._validateSchema(e)}validateSchemaSafe(e){try{return this._validateSchema(e),{valid:!0}}catch(e){return{valid:!1,err:e}}}}class Pe extends Te{validate(e,t,r={}){try{return this._validate(e,t,r),{valid:!0}}catch(e){return{valid:!1,err:e}}}validateSchema(e){try{return this._validateSchema(e),{valid:!0}}catch(e){return{valid:!1,err:e}}}}class be extends Te{validate(e,t,r={}){return new Promise((i,o)=>{try{this._validate(e,t,r,(e,t)=>e||!0!==t?o(e):i(t))}catch(e){o(e)}})}validateSchema(e){return this._validateSchema(e)}}class Se extends Te{validate(e,t,r={}){return new Promise(i=>{try{this._validate(e,t,r,(e,t)=>{i({valid:t,err:e})})}catch(e){i({valid:!1,err:e})}})}validateSchema(e){try{return this._validateSchema(e),{valid:!0}}catch(e){return{valid:!1,err:e}}}}const De=Ie,Me=xe;Re.setRemoteReference("http://json-schema.org/draft-04/schema",De,{version:"none"}),Re.setRemoteReference("http://json-schema.org/draft-04/hyper-schema",Me,{version:"none"}),e.ZSchema=Re,e.ZSchemaAsync=be,e.ZSchemaAsyncSafe=Se,e.ZSchemaSafe=Pe});
1
+ !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).ZSchema={})}(this,function(e){"use strict";const t=e=>"object"==typeof e?null===e?"null":Array.isArray(e)?"array":"object":"number"==typeof e?Number.isFinite(e)?e%1==0?"integer":"number":Number.isNaN(e)?"not-a-number":"unknown-number":typeof e;function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function i(e){return"number"==typeof e&&Number.isFinite(e)&&e%1==0}const n=e=>e.$id?e.$id:e.id?e.id:void 0,o=(e,t)=>{if("object"!=typeof e||null===e)return;if(!t)return e;const i=n(e);if(i&&(i===t||"#"===i[0]&&i.substring(1)===t))return e;let s,a;if(Array.isArray(e))for(s=e.length;s--;)if(a=o(e[s],t),a)return a;if(r(e)){const r=Object.keys(e);for(s=r.length;s--;){const i=r[s];if(0!==i.indexOf("__$")&&(a=o(e[i],t),a))return a}}},s={INVALID_TYPE:"Expected type {0} but found type {1}",INVALID_FORMAT:"Object didn't pass validation for format {0}: {1}",ENUM_MISMATCH:"No enum match for: {0}",ENUM_CASE_MISMATCH:"Enum does not match case for: {0}",ANY_OF_MISSING:"Data does not match any schemas from 'anyOf'",ONE_OF_MISSING:"Data does not match any schemas from 'oneOf'",ONE_OF_MULTIPLE:"Data is valid against more than one schema from 'oneOf'",NOT_PASSED:"Data matches schema from 'not'",ARRAY_LENGTH_SHORT:"Array is too short ({0}), minimum {1}",ARRAY_LENGTH_LONG:"Array is too long ({0}), maximum {1}",ARRAY_UNIQUE:"Array items are not unique (indexes {0} and {1})",ARRAY_ADDITIONAL_ITEMS:"Additional items not allowed",MULTIPLE_OF:"Value {0} is not a multiple of {1}",MINIMUM:"Value {0} is less than minimum {1}",MINIMUM_EXCLUSIVE:"Value {0} is equal or less than exclusive minimum {1}",MAXIMUM:"Value {0} is greater than maximum {1}",MAXIMUM_EXCLUSIVE:"Value {0} is equal or greater than exclusive maximum {1}",OBJECT_PROPERTIES_MINIMUM:"Too few properties defined ({0}), minimum {1}",OBJECT_PROPERTIES_MAXIMUM:"Too many properties defined ({0}), maximum {1}",OBJECT_MISSING_REQUIRED_PROPERTY:"Missing required property: {0}",OBJECT_ADDITIONAL_PROPERTIES:"Additional properties not allowed: {0}",OBJECT_DEPENDENCY_KEY:"Dependency failed - key must exist: {0} (due to key: {1})",MIN_LENGTH:"String is too short ({0} chars), minimum {1}",MAX_LENGTH:"String is too long ({0} chars), maximum {1}",PATTERN:"String does not match pattern {0}: {1}",KEYWORD_TYPE_EXPECTED:"Keyword '{0}' is expected to be of type '{1}'",KEYWORD_UNDEFINED_STRICT:"Keyword '{0}' must be defined in strict mode",KEYWORD_UNEXPECTED:"Keyword '{0}' is not expected to appear in the schema",KEYWORD_MUST_BE:"Keyword '{0}' must be {1}",KEYWORD_DEPENDENCY:"Keyword '{0}' requires keyword '{1}'",KEYWORD_PATTERN:"Keyword '{0}' is not a valid RegExp pattern: {1}",KEYWORD_VALUE_TYPE:"Each element of keyword '{0}' array must be a '{1}'",UNKNOWN_FORMAT:"There is no validation function for format '{0}'",CUSTOM_MODE_FORCE_PROPERTIES:"{0} must define at least one property if present",REF_UNRESOLVED:"Reference has not been resolved during compilation: {0}",UNRESOLVABLE_REFERENCE:"Reference could not be resolved: {0}",SCHEMA_NOT_REACHABLE:"Validator was not able to read schema with uri: {0}",SCHEMA_TYPE_EXPECTED:"Schema is expected to be of type 'object'",SCHEMA_NOT_AN_OBJECT:"Schema is not an object: {0}",ASYNC_TIMEOUT:"{0} asynchronous task(s) have timed out after {1} ms",PARENT_SCHEMA_VALIDATION_FAILED:"Schema failed to validate against its parent schema, see inner errors for details.",REMOTE_NOT_VALID:"Remote reference didn't compile successfully: {0}",SCHEMA_IS_FALSE:'Boolean schema "false" is always invalid.',CONST:"Value does not match const: {0}",CONTAINS:"Array does not contain an item matching the schema",PROPERTY_NAMES:"Property name {0} does not match the propertyNames schema"};class a extends Error{name;details;constructor(e,t){super(e),this.name="z-schema validation error",this.details=t}}function d({message:e,details:t}){return new a(e||"",t)}const l=(e,t,i)=>{const n=(i=i||{}).caseInsensitiveComparison||!1;if(e===t)return!0;if(!0===n&&"string"==typeof e&&"string"==typeof t&&e.toUpperCase()===t.toUpperCase())return!0;let o,s;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(s=e.length,o=0;o<s;o++)if(!l(e[o],t[o],{caseInsensitiveComparison:n}))return!1;return!0}if(r(e)&&r(t)){const r=f(e),i=f(t);if(!l(r,i,{caseInsensitiveComparison:n}))return!1;for(s=r.length,o=0;o<s;o++)if(!l(e[r[o]],t[r[o]],{caseInsensitiveComparison:n}))return!1;return!0}return!1},c=e=>decodeURIComponent(e).replace(/~[0-1]/g,e=>"~1"===e?"/":"~"),f=e=>Object.keys(e).sort(),p=(e,t)=>("string"==typeof t&&(t=t.split(".")),t.reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)),u=Symbol.for("z-schema/json"),h=Symbol.for("z-schema/schema"),m=e=>{const t=e.indexOf("#");return-1===t?e:e.slice(0,t)},y=e=>/^(https?|file):\/\//.test(e);class E{asyncTasks=[];commonErrorMessage;errors=[];json;path=[];schemaPath=[];rootSchema;parentReport;options;reportOptions;validateOptions={};constructor(e,t,r){this.parentReport=e instanceof E?e:void 0,this.options=e instanceof E?e.options:e||{},e instanceof E?(this.reportOptions=t||{},this.validateOptions=r||e.validateOptions):(this.reportOptions={},this.validateOptions=t||{})}isValid(){if(this.asyncTasks.length>0)throw new Error("Async tasks pending, can't answer isValid");return 0===this.errors.length}addAsyncTask(e,t,r){this.asyncTasks.push([e,t,r])}getAncestor(e){if(this.parentReport)return this.parentReport.getSchemaId()===e?this.parentReport:this.parentReport.getAncestor(e)}processAsyncTasks(e,t){const r=e||2e3;let i=this.asyncTasks.length,n=i,o=!1;const s=()=>{setTimeout(()=>{const e=0===this.errors.length,r=e?void 0:d({details:this.errors});t(r,e)},0)},a=e=>t=>{o||(e(t),0===--i&&s())};if(0===i||this.errors.length>0&&this.options.breakOnFirstError)s();else{for(;n--;){const[e,t,r]=this.asyncTasks[n];e(...t,a(r))}setTimeout(()=>{i>0&&(o=!0,this.addError("ASYNC_TIMEOUT",[i,r]),t(d({details:this.errors}),!1))},r)}}getPath(e){let t=[];return this.parentReport&&(t=t.concat(this.parentReport.path)),t=t.concat(this.path),!0!==e?"#/"+t.map(function(e){return e=e.toString(),y(e)?"uri("+e+")":e.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/"):t}getSchemaPath(){let e=[];return this.parentReport&&(e=e.concat(this.parentReport.schemaPath)),e=e.concat(this.schemaPath),e}getSchemaId(){if(!this.rootSchema)return;let e=[];for(this.parentReport&&(e=e.concat(this.parentReport.path)),e=e.concat(this.path);e.length>0;){const t=p(this.rootSchema,e);if(t&&t.id)return t.id;e.pop()}return this.rootSchema.id}hasError(e,t){let r=this.errors.length;for(;r--;)if(this.errors[r].code===e){let e=!0,i=this.errors[r].params.length;for(;i--;)this.errors[r].params[i]!==t[i]&&(e=!1);if(e)return e}return!1}addError(e,t,r,i,n){if(!e)throw new Error("No errorCode passed into addError()");this.addCustomError(e,s[e],t,r,i,n)}getJson(){return this.json?this.json:this.parentReport?this.parentReport.getJson():void 0}addCustomError(e,t,i,n,o,s){if("number"==typeof this.reportOptions.maxErrors&&this.errors.length>=this.reportOptions.maxErrors)return;if(!t)throw new Error("No errorMessage known for code "+e);let a=(i=i||[]).length;for(;a--;){const e=null===i[a]||r(i[a])?JSON.stringify(i[a]):i[a];t=t.replace("{"+a+"}",e.toString())}const d={code:e,params:i,message:t,path:this.getPath(this.options.reportPathAsArray),schemaPath:this.getSchemaPath(),schemaId:this.getSchemaId(),keyword:s};if(d[h]=o,d[u]=this.getJson(),o&&"string"==typeof o?d.description=o:o&&"object"==typeof o&&(o.title&&(d.title=o.title),o.description&&(d.description=o.description)),null!=n){for(Array.isArray(n)||(n=[n]),d.inner=[],a=n.length;a--;){const e=n[a];let t=e.errors.length;for(;t--;)d.inner.push(e.errors[t])}0===d.inner.length&&(d.inner=void 0)}Array.isArray(this.validateOptions.excludeErrors)&&this.validateOptions.excludeErrors.includes(e)||this.errors.push(d)}}function g(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function _(e,t,r,i){g(e,r)&&Object.defineProperty(t,r,{value:i?i(e[r]):e[r],enumerable:!0,writable:!0,configurable:!0})}const v=e=>{if(null==e||"object"!=typeof e)return e;let t,r;if(Array.isArray(e))for(t=[],r=e.length;r--;)t[r]=e[r];else{t={};const r=Object.keys(e).sort();for(const i of r)_(e,t,i)}return t},O=e=>{let t=0;const r=new Map,i=[],n=e=>{if("object"!=typeof e||null===e)return e;let o,s;const a=r.get(e);if(void 0!==a)return i[a];if(r.set(e,t++),Array.isArray(e))for(o=[],i.push(o),s=e.length;s--;)o[s]=n(e[s]);else{o={},i.push(o);const t=Object.keys(e).sort();for(const r of t)_(e,o,r,n)}return o};return n(e)};class A{validator;static global_cache={};cache={};constructor(e){this.validator=e}static cacheSchemaByUri(e,t){const r=m(e);r&&(this.global_cache[r]=t)}cacheSchemaByUri(e,t){const r=m(e);r&&(this.cache[r]=t)}removeFromCacheByUri(e){const t=m(e);t&&delete this.cache[t]}checkCacheForUri(e){const t=m(e);return!!t&&null!=this.cache[t]}getSchema(e,t){return Array.isArray(t)?t.map(t=>this.getSchema(e,t)):"string"==typeof t?this.getSchemaByUri(e,t):O(t)}fromCache(e){let t=this.cache[e];if(t)return this.cache[e];return t=A.global_cache[e],t?((!(r=t).id||!y(r.id)&&y(e))&&(r.id=e),O(r)):void 0;var r}getSchemaByUri(e,t,r){if(r&&!y(t)){let e=n(r);if(e&&y(e)||"string"!=typeof r.id||!y(r.id)||(e=r.id),e&&y(e)){const r=e.indexOf("#"),i=-1===r?e:e.slice(0,r);try{t=new URL(t,i).toString()}catch{}}}const i=m(t),s=(e=>{const t=e.indexOf("#");return-1===t?void 0:e.slice(t+1)})(t);let a=i?this.fromCache(i):r;if(!(a&&i&&y(i))||a.id&&y(a.id)||(a.id=i),a&&i){if(a!==r){let r;e.path.push(i);const n=a.id?e.getAncestor(a.id):void 0;if(n)r=n;else{r=new E(e);const t=!a.id||!y(a.id);if(this.validator.sc.compileSchema(r,a,{noCache:t})){const e=this.validator.options;try{this.validator.options=a.__$validationOptions||this.validator.options,this.validator.sv.validateSchema(r,a)}finally{this.validator.options=e}}}const o=r.isValid();if(o||e.addError("REMOTE_NOT_VALID",[t],r),e.path.pop(),!o)return}}if(a&&s){const e=s.split("/");for(let t=0,r=e.length;a&&t<r;t++){const r=c(e[t]);a=0===t?o(a,r):a[r]}}return a}}const b={"draft-04":"http://json-schema.org/draft-04/schema#","draft-06":"http://json-schema.org/draft-06/schema#"},T={version:"draft-06",asyncTimeout:2e3,forceAdditional:!1,assumeAdditional:!1,enumCaseInsensitiveComparison:!1,forceItems:!1,forceMinItems:!1,forceMaxItems:!1,forceMinLength:!1,forceMaxLength:!1,forceProperties:!1,ignoreUnresolvableReferences:!1,noExtraKeywords:!1,noTypeless:!1,noEmptyStrings:!1,noEmptyArrays:!1,strictUris:!1,strictMode:!1,reportPathAsArray:!1,breakOnFirstError:!1,pedanticCheck:!1,ignoreUnknownFormats:!1,customValidator:null},I=e=>{let t;if("object"==typeof e){let r,i=Object.keys(e),n=i.length;for(;n--;)if(r=i[n],void 0===T[r])throw new Error("Unexpected option passed to constructor: "+r);for(i=Object.keys(T),n=i.length;n--;)r=i[n],void 0===e[r]&&(e[r]=v(T[r]));t=e}else t=v(T);return!0===t.strictMode&&(t.forceAdditional=!0,t.forceItems=!0,t.forceMaxLength=!0,t.forceProperties=!0,t.noExtraKeywords=!0,t.noTypeless=!0,t.noEmptyStrings=!0,t.noEmptyArrays=!0),t};const x={$schema:"http://json-schema.org/draft-04/hyper-schema#",id:"http://json-schema.org/draft-04/hyper-schema#",title:"JSON Hyper-Schema",allOf:[{$ref:"http://json-schema.org/draft-04/schema#"}],properties:{additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}]},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}]},dependencies:{additionalProperties:{anyOf:[{$ref:"#"},{type:"array"}]}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}]},definitions:{additionalProperties:{$ref:"#"}},patternProperties:{additionalProperties:{$ref:"#"}},properties:{additionalProperties:{$ref:"#"}},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"},links:{type:"array",items:{$ref:"#/definitions/linkDescription"}},fragmentResolution:{type:"string"},media:{type:"object",properties:{type:{description:"A media type, as described in RFC 2046",type:"string"},binaryEncoding:{description:"A content encoding scheme, as described in RFC 2045",type:"string"}}},pathStart:{description:"Instances' URIs must start with this value for this schema to apply to them",type:"string",format:"uri"}},definitions:{schemaArray:{type:"array",items:{$ref:"#"}},linkDescription:{title:"Link Description Object",type:"object",required:["href","rel"],properties:{href:{description:"a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",type:"string"},rel:{description:"relation to the target resource of the link",type:"string"},title:{description:"a title for the link",type:"string"},targetSchema:{description:"JSON Schema describing the link target",$ref:"#"},mediaType:{description:"media type (as defined by RFC 2046) describing the link target",type:"string"},method:{description:'method for requesting the target of the link (e.g. for HTTP this might be "GET" or "DELETE")',type:"string"},encType:{description:"The media type in which to submit data along with the request",type:"string",default:"application/json"},schema:{description:"Schema describing the data to submit along with the request",$ref:"#"}}},readOnly:{description:"If true, indicates that the value of this property is controlled by the server.",type:"boolean",default:!1}},links:[{rel:"self",href:"{+id}"},{rel:"full",href:"{+($ref)}"}]},R={$schema:"http://json-schema.org/draft-06/schema#",$id:"http://json-schema.org/draft-06/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},title:{type:"string"},description:{type:"string"},default:{},examples:{type:"array",items:{}},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:{}},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:{},enum:{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:{}},P={$schema:"http://json-schema.org/draft-06/hyper-schema#",$id:"http://json-schema.org/draft-06/hyper-schema#",title:"JSON Hyper-Schema",definitions:{schemaArray:{allOf:[{$ref:"http://json-schema.org/draft-06/schema#/definitions/schemaArray"},{items:{$ref:"#"}}]},linkDescription:{title:"Link Description Object",type:"object",required:["href"],properties:{href:{description:"a URI template, as defined by RFC 6570",type:"string",format:"uri-template"},hrefSchema:{description:'a schema for validating user input to the URI template, where the input is in the form of a JSON object with property names matching variable names in "href"',allOf:[{$ref:"#"}]},rel:{description:"relation to the target resource of the link",type:"string"},title:{description:"a title for the link",type:"string"},targetSchema:{description:"JSON Schema describing the link target",allOf:[{$ref:"#"}]},mediaType:{description:"media type (as defined by RFC 2046) describing the link target",type:"string"},submissionEncType:{description:"The media type in which to submit data along with the request",type:"string",default:"application/json"},submissionSchema:{description:"Schema describing the data to submit along with the request",allOf:[{$ref:"#"}]}}}},allOf:[{$ref:"http://json-schema.org/draft-06/schema#"}],properties:{additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}]},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}]},dependencies:{additionalProperties:{anyOf:[{$ref:"#"},{type:"array"}]}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}]},definitions:{additionalProperties:{$ref:"#"}},patternProperties:{additionalProperties:{$ref:"#"}},properties:{additionalProperties:{$ref:"#"}},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"},contains:{$ref:"#"},propertyNames:{$ref:"#"},base:{description:"URI Template resolved as for the 'href' keyword in the Link Description Object. The resulting URI Reference is resolved against the current URI base and sets the new URI base for URI references within the instance.",type:"string"},links:{type:"array",items:{$ref:"#/definitions/linkDescription"}},media:{type:"object",properties:{type:{description:"A media type, as described in RFC 2046",type:"string"},binaryEncoding:{description:"A content encoding scheme, as described in RFC 2045",type:"string"}}},readOnly:{description:"If true, indicates that the value of this property is controlled by the server.",type:"boolean",default:!1}},links:[{rel:"self",href:"{+%24id}"}]},S={$schema:"http://json-schema.org/draft-06/hyper-schema#",$id:"http://json-schema.org/draft-06/links#",title:"Link Description Object",type:"object",required:["href"],properties:{href:{description:"a URI template, as defined by RFC 6570",type:"string",format:"uri-template"},hrefSchema:{description:'a schema for validating user input to the URI template, where the input is in the form of a JSON object with property names matching variable names in "href"',allOf:[{$ref:"#"}]},rel:{description:"relation to the target resource of the link",type:"string"},title:{description:"a title for the link",type:"string"},targetSchema:{description:"JSON Schema describing the link target",allOf:[{$ref:"hyper-schema#"}]},mediaType:{description:"media type (as defined by RFC 2046) describing the link target",type:"string"},submissionEncType:{description:"The media type in which to submit data along with the request",type:"string",default:"application/json"},submissionSchema:{description:"Schema describing the data to submit along with the request",allOf:[{$ref:"hyper-schema#"}]}}},M=(e,t,r)=>{const i=t;i.id||(i.id=e),r&&(i.__$validationOptions=I(r)),A.cacheSchemaByUri(e,i)};function D(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}M("http://json-schema.org/draft-04/schema",{id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string"},$schema:{type:"string"},title:{type:"string"},description:{type:"string"},default:{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean",default:!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean",default:!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},enum:{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},default:{}},{version:"none"}),M("http://json-schema.org/draft-04/hyper-schema",x,{version:"none"}),M("http://json-schema.org/draft-06/schema",R,{version:"none"}),M("http://json-schema.org/draft-06/hyper-schema",P,{version:"none"}),M("http://json-schema.org/draft-06/links",S,{version:"none"});var $,N={exports:{}},C={exports:{}};function w(){return $||($=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(null==e)throw new TypeError("Expected a string but received a ".concat(e));if("String"!==e.constructor.name)throw new TypeError("Expected a string but received a ".concat(e.constructor.name))},e.exports=t.default,e.exports.default=t.default}(C,C.exports)),C.exports}var Y,U={exports:{}};function j(){return Y||(Y=1,function(e,t){function r(e){return"[object RegExp]"===Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){for(var i=0;i<t.length;i++){var n=t[i];if(e===n||r(n)&&n.test(e))return!0}return!1},e.exports=t.default,e.exports.default=t.default}(U,U.exports)),U.exports}var F,L={exports:{}};function k(){return F||(F=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r,o;(0,i.default)(e),"object"===n(t)?(r=t.min||0,o=t.max):(r=arguments[1],o=arguments[2]);var s=encodeURI(e).split(/%..|./).length-1;return s>=r&&(void 0===o||s<=o)};var r,i=(r=w())&&r.__esModule?r:{default:r};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}e.exports=t.default,e.exports.default=t.default}(L,L.exports)),L.exports}var K,W,q={exports:{}},X={exports:{}};function B(){return K||(K=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e},e.exports=t.default,e.exports.default=t.default}(X,X.exports)),X.exports}function V(){return W||(W=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){(0,r.default)(e),(t=(0,i.default)(t,o)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));!0===t.allow_wildcard&&0===e.indexOf("*.")&&(e=e.substring(2));var n=e.split("."),s=n[n.length-1];if(t.require_tld){if(n.length<2)return!1;if(!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(s))return!1;if(/\s/.test(s))return!1}if(!t.allow_numeric_tld&&/^\d+$/.test(s))return!1;return n.every(function(e){return!(e.length>63&&!t.ignore_max_length)&&(!!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(e)&&(!/[\uff01-\uff5e]/.test(e)&&(!/^-|-$/.test(e)&&!(!t.allow_underscores&&/_/.test(e)))))})};var r=n(w()),i=n(B());function n(e){return e&&e.__esModule?e:{default:e}}var o={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};e.exports=t.default,e.exports.default=t.default}(q,q.exports)),q.exports}var H,J,z={exports:{}};function G(){return H||(H=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,i.default)(t);var o=("object"===n(r)?r.version:arguments[1])||"";if(!o)return e(t,{version:4})||e(t,{version:6});if("4"===o.toString())return a.test(t);if("6"===o.toString())return l.test(t);return!1};var r,i=(r=w())&&r.__esModule?r:{default:r};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}var o="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",s="(".concat(o,"[.]){3}").concat(o),a=new RegExp("^".concat(s,"$")),d="(?:[0-9a-fA-F]{1,4})",l=new RegExp("^("+"(?:".concat(d,":){7}(?:").concat(d,"|:)|")+"(?:".concat(d,":){6}(?:").concat(s,"|:").concat(d,"|:)|")+"(?:".concat(d,":){5}(?::").concat(s,"|(:").concat(d,"){1,2}|:)|")+"(?:".concat(d,":){4}(?:(:").concat(d,"){0,1}:").concat(s,"|(:").concat(d,"){1,3}|:)|")+"(?:".concat(d,":){3}(?:(:").concat(d,"){0,2}:").concat(s,"|(:").concat(d,"){1,4}|:)|")+"(?:".concat(d,":){2}(?:(:").concat(d,"){0,3}:").concat(s,"|(:").concat(d,"){1,5}|:)|")+"(?:".concat(d,":){1}(?:(:").concat(d,"){0,4}:").concat(s,"|(:").concat(d,"){1,6}|:)|")+"(?::((?::".concat(d,"){0,5}:").concat(s,"|(?::").concat(d,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");e.exports=t.default,e.exports.default=t.default}(z,z.exports)),z.exports}function Z(){return J||(J=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if((0,r.default)(e),(t=(0,a.default)(t,l)).require_display_name||t.allow_display_name){var d=e.match(c);if(d){var E=d[1];if(e=e.replace(E,"").replace(/(^<|>$)/g,""),E.endsWith(" ")&&(E=E.slice(0,-1)),!function(e){var t=e.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;if(/[\.";<>]/.test(t)){if(t===e)return!1;if(!(t.split('"').length===t.split('\\"').length))return!1}return!0}(E))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&e.length>y)return!1;var g=e.split("@"),_=g.pop(),v=_.toLowerCase();if(t.host_blacklist.length>0&&(0,i.default)(v,t.host_blacklist))return!1;if(t.host_whitelist.length>0&&!(0,i.default)(v,t.host_whitelist))return!1;var O=g.join("@");if(t.domain_specific_validation&&("gmail.com"===v||"googlemail.com"===v)){var A=(O=O.toLowerCase()).split("+")[0];if(!(0,n.default)(A.replace(/\./g,""),{min:6,max:30}))return!1;for(var b=A.split("."),T=0;T<b.length;T++)if(!p.test(b[T]))return!1}if(!(!1!==t.ignore_max_length||(0,n.default)(O,{max:64})&&(0,n.default)(_,{max:254})))return!1;if(!(0,o.default)(_,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,s.default)(_)){if(!_.startsWith("[")||!_.endsWith("]"))return!1;var I=_.slice(1,-1);if(0===I.length||!(0,s.default)(I))return!1}}if(t.blacklisted_chars&&-1!==O.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g")))return!1;if('"'===O[0]&&'"'===O[O.length-1])return O=O.slice(1,O.length-1),t.allow_utf8_local_part?m.test(O):u.test(O);for(var x=t.allow_utf8_local_part?h:f,R=O.split("."),P=0;P<R.length;P++)if(!x.test(R[P]))return!1;return!0};var r=d(w()),i=d(j()),n=d(k()),o=d(V()),s=d(G()),a=d(B());function d(e){return e&&e.__esModule?e:{default:e}}var l={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},c=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,f=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,p=/^[a-z\d]+$/,u=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,h=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,m=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,y=254;e.exports=t.default,e.exports.default=t.default}(N,N.exports)),N.exports}var Q,ee,te=D(Z()),re=D(G()),ie={exports:{}},ne={exports:{}};function oe(){return Q||(Q=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=function(e,t){return-1!==e.indexOf(t)},e.exports=t.default,e.exports.default=t.default}(ne,ne.exports)),ne.exports}function se(){return ee||(ee=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if((0,r.default)(e),!e||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;if((t=(0,a.default)(t,c)).validate_length&&e.length>t.max_allowed_length)return!1;if(!t.allow_fragments&&(0,n.default)(e,"#"))return!1;if(!t.allow_query_components&&((0,n.default)(e,"?")||(0,n.default)(e,"&")))return!1;var d,p,u,h,m,y,E,g;E=e.split("#"),e=E.shift(),E=e.split("?");var _=(e=E.shift()).match(/^([a-z][a-z0-9+\-.]*):/i),v=!1,O=function(r){return v=!0,d=r.toLowerCase(),(!t.require_valid_protocol||-1!==t.protocols.indexOf(d))&&e.substring(_[0].length)};if(_){var A=_[1],b=e.substring(_[0].length);if("//"===b.slice(0,2)){if(!1===(e=O(A)))return!1}else{var T=b.indexOf("/"),I=-1===T?b:b.substring(0,T),x=I.indexOf("@");if(-1!==x){var R=I.substring(0,x),P=/^[a-zA-Z0-9\-_.%:]*$/.test(R),S=/%[0-9a-fA-F]{2}/.test(R);if(P&&!S){if(t.require_protocol)return!1}else if(!1===(e=O(A)))return!1}else{if(/^[0-9]/.test(b)){if(t.require_protocol)return!1}else if(!1===(e=O(A)))return!1}}}else if(t.require_protocol)return!1;if("//"===e.slice(0,2)){if(!v&&!t.allow_protocol_relative_urls)return!1;e=e.slice(2)}if(""===e)return!1;if(E=e.split("/"),""===(e=E.shift())&&!t.require_host)return!0;if((E=e.split("@")).length>1){if(t.disallow_auth)return!1;if(""===E[0])return!1;if((p=E.shift()).indexOf(":")>=0&&p.split(":").length>2)return!1;var M=p.split(":"),D=(w=2,function(e){if(Array.isArray(e))return e}(C=M)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,o,s,a=[],d=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t);else for(;!(d=(i=o.call(r)).done)&&(a.push(i.value),a.length!==t);d=!0);}catch(e){l=!0,n=e}finally{try{if(!d&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw n}}return a}}(C,w)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,t):void 0}}(C,w)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),$=D[0],N=D[1];if(""===$&&""===N)return!1}var C,w;h=E.join("@"),y=null,g=null;var Y=h.match(f);Y?(u="",g=Y[1],y=Y[2]||null):(u=(E=h.split(":")).shift(),E.length&&(y=E.join(":")));if(null!==y&&y.length>0){if(m=parseInt(y,10),!/^[0-9]+$/.test(y)||m<=0||m>65535)return!1}else if(t.require_port)return!1;if(t.host_whitelist)return(0,i.default)(u,t.host_whitelist);if(""===u&&!t.require_host)return!0;if(!((0,s.default)(u)||(0,o.default)(u,t)||g&&(0,s.default)(g,6)))return!1;if(u=u||g,t.host_blacklist&&(0,i.default)(u,t.host_blacklist))return!1;return!0};var r=d(w()),i=d(j()),n=d(oe()),o=d(V()),s=d(G()),a=d(B());function d(e){return e&&e.__esModule?e:{default:e}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}var c={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0,max_allowed_length:2084},f=/^\[([^\]]+)\](?::([0-9]+))?$/;e.exports=t.default,e.exports.default=t.default}(ie,ie.exports)),ie.exports}var ae=D(se());const de=e=>{if("string"!=typeof e)return!0;const t=/^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/.test(e);if(t){if(e.length>255)return!1;const t=e.split(".");for(let e=0;e<t.length;e++)if(t[e].length>63)return!1}return t},le=e=>"string"!=typeof e||ae.default(e),ce={date:e=>{if("string"!=typeof e)return!0;const t=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(e);return null!==t&&!(t[2]<"01"||t[2]>"12"||t[3]<"01"||t[3]>"31")},"date-time":e=>{if("string"!=typeof e)return!0;const t=e.toLowerCase().split("t");if(2!==t.length)return!1;const r=t[0],i=t[1],n=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(r);if(null===n)return!1;const o=parseInt(n[1],10),s=parseInt(n[2],10),a=parseInt(n[3],10);if(s<1||s>12||a<1||a>31)return!1;const d=new Date(o,s-1,a);if(d.getFullYear()!==o||d.getMonth()!==s-1||d.getDate()!==a)return!1;const l=/^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$/.exec(i);if(null===l)return!1;const c=parseInt(l[1],10),f=parseInt(l[2],10),p=parseInt(l[3],10);if(c>23||f>59||p>60)return!1;let u=c;if("z"!==l[5]){const e=l[5],t=/^([+-])([0-9]{2}):([0-9]{2})$/.exec(e);if(null===t)return!1;const r=t[1],i=parseInt(t[2],10),n=parseInt(t[3],10);if(i>23||n>59)return!1;u="+"===r?c-i:c+i,u=(u%24+24)%24}return 60!==p||23===u&&59===f},email:e=>"string"!=typeof e||te.default(e,{require_tld:!0}),hostname:de,"host-name":de,ipv4:e=>"string"!=typeof e||re.default(e,4),ipv6:e=>"string"!=typeof e||!e.includes("%")&&re.default(e,6),regex:e=>{if("string"!=typeof e)return!1;try{return RegExp(e),!0}catch(e){return!1}},uri:function(e){if("string"!=typeof e)return!0;if(/[^\x00-\x7F]/.test(e))return!1;const t=e.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):\/\/([^/]*)/);if(t){const e=t[2],r=e.indexOf("@");if(r>0){const t=e.substring(0,r);if(t.includes("[")||t.includes("]"))return!1}}return/^[a-zA-Z][a-zA-Z0-9+.-]*:[^"\\<>^{}^`| ]*$/.test(e)},"strict-uri":le,"uri-reference":e=>"string"!=typeof e||!/[^\x00-\x7F]/.test(e)&&/^([a-zA-Z][a-zA-Z0-9+.-]*:)?[^"\\<>^{}^`| ]*$/.test(e),"uri-template":e=>{if("string"!=typeof e)return!0;if(!/^([a-zA-Z][a-zA-Z0-9+.-]*:)?[^"\\<>^`| ]*$/.test(e))return!1;let t=!1;for(let r=0;r<e.length;r++){const i=e[r];if("{"===i){if(t)return!1;t=!0}else if("}"===i){if(!t)return!1;t=!1}}return!t},"json-pointer":e=>"string"!=typeof e||(""===e||/^(?:\/(?:[^~]|~0|~1)*)+$/.test(e)),"relative-json-pointer":e=>"string"!=typeof e||(/^\d+(#.*)?$/.test(e)||""===e),time:e=>"string"!=typeof e||/^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)(\.\d+)?$/.test(e),"idn-email":e=>"string"!=typeof e||/^[^\s@]+@[^\s@]+$/.test(e)},fe={};function pe(e){const t={...ce,...fe,...e};return f(t).filter(e=>null!=t[e])}const ue=(e,t)=>{let r,i;const n=e.length;for(r=0;r<n;r++)for(i=r+1;i<n;i++)if(l(e[r],e[i]))return t&&t.push(r,i),!1;return!0};function he(e){if(/\\[pP]{/.test(e)||/[\u{10000}-\u{10FFFF}]/u.test(e)||/\\uD[89AB][0-9A-Fa-f]{2}\\uD[CDEF][0-9A-Fa-f]{2}/.test(e))try{return{ok:!0,value:new RegExp(e,"u")}}catch(t){return{ok:!1,error:{pattern:e,message:t&&t.message?t.message:"Invalid regular expression"}}}else try{return{ok:!0,value:new RegExp(e)}}catch(t){return{ok:!1,error:{pattern:e,message:t&&t.message?t.message:"Invalid regular expression"}}}}function me(e){const t=[];let r=0;const i=e.length;let n,o;for(;r<i;)n=e.charCodeAt(r++),n>=55296&&n<=56319&&r<i?(o=e.charCodeAt(r++),56320==(64512&o)?t.push(((1023&n)<<10)+(1023&o)+65536):(t.push(n),r--)):t.push(n);return t}const ye=function(e,t){return e&&Array.isArray(e.includeErrors)&&e.includeErrors.length>0&&!t.some(function(t){return e.includeErrors.includes(t)})},Ee={id:()=>{},$ref:()=>{},$schema:()=>{},title:()=>{},description:()=>{},default:()=>{},multipleOf:function(e,t,r){if(ye(this.validateOptions,["MULTIPLE_OF"]))return;if("number"!=typeof r)return;const i=r/t.multipleOf;(!Number.isFinite(i)||Math.abs(i-Math.round(i))>=1e-10)&&e.addError("MULTIPLE_OF",[r,t.multipleOf],void 0,t,"multipleOf")},maximum:function(e,t,r){ye(this.validateOptions,["MAXIMUM","MAXIMUM_EXCLUSIVE"])||"number"==typeof r&&(!0!==t.exclusiveMaximum?r>t.maximum&&e.addError("MAXIMUM",[r,t.maximum],void 0,t,"maximum"):r>=t.maximum&&e.addError("MAXIMUM_EXCLUSIVE",[r,t.maximum],void 0,t,"maximum"))},exclusiveMaximum:function(e,t,r){if("number"==typeof t.exclusiveMaximum){if(ye(this.validateOptions,["MAXIMUM_EXCLUSIVE"]))return;if("number"!=typeof r)return;r>=t.exclusiveMaximum&&e.addError("MAXIMUM_EXCLUSIVE",[r,t.exclusiveMaximum],void 0,t,"exclusiveMaximum")}},minimum:function(e,t,r){ye(this.validateOptions,["MINIMUM","MINIMUM_EXCLUSIVE"])||"number"==typeof r&&(!0!==t.exclusiveMinimum?r<t.minimum&&e.addError("MINIMUM",[r,t.minimum],void 0,t,"minimum"):r<=t.minimum&&e.addError("MINIMUM_EXCLUSIVE",[r,t.minimum],void 0,t,"minimum"))},exclusiveMinimum:function(e,t,r){if("number"==typeof t.exclusiveMinimum){if(ye(this.validateOptions,["MINIMUM_EXCLUSIVE"]))return;if("number"!=typeof r)return;r<=t.exclusiveMinimum&&e.addError("MINIMUM_EXCLUSIVE",[r,t.exclusiveMinimum],void 0,t,"exclusiveMinimum")}},maxLength:function(e,t,r){ye(this.validateOptions,["MAX_LENGTH"])||"string"==typeof r&&me(r).length>t.maxLength&&e.addError("MAX_LENGTH",[r.length,t.maxLength],void 0,t,"maxLength")},minLength:function(e,t,r){ye(this.validateOptions,["MIN_LENGTH"])||"string"==typeof r&&me(r).length<t.minLength&&e.addError("MIN_LENGTH",[r.length,t.minLength],void 0,t,"minLength")},pattern:function(e,t,r){if(ye(this.validateOptions,["PATTERN"]))return;if("string"!=typeof r)return;const i=he(t.pattern);i.ok?i.value.test(r)||e.addError("PATTERN",[t.pattern,r],void 0,t,"pattern"):e.addError("PATTERN",[t.pattern,r,i.error.message],void 0,t,"pattern")},additionalItems:function(e,t,r){ye(this.validateOptions,["ARRAY_ADDITIONAL_ITEMS"])||Array.isArray(r)&&!1===t.additionalItems&&Array.isArray(t.items)&&r.length>t.items.length&&e.addError("ARRAY_ADDITIONAL_ITEMS",void 0,void 0,t,"additionalItems")},items:function(){},maxItems:function(e,t,r){ye(this.validateOptions,["ARRAY_LENGTH_LONG"])||Array.isArray(r)&&r.length>t.maxItems&&e.addError("ARRAY_LENGTH_LONG",[r.length,t.maxItems],void 0,t,"maxItems")},minItems:function(e,t,r){ye(this.validateOptions,["ARRAY_LENGTH_SHORT"])||Array.isArray(r)&&r.length<t.minItems&&e.addError("ARRAY_LENGTH_SHORT",[r.length,t.minItems],void 0,t,"minItems")},uniqueItems:function(e,t,r){if(!ye(this.validateOptions,["ARRAY_UNIQUE"])&&Array.isArray(r)&&!0===t.uniqueItems){const i=[];!1===ue(r,i)&&e.addError("ARRAY_UNIQUE",i,void 0,t,"uniqueItems")}},maxProperties:function(e,t,i){if(ye(this.validateOptions,["OBJECT_PROPERTIES_MAXIMUM"]))return;if(!r(i))return;const n=Object.keys(i).length;n>t.maxProperties&&e.addError("OBJECT_PROPERTIES_MAXIMUM",[n,t.maxProperties],void 0,t,"maxProperties")},minProperties:function(e,t,i){if(ye(this.validateOptions,["OBJECT_PROPERTIES_MINIMUM"]))return;if(!r(i))return;const n=Object.keys(i).length;n<t.minProperties&&e.addError("OBJECT_PROPERTIES_MINIMUM",[n,t.minProperties],void 0,t,"minProperties")},required:function(e,t,i){if(ye(this.validateOptions,["OBJECT_MISSING_REQUIRED_PROPERTY"]))return;if(!r(i))return;let n=t.required.length;for(;n--;){const r=t.required[n];g(i,r)||e.addError("OBJECT_MISSING_REQUIRED_PROPERTY",[r],void 0,t,"required")}},additionalProperties:function(e,t,r){if(void 0===t.properties&&void 0===t.patternProperties)return Ee.properties.call(this,e,t,r)},patternProperties:function(e,t,r){if(void 0===t.properties)return Ee.properties.call(this,e,t,r)},properties:function(e,t,i){if(ye(this.validateOptions,["OBJECT_ADDITIONAL_PROPERTIES"]))return;if(!r(i))return;const n=void 0!==t.properties?t.properties:{},o=void 0!==t.patternProperties?t.patternProperties:{};if(!1===t.additionalProperties){let r=Object.keys(i);const s=Object.keys(n),a=Object.keys(o);r=((e,t)=>{const r=[];let i=e.length;for(;i--;)-1===t.indexOf(e[i])&&r.push(e[i]);return r})(r,s);let d=a.length;for(;d--;){const e=he(a[d]);if(!e.ok)continue;const t=e.value;let i=r.length;for(;i--;)!0===t.test(r[i])&&r.splice(i,1)}if(r.length>0){if(Array.isArray(this.options.assumeAdditional)){let e=this.options.assumeAdditional.length;if(e)for(;e--;){const t=r.indexOf(this.options.assumeAdditional[e]);-1!==t&&r.splice(t,1)}}let i=r.length;if(i)for(;i--;)e.addError("OBJECT_ADDITIONAL_PROPERTIES",[r[i]],void 0,t,"properties")}}},dependencies:function(e,t,i){if(ye(this.validateOptions,["OBJECT_DEPENDENCY_KEY"]))return;if(!r(i))return;const n=Object.keys(t.dependencies);let o=n.length;for(;o--;){const r=n[o];if(g(i,r)){const n=t.dependencies[r];if(Array.isArray(n)){let o=n.length;for(;o--;){const s=n[o];g(i,s)||e.addError("OBJECT_DEPENDENCY_KEY",[s,r],void 0,t,"dependencies")}}else ve.call(this,e,n,i)}}},enum:function(e,t,r){if(ye(this.validateOptions,["ENUM_CASE_MISMATCH","ENUM_MISMATCH"]))return;let i=!1,n=!1,o=t.enum.length;for(;o--;){if(l(r,t.enum[o])){i=!0;break}l(r,t.enum[o],{caseInsensitiveComparison:!0})&&(n=!0)}if(!1===i){const i=n&&this.options.enumCaseInsensitiveComparison?"ENUM_CASE_MISMATCH":"ENUM_MISMATCH";e.addError(i,[JSON.stringify(r)],void 0,t,"enum")}},type:function(e,r,i){if(ye(this.validateOptions,["INVALID_TYPE"]))return;const n=t(i);"string"==typeof r.type?n===r.type||"integer"===n&&"number"===r.type||e.addError("INVALID_TYPE",[r.type,n],void 0,r,"type"):-1!==r.type.indexOf(n)||"integer"===n&&-1!==r.type.indexOf("number")||e.addError("INVALID_TYPE",[JSON.stringify(r.type),n],void 0,r,"type")},allOf:function(e,t,r){let i=t.allOf.length;for(;i--;){const n=ve.call(this,e,t.allOf[i],r);if(this.options.breakOnFirstError&&!1===n)break}},anyOf:function(e,t,r){const i=[];let n=t.anyOf.length;for(;n--;){const o=new E(e);i.push(o),ve.call(this,o,t.anyOf[n],r)}const o=e.asyncTasks.length;for(const t of i)e.asyncTasks.push(...t.asyncTasks);if(e.asyncTasks.length>o){const r=v(e.path);e.addAsyncTask(e=>{setTimeout(()=>e(null),0)},[],()=>{const n=e.path;e.path=r;let o=!1;for(const e of i)if(0===e.errors.length){o=!0;break}!1===o&&e.addError("ANY_OF_MISSING",void 0,i,t,"anyOf"),e.path=n})}else{let r=!1;for(const e of i)if(0===e.errors.length){r=!0;break}!1===r&&e.addError("ANY_OF_MISSING",void 0,i,t,"anyOf")}},oneOf:function(e,t,r){const i=[];let n=t.oneOf.length;for(;n--;){const o=new E(e);i.push(o),ve.call(this,o,t.oneOf[n],r)}const o=e.asyncTasks.length;for(const t of i)e.asyncTasks.push(...t.asyncTasks);if(e.asyncTasks.length>o){const r=v(e.path);e.addAsyncTask(e=>{setTimeout(()=>e(null),0)},[],()=>{const n=e.path;e.path=r;let o=0;for(const e of i)0===e.errors.length&&o++;0===o?e.addError("ONE_OF_MISSING",void 0,i,t,"oneOf"):o>1&&e.addError("ONE_OF_MULTIPLE",void 0,void 0,t,"oneOf"),e.path=n})}else{let r=0;for(const e of i)0===e.errors.length&&r++;0===r?e.addError("ONE_OF_MISSING",void 0,i,t,"oneOf"):r>1&&e.addError("ONE_OF_MULTIPLE",void 0,void 0,t,"oneOf")}},not:function(e,t,r){const i=new E(e);!0===ve.call(this,i,t.not,r)&&e.addError("NOT_PASSED",void 0,void 0,t,"not")},definitions:function(){},format:function(e,r,i){var n;const o=(n=this.options,{...ce,...n?.strictUris?{uri:le}:{},...fe,...n?.customFormats||{}})[r.format];if("function"==typeof o){if(ye(this.validateOptions,["INVALID_FORMAT"]))return;if(e.hasError("INVALID_TYPE",[r.type,t(i)]))return;if(2===o.length){const t=v(e.path);e.addAsyncTask(o,[i],function(n){if(!0!==n){const n=e.path;e.path=t,e.addError("INVALID_FORMAT",[r.format,JSON.stringify(i)],void 0,r,"format"),e.path=n}})}else{const t=o.call(this,i);if(t instanceof Promise){const n=v(e.path),o=this.options.asyncTimeout||2e3;e.addAsyncTask(async e=>{try{const r=new Promise((e,t)=>{setTimeout(()=>t(new Error("Async timeout")),o)});e(await Promise.race([t,r]))}catch(t){if("Async timeout"===t.message)return;e(!1)}},[],function(t){if(!0!==t){const t=e.path;e.path=n,e.addError("INVALID_FORMAT",[r.format,JSON.stringify(i)],void 0,r,"format"),e.path=t}})}else!0!==t&&e.addError("INVALID_FORMAT",[r.format,JSON.stringify(i)],void 0,r,"format")}}else!0!==this.options.ignoreUnknownFormats&&e.addError("UNKNOWN_FORMAT",[r.format],void 0,r,"format")},$id:()=>{},const:function(e,t,r){const i=t.const;!1===l(r,i)&&e.addError("CONST",[JSON.stringify(i)],void 0,t,void 0)},contains:function(e,t,r){if(ye(this.validateOptions,["CONTAINS"]))return;if(!Array.isArray(r))return;const i=t.contains;if(void 0===i)return;const n=[];let o=r.length;for(;o--;){const t=new E(e);n.push(t),ve.call(this,t,i,r[o])}const s=e.asyncTasks.length;for(const t of n)e.asyncTasks.push(...t.asyncTasks);const a=e.asyncTasks.length>s,d=()=>{let r=!1;for(const e of n)if(0===e.errors.length){r=!0;break}r||e.addError("CONTAINS",void 0,n,t,void 0)};if(a){const t=v(e.path);return void e.addAsyncTask(e=>{setTimeout(()=>e(null),0)},[],()=>{const r=e.path;e.path=t,d(),e.path=r})}d()},examples:()=>{},propertyNames:function(e,t,i){if(ye(this.validateOptions,["PROPERTY_NAMES"]))return;if(!r(i))return;const n=t.propertyNames;if(void 0===n)return;const o=Object.keys(i),s=[];for(const t of o){const r=new E(e);s.push(r),ve.call(this,r,n,t)}const a=e.asyncTasks.length;for(const t of s)e.asyncTasks.push(...t.asyncTasks);const d=e.asyncTasks.length>a,l=()=>{for(let r=0;r<o.length;r++)s[r].errors.length>0&&e.addError("PROPERTY_NAMES",[o[r]],s[r],t,void 0)};if(d){const t=v(e.path);return void e.addAsyncTask(e=>{setTimeout(()=>e(null),0)},[],()=>{const r=e.path;e.path=t,l(),e.path=r})}l()}},ge=function(e,t,r){let i=r.length;if(Array.isArray(t.items))for(;i--;)i<t.items.length?(e.path.push(i),ve.call(this,e,t.items[i],r[i]),e.path.pop()):"object"==typeof t.additionalItems&&(e.path.push(i),ve.call(this,e,t.additionalItems,r[i]),e.path.pop());else if("object"==typeof t.items||"boolean"==typeof t.items)for(;i--;)e.path.push(i),e.schemaPath.push("items"),ve.call(this,e,t.items,r[i]),e.schemaPath.pop(),e.path.pop()},_e=function(e,t,r){let i=t.additionalProperties;!0!==i&&void 0!==i||(i={});const n=t.properties?Object.keys(t.properties):[],o=t.patternProperties?Object.keys(t.patternProperties):[],s=Object.keys(r);let a=s.length;for(;a--;){const d=s[a],l=r[d],c=[];-1!==n.indexOf(d)&&c.push(t.properties[d]);let f=o.length;for(;f--;){const e=o[f],r=he(e);r.ok&&!0===r.value.test(d)&&c.push(t.patternProperties[e])}for(0===c.length&&!1!==i&&c.push(i),f=c.length;f--;)e.path.push(d),-1!==n.indexOf(d)?(e.schemaPath.push("properties"),e.schemaPath.push(d)):e.schemaPath.push("additionalProperties"),ve.call(this,e,c[f],l),e.path.pop(),e.schemaPath.pop(),-1!==n.indexOf(d)&&e.schemaPath.pop()}};function ve(e,i,n){if(e.commonErrorMessage="JSON_OBJECT_VALIDATION_FAILED",!0===i)return!0;if(!1===i)return e.addError("SCHEMA_IS_FALSE",[],void 0,i),!1;if(!r(i))return e.addError("SCHEMA_NOT_AN_OBJECT",[t(i)],void 0,i),!1;let o=Object.keys(i);if(0===o.length)return!0;let s=!1;if(e.rootSchema||(e.rootSchema=i,s=!0),void 0!==i.$ref){let t=99;for(;i.$ref&&t>0;){if(!i.__$refResolved){e.addError("REF_UNRESOLVED",[i.$ref],void 0,i);break}if(i.__$refResolved===i)break;i=i.__$refResolved,o=Object.keys(i),t--}if(0===t)throw new Error("Circular dependency by $ref references!");e.schemaPath=[]}if(i.type&&(o.splice(o.indexOf("type"),1),e.schemaPath.push("type"),Ee.type.call(this,e,i,n),e.schemaPath.pop(),e.errors.length&&this.options.breakOnFirstError))return!1;let a=o.length;for(;a--&&!(Ee[o[a]]&&(Ee[o[a]].call(this,e,i,n),e.errors.length&&this.options.breakOnFirstError)););return 0!==e.errors.length&&!1!==this.options.breakOnFirstError||(Array.isArray(n)?ge.call(this,e,i,n):r(n)&&_e.call(this,e,i,n)),"function"==typeof this.options.customValidator&&this.options.customValidator.call(this,e,i,n),s&&(e.rootSchema=void 0),0===e.errors.length}let Oe;function Ae(){return Oe}const be=["enum","const","default","examples"],Te=(e,t,r,i)=>{if(t=t||[],r=r||[],i=i||[],"object"!=typeof e||null===e)return t;const o="string"==typeof e.$ref&&void 0===e.__$refResolved;let s=!1;const a=0===r.length;let d,l=n(e);if("string"!=typeof e.id||!y(e.id)||l&&y(l)||(l=e.id),"string"==typeof l&&(a||!o)){const e=r.length>0?r[r.length-1]:void 0;r.push(xe(e,l)),s=!0}if(o&&t.push({ref:Ie(r[r.length-1],e.$ref),key:"$ref",obj:e,path:i.slice(0)}),"string"==typeof e.$schema&&void 0===e.__$schemaResolved&&t.push({ref:Ie(r[r.length-1],e.$schema),key:"$schema",obj:e,path:i.slice(0)}),Array.isArray(e))for(d=e.length;d--;)i.push(d),Te(e[d],t,r,i),i.pop();else{const n=Object.keys(e);for(d=n.length;d--;)0===n[d].indexOf("__$")||be.includes(n[d])||(i.push(n[d]),Te(e[n[d]],t,r,i),i.pop())}return s&&r.pop(),t},Ie=(e,t)=>{if(y(t))return t;const r=e??"";if("#"===t[0]){const e=r.indexOf("#");return(-1===e?r:r.slice(0,e))+t}if(!r)return t;const i=r.indexOf("#"),n=-1===i?r:r.slice(0,i);if(y(n))try{return new URL(t,n).toString()}catch{}let o=n;return o.endsWith("/")||(o=o.replace(/[^/]*$/,"")),o+t},xe=(e,t)=>{if(y(t))return t;const r=e??"";if("#"!==t[0]&&!t.includes("/")&&!t.includes(".")&&!t.includes("#")){const e=r.indexOf("#");return(-1===e?r:r.slice(0,e))+"#"+t}return Ie(e,t)};class Re{validator;constructor(e){this.validator=e}collectAndCacheIds(e){const t=(e=>{const t=[],r=["enum","const","default","examples"];return function e(i,o){if("object"!=typeof i||null==i)return;let s=!1;const a=n(i);if("string"==typeof a){let e=y(a)?"absolute":"relative";0===o.length&&(e="root");const r={id:a,type:e,obj:i};if("absolute"===e||"root"===e&&y(a))r.absoluteUri=a;else if("root"===e&&"string"==typeof i.id&&y(i.id)&&i.id!==a)r.absoluteUri=xe(i.id,a);else if("relative"===e&&(r.absoluteParent=o.filter(e=>"absolute"===e.type||"root"===e.type&&e.absoluteUri).slice(-1)[0],r.absoluteParent)){const e=r.absoluteParent.absoluteUri||r.absoluteParent.id;r.absoluteUri=e.split("/").slice(0,-1).concat(r.id).join("/")}t.push(r),o.push(r),s=!0}if(Array.isArray(i))for(const t of i)e(t,o);else for(const t of Object.keys(i))0===t.indexOf("__$")||r.includes(t)||e(i[t],o);s&&o.pop()}(e,[]),t})(e);for(const e of t)e.absoluteUri?this.validator.scache.cacheSchemaByUri(e.absoluteUri,e.obj):"root"===e.type&&this.validator.scache.cacheSchemaByUri(e.id,e.obj)}compileSchema(e,t,r){if(e.commonErrorMessage="SCHEMA_COMPILATION_FAILED","string"==typeof t){const r=this.validator.scache.getSchemaByUri(e,t);if(!r)return e.addError("SCHEMA_NOT_REACHABLE",[t]),!1;t=r}if(Array.isArray(t))return r?.noCache||t.forEach(e=>this.collectAndCacheIds(e)),this.compileArrayOfSchemas(e,t);if("boolean"==typeof t)return!0;if(r?.noCache||this.collectAndCacheIds(t),t.__$compiled&&t.id&&!1===this.validator.scache.checkCacheForUri(t.id)&&(t.__$compiled=void 0),t.__$compiled)return!0;t.$schema||"none"===this.validator.options.version||(t.$schema=this.validator.getDefaultSchemaId()),t.id&&"string"==typeof t.id&&!r?.noCache&&this.validator.scache.cacheSchemaByUri(t.id,t);let i=!1;e.rootSchema||(e.rootSchema=t,i=!0);const n=e.isValid();delete t.__$missingReferences;const o=Te(t);let s=o.length;for(;s--;){const r=o[s];let i=this.validator.scache.getSchemaByUri(e,r.ref,t);if(!i){const n=Ae();if(n){const o=m(r.ref),s=n(o);if(s){s.id=o;const n=new E(e);this.compileSchema(n,s)?i=this.validator.scache.getSchemaByUri(e,r.ref,t):e.errors=e.errors.concat(n.errors)}}}if(!i){const i=e.hasError("REMOTE_NOT_VALID",[r.ref]),o=y(r.ref);let s=!1;const a=!0===this.validator.options.ignoreUnresolvableReferences;o&&(s=this.validator.scache.checkCacheForUri(r.ref)),i||a&&o||s||(e.path.push(...r.path),e.addError("UNRESOLVABLE_REFERENCE",[r.ref]),e.path=e.path.slice(0,-r.path.length),n&&(t.__$missingReferences=t.__$missingReferences||[],t.__$missingReferences.push(r)))}r.obj[`__${r.key}Resolved`]=i}const a=e.isValid();return a&&(t.__$compiled=!0),i&&(e.rootSchema=void 0),a}compileArrayOfSchemas(e,t){let r,i=0;do{let n=e.errors.length;for(;n--;)"UNRESOLVABLE_REFERENCE"===e.errors[n].code&&e.errors.splice(n,1);for(r=i,i=this.compileArrayOfSchemasLoop(e,t),n=t.length;n--;){const e=t[n];if(e.__$missingReferences){let r=e.__$missingReferences.length;for(;r--;){const i=e.__$missingReferences[r],n=t.find(e=>e.id===i.ref);n&&(i.obj[`__${i.key}Resolved`]=n,e.__$missingReferences.splice(r,1))}0===e.__$missingReferences.length&&delete e.__$missingReferences}}}while(i!==t.length&&i!==r);return e.isValid()}compileArrayOfSchemasLoop(e,t){let r=t.length,i=0;for(;r--;){const n=new E(e);this.compileSchema(n,t[r])&&i++,e.errors=e.errors.concat(n.errors)}return i}}const Pe={$ref:function(e,t){"string"!=typeof t.$ref&&e.addError("KEYWORD_TYPE_EXPECTED",["$ref","string"],void 0,t,"$ref")},$schema:function(e,t){"string"!=typeof t.$schema&&e.addError("KEYWORD_TYPE_EXPECTED",["$schema","string"],void 0,t,"$schema")},multipleOf:function(e,t){"number"!=typeof t.multipleOf?e.addError("KEYWORD_TYPE_EXPECTED",["multipleOf","number"],void 0,t,"multipleOf"):t.multipleOf<=0&&e.addError("KEYWORD_MUST_BE",["multipleOf","strictly greater than 0"],void 0,t,"multipleOf")},maximum:function(e,t){"number"!=typeof t.maximum&&e.addError("KEYWORD_TYPE_EXPECTED",["maximum","number"],void 0,t,"maximum")},exclusiveMaximum:function(e,t){"draft-04"===e.options.version?"boolean"!=typeof t.exclusiveMaximum?e.addError("KEYWORD_TYPE_EXPECTED",["exclusiveMaximum","boolean"],void 0,t,"exclusiveMaximum"):void 0===t.maximum&&e.addError("KEYWORD_DEPENDENCY",["exclusiveMaximum","maximum"],void 0,t,"exclusiveMaximum"):"boolean"!=typeof t.exclusiveMaximum&&"number"!=typeof t.exclusiveMaximum&&e.addError("KEYWORD_TYPE_EXPECTED",["exclusiveMaximum",["boolean","number"]],void 0,t,"exclusiveMaximum")},minimum:function(e,t){"number"!=typeof t.minimum&&e.addError("KEYWORD_TYPE_EXPECTED",["minimum","number"],void 0,t,"minimum")},exclusiveMinimum:function(e,t){"draft-04"===e.options.version?"boolean"!=typeof t.exclusiveMinimum?e.addError("KEYWORD_TYPE_EXPECTED",["exclusiveMinimum","boolean"],void 0,t,"exclusiveMinimum"):void 0===t.minimum&&e.addError("KEYWORD_DEPENDENCY",["exclusiveMinimum","minimum"],void 0,t,"exclusiveMinimum"):"boolean"!=typeof t.exclusiveMinimum&&"number"!=typeof t.exclusiveMinimum&&e.addError("KEYWORD_TYPE_EXPECTED",["exclusiveMinimum",["boolean","number"]],void 0,t,"exclusiveMinimum")},maxLength:function(e,t){i(t.maxLength)?t.maxLength<0&&e.addError("KEYWORD_MUST_BE",["maxLength","greater than, or equal to 0"],void 0,t,"maxLength"):e.addError("KEYWORD_TYPE_EXPECTED",["maxLength","integer"],void 0,t,"maxLength")},minLength:function(e,t){i(t.minLength)?t.minLength<0&&e.addError("KEYWORD_MUST_BE",["minLength","greater than, or equal to 0"],void 0,t,"minLength"):e.addError("KEYWORD_TYPE_EXPECTED",["minLength","integer"],void 0,t,"minLength")},pattern:function(e,t){if("string"!=typeof t.pattern)e.addError("KEYWORD_TYPE_EXPECTED",["pattern","string"],void 0,t,"pattern");else{const r=he(t.pattern);r.ok||e.addError("KEYWORD_PATTERN",["pattern",t.pattern,r.error.message],void 0,t,"pattern")}},additionalItems:function(e,t){"boolean"==typeof t.additionalItems||r(t.additionalItems)?r(t.additionalItems)&&(e.path.push("additionalItems"),this.validateSchema(e,t.additionalItems),e.path.pop()):e.addError("KEYWORD_TYPE_EXPECTED",["additionalItems",["boolean","object"]],void 0,t,"additionalItems")},items:function(e,t){if(Array.isArray(t.items)){let r=t.items.length;for(;r--;)e.path.push("items"),e.path.push(r),this.validateSchema(e,t.items[r]),e.path.pop(),e.path.pop()}else r(t.items)||"draft-04"!==e.options.version&&"boolean"==typeof t.items?(e.path.push("items"),this.validateSchema(e,t.items),e.path.pop()):e.addError("KEYWORD_TYPE_EXPECTED",["items","draft-04"===e.options.version?["array","object"]:["array","object","boolean"]],void 0,t,"items");!0===this.options.forceAdditional&&void 0===t.additionalItems&&Array.isArray(t.items)&&e.addError("KEYWORD_UNDEFINED_STRICT",["additionalItems"],void 0,t,"additionalItems"),this.options.assumeAdditional&&void 0===t.additionalItems&&Array.isArray(t.items)&&(t.additionalItems=!1)},maxItems:function(e,t){"number"!=typeof t.maxItems?e.addError("KEYWORD_TYPE_EXPECTED",["maxItems","integer"],void 0,t,"maxItems"):t.maxItems<0&&e.addError("KEYWORD_MUST_BE",["maxItems","greater than, or equal to 0"],void 0,t,"maxItems")},minItems:function(e,t){i(t.minItems)?t.minItems<0&&e.addError("KEYWORD_MUST_BE",["minItems","greater than, or equal to 0"],void 0,t,"minItems"):e.addError("KEYWORD_TYPE_EXPECTED",["minItems","integer"],void 0,t,"minItems")},uniqueItems:function(e,t){"boolean"!=typeof t.uniqueItems&&e.addError("KEYWORD_TYPE_EXPECTED",["uniqueItems","boolean"],void 0,t,"uniqueItems")},maxProperties:function(e,t){i(t.maxProperties)?t.maxProperties<0&&e.addError("KEYWORD_MUST_BE",["maxProperties","greater than, or equal to 0"],void 0,t,"maxProperties"):e.addError("KEYWORD_TYPE_EXPECTED",["maxProperties","integer"],void 0,t,"maxProperties")},minProperties:function(e,t){i(t.minProperties)?t.minProperties<0&&e.addError("KEYWORD_MUST_BE",["minProperties","greater than, or equal to 0"],void 0,t,"minProperties"):e.addError("KEYWORD_TYPE_EXPECTED",["minProperties","integer"],void 0,t,"minProperties")},required:function(e,t){if(Array.isArray(t.required))if("draft-04"===e.options.version&&0===t.required.length)e.addError("KEYWORD_MUST_BE",["required","an array with at least one element"],void 0,t,"required");else{let r=t.required.length;for(;r--;)"string"!=typeof t.required[r]&&e.addError("KEYWORD_VALUE_TYPE",["required","string"],void 0,t,"required");!1===ue(t.required)&&e.addError("KEYWORD_MUST_BE",["required","an array with unique items"],void 0,t,"required")}else e.addError("KEYWORD_TYPE_EXPECTED",["required","array"],void 0,t,"required")},additionalProperties:function(e,t){"boolean"==typeof t.additionalProperties||r(t.additionalProperties)?r(t.additionalProperties)&&(e.path.push("additionalProperties"),this.validateSchema(e,t.additionalProperties),e.path.pop()):e.addError("KEYWORD_TYPE_EXPECTED",["additionalProperties",["boolean","object"]],void 0,t,"additionalProperties")},properties:function(e,t){if(!r(t.properties))return void e.addError("KEYWORD_TYPE_EXPECTED",["properties","object"],void 0,t,"properties");const i=Object.keys(t.properties);let n=i.length;for(;n--;){const r=i[n],o=t.properties[r];e.path.push("properties"),e.path.push(r),this.validateSchema(e,o),e.path.pop(),e.path.pop()}!0===this.options.forceAdditional&&void 0===t.additionalProperties&&e.addError("KEYWORD_UNDEFINED_STRICT",["additionalProperties"],void 0,t,"additionalProperties"),this.options.assumeAdditional&&void 0===t.additionalProperties&&(t.additionalProperties=!1),!0===this.options.forceProperties&&0===i.length&&e.addError("CUSTOM_MODE_FORCE_PROPERTIES",["properties"],void 0,t,"properties")},patternProperties:function(e,t){if(!r(t.patternProperties))return void e.addError("KEYWORD_TYPE_EXPECTED",["patternProperties","object"],void 0,t,"patternProperties");const i=Object.keys(t.patternProperties);let n=i.length;for(;n--;){const r=i[n],o=t.patternProperties[r],s=he(r);s.ok||e.addError("KEYWORD_PATTERN",["patternProperties",r,s.error.message],void 0,t,"patternProperties"),e.path.push("patternProperties"),e.path.push(r),this.validateSchema(e,o),e.path.pop(),e.path.pop()}!0===this.options.forceProperties&&0===i.length&&e.addError("CUSTOM_MODE_FORCE_PROPERTIES",["patternProperties"],void 0,t,"patternProperties")},dependencies:function(e,t){if(r(t.dependencies)){const i=Object.keys(t.dependencies);let n=i.length;for(;n--;){const o=i[n],s=t.dependencies[o];if(r(s)||"draft-04"!==e.options.version&&"boolean"==typeof s)e.path.push("dependencies"),e.path.push(o),this.validateSchema(e,s),e.path.pop(),e.path.pop();else if(Array.isArray(s)){const r=s;let i=r.length;for("draft-04"===e.options.version&&0===i&&e.addError("KEYWORD_MUST_BE",["dependencies","not empty array"],void 0,t,"dependencies");i--;)"string"!=typeof r[i]&&e.addError("KEYWORD_VALUE_TYPE",["dependencies","string"],void 0,t,"dependencies");!1===ue(r)&&e.addError("KEYWORD_MUST_BE",["dependencies","an array with unique items"],void 0,t,"dependencies")}else e.addError("KEYWORD_VALUE_TYPE",["dependencies","draft-04"===e.options.version?"object or array":"boolean, object or array"],void 0,t,"dependencies")}}else e.addError("KEYWORD_TYPE_EXPECTED",["dependencies","object"],void 0,t,"dependencies")},enum:function(e,t){!1===Array.isArray(t.enum)?e.addError("KEYWORD_TYPE_EXPECTED",["enum","array"],void 0,t,"enum"):0===t.enum.length?e.addError("KEYWORD_MUST_BE",["enum","an array with at least one element"],void 0,t,"enum"):!1===ue(t.enum)&&e.addError("KEYWORD_MUST_BE",["enum","an array with unique elements"],void 0,t,"enum")},type:function(e,t){const r=["array","boolean","integer","number","null","object","string"],i=r.join(","),n=Array.isArray(t.type);if(Array.isArray(t.type)){let n=t.type.length;for(;n--;)-1===r.indexOf(t.type[n])&&e.addError("KEYWORD_TYPE_EXPECTED",["type",i],void 0,t,"type");!1===ue(t.type)&&e.addError("KEYWORD_MUST_BE",["type","an object with unique properties"],void 0,t,"type")}else"string"==typeof t.type?-1===r.indexOf(t.type)&&e.addError("KEYWORD_TYPE_EXPECTED",["type",i],void 0,t,"type"):e.addError("KEYWORD_TYPE_EXPECTED",["type",["string","array"]],void 0,t,"type");!0===this.options.noEmptyStrings&&("string"===t.type||n&&-1!==t.type.indexOf("string"))&&void 0===t.minLength&&void 0===t.enum&&void 0===t.format&&(t.minLength=1),!0===this.options.noEmptyArrays&&("array"===t.type||n&&-1!==t.type.indexOf("array"))&&void 0===t.minItems&&(t.minItems=1),!0===this.options.forceProperties&&("object"===t.type||n&&-1!==t.type.indexOf("object"))&&void 0===t.properties&&void 0===t.patternProperties&&e.addError("KEYWORD_UNDEFINED_STRICT",["properties"],void 0,t,"properties"),!0===this.options.forceItems&&("array"===t.type||n&&-1!==t.type.indexOf("array"))&&void 0===t.items&&e.addError("KEYWORD_UNDEFINED_STRICT",["items"],void 0,t,"items"),!0===this.options.forceMinItems&&("array"===t.type||n&&-1!==t.type.indexOf("array"))&&void 0===t.minItems&&e.addError("KEYWORD_UNDEFINED_STRICT",["minItems"],void 0,t,"minItems"),!0===this.options.forceMaxItems&&("array"===t.type||n&&-1!==t.type.indexOf("array"))&&void 0===t.maxItems&&e.addError("KEYWORD_UNDEFINED_STRICT",["maxItems"],void 0,t,"maxItems"),!0===this.options.forceMinLength&&("string"===t.type||n&&-1!==t.type.indexOf("string"))&&void 0===t.minLength&&void 0===t.format&&void 0===t.enum&&void 0===t.pattern&&e.addError("KEYWORD_UNDEFINED_STRICT",["minLength"],void 0,t,"minLength"),!0===this.options.forceMaxLength&&("string"===t.type||n&&-1!==t.type.indexOf("string"))&&void 0===t.maxLength&&void 0===t.format&&void 0===t.enum&&void 0===t.pattern&&e.addError("KEYWORD_UNDEFINED_STRICT",["maxLength"],void 0,t,"maxLength")},allOf:function(e,t){if(!1===Array.isArray(t.allOf))e.addError("KEYWORD_TYPE_EXPECTED",["allOf","array"],void 0,t,"allOf");else if(0===t.allOf.length)e.addError("KEYWORD_MUST_BE",["allOf","an array with at least one element"],void 0,t,"allOf");else{let r=t.allOf.length;for(;r--;)e.path.push("allOf"),e.path.push(r),this.validateSchema(e,t.allOf[r]),e.path.pop(),e.path.pop()}},anyOf:function(e,t){if(!1===Array.isArray(t.anyOf))e.addError("KEYWORD_TYPE_EXPECTED",["anyOf","array"],void 0,t,"anyOf");else if(0===t.anyOf.length)e.addError("KEYWORD_MUST_BE",["anyOf","an array with at least one element"],void 0,t,"anyOf");else{let r=t.anyOf.length;for(;r--;)e.path.push("anyOf"),e.path.push(r),this.validateSchema(e,t.anyOf[r]),e.path.pop(),e.path.pop()}},oneOf:function(e,t){if(!1===Array.isArray(t.oneOf))e.addError("KEYWORD_TYPE_EXPECTED",["oneOf","array"],void 0,t,"oneOf");else if(0===t.oneOf.length)e.addError("KEYWORD_MUST_BE",["oneOf","an array with at least one element"],void 0,t,"oneOf");else{let r=t.oneOf.length;for(;r--;)e.path.push("oneOf"),e.path.push(r),this.validateSchema(e,t.oneOf[r]),e.path.pop(),e.path.pop()}},not:function(e,t){const i=t.not;("draft-04"===e.options.version?r(i):"boolean"==typeof i||r(i))?(e.path.push("not"),this.validateSchema(e,i),e.path.pop()):e.addError("KEYWORD_TYPE_EXPECTED",["not","draft-04"===e.options.version?"object":["boolean","object"]],void 0,t,"not")},definitions:function(e,t){if(r(t.definitions)){const r=Object.keys(t.definitions);let i=r.length;for(;i--;){const n=r[i],o=t.definitions[n];e.path.push("definitions"),e.path.push(n),this.validateSchema(e,o),e.path.pop(),e.path.pop()}}else e.addError("KEYWORD_TYPE_EXPECTED",["definitions","object"],void 0,t,"definitions")},format:function(e,t){var r;"string"!=typeof t.format?e.addError("KEYWORD_TYPE_EXPECTED",["format","string"],void 0,t,"format"):(r=t.format,pe(this.options.customFormats).includes(r)||!0===this.options.ignoreUnknownFormats||e.addError("UNKNOWN_FORMAT",[t.format],void 0,t,"format"))},id:function(e,t){"string"!=typeof t.id&&e.addError("KEYWORD_TYPE_EXPECTED",["id","string"],void 0,t,"id")},title:function(e,t){"string"!=typeof t.title&&e.addError("KEYWORD_TYPE_EXPECTED",["title","string"],void 0,t,"title")},description:function(e,t){"string"!=typeof t.description&&e.addError("KEYWORD_TYPE_EXPECTED",["description","string"],void 0,t,"description")},default:function(){}};class Se{validator;constructor(e){this.validator=e}get options(){return this.validator.options}validateArrayOfSchemas(e,t){let r=t.length;for(;r--;)this.validateSchema(e,t[r]);return e.isValid()}validateSchema(e,t){if(e.commonErrorMessage="SCHEMA_VALIDATION_FAILED",Array.isArray(t))return this.validateArrayOfSchemas(e,t);if("boolean"==typeof t)return!0;if(t.__$validated)return!0;const r=t.$schema&&n(t)!==t.$schema;if(r)if(t.__$schemaResolved&&t.__$schemaResolved!==t){const r=new E(e);!1===ve.call(this.validator,r,t.__$schemaResolved,t)&&e.addError("PARENT_SCHEMA_VALIDATION_FAILED",void 0,r,t,"$schema")}else!0!==this.validator.options.ignoreUnresolvableReferences&&e.addError("REF_UNRESOLVED",[t.$schema],void 0,t,"$schema");if(!0===this.validator.options.noTypeless){if(void 0!==t.type){let e=[];Array.isArray(t.anyOf)&&(e=e.concat(t.anyOf)),Array.isArray(t.oneOf)&&(e=e.concat(t.oneOf)),Array.isArray(t.allOf)&&(e=e.concat(t.allOf)),e.forEach(function(e){e.type||(e.type=t.type)})}void 0===t.enum&&void 0===t.type&&void 0===t.anyOf&&void 0===t.oneOf&&void 0===t.not&&void 0===t.$ref&&e.addError("KEYWORD_UNDEFINED_STRICT",["type"],void 0,t,"type")}const i=Object.keys(t);let o=i.length;for(;o--;){const n=i[o];0!==n.indexOf("__")&&(Object.prototype.hasOwnProperty.call(Pe,n)?Pe[n].call(this,e,t):r||!0===this.validator.options.noExtraKeywords&&e.addError("KEYWORD_UNEXPECTED",[n],void 0,t,void 0))}if(!0===this.validator.options.pedanticCheck){if(t.enum){const r=v(t);for(delete r.enum,delete r.default,e.path.push("enum"),o=t.enum.length;o--;)e.path.push(o),ve.call(this.validator,e,r,t.enum[o]),e.path.pop();e.path.pop()}t.default&&(e.path.push("default"),ve.call(this.validator,e,t,t.default),e.path.pop())}const s=e.isValid();return s&&(t.__$validated=!0),s}}class Me{scache;sc;sv;validateOptions={};options;constructor(e){if(!e?.__called_from_factory__)throw new Error("do not use new ZSchema(), use ZSchema.create() instead");delete e.__called_from_factory__,this.scache=new A(this),this.sc=new Re(this),this.sv=new Se(this),this.options=I(e)}getDefaultSchemaId(){return this.options.version&&"none"!==this.options.version?b[this.options.version]:b[T.version]}_validate(e,i,n,o){if("function"==typeof n&&(o=n,n={}),n||(n={}),this.validateOptions=n,"string"!=typeof i&&"boolean"!=typeof i&&!r(i)){const e=new Error("Invalid .validate call - schema must be a string or object but "+t(i)+" was passed!");if(o)return void setTimeout(function(){o(e,!1)},0);throw e}let s=!1;const a=new E(this.options,n);let l;if(a.json=e,"string"==typeof i){const e=i;if(l=this.scache.getSchema(a,e),!l){const t=new Error("Schema with id '"+e+"' wasn't found in the validator cache!");if(o)return void setTimeout(function(){o(t,!1)},0);throw t}}else l=this.scache.getSchema(a,i);let c=!1;s||(c=this.sc.compileSchema(a,l)),c||(s=!0);let f=!1;if(s||(f=this.sv.validateSchema(a,l)),f||(s=!0),n.schemaPath&&(a.rootSchema=l,l=p(l,n.schemaPath),!l)){const e=new Error("Schema path '"+n.schemaPath+"' wasn't found in the schema!");if(o)return void setTimeout(function(){o(e,!1)},0);throw e}if(s||ve.call(this,a,l,e),!o){if(a.asyncTasks.length>0)throw new Error("This validation has async tasks and cannot be done in sync mode, please provide callback argument.");if(!a.isValid())throw d({message:a.commonErrorMessage,details:a.errors});return!0}a.processAsyncTasks(this.options.asyncTimeout,o)}_validateSchema(e){if(Array.isArray(e)&&0===e.length)throw new Error(".compileSchema was called with an empty array");const t=new E(this.options);if(Array.isArray(e)){const r=this.scache.getSchema(t,e);this.sc.compileSchema(t,r)&&this.sv.validateSchema(t,r)}else{const r=this.scache.getSchema(t,e);this.sc.compileSchema(t,r)&&this.sv.validateSchema(t,r)}if(!t.isValid())throw d({message:t.commonErrorMessage,details:t.errors});return!0}registerFormat(e,t){this.options.customFormats||(this.options.customFormats={}),this.options.customFormats[e]=t}unregisterFormat(e){this.options.customFormats||(this.options.customFormats={}),this.options.customFormats[e]=null}getRegisteredFormats(){return f(this.options.customFormats||{}).filter(e=>null!=this.options.customFormats?.[e])}getSupportedFormats(){return pe(this.options.customFormats)}setRemoteReference(e,t,r){let i;i="string"==typeof t?JSON.parse(t):O(t),i.id||(i.id=e),r&&(i.__$validationOptions=I(r)),this.scache.cacheSchemaByUri(e,i)}getMissingReferences(e){if(!e)return[];const t=e.details||[],r=[];return function e(t){for(const i of t)"UNRESOLVABLE_REFERENCE"!==i.code&&"SCHEMA_NOT_REACHABLE"!==i.code||r.push(i.params[0]),i.inner&&e(i.inner)}(t),r}getMissingRemoteReferences(e){const t=this.getMissingReferences(e),r=[];let i=t.length;for(;i--;){const e=m(t[i]);e&&-1===r.indexOf(e)&&r.push(e)}return r}getResolvedSchema(e){const r=new E(this.options),i=this.scache.getSchemaByUri(r,e);if(!i)return;const n=O(i),o=[],s=function(e){let r;const i=t(e);if(("object"===i||"array"===i)&&!e.___$visited){if(e.___$visited=!0,o.push(e),e.$ref&&e.__$refResolved){const t=e.__$refResolved,i=e;for(r in delete e.$ref,delete e.__$refResolved,t)_(t,i,r)}for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&(0===r.indexOf("__$")?delete e[r]:s(e[r]))}};return s(n),o.forEach(function(e){delete e.___$visited}),n}}class De extends Me{constructor(e){super(e)}static registerFormat(e,t){return function(e,t){fe[e]=t}(e,t)}static unregisterFormat(e){return function(e){delete fe[e]}(e)}static getRegisteredFormats(){return f(fe)}static getDefaultOptions(){return O(T)}static setRemoteReference(e,t,r){let i;i="string"==typeof t?JSON.parse(t):O(t),i.id||(i.id=e),r&&(i.__$validationOptions=I(r)),A.cacheSchemaByUri(e,i)}static getSchemaReader(){return Ae()}static setSchemaReader(e){return function(e){Oe=e}(e)}static schemaSymbol=h;static jsonSymbol=u;static create(e={}){const t=e.async,r=e.safe;return delete e.async,delete e.safe,e.__called_from_factory__=!0,t&&r?new Ce(e):t?new Ne(e):r?new $e(e):new De(e)}validate(e,t,r={}){return this._validate(e,t,r)}validateSafe(e,t,r){try{return this._validate(e,t,r??{}),{valid:!0}}catch(e){return{valid:!1,err:e}}}validateAsync(e,t,r){return new Promise((i,n)=>{try{this._validate(e,t,r||{},(e,t)=>e||!0!==t?n(e):i(t))}catch(e){n(e)}})}validateAsyncSafe(e,t,r){return new Promise(i=>{try{this._validate(e,t,r||{},(e,t)=>{i({valid:t,err:e})})}catch(e){i({valid:!1,err:e})}})}validateSchema(e){return this._validateSchema(e)}validateSchemaSafe(e){try{return this._validateSchema(e),{valid:!0}}catch(e){return{valid:!1,err:e}}}}class $e extends Me{constructor(e){super(e)}validate(e,t,r={}){try{return this._validate(e,t,r),{valid:!0}}catch(e){return{valid:!1,err:e}}}validateSchema(e){try{return this._validateSchema(e),{valid:!0}}catch(e){return{valid:!1,err:e}}}}class Ne extends Me{constructor(e){super(e)}validate(e,t,r={}){return new Promise((i,n)=>{try{this._validate(e,t,r,(e,t)=>e||!0!==t?n(e):i(t))}catch(e){n(e)}})}validateSchema(e){return this._validateSchema(e)}}class Ce extends Me{constructor(e){super(e)}validate(e,t,r={}){return new Promise(i=>{try{this._validate(e,t,r,(e,t)=>{i({valid:t,err:e})})}catch(e){i({valid:!1,err:e})}})}validateSchema(e){try{return this._validateSchema(e),{valid:!0}}catch(e){return{valid:!1,err:e}}}}e.ZSchema=De,e.ZSchemaAsync=Ne,e.ZSchemaAsyncSafe=Ce,e.ZSchemaSafe=$e});