UNPKG

ixfs

Version:

An 'fs' kind of library dedicated to the browser

2 lines 59.5 kB
!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)["indexeddb-fs"]={})}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function r(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function n(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o="directory",a="^([A-Za-z]:|[A-Za-z0-9_一-龥-]+(.[A-Za-z0-9_一-龥-]+)*)((/[A-Za-z0-9_一-龥.-]+)+)$";function i(e){return e?e.result:null}function s(e,t){t||e(new Error("Something went wrong and the database transaction was not opened."))}var u=function(e){var t=e.databaseName,r=e.databaseVersion,n=e.objectStoreName;return new Promise((function(e,a){var u=d(t,r);u.onerror=a,u.onsuccess=function(t){var r=i(t.target);s(a,r),e(r)},u.onupgradeneeded=function(e){var t=i(e.target);s(a,t);var r=null==t?void 0:t.createObjectStore(n,{keyPath:"fullPath"});null==r||r.createIndex(o,o,{unique:!1})}}))},c=function(e){var t=e.initializeObjectStore;return function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,t("readwrite")];case 1:return r=n.sent(),[2,new Promise((function(t,n){var o=r.put(e);o.onerror=n,o.onsuccess=function(){return t(e)}}))]}}))}))}},f=function(e){var t=e.initializeObjectStore;return function(e,o){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,t("readonly")];case 1:return r=n.sent(),[2,new Promise((function(t,n){var a=r.get(e);a.onerror=n,a.onsuccess=function(e){return t(o(null==e?void 0:e.target))}}))]}}))}))}},h=function(e){var t=e.initializeObjectStore;return function(e,a){return r(void 0,void 0,void 0,(function(){var r,i,s,u;return n(this,(function(n){switch(n.label){case 0:return[4,t("readonly")];case 1:return r=n.sent(),i=r.index(o),s=IDBKeyRange.only(e),u=i.openCursor(s),[2,new Promise((function(e,t){u.onerror=t,u.onsuccess=function(t){var r=t.target;return a(r,e)}}))]}}))}))}},l=function(e){var t=e.initializeObjectStore;return function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,t("readwrite")];case 1:return r=n.sent(),[2,new Promise((function(t,n){var o=r.delete(e);o.onerror=n,o.onsuccess=function(){return t()}}))]}}))}))}},d=function(e,t){return indexedDB.open(e,t)},m=function(e){var t=e.databaseName,o=e.databaseVersion,a=e.objectStoreName;return function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,u({databaseName:t,databaseVersion:o,objectStoreName:a})];case 1:return r=n.sent(),[2,r.transaction(a,e).objectStore(a)]}}))}))}},p=function(e){return"string"==typeof e||e instanceof String},v=new RegExp(a);var y=function(e,t){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e()];case 1:return[2,n.sent()];case 2:return r=n.sent(),t&&t(r),[3,3];case 3:return[2,null]}}))}))};function b(e,t){for(var r=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var g=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,w=function(e){return g.exec(e).slice(1)};function F(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return(t?"/":"")+(e=b(j(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function A(e){var t=x(e),r="/"===z(e,-1);return(e=b(j(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function x(e){return"/"===e.charAt(0)}var E={extname:function(e){return w(e)[3]},basename:function(e,t){var r=w(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},dirname:function(e){var t=w(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},sep:"/",delimiter:":",relative:function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=F(e).substr(1),t=F(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),a=Math.min(n.length,o.length),i=a,s=0;s<a;s++)if(n[s]!==o[s]){i=s;break}var u=[];for(s=i;s<n.length;s++)u.push("..");return(u=u.concat(o.slice(i))).join("/")},join:function(){return A(j(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},isAbsolute:x,normalize:A,resolve:F};function j(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n<e.length;n++)t(e[n],n,e)&&r.push(e[n]);return r}var z="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)};function O(e,t){var r=E.dirname(e);return"."===r?t:r}function S(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var Z="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},D=2147483647,$=36,R=1,N=26,P=38,_=700,C=72,I=128,k="-",q=/[^\x20-\x7E]/,V=/[\x2E\u3002\uFF0E\uFF61]/g,M={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=$-R,T=Math.floor,U=String.fromCharCode; /*! https://mths.be/punycode v1.4.1 by @mathias */function B(e){throw new RangeError(M[e])}function J(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function Y(e,t,r){var n=0;for(e=r?T(e/_):e>>1,e+=T(e/t);e>L*N>>1;n+=$)e=T(e/L);return T(n+(L+1)*e/(e+P))}function G(e){return function(e,t){var r=e.split("@"),n="";r.length>1&&(n=r[0]+"@",e=r[1]);var o=function(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}((e=e.replace(V,".")).split("."),t).join(".");return n+o}(e,(function(e){return q.test(e)?"xn--"+function(e){var t,r,n,o,a,i,s,u,c,f,h,l,d,m,p,v=[];for(e=function(e){for(var t,r,n=[],o=0,a=e.length;o<a;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<a?56320==(64512&(r=e.charCodeAt(o++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),o--):n.push(t);return n}(e),l=e.length,t=I,r=0,a=C,i=0;i<l;++i)(h=e[i])<128&&v.push(U(h));for(n=o=v.length,o&&v.push(k);n<l;){for(s=D,i=0;i<l;++i)(h=e[i])>=t&&h<s&&(s=h);for(s-t>T((D-r)/(d=n+1))&&B("overflow"),r+=(s-t)*d,t=s,i=0;i<l;++i)if((h=e[i])<t&&++r>D&&B("overflow"),h==t){for(u=r,c=$;!(u<(f=c<=a?R:c>=a+N?N:c-a));c+=$)p=u-f,m=$-f,v.push(U(J(f+p%m,0))),u=T(p/m);v.push(U(J(u,0))),a=Y(r,d,n==o),r=0,++n}++r,++t}return v.join("")}(e):e}))}function H(e){return null===e}function K(e){return"string"==typeof e}function W(e){return"object"==typeof e&&null!==e}function X(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Q=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function ee(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function te(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n<e.length;n++)r.push(t(e[n],n));return r}var re=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t};function ne(e,t,r,n){t=t||"&",r=r||"=";var o={};if("string"!=typeof e||0===e.length)return o;var a=/\+/g;e=e.split(t);var i=1e3;n&&"number"==typeof n.maxKeys&&(i=n.maxKeys);var s=e.length;i>0&&s>i&&(s=i);for(var u=0;u<s;++u){var c,f,h,l,d=e[u].replace(a,"%20"),m=d.indexOf(r);m>=0?(c=d.substr(0,m),f=d.substr(m+1)):(c=d,f=""),h=decodeURIComponent(c),l=decodeURIComponent(f),X(o,h)?Q(o[h])?o[h].push(l):o[h]=[o[h],l]:o[h]=l}return o}const oe=Z.URL,ae=Z.URLSearchParams;var ie={parse:Fe,resolve:ze,resolveObject:Oe,fileURLToPath:xe,format:Ee,Url:se,URL:oe,URLSearchParams:ae};function se(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var ue=/^([a-z0-9.+-]+:)/i,ce=/:[0-9]*$/,fe=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,he=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),le=["'"].concat(he),de=["%","/","?",";","#"].concat(le),me=["/","?","#"],pe=255,ve=/^[+a-z0-9A-Z_-]{0,63}$/,ye=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,be={javascript:!0,"javascript:":!0},ge={javascript:!0,"javascript:":!0},we={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Fe(e,t,r){if(e&&W(e)&&e instanceof se)return e;var n=new se;return n.parse(e,t,r),n}function Ae(e,t,r,n){if(!K(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o<t.indexOf("#")?"?":"#",i=t.split(a);i[0]=i[0].replace(/\\/g,"/");var s=t=i.join(a);if(s=s.trim(),!n&&1===t.split("#").length){var u=fe.exec(s);if(u)return e.path=s,e.href=s,e.pathname=u[1],u[2]?(e.search=u[2],e.query=r?ne(e.search.substr(1)):e.search.substr(1)):r&&(e.search="",e.query={}),e}var c,f,h,l,d=ue.exec(s);if(d){var m=(d=d[0]).toLowerCase();e.protocol=m,s=s.substr(d.length)}if(n||d||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var p="//"===s.substr(0,2);!p||d&&ge[d]||(s=s.substr(2),e.slashes=!0)}if(!ge[d]&&(p||d&&!we[d])){var v,y,b=-1;for(c=0;c<me.length;c++)-1!==(f=s.indexOf(me[c]))&&(-1===b||f<b)&&(b=f);for(-1!==(y=-1===b?s.lastIndexOf("@"):s.lastIndexOf("@",b))&&(v=s.slice(0,y),s=s.slice(y+1),e.auth=decodeURIComponent(v)),b=-1,c=0;c<de.length;c++)-1!==(f=s.indexOf(de[c]))&&(-1===b||f<b)&&(b=f);-1===b&&(b=s.length),e.host=s.slice(0,b),s=s.slice(b),Se(e),e.hostname=e.hostname||"";var g="["===e.hostname[0]&&"]"===e.hostname[e.hostname.length-1];if(!g){var w=e.hostname.split(/\./);for(c=0,h=w.length;c<h;c++){var F=w[c];if(F&&!F.match(ve)){for(var A="",x=0,E=F.length;x<E;x++)F.charCodeAt(x)>127?A+="x":A+=F[x];if(!A.match(ve)){var j=w.slice(0,c),z=w.slice(c+1),O=F.match(ye);O&&(j.push(O[1]),z.unshift(O[2])),z.length&&(s="/"+z.join(".")+s),e.hostname=j.join(".");break}}}}e.hostname.length>pe?e.hostname="":e.hostname=e.hostname.toLowerCase(),g||(e.hostname=G(e.hostname)),l=e.port?":"+e.port:"";var S=e.hostname||"";e.host=S+l,e.href+=e.host,g&&(e.hostname=e.hostname.substr(1,e.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!be[m])for(c=0,h=le.length;c<h;c++){var Z=le[c];if(-1!==s.indexOf(Z)){var D=encodeURIComponent(Z);D===Z&&(D=escape(Z)),s=s.split(Z).join(D)}}var $=s.indexOf("#");-1!==$&&(e.hash=s.substr($),s=s.slice(0,$));var R=s.indexOf("?");if(-1!==R?(e.search=s.substr(R),e.query=s.substr(R+1),r&&(e.query=ne(e.query)),s=s.slice(0,R)):r&&(e.search="",e.query={}),s&&(e.pathname=s),we[m]&&e.hostname&&!e.pathname&&(e.pathname="/"),e.pathname||e.search){l=e.pathname||"";var N=e.search||"";e.path=l+N}return e.href=je(e),e}function xe(e){if("string"==typeof e)e=(new se).parse(e);else if(!(e instanceof se))throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof e+String(e));if("file:"!==e.protocol)throw new TypeError("The URL must be of scheme file");return function(e){const t=e.pathname;for(let e=0;e<t.length;e++)if("%"===t[e]){const r=32|t.codePointAt(e+2);if("2"===t[e+1]&&102===r)throw new TypeError("must not include encoded / characters")}return decodeURIComponent(t)}(e)}function Ee(e){return K(e)&&(e=Ae({},e)),je(e)}function je(e){var t=e.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var r=e.protocol||"",n=e.pathname||"",o=e.hash||"",a=!1,i="";e.host?a=t+e.host:e.hostname&&(a=t+(-1===e.hostname.indexOf(":")?e.hostname:"["+this.hostname+"]"),e.port&&(a+=":"+e.port)),e.query&&W(e.query)&&Object.keys(e.query).length&&(i=function(e,t,r,n){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?te(re(e),(function(n){var o=encodeURIComponent(ee(n))+r;return Q(e[n])?te(e[n],(function(e){return o+encodeURIComponent(ee(e))})).join(t):o+encodeURIComponent(ee(e[n]))})).join(t):n?encodeURIComponent(ee(n))+r+encodeURIComponent(ee(e)):""}(e.query));var s=e.search||i&&"?"+i||"";return r&&":"!==r.substr(-1)&&(r+=":"),e.slashes||(!r||we[r])&&!1!==a?(a="//"+(a||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):a||(a=""),o&&"#"!==o.charAt(0)&&(o="#"+o),s&&"?"!==s.charAt(0)&&(s="?"+s),r+a+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(s=s.replace("#","%23"))+o}function ze(e,t){return Fe(e,!1,!0).resolve(t)}function Oe(e,t){return e?Fe(e,!1,!0).resolveObject(t):t}function Se(e){var t=e.host,r=ce.exec(t);r&&(":"!==(r=r[0])&&(e.port=r.substr(1)),t=t.substr(0,t.length-r.length)),t&&(e.hostname=t)}se.prototype.parse=function(e,t,r){return Ae(this,e,t,r)},se.prototype.format=function(){return je(this)},se.prototype.resolve=function(e){return this.resolveObject(Fe(e,!1,!0)).format()},se.prototype.resolveObject=function(e){if(K(e)){var t=new se;t.parse(e,!1,!0),e=t}for(var r,n=new se,o=Object.keys(this),a=0;a<o.length;a++){var i=o[a];n[i]=this[i]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var s=Object.keys(e),u=0;u<s.length;u++){var c=s[u];"protocol"!==c&&(n[c]=e[c])}return we[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!we[e.protocol]){for(var f=Object.keys(e),h=0;h<f.length;h++){var l=f[h];n[l]=e[l]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||ge[e.protocol])n.pathname=e.pathname;else{for(r=(e.pathname||"").split("/");r.length&&!(e.host=r.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==r[0]&&r.unshift(""),r.length<2&&r.unshift(""),n.pathname=r.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var d=n.pathname||"",m=n.search||"";n.path=d+m}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var p,v=n.pathname&&"/"===n.pathname.charAt(0),y=e.host||e.pathname&&"/"===e.pathname.charAt(0),b=y||v||n.host&&e.pathname,g=b,w=n.pathname&&n.pathname.split("/")||[],F=n.protocol&&!we[n.protocol];if(r=e.pathname&&e.pathname.split("/")||[],F&&(n.hostname="",n.port=null,n.host&&(""===w[0]?w[0]=n.host:w.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===r[0]?r[0]=e.host:r.unshift(e.host)),e.host=null),b=b&&(""===r[0]||""===w[0])),y)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,w=r;else if(r.length)w||(w=[]),w.pop(),w=w.concat(r),n.search=e.search,n.query=e.query;else if(null!=e.search)return F&&(n.hostname=n.host=w.shift(),(p=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=p.shift(),n.host=n.hostname=p.shift())),n.search=e.search,n.query=e.query,H(n.pathname)&&H(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!w.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=w.slice(-1)[0],x=(n.host||e.host||w.length>1)&&("."===A||".."===A)||""===A,E=0,j=w.length;j>=0;j--)"."===(A=w[j])?w.splice(j,1):".."===A?(w.splice(j,1),E++):E&&(w.splice(j,1),E--);if(!b&&!g)for(;E--;E)w.unshift("..");!b||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),x&&"/"!==w.join("/").substr(-1)&&w.push("");var z=""===w[0]||w[0]&&"/"===w[0].charAt(0);return F&&(n.hostname=n.host=z?"":w.length?w.shift():"",(p=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=p.shift(),n.host=n.hostname=p.shift())),(b=b||n.host&&w.length)&&!z&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),H(n.pathname)&&H(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},se.prototype.parseHost=function(){return Se(this)};var Ze=S(Object.freeze({__proto__:null,URL:oe,URLSearchParams:ae,Url:se,default:ie,fileURLToPath:xe,format:Ee,parse:Fe,resolve:ze,resolveObject:Oe})),De={},$e=Ze,Re=De.ValidationError=function(e,t,r,n,o,a){if(Array.isArray(n)?(this.path=n,this.property=n.reduce((function(e,t){return e+qe(t)}),"instance")):void 0!==n&&(this.property=n),e&&(this.message=e),r){var i=r.$id||r.id;this.schema=i||r}void 0!==t&&(this.instance=t),this.name=o,this.argument=a,this.stack=this.toString()};Re.prototype.toString=function(){return this.property+" "+this.message};var Ne=De.ValidatorResult=function(e,t,r,n){this.instance=e,this.schema=t,this.options=r,this.path=n.path,this.propertyPath=n.propertyPath,this.errors=[],this.throwError=r&&r.throwError,this.throwFirst=r&&r.throwFirst,this.throwAll=r&&r.throwAll,this.disableFormat=r&&!0===r.disableFormat};function Pe(e,t){return t+": "+e.toString()+"\n"}function _e(e){Error.captureStackTrace&&Error.captureStackTrace(this,_e),this.instance=e.instance,this.schema=e.schema,this.options=e.options,this.errors=e.errors}Ne.prototype.addError=function(e){var t;if("string"==typeof e)t=new Re(e,this.instance,this.schema,this.path);else{if(!e)throw new Error("Missing error detail");if(!e.message)throw new Error("Missing error message");if(!e.name)throw new Error("Missing validator type");t=new Re(e.message,this.instance,this.schema,this.path,e.name,e.argument)}if(this.errors.push(t),this.throwFirst)throw new _e(this);if(this.throwError)throw t;return t},Ne.prototype.importErrors=function(e){"string"==typeof e||e&&e.validatorType?this.addError(e):e&&e.errors&&(this.errors=this.errors.concat(e.errors))},Ne.prototype.toString=function(e){return this.errors.map(Pe).join("")},Object.defineProperty(Ne.prototype,"valid",{get:function(){return!this.errors.length}}),De.ValidatorResultError=_e,_e.prototype=new Error,_e.prototype.constructor=_e,_e.prototype.name="Validation Error";var Ce=De.SchemaError=function e(t,r){this.message=t,this.schema=r,Error.call(this,t),Error.captureStackTrace(this,e)};Ce.prototype=Object.create(Error.prototype,{constructor:{value:Ce,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var Ie=De.SchemaContext=function(e,t,r,n,o){this.schema=e,this.options=t,Array.isArray(r)?(this.path=r,this.propertyPath=r.reduce((function(e,t){return e+qe(t)}),"instance")):this.propertyPath=r,this.base=n,this.schemas=o};Ie.prototype.resolve=function(e){return $e.resolve(this.base,e)},Ie.prototype.makeChild=function(e,t){var r=void 0===t?this.path:this.path.concat([t]),n=e.$id||e.id,o=$e.resolve(this.base,n||""),a=new Ie(e,this.options,r,o,Object.create(this.schemas));return n&&!a.schemas[o]&&(a.schemas[o]=e),a};var ke=De.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,duration:/P(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S)|\d+(D|M(\d+D)?|Y(\d+M(\d+D)?)?)(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S))?|\d+W)/i,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,"idn-email":/^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*|\[[!-Z\^-\u{10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9A-F]{12}$/i,"uri-template":/(%[0-9a-f]{2}|[!#$&(-;=?@\[\]_a-z~]|\{[!#&+,./;=?@|]?(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?(,(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?)*\})*/iu,"json-pointer":/^(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*$/iu,"relative-json-pointer":/^\d+(#|(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*)$/iu,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"utc-millisec":function(e){return"string"==typeof e&&parseFloat(e)===parseInt(e,10)&&!isNaN(e)},regex:function(e){var t=!0;try{new RegExp(e)}catch(e){t=!1}return t},style:/[\r\n\t ]*[^\r\n\t ][^:]*:[\r\n\t ]*[^\r\n\t ;]*[\r\n\t ]*;?/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/};ke.regexp=ke.regex,ke.pattern=ke.regex,ke.ipv4=ke["ip-address"],De.isFormat=function(e,t,r){if("string"==typeof e&&void 0!==ke[t]){if(ke[t]instanceof RegExp)return ke[t].test(e);if("function"==typeof ke[t])return ke[t](e)}else if(r&&r.customFormats&&"function"==typeof r.customFormats[t])return r.customFormats[t](e);return!0};var qe=De.makeSuffix=function(e){return(e=e.toString()).match(/[.\s\[\]]/)||e.match(/^[\d]/)?e.match(/^\d+$/)?"["+e+"]":"["+JSON.stringify(e)+"]":"."+e};function Ve(e,t,r,n){"object"==typeof r?t[n]=Te(e[n],r):-1===e.indexOf(r)&&t.push(r)}function Me(e,t,r){t[r]=e[r]}function Le(e,t,r,n){"object"==typeof t[n]&&t[n]&&e[n]?r[n]=Te(e[n],t[n]):r[n]=t[n]}function Te(e,t){var r=Array.isArray(t),n=r&&[]||{};return r?(e=e||[],n=n.concat(e),t.forEach(Ve.bind(null,e,n))):(e&&"object"==typeof e&&Object.keys(e).forEach(Me.bind(null,e,n)),Object.keys(t).forEach(Le.bind(null,e,t,n))),n}function Ue(e){return"/"+encodeURIComponent(e).replace(/~/g,"%7E")}De.deepCompareStrict=function e(t,r){if(typeof t!=typeof r)return!1;if(Array.isArray(t))return!!Array.isArray(r)&&(t.length===r.length&&t.every((function(n,o){return e(t[o],r[o])})));if("object"==typeof t){if(!t||!r)return t===r;var n=Object.keys(t),o=Object.keys(r);return n.length===o.length&&n.every((function(n){return e(t[n],r[n])}))}return t===r},De.deepMerge=Te,De.objectGetPath=function(e,t){for(var r,n=t.split("/").slice(1);"string"==typeof(r=n.shift());){var o=decodeURIComponent(r.replace(/~0/,"~").replace(/~1/g,"/"));if(!(o in e))return;e=e[o]}return e},De.encodePath=function(e){return e.map(Ue).join("")},De.getDecimalPlaces=function(e){var t=0;if(isNaN(e))return t;"number"!=typeof e&&(e=Number(e));var r=e.toString().split("e");if(2===r.length){if("-"!==r[1][0])return t;t=Number(r[1].slice(1))}var n=r[0].split(".");return 2===n.length&&(t+=n[1].length),t},De.isSchema=function(e){return"object"==typeof e&&e||"boolean"==typeof e};var Be=De,Je=Be.ValidatorResult,Ye=Be.SchemaError,Ge={ignoreProperties:{id:!0,default:!0,description:!0,title:!0,additionalItems:!0,then:!0,else:!0,$schema:!0,$ref:!0,extends:!0}},He=Ge.validators={};function Ke(e,t,r,n,o){var a=t.throwError,i=t.throwAll;t.throwError=!1,t.throwAll=!1;var s=this.validateSchema(e,o,t,r);return t.throwError=a,t.throwAll=i,!s.valid&&n instanceof Function&&n(s),s.valid}function We(e,t){if(Object.hasOwnProperty.call(e,t))return e[t];if(t in e)for(;e=Object.getPrototypeOf(e);)if(Object.propertyIsEnumerable.call(e,t))return e[t]}function Xe(e,t,r,n,o,a){if(this.types.object(e)&&(!t.properties||void 0===t.properties[o]))if(!1===t.additionalProperties)a.addError({name:"additionalProperties",argument:o,message:"is not allowed to have the additional property "+JSON.stringify(o)});else{var i=t.additionalProperties||{};"function"==typeof r.preValidateProperty&&r.preValidateProperty(e,o,i,r,n);var s=this.validateSchema(e[o],i,r,n.makeChild(i,o));s.instance!==a.instance[o]&&(a.instance[o]=s.instance),a.importErrors(s)}}He.type=function(e,t,r,n){if(void 0===e)return null;var o=new Je(e,t,r,n),a=Array.isArray(t.type)?t.type:[t.type];if(!a.some(this.testType.bind(this,e,t,r,n))){var i=a.map((function(e){if(e){var t=e.$id||e.id;return t?"<"+t+">":e+""}}));o.addError({name:"type",argument:i,message:"is not of a type(s) "+i})}return o},He.anyOf=function(e,t,r,n){if(void 0===e)return null;var o=new Je(e,t,r,n),a=new Je(e,t,r,n);if(!Array.isArray(t.anyOf))throw new Ye("anyOf must be an array");if(!t.anyOf.some(Ke.bind(this,e,r,n,(function(e){a.importErrors(e)})))){var i=t.anyOf.map((function(e,t){var r=e.$id||e.id;return r?"<"+r+">":e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"}));r.nestedErrors&&o.importErrors(a),o.addError({name:"anyOf",argument:i,message:"is not any of "+i.join(",")})}return o},He.allOf=function(e,t,r,n){if(void 0===e)return null;if(!Array.isArray(t.allOf))throw new Ye("allOf must be an array");var o=new Je(e,t,r,n),a=this;return t.allOf.forEach((function(t,i){var s=a.validateSchema(e,t,r,n);if(!s.valid){var u=t.$id||t.id||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+i+"]";o.addError({name:"allOf",argument:{id:u,length:s.errors.length,valid:s},message:"does not match allOf schema "+u+" with "+s.errors.length+" error[s]:"}),o.importErrors(s)}})),o},He.oneOf=function(e,t,r,n){if(void 0===e)return null;if(!Array.isArray(t.oneOf))throw new Ye("oneOf must be an array");var o=new Je(e,t,r,n),a=new Je(e,t,r,n),i=t.oneOf.filter(Ke.bind(this,e,r,n,(function(e){a.importErrors(e)}))).length,s=t.oneOf.map((function(e,t){return e.$id||e.id||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"}));return 1!==i&&(r.nestedErrors&&o.importErrors(a),o.addError({name:"oneOf",argument:s,message:"is not exactly one from "+s.join(",")})),o},He.if=function(e,t,r,n){if(void 0===e)return null;if(!Be.isSchema(t.if))throw new Error('Expected "if" keyword to be a schema');var o,a=Ke.call(this,e,r,n,null,t.if),i=new Je(e,t,r,n);if(a){if(void 0===t.then)return;if(!Be.isSchema(t.then))throw new Error('Expected "then" keyword to be a schema');o=this.validateSchema(e,t.then,r,n.makeChild(t.then)),i.importErrors(o)}else{if(void 0===t.else)return;if(!Be.isSchema(t.else))throw new Error('Expected "else" keyword to be a schema');o=this.validateSchema(e,t.else,r,n.makeChild(t.else)),i.importErrors(o)}return i},He.propertyNames=function(e,t,r,n){if(this.types.object(e)){var o=new Je(e,t,r,n),a=void 0!==t.propertyNames?t.propertyNames:{};if(!Be.isSchema(a))throw new Ye('Expected "propertyNames" to be a schema (object or boolean)');for(var i in e)if(void 0!==We(e,i)){var s=this.validateSchema(i,a,r,n.makeChild(a));o.importErrors(s)}return o}},He.properties=function(e,t,r,n){if(this.types.object(e)){var o=new Je(e,t,r,n),a=t.properties||{};for(var i in a){var s=a[i];if(void 0!==s){if(null===s)throw new Ye('Unexpected null, expected schema in "properties"');"function"==typeof r.preValidateProperty&&r.preValidateProperty(e,i,s,r,n);var u=We(e,i),c=this.validateSchema(u,s,r,n.makeChild(s,i));c.instance!==o.instance[i]&&(o.instance[i]=c.instance),o.importErrors(c)}}return o}},He.patternProperties=function(e,t,r,n){if(this.types.object(e)){var o=new Je(e,t,r,n),a=t.patternProperties||{};for(var i in e){var s=!0;for(var u in a){var c=a[u];if(void 0!==c){if(null===c)throw new Ye('Unexpected null, expected schema in "patternProperties"');try{var f=new RegExp(u,"u")}catch(e){f=new RegExp(u)}if(f.test(i)){s=!1,"function"==typeof r.preValidateProperty&&r.preValidateProperty(e,i,c,r,n);var h=this.validateSchema(e[i],c,r,n.makeChild(c,i));h.instance!==o.instance[i]&&(o.instance[i]=h.instance),o.importErrors(h)}}}s&&Xe.call(this,e,t,r,n,i,o)}return o}},He.additionalProperties=function(e,t,r,n){if(this.types.object(e)){if(t.patternProperties)return null;var o=new Je(e,t,r,n);for(var a in e)Xe.call(this,e,t,r,n,a,o);return o}},He.minProperties=function(e,t,r,n){if(this.types.object(e)){var o=new Je(e,t,r,n);return Object.keys(e).length>=t.minProperties||o.addError({name:"minProperties",argument:t.minProperties,message:"does not meet minimum property length of "+t.minProperties}),o}},He.maxProperties=function(e,t,r,n){if(this.types.object(e)){var o=new Je(e,t,r,n);return Object.keys(e).length<=t.maxProperties||o.addError({name:"maxProperties",argument:t.maxProperties,message:"does not meet maximum property length of "+t.maxProperties}),o}},He.items=function(e,t,r,n){var o=this;if(this.types.array(e)&&void 0!==t.items){var a=new Je(e,t,r,n);return e.every((function(e,i){if(Array.isArray(t.items))var s=void 0===t.items[i]?t.additionalItems:t.items[i];else s=t.items;if(void 0===s)return!0;if(!1===s)return a.addError({name:"items",message:"additionalItems not permitted"}),!1;var u=o.validateSchema(e,s,r,n.makeChild(s,i));return u.instance!==a.instance[i]&&(a.instance[i]=u.instance),a.importErrors(u),!0})),a}},He.contains=function(e,t,r,n){var o=this;if(this.types.array(e)&&void 0!==t.contains){if(!Be.isSchema(t.contains))throw new Error('Expected "contains" keyword to be a schema');var a=new Je(e,t,r,n);return!1===e.some((function(e,a){return 0===o.validateSchema(e,t.contains,r,n.makeChild(t.contains,a)).errors.length}))&&a.addError({name:"contains",argument:t.contains,message:"must contain an item matching given schema"}),a}},He.minimum=function(e,t,r,n){if(this.types.number(e)){var o=new Je(e,t,r,n);return t.exclusiveMinimum&&!0===t.exclusiveMinimum?e>t.minimum||o.addError({name:"minimum",argument:t.minimum,message:"must be greater than "+t.minimum}):e>=t.minimum||o.addError({name:"minimum",argument:t.minimum,message:"must be greater than or equal to "+t.minimum}),o}},He.maximum=function(e,t,r,n){if(this.types.number(e)){var o=new Je(e,t,r,n);return t.exclusiveMaximum&&!0===t.exclusiveMaximum?e<t.maximum||o.addError({name:"maximum",argument:t.maximum,message:"must be less than "+t.maximum}):e<=t.maximum||o.addError({name:"maximum",argument:t.maximum,message:"must be less than or equal to "+t.maximum}),o}},He.exclusiveMinimum=function(e,t,r,n){if("boolean"!=typeof t.exclusiveMinimum&&this.types.number(e)){var o=new Je(e,t,r,n);return e>t.exclusiveMinimum||o.addError({name:"exclusiveMinimum",argument:t.exclusiveMinimum,message:"must be strictly greater than "+t.exclusiveMinimum}),o}},He.exclusiveMaximum=function(e,t,r,n){if("boolean"!=typeof t.exclusiveMaximum&&this.types.number(e)){var o=new Je(e,t,r,n);return e<t.exclusiveMaximum||o.addError({name:"exclusiveMaximum",argument:t.exclusiveMaximum,message:"must be strictly less than "+t.exclusiveMaximum}),o}};var Qe=function(e,t,r,n,o,a){if(this.types.number(e)){var i=t[o];if(0==i)throw new Ye(o+" cannot be zero");var s=new Je(e,t,r,n),u=Be.getDecimalPlaces(e),c=Be.getDecimalPlaces(i),f=Math.max(u,c),h=Math.pow(10,f);return Math.round(e*h)%Math.round(i*h)!=0&&s.addError({name:o,argument:i,message:a+JSON.stringify(i)}),s}};function et(e,t,r){var n,o=r.length;for(n=t+1;n<o;n++)if(Be.deepCompareStrict(e,r[n]))return!1;return!0}He.multipleOf=function(e,t,r,n){return Qe.call(this,e,t,r,n,"multipleOf","is not a multiple of (divisible by) ")},He.divisibleBy=function(e,t,r,n){return Qe.call(this,e,t,r,n,"divisibleBy","is not divisible by (multiple of) ")},He.required=function(e,t,r,n){var o=new Je(e,t,r,n);return void 0===e&&!0===t.required?o.addError({name:"required",message:"is required"}):this.types.object(e)&&Array.isArray(t.required)&&t.required.forEach((function(t){void 0===We(e,t)&&o.addError({name:"required",argument:t,message:"requires property "+JSON.stringify(t)})})),o},He.pattern=function(e,t,r,n){if(this.types.string(e)){var o=new Je(e,t,r,n),a=t.pattern;try{var i=new RegExp(a,"u")}catch(e){i=new RegExp(a)}return e.match(i)||o.addError({name:"pattern",argument:t.pattern,message:"does not match pattern "+JSON.stringify(t.pattern.toString())}),o}},He.format=function(e,t,r,n){if(void 0!==e){var o=new Je(e,t,r,n);return o.disableFormat||Be.isFormat(e,t.format,this)||o.addError({name:"format",argument:t.format,message:"does not conform to the "+JSON.stringify(t.format)+" format"}),o}},He.minLength=function(e,t,r,n){if(this.types.string(e)){var o=new Je(e,t,r,n),a=e.match(/[\uDC00-\uDFFF]/g);return e.length-(a?a.length:0)>=t.minLength||o.addError({name:"minLength",argument:t.minLength,message:"does not meet minimum length of "+t.minLength}),o}},He.maxLength=function(e,t,r,n){if(this.types.string(e)){var o=new Je(e,t,r,n),a=e.match(/[\uDC00-\uDFFF]/g);return e.length-(a?a.length:0)<=t.maxLength||o.addError({name:"maxLength",argument:t.maxLength,message:"does not meet maximum length of "+t.maxLength}),o}},He.minItems=function(e,t,r,n){if(this.types.array(e)){var o=new Je(e,t,r,n);return e.length>=t.minItems||o.addError({name:"minItems",argument:t.minItems,message:"does not meet minimum length of "+t.minItems}),o}},He.maxItems=function(e,t,r,n){if(this.types.array(e)){var o=new Je(e,t,r,n);return e.length<=t.maxItems||o.addError({name:"maxItems",argument:t.maxItems,message:"does not meet maximum length of "+t.maxItems}),o}},He.uniqueItems=function(e,t,r,n){if(!0===t.uniqueItems&&this.types.array(e)){var o=new Je(e,t,r,n);return e.every(et)||o.addError({name:"uniqueItems",message:"contains duplicate item"}),o}},He.dependencies=function(e,t,r,n){if(this.types.object(e)){var o=new Je(e,t,r,n);for(var a in t.dependencies)if(void 0!==e[a]){var i=t.dependencies[a],s=n.makeChild(i,a);if("string"==typeof i&&(i=[i]),Array.isArray(i))i.forEach((function(t){void 0===e[t]&&o.addError({name:"dependencies",argument:s.propertyPath,message:"property "+t+" not found, required by "+s.propertyPath})}));else{var u=this.validateSchema(e,i,r,s);o.instance!==u.instance&&(o.instance=u.instance),u&&u.errors.length&&(o.addError({name:"dependencies",argument:s.propertyPath,message:"does not meet dependency required by "+s.propertyPath}),o.importErrors(u))}}return o}},He.enum=function(e,t,r,n){if(void 0===e)return null;if(!Array.isArray(t.enum))throw new Ye("enum expects an array",t);var o=new Je(e,t,r,n);return t.enum.some(Be.deepCompareStrict.bind(null,e))||o.addError({name:"enum",argument:t.enum,message:"is not one of enum values: "+t.enum.map(String).join(",")}),o},He.const=function(e,t,r,n){if(void 0===e)return null;var o=new Je(e,t,r,n);return Be.deepCompareStrict(t.const,e)||o.addError({name:"const",argument:t.const,message:"does not exactly match expected constant: "+t.const}),o},He.not=He.disallow=function(e,t,r,n){var o=this;if(void 0===e)return null;var a=new Je(e,t,r,n),i=t.not||t.disallow;return i?(Array.isArray(i)||(i=[i]),i.forEach((function(i){if(o.testType(e,t,r,n,i)){var s=i&&(i.$id||i.id)||i;a.addError({name:"not",argument:s,message:"is of prohibited type "+s})}})),a):null};var tt=Ge,rt={},nt=Ze,ot=De;function at(e,t){this.id=e,this.ref=t}rt.SchemaScanResult=at,rt.scan=function(e,t){function r(e,t){if(t&&"object"==typeof t)if(t.$ref){var s=nt.resolve(e,t.$ref);i[s]=i[s]?i[s]+1:0}else{var u=t.$id||t.id,c=u?nt.resolve(e,u):e;if(c){if(c.indexOf("#")<0&&(c+="#"),a[c]){if(!ot.deepCompareStrict(a[c],t))throw new Error("Schema <"+c+"> already exists with different definition");return a[c]}a[c]=t,"#"==c[c.length-1]&&(a[c.substring(0,c.length-1)]=t)}n(c+"/items",Array.isArray(t.items)?t.items:[t.items]),n(c+"/extends",Array.isArray(t.extends)?t.extends:[t.extends]),r(c+"/additionalItems",t.additionalItems),o(c+"/properties",t.properties),r(c+"/additionalProperties",t.additionalProperties),o(c+"/definitions",t.definitions),o(c+"/patternProperties",t.patternProperties),o(c+"/dependencies",t.dependencies),n(c+"/disallow",t.disallow),n(c+"/allOf",t.allOf),n(c+"/anyOf",t.anyOf),n(c+"/oneOf",t.oneOf),r(c+"/not",t.not)}}function n(e,t){if(Array.isArray(t))for(var n=0;n<t.length;n++)r(e+"/"+n,t[n])}function o(e,t){if(t&&"object"==typeof t)for(var n in t)r(e+"/"+n,t[n])}var a={},i={};return r(e,t),new at(a,i)};var it=Ze,st=tt,ut=De,ct=rt.scan,ft=ut.ValidatorResult,ht=ut.ValidatorResultError,lt=ut.SchemaError,dt=ut.SchemaContext,mt=function e(){this.customFormats=Object.create(e.prototype.customFormats),this.schemas={},this.unresolvedRefs=[],this.types=Object.create(vt),this.attributes=Object.create(st.validators)};function pt(e){var t="string"==typeof e?e:e.$ref;return"string"==typeof t&&t}mt.prototype.customFormats={},mt.prototype.schemas=null,mt.prototype.types=null,mt.prototype.attributes=null,mt.prototype.unresolvedRefs=null,mt.prototype.addSchema=function(e,t){var r=this;if(!e)return null;var n=ct(t||"/",e),o=t||e.$id||e.id;for(var a in n.id)this.schemas[a]=n.id[a];for(var a in n.ref)this.unresolvedRefs.push(a);return this.unresolvedRefs=this.unresolvedRefs.filter((function(e){return void 0===r.schemas[e]})),this.schemas[o]},mt.prototype.addSubSchemaArray=function(e,t){if(Array.isArray(t))for(var r=0;r<t.length;r++)this.addSubSchema(e,t[r])},mt.prototype.addSubSchemaObject=function(e,t){if(t&&"object"==typeof t)for(var r in t)this.addSubSchema(e,t[r])},mt.prototype.setSchemas=function(e){this.schemas=e},mt.prototype.getSchema=function(e){return this.schemas[e]},mt.prototype.validate=function(e,t,r,n){if("boolean"!=typeof t&&"object"!=typeof t||null===t)throw new lt("Expected `schema` to be an object or boolean");r||(r={});var o,a=t.$id||t.id,i=it.resolve(r.base||"/",a||"");if(!n){(n=new dt(t,r,[],i,Object.create(this.schemas))).schemas[i]||(n.schemas[i]=t);var s=ct(i,t);for(var u in s.id){var c=s.id[u];n.schemas[u]=c}}if(r.required&&void 0===e)return(o=new ft(e,t,r,n)).addError("is required, but is undefined"),o;if(!(o=this.validateSchema(e,t,r,n)))throw new Error("Result undefined");if(r.throwAll&&o.errors.length)throw new ht(o);return o},mt.prototype.validateSchema=function(e,t,r,n){var o=new ft(e,t,r,n);if("boolean"==typeof t)!0===t?t={}:!1===t&&(t={type:[]});else if(!t)throw new Error("schema is undefined");if(t.extends)if(Array.isArray(t.extends)){var a={schema:t,ctx:n};t.extends.forEach(this.schemaTraverser.bind(this,a)),t=a.schema,a.schema=null,a.ctx=null,a=null}else t=ut.deepMerge(t,this.superResolve(t.extends,n));var i=pt(t);if(i){var s=this.resolve(t,i,n),u=new dt(s.subschema,r,n.path,s.switchSchema,n.schemas);return this.validateSchema(e,s.subschema,r,u)}var c=r&&r.skipAttributes||[];for(var f in t)if(!st.ignoreProperties[f]&&c.indexOf(f)<0){var h=null,l=this.attributes[f];if(l)h=l.call(this,e,t,r,n);else if(!1===r.allowUnknownAttributes)throw new lt("Unsupported attribute: "+f,t);h&&o.importErrors(h)}if("function"==typeof r.rewrite){var d=r.rewrite.call(this,e,t,r,n);o.instance=d}return o},mt.prototype.schemaTraverser=function(e,t){e.schema=ut.deepMerge(e.schema,this.superResolve(t,e.ctx))},mt.prototype.superResolve=function(e,t){var r=pt(e);return r?this.resolve(e,r,t).subschema:e},mt.prototype.resolve=function(e,t,r){if(t=r.resolve(t),r.schemas[t])return{subschema:r.schemas[t],switchSchema:t};var n=it.parse(t),o=n&&n.hash,a=o&&o.length&&t.substr(0,t.length-o.length);if(!a||!r.schemas[a])throw new lt("no such schema <"+t+">",e);var i=ut.objectGetPath(r.schemas[a],o.substr(1));if(void 0===i)throw new lt("no such schema "+o+" located in <"+a+">",e);return{subschema:i,switchSchema:t}},mt.prototype.testType=function(e,t,r,n,o){if(void 0!==o){if(null===o)throw new lt('Unexpected null in "type" keyword');if("function"==typeof this.types[o])return this.types[o].call(this,e);if(o&&"object"==typeof o){var a=this.validateSchema(e,o,r,n);return void 0===a||!(a&&a.errors.length)}return!0}};var vt=mt.prototype.types={};vt.string=function(e){return"string"==typeof e},vt.number=function(e){return"number"==typeof e&&isFinite(e)},vt.integer=function(e){return"number"==typeof e&&e%1==0},vt.boolean=function(e){return"boolean"==typeof e},vt.array=function(e){return Array.isArray(e)},vt.null=function(e){return null===e},vt.date=function(e){return e instanceof Date},vt.any=function(e){return!0},vt.object=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof Date)};var yt=mt;De.ValidatorResult,De.ValidatorResultError,De.ValidationError,De.SchemaError;var bt=function(e,t,r){return(new yt).validate(e,t,r)},gt="^[a-zA-Z0-9_.-]*$",wt={type:"object",id:"/CreateFsPropsSchema",properties:{databaseName:{minLength:4,maxLength:50,type:"string",pattern:gt},objectStoreName:{minLength:1,maxLength:20,type:"string",pattern:gt},rootDirectoryName:{minLength:1,maxLength:20,type:"string",pattern:gt},databaseVersion:{minimum:1,maximum:100,type:"integer"}},required:["databaseName","databaseVersion","objectStoreName","rootDirectoryName"]};function Ft(e,t){if(""===e)return t;var r=function(e,t){if(!p(e)||!p(t)||""===t)return!1;var r="".concat(t,"/");return e.startsWith(r)}(e,t);if(!r){var n=function(e){return!(!p(e)||0===e.length)&&"/"===e[0]}(e);return"".concat(t).concat(n?"":"/").concat(e)}return e}function At(e,t){if(!p(t)||""===t)throw new Error("rootDirectoryName parameter was not provided");if(!p(e))throw new Error("fullPath parameter was not provided");if(e===t)return t;var r=Ft(e,t);if(!r||!function(e){return!!p(e)&&v.test(e)}(r))throw new Error('"'.concat(e,'" path is invalid. Path must match the following pattern: /').concat(a,"/"));return r}var xt,Et={databaseVersion:1,objectStoreName:"files",rootDirectoryName:"root",databaseName:"indexeddb-fs"},jt=function(e){var t=e.result;return Boolean(null==t?void 0:t.createdAt)};!function(e){e.DIRECTORY="directory",e.FILE="file"}(xt||(xt={}));var zt=function(e){var t=e.result;return Boolean((null==t?void 0:t.type)===xt.FILE)},Ot=function(e){var t=e.result;return Boolean((null==t?void 0:t.type)===xt.DIRECTORY)},St=function(e){return e.result},Zt=function(e){var t=e.isDirectory,o=e.openCursor,a=e.rootDirectoryName;return function(e){return r(void 0,void 0,void 0,(function(){var r,i,s,u;return n(this,(function(n){switch(n.label){case 0:return r=At(e,a),[4,t(e)];case 1:if(!n.sent())throw new Error('"'.concat(r,'" is not a directory.'));return i=[],s=[],u=function(e,t){var r=e.result;if(r){var n=r.value;if(n.type===xt.FILE){n.data;var o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["data"]);i.push(o)}else n.type!==xt.DIRECTORY||n.isRoot||s.push(n);r.continue()}else{var a=i.length,u=s.length;t({isEmpty:0===a&&0===u,filesCount:a,directoriesCount:u,files:i,directories:s})}},[2,o(r,u)]}}))}))}},Dt=function(e){return e.result},$t=function(){if(!Boolean(indexedDB))throw new Error("Your browser does not support indexedDB.")},Rt=function(e){var o=void 0===e?Et:e,a=o.databaseName,i=void 0===a?Et.databaseName:a,s=o.databaseVersion,u=void 0===s?Et.databaseVersion:s,d=o.objectStoreName,p=void 0===d?Et.objectStoreName:d,v=o.rootDirectoryName,b=void 0===v?Et.rootDirectoryName:v,g=function(){return function(e){var t=bt(e,wt),r=t.errors,n=t.valid;if(n)return n;var o=JSON.stringify(r);throw new Error("Props passed to createFS function are invalid:\n".concat(o))}({databaseName:i,objectStoreName:p,databaseVersion:u,rootDirectoryName:b})},w=function(e){var t=e.databaseName,r=e.databaseVersion,n=e.objectStoreName,o=m({databaseName:t,databaseVersion:r,objectStoreName:n});return{getRecord:f({initializeObjectStore:o}),putRecord:c({initializeObjectStore:o}),openCursor:h({initializeObjectStore:o}),deleteRecord:l({initializeObjectStore:o})}}({databaseName:i,databaseVersion:u,objectStoreName:p}),F=w.deleteRecord,A=w.getRecord,x=w.openCursor,j=w.putRecord,z=function(e){var t=e.getRecord,o=e.rootDirectoryName;return function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){return r=At(e,o),[2,t(r,jt)]}))}))}}({getRecord:A,rootDirectoryName:b}),S=function(e){var t=e.exists,o=e.getRecord,a=e.rootDirectoryName;return function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return r=At(e,a),[4,t(r)];case 1:if(!n.sent())throw new Error('"'.concat(r,'" file does not exist.'));return[2,o(r,zt)]}}))}))}}({ex