@luminocity/lemonate-gateway 8.2.13 → 8.2.14

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.
@@ -8,12 +8,12 @@ i.version="2.30.1",n(Za),i.fn=ur,i.min=Qa,i.max=ei,i.now=ti,i.utc=f,i.unix=cr,i.
8
8
  * Released under MIT license <https://lodash.com/license>
9
9
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
10
10
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11
- */var q=(Y||(Y=1,function(e,t){(function(){var a,i="Expected a function",n="__lodash_hash_undefined__",r="__lodash_placeholder__",s=32,o=128,l=256,u=1/0,c=9007199254740991,d=NaN,p=4294967295,h=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",s],["partialRight",64],["rearg",l]],f="[object Arguments]",m="[object Array]",y="[object Boolean]",g="[object Date]",b="[object Error]",v="[object Function]",w="[object GeneratorFunction]",_="[object Map]",A="[object Number]",k="[object Object]",S="[object Promise]",N="[object RegExp]",T="[object Set]",M="[object String]",x="[object Symbol]",C="[object WeakMap]",I="[object ArrayBuffer]",E="[object DataView]",F="[object Float32Array]",D="[object Float64Array]",R="[object Int8Array]",P="[object Int16Array]",L="[object Int32Array]",B="[object Uint8Array]",O="[object Uint8ClampedArray]",$="[object Uint16Array]",U="[object Uint32Array]",j=/\b__p \+= '';/g,z=/\b(__p \+=) '' \+/g,W=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,G=RegExp(Y.source),q=RegExp(H.source),Z=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,K=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ae=RegExp(te.source),ie=/^\s+/,ne=/\s/,re=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,oe=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ue=/[()=,{}\[\]\/\s]/,ce=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,fe=/^0b[01]+$/i,me=/^\[object .+?Constructor\]$/,ye=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,we=/['\n\r\u2028\u2029\\]/g,_e="\\ud800-\\udfff",Ae="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",ke="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Ne="A-Z\\xc0-\\xd6\\xd8-\\xde",Te="\\ufe0e\\ufe0f",Me="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xe="['’]",Ce="["+_e+"]",Ve="["+Me+"]",Ie="["+Ae+"]",Ee="\\d+",Fe="["+ke+"]",De="["+Se+"]",Re="[^"+_e+Me+Ee+ke+Se+Ne+"]",Pe="\\ud83c[\\udffb-\\udfff]",Le="[^"+_e+"]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",Oe="[\\ud800-\\udbff][\\udc00-\\udfff]",$e="["+Ne+"]",Ue="\\u200d",je="(?:"+De+"|"+Re+")",ze="(?:"+$e+"|"+Re+")",We="(?:['’](?:d|ll|m|re|s|t|ve))?",Ye="(?:['’](?:D|LL|M|RE|S|T|VE))?",He="(?:"+Ie+"|"+Pe+")?",Ge="["+Te+"]?",qe=Ge+He+"(?:"+Ue+"(?:"+[Le,Be,Oe].join("|")+")"+Ge+He+")*",Ze="(?:"+[Fe,Be,Oe].join("|")+")"+qe,Je="(?:"+[Le+Ie+"?",Ie,Be,Oe,Ce].join("|")+")",Ke=RegExp(xe,"g"),Xe=RegExp(Ie,"g"),Qe=RegExp(Pe+"(?="+Pe+")|"+Je+qe,"g"),et=RegExp([$e+"?"+De+"+"+We+"(?="+[Ve,$e,"$"].join("|")+")",ze+"+"+Ye+"(?="+[Ve,$e+je,"$"].join("|")+")",$e+"?"+je+"+"+We,$e+"+"+Ye,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ee,Ze].join("|"),"g"),tt=RegExp("["+Ue+_e+Ae+Te+"]"),at=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,it=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],nt=-1,rt={};rt[F]=rt[D]=rt[R]=rt[P]=rt[L]=rt[B]=rt[O]=rt[$]=rt[U]=!0,rt[f]=rt[m]=rt[I]=rt[y]=rt[E]=rt[g]=rt[b]=rt[v]=rt[_]=rt[A]=rt[k]=rt[N]=rt[T]=rt[M]=rt[C]=!1;var st={};st[f]=st[m]=st[I]=st[E]=st[y]=st[g]=st[F]=st[D]=st[R]=st[P]=st[L]=st[_]=st[A]=st[k]=st[N]=st[T]=st[M]=st[x]=st[B]=st[O]=st[$]=st[U]=!0,st[b]=st[v]=st[C]=!1;var ot={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lt=parseFloat,ut=parseInt,ct="object"==typeof V&&V&&V.Object===Object&&V,dt="object"==typeof self&&self&&self.Object===Object&&self,pt=ct||dt||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,mt=ft&&ft.exports===ht,yt=mt&&ct.process,gt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||yt&&yt.binding&&yt.binding("util")}catch(e){}}(),bt=gt&&gt.isArrayBuffer,vt=gt&&gt.isDate,wt=gt&&gt.isMap,_t=gt&&gt.isRegExp,At=gt&&gt.isSet,kt=gt&&gt.isTypedArray;function St(e,t,a){switch(a.length){case 0:return e.call(t);case 1:return e.call(t,a[0]);case 2:return e.call(t,a[0],a[1]);case 3:return e.call(t,a[0],a[1],a[2])}return e.apply(t,a)}function Nt(e,t,a,i){for(var n=-1,r=null==e?0:e.length;++n<r;){var s=e[n];t(i,s,a(s),e)}return i}function Tt(e,t){for(var a=-1,i=null==e?0:e.length;++a<i&&!1!==t(e[a],a,e););return e}function Mt(e,t){for(var a=null==e?0:e.length;a--&&!1!==t(e[a],a,e););return e}function xt(e,t){for(var a=-1,i=null==e?0:e.length;++a<i;)if(!t(e[a],a,e))return!1;return!0}function Ct(e,t){for(var a=-1,i=null==e?0:e.length,n=0,r=[];++a<i;){var s=e[a];t(s,a,e)&&(r[n++]=s)}return r}function Vt(e,t){return!(null==e||!e.length)&&$t(e,t,0)>-1}function It(e,t,a){for(var i=-1,n=null==e?0:e.length;++i<n;)if(a(t,e[i]))return!0;return!1}function Et(e,t){for(var a=-1,i=null==e?0:e.length,n=Array(i);++a<i;)n[a]=t(e[a],a,e);return n}function Ft(e,t){for(var a=-1,i=t.length,n=e.length;++a<i;)e[n+a]=t[a];return e}function Dt(e,t,a,i){var n=-1,r=null==e?0:e.length;for(i&&r&&(a=e[++n]);++n<r;)a=t(a,e[n],n,e);return a}function Rt(e,t,a,i){var n=null==e?0:e.length;for(i&&n&&(a=e[--n]);n--;)a=t(a,e[n],n,e);return a}function Pt(e,t){for(var a=-1,i=null==e?0:e.length;++a<i;)if(t(e[a],a,e))return!0;return!1}var Lt=Wt("length");function Bt(e,t,a){var i;return a(e,(function(e,a,n){if(t(e,a,n))return i=a,!1})),i}function Ot(e,t,a,i){for(var n=e.length,r=a+(i?1:-1);i?r--:++r<n;)if(t(e[r],r,e))return r;return-1}function $t(e,t,a){return t==t?function(e,t,a){for(var i=a-1,n=e.length;++i<n;)if(e[i]===t)return i;return-1}(e,t,a):Ot(e,jt,a)}function Ut(e,t,a,i){for(var n=a-1,r=e.length;++n<r;)if(i(e[n],t))return n;return-1}function jt(e){return e!=e}function zt(e,t){var a=null==e?0:e.length;return a?Gt(e,t)/a:d}function Wt(e){return function(t){return null==t?a:t[e]}}function Yt(e){return function(t){return null==e?a:e[t]}}function Ht(e,t,a,i,n){return n(e,(function(e,n,r){a=i?(i=!1,e):t(a,e,n,r)})),a}function Gt(e,t){for(var i,n=-1,r=e.length;++n<r;){var s=t(e[n]);s!==a&&(i=i===a?s:i+s)}return i}function qt(e,t){for(var a=-1,i=Array(e);++a<e;)i[a]=t(a);return i}function Zt(e){return e?e.slice(0,pa(e)+1).replace(ie,""):e}function Jt(e){return function(t){return e(t)}}function Kt(e,t){return Et(t,(function(t){return e[t]}))}function Xt(e,t){return e.has(t)}function Qt(e,t){for(var a=-1,i=e.length;++a<i&&$t(t,e[a],0)>-1;);return a}function ea(e,t){for(var a=e.length;a--&&$t(t,e[a],0)>-1;);return a}var ta=Yt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),aa=Yt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ia(e){return"\\"+ot[e]}function na(e){return tt.test(e)}function ra(e){var t=-1,a=Array(e.size);return e.forEach((function(e,i){a[++t]=[i,e]})),a}function sa(e,t){return function(a){return e(t(a))}}function oa(e,t){for(var a=-1,i=e.length,n=0,s=[];++a<i;){var o=e[a];o!==t&&o!==r||(e[a]=r,s[n++]=a)}return s}function la(e){var t=-1,a=Array(e.size);return e.forEach((function(e){a[++t]=e})),a}function ua(e){var t=-1,a=Array(e.size);return e.forEach((function(e){a[++t]=[e,e]})),a}function ca(e){return na(e)?function(e){for(var t=Qe.lastIndex=0;Qe.test(e);)++t;return t}(e):Lt(e)}function da(e){return na(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.split("")}(e)}function pa(e){for(var t=e.length;t--&&ne.test(e.charAt(t)););return t}var ha=Yt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),fa=function e(t){var V,ne=(t=null==t?pt:fa.defaults(pt.Object(),t,fa.pick(pt,it))).Array,_e=t.Date,Ae=t.Error,ke=t.Function,Se=t.Math,Ne=t.Object,Te=t.RegExp,Me=t.String,xe=t.TypeError,Ce=ne.prototype,Ve=ke.prototype,Ie=Ne.prototype,Ee=t["__core-js_shared__"],Fe=Ve.toString,De=Ie.hasOwnProperty,Re=0,Pe=(V=/[^.]+$/.exec(Ee&&Ee.keys&&Ee.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Le=Ie.toString,Be=Fe.call(Ne),Oe=pt._,$e=Te("^"+Fe.call(De).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=mt?t.Buffer:a,je=t.Symbol,ze=t.Uint8Array,We=Ue?Ue.allocUnsafe:a,Ye=sa(Ne.getPrototypeOf,Ne),He=Ne.create,Ge=Ie.propertyIsEnumerable,qe=Ce.splice,Ze=je?je.isConcatSpreadable:a,Je=je?je.iterator:a,Qe=je?je.toStringTag:a,tt=function(){try{var e=cr(Ne,"defineProperty");return e({},"",{}),e}catch(e){}}(),ot=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,ct=_e&&_e.now!==pt.Date.now&&_e.now,dt=t.setTimeout!==pt.setTimeout&&t.setTimeout,ht=Se.ceil,ft=Se.floor,yt=Ne.getOwnPropertySymbols,gt=Ue?Ue.isBuffer:a,Lt=t.isFinite,Yt=Ce.join,ma=sa(Ne.keys,Ne),ya=Se.max,ga=Se.min,ba=_e.now,va=t.parseInt,wa=Se.random,_a=Ce.reverse,Aa=cr(t,"DataView"),ka=cr(t,"Map"),Sa=cr(t,"Promise"),Na=cr(t,"Set"),Ta=cr(t,"WeakMap"),Ma=cr(Ne,"create"),xa=Ta&&new Ta,Ca={},Va=Pr(Aa),Ia=Pr(ka),Ea=Pr(Sa),Fa=Pr(Na),Da=Pr(Ta),Ra=je?je.prototype:a,Pa=Ra?Ra.valueOf:a,La=Ra?Ra.toString:a;function Ba(e){if(Qs(e)&&!js(e)&&!(e instanceof ja)){if(e instanceof Ua)return e;if(De.call(e,"__wrapped__"))return Lr(e)}return new Ua(e)}var Oa=function(){function e(){}return function(t){if(!Xs(t))return{};if(He)return He(t);e.prototype=t;var i=new e;return e.prototype=a,i}}();function $a(){}function Ua(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=a}function ja(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function za(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var i=e[t];this.set(i[0],i[1])}}function Wa(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var i=e[t];this.set(i[0],i[1])}}function Ya(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var i=e[t];this.set(i[0],i[1])}}function Ha(e){var t=-1,a=null==e?0:e.length;for(this.__data__=new Ya;++t<a;)this.add(e[t])}function Ga(e){var t=this.__data__=new Wa(e);this.size=t.size}function qa(e,t){var a=js(e),i=!a&&Us(e),n=!a&&!i&&Hs(e),r=!a&&!i&&!n&&oo(e),s=a||i||n||r,o=s?qt(e.length,Me):[],l=o.length;for(var u in e)!t&&!De.call(e,u)||s&&("length"==u||n&&("offset"==u||"parent"==u)||r&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gr(u,l))||o.push(u);return o}function Za(e){var t=e.length;return t?e[Hi(0,t-1)]:a}function Ja(e,t){return Fr(xn(e),ri(t,0,e.length))}function Ka(e){return Fr(xn(e))}function Xa(e,t,i){(i!==a&&!Bs(e[t],i)||i===a&&!(t in e))&&ii(e,t,i)}function Qa(e,t,i){var n=e[t];De.call(e,t)&&Bs(n,i)&&(i!==a||t in e)||ii(e,t,i)}function ei(e,t){for(var a=e.length;a--;)if(Bs(e[a][0],t))return a;return-1}function ti(e,t,a,i){return ci(e,(function(e,n,r){t(i,e,a(e),r)})),i}function ai(e,t){return e&&Cn(t,Vo(t),e)}function ii(e,t,a){"__proto__"==t&&tt?tt(e,t,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[t]=a}function ni(e,t){for(var i=-1,n=t.length,r=ne(n),s=null==e;++i<n;)r[i]=s?a:No(e,t[i]);return r}function ri(e,t,i){return e==e&&(i!==a&&(e=e<=i?e:i),t!==a&&(e=e>=t?e:t)),e}function si(e,t,i,n,r,s){var o,l=1&t,u=2&t,c=4&t;if(i&&(o=r?i(e,n,r,s):i(e)),o!==a)return o;if(!Xs(e))return e;var d=js(e);if(d){if(o=function(e){var t=e.length,a=new e.constructor(t);return t&&"string"==typeof e[0]&&De.call(e,"index")&&(a.index=e.index,a.input=e.input),a}(e),!l)return xn(e,o)}else{var p=hr(e),h=p==v||p==w;if(Hs(e))return An(e,l);if(p==k||p==f||h&&!r){if(o=u||h?{}:mr(e),!l)return u?function(e,t){return Cn(e,pr(e),t)}(e,function(e,t){return e&&Cn(t,Io(t),e)}(o,e)):function(e,t){return Cn(e,dr(e),t)}(e,ai(o,e))}else{if(!st[p])return r?e:{};o=function(e,t,a){var i,n=e.constructor;switch(t){case I:return kn(e);case y:case g:return new n(+e);case E:return function(e,t){var a=t?kn(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.byteLength)}(e,a);case F:case D:case R:case P:case L:case B:case O:case $:case U:return Sn(e,a);case _:return new n;case A:case M:return new n(e);case N:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case T:return new n;case x:return i=e,Pa?Ne(Pa.call(i)):{}}}(e,p,l)}}s||(s=new Ga);var m=s.get(e);if(m)return m;s.set(e,o),no(e)?e.forEach((function(a){o.add(si(a,t,i,a,e,s))})):eo(e)&&e.forEach((function(a,n){o.set(n,si(a,t,i,n,e,s))}));var b=d?a:(c?u?ir:ar:u?Io:Vo)(e);return Tt(b||e,(function(a,n){b&&(a=e[n=a]),Qa(o,n,si(a,t,i,n,e,s))})),o}function oi(e,t,i){var n=i.length;if(null==e)return!n;for(e=Ne(e);n--;){var r=i[n],s=t[r],o=e[r];if(o===a&&!(r in e)||!s(o))return!1}return!0}function li(e,t,n){if("function"!=typeof e)throw new xe(i);return Cr((function(){e.apply(a,n)}),t)}function ui(e,t,a,i){var n=-1,r=Vt,s=!0,o=e.length,l=[],u=t.length;if(!o)return l;a&&(t=Et(t,Jt(a))),i?(r=It,s=!1):t.length>=200&&(r=Xt,s=!1,t=new Ha(t));e:for(;++n<o;){var c=e[n],d=null==a?c:a(c);if(c=i||0!==c?c:0,s&&d==d){for(var p=u;p--;)if(t[p]===d)continue e;l.push(c)}else r(t,d,i)||l.push(c)}return l}Ba.templateSettings={escape:Z,evaluate:J,interpolate:K,variable:"",imports:{_:Ba}},Ba.prototype=$a.prototype,Ba.prototype.constructor=Ba,Ua.prototype=Oa($a.prototype),Ua.prototype.constructor=Ua,ja.prototype=Oa($a.prototype),ja.prototype.constructor=ja,za.prototype.clear=function(){this.__data__=Ma?Ma(null):{},this.size=0},za.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},za.prototype.get=function(e){var t=this.__data__;if(Ma){var i=t[e];return i===n?a:i}return De.call(t,e)?t[e]:a},za.prototype.has=function(e){var t=this.__data__;return Ma?t[e]!==a:De.call(t,e)},za.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ma&&t===a?n:t,this},Wa.prototype.clear=function(){this.__data__=[],this.size=0},Wa.prototype.delete=function(e){var t=this.__data__,a=ei(t,e);return!(a<0||(a==t.length-1?t.pop():qe.call(t,a,1),--this.size,0))},Wa.prototype.get=function(e){var t=this.__data__,i=ei(t,e);return i<0?a:t[i][1]},Wa.prototype.has=function(e){return ei(this.__data__,e)>-1},Wa.prototype.set=function(e,t){var a=this.__data__,i=ei(a,e);return i<0?(++this.size,a.push([e,t])):a[i][1]=t,this},Ya.prototype.clear=function(){this.size=0,this.__data__={hash:new za,map:new(ka||Wa),string:new za}},Ya.prototype.delete=function(e){var t=lr(this,e).delete(e);return this.size-=t?1:0,t},Ya.prototype.get=function(e){return lr(this,e).get(e)},Ya.prototype.has=function(e){return lr(this,e).has(e)},Ya.prototype.set=function(e,t){var a=lr(this,e),i=a.size;return a.set(e,t),this.size+=a.size==i?0:1,this},Ha.prototype.add=Ha.prototype.push=function(e){return this.__data__.set(e,n),this},Ha.prototype.has=function(e){return this.__data__.has(e)},Ga.prototype.clear=function(){this.__data__=new Wa,this.size=0},Ga.prototype.delete=function(e){var t=this.__data__,a=t.delete(e);return this.size=t.size,a},Ga.prototype.get=function(e){return this.__data__.get(e)},Ga.prototype.has=function(e){return this.__data__.has(e)},Ga.prototype.set=function(e,t){var a=this.__data__;if(a instanceof Wa){var i=a.__data__;if(!ka||i.length<199)return i.push([e,t]),this.size=++a.size,this;a=this.__data__=new Ya(i)}return a.set(e,t),this.size=a.size,this};var ci=En(bi),di=En(vi,!0);function pi(e,t){var a=!0;return ci(e,(function(e,i,n){return a=!!t(e,i,n)})),a}function hi(e,t,i){for(var n=-1,r=e.length;++n<r;){var s=e[n],o=t(s);if(null!=o&&(l===a?o==o&&!so(o):i(o,l)))var l=o,u=s}return u}function fi(e,t){var a=[];return ci(e,(function(e,i,n){t(e,i,n)&&a.push(e)})),a}function mi(e,t,a,i,n){var r=-1,s=e.length;for(a||(a=yr),n||(n=[]);++r<s;){var o=e[r];t>0&&a(o)?t>1?mi(o,t-1,a,i,n):Ft(n,o):i||(n[n.length]=o)}return n}var yi=Fn(),gi=Fn(!0);function bi(e,t){return e&&yi(e,t,Vo)}function vi(e,t){return e&&gi(e,t,Vo)}function wi(e,t){return Ct(t,(function(t){return Zs(e[t])}))}function _i(e,t){for(var i=0,n=(t=bn(t,e)).length;null!=e&&i<n;)e=e[Rr(t[i++])];return i&&i==n?e:a}function Ai(e,t,a){var i=t(e);return js(e)?i:Ft(i,a(e))}function ki(e){return null==e?e===a?"[object Undefined]":"[object Null]":Qe&&Qe in Ne(e)?function(e){var t=De.call(e,Qe),i=e[Qe];try{e[Qe]=a;var n=!0}catch(e){}var r=Le.call(e);return n&&(t?e[Qe]=i:delete e[Qe]),r}(e):function(e){return Le.call(e)}(e)}function Si(e,t){return e>t}function Ni(e,t){return null!=e&&De.call(e,t)}function Ti(e,t){return null!=e&&t in Ne(e)}function Mi(e,t,i){for(var n=i?It:Vt,r=e[0].length,s=e.length,o=s,l=ne(s),u=1/0,c=[];o--;){var d=e[o];o&&t&&(d=Et(d,Jt(t))),u=ga(d.length,u),l[o]=!i&&(t||r>=120&&d.length>=120)?new Ha(o&&d):a}d=e[0];var p=-1,h=l[0];e:for(;++p<r&&c.length<u;){var f=d[p],m=t?t(f):f;if(f=i||0!==f?f:0,!(h?Xt(h,m):n(c,m,i))){for(o=s;--o;){var y=l[o];if(!(y?Xt(y,m):n(e[o],m,i)))continue e}h&&h.push(m),c.push(f)}}return c}function xi(e,t,i){var n=null==(e=Tr(e,t=bn(t,e)))?e:e[Rr(qr(t))];return null==n?a:St(n,e,i)}function Ci(e){return Qs(e)&&ki(e)==f}function Vi(e,t,i,n,r){return e===t||(null==e||null==t||!Qs(e)&&!Qs(t)?e!=e&&t!=t:function(e,t,i,n,r,s){var o=js(e),l=js(t),u=o?m:hr(e),c=l?m:hr(t),d=(u=u==f?k:u)==k,p=(c=c==f?k:c)==k,h=u==c;if(h&&Hs(e)){if(!Hs(t))return!1;o=!0,d=!1}if(h&&!d)return s||(s=new Ga),o||oo(e)?er(e,t,i,n,r,s):function(e,t,a,i,n,r,s){switch(a){case E:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case I:return!(e.byteLength!=t.byteLength||!r(new ze(e),new ze(t)));case y:case g:case A:return Bs(+e,+t);case b:return e.name==t.name&&e.message==t.message;case N:case M:return e==t+"";case _:var o=ra;case T:var l=1&i;if(o||(o=la),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;i|=2,s.set(e,t);var c=er(o(e),o(t),i,n,r,s);return s.delete(e),c;case x:if(Pa)return Pa.call(e)==Pa.call(t)}return!1}(e,t,u,i,n,r,s);if(!(1&i)){var v=d&&De.call(e,"__wrapped__"),w=p&&De.call(t,"__wrapped__");if(v||w){var S=v?e.value():e,C=w?t.value():t;return s||(s=new Ga),r(S,C,i,n,s)}}return!!h&&(s||(s=new Ga),function(e,t,i,n,r,s){var o=1&i,l=ar(e),u=l.length,c=ar(t),d=c.length;if(u!=d&&!o)return!1;for(var p=u;p--;){var h=l[p];if(!(o?h in t:De.call(t,h)))return!1}var f=s.get(e),m=s.get(t);if(f&&m)return f==t&&m==e;var y=!0;s.set(e,t),s.set(t,e);for(var g=o;++p<u;){var b=e[h=l[p]],v=t[h];if(n)var w=o?n(v,b,h,t,e,s):n(b,v,h,e,t,s);if(!(w===a?b===v||r(b,v,i,n,s):w)){y=!1;break}g||(g="constructor"==h)}if(y&&!g){var _=e.constructor,A=t.constructor;_==A||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof A&&A instanceof A||(y=!1)}return s.delete(e),s.delete(t),y}(e,t,i,n,r,s))}(e,t,i,n,Vi,r))}function Ii(e,t,i,n){var r=i.length,s=r,o=!n;if(null==e)return!s;for(e=Ne(e);r--;){var l=i[r];if(o&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++r<s;){var u=(l=i[r])[0],c=e[u],d=l[1];if(o&&l[2]){if(c===a&&!(u in e))return!1}else{var p=new Ga;if(n)var h=n(c,d,u,e,t,p);if(!(h===a?Vi(d,c,3,n,p):h))return!1}}return!0}function Ei(e){return!(!Xs(e)||(t=e,Pe&&Pe in t))&&(Zs(e)?$e:me).test(Pr(e));var t}function Fi(e){return"function"==typeof e?e:null==e?al:"object"==typeof e?js(e)?Oi(e[0],e[1]):Bi(e):dl(e)}function Di(e){if(!Ar(e))return ma(e);var t=[];for(var a in Ne(e))De.call(e,a)&&"constructor"!=a&&t.push(a);return t}function Ri(e){if(!Xs(e))return function(e){var t=[];if(null!=e)for(var a in Ne(e))t.push(a);return t}(e);var t=Ar(e),a=[];for(var i in e)("constructor"!=i||!t&&De.call(e,i))&&a.push(i);return a}function Pi(e,t){return e<t}function Li(e,t){var a=-1,i=Ws(e)?ne(e.length):[];return ci(e,(function(e,n,r){i[++a]=t(e,n,r)})),i}function Bi(e){var t=ur(e);return 1==t.length&&t[0][2]?Sr(t[0][0],t[0][1]):function(a){return a===e||Ii(a,e,t)}}function Oi(e,t){return vr(e)&&kr(t)?Sr(Rr(e),t):function(i){var n=No(i,e);return n===a&&n===t?To(i,e):Vi(t,n,3)}}function $i(e,t,i,n,r){e!==t&&yi(t,(function(s,o){if(r||(r=new Ga),Xs(s))!function(e,t,i,n,r,s,o){var l=Mr(e,i),u=Mr(t,i),c=o.get(u);if(c)Xa(e,i,c);else{var d=s?s(l,u,i+"",e,t,o):a,p=d===a;if(p){var h=js(u),f=!h&&Hs(u),m=!h&&!f&&oo(u);d=u,h||f||m?js(l)?d=l:Ys(l)?d=xn(l):f?(p=!1,d=An(u,!0)):m?(p=!1,d=Sn(u,!0)):d=[]:ao(u)||Us(u)?(d=l,Us(l)?d=yo(l):Xs(l)&&!Zs(l)||(d=mr(u))):p=!1}p&&(o.set(u,d),r(d,u,n,s,o),o.delete(u)),Xa(e,i,d)}}(e,t,o,i,$i,n,r);else{var l=n?n(Mr(e,o),s,o+"",e,t,r):a;l===a&&(l=s),Xa(e,o,l)}}),Io)}function Ui(e,t){var i=e.length;if(i)return gr(t+=t<0?i:0,i)?e[t]:a}function ji(e,t,a){t=t.length?Et(t,(function(e){return js(e)?function(t){return _i(t,1===e.length?e[0]:e)}:e})):[al];var i=-1;t=Et(t,Jt(or()));var n=Li(e,(function(e,a,n){var r=Et(t,(function(t){return t(e)}));return{criteria:r,index:++i,value:e}}));return function(e,t){var a=e.length;for(e.sort(t);a--;)e[a]=e[a].value;return e}(n,(function(e,t){return function(e,t,a){for(var i=-1,n=e.criteria,r=t.criteria,s=n.length,o=a.length;++i<s;){var l=Nn(n[i],r[i]);if(l)return i>=o?l:l*("desc"==a[i]?-1:1)}return e.index-t.index}(e,t,a)}))}function zi(e,t,a){for(var i=-1,n=t.length,r={};++i<n;){var s=t[i],o=_i(e,s);a(o,s)&&Ki(r,bn(s,e),o)}return r}function Wi(e,t,a,i){var n=i?Ut:$t,r=-1,s=t.length,o=e;for(e===t&&(t=xn(t)),a&&(o=Et(e,Jt(a)));++r<s;)for(var l=0,u=t[r],c=a?a(u):u;(l=n(o,c,l,i))>-1;)o!==e&&qe.call(o,l,1),qe.call(e,l,1);return e}function Yi(e,t){for(var a=e?t.length:0,i=a-1;a--;){var n=t[a];if(a==i||n!==r){var r=n;gr(n)?qe.call(e,n,1):cn(e,n)}}return e}function Hi(e,t){return e+ft(wa()*(t-e+1))}function Gi(e,t){var a="";if(!e||t<1||t>c)return a;do{t%2&&(a+=e),(t=ft(t/2))&&(e+=e)}while(t);return a}function qi(e,t){return Vr(Nr(e,t,al),e+"")}function Zi(e){return Za(Oo(e))}function Ji(e,t){var a=Oo(e);return Fr(a,ri(t,0,a.length))}function Ki(e,t,i,n){if(!Xs(e))return e;for(var r=-1,s=(t=bn(t,e)).length,o=s-1,l=e;null!=l&&++r<s;){var u=Rr(t[r]),c=i;if("__proto__"===u||"constructor"===u||"prototype"===u)return e;if(r!=o){var d=l[u];(c=n?n(d,u,l):a)===a&&(c=Xs(d)?d:gr(t[r+1])?[]:{})}Qa(l,u,c),l=l[u]}return e}var Xi=xa?function(e,t){return xa.set(e,t),e}:al,Qi=tt?function(e,t){return tt(e,"toString",{configurable:!0,enumerable:!1,value:Qo(t),writable:!0})}:al;function en(e){return Fr(Oo(e))}function tn(e,t,a){var i=-1,n=e.length;t<0&&(t=-t>n?0:n+t),(a=a>n?n:a)<0&&(a+=n),n=t>a?0:a-t>>>0,t>>>=0;for(var r=ne(n);++i<n;)r[i]=e[i+t];return r}function an(e,t){var a;return ci(e,(function(e,i,n){return!(a=t(e,i,n))})),!!a}function nn(e,t,a){var i=0,n=null==e?i:e.length;if("number"==typeof t&&t==t&&n<=2147483647){for(;i<n;){var r=i+n>>>1,s=e[r];null!==s&&!so(s)&&(a?s<=t:s<t)?i=r+1:n=r}return n}return rn(e,t,al,a)}function rn(e,t,i,n){var r=0,s=null==e?0:e.length;if(0===s)return 0;for(var o=(t=i(t))!=t,l=null===t,u=so(t),c=t===a;r<s;){var d=ft((r+s)/2),p=i(e[d]),h=p!==a,f=null===p,m=p==p,y=so(p);if(o)var g=n||m;else g=c?m&&(n||h):l?m&&h&&(n||!f):u?m&&h&&!f&&(n||!y):!f&&!y&&(n?p<=t:p<t);g?r=d+1:s=d}return ga(s,4294967294)}function sn(e,t){for(var a=-1,i=e.length,n=0,r=[];++a<i;){var s=e[a],o=t?t(s):s;if(!a||!Bs(o,l)){var l=o;r[n++]=0===s?0:s}}return r}function on(e){return"number"==typeof e?e:so(e)?d:+e}function ln(e){if("string"==typeof e)return e;if(js(e))return Et(e,ln)+"";if(so(e))return La?La.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function un(e,t,a){var i=-1,n=Vt,r=e.length,s=!0,o=[],l=o;if(a)s=!1,n=It;else if(r>=200){var u=t?null:qn(e);if(u)return la(u);s=!1,n=Xt,l=new Ha}else l=t?[]:o;e:for(;++i<r;){var c=e[i],d=t?t(c):c;if(c=a||0!==c?c:0,s&&d==d){for(var p=l.length;p--;)if(l[p]===d)continue e;t&&l.push(d),o.push(c)}else n(l,d,a)||(l!==o&&l.push(d),o.push(c))}return o}function cn(e,t){return null==(e=Tr(e,t=bn(t,e)))||delete e[Rr(qr(t))]}function dn(e,t,a,i){return Ki(e,t,a(_i(e,t)),i)}function pn(e,t,a,i){for(var n=e.length,r=i?n:-1;(i?r--:++r<n)&&t(e[r],r,e););return a?tn(e,i?0:r,i?r+1:n):tn(e,i?r+1:0,i?n:r)}function hn(e,t){var a=e;return a instanceof ja&&(a=a.value()),Dt(t,(function(e,t){return t.func.apply(t.thisArg,Ft([e],t.args))}),a)}function fn(e,t,a){var i=e.length;if(i<2)return i?un(e[0]):[];for(var n=-1,r=ne(i);++n<i;)for(var s=e[n],o=-1;++o<i;)o!=n&&(r[n]=ui(r[n]||s,e[o],t,a));return un(mi(r,1),t,a)}function mn(e,t,i){for(var n=-1,r=e.length,s=t.length,o={};++n<r;){var l=n<s?t[n]:a;i(o,e[n],l)}return o}function yn(e){return Ys(e)?e:[]}function gn(e){return"function"==typeof e?e:al}function bn(e,t){return js(e)?e:vr(e,t)?[e]:Dr(go(e))}var vn=qi;function wn(e,t,i){var n=e.length;return i=i===a?n:i,!t&&i>=n?e:tn(e,t,i)}var _n=ot||function(e){return pt.clearTimeout(e)};function An(e,t){if(t)return e.slice();var a=e.length,i=We?We(a):new e.constructor(a);return e.copy(i),i}function kn(e){var t=new e.constructor(e.byteLength);return new ze(t).set(new ze(e)),t}function Sn(e,t){var a=t?kn(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.length)}function Nn(e,t){if(e!==t){var i=e!==a,n=null===e,r=e==e,s=so(e),o=t!==a,l=null===t,u=t==t,c=so(t);if(!l&&!c&&!s&&e>t||s&&o&&u&&!l&&!c||n&&o&&u||!i&&u||!r)return 1;if(!n&&!s&&!c&&e<t||c&&i&&r&&!n&&!s||l&&i&&r||!o&&r||!u)return-1}return 0}function Tn(e,t,a,i){for(var n=-1,r=e.length,s=a.length,o=-1,l=t.length,u=ya(r-s,0),c=ne(l+u),d=!i;++o<l;)c[o]=t[o];for(;++n<s;)(d||n<r)&&(c[a[n]]=e[n]);for(;u--;)c[o++]=e[n++];return c}function Mn(e,t,a,i){for(var n=-1,r=e.length,s=-1,o=a.length,l=-1,u=t.length,c=ya(r-o,0),d=ne(c+u),p=!i;++n<c;)d[n]=e[n];for(var h=n;++l<u;)d[h+l]=t[l];for(;++s<o;)(p||n<r)&&(d[h+a[s]]=e[n++]);return d}function xn(e,t){var a=-1,i=e.length;for(t||(t=ne(i));++a<i;)t[a]=e[a];return t}function Cn(e,t,i,n){var r=!i;i||(i={});for(var s=-1,o=t.length;++s<o;){var l=t[s],u=n?n(i[l],e[l],l,i,e):a;u===a&&(u=e[l]),r?ii(i,l,u):Qa(i,l,u)}return i}function Vn(e,t){return function(a,i){var n=js(a)?Nt:ti,r=t?t():{};return n(a,e,or(i,2),r)}}function In(e){return qi((function(t,i){var n=-1,r=i.length,s=r>1?i[r-1]:a,o=r>2?i[2]:a;for(s=e.length>3&&"function"==typeof s?(r--,s):a,o&&br(i[0],i[1],o)&&(s=r<3?a:s,r=1),t=Ne(t);++n<r;){var l=i[n];l&&e(t,l,n,s)}return t}))}function En(e,t){return function(a,i){if(null==a)return a;if(!Ws(a))return e(a,i);for(var n=a.length,r=t?n:-1,s=Ne(a);(t?r--:++r<n)&&!1!==i(s[r],r,s););return a}}function Fn(e){return function(t,a,i){for(var n=-1,r=Ne(t),s=i(t),o=s.length;o--;){var l=s[e?o:++n];if(!1===a(r[l],l,r))break}return t}}function Dn(e){return function(t){var i=na(t=go(t))?da(t):a,n=i?i[0]:t.charAt(0),r=i?wn(i,1).join(""):t.slice(1);return n[e]()+r}}function Rn(e){return function(t){return Dt(Jo(jo(t).replace(Ke,"")),e,"")}}function Pn(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var a=Oa(e.prototype),i=e.apply(a,t);return Xs(i)?i:a}}function Ln(e){return function(t,i,n){var r=Ne(t);if(!Ws(t)){var s=or(i,3);t=Vo(t),i=function(e){return s(r[e],e,r)}}var o=e(t,i,n);return o>-1?r[s?t[o]:o]:a}}function Bn(e){return tr((function(t){var n=t.length,r=n,s=Ua.prototype.thru;for(e&&t.reverse();r--;){var o=t[r];if("function"!=typeof o)throw new xe(i);if(s&&!l&&"wrapper"==rr(o))var l=new Ua([],!0)}for(r=l?r:n;++r<n;){var u=rr(o=t[r]),c="wrapper"==u?nr(o):a;l=c&&wr(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[rr(c[0])].apply(l,c[3]):1==o.length&&wr(o)?l[u]():l.thru(o)}return function(){var e=arguments,a=e[0];if(l&&1==e.length&&js(a))return l.plant(a).value();for(var i=0,r=n?t[i].apply(this,e):a;++i<n;)r=t[i].call(this,r);return r}}))}function On(e,t,i,n,r,s,l,u,c,d){var p=t&o,h=1&t,f=2&t,m=24&t,y=512&t,g=f?a:Pn(e);return function o(){for(var b=arguments.length,v=ne(b),w=b;w--;)v[w]=arguments[w];if(m)var _=sr(o),A=function(e,t){for(var a=e.length,i=0;a--;)e[a]===t&&++i;return i}(v,_);if(n&&(v=Tn(v,n,r,m)),s&&(v=Mn(v,s,l,m)),b-=A,m&&b<d){var k=oa(v,_);return Hn(e,t,On,o.placeholder,i,v,k,u,c,d-b)}var S=h?i:this,N=f?S[e]:e;return b=v.length,u?v=function(e,t){for(var i=e.length,n=ga(t.length,i),r=xn(e);n--;){var s=t[n];e[n]=gr(s,i)?r[s]:a}return e}(v,u):y&&b>1&&v.reverse(),p&&c<b&&(v.length=c),this&&this!==pt&&this instanceof o&&(N=g||Pn(N)),N.apply(S,v)}}function $n(e,t){return function(a,i){return function(e,t,a,i){return bi(e,(function(e,n,r){t(i,a(e),n,r)})),i}(a,e,t(i),{})}}function Un(e,t){return function(i,n){var r;if(i===a&&n===a)return t;if(i!==a&&(r=i),n!==a){if(r===a)return n;"string"==typeof i||"string"==typeof n?(i=ln(i),n=ln(n)):(i=on(i),n=on(n)),r=e(i,n)}return r}}function jn(e){return tr((function(t){return t=Et(t,Jt(or())),qi((function(a){var i=this;return e(t,(function(e){return St(e,i,a)}))}))}))}function zn(e,t){var i=(t=t===a?" ":ln(t)).length;if(i<2)return i?Gi(t,e):t;var n=Gi(t,ht(e/ca(t)));return na(t)?wn(da(n),0,e).join(""):n.slice(0,e)}function Wn(e){return function(t,i,n){return n&&"number"!=typeof n&&br(t,i,n)&&(i=n=a),t=po(t),i===a?(i=t,t=0):i=po(i),function(e,t,a,i){for(var n=-1,r=ya(ht((t-e)/(a||1)),0),s=ne(r);r--;)s[i?r:++n]=e,e+=a;return s}(t,i,n=n===a?t<i?1:-1:po(n),e)}}function Yn(e){return function(t,a){return"string"==typeof t&&"string"==typeof a||(t=mo(t),a=mo(a)),e(t,a)}}function Hn(e,t,i,n,r,o,l,u,c,d){var p=8&t;t|=p?s:64,4&(t&=~(p?64:s))||(t&=-4);var h=[e,t,r,p?o:a,p?l:a,p?a:o,p?a:l,u,c,d],f=i.apply(a,h);return wr(e)&&xr(f,h),f.placeholder=n,Ir(f,e,t)}function Gn(e){var t=Se[e];return function(e,a){if(e=mo(e),(a=null==a?0:ga(ho(a),292))&&Lt(e)){var i=(go(e)+"e").split("e");return+((i=(go(t(i[0]+"e"+(+i[1]+a)))+"e").split("e"))[0]+"e"+(+i[1]-a))}return t(e)}}var qn=Na&&1/la(new Na([,-0]))[1]==u?function(e){return new Na(e)}:ol;function Zn(e){return function(t){var a=hr(t);return a==_?ra(t):a==T?ua(t):function(e,t){return Et(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Jn(e,t,n,u,c,d,p,h){var f=2&t;if(!f&&"function"!=typeof e)throw new xe(i);var m=u?u.length:0;if(m||(t&=-97,u=c=a),p=p===a?p:ya(ho(p),0),h=h===a?h:ho(h),m-=c?c.length:0,64&t){var y=u,g=c;u=c=a}var b=f?a:nr(e),v=[e,t,n,u,c,y,g,d,p,h];if(b&&function(e,t){var a=e[1],i=t[1],n=a|i,s=n<131,u=i==o&&8==a||i==o&&a==l&&e[7].length<=t[8]||384==i&&t[7].length<=t[8]&&8==a;if(!s&&!u)return e;1&i&&(e[2]=t[2],n|=1&a?0:4);var c=t[3];if(c){var d=e[3];e[3]=d?Tn(d,c,t[4]):c,e[4]=d?oa(e[3],r):t[4]}(c=t[5])&&(d=e[5],e[5]=d?Mn(d,c,t[6]):c,e[6]=d?oa(e[5],r):t[6]),(c=t[7])&&(e[7]=c),i&o&&(e[8]=null==e[8]?t[8]:ga(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=n}(v,b),e=v[0],t=v[1],n=v[2],u=v[3],c=v[4],!(h=v[9]=v[9]===a?f?0:e.length:ya(v[9]-m,0))&&24&t&&(t&=-25),t&&1!=t)w=8==t||16==t?function(e,t,i){var n=Pn(e);return function r(){for(var s=arguments.length,o=ne(s),l=s,u=sr(r);l--;)o[l]=arguments[l];var c=s<3&&o[0]!==u&&o[s-1]!==u?[]:oa(o,u);return(s-=c.length)<i?Hn(e,t,On,r.placeholder,a,o,c,a,a,i-s):St(this&&this!==pt&&this instanceof r?n:e,this,o)}}(e,t,h):t!=s&&33!=t||c.length?On.apply(a,v):function(e,t,a,i){var n=1&t,r=Pn(e);return function t(){for(var s=-1,o=arguments.length,l=-1,u=i.length,c=ne(u+o),d=this&&this!==pt&&this instanceof t?r:e;++l<u;)c[l]=i[l];for(;o--;)c[l++]=arguments[++s];return St(d,n?a:this,c)}}(e,t,n,u);else var w=function(e,t,a){var i=1&t,n=Pn(e);return function t(){return(this&&this!==pt&&this instanceof t?n:e).apply(i?a:this,arguments)}}(e,t,n);return Ir((b?Xi:xr)(w,v),e,t)}function Kn(e,t,i,n){return e===a||Bs(e,Ie[i])&&!De.call(n,i)?t:e}function Xn(e,t,i,n,r,s){return Xs(e)&&Xs(t)&&(s.set(t,e),$i(e,t,a,Xn,s),s.delete(t)),e}function Qn(e){return ao(e)?a:e}function er(e,t,i,n,r,s){var o=1&i,l=e.length,u=t.length;if(l!=u&&!(o&&u>l))return!1;var c=s.get(e),d=s.get(t);if(c&&d)return c==t&&d==e;var p=-1,h=!0,f=2&i?new Ha:a;for(s.set(e,t),s.set(t,e);++p<l;){var m=e[p],y=t[p];if(n)var g=o?n(y,m,p,t,e,s):n(m,y,p,e,t,s);if(g!==a){if(g)continue;h=!1;break}if(f){if(!Pt(t,(function(e,t){if(!Xt(f,t)&&(m===e||r(m,e,i,n,s)))return f.push(t)}))){h=!1;break}}else if(m!==y&&!r(m,y,i,n,s)){h=!1;break}}return s.delete(e),s.delete(t),h}function tr(e){return Vr(Nr(e,a,zr),e+"")}function ar(e){return Ai(e,Vo,dr)}function ir(e){return Ai(e,Io,pr)}var nr=xa?function(e){return xa.get(e)}:ol;function rr(e){for(var t=e.name+"",a=Ca[t],i=De.call(Ca,t)?a.length:0;i--;){var n=a[i],r=n.func;if(null==r||r==e)return n.name}return t}function sr(e){return(De.call(Ba,"placeholder")?Ba:e).placeholder}function or(){var e=Ba.iteratee||il;return e=e===il?Fi:e,arguments.length?e(arguments[0],arguments[1]):e}function lr(e,t){var a,i,n=e.__data__;return("string"==(i=typeof(a=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==a:null===a)?n["string"==typeof t?"string":"hash"]:n.map}function ur(e){for(var t=Vo(e),a=t.length;a--;){var i=t[a],n=e[i];t[a]=[i,n,kr(n)]}return t}function cr(e,t){var i=function(e,t){return null==e?a:e[t]}(e,t);return Ei(i)?i:a}var dr=yt?function(e){return null==e?[]:(e=Ne(e),Ct(yt(e),(function(t){return Ge.call(e,t)})))}:fl,pr=yt?function(e){for(var t=[];e;)Ft(t,dr(e)),e=Ye(e);return t}:fl,hr=ki;function fr(e,t,a){for(var i=-1,n=(t=bn(t,e)).length,r=!1;++i<n;){var s=Rr(t[i]);if(!(r=null!=e&&a(e,s)))break;e=e[s]}return r||++i!=n?r:!!(n=null==e?0:e.length)&&Ks(n)&&gr(s,n)&&(js(e)||Us(e))}function mr(e){return"function"!=typeof e.constructor||Ar(e)?{}:Oa(Ye(e))}function yr(e){return js(e)||Us(e)||!!(Ze&&e&&e[Ze])}function gr(e,t){var a=typeof e;return!!(t=null==t?c:t)&&("number"==a||"symbol"!=a&&ge.test(e))&&e>-1&&e%1==0&&e<t}function br(e,t,a){if(!Xs(a))return!1;var i=typeof t;return!!("number"==i?Ws(a)&&gr(t,a.length):"string"==i&&t in a)&&Bs(a[t],e)}function vr(e,t){if(js(e))return!1;var a=typeof e;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=e&&!so(e))||Q.test(e)||!X.test(e)||null!=t&&e in Ne(t)}function wr(e){var t=rr(e),a=Ba[t];if("function"!=typeof a||!(t in ja.prototype))return!1;if(e===a)return!0;var i=nr(a);return!!i&&e===i[0]}(Aa&&hr(new Aa(new ArrayBuffer(1)))!=E||ka&&hr(new ka)!=_||Sa&&hr(Sa.resolve())!=S||Na&&hr(new Na)!=T||Ta&&hr(new Ta)!=C)&&(hr=function(e){var t=ki(e),i=t==k?e.constructor:a,n=i?Pr(i):"";if(n)switch(n){case Va:return E;case Ia:return _;case Ea:return S;case Fa:return T;case Da:return C}return t});var _r=Ee?Zs:ml;function Ar(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ie)}function kr(e){return e==e&&!Xs(e)}function Sr(e,t){return function(i){return null!=i&&i[e]===t&&(t!==a||e in Ne(i))}}function Nr(e,t,i){return t=ya(t===a?e.length-1:t,0),function(){for(var a=arguments,n=-1,r=ya(a.length-t,0),s=ne(r);++n<r;)s[n]=a[t+n];n=-1;for(var o=ne(t+1);++n<t;)o[n]=a[n];return o[t]=i(s),St(e,this,o)}}function Tr(e,t){return t.length<2?e:_i(e,tn(t,0,-1))}function Mr(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var xr=Er(Xi),Cr=dt||function(e,t){return pt.setTimeout(e,t)},Vr=Er(Qi);function Ir(e,t,a){var i=t+"";return Vr(e,function(e,t){var a=t.length;if(!a)return e;var i=a-1;return t[i]=(a>1?"& ":"")+t[i],t=t.join(a>2?", ":" "),e.replace(re,"{\n/* [wrapped with "+t+"] */\n")}(i,function(e,t){return Tt(h,(function(a){var i="_."+a[0];t&a[1]&&!Vt(e,i)&&e.push(i)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(oe):[]}(i),a)))}function Er(e){var t=0,i=0;return function(){var n=ba(),r=16-(n-i);if(i=n,r>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(a,arguments)}}function Fr(e,t){var i=-1,n=e.length,r=n-1;for(t=t===a?n:t;++i<t;){var s=Hi(i,r),o=e[s];e[s]=e[i],e[i]=o}return e.length=t,e}var Dr=function(e){var t=Es(e,(function(e){return 500===a.size&&a.clear(),e})),a=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,(function(e,a,i,n){t.push(i?n.replace(ce,"$1"):a||e)})),t}));function Rr(e){if("string"==typeof e||so(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Pr(e){if(null!=e){try{return Fe.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Lr(e){if(e instanceof ja)return e.clone();var t=new Ua(e.__wrapped__,e.__chain__);return t.__actions__=xn(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Br=qi((function(e,t){return Ys(e)?ui(e,mi(t,1,Ys,!0)):[]})),Or=qi((function(e,t){var i=qr(t);return Ys(i)&&(i=a),Ys(e)?ui(e,mi(t,1,Ys,!0),or(i,2)):[]})),$r=qi((function(e,t){var i=qr(t);return Ys(i)&&(i=a),Ys(e)?ui(e,mi(t,1,Ys,!0),a,i):[]}));function Ur(e,t,a){var i=null==e?0:e.length;if(!i)return-1;var n=null==a?0:ho(a);return n<0&&(n=ya(i+n,0)),Ot(e,or(t,3),n)}function jr(e,t,i){var n=null==e?0:e.length;if(!n)return-1;var r=n-1;return i!==a&&(r=ho(i),r=i<0?ya(n+r,0):ga(r,n-1)),Ot(e,or(t,3),r,!0)}function zr(e){return null!=e&&e.length?mi(e,1):[]}function Wr(e){return e&&e.length?e[0]:a}var Yr=qi((function(e){var t=Et(e,yn);return t.length&&t[0]===e[0]?Mi(t):[]})),Hr=qi((function(e){var t=qr(e),i=Et(e,yn);return t===qr(i)?t=a:i.pop(),i.length&&i[0]===e[0]?Mi(i,or(t,2)):[]})),Gr=qi((function(e){var t=qr(e),i=Et(e,yn);return(t="function"==typeof t?t:a)&&i.pop(),i.length&&i[0]===e[0]?Mi(i,a,t):[]}));function qr(e){var t=null==e?0:e.length;return t?e[t-1]:a}var Zr=qi(Jr);function Jr(e,t){return e&&e.length&&t&&t.length?Wi(e,t):e}var Kr=tr((function(e,t){var a=null==e?0:e.length,i=ni(e,t);return Yi(e,Et(t,(function(e){return gr(e,a)?+e:e})).sort(Nn)),i}));function Xr(e){return null==e?e:_a.call(e)}var Qr=qi((function(e){return un(mi(e,1,Ys,!0))})),es=qi((function(e){var t=qr(e);return Ys(t)&&(t=a),un(mi(e,1,Ys,!0),or(t,2))})),ts=qi((function(e){var t=qr(e);return t="function"==typeof t?t:a,un(mi(e,1,Ys,!0),a,t)}));function as(e){if(!e||!e.length)return[];var t=0;return e=Ct(e,(function(e){if(Ys(e))return t=ya(e.length,t),!0})),qt(t,(function(t){return Et(e,Wt(t))}))}function is(e,t){if(!e||!e.length)return[];var i=as(e);return null==t?i:Et(i,(function(e){return St(t,a,e)}))}var ns=qi((function(e,t){return Ys(e)?ui(e,t):[]})),rs=qi((function(e){return fn(Ct(e,Ys))})),ss=qi((function(e){var t=qr(e);return Ys(t)&&(t=a),fn(Ct(e,Ys),or(t,2))})),os=qi((function(e){var t=qr(e);return t="function"==typeof t?t:a,fn(Ct(e,Ys),a,t)})),ls=qi(as),us=qi((function(e){var t=e.length,i=t>1?e[t-1]:a;return i="function"==typeof i?(e.pop(),i):a,is(e,i)}));function cs(e){var t=Ba(e);return t.__chain__=!0,t}function ds(e,t){return t(e)}var ps=tr((function(e){var t=e.length,i=t?e[0]:0,n=this.__wrapped__,r=function(t){return ni(t,e)};return!(t>1||this.__actions__.length)&&n instanceof ja&&gr(i)?((n=n.slice(i,+i+(t?1:0))).__actions__.push({func:ds,args:[r],thisArg:a}),new Ua(n,this.__chain__).thru((function(e){return t&&!e.length&&e.push(a),e}))):this.thru(r)})),hs=Vn((function(e,t,a){De.call(e,a)?++e[a]:ii(e,a,1)})),fs=Ln(Ur),ms=Ln(jr);function ys(e,t){return(js(e)?Tt:ci)(e,or(t,3))}function gs(e,t){return(js(e)?Mt:di)(e,or(t,3))}var bs=Vn((function(e,t,a){De.call(e,a)?e[a].push(t):ii(e,a,[t])})),vs=qi((function(e,t,a){var i=-1,n="function"==typeof t,r=Ws(e)?ne(e.length):[];return ci(e,(function(e){r[++i]=n?St(t,e,a):xi(e,t,a)})),r})),ws=Vn((function(e,t,a){ii(e,a,t)}));function _s(e,t){return(js(e)?Et:Li)(e,or(t,3))}var As=Vn((function(e,t,a){e[a?0:1].push(t)}),(function(){return[[],[]]})),ks=qi((function(e,t){if(null==e)return[];var a=t.length;return a>1&&br(e,t[0],t[1])?t=[]:a>2&&br(t[0],t[1],t[2])&&(t=[t[0]]),ji(e,mi(t,1),[])})),Ss=ct||function(){return pt.Date.now()};function Ns(e,t,i){return t=i?a:t,t=e&&null==t?e.length:t,Jn(e,o,a,a,a,a,t)}function Ts(e,t){var n;if("function"!=typeof t)throw new xe(i);return e=ho(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=a),n}}var Ms=qi((function(e,t,a){var i=1;if(a.length){var n=oa(a,sr(Ms));i|=s}return Jn(e,i,t,a,n)})),xs=qi((function(e,t,a){var i=3;if(a.length){var n=oa(a,sr(xs));i|=s}return Jn(t,i,e,a,n)}));function Cs(e,t,n){var r,s,o,l,u,c,d=0,p=!1,h=!1,f=!0;if("function"!=typeof e)throw new xe(i);function m(t){var i=r,n=s;return r=s=a,d=t,l=e.apply(n,i)}function y(e){var i=e-c;return c===a||i>=t||i<0||h&&e-d>=o}function g(){var e=Ss();if(y(e))return b(e);u=Cr(g,function(e){var a=t-(e-c);return h?ga(a,o-(e-d)):a}(e))}function b(e){return u=a,f&&r?m(e):(r=s=a,l)}function v(){var e=Ss(),i=y(e);if(r=arguments,s=this,c=e,i){if(u===a)return function(e){return d=e,u=Cr(g,t),p?m(e):l}(c);if(h)return _n(u),u=Cr(g,t),m(c)}return u===a&&(u=Cr(g,t)),l}return t=mo(t)||0,Xs(n)&&(p=!!n.leading,o=(h="maxWait"in n)?ya(mo(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),v.cancel=function(){u!==a&&_n(u),d=0,r=c=s=u=a},v.flush=function(){return u===a?l:b(Ss())},v}var Vs=qi((function(e,t){return li(e,1,t)})),Is=qi((function(e,t,a){return li(e,mo(t)||0,a)}));function Es(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new xe(i);var a=function(){var i=arguments,n=t?t.apply(this,i):i[0],r=a.cache;if(r.has(n))return r.get(n);var s=e.apply(this,i);return a.cache=r.set(n,s)||r,s};return a.cache=new(Es.Cache||Ya),a}function Fs(e){if("function"!=typeof e)throw new xe(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Es.Cache=Ya;var Ds=vn((function(e,t){var a=(t=1==t.length&&js(t[0])?Et(t[0],Jt(or())):Et(mi(t,1),Jt(or()))).length;return qi((function(i){for(var n=-1,r=ga(i.length,a);++n<r;)i[n]=t[n].call(this,i[n]);return St(e,this,i)}))})),Rs=qi((function(e,t){var i=oa(t,sr(Rs));return Jn(e,s,a,t,i)})),Ps=qi((function(e,t){var i=oa(t,sr(Ps));return Jn(e,64,a,t,i)})),Ls=tr((function(e,t){return Jn(e,l,a,a,a,t)}));function Bs(e,t){return e===t||e!=e&&t!=t}var Os=Yn(Si),$s=Yn((function(e,t){return e>=t})),Us=Ci(function(){return arguments}())?Ci:function(e){return Qs(e)&&De.call(e,"callee")&&!Ge.call(e,"callee")},js=ne.isArray,zs=bt?Jt(bt):function(e){return Qs(e)&&ki(e)==I};function Ws(e){return null!=e&&Ks(e.length)&&!Zs(e)}function Ys(e){return Qs(e)&&Ws(e)}var Hs=gt||ml,Gs=vt?Jt(vt):function(e){return Qs(e)&&ki(e)==g};function qs(e){if(!Qs(e))return!1;var t=ki(e);return t==b||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!ao(e)}function Zs(e){if(!Xs(e))return!1;var t=ki(e);return t==v||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Js(e){return"number"==typeof e&&e==ho(e)}function Ks(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=c}function Xs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Qs(e){return null!=e&&"object"==typeof e}var eo=wt?Jt(wt):function(e){return Qs(e)&&hr(e)==_};function to(e){return"number"==typeof e||Qs(e)&&ki(e)==A}function ao(e){if(!Qs(e)||ki(e)!=k)return!1;var t=Ye(e);if(null===t)return!0;var a=De.call(t,"constructor")&&t.constructor;return"function"==typeof a&&a instanceof a&&Fe.call(a)==Be}var io=_t?Jt(_t):function(e){return Qs(e)&&ki(e)==N},no=At?Jt(At):function(e){return Qs(e)&&hr(e)==T};function ro(e){return"string"==typeof e||!js(e)&&Qs(e)&&ki(e)==M}function so(e){return"symbol"==typeof e||Qs(e)&&ki(e)==x}var oo=kt?Jt(kt):function(e){return Qs(e)&&Ks(e.length)&&!!rt[ki(e)]},lo=Yn(Pi),uo=Yn((function(e,t){return e<=t}));function co(e){if(!e)return[];if(Ws(e))return ro(e)?da(e):xn(e);if(Je&&e[Je])return function(e){for(var t,a=[];!(t=e.next()).done;)a.push(t.value);return a}(e[Je]());var t=hr(e);return(t==_?ra:t==T?la:Oo)(e)}function po(e){return e?(e=mo(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=po(e),a=t%1;return t==t?a?t-a:t:0}function fo(e){return e?ri(ho(e),0,p):0}function mo(e){if("number"==typeof e)return e;if(so(e))return d;if(Xs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Xs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Zt(e);var a=fe.test(e);return a||ye.test(e)?ut(e.slice(2),a?2:8):he.test(e)?d:+e}function yo(e){return Cn(e,Io(e))}function go(e){return null==e?"":ln(e)}var bo=In((function(e,t){if(Ar(t)||Ws(t))Cn(t,Vo(t),e);else for(var a in t)De.call(t,a)&&Qa(e,a,t[a])})),vo=In((function(e,t){Cn(t,Io(t),e)})),wo=In((function(e,t,a,i){Cn(t,Io(t),e,i)})),_o=In((function(e,t,a,i){Cn(t,Vo(t),e,i)})),Ao=tr(ni),ko=qi((function(e,t){e=Ne(e);var i=-1,n=t.length,r=n>2?t[2]:a;for(r&&br(t[0],t[1],r)&&(n=1);++i<n;)for(var s=t[i],o=Io(s),l=-1,u=o.length;++l<u;){var c=o[l],d=e[c];(d===a||Bs(d,Ie[c])&&!De.call(e,c))&&(e[c]=s[c])}return e})),So=qi((function(e){return e.push(a,Xn),St(Fo,a,e)}));function No(e,t,i){var n=null==e?a:_i(e,t);return n===a?i:n}function To(e,t){return null!=e&&fr(e,t,Ti)}var Mo=$n((function(e,t,a){null!=t&&"function"!=typeof t.toString&&(t=Le.call(t)),e[t]=a}),Qo(al)),xo=$n((function(e,t,a){null!=t&&"function"!=typeof t.toString&&(t=Le.call(t)),De.call(e,t)?e[t].push(a):e[t]=[a]}),or),Co=qi(xi);function Vo(e){return Ws(e)?qa(e):Di(e)}function Io(e){return Ws(e)?qa(e,!0):Ri(e)}var Eo=In((function(e,t,a){$i(e,t,a)})),Fo=In((function(e,t,a,i){$i(e,t,a,i)})),Do=tr((function(e,t){var a={};if(null==e)return a;var i=!1;t=Et(t,(function(t){return t=bn(t,e),i||(i=t.length>1),t})),Cn(e,ir(e),a),i&&(a=si(a,7,Qn));for(var n=t.length;n--;)cn(a,t[n]);return a})),Ro=tr((function(e,t){return null==e?{}:function(e,t){return zi(e,t,(function(t,a){return To(e,a)}))}(e,t)}));function Po(e,t){if(null==e)return{};var a=Et(ir(e),(function(e){return[e]}));return t=or(t),zi(e,a,(function(e,a){return t(e,a[0])}))}var Lo=Zn(Vo),Bo=Zn(Io);function Oo(e){return null==e?[]:Kt(e,Vo(e))}var $o=Rn((function(e,t,a){return t=t.toLowerCase(),e+(a?Uo(t):t)}));function Uo(e){return Zo(go(e).toLowerCase())}function jo(e){return(e=go(e))&&e.replace(be,ta).replace(Xe,"")}var zo=Rn((function(e,t,a){return e+(a?"-":"")+t.toLowerCase()})),Wo=Rn((function(e,t,a){return e+(a?" ":"")+t.toLowerCase()})),Yo=Dn("toLowerCase"),Ho=Rn((function(e,t,a){return e+(a?"_":"")+t.toLowerCase()})),Go=Rn((function(e,t,a){return e+(a?" ":"")+Zo(t)})),qo=Rn((function(e,t,a){return e+(a?" ":"")+t.toUpperCase()})),Zo=Dn("toUpperCase");function Jo(e,t,i){return e=go(e),(t=i?a:t)===a?function(e){return at.test(e)}(e)?function(e){return e.match(et)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ko=qi((function(e,t){try{return St(e,a,t)}catch(e){return qs(e)?e:new Ae(e)}})),Xo=tr((function(e,t){return Tt(t,(function(t){t=Rr(t),ii(e,t,Ms(e[t],e))})),e}));function Qo(e){return function(){return e}}var el=Bn(),tl=Bn(!0);function al(e){return e}function il(e){return Fi("function"==typeof e?e:si(e,1))}var nl=qi((function(e,t){return function(a){return xi(a,e,t)}})),rl=qi((function(e,t){return function(a){return xi(e,a,t)}}));function sl(e,t,a){var i=Vo(t),n=wi(t,i);null!=a||Xs(t)&&(n.length||!i.length)||(a=t,t=e,e=this,n=wi(t,Vo(t)));var r=!(Xs(a)&&"chain"in a&&!a.chain),s=Zs(e);return Tt(n,(function(a){var i=t[a];e[a]=i,s&&(e.prototype[a]=function(){var t=this.__chain__;if(r||t){var a=e(this.__wrapped__);return(a.__actions__=xn(this.__actions__)).push({func:i,args:arguments,thisArg:e}),a.__chain__=t,a}return i.apply(e,Ft([this.value()],arguments))})})),e}function ol(){}var ll=jn(Et),ul=jn(xt),cl=jn(Pt);function dl(e){return vr(e)?Wt(Rr(e)):function(e){return function(t){return _i(t,e)}}(e)}var pl=Wn(),hl=Wn(!0);function fl(){return[]}function ml(){return!1}var yl,gl=Un((function(e,t){return e+t}),0),bl=Gn("ceil"),vl=Un((function(e,t){return e/t}),1),wl=Gn("floor"),_l=Un((function(e,t){return e*t}),1),Al=Gn("round"),kl=Un((function(e,t){return e-t}),0);return Ba.after=function(e,t){if("function"!=typeof t)throw new xe(i);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Ba.ary=Ns,Ba.assign=bo,Ba.assignIn=vo,Ba.assignInWith=wo,Ba.assignWith=_o,Ba.at=Ao,Ba.before=Ts,Ba.bind=Ms,Ba.bindAll=Xo,Ba.bindKey=xs,Ba.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return js(e)?e:[e]},Ba.chain=cs,Ba.chunk=function(e,t,i){t=(i?br(e,t,i):t===a)?1:ya(ho(t),0);var n=null==e?0:e.length;if(!n||t<1)return[];for(var r=0,s=0,o=ne(ht(n/t));r<n;)o[s++]=tn(e,r,r+=t);return o},Ba.compact=function(e){for(var t=-1,a=null==e?0:e.length,i=0,n=[];++t<a;){var r=e[t];r&&(n[i++]=r)}return n},Ba.concat=function(){var e=arguments.length;if(!e)return[];for(var t=ne(e-1),a=arguments[0],i=e;i--;)t[i-1]=arguments[i];return Ft(js(a)?xn(a):[a],mi(t,1))},Ba.cond=function(e){var t=null==e?0:e.length,a=or();return e=t?Et(e,(function(e){if("function"!=typeof e[1])throw new xe(i);return[a(e[0]),e[1]]})):[],qi((function(a){for(var i=-1;++i<t;){var n=e[i];if(St(n[0],this,a))return St(n[1],this,a)}}))},Ba.conforms=function(e){return function(e){var t=Vo(e);return function(a){return oi(a,e,t)}}(si(e,1))},Ba.constant=Qo,Ba.countBy=hs,Ba.create=function(e,t){var a=Oa(e);return null==t?a:ai(a,t)},Ba.curry=function e(t,i,n){var r=Jn(t,8,a,a,a,a,a,i=n?a:i);return r.placeholder=e.placeholder,r},Ba.curryRight=function e(t,i,n){var r=Jn(t,16,a,a,a,a,a,i=n?a:i);return r.placeholder=e.placeholder,r},Ba.debounce=Cs,Ba.defaults=ko,Ba.defaultsDeep=So,Ba.defer=Vs,Ba.delay=Is,Ba.difference=Br,Ba.differenceBy=Or,Ba.differenceWith=$r,Ba.drop=function(e,t,i){var n=null==e?0:e.length;return n?tn(e,(t=i||t===a?1:ho(t))<0?0:t,n):[]},Ba.dropRight=function(e,t,i){var n=null==e?0:e.length;return n?tn(e,0,(t=n-(t=i||t===a?1:ho(t)))<0?0:t):[]},Ba.dropRightWhile=function(e,t){return e&&e.length?pn(e,or(t,3),!0,!0):[]},Ba.dropWhile=function(e,t){return e&&e.length?pn(e,or(t,3),!0):[]},Ba.fill=function(e,t,i,n){var r=null==e?0:e.length;return r?(i&&"number"!=typeof i&&br(e,t,i)&&(i=0,n=r),function(e,t,i,n){var r=e.length;for((i=ho(i))<0&&(i=-i>r?0:r+i),(n=n===a||n>r?r:ho(n))<0&&(n+=r),n=i>n?0:fo(n);i<n;)e[i++]=t;return e}(e,t,i,n)):[]},Ba.filter=function(e,t){return(js(e)?Ct:fi)(e,or(t,3))},Ba.flatMap=function(e,t){return mi(_s(e,t),1)},Ba.flatMapDeep=function(e,t){return mi(_s(e,t),u)},Ba.flatMapDepth=function(e,t,i){return i=i===a?1:ho(i),mi(_s(e,t),i)},Ba.flatten=zr,Ba.flattenDeep=function(e){return null!=e&&e.length?mi(e,u):[]},Ba.flattenDepth=function(e,t){return null!=e&&e.length?mi(e,t=t===a?1:ho(t)):[]},Ba.flip=function(e){return Jn(e,512)},Ba.flow=el,Ba.flowRight=tl,Ba.fromPairs=function(e){for(var t=-1,a=null==e?0:e.length,i={};++t<a;){var n=e[t];i[n[0]]=n[1]}return i},Ba.functions=function(e){return null==e?[]:wi(e,Vo(e))},Ba.functionsIn=function(e){return null==e?[]:wi(e,Io(e))},Ba.groupBy=bs,Ba.initial=function(e){return null!=e&&e.length?tn(e,0,-1):[]},Ba.intersection=Yr,Ba.intersectionBy=Hr,Ba.intersectionWith=Gr,Ba.invert=Mo,Ba.invertBy=xo,Ba.invokeMap=vs,Ba.iteratee=il,Ba.keyBy=ws,Ba.keys=Vo,Ba.keysIn=Io,Ba.map=_s,Ba.mapKeys=function(e,t){var a={};return t=or(t,3),bi(e,(function(e,i,n){ii(a,t(e,i,n),e)})),a},Ba.mapValues=function(e,t){var a={};return t=or(t,3),bi(e,(function(e,i,n){ii(a,i,t(e,i,n))})),a},Ba.matches=function(e){return Bi(si(e,1))},Ba.matchesProperty=function(e,t){return Oi(e,si(t,1))},Ba.memoize=Es,Ba.merge=Eo,Ba.mergeWith=Fo,Ba.method=nl,Ba.methodOf=rl,Ba.mixin=sl,Ba.negate=Fs,Ba.nthArg=function(e){return e=ho(e),qi((function(t){return Ui(t,e)}))},Ba.omit=Do,Ba.omitBy=function(e,t){return Po(e,Fs(or(t)))},Ba.once=function(e){return Ts(2,e)},Ba.orderBy=function(e,t,i,n){return null==e?[]:(js(t)||(t=null==t?[]:[t]),js(i=n?a:i)||(i=null==i?[]:[i]),ji(e,t,i))},Ba.over=ll,Ba.overArgs=Ds,Ba.overEvery=ul,Ba.overSome=cl,Ba.partial=Rs,Ba.partialRight=Ps,Ba.partition=As,Ba.pick=Ro,Ba.pickBy=Po,Ba.property=dl,Ba.propertyOf=function(e){return function(t){return null==e?a:_i(e,t)}},Ba.pull=Zr,Ba.pullAll=Jr,Ba.pullAllBy=function(e,t,a){return e&&e.length&&t&&t.length?Wi(e,t,or(a,2)):e},Ba.pullAllWith=function(e,t,i){return e&&e.length&&t&&t.length?Wi(e,t,a,i):e},Ba.pullAt=Kr,Ba.range=pl,Ba.rangeRight=hl,Ba.rearg=Ls,Ba.reject=function(e,t){return(js(e)?Ct:fi)(e,Fs(or(t,3)))},Ba.remove=function(e,t){var a=[];if(!e||!e.length)return a;var i=-1,n=[],r=e.length;for(t=or(t,3);++i<r;){var s=e[i];t(s,i,e)&&(a.push(s),n.push(i))}return Yi(e,n),a},Ba.rest=function(e,t){if("function"!=typeof e)throw new xe(i);return qi(e,t=t===a?t:ho(t))},Ba.reverse=Xr,Ba.sampleSize=function(e,t,i){return t=(i?br(e,t,i):t===a)?1:ho(t),(js(e)?Ja:Ji)(e,t)},Ba.set=function(e,t,a){return null==e?e:Ki(e,t,a)},Ba.setWith=function(e,t,i,n){return n="function"==typeof n?n:a,null==e?e:Ki(e,t,i,n)},Ba.shuffle=function(e){return(js(e)?Ka:en)(e)},Ba.slice=function(e,t,i){var n=null==e?0:e.length;return n?(i&&"number"!=typeof i&&br(e,t,i)?(t=0,i=n):(t=null==t?0:ho(t),i=i===a?n:ho(i)),tn(e,t,i)):[]},Ba.sortBy=ks,Ba.sortedUniq=function(e){return e&&e.length?sn(e):[]},Ba.sortedUniqBy=function(e,t){return e&&e.length?sn(e,or(t,2)):[]},Ba.split=function(e,t,i){return i&&"number"!=typeof i&&br(e,t,i)&&(t=i=a),(i=i===a?p:i>>>0)?(e=go(e))&&("string"==typeof t||null!=t&&!io(t))&&!(t=ln(t))&&na(e)?wn(da(e),0,i):e.split(t,i):[]},Ba.spread=function(e,t){if("function"!=typeof e)throw new xe(i);return t=null==t?0:ya(ho(t),0),qi((function(a){var i=a[t],n=wn(a,0,t);return i&&Ft(n,i),St(e,this,n)}))},Ba.tail=function(e){var t=null==e?0:e.length;return t?tn(e,1,t):[]},Ba.take=function(e,t,i){return e&&e.length?tn(e,0,(t=i||t===a?1:ho(t))<0?0:t):[]},Ba.takeRight=function(e,t,i){var n=null==e?0:e.length;return n?tn(e,(t=n-(t=i||t===a?1:ho(t)))<0?0:t,n):[]},Ba.takeRightWhile=function(e,t){return e&&e.length?pn(e,or(t,3),!1,!0):[]},Ba.takeWhile=function(e,t){return e&&e.length?pn(e,or(t,3)):[]},Ba.tap=function(e,t){return t(e),e},Ba.throttle=function(e,t,a){var n=!0,r=!0;if("function"!=typeof e)throw new xe(i);return Xs(a)&&(n="leading"in a?!!a.leading:n,r="trailing"in a?!!a.trailing:r),Cs(e,t,{leading:n,maxWait:t,trailing:r})},Ba.thru=ds,Ba.toArray=co,Ba.toPairs=Lo,Ba.toPairsIn=Bo,Ba.toPath=function(e){return js(e)?Et(e,Rr):so(e)?[e]:xn(Dr(go(e)))},Ba.toPlainObject=yo,Ba.transform=function(e,t,a){var i=js(e),n=i||Hs(e)||oo(e);if(t=or(t,4),null==a){var r=e&&e.constructor;a=n?i?new r:[]:Xs(e)&&Zs(r)?Oa(Ye(e)):{}}return(n?Tt:bi)(e,(function(e,i,n){return t(a,e,i,n)})),a},Ba.unary=function(e){return Ns(e,1)},Ba.union=Qr,Ba.unionBy=es,Ba.unionWith=ts,Ba.uniq=function(e){return e&&e.length?un(e):[]},Ba.uniqBy=function(e,t){return e&&e.length?un(e,or(t,2)):[]},Ba.uniqWith=function(e,t){return t="function"==typeof t?t:a,e&&e.length?un(e,a,t):[]},Ba.unset=function(e,t){return null==e||cn(e,t)},Ba.unzip=as,Ba.unzipWith=is,Ba.update=function(e,t,a){return null==e?e:dn(e,t,gn(a))},Ba.updateWith=function(e,t,i,n){return n="function"==typeof n?n:a,null==e?e:dn(e,t,gn(i),n)},Ba.values=Oo,Ba.valuesIn=function(e){return null==e?[]:Kt(e,Io(e))},Ba.without=ns,Ba.words=Jo,Ba.wrap=function(e,t){return Rs(gn(t),e)},Ba.xor=rs,Ba.xorBy=ss,Ba.xorWith=os,Ba.zip=ls,Ba.zipObject=function(e,t){return mn(e||[],t||[],Qa)},Ba.zipObjectDeep=function(e,t){return mn(e||[],t||[],Ki)},Ba.zipWith=us,Ba.entries=Lo,Ba.entriesIn=Bo,Ba.extend=vo,Ba.extendWith=wo,sl(Ba,Ba),Ba.add=gl,Ba.attempt=Ko,Ba.camelCase=$o,Ba.capitalize=Uo,Ba.ceil=bl,Ba.clamp=function(e,t,i){return i===a&&(i=t,t=a),i!==a&&(i=(i=mo(i))==i?i:0),t!==a&&(t=(t=mo(t))==t?t:0),ri(mo(e),t,i)},Ba.clone=function(e){return si(e,4)},Ba.cloneDeep=function(e){return si(e,5)},Ba.cloneDeepWith=function(e,t){return si(e,5,t="function"==typeof t?t:a)},Ba.cloneWith=function(e,t){return si(e,4,t="function"==typeof t?t:a)},Ba.conformsTo=function(e,t){return null==t||oi(e,t,Vo(t))},Ba.deburr=jo,Ba.defaultTo=function(e,t){return null==e||e!=e?t:e},Ba.divide=vl,Ba.endsWith=function(e,t,i){e=go(e),t=ln(t);var n=e.length,r=i=i===a?n:ri(ho(i),0,n);return(i-=t.length)>=0&&e.slice(i,r)==t},Ba.eq=Bs,Ba.escape=function(e){return(e=go(e))&&q.test(e)?e.replace(H,aa):e},Ba.escapeRegExp=function(e){return(e=go(e))&&ae.test(e)?e.replace(te,"\\$&"):e},Ba.every=function(e,t,i){var n=js(e)?xt:pi;return i&&br(e,t,i)&&(t=a),n(e,or(t,3))},Ba.find=fs,Ba.findIndex=Ur,Ba.findKey=function(e,t){return Bt(e,or(t,3),bi)},Ba.findLast=ms,Ba.findLastIndex=jr,Ba.findLastKey=function(e,t){return Bt(e,or(t,3),vi)},Ba.floor=wl,Ba.forEach=ys,Ba.forEachRight=gs,Ba.forIn=function(e,t){return null==e?e:yi(e,or(t,3),Io)},Ba.forInRight=function(e,t){return null==e?e:gi(e,or(t,3),Io)},Ba.forOwn=function(e,t){return e&&bi(e,or(t,3))},Ba.forOwnRight=function(e,t){return e&&vi(e,or(t,3))},Ba.get=No,Ba.gt=Os,Ba.gte=$s,Ba.has=function(e,t){return null!=e&&fr(e,t,Ni)},Ba.hasIn=To,Ba.head=Wr,Ba.identity=al,Ba.includes=function(e,t,a,i){e=Ws(e)?e:Oo(e),a=a&&!i?ho(a):0;var n=e.length;return a<0&&(a=ya(n+a,0)),ro(e)?a<=n&&e.indexOf(t,a)>-1:!!n&&$t(e,t,a)>-1},Ba.indexOf=function(e,t,a){var i=null==e?0:e.length;if(!i)return-1;var n=null==a?0:ho(a);return n<0&&(n=ya(i+n,0)),$t(e,t,n)},Ba.inRange=function(e,t,i){return t=po(t),i===a?(i=t,t=0):i=po(i),function(e,t,a){return e>=ga(t,a)&&e<ya(t,a)}(e=mo(e),t,i)},Ba.invoke=Co,Ba.isArguments=Us,Ba.isArray=js,Ba.isArrayBuffer=zs,Ba.isArrayLike=Ws,Ba.isArrayLikeObject=Ys,Ba.isBoolean=function(e){return!0===e||!1===e||Qs(e)&&ki(e)==y},Ba.isBuffer=Hs,Ba.isDate=Gs,Ba.isElement=function(e){return Qs(e)&&1===e.nodeType&&!ao(e)},Ba.isEmpty=function(e){if(null==e)return!0;if(Ws(e)&&(js(e)||"string"==typeof e||"function"==typeof e.splice||Hs(e)||oo(e)||Us(e)))return!e.length;var t=hr(e);if(t==_||t==T)return!e.size;if(Ar(e))return!Di(e).length;for(var a in e)if(De.call(e,a))return!1;return!0},Ba.isEqual=function(e,t){return Vi(e,t)},Ba.isEqualWith=function(e,t,i){var n=(i="function"==typeof i?i:a)?i(e,t):a;return n===a?Vi(e,t,a,i):!!n},Ba.isError=qs,Ba.isFinite=function(e){return"number"==typeof e&&Lt(e)},Ba.isFunction=Zs,Ba.isInteger=Js,Ba.isLength=Ks,Ba.isMap=eo,Ba.isMatch=function(e,t){return e===t||Ii(e,t,ur(t))},Ba.isMatchWith=function(e,t,i){return i="function"==typeof i?i:a,Ii(e,t,ur(t),i)},Ba.isNaN=function(e){return to(e)&&e!=+e},Ba.isNative=function(e){if(_r(e))throw new Ae("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Ei(e)},Ba.isNil=function(e){return null==e},Ba.isNull=function(e){return null===e},Ba.isNumber=to,Ba.isObject=Xs,Ba.isObjectLike=Qs,Ba.isPlainObject=ao,Ba.isRegExp=io,Ba.isSafeInteger=function(e){return Js(e)&&e>=-9007199254740991&&e<=c},Ba.isSet=no,Ba.isString=ro,Ba.isSymbol=so,Ba.isTypedArray=oo,Ba.isUndefined=function(e){return e===a},Ba.isWeakMap=function(e){return Qs(e)&&hr(e)==C},Ba.isWeakSet=function(e){return Qs(e)&&"[object WeakSet]"==ki(e)},Ba.join=function(e,t){return null==e?"":Yt.call(e,t)},Ba.kebabCase=zo,Ba.last=qr,Ba.lastIndexOf=function(e,t,i){var n=null==e?0:e.length;if(!n)return-1;var r=n;return i!==a&&(r=(r=ho(i))<0?ya(n+r,0):ga(r,n-1)),t==t?function(e,t,a){for(var i=a+1;i--;)if(e[i]===t)return i;return i}(e,t,r):Ot(e,jt,r,!0)},Ba.lowerCase=Wo,Ba.lowerFirst=Yo,Ba.lt=lo,Ba.lte=uo,Ba.max=function(e){return e&&e.length?hi(e,al,Si):a},Ba.maxBy=function(e,t){return e&&e.length?hi(e,or(t,2),Si):a},Ba.mean=function(e){return zt(e,al)},Ba.meanBy=function(e,t){return zt(e,or(t,2))},Ba.min=function(e){return e&&e.length?hi(e,al,Pi):a},Ba.minBy=function(e,t){return e&&e.length?hi(e,or(t,2),Pi):a},Ba.stubArray=fl,Ba.stubFalse=ml,Ba.stubObject=function(){return{}},Ba.stubString=function(){return""},Ba.stubTrue=function(){return!0},Ba.multiply=_l,Ba.nth=function(e,t){return e&&e.length?Ui(e,ho(t)):a},Ba.noConflict=function(){return pt._===this&&(pt._=Oe),this},Ba.noop=ol,Ba.now=Ss,Ba.pad=function(e,t,a){e=go(e);var i=(t=ho(t))?ca(e):0;if(!t||i>=t)return e;var n=(t-i)/2;return zn(ft(n),a)+e+zn(ht(n),a)},Ba.padEnd=function(e,t,a){e=go(e);var i=(t=ho(t))?ca(e):0;return t&&i<t?e+zn(t-i,a):e},Ba.padStart=function(e,t,a){e=go(e);var i=(t=ho(t))?ca(e):0;return t&&i<t?zn(t-i,a)+e:e},Ba.parseInt=function(e,t,a){return a||null==t?t=0:t&&(t=+t),va(go(e).replace(ie,""),t||0)},Ba.random=function(e,t,i){if(i&&"boolean"!=typeof i&&br(e,t,i)&&(t=i=a),i===a&&("boolean"==typeof t?(i=t,t=a):"boolean"==typeof e&&(i=e,e=a)),e===a&&t===a?(e=0,t=1):(e=po(e),t===a?(t=e,e=0):t=po(t)),e>t){var n=e;e=t,t=n}if(i||e%1||t%1){var r=wa();return ga(e+r*(t-e+lt("1e-"+((r+"").length-1))),t)}return Hi(e,t)},Ba.reduce=function(e,t,a){var i=js(e)?Dt:Ht,n=arguments.length<3;return i(e,or(t,4),a,n,ci)},Ba.reduceRight=function(e,t,a){var i=js(e)?Rt:Ht,n=arguments.length<3;return i(e,or(t,4),a,n,di)},Ba.repeat=function(e,t,i){return t=(i?br(e,t,i):t===a)?1:ho(t),Gi(go(e),t)},Ba.replace=function(){var e=arguments,t=go(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Ba.result=function(e,t,i){var n=-1,r=(t=bn(t,e)).length;for(r||(r=1,e=a);++n<r;){var s=null==e?a:e[Rr(t[n])];s===a&&(n=r,s=i),e=Zs(s)?s.call(e):s}return e},Ba.round=Al,Ba.runInContext=e,Ba.sample=function(e){return(js(e)?Za:Zi)(e)},Ba.size=function(e){if(null==e)return 0;if(Ws(e))return ro(e)?ca(e):e.length;var t=hr(e);return t==_||t==T?e.size:Di(e).length},Ba.snakeCase=Ho,Ba.some=function(e,t,i){var n=js(e)?Pt:an;return i&&br(e,t,i)&&(t=a),n(e,or(t,3))},Ba.sortedIndex=function(e,t){return nn(e,t)},Ba.sortedIndexBy=function(e,t,a){return rn(e,t,or(a,2))},Ba.sortedIndexOf=function(e,t){var a=null==e?0:e.length;if(a){var i=nn(e,t);if(i<a&&Bs(e[i],t))return i}return-1},Ba.sortedLastIndex=function(e,t){return nn(e,t,!0)},Ba.sortedLastIndexBy=function(e,t,a){return rn(e,t,or(a,2),!0)},Ba.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var a=nn(e,t,!0)-1;if(Bs(e[a],t))return a}return-1},Ba.startCase=Go,Ba.startsWith=function(e,t,a){return e=go(e),a=null==a?0:ri(ho(a),0,e.length),t=ln(t),e.slice(a,a+t.length)==t},Ba.subtract=kl,Ba.sum=function(e){return e&&e.length?Gt(e,al):0},Ba.sumBy=function(e,t){return e&&e.length?Gt(e,or(t,2)):0},Ba.template=function(e,t,i){var n=Ba.templateSettings;i&&br(e,t,i)&&(t=a),e=go(e),t=wo({},t,n,Kn);var r,s,o=wo({},t.imports,n.imports,Kn),l=Vo(o),u=Kt(o,l),c=0,d=t.interpolate||ve,p="__p += '",h=Te((t.escape||ve).source+"|"+d.source+"|"+(d===K?de:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),f="//# sourceURL="+(De.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++nt+"]")+"\n";e.replace(h,(function(t,a,i,n,o,l){return i||(i=n),p+=e.slice(c,l).replace(we,ia),a&&(r=!0,p+="' +\n__e("+a+") +\n'"),o&&(s=!0,p+="';\n"+o+";\n__p += '"),i&&(p+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),c=l+t.length,t})),p+="';\n";var m=De.call(t,"variable")&&t.variable;if(m){if(ue.test(m))throw new Ae("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(s?p.replace(j,""):p).replace(z,"$1").replace(W,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(r?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var y=Ko((function(){return ke(l,f+"return "+p).apply(a,u)}));if(y.source=p,qs(y))throw y;return y},Ba.times=function(e,t){if((e=ho(e))<1||e>c)return[];var a=p,i=ga(e,p);t=or(t),e-=p;for(var n=qt(i,t);++a<e;)t(a);return n},Ba.toFinite=po,Ba.toInteger=ho,Ba.toLength=fo,Ba.toLower=function(e){return go(e).toLowerCase()},Ba.toNumber=mo,Ba.toSafeInteger=function(e){return e?ri(ho(e),-9007199254740991,c):0===e?e:0},Ba.toString=go,Ba.toUpper=function(e){return go(e).toUpperCase()},Ba.trim=function(e,t,i){if((e=go(e))&&(i||t===a))return Zt(e);if(!e||!(t=ln(t)))return e;var n=da(e),r=da(t);return wn(n,Qt(n,r),ea(n,r)+1).join("")},Ba.trimEnd=function(e,t,i){if((e=go(e))&&(i||t===a))return e.slice(0,pa(e)+1);if(!e||!(t=ln(t)))return e;var n=da(e);return wn(n,0,ea(n,da(t))+1).join("")},Ba.trimStart=function(e,t,i){if((e=go(e))&&(i||t===a))return e.replace(ie,"");if(!e||!(t=ln(t)))return e;var n=da(e);return wn(n,Qt(n,da(t))).join("")},Ba.truncate=function(e,t){var i=30,n="...";if(Xs(t)){var r="separator"in t?t.separator:r;i="length"in t?ho(t.length):i,n="omission"in t?ln(t.omission):n}var s=(e=go(e)).length;if(na(e)){var o=da(e);s=o.length}if(i>=s)return e;var l=i-ca(n);if(l<1)return n;var u=o?wn(o,0,l).join(""):e.slice(0,l);if(r===a)return u+n;if(o&&(l+=u.length-l),io(r)){if(e.slice(l).search(r)){var c,d=u;for(r.global||(r=Te(r.source,go(pe.exec(r))+"g")),r.lastIndex=0;c=r.exec(d);)var p=c.index;u=u.slice(0,p===a?l:p)}}else if(e.indexOf(ln(r),l)!=l){var h=u.lastIndexOf(r);h>-1&&(u=u.slice(0,h))}return u+n},Ba.unescape=function(e){return(e=go(e))&&G.test(e)?e.replace(Y,ha):e},Ba.uniqueId=function(e){var t=++Re;return go(e)+t},Ba.upperCase=qo,Ba.upperFirst=Zo,Ba.each=ys,Ba.eachRight=gs,Ba.first=Wr,sl(Ba,(yl={},bi(Ba,(function(e,t){De.call(Ba.prototype,t)||(yl[t]=e)})),yl),{chain:!1}),Ba.VERSION="4.17.21",Tt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Ba[e].placeholder=Ba})),Tt(["drop","take"],(function(e,t){ja.prototype[e]=function(i){i=i===a?1:ya(ho(i),0);var n=this.__filtered__&&!t?new ja(this):this.clone();return n.__filtered__?n.__takeCount__=ga(i,n.__takeCount__):n.__views__.push({size:ga(i,p),type:e+(n.__dir__<0?"Right":"")}),n},ja.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Tt(["filter","map","takeWhile"],(function(e,t){var a=t+1,i=1==a||3==a;ja.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:or(e,3),type:a}),t.__filtered__=t.__filtered__||i,t}})),Tt(["head","last"],(function(e,t){var a="take"+(t?"Right":"");ja.prototype[e]=function(){return this[a](1).value()[0]}})),Tt(["initial","tail"],(function(e,t){var a="drop"+(t?"":"Right");ja.prototype[e]=function(){return this.__filtered__?new ja(this):this[a](1)}})),ja.prototype.compact=function(){return this.filter(al)},ja.prototype.find=function(e){return this.filter(e).head()},ja.prototype.findLast=function(e){return this.reverse().find(e)},ja.prototype.invokeMap=qi((function(e,t){return"function"==typeof e?new ja(this):this.map((function(a){return xi(a,e,t)}))})),ja.prototype.reject=function(e){return this.filter(Fs(or(e)))},ja.prototype.slice=function(e,t){e=ho(e);var i=this;return i.__filtered__&&(e>0||t<0)?new ja(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==a&&(i=(t=ho(t))<0?i.dropRight(-t):i.take(t-e)),i)},ja.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ja.prototype.toArray=function(){return this.take(p)},bi(ja.prototype,(function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),n=/^(?:head|last)$/.test(t),r=Ba[n?"take"+("last"==t?"Right":""):t],s=n||/^find/.test(t);r&&(Ba.prototype[t]=function(){var t=this.__wrapped__,o=n?[1]:arguments,l=t instanceof ja,u=o[0],c=l||js(t),d=function(e){var t=r.apply(Ba,Ft([e],o));return n&&p?t[0]:t};c&&i&&"function"==typeof u&&1!=u.length&&(l=c=!1);var p=this.__chain__,h=!!this.__actions__.length,f=s&&!p,m=l&&!h;if(!s&&c){t=m?t:new ja(this);var y=e.apply(t,o);return y.__actions__.push({func:ds,args:[d],thisArg:a}),new Ua(y,p)}return f&&m?e.apply(this,o):(y=this.thru(d),f?n?y.value()[0]:y.value():y)})})),Tt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ce[e],a=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);Ba.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var n=this.value();return t.apply(js(n)?n:[],e)}return this[a]((function(a){return t.apply(js(a)?a:[],e)}))}})),bi(ja.prototype,(function(e,t){var a=Ba[t];if(a){var i=a.name+"";De.call(Ca,i)||(Ca[i]=[]),Ca[i].push({name:t,func:a})}})),Ca[On(a,2).name]=[{name:"wrapper",func:a}],ja.prototype.clone=function(){var e=new ja(this.__wrapped__);return e.__actions__=xn(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=xn(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=xn(this.__views__),e},ja.prototype.reverse=function(){if(this.__filtered__){var e=new ja(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},ja.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,a=js(e),i=t<0,n=a?e.length:0,r=function(e,t,a){for(var i=-1,n=a.length;++i<n;){var r=a[i],s=r.size;switch(r.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=ga(t,e+s);break;case"takeRight":e=ya(e,t-s)}}return{start:e,end:t}}(0,n,this.__views__),s=r.start,o=r.end,l=o-s,u=i?o:s-1,c=this.__iteratees__,d=c.length,p=0,h=ga(l,this.__takeCount__);if(!a||!i&&n==l&&h==l)return hn(e,this.__actions__);var f=[];e:for(;l--&&p<h;){for(var m=-1,y=e[u+=t];++m<d;){var g=c[m],b=g.iteratee,v=g.type,w=b(y);if(2==v)y=w;else if(!w){if(1==v)continue e;break e}}f[p++]=y}return f},Ba.prototype.at=ps,Ba.prototype.chain=function(){return cs(this)},Ba.prototype.commit=function(){return new Ua(this.value(),this.__chain__)},Ba.prototype.next=function(){this.__values__===a&&(this.__values__=co(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?a:this.__values__[this.__index__++]}},Ba.prototype.plant=function(e){for(var t,i=this;i instanceof $a;){var n=Lr(i);n.__index__=0,n.__values__=a,t?r.__wrapped__=n:t=n;var r=n;i=i.__wrapped__}return r.__wrapped__=e,t},Ba.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof ja){var t=e;return this.__actions__.length&&(t=new ja(this)),(t=t.reverse()).__actions__.push({func:ds,args:[Xr],thisArg:a}),new Ua(t,this.__chain__)}return this.thru(Xr)},Ba.prototype.toJSON=Ba.prototype.valueOf=Ba.prototype.value=function(){return hn(this.__wrapped__,this.__actions__)},Ba.prototype.first=Ba.prototype.head,Je&&(Ba.prototype[Je]=function(){return this}),Ba}();ft?((ft.exports=fa)._=fa,ht._=fa):pt._=fa}).call(G)}(H,H.exports)),H.exports);class Z extends ${name="";displayName="";type=void 0;info;preload=!0;loadingManagerRule="load";item;itemRepo;condition;conditionFields=[];conditionFieldNames=[];dependantFields=[];dependenciesInitialized=!1;linkableTypes=[];collapsed=!1;presets=[];datatype=null;defaultValue=null;minValue=null;maxValue=null;language=null;widget=null;length=null;labelType=null;blocks=[];connections=[];_id="";_internalValue;_internalOptions=[];_updateConditions=!0;_hidden=!1;get hidden(){return!(!this.condition||!this.dependenciesInitialized)&&(this._updateConditions&&(this._hidden=!this._calculateConditionBlock(this.condition),this._updateConditions=!1),this._hidden)}get id(){return this._id}get options(){return this._internalOptions}set options(e){this._internalOptions=e}get value(){return this._internalValue}set value(e){this._internalValue=e,this._processDependencies()}constructor(e,t=void 0,a=void 0,i=void 0,n=void 0,r=void 0){super(n),e instanceof O?(this._id=e.id,this.restoreFromSnapshot(e)):(h.assert(e,"Field has no name!"),h.assert(a,"Field has no type!"),this._id=h.createFieldID(),this.name=e,this.displayName=t||e,this.type=a,this._internalValue=i,this.item=n,this.itemRepo=r)}updateConditions(){this.condition&&this.dependenciesInitialized&&(this._updateConditions=!0,u.$emit("field:hiddenChanged",this.id))}getId(){return this.id}resetValue(){this.value=this.defaultValue}makeIdsUnique(e=new Map,t=!1){if(e.has(this._id)||t){const t=h.createFieldID();e.set(this._id,t),this._id=t}else e.set(this._id,this._id);for(const a of this.blocks)a.makeIdsUnique(e,t);return e}transformNodeIds(e){for(const t of this.blocks)t.transformNodeIds(e);"Attribute"===this.type&&"Node"===this.datatype&&this.value&&e.has(this.value)&&(this.value=e.get(this.value))}findBlock(e){for(const t of this.blocks){const a=t.findBlock(e);if(a)return a}return null}clone(e=void 0,t=!1){let a=new Z(this.name,this.displayName,this.type);void 0===this._internalValue?a._internalValue=void 0:null===this._internalValue?a._internalValue=null:"Link"===this.type?a._internalValue=this._internalValue:a._internalValue=q.cloneDeep(this._internalValue),a.info=this.info,a.preload=this.preload,a.loadingManagerRule=this.loadingManagerRule,a.item=this.item,a.ownerItem=this.ownerItem,a.itemRepo=this.itemRepo,a.condition=this.condition,a.conditionFields=this.conditionFields,a.conditionFieldNames=this.conditionFieldNames,a.dependantFields=this.dependantFields,a.collapsed=this.collapsed,a.presets=this.presets,a.labelType=this.labelType,a.datatype=this.datatype,a.defaultValue=this.defaultValue,a.minValue=this.minValue,a.maxValue=this.maxValue,a.options=this.options,a.language=this.language,a.widget=this.widget,a.length=this.length,a.linkableTypes=this.linkableTypes;for(const i of this.blocks){let n=i.clone(e,!0,{},t);e&&(n=g.instance.proxyBlock(n,e)),a.blocks.push(n)}for(const t of this.connections){let i=t.clone();e&&(i=g.instance.proxyConnection(i,e)),a.connections.push(i)}return a}_processDependencies(){for(const e of this.dependantFields)e.updateConditions()}_getConditionField(e){for(const t of this.conditionFields)if(t&&t.name===e)return t;return null}_calculateConditionField(e,t){if(!e.startsWith("$")){let a;e.includes(".")?(a=e.split("."),e=a.splice(0,1)[0]):a=[];let i=e.endsWith("?");i&&(e=e.substring(0,e.length-1));const n=this._getConditionField(e);if(!n)return i||console.error("Field to resolve condition not found: "+e),!1;let r=n.value;for(let t=0;t<a.length;t++){if(!r)return console.error(`Field path ${a.join(".")} not found in field ${e}!`),!1;r=r[a[t]]}return"object"==typeof t?void 0!==t.$isset?t.$isset===!!r:void 0!==t.$not?t.$not!==r:(console.error("Condition value cannot be interpreted: ",t,this),!1):n.value==t}switch(e){case"$isroot":return this.item._id===this.itemRepo.rootItemId===t;case"$parenttype":return console.log("$parenttype is not yet implemented!",this),!1;case"$optionsexist":return(Array.isArray(this.options)&&this.options.length>0)===t;case"$featureenabled":return this.itemRepo.apiClient.isFeatureEnabled(t);default:return console.error("Computed value unknown: "+e,this),!1}}_calculateConditionBlock(e){for(const t in e)if(e.hasOwnProperty(t)){const a=e[t];if("$or"===t)if(Array.isArray(a)){let e=!1;for(const t of a)if(this._calculateConditionBlock(t)){e=!0;break}if(!e)return!1}else console.error("Condition contains $or but its value is not an array!");else if("$not"===t){if("object"!=typeof a)console.error("When using the $not operator, the value needs to be an object");else if(this._calculateConditionBlock(a))return!1}else if(!this._calculateConditionField(t,a))return!1}return!0}refreshFieldDependencies(){for(const e of this.blocks)e.refreshFieldDependencies()}refreshDependantFields(e,t){const a=[];if(this.condition)for(let t of this.conditionFieldNames){const i=t.endsWith("?");i&&(t=t.substring(0,t.length-1));const n=e.get(t);n?a.push(n):i||console.warn("Condition field not found: "+t)}this.conditionFields=a,this.dependantFields=t||[],this.dependenciesInitialized=!0}setCondition(e){e?"object"==typeof e?this.condition=e:(console.error("Condition must be an object if set",e),this.condition=null):this.condition=null,this.conditionFieldNames=[],this.condition&&this._scanConditions(this.condition)}_scanConditions(e){for(let t in e)if(e.hasOwnProperty(t)){const a=e[t];if(Array.isArray(a))for(const e of a)this._scanConditions(e);else t.startsWith("$")||(t.includes(".")&&(t=t.split(".")[0]),this.conditionFieldNames.includes(t)||this.conditionFieldNames.push(t))}}forEachField(e){if(e(this),this.blocks)for(const t of this.blocks)t.forEachField(e)}setInfo(e){this.info=e}setPreload(e){this.preload=e}setLoadingManagerRule(e){this.loadingManagerRule=e}setLinkableTypes(e){this.linkableTypes=e}setDefaultValue(e){this.defaultValue=e,void 0!==this._internalValue&&null!==this._internalValue||(this._internalValue=e)}setMinValue(e){this.minValue=e}setMaxValue(e){this.maxValue=e}setOptions(e){this.options=e}setDatatype(e){this.datatype=e}setLanguage(e){this.language=e}setLength(e){this.length=e}setWidget(e){this.widget=e}setBlocks(e){this.blocks=e}setConnections(e){this.connections=e}setCollapsed(e){this.collapsed=!!e}setPresets(e){this.presets=e||[]}setLabelType(e){this.labelType=e||"info"}createSnapshot(e=!1){h.assert(this.id,"Field has no ID. Cannot create snapshot");const t=[];for(const a of this.blocks)t.push(a.createSnapshot(e));const a=[];for(const e of this.connections)a.push(e.createSnapshot());return new O(this.id,"field",{name:this.name,displayName:this.displayName,type:this.type,value:this._internalValue,preload:this.preload,info:this.info,loadingManagerRule:this.loadingManagerRule,item:this.item,itemRepo:this.itemRepo,condition:this.condition,conditionFields:this.conditionFields,conditionFieldNames:this.conditionFieldNames,dependantFields:this.dependantFields,linkableTypes:this.linkableTypes,collapsed:this.collapsed,presets:this.presets,datatype:this.datatype,defaultValue:this.defaultValue,minValue:this.minValue,maxValue:this.maxValue,options:this.options,language:this.language,widget:this.widget,length:this.length,labelType:this.labelType,blocks:t,connections:a})}restoreFromSnapshot(e){e.id===this.id?(this.name=e.data.name,this.displayName=e.data.displayName,this.type=e.data.type,this._internalValue=e.data.value,this.info=e.data.info,this.preload=e.data.preload,this.loadingManagerRule=e.data.loadingManagerRule,this.item=e.data.item,this.ownerItem=e.data.item,this.itemRepo=e.data.itemRepo,this.condition=e.data.condition,this.conditionFields=e.data.conditionFields,this.conditionFieldNames=e.data.conditionFieldNames,this.dependantFields=e.data.dependantFields,this.linkableTypes=e.data.linkableTypes,this.collapsed=e.data.collapsed,this.presets=e.data.presets,this.datatype=e.data.datatype,this.defaultValue=e.data.defaultValue,this.minValue=e.data.minValue,this.maxValue=e.data.maxValue,this.options=e.data.options,this.language=e.data.language,this.widget=e.data.widget,this.length=e.data.length,this.labelType=e.data.labelType,this.blocks=[],this.connections=[],this._rollbackArray(this.blocks,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem))),this._rollbackArray(this.connections,e.data.connections,((e,t)=>g.instance.proxyConnection(new U(e.data,t),this.ownerItem)))):console.error("Snapshot ID does not match! Cannot rollback!",this,e)}rollbackFromSnapshot(e){this.value=e.data.value,this._rollbackArray(this.blocks,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem))),this._rollbackArray(this.connections,e.data.connections,((e,t)=>g.instance.proxyConnection(new U(e.data,t),this.ownerItem)))}}class J extends ${id;name=void 0;displayName=void 0;value;type=void 0;datatype=void 0;linkableTypes=[];order=0;constructor(e=void 0,t=void 0,a=void 0){super(a),this.value=t,this.id=h.createItemOrBlockID(),this.name=e,this.displayName=e,this._updateDisplayName()}getId(){return this.id}setName(e){this.name=e,this._updateDisplayName()}setType(e){this.type=e}setOrder(e){this.order=e}clone(e=new Map){const t=new J;return t.ownerItem=this.ownerItem,t.value=e.get(this.value)??this.value,t.type=this.type,t.order=this.order,t.setName(this.name),t}clearDefinition(){this.type=void 0}setDefinition(e){const t=e.type.toLowerCase();switch(t){case"boolean":case"bool":this.type="Attribute",this.datatype="Boolean",this.value=void 0!==this.value?this._toBoolean(this.value):this._toBoolean(e.defaultValue);break;case"float":this.type="Attribute",this.datatype="Float",this.value=void 0!==this.value?Number(this.value):Number(e.defaultValue);break;case"int":this.type="Attribute",this.datatype="Integer",this.value=void 0!==this.value?parseInt(this.value):parseInt(e.defaultValue);break;case"string":this.type="Attribute",this.datatype="String",this.value=void 0!==this.value&&null!==this.value?this.value.toString():e.defaultValue?e.defaultValue.toString():"";break;case"vec2":this.type="Attribute",this.datatype="Vector2d";break;case"vec3":this.type="Attribute",this.datatype="Vector3d";break;case"vec4":this.type="Attribute",this.datatype="Vector4d";break;case"mat3":this.type="Attribute",this.datatype="Mat3";break;case"mat4":this.type="Attribute",this.datatype="Mat4";break;case"color":this.type="Attribute",this.datatype="Color";break;case"image":this.type="Link",this.linkableTypes=["Image"];break;default:console.error("Unknown script field type: "+t),this.type="Attribute",this.datatype="String",this.value=this.value?this.value.toString():e.defaultValue?e.defaultValue.toString():""}}_toBoolean(e){return null!=e&&(!0===e||!1===e?e:"false"!==e.toString().toLowerCase())}_updateDisplayName(){this.name?this.displayName=h.toUserFriendlyName(this.name):this.displayName=""}createSnapshot(){return new O(this.id,"customfield",{id:this.id,value:this.value})}rollbackFromSnapshot(e){this.value=e.data.value}}class K extends M{links;instanceId;isDirty=!1;fieldInstances;userFieldInstances;customFieldInstances;packageContent;packageType;public=!1;readOnly=!1;isPackaged=!1;isGenerated=!1;packageItem;isPreparedItem=!0;resultingAcl;constructor(e){if(super(e),this.instanceId=h.createItemOrBlockID(),this.links=[],Array.isArray(e.links))for(const t of e.links)this.links.push({to:t.to,usage:t.usage,stopRecursion:t.stopRecursion,item:t.item});this.fieldInstances=[],this.userFieldInstances=[],this.customFieldInstances=g.instance.proxyCustomFieldsArray([],this),this.public=!!e.public,this.packageContent=e.packageContent,this.packageType=e.packageType,this.packageItem=e.packageItem,this.readOnly=!!e.readOnly,this.isPackaged=!!e.isPackaged,this.isGenerated=!!e.isGenerated,this.resultingAcl=JSON.parse(JSON.stringify(e.resultingAcl||[]))}createCustomFieldInstances(e){function t(e,t){for(const a of e)if(a.name===t)return a;return null}for(const a of this.customFieldInstances)t(e,a.name)||a.clearDefinition();let a=0;for(const i of e){let e=t(this.customFieldInstances,i.name);e||(e=new J(i.name,i.defaultValue,this),this.addCustomField(e)),e.setOrder(a++),e.setDefinition(i)}this.customFieldInstances.sort((function(e,t){return e.order-t.order}))}addCustomField(e){this.customFieldInstances.push(g.instance.proxyCustomField(e,this))}markDirty(){this.isDirty||(this.isDirty=!0,u.$emit("itemRepo:itemBecameDirty",this._id))}makeIdsUnique(){const e=new Map;for(const t of this.fieldInstances)t.makeIdsUnique(e,!0);this.packageContent&&this.packageContent.makeIdsUnique()}clone(e=!1){let t=new K(this);const a=new Map;for(const i of this.fieldInstances){const n=i.clone(this,!0);e&&n.makeIdsUnique(a,!0),t.fieldInstances.push(n)}if(e)for(const e of t.fieldInstances)e.transformNodeIds(a);return t}findBlock(e){for(const t of this.fieldInstances){const a=t.findBlock(e);if(a)return a}return null}refreshFieldDependencies(){te.refreshFieldDependencies(this.fieldInstances);for(const e of this.fieldInstances)e.refreshFieldDependencies()}forEachItem(e){if(e(this),this.links)for(const t of this.links)t.item&&t.item.forEachItem(e)}forEachFieldInstance(e){if(this.fieldInstances)for(const t of this.fieldInstances)t.forEachField(e)}toString(){return`PreparedItem(${JSON.stringify({_id:this._id,name:this.name,type:this.type})})`}}function X(e,t,a){if(e.admin||e.superadmin)return!0;if(!Array.isArray(t))return!0;for(const i of t)if(i.can.includes(a)){if(!i.user&&!i.group)return!0;if(i.user&&i.user===e._id)return!0;if(i.group)for(const t of e.groups){if("object"==typeof t&&t._id===i.group)return!0;if(t===i.group)return!0}}}class Q{fields;constructor(e){if(!Array.isArray(e))throw"Template fields need to be an array!";this.fields=e}clone(){const e=[];for(const t of this.fields)e.push(t.clone());return new Q(e)}specialize(e){for(const t of this.fields)void 0!==e[t.name]&&(t.defaultValue=e[t.name]);return this}instantiate(e){if(e)return this.fields;{const e=[];for(const t of this.fields)e.push(t.clone());return e}}}class ee{templates=new Map;templatesByField=new Map;static _instance;static get instance(){return this._instance||(this._instance=new this)}_existsTemplate(e,t){for(const a of e)if(a.typeName===t)return!0;return!1}addTemplates(e,t,a){const i=`${e}_${t}`,n=this.templatesByField.get(i)||[];for(const e of a){const t=`${i}_${e.typeName}`;this.templates.set(t,e),this._existsTemplate(n,e.typeName)||n.push(e)}this.templatesByField.set(i,n)}getTemplate(e,t,a){const i=`${e}_${t}_${a}`;return this.templates.get(i)}getTemplates(e,t){const a=`${e}_${t}`;return this.templatesByField.get(a)||[]}}class te{itemRepo;itemFetcher;constructor(e){this.itemRepo=e,this.itemFetcher=function(e){return e}}setItemFetcher(e){this.itemFetcher=e}setFieldsFromDatatypes(e){const t=C(e.type,!0);e.fields=t.fields||[],e.fieldSets=t.fieldSets||[]}async prepare(e){return e instanceof K?(console.warn("Trying to prepare an already prepared item: ",e),e):this.itemRepo.undoManager.ignore((async()=>{const t=new K(e);return this.setFieldsFromDatatypes(t),t.fieldInstances=await this.createFieldInstances(t,t.fields,t.attributes,"","attributes",!1),t.userFieldInstances=await this.createFieldInstances(t,t.userFields,t.userAttributes,"","userAttributes",!1),t.customFieldInstances=await this.createCustomFieldInstances(t,t.userAttributes,"_"),t.allowConversation=!!t.allowConversation,t.packageContent&&await this.itemRepo.traverseItems((e=>{e.readOnly=!0,e.isPackaged=!0,e.packageItem=t}),t.packageContent),t.packageItem?(t.readOnly=!0,t.isPackaged=!0):(t.isPackaged=!1,t.resultingAcl&&t.resultingAcl.length>0?t.readOnly=!X(await this.itemRepo.apiClient.me(!0),t.resultingAcl,"write"):t.readOnly=!0),t}))}async createCustomFieldInstances(e,t,a=""){if(!e)throw new _("createCustomFieldInstances(): Item cannot be null!");if(!t)throw new _("createCustomFieldInstances(): attributes cannot be null!");const i=[];for(const n in t)if(!a.length||n.startsWith(a)){const r=n.substring(a.length);let s=new J(r,t[n],e);s.setType("Attribute"),i.push(g.instance.proxyCustomField(s,e))}if(e.links)for(const t of e.links)if(!a.length||t.usage.startsWith(a)){const n=t.usage.substring(a.length);let r,{id:s,linkItem:o,stopRecursion:l}=await this.fetchLinkValue(e,t.usage);o?r=o:l&&(r=s);let u=new J(n,r,e);u.setType("Link"),i.push(g.instance.proxyCustomField(u,e))}return i}async createFieldInstances(e,t,a,i,n,r=!1){if(!e)throw new _("createFieldInstances(): Item cannot be null!");if(!t)throw new _("createFieldInstances(): Fields cannot be null!");const s=[],o=i.length?`${i}->`:i;for(let a=0;a<t.length;a++){const i=t[a];if("FieldSet"===i.type){const n=this.getFieldSet(e,i.name);n?(t.splice(a,1,...structuredClone(n.fields)),a+=n.fields.length-1):console.error("Fieldset not found: "+i.name)}}for(const i of t)switch(i.type){case"Separator":{const t=new Z("Separator",i.label,"Separator",null,e,this.itemRepo);t.setInfo(i.info),t.setCondition(i.if),t.setCollapsed(i.collapsed),t.setPresets(i.presets),s.push(t);break}case"Label":{const t=new Z("Label","","Label",i.text,e,this.itemRepo);t.setLabelType(i.labelType),t.setCondition(i.if),s.push(t);break}case"Link":{let t;if(!r){let{id:a,linkItem:n,stopRecursion:r}=await this.fetchLinkValue(e,i.usageAs);n?t=n:r&&(t=a)}let a=new Z(i.usageAs,i.displayName,i.type,t,e,this.itemRepo);a.setInfo(i.info),a.setCondition(i.if),a.setLinkableTypes(i.linkableTypes),void 0!==i.preload&&a.setPreload(i.preload),void 0!==i.loadingManager&&a.setLoadingManagerRule(i.loadingManager),s.push(g.instance.proxyItemField(a,e));break}case"Tree":{const t=`${o}${i.name}`,r=[];for(const s of i.childTypes){const i=new Q(await this.createFieldInstances(e,s.fields,a,t,n,!0));r.push({typeName:s.typeName,displayName:s.displayName||s.typeName,template:i,inputs:[],outputs:[]})}r.sort((function(e,t){return e.displayName.localeCompare(t.displayName)})),ee.instance.addTemplates(e.type,i.name,r);const l=new ae(void 0,void 0,"","Root",void 0,e),u=await this.readBlocks(e,l,i.name,t,a,!0,!0,"Tree");l.blocks=g.instance.proxyBlockArray(u,l,e);let c=new Z(i.name,i.displayName,i.type,null,e,this.itemRepo);c.setInfo(i.info),c.setCondition(i.if),c.setBlocks([l]),s.push(c);break}case"List":{const t=`${o}${i.name}`,r=new Q(await this.createFieldInstances(e,i.fields,a,t,n,!0)),l=[{typeName:"Entry",displayName:i.elementName,template:r,inputs:[],outputs:[]}];ee.instance.addTemplates(e.type,i.name,l);let u=new Z(i.name,i.displayName,i.type,null,e,this.itemRepo);const c=await this.readBlocks(e,void 0,i.name,t,a,!0,!0,"List"),d=g.instance.proxyListArray(c,u,e);u.setInfo(i.info),u.setCondition(i.if),u.setBlocks(d),s.push(u);break}case"NodeGraph":{const t=`${o}${i.name}`,r=[];for(const s of i.childTypes){const i=new Q(await this.createFieldInstances(e,s.fields,a,t,n,!0));r.push({typeName:s.typeName,displayName:s.displayName||s.typeName,template:i,inputs:s.inputs||[],outputs:s.outputs||[]})}r.sort((function(e,t){return e.displayName.localeCompare(t.displayName)})),ee.instance.addTemplates(e.type,i.name,r);let l=await this.readBlocks(e,void 0,i.name,t,a,!1,!1,"NodeGraph"),u=this.readConnections(e,t,a),c=new Z(i.name,i.displayName,i.type,null,e,this.itemRepo);c.setInfo(i.info),c.setCondition(i.if),c.setBlocks(g.instance.proxyGraphBlockArray(l,e)),c.setConnections(g.instance.proxyConnectionArray(u,e)),s.push(c);break}case"Attribute":{let t;r||(t=e[n]?e[n][i.name]:void 0,void 0===t&&(t=i.defaultValue));let a=new Z(i.name,i.displayName,i.type,t,e,this.itemRepo);a.setInfo(i.info),a.setCondition(i.if),a.setDefaultValue(i.defaultValue),a.setMinValue(i.minValue),a.setMaxValue(i.maxValue),a.setOptions(i.options),a.setDatatype(i.datatype),a.setLanguage(i.language),a.setWidget(i.widget),a.setLength(i.length),s.push(g.instance.proxyItemField(a,e));break}}return s}getFieldSet(e,t){if(Array.isArray(e.fieldSets))for(const a of e.fieldSets)if(a.name===t)return a;return null}async fetchLinkValue(e,t){if(!e)throw new _("fetchLinkValue(): Item cannot be null!");for(const a of e.links)if(a.usage===t)return{id:a.to,linkItem:a.item?await this.itemFetcher(a.item):null,stopRecursion:a.stopRecursion};return{id:null,linkItem:null}}async readBlocks(e,t,a,i,n,r,s,o){if(!e)throw new _("readBlocks(): Item cannot be null!");const l=[];let u=0;for(;;){const c=`${i}[${u}]`;if(!this.existsBlockNamespace(e,n,c))break;{const i=`${c}#id`,u=e.attributes[i],d=`${c}#type`;let p,h,f=e.attributes[d];switch(o){case"NodeGraph":{const t=`${c}#posx`,a=`${c}#posy`;p=e.attributes[t]||0,h=e.attributes[a]||0;break}case"List":r=!1,f="Entry"}const m=ee.instance.getTemplate(e.packageType||e.type,a,f);if(m){const i=m.typeName,d=m.displayName,f=new ae(u,t,i,i,d,e),y=await this.createFields(f,e,m.template,c,"NodeGraph"===o,n);if(f.setFields(y),"NodeGraph"===o&&(f.setPosition(p,h),f.setInputs(m.inputs),f.setOutputs(m.outputs)),r){const t=await this.readBlocks(e,f,a,c,n,r,s,o);f.blocks=g.instance.proxyBlockArray(t,f,e)}if(s){const t=await this.readScripts(e,f,c,n);f.scripts=g.instance.proxyScriptArray(t,f,e)}"NodeGraph"===o?l.push(g.instance.proxyGraphBlock(f,e)):l.push(g.instance.proxyBlock(f,e))}else console.error(`Block template not found: ${a}_${f}`)}u++}return l}async readScripts(e,t,a,i){if(!e)throw new _("readScripts(): Item cannot be null!");const n=[];let r=0;for(;;){const s=`${a}#scripts[${r}]`;if(!this.existsScriptNamespace(e,i,s))break;{const a=i[`${s}#id`],r=`${s}#item`,o=`${s}->`,l=o.length;let{linkItem:u}=await this.fetchLinkValue(e,r);const c=new W(a,t,e,u);n.push(c);for(const t in i)if(i.hasOwnProperty(t)&&t.startsWith(o)){const a=i[t],n=t.substring(l),r=new j(c,n,a,e);c.addField(r)}}r++}return n}existsScriptNamespace(e,t,a){if(!e)throw new _("existsScriptNamespace(): Item cannot be null!");return"Script"===t[`${a}#usage`]}readConnections(e,t,a){const i=[];let n=0;for(;;){const r=a[`${t}#connection[${n++}]`];if(!r)break;i.push(new U(r,e))}return i}existsBlockNamespace(e,t,a){if(!e)throw new _("existsBlockNamespace(): Item cannot be null!");const i=t[`${a}#usage`];if(i)return"Block"===i;for(const e in t)if(t.hasOwnProperty(e)&&e.startsWith(a))return!0;for(const t of e.links)if(t.usage.startsWith(a))return!0;return!1}async createFields(e,t,a,i,n,r,s=!1){let o=a.instantiate(s),l=[];for(const a of o)if(a.name){const s=`${i}->${a.name}`;switch(a.type){case"Link":if(i){let{id:e,linkItem:i,stopRecursion:n}=await this.fetchLinkValue(t,s);a.value=i||(n?e:null)}else a.value=a.defaultValue;break;case"List":{const e=await this.readBlocks(t,void 0,a.name,s,r,!0,!0,"List"),i=g.instance.proxyListArray(e,a,t);a.setBlocks(i);break}case"Attribute":i?(a.value=t.attributes[s],void 0===a.value&&(a.value=a.defaultValue)):a.value=a.defaultValue}n?l.push(g.instance.proxyGraphBlockField(a,e,t)):l.push(g.instance.proxyBlockField(a,e,t))}return l}static refreshFieldDependencies(e){const t=new Map,a=new Map;for(const a of e)t.set(a.name,a);for(const i of e)if(Array.isArray(i.conditionFieldNames))for(const e of i.conditionFieldNames){const n=t.get(e);if(n){const e=a.get(n);e?e.push(i):a.set(n,[i])}}for(const i of e)i.refreshDependantFields(t,a.get(i))}}class ae extends ${id="";parent=void 0;type=void 0;name="";displayName="";fields=[];blocks=[];isSelected=!1;isExpanded=!0;scripts=[];inputs=[];outputs=[];posX=0;posY=0;constructor(e=void 0,t=void 0,a=void 0,i=void 0,n=void 0,r=void 0){super(r),e instanceof O?this.restoreFromSnapshot(e,t):(this.id=e||h.createItemOrBlockID(),this.parent=t,this.type=a,this.name=i||this.type||"",this.displayName=n||this.name)}getId(){return this.id}getPositionInParent(){if(this.parent){let e=0;for(const t of this.parent.blocks){if(t.id===this.id)return e;e++}}return-1}refreshFieldDependencies(){te.refreshFieldDependencies(this.fields);for(const e of this.fields)e.refreshFieldDependencies();for(const e of this.blocks)e.refreshFieldDependencies()}resetFieldValues(e=!1){for(const e of this.fields)e.resetValue();if(e)for(const t of this.blocks)t.resetFieldValues(e)}makeIdsUnique(e=new Map,t=!1){if(e.has(this.id)||t){const t=h.createItemOrBlockID();e.set(this.id,t),this.id=t}else e.set(this.id,this.id);for(const a of this.fields)a.makeIdsUnique(e,t);for(const a of this.blocks)a.makeIdsUnique(e,t);for(const a of this.scripts)a.makeIdsUnique(e,t);return e}transformNodeIds(e){for(const t of this.fields)t.transformNodeIds(e);for(const t of this.blocks)t.transformNodeIds(e);for(const t of this.scripts)t.transformNodeIds(e)}clone(e,t=!0,a={},i=!1){const n=new ae;i&&(n.id=this.id),n.ownerItem=this.ownerItem,n.parent=this.parent,n.type=this.type,n.name=this.name,n.displayName=this.displayName,n.isSelected=!1,n.isExpanded=!0,n.inputs=this.inputs,n.outputs=this.outputs,n.posX=0,n.posY=0;for(const t of this.fields){let r=t.clone(e,i);void 0!==a[t.name]&&(r.value=a[t.name]),e&&(r=g.instance.proxyBlockField(r,n,e)),n.fields.push(r)}if(e&&(n.scripts=g.instance.proxyScriptArray(n.scripts,n,e)),t)for(const e of this.scripts){const t=e.clone();n.scripts.push(t)}const r=n.blocks;e&&(n.blocks=g.instance.proxyBlockArray(r,n,e));for(const a of this.blocks){let s=a.clone(e,t,{},i);s.parent=n,e&&(s=g.instance.proxyBlock(s,e)),r.push(s)}return n}getDescendantBlocks(e=[]){const t=this.blocks;return e.push(...t),t.forEach((t=>t.getDescendantBlocks(e))),e}setFields(e){this.fields=e}setInputs(e){this.inputs=e}setOutputs(e){this.outputs=e}setPosition(e,t){this.posX=e,this.posY=t}setSelected(e){this.isSelected=e}setExpanded(e){this.isExpanded=e}getRoot(){return this.parent?this.parent.getRoot():this}forEachField(e){if(this.fields)for(const t of this.fields)t.forEachField(e);if(this.blocks)for(const t of this.blocks)t.forEachField(e)}findField(e){for(const t of this.fields)if(t.name===e)return t;return null}findBlock(e){if(this.id===e)return this;for(const t of this.blocks){const a=t.findBlock(e);if(a)return a}return null}removeBlock(e){this.blocks.removeObject(e)}addBlock(e,t){this.blocks.includes(e)||(void 0===t?this.blocks.push(e):this.blocks.splice(t,0,e))}moveBlock(e,t){e.parent.blocks.moveObjectToArray(e,e.parent.blocks,t)}moveToPosition(e){this.parent.moveBlock(this,e)}moveBlockToParent(e,t){this.parent.blocks.moveObjectToArray(this,e.blocks,t),this.parent=e}moveToParent(e,t){if(this.findBlock(e))return void console.error("Cannot move block to a parent that is a child.");const a=this.getRoot();if(!a)return void console.error("Cannot find root block!");const i=a.findBlock(e);i?this.parent!==i?this.moveBlockToParent(i,t):console.warn(`Node is already in parent ${e}`):console.error(`Cannot find the new parent block: ${e}`)}getField(e){for(const t of this.fields)if(t.name===e)return t;return null}hasTag(e){const t=this.getField("Tags");return!(!t||!Array.isArray(t.value))&&t.value.includes(e)}hasOneTag(e){const t=this.getField("Tags");if(t&&Array.isArray(t.value))for(const a of e)if(t.value.includes(a))return!0;return!1}getNameFieldValue(){const e=this.getField("Name");return e?e.value:null}getActiveFieldValue(){const e=this.getField("Active");return!e||e.value}createSnapshot(e=!1){const t=[];for(const a of this.fields)a.createSnapshot&&t.push(a.createSnapshot(e));const a=[];if(!e)for(const t of this.blocks)a.push(t.createSnapshot(e));const i=[];for(const e of this.scripts)i.push(e.createSnapshot());return new O(this.id,"block",{id:this.id,ownerItem:this.ownerItem,type:this.type,name:this.name,displayName:this.displayName,fields:t,blocks:a,isExpanded:this.isExpanded,scripts:i,inputs:this.inputs,outputs:this.outputs,posX:this.posX,posY:this.posY})}restoreFromSnapshot(e,t){this.id=e.data.id,this.parent=t,this.type=e.data.type,this.ownerItem=e.data.ownerItem,this.name=e.data.name,this.displayName=e.data.displayName,this.isSelected=!1,this.isExpanded=e.data.isExpanded,this.inputs=e.data.inputs,this.outputs=e.data.outputs,this.posX=e.data.posX,this.posY=e.data.posY;const a=[];this._rollbackArray(a,e.data.fields,(e=>g.instance.proxyBlockField(new Z(e),this,this.ownerItem))),this.fields=a;const i=[];this._rollbackArray(i,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem))),this.blocks=g.instance.proxyBlockArray(i,this,this.ownerItem);const n=[];this._rollbackArray(n,e.data.scripts,((e,t)=>new W(e,t,this.ownerItem))),this.scripts=g.instance.proxyScriptArray(n,this,this.ownerItem)}rollbackFromSnapshot(e,t=!1){this._rollbackArray(this.fields,e.data.fields,(e=>g.instance.proxyBlockField(new Z(e),this,this.ownerItem))),this._rollbackArray(this.scripts,e.data.scripts,(e=>new W(e,this,this.ownerItem))),t||this._rollbackArray(this.blocks,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem)))}_getFieldByName(e,t){for(const a of t)if(a.id===e)return a;return null}}
12
- /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const ne=256,re=286,se=30,oe=15,le=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ue=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ce=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),de=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pe=new Array(576);ie(pe);const he=new Array(60);ie(he);const fe=new Array(512);ie(fe);const me=new Array(256);ie(me);const ye=new Array(29);ie(ye);const ge=new Array(se);function be(e,t,a,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let ve,we,_e;function Ae(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ie(ge);const ke=e=>e<256?fe[e]:fe[256+(e>>>7)],Se=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ne=(e,t,a)=>{e.bi_valid>16-a?(e.bi_buf|=t<<e.bi_valid&65535,Se(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=a-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=a)},Te=(e,t,a)=>{Ne(e,a[2*t],a[2*t+1])},Me=(e,t)=>{let a=0;do{a|=1&e,e>>>=1,a<<=1}while(--t>0);return a>>>1},xe=(e,t,a)=>{const i=new Array(16);let n,r,s=0;for(n=1;n<=oe;n++)s=s+a[n-1]<<1,i[n]=s;for(r=0;r<=t;r++){let t=e[2*r+1];0!==t&&(e[2*r]=Me(i[t]++,t))}},Ce=e=>{let t;for(t=0;t<re;t++)e.dyn_ltree[2*t]=0;for(t=0;t<se;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Ve=e=>{e.bi_valid>8?Se(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ie=(e,t,a,i)=>{const n=2*t,r=2*a;return e[n]<e[r]||e[n]===e[r]&&i[t]<=i[a]},Ee=(e,t,a)=>{const i=e.heap[a];let n=a<<1;for(;n<=e.heap_len&&(n<e.heap_len&&Ie(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Ie(t,i,e.heap[n],e.depth));)e.heap[a]=e.heap[n],a=n,n<<=1;e.heap[a]=i},Fe=(e,t,a)=>{let i,n,r,s,o=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+o++],i+=(255&e.pending_buf[e.sym_buf+o++])<<8,n=e.pending_buf[e.sym_buf+o++],0===i?Te(e,n,t):(r=me[n],Te(e,r+ne+1,t),s=le[r],0!==s&&(n-=ye[r],Ne(e,n,s)),i--,r=ke(i),Te(e,r,a),s=ue[r],0!==s&&(i-=ge[r],Ne(e,i,s)))}while(o<e.sym_next);Te(e,256,t)},De=(e,t)=>{const a=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,r=t.stat_desc.elems;let s,o,l,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s<r;s++)0!==a[2*s]?(e.heap[++e.heap_len]=u=s,e.depth[s]=0):a[2*s+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=u<2?++u:0,a[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=i[2*l+1]);for(t.max_code=u,s=e.heap_len>>1;s>=1;s--)Ee(e,a,s);l=r;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ee(e,a,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,a[2*l]=a[2*s]+a[2*o],e.depth[l]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,a[2*s+1]=a[2*o+1]=l,e.heap[1]=l++,Ee(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const a=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let u,c,d,p,h,f,m=0;for(p=0;p<=oe;p++)e.bl_count[p]=0;for(a[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)c=e.heap[u],p=a[2*a[2*c+1]+1]+1,p>l&&(p=l,m++),a[2*c+1]=p,c>i||(e.bl_count[p]++,h=0,c>=o&&(h=s[c-o]),f=a[2*c],e.opt_len+=f*(p+h),r&&(e.static_len+=f*(n[2*c+1]+h)));if(0!==m){do{for(p=l-1;0===e.bl_count[p];)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(p=l;0!==p;p--)for(c=e.bl_count[p];0!==c;)d=e.heap[--u],d>i||(a[2*d+1]!==p&&(e.opt_len+=(p-a[2*d+1])*a[2*d],a[2*d+1]=p),c--)}})(e,t),xe(a,u,e.bl_count)},Re=(e,t,a)=>{let i,n,r=-1,s=t[1],o=0,l=7,u=4;for(0===s&&(l=138,u=3),t[2*(a+1)+1]=65535,i=0;i<=a;i++)n=s,s=t[2*(i+1)+1],++o<l&&n===s||(o<u?e.bl_tree[2*n]+=o:0!==n?(n!==r&&e.bl_tree[2*n]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,r=n,0===s?(l=138,u=3):n===s?(l=6,u=3):(l=7,u=4))},Pe=(e,t,a)=>{let i,n,r=-1,s=t[1],o=0,l=7,u=4;for(0===s&&(l=138,u=3),i=0;i<=a;i++)if(n=s,s=t[2*(i+1)+1],!(++o<l&&n===s)){if(o<u)do{Te(e,n,e.bl_tree)}while(0!=--o);else 0!==n?(n!==r&&(Te(e,n,e.bl_tree),o--),Te(e,16,e.bl_tree),Ne(e,o-3,2)):o<=10?(Te(e,17,e.bl_tree),Ne(e,o-3,3)):(Te(e,18,e.bl_tree),Ne(e,o-11,7));o=0,r=n,0===s?(l=138,u=3):n===s?(l=6,u=3):(l=7,u=4)}};let Le=!1;const Be=(e,t,a,i)=>{Ne(e,0+(i?1:0),3),Ve(e),Se(e,a),Se(e,~a),a&&e.pending_buf.set(e.window.subarray(t,t+a),e.pending),e.pending+=a};var Oe=e=>{Le||((()=>{let e,t,a,i,n;const r=new Array(16);for(a=0,i=0;i<28;i++)for(ye[i]=a,e=0;e<1<<le[i];e++)me[a++]=i;for(me[a-1]=i,n=0,i=0;i<16;i++)for(ge[i]=n,e=0;e<1<<ue[i];e++)fe[n++]=i;for(n>>=7;i<se;i++)for(ge[i]=n<<7,e=0;e<1<<ue[i]-7;e++)fe[256+n++]=i;for(t=0;t<=oe;t++)r[t]=0;for(e=0;e<=143;)pe[2*e+1]=8,e++,r[8]++;for(;e<=255;)pe[2*e+1]=9,e++,r[9]++;for(;e<=279;)pe[2*e+1]=7,e++,r[7]++;for(;e<=287;)pe[2*e+1]=8,e++,r[8]++;for(xe(pe,287,r),e=0;e<se;e++)he[2*e+1]=5,he[2*e]=Me(e,5);ve=new be(pe,le,257,re,oe),we=new be(he,ue,0,se,oe),_e=new be(new Array(0),ce,0,19,7)})(),Le=!0),e.l_desc=new Ae(e.dyn_ltree,ve),e.d_desc=new Ae(e.dyn_dtree,we),e.bl_desc=new Ae(e.bl_tree,_e),e.bi_buf=0,e.bi_valid=0,Ce(e)},$e=(e,t,a,i)=>{let n,r,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,a=4093624447;for(t=0;t<=31;t++,a>>>=1)if(1&a&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<ne;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),De(e,e.l_desc),De(e,e.d_desc),s=(e=>{let t;for(Re(e,e.dyn_ltree,e.l_desc.max_code),Re(e,e.dyn_dtree,e.d_desc.max_code),De(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*de[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=n&&(n=r)):n=r=a+5,a+4<=n&&-1!==t?Be(e,t,a,i):4===e.strategy||r===n?(Ne(e,2+(i?1:0),3),Fe(e,pe,he)):(Ne(e,4+(i?1:0),3),((e,t,a,i)=>{let n;for(Ne(e,t-257,5),Ne(e,a-1,5),Ne(e,i-4,4),n=0;n<i;n++)Ne(e,e.bl_tree[2*de[n]+1],3);Pe(e,e.dyn_ltree,t-1),Pe(e,e.dyn_dtree,a-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),Fe(e,e.dyn_ltree,e.dyn_dtree)),Ce(e),i&&Ve(e)},Ue={_tr_init:Oe,_tr_stored_block:Be,_tr_flush_block:$e,_tr_tally:(e,t,a)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=a,0===t?e.dyn_ltree[2*a]++:(e.matches++,t--,e.dyn_ltree[2*(me[a]+ne+1)]++,e.dyn_dtree[2*ke(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ne(e,2,3),Te(e,256,pe),(e=>{16===e.bi_valid?(Se(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var je=(e,t,a,i)=>{let n=65535&e,r=e>>>16&65535,s=0;for(;0!==a;){s=a>2e3?2e3:a,a-=s;do{n=n+t[i++]|0,r=r+n|0}while(--s);n%=65521,r%=65521}return n|r<<16};const ze=new Uint32Array((()=>{let e,t=[];for(var a=0;a<256;a++){e=a;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[a]=e}return t})());var We=(e,t,a,i)=>{const n=ze,r=i+a;e^=-1;for(let a=i;a<r;a++)e=e>>>8^n[255&(e^t[a])];return~e},Ye={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},He={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ge,_tr_stored_block:qe,_tr_flush_block:Ze,_tr_tally:Je,_tr_align:Ke}=Ue,{Z_NO_FLUSH:Xe,Z_PARTIAL_FLUSH:Qe,Z_FULL_FLUSH:et,Z_FINISH:tt,Z_BLOCK:at,Z_OK:it,Z_STREAM_END:nt,Z_STREAM_ERROR:rt,Z_DATA_ERROR:st,Z_BUF_ERROR:ot,Z_DEFAULT_COMPRESSION:lt,Z_FILTERED:ut,Z_HUFFMAN_ONLY:ct,Z_RLE:dt,Z_FIXED:pt,Z_DEFAULT_STRATEGY:ht,Z_UNKNOWN:ft,Z_DEFLATED:mt}=He,yt=258,gt=262,bt=42,vt=113,wt=666,_t=(e,t)=>(e.msg=Ye[t],t),At=e=>2*e-(e>4?9:0),kt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},St=e=>{let t,a,i,n=e.w_size;t=e.hash_size,i=t;do{a=e.head[--i],e.head[i]=a>=n?a-n:0}while(--t);t=n,i=t;do{a=e.prev[--i],e.prev[i]=a>=n?a-n:0}while(--t)};let Nt=(e,t,a)=>(t<<e.hash_shift^a)&e.hash_mask;const Tt=e=>{const t=e.state;let a=t.pending;a>e.avail_out&&(a=e.avail_out),0!==a&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+a),e.next_out),e.next_out+=a,t.pending_out+=a,e.total_out+=a,e.avail_out-=a,t.pending-=a,0===t.pending&&(t.pending_out=0))},Mt=(e,t)=>{Ze(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Tt(e.strm)},xt=(e,t)=>{e.pending_buf[e.pending++]=t},Ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Vt=(e,t,a,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),a),1===e.state.wrap?e.adler=je(e.adler,t,n,a):2===e.state.wrap&&(e.adler=We(e.adler,t,n,a)),e.next_in+=n,e.total_in+=n,n)},It=(e,t)=>{let a,i,n=e.max_chain_length,r=e.strstart,s=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-gt?e.strstart-(e.w_size-gt):0,u=e.window,c=e.w_mask,d=e.prev,p=e.strstart+yt;let h=u[r+s-1],f=u[r+s];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(a=t,u[a+s]===f&&u[a+s-1]===h&&u[a]===u[r]&&u[++a]===u[r+1]){r+=2,a++;do{}while(u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&r<p);if(i=yt-(p-r),r=p-yt,i>s){if(e.match_start=t,s=i,i>=o)break;h=u[r+s-1],f=u[r+s]}}}while((t=d[t&c])>l&&0!=--n);return s<=e.lookahead?s:e.lookahead},Et=e=>{const t=e.w_size;let a,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-gt)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),St(e),i+=t),0===e.strm.avail_in)break;if(a=Vt(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=a,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=Nt(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=Nt(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<gt&&0!==e.strm.avail_in)},Ft=(e,t)=>{let a,i,n,r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,o=e.strm.avail_in;do{if(a=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,i=e.strstart-e.block_start,a>i+e.strm.avail_in&&(a=i+e.strm.avail_in),a>n&&(a=n),a<r&&(0===a&&t!==tt||t===Xe||a!==i+e.strm.avail_in))break;s=t===tt&&a===i+e.strm.avail_in?1:0,qe(e,0,0,s),e.pending_buf[e.pending-4]=a,e.pending_buf[e.pending-3]=a>>8,e.pending_buf[e.pending-2]=~a,e.pending_buf[e.pending-1]=~a>>8,Tt(e.strm),i&&(i>a&&(i=a),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,a-=i),a&&(Vt(e.strm,e.strm.output,e.strm.next_out,a),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a)}while(0===s);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?4:t!==Xe&&t!==tt&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(Vt(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,r=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=r||(i||t===tt)&&t!==Xe&&0===e.strm.avail_in&&i<=n)&&(a=i>n?n:i,s=t===tt&&0===e.strm.avail_in&&a===i?1:0,qe(e,e.block_start,a,s),e.block_start+=a,Tt(e.strm)),s?3:1)},Dt=(e,t)=>{let a,i;for(;;){if(e.lookahead<gt){if(Et(e),e.lookahead<gt&&t===Xe)return 1;if(0===e.lookahead)break}if(a=0,e.lookahead>=3&&(e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==a&&e.strstart-a<=e.w_size-gt&&(e.match_length=It(e,a)),e.match_length>=3)if(i=Je(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+1]);else i=Je(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Mt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2},Rt=(e,t)=>{let a,i,n;for(;;){if(e.lookahead<gt){if(Et(e),e.lookahead<gt&&t===Xe)return 1;if(0===e.lookahead)break}if(a=0,e.lookahead>=3&&(e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==a&&e.prev_length<e.max_lazy_match&&e.strstart-a<=e.w_size-gt&&(e.match_length=It(e,a),e.match_length<=5&&(e.strategy===ut||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=Je(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(Mt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Je(e,0,e.window[e.strstart-1]),i&&Mt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Je(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2};function Pt(e,t,a,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=a,this.max_chain=i,this.func=n}const Lt=[new Pt(0,0,0,0,Ft),new Pt(4,4,8,4,Dt),new Pt(4,5,16,8,Dt),new Pt(4,6,32,32,Dt),new Pt(4,4,16,16,Rt),new Pt(8,16,32,32,Rt),new Pt(8,16,128,128,Rt),new Pt(8,32,128,256,Rt),new Pt(32,128,258,1024,Rt),new Pt(32,258,258,4096,Rt)];function Bt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=mt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),kt(this.dyn_ltree),kt(this.dyn_dtree),kt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),kt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),kt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ot=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==bt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==vt&&t.status!==wt?1:0},$t=e=>{if(Ot(e))return _t(e,rt);e.total_in=e.total_out=0,e.data_type=ft;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?bt:vt,e.adler=2===t.wrap?0:1,t.last_flush=-2,Ge(t),it},Ut=e=>{const t=$t(e);var a;return t===it&&((a=e.state).window_size=2*a.w_size,kt(a.head),a.max_lazy_match=Lt[a.level].max_lazy,a.good_match=Lt[a.level].good_length,a.nice_match=Lt[a.level].nice_length,a.max_chain_length=Lt[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),t},jt=(e,t,a,i,n,r)=>{if(!e)return rt;let s=1;if(t===lt&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),n<1||n>9||a!==mt||i<8||i>15||t<0||t>9||r<0||r>pt||8===i&&1!==s)return _t(e,rt);8===i&&(i=9);const o=new Bt;return e.state=o,o.strm=e,o.status=bt,o.wrap=s,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=r,o.method=a,Ut(e)};var zt=(e,t)=>{if(Ot(e)||t>at||t<0)return e?_t(e,rt):rt;const a=e.state;if(!e.output||0!==e.avail_in&&!e.input||a.status===wt&&t!==tt)return _t(e,0===e.avail_out?ot:rt);const i=a.last_flush;if(a.last_flush=t,0!==a.pending){if(Tt(e),0===e.avail_out)return a.last_flush=-1,it}else if(0===e.avail_in&&At(t)<=At(i)&&t!==tt)return _t(e,ot);if(a.status===wt&&0!==e.avail_in)return _t(e,ot);if(a.status===bt&&0===a.wrap&&(a.status=vt),a.status===bt){let t=mt+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=ct||a.level<2?0:a.level<6?1:6===a.level?2:3,t|=i<<6,0!==a.strstart&&(t|=32),t+=31-t%31,Ct(a,t),0!==a.strstart&&(Ct(a,e.adler>>>16),Ct(a,65535&e.adler)),e.adler=1,a.status=vt,Tt(e),0!==a.pending)return a.last_flush=-1,it}if(57===a.status)if(e.adler=0,xt(a,31),xt(a,139),xt(a,8),a.gzhead)xt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),xt(a,255&a.gzhead.time),xt(a,a.gzhead.time>>8&255),xt(a,a.gzhead.time>>16&255),xt(a,a.gzhead.time>>24&255),xt(a,9===a.level?2:a.strategy>=ct||a.level<2?4:0),xt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(xt(a,255&a.gzhead.extra.length),xt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=We(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(xt(a,0),xt(a,0),xt(a,0),xt(a,0),xt(a,0),xt(a,9===a.level?2:a.strategy>=ct||a.level<2?4:0),xt(a,3),a.status=vt,Tt(e),0!==a.pending)return a.last_flush=-1,it;if(69===a.status){if(a.gzhead.extra){let t=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>t&&(e.adler=We(e.adler,a.pending_buf,a.pending-t,t)),a.gzindex+=n,Tt(e),0!==a.pending)return a.last_flush=-1,it;t=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>t&&(e.adler=We(e.adler,a.pending_buf,a.pending-t,t)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let t,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i)),Tt(e),0!==a.pending)return a.last_flush=-1,it;i=0}t=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,xt(a,t)}while(0!==t);a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let t,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i)),Tt(e),0!==a.pending)return a.last_flush=-1,it;i=0}t=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,xt(a,t)}while(0!==t);a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(Tt(e),0!==a.pending))return a.last_flush=-1,it;xt(a,255&e.adler),xt(a,e.adler>>8&255),e.adler=0}if(a.status=vt,Tt(e),0!==a.pending)return a.last_flush=-1,it}if(0!==e.avail_in||0!==a.lookahead||t!==Xe&&a.status!==wt){let i=0===a.level?Ft(a,t):a.strategy===ct?((e,t)=>{let a;for(;;){if(0===e.lookahead&&(Et(e),0===e.lookahead)){if(t===Xe)return 1;break}if(e.match_length=0,a=Je(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,a&&(Mt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2})(a,t):a.strategy===dt?((e,t)=>{let a,i,n,r;const s=e.window;for(;;){if(e.lookahead<=yt){if(Et(e),e.lookahead<=yt&&t===Xe)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=s[n],i===s[++n]&&i===s[++n]&&i===s[++n])){r=e.strstart+yt;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<r);e.match_length=yt-(r-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(a=Je(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(a=Je(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),a&&(Mt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2})(a,t):Lt[a.level].func(a,t);if(3!==i&&4!==i||(a.status=wt),1===i||3===i)return 0===e.avail_out&&(a.last_flush=-1),it;if(2===i&&(t===Qe?Ke(a):t!==at&&(qe(a,0,0,!1),t===et&&(kt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),Tt(e),0===e.avail_out))return a.last_flush=-1,it}return t!==tt?it:a.wrap<=0?nt:(2===a.wrap?(xt(a,255&e.adler),xt(a,e.adler>>8&255),xt(a,e.adler>>16&255),xt(a,e.adler>>24&255),xt(a,255&e.total_in),xt(a,e.total_in>>8&255),xt(a,e.total_in>>16&255),xt(a,e.total_in>>24&255)):(Ct(a,e.adler>>>16),Ct(a,65535&e.adler)),Tt(e),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?it:nt)},Wt={deflateInit:(e,t)=>jt(e,t,mt,15,8,ht),deflateInit2:jt,deflateReset:Ut,deflateResetKeep:$t,deflateSetHeader:(e,t)=>Ot(e)||2!==e.state.wrap?rt:(e.state.gzhead=t,it),deflate:zt,deflateEnd:e=>{if(Ot(e))return rt;const t=e.state.status;return e.state=null,t===vt?_t(e,st):it},deflateSetDictionary:(e,t)=>{let a=t.length;if(Ot(e))return rt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==bt||i.lookahead)return rt;if(1===n&&(e.adler=je(e.adler,t,a,0)),i.wrap=0,a>=i.w_size){0===n&&(kt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(a-i.w_size,a),0),t=e,a=i.w_size}const r=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=a,e.next_in=0,e.input=t,Et(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=Nt(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,Et(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=s,e.input=o,e.avail_in=r,i.wrap=n,it},deflateInfo:"pako deflate (from Nodeca project)"};const Yt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ht=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const a=t.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const t in a)Yt(a,t)&&(e[t]=a[t])}}return e},Gt=e=>{let t=0;for(let a=0,i=e.length;a<i;a++)t+=e[a].length;const a=new Uint8Array(t);for(let t=0,i=0,n=e.length;t<n;t++){let n=e[t];a.set(n,i),i+=n.length}return a};let qt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){qt=!1}const Zt=new Uint8Array(256);for(let e=0;e<256;e++)Zt[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Zt[254]=Zt[254]=1;var Jt=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,a,i,n,r,s=e.length,o=0;for(n=0;n<s;n++)a=e.charCodeAt(n),55296==(64512&a)&&n+1<s&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),o+=a<128?1:a<2048?2:a<65536?3:4;for(t=new Uint8Array(o),r=0,n=0;r<o;n++)a=e.charCodeAt(n),55296==(64512&a)&&n+1<s&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),a<128?t[r++]=a:a<2048?(t[r++]=192|a>>>6,t[r++]=128|63&a):a<65536?(t[r++]=224|a>>>12,t[r++]=128|a>>>6&63,t[r++]=128|63&a):(t[r++]=240|a>>>18,t[r++]=128|a>>>12&63,t[r++]=128|a>>>6&63,t[r++]=128|63&a);return t},Kt=(e,t)=>{const a=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,n;const r=new Array(2*a);for(n=0,i=0;i<a;){let t=e[i++];if(t<128){r[n++]=t;continue}let s=Zt[t];if(s>4)r[n++]=65533,i+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&i<a;)t=t<<6|63&e[i++],s--;s>1?r[n++]=65533:t<65536?r[n++]=t:(t-=65536,r[n++]=55296|t>>10&1023,r[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&qt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let a="";for(let i=0;i<t;i++)a+=String.fromCharCode(e[i]);return a})(r,n)},Xt=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let a=t-1;for(;a>=0&&128==(192&e[a]);)a--;return a<0||0===a?t:a+Zt[e[a]]>t?a:t};var Qt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const ea=Object.prototype.toString,{Z_NO_FLUSH:ta,Z_SYNC_FLUSH:aa,Z_FULL_FLUSH:ia,Z_FINISH:na,Z_OK:ra,Z_STREAM_END:sa,Z_DEFAULT_COMPRESSION:oa,Z_DEFAULT_STRATEGY:la,Z_DEFLATED:ua}=He;function ca(e){this.options=Ht({level:oa,method:ua,chunkSize:16384,windowBits:15,memLevel:8,strategy:la},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qt,this.strm.avail_out=0;let a=Wt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(a!==ra)throw new Error(Ye[a]);if(t.header&&Wt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Jt(t.dictionary):"[object ArrayBuffer]"===ea.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,a=Wt.deflateSetDictionary(this.strm,e),a!==ra)throw new Error(Ye[a]);this._dict_set=!0}}function da(e,t){const a=new ca(t);if(a.push(e,!0),a.err)throw a.msg||Ye[a.err];return a.result}ca.prototype.push=function(e,t){const a=this.strm,i=this.options.chunkSize;let n,r;if(this.ended)return!1;for(r=t===~~t?t:!0===t?na:ta,"string"==typeof e?a.input=Jt(e):"[object ArrayBuffer]"===ea.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(r===aa||r===ia)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Wt.deflate(a,r),n===sa)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Wt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===ra;if(0!==a.avail_out){if(r>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},ca.prototype.onData=function(e){this.chunks.push(e)},ca.prototype.onEnd=function(e){e===ra&&(this.result=Gt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pa=function(e,t){return(t=t||{}).raw=!0,da(e,t)},ha=function(e,t){return(t=t||{}).gzip=!0,da(e,t)},fa={Deflate:ca,deflate:da,deflateRaw:pa,gzip:ha};const ma=16209;var ya=function(e,t){let a,i,n,r,s,o,l,u,c,d,p,h,f,m,y,g,b,v,w,_,A,k,S,N;const T=e.state;a=e.next_in,S=e.input,i=a+(e.avail_in-5),n=e.next_out,N=e.output,r=n-(t-e.avail_out),s=n+(e.avail_out-257),o=T.dmax,l=T.wsize,u=T.whave,c=T.wnext,d=T.window,p=T.hold,h=T.bits,f=T.lencode,m=T.distcode,y=(1<<T.lenbits)-1,g=(1<<T.distbits)-1;e:do{h<15&&(p+=S[a++]<<h,h+=8,p+=S[a++]<<h,h+=8),b=f[p&y];t:for(;;){if(v=b>>>24,p>>>=v,h-=v,v=b>>>16&255,0===v)N[n++]=65535&b;else{if(!(16&v)){if(64&v){if(32&v){T.mode=16191;break e}e.msg="invalid literal/length code",T.mode=ma;break e}b=f[(65535&b)+(p&(1<<v)-1)];continue t}for(w=65535&b,v&=15,v&&(h<v&&(p+=S[a++]<<h,h+=8),w+=p&(1<<v)-1,p>>>=v,h-=v),h<15&&(p+=S[a++]<<h,h+=8,p+=S[a++]<<h,h+=8),b=m[p&g];;){if(v=b>>>24,p>>>=v,h-=v,v=b>>>16&255,16&v){if(_=65535&b,v&=15,h<v&&(p+=S[a++]<<h,h+=8,h<v&&(p+=S[a++]<<h,h+=8)),_+=p&(1<<v)-1,_>o){e.msg="invalid distance too far back",T.mode=ma;break e}if(p>>>=v,h-=v,v=n-r,_>v){if(v=_-v,v>u&&T.sane){e.msg="invalid distance too far back",T.mode=ma;break e}if(A=0,k=d,0===c){if(A+=l-v,v<w){w-=v;do{N[n++]=d[A++]}while(--v);A=n-_,k=N}}else if(c<v){if(A+=l+c-v,v-=c,v<w){w-=v;do{N[n++]=d[A++]}while(--v);if(A=0,c<w){v=c,w-=v;do{N[n++]=d[A++]}while(--v);A=n-_,k=N}}}else if(A+=c-v,v<w){w-=v;do{N[n++]=d[A++]}while(--v);A=n-_,k=N}for(;w>2;)N[n++]=k[A++],N[n++]=k[A++],N[n++]=k[A++],w-=3;w&&(N[n++]=k[A++],w>1&&(N[n++]=k[A++]))}else{A=n-_;do{N[n++]=N[A++],N[n++]=N[A++],N[n++]=N[A++],w-=3}while(w>2);w&&(N[n++]=N[A++],w>1&&(N[n++]=N[A++]))}break}if(64&v){e.msg="invalid distance code",T.mode=ma;break e}b=m[(65535&b)+(p&(1<<v)-1)]}}break}}while(a<i&&n<s);w=h>>3,a-=w,h-=w<<3,p&=(1<<h)-1,e.next_in=a,e.next_out=n,e.avail_in=a<i?i-a+5:5-(a-i),e.avail_out=n<s?s-n+257:257-(n-s),T.hold=p,T.bits=h};const ga=15,ba=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),va=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),wa=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),_a=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Aa=(e,t,a,i,n,r,s,o)=>{const l=o.bits;let u,c,d,p,h,f,m=0,y=0,g=0,b=0,v=0,w=0,_=0,A=0,k=0,S=0,N=null;const T=new Uint16Array(16),M=new Uint16Array(16);let x,C,V,I=null;for(m=0;m<=ga;m++)T[m]=0;for(y=0;y<i;y++)T[t[a+y]]++;for(v=l,b=ga;b>=1&&0===T[b];b--);if(v>b&&(v=b),0===b)return n[r++]=20971520,n[r++]=20971520,o.bits=1,0;for(g=1;g<b&&0===T[g];g++);for(v<g&&(v=g),A=1,m=1;m<=ga;m++)if(A<<=1,A-=T[m],A<0)return-1;if(A>0&&(0===e||1!==b))return-1;for(M[1]=0,m=1;m<ga;m++)M[m+1]=M[m]+T[m];for(y=0;y<i;y++)0!==t[a+y]&&(s[M[t[a+y]]++]=y);if(0===e?(N=I=s,f=20):1===e?(N=ba,I=va,f=257):(N=wa,I=_a,f=0),S=0,y=0,m=g,h=r,w=v,_=0,d=-1,k=1<<v,p=k-1,1===e&&k>852||2===e&&k>592)return 1;for(;;){x=m-_,s[y]+1<f?(C=0,V=s[y]):s[y]>=f?(C=I[s[y]-f],V=N[s[y]-f]):(C=96,V=0),u=1<<m-_,c=1<<w,g=c;do{c-=u,n[h+(S>>_)+c]=x<<24|C<<16|V}while(0!==c);for(u=1<<m-1;S&u;)u>>=1;if(0!==u?(S&=u-1,S+=u):S=0,y++,0==--T[m]){if(m===b)break;m=t[a+s[y]]}if(m>v&&(S&p)!==d){for(0===_&&(_=v),h+=g,w=m-_,A=1<<w;w+_<b&&(A-=T[w+_],!(A<=0));)w++,A<<=1;if(k+=1<<w,1===e&&k>852||2===e&&k>592)return 1;d=S&p,n[d]=v<<24|w<<16|h-r}}return 0!==S&&(n[h+S]=m-_<<24|64<<16),o.bits=v,0};const{Z_FINISH:ka,Z_BLOCK:Sa,Z_TREES:Na,Z_OK:Ta,Z_STREAM_END:Ma,Z_NEED_DICT:xa,Z_STREAM_ERROR:Ca,Z_DATA_ERROR:Va,Z_MEM_ERROR:Ia,Z_BUF_ERROR:Ea,Z_DEFLATED:Fa}=He,Da=16180,Ra=16190,Pa=16191,La=16192,Ba=16194,Oa=16199,$a=16200,Ua=16206,ja=16209,za=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Wa(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ya=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Da||t.mode>16211?1:0},Ha=e=>{if(Ya(e))return Ca;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Da,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Ta},Ga=e=>{if(Ya(e))return Ca;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ha(e)},qa=(e,t)=>{let a;if(Ya(e))return Ca;const i=e.state;return t<0?(a=0,t=-t):(a=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ca:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=a,i.wbits=t,Ga(e))},Za=(e,t)=>{if(!e)return Ca;const a=new Wa;e.state=a,a.strm=e,a.window=null,a.mode=Da;const i=qa(e,t);return i!==Ta&&(e.state=null),i};let Ja,Ka,Xa=!0;const Qa=e=>{if(Xa){Ja=new Int32Array(512),Ka=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Aa(1,e.lens,0,288,Ja,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Aa(2,e.lens,0,32,Ka,0,e.work,{bits:5}),Xa=!1}e.lencode=Ja,e.lenbits=9,e.distcode=Ka,e.distbits=5},ei=(e,t,a,i)=>{let n;const r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(t.subarray(a-r.wsize,a),0),r.wnext=0,r.whave=r.wsize):(n=r.wsize-r.wnext,n>i&&(n=i),r.window.set(t.subarray(a-i,a-i+n),r.wnext),(i-=n)?(r.window.set(t.subarray(a-i,a),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=n))),0};var ti=(e,t)=>{let a,i,n,r,s,o,l,u,c,d,p,h,f,m,y,g,b,v,w,_,A,k,S=0;const N=new Uint8Array(4);let T,M;const x=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ya(e)||!e.output||!e.input&&0!==e.avail_in)return Ca;a=e.state,a.mode===Pa&&(a.mode=La),s=e.next_out,n=e.output,l=e.avail_out,r=e.next_in,i=e.input,o=e.avail_in,u=a.hold,c=a.bits,d=o,p=l,k=Ta;e:for(;;)switch(a.mode){case Da:if(0===a.wrap){a.mode=La;break}for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(2&a.wrap&&35615===u){0===a.wbits&&(a.wbits=15),a.check=0,N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0),u=0,c=0,a.mode=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",a.mode=ja;break}if((15&u)!==Fa){e.msg="unknown compression method",a.mode=ja;break}if(u>>>=4,c-=4,A=8+(15&u),0===a.wbits&&(a.wbits=A),A>15||A>a.wbits){e.msg="invalid window size",a.mode=ja;break}a.dmax=1<<a.wbits,a.flags=0,e.adler=a.check=1,a.mode=512&u?16189:Pa,u=0,c=0;break;case 16181:for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(a.flags=u,(255&a.flags)!==Fa){e.msg="unknown compression method",a.mode=ja;break}if(57344&a.flags){e.msg="unknown header flags set",a.mode=ja;break}a.head&&(a.head.text=u>>8&1),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0)),u=0,c=0,a.mode=16182;case 16182:for(;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.head&&(a.head.time=u),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,a.check=We(a.check,N,4,0)),u=0,c=0,a.mode=16183;case 16183:for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.head&&(a.head.xflags=255&u,a.head.os=u>>8),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0)),u=0,c=0,a.mode=16184;case 16184:if(1024&a.flags){for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.length=u,a.head&&(a.head.extra_len=u),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0)),u=0,c=0}else a.head&&(a.head.extra=null);a.mode=16185;case 16185:if(1024&a.flags&&(h=a.length,h>o&&(h=o),h&&(a.head&&(A=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(r,r+h),A)),512&a.flags&&4&a.wrap&&(a.check=We(a.check,i,h,r)),o-=h,r+=h,a.length-=h),a.length))break e;a.length=0,a.mode=16186;case 16186:if(2048&a.flags){if(0===o)break e;h=0;do{A=i[r+h++],a.head&&A&&a.length<65536&&(a.head.name+=String.fromCharCode(A))}while(A&&h<o);if(512&a.flags&&4&a.wrap&&(a.check=We(a.check,i,h,r)),o-=h,r+=h,A)break e}else a.head&&(a.head.name=null);a.length=0,a.mode=16187;case 16187:if(4096&a.flags){if(0===o)break e;h=0;do{A=i[r+h++],a.head&&A&&a.length<65536&&(a.head.comment+=String.fromCharCode(A))}while(A&&h<o);if(512&a.flags&&4&a.wrap&&(a.check=We(a.check,i,h,r)),o-=h,r+=h,A)break e}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(4&a.wrap&&u!==(65535&a.check)){e.msg="header crc mismatch",a.mode=ja;break}u=0,c=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),e.adler=a.check=0,a.mode=Pa;break;case 16189:for(;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}e.adler=a.check=za(u),u=0,c=0,a.mode=Ra;case Ra:if(0===a.havedict)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=o,a.hold=u,a.bits=c,xa;e.adler=a.check=1,a.mode=Pa;case Pa:if(t===Sa||t===Na)break e;case La:if(a.last){u>>>=7&c,c-=7&c,a.mode=Ua;break}for(;c<3;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}switch(a.last=1&u,u>>>=1,c-=1,3&u){case 0:a.mode=16193;break;case 1:if(Qa(a),a.mode=Oa,t===Na){u>>>=2,c-=2;break e}break;case 2:a.mode=16196;break;case 3:e.msg="invalid block type",a.mode=ja}u>>>=2,c-=2;break;case 16193:for(u>>>=7&c,c-=7&c;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",a.mode=ja;break}if(a.length=65535&u,u=0,c=0,a.mode=Ba,t===Na)break e;case Ba:a.mode=16195;case 16195:if(h=a.length,h){if(h>o&&(h=o),h>l&&(h=l),0===h)break e;n.set(i.subarray(r,r+h),s),o-=h,r+=h,l-=h,s+=h,a.length-=h;break}a.mode=Pa;break;case 16196:for(;c<14;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(a.nlen=257+(31&u),u>>>=5,c-=5,a.ndist=1+(31&u),u>>>=5,c-=5,a.ncode=4+(15&u),u>>>=4,c-=4,a.nlen>286||a.ndist>30){e.msg="too many length or distance symbols",a.mode=ja;break}a.have=0,a.mode=16197;case 16197:for(;a.have<a.ncode;){for(;c<3;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.lens[x[a.have++]]=7&u,u>>>=3,c-=3}for(;a.have<19;)a.lens[x[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,T={bits:a.lenbits},k=Aa(0,a.lens,0,19,a.lencode,0,a.work,T),a.lenbits=T.bits,k){e.msg="invalid code lengths set",a.mode=ja;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;S=a.lencode[u&(1<<a.lenbits)-1],y=S>>>24,g=S>>>16&255,b=65535&S,!(y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(b<16)u>>>=y,c-=y,a.lens[a.have++]=b;else{if(16===b){for(M=y+2;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(u>>>=y,c-=y,0===a.have){e.msg="invalid bit length repeat",a.mode=ja;break}A=a.lens[a.have-1],h=3+(3&u),u>>>=2,c-=2}else if(17===b){for(M=y+3;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=y,c-=y,A=0,h=3+(7&u),u>>>=3,c-=3}else{for(M=y+7;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=y,c-=y,A=0,h=11+(127&u),u>>>=7,c-=7}if(a.have+h>a.nlen+a.ndist){e.msg="invalid bit length repeat",a.mode=ja;break}for(;h--;)a.lens[a.have++]=A}}if(a.mode===ja)break;if(0===a.lens[256]){e.msg="invalid code -- missing end-of-block",a.mode=ja;break}if(a.lenbits=9,T={bits:a.lenbits},k=Aa(1,a.lens,0,a.nlen,a.lencode,0,a.work,T),a.lenbits=T.bits,k){e.msg="invalid literal/lengths set",a.mode=ja;break}if(a.distbits=6,a.distcode=a.distdyn,T={bits:a.distbits},k=Aa(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,T),a.distbits=T.bits,k){e.msg="invalid distances set",a.mode=ja;break}if(a.mode=Oa,t===Na)break e;case Oa:a.mode=$a;case $a:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=o,a.hold=u,a.bits=c,ya(e,p),s=e.next_out,n=e.output,l=e.avail_out,r=e.next_in,i=e.input,o=e.avail_in,u=a.hold,c=a.bits,a.mode===Pa&&(a.back=-1);break}for(a.back=0;S=a.lencode[u&(1<<a.lenbits)-1],y=S>>>24,g=S>>>16&255,b=65535&S,!(y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(g&&!(240&g)){for(v=y,w=g,_=b;S=a.lencode[_+((u&(1<<v+w)-1)>>v)],y=S>>>24,g=S>>>16&255,b=65535&S,!(v+y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=v,c-=v,a.back+=v}if(u>>>=y,c-=y,a.back+=y,a.length=b,0===g){a.mode=16205;break}if(32&g){a.back=-1,a.mode=Pa;break}if(64&g){e.msg="invalid literal/length code",a.mode=ja;break}a.extra=15&g,a.mode=16201;case 16201:if(a.extra){for(M=a.extra;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.length+=u&(1<<a.extra)-1,u>>>=a.extra,c-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=16202;case 16202:for(;S=a.distcode[u&(1<<a.distbits)-1],y=S>>>24,g=S>>>16&255,b=65535&S,!(y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(!(240&g)){for(v=y,w=g,_=b;S=a.distcode[_+((u&(1<<v+w)-1)>>v)],y=S>>>24,g=S>>>16&255,b=65535&S,!(v+y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=v,c-=v,a.back+=v}if(u>>>=y,c-=y,a.back+=y,64&g){e.msg="invalid distance code",a.mode=ja;break}a.offset=b,a.extra=15&g,a.mode=16203;case 16203:if(a.extra){for(M=a.extra;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.offset+=u&(1<<a.extra)-1,u>>>=a.extra,c-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){e.msg="invalid distance too far back",a.mode=ja;break}a.mode=16204;case 16204:if(0===l)break e;if(h=p-l,a.offset>h){if(h=a.offset-h,h>a.whave&&a.sane){e.msg="invalid distance too far back",a.mode=ja;break}h>a.wnext?(h-=a.wnext,f=a.wsize-h):f=a.wnext-h,h>a.length&&(h=a.length),m=a.window}else m=n,f=s-a.offset,h=a.length;h>l&&(h=l),l-=h,a.length-=h;do{n[s++]=m[f++]}while(--h);0===a.length&&(a.mode=$a);break;case 16205:if(0===l)break e;n[s++]=a.length,l--,a.mode=$a;break;case Ua:if(a.wrap){for(;c<32;){if(0===o)break e;o--,u|=i[r++]<<c,c+=8}if(p-=l,e.total_out+=p,a.total+=p,4&a.wrap&&p&&(e.adler=a.check=a.flags?We(a.check,n,p,s-p):je(a.check,n,p,s-p)),p=l,4&a.wrap&&(a.flags?u:za(u))!==a.check){e.msg="incorrect data check",a.mode=ja;break}u=0,c=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(4&a.wrap&&u!==(4294967295&a.total)){e.msg="incorrect length check",a.mode=ja;break}u=0,c=0}a.mode=16208;case 16208:k=Ma;break e;case ja:k=Va;break e;case 16210:return Ia;default:return Ca}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=o,a.hold=u,a.bits=c,(a.wsize||p!==e.avail_out&&a.mode<ja&&(a.mode<Ua||t!==ka))&&ei(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,a.total+=p,4&a.wrap&&p&&(e.adler=a.check=a.flags?We(a.check,n,p,e.next_out-p):je(a.check,n,p,e.next_out-p)),e.data_type=a.bits+(a.last?64:0)+(a.mode===Pa?128:0)+(a.mode===Oa||a.mode===Ba?256:0),(0===d&&0===p||t===ka)&&k===Ta&&(k=Ea),k},ai={inflateReset:Ga,inflateReset2:qa,inflateResetKeep:Ha,inflateInit:e=>Za(e,15),inflateInit2:Za,inflate:ti,inflateEnd:e=>{if(Ya(e))return Ca;let t=e.state;return t.window&&(t.window=null),e.state=null,Ta},inflateGetHeader:(e,t)=>{if(Ya(e))return Ca;const a=e.state;return 2&a.wrap?(a.head=t,t.done=!1,Ta):Ca},inflateSetDictionary:(e,t)=>{const a=t.length;let i,n,r;return Ya(e)?Ca:(i=e.state,0!==i.wrap&&i.mode!==Ra?Ca:i.mode===Ra&&(n=1,n=je(n,t,a,0),n!==i.check)?Va:(r=ei(e,t,a,a),r?(i.mode=16210,Ia):(i.havedict=1,Ta)))},inflateInfo:"pako inflate (from Nodeca project)"};var ii=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ni=Object.prototype.toString,{Z_NO_FLUSH:ri,Z_FINISH:si,Z_OK:oi,Z_STREAM_END:li,Z_NEED_DICT:ui,Z_STREAM_ERROR:ci,Z_DATA_ERROR:di,Z_MEM_ERROR:pi}=He;function hi(e){this.options=Ht({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qt,this.strm.avail_out=0;let a=ai.inflateInit2(this.strm,t.windowBits);if(a!==oi)throw new Error(Ye[a]);if(this.header=new ii,ai.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Jt(t.dictionary):"[object ArrayBuffer]"===ni.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(a=ai.inflateSetDictionary(this.strm,t.dictionary),a!==oi)))throw new Error(Ye[a])}function fi(e,t){const a=new hi(t);if(a.push(e),a.err)throw a.msg||Ye[a.err];return a.result}hi.prototype.push=function(e,t){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let r,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?si:ri,"[object ArrayBuffer]"===ni.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),r=ai.inflate(a,s),r===ui&&n&&(r=ai.inflateSetDictionary(a,n),r===oi?r=ai.inflate(a,s):r===di&&(r=ui));a.avail_in>0&&r===li&&a.state.wrap>0&&0!==e[a.next_in];)ai.inflateReset(a),r=ai.inflate(a,s);switch(r){case ci:case di:case ui:case pi:return this.onEnd(r),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||r===li))if("string"===this.options.to){let e=Xt(a.output,a.next_out),t=a.next_out-e,n=Kt(a.output,e);a.next_out=t,a.avail_out=i-t,t&&a.output.set(a.output.subarray(e,e+t),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==oi||0!==o){if(r===li)return r=ai.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},hi.prototype.onData=function(e){this.chunks.push(e)},hi.prototype.onEnd=function(e){e===oi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Gt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mi=function(e,t){return(t=t||{}).raw=!0,fi(e,t)},yi={Inflate:hi,inflate:fi,inflateRaw:mi,ungzip:fi};const{Deflate:gi,deflate:bi,deflateRaw:vi,gzip:wi}=fa,{Inflate:_i,inflate:Ai,inflateRaw:ki,ungzip:Si}=yi;var Ni={Deflate:gi,deflate:bi,deflateRaw:vi,gzip:wi,Inflate:_i,inflate:Ai,inflateRaw:ki,ungzip:Si,constants:He},Ti="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Mi=[],xi=[],Ci="undefined"!=typeof Uint8Array?Uint8Array:Array,Vi=!1;function Ii(){Vi=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Mi[t]=e[t],xi[e.charCodeAt(t)]=t;xi["-".charCodeAt(0)]=62,xi["_".charCodeAt(0)]=63}function Ei(e,t,a){for(var i,n,r=[],s=t;s<a;s+=3)i=(e[s]<<16)+(e[s+1]<<8)+e[s+2],r.push(Mi[(n=i)>>18&63]+Mi[n>>12&63]+Mi[n>>6&63]+Mi[63&n]);return r.join("")}function Fi(e){var t;Vi||Ii();for(var a=e.length,i=a%3,n="",r=[],s=16383,o=0,l=a-i;o<l;o+=s)r.push(Ei(e,o,o+s>l?l:o+s));return 1===i?(t=e[a-1],n+=Mi[t>>2],n+=Mi[t<<4&63],n+="=="):2===i&&(t=(e[a-2]<<8)+e[a-1],n+=Mi[t>>10],n+=Mi[t>>4&63],n+=Mi[t<<2&63],n+="="),r.push(n),r.join("")}function Di(e,t,a,i,n){var r,s,o=8*n-i-1,l=(1<<o)-1,u=l>>1,c=-7,d=a?n-1:0,p=a?-1:1,h=e[t+d];for(d+=p,r=h&(1<<-c)-1,h>>=-c,c+=o;c>0;r=256*r+e[t+d],d+=p,c-=8);for(s=r&(1<<-c)-1,r>>=-c,c+=i;c>0;s=256*s+e[t+d],d+=p,c-=8);if(0===r)r=1-u;else{if(r===l)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,i),r-=u}return(h?-1:1)*s*Math.pow(2,r-i)}function Ri(e,t,a,i,n,r){var s,o,l,u=8*r-n-1,c=(1<<u)-1,d=c>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:r-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+d>=1?p/l:p*Math.pow(2,1-d))*l>=2&&(s++,l/=2),s+d>=c?(o=0,s=c):s+d>=1?(o=(t*l-1)*Math.pow(2,n),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;e[a+h]=255&o,h+=f,o/=256,n-=8);for(s=s<<n|o,u+=n;u>0;e[a+h]=255&s,h+=f,s/=256,u-=8);e[a+h-f]|=128*m}var Pi={}.toString,Li=Array.isArray||function(e){return"[object Array]"==Pi.call(e)};function Bi(){return $i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Oi(e,t){if(Bi()<t)throw new RangeError("Invalid typed array length");return $i.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=$i.prototype:(null===e&&(e=new $i(t)),e.length=t),e}function $i(e,t,a){if(!($i.TYPED_ARRAY_SUPPORT||this instanceof $i))return new $i(e,t,a);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return zi(this,e)}return Ui(this,e,t,a)}function Ui(e,t,a,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,a,i){if(t.byteLength,a<0||t.byteLength<a)throw new RangeError("'offset' is out of bounds");if(t.byteLength<a+(i||0))throw new RangeError("'length' is out of bounds");t=void 0===a&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,a):new Uint8Array(t,a,i);$i.TYPED_ARRAY_SUPPORT?(e=t).__proto__=$i.prototype:e=Wi(e,t);return e}(e,t,a,i):"string"==typeof t?function(e,t,a){"string"==typeof a&&""!==a||(a="utf8");if(!$i.isEncoding(a))throw new TypeError('"encoding" must be a valid string encoding');var i=0|Gi(t,a);e=Oi(e,i);var n=e.write(t,a);n!==i&&(e=e.slice(0,n));return e}(e,t,a):function(e,t){if(Hi(t)){var a=0|Yi(t.length);return 0===(e=Oi(e,a)).length||t.copy(e,0,0,a),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(i=t.length)!=i?Oi(e,0):Wi(e,t);if("Buffer"===t.type&&Li(t.data))return Wi(e,t.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function ji(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function zi(e,t){if(ji(t),e=Oi(e,t<0?0:0|Yi(t)),!$i.TYPED_ARRAY_SUPPORT)for(var a=0;a<t;++a)e[a]=0;return e}function Wi(e,t){var a=t.length<0?0:0|Yi(t.length);e=Oi(e,a);for(var i=0;i<a;i+=1)e[i]=255&t[i];return e}function Yi(e){if(e>=Bi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Bi().toString(16)+" bytes");return 0|e}function Hi(e){return!(null==e||!e._isBuffer)}function Gi(e,t){if(Hi(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var a=e.length;if(0===a)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":case void 0:return _n(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return An(e).length;default:if(i)return _n(e).length;t=(""+t).toLowerCase(),i=!0}}function qi(e,t,a){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),a<=0)return"";if((a>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return cn(this,t,a);case"utf8":case"utf-8":return sn(this,t,a);case"ascii":return ln(this,t,a);case"latin1":case"binary":return un(this,t,a);case"base64":return rn(this,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dn(this,t,a);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function Zi(e,t,a){var i=e[t];e[t]=e[a],e[a]=i}function Ji(e,t,a,i,n){if(0===e.length)return-1;if("string"==typeof a?(i=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,isNaN(a)&&(a=n?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(n)return-1;a=e.length-1}else if(a<0){if(!n)return-1;a=0}if("string"==typeof t&&(t=$i.from(t,i)),Hi(t))return 0===t.length?-1:Ki(e,t,a,i,n);if("number"==typeof t)return t&=255,$i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,a):Uint8Array.prototype.lastIndexOf.call(e,t,a):Ki(e,[t],a,i,n);throw new TypeError("val must be string, number or Buffer")}function Ki(e,t,a,i,n){var r,s=1,o=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,o/=2,l/=2,a/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var c=-1;for(r=a;r<o;r++)if(u(e,r)===u(t,-1===c?0:r-c)){if(-1===c&&(c=r),r-c+1===l)return c*s}else-1!==c&&(r-=r-c),c=-1}else for(a+l>o&&(a=o-l),r=a;r>=0;r--){for(var d=!0,p=0;p<l;p++)if(u(e,r+p)!==u(t,p)){d=!1;break}if(d)return r}return-1}function Xi(e,t,a,i){a=Number(a)||0;var n=e.length-a;i?(i=Number(i))>n&&(i=n):i=n;var r=t.length;if(r%2!=0)throw new TypeError("Invalid hex string");i>r/2&&(i=r/2);for(var s=0;s<i;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[a+s]=o}return s}function Qi(e,t,a,i){return kn(_n(t,e.length-a),e,a,i)}function en(e,t,a,i){return kn(function(e){for(var t=[],a=0;a<e.length;++a)t.push(255&e.charCodeAt(a));return t}(t),e,a,i)}function tn(e,t,a,i){return en(e,t,a,i)}function an(e,t,a,i){return kn(An(t),e,a,i)}function nn(e,t,a,i){return kn(function(e,t){for(var a,i,n,r=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(a=e.charCodeAt(s))>>8,n=a%256,r.push(n),r.push(i);return r}(t,e.length-a),e,a,i)}function rn(e,t,a){return 0===t&&a===e.length?Fi(e):Fi(e.slice(t,a))}function sn(e,t,a){a=Math.min(e.length,a);for(var i=[],n=t;n<a;){var r,s,o,l,u=e[n],c=null,d=u>239?4:u>223?3:u>191?2:1;if(n+d<=a)switch(d){case 1:u<128&&(c=u);break;case 2:128==(192&(r=e[n+1]))&&(l=(31&u)<<6|63&r)>127&&(c=l);break;case 3:r=e[n+1],s=e[n+2],128==(192&r)&&128==(192&s)&&(l=(15&u)<<12|(63&r)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:r=e[n+1],s=e[n+2],o=e[n+3],128==(192&r)&&128==(192&s)&&128==(192&o)&&(l=(15&u)<<18|(63&r)<<12|(63&s)<<6|63&o)>65535&&l<1114112&&(c=l)}null===c?(c=65533,d=1):c>65535&&(c-=65536,i.push(c>>>10&1023|55296),c=56320|1023&c),i.push(c),n+=d}return function(e){var t=e.length;if(t<=on)return String.fromCharCode.apply(String,e);var a="",i=0;for(;i<t;)a+=String.fromCharCode.apply(String,e.slice(i,i+=on));return a}(i)}$i.TYPED_ARRAY_SUPPORT=void 0===Ti.TYPED_ARRAY_SUPPORT||Ti.TYPED_ARRAY_SUPPORT,Bi(),$i.poolSize=8192,$i._augment=function(e){return e.__proto__=$i.prototype,e},$i.from=function(e,t,a){return Ui(null,e,t,a)},$i.TYPED_ARRAY_SUPPORT&&($i.prototype.__proto__=Uint8Array.prototype,$i.__proto__=Uint8Array),$i.alloc=function(e,t,a){return function(e,t,a,i){return ji(t),t<=0?Oi(e,t):void 0!==a?"string"==typeof i?Oi(e,t).fill(a,i):Oi(e,t).fill(a):Oi(e,t)}(null,e,t,a)},$i.allocUnsafe=function(e){return zi(null,e)},$i.allocUnsafeSlow=function(e){return zi(null,e)},$i.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Sn(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Sn(e.slice(0,0))}(e))},$i.compare=function(e,t){if(!Hi(e)||!Hi(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var a=e.length,i=t.length,n=0,r=Math.min(a,i);n<r;++n)if(e[n]!==t[n]){a=e[n],i=t[n];break}return a<i?-1:i<a?1:0},$i.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},$i.concat=function(e,t){if(!Li(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return $i.alloc(0);var a;if(void 0===t)for(t=0,a=0;a<e.length;++a)t+=e[a].length;var i=$i.allocUnsafe(t),n=0;for(a=0;a<e.length;++a){var r=e[a];if(!Hi(r))throw new TypeError('"list" argument must be an Array of Buffers');r.copy(i,n),n+=r.length}return i},$i.byteLength=Gi,$i.prototype._isBuffer=!0,$i.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Zi(this,t,t+1);return this},$i.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Zi(this,t,t+3),Zi(this,t+1,t+2);return this},$i.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Zi(this,t,t+7),Zi(this,t+1,t+6),Zi(this,t+2,t+5),Zi(this,t+3,t+4);return this},$i.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?sn(this,0,e):qi.apply(this,arguments)},$i.prototype.equals=function(e){if(!Hi(e))throw new TypeError("Argument must be a Buffer");return this===e||0===$i.compare(this,e)},$i.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},$i.prototype.compare=function(e,t,a,i,n){if(!Hi(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===a&&(a=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||a>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=a)return 0;if(i>=n)return-1;if(t>=a)return 1;if(this===e)return 0;for(var r=(n>>>=0)-(i>>>=0),s=(a>>>=0)-(t>>>=0),o=Math.min(r,s),l=this.slice(i,n),u=e.slice(t,a),c=0;c<o;++c)if(l[c]!==u[c]){r=l[c],s=u[c];break}return r<s?-1:s<r?1:0},$i.prototype.includes=function(e,t,a){return-1!==this.indexOf(e,t,a)},$i.prototype.indexOf=function(e,t,a){return Ji(this,e,t,a,!0)},$i.prototype.lastIndexOf=function(e,t,a){return Ji(this,e,t,a,!1)},$i.prototype.write=function(e,t,a,i){if(void 0===t)i="utf8",a=this.length,t=0;else if(void 0===a&&"string"==typeof t)i=t,a=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(a)?(a|=0,void 0===i&&(i="utf8")):(i=a,a=void 0)}var n=this.length-t;if((void 0===a||a>n)&&(a=n),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return Xi(this,e,t,a);case"utf8":case"utf-8":return Qi(this,e,t,a);case"ascii":return en(this,e,t,a);case"latin1":case"binary":return tn(this,e,t,a);case"base64":return an(this,e,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nn(this,e,t,a);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},$i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var on=4096;function ln(e,t,a){var i="";a=Math.min(e.length,a);for(var n=t;n<a;++n)i+=String.fromCharCode(127&e[n]);return i}function un(e,t,a){var i="";a=Math.min(e.length,a);for(var n=t;n<a;++n)i+=String.fromCharCode(e[n]);return i}function cn(e,t,a){var i=e.length;(!t||t<0)&&(t=0),(!a||a<0||a>i)&&(a=i);for(var n="",r=t;r<a;++r)n+=wn(e[r]);return n}function dn(e,t,a){for(var i=e.slice(t,a),n="",r=0;r<i.length;r+=2)n+=String.fromCharCode(i[r]+256*i[r+1]);return n}function pn(e,t,a){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>a)throw new RangeError("Trying to access beyond buffer length")}function hn(e,t,a,i,n,r){if(!Hi(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<r)throw new RangeError('"value" argument is out of bounds');if(a+i>e.length)throw new RangeError("Index out of range")}function fn(e,t,a,i){t<0&&(t=65535+t+1);for(var n=0,r=Math.min(e.length-a,2);n<r;++n)e[a+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function mn(e,t,a,i){t<0&&(t=4294967295+t+1);for(var n=0,r=Math.min(e.length-a,4);n<r;++n)e[a+n]=t>>>8*(i?n:3-n)&255}function yn(e,t,a,i,n,r){if(a+i>e.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function gn(e,t,a,i,n){return n||yn(e,0,a,4),Ri(e,t,a,i,23,4),a+4}function bn(e,t,a,i,n){return n||yn(e,0,a,8),Ri(e,t,a,i,52,8),a+8}$i.prototype.slice=function(e,t){var a,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e),$i.TYPED_ARRAY_SUPPORT)(a=this.subarray(e,t)).__proto__=$i.prototype;else{var n=t-e;a=new $i(n,void 0);for(var r=0;r<n;++r)a[r]=this[r+e]}return a},$i.prototype.readUIntLE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=this[e],n=1,r=0;++r<t&&(n*=256);)i+=this[e+r]*n;return i},$i.prototype.readUIntBE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},$i.prototype.readUInt8=function(e,t){return t||pn(e,1,this.length),this[e]},$i.prototype.readUInt16LE=function(e,t){return t||pn(e,2,this.length),this[e]|this[e+1]<<8},$i.prototype.readUInt16BE=function(e,t){return t||pn(e,2,this.length),this[e]<<8|this[e+1]},$i.prototype.readUInt32LE=function(e,t){return t||pn(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},$i.prototype.readUInt32BE=function(e,t){return t||pn(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},$i.prototype.readIntLE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=this[e],n=1,r=0;++r<t&&(n*=256);)i+=this[e+r]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},$i.prototype.readIntBE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=t,n=1,r=this[e+--i];i>0&&(n*=256);)r+=this[e+--i]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},$i.prototype.readInt8=function(e,t){return t||pn(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},$i.prototype.readInt16LE=function(e,t){t||pn(e,2,this.length);var a=this[e]|this[e+1]<<8;return 32768&a?4294901760|a:a},$i.prototype.readInt16BE=function(e,t){t||pn(e,2,this.length);var a=this[e+1]|this[e]<<8;return 32768&a?4294901760|a:a},$i.prototype.readInt32LE=function(e,t){return t||pn(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},$i.prototype.readInt32BE=function(e,t){return t||pn(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},$i.prototype.readFloatLE=function(e,t){return t||pn(e,4,this.length),Di(this,e,!0,23,4)},$i.prototype.readFloatBE=function(e,t){return t||pn(e,4,this.length),Di(this,e,!1,23,4)},$i.prototype.readDoubleLE=function(e,t){return t||pn(e,8,this.length),Di(this,e,!0,52,8)},$i.prototype.readDoubleBE=function(e,t){return t||pn(e,8,this.length),Di(this,e,!1,52,8)},$i.prototype.writeUIntLE=function(e,t,a,i){(e=+e,t|=0,a|=0,i)||hn(this,e,t,a,Math.pow(2,8*a)-1,0);var n=1,r=0;for(this[t]=255&e;++r<a&&(n*=256);)this[t+r]=e/n&255;return t+a},$i.prototype.writeUIntBE=function(e,t,a,i){(e=+e,t|=0,a|=0,i)||hn(this,e,t,a,Math.pow(2,8*a)-1,0);var n=a-1,r=1;for(this[t+n]=255&e;--n>=0&&(r*=256);)this[t+n]=e/r&255;return t+a},$i.prototype.writeUInt8=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,1,255,0),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},$i.prototype.writeUInt16LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):fn(this,e,t,!0),t+2},$i.prototype.writeUInt16BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):fn(this,e,t,!1),t+2},$i.prototype.writeUInt32LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):mn(this,e,t,!0),t+4},$i.prototype.writeUInt32BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):mn(this,e,t,!1),t+4},$i.prototype.writeIntLE=function(e,t,a,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*a-1);hn(this,e,t,a,n-1,-n)}var r=0,s=1,o=0;for(this[t]=255&e;++r<a&&(s*=256);)e<0&&0===o&&0!==this[t+r-1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+a},$i.prototype.writeIntBE=function(e,t,a,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*a-1);hn(this,e,t,a,n-1,-n)}var r=a-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+a},$i.prototype.writeInt8=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,1,127,-128),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},$i.prototype.writeInt16LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):fn(this,e,t,!0),t+2},$i.prototype.writeInt16BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):fn(this,e,t,!1),t+2},$i.prototype.writeInt32LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,2147483647,-2147483648),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):mn(this,e,t,!0),t+4},$i.prototype.writeInt32BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):mn(this,e,t,!1),t+4},$i.prototype.writeFloatLE=function(e,t,a){return gn(this,e,t,!0,a)},$i.prototype.writeFloatBE=function(e,t,a){return gn(this,e,t,!1,a)},$i.prototype.writeDoubleLE=function(e,t,a){return bn(this,e,t,!0,a)},$i.prototype.writeDoubleBE=function(e,t,a){return bn(this,e,t,!1,a)},$i.prototype.copy=function(e,t,a,i){if(a||(a=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<a&&(i=a),i===a)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-a&&(i=e.length-t+a);var n,r=i-a;if(this===e&&a<t&&t<i)for(n=r-1;n>=0;--n)e[n+t]=this[n+a];else if(r<1e3||!$i.TYPED_ARRAY_SUPPORT)for(n=0;n<r;++n)e[n+t]=this[n+a];else Uint8Array.prototype.set.call(e,this.subarray(a,a+r),t);return r},$i.prototype.fill=function(e,t,a,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,a=this.length):"string"==typeof a&&(i=a,a=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!$i.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<a)throw new RangeError("Out of range index");if(a<=t)return this;var r;if(t>>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(r=t;r<a;++r)this[r]=e;else{var s=Hi(e)?e:_n(new $i(e,i).toString()),o=s.length;for(r=0;r<a-t;++r)this[r+t]=s[r%o]}return this};var vn=/[^+\/0-9A-Za-z-_]/g;function wn(e){return e<16?"0"+e.toString(16):e.toString(16)}function _n(e,t){var a;t=t||1/0;for(var i=e.length,n=null,r=[],s=0;s<i;++s){if((a=e.charCodeAt(s))>55295&&a<57344){if(!n){if(a>56319){(t-=3)>-1&&r.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&r.push(239,191,189);continue}n=a;continue}if(a<56320){(t-=3)>-1&&r.push(239,191,189),n=a;continue}a=65536+(n-55296<<10|a-56320)}else n&&(t-=3)>-1&&r.push(239,191,189);if(n=null,a<128){if((t-=1)<0)break;r.push(a)}else if(a<2048){if((t-=2)<0)break;r.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;r.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;r.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return r}function An(e){return function(e){var t,a,i,n,r,s;Vi||Ii();var o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");r="="===e[o-2]?2:"="===e[o-1]?1:0,s=new Ci(3*o/4-r),i=r>0?o-4:o;var l=0;for(t=0,a=0;t<i;t+=4,a+=3)n=xi[e.charCodeAt(t)]<<18|xi[e.charCodeAt(t+1)]<<12|xi[e.charCodeAt(t+2)]<<6|xi[e.charCodeAt(t+3)],s[l++]=n>>16&255,s[l++]=n>>8&255,s[l++]=255&n;return 2===r?(n=xi[e.charCodeAt(t)]<<2|xi[e.charCodeAt(t+1)]>>4,s[l++]=255&n):1===r&&(n=xi[e.charCodeAt(t)]<<10|xi[e.charCodeAt(t+1)]<<4|xi[e.charCodeAt(t+2)]>>2,s[l++]=n>>8&255,s[l++]=255&n),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(vn,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function kn(e,t,a,i){for(var n=0;n<i&&!(n+a>=t.length||n>=e.length);++n)t[n+a]=e[n];return n}function Sn(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}const Nn={files:{},items:{},folders:{}};function Tn(e){return Nn.files[e]}function Mn(){return Nn.folders}function xn(e){return Nn.folders[e]}function Cn(e,t){for(const a of Object.values(Nn.folders))if(a.name===e&&a.parent===t)return a}function Vn(e,t){for(const a of Object.values(Nn.items))if(a.name===e&&a.folder._id===t)return a}function In(){return Nn.items}function En(e){return Nn.items[e]}function Fn(e,t){Nn.items[e]=t.rootItem;for(const[e,a]of Object.entries(t.metadata)){if(t.files[e]&&(Nn.files[e]={blob:new Blob([t.files[e]],{type:a.mimeType}),hash:a.hash,itemName:a.name,itemType:a.type,mimeType:a.mimeType}),a.attachments)for(const i of a.attachments){const a=Rn(e,i.name,i.queryParam,i.index);Nn.files[a]={blob:new Blob([t.files[a]],{type:i.mimeType}),hash:i.hash,itemName:i.name,itemType:i.type,mimeType:i.mimeType}}Nn.items[e]=a}for(const a of Object.values(t.folders))a._id=e+":"+a._id,a.parent=e+":"+a.parent,Nn.folders[a._id]=a}async function Dn(e,t){const a=$i.from(await e.arrayBuffer());let i=0;i+=8;const n=a.readInt32LE(8);i+=4;const r=new TextDecoder,s=a.subarray(i,i+n);i+=n;const o=JSON.parse(r.decode(s));o.root=t+"/"+o.root;let l=0;const u=Ni.ungzip(a.subarray(i)),c=$i.from(u),d=c.subarray(l,l+o.metadataSize);l+=o.metadataSize;const p=JSON.parse(r.decode(d)),h={};Object.entries(p).forEach((([e,a])=>{const i=t+"/"+e;a._id=i,h[i]=a,a.folder._id=t+":"+a.folder._id;for(const e of a.links)e.to=t+"/"+e.to}));const f=c.subarray(l,l+o.foldersSize);l+=o.foldersSize;const m=JSON.parse(r.decode(f)),y={};for(const[,e]of Object.entries(h))if(e.filesize&&(y[e._id]={start:l+(e.packageFileOffset||0),end:l+(e.packageFileOffset||0)+e.filesize}),e.attachments)for(const t of e.attachments)y[Rn(e._id,t.name,t.queryParam,t.index)]={start:l+(t.packageFileOffset||0),end:l+(t.packageFileOffset||0)+t.filesize};const g={};for(const[e,t]of Object.entries(y)){const a=c.subarray(t.start,t.end);g[e]=a}const b=h[o.root],v=[],w=e=>{v.push(e._id);for(const t of e.links)t.item=structuredClone(h[t.to]),w(t.item)};return w(b),{rootItem:b,metadata:h,folders:m,files:g}}function Rn(e,t,a,i){return`${e}_${t}`+(null!=a?`_${a}`:"")+(null!=i?`_${i}`:"")}function Pn(e,t,a,i){return Array.isArray(e.attachments)?e.attachments.filter((e=>e.name===t&&(void 0===i||e.index===i))).reduce(((e,t)=>Math.abs(t.queryParam-(a??0))<Math.abs(e.queryParam-(a??0))?t:e),{queryParam:1/0}):null}function Ln(e,t,a,i){const n=En(e);if(n){const r=Pn(n,t,a,i);if(!r)return null;return Tn(Rn(e,r.name,r.queryParam,r.index))}}var Bn=Object.freeze({__proto__:null,addPackageToCache:Fn,createAttachmentID:Rn,findFolder:Cn,findItem:Vn,getAttachmentFromPackageCache:Ln,getFileFromCache:Tn,getFolder:xn,getFolders:Mn,getItemFromCache:En,getItems:In,parsePackage:Dn,queryAttachments:Pn});class On{id=h.createGUID();items=[]}class $n{itemRepo;undoEvents=[];redoEvents=[];maxUndoCount=100;enabled=!0;snapshots=new Map;_undoRedoPromise=Promise.resolve();constructor(e,t=100){this.itemRepo=e,this.maxUndoCount=t,g.instance.setUndoManager(this),u.$on("undoManager:undo",(e=>this.undo(e))),u.$on("undoManager:redo",(e=>this.redo(e)))}clear(){this.undoEvents=[],this.redoEvents=[],this.snapshots.clear(),u.$emit("undoManager:undoStepsChanged",0),u.$emit("undoManager:redoStepsChanged",0)}createSnapshot(){const e=new On;for(const t of this.itemRepo.itemInstances.values())for(const a of t.values())e.items.push({_id:a._id,instanceId:a.instanceId,data:this._grabSnapshot(a)});return this.snapshots.set(e.id,e),e.id}rollbackFromSnapshot(e){const t=this.snapshots.get(e);if(!t)throw new _("Snapshot not found");for(const e of t.items){const t=this.itemRepo.itemInstances.get(e._id);if(t){const a=t.get(e.instanceId);a?this._rollbackFromSnapshot(a,e.data):console.error(`[SNAPSHOT] - Trying to rollback snapshot for item but did not find the instance: ${e._id} -> ${e.instanceId}`)}else console.error(`[SNAPSHOT] - Trying to rollback snapshot for item but did not find the item map: ${e._id}`)}this.snapshots.delete(e)}_grabSnapshot(e){const t=[];for(const a of e.fieldInstances)try{t.push(a.createSnapshot())}catch(e){const t=`[SNAPSHOT] - Could not grab snapshot of field ${a.name}`;throw console.error(t,e),new Error(e.toString())}const a=[];for(const t of e.customFieldInstances)try{a.push(t.createSnapshot())}catch(e){const a=`[SNAPSHOT] - Could not grab snapshot of custom field ${t.name}`;throw console.error(a,e),new Error(e.toString())}return new O(e._id,"item",{fieldInstances:t,customFieldInstances:a})}_getFieldInstance(e,t){for(const a of e.fieldInstances)if(a.getId()===t)return a;return null}_getCustomFieldInstance(e,t){for(const a of e.customFieldInstances)if(a.getId()===t)return a;return null}_rollbackFromSnapshot(e,t){for(const a of t.data.fieldInstances){const t=this._getFieldInstance(e,a.id);t?t.rollbackFromSnapshot(a):console.warn("[SNAPSHOT] - Could not find field instance in snapshot: "+a.id)}for(const a of t.data.customFieldInstances){const t=this._getCustomFieldInstance(e,a.id);t?t.rollbackFromSnapshot(a):console.warn("[SNAPSHOT] - Could not find custom field instance in snapshot: "+a.id)}}getEnabled(){return this.enabled}setEnabled(e){this.enabled=!!e}ignore(e){const t=this.enabled;let a=!1;try{t&&this.setEnabled(!1);const i=e();if(i&&i.then)return a=!0,i.finally((()=>{t&&this.setEnabled(!0)}))}finally{t&&!a&&this.setEnabled(!0)}}undo(e){return this._undoRedoPromise=this._undoRedoPromise.then((()=>this._performUndo(e))),this._undoRedoPromise}redo(e){return this._undoRedoPromise=this._undoRedoPromise.then((()=>this._performRedo(e))),this._undoRedoPromise}async _performUndo(e){if(this.enabled&&this.undoEvents.length){for(e=e||1;this.undoEvents.length>0&&e>0;){const t=this.spliceLastEventBundle(this.undoEvents).reverse();for(const e of t)await e.undo(),this.redoEvents.push(e);e--}u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles()),u.$emit("undoManager:redoStepsChanged",this.getNumberOfRedoBundles())}}async _performRedo(e){if(this.enabled&&this.redoEvents.length){for(e=e||1;this.redoEvents.length>0&&e>0;){const t=this.spliceLastEventBundle(this.redoEvents).reverse();for(const e of t)await e.redo(),this.undoEvents.push(e);e--}u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles()),u.$emit("undoManager:redoStepsChanged",this.getNumberOfRedoBundles())}}getUndoSteps(){return this.undoEvents.map((function(e){return{type:e.type,itemId:e.itemId,prop:e.prop}}))}getRedoSteps(){return this.redoEvents.map((e=>({type:e.type,itemId:e.itemId,prop:e.prop})))}event(e){if(this.enabled){if(this.redoEvents=[],u.$emit("undoManager:redoStepsChanged",0),this.assignBundleIndexToEvent(e),0!==this.undoEvents.length){let t=!1;for(let a=this.undoEvents.length-1;a>=0;a--){const i=this.undoEvents[a];if(!e.isWithinMergeDeltaOf(i,300))break;const n=i.merge(e,300);if(n){t=!0,this.undoEvents.splice(a,1),this.undoEvents.push(n);break}}t||(this.undoEvents.push(e),u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles()))}else this.undoEvents.push(e),u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles());if(this.getNumberOfUndoBundles()>this.maxUndoCount){this.spliceFirstEventBundle(this.undoEvents);for(const e of this.undoEvents)e.bundleIndex-=1;u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles())}}}getNumberOfUndoBundles(){return 0===this.undoEvents.length?0:this.undoEvents.at(-1).bundleIndex+1}getNumberOfRedoBundles(){if(0===this.redoEvents.length)return 0;const e=this.getNumberOfUndoBundles()-1;return this.redoEvents.at(0).bundleIndex-e}spliceLastEventBundle(e){if(0===e.length)return[];const t=e.at(-1).bundleIndex;let a=e.length-1;for(let i=e.length-1;i>=0&&e[i].bundleIndex===t;i--)a=i;return e.splice(a)}spliceFirstEventBundle(e){if(0===e.length)return[];const t=e.at(0).bundleIndex;for(let a=1;a<e.length;a++)if(e[a].bundleIndex!==t)return e.splice(0,a);return e.splice(0)}assignBundleIndexToEvent(e){if(0===this.undoEvents.length)return void(e.bundleIndex=0);const t=this.undoEvents.at(-1),a=Math.abs(e.createdAt-t.createdAt);e.bundleIndex=a>300?t.bundleIndex+1:t.bundleIndex}}class Un{updateItemLinksAndAttributes(e,t,a){try{const i=[],n={},r={};this.getLinksAndAttributes(e,i,n,r,t,a),e.attributes=n,e.userAttributes=r,e.links=i}catch(e){throw console.error(e),new k(e)}}getLinksAndAttributes(e,t,a,i,n,r){e.fieldInstances.length&&this.retrieveLinksAndAttributesFromFieldInstances(e.fieldInstances,t,a,n,r),e.userFieldInstances.length&&this.retrieveLinksAndAttributesFromFieldInstances(e.userFieldInstances,t,i,n,r),e.customFieldInstances.length&&(console.log(e.customFieldInstances),this.retrieveLinksAndAttributesFromFieldInstances(e.customFieldInstances,t,i,n,r,"_"))}retrieveLinksAndAttributesFromFieldInstances(e,t,a,i,n,r=""){for(const s of e)switch(s.type){case"Link":if(s.value&&t){if(n&&s.hidden)continue;i?t.push({usage:r+s.name,to:s.value._id,item:s.value}):t.push({usage:r+s.name,to:s.value._id})}break;case"Attribute":a&&(a[r+s.name]=s.value);break;case"List":s.blocks&&this.traverseListFieldInstances(s.blocks,t,a,r+s.name,i);break;case"Tree":if(s.blocks){const e=s.blocks[0];e.blocks&&this.traverseTreeFieldInstance(e.blocks,t,a,r+s.name,i)}break;case"NodeGraph":if(s.blocks&&this.traverseTreeFieldInstance(s.blocks,t,a,r+s.name,i),a&&Array.isArray(s.connections)){let e=0;for(const t of s.connections){a[`${r}${s.name}#connection[${e++}]`]={srcNode:t.srcNode,srcSlot:t.srcSlot,destNode:t.destNode,destSlot:t.destSlot}}}}}traverseTreeFieldInstance(e,t,a,i,n){let r=0;for(const s of e){const e=`${i}[${r}]`,o=e+"#type",l=e+"#id",u=e+"#posx",c=e+"#posy";a&&(a[e+"#usage"]="Block",a[o]=s.type,a[l]=s.id,void 0!==s.posX&&(a[u]=s.posX||0),void 0!==s.posY&&(a[c]=s.posY||0));for(const i of s.fields){const r=`${e}->${i.name}`;switch(i.type){case"Link":i.value&&t&&(n?t.push({usage:r,to:i.value._id,item:i.value}):t.push({usage:r,to:i.value._id}));break;case"List":i.blocks&&this.traverseListFieldInstances(i.blocks,t,a,r,n);break;case"Attribute":a&&(a[r]=i.value)}}s.scripts&&this.processScripts(s.scripts,t,a,e,n),s.blocks&&this.traverseTreeFieldInstance(s.blocks,t,a,e,n),r++}}traverseListFieldInstances(e,t,a,i,n){let r=0;for(const s of e){const e=`${i}[${r}]`;for(const i of s.fields){const r=`${e}->${i.name}`;switch(i.type){case"Link":if(i.value&&t){const e={usage:r,to:"object"==typeof i.value?i.value._id:i.value,item:null};n&&"object"===i.value&&(e.item=i.value),t.push(e)}break;case"Attribute":a&&(a[r]=i.value)}}r++}}processScripts(e,t,a,i,n){let r=0;for(const s of e){const e=`${i}#scripts[${r}]`,o=e+"#id",l=e+"#item";a&&(a[e+"#usage"]="Script",a[o]=s.id),t&&s.item.value&&(n?t.push({usage:l,to:s.item.value._id,item:s.item.value}):t.push({usage:l,to:s.item.value._id}));for(const i of s.fields){const r=`${e}->${i.name}`;if("Link"===i.type)i.value&&t&&(n?t.push({usage:r,to:i.value._id,item:i.value}):t.push({usage:r,to:i.value._id}));else a&&(a[r]=i.value)}r++}}}class jn{apiClient;activeItem=void 0;rootItemId=void 0;loadingItems=new Map;loadedItems=new Map;itemInstances=new Map;resolvedPaths=new Map;jail;apiGateway;itemCache;undoManager=new $n(this);itemPreparator=new te(this);itemChangeProcessor=new Un;usePublicApi;constructor(e,t){this.apiClient=t,this.apiGateway=new L(t),this.itemCache=new B(this.apiGateway),this.usePublicApi=!!e,this.jail={active:!1,mountedFolders:[]},u.$on("item:rename",(e=>this.handleRename(e)))}_logGroup(e){}_logGroupEnd(){}_log(e){}getLoadedItems(){return Array.from(this.loadedItems.values())}getItemInstances(){return this.itemInstances}findLoadedItem(e){return this.loadedItems.get(e)}_handleError(e,t){throw console.error(e),new k("ItemRepo: "+t)}getUndoManager(){return this.undoManager}async createFieldsForItem(e,t,a,i=!1){return this.itemPreparator.createFields(e,a,t,"",!1,a.attributes,i)}async createScriptsForItem(e,t=[],a,i=!0){const n=[];for(const i of t){if(!i.item)continue;const t=await this.loadItem(i.item);if(!t)continue;const r=new W(void 0,e,a,t);n.push(r);for(const e of i.fields){const t=new j(r,e.name,e.value,a);r.addField(t)}}e.scripts=i?g.instance.proxyScriptArray(n,e,a):n}clear(){this.rootItemId=void 0,this.activeItem=void 0,this.loadedItems.clear(),this.resolvedPaths.clear(),this.itemInstances.clear(),this.loadingItems.clear();this.apiClient.getCollab().endCollaboration()}removeBlock(e,t){t.blocks.removeObject(e),e.parent=void 0}traverseBlockPairs(e,t,a){a(e,t);for(let i=0;i<e.blocks.length&&i<t.blocks.length;i++)this.traverseBlockPairs(e.blocks[i],t.blocks[i],a)}copyScripts(e,t,a=!1){const i=new Map;this.traverseBlockPairs(e,t,((e,t)=>i.set(e.getId(),t.getId())));const n=[];return this.traverseBlockPairs(e,t,((e,t)=>{for(const r of e.scripts){const e=r.clone(i);a&&(e.deferInitCall=!0),t.scripts.push(e),n.push(e)}})),n}updateScriptFieldReferences(e,t){const a=new Map;this.traverseBlockPairs(e,t,((e,t)=>{a.set(e.id,t.id)})),this.updateScriptFieldReferencesFromMap(a,t)}updateScriptFieldReferencesFromMap(e,t){this.traverseBlocks((t=>{for(const a of t.scripts)for(const t of a.fields)e.has(t.value)&&(t.value=e.get(t.value))}),[t])}async createNewBlock(e,t,a){const i=new ae(void 0,t,e.typeName,void 0,void 0,a),n=await this.createFieldsForItem(i,e.template,a);return i.setFields(n),i.blocks=g.instance.proxyBlockArray(i.blocks,i,a),await this.createScriptsForItem(i,void 0,a),this.addBlockToParent(i,t,a)}addBlockToParent(e,t,a){e.parent=t;const i=g.instance.proxyBlock(e,a);return t.blocks.push(i),i}async createNewListEntry(e,t,a){const i=new ae(void 0,void 0,e.typeName,void 0,void 0,a),n=await this.createFieldsForItem(i,e.template,a);return i.setFields(n),i.blocks=g.instance.proxyListArray(i.blocks,t,a),g.instance.proxyBlock(i,a)}async createNewGraphNode(e,t,a,i,n){const r=new ae(void 0,void 0,e.typeName,void 0,e.displayName,n),s=await this.itemPreparator.createFields(r,n,e.template,"",!0,n.attributes);return r.setFields(s),r.setInputs(e.inputs),r.setOutputs(e.outputs),r.setPosition(a,i),r.blocks=g.instance.proxyGraphBlockArray(r.blocks,t),this.addNodeToGraph(r,t,n),r}addNodeToGraph(e,t,a){const i=g.instance.proxyGraphBlock(e,a);t.blocks.push(i)}removeGraphNode(e,t){const a=[];for(const i of e.connections)i.srcNode!==t.id&&i.destNode!==t.id||a.push(i);for(const t of a)e.connections.removeObject(t);e.blocks.removeObject(t)}addGraphLink(e,t,a,i,n,r){e.connections.push(new U({srcNode:t,srcSlot:a,destNode:i,destSlot:n},r))}removeGraphLink(e,t,a,i,n){for(const r of e.connections)if(r.srcNode===t&&r.srcSlot===a&&r.destNode===i&&r.destSlot===n)return void e.connections.removeObject(r)}createNewScript(e,t=-1,a){t=t>=0?t:e.scripts.length;const i=new W(void 0,e,a);return e.scripts.splice(t,0,i),i}removeScript(e,t){t.scripts.removeObject(e)}findBlock(e){for(const t of this.itemInstances.values())for(const a of t.values()){const t=a.findBlock(e);if(t)return t}return null}async loadPackage(e,t){const a=await h.downloadFile(e,((e,a,i)=>{t&&t({phase:"Loading",percent:e,bytesTotal:a,bytesLoaded:i})})),i=await a.data;this.apiClient.getCollab().endCollaboration();const n=new K({_id:"root",name:"Root package",type:"Package",links:[],attributes:{},fields:[],readOnly:!0,isPackaged:!1}),r=await Dn(i,n._id);Fn(n._id,structuredClone(r));const s=Object.values(r.metadata).reverse();for(const e of s)e._id===r.rootItem._id&&(n.packageContent=e,n.packageType=e.type);return await this._linkAndPrepareItems(s),n.packageContent=this.loadedItems.get(r.rootItem._id),this.activeItem=n,n}createPackageItemUrl(e){const t=Tn(e);return t?URL.createObjectURL(t.blob):null}revokePackageItemUrl(e){URL.revokeObjectURL(e)}async _loadPackageContentRecursively(e,t){t("Loading from cache",0);const a=await this.apiClient.itemCache.addItemToCache(e._id,void 0,e.hash,(function(e,a,i){t("Loading from cloud",.9*e,i,a)})),i=await(await fetch(a.objectUrl)).blob();t("Unpacking",90);const n=await Dn(i,e._id);Fn(e._id,structuredClone(n));const r=Object.values(n.metadata).reverse();for(const t of r)t._id===n.rootItem._id&&(e.packageContent=t,e.packageType=t.type);return r}createNewItemInstance(e){const t=this.loadedItems.get(e);if(!t)return console.error(`Tried creating new instance of item, but it was not found: ${e}`),null;const a=t.clone(!0);return this._addItemInstance(a),a}_addLoadedItem(e){this.loadedItems.set(e._id,e),this._addItemInstance(e)}_addItemInstance(e){let t=this.itemInstances.get(e._id);t||(t=new Map,this.itemInstances.set(e._id,t)),t.set(e.instanceId,e)}async loadItemByRelativePath(e,t,a={}){try{const i=En(e);let n;if(i){const e=t.split("/"),a=e.pop();let r=xn(i.folder._id);for(const t of e)if(r=".."===t?xn(r.parent):Cn(t,r._id),!r)return;const s=Vn(a,r._id);n=s?._id}else n=await this.resolveRelativePath(t,e);return this.loadItem(n,a)}catch(e){this._handleError(e,`Unable to load item by relative path: ${t}: ${e}`)}}async _loadItemFromApi(e,t={}){let a;if(this.apiGateway.start(),t.recursive)if(this.usePublicApi)a=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e,!0),a.forEach((e=>e.public=!0));else try{a=await this.apiGateway.call("_loadItemFromApi","getItemAggregatedRecursive",e,{withAttachmentInfo:!0,noFields:!0})}catch{a=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e,!0),a.forEach((e=>e.public=!0))}else{let t;if(this.usePublicApi)t=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e),t.public=!0;else try{t=await this.apiGateway.call("_loadItemFromApi","getItemAggregated",e,{noFields:!0})}catch{t=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e),t.public=!0}a=[t]}return this.apiGateway.end(),a}_relinkItems(e,t){for(const a of e){if(Array.isArray(a.links))for(const e of a.links)e.item=t.get(e.to),e.item||e.stopRecursion||console.warn(`Missing link in item '${a.name}' (${a._id}) to: ${e.to} with usage ${e.usage}`);a.packageContent&&(a.packageContent=t.get(a.packageContent._id))}}createItem(e,t){const a={_id:h.createGeneratedItemId(),name:`Generated ${e}`,type:e,attributes:t||{},links:[],fields:[],fieldInstances:[],userFieldInstances:[],isGenerated:!0};return this.itemPreparator.prepare(a)}getLoadedItem(e){return this.loadedItems.get(e)}async loadItem(e,t={}){let a,i,n;if(n=this.loadedItems.get(e),n)return n;if(n=this.loadingItems.get(e),n)return n;try{const r=new Promise(((e,t)=>{a=e,i=t}));return this.loadingItems.set(e,r),n=await this._loadItemInternal(e,t),a(n),!this.activeItem&&n&&(this.rootItemId=e,this.activeItem=n,t.withCollaboration,await u.$emit("itemRepo:itemLoaded",n)),n}catch(t){return this._handleError(t,`Unable to load item ${e}: ${t}`),void i(void 0)}finally{this.loadingItems.delete(e)}}async _loadItemInternal(e,t={}){const a=(e,a,i=0,n=0)=>{"function"==typeof t.progressCallback&&t.progressCallback({phase:e,percent:a,bytesTotal:i,bytesLoaded:n})};a("Fetching metadata",1);let i=await this._loadItemFromApi(e,t);if(i=i.filter((e=>!this.loadedItems.has(e._id))),0===i.length)return console.log("After loading the item, it turns out we have them all already loaded! This should not happen!"),this.loadedItems.get(e);const n=i[0]._id;for(const e of i)if("Package"===e.type){const t=await this._loadPackageContentRecursively(e,a);for(const e of t)i.push(e)}a("Preparing data",100),await this._linkAndPrepareItems(i);return this.loadedItems.get(n)}async _linkAndPrepareItems(e){const t=new Map;for(const a of e)t.set(a._id,a);const a=new Map([...this.loadedItems,...t]);this._relinkItems(e,a);const i=[],n=()=>{const e=t.values().next().value;return t.delete(e._id),this._log(`- Fetched next item ${e.name} (${e._id})`),e},r=async e=>{this._logGroup(`- Preparing item ${e.name} (${e._id})`);const t=await this.itemPreparator.prepare(e);return i.push(t),this._addLoadedItem(t),this._logGroupEnd(),t};for(this.itemPreparator.setItemFetcher((async e=>{this._logGroup(`- Requesting item ${e.name} (${e._id})`);let a=this.loadedItems.get(e._id);if(a)return this._log("- Already prepared. Returning."),this._logGroupEnd(),a;const i=t.get(e._id);return i?(t.delete(e._id),this._log("- Don't have it yet. Preparing..."),a=await r(i),this._log("- Now prepared. Returning."),this._logGroupEnd(),a):(console.error("ItemFetcher: Could not find requested item: "+e._id,t,this.loadedItems),null)}));t.size>0;){let e=n();await r(e)}return this._relinkItems(i,this.loadedItems),i}async resolveRelativePath(e,t=null){if(!(t=t||this.activeItem?._id||null))return null;const a=`${t}#${e}`;let i;return i=this.resolvedPaths.has(a)?this.resolvedPaths.get(a):this.usePublicApi?await this.apiClient.publicResolveRelativeItem(t,e):await this.apiClient.resolveRelativeItem(t,e),this.resolvedPaths.set(a,i),i}async traverseItems(e,t=void 0){if("function"!=typeof e)return;const a=this,i=new Map;await async function t(n){if(!n)return;if(i.has(n._id))return;i.set(n._id,!0);const r=e(n);if(r&&r.then&&await r,Array.isArray(n.links))for(const e of n.links)if(e.item)await t(e.item);else if(e.to)try{const i=await a.loadItem(e.to);await t(i)}catch{console.warn(`Could not load additional item ${e.to} so cannot traverse it. Probably dead link!`)}}(t||this.activeItem)}async traverseBlocks(e,t){for(const a of t){const t=e(a);t&&t.then&&await t,Array.isArray(a.blocks)&&a.blocks?.length&&await this.traverseBlocks(e,a.blocks)}}async traverseFieldInstances(e,t){const a=this;t=t||this.activeItem?.fieldInstances||[];for(const i of t){const t=e(i);t&&t.then&&await t,Array.isArray(i.blocks)&&await this.traverseBlocks((async function(t){Array.isArray(t.fields)&&t.fields?.length&&await a.traverseFieldInstances(e,t.fields)}),i.blocks)}}async _updateLinkReferences(e,t,a,i){t?await this.traverseItems((async n=>{if(Array.isArray(n.fieldInstances)&&n.fieldInstances.length&&await this.traverseFieldInstances((async a=>{"Link"===a.type&&a.value&&a.value._id===e&&(i&&(a.value=null),a.value=t)}),n.fieldInstances),n.links)for(const r of n.links)r.to===e&&(i&&(r.to=null,r.item=null),r.to=a,r.item=t)})):console.warn(`Aborting link update: Could not load item ${a}`)}async replaceLink(e,t){if(this.getLoadedItem(e)){const a=await this.loadItem(t,{recursive:!0});await this._updateLinkReferences(e,a,t,!1)}}async forceUpdateLink(e){const t=await this.loadItem(e,{recursive:!0});await this._updateLinkReferences(e,t,e,!0)}saveItem(e){return e._id&&e.isDirty?(this.itemChangeProcessor.updateItemLinksAndAttributes(e,!1,!0),e.version||(e.version={major:0,minor:0,revision:1}),this.apiClient.updateItem({_id:e._id,name:e.name,attributes:e.attributes,userAttributes:e.userAttributes,links:e.links,tags:e.tags,contributors:e.contributors,description:e.description,shortDescription:e.shortDescription,categories:e.categories,license:e.license,version:e.version,allowConversation:e.allowConversation,visibility:e.visibility}).then((t=>(JSON.stringify(e.version)===JSON.stringify(t.version)?console.log(`Saved item ${e.name}. New version: ${e.version.major}.${e.version.minor}.${e.version.revision}`):console.log(`Saved item ${e.name}. Version ${e.version.major}.${e.version.minor}.${e.version.revision} -> ${t.version.major}.${t.version.minor}.${t.version.revision}`),t&&t.version&&(e.version=t.version),e.isDirty=!1,this.itemChangeProcessor.updateItemLinksAndAttributes(e,!0,!1),e))).catch((function(t){throw console.error(`Error saving item ${e.name}`,t,e),t}))):null}async save(){console.log("Saving changes in loaded items...");const e=[];for(const t of this.loadedItems.values()){const a=this.saveItem(t);a&&e.push(a)}if(0!==e.length){let t=0;for(const a of e)a.then((function(a){u.$emit("itemRepo:itemSaved",{item:a,progress:++t,total:e.length})}));return Promise.all(e).then((function(){console.log("Saved successfully"),u.$emit("itemRepo:itemsSaved")})).catch((function(e){console.error("Error saving:",e)}))}console.log("No changes detected.")}async existsUnsavedChanges(){if(!this.activeItem)return!1;for(const e of this.loadedItems.values())if(e._id&&e.isDirty)return!0;return!1}handleRename({id:e,newName:t}){for(const a of this.itemInstances.values())for(const i of a.values())i._id===e&&(i.name=t)}isItemKnown(e){return this.loadedItems.has(e)||this.itemInstances.has(e)||this.loadingItems.has(e)}invalidateId(e){this.loadedItems.delete(e),this.itemInstances.delete(e),this.loadingItems.delete(e)}}var zn,Wn={exports:{}};
11
+ */var q=(Y||(Y=1,function(e,t){(function(){var a,i="Expected a function",n="__lodash_hash_undefined__",r="__lodash_placeholder__",s=32,o=128,l=256,u=1/0,c=9007199254740991,d=NaN,p=4294967295,h=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",s],["partialRight",64],["rearg",l]],f="[object Arguments]",m="[object Array]",y="[object Boolean]",g="[object Date]",b="[object Error]",v="[object Function]",w="[object GeneratorFunction]",_="[object Map]",A="[object Number]",k="[object Object]",S="[object Promise]",N="[object RegExp]",T="[object Set]",M="[object String]",x="[object Symbol]",C="[object WeakMap]",I="[object ArrayBuffer]",E="[object DataView]",F="[object Float32Array]",D="[object Float64Array]",R="[object Int8Array]",P="[object Int16Array]",L="[object Int32Array]",B="[object Uint8Array]",O="[object Uint8ClampedArray]",$="[object Uint16Array]",U="[object Uint32Array]",j=/\b__p \+= '';/g,z=/\b(__p \+=) '' \+/g,W=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,G=RegExp(Y.source),q=RegExp(H.source),Z=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,K=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ae=RegExp(te.source),ie=/^\s+/,ne=/\s/,re=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,oe=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ue=/[()=,{}\[\]\/\s]/,ce=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,fe=/^0b[01]+$/i,me=/^\[object .+?Constructor\]$/,ye=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,we=/['\n\r\u2028\u2029\\]/g,_e="\\ud800-\\udfff",Ae="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",ke="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Ne="A-Z\\xc0-\\xd6\\xd8-\\xde",Te="\\ufe0e\\ufe0f",Me="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xe="['’]",Ce="["+_e+"]",Ve="["+Me+"]",Ie="["+Ae+"]",Ee="\\d+",Fe="["+ke+"]",De="["+Se+"]",Re="[^"+_e+Me+Ee+ke+Se+Ne+"]",Pe="\\ud83c[\\udffb-\\udfff]",Le="[^"+_e+"]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",Oe="[\\ud800-\\udbff][\\udc00-\\udfff]",$e="["+Ne+"]",Ue="\\u200d",je="(?:"+De+"|"+Re+")",ze="(?:"+$e+"|"+Re+")",We="(?:['’](?:d|ll|m|re|s|t|ve))?",Ye="(?:['’](?:D|LL|M|RE|S|T|VE))?",He="(?:"+Ie+"|"+Pe+")?",Ge="["+Te+"]?",qe=Ge+He+"(?:"+Ue+"(?:"+[Le,Be,Oe].join("|")+")"+Ge+He+")*",Ze="(?:"+[Fe,Be,Oe].join("|")+")"+qe,Je="(?:"+[Le+Ie+"?",Ie,Be,Oe,Ce].join("|")+")",Ke=RegExp(xe,"g"),Xe=RegExp(Ie,"g"),Qe=RegExp(Pe+"(?="+Pe+")|"+Je+qe,"g"),et=RegExp([$e+"?"+De+"+"+We+"(?="+[Ve,$e,"$"].join("|")+")",ze+"+"+Ye+"(?="+[Ve,$e+je,"$"].join("|")+")",$e+"?"+je+"+"+We,$e+"+"+Ye,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ee,Ze].join("|"),"g"),tt=RegExp("["+Ue+_e+Ae+Te+"]"),at=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,it=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],nt=-1,rt={};rt[F]=rt[D]=rt[R]=rt[P]=rt[L]=rt[B]=rt[O]=rt[$]=rt[U]=!0,rt[f]=rt[m]=rt[I]=rt[y]=rt[E]=rt[g]=rt[b]=rt[v]=rt[_]=rt[A]=rt[k]=rt[N]=rt[T]=rt[M]=rt[C]=!1;var st={};st[f]=st[m]=st[I]=st[E]=st[y]=st[g]=st[F]=st[D]=st[R]=st[P]=st[L]=st[_]=st[A]=st[k]=st[N]=st[T]=st[M]=st[x]=st[B]=st[O]=st[$]=st[U]=!0,st[b]=st[v]=st[C]=!1;var ot={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lt=parseFloat,ut=parseInt,ct="object"==typeof V&&V&&V.Object===Object&&V,dt="object"==typeof self&&self&&self.Object===Object&&self,pt=ct||dt||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,mt=ft&&ft.exports===ht,yt=mt&&ct.process,gt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||yt&&yt.binding&&yt.binding("util")}catch(e){}}(),bt=gt&&gt.isArrayBuffer,vt=gt&&gt.isDate,wt=gt&&gt.isMap,_t=gt&&gt.isRegExp,At=gt&&gt.isSet,kt=gt&&gt.isTypedArray;function St(e,t,a){switch(a.length){case 0:return e.call(t);case 1:return e.call(t,a[0]);case 2:return e.call(t,a[0],a[1]);case 3:return e.call(t,a[0],a[1],a[2])}return e.apply(t,a)}function Nt(e,t,a,i){for(var n=-1,r=null==e?0:e.length;++n<r;){var s=e[n];t(i,s,a(s),e)}return i}function Tt(e,t){for(var a=-1,i=null==e?0:e.length;++a<i&&!1!==t(e[a],a,e););return e}function Mt(e,t){for(var a=null==e?0:e.length;a--&&!1!==t(e[a],a,e););return e}function xt(e,t){for(var a=-1,i=null==e?0:e.length;++a<i;)if(!t(e[a],a,e))return!1;return!0}function Ct(e,t){for(var a=-1,i=null==e?0:e.length,n=0,r=[];++a<i;){var s=e[a];t(s,a,e)&&(r[n++]=s)}return r}function Vt(e,t){return!(null==e||!e.length)&&$t(e,t,0)>-1}function It(e,t,a){for(var i=-1,n=null==e?0:e.length;++i<n;)if(a(t,e[i]))return!0;return!1}function Et(e,t){for(var a=-1,i=null==e?0:e.length,n=Array(i);++a<i;)n[a]=t(e[a],a,e);return n}function Ft(e,t){for(var a=-1,i=t.length,n=e.length;++a<i;)e[n+a]=t[a];return e}function Dt(e,t,a,i){var n=-1,r=null==e?0:e.length;for(i&&r&&(a=e[++n]);++n<r;)a=t(a,e[n],n,e);return a}function Rt(e,t,a,i){var n=null==e?0:e.length;for(i&&n&&(a=e[--n]);n--;)a=t(a,e[n],n,e);return a}function Pt(e,t){for(var a=-1,i=null==e?0:e.length;++a<i;)if(t(e[a],a,e))return!0;return!1}var Lt=Wt("length");function Bt(e,t,a){var i;return a(e,(function(e,a,n){if(t(e,a,n))return i=a,!1})),i}function Ot(e,t,a,i){for(var n=e.length,r=a+(i?1:-1);i?r--:++r<n;)if(t(e[r],r,e))return r;return-1}function $t(e,t,a){return t==t?function(e,t,a){for(var i=a-1,n=e.length;++i<n;)if(e[i]===t)return i;return-1}(e,t,a):Ot(e,jt,a)}function Ut(e,t,a,i){for(var n=a-1,r=e.length;++n<r;)if(i(e[n],t))return n;return-1}function jt(e){return e!=e}function zt(e,t){var a=null==e?0:e.length;return a?Gt(e,t)/a:d}function Wt(e){return function(t){return null==t?a:t[e]}}function Yt(e){return function(t){return null==e?a:e[t]}}function Ht(e,t,a,i,n){return n(e,(function(e,n,r){a=i?(i=!1,e):t(a,e,n,r)})),a}function Gt(e,t){for(var i,n=-1,r=e.length;++n<r;){var s=t(e[n]);s!==a&&(i=i===a?s:i+s)}return i}function qt(e,t){for(var a=-1,i=Array(e);++a<e;)i[a]=t(a);return i}function Zt(e){return e?e.slice(0,pa(e)+1).replace(ie,""):e}function Jt(e){return function(t){return e(t)}}function Kt(e,t){return Et(t,(function(t){return e[t]}))}function Xt(e,t){return e.has(t)}function Qt(e,t){for(var a=-1,i=e.length;++a<i&&$t(t,e[a],0)>-1;);return a}function ea(e,t){for(var a=e.length;a--&&$t(t,e[a],0)>-1;);return a}var ta=Yt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),aa=Yt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ia(e){return"\\"+ot[e]}function na(e){return tt.test(e)}function ra(e){var t=-1,a=Array(e.size);return e.forEach((function(e,i){a[++t]=[i,e]})),a}function sa(e,t){return function(a){return e(t(a))}}function oa(e,t){for(var a=-1,i=e.length,n=0,s=[];++a<i;){var o=e[a];o!==t&&o!==r||(e[a]=r,s[n++]=a)}return s}function la(e){var t=-1,a=Array(e.size);return e.forEach((function(e){a[++t]=e})),a}function ua(e){var t=-1,a=Array(e.size);return e.forEach((function(e){a[++t]=[e,e]})),a}function ca(e){return na(e)?function(e){for(var t=Qe.lastIndex=0;Qe.test(e);)++t;return t}(e):Lt(e)}function da(e){return na(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.split("")}(e)}function pa(e){for(var t=e.length;t--&&ne.test(e.charAt(t)););return t}var ha=Yt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),fa=function e(t){var V,ne=(t=null==t?pt:fa.defaults(pt.Object(),t,fa.pick(pt,it))).Array,_e=t.Date,Ae=t.Error,ke=t.Function,Se=t.Math,Ne=t.Object,Te=t.RegExp,Me=t.String,xe=t.TypeError,Ce=ne.prototype,Ve=ke.prototype,Ie=Ne.prototype,Ee=t["__core-js_shared__"],Fe=Ve.toString,De=Ie.hasOwnProperty,Re=0,Pe=(V=/[^.]+$/.exec(Ee&&Ee.keys&&Ee.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Le=Ie.toString,Be=Fe.call(Ne),Oe=pt._,$e=Te("^"+Fe.call(De).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=mt?t.Buffer:a,je=t.Symbol,ze=t.Uint8Array,We=Ue?Ue.allocUnsafe:a,Ye=sa(Ne.getPrototypeOf,Ne),He=Ne.create,Ge=Ie.propertyIsEnumerable,qe=Ce.splice,Ze=je?je.isConcatSpreadable:a,Je=je?je.iterator:a,Qe=je?je.toStringTag:a,tt=function(){try{var e=cr(Ne,"defineProperty");return e({},"",{}),e}catch(e){}}(),ot=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,ct=_e&&_e.now!==pt.Date.now&&_e.now,dt=t.setTimeout!==pt.setTimeout&&t.setTimeout,ht=Se.ceil,ft=Se.floor,yt=Ne.getOwnPropertySymbols,gt=Ue?Ue.isBuffer:a,Lt=t.isFinite,Yt=Ce.join,ma=sa(Ne.keys,Ne),ya=Se.max,ga=Se.min,ba=_e.now,va=t.parseInt,wa=Se.random,_a=Ce.reverse,Aa=cr(t,"DataView"),ka=cr(t,"Map"),Sa=cr(t,"Promise"),Na=cr(t,"Set"),Ta=cr(t,"WeakMap"),Ma=cr(Ne,"create"),xa=Ta&&new Ta,Ca={},Va=Pr(Aa),Ia=Pr(ka),Ea=Pr(Sa),Fa=Pr(Na),Da=Pr(Ta),Ra=je?je.prototype:a,Pa=Ra?Ra.valueOf:a,La=Ra?Ra.toString:a;function Ba(e){if(Qs(e)&&!js(e)&&!(e instanceof ja)){if(e instanceof Ua)return e;if(De.call(e,"__wrapped__"))return Lr(e)}return new Ua(e)}var Oa=function(){function e(){}return function(t){if(!Xs(t))return{};if(He)return He(t);e.prototype=t;var i=new e;return e.prototype=a,i}}();function $a(){}function Ua(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=a}function ja(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function za(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var i=e[t];this.set(i[0],i[1])}}function Wa(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var i=e[t];this.set(i[0],i[1])}}function Ya(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var i=e[t];this.set(i[0],i[1])}}function Ha(e){var t=-1,a=null==e?0:e.length;for(this.__data__=new Ya;++t<a;)this.add(e[t])}function Ga(e){var t=this.__data__=new Wa(e);this.size=t.size}function qa(e,t){var a=js(e),i=!a&&Us(e),n=!a&&!i&&Hs(e),r=!a&&!i&&!n&&oo(e),s=a||i||n||r,o=s?qt(e.length,Me):[],l=o.length;for(var u in e)!t&&!De.call(e,u)||s&&("length"==u||n&&("offset"==u||"parent"==u)||r&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gr(u,l))||o.push(u);return o}function Za(e){var t=e.length;return t?e[Hi(0,t-1)]:a}function Ja(e,t){return Fr(xn(e),ri(t,0,e.length))}function Ka(e){return Fr(xn(e))}function Xa(e,t,i){(i!==a&&!Bs(e[t],i)||i===a&&!(t in e))&&ii(e,t,i)}function Qa(e,t,i){var n=e[t];De.call(e,t)&&Bs(n,i)&&(i!==a||t in e)||ii(e,t,i)}function ei(e,t){for(var a=e.length;a--;)if(Bs(e[a][0],t))return a;return-1}function ti(e,t,a,i){return ci(e,(function(e,n,r){t(i,e,a(e),r)})),i}function ai(e,t){return e&&Cn(t,Vo(t),e)}function ii(e,t,a){"__proto__"==t&&tt?tt(e,t,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[t]=a}function ni(e,t){for(var i=-1,n=t.length,r=ne(n),s=null==e;++i<n;)r[i]=s?a:No(e,t[i]);return r}function ri(e,t,i){return e==e&&(i!==a&&(e=e<=i?e:i),t!==a&&(e=e>=t?e:t)),e}function si(e,t,i,n,r,s){var o,l=1&t,u=2&t,c=4&t;if(i&&(o=r?i(e,n,r,s):i(e)),o!==a)return o;if(!Xs(e))return e;var d=js(e);if(d){if(o=function(e){var t=e.length,a=new e.constructor(t);return t&&"string"==typeof e[0]&&De.call(e,"index")&&(a.index=e.index,a.input=e.input),a}(e),!l)return xn(e,o)}else{var p=hr(e),h=p==v||p==w;if(Hs(e))return An(e,l);if(p==k||p==f||h&&!r){if(o=u||h?{}:mr(e),!l)return u?function(e,t){return Cn(e,pr(e),t)}(e,function(e,t){return e&&Cn(t,Io(t),e)}(o,e)):function(e,t){return Cn(e,dr(e),t)}(e,ai(o,e))}else{if(!st[p])return r?e:{};o=function(e,t,a){var i,n=e.constructor;switch(t){case I:return kn(e);case y:case g:return new n(+e);case E:return function(e,t){var a=t?kn(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.byteLength)}(e,a);case F:case D:case R:case P:case L:case B:case O:case $:case U:return Sn(e,a);case _:return new n;case A:case M:return new n(e);case N:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case T:return new n;case x:return i=e,Pa?Ne(Pa.call(i)):{}}}(e,p,l)}}s||(s=new Ga);var m=s.get(e);if(m)return m;s.set(e,o),no(e)?e.forEach((function(a){o.add(si(a,t,i,a,e,s))})):eo(e)&&e.forEach((function(a,n){o.set(n,si(a,t,i,n,e,s))}));var b=d?a:(c?u?ir:ar:u?Io:Vo)(e);return Tt(b||e,(function(a,n){b&&(a=e[n=a]),Qa(o,n,si(a,t,i,n,e,s))})),o}function oi(e,t,i){var n=i.length;if(null==e)return!n;for(e=Ne(e);n--;){var r=i[n],s=t[r],o=e[r];if(o===a&&!(r in e)||!s(o))return!1}return!0}function li(e,t,n){if("function"!=typeof e)throw new xe(i);return Cr((function(){e.apply(a,n)}),t)}function ui(e,t,a,i){var n=-1,r=Vt,s=!0,o=e.length,l=[],u=t.length;if(!o)return l;a&&(t=Et(t,Jt(a))),i?(r=It,s=!1):t.length>=200&&(r=Xt,s=!1,t=new Ha(t));e:for(;++n<o;){var c=e[n],d=null==a?c:a(c);if(c=i||0!==c?c:0,s&&d==d){for(var p=u;p--;)if(t[p]===d)continue e;l.push(c)}else r(t,d,i)||l.push(c)}return l}Ba.templateSettings={escape:Z,evaluate:J,interpolate:K,variable:"",imports:{_:Ba}},Ba.prototype=$a.prototype,Ba.prototype.constructor=Ba,Ua.prototype=Oa($a.prototype),Ua.prototype.constructor=Ua,ja.prototype=Oa($a.prototype),ja.prototype.constructor=ja,za.prototype.clear=function(){this.__data__=Ma?Ma(null):{},this.size=0},za.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},za.prototype.get=function(e){var t=this.__data__;if(Ma){var i=t[e];return i===n?a:i}return De.call(t,e)?t[e]:a},za.prototype.has=function(e){var t=this.__data__;return Ma?t[e]!==a:De.call(t,e)},za.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ma&&t===a?n:t,this},Wa.prototype.clear=function(){this.__data__=[],this.size=0},Wa.prototype.delete=function(e){var t=this.__data__,a=ei(t,e);return!(a<0||(a==t.length-1?t.pop():qe.call(t,a,1),--this.size,0))},Wa.prototype.get=function(e){var t=this.__data__,i=ei(t,e);return i<0?a:t[i][1]},Wa.prototype.has=function(e){return ei(this.__data__,e)>-1},Wa.prototype.set=function(e,t){var a=this.__data__,i=ei(a,e);return i<0?(++this.size,a.push([e,t])):a[i][1]=t,this},Ya.prototype.clear=function(){this.size=0,this.__data__={hash:new za,map:new(ka||Wa),string:new za}},Ya.prototype.delete=function(e){var t=lr(this,e).delete(e);return this.size-=t?1:0,t},Ya.prototype.get=function(e){return lr(this,e).get(e)},Ya.prototype.has=function(e){return lr(this,e).has(e)},Ya.prototype.set=function(e,t){var a=lr(this,e),i=a.size;return a.set(e,t),this.size+=a.size==i?0:1,this},Ha.prototype.add=Ha.prototype.push=function(e){return this.__data__.set(e,n),this},Ha.prototype.has=function(e){return this.__data__.has(e)},Ga.prototype.clear=function(){this.__data__=new Wa,this.size=0},Ga.prototype.delete=function(e){var t=this.__data__,a=t.delete(e);return this.size=t.size,a},Ga.prototype.get=function(e){return this.__data__.get(e)},Ga.prototype.has=function(e){return this.__data__.has(e)},Ga.prototype.set=function(e,t){var a=this.__data__;if(a instanceof Wa){var i=a.__data__;if(!ka||i.length<199)return i.push([e,t]),this.size=++a.size,this;a=this.__data__=new Ya(i)}return a.set(e,t),this.size=a.size,this};var ci=En(bi),di=En(vi,!0);function pi(e,t){var a=!0;return ci(e,(function(e,i,n){return a=!!t(e,i,n)})),a}function hi(e,t,i){for(var n=-1,r=e.length;++n<r;){var s=e[n],o=t(s);if(null!=o&&(l===a?o==o&&!so(o):i(o,l)))var l=o,u=s}return u}function fi(e,t){var a=[];return ci(e,(function(e,i,n){t(e,i,n)&&a.push(e)})),a}function mi(e,t,a,i,n){var r=-1,s=e.length;for(a||(a=yr),n||(n=[]);++r<s;){var o=e[r];t>0&&a(o)?t>1?mi(o,t-1,a,i,n):Ft(n,o):i||(n[n.length]=o)}return n}var yi=Fn(),gi=Fn(!0);function bi(e,t){return e&&yi(e,t,Vo)}function vi(e,t){return e&&gi(e,t,Vo)}function wi(e,t){return Ct(t,(function(t){return Zs(e[t])}))}function _i(e,t){for(var i=0,n=(t=bn(t,e)).length;null!=e&&i<n;)e=e[Rr(t[i++])];return i&&i==n?e:a}function Ai(e,t,a){var i=t(e);return js(e)?i:Ft(i,a(e))}function ki(e){return null==e?e===a?"[object Undefined]":"[object Null]":Qe&&Qe in Ne(e)?function(e){var t=De.call(e,Qe),i=e[Qe];try{e[Qe]=a;var n=!0}catch(e){}var r=Le.call(e);return n&&(t?e[Qe]=i:delete e[Qe]),r}(e):function(e){return Le.call(e)}(e)}function Si(e,t){return e>t}function Ni(e,t){return null!=e&&De.call(e,t)}function Ti(e,t){return null!=e&&t in Ne(e)}function Mi(e,t,i){for(var n=i?It:Vt,r=e[0].length,s=e.length,o=s,l=ne(s),u=1/0,c=[];o--;){var d=e[o];o&&t&&(d=Et(d,Jt(t))),u=ga(d.length,u),l[o]=!i&&(t||r>=120&&d.length>=120)?new Ha(o&&d):a}d=e[0];var p=-1,h=l[0];e:for(;++p<r&&c.length<u;){var f=d[p],m=t?t(f):f;if(f=i||0!==f?f:0,!(h?Xt(h,m):n(c,m,i))){for(o=s;--o;){var y=l[o];if(!(y?Xt(y,m):n(e[o],m,i)))continue e}h&&h.push(m),c.push(f)}}return c}function xi(e,t,i){var n=null==(e=Tr(e,t=bn(t,e)))?e:e[Rr(qr(t))];return null==n?a:St(n,e,i)}function Ci(e){return Qs(e)&&ki(e)==f}function Vi(e,t,i,n,r){return e===t||(null==e||null==t||!Qs(e)&&!Qs(t)?e!=e&&t!=t:function(e,t,i,n,r,s){var o=js(e),l=js(t),u=o?m:hr(e),c=l?m:hr(t),d=(u=u==f?k:u)==k,p=(c=c==f?k:c)==k,h=u==c;if(h&&Hs(e)){if(!Hs(t))return!1;o=!0,d=!1}if(h&&!d)return s||(s=new Ga),o||oo(e)?er(e,t,i,n,r,s):function(e,t,a,i,n,r,s){switch(a){case E:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case I:return!(e.byteLength!=t.byteLength||!r(new ze(e),new ze(t)));case y:case g:case A:return Bs(+e,+t);case b:return e.name==t.name&&e.message==t.message;case N:case M:return e==t+"";case _:var o=ra;case T:var l=1&i;if(o||(o=la),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;i|=2,s.set(e,t);var c=er(o(e),o(t),i,n,r,s);return s.delete(e),c;case x:if(Pa)return Pa.call(e)==Pa.call(t)}return!1}(e,t,u,i,n,r,s);if(!(1&i)){var v=d&&De.call(e,"__wrapped__"),w=p&&De.call(t,"__wrapped__");if(v||w){var S=v?e.value():e,C=w?t.value():t;return s||(s=new Ga),r(S,C,i,n,s)}}return!!h&&(s||(s=new Ga),function(e,t,i,n,r,s){var o=1&i,l=ar(e),u=l.length,c=ar(t),d=c.length;if(u!=d&&!o)return!1;for(var p=u;p--;){var h=l[p];if(!(o?h in t:De.call(t,h)))return!1}var f=s.get(e),m=s.get(t);if(f&&m)return f==t&&m==e;var y=!0;s.set(e,t),s.set(t,e);for(var g=o;++p<u;){var b=e[h=l[p]],v=t[h];if(n)var w=o?n(v,b,h,t,e,s):n(b,v,h,e,t,s);if(!(w===a?b===v||r(b,v,i,n,s):w)){y=!1;break}g||(g="constructor"==h)}if(y&&!g){var _=e.constructor,A=t.constructor;_==A||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof A&&A instanceof A||(y=!1)}return s.delete(e),s.delete(t),y}(e,t,i,n,r,s))}(e,t,i,n,Vi,r))}function Ii(e,t,i,n){var r=i.length,s=r,o=!n;if(null==e)return!s;for(e=Ne(e);r--;){var l=i[r];if(o&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++r<s;){var u=(l=i[r])[0],c=e[u],d=l[1];if(o&&l[2]){if(c===a&&!(u in e))return!1}else{var p=new Ga;if(n)var h=n(c,d,u,e,t,p);if(!(h===a?Vi(d,c,3,n,p):h))return!1}}return!0}function Ei(e){return!(!Xs(e)||(t=e,Pe&&Pe in t))&&(Zs(e)?$e:me).test(Pr(e));var t}function Fi(e){return"function"==typeof e?e:null==e?al:"object"==typeof e?js(e)?Oi(e[0],e[1]):Bi(e):dl(e)}function Di(e){if(!Ar(e))return ma(e);var t=[];for(var a in Ne(e))De.call(e,a)&&"constructor"!=a&&t.push(a);return t}function Ri(e){if(!Xs(e))return function(e){var t=[];if(null!=e)for(var a in Ne(e))t.push(a);return t}(e);var t=Ar(e),a=[];for(var i in e)("constructor"!=i||!t&&De.call(e,i))&&a.push(i);return a}function Pi(e,t){return e<t}function Li(e,t){var a=-1,i=Ws(e)?ne(e.length):[];return ci(e,(function(e,n,r){i[++a]=t(e,n,r)})),i}function Bi(e){var t=ur(e);return 1==t.length&&t[0][2]?Sr(t[0][0],t[0][1]):function(a){return a===e||Ii(a,e,t)}}function Oi(e,t){return vr(e)&&kr(t)?Sr(Rr(e),t):function(i){var n=No(i,e);return n===a&&n===t?To(i,e):Vi(t,n,3)}}function $i(e,t,i,n,r){e!==t&&yi(t,(function(s,o){if(r||(r=new Ga),Xs(s))!function(e,t,i,n,r,s,o){var l=Mr(e,i),u=Mr(t,i),c=o.get(u);if(c)Xa(e,i,c);else{var d=s?s(l,u,i+"",e,t,o):a,p=d===a;if(p){var h=js(u),f=!h&&Hs(u),m=!h&&!f&&oo(u);d=u,h||f||m?js(l)?d=l:Ys(l)?d=xn(l):f?(p=!1,d=An(u,!0)):m?(p=!1,d=Sn(u,!0)):d=[]:ao(u)||Us(u)?(d=l,Us(l)?d=yo(l):Xs(l)&&!Zs(l)||(d=mr(u))):p=!1}p&&(o.set(u,d),r(d,u,n,s,o),o.delete(u)),Xa(e,i,d)}}(e,t,o,i,$i,n,r);else{var l=n?n(Mr(e,o),s,o+"",e,t,r):a;l===a&&(l=s),Xa(e,o,l)}}),Io)}function Ui(e,t){var i=e.length;if(i)return gr(t+=t<0?i:0,i)?e[t]:a}function ji(e,t,a){t=t.length?Et(t,(function(e){return js(e)?function(t){return _i(t,1===e.length?e[0]:e)}:e})):[al];var i=-1;t=Et(t,Jt(or()));var n=Li(e,(function(e,a,n){var r=Et(t,(function(t){return t(e)}));return{criteria:r,index:++i,value:e}}));return function(e,t){var a=e.length;for(e.sort(t);a--;)e[a]=e[a].value;return e}(n,(function(e,t){return function(e,t,a){for(var i=-1,n=e.criteria,r=t.criteria,s=n.length,o=a.length;++i<s;){var l=Nn(n[i],r[i]);if(l)return i>=o?l:l*("desc"==a[i]?-1:1)}return e.index-t.index}(e,t,a)}))}function zi(e,t,a){for(var i=-1,n=t.length,r={};++i<n;){var s=t[i],o=_i(e,s);a(o,s)&&Ki(r,bn(s,e),o)}return r}function Wi(e,t,a,i){var n=i?Ut:$t,r=-1,s=t.length,o=e;for(e===t&&(t=xn(t)),a&&(o=Et(e,Jt(a)));++r<s;)for(var l=0,u=t[r],c=a?a(u):u;(l=n(o,c,l,i))>-1;)o!==e&&qe.call(o,l,1),qe.call(e,l,1);return e}function Yi(e,t){for(var a=e?t.length:0,i=a-1;a--;){var n=t[a];if(a==i||n!==r){var r=n;gr(n)?qe.call(e,n,1):cn(e,n)}}return e}function Hi(e,t){return e+ft(wa()*(t-e+1))}function Gi(e,t){var a="";if(!e||t<1||t>c)return a;do{t%2&&(a+=e),(t=ft(t/2))&&(e+=e)}while(t);return a}function qi(e,t){return Vr(Nr(e,t,al),e+"")}function Zi(e){return Za(Oo(e))}function Ji(e,t){var a=Oo(e);return Fr(a,ri(t,0,a.length))}function Ki(e,t,i,n){if(!Xs(e))return e;for(var r=-1,s=(t=bn(t,e)).length,o=s-1,l=e;null!=l&&++r<s;){var u=Rr(t[r]),c=i;if("__proto__"===u||"constructor"===u||"prototype"===u)return e;if(r!=o){var d=l[u];(c=n?n(d,u,l):a)===a&&(c=Xs(d)?d:gr(t[r+1])?[]:{})}Qa(l,u,c),l=l[u]}return e}var Xi=xa?function(e,t){return xa.set(e,t),e}:al,Qi=tt?function(e,t){return tt(e,"toString",{configurable:!0,enumerable:!1,value:Qo(t),writable:!0})}:al;function en(e){return Fr(Oo(e))}function tn(e,t,a){var i=-1,n=e.length;t<0&&(t=-t>n?0:n+t),(a=a>n?n:a)<0&&(a+=n),n=t>a?0:a-t>>>0,t>>>=0;for(var r=ne(n);++i<n;)r[i]=e[i+t];return r}function an(e,t){var a;return ci(e,(function(e,i,n){return!(a=t(e,i,n))})),!!a}function nn(e,t,a){var i=0,n=null==e?i:e.length;if("number"==typeof t&&t==t&&n<=2147483647){for(;i<n;){var r=i+n>>>1,s=e[r];null!==s&&!so(s)&&(a?s<=t:s<t)?i=r+1:n=r}return n}return rn(e,t,al,a)}function rn(e,t,i,n){var r=0,s=null==e?0:e.length;if(0===s)return 0;for(var o=(t=i(t))!=t,l=null===t,u=so(t),c=t===a;r<s;){var d=ft((r+s)/2),p=i(e[d]),h=p!==a,f=null===p,m=p==p,y=so(p);if(o)var g=n||m;else g=c?m&&(n||h):l?m&&h&&(n||!f):u?m&&h&&!f&&(n||!y):!f&&!y&&(n?p<=t:p<t);g?r=d+1:s=d}return ga(s,4294967294)}function sn(e,t){for(var a=-1,i=e.length,n=0,r=[];++a<i;){var s=e[a],o=t?t(s):s;if(!a||!Bs(o,l)){var l=o;r[n++]=0===s?0:s}}return r}function on(e){return"number"==typeof e?e:so(e)?d:+e}function ln(e){if("string"==typeof e)return e;if(js(e))return Et(e,ln)+"";if(so(e))return La?La.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function un(e,t,a){var i=-1,n=Vt,r=e.length,s=!0,o=[],l=o;if(a)s=!1,n=It;else if(r>=200){var u=t?null:qn(e);if(u)return la(u);s=!1,n=Xt,l=new Ha}else l=t?[]:o;e:for(;++i<r;){var c=e[i],d=t?t(c):c;if(c=a||0!==c?c:0,s&&d==d){for(var p=l.length;p--;)if(l[p]===d)continue e;t&&l.push(d),o.push(c)}else n(l,d,a)||(l!==o&&l.push(d),o.push(c))}return o}function cn(e,t){return null==(e=Tr(e,t=bn(t,e)))||delete e[Rr(qr(t))]}function dn(e,t,a,i){return Ki(e,t,a(_i(e,t)),i)}function pn(e,t,a,i){for(var n=e.length,r=i?n:-1;(i?r--:++r<n)&&t(e[r],r,e););return a?tn(e,i?0:r,i?r+1:n):tn(e,i?r+1:0,i?n:r)}function hn(e,t){var a=e;return a instanceof ja&&(a=a.value()),Dt(t,(function(e,t){return t.func.apply(t.thisArg,Ft([e],t.args))}),a)}function fn(e,t,a){var i=e.length;if(i<2)return i?un(e[0]):[];for(var n=-1,r=ne(i);++n<i;)for(var s=e[n],o=-1;++o<i;)o!=n&&(r[n]=ui(r[n]||s,e[o],t,a));return un(mi(r,1),t,a)}function mn(e,t,i){for(var n=-1,r=e.length,s=t.length,o={};++n<r;){var l=n<s?t[n]:a;i(o,e[n],l)}return o}function yn(e){return Ys(e)?e:[]}function gn(e){return"function"==typeof e?e:al}function bn(e,t){return js(e)?e:vr(e,t)?[e]:Dr(go(e))}var vn=qi;function wn(e,t,i){var n=e.length;return i=i===a?n:i,!t&&i>=n?e:tn(e,t,i)}var _n=ot||function(e){return pt.clearTimeout(e)};function An(e,t){if(t)return e.slice();var a=e.length,i=We?We(a):new e.constructor(a);return e.copy(i),i}function kn(e){var t=new e.constructor(e.byteLength);return new ze(t).set(new ze(e)),t}function Sn(e,t){var a=t?kn(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.length)}function Nn(e,t){if(e!==t){var i=e!==a,n=null===e,r=e==e,s=so(e),o=t!==a,l=null===t,u=t==t,c=so(t);if(!l&&!c&&!s&&e>t||s&&o&&u&&!l&&!c||n&&o&&u||!i&&u||!r)return 1;if(!n&&!s&&!c&&e<t||c&&i&&r&&!n&&!s||l&&i&&r||!o&&r||!u)return-1}return 0}function Tn(e,t,a,i){for(var n=-1,r=e.length,s=a.length,o=-1,l=t.length,u=ya(r-s,0),c=ne(l+u),d=!i;++o<l;)c[o]=t[o];for(;++n<s;)(d||n<r)&&(c[a[n]]=e[n]);for(;u--;)c[o++]=e[n++];return c}function Mn(e,t,a,i){for(var n=-1,r=e.length,s=-1,o=a.length,l=-1,u=t.length,c=ya(r-o,0),d=ne(c+u),p=!i;++n<c;)d[n]=e[n];for(var h=n;++l<u;)d[h+l]=t[l];for(;++s<o;)(p||n<r)&&(d[h+a[s]]=e[n++]);return d}function xn(e,t){var a=-1,i=e.length;for(t||(t=ne(i));++a<i;)t[a]=e[a];return t}function Cn(e,t,i,n){var r=!i;i||(i={});for(var s=-1,o=t.length;++s<o;){var l=t[s],u=n?n(i[l],e[l],l,i,e):a;u===a&&(u=e[l]),r?ii(i,l,u):Qa(i,l,u)}return i}function Vn(e,t){return function(a,i){var n=js(a)?Nt:ti,r=t?t():{};return n(a,e,or(i,2),r)}}function In(e){return qi((function(t,i){var n=-1,r=i.length,s=r>1?i[r-1]:a,o=r>2?i[2]:a;for(s=e.length>3&&"function"==typeof s?(r--,s):a,o&&br(i[0],i[1],o)&&(s=r<3?a:s,r=1),t=Ne(t);++n<r;){var l=i[n];l&&e(t,l,n,s)}return t}))}function En(e,t){return function(a,i){if(null==a)return a;if(!Ws(a))return e(a,i);for(var n=a.length,r=t?n:-1,s=Ne(a);(t?r--:++r<n)&&!1!==i(s[r],r,s););return a}}function Fn(e){return function(t,a,i){for(var n=-1,r=Ne(t),s=i(t),o=s.length;o--;){var l=s[e?o:++n];if(!1===a(r[l],l,r))break}return t}}function Dn(e){return function(t){var i=na(t=go(t))?da(t):a,n=i?i[0]:t.charAt(0),r=i?wn(i,1).join(""):t.slice(1);return n[e]()+r}}function Rn(e){return function(t){return Dt(Jo(jo(t).replace(Ke,"")),e,"")}}function Pn(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var a=Oa(e.prototype),i=e.apply(a,t);return Xs(i)?i:a}}function Ln(e){return function(t,i,n){var r=Ne(t);if(!Ws(t)){var s=or(i,3);t=Vo(t),i=function(e){return s(r[e],e,r)}}var o=e(t,i,n);return o>-1?r[s?t[o]:o]:a}}function Bn(e){return tr((function(t){var n=t.length,r=n,s=Ua.prototype.thru;for(e&&t.reverse();r--;){var o=t[r];if("function"!=typeof o)throw new xe(i);if(s&&!l&&"wrapper"==rr(o))var l=new Ua([],!0)}for(r=l?r:n;++r<n;){var u=rr(o=t[r]),c="wrapper"==u?nr(o):a;l=c&&wr(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[rr(c[0])].apply(l,c[3]):1==o.length&&wr(o)?l[u]():l.thru(o)}return function(){var e=arguments,a=e[0];if(l&&1==e.length&&js(a))return l.plant(a).value();for(var i=0,r=n?t[i].apply(this,e):a;++i<n;)r=t[i].call(this,r);return r}}))}function On(e,t,i,n,r,s,l,u,c,d){var p=t&o,h=1&t,f=2&t,m=24&t,y=512&t,g=f?a:Pn(e);return function o(){for(var b=arguments.length,v=ne(b),w=b;w--;)v[w]=arguments[w];if(m)var _=sr(o),A=function(e,t){for(var a=e.length,i=0;a--;)e[a]===t&&++i;return i}(v,_);if(n&&(v=Tn(v,n,r,m)),s&&(v=Mn(v,s,l,m)),b-=A,m&&b<d){var k=oa(v,_);return Hn(e,t,On,o.placeholder,i,v,k,u,c,d-b)}var S=h?i:this,N=f?S[e]:e;return b=v.length,u?v=function(e,t){for(var i=e.length,n=ga(t.length,i),r=xn(e);n--;){var s=t[n];e[n]=gr(s,i)?r[s]:a}return e}(v,u):y&&b>1&&v.reverse(),p&&c<b&&(v.length=c),this&&this!==pt&&this instanceof o&&(N=g||Pn(N)),N.apply(S,v)}}function $n(e,t){return function(a,i){return function(e,t,a,i){return bi(e,(function(e,n,r){t(i,a(e),n,r)})),i}(a,e,t(i),{})}}function Un(e,t){return function(i,n){var r;if(i===a&&n===a)return t;if(i!==a&&(r=i),n!==a){if(r===a)return n;"string"==typeof i||"string"==typeof n?(i=ln(i),n=ln(n)):(i=on(i),n=on(n)),r=e(i,n)}return r}}function jn(e){return tr((function(t){return t=Et(t,Jt(or())),qi((function(a){var i=this;return e(t,(function(e){return St(e,i,a)}))}))}))}function zn(e,t){var i=(t=t===a?" ":ln(t)).length;if(i<2)return i?Gi(t,e):t;var n=Gi(t,ht(e/ca(t)));return na(t)?wn(da(n),0,e).join(""):n.slice(0,e)}function Wn(e){return function(t,i,n){return n&&"number"!=typeof n&&br(t,i,n)&&(i=n=a),t=po(t),i===a?(i=t,t=0):i=po(i),function(e,t,a,i){for(var n=-1,r=ya(ht((t-e)/(a||1)),0),s=ne(r);r--;)s[i?r:++n]=e,e+=a;return s}(t,i,n=n===a?t<i?1:-1:po(n),e)}}function Yn(e){return function(t,a){return"string"==typeof t&&"string"==typeof a||(t=mo(t),a=mo(a)),e(t,a)}}function Hn(e,t,i,n,r,o,l,u,c,d){var p=8&t;t|=p?s:64,4&(t&=~(p?64:s))||(t&=-4);var h=[e,t,r,p?o:a,p?l:a,p?a:o,p?a:l,u,c,d],f=i.apply(a,h);return wr(e)&&xr(f,h),f.placeholder=n,Ir(f,e,t)}function Gn(e){var t=Se[e];return function(e,a){if(e=mo(e),(a=null==a?0:ga(ho(a),292))&&Lt(e)){var i=(go(e)+"e").split("e");return+((i=(go(t(i[0]+"e"+(+i[1]+a)))+"e").split("e"))[0]+"e"+(+i[1]-a))}return t(e)}}var qn=Na&&1/la(new Na([,-0]))[1]==u?function(e){return new Na(e)}:ol;function Zn(e){return function(t){var a=hr(t);return a==_?ra(t):a==T?ua(t):function(e,t){return Et(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Jn(e,t,n,u,c,d,p,h){var f=2&t;if(!f&&"function"!=typeof e)throw new xe(i);var m=u?u.length:0;if(m||(t&=-97,u=c=a),p=p===a?p:ya(ho(p),0),h=h===a?h:ho(h),m-=c?c.length:0,64&t){var y=u,g=c;u=c=a}var b=f?a:nr(e),v=[e,t,n,u,c,y,g,d,p,h];if(b&&function(e,t){var a=e[1],i=t[1],n=a|i,s=n<131,u=i==o&&8==a||i==o&&a==l&&e[7].length<=t[8]||384==i&&t[7].length<=t[8]&&8==a;if(!s&&!u)return e;1&i&&(e[2]=t[2],n|=1&a?0:4);var c=t[3];if(c){var d=e[3];e[3]=d?Tn(d,c,t[4]):c,e[4]=d?oa(e[3],r):t[4]}(c=t[5])&&(d=e[5],e[5]=d?Mn(d,c,t[6]):c,e[6]=d?oa(e[5],r):t[6]),(c=t[7])&&(e[7]=c),i&o&&(e[8]=null==e[8]?t[8]:ga(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=n}(v,b),e=v[0],t=v[1],n=v[2],u=v[3],c=v[4],!(h=v[9]=v[9]===a?f?0:e.length:ya(v[9]-m,0))&&24&t&&(t&=-25),t&&1!=t)w=8==t||16==t?function(e,t,i){var n=Pn(e);return function r(){for(var s=arguments.length,o=ne(s),l=s,u=sr(r);l--;)o[l]=arguments[l];var c=s<3&&o[0]!==u&&o[s-1]!==u?[]:oa(o,u);return(s-=c.length)<i?Hn(e,t,On,r.placeholder,a,o,c,a,a,i-s):St(this&&this!==pt&&this instanceof r?n:e,this,o)}}(e,t,h):t!=s&&33!=t||c.length?On.apply(a,v):function(e,t,a,i){var n=1&t,r=Pn(e);return function t(){for(var s=-1,o=arguments.length,l=-1,u=i.length,c=ne(u+o),d=this&&this!==pt&&this instanceof t?r:e;++l<u;)c[l]=i[l];for(;o--;)c[l++]=arguments[++s];return St(d,n?a:this,c)}}(e,t,n,u);else var w=function(e,t,a){var i=1&t,n=Pn(e);return function t(){return(this&&this!==pt&&this instanceof t?n:e).apply(i?a:this,arguments)}}(e,t,n);return Ir((b?Xi:xr)(w,v),e,t)}function Kn(e,t,i,n){return e===a||Bs(e,Ie[i])&&!De.call(n,i)?t:e}function Xn(e,t,i,n,r,s){return Xs(e)&&Xs(t)&&(s.set(t,e),$i(e,t,a,Xn,s),s.delete(t)),e}function Qn(e){return ao(e)?a:e}function er(e,t,i,n,r,s){var o=1&i,l=e.length,u=t.length;if(l!=u&&!(o&&u>l))return!1;var c=s.get(e),d=s.get(t);if(c&&d)return c==t&&d==e;var p=-1,h=!0,f=2&i?new Ha:a;for(s.set(e,t),s.set(t,e);++p<l;){var m=e[p],y=t[p];if(n)var g=o?n(y,m,p,t,e,s):n(m,y,p,e,t,s);if(g!==a){if(g)continue;h=!1;break}if(f){if(!Pt(t,(function(e,t){if(!Xt(f,t)&&(m===e||r(m,e,i,n,s)))return f.push(t)}))){h=!1;break}}else if(m!==y&&!r(m,y,i,n,s)){h=!1;break}}return s.delete(e),s.delete(t),h}function tr(e){return Vr(Nr(e,a,zr),e+"")}function ar(e){return Ai(e,Vo,dr)}function ir(e){return Ai(e,Io,pr)}var nr=xa?function(e){return xa.get(e)}:ol;function rr(e){for(var t=e.name+"",a=Ca[t],i=De.call(Ca,t)?a.length:0;i--;){var n=a[i],r=n.func;if(null==r||r==e)return n.name}return t}function sr(e){return(De.call(Ba,"placeholder")?Ba:e).placeholder}function or(){var e=Ba.iteratee||il;return e=e===il?Fi:e,arguments.length?e(arguments[0],arguments[1]):e}function lr(e,t){var a,i,n=e.__data__;return("string"==(i=typeof(a=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==a:null===a)?n["string"==typeof t?"string":"hash"]:n.map}function ur(e){for(var t=Vo(e),a=t.length;a--;){var i=t[a],n=e[i];t[a]=[i,n,kr(n)]}return t}function cr(e,t){var i=function(e,t){return null==e?a:e[t]}(e,t);return Ei(i)?i:a}var dr=yt?function(e){return null==e?[]:(e=Ne(e),Ct(yt(e),(function(t){return Ge.call(e,t)})))}:fl,pr=yt?function(e){for(var t=[];e;)Ft(t,dr(e)),e=Ye(e);return t}:fl,hr=ki;function fr(e,t,a){for(var i=-1,n=(t=bn(t,e)).length,r=!1;++i<n;){var s=Rr(t[i]);if(!(r=null!=e&&a(e,s)))break;e=e[s]}return r||++i!=n?r:!!(n=null==e?0:e.length)&&Ks(n)&&gr(s,n)&&(js(e)||Us(e))}function mr(e){return"function"!=typeof e.constructor||Ar(e)?{}:Oa(Ye(e))}function yr(e){return js(e)||Us(e)||!!(Ze&&e&&e[Ze])}function gr(e,t){var a=typeof e;return!!(t=null==t?c:t)&&("number"==a||"symbol"!=a&&ge.test(e))&&e>-1&&e%1==0&&e<t}function br(e,t,a){if(!Xs(a))return!1;var i=typeof t;return!!("number"==i?Ws(a)&&gr(t,a.length):"string"==i&&t in a)&&Bs(a[t],e)}function vr(e,t){if(js(e))return!1;var a=typeof e;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=e&&!so(e))||Q.test(e)||!X.test(e)||null!=t&&e in Ne(t)}function wr(e){var t=rr(e),a=Ba[t];if("function"!=typeof a||!(t in ja.prototype))return!1;if(e===a)return!0;var i=nr(a);return!!i&&e===i[0]}(Aa&&hr(new Aa(new ArrayBuffer(1)))!=E||ka&&hr(new ka)!=_||Sa&&hr(Sa.resolve())!=S||Na&&hr(new Na)!=T||Ta&&hr(new Ta)!=C)&&(hr=function(e){var t=ki(e),i=t==k?e.constructor:a,n=i?Pr(i):"";if(n)switch(n){case Va:return E;case Ia:return _;case Ea:return S;case Fa:return T;case Da:return C}return t});var _r=Ee?Zs:ml;function Ar(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ie)}function kr(e){return e==e&&!Xs(e)}function Sr(e,t){return function(i){return null!=i&&i[e]===t&&(t!==a||e in Ne(i))}}function Nr(e,t,i){return t=ya(t===a?e.length-1:t,0),function(){for(var a=arguments,n=-1,r=ya(a.length-t,0),s=ne(r);++n<r;)s[n]=a[t+n];n=-1;for(var o=ne(t+1);++n<t;)o[n]=a[n];return o[t]=i(s),St(e,this,o)}}function Tr(e,t){return t.length<2?e:_i(e,tn(t,0,-1))}function Mr(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var xr=Er(Xi),Cr=dt||function(e,t){return pt.setTimeout(e,t)},Vr=Er(Qi);function Ir(e,t,a){var i=t+"";return Vr(e,function(e,t){var a=t.length;if(!a)return e;var i=a-1;return t[i]=(a>1?"& ":"")+t[i],t=t.join(a>2?", ":" "),e.replace(re,"{\n/* [wrapped with "+t+"] */\n")}(i,function(e,t){return Tt(h,(function(a){var i="_."+a[0];t&a[1]&&!Vt(e,i)&&e.push(i)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(oe):[]}(i),a)))}function Er(e){var t=0,i=0;return function(){var n=ba(),r=16-(n-i);if(i=n,r>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(a,arguments)}}function Fr(e,t){var i=-1,n=e.length,r=n-1;for(t=t===a?n:t;++i<t;){var s=Hi(i,r),o=e[s];e[s]=e[i],e[i]=o}return e.length=t,e}var Dr=function(e){var t=Es(e,(function(e){return 500===a.size&&a.clear(),e})),a=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,(function(e,a,i,n){t.push(i?n.replace(ce,"$1"):a||e)})),t}));function Rr(e){if("string"==typeof e||so(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Pr(e){if(null!=e){try{return Fe.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Lr(e){if(e instanceof ja)return e.clone();var t=new Ua(e.__wrapped__,e.__chain__);return t.__actions__=xn(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Br=qi((function(e,t){return Ys(e)?ui(e,mi(t,1,Ys,!0)):[]})),Or=qi((function(e,t){var i=qr(t);return Ys(i)&&(i=a),Ys(e)?ui(e,mi(t,1,Ys,!0),or(i,2)):[]})),$r=qi((function(e,t){var i=qr(t);return Ys(i)&&(i=a),Ys(e)?ui(e,mi(t,1,Ys,!0),a,i):[]}));function Ur(e,t,a){var i=null==e?0:e.length;if(!i)return-1;var n=null==a?0:ho(a);return n<0&&(n=ya(i+n,0)),Ot(e,or(t,3),n)}function jr(e,t,i){var n=null==e?0:e.length;if(!n)return-1;var r=n-1;return i!==a&&(r=ho(i),r=i<0?ya(n+r,0):ga(r,n-1)),Ot(e,or(t,3),r,!0)}function zr(e){return null!=e&&e.length?mi(e,1):[]}function Wr(e){return e&&e.length?e[0]:a}var Yr=qi((function(e){var t=Et(e,yn);return t.length&&t[0]===e[0]?Mi(t):[]})),Hr=qi((function(e){var t=qr(e),i=Et(e,yn);return t===qr(i)?t=a:i.pop(),i.length&&i[0]===e[0]?Mi(i,or(t,2)):[]})),Gr=qi((function(e){var t=qr(e),i=Et(e,yn);return(t="function"==typeof t?t:a)&&i.pop(),i.length&&i[0]===e[0]?Mi(i,a,t):[]}));function qr(e){var t=null==e?0:e.length;return t?e[t-1]:a}var Zr=qi(Jr);function Jr(e,t){return e&&e.length&&t&&t.length?Wi(e,t):e}var Kr=tr((function(e,t){var a=null==e?0:e.length,i=ni(e,t);return Yi(e,Et(t,(function(e){return gr(e,a)?+e:e})).sort(Nn)),i}));function Xr(e){return null==e?e:_a.call(e)}var Qr=qi((function(e){return un(mi(e,1,Ys,!0))})),es=qi((function(e){var t=qr(e);return Ys(t)&&(t=a),un(mi(e,1,Ys,!0),or(t,2))})),ts=qi((function(e){var t=qr(e);return t="function"==typeof t?t:a,un(mi(e,1,Ys,!0),a,t)}));function as(e){if(!e||!e.length)return[];var t=0;return e=Ct(e,(function(e){if(Ys(e))return t=ya(e.length,t),!0})),qt(t,(function(t){return Et(e,Wt(t))}))}function is(e,t){if(!e||!e.length)return[];var i=as(e);return null==t?i:Et(i,(function(e){return St(t,a,e)}))}var ns=qi((function(e,t){return Ys(e)?ui(e,t):[]})),rs=qi((function(e){return fn(Ct(e,Ys))})),ss=qi((function(e){var t=qr(e);return Ys(t)&&(t=a),fn(Ct(e,Ys),or(t,2))})),os=qi((function(e){var t=qr(e);return t="function"==typeof t?t:a,fn(Ct(e,Ys),a,t)})),ls=qi(as),us=qi((function(e){var t=e.length,i=t>1?e[t-1]:a;return i="function"==typeof i?(e.pop(),i):a,is(e,i)}));function cs(e){var t=Ba(e);return t.__chain__=!0,t}function ds(e,t){return t(e)}var ps=tr((function(e){var t=e.length,i=t?e[0]:0,n=this.__wrapped__,r=function(t){return ni(t,e)};return!(t>1||this.__actions__.length)&&n instanceof ja&&gr(i)?((n=n.slice(i,+i+(t?1:0))).__actions__.push({func:ds,args:[r],thisArg:a}),new Ua(n,this.__chain__).thru((function(e){return t&&!e.length&&e.push(a),e}))):this.thru(r)})),hs=Vn((function(e,t,a){De.call(e,a)?++e[a]:ii(e,a,1)})),fs=Ln(Ur),ms=Ln(jr);function ys(e,t){return(js(e)?Tt:ci)(e,or(t,3))}function gs(e,t){return(js(e)?Mt:di)(e,or(t,3))}var bs=Vn((function(e,t,a){De.call(e,a)?e[a].push(t):ii(e,a,[t])})),vs=qi((function(e,t,a){var i=-1,n="function"==typeof t,r=Ws(e)?ne(e.length):[];return ci(e,(function(e){r[++i]=n?St(t,e,a):xi(e,t,a)})),r})),ws=Vn((function(e,t,a){ii(e,a,t)}));function _s(e,t){return(js(e)?Et:Li)(e,or(t,3))}var As=Vn((function(e,t,a){e[a?0:1].push(t)}),(function(){return[[],[]]})),ks=qi((function(e,t){if(null==e)return[];var a=t.length;return a>1&&br(e,t[0],t[1])?t=[]:a>2&&br(t[0],t[1],t[2])&&(t=[t[0]]),ji(e,mi(t,1),[])})),Ss=ct||function(){return pt.Date.now()};function Ns(e,t,i){return t=i?a:t,t=e&&null==t?e.length:t,Jn(e,o,a,a,a,a,t)}function Ts(e,t){var n;if("function"!=typeof t)throw new xe(i);return e=ho(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=a),n}}var Ms=qi((function(e,t,a){var i=1;if(a.length){var n=oa(a,sr(Ms));i|=s}return Jn(e,i,t,a,n)})),xs=qi((function(e,t,a){var i=3;if(a.length){var n=oa(a,sr(xs));i|=s}return Jn(t,i,e,a,n)}));function Cs(e,t,n){var r,s,o,l,u,c,d=0,p=!1,h=!1,f=!0;if("function"!=typeof e)throw new xe(i);function m(t){var i=r,n=s;return r=s=a,d=t,l=e.apply(n,i)}function y(e){var i=e-c;return c===a||i>=t||i<0||h&&e-d>=o}function g(){var e=Ss();if(y(e))return b(e);u=Cr(g,function(e){var a=t-(e-c);return h?ga(a,o-(e-d)):a}(e))}function b(e){return u=a,f&&r?m(e):(r=s=a,l)}function v(){var e=Ss(),i=y(e);if(r=arguments,s=this,c=e,i){if(u===a)return function(e){return d=e,u=Cr(g,t),p?m(e):l}(c);if(h)return _n(u),u=Cr(g,t),m(c)}return u===a&&(u=Cr(g,t)),l}return t=mo(t)||0,Xs(n)&&(p=!!n.leading,o=(h="maxWait"in n)?ya(mo(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),v.cancel=function(){u!==a&&_n(u),d=0,r=c=s=u=a},v.flush=function(){return u===a?l:b(Ss())},v}var Vs=qi((function(e,t){return li(e,1,t)})),Is=qi((function(e,t,a){return li(e,mo(t)||0,a)}));function Es(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new xe(i);var a=function(){var i=arguments,n=t?t.apply(this,i):i[0],r=a.cache;if(r.has(n))return r.get(n);var s=e.apply(this,i);return a.cache=r.set(n,s)||r,s};return a.cache=new(Es.Cache||Ya),a}function Fs(e){if("function"!=typeof e)throw new xe(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Es.Cache=Ya;var Ds=vn((function(e,t){var a=(t=1==t.length&&js(t[0])?Et(t[0],Jt(or())):Et(mi(t,1),Jt(or()))).length;return qi((function(i){for(var n=-1,r=ga(i.length,a);++n<r;)i[n]=t[n].call(this,i[n]);return St(e,this,i)}))})),Rs=qi((function(e,t){var i=oa(t,sr(Rs));return Jn(e,s,a,t,i)})),Ps=qi((function(e,t){var i=oa(t,sr(Ps));return Jn(e,64,a,t,i)})),Ls=tr((function(e,t){return Jn(e,l,a,a,a,t)}));function Bs(e,t){return e===t||e!=e&&t!=t}var Os=Yn(Si),$s=Yn((function(e,t){return e>=t})),Us=Ci(function(){return arguments}())?Ci:function(e){return Qs(e)&&De.call(e,"callee")&&!Ge.call(e,"callee")},js=ne.isArray,zs=bt?Jt(bt):function(e){return Qs(e)&&ki(e)==I};function Ws(e){return null!=e&&Ks(e.length)&&!Zs(e)}function Ys(e){return Qs(e)&&Ws(e)}var Hs=gt||ml,Gs=vt?Jt(vt):function(e){return Qs(e)&&ki(e)==g};function qs(e){if(!Qs(e))return!1;var t=ki(e);return t==b||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!ao(e)}function Zs(e){if(!Xs(e))return!1;var t=ki(e);return t==v||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Js(e){return"number"==typeof e&&e==ho(e)}function Ks(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=c}function Xs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Qs(e){return null!=e&&"object"==typeof e}var eo=wt?Jt(wt):function(e){return Qs(e)&&hr(e)==_};function to(e){return"number"==typeof e||Qs(e)&&ki(e)==A}function ao(e){if(!Qs(e)||ki(e)!=k)return!1;var t=Ye(e);if(null===t)return!0;var a=De.call(t,"constructor")&&t.constructor;return"function"==typeof a&&a instanceof a&&Fe.call(a)==Be}var io=_t?Jt(_t):function(e){return Qs(e)&&ki(e)==N},no=At?Jt(At):function(e){return Qs(e)&&hr(e)==T};function ro(e){return"string"==typeof e||!js(e)&&Qs(e)&&ki(e)==M}function so(e){return"symbol"==typeof e||Qs(e)&&ki(e)==x}var oo=kt?Jt(kt):function(e){return Qs(e)&&Ks(e.length)&&!!rt[ki(e)]},lo=Yn(Pi),uo=Yn((function(e,t){return e<=t}));function co(e){if(!e)return[];if(Ws(e))return ro(e)?da(e):xn(e);if(Je&&e[Je])return function(e){for(var t,a=[];!(t=e.next()).done;)a.push(t.value);return a}(e[Je]());var t=hr(e);return(t==_?ra:t==T?la:Oo)(e)}function po(e){return e?(e=mo(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=po(e),a=t%1;return t==t?a?t-a:t:0}function fo(e){return e?ri(ho(e),0,p):0}function mo(e){if("number"==typeof e)return e;if(so(e))return d;if(Xs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Xs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Zt(e);var a=fe.test(e);return a||ye.test(e)?ut(e.slice(2),a?2:8):he.test(e)?d:+e}function yo(e){return Cn(e,Io(e))}function go(e){return null==e?"":ln(e)}var bo=In((function(e,t){if(Ar(t)||Ws(t))Cn(t,Vo(t),e);else for(var a in t)De.call(t,a)&&Qa(e,a,t[a])})),vo=In((function(e,t){Cn(t,Io(t),e)})),wo=In((function(e,t,a,i){Cn(t,Io(t),e,i)})),_o=In((function(e,t,a,i){Cn(t,Vo(t),e,i)})),Ao=tr(ni),ko=qi((function(e,t){e=Ne(e);var i=-1,n=t.length,r=n>2?t[2]:a;for(r&&br(t[0],t[1],r)&&(n=1);++i<n;)for(var s=t[i],o=Io(s),l=-1,u=o.length;++l<u;){var c=o[l],d=e[c];(d===a||Bs(d,Ie[c])&&!De.call(e,c))&&(e[c]=s[c])}return e})),So=qi((function(e){return e.push(a,Xn),St(Fo,a,e)}));function No(e,t,i){var n=null==e?a:_i(e,t);return n===a?i:n}function To(e,t){return null!=e&&fr(e,t,Ti)}var Mo=$n((function(e,t,a){null!=t&&"function"!=typeof t.toString&&(t=Le.call(t)),e[t]=a}),Qo(al)),xo=$n((function(e,t,a){null!=t&&"function"!=typeof t.toString&&(t=Le.call(t)),De.call(e,t)?e[t].push(a):e[t]=[a]}),or),Co=qi(xi);function Vo(e){return Ws(e)?qa(e):Di(e)}function Io(e){return Ws(e)?qa(e,!0):Ri(e)}var Eo=In((function(e,t,a){$i(e,t,a)})),Fo=In((function(e,t,a,i){$i(e,t,a,i)})),Do=tr((function(e,t){var a={};if(null==e)return a;var i=!1;t=Et(t,(function(t){return t=bn(t,e),i||(i=t.length>1),t})),Cn(e,ir(e),a),i&&(a=si(a,7,Qn));for(var n=t.length;n--;)cn(a,t[n]);return a})),Ro=tr((function(e,t){return null==e?{}:function(e,t){return zi(e,t,(function(t,a){return To(e,a)}))}(e,t)}));function Po(e,t){if(null==e)return{};var a=Et(ir(e),(function(e){return[e]}));return t=or(t),zi(e,a,(function(e,a){return t(e,a[0])}))}var Lo=Zn(Vo),Bo=Zn(Io);function Oo(e){return null==e?[]:Kt(e,Vo(e))}var $o=Rn((function(e,t,a){return t=t.toLowerCase(),e+(a?Uo(t):t)}));function Uo(e){return Zo(go(e).toLowerCase())}function jo(e){return(e=go(e))&&e.replace(be,ta).replace(Xe,"")}var zo=Rn((function(e,t,a){return e+(a?"-":"")+t.toLowerCase()})),Wo=Rn((function(e,t,a){return e+(a?" ":"")+t.toLowerCase()})),Yo=Dn("toLowerCase"),Ho=Rn((function(e,t,a){return e+(a?"_":"")+t.toLowerCase()})),Go=Rn((function(e,t,a){return e+(a?" ":"")+Zo(t)})),qo=Rn((function(e,t,a){return e+(a?" ":"")+t.toUpperCase()})),Zo=Dn("toUpperCase");function Jo(e,t,i){return e=go(e),(t=i?a:t)===a?function(e){return at.test(e)}(e)?function(e){return e.match(et)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ko=qi((function(e,t){try{return St(e,a,t)}catch(e){return qs(e)?e:new Ae(e)}})),Xo=tr((function(e,t){return Tt(t,(function(t){t=Rr(t),ii(e,t,Ms(e[t],e))})),e}));function Qo(e){return function(){return e}}var el=Bn(),tl=Bn(!0);function al(e){return e}function il(e){return Fi("function"==typeof e?e:si(e,1))}var nl=qi((function(e,t){return function(a){return xi(a,e,t)}})),rl=qi((function(e,t){return function(a){return xi(e,a,t)}}));function sl(e,t,a){var i=Vo(t),n=wi(t,i);null!=a||Xs(t)&&(n.length||!i.length)||(a=t,t=e,e=this,n=wi(t,Vo(t)));var r=!(Xs(a)&&"chain"in a&&!a.chain),s=Zs(e);return Tt(n,(function(a){var i=t[a];e[a]=i,s&&(e.prototype[a]=function(){var t=this.__chain__;if(r||t){var a=e(this.__wrapped__);return(a.__actions__=xn(this.__actions__)).push({func:i,args:arguments,thisArg:e}),a.__chain__=t,a}return i.apply(e,Ft([this.value()],arguments))})})),e}function ol(){}var ll=jn(Et),ul=jn(xt),cl=jn(Pt);function dl(e){return vr(e)?Wt(Rr(e)):function(e){return function(t){return _i(t,e)}}(e)}var pl=Wn(),hl=Wn(!0);function fl(){return[]}function ml(){return!1}var yl,gl=Un((function(e,t){return e+t}),0),bl=Gn("ceil"),vl=Un((function(e,t){return e/t}),1),wl=Gn("floor"),_l=Un((function(e,t){return e*t}),1),Al=Gn("round"),kl=Un((function(e,t){return e-t}),0);return Ba.after=function(e,t){if("function"!=typeof t)throw new xe(i);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Ba.ary=Ns,Ba.assign=bo,Ba.assignIn=vo,Ba.assignInWith=wo,Ba.assignWith=_o,Ba.at=Ao,Ba.before=Ts,Ba.bind=Ms,Ba.bindAll=Xo,Ba.bindKey=xs,Ba.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return js(e)?e:[e]},Ba.chain=cs,Ba.chunk=function(e,t,i){t=(i?br(e,t,i):t===a)?1:ya(ho(t),0);var n=null==e?0:e.length;if(!n||t<1)return[];for(var r=0,s=0,o=ne(ht(n/t));r<n;)o[s++]=tn(e,r,r+=t);return o},Ba.compact=function(e){for(var t=-1,a=null==e?0:e.length,i=0,n=[];++t<a;){var r=e[t];r&&(n[i++]=r)}return n},Ba.concat=function(){var e=arguments.length;if(!e)return[];for(var t=ne(e-1),a=arguments[0],i=e;i--;)t[i-1]=arguments[i];return Ft(js(a)?xn(a):[a],mi(t,1))},Ba.cond=function(e){var t=null==e?0:e.length,a=or();return e=t?Et(e,(function(e){if("function"!=typeof e[1])throw new xe(i);return[a(e[0]),e[1]]})):[],qi((function(a){for(var i=-1;++i<t;){var n=e[i];if(St(n[0],this,a))return St(n[1],this,a)}}))},Ba.conforms=function(e){return function(e){var t=Vo(e);return function(a){return oi(a,e,t)}}(si(e,1))},Ba.constant=Qo,Ba.countBy=hs,Ba.create=function(e,t){var a=Oa(e);return null==t?a:ai(a,t)},Ba.curry=function e(t,i,n){var r=Jn(t,8,a,a,a,a,a,i=n?a:i);return r.placeholder=e.placeholder,r},Ba.curryRight=function e(t,i,n){var r=Jn(t,16,a,a,a,a,a,i=n?a:i);return r.placeholder=e.placeholder,r},Ba.debounce=Cs,Ba.defaults=ko,Ba.defaultsDeep=So,Ba.defer=Vs,Ba.delay=Is,Ba.difference=Br,Ba.differenceBy=Or,Ba.differenceWith=$r,Ba.drop=function(e,t,i){var n=null==e?0:e.length;return n?tn(e,(t=i||t===a?1:ho(t))<0?0:t,n):[]},Ba.dropRight=function(e,t,i){var n=null==e?0:e.length;return n?tn(e,0,(t=n-(t=i||t===a?1:ho(t)))<0?0:t):[]},Ba.dropRightWhile=function(e,t){return e&&e.length?pn(e,or(t,3),!0,!0):[]},Ba.dropWhile=function(e,t){return e&&e.length?pn(e,or(t,3),!0):[]},Ba.fill=function(e,t,i,n){var r=null==e?0:e.length;return r?(i&&"number"!=typeof i&&br(e,t,i)&&(i=0,n=r),function(e,t,i,n){var r=e.length;for((i=ho(i))<0&&(i=-i>r?0:r+i),(n=n===a||n>r?r:ho(n))<0&&(n+=r),n=i>n?0:fo(n);i<n;)e[i++]=t;return e}(e,t,i,n)):[]},Ba.filter=function(e,t){return(js(e)?Ct:fi)(e,or(t,3))},Ba.flatMap=function(e,t){return mi(_s(e,t),1)},Ba.flatMapDeep=function(e,t){return mi(_s(e,t),u)},Ba.flatMapDepth=function(e,t,i){return i=i===a?1:ho(i),mi(_s(e,t),i)},Ba.flatten=zr,Ba.flattenDeep=function(e){return null!=e&&e.length?mi(e,u):[]},Ba.flattenDepth=function(e,t){return null!=e&&e.length?mi(e,t=t===a?1:ho(t)):[]},Ba.flip=function(e){return Jn(e,512)},Ba.flow=el,Ba.flowRight=tl,Ba.fromPairs=function(e){for(var t=-1,a=null==e?0:e.length,i={};++t<a;){var n=e[t];i[n[0]]=n[1]}return i},Ba.functions=function(e){return null==e?[]:wi(e,Vo(e))},Ba.functionsIn=function(e){return null==e?[]:wi(e,Io(e))},Ba.groupBy=bs,Ba.initial=function(e){return null!=e&&e.length?tn(e,0,-1):[]},Ba.intersection=Yr,Ba.intersectionBy=Hr,Ba.intersectionWith=Gr,Ba.invert=Mo,Ba.invertBy=xo,Ba.invokeMap=vs,Ba.iteratee=il,Ba.keyBy=ws,Ba.keys=Vo,Ba.keysIn=Io,Ba.map=_s,Ba.mapKeys=function(e,t){var a={};return t=or(t,3),bi(e,(function(e,i,n){ii(a,t(e,i,n),e)})),a},Ba.mapValues=function(e,t){var a={};return t=or(t,3),bi(e,(function(e,i,n){ii(a,i,t(e,i,n))})),a},Ba.matches=function(e){return Bi(si(e,1))},Ba.matchesProperty=function(e,t){return Oi(e,si(t,1))},Ba.memoize=Es,Ba.merge=Eo,Ba.mergeWith=Fo,Ba.method=nl,Ba.methodOf=rl,Ba.mixin=sl,Ba.negate=Fs,Ba.nthArg=function(e){return e=ho(e),qi((function(t){return Ui(t,e)}))},Ba.omit=Do,Ba.omitBy=function(e,t){return Po(e,Fs(or(t)))},Ba.once=function(e){return Ts(2,e)},Ba.orderBy=function(e,t,i,n){return null==e?[]:(js(t)||(t=null==t?[]:[t]),js(i=n?a:i)||(i=null==i?[]:[i]),ji(e,t,i))},Ba.over=ll,Ba.overArgs=Ds,Ba.overEvery=ul,Ba.overSome=cl,Ba.partial=Rs,Ba.partialRight=Ps,Ba.partition=As,Ba.pick=Ro,Ba.pickBy=Po,Ba.property=dl,Ba.propertyOf=function(e){return function(t){return null==e?a:_i(e,t)}},Ba.pull=Zr,Ba.pullAll=Jr,Ba.pullAllBy=function(e,t,a){return e&&e.length&&t&&t.length?Wi(e,t,or(a,2)):e},Ba.pullAllWith=function(e,t,i){return e&&e.length&&t&&t.length?Wi(e,t,a,i):e},Ba.pullAt=Kr,Ba.range=pl,Ba.rangeRight=hl,Ba.rearg=Ls,Ba.reject=function(e,t){return(js(e)?Ct:fi)(e,Fs(or(t,3)))},Ba.remove=function(e,t){var a=[];if(!e||!e.length)return a;var i=-1,n=[],r=e.length;for(t=or(t,3);++i<r;){var s=e[i];t(s,i,e)&&(a.push(s),n.push(i))}return Yi(e,n),a},Ba.rest=function(e,t){if("function"!=typeof e)throw new xe(i);return qi(e,t=t===a?t:ho(t))},Ba.reverse=Xr,Ba.sampleSize=function(e,t,i){return t=(i?br(e,t,i):t===a)?1:ho(t),(js(e)?Ja:Ji)(e,t)},Ba.set=function(e,t,a){return null==e?e:Ki(e,t,a)},Ba.setWith=function(e,t,i,n){return n="function"==typeof n?n:a,null==e?e:Ki(e,t,i,n)},Ba.shuffle=function(e){return(js(e)?Ka:en)(e)},Ba.slice=function(e,t,i){var n=null==e?0:e.length;return n?(i&&"number"!=typeof i&&br(e,t,i)?(t=0,i=n):(t=null==t?0:ho(t),i=i===a?n:ho(i)),tn(e,t,i)):[]},Ba.sortBy=ks,Ba.sortedUniq=function(e){return e&&e.length?sn(e):[]},Ba.sortedUniqBy=function(e,t){return e&&e.length?sn(e,or(t,2)):[]},Ba.split=function(e,t,i){return i&&"number"!=typeof i&&br(e,t,i)&&(t=i=a),(i=i===a?p:i>>>0)?(e=go(e))&&("string"==typeof t||null!=t&&!io(t))&&!(t=ln(t))&&na(e)?wn(da(e),0,i):e.split(t,i):[]},Ba.spread=function(e,t){if("function"!=typeof e)throw new xe(i);return t=null==t?0:ya(ho(t),0),qi((function(a){var i=a[t],n=wn(a,0,t);return i&&Ft(n,i),St(e,this,n)}))},Ba.tail=function(e){var t=null==e?0:e.length;return t?tn(e,1,t):[]},Ba.take=function(e,t,i){return e&&e.length?tn(e,0,(t=i||t===a?1:ho(t))<0?0:t):[]},Ba.takeRight=function(e,t,i){var n=null==e?0:e.length;return n?tn(e,(t=n-(t=i||t===a?1:ho(t)))<0?0:t,n):[]},Ba.takeRightWhile=function(e,t){return e&&e.length?pn(e,or(t,3),!1,!0):[]},Ba.takeWhile=function(e,t){return e&&e.length?pn(e,or(t,3)):[]},Ba.tap=function(e,t){return t(e),e},Ba.throttle=function(e,t,a){var n=!0,r=!0;if("function"!=typeof e)throw new xe(i);return Xs(a)&&(n="leading"in a?!!a.leading:n,r="trailing"in a?!!a.trailing:r),Cs(e,t,{leading:n,maxWait:t,trailing:r})},Ba.thru=ds,Ba.toArray=co,Ba.toPairs=Lo,Ba.toPairsIn=Bo,Ba.toPath=function(e){return js(e)?Et(e,Rr):so(e)?[e]:xn(Dr(go(e)))},Ba.toPlainObject=yo,Ba.transform=function(e,t,a){var i=js(e),n=i||Hs(e)||oo(e);if(t=or(t,4),null==a){var r=e&&e.constructor;a=n?i?new r:[]:Xs(e)&&Zs(r)?Oa(Ye(e)):{}}return(n?Tt:bi)(e,(function(e,i,n){return t(a,e,i,n)})),a},Ba.unary=function(e){return Ns(e,1)},Ba.union=Qr,Ba.unionBy=es,Ba.unionWith=ts,Ba.uniq=function(e){return e&&e.length?un(e):[]},Ba.uniqBy=function(e,t){return e&&e.length?un(e,or(t,2)):[]},Ba.uniqWith=function(e,t){return t="function"==typeof t?t:a,e&&e.length?un(e,a,t):[]},Ba.unset=function(e,t){return null==e||cn(e,t)},Ba.unzip=as,Ba.unzipWith=is,Ba.update=function(e,t,a){return null==e?e:dn(e,t,gn(a))},Ba.updateWith=function(e,t,i,n){return n="function"==typeof n?n:a,null==e?e:dn(e,t,gn(i),n)},Ba.values=Oo,Ba.valuesIn=function(e){return null==e?[]:Kt(e,Io(e))},Ba.without=ns,Ba.words=Jo,Ba.wrap=function(e,t){return Rs(gn(t),e)},Ba.xor=rs,Ba.xorBy=ss,Ba.xorWith=os,Ba.zip=ls,Ba.zipObject=function(e,t){return mn(e||[],t||[],Qa)},Ba.zipObjectDeep=function(e,t){return mn(e||[],t||[],Ki)},Ba.zipWith=us,Ba.entries=Lo,Ba.entriesIn=Bo,Ba.extend=vo,Ba.extendWith=wo,sl(Ba,Ba),Ba.add=gl,Ba.attempt=Ko,Ba.camelCase=$o,Ba.capitalize=Uo,Ba.ceil=bl,Ba.clamp=function(e,t,i){return i===a&&(i=t,t=a),i!==a&&(i=(i=mo(i))==i?i:0),t!==a&&(t=(t=mo(t))==t?t:0),ri(mo(e),t,i)},Ba.clone=function(e){return si(e,4)},Ba.cloneDeep=function(e){return si(e,5)},Ba.cloneDeepWith=function(e,t){return si(e,5,t="function"==typeof t?t:a)},Ba.cloneWith=function(e,t){return si(e,4,t="function"==typeof t?t:a)},Ba.conformsTo=function(e,t){return null==t||oi(e,t,Vo(t))},Ba.deburr=jo,Ba.defaultTo=function(e,t){return null==e||e!=e?t:e},Ba.divide=vl,Ba.endsWith=function(e,t,i){e=go(e),t=ln(t);var n=e.length,r=i=i===a?n:ri(ho(i),0,n);return(i-=t.length)>=0&&e.slice(i,r)==t},Ba.eq=Bs,Ba.escape=function(e){return(e=go(e))&&q.test(e)?e.replace(H,aa):e},Ba.escapeRegExp=function(e){return(e=go(e))&&ae.test(e)?e.replace(te,"\\$&"):e},Ba.every=function(e,t,i){var n=js(e)?xt:pi;return i&&br(e,t,i)&&(t=a),n(e,or(t,3))},Ba.find=fs,Ba.findIndex=Ur,Ba.findKey=function(e,t){return Bt(e,or(t,3),bi)},Ba.findLast=ms,Ba.findLastIndex=jr,Ba.findLastKey=function(e,t){return Bt(e,or(t,3),vi)},Ba.floor=wl,Ba.forEach=ys,Ba.forEachRight=gs,Ba.forIn=function(e,t){return null==e?e:yi(e,or(t,3),Io)},Ba.forInRight=function(e,t){return null==e?e:gi(e,or(t,3),Io)},Ba.forOwn=function(e,t){return e&&bi(e,or(t,3))},Ba.forOwnRight=function(e,t){return e&&vi(e,or(t,3))},Ba.get=No,Ba.gt=Os,Ba.gte=$s,Ba.has=function(e,t){return null!=e&&fr(e,t,Ni)},Ba.hasIn=To,Ba.head=Wr,Ba.identity=al,Ba.includes=function(e,t,a,i){e=Ws(e)?e:Oo(e),a=a&&!i?ho(a):0;var n=e.length;return a<0&&(a=ya(n+a,0)),ro(e)?a<=n&&e.indexOf(t,a)>-1:!!n&&$t(e,t,a)>-1},Ba.indexOf=function(e,t,a){var i=null==e?0:e.length;if(!i)return-1;var n=null==a?0:ho(a);return n<0&&(n=ya(i+n,0)),$t(e,t,n)},Ba.inRange=function(e,t,i){return t=po(t),i===a?(i=t,t=0):i=po(i),function(e,t,a){return e>=ga(t,a)&&e<ya(t,a)}(e=mo(e),t,i)},Ba.invoke=Co,Ba.isArguments=Us,Ba.isArray=js,Ba.isArrayBuffer=zs,Ba.isArrayLike=Ws,Ba.isArrayLikeObject=Ys,Ba.isBoolean=function(e){return!0===e||!1===e||Qs(e)&&ki(e)==y},Ba.isBuffer=Hs,Ba.isDate=Gs,Ba.isElement=function(e){return Qs(e)&&1===e.nodeType&&!ao(e)},Ba.isEmpty=function(e){if(null==e)return!0;if(Ws(e)&&(js(e)||"string"==typeof e||"function"==typeof e.splice||Hs(e)||oo(e)||Us(e)))return!e.length;var t=hr(e);if(t==_||t==T)return!e.size;if(Ar(e))return!Di(e).length;for(var a in e)if(De.call(e,a))return!1;return!0},Ba.isEqual=function(e,t){return Vi(e,t)},Ba.isEqualWith=function(e,t,i){var n=(i="function"==typeof i?i:a)?i(e,t):a;return n===a?Vi(e,t,a,i):!!n},Ba.isError=qs,Ba.isFinite=function(e){return"number"==typeof e&&Lt(e)},Ba.isFunction=Zs,Ba.isInteger=Js,Ba.isLength=Ks,Ba.isMap=eo,Ba.isMatch=function(e,t){return e===t||Ii(e,t,ur(t))},Ba.isMatchWith=function(e,t,i){return i="function"==typeof i?i:a,Ii(e,t,ur(t),i)},Ba.isNaN=function(e){return to(e)&&e!=+e},Ba.isNative=function(e){if(_r(e))throw new Ae("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Ei(e)},Ba.isNil=function(e){return null==e},Ba.isNull=function(e){return null===e},Ba.isNumber=to,Ba.isObject=Xs,Ba.isObjectLike=Qs,Ba.isPlainObject=ao,Ba.isRegExp=io,Ba.isSafeInteger=function(e){return Js(e)&&e>=-9007199254740991&&e<=c},Ba.isSet=no,Ba.isString=ro,Ba.isSymbol=so,Ba.isTypedArray=oo,Ba.isUndefined=function(e){return e===a},Ba.isWeakMap=function(e){return Qs(e)&&hr(e)==C},Ba.isWeakSet=function(e){return Qs(e)&&"[object WeakSet]"==ki(e)},Ba.join=function(e,t){return null==e?"":Yt.call(e,t)},Ba.kebabCase=zo,Ba.last=qr,Ba.lastIndexOf=function(e,t,i){var n=null==e?0:e.length;if(!n)return-1;var r=n;return i!==a&&(r=(r=ho(i))<0?ya(n+r,0):ga(r,n-1)),t==t?function(e,t,a){for(var i=a+1;i--;)if(e[i]===t)return i;return i}(e,t,r):Ot(e,jt,r,!0)},Ba.lowerCase=Wo,Ba.lowerFirst=Yo,Ba.lt=lo,Ba.lte=uo,Ba.max=function(e){return e&&e.length?hi(e,al,Si):a},Ba.maxBy=function(e,t){return e&&e.length?hi(e,or(t,2),Si):a},Ba.mean=function(e){return zt(e,al)},Ba.meanBy=function(e,t){return zt(e,or(t,2))},Ba.min=function(e){return e&&e.length?hi(e,al,Pi):a},Ba.minBy=function(e,t){return e&&e.length?hi(e,or(t,2),Pi):a},Ba.stubArray=fl,Ba.stubFalse=ml,Ba.stubObject=function(){return{}},Ba.stubString=function(){return""},Ba.stubTrue=function(){return!0},Ba.multiply=_l,Ba.nth=function(e,t){return e&&e.length?Ui(e,ho(t)):a},Ba.noConflict=function(){return pt._===this&&(pt._=Oe),this},Ba.noop=ol,Ba.now=Ss,Ba.pad=function(e,t,a){e=go(e);var i=(t=ho(t))?ca(e):0;if(!t||i>=t)return e;var n=(t-i)/2;return zn(ft(n),a)+e+zn(ht(n),a)},Ba.padEnd=function(e,t,a){e=go(e);var i=(t=ho(t))?ca(e):0;return t&&i<t?e+zn(t-i,a):e},Ba.padStart=function(e,t,a){e=go(e);var i=(t=ho(t))?ca(e):0;return t&&i<t?zn(t-i,a)+e:e},Ba.parseInt=function(e,t,a){return a||null==t?t=0:t&&(t=+t),va(go(e).replace(ie,""),t||0)},Ba.random=function(e,t,i){if(i&&"boolean"!=typeof i&&br(e,t,i)&&(t=i=a),i===a&&("boolean"==typeof t?(i=t,t=a):"boolean"==typeof e&&(i=e,e=a)),e===a&&t===a?(e=0,t=1):(e=po(e),t===a?(t=e,e=0):t=po(t)),e>t){var n=e;e=t,t=n}if(i||e%1||t%1){var r=wa();return ga(e+r*(t-e+lt("1e-"+((r+"").length-1))),t)}return Hi(e,t)},Ba.reduce=function(e,t,a){var i=js(e)?Dt:Ht,n=arguments.length<3;return i(e,or(t,4),a,n,ci)},Ba.reduceRight=function(e,t,a){var i=js(e)?Rt:Ht,n=arguments.length<3;return i(e,or(t,4),a,n,di)},Ba.repeat=function(e,t,i){return t=(i?br(e,t,i):t===a)?1:ho(t),Gi(go(e),t)},Ba.replace=function(){var e=arguments,t=go(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Ba.result=function(e,t,i){var n=-1,r=(t=bn(t,e)).length;for(r||(r=1,e=a);++n<r;){var s=null==e?a:e[Rr(t[n])];s===a&&(n=r,s=i),e=Zs(s)?s.call(e):s}return e},Ba.round=Al,Ba.runInContext=e,Ba.sample=function(e){return(js(e)?Za:Zi)(e)},Ba.size=function(e){if(null==e)return 0;if(Ws(e))return ro(e)?ca(e):e.length;var t=hr(e);return t==_||t==T?e.size:Di(e).length},Ba.snakeCase=Ho,Ba.some=function(e,t,i){var n=js(e)?Pt:an;return i&&br(e,t,i)&&(t=a),n(e,or(t,3))},Ba.sortedIndex=function(e,t){return nn(e,t)},Ba.sortedIndexBy=function(e,t,a){return rn(e,t,or(a,2))},Ba.sortedIndexOf=function(e,t){var a=null==e?0:e.length;if(a){var i=nn(e,t);if(i<a&&Bs(e[i],t))return i}return-1},Ba.sortedLastIndex=function(e,t){return nn(e,t,!0)},Ba.sortedLastIndexBy=function(e,t,a){return rn(e,t,or(a,2),!0)},Ba.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var a=nn(e,t,!0)-1;if(Bs(e[a],t))return a}return-1},Ba.startCase=Go,Ba.startsWith=function(e,t,a){return e=go(e),a=null==a?0:ri(ho(a),0,e.length),t=ln(t),e.slice(a,a+t.length)==t},Ba.subtract=kl,Ba.sum=function(e){return e&&e.length?Gt(e,al):0},Ba.sumBy=function(e,t){return e&&e.length?Gt(e,or(t,2)):0},Ba.template=function(e,t,i){var n=Ba.templateSettings;i&&br(e,t,i)&&(t=a),e=go(e),t=wo({},t,n,Kn);var r,s,o=wo({},t.imports,n.imports,Kn),l=Vo(o),u=Kt(o,l),c=0,d=t.interpolate||ve,p="__p += '",h=Te((t.escape||ve).source+"|"+d.source+"|"+(d===K?de:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),f="//# sourceURL="+(De.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++nt+"]")+"\n";e.replace(h,(function(t,a,i,n,o,l){return i||(i=n),p+=e.slice(c,l).replace(we,ia),a&&(r=!0,p+="' +\n__e("+a+") +\n'"),o&&(s=!0,p+="';\n"+o+";\n__p += '"),i&&(p+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),c=l+t.length,t})),p+="';\n";var m=De.call(t,"variable")&&t.variable;if(m){if(ue.test(m))throw new Ae("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(s?p.replace(j,""):p).replace(z,"$1").replace(W,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(r?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var y=Ko((function(){return ke(l,f+"return "+p).apply(a,u)}));if(y.source=p,qs(y))throw y;return y},Ba.times=function(e,t){if((e=ho(e))<1||e>c)return[];var a=p,i=ga(e,p);t=or(t),e-=p;for(var n=qt(i,t);++a<e;)t(a);return n},Ba.toFinite=po,Ba.toInteger=ho,Ba.toLength=fo,Ba.toLower=function(e){return go(e).toLowerCase()},Ba.toNumber=mo,Ba.toSafeInteger=function(e){return e?ri(ho(e),-9007199254740991,c):0===e?e:0},Ba.toString=go,Ba.toUpper=function(e){return go(e).toUpperCase()},Ba.trim=function(e,t,i){if((e=go(e))&&(i||t===a))return Zt(e);if(!e||!(t=ln(t)))return e;var n=da(e),r=da(t);return wn(n,Qt(n,r),ea(n,r)+1).join("")},Ba.trimEnd=function(e,t,i){if((e=go(e))&&(i||t===a))return e.slice(0,pa(e)+1);if(!e||!(t=ln(t)))return e;var n=da(e);return wn(n,0,ea(n,da(t))+1).join("")},Ba.trimStart=function(e,t,i){if((e=go(e))&&(i||t===a))return e.replace(ie,"");if(!e||!(t=ln(t)))return e;var n=da(e);return wn(n,Qt(n,da(t))).join("")},Ba.truncate=function(e,t){var i=30,n="...";if(Xs(t)){var r="separator"in t?t.separator:r;i="length"in t?ho(t.length):i,n="omission"in t?ln(t.omission):n}var s=(e=go(e)).length;if(na(e)){var o=da(e);s=o.length}if(i>=s)return e;var l=i-ca(n);if(l<1)return n;var u=o?wn(o,0,l).join(""):e.slice(0,l);if(r===a)return u+n;if(o&&(l+=u.length-l),io(r)){if(e.slice(l).search(r)){var c,d=u;for(r.global||(r=Te(r.source,go(pe.exec(r))+"g")),r.lastIndex=0;c=r.exec(d);)var p=c.index;u=u.slice(0,p===a?l:p)}}else if(e.indexOf(ln(r),l)!=l){var h=u.lastIndexOf(r);h>-1&&(u=u.slice(0,h))}return u+n},Ba.unescape=function(e){return(e=go(e))&&G.test(e)?e.replace(Y,ha):e},Ba.uniqueId=function(e){var t=++Re;return go(e)+t},Ba.upperCase=qo,Ba.upperFirst=Zo,Ba.each=ys,Ba.eachRight=gs,Ba.first=Wr,sl(Ba,(yl={},bi(Ba,(function(e,t){De.call(Ba.prototype,t)||(yl[t]=e)})),yl),{chain:!1}),Ba.VERSION="4.17.21",Tt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Ba[e].placeholder=Ba})),Tt(["drop","take"],(function(e,t){ja.prototype[e]=function(i){i=i===a?1:ya(ho(i),0);var n=this.__filtered__&&!t?new ja(this):this.clone();return n.__filtered__?n.__takeCount__=ga(i,n.__takeCount__):n.__views__.push({size:ga(i,p),type:e+(n.__dir__<0?"Right":"")}),n},ja.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Tt(["filter","map","takeWhile"],(function(e,t){var a=t+1,i=1==a||3==a;ja.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:or(e,3),type:a}),t.__filtered__=t.__filtered__||i,t}})),Tt(["head","last"],(function(e,t){var a="take"+(t?"Right":"");ja.prototype[e]=function(){return this[a](1).value()[0]}})),Tt(["initial","tail"],(function(e,t){var a="drop"+(t?"":"Right");ja.prototype[e]=function(){return this.__filtered__?new ja(this):this[a](1)}})),ja.prototype.compact=function(){return this.filter(al)},ja.prototype.find=function(e){return this.filter(e).head()},ja.prototype.findLast=function(e){return this.reverse().find(e)},ja.prototype.invokeMap=qi((function(e,t){return"function"==typeof e?new ja(this):this.map((function(a){return xi(a,e,t)}))})),ja.prototype.reject=function(e){return this.filter(Fs(or(e)))},ja.prototype.slice=function(e,t){e=ho(e);var i=this;return i.__filtered__&&(e>0||t<0)?new ja(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==a&&(i=(t=ho(t))<0?i.dropRight(-t):i.take(t-e)),i)},ja.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ja.prototype.toArray=function(){return this.take(p)},bi(ja.prototype,(function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),n=/^(?:head|last)$/.test(t),r=Ba[n?"take"+("last"==t?"Right":""):t],s=n||/^find/.test(t);r&&(Ba.prototype[t]=function(){var t=this.__wrapped__,o=n?[1]:arguments,l=t instanceof ja,u=o[0],c=l||js(t),d=function(e){var t=r.apply(Ba,Ft([e],o));return n&&p?t[0]:t};c&&i&&"function"==typeof u&&1!=u.length&&(l=c=!1);var p=this.__chain__,h=!!this.__actions__.length,f=s&&!p,m=l&&!h;if(!s&&c){t=m?t:new ja(this);var y=e.apply(t,o);return y.__actions__.push({func:ds,args:[d],thisArg:a}),new Ua(y,p)}return f&&m?e.apply(this,o):(y=this.thru(d),f?n?y.value()[0]:y.value():y)})})),Tt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ce[e],a=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);Ba.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var n=this.value();return t.apply(js(n)?n:[],e)}return this[a]((function(a){return t.apply(js(a)?a:[],e)}))}})),bi(ja.prototype,(function(e,t){var a=Ba[t];if(a){var i=a.name+"";De.call(Ca,i)||(Ca[i]=[]),Ca[i].push({name:t,func:a})}})),Ca[On(a,2).name]=[{name:"wrapper",func:a}],ja.prototype.clone=function(){var e=new ja(this.__wrapped__);return e.__actions__=xn(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=xn(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=xn(this.__views__),e},ja.prototype.reverse=function(){if(this.__filtered__){var e=new ja(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},ja.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,a=js(e),i=t<0,n=a?e.length:0,r=function(e,t,a){for(var i=-1,n=a.length;++i<n;){var r=a[i],s=r.size;switch(r.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=ga(t,e+s);break;case"takeRight":e=ya(e,t-s)}}return{start:e,end:t}}(0,n,this.__views__),s=r.start,o=r.end,l=o-s,u=i?o:s-1,c=this.__iteratees__,d=c.length,p=0,h=ga(l,this.__takeCount__);if(!a||!i&&n==l&&h==l)return hn(e,this.__actions__);var f=[];e:for(;l--&&p<h;){for(var m=-1,y=e[u+=t];++m<d;){var g=c[m],b=g.iteratee,v=g.type,w=b(y);if(2==v)y=w;else if(!w){if(1==v)continue e;break e}}f[p++]=y}return f},Ba.prototype.at=ps,Ba.prototype.chain=function(){return cs(this)},Ba.prototype.commit=function(){return new Ua(this.value(),this.__chain__)},Ba.prototype.next=function(){this.__values__===a&&(this.__values__=co(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?a:this.__values__[this.__index__++]}},Ba.prototype.plant=function(e){for(var t,i=this;i instanceof $a;){var n=Lr(i);n.__index__=0,n.__values__=a,t?r.__wrapped__=n:t=n;var r=n;i=i.__wrapped__}return r.__wrapped__=e,t},Ba.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof ja){var t=e;return this.__actions__.length&&(t=new ja(this)),(t=t.reverse()).__actions__.push({func:ds,args:[Xr],thisArg:a}),new Ua(t,this.__chain__)}return this.thru(Xr)},Ba.prototype.toJSON=Ba.prototype.valueOf=Ba.prototype.value=function(){return hn(this.__wrapped__,this.__actions__)},Ba.prototype.first=Ba.prototype.head,Je&&(Ba.prototype[Je]=function(){return this}),Ba}();ft?((ft.exports=fa)._=fa,ht._=fa):pt._=fa}).call(G)}(H,H.exports)),H.exports);class Z extends ${name="";displayName="";type=void 0;info;preload=!0;loadingManagerRule="load";item;itemRepo;condition;conditionFields=[];conditionFieldNames=[];dependantFields=[];dependenciesInitialized=!1;linkableTypes=[];collapsed=!1;presets=[];datatype=null;defaultValue=null;minValue=null;maxValue=null;language=null;widget=null;length=null;labelType=null;blocks=[];connections=[];_id="";_internalValue;_internalOptions=[];_updateConditions=!0;_hidden=!1;get hidden(){return!(!this.condition||!this.dependenciesInitialized)&&(this._updateConditions&&(this._hidden=!this._calculateConditionBlock(this.condition),this._updateConditions=!1),this._hidden)}get id(){return this._id}get options(){return this._internalOptions}set options(e){this._internalOptions=e}get value(){return this._internalValue}set value(e){this._internalValue=e,this._processDependencies()}constructor(e,t=void 0,a=void 0,i=void 0,n=void 0,r=void 0){super(n),e instanceof O?(this._id=e.id,this.restoreFromSnapshot(e)):(h.assert(e,"Field has no name!"),h.assert(a,"Field has no type!"),this._id=h.createFieldID(),this.name=e,this.displayName=t||e,this.type=a,this._internalValue=i,this.item=n,this.itemRepo=r)}updateConditions(){this.condition&&this.dependenciesInitialized&&(this._updateConditions=!0,u.$emit("field:hiddenChanged",this.id))}getId(){return this.id}resetValue(){this.value=this.defaultValue}makeIdsUnique(e=new Map,t=!1){if(e.has(this._id)||t){const t=h.createFieldID();e.set(this._id,t),this._id=t}else e.set(this._id,this._id);for(const a of this.blocks)a.makeIdsUnique(e,t);return e}transformNodeIds(e){for(const t of this.blocks)t.transformNodeIds(e);"Attribute"===this.type&&"Node"===this.datatype&&this.value&&e.has(this.value)&&(this.value=e.get(this.value))}findBlock(e){for(const t of this.blocks){const a=t.findBlock(e);if(a)return a}return null}clone(e=void 0,t=!1){let a=new Z(this.name,this.displayName,this.type);void 0===this._internalValue?a._internalValue=void 0:null===this._internalValue?a._internalValue=null:"Link"===this.type?a._internalValue=this._internalValue:a._internalValue=q.cloneDeep(this._internalValue),a.info=this.info,a.preload=this.preload,a.loadingManagerRule=this.loadingManagerRule,a.item=this.item,a.ownerItem=this.ownerItem,a.itemRepo=this.itemRepo,a.condition=this.condition,a.conditionFields=this.conditionFields,a.conditionFieldNames=this.conditionFieldNames,a.dependantFields=this.dependantFields,a.collapsed=this.collapsed,a.presets=this.presets,a.labelType=this.labelType,a.datatype=this.datatype,a.defaultValue=this.defaultValue,a.minValue=this.minValue,a.maxValue=this.maxValue,a.options=this.options,a.language=this.language,a.widget=this.widget,a.length=this.length,a.linkableTypes=this.linkableTypes;for(const i of this.blocks){let n=i.clone(e,!0,{},t);e&&(n=g.instance.proxyBlock(n,e)),a.blocks.push(n)}for(const t of this.connections){let i=t.clone();e&&(i=g.instance.proxyConnection(i,e)),a.connections.push(i)}return a}_processDependencies(){for(const e of this.dependantFields)e.updateConditions()}_getConditionField(e){for(const t of this.conditionFields)if(t&&t.name===e)return t;return null}_calculateConditionField(e,t){if(!e.startsWith("$")){let a;e.includes(".")?(a=e.split("."),e=a.splice(0,1)[0]):a=[];let i=e.endsWith("?");i&&(e=e.substring(0,e.length-1));const n=this._getConditionField(e);if(!n)return i||console.error("Field to resolve condition not found: "+e),!1;let r=n.value;for(let t=0;t<a.length;t++){if(!r)return console.error(`Field path ${a.join(".")} not found in field ${e}!`),!1;r=r[a[t]]}return"object"==typeof t?void 0!==t.$isset?t.$isset===!!r:void 0!==t.$not?t.$not!==r:(console.error("Condition value cannot be interpreted: ",t,this),!1):n.value==t}switch(e){case"$isroot":return this.item._id===this.itemRepo.rootItemId===t;case"$parenttype":return console.log("$parenttype is not yet implemented!",this),!1;case"$optionsexist":return(Array.isArray(this.options)&&this.options.length>0)===t;case"$featureenabled":return this.itemRepo.apiClient.isFeatureEnabled(t);default:return console.error("Computed value unknown: "+e,this),!1}}_calculateConditionBlock(e){for(const t in e)if(e.hasOwnProperty(t)){const a=e[t];if("$or"===t)if(Array.isArray(a)){let e=!1;for(const t of a)if(this._calculateConditionBlock(t)){e=!0;break}if(!e)return!1}else console.error("Condition contains $or but its value is not an array!");else if("$not"===t){if("object"!=typeof a)console.error("When using the $not operator, the value needs to be an object");else if(this._calculateConditionBlock(a))return!1}else if(!this._calculateConditionField(t,a))return!1}return!0}refreshFieldDependencies(){for(const e of this.blocks)e.refreshFieldDependencies()}refreshDependantFields(e,t){const a=[];if(this.condition)for(let t of this.conditionFieldNames){const i=t.endsWith("?");i&&(t=t.substring(0,t.length-1));const n=e.get(t);n?a.push(n):i||console.warn("Condition field not found: "+t)}this.conditionFields=a,this.dependantFields=t||[],this.dependenciesInitialized=!0}setCondition(e){e?"object"==typeof e?this.condition=e:(console.error("Condition must be an object if set",e),this.condition=null):this.condition=null,this.conditionFieldNames=[],this.condition&&this._scanConditions(this.condition)}_scanConditions(e){for(let t in e)if(e.hasOwnProperty(t)){const a=e[t];if(Array.isArray(a))for(const e of a)this._scanConditions(e);else t.startsWith("$")||(t.includes(".")&&(t=t.split(".")[0]),this.conditionFieldNames.includes(t)||this.conditionFieldNames.push(t))}}forEachField(e){if(e(this),this.blocks)for(const t of this.blocks)t.forEachField(e)}setInfo(e){this.info=e}setPreload(e){this.preload=e}setLoadingManagerRule(e){this.loadingManagerRule=e}setLinkableTypes(e){this.linkableTypes=e}setDefaultValue(e){this.defaultValue=e,void 0!==this._internalValue&&null!==this._internalValue||(this._internalValue=e)}setMinValue(e){this.minValue=e}setMaxValue(e){this.maxValue=e}setOptions(e){this.options=e}setDatatype(e){this.datatype=e}setLanguage(e){this.language=e}setLength(e){this.length=e}setWidget(e){this.widget=e}setBlocks(e){this.blocks=e}setConnections(e){this.connections=e}setCollapsed(e){this.collapsed=!!e}setPresets(e){this.presets=e||[]}setLabelType(e){this.labelType=e||"info"}createSnapshot(e=!1){h.assert(this.id,"Field has no ID. Cannot create snapshot");const t=[];for(const a of this.blocks)t.push(a.createSnapshot(e));const a=[];for(const e of this.connections)a.push(e.createSnapshot());return new O(this.id,"field",{name:this.name,displayName:this.displayName,type:this.type,value:this._internalValue,preload:this.preload,info:this.info,loadingManagerRule:this.loadingManagerRule,item:this.item,itemRepo:this.itemRepo,condition:this.condition,conditionFields:this.conditionFields,conditionFieldNames:this.conditionFieldNames,dependantFields:this.dependantFields,linkableTypes:this.linkableTypes,collapsed:this.collapsed,presets:this.presets,datatype:this.datatype,defaultValue:this.defaultValue,minValue:this.minValue,maxValue:this.maxValue,options:this.options,language:this.language,widget:this.widget,length:this.length,labelType:this.labelType,blocks:t,connections:a})}restoreFromSnapshot(e){e.id===this.id?(this.name=e.data.name,this.displayName=e.data.displayName,this.type=e.data.type,this._internalValue=e.data.value,this.info=e.data.info,this.preload=e.data.preload,this.loadingManagerRule=e.data.loadingManagerRule,this.item=e.data.item,this.ownerItem=e.data.item,this.itemRepo=e.data.itemRepo,this.condition=e.data.condition,this.conditionFields=e.data.conditionFields,this.conditionFieldNames=e.data.conditionFieldNames,this.dependantFields=e.data.dependantFields,this.linkableTypes=e.data.linkableTypes,this.collapsed=e.data.collapsed,this.presets=e.data.presets,this.datatype=e.data.datatype,this.defaultValue=e.data.defaultValue,this.minValue=e.data.minValue,this.maxValue=e.data.maxValue,this.options=e.data.options,this.language=e.data.language,this.widget=e.data.widget,this.length=e.data.length,this.labelType=e.data.labelType,this.blocks=[],this.connections=[],this._rollbackArray(this.blocks,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem))),this._rollbackArray(this.connections,e.data.connections,((e,t)=>g.instance.proxyConnection(new U(e.data,t),this.ownerItem)))):console.error("Snapshot ID does not match! Cannot rollback!",this,e)}rollbackFromSnapshot(e){this.value=e.data.value,this._rollbackArray(this.blocks,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem))),this._rollbackArray(this.connections,e.data.connections,((e,t)=>g.instance.proxyConnection(new U(e.data,t),this.ownerItem)))}}class J extends ${id;name=void 0;displayName=void 0;value;type=void 0;datatype=void 0;linkableTypes=[];order=0;constructor(e=void 0,t=void 0,a=void 0){super(a),this.value=t,this.id=h.createItemOrBlockID(),this.name=e,this.displayName=e,this._updateDisplayName()}getId(){return this.id}setName(e){this.name=e,this._updateDisplayName()}setType(e){this.type=e}setOrder(e){this.order=e}clone(e=new Map){const t=new J;return t.ownerItem=this.ownerItem,t.value=e.get(this.value)??this.value,t.type=this.type,t.order=this.order,t.setName(this.name),t}clearDefinition(){this.type=void 0}setDefinition(e){const t=e.type.toLowerCase();switch(t){case"boolean":case"bool":this.type="Attribute",this.datatype="Boolean",this.value=void 0!==this.value?this._toBoolean(this.value):this._toBoolean(e.defaultValue);break;case"float":this.type="Attribute",this.datatype="Float",this.value=void 0!==this.value?Number(this.value):Number(e.defaultValue);break;case"int":this.type="Attribute",this.datatype="Integer",this.value=void 0!==this.value?parseInt(this.value):parseInt(e.defaultValue);break;case"string":this.type="Attribute",this.datatype="String",this.value=void 0!==this.value&&null!==this.value?this.value.toString():e.defaultValue?e.defaultValue.toString():"";break;case"vec2":this.type="Attribute",this.datatype="Vector2d";break;case"vec3":this.type="Attribute",this.datatype="Vector3d";break;case"vec4":this.type="Attribute",this.datatype="Vector4d";break;case"mat3":this.type="Attribute",this.datatype="Mat3";break;case"mat4":this.type="Attribute",this.datatype="Mat4";break;case"color":this.type="Attribute",this.datatype="Color";break;case"image":this.type="Link",this.linkableTypes=["Image"];break;default:console.error("Unknown script field type: "+t),this.type="Attribute",this.datatype="String",this.value=this.value?this.value.toString():e.defaultValue?e.defaultValue.toString():""}}_toBoolean(e){return null!=e&&(!0===e||!1===e?e:"false"!==e.toString().toLowerCase())}_updateDisplayName(){this.name?this.displayName=h.toUserFriendlyName(this.name):this.displayName=""}createSnapshot(){return new O(this.id,"customfield",{id:this.id,value:this.value})}rollbackFromSnapshot(e){this.value=e.data.value}}class K extends M{links;instanceId;isDirty=!1;fieldInstances;userFieldInstances;customFieldInstances;packageContent;packageType;public=!1;readOnly=!1;isPackaged=!1;isGenerated=!1;packageItem;isPreparedItem=!0;resultingAcl;constructor(e){if(super(e),this.instanceId=h.createItemOrBlockID(),this.links=[],Array.isArray(e.links))for(const t of e.links)this.links.push({to:t.to,usage:t.usage,stopRecursion:t.stopRecursion,item:t.item});this.fieldInstances=[],this.userFieldInstances=[],this.customFieldInstances=g.instance.proxyCustomFieldsArray([],this),this.public=!!e.public,this.packageContent=e.packageContent,this.packageType=e.packageType,this.packageItem=e.packageItem,this.readOnly=!!e.readOnly,this.isPackaged=!!e.isPackaged,this.isGenerated=!!e.isGenerated,this.resultingAcl=JSON.parse(JSON.stringify(e.resultingAcl||[]))}createCustomFieldInstances(e){function t(e,t){for(const a of e)if(a.name===t)return a;return null}for(const a of this.customFieldInstances)t(e,a.name)||a.clearDefinition();let a=0;for(const i of e){let e=t(this.customFieldInstances,i.name);e||(e=new J(i.name,i.defaultValue,this),this.addCustomField(e)),e.setOrder(a++),e.setDefinition(i)}this.customFieldInstances.sort((function(e,t){return e.order-t.order}))}addCustomField(e){this.customFieldInstances.push(g.instance.proxyCustomField(e,this))}markDirty(){this.isDirty||(this.isDirty=!0,u.$emit("itemRepo:itemBecameDirty",this._id))}makeIdsUnique(){const e=new Map;for(const t of this.fieldInstances)t.makeIdsUnique(e,!0);this.packageContent&&this.packageContent.makeIdsUnique()}clone(e=!1){let t=new K(this);const a=new Map;for(const i of this.fieldInstances){const n=i.clone(this,!0);e&&n.makeIdsUnique(a,!0),t.fieldInstances.push(n)}if(e)for(const e of t.fieldInstances)e.transformNodeIds(a);return t}findBlock(e){for(const t of this.fieldInstances){const a=t.findBlock(e);if(a)return a}return null}refreshFieldDependencies(){te.refreshFieldDependencies(this.fieldInstances);for(const e of this.fieldInstances)e.refreshFieldDependencies()}forEachItem(e){if(e(this),this.links)for(const t of this.links)t.item&&t.item.forEachItem(e)}forEachFieldInstance(e){if(this.fieldInstances)for(const t of this.fieldInstances)t.forEachField(e)}toString(){return`PreparedItem(${JSON.stringify({_id:this._id,name:this.name,type:this.type})})`}}function X(e,t,a){if(e.admin||e.superadmin)return!0;if(!Array.isArray(t))return!0;for(const i of t)if(i.can.includes(a)){if(!i.user&&!i.group)return!0;if(i.user&&i.user===e._id)return!0;if(i.group)for(const t of e.groups){if("object"==typeof t&&t._id===i.group)return!0;if(t===i.group)return!0}}}class Q{fields;constructor(e){if(!Array.isArray(e))throw"Template fields need to be an array!";this.fields=e}clone(){const e=[];for(const t of this.fields)e.push(t.clone());return new Q(e)}specialize(e){for(const t of this.fields)void 0!==e[t.name]&&(t.defaultValue=e[t.name]);return this}instantiate(e){if(e)return this.fields;{const e=[];for(const t of this.fields)e.push(t.clone());return e}}}class ee{templates=new Map;templatesByField=new Map;static _instance;static get instance(){return this._instance||(this._instance=new this)}_existsTemplate(e,t){for(const a of e)if(a.typeName===t)return!0;return!1}addTemplates(e,t,a){const i=`${e}_${t}`,n=this.templatesByField.get(i)||[];for(const e of a){const t=`${i}_${e.typeName}`;this.templates.set(t,e),this._existsTemplate(n,e.typeName)||n.push(e)}this.templatesByField.set(i,n)}getTemplate(e,t,a){const i=`${e}_${t}_${a}`;return this.templates.get(i)}getTemplates(e,t){const a=`${e}_${t}`;return this.templatesByField.get(a)||[]}}class te{itemRepo;itemFetcher;constructor(e){this.itemRepo=e,this.itemFetcher=function(e){return e}}setItemFetcher(e){this.itemFetcher=e}setFieldsFromDatatypes(e){const t=C(e.type,!0);e.fields=t.fields||[],e.fieldSets=t.fieldSets||[]}async prepare(e){return e instanceof K?(console.warn("Trying to prepare an already prepared item: ",e),e):this.itemRepo.undoManager.ignore((async()=>{const t=new K(e);return this.setFieldsFromDatatypes(t),t.fieldInstances=await this.createFieldInstances(t,t.fields,t.attributes,"","attributes",!1),t.userFieldInstances=await this.createFieldInstances(t,t.userFields,t.userAttributes,"","userAttributes",!1),t.customFieldInstances=await this.createCustomFieldInstances(t,t.userAttributes,"_"),t.allowConversation=!!t.allowConversation,t.packageContent&&(t.packageContent.name=t.name,await this.itemRepo.traverseItems((e=>{e.readOnly=!0,e.isPackaged=!0,e.packageItem=t}),t.packageContent)),t.packageItem?(t.readOnly=!0,t.isPackaged=!0):(t.isPackaged=!1,t.resultingAcl&&t.resultingAcl.length>0?t.readOnly=!X(await this.itemRepo.apiClient.me(!0),t.resultingAcl,"write"):t.readOnly=!0),t}))}async createCustomFieldInstances(e,t,a=""){if(!e)throw new _("createCustomFieldInstances(): Item cannot be null!");if(!t)throw new _("createCustomFieldInstances(): attributes cannot be null!");const i=[];for(const n in t)if(!a.length||n.startsWith(a)){const r=n.substring(a.length);let s=new J(r,t[n],e);s.setType("Attribute"),i.push(g.instance.proxyCustomField(s,e))}if(e.links)for(const t of e.links)if(!a.length||t.usage.startsWith(a)){const n=t.usage.substring(a.length);let r,{id:s,linkItem:o,stopRecursion:l}=await this.fetchLinkValue(e,t.usage);o?r=o:l&&(r=s);let u=new J(n,r,e);u.setType("Link"),i.push(g.instance.proxyCustomField(u,e))}return i}async createFieldInstances(e,t,a,i,n,r=!1){if(!e)throw new _("createFieldInstances(): Item cannot be null!");if(!t)throw new _("createFieldInstances(): Fields cannot be null!");const s=[],o=i.length?`${i}->`:i;for(let a=0;a<t.length;a++){const i=t[a];if("FieldSet"===i.type){const n=this.getFieldSet(e,i.name);n?(t.splice(a,1,...structuredClone(n.fields)),a+=n.fields.length-1):console.error("Fieldset not found: "+i.name)}}for(const i of t)switch(i.type){case"Separator":{const t=new Z("Separator",i.label,"Separator",null,e,this.itemRepo);t.setInfo(i.info),t.setCondition(i.if),t.setCollapsed(i.collapsed),t.setPresets(i.presets),s.push(t);break}case"Label":{const t=new Z("Label","","Label",i.text,e,this.itemRepo);t.setLabelType(i.labelType),t.setCondition(i.if),s.push(t);break}case"Link":{let t;if(!r){let{id:a,linkItem:n,stopRecursion:r}=await this.fetchLinkValue(e,i.usageAs);n?t=n:r&&(t=a)}let a=new Z(i.usageAs,i.displayName,i.type,t,e,this.itemRepo);a.setInfo(i.info),a.setCondition(i.if),a.setLinkableTypes(i.linkableTypes),void 0!==i.preload&&a.setPreload(i.preload),void 0!==i.loadingManager&&a.setLoadingManagerRule(i.loadingManager),s.push(g.instance.proxyItemField(a,e));break}case"Tree":{const t=`${o}${i.name}`,r=[];for(const s of i.childTypes){const i=new Q(await this.createFieldInstances(e,s.fields,a,t,n,!0));r.push({typeName:s.typeName,displayName:s.displayName||s.typeName,template:i,inputs:[],outputs:[]})}r.sort((function(e,t){return e.displayName.localeCompare(t.displayName)})),ee.instance.addTemplates(e.type,i.name,r);const l=new ae(void 0,void 0,"","Root",void 0,e),u=await this.readBlocks(e,l,i.name,t,a,!0,!0,"Tree");l.blocks=g.instance.proxyBlockArray(u,l,e);let c=new Z(i.name,i.displayName,i.type,null,e,this.itemRepo);c.setInfo(i.info),c.setCondition(i.if),c.setBlocks([l]),s.push(c);break}case"List":{const t=`${o}${i.name}`,r=new Q(await this.createFieldInstances(e,i.fields,a,t,n,!0)),l=[{typeName:"Entry",displayName:i.elementName,template:r,inputs:[],outputs:[]}];ee.instance.addTemplates(e.type,i.name,l);let u=new Z(i.name,i.displayName,i.type,null,e,this.itemRepo);const c=await this.readBlocks(e,void 0,i.name,t,a,!0,!0,"List"),d=g.instance.proxyListArray(c,u,e);u.setInfo(i.info),u.setCondition(i.if),u.setBlocks(d),s.push(u);break}case"NodeGraph":{const t=`${o}${i.name}`,r=[];for(const s of i.childTypes){const i=new Q(await this.createFieldInstances(e,s.fields,a,t,n,!0));r.push({typeName:s.typeName,displayName:s.displayName||s.typeName,template:i,inputs:s.inputs||[],outputs:s.outputs||[]})}r.sort((function(e,t){return e.displayName.localeCompare(t.displayName)})),ee.instance.addTemplates(e.type,i.name,r);let l=await this.readBlocks(e,void 0,i.name,t,a,!1,!1,"NodeGraph"),u=this.readConnections(e,t,a),c=new Z(i.name,i.displayName,i.type,null,e,this.itemRepo);c.setInfo(i.info),c.setCondition(i.if),c.setBlocks(g.instance.proxyGraphBlockArray(l,e)),c.setConnections(g.instance.proxyConnectionArray(u,e)),s.push(c);break}case"Attribute":{let t;r||(t=e[n]?e[n][i.name]:void 0,void 0===t&&(t=i.defaultValue));let a=new Z(i.name,i.displayName,i.type,t,e,this.itemRepo);a.setInfo(i.info),a.setCondition(i.if),a.setDefaultValue(i.defaultValue),a.setMinValue(i.minValue),a.setMaxValue(i.maxValue),a.setOptions(i.options),a.setDatatype(i.datatype),a.setLanguage(i.language),a.setWidget(i.widget),a.setLength(i.length),s.push(g.instance.proxyItemField(a,e));break}}return s}getFieldSet(e,t){if(Array.isArray(e.fieldSets))for(const a of e.fieldSets)if(a.name===t)return a;return null}async fetchLinkValue(e,t){if(!e)throw new _("fetchLinkValue(): Item cannot be null!");for(const a of e.links)if(a.usage===t)return{id:a.to,linkItem:a.item?await this.itemFetcher(a.item):null,stopRecursion:a.stopRecursion};return{id:null,linkItem:null}}async readBlocks(e,t,a,i,n,r,s,o){if(!e)throw new _("readBlocks(): Item cannot be null!");const l=[];let u=0;for(;;){const c=`${i}[${u}]`;if(!this.existsBlockNamespace(e,n,c))break;{const i=`${c}#id`,u=e.attributes[i],d=`${c}#type`;let p,h,f=e.attributes[d];switch(o){case"NodeGraph":{const t=`${c}#posx`,a=`${c}#posy`;p=e.attributes[t]||0,h=e.attributes[a]||0;break}case"List":r=!1,f="Entry"}const m=ee.instance.getTemplate(e.packageType||e.type,a,f);if(m){const i=m.typeName,d=m.displayName,f=new ae(u,t,i,i,d,e),y=await this.createFields(f,e,m.template,c,"NodeGraph"===o,n);if(f.setFields(y),"NodeGraph"===o&&(f.setPosition(p,h),f.setInputs(m.inputs),f.setOutputs(m.outputs)),r){const t=await this.readBlocks(e,f,a,c,n,r,s,o);f.blocks=g.instance.proxyBlockArray(t,f,e)}if(s){const t=await this.readScripts(e,f,c,n);f.scripts=g.instance.proxyScriptArray(t,f,e)}"NodeGraph"===o?l.push(g.instance.proxyGraphBlock(f,e)):l.push(g.instance.proxyBlock(f,e))}else console.error(`Block template not found: ${a}_${f}`)}u++}return l}async readScripts(e,t,a,i){if(!e)throw new _("readScripts(): Item cannot be null!");const n=[];let r=0;for(;;){const s=`${a}#scripts[${r}]`;if(!this.existsScriptNamespace(e,i,s))break;{const a=i[`${s}#id`],r=`${s}#item`,o=`${s}->`,l=o.length;let{linkItem:u}=await this.fetchLinkValue(e,r);const c=new W(a,t,e,u);n.push(c);for(const t in i)if(i.hasOwnProperty(t)&&t.startsWith(o)){const a=i[t],n=t.substring(l),r=new j(c,n,a,e);c.addField(r)}}r++}return n}existsScriptNamespace(e,t,a){if(!e)throw new _("existsScriptNamespace(): Item cannot be null!");return"Script"===t[`${a}#usage`]}readConnections(e,t,a){const i=[];let n=0;for(;;){const r=a[`${t}#connection[${n++}]`];if(!r)break;i.push(new U(r,e))}return i}existsBlockNamespace(e,t,a){if(!e)throw new _("existsBlockNamespace(): Item cannot be null!");const i=t[`${a}#usage`];if(i)return"Block"===i;for(const e in t)if(t.hasOwnProperty(e)&&e.startsWith(a))return!0;for(const t of e.links)if(t.usage.startsWith(a))return!0;return!1}async createFields(e,t,a,i,n,r,s=!1){let o=a.instantiate(s),l=[];for(const a of o)if(a.name){const s=`${i}->${a.name}`;switch(a.type){case"Link":if(i){let{id:e,linkItem:i,stopRecursion:n}=await this.fetchLinkValue(t,s);a.value=i||(n?e:null)}else a.value=a.defaultValue;break;case"List":{const e=await this.readBlocks(t,void 0,a.name,s,r,!0,!0,"List"),i=g.instance.proxyListArray(e,a,t);a.setBlocks(i);break}case"Attribute":i?(a.value=t.attributes[s],void 0===a.value&&(a.value=a.defaultValue)):a.value=a.defaultValue}n?l.push(g.instance.proxyGraphBlockField(a,e,t)):l.push(g.instance.proxyBlockField(a,e,t))}return l}static refreshFieldDependencies(e){const t=new Map,a=new Map;for(const a of e)t.set(a.name,a);for(const i of e)if(Array.isArray(i.conditionFieldNames))for(const e of i.conditionFieldNames){const n=t.get(e);if(n){const e=a.get(n);e?e.push(i):a.set(n,[i])}}for(const i of e)i.refreshDependantFields(t,a.get(i))}}class ae extends ${id="";parent=void 0;type=void 0;name="";displayName="";fields=[];blocks=[];isSelected=!1;isExpanded=!0;scripts=[];inputs=[];outputs=[];posX=0;posY=0;constructor(e=void 0,t=void 0,a=void 0,i=void 0,n=void 0,r=void 0){super(r),e instanceof O?this.restoreFromSnapshot(e,t):(this.id=e||h.createItemOrBlockID(),this.parent=t,this.type=a,this.name=i||this.type||"",this.displayName=n||this.name)}getId(){return this.id}getPositionInParent(){if(this.parent){let e=0;for(const t of this.parent.blocks){if(t.id===this.id)return e;e++}}return-1}refreshFieldDependencies(){te.refreshFieldDependencies(this.fields);for(const e of this.fields)e.refreshFieldDependencies();for(const e of this.blocks)e.refreshFieldDependencies()}resetFieldValues(e=!1){for(const e of this.fields)e.resetValue();if(e)for(const t of this.blocks)t.resetFieldValues(e)}makeIdsUnique(e=new Map,t=!1){if(e.has(this.id)||t){const t=h.createItemOrBlockID();e.set(this.id,t),this.id=t}else e.set(this.id,this.id);for(const a of this.fields)a.makeIdsUnique(e,t);for(const a of this.blocks)a.makeIdsUnique(e,t);for(const a of this.scripts)a.makeIdsUnique(e,t);return e}transformNodeIds(e){for(const t of this.fields)t.transformNodeIds(e);for(const t of this.blocks)t.transformNodeIds(e);for(const t of this.scripts)t.transformNodeIds(e)}clone(e,t=!0,a={},i=!1){const n=new ae;i&&(n.id=this.id),n.ownerItem=this.ownerItem,n.parent=this.parent,n.type=this.type,n.name=this.name,n.displayName=this.displayName,n.isSelected=!1,n.isExpanded=!0,n.inputs=this.inputs,n.outputs=this.outputs,n.posX=0,n.posY=0;for(const t of this.fields){let r=t.clone(e,i);void 0!==a[t.name]&&(r.value=a[t.name]),e&&(r=g.instance.proxyBlockField(r,n,e)),n.fields.push(r)}if(e&&(n.scripts=g.instance.proxyScriptArray(n.scripts,n,e)),t)for(const e of this.scripts){const t=e.clone();n.scripts.push(t)}const r=n.blocks;e&&(n.blocks=g.instance.proxyBlockArray(r,n,e));for(const a of this.blocks){let s=a.clone(e,t,{},i);s.parent=n,e&&(s=g.instance.proxyBlock(s,e)),r.push(s)}return n}getDescendantBlocks(e=[]){const t=this.blocks;return e.push(...t),t.forEach((t=>t.getDescendantBlocks(e))),e}setFields(e){this.fields=e}setInputs(e){this.inputs=e}setOutputs(e){this.outputs=e}setPosition(e,t){this.posX=e,this.posY=t}setSelected(e){this.isSelected=e}setExpanded(e){this.isExpanded=e}getRoot(){return this.parent?this.parent.getRoot():this}forEachField(e){if(this.fields)for(const t of this.fields)t.forEachField(e);if(this.blocks)for(const t of this.blocks)t.forEachField(e)}findField(e){for(const t of this.fields)if(t.name===e)return t;return null}findBlock(e){if(this.id===e)return this;for(const t of this.blocks){const a=t.findBlock(e);if(a)return a}return null}removeBlock(e){this.blocks.removeObject(e)}addBlock(e,t){this.blocks.includes(e)||(void 0===t?this.blocks.push(e):this.blocks.splice(t,0,e))}moveBlock(e,t){e.parent.blocks.moveObjectToArray(e,e.parent.blocks,t)}moveToPosition(e){this.parent.moveBlock(this,e)}moveBlockToParent(e,t){this.parent.blocks.moveObjectToArray(this,e.blocks,t),this.parent=e}moveToParent(e,t){if(this.findBlock(e))return void console.error("Cannot move block to a parent that is a child.");const a=this.getRoot();if(!a)return void console.error("Cannot find root block!");const i=a.findBlock(e);i?this.parent!==i?this.moveBlockToParent(i,t):console.warn(`Node is already in parent ${e}`):console.error(`Cannot find the new parent block: ${e}`)}getField(e){for(const t of this.fields)if(t.name===e)return t;return null}hasTag(e){const t=this.getField("Tags");return!(!t||!Array.isArray(t.value))&&t.value.includes(e)}hasOneTag(e){const t=this.getField("Tags");if(t&&Array.isArray(t.value))for(const a of e)if(t.value.includes(a))return!0;return!1}getNameFieldValue(){const e=this.getField("Name");return e?e.value:null}getActiveFieldValue(){const e=this.getField("Active");return!e||e.value}createSnapshot(e=!1){const t=[];for(const a of this.fields)a.createSnapshot&&t.push(a.createSnapshot(e));const a=[];if(!e)for(const t of this.blocks)a.push(t.createSnapshot(e));const i=[];for(const e of this.scripts)i.push(e.createSnapshot());return new O(this.id,"block",{id:this.id,ownerItem:this.ownerItem,type:this.type,name:this.name,displayName:this.displayName,fields:t,blocks:a,isExpanded:this.isExpanded,scripts:i,inputs:this.inputs,outputs:this.outputs,posX:this.posX,posY:this.posY})}restoreFromSnapshot(e,t){this.id=e.data.id,this.parent=t,this.type=e.data.type,this.ownerItem=e.data.ownerItem,this.name=e.data.name,this.displayName=e.data.displayName,this.isSelected=!1,this.isExpanded=e.data.isExpanded,this.inputs=e.data.inputs,this.outputs=e.data.outputs,this.posX=e.data.posX,this.posY=e.data.posY;const a=[];this._rollbackArray(a,e.data.fields,(e=>g.instance.proxyBlockField(new Z(e),this,this.ownerItem))),this.fields=a;const i=[];this._rollbackArray(i,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem))),this.blocks=g.instance.proxyBlockArray(i,this,this.ownerItem);const n=[];this._rollbackArray(n,e.data.scripts,((e,t)=>new W(e,t,this.ownerItem))),this.scripts=g.instance.proxyScriptArray(n,this,this.ownerItem)}rollbackFromSnapshot(e,t=!1){this._rollbackArray(this.fields,e.data.fields,(e=>g.instance.proxyBlockField(new Z(e),this,this.ownerItem))),this._rollbackArray(this.scripts,e.data.scripts,(e=>new W(e,this,this.ownerItem))),t||this._rollbackArray(this.blocks,e.data.blocks,((e,t)=>g.instance.proxyBlock(new ae(e,t),this.ownerItem)))}_getFieldByName(e,t){for(const a of t)if(a.id===e)return a;return null}}
12
+ /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const ne=256,re=286,se=30,oe=15,le=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ue=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ce=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),de=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pe=new Array(576);ie(pe);const he=new Array(60);ie(he);const fe=new Array(512);ie(fe);const me=new Array(256);ie(me);const ye=new Array(29);ie(ye);const ge=new Array(se);function be(e,t,a,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let ve,we,_e;function Ae(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ie(ge);const ke=e=>e<256?fe[e]:fe[256+(e>>>7)],Se=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ne=(e,t,a)=>{e.bi_valid>16-a?(e.bi_buf|=t<<e.bi_valid&65535,Se(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=a-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=a)},Te=(e,t,a)=>{Ne(e,a[2*t],a[2*t+1])},Me=(e,t)=>{let a=0;do{a|=1&e,e>>>=1,a<<=1}while(--t>0);return a>>>1},xe=(e,t,a)=>{const i=new Array(16);let n,r,s=0;for(n=1;n<=oe;n++)s=s+a[n-1]<<1,i[n]=s;for(r=0;r<=t;r++){let t=e[2*r+1];0!==t&&(e[2*r]=Me(i[t]++,t))}},Ce=e=>{let t;for(t=0;t<re;t++)e.dyn_ltree[2*t]=0;for(t=0;t<se;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Ve=e=>{e.bi_valid>8?Se(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ie=(e,t,a,i)=>{const n=2*t,r=2*a;return e[n]<e[r]||e[n]===e[r]&&i[t]<=i[a]},Ee=(e,t,a)=>{const i=e.heap[a];let n=a<<1;for(;n<=e.heap_len&&(n<e.heap_len&&Ie(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Ie(t,i,e.heap[n],e.depth));)e.heap[a]=e.heap[n],a=n,n<<=1;e.heap[a]=i},Fe=(e,t,a)=>{let i,n,r,s,o=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+o++],i+=(255&e.pending_buf[e.sym_buf+o++])<<8,n=e.pending_buf[e.sym_buf+o++],0===i?Te(e,n,t):(r=me[n],Te(e,r+ne+1,t),s=le[r],0!==s&&(n-=ye[r],Ne(e,n,s)),i--,r=ke(i),Te(e,r,a),s=ue[r],0!==s&&(i-=ge[r],Ne(e,i,s)))}while(o<e.sym_next);Te(e,256,t)},De=(e,t)=>{const a=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,r=t.stat_desc.elems;let s,o,l,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s<r;s++)0!==a[2*s]?(e.heap[++e.heap_len]=u=s,e.depth[s]=0):a[2*s+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=u<2?++u:0,a[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=i[2*l+1]);for(t.max_code=u,s=e.heap_len>>1;s>=1;s--)Ee(e,a,s);l=r;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ee(e,a,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,a[2*l]=a[2*s]+a[2*o],e.depth[l]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,a[2*s+1]=a[2*o+1]=l,e.heap[1]=l++,Ee(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const a=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let u,c,d,p,h,f,m=0;for(p=0;p<=oe;p++)e.bl_count[p]=0;for(a[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)c=e.heap[u],p=a[2*a[2*c+1]+1]+1,p>l&&(p=l,m++),a[2*c+1]=p,c>i||(e.bl_count[p]++,h=0,c>=o&&(h=s[c-o]),f=a[2*c],e.opt_len+=f*(p+h),r&&(e.static_len+=f*(n[2*c+1]+h)));if(0!==m){do{for(p=l-1;0===e.bl_count[p];)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(p=l;0!==p;p--)for(c=e.bl_count[p];0!==c;)d=e.heap[--u],d>i||(a[2*d+1]!==p&&(e.opt_len+=(p-a[2*d+1])*a[2*d],a[2*d+1]=p),c--)}})(e,t),xe(a,u,e.bl_count)},Re=(e,t,a)=>{let i,n,r=-1,s=t[1],o=0,l=7,u=4;for(0===s&&(l=138,u=3),t[2*(a+1)+1]=65535,i=0;i<=a;i++)n=s,s=t[2*(i+1)+1],++o<l&&n===s||(o<u?e.bl_tree[2*n]+=o:0!==n?(n!==r&&e.bl_tree[2*n]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,r=n,0===s?(l=138,u=3):n===s?(l=6,u=3):(l=7,u=4))},Pe=(e,t,a)=>{let i,n,r=-1,s=t[1],o=0,l=7,u=4;for(0===s&&(l=138,u=3),i=0;i<=a;i++)if(n=s,s=t[2*(i+1)+1],!(++o<l&&n===s)){if(o<u)do{Te(e,n,e.bl_tree)}while(0!=--o);else 0!==n?(n!==r&&(Te(e,n,e.bl_tree),o--),Te(e,16,e.bl_tree),Ne(e,o-3,2)):o<=10?(Te(e,17,e.bl_tree),Ne(e,o-3,3)):(Te(e,18,e.bl_tree),Ne(e,o-11,7));o=0,r=n,0===s?(l=138,u=3):n===s?(l=6,u=3):(l=7,u=4)}};let Le=!1;const Be=(e,t,a,i)=>{Ne(e,0+(i?1:0),3),Ve(e),Se(e,a),Se(e,~a),a&&e.pending_buf.set(e.window.subarray(t,t+a),e.pending),e.pending+=a};var Oe=e=>{Le||((()=>{let e,t,a,i,n;const r=new Array(16);for(a=0,i=0;i<28;i++)for(ye[i]=a,e=0;e<1<<le[i];e++)me[a++]=i;for(me[a-1]=i,n=0,i=0;i<16;i++)for(ge[i]=n,e=0;e<1<<ue[i];e++)fe[n++]=i;for(n>>=7;i<se;i++)for(ge[i]=n<<7,e=0;e<1<<ue[i]-7;e++)fe[256+n++]=i;for(t=0;t<=oe;t++)r[t]=0;for(e=0;e<=143;)pe[2*e+1]=8,e++,r[8]++;for(;e<=255;)pe[2*e+1]=9,e++,r[9]++;for(;e<=279;)pe[2*e+1]=7,e++,r[7]++;for(;e<=287;)pe[2*e+1]=8,e++,r[8]++;for(xe(pe,287,r),e=0;e<se;e++)he[2*e+1]=5,he[2*e]=Me(e,5);ve=new be(pe,le,257,re,oe),we=new be(he,ue,0,se,oe),_e=new be(new Array(0),ce,0,19,7)})(),Le=!0),e.l_desc=new Ae(e.dyn_ltree,ve),e.d_desc=new Ae(e.dyn_dtree,we),e.bl_desc=new Ae(e.bl_tree,_e),e.bi_buf=0,e.bi_valid=0,Ce(e)},$e=(e,t,a,i)=>{let n,r,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,a=4093624447;for(t=0;t<=31;t++,a>>>=1)if(1&a&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<ne;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),De(e,e.l_desc),De(e,e.d_desc),s=(e=>{let t;for(Re(e,e.dyn_ltree,e.l_desc.max_code),Re(e,e.dyn_dtree,e.d_desc.max_code),De(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*de[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=n&&(n=r)):n=r=a+5,a+4<=n&&-1!==t?Be(e,t,a,i):4===e.strategy||r===n?(Ne(e,2+(i?1:0),3),Fe(e,pe,he)):(Ne(e,4+(i?1:0),3),((e,t,a,i)=>{let n;for(Ne(e,t-257,5),Ne(e,a-1,5),Ne(e,i-4,4),n=0;n<i;n++)Ne(e,e.bl_tree[2*de[n]+1],3);Pe(e,e.dyn_ltree,t-1),Pe(e,e.dyn_dtree,a-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),Fe(e,e.dyn_ltree,e.dyn_dtree)),Ce(e),i&&Ve(e)},Ue={_tr_init:Oe,_tr_stored_block:Be,_tr_flush_block:$e,_tr_tally:(e,t,a)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=a,0===t?e.dyn_ltree[2*a]++:(e.matches++,t--,e.dyn_ltree[2*(me[a]+ne+1)]++,e.dyn_dtree[2*ke(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ne(e,2,3),Te(e,256,pe),(e=>{16===e.bi_valid?(Se(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var je=(e,t,a,i)=>{let n=65535&e,r=e>>>16&65535,s=0;for(;0!==a;){s=a>2e3?2e3:a,a-=s;do{n=n+t[i++]|0,r=r+n|0}while(--s);n%=65521,r%=65521}return n|r<<16};const ze=new Uint32Array((()=>{let e,t=[];for(var a=0;a<256;a++){e=a;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[a]=e}return t})());var We=(e,t,a,i)=>{const n=ze,r=i+a;e^=-1;for(let a=i;a<r;a++)e=e>>>8^n[255&(e^t[a])];return~e},Ye={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},He={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ge,_tr_stored_block:qe,_tr_flush_block:Ze,_tr_tally:Je,_tr_align:Ke}=Ue,{Z_NO_FLUSH:Xe,Z_PARTIAL_FLUSH:Qe,Z_FULL_FLUSH:et,Z_FINISH:tt,Z_BLOCK:at,Z_OK:it,Z_STREAM_END:nt,Z_STREAM_ERROR:rt,Z_DATA_ERROR:st,Z_BUF_ERROR:ot,Z_DEFAULT_COMPRESSION:lt,Z_FILTERED:ut,Z_HUFFMAN_ONLY:ct,Z_RLE:dt,Z_FIXED:pt,Z_DEFAULT_STRATEGY:ht,Z_UNKNOWN:ft,Z_DEFLATED:mt}=He,yt=258,gt=262,bt=42,vt=113,wt=666,_t=(e,t)=>(e.msg=Ye[t],t),At=e=>2*e-(e>4?9:0),kt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},St=e=>{let t,a,i,n=e.w_size;t=e.hash_size,i=t;do{a=e.head[--i],e.head[i]=a>=n?a-n:0}while(--t);t=n,i=t;do{a=e.prev[--i],e.prev[i]=a>=n?a-n:0}while(--t)};let Nt=(e,t,a)=>(t<<e.hash_shift^a)&e.hash_mask;const Tt=e=>{const t=e.state;let a=t.pending;a>e.avail_out&&(a=e.avail_out),0!==a&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+a),e.next_out),e.next_out+=a,t.pending_out+=a,e.total_out+=a,e.avail_out-=a,t.pending-=a,0===t.pending&&(t.pending_out=0))},Mt=(e,t)=>{Ze(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Tt(e.strm)},xt=(e,t)=>{e.pending_buf[e.pending++]=t},Ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Vt=(e,t,a,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),a),1===e.state.wrap?e.adler=je(e.adler,t,n,a):2===e.state.wrap&&(e.adler=We(e.adler,t,n,a)),e.next_in+=n,e.total_in+=n,n)},It=(e,t)=>{let a,i,n=e.max_chain_length,r=e.strstart,s=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-gt?e.strstart-(e.w_size-gt):0,u=e.window,c=e.w_mask,d=e.prev,p=e.strstart+yt;let h=u[r+s-1],f=u[r+s];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(a=t,u[a+s]===f&&u[a+s-1]===h&&u[a]===u[r]&&u[++a]===u[r+1]){r+=2,a++;do{}while(u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&r<p);if(i=yt-(p-r),r=p-yt,i>s){if(e.match_start=t,s=i,i>=o)break;h=u[r+s-1],f=u[r+s]}}}while((t=d[t&c])>l&&0!=--n);return s<=e.lookahead?s:e.lookahead},Et=e=>{const t=e.w_size;let a,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-gt)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),St(e),i+=t),0===e.strm.avail_in)break;if(a=Vt(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=a,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=Nt(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=Nt(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<gt&&0!==e.strm.avail_in)},Ft=(e,t)=>{let a,i,n,r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,o=e.strm.avail_in;do{if(a=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,i=e.strstart-e.block_start,a>i+e.strm.avail_in&&(a=i+e.strm.avail_in),a>n&&(a=n),a<r&&(0===a&&t!==tt||t===Xe||a!==i+e.strm.avail_in))break;s=t===tt&&a===i+e.strm.avail_in?1:0,qe(e,0,0,s),e.pending_buf[e.pending-4]=a,e.pending_buf[e.pending-3]=a>>8,e.pending_buf[e.pending-2]=~a,e.pending_buf[e.pending-1]=~a>>8,Tt(e.strm),i&&(i>a&&(i=a),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,a-=i),a&&(Vt(e.strm,e.strm.output,e.strm.next_out,a),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a)}while(0===s);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?4:t!==Xe&&t!==tt&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(Vt(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,r=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=r||(i||t===tt)&&t!==Xe&&0===e.strm.avail_in&&i<=n)&&(a=i>n?n:i,s=t===tt&&0===e.strm.avail_in&&a===i?1:0,qe(e,e.block_start,a,s),e.block_start+=a,Tt(e.strm)),s?3:1)},Dt=(e,t)=>{let a,i;for(;;){if(e.lookahead<gt){if(Et(e),e.lookahead<gt&&t===Xe)return 1;if(0===e.lookahead)break}if(a=0,e.lookahead>=3&&(e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==a&&e.strstart-a<=e.w_size-gt&&(e.match_length=It(e,a)),e.match_length>=3)if(i=Je(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+1]);else i=Je(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Mt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2},Rt=(e,t)=>{let a,i,n;for(;;){if(e.lookahead<gt){if(Et(e),e.lookahead<gt&&t===Xe)return 1;if(0===e.lookahead)break}if(a=0,e.lookahead>=3&&(e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==a&&e.prev_length<e.max_lazy_match&&e.strstart-a<=e.w_size-gt&&(e.match_length=It(e,a),e.match_length<=5&&(e.strategy===ut||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=Je(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=Nt(e,e.ins_h,e.window[e.strstart+3-1]),a=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(Mt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Je(e,0,e.window[e.strstart-1]),i&&Mt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Je(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2};function Pt(e,t,a,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=a,this.max_chain=i,this.func=n}const Lt=[new Pt(0,0,0,0,Ft),new Pt(4,4,8,4,Dt),new Pt(4,5,16,8,Dt),new Pt(4,6,32,32,Dt),new Pt(4,4,16,16,Rt),new Pt(8,16,32,32,Rt),new Pt(8,16,128,128,Rt),new Pt(8,32,128,256,Rt),new Pt(32,128,258,1024,Rt),new Pt(32,258,258,4096,Rt)];function Bt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=mt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),kt(this.dyn_ltree),kt(this.dyn_dtree),kt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),kt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),kt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ot=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==bt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==vt&&t.status!==wt?1:0},$t=e=>{if(Ot(e))return _t(e,rt);e.total_in=e.total_out=0,e.data_type=ft;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?bt:vt,e.adler=2===t.wrap?0:1,t.last_flush=-2,Ge(t),it},Ut=e=>{const t=$t(e);var a;return t===it&&((a=e.state).window_size=2*a.w_size,kt(a.head),a.max_lazy_match=Lt[a.level].max_lazy,a.good_match=Lt[a.level].good_length,a.nice_match=Lt[a.level].nice_length,a.max_chain_length=Lt[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),t},jt=(e,t,a,i,n,r)=>{if(!e)return rt;let s=1;if(t===lt&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),n<1||n>9||a!==mt||i<8||i>15||t<0||t>9||r<0||r>pt||8===i&&1!==s)return _t(e,rt);8===i&&(i=9);const o=new Bt;return e.state=o,o.strm=e,o.status=bt,o.wrap=s,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=r,o.method=a,Ut(e)};var zt=(e,t)=>{if(Ot(e)||t>at||t<0)return e?_t(e,rt):rt;const a=e.state;if(!e.output||0!==e.avail_in&&!e.input||a.status===wt&&t!==tt)return _t(e,0===e.avail_out?ot:rt);const i=a.last_flush;if(a.last_flush=t,0!==a.pending){if(Tt(e),0===e.avail_out)return a.last_flush=-1,it}else if(0===e.avail_in&&At(t)<=At(i)&&t!==tt)return _t(e,ot);if(a.status===wt&&0!==e.avail_in)return _t(e,ot);if(a.status===bt&&0===a.wrap&&(a.status=vt),a.status===bt){let t=mt+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=ct||a.level<2?0:a.level<6?1:6===a.level?2:3,t|=i<<6,0!==a.strstart&&(t|=32),t+=31-t%31,Ct(a,t),0!==a.strstart&&(Ct(a,e.adler>>>16),Ct(a,65535&e.adler)),e.adler=1,a.status=vt,Tt(e),0!==a.pending)return a.last_flush=-1,it}if(57===a.status)if(e.adler=0,xt(a,31),xt(a,139),xt(a,8),a.gzhead)xt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),xt(a,255&a.gzhead.time),xt(a,a.gzhead.time>>8&255),xt(a,a.gzhead.time>>16&255),xt(a,a.gzhead.time>>24&255),xt(a,9===a.level?2:a.strategy>=ct||a.level<2?4:0),xt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(xt(a,255&a.gzhead.extra.length),xt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=We(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(xt(a,0),xt(a,0),xt(a,0),xt(a,0),xt(a,0),xt(a,9===a.level?2:a.strategy>=ct||a.level<2?4:0),xt(a,3),a.status=vt,Tt(e),0!==a.pending)return a.last_flush=-1,it;if(69===a.status){if(a.gzhead.extra){let t=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>t&&(e.adler=We(e.adler,a.pending_buf,a.pending-t,t)),a.gzindex+=n,Tt(e),0!==a.pending)return a.last_flush=-1,it;t=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>t&&(e.adler=We(e.adler,a.pending_buf,a.pending-t,t)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let t,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i)),Tt(e),0!==a.pending)return a.last_flush=-1,it;i=0}t=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,xt(a,t)}while(0!==t);a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let t,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i)),Tt(e),0!==a.pending)return a.last_flush=-1,it;i=0}t=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,xt(a,t)}while(0!==t);a.gzhead.hcrc&&a.pending>i&&(e.adler=We(e.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(Tt(e),0!==a.pending))return a.last_flush=-1,it;xt(a,255&e.adler),xt(a,e.adler>>8&255),e.adler=0}if(a.status=vt,Tt(e),0!==a.pending)return a.last_flush=-1,it}if(0!==e.avail_in||0!==a.lookahead||t!==Xe&&a.status!==wt){let i=0===a.level?Ft(a,t):a.strategy===ct?((e,t)=>{let a;for(;;){if(0===e.lookahead&&(Et(e),0===e.lookahead)){if(t===Xe)return 1;break}if(e.match_length=0,a=Je(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,a&&(Mt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2})(a,t):a.strategy===dt?((e,t)=>{let a,i,n,r;const s=e.window;for(;;){if(e.lookahead<=yt){if(Et(e),e.lookahead<=yt&&t===Xe)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=s[n],i===s[++n]&&i===s[++n]&&i===s[++n])){r=e.strstart+yt;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<r);e.match_length=yt-(r-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(a=Je(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(a=Je(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),a&&(Mt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===tt?(Mt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Mt(e,!1),0===e.strm.avail_out)?1:2})(a,t):Lt[a.level].func(a,t);if(3!==i&&4!==i||(a.status=wt),1===i||3===i)return 0===e.avail_out&&(a.last_flush=-1),it;if(2===i&&(t===Qe?Ke(a):t!==at&&(qe(a,0,0,!1),t===et&&(kt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),Tt(e),0===e.avail_out))return a.last_flush=-1,it}return t!==tt?it:a.wrap<=0?nt:(2===a.wrap?(xt(a,255&e.adler),xt(a,e.adler>>8&255),xt(a,e.adler>>16&255),xt(a,e.adler>>24&255),xt(a,255&e.total_in),xt(a,e.total_in>>8&255),xt(a,e.total_in>>16&255),xt(a,e.total_in>>24&255)):(Ct(a,e.adler>>>16),Ct(a,65535&e.adler)),Tt(e),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?it:nt)},Wt={deflateInit:(e,t)=>jt(e,t,mt,15,8,ht),deflateInit2:jt,deflateReset:Ut,deflateResetKeep:$t,deflateSetHeader:(e,t)=>Ot(e)||2!==e.state.wrap?rt:(e.state.gzhead=t,it),deflate:zt,deflateEnd:e=>{if(Ot(e))return rt;const t=e.state.status;return e.state=null,t===vt?_t(e,st):it},deflateSetDictionary:(e,t)=>{let a=t.length;if(Ot(e))return rt;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==bt||i.lookahead)return rt;if(1===n&&(e.adler=je(e.adler,t,a,0)),i.wrap=0,a>=i.w_size){0===n&&(kt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(a-i.w_size,a),0),t=e,a=i.w_size}const r=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=a,e.next_in=0,e.input=t,Et(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=Nt(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,Et(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=s,e.input=o,e.avail_in=r,i.wrap=n,it},deflateInfo:"pako deflate (from Nodeca project)"};const Yt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ht=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const a=t.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const t in a)Yt(a,t)&&(e[t]=a[t])}}return e},Gt=e=>{let t=0;for(let a=0,i=e.length;a<i;a++)t+=e[a].length;const a=new Uint8Array(t);for(let t=0,i=0,n=e.length;t<n;t++){let n=e[t];a.set(n,i),i+=n.length}return a};let qt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){qt=!1}const Zt=new Uint8Array(256);for(let e=0;e<256;e++)Zt[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Zt[254]=Zt[254]=1;var Jt=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,a,i,n,r,s=e.length,o=0;for(n=0;n<s;n++)a=e.charCodeAt(n),55296==(64512&a)&&n+1<s&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),o+=a<128?1:a<2048?2:a<65536?3:4;for(t=new Uint8Array(o),r=0,n=0;r<o;n++)a=e.charCodeAt(n),55296==(64512&a)&&n+1<s&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),a<128?t[r++]=a:a<2048?(t[r++]=192|a>>>6,t[r++]=128|63&a):a<65536?(t[r++]=224|a>>>12,t[r++]=128|a>>>6&63,t[r++]=128|63&a):(t[r++]=240|a>>>18,t[r++]=128|a>>>12&63,t[r++]=128|a>>>6&63,t[r++]=128|63&a);return t},Kt=(e,t)=>{const a=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,n;const r=new Array(2*a);for(n=0,i=0;i<a;){let t=e[i++];if(t<128){r[n++]=t;continue}let s=Zt[t];if(s>4)r[n++]=65533,i+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&i<a;)t=t<<6|63&e[i++],s--;s>1?r[n++]=65533:t<65536?r[n++]=t:(t-=65536,r[n++]=55296|t>>10&1023,r[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&qt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let a="";for(let i=0;i<t;i++)a+=String.fromCharCode(e[i]);return a})(r,n)},Xt=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let a=t-1;for(;a>=0&&128==(192&e[a]);)a--;return a<0||0===a?t:a+Zt[e[a]]>t?a:t};var Qt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const ea=Object.prototype.toString,{Z_NO_FLUSH:ta,Z_SYNC_FLUSH:aa,Z_FULL_FLUSH:ia,Z_FINISH:na,Z_OK:ra,Z_STREAM_END:sa,Z_DEFAULT_COMPRESSION:oa,Z_DEFAULT_STRATEGY:la,Z_DEFLATED:ua}=He;function ca(e){this.options=Ht({level:oa,method:ua,chunkSize:16384,windowBits:15,memLevel:8,strategy:la},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qt,this.strm.avail_out=0;let a=Wt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(a!==ra)throw new Error(Ye[a]);if(t.header&&Wt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Jt(t.dictionary):"[object ArrayBuffer]"===ea.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,a=Wt.deflateSetDictionary(this.strm,e),a!==ra)throw new Error(Ye[a]);this._dict_set=!0}}function da(e,t){const a=new ca(t);if(a.push(e,!0),a.err)throw a.msg||Ye[a.err];return a.result}ca.prototype.push=function(e,t){const a=this.strm,i=this.options.chunkSize;let n,r;if(this.ended)return!1;for(r=t===~~t?t:!0===t?na:ta,"string"==typeof e?a.input=Jt(e):"[object ArrayBuffer]"===ea.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(r===aa||r===ia)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Wt.deflate(a,r),n===sa)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Wt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===ra;if(0!==a.avail_out){if(r>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},ca.prototype.onData=function(e){this.chunks.push(e)},ca.prototype.onEnd=function(e){e===ra&&(this.result=Gt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pa=function(e,t){return(t=t||{}).raw=!0,da(e,t)},ha=function(e,t){return(t=t||{}).gzip=!0,da(e,t)},fa={Deflate:ca,deflate:da,deflateRaw:pa,gzip:ha};const ma=16209;var ya=function(e,t){let a,i,n,r,s,o,l,u,c,d,p,h,f,m,y,g,b,v,w,_,A,k,S,N;const T=e.state;a=e.next_in,S=e.input,i=a+(e.avail_in-5),n=e.next_out,N=e.output,r=n-(t-e.avail_out),s=n+(e.avail_out-257),o=T.dmax,l=T.wsize,u=T.whave,c=T.wnext,d=T.window,p=T.hold,h=T.bits,f=T.lencode,m=T.distcode,y=(1<<T.lenbits)-1,g=(1<<T.distbits)-1;e:do{h<15&&(p+=S[a++]<<h,h+=8,p+=S[a++]<<h,h+=8),b=f[p&y];t:for(;;){if(v=b>>>24,p>>>=v,h-=v,v=b>>>16&255,0===v)N[n++]=65535&b;else{if(!(16&v)){if(64&v){if(32&v){T.mode=16191;break e}e.msg="invalid literal/length code",T.mode=ma;break e}b=f[(65535&b)+(p&(1<<v)-1)];continue t}for(w=65535&b,v&=15,v&&(h<v&&(p+=S[a++]<<h,h+=8),w+=p&(1<<v)-1,p>>>=v,h-=v),h<15&&(p+=S[a++]<<h,h+=8,p+=S[a++]<<h,h+=8),b=m[p&g];;){if(v=b>>>24,p>>>=v,h-=v,v=b>>>16&255,16&v){if(_=65535&b,v&=15,h<v&&(p+=S[a++]<<h,h+=8,h<v&&(p+=S[a++]<<h,h+=8)),_+=p&(1<<v)-1,_>o){e.msg="invalid distance too far back",T.mode=ma;break e}if(p>>>=v,h-=v,v=n-r,_>v){if(v=_-v,v>u&&T.sane){e.msg="invalid distance too far back",T.mode=ma;break e}if(A=0,k=d,0===c){if(A+=l-v,v<w){w-=v;do{N[n++]=d[A++]}while(--v);A=n-_,k=N}}else if(c<v){if(A+=l+c-v,v-=c,v<w){w-=v;do{N[n++]=d[A++]}while(--v);if(A=0,c<w){v=c,w-=v;do{N[n++]=d[A++]}while(--v);A=n-_,k=N}}}else if(A+=c-v,v<w){w-=v;do{N[n++]=d[A++]}while(--v);A=n-_,k=N}for(;w>2;)N[n++]=k[A++],N[n++]=k[A++],N[n++]=k[A++],w-=3;w&&(N[n++]=k[A++],w>1&&(N[n++]=k[A++]))}else{A=n-_;do{N[n++]=N[A++],N[n++]=N[A++],N[n++]=N[A++],w-=3}while(w>2);w&&(N[n++]=N[A++],w>1&&(N[n++]=N[A++]))}break}if(64&v){e.msg="invalid distance code",T.mode=ma;break e}b=m[(65535&b)+(p&(1<<v)-1)]}}break}}while(a<i&&n<s);w=h>>3,a-=w,h-=w<<3,p&=(1<<h)-1,e.next_in=a,e.next_out=n,e.avail_in=a<i?i-a+5:5-(a-i),e.avail_out=n<s?s-n+257:257-(n-s),T.hold=p,T.bits=h};const ga=15,ba=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),va=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),wa=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),_a=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Aa=(e,t,a,i,n,r,s,o)=>{const l=o.bits;let u,c,d,p,h,f,m=0,y=0,g=0,b=0,v=0,w=0,_=0,A=0,k=0,S=0,N=null;const T=new Uint16Array(16),M=new Uint16Array(16);let x,C,V,I=null;for(m=0;m<=ga;m++)T[m]=0;for(y=0;y<i;y++)T[t[a+y]]++;for(v=l,b=ga;b>=1&&0===T[b];b--);if(v>b&&(v=b),0===b)return n[r++]=20971520,n[r++]=20971520,o.bits=1,0;for(g=1;g<b&&0===T[g];g++);for(v<g&&(v=g),A=1,m=1;m<=ga;m++)if(A<<=1,A-=T[m],A<0)return-1;if(A>0&&(0===e||1!==b))return-1;for(M[1]=0,m=1;m<ga;m++)M[m+1]=M[m]+T[m];for(y=0;y<i;y++)0!==t[a+y]&&(s[M[t[a+y]]++]=y);if(0===e?(N=I=s,f=20):1===e?(N=ba,I=va,f=257):(N=wa,I=_a,f=0),S=0,y=0,m=g,h=r,w=v,_=0,d=-1,k=1<<v,p=k-1,1===e&&k>852||2===e&&k>592)return 1;for(;;){x=m-_,s[y]+1<f?(C=0,V=s[y]):s[y]>=f?(C=I[s[y]-f],V=N[s[y]-f]):(C=96,V=0),u=1<<m-_,c=1<<w,g=c;do{c-=u,n[h+(S>>_)+c]=x<<24|C<<16|V}while(0!==c);for(u=1<<m-1;S&u;)u>>=1;if(0!==u?(S&=u-1,S+=u):S=0,y++,0==--T[m]){if(m===b)break;m=t[a+s[y]]}if(m>v&&(S&p)!==d){for(0===_&&(_=v),h+=g,w=m-_,A=1<<w;w+_<b&&(A-=T[w+_],!(A<=0));)w++,A<<=1;if(k+=1<<w,1===e&&k>852||2===e&&k>592)return 1;d=S&p,n[d]=v<<24|w<<16|h-r}}return 0!==S&&(n[h+S]=m-_<<24|64<<16),o.bits=v,0};const{Z_FINISH:ka,Z_BLOCK:Sa,Z_TREES:Na,Z_OK:Ta,Z_STREAM_END:Ma,Z_NEED_DICT:xa,Z_STREAM_ERROR:Ca,Z_DATA_ERROR:Va,Z_MEM_ERROR:Ia,Z_BUF_ERROR:Ea,Z_DEFLATED:Fa}=He,Da=16180,Ra=16190,Pa=16191,La=16192,Ba=16194,Oa=16199,$a=16200,Ua=16206,ja=16209,za=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Wa(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ya=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Da||t.mode>16211?1:0},Ha=e=>{if(Ya(e))return Ca;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Da,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Ta},Ga=e=>{if(Ya(e))return Ca;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ha(e)},qa=(e,t)=>{let a;if(Ya(e))return Ca;const i=e.state;return t<0?(a=0,t=-t):(a=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ca:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=a,i.wbits=t,Ga(e))},Za=(e,t)=>{if(!e)return Ca;const a=new Wa;e.state=a,a.strm=e,a.window=null,a.mode=Da;const i=qa(e,t);return i!==Ta&&(e.state=null),i};let Ja,Ka,Xa=!0;const Qa=e=>{if(Xa){Ja=new Int32Array(512),Ka=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Aa(1,e.lens,0,288,Ja,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Aa(2,e.lens,0,32,Ka,0,e.work,{bits:5}),Xa=!1}e.lencode=Ja,e.lenbits=9,e.distcode=Ka,e.distbits=5},ei=(e,t,a,i)=>{let n;const r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(t.subarray(a-r.wsize,a),0),r.wnext=0,r.whave=r.wsize):(n=r.wsize-r.wnext,n>i&&(n=i),r.window.set(t.subarray(a-i,a-i+n),r.wnext),(i-=n)?(r.window.set(t.subarray(a-i,a),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=n))),0};var ti=(e,t)=>{let a,i,n,r,s,o,l,u,c,d,p,h,f,m,y,g,b,v,w,_,A,k,S=0;const N=new Uint8Array(4);let T,M;const x=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ya(e)||!e.output||!e.input&&0!==e.avail_in)return Ca;a=e.state,a.mode===Pa&&(a.mode=La),s=e.next_out,n=e.output,l=e.avail_out,r=e.next_in,i=e.input,o=e.avail_in,u=a.hold,c=a.bits,d=o,p=l,k=Ta;e:for(;;)switch(a.mode){case Da:if(0===a.wrap){a.mode=La;break}for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(2&a.wrap&&35615===u){0===a.wbits&&(a.wbits=15),a.check=0,N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0),u=0,c=0,a.mode=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",a.mode=ja;break}if((15&u)!==Fa){e.msg="unknown compression method",a.mode=ja;break}if(u>>>=4,c-=4,A=8+(15&u),0===a.wbits&&(a.wbits=A),A>15||A>a.wbits){e.msg="invalid window size",a.mode=ja;break}a.dmax=1<<a.wbits,a.flags=0,e.adler=a.check=1,a.mode=512&u?16189:Pa,u=0,c=0;break;case 16181:for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(a.flags=u,(255&a.flags)!==Fa){e.msg="unknown compression method",a.mode=ja;break}if(57344&a.flags){e.msg="unknown header flags set",a.mode=ja;break}a.head&&(a.head.text=u>>8&1),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0)),u=0,c=0,a.mode=16182;case 16182:for(;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.head&&(a.head.time=u),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,a.check=We(a.check,N,4,0)),u=0,c=0,a.mode=16183;case 16183:for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.head&&(a.head.xflags=255&u,a.head.os=u>>8),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0)),u=0,c=0,a.mode=16184;case 16184:if(1024&a.flags){for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.length=u,a.head&&(a.head.extra_len=u),512&a.flags&&4&a.wrap&&(N[0]=255&u,N[1]=u>>>8&255,a.check=We(a.check,N,2,0)),u=0,c=0}else a.head&&(a.head.extra=null);a.mode=16185;case 16185:if(1024&a.flags&&(h=a.length,h>o&&(h=o),h&&(a.head&&(A=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(r,r+h),A)),512&a.flags&&4&a.wrap&&(a.check=We(a.check,i,h,r)),o-=h,r+=h,a.length-=h),a.length))break e;a.length=0,a.mode=16186;case 16186:if(2048&a.flags){if(0===o)break e;h=0;do{A=i[r+h++],a.head&&A&&a.length<65536&&(a.head.name+=String.fromCharCode(A))}while(A&&h<o);if(512&a.flags&&4&a.wrap&&(a.check=We(a.check,i,h,r)),o-=h,r+=h,A)break e}else a.head&&(a.head.name=null);a.length=0,a.mode=16187;case 16187:if(4096&a.flags){if(0===o)break e;h=0;do{A=i[r+h++],a.head&&A&&a.length<65536&&(a.head.comment+=String.fromCharCode(A))}while(A&&h<o);if(512&a.flags&&4&a.wrap&&(a.check=We(a.check,i,h,r)),o-=h,r+=h,A)break e}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;c<16;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(4&a.wrap&&u!==(65535&a.check)){e.msg="header crc mismatch",a.mode=ja;break}u=0,c=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),e.adler=a.check=0,a.mode=Pa;break;case 16189:for(;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}e.adler=a.check=za(u),u=0,c=0,a.mode=Ra;case Ra:if(0===a.havedict)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=o,a.hold=u,a.bits=c,xa;e.adler=a.check=1,a.mode=Pa;case Pa:if(t===Sa||t===Na)break e;case La:if(a.last){u>>>=7&c,c-=7&c,a.mode=Ua;break}for(;c<3;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}switch(a.last=1&u,u>>>=1,c-=1,3&u){case 0:a.mode=16193;break;case 1:if(Qa(a),a.mode=Oa,t===Na){u>>>=2,c-=2;break e}break;case 2:a.mode=16196;break;case 3:e.msg="invalid block type",a.mode=ja}u>>>=2,c-=2;break;case 16193:for(u>>>=7&c,c-=7&c;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",a.mode=ja;break}if(a.length=65535&u,u=0,c=0,a.mode=Ba,t===Na)break e;case Ba:a.mode=16195;case 16195:if(h=a.length,h){if(h>o&&(h=o),h>l&&(h=l),0===h)break e;n.set(i.subarray(r,r+h),s),o-=h,r+=h,l-=h,s+=h,a.length-=h;break}a.mode=Pa;break;case 16196:for(;c<14;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(a.nlen=257+(31&u),u>>>=5,c-=5,a.ndist=1+(31&u),u>>>=5,c-=5,a.ncode=4+(15&u),u>>>=4,c-=4,a.nlen>286||a.ndist>30){e.msg="too many length or distance symbols",a.mode=ja;break}a.have=0,a.mode=16197;case 16197:for(;a.have<a.ncode;){for(;c<3;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.lens[x[a.have++]]=7&u,u>>>=3,c-=3}for(;a.have<19;)a.lens[x[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,T={bits:a.lenbits},k=Aa(0,a.lens,0,19,a.lencode,0,a.work,T),a.lenbits=T.bits,k){e.msg="invalid code lengths set",a.mode=ja;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;S=a.lencode[u&(1<<a.lenbits)-1],y=S>>>24,g=S>>>16&255,b=65535&S,!(y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(b<16)u>>>=y,c-=y,a.lens[a.have++]=b;else{if(16===b){for(M=y+2;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(u>>>=y,c-=y,0===a.have){e.msg="invalid bit length repeat",a.mode=ja;break}A=a.lens[a.have-1],h=3+(3&u),u>>>=2,c-=2}else if(17===b){for(M=y+3;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=y,c-=y,A=0,h=3+(7&u),u>>>=3,c-=3}else{for(M=y+7;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=y,c-=y,A=0,h=11+(127&u),u>>>=7,c-=7}if(a.have+h>a.nlen+a.ndist){e.msg="invalid bit length repeat",a.mode=ja;break}for(;h--;)a.lens[a.have++]=A}}if(a.mode===ja)break;if(0===a.lens[256]){e.msg="invalid code -- missing end-of-block",a.mode=ja;break}if(a.lenbits=9,T={bits:a.lenbits},k=Aa(1,a.lens,0,a.nlen,a.lencode,0,a.work,T),a.lenbits=T.bits,k){e.msg="invalid literal/lengths set",a.mode=ja;break}if(a.distbits=6,a.distcode=a.distdyn,T={bits:a.distbits},k=Aa(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,T),a.distbits=T.bits,k){e.msg="invalid distances set",a.mode=ja;break}if(a.mode=Oa,t===Na)break e;case Oa:a.mode=$a;case $a:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=o,a.hold=u,a.bits=c,ya(e,p),s=e.next_out,n=e.output,l=e.avail_out,r=e.next_in,i=e.input,o=e.avail_in,u=a.hold,c=a.bits,a.mode===Pa&&(a.back=-1);break}for(a.back=0;S=a.lencode[u&(1<<a.lenbits)-1],y=S>>>24,g=S>>>16&255,b=65535&S,!(y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(g&&!(240&g)){for(v=y,w=g,_=b;S=a.lencode[_+((u&(1<<v+w)-1)>>v)],y=S>>>24,g=S>>>16&255,b=65535&S,!(v+y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=v,c-=v,a.back+=v}if(u>>>=y,c-=y,a.back+=y,a.length=b,0===g){a.mode=16205;break}if(32&g){a.back=-1,a.mode=Pa;break}if(64&g){e.msg="invalid literal/length code",a.mode=ja;break}a.extra=15&g,a.mode=16201;case 16201:if(a.extra){for(M=a.extra;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.length+=u&(1<<a.extra)-1,u>>>=a.extra,c-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=16202;case 16202:for(;S=a.distcode[u&(1<<a.distbits)-1],y=S>>>24,g=S>>>16&255,b=65535&S,!(y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(!(240&g)){for(v=y,w=g,_=b;S=a.distcode[_+((u&(1<<v+w)-1)>>v)],y=S>>>24,g=S>>>16&255,b=65535&S,!(v+y<=c);){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}u>>>=v,c-=v,a.back+=v}if(u>>>=y,c-=y,a.back+=y,64&g){e.msg="invalid distance code",a.mode=ja;break}a.offset=b,a.extra=15&g,a.mode=16203;case 16203:if(a.extra){for(M=a.extra;c<M;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}a.offset+=u&(1<<a.extra)-1,u>>>=a.extra,c-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){e.msg="invalid distance too far back",a.mode=ja;break}a.mode=16204;case 16204:if(0===l)break e;if(h=p-l,a.offset>h){if(h=a.offset-h,h>a.whave&&a.sane){e.msg="invalid distance too far back",a.mode=ja;break}h>a.wnext?(h-=a.wnext,f=a.wsize-h):f=a.wnext-h,h>a.length&&(h=a.length),m=a.window}else m=n,f=s-a.offset,h=a.length;h>l&&(h=l),l-=h,a.length-=h;do{n[s++]=m[f++]}while(--h);0===a.length&&(a.mode=$a);break;case 16205:if(0===l)break e;n[s++]=a.length,l--,a.mode=$a;break;case Ua:if(a.wrap){for(;c<32;){if(0===o)break e;o--,u|=i[r++]<<c,c+=8}if(p-=l,e.total_out+=p,a.total+=p,4&a.wrap&&p&&(e.adler=a.check=a.flags?We(a.check,n,p,s-p):je(a.check,n,p,s-p)),p=l,4&a.wrap&&(a.flags?u:za(u))!==a.check){e.msg="incorrect data check",a.mode=ja;break}u=0,c=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;c<32;){if(0===o)break e;o--,u+=i[r++]<<c,c+=8}if(4&a.wrap&&u!==(4294967295&a.total)){e.msg="incorrect length check",a.mode=ja;break}u=0,c=0}a.mode=16208;case 16208:k=Ma;break e;case ja:k=Va;break e;case 16210:return Ia;default:return Ca}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=o,a.hold=u,a.bits=c,(a.wsize||p!==e.avail_out&&a.mode<ja&&(a.mode<Ua||t!==ka))&&ei(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,a.total+=p,4&a.wrap&&p&&(e.adler=a.check=a.flags?We(a.check,n,p,e.next_out-p):je(a.check,n,p,e.next_out-p)),e.data_type=a.bits+(a.last?64:0)+(a.mode===Pa?128:0)+(a.mode===Oa||a.mode===Ba?256:0),(0===d&&0===p||t===ka)&&k===Ta&&(k=Ea),k},ai={inflateReset:Ga,inflateReset2:qa,inflateResetKeep:Ha,inflateInit:e=>Za(e,15),inflateInit2:Za,inflate:ti,inflateEnd:e=>{if(Ya(e))return Ca;let t=e.state;return t.window&&(t.window=null),e.state=null,Ta},inflateGetHeader:(e,t)=>{if(Ya(e))return Ca;const a=e.state;return 2&a.wrap?(a.head=t,t.done=!1,Ta):Ca},inflateSetDictionary:(e,t)=>{const a=t.length;let i,n,r;return Ya(e)?Ca:(i=e.state,0!==i.wrap&&i.mode!==Ra?Ca:i.mode===Ra&&(n=1,n=je(n,t,a,0),n!==i.check)?Va:(r=ei(e,t,a,a),r?(i.mode=16210,Ia):(i.havedict=1,Ta)))},inflateInfo:"pako inflate (from Nodeca project)"};var ii=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ni=Object.prototype.toString,{Z_NO_FLUSH:ri,Z_FINISH:si,Z_OK:oi,Z_STREAM_END:li,Z_NEED_DICT:ui,Z_STREAM_ERROR:ci,Z_DATA_ERROR:di,Z_MEM_ERROR:pi}=He;function hi(e){this.options=Ht({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qt,this.strm.avail_out=0;let a=ai.inflateInit2(this.strm,t.windowBits);if(a!==oi)throw new Error(Ye[a]);if(this.header=new ii,ai.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Jt(t.dictionary):"[object ArrayBuffer]"===ni.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(a=ai.inflateSetDictionary(this.strm,t.dictionary),a!==oi)))throw new Error(Ye[a])}function fi(e,t){const a=new hi(t);if(a.push(e),a.err)throw a.msg||Ye[a.err];return a.result}hi.prototype.push=function(e,t){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let r,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?si:ri,"[object ArrayBuffer]"===ni.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),r=ai.inflate(a,s),r===ui&&n&&(r=ai.inflateSetDictionary(a,n),r===oi?r=ai.inflate(a,s):r===di&&(r=ui));a.avail_in>0&&r===li&&a.state.wrap>0&&0!==e[a.next_in];)ai.inflateReset(a),r=ai.inflate(a,s);switch(r){case ci:case di:case ui:case pi:return this.onEnd(r),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||r===li))if("string"===this.options.to){let e=Xt(a.output,a.next_out),t=a.next_out-e,n=Kt(a.output,e);a.next_out=t,a.avail_out=i-t,t&&a.output.set(a.output.subarray(e,e+t),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==oi||0!==o){if(r===li)return r=ai.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},hi.prototype.onData=function(e){this.chunks.push(e)},hi.prototype.onEnd=function(e){e===oi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Gt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mi=function(e,t){return(t=t||{}).raw=!0,fi(e,t)},yi={Inflate:hi,inflate:fi,inflateRaw:mi,ungzip:fi};const{Deflate:gi,deflate:bi,deflateRaw:vi,gzip:wi}=fa,{Inflate:_i,inflate:Ai,inflateRaw:ki,ungzip:Si}=yi;var Ni={Deflate:gi,deflate:bi,deflateRaw:vi,gzip:wi,Inflate:_i,inflate:Ai,inflateRaw:ki,ungzip:Si,constants:He},Ti="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Mi=[],xi=[],Ci="undefined"!=typeof Uint8Array?Uint8Array:Array,Vi=!1;function Ii(){Vi=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Mi[t]=e[t],xi[e.charCodeAt(t)]=t;xi["-".charCodeAt(0)]=62,xi["_".charCodeAt(0)]=63}function Ei(e,t,a){for(var i,n,r=[],s=t;s<a;s+=3)i=(e[s]<<16)+(e[s+1]<<8)+e[s+2],r.push(Mi[(n=i)>>18&63]+Mi[n>>12&63]+Mi[n>>6&63]+Mi[63&n]);return r.join("")}function Fi(e){var t;Vi||Ii();for(var a=e.length,i=a%3,n="",r=[],s=16383,o=0,l=a-i;o<l;o+=s)r.push(Ei(e,o,o+s>l?l:o+s));return 1===i?(t=e[a-1],n+=Mi[t>>2],n+=Mi[t<<4&63],n+="=="):2===i&&(t=(e[a-2]<<8)+e[a-1],n+=Mi[t>>10],n+=Mi[t>>4&63],n+=Mi[t<<2&63],n+="="),r.push(n),r.join("")}function Di(e,t,a,i,n){var r,s,o=8*n-i-1,l=(1<<o)-1,u=l>>1,c=-7,d=a?n-1:0,p=a?-1:1,h=e[t+d];for(d+=p,r=h&(1<<-c)-1,h>>=-c,c+=o;c>0;r=256*r+e[t+d],d+=p,c-=8);for(s=r&(1<<-c)-1,r>>=-c,c+=i;c>0;s=256*s+e[t+d],d+=p,c-=8);if(0===r)r=1-u;else{if(r===l)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,i),r-=u}return(h?-1:1)*s*Math.pow(2,r-i)}function Ri(e,t,a,i,n,r){var s,o,l,u=8*r-n-1,c=(1<<u)-1,d=c>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:r-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+d>=1?p/l:p*Math.pow(2,1-d))*l>=2&&(s++,l/=2),s+d>=c?(o=0,s=c):s+d>=1?(o=(t*l-1)*Math.pow(2,n),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;e[a+h]=255&o,h+=f,o/=256,n-=8);for(s=s<<n|o,u+=n;u>0;e[a+h]=255&s,h+=f,s/=256,u-=8);e[a+h-f]|=128*m}var Pi={}.toString,Li=Array.isArray||function(e){return"[object Array]"==Pi.call(e)};function Bi(){return $i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Oi(e,t){if(Bi()<t)throw new RangeError("Invalid typed array length");return $i.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=$i.prototype:(null===e&&(e=new $i(t)),e.length=t),e}function $i(e,t,a){if(!($i.TYPED_ARRAY_SUPPORT||this instanceof $i))return new $i(e,t,a);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return zi(this,e)}return Ui(this,e,t,a)}function Ui(e,t,a,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,a,i){if(t.byteLength,a<0||t.byteLength<a)throw new RangeError("'offset' is out of bounds");if(t.byteLength<a+(i||0))throw new RangeError("'length' is out of bounds");t=void 0===a&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,a):new Uint8Array(t,a,i);$i.TYPED_ARRAY_SUPPORT?(e=t).__proto__=$i.prototype:e=Wi(e,t);return e}(e,t,a,i):"string"==typeof t?function(e,t,a){"string"==typeof a&&""!==a||(a="utf8");if(!$i.isEncoding(a))throw new TypeError('"encoding" must be a valid string encoding');var i=0|Gi(t,a);e=Oi(e,i);var n=e.write(t,a);n!==i&&(e=e.slice(0,n));return e}(e,t,a):function(e,t){if(Hi(t)){var a=0|Yi(t.length);return 0===(e=Oi(e,a)).length||t.copy(e,0,0,a),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(i=t.length)!=i?Oi(e,0):Wi(e,t);if("Buffer"===t.type&&Li(t.data))return Wi(e,t.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function ji(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function zi(e,t){if(ji(t),e=Oi(e,t<0?0:0|Yi(t)),!$i.TYPED_ARRAY_SUPPORT)for(var a=0;a<t;++a)e[a]=0;return e}function Wi(e,t){var a=t.length<0?0:0|Yi(t.length);e=Oi(e,a);for(var i=0;i<a;i+=1)e[i]=255&t[i];return e}function Yi(e){if(e>=Bi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Bi().toString(16)+" bytes");return 0|e}function Hi(e){return!(null==e||!e._isBuffer)}function Gi(e,t){if(Hi(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var a=e.length;if(0===a)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":case void 0:return _n(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a;case"hex":return a>>>1;case"base64":return An(e).length;default:if(i)return _n(e).length;t=(""+t).toLowerCase(),i=!0}}function qi(e,t,a){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),a<=0)return"";if((a>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return cn(this,t,a);case"utf8":case"utf-8":return sn(this,t,a);case"ascii":return ln(this,t,a);case"latin1":case"binary":return un(this,t,a);case"base64":return rn(this,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dn(this,t,a);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function Zi(e,t,a){var i=e[t];e[t]=e[a],e[a]=i}function Ji(e,t,a,i,n){if(0===e.length)return-1;if("string"==typeof a?(i=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,isNaN(a)&&(a=n?0:e.length-1),a<0&&(a=e.length+a),a>=e.length){if(n)return-1;a=e.length-1}else if(a<0){if(!n)return-1;a=0}if("string"==typeof t&&(t=$i.from(t,i)),Hi(t))return 0===t.length?-1:Ki(e,t,a,i,n);if("number"==typeof t)return t&=255,$i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,a):Uint8Array.prototype.lastIndexOf.call(e,t,a):Ki(e,[t],a,i,n);throw new TypeError("val must be string, number or Buffer")}function Ki(e,t,a,i,n){var r,s=1,o=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,o/=2,l/=2,a/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var c=-1;for(r=a;r<o;r++)if(u(e,r)===u(t,-1===c?0:r-c)){if(-1===c&&(c=r),r-c+1===l)return c*s}else-1!==c&&(r-=r-c),c=-1}else for(a+l>o&&(a=o-l),r=a;r>=0;r--){for(var d=!0,p=0;p<l;p++)if(u(e,r+p)!==u(t,p)){d=!1;break}if(d)return r}return-1}function Xi(e,t,a,i){a=Number(a)||0;var n=e.length-a;i?(i=Number(i))>n&&(i=n):i=n;var r=t.length;if(r%2!=0)throw new TypeError("Invalid hex string");i>r/2&&(i=r/2);for(var s=0;s<i;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[a+s]=o}return s}function Qi(e,t,a,i){return kn(_n(t,e.length-a),e,a,i)}function en(e,t,a,i){return kn(function(e){for(var t=[],a=0;a<e.length;++a)t.push(255&e.charCodeAt(a));return t}(t),e,a,i)}function tn(e,t,a,i){return en(e,t,a,i)}function an(e,t,a,i){return kn(An(t),e,a,i)}function nn(e,t,a,i){return kn(function(e,t){for(var a,i,n,r=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(a=e.charCodeAt(s))>>8,n=a%256,r.push(n),r.push(i);return r}(t,e.length-a),e,a,i)}function rn(e,t,a){return 0===t&&a===e.length?Fi(e):Fi(e.slice(t,a))}function sn(e,t,a){a=Math.min(e.length,a);for(var i=[],n=t;n<a;){var r,s,o,l,u=e[n],c=null,d=u>239?4:u>223?3:u>191?2:1;if(n+d<=a)switch(d){case 1:u<128&&(c=u);break;case 2:128==(192&(r=e[n+1]))&&(l=(31&u)<<6|63&r)>127&&(c=l);break;case 3:r=e[n+1],s=e[n+2],128==(192&r)&&128==(192&s)&&(l=(15&u)<<12|(63&r)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:r=e[n+1],s=e[n+2],o=e[n+3],128==(192&r)&&128==(192&s)&&128==(192&o)&&(l=(15&u)<<18|(63&r)<<12|(63&s)<<6|63&o)>65535&&l<1114112&&(c=l)}null===c?(c=65533,d=1):c>65535&&(c-=65536,i.push(c>>>10&1023|55296),c=56320|1023&c),i.push(c),n+=d}return function(e){var t=e.length;if(t<=on)return String.fromCharCode.apply(String,e);var a="",i=0;for(;i<t;)a+=String.fromCharCode.apply(String,e.slice(i,i+=on));return a}(i)}$i.TYPED_ARRAY_SUPPORT=void 0===Ti.TYPED_ARRAY_SUPPORT||Ti.TYPED_ARRAY_SUPPORT,Bi(),$i.poolSize=8192,$i._augment=function(e){return e.__proto__=$i.prototype,e},$i.from=function(e,t,a){return Ui(null,e,t,a)},$i.TYPED_ARRAY_SUPPORT&&($i.prototype.__proto__=Uint8Array.prototype,$i.__proto__=Uint8Array),$i.alloc=function(e,t,a){return function(e,t,a,i){return ji(t),t<=0?Oi(e,t):void 0!==a?"string"==typeof i?Oi(e,t).fill(a,i):Oi(e,t).fill(a):Oi(e,t)}(null,e,t,a)},$i.allocUnsafe=function(e){return zi(null,e)},$i.allocUnsafeSlow=function(e){return zi(null,e)},$i.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Sn(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Sn(e.slice(0,0))}(e))},$i.compare=function(e,t){if(!Hi(e)||!Hi(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var a=e.length,i=t.length,n=0,r=Math.min(a,i);n<r;++n)if(e[n]!==t[n]){a=e[n],i=t[n];break}return a<i?-1:i<a?1:0},$i.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},$i.concat=function(e,t){if(!Li(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return $i.alloc(0);var a;if(void 0===t)for(t=0,a=0;a<e.length;++a)t+=e[a].length;var i=$i.allocUnsafe(t),n=0;for(a=0;a<e.length;++a){var r=e[a];if(!Hi(r))throw new TypeError('"list" argument must be an Array of Buffers');r.copy(i,n),n+=r.length}return i},$i.byteLength=Gi,$i.prototype._isBuffer=!0,$i.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Zi(this,t,t+1);return this},$i.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Zi(this,t,t+3),Zi(this,t+1,t+2);return this},$i.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Zi(this,t,t+7),Zi(this,t+1,t+6),Zi(this,t+2,t+5),Zi(this,t+3,t+4);return this},$i.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?sn(this,0,e):qi.apply(this,arguments)},$i.prototype.equals=function(e){if(!Hi(e))throw new TypeError("Argument must be a Buffer");return this===e||0===$i.compare(this,e)},$i.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},$i.prototype.compare=function(e,t,a,i,n){if(!Hi(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===a&&(a=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||a>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=a)return 0;if(i>=n)return-1;if(t>=a)return 1;if(this===e)return 0;for(var r=(n>>>=0)-(i>>>=0),s=(a>>>=0)-(t>>>=0),o=Math.min(r,s),l=this.slice(i,n),u=e.slice(t,a),c=0;c<o;++c)if(l[c]!==u[c]){r=l[c],s=u[c];break}return r<s?-1:s<r?1:0},$i.prototype.includes=function(e,t,a){return-1!==this.indexOf(e,t,a)},$i.prototype.indexOf=function(e,t,a){return Ji(this,e,t,a,!0)},$i.prototype.lastIndexOf=function(e,t,a){return Ji(this,e,t,a,!1)},$i.prototype.write=function(e,t,a,i){if(void 0===t)i="utf8",a=this.length,t=0;else if(void 0===a&&"string"==typeof t)i=t,a=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(a)?(a|=0,void 0===i&&(i="utf8")):(i=a,a=void 0)}var n=this.length-t;if((void 0===a||a>n)&&(a=n),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return Xi(this,e,t,a);case"utf8":case"utf-8":return Qi(this,e,t,a);case"ascii":return en(this,e,t,a);case"latin1":case"binary":return tn(this,e,t,a);case"base64":return an(this,e,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nn(this,e,t,a);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},$i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var on=4096;function ln(e,t,a){var i="";a=Math.min(e.length,a);for(var n=t;n<a;++n)i+=String.fromCharCode(127&e[n]);return i}function un(e,t,a){var i="";a=Math.min(e.length,a);for(var n=t;n<a;++n)i+=String.fromCharCode(e[n]);return i}function cn(e,t,a){var i=e.length;(!t||t<0)&&(t=0),(!a||a<0||a>i)&&(a=i);for(var n="",r=t;r<a;++r)n+=wn(e[r]);return n}function dn(e,t,a){for(var i=e.slice(t,a),n="",r=0;r<i.length;r+=2)n+=String.fromCharCode(i[r]+256*i[r+1]);return n}function pn(e,t,a){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>a)throw new RangeError("Trying to access beyond buffer length")}function hn(e,t,a,i,n,r){if(!Hi(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<r)throw new RangeError('"value" argument is out of bounds');if(a+i>e.length)throw new RangeError("Index out of range")}function fn(e,t,a,i){t<0&&(t=65535+t+1);for(var n=0,r=Math.min(e.length-a,2);n<r;++n)e[a+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function mn(e,t,a,i){t<0&&(t=4294967295+t+1);for(var n=0,r=Math.min(e.length-a,4);n<r;++n)e[a+n]=t>>>8*(i?n:3-n)&255}function yn(e,t,a,i,n,r){if(a+i>e.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function gn(e,t,a,i,n){return n||yn(e,0,a,4),Ri(e,t,a,i,23,4),a+4}function bn(e,t,a,i,n){return n||yn(e,0,a,8),Ri(e,t,a,i,52,8),a+8}$i.prototype.slice=function(e,t){var a,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e),$i.TYPED_ARRAY_SUPPORT)(a=this.subarray(e,t)).__proto__=$i.prototype;else{var n=t-e;a=new $i(n,void 0);for(var r=0;r<n;++r)a[r]=this[r+e]}return a},$i.prototype.readUIntLE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=this[e],n=1,r=0;++r<t&&(n*=256);)i+=this[e+r]*n;return i},$i.prototype.readUIntBE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},$i.prototype.readUInt8=function(e,t){return t||pn(e,1,this.length),this[e]},$i.prototype.readUInt16LE=function(e,t){return t||pn(e,2,this.length),this[e]|this[e+1]<<8},$i.prototype.readUInt16BE=function(e,t){return t||pn(e,2,this.length),this[e]<<8|this[e+1]},$i.prototype.readUInt32LE=function(e,t){return t||pn(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},$i.prototype.readUInt32BE=function(e,t){return t||pn(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},$i.prototype.readIntLE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=this[e],n=1,r=0;++r<t&&(n*=256);)i+=this[e+r]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},$i.prototype.readIntBE=function(e,t,a){e|=0,t|=0,a||pn(e,t,this.length);for(var i=t,n=1,r=this[e+--i];i>0&&(n*=256);)r+=this[e+--i]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},$i.prototype.readInt8=function(e,t){return t||pn(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},$i.prototype.readInt16LE=function(e,t){t||pn(e,2,this.length);var a=this[e]|this[e+1]<<8;return 32768&a?4294901760|a:a},$i.prototype.readInt16BE=function(e,t){t||pn(e,2,this.length);var a=this[e+1]|this[e]<<8;return 32768&a?4294901760|a:a},$i.prototype.readInt32LE=function(e,t){return t||pn(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},$i.prototype.readInt32BE=function(e,t){return t||pn(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},$i.prototype.readFloatLE=function(e,t){return t||pn(e,4,this.length),Di(this,e,!0,23,4)},$i.prototype.readFloatBE=function(e,t){return t||pn(e,4,this.length),Di(this,e,!1,23,4)},$i.prototype.readDoubleLE=function(e,t){return t||pn(e,8,this.length),Di(this,e,!0,52,8)},$i.prototype.readDoubleBE=function(e,t){return t||pn(e,8,this.length),Di(this,e,!1,52,8)},$i.prototype.writeUIntLE=function(e,t,a,i){(e=+e,t|=0,a|=0,i)||hn(this,e,t,a,Math.pow(2,8*a)-1,0);var n=1,r=0;for(this[t]=255&e;++r<a&&(n*=256);)this[t+r]=e/n&255;return t+a},$i.prototype.writeUIntBE=function(e,t,a,i){(e=+e,t|=0,a|=0,i)||hn(this,e,t,a,Math.pow(2,8*a)-1,0);var n=a-1,r=1;for(this[t+n]=255&e;--n>=0&&(r*=256);)this[t+n]=e/r&255;return t+a},$i.prototype.writeUInt8=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,1,255,0),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},$i.prototype.writeUInt16LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):fn(this,e,t,!0),t+2},$i.prototype.writeUInt16BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):fn(this,e,t,!1),t+2},$i.prototype.writeUInt32LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):mn(this,e,t,!0),t+4},$i.prototype.writeUInt32BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):mn(this,e,t,!1),t+4},$i.prototype.writeIntLE=function(e,t,a,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*a-1);hn(this,e,t,a,n-1,-n)}var r=0,s=1,o=0;for(this[t]=255&e;++r<a&&(s*=256);)e<0&&0===o&&0!==this[t+r-1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+a},$i.prototype.writeIntBE=function(e,t,a,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*a-1);hn(this,e,t,a,n-1,-n)}var r=a-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+a},$i.prototype.writeInt8=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,1,127,-128),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},$i.prototype.writeInt16LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):fn(this,e,t,!0),t+2},$i.prototype.writeInt16BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):fn(this,e,t,!1),t+2},$i.prototype.writeInt32LE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,2147483647,-2147483648),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):mn(this,e,t,!0),t+4},$i.prototype.writeInt32BE=function(e,t,a){return e=+e,t|=0,a||hn(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):mn(this,e,t,!1),t+4},$i.prototype.writeFloatLE=function(e,t,a){return gn(this,e,t,!0,a)},$i.prototype.writeFloatBE=function(e,t,a){return gn(this,e,t,!1,a)},$i.prototype.writeDoubleLE=function(e,t,a){return bn(this,e,t,!0,a)},$i.prototype.writeDoubleBE=function(e,t,a){return bn(this,e,t,!1,a)},$i.prototype.copy=function(e,t,a,i){if(a||(a=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<a&&(i=a),i===a)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-a&&(i=e.length-t+a);var n,r=i-a;if(this===e&&a<t&&t<i)for(n=r-1;n>=0;--n)e[n+t]=this[n+a];else if(r<1e3||!$i.TYPED_ARRAY_SUPPORT)for(n=0;n<r;++n)e[n+t]=this[n+a];else Uint8Array.prototype.set.call(e,this.subarray(a,a+r),t);return r},$i.prototype.fill=function(e,t,a,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,a=this.length):"string"==typeof a&&(i=a,a=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!$i.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<a)throw new RangeError("Out of range index");if(a<=t)return this;var r;if(t>>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(r=t;r<a;++r)this[r]=e;else{var s=Hi(e)?e:_n(new $i(e,i).toString()),o=s.length;for(r=0;r<a-t;++r)this[r+t]=s[r%o]}return this};var vn=/[^+\/0-9A-Za-z-_]/g;function wn(e){return e<16?"0"+e.toString(16):e.toString(16)}function _n(e,t){var a;t=t||1/0;for(var i=e.length,n=null,r=[],s=0;s<i;++s){if((a=e.charCodeAt(s))>55295&&a<57344){if(!n){if(a>56319){(t-=3)>-1&&r.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&r.push(239,191,189);continue}n=a;continue}if(a<56320){(t-=3)>-1&&r.push(239,191,189),n=a;continue}a=65536+(n-55296<<10|a-56320)}else n&&(t-=3)>-1&&r.push(239,191,189);if(n=null,a<128){if((t-=1)<0)break;r.push(a)}else if(a<2048){if((t-=2)<0)break;r.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;r.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;r.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return r}function An(e){return function(e){var t,a,i,n,r,s;Vi||Ii();var o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");r="="===e[o-2]?2:"="===e[o-1]?1:0,s=new Ci(3*o/4-r),i=r>0?o-4:o;var l=0;for(t=0,a=0;t<i;t+=4,a+=3)n=xi[e.charCodeAt(t)]<<18|xi[e.charCodeAt(t+1)]<<12|xi[e.charCodeAt(t+2)]<<6|xi[e.charCodeAt(t+3)],s[l++]=n>>16&255,s[l++]=n>>8&255,s[l++]=255&n;return 2===r?(n=xi[e.charCodeAt(t)]<<2|xi[e.charCodeAt(t+1)]>>4,s[l++]=255&n):1===r&&(n=xi[e.charCodeAt(t)]<<10|xi[e.charCodeAt(t+1)]<<4|xi[e.charCodeAt(t+2)]>>2,s[l++]=n>>8&255,s[l++]=255&n),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(vn,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function kn(e,t,a,i){for(var n=0;n<i&&!(n+a>=t.length||n>=e.length);++n)t[n+a]=e[n];return n}function Sn(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}const Nn={files:{},items:{},folders:{}};function Tn(e){return Nn.files[e]}function Mn(){return Nn.folders}function xn(e){return Nn.folders[e]}function Cn(e,t){for(const a of Object.values(Nn.folders))if(a.name===e&&a.parent===t)return a}function Vn(e,t){for(const a of Object.values(Nn.items))if(a.name===e&&a.folder._id===t)return a}function In(){return Nn.items}function En(e){return Nn.items[e]}function Fn(e,t){Nn.items[e]=t.rootItem;for(const[e,a]of Object.entries(t.metadata)){if(t.files[e]&&(Nn.files[e]={blob:new Blob([t.files[e]],{type:a.mimeType}),hash:a.hash,itemName:a.name,itemType:a.type,mimeType:a.mimeType}),a.attachments)for(const i of a.attachments){const a=Rn(e,i.name,i.queryParam,i.index);Nn.files[a]={blob:new Blob([t.files[a]],{type:i.mimeType}),hash:i.hash,itemName:i.name,itemType:i.type,mimeType:i.mimeType}}Nn.items[e]=a}for(const a of Object.values(t.folders))a._id=e+":"+a._id,a.parent=e+":"+a.parent,Nn.folders[a._id]=a}async function Dn(e,t){const a=$i.from(await e.arrayBuffer());let i=0;i+=8;const n=a.readInt32LE(8);i+=4;const r=new TextDecoder,s=a.subarray(i,i+n);i+=n;const o=JSON.parse(r.decode(s));o.root=t+"/"+o.root;let l=0;const u=Ni.ungzip(a.subarray(i)),c=$i.from(u),d=c.subarray(l,l+o.metadataSize);l+=o.metadataSize;const p=JSON.parse(r.decode(d)),h={};Object.entries(p).forEach((([e,a])=>{const i=t+"/"+e;a._id=i,h[i]=a,a.folder._id=t+":"+a.folder._id;for(const e of a.links)e.to=t+"/"+e.to}));const f=c.subarray(l,l+o.foldersSize);l+=o.foldersSize;const m=JSON.parse(r.decode(f)),y={};for(const[,e]of Object.entries(h))if(e.filesize&&(y[e._id]={start:l+(e.packageFileOffset||0),end:l+(e.packageFileOffset||0)+e.filesize}),e.attachments)for(const t of e.attachments)y[Rn(e._id,t.name,t.queryParam,t.index)]={start:l+(t.packageFileOffset||0),end:l+(t.packageFileOffset||0)+t.filesize};const g={};for(const[e,t]of Object.entries(y)){const a=c.subarray(t.start,t.end);g[e]=a}const b=h[o.root],v=[],w=e=>{v.push(e._id);for(const t of e.links)t.item=structuredClone(h[t.to]),w(t.item)};return w(b),{rootItem:b,metadata:h,folders:m,files:g}}function Rn(e,t,a,i){return`${e}_${t}`+(null!=a?`_${a}`:"")+(null!=i?`_${i}`:"")}function Pn(e,t,a,i){return Array.isArray(e.attachments)?e.attachments.filter((e=>e.name===t&&(void 0===i||e.index===i))).reduce(((e,t)=>Math.abs(t.queryParam-(a??0))<Math.abs(e.queryParam-(a??0))?t:e),{queryParam:1/0}):null}function Ln(e,t,a,i){const n=En(e);if(n){const r=Pn(n,t,a,i);if(!r)return null;return Tn(Rn(e,r.name,r.queryParam,r.index))}}var Bn=Object.freeze({__proto__:null,addPackageToCache:Fn,createAttachmentID:Rn,findFolder:Cn,findItem:Vn,getAttachmentFromPackageCache:Ln,getFileFromCache:Tn,getFolder:xn,getFolders:Mn,getItemFromCache:En,getItems:In,parsePackage:Dn,queryAttachments:Pn});class On{id=h.createGUID();items=[]}class $n{itemRepo;undoEvents=[];redoEvents=[];maxUndoCount=100;enabled=!0;snapshots=new Map;_undoRedoPromise=Promise.resolve();constructor(e,t=100){this.itemRepo=e,this.maxUndoCount=t,g.instance.setUndoManager(this),u.$on("undoManager:undo",(e=>this.undo(e))),u.$on("undoManager:redo",(e=>this.redo(e)))}clear(){this.undoEvents=[],this.redoEvents=[],this.snapshots.clear(),u.$emit("undoManager:undoStepsChanged",0),u.$emit("undoManager:redoStepsChanged",0)}createSnapshot(){const e=new On;for(const t of this.itemRepo.itemInstances.values())for(const a of t.values())e.items.push({_id:a._id,instanceId:a.instanceId,data:this._grabSnapshot(a)});return this.snapshots.set(e.id,e),e.id}rollbackFromSnapshot(e){const t=this.snapshots.get(e);if(!t)throw new _("Snapshot not found");for(const e of t.items){const t=this.itemRepo.itemInstances.get(e._id);if(t){const a=t.get(e.instanceId);a?this._rollbackFromSnapshot(a,e.data):console.error(`[SNAPSHOT] - Trying to rollback snapshot for item but did not find the instance: ${e._id} -> ${e.instanceId}`)}else console.error(`[SNAPSHOT] - Trying to rollback snapshot for item but did not find the item map: ${e._id}`)}this.snapshots.delete(e)}_grabSnapshot(e){const t=[];for(const a of e.fieldInstances)try{t.push(a.createSnapshot())}catch(e){const t=`[SNAPSHOT] - Could not grab snapshot of field ${a.name}`;throw console.error(t,e),new Error(e.toString())}const a=[];for(const t of e.customFieldInstances)try{a.push(t.createSnapshot())}catch(e){const a=`[SNAPSHOT] - Could not grab snapshot of custom field ${t.name}`;throw console.error(a,e),new Error(e.toString())}return new O(e._id,"item",{fieldInstances:t,customFieldInstances:a})}_getFieldInstance(e,t){for(const a of e.fieldInstances)if(a.getId()===t)return a;return null}_getCustomFieldInstance(e,t){for(const a of e.customFieldInstances)if(a.getId()===t)return a;return null}_rollbackFromSnapshot(e,t){for(const a of t.data.fieldInstances){const t=this._getFieldInstance(e,a.id);t?t.rollbackFromSnapshot(a):console.warn("[SNAPSHOT] - Could not find field instance in snapshot: "+a.id)}for(const a of t.data.customFieldInstances){const t=this._getCustomFieldInstance(e,a.id);t?t.rollbackFromSnapshot(a):console.warn("[SNAPSHOT] - Could not find custom field instance in snapshot: "+a.id)}}getEnabled(){return this.enabled}setEnabled(e){this.enabled=!!e}ignore(e){const t=this.enabled;let a=!1;try{t&&this.setEnabled(!1);const i=e();if(i&&i.then)return a=!0,i.finally((()=>{t&&this.setEnabled(!0)}))}finally{t&&!a&&this.setEnabled(!0)}}undo(e){return this._undoRedoPromise=this._undoRedoPromise.then((()=>this._performUndo(e))),this._undoRedoPromise}redo(e){return this._undoRedoPromise=this._undoRedoPromise.then((()=>this._performRedo(e))),this._undoRedoPromise}async _performUndo(e){if(this.enabled&&this.undoEvents.length){for(e=e||1;this.undoEvents.length>0&&e>0;){const t=this.spliceLastEventBundle(this.undoEvents).reverse();for(const e of t)await e.undo(),this.redoEvents.push(e);e--}u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles()),u.$emit("undoManager:redoStepsChanged",this.getNumberOfRedoBundles())}}async _performRedo(e){if(this.enabled&&this.redoEvents.length){for(e=e||1;this.redoEvents.length>0&&e>0;){const t=this.spliceLastEventBundle(this.redoEvents).reverse();for(const e of t)await e.redo(),this.undoEvents.push(e);e--}u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles()),u.$emit("undoManager:redoStepsChanged",this.getNumberOfRedoBundles())}}getUndoSteps(){return this.undoEvents.map((function(e){return{type:e.type,itemId:e.itemId,prop:e.prop}}))}getRedoSteps(){return this.redoEvents.map((e=>({type:e.type,itemId:e.itemId,prop:e.prop})))}event(e){if(this.enabled){if(this.redoEvents=[],u.$emit("undoManager:redoStepsChanged",0),this.assignBundleIndexToEvent(e),0!==this.undoEvents.length){let t=!1;for(let a=this.undoEvents.length-1;a>=0;a--){const i=this.undoEvents[a];if(!e.isWithinMergeDeltaOf(i,300))break;const n=i.merge(e,300);if(n){t=!0,this.undoEvents.splice(a,1),this.undoEvents.push(n);break}}t||(this.undoEvents.push(e),u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles()))}else this.undoEvents.push(e),u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles());if(this.getNumberOfUndoBundles()>this.maxUndoCount){this.spliceFirstEventBundle(this.undoEvents);for(const e of this.undoEvents)e.bundleIndex-=1;u.$emit("undoManager:undoStepsChanged",this.getNumberOfUndoBundles())}}}getNumberOfUndoBundles(){return 0===this.undoEvents.length?0:this.undoEvents.at(-1).bundleIndex+1}getNumberOfRedoBundles(){if(0===this.redoEvents.length)return 0;const e=this.getNumberOfUndoBundles()-1;return this.redoEvents.at(0).bundleIndex-e}spliceLastEventBundle(e){if(0===e.length)return[];const t=e.at(-1).bundleIndex;let a=e.length-1;for(let i=e.length-1;i>=0&&e[i].bundleIndex===t;i--)a=i;return e.splice(a)}spliceFirstEventBundle(e){if(0===e.length)return[];const t=e.at(0).bundleIndex;for(let a=1;a<e.length;a++)if(e[a].bundleIndex!==t)return e.splice(0,a);return e.splice(0)}assignBundleIndexToEvent(e){if(0===this.undoEvents.length)return void(e.bundleIndex=0);const t=this.undoEvents.at(-1),a=Math.abs(e.createdAt-t.createdAt);e.bundleIndex=a>300?t.bundleIndex+1:t.bundleIndex}}class Un{updateItemLinksAndAttributes(e,t,a){try{const i=[],n={},r={};this.getLinksAndAttributes(e,i,n,r,t,a),e.attributes=n,e.userAttributes=r,e.links=i}catch(e){throw console.error(e),new k(e)}}getLinksAndAttributes(e,t,a,i,n,r){e.fieldInstances.length&&this.retrieveLinksAndAttributesFromFieldInstances(e.fieldInstances,t,a,n,r),e.userFieldInstances.length&&this.retrieveLinksAndAttributesFromFieldInstances(e.userFieldInstances,t,i,n,r),e.customFieldInstances.length&&(console.log(e.customFieldInstances),this.retrieveLinksAndAttributesFromFieldInstances(e.customFieldInstances,t,i,n,r,"_"))}retrieveLinksAndAttributesFromFieldInstances(e,t,a,i,n,r=""){for(const s of e)switch(s.type){case"Link":if(s.value&&t){if(n&&s.hidden)continue;i?t.push({usage:r+s.name,to:s.value._id,item:s.value}):t.push({usage:r+s.name,to:s.value._id})}break;case"Attribute":a&&(a[r+s.name]=s.value);break;case"List":s.blocks&&this.traverseListFieldInstances(s.blocks,t,a,r+s.name,i);break;case"Tree":if(s.blocks){const e=s.blocks[0];e.blocks&&this.traverseTreeFieldInstance(e.blocks,t,a,r+s.name,i)}break;case"NodeGraph":if(s.blocks&&this.traverseTreeFieldInstance(s.blocks,t,a,r+s.name,i),a&&Array.isArray(s.connections)){let e=0;for(const t of s.connections){a[`${r}${s.name}#connection[${e++}]`]={srcNode:t.srcNode,srcSlot:t.srcSlot,destNode:t.destNode,destSlot:t.destSlot}}}}}traverseTreeFieldInstance(e,t,a,i,n){let r=0;for(const s of e){const e=`${i}[${r}]`,o=e+"#type",l=e+"#id",u=e+"#posx",c=e+"#posy";a&&(a[e+"#usage"]="Block",a[o]=s.type,a[l]=s.id,void 0!==s.posX&&(a[u]=s.posX||0),void 0!==s.posY&&(a[c]=s.posY||0));for(const i of s.fields){const r=`${e}->${i.name}`;switch(i.type){case"Link":i.value&&t&&(n?t.push({usage:r,to:i.value._id,item:i.value}):t.push({usage:r,to:i.value._id}));break;case"List":i.blocks&&this.traverseListFieldInstances(i.blocks,t,a,r,n);break;case"Attribute":a&&(a[r]=i.value)}}s.scripts&&this.processScripts(s.scripts,t,a,e,n),s.blocks&&this.traverseTreeFieldInstance(s.blocks,t,a,e,n),r++}}traverseListFieldInstances(e,t,a,i,n){let r=0;for(const s of e){const e=`${i}[${r}]`;for(const i of s.fields){const r=`${e}->${i.name}`;switch(i.type){case"Link":if(i.value&&t){const e={usage:r,to:"object"==typeof i.value?i.value._id:i.value,item:null};n&&"object"===i.value&&(e.item=i.value),t.push(e)}break;case"Attribute":a&&(a[r]=i.value)}}r++}}processScripts(e,t,a,i,n){let r=0;for(const s of e){const e=`${i}#scripts[${r}]`,o=e+"#id",l=e+"#item";a&&(a[e+"#usage"]="Script",a[o]=s.id),t&&s.item.value&&(n?t.push({usage:l,to:s.item.value._id,item:s.item.value}):t.push({usage:l,to:s.item.value._id}));for(const i of s.fields){const r=`${e}->${i.name}`;if("Link"===i.type)i.value&&t&&(n?t.push({usage:r,to:i.value._id,item:i.value}):t.push({usage:r,to:i.value._id}));else a&&(a[r]=i.value)}r++}}}class jn{apiClient;activeItem=void 0;rootItemId=void 0;loadingItems=new Map;loadedItems=new Map;itemInstances=new Map;resolvedPaths=new Map;jail;apiGateway;itemCache;undoManager=new $n(this);itemPreparator=new te(this);itemChangeProcessor=new Un;usePublicApi;constructor(e,t){this.apiClient=t,this.apiGateway=new L(t),this.itemCache=new B(this.apiGateway),this.usePublicApi=!!e,this.jail={active:!1,mountedFolders:[]},u.$on("item:rename",(e=>this.handleRename(e)))}_logGroup(e){}_logGroupEnd(){}_log(e){}getLoadedItems(){return Array.from(this.loadedItems.values())}getItemInstances(){return this.itemInstances}findLoadedItem(e){return this.loadedItems.get(e)}_handleError(e,t){throw console.error(e),new k("ItemRepo: "+t)}getUndoManager(){return this.undoManager}async createFieldsForItem(e,t,a,i=!1){return this.itemPreparator.createFields(e,a,t,"",!1,a.attributes,i)}async createScriptsForItem(e,t=[],a,i=!0){const n=[];for(const i of t){if(!i.item)continue;const t=await this.loadItem(i.item);if(!t)continue;const r=new W(void 0,e,a,t);n.push(r);for(const e of i.fields){const t=new j(r,e.name,e.value,a);r.addField(t)}}e.scripts=i?g.instance.proxyScriptArray(n,e,a):n}clear(){this.rootItemId=void 0,this.activeItem=void 0,this.loadedItems.clear(),this.resolvedPaths.clear(),this.itemInstances.clear(),this.loadingItems.clear();this.apiClient.getCollab().endCollaboration()}removeBlock(e,t){t.blocks.removeObject(e),e.parent=void 0}traverseBlockPairs(e,t,a){a(e,t);for(let i=0;i<e.blocks.length&&i<t.blocks.length;i++)this.traverseBlockPairs(e.blocks[i],t.blocks[i],a)}copyScripts(e,t,a=!1){const i=new Map;this.traverseBlockPairs(e,t,((e,t)=>i.set(e.getId(),t.getId())));const n=[];return this.traverseBlockPairs(e,t,((e,t)=>{for(const r of e.scripts){const e=r.clone(i);a&&(e.deferInitCall=!0),t.scripts.push(e),n.push(e)}})),n}updateScriptFieldReferences(e,t){const a=new Map;this.traverseBlockPairs(e,t,((e,t)=>{a.set(e.id,t.id)})),this.updateScriptFieldReferencesFromMap(a,t)}updateScriptFieldReferencesFromMap(e,t){this.traverseBlocks((t=>{for(const a of t.scripts)for(const t of a.fields)e.has(t.value)&&(t.value=e.get(t.value))}),[t])}async createNewBlock(e,t,a){const i=new ae(void 0,t,e.typeName,void 0,void 0,a),n=await this.createFieldsForItem(i,e.template,a);return i.setFields(n),i.blocks=g.instance.proxyBlockArray(i.blocks,i,a),await this.createScriptsForItem(i,void 0,a),this.addBlockToParent(i,t,a)}addBlockToParent(e,t,a){e.parent=t;const i=g.instance.proxyBlock(e,a);return t.blocks.push(i),i}async createNewListEntry(e,t,a){const i=new ae(void 0,void 0,e.typeName,void 0,void 0,a),n=await this.createFieldsForItem(i,e.template,a);return i.setFields(n),i.blocks=g.instance.proxyListArray(i.blocks,t,a),g.instance.proxyBlock(i,a)}async createNewGraphNode(e,t,a,i,n){const r=new ae(void 0,void 0,e.typeName,void 0,e.displayName,n),s=await this.itemPreparator.createFields(r,n,e.template,"",!0,n.attributes);return r.setFields(s),r.setInputs(e.inputs),r.setOutputs(e.outputs),r.setPosition(a,i),r.blocks=g.instance.proxyGraphBlockArray(r.blocks,t),this.addNodeToGraph(r,t,n),r}addNodeToGraph(e,t,a){const i=g.instance.proxyGraphBlock(e,a);t.blocks.push(i)}removeGraphNode(e,t){const a=[];for(const i of e.connections)i.srcNode!==t.id&&i.destNode!==t.id||a.push(i);for(const t of a)e.connections.removeObject(t);e.blocks.removeObject(t)}addGraphLink(e,t,a,i,n,r){e.connections.push(new U({srcNode:t,srcSlot:a,destNode:i,destSlot:n},r))}removeGraphLink(e,t,a,i,n){for(const r of e.connections)if(r.srcNode===t&&r.srcSlot===a&&r.destNode===i&&r.destSlot===n)return void e.connections.removeObject(r)}createNewScript(e,t=-1,a){t=t>=0?t:e.scripts.length;const i=new W(void 0,e,a);return e.scripts.splice(t,0,i),i}removeScript(e,t){t.scripts.removeObject(e)}findBlock(e){for(const t of this.itemInstances.values())for(const a of t.values()){const t=a.findBlock(e);if(t)return t}return null}async loadPackage(e,t){const a=await h.downloadFile(e,((e,a,i)=>{t&&t({phase:"Loading",percent:e,bytesTotal:a,bytesLoaded:i})})),i=await a.data;this.apiClient.getCollab().endCollaboration();const n=new K({_id:"root",name:"Root package",type:"Package",links:[],attributes:{},fields:[],readOnly:!0,isPackaged:!1}),r=await Dn(i,n._id);Fn(n._id,structuredClone(r));const s=Object.values(r.metadata).reverse();for(const e of s)e._id===r.rootItem._id&&(n.packageContent=e,n.packageType=e.type);return await this._linkAndPrepareItems(s),n.packageContent=this.loadedItems.get(r.rootItem._id),this.activeItem=n,n}createPackageItemUrl(e){const t=Tn(e);return t?URL.createObjectURL(t.blob):null}revokePackageItemUrl(e){URL.revokeObjectURL(e)}async _loadPackageContentRecursively(e,t){t("Loading from cache",0);const a=await this.apiClient.itemCache.addItemToCache(e._id,void 0,e.hash,(function(e,a,i){t("Loading from cloud",.9*e,i,a)})),i=await(await fetch(a.objectUrl)).blob();t("Unpacking",90);const n=await Dn(i,e._id);Fn(e._id,structuredClone(n));const r=Object.values(n.metadata).reverse();for(const t of r)t._id===n.rootItem._id&&(e.packageContent=t,e.packageType=t.type);return r}createNewItemInstance(e){const t=this.loadedItems.get(e);if(!t)return console.error(`Tried creating new instance of item, but it was not found: ${e}`),null;const a=t.clone(!0);return this._addItemInstance(a),a}_addLoadedItem(e){this.loadedItems.set(e._id,e),this._addItemInstance(e)}_addItemInstance(e){let t=this.itemInstances.get(e._id);t||(t=new Map,this.itemInstances.set(e._id,t)),t.set(e.instanceId,e)}async loadItemByRelativePath(e,t,a={}){try{const i=En(e);let n;if(i){const e=t.split("/"),a=e.pop();let r=xn(i.folder._id);for(const t of e)if(r=".."===t?xn(r.parent):Cn(t,r._id),!r)return;const s=Vn(a,r._id);n=s?._id}else n=await this.resolveRelativePath(t,e);return this.loadItem(n,a)}catch(e){this._handleError(e,`Unable to load item by relative path: ${t}: ${e}`)}}async _loadItemFromApi(e,t={}){let a;if(this.apiGateway.start(),t.recursive)if(this.usePublicApi)a=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e,!0),a.forEach((e=>e.public=!0));else try{a=await this.apiGateway.call("_loadItemFromApi","getItemAggregatedRecursive",e,{withAttachmentInfo:!0,noFields:!0})}catch{a=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e,!0),a.forEach((e=>e.public=!0))}else{let t;if(this.usePublicApi)t=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e),t.public=!0;else try{t=await this.apiGateway.call("_loadItemFromApi","getItemAggregated",e,{noFields:!0})}catch{t=await this.apiGateway.call("_loadItemFromApi","getItemPublicRecursive",e),t.public=!0}a=[t]}return this.apiGateway.end(),a}_relinkItems(e,t){for(const a of e){if(Array.isArray(a.links))for(const e of a.links)e.item=t.get(e.to),e.item||e.stopRecursion||console.warn(`Missing link in item '${a.name}' (${a._id}) to: ${e.to} with usage ${e.usage}`);a.packageContent&&(a.packageContent=t.get(a.packageContent._id))}}createItem(e,t){const a={_id:h.createGeneratedItemId(),name:`Generated ${e}`,type:e,attributes:t||{},links:[],fields:[],fieldInstances:[],userFieldInstances:[],isGenerated:!0};return this.itemPreparator.prepare(a)}getLoadedItem(e){return this.loadedItems.get(e)}async loadItem(e,t={}){let a,i,n;if(n=this.loadedItems.get(e),n)return n;if(n=this.loadingItems.get(e),n)return n;try{const r=new Promise(((e,t)=>{a=e,i=t}));return this.loadingItems.set(e,r),n=await this._loadItemInternal(e,t),a(n),!this.activeItem&&n&&(this.rootItemId=e,this.activeItem=n,t.withCollaboration,await u.$emit("itemRepo:itemLoaded",n)),n}catch(t){return this._handleError(t,`Unable to load item ${e}: ${t}`),void i(void 0)}finally{this.loadingItems.delete(e)}}async _loadItemInternal(e,t={}){const a=(e,a,i=0,n=0)=>{"function"==typeof t.progressCallback&&t.progressCallback({phase:e,percent:a,bytesTotal:i,bytesLoaded:n})};a("Fetching metadata",1);let i=await this._loadItemFromApi(e,t);if(i=i.filter((e=>!this.loadedItems.has(e._id))),0===i.length)return console.log("After loading the item, it turns out we have them all already loaded! This should not happen!"),this.loadedItems.get(e);const n=i[0]._id;for(const e of i)if("Package"===e.type){const t=await this._loadPackageContentRecursively(e,a);for(const e of t)i.push(e)}a("Preparing data",100),await this._linkAndPrepareItems(i);return this.loadedItems.get(n)}async _linkAndPrepareItems(e){const t=new Map;for(const a of e)t.set(a._id,a);const a=new Map([...this.loadedItems,...t]);this._relinkItems(e,a);const i=[],n=()=>{const e=t.values().next().value;return t.delete(e._id),this._log(`- Fetched next item ${e.name} (${e._id})`),e},r=async e=>{this._logGroup(`- Preparing item ${e.name} (${e._id})`);const t=await this.itemPreparator.prepare(e);return i.push(t),this._addLoadedItem(t),this._logGroupEnd(),t};for(this.itemPreparator.setItemFetcher((async e=>{this._logGroup(`- Requesting item ${e.name} (${e._id})`);let a=this.loadedItems.get(e._id);if(a)return this._log("- Already prepared. Returning."),this._logGroupEnd(),a;const i=t.get(e._id);return i?(t.delete(e._id),this._log("- Don't have it yet. Preparing..."),a=await r(i),this._log("- Now prepared. Returning."),this._logGroupEnd(),a):(console.error("ItemFetcher: Could not find requested item: "+e._id,t,this.loadedItems),null)}));t.size>0;){let e=n();await r(e)}return this._relinkItems(i,this.loadedItems),i}async resolveRelativePath(e,t=null){if(!(t=t||this.activeItem?._id||null))return null;const a=`${t}#${e}`;let i;return i=this.resolvedPaths.has(a)?this.resolvedPaths.get(a):this.usePublicApi?await this.apiClient.publicResolveRelativeItem(t,e):await this.apiClient.resolveRelativeItem(t,e),this.resolvedPaths.set(a,i),i}async traverseItems(e,t=void 0){if("function"!=typeof e)return;const a=this,i=new Map;await async function t(n){if(!n)return;if(i.has(n._id))return;i.set(n._id,!0);const r=e(n);if(r&&r.then&&await r,Array.isArray(n.links))for(const e of n.links)if(e.item)await t(e.item);else if(e.to)try{const i=await a.loadItem(e.to);await t(i)}catch{console.warn(`Could not load additional item ${e.to} so cannot traverse it. Probably dead link!`)}}(t||this.activeItem)}async traverseBlocks(e,t){for(const a of t){const t=e(a);t&&t.then&&await t,Array.isArray(a.blocks)&&a.blocks?.length&&await this.traverseBlocks(e,a.blocks)}}async traverseFieldInstances(e,t){const a=this;t=t||this.activeItem?.fieldInstances||[];for(const i of t){const t=e(i);t&&t.then&&await t,Array.isArray(i.blocks)&&await this.traverseBlocks((async function(t){Array.isArray(t.fields)&&t.fields?.length&&await a.traverseFieldInstances(e,t.fields)}),i.blocks)}}async _updateLinkReferences(e,t,a,i){t?await this.traverseItems((async n=>{if(Array.isArray(n.fieldInstances)&&n.fieldInstances.length){await this.traverseFieldInstances((async a=>{"Link"===a.type&&a.value&&a.value._id===e&&(i&&(a.value=null),a.value=t)}),n.fieldInstances);for(const a of n.fieldInstances)Array.isArray(a.blocks)&&await this.traverseBlocks((async a=>{if(Array.isArray(a.scripts))for(const n of a.scripts)n.item?.value?._id===e&&(i&&(n.item.value=void 0),n.item.value=t)}),a.blocks)}if(n.links)for(const r of n.links)r.to===e&&(i&&(r.to=null,r.item=null),r.to=a,r.item=t)})):console.warn(`Aborting link update: Could not load item ${a}`)}async replaceLink(e,t){if(this.getLoadedItem(e)){const a=await this.loadItem(t,{recursive:!0});await this._updateLinkReferences(e,a,t,!1)}}async forceUpdateLink(e){const t=await this.loadItem(e,{recursive:!0});await this._updateLinkReferences(e,t,e,!0)}saveItem(e){return e._id&&e.isDirty?(this.itemChangeProcessor.updateItemLinksAndAttributes(e,!1,!0),e.version||(e.version={major:0,minor:0,revision:1}),this.apiClient.updateItem({_id:e._id,name:e.name,attributes:e.attributes,userAttributes:e.userAttributes,links:e.links,tags:e.tags,contributors:e.contributors,description:e.description,shortDescription:e.shortDescription,categories:e.categories,license:e.license,version:e.version,allowConversation:e.allowConversation,visibility:e.visibility}).then((t=>(JSON.stringify(e.version)===JSON.stringify(t.version)?console.log(`Saved item ${e.name}. New version: ${e.version.major}.${e.version.minor}.${e.version.revision}`):console.log(`Saved item ${e.name}. Version ${e.version.major}.${e.version.minor}.${e.version.revision} -> ${t.version.major}.${t.version.minor}.${t.version.revision}`),t&&t.version&&(e.version=t.version),e.isDirty=!1,this.itemChangeProcessor.updateItemLinksAndAttributes(e,!0,!1),e))).catch((function(t){throw console.error(`Error saving item ${e.name}`,t,e),t}))):null}async save(){console.log("Saving changes in loaded items...");const e=[];for(const t of this.loadedItems.values()){const a=this.saveItem(t);a&&e.push(a)}if(0!==e.length){let t=0;for(const a of e)a.then((function(a){u.$emit("itemRepo:itemSaved",{item:a,progress:++t,total:e.length})}));return Promise.all(e).then((function(){console.log("Saved successfully"),u.$emit("itemRepo:itemsSaved")})).catch((function(e){console.error("Error saving:",e)}))}console.log("No changes detected.")}async existsUnsavedChanges(){if(!this.activeItem)return!1;for(const e of this.loadedItems.values())if(e._id&&e.isDirty)return!0;return!1}handleRename({id:e,newName:t}){for(const a of this.itemInstances.values())for(const i of a.values())i._id===e&&(i.name=t)}isItemKnown(e){return this.loadedItems.has(e)||this.itemInstances.has(e)||this.loadingItems.has(e)}invalidateId(e){this.loadedItems.delete(e),this.itemInstances.delete(e),this.loadingItems.delete(e)}}var zn,Wn={exports:{}};
13
13
  /*!
14
14
  localForage -- Offline Storage, Improved
15
15
  Version 1.10.0
16
16
  https://localforage.github.io/localForage
17
17
  (c) 2013-2017 Mozilla, Apache License 2.0
18
- */var Yn=(zn||(zn=1,function(e){e.exports=function e(t,a,i){function n(s,o){if(!a[s]){if(!t[s]){if(!o&&E)return E(s);if(r)return r(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=a[s]={exports:{}};t[s][0].call(u.exports,(function(e){var a=t[s][1][e];return n(a||e)}),u,u.exports,e,t,a,i)}return a[s].exports}for(var r=E,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,a){(function(e){var a,i,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var r=0,s=new n(c),o=e.document.createTextNode("");s.observe(o,{characterData:!0}),a=function(){o.data=r=++r%2}}else if(e.setImmediate||void 0===e.MessageChannel)a="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){c(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(c,0)};else{var l=new e.MessageChannel;l.port1.onmessage=c,a=function(){l.port2.postMessage(0)}}var u=[];function c(){var e,t;i=!0;for(var a=u.length;a;){for(t=u,u=[],e=-1;++e<a;)t[e]();a=u.length}i=!1}function d(e){1!==u.push(e)||i||a()}t.exports=d}).call(this,void 0!==V?V:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,a){var i=e(1);function n(){}var r={},s=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==n&&h(this,e)}function c(e,t,a){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof a&&(this.onRejected=a,this.callRejected=this.otherCallRejected)}function d(e,t,a){i((function(){var i;try{i=t(a)}catch(t){return r.reject(e,t)}i===e?r.reject(e,new TypeError("Cannot resolve promise with itself")):r.resolve(e,i)}))}function p(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var a=!1;function i(t){a||(a=!0,r.reject(e,t))}function n(t){a||(a=!0,r.resolve(e,t))}function s(){t(n,i)}var o=f(s);"error"===o.status&&i(o.value)}function f(e,t){var a={};try{a.value=e(t),a.status="success"}catch(e){a.status="error",a.value=e}return a}function m(e){return e instanceof this?e:r.resolve(new this(n),e)}function y(e){var t=new this(n);return r.reject(t,e)}function g(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var a=e.length,i=!1;if(!a)return this.resolve([]);for(var s=new Array(a),o=0,l=-1,u=new this(n);++l<a;)c(e[l],l);return u;function c(e,n){function l(e){s[n]=e,++o!==a||i||(i=!0,r.resolve(u,s))}t.resolve(e).then(l,(function(e){i||(i=!0,r.reject(u,e))}))}}function b(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var a=e.length,i=!1;if(!a)return this.resolve([]);for(var s=-1,o=new this(n);++s<a;)l(e[s]);return o;function l(e){t.resolve(e).then((function(e){i||(i=!0,r.resolve(o,e))}),(function(e){i||(i=!0,r.reject(o,e))}))}}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===s)return this;var a=new this.constructor(n);return this.state!==l?d(a,this.state===o?e:t,this.outcome):this.queue.push(new c(a,e,t)),a},c.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},c.prototype.otherCallFulfilled=function(e){d(this.promise,this.onFulfilled,e)},c.prototype.callRejected=function(e){r.reject(this.promise,e)},c.prototype.otherCallRejected=function(e){d(this.promise,this.onRejected,e)},r.resolve=function(e,t){var a=f(p,t);if("error"===a.status)return r.reject(e,a.value);var i=a.value;if(i)h(e,i);else{e.state=o,e.outcome=t;for(var n=-1,s=e.queue.length;++n<s;)e.queue[n].callFulfilled(t)}return e},r.reject=function(e,t){e.state=s,e.outcome=t;for(var a=-1,i=e.queue.length;++a<i;)e.queue[a].callRejected(t);return e},u.resolve=m,u.reject=y,u.all=g,u.race=b},{1:1}],3:[function(e,t,a){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==V?V:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,a){var i="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};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var s=r();function o(){try{if(!s||!s.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if("TypeError"!==n.name)throw n;for(var a=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)a.append(e[i]);return a.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var u=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function d(e,t,a){"function"==typeof t&&e.then(t),"function"==typeof a&&e.catch(a)}function p(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function h(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var f="local-forage-detect-blob-support",m=void 0,y={},g=Object.prototype.toString,b="readonly",v="readwrite";function w(e){for(var t=e.length,a=new ArrayBuffer(t),i=new Uint8Array(a),n=0;n<t;n++)i[n]=e.charCodeAt(n);return a}function _(e){return new u((function(t){var a=e.transaction(f,v),i=l([""]);a.objectStore(f).put(i,"key"),a.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},a.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);t(a||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function A(e){return"boolean"==typeof m?u.resolve(m):_(e).then((function(e){return m=e}))}function k(e){var t=y[e.name],a={};a.promise=new u((function(e,t){a.resolve=e,a.reject=t})),t.deferredOperations.push(a),t.dbReady?t.dbReady=t.dbReady.then((function(){return a.promise})):t.dbReady=a.promise}function S(e){var t=y[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function N(e,t){var a=y[e.name].deferredOperations.pop();if(a)return a.reject(t),a.promise}function T(e,t){return new u((function(a,i){if(y[e.name]=y[e.name]||P(),e.db){if(!t)return a(e.db);k(e),e.db.close()}var n=[e.name];t&&n.push(e.version);var r=s.open.apply(s,n);t&&(r.onupgradeneeded=function(t){var a=r.result;try{a.createObjectStore(e.storeName),t.oldVersion<=1&&a.createObjectStore(f)}catch(a){if("ConstraintError"!==a.name)throw a;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),r.onerror=function(e){e.preventDefault(),i(r.error)},r.onsuccess=function(){var t=r.result;t.onversionchange=function(e){e.target.close()},a(t),S(e)}}))}function M(e){return T(e,!1)}function x(e){return T(e,!0)}function C(e,t){if(!e.db)return!0;var a=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,n=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),n||a){if(a){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function V(e){return new u((function(t,a){var i=new FileReader;i.onerror=a,i.onloadend=function(a){var i=btoa(a.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function I(e){return l([w(atob(e.data))],{type:e.type})}function E(e){return e&&e.__local_forage_encoded_blob}function F(e){var t=this,a=t._initReady().then((function(){var e=y[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return d(a,e,e),a}function D(e){k(e);for(var t=y[e.name],a=t.forages,i=0;i<a.length;i++){var n=a[i];n._dbInfo.db&&(n._dbInfo.db.close(),n._dbInfo.db=null)}return e.db=null,M(e).then((function(t){return e.db=t,C(e)?x(e):t})).then((function(i){e.db=t.db=i;for(var n=0;n<a.length;n++)a[n]._dbInfo.db=i})).catch((function(t){throw N(e,t),t}))}function R(e,t,a,i){void 0===i&&(i=1);try{var n=e.db.transaction(e.storeName,t);a(null,n)}catch(n){if(i>0&&(!e.db||"InvalidStateError"===n.name||"NotFoundError"===n.name))return u.resolve().then((function(){if(!e.db||"NotFoundError"===n.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),x(e)})).then((function(){return D(e).then((function(){R(e,t,a,i-1)}))})).catch(a);a(n)}}function P(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function L(e){var t=this,a={db:null};if(e)for(var i in e)a[i]=e[i];var n=y[a.name];n||(n=P(),y[a.name]=n),n.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=F);var r=[];function s(){return u.resolve()}for(var o=0;o<n.forages.length;o++){var l=n.forages[o];l!==t&&r.push(l._initReady().catch(s))}var c=n.forages.slice(0);return u.all(r).then((function(){return a.db=n.db,M(a)})).then((function(e){return a.db=e,C(a,t._defaultConfig.version)?x(a):e})).then((function(e){a.db=n.db=e,t._dbInfo=a;for(var i=0;i<c.length;i++){var r=c[i];r!==t&&(r._dbInfo.db=a.db,r._dbInfo.version=a.version)}}))}function B(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){R(a._dbInfo,b,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),E(e)&&(e=I(e)),t(e)},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function O(e,t){var a=this,i=new u((function(t,i){a.ready().then((function(){R(a._dbInfo,b,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName).openCursor(),o=1;s.onsuccess=function(){var a=s.result;if(a){var i=a.value;E(i)&&(i=I(i));var n=e(i,a.key,o++);void 0!==n?t(n):a.continue()}else t()},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function $(e,t,a){var i=this;e=p(e);var n=new u((function(a,n){var r;i.ready().then((function(){return r=i._dbInfo,"[object Blob]"===g.call(t)?A(r.db).then((function(e){return e?t:V(t)})):t})).then((function(t){R(i._dbInfo,v,(function(r,s){if(r)return n(r);try{var o=s.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var l=o.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),a(t)},s.onabort=s.onerror=function(){var e=l.error?l.error:l.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,a),n}function U(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){R(a._dbInfo,v,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName).delete(e);r.oncomplete=function(){t()},r.onerror=function(){i(s.error)},r.onabort=function(){var e=s.error?s.error:s.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function j(e){var t=this,a=new u((function(e,a){t.ready().then((function(){R(t._dbInfo,v,(function(i,n){if(i)return a(i);try{var r=n.objectStore(t._dbInfo.storeName).clear();n.oncomplete=function(){e()},n.onabort=n.onerror=function(){var e=r.error?r.error:r.transaction.error;a(e)}}catch(e){a(e)}}))})).catch(a)}));return c(a,e),a}function z(e){var t=this,a=new u((function(e,a){t.ready().then((function(){R(t._dbInfo,b,(function(i,n){if(i)return a(i);try{var r=n.objectStore(t._dbInfo.storeName).count();r.onsuccess=function(){e(r.result)},r.onerror=function(){a(r.error)}}catch(e){a(e)}}))})).catch(a)}));return c(a,e),a}function W(e,t){var a=this,i=new u((function(t,i){e<0?t(null):a.ready().then((function(){R(a._dbInfo,b,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName),o=!1,l=s.openKeyCursor();l.onsuccess=function(){var a=l.result;a?0===e||o?t(a.key):(o=!0,a.advance(e)):t(null)},l.onerror=function(){i(l.error)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function Y(e){var t=this,a=new u((function(e,a){t.ready().then((function(){R(t._dbInfo,b,(function(i,n){if(i)return a(i);try{var r=n.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];r.onsuccess=function(){var t=r.result;t?(s.push(t.key),t.continue()):e(s)},r.onerror=function(){a(r.error)}}catch(e){a(e)}}))})).catch(a)}));return c(a,e),a}function H(e,t){t=h.apply(this,arguments);var a=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||a.name,e.storeName=e.storeName||a.storeName);var i,n=this;if(e.name){var r=e.name===a.name&&n._dbInfo.db?u.resolve(n._dbInfo.db):M(e).then((function(t){var a=y[e.name],i=a.forages;a.db=t;for(var n=0;n<i.length;n++)i[n]._dbInfo.db=t;return t}));i=e.storeName?r.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var a=t.version+1;k(e);var i=y[e.name],n=i.forages;t.close();for(var r=0;r<n.length;r++){var o=n[r];o._dbInfo.db=null,o._dbInfo.version=a}var l=new u((function(t,i){var n=s.open(e.name,a);n.onerror=function(e){n.result.close(),i(e)},n.onupgradeneeded=function(){n.result.deleteObjectStore(e.storeName)},n.onsuccess=function(){var e=n.result;e.close(),t(e)}}));return l.then((function(e){i.db=e;for(var t=0;t<n.length;t++){var a=n[t];a._dbInfo.db=e,S(a._dbInfo)}})).catch((function(t){throw(N(e,t)||u.resolve()).catch((function(){})),t}))}})):r.then((function(t){k(e);var a=y[e.name],i=a.forages;t.close();for(var n=0;n<i.length;n++)i[n]._dbInfo.db=null;var r=new u((function(t,a){var i=s.deleteDatabase(e.name);i.onerror=function(){var e=i.result;e&&e.close(),a(i.error)},i.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}}));return r.then((function(e){a.db=e;for(var t=0;t<i.length;t++)S(i[t]._dbInfo)})).catch((function(t){throw(N(e,t)||u.resolve()).catch((function(){})),t}))}))}else i=u.reject("Invalid arguments");return c(i,t),i}var G={_driver:"asyncStorage",_initStorage:L,_support:o(),iterate:O,getItem:B,setItem:$,removeItem:U,clear:j,length:z,key:W,keys:Y,dropInstance:H};function q(){return"function"==typeof openDatabase}var Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",K=/^~~local_forage_type~([^~]+)~/,X="__lfsc__:",Q=X.length,ee="arbf",te="blob",ae="si08",ie="ui08",ne="uic8",re="si16",se="si32",oe="ur16",le="ui32",ue="fl32",ce="fl64",de=Q+ee.length,pe=Object.prototype.toString;function he(e){var t,a,i,n,r,s=.75*e.length,o=e.length,l=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var u=new ArrayBuffer(s),c=new Uint8Array(u);for(t=0;t<o;t+=4)a=Z.indexOf(e[t]),i=Z.indexOf(e[t+1]),n=Z.indexOf(e[t+2]),r=Z.indexOf(e[t+3]),c[l++]=a<<2|i>>4,c[l++]=(15&i)<<4|n>>2,c[l++]=(3&n)<<6|63&r;return u}function fe(e){var t,a=new Uint8Array(e),i="";for(t=0;t<a.length;t+=3)i+=Z[a[t]>>2],i+=Z[(3&a[t])<<4|a[t+1]>>4],i+=Z[(15&a[t+1])<<2|a[t+2]>>6],i+=Z[63&a[t+2]];return a.length%3==2?i=i.substring(0,i.length-1)+"=":a.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function me(e,t){var a="";if(e&&(a=pe.call(e)),e&&("[object ArrayBuffer]"===a||e.buffer&&"[object ArrayBuffer]"===pe.call(e.buffer))){var i,n=X;e instanceof ArrayBuffer?(i=e,n+=ee):(i=e.buffer,"[object Int8Array]"===a?n+=ae:"[object Uint8Array]"===a?n+=ie:"[object Uint8ClampedArray]"===a?n+=ne:"[object Int16Array]"===a?n+=re:"[object Uint16Array]"===a?n+=oe:"[object Int32Array]"===a?n+=se:"[object Uint32Array]"===a?n+=le:"[object Float32Array]"===a?n+=ue:"[object Float64Array]"===a?n+=ce:t(new Error("Failed to get type for BinaryArray"))),t(n+fe(i))}else if("[object Blob]"===a){var r=new FileReader;r.onload=function(){var a=J+e.type+"~"+fe(this.result);t(X+te+a)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(a){console.error("Couldn't convert value into a JSON string: ",e),t(null,a)}}function ye(e){if(e.substring(0,Q)!==X)return JSON.parse(e);var t,a=e.substring(de),i=e.substring(Q,de);if(i===te&&K.test(a)){var n=a.match(K);t=n[1],a=a.substring(n[0].length)}var r=he(a);switch(i){case ee:return r;case te:return l([r],{type:t});case ae:return new Int8Array(r);case ie:return new Uint8Array(r);case ne:return new Uint8ClampedArray(r);case re:return new Int16Array(r);case oe:return new Uint16Array(r);case se:return new Int32Array(r);case le:return new Uint32Array(r);case ue:return new Float32Array(r);case ce:return new Float64Array(r);default:throw new Error("Unkown type: "+i)}}var ge={serialize:me,deserialize:ye,stringToBuffer:he,bufferToString:fe};function be(e,t,a,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],a,i)}function ve(e){var t=this,a={db:null};if(e)for(var i in e)a[i]="string"!=typeof e[i]?e[i].toString():e[i];var n=new u((function(e,i){try{a.db=openDatabase(a.name,String(a.version),a.description,a.size)}catch(e){return i(e)}a.db.transaction((function(n){be(n,a,(function(){t._dbInfo=a,e()}),(function(e,t){i(t)}))}),i)}));return a.serializer=ge,n}function we(e,t,a,i,n,r){e.executeSql(a,i,n,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,o){o.rows.length?r(e,s):be(e,t,(function(){e.executeSql(a,i,n,r)}),r)}),r):r(e,s)}),r)}function _e(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"SELECT * FROM "+n.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,a){var i=a.rows.length?a.rows.item(0).value:null;i&&(i=n.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function Ae(e,t){var a=this,i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"SELECT * FROM "+n.storeName,[],(function(a,i){for(var r=i.rows,s=r.length,o=0;o<s;o++){var l=r.item(o),u=l.value;if(u&&(u=n.serializer.deserialize(u)),void 0!==(u=e(u,l.key,o+1)))return void t(u)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function ke(e,t,a,i){var n=this;e=p(e);var r=new u((function(r,s){n.ready().then((function(){void 0===t&&(t=null);var o=t,l=n._dbInfo;l.serializer.serialize(t,(function(t,u){u?s(u):l.db.transaction((function(a){we(a,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){r(o)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void r(ke.apply(n,[e,o,a,i-1]));s(t)}}))}))})).catch(s)}));return c(r,a),r}function Se(e,t,a){return ke.apply(this,[e,t,a,1])}function Ne(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"DELETE FROM "+n.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function Te(e){var t=this,a=new u((function(e,a){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){a(t)}))}))})).catch(a)}));return c(a,e),a}function Me(e){var t=this,a=new u((function(e,a){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,a){var i=a.rows.item(0).c;e(i)}),(function(e,t){a(t)}))}))})).catch(a)}));return c(a,e),a}function xe(e,t){var a=this,i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"SELECT key FROM "+n.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,a){var i=a.rows.length?a.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function Ce(e){var t=this,a=new u((function(e,a){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT key FROM "+i.storeName,[],(function(t,a){for(var i=[],n=0;n<a.rows.length;n++)i.push(a.rows.item(n).key);e(i)}),(function(e,t){a(t)}))}))})).catch(a)}));return c(a,e),a}function Ve(e){return new u((function(t,a){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(a,i){for(var n=[],r=0;r<i.rows.length;r++)n.push(i.rows.item(r).name);t({db:e,storeNames:n})}),(function(e,t){a(t)}))}),(function(e){a(e)}))}))}function Ie(e,t){t=h.apply(this,arguments);var a=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||a.name,e.storeName=e.storeName||a.storeName);var i,n=this;return c(i=e.name?new u((function(t){var i;i=e.name===a.name?n._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Ve(i))})).then((function(e){return new u((function(t,a){e.db.transaction((function(i){function n(e){return new u((function(t,a){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){a(t)}))}))}for(var r=[],s=0,o=e.storeNames.length;s<o;s++)r.push(n(e.storeNames[s]));u.all(r).then((function(){t()})).catch((function(e){a(e)}))}),(function(e){a(e)}))}))})):u.reject("Invalid arguments"),t),i}var Ee={_driver:"webSQLStorage",_initStorage:ve,_support:q(),iterate:Ae,getItem:_e,setItem:Se,removeItem:Ne,clear:Te,length:Me,key:xe,keys:Ce,dropInstance:Ie};function Fe(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function De(e,t){var a=e.name+"/";return e.storeName!==t.storeName&&(a+=e.storeName+"/"),a}function Re(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Pe(){return!Re()||localStorage.length>0}function Le(e){var t=this,a={};if(e)for(var i in e)a[i]=e[i];return a.keyPrefix=De(e,t._defaultConfig),Pe()?(t._dbInfo=a,a.serializer=ge,u.resolve()):u.reject()}function Be(e){var t=this,a=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,a=localStorage.length-1;a>=0;a--){var i=localStorage.key(a);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return c(a,e),a}function Oe(e,t){var a=this;e=p(e);var i=a.ready().then((function(){var t=a._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return c(i,t),i}function $e(e,t){var a=this,i=a.ready().then((function(){for(var t=a._dbInfo,i=t.keyPrefix,n=i.length,r=localStorage.length,s=1,o=0;o<r;o++){var l=localStorage.key(o);if(0===l.indexOf(i)){var u=localStorage.getItem(l);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,l.substring(n),s++)))return u}}}));return c(i,t),i}function Ue(e,t){var a=this,i=a.ready().then((function(){var t,i=a._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return c(i,t),i}function je(e){var t=this,a=t.ready().then((function(){for(var e=t._dbInfo,a=localStorage.length,i=[],n=0;n<a;n++){var r=localStorage.key(n);0===r.indexOf(e.keyPrefix)&&i.push(r.substring(e.keyPrefix.length))}return i}));return c(a,e),a}function ze(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t}function We(e,t){var a=this;e=p(e);var i=a.ready().then((function(){var t=a._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(i,t),i}function Ye(e,t,a){var i=this;e=p(e);var n=i.ready().then((function(){void 0===t&&(t=null);var a=t;return new u((function(n,r){var s=i._dbInfo;s.serializer.serialize(t,(function(t,i){if(i)r(i);else try{localStorage.setItem(s.keyPrefix+e,t),n(a)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||r(e),r(e)}}))}))}));return c(n,a),n}function He(e,t){if(t=h.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var a=this.config();e.name=e.name||a.name,e.storeName=e.storeName||a.storeName}var i,n=this;return i=e.name?new u((function(t){e.storeName?t(De(e,n._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var a=localStorage.key(t);0===a.indexOf(e)&&localStorage.removeItem(a)}})):u.reject("Invalid arguments"),c(i,t),i}var Ge={_driver:"localStorageWrapper",_initStorage:Le,_support:Fe(),iterate:$e,getItem:Oe,setItem:Ye,removeItem:We,clear:Be,length:ze,key:Ue,keys:je,dropInstance:He},qe=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Ze=function(e,t){for(var a=e.length,i=0;i<a;){if(qe(e[i],t))return!0;i++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ke={},Xe={},Qe={INDEXEDDB:G,WEBSQL:Ee,LOCALSTORAGE:Ge},et=[Qe.INDEXEDDB._driver,Qe.WEBSQL._driver,Qe.LOCALSTORAGE._driver],tt=["dropInstance"],at=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function nt(e,t){e[t]=function(){var a=arguments;return e.ready().then((function(){return e[t].apply(e,a)}))}}function rt(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var a in t)t.hasOwnProperty(a)&&(Je(t[a])?arguments[0][a]=t[a].slice():arguments[0][a]=t[a])}return arguments[0]}var st=function(){function e(t){for(var a in n(this,e),Qe)if(Qe.hasOwnProperty(a)){var i=Qe[a],r=i._driver;this[a]=r,Ke[r]||this.defineDriver(i)}this._defaultConfig=rt({},it),this._config=rt({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,a){var i=new u((function(t,a){try{var i=e._driver,n=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void a(n);for(var r=at.concat("_initStorage"),s=0,o=r.length;s<o;s++){var l=r[s];if((!Ze(tt,l)||e[l])&&"function"!=typeof e[l])return void a(n)}var d=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),a=u.reject(t);return c(a,arguments[arguments.length-1]),a}},a=0,i=tt.length;a<i;a++){var n=tt[a];e[n]||(e[n]=t(n))}};d();var p=function(a){Ke[i]&&console.info("Redefining LocalForage driver: "+i),Ke[i]=e,Xe[i]=a,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(p,a):p(!!e._support):p(!0)}catch(e){a(e)}}));return d(i,t,a),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,a){var i=Ke[e]?u.resolve(Ke[e]):u.reject(new Error("Driver not found."));return d(i,t,a),i},e.prototype.getSerializer=function(e){var t=u.resolve(ge);return d(t,e),t},e.prototype.ready=function(e){var t=this,a=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return d(a,e,e),a},e.prototype.setDriver=function(e,t,a){var i=this;Je(e)||(e=[e]);var n=this._getSupportedDrivers(e);function r(){i._config.driver=i.driver()}function s(e){return i._extend(e),r(),i._ready=i._initStorage(i._config),i._ready}function o(e){return function(){var t=0;function a(){for(;t<e.length;){var n=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(n).then(s).catch(a)}r();var o=new Error("No available storage method found.");return i._driverSet=u.reject(o),i._driverSet}return a()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return u.resolve()})):u.resolve();return this._driverSet=l.then((function(){var e=n[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,r(),i._wrapLibraryMethodsWithReady(),i._initDriver=o(n)}))})).catch((function(){r();var e=new Error("No available storage method found.");return i._driverSet=u.reject(e),i._driverSet})),d(this._driverSet,t,a),this._driverSet},e.prototype.supports=function(e){return!!Xe[e]},e.prototype._extend=function(e){rt(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],a=0,i=e.length;a<i;a++){var n=e[a];this.supports(n)&&t.push(n)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=at.length;e<t;e++)nt(this,at[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ot=new st;t.exports=ot},{3:3}]},{},[4])(4)}(Wn)),Wn.exports),Hn=I(Yn);class Gn{databaseName;collectionName;size;_store;constructor(e,t,a){Hn.config({driver:Hn.INDEXEDDB}),this.databaseName=e||"lumino-cache",this.collectionName=t||"data",this.size=a,this._store=Hn.createInstance({name:this.databaseName,storeName:this.collectionName})}async init(){}async _keys(){return this._store.keys()}async _set(e,t){return this._store.setItem(e,t)}async _clear(){return this._store.clear()}async _get(e){return this._store.getItem(e)}async _remove(e){return this._store.removeItem(e)}}function qn(e){let t,a,i,n;e.onmessage=async r=>{const s=r.data;try{switch(s.type){case"init":{i=s.databaseName,n=s.collectionName,t=await navigator.storage.getDirectory();const r=await t.getDirectoryHandle(i,{create:!0});a=await r.getDirectoryHandle(n,{create:!0}),e.postMessage({type:s.type,database:i,collection:n,success:!0});break}case"write":{if(!a)throw new Error("OPFS Worker: not initialized yet!");const t=await a.getFileHandle(s.filename,{create:!0}),r=await t.createSyncAccessHandle();let o;if("string"==typeof s.content){o=(new TextEncoder).encode(s.content).buffer}else if(s.content instanceof ArrayBuffer)o=s.content;else{if(!(s.content instanceof Blob))throw new Error("OPFS Worker: Unsupported content type: "+typeof s.content);o=await s.content.arrayBuffer()}r.truncate(o.byteLength),r.write(o,{at:0}),await r.flush(),r.close(),e.postMessage({type:s.type,database:i,collection:n,success:!0});break}}}catch(t){e.postMessage({type:s.type,success:!1,database:i,collection:n,error:t.message})}}}class Zn{databaseName;collectionName;size;_worker;_storage;_root;constructor(e,t,a){this.databaseName=e||"lumino-cache",this.collectionName=t||"data",this.size=a}async init(){if("object"==typeof globalThis.navigator&&"storage"in globalThis.navigator&&"function"==typeof globalThis.navigator.storage.getDirectory){this._storage=await navigator.storage.getDirectory();const e=await this._storage.getDirectoryHandle(this.databaseName,{create:!0});let t,a;this._root=await e.getDirectoryHandle(this.collectionName,{create:!0}),this._worker=new Worker(URL.createObjectURL(new Blob(["(",qn.toString(),")(self)"],{type:"application/javascript"})),{type:"module"});let i=new Promise(((e,i)=>{t=e,a=i}));return this._worker.onmessage=e=>{const i=e.data;i.success||console.error("OPFS Worker failed:",i),"init"===i.type&&(i.success?t():a(i.error))},this._worker.postMessage({type:"init",databaseName:this.databaseName,collectionName:this.collectionName}),i}}async _keys(){if(!this._root)return[];const e=[];for await(const t of this._root.values())e.push(t.name);return e}async _set(e,t){if(!this._root)return;let a;if(t instanceof Blob)a=t;else if("object"==typeof t){const e=JSON.stringify(t,null,2);a=new Blob([e],{type:"application/json"})}else a=new Blob([t],{type:"text/plain"});const i=await this._root.getFileHandle(e,{create:!0});if("function"==typeof i.createWritable){const e=await i.createWritable();await e.write(a),await e.close()}else this._worker.postMessage({type:"write",filename:e,content:a})}async _clear(){if(!this._root)return;const e=[];for await(const t of this._root.values())e.push(this._root.removeEntry(t.name));return Promise.all(e)}async _get(e,t){if(!this._root)return null;let a;try{const t=await this._root.getFileHandle(e);a=await t.getFile()}catch(e){return null}switch(t=t||a.type){case"text/plain":return a.text();case"application/json":{const e=await a.text();try{return JSON.parse(e)}catch(t){return console.error("Content was loaded from cache but could not be json parsed: ",e),null}}default:return a}}async _remove(e){if(this._root)return this._root.removeEntry(e)}}class Jn{databaseName;collectionName;size;type;_impl;constructor(e,t,a=0,i=1){switch(this.databaseName=e||"lumino",this.collectionName=t||"data",this.size=1048576*(i||1),this.type=a,this.type){case 0:this._impl=new Gn(this.databaseName,this.collectionName,this.size);break;case 1:this._impl=new Zn(this.databaseName,this.collectionName,this.size);break;default:throw"Invalid storage type: "+a}}async init(){return this._impl.init()}async _keys(){return this._impl._keys()}fixKey(e){return e.replaceAll("/","_")}async _set(e,t){return this._impl._set(this.fixKey(e),t)}async _clear(){return this._impl._clear()}async _get(e,t){return this._impl._get(this.fixKey(e),t)}async _remove(e){return this._impl._remove(this.fixKey(e))}}var Kn,Xn,Qn,er,tr,ar,ir,nr,rr,sr,or,lr,ur,cr,dr,pr,hr,fr,mr,yr,gr,br,vr,wr,_r,Ar,kr,Sr;function Nr(){if(Xn)return Kn;return Xn=1,Kn=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Tr(){if(ar)return tr;ar=1;var e=function(){if(er)return Qn;er=1;var e="object"==typeof V&&V&&V.Object===Object&&V;return Qn=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,a=e||t||Function("return this")();return tr=a}function Mr(){if(lr)return or;lr=1;var e=function(){if(sr)return rr;sr=1;var e=/\s/;return rr=function(t){for(var a=t.length;a--&&e.test(t.charAt(a)););return a}}(),t=/^\s+/;return or=function(a){return a?a.slice(0,e(a)+1).replace(t,""):a}}function xr(){if(cr)return ur;cr=1;var e=Tr().Symbol;return ur=e}function Cr(){if(yr)return mr;yr=1;var e=xr(),t=function(){if(pr)return dr;pr=1;var e=xr(),t=Object.prototype,a=t.hasOwnProperty,i=t.toString,n=e?e.toStringTag:void 0;return dr=function(e){var t=a.call(e,n),r=e[n];try{e[n]=void 0;var s=!0}catch(e){}var o=i.call(e);return s&&(t?e[n]=r:delete e[n]),o}}(),a=function(){if(fr)return hr;fr=1;var e=Object.prototype.toString;return hr=function(t){return e.call(t)}}(),i=e?e.toStringTag:void 0;return mr=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":i&&i in Object(e)?t(e):a(e)}}function Vr(){if(wr)return vr;wr=1;var e=Cr(),t=br?gr:(br=1,gr=function(e){return null!=e&&"object"==typeof e});return vr=function(a){return"symbol"==typeof a||t(a)&&"[object Symbol]"==e(a)}}var Ir=function(){if(Sr)return kr;Sr=1;var e=Nr(),t=function(){if(nr)return ir;nr=1;var e=Tr();return ir=function(){return e.Date.now()}}(),a=function(){if(Ar)return _r;Ar=1;var e=Mr(),t=Nr(),a=Vr(),i=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,r=/^0o[0-7]+$/i,s=parseInt;return _r=function(o){if("number"==typeof o)return o;if(a(o))return NaN;if(t(o)){var l="function"==typeof o.valueOf?o.valueOf():o;o=t(l)?l+"":l}if("string"!=typeof o)return 0===o?o:+o;o=e(o);var u=n.test(o);return u||r.test(o)?s(o.slice(2),u?2:8):i.test(o)?NaN:+o}}(),i=Math.max,n=Math.min;return kr=function(r,s,o){var l,u,c,d,p,h,f=0,m=!1,y=!1,g=!0;if("function"!=typeof r)throw new TypeError("Expected a function");function b(e){var t=l,a=u;return l=u=void 0,f=e,d=r.apply(a,t)}function v(e){var t=e-h;return void 0===h||t>=s||t<0||y&&e-f>=c}function w(){var e=t();if(v(e))return _(e);p=setTimeout(w,function(e){var t=s-(e-h);return y?n(t,c-(e-f)):t}(e))}function _(e){return p=void 0,g&&l?b(e):(l=u=void 0,d)}function A(){var e=t(),a=v(e);if(l=arguments,u=this,h=e,a){if(void 0===p)return function(e){return f=e,p=setTimeout(w,s),m?b(e):d}(h);if(y)return clearTimeout(p),p=setTimeout(w,s),b(h)}return void 0===p&&(p=setTimeout(w,s)),d}return s=a(s)||0,e(o)&&(m=!!o.leading,c=(y="maxWait"in o)?i(a(o.maxWait)||0,s):c,g="trailing"in o?!!o.trailing:g),A.cancel=function(){void 0!==p&&clearTimeout(p),f=0,l=h=u=p=void 0},A.flush=function(){return void 0===p?d:_(t())},A},kr}(),Er=I(Ir);class Fr extends Jn{apiClient;cache=new Map;urlToIdMap=new Map;logging=!1;ready=!1;usePublicApi=!1;quota=0;size=0;usePersistentStorage=!1;saveIndex;constructor(e,t,a,i){if(super("lumino","items",1),!a)throw"A lumino client needs to be passed.";this.apiClient=a,this.usePublicApi=e,this.quota=1048576*(i||1024),this.usePersistentStorage=t;this.saveIndex=Er((()=>{const e=[];for(const t of this.cache.values())e.push({id:t.id,time:t.time.valueOf(),size:t.size,hash:t.hash,itemType:t.itemType,mimeType:t.mimeType,itemName:t.itemName});this._set("index",e).then((function(){})).catch((function(e){console.error("Error saving cache index: "+e)}))}),1e3)}async init(){return await super.init(),this.initFromStorage()}getQuota(){return this.quota}setQuota(e){this.quota=e,this.checkQuota()}getCount(){return this.cache.size}getSize(){return this.size}async initFromStorage(){if(this.usePersistentStorage){const e=await this._get("index","application/json");if(e&&Array.isArray(e))for(const t of e)t.time=P(t.time),this.cache.set(t.id,t),this.size+=t.size;else await this._clear(),this.saveIndex()}this.ready=!0,u.$emit("itemCache:cacheReady"),u.$emit("itemCache:cacheChange"),u.$on("item:rename",(e=>this.handleRename(e)))}async addToStorage(e,t){if(this.usePersistentStorage){const a={id:e.id,time:P(e.time.toDate()),size:e.size,hash:e.hash,itemType:e.itemType,mimeType:e.mimeType,itemName:e.itemName};await this._set(`blob_${e.id}`,t),this.cache.set(e.id,a),this.saveIndex()}this.size+=e.size}waitUntilReady(){const e=this;return new Promise(((t,a)=>{try{e.ready?t():u.$on("itemCache:cacheReady",(()=>{t()}))}catch(e){a(e)}}))}findObject(e){return this.cache.get(e)}getEntries(){return this.cache.values()}clear(){for(const e of this.cache.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);this.cache.clear(),u.$emit("itemCache:cacheChange"),this.usePersistentStorage&&this._clear().then((function(){console.log("Cache storage cleared.")})).catch((function(e){console.error(e)}))}clearMemory(){for(let e of this.cache.values())e.objectUrl&&(URL.revokeObjectURL(e.objectUrl),delete e.objectUrl);u.$emit("itemCache:cacheChange")}checkQuota(e=0){let t=this.size+e;if(t>this.quota){const e=[...this.cache.entries()].sort((function(e,t){return e[1].time.valueOf()-t[1].time.valueOf()}));let a=0;for(;t>this.quota&&a<e.length;){const i=e[a][1];i.objectUrl||(t-=i.size,this.removeObjectFromCache(i.id)),a++}}}removeObjectFromCache(e){const t=this.cache.get(e);t&&(t.objectUrl&&URL.revokeObjectURL(t.objectUrl),this.cache.delete(e),this.size-=t.size,this.usePersistentStorage&&(this._remove(`blob_${t.id}`).then((function(){console.log(`Removed blob for ${e} from cache`)})).catch((function(t){console.error(`Error removing blob for ${e} from cache: ${t}`)})),this.saveIndex()))}getIdFromUrl(e){return this.urlToIdMap.has(e)?this.urlToIdMap.get(e):null}getById(e){const t=this.findObject(e);return t?(this.logging&&console.log("Retrieving from cache: "+e),t.time=P(),t):(this.logging&&console.error("Object not in cache: "+e),null)}getObjectUrl(e){const t=this.getIdFromUrl(e);if(!t)return console.error("Could not find URL in cache: "+e),"";const a=this.getById(t);return a?a.objectUrl:(console.error("Could not find Id in cache: "+t),"")}async getBufferById(e){const t=await this.getBlobById(e);return t?await new Response(t).arrayBuffer():null}async getBlobById(e){const t=this.getById(e);return t?await fetch(t.objectUrl).then((e=>e.blob())):null}async loadFromStorage(e){if(e.objectUrl)return!0;let t=null;return!!this.usePersistentStorage&&(t=await this._get(`blob_${e.id}`),!!t&&(e.objectUrl=URL.createObjectURL(t),e.time=P(),this.saveIndex(),u.$emit("itemCache:cacheChange"),!0))}getCacheKey(e,t){return t&&"item"!==t.type?e+"_lod"+t.index:e}_getLodLevelUrl(e,t){let a;return a=t&&"item"!==t.type?this.apiClient.getAttachmentDownloadUrl(e,"lod",t.index):this.apiClient.getDownloadUrl(e),a}async loadItem(e,t,a){let i=0;for(;;)try{let i;if(this.usePublicApi)i=t&&"item"!==t.type?await this.apiClient.downloadPublicAttachment(e,"lod",t.index,void 0,a):await this.apiClient.publicDownloadItem(e,a);else try{i=t&&"item"!==t.type?await this.apiClient.downloadAttachment(e,"lod",t.index,void 0,a):await this.apiClient.downloadItem(e,a)}catch{i=t&&"item"!==t.type?await this.apiClient.downloadPublicAttachment(e,"lod",t.index,void 0,a):await this.apiClient.publicDownloadItem(e,a)}return i}catch(t){if(console.log(t),i++,!(i<3))return u.$emit("client:fatalError",`Failed to download item ${e}`),null;console.debug(`Failed attempts to download item ${e}: ${i}. Trying again...`)}}async addItemToCache(e,t,a,i){try{const n=this.getCacheKey(e,t),r=this.findObject(n);if(r&&(a||!this.apiClient.getItemHash||this.usePublicApi||(a=await this.apiClient.getItemHash(e)),a&&r.hash===a&&(this.logging&&console.log("Item already in cache: "+e),await this.loadFromStorage(r))))return r.url||(r.url=this._getLodLevelUrl(e,t)),this.urlToIdMap.set(r.url,n),this.cache.set(n,r),r;i&&i(0);let s=await this.loadItem(e,t,i);if(!s)return console.error("Was not able to load object into cache: "+n),null;i&&i(100);const o=this._getLodLevelUrl(e,t),l=URL.createObjectURL(s.blob),c={id:n,url:o,time:P(),objectUrl:l,size:s.blob.size,hash:s.hash,itemType:s.itemType,mimeType:s.mimeType,itemName:s.itemName};return this.checkQuota(c.size),await this.addToStorage(c,s.blob),this.cache.set(n,c),this.urlToIdMap.set(o,n),this.saveIndex(),u.$emit("itemCache:cacheChange"),this.logging&&console.log("Added item to cache: ",c),c}catch(e){return console.error(e),null}}getObjectCount(){return this.cache.size}getObjectSize(){let e=0;for(const t of this.cache.values())e+=t.size;return e}handleRename({id:e,newName:t}){const a=this.cache.get(e);a&&(a.itemName=t,this.saveIndex(),u.$emit("itemCache:cacheChange"))}}class Dr extends Jn{apiClient;ready=!1;maxNumItems=1e4;constructor(e){if(super("lumino","folders",1),!e)throw"A lumino client needs to be passed.";this.apiClient=e}async init(){await super.init(),await this.checkStorage(),this.ready=!0}clear(){return this._clear()}async checkStorage(){const e=await this._keys();let t=e.length-this.maxNumItems;if(t>0){t=Math.floor(this.maxNumItems/2);const a=[];for(let i=0;i<t;i++)a.push(this._remove(e[i]));await Promise.all(a)}}async getFolderListing(e){return this.ready?this._get(e,"application/json"):null}async getItemListing(e){if(!this.ready)return null;const t=await this._get("items_"+e,"application/json");if(!t)return null;const a=await this.getFolderListing(e);return a&&a.parent&&new Date(t.cachedAt).getTime()>new Date(a.parent.updatedAt).getTime()?t.data:null}async getFolderACLs(e,t){if(!this.ready)return null;const a=await this._get("acl_"+e,"application/json");return a&&Date.now()-a.cachedAt<t?(delete a.cachedAt,a):null}async refreshCacheForFolder(e){const t=await this.getFolderListing(e);await this.addFolderListing(e,t)}async addFolderListing(e,t){this.ready&&(await this._set(e,{...t,cachedAt:new Date}),await this.checkStorage())}async addItemListing(e,t){this.ready&&(await this._set("items_"+e,{data:t,cachedAt:new Date}),await this.checkStorage())}async addACL(e,t){this.ready&&(await this._set("acl_"+e,{...t,cachedAt:new Date}),await this.checkStorage())}}class Rr extends Jn{apiClient;constructor(e){if(super("lumino","thumbs",1),!e)throw"A lumino client needs to be passed.";this.apiClient=e}clear(){this._clear()}async _loadThumbnail(e,t){try{return await this.apiClient.getThumbnail(e,t)}catch{try{return await this.apiClient.getPublicThumbnail(e,t)}catch{return null}}}async get(e,t,a,i){if(!t)throw"Cannot retrieve item thumbnail from cache without knowing size!";let n=await this._get(e,"application/json");if(n&&n.hash===a&&n.timestamp===i){for(const e of n.thumbnails)if(e.size===t){if(e.data)return e.data;n.thumbnails.removeObject(e);break}let a=await this._loadThumbnail(t,e);return a&&(n.thumbnails.push({size:t,data:a}),await this._set(e,n)),a}let r=await this._loadThumbnail(t,e);if(a||i){let s=[];r&&s.push({size:t,data:r}),n={id:e,hash:a,timestamp:i,thumbnails:s},await this._set(e,n)}return r}}class Pr{apiClient;cache=new Map;constructor(e){this.apiClient=e,this.cache=new Map}async resolve(e){let t=this.cache.get(e);if(!t)try{t=this.apiClient.getUserPublicInfo(e,this.apiClient.requestClientId,32),this.cache.set(e,t)}catch(e){console.error(e)}return t}}class Lr{apiClient;cache=new Map;constructor(e){this.apiClient=e}async resolve(e){let t=this.cache.get(e);if(!t)try{t=this.apiClient.getGroupPublicInfo(e,this.apiClient.requestClientId,32),this.cache.set(e,t)}catch(e){console.error(e)}return t}}class Br{apiClient;cache=new Map;constructor(e){this.apiClient=e}async get(e,t,a,i,n=!1){const r=`${e}_${t}_${a}${void 0===i?"":`_${i}`}`,s=this.cache.get(r);if(s)return s;try{const s=new Promise((async r=>{try{let s;s=n?await this.apiClient.downloadPublicAttachment(e,t,a,i,void 0):await this.apiClient.downloadAttachmentPOP(e,t,a,i,void 0);r(URL.createObjectURL(s.blob))}catch(e){r(null)}}));return this.cache.set(r,s),s}catch(e){return console.warn(`Attachment ${r} not available.`),null}}invalidateAttachment(e,t,a,i){let n=`${e}_${t}`;null!=a&&(n+=`_${a}`);for(const e of this.cache.keys()){const t=null==i||e.endsWith(`_${i}`);e.startsWith(n)&&t&&this.cache.delete(e)}}}class Or{apiClient;itemRepo;jobManager;items=[];hasExternalResources=!1;totalSize=0;affectedFolderIds=new Set;constructor(e){this.apiClient=e,this.itemRepo=e.getItemRepo(),this.jobManager=e.getJobManager()}_updateQuota(){this.apiClient.eventBus.$emit("quota:update")}async getPreviousVersions(e,t){const a=[];t=t||"published";const i=await this.apiClient.createFolder({name:t,parent:e,returnIfExists:!0}),n=await this.apiClient.getFoldersInFolderList(i,{folderAsItemType:"Package"});for(const e of n.children)e.item&&a.push({itemId:e.item._id,folderId:e._id,version:e.name,name:e.item.name,filesize:0|e.item.filesize,visibility:e.item.visibility});return a}async verify(e){const t=this,a=new Map,i=new Map;e=e?await this.itemRepo.loadItem(e._id,{recursive:!0}):this.itemRepo.activeItem;const n=await r(e.folder);async function r(e){try{if(e){const a=e._id?e._id:e;if(i.has(a))return i.get(a);{const e=(await t.apiClient.getFolderPath(a)).path;return i.set(a,e),e}}return"/"}catch{return""}}await this.itemRepo.traverseItems((async function(e){const t={_id:e._id,name:e.name,type:e.type,size:e.totalSize,path:await r(e.folder),item:e,external:!1};t.path.startsWith(n)?t.path=t.path.slice(n.length):t.external=!0,a.set(e._id,t)})),this.items=Array.from(a.values()),this.hasExternalResources=!1,this.totalSize=0;for(const e of this.items)e.external&&(this.hasExternalResources=!0),this.totalSize+=e.size;return!this.hasExternalResources}getItems(){return this.items}async unpackToProject(e,t,a,i){a&&(t=await this.apiClient.createFolder({name:a,parent:t,returnIfExists:!0}));const n=await this.apiClient.getItem(e);n.folder===t&&await this.apiClient.renameItem(e,n.name+" (Unpackaged)");const r=await this.apiClient.createFolder({name:n.name,parent:t,fixNameCollisions:!0}),s=await this.jobManager.execute("JS:Unpackage",[{_id:e,isFolder:!1}],[{name:"Destination Folder",value:r},{name:"Make Destination Visible",value:!1}],i);if(this._updateQuota(),3===s.state){const t=s.log.trim().split(";");if(2!==t.length||"UNPACKAGED"!==t[0])throw new A("Unpacking failed. Did not get unpackaged item id!");const a=t[1].trim();return await this.apiClient.renameItem(a,n.name),await this.itemRepo.replaceLink(e,a),a}if(2===s.state)throw new A("Unpacking failed: "+s.error)}async copyItemToProject(e,t,a,i){return(await this.copyItemsToProject([{_id:e,isFolder:!1}],t,a,i))[0].newId}async copyItemsToProject(e,t,a,i){a=a||"packages",t=await this.apiClient.createFolder({name:a,parent:t,returnIfExists:!0}),this.affectedFolderIds.add(t);const n=[];if(e.length){const a=await this.jobManager.execute("JS:CloneItem",e,[{name:"Deep Clone",value:!1},{name:"Destination Folder",value:t},{name:"Exclude Types",value:""},{name:"Make Private",value:!0}],i);if(this._updateQuota(),3===a.state){if(!a.log.trim().length)throw new A("Copy job returned no results.");{const e=a.log.split("\n").reverse();for(const t of e){const e=t.trim().split(";");if(3===e.length){const t=e[1],a=e[2];await this.itemRepo.replaceLink(t,a),n.push({oldId:t,newId:a})}}}}else if(2===a.state)throw new A("Copying of items failed: "+a.error)}return n}async copyToProject(e,t,a){const i=[];for(const e of this.items)e.external&&i.push({_id:e._id,isFolder:!1});return this.copyItemsToProject(i,e,t,a)}async unpublish(e){await this.apiClient.makeItemPrivate(e,!1,!1)}async publish(e,t,a,i,n,r,s,o){const l=e.version;i=i||`published/${l.major}.${l.minor}.${l.revision}`,n=void 0===n||n,r=void 0===r||r,this.affectedFolderIds.add(a);let u,c=a;if(i){const e=i.split("/");for(const t of e)c=await this.apiClient.createFolder({name:t,parent:c,returnIfExists:!0}),this.affectedFolderIds.add(c),u||(u=c)}const d=(await this.apiClient.getFoldersInFolderList(a)).children.map((e=>e._id)).filter((e=>e!==u)).join(","),p=await this.jobManager.execute("JS:CreatePackage",[{_id:e._id,isFolder:!1}],[{name:"Folders To Include",value:d},{name:"Destination Folder",value:c},{name:"Item Name",value:t},{name:"Make Public",value:!!n},{name:"Copy External",value:!!r},{name:"Always Create New Package",value:!!s},{name:"Make Cloneable",value:!!o}]);if(this._updateQuota(),2===p.state)throw new A("Packaging failed: "+p.error);this.apiClient.eventBus.$emit("folder:changed",Array.from(this.affectedFolderIds.values()))}}class $r{id;job;nextCheckMs;constructor(e,t,a){this.id=e,this.job=a,this.nextCheckMs=t}}class Ur{apiClient;jobs=new Map;constructor(e){this.apiClient=e}getJobs(){return Array.from(this.jobs.values())}async execute(e,t,a,i=void 0,n){const r=this;return new Promise((async(s,o)=>{try{const o=async()=>{try{u.job=await r.apiClient.getJobState(l);let e=!1;switch(u.job.state){case 0:case 1:try{i&&i(u.job)}catch(e){console.error("Error calling progress callback: ",e)}break;case 2:case 3:console.log("Job is done."),e=!0,s(u.job)}e?r.jobs.delete(l):(u.nextCheckMs=Math.min(2*u.nextCheckMs,8e3),setTimeout(o,u.nextCheckMs))}catch(e){console.error("Error fetching job state: "+e)}},l=await r.apiClient.createJob({type:e,elements:t,parameters:a,requiredParameters:n}),u=new $r(l,1e3);r.jobs.set(l,u),setTimeout(o,u.nextCheckMs)}catch(e){o(e)}}))}}const jr={mp3:{name:"Mpeg Audio Layer 3",itemType:"Audio",itemTypeCollection:"Audio Collection",collectionEntryName:"AudioItems",folderName:"audio",defaultAction:"Use",actions:["Skip","Use"]},hdr:{name:"HDR Image",itemType:"HDR Image",folderName:"envmaps",defaultAction:"Use",actions:["Skip","Use"]},glb:{name:"Gltf Binary",itemType:"Mesh",itemTypeCollection:"Mesh Collection",collectionEntryName:"MeshItems",folderName:"meshes",defaultAction:"Use",actions:["Skip","Use"]},png:{name:"Portable Network Graphics",itemType:"Image",folderName:"textures",defaultAction:"Use",actions:["Skip","Use"]},jpg:{name:"JPEG",itemType:"Image",folderName:"textures",defaultAction:"Use",actions:["Skip","Use"]},jpeg:{name:"JPEG",itemType:"Image",folderName:"textures",defaultAction:"Use",actions:["Skip","Use"]},lua:{name:"Lua",itemType:"Script",folderName:"scripts",defaultAction:"Use",actions:["Skip","Use"]},ttf:{name:"True Type Font",itemType:"Font",folderName:"fonts",defaultAction:"Use",actions:["Skip","Use"]},otf:{name:"Open Type Font",itemType:"Font",folderName:"fonts",defaultAction:"Use",actions:["Skip","Use"]},unknown:{name:"Unsupported",itemType:"Unknown",defaultAction:"Skip",actions:["Skip"],invisible:!0}},zr={Audio:"audio","Audio Collection":"audio","HDR Image":"envmaps",Mesh:"meshes","Mesh Collection":"",Script:"scripts",Material:"materials","Background Shader":"background shaders","Pixel Shader":"pixel shaders","Vertex Shader":"vertex shaders",Image:"textures",Scene:"prefabs",Font:"fonts"};function Wr(e,t){let a=jr[t];a||(a=jr.unknown),e.size=e.blob?e.blob.size:0,e.type=a.name,e.collectionType=a.itemTypeCollection,e.collectionEntryName=a.collectionEntryName,e.action=a.defaultAction,e.actions=a.actions,e.folderName=a.folderName,e.itemType=a.itemType,e.name=function(e,t){let a=e.lastIndexOf(".");return e.substring(0,a<0?e.length:a)+"."+t}(e.name,t)}class Yr{name;blob;processing=!1;progress=0;size=0;type;collectionType;collectionEntryName;action;actions;folderName;itemType;constructor(e,t,a){this.name=e,this.blob=t,Wr(this,a)}}class Hr{apiClient;itemRepo;jobManager;items=[];mainItem;totalSize=0;oldMainItemId;originalItemIds=[];affectedFolderIds=new Set;packageId;converter;supportedExtensions;hasExternalResources=!1;constructor(e){this.apiClient=e,this.itemRepo=e.getItemRepo(),this.jobManager=e.getJobManager();const t=[];for(const e in jr)jr[e].invisible||t.push(`.${e.toUpperCase()}`);this.supportedExtensions=t.sort(((e,t)=>e.localeCompare(t)))}_updateQuota(){this.apiClient.eventBus.$emit("quota:update")}_addAffectedFolder(e){"object"==typeof e&&e._id?this.affectedFolderIds.add(e._id):"string"==typeof e?this.affectedFolderIds.add(e):console.error("Invalid affected folder to add: ",e)}getAffectedFolderIds(){return Array.from(this.affectedFolderIds.values())}getSupportedExtensions(){return this.supportedExtensions}setConverter(e){this.converter=e}setItems(e){this.items=e}async scan(e){const t=this,a=new Map,i=new Map;this.mainItem=await this.itemRepo.loadItem(e,{recursive:!0}),this.oldMainItemId=this.mainItem._id;const n=await r(this.mainItem.folder);async function r(e){try{if(e){const a=e._id?e._id:e;if(i.has(a))return i.get(a);{const e=(await t.apiClient.getFolderPath(a)).path;return i.set(a,e),e}}return"/"}catch(e){return console.error(e),""}}await this.itemRepo.traverseItems((async function(e){const i={_id:e._id,name:e.name,type:e.type,size:e.totalSize,path:await r(e.folder),item:e,external:!1};i.path.startsWith(n)?i.path=i.path.slice(n.length):i.external=!0,t._addAffectedFolder(e.folder),a.set(e._id,i)}),this.mainItem),this.items=Array.from(a.values()),this.originalItemIds=this.items.map((e=>e._id)),this.hasExternalResources=!1,this.totalSize=0;for(const e of this.items)e.external&&(this.hasExternalResources=!0),this.totalSize+=e.size;return this.items}getItems(){return this.items}async saveMainItemChanges(){const e=this.mainItem;await this.apiClient.updateItem({_id:e._id,name:e.name,shortDescription:e.shortDescription,description:e.description,tags:e.tags,categories:e.categories,visibility:e.visibility,contributors:e.contributors,version:e.version})}async createAssetFolder(e,t){let a=e;const i=t.split("/");this._addAffectedFolder(e);for(const e of i)a=await this.apiClient.createFolder({name:e,parent:a,returnIfExists:!0}),this._addAffectedFolder(a);const n=await this.apiClient.getItemsInFolderList(a,!0);if(n&&n.length)throw new Error("Asset folder already exists and is not empty!");return a}createStandardAssetFolderPath(e){let t=zr[e.type];return t||(t=e.type.toLowerCase()+"s"),`assets/${t}/${e.name}`}async executeActions(){if(!this.converter)throw new Error("No converter is configured. Cannot execute actions on items.");return this.converter(this.items,Wr)}async createAsset(e,t=!1,a){const i=[];for(const e of this.items)i.push(e._id);if(this._addAffectedFolder(e),i.length)if(t){await this.apiClient.moveItems({items:i,dest:e})!==i.length&&console.warn("Not all items could be moved. Most likely due to permissions."),this.mainItem.folder=e}else{const t=await this.jobManager.execute("JS:CloneItem",[{_id:this.mainItem._id,isFolder:!1}],[{name:"Deep Clone",value:!0},{name:"Destination Folder",value:e},{name:"Exclude Types",value:""}],a);if(3===t.state){const a=t.log.split("\n").reverse()[0].split(";");this.mainItem._id=a[2],this.mainItem.folder=e}else if(2===t.state)throw new A("Copying of items failed: "+t.error)}"Main"!==this.mainItem.name&&(this.mainItem.originalName=this.mainItem.name,this.mainItem.name="Main",await this.apiClient.renameItem(this.mainItem._id,this.mainItem.name));const n=await this.apiClient.getItem(this.mainItem._id);return n.flags||(n.flags=[]),n.flags.includes("original")||n.flags.push("original"),await this.apiClient.updateItem(n),this._updateQuota(),this.mainItem._id}async createPackage(e,t=!1,a=!1){let i,n=this.mainItem.folder;if(this._addAffectedFolder(n),void 0===e){const t=this.mainItem.version||{major:1,minor:0,revision:0};e=`published/${t.major}.${t.minor}.${t.revision}`}if(void 0===t&&(t=!0),e){const t=e.split("/");for(const e of t)n=await this.apiClient.createFolder({name:e,parent:n,returnIfExists:!0}),this._addAffectedFolder(n),i||(i=n)}const r=(await this.apiClient.getFoldersInFolderList(this.mainItem.folder)).children.map((e=>e._id)).filter((e=>e!==i)).join(","),s=await this.jobManager.execute("JS:CreatePackage",[{_id:this.mainItem._id,isFolder:!1}],[{name:"Folders To Include",value:r},{name:"Destination Folder",value:n},{name:"Item Name",value:this.mainItem.originalName||this.mainItem.name},{name:"Make Public",value:!!t},{name:"Copy External",value:!!a}]);if(this._updateQuota(),2===s.state)throw new A("Packaging failed: "+s.error);const o=s.log.split("\n").reverse()[0].split(";");this.packageId=o[2]}async replaceReferences(){await this.itemRepo.replaceLink(this.oldMainItemId,this.packageId)}async deleteOriginalItems(){await this.apiClient.deleteItem(this.originalItemIds)}sendFolderRefreshEvent(){this.apiClient.eventBus.$emit("folder:changed",this.getAffectedFolderIds())}async processUploads(e){const t=[];for(const a of e)if("application/zip"===a.type||"application/x-zip-compressed"===a.type){const e=new s;try{const i=[];(await e.loadAsync(a)).forEach(((e,a)=>{const n=a.name.split("/").pop();if(!n.startsWith(".")){const e=n.split(".").pop(),r=a.async("blob");i.push(r),r.then((function(i){const n=new Yr(a.name,i,e);t.push(n)}))}})),await Promise.all(i)}catch(e){console.error("Error reading the ZIP file:",e)}}else{const e=a.name.split(".").pop(),i=new Yr(a.name,a,e);t.push(i)}return t}detectAssets(e){let t,a,i,n=0;for(const r of e)if("Use"===r.action)if(void 0===t)t=r.itemType,a=r.collectionType,i=r.folderName,n++;else{if(t!==r.itemType)return{valid:!1,reason:"Mixed item types found. To create an asset, upload a single type of file for example only meshes."};n++}return 0===n?{valid:!1,reason:"There are no files we can use to create an asset."}:n>1&&!a?{valid:!1,reason:"Cannot create collections of this type."}:{valid:!0,assetType:n>1?a:t,itemCount:n,folderName:i}}_filterUploadFiles(e){let t=[];for(const a of e)"Use"===a.action&&t.push(a);return t}createNewItem(){return{name:"New asset",type:"",description:"",shortDescription:"",tags:[],flags:["original"],categories:[],license:"CC0",allowConversation:!0,version:{major:1,minor:0,revision:0}}}async createAssetFromFiles(e,t,a,i=!1,n=!1){const r=this.detectAssets(e);if(r.assetType!==a.type)throw new Error("Asset type not valid for these items.");if(!r.valid)throw new Error(r.reason||"No valid asset detected.");let s=await this.apiClient.createFolder({name:r.folderName,parent:t,returnIfExists:!0}),o=await this.apiClient.createFolder({name:a.name,parent:s,returnIfExists:!0}),l=!1;if(0===(await this.apiClient.getItemsInFolderList(o)).length){(await this.apiClient.getFoldersInFolderList(o)).children.length&&(l=!0)}else l=!0;if(l){if(!i)throw new Error("Cannot create asset, target folder is not empty!");await this.apiClient.deleteFolder(o),o=await this.apiClient.createFolder({name:a.name,parent:s})}let u,c=this._filterUploadFiles(e);if(1===c.length){const e=c[0];e.processing=!0,e.progress=0,u=await this.apiClient.uploadAndCreate(o,e.blob,e.name,{nameOverride:"Main",flags:"original"},(function(t){e.progress=t})),this._updateQuota(),e.action="Skip"}else{let e=await this.apiClient.createFolder({name:"resources",parent:o}),t={},a=[],i=0;for(const n of c){n.processing=!0,n.progress=0;const r=await this.apiClient.uploadAndCreate(e,n.blob,n.name,void 0,(function(e){n.progress=e}));this._updateQuota(),n.action="Skip",t[`${n.collectionEntryName}[${i}]->Name`]="",a.push({usage:`MeshItems[${i}]->Mesh`,to:r}),i++}u=await this.apiClient.createItem({type:r.assetType,name:"Main",flags:["original"],folder:o,fixNameCollisions:!0,attributes:t,links:a})}return a._id=u,a.folder=o,this.mainItem=a,n?{assetItemId:u,assetTypeFolderId:s,assetFolderId:o}:u}}class Gr{apiClient;itemRepo;constructor(e){this.apiClient=e,this.itemRepo=e.getItemRepo()}grab(e,t,a,i){i=i||{};const n=[];for(const r of a){const a=this._serializeBlockFields(r),s=this._serializeScripts(r),o={type:"block",item:e._id,field:t.name,path:"",block:{id:r.id,type:r.type||"Group",fields:a,scripts:s,children:[]}};i.omitPath||(o.path=this._getBlockPath(r)),i.withChildren&&(o.block.children=this.grab(e,t,r.blocks||[],{withChildren:!0,returnArray:!0})),n.push(o)}if(i.returnArray)return n;const r={type:"serializedBlocks",data:n};return i.noStringify?r:JSON.stringify(r,null,2)}async put(e,t,a,i={}){e=this.validateMessage(e);const n=[];for(const r of e.data){const e=await this._putBlock(r,t,a,i);e&&n.push(e)}return n}validateMessage(e){if("string"==typeof e&&(e=JSON.parse(e)),"serializedBlocks"!==e.type)throw new Error("Data must be a serialized block message. Format is wrong.");if(!Array.isArray(e.data))throw new Error("The contained data is not an array.");return e}async clone(e,t,a,i,n={}){const r=this.grab(i,t,[e],{withChildren:!0,noStringify:!0});return this.put(r,t,a,n)}_updateScriptFieldReferences(e,t){const a=new Map,i=(e,t)=>{a.set(e.block.id,t.id);const n=e.block.children||[],r=t.blocks||[];for(let e=0;e<n.length;e++)i(n[e],r[e])};i(e,t),this.itemRepo.updateScriptFieldReferencesFromMap(a,t)}async _putBlock(e,t,a,i={},n=!1){if(!e.block||!e.block.type||!e.block.fields)return null;const r=e.block,s=this._findItemById(e.item)??this.itemRepo.activeItem;let o=a;o||(o=this._findParentBlock(s,e.field,e.path));const l={};if(Array.isArray(r.fields))for(const e of r.fields){const{name:t,type:a,value:n,linkto:r}=e;if("Separator"!==a)if(i.fieldOverrides&&t in i.fieldOverrides)l[t]=i.fieldOverrides[t];else if(r){const e=this.itemRepo.getLoadedItem(r);l[t]=e||await this.itemRepo.loadItem(r)}else l[t]=n}const u=i.dontCopyScripts?[]:[...r.scripts],c=await this._createUnproxifiedBlock(r.type,l,u,t,s),d={...i,parentPosition:void 0,fieldOverrides:void 0};if(!c)return console.warn(`Could not create block of type ${r.type}. Skipping.`),null;if(Array.isArray(r.children))for(const e of r.children)await this._putBlock(e,t,c,d,!0);if(n&&o)return"number"==typeof i.parentPosition?o.blocks.splice(i.parentPosition,0,c):o.blocks.push(c),c.parent=o,c;i.dontCopyScripts||this._updateScriptFieldReferences(e,c);return this._proxifyAndAttachTree(c,o,s,i.parentPosition)}async _createUnproxifiedBlock(e,t,a,i,n){let r=ee.instance.getTemplate(n.packageType||n.type,i.name,e);if(!r)return null;if(t){const e=r.template.clone().specialize(t);r={displayName:r.displayName,typeName:r.typeName,template:e,inputs:r.inputs,outputs:r.outputs}}const s=new ae(void 0,void 0,r.typeName,void 0,r.displayName,n),o=await this.itemRepo.createFieldsForItem(s,r.template,n,!0);return s.setFields(o),s.blocks=[],await this.itemRepo.createScriptsForItem(s,a,n,!1),s}_proxifyAndAttachTree(e,t,a,i){const n=e=>{if(Array.isArray(e.blocks)&&e.blocks.length)for(const t of e.blocks)n(t);const t=e.blocks.map((e=>g.instance.proxyBlock(e,a)));e.blocks=g.instance.proxyBlockArray(t,e,a),e.scripts=g.instance.proxyScriptArray(e.scripts,e,a)};n(e),e.parent=t;const r=g.instance.proxyBlock(e,a);return"number"==typeof i?t.blocks.splice(i,0,r):t.blocks.push(r),r}_findItemById(e){return this.itemRepo.findLoadedItem(e)}_findItemField(e,t){if(!e.fieldInstances)return null;for(const a of e.fieldInstances)if(a.name===t)return a;return null}_findParentBlock(e,t,a){const i=this._findItemField(e,t);if(!i)return null;const n=a.split("/");let r=i.blocks,s=null;for(const e of n)s=r[e],r=s.blocks;return s}_getBlockIndex(e){if(!e.parent)return 0;let t=0;for(const a of e.parent.blocks){if(e.id===a.id)return t;t++}throw new Error("Could not find block in parent block array!")}_getBlockPath(e){const t=[];let a=e;for(;a;)t.push(this._getBlockIndex(a)),a=a.parent;return"/"+t.reverse().join("/")}_serializeBlockFields(e){const t=[];if(!Array.isArray(e.fields))return t;for(const a of e.fields)switch(a.type){case"Link":t.push({name:a.name,linkto:a.value?._id});break;case"Attribute":t.push({name:a.name,value:a.value});break;case"Separator":t.push({name:a.name,type:"Separator"})}return t}_serializeScripts(e){const t=[];if(!Array.isArray(e.scripts))return t;for(const a of e.scripts){const e=[],i={item:a.item?.value?._id,fields:e};for(const t of a.fields)e.push({name:t.name,value:t.value});t.push(i)}return t}}function qr(){throw new Error("setTimeout has not been defined")}function Zr(){throw new Error("clearTimeout has not been defined")}Array.prototype.pushAll||(Array.prototype.pushAll=function(e){for(const t of e)this.push(t)}),Array.prototype.removeObject||(Array.prototype.removeObject=function(e){const t=this.indexOf(e);return t>-1&&(this.splice(t,1),!0)}),Array.prototype.moveObjectToArray||(Array.prototype.moveObjectToArray=function(e,t,a){const i=this.indexOf(e);if(i>-1){return(0,this.moveToArray)(i,t,a)}return!1}),Array.prototype.removeByFilterFunc||(Array.prototype.removeByFilterFunc=function(e){let t=0;for(let a=0;a<this.length;a++)e(this[a])&&(this.splice(a,1),a--,t++);return t}),Array.prototype.clone||(Array.prototype.clone=function(){const e=[];for(const t of this)e.push(t);return e});var Jr=qr,Kr=Zr;function Xr(e){if(Jr===setTimeout)return setTimeout(e,0);if((Jr===qr||!Jr)&&setTimeout)return Jr=setTimeout,setTimeout(e,0);try{return Jr(e,0)}catch(t){try{return Jr.call(null,e,0)}catch(t){return Jr.call(this,e,0)}}}"function"==typeof Ti.setTimeout&&(Jr=setTimeout),"function"==typeof Ti.clearTimeout&&(Kr=clearTimeout);var Qr,es=[],ts=!1,as=-1;function is(){ts&&Qr&&(ts=!1,Qr.length?es=Qr.concat(es):as=-1,es.length&&ns())}function ns(){if(!ts){var e=Xr(is);ts=!0;for(var t=es.length;t;){for(Qr=es,es=[];++as<t;)Qr&&Qr[as].run();as=-1,t=es.length}Qr=null,ts=!1,function(e){if(Kr===clearTimeout)return clearTimeout(e);if((Kr===Zr||!Kr)&&clearTimeout)return Kr=clearTimeout,clearTimeout(e);try{return Kr(e)}catch(t){try{return Kr.call(null,e)}catch(t){return Kr.call(this,e)}}}(e)}}function rs(e,t){this.fun=e,this.array=t}rs.prototype.run=function(){this.fun.apply(null,this.array)};function ss(){}var os=ss,ls=ss,us=ss,cs=ss,ds=ss,ps=ss,hs=ss;var fs=Ti.performance||{},ms=fs.now||fs.mozNow||fs.msNow||fs.oNow||fs.webkitNow||function(){return(new Date).getTime()};var ys=new Date;var gs={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];es.push(new rs(e,t)),1!==es.length||ts||Xr(ns)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:os,addListener:ls,once:us,off:cs,removeListener:ds,removeAllListeners:ps,emit:hs,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*ms.call(fs),a=Math.floor(t),i=Math.floor(t%1*1e9);return e&&(a-=e[0],(i-=e[1])<0&&(a--,i+=1e9)),[a,i]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-ys)/1e3}};const bs=()=>new Map,vs=e=>{const t=bs();return e.forEach(((e,a)=>{t.set(a,e)})),t},ws=(e,t,a)=>{let i=e.get(t);return void 0===i&&e.set(t,i=a()),i},_s=()=>new Set,As=e=>e[e.length-1],ks=(e,t)=>{for(let a=0;a<t.length;a++)e.push(t[a])},Ss=Array.from,Ns=Array.isArray;class Ts{constructor(){this._observers=bs()}on(e,t){return ws(this._observers,e,_s).add(t),t}once(e,t){const a=(...i)=>{this.off(e,a),t(...i)};this.on(e,a)}off(e,t){const a=this._observers.get(e);void 0!==a&&(a.delete(t),0===a.size&&this._observers.delete(e))}emit(e,t){return Ss((this._observers.get(e)||bs()).values()).forEach((e=>e(...t)))}destroy(){this._observers=bs()}}class Ms{constructor(){this._observers=bs()}on(e,t){ws(this._observers,e,_s).add(t)}once(e,t){const a=(...i)=>{this.off(e,a),t(...i)};this.on(e,a)}off(e,t){const a=this._observers.get(e);void 0!==a&&(a.delete(t),0===a.size&&this._observers.delete(e))}emit(e,t){return Ss((this._observers.get(e)||bs()).values()).forEach((e=>e(...t)))}destroy(){this._observers=bs()}}const xs=Math.floor,Cs=Math.abs,Vs=(e,t)=>e<t?e:t,Is=(e,t)=>e>t?e:t,Es=Math.pow,Fs=e=>0!==e?e<0:1/e<0,Ds=64,Rs=128,Ps=127,Ls=Number.MAX_SAFE_INTEGER,Bs=Number.isInteger||(e=>"number"==typeof e&&isFinite(e)&&xs(e)===e),Os=String.fromCharCode,$s=/^\s*/g,Us=/([A-Z])/g,js=(e,t)=>(e=>e.replace($s,""))(e.replace(Us,(e=>`${t}${(e=>e.toLowerCase())(e)}`))),zs="undefined"!=typeof TextEncoder?new TextEncoder:null,Ws=zs?e=>zs.encode(e):e=>{const t=unescape(encodeURIComponent(e)),a=t.length,i=new Uint8Array(a);for(let e=0;e<a;e++)i[e]=t.codePointAt(e);return i};let Ys="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ys&&1===Ys.decode(new Uint8Array).length&&(Ys=null);class Hs{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Gs=()=>new Hs,qs=e=>{let t=e.cpos;for(let a=0;a<e.bufs.length;a++)t+=e.bufs[a].length;return t},Zs=e=>{const t=new Uint8Array(qs(e));let a=0;for(let i=0;i<e.bufs.length;i++){const n=e.bufs[i];t.set(n,a),a+=n.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),a),t},Js=(e,t)=>{const a=e.cbuf.length;e.cpos===a&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*a),e.cpos=0),e.cbuf[e.cpos++]=t},Ks=Js,Xs=(e,t)=>{for(;t>Ps;)Js(e,Rs|Ps&t),t=xs(t/128);Js(e,Ps&t)},Qs=(e,t)=>{const a=Fs(t);for(a&&(t=-t),Js(e,(t>63?Rs:0)|(a?Ds:0)|63&t),t=xs(t/64);t>0;)Js(e,(t>Ps?Rs:0)|Ps&t),t=xs(t/128)},eo=new Uint8Array(3e4),to=eo.length/3,ao=zs&&zs.encodeInto?(e,t)=>{if(t.length<to){const a=zs.encodeInto(t,eo).written||0;Xs(e,a);for(let t=0;t<a;t++)Js(e,eo[t])}else no(e,Ws(t))}:(e,t)=>{const a=unescape(encodeURIComponent(t)),i=a.length;Xs(e,i);for(let t=0;t<i;t++)Js(e,a.codePointAt(t))},io=(e,t)=>{const a=e.cbuf.length,i=e.cpos,n=Vs(a-i,t.length),r=t.length-n;e.cbuf.set(t.subarray(0,n),i),e.cpos+=n,r>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Is(2*a,r)),e.cbuf.set(t.subarray(n)),e.cpos=r)},no=(e,t)=>{Xs(e,t.byteLength),io(e,t)},ro=(e,t)=>{((e,t)=>{const a=e.cbuf.length;a-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(2*Is(a,t)),e.cpos=0)})(e,t);const a=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,a},so=new DataView(new ArrayBuffer(4)),oo=(e,t)=>{switch(typeof t){case"string":Js(e,119),ao(e,t);break;case"number":Bs(t)&&Cs(t)<=2147483647?(Js(e,125),Qs(e,t)):(a=t,so.setFloat32(0,a),so.getFloat32(0)===a?(Js(e,124),((e,t)=>{ro(e,4).setFloat32(0,t,!1)})(e,t)):(Js(e,123),((e,t)=>{ro(e,8).setFloat64(0,t,!1)})(e,t)));break;case"bigint":Js(e,122),((e,t)=>{ro(e,8).setBigInt64(0,t,!1)})(e,t);break;case"object":if(null===t)Js(e,126);else if(Ns(t)){Js(e,117),Xs(e,t.length);for(let a=0;a<t.length;a++)oo(e,t[a])}else if(t instanceof Uint8Array)Js(e,116),no(e,t);else{Js(e,118);const a=Object.keys(t);Xs(e,a.length);for(let i=0;i<a.length;i++){const n=a[i];ao(e,n),oo(e,t[n])}}break;case"boolean":Js(e,t?120:121);break;default:Js(e,127)}var a};class lo extends Hs{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Xs(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const uo=e=>{e.count>0&&(Qs(e.encoder,1===e.count?e.s:-e.s),e.count>1&&Xs(e.encoder,e.count-2))};class co{constructor(){this.encoder=new Hs,this.s=0,this.count=0}write(e){this.s===e?this.count++:(uo(this),this.count=1,this.s=e)}toUint8Array(){return uo(this),Zs(this.encoder)}}const po=e=>{if(e.count>0){const t=2*e.diff+(1===e.count?0:1);Qs(e.encoder,t),e.count>1&&Xs(e.encoder,e.count-2)}};class ho{constructor(){this.encoder=new Hs,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(po(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return po(this),Zs(this.encoder)}}class fo{constructor(){this.sarr=[],this.s="",this.lensE=new co}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Hs;return this.sarr.push(this.s),this.s="",ao(e,this.sarr.join("")),io(e,this.lensE.toUint8Array()),Zs(e)}}const mo=e=>new Error(e),yo=()=>{throw mo("Method unimplemented")},go=()=>{throw mo("Unexpected case")},bo=mo("Unexpected end of array"),vo=mo("Integer out of Range");class wo{constructor(e){this.arr=e,this.pos=0}}const _o=e=>new wo(e),Ao=e=>((e,t)=>{const a=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,a})(e,So(e)),ko=e=>e.arr[e.pos++],So=e=>{let t=0,a=1;const i=e.arr.length;for(;e.pos<i;){const i=e.arr[e.pos++];if(t+=(i&Ps)*a,a*=128,i<Rs)return t;if(t>Ls)throw vo}throw bo},No=e=>{let t=e.arr[e.pos++],a=63&t,i=64;const n=(t&Ds)>0?-1:1;if(!(t&Rs))return n*a;const r=e.arr.length;for(;e.pos<r;){if(t=e.arr[e.pos++],a+=(t&Ps)*i,i*=128,t<Rs)return n*a;if(a>Ls)throw vo}throw bo},To=Ys?e=>Ys.decode(Ao(e)):e=>{let t=So(e);if(0===t)return"";{let a=String.fromCodePoint(ko(e));if(--t<100)for(;t--;)a+=String.fromCodePoint(ko(e));else for(;t>0;){const i=t<1e4?t:1e4,n=e.arr.subarray(e.pos,e.pos+i);e.pos+=i,a+=String.fromCodePoint.apply(null,n),t-=i}return decodeURIComponent(escape(a))}},Mo=(e,t)=>{const a=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,a},xo=[e=>{},e=>null,No,e=>Mo(e,4).getFloat32(0,!1),e=>Mo(e,8).getFloat64(0,!1),e=>Mo(e,8).getBigInt64(0,!1),e=>!1,e=>!0,To,e=>{const t=So(e),a={};for(let i=0;i<t;i++){a[To(e)]=Co(e)}return a},e=>{const t=So(e),a=[];for(let i=0;i<t;i++)a.push(Co(e));return a},Ao],Co=e=>xo[127-ko(e)](e);class Vo extends wo{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){var e;return 0===this.count&&(this.s=this.reader(this),(e=this).pos!==e.arr.length?this.count=So(this)+1:this.count=-1),this.count--,this.s}}class Io extends wo{constructor(e){super(e),this.s=0,this.count=0}read(){if(0===this.count){this.s=No(this);const e=Fs(this.s);this.count=1,e&&(this.s=-this.s,this.count=So(this)+2)}return this.count--,this.s}}class Eo extends wo{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const e=No(this),t=1&e;this.diff=xs(e/2),this.count=1,t&&(this.count=So(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Fo{constructor(e){this.decoder=new Io(e),this.str=To(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const Do=crypto.getRandomValues.bind(crypto),Ro=()=>Do(new Uint32Array(1))[0],Po=[1e7]+-1e3+-4e3+-8e3+-1e11,Lo=()=>Po.replace(/[018]/g,(e=>(e^Ro()&15>>e/4).toString(16))),Bo=Date.now,Oo=e=>new Promise(e);Promise.all.bind(Promise);const $o=e=>void 0===e?null:e;let Uo=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},jo=!0;try{"undefined"!=typeof localStorage&&localStorage&&(Uo=localStorage,jo=!1)}catch(e){}const zo=Uo,Wo=Object.assign,Yo=Object.keys,Ho=e=>Yo(e).length,Go=e=>Yo(e).length,qo=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Zo=Object.freeze,Jo=e=>{for(const t in e){const a=e[t];"object"!=typeof a&&"function"!=typeof a||Jo(e[t])}return Zo(e)},Ko=Symbol("Equality"),Xo=(e,t,a=0)=>{try{for(;a<e.length;a++)e[a](...t)}finally{a<e.length&&Xo(e,t,a+1)}},Qo=e=>e,el=(e,t)=>{if(e===t)return!0;if(null==e||null==t||e.constructor!==t.constructor)return!1;if(null!=e[Ko])return e[Ko](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let a=0;a<e.length;a++)if(e[a]!==t[a])return!1;break;case Set:if(e.size!==t.size)return!1;for(const a of e)if(!t.has(a))return!1;break;case Map:if(e.size!==t.size)return!1;for(const a of e.keys())if(!t.has(a)||!el(e.get(a),t.get(a)))return!1;break;case Object:if(Ho(e)!==Ho(t))return!1;for(const a in e)if(!qo(e,a)||!el(e[a],t[a]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!el(e[a],t[a]))return!1;break;default:return!1}return!0},tl=void 0!==gs&&gs.release&&/node|io\.js/.test(gs.release.name)&&"[object process]"===Object.prototype.toString.call(void 0!==gs?gs:0),al="undefined"!=typeof window&&"undefined"!=typeof document&&!tl;let il;const nl=e=>(()=>{if(void 0===il)if(tl){il=bs();const e=gs.argv;let t=null;for(let a=0;a<e.length;a++){const i=e[a];"-"===i[0]?(null!==t&&il.set(t,""),t=i):null!==t&&(il.set(t,i),t=null)}null!==t&&il.set(t,"")}else"object"==typeof location?(il=bs(),(location.search||"?").slice(1).split("&").forEach((e=>{if(0!==e.length){const[t,a]=e.split("=");il.set(`--${js(t,"-")}`,a),il.set(`-${js(t,"-")}`,a)}}))):il=bs();return il})().has(e),rl=e=>$o(tl?gs.env[e.toUpperCase().replaceAll("-","_")]:zo.getItem(e)),sl=e=>nl("--"+e)||null!==rl(e);sl("production");var ol;const ll=tl&&(ol=gs.env.FORCE_COLOR,["true","1","2"].includes(ol))||!nl("--no-colors")&&!sl("no-color")&&(!tl||gs.stdout.isTTY)&&(!tl||nl("--color")||null!==rl("COLORTERM")||(rl("TERM")||"").includes("color")),ul=e=>new Uint8Array(e),cl=al?e=>{let t="";for(let a=0;a<e.byteLength;a++)t+=Os(e[a]);return btoa(t)}:e=>$i.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),dl=al?e=>{const t=atob(e),a=ul(t.length);for(let e=0;e<t.length;e++)a[e]=t.charCodeAt(e);return a}:e=>{const t=$i.from(e,"base64");return((e,t,a)=>new Uint8Array(e,t,a))(t.buffer,t.byteOffset,t.byteLength)};class pl{constructor(e,t){this.left=e,this.right=t}}const hl=(e,t)=>new pl(e,t);"undefined"!=typeof DOMParser&&new DOMParser;const fl=Symbol,ml=fl(),yl=fl(),gl=fl(),bl=fl(),vl=fl(),wl=fl(),_l=fl(),Al=fl(),kl=fl(),Sl={[ml]:hl("font-weight","bold"),[yl]:hl("font-weight","normal"),[gl]:hl("color","blue"),[vl]:hl("color","green"),[bl]:hl("color","grey"),[wl]:hl("color","red"),[_l]:hl("color","purple"),[Al]:hl("color","orange"),[kl]:hl("color","black")},Nl=ll?e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());const t=[],a=[],i=bs();let n=[],r=0;for(;r<e.length;r++){const n=e[r],s=Sl[n];if(void 0!==s)i.set(s.left,s.right);else{if(void 0===n)break;if(n.constructor!==String&&n.constructor!==Number)break;{const e=((e,t)=>{const a=[];for(const[i,n]of e)a.push(t(n,i));return a})(i,((e,t)=>`${t}:${e};`)).join("");r>0||e.length>0?(t.push("%c"+n),a.push(e)):t.push(n)}}}for(r>0&&(n=a,n.unshift(t.join("")));r<e.length;r++){const t=e[r];t instanceof Symbol||n.push(t)}return n}:e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());const t=[],a=[];let i=0;for(;i<e.length;i++){const a=e[i];if(void 0===a)break;if(a.constructor===String||a.constructor===Number)t.push(a);else if(a.constructor===Object)break}for(i>0&&a.push(t.join(""));i<e.length;i++){const t=e[i];t instanceof Symbol||a.push(t)}return a},Tl=_s(),Ml=e=>({[Symbol.iterator](){return this},next:e}),xl=(e,t)=>Ml((()=>{const{done:a,value:i}=e.next();return{done:a,value:a?void 0:t(i)}}));class Cl{constructor(e,t){this.clock=e,this.len=t}}class Vl{constructor(){this.clients=new Map}}const Il=(e,t,a)=>t.clients.forEach(((t,i)=>{const n=e.doc.store.clients.get(i);if(null!=n){const i=n[n.length-1],r=i.id.clock+i.length;for(let i=0,s=t[i];i<t.length&&s.clock<r;s=t[++i])_u(e,n,s.clock,s.len,a)}})),El=(e,t)=>{const a=e.clients.get(t.client);return void 0!==a&&null!==((e,t)=>{let a=0,i=e.length-1;for(;a<=i;){const n=xs((a+i)/2),r=e[n],s=r.clock;if(s<=t){if(t<s+r.len)return n;a=n+1}else i=n-1}return null})(a,t.clock)},Fl=e=>{e.clients.forEach((e=>{let t,a;for(e.sort(((e,t)=>e.clock-t.clock)),t=1,a=1;t<e.length;t++){const i=e[a-1],n=e[t];i.clock+i.len>=n.clock?i.len=Is(i.len,n.clock+n.len-i.clock):(a<t&&(e[a]=n),a++)}e.length=a}))},Dl=(e,t,a,i)=>{ws(e.clients,t,(()=>[])).push(new Cl(a,i))},Rl=e=>{const t=new Vl;return e.clients.forEach(((e,a)=>{const i=[];for(let t=0;t<e.length;t++){const a=e[t];if(a.deleted){const n=a.id.clock;let r=a.length;if(t+1<e.length)for(let a=e[t+1];t+1<e.length&&a.deleted;a=e[1+ ++t])r+=a.length;i.push(new Cl(n,r))}}i.length>0&&t.clients.set(a,i)})),t},Pl=(e,t)=>{Xs(e.restEncoder,t.clients.size),Ss(t.clients.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,a])=>{e.resetDsCurVal(),Xs(e.restEncoder,t);const i=a.length;Xs(e.restEncoder,i);for(let t=0;t<i;t++){const i=a[t];e.writeDsClock(i.clock),e.writeDsLen(i.len)}}))},Ll=e=>{const t=new Vl,a=So(e.restDecoder);for(let i=0;i<a;i++){e.resetDsCurVal();const a=So(e.restDecoder),i=So(e.restDecoder);if(i>0){const n=ws(t.clients,a,(()=>[]));for(let t=0;t<i;t++)n.push(new Cl(e.readDsClock(),e.readDsLen()))}}return t},Bl=(e,t,a)=>{const i=new Vl,n=So(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const n=So(e.restDecoder),r=So(e.restDecoder),s=a.clients.get(n)||[],o=fu(a,n);for(let a=0;a<r;a++){const a=e.readDsClock(),r=a+e.readDsLen();if(a<o){o<r&&Dl(i,n,o,r-o);let e=yu(s,a),l=s[e];for(!l.deleted&&l.id.clock<a&&(s.splice(e+1,0,nd(t,l,a-l.id.clock)),e++);e<s.length&&(l=s[e++],l.id.clock<r);)l.deleted||(r<l.id.clock+l.length&&s.splice(e,0,nd(t,l,r-l.id.clock)),l.delete(t))}else Dl(i,n,a,r-a)}}if(i.clients.size>0){const e=new ql;return Xs(e.restEncoder,0),Pl(e,i),e.toUint8Array()}return null},Ol=Ro;class $l extends Ts{constructor({guid:e=Lo(),collectionid:t=null,gc:a=!0,gcFilter:i=()=>!0,meta:n=null,autoLoad:r=!1,shouldLoad:s=!0}={}){super(),this.gc=a,this.gcFilter=i,this.clientID=Ol(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new pu,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=s,this.autoLoad=r,this.meta=n,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Oo((e=>{this.on("load",(()=>{this.isLoaded=!0,e(this)}))}));const o=()=>Oo((e=>{const t=a=>{void 0!==a&&!0!==a||(this.off("sync",t),e())};this.on("sync",t)}));this.on("sync",(e=>{!1===e&&this.isSynced&&(this.whenSynced=o()),this.isSynced=void 0===e||!0===e,this.isSynced&&!this.isLoaded&&this.emit("load",[this])})),this.whenSynced=o()}load(){const e=this._item;null===e||this.shouldLoad||Mu(e.parent.doc,(e=>{e.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ss(this.subdocs).map((e=>e.guid)))}transact(e,t=null){return Mu(this,e,t)}get(e,t=qu){const a=ws(this.share,e,(()=>{const e=new t;return e._integrate(this,null),e})),i=a.constructor;if(t!==qu&&i!==t){if(i===qu){const i=new t;i._map=a._map,a._map.forEach((e=>{for(;null!==e;e=e.left)e.parent=i})),i._start=a._start;for(let e=i._start;null!==e;e=e.right)e.parent=i;return i._length=a._length,this.share.set(e,i),i._integrate(this,null),i}throw new Error(`Type with the name ${e} has already been defined with a different constructor`)}return a}getArray(e=""){return this.get(e,pc)}getText(e=""){return this.get(e,Vc)}getMap(e=""){return this.get(e,fc)}getXmlElement(e=""){return this.get(e,Fc)}getXmlFragment(e=""){return this.get(e,Ec)}toJSON(){const e={};return this.share.forEach(((t,a)=>{e[a]=t.toJSON()})),e}destroy(){this.isDestroyed=!0,Ss(this.subdocs).forEach((e=>e.destroy()));const e=this._item;if(null!==e){this._item=null;const t=e.content;t.doc=new $l({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,Mu(e.parent.doc,(a=>{const i=t.doc;e.deleted||a.subdocsAdded.add(i),a.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Ul{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return So(this.restDecoder)}readDsLen(){return So(this.restDecoder)}}class jl extends Ul{readLeftID(){return uu(So(this.restDecoder),So(this.restDecoder))}readRightID(){return uu(So(this.restDecoder),So(this.restDecoder))}readClient(){return So(this.restDecoder)}readInfo(){return ko(this.restDecoder)}readString(){return To(this.restDecoder)}readParentInfo(){return 1===So(this.restDecoder)}readTypeRef(){return So(this.restDecoder)}readLen(){return So(this.restDecoder)}readAny(){return Co(this.restDecoder)}readBuf(){return(e=>{const t=ul(e.byteLength);return t.set(e),t})(Ao(this.restDecoder))}readJSON(){return JSON.parse(To(this.restDecoder))}readKey(){return To(this.restDecoder)}}class zl{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=So(this.restDecoder),this.dsCurrVal}readDsLen(){const e=So(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Wl extends zl{constructor(e){super(e),this.keys=[],So(e),this.keyClockDecoder=new Eo(Ao(e)),this.clientDecoder=new Io(Ao(e)),this.leftClockDecoder=new Eo(Ao(e)),this.rightClockDecoder=new Eo(Ao(e)),this.infoDecoder=new Vo(Ao(e),ko),this.stringDecoder=new Fo(Ao(e)),this.parentInfoDecoder=new Vo(Ao(e),ko),this.typeRefDecoder=new Io(Ao(e)),this.lenDecoder=new Io(Ao(e))}readLeftID(){return new ou(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ou(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Co(this.restDecoder)}readBuf(){return Ao(this.restDecoder)}readJSON(){return Co(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const e=this.stringDecoder.read();return this.keys.push(e),e}}}class Yl{constructor(){this.restEncoder=Gs()}toUint8Array(){return Zs(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Xs(this.restEncoder,e)}writeDsLen(e){Xs(this.restEncoder,e)}}class Hl extends Yl{writeLeftID(e){Xs(this.restEncoder,e.client),Xs(this.restEncoder,e.clock)}writeRightID(e){Xs(this.restEncoder,e.client),Xs(this.restEncoder,e.clock)}writeClient(e){Xs(this.restEncoder,e)}writeInfo(e){Ks(this.restEncoder,e)}writeString(e){ao(this.restEncoder,e)}writeParentInfo(e){Xs(this.restEncoder,e?1:0)}writeTypeRef(e){Xs(this.restEncoder,e)}writeLen(e){Xs(this.restEncoder,e)}writeAny(e){oo(this.restEncoder,e)}writeBuf(e){no(this.restEncoder,e)}writeJSON(e){ao(this.restEncoder,JSON.stringify(e))}writeKey(e){ao(this.restEncoder,e)}}class Gl{constructor(){this.restEncoder=Gs(),this.dsCurrVal=0}toUint8Array(){return Zs(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,Xs(this.restEncoder,t)}writeDsLen(e){0===e&&go(),Xs(this.restEncoder,e-1),this.dsCurrVal+=e}}class ql extends Gl{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ho,this.clientEncoder=new co,this.leftClockEncoder=new ho,this.rightClockEncoder=new ho,this.infoEncoder=new lo(Ks),this.stringEncoder=new fo,this.parentInfoEncoder=new lo(Ks),this.typeRefEncoder=new co,this.lenEncoder=new co}toUint8Array(){const e=Gs();return Xs(e,0),no(e,this.keyClockEncoder.toUint8Array()),no(e,this.clientEncoder.toUint8Array()),no(e,this.leftClockEncoder.toUint8Array()),no(e,this.rightClockEncoder.toUint8Array()),no(e,Zs(this.infoEncoder)),no(e,this.stringEncoder.toUint8Array()),no(e,Zs(this.parentInfoEncoder)),no(e,this.typeRefEncoder.toUint8Array()),no(e,this.lenEncoder.toUint8Array()),io(e,Zs(this.restEncoder)),Zs(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){oo(this.restEncoder,e)}writeBuf(e){no(this.restEncoder,e)}writeJSON(e){oo(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);void 0===t?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const Zl=(e,t,a)=>{const i=new Map;a.forEach(((e,a)=>{fu(t,a)>e&&i.set(a,e)})),hu(t).forEach(((e,t)=>{a.has(t)||i.set(t,0)})),Xs(e.restEncoder,i.size),Ss(i.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([a,i])=>{((e,t,a,i)=>{i=Is(i,t[0].id.clock);const n=yu(t,i);Xs(e.restEncoder,t.length-n),e.writeClient(a),Xs(e.restEncoder,i);const r=t[n];r.write(e,i-r.id.clock);for(let a=n+1;a<t.length;a++)t[a].write(e,0)})(e,t.clients.get(a),a,i)}))},Jl=(e,t,a,i=new Wl(e))=>Mu(t,(e=>{e.local=!1;let t=!1;const a=e.doc,n=a.store,r=((e,t)=>{const a=bs(),i=So(e.restDecoder);for(let n=0;n<i;n++){const i=So(e.restDecoder),n=new Array(i),r=e.readClient();let s=So(e.restDecoder);a.set(r,{i:0,refs:n});for(let a=0;a<i;a++){const i=e.readInfo();switch(31&i){case 0:{const t=e.readLen();n[a]=new Bc(uu(r,s),t),s+=t;break}case 10:{const t=So(e.restDecoder);n[a]=new ld(uu(r,s),t),s+=t;break}default:{const o=!(192&i),l=new rd(uu(r,s),null,(i&Rs)===Rs?e.readLeftID():null,null,(i&Ds)===Ds?e.readRightID():null,o?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,!o||32&~i?null:e.readString(),sd(e,i));n[a]=l,s+=l.length}}}}return a})(i,a),s=((e,t,a)=>{const i=[];let n=Ss(a.keys()).sort(((e,t)=>e-t));if(0===n.length)return null;const r=()=>{if(0===n.length)return null;let e=a.get(n[n.length-1]);for(;e.refs.length===e.i;){if(n.pop(),!(n.length>0))return null;e=a.get(n[n.length-1])}return e};let s=r();if(null===s)return null;const o=new pu,l=new Map,u=(e,t)=>{const a=l.get(e);(null==a||a>t)&&l.set(e,t)};let c=s.refs[s.i++];const d=new Map,p=()=>{for(const e of i){const t=e.id.client,i=a.get(t);i?(i.i--,o.clients.set(t,i.refs.slice(i.i)),a.delete(t),i.i=0,i.refs=[]):o.clients.set(t,[e]),n=n.filter((e=>e!==t))}i.length=0};for(;;){if(c.constructor!==ld){const n=ws(d,c.id.client,(()=>fu(t,c.id.client)))-c.id.clock;if(n<0)i.push(c),u(c.id.client,c.id.clock-1),p();else{const r=c.getMissing(e,t);if(null!==r){i.push(c);const e=a.get(r)||{refs:[],i:0};if(e.refs.length!==e.i){c=e.refs[e.i++];continue}u(r,fu(t,r)),p()}else(0===n||n<c.length)&&(c.integrate(e,n),d.set(c.id.client,c.id.clock+c.length))}}if(i.length>0)c=i.pop();else if(null!==s&&s.i<s.refs.length)c=s.refs[s.i++];else{if(s=r(),null===s)break;c=s.refs[s.i++]}}if(o.clients.size>0){const e=new ql;return Zl(e,o,new Map),Xs(e.restEncoder,0),{missing:l,update:e.toUint8Array()}}return null})(e,n,r),o=n.pendingStructs;if(o){for(const[e,a]of o.missing)if(a<fu(n,e)){t=!0;break}if(s){for(const[e,t]of s.missing){const a=o.missing.get(e);(null==a||a>t)&&o.missing.set(e,t)}o.update=Eu([o.update,s.update])}}else n.pendingStructs=s;const l=Bl(i,e,n);if(n.pendingDs){const t=new Wl(_o(n.pendingDs));So(t.restDecoder);const a=Bl(t,e,n);n.pendingDs=l&&a?Eu([l,a]):l||a}else n.pendingDs=l;if(t){const t=n.pendingStructs.update;n.pendingStructs=null,Kl(e.doc,t)}}),a,!1),Kl=(e,t,a,i=Wl)=>{const n=_o(t);Jl(n,e,a,new i(n))},Xl=(e,t=new Uint8Array([0]),a=new ql)=>{((e,t,a=new Map)=>{Zl(e,t.store,a),Pl(e,Rl(t.store))})(a,e,Ql(t));const i=[a.toUint8Array()];if(e.store.pendingDs&&i.push(e.store.pendingDs),e.store.pendingStructs&&i.push(Fu(e.store.pendingStructs.update,t)),i.length>1){if(a.constructor===Hl)return Vu(i.map(((e,t)=>0===t?e:Lu(e))));if(a.constructor===ql)return Eu(i)}return i[0]},Ql=e=>(e=>{const t=new Map,a=So(e.restDecoder);for(let i=0;i<a;i++){const a=So(e.restDecoder),i=So(e.restDecoder);t.set(a,i)}return t})(new Ul(_o(e))),eu=(e,t)=>(Xs(e.restEncoder,t.size),Ss(t.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,a])=>{Xs(e.restEncoder,t),Xs(e.restEncoder,a)})),e),tu=(e,t=new Gl)=>(e instanceof Map?eu(t,e):((e,t)=>{eu(e,hu(t.store))})(t,e),t.toUint8Array());class au{constructor(){this.l=[]}}const iu=()=>new au,nu=(e,t)=>e.l.push(t),ru=(e,t)=>{const a=e.l,i=a.length;e.l=a.filter((e=>t!==e)),i===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},su=(e,t,a)=>Xo(e.l,[t,a]);class ou{constructor(e,t){this.client=e,this.clock=t}}const lu=(e,t)=>e===t||null!==e&&null!==t&&e.client===t.client&&e.clock===t.clock,uu=(e,t)=>new ou(e,t),cu=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!El(t.ds,e.id),du=(e,t)=>{const a=ws(e.meta,du,_s),i=e.doc.store;a.has(t)||(t.sv.forEach(((t,a)=>{t<fu(i,a)&&vu(e,uu(a,t))})),Il(e,t.ds,(e=>{})),a.add(t))};class pu{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const hu=e=>{const t=new Map;return e.clients.forEach(((e,a)=>{const i=e[e.length-1];t.set(a,i.id.clock+i.length)})),t},fu=(e,t)=>{const a=e.clients.get(t);if(void 0===a)return 0;const i=a[a.length-1];return i.id.clock+i.length},mu=(e,t)=>{let a=e.clients.get(t.id.client);if(void 0===a)a=[],e.clients.set(t.id.client,a);else{const e=a[a.length-1];if(e.id.clock+e.length!==t.id.clock)throw go()}a.push(t)},yu=(e,t)=>{let a=0,i=e.length-1,n=e[i],r=n.id.clock;if(r===t)return i;let s=xs(t/(r+n.length-1)*i);for(;a<=i;){if(n=e[s],r=n.id.clock,r<=t){if(t<r+n.length)return s;a=s+1}else i=s-1;s=xs((a+i)/2)}throw go()},gu=(e,t)=>{const a=e.clients.get(t.client);return a[yu(a,t.clock)]},bu=(e,t,a)=>{const i=yu(t,a),n=t[i];return n.id.clock<a&&n instanceof rd?(t.splice(i+1,0,nd(e,n,a-n.id.clock)),i+1):i},vu=(e,t)=>{const a=e.doc.store.clients.get(t.client);return a[bu(e,a,t.clock)]},wu=(e,t,a)=>{const i=t.clients.get(a.client),n=yu(i,a.clock),r=i[n];return a.clock!==r.id.clock+r.length-1&&r.constructor!==Bc&&i.splice(n+1,0,nd(e,r,a.clock-r.id.clock+1)),r},_u=(e,t,a,i,n)=>{if(0===i)return;const r=a+i;let s,o=bu(e,t,a);do{s=t[o++],r<s.id.clock+s.length&&bu(e,t,r),n(s)}while(o<t.length&&t[o].id.clock<r)};class Au{constructor(e,t,a){this.doc=e,this.deleteSet=new Vl,this.beforeState=hu(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=a,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const ku=(e,t)=>!(0===t.deleteSet.clients.size&&!((e,t)=>{for(const[a,i]of e)if(t(i,a))return!0;return!1})(t.afterState,((e,a)=>t.beforeState.get(a)!==e)))&&(Fl(t.deleteSet),((e,t)=>{Zl(e,t.doc.store,t.beforeState)})(e,t),Pl(e,t.deleteSet),!0),Su=(e,t,a)=>{const i=t._item;(null===i||i.id.clock<(e.beforeState.get(i.id.client)||0)&&!i.deleted)&&ws(e.changed,t,_s).add(a)},Nu=(e,t)=>{let a=e[t],i=e[t-1],n=t;for(;n>0&&(i.deleted===a.deleted&&i.constructor===a.constructor&&i.mergeWith(a));a=i,i=e[--n-1])a instanceof rd&&null!==a.parentSub&&a.parent._map.get(a.parentSub)===a&&a.parent._map.set(a.parentSub,i);const r=t-n;return r&&e.splice(t+1-r,r),r},Tu=(e,t)=>{if(t<e.length){const a=e[t],i=a.doc,n=i.store,r=a.deleteSet,s=a._mergeStructs;try{Fl(r),a.afterState=hu(a.doc.store),i.emit("beforeObserverCalls",[a,i]);const e=[];a.changed.forEach(((t,i)=>e.push((()=>{null!==i._item&&i._item.deleted||i._callObserver(a,t)})))),e.push((()=>{a.changedParentTypes.forEach(((e,t)=>{t._dEH.l.length>0&&(null===t._item||!t._item.deleted)&&((e=e.filter((e=>null===e.target._item||!e.target._item.deleted))).forEach((e=>{e.currentTarget=t,e._path=null})),e.sort(((e,t)=>e.path.length-t.path.length)),su(t._dEH,e,a))}))})),e.push((()=>i.emit("afterTransaction",[a,i]))),Xo(e,[]),a._needFormattingCleanup&&Mc(a)}finally{i.gc&&((e,t,a)=>{for(const[i,n]of e.clients.entries()){const e=t.clients.get(i);for(let i=n.length-1;i>=0;i--){const r=n[i],s=r.clock+r.len;for(let i=yu(e,r.clock),n=e[i];i<e.length&&n.id.clock<s;n=e[++i]){const n=e[i];if(r.clock+r.len<=n.id.clock)break;n instanceof rd&&n.deleted&&!n.keep&&a(n)&&n.gc(t,!1)}}}})(r,n,i.gcFilter),((e,t)=>{e.clients.forEach(((e,a)=>{const i=t.clients.get(a);for(let t=e.length-1;t>=0;t--){const a=e[t];for(let e=Vs(i.length-1,1+yu(i,a.clock+a.len-1)),t=i[e];e>0&&t.id.clock>=a.clock;t=i[e])e-=1+Nu(i,e)}}))})(r,n),a.afterState.forEach(((e,t)=>{const i=a.beforeState.get(t)||0;if(i!==e){const e=n.clients.get(t),a=Is(yu(e,i),1);for(let t=e.length-1;t>=a;)t-=1+Nu(e,t)}}));for(let e=s.length-1;e>=0;e--){const{client:t,clock:a}=s[e].id,i=n.clients.get(t),r=yu(i,a);r+1<i.length&&Nu(i,r+1)>1||r>0&&Nu(i,r)}if(a.local||a.afterState.get(i.clientID)===a.beforeState.get(i.clientID)||(((...e)=>{console.log(...Nl(e)),Tl.forEach((t=>t.print(e)))})(Al,ml,"[yjs] ",yl,wl,"Changed the client-id because another client seems to be using it."),i.clientID=Ol()),i.emit("afterTransactionCleanup",[a,i]),i._observers.has("update")){const e=new Hl;ku(e,a)&&i.emit("update",[e.toUint8Array(),a.origin,i,a])}if(i._observers.has("updateV2")){const e=new ql;ku(e,a)&&i.emit("updateV2",[e.toUint8Array(),a.origin,i,a])}const{subdocsAdded:o,subdocsLoaded:l,subdocsRemoved:u}=a;(o.size>0||u.size>0||l.size>0)&&(o.forEach((e=>{e.clientID=i.clientID,null==e.collectionid&&(e.collectionid=i.collectionid),i.subdocs.add(e)})),u.forEach((e=>i.subdocs.delete(e))),i.emit("subdocs",[{loaded:l,added:o,removed:u},i,a]),u.forEach((e=>e.destroy()))),e.length<=t+1?(i._transactionCleanups=[],i.emit("afterAllTransactions",[i,e])):Tu(e,t+1)}}},Mu=(e,t,a=null,i=!0)=>{const n=e._transactionCleanups;let r=!1,s=null;null===e._transaction&&(r=!0,e._transaction=new Au(e,a,i),n.push(e._transaction),1===n.length&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(r){const t=e._transaction===n[0];e._transaction=null,t&&Tu(n,0)}}return s};class xu{constructor(e,t){this.gen=function*(e){const t=So(e.restDecoder);for(let a=0;a<t;a++){const t=So(e.restDecoder),a=e.readClient();let i=So(e.restDecoder);for(let n=0;n<t;n++){const t=e.readInfo();if(10===t){const t=So(e.restDecoder);yield new ld(uu(a,i),t),i+=t}else if(31&t){const n=!(192&t),r=new rd(uu(a,i),null,(t&Rs)===Rs?e.readLeftID():null,null,(t&Ds)===Ds?e.readRightID():null,n?e.readParentInfo()?e.readString():e.readLeftID():null,!n||32&~t?null:e.readString(),sd(e,t));yield r,i+=r.length}else{const t=e.readLen();yield new Bc(uu(a,i),t),i+=t}}}}(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===ld);return this.curr}}class Cu{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Vu=e=>Eu(e,jl,Hl),Iu=(e,t)=>{if(e.constructor===Bc){const{client:a,clock:i}=e.id;return new Bc(uu(a,i+t),e.length-t)}if(e.constructor===ld){const{client:a,clock:i}=e.id;return new ld(uu(a,i+t),e.length-t)}{const a=e,{client:i,clock:n}=a.id;return new rd(uu(i,n+t),null,uu(i,n+t-1),null,a.rightOrigin,a.parent,a.parentSub,a.content.splice(t))}},Eu=(e,t=Wl,a=ql)=>{if(1===e.length)return e[0];const i=e.map((e=>new t(_o(e))));let n=i.map((e=>new xu(e,!0))),r=null;const s=new a,o=new Cu(s);for(;n=n.filter((e=>null!==e.curr)),n.sort(((e,t)=>{if(e.curr.id.client===t.curr.id.client){const a=e.curr.id.clock-t.curr.id.clock;return 0===a?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===ld?1:-1:a}return t.curr.id.client-e.curr.id.client})),0!==n.length;){const e=n[0],t=e.curr.id.client;if(null!==r){let a=e.curr,i=!1;for(;null!==a&&a.id.clock+a.length<=r.struct.id.clock+r.struct.length&&a.id.client>=r.struct.id.client;)a=e.next(),i=!0;if(null===a||a.id.client!==t||i&&a.id.clock>r.struct.id.clock+r.struct.length)continue;if(t!==r.struct.id.client)Ru(o,r.struct,r.offset),r={struct:a,offset:0},e.next();else if(r.struct.id.clock+r.struct.length<a.id.clock)if(r.struct.constructor===ld)r.struct.length=a.id.clock+a.length-r.struct.id.clock;else{Ru(o,r.struct,r.offset);const e=a.id.clock-r.struct.id.clock-r.struct.length;r={struct:new ld(uu(t,r.struct.id.clock+r.struct.length),e),offset:0}}else{const t=r.struct.id.clock+r.struct.length-a.id.clock;t>0&&(r.struct.constructor===ld?r.struct.length-=t:a=Iu(a,t)),r.struct.mergeWith(a)||(Ru(o,r.struct,r.offset),r={struct:a,offset:0},e.next())}}else r={struct:e.curr,offset:0},e.next();for(let a=e.curr;null!==a&&a.id.client===t&&a.id.clock===r.struct.id.clock+r.struct.length&&a.constructor!==ld;a=e.next())Ru(o,r.struct,r.offset),r={struct:a,offset:0}}null!==r&&(Ru(o,r.struct,r.offset),r=null),Pu(o);const l=(e=>{const t=new Vl;for(let a=0;a<e.length;a++)e[a].clients.forEach(((i,n)=>{if(!t.clients.has(n)){const r=i.slice();for(let t=a+1;t<e.length;t++)ks(r,e[t].clients.get(n)||[]);t.clients.set(n,r)}}));return Fl(t),t})(i.map((e=>Ll(e))));return Pl(s,l),s.toUint8Array()},Fu=(e,t,a=Wl,i=ql)=>{const n=Ql(t),r=new i,s=new Cu(r),o=new a(_o(e)),l=new xu(o,!1);for(;l.curr;){const e=l.curr,t=e.id.client,a=n.get(t)||0;if(l.curr.constructor!==ld)if(e.id.clock+e.length>a)for(Ru(s,e,Is(a-e.id.clock,0)),l.next();l.curr&&l.curr.id.client===t;)Ru(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===t&&l.curr.id.clock+l.curr.length<=a;)l.next();else l.next()}Pu(s);const u=Ll(o);return Pl(r,u),r.toUint8Array()},Du=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Zs(e.encoder.restEncoder)}),e.encoder.restEncoder=Gs(),e.written=0)},Ru=(e,t,a)=>{e.written>0&&e.currClient!==t.id.client&&Du(e),0===e.written&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Xs(e.encoder.restEncoder,t.id.clock+a)),t.write(e.encoder,a),e.written++},Pu=e=>{Du(e);const t=e.encoder.restEncoder;Xs(t,e.clientStructs.length);for(let a=0;a<e.clientStructs.length;a++){const i=e.clientStructs[a];Xs(t,i.written),io(t,i.restEncoder)}},Lu=e=>((e,t,a,i)=>{const n=new a(_o(e)),r=new xu(n,!1),s=new i,o=new Cu(s);for(let e=r.curr;null!==e;e=r.next())Ru(o,t(e),0);Pu(o);const l=Ll(n);return Pl(s,l),s.toUint8Array()})(e,Qo,Wl,Hl),Bu="You must not compute changes after the event-handler fired.";class Ou{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=$u(this.currentTarget,this.target))}deletes(e){return El(this.transaction.deleteSet,e.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw mo(Bu);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach((a=>{if(null!==a){const i=t._map.get(a);let n,r;if(this.adds(i)){let e=i.left;for(;null!==e&&this.adds(e);)e=e.left;if(this.deletes(i)){if(null===e||!this.deletes(e))return;n="delete",r=As(e.content.getContent())}else null!==e&&this.deletes(e)?(n="update",r=As(e.content.getContent())):(n="add",r=void 0)}else{if(!this.deletes(i))return;n="delete",r=As(i.content.getContent())}e.set(a,{action:n,oldValue:r})}})),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(null===e){if(0===this.transaction.doc._transactionCleanups.length)throw mo(Bu);const t=this.target,a=_s(),i=_s(),n=[];e={added:a,deleted:i,delta:n,keys:this.keys};if(this.transaction.changed.get(t).has(null)){let e=null;const r=()=>{e&&n.push(e)};for(let n=t._start;null!==n;n=n.right)n.deleted?this.deletes(n)&&!this.adds(n)&&(null!==e&&void 0!==e.delete||(r(),e={delete:0}),e.delete+=n.length,i.add(n)):this.adds(n)?(null!==e&&void 0!==e.insert||(r(),e={insert:[]}),e.insert=e.insert.concat(n.content.getContent()),a.add(n)):(null!==e&&void 0!==e.retain||(r(),e={retain:0}),e.retain+=n.length);null!==e&&void 0===e.retain&&r()}this._changes=e}return e}}const $u=(e,t)=>{const a=[];for(;null!==t._item&&t!==e;){if(null!==t._item.parentSub)a.unshift(t._item.parentSub);else{let e=0,i=t._item.parent._start;for(;i!==t._item&&null!==i;)!i.deleted&&i.countable&&(e+=i.length),i=i.right;a.unshift(e)}t=t._item.parent}return a},Uu=()=>{((...e)=>{console.warn(...Nl(e)),e.unshift(Al),Tl.forEach((t=>t.print(e)))})("Invalid access: Add Yjs type to a document before reading data.")};let ju=0;class zu{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ju++}}const Wu=(e,t,a)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=a,e.timestamp=ju++},Yu=(e,t)=>{if(null===e._start||0===t||null===e._searchMarker)return null;const a=0===e._searchMarker.length?null:e._searchMarker.reduce(((e,a)=>Cs(t-e.index)<Cs(t-a.index)?e:a));let i=e._start,n=0;for(null!==a&&(i=a.p,n=a.index,(e=>{e.timestamp=ju++})(a));null!==i.right&&n<t;){if(!i.deleted&&i.countable){if(t<n+i.length)break;n+=i.length}i=i.right}for(;null!==i.left&&n>t;)i=i.left,!i.deleted&&i.countable&&(n-=i.length);for(;null!==i.left&&i.left.id.client===i.id.client&&i.left.id.clock+i.left.length===i.id.clock;)i=i.left,!i.deleted&&i.countable&&(n-=i.length);return null!==a&&Cs(a.index-n)<i.parent.length/80?(Wu(a,i,n),a):((e,t,a)=>{if(e.length>=80){const i=e.reduce(((e,t)=>e.timestamp<t.timestamp?e:t));return Wu(i,t,a),i}{const i=new zu(t,a);return e.push(i),i}})(e._searchMarker,i,n)},Hu=(e,t,a)=>{for(let i=e.length-1;i>=0;i--){const n=e[i];if(a>0){let t=n.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(n.index-=t.length);if(null===t||!0===t.marker){e.splice(i,1);continue}n.p=t,t.marker=!0}(t<n.index||a>0&&t===n.index)&&(n.index=Is(t,n.index+a))}},Gu=(e,t,a)=>{const i=e,n=t.changedParentTypes;for(;ws(n,e,(()=>[])).push(a),null!==e._item;)e=e._item.parent;su(i._eH,a,t)};class qu{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=iu(),this._dEH=iu(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw yo()}clone(){throw yo()}_write(e){}get _first(){let e=this._start;for(;null!==e&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){nu(this._eH,e)}observeDeep(e){nu(this._dEH,e)}unobserve(e){ru(this._eH,e)}unobserveDeep(e){ru(this._dEH,e)}toJSON(){}}const Zu=(e,t,a)=>{e.doc??Uu(),t<0&&(t=e._length+t),a<0&&(a=e._length+a);let i=a-t;const n=[];let r=e._start;for(;null!==r&&i>0;){if(r.countable&&!r.deleted){const e=r.content.getContent();if(e.length<=t)t-=e.length;else{for(let a=t;a<e.length&&i>0;a++)n.push(e[a]),i--;t=0}}r=r.right}return n},Ju=e=>{e.doc??Uu();const t=[];let a=e._start;for(;null!==a;){if(a.countable&&!a.deleted){const e=a.content.getContent();for(let a=0;a<e.length;a++)t.push(e[a])}a=a.right}return t},Ku=(e,t)=>{let a=0,i=e._start;for(e.doc??Uu();null!==i;){if(i.countable&&!i.deleted){const n=i.content.getContent();for(let i=0;i<n.length;i++)t(n[i],a++,e)}i=i.right}},Xu=(e,t)=>{const a=[];return Ku(e,((i,n)=>{a.push(t(i,n,e))})),a},Qu=e=>{let t=e._start,a=null,i=0;return{[Symbol.iterator](){return this},next:()=>{if(null===a){for(;null!==t&&t.deleted;)t=t.right;if(null===t)return{done:!0,value:void 0};a=t.content.getContent(),i=0,t=t.right}const e=a[i++];return a.length<=i&&(a=null),{done:!1,value:e}}}},ec=(e,t)=>{e.doc??Uu();const a=Yu(e,t);let i=e._start;for(null!==a&&(i=a.p,t-=a.index);null!==i;i=i.right)if(!i.deleted&&i.countable){if(t<i.length)return i.content.getContent()[t];t-=i.length}},tc=(e,t,a,i)=>{let n=a;const r=e.doc,s=r.clientID,o=r.store,l=null===a?t._start:a.right;let u=[];const c=()=>{u.length>0&&(n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new Gc(u)),n.integrate(e,0),u=[])};i.forEach((a=>{if(null===a)u.push(a);else switch(a.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(a);break;default:switch(c(),a.constructor){case Uint8Array:case ArrayBuffer:n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new Oc(new Uint8Array(a))),n.integrate(e,0);break;case $l:n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new jc(a)),n.integrate(e,0);break;default:if(!(a instanceof qu))throw new Error("Unexpected content type in insert operation");n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new id(a)),n.integrate(e,0)}}})),c()},ac=()=>mo("Length exceeded!"),ic=(e,t,a,i)=>{if(a>t._length)throw ac();if(0===a)return t._searchMarker&&Hu(t._searchMarker,a,i.length),tc(e,t,null,i);const n=a,r=Yu(t,a);let s=t._start;for(null!==r&&(s=r.p,0===(a-=r.index)&&(s=s.prev,a+=s&&s.countable&&!s.deleted?s.length:0));null!==s;s=s.right)if(!s.deleted&&s.countable){if(a<=s.length){a<s.length&&vu(e,uu(s.id.client,s.id.clock+a));break}a-=s.length}return t._searchMarker&&Hu(t._searchMarker,n,i.length),tc(e,t,s,i)},nc=(e,t,a,i)=>{if(0===i)return;const n=a,r=i,s=Yu(t,a);let o=t._start;for(null!==s&&(o=s.p,a-=s.index);null!==o&&a>0;o=o.right)!o.deleted&&o.countable&&(a<o.length&&vu(e,uu(o.id.client,o.id.clock+a)),a-=o.length);for(;i>0&&null!==o;)o.deleted||(i<o.length&&vu(e,uu(o.id.client,o.id.clock+i)),o.delete(e),i-=o.length),o=o.right;if(i>0)throw ac();t._searchMarker&&Hu(t._searchMarker,n,-r+i)},rc=(e,t,a)=>{const i=t._map.get(a);void 0!==i&&i.delete(e)},sc=(e,t,a,i)=>{const n=t._map.get(a)||null,r=e.doc,s=r.clientID;let o;if(null==i)o=new Gc([i]);else switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:o=new Gc([i]);break;case Uint8Array:o=new Oc(i);break;case $l:o=new jc(i);break;default:if(!(i instanceof qu))throw new Error("Unexpected content type");o=new id(i)}new rd(uu(s,fu(r.store,s)),n,n&&n.lastId,null,null,t,a,o).integrate(e,0)},oc=(e,t)=>{e.doc??Uu();const a=e._map.get(t);return void 0===a||a.deleted?void 0:a.content.getContent()[a.length-1]},lc=e=>{const t={};return e.doc??Uu(),e._map.forEach(((e,a)=>{e.deleted||(t[a]=e.content.getContent()[e.length-1])})),t},uc=(e,t)=>{e.doc??Uu();const a=e._map.get(t);return void 0!==a&&!a.deleted},cc=e=>{return e.doc??Uu(),t=e._map.entries(),a=e=>!e[1].deleted,Ml((()=>{let e;do{e=t.next()}while(!e.done&&!a(e.value));return e}));var t,a};class dc extends Ou{}class pc extends qu{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new pc;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new pc}clone(){const e=new pc;return e.insert(0,this.toArray().map((e=>e instanceof qu?e.clone():e))),e}get length(){return this.doc??Uu(),this._length}_callObserver(e,t){super._callObserver(e,t),Gu(this,e,new dc(this,e))}insert(e,t){null!==this.doc?Mu(this.doc,(a=>{ic(a,this,e,t)})):this._prelimContent.splice(e,0,...t)}push(e){null!==this.doc?Mu(this.doc,(t=>{((e,t,a)=>{let i=(t._searchMarker||[]).reduce(((e,t)=>t.index>e.index?t:e),{index:0,p:t._start}).p;if(i)for(;i.right;)i=i.right;tc(e,t,i,a)})(t,this,e)})):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){null!==this.doc?Mu(this.doc,(a=>{nc(a,this,e,t)})):this._prelimContent.splice(e,t)}get(e){return ec(this,e)}toArray(){return Ju(this)}slice(e=0,t=this.length){return Zu(this,e,t)}toJSON(){return this.map((e=>e instanceof qu?e.toJSON():e))}map(e){return Xu(this,e)}forEach(e){Ku(this,e)}[Symbol.iterator](){return Qu(this)}_write(e){e.writeTypeRef(Jc)}}class hc extends Ou{constructor(e,t,a){super(e,t),this.keysChanged=a}}class fc extends qu{constructor(e){super(),this._prelimContent=null,this._prelimContent=void 0===e?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach(((e,t)=>{this.set(t,e)})),this._prelimContent=null}_copy(){return new fc}clone(){const e=new fc;return this.forEach(((t,a)=>{e.set(a,t instanceof qu?t.clone():t)})),e}_callObserver(e,t){Gu(this,e,new hc(this,e,t))}toJSON(){this.doc??Uu();const e={};return this._map.forEach(((t,a)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[a]=i instanceof qu?i.toJSON():i}})),e}get size(){return[...cc(this)].length}keys(){return xl(cc(this),(e=>e[0]))}values(){return xl(cc(this),(e=>e[1].content.getContent()[e[1].length-1]))}entries(){return xl(cc(this),(e=>[e[0],e[1].content.getContent()[e[1].length-1]]))}forEach(e){this.doc??Uu(),this._map.forEach(((t,a)=>{t.deleted||e(t.content.getContent()[t.length-1],a,this)}))}[Symbol.iterator](){return this.entries()}delete(e){null!==this.doc?Mu(this.doc,(t=>{rc(t,this,e)})):this._prelimContent.delete(e)}set(e,t){return null!==this.doc?Mu(this.doc,(a=>{sc(a,this,e,t)})):this._prelimContent.set(e,t),t}get(e){return oc(this,e)}has(e){return uc(this,e)}clear(){null!==this.doc?Mu(this.doc,(e=>{this.forEach((function(t,a,i){rc(e,i,a)}))})):this._prelimContent.clear()}_write(e){e.writeTypeRef(Kc)}}const mc=(e,t)=>e===t||"object"==typeof e&&"object"==typeof t&&e&&t&&((e,t)=>e===t||Go(e)===Go(t)&&((e,t)=>{for(const a in e)if(!t(e[a],a))return!1;return!0})(e,((e,a)=>(void 0!==e||qo(t,a))&&t[a]===e)))(e,t);class yc{constructor(e,t,a,i){this.left=e,this.right=t,this.index=a,this.currentAttributes=i}forward(){if(null===this.right&&go(),this.right.content.constructor===Wc)this.right.deleted||wc(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}}const gc=(e,t,a)=>{for(;null!==t.right&&a>0;){if(t.right.content.constructor===Wc)t.right.deleted||wc(t.currentAttributes,t.right.content);else t.right.deleted||(a<t.right.length&&vu(e,uu(t.right.id.client,t.right.id.clock+a)),t.index+=t.right.length,a-=t.right.length);t.left=t.right,t.right=t.right.right}return t},bc=(e,t,a,i)=>{const n=new Map,r=i?Yu(t,a):null;if(r){const t=new yc(r.p.left,r.p,r.index,n);return gc(e,t,a-r.index)}{const i=new yc(null,t._start,0,n);return gc(e,i,a)}},vc=(e,t,a,i)=>{for(;null!==a.right&&(!0===a.right.deleted||a.right.content.constructor===Wc&&mc(i.get(a.right.content.key),a.right.content.value));)a.right.deleted||i.delete(a.right.content.key),a.forward();const n=e.doc,r=n.clientID;i.forEach(((i,s)=>{const o=a.left,l=a.right,u=new rd(uu(r,fu(n.store,r)),o,o&&o.lastId,l,l&&l.id,t,null,new Wc(s,i));u.integrate(e,0),a.right=u,a.forward()}))},wc=(e,t)=>{const{key:a,value:i}=t;null===i?e.delete(a):e.set(a,i)},_c=(e,t)=>{for(;null!==e.right&&(e.right.deleted||e.right.content.constructor===Wc&&mc(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Ac=(e,t,a,i)=>{const n=e.doc,r=n.clientID,s=new Map;for(const o in i){const l=i[o],u=a.currentAttributes.get(o)??null;if(!mc(u,l)){s.set(o,u);const{left:i,right:c}=a;a.right=new rd(uu(r,fu(n.store,r)),i,i&&i.lastId,c,c&&c.id,t,null,new Wc(o,l)),a.right.integrate(e,0),a.forward()}}return s},kc=(e,t,a,i,n)=>{a.currentAttributes.forEach(((e,t)=>{void 0===n[t]&&(n[t]=null)}));const r=e.doc,s=r.clientID;_c(a,n);const o=Ac(e,t,a,n),l=i.constructor===String?new qc(i):i instanceof qu?new id(i):new zc(i);let{left:u,right:c,index:d}=a;t._searchMarker&&Hu(t._searchMarker,a.index,l.getLength()),c=new rd(uu(s,fu(r.store,s)),u,u&&u.lastId,c,c&&c.id,t,null,l),c.integrate(e,0),a.right=c,a.index=d,a.forward(),vc(e,t,a,o)},Sc=(e,t,a,i,n)=>{const r=e.doc,s=r.clientID;_c(a,n);const o=Ac(e,t,a,n);e:for(;null!==a.right&&(i>0||o.size>0&&(a.right.deleted||a.right.content.constructor===Wc));){if(!a.right.deleted)switch(a.right.content.constructor){case Wc:{const{key:t,value:r}=a.right.content,s=n[t];if(void 0!==s){if(mc(s,r))o.delete(t);else{if(0===i)break e;o.set(t,r)}a.right.delete(e)}else a.currentAttributes.set(t,r);break}default:i<a.right.length&&vu(e,uu(a.right.id.client,a.right.id.clock+i)),i-=a.right.length}a.forward()}if(i>0){let n="";for(;i>0;i--)n+="\n";a.right=new rd(uu(s,fu(r.store,s)),a.left,a.left&&a.left.lastId,a.right,a.right&&a.right.id,t,null,new qc(n)),a.right.integrate(e,0),a.forward()}vc(e,t,a,o)},Nc=(e,t,a,i,n)=>{let r=t;const s=bs();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===Wc){const e=r.content;s.set(e.key,e)}r=r.right}let o=0,l=!1;for(;t!==r;){if(a===t&&(l=!0),!t.deleted){const a=t.content;switch(a.constructor){case Wc:{const{key:r,value:u}=a,c=i.get(r)??null;s.get(r)===a&&c!==u||(t.delete(e),o++,l||(n.get(r)??null)!==u||c===u||(null===c?n.delete(r):n.set(r,c))),l||t.deleted||wc(n,a);break}}}t=t.right}return o},Tc=e=>{let t=0;return Mu(e.doc,(a=>{let i=e._start,n=e._start,r=bs();const s=vs(r);for(;n;){if(!1===n.deleted)if(n.content.constructor===Wc)wc(s,n.content);else t+=Nc(a,i,n,r,s),r=vs(s),i=n;n=n.right}})),t},Mc=e=>{const t=new Set,a=e.doc;for(const[i,n]of e.afterState.entries()){const r=e.beforeState.get(i)||0;n!==r&&_u(e,a.store.clients.get(i),r,n,(e=>{e.deleted||e.content.constructor!==Wc||e.constructor===Bc||t.add(e.parent)}))}Mu(a,(a=>{Il(e,e.deleteSet,(e=>{if(e instanceof Bc||!e.parent._hasFormatting||t.has(e.parent))return;const i=e.parent;e.content.constructor===Wc?t.add(i):((e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const a=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Wc){const i=t.content.key;a.has(i)?t.delete(e):a.add(i)}t=t.left}})(a,e)}));for(const e of t)Tc(e)}))},xc=(e,t,a)=>{const i=a,n=vs(t.currentAttributes),r=t.right;for(;a>0&&null!==t.right;){if(!1===t.right.deleted)switch(t.right.content.constructor){case id:case zc:case qc:a<t.right.length&&vu(e,uu(t.right.id.client,t.right.id.clock+a)),a-=t.right.length,t.right.delete(e)}t.forward()}r&&Nc(e,r,t.right,n,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&Hu(s._searchMarker,t.index,-i+a),t};class Cc extends Ou{constructor(e,t,a){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,a.forEach((e=>{null===e?this.childListChanged=!0:this.keysChanged.add(e)}))}get changes(){if(null===this._changes){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(null===this._delta){const e=this.target.doc,t=[];Mu(e,(e=>{const a=new Map,i=new Map;let n=this.target._start,r=null;const s={};let o="",l=0,u=0;const c=()=>{if(null!==r){let e=null;switch(r){case"delete":u>0&&(e={delete:u}),u=0;break;case"insert":("object"==typeof o||o.length>0)&&(e={insert:o},a.size>0&&(e.attributes={},a.forEach(((t,a)=>{null!==t&&(e.attributes[a]=t)})))),o="";break;case"retain":l>0&&(e={retain:l},(e=>{for(const t in e)return!1;return!0})(s)||(e.attributes=Wo({},s))),l=0}e&&t.push(e),r=null}};for(;null!==n;){switch(n.content.constructor){case id:case zc:this.adds(n)?this.deletes(n)||(c(),r="insert",o=n.content.getContent()[0],c()):this.deletes(n)?("delete"!==r&&(c(),r="delete"),u+=1):n.deleted||("retain"!==r&&(c(),r="retain"),l+=1);break;case qc:this.adds(n)?this.deletes(n)||("insert"!==r&&(c(),r="insert"),o+=n.content.str):this.deletes(n)?("delete"!==r&&(c(),r="delete"),u+=n.length):n.deleted||("retain"!==r&&(c(),r="retain"),l+=n.length);break;case Wc:{const{key:t,value:o}=n.content;if(this.adds(n)){if(!this.deletes(n)){const l=a.get(t)??null;mc(l,o)?null!==o&&n.delete(e):("retain"===r&&c(),mc(o,i.get(t)??null)?delete s[t]:s[t]=o)}}else if(this.deletes(n)){i.set(t,o);const e=a.get(t)??null;mc(e,o)||("retain"===r&&c(),s[t]=e)}else if(!n.deleted){i.set(t,o);const a=s[t];void 0!==a&&(mc(a,o)?null!==a&&n.delete(e):("retain"===r&&c(),null===o?delete s[t]:s[t]=o))}n.deleted||("insert"===r&&c(),wc(a,n.content));break}}n=n.right}for(c();t.length>0;){const e=t[t.length-1];if(void 0===e.retain||void 0!==e.attributes)break;t.pop()}})),this._delta=t}return this._delta}}class Vc extends qu{constructor(e){super(),this._pending=void 0!==e?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Uu(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((e=>e()))}catch(e){console.error(e)}this._pending=null}_copy(){return new Vc}clone(){const e=new Vc;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const a=new Cc(this,e,t);Gu(this,e,a),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Uu();let e="",t=this._start;for(;null!==t;)!t.deleted&&t.countable&&t.content.constructor===qc&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){null!==this.doc?Mu(this.doc,(a=>{const i=new yc(null,this._start,0,new Map);for(let n=0;n<e.length;n++){const r=e[n];if(void 0!==r.insert){const s=t||"string"!=typeof r.insert||n!==e.length-1||null!==i.right||"\n"!==r.insert.slice(-1)?r.insert:r.insert.slice(0,-1);("string"!=typeof s||s.length>0)&&kc(a,this,i,s,r.attributes||{})}else void 0!==r.retain?Sc(a,this,i,r.retain,r.attributes||{}):void 0!==r.delete&&xc(a,i,r.delete)}})):this._pending.push((()=>this.applyDelta(e)))}toDelta(e,t,a){this.doc??Uu();const i=[],n=new Map,r=this.doc;let s="",o=this._start;function l(){if(s.length>0){const e={};let t=!1;n.forEach(((a,i)=>{t=!0,e[i]=a}));const a={insert:s};t&&(a.attributes=e),i.push(a),s=""}}const u=()=>{for(;null!==o;){if(cu(o,e)||void 0!==t&&cu(o,t))switch(o.content.constructor){case qc:{const i=n.get("ychange");void 0===e||cu(o,e)?void 0===t||cu(o,t)?void 0!==i&&(l(),n.delete("ychange")):void 0!==i&&i.user===o.id.client&&"added"===i.type||(l(),n.set("ychange",a?a("added",o.id):{type:"added"})):void 0!==i&&i.user===o.id.client&&"removed"===i.type||(l(),n.set("ychange",a?a("removed",o.id):{type:"removed"})),s+=o.content.str;break}case id:case zc:{l();const e={insert:o.content.getContent()[0]};if(n.size>0){const t={};e.attributes=t,n.forEach(((e,a)=>{t[a]=e}))}i.push(e);break}case Wc:cu(o,e)&&(l(),wc(n,o.content))}o=o.right}l()};return e||t?Mu(r,(a=>{e&&du(a,e),t&&du(a,t),u()}),"cleanup"):u(),i}insert(e,t,a){if(t.length<=0)return;const i=this.doc;null!==i?Mu(i,(i=>{const n=bc(i,this,e,!a);a||(a={},n.currentAttributes.forEach(((e,t)=>{a[t]=e}))),kc(i,this,n,t,a)})):this._pending.push((()=>this.insert(e,t,a)))}insertEmbed(e,t,a){const i=this.doc;null!==i?Mu(i,(i=>{const n=bc(i,this,e,!a);kc(i,this,n,t,a||{})})):this._pending.push((()=>this.insertEmbed(e,t,a||{})))}delete(e,t){if(0===t)return;const a=this.doc;null!==a?Mu(a,(a=>{xc(a,bc(a,this,e,!0),t)})):this._pending.push((()=>this.delete(e,t)))}format(e,t,a){if(0===t)return;const i=this.doc;null!==i?Mu(i,(i=>{const n=bc(i,this,e,!1);null!==n.right&&Sc(i,this,n,t,a)})):this._pending.push((()=>this.format(e,t,a)))}removeAttribute(e){null!==this.doc?Mu(this.doc,(t=>{rc(t,this,e)})):this._pending.push((()=>this.removeAttribute(e)))}setAttribute(e,t){null!==this.doc?Mu(this.doc,(a=>{sc(a,this,e,t)})):this._pending.push((()=>this.setAttribute(e,t)))}getAttribute(e){return oc(this,e)}getAttributes(){return lc(this)}_write(e){e.writeTypeRef(Xc)}}class Ic{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Uu()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(null!==e&&(!this._firstCall||e.deleted||!this._filter(t)))do{if(t=e.content.type,e.deleted||t.constructor!==Fc&&t.constructor!==Ec||null===t._start)for(;null!==e;){const t=e.next;if(null!==t){e=t;break}e=e.parent===this._root?null:e.parent._item}else e=t._start}while(null!==e&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,null===e?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Ec extends qu{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ec}clone(){const e=new Ec;return e.insert(0,this.toArray().map((e=>e instanceof qu?e.clone():e))),e}get length(){return this.doc??Uu(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(e){return new Ic(this,e)}querySelector(e){e=e.toUpperCase();const t=new Ic(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Ss(new Ic(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)))}_callObserver(e,t){Gu(this,e,new Dc(this,t,e))}toString(){return Xu(this,(e=>e.toString())).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},a){const i=e.createDocumentFragment();return void 0!==a&&a._createAssociation(i,this),Ku(this,(n=>{i.insertBefore(n.toDOM(e,t,a),null)})),i}insert(e,t){null!==this.doc?Mu(this.doc,(a=>{ic(a,this,e,t)})):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(null!==this.doc)Mu(this.doc,(a=>{const i=e&&e instanceof qu?e._item:e;tc(a,this,i,t)}));else{const a=this._prelimContent,i=null===e?0:a.findIndex((t=>t===e))+1;if(0===i&&null!==e)throw mo("Reference item not found");a.splice(i,0,...t)}}delete(e,t=1){null!==this.doc?Mu(this.doc,(a=>{nc(a,this,e,t)})):this._prelimContent.splice(e,t)}toArray(){return Ju(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ec(this,e)}slice(e=0,t=this.length){return Zu(this,e,t)}forEach(e){Ku(this,e)}_write(e){e.writeTypeRef(ed)}}class Fc extends Ec{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach(((e,t)=>{this.setAttribute(t,e)})),this._prelimAttrs=null}_copy(){return new Fc(this.nodeName)}clone(){const e=new Fc(this.nodeName);return((e,t)=>{for(const a in e)t(e[a],a)})(this.getAttributes(),((t,a)=>{"string"==typeof t&&e.setAttribute(a,t)})),e.insert(0,this.toArray().map((e=>e instanceof qu?e.clone():e))),e}toString(){const e=this.getAttributes(),t=[],a=[];for(const t in e)a.push(t);a.sort();const i=a.length;for(let n=0;n<i;n++){const i=a[n];t.push(i+'="'+e[i]+'"')}const n=this.nodeName.toLocaleLowerCase();return`<${n}${t.length>0?" "+t.join(" "):""}>${super.toString()}</${n}>`}removeAttribute(e){null!==this.doc?Mu(this.doc,(t=>{rc(t,this,e)})):this._prelimAttrs.delete(e)}setAttribute(e,t){null!==this.doc?Mu(this.doc,(a=>{sc(a,this,e,t)})):this._prelimAttrs.set(e,t)}getAttribute(e){return oc(this,e)}hasAttribute(e){return uc(this,e)}getAttributes(e){return e?((e,t)=>{const a={};return e._map.forEach(((e,i)=>{let n=e;for(;null!==n&&(!t.sv.has(n.id.client)||n.id.clock>=(t.sv.get(n.id.client)||0));)n=n.left;null!==n&&cu(n,t)&&(a[i]=n.content.getContent()[n.length-1])})),a})(this,e):lc(this)}toDOM(e=document,t={},a){const i=e.createElement(this.nodeName),n=this.getAttributes();for(const e in n){const t=n[e];"string"==typeof t&&i.setAttribute(e,t)}return Ku(this,(n=>{i.appendChild(n.toDOM(e,t,a))})),void 0!==a&&a._createAssociation(i,this),i}_write(e){e.writeTypeRef(Qc),e.writeKey(this.nodeName)}}class Dc extends Ou{constructor(e,t,a){super(e,a),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((e=>{null===e?this.childListChanged=!0:this.attributesChanged.add(e)}))}}class Rc extends fc{constructor(e){super(),this.hookName=e}_copy(){return new Rc(this.hookName)}clone(){const e=new Rc(this.hookName);return this.forEach(((t,a)=>{e.set(a,t)})),e}toDOM(e=document,t={},a){const i=t[this.hookName];let n;return n=void 0!==i?i.createDom(this):document.createElement(this.hookName),n.setAttribute("data-yjs-hook",this.hookName),void 0!==a&&a._createAssociation(n,this),n}_write(e){e.writeTypeRef(td),e.writeKey(this.hookName)}}class Pc extends Vc{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Pc}clone(){const e=new Pc;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,a){const i=e.createTextNode(this.toString());return void 0!==a&&a._createAssociation(i,this),i}toString(){return this.toDelta().map((e=>{const t=[];for(const a in e.attributes){const i=[];for(const t in e.attributes[a])i.push({key:t,value:e.attributes[a][t]});i.sort(((e,t)=>e.key<t.key?-1:1)),t.push({nodeName:a,attrs:i})}t.sort(((e,t)=>e.nodeName<t.nodeName?-1:1));let a="";for(let e=0;e<t.length;e++){const i=t[e];a+=`<${i.nodeName}`;for(let e=0;e<i.attrs.length;e++){const t=i.attrs[e];a+=` ${t.key}="${t.value}"`}a+=">"}a+=e.insert;for(let e=t.length-1;e>=0;e--)a+=`</${t[e].nodeName}>`;return a})).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ad)}}class Lc{constructor(e,t){this.id=e,this.length=t}get deleted(){throw yo()}mergeWith(e){return!1}write(e,t,a){throw yo()}integrate(e,t){throw yo()}}class Bc extends Lc{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),mu(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Oc{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Oc(this.content)}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class $c{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new $c(this.len)}splice(e){const t=new $c(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Dl(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const Uc=(e,t)=>new $l({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class jc{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),null!==e.meta&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new jc(Uc(this.doc.guid,this.opts))}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}class zc{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new zc(this.embed)}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class Wc{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Wc(this.key,this.value)}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){const a=t.parent;a._searchMarker=null,a._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}class Yc{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Yc(this.arr)}splice(e){const t=new Yc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const a=this.arr.length;e.writeLen(a-t);for(let i=t;i<a;i++){const t=this.arr[i];e.writeString(void 0===t?"undefined":JSON.stringify(t))}}getRef(){return 2}}const Hc="development"===rl("node_env");class Gc{constructor(e){this.arr=e,Hc&&Jo(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Gc(this.arr)}splice(e){const t=new Gc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const a=this.arr.length;e.writeLen(a-t);for(let i=t;i<a;i++){const t=this.arr[i];e.writeAny(t)}}getRef(){return 8}}class qc{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new qc(this.str)}splice(e){const t=new qc(this.str.slice(e));this.str=this.str.slice(0,e);const a=this.str.charCodeAt(e-1);return a>=55296&&a<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(0===t?this.str:this.str.slice(t))}getRef(){return 4}}const Zc=[e=>new pc,e=>new fc,e=>new Vc,e=>new Fc(e.readKey()),e=>new Ec,e=>new Rc(e.readKey()),e=>new Pc],Jc=0,Kc=1,Xc=2,Qc=3,ed=4,td=5,ad=6;class id{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new id(this.type._copy())}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;null!==t;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach((t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)})),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;null!==t;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((t=>{for(;null!==t;)t.gc(e,!0),t=t.left})),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const nd=(e,t,a)=>{const{client:i,clock:n}=t.id,r=new rd(uu(i,n+a),t,uu(i,n+a-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(a));return t.deleted&&r.markDeleted(),t.keep&&(r.keep=!0),null!==t.redone&&(r.redone=uu(t.redone.client,t.redone.clock+a)),t.right=r,null!==r.right&&(r.right.left=r),e._mergeStructs.push(r),null!==r.parentSub&&null===r.right&&r.parent._map.set(r.parentSub,r),t.length=a,r};class rd extends Lc{constructor(e,t,a,i,n,r,s,o){super(e,o.getLength()),this.origin=a,this.left=t,this.right=i,this.rightOrigin=n,this.parent=r,this.parentSub=s,this.redone=null,this.content=o,this.info=this.content.isCountable()?2:0}set marker(e){(8&this.info)>0!==e&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=fu(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=fu(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ou&&this.id.client!==this.parent.client&&this.parent.clock>=fu(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=wu(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=vu(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Bc||this.right&&this.right.constructor===Bc)this.parent=null;else if(this.parent){if(this.parent.constructor===ou){const e=gu(t,this.parent);e.constructor===Bc?this.parent=null:this.parent=e.content.type}}else this.left&&this.left.constructor===rd?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===rd&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wu(e,e.doc.store,uu(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let t,a=this.left;if(null!==a)t=a.right;else if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start;const i=new Set,n=new Set;for(;null!==t&&t!==this.right;){if(n.add(t),i.add(t),lu(this.origin,t.origin)){if(t.id.client<this.id.client)a=t,i.clear();else if(lu(this.rightOrigin,t.rightOrigin))break}else{if(null===t.origin||!n.has(gu(e.doc.store,t.origin)))break;i.has(gu(e.doc.store,t.origin))||(a=t,i.clear())}t=t.right}this.left=a}if(null!==this.left){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(e)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),mu(e.doc.store,this),this.content.integrate(e,this),Su(e,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(e)}else new Bc(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;null!==e&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;null!==e&&e.deleted;)e=e.left;return e}get lastId(){return 1===this.length?this.id:uu(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&lu(e.origin,this.lastId)&&this.right===e&&lu(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&null===this.redone&&null===e.redone&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach((t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))})),e.keep&&(this.keep=!0),this.right=e.right,null!==this.right&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&null===this.parentSub&&(t._length-=this.length),this.markDeleted(),Dl(e.deleteSet,this.id.client,this.id.clock,this.length),Su(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw go();this.content.gc(e),t?((e,t,a)=>{const i=e.clients.get(t.id.client);i[yu(i,t.id.clock)]=a})(e,this,new Bc(this.id,this.length)):this.content=new $c(this.length)}write(e,t){const a=t>0?uu(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,n=this.parentSub,r=31&this.content.getRef()|(null===a?0:Rs)|(null===i?0:Ds)|(null===n?0:32);if(e.writeInfo(r),null!==a&&e.writeLeftID(a),null!==i&&e.writeRightID(i),null===a&&null===i){const t=this.parent;if(void 0!==t._item){const a=t._item;if(null===a){const a=(e=>{for(const[t,a]of e.doc.share.entries())if(a===e)return t;throw go()})(t);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===ou?(e.writeParentInfo(!1),e.writeLeftID(t)):go();null!==n&&e.writeString(n)}this.content.write(e,t)}}const sd=(e,t)=>od[31&t](e),od=[()=>{go()},e=>new $c(e.readLen()),e=>{const t=e.readLen(),a=[];for(let i=0;i<t;i++){const t=e.readString();"undefined"===t?a.push(void 0):a.push(JSON.parse(t))}return new Yc(a)},e=>new Oc(e.readBuf()),e=>new qc(e.readString()),e=>new zc(e.readJSON()),e=>new Wc(e.readKey(),e.readJSON()),e=>new id(Zc[e.readTypeRef()](e)),e=>{const t=e.readLen(),a=[];for(let i=0;i<t;i++)a.push(e.readAny());return new Gc(a)},e=>new jc(Uc(e.readString(),e.readAny())),()=>{go()}];class ld extends Lc{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){go()}write(e,t){e.writeInfo(10),Xs(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const ud="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},cd="__ $YJS$ __";!0===ud[cd]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),ud[cd]=!0;const dd=new Map;const pd="undefined"==typeof BroadcastChannel?class{constructor(e){var t;this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&null!==this.onmessage&&this.onmessage({data:dl(t.newValue||"")}),t=this._onChange,jo||addEventListener("storage",t)}postMessage(e){zo.setItem(this.room,cl(new Uint8Array(e)))}close(){var e;e=this._onChange,jo||removeEventListener("storage",e)}}:BroadcastChannel,hd=e=>ws(dd,e,(()=>{const t=_s(),a=new pd(e);return a.onmessage=e=>t.forEach((t=>t(e.data,"broadcastchannel"))),{bc:a,subs:t}})),fd=(e,t,a=null)=>{const i=hd(e);i.bc.postMessage(t),i.subs.forEach((e=>e(t,a)))},md=(e,t)=>{Xs(e,0);const a=(e=>tu(e,new Yl))(t);no(e,a)},yd=(e,t,a)=>{Xs(e,1),no(e,((e,t)=>Xl(e,t,new Hl))(t,a))},gd=(e,t,a)=>{try{((e,t,a)=>{Kl(e,t,a,jl)})(t,Ao(e),a)}catch(e){console.error("Caught error while handling a Yjs update",e)}},bd=gd,vd=(e,t,a,i)=>{const n=So(e);switch(n){case 0:((e,t,a)=>{yd(t,a,Ao(e))})(e,t,a);break;case 1:gd(e,a,i);break;case 2:bd(e,a,i);break;default:throw new Error("Unknown message type")}return n},wd=3e4;class _d extends Ms{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const e=Bo();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const t=[];this.meta.forEach(((a,i)=>{i!==this.clientID&&wd<=e-a.lastUpdated&&this.states.has(i)&&t.push(i)})),t.length>0&&Ad(this,t,"timeout")}),xs(3e3)),e.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,a=this.meta.get(t),i=void 0===a?0:a.clock+1,n=this.states.get(t);null===e?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:Bo()});const r=[],s=[],o=[],l=[];null===e?l.push(t):null==n?null!=e&&r.push(t):(s.push(t),el(n,e)||o.push(t)),(r.length>0||o.length>0||l.length>0)&&this.emit("change",[{added:r,updated:o,removed:l},"local"]),this.emit("update",[{added:r,updated:s,removed:l},"local"])}setLocalStateField(e,t){const a=this.getLocalState();null!==a&&this.setLocalState({...a,[e]:t})}getStates(){return this.states}}const Ad=(e,t,a)=>{const i=[];for(let a=0;a<t.length;a++){const n=t[a];if(e.states.has(n)){if(e.states.delete(n),n===e.clientID){const t=e.meta.get(n);e.meta.set(n,{clock:t.clock+1,lastUpdated:Bo()})}i.push(n)}}i.length>0&&(e.emit("change",[{added:[],updated:[],removed:i},a]),e.emit("update",[{added:[],updated:[],removed:i},a]))},kd=(e,t,a=e.states)=>{const i=t.length,n=Gs();Xs(n,i);for(let r=0;r<i;r++){const i=t[r],s=a.get(i)||null,o=e.meta.get(i).clock;Xs(n,i),Xs(n,o),ao(n,JSON.stringify(s))}return Zs(n)},Sd=[];Sd[0]=(e,t,a,i,n)=>{Xs(e,0);const r=vd(t,e,a.doc,a);i&&1===r&&!a.synced&&(a.synced=!0)},Sd[3]=(e,t,a,i,n)=>{Xs(e,1),no(e,kd(a.awareness,Array.from(a.awareness.getStates().keys())))},Sd[1]=(e,t,a,i,n)=>{((e,t,a)=>{const i=_o(t),n=Bo(),r=[],s=[],o=[],l=[],u=So(i);for(let t=0;t<u;t++){const t=So(i);let a=So(i);const u=JSON.parse(To(i)),c=e.meta.get(t),d=e.states.get(t),p=void 0===c?0:c.clock;(p<a||p===a&&null===u&&e.states.has(t))&&(null===u?t===e.clientID&&null!=e.getLocalState()?a++:e.states.delete(t):e.states.set(t,u),e.meta.set(t,{clock:a,lastUpdated:n}),void 0===c&&null!==u?r.push(t):void 0!==c&&null===u?l.push(t):null!==u&&(el(u,d)||o.push(t),s.push(t)))}(r.length>0||o.length>0||l.length>0)&&e.emit("change",[{added:r,updated:o,removed:l},a]),(r.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:r,updated:s,removed:l},a])})(a.awareness,Ao(t),a)},Sd[2]=(e,t,a,i,n)=>{((e,t,a)=>{0===So(e)&&a(t,To(e))})(t,a.doc,((e,t)=>Nd(a,t)))};const Nd=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),Td=(e,t,a)=>{const i=_o(t),n=Gs(),r=So(i),s=e.messageHandlers[r];return s?s(n,i,e,a,r):console.error("Unable to compute message"),n},Md=(e,t,a)=>{t===e.ws&&(e.emit("connection-close",[a,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,Ad(e.awareness,Array.from(e.awareness.getStates().keys()).filter((t=>t!==e.doc.clientID)),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(xd,Vs(100*Es(2,e.wsUnsuccessfulReconnects),e.maxBackoffTime),e))},xd=e=>{if(e.shouldConnect&&null===e.ws){const t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=a=>{e.wsLastMessageReceived=Bo();const i=Td(e,new Uint8Array(a.data),!0);qs(i)>1&&t.send(Zs(i))},t.onerror=t=>{e.emit("connection-error",[t,e])},t.onclose=a=>{Md(e,t,a)},t.onopen=()=>{e.wsLastMessageReceived=Bo(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const a=Gs();if(Xs(a,0),md(a,e.doc),t.send(Zs(a)),null!==e.awareness.getLocalState()){const a=Gs();Xs(a,1),no(a,kd(e.awareness,[e.doc.clientID])),t.send(Zs(a))}},e.emit("status",[{status:"connecting"}])}},Cd=(e,t)=>{const a=e.ws;e.wsconnected&&a&&a.readyState===a.OPEN&&a.send(t),e.bcconnected&&fd(e.bcChannel,t,e)};class Vd extends Ts{constructor(e,t,a,{connect:i=!0,awareness:n=new _d(a),params:r={},protocols:s=[],WebSocketPolyfill:o=WebSocket,resyncInterval:l=-1,maxBackoffTime:u=2500,disableBc:c=!1}={}){for(super();"/"===e[e.length-1];)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=u,this.params=r,this.protocols=s,this.roomname=t,this.doc=a,this._WS=o,this.awareness=n,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=c,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Sd.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=i,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval((()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=Gs();Xs(e,0),md(e,a),this.ws.send(Zs(e))}}),l)),this._bcSubscriber=(e,t)=>{if(t!==this){const t=Td(this,new Uint8Array(e),!1);qs(t)>1&&fd(this.bcChannel,Zs(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){const t=Gs();Xs(t,0),((e,t)=>{Xs(e,2),no(e,t)})(t,e),Cd(this,Zs(t))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:a},i)=>{const r=e.concat(t).concat(a),s=Gs();Xs(s,1),no(s,kd(n,r)),Cd(this,Zs(s))},this._exitHandler=()=>{Ad(this.awareness,[a.clientID],"app closed")},tl&&void 0!==gs&&gs.on("exit",this._exitHandler),n.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval((()=>{this.wsconnected&&3e4<Bo()-this.wsLastMessageReceived&&Md(this,this.ws,null)}),3e3),i&&this.connect()}get url(){const e=(e=>((e,t)=>{const a=[];for(const i in e)a.push(t(e[i],i));return a})(e,((e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`)).join("&"))(this.params);return this.serverUrl+"/"+this.roomname+(0===e.length?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){0!==this._resyncInterval&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),tl&&void 0!==gs&&gs.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;var e,t;this.bcconnected||(e=this.bcChannel,t=this._bcSubscriber,hd(e).subs.add(t),this.bcconnected=!0);const a=Gs();Xs(a,0),md(a,this.doc),fd(this.bcChannel,Zs(a),this);const i=Gs();Xs(i,0),yd(i,this.doc),fd(this.bcChannel,Zs(i),this);const n=Gs();Xs(n,3),fd(this.bcChannel,Zs(n),this);const r=Gs();Xs(r,1),no(r,kd(this.awareness,[this.doc.clientID])),fd(this.bcChannel,Zs(r),this)}disconnectBc(){const e=Gs();Xs(e,1),no(e,kd(this.awareness,[this.doc.clientID],new Map)),Cd(this,Zs(e)),this.bcconnected&&(((e,t)=>{const a=hd(e),i=a.subs.delete(t);i&&0===a.subs.size&&(a.bc.close(),dd.delete(e))})(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),null!==this.ws&&Md(this,this.ws,null)}connect(){this.shouldConnect=!0,this.wsconnected||null!==this.ws||(xd(this),this.connectBc())}}class Id extends $l{}class Ed{apiClient;collabDocument;yWebsocketProvider;item;awareness;users=[];avatars=new Map;constructor(e){this.apiClient=e,this.collabDocument=new Id}isActive(){return void 0!==this.yWebsocketProvider}getAwarenessStates(){return this.awareness?this.awareness.getStates():new Map}getUsersList(){return this.users}_getUser(e){for(const t of this.users)if(e===t.key)return t;return null}getLocalState(){if(!this.awareness)throw new Error("No awareness available. Cannot get state field.");return this.awareness.getLocalState()}setLocalStateField(e,t){if(!this.awareness)throw new Error("No awareness available. Cannot set state field.");this.awareness.setLocalStateField(e,t)}async _updateUsersList(){const e=this.getAwarenessStates(),t=await this.apiClient.me(!0);for(const[a,i]of e.entries()){if(!this._getUser(a)){let e=this.avatars.get(i.user.id);if(!e){e=(await this.apiClient.getAvatar(i.user.id,32)).avatar,this.avatars.set(i.user.id,e)}this.users.push({key:a,id:i.user.id,name:i.user.name,color:i.user.color,avatar:e,itsMe:i.user.id===t._id})}}const a=[];for(const t of this.users)e.has(t.key)&&a.push(t);this.users=a}async startCollaboration(e){try{if(!this.apiClient.isDevOrLocalhost())return!1;this.endCollaboration(),this.item=e;const t=this.apiClient.getCollabUrl(),a=`${this.item.type}.${this.item._id}`;let i=1e3;this.yWebsocketProvider=new Vd(t,a,this.collabDocument,{connect:!1}),this.yWebsocketProvider.on("status",(e=>{console.log(`[Collab] ${e.status}`),"disconnected"===e.status&&this.yWebsocketProvider&&(this.yWebsocketProvider.disconnect(),setTimeout(r,i))})),this.yWebsocketProvider.on("sync",(e=>{console.log(`[Collab] synced: ${e}`)})),this.awareness=this.yWebsocketProvider.awareness,this.awareness.on("change",(async e=>{await this._updateUsersList(),u.$emit("collab:awareness:changed",{users:this.users,states:this.getAwarenessStates(),changes:e})}));const n=await this.apiClient.me(!0);this.awareness.setLocalStateField("user",{id:n._id,name:n.name,color:h.colorFromString(n.name)});const r=async()=>{if(!this.yWebsocketProvider)return void console.warn("[Collab] Cannot connect without websocket provider!");console.log("[Collab] reconnecting...");const e=await this.apiClient.getCollabToken();this.yWebsocketProvider.params.token=e,this.yWebsocketProvider.connect()};return await r(),u.$emit("collab:started"),!0}catch(e){return console.error("Error starting collaboration: ",e),!1}}endCollaboration(){this.yWebsocketProvider&&(console.log("Ending collaboration."),u.$emit("collab:ended"),this.yWebsocketProvider.destroy(),this.yWebsocketProvider=void 0,this.awareness=void 0),this.collabDocument=new Id,this.item=void 0}}class Fd{apiClient;constructor(e){this.apiClient=e}async testCopyItems(e,t){const a=await this.apiClient.getItemsInFolderList(t,!0),i=await this.apiClient.getFoldersInFolderList(t),n=new Map;for(const e of i.children)n.set(e.name,null);for(const e of a)n.set(e.name,e._id);const r=this.apiClient.getItemRepo(),s=[];for(const t of e){let e,a,i=!1;t.isFolder?a=await this.apiClient.getFolder(t._id):(a=r.getLoadedItem(t._id),a||(a=await this.apiClient.getItem(t._id))),e=a?.name,i=n.has(e),s.push({_id:t._id,isFolder:t.isFolder,data:a,name:e,conflicted:i,conflictedItemId:n.get(e)})}return s}async copyItems(e,t,a=!1,i=!1){const n=e.filter((e=>!e.isFolder)).map((e=>e._id)),r=await this.apiClient.copyItems(n,t,a,i),s=this.apiClient.getItemRepo();for(let t of r){const a=e.filter((e=>e._id===t.original));a.length>0&&(t.replaced=a[0].conflictedItemId),await s.replaceLink(t.original,t.clone)}return await this.apiClient.eventBus.$emit("folder:changed",t),await this.apiClient.eventBus.$emit("items:copied",r),r}}class Dd{apiClient;jobManager;constructor(e){this.apiClient=e,this.jobManager=e.getJobManager()}async executeExport(e,t,a,i){const n=await this.jobManager.execute("EXPORT:ExportGame",[{_id:e,isFolder:!1}],[{name:"Destination Folder",value:a},{name:"EngineVersion",value:i}],void 0,{os:t});if(await this.apiClient.eventBus.$emit("quota:update"),2===n.state)throw new A("Export failed: "+n.error);await this.apiClient.eventBus.$emit("folder:changed",[a])}}(i.default?i.default:i)(a,{retries:3,retryCondition:e=>e.message.includes("net::ERR_NETWORK_CHANGED")});const Rd={Draft:0,Private:1,NotListed:2,Public:3};e.AccessDeniedException=N,e.AggregatedItem=M,e.ApiClient=class extends l{accessToken;apiToken;options;forcePublicApi;usePublicApi;usePersistentStorage;storageSizeMib;requestClientId;webProtocol;wsProtocol;viewerProtocol;collabProtocol;restUrl;wsUrl;viewerUrl;collabUrl;itemRepo;itemCache;folderCache;thumbCache;userCache;groupCache;attachmentCache;jobManager;serializer;collab;itemCopier;executableExporter;eventBus;api;ws;cachedMe;profiler;wsLastPing;last2faCode="";constructor(e={}){super(),e=e||{},this.options=Object.assign({host:"auto",viewerHost:"auto",collabHost:"auto",https:!0,path:"",websocketPath:"/api/ws",wsAutoReconnect:!0,wsAutoConnect:!1,forcePublicApi:!1,debug:!1,accessToken:null,apiToken:null,viewerHttps:!1,collabHttps:!1,usePersistentStorage:!0,storageSizeMib:10240,requestClientId:null},e);const t=this.isOnLocalhost(),i=this.isDevPlatform();"auto"===this.options.host&&(this.options.host="api.lumino.cloud",this.options.https=!0,"object"==typeof window&&"location"in window&&(i?(this.options.host="api-dev.lumino.cloud",this.options.https=!0):t&&(this.options.host="localhost:8081",this.options.https=!1))),"auto"===this.options.viewerHost&&(this.options.viewerHost="viewer.lumino.cloud",this.options.viewerHttps=!0,"object"==typeof window&&"location"in window&&(i?(this.options.viewerHost="viewer-dev.lumino.cloud",this.options.viewerHttps=!0):t&&(this.options.viewerHost="localhost:8090",this.options.viewerHttps=!1))),"auto"===this.options.collabHost&&(this.options.collabHost="collab.lumino.cloud",this.options.collabHttps=!0,"object"==typeof window&&"location"in window&&(i?(this.options.collabHost="collab-dev.lumino.cloud",this.options.collabHttps=!0):t&&(this.options.collabHost="localhost:8200",this.options.collabHttps=!1))),this.accessToken=this.options.accessToken,this.apiToken=this.options.apiToken,this.forcePublicApi=this.options.forcePublicApi,this.usePublicApi=!this.accessToken&&!this.apiToken,this.usePersistentStorage=this.options.usePersistentStorage,this.storageSizeMib=this.options.storageSizeMib,this.requestClientId=this.options.requestClientId,this.cachedMe=null,this.itemRepo=new jn(this.usePublicApi,this),this.itemCache=new Fr(this.usePublicApi,this.usePersistentStorage,this,this.storageSizeMib),this.folderCache=new Dr(this),this.thumbCache=new Rr(this),this.userCache=new Pr(this),this.groupCache=new Lr(this),this.attachmentCache=new Br(this),this.jobManager=new Ur(this),this.serializer=new Gr(this),this.collab=new Ed(this),this.itemCopier=new Fd(this),this.executableExporter=new Dd(this),this.eventBus=u,this.profiler=null,this.webProtocol=this.options.https?"https":"http",this.restUrl=`${this.webProtocol}://${this.options.host}${this.options.path}`,this.wsProtocol=this.options.https?"wss":"ws",this.wsUrl=`${this.wsProtocol}://${this.options.host}${this.options.websocketPath}`,this.viewerProtocol=this.options.viewerHttps?"https":"http",this.viewerUrl=`${this.viewerProtocol}://${this.options.viewerHost}`,this.collabProtocol=this.options.collabHttps?"wss":"ws",this.collabUrl=`${this.collabProtocol}://${this.options.collabHost}`,this.api=a.create({baseURL:this.restUrl}),this.ws=null,this.wsLastPing=null,this.setDebugMode(this.options.debug)}async initCaches(){return Promise.all([this.itemCache.init(),this.folderCache.init(),this.thumbCache.init()])}clearCaches(){this.itemCache.clear(),this.folderCache.clear(),this.thumbCache.clear()}isDevPlatform(){return"object"==typeof window&&"location"in window&&window.location.href.includes("dev.lumino.cloud")}isOnLocalhost(){return"object"==typeof window&&"location"in window&&window.location.href.includes("localhost")}isDevOrLocalhost(){return this.isOnLocalhost()||this.isDevPlatform()}async clearIndexedDb(e){return new Promise(((t,a)=>{const i=indexedDB.deleteDatabase(e);i.onsuccess=()=>{t()},i.onerror=e=>{a("An error occured while deleting a IndexedDB database.")},i.onblocked=()=>{a(`Database deletion is blocked. Please close all connections to "${e}".`)}}))}async logout(){return this.clearCaches(),this.clearIndexedDb("lumino")}setDebugMode(e){this.options.debug=!!e,this.eventBus.setDebugMode(this.options.debug)}websocketConnect(e){const t=this;if(this.ws){if(!e)return void console.warn("Websocket is already connected!");this.websocketDisconnect()}this.ws=new n(this.wsUrl),this.ws.onerror=function(e){console.error("Websocket error",e),t.$emit("client:websocketError",e)},this.ws.onopen=function(){t.$emit("client:websocketOpen"),t.accessToken&&t.websocketSend(JSON.stringify({type:"auth",subscriptions:["item","folder","job","user","notification"],token:t.accessToken}))},this.ws.onclose=function(){t.$emit("client:websocketClosed"),t.options.wsAutoReconnect&&t.websocketConnect(!0)},this.ws.onmessage=function(e){try{const a=JSON.parse(e.data);switch(a.type){case"ping":t.wsLastPing=new Date,t.ws&&t.ws.send(JSON.stringify({type:"ping"}));break;case"authenticated":t.$emit("client:websocketAuthenticated");break;case"Item":case"Folder":case"Notification":case"Job":case"User":u.$emit("client:elementUpdate",a);break;default:console.warn("Unknown websocket message: ",a)}}catch(e){console.error("Websocket error:",e)}}}websocketDisconnect(){this.ws&&(this.ws.close(),this.ws=null)}websocketSend(e){this.ws?1===this.ws.readyState?this.ws.send(e):console.error("Websocket is not in READY state. Currently in state "+this.ws.readyState):console.error("Websocket is not created")}getItemCopier(){return this.itemCopier}getExecutableExporter(){return this.executableExporter}getCollab(){return this.collab}getCollabUrl(){return this.collabUrl}getPublisher(){return new Or(this)}getAssetCreator(){return new Hr(this)}getJobManager(){return this.jobManager}getThumbCache(){return this.thumbCache}getItemCache(){return this.itemCache}getItemRepo(){return this.itemRepo}getRootVisibility(){return this.itemRepo.activeItem?this.itemRepo.activeItem.visibility:Rd.Private}getEventBus(){return this.eventBus}getSerializer(){return this.serializer}setForcePublicApi(e){this.forcePublicApi=e,this._updateUsePublicApi()}_updateUsePublicApi(){this.usePublicApi=this.forcePublicApi||!this.apiToken&&!this.accessToken,this.itemRepo.usePublicApi=this.usePublicApi,this.itemCache.usePublicApi=this.usePublicApi}setApiToken(e){this.apiToken=e,this._updateUsePublicApi()}setAccessToken(e){this.accessToken=e,this._updateUsePublicApi(),this.accessToken&&this.options.wsAutoConnect&&this.websocketConnect()}getApiToken(){return this.apiToken}getAccessToken(){return this.accessToken}updateBaseUrl(e){this.options.host=e,this.webProtocol=this.options.https?"https":"http";const t=`${this.webProtocol}://${this.options.host}${this.options.path}`;this.setApiBaseUrl(t),this.wsProtocol=this.options.https?"wss":"ws";const a=`${this.wsProtocol}://${this.options.host}${this.options.websocketPath}`;this.setWsBaseUrl(a)}setApiBaseUrl(e){this.restUrl=e,this.api=a.create({baseURL:this.restUrl})}setWsBaseUrl(e){this.wsUrl=e,this.accessToken&&this.options.wsAutoConnect&&(this.websocketDisconnect(),this.websocketConnect())}setRequestClientId(e){this.requestClientId=e}getApiBaseUrl(){return this.restUrl}getWsBaseUrl(){return this.wsUrl}getViewerBaseUrl(){return this.viewerUrl}setProfiler(e){if(!e||"function"!=typeof e.start)throw new Error("Profiler needs to be an object providing a start function.");this.profiler=e}async login2FA(e,t,a){return console.log("Running Login..."),this.execute("post","/api/auth/login2fa",{account:e,password:t,client:a}).then((e=>{this.last2faCode=e,this.eventBus.$emit("login.2facode",e)}))}async confirm2FA(e,t){return this.execute("post","/api/auth/confirm2fa",{account:e,code:t})}isAuthenticated(){return!!this.accessToken||!!this.apiToken}isFeatureEnabled(e){return!!this.cachedMe&&this.cachedMe.features.includes(e)}async resolveUserOrGroupInfoForItem(e){return e.quotaUser?this.userCache.resolve(e.quotaUser):e.quotaGroup?this.groupCache.resolve(e.quotaGroup):e.createdBy?this.userCache.resolve(e.createdBy):{name:"?",initials:"?",avatar:null}}_startOp(e){const t=this,a={id:h.createGUID(),name:e,startTimeMs:performance.now(),runningMs:0,percent:0,reportProgress:function(e){a.percent=e},interval:null,finish:function(){if(a.interval&&clearInterval(a.interval),a.runningMs>1e3)try{t.$emit("client:longRunningOpFinished",a.id)}catch(e){console.error(e)}}};return a.interval=setInterval((function(){if(a.runningMs=performance.now()-a.startTimeMs,a.runningMs>1e3)try{t.$emit("client:longRunningOp",a.id,a.name,a.percent)}catch(e){console.error(e)}}),100),a}_createOpName(e,t){try{const a=t.split("/");switch(e.toLowerCase()){case"get":e="Fetching";break;case"post":e="Creating";break;case"put":e="Updating";break;case"delete":e="Deleting"}a.shift(),a.shift();const i=a.shift();let n=a.join("/");return n.length&&(n=` [${n}]`),`${e} ${i} data ${n}`}catch{return`${e} ${t}`}}addAuthenticationHeaders(e){this.accessToken&&(e["x-access-token"]=this.accessToken),this.apiToken&&(e["x-api-token"]=this.apiToken),this.requestClientId&&(e["x-request-client"]=this.requestClientId)}async execute(e,t,a,i){let n=this,r={};(i=i||{}).headers?r=i.headers:a&&"object"==typeof a&&"getHeaders"in a&&"function"==typeof a.getHeaders&&(r=a.getHeaders()),this.addAuthenticationHeaders(r);const s=this.profiler?this.profiler.start("ApiClient",`${e} ${t}`):null,o=this._startOp(i.opName||n._createOpName(e,t));return this.api({method:e,url:t,data:a,responseType:i.responseType,headers:r,signal:i.controller?i.controller.signal:void 0,onUploadProgress:function(e){if(e.total){const t=Math.min(100,Math.round(100*e.loaded/e.total));o.reportProgress(t),n.$emit("client:progress",{type:"upload",percent:t}),"function"==typeof i.progressCallback&&i.progressCallback(t,e.loaded,e.total)}},onDownloadProgress:function(e){if(e.total){const t=Math.min(100,Math.round(100*e.loaded/e.total));o.reportProgress(t),n.$emit("client:progress",{type:"download",percent:t}),"function"==typeof i.progressCallback&&i.progressCallback(t,e.loaded,e.total)}}}).then((e=>{if(s&&s.done(),o.finish(),n.$emit("client:progress",{type:"done"}),e.headers["content-type"].startsWith("application/json")){if("success"===e.data.result){let t;return t=i.withNext?{data:e.data.data,next:e.data.next}:e.data.data,i.emitOnSuccess&&this.eventBus.$emit(i.emitOnSuccess,t),t}throw e.data.redirect&&this.$emit("client:redirect",e.data.redirect),e.data.error?e.data.error:"API response seems to be json but does not contain result type!"}return i.emitOnSuccess&&this.eventBus.$emit(i.emitOnSuccess),{blob:new Blob([e.data],{type:e.headers["content-type"]}),hash:e.headers["sha256-hash"],itemName:e.headers["lumino-itemname"],itemType:e.headers["lumino-itemtype"],mimeType:e.headers["content-type"]}})).catch((e=>{if(s&&s.done(),o.finish(),n.$emit("client:progress",{type:"done"}),e.response){if(401===e.response.status)throw this.$emit("client:unauthorized"),new N("Access denied. Please login again.");if(413===e.response.status)throw new S;if(e.response.data&&e.response.data.error)throw new Error(e.response.data.error)}throw e}))}_createFormData(e,t){let a=new r;if("function"==typeof File&&e instanceof Blob)a.append("file",e,t);else{const i=new Blob([e]);try{a.append("file",i,t)}catch{a=new r,a.append("file",e,t)}}return a}async me(e){return e&&this.cachedMe||(this.cachedMe=await this.execute("get","/api/auth/me")),this.cachedMe}async getHomeFolder(){return this.execute("get","/api/auth/homefolder")}async myClients(){return this.execute("get","/api/auth/myclients")}async getCollabToken(){return this.execute("get","/api/auth/collabtoken")}async checkCollabToken(e){return this.execute("post","/api/auth/collabtoken",{token:e})}async register(e){return this.execute("post","/api/auth/register",e)}async deleteMyAccount(e){return this.execute("post","/api/auth/deletemyaccount",{password:e})}async confirmEmail(e){return this.execute("get","/api/auth/confirmemail/"+e)}async confirmEmailChange(e){return this.execute("get","/api/auth/confirmchangedemail/"+e)}async forgotPassword(e,t){return this.execute("post","/api/auth/forgotpassword",{account:e,client:t})}async setNewPassword(e,t){return this.execute("post","/api/auth/setnewpassword",{token:e,password:t})}async accountExists(e){return this.execute("post","/api/auth/accountExists",e)}async getItemsInFolderList(e,t=!1){if(e&&!t){const t=await this.folderCache.getItemListing(e);if(t)return t}const a=await this.execute("get","/api/item/infolder/"+(e||"0"));return await this.folderCache.addItemListing(e,a),a}async getItem(e,t){const a=[];t&&(t.returnClonedFrom&&a.push("returnClonedFrom=true"),t.withThumbnails&&a.push("withThumbnails=true"));let i="";return a.length&&(i=`?${a.join("&")}`),this.execute("get",`/api/item/${e}${i}`)}getItemAggregatedPOP(e,t){return this.usePublicApi?this.getItemPublicAggregated(e,t):this.getItemAggregated(e,t)}async getItemPublicAggregated(e,t){const a=En(e);if(a)return a;const i=[];t&&(t.withFieldInstances&&i.push("withFieldInstances"),t.withAttachmentInfo&&i.push("withAttachmentInfo"),t.noAttributes&&i.push("noAttributes"),t.noUserAttributes&&i.push("noUserAttributes"),t.noFields&&i.push("noFields"),t.noThumbnails&&i.push("noThumbnails"),t.noLinks&&i.push("noLinks"));let n="";return i.length&&(n=`?${i.join("&")}`),En(e)?En(e):this.execute("get","/api/item/publicaggregate/"+e+n)}async getItemAggregated(e,t){const a=En(e);if(a)return a;const i=[];t&&(t.withFieldInstances&&i.push("withFieldInstances"),t.withAttachmentInfo&&i.push("withAttachmentInfo"),t.noAttributes&&i.push("noAttributes"),t.noUserAttributes&&i.push("noUserAttributes"),t.noFields&&i.push("noFields"),t.noThumbnails&&i.push("noThumbnails"),t.noLinks&&i.push("noLinks"));let n="";return i.length&&(n=`?${i.join("&")}`),En(e)?En(e):this.execute("get",`/api/item/aggregate/${e}${n}`)}async getItemAggregatedRecursive(e,t){const a=[];t&&(t.withFieldInstances&&a.push("withFieldInstances"),t.withAttachmentInfo&&a.push("withAttachmentInfo"),t.noAttributes&&a.push("noAttributes"),t.noUserAttributes&&a.push("noUserAttributes"),t.noFields&&a.push("noFields"),t.noThumbnails&&a.push("noThumbnails"));let i="";return a.length&&(i=`?${a.join("&")}`),this.execute("get",`/api/item/aggregaterecursive/${e}${i}`)}async getItemPublicRecursive(e,t){return this.execute("get","/api/item/publicrecursive/"+e+(t?"?withFeatures":""))}async getItemPublic(e,t){return this.execute("get","/api/item/public/"+e+(t?"?returnClonedFrom=true":""))}async getItemHistory(e){return this.execute("get","/api/item/history/"+e)}async copyItems(e,t,a,i){return this.execute("post","/api/item/copy",{sourceItemIds:e,destFolderId:t,deepCopy:a,overwrite:i})}async createItem(e){return this.execute("post","/api/item",e)}async updateItem(e){return this.execute("put","/api/item",e)}async deleteItem(e){return this.execute("delete","/api/item",{id:e})}async renameItem(e,t){return this.updateItem({_id:e,name:t})}async queryPublicItemsList(e){return this.execute("post","/api/item/publicquery",e)}async queryItemsListPOP(e){return this.usePublicApi?this.queryPublicItemsList(e):this.queryItemsList(e)}async queryItemsList(e){return this.execute("post","/api/item/query",e)}async queryItemsListAsExcel(e){e.exportAsExcel=!0;const t=await this.execute("post","/api/item/query",e,{responseType:"arraybuffer"}),a=window.URL.createObjectURL(t.blob),i=document.createElement("a");i.href=a,i.setAttribute("download","export.xlsx"),i.click()}async moveItems(e){return this.execute("post","/api/item/move",e)}async downloadItem(e,t){const a=Tn(e);return a||this.execute("get",`/api/item/download/${e}`,null,{responseType:"arraybuffer",progressCallback:t,opName:`Downloading item ${e}`})}async publicDownloadItem(e,t){const a=Tn(e);return a||this.execute("get",`/api/item/publicdownload/${e}`,null,{responseType:"arraybuffer",progressCallback:t})}async getItemHash(e){const t=En(e);return t?t.hash:this.execute("get",`/api/item/hash/${e}`)}async requestSecureDownload(e){return this.execute("get","/api/item/requestsecuredownload/"+e)}async getThumbnail(e,t){return this.execute("get",`/api/item/thumbnail/${e}/${t}`)}async uploadThumbnail(e,t,a,i,n,r){const s=this._createFormData(a,i);return this.execute("post",`/api/item/thumbnail/${t}/${e}`,s,{progressCallback:n,controller:r})}async getPublicThumbnail(e,t){return this.execute("get",`/api/item/publicthumbnail/${e}/${t}`)}async makeItemPublic(e,t,a){return this.execute("put","/api/item/makepublic",{id:e,recursive:t,inSubfolders:a})}async setVisibility(e,t,a,i){return this.execute("put","/api/item/setvisibility",{id:e,visibility:t,recursive:a,inSubfolders:i})}async makeItemPrivate(e,t,a){return this.execute("put","/api/item/makeprivate",{id:e,recursive:t,inSubfolders:a})}async setOmitLodGeneration(e,t){return this.execute("get",`/api/item/setOmitLodGeneration/${e}/${t}`)}async setOmitThumbnailGeneration(e,t){return this.execute("get",`/api/item/setOmitThumbnailGeneration/${e}/${t}`)}async setOmitPreviewGeneration(e,t){return this.execute("get",`/api/item/setOmitPreviewGeneration/${e}/${t}`)}async uploadAndCreate(e,t,a,i,n,r){const s=this._createFormData(t,a);let o=`/api/item/uploadAndCreate/${e}`,l={};return i&&("object"==typeof i?(i.autoDestructIn&&(o+="?autoDestructIn="+i.autoDestructIn),i.visibility&&(o+="?visibility="+i.visibility),i.flags&&(o+="?flags="+i.flags),i.overwrite&&(o+="?overwrite="+(i.overwrite?"true":"false")),i.nameOverride&&(l["x-override-name"]=i.nameOverride)):o+="?autoDestructIn="+i),this.execute("post",o,s,{progressCallback:n,controller:r,headers:l})}async upload(e,t,a,i,n,r){const s=[];r&&(r.omitHandleDependencyChange&&s.push("omitHandleDependencyChange=true"),r.keepThumbnails&&s.push("keepThumbnails=true"));let o="";s.length&&(o=`?${s.join("&")}`);const l=this._createFormData(t,a);return this.execute("post",`/api/item/upload/${e}${o}`,l,{progressCallback:i,controller:n})}resetPreview(e){const t=this.execute("delete",`/api/item/attachment/${e}/preview`),a=this.execute("get",`/api/item/setOmitPreviewGeneration/${e}/false`);return Promise.all([t,a])}clearPreview(e){const t=this.execute("delete",`/api/item/attachment/${e}/preview`),a=this.execute("get",`/api/item/setOmitPreviewGeneration/${e}/true`);return Promise.all([t,a])}async clearThumbnail(e){return this.execute("get",`/api/item/clearThumbnail/${e}`)}async resetThumbnail(e){return this.execute("get",`/api/item/resetThumbnail/${e}`)}async downloadAttachmentPOP(e,t,a,i,n){return this.usePublicApi?this.downloadPublicAttachment(e,t,a,i,n):this.downloadAttachment(e,t,a,i,n)}_getAttachmentUrlPath(e,t,a,i,n){return`/api/item/${n?"public":""}attachment/${e}/${t}${null!=a?`/${a}`:"/undefined"}${null!=i?`/${i}`:""}`}async downloadAttachment(e,t,a,i=0,n){const r=Ln(e,t,a,i);return r||this.execute("get",this._getAttachmentUrlPath(e,t,a,i),null,{responseType:"arraybuffer",progressCallback:n})}async downloadPublicAttachment(e,t,a,i,n){const r=Ln(e,t,a,i);return r||this.execute("get",this._getAttachmentUrlPath(e,t,a,i,!0),null,{responseType:"arraybuffer",progressCallback:n})}async uploadAttachment(e,t,a,i,n,r,s,o){const l=this._createFormData(n,r);return this.execute("post",this._getAttachmentUrlPath(e,t,a,i),l,{progressCallback:s,controller:o})}async deleteAttachment(e,t,a,i){return this.attachmentCache.invalidateAttachment(e,t,a,i),this.execute("delete",this._getAttachmentUrlPath(e,t,a,i))}setPerceptiveHashOnAttachment(e,t,a){return this.execute("get",`/api/item/setPerceptiveHashAttachment/${e}/${t}/${a}`)}setPerceptiveHash(e,t){return this.execute("get",`/api/item/setPerceptiveHash/${e}/${t}`)}async getItemClient(e){return this.execute("get",`/api/item/getClient/${e}`)}async getItemAcl(e){return this.execute("get",`/api/item/acl/${e}`)}async getItemsLinking(e){return this.execute("get",`/api/item/linking/${e}`)}async setAttributes(e,t){return this.execute("put","/api/item/setAttributes",{id:e,attributes:t})}async getItemSyncList(e){const t=P(e).format("YYYYMMDDHHmmss");return this.execute("get",`/api/item/synclist/${t}`)}async increaseViews(e){return this.execute("get",`/api/item/increaseViews/${e}`)}async getViews(e){return this.execute("get",`/api/item/views/${e}`)}async getPublicItemCounts(e){return this.execute("get",`/api/item/publiccounts/${e}`)}async getItemCounts(e){return this.execute("get",`/api/item/counts/${e}`)}async likeItem(e){return this.execute("get",`/api/item/like/${e}`)}async unlikeItem(e){return this.execute("get",`/api/item/unlike/${e}`)}async doILike(e){return this.execute("get",`/api/item/doILike/${e}`)}async setItemAutoDestruct(e,t){const a=P(t).format("YYYYMMDDHHmmss");return this.execute("get",`/api/item/setAutoDestruct/${e}/${a}`)}async clearItemAutoDestruct(e){return this.execute("get",`/api/item/clearAutoDestruct/${e}`)}async resolveRelativeItem(e,t){const a=En(e);if(!a)return this.execute("post","/api/item/resolve/"+e,{path:t});t.startsWith("/")&&(t=t.substring(1));const i=t.split("/"),n=i.pop();let r=a.folder._id;for(const e of i){let t=!1;for(const[a,i]of Object.entries(Mn()))if(i.parent===r&&i.name===e){r=a,t=!0;break}if(!t)break}for(const e of Object.values(In()))if(e.folder._id===r&&e.name===n)return e._id;return console.error(`Could not resolve path ${t} for item ${e}`),null}async publicResolveRelativeItem(e,t){const a=En(e);if(!a)return this.execute("post","/api/item/publicResolve/"+e,{path:t});t.startsWith("/")&&(t=t.substring(1));const i=t.split("/"),n=i.pop();let r=xn(a.folder._id);for(const e of i)if(".."===e)r=xn(r.parent);else{const t=Cn(e,r._id);if(!t)throw new Error("Can't find folder while loading folder from package");r=t}const s=Vn(n,r._id);if(s)return s._id;throw new Error("Can't load item from package.")}async rewireItems(e){return this.execute("post","/api/item/rewire",{items:e})}async getFolder(e){return this.execute("get","/api/folder/"+e)}async getFullFolderTree(e){return this.execute("get",`/api/folder/fulltree/${e||"0"}`)}async getFoldersInFolderList(e,t){e=e||"0";const a=[];let i="";if(t){if(t.resolveNames&&!t.folderAsItemType&&"0"!==e){if(i=await this.folderCache.getFolderListing(e),i&&Date.now()-new Date(i.cachedAt).getTime()<1e4)return i;i&&i.parent&&a.push(`lastUpdatedAt=${i.parent.updatedAt}`)}t.resolveNames&&a.push("resolve"),t.folderAsItemType&&a.push(`folderAsItemType=${t.folderAsItemType}`),t.folderAsItemName&&a.push(`folderAsItemName=${t.folderAsItemName}`),t.folderAsItemFlag&&a.push(`folderAsItemFlag=${t.folderAsItemFlag}`),t.withStats&&a.push("withStats=true"),t.returnLatestPackage&&a.push("returnLatestPackage=true")}let n="";a.length&&(n="?"+a.join("&"));const r=await this.execute("get",`/api/folder/infolder/${e}${n}`);if(!0===r.notModified)return i;if(!t||t.resolveNames&&!t.folderAsItemType){const t=await this.getFolderAclList([e,...r.children.map((e=>e._id))]);for(const e of t)await this.folderCache.addACL(e.id,e.acl);return await this.folderCache.addFolderListing(e,r),r}return r}async updateFolderCache(e){const t=[];for(const a of e){if(!a)continue;const e=await this.folderCache.getFolderListing(a);e&&e.parent?t.push({id:a,lastUpdatedAt:e.parent.updatedAt}):t.push({id:a})}const a=await this.execute("post","/api/folder/infolderquery",{folders:t});for(const e of a)!0===e.data.notModified?await this.folderCache.refreshCacheForFolder(e.id):await this.folderCache.addFolderListing(e.id,e.data)}async createFolder(e){return this.execute("post","/api/folder",e)}async updateFolder(e){return this.execute("put","/api/folder",e)}async deleteFolder(e){return this.execute("delete","/api/folder",{id:e})}async renameFolder(e,t){return this.updateFolder({_id:e,name:t})}async moveFolders(e){return this.execute("post","/api/folder/move",e)}async getFolderPath(e){return e?("object"==typeof e&&(e=e._id),this.execute("get","/api/folder/path/"+e)):{path:"/",elements:[]}}async resolveFolderPath(e){return"/"===(e=e.trim())?null:this.execute("post","/api/folder/resolve",{path:e})}async getFolderClient(e){return this.execute("get",`/api/folder/getClient/${e}`)}async getFolderAcl(e){const t=await this.folderCache.getFolderACLs(e||"0",1e4);if(t&&e)return t;{const t=await this.execute("get",`/api/folder/acl/${e||"0"}`);return await this.folderCache.addACL(e||"0",t),t}}async getFolderAclList(e){return this.execute("post","/api/folder/aclquery",{ids:e})}async getUser(e){return this.execute("get","/api/user/"+e)}async getUsersList(){return this.execute("get","/api/user")}async createUser(e){return this.execute("post","/api/user",e)}async queryUser(e,t,a){return this.execute("post","/api/user/query",{searchQuery:e,groupID:t,cursor:a},{withNext:!0})}async updateUser(e){return this.execute("put","/api/user",e)}async deleteUser(e){return this.execute("delete","/api/user",{id:e})}async updateMyProfile(e){return this.execute("put","/api/user/myprofile",e)}async switchClient(e){return this.execute("get",`/api/user/switchclient/${e}`)}async activateUser(e,t){return this.execute("post","/api/user/activate",{token:t,password:e})}async getUsersToApprove(){return this.execute("get","/api/user/approvals")}async approveUserRegistration(e){return this.execute("get",`/api/user/approveuserregistration/${e}`)}async rejectUserRegistration(e){return this.execute("get",`/api/user/rejectuserregistration/${e}`)}async uploadAvatar(e){const t=new r;if(e instanceof Blob)t.append("file",e);else{const a=new Blob([new Uint8Array(e)]);t.append("file",a,"avatar.jpg")}return this.execute("post","/api/user/uploadAvatar",t)}async clearAvatar(){return this.execute("get","/api/user/clearAvatar")}async getAvatar(e,t){return this.execute("get",`/api/user/avatar/${t}/${e}`)}async getUserPublicInfo(e,t,a){return this.execute("get",`/api/user/publicinfo/${e}/${t}/${a}`)}async getUserAttribute(e){return this.execute("get",`/api/user/attribute/${e}`)}async clearUserAttribute(e){return this.execute("delete",`/api/user/attribute/${e}`)}async setUserAttribute(e,t){return this.execute("post",`/api/user/attribute/${e}`,t)}async getGroup(e){return this.execute("get","/api/group/"+e)}async getGroupFolder(e){return this.execute("get","/api/group/folder/"+e)}async getGroupsList(){return this.execute("get","/api/group")}async createGroup(e){return this.execute("post","/api/group",e)}async queryGroup(e,t){return this.execute("post","/api/group/query",{searchQuery:e,cursor:t},{withNext:!0})}async updateGroup(e){return this.execute("put","/api/group",e)}async deleteGroup(e){return this.execute("delete","/api/group",{id:e})}async getGroupQuotaInfo(e){return this.execute("get","/api/group/quota/"+e)}async getGroupPublicInfo(e,t,a){return this.execute("get",`/api/group/publicinfo/${e}/${t}/${a}`)}async getGroupUsers(e){return this.execute("get","/api/group/users/"+e)}async uploadGroupAvatar(e,t){const a=new r;if(t instanceof Blob)a.append("file",t);else{const e=new Blob([new Uint8Array(t)]);a.append("file",e,"avatar.jpg")}return this.execute("post","/api/group/"+e+"/uploadAvatar",a)}async getClientsList(){return this.execute("get","/api/client")}async getClient(e){return this.execute("get",`/api/client/${e}`)}async createClient(e){return this.execute("post","/api/client",e)}async queryClient(e,t){return this.execute("post","/api/client/query",{searchQuery:e,cursor:t},{withNext:!0})}async updateClient(e){return this.execute("put","/api/client",e)}async deleteClient(e){return this.execute("delete","/api/client",{id:e})}async getClientMetrics(e,t,a){return this.execute("get",`/api/client/metrics/${t}/${a}/${e}`)}async joinClient(e){return this.execute("get",`/api/client/join/${e}`)}async leaveClient(e){return this.execute("get",`/api/client/leave/${e}`)}async myClient(){return this.execute("get","/api/client/my")}async saveMyClient(e){return this.execute("put","/api/client/my",e)}async getPublicCategories(e){return this.execute("get",`/api/client/publiccategories/${e}`)}async getCategories(){return this.execute("get","/api/client/categories")}async getCategoriesInClient(e){return this.execute("get",`/api/client/categories/${e}`)}async updateCategoriesInClient(e,t){return this.execute("post",`/api/client/categories/${e}`,t)}async getLicenses(){return this.execute("get","/api/license")}async getLicensesInClient(e){return this.execute("get",`/api/license/inclient/${e}`)}async getLicense(e){return this.execute("get",`/api/license/${e}`)}async createLicense(e){return this.execute("post","/api/license",e)}async updateLicense(e){return this.execute("put","/api/license",e)}async deleteLicense(e,t){return this.execute("delete","/api/license",{_id:e,client:t})}async getPublicLicenses(e){return this.execute("get",`/api/license/publiclist/${e}`)}async getPublicLicense(e){return this.execute("get",`/api/license/public/${e}`)}async getDatatypesList(){return this.execute("get","/api/datatype")}async getPublicDatatypesList(e){return this.execute("get",`/api/datatype/public/${e}`)}async getDatatypesListOnClient(){return this.execute("get","/api/datatype/onclient")}async getDatatypesListOnClientForAll(){return this.execute("get","/api/datatype/onclientforall")}async getAllDatatypesList(){return this.execute("get","/api/datatype/all")}async getDatatype(e){return this.execute("get",`/api/datatype/${e}`)}async createDatatype(e){return this.execute("post","/api/datatype",e)}async updateDatatype(e){return this.execute("put","/api/datatype",e)}async deleteDatatype(e){return this.execute("delete","/api/datatype",{id:e})}async getMyNotifications(e){return this.execute("get","/api/notification"+(e?`?maxCount=${e}`:""))}async markNotificationAsRead(e){return this.execute("get",`/api/notification/markasread/${e}`)}async markAllNotificationsAsRead(){return this.execute("get","/api/notification/markallasread")}async createJob(e){return this.execute("post","/api/job",e,{emitOnSuccess:"job:created"})}async getManualJobTypes(){return this.execute("get","/api/job/manualtypes")}async getManualJobTypesOnClient(){return this.execute("get","/api/job/manualtypes/onclient")}async getManualJobTypesOnClientForAll(){return this.execute("get","/api/job/manualtypes/onclientforall")}async getAllManualJobTypes(){return this.execute("get","/api/job/manualtypes/all")}async getAllManualJobTypesForClient(e){return this.execute("get",`/api/job/manualtypes/all/${e}`)}async getClientJobTypes(){return this.execute("get","/api/job/clientTypes")}async getMyJobs(){return this.execute("get","/api/job/mine")}async getJobs(){return this.execute("get","/api/job")}async getJobsAggregated(){return this.execute("get","/api/job/aggregated")}async getJobsTimeframe(e,t){return this.execute("get",`/api/job/all/${e}/${t}`)}async getJob(e){return this.execute("get",`/api/job/${e}`)}async getJobState(e){return this.execute("get",`/api/job/state/${e}`)}async getAgents(){return this.execute("get","/api/jobagent")}async getAgentsAggregated(){return this.execute("get","/api/jobagent/aggregated")}async enableJobAgent(e){return this.execute("get",`/api/jobagent/enable/${e}`)}async disableJobAgent(e){return this.execute("get",`/api/jobagent/disable/${e}`)}async restartJobAgent(e){return this.execute("get",`/api/jobagent/restart/${e}`)}async getPermissionsList(){return this.execute("get","/api/permission")}async getPlugins(){return this.execute("get","/api/plugin")}async getPlans(){return this.execute("get","/api/plan")}async getPlan(e){return this.execute("get",`/api/plan/${e}`)}async createPlan(e){return this.execute("post","/api/plan",e)}async updatePlan(e){return this.execute("put","/api/plan",e)}async deletePlan(e){return this.execute("delete","/api/plan",{id:e})}async getWorkflows(){return this.execute("get","/api/workflow")}async getWorkflow(e){return this.execute("get",`/api/workflow/${e}`)}async createWorkflow(e){return this.execute("post","/api/workflow",e)}async updateWorkflow(e){return this.execute("put","/api/workflow",e)}async deleteWorkflow(e){return this.execute("delete","/api/workflow",{id:e})}async startWorkflow(e){return this.execute("post","/api/workflow/start",e)}async getAccessTokens(){return this.execute("get","/api/accesstoken")}async getClientAccessTokens(){return this.execute("get","/api/accesstoken/client")}async createAccessToken(e){return this.execute("post","/api/accesstoken",e)}async createClientAccessToken(e){return this.execute("post","/api/accesstoken/client",e)}async deleteAccessToken(e){return this.execute("delete","/api/accesstoken",{id:e})}async deleteClientAccessToken(e){return this.execute("delete","/api/accesstoken/client",{id:e})}async enableAccessToken(e){return this.execute("get",`/api/accesstoken/enable/${e}`)}async disableAccessToken(e){return this.execute("get",`/api/accesstoken/disable/${e}`)}async getApiTokens(){return this.execute("get","/api/apitoken")}async createApiToken(e){return this.execute("post","/api/apitoken",e)}async deleteApiToken(e){return this.execute("delete","/api/apitoken",{id:e})}async getMyClientInvoices(){return this.execute("get","/api/invoice")}async getMyUserInvoices(){return this.execute("get","/api/invoice/my")}async getClientInvoices(e){return this.execute("get",`/api/invoice/client/${e}`)}async downloadInvoice(e,t){const a=await this.execute("get",`/api/invoice/download/${e}`,null,{responseType:"arraybuffer"}),i=window.URL.createObjectURL(a.blob),n=document.createElement("a");n.href=i,n.setAttribute("download",t||"invoice.pdf"),document.body.appendChild(n),n.click()}async regenerateInvoice(e){return this.execute("get",`/api/invoice/regenerate/${e}`)}async getInvoicesForMonth(e,t){return this.execute("get",`/api/invoice/month/${t}/${e}`)}async refundInvoice(e,t,a){return this.execute("post","/api/invoice/refund",{invoice:e,amount:t,reason:a})}async paymentStartCheckout(e,t){return this.execute("post","/api/payment/checkout",{successUrl:e,cancelUrl:t})}async paymentStartUserCheckout(e,t){return this.execute("post","/api/payment/usercheckout",{successUrl:e,cancelUrl:t})}async getSupportedCurrencies(){return this.execute("get","/api/payment/supportedCurrencies")}async getPurchasables(){return this.execute("get","/api/purchasable")}async getPurchasable(e){return this.execute("get",`/api/purchasable/${e}`)}async createPurchasable(e){return this.execute("post","/api/purchasable",e)}async updatePurchasable(e){return this.execute("put","/api/purchasable",e)}async deletePurchasable(e){return this.execute("delete","/api/purchasable",{id:e})}async getPublicPurchasables(e){return this.execute("get",`/api/purchasable/public/${e}`)}async getPurchases(){return this.execute("get","/api/purchase")}async getMyActivePurchases(){return this.execute("get","/api/purchase/active")}async purchase(e){return this.execute("post","/api/purchase",e)}async changePurchaseProduct(e,t,a){return this.execute("post","/api/purchase/change",{purchaseID:e,purchasableID:t,optionID:a})}async cancelPurchase(e){return this.execute("delete","/api/purchase",{id:e})}async uncancelPurchase(e){return this.execute("post","/api/purchase/uncancel",{id:e})}async getSecureSessionPayload(e,t){return this.execute("get","/api/payment/secureSessionPayload?purchasableID="+e+"&optionID="+t)}async queryPurchases(e,t,a,i,n,r){return this.execute("post","/api/purchase/query",{startDate:e,endDate:t,email:a,invoice:i,cursor:n,limit:r})}async getAttributeTemplates(){return this.execute("get","/api/attributetemplate")}async getAttributeTemplate(e){return this.execute("get",`/api/attributetemplate/${e}`)}async createAttributeTemplate(e){return this.execute("post","/api/attributetemplate",e)}async updateAttributeTemplate(e){return this.execute("put","/api/attributetemplate",e)}async deleteAttributeTemplate(e){return this.execute("delete","/api/attributetemplate",{id:e})}async getStorages(){return this.execute("get","/api/storage")}async getConversation(e){return this.execute("get",`/api/conversation/${e}`)}async getPublicConversation(e){return this.execute("get",`/api/conversation/public/${e}`)}async createConversation(e,t){return this.execute("post","/api/conversation",{parentId:e,parentType:t})}async postConversationMessage(e,t,a){return this.execute("post","/api/conversation/post",{id:e,text:t,replyTo:a})}async editConversationMessage(e,t){return this.execute("put","/api/conversation/post",{id:e,text:t})}async deleteConversationMessage(e){return this.execute("delete","/api/conversation/post",{id:e})}async subscribeToConversation(e){return this.execute("post","/api/conversation/subscribe",{id:e})}async unsubscribeFromConversation(e){return this.execute("post","/api/conversation/unsubscribe",{id:e})}async likeConversationEntry(e){return this.execute("post","/api/conversation/like",{id:e})}async unlikeConversationEntry(e){return this.execute("post","/api/conversation/unlike",{id:e})}async command(e){return this.execute("post","/api/command",e)}async getMailTemplates(){return this.execute("get","/api/mailtemplate")}async getMailTemplate(e){return this.execute("get",`/api/mailtemplate/${e}`)}async createMailTemplate(e){return this.execute("post","/api/mailtemplate",e)}async updateMailTemplate(e){return this.execute("put","/api/mailtemplate",e)}async deleteMailTemplate(e){return this.execute("delete","/api/mailtemplate",{id:e})}async addMailTemplateImage(e,t,a){const i=this._createFormData(a,"image.jpg");return this.execute("post",`/api/mailtemplate/image/${e}/${t}`,i)}async deleteMailTemplateImage(e,t){return this.execute("delete",`/api/mailtemplate/image/${e}/${t}`)}async getMailTemplateNames(){return this.execute("get","/api/mailtemplate/names")}async getMailQuery(e,t,a,i){return this.execute("post","/api/email/query",{templateName:e,dateStart:t,dateEnd:a,success:i},{withNext:!0})}async getMail(e){return this.execute("get","/api/email/get?token="+e)}async getInvoiceTemplates(){return this.execute("get","/api/invoicetemplate")}async getInvoiceTemplate(e){return this.execute("get",`/api/invoicetemplate/${e}`)}async createInvoiceTemplate(e){return this.execute("post","/api/invoicetemplate",e)}async updateInvoiceTemplate(e){return this.execute("put","/api/invoicetemplate",e)}async deleteInvoiceTemplate(e){return this.execute("delete","/api/invoicetemplate",{id:e})}async addInvoiceTemplateImage(e,t,a){const i=this._createFormData(a,"image.jpg");return this.execute("post",`/api/invoicetemplate/image/${e}/${t}`,i)}async deleteInvoiceTemplateImage(e,t){return this.execute("delete",`/api/invoicetemplate/image/${e}/${t}`)}async getItemTemplatesList(){return this.execute("get","/api/itemtemplate/list")}async getItemTemplates(){return this.execute("get","/api/itemtemplate")}async createItemTemplate(e){return this.execute("post","/api/itemtemplate",e)}async updateItemTemplate(e){return this.execute("put","/api/itemtemplate",e)}async deleteItemTemplate(e){return this.execute("delete","/api/itemtemplate",{id:e})}async getFeatures(){return this.execute("get","/api/feature")}async getFeaturesOnClient(){return this.execute("get","/api/feature/onclient")}async getFeaturesOnClientForAll(){return this.execute("get","/api/feature/onclientforall")}async getAllFeatures(){return this.execute("get","/api/feature/all")}async getBlogs(){return this.execute("get","/api/blog")}async getBlog(e){return this.execute("get","/api/blog/"+e)}async getPublicBlog(e){return this.execute("get","/api/blog/"+e+"/public")}async createBlog(e,t,a,i){return this.execute("post","/api/blog",{name:e,public:t,commentsEnabled:a,editors:i})}async saveBlog(e,t,a,i,n){return this.execute("put","/api/blog",{_id:e,name:t,public:a,commentsEnabled:i,editors:n})}async deleteBlog(e){return this.execute("delete","/api/blog",{_id:e})}async getBlogOverview(e){return this.execute("get","/api/blog/"+e+"/overview")}async queryBlog(e,t,a,i,n,r,s){return this.execute("post","/api/blog/"+e+"/query",{tag:t,text:a,limit:i,previousArticle:n,searchTag:r,sortBy:s})}async getArticles(e){return this.execute("get","/api/blog/"+e+"/article")}async getArticle(e,t){return this.execute("get","/api/blog/"+e+"/article/"+t)}async getArticleBySlug(e,t){return this.execute("get","/api/blog/article/"+e+"/"+t)}async createArticle(e,t,a){return this.execute("post","/api/blog/"+e+"/article",{title:t,slug:a})}async saveArticle(e,t,a,i,n,r,s,o){return this.execute("put","/api/blog/"+e+"/article",{_id:t,title:a,slug:i,content:o,tags:r,public:n,author:s})}async deleteArticle(e,t){return this.execute("delete","/api/blog/"+e+"/article",{_id:t})}async getNewsletters(){return this.execute("get","/api/newsletter")}async createNewsletter(e,t){return this.execute("post","/api/newsletter",{name:e,editors:t})}async getNewsletter(e){return this.execute("get","/api/newsletter/"+e)}async updateNewsletter(e,t,a,i){return this.execute("put","/api/newsletter/"+e,{name:t,sender:a,editors:i})}async deleteNewsletter(e){return this.execute("delete","/api/newsletter/"+e)}async joinNewsletter(e,t){return this.execute("post","/api/newsletter/join",{id:e,email:t})}async confirmNewsletter(e){return this.execute("post","/api/newsletter/confirm",{token:e})}async unsubscribeFromNewsletter(e){return this.execute("post","/api/newsletter/unsubscribe",{token:e})}async getNewsletterBlocks(){return this.execute("get","/api/newsletterblock")}async getNewsletterBlock(e){return this.execute("get","/api/newsletterblock/"+e)}async createNewsletterBlock(e){return this.execute("post","/api/newsletterblock",{name:e})}async updateNewsletterBlock(e,t,a,i,n,r){return this.execute("put","/api/newsletterblock/"+e,{name:t,inputs:a,html:i,css:n,acceptsChildren:r})}async deleteNewsletterBlock(e){return this.execute("delete","/api/newsletterblock/"+e)}async getNewsletterMails(e){return this.execute("get","/api/newslettermail/"+e)}async getNewsletterMail(e,t){return this.execute("get","/api/newslettermail/"+e+"/"+t)}async createNewsletterMail(e,t){return this.execute("post","/api/newslettermail/"+e,{title:t})}async updateNewsletterMail(e,t,a,i,n){return this.execute("put","/api/newslettermail/"+e+"/"+t,{title:a,blocks:i,parentBlock:n})}async generatePreviewNewsletterMail(e,t){return this.execute("post","/api/newslettermail/render",{blocks:e,parentBlock:t})}async sendTestNewsletter(e,t,a){return this.execute("post","/api/newslettermail/"+e+"/"+t+"/sendTest",{email:a})}async sendOutNewsletter(e,t){return this.execute("post","/api/newslettermail/"+e+"/"+t+"/send",{})}async getPages(){return this.execute("get","/api/page")}async createPage(e,t){return this.execute("post","/api/page",{title:e,slug:t})}async getPage(e){return this.execute("get","/api/page/"+e)}async updatePage(e,t,a,i,n){return this.execute("put","/api/page",{_id:e,title:t,slug:a,public:i,content:n})}async deletePage(e){return this.execute("delete","/api/page",{_id:e})}async getPublicPage(e,t){return this.execute("get","/api/page/public/"+e+"/"+t)}async setItemFlag(e,t,a,i,n,r){return this.execute("post","/api/itemflag",{item:e,isStaffPick:t,featureWeight:a,isGame:i,replaceIndex:n,internalRating:r})}getDownloadUrl(e){return`${this.getApiBaseUrl()}/api/item/download/${e}`}getAttachmentDownloadUrl(e,t,a,i){return`${this.getApiBaseUrl()}${this._getAttachmentUrlPath(e,t,a,i)}`}getPublicAttachmentDownloadUrl(e,t,a,i){return`${this.getApiBaseUrl()}${this._getAttachmentUrlPath(e,t,a,i,!0)}`}getPublicDownloadUrl(e){return`${this.getApiBaseUrl()}/api/item/publicdownload/${e}`}async postFeedback(e){return this.execute("post","/api/feedback",{text:e})}},e.ApiGateway=L,e.Block=ae,e.CustomField=J,e.EventEmitter=l,e.Field=Z,e.InvalidArgumentException=_,e.InvalidStateException=class extends w{constructor(e){super(e,"InvalidStateException")}},e.Item=T,e.ItemCache=Fr,e.ItemRepo=jn,e.ItemVisibility=Rd,e.LinkableItemsCache=class{linkableItemsCache;apiGateway;itemCache;usePublicApi;constructor(e,t,a=!1){this.linkableItemsCache=new Map,this.apiGateway=e,this.itemCache=t,this.usePublicApi=a}clear(){this.linkableItemsCache.clear()}resolveItem(e,t){for(const a of t)if(a._id===e)return a;return null}async loadLinkableItems(e,t){if(!e)throw"loadLinkableItems(): Item cannot be null!";let a=[];if(t.linkableTypes&&t.linkableTypes.length){if(!this.usePublicApi){const i=t.linkableTypes.join("#")+(e.folder?e.folder._id:"");if(this.linkableItemsCache.has(i))return this.linkableItemsCache.get(i);const n=[...t.linkableTypes];n.includes("Package")||n.push("Package");const r={types:n,folder:e.folder?e.folder._id:null};a=(await this.apiGateway.call("LinkableItemsCache::loadLinkableItems","queryItemsList",r)).filter((e=>"Package"!==e.type||t.linkableTypes.includes(e.packageType)));for(const i of e.links)if(null==this.resolveItem(i.to,a))try{const e=await this.itemCache.getItem(i.to);t.linkableTypes.includes(e.type)&&a.push(e)}catch(e){console.error(`Link item ${i.to} not found. Dead link? (${e})`)}this.linkableItemsCache.set(i,a)}}else{for(const t of e.links){const e=await this.itemCache.getItem(t.to);a.push(e)}const i=t.name+"#CurrentLinks";this.linkableItemsCache.set(i,a)}return a}},e.LoaderException=k,e.PackageTools=Bn,e.PreparedItem=K,e.Profiler=v,e.Proxifier=g,e.ProxyEvent=c,e.QuotaExceededException=S,e.Script=W,e.ScriptField=j,e.Snapshot=O,e.Storage=Jn,e.Template=Q,e.TemplateFactory=ee,e.ThumbCache=Rr,e.UndoManager=$n,e.eventBus=u,e.getDatatypeByName=C,e.getDatatypes=function(){return structuredClone(x)},e.hasPermission=function(e,t,a){if(e.admin&&!a)return!0;if(e.superadmin)return!0;if(Array.isArray(e.permissions))if(Array.isArray(t)){for(const a of e.permissions)for(const e of t)if(a===e)return!0}else for(const a of e.permissions)if(a===t)return!0;return!1},e.profileAsyncBlock=async function(e,t){return v.instance.asyncBlock(e,t)},e.profileBlock=function(e,t){return v.instance.block(e,t)},e.tools=h,e.verifyAcl=X}));
18
+ */var Yn=(zn||(zn=1,function(e){e.exports=function e(t,a,i){function n(s,o){if(!a[s]){if(!t[s]){if(!o&&E)return E(s);if(r)return r(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=a[s]={exports:{}};t[s][0].call(u.exports,(function(e){var a=t[s][1][e];return n(a||e)}),u,u.exports,e,t,a,i)}return a[s].exports}for(var r=E,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,a){(function(e){var a,i,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var r=0,s=new n(c),o=e.document.createTextNode("");s.observe(o,{characterData:!0}),a=function(){o.data=r=++r%2}}else if(e.setImmediate||void 0===e.MessageChannel)a="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){c(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(c,0)};else{var l=new e.MessageChannel;l.port1.onmessage=c,a=function(){l.port2.postMessage(0)}}var u=[];function c(){var e,t;i=!0;for(var a=u.length;a;){for(t=u,u=[],e=-1;++e<a;)t[e]();a=u.length}i=!1}function d(e){1!==u.push(e)||i||a()}t.exports=d}).call(this,void 0!==V?V:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,a){var i=e(1);function n(){}var r={},s=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==n&&h(this,e)}function c(e,t,a){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof a&&(this.onRejected=a,this.callRejected=this.otherCallRejected)}function d(e,t,a){i((function(){var i;try{i=t(a)}catch(t){return r.reject(e,t)}i===e?r.reject(e,new TypeError("Cannot resolve promise with itself")):r.resolve(e,i)}))}function p(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var a=!1;function i(t){a||(a=!0,r.reject(e,t))}function n(t){a||(a=!0,r.resolve(e,t))}function s(){t(n,i)}var o=f(s);"error"===o.status&&i(o.value)}function f(e,t){var a={};try{a.value=e(t),a.status="success"}catch(e){a.status="error",a.value=e}return a}function m(e){return e instanceof this?e:r.resolve(new this(n),e)}function y(e){var t=new this(n);return r.reject(t,e)}function g(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var a=e.length,i=!1;if(!a)return this.resolve([]);for(var s=new Array(a),o=0,l=-1,u=new this(n);++l<a;)c(e[l],l);return u;function c(e,n){function l(e){s[n]=e,++o!==a||i||(i=!0,r.resolve(u,s))}t.resolve(e).then(l,(function(e){i||(i=!0,r.reject(u,e))}))}}function b(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var a=e.length,i=!1;if(!a)return this.resolve([]);for(var s=-1,o=new this(n);++s<a;)l(e[s]);return o;function l(e){t.resolve(e).then((function(e){i||(i=!0,r.resolve(o,e))}),(function(e){i||(i=!0,r.reject(o,e))}))}}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===s)return this;var a=new this.constructor(n);return this.state!==l?d(a,this.state===o?e:t,this.outcome):this.queue.push(new c(a,e,t)),a},c.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},c.prototype.otherCallFulfilled=function(e){d(this.promise,this.onFulfilled,e)},c.prototype.callRejected=function(e){r.reject(this.promise,e)},c.prototype.otherCallRejected=function(e){d(this.promise,this.onRejected,e)},r.resolve=function(e,t){var a=f(p,t);if("error"===a.status)return r.reject(e,a.value);var i=a.value;if(i)h(e,i);else{e.state=o,e.outcome=t;for(var n=-1,s=e.queue.length;++n<s;)e.queue[n].callFulfilled(t)}return e},r.reject=function(e,t){e.state=s,e.outcome=t;for(var a=-1,i=e.queue.length;++a<i;)e.queue[a].callRejected(t);return e},u.resolve=m,u.reject=y,u.all=g,u.race=b},{1:1}],3:[function(e,t,a){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==V?V:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,a){var i="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};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var s=r();function o(){try{if(!s||!s.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function l(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if("TypeError"!==n.name)throw n;for(var a=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)a.append(e[i]);return a.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var u=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function d(e,t,a){"function"==typeof t&&e.then(t),"function"==typeof a&&e.catch(a)}function p(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function h(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var f="local-forage-detect-blob-support",m=void 0,y={},g=Object.prototype.toString,b="readonly",v="readwrite";function w(e){for(var t=e.length,a=new ArrayBuffer(t),i=new Uint8Array(a),n=0;n<t;n++)i[n]=e.charCodeAt(n);return a}function _(e){return new u((function(t){var a=e.transaction(f,v),i=l([""]);a.objectStore(f).put(i,"key"),a.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},a.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);t(a||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function A(e){return"boolean"==typeof m?u.resolve(m):_(e).then((function(e){return m=e}))}function k(e){var t=y[e.name],a={};a.promise=new u((function(e,t){a.resolve=e,a.reject=t})),t.deferredOperations.push(a),t.dbReady?t.dbReady=t.dbReady.then((function(){return a.promise})):t.dbReady=a.promise}function S(e){var t=y[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function N(e,t){var a=y[e.name].deferredOperations.pop();if(a)return a.reject(t),a.promise}function T(e,t){return new u((function(a,i){if(y[e.name]=y[e.name]||P(),e.db){if(!t)return a(e.db);k(e),e.db.close()}var n=[e.name];t&&n.push(e.version);var r=s.open.apply(s,n);t&&(r.onupgradeneeded=function(t){var a=r.result;try{a.createObjectStore(e.storeName),t.oldVersion<=1&&a.createObjectStore(f)}catch(a){if("ConstraintError"!==a.name)throw a;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),r.onerror=function(e){e.preventDefault(),i(r.error)},r.onsuccess=function(){var t=r.result;t.onversionchange=function(e){e.target.close()},a(t),S(e)}}))}function M(e){return T(e,!1)}function x(e){return T(e,!0)}function C(e,t){if(!e.db)return!0;var a=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,n=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),n||a){if(a){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function V(e){return new u((function(t,a){var i=new FileReader;i.onerror=a,i.onloadend=function(a){var i=btoa(a.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function I(e){return l([w(atob(e.data))],{type:e.type})}function E(e){return e&&e.__local_forage_encoded_blob}function F(e){var t=this,a=t._initReady().then((function(){var e=y[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return d(a,e,e),a}function D(e){k(e);for(var t=y[e.name],a=t.forages,i=0;i<a.length;i++){var n=a[i];n._dbInfo.db&&(n._dbInfo.db.close(),n._dbInfo.db=null)}return e.db=null,M(e).then((function(t){return e.db=t,C(e)?x(e):t})).then((function(i){e.db=t.db=i;for(var n=0;n<a.length;n++)a[n]._dbInfo.db=i})).catch((function(t){throw N(e,t),t}))}function R(e,t,a,i){void 0===i&&(i=1);try{var n=e.db.transaction(e.storeName,t);a(null,n)}catch(n){if(i>0&&(!e.db||"InvalidStateError"===n.name||"NotFoundError"===n.name))return u.resolve().then((function(){if(!e.db||"NotFoundError"===n.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),x(e)})).then((function(){return D(e).then((function(){R(e,t,a,i-1)}))})).catch(a);a(n)}}function P(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function L(e){var t=this,a={db:null};if(e)for(var i in e)a[i]=e[i];var n=y[a.name];n||(n=P(),y[a.name]=n),n.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=F);var r=[];function s(){return u.resolve()}for(var o=0;o<n.forages.length;o++){var l=n.forages[o];l!==t&&r.push(l._initReady().catch(s))}var c=n.forages.slice(0);return u.all(r).then((function(){return a.db=n.db,M(a)})).then((function(e){return a.db=e,C(a,t._defaultConfig.version)?x(a):e})).then((function(e){a.db=n.db=e,t._dbInfo=a;for(var i=0;i<c.length;i++){var r=c[i];r!==t&&(r._dbInfo.db=a.db,r._dbInfo.version=a.version)}}))}function B(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){R(a._dbInfo,b,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),E(e)&&(e=I(e)),t(e)},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function O(e,t){var a=this,i=new u((function(t,i){a.ready().then((function(){R(a._dbInfo,b,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName).openCursor(),o=1;s.onsuccess=function(){var a=s.result;if(a){var i=a.value;E(i)&&(i=I(i));var n=e(i,a.key,o++);void 0!==n?t(n):a.continue()}else t()},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function $(e,t,a){var i=this;e=p(e);var n=new u((function(a,n){var r;i.ready().then((function(){return r=i._dbInfo,"[object Blob]"===g.call(t)?A(r.db).then((function(e){return e?t:V(t)})):t})).then((function(t){R(i._dbInfo,v,(function(r,s){if(r)return n(r);try{var o=s.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var l=o.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),a(t)},s.onabort=s.onerror=function(){var e=l.error?l.error:l.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,a),n}function U(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){R(a._dbInfo,v,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName).delete(e);r.oncomplete=function(){t()},r.onerror=function(){i(s.error)},r.onabort=function(){var e=s.error?s.error:s.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function j(e){var t=this,a=new u((function(e,a){t.ready().then((function(){R(t._dbInfo,v,(function(i,n){if(i)return a(i);try{var r=n.objectStore(t._dbInfo.storeName).clear();n.oncomplete=function(){e()},n.onabort=n.onerror=function(){var e=r.error?r.error:r.transaction.error;a(e)}}catch(e){a(e)}}))})).catch(a)}));return c(a,e),a}function z(e){var t=this,a=new u((function(e,a){t.ready().then((function(){R(t._dbInfo,b,(function(i,n){if(i)return a(i);try{var r=n.objectStore(t._dbInfo.storeName).count();r.onsuccess=function(){e(r.result)},r.onerror=function(){a(r.error)}}catch(e){a(e)}}))})).catch(a)}));return c(a,e),a}function W(e,t){var a=this,i=new u((function(t,i){e<0?t(null):a.ready().then((function(){R(a._dbInfo,b,(function(n,r){if(n)return i(n);try{var s=r.objectStore(a._dbInfo.storeName),o=!1,l=s.openKeyCursor();l.onsuccess=function(){var a=l.result;a?0===e||o?t(a.key):(o=!0,a.advance(e)):t(null)},l.onerror=function(){i(l.error)}}catch(e){i(e)}}))})).catch(i)}));return c(i,t),i}function Y(e){var t=this,a=new u((function(e,a){t.ready().then((function(){R(t._dbInfo,b,(function(i,n){if(i)return a(i);try{var r=n.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];r.onsuccess=function(){var t=r.result;t?(s.push(t.key),t.continue()):e(s)},r.onerror=function(){a(r.error)}}catch(e){a(e)}}))})).catch(a)}));return c(a,e),a}function H(e,t){t=h.apply(this,arguments);var a=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||a.name,e.storeName=e.storeName||a.storeName);var i,n=this;if(e.name){var r=e.name===a.name&&n._dbInfo.db?u.resolve(n._dbInfo.db):M(e).then((function(t){var a=y[e.name],i=a.forages;a.db=t;for(var n=0;n<i.length;n++)i[n]._dbInfo.db=t;return t}));i=e.storeName?r.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var a=t.version+1;k(e);var i=y[e.name],n=i.forages;t.close();for(var r=0;r<n.length;r++){var o=n[r];o._dbInfo.db=null,o._dbInfo.version=a}var l=new u((function(t,i){var n=s.open(e.name,a);n.onerror=function(e){n.result.close(),i(e)},n.onupgradeneeded=function(){n.result.deleteObjectStore(e.storeName)},n.onsuccess=function(){var e=n.result;e.close(),t(e)}}));return l.then((function(e){i.db=e;for(var t=0;t<n.length;t++){var a=n[t];a._dbInfo.db=e,S(a._dbInfo)}})).catch((function(t){throw(N(e,t)||u.resolve()).catch((function(){})),t}))}})):r.then((function(t){k(e);var a=y[e.name],i=a.forages;t.close();for(var n=0;n<i.length;n++)i[n]._dbInfo.db=null;var r=new u((function(t,a){var i=s.deleteDatabase(e.name);i.onerror=function(){var e=i.result;e&&e.close(),a(i.error)},i.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}}));return r.then((function(e){a.db=e;for(var t=0;t<i.length;t++)S(i[t]._dbInfo)})).catch((function(t){throw(N(e,t)||u.resolve()).catch((function(){})),t}))}))}else i=u.reject("Invalid arguments");return c(i,t),i}var G={_driver:"asyncStorage",_initStorage:L,_support:o(),iterate:O,getItem:B,setItem:$,removeItem:U,clear:j,length:z,key:W,keys:Y,dropInstance:H};function q(){return"function"==typeof openDatabase}var Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",K=/^~~local_forage_type~([^~]+)~/,X="__lfsc__:",Q=X.length,ee="arbf",te="blob",ae="si08",ie="ui08",ne="uic8",re="si16",se="si32",oe="ur16",le="ui32",ue="fl32",ce="fl64",de=Q+ee.length,pe=Object.prototype.toString;function he(e){var t,a,i,n,r,s=.75*e.length,o=e.length,l=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var u=new ArrayBuffer(s),c=new Uint8Array(u);for(t=0;t<o;t+=4)a=Z.indexOf(e[t]),i=Z.indexOf(e[t+1]),n=Z.indexOf(e[t+2]),r=Z.indexOf(e[t+3]),c[l++]=a<<2|i>>4,c[l++]=(15&i)<<4|n>>2,c[l++]=(3&n)<<6|63&r;return u}function fe(e){var t,a=new Uint8Array(e),i="";for(t=0;t<a.length;t+=3)i+=Z[a[t]>>2],i+=Z[(3&a[t])<<4|a[t+1]>>4],i+=Z[(15&a[t+1])<<2|a[t+2]>>6],i+=Z[63&a[t+2]];return a.length%3==2?i=i.substring(0,i.length-1)+"=":a.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function me(e,t){var a="";if(e&&(a=pe.call(e)),e&&("[object ArrayBuffer]"===a||e.buffer&&"[object ArrayBuffer]"===pe.call(e.buffer))){var i,n=X;e instanceof ArrayBuffer?(i=e,n+=ee):(i=e.buffer,"[object Int8Array]"===a?n+=ae:"[object Uint8Array]"===a?n+=ie:"[object Uint8ClampedArray]"===a?n+=ne:"[object Int16Array]"===a?n+=re:"[object Uint16Array]"===a?n+=oe:"[object Int32Array]"===a?n+=se:"[object Uint32Array]"===a?n+=le:"[object Float32Array]"===a?n+=ue:"[object Float64Array]"===a?n+=ce:t(new Error("Failed to get type for BinaryArray"))),t(n+fe(i))}else if("[object Blob]"===a){var r=new FileReader;r.onload=function(){var a=J+e.type+"~"+fe(this.result);t(X+te+a)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(a){console.error("Couldn't convert value into a JSON string: ",e),t(null,a)}}function ye(e){if(e.substring(0,Q)!==X)return JSON.parse(e);var t,a=e.substring(de),i=e.substring(Q,de);if(i===te&&K.test(a)){var n=a.match(K);t=n[1],a=a.substring(n[0].length)}var r=he(a);switch(i){case ee:return r;case te:return l([r],{type:t});case ae:return new Int8Array(r);case ie:return new Uint8Array(r);case ne:return new Uint8ClampedArray(r);case re:return new Int16Array(r);case oe:return new Uint16Array(r);case se:return new Int32Array(r);case le:return new Uint32Array(r);case ue:return new Float32Array(r);case ce:return new Float64Array(r);default:throw new Error("Unkown type: "+i)}}var ge={serialize:me,deserialize:ye,stringToBuffer:he,bufferToString:fe};function be(e,t,a,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],a,i)}function ve(e){var t=this,a={db:null};if(e)for(var i in e)a[i]="string"!=typeof e[i]?e[i].toString():e[i];var n=new u((function(e,i){try{a.db=openDatabase(a.name,String(a.version),a.description,a.size)}catch(e){return i(e)}a.db.transaction((function(n){be(n,a,(function(){t._dbInfo=a,e()}),(function(e,t){i(t)}))}),i)}));return a.serializer=ge,n}function we(e,t,a,i,n,r){e.executeSql(a,i,n,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,o){o.rows.length?r(e,s):be(e,t,(function(){e.executeSql(a,i,n,r)}),r)}),r):r(e,s)}),r)}function _e(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"SELECT * FROM "+n.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,a){var i=a.rows.length?a.rows.item(0).value:null;i&&(i=n.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function Ae(e,t){var a=this,i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"SELECT * FROM "+n.storeName,[],(function(a,i){for(var r=i.rows,s=r.length,o=0;o<s;o++){var l=r.item(o),u=l.value;if(u&&(u=n.serializer.deserialize(u)),void 0!==(u=e(u,l.key,o+1)))return void t(u)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function ke(e,t,a,i){var n=this;e=p(e);var r=new u((function(r,s){n.ready().then((function(){void 0===t&&(t=null);var o=t,l=n._dbInfo;l.serializer.serialize(t,(function(t,u){u?s(u):l.db.transaction((function(a){we(a,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){r(o)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void r(ke.apply(n,[e,o,a,i-1]));s(t)}}))}))})).catch(s)}));return c(r,a),r}function Se(e,t,a){return ke.apply(this,[e,t,a,1])}function Ne(e,t){var a=this;e=p(e);var i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"DELETE FROM "+n.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function Te(e){var t=this,a=new u((function(e,a){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){a(t)}))}))})).catch(a)}));return c(a,e),a}function Me(e){var t=this,a=new u((function(e,a){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,a){var i=a.rows.item(0).c;e(i)}),(function(e,t){a(t)}))}))})).catch(a)}));return c(a,e),a}function xe(e,t){var a=this,i=new u((function(t,i){a.ready().then((function(){var n=a._dbInfo;n.db.transaction((function(a){we(a,n,"SELECT key FROM "+n.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,a){var i=a.rows.length?a.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return c(i,t),i}function Ce(e){var t=this,a=new u((function(e,a){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT key FROM "+i.storeName,[],(function(t,a){for(var i=[],n=0;n<a.rows.length;n++)i.push(a.rows.item(n).key);e(i)}),(function(e,t){a(t)}))}))})).catch(a)}));return c(a,e),a}function Ve(e){return new u((function(t,a){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(a,i){for(var n=[],r=0;r<i.rows.length;r++)n.push(i.rows.item(r).name);t({db:e,storeNames:n})}),(function(e,t){a(t)}))}),(function(e){a(e)}))}))}function Ie(e,t){t=h.apply(this,arguments);var a=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||a.name,e.storeName=e.storeName||a.storeName);var i,n=this;return c(i=e.name?new u((function(t){var i;i=e.name===a.name?n._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Ve(i))})).then((function(e){return new u((function(t,a){e.db.transaction((function(i){function n(e){return new u((function(t,a){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){a(t)}))}))}for(var r=[],s=0,o=e.storeNames.length;s<o;s++)r.push(n(e.storeNames[s]));u.all(r).then((function(){t()})).catch((function(e){a(e)}))}),(function(e){a(e)}))}))})):u.reject("Invalid arguments"),t),i}var Ee={_driver:"webSQLStorage",_initStorage:ve,_support:q(),iterate:Ae,getItem:_e,setItem:Se,removeItem:Ne,clear:Te,length:Me,key:xe,keys:Ce,dropInstance:Ie};function Fe(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function De(e,t){var a=e.name+"/";return e.storeName!==t.storeName&&(a+=e.storeName+"/"),a}function Re(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Pe(){return!Re()||localStorage.length>0}function Le(e){var t=this,a={};if(e)for(var i in e)a[i]=e[i];return a.keyPrefix=De(e,t._defaultConfig),Pe()?(t._dbInfo=a,a.serializer=ge,u.resolve()):u.reject()}function Be(e){var t=this,a=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,a=localStorage.length-1;a>=0;a--){var i=localStorage.key(a);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return c(a,e),a}function Oe(e,t){var a=this;e=p(e);var i=a.ready().then((function(){var t=a._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return c(i,t),i}function $e(e,t){var a=this,i=a.ready().then((function(){for(var t=a._dbInfo,i=t.keyPrefix,n=i.length,r=localStorage.length,s=1,o=0;o<r;o++){var l=localStorage.key(o);if(0===l.indexOf(i)){var u=localStorage.getItem(l);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,l.substring(n),s++)))return u}}}));return c(i,t),i}function Ue(e,t){var a=this,i=a.ready().then((function(){var t,i=a._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return c(i,t),i}function je(e){var t=this,a=t.ready().then((function(){for(var e=t._dbInfo,a=localStorage.length,i=[],n=0;n<a;n++){var r=localStorage.key(n);0===r.indexOf(e.keyPrefix)&&i.push(r.substring(e.keyPrefix.length))}return i}));return c(a,e),a}function ze(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t}function We(e,t){var a=this;e=p(e);var i=a.ready().then((function(){var t=a._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(i,t),i}function Ye(e,t,a){var i=this;e=p(e);var n=i.ready().then((function(){void 0===t&&(t=null);var a=t;return new u((function(n,r){var s=i._dbInfo;s.serializer.serialize(t,(function(t,i){if(i)r(i);else try{localStorage.setItem(s.keyPrefix+e,t),n(a)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||r(e),r(e)}}))}))}));return c(n,a),n}function He(e,t){if(t=h.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var a=this.config();e.name=e.name||a.name,e.storeName=e.storeName||a.storeName}var i,n=this;return i=e.name?new u((function(t){e.storeName?t(De(e,n._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var a=localStorage.key(t);0===a.indexOf(e)&&localStorage.removeItem(a)}})):u.reject("Invalid arguments"),c(i,t),i}var Ge={_driver:"localStorageWrapper",_initStorage:Le,_support:Fe(),iterate:$e,getItem:Oe,setItem:Ye,removeItem:We,clear:Be,length:ze,key:Ue,keys:je,dropInstance:He},qe=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Ze=function(e,t){for(var a=e.length,i=0;i<a;){if(qe(e[i],t))return!0;i++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ke={},Xe={},Qe={INDEXEDDB:G,WEBSQL:Ee,LOCALSTORAGE:Ge},et=[Qe.INDEXEDDB._driver,Qe.WEBSQL._driver,Qe.LOCALSTORAGE._driver],tt=["dropInstance"],at=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function nt(e,t){e[t]=function(){var a=arguments;return e.ready().then((function(){return e[t].apply(e,a)}))}}function rt(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var a in t)t.hasOwnProperty(a)&&(Je(t[a])?arguments[0][a]=t[a].slice():arguments[0][a]=t[a])}return arguments[0]}var st=function(){function e(t){for(var a in n(this,e),Qe)if(Qe.hasOwnProperty(a)){var i=Qe[a],r=i._driver;this[a]=r,Ke[r]||this.defineDriver(i)}this._defaultConfig=rt({},it),this._config=rt({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,a){var i=new u((function(t,a){try{var i=e._driver,n=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void a(n);for(var r=at.concat("_initStorage"),s=0,o=r.length;s<o;s++){var l=r[s];if((!Ze(tt,l)||e[l])&&"function"!=typeof e[l])return void a(n)}var d=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),a=u.reject(t);return c(a,arguments[arguments.length-1]),a}},a=0,i=tt.length;a<i;a++){var n=tt[a];e[n]||(e[n]=t(n))}};d();var p=function(a){Ke[i]&&console.info("Redefining LocalForage driver: "+i),Ke[i]=e,Xe[i]=a,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(p,a):p(!!e._support):p(!0)}catch(e){a(e)}}));return d(i,t,a),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,a){var i=Ke[e]?u.resolve(Ke[e]):u.reject(new Error("Driver not found."));return d(i,t,a),i},e.prototype.getSerializer=function(e){var t=u.resolve(ge);return d(t,e),t},e.prototype.ready=function(e){var t=this,a=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return d(a,e,e),a},e.prototype.setDriver=function(e,t,a){var i=this;Je(e)||(e=[e]);var n=this._getSupportedDrivers(e);function r(){i._config.driver=i.driver()}function s(e){return i._extend(e),r(),i._ready=i._initStorage(i._config),i._ready}function o(e){return function(){var t=0;function a(){for(;t<e.length;){var n=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(n).then(s).catch(a)}r();var o=new Error("No available storage method found.");return i._driverSet=u.reject(o),i._driverSet}return a()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return u.resolve()})):u.resolve();return this._driverSet=l.then((function(){var e=n[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,r(),i._wrapLibraryMethodsWithReady(),i._initDriver=o(n)}))})).catch((function(){r();var e=new Error("No available storage method found.");return i._driverSet=u.reject(e),i._driverSet})),d(this._driverSet,t,a),this._driverSet},e.prototype.supports=function(e){return!!Xe[e]},e.prototype._extend=function(e){rt(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],a=0,i=e.length;a<i;a++){var n=e[a];this.supports(n)&&t.push(n)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=at.length;e<t;e++)nt(this,at[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ot=new st;t.exports=ot},{3:3}]},{},[4])(4)}(Wn)),Wn.exports),Hn=I(Yn);class Gn{databaseName;collectionName;size;_store;constructor(e,t,a){Hn.config({driver:Hn.INDEXEDDB}),this.databaseName=e||"lumino-cache",this.collectionName=t||"data",this.size=a,this._store=Hn.createInstance({name:this.databaseName,storeName:this.collectionName})}async init(){}async _keys(){return this._store.keys()}async _set(e,t){return this._store.setItem(e,t)}async _clear(){return this._store.clear()}async _get(e){return this._store.getItem(e)}async _remove(e){return this._store.removeItem(e)}}function qn(e){let t,a,i,n;e.onmessage=async r=>{const s=r.data;try{switch(s.type){case"init":{i=s.databaseName,n=s.collectionName,t=await navigator.storage.getDirectory();const r=await t.getDirectoryHandle(i,{create:!0});a=await r.getDirectoryHandle(n,{create:!0}),e.postMessage({type:s.type,database:i,collection:n,success:!0});break}case"write":{if(!a)throw new Error("OPFS Worker: not initialized yet!");const t=await a.getFileHandle(s.filename,{create:!0}),r=await t.createSyncAccessHandle();let o;if("string"==typeof s.content){o=(new TextEncoder).encode(s.content).buffer}else if(s.content instanceof ArrayBuffer)o=s.content;else{if(!(s.content instanceof Blob))throw new Error("OPFS Worker: Unsupported content type: "+typeof s.content);o=await s.content.arrayBuffer()}r.truncate(o.byteLength),r.write(o,{at:0}),await r.flush(),r.close(),e.postMessage({type:s.type,database:i,collection:n,success:!0});break}}}catch(t){e.postMessage({type:s.type,success:!1,database:i,collection:n,error:t.message})}}}class Zn{databaseName;collectionName;size;_worker;_storage;_root;constructor(e,t,a){this.databaseName=e||"lumino-cache",this.collectionName=t||"data",this.size=a}async init(){if("object"==typeof globalThis.navigator&&"storage"in globalThis.navigator&&"function"==typeof globalThis.navigator.storage.getDirectory){this._storage=await navigator.storage.getDirectory();const e=await this._storage.getDirectoryHandle(this.databaseName,{create:!0});let t,a;this._root=await e.getDirectoryHandle(this.collectionName,{create:!0}),this._worker=new Worker(URL.createObjectURL(new Blob(["(",qn.toString(),")(self)"],{type:"application/javascript"})),{type:"module"});let i=new Promise(((e,i)=>{t=e,a=i}));return this._worker.onmessage=e=>{const i=e.data;i.success||console.error("OPFS Worker failed:",i),"init"===i.type&&(i.success?t():a(i.error))},this._worker.postMessage({type:"init",databaseName:this.databaseName,collectionName:this.collectionName}),i}}async _keys(){if(!this._root)return[];const e=[];for await(const t of this._root.values())e.push(t.name);return e}async _set(e,t){if(!this._root)return;let a;if(t instanceof Blob)a=t;else if("object"==typeof t){const e=JSON.stringify(t,null,2);a=new Blob([e],{type:"application/json"})}else a=new Blob([t],{type:"text/plain"});const i=await this._root.getFileHandle(e,{create:!0});if("function"==typeof i.createWritable){const e=await i.createWritable();await e.write(a),await e.close()}else this._worker.postMessage({type:"write",filename:e,content:a})}async _clear(){if(!this._root)return;const e=[];for await(const t of this._root.values())e.push(this._root.removeEntry(t.name));return Promise.all(e)}async _get(e,t){if(!this._root)return null;let a;try{const t=await this._root.getFileHandle(e);a=await t.getFile()}catch(e){return null}switch(t=t||a.type){case"text/plain":return a.text();case"application/json":{const e=await a.text();try{return JSON.parse(e)}catch(t){return console.error("Content was loaded from cache but could not be json parsed: ",e),null}}default:return a}}async _remove(e){if(this._root)return this._root.removeEntry(e)}}class Jn{databaseName;collectionName;size;type;_impl;constructor(e,t,a=0,i=1){switch(this.databaseName=e||"lumino",this.collectionName=t||"data",this.size=1048576*(i||1),this.type=a,this.type){case 0:this._impl=new Gn(this.databaseName,this.collectionName,this.size);break;case 1:this._impl=new Zn(this.databaseName,this.collectionName,this.size);break;default:throw"Invalid storage type: "+a}}async init(){return this._impl.init()}async _keys(){return this._impl._keys()}fixKey(e){return e.replaceAll("/","_")}async _set(e,t){return this._impl._set(this.fixKey(e),t)}async _clear(){return this._impl._clear()}async _get(e,t){return this._impl._get(this.fixKey(e),t)}async _remove(e){return this._impl._remove(this.fixKey(e))}}var Kn,Xn,Qn,er,tr,ar,ir,nr,rr,sr,or,lr,ur,cr,dr,pr,hr,fr,mr,yr,gr,br,vr,wr,_r,Ar,kr,Sr;function Nr(){if(Xn)return Kn;return Xn=1,Kn=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Tr(){if(ar)return tr;ar=1;var e=function(){if(er)return Qn;er=1;var e="object"==typeof V&&V&&V.Object===Object&&V;return Qn=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,a=e||t||Function("return this")();return tr=a}function Mr(){if(lr)return or;lr=1;var e=function(){if(sr)return rr;sr=1;var e=/\s/;return rr=function(t){for(var a=t.length;a--&&e.test(t.charAt(a)););return a}}(),t=/^\s+/;return or=function(a){return a?a.slice(0,e(a)+1).replace(t,""):a}}function xr(){if(cr)return ur;cr=1;var e=Tr().Symbol;return ur=e}function Cr(){if(yr)return mr;yr=1;var e=xr(),t=function(){if(pr)return dr;pr=1;var e=xr(),t=Object.prototype,a=t.hasOwnProperty,i=t.toString,n=e?e.toStringTag:void 0;return dr=function(e){var t=a.call(e,n),r=e[n];try{e[n]=void 0;var s=!0}catch(e){}var o=i.call(e);return s&&(t?e[n]=r:delete e[n]),o}}(),a=function(){if(fr)return hr;fr=1;var e=Object.prototype.toString;return hr=function(t){return e.call(t)}}(),i=e?e.toStringTag:void 0;return mr=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":i&&i in Object(e)?t(e):a(e)}}function Vr(){if(wr)return vr;wr=1;var e=Cr(),t=br?gr:(br=1,gr=function(e){return null!=e&&"object"==typeof e});return vr=function(a){return"symbol"==typeof a||t(a)&&"[object Symbol]"==e(a)}}var Ir=function(){if(Sr)return kr;Sr=1;var e=Nr(),t=function(){if(nr)return ir;nr=1;var e=Tr();return ir=function(){return e.Date.now()}}(),a=function(){if(Ar)return _r;Ar=1;var e=Mr(),t=Nr(),a=Vr(),i=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,r=/^0o[0-7]+$/i,s=parseInt;return _r=function(o){if("number"==typeof o)return o;if(a(o))return NaN;if(t(o)){var l="function"==typeof o.valueOf?o.valueOf():o;o=t(l)?l+"":l}if("string"!=typeof o)return 0===o?o:+o;o=e(o);var u=n.test(o);return u||r.test(o)?s(o.slice(2),u?2:8):i.test(o)?NaN:+o}}(),i=Math.max,n=Math.min;return kr=function(r,s,o){var l,u,c,d,p,h,f=0,m=!1,y=!1,g=!0;if("function"!=typeof r)throw new TypeError("Expected a function");function b(e){var t=l,a=u;return l=u=void 0,f=e,d=r.apply(a,t)}function v(e){var t=e-h;return void 0===h||t>=s||t<0||y&&e-f>=c}function w(){var e=t();if(v(e))return _(e);p=setTimeout(w,function(e){var t=s-(e-h);return y?n(t,c-(e-f)):t}(e))}function _(e){return p=void 0,g&&l?b(e):(l=u=void 0,d)}function A(){var e=t(),a=v(e);if(l=arguments,u=this,h=e,a){if(void 0===p)return function(e){return f=e,p=setTimeout(w,s),m?b(e):d}(h);if(y)return clearTimeout(p),p=setTimeout(w,s),b(h)}return void 0===p&&(p=setTimeout(w,s)),d}return s=a(s)||0,e(o)&&(m=!!o.leading,c=(y="maxWait"in o)?i(a(o.maxWait)||0,s):c,g="trailing"in o?!!o.trailing:g),A.cancel=function(){void 0!==p&&clearTimeout(p),f=0,l=h=u=p=void 0},A.flush=function(){return void 0===p?d:_(t())},A},kr}(),Er=I(Ir);class Fr extends Jn{apiClient;cache=new Map;urlToIdMap=new Map;logging=!1;ready=!1;usePublicApi=!1;quota=0;size=0;usePersistentStorage=!1;saveIndex;constructor(e,t,a,i){if(super("lumino","items",1),!a)throw"A lumino client needs to be passed.";this.apiClient=a,this.usePublicApi=e,this.quota=1048576*(i||1024),this.usePersistentStorage=t;this.saveIndex=Er((()=>{const e=[];for(const t of this.cache.values())e.push({id:t.id,time:t.time.valueOf(),size:t.size,hash:t.hash,itemType:t.itemType,mimeType:t.mimeType,itemName:t.itemName});this._set("index",e).then((function(){})).catch((function(e){console.error("Error saving cache index: "+e)}))}),1e3)}async init(){return await super.init(),this.initFromStorage()}getQuota(){return this.quota}setQuota(e){this.quota=e,this.checkQuota()}getCount(){return this.cache.size}getSize(){return this.size}async initFromStorage(){if(this.usePersistentStorage){const e=await this._get("index","application/json");if(e&&Array.isArray(e))for(const t of e)t.time=P(t.time),this.cache.set(t.id,t),this.size+=t.size;else await this._clear(),this.saveIndex()}this.ready=!0,u.$emit("itemCache:cacheReady"),u.$emit("itemCache:cacheChange"),u.$on("item:rename",(e=>this.handleRename(e)))}async addToStorage(e,t){if(this.usePersistentStorage){const a={id:e.id,time:P(e.time.toDate()),size:e.size,hash:e.hash,itemType:e.itemType,mimeType:e.mimeType,itemName:e.itemName};await this._set(`blob_${e.id}`,t),this.cache.set(e.id,a),this.saveIndex()}this.size+=e.size}waitUntilReady(){const e=this;return new Promise(((t,a)=>{try{e.ready?t():u.$on("itemCache:cacheReady",(()=>{t()}))}catch(e){a(e)}}))}findObject(e){return this.cache.get(e)}getEntries(){return this.cache.values()}clear(){for(const e of this.cache.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);this.cache.clear(),u.$emit("itemCache:cacheChange"),this.usePersistentStorage&&this._clear().then((function(){console.log("Cache storage cleared.")})).catch((function(e){console.error(e)}))}clearMemory(){for(let e of this.cache.values())e.objectUrl&&(URL.revokeObjectURL(e.objectUrl),delete e.objectUrl);u.$emit("itemCache:cacheChange")}checkQuota(e=0){let t=this.size+e;if(t>this.quota){const e=[...this.cache.entries()].sort((function(e,t){return e[1].time.valueOf()-t[1].time.valueOf()}));let a=0;for(;t>this.quota&&a<e.length;){const i=e[a][1];i.objectUrl||(t-=i.size,this.removeObjectFromCache(i.id)),a++}}}removeObjectFromCache(e){const t=this.cache.get(e);t&&(t.objectUrl&&URL.revokeObjectURL(t.objectUrl),this.cache.delete(e),this.size-=t.size,this.usePersistentStorage&&(this._remove(`blob_${t.id}`).then((function(){console.log(`Removed blob for ${e} from cache`)})).catch((function(t){console.error(`Error removing blob for ${e} from cache: ${t}`)})),this.saveIndex()))}getIdFromUrl(e){return this.urlToIdMap.has(e)?this.urlToIdMap.get(e):null}getById(e){const t=this.findObject(e);return t?(this.logging&&console.log("Retrieving from cache: "+e),t.time=P(),t):(this.logging&&console.error("Object not in cache: "+e),null)}getObjectUrl(e){const t=this.getIdFromUrl(e);if(!t)return console.error("Could not find URL in cache: "+e),"";const a=this.getById(t);return a?a.objectUrl:(console.error("Could not find Id in cache: "+t),"")}async getBufferById(e){const t=await this.getBlobById(e);return t?await new Response(t).arrayBuffer():null}async getBlobById(e){const t=this.getById(e);return t?await fetch(t.objectUrl).then((e=>e.blob())):null}async loadFromStorage(e){if(e.objectUrl)return!0;let t=null;return!!this.usePersistentStorage&&(t=await this._get(`blob_${e.id}`),!!t&&(e.objectUrl=URL.createObjectURL(t),e.time=P(),this.saveIndex(),u.$emit("itemCache:cacheChange"),!0))}getCacheKey(e,t){return t&&"item"!==t.type?e+"_lod"+t.index:e}_getLodLevelUrl(e,t){let a;return a=t&&"item"!==t.type?this.apiClient.getAttachmentDownloadUrl(e,"lod",t.index):this.apiClient.getDownloadUrl(e),a}async loadItem(e,t,a){let i=0;for(;;)try{let i;if(this.usePublicApi)i=t&&"item"!==t.type?await this.apiClient.downloadPublicAttachment(e,"lod",t.index,void 0,a):await this.apiClient.publicDownloadItem(e,a);else try{i=t&&"item"!==t.type?await this.apiClient.downloadAttachment(e,"lod",t.index,void 0,a):await this.apiClient.downloadItem(e,a)}catch{i=t&&"item"!==t.type?await this.apiClient.downloadPublicAttachment(e,"lod",t.index,void 0,a):await this.apiClient.publicDownloadItem(e,a)}return i}catch(t){if(console.log(t),i++,!(i<3))return u.$emit("client:fatalError",`Failed to download item ${e}`),null;console.debug(`Failed attempts to download item ${e}: ${i}. Trying again...`)}}async addItemToCache(e,t,a,i){try{const n=this.getCacheKey(e,t),r=this.findObject(n);if(r&&(a||!this.apiClient.getItemHash||this.usePublicApi||(a=await this.apiClient.getItemHash(e)),a&&r.hash===a&&(this.logging&&console.log("Item already in cache: "+e),await this.loadFromStorage(r))))return r.url||(r.url=this._getLodLevelUrl(e,t)),this.urlToIdMap.set(r.url,n),this.cache.set(n,r),r;i&&i(0);let s=await this.loadItem(e,t,i);if(!s)return console.error("Was not able to load object into cache: "+n),null;i&&i(100);const o=this._getLodLevelUrl(e,t),l=URL.createObjectURL(s.blob),c={id:n,url:o,time:P(),objectUrl:l,size:s.blob.size,hash:s.hash,itemType:s.itemType,mimeType:s.mimeType,itemName:s.itemName};return this.checkQuota(c.size),await this.addToStorage(c,s.blob),this.cache.set(n,c),this.urlToIdMap.set(o,n),this.saveIndex(),u.$emit("itemCache:cacheChange"),this.logging&&console.log("Added item to cache: ",c),c}catch(e){return console.error(e),null}}getObjectCount(){return this.cache.size}getObjectSize(){let e=0;for(const t of this.cache.values())e+=t.size;return e}handleRename({id:e,newName:t}){const a=this.cache.get(e);a&&(a.itemName=t,this.saveIndex(),u.$emit("itemCache:cacheChange"))}}class Dr extends Jn{apiClient;ready=!1;maxNumItems=1e4;constructor(e){if(super("lumino","folders",1),!e)throw"A lumino client needs to be passed.";this.apiClient=e}async init(){await super.init(),await this.checkStorage(),this.ready=!0}clear(){return this._clear()}async checkStorage(){const e=await this._keys();let t=e.length-this.maxNumItems;if(t>0){t=Math.floor(this.maxNumItems/2);const a=[];for(let i=0;i<t;i++)a.push(this._remove(e[i]));await Promise.all(a)}}async getFolderListing(e){return this.ready?this._get(e,"application/json"):null}async getItemListing(e){if(!this.ready)return null;const t=await this._get("items_"+e,"application/json");if(!t)return null;const a=await this.getFolderListing(e);return a&&a.parent&&new Date(t.cachedAt).getTime()>new Date(a.parent.updatedAt).getTime()?t.data:null}async getFolderACLs(e,t){if(!this.ready)return null;const a=await this._get("acl_"+e,"application/json");return a&&Date.now()-a.cachedAt<t?(delete a.cachedAt,a):null}async refreshCacheForFolder(e){const t=await this.getFolderListing(e);await this.addFolderListing(e,t)}async addFolderListing(e,t){this.ready&&(await this._set(e,{...t,cachedAt:new Date}),await this.checkStorage())}async addItemListing(e,t){this.ready&&(await this._set("items_"+e,{data:t,cachedAt:new Date}),await this.checkStorage())}async addACL(e,t){this.ready&&(await this._set("acl_"+e,{...t,cachedAt:new Date}),await this.checkStorage())}}class Rr extends Jn{apiClient;constructor(e){if(super("lumino","thumbs",1),!e)throw"A lumino client needs to be passed.";this.apiClient=e}clear(){this._clear()}async _loadThumbnail(e,t){try{return await this.apiClient.getThumbnail(e,t)}catch{try{return await this.apiClient.getPublicThumbnail(e,t)}catch{return null}}}async get(e,t,a,i){if(!t)throw"Cannot retrieve item thumbnail from cache without knowing size!";let n=await this._get(e,"application/json");if(n&&n.hash===a&&n.timestamp===i){for(const e of n.thumbnails)if(e.size===t){if(e.data)return e.data;n.thumbnails.removeObject(e);break}let a=await this._loadThumbnail(t,e);return a&&(n.thumbnails.push({size:t,data:a}),await this._set(e,n)),a}let r=await this._loadThumbnail(t,e);if(a||i){let s=[];r&&s.push({size:t,data:r}),n={id:e,hash:a,timestamp:i,thumbnails:s},await this._set(e,n)}return r}}class Pr{apiClient;cache=new Map;constructor(e){this.apiClient=e,this.cache=new Map}async resolve(e){let t=this.cache.get(e);if(!t)try{t=this.apiClient.getUserPublicInfo(e,this.apiClient.requestClientId,32),this.cache.set(e,t)}catch(e){console.error(e)}return t}}class Lr{apiClient;cache=new Map;constructor(e){this.apiClient=e}async resolve(e){let t=this.cache.get(e);if(!t)try{t=this.apiClient.getGroupPublicInfo(e,this.apiClient.requestClientId,32),this.cache.set(e,t)}catch(e){console.error(e)}return t}}class Br{apiClient;cache=new Map;constructor(e){this.apiClient=e}async get(e,t,a,i,n=!1){const r=`${e}_${t}_${a}${void 0===i?"":`_${i}`}`,s=this.cache.get(r);if(s)return s;try{const s=new Promise((async r=>{try{let s;s=n?await this.apiClient.downloadPublicAttachment(e,t,a,i,void 0):await this.apiClient.downloadAttachmentPOP(e,t,a,i,void 0);r(URL.createObjectURL(s.blob))}catch(e){r(null)}}));return this.cache.set(r,s),s}catch(e){return console.warn(`Attachment ${r} not available.`),null}}invalidateAttachment(e,t,a,i){let n=`${e}_${t}`;null!=a&&(n+=`_${a}`);for(const e of this.cache.keys()){const t=null==i||e.endsWith(`_${i}`);e.startsWith(n)&&t&&this.cache.delete(e)}}}class Or{apiClient;itemRepo;jobManager;items=[];hasExternalResources=!1;totalSize=0;affectedFolderIds=new Set;constructor(e){this.apiClient=e,this.itemRepo=e.getItemRepo(),this.jobManager=e.getJobManager()}_updateQuota(){this.apiClient.eventBus.$emit("quota:update")}async getPreviousVersions(e,t){const a=[];t=t||"published";const i=await this.apiClient.createFolder({name:t,parent:e,returnIfExists:!0}),n=await this.apiClient.getFoldersInFolderList(i,{folderAsItemType:"Package"});for(const e of n.children)e.item&&a.push({itemId:e.item._id,folderId:e._id,version:e.name,name:e.item.name,filesize:0|e.item.filesize,visibility:e.item.visibility});return a}async verify(e){const t=this,a=new Map,i=new Map;e=e?await this.itemRepo.loadItem(e._id,{recursive:!0}):this.itemRepo.activeItem;const n=await r(e.folder);async function r(e){try{if(e){const a=e._id?e._id:e;if(i.has(a))return i.get(a);{const e=(await t.apiClient.getFolderPath(a)).path;return i.set(a,e),e}}return"/"}catch{return""}}await this.itemRepo.traverseItems((async function(e){const t={_id:e._id,name:e.name,type:e.type,size:e.totalSize,path:await r(e.folder),item:e,external:!1};t.path.startsWith(n)?t.path=t.path.slice(n.length):t.external=!0,a.set(e._id,t)})),this.items=Array.from(a.values()),this.hasExternalResources=!1,this.totalSize=0;for(const e of this.items)e.external&&(this.hasExternalResources=!0),this.totalSize+=e.size;return!this.hasExternalResources}getItems(){return this.items}async unpackToProject(e,t,a,i){a&&(t=await this.apiClient.createFolder({name:a,parent:t,returnIfExists:!0}));const n=await this.apiClient.getItem(e);n.folder===t&&await this.apiClient.renameItem(e,n.name+" (Unpackaged)");const r=await this.apiClient.createFolder({name:n.name,parent:t,fixNameCollisions:!0}),s=await this.jobManager.execute("JS:Unpackage",[{_id:e,isFolder:!1}],[{name:"Destination Folder",value:r},{name:"Make Destination Visible",value:!1}],i);if(this._updateQuota(),3===s.state){const t=s.log.trim().split(";");if(2!==t.length||"UNPACKAGED"!==t[0])throw new A("Unpacking failed. Did not get unpackaged item id!");const a=t[1].trim();return await this.apiClient.renameItem(a,n.name),await this.itemRepo.replaceLink(e,a),a}if(2===s.state)throw new A("Unpacking failed: "+s.error)}async copyItemToProject(e,t,a,i){return(await this.copyItemsToProject([{_id:e,isFolder:!1}],t,a,i))[0].newId}async copyItemsToProject(e,t,a,i){a=a||"packages",t=await this.apiClient.createFolder({name:a,parent:t,returnIfExists:!0}),this.affectedFolderIds.add(t);const n=[];if(e.length){const a=await this.jobManager.execute("JS:CloneItem",e,[{name:"Deep Clone",value:!1},{name:"Destination Folder",value:t},{name:"Exclude Types",value:""},{name:"Make Private",value:!0}],i);if(this._updateQuota(),3===a.state){if(!a.log.trim().length)throw new A("Copy job returned no results.");{const e=a.log.split("\n").reverse();for(const t of e){const e=t.trim().split(";");if(3===e.length){const t=e[1],a=e[2];await this.itemRepo.replaceLink(t,a),n.push({oldId:t,newId:a})}}}}else if(2===a.state)throw new A("Copying of items failed: "+a.error)}return n}async copyToProject(e,t,a){const i=[];for(const e of this.items)e.external&&i.push({_id:e._id,isFolder:!1});return this.copyItemsToProject(i,e,t,a)}async unpublish(e){await this.apiClient.makeItemPrivate(e,!1,!1)}async publish(e,t,a,i,n,r,s,o){const l=e.version;i=i||`published/${l.major}.${l.minor}.${l.revision}`,n=void 0===n||n,r=void 0===r||r,this.affectedFolderIds.add(a);let u,c=a;if(i){const e=i.split("/");for(const t of e)c=await this.apiClient.createFolder({name:t,parent:c,returnIfExists:!0}),this.affectedFolderIds.add(c),u||(u=c)}const d=(await this.apiClient.getFoldersInFolderList(a)).children.map((e=>e._id)).filter((e=>e!==u)).join(","),p=await this.jobManager.execute("JS:CreatePackage",[{_id:e._id,isFolder:!1}],[{name:"Folders To Include",value:d},{name:"Destination Folder",value:c},{name:"Item Name",value:t},{name:"Make Public",value:!!n},{name:"Copy External",value:!!r},{name:"Always Create New Package",value:!!s},{name:"Make Cloneable",value:!!o}]);if(this._updateQuota(),2===p.state)throw new A("Packaging failed: "+p.error);this.apiClient.eventBus.$emit("folder:changed",Array.from(this.affectedFolderIds.values()))}}class $r{id;job;nextCheckMs;constructor(e,t,a){this.id=e,this.job=a,this.nextCheckMs=t}}class Ur{apiClient;jobs=new Map;constructor(e){this.apiClient=e}getJobs(){return Array.from(this.jobs.values())}async execute(e,t,a,i=void 0,n){const r=this;return new Promise((async(s,o)=>{try{const o=async()=>{try{u.job=await r.apiClient.getJobState(l);let e=!1;switch(u.job.state){case 0:case 1:try{i&&i(u.job)}catch(e){console.error("Error calling progress callback: ",e)}break;case 2:case 3:console.log("Job is done."),e=!0,s(u.job)}e?r.jobs.delete(l):(u.nextCheckMs=Math.min(2*u.nextCheckMs,8e3),setTimeout(o,u.nextCheckMs))}catch(e){console.error("Error fetching job state: "+e)}},l=await r.apiClient.createJob({type:e,elements:t,parameters:a,requiredParameters:n}),u=new $r(l,1e3);r.jobs.set(l,u),setTimeout(o,u.nextCheckMs)}catch(e){o(e)}}))}}const jr={mp3:{name:"Mpeg Audio Layer 3",itemType:"Audio",itemTypeCollection:"Audio Collection",collectionEntryName:"AudioItems",folderName:"audio",defaultAction:"Use",actions:["Skip","Use"]},hdr:{name:"HDR Image",itemType:"HDR Image",folderName:"envmaps",defaultAction:"Use",actions:["Skip","Use"]},glb:{name:"Gltf Binary",itemType:"Mesh",itemTypeCollection:"Mesh Collection",collectionEntryName:"MeshItems",folderName:"meshes",defaultAction:"Use",actions:["Skip","Use"]},png:{name:"Portable Network Graphics",itemType:"Image",folderName:"textures",defaultAction:"Use",actions:["Skip","Use"]},jpg:{name:"JPEG",itemType:"Image",folderName:"textures",defaultAction:"Use",actions:["Skip","Use"]},jpeg:{name:"JPEG",itemType:"Image",folderName:"textures",defaultAction:"Use",actions:["Skip","Use"]},lua:{name:"Lua",itemType:"Script",folderName:"scripts",defaultAction:"Use",actions:["Skip","Use"]},ttf:{name:"True Type Font",itemType:"Font",folderName:"fonts",defaultAction:"Use",actions:["Skip","Use"]},otf:{name:"Open Type Font",itemType:"Font",folderName:"fonts",defaultAction:"Use",actions:["Skip","Use"]},unknown:{name:"Unsupported",itemType:"Unknown",defaultAction:"Skip",actions:["Skip"],invisible:!0}},zr={Audio:"audio","Audio Collection":"audio","HDR Image":"envmaps",Mesh:"meshes","Mesh Collection":"",Script:"scripts",Material:"materials","Background Shader":"background shaders","Pixel Shader":"pixel shaders","Vertex Shader":"vertex shaders",Image:"textures",Scene:"prefabs",Font:"fonts"};function Wr(e,t){let a=jr[t];a||(a=jr.unknown),e.size=e.blob?e.blob.size:0,e.type=a.name,e.collectionType=a.itemTypeCollection,e.collectionEntryName=a.collectionEntryName,e.action=a.defaultAction,e.actions=a.actions,e.folderName=a.folderName,e.itemType=a.itemType,e.name=function(e,t){let a=e.lastIndexOf(".");return e.substring(0,a<0?e.length:a)+"."+t}(e.name,t)}class Yr{name;blob;processing=!1;progress=0;size=0;type;collectionType;collectionEntryName;action;actions;folderName;itemType;constructor(e,t,a){this.name=e,this.blob=t,Wr(this,a)}}class Hr{apiClient;itemRepo;jobManager;items=[];mainItem;totalSize=0;oldMainItemId;originalItemIds=[];affectedFolderIds=new Set;packageId;converter;supportedExtensions;hasExternalResources=!1;constructor(e){this.apiClient=e,this.itemRepo=e.getItemRepo(),this.jobManager=e.getJobManager();const t=[];for(const e in jr)jr[e].invisible||t.push(`.${e.toUpperCase()}`);this.supportedExtensions=t.sort(((e,t)=>e.localeCompare(t)))}_updateQuota(){this.apiClient.eventBus.$emit("quota:update")}_addAffectedFolder(e){"object"==typeof e&&e._id?this.affectedFolderIds.add(e._id):"string"==typeof e?this.affectedFolderIds.add(e):console.error("Invalid affected folder to add: ",e)}getAffectedFolderIds(){return Array.from(this.affectedFolderIds.values())}getSupportedExtensions(){return this.supportedExtensions}setConverter(e){this.converter=e}setItems(e){this.items=e}async scan(e){const t=this,a=new Map,i=new Map;this.mainItem=await this.itemRepo.loadItem(e,{recursive:!0}),this.oldMainItemId=this.mainItem._id;const n=await r(this.mainItem.folder);async function r(e){try{if(e){const a=e._id?e._id:e;if(i.has(a))return i.get(a);{const e=(await t.apiClient.getFolderPath(a)).path;return i.set(a,e),e}}return"/"}catch(e){return console.error(e),""}}await this.itemRepo.traverseItems((async function(e){const i={_id:e._id,name:e.name,type:e.type,size:e.totalSize,path:await r(e.folder),item:e,external:!1};i.path.startsWith(n)?i.path=i.path.slice(n.length):i.external=!0,t._addAffectedFolder(e.folder),a.set(e._id,i)}),this.mainItem),this.items=Array.from(a.values()),this.originalItemIds=this.items.map((e=>e._id)),this.hasExternalResources=!1,this.totalSize=0;for(const e of this.items)e.external&&(this.hasExternalResources=!0),this.totalSize+=e.size;return this.items}getItems(){return this.items}async saveMainItemChanges(){const e=this.mainItem;await this.apiClient.updateItem({_id:e._id,name:e.name,shortDescription:e.shortDescription,description:e.description,tags:e.tags,categories:e.categories,visibility:e.visibility,contributors:e.contributors,version:e.version})}async createAssetFolder(e,t){let a=e;const i=t.split("/");this._addAffectedFolder(e);for(const e of i)a=await this.apiClient.createFolder({name:e,parent:a,returnIfExists:!0}),this._addAffectedFolder(a);const n=await this.apiClient.getItemsInFolderList(a,!0);if(n&&n.length)throw new Error("Asset folder already exists and is not empty!");return a}createStandardAssetFolderPath(e){let t=zr[e.type];return t||(t=e.type.toLowerCase()+"s"),`assets/${t}/${e.name}`}async executeActions(){if(!this.converter)throw new Error("No converter is configured. Cannot execute actions on items.");return this.converter(this.items,Wr)}async createAsset(e,t=!1,a){const i=[];for(const e of this.items)i.push(e._id);if(this._addAffectedFolder(e),i.length)if(t){await this.apiClient.moveItems({items:i,dest:e})!==i.length&&console.warn("Not all items could be moved. Most likely due to permissions."),this.mainItem.folder=e}else{const t=await this.jobManager.execute("JS:CloneItem",[{_id:this.mainItem._id,isFolder:!1}],[{name:"Deep Clone",value:!0},{name:"Destination Folder",value:e},{name:"Exclude Types",value:""}],a);if(3===t.state){const a=t.log.split("\n").reverse()[0].split(";");this.mainItem={...this.mainItem,_id:a[2],folder:e}}else if(2===t.state)throw new A("Copying of items failed: "+t.error)}"Main"!==this.mainItem.name&&(this.mainItem.originalName=this.mainItem.name,this.mainItem.name="Main",await this.apiClient.renameItem(this.mainItem._id,this.mainItem.name));const n=await this.apiClient.getItem(this.mainItem._id);return n.flags||(n.flags=[]),n.flags.includes("original")||n.flags.push("original"),await this.apiClient.updateItem(n),this._updateQuota(),this.mainItem._id}async createPackage(e,t=!1,a=!1){let i,n=this.mainItem.folder;if(this._addAffectedFolder(n),void 0===e){const t=this.mainItem.version||{major:1,minor:0,revision:0};e=`published/${t.major}.${t.minor}.${t.revision}`}if(void 0===t&&(t=!0),e){const t=e.split("/");for(const e of t)n=await this.apiClient.createFolder({name:e,parent:n,returnIfExists:!0}),this._addAffectedFolder(n),i||(i=n)}const r=(await this.apiClient.getFoldersInFolderList(this.mainItem.folder)).children.map((e=>e._id)).filter((e=>e!==i)).join(","),s=await this.jobManager.execute("JS:CreatePackage",[{_id:this.mainItem._id,isFolder:!1}],[{name:"Folders To Include",value:r},{name:"Destination Folder",value:n},{name:"Item Name",value:this.mainItem.originalName||this.mainItem.name},{name:"Make Public",value:!!t},{name:"Copy External",value:!!a}]);if(this._updateQuota(),2===s.state)throw new A("Packaging failed: "+s.error);const o=s.log.split("\n").reverse()[0].split(";");this.packageId=o[2]}async replaceReferences(){await this.itemRepo.replaceLink(this.oldMainItemId,this.packageId)}async deleteOriginalItems(){await this.apiClient.deleteItem(this.originalItemIds)}sendFolderRefreshEvent(){this.apiClient.eventBus.$emit("folder:changed",this.getAffectedFolderIds())}async processUploads(e){const t=[];for(const a of e)if("application/zip"===a.type||"application/x-zip-compressed"===a.type){const e=new s;try{const i=[];(await e.loadAsync(a)).forEach(((e,a)=>{const n=a.name.split("/").pop();if(!n.startsWith(".")){const e=n.split(".").pop(),r=a.async("blob");i.push(r),r.then((function(i){const n=new Yr(a.name,i,e);t.push(n)}))}})),await Promise.all(i)}catch(e){console.error("Error reading the ZIP file:",e)}}else{const e=a.name.split(".").pop(),i=new Yr(a.name,a,e);t.push(i)}return t}detectAssets(e){let t,a,i,n=0;for(const r of e)if("Use"===r.action)if(void 0===t)t=r.itemType,a=r.collectionType,i=r.folderName,n++;else{if(t!==r.itemType)return{valid:!1,reason:"Mixed item types found. To create an asset, upload a single type of file for example only meshes."};n++}return 0===n?{valid:!1,reason:"There are no files we can use to create an asset."}:n>1&&!a?{valid:!1,reason:"Cannot create collections of this type."}:{valid:!0,assetType:n>1?a:t,itemCount:n,folderName:i}}_filterUploadFiles(e){let t=[];for(const a of e)"Use"===a.action&&t.push(a);return t}createNewItem(){return{name:"New asset",type:"",description:"",shortDescription:"",tags:[],flags:["original"],categories:[],license:"CC0",allowConversation:!0,version:{major:1,minor:0,revision:0}}}async createAssetFromFiles(e,t,a,i=!1,n=!1){const r=this.detectAssets(e);if(r.assetType!==a.type)throw new Error("Asset type not valid for these items.");if(!r.valid)throw new Error(r.reason||"No valid asset detected.");let s=await this.apiClient.createFolder({name:r.folderName,parent:t,returnIfExists:!0}),o=await this.apiClient.createFolder({name:a.name,parent:s,returnIfExists:!0}),l=!1;if(0===(await this.apiClient.getItemsInFolderList(o)).length){(await this.apiClient.getFoldersInFolderList(o)).children.length&&(l=!0)}else l=!0;if(l){if(!i)throw new Error("Cannot create asset, target folder is not empty!");await this.apiClient.deleteFolder(o),o=await this.apiClient.createFolder({name:a.name,parent:s})}let u,c=this._filterUploadFiles(e);if(1===c.length){const e=c[0];e.processing=!0,e.progress=0,u=await this.apiClient.uploadAndCreate(o,e.blob,e.name,{nameOverride:"Main",flags:"original"},(function(t){e.progress=t})),this._updateQuota(),e.action="Skip"}else{let e=await this.apiClient.createFolder({name:"resources",parent:o}),t={},a=[],i=0;for(const n of c){n.processing=!0,n.progress=0;const r=await this.apiClient.uploadAndCreate(e,n.blob,n.name,void 0,(function(e){n.progress=e}));this._updateQuota(),n.action="Skip",t[`${n.collectionEntryName}[${i}]->Name`]="",a.push({usage:`MeshItems[${i}]->Mesh`,to:r}),i++}u=await this.apiClient.createItem({type:r.assetType,name:"Main",flags:["original"],folder:o,fixNameCollisions:!0,attributes:t,links:a})}return a._id=u,a.folder=o,this.mainItem=a,n?{assetItemId:u,assetTypeFolderId:s,assetFolderId:o}:u}}class Gr{apiClient;itemRepo;constructor(e){this.apiClient=e,this.itemRepo=e.getItemRepo()}grab(e,t,a,i){i=i||{};const n=[];for(const r of a){const a=this._serializeBlockFields(r),s=this._serializeScripts(r),o={type:"block",item:e._id,field:t.name,path:"",block:{id:r.id,type:r.type||"Group",fields:a,scripts:s,children:[]}};i.omitPath||(o.path=this._getBlockPath(r)),i.withChildren&&(o.block.children=this.grab(e,t,r.blocks||[],{withChildren:!0,returnArray:!0})),n.push(o)}if(i.returnArray)return n;const r={type:"serializedBlocks",data:n};return i.noStringify?r:JSON.stringify(r,null,2)}async put(e,t,a,i={}){e=this.validateMessage(e);const n=[];for(const r of e.data){const e=await this._putBlock(r,t,a,i);e&&n.push(e)}return n}validateMessage(e){if("string"==typeof e&&(e=JSON.parse(e)),"serializedBlocks"!==e.type)throw new Error("Data must be a serialized block message. Format is wrong.");if(!Array.isArray(e.data))throw new Error("The contained data is not an array.");return e}async clone(e,t,a,i,n={}){const r=this.grab(i,t,[e],{withChildren:!0,noStringify:!0});return this.put(r,t,a,n)}_updateScriptFieldReferences(e,t){const a=new Map,i=(e,t)=>{a.set(e.block.id,t.id);const n=e.block.children||[],r=t.blocks||[];for(let e=0;e<n.length;e++)i(n[e],r[e])};i(e,t),this.itemRepo.updateScriptFieldReferencesFromMap(a,t)}async _putBlock(e,t,a,i={},n=!1){if(!e.block||!e.block.type||!e.block.fields)return null;const r=e.block,s=this._findItemById(e.item)??this.itemRepo.activeItem;let o=a;o||(o=this._findParentBlock(s,e.field,e.path));const l={};if(Array.isArray(r.fields))for(const e of r.fields){const{name:t,type:a,value:n,linkto:r}=e;if("Separator"!==a)if(i.fieldOverrides&&t in i.fieldOverrides)l[t]=i.fieldOverrides[t];else if(r){const e=this.itemRepo.getLoadedItem(r);l[t]=e||await this.itemRepo.loadItem(r)}else l[t]=n}const u=i.dontCopyScripts?[]:[...r.scripts],c=await this._createUnproxifiedBlock(r.type,l,u,t,s),d={...i,parentPosition:void 0,fieldOverrides:void 0};if(!c)return console.warn(`Could not create block of type ${r.type}. Skipping.`),null;if(Array.isArray(r.children))for(const e of r.children)await this._putBlock(e,t,c,d,!0);if(n&&o)return"number"==typeof i.parentPosition?o.blocks.splice(i.parentPosition,0,c):o.blocks.push(c),c.parent=o,c;i.dontCopyScripts||this._updateScriptFieldReferences(e,c);return this._proxifyAndAttachTree(c,o,s,i.parentPosition)}async _createUnproxifiedBlock(e,t,a,i,n){let r=ee.instance.getTemplate(n.packageType||n.type,i.name,e);if(!r)return null;if(t){const e=r.template.clone().specialize(t);r={displayName:r.displayName,typeName:r.typeName,template:e,inputs:r.inputs,outputs:r.outputs}}const s=new ae(void 0,void 0,r.typeName,void 0,r.displayName,n),o=await this.itemRepo.createFieldsForItem(s,r.template,n,!0);return s.setFields(o),s.blocks=[],await this.itemRepo.createScriptsForItem(s,a,n,!1),s}_proxifyAndAttachTree(e,t,a,i){const n=e=>{if(Array.isArray(e.blocks)&&e.blocks.length)for(const t of e.blocks)n(t);const t=e.blocks.map((e=>g.instance.proxyBlock(e,a)));e.blocks=g.instance.proxyBlockArray(t,e,a),e.scripts=g.instance.proxyScriptArray(e.scripts,e,a)};n(e),e.parent=t;const r=g.instance.proxyBlock(e,a);return"number"==typeof i?t.blocks.splice(i,0,r):t.blocks.push(r),r}_findItemById(e){return this.itemRepo.findLoadedItem(e)}_findItemField(e,t){if(!e.fieldInstances)return null;for(const a of e.fieldInstances)if(a.name===t)return a;return null}_findParentBlock(e,t,a){const i=this._findItemField(e,t);if(!i)return null;const n=a.split("/");let r=i.blocks,s=null;for(const e of n)s=r[e],r=s.blocks;return s}_getBlockIndex(e){if(!e.parent)return 0;let t=0;for(const a of e.parent.blocks){if(e.id===a.id)return t;t++}throw new Error("Could not find block in parent block array!")}_getBlockPath(e){const t=[];let a=e;for(;a;)t.push(this._getBlockIndex(a)),a=a.parent;return"/"+t.reverse().join("/")}_serializeBlockFields(e){const t=[];if(!Array.isArray(e.fields))return t;for(const a of e.fields)switch(a.type){case"Link":t.push({name:a.name,linkto:a.value?._id});break;case"Attribute":t.push({name:a.name,value:a.value});break;case"Separator":t.push({name:a.name,type:"Separator"})}return t}_serializeScripts(e){const t=[];if(!Array.isArray(e.scripts))return t;for(const a of e.scripts){const e=[],i={item:a.item?.value?._id,fields:e};for(const t of a.fields)e.push({name:t.name,value:t.value});t.push(i)}return t}}function qr(){throw new Error("setTimeout has not been defined")}function Zr(){throw new Error("clearTimeout has not been defined")}Array.prototype.pushAll||(Array.prototype.pushAll=function(e){for(const t of e)this.push(t)}),Array.prototype.removeObject||(Array.prototype.removeObject=function(e){const t=this.indexOf(e);return t>-1&&(this.splice(t,1),!0)}),Array.prototype.moveObjectToArray||(Array.prototype.moveObjectToArray=function(e,t,a){const i=this.indexOf(e);if(i>-1){return(0,this.moveToArray)(i,t,a)}return!1}),Array.prototype.removeByFilterFunc||(Array.prototype.removeByFilterFunc=function(e){let t=0;for(let a=0;a<this.length;a++)e(this[a])&&(this.splice(a,1),a--,t++);return t}),Array.prototype.clone||(Array.prototype.clone=function(){const e=[];for(const t of this)e.push(t);return e});var Jr=qr,Kr=Zr;function Xr(e){if(Jr===setTimeout)return setTimeout(e,0);if((Jr===qr||!Jr)&&setTimeout)return Jr=setTimeout,setTimeout(e,0);try{return Jr(e,0)}catch(t){try{return Jr.call(null,e,0)}catch(t){return Jr.call(this,e,0)}}}"function"==typeof Ti.setTimeout&&(Jr=setTimeout),"function"==typeof Ti.clearTimeout&&(Kr=clearTimeout);var Qr,es=[],ts=!1,as=-1;function is(){ts&&Qr&&(ts=!1,Qr.length?es=Qr.concat(es):as=-1,es.length&&ns())}function ns(){if(!ts){var e=Xr(is);ts=!0;for(var t=es.length;t;){for(Qr=es,es=[];++as<t;)Qr&&Qr[as].run();as=-1,t=es.length}Qr=null,ts=!1,function(e){if(Kr===clearTimeout)return clearTimeout(e);if((Kr===Zr||!Kr)&&clearTimeout)return Kr=clearTimeout,clearTimeout(e);try{return Kr(e)}catch(t){try{return Kr.call(null,e)}catch(t){return Kr.call(this,e)}}}(e)}}function rs(e,t){this.fun=e,this.array=t}rs.prototype.run=function(){this.fun.apply(null,this.array)};function ss(){}var os=ss,ls=ss,us=ss,cs=ss,ds=ss,ps=ss,hs=ss;var fs=Ti.performance||{},ms=fs.now||fs.mozNow||fs.msNow||fs.oNow||fs.webkitNow||function(){return(new Date).getTime()};var ys=new Date;var gs={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];es.push(new rs(e,t)),1!==es.length||ts||Xr(ns)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:os,addListener:ls,once:us,off:cs,removeListener:ds,removeAllListeners:ps,emit:hs,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*ms.call(fs),a=Math.floor(t),i=Math.floor(t%1*1e9);return e&&(a-=e[0],(i-=e[1])<0&&(a--,i+=1e9)),[a,i]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-ys)/1e3}};const bs=()=>new Map,vs=e=>{const t=bs();return e.forEach(((e,a)=>{t.set(a,e)})),t},ws=(e,t,a)=>{let i=e.get(t);return void 0===i&&e.set(t,i=a()),i},_s=()=>new Set,As=e=>e[e.length-1],ks=(e,t)=>{for(let a=0;a<t.length;a++)e.push(t[a])},Ss=Array.from,Ns=Array.isArray;class Ts{constructor(){this._observers=bs()}on(e,t){return ws(this._observers,e,_s).add(t),t}once(e,t){const a=(...i)=>{this.off(e,a),t(...i)};this.on(e,a)}off(e,t){const a=this._observers.get(e);void 0!==a&&(a.delete(t),0===a.size&&this._observers.delete(e))}emit(e,t){return Ss((this._observers.get(e)||bs()).values()).forEach((e=>e(...t)))}destroy(){this._observers=bs()}}class Ms{constructor(){this._observers=bs()}on(e,t){ws(this._observers,e,_s).add(t)}once(e,t){const a=(...i)=>{this.off(e,a),t(...i)};this.on(e,a)}off(e,t){const a=this._observers.get(e);void 0!==a&&(a.delete(t),0===a.size&&this._observers.delete(e))}emit(e,t){return Ss((this._observers.get(e)||bs()).values()).forEach((e=>e(...t)))}destroy(){this._observers=bs()}}const xs=Math.floor,Cs=Math.abs,Vs=(e,t)=>e<t?e:t,Is=(e,t)=>e>t?e:t,Es=Math.pow,Fs=e=>0!==e?e<0:1/e<0,Ds=64,Rs=128,Ps=127,Ls=Number.MAX_SAFE_INTEGER,Bs=Number.isInteger||(e=>"number"==typeof e&&isFinite(e)&&xs(e)===e),Os=String.fromCharCode,$s=/^\s*/g,Us=/([A-Z])/g,js=(e,t)=>(e=>e.replace($s,""))(e.replace(Us,(e=>`${t}${(e=>e.toLowerCase())(e)}`))),zs="undefined"!=typeof TextEncoder?new TextEncoder:null,Ws=zs?e=>zs.encode(e):e=>{const t=unescape(encodeURIComponent(e)),a=t.length,i=new Uint8Array(a);for(let e=0;e<a;e++)i[e]=t.codePointAt(e);return i};let Ys="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ys&&1===Ys.decode(new Uint8Array).length&&(Ys=null);class Hs{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Gs=()=>new Hs,qs=e=>{let t=e.cpos;for(let a=0;a<e.bufs.length;a++)t+=e.bufs[a].length;return t},Zs=e=>{const t=new Uint8Array(qs(e));let a=0;for(let i=0;i<e.bufs.length;i++){const n=e.bufs[i];t.set(n,a),a+=n.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),a),t},Js=(e,t)=>{const a=e.cbuf.length;e.cpos===a&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*a),e.cpos=0),e.cbuf[e.cpos++]=t},Ks=Js,Xs=(e,t)=>{for(;t>Ps;)Js(e,Rs|Ps&t),t=xs(t/128);Js(e,Ps&t)},Qs=(e,t)=>{const a=Fs(t);for(a&&(t=-t),Js(e,(t>63?Rs:0)|(a?Ds:0)|63&t),t=xs(t/64);t>0;)Js(e,(t>Ps?Rs:0)|Ps&t),t=xs(t/128)},eo=new Uint8Array(3e4),to=eo.length/3,ao=zs&&zs.encodeInto?(e,t)=>{if(t.length<to){const a=zs.encodeInto(t,eo).written||0;Xs(e,a);for(let t=0;t<a;t++)Js(e,eo[t])}else no(e,Ws(t))}:(e,t)=>{const a=unescape(encodeURIComponent(t)),i=a.length;Xs(e,i);for(let t=0;t<i;t++)Js(e,a.codePointAt(t))},io=(e,t)=>{const a=e.cbuf.length,i=e.cpos,n=Vs(a-i,t.length),r=t.length-n;e.cbuf.set(t.subarray(0,n),i),e.cpos+=n,r>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Is(2*a,r)),e.cbuf.set(t.subarray(n)),e.cpos=r)},no=(e,t)=>{Xs(e,t.byteLength),io(e,t)},ro=(e,t)=>{((e,t)=>{const a=e.cbuf.length;a-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(2*Is(a,t)),e.cpos=0)})(e,t);const a=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,a},so=new DataView(new ArrayBuffer(4)),oo=(e,t)=>{switch(typeof t){case"string":Js(e,119),ao(e,t);break;case"number":Bs(t)&&Cs(t)<=2147483647?(Js(e,125),Qs(e,t)):(a=t,so.setFloat32(0,a),so.getFloat32(0)===a?(Js(e,124),((e,t)=>{ro(e,4).setFloat32(0,t,!1)})(e,t)):(Js(e,123),((e,t)=>{ro(e,8).setFloat64(0,t,!1)})(e,t)));break;case"bigint":Js(e,122),((e,t)=>{ro(e,8).setBigInt64(0,t,!1)})(e,t);break;case"object":if(null===t)Js(e,126);else if(Ns(t)){Js(e,117),Xs(e,t.length);for(let a=0;a<t.length;a++)oo(e,t[a])}else if(t instanceof Uint8Array)Js(e,116),no(e,t);else{Js(e,118);const a=Object.keys(t);Xs(e,a.length);for(let i=0;i<a.length;i++){const n=a[i];ao(e,n),oo(e,t[n])}}break;case"boolean":Js(e,t?120:121);break;default:Js(e,127)}var a};class lo extends Hs{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Xs(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const uo=e=>{e.count>0&&(Qs(e.encoder,1===e.count?e.s:-e.s),e.count>1&&Xs(e.encoder,e.count-2))};class co{constructor(){this.encoder=new Hs,this.s=0,this.count=0}write(e){this.s===e?this.count++:(uo(this),this.count=1,this.s=e)}toUint8Array(){return uo(this),Zs(this.encoder)}}const po=e=>{if(e.count>0){const t=2*e.diff+(1===e.count?0:1);Qs(e.encoder,t),e.count>1&&Xs(e.encoder,e.count-2)}};class ho{constructor(){this.encoder=new Hs,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(po(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return po(this),Zs(this.encoder)}}class fo{constructor(){this.sarr=[],this.s="",this.lensE=new co}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Hs;return this.sarr.push(this.s),this.s="",ao(e,this.sarr.join("")),io(e,this.lensE.toUint8Array()),Zs(e)}}const mo=e=>new Error(e),yo=()=>{throw mo("Method unimplemented")},go=()=>{throw mo("Unexpected case")},bo=mo("Unexpected end of array"),vo=mo("Integer out of Range");class wo{constructor(e){this.arr=e,this.pos=0}}const _o=e=>new wo(e),Ao=e=>((e,t)=>{const a=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,a})(e,So(e)),ko=e=>e.arr[e.pos++],So=e=>{let t=0,a=1;const i=e.arr.length;for(;e.pos<i;){const i=e.arr[e.pos++];if(t+=(i&Ps)*a,a*=128,i<Rs)return t;if(t>Ls)throw vo}throw bo},No=e=>{let t=e.arr[e.pos++],a=63&t,i=64;const n=(t&Ds)>0?-1:1;if(!(t&Rs))return n*a;const r=e.arr.length;for(;e.pos<r;){if(t=e.arr[e.pos++],a+=(t&Ps)*i,i*=128,t<Rs)return n*a;if(a>Ls)throw vo}throw bo},To=Ys?e=>Ys.decode(Ao(e)):e=>{let t=So(e);if(0===t)return"";{let a=String.fromCodePoint(ko(e));if(--t<100)for(;t--;)a+=String.fromCodePoint(ko(e));else for(;t>0;){const i=t<1e4?t:1e4,n=e.arr.subarray(e.pos,e.pos+i);e.pos+=i,a+=String.fromCodePoint.apply(null,n),t-=i}return decodeURIComponent(escape(a))}},Mo=(e,t)=>{const a=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,a},xo=[e=>{},e=>null,No,e=>Mo(e,4).getFloat32(0,!1),e=>Mo(e,8).getFloat64(0,!1),e=>Mo(e,8).getBigInt64(0,!1),e=>!1,e=>!0,To,e=>{const t=So(e),a={};for(let i=0;i<t;i++){a[To(e)]=Co(e)}return a},e=>{const t=So(e),a=[];for(let i=0;i<t;i++)a.push(Co(e));return a},Ao],Co=e=>xo[127-ko(e)](e);class Vo extends wo{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){var e;return 0===this.count&&(this.s=this.reader(this),(e=this).pos!==e.arr.length?this.count=So(this)+1:this.count=-1),this.count--,this.s}}class Io extends wo{constructor(e){super(e),this.s=0,this.count=0}read(){if(0===this.count){this.s=No(this);const e=Fs(this.s);this.count=1,e&&(this.s=-this.s,this.count=So(this)+2)}return this.count--,this.s}}class Eo extends wo{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const e=No(this),t=1&e;this.diff=xs(e/2),this.count=1,t&&(this.count=So(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Fo{constructor(e){this.decoder=new Io(e),this.str=To(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const Do=crypto.getRandomValues.bind(crypto),Ro=()=>Do(new Uint32Array(1))[0],Po=[1e7]+-1e3+-4e3+-8e3+-1e11,Lo=()=>Po.replace(/[018]/g,(e=>(e^Ro()&15>>e/4).toString(16))),Bo=Date.now,Oo=e=>new Promise(e);Promise.all.bind(Promise);const $o=e=>void 0===e?null:e;let Uo=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},jo=!0;try{"undefined"!=typeof localStorage&&localStorage&&(Uo=localStorage,jo=!1)}catch(e){}const zo=Uo,Wo=Object.assign,Yo=Object.keys,Ho=e=>Yo(e).length,Go=e=>Yo(e).length,qo=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Zo=Object.freeze,Jo=e=>{for(const t in e){const a=e[t];"object"!=typeof a&&"function"!=typeof a||Jo(e[t])}return Zo(e)},Ko=Symbol("Equality"),Xo=(e,t,a=0)=>{try{for(;a<e.length;a++)e[a](...t)}finally{a<e.length&&Xo(e,t,a+1)}},Qo=e=>e,el=(e,t)=>{if(e===t)return!0;if(null==e||null==t||e.constructor!==t.constructor)return!1;if(null!=e[Ko])return e[Ko](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let a=0;a<e.length;a++)if(e[a]!==t[a])return!1;break;case Set:if(e.size!==t.size)return!1;for(const a of e)if(!t.has(a))return!1;break;case Map:if(e.size!==t.size)return!1;for(const a of e.keys())if(!t.has(a)||!el(e.get(a),t.get(a)))return!1;break;case Object:if(Ho(e)!==Ho(t))return!1;for(const a in e)if(!qo(e,a)||!el(e[a],t[a]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!el(e[a],t[a]))return!1;break;default:return!1}return!0},tl=void 0!==gs&&gs.release&&/node|io\.js/.test(gs.release.name)&&"[object process]"===Object.prototype.toString.call(void 0!==gs?gs:0),al="undefined"!=typeof window&&"undefined"!=typeof document&&!tl;let il;const nl=e=>(()=>{if(void 0===il)if(tl){il=bs();const e=gs.argv;let t=null;for(let a=0;a<e.length;a++){const i=e[a];"-"===i[0]?(null!==t&&il.set(t,""),t=i):null!==t&&(il.set(t,i),t=null)}null!==t&&il.set(t,"")}else"object"==typeof location?(il=bs(),(location.search||"?").slice(1).split("&").forEach((e=>{if(0!==e.length){const[t,a]=e.split("=");il.set(`--${js(t,"-")}`,a),il.set(`-${js(t,"-")}`,a)}}))):il=bs();return il})().has(e),rl=e=>$o(tl?gs.env[e.toUpperCase().replaceAll("-","_")]:zo.getItem(e)),sl=e=>nl("--"+e)||null!==rl(e);sl("production");var ol;const ll=tl&&(ol=gs.env.FORCE_COLOR,["true","1","2"].includes(ol))||!nl("--no-colors")&&!sl("no-color")&&(!tl||gs.stdout.isTTY)&&(!tl||nl("--color")||null!==rl("COLORTERM")||(rl("TERM")||"").includes("color")),ul=e=>new Uint8Array(e),cl=al?e=>{let t="";for(let a=0;a<e.byteLength;a++)t+=Os(e[a]);return btoa(t)}:e=>$i.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),dl=al?e=>{const t=atob(e),a=ul(t.length);for(let e=0;e<t.length;e++)a[e]=t.charCodeAt(e);return a}:e=>{const t=$i.from(e,"base64");return((e,t,a)=>new Uint8Array(e,t,a))(t.buffer,t.byteOffset,t.byteLength)};class pl{constructor(e,t){this.left=e,this.right=t}}const hl=(e,t)=>new pl(e,t);"undefined"!=typeof DOMParser&&new DOMParser;const fl=Symbol,ml=fl(),yl=fl(),gl=fl(),bl=fl(),vl=fl(),wl=fl(),_l=fl(),Al=fl(),kl=fl(),Sl={[ml]:hl("font-weight","bold"),[yl]:hl("font-weight","normal"),[gl]:hl("color","blue"),[vl]:hl("color","green"),[bl]:hl("color","grey"),[wl]:hl("color","red"),[_l]:hl("color","purple"),[Al]:hl("color","orange"),[kl]:hl("color","black")},Nl=ll?e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());const t=[],a=[],i=bs();let n=[],r=0;for(;r<e.length;r++){const n=e[r],s=Sl[n];if(void 0!==s)i.set(s.left,s.right);else{if(void 0===n)break;if(n.constructor!==String&&n.constructor!==Number)break;{const e=((e,t)=>{const a=[];for(const[i,n]of e)a.push(t(n,i));return a})(i,((e,t)=>`${t}:${e};`)).join("");r>0||e.length>0?(t.push("%c"+n),a.push(e)):t.push(n)}}}for(r>0&&(n=a,n.unshift(t.join("")));r<e.length;r++){const t=e[r];t instanceof Symbol||n.push(t)}return n}:e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());const t=[],a=[];let i=0;for(;i<e.length;i++){const a=e[i];if(void 0===a)break;if(a.constructor===String||a.constructor===Number)t.push(a);else if(a.constructor===Object)break}for(i>0&&a.push(t.join(""));i<e.length;i++){const t=e[i];t instanceof Symbol||a.push(t)}return a},Tl=_s(),Ml=e=>({[Symbol.iterator](){return this},next:e}),xl=(e,t)=>Ml((()=>{const{done:a,value:i}=e.next();return{done:a,value:a?void 0:t(i)}}));class Cl{constructor(e,t){this.clock=e,this.len=t}}class Vl{constructor(){this.clients=new Map}}const Il=(e,t,a)=>t.clients.forEach(((t,i)=>{const n=e.doc.store.clients.get(i);if(null!=n){const i=n[n.length-1],r=i.id.clock+i.length;for(let i=0,s=t[i];i<t.length&&s.clock<r;s=t[++i])_u(e,n,s.clock,s.len,a)}})),El=(e,t)=>{const a=e.clients.get(t.client);return void 0!==a&&null!==((e,t)=>{let a=0,i=e.length-1;for(;a<=i;){const n=xs((a+i)/2),r=e[n],s=r.clock;if(s<=t){if(t<s+r.len)return n;a=n+1}else i=n-1}return null})(a,t.clock)},Fl=e=>{e.clients.forEach((e=>{let t,a;for(e.sort(((e,t)=>e.clock-t.clock)),t=1,a=1;t<e.length;t++){const i=e[a-1],n=e[t];i.clock+i.len>=n.clock?i.len=Is(i.len,n.clock+n.len-i.clock):(a<t&&(e[a]=n),a++)}e.length=a}))},Dl=(e,t,a,i)=>{ws(e.clients,t,(()=>[])).push(new Cl(a,i))},Rl=e=>{const t=new Vl;return e.clients.forEach(((e,a)=>{const i=[];for(let t=0;t<e.length;t++){const a=e[t];if(a.deleted){const n=a.id.clock;let r=a.length;if(t+1<e.length)for(let a=e[t+1];t+1<e.length&&a.deleted;a=e[1+ ++t])r+=a.length;i.push(new Cl(n,r))}}i.length>0&&t.clients.set(a,i)})),t},Pl=(e,t)=>{Xs(e.restEncoder,t.clients.size),Ss(t.clients.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,a])=>{e.resetDsCurVal(),Xs(e.restEncoder,t);const i=a.length;Xs(e.restEncoder,i);for(let t=0;t<i;t++){const i=a[t];e.writeDsClock(i.clock),e.writeDsLen(i.len)}}))},Ll=e=>{const t=new Vl,a=So(e.restDecoder);for(let i=0;i<a;i++){e.resetDsCurVal();const a=So(e.restDecoder),i=So(e.restDecoder);if(i>0){const n=ws(t.clients,a,(()=>[]));for(let t=0;t<i;t++)n.push(new Cl(e.readDsClock(),e.readDsLen()))}}return t},Bl=(e,t,a)=>{const i=new Vl,n=So(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const n=So(e.restDecoder),r=So(e.restDecoder),s=a.clients.get(n)||[],o=fu(a,n);for(let a=0;a<r;a++){const a=e.readDsClock(),r=a+e.readDsLen();if(a<o){o<r&&Dl(i,n,o,r-o);let e=yu(s,a),l=s[e];for(!l.deleted&&l.id.clock<a&&(s.splice(e+1,0,nd(t,l,a-l.id.clock)),e++);e<s.length&&(l=s[e++],l.id.clock<r);)l.deleted||(r<l.id.clock+l.length&&s.splice(e,0,nd(t,l,r-l.id.clock)),l.delete(t))}else Dl(i,n,a,r-a)}}if(i.clients.size>0){const e=new ql;return Xs(e.restEncoder,0),Pl(e,i),e.toUint8Array()}return null},Ol=Ro;class $l extends Ts{constructor({guid:e=Lo(),collectionid:t=null,gc:a=!0,gcFilter:i=()=>!0,meta:n=null,autoLoad:r=!1,shouldLoad:s=!0}={}){super(),this.gc=a,this.gcFilter=i,this.clientID=Ol(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new pu,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=s,this.autoLoad=r,this.meta=n,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Oo((e=>{this.on("load",(()=>{this.isLoaded=!0,e(this)}))}));const o=()=>Oo((e=>{const t=a=>{void 0!==a&&!0!==a||(this.off("sync",t),e())};this.on("sync",t)}));this.on("sync",(e=>{!1===e&&this.isSynced&&(this.whenSynced=o()),this.isSynced=void 0===e||!0===e,this.isSynced&&!this.isLoaded&&this.emit("load",[this])})),this.whenSynced=o()}load(){const e=this._item;null===e||this.shouldLoad||Mu(e.parent.doc,(e=>{e.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ss(this.subdocs).map((e=>e.guid)))}transact(e,t=null){return Mu(this,e,t)}get(e,t=qu){const a=ws(this.share,e,(()=>{const e=new t;return e._integrate(this,null),e})),i=a.constructor;if(t!==qu&&i!==t){if(i===qu){const i=new t;i._map=a._map,a._map.forEach((e=>{for(;null!==e;e=e.left)e.parent=i})),i._start=a._start;for(let e=i._start;null!==e;e=e.right)e.parent=i;return i._length=a._length,this.share.set(e,i),i._integrate(this,null),i}throw new Error(`Type with the name ${e} has already been defined with a different constructor`)}return a}getArray(e=""){return this.get(e,pc)}getText(e=""){return this.get(e,Vc)}getMap(e=""){return this.get(e,fc)}getXmlElement(e=""){return this.get(e,Fc)}getXmlFragment(e=""){return this.get(e,Ec)}toJSON(){const e={};return this.share.forEach(((t,a)=>{e[a]=t.toJSON()})),e}destroy(){this.isDestroyed=!0,Ss(this.subdocs).forEach((e=>e.destroy()));const e=this._item;if(null!==e){this._item=null;const t=e.content;t.doc=new $l({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,Mu(e.parent.doc,(a=>{const i=t.doc;e.deleted||a.subdocsAdded.add(i),a.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Ul{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return So(this.restDecoder)}readDsLen(){return So(this.restDecoder)}}class jl extends Ul{readLeftID(){return uu(So(this.restDecoder),So(this.restDecoder))}readRightID(){return uu(So(this.restDecoder),So(this.restDecoder))}readClient(){return So(this.restDecoder)}readInfo(){return ko(this.restDecoder)}readString(){return To(this.restDecoder)}readParentInfo(){return 1===So(this.restDecoder)}readTypeRef(){return So(this.restDecoder)}readLen(){return So(this.restDecoder)}readAny(){return Co(this.restDecoder)}readBuf(){return(e=>{const t=ul(e.byteLength);return t.set(e),t})(Ao(this.restDecoder))}readJSON(){return JSON.parse(To(this.restDecoder))}readKey(){return To(this.restDecoder)}}class zl{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=So(this.restDecoder),this.dsCurrVal}readDsLen(){const e=So(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Wl extends zl{constructor(e){super(e),this.keys=[],So(e),this.keyClockDecoder=new Eo(Ao(e)),this.clientDecoder=new Io(Ao(e)),this.leftClockDecoder=new Eo(Ao(e)),this.rightClockDecoder=new Eo(Ao(e)),this.infoDecoder=new Vo(Ao(e),ko),this.stringDecoder=new Fo(Ao(e)),this.parentInfoDecoder=new Vo(Ao(e),ko),this.typeRefDecoder=new Io(Ao(e)),this.lenDecoder=new Io(Ao(e))}readLeftID(){return new ou(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ou(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Co(this.restDecoder)}readBuf(){return Ao(this.restDecoder)}readJSON(){return Co(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const e=this.stringDecoder.read();return this.keys.push(e),e}}}class Yl{constructor(){this.restEncoder=Gs()}toUint8Array(){return Zs(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Xs(this.restEncoder,e)}writeDsLen(e){Xs(this.restEncoder,e)}}class Hl extends Yl{writeLeftID(e){Xs(this.restEncoder,e.client),Xs(this.restEncoder,e.clock)}writeRightID(e){Xs(this.restEncoder,e.client),Xs(this.restEncoder,e.clock)}writeClient(e){Xs(this.restEncoder,e)}writeInfo(e){Ks(this.restEncoder,e)}writeString(e){ao(this.restEncoder,e)}writeParentInfo(e){Xs(this.restEncoder,e?1:0)}writeTypeRef(e){Xs(this.restEncoder,e)}writeLen(e){Xs(this.restEncoder,e)}writeAny(e){oo(this.restEncoder,e)}writeBuf(e){no(this.restEncoder,e)}writeJSON(e){ao(this.restEncoder,JSON.stringify(e))}writeKey(e){ao(this.restEncoder,e)}}class Gl{constructor(){this.restEncoder=Gs(),this.dsCurrVal=0}toUint8Array(){return Zs(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,Xs(this.restEncoder,t)}writeDsLen(e){0===e&&go(),Xs(this.restEncoder,e-1),this.dsCurrVal+=e}}class ql extends Gl{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ho,this.clientEncoder=new co,this.leftClockEncoder=new ho,this.rightClockEncoder=new ho,this.infoEncoder=new lo(Ks),this.stringEncoder=new fo,this.parentInfoEncoder=new lo(Ks),this.typeRefEncoder=new co,this.lenEncoder=new co}toUint8Array(){const e=Gs();return Xs(e,0),no(e,this.keyClockEncoder.toUint8Array()),no(e,this.clientEncoder.toUint8Array()),no(e,this.leftClockEncoder.toUint8Array()),no(e,this.rightClockEncoder.toUint8Array()),no(e,Zs(this.infoEncoder)),no(e,this.stringEncoder.toUint8Array()),no(e,Zs(this.parentInfoEncoder)),no(e,this.typeRefEncoder.toUint8Array()),no(e,this.lenEncoder.toUint8Array()),io(e,Zs(this.restEncoder)),Zs(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){oo(this.restEncoder,e)}writeBuf(e){no(this.restEncoder,e)}writeJSON(e){oo(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);void 0===t?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const Zl=(e,t,a)=>{const i=new Map;a.forEach(((e,a)=>{fu(t,a)>e&&i.set(a,e)})),hu(t).forEach(((e,t)=>{a.has(t)||i.set(t,0)})),Xs(e.restEncoder,i.size),Ss(i.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([a,i])=>{((e,t,a,i)=>{i=Is(i,t[0].id.clock);const n=yu(t,i);Xs(e.restEncoder,t.length-n),e.writeClient(a),Xs(e.restEncoder,i);const r=t[n];r.write(e,i-r.id.clock);for(let a=n+1;a<t.length;a++)t[a].write(e,0)})(e,t.clients.get(a),a,i)}))},Jl=(e,t,a,i=new Wl(e))=>Mu(t,(e=>{e.local=!1;let t=!1;const a=e.doc,n=a.store,r=((e,t)=>{const a=bs(),i=So(e.restDecoder);for(let n=0;n<i;n++){const i=So(e.restDecoder),n=new Array(i),r=e.readClient();let s=So(e.restDecoder);a.set(r,{i:0,refs:n});for(let a=0;a<i;a++){const i=e.readInfo();switch(31&i){case 0:{const t=e.readLen();n[a]=new Bc(uu(r,s),t),s+=t;break}case 10:{const t=So(e.restDecoder);n[a]=new ld(uu(r,s),t),s+=t;break}default:{const o=!(192&i),l=new rd(uu(r,s),null,(i&Rs)===Rs?e.readLeftID():null,null,(i&Ds)===Ds?e.readRightID():null,o?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,!o||32&~i?null:e.readString(),sd(e,i));n[a]=l,s+=l.length}}}}return a})(i,a),s=((e,t,a)=>{const i=[];let n=Ss(a.keys()).sort(((e,t)=>e-t));if(0===n.length)return null;const r=()=>{if(0===n.length)return null;let e=a.get(n[n.length-1]);for(;e.refs.length===e.i;){if(n.pop(),!(n.length>0))return null;e=a.get(n[n.length-1])}return e};let s=r();if(null===s)return null;const o=new pu,l=new Map,u=(e,t)=>{const a=l.get(e);(null==a||a>t)&&l.set(e,t)};let c=s.refs[s.i++];const d=new Map,p=()=>{for(const e of i){const t=e.id.client,i=a.get(t);i?(i.i--,o.clients.set(t,i.refs.slice(i.i)),a.delete(t),i.i=0,i.refs=[]):o.clients.set(t,[e]),n=n.filter((e=>e!==t))}i.length=0};for(;;){if(c.constructor!==ld){const n=ws(d,c.id.client,(()=>fu(t,c.id.client)))-c.id.clock;if(n<0)i.push(c),u(c.id.client,c.id.clock-1),p();else{const r=c.getMissing(e,t);if(null!==r){i.push(c);const e=a.get(r)||{refs:[],i:0};if(e.refs.length!==e.i){c=e.refs[e.i++];continue}u(r,fu(t,r)),p()}else(0===n||n<c.length)&&(c.integrate(e,n),d.set(c.id.client,c.id.clock+c.length))}}if(i.length>0)c=i.pop();else if(null!==s&&s.i<s.refs.length)c=s.refs[s.i++];else{if(s=r(),null===s)break;c=s.refs[s.i++]}}if(o.clients.size>0){const e=new ql;return Zl(e,o,new Map),Xs(e.restEncoder,0),{missing:l,update:e.toUint8Array()}}return null})(e,n,r),o=n.pendingStructs;if(o){for(const[e,a]of o.missing)if(a<fu(n,e)){t=!0;break}if(s){for(const[e,t]of s.missing){const a=o.missing.get(e);(null==a||a>t)&&o.missing.set(e,t)}o.update=Eu([o.update,s.update])}}else n.pendingStructs=s;const l=Bl(i,e,n);if(n.pendingDs){const t=new Wl(_o(n.pendingDs));So(t.restDecoder);const a=Bl(t,e,n);n.pendingDs=l&&a?Eu([l,a]):l||a}else n.pendingDs=l;if(t){const t=n.pendingStructs.update;n.pendingStructs=null,Kl(e.doc,t)}}),a,!1),Kl=(e,t,a,i=Wl)=>{const n=_o(t);Jl(n,e,a,new i(n))},Xl=(e,t=new Uint8Array([0]),a=new ql)=>{((e,t,a=new Map)=>{Zl(e,t.store,a),Pl(e,Rl(t.store))})(a,e,Ql(t));const i=[a.toUint8Array()];if(e.store.pendingDs&&i.push(e.store.pendingDs),e.store.pendingStructs&&i.push(Fu(e.store.pendingStructs.update,t)),i.length>1){if(a.constructor===Hl)return Vu(i.map(((e,t)=>0===t?e:Lu(e))));if(a.constructor===ql)return Eu(i)}return i[0]},Ql=e=>(e=>{const t=new Map,a=So(e.restDecoder);for(let i=0;i<a;i++){const a=So(e.restDecoder),i=So(e.restDecoder);t.set(a,i)}return t})(new Ul(_o(e))),eu=(e,t)=>(Xs(e.restEncoder,t.size),Ss(t.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,a])=>{Xs(e.restEncoder,t),Xs(e.restEncoder,a)})),e),tu=(e,t=new Gl)=>(e instanceof Map?eu(t,e):((e,t)=>{eu(e,hu(t.store))})(t,e),t.toUint8Array());class au{constructor(){this.l=[]}}const iu=()=>new au,nu=(e,t)=>e.l.push(t),ru=(e,t)=>{const a=e.l,i=a.length;e.l=a.filter((e=>t!==e)),i===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},su=(e,t,a)=>Xo(e.l,[t,a]);class ou{constructor(e,t){this.client=e,this.clock=t}}const lu=(e,t)=>e===t||null!==e&&null!==t&&e.client===t.client&&e.clock===t.clock,uu=(e,t)=>new ou(e,t),cu=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!El(t.ds,e.id),du=(e,t)=>{const a=ws(e.meta,du,_s),i=e.doc.store;a.has(t)||(t.sv.forEach(((t,a)=>{t<fu(i,a)&&vu(e,uu(a,t))})),Il(e,t.ds,(e=>{})),a.add(t))};class pu{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const hu=e=>{const t=new Map;return e.clients.forEach(((e,a)=>{const i=e[e.length-1];t.set(a,i.id.clock+i.length)})),t},fu=(e,t)=>{const a=e.clients.get(t);if(void 0===a)return 0;const i=a[a.length-1];return i.id.clock+i.length},mu=(e,t)=>{let a=e.clients.get(t.id.client);if(void 0===a)a=[],e.clients.set(t.id.client,a);else{const e=a[a.length-1];if(e.id.clock+e.length!==t.id.clock)throw go()}a.push(t)},yu=(e,t)=>{let a=0,i=e.length-1,n=e[i],r=n.id.clock;if(r===t)return i;let s=xs(t/(r+n.length-1)*i);for(;a<=i;){if(n=e[s],r=n.id.clock,r<=t){if(t<r+n.length)return s;a=s+1}else i=s-1;s=xs((a+i)/2)}throw go()},gu=(e,t)=>{const a=e.clients.get(t.client);return a[yu(a,t.clock)]},bu=(e,t,a)=>{const i=yu(t,a),n=t[i];return n.id.clock<a&&n instanceof rd?(t.splice(i+1,0,nd(e,n,a-n.id.clock)),i+1):i},vu=(e,t)=>{const a=e.doc.store.clients.get(t.client);return a[bu(e,a,t.clock)]},wu=(e,t,a)=>{const i=t.clients.get(a.client),n=yu(i,a.clock),r=i[n];return a.clock!==r.id.clock+r.length-1&&r.constructor!==Bc&&i.splice(n+1,0,nd(e,r,a.clock-r.id.clock+1)),r},_u=(e,t,a,i,n)=>{if(0===i)return;const r=a+i;let s,o=bu(e,t,a);do{s=t[o++],r<s.id.clock+s.length&&bu(e,t,r),n(s)}while(o<t.length&&t[o].id.clock<r)};class Au{constructor(e,t,a){this.doc=e,this.deleteSet=new Vl,this.beforeState=hu(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=a,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const ku=(e,t)=>!(0===t.deleteSet.clients.size&&!((e,t)=>{for(const[a,i]of e)if(t(i,a))return!0;return!1})(t.afterState,((e,a)=>t.beforeState.get(a)!==e)))&&(Fl(t.deleteSet),((e,t)=>{Zl(e,t.doc.store,t.beforeState)})(e,t),Pl(e,t.deleteSet),!0),Su=(e,t,a)=>{const i=t._item;(null===i||i.id.clock<(e.beforeState.get(i.id.client)||0)&&!i.deleted)&&ws(e.changed,t,_s).add(a)},Nu=(e,t)=>{let a=e[t],i=e[t-1],n=t;for(;n>0&&(i.deleted===a.deleted&&i.constructor===a.constructor&&i.mergeWith(a));a=i,i=e[--n-1])a instanceof rd&&null!==a.parentSub&&a.parent._map.get(a.parentSub)===a&&a.parent._map.set(a.parentSub,i);const r=t-n;return r&&e.splice(t+1-r,r),r},Tu=(e,t)=>{if(t<e.length){const a=e[t],i=a.doc,n=i.store,r=a.deleteSet,s=a._mergeStructs;try{Fl(r),a.afterState=hu(a.doc.store),i.emit("beforeObserverCalls",[a,i]);const e=[];a.changed.forEach(((t,i)=>e.push((()=>{null!==i._item&&i._item.deleted||i._callObserver(a,t)})))),e.push((()=>{a.changedParentTypes.forEach(((e,t)=>{t._dEH.l.length>0&&(null===t._item||!t._item.deleted)&&((e=e.filter((e=>null===e.target._item||!e.target._item.deleted))).forEach((e=>{e.currentTarget=t,e._path=null})),e.sort(((e,t)=>e.path.length-t.path.length)),su(t._dEH,e,a))}))})),e.push((()=>i.emit("afterTransaction",[a,i]))),Xo(e,[]),a._needFormattingCleanup&&Mc(a)}finally{i.gc&&((e,t,a)=>{for(const[i,n]of e.clients.entries()){const e=t.clients.get(i);for(let i=n.length-1;i>=0;i--){const r=n[i],s=r.clock+r.len;for(let i=yu(e,r.clock),n=e[i];i<e.length&&n.id.clock<s;n=e[++i]){const n=e[i];if(r.clock+r.len<=n.id.clock)break;n instanceof rd&&n.deleted&&!n.keep&&a(n)&&n.gc(t,!1)}}}})(r,n,i.gcFilter),((e,t)=>{e.clients.forEach(((e,a)=>{const i=t.clients.get(a);for(let t=e.length-1;t>=0;t--){const a=e[t];for(let e=Vs(i.length-1,1+yu(i,a.clock+a.len-1)),t=i[e];e>0&&t.id.clock>=a.clock;t=i[e])e-=1+Nu(i,e)}}))})(r,n),a.afterState.forEach(((e,t)=>{const i=a.beforeState.get(t)||0;if(i!==e){const e=n.clients.get(t),a=Is(yu(e,i),1);for(let t=e.length-1;t>=a;)t-=1+Nu(e,t)}}));for(let e=s.length-1;e>=0;e--){const{client:t,clock:a}=s[e].id,i=n.clients.get(t),r=yu(i,a);r+1<i.length&&Nu(i,r+1)>1||r>0&&Nu(i,r)}if(a.local||a.afterState.get(i.clientID)===a.beforeState.get(i.clientID)||(((...e)=>{console.log(...Nl(e)),Tl.forEach((t=>t.print(e)))})(Al,ml,"[yjs] ",yl,wl,"Changed the client-id because another client seems to be using it."),i.clientID=Ol()),i.emit("afterTransactionCleanup",[a,i]),i._observers.has("update")){const e=new Hl;ku(e,a)&&i.emit("update",[e.toUint8Array(),a.origin,i,a])}if(i._observers.has("updateV2")){const e=new ql;ku(e,a)&&i.emit("updateV2",[e.toUint8Array(),a.origin,i,a])}const{subdocsAdded:o,subdocsLoaded:l,subdocsRemoved:u}=a;(o.size>0||u.size>0||l.size>0)&&(o.forEach((e=>{e.clientID=i.clientID,null==e.collectionid&&(e.collectionid=i.collectionid),i.subdocs.add(e)})),u.forEach((e=>i.subdocs.delete(e))),i.emit("subdocs",[{loaded:l,added:o,removed:u},i,a]),u.forEach((e=>e.destroy()))),e.length<=t+1?(i._transactionCleanups=[],i.emit("afterAllTransactions",[i,e])):Tu(e,t+1)}}},Mu=(e,t,a=null,i=!0)=>{const n=e._transactionCleanups;let r=!1,s=null;null===e._transaction&&(r=!0,e._transaction=new Au(e,a,i),n.push(e._transaction),1===n.length&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(r){const t=e._transaction===n[0];e._transaction=null,t&&Tu(n,0)}}return s};class xu{constructor(e,t){this.gen=function*(e){const t=So(e.restDecoder);for(let a=0;a<t;a++){const t=So(e.restDecoder),a=e.readClient();let i=So(e.restDecoder);for(let n=0;n<t;n++){const t=e.readInfo();if(10===t){const t=So(e.restDecoder);yield new ld(uu(a,i),t),i+=t}else if(31&t){const n=!(192&t),r=new rd(uu(a,i),null,(t&Rs)===Rs?e.readLeftID():null,null,(t&Ds)===Ds?e.readRightID():null,n?e.readParentInfo()?e.readString():e.readLeftID():null,!n||32&~t?null:e.readString(),sd(e,t));yield r,i+=r.length}else{const t=e.readLen();yield new Bc(uu(a,i),t),i+=t}}}}(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===ld);return this.curr}}class Cu{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Vu=e=>Eu(e,jl,Hl),Iu=(e,t)=>{if(e.constructor===Bc){const{client:a,clock:i}=e.id;return new Bc(uu(a,i+t),e.length-t)}if(e.constructor===ld){const{client:a,clock:i}=e.id;return new ld(uu(a,i+t),e.length-t)}{const a=e,{client:i,clock:n}=a.id;return new rd(uu(i,n+t),null,uu(i,n+t-1),null,a.rightOrigin,a.parent,a.parentSub,a.content.splice(t))}},Eu=(e,t=Wl,a=ql)=>{if(1===e.length)return e[0];const i=e.map((e=>new t(_o(e))));let n=i.map((e=>new xu(e,!0))),r=null;const s=new a,o=new Cu(s);for(;n=n.filter((e=>null!==e.curr)),n.sort(((e,t)=>{if(e.curr.id.client===t.curr.id.client){const a=e.curr.id.clock-t.curr.id.clock;return 0===a?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===ld?1:-1:a}return t.curr.id.client-e.curr.id.client})),0!==n.length;){const e=n[0],t=e.curr.id.client;if(null!==r){let a=e.curr,i=!1;for(;null!==a&&a.id.clock+a.length<=r.struct.id.clock+r.struct.length&&a.id.client>=r.struct.id.client;)a=e.next(),i=!0;if(null===a||a.id.client!==t||i&&a.id.clock>r.struct.id.clock+r.struct.length)continue;if(t!==r.struct.id.client)Ru(o,r.struct,r.offset),r={struct:a,offset:0},e.next();else if(r.struct.id.clock+r.struct.length<a.id.clock)if(r.struct.constructor===ld)r.struct.length=a.id.clock+a.length-r.struct.id.clock;else{Ru(o,r.struct,r.offset);const e=a.id.clock-r.struct.id.clock-r.struct.length;r={struct:new ld(uu(t,r.struct.id.clock+r.struct.length),e),offset:0}}else{const t=r.struct.id.clock+r.struct.length-a.id.clock;t>0&&(r.struct.constructor===ld?r.struct.length-=t:a=Iu(a,t)),r.struct.mergeWith(a)||(Ru(o,r.struct,r.offset),r={struct:a,offset:0},e.next())}}else r={struct:e.curr,offset:0},e.next();for(let a=e.curr;null!==a&&a.id.client===t&&a.id.clock===r.struct.id.clock+r.struct.length&&a.constructor!==ld;a=e.next())Ru(o,r.struct,r.offset),r={struct:a,offset:0}}null!==r&&(Ru(o,r.struct,r.offset),r=null),Pu(o);const l=(e=>{const t=new Vl;for(let a=0;a<e.length;a++)e[a].clients.forEach(((i,n)=>{if(!t.clients.has(n)){const r=i.slice();for(let t=a+1;t<e.length;t++)ks(r,e[t].clients.get(n)||[]);t.clients.set(n,r)}}));return Fl(t),t})(i.map((e=>Ll(e))));return Pl(s,l),s.toUint8Array()},Fu=(e,t,a=Wl,i=ql)=>{const n=Ql(t),r=new i,s=new Cu(r),o=new a(_o(e)),l=new xu(o,!1);for(;l.curr;){const e=l.curr,t=e.id.client,a=n.get(t)||0;if(l.curr.constructor!==ld)if(e.id.clock+e.length>a)for(Ru(s,e,Is(a-e.id.clock,0)),l.next();l.curr&&l.curr.id.client===t;)Ru(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===t&&l.curr.id.clock+l.curr.length<=a;)l.next();else l.next()}Pu(s);const u=Ll(o);return Pl(r,u),r.toUint8Array()},Du=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Zs(e.encoder.restEncoder)}),e.encoder.restEncoder=Gs(),e.written=0)},Ru=(e,t,a)=>{e.written>0&&e.currClient!==t.id.client&&Du(e),0===e.written&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Xs(e.encoder.restEncoder,t.id.clock+a)),t.write(e.encoder,a),e.written++},Pu=e=>{Du(e);const t=e.encoder.restEncoder;Xs(t,e.clientStructs.length);for(let a=0;a<e.clientStructs.length;a++){const i=e.clientStructs[a];Xs(t,i.written),io(t,i.restEncoder)}},Lu=e=>((e,t,a,i)=>{const n=new a(_o(e)),r=new xu(n,!1),s=new i,o=new Cu(s);for(let e=r.curr;null!==e;e=r.next())Ru(o,t(e),0);Pu(o);const l=Ll(n);return Pl(s,l),s.toUint8Array()})(e,Qo,Wl,Hl),Bu="You must not compute changes after the event-handler fired.";class Ou{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=$u(this.currentTarget,this.target))}deletes(e){return El(this.transaction.deleteSet,e.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw mo(Bu);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach((a=>{if(null!==a){const i=t._map.get(a);let n,r;if(this.adds(i)){let e=i.left;for(;null!==e&&this.adds(e);)e=e.left;if(this.deletes(i)){if(null===e||!this.deletes(e))return;n="delete",r=As(e.content.getContent())}else null!==e&&this.deletes(e)?(n="update",r=As(e.content.getContent())):(n="add",r=void 0)}else{if(!this.deletes(i))return;n="delete",r=As(i.content.getContent())}e.set(a,{action:n,oldValue:r})}})),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(null===e){if(0===this.transaction.doc._transactionCleanups.length)throw mo(Bu);const t=this.target,a=_s(),i=_s(),n=[];e={added:a,deleted:i,delta:n,keys:this.keys};if(this.transaction.changed.get(t).has(null)){let e=null;const r=()=>{e&&n.push(e)};for(let n=t._start;null!==n;n=n.right)n.deleted?this.deletes(n)&&!this.adds(n)&&(null!==e&&void 0!==e.delete||(r(),e={delete:0}),e.delete+=n.length,i.add(n)):this.adds(n)?(null!==e&&void 0!==e.insert||(r(),e={insert:[]}),e.insert=e.insert.concat(n.content.getContent()),a.add(n)):(null!==e&&void 0!==e.retain||(r(),e={retain:0}),e.retain+=n.length);null!==e&&void 0===e.retain&&r()}this._changes=e}return e}}const $u=(e,t)=>{const a=[];for(;null!==t._item&&t!==e;){if(null!==t._item.parentSub)a.unshift(t._item.parentSub);else{let e=0,i=t._item.parent._start;for(;i!==t._item&&null!==i;)!i.deleted&&i.countable&&(e+=i.length),i=i.right;a.unshift(e)}t=t._item.parent}return a},Uu=()=>{((...e)=>{console.warn(...Nl(e)),e.unshift(Al),Tl.forEach((t=>t.print(e)))})("Invalid access: Add Yjs type to a document before reading data.")};let ju=0;class zu{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ju++}}const Wu=(e,t,a)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=a,e.timestamp=ju++},Yu=(e,t)=>{if(null===e._start||0===t||null===e._searchMarker)return null;const a=0===e._searchMarker.length?null:e._searchMarker.reduce(((e,a)=>Cs(t-e.index)<Cs(t-a.index)?e:a));let i=e._start,n=0;for(null!==a&&(i=a.p,n=a.index,(e=>{e.timestamp=ju++})(a));null!==i.right&&n<t;){if(!i.deleted&&i.countable){if(t<n+i.length)break;n+=i.length}i=i.right}for(;null!==i.left&&n>t;)i=i.left,!i.deleted&&i.countable&&(n-=i.length);for(;null!==i.left&&i.left.id.client===i.id.client&&i.left.id.clock+i.left.length===i.id.clock;)i=i.left,!i.deleted&&i.countable&&(n-=i.length);return null!==a&&Cs(a.index-n)<i.parent.length/80?(Wu(a,i,n),a):((e,t,a)=>{if(e.length>=80){const i=e.reduce(((e,t)=>e.timestamp<t.timestamp?e:t));return Wu(i,t,a),i}{const i=new zu(t,a);return e.push(i),i}})(e._searchMarker,i,n)},Hu=(e,t,a)=>{for(let i=e.length-1;i>=0;i--){const n=e[i];if(a>0){let t=n.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(n.index-=t.length);if(null===t||!0===t.marker){e.splice(i,1);continue}n.p=t,t.marker=!0}(t<n.index||a>0&&t===n.index)&&(n.index=Is(t,n.index+a))}},Gu=(e,t,a)=>{const i=e,n=t.changedParentTypes;for(;ws(n,e,(()=>[])).push(a),null!==e._item;)e=e._item.parent;su(i._eH,a,t)};class qu{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=iu(),this._dEH=iu(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw yo()}clone(){throw yo()}_write(e){}get _first(){let e=this._start;for(;null!==e&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){nu(this._eH,e)}observeDeep(e){nu(this._dEH,e)}unobserve(e){ru(this._eH,e)}unobserveDeep(e){ru(this._dEH,e)}toJSON(){}}const Zu=(e,t,a)=>{e.doc??Uu(),t<0&&(t=e._length+t),a<0&&(a=e._length+a);let i=a-t;const n=[];let r=e._start;for(;null!==r&&i>0;){if(r.countable&&!r.deleted){const e=r.content.getContent();if(e.length<=t)t-=e.length;else{for(let a=t;a<e.length&&i>0;a++)n.push(e[a]),i--;t=0}}r=r.right}return n},Ju=e=>{e.doc??Uu();const t=[];let a=e._start;for(;null!==a;){if(a.countable&&!a.deleted){const e=a.content.getContent();for(let a=0;a<e.length;a++)t.push(e[a])}a=a.right}return t},Ku=(e,t)=>{let a=0,i=e._start;for(e.doc??Uu();null!==i;){if(i.countable&&!i.deleted){const n=i.content.getContent();for(let i=0;i<n.length;i++)t(n[i],a++,e)}i=i.right}},Xu=(e,t)=>{const a=[];return Ku(e,((i,n)=>{a.push(t(i,n,e))})),a},Qu=e=>{let t=e._start,a=null,i=0;return{[Symbol.iterator](){return this},next:()=>{if(null===a){for(;null!==t&&t.deleted;)t=t.right;if(null===t)return{done:!0,value:void 0};a=t.content.getContent(),i=0,t=t.right}const e=a[i++];return a.length<=i&&(a=null),{done:!1,value:e}}}},ec=(e,t)=>{e.doc??Uu();const a=Yu(e,t);let i=e._start;for(null!==a&&(i=a.p,t-=a.index);null!==i;i=i.right)if(!i.deleted&&i.countable){if(t<i.length)return i.content.getContent()[t];t-=i.length}},tc=(e,t,a,i)=>{let n=a;const r=e.doc,s=r.clientID,o=r.store,l=null===a?t._start:a.right;let u=[];const c=()=>{u.length>0&&(n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new Gc(u)),n.integrate(e,0),u=[])};i.forEach((a=>{if(null===a)u.push(a);else switch(a.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(a);break;default:switch(c(),a.constructor){case Uint8Array:case ArrayBuffer:n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new Oc(new Uint8Array(a))),n.integrate(e,0);break;case $l:n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new jc(a)),n.integrate(e,0);break;default:if(!(a instanceof qu))throw new Error("Unexpected content type in insert operation");n=new rd(uu(s,fu(o,s)),n,n&&n.lastId,l,l&&l.id,t,null,new id(a)),n.integrate(e,0)}}})),c()},ac=()=>mo("Length exceeded!"),ic=(e,t,a,i)=>{if(a>t._length)throw ac();if(0===a)return t._searchMarker&&Hu(t._searchMarker,a,i.length),tc(e,t,null,i);const n=a,r=Yu(t,a);let s=t._start;for(null!==r&&(s=r.p,0===(a-=r.index)&&(s=s.prev,a+=s&&s.countable&&!s.deleted?s.length:0));null!==s;s=s.right)if(!s.deleted&&s.countable){if(a<=s.length){a<s.length&&vu(e,uu(s.id.client,s.id.clock+a));break}a-=s.length}return t._searchMarker&&Hu(t._searchMarker,n,i.length),tc(e,t,s,i)},nc=(e,t,a,i)=>{if(0===i)return;const n=a,r=i,s=Yu(t,a);let o=t._start;for(null!==s&&(o=s.p,a-=s.index);null!==o&&a>0;o=o.right)!o.deleted&&o.countable&&(a<o.length&&vu(e,uu(o.id.client,o.id.clock+a)),a-=o.length);for(;i>0&&null!==o;)o.deleted||(i<o.length&&vu(e,uu(o.id.client,o.id.clock+i)),o.delete(e),i-=o.length),o=o.right;if(i>0)throw ac();t._searchMarker&&Hu(t._searchMarker,n,-r+i)},rc=(e,t,a)=>{const i=t._map.get(a);void 0!==i&&i.delete(e)},sc=(e,t,a,i)=>{const n=t._map.get(a)||null,r=e.doc,s=r.clientID;let o;if(null==i)o=new Gc([i]);else switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:o=new Gc([i]);break;case Uint8Array:o=new Oc(i);break;case $l:o=new jc(i);break;default:if(!(i instanceof qu))throw new Error("Unexpected content type");o=new id(i)}new rd(uu(s,fu(r.store,s)),n,n&&n.lastId,null,null,t,a,o).integrate(e,0)},oc=(e,t)=>{e.doc??Uu();const a=e._map.get(t);return void 0===a||a.deleted?void 0:a.content.getContent()[a.length-1]},lc=e=>{const t={};return e.doc??Uu(),e._map.forEach(((e,a)=>{e.deleted||(t[a]=e.content.getContent()[e.length-1])})),t},uc=(e,t)=>{e.doc??Uu();const a=e._map.get(t);return void 0!==a&&!a.deleted},cc=e=>{return e.doc??Uu(),t=e._map.entries(),a=e=>!e[1].deleted,Ml((()=>{let e;do{e=t.next()}while(!e.done&&!a(e.value));return e}));var t,a};class dc extends Ou{}class pc extends qu{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new pc;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new pc}clone(){const e=new pc;return e.insert(0,this.toArray().map((e=>e instanceof qu?e.clone():e))),e}get length(){return this.doc??Uu(),this._length}_callObserver(e,t){super._callObserver(e,t),Gu(this,e,new dc(this,e))}insert(e,t){null!==this.doc?Mu(this.doc,(a=>{ic(a,this,e,t)})):this._prelimContent.splice(e,0,...t)}push(e){null!==this.doc?Mu(this.doc,(t=>{((e,t,a)=>{let i=(t._searchMarker||[]).reduce(((e,t)=>t.index>e.index?t:e),{index:0,p:t._start}).p;if(i)for(;i.right;)i=i.right;tc(e,t,i,a)})(t,this,e)})):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){null!==this.doc?Mu(this.doc,(a=>{nc(a,this,e,t)})):this._prelimContent.splice(e,t)}get(e){return ec(this,e)}toArray(){return Ju(this)}slice(e=0,t=this.length){return Zu(this,e,t)}toJSON(){return this.map((e=>e instanceof qu?e.toJSON():e))}map(e){return Xu(this,e)}forEach(e){Ku(this,e)}[Symbol.iterator](){return Qu(this)}_write(e){e.writeTypeRef(Jc)}}class hc extends Ou{constructor(e,t,a){super(e,t),this.keysChanged=a}}class fc extends qu{constructor(e){super(),this._prelimContent=null,this._prelimContent=void 0===e?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach(((e,t)=>{this.set(t,e)})),this._prelimContent=null}_copy(){return new fc}clone(){const e=new fc;return this.forEach(((t,a)=>{e.set(a,t instanceof qu?t.clone():t)})),e}_callObserver(e,t){Gu(this,e,new hc(this,e,t))}toJSON(){this.doc??Uu();const e={};return this._map.forEach(((t,a)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[a]=i instanceof qu?i.toJSON():i}})),e}get size(){return[...cc(this)].length}keys(){return xl(cc(this),(e=>e[0]))}values(){return xl(cc(this),(e=>e[1].content.getContent()[e[1].length-1]))}entries(){return xl(cc(this),(e=>[e[0],e[1].content.getContent()[e[1].length-1]]))}forEach(e){this.doc??Uu(),this._map.forEach(((t,a)=>{t.deleted||e(t.content.getContent()[t.length-1],a,this)}))}[Symbol.iterator](){return this.entries()}delete(e){null!==this.doc?Mu(this.doc,(t=>{rc(t,this,e)})):this._prelimContent.delete(e)}set(e,t){return null!==this.doc?Mu(this.doc,(a=>{sc(a,this,e,t)})):this._prelimContent.set(e,t),t}get(e){return oc(this,e)}has(e){return uc(this,e)}clear(){null!==this.doc?Mu(this.doc,(e=>{this.forEach((function(t,a,i){rc(e,i,a)}))})):this._prelimContent.clear()}_write(e){e.writeTypeRef(Kc)}}const mc=(e,t)=>e===t||"object"==typeof e&&"object"==typeof t&&e&&t&&((e,t)=>e===t||Go(e)===Go(t)&&((e,t)=>{for(const a in e)if(!t(e[a],a))return!1;return!0})(e,((e,a)=>(void 0!==e||qo(t,a))&&t[a]===e)))(e,t);class yc{constructor(e,t,a,i){this.left=e,this.right=t,this.index=a,this.currentAttributes=i}forward(){if(null===this.right&&go(),this.right.content.constructor===Wc)this.right.deleted||wc(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}}const gc=(e,t,a)=>{for(;null!==t.right&&a>0;){if(t.right.content.constructor===Wc)t.right.deleted||wc(t.currentAttributes,t.right.content);else t.right.deleted||(a<t.right.length&&vu(e,uu(t.right.id.client,t.right.id.clock+a)),t.index+=t.right.length,a-=t.right.length);t.left=t.right,t.right=t.right.right}return t},bc=(e,t,a,i)=>{const n=new Map,r=i?Yu(t,a):null;if(r){const t=new yc(r.p.left,r.p,r.index,n);return gc(e,t,a-r.index)}{const i=new yc(null,t._start,0,n);return gc(e,i,a)}},vc=(e,t,a,i)=>{for(;null!==a.right&&(!0===a.right.deleted||a.right.content.constructor===Wc&&mc(i.get(a.right.content.key),a.right.content.value));)a.right.deleted||i.delete(a.right.content.key),a.forward();const n=e.doc,r=n.clientID;i.forEach(((i,s)=>{const o=a.left,l=a.right,u=new rd(uu(r,fu(n.store,r)),o,o&&o.lastId,l,l&&l.id,t,null,new Wc(s,i));u.integrate(e,0),a.right=u,a.forward()}))},wc=(e,t)=>{const{key:a,value:i}=t;null===i?e.delete(a):e.set(a,i)},_c=(e,t)=>{for(;null!==e.right&&(e.right.deleted||e.right.content.constructor===Wc&&mc(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Ac=(e,t,a,i)=>{const n=e.doc,r=n.clientID,s=new Map;for(const o in i){const l=i[o],u=a.currentAttributes.get(o)??null;if(!mc(u,l)){s.set(o,u);const{left:i,right:c}=a;a.right=new rd(uu(r,fu(n.store,r)),i,i&&i.lastId,c,c&&c.id,t,null,new Wc(o,l)),a.right.integrate(e,0),a.forward()}}return s},kc=(e,t,a,i,n)=>{a.currentAttributes.forEach(((e,t)=>{void 0===n[t]&&(n[t]=null)}));const r=e.doc,s=r.clientID;_c(a,n);const o=Ac(e,t,a,n),l=i.constructor===String?new qc(i):i instanceof qu?new id(i):new zc(i);let{left:u,right:c,index:d}=a;t._searchMarker&&Hu(t._searchMarker,a.index,l.getLength()),c=new rd(uu(s,fu(r.store,s)),u,u&&u.lastId,c,c&&c.id,t,null,l),c.integrate(e,0),a.right=c,a.index=d,a.forward(),vc(e,t,a,o)},Sc=(e,t,a,i,n)=>{const r=e.doc,s=r.clientID;_c(a,n);const o=Ac(e,t,a,n);e:for(;null!==a.right&&(i>0||o.size>0&&(a.right.deleted||a.right.content.constructor===Wc));){if(!a.right.deleted)switch(a.right.content.constructor){case Wc:{const{key:t,value:r}=a.right.content,s=n[t];if(void 0!==s){if(mc(s,r))o.delete(t);else{if(0===i)break e;o.set(t,r)}a.right.delete(e)}else a.currentAttributes.set(t,r);break}default:i<a.right.length&&vu(e,uu(a.right.id.client,a.right.id.clock+i)),i-=a.right.length}a.forward()}if(i>0){let n="";for(;i>0;i--)n+="\n";a.right=new rd(uu(s,fu(r.store,s)),a.left,a.left&&a.left.lastId,a.right,a.right&&a.right.id,t,null,new qc(n)),a.right.integrate(e,0),a.forward()}vc(e,t,a,o)},Nc=(e,t,a,i,n)=>{let r=t;const s=bs();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===Wc){const e=r.content;s.set(e.key,e)}r=r.right}let o=0,l=!1;for(;t!==r;){if(a===t&&(l=!0),!t.deleted){const a=t.content;switch(a.constructor){case Wc:{const{key:r,value:u}=a,c=i.get(r)??null;s.get(r)===a&&c!==u||(t.delete(e),o++,l||(n.get(r)??null)!==u||c===u||(null===c?n.delete(r):n.set(r,c))),l||t.deleted||wc(n,a);break}}}t=t.right}return o},Tc=e=>{let t=0;return Mu(e.doc,(a=>{let i=e._start,n=e._start,r=bs();const s=vs(r);for(;n;){if(!1===n.deleted)if(n.content.constructor===Wc)wc(s,n.content);else t+=Nc(a,i,n,r,s),r=vs(s),i=n;n=n.right}})),t},Mc=e=>{const t=new Set,a=e.doc;for(const[i,n]of e.afterState.entries()){const r=e.beforeState.get(i)||0;n!==r&&_u(e,a.store.clients.get(i),r,n,(e=>{e.deleted||e.content.constructor!==Wc||e.constructor===Bc||t.add(e.parent)}))}Mu(a,(a=>{Il(e,e.deleteSet,(e=>{if(e instanceof Bc||!e.parent._hasFormatting||t.has(e.parent))return;const i=e.parent;e.content.constructor===Wc?t.add(i):((e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const a=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Wc){const i=t.content.key;a.has(i)?t.delete(e):a.add(i)}t=t.left}})(a,e)}));for(const e of t)Tc(e)}))},xc=(e,t,a)=>{const i=a,n=vs(t.currentAttributes),r=t.right;for(;a>0&&null!==t.right;){if(!1===t.right.deleted)switch(t.right.content.constructor){case id:case zc:case qc:a<t.right.length&&vu(e,uu(t.right.id.client,t.right.id.clock+a)),a-=t.right.length,t.right.delete(e)}t.forward()}r&&Nc(e,r,t.right,n,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&Hu(s._searchMarker,t.index,-i+a),t};class Cc extends Ou{constructor(e,t,a){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,a.forEach((e=>{null===e?this.childListChanged=!0:this.keysChanged.add(e)}))}get changes(){if(null===this._changes){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(null===this._delta){const e=this.target.doc,t=[];Mu(e,(e=>{const a=new Map,i=new Map;let n=this.target._start,r=null;const s={};let o="",l=0,u=0;const c=()=>{if(null!==r){let e=null;switch(r){case"delete":u>0&&(e={delete:u}),u=0;break;case"insert":("object"==typeof o||o.length>0)&&(e={insert:o},a.size>0&&(e.attributes={},a.forEach(((t,a)=>{null!==t&&(e.attributes[a]=t)})))),o="";break;case"retain":l>0&&(e={retain:l},(e=>{for(const t in e)return!1;return!0})(s)||(e.attributes=Wo({},s))),l=0}e&&t.push(e),r=null}};for(;null!==n;){switch(n.content.constructor){case id:case zc:this.adds(n)?this.deletes(n)||(c(),r="insert",o=n.content.getContent()[0],c()):this.deletes(n)?("delete"!==r&&(c(),r="delete"),u+=1):n.deleted||("retain"!==r&&(c(),r="retain"),l+=1);break;case qc:this.adds(n)?this.deletes(n)||("insert"!==r&&(c(),r="insert"),o+=n.content.str):this.deletes(n)?("delete"!==r&&(c(),r="delete"),u+=n.length):n.deleted||("retain"!==r&&(c(),r="retain"),l+=n.length);break;case Wc:{const{key:t,value:o}=n.content;if(this.adds(n)){if(!this.deletes(n)){const l=a.get(t)??null;mc(l,o)?null!==o&&n.delete(e):("retain"===r&&c(),mc(o,i.get(t)??null)?delete s[t]:s[t]=o)}}else if(this.deletes(n)){i.set(t,o);const e=a.get(t)??null;mc(e,o)||("retain"===r&&c(),s[t]=e)}else if(!n.deleted){i.set(t,o);const a=s[t];void 0!==a&&(mc(a,o)?null!==a&&n.delete(e):("retain"===r&&c(),null===o?delete s[t]:s[t]=o))}n.deleted||("insert"===r&&c(),wc(a,n.content));break}}n=n.right}for(c();t.length>0;){const e=t[t.length-1];if(void 0===e.retain||void 0!==e.attributes)break;t.pop()}})),this._delta=t}return this._delta}}class Vc extends qu{constructor(e){super(),this._pending=void 0!==e?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Uu(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((e=>e()))}catch(e){console.error(e)}this._pending=null}_copy(){return new Vc}clone(){const e=new Vc;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const a=new Cc(this,e,t);Gu(this,e,a),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Uu();let e="",t=this._start;for(;null!==t;)!t.deleted&&t.countable&&t.content.constructor===qc&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){null!==this.doc?Mu(this.doc,(a=>{const i=new yc(null,this._start,0,new Map);for(let n=0;n<e.length;n++){const r=e[n];if(void 0!==r.insert){const s=t||"string"!=typeof r.insert||n!==e.length-1||null!==i.right||"\n"!==r.insert.slice(-1)?r.insert:r.insert.slice(0,-1);("string"!=typeof s||s.length>0)&&kc(a,this,i,s,r.attributes||{})}else void 0!==r.retain?Sc(a,this,i,r.retain,r.attributes||{}):void 0!==r.delete&&xc(a,i,r.delete)}})):this._pending.push((()=>this.applyDelta(e)))}toDelta(e,t,a){this.doc??Uu();const i=[],n=new Map,r=this.doc;let s="",o=this._start;function l(){if(s.length>0){const e={};let t=!1;n.forEach(((a,i)=>{t=!0,e[i]=a}));const a={insert:s};t&&(a.attributes=e),i.push(a),s=""}}const u=()=>{for(;null!==o;){if(cu(o,e)||void 0!==t&&cu(o,t))switch(o.content.constructor){case qc:{const i=n.get("ychange");void 0===e||cu(o,e)?void 0===t||cu(o,t)?void 0!==i&&(l(),n.delete("ychange")):void 0!==i&&i.user===o.id.client&&"added"===i.type||(l(),n.set("ychange",a?a("added",o.id):{type:"added"})):void 0!==i&&i.user===o.id.client&&"removed"===i.type||(l(),n.set("ychange",a?a("removed",o.id):{type:"removed"})),s+=o.content.str;break}case id:case zc:{l();const e={insert:o.content.getContent()[0]};if(n.size>0){const t={};e.attributes=t,n.forEach(((e,a)=>{t[a]=e}))}i.push(e);break}case Wc:cu(o,e)&&(l(),wc(n,o.content))}o=o.right}l()};return e||t?Mu(r,(a=>{e&&du(a,e),t&&du(a,t),u()}),"cleanup"):u(),i}insert(e,t,a){if(t.length<=0)return;const i=this.doc;null!==i?Mu(i,(i=>{const n=bc(i,this,e,!a);a||(a={},n.currentAttributes.forEach(((e,t)=>{a[t]=e}))),kc(i,this,n,t,a)})):this._pending.push((()=>this.insert(e,t,a)))}insertEmbed(e,t,a){const i=this.doc;null!==i?Mu(i,(i=>{const n=bc(i,this,e,!a);kc(i,this,n,t,a||{})})):this._pending.push((()=>this.insertEmbed(e,t,a||{})))}delete(e,t){if(0===t)return;const a=this.doc;null!==a?Mu(a,(a=>{xc(a,bc(a,this,e,!0),t)})):this._pending.push((()=>this.delete(e,t)))}format(e,t,a){if(0===t)return;const i=this.doc;null!==i?Mu(i,(i=>{const n=bc(i,this,e,!1);null!==n.right&&Sc(i,this,n,t,a)})):this._pending.push((()=>this.format(e,t,a)))}removeAttribute(e){null!==this.doc?Mu(this.doc,(t=>{rc(t,this,e)})):this._pending.push((()=>this.removeAttribute(e)))}setAttribute(e,t){null!==this.doc?Mu(this.doc,(a=>{sc(a,this,e,t)})):this._pending.push((()=>this.setAttribute(e,t)))}getAttribute(e){return oc(this,e)}getAttributes(){return lc(this)}_write(e){e.writeTypeRef(Xc)}}class Ic{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Uu()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(null!==e&&(!this._firstCall||e.deleted||!this._filter(t)))do{if(t=e.content.type,e.deleted||t.constructor!==Fc&&t.constructor!==Ec||null===t._start)for(;null!==e;){const t=e.next;if(null!==t){e=t;break}e=e.parent===this._root?null:e.parent._item}else e=t._start}while(null!==e&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,null===e?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Ec extends qu{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ec}clone(){const e=new Ec;return e.insert(0,this.toArray().map((e=>e instanceof qu?e.clone():e))),e}get length(){return this.doc??Uu(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(e){return new Ic(this,e)}querySelector(e){e=e.toUpperCase();const t=new Ic(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Ss(new Ic(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)))}_callObserver(e,t){Gu(this,e,new Dc(this,t,e))}toString(){return Xu(this,(e=>e.toString())).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},a){const i=e.createDocumentFragment();return void 0!==a&&a._createAssociation(i,this),Ku(this,(n=>{i.insertBefore(n.toDOM(e,t,a),null)})),i}insert(e,t){null!==this.doc?Mu(this.doc,(a=>{ic(a,this,e,t)})):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(null!==this.doc)Mu(this.doc,(a=>{const i=e&&e instanceof qu?e._item:e;tc(a,this,i,t)}));else{const a=this._prelimContent,i=null===e?0:a.findIndex((t=>t===e))+1;if(0===i&&null!==e)throw mo("Reference item not found");a.splice(i,0,...t)}}delete(e,t=1){null!==this.doc?Mu(this.doc,(a=>{nc(a,this,e,t)})):this._prelimContent.splice(e,t)}toArray(){return Ju(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ec(this,e)}slice(e=0,t=this.length){return Zu(this,e,t)}forEach(e){Ku(this,e)}_write(e){e.writeTypeRef(ed)}}class Fc extends Ec{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach(((e,t)=>{this.setAttribute(t,e)})),this._prelimAttrs=null}_copy(){return new Fc(this.nodeName)}clone(){const e=new Fc(this.nodeName);return((e,t)=>{for(const a in e)t(e[a],a)})(this.getAttributes(),((t,a)=>{"string"==typeof t&&e.setAttribute(a,t)})),e.insert(0,this.toArray().map((e=>e instanceof qu?e.clone():e))),e}toString(){const e=this.getAttributes(),t=[],a=[];for(const t in e)a.push(t);a.sort();const i=a.length;for(let n=0;n<i;n++){const i=a[n];t.push(i+'="'+e[i]+'"')}const n=this.nodeName.toLocaleLowerCase();return`<${n}${t.length>0?" "+t.join(" "):""}>${super.toString()}</${n}>`}removeAttribute(e){null!==this.doc?Mu(this.doc,(t=>{rc(t,this,e)})):this._prelimAttrs.delete(e)}setAttribute(e,t){null!==this.doc?Mu(this.doc,(a=>{sc(a,this,e,t)})):this._prelimAttrs.set(e,t)}getAttribute(e){return oc(this,e)}hasAttribute(e){return uc(this,e)}getAttributes(e){return e?((e,t)=>{const a={};return e._map.forEach(((e,i)=>{let n=e;for(;null!==n&&(!t.sv.has(n.id.client)||n.id.clock>=(t.sv.get(n.id.client)||0));)n=n.left;null!==n&&cu(n,t)&&(a[i]=n.content.getContent()[n.length-1])})),a})(this,e):lc(this)}toDOM(e=document,t={},a){const i=e.createElement(this.nodeName),n=this.getAttributes();for(const e in n){const t=n[e];"string"==typeof t&&i.setAttribute(e,t)}return Ku(this,(n=>{i.appendChild(n.toDOM(e,t,a))})),void 0!==a&&a._createAssociation(i,this),i}_write(e){e.writeTypeRef(Qc),e.writeKey(this.nodeName)}}class Dc extends Ou{constructor(e,t,a){super(e,a),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((e=>{null===e?this.childListChanged=!0:this.attributesChanged.add(e)}))}}class Rc extends fc{constructor(e){super(),this.hookName=e}_copy(){return new Rc(this.hookName)}clone(){const e=new Rc(this.hookName);return this.forEach(((t,a)=>{e.set(a,t)})),e}toDOM(e=document,t={},a){const i=t[this.hookName];let n;return n=void 0!==i?i.createDom(this):document.createElement(this.hookName),n.setAttribute("data-yjs-hook",this.hookName),void 0!==a&&a._createAssociation(n,this),n}_write(e){e.writeTypeRef(td),e.writeKey(this.hookName)}}class Pc extends Vc{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Pc}clone(){const e=new Pc;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,a){const i=e.createTextNode(this.toString());return void 0!==a&&a._createAssociation(i,this),i}toString(){return this.toDelta().map((e=>{const t=[];for(const a in e.attributes){const i=[];for(const t in e.attributes[a])i.push({key:t,value:e.attributes[a][t]});i.sort(((e,t)=>e.key<t.key?-1:1)),t.push({nodeName:a,attrs:i})}t.sort(((e,t)=>e.nodeName<t.nodeName?-1:1));let a="";for(let e=0;e<t.length;e++){const i=t[e];a+=`<${i.nodeName}`;for(let e=0;e<i.attrs.length;e++){const t=i.attrs[e];a+=` ${t.key}="${t.value}"`}a+=">"}a+=e.insert;for(let e=t.length-1;e>=0;e--)a+=`</${t[e].nodeName}>`;return a})).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ad)}}class Lc{constructor(e,t){this.id=e,this.length=t}get deleted(){throw yo()}mergeWith(e){return!1}write(e,t,a){throw yo()}integrate(e,t){throw yo()}}class Bc extends Lc{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),mu(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Oc{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Oc(this.content)}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class $c{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new $c(this.len)}splice(e){const t=new $c(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Dl(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const Uc=(e,t)=>new $l({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class jc{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),null!==e.meta&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new jc(Uc(this.doc.guid,this.opts))}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}class zc{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new zc(this.embed)}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class Wc{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Wc(this.key,this.value)}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){const a=t.parent;a._searchMarker=null,a._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}class Yc{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Yc(this.arr)}splice(e){const t=new Yc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const a=this.arr.length;e.writeLen(a-t);for(let i=t;i<a;i++){const t=this.arr[i];e.writeString(void 0===t?"undefined":JSON.stringify(t))}}getRef(){return 2}}const Hc="development"===rl("node_env");class Gc{constructor(e){this.arr=e,Hc&&Jo(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Gc(this.arr)}splice(e){const t=new Gc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const a=this.arr.length;e.writeLen(a-t);for(let i=t;i<a;i++){const t=this.arr[i];e.writeAny(t)}}getRef(){return 8}}class qc{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new qc(this.str)}splice(e){const t=new qc(this.str.slice(e));this.str=this.str.slice(0,e);const a=this.str.charCodeAt(e-1);return a>=55296&&a<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(0===t?this.str:this.str.slice(t))}getRef(){return 4}}const Zc=[e=>new pc,e=>new fc,e=>new Vc,e=>new Fc(e.readKey()),e=>new Ec,e=>new Rc(e.readKey()),e=>new Pc],Jc=0,Kc=1,Xc=2,Qc=3,ed=4,td=5,ad=6;class id{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new id(this.type._copy())}splice(e){throw yo()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;null!==t;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach((t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)})),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;null!==t;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((t=>{for(;null!==t;)t.gc(e,!0),t=t.left})),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const nd=(e,t,a)=>{const{client:i,clock:n}=t.id,r=new rd(uu(i,n+a),t,uu(i,n+a-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(a));return t.deleted&&r.markDeleted(),t.keep&&(r.keep=!0),null!==t.redone&&(r.redone=uu(t.redone.client,t.redone.clock+a)),t.right=r,null!==r.right&&(r.right.left=r),e._mergeStructs.push(r),null!==r.parentSub&&null===r.right&&r.parent._map.set(r.parentSub,r),t.length=a,r};class rd extends Lc{constructor(e,t,a,i,n,r,s,o){super(e,o.getLength()),this.origin=a,this.left=t,this.right=i,this.rightOrigin=n,this.parent=r,this.parentSub=s,this.redone=null,this.content=o,this.info=this.content.isCountable()?2:0}set marker(e){(8&this.info)>0!==e&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=fu(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=fu(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ou&&this.id.client!==this.parent.client&&this.parent.clock>=fu(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=wu(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=vu(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Bc||this.right&&this.right.constructor===Bc)this.parent=null;else if(this.parent){if(this.parent.constructor===ou){const e=gu(t,this.parent);e.constructor===Bc?this.parent=null:this.parent=e.content.type}}else this.left&&this.left.constructor===rd?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===rd&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wu(e,e.doc.store,uu(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let t,a=this.left;if(null!==a)t=a.right;else if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start;const i=new Set,n=new Set;for(;null!==t&&t!==this.right;){if(n.add(t),i.add(t),lu(this.origin,t.origin)){if(t.id.client<this.id.client)a=t,i.clear();else if(lu(this.rightOrigin,t.rightOrigin))break}else{if(null===t.origin||!n.has(gu(e.doc.store,t.origin)))break;i.has(gu(e.doc.store,t.origin))||(a=t,i.clear())}t=t.right}this.left=a}if(null!==this.left){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(e)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),mu(e.doc.store,this),this.content.integrate(e,this),Su(e,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(e)}else new Bc(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;null!==e&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;null!==e&&e.deleted;)e=e.left;return e}get lastId(){return 1===this.length?this.id:uu(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&lu(e.origin,this.lastId)&&this.right===e&&lu(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&null===this.redone&&null===e.redone&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach((t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))})),e.keep&&(this.keep=!0),this.right=e.right,null!==this.right&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&null===this.parentSub&&(t._length-=this.length),this.markDeleted(),Dl(e.deleteSet,this.id.client,this.id.clock,this.length),Su(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw go();this.content.gc(e),t?((e,t,a)=>{const i=e.clients.get(t.id.client);i[yu(i,t.id.clock)]=a})(e,this,new Bc(this.id,this.length)):this.content=new $c(this.length)}write(e,t){const a=t>0?uu(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,n=this.parentSub,r=31&this.content.getRef()|(null===a?0:Rs)|(null===i?0:Ds)|(null===n?0:32);if(e.writeInfo(r),null!==a&&e.writeLeftID(a),null!==i&&e.writeRightID(i),null===a&&null===i){const t=this.parent;if(void 0!==t._item){const a=t._item;if(null===a){const a=(e=>{for(const[t,a]of e.doc.share.entries())if(a===e)return t;throw go()})(t);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===ou?(e.writeParentInfo(!1),e.writeLeftID(t)):go();null!==n&&e.writeString(n)}this.content.write(e,t)}}const sd=(e,t)=>od[31&t](e),od=[()=>{go()},e=>new $c(e.readLen()),e=>{const t=e.readLen(),a=[];for(let i=0;i<t;i++){const t=e.readString();"undefined"===t?a.push(void 0):a.push(JSON.parse(t))}return new Yc(a)},e=>new Oc(e.readBuf()),e=>new qc(e.readString()),e=>new zc(e.readJSON()),e=>new Wc(e.readKey(),e.readJSON()),e=>new id(Zc[e.readTypeRef()](e)),e=>{const t=e.readLen(),a=[];for(let i=0;i<t;i++)a.push(e.readAny());return new Gc(a)},e=>new jc(Uc(e.readString(),e.readAny())),()=>{go()}];class ld extends Lc{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){go()}write(e,t){e.writeInfo(10),Xs(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const ud="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},cd="__ $YJS$ __";!0===ud[cd]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),ud[cd]=!0;const dd=new Map;const pd="undefined"==typeof BroadcastChannel?class{constructor(e){var t;this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&null!==this.onmessage&&this.onmessage({data:dl(t.newValue||"")}),t=this._onChange,jo||addEventListener("storage",t)}postMessage(e){zo.setItem(this.room,cl(new Uint8Array(e)))}close(){var e;e=this._onChange,jo||removeEventListener("storage",e)}}:BroadcastChannel,hd=e=>ws(dd,e,(()=>{const t=_s(),a=new pd(e);return a.onmessage=e=>t.forEach((t=>t(e.data,"broadcastchannel"))),{bc:a,subs:t}})),fd=(e,t,a=null)=>{const i=hd(e);i.bc.postMessage(t),i.subs.forEach((e=>e(t,a)))},md=(e,t)=>{Xs(e,0);const a=(e=>tu(e,new Yl))(t);no(e,a)},yd=(e,t,a)=>{Xs(e,1),no(e,((e,t)=>Xl(e,t,new Hl))(t,a))},gd=(e,t,a)=>{try{((e,t,a)=>{Kl(e,t,a,jl)})(t,Ao(e),a)}catch(e){console.error("Caught error while handling a Yjs update",e)}},bd=gd,vd=(e,t,a,i)=>{const n=So(e);switch(n){case 0:((e,t,a)=>{yd(t,a,Ao(e))})(e,t,a);break;case 1:gd(e,a,i);break;case 2:bd(e,a,i);break;default:throw new Error("Unknown message type")}return n},wd=3e4;class _d extends Ms{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const e=Bo();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const t=[];this.meta.forEach(((a,i)=>{i!==this.clientID&&wd<=e-a.lastUpdated&&this.states.has(i)&&t.push(i)})),t.length>0&&Ad(this,t,"timeout")}),xs(3e3)),e.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,a=this.meta.get(t),i=void 0===a?0:a.clock+1,n=this.states.get(t);null===e?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:Bo()});const r=[],s=[],o=[],l=[];null===e?l.push(t):null==n?null!=e&&r.push(t):(s.push(t),el(n,e)||o.push(t)),(r.length>0||o.length>0||l.length>0)&&this.emit("change",[{added:r,updated:o,removed:l},"local"]),this.emit("update",[{added:r,updated:s,removed:l},"local"])}setLocalStateField(e,t){const a=this.getLocalState();null!==a&&this.setLocalState({...a,[e]:t})}getStates(){return this.states}}const Ad=(e,t,a)=>{const i=[];for(let a=0;a<t.length;a++){const n=t[a];if(e.states.has(n)){if(e.states.delete(n),n===e.clientID){const t=e.meta.get(n);e.meta.set(n,{clock:t.clock+1,lastUpdated:Bo()})}i.push(n)}}i.length>0&&(e.emit("change",[{added:[],updated:[],removed:i},a]),e.emit("update",[{added:[],updated:[],removed:i},a]))},kd=(e,t,a=e.states)=>{const i=t.length,n=Gs();Xs(n,i);for(let r=0;r<i;r++){const i=t[r],s=a.get(i)||null,o=e.meta.get(i).clock;Xs(n,i),Xs(n,o),ao(n,JSON.stringify(s))}return Zs(n)},Sd=[];Sd[0]=(e,t,a,i,n)=>{Xs(e,0);const r=vd(t,e,a.doc,a);i&&1===r&&!a.synced&&(a.synced=!0)},Sd[3]=(e,t,a,i,n)=>{Xs(e,1),no(e,kd(a.awareness,Array.from(a.awareness.getStates().keys())))},Sd[1]=(e,t,a,i,n)=>{((e,t,a)=>{const i=_o(t),n=Bo(),r=[],s=[],o=[],l=[],u=So(i);for(let t=0;t<u;t++){const t=So(i);let a=So(i);const u=JSON.parse(To(i)),c=e.meta.get(t),d=e.states.get(t),p=void 0===c?0:c.clock;(p<a||p===a&&null===u&&e.states.has(t))&&(null===u?t===e.clientID&&null!=e.getLocalState()?a++:e.states.delete(t):e.states.set(t,u),e.meta.set(t,{clock:a,lastUpdated:n}),void 0===c&&null!==u?r.push(t):void 0!==c&&null===u?l.push(t):null!==u&&(el(u,d)||o.push(t),s.push(t)))}(r.length>0||o.length>0||l.length>0)&&e.emit("change",[{added:r,updated:o,removed:l},a]),(r.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:r,updated:s,removed:l},a])})(a.awareness,Ao(t),a)},Sd[2]=(e,t,a,i,n)=>{((e,t,a)=>{0===So(e)&&a(t,To(e))})(t,a.doc,((e,t)=>Nd(a,t)))};const Nd=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),Td=(e,t,a)=>{const i=_o(t),n=Gs(),r=So(i),s=e.messageHandlers[r];return s?s(n,i,e,a,r):console.error("Unable to compute message"),n},Md=(e,t,a)=>{t===e.ws&&(e.emit("connection-close",[a,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,Ad(e.awareness,Array.from(e.awareness.getStates().keys()).filter((t=>t!==e.doc.clientID)),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(xd,Vs(100*Es(2,e.wsUnsuccessfulReconnects),e.maxBackoffTime),e))},xd=e=>{if(e.shouldConnect&&null===e.ws){const t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=a=>{e.wsLastMessageReceived=Bo();const i=Td(e,new Uint8Array(a.data),!0);qs(i)>1&&t.send(Zs(i))},t.onerror=t=>{e.emit("connection-error",[t,e])},t.onclose=a=>{Md(e,t,a)},t.onopen=()=>{e.wsLastMessageReceived=Bo(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const a=Gs();if(Xs(a,0),md(a,e.doc),t.send(Zs(a)),null!==e.awareness.getLocalState()){const a=Gs();Xs(a,1),no(a,kd(e.awareness,[e.doc.clientID])),t.send(Zs(a))}},e.emit("status",[{status:"connecting"}])}},Cd=(e,t)=>{const a=e.ws;e.wsconnected&&a&&a.readyState===a.OPEN&&a.send(t),e.bcconnected&&fd(e.bcChannel,t,e)};class Vd extends Ts{constructor(e,t,a,{connect:i=!0,awareness:n=new _d(a),params:r={},protocols:s=[],WebSocketPolyfill:o=WebSocket,resyncInterval:l=-1,maxBackoffTime:u=2500,disableBc:c=!1}={}){for(super();"/"===e[e.length-1];)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=u,this.params=r,this.protocols=s,this.roomname=t,this.doc=a,this._WS=o,this.awareness=n,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=c,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Sd.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=i,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval((()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=Gs();Xs(e,0),md(e,a),this.ws.send(Zs(e))}}),l)),this._bcSubscriber=(e,t)=>{if(t!==this){const t=Td(this,new Uint8Array(e),!1);qs(t)>1&&fd(this.bcChannel,Zs(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){const t=Gs();Xs(t,0),((e,t)=>{Xs(e,2),no(e,t)})(t,e),Cd(this,Zs(t))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:a},i)=>{const r=e.concat(t).concat(a),s=Gs();Xs(s,1),no(s,kd(n,r)),Cd(this,Zs(s))},this._exitHandler=()=>{Ad(this.awareness,[a.clientID],"app closed")},tl&&void 0!==gs&&gs.on("exit",this._exitHandler),n.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval((()=>{this.wsconnected&&3e4<Bo()-this.wsLastMessageReceived&&Md(this,this.ws,null)}),3e3),i&&this.connect()}get url(){const e=(e=>((e,t)=>{const a=[];for(const i in e)a.push(t(e[i],i));return a})(e,((e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`)).join("&"))(this.params);return this.serverUrl+"/"+this.roomname+(0===e.length?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){0!==this._resyncInterval&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),tl&&void 0!==gs&&gs.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;var e,t;this.bcconnected||(e=this.bcChannel,t=this._bcSubscriber,hd(e).subs.add(t),this.bcconnected=!0);const a=Gs();Xs(a,0),md(a,this.doc),fd(this.bcChannel,Zs(a),this);const i=Gs();Xs(i,0),yd(i,this.doc),fd(this.bcChannel,Zs(i),this);const n=Gs();Xs(n,3),fd(this.bcChannel,Zs(n),this);const r=Gs();Xs(r,1),no(r,kd(this.awareness,[this.doc.clientID])),fd(this.bcChannel,Zs(r),this)}disconnectBc(){const e=Gs();Xs(e,1),no(e,kd(this.awareness,[this.doc.clientID],new Map)),Cd(this,Zs(e)),this.bcconnected&&(((e,t)=>{const a=hd(e),i=a.subs.delete(t);i&&0===a.subs.size&&(a.bc.close(),dd.delete(e))})(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),null!==this.ws&&Md(this,this.ws,null)}connect(){this.shouldConnect=!0,this.wsconnected||null!==this.ws||(xd(this),this.connectBc())}}class Id extends $l{}class Ed{apiClient;collabDocument;yWebsocketProvider;item;awareness;users=[];avatars=new Map;constructor(e){this.apiClient=e,this.collabDocument=new Id}isActive(){return void 0!==this.yWebsocketProvider}getAwarenessStates(){return this.awareness?this.awareness.getStates():new Map}getUsersList(){return this.users}_getUser(e){for(const t of this.users)if(e===t.key)return t;return null}getLocalState(){if(!this.awareness)throw new Error("No awareness available. Cannot get state field.");return this.awareness.getLocalState()}setLocalStateField(e,t){if(!this.awareness)throw new Error("No awareness available. Cannot set state field.");this.awareness.setLocalStateField(e,t)}async _updateUsersList(){const e=this.getAwarenessStates(),t=await this.apiClient.me(!0);for(const[a,i]of e.entries()){if(!this._getUser(a)){let e=this.avatars.get(i.user.id);if(!e){e=(await this.apiClient.getAvatar(i.user.id,32)).avatar,this.avatars.set(i.user.id,e)}this.users.push({key:a,id:i.user.id,name:i.user.name,color:i.user.color,avatar:e,itsMe:i.user.id===t._id})}}const a=[];for(const t of this.users)e.has(t.key)&&a.push(t);this.users=a}async startCollaboration(e){try{if(!this.apiClient.isDevOrLocalhost())return!1;this.endCollaboration(),this.item=e;const t=this.apiClient.getCollabUrl(),a=`${this.item.type}.${this.item._id}`;let i=1e3;this.yWebsocketProvider=new Vd(t,a,this.collabDocument,{connect:!1}),this.yWebsocketProvider.on("status",(e=>{console.log(`[Collab] ${e.status}`),"disconnected"===e.status&&this.yWebsocketProvider&&(this.yWebsocketProvider.disconnect(),setTimeout(r,i))})),this.yWebsocketProvider.on("sync",(e=>{console.log(`[Collab] synced: ${e}`)})),this.awareness=this.yWebsocketProvider.awareness,this.awareness.on("change",(async e=>{await this._updateUsersList(),u.$emit("collab:awareness:changed",{users:this.users,states:this.getAwarenessStates(),changes:e})}));const n=await this.apiClient.me(!0);this.awareness.setLocalStateField("user",{id:n._id,name:n.name,color:h.colorFromString(n.name)});const r=async()=>{if(!this.yWebsocketProvider)return void console.warn("[Collab] Cannot connect without websocket provider!");console.log("[Collab] reconnecting...");const e=await this.apiClient.getCollabToken();this.yWebsocketProvider.params.token=e,this.yWebsocketProvider.connect()};return await r(),u.$emit("collab:started"),!0}catch(e){return console.error("Error starting collaboration: ",e),!1}}endCollaboration(){this.yWebsocketProvider&&(console.log("Ending collaboration."),u.$emit("collab:ended"),this.yWebsocketProvider.destroy(),this.yWebsocketProvider=void 0,this.awareness=void 0),this.collabDocument=new Id,this.item=void 0}}class Fd{apiClient;constructor(e){this.apiClient=e}async testCopyItems(e,t){const a=await this.apiClient.getItemsInFolderList(t,!0),i=await this.apiClient.getFoldersInFolderList(t),n=new Map;for(const e of i.children)n.set(e.name,null);for(const e of a)n.set(e.name,e._id);const r=this.apiClient.getItemRepo(),s=[];for(const t of e){let e,a,i=!1;t.isFolder?a=await this.apiClient.getFolder(t._id):(a=r.getLoadedItem(t._id),a||(a=await this.apiClient.getItem(t._id))),e=a?.name,i=n.has(e),s.push({_id:t._id,isFolder:t.isFolder,data:a,name:e,conflicted:i,conflictedItemId:n.get(e)})}return s}async copyItems(e,t,a=!1,i=!1){const n=e.filter((e=>!e.isFolder)).map((e=>e._id)),r=await this.apiClient.copyItems(n,t,a,i),s=this.apiClient.getItemRepo();for(let t of r){const a=e.filter((e=>e._id===t.original));a.length>0&&(t.replaced=a[0].conflictedItemId),await s.replaceLink(t.original,t.clone)}return await this.apiClient.eventBus.$emit("folder:changed",t),await this.apiClient.eventBus.$emit("items:copied",r),r}}class Dd{apiClient;jobManager;constructor(e){this.apiClient=e,this.jobManager=e.getJobManager()}async executeExport(e,t,a,i){const n=await this.jobManager.execute("EXPORT:ExportGame",[{_id:e,isFolder:!1}],[{name:"Destination Folder",value:a},{name:"EngineVersion",value:i}],void 0,{os:t});if(await this.apiClient.eventBus.$emit("quota:update"),2===n.state)throw new A("Export failed: "+n.error);await this.apiClient.eventBus.$emit("folder:changed",[a])}}(i.default?i.default:i)(a,{retries:3,retryCondition:e=>e.message.includes("net::ERR_NETWORK_CHANGED")});const Rd={Draft:0,Private:1,NotListed:2,Public:3};e.AccessDeniedException=N,e.AggregatedItem=M,e.ApiClient=class extends l{accessToken;apiToken;options;forcePublicApi;usePublicApi;usePersistentStorage;storageSizeMib;requestClientId;webProtocol;wsProtocol;viewerProtocol;collabProtocol;restUrl;wsUrl;viewerUrl;collabUrl;itemRepo;itemCache;folderCache;thumbCache;userCache;groupCache;attachmentCache;jobManager;serializer;collab;itemCopier;executableExporter;eventBus;api;ws;cachedMe;profiler;wsLastPing;last2faCode="";constructor(e={}){super(),e=e||{},this.options=Object.assign({host:"auto",viewerHost:"auto",collabHost:"auto",https:!0,path:"",websocketPath:"/api/ws",wsAutoReconnect:!0,wsAutoConnect:!1,forcePublicApi:!1,debug:!1,accessToken:null,apiToken:null,viewerHttps:!1,collabHttps:!1,usePersistentStorage:!0,storageSizeMib:10240,requestClientId:null},e);const t=this.isOnLocalhost(),i=this.isDevPlatform();"auto"===this.options.host&&(this.options.host="api.lumino.cloud",this.options.https=!0,"object"==typeof window&&"location"in window&&(i?(this.options.host="api-dev.lumino.cloud",this.options.https=!0):t&&(this.options.host="localhost:8081",this.options.https=!1))),"auto"===this.options.viewerHost&&(this.options.viewerHost="viewer.lumino.cloud",this.options.viewerHttps=!0,"object"==typeof window&&"location"in window&&(i?(this.options.viewerHost="viewer-dev.lumino.cloud",this.options.viewerHttps=!0):t&&(this.options.viewerHost="localhost:8090",this.options.viewerHttps=!1))),"auto"===this.options.collabHost&&(this.options.collabHost="collab.lumino.cloud",this.options.collabHttps=!0,"object"==typeof window&&"location"in window&&(i?(this.options.collabHost="collab-dev.lumino.cloud",this.options.collabHttps=!0):t&&(this.options.collabHost="localhost:8200",this.options.collabHttps=!1))),this.accessToken=this.options.accessToken,this.apiToken=this.options.apiToken,this.forcePublicApi=this.options.forcePublicApi,this.usePublicApi=!this.accessToken&&!this.apiToken,this.usePersistentStorage=this.options.usePersistentStorage,this.storageSizeMib=this.options.storageSizeMib,this.requestClientId=this.options.requestClientId,this.cachedMe=null,this.itemRepo=new jn(this.usePublicApi,this),this.itemCache=new Fr(this.usePublicApi,this.usePersistentStorage,this,this.storageSizeMib),this.folderCache=new Dr(this),this.thumbCache=new Rr(this),this.userCache=new Pr(this),this.groupCache=new Lr(this),this.attachmentCache=new Br(this),this.jobManager=new Ur(this),this.serializer=new Gr(this),this.collab=new Ed(this),this.itemCopier=new Fd(this),this.executableExporter=new Dd(this),this.eventBus=u,this.profiler=null,this.webProtocol=this.options.https?"https":"http",this.restUrl=`${this.webProtocol}://${this.options.host}${this.options.path}`,this.wsProtocol=this.options.https?"wss":"ws",this.wsUrl=`${this.wsProtocol}://${this.options.host}${this.options.websocketPath}`,this.viewerProtocol=this.options.viewerHttps?"https":"http",this.viewerUrl=`${this.viewerProtocol}://${this.options.viewerHost}`,this.collabProtocol=this.options.collabHttps?"wss":"ws",this.collabUrl=`${this.collabProtocol}://${this.options.collabHost}`,this.api=a.create({baseURL:this.restUrl}),this.ws=null,this.wsLastPing=null,this.setDebugMode(this.options.debug)}async initCaches(){return Promise.all([this.itemCache.init(),this.folderCache.init(),this.thumbCache.init()])}clearCaches(){this.itemCache.clear(),this.folderCache.clear(),this.thumbCache.clear()}isDevPlatform(){return"object"==typeof window&&"location"in window&&window.location.href.includes("dev.lumino.cloud")}isOnLocalhost(){return"object"==typeof window&&"location"in window&&window.location.href.includes("localhost")}isDevOrLocalhost(){return this.isOnLocalhost()||this.isDevPlatform()}async clearIndexedDb(e){return new Promise(((t,a)=>{const i=indexedDB.deleteDatabase(e);i.onsuccess=()=>{t()},i.onerror=e=>{a("An error occured while deleting a IndexedDB database.")},i.onblocked=()=>{a(`Database deletion is blocked. Please close all connections to "${e}".`)}}))}async logout(){return this.clearCaches(),this.clearIndexedDb("lumino")}setDebugMode(e){this.options.debug=!!e,this.eventBus.setDebugMode(this.options.debug)}websocketConnect(e){const t=this;if(this.ws){if(!e)return void console.warn("Websocket is already connected!");this.websocketDisconnect()}this.ws=new n(this.wsUrl),this.ws.onerror=function(e){console.error("Websocket error",e),t.$emit("client:websocketError",e)},this.ws.onopen=function(){t.$emit("client:websocketOpen"),t.accessToken&&t.websocketSend(JSON.stringify({type:"auth",subscriptions:["item","folder","job","user","notification"],token:t.accessToken}))},this.ws.onclose=function(){t.$emit("client:websocketClosed"),t.options.wsAutoReconnect&&t.websocketConnect(!0)},this.ws.onmessage=function(e){try{const a=JSON.parse(e.data);switch(a.type){case"ping":t.wsLastPing=new Date,t.ws&&t.ws.send(JSON.stringify({type:"ping"}));break;case"authenticated":t.$emit("client:websocketAuthenticated");break;case"Item":case"Folder":case"Notification":case"Job":case"User":u.$emit("client:elementUpdate",a);break;default:console.warn("Unknown websocket message: ",a)}}catch(e){console.error("Websocket error:",e)}}}websocketDisconnect(){this.ws&&(this.ws.close(),this.ws=null)}websocketSend(e){this.ws?1===this.ws.readyState?this.ws.send(e):console.error("Websocket is not in READY state. Currently in state "+this.ws.readyState):console.error("Websocket is not created")}getItemCopier(){return this.itemCopier}getExecutableExporter(){return this.executableExporter}getCollab(){return this.collab}getCollabUrl(){return this.collabUrl}getPublisher(){return new Or(this)}getAssetCreator(){return new Hr(this)}getJobManager(){return this.jobManager}getThumbCache(){return this.thumbCache}getItemCache(){return this.itemCache}getItemRepo(){return this.itemRepo}getRootVisibility(){return this.itemRepo.activeItem?this.itemRepo.activeItem.visibility:Rd.Private}getEventBus(){return this.eventBus}getSerializer(){return this.serializer}setForcePublicApi(e){this.forcePublicApi=e,this._updateUsePublicApi()}_updateUsePublicApi(){this.usePublicApi=this.forcePublicApi||!this.apiToken&&!this.accessToken,this.itemRepo.usePublicApi=this.usePublicApi,this.itemCache.usePublicApi=this.usePublicApi}setApiToken(e){this.apiToken=e,this._updateUsePublicApi()}setAccessToken(e){this.accessToken=e,this._updateUsePublicApi(),this.accessToken&&this.options.wsAutoConnect&&this.websocketConnect()}getApiToken(){return this.apiToken}getAccessToken(){return this.accessToken}updateBaseUrl(e){this.options.host=e,this.webProtocol=this.options.https?"https":"http";const t=`${this.webProtocol}://${this.options.host}${this.options.path}`;this.setApiBaseUrl(t),this.wsProtocol=this.options.https?"wss":"ws";const a=`${this.wsProtocol}://${this.options.host}${this.options.websocketPath}`;this.setWsBaseUrl(a)}setApiBaseUrl(e){this.restUrl=e,this.api=a.create({baseURL:this.restUrl})}setWsBaseUrl(e){this.wsUrl=e,this.accessToken&&this.options.wsAutoConnect&&(this.websocketDisconnect(),this.websocketConnect())}setRequestClientId(e){this.requestClientId=e}getApiBaseUrl(){return this.restUrl}getWsBaseUrl(){return this.wsUrl}getViewerBaseUrl(){return this.viewerUrl}setProfiler(e){if(!e||"function"!=typeof e.start)throw new Error("Profiler needs to be an object providing a start function.");this.profiler=e}async login2FA(e,t,a){return console.log("Running Login..."),this.execute("post","/api/auth/login2fa",{account:e,password:t,client:a}).then((e=>{this.last2faCode=e,this.eventBus.$emit("login.2facode",e)}))}async confirm2FA(e,t){return this.execute("post","/api/auth/confirm2fa",{account:e,code:t})}isAuthenticated(){return!!this.accessToken||!!this.apiToken}isFeatureEnabled(e){return!!this.cachedMe&&this.cachedMe.features.includes(e)}async resolveUserOrGroupInfoForItem(e){return e.quotaUser?this.userCache.resolve(e.quotaUser):e.quotaGroup?this.groupCache.resolve(e.quotaGroup):e.createdBy?this.userCache.resolve(e.createdBy):{name:"?",initials:"?",avatar:null}}_startOp(e){const t=this,a={id:h.createGUID(),name:e,startTimeMs:performance.now(),runningMs:0,percent:0,reportProgress:function(e){a.percent=e},interval:null,finish:function(){if(a.interval&&clearInterval(a.interval),a.runningMs>1e3)try{t.$emit("client:longRunningOpFinished",a.id)}catch(e){console.error(e)}}};return a.interval=setInterval((function(){if(a.runningMs=performance.now()-a.startTimeMs,a.runningMs>1e3)try{t.$emit("client:longRunningOp",a.id,a.name,a.percent)}catch(e){console.error(e)}}),100),a}_createOpName(e,t){try{const a=t.split("/");switch(e.toLowerCase()){case"get":e="Fetching";break;case"post":e="Creating";break;case"put":e="Updating";break;case"delete":e="Deleting"}a.shift(),a.shift();const i=a.shift();let n=a.join("/");return n.length&&(n=` [${n}]`),`${e} ${i} data ${n}`}catch{return`${e} ${t}`}}addAuthenticationHeaders(e){this.accessToken&&(e["x-access-token"]=this.accessToken),this.apiToken&&(e["x-api-token"]=this.apiToken),this.requestClientId&&(e["x-request-client"]=this.requestClientId)}async execute(e,t,a,i){let n=this,r={};(i=i||{}).headers?r=i.headers:a&&"object"==typeof a&&"getHeaders"in a&&"function"==typeof a.getHeaders&&(r=a.getHeaders()),this.addAuthenticationHeaders(r);const s=this.profiler?this.profiler.start("ApiClient",`${e} ${t}`):null,o=this._startOp(i.opName||n._createOpName(e,t));return this.api({method:e,url:t,data:a,responseType:i.responseType,headers:r,signal:i.controller?i.controller.signal:void 0,onUploadProgress:function(e){if(e.total){const t=Math.min(100,Math.round(100*e.loaded/e.total));o.reportProgress(t),n.$emit("client:progress",{type:"upload",percent:t}),"function"==typeof i.progressCallback&&i.progressCallback(t,e.loaded,e.total)}},onDownloadProgress:function(e){if(e.total){const t=Math.min(100,Math.round(100*e.loaded/e.total));o.reportProgress(t),n.$emit("client:progress",{type:"download",percent:t}),"function"==typeof i.progressCallback&&i.progressCallback(t,e.loaded,e.total)}}}).then((e=>{if(s&&s.done(),o.finish(),n.$emit("client:progress",{type:"done"}),e.headers["content-type"].startsWith("application/json")){if("success"===e.data.result){let t;return t=i.withNext?{data:e.data.data,next:e.data.next}:e.data.data,i.emitOnSuccess&&this.eventBus.$emit(i.emitOnSuccess,t),t}throw e.data.redirect&&this.$emit("client:redirect",e.data.redirect),e.data.error?e.data.error:"API response seems to be json but does not contain result type!"}return i.emitOnSuccess&&this.eventBus.$emit(i.emitOnSuccess),{blob:new Blob([e.data],{type:e.headers["content-type"]}),hash:e.headers["sha256-hash"],itemName:e.headers["lumino-itemname"],itemType:e.headers["lumino-itemtype"],mimeType:e.headers["content-type"]}})).catch((e=>{if(s&&s.done(),o.finish(),n.$emit("client:progress",{type:"done"}),e.response){if(401===e.response.status)throw this.$emit("client:unauthorized"),new N("Access denied. Please login again.");if(413===e.response.status)throw new S;if(e.response.data&&e.response.data.error)throw new Error(e.response.data.error)}throw e}))}_createFormData(e,t){let a=new r;if("function"==typeof File&&e instanceof Blob)a.append("file",e,t);else{const i=new Blob([e]);try{a.append("file",i,t)}catch{a=new r,a.append("file",e,t)}}return a}async me(e){return e&&this.cachedMe||(this.cachedMe=await this.execute("get","/api/auth/me")),this.cachedMe}async getHomeFolder(){return this.execute("get","/api/auth/homefolder")}async myClients(){return this.execute("get","/api/auth/myclients")}async getCollabToken(){return this.execute("get","/api/auth/collabtoken")}async checkCollabToken(e){return this.execute("post","/api/auth/collabtoken",{token:e})}async register(e){return this.execute("post","/api/auth/register",e)}async deleteMyAccount(e){return this.execute("post","/api/auth/deletemyaccount",{password:e})}async confirmEmail(e){return this.execute("get","/api/auth/confirmemail/"+e)}async confirmEmailChange(e){return this.execute("get","/api/auth/confirmchangedemail/"+e)}async forgotPassword(e,t){return this.execute("post","/api/auth/forgotpassword",{account:e,client:t})}async setNewPassword(e,t){return this.execute("post","/api/auth/setnewpassword",{token:e,password:t})}async accountExists(e){return this.execute("post","/api/auth/accountExists",e)}async getItemsInFolderList(e,t=!1){if(e&&!t){const t=await this.folderCache.getItemListing(e);if(t)return t}const a=await this.execute("get","/api/item/infolder/"+(e||"0"));return await this.folderCache.addItemListing(e,a),a}async getItem(e,t){const a=[];t&&(t.returnClonedFrom&&a.push("returnClonedFrom=true"),t.withThumbnails&&a.push("withThumbnails=true"));let i="";return a.length&&(i=`?${a.join("&")}`),this.execute("get",`/api/item/${e}${i}`)}getItemAggregatedPOP(e,t){return this.usePublicApi?this.getItemPublicAggregated(e,t):this.getItemAggregated(e,t)}async getItemPublicAggregated(e,t){const a=En(e);if(a)return a;const i=[];t&&(t.withFieldInstances&&i.push("withFieldInstances"),t.withAttachmentInfo&&i.push("withAttachmentInfo"),t.noAttributes&&i.push("noAttributes"),t.noUserAttributes&&i.push("noUserAttributes"),t.noFields&&i.push("noFields"),t.noThumbnails&&i.push("noThumbnails"),t.noLinks&&i.push("noLinks"));let n="";return i.length&&(n=`?${i.join("&")}`),En(e)?En(e):this.execute("get","/api/item/publicaggregate/"+e+n)}async getItemAggregated(e,t){const a=En(e);if(a)return a;const i=[];t&&(t.withFieldInstances&&i.push("withFieldInstances"),t.withAttachmentInfo&&i.push("withAttachmentInfo"),t.noAttributes&&i.push("noAttributes"),t.noUserAttributes&&i.push("noUserAttributes"),t.noFields&&i.push("noFields"),t.noThumbnails&&i.push("noThumbnails"),t.noLinks&&i.push("noLinks"));let n="";return i.length&&(n=`?${i.join("&")}`),En(e)?En(e):this.execute("get",`/api/item/aggregate/${e}${n}`)}async getItemAggregatedRecursive(e,t){const a=[];t&&(t.withFieldInstances&&a.push("withFieldInstances"),t.withAttachmentInfo&&a.push("withAttachmentInfo"),t.noAttributes&&a.push("noAttributes"),t.noUserAttributes&&a.push("noUserAttributes"),t.noFields&&a.push("noFields"),t.noThumbnails&&a.push("noThumbnails"));let i="";return a.length&&(i=`?${a.join("&")}`),this.execute("get",`/api/item/aggregaterecursive/${e}${i}`)}async getItemPublicRecursive(e,t){return this.execute("get","/api/item/publicrecursive/"+e+(t?"?withFeatures":""))}async getItemPublic(e,t){return this.execute("get","/api/item/public/"+e+(t?"?returnClonedFrom=true":""))}async getItemHistory(e){return this.execute("get","/api/item/history/"+e)}async copyItems(e,t,a,i){return this.execute("post","/api/item/copy",{sourceItemIds:e,destFolderId:t,deepCopy:a,overwrite:i})}async createItem(e){return this.execute("post","/api/item",e)}async updateItem(e){return this.execute("put","/api/item",e)}async deleteItem(e){return this.execute("delete","/api/item",{id:e})}async renameItem(e,t){return this.updateItem({_id:e,name:t})}async queryPublicItemsList(e){return this.execute("post","/api/item/publicquery",e)}async queryItemsListPOP(e){return this.usePublicApi?this.queryPublicItemsList(e):this.queryItemsList(e)}async queryItemsList(e){return this.execute("post","/api/item/query",e)}async queryItemsListAsExcel(e){e.exportAsExcel=!0;const t=await this.execute("post","/api/item/query",e,{responseType:"arraybuffer"}),a=window.URL.createObjectURL(t.blob),i=document.createElement("a");i.href=a,i.setAttribute("download","export.xlsx"),i.click()}async moveItems(e){return this.execute("post","/api/item/move",e)}async downloadItem(e,t){const a=Tn(e);return a||this.execute("get",`/api/item/download/${e}`,null,{responseType:"arraybuffer",progressCallback:t,opName:`Downloading item ${e}`})}async publicDownloadItem(e,t){const a=Tn(e);return a||this.execute("get",`/api/item/publicdownload/${e}`,null,{responseType:"arraybuffer",progressCallback:t})}async getItemHash(e){const t=En(e);return t?t.hash:this.execute("get",`/api/item/hash/${e}`)}async requestSecureDownload(e){return this.execute("get","/api/item/requestsecuredownload/"+e)}async getThumbnail(e,t){return this.execute("get",`/api/item/thumbnail/${e}/${t}`)}async uploadThumbnail(e,t,a,i,n,r){const s=this._createFormData(a,i);return this.execute("post",`/api/item/thumbnail/${t}/${e}`,s,{progressCallback:n,controller:r})}async getPublicThumbnail(e,t){return this.execute("get",`/api/item/publicthumbnail/${e}/${t}`)}async makeItemPublic(e,t,a){return this.execute("put","/api/item/makepublic",{id:e,recursive:t,inSubfolders:a})}async setVisibility(e,t,a,i){return this.execute("put","/api/item/setvisibility",{id:e,visibility:t,recursive:a,inSubfolders:i})}async makeItemPrivate(e,t,a){return this.execute("put","/api/item/makeprivate",{id:e,recursive:t,inSubfolders:a})}async setOmitLodGeneration(e,t){return this.execute("get",`/api/item/setOmitLodGeneration/${e}/${t}`)}async setOmitThumbnailGeneration(e,t){return this.execute("get",`/api/item/setOmitThumbnailGeneration/${e}/${t}`)}async setOmitPreviewGeneration(e,t){return this.execute("get",`/api/item/setOmitPreviewGeneration/${e}/${t}`)}async uploadAndCreate(e,t,a,i,n,r){const s=this._createFormData(t,a);let o=`/api/item/uploadAndCreate/${e}`,l={};return i&&("object"==typeof i?(i.autoDestructIn&&(o+="?autoDestructIn="+i.autoDestructIn),i.visibility&&(o+="?visibility="+i.visibility),i.flags&&(o+="?flags="+i.flags),i.overwrite&&(o+="?overwrite="+(i.overwrite?"true":"false")),i.nameOverride&&(l["x-override-name"]=i.nameOverride)):o+="?autoDestructIn="+i),this.execute("post",o,s,{progressCallback:n,controller:r,headers:l})}async upload(e,t,a,i,n,r){const s=[];r&&(r.omitHandleDependencyChange&&s.push("omitHandleDependencyChange=true"),r.keepThumbnails&&s.push("keepThumbnails=true"));let o="";s.length&&(o=`?${s.join("&")}`);const l=this._createFormData(t,a);return this.execute("post",`/api/item/upload/${e}${o}`,l,{progressCallback:i,controller:n})}resetPreview(e){const t=this.execute("delete",`/api/item/attachment/${e}/preview`),a=this.execute("get",`/api/item/setOmitPreviewGeneration/${e}/false`);return Promise.all([t,a])}clearPreview(e){const t=this.execute("delete",`/api/item/attachment/${e}/preview`),a=this.execute("get",`/api/item/setOmitPreviewGeneration/${e}/true`);return Promise.all([t,a])}async clearThumbnail(e){return this.execute("get",`/api/item/clearThumbnail/${e}`)}async resetThumbnail(e){return this.execute("get",`/api/item/resetThumbnail/${e}`)}async downloadAttachmentPOP(e,t,a,i,n){return this.usePublicApi?this.downloadPublicAttachment(e,t,a,i,n):this.downloadAttachment(e,t,a,i,n)}_getAttachmentUrlPath(e,t,a,i,n){return`/api/item/${n?"public":""}attachment/${e}/${t}${null!=a?`/${a}`:"/undefined"}${null!=i?`/${i}`:""}`}async downloadAttachment(e,t,a,i=0,n){const r=Ln(e,t,a,i);return r||this.execute("get",this._getAttachmentUrlPath(e,t,a,i),null,{responseType:"arraybuffer",progressCallback:n})}async downloadPublicAttachment(e,t,a,i,n){const r=Ln(e,t,a,i);return r||this.execute("get",this._getAttachmentUrlPath(e,t,a,i,!0),null,{responseType:"arraybuffer",progressCallback:n})}async uploadAttachment(e,t,a,i,n,r,s,o){const l=this._createFormData(n,r);return this.execute("post",this._getAttachmentUrlPath(e,t,a,i),l,{progressCallback:s,controller:o})}async deleteAttachment(e,t,a,i){return this.attachmentCache.invalidateAttachment(e,t,a,i),this.execute("delete",this._getAttachmentUrlPath(e,t,a,i))}setPerceptiveHashOnAttachment(e,t,a){return this.execute("get",`/api/item/setPerceptiveHashAttachment/${e}/${t}/${a}`)}setPerceptiveHash(e,t){return this.execute("get",`/api/item/setPerceptiveHash/${e}/${t}`)}async getItemClient(e){return this.execute("get",`/api/item/getClient/${e}`)}async getItemAcl(e){return this.execute("get",`/api/item/acl/${e}`)}async getItemsLinking(e){return this.execute("get",`/api/item/linking/${e}`)}async setAttributes(e,t){return this.execute("put","/api/item/setAttributes",{id:e,attributes:t})}async getItemSyncList(e){const t=P(e).format("YYYYMMDDHHmmss");return this.execute("get",`/api/item/synclist/${t}`)}async increaseViews(e){return this.execute("get",`/api/item/increaseViews/${e}`)}async getViews(e){return this.execute("get",`/api/item/views/${e}`)}async getPublicItemCounts(e){return this.execute("get",`/api/item/publiccounts/${e}`)}async getItemCounts(e){return this.execute("get",`/api/item/counts/${e}`)}async likeItem(e){return this.execute("get",`/api/item/like/${e}`)}async unlikeItem(e){return this.execute("get",`/api/item/unlike/${e}`)}async doILike(e){return this.execute("get",`/api/item/doILike/${e}`)}async setItemAutoDestruct(e,t){const a=P(t).format("YYYYMMDDHHmmss");return this.execute("get",`/api/item/setAutoDestruct/${e}/${a}`)}async clearItemAutoDestruct(e){return this.execute("get",`/api/item/clearAutoDestruct/${e}`)}async resolveRelativeItem(e,t){const a=En(e);if(!a)return this.execute("post","/api/item/resolve/"+e,{path:t});t.startsWith("/")&&(t=t.substring(1));const i=t.split("/"),n=i.pop();let r=a.folder._id;for(const e of i){let t=!1;for(const[a,i]of Object.entries(Mn()))if(i.parent===r&&i.name===e){r=a,t=!0;break}if(!t)break}for(const e of Object.values(In()))if(e.folder._id===r&&e.name===n)return e._id;return console.error(`Could not resolve path ${t} for item ${e}`),null}async publicResolveRelativeItem(e,t){const a=En(e);if(!a)return this.execute("post","/api/item/publicResolve/"+e,{path:t});t.startsWith("/")&&(t=t.substring(1));const i=t.split("/"),n=i.pop();let r=xn(a.folder._id);for(const e of i)if(".."===e)r=xn(r.parent);else{const t=Cn(e,r._id);if(!t)throw new Error("Can't find folder while loading folder from package");r=t}const s=Vn(n,r._id);if(s)return s._id;throw new Error("Can't load item from package.")}async rewireItems(e){return this.execute("post","/api/item/rewire",{items:e})}async getFolder(e){return this.execute("get","/api/folder/"+e)}async getFullFolderTree(e){return this.execute("get",`/api/folder/fulltree/${e||"0"}`)}async getFoldersInFolderList(e,t){e=e||"0";const a=[];let i="";if(t){if(t.resolveNames&&!t.folderAsItemType&&"0"!==e){if(i=await this.folderCache.getFolderListing(e),i&&Date.now()-new Date(i.cachedAt).getTime()<1e4)return i;i&&i.parent&&a.push(`lastUpdatedAt=${i.parent.updatedAt}`)}t.resolveNames&&a.push("resolve"),t.folderAsItemType&&a.push(`folderAsItemType=${t.folderAsItemType}`),t.folderAsItemName&&a.push(`folderAsItemName=${t.folderAsItemName}`),t.folderAsItemFlag&&a.push(`folderAsItemFlag=${t.folderAsItemFlag}`),t.withStats&&a.push("withStats=true"),t.returnLatestPackage&&a.push("returnLatestPackage=true")}let n="";a.length&&(n="?"+a.join("&"));const r=await this.execute("get",`/api/folder/infolder/${e}${n}`);if(!0===r.notModified)return i;if(!t||t.resolveNames&&!t.folderAsItemType){const t=await this.getFolderAclList([e,...r.children.map((e=>e._id))]);for(const e of t)await this.folderCache.addACL(e.id,e.acl);return await this.folderCache.addFolderListing(e,r),r}return r}async updateFolderCache(e){const t=[];for(const a of e){if(!a)continue;const e=await this.folderCache.getFolderListing(a);e&&e.parent?t.push({id:a,lastUpdatedAt:e.parent.updatedAt}):t.push({id:a})}const a=await this.execute("post","/api/folder/infolderquery",{folders:t});for(const e of a)!0===e.data.notModified?await this.folderCache.refreshCacheForFolder(e.id):await this.folderCache.addFolderListing(e.id,e.data)}async createFolder(e){return this.execute("post","/api/folder",e)}async updateFolder(e){return this.execute("put","/api/folder",e)}async deleteFolder(e){return this.execute("delete","/api/folder",{id:e})}async renameFolder(e,t){return this.updateFolder({_id:e,name:t})}async moveFolders(e){return this.execute("post","/api/folder/move",e)}async getFolderPath(e){return e?("object"==typeof e&&(e=e._id),this.execute("get","/api/folder/path/"+e)):{path:"/",elements:[]}}async resolveFolderPath(e){return"/"===(e=e.trim())?null:this.execute("post","/api/folder/resolve",{path:e})}async getFolderClient(e){return this.execute("get",`/api/folder/getClient/${e}`)}async getFolderAcl(e){const t=await this.folderCache.getFolderACLs(e||"0",1e4);if(t&&e)return t;{const t=await this.execute("get",`/api/folder/acl/${e||"0"}`);return await this.folderCache.addACL(e||"0",t),t}}async getFolderAclList(e){return this.execute("post","/api/folder/aclquery",{ids:e})}async getUser(e){return this.execute("get","/api/user/"+e)}async getUsersList(){return this.execute("get","/api/user")}async createUser(e){return this.execute("post","/api/user",e)}async queryUser(e,t,a){return this.execute("post","/api/user/query",{searchQuery:e,groupID:t,cursor:a},{withNext:!0})}async updateUser(e){return this.execute("put","/api/user",e)}async deleteUser(e){return this.execute("delete","/api/user",{id:e})}async updateMyProfile(e){return this.execute("put","/api/user/myprofile",e)}async switchClient(e){return this.execute("get",`/api/user/switchclient/${e}`)}async activateUser(e,t){return this.execute("post","/api/user/activate",{token:t,password:e})}async getUsersToApprove(){return this.execute("get","/api/user/approvals")}async approveUserRegistration(e){return this.execute("get",`/api/user/approveuserregistration/${e}`)}async rejectUserRegistration(e){return this.execute("get",`/api/user/rejectuserregistration/${e}`)}async uploadAvatar(e){const t=new r;if(e instanceof Blob)t.append("file",e);else{const a=new Blob([new Uint8Array(e)]);t.append("file",a,"avatar.jpg")}return this.execute("post","/api/user/uploadAvatar",t)}async clearAvatar(){return this.execute("get","/api/user/clearAvatar")}async getAvatar(e,t){return this.execute("get",`/api/user/avatar/${t}/${e}`)}async getUserPublicInfo(e,t,a){return this.execute("get",`/api/user/publicinfo/${e}/${t}/${a}`)}async getUserAttribute(e){return this.execute("get",`/api/user/attribute/${e}`)}async clearUserAttribute(e){return this.execute("delete",`/api/user/attribute/${e}`)}async setUserAttribute(e,t){return this.execute("post",`/api/user/attribute/${e}`,t)}async getGroup(e){return this.execute("get","/api/group/"+e)}async getGroupFolder(e){return this.execute("get","/api/group/folder/"+e)}async getGroupsList(){return this.execute("get","/api/group")}async createGroup(e){return this.execute("post","/api/group",e)}async queryGroup(e,t){return this.execute("post","/api/group/query",{searchQuery:e,cursor:t},{withNext:!0})}async updateGroup(e){return this.execute("put","/api/group",e)}async deleteGroup(e){return this.execute("delete","/api/group",{id:e})}async getGroupQuotaInfo(e){return this.execute("get","/api/group/quota/"+e)}async getGroupPublicInfo(e,t,a){return this.execute("get",`/api/group/publicinfo/${e}/${t}/${a}`)}async getGroupUsers(e){return this.execute("get","/api/group/users/"+e)}async uploadGroupAvatar(e,t){const a=new r;if(t instanceof Blob)a.append("file",t);else{const e=new Blob([new Uint8Array(t)]);a.append("file",e,"avatar.jpg")}return this.execute("post","/api/group/"+e+"/uploadAvatar",a)}async getClientsList(){return this.execute("get","/api/client")}async getClient(e){return this.execute("get",`/api/client/${e}`)}async createClient(e){return this.execute("post","/api/client",e)}async queryClient(e,t){return this.execute("post","/api/client/query",{searchQuery:e,cursor:t},{withNext:!0})}async updateClient(e){return this.execute("put","/api/client",e)}async deleteClient(e){return this.execute("delete","/api/client",{id:e})}async getClientMetrics(e,t,a){return this.execute("get",`/api/client/metrics/${t}/${a}/${e}`)}async joinClient(e){return this.execute("get",`/api/client/join/${e}`)}async leaveClient(e){return this.execute("get",`/api/client/leave/${e}`)}async myClient(){return this.execute("get","/api/client/my")}async saveMyClient(e){return this.execute("put","/api/client/my",e)}async getPublicCategories(e){return this.execute("get",`/api/client/publiccategories/${e}`)}async getCategories(){return this.execute("get","/api/client/categories")}async getCategoriesInClient(e){return this.execute("get",`/api/client/categories/${e}`)}async updateCategoriesInClient(e,t){return this.execute("post",`/api/client/categories/${e}`,t)}async getLicenses(){return this.execute("get","/api/license")}async getLicensesInClient(e){return this.execute("get",`/api/license/inclient/${e}`)}async getLicense(e){return this.execute("get",`/api/license/${e}`)}async createLicense(e){return this.execute("post","/api/license",e)}async updateLicense(e){return this.execute("put","/api/license",e)}async deleteLicense(e,t){return this.execute("delete","/api/license",{_id:e,client:t})}async getPublicLicenses(e){return this.execute("get",`/api/license/publiclist/${e}`)}async getPublicLicense(e){return this.execute("get",`/api/license/public/${e}`)}async getDatatypesList(){return this.execute("get","/api/datatype")}async getPublicDatatypesList(e){return this.execute("get",`/api/datatype/public/${e}`)}async getDatatypesListOnClient(){return this.execute("get","/api/datatype/onclient")}async getDatatypesListOnClientForAll(){return this.execute("get","/api/datatype/onclientforall")}async getAllDatatypesList(){return this.execute("get","/api/datatype/all")}async getDatatype(e){return this.execute("get",`/api/datatype/${e}`)}async createDatatype(e){return this.execute("post","/api/datatype",e)}async updateDatatype(e){return this.execute("put","/api/datatype",e)}async deleteDatatype(e){return this.execute("delete","/api/datatype",{id:e})}async getMyNotifications(e){return this.execute("get","/api/notification"+(e?`?maxCount=${e}`:""))}async markNotificationAsRead(e){return this.execute("get",`/api/notification/markasread/${e}`)}async markAllNotificationsAsRead(){return this.execute("get","/api/notification/markallasread")}async createJob(e){return this.execute("post","/api/job",e,{emitOnSuccess:"job:created"})}async getManualJobTypes(){return this.execute("get","/api/job/manualtypes")}async getManualJobTypesOnClient(){return this.execute("get","/api/job/manualtypes/onclient")}async getManualJobTypesOnClientForAll(){return this.execute("get","/api/job/manualtypes/onclientforall")}async getAllManualJobTypes(){return this.execute("get","/api/job/manualtypes/all")}async getAllManualJobTypesForClient(e){return this.execute("get",`/api/job/manualtypes/all/${e}`)}async getClientJobTypes(){return this.execute("get","/api/job/clientTypes")}async getMyJobs(){return this.execute("get","/api/job/mine")}async getJobs(){return this.execute("get","/api/job")}async getJobsAggregated(){return this.execute("get","/api/job/aggregated")}async getJobsTimeframe(e,t){return this.execute("get",`/api/job/all/${e}/${t}`)}async getJob(e){return this.execute("get",`/api/job/${e}`)}async getJobState(e){return this.execute("get",`/api/job/state/${e}`)}async getAgents(){return this.execute("get","/api/jobagent")}async getAgentsAggregated(){return this.execute("get","/api/jobagent/aggregated")}async enableJobAgent(e){return this.execute("get",`/api/jobagent/enable/${e}`)}async disableJobAgent(e){return this.execute("get",`/api/jobagent/disable/${e}`)}async restartJobAgent(e){return this.execute("get",`/api/jobagent/restart/${e}`)}async getPermissionsList(){return this.execute("get","/api/permission")}async getPlugins(){return this.execute("get","/api/plugin")}async getPlans(){return this.execute("get","/api/plan")}async getPlan(e){return this.execute("get",`/api/plan/${e}`)}async createPlan(e){return this.execute("post","/api/plan",e)}async updatePlan(e){return this.execute("put","/api/plan",e)}async deletePlan(e){return this.execute("delete","/api/plan",{id:e})}async getWorkflows(){return this.execute("get","/api/workflow")}async getWorkflow(e){return this.execute("get",`/api/workflow/${e}`)}async createWorkflow(e){return this.execute("post","/api/workflow",e)}async updateWorkflow(e){return this.execute("put","/api/workflow",e)}async deleteWorkflow(e){return this.execute("delete","/api/workflow",{id:e})}async startWorkflow(e){return this.execute("post","/api/workflow/start",e)}async getAccessTokens(){return this.execute("get","/api/accesstoken")}async getClientAccessTokens(){return this.execute("get","/api/accesstoken/client")}async createAccessToken(e){return this.execute("post","/api/accesstoken",e)}async createClientAccessToken(e){return this.execute("post","/api/accesstoken/client",e)}async deleteAccessToken(e){return this.execute("delete","/api/accesstoken",{id:e})}async deleteClientAccessToken(e){return this.execute("delete","/api/accesstoken/client",{id:e})}async enableAccessToken(e){return this.execute("get",`/api/accesstoken/enable/${e}`)}async disableAccessToken(e){return this.execute("get",`/api/accesstoken/disable/${e}`)}async getApiTokens(){return this.execute("get","/api/apitoken")}async createApiToken(e){return this.execute("post","/api/apitoken",e)}async deleteApiToken(e){return this.execute("delete","/api/apitoken",{id:e})}async getMyClientInvoices(){return this.execute("get","/api/invoice")}async getMyUserInvoices(){return this.execute("get","/api/invoice/my")}async getClientInvoices(e){return this.execute("get",`/api/invoice/client/${e}`)}async downloadInvoice(e,t){const a=await this.execute("get",`/api/invoice/download/${e}`,null,{responseType:"arraybuffer"}),i=window.URL.createObjectURL(a.blob),n=document.createElement("a");n.href=i,n.setAttribute("download",t||"invoice.pdf"),document.body.appendChild(n),n.click()}async regenerateInvoice(e){return this.execute("get",`/api/invoice/regenerate/${e}`)}async getInvoicesForMonth(e,t){return this.execute("get",`/api/invoice/month/${t}/${e}`)}async refundInvoice(e,t,a){return this.execute("post","/api/invoice/refund",{invoice:e,amount:t,reason:a})}async paymentStartCheckout(e,t){return this.execute("post","/api/payment/checkout",{successUrl:e,cancelUrl:t})}async paymentStartUserCheckout(e,t){return this.execute("post","/api/payment/usercheckout",{successUrl:e,cancelUrl:t})}async getSupportedCurrencies(){return this.execute("get","/api/payment/supportedCurrencies")}async getPurchasables(){return this.execute("get","/api/purchasable")}async getPurchasable(e){return this.execute("get",`/api/purchasable/${e}`)}async createPurchasable(e){return this.execute("post","/api/purchasable",e)}async updatePurchasable(e){return this.execute("put","/api/purchasable",e)}async deletePurchasable(e){return this.execute("delete","/api/purchasable",{id:e})}async getPublicPurchasables(e){return this.execute("get",`/api/purchasable/public/${e}`)}async getPurchases(){return this.execute("get","/api/purchase")}async getMyActivePurchases(){return this.execute("get","/api/purchase/active")}async purchase(e){return this.execute("post","/api/purchase",e)}async changePurchaseProduct(e,t,a){return this.execute("post","/api/purchase/change",{purchaseID:e,purchasableID:t,optionID:a})}async cancelPurchase(e){return this.execute("delete","/api/purchase",{id:e})}async uncancelPurchase(e){return this.execute("post","/api/purchase/uncancel",{id:e})}async getSecureSessionPayload(e,t){return this.execute("get","/api/payment/secureSessionPayload?purchasableID="+e+"&optionID="+t)}async queryPurchases(e,t,a,i,n,r){return this.execute("post","/api/purchase/query",{startDate:e,endDate:t,email:a,invoice:i,cursor:n,limit:r})}async getAttributeTemplates(){return this.execute("get","/api/attributetemplate")}async getAttributeTemplate(e){return this.execute("get",`/api/attributetemplate/${e}`)}async createAttributeTemplate(e){return this.execute("post","/api/attributetemplate",e)}async updateAttributeTemplate(e){return this.execute("put","/api/attributetemplate",e)}async deleteAttributeTemplate(e){return this.execute("delete","/api/attributetemplate",{id:e})}async getStorages(){return this.execute("get","/api/storage")}async getConversation(e){return this.execute("get",`/api/conversation/${e}`)}async getPublicConversation(e){return this.execute("get",`/api/conversation/public/${e}`)}async createConversation(e,t){return this.execute("post","/api/conversation",{parentId:e,parentType:t})}async postConversationMessage(e,t,a){return this.execute("post","/api/conversation/post",{id:e,text:t,replyTo:a})}async editConversationMessage(e,t){return this.execute("put","/api/conversation/post",{id:e,text:t})}async deleteConversationMessage(e){return this.execute("delete","/api/conversation/post",{id:e})}async subscribeToConversation(e){return this.execute("post","/api/conversation/subscribe",{id:e})}async unsubscribeFromConversation(e){return this.execute("post","/api/conversation/unsubscribe",{id:e})}async likeConversationEntry(e){return this.execute("post","/api/conversation/like",{id:e})}async unlikeConversationEntry(e){return this.execute("post","/api/conversation/unlike",{id:e})}async command(e){return this.execute("post","/api/command",e)}async getMailTemplates(){return this.execute("get","/api/mailtemplate")}async getMailTemplate(e){return this.execute("get",`/api/mailtemplate/${e}`)}async createMailTemplate(e){return this.execute("post","/api/mailtemplate",e)}async updateMailTemplate(e){return this.execute("put","/api/mailtemplate",e)}async deleteMailTemplate(e){return this.execute("delete","/api/mailtemplate",{id:e})}async addMailTemplateImage(e,t,a){const i=this._createFormData(a,"image.jpg");return this.execute("post",`/api/mailtemplate/image/${e}/${t}`,i)}async deleteMailTemplateImage(e,t){return this.execute("delete",`/api/mailtemplate/image/${e}/${t}`)}async getMailTemplateNames(){return this.execute("get","/api/mailtemplate/names")}async getMailQuery(e,t,a,i){return this.execute("post","/api/email/query",{templateName:e,dateStart:t,dateEnd:a,success:i},{withNext:!0})}async getMail(e){return this.execute("get","/api/email/get?token="+e)}async getInvoiceTemplates(){return this.execute("get","/api/invoicetemplate")}async getInvoiceTemplate(e){return this.execute("get",`/api/invoicetemplate/${e}`)}async createInvoiceTemplate(e){return this.execute("post","/api/invoicetemplate",e)}async updateInvoiceTemplate(e){return this.execute("put","/api/invoicetemplate",e)}async deleteInvoiceTemplate(e){return this.execute("delete","/api/invoicetemplate",{id:e})}async addInvoiceTemplateImage(e,t,a){const i=this._createFormData(a,"image.jpg");return this.execute("post",`/api/invoicetemplate/image/${e}/${t}`,i)}async deleteInvoiceTemplateImage(e,t){return this.execute("delete",`/api/invoicetemplate/image/${e}/${t}`)}async getItemTemplatesList(){return this.execute("get","/api/itemtemplate/list")}async getItemTemplates(){return this.execute("get","/api/itemtemplate")}async createItemTemplate(e){return this.execute("post","/api/itemtemplate",e)}async updateItemTemplate(e){return this.execute("put","/api/itemtemplate",e)}async deleteItemTemplate(e){return this.execute("delete","/api/itemtemplate",{id:e})}async getFeatures(){return this.execute("get","/api/feature")}async getFeaturesOnClient(){return this.execute("get","/api/feature/onclient")}async getFeaturesOnClientForAll(){return this.execute("get","/api/feature/onclientforall")}async getAllFeatures(){return this.execute("get","/api/feature/all")}async getBlogs(){return this.execute("get","/api/blog")}async getBlog(e){return this.execute("get","/api/blog/"+e)}async getPublicBlog(e){return this.execute("get","/api/blog/"+e+"/public")}async createBlog(e,t,a,i){return this.execute("post","/api/blog",{name:e,public:t,commentsEnabled:a,editors:i})}async saveBlog(e,t,a,i,n){return this.execute("put","/api/blog",{_id:e,name:t,public:a,commentsEnabled:i,editors:n})}async deleteBlog(e){return this.execute("delete","/api/blog",{_id:e})}async getBlogOverview(e){return this.execute("get","/api/blog/"+e+"/overview")}async queryBlog(e,t,a,i,n,r,s){return this.execute("post","/api/blog/"+e+"/query",{tag:t,text:a,limit:i,previousArticle:n,searchTag:r,sortBy:s})}async getArticles(e){return this.execute("get","/api/blog/"+e+"/article")}async getArticle(e,t){return this.execute("get","/api/blog/"+e+"/article/"+t)}async getArticleBySlug(e,t){return this.execute("get","/api/blog/article/"+e+"/"+t)}async createArticle(e,t,a){return this.execute("post","/api/blog/"+e+"/article",{title:t,slug:a})}async saveArticle(e,t,a,i,n,r,s,o){return this.execute("put","/api/blog/"+e+"/article",{_id:t,title:a,slug:i,content:o,tags:r,public:n,author:s})}async deleteArticle(e,t){return this.execute("delete","/api/blog/"+e+"/article",{_id:t})}async getNewsletters(){return this.execute("get","/api/newsletter")}async createNewsletter(e,t){return this.execute("post","/api/newsletter",{name:e,editors:t})}async getNewsletter(e){return this.execute("get","/api/newsletter/"+e)}async updateNewsletter(e,t,a,i){return this.execute("put","/api/newsletter/"+e,{name:t,sender:a,editors:i})}async deleteNewsletter(e){return this.execute("delete","/api/newsletter/"+e)}async joinNewsletter(e,t){return this.execute("post","/api/newsletter/join",{id:e,email:t})}async confirmNewsletter(e){return this.execute("post","/api/newsletter/confirm",{token:e})}async unsubscribeFromNewsletter(e){return this.execute("post","/api/newsletter/unsubscribe",{token:e})}async getNewsletterBlocks(){return this.execute("get","/api/newsletterblock")}async getNewsletterBlock(e){return this.execute("get","/api/newsletterblock/"+e)}async createNewsletterBlock(e){return this.execute("post","/api/newsletterblock",{name:e})}async updateNewsletterBlock(e,t,a,i,n,r){return this.execute("put","/api/newsletterblock/"+e,{name:t,inputs:a,html:i,css:n,acceptsChildren:r})}async deleteNewsletterBlock(e){return this.execute("delete","/api/newsletterblock/"+e)}async getNewsletterMails(e){return this.execute("get","/api/newslettermail/"+e)}async getNewsletterMail(e,t){return this.execute("get","/api/newslettermail/"+e+"/"+t)}async createNewsletterMail(e,t){return this.execute("post","/api/newslettermail/"+e,{title:t})}async updateNewsletterMail(e,t,a,i,n){return this.execute("put","/api/newslettermail/"+e+"/"+t,{title:a,blocks:i,parentBlock:n})}async generatePreviewNewsletterMail(e,t){return this.execute("post","/api/newslettermail/render",{blocks:e,parentBlock:t})}async sendTestNewsletter(e,t,a){return this.execute("post","/api/newslettermail/"+e+"/"+t+"/sendTest",{email:a})}async sendOutNewsletter(e,t){return this.execute("post","/api/newslettermail/"+e+"/"+t+"/send",{})}async getPages(){return this.execute("get","/api/page")}async createPage(e,t){return this.execute("post","/api/page",{title:e,slug:t})}async getPage(e){return this.execute("get","/api/page/"+e)}async updatePage(e,t,a,i,n){return this.execute("put","/api/page",{_id:e,title:t,slug:a,public:i,content:n})}async deletePage(e){return this.execute("delete","/api/page",{_id:e})}async getPublicPage(e,t){return this.execute("get","/api/page/public/"+e+"/"+t)}async setItemFlag(e,t,a,i,n,r){return this.execute("post","/api/itemflag",{item:e,isStaffPick:t,featureWeight:a,isGame:i,replaceIndex:n,internalRating:r})}getDownloadUrl(e){return`${this.getApiBaseUrl()}/api/item/download/${e}`}getAttachmentDownloadUrl(e,t,a,i){return`${this.getApiBaseUrl()}${this._getAttachmentUrlPath(e,t,a,i)}`}getPublicAttachmentDownloadUrl(e,t,a,i){return`${this.getApiBaseUrl()}${this._getAttachmentUrlPath(e,t,a,i,!0)}`}getPublicDownloadUrl(e){return`${this.getApiBaseUrl()}/api/item/publicdownload/${e}`}async postFeedback(e){return this.execute("post","/api/feedback",{text:e})}},e.ApiGateway=L,e.Block=ae,e.CustomField=J,e.EventEmitter=l,e.Field=Z,e.InvalidArgumentException=_,e.InvalidStateException=class extends w{constructor(e){super(e,"InvalidStateException")}},e.Item=T,e.ItemCache=Fr,e.ItemRepo=jn,e.ItemVisibility=Rd,e.LinkableItemsCache=class{linkableItemsCache;apiGateway;itemCache;usePublicApi;constructor(e,t,a=!1){this.linkableItemsCache=new Map,this.apiGateway=e,this.itemCache=t,this.usePublicApi=a}clear(){this.linkableItemsCache.clear()}resolveItem(e,t){for(const a of t)if(a._id===e)return a;return null}async loadLinkableItems(e,t){if(!e)throw"loadLinkableItems(): Item cannot be null!";let a=[];if(t.linkableTypes&&t.linkableTypes.length){if(!this.usePublicApi){const i=t.linkableTypes.join("#")+(e.folder?e.folder._id:"");if(this.linkableItemsCache.has(i))return this.linkableItemsCache.get(i);const n=[...t.linkableTypes];n.includes("Package")||n.push("Package");const r={types:n,folder:e.folder?e.folder._id:null};a=(await this.apiGateway.call("LinkableItemsCache::loadLinkableItems","queryItemsList",r)).filter((e=>"Package"!==e.type||t.linkableTypes.includes(e.packageType)));for(const i of e.links)if(null==this.resolveItem(i.to,a))try{const e=await this.itemCache.getItem(i.to);t.linkableTypes.includes(e.type)&&a.push(e)}catch(e){console.error(`Link item ${i.to} not found. Dead link? (${e})`)}this.linkableItemsCache.set(i,a)}}else{for(const t of e.links){const e=await this.itemCache.getItem(t.to);a.push(e)}const i=t.name+"#CurrentLinks";this.linkableItemsCache.set(i,a)}return a}},e.LoaderException=k,e.PackageTools=Bn,e.PreparedItem=K,e.Profiler=v,e.Proxifier=g,e.ProxyEvent=c,e.QuotaExceededException=S,e.Script=W,e.ScriptField=j,e.Snapshot=O,e.Storage=Jn,e.Template=Q,e.TemplateFactory=ee,e.ThumbCache=Rr,e.UndoManager=$n,e.eventBus=u,e.getDatatypeByName=C,e.getDatatypes=function(){return structuredClone(x)},e.hasPermission=function(e,t,a){if(e.admin&&!a)return!0;if(e.superadmin)return!0;if(Array.isArray(e.permissions))if(Array.isArray(t)){for(const a of e.permissions)for(const e of t)if(a===e)return!0}else for(const a of e.permissions)if(a===t)return!0;return!1},e.profileAsyncBlock=async function(e,t){return v.instance.asyncBlock(e,t)},e.profileBlock=function(e,t){return v.instance.block(e,t)},e.tools=h,e.verifyAcl=X}));
19
19
  //# sourceMappingURL=lemonate-gateway.umd.js.map