import{X as Re}from"./index-BLqts8WY.js";var mn={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var fn=function(){return fn=Object.assign||function(v){for(var s,m=1,w=arguments.length;m0&&p[p.length-1])&&(u[0]===6||u[0]===2)){s=0;continue}if(u[0]===3&&(!p||u[1]>p[0]&&u[1]"u")throw new Error("FileReaderSync missing. Reading blobs synchronously requires code to run from within a web worker. Use TSON.encapsulateAsync() to do it from the main thread.");var s=new FileReaderSync,m=v==="binary"?s.readAsArrayBuffer(g):s.readAsText(g);return m}var hn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bn(g,v){return v={exports:{}},g(v,v.exports),v.exports}var pn=bn(function(g,v){(function(s,m){g.exports=m()})(hn,function(){function s(l){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?s=function(y){return typeof y}:s=function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},s(l)}function m(l,y,h,d,A,G,H){try{var W=l[G](H),C=W.value}catch(Ae){h(Ae);return}W.done?y(C):Promise.resolve(C).then(d,A)}function w(l){return function(){var y=this,h=arguments;return new Promise(function(d,A){var G=l.apply(y,h);function H(C){m(G,d,A,H,W,"next",C)}function W(C){m(G,d,A,H,W,"throw",C)}H(void 0)})}}function p(l,y){if(!(l instanceof y))throw new TypeError("Cannot call a class as a function")}function o(l,y){for(var h=0;h-1){var d=l[he(y.slice(0,h))];return d===void 0?void 0:Se(d,y.slice(h+1))}return l[he(y)]}function Be(l,y,h){if(y==="")return h;var d=y.indexOf(".");if(d>-1){var A=l[he(y.slice(0,d))];return Be(A,y.slice(d+1),h)}return l[he(y)]=h,l}function _e(l){return l===null?"null":Array.isArray(l)?"array":s(l)}var ce=Object.keys,be=Array.isArray,Ce={}.hasOwnProperty,Me=["type","replaced","iterateIn","iterateUnsetNumeric"];function $(l,y){if(l.keypath==="")return-1;var h=l.keypath.match(/\./g)||0,d=y.keypath.match(/\./g)||0;return h&&(h=h.length),d&&(d=d.length),h>d?-1:hy.keypath}var ye=function(){function l(y){p(this,l),this.options=y,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}return j(l,[{key:"stringify",value:function(h,d,A,G){G=_({},this.options,{},G,{stringification:!0});var H=this.encapsulate(h,null,G);return be(H)?JSON.stringify(H[0],d,A):H.then(function(W){return JSON.stringify(W,d,A)})}},{key:"stringifySync",value:function(h,d,A,G){return this.stringify(h,d,A,_({throwOnBadSyncType:!0},G,{sync:!0}))}},{key:"stringifyAsync",value:function(h,d,A,G){return this.stringify(h,d,A,_({throwOnBadSyncType:!0},G,{sync:!1}))}},{key:"parse",value:function(h,d,A){return A=_({},this.options,{},A,{parse:!0}),this.revive(JSON.parse(h,d),A)}},{key:"parseSync",value:function(h,d,A){return this.parse(h,d,_({throwOnBadSyncType:!0},A,{sync:!0}))}},{key:"parseAsync",value:function(h,d,A){return this.parse(h,d,_({throwOnBadSyncType:!0},A,{sync:!1}))}},{key:"specialTypeNames",value:function(h,d){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return A.returnTypeNames=!0,this.encapsulate(h,d,A)}},{key:"rootTypeName",value:function(h,d){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return A.iterateNone=!0,this.encapsulate(h,d,A)}},{key:"encapsulate",value:function(h,d,A){A=_({sync:!0},this.options,{},A);var G=A,H=G.sync,W=this,C={},Ae=[],Ue=[],xe=[],Ge="cyclic"in A?A.cyclic:!0,Ye=A,Xe=Ye.encapsulateObserver,Fe=ue("",h,Ge,d||{},xe);function qe(I){var t=Object.values(C);if(A.iterateNone)return t.length?t[0]:l.getJSONType(I);if(t.length){if(A.returnTypeNames)return pe(new Set(t));!I||!f(I)||Ce.call(I,"$types")?I={$:I,$types:{$:C}}:I.$types=C}else M(I)&&Ce.call(I,"$types")&&(I={$:I,$types:!0});return A.returnTypeNames?!1:I}function ge(I,t){return oe.apply(this,arguments)}function oe(){return oe=w(regeneratorRuntime.mark(function I(t,e){var n;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,Promise.all(e.map(function(O){return O[1].p}));case 2:return n=a.sent,a.next=5,Promise.all(n.map(function(){var O=w(regeneratorRuntime.mark(function T(B){var E,L,Y,q,ae,Q,X,fe,le,D,Te,P,S,U;return regeneratorRuntime.wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(E=[],L=e.splice(0,1),Y=F(L,1),q=Y[0],ae=F(q,7),Q=ae[0],X=ae[2],fe=ae[3],le=ae[4],D=ae[5],Te=ae[6],P=ue(Q,B,X,fe,E,!0,Te),S=b(P,N),!(Q&&S)){x.next=11;break}return x.next=8,P.p;case 8:return U=x.sent,le[D]=U,x.abrupt("return",ge(t,E));case 11:return Q?le[D]=P:S?t=P.p:t=P,x.abrupt("return",ge(t,E));case 13:case"end":return x.stop()}},T)}));return function(T){return O.apply(this,arguments)}}()));case 5:return a.abrupt("return",t);case 6:case"end":return a.stop()}},I)})),oe.apply(this,arguments)}function ne(I,t,e){Object.assign(I,t);var n=Me.map(function(i){var a=I[i];return delete I[i],a});e(),Me.forEach(function(i,a){I[i]=n[a]})}function ue(I,t,e,n,i,a,O){var T,B={},E=s(t),L=Xe?function(S){var U=O||n.type||l.getJSONType(t);Xe(Object.assign(S||B,{keypath:I,value:t,cyclic:e,stateObj:n,promisesData:i,resolvingTypesonPromise:a,awaitingTypesonPromise:b(t,N)},{type:U}))}:null;if(["string","boolean","number","undefined"].includes(E))return t===void 0||E==="number"&&(isNaN(t)||t===-1/0||t===1/0)?(n.replaced?T=t:T=we(I,t,n,i,!1,a,L),T!==t&&(B={replaced:T})):T=t,L&&L(),T;if(t===null)return L&&L(),t;if(e&&!n.iterateIn&&!n.iterateUnsetNumeric&&t&&s(t)==="object"){var Y=Ae.indexOf(t);if(Y<0)e===!0&&(Ae.push(t),Ue.push(I));else return C[I]="#",L&&L({cyclicKeypath:Ue[Y]}),"#"+Ue[Y]}var q=f(t),ae=be(t),Q=(q||ae)&&(!W.plainObjectReplacers.length||n.replaced)||n.iterateIn?t:we(I,t,n,i,q||ae,null,L),X;if(Q!==t?(T=Q,B={replaced:Q}):I===""&&b(t,N)?(i.push([I,t,e,n,void 0,void 0,n.type]),T=t):ae&&n.iterateIn!=="object"||n.iterateIn==="array"?(X=new Array(t.length),B={clone:X}):!["function","symbol"].includes(s(t))&&!("toJSON"in t)&&!b(t,N)&&!b(t,Promise)&&!b(t,ArrayBuffer)||q||n.iterateIn==="object"?(X={},n.addLength&&(X.length=t.length),B={clone:X}):T=t,L&&L(),A.iterateNone)return X||T;if(!X)return T;if(n.iterateIn){var fe=function(U){var k={ownKeys:Ce.call(t,U)};ne(n,k,function(){var x=I+(I?".":"")+ie(U),z=ue(x,t[U],!!e,n,i,a);b(z,N)?i.push([x,z,!!e,n,X,U,n.type]):z!==void 0&&(X[U]=z)})};for(var le in t)fe(le);L&&L({endIterateIn:!0,end:!0})}else ce(t).forEach(function(S){var U=I+(I?".":"")+ie(S),k={ownKeys:!0};ne(n,k,function(){var x=ue(U,t[S],!!e,n,i,a);b(x,N)?i.push([U,x,!!e,n,X,S,n.type]):x!==void 0&&(X[S]=x)})}),L&&L({endIterateOwn:!0,end:!0});if(n.iterateUnsetNumeric){for(var D=t.length,Te=function(U){if(!(U in t)){var k=I+(I?".":"")+U,x={ownKeys:!1};ne(n,x,function(){var z=ue(k,void 0,!!e,n,i,a);b(z,N)?i.push([k,z,!!e,n,X,U,n.type]):z!==void 0&&(X[U]=z)})}},P=0;Pt.length)&&(e=t.length);for(var n=0,i=new Array(e);n"u"||!(Symbol.iterator in Object(i)))){var O=[],T=!0,B=!1,E=void 0;try{for(var L,Y=i[Symbol.iterator]();!(T=(L=Y.next()).done)&&(O.push(L.value),!a||O.length!==a);T=!0);}catch(q){B=!0,E=q}finally{try{T||Y.return==null||Y.return()}finally{if(B)throw E}}return O}}(t,e)||Ee(t,e)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ee(t){return function(n){if(Array.isArray(n))return me(n)}(t)||function(n){if(typeof Symbol<"u"&&Symbol.iterator in Object(n))return Array.from(n)}(t)||Ee(t)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ee(t,e){if(t){if(typeof t=="string")return me(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?me(t,e):void 0}}function me(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n-1){var i=t[M(e.slice(0,n))];return i===void 0?void 0:ie(i,e.slice(n+1))}return t[M(e)]}function he(t,e,n){if(e==="")return n;var i=e.indexOf(".");return i>-1?he(t[M(e.slice(0,i))],e.slice(i+1),n):(t[M(e)]=n,t)}function Se(t,e,n){return t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t}var Be=Object.keys,_e=Array.isArray,ce={}.hasOwnProperty,be=["type","replaced","iterateIn","iterateUnsetNumeric"];function Ce(t){return function(){for(var e=[],n=0;ni?-1:ne.keypath}var $=function(){function t(e){_(this,t),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}return function(n,i,a){return F(n.prototype,i),n}(t,[{key:"stringify",value:function(n,i,a,O){O=J(J(J({},this.options),O),{},{stringification:!0});var T=this.encapsulate(n,null,O);return _e(T)?JSON.stringify(T[0],i,a):T.then(function(B){return JSON.stringify(B,i,a)})}},{key:"stringifySync",value:function(n,i,a,O){return this.stringify(n,i,a,J(J({throwOnBadSyncType:!0},O),{},{sync:!0}))}},{key:"stringifyAsync",value:function(n,i,a,O){return this.stringify(n,i,a,J(J({throwOnBadSyncType:!0},O),{},{sync:!1}))}},{key:"parse",value:function(n,i,a){return a=J(J(J({},this.options),a),{},{parse:!0}),this.revive(JSON.parse(n,i),a)}},{key:"parseSync",value:function(n,i,a){return this.parse(n,i,J(J({throwOnBadSyncType:!0},a),{},{sync:!0}))}},{key:"parseAsync",value:function(n,i,a){return this.parse(n,i,J(J({throwOnBadSyncType:!0},a),{},{sync:!1}))}},{key:"specialTypeNames",value:function(n,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return a.returnTypeNames=!0,this.encapsulate(n,i,a)}},{key:"rootTypeName",value:function(n,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return a.iterateNone=!0,this.encapsulate(n,i,a)}},{key:"encapsulate",value:function(n,i,a){var O=Ce(function(P,S){return Se(Promise.all(S.map(function(U){return U[1].p})),function(U){return Se(Promise.all(U.map(Ce(function(k){var x=!1,z=[],Ke=V(S.splice(0,1),1),Oe=V(Ke[0],7),Le=Oe[0],De=Oe[2],se=Oe[3],Ve=Oe[4],de=Oe[5],$e=Oe[6],je=D(Le,k,De,se,z,!0,$e),ze=r(je,N);return function(yn,on){var tn=yn();return tn&&tn.then?tn.then(on):on(tn)}(function(){if(Le&&ze)return Se(je.p,function(He){return Ve[de]=He,x=!0,O(P,z)})},function(He){return x?He:(Le?Ve[de]=je:P=ze?je.p:je,O(P,z))})}))),function(){return P})})}),T=(a=J(J({sync:!0},this.options),a)).sync,B=this,E={},L=[],Y=[],q=[],ae=!("cyclic"in a)||a.cyclic,Q=a.encapsulateObserver,X=D("",n,ae,i||{},q);function fe(P){var S=Object.values(E);if(a.iterateNone)return S.length?S[0]:t.getJSONType(P);if(S.length){if(a.returnTypeNames)return ee(new Set(S));P&&b(P)&&!ce.call(P,"$types")?P.$types=E:P={$:P,$types:{$:E}}}else f(P)&&ce.call(P,"$types")&&(P={$:P,$types:!0});return!a.returnTypeNames&&P}function le(P,S,U){Object.assign(P,S);var k=be.map(function(x){var z=P[x];return delete P[x],z});U(),be.forEach(function(x,z){P[x]=k[z]})}function D(P,S,U,k,x,z,Ke){var Oe,Le={},De=u(S),se=Q?function(Ze){var Ie=Ke||k.type||t.getJSONType(S);Q(Object.assign(Ze||Le,{keypath:P,value:S,cyclic:U,stateObj:k,promisesData:x,resolvingTypesonPromise:z,awaitingTypesonPromise:r(S,N)},{type:Ie}))}:null;if(["string","boolean","number","undefined"].includes(De))return S===void 0||Number.isNaN(S)||S===Number.NEGATIVE_INFINITY||S===Number.POSITIVE_INFINITY?(Oe=k.replaced?S:Te(P,S,k,x,!1,z,se))!==S&&(Le={replaced:Oe}):Oe=S,se&&se(),Oe;if(S===null)return se&&se(),S;if(U&&!k.iterateIn&&!k.iterateUnsetNumeric&&S&&u(S)==="object"){var Ve=L.indexOf(S);if(!(Ve<0))return E[P]="#",se&&se({cyclicKeypath:Y[Ve]}),"#"+Y[Ve];U===!0&&(L.push(S),Y.push(P))}var de,$e=b(S),je=_e(S),ze=($e||je)&&(!B.plainObjectReplacers.length||k.replaced)||k.iterateIn?S:Te(P,S,k,x,$e||je,null,se);if(ze!==S?(Oe=ze,Le={replaced:ze}):P===""&&r(S,N)?(x.push([P,S,U,k,void 0,void 0,k.type]),Oe=S):je&&k.iterateIn!=="object"||k.iterateIn==="array"?(de=new Array(S.length),Le={clone:de}):(["function","symbol"].includes(u(S))||"toJSON"in S||r(S,N)||r(S,Promise)||r(S,ArrayBuffer))&&!$e&&k.iterateIn!=="object"?Oe=S:(de={},k.addLength&&(de.length=S.length),Le={clone:de}),se&&se(),a.iterateNone)return de||Oe;if(!de)return Oe;if(k.iterateIn){var He=function(Ie){var Qe={ownKeys:ce.call(S,Ie)};le(k,Qe,function(){var nn=P+(P?".":"")+Z(Ie),un=D(nn,S[Ie],!!U,k,x,z);r(un,N)?x.push([nn,un,!!U,k,de,Ie,k.type]):un!==void 0&&(de[Ie]=un)})};for(var yn in S)He(yn);se&&se({endIterateIn:!0,end:!0})}else Be(S).forEach(function(Ze){var Ie=P+(P?".":"")+Z(Ze);le(k,{ownKeys:!0},function(){var Qe=D(Ie,S[Ze],!!U,k,x,z);r(Qe,N)?x.push([Ie,Qe,!!U,k,de,Ze,k.type]):Qe!==void 0&&(de[Ze]=Qe)})}),se&&se({endIterateOwn:!0,end:!0});if(k.iterateUnsetNumeric){for(var on=S.length,tn=function(Ie){if(!(Ie in S)){var Qe=P+(P?".":"")+Ie;le(k,{ownKeys:!1},function(){var nn=D(Qe,void 0,!!U,k,x,z);r(nn,N)?x.push([Qe,nn,!!U,k,de,Ie,k.type]):nn!==void 0&&(de[Ie]=nn)})}},dn=0;dn>2],T+=C[(3&a[B])<<4|a[B+1]>>4],T+=C[(15&a[B+1])<<2|a[B+2]>>6],T+=C[63&a[B+2]];return O%3==2?T=T.slice(0,-1)+"=":O%3==1&&(T=T.slice(0,-2)+"=="),T},Ge=function(e){var n,i,a,O,T=e.length,B=.75*e.length,E=0;e[e.length-1]==="="&&(B--,e[e.length-2]==="="&&B--);for(var L=new ArrayBuffer(B),Y=new Uint8Array(L),q=0;q>4,Y[E++]=(15&i)<<4|a>>2,Y[E++]=(3&a)<<6|63&O;return L},Ye={arraybuffer:{test:function(e){return $.toStringTag(e)==="ArrayBuffer"},replace:function(e,n){n.buffers||(n.buffers=[]);var i=n.buffers.indexOf(e);return i>-1?{index:i}:(n.buffers.push(e),xe(e))},revive:function(e,n){if(n.buffers||(n.buffers=[]),s(e)==="object")return n.buffers[e.index];var i=Ge(e);return n.buffers.push(i),i}}},Xe=typeof self>"u"?hn:self,Fe={};["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].forEach(function(t){var e=t,n=Xe[e];n&&(Fe[t.toLowerCase()]={test:function(a){return $.toStringTag(a)===e},replace:function(a,O){var T=a.buffer,B=a.byteOffset,E=a.length;O.buffers||(O.buffers=[]);var L=O.buffers.indexOf(T);return L>-1?{index:L,byteOffset:B,length:E}:(O.buffers.push(T),{encoded:xe(T),byteOffset:B,length:E})},revive:function(a,O){O.buffers||(O.buffers=[]);var T,B=a.byteOffset,E=a.length,L=a.encoded,Y=a.index;return"index"in a?T=O.buffers[Y]:(T=Ge(L),O.buffers.push(T)),new n(T,B,E)}})});var qe={dataview:{test:function(e){return $.toStringTag(e)==="DataView"},replace:function(e,n){var i=e.buffer,a=e.byteOffset,O=e.byteLength;n.buffers||(n.buffers=[]);var T=n.buffers.indexOf(i);return T>-1?{index:T,byteOffset:a,byteLength:O}:(n.buffers.push(i),{encoded:xe(i),byteOffset:a,byteLength:O})},revive:function(e,n){n.buffers||(n.buffers=[]);var i,a=e.byteOffset,O=e.byteLength,T=e.encoded,B=e.index;return"index"in e?i=n.buffers[B]:(i=Ge(T),n.buffers.push(i)),new DataView(i,a,O)}}},ge={IntlCollator:{test:function(e){return $.hasConstructorOf(e,Intl.Collator)},replace:function(e){return e.resolvedOptions()},revive:function(e){return new Intl.Collator(e.locale,e)}},IntlDateTimeFormat:{test:function(e){return $.hasConstructorOf(e,Intl.DateTimeFormat)},replace:function(e){return e.resolvedOptions()},revive:function(e){return new Intl.DateTimeFormat(e.locale,e)}},IntlNumberFormat:{test:function(e){return $.hasConstructorOf(e,Intl.NumberFormat)},replace:function(e){return e.resolvedOptions()},revive:function(e){return new Intl.NumberFormat(e.locale,e)}}};function oe(t){for(var e=new Uint8Array(t.length),n=0;n>2],o+=rn[(w[j]&3)<<4|w[j+1]>>4],o+=rn[(w[j+1]&15)<<2|w[j+2]>>6],o+=rn[w[j+2]&63];return p%3===2?o=o.slice(0,-1)+"=":p%3===1&&(o=o.slice(0,-2)+"=="),o},On=function(v){var s=v.length,m=v.length*.75,w=0,p,o,j,R;v[v.length-1]==="="&&(m--,v[v.length-2]==="="&&m--);for(var u=new ArrayBuffer(m),_=new Uint8Array(u),F=0;F>4,_[w++]=(o&15)<<4|j>>2,_[w++]=(j&3)<<6|R&63;return u},jn=typeof self>"u"?global:self,Sn={};["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].forEach(function(g){var v=g,s=jn[v];s&&(Sn[g.toLowerCase()+"2"]={test:function(m){return pn.toStringTag(m)===v},replace:function(m){var w=m.buffer,p=m.byteOffset,o=m.length;return{buffer:w,byteOffset:p,length:o}},revive:function(m){var w=m.buffer,p=m.byteOffset,o=m.length;return new s(w,p,o)}})});var In={arraybuffer:{test:function(g){return pn.toStringTag(g)==="ArrayBuffer"},replace:function(g){return vn(g,0,g.byteLength)},revive:function(g){var v=On(g);return v}}},Je=new pn().register(Pn),Bn="FileReaderSync"in self,ln=[],cn=0;Je.register([In,Sn,{blob2:{test:function(g){return pn.toStringTag(g)==="Blob"},replace:function(g){if(g.isClosed)throw new Error("The Blob is closed");if(Bn){var v=wn(g,"binary"),s=vn(v,0,v.byteLength);return{type:g.type,data:s}}else{ln.push(g);var m={type:g.type,data:{start:cn,end:cn+g.size}};return cn+=g.size,m}},finalize:function(g,v){g.data=vn(v,0,v.byteLength)},revive:function(g){var v=g.type,s=g.data;return new Blob([On(s)],{type:v})}}}]);Je.mustFinalize=function(){return ln.length>0};Je.finalize=function(g){return en(void 0,void 0,void 0,function(){var v,s,m,w,p,o,j,R,u,_,F,pe;return We(this,function(ve){switch(ve.label){case 0:return[4,gn(new Blob(ln),"binary")];case 1:if(v=ve.sent(),g){for(s=0,m=g;s0&&(p.push(","),j&&p.push(` `)),he=be.length===r,c?(Ce=V?be.filter(function(d){return V(te,d)}):be,Me=ee?Ce.map(function(d){return ee(te,d).value}):Ce,$=Me.map(function(d){return Je.encapsulate(d)}),Je.mustFinalize()?[4,Re.waitFor(Je.finalize($))]:[3,3]):[3,4]);case 2:h.sent(),h.label=3;case 3:return y=JSON.stringify($,void 0,j?2:void 0),j&&(y=y.split(` `).join(` `)),p.push(new Blob([y.substring(1,y.length-1)])),ie=Me.length,M=be.length>0?Re.getByKeyPath(be[be.length-1],Pe.keyPath):null,[3,8];case 4:return[4,ce.primaryKeys()];case 5:return ye=h.sent(),ke=ye.map(function(d,A){return[d,be[A]]}),V&&(ke=ke.filter(function(d){var A=d[0],G=d[1];return V(te,G,A)})),ee&&(ke=ke.map(function(d){var A=d[0],G=d[1],H=ee(te,G,A);return[H.key,H.value]})),l=ke.map(function(d){return Je.encapsulate(d)}),Je.mustFinalize()?[4,Re.waitFor(Je.finalize(l))]:[3,7];case 6:h.sent(),h.label=7;case 7:y=JSON.stringify(l,void 0,j?2:void 0),j&&(y=y.split(` `).join(` `)),p.push(new Blob([y.substring(1,y.length-1)])),ie=ke.length,M=ye.length>0?ye[ye.length-1]:null,h.label=8;case 8:return _.completedRows+=be.length,[2]}})},_e.label=1;case 1:return he?[5,Se()]:[3,3];case 2:return Be=_e.sent(),Be==="break"?[3,3]:[3,1];case 3:return p.push(f.substr(Z)),_.completedTables+=1,_.completedTables<_.totalTables&&p.push(","),[2]}})},me=0,N=o,K.label=2;case 2:return mer)switch(f){case"text":closeText(c);break;default:K(c,"Max buffer length exceeded: "+f)}b=Math.max(b,Z)}c.bufferCheckPosition=s.MAX_BUFFER_LENGTH-b+c.position}function F(c){for(var r in w)c[r]=w[r]}var pe=/[\\"\n]/g;function ve(c){if(!(this instanceof ve))return new ve(c);var r=this;F(r),r.bufferCheckPosition=s.MAX_BUFFER_LENGTH,r.q=r.c=r.p="",r.opt=c||{},r.closed=r.closedRoot=r.sawRoot=!1,r.tag=r.error=null,r.state=o.BEGIN,r.stack=new Array,r.position=r.column=0,r.line=1,r.slashed=!1,r.unicodeI=0,r.unicodeS=null,r.depth=0,ee(r,"onready")}ve.prototype={end:function(){te(this)},write:Pe,resume:function(){return this.error=null,this},close:function(){return this.write(null)}};try{j=Ln.Stream}catch{j=function(){}}function J(c){return new V(c)}function V(c){if(!(this instanceof V))return new V(c);this._parser=new ve(c),this.writable=!0,this.readable=!0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.temp_buffs={2:new Buffer(2),3:new Buffer(3),4:new Buffer(4)},this.string="";var r=this;j.apply(r),this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(b){r.emit("error",b),r._parser.error=null},p.forEach(function(b){Object.defineProperty(r,"on"+b,{get:function(){return r._parser["on"+b]},set:function(f){if(!f)return r.removeAllListeners(b),r._parser["on"+b]=f,f;r.on(b,f)},enumerable:!0,configurable:!1})})}V.prototype=Object.create(j.prototype,{constructor:{value:V}}),V.prototype.write=function(c){c=new Buffer(c);for(var r=0;r0){for(var f=0;f=128)if(b>=194&&b<=223&&(this.bytes_in_sequence=2),b>=224&&b<=239&&(this.bytes_in_sequence=3),b>=240&&b<=244&&(this.bytes_in_sequence=4),this.bytes_in_sequence+r>c.length){for(var Z=0;Z<=c.length-1-r;Z++)this.temp_buffs[this.bytes_in_sequence][Z]=c[r+Z];return this.bytes_remaining=r+this.bytes_in_sequence-c.length,!0}else{this.string=c.slice(r,r+this.bytes_in_sequence).toString(),r=r+this.bytes_in_sequence-1,this._parser.write(this.string),this.emit("data",this.string);continue}for(var M=r;M=128);M++);this.string=c.slice(r,M).toString(),this._parser.write(this.string),this.emit("data",this.string),r=M-1}},V.prototype.end=function(c){return c&&c.length&&this._parser.write(c.toString()),this._parser.end(),!0},V.prototype.on=function(c,r){var b=this;return!b._parser["on"+c]&&p.indexOf(c)!==-1&&(b._parser["on"+c]=function(){var f=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);f.splice(0,0,c),b.emit.apply(b,f)}),j.prototype.on.call(b,c,r)},V.prototype.destroy=function(){F(this._parser),this.emit("close")};function ee(c,r,b){s.INFO&&console.log("-- emit",r,b),c[r]&&c[r](b)}function Ee(c,r,b){me(c),ee(c,r,b)}function me(c,r){c.textNode=Ne(c.opt,c.textNode),c.textNode!==void 0&&ee(c,r||"onvalue",c.textNode),c.textNode=void 0}function N(c){c.numberNode&&ee(c,"onvalue",parseFloat(c.numberNode)),c.numberNode=""}function Ne(c,r){return r===void 0||(c.trim&&(r=r.trim()),c.normalize&&(r=r.replace(/\s+/g," "))),r}function K(c,r){return me(c),r+=` Line: `+c.line+` Column: `+c.column+` Char: `+c.c,r=new Error(r),c.error=r,ee(c,"onerror",r),c}function te(c){return(c.state!==o.VALUE||c.depth!==0)&&K(c,"Unexpected end"),me(c),c.c="",c.closed=!0,ee(c,"onend"),ve.call(c,c.opt),c}function re(c){return c===u.carriageReturn||c===u.lineFeed||c===u.space||c===u.tab}function Pe(c){var r=this;if(this.error)throw this.error;if(r.closed)return K(r,"Cannot write after close. Assign an onready handler.");if(c===null)return te(r);var b=0,f=c.charCodeAt(0),Z=r.p;for(s.DEBUG&&console.log("write -> ["+c+"]");f&&(Z=f,r.c=f=c.charCodeAt(b++),Z!==f?r.p=Z:Z=r.p,!!f);)switch(s.DEBUG&&console.log(b,f,s.STATE[r.state]),r.position++,f===u.lineFeed?(r.line++,r.column=0):r.column++,r.state){case o.BEGIN:f===u.openBrace?r.state=o.OPEN_OBJECT:f===u.openBracket?r.state=o.OPEN_ARRAY:re(f)||K(r,"Non-whitespace before {[.");continue;case o.OPEN_KEY:case o.OPEN_OBJECT:if(re(f))continue;if(r.state===o.OPEN_KEY)r.stack.push(o.CLOSE_KEY);else if(f===u.closeBrace){ee(r,"onopenobject"),this.depth++,ee(r,"oncloseobject"),this.depth--,r.state=r.stack.pop()||o.VALUE;continue}else r.stack.push(o.CLOSE_OBJECT);f===u.doubleQuote?r.state=o.STRING:K(r,'Malformed object key should start with "');continue;case o.CLOSE_KEY:case o.CLOSE_OBJECT:if(re(f))continue;r.state,o.CLOSE_KEY,f===u.colon?(r.state===o.CLOSE_OBJECT?(r.stack.push(o.CLOSE_OBJECT),me(r,"onopenobject"),this.depth++):me(r,"onkey"),r.state=o.VALUE):f===u.closeBrace?(Ee(r,"oncloseobject"),this.depth--,r.state=r.stack.pop()||o.VALUE):f===u.comma?(r.state===o.CLOSE_OBJECT&&r.stack.push(o.CLOSE_OBJECT),me(r),r.state=o.OPEN_KEY):K(r,"Bad object");continue;case o.OPEN_ARRAY:case o.VALUE:if(re(f))continue;if(r.state===o.OPEN_ARRAY)if(ee(r,"onopenarray"),this.depth++,r.state=o.VALUE,f===u.closeBracket){ee(r,"onclosearray"),this.depth--,r.state=r.stack.pop()||o.VALUE;continue}else r.stack.push(o.CLOSE_ARRAY);f===u.doubleQuote?r.state=o.STRING:f===u.openBrace?r.state=o.OPEN_OBJECT:f===u.openBracket?r.state=o.OPEN_ARRAY:f===u.t?r.state=o.TRUE:f===u.f?r.state=o.FALSE:f===u.n?r.state=o.NULL:f===u.minus?r.numberNode+="-":u._0<=f&&f<=u._9?(r.numberNode+=String.fromCharCode(f),r.state=o.NUMBER_DIGIT):K(r,"Bad value");continue;case o.CLOSE_ARRAY:if(f===u.comma)r.stack.push(o.CLOSE_ARRAY),me(r,"onvalue"),r.state=o.VALUE;else if(f===u.closeBracket)Ee(r,"onclosearray"),this.depth--,r.state=r.stack.pop()||o.VALUE;else{if(re(f))continue;K(r,"Bad array")}continue;case o.STRING:r.textNode===void 0&&(r.textNode="");var M=b-1,ie=r.slashed,he=r.unicodeI;e:for(;;){for(s.DEBUG&&console.log(b,f,s.STATE[r.state],ie);he>0;)if(r.unicodeS+=String.fromCharCode(f),f=c.charCodeAt(b++),r.position++,he===4?(r.textNode+=String.fromCharCode(parseInt(r.unicodeS,16)),he=0,M=b-1):he++,!f)break e;if(f===u.doubleQuote&&!ie){r.state=r.stack.pop()||o.VALUE,r.textNode+=c.substring(M,b-1),r.position+=b-1-M;break}if(f===u.backslash&&!ie&&(ie=!0,r.textNode+=c.substring(M,b-1),r.position+=b-1-M,f=c.charCodeAt(b++),r.position++,!f))break;if(ie){if(ie=!1,f===u.n?r.textNode+=` `:f===u.r?r.textNode+="\r":f===u.t?r.textNode+=" ":f===u.f?r.textNode+="\f":f===u.b?r.textNode+="\b":f===u.u?(he=1,r.unicodeS=""):r.textNode+=String.fromCharCode(f),f=c.charCodeAt(b++),r.position++,M=b-1,f)continue;break}pe.lastIndex=b;var Se=pe.exec(c);if(Se===null){b=c.length+1,r.textNode+=c.substring(M,b-1),r.position+=b-1-M;break}if(b=Se.index+1,f=c.charCodeAt(Se.index),!f){r.textNode+=c.substring(M,b-1),r.position+=b-1-M;break}}r.slashed=ie,r.unicodeI=he;continue;case o.TRUE:f===u.r?r.state=o.TRUE2:K(r,"Invalid true started with t"+f);continue;case o.TRUE2:f===u.u?r.state=o.TRUE3:K(r,"Invalid true started with tr"+f);continue;case o.TRUE3:f===u.e?(ee(r,"onvalue",!0),r.state=r.stack.pop()||o.VALUE):K(r,"Invalid true started with tru"+f);continue;case o.FALSE:f===u.a?r.state=o.FALSE2:K(r,"Invalid false started with f"+f);continue;case o.FALSE2:f===u.l?r.state=o.FALSE3:K(r,"Invalid false started with fa"+f);continue;case o.FALSE3:f===u.s?r.state=o.FALSE4:K(r,"Invalid false started with fal"+f);continue;case o.FALSE4:f===u.e?(ee(r,"onvalue",!1),r.state=r.stack.pop()||o.VALUE):K(r,"Invalid false started with fals"+f);continue;case o.NULL:f===u.u?r.state=o.NULL2:K(r,"Invalid null started with n"+f);continue;case o.NULL2:f===u.l?r.state=o.NULL3:K(r,"Invalid null started with nu"+f);continue;case o.NULL3:f===u.l?(ee(r,"onvalue",null),r.state=r.stack.pop()||o.VALUE):K(r,"Invalid null started with nul"+f);continue;case o.NUMBER_DECIMAL_POINT:f===u.period?(r.numberNode+=".",r.state=o.NUMBER_DIGIT):K(r,"Leading zero not followed by .");continue;case o.NUMBER_DIGIT:u._0<=f&&f<=u._9?r.numberNode+=String.fromCharCode(f):f===u.period?(r.numberNode.indexOf(".")!==-1&&K(r,"Invalid number has two dots"),r.numberNode+="."):f===u.e||f===u.E?((r.numberNode.indexOf("e")!==-1||r.numberNode.indexOf("E")!==-1)&&K(r,"Invalid number has two exponential"),r.numberNode+="e"):f===u.plus||f===u.minus?(Z===u.e||Z===u.E||K(r,"Invalid symbol in number"),r.numberNode+=String.fromCharCode(f)):(N(r),b--,r.state=r.stack.pop()||o.VALUE);continue;default:K(r,"Unknown state: "+r.state)}return r.position>=r.bufferCheckPosition&&_(r),r}})(v)});function xn(g){var v=0,s=Fn(),m={pullAsync:function(w){return en(this,void 0,void 0,function(){var p,o,j;return We(this,function(R){switch(R.label){case 0:return p=g.slice(v,v+w),v+=w,[4,gn(p,"text")];case 1:return o=R.sent(),j=s.write(o),m.result=j||{},[2,j]}})})},pullSync:function(w){var p=g.slice(v,v+w);v+=w;var o=wn(p,"text"),j=s.write(o);return m.result=j||{},j},done:function(){return s.done()},eof:function(){return v>=g.size},result:{}};return m}function Fn(g){var v=Rn.parser(),s=0,m,w=[],p,o,j=!1,R=!1;return v.onopenobject=function(u){var _={};_.incomplete=!0,m||(m=_),p&&(w.push([o,p,R]),R?p.push(_):p[o]=_),p=_,o=u,R=!1,++s},v.onkey=function(u){return o=u},v.onvalue=function(u){return R?p.push(u):p[o]=u},v.oncloseobject=function(){var u;delete p.incomplete,o=null,--s===0?j=!0:(u=w.pop(),o=u[0],p=u[1],R=u[2])},v.onopenarray=function(){var u=[];u.incomplete=!0,m||(m=u),p&&(w.push([o,p,R]),R?p.push(u):p[o]=u),p=u,R=!0,o=null,++s},v.onclosearray=function(){var u;delete p.incomplete,o=null,--s===0?j=!0:(u=w.pop(),o=u[0],p=u[1],R=u[2])},{write:function(u){return v.write(u),m},done:function(){return j}}}var An=1024;function Kn(g,v){return en(this,void 0,void 0,function(){var s,m,w,p;return We(this,function(o){switch(o.label){case 0:return v=v||{},s=v.chunkSizeBytes||An*1024,[4,En(g,s)];case 1:return m=o.sent(),w=m.result.data,p=new Re(v.name!==void 0?v.name:w.databaseName),p.version(w.databaseVersion).stores(Nn(w)),[4,Tn(p,m,v.name!==void 0?fn(fn({},v),{acceptNameDiff:!0}):v)];case 2:return o.sent(),[2,p]}})})}function Tn(g,v,s){return en(this,void 0,void 0,function(){function m(){return en(this,void 0,void 0,function(){var V,ee,Ee,me,N;return We(this,function(Ne){switch(Ne.label){case 0:V=function(K){var te,re,Pe,c,r,b,f,Z,M,ie,he,Se,Be;return We(this,function(_e){switch(_e.label){case 0:if(u.includes(K.tableName))return[2,"continue"];if(!K.rows)return[2,"break"];if(!K.rows.incomplete&&K.rows.length===0)return[2,"continue"];if(_&&Re.ignoreTransaction(function(){return _(F)}),te=K.tableName,re=g.table(te),Pe=R.tables.filter(function(ce){return ce.name===te})[0].schema,!re){if(s.acceptMissingTables)return[2,"continue"];throw new Error("Exported table ".concat(K.tableName," is missing in installed database"))}if(!s.acceptChangedPrimaryKey&&Pe.split(",")[0]!=re.schema.primKey.src)throw new Error("Primary key differs for table ".concat(K.tableName,". "));for(c=K.rows,r=[],b=0;b0&&R.data[0].rows&&!R.data[0].rows.incomplete;)R.data.splice(0,1);return!p.done()&&!p.eof()?j?(p.pullSync(w),[3,7]):[3,5]:[3,8];case 5:return[4,Re.waitFor(p.pullAsync(w))];case 6:Ne.sent(),Ne.label=7;case 7:return[3,9];case 8:return[3,10];case 9:return[3,0];case 10:return[2]}})})}var w,p,o,j,R,u,_,F,pe,ve,J;return We(this,function(V){switch(V.label){case 0:return s=s||{},w=s.chunkSizeBytes||An*1024,[4,En(v,w)];case 1:if(p=V.sent(),o=p.result,j="FileReaderSync"in self,R=o.data,u=s.skipTables?s.skipTables:[],!s.acceptNameDiff&&g.name!==R.databaseName)throw new Error("Name differs. Current database name is ".concat(g.name," but export is ").concat(R.databaseName));if(!s.acceptVersionDiff&&g.verno!==R.databaseVersion)throw new Error("Database version differs. Current database is in version ".concat(g.verno," but export is ").concat(R.databaseVersion));if(_=s.progressCallback,F={done:!1,completedRows:0,completedTables:0,totalRows:R.tables.reduce(function(ee,Ee){return ee+Ee.rowCount},0),totalTables:R.tables.length},_&&Re.ignoreTransaction(function(){return _(F)}),!s.clearTablesBeforeImport)return[3,5];pe=0,ve=g.tables,V.label=2;case 2:return peUn)throw new Error("Format version ".concat(m.formatVersion," not supported"));if(!m.data)throw new Error("No data in export file");if(!m.data.databaseName)throw new Error("Missing databaseName in export file");if(!m.data.databaseVersion)throw new Error("Missing databaseVersion in export file");if(!m.data.tables)throw new Error("Missing tables in export file");return[2,s]}})})}Re.prototype.export=function(g){return kn(this,g)};Re.prototype.import=function(g,v){return Tn(this,g,v)};Re.import=function(g,v){return Kn(g,v)};